(()=>{var e,i;window.shiptastic=window.shiptastic||{},window.shiptastic.admin=window.shiptastic.admin||{},e=jQuery,(i=window.shiptastic).admin.shipment_label={params:{},init:function(){var t=i.admin.shipment_label;e(document).on("change",".shipments-create-label #product_id",t.onChangeLabelProductId),e(document).on("change",".label-service-list input[type=checkbox]",t.onChangeLabelService)},onChangeLabelService:function(){var i=e(".shipments-create-label").find("p.form-field :input[data-exclude-if-checked]"),t=[],n=e(this);e(".label-service-list input[type=checkbox]:checked").each((function(){let i=e(this).attr("name");i.includes("service_")&&t.push(i.replace("service_",""))})),i.each((function(){var i=e(this),a=i.data("exclude-if-checked");if(n.get(0)===i.get(0))return null;if(a.length>0){let e=a.split(",").filter(Boolean);t.filter((i=>e.includes(i))).length>0?(i.prop("checked",!1),i.parents(".form-field").hide()):i.parents(".form-field").show()}}))},onChangeLabelProductId:function(){i.admin.shipment_label.showOrHideByLabelProduct(e(this).val())},showOrHideByLabelProduct:function(i){e(".shipments-create-label").find("p.form-field :input[data-products-supported]").each((function(){var t=e(this),n=t.data("products-supported");if(n.length>0)if(n.indexOf("&")>-1&&t.is("select")){var a=n.split("&").filter(Boolean),c=!1;e.each(a,(function(n,a){var r=a.split("=").filter(Boolean);if(r.length>1){var s=r[0],l=r[1].split(","),o=!0,d=t.find('option[value="'+s+'"]');d.length>0&&(-1!==e.inArray(i,l)&&(o=!1),o?(d.is(":selected")&&(c=!0),d.hide()):d.show())}}));var r=!0;t.find("option").each((function(){if("none"!==e(this).css("display"))return c&&e(this).prop("selected",!0),r=!1,!1})),r?(t.parents(".form-field").hide(),t.trigger("change")):(t.parents(".form-field").show(),t.trigger("change")),t.trigger("change")}else{var s=n.split(",").filter(Boolean),l=s.length>0;-1!==e.inArray(i,s)&&(l=!1),l?(t.parents(".form-field").hide(),t.trigger("change")):(t.parents(".form-field").show(),t.trigger("change"))}}))}},e(document).ready((function(){i.admin.shipment_label.init()})),((window.wcShiptastic=window.wcShiptastic||{}).static=window.wcShiptastic.static||{})["admin-shipment-label"]={}})();