`:F+="
",F+=`
${T.marker}
${T.seriesName}
${O}
`}),F}},xAxis:{type:"category",data:g.value,axisLabel:{color:p.value?"#ffffff":"#696778",fontSize:12},axisLine:{lineStyle:{type:"dashed",color:p.value?"#253241":"#D6DAE1"}}},yAxis:[{type:"value",position:"left",name:u("Volume (%s)",pt.currencySign),axisLabel:{color:p.value?"#ffffff":"#696778",fontSize:12,formatter:V=>pt.formatScaledChart(V)},splitLine:{show:!0,lineStyle:{color:p.value?"#253241":"#D6DAE1",type:"dashed"}}},{type:"value",position:"right",name:u("YoY Growth (%)"),axisLabel:{color:p.value?"#ffffff":"#696778",fontSize:12,formatter:"{value}%"},splitLine:{show:!1},min:Math.min(...v.value.filter(V=>!isNaN(V)),0)-5,max:Math.max(...v.value.filter(V=>!isNaN(V)),0)+5}],series:y.value};try{b.setOption($,{notMerge:!0,replaceMerge:["series"]})}catch(V){i.value=`Error updating chart: ${V.message}`}},S=($,V,F,x,Q=0)=>({name:$,type:V,barMaxWidth:t.barMaxWidth,areaStyle:V==="line"?null:void 0,data:F,smooth:V==="line",color:x,lineStyle:V==="line"?{width:2}:void 0,yAxisIndex:Q,emphasis:{scale:2,itemStyle:{color:p.value?c.blue[800]:c.blue[400]}}});return be([()=>t.data,s],()=>{ke(w)},{deep:!0}),xt(()=>{window.removeEventListener("onFluentCartThemeChange",w,!1),window.removeEventListener("fluentCartCurrencyChange",w,!1),b&&(b.dispose(),b=null)}),Ie(()=>{window.addEventListener("onFluentCartThemeChange",w),window.addEventListener("fluentCartCurrencyChange",w),ke(k)}),($,V)=>(r(),h("div",Dde,[n(Be,{id:"chartContainer",ref_key:"cardRef",ref:l},{default:d(()=>[n(Qe,{title:A(u)(e.title),title_size:"small",border_bottom:""},{action:d(()=>V[0]||(V[0]=[])),_:1},8,["title"]),n(Ce,{class:"p-0"},{default:d(()=>[i.value?(r(),h("div",Vde,m(i.value),1)):B("",!0),e.isEmpty?(r(),E(wt,{key:2,icon:"Empty/ListView","has-dark":!0,text:A(u)("Currently there is no data!"),class:"fct-report-empty-state"},null,8,["text"])):(r(),h("div",{key:1,class:"fct-chart-wrap fct-gross-volume-chart",ref_key:"chartRef",ref:a,style:{height:"400px"}},null,512))]),_:1})]),_:1},512)]))}},Ac=lt(Tde,[["__scopeId","data-v-101c1068"]]),Mde={class:"fct-country-volume-chart-wrap"},Lde={class:"fct-btn-group sm"},Rde=.05,Ode={__name:"CountryVolumeChart",props:{data:{type:Object,required:!0},title:{type:String,default:""}},setup(e){const t=e,a=M(null),l=M(null);let s=null;const i=M("bar");M("");const c=M(De.isDark()),p=N(()=>c.value?["#8FC0F5","#4E90E8","#2E6BC4","#1E4C90","#143562"]:["#9CC9FA","#3E9DF6","#1573D5","#0B57A3","#083C73"]),f=F=>{const x=F.replace("#",""),Q=parseInt(x.substring(0,2),16),D=parseInt(x.substring(2,4),16),T=parseInt(x.substring(4,6),16);return(Q*299+D*587+T*114)/1e3>150?"#0B3A66":"#ffffff"},_=N(()=>{const F=Array.isArray(t.data.by_countries)?t.data.by_countries:Object.values(t.data.by_countries);return!F.length||!F.every(x=>!!x)}),g=De.colors,y=N(()=>{const F=t.data.by_month||{};return Object.keys(F).sort().map(Q=>{const D=F[Q],T=Object.values(D).reduce((I,O)=>I+O,0),U=Object.entries(D).sort((I,O)=>I[1]-O[1]).reduce((I,[O,L])=>({...I,[O]:L}),{});return{label:Q,countries:U,total:T}})}),v=N(()=>y.value.length?y.value.map(F=>{try{const[x,Q]=F.label.split("-");return et(new Date(x,Q-1)).format("MMM YYYY")}catch{return F.label}}):[]),b=N(()=>{const F={};Object.values(t.data.by_month||{}).forEach(D=>{Object.entries(D).forEach(([T,U])=>{F[T]=(F[T]||0)+U})}),Object.entries(t.data.by_countries||{}).forEach(([D,T])=>{F[D]=T});const x=p.value,Q=x[x.length-1];return Object.keys(F).sort((D,T)=>F[T]-F[D]).reduce((D,T,U)=>(D[T]=x[U]||Q,D),{})}),k=N(()=>y.value.reduce((F,x)=>Math.max(F,x.total),0)),w=N(()=>{const F=t.data.by_month||{},x=new Set;Object.values(F).forEach(T=>{Object.keys(T).forEach(U=>x.add(U))});const Q=p.value,D=k.value;return Array.from(x).reverse().map(T=>{const U=b.value[T]||Q[Q.length-1],I=f(U),O=y.value.map(L=>{const P=L.countries[T]||0,q=D>0&&P/D>=Rde;return{value:P/100,label:{show:P>0&&q,position:"inside",formatter:T,color:I,fontSize:10,fontWeight:"bold"}}});return{name:T,type:i.value,stack:"total",data:O,itemStyle:{color:U},lineStyle:{color:U}}})}),S=()=>{if(!a.value)return;s=aa(a.value);const F={backgroundColor:"transparent",tooltip:{trigger:"axis",backgroundColor:c.value?"#253241":"#ffffff",textStyle:{color:c.value?g.gray[25]:g.system.mid},borderColor:c.value?"#2C3C4E":"#c0c4ca",axisPointer:Ul(c.value,g.report.dark_cyan_blue_16,g.report.light_gray_cyan_blue,i.value),borderWidth:1,confine:!0,position:gl,formatter:x=>{const Q=c.value?"#ffffff":"#565865",D=c.value?g.report.dark_cyan_blue_16:g.report.light_gray_blue,T=y.value[x[0].dataIndex].total;let U=x[0].axisValue;return x.filter(I=>I.value>0).sort((I,O)=>O.value-I.value).forEach(I=>{const O=qa(I.value*100);U+=`
${I.marker}
${Us(I.seriesName)}
${O}
`}),U+=`
${u("Total")}
${qa(T)}
`,U}},xAxis:{type:"category",data:v.value,axisLabel:{color:c.value?"#ffffff":"#696778",fontSize:12},axisLine:{lineStyle:{color:c.value?"#253241":"#D6DAE1"}}},yAxis:{type:"value",position:"left",name:u("Volume (%s)",pt.currencySign),axisLabel:{color:c.value?"#ffffff":"#696778",fontSize:12,formatter:x=>pt.formatScaled(x*100)},splitLine:{show:!0,lineStyle:{color:c.value?"#253241":"#D6DAE1",type:"dashed"}}},series:w.value};s.setOption(F)},$=()=>{c.value=De.isDark(),ke(()=>{S()})},V=()=>{s&&(s.dispose(),s=null),S()};return Ie(()=>{window.addEventListener("onFluentCartThemeChange",$),window.addEventListener("fluentCartCurrencyChange",V),ke(S)}),xt(()=>{window.removeEventListener("onFluentCartThemeChange",$,!1),window.removeEventListener("fluentCartCurrencyChange",V,!1)}),be(()=>c.value,()=>{s&&(s.dispose(),S())}),be(()=>t.data,()=>{s&&S()}),(F,x)=>(r(),h("div",Mde,[n(Be,{id:"chartContainer",ref_key:"cardRef",ref:l},{default:d(()=>[n(Qe,{title:e.title,title_size:"small",border_bottom:""},{action:d(()=>[o("div",Lde,[n(Sm,{targetRef:a.value},null,8,["targetRef"])])]),_:1},8,["title"]),n(Ce,{class:"p-0"},{default:d(()=>[_.value?(r(),E(wt,{key:1,icon:"Empty/ListView","has-dark":!0,text:A(u)("Currently there is no data!"),class:"fct-report-empty-state"},null,8,["text"])):(r(),h("div",{key:0,class:"fct-chart-wrap fct-country-volume-chart",ref_key:"chartRef",ref:a,style:{height:"400px"}},null,512))]),_:1})]),_:1},512)]))}},pc=lt(Ode,[["__scopeId","data-v-b6ca7579"]]),Hde={class:"fct-card-header-title is-small"},fc={__name:"CountryNetChart",props:{data:{type:Object,required:!0},title:{type:String,default:""}},setup(e){const t=e,a=De.colors.report,l=M(De.isDark()),s=M(null),i=M("line"),c=M(t.data),p=N(()=>({textColor:l.value?"#ffffff":"#696778",borderColor:l.value?"#2C3C4E":"#c0c4ca",splitLineColor:l.value?"#253241":"#D6DAE1",bgColor:l.value?"#2d3748":"#ffffff"})),f=N(()=>Object.values(c.value).every(w=>w===0)),_=N(()=>Object.keys(c.value)),g=N(()=>[{name:u("Current"),type:i.value,data:Object.values(c.value),smooth:!0,color:l.value?a.purple_dark_mode:a.purple,lineStyle:{width:2},barMaxWidth:30}]);let y=null;const v=()=>{s.value&&!y&&(y=aa(s.value),b())},b=()=>{if(!y)return;const w={legend:{show:!1},tooltip:{trigger:"axis",backgroundColor:p.value.bgColor,borderColor:p.value.borderColor,borderWidth:1,textStyle:{color:p.value.textColor},axisPointer:Ul(l.value,a.dark_cyan_blue_16,a.light_gray_blue,i.value),confine:!0,position:gl,formatter:S=>{let $=Us(S[0].name);const V=l.value?"#ffffff":"#565865";return S.forEach(F=>{const x=qa(F.value);$+=`
${F.marker}
${F.seriesName}
${x}
`}),$}},xAxis:{type:"category",data:_.value,axisLabel:{color:p.value.textColor,fontSize:12},axisLine:{lineStyle:{type:"dashed",color:p.value.splitLineColor}}},yAxis:{type:"value",axisLabel:{color:p.value.textColor,fontSize:12,formatter:S=>pt.formatScaled(S)},splitLine:{show:!0,lineStyle:{color:p.value.splitLineColor,type:"dashed"}}},series:g.value,grid:{left:"10px",right:"10px",top:"20px",bottom:"60px",containLabel:!0}};y.setOption(w,{notMerge:!0,replaceMerge:["series"]})};be([()=>c.value,i,()=>l.value],()=>{ke(b)},{deep:!0});const k=()=>{l.value=De.isDark(),ke(()=>{b()})};return Ie(()=>{window.addEventListener("onFluentCartThemeChange",k,!1),window.addEventListener("fluentCartCurrencyChange",b),ke(v)}),xt(()=>{window.removeEventListener("onFluentCartThemeChange",k,!1),window.removeEventListener("fluentCartCurrencyChange",b,!1)}),(w,S)=>(r(),E(Be,null,{default:d(()=>[e.title!==""?(r(),E(Qe,{key:0,border_bottom:!0},{title:d(()=>[o("h3",Hde,m(e.title),1)]),_:1})):B("",!0),n(Ce,null,{default:d(()=>[f.value?(r(),E(wt,{key:1,icon:"Empty/ListView","has-dark":!0,text:A(u)("Currently there is no data!"),class:"fct-report-empty-state"},null,8,["text"])):(r(),h("div",{key:0,class:"fct-chart-wrap h-[350px]",ref_key:"SubscriptionCountTrendChartRef",ref:s},null,512))]),_:1})]),_:1}))}},Pde={class:"fct-overview-report-loader-wrap"},Nde={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},Kde={class:"fct-card-header-title is-small"},Gde={class:"flex gap-2 mt-1"},jde={class:"py-6"},zde={class:"grid grid-cols-1"},qde={class:"fct-card-header-title is-small"},Yde={class:"py-6"},Wde={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-2"},Jde={class:"fct-card-header-title is-small"},Xde={class:"flex gap-2 mt-1"},Zde={class:"py-6"},eue={class:"grid grid-cols-1"},tue={class:"fct-card-header-title is-small"},aue={class:"py-6"},lue={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-2"},sue={class:"fct-card-header-title is-small"},nue={class:"py-6"},oue={__name:"OverviewLoading",setup(e){const t=[{title:u("Gross Summary"),key:"gross_summary"},{title:u("Gross Revenue Quarterly"),key:"net_summary"}],a=[{title:u("Net Revenue"),key:"net_revenue"},{title:u("Net Revenue Quarterly"),key:"net_revenue_quarterly"}],l=[{title:u("Top Country Gross Volume"),key:"top_country_gross"},{title:u("Top Country Net Volume"),key:"top_country_net"}],s=[{title:u("Top Countries Gross Revenue"),key:"top_country_revenue"},{title:u("Top Countries Net Revenue"),key:"top_country_net_revenue"}];return(i,c)=>{const p=C("el-skeleton-item"),f=C("el-skeleton");return r(),h("div",Pde,[o("div",Nde,[(r(),h(H,null,ae(t,(_,g)=>o("div",{key:g},[n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Qe,{border_bottom:!0},{title:d(()=>[o("h3",Kde,m(_.title),1),o("div",Gde,[n(f,{animated:""},{template:d(()=>[n(p,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:2},1024),o("div",jde,[n(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",zde,[(r(),h(H,null,ae(2,_=>o("div",{key:_},[n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(f,{animated:""},{template:d(()=>[n(p,{variant:"p",class:"w-2/3"})]),_:1}),n(Qe,{border_bottom:!0},{title:d(()=>[o("h2",qde,m(A(u)("Gross Volume Breakdown")),1)]),_:1}),o("div",Yde,[n(f,{animated:"",rows:7})])]),_:1})]),_:1})])),64))]),o("div",Wde,[(r(),h(H,null,ae(a,(_,g)=>o("div",{key:g},[n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Qe,{border_bottom:!0},{title:d(()=>[o("h3",Jde,m(_.title),1),o("div",Xde,[n(f,{animated:""},{template:d(()=>[n(p,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:2},1024),o("div",Zde,[n(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",eue,[(r(),h(H,null,ae(l,(_,g)=>o("div",{key:g},[n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Qe,{border_bottom:!0},{title:d(()=>[o("h2",tue,m(_.title),1)]),_:2},1024),o("div",aue,[n(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",lue,[(r(),h(H,null,ae(s,(_,g)=>o("div",{key:g},[n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Qe,{border_bottom:!0},{title:d(()=>[o("h3",sue,m(_.title),1)]),_:2},1024),o("div",nue,[n(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))])])}}},iue={class:"overview-summary-report-inline"},rue={class:"inner-value"},due={__name:"Summary",props:{title:{type:String},current:{type:[String,Number],required:!0},previous:{type:[String,Number],required:!0},fluctuation:{type:[String,Number],required:!0}},setup(e){return(t,a)=>(r(),h("div",iue,[o("div",rue,[n(Ms,{amount:A(pt).formatScaled(e.current),title:A(u)(e.title)},null,8,["amount","title"])]),n(ml,{fluctuation:e.fluctuation,amount:e.previous/100,fluctuationSuffix:A(u)("YoY")},null,8,["fluctuation","amount","fluctuationSuffix"])]))}},go=lt(due,[["__scopeId","data-v-b394c9f1"]]),uue={class:"report-overview-page"},cue={class:"flex items-center justify-start gap-1 mb-2 text-xs text-system-mid dark:text-system-light"},Aue={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},pue={class:"fct-card-header-title is-small"},fue={class:"fct-card-header-title is-small"},mue={class:"grid grid-cols-1"},hue=["innerHTML"],_ue=["innerHTML"],vue={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},gue={class:"fct-card-header-title is-small"},yue={class:"fct-card-header-title is-small"},bue={class:"grid gap-4 grid-cols-1"},wue={class:"grid gap-4 grid-cols-1"},Cue={class:"report-overview-col-2 grid gap-7.5 grid-cols-1 xl:grid-cols-2"},kue={__name:"Overview",setup(e){const t=M({}),a=M(!0),l=M({gross_revenue_quarterly:{},net_revenue_quarterly:{}}),s=()=>{ue.get("reports/overview").then(p=>{t.value=p.data,i()}).catch(p=>{}).finally(()=>{a.value=!1})},i=()=>{l.value.gross_revenue_quarterly=c(t.value.gross_revenue_quarterly,"current","prev_year"),l.value.net_revenue_quarterly=c(t.value.net_revenue_quarterly,"current","prev_year")},c=(p,f="current",_="prev")=>{const g=it.sum(p,"*."+f),y=it.sum(p,"*."+_),v=y===0?100:(g-y)/y*100;return{value:parseFloat(v.toFixed(2)),prev:y,current:g}};return N(()=>{var p,f;return((p=t.value.gross_summary)==null?void 0:p.yoy_growth)<0?"danger":((f=t.value.gross_summary)==null?void 0:f.yoy_growth)===null?"warning":"success"}),Ie(()=>{s()}),(p,f)=>(r(),h("div",uue,[o("div",cue,[n(J,{name:"InformationFill",class:"w-4 h-4 text-system-light"}),R(" "+m(A(u)("Last %s Months",A(u)(12))),1)]),a.value?(r(),E(oue,{key:0})):(r(),h(H,{key:1},[o("div",Aue,[n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Qe,{border_bottom:""},{title:d(()=>[o("h3",pue,m(A(u)("Gross Summary")),1),n(go,{current:t.value.gross_summary.total,previous:t.value.gross_summary.total_prev,fluctuation:t.value.gross_summary.yoy_growth},null,8,["current","previous","fluctuation"])]),_:1}),n(vo,{data:t.value.gross_revenue,dataKey:"current","date-range":"","is-empty":!t.value.gross_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1}),n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Qe,{border_bottom:""},{title:d(()=>[o("h3",fue,m(A(u)("Gross Revenue Quarterly")),1),n(go,{current:l.value.gross_revenue_quarterly.current,previous:l.value.gross_revenue_quarterly.prev,fluctuation:l.value.gross_revenue_quarterly.value},null,8,["current","previous","fluctuation"])]),_:1}),n(vo,{data:t.value.gross_revenue_quarterly,dataKey:"current","bar-max-width":80,"is-empty":!l.value.gross_revenue_quarterly.current},null,8,["data","is-empty"])]),_:1})]),_:1})]),o("div",mue,[n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>[o("div",{class:"mb-3",innerHTML:A(pt).generateVolumeSummary(t.value.gross_revenue,!0)},null,8,hue),n(Ac,{title:A(u)("Gross Volume Breakdown"),data:t.value.gross_revenue,dataKey:"current","is-date":"","is-empty":!t.value.gross_summary.total},null,8,["title","data","is-empty"])]),_:1})]),_:1}),n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>[o("div",{class:"mb-3",innerHTML:A(pt).generateVolumeSummary(t.value.gross_revenue_quarterly)},null,8,_ue),n(Ac,{title:A(u)("Gross Revenue Breakdown"),data:t.value.gross_revenue_quarterly,dataKey:"current",prevKey:"prev_year",labelKey:"yy_growth","bar-max-width":80,"is-empty":!t.value.gross_summary.total},null,8,["title","data","is-empty"])]),_:1})]),_:1})]),o("div",vue,[n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Qe,{border_bottom:!0},{title:d(()=>[o("h3",gue,m(A(u)("Net Revenue")),1),n(go,{title:A(u)("Net Revenue"),current:t.value.net_summary.total,previous:t.value.net_summary.total_prev,fluctuation:t.value.net_summary.yoy_growth},null,8,["title","current","previous","fluctuation"])]),_:1}),n(vo,{data:t.value.net_revenue,dataKey:"current","date-range":"","is-empty":!t.value.net_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1}),n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(Qe,{border_bottom:!0},{title:d(()=>[o("h3",yue,m(A(u)("Net Revenue Quarterly")),1),n(go,{title:A(u)("Net Revenue Quarterly"),current:l.value.net_revenue_quarterly.current,previous:l.value.net_revenue_quarterly.prev,fluctuation:l.value.net_revenue_quarterly.value},null,8,["title","current","previous","fluctuation"])]),_:1}),n(vo,{data:t.value.net_revenue_quarterly,dataKey:"current","bar-max-width":80,"is-empty":!t.value.net_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1})]),o("div",bue,[n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(pc,{data:t.value.top_country_gross,title:A(u)("Top Country Gross Volume")},null,8,["data","title"])]),_:1})]),_:1})]),o("div",wue,[n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>[n(pc,{data:t.value.top_country_net,title:A(u)("Top Country Net Volume")},null,8,["data","title"])]),_:1})]),_:1})]),o("div",Cue,[n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>{var _;return[n(fc,{data:(_=t.value.top_country_gross)==null?void 0:_.by_countries,title:A(u)("Top Countries Gross Revenue")},null,8,["data","title"])]}),_:1})]),_:1}),n(Be,null,{default:d(()=>[n(Ce,null,{default:d(()=>{var _;return[n(fc,{data:(_=t.value.top_country_net)==null?void 0:_.by_countries,title:A(u)("Top Countries Net Revenue")},null,8,["data","title"])]}),_:1})]),_:1})])],64))]))}},Bue={class:"setting-wrap"},xue={class:"setting-wrap-inner"},Sue={key:0,class:"bg-white rounded p-6 dark:bg-dark-700"},Fue={class:"grid gap-3 mb-6"},$ue={class:"grid gap-3 mb-6"},Eue={class:"grid gap-3 mb-6"},Uue={class:"grid gap-3"},Iue={class:"payment-method-list fct-content-card-list"},Que=["id"],Due={class:"flex items-start gap-3"},Vue={class:"grid gap-2 flex-1"},Tue={key:0,class:"fct-content-card-list-head stripe"},Mue=["src","alt"],Lue=["src","alt"],Rue={class:"block font-semibold text-system-dark dark:text-gray-50"},Oue={class:"fct-content-card-list-content"},Hue={class:"fct-content-card-list-action flex items-center gap-2"},Pue={key:0},Nue=Object.assign({name:"AddonSettings"},{__name:"AddonSettings",setup(e){const t=Op(),{form:a}=t.data,l=vs(),s=M([]),i=M([]),c=M(!0),p=M(!1),f=M(!0),_=M({}),g=M(!1),y=M({}),v=M(!1),b=M(""),k=M(""),w=M(""),S=N(()=>Object.keys(y.value).length>0),$=()=>{p.value=!0;let T=a.values;ue.post("settings/modules",{...T}).then(U=>{z.success(u("Settings saved successfully")),setTimeout(()=>{window.location.reload()},300)}).catch(U=>{if(U&&U.message)return z.error(U);_.value=U}).finally(()=>{p.value=!1,f.value=!1,c.value=!1})},V=()=>{c.value=!0,ue.get("settings/modules",{}).then(T=>{var O,L;a.setSchema(T.fields).setDefaults(T.settings).initForm(),s.value=T.settings,i.value=T.fields,f.value=!1,p.value=!1;const U=((L=(O=T.fields)==null?void 0:O.modules_settings)==null?void 0:L.schema)||[];let I=!1;Array.isArray(U)?I=U.length>0:I=Object.keys(U).length>0,g.value=I}).finally(()=>{c.value=!1})},F=()=>{v.value=!0,ue.get("settings/modules/plugin-addons",{}).then(T=>{y.value=T.addons||{},w.value&&ke(()=>ln.scrollToHashSection(w.value))}).catch(T=>{z.error(T)}).finally(()=>{v.value=!1})},x=Ge.get("app_config.isProActive"),Q=(T,U)=>{if(!x){window.open(T.repo_link,"_blank","noopener,noreferrer");return}b.value=U,ue.post("settings/modules/plugin-addons/install",{plugin_slug:T.plugin_slug,source_type:T.source_type||"wordpress",source_link:T.source_link||"",asset_path:T.asset_path||""}).then(I=>{I.action==="copy"&&I.url?(Zl.copy(I.url,{successMessage:u("Download link copied to your clipboard")}),window.open(I.url,"_blank","noopener,noreferrer")):I.action==="reload"?(z.success(I.message||u("Addon installed successfully")),setTimeout(()=>{window.location.reload()},500)):z.success(I.message||u("Addon installed successfully"))}).catch(I=>{z.error(I)}).finally(()=>{b.value=""})},D=(T,U)=>{k.value=U,ue.post("settings/modules/plugin-addons/activate",{plugin_file:T.plugin_file}).then(I=>{z.success(I.message||u("Addon activated successfully")),setTimeout(()=>{window.location.reload()},500)}).catch(I=>{z.error(I)}).finally(()=>{k.value=""})};return Ie(()=>{const T=window.location.hash||"",U=T.lastIndexOf("#");U>0&&(w.value=T.substring(U+1)),V(),F()}),l.onSave($),(T,U)=>{const I=C("el-skeleton-item"),O=C("el-skeleton"),L=C("el-form"),P=C("el-button"),q=C("el-icon"),X=C("router-link");return r(),h("div",Bue,[n(Qa,{heading:A(u)("Addon Settings"),"show-save-button":!1},null,8,["heading"]),o("div",xue,[n(Da),f.value?(r(),h("div",Sue,[n(O,{loading:f.value,animated:""},{template:d(()=>[o("div",Fue,[n(I,{variant:"p",class:"w-[20%]"}),n(I,{variant:"p"})]),o("div",$ue,[n(I,{variant:"p",class:"w-[20%]"}),n(I,{variant:"p"})]),o("div",Eue,[n(I,{variant:"p",class:"w-[20%]"}),n(I,{variant:"p"})]),o("div",Uue,[n(I,{variant:"p",class:"w-[20%]"}),n(I,{variant:"p"})])]),_:1},8,["loading"])])):B("",!0),f.value?B("",!0):(r(),h(H,{key:1},[A(a).isReady?(r(),E(L,{key:0},{default:d(()=>[g.value?(r(),E(ki,{key:0,form:A(a),showSubmitButton:!0,onOnSubmitButtonClick:$,submitButtonText:A(u)("Save Settings"),loading:p.value,onOnChange:U[0]||(U[0]=G=>{}),"validation-errors":_.value},null,8,["form","submitButtonText","loading","validation-errors"])):S.value?B("",!0):(r(),E(Be,{key:1},{default:d(()=>[n(Qe,{title:A(u)("Features & addon"),border_bottom:""},null,8,["title"]),n(Ce,null,{default:d(()=>[n(wt,{class:"fct-addon-empty-state",icon:"Empty/Integrations",text:A(u)("No module settings found.")},null,8,["text"])]),_:1})]),_:1}))]),_:1})):B("",!0),S.value?(r(),E(Be,{key:1,class:"mt-6"},{default:d(()=>[n(Qe,{title:A(u)("Plugin Addons"),border_bottom:""},null,8,["title"]),n(Ce,{class:"py-0"},{default:d(()=>[o("div",Iue,[(r(!0),h(H,null,ae(y.value,(G,te)=>(r(),h("div",{key:te,class:"fct-content-card-list-item",id:G.plugin_slug===w.value?w.value:null},[o("div",Due,[o("div",Vue,[G.logo?(r(),h("div",Tue,[o("img",{class:de({"dark:hidden":G.dark_logo}),src:G.logo,alt:G.title},null,10,Mue),G.dark_logo?(r(),h("img",{key:0,src:G.dark_logo,alt:G.title,class:"hidden dark:block"},null,8,Lue)):B("",!0),o("span",Rue,m(G.title),1),G.is_active?(r(),E(ma,{key:1,status:"active",text:A(u)("Active")},null,8,["text"])):B("",!0)])):B("",!0),o("div",Oue,[o("p",null,m(G.description),1)])]),o("div",Hue,[G.upcoming?(r(),h("div",Pue,m(A(u)("Coming Soon")),1)):(r(),h(H,{key:1},[G.is_installed?G.is_installed&&!G.is_active&&(A(x)||G.source_type!=="github")?(r(),E(P,{key:1,type:"success",size:"small",loading:k.value===te,disabled:k.value===te,onClick:ne=>D(G,te)},{default:d(()=>[R(m(A(u)("Activate")),1)]),_:2},1032,["loading","disabled","onClick"])):B("",!0):(r(),E(P,{key:0,type:"primary",size:"small",loading:b.value===te,disabled:b.value===te,onClick:ne=>Q(G,te)},{default:d(()=>[R(m(A(x)?A(u)("Install & Activate"):A(u)("Download")),1)]),_:2},1032,["loading","disabled","onClick"])),G.is_active&&te==="fluent-pdf"?(r(),E(X,{key:2,to:{path:"/settings/pdf-template"}},{default:d(()=>[n(q,{class:"text-gray-500 hover:text-primary cursor-pointer",size:18},{default:d(()=>[n(A(Rc))]),_:1})]),_:1})):B("",!0)],64))])])],8,Que))),128))])]),_:1})]),_:1})):B("",!0)],64))])])}}}),Kue=lt(Nue,[["__scopeId","data-v-a315b5d5"]]),Gue={class:"form-note"},jue={class:"form-note"},zue={class:"form-note"},que={class:"form-note"},Yue={class:"el-form-item__label"},Wue={class:"h-[297px] w-full relative"},Jue={class:"mt-2 mb-2"},Xue={class:"form-note"},Zue={class:"fct-powered-by-email-footer-checkbox mb-4 pb-4 border-[1px] border-l-0 border-t-0 border-r-0 border-solid border-gray-outline dark:border-dark-400"},ece={class:"setting-html-wrapper"},tce={class:"setting-label"},ace={class:"form-note"},lce={class:"setting-fields-inner w-full"},sce={__name:"MailingSettingsLoader",setup(e){return(t,a)=>{const l=C("el-skeleton-item"),s=C("el-skeleton"),i=C("el-form-item"),c=C("el-col"),p=C("el-row");return r(),E(Ce,null,{default:d(()=>[n(p,{gutter:15},{default:d(()=>[n(c,{lg:12},{default:d(()=>[n(i,{label:A(u)("From Name"),"label-position":"top"},{default:d(()=>[n(s,{animated:"",class:"h-9 gap-2"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),a[0]||(a[0]=o("br",null,null,-1)),o("div",null,[o("div",Gue,[o("p",null,m(A(u)("Name that will be used to send emails")),1)])])]),_:1,__:[0]},8,["label"])]),_:1}),n(c,{lg:12},{default:d(()=>[n(i,{label:A(u)("From Email"),"label-position":"top"},{default:d(()=>[n(s,{animated:"",class:"h-9"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),o("div",null,[o("div",jue,[o("p",null,m(A(u)(`Provide Valid Email Address email as per your domain/SMTP settings. This
email will be used to send emails like notifications`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),n(p,{gutter:15},{default:d(()=>[n(c,{lg:12},{default:d(()=>[n(i,{label:A(u)("Reply to name (Optional)"),"label-position":"top"},{default:d(()=>[n(s,{animated:"",class:"h-9"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),o("div",zue,[o("p",null,m(A(u)("Name that will be used for reply to attribute")),1)])]),_:1},8,["label"])]),_:1}),n(c,{lg:12},{default:d(()=>[n(i,{label:A(u)("Reply to email (Optional)"),"label-position":"top"},{default:d(()=>[n(s,{animated:"",class:"h-9"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),o("div",null,[o("div",que,[o("p",null,m(A(u)(`If someone replies to your notification email, this is where you would like to
receive it.`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),n(p,{gutter:15},{default:d(()=>[n(c,null,{default:d(()=>[o("div",Yue,m(A(u)("Email Footer")),1),o("div",Wue,[n(s,{animated:"",rows:7})]),o("div",Jue,[o("div",Xue,[o("p",null,m(A(u)(`This email footer will be used for all emails sent from FluentCart, It's highly recommended to use your business name and address in the footer for
compliance.`)),1)])]),o("div",Zue,[n(s,{animated:"",class:"h-5"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1})])]),_:1})]),_:1}),n(p,{gutter:15},{default:d(()=>[n(c,null,{default:d(()=>[n(i,null,{default:d(()=>[n(p,{gutter:15,class:"w-full"},{default:d(()=>[n(c,{lg:12},{default:d(()=>[o("div",ece,[o("span",tce,m(A(u)("Admin Email Address")),1),o("div",ace,[o("p",null,m(A(u)("FluentCart will send admin notification to this email address.")),1)])])]),_:1}),n(c,{lg:12},{default:d(()=>[o("div",lce,[n(s,{animated:"",class:"h-9"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1})])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})}}},nce={class:"setting-wrap"},oce={class:"setting-wrap-inner"},ice={class:"form-note"},rce={class:"form-note"},dce={class:"form-note"},uce={class:"form-note"},cce={class:"el-form-item__label"},Ace={class:"mt-2 mb-2"},pce={class:"form-note"},fce={class:"fct-powered-by-email-footer-checkbox"},mce={class:"setting-html-wrapper"},hce={class:"setting-label"},_ce={class:"form-note"},vce={class:"setting-fields-inner w-full"},gce={class:"setting-save-action"},yce={__name:"MailingSettings",setup(e){const t=M({from_name:"",from_email:"",reply_to_name:"",reply_to_email:"",email_footer:"",show_email_footer:"yes",admin_email:"{{wp.admin_email}}"}),a=Ge.get("app_config.isProActive"),l=M(!1),s=M({}),i=M({}),c=()=>{l.value=!0,ue.get("email-notification/get-settings").then(f=>{var _,g,y,v,b,k,w;t.value={from_name:(_=f.data)==null?void 0:_.from_name,from_email:(g=f.data)==null?void 0:g.from_email,reply_to_name:(y=f.data)==null?void 0:y.reply_to_name,reply_to_email:(v=f.data)==null?void 0:v.reply_to_email,email_footer:(b=f.data)==null?void 0:b.email_footer,admin_email:(k=f.data)==null?void 0:k.admin_email,show_email_footer:((w=f.data)==null?void 0:w.show_email_footer)||"yes"},i.value=f.shortcodes}).catch(f=>{}).finally(()=>{l.value=!1})},p=()=>{l.value=!0,s.value={},ue.post("email-notification/save-settings",t.value).then(f=>{z.success(f.message)}).catch(f=>{f.status_code===422&&f.data?s.value=f.data:f.message?z.error(f.message):(z.error(u("Something went wrong")),s.value=f)}).finally(()=>{l.value=!1})};return Ie(()=>{c()}),(f,_)=>{const g=C("el-input"),y=C("el-form-item"),v=C("el-col"),b=C("el-row"),k=C("el-tooltip"),w=C("el-checkbox"),S=C("el-button");return r(),h("div",nce,[n(Qa,{heading:A(u)("Mailing Settings"),loading:l.value,onOnSave:p},null,8,["heading","loading"]),o("div",oce,[n(Da),n(Be,null,{default:d(()=>[n(Qe,{title:A(u)("Email Configuration"),text:A(u)("Set your from name, email, and email footer. These configurations will be used to send emails from %s.","FluentCart"),border_bottom:""},null,8,["title","text"]),l.value?(r(),E(sce,{key:0})):(r(),E(Ce,{key:1},{default:d(()=>[n(b,{gutter:15},{default:d(()=>[n(v,{lg:12},{default:d(()=>[n(y,{label:A(u)("From Name"),"label-position":"top"},{default:d(()=>[n(g,{modelValue:t.value.from_name,"onUpdate:modelValue":_[0]||(_[0]=$=>t.value.from_name=$)},null,8,["modelValue"]),_[9]||(_[9]=o("br",null,null,-1)),o("div",null,[n(fl,{"validation-errors":s.value.from_name||{},"field-key":"from_name"},null,8,["validation-errors"]),o("div",ice,[o("p",null,m(A(u)("Name that will be used to send emails")),1)])])]),_:1,__:[9]},8,["label"])]),_:1}),n(v,{lg:12},{default:d(()=>[n(y,{label:A(u)("From Email"),"label-position":"top"},{default:d(()=>[n(g,{modelValue:t.value.from_email,"onUpdate:modelValue":_[1]||(_[1]=$=>t.value.from_email=$)},null,8,["modelValue"]),o("div",null,[n(fl,{"validation-errors":s.value.from_email||{},"field-key":"from_email"},null,8,["validation-errors"]),o("div",rce,[o("p",null,m(A(u)(`Provide Valid Email Address email as per your domain/SMTP settings. This
email will be used to send emails like notifications`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),n(b,{gutter:15},{default:d(()=>[n(v,{lg:12},{default:d(()=>[n(y,{label:A(u)("Reply to name (Optional)"),"label-position":"top"},{default:d(()=>[n(g,{modelValue:t.value.reply_to_name,"onUpdate:modelValue":_[2]||(_[2]=$=>t.value.reply_to_name=$)},null,8,["modelValue"]),o("div",dce,[o("p",null,m(A(u)("Name that will be used for reply to attribute")),1)])]),_:1},8,["label"])]),_:1}),n(v,{lg:12},{default:d(()=>[n(y,{label:A(u)("Reply to email (Optional)"),"label-position":"top"},{default:d(()=>[n(g,{modelValue:t.value.reply_to_email,"onUpdate:modelValue":_[3]||(_[3]=$=>t.value.reply_to_email=$)},null,8,["modelValue"]),o("div",null,[n(fl,{"validation-errors":s.value.reply_to_email||{},"field-key":"reply_to_email"},null,8,["validation-errors"]),o("div",uce,[o("p",null,m(A(u)(`If someone replies to your notification email, this is where you would like to
receive it.`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),n(b,{gutter:15},{default:d(()=>[n(v,null,{default:d(()=>[o("div",cce,m(A(u)("Email Footer")),1),n(es,{"short-codes":i.value,modelValue:t.value.email_footer,"onUpdate:modelValue":_[4]||(_[4]=$=>t.value.email_footer=$),onUpdate:_[5]||(_[5]=$=>{t.value.email_footer=$})},null,8,["short-codes","modelValue"]),o("div",Ace,[n(fl,{"validation-errors":s.value.email_footer||{},"field-key":"email_footer"},null,8,["validation-errors"]),o("div",pce,[o("p",null,m(A(u)(`This email footer will be used for all emails sent from FluentCart, It's highly recommended to use your business name and address in the footer for
compliance.`)),1)])]),o("div",fce,[n(w,{modelValue:t.value.show_email_footer,"onUpdate:modelValue":_[6]||(_[6]=$=>t.value.show_email_footer=$),"true-value":"yes","false-value":"no",disabled:!A(a)},{default:d(()=>[R(m(A(u)("Enable powered by FluentCart in the email footer"))+" ",1),A(a)?B("",!0):(r(),E(k,{key:0,"popper-class":"fct-tooltip",placement:"top"},{content:d(()=>[R(m(A(u)("This feature is available in pro version only.")),1)]),default:d(()=>[n(J,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),_:1},8,["modelValue","disabled"])])]),_:1})]),_:1}),n(b,{gutter:15},{default:d(()=>[n(v,null,{default:d(()=>[n(y,null,{default:d(()=>[n(b,{gutter:15,class:"w-full"},{default:d(()=>[n(v,{lg:12},{default:d(()=>[o("div",mce,[o("span",hce,m(A(u)("Admin Email Address")),1),o("div",_ce,[o("p",null,m(A(u)("FluentCart will send admin notification to this email address.")),1)])])]),_:1}),n(v,{lg:12},{default:d(()=>[o("div",vce,[n(g,{modelValue:t.value.admin_email,"onUpdate:modelValue":_[7]||(_[7]=$=>t.value.admin_email=$)},null,8,["modelValue"])])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}))]),_:1}),o("div",gce,[n(S,{type:"primary",onClick:_[8]||(_[8]=$=>p()),loading:l.value},{default:d(()=>[R(m(A(u)("Save Settings")),1)]),_:1},8,["loading"])])])])}}},bce={class:"setting-wrap"},wce={class:"setting-wrap-inner"},Cce={class:"form-note"},kce={class:"form-note"},Bce={class:"form-note",style:{"padding-top":"6px"}},xce={class:"form-note"},Sce={class:"setting-save-action"},mc="{{wp.admin_email}}",Fce={__name:"StoreDigestSettings",setup(e){const t=M({recipients:"{{wp.admin_email}}",send_when_empty:"no",daily:{enabled:"no",send_hour:8},weekly:{enabled:"no",send_hour:8,send_dow:1},monthly:{enabled:"no",send_hour:8}}),a=M(!1),l=M({}),s=M(""),i=[{key:"daily",label:u("Daily digest"),desc:u("Yesterday's performance, sent every morning.")},{key:"weekly",label:u("Weekly digest"),desc:u("The previous 7 days, sent on your chosen day.")},{key:"monthly",label:u("Monthly digest"),desc:u("The previous calendar month, sent on the 1st.")}],c=u("Comma-separate multiple addresses. %1$s resolves to the site admin email.",mc),p=N(()=>{const v=[];for(let b=0;b<24;b++)v.push({value:b,label:String(b).padStart(2,"0")+":00"});return v}),f=[{value:1,label:u("Monday")},{value:2,label:u("Tuesday")},{value:3,label:u("Wednesday")},{value:4,label:u("Thursday")},{value:5,label:u("Friday")},{value:6,label:u("Saturday")},{value:7,label:u("Sunday")}],_=()=>{a.value=!0,ue.get("email-notification/digest-settings").then(v=>{v.data&&(t.value=v.data)}).catch(()=>{}).finally(()=>{a.value=!1})},g=()=>{a.value=!0,l.value={},ue.post("email-notification/digest-settings",t.value).then(v=>{z.success(v.message)}).catch(v=>{v.status_code===422&&v.data?l.value=v.data:v.message?z.error(v.message):z.error(u("Something went wrong"))}).finally(()=>{a.value=!1})},y=v=>{s.value=v,ue.post("email-notification/digest-settings/send-test",{frequency:v}).then(b=>{z.success(b.message)}).catch(b=>{z.error(b.message||u("Could not send the test email."))}).finally(()=>{s.value=""})};return Ie(()=>{_()}),(v,b)=>{const k=C("el-input"),w=C("el-form-item"),S=C("el-col"),$=C("el-checkbox"),V=C("el-row"),F=C("el-switch"),x=C("el-option"),Q=C("el-select"),D=C("el-button");return r(),h("div",bce,[n(Qa,{heading:A(u)("Store Digest Emails"),loading:a.value,onOnSave:g},null,8,["heading","loading"]),o("div",wce,[n(Da),n(Be,null,{default:d(()=>[n(Qe,{title:A(u)("Recipients & General"),text:A(u)("A system email summarising your store activity. Numbers match the Reports dashboard."),border_bottom:""},null,8,["title","text"]),n(Ce,null,{default:d(()=>[n(V,{gutter:15},{default:d(()=>[n(S,{lg:12},{default:d(()=>[n(w,{label:A(u)("Recipient email addresses"),"label-position":"top"},{default:d(()=>[n(k,{modelValue:t.value.recipients,"onUpdate:modelValue":b[0]||(b[0]=T=>t.value.recipients=T),placeholder:mc},null,8,["modelValue"]),o("div",null,[n(fl,{"validation-errors":l.value.recipients||{},"field-key":"recipients"},null,8,["validation-errors"]),o("div",Cce,[o("p",null,m(A(c)),1)])])]),_:1},8,["label"])]),_:1}),n(S,{lg:12},{default:d(()=>[n(w,{label:A(u)("Empty periods"),"label-position":"top"},{default:d(()=>[n($,{modelValue:t.value.send_when_empty,"onUpdate:modelValue":b[1]||(b[1]=T=>t.value.send_when_empty=T),"true-value":"yes","false-value":"no"},{default:d(()=>[R(m(A(u)("Send even when there was no activity")),1)]),_:1},8,["modelValue"]),o("div",kce,[o("p",null,m(A(u)("When off, a digest is skipped for any period with no paid orders.")),1)])]),_:1},8,["label"])]),_:1})]),_:1})]),_:1})]),_:1}),(r(),h(H,null,ae(i,T=>n(Be,{key:T.key,class:"fct-mt-4"},{default:d(()=>[n(Qe,{title:T.label,text:T.desc,border_bottom:""},null,8,["title","text"]),n(Ce,null,{default:d(()=>[n(V,{gutter:15,align:"middle"},{default:d(()=>[n(S,{lg:6},{default:d(()=>[n(w,{label:A(u)("Enable"),"label-position":"top"},{default:d(()=>[n(F,{modelValue:t.value[T.key].enabled,"onUpdate:modelValue":U=>t.value[T.key].enabled=U,"active-value":"yes","inactive-value":"no"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"])]),_:2},1024),n(S,{lg:6},{default:d(()=>[n(w,{label:A(u)("Send time"),"label-position":"top"},{default:d(()=>[n(Q,{modelValue:t.value[T.key].send_hour,"onUpdate:modelValue":U=>t.value[T.key].send_hour=U,class:"w-full"},{default:d(()=>[(r(!0),h(H,null,ae(p.value,U=>(r(),E(x,{key:U.value,label:U.label,value:U.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"])]),_:2},1024),T.key==="weekly"?(r(),E(S,{key:0,lg:6},{default:d(()=>[n(w,{label:A(u)("Day of week"),"label-position":"top"},{default:d(()=>[n(Q,{modelValue:t.value.weekly.send_dow,"onUpdate:modelValue":b[2]||(b[2]=U=>t.value.weekly.send_dow=U),class:"w-full"},{default:d(()=>[(r(),h(H,null,ae(f,U=>n(x,{key:U.value,label:U.label,value:U.value},null,8,["label","value"])),64))]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1})):B("",!0),T.key==="monthly"?(r(),E(S,{key:1,lg:6},{default:d(()=>[n(w,{label:A(u)("Send day"),"label-position":"top"},{default:d(()=>[o("div",Bce,[o("p",null,m(A(u)("Sent on the 1st of each month.")),1)])]),_:1},8,["label"])]),_:1})):B("",!0),n(S,{lg:6},{default:d(()=>[n(w,{label:" ","label-position":"top"},{default:d(()=>[n(D,{loading:s.value===T.key,onClick:U=>y(T.key),class:"mt-2"},{default:d(()=>[R(m(A(u)("Send test email")),1)]),_:2},1032,["loading","onClick"])]),_:2},1024)]),_:2},1024)]),_:2},1024),o("div",xce,[o("p",null,m(A(u)("Send time is in your store timezone. Test emails use your saved recipients.")),1)])]),_:2},1024)]),_:2},1024)),64)),o("div",Sce,[n(D,{type:"primary",onClick:b[3]||(b[3]=T=>g()),loading:a.value},{default:d(()=>[R(m(A(u)("Save Settings")),1)]),_:1},8,["loading"])])])])}}},$ce={};function Ece(e,t){const a=C("router-view");return r(),h("div",null,[n(a)])}const Uce=lt($ce,[["render",Ece]]),Ice={},Qce={class:"fct-setting-form-row"},Dce={class:"w-[300px]"},Vce={class:"flex-grow flex-shrink flex-basis-0 self-center"},Tce={class:"fct-setting-form-row"},Mce={class:"w-[300px]"},Lce={class:"flex-grow flex-shrink flex-basis-0 self-center"},Rce={class:"fct-setting-form-row"},Oce={class:"w-[300px]"},Hce={class:"flex-grow flex-shrink flex-basis-0 self-center"};function Pce(e,t){const a=C("el-skeleton-item"),l=C("el-skeleton");return r(),h("div",null,[o("div",Qce,[o("div",Dce,[n(l,{animated:"",class:"max-w-[70%]"},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1}),n(l,{animated:"",class:"max-w-[80%]"},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"}),n(a,{variant:"p",class:"w-1/2 h-4"})]),_:1})]),o("div",Vce,[n(l,{animated:""},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])]),o("div",Tce,[o("div",Mce,[n(l,{animated:"",class:"max-w-[60%]"},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1}),n(l,{animated:"",class:"max-w-full"},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})]),o("div",Lce,[n(l,{animated:""},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])]),o("div",Rce,[o("div",Oce,[n(l,{animated:"",class:"max-w-[50%]"},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1}),n(l,{animated:"",class:"max-w-full"},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})]),o("div",Hce,[n(l,{animated:""},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])])])}const Nce=lt(Ice,[["render",Pce]]),Kce={name:"TaxConfigurations",components:{TaxConfigurationsLoader:Nce,CardContainer:Be,CardBody:Ce,CardHeader:Qe,LabelHint:fa,SettingsHeader:Qa,AdminNotice:Da,Animation:va},data(){return{settings:{enable_tax:"no",tax_inclusion:"included",tax_calculation_basis:"shipping",tax_rounding:"item",checkout_tax_breakdown_display:"itemized",tax_display_label:"Tax",price_suffix_included:"",price_suffix_excluded:"",eu_vat_settings:{require_vat_number:"no",local_reverse_charge:"yes",reverse_charge_price_mode:"fixed",vat_reverse_excluded_categories:[]}},tax_settings_changed:!1,saving:!1,loading:!1,categories:[],fetchingCategories:!1,keyboardShortcuts:null}},computed:{handlePriceMode(){return this.settings.eu_vat_settings.local_reverse_charge=="yes"}},mounted(){this.bindSaveShortcut(),this.getSettings(),this.fetchCategories()},beforeUnmount(){this.unbindSaveShortcut()},methods:{translate:u,saveSettings(){this.saving||this.loading||(this.saving=!0,this.$post("tax/configuration/settings",{settings:this.settings}).then(e=>{this.handleSuccess(e.message),this.tax_settings_changed=!0,Ge.mergeConfig({is_tax_enabled:this.settings.enable_tax==="yes"})}).catch(e=>{var t;this.handleError((t=e==null?void 0:e.data)==null?void 0:t.message),this.saving=!1}).finally(()=>{this.saving=!1}))},getSettings(){this.loading=!0,this.$get("tax/configuration/settings").then(e=>{if(this.settings=e.settings,this.settings.eu_vat_settings={require_vat_number:"no",local_reverse_charge:"yes",reverse_charge_price_mode:"fixed",vat_reverse_excluded_categories:[],...this.settings.eu_vat_settings||{}},["itemized","simplified"].includes(this.settings.checkout_tax_breakdown_display)||(this.settings.checkout_tax_breakdown_display="itemized"),this.settings.tax_display_label||(this.settings.tax_display_label="Tax"),!Array.isArray(this.settings.eu_vat_settings.vat_reverse_excluded_categories))this.settings.eu_vat_settings.vat_reverse_excluded_categories=[];else{let t=this.settings.eu_vat_settings.vat_reverse_excluded_categories.map(a=>a.toString());this.settings.eu_vat_settings.vat_reverse_excluded_categories=t}}).catch(e=>{var t;this.handleError((t=e==null?void 0:e.data)==null?void 0:t.message)}).finally(()=>{this.loading=!1})},fetchCategories(){this.categories.length>0||(this.fetchingCategories=!0,this.$get("products/fetch-term").then(e=>{this.categories=e.taxonomies["product-categories"].terms||[]}).catch(()=>{}).finally(()=>{this.fetchingCategories=!1}))},bindSaveShortcut(){this.keyboardShortcuts=_s(),this.keyboardShortcuts.bind(["mod+s"],e=>{e.preventDefault(),this.saveSettings()})},unbindSaveShortcut(){var e;(e=this.keyboardShortcuts)!=null&&e.unbind&&this.keyboardShortcuts.unbind("mod+s")}}},Gce={class:"setting-wrap"},jce={class:"setting-wrap-inner"},zce={class:"fct-setting-form-row"},qce={class:"fct-setting-form-content flex gap-3.5 flex-1"},Yce={class:"fct-inline-tip"},Wce={key:1},Jce={class:"fct-setting-form-row"},Xce={class:"fct-setting-form-content"},Zce={class:"fct-inline-tip"},eAe={class:"fct-setting-form-fields self-center"},tAe={class:"fct-inline-tip mt-2"},aAe={class:"fct-setting-form-row"},lAe={class:"fct-setting-form-content"},sAe={class:"fct-inline-tip"},nAe={class:"fct-setting-form-fields self-center"},oAe={class:"flex flex-col"},iAe={class:"price-mode-label"},rAe={class:"price-mode-text"},dAe={class:"flex flex-col"},uAe={class:"price-mode-label"},cAe={class:"price-mode-text"},AAe={class:"fct-setting-form-row"},pAe={class:"fct-setting-form-content"},fAe={class:"fct-inline-tip"},mAe={class:"fct-setting-form-fields self-center"},hAe={class:"fct-setting-form-row"},_Ae={class:"fct-setting-form-content"},vAe={class:"fct-inline-tip"},gAe={class:"fct-setting-form-fields self-center"},yAe={class:"fct-setting-form-row"},bAe={class:"fct-setting-form-content"},wAe={class:"fct-inline-tip"},CAe={class:"fct-setting-form-fields self-center"},kAe={class:"fct-setting-form-row"},BAe={class:"fct-setting-form-content"},xAe={class:"fct-inline-tip"},SAe={class:"fct-setting-form-fields self-center"},FAe={key:0,class:"fct-setting-form-row"},$Ae={class:"fct-setting-form-content"},EAe={class:"fct-inline-tip"},UAe={class:"fct-setting-form-fields self-center"},IAe={class:"fct-setting-form-row"},QAe={class:"fct-setting-form-content"},DAe={class:"fct-inline-tip"},VAe={class:"fct-setting-form-fields"},TAe={class:"fct-vat-charge-setting-wrap grid gap-5 w-full"},MAe={class:"fct-local-reverse-charge flex gap-2 justify-items-start"},LAe={class:"fct-inline-tip"},RAe={class:"fct-vat-excluded-categories"},OAe={class:"fct-inline-tip"};function HAe(e,t,a,l,s,i){const c=C("SettingsHeader"),p=C("AdminNotice"),f=C("el-switch"),_=C("LabelHint"),g=C("TaxConfigurationsLoader"),y=C("el-radio"),v=C("el-radio-group"),b=C("el-option"),k=C("el-select"),w=C("el-input"),S=C("Animation"),$=C("CardBody"),V=C("CardContainer"),F=Ma("loading");return r(),h("div",Gce,[n(c,{heading:i.translate("Tax Configuration"),loading:s.saving,"show-cmnd-icon":!0,onOnSave:i.saveSettings},null,8,["heading","loading","onOnSave"]),o("div",jce,[n(p),n(V,null,{default:d(()=>[n($,null,{default:d(()=>[o("div",zce,[o("div",qce,[n(f,{modelValue:s.settings.enable_tax,"onUpdate:modelValue":t[0]||(t[0]=x=>s.settings.enable_tax=x),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"]),o("div",null,[n(_,{title:i.translate("Enable Tax")},null,8,["title"]),o("p",Yce,m(s.settings.enable_tax==="yes"?i.translate("This store is now collecting tax."):i.translate("This store is not collecting tax.")),1)])])]),n(S,{visible:s.settings.enable_tax==="yes",accordion:""},{default:d(()=>[s.loading?(r(),E(g,{key:0})):B("",!0),s.loading?B("",!0):(r(),h("div",Wce,[o("div",Jce,[o("div",Xce,[n(_,{title:i.translate("Prices entered with tax")},null,8,["title"]),o("p",Zce,m(i.translate("Choose whether product prices are entered including or excluding tax.")),1)]),o("div",eAe,[n(v,{modelValue:s.settings.tax_inclusion,"onUpdate:modelValue":t[1]||(t[1]=x=>s.settings.tax_inclusion=x)},{default:d(()=>[n(y,{value:"included"},{default:d(()=>[R(m(i.translate("Included")),1)]),_:1}),n(y,{value:"excluded"},{default:d(()=>[R(m(i.translate("Excluded")),1)]),_:1})]),_:1},8,["modelValue"]),o("p",tAe,m(i.translate("Shipping tax always follows the store-level tax mode (Included or Excluded). Product-specific tax settings do not apply to shipping.")),1)])]),o("div",aAe,[o("div",lAe,[n(_,{title:i.translate("Tax-Inclusive Price Mode")},null,8,["title"]),o("p",sAe,m(i.translate("Controls how reverse charge affects tax-inclusive product prices.")),1)]),o("div",nAe,[n(v,{modelValue:s.settings.eu_vat_settings.reverse_charge_price_mode,"onUpdate:modelValue":t[2]||(t[2]=x=>s.settings.eu_vat_settings.reverse_charge_price_mode=x),class:"fct-reverse-charge-price-mode"},{default:d(()=>[n(y,{value:"fixed"},{default:d(()=>[o("div",oAe,[o("span",iAe,m(i.translate("Fixed")),1),o("span",rAe,m(i.translate("Listed price stays unchanged on reverse charge. Only the tax line is zeroed on the invoice.")),1)])]),_:1}),n(y,{value:"dynamic"},{default:d(()=>[o("div",dAe,[o("span",uAe,m(i.translate("Dynamic")),1),o("span",cAe,m(i.translate("VAT is stripped from the price on reverse charge. Customer pays the net (ex-VAT) amount.")),1)])]),_:1})]),_:1},8,["modelValue"])])]),o("div",AAe,[o("div",pAe,[n(_,{title:i.translate("Calculate Tax Based On")},null,8,["title"]),o("p",fAe,m(i.translate("Determine the location used for tax calculations.")),1)]),o("div",mAe,[n(k,{modelValue:s.settings.tax_calculation_basis,"onUpdate:modelValue":t[3]||(t[3]=x=>s.settings.tax_calculation_basis=x),clearable:""},{default:d(()=>[n(b,{value:"shipping",label:i.translate("Customer Shipping Address")},null,8,["label"]),n(b,{value:"billing",label:i.translate("Customer Billing Address")},null,8,["label"]),n(b,{value:"store",label:i.translate("Store Location")},null,8,["label"])]),_:1},8,["modelValue"])])]),o("div",hAe,[o("div",_Ae,[n(_,{title:i.translate("Price Suffix (Tax Included)")},null,8,["title"]),o("p",vAe,m(i.translate("Shown on prices where tax is included. Applies when product or store pricing is tax-inclusive.")),1)]),o("div",gAe,[n(w,{modelValue:s.settings.price_suffix_included,"onUpdate:modelValue":t[4]||(t[4]=x=>s.settings.price_suffix_included=x),placeholder:i.translate("e.g. (incl. tax)")},null,8,["modelValue","placeholder"])])]),o("div",yAe,[o("div",bAe,[n(_,{title:i.translate("Price Suffix (Tax Excluded)")},null,8,["title"]),o("p",wAe,m(i.translate("Shown on prices where tax is excluded. Applies when product or store pricing is tax-exclusive.")),1)]),o("div",CAe,[n(w,{modelValue:s.settings.price_suffix_excluded,"onUpdate:modelValue":t[5]||(t[5]=x=>s.settings.price_suffix_excluded=x),placeholder:i.translate("e.g. (+ tax)")},null,8,["modelValue","placeholder"])])]),o("div",kAe,[o("div",BAe,[n(_,{title:i.translate("Tax Display Style")},null,8,["title"]),o("p",xAe,m(i.translate("Choose how tax context appears on each checkout line item.")),1)]),o("div",SAe,[n(k,{modelValue:s.settings.checkout_tax_breakdown_display,"onUpdate:modelValue":t[6]||(t[6]=x=>s.settings.checkout_tax_breakdown_display=x)},{default:d(()=>[n(b,{value:"simplified",label:i.translate("Simplified (single line + details)")},null,8,["label"]),n(b,{value:"itemized",label:i.translate("Itemized (per-item tax + breakdown)")},null,8,["label"])]),_:1},8,["modelValue"])])]),s.settings.checkout_tax_breakdown_display==="simplified"?(r(),h("div",FAe,[o("div",$Ae,[n(_,{title:i.translate("Tax Line Label")},null,8,["title"]),o("p",EAe,m(i.translate("The single-line tax label shown in Simplified mode, e.g. VAT, MwSt, GST.")),1)]),o("div",UAe,[n(w,{modelValue:s.settings.tax_display_label,"onUpdate:modelValue":t[7]||(t[7]=x=>s.settings.tax_display_label=x),placeholder:i.translate("e.g. Tax")},null,8,["modelValue","placeholder"])])])):B("",!0),o("div",IAe,[o("div",QAe,[n(_,{title:i.translate("VAT Reverse Charge Settings")},null,8,["title"]),o("p",DAe,m(i.translate("Configure reverse VAT handling for customers in the European Union.")),1)]),o("div",VAe,[o("div",TAe,[o("div",MAe,[n(f,{modelValue:s.settings.eu_vat_settings.local_reverse_charge,"onUpdate:modelValue":t[8]||(t[8]=x=>s.settings.eu_vat_settings.local_reverse_charge=x),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"]),o("div",null,[n(_,{title:i.translate("Local Reverse Charge")},null,8,["title"]),o("p",LAe,m(i.translate("If enabled, apply reverse charge when applicable even when customers are in your home country.")),1)])]),n(S,{visible:i.handlePriceMode,accordion:""},{default:d(()=>[o("div",RAe,[n(_,{title:i.translate("Exclude Categories from VAT reverse")},null,8,["title"]),o("p",OAe,m(i.translate("Select product categories that should NOT get VAT reverse charge !")),1),qt((r(),E(k,{modelValue:s.settings.eu_vat_settings.vat_reverse_excluded_categories,"onUpdate:modelValue":t[9]||(t[9]=x=>s.settings.eu_vat_settings.vat_reverse_excluded_categories=x),filterable:"",multiple:"",clearable:"",placeholder:i.translate("Select Product Categories"),class:"w-full mt-4"},{default:d(()=>[(r(!0),h(H,null,ae(s.categories,x=>(r(),E(b,{key:x.value||x.term_id,label:x.label||x.name,value:x.value||x.term_id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])),[[F,s.fetchingCategories]])])]),_:1},8,["visible"])])])])]))]),_:1},8,["visible"])]),_:1})]),_:1})])])}const PAe=lt(Kce,[["render",HAe]]),NAe={class:"fct-tax-rates-wrap-loader px-5"},KAe={__name:"TaxRatesLoader",setup(e){const t=M(Array.from({length:6},()=>`${Math.floor(Math.random()*21)+120}px`));return(a,l)=>{const s=C("el-skeleton-item"),i=C("el-skeleton");return r(),h("div",NAe,[(r(!0),h(H,null,ae(t.value,(c,p)=>(r(),h("div",{key:p,class:"flex items-center justify-between border-[1px] border-solid border-gray-divider dark:border-dark-400 rounded h-12 pr-4 pl-6 mb-4"},[n(i,{animated:"",style:ua({width:c}),class:"h-4"},{template:d(()=>[n(s,{variant:"p",class:"h-4"})]),_:2},1032,["style"]),n(i,{animated:"",class:"w-[100px] h-4"},{template:d(()=>[n(s,{variant:"p",class:"h-4"})]),_:1})]))),128))])}}},GAe={class:"setting-wrap"},jAe={class:"setting-wrap-inner"},zAe={class:"fct-all-tax-classes-page"},qAe={class:"flex items-center justify-end gap-4"},YAe={key:0,class:"px-6 py-4 border-b border-gray-200 dark:border-gray-700"},WAe={class:"inline-flex items-center gap-2"},JAe={class:"inline-flex items-center gap-2"},XAe=["src","alt"],ZAe={key:0,class:"text-gray-400 dark:text-gray-300"},epe={key:1,class:"text-success-500"},tpe={key:2,class:"text-system-mid dark:text-gray-300"},ape={key:3,class:"text-gray-400 dark:text-gray-300"},lpe={key:1,class:"text-gray-400"},spe={__name:"TaxRates",setup(e){const t=M({}),a=M([]),l=M({}),s=M({}),i=N(()=>!!Ge.get("is_tax_enabled")),c=M(!1),p=M({}),f={};let _=0;const g=M(""),y=M(!1),v={XI:"gb"},b=U=>(v[U]||U).toLowerCase(),k=N(()=>{const U=new Set;for(const I of a.value)for(const O of I.countries||[])U.add(O.country_code);return U}),w=U=>!U||!Object.prototype.hasOwnProperty.call(s.value,U)?!0:s.value[U],S=U=>!U||!U.vat?!1:U.rates&&typeof U.rates=="object"&&Object.keys(U.rates).length?Object.values(U.rates).some(I=>I&&parseFloat(I.rate)>0):parseFloat(U.rate)>0,$=N(()=>{const U=l.value||{},I=Array.isArray(U.country_registrations)?U.country_registrations:[],O=U.method||"",L=I.some(S);if(O==="oss")return!!U.oss_country;if(O==="home"){const P=U.home_country||"",q=I.find(X=>X.country===P);if(P&&q&&S(q))return!0}return O==="specific"?!!U.home_country:L}),V=N(()=>{const U=l.value||{},I=Array.isArray(U.country_registrations)?U.country_registrations:[],O=U.method||"";return O==="oss"?!!U.oss_country:O==="home"?!!U.home_country&&I.some(L=>L.country===U.home_country):O==="specific"?!!U.home_country:I.some(S)}),F=N(()=>{const U=[],I=Object.values(t.value||{});for(const P of I)if(P.group_code==="EU")U.push({country_code:"EU",country_name:"European Union",isEU:!0,group_code:"EU",hasConfig:V.value,enabled:w("EU"),collecting:V.value&&$.value&&w("EU")});else for(const q of P.countries||[]){const X=k.value.has(q.country_code),G=w(q.country_code);U.push({country_code:q.country_code,country_name:q.country_name,isEU:!1,group_code:P.group_code,hasConfig:X,enabled:G,collecting:X&&G})}const O=["EU","US","GB","AU","CA","NZ","IN","SG","JP"],L=new Set(O);return U.sort((P,q)=>{if(P.hasConfig!==q.hasConfig)return P.hasConfig?-1:1;const X=L.has(P.country_code),G=L.has(q.country_code);return X&&G?O.indexOf(P.country_code)-O.indexOf(q.country_code):X?-1:G?1:P.country_name.localeCompare(q.country_name)}),U}),x=N(()=>{const U=g.value.trim().toLowerCase();return F.value.filter(I=>y.value&&(!i.value||!I.collecting)?!1:U?I.country_name.toLowerCase().includes(U)||I.country_code.toLowerCase().includes(U):!0)}),Q=N(()=>{if(!i.value)return!1;const U=F.value.filter(O=>O.enabled).length,I=F.value.filter(O=>!O.enabled).length;return U>0&&I>0}),D=()=>{c.value=!0,Promise.all([ue.get("tax/configuration/rates"),ue.get("tax/rates"),ue.get("tax/configuration/settings")]).then(([U,I,O])=>{var L;t.value=U.tax_rates,a.value=I.tax_rates,s.value=I.country_enabled_map||{},l.value=((L=O.settings)==null?void 0:L.eu_vat_settings)||{}}).catch(U=>{}).finally(()=>{c.value=!1})},T=(U,I)=>{const O=w(U.country_code),L=++_;f[U.country_code]=L,s.value={...s.value,[U.country_code]:I},p.value={...p.value,[U.country_code]:!0},ue.post("tax/country-status/"+U.country_code,{enabled:I?1:0}).then(P=>{f[U.country_code]===L&&(z.success(P.message),s.value={...s.value,[U.country_code]:P.enabled})}).catch(P=>{var q;f[U.country_code]===L&&(s.value={...s.value,[U.country_code]:O},z.error(((q=P==null?void 0:P.data)==null?void 0:q.message)||u("Failed to update tax status")))}).finally(()=>{if(f[U.country_code]===L){const P={...p.value};delete P[U.country_code],p.value=P}})};return Ie(()=>{D()}),(U,I)=>{const O=C("el-checkbox"),L=C("el-input"),P=C("el-table-column"),q=C("el-switch"),X=C("el-table");return r(),h("div",GAe,[n(Qa,{heading:A(u)("Tax Regions"),"show-save-button":!1},null,8,["heading"]),o("div",jAe,[n(Da),o("div",zAe,[n(Be,{class:"overflow-hidden"},{default:d(()=>[n(Qe,{title:A(u)("Tax Regions"),text:A(u)("Manage tax rates for different regions")},{action:d(()=>[o("div",qAe,[Q.value?(r(),E(O,{key:0,modelValue:y.value,"onUpdate:modelValue":I[0]||(I[0]=G=>y.value=G)},{default:d(()=>[R(m(A(u)("Collecting Tax")),1)]),_:1},8,["modelValue"])):B("",!0),n(L,{modelValue:g.value,"onUpdate:modelValue":I[1]||(I[1]=G=>g.value=G),class:"w-[200px]",placeholder:A(u)("Search regions..."),size:"small",clearable:""},{prefix:d(()=>[n(J,{name:"Search",class:"w-4 h-4"})]),_:1},8,["modelValue","placeholder"])])]),_:1},8,["title","text"]),n(Ce,{class:"px-0 pb-0"},{default:d(()=>[!c.value&&!i.value?(r(),h("div",YAe,[n(Xa,{type:"warning",icon:"AlertTriangle",content:A(u)("Tax is currently disabled. Enable tax from the Tax Settings page to start collecting tax.")},null,8,["content"])])):B("",!0),c.value?(r(),E(KAe,{key:1})):(r(),E(X,{key:2,data:x.value,"max-height":"500",class:"w-full compact-table fct-tax-rates-regions-table"},{default:d(()=>[n(P,{label:A(u)("Region"),"min-width":"300"},{default:d(({row:G})=>[G.isEU?(r(),E(Ba,{key:0,class:"hover:no-underline",to:{name:"eu"}},{default:d(()=>[o("div",WAe,[I[2]||(I[2]=o("img",{class:"w-[22px] block",src:"https://flagcdn.com/w40/eu.png",alt:"EU"},null,-1)),R(" "+m(G.country_name),1)])]),_:2},1024)):(r(),E(Ba,{key:1,to:{name:"tax-rates-country-single",params:{country:G.country_code,group:G.group_code}},class:"fct-tax-region-link hover:no-underline"},{default:d(()=>[o("div",JAe,[o("img",{class:"w-[22px] block",src:`https://flagcdn.com/w40/${b(G.country_code)}.png`,alt:G.country_code},null,8,XAe),R(" "+m(G.country_name),1)])]),_:2},1032,["to"]))]),_:1},8,["label"]),n(P,{label:A(u)("Collecting"),width:"200"},{default:d(({row:G})=>[i.value?G.collecting?(r(),h("span",epe,m(A(u)("Collecting tax")),1)):G.hasConfig&&!G.enabled?(r(),h("span",tpe,m(A(u)("Disabled")),1)):(r(),h("span",ape,"—")):(r(),h("span",ZAe,"—"))]),_:1},8,["label"]),n(P,{label:A(u)("Enabled"),width:"140",align:"center"},{default:d(({row:G})=>[G.hasConfig?(r(),E(q,{key:0,"model-value":i.value?G.enabled:!1,loading:!!p.value[G.country_code],disabled:!i.value,onChange:te=>T(G,te)},null,8,["model-value","loading","disabled","onChange"])):(r(),h("span",lpe,"—"))]),_:1},8,["label"])]),_:1},8,["data"]))]),_:1})]),_:1})])])])}}},npe={class:"fct-base-taxes"},ope={class:"fct-tax-class-tabs"},ipe={class:"fct-tax-class-tabs__list"},rpe={class:"fct-base-taxes__header"},dpe={class:"fct-base-taxes__header-label"},upe={class:"fct-base-taxes__state-row fct-base-taxes__state-row--federal"},cpe={class:"fct-base-taxes__region-name fct-base-taxes__region-name--federal"},Ape={class:"fct-base-taxes__state-fields"},ppe={class:"fct-base-taxes__region-name"},fpe={class:"fct-base-taxes__state-fields"},mpe={__name:"CountryTaxRatesLoader",setup(e){const t=[1,2,3];return(a,l)=>{const s=C("el-skeleton-item"),i=C("el-skeleton");return r(),h("div",null,[o("div",npe,[o("div",ope,[o("div",ipe,[(r(),h(H,null,ae(3,c=>o("div",{key:c,class:"fct-tax-class-tabs__tab"},[n(i,{animated:""},{template:d(()=>[n(s,{variant:"text",class:"w-16 h-5"})]),_:1})])),64)),n(i,{animated:""},{template:d(()=>[n(s,{variant:"text",class:"w-5 h-5"})]),_:1})])]),o("div",rpe,[o("span",dpe,m(A(u)("Regions")),1)]),o("div",upe,[o("div",cpe,[n(i,{animated:""},{template:d(()=>[n(s,{variant:"text",class:"w-40 h-5"})]),_:1})]),o("div",Ape,[n(i,{animated:""},{template:d(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-rate h-8"})]),_:1}),n(i,{animated:""},{template:d(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-name h-8"})]),_:1}),l[0]||(l[0]=o("div",{class:"fct-base-taxes__field-compound"},null,-1))])]),l[1]||(l[1]=o("div",{class:"fct-base-taxes__divider"},null,-1)),(r(),h(H,null,ae(t,c=>o("div",{key:c,class:"fct-base-taxes__state-row"},[o("div",ppe,[n(i,{animated:""},{template:d(()=>[n(s,{variant:"text",class:"w-32 h-4"})]),_:1})]),o("div",fpe,[n(i,{animated:""},{template:d(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-rate h-8"})]),_:1}),n(i,{animated:""},{template:d(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-name h-8"})]),_:1}),n(i,{animated:""},{template:d(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-compound h-8"})]),_:1})])])),64))])])}}},hpe={class:"fct-tax-class-tabs"},_pe={class:"fct-tax-class-tabs__list"},vpe=["onClick"],gpe=["title","onClick"],ype=["disabled","title"],bpe=["disabled","title"],wpe=["disabled"],Cpe=["disabled","title"],kpe={class:"fct-tax-class-tabs__search"},of={__name:"TaxClassTabs",props:{classes:{type:Array,default:()=>[]},activeId:{type:[Number,String],default:null},maxClasses:{type:Number,default:6},creating:{type:Boolean,default:!1},search:{type:String,default:""}},emits:["switch","delete","add","create-custom","update:search"],setup(e,{emit:t}){const a=e,l=t,s=M(!1),i=M(""),c=M(null),p=M(!1),f=N(()=>[...a.classes].sort((w,S)=>w.slug==="standard"&&S.slug!=="standard"?-1:w.slug!=="standard"&&S.slug==="standard"?1:0)),_=N(()=>["reduced","zero"].filter(w=>!a.classes.find(S=>S.slug===w))),g=()=>{i.value="",p.value=!1,s.value=!0,ke(()=>{var w;return(w=c.value)==null?void 0:w.focus()})},y=w=>{if(w==="custom"){g();return}l("add",w)},v=()=>{const w=i.value.trim();if(!w){b();return}l("create-custom",w)},b=()=>{s.value=!1,i.value="",p.value=!1},k=()=>{!a.creating&&!i.value.trim()&&b()};return be([()=>a.classes.length,()=>a.creating],([w,S],[$,V])=>{if(s.value){if(w>$){b();return}V&&!S&&(p.value=!0)}}),be(i,()=>{p.value=!1}),(w,S)=>{const $=C("el-input"),V=C("el-dropdown-item"),F=C("el-dropdown-menu"),x=C("el-dropdown");return r(),h("div",hpe,[o("div",_pe,[(r(!0),h(H,null,ae(f.value,Q=>(r(),h("button",{key:Q.id,class:de(["fct-tax-class-tabs__tab",{"fct-tax-class-tabs__tab--active":e.activeId==Q.id}]),onClick:D=>l("switch",Q)},[R(m(Q.title)+" ",1),Q.slug!=="standard"?(r(),h("span",{key:0,class:"fct-tax-class-tabs__delete",title:A(u)("Delete tax class"),onClick:Ne(D=>l("delete",Q),["stop"])},[n(J,{name:"Close"})],8,gpe)):B("",!0)],10,vpe))),128)),e.classes.length
i.value=Q),size:"small",maxlength:"30",disabled:e.creating,placeholder:A(u)("e.g. Luxury"),onKeyup:[xa(v,["enter"]),xa(b,["esc"])],onBlur:k},null,8,["modelValue","disabled","placeholder"]),o("button",{class:"fct-tax-class-tabs__inline-confirm",disabled:e.creating||!i.value.trim(),title:A(u)("Create tax class"),onMousedown:S[1]||(S[1]=Ne(()=>{},["prevent"])),onClick:v},[n(J,{name:"Check"})],40,ype),o("button",{class:"fct-tax-class-tabs__inline-cancel",disabled:e.creating,title:A(u)("Cancel"),onMousedown:S[2]||(S[2]=Ne(()=>{},["prevent"])),onClick:b},[n(J,{name:"Close"})],40,bpe)],2)):_.value.length?(r(),E(x,{key:1,trigger:"click",disabled:e.creating,onCommand:y,"popper-class":"fct-dropdown"},{dropdown:d(()=>[n(F,null,{default:d(()=>[_.value.includes("reduced")?(r(),E(V,{key:0,command:"reduced"},{default:d(()=>[R(m(A(u)("Reduced")),1)]),_:1})):B("",!0),_.value.includes("zero")?(r(),E(V,{key:1,command:"zero"},{default:d(()=>[R(m(A(u)("Zero")),1)]),_:1})):B("",!0),n(V,{command:"custom"},{default:d(()=>[R(m(A(u)("Custom Class...")),1)]),_:1})]),_:1})]),default:d(()=>[o("button",{class:"fct-tax-class-tabs__add",disabled:e.creating},[n(J,{name:"Plus"})],8,wpe)]),_:1},8,["disabled"])):(r(),h("button",{key:2,class:"fct-tax-class-tabs__add",disabled:e.creating,title:A(u)("Add custom tax class"),onClick:g},[n(J,{name:"Plus"})],8,Cpe))],64)):B("",!0)]),o("div",kpe,[n($,{"model-value":e.search,placeholder:A(u)("Search country or region…"),size:"small",clearable:"","onUpdate:modelValue":S[3]||(S[3]=Q=>l("update:search",Q)),onClear:S[4]||(S[4]=Q=>l("update:search",""))},{prefix:d(()=>[n(J,{name:"Search",class:"w-3.5 h-3.5 text-system-light dark:text-gray-400"})]),_:1},8,["model-value","placeholder"]),ba(w.$slots,"search-actions")])])}}},Bpe=(e=[])=>e.find(t=>t.slug==="standard")||e[0]||null,Id=({classes:e=[],activeId:t=null})=>(t?e.find(l=>l.id===t):null)||Bpe(e),xpe=({classes:e=[],previousIds:t=new Set,createdSlug:a=null})=>{if(a){const l=e.find(s=>s.slug===a);if(l)return l}return e.find(l=>!t.has(l.id))||null},zo=async({payload:e,createdSlug:t=null,currentClasses:a=[],reloadClasses:l})=>{const s=new Set((a||[]).map(p=>p.id)),i=await ue.post("tax/classes",e),c=await l();return{response:i,classes:c,createdClass:xpe({classes:c,previousIds:s,createdSlug:t})}},rf=async({classId:e,currentActiveId:t=null,reloadClasses:a})=>{const l=await ue.delete("tax/classes/"+e),s=await a();return{response:l,classes:s,nextActiveClass:Id({classes:s,activeId:t})}};function en(e){return e==null||e===""?"":String(e)}const Spe={class:"setting-wrap"},Fpe={class:"setting-wrap-inner"},$pe={class:"fct-single-tax-rates-country-single-page"},Epe={class:"fct-single-tax-rates-country-single"},Upe={class:"single-page-header flex items-center justify-between"},Ipe={key:0,class:"flex items-center gap-2"},Qpe={key:0,class:"notices fct-notices-wrap fct-layout-width settings"},Dpe={class:"mt-3 flex justify-end"},Vpe={key:1,class:"fct-base-taxes"},Tpe={class:"fct-btn-group mt-4 justify-end sm"},Mpe={class:"fct-tax-rates-country-view"},Lpe={key:0},Rpe={key:1},Ope={key:0},Hpe={key:1},Ppe={class:"fct-btn-group sm justify-end"},hc={__name:"TaxRatesCountrySingle",props:{country:{type:String},group:{type:String}},setup(e){const t=e,a=M(!1),l=M([]),s=M(""),i=N(()=>!!Ge.get("is_tax_enabled")),c=M([]),p=M(null),f=M("standard"),_=M(!1),g=M(null),y=M(6),v=M({id:null,rate:0,name:"Tax",state:"",is_compound:"0",for_order:0}),b=M({rate:0,name:""}),k=M([]),w=M({}),S=M(""),$=N(()=>{const Z=S.value.trim().toLowerCase();return Z?k.value.filter(we=>we.stateName&&we.stateName.toLowerCase().includes(Z)):k.value}),V=N(()=>t.group==="EU"),F=N(()=>[v.value,...$.value]),x=M([]),Q=M(!1),D=M([]),T=M([]),U=M(!1),I=M(new Set),O=M(0),L=M([]),P=M(!1),q=M(!1),X=M(!1),G=M({type:"products",original_type:"",original_id:"",category_id:"",category_name:"",state:"__country__",city:"",postcode:"",tax_label:"",tax_rate:0,override_state_tax:!0,class_id:0,id:"",previous_id:""}),te=N(()=>{const Z=v.value.rate||0;return[{label:u("added to")+` ${Z}% `+u("federal tax"),is_compound:"0",for_order:0},{label:u("instead of")+` ${Z}% `+u("federal tax"),is_compound:"0",for_order:1},{label:u("compounded on top of")+` ${Z}% `+u("federal tax"),is_compound:"1",for_order:0}]}),ne=Z=>String(Z.is_compound)==="1"?"1_0":Z.for_order==1?"0_1":"0_0",re=(Z,we)=>{const[le,pe]=we.split("_");Z.is_compound=le,Z.for_order=parseInt(pe)},K=Z=>Z&&Z.replace(/\s*\(Standard\)\s*/gi,"").trim(),Y=M(!1),W=M({}),j=M(!1),ie=M(""),he=M(""),me=M(""),ye=M(!1),se=M(!1),fe=M(!0),$e=M(!1),tt=M(!1),ve=M(!1),Je=N(()=>u("Toggle tax collection for %1$s",s.value||t.country)),vt=()=>ue.get("tax/classes").then(Z=>{c.value=Z.classes||[],y.value=Z.max_classes||6,g.value=Z.next_builtin||null;const we=Id({classes:c.value,activeId:p.value});return we&&(p.value=we.id,f.value=we.slug),c.value}).catch(Z=>c.value),Ye=(Z="")=>{if(!Z)return v.value.name||"Tax";const we=k.value.find(le=>le.state===Z);return we!=null&&we.name?we.name:v.value.name||"Tax"},xe=Z=>{v.value={...Z.federalRate},b.value={...Z.federalOriginal},k.value=Z.stateRows.map(we=>({...we})),w.value={...Z.stateOriginals}},Ee=()=>({federalRate:{...v.value},federalOriginal:{...b.value},stateRows:k.value.map(Z=>({...Z})),stateOriginals:{...w.value}}),Oe=()=>{p.value&&(W.value[p.value]=Ee())},Me=async Z=>{Oe(),p.value=Z.id,f.value=Z.slug,W.value[Z.id]?(xe(W.value[Z.id]),await mt()):await jt()},gt=Z=>{_.value=!0,zo({payload:{slug:Z},createdSlug:Z,currentClasses:c.value,reloadClasses:vt}).then(({response:we,createdClass:le})=>{if(z.success(we.message),le)return Me(le)}).catch(we=>{var le;z.error(((le=we==null?void 0:we.data)==null?void 0:le.message)||"Failed to create tax class")}).finally(()=>{_.value=!1})},yt=Z=>{_.value=!0,zo({payload:{title:Z},currentClasses:c.value,reloadClasses:vt}).then(({response:we,createdClass:le})=>{if(z.success(we.message),le)return Me(le)}).catch(we=>{var le;z.error(((le=we==null?void 0:we.data)==null?void 0:le.message)||"Failed to create tax class")}).finally(()=>{_.value=!1})},Mt=Z=>{const we=p.value===Z.id;rl(u("All rates for this class will be deleted. Products using it will default to Standard."),u("Delete")+" "+Z.title+"?",{confirmButtonText:u("Yes, Delete"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{rf({classId:Z.id,currentActiveId:p.value,reloadClasses:vt}).then(({response:le,nextActiveClass:pe})=>{if(delete W.value[Z.id],z.success(le.message),pe)return we&&(p.value=null),Me(pe)}).catch(le=>{var pe;z.error(((pe=le==null?void 0:le.data)==null?void 0:pe.message)||"Failed to delete tax class")})}).catch(()=>{})},Ut=()=>ue.get("address-info/get-country-info",{country_code:t.country}).then(Z=>{l.value=Z.states||[],s.value=Z.country_name||t.country}).catch(Z=>{z.error(u("Failed to load country data. Please refresh the page."))}),Dt=()=>V.value?(he.value="",me.value="",Promise.resolve()):(ye.value=!0,ue.get("tax/country-tax-id/"+t.country).then(Z=>{var le;const we=((le=Z==null?void 0:Z.tax_data)==null?void 0:le.tax_id)||"";he.value=we,me.value=we}).catch(Z=>{var we;z.error(((we=Z==null?void 0:Z.data)==null?void 0:we.message)||u("Failed to load tax ID"))}).finally(()=>{ye.value=!1})),ht=({hydrateClassData:Z=!0}={})=>ue.get("tax/rates/country/rates/"+t.country).then(we=>{const le=we.tax_rates||[],pe=le.filter(Ke=>Ke.for_shipping!==null),je=p.value?le.filter(Ke=>Number(Ke.class_id)===Number(p.value)):le;D.value=je.filter(Ke=>!Ke.city&&!Ke.postcode).map(Ke=>({name:Ke.name,value:Ke.id,state:Ke.state||""}));const at=It(je);return ve.value=le.length>0,Z&&(xe(at),Oe(),fe.value=!!we.tax_enabled,tt.value=!0),{allRates:le,shippingOverrides:pe,classEntry:at}}).catch(we=>(z.error(u("Failed to load tax rates. Please refresh the page.")),{allRates:[],shippingOverrides:[],classEntry:null})),Pt=()=>ue.get("tax/product-overrides/"+t.country).then(Z=>Z.overrides||[]).catch(()=>[]),Ct=()=>{L.value.length>0||(P.value=!0,ue.get("products/fetch-term").then(Z=>{const we=Z.taxonomies&&Z.taxonomies["product-categories"]?Z.taxonomies["product-categories"].terms||[]:[];L.value=we.map(le=>({...le,value:en(le.value)}))}).catch(()=>{}).finally(()=>{P.value=!1}))};let St=0;const Ot=Z=>{const we=++St;return!Z||Number(Z)===Number(p.value)?(T.value=D.value.slice(),U.value=!1,Promise.resolve()):(U.value=!0,T.value=[],ue.get("tax/rates/country/rates/"+t.country,{class_id:Z}).then(le=>{if(we!==St)return;const pe=le.tax_rates||[];T.value=pe.filter(je=>!je.city&&!je.postcode).map(je=>({name:je.name,value:je.id,state:je.state||""}))}).catch(()=>{we===St&&(T.value=[],z.error(u("Failed to load tax rates for the selected tax class")))}).finally(()=>{we===St&&(U.value=!1)}))},Ht=(Z,we)=>{var pe,je;const le=[];for(const at of Z){const Ke=at.state?((pe=l.value.find(Xe=>Xe.value===at.state))==null?void 0:pe.name)||at.state:s.value||t.country,qe=Ye(at.state||""),ft=c.value.find(Xe=>Number(Xe.id)===Number(at.class_id));le.push({id:at.id,type:"shipping",label:qe,tax_label:qe,category_name:"",location:Ke,city:at.city||"",postcode:at.postcode||"",rate:at.for_shipping,class_id:Number(at.class_id)||0,class_label:ft?ft.title:"",_raw:at})}for(const at of we){const Ke=at.meta_value||at,qe=Ke.state||"",ft=qe?((je=l.value.find(Xt=>Xt.value===qe))==null?void 0:je.name)||qe:s.value||t.country,Xe=Number(at.class_id)||0,Et=Xe?c.value.find(Xt=>Number(Xt.id)===Xe):null;le.push({id:at.id,type:"products",label:Ke.category_name||"",tax_label:Ke.tax_label||"",category_name:Ke.category_name||"",location:ft,city:Ke.city||"",postcode:Ke.postcode||"",rate:Ke.rate,class_id:Xe,class_label:Et?Et.title:"",_raw:at})}x.value=le},It=Z=>{const we=Xe=>(!Xe.state||Xe.state==="")&&(!Xe.city||Xe.city==="")&&(!Xe.postcode||Xe.postcode===""),le=Z.find(we),pe=Z.filter(Xe=>Xe.state&&Xe.state!==""&&(!Xe.city||Xe.city==="")&&(!Xe.postcode||Xe.postcode===""));let je,at;if(le){const Xe=K(le.name)||"Tax";je={...le,name:Xe},at={rate:le.rate,name:Xe}}else je={id:null,rate:0,name:"Tax",state:"",is_compound:"0",for_order:0},at={rate:0,name:"Tax"};const Ke={};for(const Xe of pe)Ke[Xe.state]=Xe;const qe=[],ft={};for(const Xe of l.value){const Et=Ke[Xe.value];if(Et){const Xt=K(Et.name)||"State Tax";qe.push({id:Et.id,state:Xe.value,stateName:Xe.name,rate:Et.rate,name:Xt,is_compound:String(Et.is_compound||"0"),for_order:Et.for_order||0}),ft[Xe.value]={rate:Et.rate,name:Xt,is_compound:String(Et.is_compound||"0"),for_order:Et.for_order||0}}else qe.push({id:null,state:Xe.value,stateName:Xe.name,rate:0,name:"State Tax",is_compound:"0",for_order:0}),ft[Xe.value]={rate:0,name:"State Tax",is_compound:"0",for_order:0}}return{federalRate:je,federalOriginal:at,stateRows:qe,stateOriginals:ft}},mt=async()=>{const[{shippingOverrides:Z},we]=await Promise.all([ht({hydrateClassData:!1}),Pt()]);Ht(Z,we)},jt=async()=>{a.value=!0;try{const[{shippingOverrides:Z},we]=await Promise.all([ht(),Pt()]);Ht(Z,we)}finally{a.value=!1}},ge=async()=>{a.value=!0;try{await Promise.all([vt(),Ut(),Dt()]),await jt()}finally{a.value=!1}},Fe=()=>{V.value||se.value||ye.value||(se.value=!0,ue.post("tax/country-tax-id/"+t.country,{tax_id:he.value||""}).then(Z=>{me.value=he.value||"",z.success(Z.message||u("Tax ID has been saved successfully"))}).catch(Z=>{var we;z.error(((we=Z==null?void 0:Z.data)==null?void 0:we.message)||u("Failed to save tax ID"))}).finally(()=>{se.value=!1}))},nt=Z=>{if($e.value)return;const we=fe.value;fe.value=Z,$e.value=!0,ue.post("tax/country-status/"+t.country,{enabled:Z?1:0}).then(le=>{fe.value=le.enabled,z.success(le.message)}).catch(le=>{var pe;fe.value=we,z.error(((pe=le==null?void 0:le.data)==null?void 0:pe.message)||u("Failed to update tax status"))}).finally(()=>{$e.value=!1})},bt=async()=>{try{await rl(u("This will overwrite your current rates with preset defaults. Continue?"),u("Reset to default tax rates"),{confirmButtonText:u("Reset"),cancelButtonText:u("Cancel"),type:"warning"})}catch{return}j.value=!0;try{const we=(await ue.get("tax/configuration/rates")).tax_rates||{};let le=[];for(const qe in we){const ft=we[qe];for(const Xe of ft.countries||[])if(Xe.country_code===t.country){le=Xe.rates||[];break}if(le.length)break}if(!le.length){z.error(u("No preset rates found for this country"));return}const pe=le.find(qe=>(!qe.state||qe.state==="")&&qe.type==="standard"),je=le.filter(qe=>qe.state&&qe.state!==""&&qe.type==="standard"),at=[];pe&&pe.rate>0&&(v.value.rate=pe.rate,v.value.name=K(pe.name||"")||u("Tax"),at.push(Bt()));const Ke=[];for(const qe of je){const ft=k.value.find(Xe=>Xe.state===qe.state);ft&&(ft.rate=qe.rate,ft.name=K(qe.name)||u("State Tax"),ft.is_compound=qe.compound?"1":"0",Ke.push(Wt(ft)))}await Promise.all([...at,...Ke]),Oe(),await mt(),z.success(u("Tax rates have been reset to defaults"))}catch{z.error(u("Failed to reset tax rates"))}finally{j.value=!1}},Bt=()=>{const Z={country:t.country,state:"",rate:v.value.rate,name:v.value.name||"Tax",is_compound:v.value.is_compound||"0",for_order:v.value.for_order||0,group:t.group,class_id:p.value||""};return(v.value.id?ue.put("tax/country/rate/"+v.value.id,Z):ue.post("tax/country/rate",Z)).then(le=>{le.tax_rate&&(v.value.id=le.tax_rate.id),b.value={rate:v.value.rate,name:v.value.name}})},Wt=Z=>{const we={country:t.country,state:Z.state,rate:Z.rate,name:Z.name,is_compound:Z.is_compound,for_order:Z.for_order,group:t.group,class_id:p.value||""};return(Z.id?ue.put("tax/country/rate/"+Z.id,we):ue.post("tax/country/rate",we)).then(pe=>{pe.tax_rate&&(Z.id=pe.tax_rate.id),w.value[Z.state]={rate:Z.rate,name:Z.name,is_compound:String(Z.is_compound),for_order:Z.for_order}})},_t=async()=>{Y.value=!0;try{const Z=[];(String(v.value.rate)!==String(b.value.rate)||v.value.name!==b.value.name)&&Z.push(Bt());for(const le of k.value){const pe=w.value[le.state];(!pe||String(le.rate)!==String(pe.rate)||le.name!==pe.name||String(le.is_compound)!==String(pe.is_compound)||le.for_order!=pe.for_order)&&Z.push(Wt(le))}await Promise.all(Z),Oe(),await mt(),z.success(u("Tax rates saved"))}catch{z.error(u("Failed to save rates"))}finally{Y.value=!1}},la=()=>{I.value=new Set,O.value=0},sa=()=>{const Z=Ye();X.value=!1,G.value={type:"products",original_type:"",original_id:"",category_id:"",category_name:"",state:"__country__",city:"",postcode:"",tax_label:Z,tax_rate:0,override_state_tax:!0,class_id:Number(p.value)||0,id:"",previous_id:""},ie.value=Z,T.value=D.value.slice(),Q.value=!0,Ct()},Nt=Z=>{if(X.value=!0,Ct(),Z.type==="shipping"){const we=Z._raw.state||"",le=Ye(we),pe=Number(Z._raw.class_id)||Number(p.value)||0;G.value={type:"shipping",original_type:"shipping",original_id:Z.id,category_id:"",category_name:"",state:we||"__country__",city:Z._raw.city||"",postcode:Z._raw.postcode||"",tax_label:le,tax_rate:Z.rate,override_state_tax:!0,class_id:pe,id:Z.id,previous_id:Z.id},ie.value=le,O.value=pe,Ot(pe);const je=Z._raw.city||"",at=Z._raw.postcode||"",Ke=new Set;for(const qe of x.value)qe.type==="shipping"&&(qe._raw.state||"")===we&&(qe._raw.city||"")===je&&(qe._raw.postcode||"")===at&&Ke.add(Number(qe.class_id));I.value=Ke}else{const we=Z._raw.meta_value||Z._raw,le=we.state||"",pe=Ye(le),je=Z.tax_label||pe;G.value={type:"products",original_type:"products",original_id:Z.id,category_id:en(we.category_id),category_name:Z.category_name,state:le||"__country__",tax_label:je,tax_rate:Z.rate,override_state_tax:we.override_state_tax==="yes",city:we.city||"",postcode:we.postcode||"",class_id:Z.class_id||0,id:Z.id,previous_id:""},ie.value=pe}Q.value=!0},ia=N(()=>{const Z=[{label:s.value||t.country,value:"__country__"}];for(const we of l.value)Z.push({label:we.name,value:we.value});return Z}),el=N(()=>{if(!T.value.length)return ia.value;const Z=new Set(T.value.map(we=>we.state||""));return ia.value.filter(we=>{const le=we.value==="__country__"?"":we.value;return Z.has(le)})}),Ll=Z=>{const we=en(Z),le=L.value.find(pe=>pe.value===we);le&&(G.value.category_name=le.label)},Ra=Z=>{rl(u("Are you sure you want to delete this override?"),u("Confirm Delete"),{confirmButtonText:u("Yes, Delete"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{const we=Z.type==="shipping"?"tax/rates/country/override/"+Z.id:"tax/product-overrides/"+Z.id;ue.delete(we).then(le=>{z.success(le.message),x.value=x.value.filter(pe=>!(pe.id===Z.id&&pe.type===Z.type))}).catch(le=>{var pe;z.error(((pe=le==null?void 0:le.data)==null?void 0:pe.message)||u("Failed to delete override"))})}).catch(()=>{})},na=async()=>{var we;const Z=G.value.state==="__country__"?"":G.value.state;if(G.value.type==="products"&&!G.value.category_id){z.error(u("Please select a category"));return}if(G.value.type==="shipping"){if(!G.value.class_id){z.error(u("Please select a tax class"));return}if(U.value){z.error(u("Please wait for the province rates to finish loading"));return}const le=T.value.find(pe=>(pe.state||"")===Z);G.value.id=le?le.value:0}q.value=!0;try{let le;if(G.value.type==="products"){const pe=G.value.state==="__country__"?"":G.value.state;le=await ue.post("tax/product-overrides",{id:X.value&&G.value.original_type==="products"?G.value.original_id:"",source_type:G.value.original_type,source_id:G.value.original_id,country:t.country,state:pe,category_id:G.value.category_id,category_name:G.value.category_name,tax_label:G.value.tax_label,rate:G.value.tax_rate,override_state_tax:G.value.override_state_tax===!0?"yes":"no",city:G.value.city||"",postcode:G.value.postcode||"",class_id:G.value.class_id||0})}else le=await ue.post("tax/rates/country/override",{id:G.value.id,country:t.country,state:Z,previous_id:X.value&&G.value.original_type==="shipping"?G.value.previous_id:"",source_type:G.value.original_type,source_id:G.value.original_id,class_id:G.value.class_id||p.value||"",override_tax_rate:G.value.tax_rate,city:G.value.city||"",postcode:G.value.postcode||""});z.success(le.message),Q.value=!1,await mt()}catch(le){const pe=((we=le==null?void 0:le.data)==null?void 0:we.message)||(le==null?void 0:le.message)||"Failed to save override";z.error(pe)}finally{q.value=!1}};return be(()=>G.value.type,Z=>{Z==="shipping"&&(G.value.class_id||(G.value.class_id=p.value||0),Ot(G.value.class_id))}),be(()=>G.value.class_id,Z=>{G.value.type!=="shipping"||!Q.value||Ot(Z).then(()=>{const we=G.value.state==="__country__"?"":G.value.state,le=T.value.map(pe=>pe.state||"");we!==""&&!le.includes(we)&&(G.value.state="__country__")})}),be(()=>G.value.state,Z=>{if(!Q.value||G.value.type!=="products"||X.value)return;const we=Ye(Z==="__country__"?"":Z);(!G.value.tax_label||G.value.tax_label===ie.value)&&(G.value.tax_label=we),ie.value=we}),Ie(()=>{ge()}),(Z,we)=>{const le=C("el-breadcrumb-item"),pe=C("el-breadcrumb"),je=C("el-switch"),at=C("el-skeleton"),Ke=C("el-input"),qe=C("el-form-item"),ft=C("el-form"),Xe=C("el-button"),Et=C("el-table-column"),Xt=C("el-option"),Ae=C("el-select"),_e=C("el-table"),Le=C("el-tag"),Ve=C("el-radio"),ee=C("el-radio-group"),He=C("el-checkbox"),ut=C("el-dialog");return r(),h("div",Spe,[o("div",Fpe,[o("div",$pe,[o("div",Epe,[o("div",Upe,[n(pe,{class:"mb-0","separator-icon":A(dl)},{default:d(()=>[e.group==="EU"?(r(),E(le,{key:0,to:{name:"eu"}},{default:d(()=>[R(m(A(u)("Tax Regions")),1)]),_:1})):(r(),E(le,{key:1,to:{name:"tax_rates"}},{default:d(()=>[R(m(A(u)("Tax Regions")),1)]),_:1})),n(le,null,{default:d(()=>[R(m(s.value||e.country),1)]),_:1})]),_:1},8,["separator-icon"]),tt.value&&ve.value?(r(),h("div",Ipe,[i.value?(r(),h("span",{key:0,class:de(["text-sm",fe.value?"text-success-500":"text-system-mid dark:text-gray-300"])},m(fe.value?A(u)("Collecting tax"):A(u)("Disabled")),3)):B("",!0),n(je,{"model-value":i.value?fe.value:!1,loading:$e.value,disabled:!i.value,"aria-label":Je.value,onChange:nt},null,8,["model-value","loading","disabled","aria-label"])])):B("",!0)]),!a.value&&!i.value?(r(),h("div",Qpe,[n(Xa,{type:"warning",icon:"AlertTriangle",content:A(u)("Tax is currently disabled. Enable tax from the Tax Settings page to start collecting tax.")},null,8,["content"])])):B("",!0),V.value?B("",!0):(r(),E(Be,{key:1},{default:d(()=>[n(Ce,null,{default:d(()=>[ye.value?(r(),E(at,{key:0,animated:"",rows:2})):(r(),E(ft,{key:1,"label-position":"top"},{default:d(()=>[n(qe,{label:A(u)("VAT/GST/Tax Number"),class:"mb-0"},{default:d(()=>[n(Ke,{modelValue:he.value,"onUpdate:modelValue":we[0]||(we[0]=Se=>he.value=Se),placeholder:A(u)("VAT/GST/Tax Number"),maxlength:"255"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})),o("div",Dpe,[n(Xe,{type:"primary",size:"small",loading:se.value,disabled:ye.value||se.value||he.value===me.value,onClick:Fe},{default:d(()=>[R(m(A(u)("Save")),1)]),_:1},8,["loading","disabled"])])]),_:1})]),_:1})),n(Be,null,{default:d(()=>[n(Qe,{title:A(u)("Base taxes")},null,8,["title"]),n(Ce,null,{default:d(()=>[n(Xa,{type:"info"},{content:d(()=>[o("span",null,m(A(u)("Rates are pre-filled for convenience and may not reflect current laws — verify with a tax advisor before going live. If you sell products taxed at different rates (e.g. food, books, digital goods), use the"))+" + "+m(A(u)("button to add tax classes.")),1)]),_:1}),a.value?(r(),E(mpe,{key:0})):(r(),h("div",Vpe,[n(of,{classes:c.value,"active-id":p.value,"max-classes":y.value,creating:_.value,search:S.value,onSwitch:Me,onDelete:Mt,onAdd:gt,onCreateCustom:yt,"onUpdate:search":we[1]||(we[1]=Se=>S.value=Se)},null,8,["classes","active-id","max-classes","creating","search"]),n(_e,{data:F.value,class:"w-full fct-tax-rates-table","max-height":"450"},{default:d(()=>[n(Et,{label:A(u)("Region")},{default:d(({row:Se})=>[o("span",{class:de(["fct-base-taxes__region-name",Se.state?"":"fct-base-taxes__region-name--federal"])},m(Se.state?Se.stateName:s.value||e.country),3)]),_:1},8,["label"]),n(Et,{label:A(u)("Rate"),width:"130"},{default:d(({row:Se})=>[n(Ke,{modelValue:Se.rate,"onUpdate:modelValue":kt=>Se.rate=kt,size:"small",type:"number",step:"0.01",min:"0"},{suffix:d(()=>we[18]||(we[18]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:1},8,["label"]),n(Et,{label:A(u)("Tax Label"),width:"200"},{default:d(({row:Se})=>[n(Ke,{modelValue:Se.name,"onUpdate:modelValue":kt=>Se.name=kt,size:"small",placeholder:A(u)("Tax name")},null,8,["modelValue","onUpdate:modelValue","placeholder"])]),_:1},8,["label"]),k.value.length>0?(r(),E(Et,{key:0,label:A(u)("Compound"),width:"310"},{default:d(({row:Se})=>[Se.state?(r(),E(Ae,{key:0,"model-value":ne(Se),size:"small",style:{width:"100%"},onChange:kt=>re(Se,kt)},{default:d(()=>[n(Xt,{value:"0_0",label:te.value[0].label},null,8,["label"]),n(Xt,{value:"0_1",label:te.value[1].label},null,8,["label"]),n(Xt,{value:"1_0",label:te.value[2].label},null,8,["label"])]),_:2},1032,["model-value","onChange"])):B("",!0)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"]),o("div",Tpe,[f.value==="standard"?(r(),E(Xe,{key:0,loading:j.value,size:"small",onClick:bt,type:"danger",soft:""},{default:d(()=>[R(m(A(u)("Reset to default")),1)]),_:1},8,["loading"])):B("",!0),n(Xe,{type:"primary",size:"small",loading:Y.value,onClick:_t},{default:d(()=>[R(m(A(u)("Save Rates")),1)]),_:1},8,["loading"])])]))]),_:1})]),_:1}),n(Be,null,{default:d(()=>[n(Qe,{title:A(u)("Tax overrides"),text:A(u)("Override tax rates for specific product categories or shipping.")},{action:d(()=>[n(Xe,{size:"small",onClick:sa},{default:d(()=>[R(m(A(u)("Add Tax Override")),1)]),_:1})]),_:1},8,["title","text"]),n(Ce,null,{default:d(()=>[o("div",Mpe,[n(_e,{data:x.value,"empty-text":A(u)("No overrides configured")},{default:d(()=>[n(Et,{label:A(u)("Type"),width:"110"},{default:d(({row:Se})=>[n(Le,{type:Se.type==="products"?"primary":"info",size:"small"},{default:d(()=>[R(m(Se.type==="products"?A(u)("Product"):A(u)("Shipping")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),n(Et,{label:A(u)("Category")},{default:d(({row:Se})=>[R(m(Se.category_name||"—"),1)]),_:1},8,["label"]),n(Et,{label:A(u)("Tax Label")},{default:d(({row:Se})=>[R(m(Se.tax_label||"—"),1)]),_:1},8,["label"]),n(Et,{label:A(u)("Location")},{default:d(({row:Se})=>[R(m(Se.location),1)]),_:1},8,["label"]),n(Et,{label:A(u)("Tax Class"),width:"130"},{default:d(({row:Se})=>[Se.type==="products"?(r(),h("span",Lpe,m(Se.class_label||A(u)("All")),1)):(r(),h("span",Rpe,m(Se.class_label||"—"),1))]),_:1},8,["label"]),n(Et,{label:A(u)("City / Postcode")},{default:d(({row:Se})=>[Se.city||Se.postcode?(r(),h("span",Ope,m([Se.city,Se.postcode].filter(Boolean).join(" / ")),1)):(r(),h("span",Hpe,"—"))]),_:1},8,["label"]),n(Et,{label:A(u)("Rate"),width:"100"},{default:d(({row:Se})=>[R(m(Se.rate)+"% ",1)]),_:1},8,["label"]),n(Et,{label:A(u)("Actions"),width:"110",align:"right"},{default:d(({row:Se})=>[o("div",Ppe,[n(Ze,{tag:"button",size:"small",onClick:kt=>Nt(Se)},{default:d(()=>[n(J,{name:"Edit"})]),_:2},1032,["onClick"]),n(Ze,{tag:"button",size:"small",onClick:kt=>Ra(Se),bg:"danger",outline:""},{default:d(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick"])])]),_:1},8,["label"])]),_:1},8,["data","empty-text"])])]),_:1})]),_:1}),n(ut,{modelValue:Q.value,"onUpdate:modelValue":we[17]||(we[17]=Se=>Q.value=Se),title:(X.value?A(u)("Edit tax override for"):A(u)("Add tax override for"))+" "+(s.value||e.country),width:"520px","append-to-body":!0,onClose:la},{footer:d(()=>[n(Xe,{onClick:we[16]||(we[16]=Se=>Q.value=!1)},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(Xe,{type:"primary",loading:q.value,onClick:na},{default:d(()=>[R(m(X.value?A(u)("Save changes"):A(u)("Add override")),1)]),_:1},8,["loading"])]),default:d(()=>[n(ft,{"label-position":"top",model:G.value},{default:d(()=>[n(qe,{label:A(u)("Override type")},{default:d(()=>[n(ee,{modelValue:G.value.type,"onUpdate:modelValue":we[2]||(we[2]=Se=>G.value.type=Se)},{default:d(()=>[n(Ve,{value:"products"},{default:d(()=>[R(m(A(u)("Products")),1)]),_:1}),n(Ve,{value:"shipping"},{default:d(()=>[R(m(A(u)("Shipping")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),G.value.type==="products"?(r(),h(H,{key:0},[n(qe,{label:A(u)("Category")},{default:d(()=>[n(Ae,{modelValue:G.value.category_id,"onUpdate:modelValue":we[3]||(we[3]=Se=>G.value.category_id=Se),filterable:"",placeholder:A(u)("Select a category"),loading:P.value,style:{width:"100%"},onChange:Ll},{default:d(()=>[(r(!0),h(H,null,ae(L.value,Se=>(r(),E(Xt,{key:Se.value,label:Se.label,value:Se.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","loading"])]),_:1},8,["label"]),n(qe,{label:A(u)("Tax Class")},{default:d(()=>[n(Ae,{modelValue:G.value.class_id,"onUpdate:modelValue":we[4]||(we[4]=Se=>G.value.class_id=Se),style:{width:"100%"}},{default:d(()=>[n(Xt,{value:0,label:A(u)("All Tax Classes")},null,8,["label"]),(r(!0),h(H,null,ae(c.value,Se=>(r(),E(Xt,{key:Se.id,value:Number(Se.id),label:Se.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"]),n(qe,{label:A(u)("Tax label")},{default:d(()=>[n(Ke,{modelValue:G.value.tax_label,"onUpdate:modelValue":we[5]||(we[5]=Se=>G.value.tax_label=Se),placeholder:A(u)("e.g. Tax, VAT, GST")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(qe,{label:A(u)("Location")},{default:d(()=>[n(Ae,{modelValue:G.value.state,"onUpdate:modelValue":we[6]||(we[6]=Se=>G.value.state=Se),placeholder:A(u)("Select location"),filterable:"",style:{width:"100%"}},{default:d(()=>[(r(!0),h(H,null,ae(ia.value,Se=>(r(),E(Xt,{key:Se.value,label:Se.label,value:Se.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(qe,{label:A(u)("City (optional)")},{default:d(()=>[n(Ke,{modelValue:G.value.city,"onUpdate:modelValue":we[7]||(we[7]=Se=>G.value.city=Se),placeholder:A(u)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(qe,{label:A(u)("Postcode (optional)")},{default:d(()=>[n(Ke,{modelValue:G.value.postcode,"onUpdate:modelValue":we[8]||(we[8]=Se=>G.value.postcode=Se),placeholder:A(u)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(qe,{label:A(u)("Tax rate (%)")},{default:d(()=>[n(Ke,{modelValue:G.value.tax_rate,"onUpdate:modelValue":we[9]||(we[9]=Se=>G.value.tax_rate=Se),type:"number",step:"0.01",min:"0",placeholder:A(u)("e.g. 0 for tax exempt")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),k.value.length>0?(r(),E(qe,{key:0},{default:d(()=>[n(He,{modelValue:G.value.override_state_tax,"onUpdate:modelValue":we[10]||(we[10]=Se=>G.value.override_state_tax=Se)},{default:d(()=>[R(m(A(u)("Also override state/provincial taxes")),1)]),_:1},8,["modelValue"])]),_:1})):B("",!0)],64)):(r(),h(H,{key:1},[n(qe,{label:A(u)("Tax Class")},{default:d(()=>[n(Ae,{modelValue:G.value.class_id,"onUpdate:modelValue":we[11]||(we[11]=Se=>G.value.class_id=Se),style:{width:"100%"},loading:U.value},{default:d(()=>[(r(!0),h(H,null,ae(c.value,Se=>(r(),E(Xt,{key:Se.id,value:Number(Se.id),label:Se.title,disabled:X.value&&Number(Se.id)!==Number(O.value)&&I.value.has(Number(Se.id))},null,8,["value","label","disabled"]))),128))]),_:1},8,["modelValue","loading"])]),_:1},8,["label"]),n(qe,{label:A(u)("Location")},{default:d(()=>[n(Ae,{modelValue:G.value.state,"onUpdate:modelValue":we[12]||(we[12]=Se=>G.value.state=Se),placeholder:A(u)("Select location"),filterable:"",style:{width:"100%"}},{default:d(()=>[(r(!0),h(H,null,ae(el.value,Se=>(r(),E(Xt,{key:Se.value,label:Se.label,value:Se.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(qe,{label:A(u)("City (optional)")},{default:d(()=>[n(Ke,{modelValue:G.value.city,"onUpdate:modelValue":we[13]||(we[13]=Se=>G.value.city=Se),placeholder:A(u)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(qe,{label:A(u)("Postcode (optional)")},{default:d(()=>[n(Ke,{modelValue:G.value.postcode,"onUpdate:modelValue":we[14]||(we[14]=Se=>G.value.postcode=Se),placeholder:A(u)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(qe,{label:A(u)("Tax rate (%)")},{default:d(()=>[n(Ke,{modelValue:G.value.tax_rate,"onUpdate:modelValue":we[15]||(we[15]=Se=>G.value.tax_rate=Se),type:"number",step:"0.01",min:"0"},null,8,["modelValue"])]),_:1},8,["label"])],64))]),_:1},8,["model"])]),_:1},8,["modelValue","title"])])])])])}}};class Npe extends Qs{getTabs(){return{all:u("All"),filed:u("Filed"),not_filed:u("Not Filed")}}getToggleableColumns(){return[{label:"ID",value:"id"},{label:"Order ID",value:"order_id"},{label:"Zip Code",value:"postcode"},{label:"Tax Rate",value:"rate"},{label:"Filed",value:"filed_at"}]}getSearchHint(){return u("Search by id, title, content or module.")}getFetchUrl(){return"taxes"}parseResponse(t){return t.taxes}getTableName(){return"taxes_table"}with(){return["admin_tax_report"]}scopes(){return["validOrder"]}}function Kpe(e){return Npe.init(e)}const Gpe=e=>e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase()),jpe=e=>{const t=Object.keys(e[0]),l=[t.map(Gpe).join(",")];return e.forEach(s=>{const i=t.map(c=>{let p=s[c];return typeof p=="object"&&(p=JSON.stringify(p)),typeof p=="string"&&(p=`"${p.replace(/"/g,'""')}"`),p});l.push(i.join(","))}),l.join(`
`)},zpe=(e,t="export.csv")=>new Promise((a,l)=>{try{if(!e||!e.length)throw new Error("No data to export");const s=jpe(e),i=new Blob([s],{type:"text/csv"}),c=document.createElement("a"),p=()=>{window.removeEventListener("focus",p),a()};window.addEventListener("focus",p),c.href=URL.createObjectURL(i),c.download=t,c.click(),URL.revokeObjectURL(c.href),setTimeout(()=>{a()},200)}catch(s){l(s)}}),qpe={class:"table-cell"},Ype={class:"table-cell"},Wpe={class:"table-cell"},Jpe={class:"table-cell"},Xpe={class:"table-cell"},Zpe={class:"table-cell"},efe={class:"table-cell"},tfe={class:"table-cell"},afe={class:"table-cell"},lfe={__name:"TaxesLoader",props:{nextPageCount:{type:Number,default:0},taxTable:{type:Object,default:()=>({})}},setup(e){const t=e,a=Array.from({length:t.nextPageCount},(l,s)=>s+1);return(l,s)=>{const i=C("el-table-column"),c=C("el-skeleton-item"),p=C("el-skeleton"),f=C("el-table");return r(),E(f,{data:A(a),class:"w-full compact-table full-compact"},{default:d(()=>[n(i,{type:"selection",width:45}),e.taxTable.isColumnVisible("id")?(r(),E(i,{key:0,width:100,label:A(u)("ID")},{default:d(()=>[o("div",qpe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.taxTable.isColumnVisible("order_id")?(r(),E(i,{key:1,label:A(u)("Order ID"),width:100},{default:d(()=>[o("div",Ype,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(i,{label:A(u)("Tax Country"),width:120},{default:d(()=>[o("div",Wpe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"]),n(i,{label:A(u)("Tax Region"),width:120},{default:d(()=>[o("div",Jpe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("postcode")?(r(),E(i,{key:2,label:A(u)("Zip Code"),width:120},{default:d(()=>[o("div",Xpe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(i,{label:A(u)("Tax Name"),width:120},{default:d(()=>[o("div",Zpe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("rate")?(r(),E(i,{key:3,label:A(u)("Tax Rate"),width:120},{default:d(()=>[o("div",efe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(i,{label:A(u)("Sale Taxes"),width:120},{default:d(()=>[o("div",tfe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("filed_at")?(r(),E(i,{key:4,label:A(u)("Filed"),width:120},{default:d(()=>[o("div",afe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])}}},sfe={class:"table-cell"},nfe={class:"table-cell"},ofe={class:"table-cell"},ife={class:"table-cell"},rfe={class:"table-cell"},dfe={class:"table-cell"},ufe={class:"table-cell"},cfe={class:"table-cell"},Afe={class:"table-cell"},pfe={__name:"AllCouponsLoader",props:{nextPageCount:{type:Number,default:0},couponTable:{type:Object,default:()=>({})}},setup(e){const t=e,a=Array.from({length:t.nextPageCount},(l,s)=>s+1);return(l,s)=>{const i=C("el-skeleton-item"),c=C("el-skeleton"),p=C("el-table-column"),f=C("el-table");return r(),E(f,{data:A(a),class:"w-full compact-table responsive full-compact"},{default:d(()=>[n(p,{width:103,label:A(u)("ID")},{default:d(()=>[o("div",sfe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[70px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("title")?(r(),E(p,{key:0,label:A(u)("Title"),width:227},{default:d(()=>[o("div",nfe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[180px]"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(p,{label:A(u)("Code"),width:206},{default:d(()=>[o("div",ofe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[130px]"})]),_:1})])]),_:1},8,["label"]),n(p,{label:A(u)("Amount"),width:124},{default:d(()=>[o("div",ife,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:1},8,["label"]),n(p,{label:A(u)("Usage"),width:155},{default:d(()=>[o("div",rfe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("stackable")?(r(),E(p,{key:1,label:A(u)("Stackable"),width:124},{default:d(()=>[o("div",dfe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[80px]"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(p,{label:A(u)("Status"),width:124},{default:d(()=>[o("div",ufe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[90px]"})]),_:1})])]),_:1},8,["label"]),n(p,{label:A(u)("Expiry Date"),width:124},{default:d(()=>[o("div",cfe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[90px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("actions")?(r(),E(p,{key:2,label:A(u)("Actions"),width:103,align:"right"},{default:d(()=>[o("div",Afe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[70px]"})]),_:1})])]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])}}},ffe={class:"fct-taxes-page fct-layout-width"},mfe={key:1},hfe={style:{display:"flex","flex-wrap":"wrap","align-items":"center",gap:"4px"}},_fe={class:"fct-tax-filing-wrap"},vfe={class:"fct-tax-filing-summary"},gfe={class:"summary-item"},yfe={class:"summary-label"},bfe={class:"summary-value"},wfe={class:"summary-item"},Cfe={class:"summary-label"},kfe={class:"summary-value"},Bfe={class:"fct-tax-filing max-h-[400px] overflow-y-auto"},xfe={style:{display:"flex","flex-wrap":"wrap","align-items":"center",gap:"4px"}},Sfe={class:"dialog-footer"},Ffe={class:"fct-tax-filing-success-wrap"},$fe={class:"fct-tax-filling-success-icon"},Efe={class:"dialog-footer"},Ufe={__name:"Taxes",setup(e){const t=Object.fromEntries(rm.map(x=>[x.value,x.label])),a=x=>t[x]||x;Yt().ctx;const l=Kpe(),s=M(!1),i=M(!1),c=M(!1),p=M([]),f=N(()=>l.getTableData().map(x=>{var Q,D,T,U,I,O,L,P,q,X,G;return{id:x.id,order_id:x.order_id,country:a(((Q=x.tax_rate)==null?void 0:Q.country)??((D=x.meta)==null?void 0:D.tax_country)??""),state:((T=x.tax_rate)==null?void 0:T.formatted_state)??((U=x.tax_rate)==null?void 0:U.state)??"",postcode:((I=x.tax_rate)==null?void 0:I.postcode)??"",name:((O=x.tax_rate)==null?void 0:O.name)??((L=x.meta)==null?void 0:L.label)??"",reverse_charge:!!((P=x.meta)!=null&&P.reverse_charge_applied),rate:((q=x.tax_rate)==null?void 0:q.rate)??((X=x.meta)==null?void 0:X.rate_percent)??"",total_tax:String(parseFloat((x.total_tax/100).toFixed(2))),currency:((G=x.order)==null?void 0:G.currency)||"",total_tax:String(parseFloat((x.total_tax/100).toFixed(2))),filed_at:x.filed_at?u("Yes"):u("No")}})),_=()=>{s.value=!0,i.value=!1},g=()=>{s.value=!1,i.value=!0},y=async()=>{try{await zpe($.value),g()}catch{}},v=()=>{i.value=!1},b=()=>{const x=$.value.map(Q=>Q.id);ue.post(l.getFetchUrl(),{ids:x}).then(Q=>{z.success(Q.message),l.fetch()}).catch(Q=>{z.error(Q)}).finally(()=>{v()})},k=x=>{p.value=x,c.value=x.length>0},w=x=>{$.value=x},S=M(null),$=M([]),V=N(()=>{const x=$.value.reduce((D,T)=>D+parseFloat(T.total_tax||0),0),Q=[...new Set($.value.map(D=>D.order_id))];return{totalTax:pt.formatNumber(Math.round(x*100),!1),totalOrders:Q.length,items:$.value}}),F=()=>{ke(()=>{$.value=[...p.value],p.value.forEach(x=>{S.value.toggleRowSelection(x,!0)})})};return(x,Q)=>{const D=C("el-button"),T=C("el-tooltip"),U=C("el-table-column"),I=C("router-link"),O=C("el-tag"),L=C("el-table"),P=C("el-dialog");return r(),h("div",ffe,[n(nl,{title:A(u)("Taxes")},{action:d(()=>[c.value?(r(),E(D,{key:1,type:"primary",onClick:_,disabled:!c.value},{default:d(()=>[R(m(A(u)("Tax Filing")),1)]),_:1},8,["disabled"])):(r(),E(T,{key:0,"popper-class":"fct-tooltip",effect:"dark",content:A(u)("Please select the taxes you want to file"),placement:"top-start"},{default:d(()=>[n(D,{type:"primary",disabled:!c.value},{default:d(()=>[R(m(A(u)("Tax Filing")),1)]),_:1},8,["disabled"])]),_:1},8,["content"]))]),_:1},8,["title"]),n(Ds,{table:A(l),"has-mobile-slot":!1},{default:d(()=>[A(l).isLoading()?(r(),E(lfe,{key:0,taxTable:A(l),"next-page-count":A(l).nextPageCount},null,8,["taxTable","next-page-count"])):(r(),h("div",mfe,[n(L,{class:"w-full",data:f.value,onSelectionChange:k},{empty:d(()=>[n(wt,{icon:"Empty/ListView","has-dark":!0,text:A(u)("We could't find any taxes matching your filter.")},null,8,["text"])]),default:d(()=>[n(U,{type:"selection",width:45}),A(l).isColumnVisible("id")?(r(),E(U,{key:0,label:A(u)("ID"),width:100},{default:d(q=>[o("span",null,"#"+m(A(u)(q.row.id)),1)]),_:1},8,["label"])):B("",!0),A(l).isColumnVisible("order_id")?(r(),E(U,{key:1,label:A(u)("Order ID"),width:100},{default:d(q=>[o("span",hfe,[n(I,{class:"link",to:{name:"view_order",params:{order_id:q.row.order_id}}},{default:d(()=>[R(" #"+m(q.row.order_id),1)]),_:2},1032,["to"]),q.row.reverse_charge?(r(),E(O,{key:0,type:"warning",size:"small","disable-transitions":""},{default:d(()=>[R(m(A(u)("Reverse Charge")),1)]),_:1})):B("",!0)])]),_:1},8,["label"])):B("",!0),n(U,{label:A(u)("Tax Country"),width:120},{default:d(q=>[o("span",null,m(q.row.country),1)]),_:1},8,["label"]),n(U,{label:A(u)("Tax Region"),width:120},{default:d(q=>[o("span",null,m(q.row.state),1)]),_:1},8,["label"]),A(l).isColumnVisible("postcode")?(r(),E(U,{key:2,label:A(u)("Zip Code"),width:120},{default:d(q=>[o("span",null,m(q.row.postcode),1)]),_:1},8,["label"])):B("",!0),n(U,{label:A(u)("Tax Name"),width:120},{default:d(q=>[o("span",null,m(q.row.name),1)]),_:1},8,["label"]),A(l).isColumnVisible("rate")?(r(),E(U,{key:3,label:A(u)("Tax Rate"),width:120},{default:d(q=>[o("span",null,m(q.row.rate)+"%",1)]),_:1},8,["label"])):B("",!0),n(U,{label:A(u)("Sale Taxes"),width:120},{default:d(q=>[o("span",null,m(A(pt).formatForOrder(q.row.total_tax_cents,q.row.currency)),1)]),_:1},8,["label"]),A(l).isColumnVisible("filed_at")?(r(),E(U,{key:4,label:A(u)("Filed"),width:120},{default:d(q=>[o("span",null,m(q.row.filed_at),1)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])]))]),_:1},8,["table"]),n(P,{modelValue:s.value,"onUpdate:modelValue":Q[1]||(Q[1]=q=>s.value=q),title:A(u)("Tax Filing"),onOpen:F,class:"fct-tax-filling-modal"},{footer:d(()=>[o("div",Sfe,[n(D,{onClick:Q[0]||(Q[0]=()=>{s.value=!1})},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(D,{type:"primary",onClick:y},{default:d(()=>[n(J,{name:"Download",style:{width:"16px",height:"16px"}}),R(" "+m(A(u)("Download & Continue")),1)]),_:1})])]),default:d(()=>[o("div",_fe,[o("div",vfe,[o("div",gfe,[o("span",yfe,m(A(u)("Taxable Amount")),1),o("span",bfe,m(V.value.totalTax),1)]),o("div",wfe,[o("span",Cfe,m(A(u)("Total Orders")),1),o("span",kfe,m(A(u)(V.value.totalOrders)),1)])]),o("div",Bfe,[n(L,{ref_key:"selectedTaxesTableRef",ref:S,data:p.value,onSelectionChange:w},{empty:d(()=>[n(wt,{icon:"Empty/ListView",text:A(u)("We could't find any taxes matching your filter.")},null,8,["text"])]),default:d(()=>[n(U,{type:"selection",width:45}),n(U,{label:A(u)("ID"),width:100},{default:d(q=>[o("span",null,m(q.row.id),1)]),_:1},8,["label"]),n(U,{label:A(u)("Order ID"),"min-width":100},{default:d(q=>[o("span",xfe,[o("span",null,m(q.row.order_id),1),q.row.reverse_charge?(r(),E(O,{key:0,type:"warning",size:"small","disable-transitions":""},{default:d(()=>[R(m(A(u)("Reverse Charge")),1)]),_:1})):B("",!0)])]),_:1},8,["label"]),n(U,{width:120,label:A(u)("Tax Country")},{default:d(q=>[o("span",null,m(q.row.country),1)]),_:1},8,["label"]),n(U,{width:120,label:A(u)("Tax Region")},{default:d(q=>[o("span",null,m(q.row.state),1)]),_:1},8,["label"]),n(U,{label:A(u)("Zip Code"),width:120},{default:d(q=>[o("span",null,m(q.row.postcode),1)]),_:1},8,["label"]),n(U,{width:120,label:A(u)("Tax Name")},{default:d(q=>[o("span",null,m(q.row.name),1)]),_:1},8,["label"]),n(U,{label:A(u)("Tax Rate"),width:120},{default:d(q=>[o("span",null,m(q.row.rate)+"%",1)]),_:1},8,["label"]),n(U,{width:150,label:A(u)("Sale Taxes")},{default:d(q=>[o("span",null,m(A(pt).formatForOrder(q.row.total_tax_cents,q.row.currency)),1)]),_:1},8,["label"])]),_:1},8,["data"])])])]),_:1},8,["modelValue","title"]),n(P,{modelValue:i.value,"onUpdate:modelValue":Q[2]||(Q[2]=q=>i.value=q),class:"fct-tax-filling-success-modal","close-on-click-modal":!1},{footer:d(()=>[o("div",Efe,[n(D,{onClick:v},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(D,{type:"primary",onClick:b},{default:d(()=>[R(m(A(u)("Mark as Filed")),1)]),_:1})])]),default:d(()=>[o("div",Ffe,[o("div",$fe,[n(J,{name:"CheckCircleFill"})]),o("div",null,[o("h4",null,m(A(u)("Don't Forget to Save Your Tax File")),1),o("p",null,m(A(u)("You're about to mark this tax report as filed.")),1),o("p",null,[R(m(A(u)("Make sure you've downloaded and saved the CSV file for your records before proceeding."))+" ",1),o("a",{onClick:Ne(y,["prevent"]),class:"cursor-pointer"},m(A(u)("Download Again")),1)])])])]),_:1},8,["modelValue"])])}}},Ife={class:"fct-card fct-card-border fct-vat-card"},Qfe={class:"fct-card-body"},Dfe={class:"fct-vat-card-header"},Vfe={class:"fct-vat-card-title"},Tfe={class:"fct-card fct-card-border fct-vat-card mt-5"},Mfe={class:"fct-card-body"},Lfe={class:"fct-vat-card-header"},Rfe={class:"fct-vat-card-title"},Ofe={class:"fct-tax-rates-country-view"},Hfe={class:"border border-gray-200 rounded-md overflow-hidden dark:border-dark-300"},Pfe={class:"grid grid-cols-[110px_1fr_1fr_1fr_100px_80px] gap-4 py-3 border-b border-gray-200 dark:border-dark-300"},Nfe={__name:"EUVatSettingsLoader",setup(e){const t=[1,2,3];return(a,l)=>(r(),h("div",null,[o("div",Ife,[o("div",Qfe,[o("div",Dfe,[o("div",Vfe,[o("h3",null,m(A(u)("Collect VAT cross-border")),1)])]),l[0]||(l[0]=o("div",{class:"fct-vat-card-body"},[o("div",{class:"fct-sk w-[200px] h-3 rounded-xs"}),o("div",{class:"fct-sk w-full h-3 rounded-xs mt-3"})],-1))])]),o("div",Tfe,[o("div",Mfe,[o("div",Lfe,[o("div",Rfe,[o("h3",null,m(A(u)("Tax overrides")),1)])]),o("div",Ofe,[o("div",Hfe,[o("div",Pfe,[(r(),h(H,null,ae(6,s=>o("div",{key:"header-"+s,class:"fct-sk h-3 rounded-xs"})),64))]),(r(),h(H,null,ae(t,s=>o("div",{key:"override-row-"+s,class:"grid grid-cols-[110px_1fr_1fr_1fr_100px_80px] gap-4 py-4 border-b border-gray-100 last:border-b-0 dark:border-dark-400"},l[1]||(l[1]=[Un('',6)]))),64))])])])])]))}},Kfe={class:"fct-modal-body"},Gfe={class:"fct-radio-option-fields"},jfe={class:"form-note"},zfe={class:"fct-radio-option-fields"},qfe={class:"fct-radio-option-fields-desc"},Yfe={class:"form-note"},Wfe={key:0,class:"fct-info-box mt-3"},Jfe={class:"text-xs text-system-mid"},Xfe={class:"fct-radio-option-fields"},Zfe={class:"fct-radio-option-fields-desc"},eme={__name:"EUVatCrossBorderModal",props:{modelValue:{type:Boolean,default:!1},countries:{type:Array,default:()=>[]},currentForm:{type:Object,default:()=>({})},initialRegistrations:{type:Array,default:()=>[]}},emits:["update:modelValue","saved"],setup(e,{emit:t}){const a=e,l=t,s=M({method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}),i=M(!1);be(()=>a.modelValue,_=>{if(_){const g=a.initialRegistrations.length?a.initialRegistrations[0]:null,y=g?g.country:"",v=g&&g.vat||"",b=a.currentForm||{};s.value={method:b.method||"oss",oss_country:b.oss_country||y,oss_vat:b.oss_vat||v,home_country:b.home_country||y,home_vat:b.home_vat||v}}else s.value={method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}});function c(_){const g=a.countries.find(y=>y.value===_);return g?parseFloat(g.default_rate||0):0}function p(){return a.initialRegistrations.some(_=>_.country===s.value.home_country)}function f(){if(!s.value.method){z.error(u("Select a cross-border registration type"));return}if(s.value.method==="oss"){if(!s.value.oss_country){z.error(u("Select your country of OSS registration"));return}}else if(s.value.method==="home"&&!s.value.home_country){z.error(u("Select your country of registration"));return}i.value=!0,(s.value.method==="home"&&!p()?ue.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:s.value.home_country,vat:s.value.home_vat,rate:c(s.value.home_country)}):Promise.resolve()).then(()=>ue.post("tax/configuration/settings/eu-vat",{action:"euCrossBorderSettings",eu_vat_settings:s.value})).then(g=>{z.success(g.message),l("saved",{method:s.value.method,oss_country:s.value.oss_country,oss_vat:s.value.oss_vat,home_country:s.value.home_country,home_country_vat:s.value.home_vat}),l("update:modelValue",!1)}).catch(g=>{var y;z.error((y=g==null?void 0:g.data)==null?void 0:y.message)}).finally(()=>{i.value=!1})}return(_,g)=>{const y=C("el-radio"),v=C("el-option"),b=C("el-select"),k=C("el-form-item"),w=C("el-input"),S=C("el-radio-group"),$=C("el-form"),V=C("el-button"),F=C("el-dialog");return r(),E(F,{"model-value":e.modelValue,title:A(u)("Collect across the EU"),width:"760px","close-on-click-modal":!1,class:"fluent-cart-admin-pages","append-to-body":!0,"onUpdate:modelValue":g[9]||(g[9]=x=>l("update:modelValue",x))},{footer:d(()=>[n(V,{onClick:g[8]||(g[8]=x=>l("update:modelValue",!1))},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(V,{type:"primary",onClick:f,loading:i.value},{default:d(()=>[R(m(A(u)("Collect VAT")),1)]),_:1},8,["loading"])]),default:d(()=>[o("div",Kfe,[n($,{"label-position":"top"},{default:d(()=>[n(S,{modelValue:s.value.method,"onUpdate:modelValue":g[7]||(g[7]=x=>s.value.method=x),class:"fct-cross-border-radios"},{default:d(()=>[o("div",{class:de(["fct-radio-option",{"is-active":s.value.method==="oss"}]),onClick:g[2]||(g[2]=x=>s.value.method="oss")},[n(y,{value:"oss"},{default:d(()=>[R(m(A(u)("Collect using a One Stop Shop (OSS) registration")),1)]),_:1}),n(va,{accordion:"",visible:s.value.method==="oss"},{default:d(()=>[o("div",Gfe,[n(k,{label:A(u)("Country of OSS registration")},{default:d(()=>[n(b,{modelValue:s.value.oss_country,"onUpdate:modelValue":g[0]||(g[0]=x=>s.value.oss_country=x),placeholder:A(u)("Select country"),filterable:"",class:"w-full"},{default:d(()=>[(r(!0),h(H,null,ae(e.countries,x=>(r(),E(v,{key:x.value,label:x.label,value:x.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(k,{label:A(u)("VAT number")},{default:d(()=>[n(w,{modelValue:s.value.oss_vat,"onUpdate:modelValue":g[1]||(g[1]=x=>s.value.oss_vat=x),placeholder:A(u)("e.g. DE999999999")},null,8,["modelValue","placeholder"]),o("div",jfe,[o("p",null,m(A(u)("Shown on VAT invoice")),1)])]),_:1},8,["label"])])]),_:1},8,["visible"])],2),o("div",{class:de(["fct-radio-option",{"is-active":s.value.method==="home"}]),onClick:g[5]||(g[5]=x=>s.value.method="home")},[n(y,{value:"home"},{default:d(()=>[R(m(A(u)("Collect using your home country registration")),1)]),_:1}),n(va,{accordion:"",visible:s.value.method==="home"},{default:d(()=>[o("div",zfe,[o("p",qfe,m(A(u)("Applies to micro-businesses located in one EU country and making less than €10,000 in sales to other EU countries each year")),1),n(k,{label:A(u)("Country of registration")},{default:d(()=>[n(b,{modelValue:s.value.home_country,"onUpdate:modelValue":g[3]||(g[3]=x=>s.value.home_country=x),placeholder:A(u)("Select country"),filterable:"",class:"w-full"},{default:d(()=>[(r(!0),h(H,null,ae(e.countries,x=>(r(),E(v,{key:x.value,label:x.label,value:x.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(k,{label:A(u)("VAT number")},{default:d(()=>[n(w,{modelValue:s.value.home_vat,"onUpdate:modelValue":g[4]||(g[4]=x=>s.value.home_vat=x),placeholder:A(u)("e.g. DE999999999")},null,8,["modelValue","placeholder"]),o("div",Yfe,[o("p",null,m(A(u)("Shown on VAT invoice")),1)])]),_:1},8,["label"]),e.initialRegistrations.length?B("",!0):(r(),h("div",Wfe,[n(J,{name:"InformationFill",class:"w-4 h-4 text-blue-500 flex-shrink-0"}),o("span",Jfe,m(A(u)("You haven't added a home country registration. The information you add here will be used to create one for you.")),1)]))])]),_:1},8,["visible"])],2),o("div",{class:de(["fct-radio-option",{"is-active":s.value.method==="specific"}]),onClick:g[6]||(g[6]=x=>s.value.method="specific")},[n(y,{value:"specific"},{default:d(()=>[R(m(A(u)("Collect using specific country registrations")),1)]),_:1}),n(va,{accordion:"",visible:s.value.method==="specific"},{default:d(()=>[o("div",Xfe,[o("p",Zfe,m(A(u)("Register in each EU country where you are required to collect VAT. Manage your registrations in the country list below.")),1)])]),_:1},8,["visible"])],2)]),_:1},8,["modelValue"])]),_:1})])]),_:1},8,["model-value","title"])}}},tme={key:0,class:"fct-country-registrations-list mt-4"},ame={class:"fct-home-country-header"},lme=["src","alt"],sme={class:"fct-vat-country-name"},nme={key:0,class:"fct-collecting-badge"},ome={class:"fct-home-country-body"},ime={class:"fct-vat-home-field"},rme={class:"fct-vat-home-field__label"},dme={class:"fct-reg-rates-section"},ume={class:"fct-reg-rates-table fct-reg-rates-table--home mt-5 px-5 pt-5"},cme={class:"fct-reg-rates-row fct-reg-rates-header"},Ame={class:"fct-reg-rates-cell-label"},pme={class:"fct-reg-rates-cell-label"},fme={key:1,class:"fct-reg-class-name"},mme={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},hme={class:"fct-reg-rates-cell-input"},_me={class:"fct-reg-rates-cell-action"},vme=["title","onClick"],gme={key:0,class:"fct-reg-add-class px-5"},yme={type:"button",class:"fct-reg-add-class-btn"},bme={class:"fct-vat-home-actions"},wme={__name:"EUVatHomeCountryRegistration",props:{countries:{type:Array,default:()=>[]},homeCountry:{type:String,default:""},homeVat:{type:String,default:""},taxClasses:{type:Array,default:()=>[]},registrations:{type:Array,default:()=>[]}},emits:["save-home","class-changed"],setup(e,{emit:t}){const a=e,l=t,s=M({country:"",vat:"",rates:{}}),i=M([]),c=N(()=>a.homeCountry&&a.countries.find(x=>x.value===a.homeCountry)||null),p=N(()=>a.homeCountry&&a.registrations.find(x=>x.country===a.homeCountry)||null),f=N(()=>{const x=p.value;return!x||!x.vat?!1:x.rates&&typeof x.rates=="object"&&Object.keys(x.rates).length?Object.values(x.rates).some(function(Q){return Q&&parseFloat(Q.rate)>0}):parseFloat(x.rate)>0}),_=N(()=>[...a.taxClasses,...i.value]),g=N(()=>_.value.length?_.value:[{slug:"standard",title:u("Standard")}]),y=N(()=>{if(_.value.length>=6)return[];const x=_.value.map(D=>D.slug).filter(Boolean),Q=[];return x.includes("reduced")||Q.push({command:"reduced",label:u("Reduced")}),x.includes("zero")||Q.push({command:"zero",label:u("Zero")}),Q.push({command:"custom",label:u("Custom Class...")}),Q});be([()=>a.homeCountry,()=>a.homeVat,()=>a.taxClasses,()=>a.registrations],()=>{const x=p.value,Q={};a.taxClasses.forEach(D=>{var O;const T=(O=x==null?void 0:x.rates)==null?void 0:O[D.slug],U=D.slug==="standard"?(x==null?void 0:x.rate)??"":"",I=D.slug==="standard"?(x==null?void 0:x.tax_label)??"":"";T&&typeof T=="object"?Q[D.slug]={rate:T.rate??"",label:T.label??""}:Q[D.slug]={rate:T??U,label:I}}),i.value.forEach(D=>{const T=v(D);Q[T]=s.value.rates[T]||{rate:"",label:""}}),Q.standard||(Q.standard={rate:"",label:""}),s.value={country:a.homeCountry||"",vat:(x==null?void 0:x.vat)||a.homeVat||"",rates:Q}},{immediate:!0});function v(x){return x.tempKey||x.slug}function b(x){if(x==="custom"){w();return}const Q=x==="reduced"?u("Reduced"):u("Zero");i.value.push({slug:x,title:Q,tempKey:x}),s.value.rates[x]={rate:"",label:""}}let k=0;function w(){const x="_new_"+k++;i.value.push({slug:null,title:"",tempKey:x,isNew:!0}),s.value.rates[x]={rate:"",label:""}}function S(x){return x.slug?x.title||x.slug:x.title&&x.title.trim()?x.title.trim():u("Custom")}function $(x){if(x.hasError=!1,x.created)return Promise.resolve(null);if(!x.slug&&!(x.title&&x.title.trim()))return x.hasError=!0,Promise.reject(new Error(u("Please enter a name for the custom tax class")));const Q=x.slug?{slug:x.slug}:{title:x.title.trim()};return ue.post("tax/classes",Q).then(D=>{const T=(D==null?void 0:D.class)||{},U=T.slug||x.slug;if(!U)throw new Error(u("Tax class creation returned an invalid response"));return!x.slug&&s.value.rates[x.tempKey]!==void 0&&(s.value.rates[U]=s.value.rates[x.tempKey],delete s.value.rates[x.tempKey],x.tempKey=null),x.slug=U,x.title=T.title||x.title,x.created=!0,T}).catch(D=>{var U;x.hasError=!0;const T=((U=D==null?void 0:D.data)==null?void 0:U.message)||u("Failed to create tax class");throw new Error(u("%1$s: %2$s",T,S(x)))})}function V(x){const Q=v(x);if(i.value.some(T=>v(T)===Q)){i.value=i.value.filter(T=>v(T)!==Q),delete s.value.rates[Q];return}rl(u('This will permanently delete the "%1$s" tax class and all its rates across every country (not just EU). Products using this class will fall back to Standard. Continue?',x.title),u("Delete Tax Class"),{confirmButtonText:u("Delete"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{ue.delete("tax/classes/"+x.id).then(()=>{l("class-changed")}).catch(T=>{var U;z.error(((U=T==null?void 0:T.data)==null?void 0:U.message)||u("Failed to delete tax class"))})}).catch(()=>{})}function F(){const x=i.value.map($);Promise.all(x).then(()=>{i.value=[],l("save-home",{country:s.value.country,vat:s.value.vat,rates:s.value.rates})}).catch(Q=>{z.error((Q==null?void 0:Q.message)||u("Failed to create tax class"))})}return(x,Q)=>{const D=C("el-input"),T=C("el-dropdown-item"),U=C("el-dropdown-menu"),I=C("el-dropdown"),O=C("el-button");return c.value?(r(),h("div",tme,[o("div",ame,[o("img",{src:`https://flagcdn.com/w40/${e.homeCountry.toLowerCase()}.png`,alt:c.value.label,class:"fct-flag-icon"},null,8,lme),o("span",sme,m(c.value.label),1),f.value?(r(),h("span",nme,[Q[1]||(Q[1]=o("span",{class:"fct-green-dot"},null,-1)),R(" "+m(A(u)("Collecting")),1)])):B("",!0)]),o("div",ome,[o("div",ime,[o("label",rme,m(A(u)("VAT number")),1),n(D,{modelValue:s.value.vat,"onUpdate:modelValue":Q[0]||(Q[0]=L=>s.value.vat=L),class:"fct-vat-number-input"},null,8,["modelValue"])]),o("div",dme,[o("div",ume,[o("div",cme,[o("div",Ame,m(A(u)("Tax Classes")),1),Q[2]||(Q[2]=o("div",{class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},null,-1)),Q[3]||(Q[3]=o("div",{class:"fct-reg-rates-cell-input"},null,-1)),Q[4]||(Q[4]=o("div",{class:"fct-reg-rates-cell-action"},null,-1))]),(r(!0),h(H,null,ae(g.value,L=>(r(),h("div",{key:v(L),class:"fct-reg-rates-row"},[o("div",pme,[L.isNew?(r(),E(D,{key:0,modelValue:L.title,"onUpdate:modelValue":P=>L.title=P,size:"small",placeholder:A(u)("Class name"),class:de(["fct-reg-class-name-input",{"fct-reg-class-name-input--error":L.hasError}]),onInput:P=>L.hasError=!1},null,8,["modelValue","onUpdate:modelValue","placeholder","class","onInput"])):(r(),h("span",fme,m(L.title),1))]),o("div",mme,[n(D,{modelValue:s.value.rates[v(L)].rate,"onUpdate:modelValue":P=>s.value.rates[v(L)].rate=P,type:"number",step:"0.01",min:"0",size:"small"},{suffix:d(()=>Q[5]||(Q[5]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])]),o("div",hme,[n(D,{modelValue:s.value.rates[v(L)].label,"onUpdate:modelValue":P=>s.value.rates[v(L)].label=P,size:"small",placeholder:A(u)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])]),o("div",_me,[L.slug!=="standard"?(r(),h("button",{key:0,type:"button",class:"fct-reg-rates-delete-btn",title:A(u)("Delete class"),onClick:P=>V(L)},[n(J,{name:"Delete"})],8,vme)):B("",!0)])]))),128))]),y.value.length?(r(),h("div",gme,[y.value.length===1&&y.value[0].command==="custom"?(r(),h("button",{key:0,type:"button",class:"fct-reg-add-class-btn",onClick:w},[n(J,{name:"Plus",class:"w-3 h-3"}),R(" "+m(A(u)("Add class")),1)])):(r(),E(I,{key:1,trigger:"click",onCommand:b,"popper-class":"fct-dropdown"},{dropdown:d(()=>[n(U,null,{default:d(()=>[(r(!0),h(H,null,ae(y.value,L=>(r(),E(T,{key:L.command,command:L.command},{default:d(()=>[R(m(L.label),1)]),_:2},1032,["command"]))),128))]),_:1})]),default:d(()=>[o("button",yme,[n(J,{name:"Plus",class:"w-3 h-3"}),R(" "+m(A(u)("Add class")),1)])]),_:1}))])):B("",!0)]),o("div",bme,[n(O,{type:"primary",size:"small",onClick:F},{default:d(()=>[R(m(A(u)("Save VAT")),1)]),_:1})])])])):B("",!0)}}},Cme={class:"fct-modal-body fct-country-reg-modal"},kme={class:"fct-country-reg-text"},Bme={class:"form-note"},xme={class:"fct-reg-rates-table"},Sme={class:"fct-reg-rates-row fct-reg-rates-header"},Fme={class:"fct-reg-rates-cell-label"},$me={class:"fct-reg-rates-cell-label"},Eme={key:1,class:"fct-reg-class-name"},Ume={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},Ime={class:"fct-reg-rates-cell-input"},Qme={key:1,class:"fct-reg-rates-row"},Dme={class:"fct-reg-rates-cell-label"},Vme={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},Tme={class:"fct-reg-rates-cell-input"},Mme={key:0,class:"fct-reg-add-class"},Lme={type:"button",class:"fct-reg-add-class-btn"},Rme={__name:"EUVatRegistrationModal",props:{modelValue:{type:Boolean,default:!1},countries:{type:Array,default:()=>[]},taxClasses:{type:Array,default:()=>[]},initialForm:{type:Object,default:()=>({country:"",vat:"",rates:{},isEdit:!1})},registeredCountries:{type:Array,default:()=>[]}},emits:["update:modelValue","saved"],setup(e,{emit:t}){const a=e,l=t,s=M({country:"",vat:"",rates:{},isEdit:!1}),i=M([]),c=M(!1),p=N(()=>[...a.taxClasses,...i.value]),f=N(()=>{if(p.value.length>=6)return[];const V=p.value.map(x=>x.slug).filter(Boolean),F=[];return V.includes("reduced")||F.push({command:"reduced",label:u("Reduced")}),V.includes("zero")||F.push({command:"zero",label:u("Zero")}),F.push({command:"custom",label:u("Custom Class...")}),F}),_=N(()=>s.value.isEdit?a.countries:a.countries.filter(V=>!a.registeredCountries.includes(V.value)));be(()=>a.modelValue,V=>{if(V){const F=a.initialForm||{},x=F.rates?JSON.parse(JSON.stringify(F.rates)):{};a.taxClasses.forEach(Q=>{x[Q.slug]||(x[Q.slug]={rate:"",label:""})}),x.standard||(x.standard={rate:"",label:""}),s.value={country:F.country||"",vat:F.vat||"",rates:x,isEdit:F.isEdit||!1},i.value=[]}});function g(V){return V.tempKey||V.slug}function y(V){const F=a.countries.find(x=>x.value===V);if(F&&F.default_rate){const x=s.value.rates.standard||{};s.value.rates=Object.assign({},s.value.rates,{standard:Object.assign({},x,{rate:F.default_rate})})}}function v(V){if(V==="custom"){k();return}const F=V==="reduced"?u("Reduced"):u("Zero");i.value.push({slug:V,title:F,tempKey:V}),s.value.rates[V]={rate:"",label:""}}let b=0;function k(){const V="_new_"+b++;i.value.push({slug:null,title:"",tempKey:V,isNew:!0}),s.value.rates[V]={rate:"",label:""}}function w(V){return V.slug?V.title||V.slug:V.title&&V.title.trim()?V.title.trim():u("Custom")}function S(V){if(V.hasError=!1,V.created)return Promise.resolve(null);if(!V.slug&&!(V.title&&V.title.trim()))return V.hasError=!0,Promise.reject(new Error(u("Please enter a name for the custom tax class")));const F=V.slug?{slug:V.slug}:{title:V.title.trim()};return ue.post("tax/classes",F).then(x=>{const Q=(x==null?void 0:x.class)||{},D=Q.slug||V.slug;if(!D)throw new Error(u("Tax class creation returned an invalid response"));return!V.slug&&s.value.rates[V.tempKey]!==void 0&&(s.value.rates[D]=s.value.rates[V.tempKey],delete s.value.rates[V.tempKey],V.tempKey=null),V.slug=D,V.title=Q.title||V.title,V.created=!0,Q}).catch(x=>{var D;V.hasError=!0;const Q=((D=x==null?void 0:x.data)==null?void 0:D.message)||u("Failed to create tax class");throw new Error(u("%1$s: %2$s",Q,w(V)))})}function $(){if(!s.value.country){z.error(u("Select a registration country"));return}const V=s.value.rates;if(!Object.values(V).some(Q=>parseFloat(Q.rate)>0)){z.error(u("At least one tax rate must be greater than 0%"));return}c.value=!0;const x=i.value.map(S);Promise.all(x).then(()=>ue.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:s.value.country,vat:s.value.vat,rates:s.value.rates})).then(Q=>{z.success(Q.message),i.value=[],l("saved"),l("update:modelValue",!1)}).catch(Q=>{var D;z.error((Q==null?void 0:Q.message)||((D=Q==null?void 0:Q.data)==null?void 0:D.message)||u("Failed to save VAT registration"))}).finally(()=>{c.value=!1})}return(V,F)=>{const x=C("el-option"),Q=C("el-select"),D=C("el-form-item"),T=C("el-input"),U=C("el-dropdown-item"),I=C("el-dropdown-menu"),O=C("el-dropdown"),L=C("el-form"),P=C("el-button"),q=C("el-dialog");return r(),E(q,{"model-value":e.modelValue,title:s.value.isEdit?A(u)("Edit VAT registration"):A(u)("Collect VAT"),"close-on-click-modal":!1,class:"fluent-cart-admin-pages","append-to-body":!0,"onUpdate:modelValue":F[5]||(F[5]=X=>l("update:modelValue",X))},{footer:d(()=>[n(P,{onClick:F[4]||(F[4]=X=>l("update:modelValue",!1))},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(P,{type:"primary",onClick:$,loading:c.value},{default:d(()=>[R(m(A(u)("Collect VAT")),1)]),_:1},8,["loading"])]),default:d(()=>[o("div",Cme,[o("p",kme,m(A(u)("Make sure you're registered for VAT when collecting in the EU.")),1),n(L,{"label-position":"top"},{default:d(()=>[n(D,{label:A(u)("Registration country")},{default:d(()=>[n(Q,{modelValue:s.value.country,"onUpdate:modelValue":F[0]||(F[0]=X=>s.value.country=X),placeholder:A(u)("Select country"),filterable:"",class:"w-full",disabled:s.value.isEdit,onChange:y},{default:d(()=>[(r(!0),h(H,null,ae(_.value,X=>(r(),E(x,{key:X.value,label:X.label,value:X.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","disabled"])]),_:1},8,["label"]),n(D,{label:A(u)("VAT number")},{default:d(()=>[n(T,{modelValue:s.value.vat,"onUpdate:modelValue":F[1]||(F[1]=X=>s.value.vat=X),placeholder:s.value.country?s.value.country+"999999999":"DE999999999"},null,8,["modelValue","placeholder"]),o("div",Bme,[o("p",null,m(A(u)("Shown on VAT invoice")),1)])]),_:1},8,["label"]),o("div",xme,[o("div",Sme,[o("div",Fme,m(A(u)("Tax Classes")),1),F[6]||(F[6]=o("div",{class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},null,-1)),F[7]||(F[7]=o("div",{class:"fct-reg-rates-cell-input"},null,-1))]),p.value.length?(r(!0),h(H,{key:0},ae(p.value,X=>(r(),h("div",{key:X.tempKey||X.slug,class:"fct-reg-rates-row"},[o("div",$me,[X.isNew?(r(),E(T,{key:0,modelValue:X.title,"onUpdate:modelValue":G=>X.title=G,size:"small",placeholder:A(u)("Class name"),class:de(["fct-reg-class-name-input",{"fct-reg-class-name-input--error":X.hasError}]),onInput:G=>X.hasError=!1},null,8,["modelValue","onUpdate:modelValue","placeholder","class","onInput"])):(r(),h("span",Eme,m(X.title),1))]),o("div",Ume,[n(T,{modelValue:s.value.rates[g(X)].rate,"onUpdate:modelValue":G=>s.value.rates[g(X)].rate=G,modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",size:"small",placeholder:X.slug==="standard"?"19":"0"},{suffix:d(()=>F[8]||(F[8]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue","placeholder"])]),o("div",Ime,[n(T,{modelValue:s.value.rates[g(X)].label,"onUpdate:modelValue":G=>s.value.rates[g(X)].label=G,size:"small",placeholder:A(u)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])])]))),128)):(r(),h("div",Qme,[o("div",Dme,m(A(u)("Standard")),1),o("div",Vme,[n(T,{modelValue:s.value.rates.standard.rate,"onUpdate:modelValue":F[2]||(F[2]=X=>s.value.rates.standard.rate=X),modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",size:"small",placeholder:"19"},{suffix:d(()=>F[9]||(F[9]=[R("%",-1)])),_:1},8,["modelValue"])]),o("div",Tme,[n(T,{modelValue:s.value.rates.standard.label,"onUpdate:modelValue":F[3]||(F[3]=X=>s.value.rates.standard.label=X),size:"small",placeholder:A(u)("e.g. VAT, MwSt")},null,8,["modelValue","placeholder"])])]))]),f.value.length?(r(),h("div",Mme,[f.value.length===1&&f.value[0].command==="custom"?(r(),h("button",{key:0,type:"button",class:"fct-reg-add-class-btn",onClick:k},[n(J,{name:"Plus"}),R(" "+m(A(u)("Add class")),1)])):(r(),E(O,{key:1,trigger:"click",onCommand:v},{dropdown:d(()=>[n(I,null,{default:d(()=>[(r(!0),h(H,null,ae(f.value,X=>(r(),E(U,{key:X.command,command:X.command},{default:d(()=>[R(m(X.label),1)]),_:2},1032,["command"]))),128))]),_:1})]),default:d(()=>[o("button",Lme,[n(J,{name:"Plus"}),R(" "+m(A(u)("Add class")),1)])]),_:1}))])):B("",!0)]),_:1})])]),_:1},8,["model-value","title"])}}},Ome={class:"fct-oss-rates-section"},Hme=["aria-expanded"],Pme={class:"inline-flex items-center gap-2"},Nme={class:"fct-oss-rates-count"},Kme={class:"fct-oss-rates-table"},Gme={key:1,class:"text-system-mid"},jme={class:"fct-btn-group mt-4 justify-end sm"},zme={__name:"EUVatOssRatesSection",setup(e,{expose:t}){const a=M([]),l=M([]),s=M(null),i=M("standard"),c=M(!1),p=M(!1),f=M(!1),_=M(!1),g=M(6),y=M(!1),v=M(""),b=N(()=>a.value),k=N(()=>{const D=v.value.trim().toLowerCase();return D?b.value.filter(T=>T.label&&T.label.toLowerCase().includes(D)):b.value});function w(){return c.value=!0,ue.get("tax/configuration/settings/eu-vat/oss-rates").then(D=>{a.value=D.rates||[],l.value=D.classes||[];const T=Id({classes:l.value,activeId:s.value});return T&&(s.value=T.id,i.value=T.slug),l.value}).catch(D=>{var T;z.error((T=D==null?void 0:D.data)==null?void 0:T.message)}).finally(()=>{c.value=!1})}function S(D){s.value=D.id,i.value=D.slug}function $(D){y.value=!0,zo({payload:{slug:D},createdSlug:D,currentClasses:l.value,reloadClasses:w}).then(({createdClass:T})=>{T&&S(T)}).catch(T=>{var U;z.error((U=T==null?void 0:T.data)==null?void 0:U.message)}).finally(()=>{y.value=!1})}function V(D){y.value=!0,zo({payload:{title:D},currentClasses:l.value,reloadClasses:w}).then(({createdClass:T})=>{T&&S(T)}).catch(T=>{var U;z.error((U=T==null?void 0:T.data)==null?void 0:U.message)}).finally(()=>{y.value=!1})}function F(D){D.slug!=="standard"&&rl(u('This will permanently delete the "%1$s" tax class and all its rates across every country (not just EU). Products using this class will fall back to Standard. Continue?',D.title),u("Delete Tax Class"),{confirmButtonText:u("Remove"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{c.value=!0,rf({classId:D.id,currentActiveId:s.value===D.id?null:s.value,reloadClasses:w}).then(({nextActiveClass:T})=>{T&&S(T)}).catch(T=>{var U;z.error((U=T==null?void 0:T.data)==null?void 0:U.message),c.value=!1})}).catch(()=>{})}function x(){p.value=!0,ue.post("tax/configuration/settings/eu-vat/oss-rates",{rates:b.value.map(D=>({country:D.country,rate:D.rate,tax_label:D.tax_label||"",class_rates:D.class_rates||{}}))}).then(D=>{z.success(D.message)}).catch(D=>{var T;z.error((T=D==null?void 0:D.data)==null?void 0:T.message)}).finally(()=>{p.value=!1})}function Q(){rl(u("This will overwrite all EU destination country standard rates with preset defaults. Continue?"),u("Reset to default tax rates"),{confirmButtonText:u("Reset"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{f.value=!0,ue.post("tax/configuration/settings/eu-vat/reset-rates").then(()=>w()).then(()=>{z.success(u("EU tax rates have been reset to defaults"))}).catch(D=>{var T;z.error(((T=D==null?void 0:D.data)==null?void 0:T.message)||u("Failed to reset rates"))}).finally(()=>{f.value=!1})}).catch(()=>{})}return Ie(w),t({loadRates:w}),(D,T)=>{const U=C("el-icon"),I=C("el-table-column"),O=C("el-input"),L=C("el-table"),P=C("el-button"),q=Ma("loading");return r(),h("div",Ome,[o("div",{class:"fct-oss-rates-toggle",role:"button",tabindex:"0","aria-expanded":_.value,onClick:T[0]||(T[0]=X=>{_.value=!_.value,_.value||(v.value="")}),onKeydown:[T[1]||(T[1]=xa(Ne(X=>{_.value=!_.value,_.value||(v.value="")},["prevent"]),["enter"])),T[2]||(T[2]=xa(Ne(X=>{_.value=!_.value,_.value||(v.value="")},["prevent"]),["space"]))]},[o("span",Pme,[R(m(A(u)("Destination country rates"))+" ",1),o("span",Nme," ("+m(b.value.length)+") ",1)]),n(U,{class:de(["fct-oss-rates-arrow",{"is-expanded":_.value}])},{default:d(()=>[n(J,{name:"ChevronDown",class:"w-4 h-4"})]),_:1},8,["class"])],40,Hme),n(Wl,{name:"fct-collapse"},{default:d(()=>[qt(o("div",Kme,[n(Xa,{type:"info"},{content:d(()=>[o("span",null,m(A(u)("Rates are pre-filled for convenience and may not reflect current laws — verify with a tax advisor before going live. If you sell products taxed at different rates (e.g. food, books, digital goods), use the"))+" + "+m(A(u)("button to add tax classes.")),1)]),_:1}),n(of,{classes:l.value,"active-id":s.value,"max-classes":g.value,creating:y.value,search:v.value,onSwitch:S,onDelete:F,onAdd:$,onCreateCustom:V,"onUpdate:search":T[3]||(T[3]=X=>v.value=X)},null,8,["classes","active-id","max-classes","creating","search"]),qt((r(),E(L,{data:k.value,class:"w-full fct-tax-rates-table","max-height":"450","empty-text":A(u)("No rates found")},{default:d(()=>[n(I,{label:A(u)("Country"),"min-width":"160"},{default:d(({row:X})=>[R(m(X.label),1)]),_:1},8,["label"]),n(I,{label:A(u)("Tax Label"),"min-width":"150"},{default:d(({row:X})=>[X.class_rates&&X.class_rates[i.value]?(r(),E(O,{key:0,modelValue:X.class_rates[i.value].label,"onUpdate:modelValue":G=>X.class_rates[i.value].label=G,size:"small",placeholder:A(u)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])):B("",!0)]),_:1},8,["label"]),n(I,{label:A(u)("Rate"),"min-width":"120"},{default:d(({row:X})=>[X.class_rates&&X.class_rates[i.value]?(r(),E(O,{key:0,modelValue:X.class_rates[i.value].rate,"onUpdate:modelValue":G=>X.class_rates[i.value].rate=G,modelModifiers:{number:!0},size:"small",type:"number",min:0,max:100,step:"0.5"},{suffix:d(()=>T[4]||(T[4]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])):(r(),h("span",Gme,"—"))]),_:1},8,["label"])]),_:1},8,["data","empty-text"])),[[q,c.value]]),o("div",jme,[i.value==="standard"?(r(),E(P,{key:0,size:"small",loading:f.value,onClick:Q,type:"danger",soft:""},{default:d(()=>[R(m(A(u)("Reset to default")),1)]),_:1},8,["loading"])):B("",!0),n(P,{type:"primary",size:"small",loading:p.value,onClick:x},{default:d(()=>[R(m(A(u)("Save Rates")),1)]),_:1},8,["loading"])])],512),[[Dl,_.value]])]),_:1})])}}},qme={class:"fct-vat-card-header"},Yme={class:"fct-vat-card-title"},Wme={class:"fct-vat-card-body"},Jme={class:"fct-vat-reg-info"},Xme={class:"fct-vat-country-name"},Zme={key:0,size:"small",type:"success",class:"ml-3 fct-collecting-badge"},ehe={key:1,class:"ml-3 text-sm text-system-mid dark:text-gray-400"},the={key:2,class:"fct-country-registrations-list mt-4"},ahe={class:"fct-reg-rows"},lhe={key:0,class:"fct-vat-registration-row"},she={class:"fct-vat-reg-info"},nhe=["src","alt"],ohe={class:"fct-vat-country-name"},ihe={class:"fct-vat-reg-info"},rhe=["src","alt"],dhe={class:"fct-vat-country-name"},uhe={key:0,class:"fct-vat-number"},che={key:1,class:"fct-vat-missing-badge"},Ahe={class:"fct-vat-reg-actions"},phe={key:1,class:"fct-vat-empty-state"},fhe={class:"text-system-mid text-sm"},mhe={key:0,class:"px-5 py-3"},hhe={key:1,class:"fct-vat-cross-border-empty"},_he={class:"fct-vat-cross-border-empty-text"},vhe={class:"fct-vat-cross-border-empty-title"},ghe={class:"fct-vat-cross-border-empty-desc"},yhe={__name:"EUVatCrossBorderCard",props:{countries:{type:Array,default:()=>[]},initialForm:{type:Object,default:()=>({})},initialRegistrations:{type:Array,default:()=>[]},storeCountry:{type:String,default:""},isTaxEnabled:{type:Boolean,default:!0}},emits:["method-changed"],setup(e,{emit:t}){const a=e,l=t,s=M({method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}),i=M(!1),c=M(null),p=M([]),f=M(!1),_=M({country:"",vat:"",rates:{},isEdit:!1}),g=N(()=>a.countries.length||28),y=N(()=>a.initialRegistrations.filter(V).length),v=N(()=>a.storeCountry&&a.countries.find(te=>te.value===a.storeCountry)||null),b=N(()=>a.storeCountry?a.initialRegistrations.some(te=>te.country===a.storeCountry):!1),k=N(()=>{if(s.value.method!=="home"||!s.value.home_country)return!1;const te=a.initialRegistrations.find(ne=>ne.country===s.value.home_country);return!!te&&V(te)}),w=N(()=>s.value.method==="oss"||s.value.method==="home"||s.value.method==="specific");function S(te){if(!te||!Array.isArray(a.countries))return te;const ne=a.countries.find(re=>re.value===te);return ne?ne.label:te}function $(te){return te?te.rates&&typeof te.rates=="object"&&Object.keys(te.rates).length?Object.values(te.rates).some(ne=>ne&&parseFloat(ne.rate)>0):parseFloat(te.rate)>0:!1}function V(te){return!!te&&!!te.vat&&$(te)}function F(te){return $(te)&&!te.vat}function x(){return ue.get("tax/classes").then(te=>{p.value=te.classes||[]}).catch(()=>{z.error(u("Failed to load tax classes"))})}function Q(te){const ne={};return p.value.forEach(re=>{ne[re.slug]={rate:re.slug==="standard"&&te||"",label:""}}),ne}function D(){const te=v.value&&!b.value?a.storeCountry:"",ne=te&&v.value&&v.value.default_rate||"";_.value={country:te,vat:"",rates:Q(ne),isEdit:!1},f.value=!0}function T(te){const ne=te.rates||{},re={};p.value.forEach(K=>{const Y=ne[K.slug];if(Y&&typeof Y=="object")re[K.slug]={rate:Y.rate||"",label:Y.label||""};else{const W=K.slug==="standard"?te.rate||"":Y||"";re[K.slug]={rate:W,label:K.slug==="standard"&&te.tax_label||""}}}),_.value={country:te.country,vat:te.vat||"",rates:re,isEdit:!0},f.value=!0}function U(){x(),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:s.value.home_vat})}function I(te){ue.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:te.country,vat:te.vat,rates:te.rates}).then(ne=>{z.success(ne.message),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:te.vat})}).catch(ne=>{var re;z.error(((re=ne==null?void 0:ne.data)==null?void 0:re.message)||u("Failed to save VAT registration"))})}function O(te){rl(u("Are you sure you want to remove this country registration?"),u("Confirm Remove"),{confirmButtonText:u("Yes, Remove"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{ue.post("tax/configuration/settings/eu-vat",{action:"deleteCountryRegistration",country:te}).then(ne=>{z.success(ne.message),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:s.value.home_vat})}).catch(ne=>{var re;z.error((re=ne==null?void 0:ne.data)==null?void 0:re.message)})}).catch(()=>{})}function L(){return y.value===1?u("Collecting in 1 country"):u("Collecting in %1$s countries",y.value)}const P=N(()=>g.value===1?u("Collecting in 1 region"):u("Collecting in %1$s regions",g.value));function q(te){s.value={method:te.method,oss_country:te.oss_country,oss_vat:te.oss_vat,home_country:te.home_country,home_vat:te.home_country_vat},te.method==="oss"&&ke(()=>{var ne;return(ne=c.value)==null?void 0:ne.loadRates()}),l("method-changed",{method:te.method,home_country:te.home_country,home_vat:te.home_country_vat})}function X(te){te==="edit"?i.value=!0:te==="stop"&&G()}function G(){rl(u("Are you sure you want to stop collecting cross-border VAT? This will clear your OSS/home country registration."),u("Stop Collecting"),{confirmButtonText:u("Yes, Stop"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{ue.post("tax/configuration/settings/eu-vat",{action:"euCrossBorderSettings",eu_vat_settings:{method:"specific"},reset_registration:"yes"}).then(te=>{z.success(te.message),s.value={method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""},l("method-changed",{method:"",home_country:"",home_vat:""})}).catch(te=>{var ne;z.error((ne=te==null?void 0:te.data)==null?void 0:ne.message)})}).catch(()=>{})}return be(()=>a.initialForm,te=>{const ne=te||{};s.value={method:ne.method||"",oss_country:ne.oss_country||"",oss_vat:ne.oss_vat||"",home_country:ne.home_country||"",home_vat:ne.home_vat||""}},{immediate:!0}),be(()=>a.countries,te=>{te&&te.length&&x()},{immediate:!0}),(te,ne)=>{const re=C("el-tooltip"),K=C("el-dropdown-item"),Y=C("el-dropdown-menu"),W=C("el-dropdown"),j=C("el-button");return r(),h(H,null,[n(Be,{class:"fct-vat-card"},{default:d(()=>[n(Ce,null,{default:d(()=>[o("div",qme,[o("div",Yme,[o("h3",null,m(A(u)("Collect VAT cross-border")),1),n(re,{content:A(u)("Choose how to collect VAT for sales to other EU countries."),placement:"top"},{default:d(()=>[n(J,{name:"InformationFill",class:"w-4 h-4 text-system-mid cursor-pointer"})]),_:1},8,["content"])]),w.value?(r(),E(W,{key:0,trigger:"click",onCommand:X,"popper-class":"fct-dropdown",placement:"bottom-end"},{dropdown:d(()=>[n(Y,null,{default:d(()=>[n(K,{command:"edit"},{default:d(()=>[R(m(A(u)("Edit registration")),1)]),_:1}),n(K,{command:"stop"},{default:d(()=>[R(m(A(u)("Stop collecting")),1)]),_:1})]),_:1})]),default:d(()=>[n(Ze,{border:"none",size:"small",tag:"button"},{default:d(()=>[n(J,{name:"More"})]),_:1})]),_:1})):B("",!0)]),o("div",Wme,[w.value?(r(),h(H,{key:0},[o("div",Jme,[ne[4]||(ne[4]=o("span",{class:"fct-eu-flag-icon"},"🇪🇺",-1)),o("span",Xme,m(s.value.method==="oss"?A(u)("EU (OSS)"):s.value.method==="home"?A(u)("EU (micro-business)"):A(u)("EU (specific countries)")),1),e.isTaxEnabled&&(s.value.method!=="specific"||y.value>0)?(r(),h("span",Zme,[ne[3]||(ne[3]=o("span",{class:"fct-green-dot"},null,-1)),s.value.method==="specific"?(r(),h(H,{key:0},[R(m(L()),1)],64)):(r(),h(H,{key:1},[R(m(P.value),1)],64))])):B("",!0),e.isTaxEnabled?B("",!0):(r(),h("span",ehe,m(A(u)("Tax disabled")),1))]),s.value.method==="home"?(r(),E(Xa,{key:0,type:k.value?"info":"warning",icon:"Info",class:"mb-4 mt-4",content:k.value?A(u)("Collecting cross-border EU VAT at your %1$s home country rate. This is for small businesses whose total cross-border EU sales stay below €10,000/year. Once you exceed that threshold you must charge each buyer's local VAT rate instead.",S(s.value.home_country)):A(u)("Your %1$s home country VAT rate will apply to all EU cross-border sales. This is available for small businesses below €10,000/year in cross-border EU sales. Make sure %1$s is registered below with the correct rate.",S(s.value.home_country))},null,8,["type","content"])):B("",!0),s.value.method==="home"?(r(),E(wme,{key:1,countries:e.countries,"home-country":s.value.home_country,"home-vat":s.value.home_vat,"tax-classes":p.value,registrations:e.initialRegistrations,onSaveHome:I,onClassChanged:x},null,8,["countries","home-country","home-vat","tax-classes","registrations"])):B("",!0),s.value.method==="specific"?(r(),h("div",the,[o("div",ahe,[v.value&&!b.value?(r(),h("div",lhe,[o("div",she,[o("img",{src:`https://flagcdn.com/w40/${e.storeCountry.toLowerCase()}.png`,alt:v.value.label,class:"fct-flag-icon"},null,8,nhe),o("span",ohe,m(v.value.label),1)]),n(j,{size:"small",onClick:D},{default:d(()=>[R(m(A(u)("Configure")),1)]),_:1})])):B("",!0),(r(!0),h(H,null,ae(e.initialRegistrations,ie=>(r(),h("div",{key:ie.country,class:"fct-vat-registration-row"},[o("div",ihe,[o("img",{src:`https://flagcdn.com/w40/${ie.country.toLowerCase()}.png`,alt:S(ie.country),class:"fct-flag-icon"},null,8,rhe),o("span",dhe,m(S(ie.country)),1),ie.vat?(r(),h("span",uhe,m(ie.vat),1)):F(ie)?(r(),h("span",che,m(A(u)("VAT ID missing")),1)):B("",!0)]),o("div",Ahe,[$(ie)?(r(),E(Ze,{key:0,border:"none",size:"small",tag:"button",title:A(u)("Edit"),onClick:he=>T(ie)},{default:d(()=>[n(J,{name:"Edit"})]),_:2},1032,["title","onClick"])):(r(),E(j,{key:1,size:"small",onClick:he=>T(ie)},{default:d(()=>[R(m(A(u)("Configure")),1)]),_:2},1032,["onClick"])),n(Ze,{border:"none",size:"small",tag:"button",title:A(u)("Delete"),onClick:he=>O(ie.country)},{default:d(()=>[n(J,{name:"Delete"})]),_:2},1032,["title","onClick"])])]))),128)),!e.initialRegistrations.length&&!v.value?(r(),h("div",phe,[o("p",fhe,m(A(u)("No country VAT registrations configured.")),1),n(j,{type:"primary",size:"small",onClick:D},{default:d(()=>[R(m(A(u)("Configure")),1)]),_:1})])):B("",!0)]),e.initialRegistrations.length||v.value?(r(),h("div",mhe,[n(j,{type:"primary",link:"",onClick:D},{default:d(()=>[R(" + "+m(A(u)("Collect in another country")),1)]),_:1})])):B("",!0)])):B("",!0),s.value.method==="oss"?(r(),E(zme,{key:3,ref_key:"ossRatesRef",ref:c},null,512)):B("",!0)],64)):(r(),h("div",hhe,[ne[5]||(ne[5]=o("span",{class:"fct-eu-flag-icon"},"🇪🇺",-1)),o("div",_he,[o("p",vhe,m(A(u)("Not collecting cross-border VAT")),1),o("p",ghe,m(A(u)("Set up OSS, micro-business, or specific-country registrations to collect VAT across the EU.")),1)]),n(j,{size:"small",onClick:ne[0]||(ne[0]=ie=>i.value=!0),type:"primary"},{default:d(()=>[R(m(A(u)("Configure")),1)]),_:1})]))])]),_:1})]),_:1}),n(eme,{modelValue:i.value,"onUpdate:modelValue":ne[1]||(ne[1]=ie=>i.value=ie),countries:e.countries,"current-form":s.value,"initial-registrations":e.initialRegistrations,onSaved:q},null,8,["modelValue","countries","current-form","initial-registrations"]),n(Rme,{modelValue:f.value,"onUpdate:modelValue":ne[2]||(ne[2]=ie=>f.value=ie),countries:e.countries,"tax-classes":p.value,"initial-form":_.value,"registered-countries":e.initialRegistrations.map(ie=>ie.country),onSaved:U},null,8,["modelValue","countries","tax-classes","initial-form","registered-countries"])],64)}}},bhe={__name:"EUVatTaxOverrideModal",props:{modelValue:{type:Boolean,default:!1},countries:{type:Array,default:()=>[]},taxClasses:{type:Array,default:()=>[]},editRow:{type:Object,default:null}},emits:["update:modelValue","saved"],setup(e,{emit:t}){const a=e,l=t,s=M({type:"products",original_type:"",original_id:"",category_id:"",category_name:"",country:"",city:"",postcode:"",tax_label:"VAT",tax_rate:0,class_id:0,id:""}),i=M([]),c=M(!1),p=M(!1);function f(){return a.taxClasses&&a.taxClasses.length>0&&Number(a.taxClasses[0].id)||0}function _(){s.value={type:"products",original_type:"",original_id:"",category_id:"",category_name:"",country:"",city:"",postcode:"",tax_label:"VAT",tax_rate:0,class_id:0,id:""}}function g(w){if(w.type==="shipping")s.value={type:"shipping",original_type:"shipping",original_id:w.id,category_id:"",category_name:"",country:w._raw.country||"",city:w._raw.city||"",postcode:w._raw.postcode||"",tax_label:w.tax_label,tax_rate:w.rate,class_id:Number(w._raw.class_id)||f(),id:w.id};else{const S=w._raw.meta_value||w._raw;s.value={type:"products",original_type:"products",original_id:w.id,category_id:en(S.category_id),category_name:w.category_name,country:S.country||"",city:S.city||"",postcode:S.postcode||"",tax_label:w.tax_label,tax_rate:w.rate,class_id:Number(w.class_id)||0,id:w.id}}}be(()=>a.modelValue,w=>{w&&(a.editRow?g(a.editRow):_(),y())}),be(()=>s.value.type,w=>{w==="shipping"&&!s.value.class_id&&(s.value.class_id=f())}),be(()=>a.taxClasses,w=>{s.value.type==="shipping"&&!s.value.class_id&&w&&w.length>0&&(s.value.class_id=Number(w[0].id)||0)});function y(){i.value.length>0||(c.value=!0,ue.get("products/fetch-term").then(w=>{const S=w.taxonomies&&w.taxonomies["product-categories"]?w.taxonomies["product-categories"].terms||[]:[];i.value=S.map($=>({...$,value:en($.value)}))}).catch(()=>{z.error(u("Failed to load product categories"))}).finally(()=>{c.value=!1}))}function v(w,S){return ue.get("tax/rates/country/rates/"+w,{class_id:S}).then($=>{const F=($&&$.tax_rates?$.tax_rates:[]).find(function(Q){return!Q.state&&!Q.city&&!Q.postcode});if(F)return F;const x=a.countries.find(function(Q){return Q.value===w});return ue.post("tax/country/rate",{country:w,state:"",rate:x&&x.default_rate||0,name:"Tax",is_compound:0,for_order:0,group:"EU",class_id:S}).then(function(Q){return Q&&Q.tax_rate?Q.tax_rate:null})})}function b(w){const S=en(w),$=i.value.find(V=>V.value===S);$&&(s.value.category_name=$.label)}function k(){if(s.value.type==="products"&&!s.value.category_id){z.error(u("Please select a category"));return}if(!s.value.country){z.error(u("Please select a location"));return}if(s.value.type==="shipping"){if(!a.taxClasses||a.taxClasses.length===0){z.error(u("Tax classes are not available. Please reload the page and try again."));return}if(!s.value.class_id){z.error(u("Please select a tax class"));return}}if(p.value=!0,s.value.type==="products")ue.post("tax/product-overrides",{id:s.value.original_type==="products"?s.value.original_id:"",source_type:s.value.original_type,source_id:s.value.original_id,country:s.value.country,state:"",city:s.value.city||"",postcode:s.value.postcode||"",category_id:s.value.category_id,category_name:s.value.category_name,tax_label:s.value.tax_label,rate:s.value.tax_rate,override_state_tax:"no",class_id:s.value.class_id||0}).then(w=>{z.success(w.message),l("saved"),l("update:modelValue",!1)}).catch(w=>{z.error(w&&w.data?w.data.message:w&&w.message?w.message:"")}).finally(()=>{p.value=!1});else{const w=s.value.class_id;v(s.value.country,w).then(S=>S?ue.post("tax/rates/country/override",{id:S.id,previous_id:s.value.original_type==="shipping"?s.value.original_id:"",source_type:s.value.original_type,source_id:s.value.original_id,class_id:w,override_tax_rate:s.value.tax_rate,city:s.value.city||"",postcode:s.value.postcode||""}).then($=>{z.success($.message),l("saved"),l("update:modelValue",!1)}).catch($=>{z.error($&&$.data?$.data.message:$&&$.message?$.message:"")}).finally(()=>{p.value=!1}):(z.error(u("No tax rate found for the selected country and tax class")),p.value=!1,null)).catch(S=>{z.error(S&&S.data?S.data.message:S&&S.message?S.message:""),p.value=!1})}}return(w,S)=>{const $=C("el-radio"),V=C("el-radio-group"),F=C("el-form-item"),x=C("el-option"),Q=C("el-select"),D=C("el-input"),T=C("el-form"),U=C("el-button"),I=C("el-dialog");return r(),E(I,{"model-value":e.modelValue,title:e.editRow?A(u)("Edit tax override"):A(u)("Add tax override"),width:"520px","close-on-click-modal":!1,class:"fluent-cart-admin-pages","append-to-body":!0,"onUpdate:modelValue":S[14]||(S[14]=O=>l("update:modelValue",O))},{footer:d(()=>[n(U,{onClick:S[13]||(S[13]=O=>l("update:modelValue",!1))},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(U,{type:"primary",loading:p.value,onClick:k},{default:d(()=>[R(m(e.editRow?A(u)("Save changes"):A(u)("Add override")),1)]),_:1},8,["loading"])]),default:d(()=>[n(T,{"label-position":"top",model:s.value},{default:d(()=>[n(F,{label:A(u)("Override type")},{default:d(()=>[n(V,{modelValue:s.value.type,"onUpdate:modelValue":S[0]||(S[0]=O=>s.value.type=O)},{default:d(()=>[n($,{value:"products"},{default:d(()=>[R(m(A(u)("Products")),1)]),_:1}),n($,{value:"shipping"},{default:d(()=>[R(m(A(u)("Shipping")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),s.value.type==="products"?(r(),h(H,{key:0},[n(F,{label:A(u)("Category")},{default:d(()=>[n(Q,{modelValue:s.value.category_id,"onUpdate:modelValue":S[1]||(S[1]=O=>s.value.category_id=O),filterable:"",placeholder:A(u)("Select a category"),loading:c.value,style:{width:"100%"},onChange:b},{default:d(()=>[(r(!0),h(H,null,ae(i.value,O=>(r(),E(x,{key:O.value,label:O.label,value:O.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","loading"])]),_:1},8,["label"]),e.taxClasses.length>0?(r(),E(F,{key:0,label:A(u)("Tax Class")},{default:d(()=>[n(Q,{modelValue:s.value.class_id,"onUpdate:modelValue":S[2]||(S[2]=O=>s.value.class_id=O),style:{width:"100%"}},{default:d(()=>[n(x,{value:0,label:A(u)("All Tax Classes")},null,8,["label"]),(r(!0),h(H,null,ae(e.taxClasses,O=>(r(),E(x,{key:O.id,value:Number(O.id),label:O.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])):B("",!0),n(F,{label:A(u)("Tax label")},{default:d(()=>[n(D,{modelValue:s.value.tax_label,"onUpdate:modelValue":S[3]||(S[3]=O=>s.value.tax_label=O),placeholder:A(u)("e.g. Tax, VAT, GST")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(F,{label:A(u)("Location")},{default:d(()=>[n(Q,{modelValue:s.value.country,"onUpdate:modelValue":S[4]||(S[4]=O=>s.value.country=O),placeholder:A(u)("Select country"),filterable:"",style:{width:"100%"}},{default:d(()=>[(r(!0),h(H,null,ae(e.countries,O=>(r(),E(x,{key:O.value,label:O.label,value:O.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(F,{label:A(u)("City (optional)")},{default:d(()=>[n(D,{modelValue:s.value.city,"onUpdate:modelValue":S[5]||(S[5]=O=>s.value.city=O),placeholder:A(u)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(F,{label:A(u)("Postcode (optional)")},{default:d(()=>[n(D,{modelValue:s.value.postcode,"onUpdate:modelValue":S[6]||(S[6]=O=>s.value.postcode=O),placeholder:A(u)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(F,{label:A(u)("Tax rate (%)")},{default:d(()=>[n(D,{modelValue:s.value.tax_rate,"onUpdate:modelValue":S[7]||(S[7]=O=>s.value.tax_rate=O),type:"number",step:"0.01",min:"0",placeholder:A(u)("e.g. 0 for tax exempt")},null,8,["modelValue","placeholder"])]),_:1},8,["label"])],64)):(r(),h(H,{key:1},[n(F,{label:A(u)("Location")},{default:d(()=>[n(Q,{modelValue:s.value.country,"onUpdate:modelValue":S[8]||(S[8]=O=>s.value.country=O),placeholder:A(u)("Select country"),filterable:"",style:{width:"100%"}},{default:d(()=>[(r(!0),h(H,null,ae(e.countries,O=>(r(),E(x,{key:O.value,label:O.label,value:O.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),e.taxClasses.length>0?(r(),E(F,{key:0,label:A(u)("Tax Class")},{default:d(()=>[n(Q,{modelValue:s.value.class_id,"onUpdate:modelValue":S[9]||(S[9]=O=>s.value.class_id=O),style:{width:"100%"}},{default:d(()=>[(r(!0),h(H,null,ae(e.taxClasses,O=>(r(),E(x,{key:O.id,value:Number(O.id),label:O.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])):B("",!0),n(F,{label:A(u)("City (optional)")},{default:d(()=>[n(D,{modelValue:s.value.city,"onUpdate:modelValue":S[10]||(S[10]=O=>s.value.city=O),placeholder:A(u)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(F,{label:A(u)("Postcode (optional)")},{default:d(()=>[n(D,{modelValue:s.value.postcode,"onUpdate:modelValue":S[11]||(S[11]=O=>s.value.postcode=O),placeholder:A(u)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(F,{label:A(u)("Tax rate (%)")},{default:d(()=>[n(D,{modelValue:s.value.tax_rate,"onUpdate:modelValue":S[12]||(S[12]=O=>s.value.tax_rate=O),type:"number",step:"0.01",min:"0"},null,8,["modelValue"])]),_:1},8,["label"])],64))]),_:1},8,["model"])]),_:1},8,["model-value","title"])}}},whe={class:"fct-tax-rates-country-view"},Che={key:0,class:"border border-gray-200 rounded-md overflow-hidden dark:border-dark-300"},khe={class:"grid grid-cols-[110px_1fr_1fr_1fr_100px_110px] gap-4 px-4 py-3 border-b border-gray-200 dark:border-dark-300"},Bhe={key:0},xhe={key:1},She={class:"fct-btn-group sm justify-end"},Fhe={__name:"EUVatTaxOverridesCard",props:{countries:{type:Array,default:()=>[]}},setup(e){const t=e,a=M([]),l=M(!1),s=M(!1),i=M(null),c=M([]);function p(b){if(!b||!Array.isArray(t.countries))return b;const k=t.countries.find(w=>w.value===b);return k?k.label:b}function f(){ue.get("tax/classes").then(b=>{c.value=b.classes||[]}).catch(()=>{z.error(u("Failed to load tax classes"))})}function _(){l.value=!0,ue.get("tax/configuration/settings/eu-vat/product-overrides").then(b=>{const k=[],w=b.overrides||[];for(const $ of w){const V=$.meta_value||$;k.push({id:$.id,type:"products",tax_label:V.tax_label||"",category_name:V.category_name||"",location:p(V.country),city:V.city||"",postcode:V.postcode||"",rate:V.rate,class_id:Number($.class_id)||0,class_label:$.class_label||"",_raw:$})}const S=b.shipping_overrides||[];for(const $ of S)k.push({id:$.id,type:"shipping",tax_label:$.name||"",category_name:"",location:p($.country),city:$.city||"",postcode:$.postcode||"",rate:$.for_shipping,class_id:Number($.class_id)||0,class_label:$.class_label||"",_raw:$});a.value=k}).catch(()=>{a.value=[]}).finally(()=>{l.value=!1})}function g(){i.value=null,s.value=!0}function y(b){i.value=b,s.value=!0}function v(b){rl(u("Are you sure you want to delete this override?"),u("Confirm Delete"),{confirmButtonText:u("Yes, Delete"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{const k=b.type==="shipping"?"tax/rates/country/override/"+b.id:"tax/product-overrides/"+b.id;ue.delete(k).then(w=>{z.success(w.message),a.value=a.value.filter(S=>!(S.id===b.id&&S.type===b.type))}).catch(w=>{var S;z.error((S=w==null?void 0:w.data)==null?void 0:S.message)})}).catch(()=>{})}return Ie(()=>{f(),_()}),(b,k)=>{const w=C("el-button"),S=C("el-tag"),$=C("el-table-column"),V=C("el-table");return r(),h(H,null,[n(Be,{class:"fct-vat-card"},{default:d(()=>[n(Qe,{title:A(u)("Tax overrides"),text:A(u)("Override tax rates for specific product categories or shipping.")},{action:d(()=>[n(w,{size:"small",onClick:g},{default:d(()=>[R(m(A(u)("Add Tax Override")),1)]),_:1})]),_:1},8,["title","text"]),n(Ce,null,{default:d(()=>[o("div",whe,[l.value?(r(),h("div",Che,[o("div",khe,[(r(),h(H,null,ae(6,F=>o("div",{key:"loading-header-"+F,class:"fct-sk h-3 rounded-xs"})),64))]),(r(),h(H,null,ae(3,F=>o("div",{key:"loading-row-"+F,class:"grid grid-cols-[110px_1fr_1fr_1fr_100px_110px] gap-4 px-4 py-4 border-b border-gray-100 last:border-b-0 dark:border-dark-400"},k[2]||(k[2]=[o("div",{class:"fct-sk w-16 h-6 rounded-full"},null,-1),o("div",{class:"fct-sk w-28 h-3.5 rounded-xs"},null,-1),o("div",{class:"fct-sk w-24 h-3.5 rounded-xs"},null,-1),o("div",{class:"fct-sk w-24 h-3.5 rounded-xs"},null,-1),o("div",{class:"fct-sk w-12 h-3.5 rounded-xs"},null,-1),o("div",{class:"fct-sk w-4 h-4 rounded-xs justify-self-end"},null,-1)]))),64))])):(r(),E(V,{key:1,data:a.value,"empty-text":A(u)("No overrides configured")},{default:d(()=>[n($,{label:A(u)("Type"),width:"110"},{default:d(({row:F})=>[n(S,{type:F.type==="products"?"primary":"info",size:"small"},{default:d(()=>[R(m(F.type==="products"?A(u)("Product"):A(u)("Shipping")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),n($,{label:A(u)("Category")},{default:d(({row:F})=>[R(m(F.category_name||"—"),1)]),_:1},8,["label"]),n($,{label:A(u)("Tax Class"),width:"130"},{default:d(({row:F})=>[R(m(F.class_label||A(u)("All")),1)]),_:1},8,["label"]),n($,{label:A(u)("Tax Label")},{default:d(({row:F})=>[R(m(F.tax_label||"—"),1)]),_:1},8,["label"]),n($,{label:A(u)("Location")},{default:d(({row:F})=>[R(m(F.location),1)]),_:1},8,["label"]),n($,{label:A(u)("City / Postcode")},{default:d(({row:F})=>[F.city||F.postcode?(r(),h("span",Bhe,m([F.city,F.postcode].filter(Boolean).join(" / ")),1)):(r(),h("span",xhe,"—"))]),_:1},8,["label"]),n($,{label:A(u)("Rate"),width:"100"},{default:d(({row:F})=>[R(m(F.rate)+"% ",1)]),_:1},8,["label"]),n($,{label:A(u)("Actions"),width:"110",align:"right"},{default:d(({row:F})=>[o("div",She,[n(Ze,{tag:"button",size:"small",onClick:x=>y(F)},{default:d(()=>[n(J,{name:"Edit"})]),_:2},1032,["onClick"]),n(Ze,{tag:"button",size:"small",onClick:x=>v(F),bg:"danger",outline:""},{default:d(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick"])])]),_:1},8,["label"])]),_:1},8,["data","empty-text"]))])]),_:1})]),_:1}),n(bhe,{modelValue:s.value,"onUpdate:modelValue":[k[0]||(k[0]=F=>s.value=F),k[1]||(k[1]=F=>!F&&(i.value=null))],countries:e.countries,"tax-classes":c.value,"edit-row":i.value,onSaved:_},null,8,["modelValue","countries","tax-classes","edit-row"])],64)}}},$he={class:"setting-wrap"},Ehe={class:"setting-wrap-inner"},Uhe={class:"fct-tax-collection-page"},Ihe={__name:"EUVatSettings",setup(e){const t=M(!0),a=Ge.get("eu_vat_county_options",[]),l=M(""),s=M(""),i=M([]),c=M({}),p=N(()=>!!Ge.get("is_tax_enabled"));function f(){return t.value=!0,ue.get("tax/configuration/settings").then(g=>{var v;const y=((v=g.settings)==null?void 0:v.eu_vat_settings)||{};l.value=g.store_country||"",i.value=y.country_registrations||[],c.value=y,s.value=y.method||""}).catch(g=>{var y;z.error((y=g==null?void 0:g.data)==null?void 0:y.message)}).finally(()=>{t.value=!1})}function _({method:g}){s.value=g||"",f()}return Ie(f),(g,y)=>(r(),h("div",$he,[n(Qa,{heading:A(u)("VAT collection"),"show-save-button":!1},null,8,["heading"]),o("div",Ehe,[n(Da),o("div",Uhe,[t.value?(r(),E(Nfe,{key:0})):(r(),h(H,{key:1},[n(yhe,{countries:A(a),"initial-form":c.value,"initial-registrations":i.value,"store-country":l.value,"is-tax-enabled":p.value,onMethodChanged:_},null,8,["countries","initial-form","initial-registrations","store-country","is-tax-enabled"]),n(Fhe,{countries:A(a),class:"mt-5"},null,8,["countries"])],64))])])]))}};class Qhe extends Qs{getTabs(){return{all:u("All"),active:u("Active"),expired:u("Inactive")}}getToggleableColumns(){return[{label:"Title",value:"title"},{label:"Stackable",value:"stackable"},{label:"Actions",value:"actions"}]}getSearchHint(){return u("Search by id, title, amount, code.")}getFetchUrl(){return"coupons"}parseResponse(t){return t.coupons}getTableName(){return"coupon_table"}getAdvanceFilterOptions(){return null}getSearchGuideOptions(){return[]}with(){return[]}}function df(e){return Qhe.init(e)}const Dhe={class:"fct-table-mobile-wrap fct-coupons-table-mobile-wrap"},Vhe={class:"fct-table-mobile-header"},The={class:"fct-table-mobile-header-left"},Mhe={class:"fct-table-id-col"},Lhe={class:"fct-table-status-col"},Rhe=["onClick"],Ohe={class:"title"},Hhe={class:"value"},Phe={key:0,class:"fct-table-action-col"},Nhe={class:"more-btn pr-0"},Khe={class:"fct-table-mobile-body"},Ghe=["onClick"],jhe={key:0,class:"fct-table-coupon-title-col"},zhe={class:"fct-table-coupon-code-col"},qhe=["onClick"],Yhe={class:"fct-table-mobile-footer"},Whe=["onClick"],Jhe={class:"fct-table-date-col grid"},Xhe={class:"title"},Zhe={class:"value"},e_e={key:0,class:"fct-table-stackable-col"},t_e={class:"title"},a_e={class:"value"},l_e={class:"fct-table-amount-col"},s_e={class:"title"},n_e={class:"value"},o_e={__name:"CouponsTableMobile",props:{table:{type:Object,required:!0},emptyText:{type:String,default:u("No customers found.")}},setup(e){et.extend(di);const t=e,a=s=>{if(!s||s==="0000-00-00 00:00:00")return!1;const i=et.utc(s).local();return i.isValid()?i.isBefore(et()):!1},l=s=>{let i=u("Are you sure you want to delete this %s coupon. This action is not recoverable",s.coupon.title);s.action==="delete"&&rl(i,u("Confirm Delete!"),{confirmButtonText:u("Yes, Delete!"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{ue.delete("coupons/"+s.coupon.id).then(c=>{z.success(c.message),t.table.fetch()}).catch(c=>{z.error(c)}).finally(()=>{})}).catch(()=>{})};return(s,i)=>{const c=C("router-link"),p=C("el-tooltip"),f=C("el-dropdown-item"),_=C("el-dropdown-menu"),g=C("el-dropdown");return r(),h("div",Dhe,[(r(!0),h(H,null,ae(e.table.getTableData(),(y,v)=>(r(),h("div",{key:y.id,class:"fct-table-mobile-row"},[o("div",Vhe,[o("div",The,[o("div",Mhe,[n(c,{to:{name:"add_or_edit_coupon",params:{coupon_id:y.id}},class:"id"},{default:d(()=>[R(" #"+m(y.id),1)]),_:2},1032,["to"])]),o("div",Lhe,[n(ma,{status:y.status},{default:d(()=>[R(m(a(y.end_date)?A(u)("Expired"):y.status),1)]),_:2},1032,["status"]),y.status==="scheduled"?(r(),E(p,{key:0,effect:"dark",placement:"top","popper-class":"fct-label-hint-popover fct-tooltip","show-after":400,"hide-after":0},{content:d(()=>[R(m(A(u)("Available On: %s",A($s)(y.start_date,!0))),1)]),default:d(()=>[n(J,{name:"InformationFill",class:"w-4 h-4 flex-none"})]),_:2},1024)):B("",!0)]),o("div",{class:"fct-table-usage-col",onClick:b=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[o("div",Ohe,m(A(u)("Usage:")),1),o("div",Hhe,[R(m(y.use_count??0)+" ",1),i[0]||(i[0]=o("span",null,"/",-1)),R(" "+m(y.conditions.max_uses>0?y.conditions.max_uses:A(u)("Unlimited")),1)])],8,Rhe)]),e.table.isColumnVisible("actions")?(r(),h("div",Phe,[n(g,{trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:l,placement:"bottom-end"},{dropdown:d(()=>[n(_,null,{default:d(()=>[y.id?(r(),E(f,{key:0,class:"item-link"},{default:d(()=>[n(c,{to:{name:"add_or_edit_coupon",params:{coupon_id:y.id,action:"edit"}}},{default:d(()=>[n(J,{name:"Edit"}),R(" "+m(A(u)("Edit")),1)]),_:2},1032,["to"])]),_:2},1024)):B("",!0),n(f,{command:{action:"delete",coupon:y},class:"item-destructive"},{default:d(()=>[n(J,{name:"Delete"}),R(" "+m(A(u)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:d(()=>[o("span",Nhe,[n(J,{name:"More"})])]),_:2},1024)])):B("",!0)]),o("div",Khe,[o("div",{class:"fct-table-coupon-code-wrapper-col",onClick:b=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[e.table.isColumnVisible("title")?(r(),h("div",jhe,m(y.title),1)):B("",!0),o("div",zhe,[o("code",{class:"copyable-content",onClick:b=>{A(Zl).copy(y.code)}},m(y.code),9,qhe)])],8,Ghe)]),o("div",Yhe,[o("div",{class:"fct-table-mobile-footer-row items-start",onClick:b=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[o("div",Jhe,[o("div",Xhe,m(A(u)("Expiry Date")),1),o("div",Zhe,[isNaN(Date.parse(y.end_date))?(r(),h(H,{key:1},[R("n/a")],64)):(r(),E(Na,{key:0,"date-time":y.end_date,"with-time":!0},null,8,["date-time"]))])]),e.table.isColumnVisible("stackable")?(r(),h("div",e_e,[o("div",t_e,m(A(u)("Stackable")),1),o("div",a_e,m(y.stackable),1)])):B("",!0),o("div",l_e,[o("div",s_e,m(A(u)("Amount")),1),o("div",n_e,m(y.type!=="percentage"?A(Gt)(y.amount,!0):y.amount+"%"),1)])],8,Whe)])]))),128))])}}},i_e={},r_e={class:"px-4 py-3"},d_e={class:"grid grid-cols-3 gap-5 mt-5"};function u_e(e,t){const a=C("el-skeleton-item"),l=C("el-skeleton");return r(),E(l,{animated:""},{template:d(()=>[o("div",r_e,[(r(),h(H,null,ae(2,s=>o("div",{key:s,class:"flex items-center justify-between mb-3"},[n(a,{varient:"p",class:"w-1/2"}),n(a,{varient:"p",class:"w-[100px]"})])),64)),o("div",d_e,[(r(),h(H,null,ae(3,s=>o("div",{key:s},[n(a,{varient:"p",class:"w-1/2"}),n(a,{varient:"p",class:"w-[100px]"})])),64))])])]),_:1})}const c_e=lt(i_e,[["render",u_e]]),A_e={class:"fct-all-coupons-page fct-layout-width"},p_e={class:"fct-all-coupons-wrap"},f_e={key:1},m_e=["onClick"],h_e={class:"capitalize"},__e={class:"more-btn mr-2"},_c={__name:"AllCoupons",setup(e){et.extend(di);const t=df(),a=M(!1),l=c=>{let p=u("Are you sure you want to delete this %s coupon. This action is not recoverable",c.coupon.title);c.action==="delete"&&rl(p,u("Confirm Delete!"),{confirmButtonText:u("Yes, Delete!"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{ue.delete("coupons/"+c.coupon.id).then(f=>{z.success(f.message),t.fetch()}).catch(f=>{var _;f.status_code=="422"?z.validationErrors(f):z.error((_=f.data)==null?void 0:_.message)}).finally(()=>{})}).catch(()=>{})},s=()=>{ue.get("coupons/getSettings").then(c=>{a.value=!!parseInt(c.show_on_checkout)}).catch(c=>{var p;c.status_code=="422"?z.validationErrors(c):z.error((p=c.data)==null?void 0:p.message)}).finally(()=>{})},i=c=>{if(!c||c==="0000-00-00 00:00:00")return!1;const p=et.utc(c).local();return p.isValid()?p.isBefore(et()):!1};return Ie(()=>{s()}),(c,p)=>{const f=C("el-button"),_=C("el-table-column"),g=C("el-tooltip"),y=C("router-link"),v=C("el-dropdown-item"),b=C("el-dropdown-menu"),k=C("el-dropdown"),w=C("el-table");return r(),E(Rt,{permission:"coupons/view"},{default:d(()=>[o("div",A_e,[n(nl,{title:A(u)("Coupons")},{action:d(()=>[n(f,{tag:"router-link",type:"primary",to:{name:"add_or_edit_coupon"}},{default:d(()=>[R(m(A(u)("Add Coupon")),1)]),_:1})]),_:1},8,["title"]),o("div",p_e,[n(Ds,{table:A(t),"has-mobile-slot":!0},{mobile:d(()=>[A(t).isLoading()?(r(),E(c_e,{key:0})):B("",!0),A(t).isLoading()?B("",!0):(r(),E(o_e,{key:1,table:A(t)},null,8,["table"]))]),default:d(()=>[A(t).isLoading()?(r(),E(pfe,{key:0,couponTable:A(t),"next-page-count":A(t).nextPageCount},null,8,["couponTable","next-page-count"])):(r(),h("div",f_e,[n(w,{data:A(t).getTableData(),class:"w-full compact-table full-compact"},{empty:d(()=>[n(wt,{icon:"Empty/Order","has-dark":"",text:A(u)("No coupons available at the moment.")},null,8,["text"])]),default:d(()=>[n(_,{width:100,label:A(u)("ID")},{default:d(S=>[n(Ba,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id}}},{default:d(()=>[R(" #"+m(A(ta)(S.row.id)),1)]),_:2},1032,["to"])]),_:1},8,["label"]),A(t).isColumnVisible("title")?(r(),E(_,{key:0,label:A(u)("Title"),width:220},{default:d(S=>[n(Ba,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[R(m(S.row.title),1)]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),n(_,{label:A(u)("Code"),width:200},{default:d(S=>[o("code",{class:"copyable-content",onClick:$=>{A(Zl).copy(S.row.code)}},m(S.row.code),9,m_e)]),_:1},8,["label"]),n(_,{label:A(u)("Amount"),width:120},{default:d(S=>[n(Ba,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[R(m(S.row.type!=="percentage"?A(Gt)(S.row.amount,!0):S.row.amount+"%"),1)]),_:2},1032,["to"])]),_:1},8,["label"]),n(_,{label:A(u)("Usage"),width:150},{default:d(S=>[n(Ba,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[o("span",null,m(A(ta)(S.row.use_count??0)),1),p[0]||(p[0]=o("span",{class:"px-1"},"/",-1)),o("span",null,m(S.row.conditions.max_uses>0?S.row.conditions.max_uses:A(u)("Unlimited")),1)]),_:2,__:[0]},1032,["to"])]),_:1},8,["label"]),A(t).isColumnVisible("stackable")?(r(),E(_,{key:1,label:A(u)("Stackable"),width:120},{default:d(S=>[n(Ba,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[o("span",h_e,m(S.row.stackable),1)]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),n(_,{label:A(u)("Status"),width:120},{default:d(S=>[n(Ba,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[n(ma,{status:S.row.status},{default:d(()=>[R(m(i(S.row.end_date)?A(u)("Expired"):S.row.status),1)]),_:2},1032,["status"]),S.row.status==="scheduled"?(r(),E(g,{key:0,effect:"dark",placement:"top","popper-class":"fct-label-hint-popover fct-tooltip","show-after":400,"hide-after":0},{content:d(()=>[R(m(A(u)("Available On: %s",A($s)(S.row.start_date,!0))),1)]),default:d(()=>[n(J,{name:"InformationFill",class:"w-4 h-4 flex-none"})]),_:2},1024)):B("",!0)]),_:2},1032,["to"])]),_:1},8,["label"]),n(_,{label:A(u)("Expiry Date"),width:120},{default:d(S=>[n(Ba,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[o("span",null,[isNaN(Date.parse(S.row.end_date))?(r(),h(H,{key:1},[R("n/a")],64)):(r(),E(Na,{key:0,"date-time":S.row.end_date,"with-time":!0},null,8,["date-time"]))])]),_:2},1032,["to"])]),_:1},8,["label"]),A(t).isColumnVisible("actions")?(r(),E(_,{key:2,label:A(u)("Actions"),width:100,align:"right",fixed:"right"},{default:d(S=>[n(k,{trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:l,placement:"bottom-end"},{dropdown:d(()=>[n(b,null,{default:d(()=>[S.row.id?(r(),E(v,{key:0,class:"item-link"},{default:d(()=>[n(y,{to:{name:"add_or_edit_coupon",params:{coupon_id:S.row.id,action:"edit"}}},{default:d(()=>[n(J,{name:"Edit"}),R(" "+m(A(u)("Edit")),1)]),_:2},1032,["to"])]),_:2},1024)):B("",!0),n(v,{command:{action:"delete",coupon:S.row},class:"item-destructive"},{default:d(()=>[n(J,{name:"Delete"}),R(" "+m(A(u)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:d(()=>[o("span",__e,[n(J,{name:"More"})])]),_:2},1024)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])]))]),_:1},8,["table"])])])]),_:1})}}},v_e={class:"fct-add-edit-coupon-wrapper fct-layout-width"},g_e={class:"single-page-header"},y_e={class:"single-page-body"},b_e={class:"fct-add-edit-coupon"},w_e={class:"fct-add-edit-coupon-main"},C_e={class:"fct-add-edit-coupon-aside"},k_e={class:"fct-admin-sidebar"},B_e={__name:"SingleCouponLoader",setup(e){return(t,a)=>{const l=C("el-skeleton-item"),s=C("el-skeleton"),i=C("el-breadcrumb-item"),c=C("el-breadcrumb");return r(),h("div",v_e,[o("div",g_e,[n(c,{"separator-icon":A(dl)},{default:d(()=>[n(i,null,{default:d(()=>[n(s,{animated:!0},{template:d(()=>[n(l,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),n(i,null,{default:d(()=>[n(s,{animated:!0},{template:d(()=>[n(l,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),n(i,null,{default:d(()=>[n(s,{animated:!0},{template:d(()=>[n(l,{variant:"p",class:"w-[60px] h-4"})]),_:1})]),_:1})]),_:1},8,["separator-icon"])]),o("div",y_e,[o("div",b_e,[o("div",w_e,[n(Be,null,{default:d(()=>[n(Qe,{title:A(u)("Basic Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(Ce,null,{default:d(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),n(Be,null,{default:d(()=>[n(Qe,{title:A(u)("Discount Value"),border_bottom:"",title_size:"small"},null,8,["title"]),n(Ce,null,{default:d(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),n(Be,null,{default:d(()=>[n(Qe,{title:A(u)("Schedule"),border_bottom:"",title_size:"small"},null,8,["title"]),n(Ce,null,{default:d(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),n(Be,null,{default:d(()=>[n(Qe,{title:A(u)("Maximum Discount Uses"),border_bottom:"",title_size:"small"},null,8,["title"]),n(Ce,null,{default:d(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1}),n(Be,null,{default:d(()=>[n(Qe,{title:A(u)("Additional Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(Ce,null,{default:d(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"}),n(l,{variant:"p",class:"max-w-[400px] h-4"}),n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1})]),o("div",C_e,[o("div",k_e,[n(Be,null,{default:d(()=>[n(Qe,{title:A(u)("Summary"),border_bottom:"",title_size:"small"},null,8,["title"]),n(Ce,null,{default:d(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"}),n(l,{variant:"p",class:"w-2/3 h-4"}),n(l,{variant:"p",class:"w-1/3 h-4"})]),_:1})]),_:1})]),_:1})])])])])])}}};et.extend(di);et.extend(tA);const x_e={name:"AddOrEditCoupon",components:{CardContainer:Be,CardHeader:Qe,CardBody:Ce,LabelHint:fa,ValidationError:ra,CopyToClipboard:Ia,DynamicTemplates:cn,SaveBar:rn,ProductVariationSelector:aA,SingleCouponLoader:B_e,Activity:Yc},beforeRouteLeave(e,t,a){var l;(l=this.keyboardShortcuts)!=null&&l.unbind&&this.keyboardShortcuts.unbind("mod+s"),a()},props:{coupon_id:{type:[String,Number],required:!0}},data(){return{changes_made:0,creating:!1,updating:!1,keyboardShortcuts:null,coupon:{type:"fixed",status:"active",stackable:"no",show_on_checkout:"no",title:"",code:"",priority:0,amount:0,start_date:"",end_date:"",notes:"",conditions:{buy_quantity:1,get_quantity:1,excluded_categories:[],included_categories:[],excluded_products:[],included_products:[],min_purchase_amount:"",max_purchase_amount:"",min_amount_basis:"subtotal",allowed_user_ids:[],allowed_user_roles:[],apply_to_quantity:"no",apply_to_whole_cart:"yes",max_per_customer:"",max_discount_amount:"",max_uses:"",buy_products:[],get_products:[],is_recurring:"no"}},validationErrors:{},minQuantity:1,maxQuantity:100,minPurchaseAmount:0,maxPurchaseAmount:1e4,minDiscountAmount:0,minLimit:0,maxLimit:1e3,categories:[],usageError:!1,isEndDateEnabled:!1,fetchingCoupon:!1,isInitialLoading:!1,showDynamicTemplates:!1,showManageActivity:!1}},computed:{ArrowRight(){return dl},maxDiscountAmount(){return this.coupon.type==="percentage"?100:999999}},watch:{coupon:{handler(){this.handleChangesMade()},deep:!0}},mounted(){this.keyboardShortcuts=_s(),this.fetchTerms(),this.coupon_id?(this.fetchCoupon(),this.keyboardShortcuts.bind(["mod+s"],e=>{e.preventDefault(),this.updateCoupon()}),window.onbeforeunload=()=>{if(this.changes_made>1)return!0}):this.keyboardShortcuts.bind(["mod+s"],e=>{e.preventDefault(),this.addCoupon()})},methods:{translate:u,generateRandomCouponCode(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let t="";for(let a=0;a<8;a++)t+=e.charAt(Math.floor(Math.random()*e.length));this.coupon.code=t},onChangeCouponInput(e,t){if(t=parseInt(t),isNaN(t)||t===""){this.coupon[e]="";return}if(e==="priority"&&(t<0||t>100)){this.coupon[e]=0;return}if((e==="buy_quantity"||e==="get_quantity")&&(tthis.maxQuantity)){this.coupon[e]=this.minQuantity;return}if((e==="min_purchase_amount"||e==="max_discount_amount")&&(tthis.maxPurchaseAmount)){this.coupon.conditions[e]=this.minPurchaseAmount;return}if(e==="amount"){if(this.coupon.type==="fixed"&&(tthis.maxDiscountAmount)){this.coupon[e]=this.minDiscountAmount;return}if(this.coupon.type==="percentage"&&(tthis.maxDiscountAmount)){this.coupon[e]=this.minDiscountAmount;return}}if((e==="max_uses"||e==="max_per_customer")&&(tthis.maxLimit)){this.coupon[e]=this.minLimit;return}},preventInvalidChars(e,t=!1){let a=["-",".","+"];t&&(a=["-","+"]),a.includes(e.key)&&e.preventDefault()},handleChangesMade(){this.changes_made++},setDefaultStatus(){const e=new Date,t=this.coupon.start_date?new Date(this.coupon.start_date):null,a=this.coupon.end_date?new Date(this.coupon.end_date):null;this.coupon.status!=="disabled"&&(a===null&&(this.isEndDateEnabled=!1),!t&&!a?this.coupon.status="active":t&&ea?this.coupon.status="expired":this.coupon.status="active")},disabledStartDate(e){const t=new Date;return t.setHours(0,0,0,0),e&&e.getTime()parseInt(t,10)):[]},reloadPage(){return window.location.reload()},validateAndFormatDate(e){let t=this.formatDate(e);return t!==null&&t!=="Invalid date"?t:null},validateDate(){this.coupon.start_date=this.validateAndFormatDate(this.coupon.start_date),this.coupon.end_date=this.validateAndFormatDate(this.coupon.end_date)},fetchTerms(){ue.get("products/fetch-term").then(e=>{this.categories=e.taxonomies["product-categories"].terms}).catch(e=>{var t;e.status_code=="422"?z.validationErrors(e):z.error((t=e.data)==null?void 0:t.message)}).finally(()=>{})},fetchCoupon(){this.fetchingCoupon=!0,this.isInitialLoading=!0,ue.get(`coupons/${this.coupon_id}`,{}).then(e=>{var l,s;const t=(l=e==null?void 0:e.coupon)==null?void 0:l.start_date,a=(s=e==null?void 0:e.coupon)==null?void 0:s.end_date;t&&t!=="0000-00-00 00:00:00"&&(e.coupon.start_date=et.utc(t).tz(et.tz.guess()).format("YYYY-MM-DD HH:mm:ss")),a&&a!=="0000-00-00 00:00:00"&&(e.coupon.end_date=et.utc(a).tz(et.tz.guess()).format("YYYY-MM-DD HH:mm:ss")),e=e.coupon,this.coupon=e,this.coupon.start_date=this.formatDate(this.coupon.start_date),this.coupon.end_date=this.formatDate(this.coupon.end_date),this.coupon.end_date!==null&&(this.isEndDateEnabled=!0),this.coupon.end_date=this.coupon.end_date!==null&&this.coupon.end_date!=="Invalid date"?this.coupon.end_date:null,this.coupon.conditions.excluded_products=this.parseProductIds(e.conditions.excluded_products),this.coupon.conditions.included_products=this.parseProductIds(e.conditions.included_products),this.coupon.conditions.min_amount_basis||(this.coupon.conditions.min_amount_basis="total"),this.formatAmount(),this.setDefaultStatus(),this.showDynamicTemplates=!0}).catch(e=>{var t;errors.status_code=="422"?z.validationErrors(errors):z.error((t=errors.data)==null?void 0:t.message)}).finally(()=>{this.fetchingCoupon=!1,this.isInitialLoading=!1,this.changes_made=0})},updateCoupon(){var e,t;this.updating=!0,this.validateDate(),(e=this.$refs.dynamic_templates)==null||e.beforeUpdatingData({data:{coupon:this.coupon}}),ue.put(`coupons/${this.coupon_id}`,{...this.coupon,metaValue:(t=this.$refs.dynamic_templates)==null?void 0:t.getFormStates()}).then(a=>{var l;(l=this.$refs.dynamic_templates)==null||l.afterUpdatingData({coupon:this.coupon,response:a}),z.success(a.message),this.validationErrors={},this.setDefaultStatus(),this.changes_made=0}).catch(a=>{var l;a.status_code=="422"?(z.validationErrors(a),this.validationErrors=a):z.error((l=a.data)==null?void 0:l.message)}).finally(()=>{this.updating=!1,this.changes_made=0})},addCoupon(){var e,t;this.creating=!0,this.validateDate(),(e=this.$refs.dynamic_templates)==null||e.beforeUpdatingData({data:{coupon:this.coupon}}),ue.post("coupons",{...this.coupon,metaValue:(t=this.$refs.dynamic_templates)==null?void 0:t.getFormStates()}).then(a=>{var l;(l=this.$refs.dynamic_templates)==null||l.afterUpdatingData({coupon:this.coupon,response:a}),z.success(a.message),this.$router.push({name:"coupons"}),this.validationErrors={}}).catch(a=>{var l;a.status_code=="422"?(z.validationErrors(a),this.validationErrors=a):z.error((l=a.data)==null?void 0:l.message)}).finally(()=>{this.creating=!1})}}},S_e={class:"fct-add-edit-coupon-wrapper fct-layout-width"},F_e={class:"single-page-header"},$_e={class:"single-page-body"},E_e={class:"fct-add-edit-coupon"},U_e={class:"fct-add-edit-coupon-main"},I_e={class:"flex gap-2 items-center justify-between w-full mb-2.5"},Q_e={class:"form-note"},D_e=["innerHTML"],V_e={key:1},T_e=["innerHTML"],M_e=["innerHTML"],L_e=["innerHTML"],R_e={class:"fct-add-edit-coupon-aside"},O_e={class:"fct-admin-sidebar"},H_e={class:"fct-admin-sidebar-item"},P_e={key:0,class:"flex items-center gap-1"},N_e={class:"text-sm font-medium text-system-dark dark:text-gray-300"},K_e={key:1},G_e={class:"fct-admin-sidebar-item mt-5 hidden"},j_e={class:"sidebar-title mb-3"},z_e={class:"fct-bullet-lists"},q_e={class:"fct-admin-sidebar-item mt-5 hidden"},Y_e={class:"sidebar-title mb-3"},W_e={class:"fct-bullet-lists"},J_e={key:0};function X_e(e,t,a,l,s,i){const c=C("SaveBar"),p=C("SingleCouponLoader"),f=C("el-breadcrumb-item"),_=C("el-breadcrumb"),g=C("CardHeader"),y=C("el-input"),v=C("ValidationError"),b=C("el-form-item"),k=C("el-col"),w=C("LabelHint"),S=C("el-row"),$=C("CardBody"),V=C("CardContainer"),F=C("el-option"),x=C("el-select"),Q=C("el-radio"),D=C("el-radio-group"),T=C("ProductVariationSelector"),U=C("el-checkbox"),I=C("el-form"),O=C("CopyToClipboard"),L=C("el-date-picker"),P=C("DynamicTemplates"),q=C("Activity");return r(),h("div",S_e,[n(c,{isActive:s.changes_made>0?"is-active":"",loading:a.coupon_id?s.updating:s.creating,onSave:t[0]||(t[0]=X=>a.coupon_id?i.updateCoupon():i.addCoupon()),onDiscard:i.reloadPage,"show-cmnd-icon":!0,saveButtonText:a.coupon_id?i.translate("Update"):i.translate("Create")},null,8,["isActive","loading","onDiscard","saveButtonText"]),s.fetchingCoupon?(r(),E(p,{key:0})):B("",!0),s.fetchingCoupon?B("",!0):(r(),h(H,{key:1},[o("div",F_e,[n(_,{"separator-icon":i.ArrowRight},{default:d(()=>[n(f,{to:{name:"coupons"}},{default:d(()=>[R(m(i.translate("Coupons")),1)]),_:1}),n(f,null,{default:d(()=>[R(m(a.coupon_id?i.translate("Edit Coupon"):i.translate("Add Coupon")),1)]),_:1}),a.coupon_id?(r(),E(f,{key:0},{default:d(()=>[R(m(s.coupon.title),1)]),_:1})):B("",!0)]),_:1},8,["separator-icon"])]),o("div",$_e,[o("div",E_e,[o("div",U_e,[n(I,{model:s.coupon,"label-position":"top","require-asterisk-position":"right"},{default:d(()=>[n(V,null,{default:d(()=>[n(g,{title:i.translate("Basic Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,{class:"pb-1.5"},{default:d(()=>[n(S,{gutter:20},{default:d(()=>[n(k,{lg:24},{default:d(()=>[n(b,{label:i.translate("Title"),required:""},{default:d(()=>{var X,G;return[n(y,{modelValue:s.coupon.title,"onUpdate:modelValue":t[1]||(t[1]=te=>s.coupon.title=te),placeholder:i.translate("Enter title"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("title")?"is-error":""),maxlength:"50",id:"title"},null,8,["modelValue","placeholder","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("title")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"title"},null,8,["validation-errors"])):B("",!0)]}),_:1},8,["label"])]),_:1}),n(k,{lg:12},{default:d(()=>[n(b,null,{default:d(()=>{var X,G;return[o("div",I_e,[n(w,{title:i.translate("Code"),required:""},null,8,["title"]),o("span",{class:"text-system-dark text-xs cursor-pointer hover:underline dark:text-gray-50 underline",onClick:t[2]||(t[2]=(...te)=>i.generateRandomCouponCode&&i.generateRandomCouponCode(...te))},m(i.translate("Generate Random Code")),1)]),n(y,{modelValue:s.coupon.code,"onUpdate:modelValue":t[3]||(t[3]=te=>s.coupon.code=te),placeholder:i.translate("Eg. COUPON10"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("code")?"is-error":""),maxlength:"20"},null,8,["modelValue","placeholder","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("code")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"code"},null,8,["validation-errors"])):B("",!0),o("div",Q_e,[o("p",null,m(i.translate("Customers must enter this code at checkout.")),1)])]}),_:1})]),_:1}),n(k,{lg:12},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("Coupon Priority"),content:i.translate("Coupons will be calculated based on their priority. The lower the number the higher the priority is.")},null,8,["title","content"])]),default:d(()=>{var X,G;return[n(y,{modelValue:s.coupon.priority,"onUpdate:modelValue":t[4]||(t[4]=te=>s.coupon.priority=te),type:"number",placeholder:i.translate("Enter priority"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("priority")?"is-error":""),min:"0",max:"100",onInput:t[5]||(t[5]=te=>{i.onChangeCouponInput("priority",te)}),onKeypress:i.preventInvalidChars},null,8,["modelValue","placeholder","class","onKeypress"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("priority")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"priority"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),n(V,null,{default:d(()=>[n(g,{title:i.translate("Discount Details"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,{class:"pb-1.5"},{default:d(()=>[n(S,{gutter:20},{default:d(()=>[n(k,{lg:8},{default:d(()=>[n(b,{label:i.translate("Type"),required:""},{default:d(()=>{var X;return[n(x,{modelValue:s.coupon.type,"onUpdate:modelValue":t[6]||(t[6]=G=>s.coupon.type=G),placeholder:i.translate("Select coupon type"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("type")?"is-error":""),"default-first-option":""},{default:d(()=>[n(F,{label:i.translate("Fixed"),value:"fixed"},null,8,["label"]),n(F,{label:i.translate("Percentage"),value:"percentage"},null,8,["label"])]),_:1},8,["modelValue","placeholder","class"])]}),_:1},8,["label"])]),_:1}),s.coupon.type==="fixed"||s.coupon.type==="percentage"?(r(),h(H,{key:0},[n(k,{lg:8},{default:d(()=>[n(b,{label:s.coupon.type==="percentage"?i.translate("Discount Percentage (%)"):i.translate("Discount Amount"),required:""},{default:d(()=>{var X;return[n(y,{modelValue:s.coupon.amount,"onUpdate:modelValue":t[7]||(t[7]=G=>s.coupon.amount=G),type:"number",placeholder:"0.00",min:s.minDiscountAmount,max:i.maxDiscountAmount,step:"0.01",onInput:t[8]||(t[8]=G=>{i.onChangeCouponInput("amount",G)}),onKeypress:t[9]||(t[9]=G=>i.preventInvalidChars(G,!0))},{prefix:d(()=>[s.coupon.type==="fixed"?(r(),h("span",{key:0,innerHTML:e.appVars.shop.currency_sign},null,8,D_e)):(r(),h("span",V_e,"%"))]),_:1},8,["modelValue","min","max"]),(X=s.validationErrors)!=null&&X.hasOwnProperty("amount")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"amount"},null,8,["validation-errors"])):B("",!0)]}),_:1},8,["label"])]),_:1}),s.coupon.type==="percentage"?(r(),E(k,{key:0,lg:8},{default:d(()=>[n(b,{label:i.translate("Max Discount Amount")},{default:d(()=>{var X;return[n(y,{modelValue:s.coupon.conditions.max_discount_amount,"onUpdate:modelValue":t[10]||(t[10]=G=>s.coupon.conditions.max_discount_amount=G),type:"number",placeholder:i.translate("leave empty or 0 for no max limit"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("max_discount_amount")?"is-error":"")},{prefix:d(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,T_e)]),_:1},8,["modelValue","placeholder","class"]),n(v,{"validation-errors":s.validationErrors,"field-key":"max_discount_amount"},null,8,["validation-errors"])]}),_:1},8,["label"])]),_:1})):B("",!0)],64)):B("",!0)]),_:1})]),_:1})]),_:1}),n(V,null,{default:d(()=>[n(g,{title:i.translate("Usage Restrictions"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,{class:"pb-1.5"},{default:d(()=>[n(S,{gutter:20},{default:d(()=>[n(k,{lg:12},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("Min Spend Amount"),content:i.translate("Minimum spend (subtotal) allowed to use the coupon.")},null,8,["title","content"])]),default:d(()=>{var X,G;return[n(y,{modelValue:s.coupon.conditions.min_purchase_amount,"onUpdate:modelValue":t[11]||(t[11]=te=>s.coupon.conditions.min_purchase_amount=te),type:"number",placeholder:"0.00",class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("min_purchase_amount")?"is-error":"")},{prefix:d(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,M_e)]),_:1},8,["modelValue","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("min_purchase_amount")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"min_purchase_amount"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(k,{lg:12},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("Max Spend Amount"),content:i.translate("Set the maximum spend (subtotal) allowed when using the coupon.")},null,8,["title","content"])]),default:d(()=>{var X,G;return[n(y,{modelValue:s.coupon.conditions.max_purchase_amount,"onUpdate:modelValue":t[12]||(t[12]=te=>s.coupon.conditions.max_purchase_amount=te),type:"number",placeholder:i.translate("leave empty or 0 for no max limit"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("max_purchase_amount")?"is-error":"")},{prefix:d(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,L_e)]),_:1},8,["modelValue","placeholder","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("max_purchase_amount")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"max_purchase_amount"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(k,{lg:24},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("Spend Amount Based On"),content:i.translate("Choose what the min/max spend limits are measured against: the cart subtotal (items only) or the order total (including shipping and fees). Applies at checkout.")},null,8,["title","content"])]),default:d(()=>[n(D,{modelValue:s.coupon.conditions.min_amount_basis,"onUpdate:modelValue":t[13]||(t[13]=X=>s.coupon.conditions.min_amount_basis=X)},{default:d(()=>[n(Q,{value:"subtotal",label:i.translate("Subtotal (items only)")},null,8,["label"]),n(Q,{value:"total",label:i.translate("Total (includes shipping & fees)")},null,8,["label"])]),_:1},8,["modelValue"])]),_:1})]),_:1}),n(k,{md:12},{default:d(()=>[n(b,{label:i.translate("Include Categories")},{default:d(()=>[n(x,{modelValue:s.coupon.conditions.included_categories,"onUpdate:modelValue":t[14]||(t[14]=X=>s.coupon.conditions.included_categories=X),multiple:"",placeholder:i.translate("Any Category"),filterable:"",remote:"","reserve-keyword":!1},{default:d(()=>[(r(!0),h(H,null,ae(s.categories,X=>(r(),E(F,{key:X.value,label:X.label,value:X.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),n(k,{md:12},{default:d(()=>[n(b,{label:i.translate("Exclude Categories")},{default:d(()=>[n(x,{modelValue:s.coupon.conditions.excluded_categories,"onUpdate:modelValue":t[15]||(t[15]=X=>s.coupon.conditions.excluded_categories=X),multiple:"",placeholder:i.translate("No Categories"),filterable:"",remote:"","reserve-keyword":!1},{default:d(()=>[(r(!0),h(H,null,ae(s.categories,X=>(r(),E(F,{key:X.value,label:X.label,value:X.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),n(k,{md:24},{default:d(()=>[n(b,{label:i.translate("Include Products")},{default:d(()=>[n(T,{modelValue:s.coupon.conditions.included_products,"onUpdate:modelValue":t[16]||(t[16]=X=>s.coupon.conditions.included_products=X)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1}),n(k,{md:24},{default:d(()=>[n(b,{label:i.translate("Excluded Products")},{default:d(()=>[n(T,{modelValue:s.coupon.conditions.excluded_products,"onUpdate:modelValue":t[17]||(t[17]=X=>s.coupon.conditions.excluded_products=X)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1}),n(k,{md:24},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("By Email Address"),content:i.translate("List of email addresses that can use the coupon. Separate multiple emails with commas. You may also use regular expressions.")},null,8,["title","content"])]),default:d(()=>{var X;return[n(y,{autocomplete:"off",modelValue:s.coupon.conditions.email_restrictions,"onUpdate:modelValue":t[18]||(t[18]=G=>s.coupon.conditions.email_restrictions=G),type:"text",placeholder:i.translate("email1@domain.com, *@special.com, ... or regex pattern")},null,8,["modelValue","placeholder"]),(X=s.validationErrors)!=null&&X.hasOwnProperty("email_restrictions")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"email_restrictions"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(k,{md:24},{default:d(()=>{var X;return[n(b,null,{label:d(()=>[n(w,{title:i.translate("Recurring Coupon"),content:i.translate("Mark this coupon as recurring to apply it automatically to every future subscription order. This discount will automatically apply on every renewal. However, the coupon will not be applied if it reduces the payable amount to zero.")},null,8,["title","content"])]),default:d(()=>[n(U,{modelValue:s.coupon.conditions.is_recurring,"onUpdate:modelValue":t[19]||(t[19]=G=>s.coupon.conditions.is_recurring=G),label:i.translate("Make this coupon recurring"),"true-value":"yes","false-value":"no"},null,8,["modelValue","label"])]),_:1}),(X=s.validationErrors)!=null&&X.hasOwnProperty("is_recurring")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"is_recurring"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1})]),_:1})]),_:1}),n(V,null,{default:d(()=>[n(g,{title:i.translate("Maximum Discount Uses"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,{class:"pb-1.5"},{default:d(()=>[n(S,{gutter:20},{default:d(()=>[n(k,{lg:12},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("Total Limit"),content:i.translate("Total number of times this coupon can be redeemed across the entire store.")},null,8,["title","content"])]),default:d(()=>{var X,G;return[n(y,{modelValue:s.coupon.conditions.max_uses,"onUpdate:modelValue":t[20]||(t[20]=te=>s.coupon.conditions.max_uses=te),type:"number",placeholder:i.translate("Total limit"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("max_uses")?"is-error":s.usageError),min:s.minLimit,max:s.maxLimit,onInput:t[21]||(t[21]=te=>{i.onChangeCouponInput("max_uses",te)}),onKeypress:i.preventInvalidChars},null,8,["modelValue","placeholder","class","min","max","onKeypress"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("max_uses")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"max_uses"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(k,{lg:12},{default:d(()=>[n(b,null,{label:d(()=>[n(w,{title:i.translate("Per User Limit"),content:i.translate("Maximum an user can use. 0 means unlimited")},null,8,["title","content"])]),default:d(()=>[n(y,{modelValue:s.coupon.conditions.max_per_customer,"onUpdate:modelValue":t[22]||(t[22]=X=>s.coupon.conditions.max_per_customer=X),type:"number",placeholder:i.translate("Max limit per user"),class:de(s.validationErrors.hasOwnProperty("max_per_customer")?"is-error":""),min:s.minLimit,max:s.maxLimit,onInput:t[23]||(t[23]=X=>{i.onChangeCouponInput("max_per_customer",X)}),onKeypress:i.preventInvalidChars},null,8,["modelValue","placeholder","class","min","max","onKeypress"]),n(v,{"validation-errors":s.validationErrors,"field-key":"max_per_customer"},null,8,["validation-errors"])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),n(V,null,{default:d(()=>[n(g,{title:i.translate("Additional Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,{class:"pb-1.5"},{default:d(()=>[n(S,{gutter:20},{default:d(()=>[n(k,{lg:24},{default:d(()=>[n(b,{label:i.translate("Status")},{default:d(()=>[n(D,{modelValue:s.coupon.status,"onUpdate:modelValue":t[24]||(t[24]=X=>s.coupon.status=X)},{default:d(()=>[n(Q,{value:"active",label:i.translate("Active")},null,8,["label"]),n(Q,{value:"disabled",label:i.translate("Disabled")},null,8,["label"]),n(Q,{disabled:"",value:"expired",label:i.translate("Expired")},null,8,["label"])]),_:1},8,["modelValue"]),n(v,{"validation-errors":s.validationErrors,"field-key":"status"},null,8,["validation-errors"])]),_:1},8,["label"])]),_:1}),n(k,{lg:24},{default:d(()=>[n(b,{label:i.translate("Internal Notes")},{default:d(()=>{var X;return[n(y,{modelValue:s.coupon.notes,"onUpdate:modelValue":t[25]||(t[25]=G=>s.coupon.notes=G),type:"textarea",placeholder:i.translate("Enter note"),class:de((X=s.validationErrors)!=null&&X.hasOwnProperty("notes")?"is-error":"")},null,8,["modelValue","placeholder","class"]),n(v,{"validation-errors":s.validationErrors,"field-key":"notes"},null,8,["validation-errors"])]}),_:1},8,["label"])]),_:1}),n(k,{lg:24},{default:d(()=>{var X;return[n(b,null,{label:d(()=>[n(w,{title:i.translate("Stackable"),content:i.translate("Yes means the coupon can be applied with other coupons")},null,8,["title","content"])]),default:d(()=>[n(D,{modelValue:s.coupon.stackable,"onUpdate:modelValue":t[26]||(t[26]=G=>s.coupon.stackable=G)},{default:d(()=>[n(Q,{value:"yes"},{default:d(()=>[R(m(i.translate("Yes")),1)]),_:1}),n(Q,{value:"no"},{default:d(()=>[R(m(i.translate("No")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1}),(X=s.validationErrors)!=null&&X.hasOwnProperty("stackable")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"stackable"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])]),o("div",R_e,[o("div",O_e,[n(V,null,{default:d(()=>[n(g,{title:i.translate("Summary"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,null,{default:d(()=>[o("div",H_e,[s.coupon.code?(r(),h("div",P_e,[o("span",N_e,m(i.translate("Coupon code"))+": "+m(s.coupon.code),1),n(O,{text:s.coupon.code,showMode:"basic_copy_btn",tooltipText:i.translate("Copy discount code")},null,8,["text","tooltipText"])])):(r(),h("div",K_e,m(i.translate("No discount code yet")),1))]),o("div",G_e,[o("h4",j_e,m(i.translate("Type & Method")),1),o("ul",z_e,[o("li",null,[o("span",null,m(i.translate("Amount off Products")),1)]),o("li",null,[o("span",null,m(i.translate("Code")),1)])])]),o("div",q_e,[o("h4",Y_e,m(i.translate("Details")),1),o("ul",W_e,[o("li",null,[o("span",null,m(i.translate("For Online Store")),1)]),o("li",null,[o("span",null,m(i.translate("No Min Purchase Requirement")),1)]),o("li",null,[o("span",null,m(i.translate("All Customers")),1)])])])]),_:1})]),_:1}),n(V,null,{default:d(()=>[n(g,{title:i.translate("Schedule"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,{class:"pb-1.5"},{default:d(()=>[n(I,{"label-position":"top"},{default:d(()=>[n(S,{gutter:20},{default:d(()=>[n(k,{lg:24},{default:d(()=>[n(b,{label:i.translate("Start Date & Time")},{default:d(()=>[n(L,{modelValue:s.coupon.start_date,"onUpdate:modelValue":t[27]||(t[27]=X=>s.coupon.start_date=X),type:"datetime","value-format":"YYYY-MM-DDTHH:mm:ssZ",placeholder:i.translate("Start date & time"),onChange:i.setDefaultStatus,"disabled-date":i.disabledStartDate},null,8,["modelValue","placeholder","onChange","disabled-date"])]),_:1},8,["label"])]),_:1}),n(k,{lg:24},{default:d(()=>[n(b,null,{default:d(()=>[n(U,{modelValue:s.isEndDateEnabled,"onUpdate:modelValue":t[28]||(t[28]=X=>s.isEndDateEnabled=X),label:i.translate("Set end date & time"),onChange:t[29]||(t[29]=X=>{X||(s.coupon.end_date=null)})},null,8,["modelValue","label"])]),_:1})]),_:1}),s.isEndDateEnabled?(r(),E(k,{key:0,lg:24},{default:d(()=>[n(b,{label:i.translate("End Date & Time")},{default:d(()=>[n(L,{modelValue:s.coupon.end_date,"onUpdate:modelValue":t[30]||(t[30]=X=>s.coupon.end_date=X),type:"datetime","value-format":"YYYY-MM-DDTHH:mm:ssZ",placeholder:i.translate("End date & time"),onChange:i.setDefaultStatus,"disabled-date":i.disabledEndDate},null,8,["modelValue","placeholder","onChange","disabled-date"]),s.validationErrors.hasOwnProperty("end_date")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"end_date"},null,8,["validation-errors"])):B("",!0)]),_:1},8,["label"])]),_:1})):B("",!0)]),_:1})]),_:1})]),_:1})]),_:1})]),s.showDynamicTemplates?(r(),h("div",J_e,[n(P,{filter:"fluent_cart_single_coupon_page",ref:"dynamic_templates",data:{coupon:s.coupon},widgetsQuery:{coupon_id:s.coupon.id},onChange:i.handleChangesMade},null,8,["data","widgetsQuery","onChange"])])):B("",!0),n(V,null,{default:d(()=>[n(g,{title:i.translate("Activity"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,null,{default:d(()=>[n(q,{onReload:i.fetchCoupon,activities:s.coupon.activities||[],showManageActivity:s.showManageActivity},null,8,["onReload","activities","showManageActivity"])]),_:1})]),_:1})])])])],64))])}const Z_e=lt(x_e,[["render",X_e]]),eve={name:"CheckoutFields",components:{Animation:va,CardHeader:Qe,Card:Be,CardBody:Ce,SettingsHeader:Qa,AdminNotice:Da},data(){return{fields:{},settings:{},saving:!1,fetching:!1}},watch:{"settings.basic_info.last_name.enabled"(e){var t,a;e==="yes"&&((a=(t=this.settings.basic_info)==null?void 0:t.first_name)==null?void 0:a.enabled)==="no"&&(this.settings.basic_info.first_name.enabled="yes")},"settings.business_details":{deep:!0,handler(e){var a,l,s;if(!e||!e.b2b_only_mode)return;((a=e.company_name)==null?void 0:a.enabled)==="yes"||((l=e.vat_number)==null?void 0:l.enabled)==="yes"||((s=e.legal_registration_id)==null?void 0:s.enabled)==="yes"||(e.b2b_only_mode.enabled="no")}}},mounted(){this.getFields()},methods:{translate:u,isFirstNameDisabled(e,t){var a,l;return e==="basic_info"&&t==="first_name"&&((l=(a=this.settings.basic_info)==null?void 0:a.last_name)==null?void 0:l.enabled)==="yes"},isB2BOnlyModeDisabled(e,t){var l,s,i;if(e!=="business_details"||t!=="b2b_only_mode")return!1;const a=this.settings.business_details||{};return((l=a.company_name)==null?void 0:l.enabled)!=="yes"&&((s=a.vat_number)==null?void 0:s.enabled)!=="yes"&&((i=a.legal_registration_id)==null?void 0:i.enabled)!=="yes"},shouldDimLabel(e,t){var a,l,s,i,c,p,f;return((s=(l=(a=this.settings)==null?void 0:a[e])==null?void 0:l[t])==null?void 0:s.enabled)==="no"?!0:e==="basic_info"&&t==="full_name"?((c=(i=this.settings.basic_info)==null?void 0:i.first_name)==null?void 0:c.enabled)==="yes"||((f=(p=this.settings.basic_info)==null?void 0:p.last_name)==null?void 0:f.enabled)==="yes":!1},isVisible(e,t){var a,l,s,i;return t==="full_name"?((l=(a=this.settings.basic_info)==null?void 0:a.first_name)==null?void 0:l.enabled)!=="yes"&&((i=(s=this.settings.basic_info)==null?void 0:s.last_name)==null?void 0:i.enabled)!=="yes":!0},getFields(){this.fetching=!0,this.$get("checkout-fields/get-fields").then(e=>{this.fields=e.fields||{},this.settings=e.settings||{}}).catch(e=>{this.handleError(e)}).finally(()=>{this.fetching=!1})},saveFields(){this.saving=!0,this.$post("checkout-fields/save-fields",{settings:this.settings}).then(e=>{this.$notify.success(e.message||this.$t("Settings saved successfully!")),this.getFields()}).catch(e=>{this.handleError(e)}).finally(()=>{this.saving=!1})},formatSectionTitle(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}}},tve={class:"setting-wrap"},ave={class:"setting-wrap-inner"},lve={class:"fct-checkout-fields-wrapp"},sve={class:"field-heading"},nve={class:"fct-checkout-fields"},ove={key:0,class:"fct-checkout-field"},ive={class:"fct-checkout-field-info"},rve={class:"fct-checkout-field-label-wrap"},dve={class:"fct-checkout-field-tags"},uve={key:0,class:"fct-checkout-field-info-desc"},cve={key:0,class:"fct-checkout-field-action"},Ave={key:1,class:"fct-checkout-field-input"},pve={class:"fct-checkout-field-info"},fve={class:"fct-checkout-field-label-wrap"},mve={key:1,class:"fct-checkout-field-tags"},hve={key:0,class:"fct-checkout-field-info-desc"},_ve={key:0,class:"fct-checkout-field-action"},vve={class:"form-section-save-action"};function gve(e,t,a,l,s,i){const c=C("SettingsHeader"),p=C("AdminNotice"),f=C("el-skeleton"),_=C("el-switch"),g=C("el-tag"),y=C("el-checkbox"),v=C("el-input"),b=C("CardBody"),k=C("Card"),w=C("el-button");return r(),h("div",tve,[n(c,{heading:i.translate("Checkout Fields"),loading:s.saving,onOnSave:i.saveFields},null,8,["heading","loading","onOnSave"]),o("div",ave,[n(p),o("div",lve,[n(k,null,{default:d(()=>[n(b,null,{default:d(()=>[n(f,{loading:s.fetching,animated:"",rows:5},null,8,["loading"]),s.fetching?B("",!0):(r(!0),h(H,{key:0},ae(s.fields,(S,$)=>(r(),h("div",{key:$,class:"fct-checkout-field-section"},[o("h3",sve,m(i.formatSectionTitle($)),1),o("div",nve,[S.label?(r(),h("div",ove,[o("div",ive,[o("div",rve,[S.can_alter==="yes"?(r(),E(_,{key:0,modelValue:s.settings[$].enabled,"onUpdate:modelValue":V=>s.settings[$].enabled=V,"active-value":"yes","inactive-value":"no"},null,8,["modelValue","onUpdate:modelValue"])):B("",!0),o("span",{class:de(`fct-checkout-field-label ${s.settings[$].enabled==="no"?"opacity-50":""}`)},m(S.label),3),o("div",dve,[S.can_alter!=="yes"&&s.settings[$].enabled==="yes"?(r(),E(g,{key:0,size:"small"},{default:d(()=>[R(m(i.translate("System")),1)]),_:1})):B("",!0),s.settings[$].required==="yes"&&s.settings[$].enabled==="yes"?(r(),E(g,{key:1,size:"small"},{default:d(()=>[R(m(i.translate("Required")),1)]),_:1})):B("",!0)])]),S.help_text?(r(),h("div",uve,m(S.help_text),1)):B("",!0)]),S.can_alter==="yes"?(r(),h("div",cve,[n(y,{modelValue:s.settings[$].required,"onUpdate:modelValue":V=>s.settings[$].required=V,"true-label":"yes","false-label":"no",disabled:s.settings[$].enabled!=="yes"},{default:d(()=>[R(m(i.translate("Required")),1)]),_:2},1032,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0),s.settings[$].hasOwnProperty("text")&&s.settings[$].enabled==="yes"?(r(),h("div",Ave,[n(v,{type:"textarea",modelValue:s.settings[$].text,"onUpdate:modelValue":V=>s.settings[$].text=V,disabled:s.settings[$].enabled!=="yes"},null,8,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0)])):(r(!0),h(H,{key:1},ae(S,(V,F)=>(r(),h("div",{key:F,class:"fct-checkout-field"},[o("div",pve,[o("div",fve,[V.can_alter==="yes"?(r(),E(_,{key:0,modelValue:s.settings[$][F].enabled,"onUpdate:modelValue":x=>s.settings[$][F].enabled=x,"active-value":"yes","inactive-value":"no",disabled:i.isFirstNameDisabled($,F)||i.isB2BOnlyModeDisabled($,F)},null,8,["modelValue","onUpdate:modelValue","disabled"])):B("",!0),o("span",{class:de(["fct-checkout-field-label",i.shouldDimLabel($,F)?"opacity-50":""])},m(V.label),3),i.isVisible(V,F)?(r(),h("div",mve,[V.can_alter!=="yes"&&s.settings[$][F].enabled==="yes"?(r(),E(g,{key:0,size:"small"},{default:d(()=>[R(m(i.translate("System")),1)]),_:1})):B("",!0),s.settings[$][F].required==="yes"&&s.settings[$][F].enabled==="yes"?(r(),E(g,{key:1,size:"small"},{default:d(()=>[R(m(i.translate("Required")),1)]),_:1})):B("",!0)])):B("",!0)]),V.help_text?(r(),h("div",hve,m(V.help_text),1)):B("",!0)]),V.can_alter==="yes"&&F!=="first_name"&&F!=="b2b_only_mode"?(r(),h("div",_ve,[n(y,{modelValue:s.settings[$][F].required,"onUpdate:modelValue":x=>s.settings[$][F].required=x,"true-label":"yes","false-label":"no",disabled:s.settings[$][F].enabled!=="yes"},{default:d(()=>[R(m(i.translate("Required")),1)]),_:2},1032,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0)]))),128))])]))),128))]),_:1})]),_:1}),o("div",vve,[n(w,{type:"primary",onClick:i.saveFields,loading:s.saving},{default:d(()=>[R(m(i.translate("Save")),1)]),_:1},8,["onClick","loading"])])])])])}const yve=lt(eve,[["render",gve]]);var So={exports:{}};/* @license
Papa Parse
v5.5.3
https://github.com/mholt/PapaParse
License: MIT
*/var bve=So.exports,vc;function wve(){return vc||(vc=1,function(e,t){((a,l)=>{e.exports=l()})(bve,function a(){var l=typeof self<"u"?self:typeof window<"u"?window:l!==void 0?l:{},s,i=!l.document&&!!l.postMessage,c=l.IS_PAPA_WORKER||!1,p={},f=0,_={};function g(U){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(I){var O=Q(I);O.chunkSize=parseInt(O.chunkSize),I.step||I.chunk||(O.chunkSize=null),this._handle=new w(O),(this._handle.streamer=this)._config=O}).call(this,U),this.parseChunk=function(I,O){var L=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0=this._config.preview),c)l.postMessage({results:P,workerId:_.WORKER_ID,finished:L});else if(T(this._config.chunk)&&!O){if(this._config.chunk(P,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=P=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(P.data),this._completeResults.errors=this._completeResults.errors.concat(P.errors),this._completeResults.meta=P.meta),this._completed||!L||!T(this._config.complete)||P&&P.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),L||P&&P.meta.paused||this._nextChunk(),P}this._halted=!0},this._sendError=function(I){T(this._config.error)?this._config.error(I):c&&this._config.error&&l.postMessage({workerId:_.WORKER_ID,error:I,finished:!1})}}function y(U){var I;(U=U||{}).chunkSize||(U.chunkSize=_.RemoteChunkSize),g.call(this,U),this._nextChunk=i?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(O){this._input=O,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(I=new XMLHttpRequest,this._config.withCredentials&&(I.withCredentials=this._config.withCredentials),i||(I.onload=D(this._chunkLoaded,this),I.onerror=D(this._chunkError,this)),I.open(this._config.downloadRequestBody?"POST":"GET",this._input,!i),this._config.downloadRequestHeaders){var O,L=this._config.downloadRequestHeaders;for(O in L)I.setRequestHeader(O,L[O])}var P;this._config.chunkSize&&(P=this._start+this._config.chunkSize-1,I.setRequestHeader("Range","bytes="+this._start+"-"+P));try{I.send(this._config.downloadRequestBody)}catch(q){this._chunkError(q.message)}i&&I.status===0&&this._chunkError()}},this._chunkLoaded=function(){I.readyState===4&&(I.status<200||400<=I.status?this._chunkError():(this._start+=this._config.chunkSize||I.responseText.length,this._finished=!this._config.chunkSize||this._start>=(O=>(O=O.getResponseHeader("Content-Range"))!==null?parseInt(O.substring(O.lastIndexOf("/")+1)):-1)(I),this.parseChunk(I.responseText)))},this._chunkError=function(O){O=I.statusText||O,this._sendError(new Error(O))}}function v(U){(U=U||{}).chunkSize||(U.chunkSize=_.LocalChunkSize),g.call(this,U);var I,O,L=typeof FileReader<"u";this.stream=function(P){this._input=P,O=P.slice||P.webkitSlice||P.mozSlice,L?((I=new FileReader).onload=D(this._chunkLoaded,this),I.onerror=D(this._chunkError,this)):I=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(P.target.result)},this._chunkError=function(){this._sendError(I.error)}}function b(U){var I;g.call(this,U=U||{}),this.stream=function(O){return I=O,this._nextChunk()},this._nextChunk=function(){var O,L;if(!this._finished)return O=this._config.chunkSize,I=O?(L=I.substring(0,O),I.substring(O)):(L=I,""),this._finished=!I,this.parseChunk(L)}}function k(U){g.call(this,U=U||{});var I=[],O=!0,L=!1;this.pause=function(){g.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){g.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(P){this._input=P,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){L&&I.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),I.length?this.parseChunk(I.shift()):O=!0},this._streamData=D(function(P){try{I.push(typeof P=="string"?P:P.toString(this._config.encoding)),O&&(O=!1,this._checkIsFinished(),this.parseChunk(I.shift()))}catch(q){this._streamError(q)}},this),this._streamError=D(function(P){this._streamCleanUp(),this._sendError(P)},this),this._streamEnd=D(function(){this._streamCleanUp(),L=!0,this._streamData("")},this),this._streamCleanUp=D(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function w(U){var I,O,L,P,q=Math.pow(2,53),X=-q,G=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,te=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,ne=this,re=0,K=0,Y=!1,W=!1,j=[],ie={data:[],errors:[],meta:{}};function he(fe){return U.skipEmptyLines==="greedy"?fe.join("").trim()==="":fe.length===1&&fe[0].length===0}function me(){if(ie&&L&&(se("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+_.DefaultDelimiter+"'"),L=!1),U.skipEmptyLines&&(ie.data=ie.data.filter(function(ve){return!he(ve)})),ye()){let ve=function(Je,vt){T(U.transformHeader)&&(Je=U.transformHeader(Je,vt)),j.push(Je)};if(ie)if(Array.isArray(ie.data[0])){for(var fe=0;ye()&&fe(gt=>(U.dynamicTypingFunction&&U.dynamicTyping[gt]===void 0&&(U.dynamicTyping[gt]=U.dynamicTypingFunction(gt)),(U.dynamicTyping[gt]||U.dynamicTyping)===!0))(Oe)?Me==="true"||Me==="TRUE"||Me!=="false"&&Me!=="FALSE"&&((gt=>{if(G.test(gt)&&(gt=parseFloat(gt),X=j.length?"__parsed_extra":j[Ye]:xe,Ee=U.transform?U.transform(Ee,xe):Ee);xe==="__parsed_extra"?(vt[xe]=vt[xe]||[],vt[xe].push(Ee)):vt[xe]=Ee}return U.header&&(Ye>j.length?se("FieldMismatch","TooManyFields","Too many fields: expected "+j.length+" fields but parsed "+Ye,K+Je):YeU.preview?O.abort():(ie.data=ie.data[0],P(ie,ne))))}),this.parse=function(fe,$e,tt){var ve=U.quoteChar||'"',ve=(U.newline||(U.newline=this.guessLineEndings(fe,ve)),L=!1,U.delimiter?T(U.delimiter)&&(U.delimiter=U.delimiter(fe),ie.meta.delimiter=U.delimiter):((ve=((Je,vt,Ye,xe,Ee)=>{var Oe,Me,gt,yt;Ee=Ee||[","," ","|",";",_.RECORD_SEP,_.UNIT_SEP];for(var Mt=0;Mt=tt.length/2?`\r
`:"\r"}}function S(U){return U.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $(U){var I=(U=U||{}).delimiter,O=U.newline,L=U.comments,P=U.step,q=U.preview,X=U.fastMode,G=null,te=!1,ne=U.quoteChar==null?'"':U.quoteChar,re=ne;if(U.escapeChar!==void 0&&(re=U.escapeChar),(typeof I!="string"||-1<_.BAD_DELIMITERS.indexOf(I))&&(I=","),L===I)throw new Error("Comment character same as delimiter");L===!0?L="#":(typeof L!="string"||-1<_.BAD_DELIMITERS.indexOf(L))&&(L=!1),O!==`
`&&O!=="\r"&&O!==`\r
`&&(O=`
`);var K=0,Y=!1;this.parse=function(W,j,ie){if(typeof W!="string")throw new Error("Input must be a string");var he=W.length,me=I.length,ye=O.length,se=L.length,fe=T(P),$e=[],tt=[],ve=[],Je=K=0;if(!W)return ht();if(X||X!==!1&&W.indexOf(ne)===-1){for(var vt=W.split(O),Ye=0;Ye=q)return ht(!0);break}tt.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:$e.length,index:K}),Me++}}else if(L&&ve.length===0&&W.substring(K,K+se)===L){if(Ee===-1)return ht();K=Ee+ye,Ee=W.indexOf(O,K),xe=W.indexOf(I,K)}else if(xe!==-1&&(xe=q)return ht(!0)}return Ut();function yt(Ct){$e.push(Ct),Je=K}function Mt(Ct){var St=0;return St=Ct!==-1&&(Ct=W.substring(Me+1,Ct))&&Ct.trim()===""?Ct.length:St}function Ut(Ct){return ie||(Ct===void 0&&(Ct=W.substring(K)),ve.push(Ct),K=he,yt(ve),fe&&Pt()),ht()}function Dt(Ct){K=Ct,yt(ve),ve=[],Ee=W.indexOf(O,K)}function ht(Ct){if(U.header&&!j&&$e.length&&!te){var St=$e[0],Ot=Object.create(null),Ht=new Set(St);let It=!1;for(let mt=0;mtL.charCodeAt(0)!==65279?L:L.slice(1))(U),O=new(I.download?y:b)(I)):U.readable===!0&&T(U.read)&&T(U.on)?O=new k(I):(l.File&&U instanceof File||U instanceof Object)&&(O=new v(I)),O.stream(U);(O=(()=>{var L;return!!_.WORKERS_SUPPORTED&&(L=(()=>{var P=l.URL||l.webkitURL||null,q=a.toString();return _.BLOB_URL||(_.BLOB_URL=P.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",q,")();"],{type:"text/javascript"})))})(),(L=new l.Worker(L)).onmessage=V,L.id=f++,p[L.id]=L)})()).userStep=I.step,O.userChunk=I.chunk,O.userComplete=I.complete,O.userError=I.error,I.step=T(I.step),I.chunk=T(I.chunk),I.complete=T(I.complete),I.error=T(I.error),delete I.worker,O.postMessage({input:U,config:I,workerId:O.id})},_.unparse=function(U,I){var O=!1,L=!0,P=",",q=`\r
`,X='"',G=X+X,te=!1,ne=null,re=!1,K=((()=>{if(typeof I=="object"){if(typeof I.delimiter!="string"||_.BAD_DELIMITERS.filter(function(j){return I.delimiter.indexOf(j)!==-1}).length||(P=I.delimiter),typeof I.quotes!="boolean"&&typeof I.quotes!="function"&&!Array.isArray(I.quotes)||(O=I.quotes),typeof I.skipEmptyLines!="boolean"&&typeof I.skipEmptyLines!="string"||(te=I.skipEmptyLines),typeof I.newline=="string"&&(q=I.newline),typeof I.quoteChar=="string"&&(X=I.quoteChar),typeof I.header=="boolean"&&(L=I.header),Array.isArray(I.columns)){if(I.columns.length===0)throw new Error("Option columns is empty");ne=I.columns}I.escapeChar!==void 0&&(G=I.escapeChar+X),I.escapeFormulae instanceof RegExp?re=I.escapeFormulae:typeof I.escapeFormulae=="boolean"&&I.escapeFormulae&&(re=/^[=+\-@\t\r].*$/)}})(),new RegExp(S(X),"g"));if(typeof U=="string"&&(U=JSON.parse(U)),Array.isArray(U)){if(!U.length||Array.isArray(U[0]))return Y(null,U,te);if(typeof U[0]=="object")return Y(ne||Object.keys(U[0]),U,te)}else if(typeof U=="object")return typeof U.data=="string"&&(U.data=JSON.parse(U.data)),Array.isArray(U.data)&&(U.fields||(U.fields=U.meta&&U.meta.fields||ne),U.fields||(U.fields=Array.isArray(U.data[0])?U.fields:typeof U.data[0]=="object"?Object.keys(U.data[0]):[]),Array.isArray(U.data[0])||typeof U.data[0]=="object"||(U.data=[U.data])),Y(U.fields||[],U.data||[],te);throw new Error("Unable to serialize unrecognized input");function Y(j,ie,he){var me="",ye=(typeof j=="string"&&(j=JSON.parse(j)),typeof ie=="string"&&(ie=JSON.parse(ie)),Array.isArray(j)&&0{for(var fe=0;feJ7(G,k.thousand),S=G=>{G&&gc.parse(G,{header:!0,complete:function(te){p.value=te.data,c.value=te.meta.fields,g.value=c.value.includes("Type")&&c.value.includes("Parent"),V(),g.value&&Q(),b.value=!0}})},$=()=>{_.value={},c.value=[],p.value=[],b.value=!1,g.value=!1},V=()=>{const G=[],te=[];let ne=0;c.value.forEach(re=>{let K=null,Y=null;const W=re.toString();for(const[j,ie]of y.entries())if(W.toLocaleLowerCase().startsWith(ie)){const he=re.toString().match(/ \d+ /g);if(Array.isArray(he)&&he.length===1){let me=he[0];ne=me>ne?me:ne,K=re.toString().replace(he[0]," %d "),Y=re.toString().replace(he[0]," ");break}}K!=null?G.includes(K)||(G.push(K),te.push({title:Y,value:K})):te.push({title:re,value:re})}),_.value=te,v=ne},F=()=>window.fluentCartRestVars.rest.url+"/files/upload",x={post_id:["ID"],post_title:["Name"],post_name:["SKU"],post_content:["description","Description"],post_excerpt:["Short description","Short Description"],post_status:["Published"],comment_status:["Allow customer reviews?"],item_price:["Regular price","Meta: _subscription_price"],compare_price:["Sale price"],images:["Images"],categories:["Categories"],sku:["SKU"],payment_type:["Payment Type"],repeat_interval:["Subscription Interval","Meta: _subscription_period"],trial_days:["Trial Days","Meta: _subscription_trial_length"],installment:["Installment"],installment_count:["Installment Count"],manage_setup_fee:["Setup Fee"],signup_fee_name:["Setup Fee Name"],signup_fee:["Setup Fee Amount","Meta: _subscription_sign_up_fee"]},Q=()=>{for(const[G,te]of Object.entries(x))if(f.value[G]){for(const ne of te)if(c.value.includes(ne)){f.value[G].value=ne;break}}},D=G=>G?{day:"daily",week:"weekly",month:"monthly",year:"yearly"}[G.trim().toLowerCase()]||G:"",T=G=>{if(!G)return"";const te=G.split(",").map(ne=>ne.trim().toLowerCase());return te.includes("variation")?"variation":te.includes("variable")?"variable":te.includes("subscription")?"subscription":te.includes("simple")?"simple":te[0]||""},U=(G=!0)=>{const te=[],ne={},re=f.value,K={description:"",payment_type:"onetime",times:"",repeat_interval:"",trial_days:"",billing_summary:"",manage_setup_fee:"no",signup_fee_name:"",signup_fee:"",setup_fee_per_item:"no"},Y=j=>{const ie=[];for(let he=1;he<=10;he++){const me=`Attribute ${he} name`,ye=`Attribute ${he} value(s)`;j[me]&&j[ye]&&ie.push(j[ye])}return ie.join(" - ")},W=j=>j==="1"||j===1?"published":j==="0"||j===0?"draft":j||"published";p.value.forEach(j=>{var tt,ve,Je,vt,Ye,xe,Ee,Oe,Me,gt,yt,Mt,Ut,Dt,ht,Pt,Ct,St,Ot,Ht;const ie=T(j.Type);if(ie!=="simple"&&ie!=="variable"&&ie!=="subscription")return;const he={};he._cid=Al(),he.post_title=j[(tt=re.post_title)==null?void 0:tt.value]||"",he.post_name=j[(ve=re.post_name)==null?void 0:ve.value]||he.post_title,he.ID=j[(Je=re.post_id)==null?void 0:Je.value]||"",he.post_content=j[(vt=re.post_content)==null?void 0:vt.value]||"",he.post_excerpt=j[(Ye=re.post_excerpt)==null?void 0:Ye.value]||"",he.post_status=W(j[(xe=re.post_status)==null?void 0:xe.value]);const me={variation_type:ie==="variable"?"simple_variations":"simple",manage_stock:"0",fulfillment_type:"physical"},ye=j[(Ee=re.images)==null?void 0:Ee.value]||"",se=[];ye&&ye.split(",").map(It=>It.trim()).filter(Boolean).forEach(It=>{const mt=It.split("/").pop().split("?")[0]||"image";se.push({id:0,url:It,title:mt})}),he.detail=me,he.gallery=se,he.variants=[];const fe=j[(Oe=re.categories)==null?void 0:Oe.value]||"";if(fe?he.categories=fe.split(",").map(It=>It.trim()).filter(Boolean):he.categories=[],ie==="simple"||ie==="subscription"){const It=w(j[(Me=re.item_price)==null?void 0:Me.value]||""),mt=w(j[(gt=re.compare_price)==null?void 0:gt.value]||""),jt=j[(yt=re.sku)==null?void 0:yt.value]||"",ge=ie==="subscription"?"subscription":j[(Mt=re.payment_type)==null?void 0:Mt.value]||"onetime",Fe=D(j[(Ut=re.repeat_interval)==null?void 0:Ut.value]||""),nt=j[(Dt=re.trial_days)==null?void 0:Dt.value]||"",bt=j[(ht=re.installment)==null?void 0:ht.value]||"",Bt=j[(Pt=re.installment_count)==null?void 0:Pt.value]||"",Wt=j[(Ct=re.manage_setup_fee)==null?void 0:Ct.value]||"",_t=j[(St=re.signup_fee_name)==null?void 0:St.value]||"",la=w(j[(Ot=re.signup_fee)==null?void 0:Ot.value]||"");(It||he.post_title)&&he.variants.push({_cid:Al(),variation_title:he.post_title,sku:jt,item_price:It,compare_price:mt,other_info:{...K,payment_type:ge,repeat_interval:Fe,trial_days:nt,installment:bt==="yes"?"yes":"no",times:Bt,manage_setup_fee:Wt==="yes"?"yes":"no",signup_fee_name:_t,signup_fee:la},media:[]})}const $e=j[(Ht=re.sku)==null?void 0:Ht.value]||"";ie==="variable"&&$e&&(ne[$e]=he),te.push(he)}),p.value.forEach(j=>{var gt,yt,Mt,Ut,Dt,ht,Pt,Ct,St,Ot,Ht,It;if(T(j.Type)!=="variation")return;const ie=j.Parent;if(!ie||!ne[ie])return;const he=Y(j),me=w(j[(gt=re.item_price)==null?void 0:gt.value]||""),ye=w(j[(yt=re.compare_price)==null?void 0:yt.value]||""),se=j[(Mt=re.images)==null?void 0:Mt.value]||"",fe=[];se&&se.split(",").map(mt=>mt.trim()).filter(Boolean).forEach(mt=>{const jt=mt.split("/").pop().split("?")[0]||"image";fe.push({id:0,url:mt,title:jt})});const $e=j[(Ut=re.sku)==null?void 0:Ut.value]||"",tt=j[(Dt=re.payment_type)==null?void 0:Dt.value]||"onetime",ve=D(j[(ht=re.repeat_interval)==null?void 0:ht.value]||""),Je=j[(Pt=re.trial_days)==null?void 0:Pt.value]||"",vt=j[(Ct=re.installment)==null?void 0:Ct.value]||"",Ye=j[(St=re.installment_count)==null?void 0:St.value]||"",xe=j[(Ot=re.manage_setup_fee)==null?void 0:Ot.value]||"",Ee=j[(Ht=re.signup_fee_name)==null?void 0:Ht.value]||"",Oe=w(j[(It=re.signup_fee)==null?void 0:It.value]||""),Me={_cid:Al(),variation_title:he||j.Name||"",sku:$e,item_price:me,compare_price:ye,other_info:{...K,payment_type:tt,repeat_interval:ve,trial_days:Je,installment:vt==="yes"?"yes":"no",times:Ye,manage_setup_fee:xe==="yes"?"yes":"no",signup_fee_name:Ee,signup_fee:Oe},media:fe};ne[ie].variants.push(Me)}),X("onDataPopulated",{products:te,concat:G})},I=(G=!0)=>{if(g.value)return U(G);const te=[];p.value.forEach(ne=>{var Ye,xe,Ee,Oe,Me,gt,yt,Mt,Ut,Dt,ht,Pt;const re={};re._cid=Al();const K=f.value;re.post_title=ne[K.post_title.value]??"",re.post_name=ne[K.post_name.value]??re.post_title,re.ID=ne[K.post_id.value]??"",re.post_content=ne[K.post_content.value]??"",re.post_excerpt=ne[K.post_excerpt.value]??"",re.post_status=ne[(Ye=K.post_status)==null?void 0:Ye.value]||"published",re.comment_status="close";const Y=ne[(xe=K.images)==null?void 0:xe.value]||"",W=[];Y&&Y.split(",").map(Ct=>Ct.trim()).filter(Boolean).forEach(Ct=>{const St=Ct.split("/").pop().split("?")[0]||"image";W.push({id:0,url:Ct,title:St})});const j=ne[(Ee=K.categories)==null?void 0:Ee.value]||"";j?re.categories=j.split(",").map(Ct=>Ct.trim()).filter(Boolean):re.categories=[];const ie=ne[(Oe=K.sku)==null?void 0:Oe.value]||"",he=ne[(Me=K.payment_type)==null?void 0:Me.value]||"onetime",me=ne[(gt=K.repeat_interval)==null?void 0:gt.value]||"",ye=ne[(yt=K.trial_days)==null?void 0:yt.value]||"",se=ne[(Mt=K.installment)==null?void 0:Mt.value]||"",fe=ne[(Ut=K.installment_count)==null?void 0:Ut.value]||"",$e=ne[(Dt=K.manage_setup_fee)==null?void 0:Dt.value]||"",tt=ne[(ht=K.signup_fee_name)==null?void 0:ht.value]||"",ve=w(ne[(Pt=K.signup_fee)==null?void 0:Pt.value]||""),Je={variation_type:"simple",manage_stock:"0",fulfillment_type:"physical"},vt={description:"",payment_type:he,times:fe,repeat_interval:me,trial_days:ye,billing_summary:"",manage_setup_fee:$e==="yes"?"yes":"no",signup_fee_name:tt,signup_fee:ve,setup_fee_per_item:"no",installment:se==="yes"?"yes":"no"};re.gallery=W,re.variants=[];for(let Ct=1;Ct<=v;Ct++){const St={};["variation_title","item_price","compare_price"].forEach(Ot=>{var It;const Ht=((It=K[Ot])==null?void 0:It.value)??"";if(Ht.length>0){const mt=Ht.replace("%d",Ct.toString()),jt=ne[mt];St[Ot]=Ot==="variation_title"?jt:w(jt)}}),P(St)&&(St._cid=Al(),St.sku=ie,St.other_info={...vt},St.media=[],re.variants.push(St))}re.variants.length>0?(Je.variation_type="simple_variations",re.detail=Je,te.push(re)):P(re)&&(re.variants.push({_cid:Al(),variation_title:"",sku:ie,item_price:0,compare_price:0,other_info:{...vt},media:[]}),re.detail=Je,te.push(re))}),X("onDataPopulated",{products:te,concat:G})},O=()=>{l.value=!1,s.value=[],i.value=null,$()},L=(G=!0)=>{I(G),O()},P=G=>{let te=!1;for(const[ne,re]of Object.entries(G))if(typeof re!==null&&typeof re<"u"&&(Array.isArray(re)&&re.length>0||re.toString().length>0)){te=!0;break}return te};Ie(()=>{f.value={post_id:{title:a.$t("Post ID"),value:""},post_title:{title:a.$t("Post Title"),value:""},post_name:{title:a.$t("Post Name"),value:""},post_content:{title:a.$t("Post Content"),value:""},post_excerpt:{title:a.$t("Post Excerpt"),value:""},post_status:{title:a.$t("Post Status"),value:""},post_date:{title:a.$t("Post Date"),value:""},comment_status:{title:a.$t("Comment Status"),value:""},images:{title:a.$t("Images"),value:""},variation_title:{title:a.$t("Variation Title"),value:""},item_price:{title:a.$t("Variation Price"),value:""},compare_price:{title:a.$t("Variation Compare Price"),value:""},sku:{title:a.$t("SKU"),value:""},categories:{title:a.$t("Categories"),value:""},payment_type:{title:a.$t("Payment Type"),value:""},repeat_interval:{title:a.$t("Subscription Interval"),value:""},trial_days:{title:a.$t("Trial Days"),value:""},installment:{title:a.$t("Installment"),value:""},installment_count:{title:a.$t("Installment Count"),value:""},manage_setup_fee:{title:a.$t("Setup Fee"),value:""},signup_fee_name:{title:a.$t("Setup Fee Name"),value:""},signup_fee:{title:a.$t("Setup Fee Amount"),value:""}}});const q=()=>{const G=[{ID:"",Type:"simple",SKU:"BASIC-TEE-001",Name:"Classic Cotton T-Shirt",Published:1,"Short description":"Comfortable everyday cotton tee",description:"Made from 100% organic cotton. Pre-shrunk and machine washable.",Categories:"Clothing, Clothing > T-Shirts",Images:"https://example.com/images/tee-front.jpg, https://example.com/images/tee-back.jpg",Parent:"","Regular price":"29.99","Sale price":"24.99","Attribute 1 name":"","Attribute 1 value(s)":"","Payment Type":"onetime","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"simple",SKU:"STARTER-PLAN",Name:"Starter Membership Plan",Published:1,"Short description":"Monthly access to premium content",description:"Get access to all premium tutorials and resources. Cancel anytime.",Categories:"Memberships",Images:"",Parent:"","Regular price":"9.99","Sale price":"","Attribute 1 name":"","Attribute 1 value(s)":"","Payment Type":"subscription","Subscription Interval":"monthly","Trial Days":"14",Installment:"","Installment Count":"","Setup Fee":"yes","Setup Fee Name":"Activation Fee","Setup Fee Amount":"4.99"},{ID:"",Type:"simple",SKU:"PRO-YEARLY",Name:"Pro Annual Plan",Published:1,"Short description":"12-month installment plan",description:"Pay in 12 monthly installments for annual access to all pro features.",Categories:"Memberships",Images:"",Parent:"","Regular price":"19.99","Sale price":"","Attribute 1 name":"","Attribute 1 value(s)":"","Payment Type":"subscription","Subscription Interval":"monthly","Trial Days":"",Installment:"yes","Installment Count":"12","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"variable",SKU:"HOODIE-PREMIUM",Name:"Premium Zip Hoodie",Published:1,"Short description":"Heavyweight zip-up hoodie",description:"Premium quality hoodie with YKK zipper. Available in multiple colors.",Categories:"Clothing, Clothing > Hoodies",Images:"https://example.com/images/hoodie-main.jpg, https://example.com/images/hoodie-side.jpg, https://example.com/images/hoodie-detail.jpg",Parent:"","Regular price":"","Sale price":"","Attribute 1 name":"","Attribute 1 value(s)":"","Payment Type":"","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"variation",SKU:"HOODIE-BLK",Name:"",Published:1,"Short description":"",description:"",Categories:"",Images:"https://example.com/images/hoodie-black.jpg",Parent:"HOODIE-PREMIUM","Regular price":"59.99","Sale price":"","Attribute 1 name":"Color","Attribute 1 value(s)":"Black","Payment Type":"","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"variation",SKU:"HOODIE-WHT",Name:"",Published:1,"Short description":"",description:"",Categories:"",Images:"",Parent:"HOODIE-PREMIUM","Regular price":"59.99","Sale price":"","Attribute 1 name":"Color","Attribute 1 value(s)":"White","Payment Type":"","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""},{ID:"",Type:"variation",SKU:"HOODIE-BLU-LE",Name:"",Published:1,"Short description":"",description:"",Categories:"",Images:"",Parent:"HOODIE-PREMIUM","Regular price":"69.99","Sale price":"64.99","Attribute 1 name":"Color","Attribute 1 value(s)":"Blue","Payment Type":"","Subscription Interval":"","Trial Days":"",Installment:"","Installment Count":"","Setup Fee":"","Setup Fee Name":"","Setup Fee Amount":""}],te=gc.unparse(G),ne=new Blob([te],{type:"text/csv;charset=utf-8;"}),re=URL.createObjectURL(ne),K=document.createElement("a");K.href=re,K.download="fluent-cart-sample-import.csv",document.body.appendChild(K),K.click(),document.body.removeChild(K),URL.revokeObjectURL(re)},X=t;return(G,te)=>{const ne=C("el-button"),re=C("el-upload"),K=C("el-option"),Y=C("el-select"),W=C("el-dialog");return r(),h(H,null,[n(ne,{onClick:te[0]||(te[0]=j=>l.value=!0)},{default:d(()=>[R(m(G.$t("Import")),1)]),_:1}),n(W,{modelValue:l.value,"onUpdate:modelValue":te[4]||(te[4]=j=>l.value=j),"append-to-body":!0,title:G.$t("Import Products"),class:"fct-bulk-import-dialog"},{default:d(()=>[b.value?B("",!0):(r(),E(re,{key:0,class:"fct-file-uploader",ref:"uploaderRef","file-list":s.value,"onUpdate:fileList":te[1]||(te[1]=j=>s.value=j),drag:"",action:F(),"on-progress":()=>{},"on-success":()=>{},"on-error":()=>{},"auto-upload":!1,"on-change":j=>{$(),i.value=j,S(j==null?void 0:j.raw)},multiple:!1,limit:1,"show-file-list":!0},{default:d(()=>[n(Ze,{circle:"",bg:"primary",soft:""},{default:d(()=>[n(J,{name:"Upload"})]),_:1}),o("div",kve,[R(m(G.$t("Drag & Drop or"))+" ",1),o("em",null,m(G.$t("Browse/Upload")),1),R(" "+m(G.$t("Files"))+" ",1),o("span",null,m(A(u)("Any Format upto %s",A(Qt).serverMaxUploadSize())),1)])]),_:1},8,["file-list","action","on-change"])),b.value?B("",!0):(r(),E(ne,{key:1,onClick:q,link:""},{default:d(()=>[n(J,{name:"Download"}),R(" "+m(G.$t("Download a Sample CSV File")),1)]),_:1})),b.value?(r(),h(H,{key:2},[o("div",Bve,[o("h4",xve,m(G.$t("Map Columns")),1),o("table",Sve,[o("thead",null,[o("tr",null,[o("th",null,m(G.$t("Products Fields")),1),o("th",null,m(G.$t("CSV Headers")),1)])]),o("tbody",null,[(r(!0),h(H,null,ae(f.value,(j,ie)=>(r(),h("tr",null,[o("td",null,m(j.title),1),o("td",Fve,[n(Y,{modelValue:j.value,"onUpdate:modelValue":he=>j.value=he,filterable:"",clearable:""},{default:d(()=>[(r(!0),h(H,null,ae(_.value,he=>(r(),E(K,{key:he.value,label:he.title,value:he.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])])]))),256))])])]),o("div",$ve,[n(ne,{onClick:te[2]||(te[2]=j=>L())},{default:d(()=>[R(m(G.$t("Add Products")),1)]),_:1}),n(ne,{onClick:te[3]||(te[3]=j=>L(!1))},{default:d(()=>[R(m(G.$t("Clear and Add Products")),1)]),_:1})])],64)):B("",!0)]),_:1},8,["modelValue","title"])],64)}}};class Uve extends Ed{beforeInit(){this.data.products=[],this.data.saving=!1,this.data.saveProgress={total:0,completed:0,errors:[],createdIds:[]},this.data.savingIds=new Set,this.data.savedIds=new Set,this.data.productErrors=new Map,this.data.categoryOptions=[],this.data.dummies.product={ID:"",post_title:"",post_name:"",post_content:"",post_excerpt:"",post_status:"published",post_date:new Date,comment_status:"close",categories:[],variants:!1}}populateDummyProduct(){const t={...this.data.dummies.product};t._cid=Al(),t.detail={...this.data.dummies.productDetail},t.gallery=[],t.downloadable_files={...this.data.dummies.downloadableFile},t.variants=[this.getDummyVariation(t)],this.data.products.push(t)}clearProducts(){this.data.products=[]}isSaving(t){return this.data.savingIds.has(t)}isSaved(t){return this.data.savedIds.has(t)}isRowDisabled(t){return this.isSaving(t)||this.isSaved(t)}hasError(t){return this.data.productErrors.has(t)}getError(t){const a=this.data.productErrors.get(t);return a?a.fields&&Object.keys(a.fields).length?Object.values(a.fields).join("; "):a.message||"":""}hasProductLevelError(t){const a=this.data.productErrors.get(t);return a?!a.fields||!Object.keys(a.fields).length?!!a.message:Object.keys(a.fields).some(l=>!l.startsWith("variants.")):!1}getProductLevelError(t){const a=this.data.productErrors.get(t);return a?!a.fields||!Object.keys(a.fields).length?a.message||"":Object.entries(a.fields).filter(([s])=>!s.startsWith("variants.")).map(([,s])=>s).join("; ")||"":""}hasVariantError(t,a){const l=this.data.productErrors.get(t);if(!(l!=null&&l.fields))return!1;const s=`variants.${a}.`;return Object.keys(l.fields).some(i=>i.startsWith(s))}getVariantError(t,a){const l=this.data.productErrors.get(t);if(!(l!=null&&l.fields))return"";const s=`variants.${a}.`;return Object.entries(l.fields).filter(([c])=>c.startsWith(s)).map(([,c])=>c).join("; ")}hasFieldError(t,a){var s;const l=this.data.productErrors.get(t);return!!((s=l==null?void 0:l.fields)!=null&&s[a])}hasVariantFieldError(t,a,l){return this.hasFieldError(t,`variants.${a}.${l}`)}chunkArray(t,a){const l=[];for(let s=0;s!this.data.savedIds.has(c._cid));if(a.length===0){z.error(u("No products to save."));return}const l=this.chunkArray(a,10);this.data.saving=!0,this.data.productErrors=new Map,this.data.saveProgress={total:l.length,completed:0,errors:[],createdIds:[]};try{for(const f of l){const _=f.map(g=>g._cid);for(const g of _)this.data.savingIds.add(g);this.data.savingIds=new Set(this.data.savingIds);try{const g=await ue.post("products/bulk-insert",{products:f});if(g.created&&g.created.length){this.data.saveProgress.createdIds.push(...g.created);for(const y of g.created){this.data.savedIds.add(y._cid);const v=t.find(b=>b._cid===y._cid);v&&(v.ID=y.id,v.view_url=y.view_url||"")}this.data.savedIds=new Set(this.data.savedIds)}if(g.errors&&g.errors.length){this.data.saveProgress.errors.push(...g.errors);for(const y of g.errors)y._cid&&this.data.productErrors.set(y._cid,{message:y.message,fields:y.fields||{}});this.data.productErrors=new Map(this.data.productErrors)}}catch(g){const y=(s=g==null?void 0:g.data)==null?void 0:s.errors;if(Array.isArray(y)&&y.length){this.data.saveProgress.errors.push(...y);for(const v of y)v._cid&&this.data.productErrors.set(v._cid,{message:v.message,fields:v.fields||{}})}else{const v=((i=g==null?void 0:g.data)==null?void 0:i.message)||"A chunk failed to save";this.data.saveProgress.errors.push({message:v});for(const b of _)this.data.productErrors.set(b,{message:v,fields:{}})}this.data.productErrors=new Map(this.data.productErrors)}for(const g of _)this.data.savingIds.delete(g);this.data.savingIds=new Set(this.data.savingIds),this.data.saveProgress.completed++}const{createdIds:c,errors:p}=this.data.saveProgress;p.length===0?z.success(`${c.length} product(s) created successfully`):c.length>0?z.info(`${c.length} product(s) created, ${p.length} error(s)`):z.error(u("All products failed to save"))}finally{this.data.saving=!1}}async removeProduct(t){var l;if(t.ID&&this.data.savedIds.has(t._cid)){try{await ue.delete(`products/${t.ID}`)}catch(s){const i=((l=s==null?void 0:s.data)==null?void 0:l.message)||"Failed to delete product from server";z.error(i);return}this.data.savedIds.delete(t._cid),this.data.savedIds=new Set(this.data.savedIds)}const a=this.data.products.indexOf(t);a!==-1&&this.data.products.splice(a,1)}removeVariant(t,a){const l=t.variants.indexOf(a);l!==-1&&t.variants.splice(l,1)}duplicateProduct(t){const a=JSON.parse(JSON.stringify(t));a._cid=Al(),a.post_title=a.post_title?a.post_title+" (Copy)":"",a.variants&&Array.isArray(a.variants)&&a.variants.forEach(s=>{s.sku="",s._cid=Al()});const l=this.data.products.indexOf(t);this.data.products.splice(l+1,0,a)}duplicateProductWithVariants(t,a){const l=JSON.parse(JSON.stringify(t));if(l._cid=Al(),l.post_title=l.post_title?l.post_title+" (Copy)":"",l.variants&&Array.isArray(l.variants)){const i=new Set(a);l.variants=l.variants.filter((c,p)=>i.has(p)),l.variants.forEach(c=>{c.sku="",c._cid=Al()})}const s=this.data.products.indexOf(t);this.data.products.splice(s+1,0,l)}duplicateVariant(t,a){const l=JSON.parse(JSON.stringify(a));l._cid=Al(),l.variation_title=l.variation_title?l.variation_title+" (Copy)":"",l.sku="";const s=t.variants.indexOf(a);t.variants.splice(s+1,0,l)}resetPaymentTypeDefaults(t){t.other_info.payment_type==="onetime"&&(t.other_info.installment="no",t.other_info.times="",t.other_info.manage_setup_fee="no",t.other_info.signup_fee="",t.other_info.signup_fee_name="")}resetState(){this.data.products.splice(0),this.data.savedIds=new Set,this.data.savingIds=new Set,this.data.productErrors=new Map}getColumnWidthStorageKey(){return"bulk_insert_column_widths"}getColumnStorageKey(){return"bulk_insert_columns"}getToggleableColumns(){return[{label:"SKU",value:"sku"},{label:"Media",value:"media"},{label:"Categories",value:"categories"},{label:"Description",value:"description"},{label:"Short Description",value:"short_description"},{label:"Status",value:"status"},{label:"Product Type",value:"product_type"},{label:"Pricing Type",value:"pricing_type"},{label:"Payment Type",value:"payment_type"},{label:"Interval",value:"interval"},{label:"Trial Days",value:"trial_days"},{label:"Best Price",value:"best_price"},{label:"Compare-at Price",value:"compare_price"},{label:"Track Quantity",value:"track_quantity"},{label:"Stock",value:"stock"}]}flattenCategoryTree(t,a=""){var s;const l=[];for(const i of t){const c=a?`${a} > ${i.label}`:i.label;l.push({label:c,value:c}),(s=i.children)!=null&&s.length&&l.push(...this.flattenCategoryTree(i.children,c))}return l}async fetchCategories(){try{const a=(await ue.get("products/fetch-term")).taxonomies||{},l=Object.values(a).find(s=>s.name==="product-categories");l!=null&&l.terms&&(this.data.categoryOptions=this.flattenCategoryTree(l.terms))}catch{}}}const Ft=Uve.init(),Ive={class:"max-w-full overflow-x-scroll"},Qve={class:"relative"},Dve={key:0,class:"bulk-checkbox-cell"},Vve=["onMousedown","onTouchstart"],uf={__name:"ResizeableColumns",props:{columns:{type:Array,required:!0},stickyLast:{type:Boolean,default:!1}},emits:["scroll","resize-end"],setup(e,{emit:t}){const a=t,l=Rf(),s=Xr("table"),i=M(null);let c=null;Ie(()=>{ke(()=>{const g=s.value.querySelectorAll("th"),y=l["header-first"]?1:0;Array.from(g).forEach((v,b)=>{const k=b-y;k<0||k>=p.columns.length||(p.columns[k].width=v.offsetWidth,p.columns[k].minWidth||(p.columns[k].minWidth=v.offsetWidth))}),c=new ResizeObserver(()=>{s.value.style.setProperty("--resizer-height",s.value.offsetHeight+"px");const v=s.value.querySelector("th");v&&s.value.style.setProperty("--header-height",v.offsetHeight+"px")}),c.observe(s.value)})}),vl(()=>{c&&c.disconnect()});const p=e,f=N(()=>{const g=l["header-first"]?40:0;return p.columns.reduce((y,v)=>y+v.width,0)+g}),_=(g,y)=>{g.preventDefault();const v=g.clientX,b=p.columns[y].width,k=p.columns[y].minWidth||50;i.value=y;const w=$=>{const V=b+($.clientX-v);V>=k&&(p.columns[y].width=V)},S=()=>{i.value=null,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",S),a("resize-end")};document.addEventListener("mousemove",w),document.addEventListener("mouseup",S)};return(g,y)=>(r(),h("div",Ive,[o("div",{class:de(["resizable-table",{"is-resizing":i.value!==null}]),onScroll:y[0]||(y[0]=v=>a("scroll",v))},[o("div",Qve,[o("table",{id:"tb",ref_key:"table",ref:s,style:ua({tableLayout:"fixed",width:f.value+"px"})},[o("thead",null,[o("tr",null,[g.$slots["header-first"]?(r(),h("th",Dve,[ba(g.$slots,"header-first")])):B("",!0),(r(!0),h(H,null,ae(e.columns,(v,b)=>(r(),h("th",{class:de({"sticky-col":b===0,"sticky-col sticky-col-right":b===e.columns.length-1&&e.stickyLast}),style:ua({width:v.width+"px",zIndex:b===0||b===e.columns.length-1&&e.stickyLast?70:e.columns.length-b+50,left:b===0&&g.$slots["header-first"]?"40px":b===0?"0px":void 0}),key:v.key||b},[b===e.columns.length-1?ba(g.$slots,"header-last",{key:0},()=>[R(m(v.title),1)]):(r(),h(H,{key:1},[R(m(v.title),1)],64)),b_(k,b),onTouchstart:k=>_(k,b)},null,42,Vve)):B("",!0)],6))),128))])]),o("tbody",null,[ba(g.$slots,"default")])],4)])],34)]))}},Tve={class:"bulk-setup-fee-badge"},Mve={key:1,class:"text-gray-300 text-sm flex justify-center"},qo={__name:"BulkPriceInput",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const a=t;return(l,s)=>{var c;const i=C("el-tooltip");return e.variant?(r(),E(Yl,{key:0,size:"small","error-class":e.hasError?"is-error":"","model-value":e.variant.item_price,placeholder:l.$t("Price"),disabled:e.disabled,"onUpdate:modelValue":s[0]||(s[0]=p=>{e.variant.item_price=p,a("change")})},oa({_:2},[((c=e.variant.other_info)==null?void 0:c.manage_setup_fee)==="yes"&&e.variant.other_info.signup_fee?{name:"suffix",fn:d(()=>[n(i,{content:(e.variant.other_info.signup_fee_name||l.$t("Setup fee"))+": "+A(Gt)(e.variant.other_info.signup_fee,!0),placement:"top","popper-class":"fct-tooltip"},{default:d(()=>[o("span",Tve,"+ "+m(l.$t("fee")),1)]),_:1},8,["content"])]),key:"0"}:void 0]),1032,["error-class","model-value","placeholder","disabled"])):(r(),h("span",Mve,"—"))}}},Lve=["disabled"],Rve={key:0,class:"fct-bulk-sub-count"},Ove={class:"fct-bulk-sub-popover-body"},Hve={class:"fct-bulk-sub-popover-title"},Pve={class:"fct-bulk-sub-section"},Nve={class:"fct-bulk-sub-row"},Kve={class:"fct-bulk-sub-row"},Gve={class:"fct-bulk-sub-label"},jve={class:"fct-bulk-sub-row"},zve={class:"fct-bulk-sub-label"},qve=["innerHTML"],Yve={class:"fct-bulk-sub-section"},Wve={class:"fct-bulk-sub-row"},Jve={class:"fct-bulk-sub-row"},Xve={class:"fct-bulk-sub-label"},Zve={class:"fct-bulk-sub-row"},ege={class:"fct-bulk-sub-label"},tge={class:"fct-bulk-sub-footer"},or=2,age={__name:"BulkSubscriptionPopover",props:{variant:{type:Object,required:!0},disabled:{type:Boolean,default:!1}},emits:["changed"],setup(e,{emit:t}){const a=e,l=t,s=Yt().ctx,i=Ge.get(),c=Ge.get("app_config.isProActive"),p=M(!1);N(()=>{var F;return((F=i==null?void 0:i.shop)==null?void 0:F.currency_sign)||"$"});const f=N(()=>{var F;return((F=a.variant)==null?void 0:F.other_info)||{}}),_=N(()=>f.value.payment_type==="subscription"),g=N(()=>f.value.installment==="yes"),y=N(()=>Number(f.value.times)||1),v=N(()=>{var x;const F=Number((x=a.variant)==null?void 0:x.item_price)||0;return g.value?F*y.value:F}),b=N(()=>{const F=[];if(g.value&&F.push(s.$t("Installment")+": "+y.value+"x"),f.value.manage_setup_fee==="yes"){const x=f.value.signup_fee_name||s.$t("Setup fee"),Q=f.value.signup_fee||0;F.push(s.$t("Setup fee")+": "+x+" ("+Gt(Q,!0)+")")}return F.length>0?F.join(`
`):s.$t("Subscription settings")}),k=F=>{F==="no"?a.variant.other_info.times="":w(),l("changed")},w=()=>{const F=Number(a.variant.other_info.times);(!Number.isFinite(F)||F{F==="no"&&(a.variant.other_info.signup_fee=""),l("changed")},$=()=>{l("changed")},V=()=>{p.value=!1};return(F,x)=>{const Q=C("el-checkbox"),D=C("el-tooltip"),T=C("el-input"),U=C("el-switch"),I=C("el-button"),O=C("el-popover");return r(),E(D,{content:b.value,placement:"top",disabled:!_.value||p.value,"popper-class":"fct-tooltip","show-after":400},{default:d(()=>[n(O,{visible:p.value,"onUpdate:visible":x[6]||(x[6]=L=>p.value=L),placement:"bottom",width:320,trigger:"click",disabled:e.disabled||!_.value,"popper-class":"bulk-sub-popover"},{reference:d(()=>[o("button",{class:de(["fc-bulk-sub-icon-btn",{"is-active":_.value,"is-configured":_.value&&(g.value||f.value.manage_setup_fee==="yes")}]),disabled:e.disabled||!_.value,onClick:x[0]||(x[0]=Ne(()=>{},["prevent"]))},[x[7]||(x[7]=o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16"},[o("path",{d:"M6 4H21C21.5523 4 22 4.44772 22 5V12H20V6H6V9L1 5.5L6 2V4ZM18 20H3C2.44772 20 2 19.5523 2 19V12H4V18H18V15L23 18.5L18 22V20Z"})],-1)),g.value?(r(),h("span",Rve,m(y.value),1)):B("",!0)],10,Lve)]),default:d(()=>[o("div",Ove,[o("h4",Hve,m(F.$t("Subscription Settings")),1),o("div",Pve,[o("div",Nve,[n(Q,{"true-value":"yes","false-value":"no",label:F.$t("Enable installment payment"),modelValue:e.variant.other_info.installment,"onUpdate:modelValue":x[1]||(x[1]=L=>e.variant.other_info.installment=L),disabled:!A(c)||e.disabled,onChange:k},null,8,["label","modelValue","disabled"]),A(c)?B("",!0):(r(),E(D,{key:0,"popper-class":"fct-tooltip"},{content:d(()=>[R(m(F.$t("This feature is available in pro version only.")),1)]),default:d(()=>[n(J,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),f.value.installment==="yes"?(r(),h(H,{key:0},[o("div",Kve,[o("label",Gve,m(F.$t("Installment Count")),1),n(T,{type:"number",min:or,size:"small",modelValue:e.variant.other_info.times,"onUpdate:modelValue":x[2]||(x[2]=L=>e.variant.other_info.times=L),modelModifiers:{number:!0},placeholder:F.$t("Count"),style:{width:"100px"},onInput:$,onChange:w},null,8,["modelValue","placeholder"])]),o("div",jve,[o("span",zve,m(F.$t("Total Price")),1),o("span",{class:"fct-bulk-sub-value",innerHTML:A(Gt)(v.value,!0)},null,8,qve)])],64)):B("",!0)]),o("div",Yve,[o("div",Wve,[n(U,{"active-text":F.$t("Setup fee"),modelValue:e.variant.other_info.manage_setup_fee,"onUpdate:modelValue":x[3]||(x[3]=L=>e.variant.other_info.manage_setup_fee=L),"active-value":"yes","inactive-value":"no",disabled:!A(c)||e.disabled,size:"small",onChange:S},null,8,["active-text","modelValue","disabled"]),A(c)?B("",!0):(r(),E(D,{key:0,"popper-class":"fct-tooltip"},{content:d(()=>[R(m(F.$t("This feature is available in pro version only.")),1)]),default:d(()=>[n(J,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),f.value.manage_setup_fee==="yes"?(r(),h(H,{key:0},[o("div",Jve,[o("label",Xve,m(F.$t("Label")),1),n(T,{size:"small",modelValue:e.variant.other_info.signup_fee_name,"onUpdate:modelValue":x[4]||(x[4]=L=>e.variant.other_info.signup_fee_name=L),placeholder:F.$t("e.g. Initial Setup"),onInput:$},null,8,["modelValue","placeholder"])]),o("div",Zve,[o("label",ege,m(F.$t("Amount")),1),n(Yl,{size:"small","model-value":e.variant.other_info.signup_fee,placeholder:F.$t("Amount"),"onUpdate:modelValue":x[5]||(x[5]=L=>{e.variant.other_info.signup_fee=L,$()})},null,8,["model-value","placeholder"])])],64)):B("",!0)]),o("div",tge,[n(I,{size:"small",type:"primary",onClick:V},{default:d(()=>[R(m(F.$t("Done")),1)]),_:1})])])]),_:1},8,["visible","disabled"])]),_:1},8,["content","disabled"])}}},lge={key:0,class:"flex items-center"},sge={key:1,class:"text-gray-300 text-sm flex justify-center"},Yo={__name:"BulkPaymentTypeCell",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change","payment-type-change"],setup(e,{emit:t}){const a=e,l=t,s=()=>{var i;return(i=a.variant)==null?void 0:i.other_info};return(i,c)=>{const p=C("el-option"),f=C("el-select");return e.variant&&s()?(r(),h("div",lge,[n(f,{modelValue:e.variant.other_info.payment_type,"onUpdate:modelValue":c[0]||(c[0]=_=>e.variant.other_info.payment_type=_),size:"small",class:de({"is-field-error":e.hasError}),disabled:e.disabled,onChange:c[1]||(c[1]=_=>l("payment-type-change",e.variant))},{default:d(()=>[n(p,{label:i.$t("One Time"),value:"onetime"},null,8,["label"]),n(p,{label:i.$t("Subscription"),value:"subscription"},null,8,["label"])]),_:1},8,["modelValue","class","disabled"]),n(age,{variant:e.variant,disabled:e.disabled,onChanged:c[2]||(c[2]=_=>l("change"))},null,8,["variant","disabled"])])):(r(),h("span",sge,"—"))}}},nge={key:1,class:"text-gray-300 text-sm flex justify-center"},Wo={__name:"BulkIntervalSelect",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const a=e,l=t,s=()=>{var i,c;return((c=(i=a.variant)==null?void 0:i.other_info)==null?void 0:c.payment_type)==="subscription"};return(i,c)=>{const p=C("el-option"),f=C("el-select");return e.variant&&s()?(r(),E(f,{key:0,modelValue:e.variant.other_info.repeat_interval,"onUpdate:modelValue":c[0]||(c[0]=_=>e.variant.other_info.repeat_interval=_),size:"small",class:de({"is-field-error":e.hasError}),disabled:e.disabled,onChange:c[1]||(c[1]=_=>l("change"))},{default:d(()=>[n(p,{label:i.$t("Yearly"),value:"yearly"},null,8,["label"]),n(p,{label:i.$t("Half Yearly"),value:"half_yearly"},null,8,["label"]),n(p,{label:i.$t("Quarterly"),value:"quarterly"},null,8,["label"]),n(p,{label:i.$t("Monthly"),value:"monthly"},null,8,["label"]),n(p,{label:i.$t("Weekly"),value:"weekly"},null,8,["label"]),n(p,{label:i.$t("Daily"),value:"daily"},null,8,["label"])]),_:1},8,["modelValue","class","disabled"])):(r(),h("span",nge,"—"))}}},oge={key:1,class:"text-gray-300 text-sm flex justify-center"},Jo={__name:"BulkTrialDaysInput",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const a=e,l=t,s=()=>{var i,c;return((c=(i=a.variant)==null?void 0:i.other_info)==null?void 0:c.payment_type)==="subscription"};return(i,c)=>{const p=C("el-input");return e.variant&&s()?(r(),E(p,{key:0,class:de(["fct-bulk-input",{"is-error":e.hasError}]),modelValue:e.variant.other_info.trial_days,"onUpdate:modelValue":c[0]||(c[0]=f=>e.variant.other_info.trial_days=f),placeholder:"0",disabled:e.disabled,onChange:c[1]||(c[1]=f=>l("change")),size:"small"},null,8,["class","modelValue","disabled"])):(r(),h("span",oge,"—"))}}},ige={key:1,class:"text-gray-300 text-sm flex justify-center"},Xo={__name:"BulkComparePriceInput",props:{variant:{type:Object,default:null},disabled:{type:Boolean,default:!1},hasError:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const a=t;return(l,s)=>e.variant?(r(),E(Yl,{key:0,size:"small","error-class":e.hasError?"is-error":"","model-value":e.variant.compare_price,placeholder:l.$t("Compare price"),disabled:e.disabled,"onUpdate:modelValue":s[0]||(s[0]=i=>{e.variant.compare_price=i,a("change")})},null,8,["error-class","model-value","placeholder","disabled"])):(r(),h("span",ige,"—"))}},cf={__name:"BulkCategorySelect",props:{modelValue:{type:Array,default:()=>[]},options:{type:Array,default:()=>[]},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","change"],setup(e,{emit:t}){const a=t,l=s=>{a("update:modelValue",s),a("change",s)};return(s,i)=>{const c=C("el-option"),p=C("el-select");return r(),E(p,{"model-value":e.modelValue,multiple:"",filterable:"","allow-create":"","default-first-option":"","collapse-tags":"","collapse-tags-tooltip":!1,"max-collapse-tags":1,size:"small",placeholder:s.$t("Select or type..."),disabled:e.disabled,"onUpdate:modelValue":l},{default:d(()=>[(r(!0),h(H,null,ae(e.options,f=>(r(),E(c,{key:f.value,label:f.label,value:f.value},null,8,["label","value"]))),128))]),_:1},8,["model-value","placeholder","disabled"])}}},rge=["textContent"],dge={key:1,class:"fct-bulk-editor-placeholder"},Zo={__name:"BulkEditorCell",props:{value:{type:String,default:""},placeholder:{type:String,default:""}},emits:["click"],setup(e){return(t,a)=>(r(),h("div",{class:"fct-bulk-editor",onClick:a[0]||(a[0]=l=>t.$emit("click"))},[e.value?(r(),h("span",{key:0,class:"bulk-editor-preview",textContent:m(e.value)},null,8,rge)):(r(),h("span",dge,m(e.placeholder),1))]))}};function Af(){const e=M(new Set),t=M(null),a=M(!1),l=(y,v,b)=>{if(v.shiftKey&&t.value!==null){const w=b.indexOf(t.value),S=b.indexOf(y);if(w!==-1&&S!==-1){const $=Math.min(w,S),V=Math.max(w,S),F=new Set(e.value);for(let x=$;x<=V;x++)F.add(b[x]);e.value=F}}else{const w=new Set(e.value);w.has(y)?w.delete(y):w.add(y),e.value=w,t.value=y}},s=y=>{e.value.size===y.length&&y.length>0?e.value=new Set:e.value=new Set(y)},i=y=>{e.value=new Set(y)},c=()=>{e.value=new Set,t.value=null,a.value=!1},p=()=>{a.value?a.value=!1:e.value.size>=2&&(a.value=!0)};be(e,y=>{a.value&&y.size<2&&(a.value=!1)});const f=y=>e.value.has(y),_=N(()=>e.value.size);return{selectedKeys:e,lastClickedKey:t,isLinkMode:a,handleRowClick:l,toggleSelectAll:s,selectAll:i,deselectAll:c,toggleLinkMode:p,isSelected:f,selectedCount:_,pruneStaleKeys:y=>{const v=new Set(y);let b=!1;const k=new Set;for(const w of e.value)v.has(w)?k.add(w):b=!0;b&&(e.value=k),t.value&&!v.has(t.value)&&(t.value=null)}}}const uge={mounted(e,t){e.indeterminate=!!t.value},updated(e,t){e.indeterminate=!!t.value}},pf={title:{product:{get:e=>e.post_title,set:(e,t)=>e.post_title=t},variant:{get:e=>e.variation_title,set:(e,t)=>e.variation_title=t}},sku:{product:{get:e=>{var t,a;return(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.sku},set:(e,t)=>{var a;(a=e.variants)!=null&&a[0]&&(e.variants[0].sku=t)}},variant:{get:e=>e.sku,set:(e,t)=>e.sku=t}},status:{product:{get:e=>e.post_status,set:(e,t)=>e.post_status=t}},description:{product:{get:e=>e.post_content,set:(e,t)=>e.post_content=t}},short_desc:{product:{get:e=>e.post_excerpt,set:(e,t)=>e.post_excerpt=t}},product_type:{product:{get:e=>{var t;return(t=e.detail)==null?void 0:t.fulfillment_type},set:(e,t)=>{e.detail&&(e.detail.fulfillment_type=t)}}},pricing_type:{product:{get:e=>{var t;return(t=e.detail)==null?void 0:t.variation_type},set:(e,t)=>{e.detail&&(e.detail.variation_type=t)}}},payment_type:{product:{get:e=>{var t,a,l;return(l=(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.other_info)==null?void 0:l.payment_type},set:(e,t)=>{var a,l;(l=(a=e.variants)==null?void 0:a[0])!=null&&l.other_info&&(e.variants[0].other_info.payment_type=t)}},variant:{get:e=>{var t;return(t=e.other_info)==null?void 0:t.payment_type},set:(e,t)=>{e.other_info&&(e.other_info.payment_type=t)}}},interval:{product:{get:e=>{var t,a,l;return(l=(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.other_info)==null?void 0:l.repeat_interval},set:(e,t)=>{var a,l;(l=(a=e.variants)==null?void 0:a[0])!=null&&l.other_info&&(e.variants[0].other_info.repeat_interval=t)}},variant:{get:e=>{var t;return(t=e.other_info)==null?void 0:t.repeat_interval},set:(e,t)=>{e.other_info&&(e.other_info.repeat_interval=t)}}},trial_days:{product:{get:e=>{var t,a,l;return(l=(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.other_info)==null?void 0:l.trial_days},set:(e,t)=>{var a,l;(l=(a=e.variants)==null?void 0:a[0])!=null&&l.other_info&&(e.variants[0].other_info.trial_days=t)}},variant:{get:e=>{var t;return(t=e.other_info)==null?void 0:t.trial_days},set:(e,t)=>{e.other_info&&(e.other_info.trial_days=t)}}},price:{product:{get:e=>{var t,a;return(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.item_price},set:(e,t)=>{var a;(a=e.variants)!=null&&a[0]&&(e.variants[0].item_price=t)}},variant:{get:e=>e.item_price,set:(e,t)=>e.item_price=t}},compare_price:{product:{get:e=>{var t,a;return(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.compare_price},set:(e,t)=>{var a;(a=e.variants)!=null&&a[0]&&(e.variants[0].compare_price=t)}},variant:{get:e=>e.compare_price,set:(e,t)=>e.compare_price=t}},manage_stock:{product:{get:e=>{var t;return(t=e.detail)==null?void 0:t.manage_stock},set:(e,t)=>{e.detail&&(e.detail.manage_stock=t)}}},categories:{product:{get:e=>e.categories,set:(e,t)=>e.categories=[...t]}}},cge={...pf,stock:{product:{get:e=>{var t;return(t=e.detail)==null?void 0:t.total_stock},set:(e,t)=>{e.detail&&(e.detail.total_stock=t)}},variant:{get:e=>e.total_stock,set:(e,t)=>e.total_stock=t}}},Age={...pf,stock:{product:{get:e=>{var t,a;return(a=(t=e.variants)==null?void 0:t[0])==null?void 0:a.available},set:(e,t)=>{var a;(a=e.variants)!=null&&a[0]&&(e.variants[0].available=t)}},variant:{get:e=>e.available,set:(e,t)=>e.available=t}}};function ff(e,t,a,l,s,i,c){const p=c[e];if(p)for(const f of l){if(f===a)continue;const _=s(f);if(!_)continue;const g=p[_.type];g&&(g.set(_.data,t),i&&i(_.product))}}const pge={class:"fct-bulk-insert-page fct-layout-width"},fge={class:"fct-btn-group sm justify-end"},mge={class:"filter-popover-item"},hge={class:"filter-popover-title"},_ge={key:0,"aria-hidden":"true"},vge=["colspan"],gge=["onClick"],yge=["onClick"],bge={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},wge={class:"flex items-center"},Cge=["onClick","title"],kge={key:0,class:"bulk-collapse-count"},Bge=["title"],xge=["title"],Sge={class:"bulk-status-icon is-error"},Fge={key:0,class:"fct-bulk-sku-cell"},$ge={key:1,class:"text-gray-300 text-sm flex justify-center"},Ege={key:1,class:"fct-bulk-media-cell"},Uge={key:2,class:"fct-bulk-categories-cell"},Ige={key:3,class:"fct-bulk-desc-cell"},Qge={key:4,class:"fct-bulk-short-desc-cell"},Dge={key:5,class:"fct-bulk-status-cell"},Vge={key:6,class:"fct-bulk-product-type-cell"},Tge={key:7,class:"fct-bulk-product-type-cell"},Mge={key:8,class:"fct-bulk-pricing-type-cell"},Lge={key:9,class:"fct-bulk-pricing-type-cell"},Rge={key:10,class:"fct-bulk-payment-type-cell"},Oge={key:11,class:"fct-bulk-interval-cell"},Hge={key:12,class:"fct-bulk-trial-days-cell"},Pge={key:13,class:"fct-bulk-best-price-cell"},Nge={key:14,class:"fct-bulk-compare-price-cell"},Kge={key:15,class:"fct-bulk-qty-cell !pl-5"},Gge={key:16,class:"fct-bulk-stock-cell"},jge={key:1,class:"text-gray-300 text-sm pl-5"},zge={class:"fct-btn-group xs justify-end"},qge=["href","title"],Yge={key:0,class:"bulk-variants-block-row"},Wge=["colspan"],Jge={class:"bulk-inner-table",style:{tableLayout:"fixed",width:"100%",borderCollapse:"collapse"}},Xge=["onClick"],Zge={class:"bulk-checkbox-cell"},e1e={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},t1e={class:"flex items-center gap-1 pl-4"},a1e={class:"bulk-status-icon is-error"},l1e={key:0,class:"fct-bulk-sku-cell"},s1e={key:1,class:"fct-bulk-media-cell"},n1e={key:2},o1e={key:3},i1e={key:4},r1e={key:5},d1e={key:6},u1e={key:7},c1e={key:8},A1e={key:9},p1e={key:10},f1e={key:11},m1e={key:12},h1e={key:13,class:"text-center"},_1e={key:14},v1e={key:1,class:"text-gray-300 text-sm flex justify-center"},g1e={class:"fct-btn-group sm justify-end"},y1e={class:"bulk-add-variant-row"},b1e=["colspan"],w1e={class:"sticky left-0 inline-block pl-6"},C1e={key:1,"aria-hidden":"true"},k1e=["colspan"],ir=43,B1e=10,x1e=800,yc=100,S1e={__name:"BulkInsert",setup(e){const{options:t,products:a}=Ft.data,l=ge=>{var Fe;return((Fe=ge==null?void 0:ge.detail)==null?void 0:Fe.variation_type)==="simple"},s=N(()=>Ft.data.saving),i=N(()=>Ft.data.saveProgress),c=N(()=>{const ge=Ft.data.saveProgress;return ge.total?Math.round(ge.completed/ge.total*100):0}),p=()=>{Ft.saveProducts()},f=ge=>Ft.isSaving(ge._cid),_=ge=>Ft.isSaved(ge._cid),g=ge=>Ft.isRowDisabled(ge._cid),y=ge=>Ft.hasError(ge._cid),v=ge=>Ft.getError(ge._cid),b=ge=>Ft.hasProductLevelError(ge._cid),k=(ge,Fe)=>Ft.hasVariantError(ge._cid,Fe),w=(ge,Fe)=>Ft.getVariantError(ge._cid,Fe),S=(ge,Fe)=>Ft.hasFieldError(ge._cid,Fe),$=(ge,Fe,nt)=>Ft.hasVariantFieldError(ge._cid,Fe,nt),V=async ge=>{const Fe=ge.post_title||P.$t("Untitled product"),nt=Array.isArray(ge.variants)?ge.variants.length:0,bt=Ft.isSaved(ge._cid);let Bt=nt>0?P.$t('This will remove "%1$s" and its %2$s variant(s).',Fe,nt):P.$t('This will remove "%1$s".',Fe);bt&&(Bt+=" "+P.$t("This product was already saved and will be permanently deleted."));try{await xl.confirm(Bt,P.$t("Remove Product"),{confirmButtonText:P.$t("Remove"),cancelButtonText:P.$t("Cancel"),type:"warning"})}catch{return}await Ft.removeProduct(ge)},F=(ge,Fe)=>{const nt=Fe.variation_title||P.$t("Untitled variant");xl.confirm(P.$t('This will remove the variant "%1$s".',nt),P.$t("Remove Variant"),{confirmButtonText:P.$t("Remove"),cancelButtonText:P.$t("Cancel"),confirmButtonClass:"el-button--small",cancelButtonClass:"el-button--small",type:"warning"}).then(()=>{Ft.removeVariant(ge,Fe)}).catch(()=>{})},x=ge=>Ft.duplicateProduct(ge),Q=(ge,Fe)=>Ft.duplicateVariant(ge,Fe),D=()=>{const ge=[];for(const Fe of a){const nt=`p:${Fe._cid}`,bt=Y.value.has(nt),Bt=[];Fe.variants&&Fe.variants.forEach((Wt,_t)=>{Y.value.has(`v:${Fe._cid}:${_t}`)&&Bt.push(_t)}),!(!bt&&Bt.length===0)&&(bt&&Bt.length===0?ge.push({product:Fe,type:"full"}):!bt&&Bt.length>0?ge.push({product:Fe,type:"variants-only",variantIndexes:Bt}):ge.push({product:Fe,type:"partial",variantIndexes:Bt}))}return ge},T=()=>{const ge=D();if(!ge.length)return;const Fe=ge.filter(_t=>_t.type==="full").length,nt=ge.filter(_t=>_t.type==="partial").length,Bt=ge.filter(_t=>_t.type==="variants-only").reduce((_t,la)=>_t+la.variantIndexes.length,0),Wt=[];Fe>0&&Wt.push(`${Fe} product(s) with all variants`),nt>0&&Wt.push(`${nt} product(s) with selected variants`),Bt>0&&Wt.push(`${Bt} variant(s)`),xl.confirm(P.$t("Duplicate %s?").replace("%s",Wt.join(", ")),P.$t("Bulk Duplicate"),{confirmButtonText:P.$t("Duplicate"),cancelButtonText:P.$t("Cancel"),type:"info"}).then(()=>{for(const _t of ge)if(_t.type==="full")Ft.duplicateProduct(_t.product);else if(_t.type==="variants-only")for(const la of _t.variantIndexes){const sa=_t.product.variants[la];sa&&Ft.duplicateVariant(_t.product,sa)}else _t.type==="partial"&&Ft.duplicateProductWithVariants(_t.product,_t.variantIndexes);he()}).catch(()=>{})},U=async()=>{const ge=[],Fe=[];for(const _t of a){const la=`p:${_t._cid}`;if(Y.value.has(la)){ge.push(_t);continue}const Nt=[];_t.variants&&_t.variants.forEach((ia,el)=>{Y.value.has(`v:${_t._cid}:${el}`)&&Nt.push(ia)}),Nt.length>0&&Fe.push({product:_t,variants:Nt})}if(!ge.length&&!Fe.length)return;const nt=ge.filter(_t=>Ft.isSaved(_t._cid)).length,bt=Fe.reduce((_t,la)=>_t+la.variants.length,0),Bt=[];ge.length>0&&Bt.push(`${ge.length} product(s)`),bt>0&&Bt.push(`${bt} variant(s)`);let Wt=P.$t("Remove %s?").replace("%s",Bt.join(" and "));nt>0&&(Wt+=" "+P.$t("%s already saved will be permanently deleted.").replace("%s",`${nt}`));try{await xl.confirm(Wt,P.$t("Bulk Remove"),{confirmButtonText:P.$t("Remove"),cancelButtonText:P.$t("Cancel"),type:"warning"})}catch{return}for(const _t of ge)await Ft.removeProduct(_t);for(const{product:_t,variants:la}of Fe)for(const sa of la)Ft.removeVariant(_t,sa);he()},I=ge=>{Ft.resetPaymentTypeDefaults(ge)},O=(ge,Fe)=>{const nt=Ft.data.categoryOptions;for(const bt of Fe)nt.find(Bt=>Bt.value===bt)||nt.push({label:bt,value:bt})},L=()=>{Ft.populateDummyProduct()},P=Yt().ctx,q=ge=>{const Fe=Ft.data.products;ge.concat||(Fe.splice(0,Fe.length),Ft.data.savedIds=new Set,Ft.data.savingIds=new Set,Ft.data.productErrors=new Map),Fe.push(...ge.products)},X=M({visible:!1,field:"",product:null,value:""}),G=(ge,Fe)=>{X.value={visible:!0,field:Fe,product:ge,value:ge[Fe]||""}},te=ge=>{X.value.value=ge},ne=()=>{const{product:ge,field:Fe,value:nt}=X.value;ge&&(ge[Fe]=nt),X.value.visible=!1},re=N(()=>X.value.field==="post_content"?P.$t("Edit Description"):P.$t("Edit Short Description")),K=M(!0),{selectedKeys:Y,handleRowClick:W,toggleSelectAll:j,selectAll:ie,deselectAll:he,isSelected:me,selectedCount:ye,isLinkMode:se,toggleLinkMode:fe}=Af(),$e=N(()=>{const ge=[];for(const Fe of ht.value)if(ge.push(`p:${Fe.productId}`),Fe.hasVariants&&!Fe.collapsed)for(let nt=0;nt{var Fe;if(ge.startsWith("p:")){const nt=ge.slice(2),bt=a.find(Bt=>Bt._cid===nt);return bt?{type:"product",data:bt,product:bt}:null}else if(ge.startsWith("v:")){const nt=ge.split(":"),bt=nt[1],Bt=parseInt(nt[2]),Wt=a.find(_t=>_t._cid===bt);if(Wt&&((Fe=Wt.variants)!=null&&Fe[Bt]))return{type:"variant",data:Wt.variants[Bt],product:Wt}}return null},ve=(ge,Fe,nt)=>{!se.value||!me(nt)||ff(ge,Fe,nt,Y.value,tt,null,cge)},Je=M(!1),vt=ge=>{ge.key==="Shift"&&(Je.value=!0)},Ye=ge=>{ge.key==="Shift"&&(Je.value=!1)},xe=(ge,Fe)=>{if(!Fe.shiftKey||Fe.target.closest(".bulk-checkbox-cell"))return;Fe.preventDefault();const nt=new Set(Y.value);nt.has(ge)?nt.delete(ge):nt.add(ge),Y.value=nt},Ee=M([]),Oe=N(()=>Ee.value.filter(ge=>ge.key==="title"||ge.key==="actions"?!0:Ft.isColumnVisible(ge.key))),Me=ge=>Ft.isColumnVisible(ge),gt=()=>{Ft.saveColumnWidths(Ee.value)},yt=M(new Set),Mt=ge=>{const Fe=ge._cid;yt.value.has(Fe)?yt.value.delete(Fe):yt.value.add(Fe),yt.value=new Set(yt.value)},Ut=ge=>yt.value.has(ge._cid),Dt=M(0),ht=N(()=>{let ge=0;return a.map(Fe=>{var Nt;const nt=Fe._cid,bt=((Nt=Fe.detail)==null?void 0:Nt.variation_type)!=="simple"&&Array.isArray(Fe.variants),Bt=bt?Fe.variants.length:0,Wt=yt.value.has(nt),_t=bt&&!Wt?(Bt+1)*ir:0,la=ir+_t,sa={product:Fe,productId:nt,hasVariants:bt,variantCount:Bt,collapsed:Wt,groupHeight:la,offset:ge};return ge+=la,sa})}),Pt=N(()=>{const ge=ht.value;if(ge.length===0)return 0;const Fe=ge[ge.length-1];return Fe.offset+Fe.groupHeight}),Ct=N(()=>{const ge=ht.value,Fe=Dt.value,nt=Fe+x1e,bt=B1e*ir;return ge.filter(Bt=>Bt.offset+Bt.groupHeight>=Fe-bt&&Bt.offset<=nt+bt)}),St=N(()=>Ct.value.length===0?0:Ct.value[0].offset),Ot=N(()=>{if(Ct.value.length===0)return 0;const ge=Ct.value[Ct.value.length-1];return Pt.value-ge.offset-ge.groupHeight});let Ht=null,It=0;const mt=ge=>{const Fe=ge.target,nt=Date.now();Ht&&clearTimeout(Ht),nt-It>=yc?(Dt.value=Fe.scrollTop,It=nt):Ht=setTimeout(()=>{Dt.value=Fe.scrollTop,It=Date.now(),Ht=null},yc)};let jt=null;return Ie(async()=>{jt=_s(),jt.bind("mod+a",ge=>{var nt,bt;const Fe=(nt=document.activeElement)==null?void 0:nt.tagName;Fe==="INPUT"||Fe==="TEXTAREA"||(bt=document.activeElement)!=null&&bt.isContentEditable||(ge.preventDefault(),ie($e.value))}),jt.bind("escape",()=>{var Fe,nt;const ge=(Fe=document.activeElement)==null?void 0:Fe.tagName;ge==="INPUT"||ge==="TEXTAREA"||(nt=document.activeElement)!=null&&nt.isContentEditable||(se.value?fe():he())}),Ee.value=[{key:"title",title:P.$t("Title"),width:150,minWidth:100},{key:"sku",title:P.$t("SKU"),width:120,minWidth:80},{key:"media",title:P.$t("Media"),width:100,minWidth:50},{key:"categories",title:P.$t("Categories"),width:200,minWidth:150},{key:"description",title:P.$t("Description"),width:200,minWidth:150},{key:"short_description",title:P.$t("Short Description"),width:150,minWidth:100},{key:"status",title:P.$t("Status"),width:100,minWidth:50},{key:"product_type",title:P.$t("Product Type"),width:200,minWidth:150},{key:"pricing_type",title:P.$t("Pricing Type"),width:200,minWidth:150},{key:"payment_type",title:P.$t("Payment Type"),width:120,minWidth:100},{key:"interval",title:P.$t("Interval"),width:120,minWidth:80},{key:"trial_days",title:P.$t("Trial Days"),width:100,minWidth:70},{key:"best_price",title:P.$t("Best Price"),width:100,minWidth:100},{key:"compare_price",title:P.$t("Compare-at Price"),width:200,minWidth:150},{key:"track_quantity",title:P.$t("Track Quantity"),width:100,minWidth:100},{key:"stock",title:P.$t("Stock"),width:150,minWidth:150},{key:"actions",title:"",width:110,minWidth:110}],Ft.restoreColumnWidths(Ee.value),Ft.setupColumnVisibility(),Ft.fetchCategories(),document.body.classList.add("fct-bulk-page"),window.addEventListener("keydown",vt),window.addEventListener("keyup",Ye)}),vl(()=>{document.body.classList.remove("fct-bulk-page"),window.removeEventListener("keydown",vt),window.removeEventListener("keyup",Ye),jt&&jt.reset()}),(ge,Fe)=>{const nt=C("el-button"),bt=C("el-progress"),Bt=C("el-checkbox"),Wt=C("el-checkbox-group"),_t=C("el-tooltip"),la=C("el-popover"),sa=C("el-input"),Nt=C("el-icon"),ia=C("el-option"),el=C("el-select"),Ll=C("el-switch"),Ra=C("el-dialog");return r(),h("div",pge,[n(nl,{title:ge.$t("Bulk Insert")},{action:d(()=>[n(Eve,{onOnDataPopulated:q}),n(nt,{onClick:L},{default:d(()=>[R(m(ge.$t("Add Product")),1)]),_:1}),n(nt,{type:"primary",onClick:p,loading:s.value,disabled:s.value||A(a).length===0},{default:d(()=>[R(m(s.value?ge.$t("Saving %s/%s...").replace("%s",i.value.completed).replace("%s",i.value.total):ge.$t("Save All Products")),1)]),_:1},8,["loading","disabled"])]),_:1},8,["title"]),s.value?(r(),E(bt,{key:0,percentage:c.value,"stroke-width":6,class:"mb-4"},null,8,["percentage"])):B("",!0),n(Be,null,{default:d(()=>{var na;return[A(a).length>0?(r(),E(Qe,{key:0,title:((na=A(a))==null?void 0:na.length)===1?ge.$t("Product"):ge.$t("Products"),border_bottom:""},{action:d(()=>[o("div",fge,[n(nt,{disabled:A(ye)===0,onClick:U,size:"small",type:"danger",soft:""},{default:d(()=>[Fe[8]||(Fe[8]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("polyline",{points:"3 6 5 6 21 6"}),o("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)),R(" "+m(ge.$t("Delete")),1)]),_:1,__:[8]},8,["disabled"]),n(nt,{disabled:A(ye)===0,onClick:T,size:"small",type:"info",soft:""},{default:d(()=>[Fe[9]||(Fe[9]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),o("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})],-1)),R(" "+m(ge.$t("Duplicate")),1)]),_:1,__:[9]},8,["disabled"]),n(nt,{class:de({"is-active":A(se)}),disabled:A(ye)<2&&!A(se),onClick:A(fe),size:"small",type:"info",soft:""},{default:d(()=>[Fe[10]||(Fe[10]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})],-1)),R(" "+m(A(se)?ge.$t("Unlink"):ge.$t("Link")),1)]),_:1,__:[10]},8,["class","disabled","onClick"]),n(Bt,{modelValue:K.value,"onUpdate:modelValue":Fe[0]||(Fe[0]=Z=>K.value=Z),label:ge.$t("Pin Actions")},null,8,["modelValue","label"]),n(la,{trigger:"click",placement:"bottom-end",width:"240","popper-class":"filter-popover"},{reference:d(()=>[o("span",null,[n(_t,{effect:"light",content:ge.$t("Toggle columns"),placement:"top","popper-class":"fct-tooltip"},{default:d(()=>[n(Ze,{tag:"button",size:"small"},{default:d(()=>[n(J,{name:"ColumnIcon"})]),_:1})]),_:1},8,["content"])])]),default:d(()=>[o("div",mge,[o("h3",hge,m(ge.$t("Columns")),1),n(Wt,{modelValue:A(Ft).data.visibleColumns,"onUpdate:modelValue":Fe[1]||(Fe[1]=Z=>A(Ft).data.visibleColumns=Z),class:"fct-checkbox-blocks",onChange:Fe[2]||(Fe[2]=Z=>A(Ft).handleColumnVisibilityChange())},{default:d(()=>[(r(!0),h(H,null,ae(A(Ft).getToggleableColumns(),Z=>(r(),E(Bt,{key:Z.value,value:Z.value,label:ge.$t(Z.label)},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])]),_:1})])]),_:1},8,["title"])):B("",!0),n(Ce,{class:"p-0"},{default:d(()=>[A(a).length>0?(r(),h("div",{key:0,class:de(["relative",{"is-link-mode":A(se),"is-shift-held":Je.value}])},[n(uf,{columns:Oe.value,"sticky-last":K.value,onScroll:mt,onResizeEnd:gt},{"header-first":d(()=>[n(Bt,{"model-value":A(ye)>0&&A(ye)===$e.value.length,indeterminate:A(ye)>0&&A(ye)<$e.value.length,onChange:Fe[3]||(Fe[3]=Z=>A(j)($e.value))},null,8,["model-value","indeterminate"])]),"header-last":d(()=>[R(m(ge.$t("Actions")),1)]),default:d(()=>[St.value>0?(r(),h("tr",_ge,[o("td",{colspan:Oe.value.length+1,style:ua({height:St.value+"px",padding:0,border:"none"})},null,12,vge)])):B("",!0),(r(!0),h(H,null,ae(Ct.value,Z=>{var we,le,pe,je,at,Ke,qe,ft,Xe,Et,Xt,Ae,_e,Le,Ve;return r(),h(H,{key:Z.productId},[o("tr",{class:de(["bulk-product-row",{"is-saving":f(Z.product),"is-saved":_(Z.product),"has-product-error":y(Z.product),"is-selected":A(me)(`p:${Z.productId}`)}]),onClick:ee=>xe(`p:${Z.productId}`,ee)},[o("td",{class:"bulk-checkbox-cell",onClick:ee=>A(W)(`p:${Z.productId}`,ee,$e.value)},[n(Bt,{"model-value":A(me)(`p:${Z.productId}`),tabindex:"-1"},null,8,["model-value"])],8,yge),o("td",bge,[o("div",wge,[Z.hasVariants?(r(),h("button",{key:0,class:"bulk-collapse-btn",onClick:Ne(ee=>Mt(Z.product),["prevent"]),title:Ut(Z.product)?ge.$t("Expand variants"):ge.$t("Collapse variants")},[(r(),h("svg",{class:de(["bulk-collapse-icon",{"is-collapsed":Ut(Z.product)}]),width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},Fe[11]||(Fe[11]=[o("path",{d:"M6 4L10 8L6 12",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2)),Ut(Z.product)?(r(),h("span",kge,m(Z.variantCount),1)):B("",!0)],8,Cge)):B("",!0),n(sa,{class:de(["fct-bulk-input",{"is-error":S(Z.product,"post_title")}]),modelValue:Z.product.post_title,"onUpdate:modelValue":ee=>Z.product.post_title=ee,placeholder:ge.$t("Product title"),size:"small",disabled:g(Z.product),onInput:ee=>ve("title",ee,`p:${Z.productId}`)},null,8,["class","modelValue","onUpdate:modelValue","placeholder","disabled","onInput"]),f(Z.product)?(r(),h("span",{key:1,class:"bulk-status-icon is-syncing",title:ge.$t("Saving...")},[n(Nt,{class:"is-loading",size:14},{default:d(()=>[n(A(Xs))]),_:1})],8,Bge)):_(Z.product)?(r(),h("span",{key:2,class:"bulk-status-icon is-saved",title:ge.$t("Saved")},Fe[12]||(Fe[12]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16"},[o("path",{d:"M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-.997-6l7.07-7.071-1.414-1.414-5.656 5.657-2.829-2.829-1.414 1.414L11.003 16z"})],-1)]),8,xge)):b(Z.product)||l(Z.product)&&y(Z.product)?(r(),E(_t,{key:3,content:v(Z.product),placement:"top"},{default:d(()=>[o("span",Sge,[n(Nt,{size:16},{default:d(()=>[n(A(Uo))]),_:1})])]),_:2},1032,["content"])):B("",!0)])]),Me("sku")?(r(),h("td",Fge,[((le=(we=Z.product)==null?void 0:we.detail)==null?void 0:le.variation_type)==="simple"&&((pe=Z.product.variants)!=null&&pe[0])?(r(),E(sa,{key:0,class:de(["fct-bulk-input",{"is-error":S(Z.product,"variants.0.sku")}]),modelValue:Z.product.variants[0].sku,"onUpdate:modelValue":[ee=>Z.product.variants[0].sku=ee,ee=>ve("sku",ee,`p:${Z.productId}`)],placeholder:"SKU",size:"small",disabled:g(Z.product)},null,8,["class","modelValue","onUpdate:modelValue","disabled"])):(r(),h("span",$ge,"—"))])):B("",!0),Me("media")?(r(),h("td",Ege,[n(hl,{modelValue:Z.product.gallery,"onUpdate:modelValue":ee=>Z.product.gallery=ee,"show-url-tab":"",disabled:g(Z.product)},null,8,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0),Me("categories")?(r(),h("td",Uge,[n(cf,{modelValue:Z.product.categories,"onUpdate:modelValue":ee=>Z.product.categories=ee,options:A(Ft).data.categoryOptions,disabled:g(Z.product),onChange:ee=>{O(Z.product,ee),ve("categories",Z.product.categories,`p:${Z.productId}`)}},null,8,["modelValue","onUpdate:modelValue","options","disabled","onChange"])])):B("",!0),Me("description")?(r(),h("td",Ige,[n(Zo,{value:Z.product.post_content,placeholder:ge.$t("Description"),onClick:ee=>G(Z.product,"post_content")},null,8,["value","placeholder","onClick"])])):B("",!0),Me("short_description")?(r(),h("td",Qge,[n(Zo,{value:Z.product.post_excerpt,placeholder:ge.$t("Short description"),onClick:ee=>G(Z.product,"post_excerpt")},null,8,["value","placeholder","onClick"])])):B("",!0),Me("status")?(r(),h("td",Dge,[n(el,{modelValue:Z.product.post_status,"onUpdate:modelValue":ee=>Z.product.post_status=ee,size:"small",class:de({"is-field-error":S(Z.product,"post_status")}),disabled:g(Z.product),onChange:ee=>ve("status",Z.product.post_status,`p:${Z.productId}`)},{default:d(()=>[(r(!0),h(H,null,ae(A(t).status,ee=>(r(),E(ia,{key:ee.value,label:ge.$t(ee.title),value:ee.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):B("",!0),Me("product_type")&&((je=Z.product)!=null&&je.detail)?(r(),h("td",Vge,[n(el,{modelValue:Z.product.detail.fulfillment_type,"onUpdate:modelValue":ee=>Z.product.detail.fulfillment_type=ee,size:"small",class:de({"is-field-error":S(Z.product,"detail.fulfillment_type")}),disabled:g(Z.product),onChange:ee=>ve("product_type",Z.product.detail.fulfillment_type,`p:${Z.productId}`)},{default:d(()=>[(r(!0),h(H,null,ae(A(t).fulfilment,ee=>(r(),E(ia,{key:ee.value,label:ge.$t(ee.title),value:ee.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):Me("product_type")?(r(),h("td",Tge)):B("",!0),Me("pricing_type")&&((at=Z.product)!=null&&at.detail)?(r(),h("td",Mge,[n(el,{modelValue:Z.product.detail.variation_type,"onUpdate:modelValue":ee=>Z.product.detail.variation_type=ee,size:"small",class:de({"is-field-error":S(Z.product,"detail.variation_type")}),disabled:g(Z.product),onChange:ee=>{A(Ft).handleVariationChanged(Z.product,ee),ve("pricing_type",ee,`p:${Z.productId}`)}},{default:d(()=>[(r(!0),h(H,null,ae(A(t).variation,ee=>(r(),E(ia,{key:ee.value,label:ge.$t(ee.title),value:ee.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):Me("pricing_type")?(r(),h("td",Lge)):B("",!0),Me("payment_type")?(r(),h("td",Rge,[n(Yo,{variant:l(Z.product)?(Ke=Z.product.variants)==null?void 0:Ke[0]:null,disabled:g(Z.product),"has-error":S(Z.product,"variants.0.other_info.payment_type"),onPaymentTypeChange:ee=>{var He;I(ee),ve("payment_type",(He=ee.other_info)==null?void 0:He.payment_type,`p:${Z.productId}`)}},null,8,["variant","disabled","has-error","onPaymentTypeChange"])])):B("",!0),Me("interval")?(r(),h("td",Oge,[n(Wo,{variant:l(Z.product)?(qe=Z.product.variants)==null?void 0:qe[0]:null,disabled:g(Z.product),"has-error":S(Z.product,"variants.0.other_info.repeat_interval"),onChange:ee=>{var He,ut,Se;return ve("interval",(Se=(ut=(He=Z.product.variants)==null?void 0:He[0])==null?void 0:ut.other_info)==null?void 0:Se.repeat_interval,`p:${Z.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("trial_days")?(r(),h("td",Hge,[n(Jo,{variant:l(Z.product)?(ft=Z.product.variants)==null?void 0:ft[0]:null,disabled:g(Z.product),"has-error":S(Z.product,"variants.0.other_info.trial_days"),onChange:ee=>{var He,ut,Se;return ve("trial_days",(Se=(ut=(He=Z.product.variants)==null?void 0:He[0])==null?void 0:ut.other_info)==null?void 0:Se.trial_days,`p:${Z.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("best_price")?(r(),h("td",Pge,[n(qo,{variant:l(Z.product)?(Xe=Z.product.variants)==null?void 0:Xe[0]:null,disabled:g(Z.product),"has-error":S(Z.product,"variants.0.item_price"),onChange:ee=>{var He,ut;return ve("price",(ut=(He=Z.product.variants)==null?void 0:He[0])==null?void 0:ut.item_price,`p:${Z.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("compare_price")?(r(),h("td",Nge,[n(Xo,{variant:l(Z.product)?(Et=Z.product.variants)==null?void 0:Et[0]:null,disabled:g(Z.product),"has-error":S(Z.product,"variants.0.compare_price"),onChange:ee=>{var He,ut;return ve("compare_price",(ut=(He=Z.product.variants)==null?void 0:He[0])==null?void 0:ut.compare_price,`p:${Z.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("track_quantity")?(r(),h("td",Kge,[(Xt=Z.product)!=null&&Xt.detail?(r(),E(Ll,{key:0,modelValue:Z.product.detail.manage_stock,"onUpdate:modelValue":ee=>Z.product.detail.manage_stock=ee,"active-value":"1","inactive-value":"0",disabled:g(Z.product),onChange:ee=>{A(Ft).syncStockStatus(Z.product),ve("manage_stock",Z.product.detail.manage_stock,`p:${Z.productId}`)}},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])):B("",!0)])):B("",!0),Me("stock")?(r(),h("td",Gge,[((_e=(Ae=Z.product)==null?void 0:Ae.detail)==null?void 0:_e.manage_stock)==="1"&&((Ve=(Le=Z.product)==null?void 0:Le.detail)==null?void 0:Ve.variation_type)==="simple"?(r(),E(sa,{key:0,modelValue:Z.product.detail.total_stock,"onUpdate:modelValue":[ee=>Z.product.detail.total_stock=ee,ee=>{var He;(He=Z.product.variants)!=null&&He[0]&&(Z.product.variants[0].total_stock=ee,Z.product.variants[0].available=ee),A(Ft).syncStockStatus(Z.product),ve("stock",ee,`p:${Z.productId}`)}],disabled:g(Z.product),size:"small",placeholder:ge.$t("e.g 10")},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):(r(),h("span",jge,"—"))])):B("",!0),o("td",{class:de(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":K.value}])},[o("div",zge,[_(Z.product)&&Z.product.view_url?(r(),h("a",{key:0,href:Z.product.view_url,target:"_blank",class:"bulk-action-btn bulk-view-link",title:ge.$t("View Product")},[n(J,{name:"External"})],8,qge)):B("",!0),n(Ze,{tag:"button",size:"x-small",onClick:Ne(ee=>x(Z.product),["prevent"]),disabled:s.value||g(Z.product),title:ge.$t("Duplicate")},{default:d(()=>[n(J,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(Ze,{tag:"button",size:"x-small",hover:"danger",onClick:Ne(ee=>V(Z.product),["prevent"]),disabled:s.value||g(Z.product),title:ge.$t("Delete")},{default:d(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,gge),Z.hasVariants?(r(),h("tr",Yge,[o("td",{colspan:Oe.value.length+1,class:"!p-0 !border-b-0"},[n(va,{accordion:"",visible:!Z.collapsed,duration:200},{default:d(()=>[o("table",Jge,[o("colgroup",null,[Fe[13]||(Fe[13]=o("col",{style:{width:"40px"}},null,-1)),(r(!0),h(H,null,ae(Oe.value,(ee,He)=>(r(),h("col",{key:He,style:ua({width:ee.width+"px"})},null,4))),128))]),o("tbody",null,[(r(!0),h(H,null,ae(Z.product.variants,(ee,He)=>{var ut,Se;return r(),h("tr",{key:He,class:de(["bulk-variation-row",{"is-selected":A(me)(`v:${Z.productId}:${He}`)}]),onClick:kt=>xe(`v:${Z.productId}:${He}`,kt)},[o("td",Zge,[n(Bt,{"model-value":A(me)(`v:${Z.productId}:${He}`),tabindex:"-1",onChange:kt=>A(W)(`v:${Z.productId}:${He}`,kt,$e.value)},null,8,["model-value","onChange"])]),o("td",e1e,[o("div",t1e,[Fe[14]||(Fe[14]=o("span",{class:"text-gray-300 text-xs"},"└",-1)),n(sa,{size:"small",modelValue:ee.variation_title,"onUpdate:modelValue":[kt=>ee.variation_title=kt,kt=>ve("title",kt,`v:${Z.productId}:${He}`)],placeholder:ge.$t("Variation title"),disabled:g(Z.product),class:de({"is-error":$(Z.product,He,"variation_title")})},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),k(Z.product,He)?(r(),E(_t,{key:0,content:w(Z.product,He),placement:"top"},{default:d(()=>[o("span",a1e,[n(Nt,{size:14},{default:d(()=>[n(A(Uo))]),_:1})])]),_:2},1032,["content"])):B("",!0)])]),Me("sku")?(r(),h("td",l1e,[n(sa,{size:"small",modelValue:ee.sku,"onUpdate:modelValue":[kt=>ee.sku=kt,kt=>ve("sku",kt,`v:${Z.productId}:${He}`)],placeholder:"SKU",disabled:g(Z.product),class:de({"is-error":$(Z.product,He,"sku")})},null,8,["modelValue","onUpdate:modelValue","disabled","class"])])):B("",!0),Me("media")?(r(),h("td",s1e,[n(hl,{modelValue:ee.media,"onUpdate:modelValue":kt=>ee.media=kt,"show-url-tab":"",disabled:g(Z.product)},null,8,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0),Me("categories")?(r(),h("td",n1e,Fe[15]||(Fe[15]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("description")?(r(),h("td",o1e,Fe[16]||(Fe[16]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("short_description")?(r(),h("td",i1e,Fe[17]||(Fe[17]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("status")?(r(),h("td",r1e,Fe[18]||(Fe[18]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("product_type")?(r(),h("td",d1e,Fe[19]||(Fe[19]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("pricing_type")?(r(),h("td",u1e,Fe[20]||(Fe[20]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("payment_type")?(r(),h("td",c1e,[n(Yo,{variant:ee,disabled:g(Z.product),"has-error":$(Z.product,He,"other_info.payment_type"),onPaymentTypeChange:kt=>{var wa;I(kt),ve("payment_type",(wa=kt.other_info)==null?void 0:wa.payment_type,`v:${Z.productId}:${He}`)}},null,8,["variant","disabled","has-error","onPaymentTypeChange"])])):B("",!0),Me("interval")?(r(),h("td",A1e,[n(Wo,{variant:ee,disabled:g(Z.product),"has-error":$(Z.product,He,"other_info.repeat_interval"),onChange:kt=>{var wa;return ve("interval",(wa=ee.other_info)==null?void 0:wa.repeat_interval,`v:${Z.productId}:${He}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("trial_days")?(r(),h("td",p1e,[n(Jo,{variant:ee,disabled:g(Z.product),"has-error":$(Z.product,He,"other_info.trial_days"),onChange:kt=>{var wa;return ve("trial_days",(wa=ee.other_info)==null?void 0:wa.trial_days,`v:${Z.productId}:${He}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("best_price")?(r(),h("td",f1e,[n(qo,{variant:ee,disabled:g(Z.product),"has-error":$(Z.product,He,"item_price"),onChange:kt=>ve("price",ee.item_price,`v:${Z.productId}:${He}`)},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("compare_price")?(r(),h("td",m1e,[n(Xo,{variant:ee,disabled:g(Z.product),"has-error":$(Z.product,He,"compare_price"),onChange:kt=>ve("compare_price",ee.compare_price,`v:${Z.productId}:${He}`)},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Me("track_quantity")?(r(),h("td",h1e,Fe[21]||(Fe[21]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Me("stock")?(r(),h("td",_1e,[((Se=(ut=Z.product)==null?void 0:ut.detail)==null?void 0:Se.manage_stock)==="1"?(r(),E(sa,{key:0,class:"fc-bulk-input",size:"small",modelValue:ee.total_stock,"onUpdate:modelValue":[kt=>ee.total_stock=kt,kt=>{ee.available=kt,A(Ft).syncStockStatus(Z.product),ve("stock",kt,`v:${Z.productId}:${He}`)}],disabled:g(Z.product),placeholder:ge.$t("e.g 10")},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):(r(),h("span",v1e,"—"))])):B("",!0),o("td",{class:de(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":K.value}])},[o("div",g1e,[n(Ze,{tag:"button",size:"x-small",onClick:Ne(kt=>Q(Z.product,ee),["prevent"]),disabled:s.value||g(Z.product),title:ge.$t("Duplicate")},{default:d(()=>[n(J,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(Ze,{tag:"button",size:"x-small",hover:"danger",onClick:Ne(kt=>F(Z.product,ee),["prevent"]),disabled:s.value||g(Z.product),title:ge.$t("Delete")},{default:d(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,Xge)}),128)),o("tr",y1e,[o("td",{colspan:Oe.value.length+1},[o("div",w1e,[n(nt,{size:"small",text:"",type:"primary",onClick:Ne(ee=>A(Ft).addVariationToProduct(Z.product),["prevent"])},{default:d(()=>[R(" + "+m(ge.$t("Add Variant")),1)]),_:2},1032,["onClick"])])],8,b1e)])])])]),_:2},1032,["visible"])],8,Wge)])):B("",!0)],64)}),128)),Ot.value>0?(r(),h("tr",C1e,[o("td",{colspan:Oe.value.length+1,style:ua({height:Ot.value+"px",padding:0,border:"none"})},null,12,k1e)])):B("",!0)]),_:1},8,["columns","sticky-last"])],2)):(r(),E(wt,{key:1,icon:"Empty/ListView","has-dark":!0,text:A(u)("No products yet. Import a CSV or add products manually.")},null,8,["text"]))]),_:1})]}),_:1}),n(Ra,{modelValue:X.value.visible,"onUpdate:modelValue":Fe[6]||(Fe[6]=na=>X.value.visible=na),title:re.value,width:"700px","close-on-click-modal":!1,onClosed:Fe[7]||(Fe[7]=na=>X.value.product=null)},{footer:d(()=>[n(nt,{onClick:Fe[5]||(Fe[5]=na=>X.value.visible=!1)},{default:d(()=>[R(m(ge.$t("Cancel")),1)]),_:1}),n(nt,{type:"primary",onClick:ne},{default:d(()=>[R(m(ge.$t("Save")),1)]),_:1})]),default:d(()=>[X.value.visible&&X.value.field==="post_content"?(r(),E(es,{key:0,"model-value":X.value.value,height:300,onUpdate:te},null,8,["model-value"])):B("",!0),X.value.visible&&X.value.field==="post_excerpt"?(r(),E(sa,{key:1,modelValue:X.value.value,"onUpdate:modelValue":Fe[4]||(Fe[4]=na=>X.value.value=na),type:"textarea",rows:6,placeholder:ge.$t("Short description")},null,8,["modelValue","placeholder"])):B("",!0)]),_:1},8,["modelValue","title"])])}}};class F1e extends Ed{beforeInit(){this.data.products=[],this.data.dirty=new Set,this.data.loading=!1,this.data.saving=!1,this.data.pagination={page:1,per_page:5,total:0,hasMore:!1},this.data.saveProgress={total:0,completed:0,errors:[],updatedIds:[]},this.data.savingIds=new Set,this.data.savedIds=new Set,this.data.productErrors=new Map,this.data.advanceFilters=[[]],this.data.filterType="simple",this.data.selectedView="all",this.data.searching=!1,this.data.search="",this.data.duplicatingIds=new Set,this.data.deletingIds=new Set,this.data.categoryOptions=[],this.data.constrainedProductIds="",this.data.constrainedVariantIds="",this.data.savedViews=[],this.data.activeSavedViewId=null,this.data.savedViewQueryParams=null}getTabs(){return{all:u("All"),publish:u("Published"),draft:u("Draft"),physical:u("Physical"),digital:u("Digital")}}getTabsCount(){return Object.values(this.getTabs()).length}getSelectedTab(){return this.data.selectedView}handleTabChanged(t){t!==this.data.selectedView&&(this.data.selectedView=t,this.fetchProducts({},!1))}isSearching(){return this.data.searching!==!1}openSearch(){this.data.searching=!0}closeSearch(){this.data.searching=!1,this.data.search="",this.fetchProducts({},!1)}search(){this.fetchProducts({},!1)}useFullWidthSearch(){return!1}getSearchHint(){return u("Search by Id, product title or variation title")}getSearchGuideOptions(){return null}isUsingAdvanceFilter(){return this.data.filterType==="advanced"}isUsingSimpleFilter(){return this.data.filterType==="simple"}isAdvanceFilterEnabled(){return this.getAdvanceFilterOptions()!==null}getAdvanceFilterOptions(){var t,a,l;return((l=(a=(t=window.fluentCartAdminApp)==null?void 0:t.filter_options)==null?void 0:a.product_filter_options)==null?void 0:l.advance)||null}onFilterTypeChanged(t){t==="advanced"?(this.data.searching=!1,this.data.search=""):this.data.advanceFilters=[[]],this.fetchProducts({},!1)}applyAdvancedFilter(t=!1){this.fetchProducts({},!1)}addAdvanceFilterGroup(){this.data.advanceFilters.push([])}removeAdvanceFilterGroup(t){this.data.advanceFilters.length>1&&this.data.advanceFilters.splice(t,1)}clearAdvanceFilter(){this.data.advanceFilters=[[]],this.fetchProducts({},!1)}getColumnWidthStorageKey(){return"bulk_edit_column_widths"}getColumnStorageKey(){return"bulk_edit_columns"}getToggleableColumns(){return[{label:"Image",value:"image"},{label:"SKU",value:"sku"},{label:"Categories",value:"categories"},{label:"Description",value:"description"},{label:"Short Description",value:"short_description"},{label:"Status",value:"status"},{label:"Product Type",value:"product_type"},{label:"Pricing Type",value:"pricing_type"},{label:"Payment Type",value:"payment_type"},{label:"Interval",value:"interval"},{label:"Trial Days",value:"trial_days"},{label:"Best Price",value:"best_price"},{label:"Compare-at Price",value:"compare_price"},{label:"Track Quantity",value:"track_quantity"},{label:"Stock",value:"stock"}]}getSortableColumns(){return[]}markDirty(t){this._suppressDirty||(this.data.dirty.add(t),this.data.dirty=new Set(this.data.dirty),this.data.savedIds.has(t)&&(this.data.savedIds.delete(t),this.data.savedIds=new Set(this.data.savedIds)),this.data.productErrors.has(t)&&(this.data.productErrors.delete(t),this.data.productErrors=new Map(this.data.productErrors)))}get dirtyCount(){return this.data.dirty.size}getDirtyProducts(){return this.data.products.filter(t=>this.data.dirty.has(t.ID))}chunkArray(t,a){const l=[];for(let s=0;s{this._suppressDirty=!1}),this.data.pagination={page:_.page||f.page,per_page:_.per_page||f.per_page,total:_.total||0,hasMore:_.page*_.per_page<_.total}}catch(c){const p=((i=c==null?void 0:c.data)==null?void 0:i.message)||"Failed to fetch products";z.error(p)}finally{this.data.loading=!1}}isSavingProduct(t){return this.data.savingIds.has(t)}isDirty(t){return this.data.dirty.has(t)}isSaved(t){return this.data.savedIds.has(t)}isRowDisabled(t){return this.isSavingProduct(t)}isDuplicating(t){return this.data.duplicatingIds.has(t)}isDeleting(t){return this.data.deletingIds.has(t)}hasError(t){return this.data.productErrors.has(t)}getError(t){const a=this.data.productErrors.get(t);return a?a.fields&&Object.keys(a.fields).length?Object.values(a.fields).join("; "):a.message||"":""}hasProductLevelError(t){const a=this.data.productErrors.get(t);return a?!a.fields||!Object.keys(a.fields).length?!!a.message:Object.keys(a.fields).some(l=>!l.startsWith("variants.")):!1}getProductLevelError(t){const a=this.data.productErrors.get(t);return a?!a.fields||!Object.keys(a.fields).length?a.message||"":Object.entries(a.fields).filter(([s])=>!s.startsWith("variants.")).map(([,s])=>s).join("; ")||"":""}hasVariantError(t,a){const l=this.data.productErrors.get(t);if(!(l!=null&&l.fields))return!1;const s=`variants.${a}.`;return Object.keys(l.fields).some(i=>i.startsWith(s))}getVariantError(t,a){const l=this.data.productErrors.get(t);if(!(l!=null&&l.fields))return"";const s=`variants.${a}.`;return Object.entries(l.fields).filter(([c])=>c.startsWith(s)).map(([,c])=>c).join("; ")}hasFieldError(t,a){var s;const l=this.data.productErrors.get(t);return!!((s=l==null?void 0:l.fields)!=null&&s[a])}hasVariantFieldError(t,a,l){return this.hasFieldError(t,`variants.${a}.${l}`)}async saveProduct(t){var l,s,i,c;const a=t.ID;if(!this.data.savingIds.has(a)){this.data.savingIds.add(a),this.data.savingIds=new Set(this.data.savingIds);try{const p=await ue.post("products/bulk-update",{products:[t]});if((l=p.updated)!=null&&l.length)this.data.dirty.delete(a),this.data.dirty=new Set(this.data.dirty),this.data.savedIds.add(a),this.data.savedIds=new Set(this.data.savedIds),this.data.productErrors.delete(a),this.data.productErrors=new Map(this.data.productErrors),z.success(u("Product updated successfully"));else if((s=p.errors)!=null&&s.length){const f=p.errors[0];f!=null&&f.fields&&(this.data.productErrors.set(a,f),this.data.productErrors=new Map(this.data.productErrors)),z.error((f==null?void 0:f.message)||"Failed to save product")}}catch(p){const f=((i=p==null?void 0:p.data)==null?void 0:i.message)||"Failed to save product",_=(c=p==null?void 0:p.data)==null?void 0:c.errors;if(_!=null&&_.length){const g=_[0];g!=null&&g.fields&&(this.data.productErrors.set(a,g),this.data.productErrors=new Map(this.data.productErrors))}z.error(f)}finally{this.data.savingIds.delete(a),this.data.savingIds=new Set(this.data.savingIds)}}}async saveProducts(){var l,s;const t=this.getDirtyProducts().filter(i=>!this.data.savedIds.has(i.ID));if(t.length===0){z.info(u("No changes to save"));return}const a=this.chunkArray(t,10);this.data.saving=!0,this.data.saveProgress={total:a.length,completed:0,errors:[],updatedIds:[]};try{for(const p of a){const f=p.map(_=>_.ID);for(const _ of f)this.data.savingIds.add(_);this.data.savingIds=new Set(this.data.savingIds);try{const _=await ue.post("products/bulk-update",{products:p});if(_.updated){this.data.saveProgress.updatedIds.push(..._.updated);for(const g of _.updated)this.data.savedIds.add(g),this.data.dirty.delete(g),this.data.productErrors.delete(g);this.data.savedIds=new Set(this.data.savedIds),this.data.dirty=new Set(this.data.dirty),this.data.productErrors=new Map(this.data.productErrors)}if(_.errors&&_.errors.length){this.data.saveProgress.errors.push(..._.errors);for(const g of _.errors)g.post_id&&g.fields&&this.data.productErrors.set(g.post_id,g);this.data.productErrors=new Map(this.data.productErrors)}}catch(_){const g=((l=_==null?void 0:_.data)==null?void 0:l.message)||"A chunk failed to save";this.data.saveProgress.errors.push({message:g});const y=(s=_==null?void 0:_.data)==null?void 0:s.errors;if(y!=null&&y.length){for(const v of y)v.post_id&&v.fields&&this.data.productErrors.set(v.post_id,v);this.data.productErrors=new Map(this.data.productErrors)}}for(const _ of f)this.data.savingIds.delete(_);this.data.savingIds=new Set(this.data.savingIds),this.data.saveProgress.completed++}const{updatedIds:i,errors:c}=this.data.saveProgress;c.length===0?z.success(`${i.length} product(s) updated successfully`):i.length>0?z.info(`${i.length} product(s) updated, ${c.length} error(s)`):z.error(u("All products failed to save"))}finally{this.data.saving=!1}}async duplicateProduct(t){var l;const a=t.ID;if(!(!a||this.data.duplicatingIds.has(a))){this.data.duplicatingIds.add(a),this.data.duplicatingIds=new Set(this.data.duplicatingIds);try{const i=(await ue.post(`products/${a}/duplicate`,{})).product_id;if(i){const p=(await ue.get("products/bulk-edit-data",{search:i,per_page:1})).products||[];if(p.length>0){const f=this.data.products.indexOf(t);this.data.products.splice(f+1,0,p[0])}}}catch(s){const i=((l=s==null?void 0:s.data)==null?void 0:l.message)||"Failed to duplicate product";z.error(i)}finally{this.data.duplicatingIds.delete(a),this.data.duplicatingIds=new Set(this.data.duplicatingIds)}}}async duplicateProductWithVariants(t,a){var s;const l=t.ID;if(!(!l||this.data.duplicatingIds.has(l))){this.data.duplicatingIds.add(l),this.data.duplicatingIds=new Set(this.data.duplicatingIds);try{const c=(await ue.post(`products/${l}/duplicate`,{})).product_id;if(!c)return;const f=(await ue.get("products/bulk-edit-data",{search:c,per_page:1})).products||[];if(!f.length)return;const _=f[0],g=t.variants||[],y=new Set;for(const b of g)a.includes(b.id)&&b.serial_index!=null&&y.add(b.serial_index);_.variants&&y.size>0&&(_.variants=_.variants.filter(b=>y.has(b.serial_index)));const v=this.data.products.indexOf(t);this.data.products.splice(v+1,0,_),this.markDirty(_.ID)}catch(i){const c=((s=i==null?void 0:i.data)==null?void 0:s.message)||"Failed to duplicate product";z.error(c)}finally{this.data.duplicatingIds.delete(l),this.data.duplicatingIds=new Set(this.data.duplicatingIds)}}}duplicateVariant(t,a){const l=JSON.parse(JSON.stringify(a));l.variation_title=l.variation_title?l.variation_title+" (Copy)":"",l.sku="",delete l.id,delete l.post_id;const s=t.variants.indexOf(a);t.variants.splice(s+1,0,l),this.markDirty(t.ID)}async deleteProduct(t){var l;const a=t.ID;if(!(!a||this.data.deletingIds.has(a))){this.data.deletingIds.add(a),this.data.deletingIds=new Set(this.data.deletingIds);try{await ue.delete(`products/${a}`);const s=this.data.products.indexOf(t);s!==-1&&this.data.products.splice(s,1),this.data.dirty.delete(a),this.data.savedIds.delete(a)}catch(s){const i=((l=s==null?void 0:s.data)==null?void 0:l.message)||"Failed to delete product";z.error(i)}finally{this.data.deletingIds.delete(a),this.data.deletingIds=new Set(this.data.deletingIds)}}}removeVariant(t,a){if(t.variants.length<=1)return z.error(u("A product must have at least one variant.")),!1;const l=t.variants.indexOf(a);return l!==-1&&t.variants.splice(l,1),this.markDirty(t.ID),!0}resetPaymentTypeDefaults(t){t.other_info.payment_type==="onetime"&&(t.other_info.installment="no",t.other_info.times="",t.other_info.manage_setup_fee="no",t.other_info.signup_fee="",t.other_info.signup_fee_name="")}flattenCategoryTree(t,a=""){var s;const l=[];for(const i of t){const c=a?`${a} > ${i.label}`:i.label;l.push({label:c,value:c}),(s=i.children)!=null&&s.length&&l.push(...this.flattenCategoryTree(i.children,c))}return l}async fetchCategories(){try{const a=(await ue.get("products/fetch-term")).taxonomies||{},l=Object.values(a).find(s=>s.name==="product-categories");l!=null&&l.terms&&(this.data.categoryOptions=this.flattenCategoryTree(l.terms))}catch{}}setupSavedViews(){var a,l;const t=(a=window.fluentCartAdminApp)==null?void 0:a.table_config;this.data.savedViews=((l=t==null?void 0:t.products)==null?void 0:l.saved_views)||[]}getSavedViews(){return this.data.savedViews}getActiveSavedViewId(){return this.data.activeSavedViewId}applySavedView(t){const a=this.data.savedViews.find(l=>l.slug===t);a&&(this.data.activeSavedViewId=t,this.data.savedViewQueryParams=a.query_params)}isViewOwner(t){var a,l;return!t||!t.owner_id?!1:t.owner_id===((l=(a=window.fluentCartAdminApp)==null?void 0:a.me)==null?void 0:l.id)}renameSavedView(t,a){}updateSavedView(t){}deleteSavedView(t){}}const st=F1e.init(),$1e={class:"fct-bulk-edit-page fct-layout-width"},E1e={class:"fct-table-wrapper"},U1e={class:"fct-card-header-top"},I1e={class:"fct-card-header-left flex-1"},Q1e={class:"fct-card-header-actions"},D1e={key:0,class:"fct-advanced-filter-toggle-wrapper"},V1e={key:1,class:"fct-btn-group sm hidden md:flex"},T1e={key:0,class:"filter-search-wrap"},M1e={class:"search-bar"},L1e={class:"text-xs text-system-light pt-2 dark:text-gray-300"},R1e={class:"fct-bulk-edit-table-wrap"},O1e={key:0,class:"px-5 py-3 flex items-center justify-between border border-solid border-x-0 border-gray-divider border-t-0 dark:border-dark-400"},H1e={class:"m-0 text-base"},P1e={key:0,class:"text-system-mid text-sm font-normal dark:text-gray-300"},N1e={class:"fct-btn-group sm justify-end"},K1e={class:"filter-popover-item"},G1e={class:"filter-popover-title"},j1e={class:"fct-bulk-edit-table"},z1e={key:0,"aria-hidden":"true"},q1e=["colspan"],Y1e=["onClick"],W1e=["onClick"],J1e={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},X1e={class:"flex items-center"},Z1e=["onClick","title"],eye={key:0,class:"bulk-collapse-count"},tye=["title"],aye={class:"bulk-status-icon is-error"},lye=["disabled","onClick","title"],sye={key:0,class:"fct-bulk-media-cell"},nye={key:1,class:"fct-bulk-sku-cell"},oye={key:1,class:"text-gray-300 text-sm flex justify-center"},iye={key:2,class:"fct-bulk-categories-cell"},rye={key:3,class:"fct-bulk-desc-cell"},dye={key:4,class:"fct-bulk-short-desc-cell"},uye={key:5,class:"fct-bulk-status-cell"},cye={key:6,class:"fct-bulk-product-type-cell"},Aye={class:"bulk-readonly-label"},pye={key:7,class:"fct-bulk-pricing-type-cell"},fye={class:"bulk-readonly-label"},mye={key:8,class:"fct-bulk-payment-type-cell"},hye={key:9,class:"fct-bulk-interval-cell"},_ye={key:10,class:"fct-bulk-trial-days-cell"},vye={key:11,class:"fct-bulk-best-price-cell"},gye={key:12,class:"fct-bulk-compare-price-cell"},yye={key:13,class:"fct-bulk-qty-cell !pl-5"},bye={key:14,class:"fct-bulk-stock-cell"},wye={key:1,class:"text-gray-300 text-sm flex justify-center"},Cye={class:"fct-btn-group sm justify-end"},kye={key:0,class:"bulk-variants-block-row"},Bye=["colspan"],xye={class:"bulk-inner-table",style:{tableLayout:"fixed",width:"100%",borderCollapse:"collapse"}},Sye=["onClick"],Fye={class:"bulk-checkbox-cell"},$ye={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},Eye={class:"flex items-center gap-1 pl-4"},Uye={class:"bulk-status-icon is-error"},Iye={key:0},Qye={key:1},Dye={key:2},Vye={key:3},Tye={key:4},Mye={key:5},Lye={key:6},Rye={key:7},Oye={key:8},Hye={key:9},Pye={key:10},Nye={key:11},Kye={key:12},Gye={key:13,class:"text-center"},jye={key:14},zye={key:1,class:"text-gray-300 text-sm flex justify-center"},qye={class:"fct-btn-group sm justify-end"},Yye={key:1,"aria-hidden":"true"},Wye=["colspan"],Jye={key:1,class:"flex flex-col items-center justify-center py-16 text-center"},Xye={class:"text-system-mid text-sm"},Zye={key:2,class:"flex items-center justify-center py-8"},ebe={class:"text-system-mid text-sm"},tbe={key:1,class:"flex items-center justify-center py-3 border-top"},abe={class:"text-system-mid text-sm"},rr=43,lbe=10,bc=800,wc=100,sbe=200,nbe={__name:"BulkEdit",setup(e){const t=Yt().ctx,a=sl(),{options:l}=st.data,s=le=>{var pe;return((pe=le==null?void 0:le.detail)==null?void 0:pe.variation_type)==="simple"},i=N(()=>st.data.products),c=N(()=>st.data.loading),p=N(()=>st.data.saving),f=N(()=>st.data.saveProgress),_=N(()=>st.data.pagination),g=N(()=>st.data.dirty),y=N(()=>g.value.size),v=N(()=>Math.max(0,_.value.total-i.value.length)),b=N(()=>Math.min(_.value.per_page,v.value)),k=N(()=>{const le=st.data.saveProgress;return le.total?Math.round(le.completed/le.total*100):0}),w=Xr("search-input"),S=()=>{st.openSearch(),ke(()=>{var le;(le=w.value)==null||le.focus()})},$=(le=!1)=>{st.fetchProducts({},le)},V=()=>{st.saveProducts()},F=le=>{st.markDirty(le.ID)},x=(le,pe)=>{st.resetPaymentTypeDefaults(pe),F(le)},Q=(le,pe)=>{const je=st.data.categoryOptions;for(const at of pe)je.find(Ke=>Ke.value===at)||je.push({label:at,value:at});F(le)},D=le=>st.isDirty(le.ID),T=le=>st.isSavingProduct(le.ID),U=le=>st.isSaved(le.ID),I=le=>st.isRowDisabled(le.ID),O=le=>st.isDuplicating(le.ID),L=le=>st.isDeleting(le.ID),P=le=>st.hasError(le.ID),q=le=>st.getError(le.ID),X=le=>st.hasProductLevelError(le.ID),G=(le,pe)=>st.hasVariantError(le.ID,pe),te=(le,pe)=>st.getVariantError(le.ID,pe),ne=(le,pe)=>st.hasFieldError(le.ID,pe),re=(le,pe,je)=>st.hasVariantFieldError(le.ID,pe,je),K=le=>st.saveProduct(le),Y=le=>st.duplicateProduct(le),W=(le,pe)=>st.duplicateVariant(le,pe),j=M(!0),{selectedKeys:ie,handleRowClick:he,toggleSelectAll:me,selectAll:ye,deselectAll:se,isSelected:fe,selectedCount:$e,isLinkMode:tt,toggleLinkMode:ve}=Af(),Je=N(()=>{const le=[];for(const pe of Bt.value)if(le.push(`p:${pe.productId}`),pe.hasVariants&&!pe.collapsed)for(const je of pe.product.variants)le.push(`v:${je.id}`);return le}),vt=le=>{var pe;if(le.startsWith("p:")){const je=parseInt(le.slice(2)),at=Bt.value.find(Ke=>Ke.productId===je);return at?{type:"product",data:at.product,product:at.product}:null}else if(le.startsWith("v:")){const je=parseInt(le.slice(2));for(const at of Bt.value){const Ke=(pe=at.product.variants)==null?void 0:pe.find(qe=>qe.id===je);if(Ke)return{type:"variant",data:Ke,product:at.product}}}return null},Ye=(le,pe,je)=>{!tt.value||!fe(je)||ff(le,pe,je,ie.value,vt,F,Age)},xe=M(!1),Ee=le=>{le.key==="Shift"&&(xe.value=!0)},Oe=le=>{le.key==="Shift"&&(xe.value=!1)},Me=(le,pe)=>{if(!pe.shiftKey||pe.target.closest(".bulk-checkbox-cell"))return;pe.preventDefault();const je=new Set(ie.value);je.has(le)?je.delete(le):je.add(le),ie.value=je},gt=()=>{const le=[];for(const pe of Bt.value){const je=`p:${pe.productId}`,at=ie.value.has(je),Ke=[];if(pe.product.variants)for(const qe of pe.product.variants)ie.value.has(`v:${qe.id}`)&&Ke.push(qe.id);!at&&Ke.length===0||(at&&Ke.length===0?le.push({product:pe.product,type:"full"}):!at&&Ke.length>0?le.push({product:pe.product,type:"variants-only",variantIds:Ke}):le.push({product:pe.product,type:"partial",variantIds:Ke}))}return le},yt=async()=>{const le=gt();if(!le.length)return;const pe=le.filter(ft=>ft.type==="full").length,je=le.filter(ft=>ft.type==="partial").length,Ke=le.filter(ft=>ft.type==="variants-only").reduce((ft,Xe)=>ft+Xe.variantIds.length,0),qe=[];pe>0&&qe.push(`${pe} product(s) with all variants`),je>0&&qe.push(`${je} product(s) with selected variants`),Ke>0&&qe.push(`${Ke} variant(s)`);try{await xl.confirm(t.$t("Duplicate %s?").replace("%s",qe.join(", ")),t.$t("Bulk Duplicate"),{confirmButtonText:t.$t("Duplicate"),cancelButtonText:t.$t("Cancel"),type:"info"})}catch{return}for(const ft of le)if(ft.type==="full")await st.duplicateProduct(ft.product);else if(ft.type==="variants-only")for(const Xe of ft.variantIds){const Et=ft.product.variants.find(Xt=>Xt.id===Xe);Et&&st.duplicateVariant(ft.product,Et)}else ft.type==="partial"&&await st.duplicateProductWithVariants(ft.product,ft.variantIds);se()},Mt=async()=>{const le=[],pe=[];for(const Ke of Bt.value){const qe=`p:${Ke.productId}`;if(ie.value.has(qe)){le.push(Ke.product);continue}const Xe=[];if(Ke.product.variants)for(const Et of Ke.product.variants)ie.value.has(`v:${Et.id}`)&&Xe.push(Et);Xe.length>0&&pe.push({product:Ke.product,variants:Xe})}if(!le.length&&!pe.length)return;const je=pe.reduce((Ke,qe)=>Ke+qe.variants.length,0),at=[];le.length>0&&at.push(`${le.length} product(s)`),je>0&&at.push(`${je} variant(s)`);try{await xl.confirm(t.$t("Permanently delete %s? This cannot be undone.").replace("%s",at.join(" and ")),t.$t("Bulk Delete"),{confirmButtonText:t.$t("Delete"),cancelButtonText:t.$t("Cancel"),type:"warning"})}catch{return}for(const Ke of le)await st.deleteProduct(Ke);for(const{product:Ke,variants:qe}of pe)for(const ft of qe)st.removeVariant(Ke,ft);se()},Ut=async le=>{const pe=le.ID;if(!pe||st.isDeleting(pe))return;const je=le.post_title||t.$t("Untitled product"),at=Array.isArray(le.variants)?le.variants.length:0,Ke=at>0?t.$t('This will permanently delete "%1$s" and its %2$s variant(s).',je,at):t.$t('This will permanently delete "%1$s".',je);try{await xl.confirm(Ke,t.$t("Delete Product"),{confirmButtonText:t.$t("Delete"),cancelButtonText:t.$t("Cancel"),type:"warning"})}catch{return}st.deleteProduct(le)},Dt=(le,pe)=>{if(le.variants.length<=1){st.removeVariant(le,pe);return}const je=pe.variation_title||t.$t("Untitled variant");xl.confirm(t.$t('This will remove the variant "%1$s".',je),t.$t("Remove Variant"),{confirmButtonText:t.$t("Remove"),cancelButtonText:t.$t("Cancel"),type:"warning"}).then(()=>{st.removeVariant(le,pe)}).catch(()=>{})},ht=M({visible:!1,field:"",product:null,value:""}),Pt=(le,pe)=>{ht.value={visible:!0,field:pe,product:le,value:le[pe]||""}},Ct=le=>{ht.value.value=le},St=()=>{const{product:le,field:pe,value:je}=ht.value;le&&(le[pe]=je,F(le)),ht.value.visible=!1},Ot=N(()=>ht.value.field==="post_content"?t.$t("Edit Description"):t.$t("Edit Short Description")),Ht=M([]),It=N(()=>Ht.value.filter(le=>le.key==="title"||le.key==="actions"?!0:st.isColumnVisible(le.key))),mt=le=>st.isColumnVisible(le),jt=()=>{st.saveColumnWidths(Ht.value)},ge=M(new Set),Fe=le=>{const pe=le.ID;ge.value.has(pe)?ge.value.delete(pe):ge.value.add(pe),ge.value=new Set(ge.value)},nt=le=>ge.value.has(le.ID),bt=M(0),Bt=N(()=>{let le=0;return i.value.map(pe=>{var Xt;const je=pe.ID,at=((Xt=pe.detail)==null?void 0:Xt.variation_type)!=="simple"&&Array.isArray(pe.variants)&&pe.variants.length>0,Ke=at?pe.variants.length:0,qe=ge.value.has(je),ft=at&&!qe?Ke*rr:0,Xe=rr+ft,Et={product:pe,productId:je,hasVariants:at,variantCount:Ke,collapsed:qe,groupHeight:Xe,offset:le};return le+=Xe,Et})}),Wt=N(()=>{const le=Bt.value;if(le.length===0)return 0;const pe=le[le.length-1];return pe.offset+pe.groupHeight}),_t=N(()=>{const le=Bt.value,pe=bt.value,je=pe+bc,at=lbe*rr;return le.filter(Ke=>Ke.offset+Ke.groupHeight>=pe-at&&Ke.offset<=je+at)}),la=N(()=>_t.value.length===0?0:_t.value[0].offset),sa=N(()=>{if(_t.value.length===0)return 0;const le=_t.value[_t.value.length-1];return Wt.value-le.offset-le.groupHeight});let Nt=null,ia=0;const el=()=>{if(c.value||!_.value.hasMore||i.value.length===0)return;Wt.value-(bt.value+bc){const pe=le.target,je=Date.now();Nt&&clearTimeout(Nt),je-ia>=wc?(bt.value=pe.scrollTop,ia=je,el()):Nt=setTimeout(()=>{bt.value=pe.scrollTop,ia=Date.now(),Nt=null,el()},wc)},Ra=le=>({physical:"Physical",digital:"Digital"})[le]||le||"—",na=le=>({simple:"Simple",simple_variations:"Variable"})[le]||le||"—";let Z=null;const we=()=>{const le=a.query.product_ids,pe=a.query.variant_ids;le&&pe?st.fetchProducts({},!1,le,pe):$(!1)};return Ie(async()=>{Z=_s(),Z.bind("mod+a",le=>{var je,at;const pe=(je=document.activeElement)==null?void 0:je.tagName;pe==="INPUT"||pe==="TEXTAREA"||(at=document.activeElement)!=null&&at.isContentEditable||(le.preventDefault(),ye(Je.value))}),Z.bind("escape",()=>{var pe,je;const le=(pe=document.activeElement)==null?void 0:pe.tagName;le==="INPUT"||le==="TEXTAREA"||(je=document.activeElement)!=null&&je.isContentEditable||(tt.value?ve():se())}),Ht.value=[{key:"title",title:t.$t("Title"),width:150,minWidth:100},{key:"image",title:t.$t("Image"),width:60,minWidth:50},{key:"sku",title:t.$t("SKU"),width:120,minWidth:80},{key:"categories",title:t.$t("Categories"),width:200,minWidth:150},{key:"description",title:t.$t("Description"),width:200,minWidth:150},{key:"short_description",title:t.$t("Short Description"),width:150,minWidth:100},{key:"status",title:t.$t("Status"),width:100,minWidth:50},{key:"product_type",title:t.$t("Product Type"),width:120,minWidth:80},{key:"pricing_type",title:t.$t("Pricing Type"),width:120,minWidth:80},{key:"payment_type",title:t.$t("Payment Type"),width:120,minWidth:100},{key:"interval",title:t.$t("Interval"),width:120,minWidth:80},{key:"trial_days",title:t.$t("Trial Days"),width:100,minWidth:70},{key:"best_price",title:t.$t("Best Price"),width:100,minWidth:100},{key:"compare_price",title:t.$t("Compare-at Price"),width:150,minWidth:100},{key:"track_quantity",title:t.$t("Track Quantity"),width:100,minWidth:100},{key:"stock",title:t.$t("Stock"),width:120,minWidth:80},{key:"actions",title:"",width:110,minWidth:110}],st.restoreColumnWidths(Ht.value),st.setupColumnVisibility(),st.setupSavedViews(),st.fetchCategories(),we(),document.body.classList.add("fct-bulk-page"),window.addEventListener("keydown",Ee),window.addEventListener("keyup",Oe)}),vl(()=>{document.body.classList.remove("fct-bulk-page"),window.removeEventListener("keydown",Ee),window.removeEventListener("keyup",Oe),Z&&Z.reset()}),(le,pe)=>{const je=C("el-button"),at=C("el-progress"),Ke=C("el-switch"),qe=C("el-tooltip"),ft=C("el-input"),Xe=C("el-checkbox"),Et=C("el-checkbox-group"),Xt=C("el-popover"),Ae=C("el-icon"),_e=C("el-option"),Le=C("el-select"),Ve=C("el-dialog");return r(),h("div",$1e,[n(nl,{title:le.$t("Bulk Edit")},{action:d(()=>[n(je,{type:"primary",onClick:V,loading:p.value,disabled:p.value||y.value===0},{default:d(()=>[R(m(p.value?le.$t("Saving %s/%s...").replace("%s",f.value.completed).replace("%s",f.value.total):y.value>0?le.$t("Save Changes")+` (${y.value})`:le.$t("Save Changes")),1)]),_:1},8,["loading","disabled"])]),_:1},8,["title"]),p.value?(r(),E(at,{key:0,percentage:k.value,"stroke-width":6,class:"mb-4"},null,8,["percentage"])):B("",!0),o("div",E1e,[n(Be,null,{default:d(()=>[n(Qe,{border_bottom:""},{default:d(()=>[o("div",U1e,[o("div",I1e,[A(st).getTabsCount()&&!A(st).isUsingAdvanceFilter()?(r(),E(Nf,{key:0,class:de("hide-animation-on-mobile hidden md:inline-flex classic-tab-style"),table:A(st)},null,8,["table"])):B("",!0)]),o("div",Q1e,[A(st).isAdvanceFilterEnabled()?(r(),h("div",D1e,[n(Ke,{class:"fct-advanced-filter-toggle",onChange:pe[0]||(pe[0]=ee=>{A(st).onFilterTypeChanged(ee)}),"active-value":"advanced","inactive-value":"simple",modelValue:A(st).data.filterType,"onUpdate:modelValue":pe[1]||(pe[1]=ee=>A(st).data.filterType=ee),"active-text":le.$t("Advanced Filter"),size:"small"},null,8,["modelValue","active-text"])])):B("",!0),A(st).isUsingAdvanceFilter()?B("",!0):(r(),h("div",V1e,[A(st).isSearching()?B("",!0):(r(),E(qe,{key:0,effect:"light",content:le.$t("Search"),placement:"top","popper-class":"fct-tooltip"},{default:d(()=>[n(Ze,{tag:"button",onClick:Ne(S,["prevent"])},{default:d(()=>[n(J,{name:"Search"})]),_:1})]),_:1},8,["content"]))]))])]),n(Mc,{table:A(st)},null,8,["table"]),A(st).isSearching()&&!A(st).isUsingAdvanceFilter()?(r(),h("div",T1e,[o("div",M1e,[n(ft,{ref:"search-input",onClear:pe[2]||(pe[2]=()=>{A(st).search()}),onKeyup:pe[3]||(pe[3]=xa(()=>{A(st).search()},["enter"])),modelValue:A(st).data.search,"onUpdate:modelValue":pe[4]||(pe[4]=ee=>A(st).data.search=ee),type:"text",placeholder:le.$t("Search"),clearable:""},{prefix:d(()=>[n(J,{name:"Search"})]),_:1},8,["modelValue","placeholder"]),o("div",L1e,m(A(st).getSearchHint()),1)]),n(je,{text:"",onClick:pe[5]||(pe[5]=()=>{A(st).closeSearch()})},{default:d(()=>[R(m(le.$t("Cancel")),1)]),_:1})])):B("",!0)]),_:1}),n(Ce,{class:"p-0"},{default:d(()=>[o("div",R1e,[i.value.length>0?(r(),h("div",O1e,[o("h5",H1e,[R(m(i.value.length)+" "+m(i.value.length===1?le.$t("Product"):le.$t("Products"))+" ",1),_.value.total>i.value.length?(r(),h("span",P1e,m(le.$t("of"))+" "+m(_.value.total)+" "+m(le.$t("total"))+" · "+m(b.value)+" "+m(le.$t("next")),1)):B("",!0)]),o("div",N1e,[n(je,{disabled:A($e)===0,onClick:yt,size:"small"},{default:d(()=>[pe[14]||(pe[14]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),o("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})],-1)),R(" "+m(le.$t("Duplicate")),1)]),_:1,__:[14]},8,["disabled"]),n(je,{disabled:A($e)===0,onClick:Mt,size:"small",type:"danger",plain:""},{default:d(()=>[pe[15]||(pe[15]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("polyline",{points:"3 6 5 6 21 6"}),o("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)),R(" "+m(le.$t("Delete")),1)]),_:1,__:[15]},8,["disabled"]),n(je,{class:de({"is-active":A(tt)}),disabled:A($e)<2&&!A(tt),onClick:A(ve),size:"small"},{default:d(()=>[pe[16]||(pe[16]=o("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[o("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),o("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})],-1)),R(" "+m(A(tt)?le.$t("Unlink"):le.$t("Link")),1)]),_:1,__:[16]},8,["class","disabled","onClick"]),n(Xe,{modelValue:j.value,"onUpdate:modelValue":pe[6]||(pe[6]=ee=>j.value=ee),label:le.$t("Pin Actions")},null,8,["modelValue","label"]),n(Xt,{trigger:"click",placement:"bottom-end",width:"240","popper-class":"filter-popover"},{reference:d(()=>[o("span",null,[n(qe,{effect:"light",content:le.$t("Toggle columns"),placement:"top","popper-class":"fct-tooltip"},{default:d(()=>[n(Ze,{tag:"button",size:"small"},{default:d(()=>[n(J,{name:"ColumnIcon"})]),_:1})]),_:1},8,["content"])])]),default:d(()=>[o("div",K1e,[o("h3",G1e,m(le.$t("Columns")),1),n(Et,{modelValue:A(st).data.visibleColumns,"onUpdate:modelValue":pe[7]||(pe[7]=ee=>A(st).data.visibleColumns=ee),class:"fct-checkbox-blocks",onChange:pe[8]||(pe[8]=ee=>A(st).handleColumnVisibilityChange())},{default:d(()=>[(r(!0),h(H,null,ae(A(st).getToggleableColumns(),ee=>(r(),E(Xe,{key:ee.value,value:ee.value,label:le.$t(ee.label)},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])]),_:1})])])):B("",!0),o("div",j1e,[i.value.length>0?(r(),h("div",{key:0,class:de(["relative",{"is-link-mode":A(tt),"is-shift-held":xe.value}])},[n(uf,{columns:It.value,"sticky-last":j.value,onScroll:Ll,onResizeEnd:jt},{"header-first":d(()=>[qt(n(Xe,{checked:A($e)>0&&A($e)===Je.value.length,onChange:pe[9]||(pe[9]=ee=>A(me)(Je.value))},null,8,["checked"]),[[A(uge),A($e)>0&&A($e)[R(m(le.$t("Actions")),1)]),default:d(()=>[la.value>0?(r(),h("tr",z1e,[o("td",{colspan:It.value.length+1,style:ua({height:la.value+"px",padding:0,border:"none"})},null,12,q1e)])):B("",!0),(r(!0),h(H,null,ae(_t.value,ee=>{var He,ut,Se,kt,wa,ce,oe,Ue,Te,Pe,ct,At,rt,Lt,$a,zt,ha,Sa;return r(),h(H,{key:ee.productId},[o("tr",{class:de(["bulk-product-row",{"is-dirty":D(ee.product),"is-saving":T(ee.product),"is-saved":U(ee.product),"has-product-error":P(ee.product),"is-selected":A(fe)(`p:${ee.productId}`)}]),onClick:We=>Me(`p:${ee.productId}`,We)},[o("td",{class:"bulk-checkbox-cell",onClick:We=>A(he)(`p:${ee.productId}`,We,Je.value)},[n(Xe,{"model-value":A(fe)(`p:${ee.productId}`),tabindex:"-1"},null,8,["model-value"])],8,W1e),o("td",J1e,[o("div",X1e,[ee.hasVariants?(r(),h("button",{key:0,class:"bulk-collapse-btn",onClick:Ne(We=>Fe(ee.product),["prevent"]),title:nt(ee.product)?le.$t("Expand variants"):le.$t("Collapse variants")},[(r(),h("svg",{class:de(["bulk-collapse-icon",{"is-collapsed":nt(ee.product)}]),width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},pe[17]||(pe[17]=[o("path",{d:"M6 4L10 8L6 12",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2)),nt(ee.product)?(r(),h("span",eye,m(ee.variantCount),1)):B("",!0)],8,Z1e)):B("",!0),n(ft,{class:de(["fct-bulk-input",{"is-error":ne(ee.product,"post_title")}]),modelValue:ee.product.post_title,"onUpdate:modelValue":[We=>ee.product.post_title=We,We=>{F(ee.product),Ye("title",We,`p:${ee.productId}`)}],placeholder:le.$t("Product title"),disabled:I(ee.product),size:"small"},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),T(ee.product)?(r(),h("span",{key:1,class:"bulk-status-icon is-syncing",title:le.$t("Saving...")},[n(Ae,{class:"is-loading",size:14},{default:d(()=>[n(A(Xs))]),_:1})],8,tye)):X(ee.product)||s(ee.product)&&P(ee.product)?(r(),E(qe,{key:2,content:q(ee.product),placement:"top"},{default:d(()=>[o("span",aye,[n(Ae,{size:16},{default:d(()=>[n(A(Uo))]),_:1})])]),_:2},1032,["content"])):D(ee.product)?(r(),h("button",{key:3,class:"bulk-inline-save",disabled:I(ee.product),onClick:Ne(We=>K(ee.product),["prevent"]),title:le.$t("Save")},pe[18]||(pe[18]=[o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",width:"16",height:"16"},[o("path",{d:"M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z",fill:"currentColor"})],-1)]),8,lye)):B("",!0)])]),mt("image")?(r(),h("td",sye,[n(hl,{modelValue:ee.product.gallery,"onUpdate:modelValue":We=>ee.product.gallery=We,onChange:We=>F(ee.product)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):B("",!0),mt("sku")?(r(),h("td",nye,[((ut=(He=ee.product)==null?void 0:He.detail)==null?void 0:ut.variation_type)==="simple"&&((Se=ee.product.variants)!=null&&Se[0])?(r(),E(ft,{key:0,class:de(["fct-bulk-input",{"is-error":ne(ee.product,"variants.0.sku")}]),modelValue:ee.product.variants[0].sku,"onUpdate:modelValue":[We=>ee.product.variants[0].sku=We,We=>{F(ee.product),Ye("sku",We,`p:${ee.productId}`)}],placeholder:"SKU",size:"small",disabled:I(ee.product)},null,8,["modelValue","onUpdate:modelValue","disabled","class"])):(r(),h("span",oye,"—"))])):B("",!0),mt("categories")?(r(),h("td",iye,[n(cf,{modelValue:ee.product.categories,"onUpdate:modelValue":We=>ee.product.categories=We,options:A(st).data.categoryOptions,disabled:I(ee.product),onChange:We=>{Q(ee.product,We),Ye("categories",ee.product.categories,`p:${ee.productId}`)}},null,8,["modelValue","onUpdate:modelValue","options","disabled","onChange"])])):B("",!0),mt("description")?(r(),h("td",rye,[n(Zo,{value:ee.product.post_content,placeholder:le.$t("Description"),onClick:We=>Pt(ee.product,"post_content")},null,8,["value","placeholder","onClick"])])):B("",!0),mt("short_description")?(r(),h("td",dye,[n(Zo,{value:ee.product.post_excerpt,placeholder:le.$t("Short description"),onClick:We=>Pt(ee.product,"post_excerpt")},null,8,["value","placeholder","onClick"])])):B("",!0),mt("status")?(r(),h("td",uye,[n(Le,{modelValue:ee.product.post_status,"onUpdate:modelValue":We=>ee.product.post_status=We,size:"small",class:de({"is-field-error":ne(ee.product,"post_status")}),disabled:I(ee.product),onChange:We=>{F(ee.product),Ye("status",ee.product.post_status,`p:${ee.productId}`)}},{default:d(()=>[n(_e,{label:le.$t("Published"),value:"publish"},null,8,["label"]),n(_e,{label:le.$t("Draft"),value:"draft"},null,8,["label"])]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):B("",!0),mt("product_type")?(r(),h("td",cye,[o("span",Aye,m(Ra((wa=(kt=ee.product)==null?void 0:kt.detail)==null?void 0:wa.fulfillment_type)),1)])):B("",!0),mt("pricing_type")?(r(),h("td",pye,[o("span",fye,m(na((oe=(ce=ee.product)==null?void 0:ce.detail)==null?void 0:oe.variation_type)),1)])):B("",!0),mt("payment_type")?(r(),h("td",mye,[n(Yo,{variant:s(ee.product)?(Ue=ee.product.variants)==null?void 0:Ue[0]:null,disabled:I(ee.product),"has-error":ne(ee.product,"variants.0.other_info.payment_type"),onPaymentTypeChange:We=>{var Zt;x(ee.product,We),Ye("payment_type",(Zt=We.other_info)==null?void 0:Zt.payment_type,`p:${ee.productId}`)},onChange:We=>F(ee.product)},null,8,["variant","disabled","has-error","onPaymentTypeChange","onChange"])])):B("",!0),mt("interval")?(r(),h("td",hye,[n(Wo,{variant:s(ee.product)?(Te=ee.product.variants)==null?void 0:Te[0]:null,disabled:I(ee.product),"has-error":ne(ee.product,"variants.0.other_info.repeat_interval"),onChange:We=>{var Zt,Ka,ze;F(ee.product),Ye("interval",(ze=(Ka=(Zt=ee.product.variants)==null?void 0:Zt[0])==null?void 0:Ka.other_info)==null?void 0:ze.repeat_interval,`p:${ee.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("trial_days")?(r(),h("td",_ye,[n(Jo,{variant:s(ee.product)?(Pe=ee.product.variants)==null?void 0:Pe[0]:null,disabled:I(ee.product),"has-error":ne(ee.product,"variants.0.other_info.trial_days"),onChange:We=>{var Zt,Ka,ze;F(ee.product),Ye("trial_days",(ze=(Ka=(Zt=ee.product.variants)==null?void 0:Zt[0])==null?void 0:Ka.other_info)==null?void 0:ze.trial_days,`p:${ee.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("best_price")?(r(),h("td",vye,[n(qo,{variant:s(ee.product)?(ct=ee.product.variants)==null?void 0:ct[0]:null,disabled:I(ee.product),"has-error":ne(ee.product,"variants.0.item_price"),onChange:We=>{var Zt,Ka;F(ee.product),Ye("price",(Ka=(Zt=ee.product.variants)==null?void 0:Zt[0])==null?void 0:Ka.item_price,`p:${ee.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("compare_price")?(r(),h("td",gye,[n(Xo,{variant:s(ee.product)?(At=ee.product.variants)==null?void 0:At[0]:null,disabled:I(ee.product),"has-error":ne(ee.product,"variants.0.compare_price"),onChange:We=>{var Zt,Ka;F(ee.product),Ye("compare_price",(Ka=(Zt=ee.product.variants)==null?void 0:Zt[0])==null?void 0:Ka.compare_price,`p:${ee.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("track_quantity")?(r(),h("td",yye,[(rt=ee.product)!=null&&rt.detail?(r(),E(Ke,{key:0,modelValue:ee.product.detail.manage_stock,"onUpdate:modelValue":We=>ee.product.detail.manage_stock=We,"active-value":1,"inactive-value":0,disabled:I(ee.product),onChange:We=>{F(ee.product),A(st).syncStockStatus(ee.product),Ye("manage_stock",ee.product.detail.manage_stock,`p:${ee.productId}`)}},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])):B("",!0)])):B("",!0),mt("stock")?(r(),h("td",bye,[($a=(Lt=ee.product)==null?void 0:Lt.detail)!=null&&$a.manage_stock&&((ha=(zt=ee.product)==null?void 0:zt.detail)==null?void 0:ha.variation_type)==="simple"&&((Sa=ee.product.variants)!=null&&Sa[0])?(r(),E(ft,{key:0,class:"fct-bulk-input",placeholder:le.$t("e.g 10"),size:"small",modelValue:ee.product.variants[0].available,"onUpdate:modelValue":[We=>ee.product.variants[0].available=We,We=>{ee.product.variants[0].total_stock=We,F(ee.product),A(st).syncStockStatus(ee.product),Ye("stock",We,`p:${ee.productId}`)}],disabled:I(ee.product)},null,8,["placeholder","modelValue","onUpdate:modelValue","disabled"])):(r(),h("span",wye,"—"))])):B("",!0),o("td",{class:de(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":j.value}])},[o("div",Cye,[ee.product.view_url?(r(),E(Ze,{key:0,tag:"a",size:"x-small",href:ee.product.view_url,target:"_blank",title:le.$t("View Product")},{default:d(()=>[n(J,{name:"External"})]),_:2},1032,["href","title"])):B("",!0),n(Ze,{tag:"button",size:"x-small",onClick:Ne(We=>Y(ee.product),["prevent"]),disabled:p.value||I(ee.product)||O(ee.product),title:le.$t("Duplicate")},{default:d(()=>[O(ee.product)?(r(),E(Ae,{key:0,class:"is-loading",size:14},{default:d(()=>[n(A(Xs))]),_:1})):(r(),E(J,{key:1,name:"Copy"}))]),_:2},1032,["onClick","disabled","title"]),n(Ze,{tag:"button",size:"x-small",hover:"danger",onClick:Ne(We=>Ut(ee.product),["prevent"]),disabled:p.value||I(ee.product)||L(ee.product),title:le.$t("Delete")},{default:d(()=>[L(ee.product)?(r(),E(Ae,{key:0,class:"is-loading",size:14},{default:d(()=>[n(A(Xs))]),_:1})):(r(),E(J,{key:1,name:"Delete"}))]),_:2},1032,["onClick","disabled","title"])])],2)],10,Y1e),ee.hasVariants?(r(),h("tr",kye,[o("td",{colspan:It.value.length+1,class:"!p-0 !border-b-0"},[n(va,{accordion:"",visible:!ee.collapsed,duration:200},{default:d(()=>[o("table",xye,[o("colgroup",null,[pe[19]||(pe[19]=o("col",{style:{width:"40px"}},null,-1)),(r(!0),h(H,null,ae(It.value,(We,Zt)=>(r(),h("col",{key:Zt,style:ua({width:We.width+"px"})},null,4))),128))]),o("tbody",null,[(r(!0),h(H,null,ae(ee.product.variants,(We,Zt)=>{var Ka,ze;return r(),h("tr",{key:We.id||Zt,class:de(["bulk-variation-row",{"is-selected":A(fe)(`v:${We.id}`)}]),onClick:Tt=>Me(`v:${We.id}`,Tt)},[o("td",Fye,[n(Xe,{"model-value":A(fe)(`v:${We.id}`),tabindex:"-1",onChange:Tt=>A(he)(`v:${We.id}`,Tt,Je.value)},null,8,["model-value","onChange"])]),o("td",$ye,[o("div",Eye,[pe[20]||(pe[20]=o("span",{class:"text-gray-300 text-xs"},"└",-1)),n(ft,{size:"small",modelValue:We.variation_title,"onUpdate:modelValue":[Tt=>We.variation_title=Tt,Tt=>{F(ee.product),Ye("title",Tt,`v:${We.id}`)}],placeholder:le.$t("Variation title"),disabled:I(ee.product),class:de({"is-error":re(ee.product,Zt,"variation_title")})},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),G(ee.product,Zt)?(r(),E(qe,{key:0,content:te(ee.product,Zt),placement:"top"},{default:d(()=>[o("span",Uye,[n(Ae,{size:14},{default:d(()=>[n(A(Uo))]),_:1})])]),_:2},1032,["content"])):B("",!0)])]),mt("image")?(r(),h("td",Iye,[n(hl,{modelValue:We.media,"onUpdate:modelValue":Tt=>We.media=Tt,onChange:Tt=>F(ee.product)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):B("",!0),mt("sku")?(r(),h("td",Qye,[n(ft,{class:de(["fct-bulk-input",{"is-error":re(ee.product,Zt,"sku")}]),size:"small",modelValue:We.sku,"onUpdate:modelValue":[Tt=>We.sku=Tt,Tt=>{F(ee.product),Ye("sku",Tt,`v:${We.id}`)}],placeholder:le.$t("SKU"),disabled:I(ee.product)},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"])])):B("",!0),mt("categories")?(r(),h("td",Dye,pe[21]||(pe[21]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),mt("description")?(r(),h("td",Vye,pe[22]||(pe[22]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),mt("short_description")?(r(),h("td",Tye,pe[23]||(pe[23]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),mt("status")?(r(),h("td",Mye,pe[24]||(pe[24]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),mt("product_type")?(r(),h("td",Lye,pe[25]||(pe[25]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),mt("pricing_type")?(r(),h("td",Rye,pe[26]||(pe[26]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),mt("payment_type")?(r(),h("td",Oye,[n(Yo,{variant:We,disabled:I(ee.product),"has-error":re(ee.product,Zt,"other_info.payment_type"),onPaymentTypeChange:Tt=>{var ls;x(ee.product,Tt),Ye("payment_type",(ls=Tt.other_info)==null?void 0:ls.payment_type,`v:${We.id}`)},onChange:Tt=>F(ee.product)},null,8,["variant","disabled","has-error","onPaymentTypeChange","onChange"])])):B("",!0),mt("interval")?(r(),h("td",Hye,[n(Wo,{variant:We,disabled:I(ee.product),"has-error":re(ee.product,Zt,"other_info.repeat_interval"),onChange:Tt=>{var ls;F(ee.product),Ye("interval",(ls=We.other_info)==null?void 0:ls.repeat_interval,`v:${We.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("trial_days")?(r(),h("td",Pye,[n(Jo,{variant:We,disabled:I(ee.product),"has-error":re(ee.product,Zt,"other_info.trial_days"),onChange:Tt=>{var ls;F(ee.product),Ye("trial_days",(ls=We.other_info)==null?void 0:ls.trial_days,`v:${We.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("best_price")?(r(),h("td",Nye,[n(qo,{variant:We,disabled:I(ee.product),"has-error":re(ee.product,Zt,"item_price"),onChange:Tt=>{F(ee.product),Ye("price",We.item_price,`v:${We.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("compare_price")?(r(),h("td",Kye,[n(Xo,{variant:We,disabled:I(ee.product),"has-error":re(ee.product,Zt,"compare_price"),onChange:Tt=>{F(ee.product),Ye("compare_price",We.compare_price,`v:${We.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),mt("track_quantity")?(r(),h("td",Gye,pe[27]||(pe[27]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),mt("stock")?(r(),h("td",jye,[(ze=(Ka=ee.product)==null?void 0:Ka.detail)!=null&&ze.manage_stock?(r(),E(ft,{key:0,class:"fct-bulk-input",placeholder:le.$t("e.g 10"),size:"small",modelValue:We.available,"onUpdate:modelValue":[Tt=>We.available=Tt,Tt=>{We.total_stock=Tt,F(ee.product),A(st).syncStockStatus(ee.product),Ye("stock",Tt,`v:${We.id}`)}],disabled:I(ee.product)},null,8,["placeholder","modelValue","onUpdate:modelValue","disabled"])):(r(),h("span",zye,"—"))])):B("",!0),o("td",{class:de(["text-center",{"sticky-col sticky-col-right":j.value}])},[o("div",qye,[n(Ze,{tag:"button",size:"x-small",onClick:Ne(Tt=>W(ee.product,We),["prevent"]),disabled:p.value||I(ee.product),title:le.$t("Duplicate")},{default:d(()=>[n(J,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(Ze,{tag:"button",size:"x-small",hover:"danger",onClick:Ne(Tt=>Dt(ee.product,We),["prevent"]),disabled:p.value||I(ee.product),title:le.$t("Delete")},{default:d(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,Sye)}),128))])])]),_:2},1032,["visible"])],8,Bye)])):B("",!0)],64)}),128)),sa.value>0?(r(),h("tr",Yye,[o("td",{colspan:It.value.length+1,style:ua({height:sa.value+"px",padding:0,border:"none"})},null,12,Wye)])):B("",!0)]),_:1},8,["columns","sticky-last"])],2)):c.value?c.value?(r(),h("div",Zye,[n(Ae,{class:"is-loading mr-2"},{default:d(()=>pe[28]||(pe[28]=[o("i",{class:"el-icon-loading"},null,-1)])),_:1,__:[28]}),o("span",ebe,m(le.$t("Loading products...")),1)])):B("",!0):(r(),h("div",Jye,[o("p",Xye,m(le.$t("No products found.")),1)]))]),_.value.hasMore&&i.value.length>0&&c.value?(r(),h("div",tbe,[n(Ae,{class:"is-loading mr-2"},{default:d(()=>pe[29]||(pe[29]=[o("i",{class:"el-icon-loading"},null,-1)])),_:1,__:[29]}),o("span",abe,m(le.$t("Loading"))+" "+m(b.value)+" "+m(le.$t("more...")),1)])):B("",!0)])]),_:1})]),_:1})]),n(Ve,{modelValue:ht.value.visible,"onUpdate:modelValue":pe[12]||(pe[12]=ee=>ht.value.visible=ee),title:Ot.value,width:"700px","close-on-click-modal":!1,onClosed:pe[13]||(pe[13]=ee=>ht.value.product=null)},{footer:d(()=>[n(je,{onClick:pe[11]||(pe[11]=ee=>ht.value.visible=!1)},{default:d(()=>[R(m(le.$t("Cancel")),1)]),_:1}),n(je,{type:"primary",onClick:St},{default:d(()=>[R(m(le.$t("Save")),1)]),_:1})]),default:d(()=>[ht.value.visible&&ht.value.field==="post_content"?(r(),E(es,{key:0,"model-value":ht.value.value,height:300,onUpdate:Ct},null,8,["model-value"])):B("",!0),ht.value.visible&&ht.value.field==="post_excerpt"?(r(),E(ft,{key:1,modelValue:ht.value.value,"onUpdate:modelValue":pe[10]||(pe[10]=ee=>ht.value.value=ee),type:"textarea",rows:6,placeholder:le.$t("Short description")},null,8,["modelValue","placeholder"])):B("",!0)]),_:1},8,["modelValue","title"])])}}},mf=Ge.get("payment_routes");for(const e of mf)e.props=!0;const obe=Ge.get("storage_driver_routes"),hf=(obe||[]).filter(e=>e.name!=="s3");for(const e of hf)e.props=!0;var ibe={dashboard:{name:"dashboard",path:"/",component:gB,meta:{active_menu:"dashboard",title:u("Dashboard")}},orders:{path:"/orders",component:XF,meta:{active_menu:"orders",title:u("Orders")},children:[{name:"orders",path:"",component:q_,meta:{active_menu:"orders",title:u("Orders"),permission:"orders/view"}},{name:"view_order",path:":order_id(\\d+)/view",component:uD,props:!0,meta:{active_menu:"orders",title:u("View Order"),permission:["orders/view","orders/manage"]}},{name:"add_order",path:"add",component:PD,props:!0,meta:{active_menu:"orders",title:u("Create Order"),permission:"orders/create"}}]},products:{name:"products",path:"/products",component:MM,meta:{active_menu:"products",title:u("Products"),permission:"products/view"}},product_route:{path:"/products/:product_id(\\d+)",component:IV,name:"product_route",meta:{active_menu:"products",title:u("Products"),permission:["products/view","products/edit","integrations/manage"]},props:!0,children:[{name:"product_edit",path:"",props:!0,component:Az,meta:{active_menu:"products",title:u("Product Edit"),permission:"products/edit"}},{name:"product_integrations",path:"integrations",props:!0,component:rc,meta:{active_menu:"products",title:u("Integrations"),permission:"integrations/manage"}},{name:"product_integration_feed_editor",path:"integrations/:integration_id/:integration_name",component:Wu,meta:{active_menu:"products",title:u("Edit Integration"),permission:"integrations/manage"}},{name:"SingleIntegration",path:"integrations/:integration_id",props:!0,component:bq,meta:{active_menu:"products",title:u("Integrations"),permission:"integrations/manage"}},{name:"product_upgrade_paths",path:"upgrade-paths",props:!0,component:eq,meta:{active_menu:"products",title:u("Upgrade Paths"),permission:"integrations/manage"}},{name:"Integrations",path:"integrations",props:!0,component:rc,meta:{active_menu:"integrations",title:u("Product Integrations"),permission:"integrations/manage"}}]},product_bulk_insert:{name:"product_bulk_insert",path:"/products/bulk-insert",component:S1e,meta:{active_menu:"products",title:u("Product Bulk Insert"),permission:"products/create"}},product_bulk_edit:{name:"product_bulk_edit",path:"/products/bulk-edit",component:nbe,meta:{active_menu:"products",title:u("Product Bulk Edit"),permission:"products/edit"}},product_attributes:{name:"product_attributes",path:"/products/attributes",component:_m,meta:{active_menu:"products",title:u("Attributes"),permission:"products/view"}},product_inventory:{name:"product_inventory",path:"/products/inventory",component:aJ,meta:{active_menu:"products",title:u("Inventory"),permission:"products/view"}},customers:{path:"/customers",component:rg,meta:{active_menu:"customers",permission:["customers/view","customers/manage"]},children:[{name:"customers",path:"/customers",component:Dh,meta:{active_menu:"customers",title:u("Customers"),permission:"customers/view"}},{name:"view_customer",path:":customer_id(\\d+)/view",component:WE,props:!0,meta:{active_menu:"customers",title:u("View Customer"),permission:"customers/view"}}]},reports:{name:"reports",path:"/reports",component:vee,meta:{active_menu:"reports",permission:"reports/view"},children:[{name:"reports_overview",path:"overview",component:kue,meta:{title:u("Overview"),permission:"reports/view"}},{name:"reports_sales",path:"sales",component:qee,meta:{title:u("Sales"),permission:"reports/view"}},{name:"reports_orders",path:"orders",component:use,meta:{title:u("Orders"),permission:"reports/view"}},{name:"reports_revenue",path:"revenue",component:Kte,meta:{title:u("Revenue"),permission:"reports/view"}},{name:"reports_refunds",path:"refunds",component:zse,meta:{title:u("Refunds"),permission:"reports/view"}},{name:"reports_subscriptions",path:"subscriptions",component:Rne,meta:{title:u("Subscriptions"),permission:"reports/view"}},{name:"subscriptions-retention",path:"subscriptions/subscriptions-retention",component:Zoe,meta:{title:u("Retention"),permission:"reports/view"}},{name:"subscriptions-cohorts",path:"subscriptions/subscriptions-cohorts",component:()=>Jt(()=>import("./chunks/Cohort.js?ver=1.6.2"),[],import.meta.url),meta:{title:u("Cohorts"),permission:"reports/view"}},{name:"future_renewals",path:"subscriptions/future-renewals",component:soe,meta:{title:u("Future Renewals"),permission:"reports/view"}},{name:"reports_products",path:"products",component:Ede,meta:{title:u("Product"),permission:"reports/view"}},{name:"reports_customer",path:"customer",component:kie,meta:{title:u("Customer"),permission:"reports/view"}},{name:"reports_sources",path:"sources",component:ire,meta:{title:u("Sources"),permission:"reports/view"}}]},settings:{path:"/settings",component:P$,meta:{active_menu:"settings",title:u("Settings"),permission:["store/settings","store/sensitive"]},children:[{name:"store_settings",path:"store-settings",component:ZD,meta:{active_menu:"settings",title:u("Settings"),permission:"store/settings"},children:[{name:"store_setup",path:"",component:ws,meta:{title:u("Store Setup")}},{name:"pages_setup",path:"pages_setup",component:ws,meta:{title:u("Pages Setup")}},{name:"single_product_setup",path:"single_product_setup",component:ws,meta:{title:u("Product Page")}},{name:"cart_and_checkout",path:"cart_and_checkout",component:ws,meta:{title:u("Cart & Checkout")}},{name:"subscriptions_setup",path:"subscriptions_setup",component:ws,meta:{title:u("Subscriptions")}},{name:"checkout_fields",path:"checkout_fields",component:yve,meta:{}}]},...Ge.get("addon_settings_routes",[]).map(e=>({component:ws,...e})),{name:"email_notifications",path:"email_notifications",component:SJ,meta:{active_menu:"settings",title:u("Notifications"),permission:"store/sensitive"}},{name:"email_mailing_settings",path:"email_mailing_settings",component:yce,meta:{active_menu:"settings",title:u("Mailing Settings"),permission:"store/sensitive"}},{name:"reminders",path:"email_mailing_settings/reminders",component:ws,meta:{active_menu:"settings",title:u("Reminders"),permission:"store/sensitive"}},{name:"email_digest_settings",path:"email_digest_settings",component:Fce,meta:{active_menu:"settings",title:u("Store Digest"),permission:"store/sensitive"}},{path:"email_notifications/:name/",name:"email_notifications/edit",component:aX,meta:{active_menu:"settings",title:u("Edit Notification"),permission:"store/sensitive"},props:!0},{path:"email_notifications/add",name:"email_notifications/add",component:kX,meta:{active_menu:"settings",title:u("Add Notification"),permission:"store/sensitive"}},{name:"licensing",path:"licensing",component:wV,meta:{active_menu:"settings",title:u("Licensing"),permission:"store/sensitive"}},{name:"payments",path:"payments",component:A$,meta:{active_menu:"settings",title:u("Payment Settings"),permission:"is_super_admin"}},{name:"gateway",component:O3,path:"payments",children:mf,props:!0,meta:{active_menu:"settings",title:u("Payment Settings"),permission:"is_super_admin"}},{name:"invoice-packing",path:"invoice-packing",component:ev,meta:{active_menu:"settings",title:u("Invoice & Packing"),permission:"is_super_admin"}},{name:"pdf-template",path:"pdf-template",component:av,meta:{active_menu:"settings",title:u("PDF Templates"),permission:"is_super_admin"},children:[{name:"pdf-template-list",path:"",component:gv,meta:{active_menu:"settings",title:u("PDF Templates"),permission:"is_super_admin"}},{name:"pdf-template-settings",path:"settings",component:sg,meta:{active_menu:"settings",title:u("PDF Template Settings"),permission:"is_super_admin"}},{name:"edit-pdf-template",path:":template/edit",component:Lv,props:!0,meta:{active_menu:"settings",title:u("Edit PDF Template"),permission:"is_super_admin"}}]},{name:"roles",path:"roles",component:I$,meta:{active_menu:"settings",title:u("Role Settings"),permission:"is_super_admin"}},{name:"addons",path:"addons",component:Kue,meta:{active_menu:"settings",title:u("Features & addon"),permission:"is_super_admin"}},{name:"coupons",path:"coupons",component:_c,meta:{active_menu:"coupons",title:u("Coupons Settings"),permission:"is_super_admin"}},{name:"storage",path:"storage",component:hX,meta:{active_menu:"settings",title:u("Storage Providers"),permission:"is_super_admin"}},{name:"s3",path:"storage/s3",component:cc,props:!0,meta:{active_menu:"settings",title:u("S3"),permission:"is_super_admin"}},{name:"payment-design",path:"payments/:method/design",component:G3,meta:{active_menu:"settings",title:u("Gateway"),permission:"is_super_admin"},props:!0},{name:"drivers",component:cc,path:"storage",children:hf,props:!0,meta:{active_menu:"settings",title:u("Storage Settings"),permission:"is_super_admin"}},{name:"tax_settings",path:"tax_settings",component:Uce,meta:{active_menu:"settings",title:u("Tax Settings"),permission:"store/settings"},children:[{name:"tax_configurations",path:"",component:PAe,meta:{}},{name:"tax_rates",path:"tax_rates",component:spe,meta:{}},{name:"eu",path:"eu",component:Ihe,meta:{}},{name:"eu_country_tax_rates",path:"eu/:country/:group",component:hc,props:!0,meta:{}},{name:"tax-rates-country-single",path:"tax_rates_country_single/:country/:group",component:hc,props:!0,meta:{}}]}]},integrations:{name:"integrations",path:"/integrations",component:Q4,meta:{active_menu:"integrations",title:u("Integrations"),permission:"integrations/view"}},global_feed_editor:{name:"feed_editor",path:"/global_integrations/:integration_id/:integration_name",component:Wu,meta:{active_menu:"integrations",title:u("Global Integrations"),permission:"integrations/view"}},integration_editor:{name:"integration_editor",path:"/integrations/:integration_name",component:mS,meta:{active_menu:"integrations",title:u("Integrations"),permission:"integrations/manage"}},coupons:{name:"coupons",path:"/coupons",component:_c,meta:{active_menu:"coupons",title:u("Coupons"),permission:"coupons/view"}},logs:{name:"logs",path:"/logs",component:cZ,meta:{active_menu:"logs",title:u("Logs"),permission:"is_super_admin"}},taxes:{name:"taxes",path:"/taxes",component:Ufe,meta:{active_menu:"taxes",title:u("Taxes"),permission:"is_super_admin"}},add_or_edit_coupon_route:{name:"add_or_edit_coupon",path:"/coupons/add_or_edit_coupon/:coupon_id?",component:Z_e,props:!0,meta:{active_menu:"coupons",title:u("Coupons"),permission:"coupons/manage"}},onboarding:{path:"/onboarding",component:WF,name:"onboarding",meta:{active_menu:"dashboard",title:u("Onboarding"),permission:"is_super_admin"}}};const rbe={class:"fct-theme-button-container"},dbe={class:"theme-selected-button"},ube={__name:"ThemeToggle",setup(e){const t=M(De.MODE_LIGHT),a=c=>{t.value!==c&&(t.value=c,De.apply(c))},l=[{value:"light",label:u("Light"),icon:"Sun"},{value:"dark",label:u("Dark"),icon:"Moon"},{value:"system",label:u("System"),icon:"Tools"}];Is(()=>{const c=document.getElementById("theme-button-container");if(c){const p=c.querySelector(".fct-theme-button-container");p&&p.remove()}t.value=De.getCurrentTheme(),t.value.toString().startsWith(De.MODE_SYSTEM)&&(t.value=De.MODE_SYSTEM)});const s=c=>{ke(()=>{t.value=De.getCurrentTheme()})},i=c=>{a(c)};return Ie(()=>{window.addEventListener(De.THEME_CHANGE_EVENT,s,!1)}),vl(()=>{window.removeEventListener(De.THEME_CHANGE_EVENT,s,!1)}),(c,p)=>{const f=C("el-dropdown-item"),_=C("el-dropdown-menu"),g=C("el-dropdown");return r(),h("div",rbe,[n(g,{placement:"bottom-end",trigger:"click","popper-class":"fct-dropdown",onCommand:i},{dropdown:d(()=>[n(_,null,{default:d(()=>[(r(),h(H,null,ae(l,y=>n(f,{key:y.value,command:y.value,class:de({active:t.value===y.value})},{default:d(()=>[n(J,{name:y.icon},null,8,["name"]),R(" "+m(y.label),1)]),_:2},1032,["command","class"])),64))]),_:1})]),default:d(()=>[o("div",dbe,[t.value==="light"?(r(),E(J,{key:0,name:"Sun"})):t.value==="dark"?(r(),E(J,{key:1,name:"Moon"})):t.value==="system"?(r(),E(J,{key:2,name:"Tools"})):B("",!0)])]),_:1})])}}};function as(e){return Array.isArray?Array.isArray(e):gf(e)==="[object Array]"}function cbe(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Abe(e){return e==null?"":cbe(e)}function Ol(e){return typeof e=="string"}function _f(e){return typeof e=="number"}function pbe(e){return e===!0||e===!1||fbe(e)&&gf(e)=="[object Boolean]"}function vf(e){return typeof e=="object"}function fbe(e){return vf(e)&&e!==null}function pl(e){return e!=null}function dr(e){return!e.trim().length}function gf(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const mbe="Incorrect 'index' type",hbe=e=>`Invalid value for key ${e}`,_be=e=>`Pattern length exceeds max of ${e}.`,vbe=e=>`Missing ${e} property in key`,gbe=e=>`Property 'weight' in key '${e}' must be a positive integer`,Cc=Object.prototype.hasOwnProperty;class ybe{constructor(t){this._keys=[],this._keyMap={};let a=0;t.forEach(l=>{let s=yf(l);this._keys.push(s),this._keyMap[s.id]=s,a+=s.weight}),this._keys.forEach(l=>{l.weight/=a})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function yf(e){let t=null,a=null,l=null,s=1,i=null;if(Ol(e)||as(e))l=e,t=kc(e),a=Kr(e);else{if(!Cc.call(e,"name"))throw new Error(vbe("name"));const c=e.name;if(l=c,Cc.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(gbe(c));t=kc(c),a=Kr(c),i=e.getFn}return{path:t,id:a,weight:s,src:l,getFn:i}}function kc(e){return as(e)?e:e.split(".")}function Kr(e){return as(e)?e.join("."):e}function bbe(e,t){let a=[],l=!1;const s=(i,c,p)=>{if(pl(i))if(!c[p])a.push(i);else{let f=c[p];const _=i[f];if(!pl(_))return;if(p===c.length-1&&(Ol(_)||_f(_)||pbe(_)))a.push(Abe(_));else if(as(_)){l=!0;for(let g=0,y=_.length;ge.score===t.score?e.idx{this._keysMap[a.id]=l})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Ol(this.docs[0])?this.docs.forEach((t,a)=>{this._addString(t,a)}):this.docs.forEach((t,a)=>{this._addObject(t,a)}),this.norm.clear())}add(t){const a=this.size();Ol(t)?this._addString(t,a):this._addObject(t,a)}removeAt(t){this.records.splice(t,1);for(let a=t,l=this.size();a{let c=s.getFn?s.getFn(t):this.getFn(t,s.path);if(pl(c)){if(as(c)){let p=[];const f=[{nestedArrIndex:-1,value:c}];for(;f.length;){const{nestedArrIndex:_,value:g}=f.pop();if(pl(g))if(Ol(g)&&!dr(g)){let y={v:g,i:_,n:this.norm.get(g)};p.push(y)}else as(g)&&g.forEach((y,v)=>{f.push({nestedArrIndex:v,value:y})})}l.$[i]=p}else if(Ol(c)&&!dr(c)){let p={v:c,n:this.norm.get(c)};l.$[i]=p}}}),this.records.push(l)}toJSON(){return{keys:this.keys,records:this.records}}}function bf(e,t,{getFn:a=$t.getFn,fieldNormWeight:l=$t.fieldNormWeight}={}){const s=new Qd({getFn:a,fieldNormWeight:l});return s.setKeys(e.map(yf)),s.setSources(t),s.create(),s}function Fbe(e,{getFn:t=$t.getFn,fieldNormWeight:a=$t.fieldNormWeight}={}){const{keys:l,records:s}=e,i=new Qd({getFn:t,fieldNormWeight:a});return i.setKeys(l),i.setIndexRecords(s),i}function yo(e,{errors:t=0,currentLocation:a=0,expectedLocation:l=0,distance:s=$t.distance,ignoreLocation:i=$t.ignoreLocation}={}){const c=t/e.length;if(i)return c;const p=Math.abs(l-a);return s?c+p/s:p?1:c}function $be(e=[],t=$t.minMatchCharLength){let a=[],l=-1,s=-1,i=0;for(let c=e.length;i=t&&a.push([l,s]),l=-1)}return e[i-1]&&i-l>=t&&a.push([l,i-1]),a}const ks=32;function Ebe(e,t,a,{location:l=$t.location,distance:s=$t.distance,threshold:i=$t.threshold,findAllMatches:c=$t.findAllMatches,minMatchCharLength:p=$t.minMatchCharLength,includeMatches:f=$t.includeMatches,ignoreLocation:_=$t.ignoreLocation}={}){if(t.length>ks)throw new Error(_be(ks));const g=t.length,y=e.length,v=Math.max(0,Math.min(l,y));let b=i,k=v;const w=p>1||f,S=w?Array(y):[];let $;for(;($=e.indexOf(t,k))>-1;){let T=yo(t,{currentLocation:$,expectedLocation:v,distance:s,ignoreLocation:_});if(b=Math.min(T,b),k=$+g,w){let U=0;for(;U=O;X-=1){let G=X-1,te=a[e.charAt(G)];if(w&&(S[G]=+!!te),P[X]=(P[X+1]<<1|1)&te,T&&(P[X]|=(V[X+1]|V[X])<<1|1|V[X+1]),P[X]&Q&&(F=yo(t,{errors:T,currentLocation:G,expectedLocation:v,distance:s,ignoreLocation:_}),F<=b)){if(b=F,k=G,k<=v)break;O=Math.max(1,2*v-k)}}if(yo(t,{errors:T+1,currentLocation:v,expectedLocation:v,distance:s,ignoreLocation:_})>b)break;V=P}const D={isMatch:k>=0,score:Math.max(.001,F)};if(w){const T=$be(S,p);T.length?f&&(D.indices=T):D.isMatch=!1}return D}function Ube(e){let t={};for(let a=0,l=e.length;ae.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,""):e=>e;class wf{constructor(t,{location:a=$t.location,threshold:l=$t.threshold,distance:s=$t.distance,includeMatches:i=$t.includeMatches,findAllMatches:c=$t.findAllMatches,minMatchCharLength:p=$t.minMatchCharLength,isCaseSensitive:f=$t.isCaseSensitive,ignoreDiacritics:_=$t.ignoreDiacritics,ignoreLocation:g=$t.ignoreLocation}={}){if(this.options={location:a,threshold:l,distance:s,includeMatches:i,findAllMatches:c,minMatchCharLength:p,isCaseSensitive:f,ignoreDiacritics:_,ignoreLocation:g},t=f?t:t.toLowerCase(),t=_?ei(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const y=(b,k)=>{this.chunks.push({pattern:b,alphabet:Ube(b),startIndex:k})},v=this.pattern.length;if(v>ks){let b=0;const k=v%ks,w=v-k;for(;b{const{isMatch:V,score:F,indices:x}=Ebe(t,w,S,{location:i+$,distance:c,threshold:p,findAllMatches:f,minMatchCharLength:_,includeMatches:s,ignoreLocation:g});V&&(b=!0),v+=F,V&&x&&(y=[...y,...x])});let k={isMatch:b,score:b?v/this.chunks.length:1};return b&&s&&(k.indices=y),k}}class gs{constructor(t){this.pattern=t}static isMultiMatch(t){return Bc(t,this.multiRegex)}static isSingleMatch(t){return Bc(t,this.singleRegex)}search(){}}function Bc(e,t){const a=e.match(t);return a?a[1]:null}class Ibe extends gs{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const a=t===this.pattern;return{isMatch:a,score:a?0:1,indices:[0,this.pattern.length-1]}}}class Qbe extends gs{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const l=t.indexOf(this.pattern)===-1;return{isMatch:l,score:l?0:1,indices:[0,t.length-1]}}}class Dbe extends gs{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const a=t.startsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[0,this.pattern.length-1]}}}class Vbe extends gs{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const a=!t.startsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[0,t.length-1]}}}class Tbe extends gs{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const a=t.endsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Mbe extends gs{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const a=!t.endsWith(this.pattern);return{isMatch:a,score:a?0:1,indices:[0,t.length-1]}}}class Cf extends gs{constructor(t,{location:a=$t.location,threshold:l=$t.threshold,distance:s=$t.distance,includeMatches:i=$t.includeMatches,findAllMatches:c=$t.findAllMatches,minMatchCharLength:p=$t.minMatchCharLength,isCaseSensitive:f=$t.isCaseSensitive,ignoreDiacritics:_=$t.ignoreDiacritics,ignoreLocation:g=$t.ignoreLocation}={}){super(t),this._bitapSearch=new wf(t,{location:a,threshold:l,distance:s,includeMatches:i,findAllMatches:c,minMatchCharLength:p,isCaseSensitive:f,ignoreDiacritics:_,ignoreLocation:g})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class kf extends gs{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let a=0,l;const s=[],i=this.pattern.length;for(;(l=t.indexOf(this.pattern,a))>-1;)a=l+i,s.push([l,a-1]);const c=!!s.length;return{isMatch:c,score:c?0:1,indices:s}}}const Gr=[Ibe,kf,Dbe,Vbe,Mbe,Tbe,Qbe,Cf],xc=Gr.length,Lbe=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Rbe="|";function Obe(e,t={}){return e.split(Rbe).map(a=>{let l=a.trim().split(Lbe).filter(i=>i&&!!i.trim()),s=[];for(let i=0,c=l.length;i!!(e[ti.AND]||e[ti.OR]),Kbe=e=>!!e[qr.PATH],Gbe=e=>!as(e)&&vf(e)&&!Yr(e),Sc=e=>({[ti.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Bf(e,t,{auto:a=!0}={}){const l=s=>{let i=Object.keys(s);const c=Kbe(s);if(!c&&i.length>1&&!Yr(s))return l(Sc(s));if(Gbe(s)){const f=c?s[qr.PATH]:i[0],_=c?s[qr.PATTERN]:s[f];if(!Ol(_))throw new Error(hbe(f));const g={keyId:Kr(f),pattern:_};return a&&(g.searcher=zr(_,t)),g}let p={children:[],operator:i[0]};return i.forEach(f=>{const _=s[f];as(_)&&_.forEach(g=>{p.children.push(l(g))})}),p};return Yr(e)||(e=Sc(e)),l(e)}function jbe(e,{ignoreFieldNorm:t=$t.ignoreFieldNorm}){e.forEach(a=>{let l=1;a.matches.forEach(({key:s,norm:i,score:c})=>{const p=s?s.weight:null;l*=Math.pow(c===0&&p?Number.EPSILON:c,(p||1)*(t?1:i))}),a.score=l})}function zbe(e,t){const a=e.matches;t.matches=[],pl(a)&&a.forEach(l=>{if(!pl(l.indices)||!l.indices.length)return;const{indices:s,value:i}=l;let c={indices:s,value:i};l.key&&(c.key=l.key.src),l.idx>-1&&(c.refIndex=l.idx),t.matches.push(c)})}function qbe(e,t){t.score=e.score}function Ybe(e,t,{includeMatches:a=$t.includeMatches,includeScore:l=$t.includeScore}={}){const s=[];return a&&s.push(zbe),l&&s.push(qbe),e.map(i=>{const{idx:c}=i,p={item:t[c],refIndex:c};return s.length&&s.forEach(f=>{f(i,p)}),p})}class pn{constructor(t,a={},l){this.options={...$t,...a},this.options.useExtendedSearch,this._keyStore=new ybe(this.options.keys),this.setCollection(t,l)}setCollection(t,a){if(this._docs=t,a&&!(a instanceof Qd))throw new Error(mbe);this._myIndex=a||bf(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){pl(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const a=[];for(let l=0,s=this._docs.length;l-1&&(f=f.slice(0,a)),Ybe(f,this._docs,{includeMatches:l,includeScore:s})}_searchStringList(t){const a=zr(t,this.options),{records:l}=this._myIndex,s=[];return l.forEach(({v:i,i:c,n:p})=>{if(!pl(i))return;const{isMatch:f,score:_,indices:g}=a.searchIn(i);f&&s.push({item:i,idx:c,matches:[{score:_,value:i,norm:p,indices:g}]})}),s}_searchLogical(t){const a=Bf(t,this.options),l=(p,f,_)=>{if(!p.children){const{keyId:y,searcher:v}=p,b=this._findMatches({key:this._keyStore.get(y),value:this._myIndex.getValueForItemAtKeyId(f,y),searcher:v});return b&&b.length?[{idx:_,item:f,matches:b}]:[]}const g=[];for(let y=0,v=p.children.length;y{if(pl(p)){let _=l(a,p,f);_.length&&(i[f]||(i[f]={idx:f,item:p,matches:[]},c.push(i[f])),_.forEach(({matches:g})=>{i[f].matches.push(...g)}))}}),c}_searchObjectList(t){const a=zr(t,this.options),{keys:l,records:s}=this._myIndex,i=[];return s.forEach(({$:c,i:p})=>{if(!pl(c))return;let f=[];l.forEach((_,g)=>{f.push(...this._findMatches({key:_,value:c[g],searcher:a}))}),f.length&&i.push({idx:p,item:c,matches:f})}),i}_findMatches({key:t,value:a,searcher:l}){if(!pl(a))return[];let s=[];if(as(a))a.forEach(({v:i,i:c,n:p})=>{if(!pl(i))return;const{isMatch:f,score:_,indices:g}=l.searchIn(i);f&&s.push({score:_,key:t,value:i,idx:c,norm:p,indices:g})});else{const{v:i,n:c}=a,{isMatch:p,score:f,indices:_}=l.searchIn(i);p&&s.push({score:f,key:t,value:i,norm:c,indices:_})}return s}}pn.version="7.1.0";pn.createIndex=bf;pn.parseIndex=Fbe;pn.config=$t;pn.parseQuery=Bf;Nbe(Pbe);const Wbe=(Ge.get("payment_routes")||[]).filter(e=>!e.upcoming).map(e=>{const t=e.meta.admin_title||e.meta.title||e.meta.label||e.name;return{title:t,subtitle:u("Manage %1$s",t),path:"/settings/payments/"+e.path}}),Jbe=[{title:u("Dashboard"),path:"/"},{title:u("Orders"),path:"/orders"},{title:u("Create Order"),path:"/orders/add"},{title:u("Customers"),path:"/customers"},{title:u("Products"),path:"/products"},{title:u("Product Inventory"),path:"/products/inventory"},{title:u("Bulk Import Products"),path:"/products/bulk-insert"},{title:u("Integrations"),path:"/integrations"},{title:u("Coupons"),path:"/coupons"},{title:u("Logs"),path:"/logs"},{title:u("Taxes"),path:"/taxes"},{title:u("Reports"),path:"/reports/overview"},{title:u("Sales Report"),path:"/reports/sales"},{title:u("Orders Report"),path:"/reports/orders"},{title:u("Revenue Report"),path:"/reports/revenue"},{title:u("Refunds Report"),path:"/reports/refunds"},{title:u("Subscriptions Report"),path:"/reports/subscriptions"},{title:u("Future Renewals Report"),path:"/reports/subscriptions/future-renewals"},{title:u("Product Report"),path:"/reports/products"},{title:u("Customer Report"),path:"/reports/customer"},{title:u("Traffic Sources Report"),path:"/reports/sources"},...Wbe],Xbe=Jbe.map(({title:e,subtitle:t,path:a})=>({title:e,...t?{subtitle:t}:{},data:{type:"action",action:({router:l})=>{l.push({path:a})},show_description:!1}})),Zbe=[{title:"Theme",title_resolver:()=>{let t=(De.isDark()?"dark":"light")==="light"?u("Dark"):u("Light");return u("Change theme to %1$s",t)},data:{type:"action",action:()=>{let t=(De.isDark()?"dark":"light")==="light"?"dark":"light";De.apply(t,{fromShortcut:!0})}}}],Fc={"/settings/store-settings":u("Store Setup"),"/settings/store-settings/pages_setup":u("Pages Setup"),"/settings/store-settings/single_product_setup":u("Single Product & Order Setup"),"/settings/store-settings/cart_and_checkout":u("Cart and Checkout"),"/settings/store-settings/subscriptions_setup":u("Subscriptions Setup"),"/settings/store-settings/checkout_fields":u("Checkout Fields"),"/settings/email_notifications":u("Email Notifications"),"/settings/email_mailing_settings":u("Mailing Settings"),"/settings/email_mailing_settings/reminders":u("Reminders"),"/settings/licensing":u("Licensing"),"/settings/payments":u("Payment Settings"),"/settings/invoice-packing":u("Invoice & Packing Slips"),"/settings/pdf-template":u("PDF Templates"),"/settings/roles":u("Role Settings"),"/settings/addons":u("Features & Addons"),"/settings/tax_settings":u("Tax Settings"),"/settings/tax_settings/tax_rates":u("Tax Rates"),"/settings/tax_settings/eu":u("EU VAT Settings"),"/settings/storage":u("Storage Providers"),"/settings/coupons":u("Coupon Settings")};let xf=[];Object.keys(Fc).forEach(e=>{const t=Fc[e];xf.push({title:t,data:{type:"action",action:({router:a})=>{a.push({path:e})},description:u("Go to %1$s",t),show_description:!1}})});const e0e=[],t0e={Menu:Xbe,Actions:Zbe,Settings:xf,Shortcuts:e0e},Wr=[];Object.entries(t0e).forEach(([e,t])=>{t.forEach((a,l)=>{Wr.push({...a,id:`${e.toString().toLowerCase()}-${l}`,group:[e]})})});const a0e=()=>({shouldSort:!0,threshold:.6,keys:[{name:"title",getFn:e=>e.title},{name:"data.description",getFn:e=>e.data.description},{name:"group",weight:2,getFn:e=>e.group}]}),l0e={class:"navigable-list-container fct-global-search-result-container"},s0e={key:0,class:"no-results fct-global-search-result-not-found"},n0e={key:1},o0e=["tabindex","onClick","onKeydown"],i0e={__name:"NavigableList",props:{items:{type:Array,required:!0,default:()=>[]},noResultsText:{type:String,default:u("No results found")},onAction:{type:Function,required:!0}},setup(e,{expose:t}){const a=e,l=M(-1),s=Xr("listContainer"),i=M({}),c=(k,w)=>{w&&(i.value[k]=w)},p=k=>{const w=a.items.length;if(w===0)return;const S=w-1;k==="up"?l.value=l.value<=0?S:l.value-1:k==="down"&&(l.value=l.value>=S?0:l.value+1),f()},f=()=>{const k=s.value,w=i.value[l.value];w&&k&&(w.scrollIntoView({behavior:"smooth",block:"nearest"}),ke(()=>{w.focus()}))},_=k=>{l.value=k,g(k)},g=k=>{k>=0&&k{l.value=-1};return t({focusList:k=>{k=k??a.items.length-1,k>=0&&(l.value=k,ke(()=>{i.value[k]&&i.value[k].focus()}))},resetSelection:y,performFirstAction:()=>{a.items.length>0?(l.value=0,setTimeout(()=>{g(0)},200)):l.value=-1}}),be(()=>a.items,k=>{y(),k.length>0&&ke(()=>{})},{immediate:!0}),be(l,()=>{}),(k,w)=>(r(),h("div",l0e,[e.items.length===0?(r(),h("div",s0e,[n(J,{name:"Empty/GlobalSearch"}),R(" "+m(e.noResultsText),1)])):(r(),h("div",n0e,[o("ul",{ref_key:"listContainer",ref:s,class:"navigable-list fct-global-search-result-list"},[(r(!0),h(H,null,ae(e.items,(S,$)=>(r(),h("li",{key:$,ref_for:!0,ref:V=>c($,V),class:de({selected:$===l.value}),tabindex:$,onClick:V=>_($),onKeydown:[w[0]||(w[0]=xa(Ne(V=>p("up"),["prevent"]),["arrow-up"])),w[1]||(w[1]=xa(Ne(V=>p("down"),["prevent"]),["arrow-down"])),xa(V=>g($),["enter"])]},[ba(k.$slots,"default",{item:S,index:$,isSelected:$===l.value},void 0,!0)],42,o0e))),128))],512)]))]))}},Jr=lt(i0e,[["__scopeId","data-v-2379fe26"]]),r0e={class:"fct-search-result-label"},d0e={class:"fct-search-result-title"},u0e={key:0,class:"fct-search-result-subtitle"},c0e={key:1,class:"fct-search-result-subtitle"},A0e={class:"action-icon"},p0e={class:"recent-search-title"},f0e={class:"fct-search-result-label"},m0e={class:"fct-search-result-title"},h0e={key:0,class:"fct-search-result-subtitle"},_0e={key:1,class:"fct-search-result-subtitle"},v0e={class:"action-icon"},ur="recent_actions",g0e={__name:"ResultList",props:{query:{type:String,required:!0},searchResults:{type:Array,required:!0,default:()=>[]},onActionPerformed:{type:Function,required:!0},focusInput:{type:Function,required:!0},searchData:{type:Array,required:!0,default:()=>[]}},setup(e,{expose:t}){const a=ll();Yt().ctx;const l=e,s=M(0),i=M({}),c=M(),p=(S,$)=>{const F=S.item.data,x=_(F.type);if(x==="link"){let Q=_(F.url);_(F.new_tab)?window.open(Q,"_blank"):window.location.href=Q}else x==="action"&&_(F.action);f(S),l.onActionPerformed()},f=S=>{const $=S.item.id;let V=Qt.get(ur)||[];V=V.filter(F=>F!==$),V.unshift($),V=V.slice(0,5),Qt.set(ur,V)},_=S=>typeof S=="function"?g(S):S,g=async S=>await S({query:l.query,router:a}),y=()=>{var S;(S=c.value)==null||S.resetSelection()},v=()=>{var S;(S=c.value)==null||S.focusList(0)},b=()=>{var S;(S=c.value)==null||S.performFirstAction()};be(()=>l.searchResults,async()=>{i.value={},i.value=l.searchResults??{},s.value=Object.keys(i.value).length-1;let S=i.value;for(const $ of Object.keys(S)){const V=S[$];V.item.title_resolver&&(S[$].item.title=await _(V.item.title_resolver))}i.value={...S}});const k=M([]),w=async()=>{const S=Qt.get(ur)||[];let $=it.whereIn(l.searchData,"id",S),V=[];for(const F of $)typeof F.title_resolver=="function"&&(F.title=await _(F.title_resolver)),V.push({item:F});k.value=V};return Ie(()=>{w()}),t({focusList:v,resetSelection:y,performFirstAction:b,fetchRecentActions:w}),(S,$)=>(r(),h(H,null,[e.query||k.value.length<1?(r(),E(Jr,{key:0,items:e.searchResults,"on-action":p,"no-results-text":A(u)("No matches found"),ref_key:"navigableList",ref:c},{default:d(({item:V,index:F,isSelected:x})=>{var Q,D,T;return[o("span",r0e,[o("span",d0e,m(V.item.title),1),(Q=V.item)!=null&&Q.subtitle?(r(),h("span",u0e,m(V.item.subtitle),1)):((T=(D=V.item)==null?void 0:D.data)==null?void 0:T.show_description)===!0?(r(),h("span",c0e,m(V.item.data.description),1)):B("",!0)]),o("div",A0e,[n(J,{name:"Enter"})])]}),_:1},8,["items","no-results-text"])):B("",!0),!e.query&&k.value.length>0?(r(),h(H,{key:1},[o("span",p0e,m(A(u)("Recent Actions")),1),n(Jr,{items:k.value,"on-action":p,"no-results-text":A(u)("No matches found"),ref_key:"navigableList",ref:c},{default:d(({item:V,index:F,isSelected:x})=>{var Q,D,T;return[o("span",f0e,[o("span",m0e,m(V.item.title),1),(Q=V.item)!=null&&Q.subtitle?(r(),h("span",h0e,m(V.item.subtitle),1)):((T=(D=V.item)==null?void 0:D.data)==null?void 0:T.show_description)===!0?(r(),h("span",_0e,m(V.item.data.description),1)):B("",!0)]),o("div",v0e,[n(J,{name:"Enter"})])]}),_:1},8,["items","no-results-text"])],64)):B("",!0)],64))}},y0e=lt(g0e,[["__scopeId","data-v-ccb0ebef"]]),b0e={class:"fct-global-search-product-wrap"},w0e={class:"fct-global-search-product-left-info"},C0e={key:0,class:"type"},k0e={key:0,class:"price-and-status"},B0e={__name:"Product",props:{product:{type:Object,required:!0}},setup(e){const t=l=>l.min_price===l.max_price?Gt(l.min_price,!0):`${Gt(l.min_price,!0)} - ${Gt(l.max_price,!0)}`,a=l=>l==="publish"?u("published"):l==="future"?u("scheduled"):l;return(l,s)=>(r(),h("div",b0e,[o("div",w0e,[n(ld,{product:e.product},null,8,["product"]),e.product.detail?(r(),h("span",C0e,[R(m(A(ca).headline(e.product.detail.variation_type))+" ",1),s[0]||(s[0]=o("br",null,null,-1)),R(" "+m(A(ca).headline(e.product.detail.fulfillment_type)),1)])):B("",!0)]),e.product.detail?(r(),h("span",k0e,[R(m(t(e.product.detail))+" ",1),(r(),E(ma,{key:e.product.ID,status:e.product.post_status},{default:d(()=>[R(m(a(e.product.post_status)),1)]),_:1},8,["status"]))])):B("",!0)]))}},x0e={class:"fct-global-search-order-wrap"},S0e={class:"fct-global-search-order-header"},F0e={class:"fct-global-search-order-id"},$0e={class:"items"},E0e={class:"fct-global-search-order-header-meta"},U0e={class:"date"},I0e=["innerHTML"],Q0e={class:"customer-name"},D0e={class:"fct-global-search-order-status-wrapper"},V0e=["src","alt"],T0e={__name:"Order",props:{order:{type:Object,required:!0}},setup(e){const t=a=>it.get(window,"fluentCartAdminApp.payment_logos."+a);return(a,l)=>{var i;const s=C("el-tag");return r(),h("div",x0e,[o("div",S0e,[o("div",F0e,[R(" #"+m(e.order.id)+" ",1),o("span",$0e,m(A(u)("%s Items",e.order.order_items.length)),1)]),o("div",E0e,[o("span",U0e,[n(Na,{"date-time":e.order.created_at},null,8,["date-time"])]),l[0]||(l[0]=o("span",{class:"circle"},null,-1)),o("span",{class:"total-price",innerHTML:A(Gt)(e.order.total_amount,!0,!1,e.order.currency)},null,8,I0e),l[1]||(l[1]=o("span",{class:"circle"},null,-1)),o("span",Q0e,m(((i=e.order.customer)==null?void 0:i.full_name)||A(u)("No Name")),1)])]),o("div",D0e,[n(ma,{status:e.order.payment_status,"hide-icon":!0},null,8,["status"]),t(e.order.payment_method)?(r(),h("img",{key:0,src:t(e.order.payment_method),alt:A(ca).headline(e.order.payment_method)},null,8,V0e)):(r(),E(s,{key:1,type:"info",round:"",size:"small",class:"capitalize"},{default:d(()=>[R(m(A(ca).headline(e.order.payment_method)),1)]),_:1}))])])}}},M0e={class:"fct-global-search-customer-wrap"},L0e={class:"fct-customer-card"},R0e={class:"fct-customer-avatar"},O0e=["src"],H0e={class:"fct-customer-details"},P0e={class:"fct-customer-name"},N0e={class:"fct-customer-id"},K0e={class:"fct-customer-email"},G0e={class:"purchase-count"},j0e={class:"date"},z0e={__name:"Customer",props:{customer:{type:Object,required:!0}},setup(e){return(t,a)=>(r(),h("div",M0e,[o("div",L0e,[o("div",R0e,[o("img",{src:e.customer.photo,alt:"avatar"},null,8,O0e)]),o("div",H0e,[o("div",P0e,[R(m(e.customer.full_name||t.$t("No Name"))+" ",1),o("span",N0e,"#"+m(e.customer.id),1)]),o("div",K0e,[R(m(e.customer.email)+" ",1),a[0]||(a[0]=o("span",{class:"circle"},null,-1)),a[1]||(a[1]=R()),o("span",G0e,"Purchase: "+m(e.customer.purchase_count),1)])])]),o("span",j0e,[n(Na,{"date-time":e.customer.last_purchase_date},null,8,["date-time"])])]))}},q0e={class:"fct-global-search-coupon-wrap"},Y0e={class:"amount"},W0e={__name:"Coupon",props:{coupon:{type:Object,required:!0}},setup(e){return(t,a)=>(r(),h("div",q0e,[o("span",null,m(e.coupon.title),1),o("span",null,m(e.coupon.code),1),o("span",Y0e,m(A(Gt)(e.coupon.amount,!0)),1)]))}},J0e={class:"fct-global-remote-result-container"},X0e={class:"fct-global-remote-result-label"},Z0e={class:"text"},ewe={class:"navigable-content"},twe={class:"action-icon"},awe={__name:"RemoteResult",emits:["close-modal","onRemoteSearchStateChange"],setup(e,{expose:t,emit:a}){const l=a,s=ll(),i=M({}),c=M(""),p=M(),f=M({}),_=M([]),g=T=>{y.value=!1,_.value=S.data.tableData,l("onRemoteSearchStateChange",!1)},y=M(!1),v={orders:nA({fetch:!1}),products:Hp({fetch:!1}),customers:sA({fetch:!1}),coupons:df({fetch:!1})},b=()=>{},k=()=>{var T;(T=p.value)==null||T.focusList(0)},w=()=>{var T;(T=p.value)==null||T.performFirstAction()};Is(()=>{for(const T of Object.keys(v))v[T].onDataLoaded(g)});let S=null;const $=()=>{S=v[i.value.key],S.data.search=c.value,y.value=!0,S.fetch(),l("onRemoteSearchStateChange",!0)},V=id.debounce($,800),F=(T,U)=>{if(_.value=[],S&&(S.data.search=""),i.value=U,f.value={title:U.title,key:U.key},!T){c.value="";return}c.value=T,V()},x=()=>{s.push({name:f.value.key,query:{search:c.value}}),l("close-modal")},Q={orders:{name:"view_order",key:"order_id"},products:{name:"product_edit",key:"product_id"},customers:{name:"view_customer",key:"customer_id"},coupons:{name:"edit_coupon",key:"coupon_id"}},D=T=>{i.value.key in Q&&(s.push({name:Q[i.value.key].name,params:{[Q[i.value.key].key]:T.id||T.ID,action:"edit"}}),l("close-modal"))};return t({fetchData:F,focusList:k,resetSelection:b,performFirstAction:w}),(T,U)=>(r(),h("div",J0e,[o("div",X0e,[o("span",Z0e,m(i.value.title),1),f.value.key?(r(),h("span",{key:0,class:"view-all",onClick:x},m(c.value?A(u)('Search "%1$s" in %2$s',c.value,f.value.title):A(u)("See All %s",f.value.title)),1)):B("",!0)]),n(Jr,{items:_.value,"on-action":I=>{D(I)},"no-results-text":c.value?A(u)("No matches found for %s",i.value.title):A(u)("Type something to find %s",i.value.title),ref_key:"navigableList",ref:p},{default:d(({item:I,index:O,isSelected:L})=>[o("div",ewe,[i.value.key==="products"?(r(),E(B0e,{key:0,product:I},null,8,["product"])):B("",!0),i.value.key==="orders"?(r(),E(T0e,{key:1,order:I},null,8,["order"])):B("",!0),i.value.key==="customers"?(r(),E(z0e,{key:2,customer:I},null,8,["customer"])):B("",!0),i.value.key==="coupons"?(r(),E(W0e,{key:3,coupon:I},null,8,["coupon"])):B("",!0)]),o("div",twe,[n(J,{name:"Enter"})])]),_:1},8,["items","on-action","no-results-text"])]))}},lwe={class:"fct-global-search-input-wrap"},swe=["aria-label"],nwe={class:"fct-setting-search-icon"},owe={class:"fct-global-search-input-container"},iwe={key:0,class:"searched-item"},rwe={class:"fct-global-searching-for"},dwe={class:"fct-global-searching-for-label"},uwe={class:"fct-global-searching-suggestion-list"},cwe=["onClick"],Awe={class:"dialog-footer is-border"},pwe={class:"fct-search-commands"},fwe={class:"command-key"},mwe={class:"command-key"},hwe={class:"label"},_we={class:"command-key"},vwe={class:"label"},gwe={class:"label"},ywe={__name:"GlobalSearch",setup(e){Yt().ctx,ll();const t=M(!1),a=M(""),l=M({}),s=M(),i=M(""),c=M([u("orders"),u("products"),u("customers"),u("coupons"),u("settings"),u("menus"),u("shortcuts...")]),p=M(0),f=M(!0),_=M(0),g=M(null),y=M(null),v=M(70),b=M(40),k=M(1700),w=()=>{ke(()=>{$()})},S=()=>{var W,j;D.value?(W=X.value)==null||W.resetSelection():(j=F.value)==null||j.resetSelection(),D.value=!1,P.value=!1,V()},$=()=>{var W;(W=s.value)==null||W.focus()},V=()=>{D.value=!1,l.value=[],t.value=!1,a.value="",T.value=null},F=M(),x=W=>{let j=W.includes(","),ie={},he=[];(j?W.split(","):[W]).forEach(se=>{se.includes(":")?Q(se,ie,he):he.push(se)});let ye=[];return Object.keys(ie).forEach(se=>{const fe=ie[se];fe.length>0?fe.forEach($e=>{$e.length>0?ye.push({group:"'"+se,title:$e}):ye.push({group:"'"+se})}):ye.push({group:"'"+se})}),he.forEach(se=>{se.length>0&&ye.push({title:se})}),ye},Q=(W,j,ie)=>{if(W.length===1)return;let he=W.split(":"),me=he[0],ye=he[1];me.length>0?(j.hasOwnProperty(me)||(j[me]=[]),ye.length>0&&j[me].push(ye)):ie.push(ye)},D=M(!1),T=M(null),U=M({o:{key:"orders",title:u("Orders")},p:{key:"products",title:u("Products")},c:{key:"customers",title:u("Customers")},d:{key:"coupons",title:u("Coupons")}}),I=W=>{T.value=W,D.value=!0,l.value={},ke(()=>{var j,ie;(j=X.value)==null||j.fetchData(a.value,W),(ie=s.value)==null||ie.focus()})},O=()=>{var W;l.value=[],T.value=null,a.value="",D.value=!1,(W=s.value)==null||W.focus(),P.value=!1},L=()=>{var W;(W=X.value)==null||W.fetchData(a.value,T.value)},P=M(!1),q=W=>{P.value=W,ke(()=>{var j;(j=s.value)==null||j.focus()})},X=M(),G=_s(),te=()=>{if(t.value){$();return}const W=["o","p","c","d"];G.bind(W,j=>{j.preventDefault();const ie=U.value[j.key];ie&&I(ie)}),t.value=!0,ke(()=>{var j;(j=F.value)==null||j.fetchRecentActions()}),setTimeout(()=>{G.unbind(W)},800)};G.bind(["/"],W=>{!t.value&&ne()||(W.preventDefault(),te())});const ne=()=>{const W=document.activeElement;if(!W)return!1;const j=W.tagName;return j==="INPUT"||j==="TEXTAREA"||j==="SELECT"||W.isContentEditable},re=()=>{if(g.value)return;const W=()=>{if(s.value&&s.value.length>0)return;const ie=c.value[p.value];if(f.value)_.value{y.value=null},k.value));else{if(y.value)return;_.value>0?(_.value--,i.value=ie.slice(0,_.value)):(f.value=!0,p.value=(p.value+1)%c.value.length)}},j=()=>{W();const ie=f.value?v.value:y.value?120:b.value;g.value=setTimeout(j,ie)};j()},K=M(!1);let Y;return Ie(()=>{re(),Y=new pn(Wr,a0e());const W=document.getElementById("fct_admin_menu_search");if(W){const j=W.querySelector(".fct-global-search-input-wrap");j&&j.remove()}K.value=!!W,window.fluentCart=window.fluentCart||{},window.fluentCart.openSearch=te}),xt(()=>{window.fluentCart&&delete window.fluentCart.openSearch}),(W,j)=>{const ie=C("el-input"),he=C("el-dialog");return r(),h(H,null,[K.value?(r(),E(li,{key:0,to:"#fct_admin_menu_search"},[o("div",lwe,[o("button",{onClick:te,type:"button",class:"fct-setting-search-button","aria-label":A(u)("Search")},[o("span",nwe,[n(J,{name:"Search"})]),j[6]||(j[6]=o("span",{class:"fct-global-search-button-keys"},[o("kbd",{class:"fct-global-search-button-key"},"/")],-1))],8,swe)])])):B("",!0),n(he,{modelValue:t.value,"onUpdate:modelValue":j[5]||(j[5]=me=>t.value=me),onOpened:w,onClosed:S,class:"fct-global-search-container","append-to-body":!0},{header:d(()=>[o("div",owe,[n(J,{name:"Search",class:"search-icon"}),T.value!=null?(r(),h("div",iwe,[R(m(T.value.title)+" ",1),n(J,{name:"Cross",class:"searched-item-remove",onClick:O})])):B("",!0),n(ie,{class:"mousetrap",placeholder:A(u)("Search for %1$s",i.value),autofocus:"",ref_key:"searchRef",ref:s,id:"fct-global-search-input",disabled:P.value,onKeydown:[j[0]||(j[0]=xa(Ne(()=>{var me,ye;if(D.value){(me=X.value)==null||me.focusList();return}(ye=F.value)==null||ye.focusList()},["prevent"]),["arrow-down"])),j[1]||(j[1]=xa(Ne(()=>{var me,ye;if(D.value){(me=X.value)==null||me.performFirstAction();return}(ye=F.value)==null||ye.performFirstAction()},["prevent"]),["enter"])),j[2]||(j[2]=xa(()=>{a.value.length===0&&(T.value=null,D.value=!1)},["backspace"]))],onInput:j[3]||(j[3]=()=>{if(D.value){L();return}let me=a.value.includes(","),ye=a.value.includes(":");if(!me&&!ye)l.value.value=A(Y).search(a.value);else{const se=x(a.value);l.value.value=A(Y).search({$or:se})}}),modelValue:a.value,"onUpdate:modelValue":j[4]||(j[4]=me=>a.value=me),clearable:""},null,8,["placeholder","disabled","modelValue"])])]),default:d(()=>[n(va,{visible:!T.value&&a.value.length===0,accordion:""},{default:d(()=>[o("div",rwe,[o("div",dwe,m(A(u)("Searching for")),1),o("div",uwe,[(r(!0),h(H,null,ae(U.value,me=>{var ye;return r(),h("div",{key:me.key,onClick:se=>I(me),class:de(["fct-global-searching-suggestion",((ye=T.value)==null?void 0:ye.key)===me.key?"active":""])},m(me.title),11,cwe)}),128))])])]),_:1},8,["visible"]),D.value?(r(),E(awe,{key:0,ref_key:"remoteResultRef",ref:X,query:a.value,tag:T.value,onCloseModal:V,onOnRemoteSearchStateChange:q},null,8,["query","tag"])):(r(),E(y0e,{key:1,ref_key:"resultListRef",ref:F,query:a.value,"search-results":l.value.value,onActionPerformed:V,focusInput:$,searchData:A(Wr)},null,8,["query","search-results","searchData"])),o("div",Awe,[o("ul",pwe,[o("li",null,[o("span",fwe,[n(J,{name:"ArrowUp"})]),o("span",mwe,[n(J,{name:"ArrowDown"})]),o("span",hwe,m(A(u)("To navigate")),1)]),o("li",null,[o("span",_we,[n(J,{name:"Enter"})]),o("span",vwe,m(A(u)("To select")),1)]),o("li",null,[j[7]||(j[7]=o("kbd",{class:"command-key"},"esc",-1)),o("span",gwe,m(A(u)("To close")),1)])])])]),_:1},8,["modelValue"])],64)}}},bwe={class:"fl_app fluent-cart-admin-pages"},wwe=Object.assign({name:"DashboardApplication"},{__name:"Application",setup(e){const t=M("");Ie(()=>{jQuery(".notice:not(.fluent-cart), .error:not(.fluent-cart), #ehp-admin-cb").remove(),t.value=a(),l.value=!!document.getElementById("theme-button-container");const c=document.querySelector(".fct_admin_menu_wrap"),p=()=>{window.scrollY>10?c==null||c.classList.add("scroll-header"):c==null||c.classList.remove("scroll-header")};window.addEventListener("scroll",p)});const a=()=>window.location.href,l=M(!1),s=sl();be(()=>s.fullPath,()=>{t.value=a()});const i=N(()=>!(s.fullPath.includes("reports")||s.fullPath.includes("settings")));return(c,p)=>{const f=C("router-view");return r(),h("div",null,[n(ywe),i.value?(r(),E(Da,{key:0})):B("",!0),o("div",bwe,[n(f)]),l.value?(r(),E(li,{key:1,to:"#theme-button-container"},[n(ube)])):B("",!0)])}}});let $c=!1;function Cwe(e){return{data:function(){return{appVars:window.fluentCartAdminApp}},methods:{$get:ue.get,$post:ue.post,$put:ue.put,$del:ue.delete,$t:u,$n:Fo,formatMoney(t,a,l=!1){return!t&&l?"":(t||(t="0.00"),Ge.get("shop.currency_sign")+" "+t)},formatCents(t,a,l=!1){return!t&&l?"":(t?t=(t*100).toFixed(2):t="0.00",a?(t=new Intl.NumberFormat("en-US").format(t),Ge.get("shop.currency_sign")+" "+t):t)},formatNumber(t,a=!0,l=!1,s){return pt.formatNumber(t,a,l,s)},formatNumberForOrder(t,a,l=!0,s=!1){return pt.formatForOrder(t,a,l,s)},getAddress(t,a="billing"){let l=[t[a+"_address_1"],t[a+"_address_2"],t[a+"_city"],t[a+"_city"],t[a+"_state"],t[a+"_zip"],t[a+"_country"]];return l=l.filter(s=>!!s).join(", "),l||"no "+a+" address"},getOrderAddress(t,a="billing",l=!1){return fm(t,a,l)},changeTitle(t){jQuery("head title").text(t+" - FluentCart")},handleError(t){if(!t)return;let a="";typeof t=="string"?a=t:t&&t.message?a=t.message:a=t,typeof t=="object"&&(a=this.convertToText(t)),a||(a="Something is wrong!"),this.$notify({type:"error",title:"Error",message:a,dangerouslyUseHTMLString:!0})},convertToText(t){const a=[];if(typeof t=="object"&&t.join===void 0)for(const l in t)a.push(this.convertToText(t[l]));else if(typeof t=="object"&&t.join!==void 0)for(const l in t)a.push(this.convertToText(t[l]));else typeof t=="function"||typeof t=="string"&&a.push(t);return a.join("
")},handleSuccess:t=>{z.success(t)},handleMessage:(t,a="info",l=40,s=1e3)=>{Tc.show(t,a,l,s)},Storage:()=>Qt,buildFormRendererValue(t,a){let l={};return Object.keys(t).forEach(s=>{let i=t[s];["grid"].includes(i.type??"")?l[s]=this.buildFormRendererValue(i.schema??{},a[s]??{}):l[s]=a[s]??""}),l},registerCopyAction(){$c||($c=!0,document.addEventListener("click",t=>{t.target.matches(".copyable-content")&&Zl.copy(t.target.textContent)}))},currencySign(){return Ge.get("shop.currency_sign")},getPlaceholderImage(){return ms.getUrl("images/placeholder.svg")},saveLocal(t,a){Qt.set(t,a)},getLocal(t){return Qt.get(t)},hasPermission(t){return In.hasPermission(t)}}}}function kwe(e){e.beforeEach((t,a,l)=>{const s=it.get(t,"meta.permission");return s?In.resolve({permission:s,permissionType:it.get(t,"meta.permissionType")})?l():l({name:"unauthorized"}):(Ge.get("app_config.env"),l())})}function Bwe(e){const t={fluent_cart_products:["fluent_cart_inventory","fluent_cart_attributes"]},a=l=>{if(!l)return;const s="fluent_cart_"+l;Object.entries(t).forEach(([i,c])=>{const p=s===i;c.forEach(f=>{const _=jQuery(".toplevel_page_fluent-cart li."+f);p?_.show():_.hide()})})};e.afterEach((l,s)=>{const i=l.meta.active_menu;jQuery(".fct_menu li").removeClass("active_admin_menu"),jQuery(".fct_menu li.fct_menu_item_"+i).addClass("active_admin_menu"),jQuery(".toplevel_page_fluent-cart li").removeClass("current"),jQuery(".toplevel_page_fluent-cart li.fluent_cart_"+i).addClass("current"),a(i),l.meta.title&&jQuery("head title").text(l.meta.title+" - FluentCart")})}const xwe={mounted(e,t){const a=t.value,l=1e3,s=0,i=performance.now(),c=()=>{const p=performance.now()-i,f=Math.min(p/l,1),_=(s+f*(a-s)).toFixed(2);e.textContent=_,f<1&&requestAnimationFrame(c)};c()},updated(e,t){const a=t.value,l=2e3,s=0,i=performance.now(),c=()=>{const p=performance.now()-i,f=Math.min(p/l,1),_=(s+f*(a-s)).toFixed(2);e.textContent=_,f<1&&requestAnimationFrame(c)};c()}},Swe={__name:"Unauthorized",setup(e){return(t,a)=>(r(),h("span",null,m(A(u)("You are not allowed")),1))}},Fwe=window.fluent_cart_admin.hooks.applyFilters("fluent_cart_routes",ibe);let Ec=!1;document.addEventListener("fcart_renew_rest_nonce",function(e){Ec||xl.alert(u("Your session has expired due to inactivity. Please refresh the page to continue."),u("Session Expired"),{confirmButtonText:u("Reload"),callback:t=>{Ec=!1,window.location.reload()}})});const $we=[Wf,Jf,Xf,Lc,Zf,ed,em,tm,ni,am,lm,Oc],jl=Of(wwe);jl.config.globalProperties.appVars=Ge.get();jl.provide("appVars",Ge.get());jl.mixin(Cwe());jl.directive("loading",gm);jl.directive("animate",xwe);Fm(jl);const Dd=Hf({routes:[...Object.values(Fwe),{path:"/unauthorized",name:"unauthorized",component:Swe,props:!0},{path:"/:path(.*)*",name:"NotFound",component:ri,props:!0}],history:Pf(),scrollBehavior(e,t,a){return a||{top:0,behavior:"smooth"}}});jl.use(Dd);kwe(Dd);Bwe(Dd);$we.forEach(e=>{jl.component(e.name,e)});const Vd=Ge.get("el_strings"),Sf=Ge.get("datei18");Vd.el.datepicker.weeks=Sf.weekdaysShort;Vd.el.datepicker.months=Sf.monthsShort;jl.use(ym,{locale:Vd});jl.mount("#fluent_cart_plugin_app");if(Ge.get("has_data_migrations")){let e=0;const t=()=>{ue.post("data-backfills/run").then(a=>{a&&a.status==="running"&&++e<100&&t()}).catch(()=>{})};t()}export{Kn as E};