System.register(["./style.scss-legacy.BWo5nvXv.js"],function(e,t){"use strict";return{setters:[null],execute:function(){!function(e,t,o){const{__:s}=e.wp.i18n;o(function(){let t=!1;o.ajax({url:e.ajaxurl,type:"POST",data:{action:"adt_export_import_tools",action_type:"get_feeds_for_dropdown",nonce:e.adtObj.exportImportNonce},success:function(e){if(e.success&&e.data?.feeds){const t=o("#export_file");t.empty(),e.data.feeds.forEach(function(e){t.append('<option value="'+e.id+'">'+e.title+" (#"+e.id+")</option>")}),function(){const e=o("#export_file");e.length&&"function"==typeof e.select2&&e.select2({placeholder:s("Select Feeds","woo-product-feed-pro"),allowClear:!0,width:"100%"})}()}},error:function(e,t,o){console.warn("Failed to load feeds for dropdown:",o)}}),o(".adt-export-import-button").on("click",function(a){const r=o(this),n=o(this).data("action");if("import_feeds"===n&&!e.adtObj.isEliteActive)return void a.preventDefault();if(t)return void alert(s("Please wait for the current operation to complete.","woo-product-feed-pro"));if("export_selected_feeds"===n){const e=o("#export_file").val();if(!e||0===e.length)return void alert(s("Please select at least one feed to export.","woo-product-feed-pro"))}if("import_feeds"===n){const e=r.closest("td").find('input[type="file"]')[0],t=e?.files?.[0];if(!t)return void alert(s("Please select a file to import.","woo-product-feed-pro"));if(!t.name.toLowerCase().endsWith(".json"))return void alert(s("Please select a valid JSON file.","woo-product-feed-pro"));const o=10485760;if(t.size>o)return void alert(s("File too large. Maximum file size is 10MB.","woo-product-feed-pro"))}t=!0;const d=o(this).next(".adt-loader");let i;r.prop("disabled",!0),d.show();let c={url:e.ajaxurl,type:"POST"};if("import_feeds"===n){const t=r.closest("td").find('input[type="file"]')[0],o=r.closest("td").find('input[name="overwrite_existing_feeds"]')[0],s=new FormData;s.append("action","adt_export_import_tools"),s.append("action_type",n),s.append("nonce",e.adtObj.exportImportNonce),s.append("import_file",t.files[0]),s.append("overwrite_existing_feeds",o.checked?"1":"0"),c.data=s,c.processData=!1,c.contentType=!1}else{if(i={action:"adt_export_import_tools",action_type:n,nonce:e.adtObj.exportImportNonce},"export_selected_feeds"===n){const e=o("#export_file").val();i.feed_ids=e}c.data=i}o.ajax({...c,success:function(e){if(e.success&&"download"===e.data?.action){const t=new Blob([e.data.data],{type:"application/json"}),o=window.URL.createObjectURL(t),a=document.createElement("a");a.href=o,a.download=e.data.filename,document.body.appendChild(a),a.click(),document.body.removeChild(a),window.URL.revokeObjectURL(o),toastr.success(e.data.message||s("Feeds exported successfully.","woo-product-feed-pro"))}else if(e.success){const t=e.data?.message||s("Operation completed successfully.","woo-product-feed-pro");toastr.success(t),"import_feeds"===n&&r.closest("td").find('input[type="file"]').val("")}else{const t=e.data?.message||s("Operation failed.","woo-product-feed-pro");toastr.error(t)}},error:function(e,t,o){let a=s("Operation failed.","woo-product-feed-pro");e.responseJSON&&e.responseJSON.data&&e.responseJSON.data.message?a=e.responseJSON.data.message:e.responseJSON&&e.responseJSON.data&&"string"==typeof e.responseJSON.data?a=e.responseJSON.data:o&&(a=o),toastr.error(a)},complete:function(){t=!1,r.prop("disabled",!1),d.hide()}})})})}(window,document,jQuery)}}});
