(()=>{var t,i;window.shiptastic=window.shiptastic||{},window.shiptastic.admin=window.shiptastic.admin||{},t=jQuery,(i=window.shiptastic).admin.shipments_table={params:{},init:function(){var a=i.admin.shipments_table;a.params=wc_shiptastic_admin_shipments_table_params,a.initEnhanced(),t(document).on("click","#doaction, #doaction2",a.onBulkSubmit),t(".has-shipment-modal").wc_shiptastic_admin_shipment_modal(),t(document.body).on("init_tooltips",(function(){a.initTipTip()})),a.initTipTip()},onBulkSubmit:function(){var a=i.admin.shipments_table,e=t(this).parents(".bulkactions").find("select[name^=action]").val(),n=t(this).parents("#posts-filter").find("input.shipment_type").val(),s=[];if(t("#posts-filter").find('input[name="shipment[]"]:checked').each((function(){s.push(t(this).val())})),a.params.bulk_actions.hasOwnProperty(e)&&s.length>0){var c=a.params.bulk_actions[e];return t(".bulk-action-wrapper").find(".bulk-title").text(c.title),t("#posts-filter").addClass("bulk-action-processing"),t("#posts-filter").find(".bulkactions button").prop("disabled",!0),a.handleBulkAction(e,1,s,n),!1}},handleBulkAction:function(a,e,n,s){var c=i.admin.shipments_table,o=c.params.bulk_actions[a];t.ajax({type:"POST",url:c.params.ajax_url,data:{action:"woocommerce_stc_shipments_bulk_action_handle",bulk_action:a,step:e,type:s,referer:window.location.href,ids:n,security:o.nonce},dataType:"json",success:function(i){i.success&&("done"===i.data.step?(t(".bulk-action-wrapper").find(".woocommerce-shimpents-bulk-progress").val(i.data.percentage),window.location=i.data.url,setTimeout((function(){t("#posts-filter").removeClass("bulk-action-processing"),t("#posts-filter").find(".bulkactions button").prop("disabled",!1)}),2e3)):(t(".bulk-action-wrapper").find(".woocommerce-shimpents-bulk-progress").val(i.data.percentage),c.handleBulkAction(a,parseInt(i.data.step,10),i.data.ids,i.data.type)))}}).fail((function(t){window.console.log(t)}))},initTipTip:function(){t(".column-actions .wc-stc-shipment-action-button").tipTip({fadeIn:50,fadeOut:50,delay:200})},initEnhanced:function(){try{t(document.body).on("wc-enhanced-select-init",(function(){t(":input.wc-stc-order-search").filter(":not(.enhanced)").each((function(){var i={allowClear:!!t(this).data("allow_clear"),placeholder:t(this).data("placeholder"),minimumInputLength:t(this).data("minimum_input_length")?t(this).data("minimum_input_length"):"1",escapeMarkup:function(t){return t},ajax:{url:wc_shiptastic_admin_shipments_table_params.ajax_url,dataType:"json",delay:1e3,data:function(i){return{term:i.term,action:"woocommerce_stc_json_search_orders",security:wc_shiptastic_admin_shipments_table_params.search_orders_nonce,exclude:t(this).data("exclude")}},processResults:function(i){var a=[];return i&&t.each(i,(function(t,i){a.push({id:t,text:i})})),{results:a}},cache:!0}};t(this).selectWoo(i).addClass("enhanced")})),t(":input.wc-stc-shipping-provider-search").filter(":not(.enhanced)").each((function(){var i={allowClear:!!t(this).data("allow_clear"),placeholder:t(this).data("placeholder"),minimumInputLength:t(this).data("minimum_input_length")?t(this).data("minimum_input_length"):"1",escapeMarkup:function(t){return t},ajax:{url:wc_shiptastic_admin_shipments_table_params.ajax_url,dataType:"json",delay:1e3,data:function(i){return{term:i.term,action:"woocommerce_stc_json_search_shipping_provider",security:wc_shiptastic_admin_shipments_table_params.search_shipping_provider_nonce,exclude:t(this).data("exclude")}},processResults:function(i){var a=[];return i&&t.each(i,(function(t,i){a.push({id:t,text:i})})),{results:a}},cache:!0}};t(this).selectWoo(i).addClass("enhanced")}))})),t("html").on("click",(function(i){this===i.target&&(t(":input.wc-stc-order-search").filter(".select2-hidden-accessible").selectWoo("close"),t(":input.wc-stc-shipping-provider-search").filter(".select2-hidden-accessible").selectWoo("close"))}))}catch(t){window.console.log(t)}}},t(document).ready((function(){i.admin.shipments_table.init()})),((window.wcShiptastic=window.wcShiptastic||{}).static=window.wcShiptastic.static||{})["admin-shipments-table"]={}})();