(()=>{var i,e;window.shiptastic=window.shiptastic||{},window.shiptastic.admin=window.shiptastic.admin||{},i=jQuery,(e=window.shiptastic).admin.shipping_provider_method={params:{},currentProvider:"",init:function(){var n=e.admin.shipping_provider_method;n.params=wc_shiptastic_admin_shipping_provider_method_params,i(document).on("change","select[id$=shipping_provider]",n.showOrHideAll).on("click",".wc-stc-shipping-provider-method-tabs .nav-tab-wrapper a.nav-tab",n.onChangeTab).on("change",".override-checkbox :input",n.onChangeOverride).on("change",".wc-stc-shipping-provider-method-tab-content :input[id]",n.onChangeInput),i(document.body).on("wc_backbone_modal_loaded",n.onShippingMethodOpen),i("select[id$=shipping_provider]").length>0&&i("select[id$=shipping_provider]").trigger("change")},onChangeInput:function(){e.admin.shipment_settings.onChangeInput.call(i(this))},parseFieldId:function(i){return i.replace("[","_").replace("]","")},onChangeOverride:function(){e.admin.shipping_provider_method;var n=i(this),t=n.is(":checked"),r=n.parents(".wc-stc-shipping-provider-override-wrapper");t?r.find(".wc-stc-shipping-provider-override-inner-wrapper").addClass("has-override"):r.find(".wc-stc-shipping-provider-override-inner-wrapper").removeClass("has-override")},onChangeTab:function(){e.admin.shipping_provider_method;var n=i(this),t=n.parents("form"),r=n.attr("href").replace("#",""),a=t.find('.wc-stc-shipping-provider-method-tab-content[data-tab="'+r+'"]');return n.parents(".wc-stc-shipping-provider-method-tabs").find(".nav-tab-active").removeClass("nav-tab-active"),t.find(".wc-stc-shipping-provider-method-tab-content").removeClass("tab-content-active"),a.length>0&&(n.addClass("nav-tab-active"),a.addClass("tab-content-active"),a.find(":input:visible").trigger("change")),!1},getCleanInputId:function(i){var n=e.admin.shipping_provider_method.currentProvider,t=i.attr("id")?i.attr("id"):i.attr("name");return!!t&&(n&&t.toLowerCase().indexOf("-p-"+n+"-")>=0?t.substring(t.lastIndexOf("-p-"+n+"-"),t.length):t)},onShippingMethodOpen:function(e,n){"wc-modal-shipping-method-settings"===n&&($wrapper=i(".wc-modal-shipping-method-settings"),i("select[id$=shipping_provider]").length>0&&$wrapper.find("select[id$=shipping_provider]").trigger("change"))},showOrHideAll:function(){var n=e.admin.shipping_provider_method,t=i(this),r=t.parents("form");n.currentProvider=t.val(),r.find(".wc-stc-shipping-provider-method-tabs").hide(),r.find(".wc-stc-shipping-provider-method-tab-content").removeClass("tab-content-active"),n.currentProvider.length>0&&(r.find('.wc-stc-shipping-provider-method-tabs[data-provider="'+n.currentProvider+'"]').show(),r.find('.wc-stc-shipping-provider-method-tabs[data-provider="'+n.currentProvider+'"] .nav-tab-wrapper').find("a.nav-tab:first").trigger("click"))}},i(document).ready((function(){e.admin.shipping_provider_method.init()})),((window.wcShiptastic=window.wcShiptastic||{}).static=window.wcShiptastic.static||{})["admin-shipping-provider-method"]={}})();