jQuery(document).ready((e=>{if("woocommerce_page_wc-settings"!==(window.pagenow||""))return;window.serialize_form=s=>{let a=e(s).serializeArray();return a=e.grep(a,(e=>"_wp_http_referer"!==e.name&&"_wpnonce"!==e.name)),a.sort(((e,s)=>e.name>s.name?1:-1)),a};var s,a,t=new window.URLSearchParams(window.location.search);let r,c=e("#wc_square_location_id, #wc_square_sandbox_location_id").val(),n=e(".wc_square_save_changes_message");"square"!==t.get("tab")||t.get("section")&&""===t.get("section")||(a=serialize_form(e("#mainform"))),e(document).on("change",(function(s,a){if(a)return;const t=e("#wc_square_import_products").closest("tr");r&&c&&c.length?t.show():t.hide()})),e("#mainform :input").on("change",(function(t,r){if(r)return;const c=e("#wc_square_import_products");if(s=serialize_form("#mainform"),JSON.stringify(a)!==JSON.stringify(s)){if("wc_square_sandbox_location_id"===t.target.name||"wc_square_location_id"===t.target.name)return;n.show(),c.addClass("disabled")}else n.hide(),c.removeClass("disabled")})),e("#wc_square_sandbox_location_id, #wc_square_location_id").on("change",(function(){c=e(this).val()})),wc_square_admin_settings.is_sandbox||(e("#wc_square_sandbox_settings").hide(),e("#wc_square_sandbox_settings").next().hide(),e(".wc_square_sandbox_settings").closest("tr").hide()),e("#wc_square_system_of_record").on("change",(s=>{const a=e(s.target).val(),t=e("#wc_square_enable_inventory_sync"),c=t.closest("tr"),n=e("#wc_square_import_products").closest("tr"),o=e("#wc_square_override_product_images").closest("tr"),i=e("#wc_square_sync_interval").closest("tr");"square"===a||"woocommerce"===a?(r=!0,t.next("span").html(wc_square_admin_settings.i18n.sync_inventory_label[a]),c.find(".description").html(wc_square_admin_settings.i18n.sync_inventory_description[a]),c.show(),n.show(),i.show()):(r=!1,t.prop("checked",!1),c.hide(),n.hide(),o.hide(),i.hide()),"square"===a?(e("#wc_square_hide_missing_products").closest("tr").show(),o.show()):(e("#wc_square_hide_missing_products").closest("tr").hide(),o.hide())})).trigger("change",[!0]),e(".js-import-square-products").on("click",(function(s){s.preventDefault(),e(this).hasClass("disabled")||(new e.WCBackboneModal.View({target:"wc-square-import-products"}),e("#btn-close").on("click",(s=>{s.preventDefault(),e("button.modal-close").trigger("click")})))})),e("#wc-square-sync").on("click",(s=>{s.preventDefault(),new e.WCBackboneModal.View({target:"wc-square-sync"}),e("#btn-close").on("click",(s=>{s.preventDefault(),e("button.modal-close").trigger("click")}))})),e(document.body).on("wc_backbone_modal_response",((s,a)=>{let t;switch(a){case"wc-square-import-products":e("#wpbody").block({message:null,overlayCSS:{opacity:"0.2"},onBlock:function(){e(".blockUI.blockOverlay").css({position:"fixed"})}});const s=e("#wc-square-import-product-updates").prop("checked");t={action:"wc_square_import_products_from_square",security:wc_square_admin_settings.import_products_from_square,update_during_import:s},e.post(wc_square_admin_settings.ajax_url,t,(e=>{const s=e.data?e.data:null;s&&alert(s),location.href="admin.php?page=wc-settings&tab=square§ion=update"}));break;case"wc-square-sync":e("table.sync").block({message:null,overlayCSS:{opacity:"0.2"}}),e("table.records").block({message:null,overlayCSS:{opacity:"0.2"}}),e("#wc-square_clear-sync-records").prop("disabled",!0),t={action:"wc_square_sync_products_with_square",security:wc_square_admin_settings.sync_products_with_square},e.post(wc_square_admin_settings.ajax_url,t,(s=>{s&&s.success?location.reload():(e("#wc-square_clear-sync-records").prop("disabled",!1),e("table.sync").unblock(),e("table.records").unblock())}))}}));const o='