!function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=window.ctFrontend,n=window.ctEvents,o=e.n(n);let i={};const c=function(e){const t=new URLSearchParams;t.append("action","blocksy_get_woo_size_guide"),t.append("table_id",e.dataset.table_id),t.append("product_id",function(e){if(e.dataset.product_id)return parseInt(e.dataset.product_id);const t=e.closest(".product");if(!t)return null;const n=Array.from(t.classList).find(function(e){return 0===e.indexOf("post-")}).split("-")[1];return parseInt(n)}(e)),window.wp&&window.wp.customize&&(t.append("size_guide_placement",wp.customize("size_guide_placement")()),t.append("size_guide_side_panel_position",wp.customize("size_guide_side_panel_position")()));const n=`${ct_localizations.ajax_url}?${t.toString()}`;return{isCached:!!i[n],fetch:function(){return new Promise(function(e){var t;(t=n,i[t]?new Promise(function(e){e(i[t]),i[t]=i[t].clone()}):new Promise(function(e){return fetch(t).then(function(n){e(n),i[t]=n.clone()})})).then(function(e){return e.json()}).then(function({success:t,data:n}){const o=document.createElement("div");o.innerHTML=n.content,e(o.firstElementChild)})})}}},r=function({event:e,el:t,completeAction:n}){c(t).fetch().then(function(t){n({finalState:"",onCompleted:function(){document.querySelector(".ct-drawer-canvas").appendChild(t);const n=document.querySelector("#ct-size-guide-modal");setTimeout(function(){o().trigger("blocksy:frontend:init"),o().trigger("ct:overlay:handle-click",{event:e,options:{openStrategy:"fast",container:n}}),function(e,t){o().trigger("blocksy:frontend:init"),setTimeout(function(){o().trigger("ct:overlay:handle-click",{e:t,href:`#${e.id}`,options:{openStrategy:"skip",isModal:"modal"===e.dataset.behaviour,computeScrollContainer:function(){if(e.closest("body"))return e.querySelector(".ct-panel-content-inner")},clickOutside:!0,focus:!1}})})}(n,e)},10)}})})};(0,t.registerDynamicChunk)("blocksy_ext_woo_extra_size_guide",{mount:function(e,{event:t,completeAction:n}){t.preventDefault(),t.stopPropagation(),r({event:t,el:e,completeAction:n})},maybeGetPanelContent:function(e,{event:t}){return c(e).isCached?new Promise(function(e){e("")}):null}}),o().on("ct:modal:closed",function(e){"ct-size-guide-modal"===e.id&&setTimeout(function(){e.remove()})})}();