System.register(["./index-legacy.sLMPZLm9.js","./index-legacy.DHtJIoVo.js","./index-legacy.BBqK_jHR.js","./index-legacy.DjPCm-Xr.js","./omit-legacy.Y6HgJwmj.js","./index-legacy.CYFCxdWT.js","./index-legacy.DWOuG56R.js"],(function(e,t){"use strict";var a,o,l,n,u,s,i,r,d,c,p,m,v,f,y,g,S,h,C,O,w,b,x,_,j,N;return{setters:[e=>{a=e.d,o=e.e,l=e.l,n=e.m,u=e.v,s=e.n,i=e.F,r=e.T,d=e.q,c=e.x,p=e.u,m=e.y,v=e.z,f=e.a},e=>{y=e.F},e=>{g=e.S,S=e.s},e=>{h=e._,C=e.s,O=e.j,w=e.l,b=e.d,x=e.n},e=>{_=e.o},e=>{j=e.I},e=>{N=e.B}],execute:function(){var t=document.createElement("style");t.textContent=".additional-data-sources-inputs{margin-top:1rem}.additional-data-sources-inputs .data-source-input{margin-bottom:.5rem}.additional-data-sources-inputs .data-source-input .ant-form-item-control-input-content{display:flex;gap:.5rem;margin-bottom:.5rem}.additional-data-sources-inputs .data-source-input .ant-form-item-control-input-content :deep(.ant-input){flex:1}\n/*$vite$:1*/",document.head.appendChild(t);const A=()=>null;A.isSelectOption=!0,A.displayName="AAutoCompleteOption";const k=()=>null;k.isSelectOptGroup=!0,k.displayName="AAutoCompleteOptGroup";const B=a({compatConfig:{MODE:3},name:"AAutoComplete",inheritAttrs:!1,props:h(h({},_(S(),["loading","mode","optionLabelProp","labelInValue"])),{dataSource:Array,dropdownMenuStyle:{type:Object,default:void 0},dropdownMatchSelectWidth:{type:[Number,Boolean],default:!0},prefixCls:String,showSearch:{type:Boolean,default:void 0},transitionName:String,choiceTransitionName:{type:String,default:"zoom"},autofocus:{type:Boolean,default:void 0},backfill:{type:Boolean,default:void 0},filterOption:{type:[Boolean,Function],default:!1},defaultActiveFirstOption:{type:Boolean,default:!0},status:String}),slots:Object,setup(e,t){let{slots:a,attrs:n,expose:u}=t;C(!e.dropdownClassName);const s=o(),i=()=>{var e;const t=x(null===(e=a.default)||void 0===e?void 0:e.call(a));return t.length?t[0]:void 0};u({focus:()=>{var e;null===(e=s.value)||void 0===e||e.focus()},blur:()=>{var e;null===(e=s.value)||void 0===e||e.blur()}});const{prefixCls:r}=O("select",e);return()=>{var t,o,u;const{size:d,dataSource:c,notFoundContent:p=(null===(t=a.notFoundContent)||void 0===t?void 0:t.call(a))}=e;let m;const{class:v}=n,f={[v]:!!v,[`${r.value}-lg`]:"large"===d,[`${r.value}-sm`]:"small"===d,[`${r.value}-show-search`]:!0,[`${r.value}-auto-complete`]:!0};if(void 0===e.options){const e=(null===(o=a.dataSource)||void 0===o?void 0:o.call(a))||(null===(u=a.options)||void 0===u?void 0:u.call(a))||[];m=e.length&&function(e){var t,a;return(null===(t=null==e?void 0:e.type)||void 0===t?void 0:t.isSelectOption)||(null===(a=null==e?void 0:e.type)||void 0===a?void 0:a.isSelectOptGroup)}(e[0])?e:c?c.map((e=>{if(w(e))return e;switch(typeof e){case"string":return l(A,{key:e,value:e},{default:()=>[e]});case"object":return l(A,{key:e.value,value:e.value},{default:()=>[e.text]});default:throw new Error("AutoComplete[dataSource] only supports type `string[] | Object[]`.")}})):[]}const y=_(h(h(h({},e),n),{mode:g.SECRET_COMBOBOX_MODE_DO_NOT_USE,getInputElement:i,notFoundContent:p,class:f,popupClassName:e.popupClassName||e.dropdownClassName,ref:s}),["dataSource","loading"]);return l(g,y,b({default:()=>[m]},_(a,["default","dataSource","options"])))}}}),E=h(B,{Option:A,OptGroup:k,install:e=>(e.component(B.name,B),e.component(A.displayName,A),e.component(k.displayName,k),e)}),F={key:0,class:"additional-data-sources-inputs"};e("_",a({__name:"UrlDataSourcesField",props:{name:{},dataSources:{},enableDataSources:{type:Boolean}},setup(e){const{Item:t}=y,{Option:a}=g,{__:S}=window.wp.i18n,h=o([]),C=o(!1),O=async e=>{if(e){C.value=!0;try{const t=await f(e);h.value=t}catch(t){console.error("Error searching posts:",t)}finally{C.value=!1}}else h.value=[]};return(e,o)=>e.enableDataSources?(s(),n("div",F,[(s(!0),n(i,null,r(e.dataSources,((o,u)=>(s(),d(p(t),{key:u,class:"data-source-input",name:[e.name,u]},{default:c((()=>[l(p(E),{value:e.dataSources[u],"onUpdate:value":t=>e.dataSources[u]=t,options:h.value,loading:C.value,style:{width:"100%"},onSearch:O},{dataSource:c((()=>[(s(!0),n(i,null,r(h.value,(e=>(s(),d(p(a),{key:e.value,value:e.value},{default:c((()=>[m(v(e.label),1)])),_:2},1032,["value"])))),128))])),default:c((()=>[l(p(j),{size:"large",placeholder:p(S)("Enter page URL or select a post/page","storeagent-ai-for-woocommerce")},null,8,["placeholder"])])),_:2},1032,["value","onUpdate:value","options","loading"]),l(p(N),{type:"text",danger:"",onClick:t=>e.dataSources.splice(u,1)},{default:c((()=>[m(v(p(S)("Remove","storeagent-ai-for-woocommerce")),1)])),_:2},1032,["onClick"])])),_:2},1032,["name"])))),128)),l(p(N),{type:"dashed",block:"",onClick:o[0]||(o[0]=t=>e.dataSources.push(""))},{default:c((()=>[m(v(p(S)("Add Data Source","storeagent-ai-for-woocommerce")),1)])),_:1})])):u("",!0)}}))}}}));
