(()=>{"use strict";var e={n:o=>{var t=o&&o.__esModule?()=>o.default:()=>o;return e.d(t,{a:t}),t},d:(o,t)=>{for(var r in t)e.o(t,r)&&!e.o(o,r)&&Object.defineProperty(o,r,{enumerable:!0,get:t[r]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o)};const o=window.wp.apiFetch;var t=e.n(o);const r=window.wp.i18n;var n;(n=jQuery)(document).on("ready",e=>{n(document).on("click","#missing_wlp a",e=>{e.preventDefault(),n(e.target).css("opacity",.5);const o=n("#missing_wlp");n.ajax({url:window.ajaxurl,type:"POST",data:{action:"wpo_install_wlp",nonce:window?.wpoAdmin?.nonce},success:e=>{e?.data?.notice||(e.data.type="error"),e.data.notice=e?.data?.notice||(0,r.__)("An error occurred while processing your request.","woocommerce-product-options"),o.fadeOut(100,()=>{o.get(0).outerHTML=e.data.notice,o.removeClass("notice-error notice-success notice-warning notice-info"),o.addClass(`notice-${e.data.type}`),o.fadeIn(100)})},error:e=>{e?.data?.notice||(e.data.type="error"),e.data.notice=e?.data?.notice||(0,r.__)("An error occurred while processing your request.","woocommerce-product-options"),o.fadeOut(100,()=>{o.get(0).outerHTML=e.data.notice,o.removeClass("notice-error notice-success notice-warning notice-info"),o.addClass(`notice-${e.data.type}`),o.fadeIn(100)})}})}),n(document).on("click","#wpo_formula_conversion a.action-export",e=>{e.preventDefault();const o=n("#wpo_formula_conversion"),a=o.find(".notice-buttons a.button");o.find("p.error-message").remove(),a.attr("disabled","disabled"),t()({path:"/wc-product-options/v1/groups/export/?id="}).then(o=>{const t=new Blob([JSON.stringify(o)],{type:"application/json"}),r=URL.createObjectURL(t),n=document.createElement("a");n.href=r;const c=["wpo-export",window.location.hostname,(new Date).toISOString().split(".")[0].replace(/[-:T]/g,"")];n.download=`${c.join("-")}.json`,document.body.appendChild(n),n.click(),URL.revokeObjectURL(r),e.target.disabled=!1,a.attr("disabled",null)}).catch(t=>{o.append('<p class="error-message"></p>').find("p.error-message").text(t.message||(0,r.__)("An error occurred while processing your request. Please reload the page and try again.","woocommerce-product-options")),e.target.disabled=!1,a.attr("disabled",null)})})})})();