System.register(["./style.scss-legacy.CYJD_mAM.js"],function(e,t){"use strict";return{setters:[null],execute:function(){!function(e,t,r){const{__:o,_x:n,sprintf:a}=e.wp.i18n;r(function(){const t=e.adtObj.feed_id;let n,s=e.adtObj.feed_data,i=s?.status||"";const c=()=>new URLSearchParams(window.location.search).get("tab")||"general",d=(e,t,n="",a=!1)=>{r(".woosea-admin-notice").remove();const s=`\n        <div class="notice notice-${t} is-dismissible woosea-admin-notice" id="${n}">\n          <p style="display: flex; align-items: center; gap: 8px;">${a?'<span class="adt-loader adt-loader-secondary adt-loader-sm adt-tw-inline-block"></span>':""}${e}</p>\n          <button type="button" class="notice-dismiss">\n            <span class="screen-reader-text">${o("Dismiss this notice.","woo-product-feed-pro")}</span>\n          </button>\n        </div>\n      `;r("#adt-edit-feed .tab-content").prepend(s),r(".woosea-admin-notice .notice-dismiss").on("click",function(){r(this).closest(".woosea-admin-notice").fadeOut(300,function(){r(this).remove()})})},u=()=>!new URLSearchParams(window.location.search).has("id"),l=t=>{const o=[t];r.ajax({url:e.ajaxurl,type:"POST",data:{action:"adt_get_feed_processing_status",nonce:e.adtObj.adtNonce,feed_ids:o}}).done(e=>{if(e.success){const r=Array.isArray(e.data)?e.data.find(e=>String(e.feed_id)===String(t)):null;i=r?.status||"",g(),p(),f()}})},f=()=>{const e="processing"===i?"disabled":"enabled";r(".adt-edit-feed-form").find('button[type="submit"]').prop("disabled","disabled"===e)},p=()=>{r("#adt-edit-feed").attr("data-status",i)},g=()=>{"processing"===i?d(o("Feed is currently processing. Please wait for the feed generation to complete before making changes.","woo-product-feed-pro"),"error","feed-processing-notice",!0):r(".woosea-admin-notice#feed-processing-notice").remove()};u()||(n||(n=setInterval(()=>{l(t)},1e4)),g(),f()),r(".adt-edit-feed-form").on("submit",function(t){const n=c();if("general"===n){if(!((e=!1)=>{if(!r("#projectname").length)return!0;const t=r("#projectname").val(),n="string"==typeof t?t:"";return/^[a-zA-Z0-9-_.àèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇßØøÅåÆæœ ]*$/.test(n)?n.length<3?(e&&d(a(o("Sorry, your project name needs to be at least %d characters long.","woo-product-feed-pro"),3),"error"),!1):!(n.length>30&&(e&&d(a(o("Sorry, your project name cannot be over %d characters long.","woo-product-feed-pro"),30),"error"),1)):(e&&d(o("Sorry, only letters, numbers, whitespaces, -, . and _ are allowed for the projectname","woo-product-feed-pro"),"error"),!1)})(!0))return t.preventDefault(),!1}else if("conversion_analytics"===n&&u()&&!(()=>{const t=c();if(u()&&"conversion_analytics"===t){let t=!0,n=[];return r.ajax({url:e.ajaxurl,type:"POST",async:!1,data:{action:"check_temp_feed_required_fields",nonce:e.adtObj.adtNonce},success:function(e){!1===e.success&&(t=!1,e.data&&e.data.errors&&Array.isArray(e.data.errors)&&e.data.errors.forEach(e=>{n.push(e)}))},error:function(){t=!1,n.push(o("Could not validate feed configuration. Please try again.","woo-product-feed-pro"))}}),t||d(n.join("<br>"),"error"),t}return!0})())return t.preventDefault(),window.scrollTo(0,0),!1;if(r("#rulevalue").length){const e=r("#rulevalue").val(),n="string"==typeof e?e:"",s=1,i=200;if(n.length<s)return d(o("Sorry, rule value minimum length is 1 character","woo-product-feed-pro"),"error"),t.preventDefault(),!1;if(n.length>i)return d(a(o("Sorry, rule value cannot be over %d characters long.","woo-product-feed-pro"),i),"error"),t.preventDefault(),!1}return!0});let m=!1;u()&&(r(".adt-edit-feed-form").on("submit",function(){m=!0}),r(".woo-product-feed-pro-nav-tab-wrapper .nav-tab").on("click",function(){const e=r(this).attr("href");e&&(e=>{if(!e)return!1;if(!e.startsWith("http"))return!1;try{const t=new URL(window.location.href),r=new URL(e);return t.searchParams.get("page"),"adt-edit-feed"===r.searchParams.get("page")}catch(t){return!1}})(e)&&(m=!0,setTimeout(()=>{m=!1},100))}),r(window).on("beforeunload",function(e){if(!m){const t=o("Leaving this page will result in losing your feed configuration. Are you sure you want to leave?","woo-product-feed-pro");return e.returnValue=t,t}}))})}(window,document,jQuery)}}});
