`:F+="
",F+=`
${V.marker}
${V.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)",ft.currencySign),axisLabel:{color:p.value?"#ffffff":"#696778",fontSize:12,formatter:D=>ft.formatScaledChart(D)},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(D=>!isNaN(D)),0)-5,max:Math.max(...v.value.filter(D=>!isNaN(D)),0)+5}],series:y.value};try{w.setOption($,{notMerge:!0,replaceMerge:["series"]})}catch(D){i.value=`Error updating chart: ${D.message}`}},S=($,D,F,B,U=0)=>({name:$,type:D,barMaxWidth:t.barMaxWidth,areaStyle:D==="line"?null:void 0,data:F,smooth:D==="line",color:B,lineStyle:D==="line"?{width:2}:void 0,yAxisIndex:U,emphasis:{scale:2,itemStyle:{color:p.value?c.blue[800]:c.blue[400]}}});return be([()=>t.data,s],()=>{xe(b)},{deep:!0}),Bt(()=>{window.removeEventListener("onFluentCartThemeChange",b,!1),window.removeEventListener("fluentCartCurrencyChange",b,!1),w&&(w.dispose(),w=null)}),Ie(()=>{window.addEventListener("onFluentCartThemeChange",b),window.addEventListener("fluentCartCurrencyChange",b),xe(k)}),($,D)=>(r(),h("div",Bue,[n(Se,{id:"chartContainer",ref_key:"cardRef",ref:l},{default:d(()=>[n(Ve,{title:A(u)(e.title),title_size:"small",border_bottom:""},{action:d(()=>D[0]||(D[0]=[])),_:1},8,["title"]),n(ke,{class:"p-0"},{default:d(()=>[i.value?(r(),h("div",xue,m(i.value),1)):x("",!0),e.isEmpty?(r(),E(Ct,{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)]))}},Cc=nt(Sue,[["__scopeId","data-v-a0726f58"]]),Fue={class:"fct-country-volume-chart-wrap"},$ue={class:"fct-btn-group sm"},Eue=.05,Uue={__name:"CountryVolumeChart",props:{data:{type:Object,required:!0},title:{type:String,default:""}},setup(e){const t=e,a=T(null),l=T(null);let s=null;const i=T("bar");T("");const c=T(Te.isDark()),p=K(()=>c.value?["#8FC0F5","#4E90E8","#2E6BC4","#1E4C90","#143562"]:["#9CC9FA","#3E9DF6","#1573D5","#0B57A3","#083C73"]),f=F=>{const B=F.replace("#",""),U=parseInt(B.substring(0,2),16),Q=parseInt(B.substring(2,4),16),V=parseInt(B.substring(4,6),16);return(U*299+Q*587+V*114)/1e3>150?"#0B3A66":"#ffffff"},_=K(()=>{const F=Array.isArray(t.data.by_countries)?t.data.by_countries:Object.values(t.data.by_countries);return!F.length||!F.every(B=>!!B)}),g=Te.colors,y=K(()=>{const F=t.data.by_month||{};return Object.keys(F).sort().map(U=>{const Q=F[U],V=Object.values(Q).reduce((M,O)=>M+O,0),I=Object.entries(Q).sort((M,O)=>M[1]-O[1]).reduce((M,[O,L])=>({...M,[O]:L}),{});return{label:U,countries:I,total:V}})}),v=K(()=>y.value.length?y.value.map(F=>{try{const[B,U]=F.label.split("-");return lt(new Date(B,U-1)).locale(Zl()).format(Ll("month_year"))}catch{return F.label}}):[]),w=K(()=>{const F={};Object.values(t.data.by_month||{}).forEach(Q=>{Object.entries(Q).forEach(([V,I])=>{F[V]=(F[V]||0)+I})}),Object.entries(t.data.by_countries||{}).forEach(([Q,V])=>{F[Q]=V});const B=p.value,U=B[B.length-1];return Object.keys(F).sort((Q,V)=>F[V]-F[Q]).reduce((Q,V,I)=>(Q[V]=B[I]||U,Q),{})}),k=K(()=>y.value.reduce((F,B)=>Math.max(F,B.total),0)),b=K(()=>{const F=t.data.by_month||{},B=new Set;Object.values(F).forEach(V=>{Object.keys(V).forEach(I=>B.add(I))});const U=p.value,Q=k.value;return Array.from(B).reverse().map(V=>{const I=w.value[V]||U[U.length-1],M=f(I),O=y.value.map(L=>{const H=L.countries[V]||0,j=Q>0&&H/Q>=Eue;return{value:H/100,label:{show:H>0&&j,position:"inside",formatter:V,color:M,fontSize:10,fontWeight:"bold"}}});return{name:V,type:i.value,stack:"total",data:O,itemStyle:{color:I},lineStyle:{color:I}}})}),S=()=>{if(!a.value)return;s=na(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:Ql(c.value,g.report.dark_cyan_blue_16,g.report.light_gray_cyan_blue,i.value),borderWidth:1,confine:!0,position:wl,formatter:B=>{const U=c.value?"#ffffff":"#565865",Q=c.value?g.report.dark_cyan_blue_16:g.report.light_gray_blue,V=y.value[B[0].dataIndex].total;let I=B[0].axisValue;return B.filter(M=>M.value>0).sort((M,O)=>O.value-M.value).forEach(M=>{const O=za(M.value*100);I+=`
${M.marker}
${Qs(M.seriesName)}
${O}
`}),I+=`
${u("Total")}
${za(V)}
`,I}},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)",ft.currencySign),axisLabel:{color:c.value?"#ffffff":"#696778",fontSize:12,formatter:B=>ft.formatScaled(B*100)},splitLine:{show:!0,lineStyle:{color:c.value?"#253241":"#D6DAE1",type:"dashed"}}},series:b.value};s.setOption(F)},$=()=>{c.value=Te.isDark(),xe(()=>{S()})},D=()=>{s&&(s.dispose(),s=null),S()};return Ie(()=>{window.addEventListener("onFluentCartThemeChange",$),window.addEventListener("fluentCartCurrencyChange",D),xe(S)}),Bt(()=>{window.removeEventListener("onFluentCartThemeChange",$,!1),window.removeEventListener("fluentCartCurrencyChange",D,!1)}),be(()=>c.value,()=>{s&&(s.dispose(),S())}),be(()=>t.data,()=>{s&&S()}),(F,B)=>(r(),h("div",Fue,[n(Se,{id:"chartContainer",ref_key:"cardRef",ref:l},{default:d(()=>[n(Ve,{title:e.title,title_size:"small",border_bottom:""},{action:d(()=>[o("div",$ue,[n(Jm,{targetRef:a.value},null,8,["targetRef"])])]),_:1},8,["title"]),n(ke,{class:"p-0"},{default:d(()=>[_.value?(r(),E(Ct,{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)]))}},kc=nt(Uue,[["__scopeId","data-v-c6534652"]]),Iue={class:"fct-card-header-title is-small"},Bc={__name:"CountryNetChart",props:{data:{type:Object,required:!0},title:{type:String,default:""}},setup(e){const t=e,a=Te.colors.report,l=T(Te.isDark()),s=T(null),i=T("line"),c=T(t.data),p=K(()=>({textColor:l.value?"#ffffff":"#696778",borderColor:l.value?"#2C3C4E":"#c0c4ca",splitLineColor:l.value?"#253241":"#D6DAE1",bgColor:l.value?"#2d3748":"#ffffff"})),f=K(()=>Object.values(c.value).every(b=>b===0)),_=K(()=>Object.keys(c.value)),g=K(()=>[{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=na(s.value),w())},w=()=>{if(!y)return;const b={legend:{show:!1},tooltip:{trigger:"axis",backgroundColor:p.value.bgColor,borderColor:p.value.borderColor,borderWidth:1,textStyle:{color:p.value.textColor},axisPointer:Ql(l.value,a.dark_cyan_blue_16,a.light_gray_blue,i.value),confine:!0,position:wl,formatter:S=>{let $=Qs(S[0].name);const D=l.value?"#ffffff":"#565865";return S.forEach(F=>{const B=za(F.value);$+=`
${F.marker}
${F.seriesName}
${B}
`}),$}},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=>ft.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(b,{notMerge:!0,replaceMerge:["series"]})};be([()=>c.value,i,()=>l.value],()=>{xe(w)},{deep:!0});const k=()=>{l.value=Te.isDark(),xe(()=>{w()})};return Ie(()=>{window.addEventListener("onFluentCartThemeChange",k,!1),window.addEventListener("fluentCartCurrencyChange",w),xe(v)}),Bt(()=>{window.removeEventListener("onFluentCartThemeChange",k,!1),window.removeEventListener("fluentCartCurrencyChange",w,!1)}),(b,S)=>(r(),E(Se,null,{default:d(()=>[e.title!==""?(r(),E(Ve,{key:0,border_bottom:!0},{title:d(()=>[o("h3",Iue,m(e.title),1)]),_:1})):x("",!0),n(ke,null,{default:d(()=>[f.value?(r(),E(Ct,{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}))}},Que={class:"fct-overview-report-loader-wrap"},Due={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},Vue={class:"fct-card-header-title is-small"},Tue={class:"flex gap-2 mt-1"},Mue={class:"py-6"},Lue={class:"grid grid-cols-1"},Rue={class:"fct-card-header-title is-small"},Oue={class:"py-6"},Pue={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-2"},Hue={class:"fct-card-header-title is-small"},Nue={class:"flex gap-2 mt-1"},Kue={class:"py-6"},Gue={class:"grid grid-cols-1"},zue={class:"fct-card-header-title is-small"},jue={class:"py-6"},que={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-2"},Yue={class:"fct-card-header-title is-small"},Wue={class:"py-6"},Jue={__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",Que,[o("div",Due,[(r(),h(P,null,te(t,(_,g)=>o("div",{key:g},[n(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>[n(Ve,{border_bottom:!0},{title:d(()=>[o("h3",Vue,m(_.title),1),o("div",Tue,[n(f,{animated:""},{template:d(()=>[n(p,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:2},1024),o("div",Mue,[n(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",Lue,[(r(),h(P,null,te(2,_=>o("div",{key:_},[n(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>[n(f,{animated:""},{template:d(()=>[n(p,{variant:"p",class:"w-2/3"})]),_:1}),n(Ve,{border_bottom:!0},{title:d(()=>[o("h2",Rue,m(A(u)("Gross Volume Breakdown")),1)]),_:1}),o("div",Oue,[n(f,{animated:"",rows:7})])]),_:1})]),_:1})])),64))]),o("div",Pue,[(r(),h(P,null,te(a,(_,g)=>o("div",{key:g},[n(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>[n(Ve,{border_bottom:!0},{title:d(()=>[o("h3",Hue,m(_.title),1),o("div",Nue,[n(f,{animated:""},{template:d(()=>[n(p,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:2},1024),o("div",Kue,[n(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",Gue,[(r(),h(P,null,te(l,(_,g)=>o("div",{key:g},[n(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>[n(Ve,{border_bottom:!0},{title:d(()=>[o("h2",zue,m(_.title),1)]),_:2},1024),o("div",jue,[n(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",que,[(r(),h(P,null,te(s,(_,g)=>o("div",{key:g},[n(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>[n(Ve,{border_bottom:!0},{title:d(()=>[o("h3",Yue,m(_.title),1)]),_:2},1024),o("div",Wue,[n(f,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))])])}}},Xue={class:"overview-summary-report-inline"},Zue={class:"inner-value"},ece={__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",Xue,[o("div",Zue,[n(Rs,{amount:A(ft).formatScaled(e.current),title:A(u)(e.title)},null,8,["amount","title"])]),n(vl,{fluctuation:e.fluctuation,amount:e.previous/100,fluctuationSuffix:A(u)("YoY")},null,8,["fluctuation","amount","fluctuationSuffix"])]))}},Co=nt(ece,[["__scopeId","data-v-b394c9f1"]]),tce={class:"report-overview-page"},ace={class:"flex items-center justify-start gap-1 mb-2 text-xs text-system-mid dark:text-system-light"},lce={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},sce={class:"fct-card-header-title is-small"},nce={class:"fct-card-header-title is-small"},oce={class:"grid grid-cols-1"},ice=["innerHTML"],rce=["innerHTML"],dce={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},uce={class:"fct-card-header-title is-small"},cce={class:"fct-card-header-title is-small"},Ace={class:"grid gap-4 grid-cols-1"},pce={class:"grid gap-4 grid-cols-1"},fce={class:"report-overview-col-2 grid gap-7.5 grid-cols-1 xl:grid-cols-2"},mce={__name:"Overview",setup(e){const t=T({}),a=T(!0),l=T({gross_revenue_quarterly:{},net_revenue_quarterly:{}}),s=()=>{Ae.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=dt.sum(p,"*."+f),y=dt.sum(p,"*."+_),v=y===0?100:(g-y)/y*100;return{value:parseFloat(v.toFixed(2)),prev:y,current:g}};return K(()=>{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",tce,[o("div",ace,[n(Y,{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(Jue,{key:0})):(r(),h(P,{key:1},[o("div",lce,[n(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>[n(Ve,{border_bottom:""},{title:d(()=>[o("h3",sce,m(A(u)("Gross Summary")),1),n(Co,{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(wo,{data:t.value.gross_revenue,dataKey:"current","date-range":"","is-empty":!t.value.gross_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1}),n(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>[n(Ve,{border_bottom:""},{title:d(()=>[o("h3",nce,m(A(u)("Gross Revenue Quarterly")),1),n(Co,{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(wo,{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",oce,[n(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>[o("div",{class:"mb-3",innerHTML:A(ft).generateVolumeSummary(t.value.gross_revenue,!0)},null,8,ice),n(Cc,{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(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>[o("div",{class:"mb-3",innerHTML:A(ft).generateVolumeSummary(t.value.gross_revenue_quarterly)},null,8,rce),n(Cc,{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",dce,[n(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>[n(Ve,{border_bottom:!0},{title:d(()=>[o("h3",uce,m(A(u)("Net Revenue")),1),n(Co,{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(wo,{data:t.value.net_revenue,dataKey:"current","date-range":"","is-empty":!t.value.net_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1}),n(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>[n(Ve,{border_bottom:!0},{title:d(()=>[o("h3",cce,m(A(u)("Net Revenue Quarterly")),1),n(Co,{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(wo,{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",Ace,[n(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>[n(kc,{data:t.value.top_country_gross,title:A(u)("Top Country Gross Volume")},null,8,["data","title"])]),_:1})]),_:1})]),o("div",pce,[n(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>[n(kc,{data:t.value.top_country_net,title:A(u)("Top Country Net Volume")},null,8,["data","title"])]),_:1})]),_:1})]),o("div",fce,[n(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>{var _;return[n(Bc,{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(Se,null,{default:d(()=>[n(ke,null,{default:d(()=>{var _;return[n(Bc,{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))]))}},hce={class:"setting-wrap"},_ce={class:"setting-wrap-inner"},vce={key:0,class:"bg-white rounded p-6 dark:bg-dark-700"},gce={class:"grid gap-3 mb-6"},yce={class:"grid gap-3 mb-6"},bce={class:"grid gap-3 mb-6"},wce={class:"grid gap-3"},Cce={class:"payment-method-list fct-content-card-list"},kce=["id"],Bce={class:"flex items-start gap-3"},xce={class:"grid gap-2 flex-1"},Sce={key:0,class:"fct-content-card-list-head stripe"},Fce=["src","alt"],$ce=["src","alt"],Ece={class:"block font-semibold text-system-dark dark:text-gray-50"},Uce={class:"fct-content-card-list-content"},Ice={class:"fct-content-card-list-action flex items-center gap-2"},Qce={key:0},Dce=Object.assign({name:"AddonSettings"},{__name:"AddonSettings",setup(e){const t=ef(),{form:a}=t.data,l=ws(),s=T([]),i=T([]),c=T(!0),p=T(!1),f=T(!0),_=T({}),g=T(!1),y=T({}),v=T(!1),w=T(""),k=T(""),b=T(""),S=K(()=>Object.keys(y.value).length>0),$=()=>{p.value=!0;let V=a.values;Ae.post("settings/modules",{...V}).then(I=>{q.success(u("Settings saved successfully")),setTimeout(()=>{window.location.reload()},300)}).catch(I=>{if(I&&I.message)return q.error(I);_.value=I}).finally(()=>{p.value=!1,f.value=!1,c.value=!1})},D=()=>{c.value=!0,Ae.get("settings/modules",{}).then(V=>{var O,L;a.setSchema(V.fields).setDefaults(V.settings).initForm(),s.value=V.settings,i.value=V.fields,f.value=!1,p.value=!1;const I=((L=(O=V.fields)==null?void 0:O.modules_settings)==null?void 0:L.schema)||[];let M=!1;Array.isArray(I)?M=I.length>0:M=Object.keys(I).length>0,g.value=M}).finally(()=>{c.value=!1})},F=()=>{v.value=!0,Ae.get("settings/modules/plugin-addons",{}).then(V=>{y.value=V.addons||{},b.value&&xe(()=>nn.scrollToHashSection(b.value))}).catch(V=>{q.error(V)}).finally(()=>{v.value=!1})},B=ze.get("app_config.isProActive"),U=(V,I)=>{if(!B){window.open(V.repo_link,"_blank","noopener,noreferrer");return}w.value=I,Ae.post("settings/modules/plugin-addons/install",{plugin_slug:V.plugin_slug,source_type:V.source_type||"wordpress",source_link:V.source_link||"",asset_path:V.asset_path||""}).then(M=>{M.action==="copy"&&M.url?(as.copy(M.url,{successMessage:u("Download link copied to your clipboard")}),window.open(M.url,"_blank","noopener,noreferrer")):M.action==="reload"?(q.success(M.message||u("Addon installed successfully")),setTimeout(()=>{window.location.reload()},500)):q.success(M.message||u("Addon installed successfully"))}).catch(M=>{q.error(M)}).finally(()=>{w.value=""})},Q=(V,I)=>{k.value=I,Ae.post("settings/modules/plugin-addons/activate",{plugin_file:V.plugin_file}).then(M=>{q.success(M.message||u("Addon activated successfully")),setTimeout(()=>{window.location.reload()},500)}).catch(M=>{q.error(M)}).finally(()=>{k.value=""})};return Ie(()=>{const V=window.location.hash||"",I=V.lastIndexOf("#");I>0&&(b.value=V.substring(I+1)),D(),F()}),l.onSave($),(V,I)=>{const M=C("el-skeleton-item"),O=C("el-skeleton"),L=C("el-form"),H=C("el-button"),j=C("el-icon"),W=C("router-link");return r(),h("div",hce,[n(Ua,{heading:A(u)("Addon Settings"),"show-save-button":!1},null,8,["heading"]),o("div",_ce,[n(Ia),f.value?(r(),h("div",vce,[n(O,{loading:f.value,animated:""},{template:d(()=>[o("div",gce,[n(M,{variant:"p",class:"w-[20%]"}),n(M,{variant:"p"})]),o("div",yce,[n(M,{variant:"p",class:"w-[20%]"}),n(M,{variant:"p"})]),o("div",bce,[n(M,{variant:"p",class:"w-[20%]"}),n(M,{variant:"p"})]),o("div",wce,[n(M,{variant:"p",class:"w-[20%]"}),n(M,{variant:"p"})])]),_:1},8,["loading"])])):x("",!0),f.value?x("",!0):(r(),h(P,{key:1},[A(a).isReady?(r(),E(L,{key:0},{default:d(()=>[g.value?(r(),E(Si,{key:0,form:A(a),showSubmitButton:!0,onOnSubmitButtonClick:$,submitButtonText:A(u)("Save Settings"),loading:p.value,onOnChange:I[0]||(I[0]=G=>{}),"validation-errors":_.value},null,8,["form","submitButtonText","loading","validation-errors"])):S.value?x("",!0):(r(),E(Se,{key:1},{default:d(()=>[n(Ve,{title:A(u)("Features & addon"),border_bottom:""},null,8,["title"]),n(ke,null,{default:d(()=>[n(Ct,{class:"fct-addon-empty-state",icon:"Empty/Integrations",text:A(u)("No module settings found.")},null,8,["text"])]),_:1})]),_:1}))]),_:1})):x("",!0),S.value?(r(),E(Se,{key:1,class:"mt-6"},{default:d(()=>[n(Ve,{title:A(u)("Plugin Addons"),border_bottom:""},null,8,["title"]),n(ke,{class:"py-0"},{default:d(()=>[o("div",Cce,[(r(!0),h(P,null,te(y.value,(G,Z)=>(r(),h("div",{key:Z,class:"fct-content-card-list-item",id:G.plugin_slug===b.value?b.value:null},[o("div",Bce,[o("div",xce,[G.logo?(r(),h("div",Sce,[o("img",{class:de({"dark:hidden":G.dark_logo}),src:G.logo,alt:G.title},null,10,Fce),G.dark_logo?(r(),h("img",{key:0,src:G.dark_logo,alt:G.title,class:"hidden dark:block"},null,8,$ce)):x("",!0),o("span",Ece,m(G.title),1),G.is_active?(r(),E(fa,{key:1,status:"active",text:A(u)("Active")},null,8,["text"])):x("",!0)])):x("",!0),o("div",Uce,[o("p",null,m(G.description),1)])]),o("div",Ice,[G.upcoming?(r(),h("div",Qce,m(A(u)("Coming Soon")),1)):(r(),h(P,{key:1},[G.is_installed?G.is_installed&&!G.is_active&&(A(B)||G.source_type!=="github")?(r(),E(H,{key:1,type:"success",size:"small",loading:k.value===Z,disabled:k.value===Z,onClick:ne=>Q(G,Z)},{default:d(()=>[R(m(A(u)("Activate")),1)]),_:2},1032,["loading","disabled","onClick"])):x("",!0):(r(),E(H,{key:0,type:"primary",size:"small",loading:w.value===Z,disabled:w.value===Z,onClick:ne=>U(G,Z)},{default:d(()=>[R(m(A(B)?A(u)("Install & Activate"):A(u)("Download")),1)]),_:2},1032,["loading","disabled","onClick"])),G.is_active&&Z==="fluent-pdf"?(r(),E(W,{key:2,to:{path:"/settings/pdf-template"}},{default:d(()=>[n(j,{class:"text-gray-500 hover:text-primary cursor-pointer",size:18},{default:d(()=>[n(A(Jc))]),_:1})]),_:1})):x("",!0)],64))])])],8,kce))),128))])]),_:1})]),_:1})):x("",!0)],64))])])}}}),Vce=nt(Dce,[["__scopeId","data-v-a315b5d5"]]),Tce={class:"form-note"},Mce={class:"form-note"},Lce={class:"form-note"},Rce={class:"form-note"},Oce={class:"el-form-item__label"},Pce={class:"h-[297px] w-full relative"},Hce={class:"mt-2 mb-2"},Nce={class:"form-note"},Kce={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"},Gce={class:"setting-html-wrapper"},zce={class:"setting-label"},jce={class:"form-note"},qce={class:"setting-fields-inner w-full"},Yce={__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(ke,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",Tce,[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",Mce,[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",Lce,[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",Rce,[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",Oce,m(A(u)("Email Footer")),1),o("div",Pce,[n(s,{animated:"",rows:7})]),o("div",Hce,[o("div",Nce,[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",Kce,[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",Gce,[o("span",zce,m(A(u)("Admin Email Address")),1),o("div",jce,[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",qce,[n(s,{animated:"",class:"h-9"},{template:d(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1})])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})}}},Wce={class:"setting-wrap"},Jce={class:"setting-wrap-inner"},Xce={class:"form-note"},Zce={class:"form-note"},eAe={class:"form-note"},tAe={class:"form-note"},aAe={class:"el-form-item__label"},lAe={class:"mt-2 mb-2"},sAe={class:"form-note"},nAe={class:"fct-powered-by-email-footer-checkbox"},oAe={class:"setting-html-wrapper"},iAe={class:"setting-label"},rAe={class:"form-note"},dAe={class:"setting-fields-inner w-full"},uAe={class:"setting-save-action"},cAe={__name:"MailingSettings",setup(e){const t=T({from_name:"",from_email:"",reply_to_name:"",reply_to_email:"",email_footer:"",show_email_footer:"yes",admin_email:"{{wp.admin_email}}"}),a=ze.get("app_config.isProActive"),l=T(!1),s=T({}),i=T({}),c=()=>{l.value=!0,Ae.get("email-notification/get-settings").then(f=>{var _,g,y,v,w,k,b;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:(w=f.data)==null?void 0:w.email_footer,admin_email:(k=f.data)==null?void 0:k.admin_email,show_email_footer:((b=f.data)==null?void 0:b.show_email_footer)||"yes"},i.value=f.shortcodes}).catch(f=>{}).finally(()=>{l.value=!1})},p=()=>{l.value=!0,s.value={},Ae.post("email-notification/save-settings",t.value).then(f=>{q.success(f.message)}).catch(f=>{f.status_code===422&&f.data?s.value=f.data:f.message?q.error(f.message):(q.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"),w=C("el-row"),k=C("el-tooltip"),b=C("el-checkbox"),S=C("el-button");return r(),h("div",Wce,[n(Ua,{heading:A(u)("Mailing Settings"),loading:l.value,onOnSave:p},null,8,["heading","loading"]),o("div",Jce,[n(Ia),n(Se,null,{default:d(()=>[n(Ve,{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(Yce,{key:0})):(r(),E(ke,{key:1},{default:d(()=>[n(w,{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(_l,{"validation-errors":s.value.from_name||{},"field-key":"from_name"},null,8,["validation-errors"]),o("div",Xce,[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(_l,{"validation-errors":s.value.from_email||{},"field-key":"from_email"},null,8,["validation-errors"]),o("div",Zce,[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(w,{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",eAe,[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(_l,{"validation-errors":s.value.reply_to_email||{},"field-key":"reply_to_email"},null,8,["validation-errors"]),o("div",tAe,[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(w,{gutter:15},{default:d(()=>[n(v,null,{default:d(()=>[o("div",aAe,m(A(u)("Email Footer")),1),n(ls,{"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",lAe,[n(_l,{"validation-errors":s.value.email_footer||{},"field-key":"email_footer"},null,8,["validation-errors"]),o("div",sAe,[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",nAe,[n(b,{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)?x("",!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(Y,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),_:1},8,["modelValue","disabled"])])]),_:1})]),_:1}),n(w,{gutter:15},{default:d(()=>[n(v,null,{default:d(()=>[n(y,null,{default:d(()=>[n(w,{gutter:15,class:"w-full"},{default:d(()=>[n(v,{lg:12},{default:d(()=>[o("div",oAe,[o("span",iAe,m(A(u)("Admin Email Address")),1),o("div",rAe,[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",dAe,[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",uAe,[n(S,{type:"primary",onClick:_[8]||(_[8]=$=>p()),loading:l.value},{default:d(()=>[R(m(A(u)("Save Settings")),1)]),_:1},8,["loading"])])])])}}},AAe={class:"setting-wrap"},pAe={class:"setting-wrap-inner"},fAe={class:"form-note"},mAe={class:"form-note"},hAe={class:"form-note",style:{"padding-top":"6px"}},_Ae={class:"form-note"},vAe={class:"setting-save-action"},xc="{{wp.admin_email}}",gAe={__name:"StoreDigestSettings",setup(e){const t=T({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=T(!1),l=T({}),s=T(""),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.",xc),p=K(()=>{const v=[];for(let w=0;w<24;w++)v.push({value:w,label:String(w).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,Ae.get("email-notification/digest-settings").then(v=>{v.data&&(t.value=v.data)}).catch(()=>{}).finally(()=>{a.value=!1})},g=()=>{a.value=!0,l.value={},Ae.post("email-notification/digest-settings",t.value).then(v=>{q.success(v.message)}).catch(v=>{v.status_code===422&&v.data?l.value=v.data:v.message?q.error(v.message):q.error(u("Something went wrong"))}).finally(()=>{a.value=!1})},y=v=>{s.value=v,Ae.post("email-notification/digest-settings/send-test",{frequency:v}).then(w=>{q.success(w.message)}).catch(w=>{q.error(w.message||u("Could not send the test email."))}).finally(()=>{s.value=""})};return Ie(()=>{_()}),(v,w)=>{const k=C("el-input"),b=C("el-form-item"),S=C("el-col"),$=C("el-checkbox"),D=C("el-row"),F=C("el-switch"),B=C("el-option"),U=C("el-select"),Q=C("el-button");return r(),h("div",AAe,[n(Ua,{heading:A(u)("Store Digest Emails"),loading:a.value,onOnSave:g},null,8,["heading","loading"]),o("div",pAe,[n(Ia),n(Se,null,{default:d(()=>[n(Ve,{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(ke,null,{default:d(()=>[n(D,{gutter:15},{default:d(()=>[n(S,{lg:12},{default:d(()=>[n(b,{label:A(u)("Recipient email addresses"),"label-position":"top"},{default:d(()=>[n(k,{modelValue:t.value.recipients,"onUpdate:modelValue":w[0]||(w[0]=V=>t.value.recipients=V),placeholder:xc},null,8,["modelValue"]),o("div",null,[n(_l,{"validation-errors":l.value.recipients||{},"field-key":"recipients"},null,8,["validation-errors"]),o("div",fAe,[o("p",null,m(A(c)),1)])])]),_:1},8,["label"])]),_:1}),n(S,{lg:12},{default:d(()=>[n(b,{label:A(u)("Empty periods"),"label-position":"top"},{default:d(()=>[n($,{modelValue:t.value.send_when_empty,"onUpdate:modelValue":w[1]||(w[1]=V=>t.value.send_when_empty=V),"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",mAe,[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(P,null,te(i,V=>n(Se,{key:V.key,class:"fct-mt-4"},{default:d(()=>[n(Ve,{title:V.label,text:V.desc,border_bottom:""},null,8,["title","text"]),n(ke,null,{default:d(()=>[n(D,{gutter:15,align:"middle"},{default:d(()=>[n(S,{lg:6},{default:d(()=>[n(b,{label:A(u)("Enable"),"label-position":"top"},{default:d(()=>[n(F,{modelValue:t.value[V.key].enabled,"onUpdate:modelValue":I=>t.value[V.key].enabled=I,"active-value":"yes","inactive-value":"no"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"])]),_:2},1024),n(S,{lg:6},{default:d(()=>[n(b,{label:A(u)("Send time"),"label-position":"top"},{default:d(()=>[n(U,{modelValue:t.value[V.key].send_hour,"onUpdate:modelValue":I=>t.value[V.key].send_hour=I,class:"w-full"},{default:d(()=>[(r(!0),h(P,null,te(p.value,I=>(r(),E(B,{key:I.value,label:I.label,value:I.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"])]),_:2},1024),V.key==="weekly"?(r(),E(S,{key:0,lg:6},{default:d(()=>[n(b,{label:A(u)("Day of week"),"label-position":"top"},{default:d(()=>[n(U,{modelValue:t.value.weekly.send_dow,"onUpdate:modelValue":w[2]||(w[2]=I=>t.value.weekly.send_dow=I),class:"w-full"},{default:d(()=>[(r(),h(P,null,te(f,I=>n(B,{key:I.value,label:I.label,value:I.value},null,8,["label","value"])),64))]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1})):x("",!0),V.key==="monthly"?(r(),E(S,{key:1,lg:6},{default:d(()=>[n(b,{label:A(u)("Send day"),"label-position":"top"},{default:d(()=>[o("div",hAe,[o("p",null,m(A(u)("Sent on the 1st of each month.")),1)])]),_:1},8,["label"])]),_:1})):x("",!0),n(S,{lg:6},{default:d(()=>[n(b,{label:" ","label-position":"top"},{default:d(()=>[n(Q,{loading:s.value===V.key,onClick:I=>y(V.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",_Ae,[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",vAe,[n(Q,{type:"primary",onClick:w[3]||(w[3]=V=>g()),loading:a.value},{default:d(()=>[R(m(A(u)("Save Settings")),1)]),_:1},8,["loading"])])])])}}},yAe={};function bAe(e,t){const a=C("router-view");return r(),h("div",null,[n(a)])}const wAe=nt(yAe,[["render",bAe]]),CAe={},kAe={class:"fct-setting-form-row"},BAe={class:"w-[300px]"},xAe={class:"flex-grow flex-shrink flex-basis-0 self-center"},SAe={class:"fct-setting-form-row"},FAe={class:"w-[300px]"},$Ae={class:"flex-grow flex-shrink flex-basis-0 self-center"},EAe={class:"fct-setting-form-row"},UAe={class:"w-[300px]"},IAe={class:"flex-grow flex-shrink flex-basis-0 self-center"};function QAe(e,t){const a=C("el-skeleton-item"),l=C("el-skeleton");return r(),h("div",null,[o("div",kAe,[o("div",BAe,[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",xAe,[n(l,{animated:""},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])]),o("div",SAe,[o("div",FAe,[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",$Ae,[n(l,{animated:""},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])]),o("div",EAe,[o("div",UAe,[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",IAe,[n(l,{animated:""},{template:d(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])])])}const DAe=nt(CAe,[["render",QAe]]),VAe={name:"TaxConfigurations",components:{TaxConfigurationsLoader:DAe,CardContainer:Se,CardBody:ke,CardHeader:Ve,LabelHint:pa,SettingsHeader:Ua,AdminNotice:Ia,Animation:ya},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,ze.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=bs(),this.keyboardShortcuts.bind(["mod+s"],e=>{e.preventDefault(),this.saveSettings()})},unbindSaveShortcut(){var e;(e=this.keyboardShortcuts)!=null&&e.unbind&&this.keyboardShortcuts.unbind("mod+s")}}},TAe={class:"setting-wrap"},MAe={class:"setting-wrap-inner"},LAe={class:"fct-setting-form-row"},RAe={class:"fct-setting-form-content flex gap-3.5 flex-1"},OAe={class:"fct-inline-tip"},PAe={key:1},HAe={class:"fct-setting-form-row"},NAe={class:"fct-setting-form-content"},KAe={class:"fct-inline-tip"},GAe={class:"fct-setting-form-fields self-center"},zAe={class:"fct-inline-tip mt-2"},jAe={class:"fct-setting-form-row"},qAe={class:"fct-setting-form-content"},YAe={class:"fct-inline-tip"},WAe={class:"fct-setting-form-fields self-center"},JAe={class:"flex flex-col"},XAe={class:"price-mode-label"},ZAe={class:"price-mode-text"},epe={class:"flex flex-col"},tpe={class:"price-mode-label"},ape={class:"price-mode-text"},lpe={class:"fct-setting-form-row"},spe={class:"fct-setting-form-content"},npe={class:"fct-inline-tip"},ope={class:"fct-setting-form-fields self-center"},ipe={class:"fct-setting-form-row"},rpe={class:"fct-setting-form-content"},dpe={class:"fct-inline-tip"},upe={class:"fct-setting-form-fields self-center"},cpe={class:"fct-setting-form-row"},Ape={class:"fct-setting-form-content"},ppe={class:"fct-inline-tip"},fpe={class:"fct-setting-form-fields self-center"},mpe={class:"fct-setting-form-row"},hpe={class:"fct-setting-form-content"},_pe={class:"fct-inline-tip"},vpe={class:"fct-setting-form-fields self-center"},gpe={key:0,class:"fct-setting-form-row"},ype={class:"fct-setting-form-content"},bpe={class:"fct-inline-tip"},wpe={class:"fct-setting-form-fields self-center"},Cpe={class:"fct-setting-form-row"},kpe={class:"fct-setting-form-content"},Bpe={class:"fct-inline-tip"},xpe={class:"fct-setting-form-fields"},Spe={class:"fct-vat-charge-setting-wrap grid gap-5 w-full"},Fpe={class:"fct-local-reverse-charge flex gap-2 justify-items-start"},$pe={class:"fct-inline-tip"},Epe={class:"fct-vat-excluded-categories"},Upe={class:"fct-inline-tip"};function Ipe(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"),w=C("el-option"),k=C("el-select"),b=C("el-input"),S=C("Animation"),$=C("CardBody"),D=C("CardContainer"),F=Va("loading");return r(),h("div",TAe,[n(c,{heading:i.translate("Tax Configuration"),loading:s.saving,"show-cmnd-icon":!0,onOnSave:i.saveSettings},null,8,["heading","loading","onOnSave"]),o("div",MAe,[n(p),n(D,null,{default:d(()=>[n($,null,{default:d(()=>[o("div",LAe,[o("div",RAe,[n(f,{modelValue:s.settings.enable_tax,"onUpdate:modelValue":t[0]||(t[0]=B=>s.settings.enable_tax=B),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"]),o("div",null,[n(_,{title:i.translate("Enable Tax")},null,8,["title"]),o("p",OAe,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})):x("",!0),s.loading?x("",!0):(r(),h("div",PAe,[o("div",HAe,[o("div",NAe,[n(_,{title:i.translate("Prices entered with tax")},null,8,["title"]),o("p",KAe,m(i.translate("Choose whether product prices are entered including or excluding tax.")),1)]),o("div",GAe,[n(v,{modelValue:s.settings.tax_inclusion,"onUpdate:modelValue":t[1]||(t[1]=B=>s.settings.tax_inclusion=B)},{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",zAe,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",jAe,[o("div",qAe,[n(_,{title:i.translate("Tax-Inclusive Price Mode")},null,8,["title"]),o("p",YAe,m(i.translate("Controls how reverse charge affects tax-inclusive product prices.")),1)]),o("div",WAe,[n(v,{modelValue:s.settings.eu_vat_settings.reverse_charge_price_mode,"onUpdate:modelValue":t[2]||(t[2]=B=>s.settings.eu_vat_settings.reverse_charge_price_mode=B),class:"fct-reverse-charge-price-mode"},{default:d(()=>[n(y,{value:"fixed"},{default:d(()=>[o("div",JAe,[o("span",XAe,m(i.translate("Fixed")),1),o("span",ZAe,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",epe,[o("span",tpe,m(i.translate("Dynamic")),1),o("span",ape,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",lpe,[o("div",spe,[n(_,{title:i.translate("Calculate Tax Based On")},null,8,["title"]),o("p",npe,m(i.translate("Determine the location used for tax calculations.")),1)]),o("div",ope,[n(k,{modelValue:s.settings.tax_calculation_basis,"onUpdate:modelValue":t[3]||(t[3]=B=>s.settings.tax_calculation_basis=B),clearable:""},{default:d(()=>[n(w,{value:"shipping",label:i.translate("Customer Shipping Address")},null,8,["label"]),n(w,{value:"billing",label:i.translate("Customer Billing Address")},null,8,["label"]),n(w,{value:"store",label:i.translate("Store Location")},null,8,["label"])]),_:1},8,["modelValue"])])]),o("div",ipe,[o("div",rpe,[n(_,{title:i.translate("Price Suffix (Tax Included)")},null,8,["title"]),o("p",dpe,m(i.translate("Shown on prices where tax is included. Applies when product or store pricing is tax-inclusive.")),1)]),o("div",upe,[n(b,{modelValue:s.settings.price_suffix_included,"onUpdate:modelValue":t[4]||(t[4]=B=>s.settings.price_suffix_included=B),placeholder:i.translate("e.g. (incl. tax)")},null,8,["modelValue","placeholder"])])]),o("div",cpe,[o("div",Ape,[n(_,{title:i.translate("Price Suffix (Tax Excluded)")},null,8,["title"]),o("p",ppe,m(i.translate("Shown on prices where tax is excluded. Applies when product or store pricing is tax-exclusive.")),1)]),o("div",fpe,[n(b,{modelValue:s.settings.price_suffix_excluded,"onUpdate:modelValue":t[5]||(t[5]=B=>s.settings.price_suffix_excluded=B),placeholder:i.translate("e.g. (+ tax)")},null,8,["modelValue","placeholder"])])]),o("div",mpe,[o("div",hpe,[n(_,{title:i.translate("Tax Display Style")},null,8,["title"]),o("p",_pe,m(i.translate("Choose how tax context appears on each checkout line item.")),1)]),o("div",vpe,[n(k,{modelValue:s.settings.checkout_tax_breakdown_display,"onUpdate:modelValue":t[6]||(t[6]=B=>s.settings.checkout_tax_breakdown_display=B)},{default:d(()=>[n(w,{value:"simplified",label:i.translate("Simplified (single line + details)")},null,8,["label"]),n(w,{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",gpe,[o("div",ype,[n(_,{title:i.translate("Tax Line Label")},null,8,["title"]),o("p",bpe,m(i.translate("The single-line tax label shown in Simplified mode, e.g. VAT, MwSt, GST.")),1)]),o("div",wpe,[n(b,{modelValue:s.settings.tax_display_label,"onUpdate:modelValue":t[7]||(t[7]=B=>s.settings.tax_display_label=B),placeholder:i.translate("e.g. Tax")},null,8,["modelValue","placeholder"])])])):x("",!0),o("div",Cpe,[o("div",kpe,[n(_,{title:i.translate("VAT Reverse Charge Settings")},null,8,["title"]),o("p",Bpe,m(i.translate("Configure reverse VAT handling for customers in the European Union.")),1)]),o("div",xpe,[o("div",Spe,[o("div",Fpe,[n(f,{modelValue:s.settings.eu_vat_settings.local_reverse_charge,"onUpdate:modelValue":t[8]||(t[8]=B=>s.settings.eu_vat_settings.local_reverse_charge=B),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"]),o("div",null,[n(_,{title:i.translate("Local Reverse Charge")},null,8,["title"]),o("p",$pe,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",Epe,[n(_,{title:i.translate("Exclude Categories from VAT reverse")},null,8,["title"]),o("p",Upe,m(i.translate("Select product categories that should NOT get VAT reverse charge !")),1),Wt((r(),E(k,{modelValue:s.settings.eu_vat_settings.vat_reverse_excluded_categories,"onUpdate:modelValue":t[9]||(t[9]=B=>s.settings.eu_vat_settings.vat_reverse_excluded_categories=B),filterable:"",multiple:"",clearable:"",placeholder:i.translate("Select Product Categories"),class:"w-full mt-4"},{default:d(()=>[(r(!0),h(P,null,te(s.categories,B=>(r(),E(w,{key:B.value||B.term_id,label:B.label||B.name,value:B.value||B.term_id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])),[[F,s.fetchingCategories]])])]),_:1},8,["visible"])])])])]))]),_:1},8,["visible"])]),_:1})]),_:1})])])}const Qpe=nt(VAe,[["render",Ipe]]),Dpe={class:"fct-tax-rates-wrap-loader px-5"},Vpe={__name:"TaxRatesLoader",setup(e){const t=T(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",Dpe,[(r(!0),h(P,null,te(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:ra({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))])}}},Tpe={class:"setting-wrap"},Mpe={class:"setting-wrap-inner"},Lpe={class:"fct-all-tax-classes-page"},Rpe={class:"flex items-center justify-end gap-4"},Ope={key:0,class:"px-6 py-4 border-b border-gray-200 dark:border-gray-700"},Ppe={class:"inline-flex items-center gap-2"},Hpe={class:"inline-flex items-center gap-2"},Npe=["src","alt"],Kpe={key:0,class:"text-gray-400 dark:text-gray-300"},Gpe={key:1,class:"text-success-500"},zpe={key:2,class:"text-system-mid dark:text-gray-300"},jpe={key:3,class:"text-gray-400 dark:text-gray-300"},qpe={key:1,class:"text-gray-400"},Ype={__name:"TaxRates",setup(e){const t=T({}),a=T([]),l=T({}),s=T({}),i=K(()=>!!ze.get("is_tax_enabled")),c=T(!1),p=T({}),f={};let _=0;const g=T(""),y=T(!1),v={XI:"gb"},w=I=>(v[I]||I).toLowerCase(),k=K(()=>{const I=new Set;for(const M of a.value)for(const O of M.countries||[])I.add(O.country_code);return I}),b=I=>!I||!Object.prototype.hasOwnProperty.call(s.value,I)?!0:s.value[I],S=I=>!I||!I.vat?!1:I.rates&&typeof I.rates=="object"&&Object.keys(I.rates).length?Object.values(I.rates).some(M=>M&&parseFloat(M.rate)>0):parseFloat(I.rate)>0,$=K(()=>{const I=l.value||{},M=Array.isArray(I.country_registrations)?I.country_registrations:[],O=I.method||"",L=M.some(S);if(O==="oss")return!!I.oss_country;if(O==="home"){const H=I.home_country||"",j=M.find(W=>W.country===H);if(H&&j&&S(j))return!0}return O==="specific"?!!I.home_country:L}),D=K(()=>{const I=l.value||{},M=Array.isArray(I.country_registrations)?I.country_registrations:[],O=I.method||"";return O==="oss"?!!I.oss_country:O==="home"?!!I.home_country&&M.some(L=>L.country===I.home_country):O==="specific"?!!I.home_country:M.some(S)}),F=K(()=>{const I=[],M=Object.values(t.value||{});for(const H of M)if(H.group_code==="EU")I.push({country_code:"EU",country_name:"European Union",isEU:!0,group_code:"EU",hasConfig:D.value,enabled:b("EU"),collecting:D.value&&$.value&&b("EU")});else for(const j of H.countries||[]){const W=k.value.has(j.country_code),G=b(j.country_code);I.push({country_code:j.country_code,country_name:j.country_name,isEU:!1,group_code:H.group_code,hasConfig:W,enabled:G,collecting:W&&G})}const O=["EU","US","GB","AU","CA","NZ","IN","SG","JP"],L=new Set(O);return I.sort((H,j)=>{if(H.hasConfig!==j.hasConfig)return H.hasConfig?-1:1;const W=L.has(H.country_code),G=L.has(j.country_code);return W&&G?O.indexOf(H.country_code)-O.indexOf(j.country_code):W?-1:G?1:H.country_name.localeCompare(j.country_name)}),I}),B=K(()=>{const I=g.value.trim().toLowerCase();return F.value.filter(M=>y.value&&(!i.value||!M.collecting)?!1:I?M.country_name.toLowerCase().includes(I)||M.country_code.toLowerCase().includes(I):!0)}),U=K(()=>{if(!i.value)return!1;const I=F.value.filter(O=>O.enabled).length,M=F.value.filter(O=>!O.enabled).length;return I>0&&M>0}),Q=()=>{c.value=!0,Promise.all([Ae.get("tax/configuration/rates"),Ae.get("tax/rates"),Ae.get("tax/configuration/settings")]).then(([I,M,O])=>{var L;t.value=I.tax_rates,a.value=M.tax_rates,s.value=M.country_enabled_map||{},l.value=((L=O.settings)==null?void 0:L.eu_vat_settings)||{}}).catch(I=>{}).finally(()=>{c.value=!1})},V=(I,M)=>{const O=b(I.country_code),L=++_;f[I.country_code]=L,s.value={...s.value,[I.country_code]:M},p.value={...p.value,[I.country_code]:!0},Ae.post("tax/country-status/"+I.country_code,{enabled:M?1:0}).then(H=>{f[I.country_code]===L&&(q.success(H.message),s.value={...s.value,[I.country_code]:H.enabled})}).catch(H=>{var j;f[I.country_code]===L&&(s.value={...s.value,[I.country_code]:O},q.error(((j=H==null?void 0:H.data)==null?void 0:j.message)||u("Failed to update tax status")))}).finally(()=>{if(f[I.country_code]===L){const H={...p.value};delete H[I.country_code],p.value=H}})};return Ie(()=>{Q()}),(I,M)=>{const O=C("el-checkbox"),L=C("el-input"),H=C("el-table-column"),j=C("el-switch"),W=C("el-table");return r(),h("div",Tpe,[n(Ua,{heading:A(u)("Tax Regions"),"show-save-button":!1},null,8,["heading"]),o("div",Mpe,[n(Ia),o("div",Lpe,[n(Se,{class:"overflow-hidden"},{default:d(()=>[n(Ve,{title:A(u)("Tax Regions"),text:A(u)("Manage tax rates for different regions")},{action:d(()=>[o("div",Rpe,[U.value?(r(),E(O,{key:0,modelValue:y.value,"onUpdate:modelValue":M[0]||(M[0]=G=>y.value=G)},{default:d(()=>[R(m(A(u)("Collecting Tax")),1)]),_:1},8,["modelValue"])):x("",!0),n(L,{modelValue:g.value,"onUpdate:modelValue":M[1]||(M[1]=G=>g.value=G),class:"w-[200px]",placeholder:A(u)("Search regions..."),size:"small",clearable:""},{prefix:d(()=>[n(Y,{name:"Search",class:"w-4 h-4"})]),_:1},8,["modelValue","placeholder"])])]),_:1},8,["title","text"]),n(ke,{class:"px-0 pb-0"},{default:d(()=>[!c.value&&!i.value?(r(),h("div",Ope,[n(el,{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"])])):x("",!0),c.value?(r(),E(Vpe,{key:1})):(r(),E(W,{key:2,data:B.value,"max-height":"500",class:"w-full compact-table fct-tax-rates-regions-table"},{default:d(()=>[n(H,{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",Ppe,[M[2]||(M[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",Hpe,[o("img",{class:"w-[22px] block",src:`https://flagcdn.com/w40/${w(G.country_code)}.png`,alt:G.country_code},null,8,Npe),R(" "+m(G.country_name),1)])]),_:2},1032,["to"]))]),_:1},8,["label"]),n(H,{label:A(u)("Collecting"),width:"200"},{default:d(({row:G})=>[i.value?G.collecting?(r(),h("span",Gpe,m(A(u)("Collecting tax")),1)):G.hasConfig&&!G.enabled?(r(),h("span",zpe,m(A(u)("Disabled")),1)):(r(),h("span",jpe,"—")):(r(),h("span",Kpe,"—"))]),_:1},8,["label"]),n(H,{label:A(u)("Enabled"),width:"140",align:"center"},{default:d(({row:G})=>[G.hasConfig?(r(),E(j,{key:0,"model-value":i.value?G.enabled:!1,loading:!!p.value[G.country_code],disabled:!i.value,onChange:Z=>V(G,Z)},null,8,["model-value","loading","disabled","onChange"])):(r(),h("span",qpe,"—"))]),_:1},8,["label"])]),_:1},8,["data"]))]),_:1})]),_:1})])])])}}},Wpe={class:"fct-base-taxes"},Jpe={class:"fct-tax-class-tabs"},Xpe={class:"fct-tax-class-tabs__list"},Zpe={class:"fct-base-taxes__header"},efe={class:"fct-base-taxes__header-label"},tfe={class:"fct-base-taxes__state-row fct-base-taxes__state-row--federal"},afe={class:"fct-base-taxes__region-name fct-base-taxes__region-name--federal"},lfe={class:"fct-base-taxes__state-fields"},sfe={class:"fct-base-taxes__region-name"},nfe={class:"fct-base-taxes__state-fields"},ofe={__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",Wpe,[o("div",Jpe,[o("div",Xpe,[(r(),h(P,null,te(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",Zpe,[o("span",efe,m(A(u)("Regions")),1)]),o("div",tfe,[o("div",afe,[n(i,{animated:""},{template:d(()=>[n(s,{variant:"text",class:"w-40 h-5"})]),_:1})]),o("div",lfe,[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(P,null,te(t,c=>o("div",{key:c,class:"fct-base-taxes__state-row"},[o("div",sfe,[n(i,{animated:""},{template:d(()=>[n(s,{variant:"text",class:"w-32 h-4"})]),_:1})]),o("div",nfe,[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))])])}}},ife={class:"fct-tax-class-tabs"},rfe={class:"fct-tax-class-tabs__list"},dfe=["onClick"],ufe=["title","onClick"],cfe=["disabled","title"],Afe=["disabled","title"],pfe=["disabled"],ffe=["disabled","title"],mfe={class:"fct-tax-class-tabs__search"},wf={__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=T(!1),i=T(""),c=T(null),p=T(!1),f=K(()=>[...a.classes].sort((b,S)=>b.slug==="standard"&&S.slug!=="standard"?-1:b.slug!=="standard"&&S.slug==="standard"?1:0)),_=K(()=>["reduced","zero"].filter(b=>!a.classes.find(S=>S.slug===b))),g=()=>{i.value="",p.value=!1,s.value=!0,xe(()=>{var b;return(b=c.value)==null?void 0:b.focus()})},y=b=>{if(b==="custom"){g();return}l("add",b)},v=()=>{const b=i.value.trim();if(!b){w();return}l("create-custom",b)},w=()=>{s.value=!1,i.value="",p.value=!1},k=()=>{!a.creating&&!i.value.trim()&&w()};return be([()=>a.classes.length,()=>a.creating],([b,S],[$,D])=>{if(s.value){if(b>$){w();return}D&&!S&&(p.value=!0)}}),be(i,()=>{p.value=!1}),(b,S)=>{const $=C("el-input"),D=C("el-dropdown-item"),F=C("el-dropdown-menu"),B=C("el-dropdown");return r(),h("div",ife,[o("div",rfe,[(r(!0),h(P,null,te(f.value,U=>(r(),h("button",{key:U.id,class:de(["fct-tax-class-tabs__tab",{"fct-tax-class-tabs__tab--active":e.activeId==U.id}]),onClick:Q=>l("switch",U)},[R(m(U.title)+" ",1),U.slug!=="standard"?(r(),h("span",{key:0,class:"fct-tax-class-tabs__delete",title:A(u)("Delete tax class"),onClick:Ge(Q=>l("delete",U),["stop"])},[n(Y,{name:"Close"})],8,ufe)):x("",!0)],10,dfe))),128)),e.classes.length
i.value=U),size:"small",maxlength:"30",disabled:e.creating,placeholder:A(u)("e.g. Luxury"),onKeyup:[xa(v,["enter"]),xa(w,["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]=Ge(()=>{},["prevent"])),onClick:v},[n(Y,{name:"Check"})],40,cfe),o("button",{class:"fct-tax-class-tabs__inline-cancel",disabled:e.creating,title:A(u)("Cancel"),onMousedown:S[2]||(S[2]=Ge(()=>{},["prevent"])),onClick:w},[n(Y,{name:"Close"})],40,Afe)],2)):_.value.length?(r(),E(B,{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(D,{key:0,command:"reduced"},{default:d(()=>[R(m(A(u)("Reduced")),1)]),_:1})):x("",!0),_.value.includes("zero")?(r(),E(D,{key:1,command:"zero"},{default:d(()=>[R(m(A(u)("Zero")),1)]),_:1})):x("",!0),n(D,{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(Y,{name:"Plus"})],8,pfe)]),_: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(Y,{name:"Plus"})],8,ffe))],64)):x("",!0)]),o("div",mfe,[n($,{"model-value":e.search,placeholder:A(u)("Search country or region…"),size:"small",clearable:"","onUpdate:modelValue":S[3]||(S[3]=U=>l("update:search",U)),onClear:S[4]||(S[4]=U=>l("update:search",""))},{prefix:d(()=>[n(Y,{name:"Search",class:"w-3.5 h-3.5 text-system-light dark:text-gray-400"})]),_:1},8,["model-value","placeholder"]),ga(b.$slots,"search-actions")])])}}},hfe=(e=[])=>e.find(t=>t.slug==="standard")||e[0]||null,Td=({classes:e=[],activeId:t=null})=>(t?e.find(l=>l.id===t):null)||hfe(e),_fe=({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},Jo=async({payload:e,createdSlug:t=null,currentClasses:a=[],reloadClasses:l})=>{const s=new Set((a||[]).map(p=>p.id)),i=await Ae.post("tax/classes",e),c=await l();return{response:i,classes:c,createdClass:_fe({classes:c,previousIds:s,createdSlug:t})}},Cf=async({classId:e,currentActiveId:t=null,reloadClasses:a})=>{const l=await Ae.delete("tax/classes/"+e),s=await a();return{response:l,classes:s,nextActiveClass:Td({classes:s,activeId:t})}};function an(e){return e==null||e===""?"":String(e)}const vfe={class:"setting-wrap"},gfe={class:"setting-wrap-inner"},yfe={class:"fct-single-tax-rates-country-single-page"},bfe={class:"fct-single-tax-rates-country-single"},wfe={class:"single-page-header flex items-center justify-between"},Cfe={key:0,class:"flex items-center gap-2"},kfe={key:0,class:"notices fct-notices-wrap fct-layout-width settings"},Bfe={class:"mt-3 flex justify-end"},xfe={key:1,class:"fct-base-taxes"},Sfe={class:"fct-btn-group mt-4 justify-end sm"},Ffe={class:"fct-tax-rates-country-view"},$fe={key:0},Efe={key:1},Ufe={key:0},Ife={key:1},Qfe={class:"fct-btn-group sm justify-end"},Sc={__name:"TaxRatesCountrySingle",props:{country:{type:String},group:{type:String}},setup(e){const t=e,a=T(!1),l=T([]),s=T(""),i=K(()=>!!ze.get("is_tax_enabled")),c=T([]),p=T(null),f=T("standard"),_=T(!1),g=T(null),y=T(6),v=T({id:null,rate:0,name:"Tax",state:"",is_compound:"0",for_order:0}),w=T({rate:0,name:""}),k=T([]),b=T({}),S=T(""),$=K(()=>{const X=S.value.trim().toLowerCase();return X?k.value.filter(we=>we.stateName&&we.stateName.toLowerCase().includes(X)):k.value}),D=K(()=>t.group==="EU"),F=K(()=>[v.value,...$.value]),B=T([]),U=T(!1),Q=T([]),V=T([]),I=T(!1),M=T(new Set),O=T(0),L=T([]),H=T(!1),j=T(!1),W=T(!1),G=T({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:""}),Z=K(()=>{const X=v.value.rate||0;return[{label:u("added to")+` ${X}% `+u("federal tax"),is_compound:"0",for_order:0},{label:u("instead of")+` ${X}% `+u("federal tax"),is_compound:"0",for_order:1},{label:u("compounded on top of")+` ${X}% `+u("federal tax"),is_compound:"1",for_order:0}]}),ne=X=>String(X.is_compound)==="1"?"1_0":X.for_order==1?"0_1":"0_0",ce=(X,we)=>{const[le,he]=we.split("_");X.is_compound=le,X.for_order=parseInt(he)},z=X=>X&&X.replace(/\s*\(Standard\)\s*/gi,"").trim(),ue=T(!1),ie=T({}),J=T(!1),N=T(""),ae=T(""),oe=T(""),fe=T(!1),re=T(!1),Ee=T(!0),ye=T(!1),Ce=T(!1),ve=T(!1),Ue=K(()=>u("Toggle tax collection for %1$s",s.value||t.country)),Ke=()=>Ae.get("tax/classes").then(X=>{c.value=X.classes||[],y.value=X.max_classes||6,g.value=X.next_builtin||null;const we=Td({classes:c.value,activeId:p.value});return we&&(p.value=we.id,f.value=we.slug),c.value}).catch(X=>c.value),We=(X="")=>{if(!X)return v.value.name||"Tax";const we=k.value.find(le=>le.state===X);return we!=null&&we.name?we.name:v.value.name||"Tax"},Be=X=>{v.value={...X.federalRate},w.value={...X.federalOriginal},k.value=X.stateRows.map(we=>({...we})),b.value={...X.stateOriginals}},$e=()=>({federalRate:{...v.value},federalOriginal:{...w.value},stateRows:k.value.map(X=>({...X})),stateOriginals:{...b.value}}),He=()=>{p.value&&(ie.value[p.value]=$e())},Re=async X=>{He(),p.value=X.id,f.value=X.slug,ie.value[X.id]?(Be(ie.value[X.id]),await ht()):await qt()},yt=X=>{_.value=!0,Jo({payload:{slug:X},createdSlug:X,currentClasses:c.value,reloadClasses:Ke}).then(({response:we,createdClass:le})=>{if(q.success(we.message),le)return Re(le)}).catch(we=>{var le;q.error(((le=we==null?void 0:we.data)==null?void 0:le.message)||"Failed to create tax class")}).finally(()=>{_.value=!1})},gt=X=>{_.value=!0,Jo({payload:{title:X},currentClasses:c.value,reloadClasses:Ke}).then(({response:we,createdClass:le})=>{if(q.success(we.message),le)return Re(le)}).catch(we=>{var le;q.error(((le=we==null?void 0:we.data)==null?void 0:le.message)||"Failed to create tax class")}).finally(()=>{_.value=!1})},Rt=X=>{const we=p.value===X.id;ul(u("All rates for this class will be deleted. Products using it will default to Standard."),u("Delete")+" "+X.title+"?",{confirmButtonText:u("Yes, Delete"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{Cf({classId:X.id,currentActiveId:p.value,reloadClasses:Ke}).then(({response:le,nextActiveClass:he})=>{if(delete ie.value[X.id],q.success(le.message),he)return we&&(p.value=null),Re(he)}).catch(le=>{var he;q.error(((he=le==null?void 0:le.data)==null?void 0:he.message)||"Failed to delete tax class")})}).catch(()=>{})},Tt=()=>Ae.get("address-info/get-country-info",{country_code:t.country}).then(X=>{l.value=X.states||[],s.value=X.country_name||t.country}).catch(X=>{q.error(u("Failed to load country data. Please refresh the page."))}),Dt=()=>D.value?(ae.value="",oe.value="",Promise.resolve()):(fe.value=!0,Ae.get("tax/country-tax-id/"+t.country).then(X=>{var le;const we=((le=X==null?void 0:X.tax_data)==null?void 0:le.tax_id)||"";ae.value=we,oe.value=we}).catch(X=>{var we;q.error(((we=X==null?void 0:X.data)==null?void 0:we.message)||u("Failed to load tax ID"))}).finally(()=>{fe.value=!1})),_t=({hydrateClassData:X=!0}={})=>Ae.get("tax/rates/country/rates/"+t.country).then(we=>{const le=we.tax_rates||[],he=le.filter(je=>je.for_shipping!==null),Ye=p.value?le.filter(je=>Number(je.class_id)===Number(p.value)):le;Q.value=Ye.filter(je=>!je.city&&!je.postcode).map(je=>({name:je.name,value:je.id,state:je.state||""}));const st=Qt(Ye);return ve.value=le.length>0,X&&(Be(st),He(),Ee.value=!!we.tax_enabled,Ce.value=!0),{allRates:le,shippingOverrides:he,classEntry:st}}).catch(we=>(q.error(u("Failed to load tax rates. Please refresh the page.")),{allRates:[],shippingOverrides:[],classEntry:null})),Gt=()=>Ae.get("tax/product-overrides/"+t.country).then(X=>X.overrides||[]).catch(()=>[]),bt=()=>{L.value.length>0||(H.value=!0,Ae.get("products/fetch-term").then(X=>{const we=X.taxonomies&&X.taxonomies["product-categories"]?X.taxonomies["product-categories"].terms||[]:[];L.value=we.map(le=>({...le,value:an(le.value)}))}).catch(()=>{}).finally(()=>{H.value=!1}))};let St=0;const Pt=X=>{const we=++St;return!X||Number(X)===Number(p.value)?(V.value=Q.value.slice(),I.value=!1,Promise.resolve()):(I.value=!0,V.value=[],Ae.get("tax/rates/country/rates/"+t.country,{class_id:X}).then(le=>{if(we!==St)return;const he=le.tax_rates||[];V.value=he.filter(Ye=>!Ye.city&&!Ye.postcode).map(Ye=>({name:Ye.name,value:Ye.id,state:Ye.state||""}))}).catch(()=>{we===St&&(V.value=[],q.error(u("Failed to load tax rates for the selected tax class")))}).finally(()=>{we===St&&(I.value=!1)}))},Ht=(X,we)=>{var he,Ye;const le=[];for(const st of X){const je=st.state?((he=l.value.find(et=>et.value===st.state))==null?void 0:he.name)||st.state:s.value||t.country,Xe=We(st.state||""),mt=c.value.find(et=>Number(et.id)===Number(st.class_id));le.push({id:st.id,type:"shipping",label:Xe,tax_label:Xe,category_name:"",location:je,city:st.city||"",postcode:st.postcode||"",rate:st.for_shipping,class_id:Number(st.class_id)||0,class_label:mt?mt.title:"",_raw:st})}for(const st of we){const je=st.meta_value||st,Xe=je.state||"",mt=Xe?((Ye=l.value.find(pe=>pe.value===Xe))==null?void 0:Ye.name)||Xe:s.value||t.country,et=Number(st.class_id)||0,It=et?c.value.find(pe=>Number(pe.id)===et):null;le.push({id:st.id,type:"products",label:je.category_name||"",tax_label:je.tax_label||"",category_name:je.category_name||"",location:mt,city:je.city||"",postcode:je.postcode||"",rate:je.rate,class_id:et,class_label:It?It.title:"",_raw:st})}B.value=le},Qt=X=>{const we=et=>(!et.state||et.state==="")&&(!et.city||et.city==="")&&(!et.postcode||et.postcode===""),le=X.find(we),he=X.filter(et=>et.state&&et.state!==""&&(!et.city||et.city==="")&&(!et.postcode||et.postcode===""));let Ye,st;if(le){const et=z(le.name)||"Tax";Ye={...le,name:et},st={rate:le.rate,name:et}}else Ye={id:null,rate:0,name:"Tax",state:"",is_compound:"0",for_order:0},st={rate:0,name:"Tax"};const je={};for(const et of he)je[et.state]=et;const Xe=[],mt={};for(const et of l.value){const It=je[et.value];if(It){const pe=z(It.name)||"State Tax";Xe.push({id:It.id,state:et.value,stateName:et.name,rate:It.rate,name:pe,is_compound:String(It.is_compound||"0"),for_order:It.for_order||0}),mt[et.value]={rate:It.rate,name:pe,is_compound:String(It.is_compound||"0"),for_order:It.for_order||0}}else Xe.push({id:null,state:et.value,stateName:et.name,rate:0,name:"State Tax",is_compound:"0",for_order:0}),mt[et.value]={rate:0,name:"State Tax",is_compound:"0",for_order:0}}return{federalRate:Ye,federalOriginal:st,stateRows:Xe,stateOriginals:mt}},ht=async()=>{const[{shippingOverrides:X},we]=await Promise.all([_t({hydrateClassData:!1}),Gt()]);Ht(X,we)},qt=async()=>{a.value=!0;try{const[{shippingOverrides:X},we]=await Promise.all([_t(),Gt()]);Ht(X,we)}finally{a.value=!1}},ge=async()=>{a.value=!0;try{await Promise.all([Ke(),Tt(),Dt()]),await qt()}finally{a.value=!1}},Fe=()=>{D.value||re.value||fe.value||(re.value=!0,Ae.post("tax/country-tax-id/"+t.country,{tax_id:ae.value||""}).then(X=>{oe.value=ae.value||"",q.success(X.message||u("Tax ID has been saved successfully"))}).catch(X=>{var we;q.error(((we=X==null?void 0:X.data)==null?void 0:we.message)||u("Failed to save tax ID"))}).finally(()=>{re.value=!1}))},ot=X=>{if(ye.value)return;const we=Ee.value;Ee.value=X,ye.value=!0,Ae.post("tax/country-status/"+t.country,{enabled:X?1:0}).then(le=>{Ee.value=le.enabled,q.success(le.message)}).catch(le=>{var he;Ee.value=we,q.error(((he=le==null?void 0:le.data)==null?void 0:he.message)||u("Failed to update tax status"))}).finally(()=>{ye.value=!1})},wt=async()=>{try{await ul(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 Ae.get("tax/configuration/rates")).tax_rates||{};let le=[];for(const Xe in we){const mt=we[Xe];for(const et of mt.countries||[])if(et.country_code===t.country){le=et.rates||[];break}if(le.length)break}if(!le.length){q.error(u("No preset rates found for this country"));return}const he=le.find(Xe=>(!Xe.state||Xe.state==="")&&Xe.type==="standard"),Ye=le.filter(Xe=>Xe.state&&Xe.state!==""&&Xe.type==="standard"),st=[];he&&he.rate>0&&(v.value.rate=he.rate,v.value.name=z(he.name||"")||u("Tax"),st.push(kt()));const je=[];for(const Xe of Ye){const mt=k.value.find(et=>et.state===Xe.state);mt&&(mt.rate=Xe.rate,mt.name=z(Xe.name)||u("State Tax"),mt.is_compound=Xe.compound?"1":"0",je.push(Xt(mt)))}await Promise.all([...st,...je]),He(),await ht(),q.success(u("Tax rates have been reset to defaults"))}catch{q.error(u("Failed to reset tax rates"))}finally{J.value=!1}},kt=()=>{const X={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?Ae.put("tax/country/rate/"+v.value.id,X):Ae.post("tax/country/rate",X)).then(le=>{le.tax_rate&&(v.value.id=le.tax_rate.id),w.value={rate:v.value.rate,name:v.value.name}})},Xt=X=>{const we={country:t.country,state:X.state,rate:X.rate,name:X.name,is_compound:X.is_compound,for_order:X.for_order,group:t.group,class_id:p.value||""};return(X.id?Ae.put("tax/country/rate/"+X.id,we):Ae.post("tax/country/rate",we)).then(he=>{he.tax_rate&&(X.id=he.tax_rate.id),b.value[X.state]={rate:X.rate,name:X.name,is_compound:String(X.is_compound),for_order:X.for_order}})},vt=async()=>{ue.value=!0;try{const X=[];(String(v.value.rate)!==String(w.value.rate)||v.value.name!==w.value.name)&&X.push(kt());for(const le of k.value){const he=b.value[le.state];(!he||String(le.rate)!==String(he.rate)||le.name!==he.name||String(le.is_compound)!==String(he.is_compound)||le.for_order!=he.for_order)&&X.push(Xt(le))}await Promise.all(X),He(),await ht(),q.success(u("Tax rates saved"))}catch{q.error(u("Failed to save rates"))}finally{ue.value=!1}},ea=()=>{M.value=new Set,O.value=0},ta=()=>{const X=We();W.value=!1,G.value={type:"products",original_type:"",original_id:"",category_id:"",category_name:"",state:"__country__",city:"",postcode:"",tax_label:X,tax_rate:0,override_state_tax:!0,class_id:Number(p.value)||0,id:"",previous_id:""},N.value=X,V.value=Q.value.slice(),U.value=!0,bt()},zt=X=>{if(W.value=!0,bt(),X.type==="shipping"){const we=X._raw.state||"",le=We(we),he=Number(X._raw.class_id)||Number(p.value)||0;G.value={type:"shipping",original_type:"shipping",original_id:X.id,category_id:"",category_name:"",state:we||"__country__",city:X._raw.city||"",postcode:X._raw.postcode||"",tax_label:le,tax_rate:X.rate,override_state_tax:!0,class_id:he,id:X.id,previous_id:X.id},N.value=le,O.value=he,Pt(he);const Ye=X._raw.city||"",st=X._raw.postcode||"",je=new Set;for(const Xe of B.value)Xe.type==="shipping"&&(Xe._raw.state||"")===we&&(Xe._raw.city||"")===Ye&&(Xe._raw.postcode||"")===st&&je.add(Number(Xe.class_id));M.value=je}else{const we=X._raw.meta_value||X._raw,le=we.state||"",he=We(le),Ye=X.tax_label||he;G.value={type:"products",original_type:"products",original_id:X.id,category_id:an(we.category_id),category_name:X.category_name,state:le||"__country__",tax_label:Ye,tax_rate:X.rate,override_state_tax:we.override_state_tax==="yes",city:we.city||"",postcode:we.postcode||"",class_id:X.class_id||0,id:X.id,previous_id:""},N.value=he}U.value=!0},wa=K(()=>{const X=[{label:s.value||t.country,value:"__country__"}];for(const we of l.value)X.push({label:we.name,value:we.value});return X}),qa=K(()=>{if(!V.value.length)return wa.value;const X=new Set(V.value.map(we=>we.state||""));return wa.value.filter(we=>{const le=we.value==="__country__"?"":we.value;return X.has(le)})}),il=X=>{const we=an(X),le=L.value.find(he=>he.value===we);le&&(G.value.category_name=le.label)},Ya=X=>{ul(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=X.type==="shipping"?"tax/rates/country/override/"+X.id:"tax/product-overrides/"+X.id;Ae.delete(we).then(le=>{q.success(le.message),B.value=B.value.filter(he=>!(he.id===X.id&&he.type===X.type))}).catch(le=>{var he;q.error(((he=le==null?void 0:le.data)==null?void 0:he.message)||u("Failed to delete override"))})}).catch(()=>{})},ma=async()=>{var we;const X=G.value.state==="__country__"?"":G.value.state;if(G.value.type==="products"&&!G.value.category_id){q.error(u("Please select a category"));return}if(G.value.type==="shipping"){if(!G.value.class_id){q.error(u("Please select a tax class"));return}if(I.value){q.error(u("Please wait for the province rates to finish loading"));return}const le=V.value.find(he=>(he.state||"")===X);G.value.id=le?le.value:0}j.value=!0;try{let le;if(G.value.type==="products"){const he=G.value.state==="__country__"?"":G.value.state;le=await Ae.post("tax/product-overrides",{id:W.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:he,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 Ae.post("tax/rates/country/override",{id:G.value.id,country:t.country,state:X,previous_id:W.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||""});q.success(le.message),U.value=!1,await ht()}catch(le){const he=((we=le==null?void 0:le.data)==null?void 0:we.message)||(le==null?void 0:le.message)||"Failed to save override";q.error(he)}finally{j.value=!1}};return be(()=>G.value.type,X=>{X==="shipping"&&(G.value.class_id||(G.value.class_id=p.value||0),Pt(G.value.class_id))}),be(()=>G.value.class_id,X=>{G.value.type!=="shipping"||!U.value||Pt(X).then(()=>{const we=G.value.state==="__country__"?"":G.value.state,le=V.value.map(he=>he.state||"");we!==""&&!le.includes(we)&&(G.value.state="__country__")})}),be(()=>G.value.state,X=>{if(!U.value||G.value.type!=="products"||W.value)return;const we=We(X==="__country__"?"":X);(!G.value.tax_label||G.value.tax_label===N.value)&&(G.value.tax_label=we),N.value=we}),Ie(()=>{ge()}),(X,we)=>{const le=C("el-breadcrumb-item"),he=C("el-breadcrumb"),Ye=C("el-switch"),st=C("el-skeleton"),je=C("el-input"),Xe=C("el-form-item"),mt=C("el-form"),et=C("el-button"),It=C("el-table-column"),pe=C("el-option"),_e=C("el-select"),Oe=C("el-table"),Me=C("el-tag"),ct=C("el-radio"),ee=C("el-radio-group"),Ne=C("el-checkbox"),pt=C("el-dialog");return r(),h("div",vfe,[o("div",gfe,[o("div",yfe,[o("div",bfe,[o("div",wfe,[n(he,{class:"mb-0","separator-icon":A(Al)},{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"]),Ce.value&&ve.value?(r(),h("div",Cfe,[i.value?(r(),h("span",{key:0,class:de(["text-sm",Ee.value?"text-success-500":"text-system-mid dark:text-gray-300"])},m(Ee.value?A(u)("Collecting tax"):A(u)("Disabled")),3)):x("",!0),n(Ye,{"model-value":i.value?Ee.value:!1,loading:ye.value,disabled:!i.value,"aria-label":Ue.value,onChange:ot},null,8,["model-value","loading","disabled","aria-label"])])):x("",!0)]),!a.value&&!i.value?(r(),h("div",kfe,[n(el,{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"])])):x("",!0),D.value?x("",!0):(r(),E(Se,{key:1},{default:d(()=>[n(ke,null,{default:d(()=>[fe.value?(r(),E(st,{key:0,animated:"",rows:2})):(r(),E(mt,{key:1,"label-position":"top"},{default:d(()=>[n(Xe,{label:A(u)("VAT/GST/Tax Number"),class:"mb-0"},{default:d(()=>[n(je,{modelValue:ae.value,"onUpdate:modelValue":we[0]||(we[0]=De=>ae.value=De),placeholder:A(u)("VAT/GST/Tax Number"),maxlength:"255"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})),o("div",Bfe,[n(et,{type:"primary",size:"small",loading:re.value,disabled:fe.value||re.value||ae.value===oe.value,onClick:Fe},{default:d(()=>[R(m(A(u)("Save")),1)]),_:1},8,["loading","disabled"])])]),_:1})]),_:1})),n(Se,null,{default:d(()=>[n(Ve,{title:A(u)("Base taxes")},null,8,["title"]),n(ke,null,{default:d(()=>[n(el,{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(ofe,{key:0})):(r(),h("div",xfe,[n(wf,{classes:c.value,"active-id":p.value,"max-classes":y.value,creating:_.value,search:S.value,onSwitch:Re,onDelete:Rt,onAdd:yt,onCreateCustom:gt,"onUpdate:search":we[1]||(we[1]=De=>S.value=De)},null,8,["classes","active-id","max-classes","creating","search"]),n(Oe,{data:F.value,class:"w-full fct-tax-rates-table","max-height":"450"},{default:d(()=>[n(It,{label:A(u)("Region")},{default:d(({row:De})=>[o("span",{class:de(["fct-base-taxes__region-name",De.state?"":"fct-base-taxes__region-name--federal"])},m(De.state?De.stateName:s.value||e.country),3)]),_:1},8,["label"]),n(It,{label:A(u)("Rate"),width:"130"},{default:d(({row:De})=>[n(je,{modelValue:De.rate,"onUpdate:modelValue":xt=>De.rate=xt,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(It,{label:A(u)("Tax Label"),width:"200"},{default:d(({row:De})=>[n(je,{modelValue:De.name,"onUpdate:modelValue":xt=>De.name=xt,size:"small",placeholder:A(u)("Tax name")},null,8,["modelValue","onUpdate:modelValue","placeholder"])]),_:1},8,["label"]),k.value.length>0?(r(),E(It,{key:0,label:A(u)("Compound"),width:"310"},{default:d(({row:De})=>[De.state?(r(),E(_e,{key:0,"model-value":ne(De),size:"small",style:{width:"100%"},onChange:xt=>ce(De,xt)},{default:d(()=>[n(pe,{value:"0_0",label:Z.value[0].label},null,8,["label"]),n(pe,{value:"0_1",label:Z.value[1].label},null,8,["label"]),n(pe,{value:"1_0",label:Z.value[2].label},null,8,["label"])]),_:2},1032,["model-value","onChange"])):x("",!0)]),_:1},8,["label"])):x("",!0)]),_:1},8,["data"]),o("div",Sfe,[f.value==="standard"?(r(),E(et,{key:0,loading:J.value,size:"small",onClick:wt,type:"danger",soft:""},{default:d(()=>[R(m(A(u)("Reset to default")),1)]),_:1},8,["loading"])):x("",!0),n(et,{type:"primary",size:"small",loading:ue.value,onClick:vt},{default:d(()=>[R(m(A(u)("Save Rates")),1)]),_:1},8,["loading"])])]))]),_:1})]),_:1}),n(Se,null,{default:d(()=>[n(Ve,{title:A(u)("Tax overrides"),text:A(u)("Override tax rates for specific product categories or shipping.")},{action:d(()=>[n(et,{size:"small",onClick:ta},{default:d(()=>[R(m(A(u)("Add Tax Override")),1)]),_:1})]),_:1},8,["title","text"]),n(ke,null,{default:d(()=>[o("div",Ffe,[n(Oe,{data:B.value,"empty-text":A(u)("No overrides configured")},{default:d(()=>[n(It,{label:A(u)("Type"),width:"110"},{default:d(({row:De})=>[n(Me,{type:De.type==="products"?"primary":"info",size:"small"},{default:d(()=>[R(m(De.type==="products"?A(u)("Product"):A(u)("Shipping")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),n(It,{label:A(u)("Category")},{default:d(({row:De})=>[R(m(De.category_name||"—"),1)]),_:1},8,["label"]),n(It,{label:A(u)("Tax Label")},{default:d(({row:De})=>[R(m(De.tax_label||"—"),1)]),_:1},8,["label"]),n(It,{label:A(u)("Location")},{default:d(({row:De})=>[R(m(De.location),1)]),_:1},8,["label"]),n(It,{label:A(u)("Tax Class"),width:"130"},{default:d(({row:De})=>[De.type==="products"?(r(),h("span",$fe,m(De.class_label||A(u)("All")),1)):(r(),h("span",Efe,m(De.class_label||"—"),1))]),_:1},8,["label"]),n(It,{label:A(u)("City / Postcode")},{default:d(({row:De})=>[De.city||De.postcode?(r(),h("span",Ufe,m([De.city,De.postcode].filter(Boolean).join(" / ")),1)):(r(),h("span",Ife,"—"))]),_:1},8,["label"]),n(It,{label:A(u)("Rate"),width:"100"},{default:d(({row:De})=>[R(m(De.rate)+"% ",1)]),_:1},8,["label"]),n(It,{label:A(u)("Actions"),width:"110",align:"right"},{default:d(({row:De})=>[o("div",Qfe,[n(at,{tag:"button",size:"small",onClick:xt=>zt(De)},{default:d(()=>[n(Y,{name:"Edit"})]),_:2},1032,["onClick"]),n(at,{tag:"button",size:"small",onClick:xt=>Ya(De),bg:"danger",outline:""},{default:d(()=>[n(Y,{name:"Delete"})]),_:2},1032,["onClick"])])]),_:1},8,["label"])]),_:1},8,["data","empty-text"])])]),_:1})]),_:1}),n(pt,{modelValue:U.value,"onUpdate:modelValue":we[17]||(we[17]=De=>U.value=De),title:(W.value?A(u)("Edit tax override for"):A(u)("Add tax override for"))+" "+(s.value||e.country),width:"520px","append-to-body":!0,onClose:ea},{footer:d(()=>[n(et,{onClick:we[16]||(we[16]=De=>U.value=!1)},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(et,{type:"primary",loading:j.value,onClick:ma},{default:d(()=>[R(m(W.value?A(u)("Save changes"):A(u)("Add override")),1)]),_:1},8,["loading"])]),default:d(()=>[n(mt,{"label-position":"top",model:G.value},{default:d(()=>[n(Xe,{label:A(u)("Override type")},{default:d(()=>[n(ee,{modelValue:G.value.type,"onUpdate:modelValue":we[2]||(we[2]=De=>G.value.type=De)},{default:d(()=>[n(ct,{value:"products"},{default:d(()=>[R(m(A(u)("Products")),1)]),_:1}),n(ct,{value:"shipping"},{default:d(()=>[R(m(A(u)("Shipping")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),G.value.type==="products"?(r(),h(P,{key:0},[n(Xe,{label:A(u)("Category")},{default:d(()=>[n(_e,{modelValue:G.value.category_id,"onUpdate:modelValue":we[3]||(we[3]=De=>G.value.category_id=De),filterable:"",placeholder:A(u)("Select a category"),loading:H.value,style:{width:"100%"},onChange:il},{default:d(()=>[(r(!0),h(P,null,te(L.value,De=>(r(),E(pe,{key:De.value,label:De.label,value:De.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","loading"])]),_:1},8,["label"]),n(Xe,{label:A(u)("Tax Class")},{default:d(()=>[n(_e,{modelValue:G.value.class_id,"onUpdate:modelValue":we[4]||(we[4]=De=>G.value.class_id=De),style:{width:"100%"}},{default:d(()=>[n(pe,{value:0,label:A(u)("All Tax Classes")},null,8,["label"]),(r(!0),h(P,null,te(c.value,De=>(r(),E(pe,{key:De.id,value:Number(De.id),label:De.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"]),n(Xe,{label:A(u)("Tax label")},{default:d(()=>[n(je,{modelValue:G.value.tax_label,"onUpdate:modelValue":we[5]||(we[5]=De=>G.value.tax_label=De),placeholder:A(u)("e.g. Tax, VAT, GST")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Xe,{label:A(u)("Location")},{default:d(()=>[n(_e,{modelValue:G.value.state,"onUpdate:modelValue":we[6]||(we[6]=De=>G.value.state=De),placeholder:A(u)("Select location"),filterable:"",style:{width:"100%"}},{default:d(()=>[(r(!0),h(P,null,te(wa.value,De=>(r(),E(pe,{key:De.value,label:De.label,value:De.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Xe,{label:A(u)("City (optional)")},{default:d(()=>[n(je,{modelValue:G.value.city,"onUpdate:modelValue":we[7]||(we[7]=De=>G.value.city=De),placeholder:A(u)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Xe,{label:A(u)("Postcode (optional)")},{default:d(()=>[n(je,{modelValue:G.value.postcode,"onUpdate:modelValue":we[8]||(we[8]=De=>G.value.postcode=De),placeholder:A(u)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Xe,{label:A(u)("Tax rate (%)")},{default:d(()=>[n(je,{modelValue:G.value.tax_rate,"onUpdate:modelValue":we[9]||(we[9]=De=>G.value.tax_rate=De),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(Xe,{key:0},{default:d(()=>[n(Ne,{modelValue:G.value.override_state_tax,"onUpdate:modelValue":we[10]||(we[10]=De=>G.value.override_state_tax=De)},{default:d(()=>[R(m(A(u)("Also override state/provincial taxes")),1)]),_:1},8,["modelValue"])]),_:1})):x("",!0)],64)):(r(),h(P,{key:1},[n(Xe,{label:A(u)("Tax Class")},{default:d(()=>[n(_e,{modelValue:G.value.class_id,"onUpdate:modelValue":we[11]||(we[11]=De=>G.value.class_id=De),style:{width:"100%"},loading:I.value},{default:d(()=>[(r(!0),h(P,null,te(c.value,De=>(r(),E(pe,{key:De.id,value:Number(De.id),label:De.title,disabled:W.value&&Number(De.id)!==Number(O.value)&&M.value.has(Number(De.id))},null,8,["value","label","disabled"]))),128))]),_:1},8,["modelValue","loading"])]),_:1},8,["label"]),n(Xe,{label:A(u)("Location")},{default:d(()=>[n(_e,{modelValue:G.value.state,"onUpdate:modelValue":we[12]||(we[12]=De=>G.value.state=De),placeholder:A(u)("Select location"),filterable:"",style:{width:"100%"}},{default:d(()=>[(r(!0),h(P,null,te(qa.value,De=>(r(),E(pe,{key:De.value,label:De.label,value:De.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Xe,{label:A(u)("City (optional)")},{default:d(()=>[n(je,{modelValue:G.value.city,"onUpdate:modelValue":we[13]||(we[13]=De=>G.value.city=De),placeholder:A(u)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Xe,{label:A(u)("Postcode (optional)")},{default:d(()=>[n(je,{modelValue:G.value.postcode,"onUpdate:modelValue":we[14]||(we[14]=De=>G.value.postcode=De),placeholder:A(u)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Xe,{label:A(u)("Tax rate (%)")},{default:d(()=>[n(je,{modelValue:G.value.tax_rate,"onUpdate:modelValue":we[15]||(we[15]=De=>G.value.tax_rate=De),type:"number",step:"0.01",min:"0"},null,8,["modelValue"])]),_:1},8,["label"])],64))]),_:1},8,["model"])]),_:1},8,["modelValue","title"])])])])])}}};class Dfe extends Vs{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 Vfe(e){return Dfe.init(e)}const Tfe=e=>e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase()),Mfe=e=>{const t=Object.keys(e[0]),l=[t.map(Tfe).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(`
`)},Lfe=(e,t="export.csv")=>new Promise((a,l)=>{try{if(!e||!e.length)throw new Error("No data to export");const s=Mfe(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)}}),Rfe={class:"table-cell"},Ofe={class:"table-cell"},Pfe={class:"table-cell"},Hfe={class:"table-cell"},Nfe={class:"table-cell"},Kfe={class:"table-cell"},Gfe={class:"table-cell"},zfe={class:"table-cell"},jfe={class:"table-cell"},qfe={__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",Rfe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):x("",!0),e.taxTable.isColumnVisible("order_id")?(r(),E(i,{key:1,label:A(u)("Order ID"),width:100},{default:d(()=>[o("div",Ofe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):x("",!0),n(i,{label:A(u)("Tax Country"),width:120},{default:d(()=>[o("div",Pfe,[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",Hfe,[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",Nfe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):x("",!0),n(i,{label:A(u)("Tax Name"),width:120},{default:d(()=>[o("div",Kfe,[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",Gfe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):x("",!0),n(i,{label:A(u)("Sale Taxes"),width:120},{default:d(()=>[o("div",zfe,[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",jfe,[n(p,{animated:""},{template:d(()=>[n(c,{variant:"p"})]),_:1})])]),_:1},8,["label"])):x("",!0)]),_:1},8,["data"])}}},Yfe={class:"table-cell"},Wfe={class:"table-cell"},Jfe={class:"table-cell"},Xfe={class:"table-cell"},Zfe={class:"table-cell"},eme={class:"table-cell"},tme={class:"table-cell"},ame={class:"table-cell"},lme={class:"table-cell"},sme={__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",Yfe,[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",Wfe,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[180px]"})]),_:1})])]),_:1},8,["label"])):x("",!0),n(p,{label:A(u)("Code"),width:206},{default:d(()=>[o("div",Jfe,[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",Xfe,[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",Zfe,[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",eme,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[80px]"})]),_:1})])]),_:1},8,["label"])):x("",!0),n(p,{label:A(u)("Status"),width:124},{default:d(()=>[o("div",tme,[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",ame,[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",lme,[n(c,{animated:""},{template:d(()=>[n(i,{variant:"p",class:"w-[70px]"})]),_:1})])]),_:1},8,["label"])):x("",!0)]),_:1},8,["data"])}}},nme={class:"fct-taxes-page fct-layout-width"},ome={key:1},ime={style:{display:"flex","flex-wrap":"wrap","align-items":"center",gap:"4px"}},rme={class:"fct-tax-filing-wrap"},dme={class:"fct-tax-filing-summary"},ume={class:"summary-item"},cme={class:"summary-label"},Ame={class:"summary-value"},pme={class:"summary-item"},fme={class:"summary-label"},mme={class:"summary-value"},hme={class:"fct-tax-filing max-h-[400px] overflow-y-auto"},_me={style:{display:"flex","flex-wrap":"wrap","align-items":"center",gap:"4px"}},vme={class:"dialog-footer"},gme={class:"fct-tax-filing-success-wrap"},yme={class:"fct-tax-filling-success-icon"},bme={class:"dialog-footer"},wme={__name:"Taxes",setup(e){const t=Object.fromEntries(ym.map(B=>[B.value,B.label])),a=B=>t[B]||B;Jt().ctx;const l=Vfe(),s=T(!1),i=T(!1),c=T(!1),p=T([]),f=K(()=>l.getTableData().map(B=>{var U,Q,V,I,M,O,L,H,j,W,G;return{id:B.id,order_id:B.order_id,country:a(((U=B.tax_rate)==null?void 0:U.country)??((Q=B.meta)==null?void 0:Q.tax_country)??""),state:((V=B.tax_rate)==null?void 0:V.formatted_state)??((I=B.tax_rate)==null?void 0:I.state)??"",postcode:((M=B.tax_rate)==null?void 0:M.postcode)??"",name:((O=B.tax_rate)==null?void 0:O.name)??((L=B.meta)==null?void 0:L.label)??"",reverse_charge:!!((H=B.meta)!=null&&H.reverse_charge_applied),rate:((j=B.tax_rate)==null?void 0:j.rate)??((W=B.meta)==null?void 0:W.rate_percent)??"",total_tax:String(parseFloat((B.total_tax/100).toFixed(2))),currency:((G=B.order)==null?void 0:G.currency)||"",total_tax:String(parseFloat((B.total_tax/100).toFixed(2))),filed_at:B.filed_at?u("Yes"):u("No")}})),_=()=>{s.value=!0,i.value=!1},g=()=>{s.value=!1,i.value=!0},y=async()=>{try{await Lfe($.value),g()}catch{}},v=()=>{i.value=!1},w=()=>{const B=$.value.map(U=>U.id);Ae.post(l.getFetchUrl(),{ids:B}).then(U=>{q.success(U.message),l.fetch()}).catch(U=>{q.error(U)}).finally(()=>{v()})},k=B=>{p.value=B,c.value=B.length>0},b=B=>{$.value=B},S=T(null),$=T([]),D=K(()=>{const B=$.value.reduce((Q,V)=>Q+parseFloat(V.total_tax||0),0),U=[...new Set($.value.map(Q=>Q.order_id))];return{totalTax:ft.formatNumber(Math.round(B*100),!1),totalOrders:U.length,items:$.value}}),F=()=>{xe(()=>{$.value=[...p.value],p.value.forEach(B=>{S.value.toggleRowSelection(B,!0)})})};return(B,U)=>{const Q=C("el-button"),V=C("el-tooltip"),I=C("el-table-column"),M=C("router-link"),O=C("el-tag"),L=C("el-table"),H=C("el-dialog");return r(),h("div",nme,[n(ol,{title:A(u)("Taxes")},{action:d(()=>[c.value?(r(),E(Q,{key:1,type:"primary",onClick:_,disabled:!c.value},{default:d(()=>[R(m(A(u)("Tax Filing")),1)]),_:1},8,["disabled"])):(r(),E(V,{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(Q,{type:"primary",disabled:!c.value},{default:d(()=>[R(m(A(u)("Tax Filing")),1)]),_:1},8,["disabled"])]),_:1},8,["content"]))]),_:1},8,["title"]),n(Ts,{table:A(l),"has-mobile-slot":!1},{default:d(()=>[A(l).isLoading()?(r(),E(qfe,{key:0,taxTable:A(l),"next-page-count":A(l).nextPageCount},null,8,["taxTable","next-page-count"])):(r(),h("div",ome,[n(L,{class:"w-full",data:f.value,onSelectionChange:k},{empty:d(()=>[n(Ct,{icon:"Empty/ListView","has-dark":!0,text:A(u)("We could't find any taxes matching your filter.")},null,8,["text"])]),default:d(()=>[n(I,{type:"selection",width:45}),A(l).isColumnVisible("id")?(r(),E(I,{key:0,label:A(u)("ID"),width:100},{default:d(j=>[o("span",null,"#"+m(A(u)(j.row.id)),1)]),_:1},8,["label"])):x("",!0),A(l).isColumnVisible("order_id")?(r(),E(I,{key:1,label:A(u)("Order ID"),width:100},{default:d(j=>[o("span",ime,[n(M,{class:"link",to:{name:"view_order",params:{order_id:j.row.order_id}}},{default:d(()=>[R(" #"+m(j.row.order_id),1)]),_:2},1032,["to"]),j.row.reverse_charge?(r(),E(O,{key:0,type:"warning",size:"small","disable-transitions":""},{default:d(()=>[R(m(A(u)("Reverse Charge")),1)]),_:1})):x("",!0)])]),_:1},8,["label"])):x("",!0),n(I,{label:A(u)("Tax Country"),width:120},{default:d(j=>[o("span",null,m(j.row.country),1)]),_:1},8,["label"]),n(I,{label:A(u)("Tax Region"),width:120},{default:d(j=>[o("span",null,m(j.row.state),1)]),_:1},8,["label"]),A(l).isColumnVisible("postcode")?(r(),E(I,{key:2,label:A(u)("Zip Code"),width:120},{default:d(j=>[o("span",null,m(j.row.postcode),1)]),_:1},8,["label"])):x("",!0),n(I,{label:A(u)("Tax Name"),width:120},{default:d(j=>[o("span",null,m(j.row.name),1)]),_:1},8,["label"]),A(l).isColumnVisible("rate")?(r(),E(I,{key:3,label:A(u)("Tax Rate"),width:120},{default:d(j=>[o("span",null,m(j.row.rate)+"%",1)]),_:1},8,["label"])):x("",!0),n(I,{label:A(u)("Sale Taxes"),width:120},{default:d(j=>[o("span",null,m(A(ft).formatForOrder(j.row.total_tax_cents,j.row.currency)),1)]),_:1},8,["label"]),A(l).isColumnVisible("filed_at")?(r(),E(I,{key:4,label:A(u)("Filed"),width:120},{default:d(j=>[o("span",null,m(j.row.filed_at),1)]),_:1},8,["label"])):x("",!0)]),_:1},8,["data"])]))]),_:1},8,["table"]),n(H,{modelValue:s.value,"onUpdate:modelValue":U[1]||(U[1]=j=>s.value=j),title:A(u)("Tax Filing"),onOpen:F,class:"fct-tax-filling-modal"},{footer:d(()=>[o("div",vme,[n(Q,{onClick:U[0]||(U[0]=()=>{s.value=!1})},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(Q,{type:"primary",onClick:y},{default:d(()=>[n(Y,{name:"Download",style:{width:"16px",height:"16px"}}),R(" "+m(A(u)("Download & Continue")),1)]),_:1})])]),default:d(()=>[o("div",rme,[o("div",dme,[o("div",ume,[o("span",cme,m(A(u)("Taxable Amount")),1),o("span",Ame,m(D.value.totalTax),1)]),o("div",pme,[o("span",fme,m(A(u)("Total Orders")),1),o("span",mme,m(A(u)(D.value.totalOrders)),1)])]),o("div",hme,[n(L,{ref_key:"selectedTaxesTableRef",ref:S,data:p.value,onSelectionChange:b},{empty:d(()=>[n(Ct,{icon:"Empty/ListView",text:A(u)("We could't find any taxes matching your filter.")},null,8,["text"])]),default:d(()=>[n(I,{type:"selection",width:45}),n(I,{label:A(u)("ID"),width:100},{default:d(j=>[o("span",null,m(j.row.id),1)]),_:1},8,["label"]),n(I,{label:A(u)("Order ID"),"min-width":100},{default:d(j=>[o("span",_me,[o("span",null,m(j.row.order_id),1),j.row.reverse_charge?(r(),E(O,{key:0,type:"warning",size:"small","disable-transitions":""},{default:d(()=>[R(m(A(u)("Reverse Charge")),1)]),_:1})):x("",!0)])]),_:1},8,["label"]),n(I,{width:120,label:A(u)("Tax Country")},{default:d(j=>[o("span",null,m(j.row.country),1)]),_:1},8,["label"]),n(I,{width:120,label:A(u)("Tax Region")},{default:d(j=>[o("span",null,m(j.row.state),1)]),_:1},8,["label"]),n(I,{label:A(u)("Zip Code"),width:120},{default:d(j=>[o("span",null,m(j.row.postcode),1)]),_:1},8,["label"]),n(I,{width:120,label:A(u)("Tax Name")},{default:d(j=>[o("span",null,m(j.row.name),1)]),_:1},8,["label"]),n(I,{label:A(u)("Tax Rate"),width:120},{default:d(j=>[o("span",null,m(j.row.rate)+"%",1)]),_:1},8,["label"]),n(I,{width:150,label:A(u)("Sale Taxes")},{default:d(j=>[o("span",null,m(A(ft).formatForOrder(j.row.total_tax_cents,j.row.currency)),1)]),_:1},8,["label"])]),_:1},8,["data"])])])]),_:1},8,["modelValue","title"]),n(H,{modelValue:i.value,"onUpdate:modelValue":U[2]||(U[2]=j=>i.value=j),class:"fct-tax-filling-success-modal","close-on-click-modal":!1},{footer:d(()=>[o("div",bme,[n(Q,{onClick:v},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(Q,{type:"primary",onClick:w},{default:d(()=>[R(m(A(u)("Mark as Filed")),1)]),_:1})])]),default:d(()=>[o("div",gme,[o("div",yme,[n(Y,{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:Ge(y,["prevent"]),class:"cursor-pointer"},m(A(u)("Download Again")),1)])])])]),_:1},8,["modelValue"])])}}},Cme={class:"fct-card fct-card-border fct-vat-card"},kme={class:"fct-card-body"},Bme={class:"fct-vat-card-header"},xme={class:"fct-vat-card-title"},Sme={class:"fct-card fct-card-border fct-vat-card mt-5"},Fme={class:"fct-card-body"},$me={class:"fct-vat-card-header"},Eme={class:"fct-vat-card-title"},Ume={class:"fct-tax-rates-country-view"},Ime={class:"border border-gray-200 rounded-md overflow-hidden dark:border-dark-300"},Qme={class:"grid grid-cols-[110px_1fr_1fr_1fr_100px_80px] gap-4 py-3 border-b border-gray-200 dark:border-dark-300"},Dme={__name:"EUVatSettingsLoader",setup(e){const t=[1,2,3];return(a,l)=>(r(),h("div",null,[o("div",Cme,[o("div",kme,[o("div",Bme,[o("div",xme,[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",Sme,[o("div",Fme,[o("div",$me,[o("div",Eme,[o("h3",null,m(A(u)("Tax overrides")),1)])]),o("div",Ume,[o("div",Ime,[o("div",Qme,[(r(),h(P,null,te(6,s=>o("div",{key:"header-"+s,class:"fct-sk h-3 rounded-xs"})),64))]),(r(),h(P,null,te(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]=[Dn('',6)]))),64))])])])])]))}},Vme={class:"fct-modal-body"},Tme={class:"fct-radio-option-fields"},Mme={class:"form-note"},Lme={class:"fct-radio-option-fields"},Rme={class:"fct-radio-option-fields-desc"},Ome={class:"form-note"},Pme={key:0,class:"fct-info-box mt-3"},Hme={class:"text-xs text-system-mid"},Nme={class:"fct-radio-option-fields"},Kme={class:"fct-radio-option-fields-desc"},Gme={__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=T({method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}),i=T(!1);be(()=>a.modelValue,_=>{if(_){const g=a.initialRegistrations.length?a.initialRegistrations[0]:null,y=g?g.country:"",v=g&&g.vat||"",w=a.currentForm||{};s.value={method:w.method||"oss",oss_country:w.oss_country||y,oss_vat:w.oss_vat||v,home_country:w.home_country||y,home_vat:w.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){q.error(u("Select a cross-border registration type"));return}if(s.value.method==="oss"){if(!s.value.oss_country){q.error(u("Select your country of OSS registration"));return}}else if(s.value.method==="home"&&!s.value.home_country){q.error(u("Select your country of registration"));return}i.value=!0,(s.value.method==="home"&&!p()?Ae.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(()=>Ae.post("tax/configuration/settings/eu-vat",{action:"euCrossBorderSettings",eu_vat_settings:s.value})).then(g=>{q.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;q.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"),w=C("el-select"),k=C("el-form-item"),b=C("el-input"),S=C("el-radio-group"),$=C("el-form"),D=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]=B=>l("update:modelValue",B))},{footer:d(()=>[n(D,{onClick:g[8]||(g[8]=B=>l("update:modelValue",!1))},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(D,{type:"primary",onClick:f,loading:i.value},{default:d(()=>[R(m(A(u)("Collect VAT")),1)]),_:1},8,["loading"])]),default:d(()=>[o("div",Vme,[n($,{"label-position":"top"},{default:d(()=>[n(S,{modelValue:s.value.method,"onUpdate:modelValue":g[7]||(g[7]=B=>s.value.method=B),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]=B=>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(ya,{accordion:"",visible:s.value.method==="oss"},{default:d(()=>[o("div",Tme,[n(k,{label:A(u)("Country of OSS registration")},{default:d(()=>[n(w,{modelValue:s.value.oss_country,"onUpdate:modelValue":g[0]||(g[0]=B=>s.value.oss_country=B),placeholder:A(u)("Select country"),filterable:"",class:"w-full"},{default:d(()=>[(r(!0),h(P,null,te(e.countries,B=>(r(),E(v,{key:B.value,label:B.label,value:B.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(k,{label:A(u)("VAT number")},{default:d(()=>[n(b,{modelValue:s.value.oss_vat,"onUpdate:modelValue":g[1]||(g[1]=B=>s.value.oss_vat=B),placeholder:A(u)("e.g. DE999999999")},null,8,["modelValue","placeholder"]),o("div",Mme,[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]=B=>s.value.method="home")},[n(y,{value:"home"},{default:d(()=>[R(m(A(u)("Collect using your home country registration")),1)]),_:1}),n(ya,{accordion:"",visible:s.value.method==="home"},{default:d(()=>[o("div",Lme,[o("p",Rme,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(w,{modelValue:s.value.home_country,"onUpdate:modelValue":g[3]||(g[3]=B=>s.value.home_country=B),placeholder:A(u)("Select country"),filterable:"",class:"w-full"},{default:d(()=>[(r(!0),h(P,null,te(e.countries,B=>(r(),E(v,{key:B.value,label:B.label,value:B.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(k,{label:A(u)("VAT number")},{default:d(()=>[n(b,{modelValue:s.value.home_vat,"onUpdate:modelValue":g[4]||(g[4]=B=>s.value.home_vat=B),placeholder:A(u)("e.g. DE999999999")},null,8,["modelValue","placeholder"]),o("div",Ome,[o("p",null,m(A(u)("Shown on VAT invoice")),1)])]),_:1},8,["label"]),e.initialRegistrations.length?x("",!0):(r(),h("div",Pme,[n(Y,{name:"InformationFill",class:"w-4 h-4 text-blue-500 flex-shrink-0"}),o("span",Hme,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]=B=>s.value.method="specific")},[n(y,{value:"specific"},{default:d(()=>[R(m(A(u)("Collect using specific country registrations")),1)]),_:1}),n(ya,{accordion:"",visible:s.value.method==="specific"},{default:d(()=>[o("div",Nme,[o("p",Kme,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"])}}},zme={key:0,class:"fct-country-registrations-list mt-4"},jme={class:"fct-home-country-header"},qme=["src","alt"],Yme={class:"fct-vat-country-name"},Wme={key:0,class:"fct-collecting-badge"},Jme={class:"fct-home-country-body"},Xme={class:"fct-vat-home-field"},Zme={class:"fct-vat-home-field__label"},ehe={class:"fct-reg-rates-section"},the={class:"fct-reg-rates-table fct-reg-rates-table--home mt-5 px-5 pt-5"},ahe={class:"fct-reg-rates-row fct-reg-rates-header"},lhe={class:"fct-reg-rates-cell-label"},she={class:"fct-reg-rates-cell-label"},nhe={key:1,class:"fct-reg-class-name"},ohe={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},ihe={class:"fct-reg-rates-cell-input"},rhe={class:"fct-reg-rates-cell-action"},dhe=["title","onClick"],uhe={key:0,class:"fct-reg-add-class px-5"},che={type:"button",class:"fct-reg-add-class-btn"},Ahe={class:"fct-vat-home-actions"},phe={__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=T({country:"",vat:"",rates:{}}),i=T([]),c=K(()=>a.homeCountry&&a.countries.find(B=>B.value===a.homeCountry)||null),p=K(()=>a.homeCountry&&a.registrations.find(B=>B.country===a.homeCountry)||null),f=K(()=>{const B=p.value;return!B||!B.vat?!1:B.rates&&typeof B.rates=="object"&&Object.keys(B.rates).length?Object.values(B.rates).some(function(U){return U&&parseFloat(U.rate)>0}):parseFloat(B.rate)>0}),_=K(()=>[...a.taxClasses,...i.value]),g=K(()=>_.value.length?_.value:[{slug:"standard",title:u("Standard")}]),y=K(()=>{if(_.value.length>=6)return[];const B=_.value.map(Q=>Q.slug).filter(Boolean),U=[];return B.includes("reduced")||U.push({command:"reduced",label:u("Reduced")}),B.includes("zero")||U.push({command:"zero",label:u("Zero")}),U.push({command:"custom",label:u("Custom Class...")}),U});be([()=>a.homeCountry,()=>a.homeVat,()=>a.taxClasses,()=>a.registrations],()=>{const B=p.value,U={};a.taxClasses.forEach(Q=>{var O;const V=(O=B==null?void 0:B.rates)==null?void 0:O[Q.slug],I=Q.slug==="standard"?(B==null?void 0:B.rate)??"":"",M=Q.slug==="standard"?(B==null?void 0:B.tax_label)??"":"";V&&typeof V=="object"?U[Q.slug]={rate:V.rate??"",label:V.label??""}:U[Q.slug]={rate:V??I,label:M}}),i.value.forEach(Q=>{const V=v(Q);U[V]=s.value.rates[V]||{rate:"",label:""}}),U.standard||(U.standard={rate:"",label:""}),s.value={country:a.homeCountry||"",vat:(B==null?void 0:B.vat)||a.homeVat||"",rates:U}},{immediate:!0});function v(B){return B.tempKey||B.slug}function w(B){if(B==="custom"){b();return}const U=B==="reduced"?u("Reduced"):u("Zero");i.value.push({slug:B,title:U,tempKey:B}),s.value.rates[B]={rate:"",label:""}}let k=0;function b(){const B="_new_"+k++;i.value.push({slug:null,title:"",tempKey:B,isNew:!0}),s.value.rates[B]={rate:"",label:""}}function S(B){return B.slug?B.title||B.slug:B.title&&B.title.trim()?B.title.trim():u("Custom")}function $(B){if(B.hasError=!1,B.created)return Promise.resolve(null);if(!B.slug&&!(B.title&&B.title.trim()))return B.hasError=!0,Promise.reject(new Error(u("Please enter a name for the custom tax class")));const U=B.slug?{slug:B.slug}:{title:B.title.trim()};return Ae.post("tax/classes",U).then(Q=>{const V=(Q==null?void 0:Q.class)||{},I=V.slug||B.slug;if(!I)throw new Error(u("Tax class creation returned an invalid response"));return!B.slug&&s.value.rates[B.tempKey]!==void 0&&(s.value.rates[I]=s.value.rates[B.tempKey],delete s.value.rates[B.tempKey],B.tempKey=null),B.slug=I,B.title=V.title||B.title,B.created=!0,V}).catch(Q=>{var I;B.hasError=!0;const V=((I=Q==null?void 0:Q.data)==null?void 0:I.message)||u("Failed to create tax class");throw new Error(u("%1$s: %2$s",V,S(B)))})}function D(B){const U=v(B);if(i.value.some(V=>v(V)===U)){i.value=i.value.filter(V=>v(V)!==U),delete s.value.rates[U];return}ul(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?',B.title),u("Delete Tax Class"),{confirmButtonText:u("Delete"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{Ae.delete("tax/classes/"+B.id).then(()=>{l("class-changed")}).catch(V=>{var I;q.error(((I=V==null?void 0:V.data)==null?void 0:I.message)||u("Failed to delete tax class"))})}).catch(()=>{})}function F(){const B=i.value.map($);Promise.all(B).then(()=>{i.value=[],l("save-home",{country:s.value.country,vat:s.value.vat,rates:s.value.rates})}).catch(U=>{q.error((U==null?void 0:U.message)||u("Failed to create tax class"))})}return(B,U)=>{const Q=C("el-input"),V=C("el-dropdown-item"),I=C("el-dropdown-menu"),M=C("el-dropdown"),O=C("el-button");return c.value?(r(),h("div",zme,[o("div",jme,[o("img",{src:`https://flagcdn.com/w40/${e.homeCountry.toLowerCase()}.png`,alt:c.value.label,class:"fct-flag-icon"},null,8,qme),o("span",Yme,m(c.value.label),1),f.value?(r(),h("span",Wme,[U[1]||(U[1]=o("span",{class:"fct-green-dot"},null,-1)),R(" "+m(A(u)("Collecting")),1)])):x("",!0)]),o("div",Jme,[o("div",Xme,[o("label",Zme,m(A(u)("VAT number")),1),n(Q,{modelValue:s.value.vat,"onUpdate:modelValue":U[0]||(U[0]=L=>s.value.vat=L),class:"fct-vat-number-input"},null,8,["modelValue"])]),o("div",ehe,[o("div",the,[o("div",ahe,[o("div",lhe,m(A(u)("Tax Classes")),1),U[2]||(U[2]=o("div",{class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},null,-1)),U[3]||(U[3]=o("div",{class:"fct-reg-rates-cell-input"},null,-1)),U[4]||(U[4]=o("div",{class:"fct-reg-rates-cell-action"},null,-1))]),(r(!0),h(P,null,te(g.value,L=>(r(),h("div",{key:v(L),class:"fct-reg-rates-row"},[o("div",she,[L.isNew?(r(),E(Q,{key:0,modelValue:L.title,"onUpdate:modelValue":H=>L.title=H,size:"small",placeholder:A(u)("Class name"),class:de(["fct-reg-class-name-input",{"fct-reg-class-name-input--error":L.hasError}]),onInput:H=>L.hasError=!1},null,8,["modelValue","onUpdate:modelValue","placeholder","class","onInput"])):(r(),h("span",nhe,m(L.title),1))]),o("div",ohe,[n(Q,{modelValue:s.value.rates[v(L)].rate,"onUpdate:modelValue":H=>s.value.rates[v(L)].rate=H,type:"number",step:"0.01",min:"0",size:"small"},{suffix:d(()=>U[5]||(U[5]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])]),o("div",ihe,[n(Q,{modelValue:s.value.rates[v(L)].label,"onUpdate:modelValue":H=>s.value.rates[v(L)].label=H,size:"small",placeholder:A(u)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])]),o("div",rhe,[L.slug!=="standard"?(r(),h("button",{key:0,type:"button",class:"fct-reg-rates-delete-btn",title:A(u)("Delete class"),onClick:H=>D(L)},[n(Y,{name:"Delete"})],8,dhe)):x("",!0)])]))),128))]),y.value.length?(r(),h("div",uhe,[y.value.length===1&&y.value[0].command==="custom"?(r(),h("button",{key:0,type:"button",class:"fct-reg-add-class-btn",onClick:b},[n(Y,{name:"Plus",class:"w-3 h-3"}),R(" "+m(A(u)("Add class")),1)])):(r(),E(M,{key:1,trigger:"click",onCommand:w,"popper-class":"fct-dropdown"},{dropdown:d(()=>[n(I,null,{default:d(()=>[(r(!0),h(P,null,te(y.value,L=>(r(),E(V,{key:L.command,command:L.command},{default:d(()=>[R(m(L.label),1)]),_:2},1032,["command"]))),128))]),_:1})]),default:d(()=>[o("button",che,[n(Y,{name:"Plus",class:"w-3 h-3"}),R(" "+m(A(u)("Add class")),1)])]),_:1}))])):x("",!0)]),o("div",Ahe,[n(O,{type:"primary",size:"small",onClick:F},{default:d(()=>[R(m(A(u)("Save VAT")),1)]),_:1})])])])):x("",!0)}}},fhe={class:"fct-modal-body fct-country-reg-modal"},mhe={class:"fct-country-reg-text"},hhe={class:"form-note"},_he={class:"fct-reg-rates-table"},vhe={class:"fct-reg-rates-row fct-reg-rates-header"},ghe={class:"fct-reg-rates-cell-label"},yhe={class:"fct-reg-rates-cell-label"},bhe={key:1,class:"fct-reg-class-name"},whe={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},Che={class:"fct-reg-rates-cell-input"},khe={key:1,class:"fct-reg-rates-row"},Bhe={class:"fct-reg-rates-cell-label"},xhe={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},She={class:"fct-reg-rates-cell-input"},Fhe={key:0,class:"fct-reg-add-class"},$he={type:"button",class:"fct-reg-add-class-btn"},Ehe={__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=T({country:"",vat:"",rates:{},isEdit:!1}),i=T([]),c=T(!1),p=K(()=>[...a.taxClasses,...i.value]),f=K(()=>{if(p.value.length>=6)return[];const D=p.value.map(B=>B.slug).filter(Boolean),F=[];return D.includes("reduced")||F.push({command:"reduced",label:u("Reduced")}),D.includes("zero")||F.push({command:"zero",label:u("Zero")}),F.push({command:"custom",label:u("Custom Class...")}),F}),_=K(()=>s.value.isEdit?a.countries:a.countries.filter(D=>!a.registeredCountries.includes(D.value)));be(()=>a.modelValue,D=>{if(D){const F=a.initialForm||{},B=F.rates?JSON.parse(JSON.stringify(F.rates)):{};a.taxClasses.forEach(U=>{B[U.slug]||(B[U.slug]={rate:"",label:""})}),B.standard||(B.standard={rate:"",label:""}),s.value={country:F.country||"",vat:F.vat||"",rates:B,isEdit:F.isEdit||!1},i.value=[]}});function g(D){return D.tempKey||D.slug}function y(D){const F=a.countries.find(B=>B.value===D);if(F&&F.default_rate){const B=s.value.rates.standard||{};s.value.rates=Object.assign({},s.value.rates,{standard:Object.assign({},B,{rate:F.default_rate})})}}function v(D){if(D==="custom"){k();return}const F=D==="reduced"?u("Reduced"):u("Zero");i.value.push({slug:D,title:F,tempKey:D}),s.value.rates[D]={rate:"",label:""}}let w=0;function k(){const D="_new_"+w++;i.value.push({slug:null,title:"",tempKey:D,isNew:!0}),s.value.rates[D]={rate:"",label:""}}function b(D){return D.slug?D.title||D.slug:D.title&&D.title.trim()?D.title.trim():u("Custom")}function S(D){if(D.hasError=!1,D.created)return Promise.resolve(null);if(!D.slug&&!(D.title&&D.title.trim()))return D.hasError=!0,Promise.reject(new Error(u("Please enter a name for the custom tax class")));const F=D.slug?{slug:D.slug}:{title:D.title.trim()};return Ae.post("tax/classes",F).then(B=>{const U=(B==null?void 0:B.class)||{},Q=U.slug||D.slug;if(!Q)throw new Error(u("Tax class creation returned an invalid response"));return!D.slug&&s.value.rates[D.tempKey]!==void 0&&(s.value.rates[Q]=s.value.rates[D.tempKey],delete s.value.rates[D.tempKey],D.tempKey=null),D.slug=Q,D.title=U.title||D.title,D.created=!0,U}).catch(B=>{var Q;D.hasError=!0;const U=((Q=B==null?void 0:B.data)==null?void 0:Q.message)||u("Failed to create tax class");throw new Error(u("%1$s: %2$s",U,b(D)))})}function $(){if(!s.value.country){q.error(u("Select a registration country"));return}const D=s.value.rates;if(!Object.values(D).some(U=>parseFloat(U.rate)>0)){q.error(u("At least one tax rate must be greater than 0%"));return}c.value=!0;const B=i.value.map(S);Promise.all(B).then(()=>Ae.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:s.value.country,vat:s.value.vat,rates:s.value.rates})).then(U=>{q.success(U.message),i.value=[],l("saved"),l("update:modelValue",!1)}).catch(U=>{var Q;q.error((U==null?void 0:U.message)||((Q=U==null?void 0:U.data)==null?void 0:Q.message)||u("Failed to save VAT registration"))}).finally(()=>{c.value=!1})}return(D,F)=>{const B=C("el-option"),U=C("el-select"),Q=C("el-form-item"),V=C("el-input"),I=C("el-dropdown-item"),M=C("el-dropdown-menu"),O=C("el-dropdown"),L=C("el-form"),H=C("el-button"),j=C("el-dialog");return r(),E(j,{"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]=W=>l("update:modelValue",W))},{footer:d(()=>[n(H,{onClick:F[4]||(F[4]=W=>l("update:modelValue",!1))},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(H,{type:"primary",onClick:$,loading:c.value},{default:d(()=>[R(m(A(u)("Collect VAT")),1)]),_:1},8,["loading"])]),default:d(()=>[o("div",fhe,[o("p",mhe,m(A(u)("Make sure you're registered for VAT when collecting in the EU.")),1),n(L,{"label-position":"top"},{default:d(()=>[n(Q,{label:A(u)("Registration country")},{default:d(()=>[n(U,{modelValue:s.value.country,"onUpdate:modelValue":F[0]||(F[0]=W=>s.value.country=W),placeholder:A(u)("Select country"),filterable:"",class:"w-full",disabled:s.value.isEdit,onChange:y},{default:d(()=>[(r(!0),h(P,null,te(_.value,W=>(r(),E(B,{key:W.value,label:W.label,value:W.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","disabled"])]),_:1},8,["label"]),n(Q,{label:A(u)("VAT number")},{default:d(()=>[n(V,{modelValue:s.value.vat,"onUpdate:modelValue":F[1]||(F[1]=W=>s.value.vat=W),placeholder:s.value.country?s.value.country+"999999999":"DE999999999"},null,8,["modelValue","placeholder"]),o("div",hhe,[o("p",null,m(A(u)("Shown on VAT invoice")),1)])]),_:1},8,["label"]),o("div",_he,[o("div",vhe,[o("div",ghe,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(P,{key:0},te(p.value,W=>(r(),h("div",{key:W.tempKey||W.slug,class:"fct-reg-rates-row"},[o("div",yhe,[W.isNew?(r(),E(V,{key:0,modelValue:W.title,"onUpdate:modelValue":G=>W.title=G,size:"small",placeholder:A(u)("Class name"),class:de(["fct-reg-class-name-input",{"fct-reg-class-name-input--error":W.hasError}]),onInput:G=>W.hasError=!1},null,8,["modelValue","onUpdate:modelValue","placeholder","class","onInput"])):(r(),h("span",bhe,m(W.title),1))]),o("div",whe,[n(V,{modelValue:s.value.rates[g(W)].rate,"onUpdate:modelValue":G=>s.value.rates[g(W)].rate=G,modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",size:"small",placeholder:W.slug==="standard"?"19":"0"},{suffix:d(()=>F[8]||(F[8]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue","placeholder"])]),o("div",Che,[n(V,{modelValue:s.value.rates[g(W)].label,"onUpdate:modelValue":G=>s.value.rates[g(W)].label=G,size:"small",placeholder:A(u)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])])]))),128)):(r(),h("div",khe,[o("div",Bhe,m(A(u)("Standard")),1),o("div",xhe,[n(V,{modelValue:s.value.rates.standard.rate,"onUpdate:modelValue":F[2]||(F[2]=W=>s.value.rates.standard.rate=W),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",She,[n(V,{modelValue:s.value.rates.standard.label,"onUpdate:modelValue":F[3]||(F[3]=W=>s.value.rates.standard.label=W),size:"small",placeholder:A(u)("e.g. VAT, MwSt")},null,8,["modelValue","placeholder"])])]))]),f.value.length?(r(),h("div",Fhe,[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(Y,{name:"Plus"}),R(" "+m(A(u)("Add class")),1)])):(r(),E(O,{key:1,trigger:"click",onCommand:v},{dropdown:d(()=>[n(M,null,{default:d(()=>[(r(!0),h(P,null,te(f.value,W=>(r(),E(I,{key:W.command,command:W.command},{default:d(()=>[R(m(W.label),1)]),_:2},1032,["command"]))),128))]),_:1})]),default:d(()=>[o("button",$he,[n(Y,{name:"Plus"}),R(" "+m(A(u)("Add class")),1)])]),_:1}))])):x("",!0)]),_:1})])]),_:1},8,["model-value","title"])}}},Uhe={class:"fct-oss-rates-section"},Ihe=["aria-expanded"],Qhe={class:"inline-flex items-center gap-2"},Dhe={class:"fct-oss-rates-count"},Vhe={class:"fct-oss-rates-table"},The={key:1,class:"text-system-mid"},Mhe={class:"fct-btn-group mt-4 justify-end sm"},Lhe={__name:"EUVatOssRatesSection",setup(e,{expose:t}){const a=T([]),l=T([]),s=T(null),i=T("standard"),c=T(!1),p=T(!1),f=T(!1),_=T(!1),g=T(6),y=T(!1),v=T(""),w=K(()=>a.value),k=K(()=>{const Q=v.value.trim().toLowerCase();return Q?w.value.filter(V=>V.label&&V.label.toLowerCase().includes(Q)):w.value});function b(){return c.value=!0,Ae.get("tax/configuration/settings/eu-vat/oss-rates").then(Q=>{a.value=Q.rates||[],l.value=Q.classes||[];const V=Td({classes:l.value,activeId:s.value});return V&&(s.value=V.id,i.value=V.slug),l.value}).catch(Q=>{var V;q.error((V=Q==null?void 0:Q.data)==null?void 0:V.message)}).finally(()=>{c.value=!1})}function S(Q){s.value=Q.id,i.value=Q.slug}function $(Q){y.value=!0,Jo({payload:{slug:Q},createdSlug:Q,currentClasses:l.value,reloadClasses:b}).then(({createdClass:V})=>{V&&S(V)}).catch(V=>{var I;q.error((I=V==null?void 0:V.data)==null?void 0:I.message)}).finally(()=>{y.value=!1})}function D(Q){y.value=!0,Jo({payload:{title:Q},currentClasses:l.value,reloadClasses:b}).then(({createdClass:V})=>{V&&S(V)}).catch(V=>{var I;q.error((I=V==null?void 0:V.data)==null?void 0:I.message)}).finally(()=>{y.value=!1})}function F(Q){Q.slug!=="standard"&&ul(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?',Q.title),u("Delete Tax Class"),{confirmButtonText:u("Remove"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{c.value=!0,Cf({classId:Q.id,currentActiveId:s.value===Q.id?null:s.value,reloadClasses:b}).then(({nextActiveClass:V})=>{V&&S(V)}).catch(V=>{var I;q.error((I=V==null?void 0:V.data)==null?void 0:I.message),c.value=!1})}).catch(()=>{})}function B(){p.value=!0,Ae.post("tax/configuration/settings/eu-vat/oss-rates",{rates:w.value.map(Q=>({country:Q.country,rate:Q.rate,tax_label:Q.tax_label||"",class_rates:Q.class_rates||{}}))}).then(Q=>{q.success(Q.message)}).catch(Q=>{var V;q.error((V=Q==null?void 0:Q.data)==null?void 0:V.message)}).finally(()=>{p.value=!1})}function U(){ul(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,Ae.post("tax/configuration/settings/eu-vat/reset-rates").then(()=>b()).then(()=>{q.success(u("EU tax rates have been reset to defaults"))}).catch(Q=>{var V;q.error(((V=Q==null?void 0:Q.data)==null?void 0:V.message)||u("Failed to reset rates"))}).finally(()=>{f.value=!1})}).catch(()=>{})}return Ie(b),t({loadRates:b}),(Q,V)=>{const I=C("el-icon"),M=C("el-table-column"),O=C("el-input"),L=C("el-table"),H=C("el-button"),j=Va("loading");return r(),h("div",Uhe,[o("div",{class:"fct-oss-rates-toggle",role:"button",tabindex:"0","aria-expanded":_.value,onClick:V[0]||(V[0]=W=>{_.value=!_.value,_.value||(v.value="")}),onKeydown:[V[1]||(V[1]=xa(Ge(W=>{_.value=!_.value,_.value||(v.value="")},["prevent"]),["enter"])),V[2]||(V[2]=xa(Ge(W=>{_.value=!_.value,_.value||(v.value="")},["prevent"]),["space"]))]},[o("span",Qhe,[R(m(A(u)("Destination country rates"))+" ",1),o("span",Dhe," ("+m(w.value.length)+") ",1)]),n(I,{class:de(["fct-oss-rates-arrow",{"is-expanded":_.value}])},{default:d(()=>[n(Y,{name:"ChevronDown",class:"w-4 h-4"})]),_:1},8,["class"])],40,Ihe),n(Xl,{name:"fct-collapse"},{default:d(()=>[Wt(o("div",Vhe,[n(el,{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(wf,{classes:l.value,"active-id":s.value,"max-classes":g.value,creating:y.value,search:v.value,onSwitch:S,onDelete:F,onAdd:$,onCreateCustom:D,"onUpdate:search":V[3]||(V[3]=W=>v.value=W)},null,8,["classes","active-id","max-classes","creating","search"]),Wt((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(M,{label:A(u)("Country"),"min-width":"160"},{default:d(({row:W})=>[R(m(W.label),1)]),_:1},8,["label"]),n(M,{label:A(u)("Tax Label"),"min-width":"150"},{default:d(({row:W})=>[W.class_rates&&W.class_rates[i.value]?(r(),E(O,{key:0,modelValue:W.class_rates[i.value].label,"onUpdate:modelValue":G=>W.class_rates[i.value].label=G,size:"small",placeholder:A(u)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])):x("",!0)]),_:1},8,["label"]),n(M,{label:A(u)("Rate"),"min-width":"120"},{default:d(({row:W})=>[W.class_rates&&W.class_rates[i.value]?(r(),E(O,{key:0,modelValue:W.class_rates[i.value].rate,"onUpdate:modelValue":G=>W.class_rates[i.value].rate=G,modelModifiers:{number:!0},size:"small",type:"number",min:0,max:100,step:"0.5"},{suffix:d(()=>V[4]||(V[4]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])):(r(),h("span",The,"—"))]),_:1},8,["label"])]),_:1},8,["data","empty-text"])),[[j,c.value]]),o("div",Mhe,[i.value==="standard"?(r(),E(H,{key:0,size:"small",loading:f.value,onClick:U,type:"danger",soft:""},{default:d(()=>[R(m(A(u)("Reset to default")),1)]),_:1},8,["loading"])):x("",!0),n(H,{type:"primary",size:"small",loading:p.value,onClick:B},{default:d(()=>[R(m(A(u)("Save Rates")),1)]),_:1},8,["loading"])])],512),[[Tl,_.value]])]),_:1})])}}},Rhe={class:"fct-vat-card-header"},Ohe={class:"fct-vat-card-title"},Phe={class:"fct-vat-card-body"},Hhe={class:"fct-vat-reg-info"},Nhe={class:"fct-vat-country-name"},Khe={key:0,size:"small",type:"success",class:"ml-3 fct-collecting-badge"},Ghe={key:1,class:"ml-3 text-sm text-system-mid dark:text-gray-400"},zhe={key:2,class:"fct-country-registrations-list mt-4"},jhe={class:"fct-reg-rows"},qhe={key:0,class:"fct-vat-registration-row"},Yhe={class:"fct-vat-reg-info"},Whe=["src","alt"],Jhe={class:"fct-vat-country-name"},Xhe={class:"fct-vat-reg-info"},Zhe=["src","alt"],e_e={class:"fct-vat-country-name"},t_e={key:0,class:"fct-vat-number"},a_e={key:1,class:"fct-vat-missing-badge"},l_e={class:"fct-vat-reg-actions"},s_e={key:1,class:"fct-vat-empty-state"},n_e={class:"text-system-mid text-sm"},o_e={key:0,class:"px-5 py-3"},i_e={key:1,class:"fct-vat-cross-border-empty"},r_e={class:"fct-vat-cross-border-empty-text"},d_e={class:"fct-vat-cross-border-empty-title"},u_e={class:"fct-vat-cross-border-empty-desc"},c_e={__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=T({method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}),i=T(!1),c=T(null),p=T([]),f=T(!1),_=T({country:"",vat:"",rates:{},isEdit:!1}),g=K(()=>a.countries.length||28),y=K(()=>a.initialRegistrations.filter(D).length),v=K(()=>a.storeCountry&&a.countries.find(Z=>Z.value===a.storeCountry)||null),w=K(()=>a.storeCountry?a.initialRegistrations.some(Z=>Z.country===a.storeCountry):!1),k=K(()=>{if(s.value.method!=="home"||!s.value.home_country)return!1;const Z=a.initialRegistrations.find(ne=>ne.country===s.value.home_country);return!!Z&&D(Z)}),b=K(()=>s.value.method==="oss"||s.value.method==="home"||s.value.method==="specific");function S(Z){if(!Z||!Array.isArray(a.countries))return Z;const ne=a.countries.find(ce=>ce.value===Z);return ne?ne.label:Z}function $(Z){return Z?Z.rates&&typeof Z.rates=="object"&&Object.keys(Z.rates).length?Object.values(Z.rates).some(ne=>ne&&parseFloat(ne.rate)>0):parseFloat(Z.rate)>0:!1}function D(Z){return!!Z&&!!Z.vat&&$(Z)}function F(Z){return $(Z)&&!Z.vat}function B(){return Ae.get("tax/classes").then(Z=>{p.value=Z.classes||[]}).catch(()=>{q.error(u("Failed to load tax classes"))})}function U(Z){const ne={};return p.value.forEach(ce=>{ne[ce.slug]={rate:ce.slug==="standard"&&Z||"",label:""}}),ne}function Q(){const Z=v.value&&!w.value?a.storeCountry:"",ne=Z&&v.value&&v.value.default_rate||"";_.value={country:Z,vat:"",rates:U(ne),isEdit:!1},f.value=!0}function V(Z){const ne=Z.rates||{},ce={};p.value.forEach(z=>{const ue=ne[z.slug];if(ue&&typeof ue=="object")ce[z.slug]={rate:ue.rate||"",label:ue.label||""};else{const ie=z.slug==="standard"?Z.rate||"":ue||"";ce[z.slug]={rate:ie,label:z.slug==="standard"&&Z.tax_label||""}}}),_.value={country:Z.country,vat:Z.vat||"",rates:ce,isEdit:!0},f.value=!0}function I(){B(),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:s.value.home_vat})}function M(Z){Ae.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:Z.country,vat:Z.vat,rates:Z.rates}).then(ne=>{q.success(ne.message),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:Z.vat})}).catch(ne=>{var ce;q.error(((ce=ne==null?void 0:ne.data)==null?void 0:ce.message)||u("Failed to save VAT registration"))})}function O(Z){ul(u("Are you sure you want to remove this country registration?"),u("Confirm Remove"),{confirmButtonText:u("Yes, Remove"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{Ae.post("tax/configuration/settings/eu-vat",{action:"deleteCountryRegistration",country:Z}).then(ne=>{q.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 ce;q.error((ce=ne==null?void 0:ne.data)==null?void 0:ce.message)})}).catch(()=>{})}function L(){return y.value===1?u("Collecting in 1 country"):u("Collecting in %1$s countries",y.value)}const H=K(()=>g.value===1?u("Collecting in 1 region"):u("Collecting in %1$s regions",g.value));function j(Z){s.value={method:Z.method,oss_country:Z.oss_country,oss_vat:Z.oss_vat,home_country:Z.home_country,home_vat:Z.home_country_vat},Z.method==="oss"&&xe(()=>{var ne;return(ne=c.value)==null?void 0:ne.loadRates()}),l("method-changed",{method:Z.method,home_country:Z.home_country,home_vat:Z.home_country_vat})}function W(Z){Z==="edit"?i.value=!0:Z==="stop"&&G()}function G(){ul(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(()=>{Ae.post("tax/configuration/settings/eu-vat",{action:"euCrossBorderSettings",eu_vat_settings:{method:"specific"},reset_registration:"yes"}).then(Z=>{q.success(Z.message),s.value={method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""},l("method-changed",{method:"",home_country:"",home_vat:""})}).catch(Z=>{var ne;q.error((ne=Z==null?void 0:Z.data)==null?void 0:ne.message)})}).catch(()=>{})}return be(()=>a.initialForm,Z=>{const ne=Z||{};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,Z=>{Z&&Z.length&&B()},{immediate:!0}),(Z,ne)=>{const ce=C("el-tooltip"),z=C("el-dropdown-item"),ue=C("el-dropdown-menu"),ie=C("el-dropdown"),J=C("el-button");return r(),h(P,null,[n(Se,{class:"fct-vat-card"},{default:d(()=>[n(ke,null,{default:d(()=>[o("div",Rhe,[o("div",Ohe,[o("h3",null,m(A(u)("Collect VAT cross-border")),1),n(ce,{content:A(u)("Choose how to collect VAT for sales to other EU countries."),placement:"top"},{default:d(()=>[n(Y,{name:"InformationFill",class:"w-4 h-4 text-system-mid cursor-pointer"})]),_:1},8,["content"])]),b.value?(r(),E(ie,{key:0,trigger:"click",onCommand:W,"popper-class":"fct-dropdown",placement:"bottom-end"},{dropdown:d(()=>[n(ue,null,{default:d(()=>[n(z,{command:"edit"},{default:d(()=>[R(m(A(u)("Edit registration")),1)]),_:1}),n(z,{command:"stop"},{default:d(()=>[R(m(A(u)("Stop collecting")),1)]),_:1})]),_:1})]),default:d(()=>[n(at,{border:"none",size:"small",tag:"button"},{default:d(()=>[n(Y,{name:"More"})]),_:1})]),_:1})):x("",!0)]),o("div",Phe,[b.value?(r(),h(P,{key:0},[o("div",Hhe,[ne[4]||(ne[4]=o("span",{class:"fct-eu-flag-icon"},"🇪🇺",-1)),o("span",Nhe,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",Khe,[ne[3]||(ne[3]=o("span",{class:"fct-green-dot"},null,-1)),s.value.method==="specific"?(r(),h(P,{key:0},[R(m(L()),1)],64)):(r(),h(P,{key:1},[R(m(H.value),1)],64))])):x("",!0),e.isTaxEnabled?x("",!0):(r(),h("span",Ghe,m(A(u)("Tax disabled")),1))]),s.value.method==="home"?(r(),E(el,{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"])):x("",!0),s.value.method==="home"?(r(),E(phe,{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:M,onClassChanged:B},null,8,["countries","home-country","home-vat","tax-classes","registrations"])):x("",!0),s.value.method==="specific"?(r(),h("div",zhe,[o("div",jhe,[v.value&&!w.value?(r(),h("div",qhe,[o("div",Yhe,[o("img",{src:`https://flagcdn.com/w40/${e.storeCountry.toLowerCase()}.png`,alt:v.value.label,class:"fct-flag-icon"},null,8,Whe),o("span",Jhe,m(v.value.label),1)]),n(J,{size:"small",onClick:Q},{default:d(()=>[R(m(A(u)("Configure")),1)]),_:1})])):x("",!0),(r(!0),h(P,null,te(e.initialRegistrations,N=>(r(),h("div",{key:N.country,class:"fct-vat-registration-row"},[o("div",Xhe,[o("img",{src:`https://flagcdn.com/w40/${N.country.toLowerCase()}.png`,alt:S(N.country),class:"fct-flag-icon"},null,8,Zhe),o("span",e_e,m(S(N.country)),1),N.vat?(r(),h("span",t_e,m(N.vat),1)):F(N)?(r(),h("span",a_e,m(A(u)("VAT ID missing")),1)):x("",!0)]),o("div",l_e,[$(N)?(r(),E(at,{key:0,border:"none",size:"small",tag:"button",title:A(u)("Edit"),onClick:ae=>V(N)},{default:d(()=>[n(Y,{name:"Edit"})]),_:2},1032,["title","onClick"])):(r(),E(J,{key:1,size:"small",onClick:ae=>V(N)},{default:d(()=>[R(m(A(u)("Configure")),1)]),_:2},1032,["onClick"])),n(at,{border:"none",size:"small",tag:"button",title:A(u)("Delete"),onClick:ae=>O(N.country)},{default:d(()=>[n(Y,{name:"Delete"})]),_:2},1032,["title","onClick"])])]))),128)),!e.initialRegistrations.length&&!v.value?(r(),h("div",s_e,[o("p",n_e,m(A(u)("No country VAT registrations configured.")),1),n(J,{type:"primary",size:"small",onClick:Q},{default:d(()=>[R(m(A(u)("Configure")),1)]),_:1})])):x("",!0)]),e.initialRegistrations.length||v.value?(r(),h("div",o_e,[n(J,{type:"primary",link:"",onClick:Q},{default:d(()=>[R(" + "+m(A(u)("Collect in another country")),1)]),_:1})])):x("",!0)])):x("",!0),s.value.method==="oss"?(r(),E(Lhe,{key:3,ref_key:"ossRatesRef",ref:c},null,512)):x("",!0)],64)):(r(),h("div",i_e,[ne[5]||(ne[5]=o("span",{class:"fct-eu-flag-icon"},"🇪🇺",-1)),o("div",r_e,[o("p",d_e,m(A(u)("Not collecting cross-border VAT")),1),o("p",u_e,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]=N=>i.value=!0),type:"primary"},{default:d(()=>[R(m(A(u)("Configure")),1)]),_:1})]))])]),_:1})]),_:1}),n(Gme,{modelValue:i.value,"onUpdate:modelValue":ne[1]||(ne[1]=N=>i.value=N),countries:e.countries,"current-form":s.value,"initial-registrations":e.initialRegistrations,onSaved:j},null,8,["modelValue","countries","current-form","initial-registrations"]),n(Ehe,{modelValue:f.value,"onUpdate:modelValue":ne[2]||(ne[2]=N=>f.value=N),countries:e.countries,"tax-classes":p.value,"initial-form":_.value,"registered-countries":e.initialRegistrations.map(N=>N.country),onSaved:I},null,8,["modelValue","countries","tax-classes","initial-form","registered-countries"])],64)}}},A_e={__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=T({type:"products",original_type:"",original_id:"",category_id:"",category_name:"",country:"",city:"",postcode:"",tax_label:"VAT",tax_rate:0,class_id:0,id:""}),i=T([]),c=T(!1),p=T(!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(b){if(b.type==="shipping")s.value={type:"shipping",original_type:"shipping",original_id:b.id,category_id:"",category_name:"",country:b._raw.country||"",city:b._raw.city||"",postcode:b._raw.postcode||"",tax_label:b.tax_label,tax_rate:b.rate,class_id:Number(b._raw.class_id)||f(),id:b.id};else{const S=b._raw.meta_value||b._raw;s.value={type:"products",original_type:"products",original_id:b.id,category_id:an(S.category_id),category_name:b.category_name,country:S.country||"",city:S.city||"",postcode:S.postcode||"",tax_label:b.tax_label,tax_rate:b.rate,class_id:Number(b.class_id)||0,id:b.id}}}be(()=>a.modelValue,b=>{b&&(a.editRow?g(a.editRow):_(),y())}),be(()=>s.value.type,b=>{b==="shipping"&&!s.value.class_id&&(s.value.class_id=f())}),be(()=>a.taxClasses,b=>{s.value.type==="shipping"&&!s.value.class_id&&b&&b.length>0&&(s.value.class_id=Number(b[0].id)||0)});function y(){i.value.length>0||(c.value=!0,Ae.get("products/fetch-term").then(b=>{const S=b.taxonomies&&b.taxonomies["product-categories"]?b.taxonomies["product-categories"].terms||[]:[];i.value=S.map($=>({...$,value:an($.value)}))}).catch(()=>{q.error(u("Failed to load product categories"))}).finally(()=>{c.value=!1}))}function v(b,S){return Ae.get("tax/rates/country/rates/"+b,{class_id:S}).then($=>{const F=($&&$.tax_rates?$.tax_rates:[]).find(function(U){return!U.state&&!U.city&&!U.postcode});if(F)return F;const B=a.countries.find(function(U){return U.value===b});return Ae.post("tax/country/rate",{country:b,state:"",rate:B&&B.default_rate||0,name:"Tax",is_compound:0,for_order:0,group:"EU",class_id:S}).then(function(U){return U&&U.tax_rate?U.tax_rate:null})})}function w(b){const S=an(b),$=i.value.find(D=>D.value===S);$&&(s.value.category_name=$.label)}function k(){if(s.value.type==="products"&&!s.value.category_id){q.error(u("Please select a category"));return}if(!s.value.country){q.error(u("Please select a location"));return}if(s.value.type==="shipping"){if(!a.taxClasses||a.taxClasses.length===0){q.error(u("Tax classes are not available. Please reload the page and try again."));return}if(!s.value.class_id){q.error(u("Please select a tax class"));return}}if(p.value=!0,s.value.type==="products")Ae.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(b=>{q.success(b.message),l("saved"),l("update:modelValue",!1)}).catch(b=>{q.error(b&&b.data?b.data.message:b&&b.message?b.message:"")}).finally(()=>{p.value=!1});else{const b=s.value.class_id;v(s.value.country,b).then(S=>S?Ae.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:b,override_tax_rate:s.value.tax_rate,city:s.value.city||"",postcode:s.value.postcode||""}).then($=>{q.success($.message),l("saved"),l("update:modelValue",!1)}).catch($=>{q.error($&&$.data?$.data.message:$&&$.message?$.message:"")}).finally(()=>{p.value=!1}):(q.error(u("No tax rate found for the selected country and tax class")),p.value=!1,null)).catch(S=>{q.error(S&&S.data?S.data.message:S&&S.message?S.message:""),p.value=!1})}}return(b,S)=>{const $=C("el-radio"),D=C("el-radio-group"),F=C("el-form-item"),B=C("el-option"),U=C("el-select"),Q=C("el-input"),V=C("el-form"),I=C("el-button"),M=C("el-dialog");return r(),E(M,{"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(I,{onClick:S[13]||(S[13]=O=>l("update:modelValue",!1))},{default:d(()=>[R(m(A(u)("Cancel")),1)]),_:1}),n(I,{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(V,{"label-position":"top",model:s.value},{default:d(()=>[n(F,{label:A(u)("Override type")},{default:d(()=>[n(D,{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(P,{key:0},[n(F,{label:A(u)("Category")},{default:d(()=>[n(U,{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:w},{default:d(()=>[(r(!0),h(P,null,te(i.value,O=>(r(),E(B,{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(U,{modelValue:s.value.class_id,"onUpdate:modelValue":S[2]||(S[2]=O=>s.value.class_id=O),style:{width:"100%"}},{default:d(()=>[n(B,{value:0,label:A(u)("All Tax Classes")},null,8,["label"]),(r(!0),h(P,null,te(e.taxClasses,O=>(r(),E(B,{key:O.id,value:Number(O.id),label:O.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])):x("",!0),n(F,{label:A(u)("Tax label")},{default:d(()=>[n(Q,{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(U,{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(P,null,te(e.countries,O=>(r(),E(B,{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(Q,{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(Q,{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(Q,{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(P,{key:1},[n(F,{label:A(u)("Location")},{default:d(()=>[n(U,{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(P,null,te(e.countries,O=>(r(),E(B,{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(U,{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(P,null,te(e.taxClasses,O=>(r(),E(B,{key:O.id,value:Number(O.id),label:O.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])):x("",!0),n(F,{label:A(u)("City (optional)")},{default:d(()=>[n(Q,{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(Q,{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(Q,{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"])}}},p_e={class:"fct-tax-rates-country-view"},f_e={key:0,class:"border border-gray-200 rounded-md overflow-hidden dark:border-dark-300"},m_e={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"},h_e={key:0},__e={key:1},v_e={class:"fct-btn-group sm justify-end"},g_e={__name:"EUVatTaxOverridesCard",props:{countries:{type:Array,default:()=>[]}},setup(e){const t=e,a=T([]),l=T(!1),s=T(!1),i=T(null),c=T([]);function p(w){if(!w||!Array.isArray(t.countries))return w;const k=t.countries.find(b=>b.value===w);return k?k.label:w}function f(){Ae.get("tax/classes").then(w=>{c.value=w.classes||[]}).catch(()=>{q.error(u("Failed to load tax classes"))})}function _(){l.value=!0,Ae.get("tax/configuration/settings/eu-vat/product-overrides").then(w=>{const k=[],b=w.overrides||[];for(const $ of b){const D=$.meta_value||$;k.push({id:$.id,type:"products",tax_label:D.tax_label||"",category_name:D.category_name||"",location:p(D.country),city:D.city||"",postcode:D.postcode||"",rate:D.rate,class_id:Number($.class_id)||0,class_label:$.class_label||"",_raw:$})}const S=w.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(w){i.value=w,s.value=!0}function v(w){ul(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=w.type==="shipping"?"tax/rates/country/override/"+w.id:"tax/product-overrides/"+w.id;Ae.delete(k).then(b=>{q.success(b.message),a.value=a.value.filter(S=>!(S.id===w.id&&S.type===w.type))}).catch(b=>{var S;q.error((S=b==null?void 0:b.data)==null?void 0:S.message)})}).catch(()=>{})}return Ie(()=>{f(),_()}),(w,k)=>{const b=C("el-button"),S=C("el-tag"),$=C("el-table-column"),D=C("el-table");return r(),h(P,null,[n(Se,{class:"fct-vat-card"},{default:d(()=>[n(Ve,{title:A(u)("Tax overrides"),text:A(u)("Override tax rates for specific product categories or shipping.")},{action:d(()=>[n(b,{size:"small",onClick:g},{default:d(()=>[R(m(A(u)("Add Tax Override")),1)]),_:1})]),_:1},8,["title","text"]),n(ke,null,{default:d(()=>[o("div",p_e,[l.value?(r(),h("div",f_e,[o("div",m_e,[(r(),h(P,null,te(6,F=>o("div",{key:"loading-header-"+F,class:"fct-sk h-3 rounded-xs"})),64))]),(r(),h(P,null,te(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(D,{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",h_e,m([F.city,F.postcode].filter(Boolean).join(" / ")),1)):(r(),h("span",__e,"—"))]),_: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",v_e,[n(at,{tag:"button",size:"small",onClick:B=>y(F)},{default:d(()=>[n(Y,{name:"Edit"})]),_:2},1032,["onClick"]),n(at,{tag:"button",size:"small",onClick:B=>v(F),bg:"danger",outline:""},{default:d(()=>[n(Y,{name:"Delete"})]),_:2},1032,["onClick"])])]),_:1},8,["label"])]),_:1},8,["data","empty-text"]))])]),_:1})]),_:1}),n(A_e,{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)}}},y_e={class:"setting-wrap"},b_e={class:"setting-wrap-inner"},w_e={class:"fct-tax-collection-page"},C_e={__name:"EUVatSettings",setup(e){const t=T(!0),a=ze.get("eu_vat_county_options",[]),l=T(""),s=T(""),i=T([]),c=T({}),p=K(()=>!!ze.get("is_tax_enabled"));function f(){return t.value=!0,Ae.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;q.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",y_e,[n(Ua,{heading:A(u)("VAT collection"),"show-save-button":!1},null,8,["heading"]),o("div",b_e,[n(Ia),o("div",w_e,[t.value?(r(),E(Dme,{key:0})):(r(),h(P,{key:1},[n(c_e,{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(g_e,{countries:A(a),class:"mt-5"},null,8,["countries"])],64))])])]))}};class k_e extends Vs{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 kf(e){return k_e.init(e)}const B_e={class:"fct-table-mobile-wrap fct-coupons-table-mobile-wrap"},x_e={class:"fct-table-mobile-header"},S_e={class:"fct-table-mobile-header-left"},F_e={class:"fct-table-id-col"},$_e={class:"fct-table-status-col"},E_e=["onClick"],U_e={class:"title"},I_e={class:"value"},Q_e={key:0,class:"fct-table-action-col"},D_e={class:"more-btn pr-0"},V_e={class:"fct-table-mobile-body"},T_e=["onClick"],M_e={key:0,class:"fct-table-coupon-title-col"},L_e={class:"fct-table-coupon-code-col"},R_e=["onClick"],O_e={class:"fct-table-mobile-footer"},P_e=["onClick"],H_e={class:"fct-table-date-col grid"},N_e={class:"title"},K_e={class:"value"},G_e={key:0,class:"fct-table-stackable-col"},z_e={class:"title"},j_e={class:"value"},q_e={class:"fct-table-amount-col"},Y_e={class:"title"},W_e={class:"value"},J_e={__name:"CouponsTableMobile",props:{table:{type:Object,required:!0},emptyText:{type:String,default:u("No customers found.")}},setup(e){lt.extend(Ai);const t=e,a=s=>{if(!s||s==="0000-00-00 00:00:00")return!1;const i=lt.utc(s).local();return i.isValid()?i.isBefore(lt()):!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"&&ul(i,u("Confirm Delete!"),{confirmButtonText:u("Yes, Delete!"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{Ae.delete("coupons/"+s.coupon.id).then(c=>{q.success(c.message),t.table.fetch()}).catch(c=>{q.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",B_e,[(r(!0),h(P,null,te(e.table.getTableData(),(y,v)=>(r(),h("div",{key:y.id,class:"fct-table-mobile-row"},[o("div",x_e,[o("div",S_e,[o("div",F_e,[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",$_e,[n(fa,{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(Us)(y.start_date,!0))),1)]),default:d(()=>[n(Y,{name:"InformationFill",class:"w-4 h-4 flex-none"})]),_:2},1024)):x("",!0)]),o("div",{class:"fct-table-usage-col",onClick:w=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[o("div",U_e,m(A(u)("Usage:")),1),o("div",I_e,[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,E_e)]),e.table.isColumnVisible("actions")?(r(),h("div",Q_e,[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(Y,{name:"Edit"}),R(" "+m(A(u)("Edit")),1)]),_:2},1032,["to"])]),_:2},1024)):x("",!0),n(f,{command:{action:"delete",coupon:y},class:"item-destructive"},{default:d(()=>[n(Y,{name:"Delete"}),R(" "+m(A(u)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:d(()=>[o("span",D_e,[n(Y,{name:"More"})])]),_:2},1024)])):x("",!0)]),o("div",V_e,[o("div",{class:"fct-table-coupon-code-wrapper-col",onClick:w=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[e.table.isColumnVisible("title")?(r(),h("div",M_e,m(y.title),1)):x("",!0),o("div",L_e,[o("code",{class:"copyable-content",onClick:w=>{A(as).copy(y.code)}},m(y.code),9,R_e)])],8,T_e)]),o("div",O_e,[o("div",{class:"fct-table-mobile-footer-row items-start",onClick:w=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[o("div",H_e,[o("div",N_e,m(A(u)("Expiry Date")),1),o("div",K_e,[isNaN(Date.parse(y.end_date))?(r(),h(P,{key:1},[R("n/a")],64)):(r(),E(Pa,{key:0,"date-time":y.end_date,"with-time":!0},null,8,["date-time"]))])]),e.table.isColumnVisible("stackable")?(r(),h("div",G_e,[o("div",z_e,m(A(u)("Stackable")),1),o("div",j_e,m(y.stackable),1)])):x("",!0),o("div",q_e,[o("div",Y_e,m(A(u)("Amount")),1),o("div",W_e,m(y.type!=="percentage"?A(Kt)(y.amount,!0):y.amount+"%"),1)])],8,P_e)])]))),128))])}}},X_e={},Z_e={class:"px-4 py-3"},eve={class:"grid grid-cols-3 gap-5 mt-5"};function tve(e,t){const a=C("el-skeleton-item"),l=C("el-skeleton");return r(),E(l,{animated:""},{template:d(()=>[o("div",Z_e,[(r(),h(P,null,te(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",eve,[(r(),h(P,null,te(3,s=>o("div",{key:s},[n(a,{varient:"p",class:"w-1/2"}),n(a,{varient:"p",class:"w-[100px]"})])),64))])])]),_:1})}const ave=nt(X_e,[["render",tve]]),lve={class:"fct-all-coupons-page fct-layout-width"},sve={class:"fct-all-coupons-wrap"},nve={key:1},ove=["onClick"],ive={class:"capitalize"},rve={class:"more-btn mr-2"},Fc={__name:"AllCoupons",setup(e){lt.extend(Ai);const t=kf(),a=T(!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"&&ul(p,u("Confirm Delete!"),{confirmButtonText:u("Yes, Delete!"),cancelButtonText:u("Cancel"),type:"warning"}).then(()=>{Ae.delete("coupons/"+c.coupon.id).then(f=>{q.success(f.message),t.fetch()}).catch(f=>{var _;f.status_code=="422"?q.validationErrors(f):q.error((_=f.data)==null?void 0:_.message)}).finally(()=>{})}).catch(()=>{})},s=()=>{Ae.get("coupons/getSettings").then(c=>{a.value=!!parseInt(c.show_on_checkout)}).catch(c=>{var p;c.status_code=="422"?q.validationErrors(c):q.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=lt.utc(c).local();return p.isValid()?p.isBefore(lt()):!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"),w=C("el-dropdown-menu"),k=C("el-dropdown"),b=C("el-table");return r(),E(Ot,{permission:"coupons/view"},{default:d(()=>[o("div",lve,[n(ol,{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",sve,[n(Ts,{table:A(t),"has-mobile-slot":!0},{mobile:d(()=>[A(t).isLoading()?(r(),E(ave,{key:0})):x("",!0),A(t).isLoading()?x("",!0):(r(),E(J_e,{key:1,table:A(t)},null,8,["table"]))]),default:d(()=>[A(t).isLoading()?(r(),E(sme,{key:0,couponTable:A(t),"next-page-count":A(t).nextPageCount},null,8,["couponTable","next-page-count"])):(r(),h("div",nve,[n(b,{data:A(t).getTableData(),class:"w-full compact-table full-compact"},{empty:d(()=>[n(Ct,{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(sa)(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"])):x("",!0),n(_,{label:A(u)("Code"),width:200},{default:d(S=>[o("code",{class:"copyable-content",onClick:$=>{A(as).copy(S.row.code)}},m(S.row.code),9,ove)]),_: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(Kt)(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(sa)(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",ive,m(S.row.stackable),1)]),_:2},1032,["to"])]),_:1},8,["label"])):x("",!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(fa,{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(Us)(S.row.start_date,!0))),1)]),default:d(()=>[n(Y,{name:"InformationFill",class:"w-4 h-4 flex-none"})]),_:2},1024)):x("",!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(P,{key:1},[R("n/a")],64)):(r(),E(Pa,{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(w,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(Y,{name:"Edit"}),R(" "+m(A(u)("Edit")),1)]),_:2},1032,["to"])]),_:2},1024)):x("",!0),n(v,{command:{action:"delete",coupon:S.row},class:"item-destructive"},{default:d(()=>[n(Y,{name:"Delete"}),R(" "+m(A(u)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:d(()=>[o("span",rve,[n(Y,{name:"More"})])]),_:2},1024)]),_:1},8,["label"])):x("",!0)]),_:1},8,["data"])]))]),_:1},8,["table"])])])]),_:1})}}},dve={class:"fct-add-edit-coupon-wrapper fct-layout-width"},uve={class:"single-page-header"},cve={class:"single-page-body"},Ave={class:"fct-add-edit-coupon"},pve={class:"fct-add-edit-coupon-main"},fve={class:"fct-add-edit-coupon-aside"},mve={class:"fct-admin-sidebar"},hve={__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",dve,[o("div",uve,[n(c,{"separator-icon":A(Al)},{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",cve,[o("div",Ave,[o("div",pve,[n(Se,null,{default:d(()=>[n(Ve,{title:A(u)("Basic Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(ke,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(Se,null,{default:d(()=>[n(Ve,{title:A(u)("Discount Value"),border_bottom:"",title_size:"small"},null,8,["title"]),n(ke,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(Se,null,{default:d(()=>[n(Ve,{title:A(u)("Schedule"),border_bottom:"",title_size:"small"},null,8,["title"]),n(ke,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(Se,null,{default:d(()=>[n(Ve,{title:A(u)("Maximum Discount Uses"),border_bottom:"",title_size:"small"},null,8,["title"]),n(ke,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(Se,null,{default:d(()=>[n(Ve,{title:A(u)("Additional Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(ke,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",fve,[o("div",mve,[n(Se,null,{default:d(()=>[n(Ve,{title:A(u)("Summary"),border_bottom:"",title_size:"small"},null,8,["title"]),n(ke,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})])])])])])}}};lt.extend(Ai);lt.extend(pA);const _ve={name:"AddOrEditCoupon",components:{CardContainer:Se,CardHeader:Ve,CardBody:ke,LabelHint:pa,ValidationError:Aa,CopyToClipboard:Ea,DynamicTemplates:pn,SaveBar:un,ProductVariationSelector:fA,SingleCouponLoader:hve,Activity:iA},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 Al},maxDiscountAmount(){return this.coupon.type==="percentage"?100:999999}},watch:{coupon:{handler(){this.handleChangesMade()},deep:!0}},mounted(){this.keyboardShortcuts=bs(),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(){Ae.get("products/fetch-term").then(e=>{this.categories=e.taxonomies["product-categories"].terms}).catch(e=>{var t;e.status_code=="422"?q.validationErrors(e):q.error((t=e.data)==null?void 0:t.message)}).finally(()=>{})},fetchCoupon(){this.fetchingCoupon=!0,this.isInitialLoading=!0,Ae.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=lt.utc(t).tz(lt.tz.guess()).format("YYYY-MM-DD HH:mm:ss")),a&&a!=="0000-00-00 00:00:00"&&(e.coupon.end_date=lt.utc(a).tz(lt.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"?q.validationErrors(errors):q.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}}),Ae.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}),q.success(a.message),this.validationErrors={},this.setDefaultStatus(),this.changes_made=0}).catch(a=>{var l;a.status_code=="422"?(q.validationErrors(a),this.validationErrors=a):q.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}}),Ae.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}),q.success(a.message),this.$router.push({name:"coupons"}),this.validationErrors={}}).catch(a=>{var l;a.status_code=="422"?(q.validationErrors(a),this.validationErrors=a):q.error((l=a.data)==null?void 0:l.message)}).finally(()=>{this.creating=!1})}}},vve={class:"fct-add-edit-coupon-wrapper fct-layout-width"},gve={class:"single-page-header"},yve={class:"single-page-body"},bve={class:"fct-add-edit-coupon"},wve={class:"fct-add-edit-coupon-main"},Cve={class:"flex gap-2 items-center justify-between w-full mb-2.5"},kve={class:"form-note"},Bve=["innerHTML"],xve={key:1},Sve=["innerHTML"],Fve=["innerHTML"],$ve=["innerHTML"],Eve={class:"fct-add-edit-coupon-aside"},Uve={class:"fct-admin-sidebar"},Ive={class:"fct-admin-sidebar-item"},Qve={key:0,class:"flex items-center gap-1"},Dve={class:"text-sm font-medium text-system-dark dark:text-gray-300"},Vve={key:1},Tve={class:"fct-admin-sidebar-item mt-5 hidden"},Mve={class:"sidebar-title mb-3"},Lve={class:"fct-bullet-lists"},Rve={class:"fct-admin-sidebar-item mt-5 hidden"},Ove={class:"sidebar-title mb-3"},Pve={class:"fct-bullet-lists"},Hve={key:0};function Nve(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"),w=C("el-form-item"),k=C("el-col"),b=C("LabelHint"),S=C("el-row"),$=C("CardBody"),D=C("CardContainer"),F=C("el-option"),B=C("el-select"),U=C("el-radio"),Q=C("el-radio-group"),V=C("ProductVariationSelector"),I=C("el-checkbox"),M=C("el-form"),O=C("CopyToClipboard"),L=C("el-date-picker"),H=C("DynamicTemplates"),j=C("Activity");return r(),h("div",vve,[n(c,{isActive:s.changes_made>0?"is-active":"",loading:a.coupon_id?s.updating:s.creating,onSave:t[0]||(t[0]=W=>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})):x("",!0),s.fetchingCoupon?x("",!0):(r(),h(P,{key:1},[o("div",gve,[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})):x("",!0)]),_:1},8,["separator-icon"])]),o("div",yve,[o("div",bve,[o("div",wve,[n(M,{model:s.coupon,"label-position":"top","require-asterisk-position":"right"},{default:d(()=>[n(D,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(w,{label:i.translate("Title"),required:""},{default:d(()=>{var W,G;return[n(y,{modelValue:s.coupon.title,"onUpdate:modelValue":t[1]||(t[1]=Z=>s.coupon.title=Z),placeholder:i.translate("Enter title"),class:de((W=s.validationErrors)!=null&&W.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"])):x("",!0)]}),_:1},8,["label"])]),_:1}),n(k,{lg:12},{default:d(()=>[n(w,null,{default:d(()=>{var W,G;return[o("div",Cve,[n(b,{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]=(...Z)=>i.generateRandomCouponCode&&i.generateRandomCouponCode(...Z))},m(i.translate("Generate Random Code")),1)]),n(y,{modelValue:s.coupon.code,"onUpdate:modelValue":t[3]||(t[3]=Z=>s.coupon.code=Z),placeholder:i.translate("Eg. COUPON10"),class:de((W=s.validationErrors)!=null&&W.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"])):x("",!0),o("div",kve,[o("p",null,m(i.translate("Customers must enter this code at checkout.")),1)])]}),_:1})]),_:1}),n(k,{lg:12},{default:d(()=>[n(w,null,{label:d(()=>[n(b,{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 W,G;return[n(y,{modelValue:s.coupon.priority,"onUpdate:modelValue":t[4]||(t[4]=Z=>s.coupon.priority=Z),type:"number",placeholder:i.translate("Enter priority"),class:de((W=s.validationErrors)!=null&&W.hasOwnProperty("priority")?"is-error":""),min:"0",max:"100",onInput:t[5]||(t[5]=Z=>{i.onChangeCouponInput("priority",Z)}),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"])):x("",!0)]}),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),n(D,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(w,{label:i.translate("Type"),required:""},{default:d(()=>{var W;return[n(B,{modelValue:s.coupon.type,"onUpdate:modelValue":t[6]||(t[6]=G=>s.coupon.type=G),placeholder:i.translate("Select coupon type"),class:de((W=s.validationErrors)!=null&&W.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(P,{key:0},[n(k,{lg:8},{default:d(()=>[n(w,{label:s.coupon.type==="percentage"?i.translate("Discount Percentage (%)"):i.translate("Discount Amount"),required:""},{default:d(()=>{var W;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,Bve)):(r(),h("span",xve,"%"))]),_:1},8,["modelValue","min","max"]),(W=s.validationErrors)!=null&&W.hasOwnProperty("amount")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"amount"},null,8,["validation-errors"])):x("",!0)]}),_:1},8,["label"])]),_:1}),s.coupon.type==="percentage"?(r(),E(k,{key:0,lg:8},{default:d(()=>[n(w,{label:i.translate("Max Discount Amount")},{default:d(()=>{var W;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((W=s.validationErrors)!=null&&W.hasOwnProperty("max_discount_amount")?"is-error":"")},{prefix:d(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,Sve)]),_:1},8,["modelValue","placeholder","class"]),n(v,{"validation-errors":s.validationErrors,"field-key":"max_discount_amount"},null,8,["validation-errors"])]}),_:1},8,["label"])]),_:1})):x("",!0)],64)):x("",!0)]),_:1})]),_:1})]),_:1}),n(D,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(w,null,{label:d(()=>[n(b,{title:i.translate("Min Spend Amount"),content:i.translate("Minimum spend (subtotal) allowed to use the coupon.")},null,8,["title","content"])]),default:d(()=>{var W,G;return[n(y,{modelValue:s.coupon.conditions.min_purchase_amount,"onUpdate:modelValue":t[11]||(t[11]=Z=>s.coupon.conditions.min_purchase_amount=Z),type:"number",placeholder:"0.00",class:de((W=s.validationErrors)!=null&&W.hasOwnProperty("min_purchase_amount")?"is-error":"")},{prefix:d(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,Fve)]),_: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"])):x("",!0)]}),_:1})]),_:1}),n(k,{lg:12},{default:d(()=>[n(w,null,{label:d(()=>[n(b,{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 W,G;return[n(y,{modelValue:s.coupon.conditions.max_purchase_amount,"onUpdate:modelValue":t[12]||(t[12]=Z=>s.coupon.conditions.max_purchase_amount=Z),type:"number",placeholder:i.translate("leave empty or 0 for no max limit"),class:de((W=s.validationErrors)!=null&&W.hasOwnProperty("max_purchase_amount")?"is-error":"")},{prefix:d(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,$ve)]),_: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"])):x("",!0)]}),_:1})]),_:1}),n(k,{lg:24},{default:d(()=>[n(w,null,{label:d(()=>[n(b,{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(Q,{modelValue:s.coupon.conditions.min_amount_basis,"onUpdate:modelValue":t[13]||(t[13]=W=>s.coupon.conditions.min_amount_basis=W)},{default:d(()=>[n(U,{value:"subtotal",label:i.translate("Subtotal (items only)")},null,8,["label"]),n(U,{value:"total",label:i.translate("Total (includes shipping & fees)")},null,8,["label"])]),_:1},8,["modelValue"])]),_:1})]),_:1}),n(k,{md:12},{default:d(()=>[n(w,{label:i.translate("Include Categories")},{default:d(()=>[n(B,{modelValue:s.coupon.conditions.included_categories,"onUpdate:modelValue":t[14]||(t[14]=W=>s.coupon.conditions.included_categories=W),multiple:"",placeholder:i.translate("Any Category"),filterable:"",remote:"","reserve-keyword":!1},{default:d(()=>[(r(!0),h(P,null,te(s.categories,W=>(r(),E(F,{key:W.value,label:W.label,value:W.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),n(k,{md:12},{default:d(()=>[n(w,{label:i.translate("Exclude Categories")},{default:d(()=>[n(B,{modelValue:s.coupon.conditions.excluded_categories,"onUpdate:modelValue":t[15]||(t[15]=W=>s.coupon.conditions.excluded_categories=W),multiple:"",placeholder:i.translate("No Categories"),filterable:"",remote:"","reserve-keyword":!1},{default:d(()=>[(r(!0),h(P,null,te(s.categories,W=>(r(),E(F,{key:W.value,label:W.label,value:W.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),n(k,{md:24},{default:d(()=>[n(w,{label:i.translate("Include Products")},{default:d(()=>[n(V,{modelValue:s.coupon.conditions.included_products,"onUpdate:modelValue":t[16]||(t[16]=W=>s.coupon.conditions.included_products=W)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1}),n(k,{md:24},{default:d(()=>[n(w,{label:i.translate("Excluded Products")},{default:d(()=>[n(V,{modelValue:s.coupon.conditions.excluded_products,"onUpdate:modelValue":t[17]||(t[17]=W=>s.coupon.conditions.excluded_products=W)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1}),n(k,{md:24},{default:d(()=>[n(w,null,{label:d(()=>[n(b,{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 W;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"]),(W=s.validationErrors)!=null&&W.hasOwnProperty("email_restrictions")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"email_restrictions"},null,8,["validation-errors"])):x("",!0)]}),_:1})]),_:1}),n(k,{md:24},{default:d(()=>{var W;return[n(w,null,{label:d(()=>[n(b,{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(I,{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}),(W=s.validationErrors)!=null&&W.hasOwnProperty("is_recurring")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"is_recurring"},null,8,["validation-errors"])):x("",!0)]}),_:1})]),_:1})]),_:1})]),_:1}),n(D,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(w,null,{label:d(()=>[n(b,{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 W,G;return[n(y,{modelValue:s.coupon.conditions.max_uses,"onUpdate:modelValue":t[20]||(t[20]=Z=>s.coupon.conditions.max_uses=Z),type:"number",placeholder:i.translate("Total limit"),class:de((W=s.validationErrors)!=null&&W.hasOwnProperty("max_uses")?"is-error":s.usageError),min:s.minLimit,max:s.maxLimit,onInput:t[21]||(t[21]=Z=>{i.onChangeCouponInput("max_uses",Z)}),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"])):x("",!0)]}),_:1})]),_:1}),n(k,{lg:12},{default:d(()=>[n(w,null,{label:d(()=>[n(b,{title:i.translate("Per Logged in User Limit"),content:i.translate("Maximum an logged in user can use. 0 means unlimited. Only logged in user can use this coupon.")},null,8,["title","content"])]),default:d(()=>[n(y,{modelValue:s.coupon.conditions.max_per_customer,"onUpdate:modelValue":t[22]||(t[22]=W=>s.coupon.conditions.max_per_customer=W),type:"number",placeholder:i.translate("Max limit per logged in user"),class:de(s.validationErrors.hasOwnProperty("max_per_customer")?"is-error":""),min:s.minLimit,max:s.maxLimit,onInput:t[23]||(t[23]=W=>{i.onChangeCouponInput("max_per_customer",W)}),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(D,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(w,{label:i.translate("Status")},{default:d(()=>[n(Q,{modelValue:s.coupon.status,"onUpdate:modelValue":t[24]||(t[24]=W=>s.coupon.status=W)},{default:d(()=>[n(U,{value:"active",label:i.translate("Active")},null,8,["label"]),n(U,{value:"disabled",label:i.translate("Disabled")},null,8,["label"]),n(U,{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(w,{label:i.translate("Internal Notes")},{default:d(()=>{var W;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((W=s.validationErrors)!=null&&W.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 W;return[n(w,null,{label:d(()=>[n(b,{title:i.translate("Stackable"),content:i.translate("Yes means the coupon can be applied with other coupons")},null,8,["title","content"])]),default:d(()=>[n(Q,{modelValue:s.coupon.stackable,"onUpdate:modelValue":t[26]||(t[26]=G=>s.coupon.stackable=G)},{default:d(()=>[n(U,{value:"yes"},{default:d(()=>[R(m(i.translate("Yes")),1)]),_:1}),n(U,{value:"no"},{default:d(()=>[R(m(i.translate("No")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1}),(W=s.validationErrors)!=null&&W.hasOwnProperty("stackable")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"stackable"},null,8,["validation-errors"])):x("",!0)]}),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])]),o("div",Eve,[o("div",Uve,[n(D,null,{default:d(()=>[n(g,{title:i.translate("Summary"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,null,{default:d(()=>[o("div",Ive,[s.coupon.code?(r(),h("div",Qve,[o("span",Dve,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",Vve,m(i.translate("No discount code yet")),1))]),o("div",Tve,[o("h4",Mve,m(i.translate("Type & Method")),1),o("ul",Lve,[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",Rve,[o("h4",Ove,m(i.translate("Details")),1),o("ul",Pve,[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(D,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(M,{"label-position":"top"},{default:d(()=>[n(S,{gutter:20},{default:d(()=>[n(k,{lg:24},{default:d(()=>[n(w,{label:i.translate("Start Date & Time")},{default:d(()=>[n(L,{modelValue:s.coupon.start_date,"onUpdate:modelValue":t[27]||(t[27]=W=>s.coupon.start_date=W),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(w,null,{default:d(()=>[n(I,{modelValue:s.isEndDateEnabled,"onUpdate:modelValue":t[28]||(t[28]=W=>s.isEndDateEnabled=W),label:i.translate("Set end date & time"),onChange:t[29]||(t[29]=W=>{W||(s.coupon.end_date=null)})},null,8,["modelValue","label"])]),_:1})]),_:1}),s.isEndDateEnabled?(r(),E(k,{key:0,lg:24},{default:d(()=>[n(w,{label:i.translate("End Date & Time")},{default:d(()=>[n(L,{modelValue:s.coupon.end_date,"onUpdate:modelValue":t[30]||(t[30]=W=>s.coupon.end_date=W),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"])):x("",!0)]),_:1},8,["label"])]),_:1})):x("",!0)]),_:1})]),_:1})]),_:1})]),_:1})]),s.showDynamicTemplates?(r(),h("div",Hve,[n(H,{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"])])):x("",!0),n(D,null,{default:d(()=>[n(g,{title:i.translate("Activity"),border_bottom:"",title_size:"small"},null,8,["title"]),n($,null,{default:d(()=>[n(j,{onReload:i.fetchCoupon,activities:s.coupon.activities||[],showManageActivity:s.showManageActivity},null,8,["onReload","activities","showManageActivity"])]),_:1})]),_:1})])])])],64))])}const Kve=nt(_ve,[["render",Nve]]),Gve={name:"CheckoutFields",components:{Animation:ya,CardHeader:Ve,Card:Se,CardBody:ke,SettingsHeader:Ua,AdminNotice:Ia},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())}}},zve={class:"setting-wrap"},jve={class:"setting-wrap-inner"},qve={class:"fct-checkout-fields-wrapp"},Yve={class:"field-heading"},Wve={class:"fct-checkout-fields"},Jve={key:0,class:"fct-checkout-field"},Xve={class:"fct-checkout-field-info"},Zve={class:"fct-checkout-field-label-wrap"},ege={class:"fct-checkout-field-tags"},tge={key:0,class:"fct-checkout-field-info-desc"},age={key:0,class:"fct-checkout-field-action"},lge={key:1,class:"fct-checkout-field-input"},sge={class:"fct-checkout-field-info"},nge={class:"fct-checkout-field-label-wrap"},oge={key:1,class:"fct-checkout-field-tags"},ige={key:0,class:"fct-checkout-field-info-desc"},rge={key:0,class:"fct-checkout-field-action"},dge={class:"form-section-save-action"};function uge(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"),w=C("CardBody"),k=C("Card"),b=C("el-button");return r(),h("div",zve,[n(c,{heading:i.translate("Checkout Fields"),loading:s.saving,onOnSave:i.saveFields},null,8,["heading","loading","onOnSave"]),o("div",jve,[n(p),o("div",qve,[n(k,null,{default:d(()=>[n(w,null,{default:d(()=>[n(f,{loading:s.fetching,animated:"",rows:5},null,8,["loading"]),s.fetching?x("",!0):(r(!0),h(P,{key:0},te(s.fields,(S,$)=>(r(),h("div",{key:$,class:"fct-checkout-field-section"},[o("h3",Yve,m(i.formatSectionTitle($)),1),o("div",Wve,[S.label?(r(),h("div",Jve,[o("div",Xve,[o("div",Zve,[S.can_alter==="yes"?(r(),E(_,{key:0,modelValue:s.settings[$].enabled,"onUpdate:modelValue":D=>s.settings[$].enabled=D,"active-value":"yes","inactive-value":"no"},null,8,["modelValue","onUpdate:modelValue"])):x("",!0),o("span",{class:de(`fct-checkout-field-label ${s.settings[$].enabled==="no"?"opacity-50":""}`)},m(S.label),3),o("div",ege,[S.can_alter!=="yes"&&s.settings[$].enabled==="yes"?(r(),E(g,{key:0,size:"small"},{default:d(()=>[R(m(i.translate("System")),1)]),_:1})):x("",!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})):x("",!0)])]),S.help_text?(r(),h("div",tge,m(S.help_text),1)):x("",!0)]),S.can_alter==="yes"?(r(),h("div",age,[n(y,{modelValue:s.settings[$].required,"onUpdate:modelValue":D=>s.settings[$].required=D,"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"])])):x("",!0),s.settings[$].hasOwnProperty("text")&&s.settings[$].enabled==="yes"?(r(),h("div",lge,[n(v,{type:"textarea",modelValue:s.settings[$].text,"onUpdate:modelValue":D=>s.settings[$].text=D,disabled:s.settings[$].enabled!=="yes"},null,8,["modelValue","onUpdate:modelValue","disabled"])])):x("",!0)])):(r(!0),h(P,{key:1},te(S,(D,F)=>(r(),h("div",{key:F,class:"fct-checkout-field"},[o("div",sge,[o("div",nge,[D.can_alter==="yes"?(r(),E(_,{key:0,modelValue:s.settings[$][F].enabled,"onUpdate:modelValue":B=>s.settings[$][F].enabled=B,"active-value":"yes","inactive-value":"no",disabled:i.isFirstNameDisabled($,F)||i.isB2BOnlyModeDisabled($,F)},null,8,["modelValue","onUpdate:modelValue","disabled"])):x("",!0),o("span",{class:de(["fct-checkout-field-label",i.shouldDimLabel($,F)?"opacity-50":""])},m(D.label),3),i.isVisible(D,F)?(r(),h("div",oge,[D.can_alter!=="yes"&&s.settings[$][F].enabled==="yes"?(r(),E(g,{key:0,size:"small"},{default:d(()=>[R(m(i.translate("System")),1)]),_:1})):x("",!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})):x("",!0)])):x("",!0)]),D.help_text?(r(),h("div",ige,m(D.help_text),1)):x("",!0)]),D.can_alter==="yes"&&F!=="first_name"&&F!=="b2b_only_mode"?(r(),h("div",rge,[n(y,{modelValue:s.settings[$][F].required,"onUpdate:modelValue":B=>s.settings[$][F].required=B,"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"])])):x("",!0)]))),128))])]))),128))]),_:1})]),_:1}),o("div",dge,[n(b,{type:"primary",onClick:i.saveFields,loading:s.saving},{default:d(()=>[R(m(i.translate("Save")),1)]),_:1},8,["onClick","loading"])])])])])}const cge=nt(Gve,[["render",uge]]);var Uo={exports:{}};/* @license
Papa Parse
v5.5.3
https://github.com/mholt/PapaParse
License: MIT
*/var Age=Uo.exports,$c;function pge(){return $c||($c=1,function(e,t){((a,l)=>{e.exports=l()})(Age,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(I){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(M){var O=U(M);O.chunkSize=parseInt(O.chunkSize),M.step||M.chunk||(O.chunkSize=null),this._handle=new b(O),(this._handle.streamer=this)._config=O}).call(this,I),this.parseChunk=function(M,O){var L=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0=this._config.preview),c)l.postMessage({results:H,workerId:_.WORKER_ID,finished:L});else if(V(this._config.chunk)&&!O){if(this._config.chunk(H,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=H=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(H.data),this._completeResults.errors=this._completeResults.errors.concat(H.errors),this._completeResults.meta=H.meta),this._completed||!L||!V(this._config.complete)||H&&H.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),L||H&&H.meta.paused||this._nextChunk(),H}this._halted=!0},this._sendError=function(M){V(this._config.error)?this._config.error(M):c&&this._config.error&&l.postMessage({workerId:_.WORKER_ID,error:M,finished:!1})}}function y(I){var M;(I=I||{}).chunkSize||(I.chunkSize=_.RemoteChunkSize),g.call(this,I),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(M=new XMLHttpRequest,this._config.withCredentials&&(M.withCredentials=this._config.withCredentials),i||(M.onload=Q(this._chunkLoaded,this),M.onerror=Q(this._chunkError,this)),M.open(this._config.downloadRequestBody?"POST":"GET",this._input,!i),this._config.downloadRequestHeaders){var O,L=this._config.downloadRequestHeaders;for(O in L)M.setRequestHeader(O,L[O])}var H;this._config.chunkSize&&(H=this._start+this._config.chunkSize-1,M.setRequestHeader("Range","bytes="+this._start+"-"+H));try{M.send(this._config.downloadRequestBody)}catch(j){this._chunkError(j.message)}i&&M.status===0&&this._chunkError()}},this._chunkLoaded=function(){M.readyState===4&&(M.status<200||400<=M.status?this._chunkError():(this._start+=this._config.chunkSize||M.responseText.length,this._finished=!this._config.chunkSize||this._start>=(O=>(O=O.getResponseHeader("Content-Range"))!==null?parseInt(O.substring(O.lastIndexOf("/")+1)):-1)(M),this.parseChunk(M.responseText)))},this._chunkError=function(O){O=M.statusText||O,this._sendError(new Error(O))}}function v(I){(I=I||{}).chunkSize||(I.chunkSize=_.LocalChunkSize),g.call(this,I);var M,O,L=typeof FileReader<"u";this.stream=function(H){this._input=H,O=H.slice||H.webkitSlice||H.mozSlice,L?((M=new FileReader).onload=Q(this._chunkLoaded,this),M.onerror=Q(this._chunkError,this)):M=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(H.target.result)},this._chunkError=function(){this._sendError(M.error)}}function w(I){var M;g.call(this,I=I||{}),this.stream=function(O){return M=O,this._nextChunk()},this._nextChunk=function(){var O,L;if(!this._finished)return O=this._config.chunkSize,M=O?(L=M.substring(0,O),M.substring(O)):(L=M,""),this._finished=!M,this.parseChunk(L)}}function k(I){g.call(this,I=I||{});var M=[],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(H){this._input=H,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){L&&M.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),M.length?this.parseChunk(M.shift()):O=!0},this._streamData=Q(function(H){try{M.push(typeof H=="string"?H:H.toString(this._config.encoding)),O&&(O=!1,this._checkIsFinished(),this.parseChunk(M.shift()))}catch(j){this._streamError(j)}},this),this._streamError=Q(function(H){this._streamCleanUp(),this._sendError(H)},this),this._streamEnd=Q(function(){this._streamCleanUp(),L=!0,this._streamData("")},this),this._streamCleanUp=Q(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function b(I){var M,O,L,H,j=Math.pow(2,53),W=-j,G=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,Z=/^((\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,ce=0,z=0,ue=!1,ie=!1,J=[],N={data:[],errors:[],meta:{}};function ae(Ee){return I.skipEmptyLines==="greedy"?Ee.join("").trim()==="":Ee.length===1&&Ee[0].length===0}function oe(){if(N&&L&&(re("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+_.DefaultDelimiter+"'"),L=!1),I.skipEmptyLines&&(N.data=N.data.filter(function(ve){return!ae(ve)})),fe()){let ve=function(Ue,Ke){V(I.transformHeader)&&(Ue=I.transformHeader(Ue,Ke)),J.push(Ue)};if(N)if(Array.isArray(N.data[0])){for(var Ee=0;fe()&&Ee(yt=>(I.dynamicTypingFunction&&I.dynamicTyping[yt]===void 0&&(I.dynamicTyping[yt]=I.dynamicTypingFunction(yt)),(I.dynamicTyping[yt]||I.dynamicTyping)===!0))(He)?Re==="true"||Re==="TRUE"||Re!=="false"&&Re!=="FALSE"&&((yt=>{if(G.test(yt)&&(yt=parseFloat(yt),W=J.length?"__parsed_extra":J[We]:Be,$e=I.transform?I.transform($e,Be):$e);Be==="__parsed_extra"?(Ke[Be]=Ke[Be]||[],Ke[Be].push($e)):Ke[Be]=$e}return I.header&&(We>J.length?re("FieldMismatch","TooManyFields","Too many fields: expected "+J.length+" fields but parsed "+We,z+Ue):WeI.preview?O.abort():(N.data=N.data[0],H(N,ne))))}),this.parse=function(Ee,ye,Ce){var ve=I.quoteChar||'"',ve=(I.newline||(I.newline=this.guessLineEndings(Ee,ve)),L=!1,I.delimiter?V(I.delimiter)&&(I.delimiter=I.delimiter(Ee),N.meta.delimiter=I.delimiter):((ve=((Ue,Ke,We,Be,$e)=>{var He,Re,yt,gt;$e=$e||[","," ","|",";",_.RECORD_SEP,_.UNIT_SEP];for(var Rt=0;Rt<$e.length;Rt++){for(var Tt,Dt=$e[Rt],_t=0,Gt=0,bt=0,St=(yt=void 0,new $({comments:Be,delimiter:Dt,newline:Ke,preview:10}).parse(Ue)),Pt=0;Pt=Ce.length/2?`\r
`:"\r"}}function S(I){return I.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $(I){var M=(I=I||{}).delimiter,O=I.newline,L=I.comments,H=I.step,j=I.preview,W=I.fastMode,G=null,Z=!1,ne=I.quoteChar==null?'"':I.quoteChar,ce=ne;if(I.escapeChar!==void 0&&(ce=I.escapeChar),(typeof M!="string"||-1<_.BAD_DELIMITERS.indexOf(M))&&(M=","),L===M)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 z=0,ue=!1;this.parse=function(ie,J,N){if(typeof ie!="string")throw new Error("Input must be a string");var ae=ie.length,oe=M.length,fe=O.length,re=L.length,Ee=V(H),ye=[],Ce=[],ve=[],Ue=z=0;if(!ie)return _t();if(W||W!==!1&&ie.indexOf(ne)===-1){for(var Ke=ie.split(O),We=0;We=j)return _t(!0);break}Ce.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:ye.length,index:z}),Re++}}else if(L&&ve.length===0&&ie.substring(z,z+re)===L){if($e===-1)return _t();z=$e+fe,$e=ie.indexOf(O,z),Be=ie.indexOf(M,z)}else if(Be!==-1&&(Be<$e||$e===-1))ve.push(ie.substring(z,Be)),z=Be+oe,Be=ie.indexOf(M,z);else{if($e===-1)break;if(ve.push(ie.substring(z,$e)),Dt($e+fe),Ee&&(Gt(),ue))return _t();if(j&&ye.length>=j)return _t(!0)}return Tt();function gt(bt){ye.push(bt),Ue=z}function Rt(bt){var St=0;return St=bt!==-1&&(bt=ie.substring(Re+1,bt))&&bt.trim()===""?bt.length:St}function Tt(bt){return N||(bt===void 0&&(bt=ie.substring(z)),ve.push(bt),z=ae,gt(ve),Ee&&Gt()),_t()}function Dt(bt){z=bt,gt(ve),ve=[],$e=ie.indexOf(O,z)}function _t(bt){if(I.header&&!J&&ye.length&&!Z){var St=ye[0],Pt=Object.create(null),Ht=new Set(St);let Qt=!1;for(let ht=0;htL.charCodeAt(0)!==65279?L:L.slice(1))(I),O=new(M.download?y:w)(M)):I.readable===!0&&V(I.read)&&V(I.on)?O=new k(M):(l.File&&I instanceof File||I instanceof Object)&&(O=new v(M)),O.stream(I);(O=(()=>{var L;return!!_.WORKERS_SUPPORTED&&(L=(()=>{var H=l.URL||l.webkitURL||null,j=a.toString();return _.BLOB_URL||(_.BLOB_URL=H.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; ","(",j,")();"],{type:"text/javascript"})))})(),(L=new l.Worker(L)).onmessage=D,L.id=f++,p[L.id]=L)})()).userStep=M.step,O.userChunk=M.chunk,O.userComplete=M.complete,O.userError=M.error,M.step=V(M.step),M.chunk=V(M.chunk),M.complete=V(M.complete),M.error=V(M.error),delete M.worker,O.postMessage({input:I,config:M,workerId:O.id})},_.unparse=function(I,M){var O=!1,L=!0,H=",",j=`\r
`,W='"',G=W+W,Z=!1,ne=null,ce=!1,z=((()=>{if(typeof M=="object"){if(typeof M.delimiter!="string"||_.BAD_DELIMITERS.filter(function(J){return M.delimiter.indexOf(J)!==-1}).length||(H=M.delimiter),typeof M.quotes!="boolean"&&typeof M.quotes!="function"&&!Array.isArray(M.quotes)||(O=M.quotes),typeof M.skipEmptyLines!="boolean"&&typeof M.skipEmptyLines!="string"||(Z=M.skipEmptyLines),typeof M.newline=="string"&&(j=M.newline),typeof M.quoteChar=="string"&&(W=M.quoteChar),typeof M.header=="boolean"&&(L=M.header),Array.isArray(M.columns)){if(M.columns.length===0)throw new Error("Option columns is empty");ne=M.columns}M.escapeChar!==void 0&&(G=M.escapeChar+W),M.escapeFormulae instanceof RegExp?ce=M.escapeFormulae:typeof M.escapeFormulae=="boolean"&&M.escapeFormulae&&(ce=/^[=+\-@\t\r].*$/)}})(),new RegExp(S(W),"g"));if(typeof I=="string"&&(I=JSON.parse(I)),Array.isArray(I)){if(!I.length||Array.isArray(I[0]))return ue(null,I,Z);if(typeof I[0]=="object")return ue(ne||Object.keys(I[0]),I,Z)}else if(typeof I=="object")return typeof I.data=="string"&&(I.data=JSON.parse(I.data)),Array.isArray(I.data)&&(I.fields||(I.fields=I.meta&&I.meta.fields||ne),I.fields||(I.fields=Array.isArray(I.data[0])?I.fields:typeof I.data[0]=="object"?Object.keys(I.data[0]):[]),Array.isArray(I.data[0])||typeof I.data[0]=="object"||(I.data=[I.data])),ue(I.fields||[],I.data||[],Z);throw new Error("Unable to serialize unrecognized input");function ue(J,N,ae){var oe="",fe=(typeof J=="string"&&(J=JSON.parse(J)),typeof N=="string"&&(N=JSON.parse(N)),Array.isArray(J)&&0{for(var Ee=0;EezL(G,k.thousand),S=G=>{G&&Ec.parse(G,{header:!0,complete:function(Z){p.value=Z.data,c.value=Z.meta.fields,g.value=c.value.includes("Type")&&c.value.includes("Parent"),D(),g.value&&U(),w.value=!0}})},$=()=>{_.value={},c.value=[],p.value=[],w.value=!1,g.value=!1},D=()=>{const G=[],Z=[];let ne=0;c.value.forEach(ce=>{let z=null,ue=null;const ie=ce.toString();for(const[J,N]of y.entries())if(ie.toLocaleLowerCase().startsWith(N)){const ae=ce.toString().match(/ \d+ /g);if(Array.isArray(ae)&&ae.length===1){let oe=ae[0];ne=oe>ne?oe:ne,z=ce.toString().replace(ae[0]," %d "),ue=ce.toString().replace(ae[0]," ");break}}z!=null?G.includes(z)||(G.push(z),Z.push({title:ue,value:z})):Z.push({title:ce,value:ce})}),_.value=Z,v=ne},F=()=>window.fluentCartRestVars.rest.url+"/files/upload",B={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"]},U=()=>{for(const[G,Z]of Object.entries(B))if(f.value[G]){for(const ne of Z)if(c.value.includes(ne)){f.value[G].value=ne;break}}},Q=G=>G?{day:"daily",week:"weekly",month:"monthly",year:"yearly"}[G.trim().toLowerCase()]||G:"",V=G=>{if(!G)return"";const Z=G.split(",").map(ne=>ne.trim().toLowerCase());return Z.includes("variation")?"variation":Z.includes("variable")?"variable":Z.includes("subscription")?"subscription":Z.includes("simple")?"simple":Z[0]||""},I=(G=!0)=>{const Z=[],ne={},ce=f.value,z={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"},ue=J=>{const N=[];for(let ae=1;ae<=10;ae++){const oe=`Attribute ${ae} name`,fe=`Attribute ${ae} value(s)`;J[oe]&&J[fe]&&N.push(J[fe])}return N.join(" - ")},ie=J=>J==="1"||J===1?"published":J==="0"||J===0?"draft":J||"published";p.value.forEach(J=>{var Ce,ve,Ue,Ke,We,Be,$e,He,Re,yt,gt,Rt,Tt,Dt,_t,Gt,bt,St,Pt,Ht;const N=V(J.Type);if(N!=="simple"&&N!=="variable"&&N!=="subscription")return;const ae={};ae._cid=ml(),ae.post_title=J[(Ce=ce.post_title)==null?void 0:Ce.value]||"",ae.post_name=J[(ve=ce.post_name)==null?void 0:ve.value]||ae.post_title,ae.ID=J[(Ue=ce.post_id)==null?void 0:Ue.value]||"",ae.post_content=J[(Ke=ce.post_content)==null?void 0:Ke.value]||"",ae.post_excerpt=J[(We=ce.post_excerpt)==null?void 0:We.value]||"",ae.post_status=ie(J[(Be=ce.post_status)==null?void 0:Be.value]);const oe={variation_type:N==="variable"?"simple_variations":"simple",manage_stock:"0",fulfillment_type:"physical"},fe=J[($e=ce.images)==null?void 0:$e.value]||"",re=[];fe&&fe.split(",").map(Qt=>Qt.trim()).filter(Boolean).forEach(Qt=>{const ht=Qt.split("/").pop().split("?")[0]||"image";re.push({id:0,url:Qt,title:ht})}),ae.detail=oe,ae.gallery=re,ae.variants=[];const Ee=J[(He=ce.categories)==null?void 0:He.value]||"";if(Ee?ae.categories=Ee.split(",").map(Qt=>Qt.trim()).filter(Boolean):ae.categories=[],N==="simple"||N==="subscription"){const Qt=b(J[(Re=ce.item_price)==null?void 0:Re.value]||""),ht=b(J[(yt=ce.compare_price)==null?void 0:yt.value]||""),qt=J[(gt=ce.sku)==null?void 0:gt.value]||"",ge=N==="subscription"?"subscription":J[(Rt=ce.payment_type)==null?void 0:Rt.value]||"onetime",Fe=Q(J[(Tt=ce.repeat_interval)==null?void 0:Tt.value]||""),ot=J[(Dt=ce.trial_days)==null?void 0:Dt.value]||"",wt=J[(_t=ce.installment)==null?void 0:_t.value]||"",kt=J[(Gt=ce.installment_count)==null?void 0:Gt.value]||"",Xt=J[(bt=ce.manage_setup_fee)==null?void 0:bt.value]||"",vt=J[(St=ce.signup_fee_name)==null?void 0:St.value]||"",ea=b(J[(Pt=ce.signup_fee)==null?void 0:Pt.value]||"");(Qt||ae.post_title)&&ae.variants.push({_cid:ml(),variation_title:ae.post_title,sku:qt,item_price:Qt,compare_price:ht,other_info:{...z,payment_type:ge,repeat_interval:Fe,trial_days:ot,installment:wt==="yes"?"yes":"no",times:kt,manage_setup_fee:Xt==="yes"?"yes":"no",signup_fee_name:vt,signup_fee:ea},media:[]})}const ye=J[(Ht=ce.sku)==null?void 0:Ht.value]||"";N==="variable"&&ye&&(ne[ye]=ae),Z.push(ae)}),p.value.forEach(J=>{var yt,gt,Rt,Tt,Dt,_t,Gt,bt,St,Pt,Ht,Qt;if(V(J.Type)!=="variation")return;const N=J.Parent;if(!N||!ne[N])return;const ae=ue(J),oe=b(J[(yt=ce.item_price)==null?void 0:yt.value]||""),fe=b(J[(gt=ce.compare_price)==null?void 0:gt.value]||""),re=J[(Rt=ce.images)==null?void 0:Rt.value]||"",Ee=[];re&&re.split(",").map(ht=>ht.trim()).filter(Boolean).forEach(ht=>{const qt=ht.split("/").pop().split("?")[0]||"image";Ee.push({id:0,url:ht,title:qt})});const ye=J[(Tt=ce.sku)==null?void 0:Tt.value]||"",Ce=J[(Dt=ce.payment_type)==null?void 0:Dt.value]||"onetime",ve=Q(J[(_t=ce.repeat_interval)==null?void 0:_t.value]||""),Ue=J[(Gt=ce.trial_days)==null?void 0:Gt.value]||"",Ke=J[(bt=ce.installment)==null?void 0:bt.value]||"",We=J[(St=ce.installment_count)==null?void 0:St.value]||"",Be=J[(Pt=ce.manage_setup_fee)==null?void 0:Pt.value]||"",$e=J[(Ht=ce.signup_fee_name)==null?void 0:Ht.value]||"",He=b(J[(Qt=ce.signup_fee)==null?void 0:Qt.value]||""),Re={_cid:ml(),variation_title:ae||J.Name||"",sku:ye,item_price:oe,compare_price:fe,other_info:{...z,payment_type:Ce,repeat_interval:ve,trial_days:Ue,installment:Ke==="yes"?"yes":"no",times:We,manage_setup_fee:Be==="yes"?"yes":"no",signup_fee_name:$e,signup_fee:He},media:Ee};ne[N].variants.push(Re)}),W("onDataPopulated",{products:Z,concat:G})},M=(G=!0)=>{if(g.value)return I(G);const Z=[];p.value.forEach(ne=>{var We,Be,$e,He,Re,yt,gt,Rt,Tt,Dt,_t,Gt;const ce={};ce._cid=ml();const z=f.value;ce.post_title=ne[z.post_title.value]??"",ce.post_name=ne[z.post_name.value]??ce.post_title,ce.ID=ne[z.post_id.value]??"",ce.post_content=ne[z.post_content.value]??"",ce.post_excerpt=ne[z.post_excerpt.value]??"",ce.post_status=ne[(We=z.post_status)==null?void 0:We.value]||"published",ce.comment_status="close";const ue=ne[(Be=z.images)==null?void 0:Be.value]||"",ie=[];ue&&ue.split(",").map(bt=>bt.trim()).filter(Boolean).forEach(bt=>{const St=bt.split("/").pop().split("?")[0]||"image";ie.push({id:0,url:bt,title:St})});const J=ne[($e=z.categories)==null?void 0:$e.value]||"";J?ce.categories=J.split(",").map(bt=>bt.trim()).filter(Boolean):ce.categories=[];const N=ne[(He=z.sku)==null?void 0:He.value]||"",ae=ne[(Re=z.payment_type)==null?void 0:Re.value]||"onetime",oe=ne[(yt=z.repeat_interval)==null?void 0:yt.value]||"",fe=ne[(gt=z.trial_days)==null?void 0:gt.value]||"",re=ne[(Rt=z.installment)==null?void 0:Rt.value]||"",Ee=ne[(Tt=z.installment_count)==null?void 0:Tt.value]||"",ye=ne[(Dt=z.manage_setup_fee)==null?void 0:Dt.value]||"",Ce=ne[(_t=z.signup_fee_name)==null?void 0:_t.value]||"",ve=b(ne[(Gt=z.signup_fee)==null?void 0:Gt.value]||""),Ue={variation_type:"simple",manage_stock:"0",fulfillment_type:"physical"},Ke={description:"",payment_type:ae,times:Ee,repeat_interval:oe,trial_days:fe,billing_summary:"",manage_setup_fee:ye==="yes"?"yes":"no",signup_fee_name:Ce,signup_fee:ve,setup_fee_per_item:"no",installment:re==="yes"?"yes":"no"};ce.gallery=ie,ce.variants=[];for(let bt=1;bt<=v;bt++){const St={};["variation_title","item_price","compare_price"].forEach(Pt=>{var Qt;const Ht=((Qt=z[Pt])==null?void 0:Qt.value)??"";if(Ht.length>0){const ht=Ht.replace("%d",bt.toString()),qt=ne[ht];St[Pt]=Pt==="variation_title"?qt:b(qt)}}),H(St)&&(St._cid=ml(),St.sku=N,St.other_info={...Ke},St.media=[],ce.variants.push(St))}ce.variants.length>0?(Ue.variation_type="simple_variations",ce.detail=Ue,Z.push(ce)):H(ce)&&(ce.variants.push({_cid:ml(),variation_title:"",sku:N,item_price:0,compare_price:0,other_info:{...Ke},media:[]}),ce.detail=Ue,Z.push(ce))}),W("onDataPopulated",{products:Z,concat:G})},O=()=>{l.value=!1,s.value=[],i.value=null,$()},L=(G=!0)=>{M(G),O()},H=G=>{let Z=!1;for(const[ne,ce]of Object.entries(G))if(typeof ce!==null&&typeof ce<"u"&&(Array.isArray(ce)&&ce.length>0||ce.toString().length>0)){Z=!0;break}return Z};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 j=()=>{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":""}],Z=Ec.unparse(G),ne=new Blob([Z],{type:"text/csv;charset=utf-8;"}),ce=URL.createObjectURL(ne),z=document.createElement("a");z.href=ce,z.download="fluent-cart-sample-import.csv",document.body.appendChild(z),z.click(),document.body.removeChild(z),URL.revokeObjectURL(ce)},W=t;return(G,Z)=>{const ne=C("el-button"),ce=C("el-upload"),z=C("el-option"),ue=C("el-select"),ie=C("el-dialog");return r(),h(P,null,[n(ne,{onClick:Z[0]||(Z[0]=J=>l.value=!0)},{default:d(()=>[R(m(G.$t("Import")),1)]),_:1}),n(ie,{modelValue:l.value,"onUpdate:modelValue":Z[4]||(Z[4]=J=>l.value=J),"append-to-body":!0,title:G.$t("Import Products"),class:"fct-bulk-import-dialog"},{default:d(()=>[w.value?x("",!0):(r(),E(ce,{key:0,class:"fct-file-uploader",ref:"uploaderRef","file-list":s.value,"onUpdate:fileList":Z[1]||(Z[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(at,{circle:"",bg:"primary",soft:""},{default:d(()=>[n(Y,{name:"Upload"})]),_:1}),o("div",mge,[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(Vt).serverMaxUploadSize())),1)])]),_:1},8,["file-list","action","on-change"])),w.value?x("",!0):(r(),E(ne,{key:1,onClick:j,link:""},{default:d(()=>[n(Y,{name:"Download"}),R(" "+m(G.$t("Download a Sample CSV File")),1)]),_:1})),w.value?(r(),h(P,{key:2},[o("div",hge,[o("h4",_ge,m(G.$t("Map Columns")),1),o("table",vge,[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(P,null,te(f.value,(J,N)=>(r(),h("tr",null,[o("td",null,m(J.title),1),o("td",gge,[n(ue,{modelValue:J.value,"onUpdate:modelValue":ae=>J.value=ae,filterable:"",clearable:""},{default:d(()=>[(r(!0),h(P,null,te(_.value,ae=>(r(),E(z,{key:ae.value,label:ae.title,value:ae.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])])]))),256))])])]),o("div",yge,[n(ne,{onClick:Z[2]||(Z[2]=J=>L())},{default:d(()=>[R(m(G.$t("Add Products")),1)]),_:1}),n(ne,{onClick:Z[3]||(Z[3]=J=>L(!1))},{default:d(()=>[R(m(G.$t("Clear and Add Products")),1)]),_:1})])],64)):x("",!0)]),_:1},8,["modelValue","title"])],64)}}};class wge extends Dd{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=ml(),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){q.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 Ae.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(w=>w._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 w of _)this.data.productErrors.set(w,{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?q.success(`${c.length} product(s) created successfully`):c.length>0?q.info(`${c.length} product(s) created, ${p.length} error(s)`):q.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 Ae.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";q.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=ml(),a.post_title=a.post_title?a.post_title+" (Copy)":"",a.variants&&Array.isArray(a.variants)&&a.variants.forEach(s=>{s.sku="",s._cid=ml()});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=ml(),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=ml()})}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=ml(),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 Ae.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=wge.init(),Cge={class:"max-w-full overflow-x-scroll"},kge={class:"relative"},Bge={key:0,class:"bulk-checkbox-cell"},xge=["onMousedown","onTouchstart"],Bf={__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=Xf(),s=td("table"),i=T(null);let c=null;Ie(()=>{xe(()=>{const g=s.value.querySelectorAll("th"),y=l["header-first"]?1:0;Array.from(g).forEach((v,w)=>{const k=w-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)})}),cl(()=>{c&&c.disconnect()});const p=e,f=K(()=>{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,w=p.columns[y].width,k=p.columns[y].minWidth||50;i.value=y;const b=$=>{const D=w+($.clientX-v);D>=k&&(p.columns[y].width=D)},S=()=>{i.value=null,document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",S),a("resize-end")};document.addEventListener("mousemove",b),document.addEventListener("mouseup",S)};return(g,y)=>(r(),h("div",Cge,[o("div",{class:de(["resizable-table",{"is-resizing":i.value!==null}]),onScroll:y[0]||(y[0]=v=>a("scroll",v))},[o("div",kge,[o("table",{id:"tb",ref_key:"table",ref:s,style:ra({tableLayout:"fixed",width:f.value+"px"})},[o("thead",null,[o("tr",null,[g.$slots["header-first"]?(r(),h("th",Bge,[ga(g.$slots,"header-first")])):x("",!0),(r(!0),h(P,null,te(e.columns,(v,w)=>(r(),h("th",{class:de({"sticky-col":w===0,"sticky-col sticky-col-right":w===e.columns.length-1&&e.stickyLast}),style:ra({width:v.width+"px",zIndex:w===0||w===e.columns.length-1&&e.stickyLast?70:e.columns.length-w+50,left:w===0&&g.$slots["header-first"]?"40px":w===0?"0px":void 0}),key:v.key||w},[w===e.columns.length-1?ga(g.$slots,"header-last",{key:0},()=>[R(m(v.title),1)]):(r(),h(P,{key:1},[R(m(v.title),1)],64)),w_(k,w),onTouchstart:k=>_(k,w)},null,42,xge)):x("",!0)],6))),128))])]),o("tbody",null,[ga(g.$slots,"default")])],4)])],34)]))}},Sge={class:"bulk-setup-fee-badge"},Fge={key:1,class:"text-gray-300 text-sm flex justify-center"},Xo={__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(Za,{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(Kt)(e.variant.other_info.signup_fee,!0),placement:"top","popper-class":"fct-tooltip"},{default:d(()=>[o("span",Sge,"+ "+m(l.$t("fee")),1)]),_:1},8,["content"])]),key:"0"}:void 0]),1032,["error-class","model-value","placeholder","disabled"])):(r(),h("span",Fge,"—"))}}},$ge=["disabled"],Ege={key:0,class:"fct-bulk-sub-count"},Uge={class:"fct-bulk-sub-popover-body"},Ige={class:"fct-bulk-sub-popover-title"},Qge={class:"fct-bulk-sub-section"},Dge={class:"fct-bulk-sub-row"},Vge={class:"fct-bulk-sub-row"},Tge={class:"fct-bulk-sub-label"},Mge={class:"fct-bulk-sub-row"},Lge={class:"fct-bulk-sub-label"},Rge=["innerHTML"],Oge={class:"fct-bulk-sub-section"},Pge={class:"fct-bulk-sub-row"},Hge={class:"fct-bulk-sub-row"},Nge={class:"fct-bulk-sub-label"},Kge={class:"fct-bulk-sub-row"},Gge={class:"fct-bulk-sub-label"},zge={class:"fct-bulk-sub-footer"},dr=2,jge={__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=Jt().ctx,i=ze.get(),c=ze.get("app_config.isProActive"),p=T(!1);K(()=>{var F;return((F=i==null?void 0:i.shop)==null?void 0:F.currency_sign)||"$"});const f=K(()=>{var F;return((F=a.variant)==null?void 0:F.other_info)||{}}),_=K(()=>f.value.payment_type==="subscription"),g=K(()=>f.value.installment==="yes"),y=K(()=>Number(f.value.times)||1),v=K(()=>{var B;const F=Number((B=a.variant)==null?void 0:B.item_price)||0;return g.value?F*y.value:F}),w=K(()=>{const F=[];if(g.value&&F.push(s.$t("Installment")+": "+y.value+"x"),f.value.manage_setup_fee==="yes"){const B=f.value.signup_fee_name||s.$t("Setup fee"),U=f.value.signup_fee||0;F.push(s.$t("Setup fee")+": "+B+" ("+Kt(U,!0)+")")}return F.length>0?F.join(`
`):s.$t("Subscription settings")}),k=F=>{F==="no"?a.variant.other_info.times="":b(),l("changed")},b=()=>{const F=Number(a.variant.other_info.times);(!Number.isFinite(F)||F{F==="no"&&(a.variant.other_info.signup_fee=""),l("changed")},$=()=>{l("changed")},D=()=>{p.value=!1};return(F,B)=>{const U=C("el-checkbox"),Q=C("el-tooltip"),V=C("el-input"),I=C("el-switch"),M=C("el-button"),O=C("el-popover");return r(),E(Q,{content:w.value,placement:"top",disabled:!_.value||p.value,"popper-class":"fct-tooltip","show-after":400},{default:d(()=>[n(O,{visible:p.value,"onUpdate:visible":B[6]||(B[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:B[0]||(B[0]=Ge(()=>{},["prevent"]))},[B[7]||(B[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",Ege,m(y.value),1)):x("",!0)],10,$ge)]),default:d(()=>[o("div",Uge,[o("h4",Ige,m(F.$t("Subscription Settings")),1),o("div",Qge,[o("div",Dge,[n(U,{"true-value":"yes","false-value":"no",label:F.$t("Enable installment payment"),modelValue:e.variant.other_info.installment,"onUpdate:modelValue":B[1]||(B[1]=L=>e.variant.other_info.installment=L),disabled:!A(c)||e.disabled,onChange:k},null,8,["label","modelValue","disabled"]),A(c)?x("",!0):(r(),E(Q,{key:0,"popper-class":"fct-tooltip"},{content:d(()=>[R(m(F.$t("This feature is available in pro version only.")),1)]),default:d(()=>[n(Y,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),f.value.installment==="yes"?(r(),h(P,{key:0},[o("div",Vge,[o("label",Tge,m(F.$t("Installment Count")),1),n(V,{type:"number",min:dr,size:"small",modelValue:e.variant.other_info.times,"onUpdate:modelValue":B[2]||(B[2]=L=>e.variant.other_info.times=L),modelModifiers:{number:!0},placeholder:F.$t("Count"),style:{width:"100px"},onInput:$,onChange:b},null,8,["modelValue","placeholder"])]),o("div",Mge,[o("span",Lge,m(F.$t("Total Price")),1),o("span",{class:"fct-bulk-sub-value",innerHTML:A(Kt)(v.value,!0)},null,8,Rge)])],64)):x("",!0)]),o("div",Oge,[o("div",Pge,[n(I,{"active-text":F.$t("Setup fee"),modelValue:e.variant.other_info.manage_setup_fee,"onUpdate:modelValue":B[3]||(B[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)?x("",!0):(r(),E(Q,{key:0,"popper-class":"fct-tooltip"},{content:d(()=>[R(m(F.$t("This feature is available in pro version only.")),1)]),default:d(()=>[n(Y,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),f.value.manage_setup_fee==="yes"?(r(),h(P,{key:0},[o("div",Hge,[o("label",Nge,m(F.$t("Label")),1),n(V,{size:"small",modelValue:e.variant.other_info.signup_fee_name,"onUpdate:modelValue":B[4]||(B[4]=L=>e.variant.other_info.signup_fee_name=L),placeholder:F.$t("e.g. Initial Setup"),onInput:$},null,8,["modelValue","placeholder"])]),o("div",Kge,[o("label",Gge,m(F.$t("Amount")),1),n(Za,{size:"small","model-value":e.variant.other_info.signup_fee,placeholder:F.$t("Amount"),"onUpdate:modelValue":B[5]||(B[5]=L=>{e.variant.other_info.signup_fee=L,$()})},null,8,["model-value","placeholder"])])],64)):x("",!0)]),o("div",zge,[n(M,{size:"small",type:"primary",onClick:D},{default:d(()=>[R(m(F.$t("Done")),1)]),_:1})])])]),_:1},8,["visible","disabled"])]),_:1},8,["content","disabled"])}}},qge={key:0,class:"flex items-center"},Yge={key:1,class:"text-gray-300 text-sm flex justify-center"},Zo={__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",qge,[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(jge,{variant:e.variant,disabled:e.disabled,onChanged:c[2]||(c[2]=_=>l("change"))},null,8,["variant","disabled"])])):(r(),h("span",Yge,"—"))}}},Wge={key:1,class:"text-gray-300 text-sm flex justify-center"},ei={__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",Wge,"—"))}}},Jge={key:1,class:"text-gray-300 text-sm flex justify-center"},ti={__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",Jge,"—"))}}},Xge={key:1,class:"text-gray-300 text-sm flex justify-center"},ai={__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(Za,{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",Xge,"—"))}},xf={__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(P,null,te(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"])}}},Zge=["textContent"],eye={key:1,class:"fct-bulk-editor-placeholder"},li={__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,Zge)):(r(),h("span",eye,m(e.placeholder),1))]))}};function Sf(){const e=T(new Set),t=T(null),a=T(!1),l=(y,v,w)=>{if(v.shiftKey&&t.value!==null){const b=w.indexOf(t.value),S=w.indexOf(y);if(b!==-1&&S!==-1){const $=Math.min(b,S),D=Math.max(b,S),F=new Set(e.value);for(let B=$;B<=D;B++)F.add(w[B]);e.value=F}}else{const b=new Set(e.value);b.has(y)?b.delete(y):b.add(y),e.value=b,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),_=K(()=>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 w=!1;const k=new Set;for(const b of e.value)v.has(b)?k.add(b):w=!0;w&&(e.value=k),t.value&&!v.has(t.value)&&(t.value=null)}}}const tye={mounted(e,t){e.indeterminate=!!t.value},updated(e,t){e.indeterminate=!!t.value}},Ff={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]}}},aye={...Ff,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}}},lye={...Ff,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 $f(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 sye={class:"fct-bulk-insert-page fct-layout-width"},nye={class:"fct-btn-group sm justify-end"},oye={class:"filter-popover-item"},iye={class:"filter-popover-title"},rye={key:0,"aria-hidden":"true"},dye=["colspan"],uye=["onClick"],cye=["onClick"],Aye={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},pye={class:"flex items-center"},fye=["onClick","title"],mye={key:0,class:"bulk-collapse-count"},hye=["title"],_ye=["title"],vye={class:"bulk-status-icon is-error"},gye={key:0,class:"fct-bulk-sku-cell"},yye={key:1,class:"text-gray-300 text-sm flex justify-center"},bye={key:1,class:"fct-bulk-media-cell"},wye={key:2,class:"fct-bulk-categories-cell"},Cye={key:3,class:"fct-bulk-desc-cell"},kye={key:4,class:"fct-bulk-short-desc-cell"},Bye={key:5,class:"fct-bulk-status-cell"},xye={key:6,class:"fct-bulk-product-type-cell"},Sye={key:7,class:"fct-bulk-product-type-cell"},Fye={key:8,class:"fct-bulk-pricing-type-cell"},$ye={key:9,class:"fct-bulk-pricing-type-cell"},Eye={key:10,class:"fct-bulk-payment-type-cell"},Uye={key:11,class:"fct-bulk-interval-cell"},Iye={key:12,class:"fct-bulk-trial-days-cell"},Qye={key:13,class:"fct-bulk-best-price-cell"},Dye={key:14,class:"fct-bulk-compare-price-cell"},Vye={key:15,class:"fct-bulk-qty-cell !pl-5"},Tye={key:16,class:"fct-bulk-stock-cell"},Mye={key:1,class:"text-gray-300 text-sm pl-5"},Lye={class:"fct-btn-group xs justify-end"},Rye=["href","title"],Oye={key:0,class:"bulk-variants-block-row"},Pye=["colspan"],Hye={class:"bulk-inner-table",style:{tableLayout:"fixed",width:"100%",borderCollapse:"collapse"}},Nye=["onClick"],Kye={class:"bulk-checkbox-cell"},Gye={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},zye={class:"flex items-center gap-1 pl-4"},jye={class:"bulk-status-icon is-error"},qye={key:0,class:"fct-bulk-sku-cell"},Yye={key:1,class:"fct-bulk-media-cell"},Wye={key:2},Jye={key:3},Xye={key:4},Zye={key:5},e1e={key:6},t1e={key:7},a1e={key:8},l1e={key:9},s1e={key:10},n1e={key:11},o1e={key:12},i1e={key:13,class:"text-center"},r1e={key:14},d1e={key:1,class:"text-gray-300 text-sm flex justify-center"},u1e={class:"fct-btn-group sm justify-end"},c1e={class:"bulk-add-variant-row"},A1e=["colspan"],p1e={class:"sticky left-0 inline-block pl-6"},f1e={key:1,"aria-hidden":"true"},m1e=["colspan"],ur=43,h1e=10,_1e=800,Uc=100,v1e={__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=K(()=>Ft.data.saving),i=K(()=>Ft.data.saveProgress),c=K(()=>{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),w=ge=>Ft.hasProductLevelError(ge._cid),k=(ge,Fe)=>Ft.hasVariantError(ge._cid,Fe),b=(ge,Fe)=>Ft.getVariantError(ge._cid,Fe),S=(ge,Fe)=>Ft.hasFieldError(ge._cid,Fe),$=(ge,Fe,ot)=>Ft.hasVariantFieldError(ge._cid,Fe,ot),D=async ge=>{const Fe=ge.post_title||H.$t("Untitled product"),ot=Array.isArray(ge.variants)?ge.variants.length:0,wt=Ft.isSaved(ge._cid);let kt=ot>0?H.$t('This will remove "%1$s" and its %2$s variant(s).',Fe,ot):H.$t('This will remove "%1$s".',Fe);wt&&(kt+=" "+H.$t("This product was already saved and will be permanently deleted."));try{await Fl.confirm(kt,H.$t("Remove Product"),{confirmButtonText:H.$t("Remove"),cancelButtonText:H.$t("Cancel"),type:"warning"})}catch{return}await Ft.removeProduct(ge)},F=(ge,Fe)=>{const ot=Fe.variation_title||H.$t("Untitled variant");Fl.confirm(H.$t('This will remove the variant "%1$s".',ot),H.$t("Remove Variant"),{confirmButtonText:H.$t("Remove"),cancelButtonText:H.$t("Cancel"),confirmButtonClass:"el-button--small",cancelButtonClass:"el-button--small",type:"warning"}).then(()=>{Ft.removeVariant(ge,Fe)}).catch(()=>{})},B=ge=>Ft.duplicateProduct(ge),U=(ge,Fe)=>Ft.duplicateVariant(ge,Fe),Q=()=>{const ge=[];for(const Fe of a){const ot=`p:${Fe._cid}`,wt=ue.value.has(ot),kt=[];Fe.variants&&Fe.variants.forEach((Xt,vt)=>{ue.value.has(`v:${Fe._cid}:${vt}`)&&kt.push(vt)}),!(!wt&&kt.length===0)&&(wt&&kt.length===0?ge.push({product:Fe,type:"full"}):!wt&&kt.length>0?ge.push({product:Fe,type:"variants-only",variantIndexes:kt}):ge.push({product:Fe,type:"partial",variantIndexes:kt}))}return ge},V=()=>{const ge=Q();if(!ge.length)return;const Fe=ge.filter(vt=>vt.type==="full").length,ot=ge.filter(vt=>vt.type==="partial").length,kt=ge.filter(vt=>vt.type==="variants-only").reduce((vt,ea)=>vt+ea.variantIndexes.length,0),Xt=[];Fe>0&&Xt.push(`${Fe} product(s) with all variants`),ot>0&&Xt.push(`${ot} product(s) with selected variants`),kt>0&&Xt.push(`${kt} variant(s)`),Fl.confirm(H.$t("Duplicate %s?").replace("%s",Xt.join(", ")),H.$t("Bulk Duplicate"),{confirmButtonText:H.$t("Duplicate"),cancelButtonText:H.$t("Cancel"),type:"info"}).then(()=>{for(const vt of ge)if(vt.type==="full")Ft.duplicateProduct(vt.product);else if(vt.type==="variants-only")for(const ea of vt.variantIndexes){const ta=vt.product.variants[ea];ta&&Ft.duplicateVariant(vt.product,ta)}else vt.type==="partial"&&Ft.duplicateProductWithVariants(vt.product,vt.variantIndexes);ae()}).catch(()=>{})},I=async()=>{const ge=[],Fe=[];for(const vt of a){const ea=`p:${vt._cid}`;if(ue.value.has(ea)){ge.push(vt);continue}const zt=[];vt.variants&&vt.variants.forEach((wa,qa)=>{ue.value.has(`v:${vt._cid}:${qa}`)&&zt.push(wa)}),zt.length>0&&Fe.push({product:vt,variants:zt})}if(!ge.length&&!Fe.length)return;const ot=ge.filter(vt=>Ft.isSaved(vt._cid)).length,wt=Fe.reduce((vt,ea)=>vt+ea.variants.length,0),kt=[];ge.length>0&&kt.push(`${ge.length} product(s)`),wt>0&&kt.push(`${wt} variant(s)`);let Xt=H.$t("Remove %s?").replace("%s",kt.join(" and "));ot>0&&(Xt+=" "+H.$t("%s already saved will be permanently deleted.").replace("%s",`${ot}`));try{await Fl.confirm(Xt,H.$t("Bulk Remove"),{confirmButtonText:H.$t("Remove"),cancelButtonText:H.$t("Cancel"),type:"warning"})}catch{return}for(const vt of ge)await Ft.removeProduct(vt);for(const{product:vt,variants:ea}of Fe)for(const ta of ea)Ft.removeVariant(vt,ta);ae()},M=ge=>{Ft.resetPaymentTypeDefaults(ge)},O=(ge,Fe)=>{const ot=Ft.data.categoryOptions;for(const wt of Fe)ot.find(kt=>kt.value===wt)||ot.push({label:wt,value:wt})},L=()=>{Ft.populateDummyProduct()},H=Jt().ctx,j=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)},W=T({visible:!1,field:"",product:null,value:""}),G=(ge,Fe)=>{W.value={visible:!0,field:Fe,product:ge,value:ge[Fe]||""}},Z=ge=>{W.value.value=ge},ne=()=>{const{product:ge,field:Fe,value:ot}=W.value;ge&&(ge[Fe]=ot),W.value.visible=!1},ce=K(()=>W.value.field==="post_content"?H.$t("Edit Description"):H.$t("Edit Short Description")),z=T(!0),{selectedKeys:ue,handleRowClick:ie,toggleSelectAll:J,selectAll:N,deselectAll:ae,isSelected:oe,selectedCount:fe,isLinkMode:re,toggleLinkMode:Ee}=Sf(),ye=K(()=>{const ge=[];for(const Fe of _t.value)if(ge.push(`p:${Fe.productId}`),Fe.hasVariants&&!Fe.collapsed)for(let ot=0;ot{var Fe;if(ge.startsWith("p:")){const ot=ge.slice(2),wt=a.find(kt=>kt._cid===ot);return wt?{type:"product",data:wt,product:wt}:null}else if(ge.startsWith("v:")){const ot=ge.split(":"),wt=ot[1],kt=parseInt(ot[2]),Xt=a.find(vt=>vt._cid===wt);if(Xt&&((Fe=Xt.variants)!=null&&Fe[kt]))return{type:"variant",data:Xt.variants[kt],product:Xt}}return null},ve=(ge,Fe,ot)=>{!re.value||!oe(ot)||$f(ge,Fe,ot,ue.value,Ce,null,aye)},Ue=T(!1),Ke=ge=>{ge.key==="Shift"&&(Ue.value=!0)},We=ge=>{ge.key==="Shift"&&(Ue.value=!1)},Be=(ge,Fe)=>{if(!Fe.shiftKey||Fe.target.closest(".bulk-checkbox-cell"))return;Fe.preventDefault();const ot=new Set(ue.value);ot.has(ge)?ot.delete(ge):ot.add(ge),ue.value=ot},$e=T([]),He=K(()=>$e.value.filter(ge=>ge.key==="title"||ge.key==="actions"?!0:Ft.isColumnVisible(ge.key))),Re=ge=>Ft.isColumnVisible(ge),yt=()=>{Ft.saveColumnWidths($e.value)},gt=T(new Set),Rt=ge=>{const Fe=ge._cid;gt.value.has(Fe)?gt.value.delete(Fe):gt.value.add(Fe),gt.value=new Set(gt.value)},Tt=ge=>gt.value.has(ge._cid),Dt=T(0),_t=K(()=>{let ge=0;return a.map(Fe=>{var zt;const ot=Fe._cid,wt=((zt=Fe.detail)==null?void 0:zt.variation_type)!=="simple"&&Array.isArray(Fe.variants),kt=wt?Fe.variants.length:0,Xt=gt.value.has(ot),vt=wt&&!Xt?(kt+1)*ur:0,ea=ur+vt,ta={product:Fe,productId:ot,hasVariants:wt,variantCount:kt,collapsed:Xt,groupHeight:ea,offset:ge};return ge+=ea,ta})}),Gt=K(()=>{const ge=_t.value;if(ge.length===0)return 0;const Fe=ge[ge.length-1];return Fe.offset+Fe.groupHeight}),bt=K(()=>{const ge=_t.value,Fe=Dt.value,ot=Fe+_1e,wt=h1e*ur;return ge.filter(kt=>kt.offset+kt.groupHeight>=Fe-wt&&kt.offset<=ot+wt)}),St=K(()=>bt.value.length===0?0:bt.value[0].offset),Pt=K(()=>{if(bt.value.length===0)return 0;const ge=bt.value[bt.value.length-1];return Gt.value-ge.offset-ge.groupHeight});let Ht=null,Qt=0;const ht=ge=>{const Fe=ge.target,ot=Date.now();Ht&&clearTimeout(Ht),ot-Qt>=Uc?(Dt.value=Fe.scrollTop,Qt=ot):Ht=setTimeout(()=>{Dt.value=Fe.scrollTop,Qt=Date.now(),Ht=null},Uc)};let qt=null;return Ie(async()=>{qt=bs(),qt.bind("mod+a",ge=>{var ot,wt;const Fe=(ot=document.activeElement)==null?void 0:ot.tagName;Fe==="INPUT"||Fe==="TEXTAREA"||(wt=document.activeElement)!=null&&wt.isContentEditable||(ge.preventDefault(),N(ye.value))}),qt.bind("escape",()=>{var Fe,ot;const ge=(Fe=document.activeElement)==null?void 0:Fe.tagName;ge==="INPUT"||ge==="TEXTAREA"||(ot=document.activeElement)!=null&&ot.isContentEditable||(re.value?Ee():ae())}),$e.value=[{key:"title",title:H.$t("Title"),width:150,minWidth:100},{key:"sku",title:H.$t("SKU"),width:120,minWidth:80},{key:"media",title:H.$t("Media"),width:100,minWidth:50},{key:"categories",title:H.$t("Categories"),width:200,minWidth:150},{key:"description",title:H.$t("Description"),width:200,minWidth:150},{key:"short_description",title:H.$t("Short Description"),width:150,minWidth:100},{key:"status",title:H.$t("Status"),width:100,minWidth:50},{key:"product_type",title:H.$t("Product Type"),width:200,minWidth:150},{key:"pricing_type",title:H.$t("Pricing Type"),width:200,minWidth:150},{key:"payment_type",title:H.$t("Payment Type"),width:120,minWidth:100},{key:"interval",title:H.$t("Interval"),width:120,minWidth:80},{key:"trial_days",title:H.$t("Trial Days"),width:100,minWidth:70},{key:"best_price",title:H.$t("Best Price"),width:100,minWidth:100},{key:"compare_price",title:H.$t("Compare-at Price"),width:200,minWidth:150},{key:"track_quantity",title:H.$t("Track Quantity"),width:100,minWidth:100},{key:"stock",title:H.$t("Stock"),width:150,minWidth:150},{key:"actions",title:"",width:110,minWidth:110}],Ft.restoreColumnWidths($e.value),Ft.setupColumnVisibility(),Ft.fetchCategories(),document.body.classList.add("fct-bulk-page"),window.addEventListener("keydown",Ke),window.addEventListener("keyup",We)}),cl(()=>{document.body.classList.remove("fct-bulk-page"),window.removeEventListener("keydown",Ke),window.removeEventListener("keyup",We),qt&&qt.reset()}),(ge,Fe)=>{const ot=C("el-button"),wt=C("el-progress"),kt=C("el-checkbox"),Xt=C("el-checkbox-group"),vt=C("el-tooltip"),ea=C("el-popover"),ta=C("el-input"),zt=C("el-icon"),wa=C("el-option"),qa=C("el-select"),il=C("el-switch"),Ya=C("el-dialog");return r(),h("div",sye,[n(ol,{title:ge.$t("Bulk Insert")},{action:d(()=>[n(bge,{onOnDataPopulated:j}),n(ot,{onClick:L},{default:d(()=>[R(m(ge.$t("Add Product")),1)]),_:1}),n(ot,{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(wt,{key:0,percentage:c.value,"stroke-width":6,class:"mb-4"},null,8,["percentage"])):x("",!0),n(Se,null,{default:d(()=>{var ma;return[A(a).length>0?(r(),E(Ve,{key:0,title:((ma=A(a))==null?void 0:ma.length)===1?ge.$t("Product"):ge.$t("Products"),border_bottom:""},{action:d(()=>[o("div",nye,[n(ot,{disabled:A(fe)===0,onClick:I,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(ot,{disabled:A(fe)===0,onClick:V,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(ot,{class:de({"is-active":A(re)}),disabled:A(fe)<2&&!A(re),onClick:A(Ee),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(re)?ge.$t("Unlink"):ge.$t("Link")),1)]),_:1,__:[10]},8,["class","disabled","onClick"]),n(kt,{modelValue:z.value,"onUpdate:modelValue":Fe[0]||(Fe[0]=X=>z.value=X),label:ge.$t("Pin Actions")},null,8,["modelValue","label"]),n(ea,{trigger:"click",placement:"bottom-end",width:"240","popper-class":"filter-popover"},{reference:d(()=>[o("span",null,[n(vt,{effect:"light",content:ge.$t("Toggle columns"),placement:"top","popper-class":"fct-tooltip"},{default:d(()=>[n(at,{tag:"button",size:"small"},{default:d(()=>[n(Y,{name:"ColumnIcon"})]),_:1})]),_:1},8,["content"])])]),default:d(()=>[o("div",oye,[o("h3",iye,m(ge.$t("Columns")),1),n(Xt,{modelValue:A(Ft).data.visibleColumns,"onUpdate:modelValue":Fe[1]||(Fe[1]=X=>A(Ft).data.visibleColumns=X),class:"fct-checkbox-blocks",onChange:Fe[2]||(Fe[2]=X=>A(Ft).handleColumnVisibilityChange())},{default:d(()=>[(r(!0),h(P,null,te(A(Ft).getToggleableColumns(),X=>(r(),E(kt,{key:X.value,value:X.value,label:ge.$t(X.label)},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])]),_:1})])]),_:1},8,["title"])):x("",!0),n(ke,{class:"p-0"},{default:d(()=>[A(a).length>0?(r(),h("div",{key:0,class:de(["relative",{"is-link-mode":A(re),"is-shift-held":Ue.value}])},[n(Bf,{columns:He.value,"sticky-last":z.value,onScroll:ht,onResizeEnd:yt},{"header-first":d(()=>[n(kt,{"model-value":A(fe)>0&&A(fe)===ye.value.length,indeterminate:A(fe)>0&&A(fe)A(J)(ye.value))},null,8,["model-value","indeterminate"])]),"header-last":d(()=>[R(m(ge.$t("Actions")),1)]),default:d(()=>[St.value>0?(r(),h("tr",rye,[o("td",{colspan:He.value.length+1,style:ra({height:St.value+"px",padding:0,border:"none"})},null,12,dye)])):x("",!0),(r(!0),h(P,null,te(bt.value,X=>{var we,le,he,Ye,st,je,Xe,mt,et,It,pe,_e,Oe,Me,ct;return r(),h(P,{key:X.productId},[o("tr",{class:de(["bulk-product-row",{"is-saving":f(X.product),"is-saved":_(X.product),"has-product-error":y(X.product),"is-selected":A(oe)(`p:${X.productId}`)}]),onClick:ee=>Be(`p:${X.productId}`,ee)},[o("td",{class:"bulk-checkbox-cell",onClick:ee=>A(ie)(`p:${X.productId}`,ee,ye.value)},[n(kt,{"model-value":A(oe)(`p:${X.productId}`),tabindex:"-1"},null,8,["model-value"])],8,cye),o("td",Aye,[o("div",pye,[X.hasVariants?(r(),h("button",{key:0,class:"bulk-collapse-btn",onClick:Ge(ee=>Rt(X.product),["prevent"]),title:Tt(X.product)?ge.$t("Expand variants"):ge.$t("Collapse variants")},[(r(),h("svg",{class:de(["bulk-collapse-icon",{"is-collapsed":Tt(X.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)),Tt(X.product)?(r(),h("span",mye,m(X.variantCount),1)):x("",!0)],8,fye)):x("",!0),n(ta,{class:de(["fct-bulk-input",{"is-error":S(X.product,"post_title")}]),modelValue:X.product.post_title,"onUpdate:modelValue":ee=>X.product.post_title=ee,placeholder:ge.$t("Product title"),size:"small",disabled:g(X.product),onInput:ee=>ve("title",ee,`p:${X.productId}`)},null,8,["class","modelValue","onUpdate:modelValue","placeholder","disabled","onInput"]),f(X.product)?(r(),h("span",{key:1,class:"bulk-status-icon is-syncing",title:ge.$t("Saving...")},[n(zt,{class:"is-loading",size:14},{default:d(()=>[n(A(en))]),_:1})],8,hye)):_(X.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,_ye)):w(X.product)||l(X.product)&&y(X.product)?(r(),E(vt,{key:3,content:v(X.product),placement:"top"},{default:d(()=>[o("span",vye,[n(zt,{size:16},{default:d(()=>[n(A(Vo))]),_:1})])]),_:2},1032,["content"])):x("",!0)])]),Re("sku")?(r(),h("td",gye,[((le=(we=X.product)==null?void 0:we.detail)==null?void 0:le.variation_type)==="simple"&&((he=X.product.variants)!=null&&he[0])?(r(),E(ta,{key:0,class:de(["fct-bulk-input",{"is-error":S(X.product,"variants.0.sku")}]),modelValue:X.product.variants[0].sku,"onUpdate:modelValue":[ee=>X.product.variants[0].sku=ee,ee=>ve("sku",ee,`p:${X.productId}`)],placeholder:"SKU",size:"small",disabled:g(X.product)},null,8,["class","modelValue","onUpdate:modelValue","disabled"])):(r(),h("span",yye,"—"))])):x("",!0),Re("media")?(r(),h("td",bye,[n(yl,{modelValue:X.product.gallery,"onUpdate:modelValue":ee=>X.product.gallery=ee,"show-url-tab":"",disabled:g(X.product)},null,8,["modelValue","onUpdate:modelValue","disabled"])])):x("",!0),Re("categories")?(r(),h("td",wye,[n(xf,{modelValue:X.product.categories,"onUpdate:modelValue":ee=>X.product.categories=ee,options:A(Ft).data.categoryOptions,disabled:g(X.product),onChange:ee=>{O(X.product,ee),ve("categories",X.product.categories,`p:${X.productId}`)}},null,8,["modelValue","onUpdate:modelValue","options","disabled","onChange"])])):x("",!0),Re("description")?(r(),h("td",Cye,[n(li,{value:X.product.post_content,placeholder:ge.$t("Description"),onClick:ee=>G(X.product,"post_content")},null,8,["value","placeholder","onClick"])])):x("",!0),Re("short_description")?(r(),h("td",kye,[n(li,{value:X.product.post_excerpt,placeholder:ge.$t("Short description"),onClick:ee=>G(X.product,"post_excerpt")},null,8,["value","placeholder","onClick"])])):x("",!0),Re("status")?(r(),h("td",Bye,[n(qa,{modelValue:X.product.post_status,"onUpdate:modelValue":ee=>X.product.post_status=ee,size:"small",class:de({"is-field-error":S(X.product,"post_status")}),disabled:g(X.product),onChange:ee=>ve("status",X.product.post_status,`p:${X.productId}`)},{default:d(()=>[(r(!0),h(P,null,te(A(t).status,ee=>(r(),E(wa,{key:ee.value,label:ge.$t(ee.title),value:ee.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):x("",!0),Re("product_type")&&((Ye=X.product)!=null&&Ye.detail)?(r(),h("td",xye,[n(qa,{modelValue:X.product.detail.fulfillment_type,"onUpdate:modelValue":ee=>X.product.detail.fulfillment_type=ee,size:"small",class:de({"is-field-error":S(X.product,"detail.fulfillment_type")}),disabled:g(X.product),onChange:ee=>ve("product_type",X.product.detail.fulfillment_type,`p:${X.productId}`)},{default:d(()=>[(r(!0),h(P,null,te(A(t).fulfilment,ee=>(r(),E(wa,{key:ee.value,label:ge.$t(ee.title),value:ee.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):Re("product_type")?(r(),h("td",Sye)):x("",!0),Re("pricing_type")&&((st=X.product)!=null&&st.detail)?(r(),h("td",Fye,[n(qa,{modelValue:X.product.detail.variation_type,"onUpdate:modelValue":ee=>X.product.detail.variation_type=ee,size:"small",class:de({"is-field-error":S(X.product,"detail.variation_type")}),disabled:g(X.product),onChange:ee=>{A(Ft).handleVariationChanged(X.product,ee),ve("pricing_type",ee,`p:${X.productId}`)}},{default:d(()=>[(r(!0),h(P,null,te(A(t).variation,ee=>(r(),E(wa,{key:ee.value,label:ge.$t(ee.title),value:ee.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):Re("pricing_type")?(r(),h("td",$ye)):x("",!0),Re("payment_type")?(r(),h("td",Eye,[n(Zo,{variant:l(X.product)?(je=X.product.variants)==null?void 0:je[0]:null,disabled:g(X.product),"has-error":S(X.product,"variants.0.other_info.payment_type"),onPaymentTypeChange:ee=>{var Ne;M(ee),ve("payment_type",(Ne=ee.other_info)==null?void 0:Ne.payment_type,`p:${X.productId}`)}},null,8,["variant","disabled","has-error","onPaymentTypeChange"])])):x("",!0),Re("interval")?(r(),h("td",Uye,[n(ei,{variant:l(X.product)?(Xe=X.product.variants)==null?void 0:Xe[0]:null,disabled:g(X.product),"has-error":S(X.product,"variants.0.other_info.repeat_interval"),onChange:ee=>{var Ne,pt,De;return ve("interval",(De=(pt=(Ne=X.product.variants)==null?void 0:Ne[0])==null?void 0:pt.other_info)==null?void 0:De.repeat_interval,`p:${X.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Re("trial_days")?(r(),h("td",Iye,[n(ti,{variant:l(X.product)?(mt=X.product.variants)==null?void 0:mt[0]:null,disabled:g(X.product),"has-error":S(X.product,"variants.0.other_info.trial_days"),onChange:ee=>{var Ne,pt,De;return ve("trial_days",(De=(pt=(Ne=X.product.variants)==null?void 0:Ne[0])==null?void 0:pt.other_info)==null?void 0:De.trial_days,`p:${X.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Re("best_price")?(r(),h("td",Qye,[n(Xo,{variant:l(X.product)?(et=X.product.variants)==null?void 0:et[0]:null,disabled:g(X.product),"has-error":S(X.product,"variants.0.item_price"),onChange:ee=>{var Ne,pt;return ve("price",(pt=(Ne=X.product.variants)==null?void 0:Ne[0])==null?void 0:pt.item_price,`p:${X.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Re("compare_price")?(r(),h("td",Dye,[n(ai,{variant:l(X.product)?(It=X.product.variants)==null?void 0:It[0]:null,disabled:g(X.product),"has-error":S(X.product,"variants.0.compare_price"),onChange:ee=>{var Ne,pt;return ve("compare_price",(pt=(Ne=X.product.variants)==null?void 0:Ne[0])==null?void 0:pt.compare_price,`p:${X.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Re("track_quantity")?(r(),h("td",Vye,[(pe=X.product)!=null&&pe.detail?(r(),E(il,{key:0,modelValue:X.product.detail.manage_stock,"onUpdate:modelValue":ee=>X.product.detail.manage_stock=ee,"active-value":"1","inactive-value":"0",disabled:g(X.product),onChange:ee=>{A(Ft).syncStockStatus(X.product),ve("manage_stock",X.product.detail.manage_stock,`p:${X.productId}`)}},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])):x("",!0)])):x("",!0),Re("stock")?(r(),h("td",Tye,[((Oe=(_e=X.product)==null?void 0:_e.detail)==null?void 0:Oe.manage_stock)==="1"&&((ct=(Me=X.product)==null?void 0:Me.detail)==null?void 0:ct.variation_type)==="simple"?(r(),E(ta,{key:0,modelValue:X.product.detail.total_stock,"onUpdate:modelValue":[ee=>X.product.detail.total_stock=ee,ee=>{var Ne;(Ne=X.product.variants)!=null&&Ne[0]&&(X.product.variants[0].total_stock=ee,X.product.variants[0].available=ee),A(Ft).syncStockStatus(X.product),ve("stock",ee,`p:${X.productId}`)}],disabled:g(X.product),size:"small",placeholder:ge.$t("e.g 10")},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):(r(),h("span",Mye,"—"))])):x("",!0),o("td",{class:de(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":z.value}])},[o("div",Lye,[_(X.product)&&X.product.view_url?(r(),h("a",{key:0,href:X.product.view_url,target:"_blank",class:"bulk-action-btn bulk-view-link",title:ge.$t("View Product")},[n(Y,{name:"External"})],8,Rye)):x("",!0),n(at,{tag:"button",size:"x-small",onClick:Ge(ee=>B(X.product),["prevent"]),disabled:s.value||g(X.product),title:ge.$t("Duplicate")},{default:d(()=>[n(Y,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(at,{tag:"button",size:"x-small",hover:"danger",onClick:Ge(ee=>D(X.product),["prevent"]),disabled:s.value||g(X.product),title:ge.$t("Delete")},{default:d(()=>[n(Y,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,uye),X.hasVariants?(r(),h("tr",Oye,[o("td",{colspan:He.value.length+1,class:"!p-0 !border-b-0"},[n(ya,{accordion:"",visible:!X.collapsed,duration:200},{default:d(()=>[o("table",Hye,[o("colgroup",null,[Fe[13]||(Fe[13]=o("col",{style:{width:"40px"}},null,-1)),(r(!0),h(P,null,te(He.value,(ee,Ne)=>(r(),h("col",{key:Ne,style:ra({width:ee.width+"px"})},null,4))),128))]),o("tbody",null,[(r(!0),h(P,null,te(X.product.variants,(ee,Ne)=>{var pt,De;return r(),h("tr",{key:Ne,class:de(["bulk-variation-row",{"is-selected":A(oe)(`v:${X.productId}:${Ne}`)}]),onClick:xt=>Be(`v:${X.productId}:${Ne}`,xt)},[o("td",Kye,[n(kt,{"model-value":A(oe)(`v:${X.productId}:${Ne}`),tabindex:"-1",onChange:xt=>A(ie)(`v:${X.productId}:${Ne}`,xt,ye.value)},null,8,["model-value","onChange"])]),o("td",Gye,[o("div",zye,[Fe[14]||(Fe[14]=o("span",{class:"text-gray-300 text-xs"},"└",-1)),n(ta,{size:"small",modelValue:ee.variation_title,"onUpdate:modelValue":[xt=>ee.variation_title=xt,xt=>ve("title",xt,`v:${X.productId}:${Ne}`)],placeholder:ge.$t("Variation title"),disabled:g(X.product),class:de({"is-error":$(X.product,Ne,"variation_title")})},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),k(X.product,Ne)?(r(),E(vt,{key:0,content:b(X.product,Ne),placement:"top"},{default:d(()=>[o("span",jye,[n(zt,{size:14},{default:d(()=>[n(A(Vo))]),_:1})])]),_:2},1032,["content"])):x("",!0)])]),Re("sku")?(r(),h("td",qye,[n(ta,{size:"small",modelValue:ee.sku,"onUpdate:modelValue":[xt=>ee.sku=xt,xt=>ve("sku",xt,`v:${X.productId}:${Ne}`)],placeholder:"SKU",disabled:g(X.product),class:de({"is-error":$(X.product,Ne,"sku")})},null,8,["modelValue","onUpdate:modelValue","disabled","class"])])):x("",!0),Re("media")?(r(),h("td",Yye,[n(yl,{modelValue:ee.media,"onUpdate:modelValue":xt=>ee.media=xt,"show-url-tab":"",disabled:g(X.product)},null,8,["modelValue","onUpdate:modelValue","disabled"])])):x("",!0),Re("categories")?(r(),h("td",Wye,Fe[15]||(Fe[15]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Re("description")?(r(),h("td",Jye,Fe[16]||(Fe[16]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Re("short_description")?(r(),h("td",Xye,Fe[17]||(Fe[17]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Re("status")?(r(),h("td",Zye,Fe[18]||(Fe[18]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Re("product_type")?(r(),h("td",e1e,Fe[19]||(Fe[19]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Re("pricing_type")?(r(),h("td",t1e,Fe[20]||(Fe[20]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Re("payment_type")?(r(),h("td",a1e,[n(Zo,{variant:ee,disabled:g(X.product),"has-error":$(X.product,Ne,"other_info.payment_type"),onPaymentTypeChange:xt=>{var Wa;M(xt),ve("payment_type",(Wa=xt.other_info)==null?void 0:Wa.payment_type,`v:${X.productId}:${Ne}`)}},null,8,["variant","disabled","has-error","onPaymentTypeChange"])])):x("",!0),Re("interval")?(r(),h("td",l1e,[n(ei,{variant:ee,disabled:g(X.product),"has-error":$(X.product,Ne,"other_info.repeat_interval"),onChange:xt=>{var Wa;return ve("interval",(Wa=ee.other_info)==null?void 0:Wa.repeat_interval,`v:${X.productId}:${Ne}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Re("trial_days")?(r(),h("td",s1e,[n(ti,{variant:ee,disabled:g(X.product),"has-error":$(X.product,Ne,"other_info.trial_days"),onChange:xt=>{var Wa;return ve("trial_days",(Wa=ee.other_info)==null?void 0:Wa.trial_days,`v:${X.productId}:${Ne}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Re("best_price")?(r(),h("td",n1e,[n(Xo,{variant:ee,disabled:g(X.product),"has-error":$(X.product,Ne,"item_price"),onChange:xt=>ve("price",ee.item_price,`v:${X.productId}:${Ne}`)},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Re("compare_price")?(r(),h("td",o1e,[n(ai,{variant:ee,disabled:g(X.product),"has-error":$(X.product,Ne,"compare_price"),onChange:xt=>ve("compare_price",ee.compare_price,`v:${X.productId}:${Ne}`)},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),Re("track_quantity")?(r(),h("td",i1e,Fe[21]||(Fe[21]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),Re("stock")?(r(),h("td",r1e,[((De=(pt=X.product)==null?void 0:pt.detail)==null?void 0:De.manage_stock)==="1"?(r(),E(ta,{key:0,class:"fc-bulk-input",size:"small",modelValue:ee.total_stock,"onUpdate:modelValue":[xt=>ee.total_stock=xt,xt=>{ee.available=xt,A(Ft).syncStockStatus(X.product),ve("stock",xt,`v:${X.productId}:${Ne}`)}],disabled:g(X.product),placeholder:ge.$t("e.g 10")},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):(r(),h("span",d1e,"—"))])):x("",!0),o("td",{class:de(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":z.value}])},[o("div",u1e,[n(at,{tag:"button",size:"x-small",onClick:Ge(xt=>U(X.product,ee),["prevent"]),disabled:s.value||g(X.product),title:ge.$t("Duplicate")},{default:d(()=>[n(Y,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(at,{tag:"button",size:"x-small",hover:"danger",onClick:Ge(xt=>F(X.product,ee),["prevent"]),disabled:s.value||g(X.product),title:ge.$t("Delete")},{default:d(()=>[n(Y,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,Nye)}),128)),o("tr",c1e,[o("td",{colspan:He.value.length+1},[o("div",p1e,[n(ot,{size:"small",text:"",type:"primary",onClick:Ge(ee=>A(Ft).addVariationToProduct(X.product),["prevent"])},{default:d(()=>[R(" + "+m(ge.$t("Add Variant")),1)]),_:2},1032,["onClick"])])],8,A1e)])])])]),_:2},1032,["visible"])],8,Pye)])):x("",!0)],64)}),128)),Pt.value>0?(r(),h("tr",f1e,[o("td",{colspan:He.value.length+1,style:ra({height:Pt.value+"px",padding:0,border:"none"})},null,12,m1e)])):x("",!0)]),_:1},8,["columns","sticky-last"])],2)):(r(),E(Ct,{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(Ya,{modelValue:W.value.visible,"onUpdate:modelValue":Fe[6]||(Fe[6]=ma=>W.value.visible=ma),title:ce.value,width:"700px","close-on-click-modal":!1,onClosed:Fe[7]||(Fe[7]=ma=>W.value.product=null)},{footer:d(()=>[n(ot,{onClick:Fe[5]||(Fe[5]=ma=>W.value.visible=!1)},{default:d(()=>[R(m(ge.$t("Cancel")),1)]),_:1}),n(ot,{type:"primary",onClick:ne},{default:d(()=>[R(m(ge.$t("Save")),1)]),_:1})]),default:d(()=>[W.value.visible&&W.value.field==="post_content"?(r(),E(ls,{key:0,"model-value":W.value.value,height:300,onUpdate:Z},null,8,["model-value"])):x("",!0),W.value.visible&&W.value.field==="post_excerpt"?(r(),E(ta,{key:1,modelValue:W.value.value,"onUpdate:modelValue":Fe[4]||(Fe[4]=ma=>W.value.value=ma),type:"textarea",rows:6,placeholder:ge.$t("Short description")},null,8,["modelValue","placeholder"])):x("",!0)]),_:1},8,["modelValue","title"])])}}};class g1e extends Dd{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";q.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 Ae.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),q.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)),q.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))}q.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){q.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 Ae.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?q.success(`${i.length} product(s) updated successfully`):i.length>0?q.info(`${i.length} product(s) updated, ${c.length} error(s)`):q.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 Ae.post(`products/${a}/duplicate`,{})).product_id;if(i){const p=(await Ae.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";q.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 Ae.post(`products/${l}/duplicate`,{})).product_id;if(!c)return;const f=(await Ae.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 w of g)a.includes(w.id)&&w.serial_index!=null&&y.add(w.serial_index);_.variants&&y.size>0&&(_.variants=_.variants.filter(w=>y.has(w.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";q.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 Ae.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";q.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 q.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 Ae.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 it=g1e.init(),y1e={class:"fct-bulk-edit-page fct-layout-width"},b1e={class:"fct-table-wrapper"},w1e={class:"fct-card-header-top"},C1e={class:"fct-card-header-left flex-1"},k1e={class:"fct-card-header-actions"},B1e={key:0,class:"fct-advanced-filter-toggle-wrapper"},x1e={key:1,class:"fct-btn-group sm hidden md:flex"},S1e={key:0,class:"filter-search-wrap"},F1e={class:"search-bar"},$1e={class:"text-xs text-system-light pt-2 dark:text-gray-300"},E1e={class:"fct-bulk-edit-table-wrap"},U1e={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"},I1e={class:"m-0 text-base"},Q1e={key:0,class:"text-system-mid text-sm font-normal dark:text-gray-300"},D1e={class:"fct-btn-group sm justify-end"},V1e={class:"filter-popover-item"},T1e={class:"filter-popover-title"},M1e={class:"fct-bulk-edit-table"},L1e={key:0,"aria-hidden":"true"},R1e=["colspan"],O1e=["onClick"],P1e=["onClick"],H1e={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},N1e={class:"flex items-center"},K1e=["onClick","title"],G1e={key:0,class:"bulk-collapse-count"},z1e=["title"],j1e={class:"bulk-status-icon is-error"},q1e=["disabled","onClick","title"],Y1e={key:0,class:"fct-bulk-media-cell"},W1e={key:1,class:"fct-bulk-sku-cell"},J1e={key:1,class:"text-gray-300 text-sm flex justify-center"},X1e={key:2,class:"fct-bulk-categories-cell"},Z1e={key:3,class:"fct-bulk-desc-cell"},ebe={key:4,class:"fct-bulk-short-desc-cell"},tbe={key:5,class:"fct-bulk-status-cell"},abe={key:6,class:"fct-bulk-product-type-cell"},lbe={class:"bulk-readonly-label"},sbe={key:7,class:"fct-bulk-pricing-type-cell"},nbe={class:"bulk-readonly-label"},obe={key:8,class:"fct-bulk-payment-type-cell"},ibe={key:9,class:"fct-bulk-interval-cell"},rbe={key:10,class:"fct-bulk-trial-days-cell"},dbe={key:11,class:"fct-bulk-best-price-cell"},ube={key:12,class:"fct-bulk-compare-price-cell"},cbe={key:13,class:"fct-bulk-qty-cell !pl-5"},Abe={key:14,class:"fct-bulk-stock-cell"},pbe={key:1,class:"text-gray-300 text-sm flex justify-center"},fbe={class:"fct-btn-group sm justify-end"},mbe={key:0,class:"bulk-variants-block-row"},hbe=["colspan"],_be={class:"bulk-inner-table",style:{tableLayout:"fixed",width:"100%",borderCollapse:"collapse"}},vbe=["onClick"],gbe={class:"bulk-checkbox-cell"},ybe={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},bbe={class:"flex items-center gap-1 pl-4"},wbe={class:"bulk-status-icon is-error"},Cbe={key:0},kbe={key:1},Bbe={key:2},xbe={key:3},Sbe={key:4},Fbe={key:5},$be={key:6},Ebe={key:7},Ube={key:8},Ibe={key:9},Qbe={key:10},Dbe={key:11},Vbe={key:12},Tbe={key:13,class:"text-center"},Mbe={key:14},Lbe={key:1,class:"text-gray-300 text-sm flex justify-center"},Rbe={class:"fct-btn-group sm justify-end"},Obe={key:1,"aria-hidden":"true"},Pbe=["colspan"],Hbe={key:1,class:"flex flex-col items-center justify-center py-16 text-center"},Nbe={class:"text-system-mid text-sm"},Kbe={key:2,class:"flex items-center justify-center py-8"},Gbe={class:"text-system-mid text-sm"},zbe={key:1,class:"flex items-center justify-center py-3 border-top"},jbe={class:"text-system-mid text-sm"},cr=43,qbe=10,Ic=800,Qc=100,Ybe=200,Wbe={__name:"BulkEdit",setup(e){const t=Jt().ctx,a=nl(),{options:l}=it.data,s=le=>{var he;return((he=le==null?void 0:le.detail)==null?void 0:he.variation_type)==="simple"},i=K(()=>it.data.products),c=K(()=>it.data.loading),p=K(()=>it.data.saving),f=K(()=>it.data.saveProgress),_=K(()=>it.data.pagination),g=K(()=>it.data.dirty),y=K(()=>g.value.size),v=K(()=>Math.max(0,_.value.total-i.value.length)),w=K(()=>Math.min(_.value.per_page,v.value)),k=K(()=>{const le=it.data.saveProgress;return le.total?Math.round(le.completed/le.total*100):0}),b=td("search-input"),S=()=>{it.openSearch(),xe(()=>{var le;(le=b.value)==null||le.focus()})},$=(le=!1)=>{it.fetchProducts({},le)},D=()=>{it.saveProducts()},F=le=>{it.markDirty(le.ID)},B=(le,he)=>{it.resetPaymentTypeDefaults(he),F(le)},U=(le,he)=>{const Ye=it.data.categoryOptions;for(const st of he)Ye.find(je=>je.value===st)||Ye.push({label:st,value:st});F(le)},Q=le=>it.isDirty(le.ID),V=le=>it.isSavingProduct(le.ID),I=le=>it.isSaved(le.ID),M=le=>it.isRowDisabled(le.ID),O=le=>it.isDuplicating(le.ID),L=le=>it.isDeleting(le.ID),H=le=>it.hasError(le.ID),j=le=>it.getError(le.ID),W=le=>it.hasProductLevelError(le.ID),G=(le,he)=>it.hasVariantError(le.ID,he),Z=(le,he)=>it.getVariantError(le.ID,he),ne=(le,he)=>it.hasFieldError(le.ID,he),ce=(le,he,Ye)=>it.hasVariantFieldError(le.ID,he,Ye),z=le=>it.saveProduct(le),ue=le=>it.duplicateProduct(le),ie=(le,he)=>it.duplicateVariant(le,he),J=T(!0),{selectedKeys:N,handleRowClick:ae,toggleSelectAll:oe,selectAll:fe,deselectAll:re,isSelected:Ee,selectedCount:ye,isLinkMode:Ce,toggleLinkMode:ve}=Sf(),Ue=K(()=>{const le=[];for(const he of kt.value)if(le.push(`p:${he.productId}`),he.hasVariants&&!he.collapsed)for(const Ye of he.product.variants)le.push(`v:${Ye.id}`);return le}),Ke=le=>{var he;if(le.startsWith("p:")){const Ye=parseInt(le.slice(2)),st=kt.value.find(je=>je.productId===Ye);return st?{type:"product",data:st.product,product:st.product}:null}else if(le.startsWith("v:")){const Ye=parseInt(le.slice(2));for(const st of kt.value){const je=(he=st.product.variants)==null?void 0:he.find(Xe=>Xe.id===Ye);if(je)return{type:"variant",data:je,product:st.product}}}return null},We=(le,he,Ye)=>{!Ce.value||!Ee(Ye)||$f(le,he,Ye,N.value,Ke,F,lye)},Be=T(!1),$e=le=>{le.key==="Shift"&&(Be.value=!0)},He=le=>{le.key==="Shift"&&(Be.value=!1)},Re=(le,he)=>{if(!he.shiftKey||he.target.closest(".bulk-checkbox-cell"))return;he.preventDefault();const Ye=new Set(N.value);Ye.has(le)?Ye.delete(le):Ye.add(le),N.value=Ye},yt=()=>{const le=[];for(const he of kt.value){const Ye=`p:${he.productId}`,st=N.value.has(Ye),je=[];if(he.product.variants)for(const Xe of he.product.variants)N.value.has(`v:${Xe.id}`)&&je.push(Xe.id);!st&&je.length===0||(st&&je.length===0?le.push({product:he.product,type:"full"}):!st&&je.length>0?le.push({product:he.product,type:"variants-only",variantIds:je}):le.push({product:he.product,type:"partial",variantIds:je}))}return le},gt=async()=>{const le=yt();if(!le.length)return;const he=le.filter(mt=>mt.type==="full").length,Ye=le.filter(mt=>mt.type==="partial").length,je=le.filter(mt=>mt.type==="variants-only").reduce((mt,et)=>mt+et.variantIds.length,0),Xe=[];he>0&&Xe.push(`${he} product(s) with all variants`),Ye>0&&Xe.push(`${Ye} product(s) with selected variants`),je>0&&Xe.push(`${je} variant(s)`);try{await Fl.confirm(t.$t("Duplicate %s?").replace("%s",Xe.join(", ")),t.$t("Bulk Duplicate"),{confirmButtonText:t.$t("Duplicate"),cancelButtonText:t.$t("Cancel"),type:"info"})}catch{return}for(const mt of le)if(mt.type==="full")await it.duplicateProduct(mt.product);else if(mt.type==="variants-only")for(const et of mt.variantIds){const It=mt.product.variants.find(pe=>pe.id===et);It&&it.duplicateVariant(mt.product,It)}else mt.type==="partial"&&await it.duplicateProductWithVariants(mt.product,mt.variantIds);re()},Rt=async()=>{const le=[],he=[];for(const je of kt.value){const Xe=`p:${je.productId}`;if(N.value.has(Xe)){le.push(je.product);continue}const et=[];if(je.product.variants)for(const It of je.product.variants)N.value.has(`v:${It.id}`)&&et.push(It);et.length>0&&he.push({product:je.product,variants:et})}if(!le.length&&!he.length)return;const Ye=he.reduce((je,Xe)=>je+Xe.variants.length,0),st=[];le.length>0&&st.push(`${le.length} product(s)`),Ye>0&&st.push(`${Ye} variant(s)`);try{await Fl.confirm(t.$t("Permanently delete %s? This cannot be undone.").replace("%s",st.join(" and ")),t.$t("Bulk Delete"),{confirmButtonText:t.$t("Delete"),cancelButtonText:t.$t("Cancel"),type:"warning"})}catch{return}for(const je of le)await it.deleteProduct(je);for(const{product:je,variants:Xe}of he)for(const mt of Xe)it.removeVariant(je,mt);re()},Tt=async le=>{const he=le.ID;if(!he||it.isDeleting(he))return;const Ye=le.post_title||t.$t("Untitled product"),st=Array.isArray(le.variants)?le.variants.length:0,je=st>0?t.$t('This will permanently delete "%1$s" and its %2$s variant(s).',Ye,st):t.$t('This will permanently delete "%1$s".',Ye);try{await Fl.confirm(je,t.$t("Delete Product"),{confirmButtonText:t.$t("Delete"),cancelButtonText:t.$t("Cancel"),type:"warning"})}catch{return}it.deleteProduct(le)},Dt=(le,he)=>{if(le.variants.length<=1){it.removeVariant(le,he);return}const Ye=he.variation_title||t.$t("Untitled variant");Fl.confirm(t.$t('This will remove the variant "%1$s".',Ye),t.$t("Remove Variant"),{confirmButtonText:t.$t("Remove"),cancelButtonText:t.$t("Cancel"),type:"warning"}).then(()=>{it.removeVariant(le,he)}).catch(()=>{})},_t=T({visible:!1,field:"",product:null,value:""}),Gt=(le,he)=>{_t.value={visible:!0,field:he,product:le,value:le[he]||""}},bt=le=>{_t.value.value=le},St=()=>{const{product:le,field:he,value:Ye}=_t.value;le&&(le[he]=Ye,F(le)),_t.value.visible=!1},Pt=K(()=>_t.value.field==="post_content"?t.$t("Edit Description"):t.$t("Edit Short Description")),Ht=T([]),Qt=K(()=>Ht.value.filter(le=>le.key==="title"||le.key==="actions"?!0:it.isColumnVisible(le.key))),ht=le=>it.isColumnVisible(le),qt=()=>{it.saveColumnWidths(Ht.value)},ge=T(new Set),Fe=le=>{const he=le.ID;ge.value.has(he)?ge.value.delete(he):ge.value.add(he),ge.value=new Set(ge.value)},ot=le=>ge.value.has(le.ID),wt=T(0),kt=K(()=>{let le=0;return i.value.map(he=>{var pe;const Ye=he.ID,st=((pe=he.detail)==null?void 0:pe.variation_type)!=="simple"&&Array.isArray(he.variants)&&he.variants.length>0,je=st?he.variants.length:0,Xe=ge.value.has(Ye),mt=st&&!Xe?je*cr:0,et=cr+mt,It={product:he,productId:Ye,hasVariants:st,variantCount:je,collapsed:Xe,groupHeight:et,offset:le};return le+=et,It})}),Xt=K(()=>{const le=kt.value;if(le.length===0)return 0;const he=le[le.length-1];return he.offset+he.groupHeight}),vt=K(()=>{const le=kt.value,he=wt.value,Ye=he+Ic,st=qbe*cr;return le.filter(je=>je.offset+je.groupHeight>=he-st&&je.offset<=Ye+st)}),ea=K(()=>vt.value.length===0?0:vt.value[0].offset),ta=K(()=>{if(vt.value.length===0)return 0;const le=vt.value[vt.value.length-1];return Xt.value-le.offset-le.groupHeight});let zt=null,wa=0;const qa=()=>{if(c.value||!_.value.hasMore||i.value.length===0)return;Xt.value-(wt.value+Ic){const he=le.target,Ye=Date.now();zt&&clearTimeout(zt),Ye-wa>=Qc?(wt.value=he.scrollTop,wa=Ye,qa()):zt=setTimeout(()=>{wt.value=he.scrollTop,wa=Date.now(),zt=null,qa()},Qc)},Ya=le=>({physical:"Physical",digital:"Digital"})[le]||le||"—",ma=le=>({simple:"Simple",simple_variations:"Variable"})[le]||le||"—";let X=null;const we=()=>{const le=a.query.product_ids,he=a.query.variant_ids;le&&he?it.fetchProducts({},!1,le,he):$(!1)};return Ie(async()=>{X=bs(),X.bind("mod+a",le=>{var Ye,st;const he=(Ye=document.activeElement)==null?void 0:Ye.tagName;he==="INPUT"||he==="TEXTAREA"||(st=document.activeElement)!=null&&st.isContentEditable||(le.preventDefault(),fe(Ue.value))}),X.bind("escape",()=>{var he,Ye;const le=(he=document.activeElement)==null?void 0:he.tagName;le==="INPUT"||le==="TEXTAREA"||(Ye=document.activeElement)!=null&&Ye.isContentEditable||(Ce.value?ve():re())}),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}],it.restoreColumnWidths(Ht.value),it.setupColumnVisibility(),it.setupSavedViews(),it.fetchCategories(),we(),document.body.classList.add("fct-bulk-page"),window.addEventListener("keydown",$e),window.addEventListener("keyup",He)}),cl(()=>{document.body.classList.remove("fct-bulk-page"),window.removeEventListener("keydown",$e),window.removeEventListener("keyup",He),X&&X.reset()}),(le,he)=>{const Ye=C("el-button"),st=C("el-progress"),je=C("el-switch"),Xe=C("el-tooltip"),mt=C("el-input"),et=C("el-checkbox"),It=C("el-checkbox-group"),pe=C("el-popover"),_e=C("el-icon"),Oe=C("el-option"),Me=C("el-select"),ct=C("el-dialog");return r(),h("div",y1e,[n(ol,{title:le.$t("Bulk Edit")},{action:d(()=>[n(Ye,{type:"primary",onClick:D,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(st,{key:0,percentage:k.value,"stroke-width":6,class:"mb-4"},null,8,["percentage"])):x("",!0),o("div",b1e,[n(Se,null,{default:d(()=>[n(Ve,{border_bottom:""},{default:d(()=>[o("div",w1e,[o("div",C1e,[A(it).getTabsCount()&&!A(it).isUsingAdvanceFilter()?(r(),E(am,{key:0,class:de("hide-animation-on-mobile hidden md:inline-flex classic-tab-style"),table:A(it)},null,8,["table"])):x("",!0)]),o("div",k1e,[A(it).isAdvanceFilterEnabled()?(r(),h("div",B1e,[n(je,{class:"fct-advanced-filter-toggle",onChange:he[0]||(he[0]=ee=>{A(it).onFilterTypeChanged(ee)}),"active-value":"advanced","inactive-value":"simple",modelValue:A(it).data.filterType,"onUpdate:modelValue":he[1]||(he[1]=ee=>A(it).data.filterType=ee),"active-text":le.$t("Advanced Filter"),size:"small"},null,8,["modelValue","active-text"])])):x("",!0),A(it).isUsingAdvanceFilter()?x("",!0):(r(),h("div",x1e,[A(it).isSearching()?x("",!0):(r(),E(Xe,{key:0,effect:"light",content:le.$t("Search"),placement:"top","popper-class":"fct-tooltip"},{default:d(()=>[n(at,{tag:"button",onClick:Ge(S,["prevent"])},{default:d(()=>[n(Y,{name:"Search"})]),_:1})]),_:1},8,["content"]))]))])]),n(Yc,{table:A(it)},null,8,["table"]),A(it).isSearching()&&!A(it).isUsingAdvanceFilter()?(r(),h("div",S1e,[o("div",F1e,[n(mt,{ref:"search-input",onClear:he[2]||(he[2]=()=>{A(it).search()}),onKeyup:he[3]||(he[3]=xa(()=>{A(it).search()},["enter"])),modelValue:A(it).data.search,"onUpdate:modelValue":he[4]||(he[4]=ee=>A(it).data.search=ee),type:"text",placeholder:le.$t("Search"),clearable:""},{prefix:d(()=>[n(Y,{name:"Search"})]),_:1},8,["modelValue","placeholder"]),o("div",$1e,m(A(it).getSearchHint()),1)]),n(Ye,{text:"",onClick:he[5]||(he[5]=()=>{A(it).closeSearch()})},{default:d(()=>[R(m(le.$t("Cancel")),1)]),_:1})])):x("",!0)]),_:1}),n(ke,{class:"p-0"},{default:d(()=>[o("div",E1e,[i.value.length>0?(r(),h("div",U1e,[o("h5",I1e,[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",Q1e,m(le.$t("of"))+" "+m(_.value.total)+" "+m(le.$t("total"))+" · "+m(w.value)+" "+m(le.$t("next")),1)):x("",!0)]),o("div",D1e,[n(Ye,{disabled:A(ye)===0,onClick:gt,size:"small"},{default:d(()=>[he[14]||(he[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(Ye,{disabled:A(ye)===0,onClick:Rt,size:"small",type:"danger",plain:""},{default:d(()=>[he[15]||(he[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(Ye,{class:de({"is-active":A(Ce)}),disabled:A(ye)<2&&!A(Ce),onClick:A(ve),size:"small"},{default:d(()=>[he[16]||(he[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(Ce)?le.$t("Unlink"):le.$t("Link")),1)]),_:1,__:[16]},8,["class","disabled","onClick"]),n(et,{modelValue:J.value,"onUpdate:modelValue":he[6]||(he[6]=ee=>J.value=ee),label:le.$t("Pin Actions")},null,8,["modelValue","label"]),n(pe,{trigger:"click",placement:"bottom-end",width:"240","popper-class":"filter-popover"},{reference:d(()=>[o("span",null,[n(Xe,{effect:"light",content:le.$t("Toggle columns"),placement:"top","popper-class":"fct-tooltip"},{default:d(()=>[n(at,{tag:"button",size:"small"},{default:d(()=>[n(Y,{name:"ColumnIcon"})]),_:1})]),_:1},8,["content"])])]),default:d(()=>[o("div",V1e,[o("h3",T1e,m(le.$t("Columns")),1),n(It,{modelValue:A(it).data.visibleColumns,"onUpdate:modelValue":he[7]||(he[7]=ee=>A(it).data.visibleColumns=ee),class:"fct-checkbox-blocks",onChange:he[8]||(he[8]=ee=>A(it).handleColumnVisibilityChange())},{default:d(()=>[(r(!0),h(P,null,te(A(it).getToggleableColumns(),ee=>(r(),E(et,{key:ee.value,value:ee.value,label:le.$t(ee.label)},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])]),_:1})])])):x("",!0),o("div",M1e,[i.value.length>0?(r(),h("div",{key:0,class:de(["relative",{"is-link-mode":A(Ce),"is-shift-held":Be.value}])},[n(Bf,{columns:Qt.value,"sticky-last":J.value,onScroll:il,onResizeEnd:qt},{"header-first":d(()=>[Wt(n(et,{checked:A(ye)>0&&A(ye)===Ue.value.length,onChange:he[9]||(he[9]=ee=>A(oe)(Ue.value))},null,8,["checked"]),[[A(tye),A(ye)>0&&A(ye)[R(m(le.$t("Actions")),1)]),default:d(()=>[ea.value>0?(r(),h("tr",L1e,[o("td",{colspan:Qt.value.length+1,style:ra({height:ea.value+"px",padding:0,border:"none"})},null,12,R1e)])):x("",!0),(r(!0),h(P,null,te(vt.value,ee=>{var Ne,pt,De,xt,Wa,se,me,Qe,Le,qe,At,tt,Ut,jt,Ta,$t,Zt,ha;return r(),h(P,{key:ee.productId},[o("tr",{class:de(["bulk-product-row",{"is-dirty":Q(ee.product),"is-saving":V(ee.product),"is-saved":I(ee.product),"has-product-error":H(ee.product),"is-selected":A(Ee)(`p:${ee.productId}`)}]),onClick:Ze=>Re(`p:${ee.productId}`,Ze)},[o("td",{class:"bulk-checkbox-cell",onClick:Ze=>A(ae)(`p:${ee.productId}`,Ze,Ue.value)},[n(et,{"model-value":A(Ee)(`p:${ee.productId}`),tabindex:"-1"},null,8,["model-value"])],8,P1e),o("td",H1e,[o("div",N1e,[ee.hasVariants?(r(),h("button",{key:0,class:"bulk-collapse-btn",onClick:Ge(Ze=>Fe(ee.product),["prevent"]),title:ot(ee.product)?le.$t("Expand variants"):le.$t("Collapse variants")},[(r(),h("svg",{class:de(["bulk-collapse-icon",{"is-collapsed":ot(ee.product)}]),width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},he[17]||(he[17]=[o("path",{d:"M6 4L10 8L6 12",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2)),ot(ee.product)?(r(),h("span",G1e,m(ee.variantCount),1)):x("",!0)],8,K1e)):x("",!0),n(mt,{class:de(["fct-bulk-input",{"is-error":ne(ee.product,"post_title")}]),modelValue:ee.product.post_title,"onUpdate:modelValue":[Ze=>ee.product.post_title=Ze,Ze=>{F(ee.product),We("title",Ze,`p:${ee.productId}`)}],placeholder:le.$t("Product title"),disabled:M(ee.product),size:"small"},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),V(ee.product)?(r(),h("span",{key:1,class:"bulk-status-icon is-syncing",title:le.$t("Saving...")},[n(_e,{class:"is-loading",size:14},{default:d(()=>[n(A(en))]),_:1})],8,z1e)):W(ee.product)||s(ee.product)&&H(ee.product)?(r(),E(Xe,{key:2,content:j(ee.product),placement:"top"},{default:d(()=>[o("span",j1e,[n(_e,{size:16},{default:d(()=>[n(A(Vo))]),_:1})])]),_:2},1032,["content"])):Q(ee.product)?(r(),h("button",{key:3,class:"bulk-inline-save",disabled:M(ee.product),onClick:Ge(Ze=>z(ee.product),["prevent"]),title:le.$t("Save")},he[18]||(he[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,q1e)):x("",!0)])]),ht("image")?(r(),h("td",Y1e,[n(yl,{modelValue:ee.product.gallery,"onUpdate:modelValue":Ze=>ee.product.gallery=Ze,onChange:Ze=>F(ee.product)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):x("",!0),ht("sku")?(r(),h("td",W1e,[((pt=(Ne=ee.product)==null?void 0:Ne.detail)==null?void 0:pt.variation_type)==="simple"&&((De=ee.product.variants)!=null&&De[0])?(r(),E(mt,{key:0,class:de(["fct-bulk-input",{"is-error":ne(ee.product,"variants.0.sku")}]),modelValue:ee.product.variants[0].sku,"onUpdate:modelValue":[Ze=>ee.product.variants[0].sku=Ze,Ze=>{F(ee.product),We("sku",Ze,`p:${ee.productId}`)}],placeholder:"SKU",size:"small",disabled:M(ee.product)},null,8,["modelValue","onUpdate:modelValue","disabled","class"])):(r(),h("span",J1e,"—"))])):x("",!0),ht("categories")?(r(),h("td",X1e,[n(xf,{modelValue:ee.product.categories,"onUpdate:modelValue":Ze=>ee.product.categories=Ze,options:A(it).data.categoryOptions,disabled:M(ee.product),onChange:Ze=>{U(ee.product,Ze),We("categories",ee.product.categories,`p:${ee.productId}`)}},null,8,["modelValue","onUpdate:modelValue","options","disabled","onChange"])])):x("",!0),ht("description")?(r(),h("td",Z1e,[n(li,{value:ee.product.post_content,placeholder:le.$t("Description"),onClick:Ze=>Gt(ee.product,"post_content")},null,8,["value","placeholder","onClick"])])):x("",!0),ht("short_description")?(r(),h("td",ebe,[n(li,{value:ee.product.post_excerpt,placeholder:le.$t("Short description"),onClick:Ze=>Gt(ee.product,"post_excerpt")},null,8,["value","placeholder","onClick"])])):x("",!0),ht("status")?(r(),h("td",tbe,[n(Me,{modelValue:ee.product.post_status,"onUpdate:modelValue":Ze=>ee.product.post_status=Ze,size:"small",class:de({"is-field-error":ne(ee.product,"post_status")}),disabled:M(ee.product),onChange:Ze=>{F(ee.product),We("status",ee.product.post_status,`p:${ee.productId}`)}},{default:d(()=>[n(Oe,{label:le.$t("Published"),value:"publish"},null,8,["label"]),n(Oe,{label:le.$t("Draft"),value:"draft"},null,8,["label"])]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):x("",!0),ht("product_type")?(r(),h("td",abe,[o("span",lbe,m(Ya((Wa=(xt=ee.product)==null?void 0:xt.detail)==null?void 0:Wa.fulfillment_type)),1)])):x("",!0),ht("pricing_type")?(r(),h("td",sbe,[o("span",nbe,m(ma((me=(se=ee.product)==null?void 0:se.detail)==null?void 0:me.variation_type)),1)])):x("",!0),ht("payment_type")?(r(),h("td",obe,[n(Zo,{variant:s(ee.product)?(Qe=ee.product.variants)==null?void 0:Qe[0]:null,disabled:M(ee.product),"has-error":ne(ee.product,"variants.0.other_info.payment_type"),onPaymentTypeChange:Ze=>{var aa;B(ee.product,Ze),We("payment_type",(aa=Ze.other_info)==null?void 0:aa.payment_type,`p:${ee.productId}`)},onChange:Ze=>F(ee.product)},null,8,["variant","disabled","has-error","onPaymentTypeChange","onChange"])])):x("",!0),ht("interval")?(r(),h("td",ibe,[n(ei,{variant:s(ee.product)?(Le=ee.product.variants)==null?void 0:Le[0]:null,disabled:M(ee.product),"has-error":ne(ee.product,"variants.0.other_info.repeat_interval"),onChange:Ze=>{var aa,Ha,Je;F(ee.product),We("interval",(Je=(Ha=(aa=ee.product.variants)==null?void 0:aa[0])==null?void 0:Ha.other_info)==null?void 0:Je.repeat_interval,`p:${ee.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),ht("trial_days")?(r(),h("td",rbe,[n(ti,{variant:s(ee.product)?(qe=ee.product.variants)==null?void 0:qe[0]:null,disabled:M(ee.product),"has-error":ne(ee.product,"variants.0.other_info.trial_days"),onChange:Ze=>{var aa,Ha,Je;F(ee.product),We("trial_days",(Je=(Ha=(aa=ee.product.variants)==null?void 0:aa[0])==null?void 0:Ha.other_info)==null?void 0:Je.trial_days,`p:${ee.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),ht("best_price")?(r(),h("td",dbe,[n(Xo,{variant:s(ee.product)?(At=ee.product.variants)==null?void 0:At[0]:null,disabled:M(ee.product),"has-error":ne(ee.product,"variants.0.item_price"),onChange:Ze=>{var aa,Ha;F(ee.product),We("price",(Ha=(aa=ee.product.variants)==null?void 0:aa[0])==null?void 0:Ha.item_price,`p:${ee.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),ht("compare_price")?(r(),h("td",ube,[n(ai,{variant:s(ee.product)?(tt=ee.product.variants)==null?void 0:tt[0]:null,disabled:M(ee.product),"has-error":ne(ee.product,"variants.0.compare_price"),onChange:Ze=>{var aa,Ha;F(ee.product),We("compare_price",(Ha=(aa=ee.product.variants)==null?void 0:aa[0])==null?void 0:Ha.compare_price,`p:${ee.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),ht("track_quantity")?(r(),h("td",cbe,[(Ut=ee.product)!=null&&Ut.detail?(r(),E(je,{key:0,modelValue:ee.product.detail.manage_stock,"onUpdate:modelValue":Ze=>ee.product.detail.manage_stock=Ze,"active-value":1,"inactive-value":0,disabled:M(ee.product),onChange:Ze=>{F(ee.product),A(it).syncStockStatus(ee.product),We("manage_stock",ee.product.detail.manage_stock,`p:${ee.productId}`)}},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])):x("",!0)])):x("",!0),ht("stock")?(r(),h("td",Abe,[(Ta=(jt=ee.product)==null?void 0:jt.detail)!=null&&Ta.manage_stock&&((Zt=($t=ee.product)==null?void 0:$t.detail)==null?void 0:Zt.variation_type)==="simple"&&((ha=ee.product.variants)!=null&&ha[0])?(r(),E(mt,{key:0,class:"fct-bulk-input",placeholder:le.$t("e.g 10"),size:"small",modelValue:ee.product.variants[0].available,"onUpdate:modelValue":[Ze=>ee.product.variants[0].available=Ze,Ze=>{ee.product.variants[0].total_stock=Ze,F(ee.product),A(it).syncStockStatus(ee.product),We("stock",Ze,`p:${ee.productId}`)}],disabled:M(ee.product)},null,8,["placeholder","modelValue","onUpdate:modelValue","disabled"])):(r(),h("span",pbe,"—"))])):x("",!0),o("td",{class:de(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":J.value}])},[o("div",fbe,[ee.product.view_url?(r(),E(at,{key:0,tag:"a",size:"x-small",href:ee.product.view_url,target:"_blank",title:le.$t("View Product")},{default:d(()=>[n(Y,{name:"External"})]),_:2},1032,["href","title"])):x("",!0),n(at,{tag:"button",size:"x-small",onClick:Ge(Ze=>ue(ee.product),["prevent"]),disabled:p.value||M(ee.product)||O(ee.product),title:le.$t("Duplicate")},{default:d(()=>[O(ee.product)?(r(),E(_e,{key:0,class:"is-loading",size:14},{default:d(()=>[n(A(en))]),_:1})):(r(),E(Y,{key:1,name:"Copy"}))]),_:2},1032,["onClick","disabled","title"]),n(at,{tag:"button",size:"x-small",hover:"danger",onClick:Ge(Ze=>Tt(ee.product),["prevent"]),disabled:p.value||M(ee.product)||L(ee.product),title:le.$t("Delete")},{default:d(()=>[L(ee.product)?(r(),E(_e,{key:0,class:"is-loading",size:14},{default:d(()=>[n(A(en))]),_:1})):(r(),E(Y,{key:1,name:"Delete"}))]),_:2},1032,["onClick","disabled","title"])])],2)],10,O1e),ee.hasVariants?(r(),h("tr",mbe,[o("td",{colspan:Qt.value.length+1,class:"!p-0 !border-b-0"},[n(ya,{accordion:"",visible:!ee.collapsed,duration:200},{default:d(()=>[o("table",_be,[o("colgroup",null,[he[19]||(he[19]=o("col",{style:{width:"40px"}},null,-1)),(r(!0),h(P,null,te(Qt.value,(Ze,aa)=>(r(),h("col",{key:aa,style:ra({width:Ze.width+"px"})},null,4))),128))]),o("tbody",null,[(r(!0),h(P,null,te(ee.product.variants,(Ze,aa)=>{var Ha,Je;return r(),h("tr",{key:Ze.id||aa,class:de(["bulk-variation-row",{"is-selected":A(Ee)(`v:${Ze.id}`)}]),onClick:Lt=>Re(`v:${Ze.id}`,Lt)},[o("td",gbe,[n(et,{"model-value":A(Ee)(`v:${Ze.id}`),tabindex:"-1",onChange:Lt=>A(ae)(`v:${Ze.id}`,Lt,Ue.value)},null,8,["model-value","onChange"])]),o("td",ybe,[o("div",bbe,[he[20]||(he[20]=o("span",{class:"text-gray-300 text-xs"},"└",-1)),n(mt,{size:"small",modelValue:Ze.variation_title,"onUpdate:modelValue":[Lt=>Ze.variation_title=Lt,Lt=>{F(ee.product),We("title",Lt,`v:${Ze.id}`)}],placeholder:le.$t("Variation title"),disabled:M(ee.product),class:de({"is-error":ce(ee.product,aa,"variation_title")})},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),G(ee.product,aa)?(r(),E(Xe,{key:0,content:Z(ee.product,aa),placement:"top"},{default:d(()=>[o("span",wbe,[n(_e,{size:14},{default:d(()=>[n(A(Vo))]),_:1})])]),_:2},1032,["content"])):x("",!0)])]),ht("image")?(r(),h("td",Cbe,[n(yl,{modelValue:Ze.media,"onUpdate:modelValue":Lt=>Ze.media=Lt,onChange:Lt=>F(ee.product)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):x("",!0),ht("sku")?(r(),h("td",kbe,[n(mt,{class:de(["fct-bulk-input",{"is-error":ce(ee.product,aa,"sku")}]),size:"small",modelValue:Ze.sku,"onUpdate:modelValue":[Lt=>Ze.sku=Lt,Lt=>{F(ee.product),We("sku",Lt,`v:${Ze.id}`)}],placeholder:le.$t("SKU"),disabled:M(ee.product)},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"])])):x("",!0),ht("categories")?(r(),h("td",Bbe,he[21]||(he[21]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):x("",!0),ht("description")?(r(),h("td",xbe,he[22]||(he[22]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):x("",!0),ht("short_description")?(r(),h("td",Sbe,he[23]||(he[23]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):x("",!0),ht("status")?(r(),h("td",Fbe,he[24]||(he[24]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):x("",!0),ht("product_type")?(r(),h("td",$be,he[25]||(he[25]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):x("",!0),ht("pricing_type")?(r(),h("td",Ebe,he[26]||(he[26]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):x("",!0),ht("payment_type")?(r(),h("td",Ube,[n(Zo,{variant:Ze,disabled:M(ee.product),"has-error":ce(ee.product,aa,"other_info.payment_type"),onPaymentTypeChange:Lt=>{var os;B(ee.product,Lt),We("payment_type",(os=Lt.other_info)==null?void 0:os.payment_type,`v:${Ze.id}`)},onChange:Lt=>F(ee.product)},null,8,["variant","disabled","has-error","onPaymentTypeChange","onChange"])])):x("",!0),ht("interval")?(r(),h("td",Ibe,[n(ei,{variant:Ze,disabled:M(ee.product),"has-error":ce(ee.product,aa,"other_info.repeat_interval"),onChange:Lt=>{var os;F(ee.product),We("interval",(os=Ze.other_info)==null?void 0:os.repeat_interval,`v:${Ze.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),ht("trial_days")?(r(),h("td",Qbe,[n(ti,{variant:Ze,disabled:M(ee.product),"has-error":ce(ee.product,aa,"other_info.trial_days"),onChange:Lt=>{var os;F(ee.product),We("trial_days",(os=Ze.other_info)==null?void 0:os.trial_days,`v:${Ze.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),ht("best_price")?(r(),h("td",Dbe,[n(Xo,{variant:Ze,disabled:M(ee.product),"has-error":ce(ee.product,aa,"item_price"),onChange:Lt=>{F(ee.product),We("price",Ze.item_price,`v:${Ze.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),ht("compare_price")?(r(),h("td",Vbe,[n(ai,{variant:Ze,disabled:M(ee.product),"has-error":ce(ee.product,aa,"compare_price"),onChange:Lt=>{F(ee.product),We("compare_price",Ze.compare_price,`v:${Ze.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):x("",!0),ht("track_quantity")?(r(),h("td",Tbe,he[27]||(he[27]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):x("",!0),ht("stock")?(r(),h("td",Mbe,[(Je=(Ha=ee.product)==null?void 0:Ha.detail)!=null&&Je.manage_stock?(r(),E(mt,{key:0,class:"fct-bulk-input",placeholder:le.$t("e.g 10"),size:"small",modelValue:Ze.available,"onUpdate:modelValue":[Lt=>Ze.available=Lt,Lt=>{Ze.total_stock=Lt,F(ee.product),A(it).syncStockStatus(ee.product),We("stock",Lt,`v:${Ze.id}`)}],disabled:M(ee.product)},null,8,["placeholder","modelValue","onUpdate:modelValue","disabled"])):(r(),h("span",Lbe,"—"))])):x("",!0),o("td",{class:de(["text-center",{"sticky-col sticky-col-right":J.value}])},[o("div",Rbe,[n(at,{tag:"button",size:"x-small",onClick:Ge(Lt=>ie(ee.product,Ze),["prevent"]),disabled:p.value||M(ee.product),title:le.$t("Duplicate")},{default:d(()=>[n(Y,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(at,{tag:"button",size:"x-small",hover:"danger",onClick:Ge(Lt=>Dt(ee.product,Ze),["prevent"]),disabled:p.value||M(ee.product),title:le.$t("Delete")},{default:d(()=>[n(Y,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,vbe)}),128))])])]),_:2},1032,["visible"])],8,hbe)])):x("",!0)],64)}),128)),ta.value>0?(r(),h("tr",Obe,[o("td",{colspan:Qt.value.length+1,style:ra({height:ta.value+"px",padding:0,border:"none"})},null,12,Pbe)])):x("",!0)]),_:1},8,["columns","sticky-last"])],2)):c.value?c.value?(r(),h("div",Kbe,[n(_e,{class:"is-loading mr-2"},{default:d(()=>he[28]||(he[28]=[o("i",{class:"el-icon-loading"},null,-1)])),_:1,__:[28]}),o("span",Gbe,m(le.$t("Loading products...")),1)])):x("",!0):(r(),h("div",Hbe,[o("p",Nbe,m(le.$t("No products found.")),1)]))]),_.value.hasMore&&i.value.length>0&&c.value?(r(),h("div",zbe,[n(_e,{class:"is-loading mr-2"},{default:d(()=>he[29]||(he[29]=[o("i",{class:"el-icon-loading"},null,-1)])),_:1,__:[29]}),o("span",jbe,m(le.$t("Loading"))+" "+m(w.value)+" "+m(le.$t("more...")),1)])):x("",!0)])]),_:1})]),_:1})]),n(ct,{modelValue:_t.value.visible,"onUpdate:modelValue":he[12]||(he[12]=ee=>_t.value.visible=ee),title:Pt.value,width:"700px","close-on-click-modal":!1,onClosed:he[13]||(he[13]=ee=>_t.value.product=null)},{footer:d(()=>[n(Ye,{onClick:he[11]||(he[11]=ee=>_t.value.visible=!1)},{default:d(()=>[R(m(le.$t("Cancel")),1)]),_:1}),n(Ye,{type:"primary",onClick:St},{default:d(()=>[R(m(le.$t("Save")),1)]),_:1})]),default:d(()=>[_t.value.visible&&_t.value.field==="post_content"?(r(),E(ls,{key:0,"model-value":_t.value.value,height:300,onUpdate:bt},null,8,["model-value"])):x("",!0),_t.value.visible&&_t.value.field==="post_excerpt"?(r(),E(mt,{key:1,modelValue:_t.value.value,"onUpdate:modelValue":he[10]||(he[10]=ee=>_t.value.value=ee),type:"textarea",rows:6,placeholder:le.$t("Short description")},null,8,["modelValue","placeholder"])):x("",!0)]),_:1},8,["modelValue","title"])])}}},Ef=ze.get("payment_routes");for(const e of Ef)e.props=!0;const Jbe=ze.get("storage_driver_routes"),Uf=(Jbe||[]).filter(e=>e.name!=="s3");for(const e of Uf)e.props=!0;var Xbe={dashboard:{name:"dashboard",path:"/",component:YB,meta:{active_menu:"dashboard",title:u("Dashboard")}},orders:{path:"/orders",component:F$,meta:{active_menu:"orders",title:u("Orders")},children:[{name:"orders",path:"",component:vv,meta:{active_menu:"orders",title:u("Orders"),permission:"orders/view"}},{name:"view_order",path:":order_id(\\d+)/view",component:ND,props:!0,meta:{active_menu:"orders",title:u("View Order"),permission:["orders/view","orders/manage"]}},{name:"add_order",path:"add",component:bV,props:!0,meta:{active_menu:"orders",title:u("Create Order"),permission:"orders/create"}}]},products:{name:"products",path:"/products",component:h7,meta:{active_menu:"products",title:u("Products"),permission:"products/view"}},product_route:{path:"/products/:product_id(\\d+)",component:cT,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:lq,meta:{active_menu:"products",title:u("Product Edit"),permission:"products/edit"}},{name:"product_integrations",path:"integrations",props:!0,component:gc,meta:{active_menu:"products",title:u("Integrations"),permission:"integrations/manage"}},{name:"product_integration_feed_editor",path:"integrations/:integration_id/:integration_name",component:nc,meta:{active_menu:"products",title:u("Edit Integration"),permission:"integrations/manage"}},{name:"SingleIntegration",path:"integrations/:integration_id",props:!0,component:AY,meta:{active_menu:"products",title:u("Integrations"),permission:"integrations/manage"}},{name:"product_upgrade_paths",path:"upgrade-paths",props:!0,component:Gq,meta:{active_menu:"products",title:u("Upgrade Paths"),permission:"integrations/manage"}},{name:"Integrations",path:"integrations",props:!0,component:gc,meta:{active_menu:"integrations",title:u("Product Integrations"),permission:"integrations/manage"}}]},product_bulk_insert:{name:"product_bulk_insert",path:"/products/bulk-insert",component:v1e,meta:{active_menu:"products",title:u("Product Bulk Insert"),permission:"products/create"}},product_bulk_edit:{name:"product_bulk_edit",path:"/products/bulk-edit",component:Wbe,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:jJ,meta:{active_menu:"products",title:u("Inventory"),permission:"products/view"}},customers:{path:"/customers",component:Ig,meta:{active_menu:"customers",permission:["customers/view","customers/manage"]},children:[{name:"customers",path:"/customers",component:s_,meta:{active_menu:"customers",title:u("Customers"),permission:"customers/view"}},{name:"view_customer",path:":customer_id(\\d+)/view",component:xU,props:!0,meta:{active_menu:"customers",title:u("View Customer"),permission:"customers/view"}}]},reports:{name:"reports",path:"/reports",component:dte,meta:{active_menu:"reports",permission:"reports/view"},children:[{name:"reports_overview",path:"overview",component:mce,meta:{title:u("Overview"),permission:"reports/view"}},{name:"reports_sales",path:"sales",component:Rte,meta:{title:u("Sales"),permission:"reports/view"}},{name:"reports_orders",path:"orders",component:tne,meta:{title:u("Orders"),permission:"reports/view"}},{name:"reports_revenue",path:"revenue",component:Vae,meta:{title:u("Revenue"),permission:"reports/view"}},{name:"reports_refunds",path:"refunds",component:Lne,meta:{title:u("Refunds"),permission:"reports/view"}},{name:"reports_subscriptions",path:"subscriptions",component:Eoe,meta:{title:u("Subscriptions"),permission:"reports/view"}},{name:"subscriptions-retention",path:"subscriptions/subscriptions-retention",component:Kie,meta:{title:u("Retention"),permission:"reports/view"}},{name:"subscriptions-cohorts",path:"subscriptions/subscriptions-cohorts",component:()=>Yt(()=>import("./chunks/Cohort.js?ver=1.6.5"),[],import.meta.url),meta:{title:u("Cohorts"),permission:"reports/view"}},{name:"future_renewals",path:"subscriptions/future-renewals",component:Yoe,meta:{title:u("Future Renewals"),permission:"reports/view"}},{name:"reports_products",path:"products",component:bue,meta:{title:u("Product"),permission:"reports/view"}},{name:"reports_customer",path:"customer",component:mre,meta:{title:u("Customer"),permission:"reports/view"}},{name:"reports_sources",path:"sources",component:Xre,meta:{title:u("Sources"),permission:"reports/view"}}]},settings:{path:"/settings",component:vE,meta:{active_menu:"settings",title:u("Settings"),permission:["store/settings","store/sensitive"]},children:[{name:"store_settings",path:"store-settings",component:IV,meta:{active_menu:"settings",title:u("Settings"),permission:"store/settings"},children:[{name:"store_setup",path:"",component:Jl,meta:{title:u("Store Setup")}},{name:"pages_setup",path:"pages_setup",component:Jl,meta:{title:u("Pages Setup")}},{name:"single_product_setup",path:"single_product_setup",component:Jl,meta:{title:u("Product Page")}},{name:"cart_and_checkout",path:"cart_and_checkout",component:Jl,meta:{title:u("Cart & Checkout")}},{name:"subscriptions_setup",path:"subscriptions_setup",component:Jl,meta:{title:u("Subscriptions")}},{name:"checkout_fields",path:"checkout_fields",component:cge,meta:{}},{name:"appearance",path:"appearance",component:Jl,meta:{title:u("Appearance")}}]},{name:"compliance",path:"compliance",component:Jl,meta:{active_menu:"settings",title:u("Compliance"),permission:"store/settings"}},...ze.get("addon_settings_routes",[]).map(e=>({component:Jl,...e})),{name:"email_notifications",path:"email_notifications",component:vX,meta:{active_menu:"settings",title:u("Notifications"),permission:"store/sensitive"}},{name:"email_mailing_settings",path:"email_mailing_settings",component:cAe,meta:{active_menu:"settings",title:u("Mailing Settings"),permission:"store/sensitive"}},{name:"reminders",path:"email_mailing_settings/reminders",component:Jl,meta:{active_menu:"settings",title:u("Reminders"),permission:"store/sensitive"}},{name:"email_digest_settings",path:"email_digest_settings",component:gAe,meta:{active_menu:"settings",title:u("Store Digest"),permission:"store/sensitive"}},{path:"email_notifications/:name/",name:"email_notifications/edit",component:jX,meta:{active_menu:"settings",title:u("Edit Notification"),permission:"store/sensitive"},props:!0},{path:"email_notifications/add",name:"email_notifications/add",component:mZ,meta:{active_menu:"settings",title:u("Add Notification"),permission:"store/sensitive"}},{name:"licensing",path:"licensing",component:tT,meta:{active_menu:"settings",title:u("Licensing"),permission:"store/sensitive"}},{name:"payments",path:"payments",component:H$,meta:{active_menu:"settings",title:u("Payment Settings"),permission:"is_super_admin"}},{name:"gateway",component:hS,path:"payments",children:Ef,props:!0,meta:{active_menu:"settings",title:u("Payment Settings"),permission:"is_super_admin"}},{name:"invoice-packing",path:"invoice-packing",component:kv,meta:{active_menu:"settings",title:u("Invoice & Packing"),permission:"is_super_admin"}},{name:"pdf-template",path:"pdf-template",component:xv,meta:{active_menu:"settings",title:u("PDF Templates"),permission:"is_super_admin"},children:[{name:"pdf-template-list",path:"",component:Nv,meta:{active_menu:"settings",title:u("PDF Templates"),permission:"is_super_admin"}},{name:"pdf-template-settings",path:"settings",component:Fg,meta:{active_menu:"settings",title:u("PDF Template Settings"),permission:"is_super_admin"}},{name:"edit-pdf-template",path:":template/edit",component:rg,props:!0,meta:{active_menu:"settings",title:u("Edit PDF Template"),permission:"is_super_admin"}}]},{name:"roles",path:"roles",component:rE,meta:{active_menu:"settings",title:u("Role Settings"),permission:"is_super_admin"}},{name:"addons",path:"addons",component:Vce,meta:{active_menu:"settings",title:u("Features & addon"),permission:"is_super_admin"}},{name:"coupons",path:"coupons",component:Fc,meta:{active_menu:"coupons",title:u("Coupons Settings"),permission:"is_super_admin"}},{name:"storage",path:"storage",component:iZ,meta:{active_menu:"settings",title:u("Storage Providers"),permission:"is_super_admin"}},{name:"s3",path:"storage/s3",component:wc,props:!0,meta:{active_menu:"settings",title:u("S3"),permission:"is_super_admin"}},{name:"payment-design",path:"payments/:method/design",component:bS,meta:{active_menu:"settings",title:u("Gateway"),permission:"is_super_admin"},props:!0},{name:"drivers",component:wc,path:"storage",children:Uf,props:!0,meta:{active_menu:"settings",title:u("Storage Settings"),permission:"is_super_admin"}},{name:"tax_settings",path:"tax_settings",component:wAe,meta:{active_menu:"settings",title:u("Tax Settings"),permission:"store/settings"},children:[{name:"tax_configurations",path:"",component:Qpe,meta:{}},{name:"tax_rates",path:"tax_rates",component:Ype,meta:{}},{name:"eu",path:"eu",component:C_e,meta:{}},{name:"eu_country_tax_rates",path:"eu/:country/:group",component:Sc,props:!0,meta:{}},{name:"tax-rates-country-single",path:"tax_rates_country_single/:country/:group",component:Sc,props:!0,meta:{}}]}]},integrations:{name:"integrations",path:"/integrations",component:dx,meta:{active_menu:"integrations",title:u("Integrations"),permission:"integrations/view"}},global_feed_editor:{name:"feed_editor",path:"/global_integrations/:integration_id/:integration_name",component:nc,meta:{active_menu:"integrations",title:u("Global Integrations"),permission:"integrations/view"}},integration_editor:{name:"integration_editor",path:"/integrations/:integration_name",component:GS,meta:{active_menu:"integrations",title:u("Integrations"),permission:"integrations/manage"}},coupons:{name:"coupons",path:"/coupons",component:Fc,meta:{active_menu:"coupons",title:u("Coupons"),permission:"coupons/view"}},logs:{name:"logs",path:"/logs",component:aee,meta:{active_menu:"logs",title:u("Logs"),permission:"is_super_admin"}},taxes:{name:"taxes",path:"/taxes",component:wme,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:Kve,props:!0,meta:{active_menu:"coupons",title:u("Coupons"),permission:"coupons/manage"}},onboarding:{path:"/onboarding",component:x$,name:"onboarding",meta:{active_menu:"dashboard",title:u("Onboarding"),permission:"is_super_admin"}}};const Zbe={class:"fct-theme-button-container"},e0e={class:"theme-selected-button"},t0e={__name:"ThemeToggle",setup(e){const t=T(Te.MODE_LIGHT),a=c=>{t.value!==c&&(t.value=c,Te.apply(c))},l=[{value:"light",label:u("Light"),icon:"Sun"},{value:"dark",label:u("Dark"),icon:"Moon"},{value:"system",label:u("System"),icon:"Tools"}];Ds(()=>{const c=document.getElementById("theme-button-container");if(c){const p=c.querySelector(".fct-theme-button-container");p&&p.remove()}t.value=Te.getCurrentTheme(),t.value.toString().startsWith(Te.MODE_SYSTEM)&&(t.value=Te.MODE_SYSTEM)});const s=c=>{xe(()=>{t.value=Te.getCurrentTheme()})},i=c=>{a(c)};return Ie(()=>{window.addEventListener(Te.THEME_CHANGE_EVENT,s,!1)}),cl(()=>{window.removeEventListener(Te.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",Zbe,[n(g,{placement:"bottom-end",trigger:"click","popper-class":"fct-dropdown",onCommand:i},{dropdown:d(()=>[n(_,null,{default:d(()=>[(r(),h(P,null,te(l,y=>n(f,{key:y.value,command:y.value,class:de({active:t.value===y.value})},{default:d(()=>[n(Y,{name:y.icon},null,8,["name"]),R(" "+m(y.label),1)]),_:2},1032,["command","class"])),64))]),_:1})]),default:d(()=>[o("div",e0e,[t.value==="light"?(r(),E(Y,{key:0,name:"Sun"})):t.value==="dark"?(r(),E(Y,{key:1,name:"Moon"})):t.value==="system"?(r(),E(Y,{key:2,name:"Tools"})):x("",!0)])]),_:1})])}}};function ns(e){return Array.isArray?Array.isArray(e):Df(e)==="[object Array]"}function a0e(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function l0e(e){return e==null?"":a0e(e)}function Hl(e){return typeof e=="string"}function If(e){return typeof e=="number"}function s0e(e){return e===!0||e===!1||n0e(e)&&Df(e)=="[object Boolean]"}function Qf(e){return typeof e=="object"}function n0e(e){return Qf(e)&&e!==null}function hl(e){return e!=null}function Ar(e){return!e.trim().length}function Df(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const o0e="Incorrect 'index' type",i0e=e=>`Invalid value for key ${e}`,r0e=e=>`Pattern length exceeds max of ${e}.`,d0e=e=>`Missing ${e} property in key`,u0e=e=>`Property 'weight' in key '${e}' must be a positive integer`,Dc=Object.prototype.hasOwnProperty;class c0e{constructor(t){this._keys=[],this._keyMap={};let a=0;t.forEach(l=>{let s=Vf(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 Vf(e){let t=null,a=null,l=null,s=1,i=null;if(Hl(e)||ns(e))l=e,t=Vc(e),a=jr(e);else{if(!Dc.call(e,"name"))throw new Error(d0e("name"));const c=e.name;if(l=c,Dc.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(u0e(c));t=Vc(c),a=jr(c),i=e.getFn}return{path:t,id:a,weight:s,src:l,getFn:i}}function Vc(e){return ns(e)?e:e.split(".")}function jr(e){return ns(e)?e.join("."):e}function A0e(e,t){let a=[],l=!1;const s=(i,c,p)=>{if(hl(i))if(!c[p])a.push(i);else{let f=c[p];const _=i[f];if(!hl(_))return;if(p===c.length-1&&(Hl(_)||If(_)||s0e(_)))a.push(l0e(_));else if(ns(_)){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,Hl(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();Hl(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(hl(c)){if(ns(c)){let p=[];const f=[{nestedArrIndex:-1,value:c}];for(;f.length;){const{nestedArrIndex:_,value:g}=f.pop();if(hl(g))if(Hl(g)&&!Ar(g)){let y={v:g,i:_,n:this.norm.get(g)};p.push(y)}else ns(g)&&g.forEach((y,v)=>{f.push({nestedArrIndex:v,value:y})})}l.$[i]=p}else if(Hl(c)&&!Ar(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 Tf(e,t,{getFn:a=Et.getFn,fieldNormWeight:l=Et.fieldNormWeight}={}){const s=new Md({getFn:a,fieldNormWeight:l});return s.setKeys(e.map(Vf)),s.setSources(t),s.create(),s}function g0e(e,{getFn:t=Et.getFn,fieldNormWeight:a=Et.fieldNormWeight}={}){const{keys:l,records:s}=e,i=new Md({getFn:t,fieldNormWeight:a});return i.setKeys(l),i.setIndexRecords(s),i}function ko(e,{errors:t=0,currentLocation:a=0,expectedLocation:l=0,distance:s=Et.distance,ignoreLocation:i=Et.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 y0e(e=[],t=Et.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 Ss=32;function b0e(e,t,a,{location:l=Et.location,distance:s=Et.distance,threshold:i=Et.threshold,findAllMatches:c=Et.findAllMatches,minMatchCharLength:p=Et.minMatchCharLength,includeMatches:f=Et.includeMatches,ignoreLocation:_=Et.ignoreLocation}={}){if(t.length>Ss)throw new Error(r0e(Ss));const g=t.length,y=e.length,v=Math.max(0,Math.min(l,y));let w=i,k=v;const b=p>1||f,S=b?Array(y):[];let $;for(;($=e.indexOf(t,k))>-1;){let V=ko(t,{currentLocation:$,expectedLocation:v,distance:s,ignoreLocation:_});if(w=Math.min(V,w),k=$+g,b){let I=0;for(;I=O;W-=1){let G=W-1,Z=a[e.charAt(G)];if(b&&(S[G]=+!!Z),H[W]=(H[W+1]<<1|1)&Z,V&&(H[W]|=(D[W+1]|D[W])<<1|1|D[W+1]),H[W]&U&&(F=ko(t,{errors:V,currentLocation:G,expectedLocation:v,distance:s,ignoreLocation:_}),F<=w)){if(w=F,k=G,k<=v)break;O=Math.max(1,2*v-k)}}if(ko(t,{errors:V+1,currentLocation:v,expectedLocation:v,distance:s,ignoreLocation:_})>w)break;D=H}const Q={isMatch:k>=0,score:Math.max(.001,F)};if(b){const V=y0e(S,p);V.length?f&&(Q.indices=V):Q.isMatch=!1}return Q}function w0e(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 Mf{constructor(t,{location:a=Et.location,threshold:l=Et.threshold,distance:s=Et.distance,includeMatches:i=Et.includeMatches,findAllMatches:c=Et.findAllMatches,minMatchCharLength:p=Et.minMatchCharLength,isCaseSensitive:f=Et.isCaseSensitive,ignoreDiacritics:_=Et.ignoreDiacritics,ignoreLocation:g=Et.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=_?si(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const y=(w,k)=>{this.chunks.push({pattern:w,alphabet:w0e(w),startIndex:k})},v=this.pattern.length;if(v>Ss){let w=0;const k=v%Ss,b=v-k;for(;w{const{isMatch:D,score:F,indices:B}=b0e(t,b,S,{location:i+$,distance:c,threshold:p,findAllMatches:f,minMatchCharLength:_,includeMatches:s,ignoreLocation:g});D&&(w=!0),v+=F,D&&B&&(y=[...y,...B])});let k={isMatch:w,score:w?v/this.chunks.length:1};return w&&s&&(k.indices=y),k}}class Cs{constructor(t){this.pattern=t}static isMultiMatch(t){return Tc(t,this.multiRegex)}static isSingleMatch(t){return Tc(t,this.singleRegex)}search(){}}function Tc(e,t){const a=e.match(t);return a?a[1]:null}class C0e extends Cs{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 k0e extends Cs{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 B0e extends Cs{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 x0e extends Cs{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 S0e extends Cs{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 F0e extends Cs{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 Lf extends Cs{constructor(t,{location:a=Et.location,threshold:l=Et.threshold,distance:s=Et.distance,includeMatches:i=Et.includeMatches,findAllMatches:c=Et.findAllMatches,minMatchCharLength:p=Et.minMatchCharLength,isCaseSensitive:f=Et.isCaseSensitive,ignoreDiacritics:_=Et.ignoreDiacritics,ignoreLocation:g=Et.ignoreLocation}={}){super(t),this._bitapSearch=new Mf(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 Rf extends Cs{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 qr=[C0e,Rf,B0e,x0e,F0e,S0e,k0e,Lf],Mc=qr.length,$0e=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,E0e="|";function U0e(e,t={}){return e.split(E0e).map(a=>{let l=a.trim().split($0e).filter(i=>i&&!!i.trim()),s=[];for(let i=0,c=l.length;i!!(e[ni.AND]||e[ni.OR]),V0e=e=>!!e[Jr.PATH],T0e=e=>!ns(e)&&Qf(e)&&!Xr(e),Lc=e=>({[ni.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Of(e,t,{auto:a=!0}={}){const l=s=>{let i=Object.keys(s);const c=V0e(s);if(!c&&i.length>1&&!Xr(s))return l(Lc(s));if(T0e(s)){const f=c?s[Jr.PATH]:i[0],_=c?s[Jr.PATTERN]:s[f];if(!Hl(_))throw new Error(i0e(f));const g={keyId:jr(f),pattern:_};return a&&(g.searcher=Wr(_,t)),g}let p={children:[],operator:i[0]};return i.forEach(f=>{const _=s[f];ns(_)&&_.forEach(g=>{p.children.push(l(g))})}),p};return Xr(e)||(e=Lc(e)),l(e)}function M0e(e,{ignoreFieldNorm:t=Et.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 L0e(e,t){const a=e.matches;t.matches=[],hl(a)&&a.forEach(l=>{if(!hl(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 R0e(e,t){t.score=e.score}function O0e(e,t,{includeMatches:a=Et.includeMatches,includeScore:l=Et.includeScore}={}){const s=[];return a&&s.push(L0e),l&&s.push(R0e),e.map(i=>{const{idx:c}=i,p={item:t[c],refIndex:c};return s.length&&s.forEach(f=>{f(i,p)}),p})}class mn{constructor(t,a={},l){this.options={...Et,...a},this.options.useExtendedSearch,this._keyStore=new c0e(this.options.keys),this.setCollection(t,l)}setCollection(t,a){if(this._docs=t,a&&!(a instanceof Md))throw new Error(o0e);this._myIndex=a||Tf(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){hl(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)),O0e(f,this._docs,{includeMatches:l,includeScore:s})}_searchStringList(t){const a=Wr(t,this.options),{records:l}=this._myIndex,s=[];return l.forEach(({v:i,i:c,n:p})=>{if(!hl(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=Of(t,this.options),l=(p,f,_)=>{if(!p.children){const{keyId:y,searcher:v}=p,w=this._findMatches({key:this._keyStore.get(y),value:this._myIndex.getValueForItemAtKeyId(f,y),searcher:v});return w&&w.length?[{idx:_,item:f,matches:w}]:[]}const g=[];for(let y=0,v=p.children.length;y{if(hl(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=Wr(t,this.options),{keys:l,records:s}=this._myIndex,i=[];return s.forEach(({$:c,i:p})=>{if(!hl(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(!hl(a))return[];let s=[];if(ns(a))a.forEach(({v:i,i:c,n:p})=>{if(!hl(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}}mn.version="7.1.0";mn.createIndex=Tf;mn.parseIndex=g0e;mn.config=Et;mn.parseQuery=Of;D0e(Q0e);const P0e=(ze.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}}),H0e=[{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"},...P0e],N0e=H0e.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}})),K0e=[{title:"Theme",title_resolver:()=>{let t=(Te.isDark()?"dark":"light")==="light"?u("Dark"):u("Light");return u("Change theme to %1$s",t)},data:{type:"action",action:()=>{let t=(Te.isDark()?"dark":"light")==="light"?"dark":"light";Te.apply(t,{fromShortcut:!0})}}}],Rc={"/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/compliance":u("Compliance"),"/settings/store-settings/subscriptions_setup":u("Subscriptions Setup"),"/settings/store-settings/checkout_fields":u("Checkout Fields"),"/settings/store-settings/appearance":u("Appearance"),"/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 Pf=[];Object.keys(Rc).forEach(e=>{const t=Rc[e];Pf.push({title:t,data:{type:"action",action:({router:a})=>{a.push({path:e})},description:u("Go to %1$s",t),show_description:!1}})});const G0e=[],z0e={Menu:N0e,Actions:K0e,Settings:Pf,Shortcuts:G0e},Zr=[];Object.entries(z0e).forEach(([e,t])=>{t.forEach((a,l)=>{Zr.push({...a,id:`${e.toString().toLowerCase()}-${l}`,group:[e]})})});const j0e=()=>({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}]}),q0e={class:"navigable-list-container fct-global-search-result-container"},Y0e={key:0,class:"no-results fct-global-search-result-not-found"},W0e={key:1},J0e=["tabindex","onClick","onKeydown"],X0e={__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=T(-1),s=td("listContainer"),i=T({}),c=(k,b)=>{b&&(i.value[k]=b)},p=k=>{const b=a.items.length;if(b===0)return;const S=b-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,b=i.value[l.value];b&&k&&(b.scrollIntoView({behavior:"smooth",block:"nearest"}),xe(()=>{b.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,xe(()=>{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&&xe(()=>{})},{immediate:!0}),be(l,()=>{}),(k,b)=>(r(),h("div",q0e,[e.items.length===0?(r(),h("div",Y0e,[n(Y,{name:"Empty/GlobalSearch"}),R(" "+m(e.noResultsText),1)])):(r(),h("div",W0e,[o("ul",{ref_key:"listContainer",ref:s,class:"navigable-list fct-global-search-result-list"},[(r(!0),h(P,null,te(e.items,(S,$)=>(r(),h("li",{key:$,ref_for:!0,ref:D=>c($,D),class:de({selected:$===l.value}),tabindex:$,onClick:D=>_($),onKeydown:[b[0]||(b[0]=xa(Ge(D=>p("up"),["prevent"]),["arrow-up"])),b[1]||(b[1]=xa(Ge(D=>p("down"),["prevent"]),["arrow-down"])),xa(D=>g($),["enter"])]},[ga(k.$slots,"default",{item:S,index:$,isSelected:$===l.value},void 0,!0)],42,J0e))),128))],512)]))]))}},ed=nt(X0e,[["__scopeId","data-v-2379fe26"]]),Z0e={class:"fct-search-result-label"},ewe={class:"fct-search-result-title"},twe={key:0,class:"fct-search-result-subtitle"},awe={key:1,class:"fct-search-result-subtitle"},lwe={class:"action-icon"},swe={class:"recent-search-title"},nwe={class:"fct-search-result-label"},owe={class:"fct-search-result-title"},iwe={key:0,class:"fct-search-result-subtitle"},rwe={key:1,class:"fct-search-result-subtitle"},dwe={class:"action-icon"},pr="recent_actions",uwe={__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=sl();Jt().ctx;const l=e,s=T(0),i=T({}),c=T(),p=(S,$)=>{const F=S.item.data,B=_(F.type);if(B==="link"){let U=_(F.url);_(F.new_tab)?window.open(U,"_blank"):window.location.href=U}else B==="action"&&_(F.action);f(S),l.onActionPerformed()},f=S=>{const $=S.item.id;let D=Vt.get(pr)||[];D=D.filter(F=>F!==$),D.unshift($),D=D.slice(0,5),Vt.set(pr,D)},_=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)},w=()=>{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 D=S[$];D.item.title_resolver&&(S[$].item.title=await _(D.item.title_resolver))}i.value={...S}});const k=T([]),b=async()=>{const S=Vt.get(pr)||[];let $=dt.whereIn(l.searchData,"id",S),D=[];for(const F of $)typeof F.title_resolver=="function"&&(F.title=await _(F.title_resolver)),D.push({item:F});k.value=D};return Ie(()=>{b()}),t({focusList:v,resetSelection:y,performFirstAction:w,fetchRecentActions:b}),(S,$)=>(r(),h(P,null,[e.query||k.value.length<1?(r(),E(ed,{key:0,items:e.searchResults,"on-action":p,"no-results-text":A(u)("No matches found"),ref_key:"navigableList",ref:c},{default:d(({item:D,index:F,isSelected:B})=>{var U,Q,V;return[o("span",Z0e,[o("span",ewe,m(D.item.title),1),(U=D.item)!=null&&U.subtitle?(r(),h("span",twe,m(D.item.subtitle),1)):((V=(Q=D.item)==null?void 0:Q.data)==null?void 0:V.show_description)===!0?(r(),h("span",awe,m(D.item.data.description),1)):x("",!0)]),o("div",lwe,[n(Y,{name:"Enter"})])]}),_:1},8,["items","no-results-text"])):x("",!0),!e.query&&k.value.length>0?(r(),h(P,{key:1},[o("span",swe,m(A(u)("Recent Actions")),1),n(ed,{items:k.value,"on-action":p,"no-results-text":A(u)("No matches found"),ref_key:"navigableList",ref:c},{default:d(({item:D,index:F,isSelected:B})=>{var U,Q,V;return[o("span",nwe,[o("span",owe,m(D.item.title),1),(U=D.item)!=null&&U.subtitle?(r(),h("span",iwe,m(D.item.subtitle),1)):((V=(Q=D.item)==null?void 0:Q.data)==null?void 0:V.show_description)===!0?(r(),h("span",rwe,m(D.item.data.description),1)):x("",!0)]),o("div",dwe,[n(Y,{name:"Enter"})])]}),_:1},8,["items","no-results-text"])],64)):x("",!0)],64))}},cwe=nt(uwe,[["__scopeId","data-v-ccb0ebef"]]),Awe={class:"fct-global-search-product-wrap"},pwe={class:"fct-global-search-product-left-info"},fwe={key:0,class:"type"},mwe={key:0,class:"price-and-status"},hwe={__name:"Product",props:{product:{type:Object,required:!0}},setup(e){const t=l=>l.min_price===l.max_price?Kt(l.min_price,!0):`${Kt(l.min_price,!0)} - ${Kt(l.max_price,!0)}`,a=l=>l==="publish"?u("published"):l==="future"?u("scheduled"):l;return(l,s)=>(r(),h("div",Awe,[o("div",pwe,[n(id,{product:e.product},null,8,["product"]),e.product.detail?(r(),h("span",fwe,[R(m(A(da).headline(e.product.detail.variation_type))+" ",1),s[0]||(s[0]=o("br",null,null,-1)),R(" "+m(A(da).headline(e.product.detail.fulfillment_type)),1)])):x("",!0)]),e.product.detail?(r(),h("span",mwe,[R(m(t(e.product.detail))+" ",1),(r(),E(fa,{key:e.product.ID,status:e.product.post_status},{default:d(()=>[R(m(a(e.product.post_status)),1)]),_:1},8,["status"]))])):x("",!0)]))}},_we={class:"fct-global-search-order-wrap"},vwe={class:"fct-global-search-order-header"},gwe={class:"fct-global-search-order-id"},ywe={class:"items"},bwe={class:"fct-global-search-order-header-meta"},wwe={class:"date"},Cwe=["innerHTML"],kwe={class:"customer-name"},Bwe={class:"fct-global-search-order-status-wrapper"},xwe=["src","alt"],Swe={__name:"Order",props:{order:{type:Object,required:!0}},setup(e){const t=a=>dt.get(window,"fluentCartAdminApp.payment_logos."+a);return(a,l)=>{var i;const s=C("el-tag");return r(),h("div",_we,[o("div",vwe,[o("div",gwe,[R(" #"+m(e.order.id)+" ",1),o("span",ywe,m(A(u)("%s Items",e.order.order_items.length)),1)]),o("div",bwe,[o("span",wwe,[n(Pa,{"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(Kt)(e.order.total_amount,!0,!1,e.order.currency)},null,8,Cwe),l[1]||(l[1]=o("span",{class:"circle"},null,-1)),o("span",kwe,m(((i=e.order.customer)==null?void 0:i.full_name)||A(u)("No Name")),1)])]),o("div",Bwe,[n(fa,{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(da).headline(e.order.payment_method)},null,8,xwe)):(r(),E(s,{key:1,type:"info",round:"",size:"small",class:"capitalize"},{default:d(()=>[R(m(A(da).headline(e.order.payment_method)),1)]),_:1}))])])}}},Fwe={class:"fct-global-search-customer-wrap"},$we={class:"fct-customer-card"},Ewe={class:"fct-customer-avatar"},Uwe=["src"],Iwe={class:"fct-customer-details"},Qwe={class:"fct-customer-name"},Dwe={class:"fct-customer-id"},Vwe={class:"fct-customer-email"},Twe={class:"purchase-count"},Mwe={class:"date"},Lwe={__name:"Customer",props:{customer:{type:Object,required:!0}},setup(e){return(t,a)=>(r(),h("div",Fwe,[o("div",$we,[o("div",Ewe,[o("img",{src:e.customer.photo,alt:"avatar"},null,8,Uwe)]),o("div",Iwe,[o("div",Qwe,[R(m(e.customer.full_name||t.$t("No Name"))+" ",1),o("span",Dwe,"#"+m(e.customer.id),1)]),o("div",Vwe,[R(m(e.customer.email)+" ",1),a[0]||(a[0]=o("span",{class:"circle"},null,-1)),a[1]||(a[1]=R()),o("span",Twe,"Purchase: "+m(e.customer.purchase_count),1)])])]),o("span",Mwe,[n(Pa,{"date-time":e.customer.last_purchase_date},null,8,["date-time"])])]))}},Rwe={class:"fct-global-search-coupon-wrap"},Owe={class:"amount"},Pwe={__name:"Coupon",props:{coupon:{type:Object,required:!0}},setup(e){return(t,a)=>(r(),h("div",Rwe,[o("span",null,m(e.coupon.title),1),o("span",null,m(e.coupon.code),1),o("span",Owe,m(A(Kt)(e.coupon.amount,!0)),1)]))}},Hwe={class:"fct-global-remote-result-container"},Nwe={class:"fct-global-remote-result-label"},Kwe={class:"text"},Gwe={class:"navigable-content"},zwe={class:"action-icon"},jwe={__name:"RemoteResult",emits:["close-modal","onRemoteSearchStateChange"],setup(e,{expose:t,emit:a}){const l=a,s=sl(),i=T({}),c=T(""),p=T(),f=T({}),_=T([]),g=V=>{y.value=!1,_.value=S.data.tableData,l("onRemoteSearchStateChange",!1)},y=T(!1),v={orders:_A({fetch:!1}),products:tf({fetch:!1}),customers:hA({fetch:!1}),coupons:kf({fetch:!1})},w=()=>{},k=()=>{var V;(V=p.value)==null||V.focusList(0)},b=()=>{var V;(V=p.value)==null||V.performFirstAction()};Ds(()=>{for(const V of Object.keys(v))v[V].onDataLoaded(g)});let S=null;const $=()=>{S=v[i.value.key],S.data.search=c.value,y.value=!0,S.fetch(),l("onRemoteSearchStateChange",!0)},D=cd.debounce($,800),F=(V,I)=>{if(_.value=[],S&&(S.data.search=""),i.value=I,f.value={title:I.title,key:I.key},!V){c.value="";return}c.value=V,D()},B=()=>{s.push({name:f.value.key,query:{search:c.value}}),l("close-modal")},U={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"}},Q=V=>{i.value.key in U&&(s.push({name:U[i.value.key].name,params:{[U[i.value.key].key]:V.id||V.ID,action:"edit"}}),l("close-modal"))};return t({fetchData:F,focusList:k,resetSelection:w,performFirstAction:b}),(V,I)=>(r(),h("div",Hwe,[o("div",Nwe,[o("span",Kwe,m(i.value.title),1),f.value.key?(r(),h("span",{key:0,class:"view-all",onClick:B},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)):x("",!0)]),n(ed,{items:_.value,"on-action":M=>{Q(M)},"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:M,index:O,isSelected:L})=>[o("div",Gwe,[i.value.key==="products"?(r(),E(hwe,{key:0,product:M},null,8,["product"])):x("",!0),i.value.key==="orders"?(r(),E(Swe,{key:1,order:M},null,8,["order"])):x("",!0),i.value.key==="customers"?(r(),E(Lwe,{key:2,customer:M},null,8,["customer"])):x("",!0),i.value.key==="coupons"?(r(),E(Pwe,{key:3,coupon:M},null,8,["coupon"])):x("",!0)]),o("div",zwe,[n(Y,{name:"Enter"})])]),_:1},8,["items","on-action","no-results-text"])]))}},qwe={class:"fct-global-search-input-wrap"},Ywe=["aria-label"],Wwe={class:"fct-setting-search-icon"},Jwe={class:"fct-global-search-input-container"},Xwe={key:0,class:"searched-item"},Zwe={class:"fct-global-searching-for"},eCe={class:"fct-global-searching-for-label"},tCe={class:"fct-global-searching-suggestion-list"},aCe=["onClick"],lCe={class:"dialog-footer is-border"},sCe={class:"fct-search-commands"},nCe={class:"command-key"},oCe={class:"command-key"},iCe={class:"label"},rCe={class:"command-key"},dCe={class:"label"},uCe={class:"label"},cCe={__name:"GlobalSearch",setup(e){Jt().ctx,sl();const t=T(!1),a=T(""),l=T({}),s=T(),i=T(""),c=T([u("orders"),u("products"),u("customers"),u("coupons"),u("settings"),u("menus"),u("shortcuts...")]),p=T(0),f=T(!0),_=T(0),g=T(null),y=T(null),v=T(70),w=T(40),k=T(1700),b=()=>{xe(()=>{$()})},S=()=>{var ie,J;Q.value?(ie=W.value)==null||ie.resetSelection():(J=F.value)==null||J.resetSelection(),Q.value=!1,H.value=!1,D()},$=()=>{var ie;(ie=s.value)==null||ie.focus()},D=()=>{Q.value=!1,l.value=[],t.value=!1,a.value="",V.value=null},F=T(),B=ie=>{let J=ie.includes(","),N={},ae=[];(J?ie.split(","):[ie]).forEach(re=>{re.includes(":")?U(re,N,ae):ae.push(re)});let fe=[];return Object.keys(N).forEach(re=>{const Ee=N[re];Ee.length>0?Ee.forEach(ye=>{ye.length>0?fe.push({group:"'"+re,title:ye}):fe.push({group:"'"+re})}):fe.push({group:"'"+re})}),ae.forEach(re=>{re.length>0&&fe.push({title:re})}),fe},U=(ie,J,N)=>{if(ie.length===1)return;let ae=ie.split(":"),oe=ae[0],fe=ae[1];oe.length>0?(J.hasOwnProperty(oe)||(J[oe]=[]),fe.length>0&&J[oe].push(fe)):N.push(fe)},Q=T(!1),V=T(null),I=T({o:{key:"orders",title:u("Orders")},p:{key:"products",title:u("Products")},c:{key:"customers",title:u("Customers")},d:{key:"coupons",title:u("Coupons")}}),M=ie=>{V.value=ie,Q.value=!0,l.value={},xe(()=>{var J,N;(J=W.value)==null||J.fetchData(a.value,ie),(N=s.value)==null||N.focus()})},O=()=>{var ie;l.value=[],V.value=null,a.value="",Q.value=!1,(ie=s.value)==null||ie.focus(),H.value=!1},L=()=>{var ie;(ie=W.value)==null||ie.fetchData(a.value,V.value)},H=T(!1),j=ie=>{H.value=ie,xe(()=>{var J;(J=s.value)==null||J.focus()})},W=T(),G=bs(),Z=()=>{if(t.value){$();return}const ie=["o","p","c","d"];G.bind(ie,J=>{J.preventDefault();const N=I.value[J.key];N&&M(N)}),t.value=!0,xe(()=>{var J;(J=F.value)==null||J.fetchRecentActions()}),setTimeout(()=>{G.unbind(ie)},800)};G.bind(["/"],ie=>{!t.value&&ne()||(ie.preventDefault(),Z())});const ne=()=>{const ie=document.activeElement;if(!ie)return!1;const J=ie.tagName;return J==="INPUT"||J==="TEXTAREA"||J==="SELECT"||ie.isContentEditable},ce=()=>{if(g.value)return;const ie=()=>{if(s.value&&s.value.length>0)return;const N=c.value[p.value];if(f.value)_.value{y.value=null},k.value));else{if(y.value)return;_.value>0?(_.value--,i.value=N.slice(0,_.value)):(f.value=!0,p.value=(p.value+1)%c.value.length)}},J=()=>{ie();const N=f.value?v.value:y.value?120:w.value;g.value=setTimeout(J,N)};J()},z=T(!1);let ue;return Ie(()=>{ce(),ue=new mn(Zr,j0e());const ie=document.getElementById("fct_admin_menu_search");if(ie){const J=ie.querySelector(".fct-global-search-input-wrap");J&&J.remove()}z.value=!!ie,window.fluentCart=window.fluentCart||{},window.fluentCart.openSearch=Z}),Bt(()=>{window.fluentCart&&delete window.fluentCart.openSearch}),(ie,J)=>{const N=C("el-input"),ae=C("el-dialog");return r(),h(P,null,[z.value?(r(),E(ii,{key:0,to:"#fct_admin_menu_search"},[o("div",qwe,[o("button",{onClick:Z,type:"button",class:"fct-setting-search-button","aria-label":A(u)("Search")},[o("span",Wwe,[n(Y,{name:"Search"})]),J[6]||(J[6]=o("span",{class:"fct-global-search-button-keys"},[o("kbd",{class:"fct-global-search-button-key"},"/")],-1))],8,Ywe)])])):x("",!0),n(ae,{modelValue:t.value,"onUpdate:modelValue":J[5]||(J[5]=oe=>t.value=oe),onOpened:b,onClosed:S,class:"fct-global-search-container","append-to-body":!0},{header:d(()=>[o("div",Jwe,[n(Y,{name:"Search",class:"search-icon"}),V.value!=null?(r(),h("div",Xwe,[R(m(V.value.title)+" ",1),n(Y,{name:"Cross",class:"searched-item-remove",onClick:O})])):x("",!0),n(N,{class:"mousetrap",placeholder:A(u)("Search for %1$s",i.value),autofocus:"",ref_key:"searchRef",ref:s,id:"fct-global-search-input",disabled:H.value,onKeydown:[J[0]||(J[0]=xa(Ge(()=>{var oe,fe;if(Q.value){(oe=W.value)==null||oe.focusList();return}(fe=F.value)==null||fe.focusList()},["prevent"]),["arrow-down"])),J[1]||(J[1]=xa(Ge(()=>{var oe,fe;if(Q.value){(oe=W.value)==null||oe.performFirstAction();return}(fe=F.value)==null||fe.performFirstAction()},["prevent"]),["enter"])),J[2]||(J[2]=xa(()=>{a.value.length===0&&(V.value=null,Q.value=!1)},["backspace"]))],onInput:J[3]||(J[3]=()=>{if(Q.value){L();return}let oe=a.value.includes(","),fe=a.value.includes(":");if(!oe&&!fe)l.value.value=A(ue).search(a.value);else{const re=B(a.value);l.value.value=A(ue).search({$or:re})}}),modelValue:a.value,"onUpdate:modelValue":J[4]||(J[4]=oe=>a.value=oe),clearable:""},null,8,["placeholder","disabled","modelValue"])])]),default:d(()=>[n(ya,{visible:!V.value&&a.value.length===0,accordion:""},{default:d(()=>[o("div",Zwe,[o("div",eCe,m(A(u)("Searching for")),1),o("div",tCe,[(r(!0),h(P,null,te(I.value,oe=>{var fe;return r(),h("div",{key:oe.key,onClick:re=>M(oe),class:de(["fct-global-searching-suggestion",((fe=V.value)==null?void 0:fe.key)===oe.key?"active":""])},m(oe.title),11,aCe)}),128))])])]),_:1},8,["visible"]),Q.value?(r(),E(jwe,{key:0,ref_key:"remoteResultRef",ref:W,query:a.value,tag:V.value,onCloseModal:D,onOnRemoteSearchStateChange:j},null,8,["query","tag"])):(r(),E(cwe,{key:1,ref_key:"resultListRef",ref:F,query:a.value,"search-results":l.value.value,onActionPerformed:D,focusInput:$,searchData:A(Zr)},null,8,["query","search-results","searchData"])),o("div",lCe,[o("ul",sCe,[o("li",null,[o("span",nCe,[n(Y,{name:"ArrowUp"})]),o("span",oCe,[n(Y,{name:"ArrowDown"})]),o("span",iCe,m(A(u)("To navigate")),1)]),o("li",null,[o("span",rCe,[n(Y,{name:"Enter"})]),o("span",dCe,m(A(u)("To select")),1)]),o("li",null,[J[7]||(J[7]=o("kbd",{class:"command-key"},"esc",-1)),o("span",uCe,m(A(u)("To close")),1)])])])]),_:1},8,["modelValue"])],64)}}},ACe={class:"fl_app fluent-cart-admin-pages"},pCe=Object.assign({name:"DashboardApplication"},{__name:"Application",setup(e){const t=T("");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=T(!1),s=nl();be(()=>s.fullPath,()=>{t.value=a()});const i=K(()=>!(s.fullPath.includes("reports")||s.fullPath.includes("settings")));return(c,p)=>{const f=C("router-view");return r(),h("div",null,[n(cCe),i.value?(r(),E(Ia,{key:0})):x("",!0),o("div",ACe,[n(f)]),l.value?(r(),E(ii,{key:1,to:"#theme-button-container"},[n(t0e)])):x("",!0)])}}});let Oc=!1;function fCe(e){return{data:function(){return{appVars:window.fluentCartAdminApp}},methods:{$get:Ae.get,$post:Ae.post,$put:Ae.put,$del:Ae.delete,$t:u,$n:Io,formatMoney(t,a,l=!1){return!t&&l?"":(t||(t="0.00"),ze.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),ze.get("shop.currency_sign")+" "+t):t)},formatNumber(t,a=!0,l=!1,s){return ft.formatNumber(t,a,l,s)},formatNumberForOrder(t,a,l=!0,s=!1){return ft.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 xm(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=>{q.success(t)},handleMessage:(t,a="info",l=40,s=1e3)=>{qc.show(t,a,l,s)},Storage:()=>Vt,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(){Oc||(Oc=!0,document.addEventListener("click",t=>{t.target.matches(".copyable-content")&&as.copy(t.target.textContent)}))},currencySign(){return ze.get("shop.currency_sign")},getPlaceholderImage(){return gs.getUrl("images/placeholder.svg")},saveLocal(t,a){Vt.set(t,a)},getLocal(t){return Vt.get(t)},hasPermission(t){return Vn.hasPermission(t)}}}}function mCe(e){e.beforeEach((t,a,l)=>{const s=dt.get(t,"meta.permission");return s?Vn.resolve({permission:s,permissionType:dt.get(t,"meta.permissionType")})?l():l({name:"unauthorized"}):(ze.get("app_config.env"),l())})}function hCe(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 _Ce={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()}},vCe={__name:"Unauthorized",setup(e){return(t,a)=>(r(),h("span",null,m(A(u)("You are not allowed")),1))}},gCe=window.fluent_cart_admin.hooks.applyFilters("fluent_cart_routes",Xbe);let Pc=!1;document.addEventListener("fcart_renew_rest_nonce",function(e){Pc||Fl.alert(u("Your session has expired due to inactivity. Please refresh the page to continue."),u("Session Expired"),{confirmButtonText:u("Reload"),callback:t=>{Pc=!1,window.location.reload()}})});const yCe=[rm,dm,um,Wc,cm,ld,Am,pm,sd,fm,mm,Xc],ql=Zf(pCe);ql.config.globalProperties.appVars=ze.get();ql.provide("appVars",ze.get());ql.mixin(fCe());ql.directive("loading",Um);ql.directive("animate",_Ce);Xm(ql);const Ld=em({routes:[...Object.values(gCe),{path:"/unauthorized",name:"unauthorized",component:vCe,props:!0},{path:"/:path(.*)*",name:"NotFound",component:ci,props:!0}],history:tm(),scrollBehavior(e,t,a){return a||{top:0,behavior:"smooth"}}});ql.use(Ld);mCe(Ld);hCe(Ld);yCe.forEach(e=>{ql.component(e.name,e)});const Rd=ze.get("el_strings"),Hf=ze.get("datei18");Rd.el.datepicker.weeks=Hf.weekdaysShort;Rd.el.datepicker.months=Hf.monthsShort;ql.use(Im,{locale:Rd});ql.mount("#fluent_cart_plugin_app");if(ze.get("has_data_migrations")){let e=0;const t=()=>{Ae.post("data-backfills/run").then(a=>{a&&a.status==="running"&&++e<100&&t()}).catch(()=>{})};t()}export{jn as E,kd as _};