`:$+="
",$+=`
${D.marker}
${D.seriesName}
${O}
`}),$}},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:d("Volume (%s)",vt.currencySign),axisLabel:{color:p.value?"#ffffff":"#696778",fontSize:12,formatter:Q=>vt.formatScaledChart(Q)},splitLine:{show:!0,lineStyle:{color:p.value?"#253241":"#D6DAE1",type:"dashed"}}},{type:"value",position:"right",name:d("YoY Growth (%)"),axisLabel:{color:p.value?"#ffffff":"#696778",fontSize:12,formatter:"{value}%"},splitLine:{show:!1},min:Math.min(...v.value.filter(Q=>!isNaN(Q)),0)-5,max:Math.max(...v.value.filter(Q=>!isNaN(Q)),0)+5}],series:y.value};try{k.setOption(F,{notMerge:!0,replaceMerge:["series"]})}catch(Q){i.value=`Error updating chart: ${Q.message}`}},x=(F,Q,$,S,U=0)=>({name:F,type:Q,barMaxWidth:t.barMaxWidth,areaStyle:Q==="line"?null:void 0,data:$,smooth:Q==="line",color:S,lineStyle:Q==="line"?{width:2}:void 0,yAxisIndex:U,emphasis:{scale:2,itemStyle:{color:p.value?A.blue[800]:A.blue[400]}}});return ke([()=>t.data,s],()=>{Fe(b)},{deep:!0}),xt(()=>{window.removeEventListener("onFluentCartThemeChange",b,!1),window.removeEventListener("fluentCartCurrencyChange",b,!1),k&&(k.dispose(),k=null)}),De(()=>{window.addEventListener("onFluentCartThemeChange",b),window.addEventListener("fluentCartCurrencyChange",b),Fe(w)}),(F,Q)=>(r(),h("div",Hue,[n($e,{id:"chartContainer",ref_key:"cardRef",ref:l},{default:u(()=>[n(Qe,{title:c(d)(e.title),title_size:"small",border_bottom:""},{action:u(()=>Q[0]||(Q[0]=[])),_:1},8,["title"]),n(xe,{class:"p-0"},{default:u(()=>[i.value?(r(),h("div",Nue,f(i.value),1)):B("",!0),e.isEmpty?(r(),E(wt,{key:2,icon:"Empty/ListView","has-dark":!0,text:c(d)("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)]))}},Ec=nt(Kue,[["__scopeId","data-v-a0726f58"]]),Gue={class:"fct-country-volume-chart-wrap"},zue={class:"fct-btn-group sm"},jue=.05,que={__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 A=T(Re.isDark()),p=K(()=>A.value?["#8FC0F5","#4E90E8","#2E6BC4","#1E4C90","#143562"]:["#9CC9FA","#3E9DF6","#1573D5","#0B57A3","#083C73"]),m=$=>{const S=$.replace("#",""),U=parseInt(S.substring(0,2),16),V=parseInt(S.substring(2,4),16),D=parseInt(S.substring(4,6),16);return(U*299+V*587+D*114)/1e3>150?"#0B3A66":"#ffffff"},_=K(()=>{const $=Array.isArray(t.data.by_countries)?t.data.by_countries:Object.values(t.data.by_countries);return!$.length||!$.every(S=>!!S)}),g=Re.colors,y=K(()=>{const $=t.data.by_month||{};return Object.keys($).sort().map(U=>{const V=$[U],D=Object.values(V).reduce((L,O)=>L+O,0),I=Object.entries(V).sort((L,O)=>L[1]-O[1]).reduce((L,[O,M])=>({...L,[O]:M}),{});return{label:U,countries:I,total:D}})}),v=K(()=>y.value.length?y.value.map($=>{try{const[S,U]=$.label.split("-");return st(new Date(S,U-1)).locale(es()).format(Rl("month_year"))}catch{return $.label}}):[]),k=K(()=>{const $={};Object.values(t.data.by_month||{}).forEach(V=>{Object.entries(V).forEach(([D,I])=>{$[D]=($[D]||0)+I})}),Object.entries(t.data.by_countries||{}).forEach(([V,D])=>{$[V]=D});const S=p.value,U=S[S.length-1];return Object.keys($).sort((V,D)=>$[D]-$[V]).reduce((V,D,I)=>(V[D]=S[I]||U,V),{})}),w=K(()=>y.value.reduce(($,S)=>Math.max($,S.total),0)),b=K(()=>{const $=t.data.by_month||{},S=new Set;Object.values($).forEach(D=>{Object.keys(D).forEach(I=>S.add(I))});const U=p.value,V=w.value;return Array.from(S).reverse().map(D=>{const I=k.value[D]||U[U.length-1],L=m(I),O=y.value.map(M=>{const H=M.countries[D]||0,z=V>0&&H/V>=jue;return{value:H/100,label:{show:H>0&&z,position:"inside",formatter:D,color:L,fontSize:10,fontWeight:"bold"}}});return{name:D,type:i.value,stack:"total",data:O,itemStyle:{color:I},lineStyle:{color:I}}})}),x=()=>{if(!a.value)return;s=ua(a.value);const $={backgroundColor:"transparent",tooltip:{trigger:"axis",backgroundColor:A.value?"#253241":"#ffffff",textStyle:{color:A.value?g.gray[25]:g.system.mid},borderColor:A.value?"#2C3C4E":"#c0c4ca",axisPointer:Ql(A.value,g.report.dark_cyan_blue_16,g.report.light_gray_cyan_blue,i.value),borderWidth:1,confine:!0,position:Cl,formatter:S=>{const U=A.value?"#ffffff":"#565865",V=A.value?g.report.dark_cyan_blue_16:g.report.light_gray_blue,D=y.value[S[0].dataIndex].total;let I=S[0].axisValue;return S.filter(L=>L.value>0).sort((L,O)=>O.value-L.value).forEach(L=>{const O=qa(L.value*100);I+=`
${L.marker}
${Rs(L.seriesName)}
${O}
`}),I+=`
${d("Total")}
${qa(D)}
`,I}},xAxis:{type:"category",data:v.value,axisLabel:{color:A.value?"#ffffff":"#696778",fontSize:12},axisLine:{lineStyle:{color:A.value?"#253241":"#D6DAE1"}}},yAxis:{type:"value",position:"left",name:d("Volume (%s)",vt.currencySign),axisLabel:{color:A.value?"#ffffff":"#696778",fontSize:12,formatter:S=>vt.formatScaled(S*100)},splitLine:{show:!0,lineStyle:{color:A.value?"#253241":"#D6DAE1",type:"dashed"}}},series:b.value};s.setOption($)},F=()=>{A.value=Re.isDark(),Fe(()=>{x()})},Q=()=>{s&&(s.dispose(),s=null),x()};return De(()=>{window.addEventListener("onFluentCartThemeChange",F),window.addEventListener("fluentCartCurrencyChange",Q),Fe(x)}),xt(()=>{window.removeEventListener("onFluentCartThemeChange",F,!1),window.removeEventListener("fluentCartCurrencyChange",Q,!1)}),ke(()=>A.value,()=>{s&&(s.dispose(),x())}),ke(()=>t.data,()=>{s&&x()}),($,S)=>(r(),h("div",Gue,[n($e,{id:"chartContainer",ref_key:"cardRef",ref:l},{default:u(()=>[n(Qe,{title:e.title,title_size:"small",border_bottom:""},{action:u(()=>[o("div",zue,[n(ih,{targetRef:a.value},null,8,["targetRef"])])]),_:1},8,["title"]),n(xe,{class:"p-0"},{default:u(()=>[_.value?(r(),E(wt,{key:1,icon:"Empty/ListView","has-dark":!0,text:c(d)("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)]))}},Uc=nt(que,[["__scopeId","data-v-c6534652"]]),Yue={class:"fct-card-header-title is-small"},Ic={__name:"CountryNetChart",props:{data:{type:Object,required:!0},title:{type:String,default:""}},setup(e){const t=e,a=Re.colors.report,l=T(Re.isDark()),s=T(null),i=T("line"),A=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"})),m=K(()=>Object.values(A.value).every(b=>b===0)),_=K(()=>Object.keys(A.value)),g=K(()=>[{name:d("Current"),type:i.value,data:Object.values(A.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=ua(s.value),k())},k=()=>{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:Cl,formatter:x=>{let F=Rs(x[0].name);const Q=l.value?"#ffffff":"#565865";return x.forEach($=>{const S=qa($.value);F+=`
${$.marker}
${$.seriesName}
${S}
`}),F}},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:x=>vt.formatScaled(x)},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"]})};ke([()=>A.value,i,()=>l.value],()=>{Fe(k)},{deep:!0});const w=()=>{l.value=Re.isDark(),Fe(()=>{k()})};return De(()=>{window.addEventListener("onFluentCartThemeChange",w,!1),window.addEventListener("fluentCartCurrencyChange",k),Fe(v)}),xt(()=>{window.removeEventListener("onFluentCartThemeChange",w,!1),window.removeEventListener("fluentCartCurrencyChange",k,!1)}),(b,x)=>(r(),E($e,null,{default:u(()=>[e.title!==""?(r(),E(Qe,{key:0,border_bottom:!0},{title:u(()=>[o("h3",Yue,f(e.title),1)]),_:1})):B("",!0),n(xe,null,{default:u(()=>[m.value?(r(),E(wt,{key:1,icon:"Empty/ListView","has-dark":!0,text:c(d)("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}))}},Wue={class:"fct-overview-report-loader-wrap"},Xue={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},Jue={class:"fct-card-header-title is-small"},Zue={class:"flex gap-2 mt-1"},ece={class:"py-6"},tce={class:"grid grid-cols-1"},ace={class:"fct-card-header-title is-small"},lce={class:"py-6"},sce={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-2"},nce={class:"fct-card-header-title is-small"},oce={class:"flex gap-2 mt-1"},ice={class:"py-6"},rce={class:"grid grid-cols-1"},dce={class:"fct-card-header-title is-small"},uce={class:"py-6"},cce={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-2"},Ace={class:"fct-card-header-title is-small"},pce={class:"py-6"},fce={__name:"OverviewLoading",setup(e){const t=[{title:d("Gross Summary"),key:"gross_summary"},{title:d("Gross Revenue Quarterly"),key:"net_summary"}],a=[{title:d("Net Revenue"),key:"net_revenue"},{title:d("Net Revenue Quarterly"),key:"net_revenue_quarterly"}],l=[{title:d("Top Country Gross Volume"),key:"top_country_gross"},{title:d("Top Country Net Volume"),key:"top_country_net"}],s=[{title:d("Top Countries Gross Revenue"),key:"top_country_revenue"},{title:d("Top Countries Net Revenue"),key:"top_country_net_revenue"}];return(i,A)=>{const p=C("el-skeleton-item"),m=C("el-skeleton");return r(),h("div",Wue,[o("div",Xue,[(r(),h(P,null,le(t,(_,g)=>o("div",{key:g},[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:!0},{title:u(()=>[o("h3",Jue,f(_.title),1),o("div",Zue,[n(m,{animated:""},{template:u(()=>[n(p,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:2},1024),o("div",ece,[n(m,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",tce,[(r(),h(P,null,le(2,_=>o("div",{key:_},[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(m,{animated:""},{template:u(()=>[n(p,{variant:"p",class:"w-2/3"})]),_:1}),n(Qe,{border_bottom:!0},{title:u(()=>[o("h2",ace,f(c(d)("Gross Volume Breakdown")),1)]),_:1}),o("div",lce,[n(m,{animated:"",rows:7})])]),_:1})]),_:1})])),64))]),o("div",sce,[(r(),h(P,null,le(a,(_,g)=>o("div",{key:g},[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:!0},{title:u(()=>[o("h3",nce,f(_.title),1),o("div",oce,[n(m,{animated:""},{template:u(()=>[n(p,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:2},1024),o("div",ice,[n(m,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",rce,[(r(),h(P,null,le(l,(_,g)=>o("div",{key:g},[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:!0},{title:u(()=>[o("h2",dce,f(_.title),1)]),_:2},1024),o("div",uce,[n(m,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))]),o("div",cce,[(r(),h(P,null,le(s,(_,g)=>o("div",{key:g},[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:!0},{title:u(()=>[o("h3",Ace,f(_.title),1)]),_:2},1024),o("div",pce,[n(m,{animated:"",rows:7})])]),_:2},1024)]),_:2},1024)])),64))])])}}},mce={class:"overview-summary-report-inline"},hce={class:"inner-value"},_ce={__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",mce,[o("div",hce,[n(Ns,{amount:c(vt).formatScaled(e.current),title:c(d)(e.title)},null,8,["amount","title"])]),n(gl,{fluctuation:e.fluctuation,amount:e.previous/100,fluctuationSuffix:c(d)("YoY")},null,8,["fluctuation","amount","fluctuationSuffix"])]))}},ko=nt(_ce,[["__scopeId","data-v-b394c9f1"]]),vce={class:"report-overview-page"},gce={class:"flex items-center justify-start gap-1 mb-2 text-xs text-system-mid dark:text-system-light"},yce={class:"report-overview-col-2 grid gap-x-7.5 grid-cols-1 xl:grid-cols-2"},bce={class:"fct-card-header-title is-small"},wce={class:"fct-card-header-title is-small"},Cce={class:"grid grid-cols-1"},kce=["innerHTML"],Bce=["innerHTML"],xce={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"},$ce={class:"fct-card-header-title is-small"},Fce={class:"grid gap-4 grid-cols-1"},Ece={class:"grid gap-4 grid-cols-1"},Uce={class:"report-overview-col-2 grid gap-7.5 grid-cols-1 xl:grid-cols-2"},Ice={__name:"Overview",setup(e){const t=T({}),a=T(!0),l=T({gross_revenue_quarterly:{},net_revenue_quarterly:{}}),s=()=>{ce.get("reports/overview").then(p=>{t.value=p.data,i()}).catch(p=>{}).finally(()=>{a.value=!1})},i=()=>{l.value.gross_revenue_quarterly=A(t.value.gross_revenue_quarterly,"current","prev_year"),l.value.net_revenue_quarterly=A(t.value.net_revenue_quarterly,"current","prev_year")},A=(p,m="current",_="prev")=>{const g=dt.sum(p,"*."+m),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,m;return((p=t.value.gross_summary)==null?void 0:p.yoy_growth)<0?"danger":((m=t.value.gross_summary)==null?void 0:m.yoy_growth)===null?"warning":"success"}),De(()=>{s()}),(p,m)=>(r(),h("div",vce,[o("div",gce,[n(J,{name:"InformationFill",class:"w-4 h-4 text-system-light"}),R(" "+f(c(d)("Last %s Months",c(d)(12))),1)]),a.value?(r(),E(fce,{key:0})):(r(),h(P,{key:1},[o("div",yce,[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:""},{title:u(()=>[o("h3",bce,f(c(d)("Gross Summary")),1),n(ko,{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(Co,{data:t.value.gross_revenue,dataKey:"current","date-range":"","is-empty":!t.value.gross_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1}),n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:""},{title:u(()=>[o("h3",wce,f(c(d)("Gross Revenue Quarterly")),1),n(ko,{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(Co,{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",Cce,[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[o("div",{class:"mb-3",innerHTML:c(vt).generateVolumeSummary(t.value.gross_revenue,!0)},null,8,kce),n(Ec,{title:c(d)("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($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[o("div",{class:"mb-3",innerHTML:c(vt).generateVolumeSummary(t.value.gross_revenue_quarterly)},null,8,Bce),n(Ec,{title:c(d)("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",xce,[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:!0},{title:u(()=>[o("h3",Sce,f(c(d)("Net Revenue")),1),n(ko,{title:c(d)("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(Co,{data:t.value.net_revenue,dataKey:"current","date-range":"","is-empty":!t.value.net_summary.total},null,8,["data","is-empty"])]),_:1})]),_:1}),n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Qe,{border_bottom:!0},{title:u(()=>[o("h3",$ce,f(c(d)("Net Revenue Quarterly")),1),n(ko,{title:c(d)("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(Co,{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",Fce,[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Uc,{data:t.value.top_country_gross,title:c(d)("Top Country Gross Volume")},null,8,["data","title"])]),_:1})]),_:1})]),o("div",Ece,[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>[n(Uc,{data:t.value.top_country_net,title:c(d)("Top Country Net Volume")},null,8,["data","title"])]),_:1})]),_:1})]),o("div",Uce,[n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>{var _;return[n(Ic,{data:(_=t.value.top_country_gross)==null?void 0:_.by_countries,title:c(d)("Top Countries Gross Revenue")},null,8,["data","title"])]}),_:1})]),_:1}),n($e,null,{default:u(()=>[n(xe,null,{default:u(()=>{var _;return[n(Ic,{data:(_=t.value.top_country_net)==null?void 0:_.by_countries,title:c(d)("Top Countries Net Revenue")},null,8,["data","title"])]}),_:1})]),_:1})])],64))]))}},Vce={class:"setting-wrap"},Dce={class:"setting-wrap-inner"},Qce={key:0,class:"bg-white rounded p-6 dark:bg-dark-700"},Tce={class:"grid gap-3 mb-6"},Mce={class:"grid gap-3 mb-6"},Lce={class:"grid gap-3 mb-6"},Rce={class:"grid gap-3"},Oce={class:"payment-method-list fct-content-card-list"},Pce=["id"],Hce={class:"flex items-start gap-3"},Nce={class:"grid gap-2 flex-1"},Kce={key:0,class:"fct-content-card-list-head stripe"},Gce=["src","alt"],zce=["src","alt"],jce={class:"block font-semibold text-system-dark dark:text-gray-50"},qce={class:"fct-content-card-list-content"},Yce={class:"fct-content-card-list-action flex items-center gap-2"},Wce={key:0},Xce=Object.assign({name:"AddonSettings"},{__name:"AddonSettings",setup(e){const t=df(),{form:a}=t.data,l=ks(),s=T([]),i=T([]),A=T(!0),p=T(!1),m=T(!0),_=T({}),g=T(!1),y=T({}),v=T(!1),k=T(""),w=T(""),b=T(""),x=K(()=>Object.keys(y.value).length>0),F=()=>{p.value=!0;let D=a.values;ce.post("settings/modules",{...D}).then(I=>{q.success(d("Settings saved successfully")),setTimeout(()=>{window.location.reload()},300)}).catch(I=>{if(I&&I.message)return q.error(I);_.value=I}).finally(()=>{p.value=!1,m.value=!1,A.value=!1})},Q=()=>{A.value=!0,ce.get("settings/modules",{}).then(D=>{var O,M;a.setSchema(D.fields).setDefaults(D.settings).initForm(),s.value=D.settings,i.value=D.fields,m.value=!1,p.value=!1;const I=((M=(O=D.fields)==null?void 0:O.modules_settings)==null?void 0:M.schema)||[];let L=!1;Array.isArray(I)?L=I.length>0:L=Object.keys(I).length>0,g.value=L}).finally(()=>{A.value=!1})},$=()=>{v.value=!0,ce.get("settings/modules/plugin-addons",{}).then(D=>{y.value=D.addons||{},b.value&&Fe(()=>Ms.scrollToHashSection(b.value))}).catch(D=>{q.error(D)}).finally(()=>{v.value=!1})},S=je.get("app_config.isProActive"),U=(D,I)=>{if(!S){window.open(D.repo_link,"_blank","noopener,noreferrer");return}k.value=I,ce.post("settings/modules/plugin-addons/install",{plugin_slug:D.plugin_slug,source_type:D.source_type||"wordpress",source_link:D.source_link||"",asset_path:D.asset_path||""}).then(L=>{L.action==="copy"&&L.url?(ls.copy(L.url,{successMessage:d("Download link copied to your clipboard")}),window.open(L.url,"_blank","noopener,noreferrer")):L.action==="reload"?(q.success(L.message||d("Addon installed successfully")),setTimeout(()=>{window.location.reload()},500)):q.success(L.message||d("Addon installed successfully"))}).catch(L=>{q.error(L)}).finally(()=>{k.value=""})},V=(D,I)=>{w.value=I,ce.post("settings/modules/plugin-addons/activate",{plugin_file:D.plugin_file}).then(L=>{q.success(L.message||d("Addon activated successfully")),setTimeout(()=>{window.location.reload()},500)}).catch(L=>{q.error(L)}).finally(()=>{w.value=""})};return De(()=>{const D=window.location.hash||"",I=D.lastIndexOf("#");I>0&&(b.value=D.substring(I+1)),Q(),$()}),l.onSave(F),(D,I)=>{const L=C("el-skeleton-item"),O=C("el-skeleton"),M=C("el-form"),H=C("el-button"),z=C("el-icon"),X=C("router-link");return r(),h("div",Vce,[n($a,{heading:c(d)("Addon Settings"),"show-save-button":!1},null,8,["heading"]),o("div",Dce,[n(Fa),m.value?(r(),h("div",Qce,[n(O,{loading:m.value,animated:""},{template:u(()=>[o("div",Tce,[n(L,{variant:"p",class:"w-[20%]"}),n(L,{variant:"p"})]),o("div",Mce,[n(L,{variant:"p",class:"w-[20%]"}),n(L,{variant:"p"})]),o("div",Lce,[n(L,{variant:"p",class:"w-[20%]"}),n(L,{variant:"p"})]),o("div",Rce,[n(L,{variant:"p",class:"w-[20%]"}),n(L,{variant:"p"})])]),_:1},8,["loading"])])):B("",!0),m.value?B("",!0):(r(),h(P,{key:1},[c(a).isReady?(r(),E(M,{key:0},{default:u(()=>[g.value?(r(),E(Ui,{key:0,form:c(a),showSubmitButton:!0,onOnSubmitButtonClick:F,submitButtonText:c(d)("Save Settings"),loading:p.value,onOnChange:I[0]||(I[0]=G=>{}),"validation-errors":_.value},null,8,["form","submitButtonText","loading","validation-errors"])):x.value?B("",!0):(r(),E($e,{key:1},{default:u(()=>[n(Qe,{title:c(d)("Features & addon"),border_bottom:""},null,8,["title"]),n(xe,null,{default:u(()=>[n(wt,{class:"fct-addon-empty-state",icon:"Empty/Integrations",text:c(d)("No module settings found.")},null,8,["text"])]),_:1})]),_:1}))]),_:1})):B("",!0),x.value?(r(),E($e,{key:1,class:"mt-6"},{default:u(()=>[n(Qe,{title:c(d)("Plugin Addons"),border_bottom:""},null,8,["title"]),n(xe,{class:"py-0"},{default:u(()=>[o("div",Oce,[(r(!0),h(P,null,le(y.value,(G,Y)=>(r(),h("div",{key:Y,class:"fct-content-card-list-item",id:G.plugin_slug===b.value?b.value:null},[o("div",Hce,[o("div",Nce,[G.logo?(r(),h("div",Kce,[o("img",{class:ue({"dark:hidden":G.dark_logo}),src:G.logo,alt:G.title},null,10,Gce),G.dark_logo?(r(),h("img",{key:0,src:G.dark_logo,alt:G.title,class:"hidden dark:block"},null,8,zce)):B("",!0),o("span",jce,f(G.title),1),G.is_active?(r(),E(la,{key:1,status:"active",text:c(d)("Active")},null,8,["text"])):B("",!0)])):B("",!0),o("div",qce,[o("p",null,f(G.description),1)])]),o("div",Yce,[G.upcoming?(r(),h("div",Wce,f(c(d)("Coming Soon")),1)):(r(),h(P,{key:1},[G.is_installed?G.is_installed&&!G.is_active&&(c(S)||G.source_type!=="github")?(r(),E(H,{key:1,type:"success",size:"small",loading:w.value===Y,disabled:w.value===Y,onClick:Z=>V(G,Y)},{default:u(()=>[R(f(c(d)("Activate")),1)]),_:2},1032,["loading","disabled","onClick"])):B("",!0):(r(),E(H,{key:0,type:"primary",size:"small",loading:k.value===Y,disabled:k.value===Y,onClick:Z=>U(G,Y)},{default:u(()=>[R(f(c(S)?c(d)("Install & Activate"):c(d)("Download")),1)]),_:2},1032,["loading","disabled","onClick"])),G.is_active&&Y==="fluent-pdf"?(r(),E(X,{key:2,to:{path:"/settings/pdf-template"}},{default:u(()=>[n(z,{class:"text-gray-500 hover:text-primary cursor-pointer",size:18},{default:u(()=>[n(c(nA))]),_:1})]),_:1})):B("",!0)],64))])])],8,Pce))),128))])]),_:1})]),_:1})):B("",!0)],64))])])}}}),Jce=nt(Xce,[["__scopeId","data-v-a315b5d5"]]),Zce={class:"form-note"},eAe={class:"form-note"},tAe={class:"form-note"},aAe={class:"form-note"},lAe={class:"el-form-item__label"},sAe={class:"h-[297px] w-full relative"},nAe={class:"mt-2 mb-2"},oAe={class:"form-note"},iAe={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"},rAe={class:"setting-html-wrapper"},dAe={class:"setting-label"},uAe={class:"form-note"},cAe={class:"setting-fields-inner w-full"},AAe={__name:"MailingSettingsLoader",setup(e){return(t,a)=>{const l=C("el-skeleton-item"),s=C("el-skeleton"),i=C("el-form-item"),A=C("el-col"),p=C("el-row");return r(),E(xe,null,{default:u(()=>[n(p,{gutter:15},{default:u(()=>[n(A,{lg:12},{default:u(()=>[n(i,{label:c(d)("From Name"),"label-position":"top"},{default:u(()=>[n(s,{animated:"",class:"h-9 gap-2"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),a[0]||(a[0]=o("br",null,null,-1)),o("div",null,[o("div",Zce,[o("p",null,f(c(d)("Name that will be used to send emails")),1)])])]),_:1,__:[0]},8,["label"])]),_:1}),n(A,{lg:12},{default:u(()=>[n(i,{label:c(d)("From Email"),"label-position":"top"},{default:u(()=>[n(s,{animated:"",class:"h-9"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),o("div",null,[o("div",eAe,[o("p",null,f(c(d)(`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:u(()=>[n(A,{lg:12},{default:u(()=>[n(i,{label:c(d)("Reply to name (Optional)"),"label-position":"top"},{default:u(()=>[n(s,{animated:"",class:"h-9"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),o("div",tAe,[o("p",null,f(c(d)("Name that will be used for reply to attribute")),1)])]),_:1},8,["label"])]),_:1}),n(A,{lg:12},{default:u(()=>[n(i,{label:c(d)("Reply to email (Optional)"),"label-position":"top"},{default:u(()=>[n(s,{animated:"",class:"h-9"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1}),o("div",null,[o("div",aAe,[o("p",null,f(c(d)(`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:u(()=>[n(A,null,{default:u(()=>[o("div",lAe,f(c(d)("Email Footer")),1),o("div",sAe,[n(s,{animated:"",rows:7})]),o("div",nAe,[o("div",oAe,[o("p",null,f(c(d)(`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",iAe,[n(s,{animated:"",class:"h-5"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1})])]),_:1})]),_:1}),n(p,{gutter:15},{default:u(()=>[n(A,null,{default:u(()=>[n(i,null,{default:u(()=>[n(p,{gutter:15,class:"w-full"},{default:u(()=>[n(A,{lg:12},{default:u(()=>[o("div",rAe,[o("span",dAe,f(c(d)("Admin Email Address")),1),o("div",uAe,[o("p",null,f(c(d)("FluentCart will send admin notification to this email address.")),1)])])]),_:1}),n(A,{lg:12},{default:u(()=>[o("div",cAe,[n(s,{animated:"",class:"h-9"},{template:u(()=>[n(l,{variant:"p",class:"w-full h-4"})]),_:1})])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})}}},pAe={class:"setting-wrap"},fAe={class:"setting-wrap-inner"},mAe={class:"form-note"},hAe={class:"form-note"},_Ae={class:"form-note"},vAe={class:"form-note"},gAe={class:"el-form-item__label"},yAe={class:"mt-2 mb-2"},bAe={class:"form-note"},wAe={class:"fct-powered-by-email-footer-checkbox"},CAe={class:"setting-html-wrapper"},kAe={class:"setting-label"},BAe={class:"form-note"},xAe={class:"setting-fields-inner w-full"},SAe={class:"setting-save-action"},$Ae={__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=je.get("app_config.isProActive"),l=T(!1),s=T({}),i=T({}),A=()=>{l.value=!0,ce.get("email-notification/get-settings").then(m=>{var _,g,y,v,k,w,b;t.value={from_name:(_=m.data)==null?void 0:_.from_name,from_email:(g=m.data)==null?void 0:g.from_email,reply_to_name:(y=m.data)==null?void 0:y.reply_to_name,reply_to_email:(v=m.data)==null?void 0:v.reply_to_email,email_footer:(k=m.data)==null?void 0:k.email_footer,admin_email:(w=m.data)==null?void 0:w.admin_email,show_email_footer:((b=m.data)==null?void 0:b.show_email_footer)||"yes"},i.value=m.shortcodes}).catch(m=>{}).finally(()=>{l.value=!1})},p=()=>{l.value=!0,s.value={},ce.post("email-notification/save-settings",t.value).then(m=>{q.success(m.message)}).catch(m=>{m.status_code===422&&m.data?s.value=m.data:m.message?q.error(m.message):(q.error(d("Something went wrong")),s.value=m)}).finally(()=>{l.value=!1})};return De(()=>{A()}),(m,_)=>{const g=C("el-input"),y=C("el-form-item"),v=C("el-col"),k=C("el-row"),w=C("el-tooltip"),b=C("el-checkbox"),x=C("el-button");return r(),h("div",pAe,[n($a,{heading:c(d)("Mailing Settings"),loading:l.value,onOnSave:p},null,8,["heading","loading"]),o("div",fAe,[n(Fa),n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Email Configuration"),text:c(d)("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(AAe,{key:0})):(r(),E(xe,{key:1},{default:u(()=>[n(k,{gutter:15},{default:u(()=>[n(v,{lg:12},{default:u(()=>[n(y,{label:c(d)("From Name"),"label-position":"top"},{default:u(()=>[n(g,{modelValue:t.value.from_name,"onUpdate:modelValue":_[0]||(_[0]=F=>t.value.from_name=F)},null,8,["modelValue"]),_[9]||(_[9]=o("br",null,null,-1)),o("div",null,[n(vl,{"validation-errors":s.value.from_name||{},"field-key":"from_name"},null,8,["validation-errors"]),o("div",mAe,[o("p",null,f(c(d)("Name that will be used to send emails")),1)])])]),_:1,__:[9]},8,["label"])]),_:1}),n(v,{lg:12},{default:u(()=>[n(y,{label:c(d)("From Email"),"label-position":"top"},{default:u(()=>[n(g,{modelValue:t.value.from_email,"onUpdate:modelValue":_[1]||(_[1]=F=>t.value.from_email=F)},null,8,["modelValue"]),o("div",null,[n(vl,{"validation-errors":s.value.from_email||{},"field-key":"from_email"},null,8,["validation-errors"]),o("div",hAe,[o("p",null,f(c(d)(`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(k,{gutter:15},{default:u(()=>[n(v,{lg:12},{default:u(()=>[n(y,{label:c(d)("Reply to name (Optional)"),"label-position":"top"},{default:u(()=>[n(g,{modelValue:t.value.reply_to_name,"onUpdate:modelValue":_[2]||(_[2]=F=>t.value.reply_to_name=F)},null,8,["modelValue"]),o("div",_Ae,[o("p",null,f(c(d)("Name that will be used for reply to attribute")),1)])]),_:1},8,["label"])]),_:1}),n(v,{lg:12},{default:u(()=>[n(y,{label:c(d)("Reply to email (Optional)"),"label-position":"top"},{default:u(()=>[n(g,{modelValue:t.value.reply_to_email,"onUpdate:modelValue":_[3]||(_[3]=F=>t.value.reply_to_email=F)},null,8,["modelValue"]),o("div",null,[n(vl,{"validation-errors":s.value.reply_to_email||{},"field-key":"reply_to_email"},null,8,["validation-errors"]),o("div",vAe,[o("p",null,f(c(d)(`If someone replies to your notification email, this is where you would like to
receive it.`)),1)])])]),_:1},8,["label"])]),_:1})]),_:1}),n(k,{gutter:15},{default:u(()=>[n(v,null,{default:u(()=>[o("div",gAe,f(c(d)("Email Footer")),1),n(ss,{"short-codes":i.value,modelValue:t.value.email_footer,"onUpdate:modelValue":_[4]||(_[4]=F=>t.value.email_footer=F),onUpdate:_[5]||(_[5]=F=>{t.value.email_footer=F})},null,8,["short-codes","modelValue"]),o("div",yAe,[n(vl,{"validation-errors":s.value.email_footer||{},"field-key":"email_footer"},null,8,["validation-errors"]),o("div",bAe,[o("p",null,f(c(d)(`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",wAe,[n(b,{modelValue:t.value.show_email_footer,"onUpdate:modelValue":_[6]||(_[6]=F=>t.value.show_email_footer=F),"true-value":"yes","false-value":"no",disabled:!c(a)},{default:u(()=>[R(f(c(d)("Enable powered by FluentCart in the email footer"))+" ",1),c(a)?B("",!0):(r(),E(w,{key:0,"popper-class":"fct-tooltip",placement:"top"},{content:u(()=>[R(f(c(d)("This feature is available in pro version only.")),1)]),default:u(()=>[n(J,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),_:1},8,["modelValue","disabled"])])]),_:1})]),_:1}),n(k,{gutter:15},{default:u(()=>[n(v,null,{default:u(()=>[n(y,null,{default:u(()=>[n(k,{gutter:15,class:"w-full"},{default:u(()=>[n(v,{lg:12},{default:u(()=>[o("div",CAe,[o("span",kAe,f(c(d)("Admin Email Address")),1),o("div",BAe,[o("p",null,f(c(d)("FluentCart will send admin notification to this email address.")),1)])])]),_:1}),n(v,{lg:12},{default:u(()=>[o("div",xAe,[n(g,{modelValue:t.value.admin_email,"onUpdate:modelValue":_[7]||(_[7]=F=>t.value.admin_email=F)},null,8,["modelValue"])])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}))]),_:1}),o("div",SAe,[n(x,{type:"primary",onClick:_[8]||(_[8]=F=>p()),loading:l.value},{default:u(()=>[R(f(c(d)("Save Settings")),1)]),_:1},8,["loading"])])])])}}},FAe={class:"setting-wrap"},EAe={class:"setting-wrap-inner"},UAe={class:"form-note"},IAe={class:"form-note"},VAe={class:"form-note",style:{"padding-top":"6px"}},DAe={class:"form-note"},QAe={class:"setting-save-action"},Vc="{{wp.admin_email}}",TAe={__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:d("Daily digest"),desc:d("Yesterday's performance, sent every morning.")},{key:"weekly",label:d("Weekly digest"),desc:d("The previous 7 days, sent on your chosen day.")},{key:"monthly",label:d("Monthly digest"),desc:d("The previous calendar month, sent on the 1st.")}],A=d("Comma-separate multiple addresses. %1$s resolves to the site admin email.",Vc),p=K(()=>{const v=[];for(let k=0;k<24;k++)v.push({value:k,label:String(k).padStart(2,"0")+":00"});return v}),m=[{value:1,label:d("Monday")},{value:2,label:d("Tuesday")},{value:3,label:d("Wednesday")},{value:4,label:d("Thursday")},{value:5,label:d("Friday")},{value:6,label:d("Saturday")},{value:7,label:d("Sunday")}],_=()=>{a.value=!0,ce.get("email-notification/digest-settings").then(v=>{v.data&&(t.value=v.data)}).catch(()=>{}).finally(()=>{a.value=!1})},g=()=>{a.value=!0,l.value={},ce.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(d("Something went wrong"))}).finally(()=>{a.value=!1})},y=v=>{s.value=v,ce.post("email-notification/digest-settings/send-test",{frequency:v}).then(k=>{q.success(k.message)}).catch(k=>{q.error(k.message||d("Could not send the test email."))}).finally(()=>{s.value=""})};return De(()=>{_()}),(v,k)=>{const w=C("el-input"),b=C("el-form-item"),x=C("el-col"),F=C("el-checkbox"),Q=C("el-row"),$=C("el-switch"),S=C("el-option"),U=C("el-select"),V=C("el-button");return r(),h("div",FAe,[n($a,{heading:c(d)("Store Digest Emails"),loading:a.value,onOnSave:g},null,8,["heading","loading"]),o("div",EAe,[n(Fa),n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Recipients & General"),text:c(d)("A system email summarising your store activity. Numbers match the Reports dashboard."),border_bottom:""},null,8,["title","text"]),n(xe,null,{default:u(()=>[n(Q,{gutter:15},{default:u(()=>[n(x,{lg:12},{default:u(()=>[n(b,{label:c(d)("Recipient email addresses"),"label-position":"top"},{default:u(()=>[n(w,{modelValue:t.value.recipients,"onUpdate:modelValue":k[0]||(k[0]=D=>t.value.recipients=D),placeholder:Vc},null,8,["modelValue"]),o("div",null,[n(vl,{"validation-errors":l.value.recipients||{},"field-key":"recipients"},null,8,["validation-errors"]),o("div",UAe,[o("p",null,f(c(A)),1)])])]),_:1},8,["label"])]),_:1}),n(x,{lg:12},{default:u(()=>[n(b,{label:c(d)("Empty periods"),"label-position":"top"},{default:u(()=>[n(F,{modelValue:t.value.send_when_empty,"onUpdate:modelValue":k[1]||(k[1]=D=>t.value.send_when_empty=D),"true-value":"yes","false-value":"no"},{default:u(()=>[R(f(c(d)("Send even when there was no activity")),1)]),_:1},8,["modelValue"]),o("div",IAe,[o("p",null,f(c(d)("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,le(i,D=>n($e,{key:D.key,class:"fct-mt-4"},{default:u(()=>[n(Qe,{title:D.label,text:D.desc,border_bottom:""},null,8,["title","text"]),n(xe,null,{default:u(()=>[n(Q,{gutter:15,align:"middle"},{default:u(()=>[n(x,{lg:6},{default:u(()=>[n(b,{label:c(d)("Enable"),"label-position":"top"},{default:u(()=>[n($,{modelValue:t.value[D.key].enabled,"onUpdate:modelValue":I=>t.value[D.key].enabled=I,"active-value":"yes","inactive-value":"no"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"])]),_:2},1024),n(x,{lg:6},{default:u(()=>[n(b,{label:c(d)("Send time"),"label-position":"top"},{default:u(()=>[n(U,{modelValue:t.value[D.key].send_hour,"onUpdate:modelValue":I=>t.value[D.key].send_hour=I,class:"w-full"},{default:u(()=>[(r(!0),h(P,null,le(p.value,I=>(r(),E(S,{key:I.value,label:I.label,value:I.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"])]),_:2},1024),D.key==="weekly"?(r(),E(x,{key:0,lg:6},{default:u(()=>[n(b,{label:c(d)("Day of week"),"label-position":"top"},{default:u(()=>[n(U,{modelValue:t.value.weekly.send_dow,"onUpdate:modelValue":k[2]||(k[2]=I=>t.value.weekly.send_dow=I),class:"w-full"},{default:u(()=>[(r(),h(P,null,le(m,I=>n(S,{key:I.value,label:I.label,value:I.value},null,8,["label","value"])),64))]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1})):B("",!0),D.key==="monthly"?(r(),E(x,{key:1,lg:6},{default:u(()=>[n(b,{label:c(d)("Send day"),"label-position":"top"},{default:u(()=>[o("div",VAe,[o("p",null,f(c(d)("Sent on the 1st of each month.")),1)])]),_:1},8,["label"])]),_:1})):B("",!0),n(x,{lg:6},{default:u(()=>[n(b,{label:" ","label-position":"top"},{default:u(()=>[n(V,{loading:s.value===D.key,onClick:I=>y(D.key),class:"mt-2"},{default:u(()=>[R(f(c(d)("Send test email")),1)]),_:2},1032,["loading","onClick"])]),_:2},1024)]),_:2},1024)]),_:2},1024),o("div",DAe,[o("p",null,f(c(d)("Send time is in your store timezone. Test emails use your saved recipients.")),1)])]),_:2},1024)]),_:2},1024)),64)),o("div",QAe,[n(V,{type:"primary",onClick:k[3]||(k[3]=D=>g()),loading:a.value},{default:u(()=>[R(f(c(d)("Save Settings")),1)]),_:1},8,["loading"])])])])}}},MAe={};function LAe(e,t){const a=C("router-view");return r(),h("div",null,[n(a)])}const RAe=nt(MAe,[["render",LAe]]),OAe={},PAe={class:"fct-setting-form-row"},HAe={class:"w-[300px]"},NAe={class:"flex-grow flex-shrink flex-basis-0 self-center"},KAe={class:"fct-setting-form-row"},GAe={class:"w-[300px]"},zAe={class:"flex-grow flex-shrink flex-basis-0 self-center"},jAe={class:"fct-setting-form-row"},qAe={class:"w-[300px]"},YAe={class:"flex-grow flex-shrink flex-basis-0 self-center"};function WAe(e,t){const a=C("el-skeleton-item"),l=C("el-skeleton");return r(),h("div",null,[o("div",PAe,[o("div",HAe,[n(l,{animated:"",class:"max-w-[70%]"},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1}),n(l,{animated:"",class:"max-w-[80%]"},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"}),n(a,{variant:"p",class:"w-1/2 h-4"})]),_:1})]),o("div",NAe,[n(l,{animated:""},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])]),o("div",KAe,[o("div",GAe,[n(l,{animated:"",class:"max-w-[60%]"},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1}),n(l,{animated:"",class:"max-w-full"},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})]),o("div",zAe,[n(l,{animated:""},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])]),o("div",jAe,[o("div",qAe,[n(l,{animated:"",class:"max-w-[50%]"},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1}),n(l,{animated:"",class:"max-w-full"},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})]),o("div",YAe,[n(l,{animated:""},{template:u(()=>[n(a,{variant:"p",class:"w-full h-4"})]),_:1})])])])}const XAe=nt(OAe,[["render",WAe]]),JAe={name:"TaxConfigurations",components:{TaxConfigurationsLoader:XAe,CardContainer:$e,CardBody:xe,CardHeader:Qe,LabelHint:Rt,SettingsHeader:$a,AdminNotice:Fa,Animation:_a},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:d,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,je.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=is(),this.keyboardShortcuts.bind(["mod+s"],e=>{e.preventDefault(),this.saveSettings()})},unbindSaveShortcut(){var e;(e=this.keyboardShortcuts)!=null&&e.unbind&&this.keyboardShortcuts.unbind("mod+s")}}},ZAe={class:"setting-wrap"},epe={class:"setting-wrap-inner"},tpe={class:"fct-setting-form-row"},ape={class:"fct-setting-form-content flex gap-3.5 flex-1"},lpe={class:"fct-inline-tip"},spe={key:1},npe={class:"fct-setting-form-row"},ope={class:"fct-setting-form-content"},ipe={class:"fct-inline-tip"},rpe={class:"fct-setting-form-fields self-center"},dpe={class:"fct-inline-tip mt-2"},upe={class:"fct-setting-form-row"},cpe={class:"fct-setting-form-content"},Ape={class:"fct-inline-tip"},ppe={class:"fct-setting-form-fields self-center"},fpe={class:"flex flex-col"},mpe={class:"price-mode-label"},hpe={class:"price-mode-text"},_pe={class:"flex flex-col"},vpe={class:"price-mode-label"},gpe={class:"price-mode-text"},ype={class:"fct-setting-form-row"},bpe={class:"fct-setting-form-content"},wpe={class:"fct-inline-tip"},Cpe={class:"fct-setting-form-fields self-center"},kpe={class:"fct-setting-form-row"},Bpe={class:"fct-setting-form-content"},xpe={class:"fct-inline-tip"},Spe={class:"fct-setting-form-fields self-center"},$pe={class:"fct-setting-form-row"},Fpe={class:"fct-setting-form-content"},Epe={class:"fct-inline-tip"},Upe={class:"fct-setting-form-fields self-center"},Ipe={class:"fct-setting-form-row"},Vpe={class:"fct-setting-form-content"},Dpe={class:"fct-inline-tip"},Qpe={class:"fct-setting-form-fields self-center"},Tpe={key:0,class:"fct-setting-form-row"},Mpe={class:"fct-setting-form-content"},Lpe={class:"fct-inline-tip"},Rpe={class:"fct-setting-form-fields self-center"},Ope={class:"fct-setting-form-row"},Ppe={class:"fct-setting-form-content"},Hpe={class:"fct-inline-tip"},Npe={class:"fct-setting-form-fields"},Kpe={class:"fct-vat-charge-setting-wrap grid gap-5 w-full"},Gpe={class:"fct-local-reverse-charge flex gap-2 justify-items-start"},zpe={class:"fct-inline-tip"},jpe={class:"fct-vat-excluded-categories"},qpe={class:"fct-inline-tip"};function Ype(e,t,a,l,s,i){const A=C("SettingsHeader"),p=C("AdminNotice"),m=C("el-switch"),_=C("LabelHint"),g=C("TaxConfigurationsLoader"),y=C("el-radio"),v=C("el-radio-group"),k=C("el-option"),w=C("el-select"),b=C("el-input"),x=C("Animation"),F=C("CardBody"),Q=C("CardContainer"),$=Ta("loading");return r(),h("div",ZAe,[n(A,{heading:i.translate("Tax Configuration"),loading:s.saving,"show-cmnd-icon":!0,onOnSave:i.saveSettings},null,8,["heading","loading","onOnSave"]),o("div",epe,[n(p),n(Q,null,{default:u(()=>[n(F,null,{default:u(()=>[o("div",tpe,[o("div",ape,[n(m,{modelValue:s.settings.enable_tax,"onUpdate:modelValue":t[0]||(t[0]=S=>s.settings.enable_tax=S),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"]),o("div",null,[n(_,{title:i.translate("Enable Tax")},null,8,["title"]),o("p",lpe,f(s.settings.enable_tax==="yes"?i.translate("This store is now collecting tax."):i.translate("This store is not collecting tax.")),1)])])]),n(x,{visible:s.settings.enable_tax==="yes",accordion:""},{default:u(()=>[s.loading?(r(),E(g,{key:0})):B("",!0),s.loading?B("",!0):(r(),h("div",spe,[o("div",npe,[o("div",ope,[n(_,{title:i.translate("Prices entered with tax")},null,8,["title"]),o("p",ipe,f(i.translate("Choose whether product prices are entered including or excluding tax.")),1)]),o("div",rpe,[n(v,{modelValue:s.settings.tax_inclusion,"onUpdate:modelValue":t[1]||(t[1]=S=>s.settings.tax_inclusion=S)},{default:u(()=>[n(y,{value:"included"},{default:u(()=>[R(f(i.translate("Included")),1)]),_:1}),n(y,{value:"excluded"},{default:u(()=>[R(f(i.translate("Excluded")),1)]),_:1})]),_:1},8,["modelValue"]),o("p",dpe,f(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",upe,[o("div",cpe,[n(_,{title:i.translate("Tax-Inclusive Price Mode")},null,8,["title"]),o("p",Ape,f(i.translate("Controls how reverse charge affects tax-inclusive product prices.")),1)]),o("div",ppe,[n(v,{modelValue:s.settings.eu_vat_settings.reverse_charge_price_mode,"onUpdate:modelValue":t[2]||(t[2]=S=>s.settings.eu_vat_settings.reverse_charge_price_mode=S),class:"fct-reverse-charge-price-mode"},{default:u(()=>[n(y,{value:"fixed"},{default:u(()=>[o("div",fpe,[o("span",mpe,f(i.translate("Fixed")),1),o("span",hpe,f(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:u(()=>[o("div",_pe,[o("span",vpe,f(i.translate("Dynamic")),1),o("span",gpe,f(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",ype,[o("div",bpe,[n(_,{title:i.translate("Calculate Tax Based On")},null,8,["title"]),o("p",wpe,f(i.translate("Determine the location used for tax calculations.")),1)]),o("div",Cpe,[n(w,{modelValue:s.settings.tax_calculation_basis,"onUpdate:modelValue":t[3]||(t[3]=S=>s.settings.tax_calculation_basis=S),clearable:""},{default:u(()=>[n(k,{value:"shipping",label:i.translate("Customer Shipping Address")},null,8,["label"]),n(k,{value:"billing",label:i.translate("Customer Billing Address")},null,8,["label"]),n(k,{value:"store",label:i.translate("Store Location")},null,8,["label"])]),_:1},8,["modelValue"])])]),o("div",kpe,[o("div",Bpe,[n(_,{title:i.translate("Price Suffix (Tax Included)")},null,8,["title"]),o("p",xpe,f(i.translate("Shown on prices where tax is included. Applies when product or store pricing is tax-inclusive.")),1)]),o("div",Spe,[n(b,{modelValue:s.settings.price_suffix_included,"onUpdate:modelValue":t[4]||(t[4]=S=>s.settings.price_suffix_included=S),placeholder:i.translate("e.g. (incl. tax)")},null,8,["modelValue","placeholder"])])]),o("div",$pe,[o("div",Fpe,[n(_,{title:i.translate("Price Suffix (Tax Excluded)")},null,8,["title"]),o("p",Epe,f(i.translate("Shown on prices where tax is excluded. Applies when product or store pricing is tax-exclusive.")),1)]),o("div",Upe,[n(b,{modelValue:s.settings.price_suffix_excluded,"onUpdate:modelValue":t[5]||(t[5]=S=>s.settings.price_suffix_excluded=S),placeholder:i.translate("e.g. (+ tax)")},null,8,["modelValue","placeholder"])])]),o("div",Ipe,[o("div",Vpe,[n(_,{title:i.translate("Tax Display Style")},null,8,["title"]),o("p",Dpe,f(i.translate("Choose how tax context appears on each checkout line item.")),1)]),o("div",Qpe,[n(w,{modelValue:s.settings.checkout_tax_breakdown_display,"onUpdate:modelValue":t[6]||(t[6]=S=>s.settings.checkout_tax_breakdown_display=S)},{default:u(()=>[n(k,{value:"simplified",label:i.translate("Simplified (single line + details)")},null,8,["label"]),n(k,{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",Tpe,[o("div",Mpe,[n(_,{title:i.translate("Tax Line Label")},null,8,["title"]),o("p",Lpe,f(i.translate("The single-line tax label shown in Simplified mode, e.g. VAT, MwSt, GST.")),1)]),o("div",Rpe,[n(b,{modelValue:s.settings.tax_display_label,"onUpdate:modelValue":t[7]||(t[7]=S=>s.settings.tax_display_label=S),placeholder:i.translate("e.g. Tax")},null,8,["modelValue","placeholder"])])])):B("",!0),o("div",Ope,[o("div",Ppe,[n(_,{title:i.translate("VAT Reverse Charge Settings")},null,8,["title"]),o("p",Hpe,f(i.translate("Configure reverse VAT handling for customers in the European Union.")),1)]),o("div",Npe,[o("div",Kpe,[o("div",Gpe,[n(m,{modelValue:s.settings.eu_vat_settings.local_reverse_charge,"onUpdate:modelValue":t[8]||(t[8]=S=>s.settings.eu_vat_settings.local_reverse_charge=S),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"]),o("div",null,[n(_,{title:i.translate("Local Reverse Charge")},null,8,["title"]),o("p",zpe,f(i.translate("If enabled, apply reverse charge when applicable even when customers are in your home country.")),1)])]),n(x,{visible:i.handlePriceMode,accordion:""},{default:u(()=>[o("div",jpe,[n(_,{title:i.translate("Exclude Categories from VAT reverse")},null,8,["title"]),o("p",qpe,f(i.translate("Select product categories that should NOT get VAT reverse charge !")),1),Wt((r(),E(w,{modelValue:s.settings.eu_vat_settings.vat_reverse_excluded_categories,"onUpdate:modelValue":t[9]||(t[9]=S=>s.settings.eu_vat_settings.vat_reverse_excluded_categories=S),filterable:"",multiple:"",clearable:"",placeholder:i.translate("Select Product Categories"),class:"w-full mt-4"},{default:u(()=>[(r(!0),h(P,null,le(s.categories,S=>(r(),E(k,{key:S.value||S.term_id,label:S.label||S.name,value:S.value||S.term_id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])),[[$,s.fetchingCategories]])])]),_:1},8,["visible"])])])])]))]),_:1},8,["visible"])]),_:1})]),_:1})])])}const Wpe=nt(JAe,[["render",Ype]]),Xpe={class:"fct-tax-rates-wrap-loader px-5"},Jpe={__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",Xpe,[(r(!0),h(P,null,le(t.value,(A,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:fa({width:A}),class:"h-4"},{template:u(()=>[n(s,{variant:"p",class:"h-4"})]),_:2},1032,["style"]),n(i,{animated:"",class:"w-[100px] h-4"},{template:u(()=>[n(s,{variant:"p",class:"h-4"})]),_:1})]))),128))])}}},Zpe={class:"setting-wrap"},efe={class:"setting-wrap-inner"},tfe={class:"fct-all-tax-classes-page"},afe={class:"flex items-center justify-end gap-4"},lfe={key:0,class:"px-6 py-4 border-b border-gray-200 dark:border-gray-700"},sfe={class:"inline-flex items-center gap-2"},nfe={class:"inline-flex items-center gap-2"},ofe=["src","alt"],ife={key:0,class:"text-gray-400 dark:text-gray-300"},rfe={key:1,class:"text-success-500"},dfe={key:2,class:"text-system-mid dark:text-gray-300"},ufe={key:3,class:"text-gray-400 dark:text-gray-300"},cfe={key:1,class:"text-gray-400"},Afe={__name:"TaxRates",setup(e){const t=T({}),a=T([]),l=T({}),s=T({}),i=K(()=>!!je.get("is_tax_enabled")),A=T(!1),p=T({}),m={};let _=0;const g=T(""),y=T(!1),v={XI:"gb"},k=I=>(v[I]||I).toLowerCase(),w=K(()=>{const I=new Set;for(const L of a.value)for(const O of L.countries||[])I.add(O.country_code);return I}),b=I=>!I||!Object.prototype.hasOwnProperty.call(s.value,I)?!0:s.value[I],x=I=>!I||!I.vat?!1:I.rates&&typeof I.rates=="object"&&Object.keys(I.rates).length?Object.values(I.rates).some(L=>L&&parseFloat(L.rate)>0):parseFloat(I.rate)>0,F=K(()=>{const I=l.value||{},L=Array.isArray(I.country_registrations)?I.country_registrations:[],O=I.method||"",M=L.some(x);if(O==="oss")return!!I.oss_country;if(O==="home"){const H=I.home_country||"",z=L.find(X=>X.country===H);if(H&&z&&x(z))return!0}return O==="specific"?!!I.home_country:M}),Q=K(()=>{const I=l.value||{},L=Array.isArray(I.country_registrations)?I.country_registrations:[],O=I.method||"";return O==="oss"?!!I.oss_country:O==="home"?!!I.home_country&&L.some(M=>M.country===I.home_country):O==="specific"?!!I.home_country:L.some(x)}),$=K(()=>{const I=[],L=Object.values(t.value||{});for(const H of L)if(H.group_code==="EU")I.push({country_code:"EU",country_name:"European Union",isEU:!0,group_code:"EU",hasConfig:Q.value,enabled:b("EU"),collecting:Q.value&&F.value&&b("EU")});else for(const z of H.countries||[]){const X=w.value.has(z.country_code),G=b(z.country_code);I.push({country_code:z.country_code,country_name:z.country_name,isEU:!1,group_code:H.group_code,hasConfig:X,enabled:G,collecting:X&&G})}const O=["EU","US","GB","AU","CA","NZ","IN","SG","JP"],M=new Set(O);return I.sort((H,z)=>{if(H.hasConfig!==z.hasConfig)return H.hasConfig?-1:1;const X=M.has(H.country_code),G=M.has(z.country_code);return X&&G?O.indexOf(H.country_code)-O.indexOf(z.country_code):X?-1:G?1:H.country_name.localeCompare(z.country_name)}),I}),S=K(()=>{const I=g.value.trim().toLowerCase();return $.value.filter(L=>y.value&&(!i.value||!L.collecting)?!1:I?L.country_name.toLowerCase().includes(I)||L.country_code.toLowerCase().includes(I):!0)}),U=K(()=>{if(!i.value)return!1;const I=$.value.filter(O=>O.enabled).length,L=$.value.filter(O=>!O.enabled).length;return I>0&&L>0}),V=()=>{A.value=!0,Promise.all([ce.get("tax/configuration/rates"),ce.get("tax/rates"),ce.get("tax/configuration/settings")]).then(([I,L,O])=>{var M;t.value=I.tax_rates,a.value=L.tax_rates,s.value=L.country_enabled_map||{},l.value=((M=O.settings)==null?void 0:M.eu_vat_settings)||{}}).catch(I=>{}).finally(()=>{A.value=!1})},D=(I,L)=>{const O=b(I.country_code),M=++_;m[I.country_code]=M,s.value={...s.value,[I.country_code]:L},p.value={...p.value,[I.country_code]:!0},ce.post("tax/country-status/"+I.country_code,{enabled:L?1:0}).then(H=>{m[I.country_code]===M&&(q.success(H.message),s.value={...s.value,[I.country_code]:H.enabled})}).catch(H=>{var z;m[I.country_code]===M&&(s.value={...s.value,[I.country_code]:O},q.error(((z=H==null?void 0:H.data)==null?void 0:z.message)||d("Failed to update tax status")))}).finally(()=>{if(m[I.country_code]===M){const H={...p.value};delete H[I.country_code],p.value=H}})};return De(()=>{V()}),(I,L)=>{const O=C("el-checkbox"),M=C("el-input"),H=C("el-table-column"),z=C("el-switch"),X=C("el-table");return r(),h("div",Zpe,[n($a,{heading:c(d)("Tax Regions"),"show-save-button":!1},null,8,["heading"]),o("div",efe,[n(Fa),o("div",tfe,[n($e,{class:"overflow-hidden"},{default:u(()=>[n(Qe,{title:c(d)("Tax Regions"),text:c(d)("Manage tax rates for different regions")},{action:u(()=>[o("div",afe,[U.value?(r(),E(O,{key:0,modelValue:y.value,"onUpdate:modelValue":L[0]||(L[0]=G=>y.value=G)},{default:u(()=>[R(f(c(d)("Collecting Tax")),1)]),_:1},8,["modelValue"])):B("",!0),n(M,{modelValue:g.value,"onUpdate:modelValue":L[1]||(L[1]=G=>g.value=G),class:"w-[200px]",placeholder:c(d)("Search regions..."),size:"small",clearable:""},{prefix:u(()=>[n(J,{name:"Search",class:"w-4 h-4"})]),_:1},8,["modelValue","placeholder"])])]),_:1},8,["title","text"]),n(xe,{class:"px-0 pb-0"},{default:u(()=>[!A.value&&!i.value?(r(),h("div",lfe,[n(sl,{type:"warning",icon:"AlertTriangle",content:c(d)("Tax is currently disabled. Enable tax from the Tax Settings page to start collecting tax.")},null,8,["content"])])):B("",!0),A.value?(r(),E(Jpe,{key:1})):(r(),E(X,{key:2,data:S.value,"max-height":"500",class:"w-full compact-table fct-tax-rates-regions-table"},{default:u(()=>[n(H,{label:c(d)("Region"),"min-width":"300"},{default:u(({row:G})=>[G.isEU?(r(),E(ra,{key:0,class:"hover:no-underline",to:{name:"eu"}},{default:u(()=>[o("div",sfe,[L[2]||(L[2]=o("img",{class:"w-[22px] block",src:"https://flagcdn.com/w40/eu.png",alt:"EU"},null,-1)),R(" "+f(G.country_name),1)])]),_:2},1024)):(r(),E(ra,{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:u(()=>[o("div",nfe,[o("img",{class:"w-[22px] block",src:`https://flagcdn.com/w40/${k(G.country_code)}.png`,alt:G.country_code},null,8,ofe),R(" "+f(G.country_name),1)])]),_:2},1032,["to"]))]),_:1},8,["label"]),n(H,{label:c(d)("Collecting"),width:"200"},{default:u(({row:G})=>[i.value?G.collecting?(r(),h("span",rfe,f(c(d)("Collecting tax")),1)):G.hasConfig&&!G.enabled?(r(),h("span",dfe,f(c(d)("Disabled")),1)):(r(),h("span",ufe,"—")):(r(),h("span",ife,"—"))]),_:1},8,["label"]),n(H,{label:c(d)("Enabled"),width:"140",align:"center"},{default:u(({row:G})=>[G.hasConfig?(r(),E(z,{key:0,"model-value":i.value?G.enabled:!1,loading:!!p.value[G.country_code],disabled:!i.value,onChange:Y=>D(G,Y)},null,8,["model-value","loading","disabled","onChange"])):(r(),h("span",cfe,"—"))]),_:1},8,["label"])]),_:1},8,["data"]))]),_:1})]),_:1})])])])}}},pfe={class:"fct-base-taxes"},ffe={class:"fct-tax-class-tabs"},mfe={class:"fct-tax-class-tabs__list"},hfe={class:"fct-base-taxes__header"},_fe={class:"fct-base-taxes__header-label"},vfe={class:"fct-base-taxes__state-row fct-base-taxes__state-row--federal"},gfe={class:"fct-base-taxes__region-name fct-base-taxes__region-name--federal"},yfe={class:"fct-base-taxes__state-fields"},bfe={class:"fct-base-taxes__region-name"},wfe={class:"fct-base-taxes__state-fields"},Cfe={__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",pfe,[o("div",ffe,[o("div",mfe,[(r(),h(P,null,le(3,A=>o("div",{key:A,class:"fct-tax-class-tabs__tab"},[n(i,{animated:""},{template:u(()=>[n(s,{variant:"text",class:"w-16 h-5"})]),_:1})])),64)),n(i,{animated:""},{template:u(()=>[n(s,{variant:"text",class:"w-5 h-5"})]),_:1})])]),o("div",hfe,[o("span",_fe,f(c(d)("Regions")),1)]),o("div",vfe,[o("div",gfe,[n(i,{animated:""},{template:u(()=>[n(s,{variant:"text",class:"w-40 h-5"})]),_:1})]),o("div",yfe,[n(i,{animated:""},{template:u(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-rate h-8"})]),_:1}),n(i,{animated:""},{template:u(()=>[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,le(t,A=>o("div",{key:A,class:"fct-base-taxes__state-row"},[o("div",bfe,[n(i,{animated:""},{template:u(()=>[n(s,{variant:"text",class:"w-32 h-4"})]),_:1})]),o("div",wfe,[n(i,{animated:""},{template:u(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-rate h-8"})]),_:1}),n(i,{animated:""},{template:u(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-name h-8"})]),_:1}),n(i,{animated:""},{template:u(()=>[n(s,{variant:"rect",class:"fct-base-taxes__field-compound h-8"})]),_:1})])])),64))])])}}},kfe={class:"fct-tax-class-tabs"},Bfe={class:"fct-tax-class-tabs__list"},xfe=["onClick"],Sfe=["title","onClick"],$fe=["disabled","title"],Ffe=["disabled","title"],Efe=["disabled"],Ufe=["disabled","title"],Ife={class:"fct-tax-class-tabs__search"},If={__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(""),A=T(null),p=T(!1),m=K(()=>[...a.classes].sort((b,x)=>b.slug==="standard"&&x.slug!=="standard"?-1:b.slug!=="standard"&&x.slug==="standard"?1:0)),_=K(()=>["reduced","zero"].filter(b=>!a.classes.find(x=>x.slug===b))),g=()=>{i.value="",p.value=!1,s.value=!0,Fe(()=>{var b;return(b=A.value)==null?void 0:b.focus()})},y=b=>{if(b==="custom"){g();return}l("add",b)},v=()=>{const b=i.value.trim();if(!b){k();return}l("create-custom",b)},k=()=>{s.value=!1,i.value="",p.value=!1},w=()=>{!a.creating&&!i.value.trim()&&k()};return ke([()=>a.classes.length,()=>a.creating],([b,x],[F,Q])=>{if(s.value){if(b>F){k();return}Q&&!x&&(p.value=!0)}}),ke(i,()=>{p.value=!1}),(b,x)=>{const F=C("el-input"),Q=C("el-dropdown-item"),$=C("el-dropdown-menu"),S=C("el-dropdown");return r(),h("div",kfe,[o("div",Bfe,[(r(!0),h(P,null,le(m.value,U=>(r(),h("button",{key:U.id,class:ue(["fct-tax-class-tabs__tab",{"fct-tax-class-tabs__tab--active":e.activeId==U.id}]),onClick:V=>l("switch",U)},[R(f(U.title)+" ",1),U.slug!=="standard"?(r(),h("span",{key:0,class:"fct-tax-class-tabs__delete",title:c(d)("Delete tax class"),onClick:Ge(V=>l("delete",U),["stop"])},[n(J,{name:"Close"})],8,Sfe)):B("",!0)],10,xfe))),128)),e.classes.length
i.value=U),size:"small",maxlength:"30",disabled:e.creating,placeholder:c(d)("e.g. Luxury"),onKeyup:[da(v,["enter"]),da(k,["esc"])],onBlur:w},null,8,["modelValue","disabled","placeholder"]),o("button",{class:"fct-tax-class-tabs__inline-confirm",disabled:e.creating||!i.value.trim(),title:c(d)("Create tax class"),onMousedown:x[1]||(x[1]=Ge(()=>{},["prevent"])),onClick:v},[n(J,{name:"Check"})],40,$fe),o("button",{class:"fct-tax-class-tabs__inline-cancel",disabled:e.creating,title:c(d)("Cancel"),onMousedown:x[2]||(x[2]=Ge(()=>{},["prevent"])),onClick:k},[n(J,{name:"Close"})],40,Ffe)],2)):_.value.length?(r(),E(S,{key:1,trigger:"click",disabled:e.creating,onCommand:y,"popper-class":"fct-dropdown"},{dropdown:u(()=>[n($,null,{default:u(()=>[_.value.includes("reduced")?(r(),E(Q,{key:0,command:"reduced"},{default:u(()=>[R(f(c(d)("Reduced")),1)]),_:1})):B("",!0),_.value.includes("zero")?(r(),E(Q,{key:1,command:"zero"},{default:u(()=>[R(f(c(d)("Zero")),1)]),_:1})):B("",!0),n(Q,{command:"custom"},{default:u(()=>[R(f(c(d)("Custom Class...")),1)]),_:1})]),_:1})]),default:u(()=>[o("button",{class:"fct-tax-class-tabs__add",disabled:e.creating},[n(J,{name:"Plus"})],8,Efe)]),_:1},8,["disabled"])):(r(),h("button",{key:2,class:"fct-tax-class-tabs__add",disabled:e.creating,title:c(d)("Add custom tax class"),onClick:g},[n(J,{name:"Plus"})],8,Ufe))],64)):B("",!0)]),o("div",Ife,[n(F,{"model-value":e.search,placeholder:c(d)("Search country or region…"),size:"small",clearable:"","onUpdate:modelValue":x[3]||(x[3]=U=>l("update:search",U)),onClear:x[4]||(x[4]=U=>l("update:search",""))},{prefix:u(()=>[n(J,{name:"Search",class:"w-3.5 h-3.5 text-system-light dark:text-gray-400"})]),_:1},8,["model-value","placeholder"]),wa(b.$slots,"search-actions")])])}}},Vfe=(e=[])=>e.find(t=>t.slug==="standard")||e[0]||null,Pd=({classes:e=[],activeId:t=null})=>(t?e.find(l=>l.id===t):null)||Vfe(e),Dfe=({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},ti=async({payload:e,createdSlug:t=null,currentClasses:a=[],reloadClasses:l})=>{const s=new Set((a||[]).map(p=>p.id)),i=await ce.post("tax/classes",e),A=await l();return{response:i,classes:A,createdClass:Dfe({classes:A,previousIds:s,createdSlug:t})}},Vf=async({classId:e,currentActiveId:t=null,reloadClasses:a})=>{const l=await ce.delete("tax/classes/"+e),s=await a();return{response:l,classes:s,nextActiveClass:Pd({classes:s,activeId:t})}};function on(e){return e==null||e===""?"":String(e)}const Qfe={class:"setting-wrap"},Tfe={class:"setting-wrap-inner"},Mfe={class:"fct-single-tax-rates-country-single-page"},Lfe={class:"fct-single-tax-rates-country-single"},Rfe={class:"single-page-header flex items-center justify-between"},Ofe={key:0,class:"flex items-center gap-2"},Pfe={key:0,class:"notices fct-notices-wrap fct-layout-width settings"},Hfe={class:"mt-3 flex justify-end"},Nfe={key:1,class:"fct-base-taxes"},Kfe={class:"fct-btn-group mt-4 justify-end sm"},Gfe={class:"fct-tax-rates-country-view"},zfe={key:0},jfe={key:1},qfe={key:0},Yfe={key:1},Wfe={class:"fct-btn-group sm justify-end"},Dc={__name:"TaxRatesCountrySingle",props:{country:{type:String},group:{type:String}},setup(e){const t=e,a=T(!1),l=T([]),s=T(""),i=K(()=>!!je.get("is_tax_enabled")),A=T([]),p=T(null),m=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}),k=T({rate:0,name:""}),w=T([]),b=T({}),x=T(""),F=K(()=>{const te=x.value.trim().toLowerCase();return te?w.value.filter(Se=>Se.stateName&&Se.stateName.toLowerCase().includes(te)):w.value}),Q=K(()=>t.group==="EU"),$=K(()=>[v.value,...F.value]),S=T([]),U=T(!1),V=T([]),D=T([]),I=T(!1),L=T(new Set),O=T(0),M=T([]),H=T(!1),z=T(!1),X=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:""}),Y=K(()=>{const te=v.value.rate||0;return[{label:d("added to")+` ${te}% `+d("federal tax"),is_compound:"0",for_order:0},{label:d("instead of")+` ${te}% `+d("federal tax"),is_compound:"0",for_order:1},{label:d("compounded on top of")+` ${te}% `+d("federal tax"),is_compound:"1",for_order:0}]}),Z=te=>String(te.is_compound)==="1"?"1_0":te.for_order==1?"0_1":"0_0",de=(te,Se)=>{const[ne,he]=Se.split("_");te.is_compound=ne,te.for_order=parseInt(he)},j=te=>te&&te.replace(/\s*\(Standard\)\s*/gi,"").trim(),ge=T(!1),ie=T({}),W=T(!1),N=T(""),ae=T(""),ee=T(""),Ae=T(!1),re=T(!1),Ue=T(!0),we=T(!1),Be=T(!1),ve=T(!1),Ce=K(()=>d("Toggle tax collection for %1$s",s.value||t.country)),Oe=()=>ce.get("tax/classes").then(te=>{A.value=te.classes||[],y.value=te.max_classes||6,g.value=te.next_builtin||null;const Se=Pd({classes:A.value,activeId:p.value});return Se&&(p.value=Se.id,m.value=Se.slug),A.value}).catch(te=>A.value),Ee=(te="")=>{if(!te)return v.value.name||"Tax";const Se=w.value.find(ne=>ne.state===te);return Se!=null&&Se.name?Se.name:v.value.name||"Tax"},pe=te=>{v.value={...te.federalRate},k.value={...te.federalOriginal},w.value=te.stateRows.map(Se=>({...Se})),b.value={...te.stateOriginals}},ye=()=>({federalRate:{...v.value},federalOriginal:{...k.value},stateRows:w.value.map(te=>({...te})),stateOriginals:{...b.value}}),Ve=()=>{p.value&&(ie.value[p.value]=ye())},Le=async te=>{Ve(),p.value=te.id,m.value=te.slug,ie.value[te.id]?(pe(ie.value[te.id]),await yt()):await Xt()},At=te=>{_.value=!0,ti({payload:{slug:te},createdSlug:te,currentClasses:A.value,reloadClasses:Oe}).then(({response:Se,createdClass:ne})=>{if(q.success(Se.message),ne)return Le(ne)}).catch(Se=>{var ne;q.error(((ne=Se==null?void 0:Se.data)==null?void 0:ne.message)||"Failed to create tax class")}).finally(()=>{_.value=!1})},mt=te=>{_.value=!0,ti({payload:{title:te},currentClasses:A.value,reloadClasses:Oe}).then(({response:Se,createdClass:ne})=>{if(q.success(Se.message),ne)return Le(ne)}).catch(Se=>{var ne;q.error(((ne=Se==null?void 0:Se.data)==null?void 0:ne.message)||"Failed to create tax class")}).finally(()=>{_.value=!1})},Mt=te=>{const Se=p.value===te.id;Pa(d("All rates for this class will be deleted. Products using it will default to Standard."),d("Delete")+" "+te.title+"?",{confirmButtonText:d("Yes, Delete"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{Vf({classId:te.id,currentActiveId:p.value,reloadClasses:Oe}).then(({response:ne,nextActiveClass:he})=>{if(delete ie.value[te.id],q.success(ne.message),he)return Se&&(p.value=null),Le(he)}).catch(ne=>{var he;q.error(((he=ne==null?void 0:ne.data)==null?void 0:he.message)||"Failed to delete tax class")})}).catch(()=>{})},Dt=()=>ce.get("address-info/get-country-info",{country_code:t.country}).then(te=>{l.value=te.states||[],s.value=te.country_name||t.country}).catch(te=>{q.error(d("Failed to load country data. Please refresh the page."))}),Xe=()=>Q.value?(ae.value="",ee.value="",Promise.resolve()):(Ae.value=!0,ce.get("tax/country-tax-id/"+t.country).then(te=>{var ne;const Se=((ne=te==null?void 0:te.tax_data)==null?void 0:ne.tax_id)||"";ae.value=Se,ee.value=Se}).catch(te=>{var Se;q.error(((Se=te==null?void 0:te.data)==null?void 0:Se.message)||d("Failed to load tax ID"))}).finally(()=>{Ae.value=!1})),pt=({hydrateClassData:te=!0}={})=>ce.get("tax/rates/country/rates/"+t.country).then(Se=>{const ne=Se.tax_rates||[],he=ne.filter(qe=>qe.for_shipping!==null),We=p.value?ne.filter(qe=>Number(qe.class_id)===Number(p.value)):ne;V.value=We.filter(qe=>!qe.city&&!qe.postcode).map(qe=>({name:qe.name,value:qe.id,state:qe.state||""}));const ot=Qt(We);return ve.value=ne.length>0,te&&(pe(ot),Ve(),Ue.value=!!Se.tax_enabled,Be.value=!0),{allRates:ne,shippingOverrides:he,classEntry:ot}}).catch(Se=>(q.error(d("Failed to load tax rates. Please refresh the page.")),{allRates:[],shippingOverrides:[],classEntry:null})),jt=()=>ce.get("tax/product-overrides/"+t.country).then(te=>te.overrides||[]).catch(()=>[]),Ct=()=>{M.value.length>0||(H.value=!0,ce.get("products/fetch-term").then(te=>{const Se=te.taxonomies&&te.taxonomies["product-categories"]?te.taxonomies["product-categories"].terms||[]:[];M.value=Se.map(ne=>({...ne,value:on(ne.value)}))}).catch(()=>{}).finally(()=>{H.value=!1}))};let $t=0;const Ht=te=>{const Se=++$t;return!te||Number(te)===Number(p.value)?(D.value=V.value.slice(),I.value=!1,Promise.resolve()):(I.value=!0,D.value=[],ce.get("tax/rates/country/rates/"+t.country,{class_id:te}).then(ne=>{if(Se!==$t)return;const he=ne.tax_rates||[];D.value=he.filter(We=>!We.city&&!We.postcode).map(We=>({name:We.name,value:We.id,state:We.state||""}))}).catch(()=>{Se===$t&&(D.value=[],q.error(d("Failed to load tax rates for the selected tax class")))}).finally(()=>{Se===$t&&(I.value=!1)}))},Nt=(te,Se)=>{var he,We;const ne=[];for(const ot of te){const qe=ot.state?((he=l.value.find(tt=>tt.value===ot.state))==null?void 0:he.name)||ot.state:s.value||t.country,Ze=Ee(ot.state||""),gt=A.value.find(tt=>Number(tt.id)===Number(ot.class_id));ne.push({id:ot.id,type:"shipping",label:Ze,tax_label:Ze,category_name:"",location:qe,city:ot.city||"",postcode:ot.postcode||"",rate:ot.for_shipping,class_id:Number(ot.class_id)||0,class_label:gt?gt.title:"",_raw:ot})}for(const ot of Se){const qe=ot.meta_value||ot,Ze=qe.state||"",gt=Ze?((We=l.value.find(fe=>fe.value===Ze))==null?void 0:We.name)||Ze:s.value||t.country,tt=Number(ot.class_id)||0,Vt=tt?A.value.find(fe=>Number(fe.id)===tt):null;ne.push({id:ot.id,type:"products",label:qe.category_name||"",tax_label:qe.tax_label||"",category_name:qe.category_name||"",location:gt,city:qe.city||"",postcode:qe.postcode||"",rate:qe.rate,class_id:tt,class_label:Vt?Vt.title:"",_raw:ot})}S.value=ne},Qt=te=>{const Se=tt=>(!tt.state||tt.state==="")&&(!tt.city||tt.city==="")&&(!tt.postcode||tt.postcode===""),ne=te.find(Se),he=te.filter(tt=>tt.state&&tt.state!==""&&(!tt.city||tt.city==="")&&(!tt.postcode||tt.postcode===""));let We,ot;if(ne){const tt=j(ne.name)||"Tax";We={...ne,name:tt},ot={rate:ne.rate,name:tt}}else We={id:null,rate:0,name:"Tax",state:"",is_compound:"0",for_order:0},ot={rate:0,name:"Tax"};const qe={};for(const tt of he)qe[tt.state]=tt;const Ze=[],gt={};for(const tt of l.value){const Vt=qe[tt.value];if(Vt){const fe=j(Vt.name)||"State Tax";Ze.push({id:Vt.id,state:tt.value,stateName:tt.name,rate:Vt.rate,name:fe,is_compound:String(Vt.is_compound||"0"),for_order:Vt.for_order||0}),gt[tt.value]={rate:Vt.rate,name:fe,is_compound:String(Vt.is_compound||"0"),for_order:Vt.for_order||0}}else Ze.push({id:null,state:tt.value,stateName:tt.name,rate:0,name:"State Tax",is_compound:"0",for_order:0}),gt[tt.value]={rate:0,name:"State Tax",is_compound:"0",for_order:0}}return{federalRate:We,federalOriginal:ot,stateRows:Ze,stateOriginals:gt}},yt=async()=>{const[{shippingOverrides:te},Se]=await Promise.all([pt({hydrateClassData:!1}),jt()]);Nt(te,Se)},Xt=async()=>{a.value=!0;try{const[{shippingOverrides:te},Se]=await Promise.all([pt(),jt()]);Nt(te,Se)}finally{a.value=!1}},be=async()=>{a.value=!0;try{await Promise.all([Oe(),Dt(),Xe()]),await Xt()}finally{a.value=!1}},Ie=()=>{Q.value||re.value||Ae.value||(re.value=!0,ce.post("tax/country-tax-id/"+t.country,{tax_id:ae.value||""}).then(te=>{ee.value=ae.value||"",q.success(te.message||d("Tax ID has been saved successfully"))}).catch(te=>{var Se;q.error(((Se=te==null?void 0:te.data)==null?void 0:Se.message)||d("Failed to save tax ID"))}).finally(()=>{re.value=!1}))},it=te=>{if(we.value)return;const Se=Ue.value;Ue.value=te,we.value=!0,ce.post("tax/country-status/"+t.country,{enabled:te?1:0}).then(ne=>{Ue.value=ne.enabled,q.success(ne.message)}).catch(ne=>{var he;Ue.value=Se,q.error(((he=ne==null?void 0:ne.data)==null?void 0:he.message)||d("Failed to update tax status"))}).finally(()=>{we.value=!1})},kt=async()=>{try{await Pa(d("This will overwrite your current rates with preset defaults. Continue?"),d("Reset to default tax rates"),{confirmButtonText:d("Reset"),cancelButtonText:d("Cancel"),type:"warning"})}catch{return}W.value=!0;try{const Se=(await ce.get("tax/configuration/rates")).tax_rates||{};let ne=[];for(const Ze in Se){const gt=Se[Ze];for(const tt of gt.countries||[])if(tt.country_code===t.country){ne=tt.rates||[];break}if(ne.length)break}if(!ne.length){q.error(d("No preset rates found for this country"));return}const he=ne.find(Ze=>(!Ze.state||Ze.state==="")&&Ze.type==="standard"),We=ne.filter(Ze=>Ze.state&&Ze.state!==""&&Ze.type==="standard"),ot=[];he&&he.rate>0&&(v.value.rate=he.rate,v.value.name=j(he.name||"")||d("Tax"),ot.push(Bt()));const qe=[];for(const Ze of We){const gt=w.value.find(tt=>tt.state===Ze.state);gt&&(gt.rate=Ze.rate,gt.name=j(Ze.name)||d("State Tax"),gt.is_compound=Ze.compound?"1":"0",qe.push(ta(gt)))}await Promise.all([...ot,...qe]),Ve(),await yt(),q.success(d("Tax rates have been reset to defaults"))}catch{q.error(d("Failed to reset tax rates"))}finally{W.value=!1}},Bt=()=>{const te={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?ce.put("tax/country/rate/"+v.value.id,te):ce.post("tax/country/rate",te)).then(ne=>{ne.tax_rate&&(v.value.id=ne.tax_rate.id),k.value={rate:v.value.rate,name:v.value.name}})},ta=te=>{const Se={country:t.country,state:te.state,rate:te.rate,name:te.name,is_compound:te.is_compound,for_order:te.for_order,group:t.group,class_id:p.value||""};return(te.id?ce.put("tax/country/rate/"+te.id,Se):ce.post("tax/country/rate",Se)).then(he=>{he.tax_rate&&(te.id=he.tax_rate.id),b.value[te.state]={rate:te.rate,name:te.name,is_compound:String(te.is_compound),for_order:te.for_order}})},bt=async()=>{ge.value=!0;try{const te=[];(String(v.value.rate)!==String(k.value.rate)||v.value.name!==k.value.name)&&te.push(Bt());for(const ne of w.value){const he=b.value[ne.state];(!he||String(ne.rate)!==String(he.rate)||ne.name!==he.name||String(ne.is_compound)!==String(he.is_compound)||ne.for_order!=he.for_order)&&te.push(ta(ne))}await Promise.all(te),Ve(),await yt(),q.success(d("Tax rates saved"))}catch{q.error(d("Failed to save rates"))}finally{ge.value=!1}},sa=()=>{L.value=new Set,O.value=0},na=()=>{const te=Ee();X.value=!1,G.value={type:"products",original_type:"",original_id:"",category_id:"",category_name:"",state:"__country__",city:"",postcode:"",tax_label:te,tax_rate:0,override_state_tax:!0,class_id:Number(p.value)||0,id:"",previous_id:""},N.value=te,D.value=V.value.slice(),U.value=!0,Ct()},qt=te=>{if(X.value=!0,Ct(),te.type==="shipping"){const Se=te._raw.state||"",ne=Ee(Se),he=Number(te._raw.class_id)||Number(p.value)||0;G.value={type:"shipping",original_type:"shipping",original_id:te.id,category_id:"",category_name:"",state:Se||"__country__",city:te._raw.city||"",postcode:te._raw.postcode||"",tax_label:ne,tax_rate:te.rate,override_state_tax:!0,class_id:he,id:te.id,previous_id:te.id},N.value=ne,O.value=he,Ht(he);const We=te._raw.city||"",ot=te._raw.postcode||"",qe=new Set;for(const Ze of S.value)Ze.type==="shipping"&&(Ze._raw.state||"")===Se&&(Ze._raw.city||"")===We&&(Ze._raw.postcode||"")===ot&&qe.add(Number(Ze.class_id));L.value=qe}else{const Se=te._raw.meta_value||te._raw,ne=Se.state||"",he=Ee(ne),We=te.tax_label||he;G.value={type:"products",original_type:"products",original_id:te.id,category_id:on(Se.category_id),category_name:te.category_name,state:ne||"__country__",tax_label:We,tax_rate:te.rate,override_state_tax:Se.override_state_tax==="yes",city:Se.city||"",postcode:Se.postcode||"",class_id:te.class_id||0,id:te.id,previous_id:""},N.value=he}U.value=!0},ka=K(()=>{const te=[{label:s.value||t.country,value:"__country__"}];for(const Se of l.value)te.push({label:Se.name,value:Se.value});return te}),Ja=K(()=>{if(!D.value.length)return ka.value;const te=new Set(D.value.map(Se=>Se.state||""));return ka.value.filter(Se=>{const ne=Se.value==="__country__"?"":Se.value;return te.has(ne)})}),ul=te=>{const Se=on(te),ne=M.value.find(he=>he.value===Se);ne&&(G.value.category_name=ne.label)},Za=te=>{Pa(d("Are you sure you want to delete this override?"),d("Confirm Delete"),{confirmButtonText:d("Yes, Delete"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{const Se=te.type==="shipping"?"tax/rates/country/override/"+te.id:"tax/product-overrides/"+te.id;ce.delete(Se).then(ne=>{q.success(ne.message),S.value=S.value.filter(he=>!(he.id===te.id&&he.type===te.type))}).catch(ne=>{var he;q.error(((he=ne==null?void 0:ne.data)==null?void 0:he.message)||d("Failed to delete override"))})}).catch(()=>{})},va=async()=>{var Se;const te=G.value.state==="__country__"?"":G.value.state;if(G.value.type==="products"&&!G.value.category_id){q.error(d("Please select a category"));return}if(G.value.type==="shipping"){if(!G.value.class_id){q.error(d("Please select a tax class"));return}if(I.value){q.error(d("Please wait for the province rates to finish loading"));return}const ne=D.value.find(he=>(he.state||"")===te);G.value.id=ne?ne.value:0}z.value=!0;try{let ne;if(G.value.type==="products"){const he=G.value.state==="__country__"?"":G.value.state;ne=await ce.post("tax/product-overrides",{id:X.value&&G.value.original_type==="products"?G.value.original_id:"",source_type:G.value.original_type,source_id:G.value.original_id,country:t.country,state: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 ne=await ce.post("tax/rates/country/override",{id:G.value.id,country:t.country,state:te,previous_id:X.value&&G.value.original_type==="shipping"?G.value.previous_id:"",source_type:G.value.original_type,source_id:G.value.original_id,class_id:G.value.class_id||p.value||"",override_tax_rate:G.value.tax_rate,city:G.value.city||"",postcode:G.value.postcode||""});q.success(ne.message),U.value=!1,await yt()}catch(ne){const he=((Se=ne==null?void 0:ne.data)==null?void 0:Se.message)||(ne==null?void 0:ne.message)||"Failed to save override";q.error(he)}finally{z.value=!1}};return ke(()=>G.value.type,te=>{te==="shipping"&&(G.value.class_id||(G.value.class_id=p.value||0),Ht(G.value.class_id))}),ke(()=>G.value.class_id,te=>{G.value.type!=="shipping"||!U.value||Ht(te).then(()=>{const Se=G.value.state==="__country__"?"":G.value.state,ne=D.value.map(he=>he.state||"");Se!==""&&!ne.includes(Se)&&(G.value.state="__country__")})}),ke(()=>G.value.state,te=>{if(!U.value||G.value.type!=="products"||X.value)return;const Se=Ee(te==="__country__"?"":te);(!G.value.tax_label||G.value.tax_label===N.value)&&(G.value.tax_label=Se),N.value=Se}),De(()=>{be()}),(te,Se)=>{const ne=C("el-breadcrumb-item"),he=C("el-breadcrumb"),We=C("el-switch"),ot=C("el-skeleton"),qe=C("el-input"),Ze=C("el-form-item"),gt=C("el-form"),tt=C("el-button"),Vt=C("el-table-column"),fe=C("el-option"),_e=C("el-select"),Ne=C("el-table"),Pe=C("el-tag"),ft=C("el-radio"),se=C("el-radio-group"),ze=C("el-checkbox"),_t=C("el-dialog");return r(),h("div",Qfe,[o("div",Tfe,[o("div",Mfe,[o("div",Lfe,[o("div",Rfe,[n(he,{class:"mb-0","separator-icon":c(dl)},{default:u(()=>[e.group==="EU"?(r(),E(ne,{key:0,to:{name:"eu"}},{default:u(()=>[R(f(c(d)("Tax Regions")),1)]),_:1})):(r(),E(ne,{key:1,to:{name:"tax_rates"}},{default:u(()=>[R(f(c(d)("Tax Regions")),1)]),_:1})),n(ne,null,{default:u(()=>[R(f(s.value||e.country),1)]),_:1})]),_:1},8,["separator-icon"]),Be.value&&ve.value?(r(),h("div",Ofe,[i.value?(r(),h("span",{key:0,class:ue(["text-sm",Ue.value?"text-success-500":"text-system-mid dark:text-gray-300"])},f(Ue.value?c(d)("Collecting tax"):c(d)("Disabled")),3)):B("",!0),n(We,{"model-value":i.value?Ue.value:!1,loading:we.value,disabled:!i.value,"aria-label":Ce.value,onChange:it},null,8,["model-value","loading","disabled","aria-label"])])):B("",!0)]),!a.value&&!i.value?(r(),h("div",Pfe,[n(sl,{type:"warning",icon:"AlertTriangle",content:c(d)("Tax is currently disabled. Enable tax from the Tax Settings page to start collecting tax.")},null,8,["content"])])):B("",!0),Q.value?B("",!0):(r(),E($e,{key:1},{default:u(()=>[n(xe,null,{default:u(()=>[Ae.value?(r(),E(ot,{key:0,animated:"",rows:2})):(r(),E(gt,{key:1,"label-position":"top"},{default:u(()=>[n(Ze,{label:c(d)("VAT/GST/Tax Number"),class:"mb-0"},{default:u(()=>[n(qe,{modelValue:ae.value,"onUpdate:modelValue":Se[0]||(Se[0]=Me=>ae.value=Me),placeholder:c(d)("VAT/GST/Tax Number"),maxlength:"255"},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})),o("div",Hfe,[n(tt,{type:"primary",size:"small",loading:re.value,disabled:Ae.value||re.value||ae.value===ee.value,onClick:Ie},{default:u(()=>[R(f(c(d)("Save")),1)]),_:1},8,["loading","disabled"])])]),_:1})]),_:1})),n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Base taxes")},null,8,["title"]),n(xe,null,{default:u(()=>[n(sl,{type:"info"},{content:u(()=>[o("span",null,f(c(d)("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"))+" + "+f(c(d)("button to add tax classes.")),1)]),_:1}),a.value?(r(),E(Cfe,{key:0})):(r(),h("div",Nfe,[n(If,{classes:A.value,"active-id":p.value,"max-classes":y.value,creating:_.value,search:x.value,onSwitch:Le,onDelete:Mt,onAdd:At,onCreateCustom:mt,"onUpdate:search":Se[1]||(Se[1]=Me=>x.value=Me)},null,8,["classes","active-id","max-classes","creating","search"]),n(Ne,{data:$.value,class:"w-full fct-tax-rates-table","max-height":"450"},{default:u(()=>[n(Vt,{label:c(d)("Region")},{default:u(({row:Me})=>[o("span",{class:ue(["fct-base-taxes__region-name",Me.state?"":"fct-base-taxes__region-name--federal"])},f(Me.state?Me.stateName:s.value||e.country),3)]),_:1},8,["label"]),n(Vt,{label:c(d)("Rate"),width:"130"},{default:u(({row:Me})=>[n(qe,{modelValue:Me.rate,"onUpdate:modelValue":St=>Me.rate=St,size:"small",type:"number",step:"0.01",min:"0"},{suffix:u(()=>Se[18]||(Se[18]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:1},8,["label"]),n(Vt,{label:c(d)("Tax Label"),width:"200"},{default:u(({row:Me})=>[n(qe,{modelValue:Me.name,"onUpdate:modelValue":St=>Me.name=St,size:"small",placeholder:c(d)("Tax name")},null,8,["modelValue","onUpdate:modelValue","placeholder"])]),_:1},8,["label"]),w.value.length>0?(r(),E(Vt,{key:0,label:c(d)("Compound"),width:"310"},{default:u(({row:Me})=>[Me.state?(r(),E(_e,{key:0,"model-value":Z(Me),size:"small",style:{width:"100%"},onChange:St=>de(Me,St)},{default:u(()=>[n(fe,{value:"0_0",label:Y.value[0].label},null,8,["label"]),n(fe,{value:"0_1",label:Y.value[1].label},null,8,["label"]),n(fe,{value:"1_0",label:Y.value[2].label},null,8,["label"])]),_:2},1032,["model-value","onChange"])):B("",!0)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"]),o("div",Kfe,[m.value==="standard"?(r(),E(tt,{key:0,loading:W.value,size:"small",onClick:kt,type:"danger",soft:""},{default:u(()=>[R(f(c(d)("Reset to default")),1)]),_:1},8,["loading"])):B("",!0),n(tt,{type:"primary",size:"small",loading:ge.value,onClick:bt},{default:u(()=>[R(f(c(d)("Save Rates")),1)]),_:1},8,["loading"])])]))]),_:1})]),_:1}),n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Tax overrides"),text:c(d)("Override tax rates for specific product categories or shipping.")},{action:u(()=>[n(tt,{size:"small",onClick:na},{default:u(()=>[R(f(c(d)("Add Tax Override")),1)]),_:1})]),_:1},8,["title","text"]),n(xe,null,{default:u(()=>[o("div",Gfe,[n(Ne,{data:S.value,"empty-text":c(d)("No overrides configured")},{default:u(()=>[n(Vt,{label:c(d)("Type"),width:"110"},{default:u(({row:Me})=>[n(Pe,{type:Me.type==="products"?"primary":"info",size:"small"},{default:u(()=>[R(f(Me.type==="products"?c(d)("Product"):c(d)("Shipping")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),n(Vt,{label:c(d)("Category")},{default:u(({row:Me})=>[R(f(Me.category_name||"—"),1)]),_:1},8,["label"]),n(Vt,{label:c(d)("Tax Label")},{default:u(({row:Me})=>[R(f(Me.tax_label||"—"),1)]),_:1},8,["label"]),n(Vt,{label:c(d)("Location")},{default:u(({row:Me})=>[R(f(Me.location),1)]),_:1},8,["label"]),n(Vt,{label:c(d)("Tax Class"),width:"130"},{default:u(({row:Me})=>[Me.type==="products"?(r(),h("span",zfe,f(Me.class_label||c(d)("All")),1)):(r(),h("span",jfe,f(Me.class_label||"—"),1))]),_:1},8,["label"]),n(Vt,{label:c(d)("City / Postcode")},{default:u(({row:Me})=>[Me.city||Me.postcode?(r(),h("span",qfe,f([Me.city,Me.postcode].filter(Boolean).join(" / ")),1)):(r(),h("span",Yfe,"—"))]),_:1},8,["label"]),n(Vt,{label:c(d)("Rate"),width:"100"},{default:u(({row:Me})=>[R(f(Me.rate)+"% ",1)]),_:1},8,["label"]),n(Vt,{label:c(d)("Actions"),width:"110",align:"right"},{default:u(({row:Me})=>[o("div",Wfe,[n(lt,{tag:"button",size:"small",onClick:St=>qt(Me)},{default:u(()=>[n(J,{name:"Edit"})]),_:2},1032,["onClick"]),n(lt,{tag:"button",size:"small",onClick:St=>Za(Me),bg:"danger",outline:""},{default:u(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick"])])]),_:1},8,["label"])]),_:1},8,["data","empty-text"])])]),_:1})]),_:1}),n(_t,{modelValue:U.value,"onUpdate:modelValue":Se[17]||(Se[17]=Me=>U.value=Me),title:(X.value?c(d)("Edit tax override for"):c(d)("Add tax override for"))+" "+(s.value||e.country),width:"520px","append-to-body":!0,onClose:sa},{footer:u(()=>[n(tt,{onClick:Se[16]||(Se[16]=Me=>U.value=!1)},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1}),n(tt,{type:"primary",loading:z.value,onClick:va},{default:u(()=>[R(f(X.value?c(d)("Save changes"):c(d)("Add override")),1)]),_:1},8,["loading"])]),default:u(()=>[n(gt,{"label-position":"top",model:G.value},{default:u(()=>[n(Ze,{label:c(d)("Override type")},{default:u(()=>[n(se,{modelValue:G.value.type,"onUpdate:modelValue":Se[2]||(Se[2]=Me=>G.value.type=Me)},{default:u(()=>[n(ft,{value:"products"},{default:u(()=>[R(f(c(d)("Products")),1)]),_:1}),n(ft,{value:"shipping"},{default:u(()=>[R(f(c(d)("Shipping")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),G.value.type==="products"?(r(),h(P,{key:0},[n(Ze,{label:c(d)("Category")},{default:u(()=>[n(_e,{modelValue:G.value.category_id,"onUpdate:modelValue":Se[3]||(Se[3]=Me=>G.value.category_id=Me),filterable:"",placeholder:c(d)("Select a category"),loading:H.value,style:{width:"100%"},onChange:ul},{default:u(()=>[(r(!0),h(P,null,le(M.value,Me=>(r(),E(fe,{key:Me.value,label:Me.label,value:Me.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","loading"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Tax Class")},{default:u(()=>[n(_e,{modelValue:G.value.class_id,"onUpdate:modelValue":Se[4]||(Se[4]=Me=>G.value.class_id=Me),style:{width:"100%"}},{default:u(()=>[n(fe,{value:0,label:c(d)("All Tax Classes")},null,8,["label"]),(r(!0),h(P,null,le(A.value,Me=>(r(),E(fe,{key:Me.id,value:Number(Me.id),label:Me.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Tax label")},{default:u(()=>[n(qe,{modelValue:G.value.tax_label,"onUpdate:modelValue":Se[5]||(Se[5]=Me=>G.value.tax_label=Me),placeholder:c(d)("e.g. Tax, VAT, GST")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Location")},{default:u(()=>[n(_e,{modelValue:G.value.state,"onUpdate:modelValue":Se[6]||(Se[6]=Me=>G.value.state=Me),placeholder:c(d)("Select location"),filterable:"",style:{width:"100%"}},{default:u(()=>[(r(!0),h(P,null,le(ka.value,Me=>(r(),E(fe,{key:Me.value,label:Me.label,value:Me.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("City (optional)")},{default:u(()=>[n(qe,{modelValue:G.value.city,"onUpdate:modelValue":Se[7]||(Se[7]=Me=>G.value.city=Me),placeholder:c(d)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Postcode (optional)")},{default:u(()=>[n(qe,{modelValue:G.value.postcode,"onUpdate:modelValue":Se[8]||(Se[8]=Me=>G.value.postcode=Me),placeholder:c(d)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Tax rate (%)")},{default:u(()=>[n(qe,{modelValue:G.value.tax_rate,"onUpdate:modelValue":Se[9]||(Se[9]=Me=>G.value.tax_rate=Me),type:"number",step:"0.01",min:"0",placeholder:c(d)("e.g. 0 for tax exempt")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),w.value.length>0?(r(),E(Ze,{key:0},{default:u(()=>[n(ze,{modelValue:G.value.override_state_tax,"onUpdate:modelValue":Se[10]||(Se[10]=Me=>G.value.override_state_tax=Me)},{default:u(()=>[R(f(c(d)("Also override state/provincial taxes")),1)]),_:1},8,["modelValue"])]),_:1})):B("",!0)],64)):(r(),h(P,{key:1},[n(Ze,{label:c(d)("Tax Class")},{default:u(()=>[n(_e,{modelValue:G.value.class_id,"onUpdate:modelValue":Se[11]||(Se[11]=Me=>G.value.class_id=Me),style:{width:"100%"},loading:I.value},{default:u(()=>[(r(!0),h(P,null,le(A.value,Me=>(r(),E(fe,{key:Me.id,value:Number(Me.id),label:Me.title,disabled:X.value&&Number(Me.id)!==Number(O.value)&&L.value.has(Number(Me.id))},null,8,["value","label","disabled"]))),128))]),_:1},8,["modelValue","loading"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Location")},{default:u(()=>[n(_e,{modelValue:G.value.state,"onUpdate:modelValue":Se[12]||(Se[12]=Me=>G.value.state=Me),placeholder:c(d)("Select location"),filterable:"",style:{width:"100%"}},{default:u(()=>[(r(!0),h(P,null,le(Ja.value,Me=>(r(),E(fe,{key:Me.value,label:Me.label,value:Me.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("City (optional)")},{default:u(()=>[n(qe,{modelValue:G.value.city,"onUpdate:modelValue":Se[13]||(Se[13]=Me=>G.value.city=Me),placeholder:c(d)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Postcode (optional)")},{default:u(()=>[n(qe,{modelValue:G.value.postcode,"onUpdate:modelValue":Se[14]||(Se[14]=Me=>G.value.postcode=Me),placeholder:c(d)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n(Ze,{label:c(d)("Tax rate (%)")},{default:u(()=>[n(qe,{modelValue:G.value.tax_rate,"onUpdate:modelValue":Se[15]||(Se[15]=Me=>G.value.tax_rate=Me),type:"number",step:"0.01",min:"0"},null,8,["modelValue"])]),_:1},8,["label"])],64))]),_:1},8,["model"])]),_:1},8,["modelValue","title"])])])])])}}};class Xfe extends ws{getTabs(){return{all:d("All"),filed:d("Filed"),not_filed:d("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 d("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 Jfe(e){return Xfe.init(e)}const Zfe=e=>e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase()),eme=e=>{const t=Object.keys(e[0]),l=[t.map(Zfe).join(",")];return e.forEach(s=>{const i=t.map(A=>{let p=s[A];return typeof p=="object"&&(p=JSON.stringify(p)),typeof p=="string"&&(p=`"${p.replace(/"/g,'""')}"`),p});l.push(i.join(","))}),l.join(`
`)},tme=(e,t="export.csv")=>new Promise((a,l)=>{try{if(!e||!e.length)throw new Error("No data to export");const s=eme(e),i=new Blob([s],{type:"text/csv"}),A=document.createElement("a"),p=()=>{window.removeEventListener("focus",p),a()};window.addEventListener("focus",p),A.href=URL.createObjectURL(i),A.download=t,A.click(),URL.revokeObjectURL(A.href),setTimeout(()=>{a()},200)}catch(s){l(s)}}),ame={class:"table-cell"},lme={class:"table-cell"},sme={class:"table-cell"},nme={class:"table-cell"},ome={class:"table-cell"},ime={class:"table-cell"},rme={class:"table-cell"},dme={class:"table-cell"},ume={class:"table-cell"},cme={__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"),A=C("el-skeleton-item"),p=C("el-skeleton"),m=C("el-table");return r(),E(m,{data:c(a),class:"w-full compact-table full-compact"},{default:u(()=>[n(i,{type:"selection",width:45}),e.taxTable.isColumnVisible("id")?(r(),E(i,{key:0,width:100,label:c(d)("ID")},{default:u(()=>[o("div",ame,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.taxTable.isColumnVisible("order_id")?(r(),E(i,{key:1,label:c(d)("Order ID"),width:100},{default:u(()=>[o("div",lme,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(i,{label:c(d)("Tax Country"),width:120},{default:u(()=>[o("div",sme,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"]),n(i,{label:c(d)("Tax Region"),width:120},{default:u(()=>[o("div",nme,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("postcode")?(r(),E(i,{key:2,label:c(d)("Zip Code"),width:120},{default:u(()=>[o("div",ome,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(i,{label:c(d)("Tax Name"),width:120},{default:u(()=>[o("div",ime,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("rate")?(r(),E(i,{key:3,label:c(d)("Tax Rate"),width:120},{default:u(()=>[o("div",rme,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(i,{label:c(d)("Sale Taxes"),width:120},{default:u(()=>[o("div",dme,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"]),e.taxTable.isColumnVisible("filed_at")?(r(),E(i,{key:4,label:c(d)("Filed"),width:120},{default:u(()=>[o("div",ume,[n(p,{animated:""},{template:u(()=>[n(A,{variant:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])}}},Ame={class:"table-cell"},pme={class:"table-cell"},fme={class:"table-cell"},mme={class:"table-cell"},hme={class:"table-cell"},_me={class:"table-cell"},vme={class:"table-cell"},gme={class:"table-cell"},yme={class:"table-cell"},bme={__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"),A=C("el-skeleton"),p=C("el-table-column"),m=C("el-table");return r(),E(m,{data:c(a),class:"w-full compact-table responsive full-compact"},{default:u(()=>[n(p,{width:103,label:c(d)("ID")},{default:u(()=>[o("div",Ame,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[70px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("title")?(r(),E(p,{key:0,label:c(d)("Title"),width:227},{default:u(()=>[o("div",pme,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[180px]"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(p,{label:c(d)("Code"),width:206},{default:u(()=>[o("div",fme,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[130px]"})]),_:1})])]),_:1},8,["label"]),n(p,{label:c(d)("Amount"),width:124},{default:u(()=>[o("div",mme,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:1},8,["label"]),n(p,{label:c(d)("Usage"),width:155},{default:u(()=>[o("div",hme,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[100px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("stackable")?(r(),E(p,{key:1,label:c(d)("Stackable"),width:124},{default:u(()=>[o("div",_me,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[80px]"})]),_:1})])]),_:1},8,["label"])):B("",!0),n(p,{label:c(d)("Status"),width:124},{default:u(()=>[o("div",vme,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[90px]"})]),_:1})])]),_:1},8,["label"]),n(p,{label:c(d)("Expiry Date"),width:124},{default:u(()=>[o("div",gme,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[90px]"})]),_:1})])]),_:1},8,["label"]),e.couponTable.isColumnVisible("actions")?(r(),E(p,{key:2,label:c(d)("Actions"),width:103,align:"right"},{default:u(()=>[o("div",yme,[n(A,{animated:""},{template:u(()=>[n(i,{variant:"p",class:"w-[70px]"})]),_:1})])]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])}}},wme={class:"fct-taxes-page fct-layout-width"},Cme={key:1},kme={style:{display:"flex","flex-wrap":"wrap","align-items":"center",gap:"4px"}},Bme={class:"fct-tax-filing-wrap"},xme={class:"fct-tax-filing-summary"},Sme={class:"summary-item"},$me={class:"summary-label"},Fme={class:"summary-value"},Eme={class:"summary-item"},Ume={class:"summary-label"},Ime={class:"summary-value"},Vme={class:"fct-tax-filing max-h-[400px] overflow-y-auto"},Dme={style:{display:"flex","flex-wrap":"wrap","align-items":"center",gap:"4px"}},Qme={class:"dialog-footer"},Tme={class:"fct-tax-filing-success-wrap"},Mme={class:"fct-tax-filling-success-icon"},Lme={class:"dialog-footer"},Rme={__name:"Taxes",setup(e){const t=Object.fromEntries(Fm.map(S=>[S.value,S.label])),a=S=>t[S]||S;Zt().ctx;const l=Jfe(),s=T(!1),i=T(!1),A=T(!1),p=T([]),m=K(()=>l.getTableData().map(S=>{var U,V,D,I,L,O,M,H,z,X,G;return{id:S.id,order_id:S.order_id,country:a(((U=S.tax_rate)==null?void 0:U.country)??((V=S.meta)==null?void 0:V.tax_country)??""),state:((D=S.tax_rate)==null?void 0:D.formatted_state)??((I=S.tax_rate)==null?void 0:I.state)??"",postcode:((L=S.tax_rate)==null?void 0:L.postcode)??"",name:((O=S.tax_rate)==null?void 0:O.name)??((M=S.meta)==null?void 0:M.label)??"",reverse_charge:!!((H=S.meta)!=null&&H.reverse_charge_applied),rate:((z=S.tax_rate)==null?void 0:z.rate)??((X=S.meta)==null?void 0:X.rate_percent)??"",total_tax:String(parseFloat((S.total_tax/100).toFixed(2))),currency:((G=S.order)==null?void 0:G.currency)||"",total_tax:String(parseFloat((S.total_tax/100).toFixed(2))),filed_at:S.filed_at?d("Yes"):d("No")}})),_=()=>{s.value=!0,i.value=!1},g=()=>{s.value=!1,i.value=!0},y=async()=>{try{await tme(F.value),g()}catch{}},v=()=>{i.value=!1},k=()=>{const S=F.value.map(U=>U.id);ce.post(l.getFetchUrl(),{ids:S}).then(U=>{q.success(U.message),l.fetch()}).catch(U=>{q.error(U)}).finally(()=>{v()})},w=S=>{p.value=S,A.value=S.length>0},b=S=>{F.value=S},x=T(null),F=T([]),Q=K(()=>{const S=F.value.reduce((V,D)=>V+parseFloat(D.total_tax||0),0),U=[...new Set(F.value.map(V=>V.order_id))];return{totalTax:vt.formatNumber(Math.round(S*100),!1),totalOrders:U.length,items:F.value}}),$=()=>{Fe(()=>{F.value=[...p.value],p.value.forEach(S=>{x.value.toggleRowSelection(S,!0)})})};return(S,U)=>{const V=C("el-button"),D=C("el-tooltip"),I=C("el-table-column"),L=C("router-link"),O=C("el-tag"),M=C("el-table"),H=C("el-dialog");return r(),h("div",wme,[n(nl,{title:c(d)("Taxes")},{action:u(()=>[A.value?(r(),E(V,{key:1,type:"primary",onClick:_,disabled:!A.value},{default:u(()=>[R(f(c(d)("Tax Filing")),1)]),_:1},8,["disabled"])):(r(),E(D,{key:0,"popper-class":"fct-tooltip",effect:"dark",content:c(d)("Please select the taxes you want to file"),placement:"top-start"},{default:u(()=>[n(V,{type:"primary",disabled:!A.value},{default:u(()=>[R(f(c(d)("Tax Filing")),1)]),_:1},8,["disabled"])]),_:1},8,["content"]))]),_:1},8,["title"]),n(Cs,{table:c(l),"has-mobile-slot":!1},{default:u(()=>[c(l).isLoading()?(r(),E(cme,{key:0,taxTable:c(l),"next-page-count":c(l).nextPageCount},null,8,["taxTable","next-page-count"])):(r(),h("div",Cme,[n(M,{class:"w-full",data:m.value,onSelectionChange:w},{empty:u(()=>[n(wt,{icon:"Empty/ListView","has-dark":!0,text:c(d)("We could't find any taxes matching your filter.")},null,8,["text"])]),default:u(()=>[n(I,{type:"selection",width:45}),c(l).isColumnVisible("id")?(r(),E(I,{key:0,label:c(d)("ID"),width:100},{default:u(z=>[o("span",null,"#"+f(c(d)(z.row.id)),1)]),_:1},8,["label"])):B("",!0),c(l).isColumnVisible("order_id")?(r(),E(I,{key:1,label:c(d)("Order ID"),width:100},{default:u(z=>[o("span",kme,[n(L,{class:"link",to:{name:"view_order",params:{order_id:z.row.order_id}}},{default:u(()=>[R(" #"+f(z.row.order_id),1)]),_:2},1032,["to"]),z.row.reverse_charge?(r(),E(O,{key:0,type:"warning",size:"small","disable-transitions":""},{default:u(()=>[R(f(c(d)("Reverse Charge")),1)]),_:1})):B("",!0)])]),_:1},8,["label"])):B("",!0),n(I,{label:c(d)("Tax Country"),width:120},{default:u(z=>[o("span",null,f(z.row.country),1)]),_:1},8,["label"]),n(I,{label:c(d)("Tax Region"),width:120},{default:u(z=>[o("span",null,f(z.row.state),1)]),_:1},8,["label"]),c(l).isColumnVisible("postcode")?(r(),E(I,{key:2,label:c(d)("Zip Code"),width:120},{default:u(z=>[o("span",null,f(z.row.postcode),1)]),_:1},8,["label"])):B("",!0),n(I,{label:c(d)("Tax Name"),width:120},{default:u(z=>[o("span",null,f(z.row.name),1)]),_:1},8,["label"]),c(l).isColumnVisible("rate")?(r(),E(I,{key:3,label:c(d)("Tax Rate"),width:120},{default:u(z=>[o("span",null,f(z.row.rate)+"%",1)]),_:1},8,["label"])):B("",!0),n(I,{label:c(d)("Sale Taxes"),width:120},{default:u(z=>[o("span",null,f(c(vt).formatForOrder(z.row.total_tax_cents,z.row.currency)),1)]),_:1},8,["label"]),c(l).isColumnVisible("filed_at")?(r(),E(I,{key:4,label:c(d)("Filed"),width:120},{default:u(z=>[o("span",null,f(z.row.filed_at),1)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])]))]),_:1},8,["table"]),n(H,{modelValue:s.value,"onUpdate:modelValue":U[1]||(U[1]=z=>s.value=z),title:c(d)("Tax Filing"),onOpen:$,class:"fct-tax-filling-modal"},{footer:u(()=>[o("div",Qme,[n(V,{onClick:U[0]||(U[0]=()=>{s.value=!1})},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1}),n(V,{type:"primary",onClick:y},{default:u(()=>[n(J,{name:"Download",style:{width:"16px",height:"16px"}}),R(" "+f(c(d)("Download & Continue")),1)]),_:1})])]),default:u(()=>[o("div",Bme,[o("div",xme,[o("div",Sme,[o("span",$me,f(c(d)("Taxable Amount")),1),o("span",Fme,f(Q.value.totalTax),1)]),o("div",Eme,[o("span",Ume,f(c(d)("Total Orders")),1),o("span",Ime,f(c(d)(Q.value.totalOrders)),1)])]),o("div",Vme,[n(M,{ref_key:"selectedTaxesTableRef",ref:x,data:p.value,onSelectionChange:b},{empty:u(()=>[n(wt,{icon:"Empty/ListView",text:c(d)("We could't find any taxes matching your filter.")},null,8,["text"])]),default:u(()=>[n(I,{type:"selection",width:45}),n(I,{label:c(d)("ID"),width:100},{default:u(z=>[o("span",null,f(z.row.id),1)]),_:1},8,["label"]),n(I,{label:c(d)("Order ID"),"min-width":100},{default:u(z=>[o("span",Dme,[o("span",null,f(z.row.order_id),1),z.row.reverse_charge?(r(),E(O,{key:0,type:"warning",size:"small","disable-transitions":""},{default:u(()=>[R(f(c(d)("Reverse Charge")),1)]),_:1})):B("",!0)])]),_:1},8,["label"]),n(I,{width:120,label:c(d)("Tax Country")},{default:u(z=>[o("span",null,f(z.row.country),1)]),_:1},8,["label"]),n(I,{width:120,label:c(d)("Tax Region")},{default:u(z=>[o("span",null,f(z.row.state),1)]),_:1},8,["label"]),n(I,{label:c(d)("Zip Code"),width:120},{default:u(z=>[o("span",null,f(z.row.postcode),1)]),_:1},8,["label"]),n(I,{width:120,label:c(d)("Tax Name")},{default:u(z=>[o("span",null,f(z.row.name),1)]),_:1},8,["label"]),n(I,{label:c(d)("Tax Rate"),width:120},{default:u(z=>[o("span",null,f(z.row.rate)+"%",1)]),_:1},8,["label"]),n(I,{width:150,label:c(d)("Sale Taxes")},{default:u(z=>[o("span",null,f(c(vt).formatForOrder(z.row.total_tax_cents,z.row.currency)),1)]),_:1},8,["label"])]),_:1},8,["data"])])])]),_:1},8,["modelValue","title"]),n(H,{modelValue:i.value,"onUpdate:modelValue":U[2]||(U[2]=z=>i.value=z),class:"fct-tax-filling-success-modal","close-on-click-modal":!1},{footer:u(()=>[o("div",Lme,[n(V,{onClick:v},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1}),n(V,{type:"primary",onClick:k},{default:u(()=>[R(f(c(d)("Mark as Filed")),1)]),_:1})])]),default:u(()=>[o("div",Tme,[o("div",Mme,[n(J,{name:"CheckCircleFill"})]),o("div",null,[o("h4",null,f(c(d)("Don't Forget to Save Your Tax File")),1),o("p",null,f(c(d)("You're about to mark this tax report as filed.")),1),o("p",null,[R(f(c(d)("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"},f(c(d)("Download Again")),1)])])])]),_:1},8,["modelValue"])])}}},Ome={class:"fct-card fct-card-border fct-vat-card"},Pme={class:"fct-card-body"},Hme={class:"fct-vat-card-header"},Nme={class:"fct-vat-card-title"},Kme={class:"fct-card fct-card-border fct-vat-card mt-5"},Gme={class:"fct-card-body"},zme={class:"fct-vat-card-header"},jme={class:"fct-vat-card-title"},qme={class:"fct-tax-rates-country-view"},Yme={class:"border border-gray-200 rounded-md overflow-hidden dark:border-dark-300"},Wme={class:"grid grid-cols-[110px_1fr_1fr_1fr_100px_80px] gap-4 py-3 border-b border-gray-200 dark:border-dark-300"},Xme={__name:"EUVatSettingsLoader",setup(e){const t=[1,2,3];return(a,l)=>(r(),h("div",null,[o("div",Ome,[o("div",Pme,[o("div",Hme,[o("div",Nme,[o("h3",null,f(c(d)("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",Kme,[o("div",Gme,[o("div",zme,[o("div",jme,[o("h3",null,f(c(d)("Tax overrides")),1)])]),o("div",qme,[o("div",Yme,[o("div",Wme,[(r(),h(P,null,le(6,s=>o("div",{key:"header-"+s,class:"fct-sk h-3 rounded-xs"})),64))]),(r(),h(P,null,le(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]=[Mn('',6)]))),64))])])])])]))}},Jme={class:"fct-modal-body"},Zme={class:"fct-radio-option-fields"},ehe={class:"form-note"},the={class:"fct-radio-option-fields"},ahe={class:"fct-radio-option-fields-desc"},lhe={class:"form-note"},she={key:0,class:"fct-info-box mt-3"},nhe={class:"text-xs text-system-mid"},ohe={class:"fct-radio-option-fields"},ihe={class:"fct-radio-option-fields-desc"},rhe={__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);ke(()=>a.modelValue,_=>{if(_){const g=a.initialRegistrations.length?a.initialRegistrations[0]:null,y=g?g.country:"",v=g&&g.vat||"",k=a.currentForm||{};s.value={method:k.method||"oss",oss_country:k.oss_country||y,oss_vat:k.oss_vat||v,home_country:k.home_country||y,home_vat:k.home_vat||v}}else s.value={method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""}});function A(_){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 m(){if(!s.value.method){q.error(d("Select a cross-border registration type"));return}if(s.value.method==="oss"){if(!s.value.oss_country){q.error(d("Select your country of OSS registration"));return}}else if(s.value.method==="home"&&!s.value.home_country){q.error(d("Select your country of registration"));return}i.value=!0,(s.value.method==="home"&&!p()?ce.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:s.value.home_country,vat:s.value.home_vat,rate:A(s.value.home_country)}):Promise.resolve()).then(()=>ce.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"),k=C("el-select"),w=C("el-form-item"),b=C("el-input"),x=C("el-radio-group"),F=C("el-form"),Q=C("el-button"),$=C("el-dialog");return r(),E($,{"model-value":e.modelValue,title:c(d)("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]=S=>l("update:modelValue",S))},{footer:u(()=>[n(Q,{onClick:g[8]||(g[8]=S=>l("update:modelValue",!1))},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1}),n(Q,{type:"primary",onClick:m,loading:i.value},{default:u(()=>[R(f(c(d)("Collect VAT")),1)]),_:1},8,["loading"])]),default:u(()=>[o("div",Jme,[n(F,{"label-position":"top"},{default:u(()=>[n(x,{modelValue:s.value.method,"onUpdate:modelValue":g[7]||(g[7]=S=>s.value.method=S),class:"fct-cross-border-radios"},{default:u(()=>[o("div",{class:ue(["fct-radio-option",{"is-active":s.value.method==="oss"}]),onClick:g[2]||(g[2]=S=>s.value.method="oss")},[n(y,{value:"oss"},{default:u(()=>[R(f(c(d)("Collect using a One Stop Shop (OSS) registration")),1)]),_:1}),n(_a,{accordion:"",visible:s.value.method==="oss"},{default:u(()=>[o("div",Zme,[n(w,{label:c(d)("Country of OSS registration")},{default:u(()=>[n(k,{modelValue:s.value.oss_country,"onUpdate:modelValue":g[0]||(g[0]=S=>s.value.oss_country=S),placeholder:c(d)("Select country"),filterable:"",class:"w-full"},{default:u(()=>[(r(!0),h(P,null,le(e.countries,S=>(r(),E(v,{key:S.value,label:S.label,value:S.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(w,{label:c(d)("VAT number")},{default:u(()=>[n(b,{modelValue:s.value.oss_vat,"onUpdate:modelValue":g[1]||(g[1]=S=>s.value.oss_vat=S),placeholder:c(d)("e.g. DE999999999")},null,8,["modelValue","placeholder"]),o("div",ehe,[o("p",null,f(c(d)("Shown on VAT invoice")),1)])]),_:1},8,["label"])])]),_:1},8,["visible"])],2),o("div",{class:ue(["fct-radio-option",{"is-active":s.value.method==="home"}]),onClick:g[5]||(g[5]=S=>s.value.method="home")},[n(y,{value:"home"},{default:u(()=>[R(f(c(d)("Collect using your home country registration")),1)]),_:1}),n(_a,{accordion:"",visible:s.value.method==="home"},{default:u(()=>[o("div",the,[o("p",ahe,f(c(d)("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(w,{label:c(d)("Country of registration")},{default:u(()=>[n(k,{modelValue:s.value.home_country,"onUpdate:modelValue":g[3]||(g[3]=S=>s.value.home_country=S),placeholder:c(d)("Select country"),filterable:"",class:"w-full"},{default:u(()=>[(r(!0),h(P,null,le(e.countries,S=>(r(),E(v,{key:S.value,label:S.label,value:S.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n(w,{label:c(d)("VAT number")},{default:u(()=>[n(b,{modelValue:s.value.home_vat,"onUpdate:modelValue":g[4]||(g[4]=S=>s.value.home_vat=S),placeholder:c(d)("e.g. DE999999999")},null,8,["modelValue","placeholder"]),o("div",lhe,[o("p",null,f(c(d)("Shown on VAT invoice")),1)])]),_:1},8,["label"]),e.initialRegistrations.length?B("",!0):(r(),h("div",she,[n(J,{name:"InformationFill",class:"w-4 h-4 text-blue-500 flex-shrink-0"}),o("span",nhe,f(c(d)("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:ue(["fct-radio-option",{"is-active":s.value.method==="specific"}]),onClick:g[6]||(g[6]=S=>s.value.method="specific")},[n(y,{value:"specific"},{default:u(()=>[R(f(c(d)("Collect using specific country registrations")),1)]),_:1}),n(_a,{accordion:"",visible:s.value.method==="specific"},{default:u(()=>[o("div",ohe,[o("p",ihe,f(c(d)("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"])}}},dhe={key:0,class:"fct-country-registrations-list mt-4"},uhe={class:"fct-home-country-header"},che=["src","alt"],Ahe={class:"fct-vat-country-name"},phe={key:0,class:"fct-collecting-badge"},fhe={class:"fct-home-country-body"},mhe={class:"fct-vat-home-field"},hhe={class:"fct-vat-home-field__label"},_he={class:"fct-reg-rates-section"},vhe={class:"fct-reg-rates-table fct-reg-rates-table--home mt-5 px-5 pt-5"},ghe={class:"fct-reg-rates-row fct-reg-rates-header"},yhe={class:"fct-reg-rates-cell-label"},bhe={class:"fct-reg-rates-cell-label"},whe={key:1,class:"fct-reg-class-name"},Che={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},khe={class:"fct-reg-rates-cell-input"},Bhe={class:"fct-reg-rates-cell-action"},xhe=["title","onClick"],She={key:0,class:"fct-reg-add-class px-5"},$he={type:"button",class:"fct-reg-add-class-btn"},Fhe={class:"fct-vat-home-actions"},Ehe={__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([]),A=K(()=>a.homeCountry&&a.countries.find(S=>S.value===a.homeCountry)||null),p=K(()=>a.homeCountry&&a.registrations.find(S=>S.country===a.homeCountry)||null),m=K(()=>{const S=p.value;return!S||!S.vat?!1:S.rates&&typeof S.rates=="object"&&Object.keys(S.rates).length?Object.values(S.rates).some(function(U){return U&&parseFloat(U.rate)>0}):parseFloat(S.rate)>0}),_=K(()=>[...a.taxClasses,...i.value]),g=K(()=>_.value.length?_.value:[{slug:"standard",title:d("Standard")}]),y=K(()=>{if(_.value.length>=6)return[];const S=_.value.map(V=>V.slug).filter(Boolean),U=[];return S.includes("reduced")||U.push({command:"reduced",label:d("Reduced")}),S.includes("zero")||U.push({command:"zero",label:d("Zero")}),U.push({command:"custom",label:d("Custom Class...")}),U});ke([()=>a.homeCountry,()=>a.homeVat,()=>a.taxClasses,()=>a.registrations],()=>{const S=p.value,U={};a.taxClasses.forEach(V=>{var O;const D=(O=S==null?void 0:S.rates)==null?void 0:O[V.slug],I=V.slug==="standard"?(S==null?void 0:S.rate)??"":"",L=V.slug==="standard"?(S==null?void 0:S.tax_label)??"":"";D&&typeof D=="object"?U[V.slug]={rate:D.rate??"",label:D.label??""}:U[V.slug]={rate:D??I,label:L}}),i.value.forEach(V=>{const D=v(V);U[D]=s.value.rates[D]||{rate:"",label:""}}),U.standard||(U.standard={rate:"",label:""}),s.value={country:a.homeCountry||"",vat:(S==null?void 0:S.vat)||a.homeVat||"",rates:U}},{immediate:!0});function v(S){return S.tempKey||S.slug}function k(S){if(S==="custom"){b();return}const U=S==="reduced"?d("Reduced"):d("Zero");i.value.push({slug:S,title:U,tempKey:S}),s.value.rates[S]={rate:"",label:""}}let w=0;function b(){const S="_new_"+w++;i.value.push({slug:null,title:"",tempKey:S,isNew:!0}),s.value.rates[S]={rate:"",label:""}}function x(S){return S.slug?S.title||S.slug:S.title&&S.title.trim()?S.title.trim():d("Custom")}function F(S){if(S.hasError=!1,S.created)return Promise.resolve(null);if(!S.slug&&!(S.title&&S.title.trim()))return S.hasError=!0,Promise.reject(new Error(d("Please enter a name for the custom tax class")));const U=S.slug?{slug:S.slug}:{title:S.title.trim()};return ce.post("tax/classes",U).then(V=>{const D=(V==null?void 0:V.class)||{},I=D.slug||S.slug;if(!I)throw new Error(d("Tax class creation returned an invalid response"));return!S.slug&&s.value.rates[S.tempKey]!==void 0&&(s.value.rates[I]=s.value.rates[S.tempKey],delete s.value.rates[S.tempKey],S.tempKey=null),S.slug=I,S.title=D.title||S.title,S.created=!0,D}).catch(V=>{var I;S.hasError=!0;const D=((I=V==null?void 0:V.data)==null?void 0:I.message)||d("Failed to create tax class");throw new Error(d("%1$s: %2$s",D,x(S)))})}function Q(S){const U=v(S);if(i.value.some(D=>v(D)===U)){i.value=i.value.filter(D=>v(D)!==U),delete s.value.rates[U];return}Pa(d('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?',S.title),d("Delete Tax Class"),{confirmButtonText:d("Delete"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{ce.delete("tax/classes/"+S.id).then(()=>{l("class-changed")}).catch(D=>{var I;q.error(((I=D==null?void 0:D.data)==null?void 0:I.message)||d("Failed to delete tax class"))})}).catch(()=>{})}function $(){const S=i.value.map(F);Promise.all(S).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)||d("Failed to create tax class"))})}return(S,U)=>{const V=C("el-input"),D=C("el-dropdown-item"),I=C("el-dropdown-menu"),L=C("el-dropdown"),O=C("el-button");return A.value?(r(),h("div",dhe,[o("div",uhe,[o("img",{src:`https://flagcdn.com/w40/${e.homeCountry.toLowerCase()}.png`,alt:A.value.label,class:"fct-flag-icon"},null,8,che),o("span",Ahe,f(A.value.label),1),m.value?(r(),h("span",phe,[U[1]||(U[1]=o("span",{class:"fct-green-dot"},null,-1)),R(" "+f(c(d)("Collecting")),1)])):B("",!0)]),o("div",fhe,[o("div",mhe,[o("label",hhe,f(c(d)("VAT number")),1),n(V,{modelValue:s.value.vat,"onUpdate:modelValue":U[0]||(U[0]=M=>s.value.vat=M),class:"fct-vat-number-input"},null,8,["modelValue"])]),o("div",_he,[o("div",vhe,[o("div",ghe,[o("div",yhe,f(c(d)("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,le(g.value,M=>(r(),h("div",{key:v(M),class:"fct-reg-rates-row"},[o("div",bhe,[M.isNew?(r(),E(V,{key:0,modelValue:M.title,"onUpdate:modelValue":H=>M.title=H,size:"small",placeholder:c(d)("Class name"),class:ue(["fct-reg-class-name-input",{"fct-reg-class-name-input--error":M.hasError}]),onInput:H=>M.hasError=!1},null,8,["modelValue","onUpdate:modelValue","placeholder","class","onInput"])):(r(),h("span",whe,f(M.title),1))]),o("div",Che,[n(V,{modelValue:s.value.rates[v(M)].rate,"onUpdate:modelValue":H=>s.value.rates[v(M)].rate=H,type:"number",step:"0.01",min:"0",size:"small"},{suffix:u(()=>U[5]||(U[5]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])]),o("div",khe,[n(V,{modelValue:s.value.rates[v(M)].label,"onUpdate:modelValue":H=>s.value.rates[v(M)].label=H,size:"small",placeholder:c(d)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])]),o("div",Bhe,[M.slug!=="standard"?(r(),h("button",{key:0,type:"button",class:"fct-reg-rates-delete-btn",title:c(d)("Delete class"),onClick:H=>Q(M)},[n(J,{name:"Delete"})],8,xhe)):B("",!0)])]))),128))]),y.value.length?(r(),h("div",She,[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(J,{name:"Plus",class:"w-3 h-3"}),R(" "+f(c(d)("Add class")),1)])):(r(),E(L,{key:1,trigger:"click",onCommand:k,"popper-class":"fct-dropdown"},{dropdown:u(()=>[n(I,null,{default:u(()=>[(r(!0),h(P,null,le(y.value,M=>(r(),E(D,{key:M.command,command:M.command},{default:u(()=>[R(f(M.label),1)]),_:2},1032,["command"]))),128))]),_:1})]),default:u(()=>[o("button",$he,[n(J,{name:"Plus",class:"w-3 h-3"}),R(" "+f(c(d)("Add class")),1)])]),_:1}))])):B("",!0)]),o("div",Fhe,[n(O,{type:"primary",size:"small",onClick:$},{default:u(()=>[R(f(c(d)("Save VAT")),1)]),_:1})])])])):B("",!0)}}},Uhe={class:"fct-modal-body fct-country-reg-modal"},Ihe={class:"fct-country-reg-text"},Vhe={class:"form-note"},Dhe={class:"fct-reg-rates-table"},Qhe={class:"fct-reg-rates-row fct-reg-rates-header"},The={class:"fct-reg-rates-cell-label"},Mhe={class:"fct-reg-rates-cell-label"},Lhe={key:1,class:"fct-reg-class-name"},Rhe={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},Ohe={class:"fct-reg-rates-cell-input"},Phe={key:1,class:"fct-reg-rates-row"},Hhe={class:"fct-reg-rates-cell-label"},Nhe={class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},Khe={class:"fct-reg-rates-cell-input"},Ghe={key:0,class:"fct-reg-add-class"},zhe={type:"button",class:"fct-reg-add-class-btn"},jhe={__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([]),A=T(!1),p=K(()=>[...a.taxClasses,...i.value]),m=K(()=>{if(p.value.length>=6)return[];const Q=p.value.map(S=>S.slug).filter(Boolean),$=[];return Q.includes("reduced")||$.push({command:"reduced",label:d("Reduced")}),Q.includes("zero")||$.push({command:"zero",label:d("Zero")}),$.push({command:"custom",label:d("Custom Class...")}),$}),_=K(()=>s.value.isEdit?a.countries:a.countries.filter(Q=>!a.registeredCountries.includes(Q.value)));ke(()=>a.modelValue,Q=>{if(Q){const $=a.initialForm||{},S=$.rates?JSON.parse(JSON.stringify($.rates)):{};a.taxClasses.forEach(U=>{S[U.slug]||(S[U.slug]={rate:"",label:""})}),S.standard||(S.standard={rate:"",label:""}),s.value={country:$.country||"",vat:$.vat||"",rates:S,isEdit:$.isEdit||!1},i.value=[]}});function g(Q){return Q.tempKey||Q.slug}function y(Q){const $=a.countries.find(S=>S.value===Q);if($&&$.default_rate){const S=s.value.rates.standard||{};s.value.rates=Object.assign({},s.value.rates,{standard:Object.assign({},S,{rate:$.default_rate})})}}function v(Q){if(Q==="custom"){w();return}const $=Q==="reduced"?d("Reduced"):d("Zero");i.value.push({slug:Q,title:$,tempKey:Q}),s.value.rates[Q]={rate:"",label:""}}let k=0;function w(){const Q="_new_"+k++;i.value.push({slug:null,title:"",tempKey:Q,isNew:!0}),s.value.rates[Q]={rate:"",label:""}}function b(Q){return Q.slug?Q.title||Q.slug:Q.title&&Q.title.trim()?Q.title.trim():d("Custom")}function x(Q){if(Q.hasError=!1,Q.created)return Promise.resolve(null);if(!Q.slug&&!(Q.title&&Q.title.trim()))return Q.hasError=!0,Promise.reject(new Error(d("Please enter a name for the custom tax class")));const $=Q.slug?{slug:Q.slug}:{title:Q.title.trim()};return ce.post("tax/classes",$).then(S=>{const U=(S==null?void 0:S.class)||{},V=U.slug||Q.slug;if(!V)throw new Error(d("Tax class creation returned an invalid response"));return!Q.slug&&s.value.rates[Q.tempKey]!==void 0&&(s.value.rates[V]=s.value.rates[Q.tempKey],delete s.value.rates[Q.tempKey],Q.tempKey=null),Q.slug=V,Q.title=U.title||Q.title,Q.created=!0,U}).catch(S=>{var V;Q.hasError=!0;const U=((V=S==null?void 0:S.data)==null?void 0:V.message)||d("Failed to create tax class");throw new Error(d("%1$s: %2$s",U,b(Q)))})}function F(){if(!s.value.country){q.error(d("Select a registration country"));return}const Q=s.value.rates;if(!Object.values(Q).some(U=>parseFloat(U.rate)>0)){q.error(d("At least one tax rate must be greater than 0%"));return}A.value=!0;const S=i.value.map(x);Promise.all(S).then(()=>ce.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 V;q.error((U==null?void 0:U.message)||((V=U==null?void 0:U.data)==null?void 0:V.message)||d("Failed to save VAT registration"))}).finally(()=>{A.value=!1})}return(Q,$)=>{const S=C("el-option"),U=C("el-select"),V=C("el-form-item"),D=C("el-input"),I=C("el-dropdown-item"),L=C("el-dropdown-menu"),O=C("el-dropdown"),M=C("el-form"),H=C("el-button"),z=C("el-dialog");return r(),E(z,{"model-value":e.modelValue,title:s.value.isEdit?c(d)("Edit VAT registration"):c(d)("Collect VAT"),"close-on-click-modal":!1,class:"fluent-cart-admin-pages","append-to-body":!0,"onUpdate:modelValue":$[5]||($[5]=X=>l("update:modelValue",X))},{footer:u(()=>[n(H,{onClick:$[4]||($[4]=X=>l("update:modelValue",!1))},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1}),n(H,{type:"primary",onClick:F,loading:A.value},{default:u(()=>[R(f(c(d)("Collect VAT")),1)]),_:1},8,["loading"])]),default:u(()=>[o("div",Uhe,[o("p",Ihe,f(c(d)("Make sure you're registered for VAT when collecting in the EU.")),1),n(M,{"label-position":"top"},{default:u(()=>[n(V,{label:c(d)("Registration country")},{default:u(()=>[n(U,{modelValue:s.value.country,"onUpdate:modelValue":$[0]||($[0]=X=>s.value.country=X),placeholder:c(d)("Select country"),filterable:"",class:"w-full",disabled:s.value.isEdit,onChange:y},{default:u(()=>[(r(!0),h(P,null,le(_.value,X=>(r(),E(S,{key:X.value,label:X.label,value:X.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder","disabled"])]),_:1},8,["label"]),n(V,{label:c(d)("VAT number")},{default:u(()=>[n(D,{modelValue:s.value.vat,"onUpdate:modelValue":$[1]||($[1]=X=>s.value.vat=X),placeholder:s.value.country?s.value.country+"999999999":"DE999999999"},null,8,["modelValue","placeholder"]),o("div",Vhe,[o("p",null,f(c(d)("Shown on VAT invoice")),1)])]),_:1},8,["label"]),o("div",Dhe,[o("div",Qhe,[o("div",The,f(c(d)("Tax Classes")),1),$[6]||($[6]=o("div",{class:"fct-reg-rates-cell-input fct-reg-rates-cell-rate"},null,-1)),$[7]||($[7]=o("div",{class:"fct-reg-rates-cell-input"},null,-1))]),p.value.length?(r(!0),h(P,{key:0},le(p.value,X=>(r(),h("div",{key:X.tempKey||X.slug,class:"fct-reg-rates-row"},[o("div",Mhe,[X.isNew?(r(),E(D,{key:0,modelValue:X.title,"onUpdate:modelValue":G=>X.title=G,size:"small",placeholder:c(d)("Class name"),class:ue(["fct-reg-class-name-input",{"fct-reg-class-name-input--error":X.hasError}]),onInput:G=>X.hasError=!1},null,8,["modelValue","onUpdate:modelValue","placeholder","class","onInput"])):(r(),h("span",Lhe,f(X.title),1))]),o("div",Rhe,[n(D,{modelValue:s.value.rates[g(X)].rate,"onUpdate:modelValue":G=>s.value.rates[g(X)].rate=G,modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",size:"small",placeholder:X.slug==="standard"?"19":"0"},{suffix:u(()=>$[8]||($[8]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue","placeholder"])]),o("div",Ohe,[n(D,{modelValue:s.value.rates[g(X)].label,"onUpdate:modelValue":G=>s.value.rates[g(X)].label=G,size:"small",placeholder:c(d)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])])]))),128)):(r(),h("div",Phe,[o("div",Hhe,f(c(d)("Standard")),1),o("div",Nhe,[n(D,{modelValue:s.value.rates.standard.rate,"onUpdate:modelValue":$[2]||($[2]=X=>s.value.rates.standard.rate=X),modelModifiers:{number:!0},type:"number",step:"0.01",min:"0",size:"small",placeholder:"19"},{suffix:u(()=>$[9]||($[9]=[R("%",-1)])),_:1},8,["modelValue"])]),o("div",Khe,[n(D,{modelValue:s.value.rates.standard.label,"onUpdate:modelValue":$[3]||($[3]=X=>s.value.rates.standard.label=X),size:"small",placeholder:c(d)("e.g. VAT, MwSt")},null,8,["modelValue","placeholder"])])]))]),m.value.length?(r(),h("div",Ghe,[m.value.length===1&&m.value[0].command==="custom"?(r(),h("button",{key:0,type:"button",class:"fct-reg-add-class-btn",onClick:w},[n(J,{name:"Plus"}),R(" "+f(c(d)("Add class")),1)])):(r(),E(O,{key:1,trigger:"click",onCommand:v},{dropdown:u(()=>[n(L,null,{default:u(()=>[(r(!0),h(P,null,le(m.value,X=>(r(),E(I,{key:X.command,command:X.command},{default:u(()=>[R(f(X.label),1)]),_:2},1032,["command"]))),128))]),_:1})]),default:u(()=>[o("button",zhe,[n(J,{name:"Plus"}),R(" "+f(c(d)("Add class")),1)])]),_:1}))])):B("",!0)]),_:1})])]),_:1},8,["model-value","title"])}}},qhe={class:"fct-oss-rates-section"},Yhe=["aria-expanded"],Whe={class:"inline-flex items-center gap-2"},Xhe={class:"fct-oss-rates-count"},Jhe={class:"fct-oss-rates-table"},Zhe={key:1,class:"text-system-mid"},e_e={class:"fct-btn-group mt-4 justify-end sm"},t_e={__name:"EUVatOssRatesSection",setup(e,{expose:t}){const a=T([]),l=T([]),s=T(null),i=T("standard"),A=T(!1),p=T(!1),m=T(!1),_=T(!1),g=T(6),y=T(!1),v=T(""),k=K(()=>a.value),w=K(()=>{const V=v.value.trim().toLowerCase();return V?k.value.filter(D=>D.label&&D.label.toLowerCase().includes(V)):k.value});function b(){return A.value=!0,ce.get("tax/configuration/settings/eu-vat/oss-rates").then(V=>{a.value=V.rates||[],l.value=V.classes||[];const D=Pd({classes:l.value,activeId:s.value});return D&&(s.value=D.id,i.value=D.slug),l.value}).catch(V=>{var D;q.error((D=V==null?void 0:V.data)==null?void 0:D.message)}).finally(()=>{A.value=!1})}function x(V){s.value=V.id,i.value=V.slug}function F(V){y.value=!0,ti({payload:{slug:V},createdSlug:V,currentClasses:l.value,reloadClasses:b}).then(({createdClass:D})=>{D&&x(D)}).catch(D=>{var I;q.error((I=D==null?void 0:D.data)==null?void 0:I.message)}).finally(()=>{y.value=!1})}function Q(V){y.value=!0,ti({payload:{title:V},currentClasses:l.value,reloadClasses:b}).then(({createdClass:D})=>{D&&x(D)}).catch(D=>{var I;q.error((I=D==null?void 0:D.data)==null?void 0:I.message)}).finally(()=>{y.value=!1})}function $(V){V.slug!=="standard"&&Pa(d('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?',V.title),d("Delete Tax Class"),{confirmButtonText:d("Remove"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{A.value=!0,Vf({classId:V.id,currentActiveId:s.value===V.id?null:s.value,reloadClasses:b}).then(({nextActiveClass:D})=>{D&&x(D)}).catch(D=>{var I;q.error((I=D==null?void 0:D.data)==null?void 0:I.message),A.value=!1})}).catch(()=>{})}function S(){p.value=!0,ce.post("tax/configuration/settings/eu-vat/oss-rates",{rates:k.value.map(V=>({country:V.country,rate:V.rate,tax_label:V.tax_label||"",class_rates:V.class_rates||{}}))}).then(V=>{q.success(V.message)}).catch(V=>{var D;q.error((D=V==null?void 0:V.data)==null?void 0:D.message)}).finally(()=>{p.value=!1})}function U(){Pa(d("This will overwrite all EU destination country standard rates with preset defaults. Continue?"),d("Reset to default tax rates"),{confirmButtonText:d("Reset"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{m.value=!0,ce.post("tax/configuration/settings/eu-vat/reset-rates").then(()=>b()).then(()=>{q.success(d("EU tax rates have been reset to defaults"))}).catch(V=>{var D;q.error(((D=V==null?void 0:V.data)==null?void 0:D.message)||d("Failed to reset rates"))}).finally(()=>{m.value=!1})}).catch(()=>{})}return De(b),t({loadRates:b}),(V,D)=>{const I=C("el-icon"),L=C("el-table-column"),O=C("el-input"),M=C("el-table"),H=C("el-button"),z=Ta("loading");return r(),h("div",qhe,[o("div",{class:"fct-oss-rates-toggle",role:"button",tabindex:"0","aria-expanded":_.value,onClick:D[0]||(D[0]=X=>{_.value=!_.value,_.value||(v.value="")}),onKeydown:[D[1]||(D[1]=da(Ge(X=>{_.value=!_.value,_.value||(v.value="")},["prevent"]),["enter"])),D[2]||(D[2]=da(Ge(X=>{_.value=!_.value,_.value||(v.value="")},["prevent"]),["space"]))]},[o("span",Whe,[R(f(c(d)("Destination country rates"))+" ",1),o("span",Xhe," ("+f(k.value.length)+") ",1)]),n(I,{class:ue(["fct-oss-rates-arrow",{"is-expanded":_.value}])},{default:u(()=>[n(J,{name:"ChevronDown",class:"w-4 h-4"})]),_:1},8,["class"])],40,Yhe),n(Kl,{name:"fct-collapse"},{default:u(()=>[Wt(o("div",Jhe,[n(sl,{type:"info"},{content:u(()=>[o("span",null,f(c(d)("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"))+" + "+f(c(d)("button to add tax classes.")),1)]),_:1}),n(If,{classes:l.value,"active-id":s.value,"max-classes":g.value,creating:y.value,search:v.value,onSwitch:x,onDelete:$,onAdd:F,onCreateCustom:Q,"onUpdate:search":D[3]||(D[3]=X=>v.value=X)},null,8,["classes","active-id","max-classes","creating","search"]),Wt((r(),E(M,{data:w.value,class:"w-full fct-tax-rates-table","max-height":"450","empty-text":c(d)("No rates found")},{default:u(()=>[n(L,{label:c(d)("Country"),"min-width":"160"},{default:u(({row:X})=>[R(f(X.label),1)]),_:1},8,["label"]),n(L,{label:c(d)("Tax Label"),"min-width":"150"},{default:u(({row:X})=>[X.class_rates&&X.class_rates[i.value]?(r(),E(O,{key:0,modelValue:X.class_rates[i.value].label,"onUpdate:modelValue":G=>X.class_rates[i.value].label=G,size:"small",placeholder:c(d)("e.g. VAT, MwSt")},null,8,["modelValue","onUpdate:modelValue","placeholder"])):B("",!0)]),_:1},8,["label"]),n(L,{label:c(d)("Rate"),"min-width":"120"},{default:u(({row:X})=>[X.class_rates&&X.class_rates[i.value]?(r(),E(O,{key:0,modelValue:X.class_rates[i.value].rate,"onUpdate:modelValue":G=>X.class_rates[i.value].rate=G,modelModifiers:{number:!0},size:"small",type:"number",min:0,max:100,step:"0.5"},{suffix:u(()=>D[4]||(D[4]=[R("%",-1)])),_:2},1032,["modelValue","onUpdate:modelValue"])):(r(),h("span",Zhe,"—"))]),_:1},8,["label"])]),_:1},8,["data","empty-text"])),[[z,A.value]]),o("div",e_e,[i.value==="standard"?(r(),E(H,{key:0,size:"small",loading:m.value,onClick:U,type:"danger",soft:""},{default:u(()=>[R(f(c(d)("Reset to default")),1)]),_:1},8,["loading"])):B("",!0),n(H,{type:"primary",size:"small",loading:p.value,onClick:S},{default:u(()=>[R(f(c(d)("Save Rates")),1)]),_:1},8,["loading"])])],512),[[Sl,_.value]])]),_:1})])}}},a_e={class:"fct-vat-card-header"},l_e={class:"fct-vat-card-title"},s_e={class:"fct-vat-card-body"},n_e={class:"fct-vat-reg-info"},o_e={class:"fct-vat-country-name"},i_e={key:0,size:"small",type:"success",class:"ml-3 fct-collecting-badge"},r_e={key:1,class:"ml-3 text-sm text-system-mid dark:text-gray-400"},d_e={key:2,class:"fct-country-registrations-list mt-4"},u_e={class:"fct-reg-rows"},c_e={key:0,class:"fct-vat-registration-row"},A_e={class:"fct-vat-reg-info"},p_e=["src","alt"],f_e={class:"fct-vat-country-name"},m_e={class:"fct-vat-reg-info"},h_e=["src","alt"],__e={class:"fct-vat-country-name"},v_e={key:0,class:"fct-vat-number"},g_e={key:1,class:"fct-vat-missing-badge"},y_e={class:"fct-vat-reg-actions"},b_e={key:1,class:"fct-vat-empty-state"},w_e={class:"text-system-mid text-sm"},C_e={key:0,class:"px-5 py-3"},k_e={key:1,class:"fct-vat-cross-border-empty"},B_e={class:"fct-vat-cross-border-empty-text"},x_e={class:"fct-vat-cross-border-empty-title"},S_e={class:"fct-vat-cross-border-empty-desc"},$_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),A=T(null),p=T([]),m=T(!1),_=T({country:"",vat:"",rates:{},isEdit:!1}),g=K(()=>a.countries.length||28),y=K(()=>a.initialRegistrations.filter(Q).length),v=K(()=>a.storeCountry&&a.countries.find(Y=>Y.value===a.storeCountry)||null),k=K(()=>a.storeCountry?a.initialRegistrations.some(Y=>Y.country===a.storeCountry):!1),w=K(()=>{if(s.value.method!=="home"||!s.value.home_country)return!1;const Y=a.initialRegistrations.find(Z=>Z.country===s.value.home_country);return!!Y&&Q(Y)}),b=K(()=>s.value.method==="oss"||s.value.method==="home"||s.value.method==="specific");function x(Y){if(!Y||!Array.isArray(a.countries))return Y;const Z=a.countries.find(de=>de.value===Y);return Z?Z.label:Y}function F(Y){return Y?Y.rates&&typeof Y.rates=="object"&&Object.keys(Y.rates).length?Object.values(Y.rates).some(Z=>Z&&parseFloat(Z.rate)>0):parseFloat(Y.rate)>0:!1}function Q(Y){return!!Y&&!!Y.vat&&F(Y)}function $(Y){return F(Y)&&!Y.vat}function S(){return ce.get("tax/classes").then(Y=>{p.value=Y.classes||[]}).catch(()=>{q.error(d("Failed to load tax classes"))})}function U(Y){const Z={};return p.value.forEach(de=>{Z[de.slug]={rate:de.slug==="standard"&&Y||"",label:""}}),Z}function V(){const Y=v.value&&!k.value?a.storeCountry:"",Z=Y&&v.value&&v.value.default_rate||"";_.value={country:Y,vat:"",rates:U(Z),isEdit:!1},m.value=!0}function D(Y){const Z=Y.rates||{},de={};p.value.forEach(j=>{const ge=Z[j.slug];if(ge&&typeof ge=="object")de[j.slug]={rate:ge.rate||"",label:ge.label||""};else{const ie=j.slug==="standard"?Y.rate||"":ge||"";de[j.slug]={rate:ie,label:j.slug==="standard"&&Y.tax_label||""}}}),_.value={country:Y.country,vat:Y.vat||"",rates:de,isEdit:!0},m.value=!0}function I(){S(),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:s.value.home_vat})}function L(Y){ce.post("tax/configuration/settings/eu-vat",{action:"saveCountryRegistration",country:Y.country,vat:Y.vat,rates:Y.rates}).then(Z=>{q.success(Z.message),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:Y.vat})}).catch(Z=>{var de;q.error(((de=Z==null?void 0:Z.data)==null?void 0:de.message)||d("Failed to save VAT registration"))})}function O(Y){Pa(d("Are you sure you want to remove this country registration?"),d("Confirm Remove"),{confirmButtonText:d("Yes, Remove"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{ce.post("tax/configuration/settings/eu-vat",{action:"deleteCountryRegistration",country:Y}).then(Z=>{q.success(Z.message),l("method-changed",{method:s.value.method,home_country:s.value.home_country,home_vat:s.value.home_vat})}).catch(Z=>{var de;q.error((de=Z==null?void 0:Z.data)==null?void 0:de.message)})}).catch(()=>{})}function M(){return y.value===1?d("Collecting in 1 country"):d("Collecting in %1$s countries",y.value)}const H=K(()=>g.value===1?d("Collecting in 1 region"):d("Collecting in %1$s regions",g.value));function z(Y){s.value={method:Y.method,oss_country:Y.oss_country,oss_vat:Y.oss_vat,home_country:Y.home_country,home_vat:Y.home_country_vat},Y.method==="oss"&&Fe(()=>{var Z;return(Z=A.value)==null?void 0:Z.loadRates()}),l("method-changed",{method:Y.method,home_country:Y.home_country,home_vat:Y.home_country_vat})}function X(Y){Y==="edit"?i.value=!0:Y==="stop"&&G()}function G(){Pa(d("Are you sure you want to stop collecting cross-border VAT? This will clear your OSS/home country registration."),d("Stop Collecting"),{confirmButtonText:d("Yes, Stop"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{ce.post("tax/configuration/settings/eu-vat",{action:"euCrossBorderSettings",eu_vat_settings:{method:"specific"},reset_registration:"yes"}).then(Y=>{q.success(Y.message),s.value={method:"",oss_country:"",oss_vat:"",home_country:"",home_vat:""},l("method-changed",{method:"",home_country:"",home_vat:""})}).catch(Y=>{var Z;q.error((Z=Y==null?void 0:Y.data)==null?void 0:Z.message)})}).catch(()=>{})}return ke(()=>a.initialForm,Y=>{const Z=Y||{};s.value={method:Z.method||"",oss_country:Z.oss_country||"",oss_vat:Z.oss_vat||"",home_country:Z.home_country||"",home_vat:Z.home_vat||""}},{immediate:!0}),ke(()=>a.countries,Y=>{Y&&Y.length&&S()},{immediate:!0}),(Y,Z)=>{const de=C("el-tooltip"),j=C("el-dropdown-item"),ge=C("el-dropdown-menu"),ie=C("el-dropdown"),W=C("el-button");return r(),h(P,null,[n($e,{class:"fct-vat-card"},{default:u(()=>[n(xe,null,{default:u(()=>[o("div",a_e,[o("div",l_e,[o("h3",null,f(c(d)("Collect VAT cross-border")),1),n(de,{content:c(d)("Choose how to collect VAT for sales to other EU countries."),placement:"top"},{default:u(()=>[n(J,{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:X,"popper-class":"fct-dropdown",placement:"bottom-end"},{dropdown:u(()=>[n(ge,null,{default:u(()=>[n(j,{command:"edit"},{default:u(()=>[R(f(c(d)("Edit registration")),1)]),_:1}),n(j,{command:"stop"},{default:u(()=>[R(f(c(d)("Stop collecting")),1)]),_:1})]),_:1})]),default:u(()=>[n(lt,{border:"none",size:"small",tag:"button"},{default:u(()=>[n(J,{name:"More"})]),_:1})]),_:1})):B("",!0)]),o("div",s_e,[b.value?(r(),h(P,{key:0},[o("div",n_e,[Z[4]||(Z[4]=o("span",{class:"fct-eu-flag-icon"},"🇪🇺",-1)),o("span",o_e,f(s.value.method==="oss"?c(d)("EU (OSS)"):s.value.method==="home"?c(d)("EU (micro-business)"):c(d)("EU (specific countries)")),1),e.isTaxEnabled&&(s.value.method!=="specific"||y.value>0)?(r(),h("span",i_e,[Z[3]||(Z[3]=o("span",{class:"fct-green-dot"},null,-1)),s.value.method==="specific"?(r(),h(P,{key:0},[R(f(M()),1)],64)):(r(),h(P,{key:1},[R(f(H.value),1)],64))])):B("",!0),e.isTaxEnabled?B("",!0):(r(),h("span",r_e,f(c(d)("Tax disabled")),1))]),s.value.method==="home"?(r(),E(sl,{key:0,type:w.value?"info":"warning",icon:"Info",class:"mb-4 mt-4",content:w.value?c(d)("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.",x(s.value.home_country)):c(d)("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.",x(s.value.home_country))},null,8,["type","content"])):B("",!0),s.value.method==="home"?(r(),E(Ehe,{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:L,onClassChanged:S},null,8,["countries","home-country","home-vat","tax-classes","registrations"])):B("",!0),s.value.method==="specific"?(r(),h("div",d_e,[o("div",u_e,[v.value&&!k.value?(r(),h("div",c_e,[o("div",A_e,[o("img",{src:`https://flagcdn.com/w40/${e.storeCountry.toLowerCase()}.png`,alt:v.value.label,class:"fct-flag-icon"},null,8,p_e),o("span",f_e,f(v.value.label),1)]),n(W,{size:"small",onClick:V},{default:u(()=>[R(f(c(d)("Configure")),1)]),_:1})])):B("",!0),(r(!0),h(P,null,le(e.initialRegistrations,N=>(r(),h("div",{key:N.country,class:"fct-vat-registration-row"},[o("div",m_e,[o("img",{src:`https://flagcdn.com/w40/${N.country.toLowerCase()}.png`,alt:x(N.country),class:"fct-flag-icon"},null,8,h_e),o("span",__e,f(x(N.country)),1),N.vat?(r(),h("span",v_e,f(N.vat),1)):$(N)?(r(),h("span",g_e,f(c(d)("VAT ID missing")),1)):B("",!0)]),o("div",y_e,[F(N)?(r(),E(lt,{key:0,border:"none",size:"small",tag:"button",title:c(d)("Edit"),onClick:ae=>D(N)},{default:u(()=>[n(J,{name:"Edit"})]),_:2},1032,["title","onClick"])):(r(),E(W,{key:1,size:"small",onClick:ae=>D(N)},{default:u(()=>[R(f(c(d)("Configure")),1)]),_:2},1032,["onClick"])),n(lt,{border:"none",size:"small",tag:"button",title:c(d)("Delete"),onClick:ae=>O(N.country)},{default:u(()=>[n(J,{name:"Delete"})]),_:2},1032,["title","onClick"])])]))),128)),!e.initialRegistrations.length&&!v.value?(r(),h("div",b_e,[o("p",w_e,f(c(d)("No country VAT registrations configured.")),1),n(W,{type:"primary",size:"small",onClick:V},{default:u(()=>[R(f(c(d)("Configure")),1)]),_:1})])):B("",!0)]),e.initialRegistrations.length||v.value?(r(),h("div",C_e,[n(W,{type:"primary",link:"",onClick:V},{default:u(()=>[R(" + "+f(c(d)("Collect in another country")),1)]),_:1})])):B("",!0)])):B("",!0),s.value.method==="oss"?(r(),E(t_e,{key:3,ref_key:"ossRatesRef",ref:A},null,512)):B("",!0)],64)):(r(),h("div",k_e,[Z[5]||(Z[5]=o("span",{class:"fct-eu-flag-icon"},"🇪🇺",-1)),o("div",B_e,[o("p",x_e,f(c(d)("Not collecting cross-border VAT")),1),o("p",S_e,f(c(d)("Set up OSS, micro-business, or specific-country registrations to collect VAT across the EU.")),1)]),n(W,{size:"small",onClick:Z[0]||(Z[0]=N=>i.value=!0),type:"primary"},{default:u(()=>[R(f(c(d)("Configure")),1)]),_:1})]))])]),_:1})]),_:1}),n(rhe,{modelValue:i.value,"onUpdate:modelValue":Z[1]||(Z[1]=N=>i.value=N),countries:e.countries,"current-form":s.value,"initial-registrations":e.initialRegistrations,onSaved:z},null,8,["modelValue","countries","current-form","initial-registrations"]),n(jhe,{modelValue:m.value,"onUpdate:modelValue":Z[2]||(Z[2]=N=>m.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)}}},F_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([]),A=T(!1),p=T(!1);function m(){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)||m(),id:b.id};else{const x=b._raw.meta_value||b._raw;s.value={type:"products",original_type:"products",original_id:b.id,category_id:on(x.category_id),category_name:b.category_name,country:x.country||"",city:x.city||"",postcode:x.postcode||"",tax_label:b.tax_label,tax_rate:b.rate,class_id:Number(b.class_id)||0,id:b.id}}}ke(()=>a.modelValue,b=>{b&&(a.editRow?g(a.editRow):_(),y())}),ke(()=>s.value.type,b=>{b==="shipping"&&!s.value.class_id&&(s.value.class_id=m())}),ke(()=>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||(A.value=!0,ce.get("products/fetch-term").then(b=>{const x=b.taxonomies&&b.taxonomies["product-categories"]?b.taxonomies["product-categories"].terms||[]:[];i.value=x.map(F=>({...F,value:on(F.value)}))}).catch(()=>{q.error(d("Failed to load product categories"))}).finally(()=>{A.value=!1}))}function v(b,x){return ce.get("tax/rates/country/rates/"+b,{class_id:x}).then(F=>{const $=(F&&F.tax_rates?F.tax_rates:[]).find(function(U){return!U.state&&!U.city&&!U.postcode});if($)return $;const S=a.countries.find(function(U){return U.value===b});return ce.post("tax/country/rate",{country:b,state:"",rate:S&&S.default_rate||0,name:"Tax",is_compound:0,for_order:0,group:"EU",class_id:x}).then(function(U){return U&&U.tax_rate?U.tax_rate:null})})}function k(b){const x=on(b),F=i.value.find(Q=>Q.value===x);F&&(s.value.category_name=F.label)}function w(){if(s.value.type==="products"&&!s.value.category_id){q.error(d("Please select a category"));return}if(!s.value.country){q.error(d("Please select a location"));return}if(s.value.type==="shipping"){if(!a.taxClasses||a.taxClasses.length===0){q.error(d("Tax classes are not available. Please reload the page and try again."));return}if(!s.value.class_id){q.error(d("Please select a tax class"));return}}if(p.value=!0,s.value.type==="products")ce.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(x=>x?ce.post("tax/rates/country/override",{id:x.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(F=>{q.success(F.message),l("saved"),l("update:modelValue",!1)}).catch(F=>{q.error(F&&F.data?F.data.message:F&&F.message?F.message:"")}).finally(()=>{p.value=!1}):(q.error(d("No tax rate found for the selected country and tax class")),p.value=!1,null)).catch(x=>{q.error(x&&x.data?x.data.message:x&&x.message?x.message:""),p.value=!1})}}return(b,x)=>{const F=C("el-radio"),Q=C("el-radio-group"),$=C("el-form-item"),S=C("el-option"),U=C("el-select"),V=C("el-input"),D=C("el-form"),I=C("el-button"),L=C("el-dialog");return r(),E(L,{"model-value":e.modelValue,title:e.editRow?c(d)("Edit tax override"):c(d)("Add tax override"),width:"520px","close-on-click-modal":!1,class:"fluent-cart-admin-pages","append-to-body":!0,"onUpdate:modelValue":x[14]||(x[14]=O=>l("update:modelValue",O))},{footer:u(()=>[n(I,{onClick:x[13]||(x[13]=O=>l("update:modelValue",!1))},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1}),n(I,{type:"primary",loading:p.value,onClick:w},{default:u(()=>[R(f(e.editRow?c(d)("Save changes"):c(d)("Add override")),1)]),_:1},8,["loading"])]),default:u(()=>[n(D,{"label-position":"top",model:s.value},{default:u(()=>[n($,{label:c(d)("Override type")},{default:u(()=>[n(Q,{modelValue:s.value.type,"onUpdate:modelValue":x[0]||(x[0]=O=>s.value.type=O)},{default:u(()=>[n(F,{value:"products"},{default:u(()=>[R(f(c(d)("Products")),1)]),_:1}),n(F,{value:"shipping"},{default:u(()=>[R(f(c(d)("Shipping")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),s.value.type==="products"?(r(),h(P,{key:0},[n($,{label:c(d)("Category")},{default:u(()=>[n(U,{modelValue:s.value.category_id,"onUpdate:modelValue":x[1]||(x[1]=O=>s.value.category_id=O),filterable:"",placeholder:c(d)("Select a category"),loading:A.value,style:{width:"100%"},onChange:k},{default:u(()=>[(r(!0),h(P,null,le(i.value,O=>(r(),E(S,{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($,{key:0,label:c(d)("Tax Class")},{default:u(()=>[n(U,{modelValue:s.value.class_id,"onUpdate:modelValue":x[2]||(x[2]=O=>s.value.class_id=O),style:{width:"100%"}},{default:u(()=>[n(S,{value:0,label:c(d)("All Tax Classes")},null,8,["label"]),(r(!0),h(P,null,le(e.taxClasses,O=>(r(),E(S,{key:O.id,value:Number(O.id),label:O.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])):B("",!0),n($,{label:c(d)("Tax label")},{default:u(()=>[n(V,{modelValue:s.value.tax_label,"onUpdate:modelValue":x[3]||(x[3]=O=>s.value.tax_label=O),placeholder:c(d)("e.g. Tax, VAT, GST")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n($,{label:c(d)("Location")},{default:u(()=>[n(U,{modelValue:s.value.country,"onUpdate:modelValue":x[4]||(x[4]=O=>s.value.country=O),placeholder:c(d)("Select country"),filterable:"",style:{width:"100%"}},{default:u(()=>[(r(!0),h(P,null,le(e.countries,O=>(r(),E(S,{key:O.value,label:O.label,value:O.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"]),n($,{label:c(d)("City (optional)")},{default:u(()=>[n(V,{modelValue:s.value.city,"onUpdate:modelValue":x[5]||(x[5]=O=>s.value.city=O),placeholder:c(d)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n($,{label:c(d)("Postcode (optional)")},{default:u(()=>[n(V,{modelValue:s.value.postcode,"onUpdate:modelValue":x[6]||(x[6]=O=>s.value.postcode=O),placeholder:c(d)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n($,{label:c(d)("Tax rate (%)")},{default:u(()=>[n(V,{modelValue:s.value.tax_rate,"onUpdate:modelValue":x[7]||(x[7]=O=>s.value.tax_rate=O),type:"number",step:"0.01",min:"0",placeholder:c(d)("e.g. 0 for tax exempt")},null,8,["modelValue","placeholder"])]),_:1},8,["label"])],64)):(r(),h(P,{key:1},[n($,{label:c(d)("Location")},{default:u(()=>[n(U,{modelValue:s.value.country,"onUpdate:modelValue":x[8]||(x[8]=O=>s.value.country=O),placeholder:c(d)("Select country"),filterable:"",style:{width:"100%"}},{default:u(()=>[(r(!0),h(P,null,le(e.countries,O=>(r(),E(S,{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($,{key:0,label:c(d)("Tax Class")},{default:u(()=>[n(U,{modelValue:s.value.class_id,"onUpdate:modelValue":x[9]||(x[9]=O=>s.value.class_id=O),style:{width:"100%"}},{default:u(()=>[(r(!0),h(P,null,le(e.taxClasses,O=>(r(),E(S,{key:O.id,value:Number(O.id),label:O.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])):B("",!0),n($,{label:c(d)("City (optional)")},{default:u(()=>[n(V,{modelValue:s.value.city,"onUpdate:modelValue":x[10]||(x[10]=O=>s.value.city=O),placeholder:c(d)("Leave empty to match all cities")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n($,{label:c(d)("Postcode (optional)")},{default:u(()=>[n(V,{modelValue:s.value.postcode,"onUpdate:modelValue":x[11]||(x[11]=O=>s.value.postcode=O),placeholder:c(d)("e.g. 9300 or 9300-9399 or 9300,9400")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),n($,{label:c(d)("Tax rate (%)")},{default:u(()=>[n(V,{modelValue:s.value.tax_rate,"onUpdate:modelValue":x[12]||(x[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"])}}},E_e={class:"fct-tax-rates-country-view"},U_e={key:0,class:"border border-gray-200 rounded-md overflow-hidden dark:border-dark-300"},I_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"},V_e={key:0},D_e={key:1},Q_e={class:"fct-btn-group sm justify-end"},T_e={__name:"EUVatTaxOverridesCard",props:{countries:{type:Array,default:()=>[]}},setup(e){const t=e,a=T([]),l=T(!1),s=T(!1),i=T(null),A=T([]);function p(k){if(!k||!Array.isArray(t.countries))return k;const w=t.countries.find(b=>b.value===k);return w?w.label:k}function m(){ce.get("tax/classes").then(k=>{A.value=k.classes||[]}).catch(()=>{q.error(d("Failed to load tax classes"))})}function _(){l.value=!0,ce.get("tax/configuration/settings/eu-vat/product-overrides").then(k=>{const w=[],b=k.overrides||[];for(const F of b){const Q=F.meta_value||F;w.push({id:F.id,type:"products",tax_label:Q.tax_label||"",category_name:Q.category_name||"",location:p(Q.country),city:Q.city||"",postcode:Q.postcode||"",rate:Q.rate,class_id:Number(F.class_id)||0,class_label:F.class_label||"",_raw:F})}const x=k.shipping_overrides||[];for(const F of x)w.push({id:F.id,type:"shipping",tax_label:F.name||"",category_name:"",location:p(F.country),city:F.city||"",postcode:F.postcode||"",rate:F.for_shipping,class_id:Number(F.class_id)||0,class_label:F.class_label||"",_raw:F});a.value=w}).catch(()=>{a.value=[]}).finally(()=>{l.value=!1})}function g(){i.value=null,s.value=!0}function y(k){i.value=k,s.value=!0}function v(k){Pa(d("Are you sure you want to delete this override?"),d("Confirm Delete"),{confirmButtonText:d("Yes, Delete"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{const w=k.type==="shipping"?"tax/rates/country/override/"+k.id:"tax/product-overrides/"+k.id;ce.delete(w).then(b=>{q.success(b.message),a.value=a.value.filter(x=>!(x.id===k.id&&x.type===k.type))}).catch(b=>{var x;q.error((x=b==null?void 0:b.data)==null?void 0:x.message)})}).catch(()=>{})}return De(()=>{m(),_()}),(k,w)=>{const b=C("el-button"),x=C("el-tag"),F=C("el-table-column"),Q=C("el-table");return r(),h(P,null,[n($e,{class:"fct-vat-card"},{default:u(()=>[n(Qe,{title:c(d)("Tax overrides"),text:c(d)("Override tax rates for specific product categories or shipping.")},{action:u(()=>[n(b,{size:"small",onClick:g},{default:u(()=>[R(f(c(d)("Add Tax Override")),1)]),_:1})]),_:1},8,["title","text"]),n(xe,null,{default:u(()=>[o("div",E_e,[l.value?(r(),h("div",U_e,[o("div",I_e,[(r(),h(P,null,le(6,$=>o("div",{key:"loading-header-"+$,class:"fct-sk h-3 rounded-xs"})),64))]),(r(),h(P,null,le(3,$=>o("div",{key:"loading-row-"+$,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"},w[2]||(w[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(Q,{key:1,data:a.value,"empty-text":c(d)("No overrides configured")},{default:u(()=>[n(F,{label:c(d)("Type"),width:"110"},{default:u(({row:$})=>[n(x,{type:$.type==="products"?"primary":"info",size:"small"},{default:u(()=>[R(f($.type==="products"?c(d)("Product"):c(d)("Shipping")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),n(F,{label:c(d)("Category")},{default:u(({row:$})=>[R(f($.category_name||"—"),1)]),_:1},8,["label"]),n(F,{label:c(d)("Tax Class"),width:"130"},{default:u(({row:$})=>[R(f($.class_label||c(d)("All")),1)]),_:1},8,["label"]),n(F,{label:c(d)("Tax Label")},{default:u(({row:$})=>[R(f($.tax_label||"—"),1)]),_:1},8,["label"]),n(F,{label:c(d)("Location")},{default:u(({row:$})=>[R(f($.location),1)]),_:1},8,["label"]),n(F,{label:c(d)("City / Postcode")},{default:u(({row:$})=>[$.city||$.postcode?(r(),h("span",V_e,f([$.city,$.postcode].filter(Boolean).join(" / ")),1)):(r(),h("span",D_e,"—"))]),_:1},8,["label"]),n(F,{label:c(d)("Rate"),width:"100"},{default:u(({row:$})=>[R(f($.rate)+"% ",1)]),_:1},8,["label"]),n(F,{label:c(d)("Actions"),width:"110",align:"right"},{default:u(({row:$})=>[o("div",Q_e,[n(lt,{tag:"button",size:"small",onClick:S=>y($)},{default:u(()=>[n(J,{name:"Edit"})]),_:2},1032,["onClick"]),n(lt,{tag:"button",size:"small",onClick:S=>v($),bg:"danger",outline:""},{default:u(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick"])])]),_:1},8,["label"])]),_:1},8,["data","empty-text"]))])]),_:1})]),_:1}),n(F_e,{modelValue:s.value,"onUpdate:modelValue":[w[0]||(w[0]=$=>s.value=$),w[1]||(w[1]=$=>!$&&(i.value=null))],countries:e.countries,"tax-classes":A.value,"edit-row":i.value,onSaved:_},null,8,["modelValue","countries","tax-classes","edit-row"])],64)}}},M_e={class:"setting-wrap"},L_e={class:"setting-wrap-inner"},R_e={class:"fct-tax-collection-page"},O_e={__name:"EUVatSettings",setup(e){const t=T(!0),a=je.get("eu_vat_county_options",[]),l=T(""),s=T(""),i=T([]),A=T({}),p=K(()=>!!je.get("is_tax_enabled"));function m(){return t.value=!0,ce.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||[],A.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||"",m()}return De(m),(g,y)=>(r(),h("div",M_e,[n($a,{heading:c(d)("VAT collection"),"show-save-button":!1},null,8,["heading"]),o("div",L_e,[n(Fa),o("div",R_e,[t.value?(r(),E(Xme,{key:0})):(r(),h(P,{key:1},[n($_e,{countries:c(a),"initial-form":A.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(T_e,{countries:c(a),class:"mt-5"},null,8,["countries"])],64))])])]))}};class P_e extends ws{getTabs(){return{all:d("All"),active:d("Active"),expired:d("Inactive")}}getToggleableColumns(){return[{label:"Title",value:"title"},{label:"Stackable",value:"stackable"},{label:"Actions",value:"actions"}]}getSearchHint(){return d("Search by id, title, amount, code.")}getFetchUrl(){return"coupons"}parseResponse(t){return t.coupons}getTableName(){return"coupon_table"}getAdvanceFilterOptions(){return null}getSearchGuideOptions(){return[]}with(){return[]}}function Df(e){return P_e.init(e)}const H_e={class:"fct-table-mobile-wrap fct-coupons-table-mobile-wrap"},N_e={class:"fct-table-mobile-header"},K_e={class:"fct-table-mobile-header-left"},G_e={class:"fct-table-id-col"},z_e={class:"fct-table-status-col"},j_e=["onClick"],q_e={class:"title"},Y_e={class:"value"},W_e={key:0,class:"fct-table-action-col"},X_e={class:"more-btn pr-0"},J_e={class:"fct-table-mobile-body"},Z_e=["onClick"],eve={key:0,class:"fct-table-coupon-title-col"},tve={class:"fct-table-coupon-code-col"},ave=["onClick"],lve={class:"fct-table-mobile-footer"},sve=["onClick"],nve={class:"fct-table-date-col grid"},ove={class:"title"},ive={class:"value"},rve={key:0,class:"fct-table-stackable-col"},dve={class:"title"},uve={class:"value"},cve={class:"fct-table-amount-col"},Ave={class:"title"},pve={class:"value"},fve={__name:"CouponsTableMobile",props:{table:{type:Object,required:!0},emptyText:{type:String,default:d("No customers found.")}},setup(e){st.extend(hi);const t=e,a=s=>{if(!s||s==="0000-00-00 00:00:00")return!1;const i=st.utc(s).local();return i.isValid()?i.isBefore(st()):!1},l=s=>{let i=d("Are you sure you want to delete this %s coupon. This action is not recoverable",s.coupon.title);s.action==="delete"&&Pa(i,d("Confirm Delete!"),{confirmButtonText:d("Yes, Delete!"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{ce.delete("coupons/"+s.coupon.id).then(A=>{q.success(A.message),t.table.fetch()}).catch(A=>{q.error(A)}).finally(()=>{})}).catch(()=>{})};return(s,i)=>{const A=C("router-link"),p=C("el-tooltip"),m=C("el-dropdown-item"),_=C("el-dropdown-menu"),g=C("el-dropdown");return r(),h("div",H_e,[(r(!0),h(P,null,le(e.table.getTableData(),(y,v)=>(r(),h("div",{key:y.id,class:"fct-table-mobile-row"},[o("div",N_e,[o("div",K_e,[o("div",G_e,[n(A,{to:{name:"add_or_edit_coupon",params:{coupon_id:y.id}},class:"id"},{default:u(()=>[R(" #"+f(y.id),1)]),_:2},1032,["to"])]),o("div",z_e,[n(la,{status:y.status},{default:u(()=>[R(f(a(y.end_date)?c(d)("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:u(()=>[R(f(c(d)("Available On: %s",c(Ts)(y.start_date,!0))),1)]),default:u(()=>[n(J,{name:"InformationFill",class:"w-4 h-4 flex-none"})]),_:2},1024)):B("",!0)]),o("div",{class:"fct-table-usage-col",onClick:k=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[o("div",q_e,f(c(d)("Usage:")),1),o("div",Y_e,[R(f(y.use_count??0)+" ",1),i[0]||(i[0]=o("span",null,"/",-1)),R(" "+f(y.conditions.max_uses>0?y.conditions.max_uses:c(d)("Unlimited")),1)])],8,j_e)]),e.table.isColumnVisible("actions")?(r(),h("div",W_e,[n(g,{trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:l,placement:"bottom-end"},{dropdown:u(()=>[n(_,null,{default:u(()=>[y.id?(r(),E(m,{key:0,class:"item-link"},{default:u(()=>[n(A,{to:{name:"add_or_edit_coupon",params:{coupon_id:y.id,action:"edit"}}},{default:u(()=>[n(J,{name:"Edit"}),R(" "+f(c(d)("Edit")),1)]),_:2},1032,["to"])]),_:2},1024)):B("",!0),n(m,{command:{action:"delete",coupon:y},class:"item-destructive"},{default:u(()=>[n(J,{name:"Delete"}),R(" "+f(c(d)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:u(()=>[o("span",X_e,[n(J,{name:"More"})])]),_:2},1024)])):B("",!0)]),o("div",J_e,[o("div",{class:"fct-table-coupon-code-wrapper-col",onClick:k=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[e.table.isColumnVisible("title")?(r(),h("div",eve,f(y.title),1)):B("",!0),o("div",tve,[o("code",{class:"copyable-content",onClick:k=>{c(ls).copy(y.code)}},f(y.code),9,ave)])],8,Z_e)]),o("div",lve,[o("div",{class:"fct-table-mobile-footer-row items-start",onClick:k=>s.$router.push({name:"add_or_edit_coupon",params:{coupon_id:y.id}})},[o("div",nve,[o("div",ove,f(c(d)("Expiry Date")),1),o("div",ive,[isNaN(Date.parse(y.end_date))?(r(),h(P,{key:1},[R("n/a")],64)):(r(),E(Sa,{key:0,"date-time":y.end_date,"with-time":!0},null,8,["date-time"]))])]),e.table.isColumnVisible("stackable")?(r(),h("div",rve,[o("div",dve,f(c(d)("Stackable")),1),o("div",uve,f(y.stackable),1)])):B("",!0),o("div",cve,[o("div",Ave,f(c(d)("Amount")),1),o("div",pve,f(y.type!=="percentage"?c(zt)(y.amount,!0):y.amount+"%"),1)])],8,sve)])]))),128))])}}},mve={},hve={class:"px-4 py-3"},_ve={class:"grid grid-cols-3 gap-5 mt-5"};function vve(e,t){const a=C("el-skeleton-item"),l=C("el-skeleton");return r(),E(l,{animated:""},{template:u(()=>[o("div",hve,[(r(),h(P,null,le(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",_ve,[(r(),h(P,null,le(3,s=>o("div",{key:s},[n(a,{varient:"p",class:"w-1/2"}),n(a,{varient:"p",class:"w-[100px]"})])),64))])])]),_:1})}const gve=nt(mve,[["render",vve]]),yve={class:"fct-all-coupons-page fct-layout-width"},bve={class:"fct-all-coupons-wrap"},wve={key:1},Cve=["onClick"],kve={class:"capitalize"},Bve={class:"more-btn mr-2"},Qc={__name:"AllCoupons",setup(e){st.extend(hi);const t=Df(),a=T(!1),l=A=>{let p=d("Are you sure you want to delete this %s coupon. This action is not recoverable",A.coupon.title);A.action==="delete"&&Pa(p,d("Confirm Delete!"),{confirmButtonText:d("Yes, Delete!"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{ce.delete("coupons/"+A.coupon.id).then(m=>{q.success(m.message),t.fetch()}).catch(m=>{var _;m.status_code=="422"?q.validationErrors(m):q.error((_=m.data)==null?void 0:_.message)}).finally(()=>{})}).catch(()=>{})},s=()=>{ce.get("coupons/getSettings").then(A=>{a.value=!!parseInt(A.show_on_checkout)}).catch(A=>{var p;A.status_code=="422"?q.validationErrors(A):q.error((p=A.data)==null?void 0:p.message)}).finally(()=>{})},i=A=>{if(!A||A==="0000-00-00 00:00:00")return!1;const p=st.utc(A).local();return p.isValid()?p.isBefore(st()):!1};return De(()=>{s()}),(A,p)=>{const m=C("el-button"),_=C("el-table-column"),g=C("el-tooltip"),y=C("router-link"),v=C("el-dropdown-item"),k=C("el-dropdown-menu"),w=C("el-dropdown"),b=C("el-table");return r(),E(Ot,{permission:"coupons/view"},{default:u(()=>[o("div",yve,[n(nl,{title:c(d)("Coupons")},{action:u(()=>[n(m,{tag:"router-link",type:"primary",to:{name:"add_or_edit_coupon"}},{default:u(()=>[R(f(c(d)("Add Coupon")),1)]),_:1})]),_:1},8,["title"]),o("div",bve,[n(Cs,{table:c(t),"has-mobile-slot":!0},{mobile:u(()=>[c(t).isLoading()?(r(),E(gve,{key:0})):B("",!0),c(t).isLoading()?B("",!0):(r(),E(fve,{key:1,table:c(t)},null,8,["table"]))]),default:u(()=>[c(t).isLoading()?(r(),E(bme,{key:0,couponTable:c(t),"next-page-count":c(t).nextPageCount},null,8,["couponTable","next-page-count"])):(r(),h("div",wve,[n(b,{data:c(t).getTableData(),class:"w-full compact-table full-compact"},{empty:u(()=>[n(wt,{icon:"Empty/Order","has-dark":"",text:c(d)("No coupons available at the moment.")},null,8,["text"])]),default:u(()=>[n(_,{width:100,label:c(d)("ID")},{default:u(x=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:x.row.id}}},{default:u(()=>[R(" #"+f(c(ea)(x.row.id)),1)]),_:2},1032,["to"])]),_:1},8,["label"]),c(t).isColumnVisible("title")?(r(),E(_,{key:0,label:c(d)("Title"),width:220},{default:u(x=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:x.row.id,action:"edit"}}},{default:u(()=>[R(f(x.row.title),1)]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),n(_,{label:c(d)("Code"),width:200},{default:u(x=>[o("code",{class:"copyable-content",onClick:F=>{c(ls).copy(x.row.code)}},f(x.row.code),9,Cve)]),_:1},8,["label"]),n(_,{label:c(d)("Amount"),width:120},{default:u(x=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:x.row.id,action:"edit"}}},{default:u(()=>[R(f(x.row.type!=="percentage"?c(zt)(x.row.amount,!0):x.row.amount+"%"),1)]),_:2},1032,["to"])]),_:1},8,["label"]),n(_,{label:c(d)("Usage"),width:150},{default:u(x=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:x.row.id,action:"edit"}}},{default:u(()=>[o("span",null,f(c(ea)(x.row.use_count??0)),1),p[0]||(p[0]=o("span",{class:"px-1"},"/",-1)),o("span",null,f(x.row.conditions.max_uses>0?x.row.conditions.max_uses:c(d)("Unlimited")),1)]),_:2,__:[0]},1032,["to"])]),_:1},8,["label"]),c(t).isColumnVisible("stackable")?(r(),E(_,{key:1,label:c(d)("Stackable"),width:120},{default:u(x=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:x.row.id,action:"edit"}}},{default:u(()=>[o("span",kve,f(x.row.stackable),1)]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),n(_,{label:c(d)("Status"),width:120},{default:u(x=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:x.row.id,action:"edit"}}},{default:u(()=>[n(la,{status:x.row.status},{default:u(()=>[R(f(i(x.row.end_date)?c(d)("Expired"):x.row.status),1)]),_:2},1032,["status"]),x.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:u(()=>[R(f(c(d)("Available On: %s",c(Ts)(x.row.start_date,!0))),1)]),default:u(()=>[n(J,{name:"InformationFill",class:"w-4 h-4 flex-none"})]),_:2},1024)):B("",!0)]),_:2},1032,["to"])]),_:1},8,["label"]),n(_,{label:c(d)("Expiry Date"),width:120},{default:u(x=>[n(ra,{class:"hover:no-underline",to:{name:"add_or_edit_coupon",params:{coupon_id:x.row.id,action:"edit"}}},{default:u(()=>[o("span",null,[isNaN(Date.parse(x.row.end_date))?(r(),h(P,{key:1},[R("n/a")],64)):(r(),E(Sa,{key:0,"date-time":x.row.end_date,"with-time":!0},null,8,["date-time"]))])]),_:2},1032,["to"])]),_:1},8,["label"]),c(t).isColumnVisible("actions")?(r(),E(_,{key:2,label:c(d)("Actions"),width:100,align:"right",fixed:"right"},{default:u(x=>[n(w,{trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:l,placement:"bottom-end"},{dropdown:u(()=>[n(k,null,{default:u(()=>[x.row.id?(r(),E(v,{key:0,class:"item-link"},{default:u(()=>[n(y,{to:{name:"add_or_edit_coupon",params:{coupon_id:x.row.id,action:"edit"}}},{default:u(()=>[n(J,{name:"Edit"}),R(" "+f(c(d)("Edit")),1)]),_:2},1032,["to"])]),_:2},1024)):B("",!0),n(v,{command:{action:"delete",coupon:x.row},class:"item-destructive"},{default:u(()=>[n(J,{name:"Delete"}),R(" "+f(c(d)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:u(()=>[o("span",Bve,[n(J,{name:"More"})])]),_:2},1024)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])]))]),_:1},8,["table"])])])]),_:1})}}},xve={class:"fct-add-edit-coupon-wrapper fct-layout-width"},Sve={class:"single-page-header"},$ve={class:"single-page-body"},Fve={class:"fct-add-edit-coupon"},Eve={class:"fct-add-edit-coupon-main"},Uve={class:"fct-add-edit-coupon-aside"},Ive={class:"fct-admin-sidebar"},Vve={__name:"SingleCouponLoader",setup(e){return(t,a)=>{const l=C("el-skeleton-item"),s=C("el-skeleton"),i=C("el-breadcrumb-item"),A=C("el-breadcrumb");return r(),h("div",xve,[o("div",Sve,[n(A,{"separator-icon":c(dl)},{default:u(()=>[n(i,null,{default:u(()=>[n(s,{animated:!0},{template:u(()=>[n(l,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),n(i,null,{default:u(()=>[n(s,{animated:!0},{template:u(()=>[n(l,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),n(i,null,{default:u(()=>[n(s,{animated:!0},{template:u(()=>[n(l,{variant:"p",class:"w-[60px] h-4"})]),_:1})]),_:1})]),_:1},8,["separator-icon"])]),o("div",$ve,[o("div",Fve,[o("div",Eve,[n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Basic Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(xe,null,{default:u(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:u(()=>[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($e,null,{default:u(()=>[n(Qe,{title:c(d)("Discount Value"),border_bottom:"",title_size:"small"},null,8,["title"]),n(xe,null,{default:u(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:u(()=>[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($e,null,{default:u(()=>[n(Qe,{title:c(d)("Schedule"),border_bottom:"",title_size:"small"},null,8,["title"]),n(xe,null,{default:u(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:u(()=>[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($e,null,{default:u(()=>[n(Qe,{title:c(d)("Maximum Discount Uses"),border_bottom:"",title_size:"small"},null,8,["title"]),n(xe,null,{default:u(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:u(()=>[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($e,null,{default:u(()=>[n(Qe,{title:c(d)("Additional Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(xe,null,{default:u(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:u(()=>[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",Uve,[o("div",Ive,[n($e,null,{default:u(()=>[n(Qe,{title:c(d)("Summary"),border_bottom:"",title_size:"small"},null,8,["title"]),n(xe,null,{default:u(()=>[n(s,{animated:!0,class:"flex flex-col gap-3"},{template:u(()=>[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})])])])])])}}};st.extend(hi);st.extend(bA);const Dve={name:"AddOrEditCoupon",components:{CardContainer:$e,CardHeader:Qe,CardBody:xe,LabelHint:Rt,ValidationError:Gt,CopyToClipboard:Va,DynamicTemplates:hn,SaveBar:pn,ProductVariationSelector:wA,SingleCouponLoader:Vve,Activity:mA},beforeRouteLeave(e,t,a){var l;(l=this.keyboardShortcuts)!=null&&l.unbind&&this.keyboardShortcuts.unbind("mod+s"),a()},props:{coupon_id:{type:[String,Number],required:!0}},data(){return{changes_made:0,creating:!1,updating:!1,keyboardShortcuts:null,coupon:{type:"fixed",status:"active",stackable:"no",show_on_checkout:"no",title:"",code:"",priority:0,amount:0,start_date:"",end_date:"",notes:"",conditions:{buy_quantity:1,get_quantity:1,excluded_categories:[],included_categories:[],excluded_products:[],included_products:[],min_purchase_amount:"",max_purchase_amount:"",min_amount_basis:"subtotal",allowed_user_ids:[],allowed_user_roles:[],apply_to_quantity:"no",apply_to_whole_cart:"yes",max_per_customer:"",max_discount_amount:"",max_uses:"",buy_products:[],get_products:[],is_recurring:"no"}},validationErrors:{},minQuantity:1,maxQuantity:100,minPurchaseAmount:0,maxPurchaseAmount:1e4,minDiscountAmount:0,minLimit:0,maxLimit:1e3,categories:[],usageError:!1,isEndDateEnabled:!1,fetchingCoupon:!1,isInitialLoading:!1,showDynamicTemplates:!1,showManageActivity:!1}},computed:{ArrowRight(){return dl},maxDiscountAmount(){return this.coupon.type==="percentage"?100:999999}},watch:{coupon:{handler(){this.handleChangesMade()},deep:!0}},mounted(){this.keyboardShortcuts=is(),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:d,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(){ce.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,ce.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=st.utc(t).tz(st.tz.guess()).format("YYYY-MM-DD HH:mm:ss")),a&&a!=="0000-00-00 00:00:00"&&(e.coupon.end_date=st.utc(a).tz(st.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}}),ce.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}}),ce.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})}}},Qve={class:"fct-add-edit-coupon-wrapper fct-layout-width"},Tve={class:"single-page-header"},Mve={class:"single-page-body"},Lve={class:"fct-add-edit-coupon"},Rve={class:"fct-add-edit-coupon-main"},Ove={class:"flex gap-2 items-center justify-between w-full mb-2.5"},Pve={class:"form-note"},Hve=["innerHTML"],Nve={key:1},Kve=["innerHTML"],Gve=["innerHTML"],zve=["innerHTML"],jve={class:"fct-add-edit-coupon-aside"},qve={class:"fct-admin-sidebar"},Yve={class:"fct-admin-sidebar-item"},Wve={key:0,class:"flex items-center gap-1"},Xve={class:"text-sm font-medium text-system-dark dark:text-gray-300"},Jve={key:1},Zve={class:"fct-admin-sidebar-item mt-5 hidden"},ege={class:"sidebar-title mb-3"},tge={class:"fct-bullet-lists"},age={class:"fct-admin-sidebar-item mt-5 hidden"},lge={class:"sidebar-title mb-3"},sge={class:"fct-bullet-lists"},nge={key:0};function oge(e,t,a,l,s,i){const A=C("SaveBar"),p=C("SingleCouponLoader"),m=C("el-breadcrumb-item"),_=C("el-breadcrumb"),g=C("CardHeader"),y=C("el-input"),v=C("ValidationError"),k=C("el-form-item"),w=C("el-col"),b=C("LabelHint"),x=C("el-row"),F=C("CardBody"),Q=C("CardContainer"),$=C("el-option"),S=C("el-select"),U=C("el-radio"),V=C("el-radio-group"),D=C("ProductVariationSelector"),I=C("el-checkbox"),L=C("el-form"),O=C("CopyToClipboard"),M=C("el-date-picker"),H=C("DynamicTemplates"),z=C("Activity");return r(),h("div",Qve,[n(A,{isActive:s.changes_made>0?"is-active":"",loading:a.coupon_id?s.updating:s.creating,onSave:t[0]||(t[0]=X=>a.coupon_id?i.updateCoupon():i.addCoupon()),onDiscard:i.reloadPage,"show-cmnd-icon":!0,saveButtonText:a.coupon_id?i.translate("Update"):i.translate("Create")},null,8,["isActive","loading","onDiscard","saveButtonText"]),s.fetchingCoupon?(r(),E(p,{key:0})):B("",!0),s.fetchingCoupon?B("",!0):(r(),h(P,{key:1},[o("div",Tve,[n(_,{"separator-icon":i.ArrowRight},{default:u(()=>[n(m,{to:{name:"coupons"}},{default:u(()=>[R(f(i.translate("Coupons")),1)]),_:1}),n(m,null,{default:u(()=>[R(f(a.coupon_id?i.translate("Edit Coupon"):i.translate("Add Coupon")),1)]),_:1}),a.coupon_id?(r(),E(m,{key:0},{default:u(()=>[R(f(s.coupon.title),1)]),_:1})):B("",!0)]),_:1},8,["separator-icon"])]),o("div",Mve,[o("div",Lve,[o("div",Rve,[n(L,{model:s.coupon,"label-position":"top","require-asterisk-position":"right"},{default:u(()=>[n(Q,null,{default:u(()=>[n(g,{title:i.translate("Basic Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,{class:"pb-1.5"},{default:u(()=>[n(x,{gutter:20},{default:u(()=>[n(w,{lg:24},{default:u(()=>[n(k,{label:i.translate("Title"),required:""},{default:u(()=>{var X,G;return[n(y,{modelValue:s.coupon.title,"onUpdate:modelValue":t[1]||(t[1]=Y=>s.coupon.title=Y),placeholder:i.translate("Enter title"),class:ue((X=s.validationErrors)!=null&&X.hasOwnProperty("title")?"is-error":""),maxlength:"50",id:"title"},null,8,["modelValue","placeholder","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("title")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"title"},null,8,["validation-errors"])):B("",!0)]}),_:1},8,["label"])]),_:1}),n(w,{lg:12},{default:u(()=>[n(k,null,{default:u(()=>{var X,G;return[o("div",Ove,[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]=(...Y)=>i.generateRandomCouponCode&&i.generateRandomCouponCode(...Y))},f(i.translate("Generate Random Code")),1)]),n(y,{modelValue:s.coupon.code,"onUpdate:modelValue":t[3]||(t[3]=Y=>s.coupon.code=Y),placeholder:i.translate("Eg. COUPON10"),class:ue((X=s.validationErrors)!=null&&X.hasOwnProperty("code")?"is-error":""),maxlength:"20"},null,8,["modelValue","placeholder","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("code")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"code"},null,8,["validation-errors"])):B("",!0),o("div",Pve,[o("p",null,f(i.translate("Customers must enter this code at checkout.")),1)])]}),_:1})]),_:1}),n(w,{lg:12},{default:u(()=>[n(k,null,{label:u(()=>[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:u(()=>{var X,G;return[n(y,{modelValue:s.coupon.priority,"onUpdate:modelValue":t[4]||(t[4]=Y=>s.coupon.priority=Y),type:"number",placeholder:i.translate("Enter priority"),class:ue((X=s.validationErrors)!=null&&X.hasOwnProperty("priority")?"is-error":""),min:"0",max:"100",onInput:t[5]||(t[5]=Y=>{i.onChangeCouponInput("priority",Y)}),onKeypress:i.preventInvalidChars},null,8,["modelValue","placeholder","class","onKeypress"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("priority")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"priority"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),n(Q,null,{default:u(()=>[n(g,{title:i.translate("Discount Details"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,{class:"pb-1.5"},{default:u(()=>[n(x,{gutter:20},{default:u(()=>[n(w,{lg:8},{default:u(()=>[n(k,{label:i.translate("Type"),required:""},{default:u(()=>{var X;return[n(S,{modelValue:s.coupon.type,"onUpdate:modelValue":t[6]||(t[6]=G=>s.coupon.type=G),placeholder:i.translate("Select coupon type"),class:ue((X=s.validationErrors)!=null&&X.hasOwnProperty("type")?"is-error":""),"default-first-option":""},{default:u(()=>[n($,{label:i.translate("Fixed"),value:"fixed"},null,8,["label"]),n($,{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(w,{lg:8},{default:u(()=>[n(k,{label:s.coupon.type==="percentage"?i.translate("Discount Percentage (%)"):i.translate("Discount Amount"),required:""},{default:u(()=>{var X;return[n(y,{modelValue:s.coupon.amount,"onUpdate:modelValue":t[7]||(t[7]=G=>s.coupon.amount=G),type:"number",placeholder:"0.00",min:s.minDiscountAmount,max:i.maxDiscountAmount,step:"0.01",onInput:t[8]||(t[8]=G=>{i.onChangeCouponInput("amount",G)}),onKeypress:t[9]||(t[9]=G=>i.preventInvalidChars(G,!0))},{prefix:u(()=>[s.coupon.type==="fixed"?(r(),h("span",{key:0,innerHTML:e.appVars.shop.currency_sign},null,8,Hve)):(r(),h("span",Nve,"%"))]),_:1},8,["modelValue","min","max"]),(X=s.validationErrors)!=null&&X.hasOwnProperty("amount")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"amount"},null,8,["validation-errors"])):B("",!0)]}),_:1},8,["label"])]),_:1}),s.coupon.type==="percentage"?(r(),E(w,{key:0,lg:8},{default:u(()=>[n(k,{label:i.translate("Max Discount Amount")},{default:u(()=>{var X;return[n(y,{modelValue:s.coupon.conditions.max_discount_amount,"onUpdate:modelValue":t[10]||(t[10]=G=>s.coupon.conditions.max_discount_amount=G),type:"number",placeholder:i.translate("leave empty or 0 for no max limit"),class:ue((X=s.validationErrors)!=null&&X.hasOwnProperty("max_discount_amount")?"is-error":"")},{prefix:u(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,Kve)]),_:1},8,["modelValue","placeholder","class"]),n(v,{"validation-errors":s.validationErrors,"field-key":"max_discount_amount"},null,8,["validation-errors"])]}),_:1},8,["label"])]),_:1})):B("",!0)],64)):B("",!0)]),_:1})]),_:1})]),_:1}),n(Q,null,{default:u(()=>[n(g,{title:i.translate("Usage Restrictions"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,{class:"pb-1.5"},{default:u(()=>[n(x,{gutter:20},{default:u(()=>[n(w,{lg:12},{default:u(()=>[n(k,null,{label:u(()=>[n(b,{title:i.translate("Min Spend Amount"),content:i.translate("Minimum spend (subtotal) allowed to use the coupon.")},null,8,["title","content"])]),default:u(()=>{var X,G;return[n(y,{modelValue:s.coupon.conditions.min_purchase_amount,"onUpdate:modelValue":t[11]||(t[11]=Y=>s.coupon.conditions.min_purchase_amount=Y),type:"number",placeholder:"0.00",class:ue((X=s.validationErrors)!=null&&X.hasOwnProperty("min_purchase_amount")?"is-error":"")},{prefix:u(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,Gve)]),_:1},8,["modelValue","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("min_purchase_amount")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"min_purchase_amount"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(w,{lg:12},{default:u(()=>[n(k,null,{label:u(()=>[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:u(()=>{var X,G;return[n(y,{modelValue:s.coupon.conditions.max_purchase_amount,"onUpdate:modelValue":t[12]||(t[12]=Y=>s.coupon.conditions.max_purchase_amount=Y),type:"number",placeholder:i.translate("leave empty or 0 for no max limit"),class:ue((X=s.validationErrors)!=null&&X.hasOwnProperty("max_purchase_amount")?"is-error":"")},{prefix:u(()=>[o("span",{innerHTML:e.appVars.shop.currency_sign},null,8,zve)]),_:1},8,["modelValue","placeholder","class"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("max_purchase_amount")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"max_purchase_amount"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(w,{lg:24},{default:u(()=>[n(k,null,{label:u(()=>[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:u(()=>[n(V,{modelValue:s.coupon.conditions.min_amount_basis,"onUpdate:modelValue":t[13]||(t[13]=X=>s.coupon.conditions.min_amount_basis=X)},{default:u(()=>[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(w,{md:12},{default:u(()=>[n(k,{label:i.translate("Include Categories")},{default:u(()=>[n(S,{modelValue:s.coupon.conditions.included_categories,"onUpdate:modelValue":t[14]||(t[14]=X=>s.coupon.conditions.included_categories=X),multiple:"",placeholder:i.translate("Any Category"),filterable:"",remote:"","reserve-keyword":!1},{default:u(()=>[(r(!0),h(P,null,le(s.categories,X=>(r(),E($,{key:X.value,label:X.label,value:X.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),n(w,{md:12},{default:u(()=>[n(k,{label:i.translate("Exclude Categories")},{default:u(()=>[n(S,{modelValue:s.coupon.conditions.excluded_categories,"onUpdate:modelValue":t[15]||(t[15]=X=>s.coupon.conditions.excluded_categories=X),multiple:"",placeholder:i.translate("No Categories"),filterable:"",remote:"","reserve-keyword":!1},{default:u(()=>[(r(!0),h(P,null,le(s.categories,X=>(r(),E($,{key:X.value,label:X.label,value:X.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1}),n(w,{md:24},{default:u(()=>[n(k,{label:i.translate("Include Products")},{default:u(()=>[n(D,{modelValue:s.coupon.conditions.included_products,"onUpdate:modelValue":t[16]||(t[16]=X=>s.coupon.conditions.included_products=X)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1}),n(w,{md:24},{default:u(()=>[n(k,{label:i.translate("Excluded Products")},{default:u(()=>[n(D,{modelValue:s.coupon.conditions.excluded_products,"onUpdate:modelValue":t[17]||(t[17]=X=>s.coupon.conditions.excluded_products=X)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1}),n(w,{md:24},{default:u(()=>[n(k,null,{label:u(()=>[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:u(()=>{var X;return[n(y,{autocomplete:"off",modelValue:s.coupon.conditions.email_restrictions,"onUpdate:modelValue":t[18]||(t[18]=G=>s.coupon.conditions.email_restrictions=G),type:"text",placeholder:i.translate("email1@domain.com, *@special.com, ... or regex pattern")},null,8,["modelValue","placeholder"]),(X=s.validationErrors)!=null&&X.hasOwnProperty("email_restrictions")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"email_restrictions"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(w,{md:24},{default:u(()=>{var X;return[n(k,null,{label:u(()=>[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:u(()=>[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}),(X=s.validationErrors)!=null&&X.hasOwnProperty("is_recurring")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"is_recurring"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1})]),_:1})]),_:1}),n(Q,null,{default:u(()=>[n(g,{title:i.translate("Maximum Discount Uses"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,{class:"pb-1.5"},{default:u(()=>[n(x,{gutter:20},{default:u(()=>[n(w,{lg:12},{default:u(()=>[n(k,null,{label:u(()=>[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:u(()=>{var X,G;return[n(y,{modelValue:s.coupon.conditions.max_uses,"onUpdate:modelValue":t[20]||(t[20]=Y=>s.coupon.conditions.max_uses=Y),type:"number",placeholder:i.translate("Total limit"),class:ue((X=s.validationErrors)!=null&&X.hasOwnProperty("max_uses")?"is-error":s.usageError),min:s.minLimit,max:s.maxLimit,onInput:t[21]||(t[21]=Y=>{i.onChangeCouponInput("max_uses",Y)}),onKeypress:i.preventInvalidChars},null,8,["modelValue","placeholder","class","min","max","onKeypress"]),(G=s.validationErrors)!=null&&G.hasOwnProperty("max_uses")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"max_uses"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1}),n(w,{lg:12},{default:u(()=>[n(k,null,{label:u(()=>[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:u(()=>[n(y,{modelValue:s.coupon.conditions.max_per_customer,"onUpdate:modelValue":t[22]||(t[22]=X=>s.coupon.conditions.max_per_customer=X),type:"number",placeholder:i.translate("Max limit per logged in user"),class:ue(s.validationErrors.hasOwnProperty("max_per_customer")?"is-error":""),min:s.minLimit,max:s.maxLimit,onInput:t[23]||(t[23]=X=>{i.onChangeCouponInput("max_per_customer",X)}),onKeypress:i.preventInvalidChars},null,8,["modelValue","placeholder","class","min","max","onKeypress"]),n(v,{"validation-errors":s.validationErrors,"field-key":"max_per_customer"},null,8,["validation-errors"])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),n(Q,null,{default:u(()=>[n(g,{title:i.translate("Additional Information"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,{class:"pb-1.5"},{default:u(()=>[n(x,{gutter:20},{default:u(()=>[n(w,{lg:24},{default:u(()=>[n(k,{label:i.translate("Status")},{default:u(()=>[n(V,{modelValue:s.coupon.status,"onUpdate:modelValue":t[24]||(t[24]=X=>s.coupon.status=X)},{default:u(()=>[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(w,{lg:24},{default:u(()=>[n(k,{label:i.translate("Internal Notes")},{default:u(()=>{var X;return[n(y,{modelValue:s.coupon.notes,"onUpdate:modelValue":t[25]||(t[25]=G=>s.coupon.notes=G),type:"textarea",placeholder:i.translate("Enter note"),class:ue((X=s.validationErrors)!=null&&X.hasOwnProperty("notes")?"is-error":"")},null,8,["modelValue","placeholder","class"]),n(v,{"validation-errors":s.validationErrors,"field-key":"notes"},null,8,["validation-errors"])]}),_:1},8,["label"])]),_:1}),n(w,{lg:24},{default:u(()=>{var X;return[n(k,null,{label:u(()=>[n(b,{title:i.translate("Stackable"),content:i.translate("Yes means the coupon can be applied with other coupons")},null,8,["title","content"])]),default:u(()=>[n(V,{modelValue:s.coupon.stackable,"onUpdate:modelValue":t[26]||(t[26]=G=>s.coupon.stackable=G)},{default:u(()=>[n(U,{value:"yes"},{default:u(()=>[R(f(i.translate("Yes")),1)]),_:1}),n(U,{value:"no"},{default:u(()=>[R(f(i.translate("No")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1}),(X=s.validationErrors)!=null&&X.hasOwnProperty("stackable")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"stackable"},null,8,["validation-errors"])):B("",!0)]}),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])]),o("div",jve,[o("div",qve,[n(Q,null,{default:u(()=>[n(g,{title:i.translate("Summary"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,null,{default:u(()=>[o("div",Yve,[s.coupon.code?(r(),h("div",Wve,[o("span",Xve,f(i.translate("Coupon code"))+": "+f(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",Jve,f(i.translate("No discount code yet")),1))]),o("div",Zve,[o("h4",ege,f(i.translate("Type & Method")),1),o("ul",tge,[o("li",null,[o("span",null,f(i.translate("Amount off Products")),1)]),o("li",null,[o("span",null,f(i.translate("Code")),1)])])]),o("div",age,[o("h4",lge,f(i.translate("Details")),1),o("ul",sge,[o("li",null,[o("span",null,f(i.translate("For Online Store")),1)]),o("li",null,[o("span",null,f(i.translate("No Min Purchase Requirement")),1)]),o("li",null,[o("span",null,f(i.translate("All Customers")),1)])])])]),_:1})]),_:1}),n(Q,null,{default:u(()=>[n(g,{title:i.translate("Schedule"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,{class:"pb-1.5"},{default:u(()=>[n(L,{"label-position":"top"},{default:u(()=>[n(x,{gutter:20},{default:u(()=>[n(w,{lg:24},{default:u(()=>[n(k,{label:i.translate("Start Date & Time")},{default:u(()=>[n(M,{modelValue:s.coupon.start_date,"onUpdate:modelValue":t[27]||(t[27]=X=>s.coupon.start_date=X),type:"datetime","value-format":"YYYY-MM-DDTHH:mm:ssZ",placeholder:i.translate("Start date & time"),onChange:i.setDefaultStatus,"disabled-date":i.disabledStartDate},null,8,["modelValue","placeholder","onChange","disabled-date"])]),_:1},8,["label"])]),_:1}),n(w,{lg:24},{default:u(()=>[n(k,null,{default:u(()=>[n(I,{modelValue:s.isEndDateEnabled,"onUpdate:modelValue":t[28]||(t[28]=X=>s.isEndDateEnabled=X),label:i.translate("Set end date & time"),onChange:t[29]||(t[29]=X=>{X||(s.coupon.end_date=null)})},null,8,["modelValue","label"])]),_:1})]),_:1}),s.isEndDateEnabled?(r(),E(w,{key:0,lg:24},{default:u(()=>[n(k,{label:i.translate("End Date & Time")},{default:u(()=>[n(M,{modelValue:s.coupon.end_date,"onUpdate:modelValue":t[30]||(t[30]=X=>s.coupon.end_date=X),type:"datetime","value-format":"YYYY-MM-DDTHH:mm:ssZ",placeholder:i.translate("End date & time"),onChange:i.setDefaultStatus,"disabled-date":i.disabledEndDate},null,8,["modelValue","placeholder","onChange","disabled-date"]),s.validationErrors.hasOwnProperty("end_date")?(r(),E(v,{key:0,"validation-errors":s.validationErrors,"field-key":"end_date"},null,8,["validation-errors"])):B("",!0)]),_:1},8,["label"])]),_:1})):B("",!0)]),_:1})]),_:1})]),_:1})]),_:1})]),s.showDynamicTemplates?(r(),h("div",nge,[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"])])):B("",!0),n(Q,null,{default:u(()=>[n(g,{title:i.translate("Activity"),border_bottom:"",title_size:"small"},null,8,["title"]),n(F,null,{default:u(()=>[n(z,{onReload:i.fetchCoupon,activities:s.coupon.activities||[],showManageActivity:s.showManageActivity},null,8,["onReload","activities","showManageActivity"])]),_:1})]),_:1})])])])],64))])}const ige=nt(Dve,[["render",oge]]),rge={class:"fct-reviews-route-wrap"},dge=Object.assign({name:"ReviewsRoute"},{__name:"ReviewsRoute",setup(e){const t=Na();return(a,l)=>{const s=C("router-view");return r(),h("div",rge,[(r(),E(s,{key:c(t).query.post_id||"default"}))])}}});class uge extends ws{constructor(t={}){super(t),this.data.postId=t.postId||null}buildQueryParams(){const t=super.buildQueryParams();return this.data.postId&&(t.post_id=this.data.postId),t}getPostId(){return this.data.postId}shouldDisableFilters(){return!!this.data.postId}isUsingSimpleFilter(){return super.isUsingSimpleFilter()&&!this.shouldDisableFilters()}isAdvanceFilterEnabled(){return super.isAdvanceFilterEnabled()&&!this.shouldDisableFilters()}setupInitialData(){super.setupInitialData(),this.shouldDisableFilters()&&(this.data.filterType="simple",this.data.searching=!1,this.data.search="",this.data.advanceFilters=[[]],this.data.activeSavedViewId&&(this.data.activeSavedViewId=null,this.data.savedViewQueryParams=null,this.data.selectedView=this.getDefaultView(),Tt.set(this.getTabStorageName(),this.getDefaultView()),Ms.pushToVueUrl(null,{active_view:this.getDefaultView()})))}getSavedViews(){return this.shouldDisableFilters()?[]:super.getSavedViews()}applySavedView(t){this.shouldDisableFilters()||super.applySavedView(t)}getTabs(){return{all:d("All"),approved:d("Approved"),pending:d("Pending"),spam:d("Spam"),trash:d("Trash")}}getToggleableColumns(){return[{label:d("Reviewer"),value:"reviewer"},{label:d("Rating"),value:"rating"},{label:d("Content"),value:"content"},{label:d("Status"),value:"status"},{label:d("Date"),value:"date"},{label:d("Actions"),value:"actions"}]}getSortableColumns(){return[{label:d("ID"),value:"id"},{label:d("Rating"),value:"rating"},{label:d("Reviewer"),value:"reviewer_name"},{label:d("Created At"),value:"created_at"}]}getSearchHint(){return d("Search by title, content, reviewer name, email or product name.")}getFetchUrl(){return"reviews"}parseResponse(t){return t.reviews}getTableName(){return"review_table"}with(){return["product","customer"]}}function cge(e){return uge.init(e)}const Age={class:"table-cell"},pge={class:"table-cell"},fge={class:"table-cell"},mge={class:"table-cell"},hge={class:"table-cell"},_ge={class:"table-cell"},vge={class:"table-cell"},gge={__name:"ReviewsLoader",props:{nextPageCount:{type:Number,default:0},reviewTable:{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"),A=C("el-skeleton"),p=C("el-table-column"),m=C("el-table");return r(),E(m,{data:c(a),class:"w-full compact-table"},{default:u(()=>[n(p,{label:c(d)("ID"),width:"300"},{default:u(()=>[o("div",Age,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"]),e.reviewTable.isColumnVisible("reviewer")?(r(),E(p,{key:0,label:c(d)("Reviewer"),width:220},{default:u(()=>[o("div",pge,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.reviewTable.isColumnVisible("rating")?(r(),E(p,{key:1,label:c(d)("Rating"),width:120},{default:u(()=>[o("div",fge,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.reviewTable.isColumnVisible("content")?(r(),E(p,{key:2,label:c(d)("Review"),"min-width":200},{default:u(()=>[o("div",mge,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.reviewTable.isColumnVisible("status")?(r(),E(p,{key:3,label:c(d)("Status"),width:120},{default:u(()=>[o("div",hge,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.reviewTable.isColumnVisible("date")?(r(),E(p,{key:4,label:c(d)("Date"),width:140},{default:u(()=>[o("div",_ge,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0),e.reviewTable.isColumnVisible("actions")?(r(),E(p,{key:5,label:c(d)("Actions"),width:90},{default:u(()=>[o("div",vge,[n(A,{animated:""},{template:u(()=>[n(i,{varient:"p"})]),_:1})])]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"])}}},yge={class:"fct-table-mobile-wrap fct-reviews-table-mobile-wrap"},bge={class:"fct-table-mobile-header"},wge={class:"fct-table-date-col"},Cge=["title"],kge={class:"fct-table-mobile-body"},Bge={key:0,class:"mb-1 text-sm font-medium"},xge={key:1,class:"mb-1 text-xs text-gray-500"},Sge={key:2,class:"mb-1"},$ge={key:3,class:"text-sm text-gray-600 truncate"},Fge={key:0,class:"font-medium"},Ege={class:"fct-table-mobile-footer"},Uge={class:"fct-table-mobile-footer-row"},Ige={key:0,class:"fct-table-status-col"},Vge={class:"title"},Dge={class:"value text-sm"},Qge={key:1,class:"fct-table-status-col"},Tge={class:"title"},Mge={key:2,class:"fct-table-actions-col"},Lge={class:"title"},Rge={__name:"ReviewsTableMobile",props:{table:{type:Object}},setup(e){return(t,a)=>{const l=C("router-link");return r(),h("div",yge,[(r(!0),h(P,null,le(e.table.getTableData(),s=>(r(),h("div",{key:s.id,class:"fct-table-mobile-row"},[o("div",bge,[o("div",wge,[o("div",{title:c(d)("Review ID: %s",s.id),class:"invoice-no"}," #"+f(s.id),9,Cge),e.table.isColumnVisible("date")?(r(),h(P,{key:0},[a[0]||(a[0]=o("span",{class:"bullet"},"•",-1)),n(Sa,{class:"date","date-time":s.created_at,"with-time":!0},null,8,["date-time"])],64)):B("",!0)])]),o("div",kge,[s.product?(r(),h("div",Bge,f(s.product.post_title),1)):B("",!0),s.item_label?(r(),h("div",xge,f(s.item_label),1)):B("",!0),e.table.isColumnVisible("rating")?(r(),h("div",Sge,[n(Qi,{rating:s.rating,size:"small"},null,8,["rating"])])):B("",!0),e.table.isColumnVisible("content")?(r(),h("div",$ge,[s.title?(r(),h("span",Fge,f(s.title)+" — ",1)):B("",!0),R(" "+f(s.content),1)])):B("",!0)]),o("div",Ege,[o("div",Uge,[e.table.isColumnVisible("reviewer")?(r(),h("div",Ige,[o("div",Vge,f(c(d)("Reviewer")),1),o("div",Dge,f(s.reviewer_name),1)])):B("",!0),e.table.isColumnVisible("status")?(r(),h("div",Qge,[o("div",Tge,f(c(d)("Status")),1),(r(),E(la,{status:s.status,size:"small",key:s.id},null,8,["status"]))])):B("",!0),e.table.isColumnVisible("actions")?(r(),h("div",Mge,[o("div",Lge,f(c(d)("Actions")),1),n(l,{class:"value text-primary text-sm",to:{name:"view_review",params:{review_id:s.id}},"aria-label":c(d)("View review #%1$s",s.id)},{default:u(()=>[R(f(c(d)("View")),1)]),_:2},1032,["to","aria-label"])])):B("",!0)])])]))),128))])}}},Oge={},Pge={class:"fct-table-mobile-wrap"};function Hge(e,t){const a=C("el-skeleton");return r(),h("div",Pge,[(r(),h(P,null,le(5,l=>o("div",{key:l,class:"fct-table-mobile-row"},[n(a,{animated:"",rows:3})])),64))])}const Nge=nt(Oge,[["render",Hge]]),Kge=["aria-label"],Gge=["aria-checked","aria-label","tabindex","disabled","onClick","onMouseenter","onFocus"],zge={__name:"StarRatingInput",props:{modelValue:{type:Number,default:0},size:{type:String,default:"medium",validator:e=>["small","medium","large"].includes(e)},label:{type:String,default:()=>d("Rating")},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(e,{emit:t}){const a=e,l=t,s=T(0),i=T([]),A=w=>{a.disabled||l("update:modelValue",w)},p=w=>{const b=w===a.modelValue;A(b?0:w),b&&(s.value=0)},m=w=>{if(a.disabled)return;const b=Math.min(5,Math.max(1,(a.modelValue||0)+w));A(b),s.value=b,Fe(()=>{var x;return(x=i.value[b-1])==null?void 0:x.focus()})},_=w=>d("Rate %1$s out of 5 stars",w),g={1:d("Poor"),2:d("Average"),3:d("Good"),4:d("Very Good"),5:d("Excellent")},y={1:"danger",2:"warning",3:"info",4:"success",5:"success"},v=w=>g[w]||"",k=w=>y[w]||"none";return(w,b)=>(r(),h("div",{class:ue(["fct-star-rating-input",`fct-star-rating-input-${e.size}`])},[o("div",{class:"fct-star-rating-input__stars",role:"radiogroup","aria-label":e.label},[(r(),h(P,null,le(5,x=>o("button",{key:x,ref_for:!0,ref:F=>i.value[x-1]=F,type:"button",role:"radio",class:ue(["fct-star-rating-input__star",{"is-filled":x<=(s.value||e.modelValue),"is-selected":x<=e.modelValue}]),"aria-checked":e.modelValue===x,"aria-label":_(x),tabindex:e.modelValue===x||!e.modelValue&&x===1?0:-1,disabled:e.disabled,onClick:F=>p(x),onMouseenter:F=>s.value=x,onMouseleave:b[0]||(b[0]=F=>s.value=0),onFocus:F=>s.value=x,onBlur:b[1]||(b[1]=F=>s.value=0),onKeydown:[b[2]||(b[2]=da(Ge(F=>m(-1),["prevent"]),["left"])),b[3]||(b[3]=da(Ge(F=>m(1),["prevent"]),["right"])),b[4]||(b[4]=da(Ge(F=>m(1),["prevent"]),["up"])),b[5]||(b[5]=da(Ge(F=>m(-1),["prevent"]),["down"]))]},[n(So,{class:"fct-star-rating-input__svg"})],42,Gge)),64))],8,Kge),s.value||e.modelValue?(r(),h("span",{key:0,class:ue(["fct-star-rating-input__badge",`is-${k(s.value||e.modelValue)}`]),"aria-hidden":"true"},f(v(s.value||e.modelValue)),3)):B("",!0)],2))}},jge=["onKeydown"],qge={key:0,class:"fct-add-review-field"},Yge={class:"fct-add-review-label",for:"fct_add_review_product"},Wge={key:1,class:"fct-add-review-field"},Xge={class:"fct-add-review-label",for:"fct_add_review_variation"},Jge={key:2,class:"fct-add-review-field"},Zge={class:"fct-add-review-label"},e1e={key:0,class:"fct-add-review-required"},t1e={class:"fct-add-review-field"},a1e={class:"fct-add-review-label",for:"fct_add_review_title"},l1e={class:"fct-add-review-field"},s1e={class:"fct-add-review-label",for:"fct_add_review_content"},n1e={class:"fct-add-review-row"},o1e={class:"fct-add-review-field"},i1e={class:"fct-add-review-label",for:"fct_add_review_name"},r1e={class:"fct-add-review-field"},d1e={class:"fct-add-review-label",for:"fct_add_review_email"},u1e={class:"fct-add-review-field"},c1e={class:"fct-add-review-label",for:"fct_add_review_status"},A1e={key:0,class:"fct-add-review-field fct-add-review-field-inline"},p1e={class:"fct-add-review-switch"},f1e={class:"fct-add-review-label"},m1e={key:3,class:"fct-add-review-field"},h1e={class:"fct-add-review-label"},_1e={key:0,class:"fct-add-review-media"},v1e=["src","alt"],g1e=["aria-label","onClick"],y1e={key:0,class:"fct-add-review-media-item is-add"},b1e=["aria-label"],w1e={class:"fct-add-review-hint"},C1e=["accept"],k1e={key:1,class:"fct-add-review-locked"},B1e={class:"fct-add-review-hint"},x1e=["href"],S1e={__name:"AddReviewModal",props:{modelValue:{type:Boolean,default:!1},productId:{type:Number,default:null}},emits:["update:modelValue","created","update:saving"],setup(e,{emit:t}){const a=e,l=t,s=K({get:()=>a.modelValue,set:Ee=>l("update:modelValue",Ee)}),i=je.get("modules_settings.reviews")||{},A=i.enable_star_rating==="yes",p=A&&i.star_rating_required==="yes",m=i.show_verified_badge===void 0||i.show_verified_badge==="yes",_=i.enable_photo_reviews==="yes",g=()=>({post_id:a.productId||null,item_id:null,rating:0,title:"",content:"",reviewer_name:"",reviewer_email:"",status:"approved",is_verified:!1,media:[]}),y=T(g()),v=T(!1),k=T(null),w=T({}),b=Ee=>Object.prototype.hasOwnProperty.call(w.value,Ee),x=Ee=>{Object.prototype.hasOwnProperty.call(w.value,Ee)&&delete w.value[Ee]},F=()=>{const Ee=k.value;if(!Ee)return;const pe=Ee.querySelector("#fct_add_review_product"),Ve=(pe?pe.matches("input")?pe:pe.querySelector("input"):null)||Ee.querySelector('.fct-star-rating-input__star[tabindex="0"]')||Ee.querySelector("#fct_add_review_title");Ve&&Ve.focus()};ke(v,Ee=>l("update:saving",Ee));const Q=Ee=>String(Ee.id),$=(Ee,pe)=>`${Ee.id}:${pe.id}`,S=T([]),U=T(!1),V=T(null),D=je.get("review_media")||null,I=!!(D&&D.enabled&&_),L=Number(D==null?void 0:D.max_photos)||0,O=Number(D==null?void 0:D.max_size_mb)||0,M=String((D==null?void 0:D.accept)||"").split(",").map(Ee=>Ee.trim()).filter(Boolean),H=Lo("review_attachments","reviews"),z=!!je.get("app_config.isProActive"),X=z?d("Update FluentCart Pro to attach photos to a review"):d("Reviews with photos are available in FluentCart Pro"),G=()=>{x("post_id"),x("item_id")},Y=Ee=>{const[pe,ye]=String(Ee).split(":");y.value.post_id=Number(pe),y.value.item_id=ye?Number(ye):null},Z=T([]);let de=null,j=0,ge=null;const ie=()=>{ge&&(ge.abort(),ge=null)},W=(Ee,pe)=>{const ye=typeof AbortController<"u"?new AbortController:null;return ge=ye,ce.get("advance_filter/get-filter-options",{remote_data_key:"review_products",limit:20,...Ee},null,ye?{signal:ye.signal}:{}).then(Ve=>{var Le;return pe!==j?null:(((Le=Ve.options)==null?void 0:Le.data)||[]).map(At=>({id:Number(At.id),title:At.title,variations:(At.variations||[]).map(mt=>({id:Number(mt.id),title:mt.title}))}))})},N=Ee=>{clearTimeout(de);const pe=++j;if(ie(),!Ee){S.value=[],U.value=!1;return}U.value=!0,de=setTimeout(()=>{W({search:Ee},pe).then(ye=>{ye!==null&&(S.value=ye)}).catch(ye=>{var Ve;pe===j&&(S.value=[],q.error(((Ve=ye==null?void 0:ye.data)==null?void 0:Ve.message)||d("Could not load products. Please try again.")))}).finally(()=>{pe===j&&(ge=null,U.value=!1)})},400)},ae=Ee=>{const pe=++j;ie(),W({include_ids:[Ee],limit:1},pe).then(ye=>{if(ye===null)return;const Ve=ye.find(Le=>Le.id===Number(Ee));Z.value=Ve?Ve.variations:[]}).catch(ye=>{var Ve;pe===j&&(Z.value=[],q.error(((Ve=ye==null?void 0:ye.data)==null?void 0:Ve.message)||d("Could not load this product's variations.")))})};ke(()=>a.productId,Ee=>{y.value.post_id=Ee||null,y.value.item_id=null,V.value=null,Z.value=[],Ee&&ae(Ee)},{immediate:!0}),Ya(()=>{clearTimeout(de),ie(),y.value.media.forEach(Be)});const ee=T(null);let Ae=0;const re=K(()=>y.value.media.length>=L?d("Photo limit reached (%1$s)",L):d("Up to %1$s photos, %2$s MB each",L,O)),Ue=()=>{var Ee;return(Ee=ee.value)==null?void 0:Ee.click()},we=Ee=>{const pe=Array.from(Ee.target.files||[]);if(Ee.target.value="",!pe.length)return;const ye=L-y.value.media.length;ye<=0||(pe.length>ye&&q.info(d("%1$s photo(s) were skipped — the limit is %2$s per review",pe.length-ye,L)),pe.slice(0,ye).forEach(Ve=>{if(O&&Ve.size>O*1024*1024){q.error(d("%1$s is too large",Ve.name));return}if(M.length&&Ve.type&&!M.includes(Ve.type)){q.error(d("%1$s is not an allowed file type",Ve.name));return}y.value.media.push({key:`${Ve.name}-${Ve.size}-${Ve.lastModified}-${Ae++}`,name:Ve.name,url:URL.createObjectURL(Ve),file:Ve})}))},Be=Ee=>{Ee!=null&&Ee.url&&URL.revokeObjectURL(Ee.url)},ve=Ee=>{const pe=y.value.media.find(ye=>ye.key===Ee);Be(pe),y.value.media=y.value.media.filter(ye=>ye.key!==Ee)},Ce=()=>{y.value.media.forEach(Be),y.value=g(),S.value=[],V.value=null,w.value={}},Oe=()=>{if(v.value)return;w.value={},v.value=!0;const Ee=new FormData;Ee.append("post_id",y.value.post_id),y.value.item_id&&Ee.append("item_id",y.value.item_id),Ee.append("rating",y.value.rating),Ee.append("title",y.value.title),Ee.append("content",y.value.content),Ee.append("reviewer_name",y.value.reviewer_name),Ee.append("reviewer_email",y.value.reviewer_email),Ee.append("status",y.value.status),Ee.append("is_verified",y.value.is_verified?1:0),y.value.media.forEach(pe=>Ee.append("files[]",pe.file,pe.name)),ce.upload("reviews",Ee).then(pe=>{var ye;(ye=pe.media_rejected)!=null&&ye.length?q.error(pe.message,d("Photos not saved"),8e3):q.success(pe.message),l("created",pe.review),s.value=!1}).catch(pe=>{const ye=pe&&typeof pe=="object"&&!pe.message&&Object.values(pe).some(Ve=>Ve&&typeof Ve=="object");w.value=ye?pe:{general:{server:(pe==null?void 0:pe.message)||d("Could not add the review. Please try again.")}}}).finally(()=>{v.value=!1})};return(Ee,pe)=>{const ye=C("el-option"),Ve=C("el-option-group"),Le=C("el-select"),At=C("el-input"),mt=C("el-switch"),Mt=C("el-button"),Dt=C("el-dialog");return r(),E(Dt,{modelValue:s.value,"onUpdate:modelValue":pe[16]||(pe[16]=Xe=>s.value=Xe),class:"fct-add-review-modal",title:c(d)("Add Review"),width:"560px","align-center":"","append-to-body":"","destroy-on-close":"","close-on-click-modal":!v.value,"close-on-press-escape":!v.value,onOpened:F,onClosed:Ce},{footer:u(()=>[n(Mt,{disabled:v.value,onClick:pe[15]||(pe[15]=Xe=>s.value=!1)},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1},8,["disabled"]),n(Mt,{type:"primary",loading:v.value,disabled:v.value,onClick:Oe},{default:u(()=>[R(f(c(d)("Add Review")),1)]),_:1},8,["loading","disabled"])]),default:u(()=>[o("div",{ref_key:"formRef",ref:k,class:"fct-add-review-form",onKeydown:[da(Ge(Oe,["ctrl","prevent"]),["enter"]),da(Ge(Oe,["meta","prevent"]),["enter"])]},[n(Gt,{"validation-errors":w.value,"field-key":"general"},null,8,["validation-errors"]),e.productId?Z.value.length?(r(),h("div",Wge,[o("label",Xge,f(c(d)("Variation")),1),n(Le,{id:"fct_add_review_variation",modelValue:y.value.item_id,"onUpdate:modelValue":pe[1]||(pe[1]=Xe=>y.value.item_id=Xe),class:ue(["w-full",b("item_id")?"is-error":""]),"aria-invalid":b("item_id")?"true":void 0,clearable:"",filterable:"",placeholder:c(d)("Whole product (no specific variation)"),onFocus:pe[2]||(pe[2]=Xe=>x("item_id"))},{default:u(()=>[(r(!0),h(P,null,le(Z.value,Xe=>(r(),E(ye,{key:Xe.id,label:Xe.title,value:Xe.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","class","aria-invalid","placeholder"]),n(Gt,{"validation-errors":w.value,"field-key":"item_id"},null,8,["validation-errors"])])):B("",!0):(r(),h("div",qge,[o("label",Yge,[R(f(c(d)("Select Product"))+" ",1),pe[17]||(pe[17]=o("span",{class:"fct-add-review-required"},"*",-1))]),n(Le,{id:"fct_add_review_product",modelValue:V.value,"onUpdate:modelValue":pe[0]||(pe[0]=Xe=>V.value=Xe),class:ue(["w-full",b("post_id")||b("item_id")?"is-error":""]),"aria-invalid":b("post_id")||b("item_id")?"true":void 0,filterable:"",remote:"","reserve-keyword":!1,"remote-method":N,loading:U.value,placeholder:c(d)("Search a product"),"popper-class":"fct-add-review-product-options",onFocus:G,onChange:Y},{default:u(()=>[(r(!0),h(P,null,le(S.value,Xe=>(r(),h(P,{key:Xe.id},[Xe.variations.length?(r(),E(Ve,{key:0,label:Xe.title},{default:u(()=>[(r(!0),h(P,null,le(Xe.variations,pt=>(r(),E(ye,{key:pt.id,label:pt.title,value:$(Xe,pt)},null,8,["label","value"]))),128))]),_:2},1032,["label"])):(r(),E(ye,{key:1,label:Xe.title,value:Q(Xe)},null,8,["label","value"]))],64))),128))]),_:1},8,["modelValue","class","aria-invalid","loading","placeholder"]),n(Gt,{"validation-errors":w.value,"field-key":"post_id"},null,8,["validation-errors"]),n(Gt,{"validation-errors":w.value,"field-key":"item_id"},null,8,["validation-errors"])])),A?(r(),h("div",Jge,[o("span",Zge,[R(f(c(d)("How would you rate this product?"))+" ",1),c(p)?(r(),h("span",e1e,"*")):B("",!0)]),n(zge,{modelValue:y.value.rating,"onUpdate:modelValue":[pe[3]||(pe[3]=Xe=>y.value.rating=Xe),pe[4]||(pe[4]=Xe=>x("rating"))],class:ue(b("rating")?"is-error":""),label:c(d)("Review rating")},null,8,["modelValue","class","label"]),n(Gt,{"validation-errors":w.value,"field-key":"rating"},null,8,["validation-errors"])])):B("",!0),o("div",t1e,[o("label",a1e,f(c(d)("Review title")),1),n(At,{id:"fct_add_review_title",modelValue:y.value.title,"onUpdate:modelValue":pe[5]||(pe[5]=Xe=>y.value.title=Xe),maxlength:"192",class:ue(b("title")?"is-error":""),placeholder:c(d)("Summarize your experience"),"aria-invalid":b("title")?"true":void 0,onFocus:pe[6]||(pe[6]=Xe=>x("title"))},null,8,["modelValue","class","placeholder","aria-invalid"]),n(Gt,{"validation-errors":w.value,"field-key":"title"},null,8,["validation-errors"])]),o("div",l1e,[o("label",s1e,[R(f(c(d)("Your review"))+" ",1),pe[18]||(pe[18]=o("span",{class:"fct-add-review-required"},"*",-1))]),n(At,{id:"fct_add_review_content",modelValue:y.value.content,"onUpdate:modelValue":pe[7]||(pe[7]=Xe=>y.value.content=Xe),type:"textarea",rows:4,maxlength:"5000","show-word-limit":"",class:ue(b("content")?"is-error":""),placeholder:c(d)("What did you like or dislike? How did you use this product?"),"aria-invalid":b("content")?"true":void 0,onFocus:pe[8]||(pe[8]=Xe=>x("content"))},null,8,["modelValue","class","placeholder","aria-invalid"]),n(Gt,{"validation-errors":w.value,"field-key":"content"},null,8,["validation-errors"])]),o("div",n1e,[o("div",o1e,[o("label",i1e,[R(f(c(d)("Reviewer name"))+" ",1),pe[19]||(pe[19]=o("span",{class:"fct-add-review-required"},"*",-1))]),n(At,{id:"fct_add_review_name",modelValue:y.value.reviewer_name,"onUpdate:modelValue":pe[9]||(pe[9]=Xe=>y.value.reviewer_name=Xe),maxlength:"100",class:ue(b("reviewer_name")?"is-error":""),placeholder:c(d)("Name shown on the review"),"aria-invalid":b("reviewer_name")?"true":void 0,onFocus:pe[10]||(pe[10]=Xe=>x("reviewer_name"))},null,8,["modelValue","class","placeholder","aria-invalid"]),n(Gt,{"validation-errors":w.value,"field-key":"reviewer_name"},null,8,["validation-errors"])]),o("div",r1e,[o("label",d1e,f(c(d)("Reviewer email")),1),n(At,{id:"fct_add_review_email",modelValue:y.value.reviewer_email,"onUpdate:modelValue":pe[11]||(pe[11]=Xe=>y.value.reviewer_email=Xe),type:"email",maxlength:"192",class:ue(b("reviewer_email")?"is-error":""),placeholder:c(d)("name@example.com (optional)"),"aria-invalid":b("reviewer_email")?"true":void 0,onFocus:pe[12]||(pe[12]=Xe=>x("reviewer_email"))},null,8,["modelValue","class","placeholder","aria-invalid"]),n(Gt,{"validation-errors":w.value,"field-key":"reviewer_email"},null,8,["validation-errors"])])]),o("div",{class:ue(["fct-add-review-row",{"fct-add-review-row-single":!c(m)}])},[o("div",u1e,[o("label",c1e,f(c(d)("Status")),1),n(Le,{id:"fct_add_review_status",modelValue:y.value.status,"onUpdate:modelValue":pe[13]||(pe[13]=Xe=>y.value.status=Xe),class:"w-full"},{default:u(()=>[n(ye,{label:c(d)("Approved"),value:"approved"},null,8,["label"]),n(ye,{label:c(d)("Pending"),value:"pending"},null,8,["label"])]),_:1},8,["modelValue"])]),c(m)?(r(),h("div",A1e,[o("div",p1e,[n(mt,{modelValue:y.value.is_verified,"onUpdate:modelValue":pe[14]||(pe[14]=Xe=>y.value.is_verified=Xe),"aria-label":c(d)("Mark as verified purchase")},null,8,["modelValue","aria-label"]),o("span",f1e,f(c(d)("Verified purchase")),1)])])):B("",!0)],2),_?(r(),h("div",m1e,[o("span",h1e,f(c(d)("Attachments")),1),I?(r(),h(P,{key:0},[y.value.media.length?(r(),h("ul",_1e,[(r(!0),h(P,null,le(y.value.media,Xe=>(r(),h("li",{key:Xe.key,class:"fct-add-review-media-item"},[o("img",{src:Xe.url,alt:Xe.name||""},null,8,v1e),o("button",{type:"button",class:"fct-add-review-media-remove","aria-label":c(d)("Remove attachment"),onClick:pt=>ve(Xe.key)},"×",8,g1e)]))),128)),y.value.media.length[n(J,{name:"Crown"}),R(" "+f(c(d)("Add attachment")),1)]),_:1}),o("span",B1e,[R(f(c(X))+" ",1),!c(z)&&c(H)?(r(),h("a",{key:0,class:"fct-add-review-upgrade",href:c(H),target:"_blank",rel:"noopener noreferrer"},f(c(d)("Upgrade to Pro")),9,x1e)):B("",!0)])]))])):B("",!0)],40,jge)]),_:1},8,["modelValue","title","close-on-click-modal","close-on-press-escape"])}}},$1e={class:"fct-all-reviews-page fct-layout-width"},F1e={key:0,class:"fct-product-filter-banner"},E1e={class:"fct-all-reviews-wrap"},U1e={key:0,class:"bulk-actions-bar"},I1e={class:"bulk-left flex items-center gap-2"},V1e={class:"bulk-right"},D1e={key:0,class:"px-4 pb-3"},Q1e={class:"mb-1 text-xs text-gray-500"},T1e={class:"font-medium"},M1e={class:"text-sm text-system-dark dark:text-gray-300 truncate max-w-[220px]"},L1e={key:0,class:"text-xs text-gray-500 dark:text-gray-400 truncate max-w-[220px]"},R1e={key:1,class:"text-sm text-gray-400"},O1e={class:"font-medium"},P1e={class:"text-xs text-gray-500"},H1e={class:"max-w-[250px]"},N1e={key:0,class:"font-medium truncate"},K1e={class:"text-xs text-gray-500 truncate"},G1e=["aria-label"],Tc=20,z1e={__name:"AllReviews",setup(e){const t=Na(),a=Wa(),l=t.query.post_id?parseInt(t.query.post_id):null,s=cge({postId:l}),i=T(null),A=T([]),p=T(""),m=T(!1),_=T(""),g=T(!1),y=T(!1),v=T(null),k=T(null);let w=[];ke(k,M=>{if(!M||!w.length)return;const H=new Set(w);w=[],Fe(()=>{s.getTableData().forEach(z=>{H.has(z.id)&&M.toggleRowSelection(z,!0)})})});const b=T(!1),x=T(!1),F=()=>{let M;M=ke(()=>s.getTableData(),H=>{H.length>0&&H[0].product&&H[0].post_id===s.getPostId()?(i.value=H[0].product.post_title,M==null||M()):H.length===0&&(i.value=d("Product #%1$s",s.getPostId()),M==null||M())})};l>0&&F();const Q=()=>{a.replace({query:{...t.query,post_id:void 0}})},$=M=>{A.value=M},S=M=>{if(M.action==="delete")Pa(d("Are you sure you want to permanently delete this review? This action cannot be undone."),d("Confirm Delete"),{confirmButtonText:d("Yes, Delete!"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{ce.delete("reviews/"+M.review.id).then(H=>{q.success(H.message),s.fetch()}).catch(H=>{var z;q.error((z=H.data)==null?void 0:z.message)})}).catch(()=>{});else if(["approve","pending","spam","trash"].includes(M.action)){const H={approve:"approved",pending:"pending",spam:"spam",trash:"trash"};ce.put("reviews/"+M.review.id,{status:H[M.action]}).then(z=>{q.success(z.message),s.fetch()}).catch(z=>{var X;q.error((X=z.data)==null?void 0:X.message)})}},U=()=>{if(!p.value){q.error(d("Please select a bulk action"));return}V(p.value)},V=M=>{const H=A.value.map(z=>z.id);if(M==="reply"){_.value="",m.value=!0;return}M==="delete"?Pa(d("Are you sure you want to permanently delete %s reviews?",H.length),d("Confirm Delete"),{confirmButtonText:d("Yes, Delete!"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{O(M,H)}).catch(()=>{}):O(M,H)},D=async(M,H)=>{const z=[];for(let G=0;G{const G=X?d("Replied to %s review(s).",M):d("%s review(s) updated.",M),Y=X&&H>0?" "+d("%s skipped: already replied.",H):"";if(!z.length){q.success(G+Y);return}q.error(G+Y+" "+d("%s review(s) were not processed and are still selected. Try again.",z.length))},L=async()=>{if(!_.value.trim()){q.error(d("Please write a reply message before sending."));return}const M=A.value.map(z=>z.id);if(!M.length){q.error(d("No reviews selected"));return}g.value=!0;const H=await D(M,z=>ce.post("reviews/bulk-reply",{content:_.value,review_ids:z}));I(H,!0),g.value=!1,H.failedIds.length||(m.value=!1,p.value=""),w=H.failedIds,s.fetch()},O=async(M,H)=>{if(y.value)return;y.value=!0;const z=await D(H,X=>ce.post("reviews/bulk-action",{action_type:M,review_ids:X}));I(z),y.value=!1,z.failedIds.length||(p.value=""),w=z.failedIds,s.fetch()};return(M,H)=>{const z=C("el-button"),X=C("el-option"),G=C("el-select"),Y=C("el-progress"),Z=C("el-table-column"),de=C("router-link"),j=C("el-dropdown-item"),ge=C("el-dropdown-menu"),ie=C("el-dropdown"),W=C("el-table"),N=C("el-input"),ae=C("el-dialog");return r(),E(Ot,{permission:"reviews/manage"},{default:u(()=>[o("div",$1e,[n(nl,{title:c(d)("Reviews")},{action:u(()=>[n(z,{type:"primary",loading:x.value,disabled:x.value,onClick:H[0]||(H[0]=ee=>b.value=!0)},{default:u(()=>[R(f(c(d)("Add Review")),1)]),_:1},8,["loading","disabled"])]),_:1},8,["title"]),i.value?(r(),h("div",F1e,[o("span",null,[R(f(c(d)("Showing reviews for:"))+" ",1),o("strong",null,f(i.value),1)]),n(z,{size:"small",text:"",disabled:c(s).isLoading(),onClick:Q},{default:u(()=>[R(f(c(d)("Clear filter")),1)]),_:1},8,["disabled"])])):B("",!0),o("div",E1e,[n(Cs,{table:c(s),classicTabStyle:!0,"has-mobile-slot":!0},{mobile:u(()=>[c(s).isLoading()?(r(),E(Nge,{key:0})):B("",!0),c(s).isLoading()?B("",!0):(r(),E(Rge,{key:1,table:c(s)},null,8,["table"]))]),default:u(()=>[n(Kl,{name:"slide-fade"},{default:u(()=>[A.value.length>0?(r(),h("div",U1e,[o("div",I1e,[n(G,{size:"small",class:"bulk-select min-w-[180px]",placeholder:c(d)("Select Bulk Action"),disabled:c(s).isLoading()||y.value,modelValue:p.value,"onUpdate:modelValue":H[1]||(H[1]=ee=>p.value=ee)},{default:u(()=>[n(X,{label:c(d)("Approve"),value:"approve"},null,8,["label"]),n(X,{label:c(d)("Pending"),value:"pending"},null,8,["label"]),n(X,{label:c(d)("Mark as Spam"),value:"spam"},null,8,["label"]),n(X,{label:c(d)("Move to Trash"),value:"trash"},null,8,["label"]),n(X,{label:c(d)("Delete Permanently"),value:"delete"},null,8,["label"]),n(X,{label:c(d)("Reply"),value:"reply"},null,8,["label"])]),_:1},8,["placeholder","disabled","modelValue"]),n(z,{size:"small",type:p.value==="delete"?"danger":"primary",disabled:!p.value||y.value||c(s).isLoading(),loading:y.value,onClick:U},{default:u(()=>[R(f(v.value?c(d)("Processing %1$s of %2$s",v.value.current,v.value.total):c(d)("Confirm")),1)]),_:1},8,["type","disabled","loading"])]),o("div",V1e,f(A.value.length)+" "+f(c(d)("item(s) selected")),1)])):B("",!0)]),_:1}),v.value?(r(),h("div",D1e,[o("div",Q1e,f(c(d)("Processing batch %1$s of %2$s",v.value.current,v.value.total)),1),n(Y,{percentage:Math.round(v.value.current/v.value.total*100),"show-text":!1,"stroke-width":6},null,8,["percentage"])])):B("",!0),c(s).isLoading()?(r(),E(gge,{key:1,reviewTable:c(s),"next-page-count":c(s).nextPageCount},null,8,["reviewTable","next-page-count"])):(r(),E(W,{key:2,ref_key:"reviewTableEl",ref:k,data:c(s).getTableData(),class:"w-full compact-table",onSelectionChange:$},{empty:u(()=>[n(wt,{icon:"Empty/ListView","has-dark":"",text:c(d)("No reviews found.")},null,8,["text"])]),default:u(()=>[n(Z,{type:"selection",width:45}),n(Z,{label:c(d)("ID"),width:"300"},{default:u(ee=>[n(ra,{class:"hover:no-underline",to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[o("div",null,[o("div",T1e,"#"+f(c(ea)(ee.row.id)),1),ee.row.product?(r(),h(P,{key:0},[o("div",M1e,f(ee.row.product.post_title),1),ee.row.item_label?(r(),h("div",L1e,f(ee.row.item_label),1)):B("",!0)],64)):(r(),h("span",R1e,"-"))])]),_:2},1032,["to"])]),_:1},8,["label"]),c(s).isColumnVisible("reviewer")?(r(),E(Z,{key:0,label:c(d)("Reviewer"),width:220},{default:u(ee=>[n(ra,{class:"hover:no-underline",to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[o("div",null,[o("div",O1e,f(ee.row.reviewer_name),1),o("div",P1e,f(ee.row.reviewer_email),1)])]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),c(s).isColumnVisible("rating")?(r(),E(Z,{key:1,label:c(d)("Rating"),width:120},{default:u(ee=>[n(ra,{class:"hover:no-underline",to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[n(Qi,{rating:ee.row.rating,size:"small"},null,8,["rating"])]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),c(s).isColumnVisible("content")?(r(),E(Z,{key:2,label:c(d)("Review"),"min-width":200},{default:u(ee=>[n(ra,{class:"hover:no-underline",to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[o("div",H1e,[ee.row.title?(r(),h("div",N1e,f(ee.row.title),1)):B("",!0),o("div",K1e,f(ee.row.content),1)])]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),c(s).isColumnVisible("status")?(r(),E(Z,{key:3,label:c(d)("Status"),width:120},{default:u(ee=>[n(ra,{class:"hover:no-underline",to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[n(la,{status:ee.row.status,size:"small"},null,8,["status"])]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),c(s).isColumnVisible("date")?(r(),E(Z,{key:4,label:c(d)("Date"),width:140},{default:u(ee=>[n(ra,{class:"hover:no-underline",to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[n(Sa,{"date-time":ee.row.created_at},null,8,["date-time"])]),_:2},1032,["to"])]),_:1},8,["label"])):B("",!0),c(s).isColumnVisible("actions")?(r(),E(Z,{key:5,label:c(d)("Actions"),width:90,align:"right"},{default:u(ee=>[n(ie,{trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:S,placement:"bottom-end"},{dropdown:u(()=>[n(ge,null,{default:u(()=>[ee.row.id?(r(),E(j,{key:0,class:"item-link"},{default:u(()=>[n(de,{to:{name:"view_review",params:{review_id:ee.row.id}}},{default:u(()=>[n(J,{name:"Eye"}),R(" "+f(c(d)("View")),1)]),_:2},1032,["to"])]),_:2},1024)):B("",!0),ee.row.status!=="approved"?(r(),E(j,{key:1,command:{action:"approve",review:ee.row}},{default:u(()=>[R(f(c(d)("Approve")),1)]),_:2},1032,["command"])):B("",!0),ee.row.status!=="pending"?(r(),E(j,{key:2,command:{action:"pending",review:ee.row}},{default:u(()=>[R(f(c(d)("Pending")),1)]),_:2},1032,["command"])):B("",!0),ee.row.status!=="spam"?(r(),E(j,{key:3,command:{action:"spam",review:ee.row}},{default:u(()=>[R(f(c(d)("Spam")),1)]),_:2},1032,["command"])):B("",!0),ee.row.status!=="trash"?(r(),E(j,{key:4,command:{action:"trash",review:ee.row}},{default:u(()=>[R(f(c(d)("Trash")),1)]),_:2},1032,["command"])):B("",!0),n(j,{command:{action:"delete",review:ee.row},class:"item-destructive"},{default:u(()=>[n(J,{name:"Delete"}),R(" "+f(c(d)("Delete")),1)]),_:2},1032,["command"])]),_:2},1024)]),default:u(()=>[o("span",{class:"more-btn mr-2","aria-label":c(d)("Review actions")},[n(J,{name:"More"})],8,G1e)]),_:2},1024)]),_:1},8,["label"])):B("",!0)]),_:1},8,["data"]))]),_:1},8,["table"])]),n(S1e,{modelValue:b.value,"onUpdate:modelValue":H[2]||(H[2]=ee=>b.value=ee),saving:x.value,"onUpdate:saving":H[3]||(H[3]=ee=>x.value=ee),"product-id":c(s).getPostId()||null,onCreated:H[4]||(H[4]=ee=>c(s).fetch())},null,8,["modelValue","saving","product-id"]),n(ae,{modelValue:m.value,"onUpdate:modelValue":H[7]||(H[7]=ee=>m.value=ee),title:c(d)("Reply to %s reviews",A.value.length),width:"500px","aria-label":c(d)("Bulk reply to reviews")},{footer:u(()=>[n(z,{disabled:g.value,onClick:H[6]||(H[6]=ee=>m.value=!1)},{default:u(()=>[R(f(c(d)("Cancel")),1)]),_:1},8,["disabled"]),n(z,{type:"primary",loading:g.value,disabled:g.value,onClick:L},{default:u(()=>[R(f(v.value?c(d)("Processing %1$s of %2$s",v.value.current,v.value.total):c(d)("Send Reply")),1)]),_:1},8,["loading","disabled"])]),default:u(()=>[n(N,{modelValue:_.value,"onUpdate:modelValue":H[5]||(H[5]=ee=>_.value=ee),type:"textarea",rows:4,placeholder:c(d)("Write your reply...")},null,8,["modelValue","placeholder"])]),_:1},8,["modelValue","title","aria-label"])])]),_:1})}}},j1e={class:"fct-single-review-page fct-layout-width"},q1e={key:0,class:"p-6"},Y1e={class:"single-page-header flex items-start justify-between"},W1e={class:"single-page-header-title-wrap"},X1e={key:1},J1e={class:"single-page-header-status-wrap"},Z1e={class:"fct-btn-group sm"},eye={class:"single-page-body"},tye={class:"fct-single-review-layout"},aye={class:"fct-single-review-main"},lye={class:"fct-review-rating-inline"},sye={class:"fct-review-rating-num"},nye={class:"fct-review-thread-container"},oye={class:"fct-thread-item"},iye={class:"fct-thread-content"},rye={class:"fct-thread-name-row"},dye={class:"fct-thread-name"},uye={class:"fct-thread-meta"},cye={key:0,class:"fct-thread-title"},Aye={class:"fct-thread-text"},pye={key:1,class:"fct-thread-media"},fye=["aria-label","onClick"],mye=["src","alt"],hye={key:1,class:"fct-thread-media-video"},_ye={key:0,class:"fct-thread-reply-group"},vye={class:"fct-thread-content"},gye={class:"fct-thread-name-row"},yye={class:"fct-thread-name"},bye={class:"fct-thread-meta"},wye=["disabled","aria-label","aria-expanded"],Cye={class:"fct-thread-text"},kye={key:0,class:"fct-thread-form"},Bye={class:"fct-thread-form-box"},xye={class:"fct-thread-form-actions"},Sye={key:0,class:"fct-review-media-preview"},$ye=["src","alt"],Fye=["src"],Eye={key:2,class:"fct-review-media-preview-nav"},Uye={class:"text-sm text-gray-500"},Iye={class:"fct-single-review-aside"},Vye={class:"fct-admin-sidebar"},Dye={class:"fct-review-context"},Qye={key:0,class:"fct-review-context-row"},Tye={class:"fct-review-context-thumb","aria-hidden":"true"},Mye=["src"],Lye={class:"fct-review-context-label"},Rye={key:0,class:"block text-xs text-gray-500 dark:text-gray-400"},Oye=["href","aria-label","title"],Pye={class:"fct-review-context-row"},Hye={class:"fct-review-context-label"},Nye={class:"fct-review-verified-row"},Kye={class:"fct-review-verified-label"},Gye={class:"fct-review-verified-hint"},zye={class:"fct-review-actions-label"},jye={class:"fct-review-action-buttons"},qye=["disabled","aria-label","title","onClick"],Yye={class:"fct-review-action-label"},Wye={class:"fct-vote-rows"},Xye={class:"fct-vote-row fct-vote-row--helpful"},Jye={class:"fct-vote-row-count"},Zye={class:"sr-only"},ebe={class:"fct-vote-row fct-vote-row--not-helpful"},tbe={class:"fct-vote-row-count"},abe={class:"sr-only"},lbe={key:2,class:"p-6 text-center text-gray-500"},sbe={__name:"SingleReview",setup(e){const t=Na(),a=Wa(),l=T(null),s=T(!0),i=()=>{var Y;return dt.get((Y=l.value)==null?void 0:Y.product,"detail.featured_media.url")??pl.productPlaceholder()},A=K(()=>[{status:"approved",label:d("Approve"),aria:d("Approve")},{status:"spam",label:d("Spam"),aria:d("Mark as Spam")},{status:"trash",label:d("Trash"),aria:d("Move to Trash")},{status:"pending",label:d("Pending"),aria:d("Mark as Pending")}].filter(Z=>{var de;return Z.status!==((de=l.value)==null?void 0:de.status)}).slice(0,3)),p=T(""),m=T(!1),_=T(null),g=[{status:"pending",label:d("Pending"),icon:"Clock"},{status:"approved",label:d("Approved"),icon:"Check"},{status:"spam",label:d("Spam"),icon:"AlertIcon"},{status:"trash",label:d("Trash"),icon:"TrashIcon"}],y=Y=>{const Z=g.find(de=>de.status===Y);return Z?Z.label:Y},v=T(null),k=(Y,Z)=>{_.value===null&&(_.value=Y.id,ce.put("reviews/"+Y.id,{status:Z}).then(de=>{Y.status=Z,q.success(de.message)}).catch(de=>{var j;return q.error((j=de.data)==null?void 0:j.message)}).finally(()=>{_.value=null}))},w=T(null),b=()=>{Fe(()=>{w.value&&(w.value.scrollTop=w.value.scrollHeight)})},x=T(!1),F=T(!1),Q=T(null),$=T([]),S=T(!1),U=K(()=>{var Y;return S.value||!(((Y=l.value)==null?void 0:Y.replies)||[]).length}),V=T(!1),D=T(0),I=Y=>{D.value=Y,V.value=!0},L=Y=>{!V.value||!$.value.length||(Y.key==="ArrowLeft"&&D.value>0?D.value--:Y.key==="ArrowRight"&&D.value<$.value.length-1&&D.value++)};ke(V,Y=>{Y?document.addEventListener("keydown",L):document.removeEventListener("keydown",L)});const O=()=>{s.value=!0,ce.get("reviews/"+t.params.review_id).then(Y=>{l.value=Y.review,Q.value=Y.vote_counts||null,$.value=Y.review_media||[],S.value=!!Y.allow_multiple_replies,b()}).catch(Y=>{var Z;q.error(((Z=Y.data)==null?void 0:Z.message)||d("Review not found"))}).finally(()=>{s.value=!1})},M=Y=>{x.value||(x.value=!0,ce.put("reviews/"+l.value.id,{status:Y}).then(Z=>{q.success(Z.message),l.value.status=Y}).catch(Z=>{var de;q.error((de=Z.data)==null?void 0:de.message)}).finally(()=>{x.value=!1}))},H=Y=>{F.value||(F.value=!0,ce.put("reviews/"+l.value.id,{is_verified:Y?1:0}).then(Z=>{q.success(Z.message),l.value.is_verified=Y?1:0}).catch(Z=>{var de;q.error((de=Z.data)==null?void 0:de.message)}).finally(()=>{F.value=!1}))},z=()=>{Pa(d("Are you sure you want to permanently delete this review? This action cannot be undone."),d("Confirm Delete"),{confirmButtonText:d("Yes, Delete!"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{ce.delete("reviews/"+l.value.id).then(Y=>{q.success(Y.message),a.push({name:"reviews"})}).catch(Y=>{var Z;q.error((Z=Y.data)==null?void 0:Z.message)})}).catch(()=>{})},X=Y=>{Pa(d("Are you sure you want to delete this reply?"),d("Delete Reply"),{confirmButtonText:d("Yes, Delete"),cancelButtonText:d("Cancel"),type:"warning"}).then(()=>{ce.delete("reviews/"+l.value.id+"/replies/"+Y).then(Z=>{q.success(Z.message),Array.isArray(l.value.replies)&&(l.value.replies=l.value.replies.filter(de=>de.id!==Y))}).catch(Z=>{var de;q.error((de=Z.data)==null?void 0:de.message)})}).catch(()=>{})},G=()=>{if(!p.value.trim()){q.error(d("Please write a reply message before sending."));return}m.value=!0,ce.post("reviews/"+l.value.id+"/reply",{content:p.value}).then(Y=>{q.success(Y.message),p.value="",Y.reply?(Array.isArray(l.value.replies)||(l.value.replies=[]),l.value.replies.push(Y.reply),b()):O()}).catch(Y=>{var Z;q.error((Z=Y.data)==null?void 0:Z.message)}).finally(()=>{m.value=!1})};return De(()=>{O()}),Ya(()=>{document.removeEventListener("keydown",L)}),(Y,Z)=>{const de=C("el-skeleton"),j=C("el-breadcrumb-item"),ge=C("el-tooltip"),ie=C("router-link"),W=C("el-breadcrumb"),N=C("el-icon"),ae=C("el-button"),ee=C("el-dropdown-item"),Ae=C("el-dropdown-menu"),re=C("el-dropdown"),Ue=C("el-tag"),we=C("el-input"),Be=C("el-dialog"),ve=C("el-switch");return r(),E(Ot,{permission:"reviews/manage"},{default:u(()=>[o("div",j1e,[s.value?(r(),h("div",q1e,[n(de,{rows:8,animated:""})])):l.value?(r(),h(P,{key:1},[o("div",Y1e,[o("div",null,[o("div",W1e,[n(W,{"separator-icon":c(dl)},{default:u(()=>[n(j,{to:{name:"reviews"}},{default:u(()=>[R(f(c(d)("Reviews")),1)]),_:1}),l.value.product?(r(),E(j,{key:0,to:{name:"reviews",query:{post_id:l.value.post_id}}},{default:u(()=>[R(f(l.value.product.post_title),1)]),_:1},8,["to"])):B("",!0),n(j,null,{default:u(()=>[l.value.reviewer_email?(r(),E(ge,{key:0,content:l.value.reviewer_email,placement:"bottom"},{default:u(()=>[o("span",null,f(l.value.reviewer_name),1)]),_:1},8,["content"])):(r(),h("span",X1e,f(l.value.reviewer_name),1)),l.value.customer?(r(),E(ie,{key:2,class:"fct-goto-customer-pill",to:{name:"view_customer",params:{customer_id:l.value.customer.id}}},{default:u(()=>[R(f(c(d)("Go to Customer")),1),Z[8]||(Z[8]=o("span",{"aria-hidden":"true"},"→",-1))]),_:1,__:[8]},8,["to"])):B("",!0)]),_:1})]),_:1},8,["separator-icon"]),o("div",J1e,[n(la,{status:l.value.status},null,8,["status"])])])]),o("div",Z1e,[n(re,{trigger:"click"},{dropdown:u(()=>[n(Ae,null,{default:u(()=>[l.value.status!=="approved"?(r(),E(ee,{key:0,disabled:x.value,onClick:Z[0]||(Z[0]=Ce=>M("approved"))},{default:u(()=>[R(f(c(d)("Approve")),1)]),_:1},8,["disabled"])):B("",!0),l.value.status!=="spam"?(r(),E(ee,{key:1,disabled:x.value,onClick:Z[1]||(Z[1]=Ce=>M("spam"))},{default:u(()=>[R(f(c(d)("Mark as Spam")),1)]),_:1},8,["disabled"])):B("",!0),l.value.status!=="pending"?(r(),E(ee,{key:2,disabled:x.value,onClick:Z[2]||(Z[2]=Ce=>M("pending"))},{default:u(()=>[R(f(c(d)("Mark as Pending")),1)]),_:1},8,["disabled"])):B("",!0),l.value.status!=="trash"?(r(),E(ee,{key:3,disabled:x.value,onClick:Z[3]||(Z[3]=Ce=>M("trash"))},{default:u(()=>[R(f(c(d)("Move to Trash")),1)]),_:1},8,["disabled"])):B("",!0),n(ee,{onClick:z,class:"fct-dropdown-item--danger"},{default:u(()=>[R(f(c(d)("Delete Permanently")),1)]),_:1})]),_:1})]),default:u(()=>[n(ae,{size:"small"},{default:u(()=>[R(f(c(d)("More Actions"))+" ",1),n(N,{class:"el-icon--right"},{default:u(()=>[n(c(Qs))]),_:1})]),_:1})]),_:1})])]),o("div",eye,[o("div",tye,[o("div",aye,[n(c($e),null,{default:u(()=>[n(c(Qe),{title:c(d)("Review Information"),border_bottom:"",title_size:"small"},{action:u(()=>[o("span",lye,[n(Qi,{rating:l.value.rating,size:"small"},null,8,["rating"]),o("span",sye,f(l.value.rating?Number(l.value.rating).toFixed(1):"—"),1)])]),_:1},8,["title"]),o("div",nye,[o("div",{class:"fct-review-thread",ref_key:"chatScrollRef",ref:w},[o("div",oye,[n(Is,{name:l.value.reviewer_name,url:l.value.photo},null,8,["name","url"]),o("div",iye,[o("div",rye,[o("span",dye,f(l.value.reviewer_name),1),n(Ue,{size:"small",effect:"light",class:"fct-customer-review-badge"},{default:u(()=>[R(f(c(d)("Customer review")),1)]),_:1}),l.value.user_id?B("",!0):(r(),E(Ue,{key:0,size:"small",type:"warning",effect:"light"},{default:u(()=>[R(f(c(d)("Guest")),1)]),_:1})),l.value.is_verified?(r(),E(Ue,{key:1,size:"small",type:"success",effect:"light"},{default:u(()=>[R(f(c(d)("Verified Purchase")),1)]),_:1})):B("",!0)]),o("div",uye,[n(Sa,{"date-time":l.value.created_at,"with-time":!0},null,8,["date-time"])]),l.value.title?(r(),h("div",cye,f(l.value.title),1)):B("",!0),o("div",Aye,f(l.value.content||c(d)("No review content.")),1),$.value&&$.value.length?(r(),h("div",pye,[(r(!0),h(P,null,le($.value,(Ce,Oe)=>(r(),h("button",{key:Ce.id,type:"button",class:"fct-thread-media-thumb","aria-label":`${c(d)("Preview")} ${Ce.name||c(d)("media")}`,onClick:Ee=>I(Oe)},[Ce.type==="image"?(r(),h("img",{key:0,src:Ce.url,alt:Ce.name,loading:"lazy"},null,8,mye)):(r(),h("div",hye,Z[9]||(Z[9]=[o("span",{class:"fct-thread-media-play"},"▶",-1)])))],8,fye))),128))])):B("",!0)])]),l.value.replies&&l.value.replies.length?(r(),h("div",_ye,[(r(!0),h(P,null,le(l.value.replies,Ce=>(r(),h("div",{key:Ce.id,class:"fct-thread-reply-card"},[n(Is,{name:Ce.reviewer_name||c(d)("Customer"),url:Ce.photo},null,8,["name","url"]),o("div",vye,[o("div",gye,[o("span",yye,f(Ce.reviewer_name||c(d)("Customer")),1),Number(Ce.is_admin_reply)===1?(r(),E(Ue,{key:0,size:"small",effect:"light",class:"fct-admin-reply-badge"},{default:u(()=>[R(f(c(d)("Admin")),1)]),_:1})):B("",!0)]),o("div",bye,[n(Sa,{"date-time":Ce.created_at,"with-time":!0},null,8,["date-time"]),Z[10]||(Z[10]=o("span",{class:"fct-thread-meta-dot","aria-hidden":"true"},"·",-1)),n(re,{trigger:"click",disabled:_.value!==null,onCommand:Oe=>k(Ce,Oe),onVisibleChange:Oe=>v.value=Oe?Ce.id:null},{dropdown:u(()=>[n(Ae,{class:"fct-thread-status-menu"},{default:u(()=>[(r(),h(P,null,le(g,Oe=>n(ee,{key:Oe.status,command:Oe.status,disabled:Oe.status===Ce.status,class:ue(["fct-thread-status-option",`fct-thread-status-option--${Oe.status}`,{"is-current":Oe.status===Ce.status}])},{default:u(()=>[n(J,{name:Oe.status===Ce.status?"Check":Oe.icon,class:"fct-thread-status-option-icon"},null,8,["name"]),o("span",null,f(Oe.label),1)]),_:2},1032,["command","disabled","class"])),64))]),_:2},1024)]),default:u(()=>[o("button",{type:"button",class:ue(["fct-thread-status-trigger",{"is-open":v.value===Ce.id,"is-busy":_.value===Ce.id}]),disabled:_.value!==null,"aria-label":c(d)("Reply status"),"aria-expanded":v.value===Ce.id?"true":"false","aria-haspopup":"menu"},[n(la,{type:Ce.status,class:"fct-thread-status-pill"},{default:u(()=>[o("span",null,f(y(Ce.status)),1),n(N,{class:"fct-thread-status-caret","aria-hidden":"true"},{default:u(()=>[n(c(Qs))]),_:1})]),_:2},1032,["type"])],10,wye)]),_:2},1032,["disabled","onCommand","onVisibleChange"]),n(ae,{type:"danger",text:"",size:"small",class:"fct-thread-delete-btn","aria-label":c(d)("Delete reply"),onClick:Oe=>X(Ce.id)},{default:u(()=>[n(J,{name:"TrashIcon"})]),_:2},1032,["aria-label","onClick"])]),o("div",Cye,f(Ce.content),1)])]))),128))])):B("",!0)],512),U.value?(r(),h("div",kye,[o("div",Bye,[n(we,{modelValue:p.value,"onUpdate:modelValue":Z[4]||(Z[4]=Ce=>p.value=Ce),type:"textarea",rows:3,placeholder:c(d)("Type a message"),"aria-label":c(d)("Reply to review"),resize:"none"},null,8,["modelValue","placeholder","aria-label"]),o("div",xye,[n(ae,{class:"fct-thread-reply-btn",size:"small",onClick:G,loading:m.value,disabled:m.value||!p.value.trim()},{default:u(()=>[R(f(c(d)("Reply")),1)]),_:1},8,["loading","disabled"])])])])):B("",!0)])]),_:1}),n(Be,{modelValue:V.value,"onUpdate:modelValue":Z[7]||(Z[7]=Ce=>V.value=Ce),title:c(d)("Review Media"),width:"720px","destroy-on-close":"","aria-label":c(d)("Review media preview")},{default:u(()=>[$.value&&$.value[D.value]?(r(),h("div",Sye,[$.value[D.value].type==="image"?(r(),h("img",{key:0,src:$.value[D.value].url,alt:$.value[D.value].name,class:"fct-review-media-preview-img"},null,8,$ye)):(r(),h("video",{key:1,src:$.value[D.value].url,controls:"",class:"fct-review-media-preview-video"},null,8,Fye)),$.value.length>1?(r(),h("div",Eye,[n(ae,{size:"small",disabled:D.value===0,onClick:Z[5]||(Z[5]=Ce=>D.value--)},{default:u(()=>[R(" ← "+f(c(d)("Previous")),1)]),_:1},8,["disabled"]),o("span",Uye,f(D.value+1)+" / "+f($.value.length),1),n(ae,{size:"small",disabled:D.value===$.value.length-1,onClick:Z[6]||(Z[6]=Ce=>D.value++)},{default:u(()=>[R(f(c(d)("Next"))+" → ",1)]),_:1},8,["disabled"])])):B("",!0)])):B("",!0)]),_:1},8,["modelValue","title","aria-label"])]),o("div",Iye,[o("div",Vye,[n(c($e),null,{default:u(()=>[n(c(Qe),{title:c(d)("About the Reviews"),border_bottom:"",title_size:"small"},null,8,["title"]),n(c(xe),null,{default:u(()=>[o("div",Dye,[l.value.product?(r(),h("div",Qye,[o("span",Tye,[o("img",{src:i(),alt:""},null,8,Mye)]),o("span",Lye,[R(f(l.value.product.post_title)+" ",1),l.value.item_label?(r(),h("span",Rye,f(l.value.item_label),1)):B("",!0)]),l.value.product.view_url?(r(),h("a",{key:0,class:"fct-review-context-link",href:l.value.product.view_url,target:"_blank",rel:"noopener noreferrer","aria-label":c(d)("View product"),title:c(d)("View product")},[n(J,{name:"Redirect"})],8,Oye)):B("",!0)])):B("",!0),o("div",Pye,[n(Is,{class:"fct-review-context-avatar",name:l.value.reviewer_name,url:l.value.photo},null,8,["name","url"]),o("span",Hye,f(l.value.customer?l.value.reviewer_name:c(d)("Guest customer")),1),l.value.customer?(r(),E(ie,{key:0,class:"fct-review-context-link",to:{name:"view_customer",params:{customer_id:l.value.customer.id}},target:"_blank","aria-label":c(d)("View profile"),title:c(d)("View profile")},{default:u(()=>[n(J,{name:"Redirect"})]),_:1},8,["to","aria-label","title"])):(r(),E(Ue,{key:1,type:"info",round:"",class:"flex-shrink-0"},{default:u(()=>[R(f(c(d)("No account")),1)]),_:1}))])]),o("div",Nye,[o("div",null,[o("div",Kye,f(c(d)("Verified purchase")),1),o("div",Gye,f(c(d)("Show the verified badge on this review")),1)]),n(ve,{"model-value":!!l.value.is_verified,loading:F.value,disabled:F.value,"aria-label":c(d)("Mark as verified purchase"),"onUpdate:modelValue":H},null,8,["model-value","loading","disabled","aria-label"])]),o("div",zye,f(c(d)("Actions")),1),o("div",jye,[(r(!0),h(P,null,le(A.value,Ce=>(r(),h("button",{key:Ce.status,type:"button",class:ue(["fct-review-action",`fct-review-action--${Ce.status}`]),disabled:x.value,"aria-label":Ce.aria,title:Ce.aria,onClick:Oe=>M(Ce.status)},[Ce.status==="approved"?(r(),E(J,{key:0,class:"fct-review-action-icon",name:"Check"})):Ce.status==="spam"?(r(),E(J,{key:1,class:"fct-review-action-icon",name:"FlagIcon"})):Ce.status==="trash"?(r(),E(J,{key:2,class:"fct-review-action-icon",name:"TrashIcon"})):(r(),E(J,{key:3,class:"fct-review-action-icon",name:"Clock"})),o("span",Yye,f(Ce.label),1)],10,qye))),128))])]),_:1})]),_:1}),Q.value?(r(),E(c($e),{key:0},{default:u(()=>[n(c(Qe),{title:c(d)("Helpful Votes"),text:c(d)("How shoppers reacted to this review"),title_size:"small"},null,8,["title","text"]),n(c(xe),null,{default:u(()=>[o("div",Wye,[o("div",Xye,[n(J,{name:"ThumbUp"}),o("span",Jye,f(Q.value.helpful),1),o("span",Zye,f(c(d)("Helpful votes")),1)]),o("div",ebe,[n(J,{name:"ThumbDown"}),o("span",tbe,f(Q.value.not_helpful),1),o("span",abe,f(c(d)("Not helpful votes")),1)])])]),_:1})]),_:1})):B("",!0)])])])])],64)):(r(),h("div",lbe,f(c(d)("Review not found")),1))])]),_:1})}}},nbe={class:"setting-wrap fct-review-settings"},obe={class:"setting-wrap-inner"},ibe={class:"fct-setting-form-row"},rbe={class:"fct-setting-form-content flex gap-3.5 flex-1"},dbe={class:"fct-inline-tip"},ube={key:0,class:"fct-setting-form-row"},cbe={class:"grid gap-3 mb-6"},Abe={class:"grid gap-3"},pbe={key:1},fbe={class:"fct-setting-form-row"},mbe={class:"fct-setting-form-content"},hbe={class:"fct-inline-tip"},_be={class:"fct-setting-form-fields self-center"},vbe={class:"flex flex-col"},gbe={class:"fct-review-radio-label"},ybe={class:"fct-review-radio-text"},bbe={class:"fct-setting-form-row"},wbe={class:"fct-setting-form-content"},Cbe={class:"fct-inline-tip"},kbe={class:"fct-setting-form-fields self-center flex justify-end"},Bbe={class:"fct-setting-form-row"},xbe={class:"fct-setting-form-content"},Sbe={class:"fct-inline-tip"},$be={class:"fct-setting-form-fields self-center flex justify-end"},Fbe={key:0,class:"fct-setting-form-row is-child"},Ebe={class:"fct-setting-form-content"},Ube={class:"fct-inline-tip"},Ibe={class:"fct-setting-form-fields self-center flex justify-end"},Vbe={class:"fct-setting-form-row"},Dbe={class:"fct-setting-form-content"},Qbe={class:"fct-inline-tip"},Tbe={class:"fct-setting-form-fields self-center flex justify-end"},Mbe={class:"fct-setting-form-row"},Lbe={class:"fct-setting-form-content"},Rbe={class:"fct-inline-tip"},Obe={class:"fct-setting-form-fields self-center flex justify-end"},Pbe={class:"fct-setting-form-row"},Hbe={class:"fct-setting-form-content"},Nbe={class:"fct-inline-tip"},Kbe={key:0,class:"fct-inline-tip"},Gbe={class:"fct-setting-form-fields self-center flex justify-end"},zbe={class:"fct-setting-form-row is-child"},jbe={class:"fct-setting-form-content"},qbe={class:"fct-setting-form-fields self-center flex justify-end"},Ybe={class:"fct-setting-form-row is-child"},Wbe={class:"fct-setting-form-content"},Xbe={class:"fct-setting-form-fields self-center flex justify-end"},Jbe={class:"fct-setting-form-row is-child"},Zbe={class:"fct-setting-form-content"},e0e={class:"fct-inline-tip"},t0e={class:"fct-setting-form-fields self-center flex justify-end"},a0e={class:"fct-setting-form-row is-child"},l0e={class:"fct-setting-form-content"},s0e={class:"fct-setting-form-fields self-center"},n0e={class:"fct-setting-form-row"},o0e={class:"fct-setting-form-content"},i0e={class:"fct-inline-tip"},r0e={key:0,class:"fct-inline-tip"},d0e={class:"fct-setting-form-fields self-center flex justify-end"},u0e=Object.assign({name:"ReviewSettings"},{__name:"ReviewSettings",setup(e){const t=$e,a=xe,l=je.get("app_config.isProActive"),s=T(!0),i=T(!1);let A=!1;const p=is(),m=[{value:"verified_buyers",label:d("Verified buyers only"),desc:d("Only customers who purchased the product.")},{value:"logged_in",label:d("Logged-in users"),desc:d("Any logged-in user can leave a review.")},{value:"anyone",label:d("Anyone"),desc:d("Guests can leave reviews too.")}],_=Us({active:"yes",review_permission_mode:"verified_buyers",auto_approve_reviews:"no",show_verified_badge:"yes",enable_star_rating:"yes",star_rating_required:"yes",reviews_per_page:10,enable_photo_reviews:"no",auto_approve_photo_reviews:"no",max_photos_per_review:5,max_photo_size_mb:1,allowed_photo_types:["jpeg","png","gif","webp"],enable_helpful_votes:"yes"});let g={};const y=()=>{s.value=!0,A=!1,ce.get("settings/modules",{}).then(k=>{g=k.settings||{};const w=g.reviews||{};Object.keys(_).forEach(b=>{w[b]!==void 0&&(_[b]=w[b])}),A=!0}).catch(k=>{var w;q.error(((w=k==null?void 0:k.data)==null?void 0:w.message)||(k==null?void 0:k.message)||d("Could not load review settings."))}).finally(()=>{s.value=!1})},v=()=>{s.value||!A||(i.value=!0,ce.post("settings/modules",{...g,reviews:{..._}}).then(()=>{q.success(d("Settings saved successfully"))}).catch(k=>{var w;q.error(((w=k==null?void 0:k.data)==null?void 0:w.message)||(k==null?void 0:k.message)||d("Failed to save settings"))}).finally(()=>{i.value=!1}))};return De(()=>{y(),p.bind(["mod+s"],k=>{k.preventDefault(),v()})}),Ya(()=>{p.unbind(["mod+s"])}),(k,w)=>{const b=C("el-switch"),x=C("el-skeleton-item"),F=C("el-skeleton"),Q=C("el-radio"),$=C("el-radio-group"),S=C("el-input-number"),U=C("el-button"),V=C("el-checkbox"),D=C("el-checkbox-group");return r(),h("div",nbe,[n($a,{heading:c(d)("Product Reviews"),loading:i.value,"show-cmnd-icon":!0,onOnSave:v},null,8,["heading","loading"]),o("div",obe,[n(Fa),n(c(t),null,{default:u(()=>[n(c(a),null,{default:u(()=>[o("div",ibe,[o("div",rbe,[n(b,{modelValue:_.active,"onUpdate:modelValue":w[0]||(w[0]=I=>_.active=I),"active-value":"yes","inactive-value":"no",disabled:s.value},null,8,["modelValue","disabled"]),o("div",null,[n(Rt,{title:c(d)("Enable Product Reviews")},null,8,["title"]),o("p",dbe,f(_.active==="yes"?c(d)("Customers can leave ratings and reviews on products."):c(d)("Customers cannot leave reviews right now.")),1)])])]),n(_a,{visible:_.active==="yes",accordion:""},{default:u(()=>[s.value?(r(),h("div",ube,[n(F,{animated:"",class:"w-full"},{template:u(()=>[o("div",cbe,[n(x,{variant:"p",class:"w-[20%]"}),n(x,{variant:"p"})]),o("div",Abe,[n(x,{variant:"p",class:"w-[20%]"}),n(x,{variant:"p"})])]),_:1})])):B("",!0),s.value?B("",!0):(r(),h("div",pbe,[o("div",fbe,[o("div",mbe,[n(Rt,{title:c(d)("Who can leave reviews?")},null,8,["title"]),o("p",hbe,f(c(d)("Who is offered the review form on a product.")),1)]),o("div",_be,[n($,{modelValue:_.review_permission_mode,"onUpdate:modelValue":w[1]||(w[1]=I=>_.review_permission_mode=I),class:"fct-review-stacked-radios"},{default:u(()=>[(r(),h(P,null,le(m,I=>n(Q,{key:I.value,value:I.value},{default:u(()=>[o("div",vbe,[o("span",gbe,f(I.label),1),o("span",ybe,f(I.desc),1)])]),_:2},1032,["value"])),64))]),_:1},8,["modelValue"])])]),o("div",bbe,[o("div",wbe,[n(Rt,{title:c(d)("Show 'Verified Owner' Badge")},null,8,["title"]),o("p",Cbe,f(c(d)("Display a verified badge on reviews from customers who purchased the product.")),1)]),o("div",kbe,[n(b,{modelValue:_.show_verified_badge,"onUpdate:modelValue":w[2]||(w[2]=I=>_.show_verified_badge=I),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"])])]),o("div",Bbe,[o("div",xbe,[n(Rt,{title:c(d)("Enable Star Ratings")},null,8,["title"]),o("p",Sbe,f(c(d)("Allow customers to rate products with stars.")),1)]),o("div",$be,[n(b,{modelValue:_.enable_star_rating,"onUpdate:modelValue":w[3]||(w[3]=I=>_.enable_star_rating=I),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"])])]),_.enable_star_rating==="yes"?(r(),h("div",Fbe,[o("div",Ebe,[n(Rt,{title:c(d)("Star Ratings Required")},null,8,["title"]),o("p",Ube,f(c(d)("When off, customers can submit text-only reviews without a star rating.")),1)]),o("div",Ibe,[n(b,{modelValue:_.star_rating_required,"onUpdate:modelValue":w[4]||(w[4]=I=>_.star_rating_required=I),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"])])])):B("",!0),o("div",Vbe,[o("div",Dbe,[n(Rt,{title:c(d)("Auto-approve Reviews")},null,8,["title"]),o("p",Qbe,f(c(d)("Publish new reviews immediately, without moderation.")),1)]),o("div",Tbe,[n(b,{modelValue:_.auto_approve_reviews,"onUpdate:modelValue":w[5]||(w[5]=I=>_.auto_approve_reviews=I),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"])])]),o("div",Mbe,[o("div",Lbe,[n(Rt,{title:c(d)("Reviews Per Page")},null,8,["title"]),o("p",Rbe,f(c(d)("How many reviews a product page lists before paging.")),1)]),o("div",Obe,[n(S,{modelValue:_.reviews_per_page,"onUpdate:modelValue":w[6]||(w[6]=I=>_.reviews_per_page=I),min:1,max:50},null,8,["modelValue"])])]),o("div",Pbe,[o("div",Hbe,[n(Rt,{title:c(d)("Photo Reviews")},null,8,["title"]),o("p",Nbe,f(c(d)("Let customers attach photos to their reviews.")),1),c(l)?B("",!0):(r(),h("p",Kbe,[R(f(c(d)("This feature is only available in FluentCart Pro."))+" ",1),n(U,{size:"small",tag:"a",link:"",href:c(Lo)("feature_lock_review_settings"),target:"_blank",rel:"noopener noreferrer"},{default:u(()=>[R(f(c(d)("Upgrade to Pro")),1)]),_:1},8,["href"])]))]),o("div",Gbe,[n(b,{modelValue:_.enable_photo_reviews,"onUpdate:modelValue":w[7]||(w[7]=I=>_.enable_photo_reviews=I),"active-value":"yes","inactive-value":"no",disabled:!c(l)},null,8,["modelValue","disabled"])])]),c(l)&&_.enable_photo_reviews==="yes"?(r(),h(P,{key:1},[o("div",zbe,[o("div",jbe,[n(Rt,{title:c(d)("Max Photos Per Review")},null,8,["title"])]),o("div",qbe,[n(S,{modelValue:_.max_photos_per_review,"onUpdate:modelValue":w[8]||(w[8]=I=>_.max_photos_per_review=I),min:1,max:10},null,8,["modelValue"])])]),o("div",Ybe,[o("div",Wbe,[n(Rt,{title:c(d)("Max File Size (MB)")},null,8,["title"])]),o("div",Xbe,[n(S,{modelValue:_.max_photo_size_mb,"onUpdate:modelValue":w[9]||(w[9]=I=>_.max_photo_size_mb=I),min:.1,max:10,step:.1,precision:1,"controls-position":"right"},null,8,["modelValue"])])]),o("div",Jbe,[o("div",Zbe,[n(Rt,{title:c(d)("Auto-approve Photo Reviews")},null,8,["title"]),o("p",e0e,f(c(d)("Publish reviews with photos immediately. When off, photo reviews always wait for moderation.")),1)]),o("div",t0e,[n(b,{modelValue:_.auto_approve_photo_reviews,"onUpdate:modelValue":w[10]||(w[10]=I=>_.auto_approve_photo_reviews=I),"active-value":"yes","inactive-value":"no"},null,8,["modelValue"])])]),o("div",a0e,[o("div",l0e,[n(Rt,{title:c(d)("Allowed File Types")},null,8,["title"])]),o("div",s0e,[n(D,{modelValue:_.allowed_photo_types,"onUpdate:modelValue":w[11]||(w[11]=I=>_.allowed_photo_types=I)},{default:u(()=>[n(V,{label:"jpeg"},{default:u(()=>w[13]||(w[13]=[R("JPEG",-1)])),_:1,__:[13]}),n(V,{label:"png"},{default:u(()=>w[14]||(w[14]=[R("PNG",-1)])),_:1,__:[14]}),n(V,{label:"gif"},{default:u(()=>w[15]||(w[15]=[R("GIF",-1)])),_:1,__:[15]}),n(V,{label:"webp"},{default:u(()=>w[16]||(w[16]=[R("WebP",-1)])),_:1,__:[16]})]),_:1},8,["modelValue"])])])],64)):B("",!0),o("div",n0e,[o("div",o0e,[n(Rt,{title:c(d)("Helpful Votes")},null,8,["title"]),o("p",i0e,f(c(d)("Let visitors mark reviews as helpful.")),1),c(l)?B("",!0):(r(),h("p",r0e,[R(f(c(d)("This feature is only available in FluentCart Pro."))+" ",1),n(U,{size:"small",tag:"a",link:"",href:c(Lo)("feature_lock_review_settings"),target:"_blank",rel:"noopener noreferrer"},{default:u(()=>[R(f(c(d)("Upgrade to Pro")),1)]),_:1},8,["href"])]))]),o("div",d0e,[n(b,{modelValue:_.enable_helpful_votes,"onUpdate:modelValue":w[12]||(w[12]=I=>_.enable_helpful_votes=I),"active-value":"yes","inactive-value":"no",disabled:!c(l)},null,8,["modelValue","disabled"])])])]))]),_:1},8,["visible"])]),_:1})]),_:1})])])}}}),c0e={name:"CheckoutFields",components:{Animation:_a,CardHeader:Qe,Card:$e,CardBody:xe,SettingsHeader:$a,AdminNotice:Fa},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:d,clearRequiredWhenDisabled(e){e&&e.enabled!=="yes"&&e.required==="yes"&&(e.required="no")},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,A,p,m;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"?((A=(i=this.settings.basic_info)==null?void 0:i.first_name)==null?void 0:A.enabled)==="yes"||((m=(p=this.settings.basic_info)==null?void 0:p.last_name)==null?void 0:m.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())}}},A0e={class:"setting-wrap"},p0e={class:"setting-wrap-inner"},f0e={class:"fct-checkout-fields-wrapp"},m0e={class:"field-heading"},h0e={class:"fct-checkout-fields"},_0e={key:0,class:"fct-checkout-field"},v0e={class:"fct-checkout-field-info"},g0e={class:"fct-checkout-field-label-wrap"},y0e={class:"fct-checkout-field-tags"},b0e={key:0,class:"fct-checkout-field-info-desc"},w0e={key:0,class:"fct-checkout-field-action"},C0e={key:1,class:"fct-checkout-field-input"},k0e={class:"fct-checkout-field-info"},B0e={class:"fct-checkout-field-label-wrap"},x0e={key:1,class:"fct-checkout-field-tags"},S0e={key:0,class:"fct-checkout-field-info-desc"},$0e={key:0,class:"fct-checkout-field-action"},F0e={class:"form-section-save-action"};function E0e(e,t,a,l,s,i){const A=C("SettingsHeader"),p=C("AdminNotice"),m=C("el-skeleton"),_=C("el-switch"),g=C("el-tag"),y=C("el-checkbox"),v=C("el-input"),k=C("CardBody"),w=C("Card"),b=C("el-button");return r(),h("div",A0e,[n(A,{heading:i.translate("Checkout Fields"),loading:s.saving,onOnSave:i.saveFields},null,8,["heading","loading","onOnSave"]),o("div",p0e,[n(p),o("div",f0e,[n(w,null,{default:u(()=>[n(k,null,{default:u(()=>[n(m,{loading:s.fetching,animated:"",rows:5},null,8,["loading"]),s.fetching?B("",!0):(r(!0),h(P,{key:0},le(s.fields,(x,F)=>(r(),h("div",{key:F,class:"fct-checkout-field-section"},[o("h3",m0e,f(i.formatSectionTitle(F)),1),o("div",h0e,[x.label?(r(),h("div",_0e,[o("div",v0e,[o("div",g0e,[x.can_alter==="yes"?(r(),E(_,{key:0,modelValue:s.settings[F].enabled,"onUpdate:modelValue":Q=>s.settings[F].enabled=Q,"active-value":"yes","inactive-value":"no",onChange:Q=>i.clearRequiredWhenDisabled(s.settings[F])},null,8,["modelValue","onUpdate:modelValue","onChange"])):B("",!0),o("span",{class:ue(`fct-checkout-field-label ${s.settings[F].enabled==="no"?"opacity-50":""}`)},f(x.label),3),o("div",y0e,[x.can_alter!=="yes"&&s.settings[F].enabled==="yes"?(r(),E(g,{key:0,size:"small"},{default:u(()=>[R(f(i.translate("System")),1)]),_:1})):B("",!0),s.settings[F].required==="yes"&&s.settings[F].enabled==="yes"?(r(),E(g,{key:1,size:"small"},{default:u(()=>[R(f(i.translate("Required")),1)]),_:1})):B("",!0)])]),x.help_text?(r(),h("div",b0e,f(x.help_text),1)):B("",!0)]),x.can_alter==="yes"?(r(),h("div",w0e,[n(y,{modelValue:s.settings[F].required,"onUpdate:modelValue":Q=>s.settings[F].required=Q,"true-label":"yes","false-label":"no",disabled:s.settings[F].enabled!=="yes"},{default:u(()=>[R(f(i.translate("Required")),1)]),_:2},1032,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0),s.settings[F].hasOwnProperty("text")&&s.settings[F].enabled==="yes"?(r(),h("div",C0e,[n(v,{type:"textarea",modelValue:s.settings[F].text,"onUpdate:modelValue":Q=>s.settings[F].text=Q,disabled:s.settings[F].enabled!=="yes"},null,8,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0)])):(r(!0),h(P,{key:1},le(x,(Q,$)=>(r(),h("div",{key:$,class:"fct-checkout-field"},[o("div",k0e,[o("div",B0e,[Q.can_alter==="yes"?(r(),E(_,{key:0,modelValue:s.settings[F][$].enabled,"onUpdate:modelValue":S=>s.settings[F][$].enabled=S,"active-value":"yes","inactive-value":"no",onChange:S=>i.clearRequiredWhenDisabled(s.settings[F][$]),disabled:i.isFirstNameDisabled(F,$)||i.isB2BOnlyModeDisabled(F,$)},null,8,["modelValue","onUpdate:modelValue","onChange","disabled"])):B("",!0),o("span",{class:ue(["fct-checkout-field-label",i.shouldDimLabel(F,$)?"opacity-50":""])},f(Q.label),3),i.isVisible(Q,$)?(r(),h("div",x0e,[(Q.can_alter!=="yes"||$==="first_name")&&s.settings[F][$].enabled==="yes"?(r(),E(g,{key:0,size:"small"},{default:u(()=>[R(f(i.translate("System")),1)]),_:1})):B("",!0),s.settings[F][$].required==="yes"&&s.settings[F][$].enabled==="yes"?(r(),E(g,{key:1,size:"small"},{default:u(()=>[R(f(i.translate("Required")),1)]),_:1})):B("",!0)])):B("",!0)]),Q.help_text?(r(),h("div",S0e,f(Q.help_text),1)):B("",!0)]),Q.can_alter==="yes"&&$!=="first_name"&&$!=="b2b_only_mode"?(r(),h("div",$0e,[n(y,{modelValue:s.settings[F][$].required,"onUpdate:modelValue":S=>s.settings[F][$].required=S,"true-label":"yes","false-label":"no",disabled:s.settings[F][$].enabled!=="yes"},{default:u(()=>[R(f(i.translate("Required")),1)]),_:2},1032,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0)]))),128))])]))),128))]),_:1})]),_:1}),o("div",F0e,[n(b,{type:"primary",onClick:i.saveFields,loading:s.saving},{default:u(()=>[R(f(i.translate("Save")),1)]),_:1},8,["onClick","loading"])])])])])}const U0e=nt(c0e,[["render",E0e]]);var Vo={exports:{}};/* @license
Papa Parse
v5.5.3
https://github.com/mholt/PapaParse
License: MIT
*/var I0e=Vo.exports,Mc;function V0e(){return Mc||(Mc=1,function(e,t){((a,l)=>{e.exports=l()})(I0e,function a(){var l=typeof self<"u"?self:typeof window<"u"?window:l!==void 0?l:{},s,i=!l.document&&!!l.postMessage,A=l.IS_PAPA_WORKER||!1,p={},m=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(L){var O=U(L);O.chunkSize=parseInt(O.chunkSize),L.step||L.chunk||(O.chunkSize=null),this._handle=new b(O),(this._handle.streamer=this)._config=O}).call(this,I),this.parseChunk=function(L,O){var M=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0=this._config.preview),A)l.postMessage({results:H,workerId:_.WORKER_ID,finished:M});else if(D(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||!M||!D(this._config.complete)||H&&H.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),M||H&&H.meta.paused||this._nextChunk(),H}this._halted=!0},this._sendError=function(L){D(this._config.error)?this._config.error(L):A&&this._config.error&&l.postMessage({workerId:_.WORKER_ID,error:L,finished:!1})}}function y(I){var L;(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(L=new XMLHttpRequest,this._config.withCredentials&&(L.withCredentials=this._config.withCredentials),i||(L.onload=V(this._chunkLoaded,this),L.onerror=V(this._chunkError,this)),L.open(this._config.downloadRequestBody?"POST":"GET",this._input,!i),this._config.downloadRequestHeaders){var O,M=this._config.downloadRequestHeaders;for(O in M)L.setRequestHeader(O,M[O])}var H;this._config.chunkSize&&(H=this._start+this._config.chunkSize-1,L.setRequestHeader("Range","bytes="+this._start+"-"+H));try{L.send(this._config.downloadRequestBody)}catch(z){this._chunkError(z.message)}i&&L.status===0&&this._chunkError()}},this._chunkLoaded=function(){L.readyState===4&&(L.status<200||400<=L.status?this._chunkError():(this._start+=this._config.chunkSize||L.responseText.length,this._finished=!this._config.chunkSize||this._start>=(O=>(O=O.getResponseHeader("Content-Range"))!==null?parseInt(O.substring(O.lastIndexOf("/")+1)):-1)(L),this.parseChunk(L.responseText)))},this._chunkError=function(O){O=L.statusText||O,this._sendError(new Error(O))}}function v(I){(I=I||{}).chunkSize||(I.chunkSize=_.LocalChunkSize),g.call(this,I);var L,O,M=typeof FileReader<"u";this.stream=function(H){this._input=H,O=H.slice||H.webkitSlice||H.mozSlice,M?((L=new FileReader).onload=V(this._chunkLoaded,this),L.onerror=V(this._chunkError,this)):L=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(L.error)}}function k(I){var L;g.call(this,I=I||{}),this.stream=function(O){return L=O,this._nextChunk()},this._nextChunk=function(){var O,M;if(!this._finished)return O=this._config.chunkSize,L=O?(M=L.substring(0,O),L.substring(O)):(M=L,""),this._finished=!L,this.parseChunk(M)}}function w(I){g.call(this,I=I||{});var L=[],O=!0,M=!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(){M&&L.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),L.length?this.parseChunk(L.shift()):O=!0},this._streamData=V(function(H){try{L.push(typeof H=="string"?H:H.toString(this._config.encoding)),O&&(O=!1,this._checkIsFinished(),this.parseChunk(L.shift()))}catch(z){this._streamError(z)}},this),this._streamError=V(function(H){this._streamCleanUp(),this._sendError(H)},this),this._streamEnd=V(function(){this._streamCleanUp(),M=!0,this._streamData("")},this),this._streamCleanUp=V(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function b(I){var L,O,M,H,z=Math.pow(2,53),X=-z,G=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,Y=/^((\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)))$/,Z=this,de=0,j=0,ge=!1,ie=!1,W=[],N={data:[],errors:[],meta:{}};function ae(Ue){return I.skipEmptyLines==="greedy"?Ue.join("").trim()==="":Ue.length===1&&Ue[0].length===0}function ee(){if(N&&M&&(re("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+_.DefaultDelimiter+"'"),M=!1),I.skipEmptyLines&&(N.data=N.data.filter(function(ve){return!ae(ve)})),Ae()){let ve=function(Ce,Oe){D(I.transformHeader)&&(Ce=I.transformHeader(Ce,Oe)),W.push(Ce)};if(N)if(Array.isArray(N.data[0])){for(var Ue=0;Ae()&&Ue(At=>(I.dynamicTypingFunction&&I.dynamicTyping[At]===void 0&&(I.dynamicTyping[At]=I.dynamicTypingFunction(At)),(I.dynamicTyping[At]||I.dynamicTyping)===!0))(Ve)?Le==="true"||Le==="TRUE"||Le!=="false"&&Le!=="FALSE"&&((At=>{if(G.test(At)&&(At=parseFloat(At),X=W.length?"__parsed_extra":W[Ee]:pe,ye=I.transform?I.transform(ye,pe):ye);pe==="__parsed_extra"?(Oe[pe]=Oe[pe]||[],Oe[pe].push(ye)):Oe[pe]=ye}return I.header&&(Ee>W.length?re("FieldMismatch","TooManyFields","Too many fields: expected "+W.length+" fields but parsed "+Ee,j+Ce):EeI.preview?O.abort():(N.data=N.data[0],H(N,Z))))}),this.parse=function(Ue,we,Be){var ve=I.quoteChar||'"',ve=(I.newline||(I.newline=this.guessLineEndings(Ue,ve)),M=!1,I.delimiter?D(I.delimiter)&&(I.delimiter=I.delimiter(Ue),N.meta.delimiter=I.delimiter):((ve=((Ce,Oe,Ee,pe,ye)=>{var Ve,Le,At,mt;ye=ye||[","," ","|",";",_.RECORD_SEP,_.UNIT_SEP];for(var Mt=0;Mt=Be.length/2?`\r
`:"\r"}}function x(I){return I.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function F(I){var L=(I=I||{}).delimiter,O=I.newline,M=I.comments,H=I.step,z=I.preview,X=I.fastMode,G=null,Y=!1,Z=I.quoteChar==null?'"':I.quoteChar,de=Z;if(I.escapeChar!==void 0&&(de=I.escapeChar),(typeof L!="string"||-1<_.BAD_DELIMITERS.indexOf(L))&&(L=","),M===L)throw new Error("Comment character same as delimiter");M===!0?M="#":(typeof M!="string"||-1<_.BAD_DELIMITERS.indexOf(M))&&(M=!1),O!==`
`&&O!=="\r"&&O!==`\r
`&&(O=`
`);var j=0,ge=!1;this.parse=function(ie,W,N){if(typeof ie!="string")throw new Error("Input must be a string");var ae=ie.length,ee=L.length,Ae=O.length,re=M.length,Ue=D(H),we=[],Be=[],ve=[],Ce=j=0;if(!ie)return pt();if(X||X!==!1&&ie.indexOf(Z)===-1){for(var Oe=ie.split(O),Ee=0;Ee=z)return pt(!0);break}Be.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:we.length,index:j}),Le++}}else if(M&&ve.length===0&&ie.substring(j,j+re)===M){if(ye===-1)return pt();j=ye+Ae,ye=ie.indexOf(O,j),pe=ie.indexOf(L,j)}else if(pe!==-1&&(pe=z)return pt(!0)}return Dt();function mt(Ct){we.push(Ct),Ce=j}function Mt(Ct){var $t=0;return $t=Ct!==-1&&(Ct=ie.substring(Le+1,Ct))&&Ct.trim()===""?Ct.length:$t}function Dt(Ct){return N||(Ct===void 0&&(Ct=ie.substring(j)),ve.push(Ct),j=ae,mt(ve),Ue&&jt()),pt()}function Xe(Ct){j=Ct,mt(ve),ve=[],ye=ie.indexOf(O,j)}function pt(Ct){if(I.header&&!W&&we.length&&!Y){var $t=we[0],Ht=Object.create(null),Nt=new Set($t);let Qt=!1;for(let yt=0;yt<$t.length;yt++){let Xt=$t[yt];if(Ht[Xt=D(I.transformHeader)?I.transformHeader(Xt,yt):Xt]){let be,Ie=Ht[Xt];for(;be=Xt+"_"+Ie,Ie++,Nt.has(be););Nt.add(be),$t[yt]=be,Ht[Xt]++,Qt=!0,(G=G===null?{}:G)[be]=Xt}else Ht[Xt]=1,$t[yt]=Xt;Nt.add(Xt)}Qt&&console.warn("Duplicate headers found and renamed."),Y=!0}return{data:we,errors:Be,meta:{delimiter:L,linebreak:O,aborted:ge,truncated:!!Ct,cursor:Ce+(W||0),renamedHeaders:G}}}function jt(){H(pt()),we=[],Be=[]}},this.abort=function(){ge=!0},this.getCharIndex=function(){return j}}function Q(I){var L=I.data,O=p[L.workerId],M=!1;if(L.error)O.userError(L.error,L.file);else if(L.results&&L.results.data){var H={abort:function(){M=!0,$(L.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:S,resume:S};if(D(O.userStep)){for(var z=0;zM.charCodeAt(0)!==65279?M:M.slice(1))(I),O=new(L.download?y:k)(L)):I.readable===!0&&D(I.read)&&D(I.on)?O=new w(L):(l.File&&I instanceof File||I instanceof Object)&&(O=new v(L)),O.stream(I);(O=(()=>{var M;return!!_.WORKERS_SUPPORTED&&(M=(()=>{var H=l.URL||l.webkitURL||null,z=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; ","(",z,")();"],{type:"text/javascript"})))})(),(M=new l.Worker(M)).onmessage=Q,M.id=m++,p[M.id]=M)})()).userStep=L.step,O.userChunk=L.chunk,O.userComplete=L.complete,O.userError=L.error,L.step=D(L.step),L.chunk=D(L.chunk),L.complete=D(L.complete),L.error=D(L.error),delete L.worker,O.postMessage({input:I,config:L,workerId:O.id})},_.unparse=function(I,L){var O=!1,M=!0,H=",",z=`\r
`,X='"',G=X+X,Y=!1,Z=null,de=!1,j=((()=>{if(typeof L=="object"){if(typeof L.delimiter!="string"||_.BAD_DELIMITERS.filter(function(W){return L.delimiter.indexOf(W)!==-1}).length||(H=L.delimiter),typeof L.quotes!="boolean"&&typeof L.quotes!="function"&&!Array.isArray(L.quotes)||(O=L.quotes),typeof L.skipEmptyLines!="boolean"&&typeof L.skipEmptyLines!="string"||(Y=L.skipEmptyLines),typeof L.newline=="string"&&(z=L.newline),typeof L.quoteChar=="string"&&(X=L.quoteChar),typeof L.header=="boolean"&&(M=L.header),Array.isArray(L.columns)){if(L.columns.length===0)throw new Error("Option columns is empty");Z=L.columns}L.escapeChar!==void 0&&(G=L.escapeChar+X),L.escapeFormulae instanceof RegExp?de=L.escapeFormulae:typeof L.escapeFormulae=="boolean"&&L.escapeFormulae&&(de=/^[=+\-@\t\r].*$/)}})(),new RegExp(x(X),"g"));if(typeof I=="string"&&(I=JSON.parse(I)),Array.isArray(I)){if(!I.length||Array.isArray(I[0]))return ge(null,I,Y);if(typeof I[0]=="object")return ge(Z||Object.keys(I[0]),I,Y)}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||Z),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])),ge(I.fields||[],I.data||[],Y);throw new Error("Unable to serialize unrecognized input");function ge(W,N,ae){var ee="",Ae=(typeof W=="string"&&(W=JSON.parse(W)),typeof N=="string"&&(N=JSON.parse(N)),Array.isArray(W)&&0{for(var Ue=0;UedR(G,w.thousand),x=G=>{G&&Lc.parse(G,{header:!0,complete:function(Y){p.value=Y.data,A.value=Y.meta.fields,g.value=A.value.includes("Type")&&A.value.includes("Parent"),Q(),g.value&&U(),k.value=!0}})},F=()=>{_.value={},A.value=[],p.value=[],k.value=!1,g.value=!1},Q=()=>{const G=[],Y=[];let Z=0;A.value.forEach(de=>{let j=null,ge=null;const ie=de.toString();for(const[W,N]of y.entries())if(ie.toLocaleLowerCase().startsWith(N)){const ae=de.toString().match(/ \d+ /g);if(Array.isArray(ae)&&ae.length===1){let ee=ae[0];Z=ee>Z?ee:Z,j=de.toString().replace(ae[0]," %d "),ge=de.toString().replace(ae[0]," ");break}}j!=null?G.includes(j)||(G.push(j),Y.push({title:ge,value:j})):Y.push({title:de,value:de})}),_.value=Y,v=Z},$=()=>window.fluentCartRestVars.rest.url+"/files/upload",S={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,Y]of Object.entries(S))if(m.value[G]){for(const Z of Y)if(A.value.includes(Z)){m.value[G].value=Z;break}}},V=G=>G?{day:"daily",week:"weekly",month:"monthly",year:"yearly"}[G.trim().toLowerCase()]||G:"",D=G=>{if(!G)return"";const Y=G.split(",").map(Z=>Z.trim().toLowerCase());return Y.includes("variation")?"variation":Y.includes("variable")?"variable":Y.includes("subscription")?"subscription":Y.includes("simple")?"simple":Y[0]||""},I=(G=!0)=>{const Y=[],Z={},de=m.value,j={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"},ge=W=>{const N=[];for(let ae=1;ae<=10;ae++){const ee=`Attribute ${ae} name`,Ae=`Attribute ${ae} value(s)`;W[ee]&&W[Ae]&&N.push(W[Ae])}return N.join(" - ")},ie=W=>W==="1"||W===1?"published":W==="0"||W===0?"draft":W||"published";p.value.forEach(W=>{var Be,ve,Ce,Oe,Ee,pe,ye,Ve,Le,At,mt,Mt,Dt,Xe,pt,jt,Ct,$t,Ht,Nt;const N=D(W.Type);if(N!=="simple"&&N!=="variable"&&N!=="subscription")return;const ae={};ae._cid=hl(),ae.post_title=W[(Be=de.post_title)==null?void 0:Be.value]||"",ae.post_name=W[(ve=de.post_name)==null?void 0:ve.value]||ae.post_title,ae.ID=W[(Ce=de.post_id)==null?void 0:Ce.value]||"",ae.post_content=W[(Oe=de.post_content)==null?void 0:Oe.value]||"",ae.post_excerpt=W[(Ee=de.post_excerpt)==null?void 0:Ee.value]||"",ae.post_status=ie(W[(pe=de.post_status)==null?void 0:pe.value]);const ee={variation_type:N==="variable"?"simple_variations":"simple",manage_stock:"0",fulfillment_type:"physical"},Ae=W[(ye=de.images)==null?void 0:ye.value]||"",re=[];Ae&&Ae.split(",").map(Qt=>Qt.trim()).filter(Boolean).forEach(Qt=>{const yt=Qt.split("/").pop().split("?")[0]||"image";re.push({id:0,url:Qt,title:yt})}),ae.detail=ee,ae.gallery=re,ae.variants=[];const Ue=W[(Ve=de.categories)==null?void 0:Ve.value]||"";if(Ue?ae.categories=Ue.split(",").map(Qt=>Qt.trim()).filter(Boolean):ae.categories=[],N==="simple"||N==="subscription"){const Qt=b(W[(Le=de.item_price)==null?void 0:Le.value]||""),yt=b(W[(At=de.compare_price)==null?void 0:At.value]||""),Xt=W[(mt=de.sku)==null?void 0:mt.value]||"",be=N==="subscription"?"subscription":W[(Mt=de.payment_type)==null?void 0:Mt.value]||"onetime",Ie=V(W[(Dt=de.repeat_interval)==null?void 0:Dt.value]||""),it=W[(Xe=de.trial_days)==null?void 0:Xe.value]||"",kt=W[(pt=de.installment)==null?void 0:pt.value]||"",Bt=W[(jt=de.installment_count)==null?void 0:jt.value]||"",ta=W[(Ct=de.manage_setup_fee)==null?void 0:Ct.value]||"",bt=W[($t=de.signup_fee_name)==null?void 0:$t.value]||"",sa=b(W[(Ht=de.signup_fee)==null?void 0:Ht.value]||"");(Qt||ae.post_title)&&ae.variants.push({_cid:hl(),variation_title:ae.post_title,sku:Xt,item_price:Qt,compare_price:yt,other_info:{...j,payment_type:be,repeat_interval:Ie,trial_days:it,installment:kt==="yes"?"yes":"no",times:Bt,manage_setup_fee:ta==="yes"?"yes":"no",signup_fee_name:bt,signup_fee:sa},media:[]})}const we=W[(Nt=de.sku)==null?void 0:Nt.value]||"";N==="variable"&&we&&(Z[we]=ae),Y.push(ae)}),p.value.forEach(W=>{var At,mt,Mt,Dt,Xe,pt,jt,Ct,$t,Ht,Nt,Qt;if(D(W.Type)!=="variation")return;const N=W.Parent;if(!N||!Z[N])return;const ae=ge(W),ee=b(W[(At=de.item_price)==null?void 0:At.value]||""),Ae=b(W[(mt=de.compare_price)==null?void 0:mt.value]||""),re=W[(Mt=de.images)==null?void 0:Mt.value]||"",Ue=[];re&&re.split(",").map(yt=>yt.trim()).filter(Boolean).forEach(yt=>{const Xt=yt.split("/").pop().split("?")[0]||"image";Ue.push({id:0,url:yt,title:Xt})});const we=W[(Dt=de.sku)==null?void 0:Dt.value]||"",Be=W[(Xe=de.payment_type)==null?void 0:Xe.value]||"onetime",ve=V(W[(pt=de.repeat_interval)==null?void 0:pt.value]||""),Ce=W[(jt=de.trial_days)==null?void 0:jt.value]||"",Oe=W[(Ct=de.installment)==null?void 0:Ct.value]||"",Ee=W[($t=de.installment_count)==null?void 0:$t.value]||"",pe=W[(Ht=de.manage_setup_fee)==null?void 0:Ht.value]||"",ye=W[(Nt=de.signup_fee_name)==null?void 0:Nt.value]||"",Ve=b(W[(Qt=de.signup_fee)==null?void 0:Qt.value]||""),Le={_cid:hl(),variation_title:ae||W.Name||"",sku:we,item_price:ee,compare_price:Ae,other_info:{...j,payment_type:Be,repeat_interval:ve,trial_days:Ce,installment:Oe==="yes"?"yes":"no",times:Ee,manage_setup_fee:pe==="yes"?"yes":"no",signup_fee_name:ye,signup_fee:Ve},media:Ue};Z[N].variants.push(Le)}),X("onDataPopulated",{products:Y,concat:G})},L=(G=!0)=>{if(g.value)return I(G);const Y=[];p.value.forEach(Z=>{var Ee,pe,ye,Ve,Le,At,mt,Mt,Dt,Xe,pt,jt;const de={};de._cid=hl();const j=m.value;de.post_title=Z[j.post_title.value]??"",de.post_name=Z[j.post_name.value]??de.post_title,de.ID=Z[j.post_id.value]??"",de.post_content=Z[j.post_content.value]??"",de.post_excerpt=Z[j.post_excerpt.value]??"",de.post_status=Z[(Ee=j.post_status)==null?void 0:Ee.value]||"published",de.comment_status="close";const ge=Z[(pe=j.images)==null?void 0:pe.value]||"",ie=[];ge&&ge.split(",").map(Ct=>Ct.trim()).filter(Boolean).forEach(Ct=>{const $t=Ct.split("/").pop().split("?")[0]||"image";ie.push({id:0,url:Ct,title:$t})});const W=Z[(ye=j.categories)==null?void 0:ye.value]||"";W?de.categories=W.split(",").map(Ct=>Ct.trim()).filter(Boolean):de.categories=[];const N=Z[(Ve=j.sku)==null?void 0:Ve.value]||"",ae=Z[(Le=j.payment_type)==null?void 0:Le.value]||"onetime",ee=Z[(At=j.repeat_interval)==null?void 0:At.value]||"",Ae=Z[(mt=j.trial_days)==null?void 0:mt.value]||"",re=Z[(Mt=j.installment)==null?void 0:Mt.value]||"",Ue=Z[(Dt=j.installment_count)==null?void 0:Dt.value]||"",we=Z[(Xe=j.manage_setup_fee)==null?void 0:Xe.value]||"",Be=Z[(pt=j.signup_fee_name)==null?void 0:pt.value]||"",ve=b(Z[(jt=j.signup_fee)==null?void 0:jt.value]||""),Ce={variation_type:"simple",manage_stock:"0",fulfillment_type:"physical"},Oe={description:"",payment_type:ae,times:Ue,repeat_interval:ee,trial_days:Ae,billing_summary:"",manage_setup_fee:we==="yes"?"yes":"no",signup_fee_name:Be,signup_fee:ve,setup_fee_per_item:"no",installment:re==="yes"?"yes":"no"};de.gallery=ie,de.variants=[];for(let Ct=1;Ct<=v;Ct++){const $t={};["variation_title","item_price","compare_price"].forEach(Ht=>{var Qt;const Nt=((Qt=j[Ht])==null?void 0:Qt.value)??"";if(Nt.length>0){const yt=Nt.replace("%d",Ct.toString()),Xt=Z[yt];$t[Ht]=Ht==="variation_title"?Xt:b(Xt)}}),H($t)&&($t._cid=hl(),$t.sku=N,$t.other_info={...Oe},$t.media=[],de.variants.push($t))}de.variants.length>0?(Ce.variation_type="simple_variations",de.detail=Ce,Y.push(de)):H(de)&&(de.variants.push({_cid:hl(),variation_title:"",sku:N,item_price:0,compare_price:0,other_info:{...Oe},media:[]}),de.detail=Ce,Y.push(de))}),X("onDataPopulated",{products:Y,concat:G})},O=()=>{l.value=!1,s.value=[],i.value=null,F()},M=(G=!0)=>{L(G),O()},H=G=>{let Y=!1;for(const[Z,de]of Object.entries(G))if(typeof de!==null&&typeof de<"u"&&(Array.isArray(de)&&de.length>0||de.toString().length>0)){Y=!0;break}return Y};De(()=>{m.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 z=()=>{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":""}],Y=Lc.unparse(G),Z=new Blob([Y],{type:"text/csv;charset=utf-8;"}),de=URL.createObjectURL(Z),j=document.createElement("a");j.href=de,j.download="fluent-cart-sample-import.csv",document.body.appendChild(j),j.click(),document.body.removeChild(j),URL.revokeObjectURL(de)},X=t;return(G,Y)=>{const Z=C("el-button"),de=C("el-upload"),j=C("el-option"),ge=C("el-select"),ie=C("el-dialog");return r(),h(P,null,[n(Z,{onClick:Y[0]||(Y[0]=W=>l.value=!0)},{default:u(()=>[R(f(G.$t("Import")),1)]),_:1}),n(ie,{modelValue:l.value,"onUpdate:modelValue":Y[4]||(Y[4]=W=>l.value=W),"append-to-body":!0,title:G.$t("Import Products"),class:"fct-bulk-import-dialog"},{default:u(()=>[k.value?B("",!0):(r(),E(de,{key:0,class:"fct-file-uploader",ref:"uploaderRef","file-list":s.value,"onUpdate:fileList":Y[1]||(Y[1]=W=>s.value=W),drag:"",action:$(),"on-progress":()=>{},"on-success":()=>{},"on-error":()=>{},"auto-upload":!1,"on-change":W=>{F(),i.value=W,x(W==null?void 0:W.raw)},multiple:!1,limit:1,"show-file-list":!0},{default:u(()=>[n(lt,{circle:"",bg:"primary",soft:""},{default:u(()=>[n(J,{name:"Upload"})]),_:1}),o("div",Q0e,[R(f(G.$t("Drag & Drop or"))+" ",1),o("em",null,f(G.$t("Browse/Upload")),1),R(" "+f(G.$t("Files"))+" ",1),o("span",null,f(c(d)("Any Format upto %s",c(Tt).serverMaxUploadSize())),1)])]),_:1},8,["file-list","action","on-change"])),k.value?B("",!0):(r(),E(Z,{key:1,onClick:z,link:""},{default:u(()=>[n(J,{name:"Download"}),R(" "+f(G.$t("Download a Sample CSV File")),1)]),_:1})),k.value?(r(),h(P,{key:2},[o("div",T0e,[o("h4",M0e,f(G.$t("Map Columns")),1),o("table",L0e,[o("thead",null,[o("tr",null,[o("th",null,f(G.$t("Products Fields")),1),o("th",null,f(G.$t("CSV Headers")),1)])]),o("tbody",null,[(r(!0),h(P,null,le(m.value,(W,N)=>(r(),h("tr",null,[o("td",null,f(W.title),1),o("td",R0e,[n(ge,{modelValue:W.value,"onUpdate:modelValue":ae=>W.value=ae,filterable:"",clearable:""},{default:u(()=>[(r(!0),h(P,null,le(_.value,ae=>(r(),E(j,{key:ae.value,label:ae.title,value:ae.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])])]))),256))])])]),o("div",O0e,[n(Z,{onClick:Y[2]||(Y[2]=W=>M())},{default:u(()=>[R(f(G.$t("Add Products")),1)]),_:1}),n(Z,{onClick:Y[3]||(Y[3]=W=>M(!1))},{default:u(()=>[R(f(G.$t("Clear and Add Products")),1)]),_:1})])],64)):B("",!0)]),_:1},8,["modelValue","title"])],64)}}};class H0e extends Rd{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=hl(),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(([A])=>A.startsWith(s)).map(([,A])=>A).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(A._cid));if(a.length===0){q.error(d("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 m of l){const _=m.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 ce.post("products/bulk-insert",{products:m});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(k=>k._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 k of _)this.data.productErrors.set(k,{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:A,errors:p}=this.data.saveProgress;p.length===0?q.success(`${A.length} product(s) created successfully`):A.length>0?q.info(`${A.length} product(s) created, ${p.length} error(s)`):q.error(d("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 ce.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=hl(),a.post_title=a.post_title?a.post_title+" (Copy)":"",a.variants&&Array.isArray(a.variants)&&a.variants.forEach(s=>{s.sku="",s._cid=hl()});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=hl(),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((A,p)=>i.has(p)),l.variants.forEach(A=>{A.sku="",A._cid=hl()})}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=hl(),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 A=a?`${a} > ${i.label}`:i.label;l.push({label:A,value:A}),(s=i.children)!=null&&s.length&&l.push(...this.flattenCategoryTree(i.children,A))}return l}async fetchCategories(){try{const a=(await ce.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=H0e.init(),N0e={class:"max-w-full overflow-x-scroll"},K0e={class:"relative"},G0e={key:0,class:"bulk-checkbox-cell"},z0e=["onMousedown","onTouchstart"],Qf={__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=rm(),s=od("table"),i=T(null);let A=null;De(()=>{Fe(()=>{const g=s.value.querySelectorAll("th"),y=l["header-first"]?1:0;Array.from(g).forEach((v,k)=>{const w=k-y;w<0||w>=p.columns.length||(p.columns[w].width=v.offsetWidth,p.columns[w].minWidth||(p.columns[w].minWidth=v.offsetWidth))}),A=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")}),A.observe(s.value)})}),Ya(()=>{A&&A.disconnect()});const p=e,m=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,k=p.columns[y].width,w=p.columns[y].minWidth||50;i.value=y;const b=F=>{const Q=k+(F.clientX-v);Q>=w&&(p.columns[y].width=Q)},x=()=>{i.value=null,document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",x),a("resize-end")};document.addEventListener("mousemove",b),document.addEventListener("mouseup",x)};return(g,y)=>(r(),h("div",N0e,[o("div",{class:ue(["resizable-table",{"is-resizing":i.value!==null}]),onScroll:y[0]||(y[0]=v=>a("scroll",v))},[o("div",K0e,[o("table",{id:"tb",ref_key:"table",ref:s,style:fa({tableLayout:"fixed",width:m.value+"px"})},[o("thead",null,[o("tr",null,[g.$slots["header-first"]?(r(),h("th",G0e,[wa(g.$slots,"header-first")])):B("",!0),(r(!0),h(P,null,le(e.columns,(v,k)=>(r(),h("th",{class:ue({"sticky-col":k===0,"sticky-col sticky-col-right":k===e.columns.length-1&&e.stickyLast}),style:fa({width:v.width+"px",zIndex:k===0||k===e.columns.length-1&&e.stickyLast?70:e.columns.length-k+50,left:k===0&&g.$slots["header-first"]?"40px":k===0?"0px":void 0}),key:v.key||k},[k===e.columns.length-1?wa(g.$slots,"header-last",{key:0},()=>[R(f(v.title),1)]):(r(),h(P,{key:1},[R(f(v.title),1)],64)),k_(w,k),onTouchstart:w=>_(w,k)},null,42,z0e)):B("",!0)],6))),128))])]),o("tbody",null,[wa(g.$slots,"default")])],4)])],34)]))}},j0e={class:"bulk-setup-fee-badge"},q0e={key:1,class:"text-gray-300 text-sm flex justify-center"},ai={__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 A;const i=C("el-tooltip");return e.variant?(r(),E(ll,{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")})},ca({_:2},[((A=e.variant.other_info)==null?void 0:A.manage_setup_fee)==="yes"&&e.variant.other_info.signup_fee?{name:"suffix",fn:u(()=>[n(i,{content:(e.variant.other_info.signup_fee_name||l.$t("Setup fee"))+": "+c(zt)(e.variant.other_info.signup_fee,!0),placement:"top","popper-class":"fct-tooltip"},{default:u(()=>[o("span",j0e,"+ "+f(l.$t("fee")),1)]),_:1},8,["content"])]),key:"0"}:void 0]),1032,["error-class","model-value","placeholder","disabled"])):(r(),h("span",q0e,"—"))}}},Y0e=["disabled"],W0e={key:0,class:"fct-bulk-sub-count"},X0e={class:"fct-bulk-sub-popover-body"},J0e={class:"fct-bulk-sub-popover-title"},Z0e={class:"fct-bulk-sub-section"},ewe={class:"fct-bulk-sub-row"},twe={class:"fct-bulk-sub-row"},awe={class:"fct-bulk-sub-label"},lwe={class:"fct-bulk-sub-row"},swe={class:"fct-bulk-sub-label"},nwe=["innerHTML"],owe={class:"fct-bulk-sub-section"},iwe={class:"fct-bulk-sub-row"},rwe={class:"fct-bulk-sub-row"},dwe={class:"fct-bulk-sub-label"},uwe={class:"fct-bulk-sub-row"},cwe={class:"fct-bulk-sub-label"},Awe={class:"fct-bulk-sub-footer"},fr=2,pwe={__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=Zt().ctx,i=je.get(),A=je.get("app_config.isProActive"),p=T(!1);K(()=>{var $;return(($=i==null?void 0:i.shop)==null?void 0:$.currency_sign)||"$"});const m=K(()=>{var $;return(($=a.variant)==null?void 0:$.other_info)||{}}),_=K(()=>m.value.payment_type==="subscription"),g=K(()=>m.value.installment==="yes"),y=K(()=>Number(m.value.times)||1),v=K(()=>{var S;const $=Number((S=a.variant)==null?void 0:S.item_price)||0;return g.value?$*y.value:$}),k=K(()=>{const $=[];if(g.value&&$.push(s.$t("Installment")+": "+y.value+"x"),m.value.manage_setup_fee==="yes"){const S=m.value.signup_fee_name||s.$t("Setup fee"),U=m.value.signup_fee||0;$.push(s.$t("Setup fee")+": "+S+" ("+zt(U,!0)+")")}return $.length>0?$.join(`
`):s.$t("Subscription settings")}),w=$=>{$==="no"?a.variant.other_info.times="":b(),l("changed")},b=()=>{const $=Number(a.variant.other_info.times);(!Number.isFinite($)||${$==="no"&&(a.variant.other_info.signup_fee=""),l("changed")},F=()=>{l("changed")},Q=()=>{p.value=!1};return($,S)=>{const U=C("el-checkbox"),V=C("el-tooltip"),D=C("el-input"),I=C("el-switch"),L=C("el-button"),O=C("el-popover");return r(),E(V,{content:k.value,placement:"top",disabled:!_.value||p.value,"popper-class":"fct-tooltip","show-after":400},{default:u(()=>[n(O,{visible:p.value,"onUpdate:visible":S[6]||(S[6]=M=>p.value=M),placement:"bottom",width:320,trigger:"click",disabled:e.disabled||!_.value,"popper-class":"bulk-sub-popover"},{reference:u(()=>[o("button",{class:ue(["fc-bulk-sub-icon-btn",{"is-active":_.value,"is-configured":_.value&&(g.value||m.value.manage_setup_fee==="yes")}]),disabled:e.disabled||!_.value,onClick:S[0]||(S[0]=Ge(()=>{},["prevent"]))},[S[7]||(S[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",W0e,f(y.value),1)):B("",!0)],10,Y0e)]),default:u(()=>[o("div",X0e,[o("h4",J0e,f($.$t("Subscription Settings")),1),o("div",Z0e,[o("div",ewe,[n(U,{"true-value":"yes","false-value":"no",label:$.$t("Enable installment payment"),modelValue:e.variant.other_info.installment,"onUpdate:modelValue":S[1]||(S[1]=M=>e.variant.other_info.installment=M),disabled:!c(A)||e.disabled,onChange:w},null,8,["label","modelValue","disabled"]),c(A)?B("",!0):(r(),E(V,{key:0,"popper-class":"fct-tooltip"},{content:u(()=>[R(f($.$t("This feature is available in pro version only.")),1)]),default:u(()=>[n(J,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),m.value.installment==="yes"?(r(),h(P,{key:0},[o("div",twe,[o("label",awe,f($.$t("Installment Count")),1),n(D,{type:"number",min:fr,size:"small",modelValue:e.variant.other_info.times,"onUpdate:modelValue":S[2]||(S[2]=M=>e.variant.other_info.times=M),modelModifiers:{number:!0},placeholder:$.$t("Count"),style:{width:"100px"},onInput:F,onChange:b},null,8,["modelValue","placeholder"])]),o("div",lwe,[o("span",swe,f($.$t("Total Price")),1),o("span",{class:"fct-bulk-sub-value",innerHTML:c(zt)(v.value,!0)},null,8,nwe)])],64)):B("",!0)]),o("div",owe,[o("div",iwe,[n(I,{"active-text":$.$t("Setup fee"),modelValue:e.variant.other_info.manage_setup_fee,"onUpdate:modelValue":S[3]||(S[3]=M=>e.variant.other_info.manage_setup_fee=M),"active-value":"yes","inactive-value":"no",disabled:!c(A)||e.disabled,size:"small",onChange:x},null,8,["active-text","modelValue","disabled"]),c(A)?B("",!0):(r(),E(V,{key:0,"popper-class":"fct-tooltip"},{content:u(()=>[R(f($.$t("This feature is available in pro version only.")),1)]),default:u(()=>[n(J,{name:"Crown",class:"fct-pro-icon"})]),_:1}))]),m.value.manage_setup_fee==="yes"?(r(),h(P,{key:0},[o("div",rwe,[o("label",dwe,f($.$t("Label")),1),n(D,{size:"small",modelValue:e.variant.other_info.signup_fee_name,"onUpdate:modelValue":S[4]||(S[4]=M=>e.variant.other_info.signup_fee_name=M),placeholder:$.$t("e.g. Initial Setup"),onInput:F},null,8,["modelValue","placeholder"])]),o("div",uwe,[o("label",cwe,f($.$t("Amount")),1),n(ll,{size:"small","model-value":e.variant.other_info.signup_fee,placeholder:$.$t("Amount"),"onUpdate:modelValue":S[5]||(S[5]=M=>{e.variant.other_info.signup_fee=M,F()})},null,8,["model-value","placeholder"])])],64)):B("",!0)]),o("div",Awe,[n(L,{size:"small",type:"primary",onClick:Q},{default:u(()=>[R(f($.$t("Done")),1)]),_:1})])])]),_:1},8,["visible","disabled"])]),_:1},8,["content","disabled"])}}},fwe={key:0,class:"flex items-center"},mwe={key:1,class:"text-gray-300 text-sm flex justify-center"},li={__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,A)=>{const p=C("el-option"),m=C("el-select");return e.variant&&s()?(r(),h("div",fwe,[n(m,{modelValue:e.variant.other_info.payment_type,"onUpdate:modelValue":A[0]||(A[0]=_=>e.variant.other_info.payment_type=_),size:"small",class:ue({"is-field-error":e.hasError}),disabled:e.disabled,onChange:A[1]||(A[1]=_=>l("payment-type-change",e.variant))},{default:u(()=>[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(pwe,{variant:e.variant,disabled:e.disabled,onChanged:A[2]||(A[2]=_=>l("change"))},null,8,["variant","disabled"])])):(r(),h("span",mwe,"—"))}}},hwe={key:1,class:"text-gray-300 text-sm flex justify-center"},si={__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,A;return((A=(i=a.variant)==null?void 0:i.other_info)==null?void 0:A.payment_type)==="subscription"};return(i,A)=>{const p=C("el-option"),m=C("el-select");return e.variant&&s()?(r(),E(m,{key:0,modelValue:e.variant.other_info.repeat_interval,"onUpdate:modelValue":A[0]||(A[0]=_=>e.variant.other_info.repeat_interval=_),size:"small",class:ue({"is-field-error":e.hasError}),disabled:e.disabled,onChange:A[1]||(A[1]=_=>l("change"))},{default:u(()=>[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",hwe,"—"))}}},_we={key:1,class:"text-gray-300 text-sm flex justify-center"},ni={__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,A;return((A=(i=a.variant)==null?void 0:i.other_info)==null?void 0:A.payment_type)==="subscription"};return(i,A)=>{const p=C("el-input");return e.variant&&s()?(r(),E(p,{key:0,class:ue(["fct-bulk-input",{"is-error":e.hasError}]),modelValue:e.variant.other_info.trial_days,"onUpdate:modelValue":A[0]||(A[0]=m=>e.variant.other_info.trial_days=m),placeholder:"0",disabled:e.disabled,onChange:A[1]||(A[1]=m=>l("change")),size:"small"},null,8,["class","modelValue","disabled"])):(r(),h("span",_we,"—"))}}},vwe={key:1,class:"text-gray-300 text-sm flex justify-center"},oi={__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(ll,{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",vwe,"—"))}},Tf={__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 A=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:u(()=>[(r(!0),h(P,null,le(e.options,m=>(r(),E(A,{key:m.value,label:m.label,value:m.value},null,8,["label","value"]))),128))]),_:1},8,["model-value","placeholder","disabled"])}}},gwe=["textContent"],ywe={key:1,class:"fct-bulk-editor-placeholder"},ii={__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:f(e.value)},null,8,gwe)):(r(),h("span",ywe,f(e.placeholder),1))]))}};function Mf(){const e=T(new Set),t=T(null),a=T(!1),l=(y,v,k)=>{if(v.shiftKey&&t.value!==null){const b=k.indexOf(t.value),x=k.indexOf(y);if(b!==-1&&x!==-1){const F=Math.min(b,x),Q=Math.max(b,x),$=new Set(e.value);for(let S=F;S<=Q;S++)$.add(k[S]);e.value=$}}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)},A=()=>{e.value=new Set,t.value=null,a.value=!1},p=()=>{a.value?a.value=!1:e.value.size>=2&&(a.value=!0)};ke(e,y=>{a.value&&y.size<2&&(a.value=!1)});const m=y=>e.value.has(y),_=K(()=>e.value.size);return{selectedKeys:e,lastClickedKey:t,isLinkMode:a,handleRowClick:l,toggleSelectAll:s,selectAll:i,deselectAll:A,toggleLinkMode:p,isSelected:m,selectedCount:_,pruneStaleKeys:y=>{const v=new Set(y);let k=!1;const w=new Set;for(const b of e.value)v.has(b)?w.add(b):k=!0;k&&(e.value=w),t.value&&!v.has(t.value)&&(t.value=null)}}}const bwe={mounted(e,t){e.indeterminate=!!t.value},updated(e,t){e.indeterminate=!!t.value}},Lf={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]}}},wwe={...Lf,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}}},Cwe={...Lf,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 Rf(e,t,a,l,s,i,A){const p=A[e];if(p)for(const m of l){if(m===a)continue;const _=s(m);if(!_)continue;const g=p[_.type];g&&(g.set(_.data,t),i&&i(_.product))}}const kwe={class:"fct-bulk-insert-page fct-layout-width"},Bwe={class:"fct-btn-group sm justify-end"},xwe={class:"filter-popover-item"},Swe={class:"filter-popover-title"},$we={key:0,"aria-hidden":"true"},Fwe=["colspan"],Ewe=["onClick"],Uwe=["onClick"],Iwe={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},Vwe={class:"flex items-center"},Dwe=["onClick","title"],Qwe={key:0,class:"bulk-collapse-count"},Twe=["title"],Mwe=["title"],Lwe={class:"bulk-status-icon is-error"},Rwe={key:0,class:"fct-bulk-sku-cell"},Owe={key:1,class:"text-gray-300 text-sm flex justify-center"},Pwe={key:1,class:"fct-bulk-media-cell"},Hwe={key:2,class:"fct-bulk-categories-cell"},Nwe={key:3,class:"fct-bulk-desc-cell"},Kwe={key:4,class:"fct-bulk-short-desc-cell"},Gwe={key:5,class:"fct-bulk-status-cell"},zwe={key:6,class:"fct-bulk-product-type-cell"},jwe={key:7,class:"fct-bulk-product-type-cell"},qwe={key:8,class:"fct-bulk-pricing-type-cell"},Ywe={key:9,class:"fct-bulk-pricing-type-cell"},Wwe={key:10,class:"fct-bulk-payment-type-cell"},Xwe={key:11,class:"fct-bulk-interval-cell"},Jwe={key:12,class:"fct-bulk-trial-days-cell"},Zwe={key:13,class:"fct-bulk-best-price-cell"},eCe={key:14,class:"fct-bulk-compare-price-cell"},tCe={key:15,class:"fct-bulk-qty-cell !pl-5"},aCe={key:16,class:"fct-bulk-stock-cell"},lCe={key:1,class:"text-gray-300 text-sm pl-5"},sCe={class:"fct-btn-group xs justify-end"},nCe=["href","title"],oCe={key:0,class:"bulk-variants-block-row"},iCe=["colspan"],rCe={class:"bulk-inner-table",style:{tableLayout:"fixed",width:"100%",borderCollapse:"collapse"}},dCe=["onClick"],uCe={class:"bulk-checkbox-cell"},cCe={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},ACe={class:"flex items-center gap-1 pl-4"},pCe={class:"bulk-status-icon is-error"},fCe={key:0,class:"fct-bulk-sku-cell"},mCe={key:1,class:"fct-bulk-media-cell"},hCe={key:2},_Ce={key:3},vCe={key:4},gCe={key:5},yCe={key:6},bCe={key:7},wCe={key:8},CCe={key:9},kCe={key:10},BCe={key:11},xCe={key:12},SCe={key:13,class:"text-center"},$Ce={key:14},FCe={key:1,class:"text-gray-300 text-sm flex justify-center"},ECe={class:"fct-btn-group sm justify-end"},UCe={class:"bulk-add-variant-row"},ICe=["colspan"],VCe={class:"sticky left-0 inline-block pl-6"},DCe={key:1,"aria-hidden":"true"},QCe=["colspan"],mr=43,TCe=10,MCe=800,Rc=100,LCe={__name:"BulkInsert",setup(e){const{options:t,products:a}=Ft.data,l=be=>{var Ie;return((Ie=be==null?void 0:be.detail)==null?void 0:Ie.variation_type)==="simple"},s=K(()=>Ft.data.saving),i=K(()=>Ft.data.saveProgress),A=K(()=>{const be=Ft.data.saveProgress;return be.total?Math.round(be.completed/be.total*100):0}),p=()=>{Ft.saveProducts()},m=be=>Ft.isSaving(be._cid),_=be=>Ft.isSaved(be._cid),g=be=>Ft.isRowDisabled(be._cid),y=be=>Ft.hasError(be._cid),v=be=>Ft.getError(be._cid),k=be=>Ft.hasProductLevelError(be._cid),w=(be,Ie)=>Ft.hasVariantError(be._cid,Ie),b=(be,Ie)=>Ft.getVariantError(be._cid,Ie),x=(be,Ie)=>Ft.hasFieldError(be._cid,Ie),F=(be,Ie,it)=>Ft.hasVariantFieldError(be._cid,Ie,it),Q=async be=>{const Ie=be.post_title||H.$t("Untitled product"),it=Array.isArray(be.variants)?be.variants.length:0,kt=Ft.isSaved(be._cid);let Bt=it>0?H.$t('This will remove "%1$s" and its %2$s variant(s).',Ie,it):H.$t('This will remove "%1$s".',Ie);kt&&(Bt+=" "+H.$t("This product was already saved and will be permanently deleted."));try{await El.confirm(Bt,H.$t("Remove Product"),{confirmButtonText:H.$t("Remove"),cancelButtonText:H.$t("Cancel"),type:"warning"})}catch{return}await Ft.removeProduct(be)},$=(be,Ie)=>{const it=Ie.variation_title||H.$t("Untitled variant");El.confirm(H.$t('This will remove the variant "%1$s".',it),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(be,Ie)}).catch(()=>{})},S=be=>Ft.duplicateProduct(be),U=(be,Ie)=>Ft.duplicateVariant(be,Ie),V=()=>{const be=[];for(const Ie of a){const it=`p:${Ie._cid}`,kt=ge.value.has(it),Bt=[];Ie.variants&&Ie.variants.forEach((ta,bt)=>{ge.value.has(`v:${Ie._cid}:${bt}`)&&Bt.push(bt)}),!(!kt&&Bt.length===0)&&(kt&&Bt.length===0?be.push({product:Ie,type:"full"}):!kt&&Bt.length>0?be.push({product:Ie,type:"variants-only",variantIndexes:Bt}):be.push({product:Ie,type:"partial",variantIndexes:Bt}))}return be},D=()=>{const be=V();if(!be.length)return;const Ie=be.filter(bt=>bt.type==="full").length,it=be.filter(bt=>bt.type==="partial").length,Bt=be.filter(bt=>bt.type==="variants-only").reduce((bt,sa)=>bt+sa.variantIndexes.length,0),ta=[];Ie>0&&ta.push(`${Ie} product(s) with all variants`),it>0&&ta.push(`${it} product(s) with selected variants`),Bt>0&&ta.push(`${Bt} variant(s)`),El.confirm(H.$t("Duplicate %s?").replace("%s",ta.join(", ")),H.$t("Bulk Duplicate"),{confirmButtonText:H.$t("Duplicate"),cancelButtonText:H.$t("Cancel"),type:"info"}).then(()=>{for(const bt of be)if(bt.type==="full")Ft.duplicateProduct(bt.product);else if(bt.type==="variants-only")for(const sa of bt.variantIndexes){const na=bt.product.variants[sa];na&&Ft.duplicateVariant(bt.product,na)}else bt.type==="partial"&&Ft.duplicateProductWithVariants(bt.product,bt.variantIndexes);ae()}).catch(()=>{})},I=async()=>{const be=[],Ie=[];for(const bt of a){const sa=`p:${bt._cid}`;if(ge.value.has(sa)){be.push(bt);continue}const qt=[];bt.variants&&bt.variants.forEach((ka,Ja)=>{ge.value.has(`v:${bt._cid}:${Ja}`)&&qt.push(ka)}),qt.length>0&&Ie.push({product:bt,variants:qt})}if(!be.length&&!Ie.length)return;const it=be.filter(bt=>Ft.isSaved(bt._cid)).length,kt=Ie.reduce((bt,sa)=>bt+sa.variants.length,0),Bt=[];be.length>0&&Bt.push(`${be.length} product(s)`),kt>0&&Bt.push(`${kt} variant(s)`);let ta=H.$t("Remove %s?").replace("%s",Bt.join(" and "));it>0&&(ta+=" "+H.$t("%s already saved will be permanently deleted.").replace("%s",`${it}`));try{await El.confirm(ta,H.$t("Bulk Remove"),{confirmButtonText:H.$t("Remove"),cancelButtonText:H.$t("Cancel"),type:"warning"})}catch{return}for(const bt of be)await Ft.removeProduct(bt);for(const{product:bt,variants:sa}of Ie)for(const na of sa)Ft.removeVariant(bt,na);ae()},L=be=>{Ft.resetPaymentTypeDefaults(be)},O=(be,Ie)=>{const it=Ft.data.categoryOptions;for(const kt of Ie)it.find(Bt=>Bt.value===kt)||it.push({label:kt,value:kt})},M=()=>{Ft.populateDummyProduct()},H=Zt().ctx,z=be=>{const Ie=Ft.data.products;be.concat||(Ie.splice(0,Ie.length),Ft.data.savedIds=new Set,Ft.data.savingIds=new Set,Ft.data.productErrors=new Map),Ie.push(...be.products)},X=T({visible:!1,field:"",product:null,value:""}),G=(be,Ie)=>{X.value={visible:!0,field:Ie,product:be,value:be[Ie]||""}},Y=be=>{X.value.value=be},Z=()=>{const{product:be,field:Ie,value:it}=X.value;be&&(be[Ie]=it),X.value.visible=!1},de=K(()=>X.value.field==="post_content"?H.$t("Edit Description"):H.$t("Edit Short Description")),j=T(!0),{selectedKeys:ge,handleRowClick:ie,toggleSelectAll:W,selectAll:N,deselectAll:ae,isSelected:ee,selectedCount:Ae,isLinkMode:re,toggleLinkMode:Ue}=Mf(),we=K(()=>{const be=[];for(const Ie of pt.value)if(be.push(`p:${Ie.productId}`),Ie.hasVariants&&!Ie.collapsed)for(let it=0;it{var Ie;if(be.startsWith("p:")){const it=be.slice(2),kt=a.find(Bt=>Bt._cid===it);return kt?{type:"product",data:kt,product:kt}:null}else if(be.startsWith("v:")){const it=be.split(":"),kt=it[1],Bt=parseInt(it[2]),ta=a.find(bt=>bt._cid===kt);if(ta&&((Ie=ta.variants)!=null&&Ie[Bt]))return{type:"variant",data:ta.variants[Bt],product:ta}}return null},ve=(be,Ie,it)=>{!re.value||!ee(it)||Rf(be,Ie,it,ge.value,Be,null,wwe)},Ce=T(!1),Oe=be=>{be.key==="Shift"&&(Ce.value=!0)},Ee=be=>{be.key==="Shift"&&(Ce.value=!1)},pe=(be,Ie)=>{if(!Ie.shiftKey||Ie.target.closest(".bulk-checkbox-cell"))return;Ie.preventDefault();const it=new Set(ge.value);it.has(be)?it.delete(be):it.add(be),ge.value=it},ye=T([]),Ve=K(()=>ye.value.filter(be=>be.key==="title"||be.key==="actions"?!0:Ft.isColumnVisible(be.key))),Le=be=>Ft.isColumnVisible(be),At=()=>{Ft.saveColumnWidths(ye.value)},mt=T(new Set),Mt=be=>{const Ie=be._cid;mt.value.has(Ie)?mt.value.delete(Ie):mt.value.add(Ie),mt.value=new Set(mt.value)},Dt=be=>mt.value.has(be._cid),Xe=T(0),pt=K(()=>{let be=0;return a.map(Ie=>{var qt;const it=Ie._cid,kt=((qt=Ie.detail)==null?void 0:qt.variation_type)!=="simple"&&Array.isArray(Ie.variants),Bt=kt?Ie.variants.length:0,ta=mt.value.has(it),bt=kt&&!ta?(Bt+1)*mr:0,sa=mr+bt,na={product:Ie,productId:it,hasVariants:kt,variantCount:Bt,collapsed:ta,groupHeight:sa,offset:be};return be+=sa,na})}),jt=K(()=>{const be=pt.value;if(be.length===0)return 0;const Ie=be[be.length-1];return Ie.offset+Ie.groupHeight}),Ct=K(()=>{const be=pt.value,Ie=Xe.value,it=Ie+MCe,kt=TCe*mr;return be.filter(Bt=>Bt.offset+Bt.groupHeight>=Ie-kt&&Bt.offset<=it+kt)}),$t=K(()=>Ct.value.length===0?0:Ct.value[0].offset),Ht=K(()=>{if(Ct.value.length===0)return 0;const be=Ct.value[Ct.value.length-1];return jt.value-be.offset-be.groupHeight});let Nt=null,Qt=0;const yt=be=>{const Ie=be.target,it=Date.now();Nt&&clearTimeout(Nt),it-Qt>=Rc?(Xe.value=Ie.scrollTop,Qt=it):Nt=setTimeout(()=>{Xe.value=Ie.scrollTop,Qt=Date.now(),Nt=null},Rc)};let Xt=null;return De(async()=>{Xt=is(),Xt.bind("mod+a",be=>{var it,kt;const Ie=(it=document.activeElement)==null?void 0:it.tagName;Ie==="INPUT"||Ie==="TEXTAREA"||(kt=document.activeElement)!=null&&kt.isContentEditable||(be.preventDefault(),N(we.value))}),Xt.bind("escape",()=>{var Ie,it;const be=(Ie=document.activeElement)==null?void 0:Ie.tagName;be==="INPUT"||be==="TEXTAREA"||(it=document.activeElement)!=null&&it.isContentEditable||(re.value?Ue():ae())}),ye.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(ye.value),Ft.setupColumnVisibility(),Ft.fetchCategories(),document.body.classList.add("fct-bulk-page"),window.addEventListener("keydown",Oe),window.addEventListener("keyup",Ee)}),Ya(()=>{document.body.classList.remove("fct-bulk-page"),window.removeEventListener("keydown",Oe),window.removeEventListener("keyup",Ee),Xt&&Xt.reset()}),(be,Ie)=>{const it=C("el-button"),kt=C("el-progress"),Bt=C("el-checkbox"),ta=C("el-checkbox-group"),bt=C("el-tooltip"),sa=C("el-popover"),na=C("el-input"),qt=C("el-icon"),ka=C("el-option"),Ja=C("el-select"),ul=C("el-switch"),Za=C("el-dialog");return r(),h("div",kwe,[n(nl,{title:be.$t("Bulk Insert")},{action:u(()=>[n(P0e,{onOnDataPopulated:z}),n(it,{onClick:M},{default:u(()=>[R(f(be.$t("Add Product")),1)]),_:1}),n(it,{type:"primary",onClick:p,loading:s.value,disabled:s.value||c(a).length===0},{default:u(()=>[R(f(s.value?be.$t("Saving %s/%s...").replace("%s",i.value.completed).replace("%s",i.value.total):be.$t("Save All Products")),1)]),_:1},8,["loading","disabled"])]),_:1},8,["title"]),s.value?(r(),E(kt,{key:0,percentage:A.value,"stroke-width":6,class:"mb-4"},null,8,["percentage"])):B("",!0),n($e,null,{default:u(()=>{var va;return[c(a).length>0?(r(),E(Qe,{key:0,title:((va=c(a))==null?void 0:va.length)===1?be.$t("Product"):be.$t("Products"),border_bottom:""},{action:u(()=>[o("div",Bwe,[n(it,{disabled:c(Ae)===0,onClick:I,size:"small",type:"danger",soft:""},{default:u(()=>[Ie[8]||(Ie[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(" "+f(be.$t("Delete")),1)]),_:1,__:[8]},8,["disabled"]),n(it,{disabled:c(Ae)===0,onClick:D,size:"small",type:"info",soft:""},{default:u(()=>[Ie[9]||(Ie[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(" "+f(be.$t("Duplicate")),1)]),_:1,__:[9]},8,["disabled"]),n(it,{class:ue({"is-active":c(re)}),disabled:c(Ae)<2&&!c(re),onClick:c(Ue),size:"small",type:"info",soft:""},{default:u(()=>[Ie[10]||(Ie[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(" "+f(c(re)?be.$t("Unlink"):be.$t("Link")),1)]),_:1,__:[10]},8,["class","disabled","onClick"]),n(Bt,{modelValue:j.value,"onUpdate:modelValue":Ie[0]||(Ie[0]=te=>j.value=te),label:be.$t("Pin Actions")},null,8,["modelValue","label"]),n(sa,{trigger:"click",placement:"bottom-end",width:"240","popper-class":"filter-popover"},{reference:u(()=>[o("span",null,[n(bt,{effect:"light",content:be.$t("Toggle columns"),placement:"top","popper-class":"fct-tooltip"},{default:u(()=>[n(lt,{tag:"button",size:"small"},{default:u(()=>[n(J,{name:"ColumnIcon"})]),_:1})]),_:1},8,["content"])])]),default:u(()=>[o("div",xwe,[o("h3",Swe,f(be.$t("Columns")),1),n(ta,{modelValue:c(Ft).data.visibleColumns,"onUpdate:modelValue":Ie[1]||(Ie[1]=te=>c(Ft).data.visibleColumns=te),class:"fct-checkbox-blocks",onChange:Ie[2]||(Ie[2]=te=>c(Ft).handleColumnVisibilityChange())},{default:u(()=>[(r(!0),h(P,null,le(c(Ft).getToggleableColumns(),te=>(r(),E(Bt,{key:te.value,value:te.value,label:be.$t(te.label)},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])]),_:1})])]),_:1},8,["title"])):B("",!0),n(xe,{class:"p-0"},{default:u(()=>[c(a).length>0?(r(),h("div",{key:0,class:ue(["relative",{"is-link-mode":c(re),"is-shift-held":Ce.value}])},[n(Qf,{columns:Ve.value,"sticky-last":j.value,onScroll:yt,onResizeEnd:At},{"header-first":u(()=>[n(Bt,{"model-value":c(Ae)>0&&c(Ae)===we.value.length,indeterminate:c(Ae)>0&&c(Ae)c(W)(we.value))},null,8,["model-value","indeterminate"])]),"header-last":u(()=>[R(f(be.$t("Actions")),1)]),default:u(()=>[$t.value>0?(r(),h("tr",$we,[o("td",{colspan:Ve.value.length+1,style:fa({height:$t.value+"px",padding:0,border:"none"})},null,12,Fwe)])):B("",!0),(r(!0),h(P,null,le(Ct.value,te=>{var Se,ne,he,We,ot,qe,Ze,gt,tt,Vt,fe,_e,Ne,Pe,ft;return r(),h(P,{key:te.productId},[o("tr",{class:ue(["bulk-product-row",{"is-saving":m(te.product),"is-saved":_(te.product),"has-product-error":y(te.product),"is-selected":c(ee)(`p:${te.productId}`)}]),onClick:se=>pe(`p:${te.productId}`,se)},[o("td",{class:"bulk-checkbox-cell",onClick:se=>c(ie)(`p:${te.productId}`,se,we.value)},[n(Bt,{"model-value":c(ee)(`p:${te.productId}`),tabindex:"-1"},null,8,["model-value"])],8,Uwe),o("td",Iwe,[o("div",Vwe,[te.hasVariants?(r(),h("button",{key:0,class:"bulk-collapse-btn",onClick:Ge(se=>Mt(te.product),["prevent"]),title:Dt(te.product)?be.$t("Expand variants"):be.$t("Collapse variants")},[(r(),h("svg",{class:ue(["bulk-collapse-icon",{"is-collapsed":Dt(te.product)}]),width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},Ie[11]||(Ie[11]=[o("path",{d:"M6 4L10 8L6 12",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2)),Dt(te.product)?(r(),h("span",Qwe,f(te.variantCount),1)):B("",!0)],8,Dwe)):B("",!0),n(na,{class:ue(["fct-bulk-input",{"is-error":x(te.product,"post_title")}]),modelValue:te.product.post_title,"onUpdate:modelValue":se=>te.product.post_title=se,placeholder:be.$t("Product title"),size:"small",disabled:g(te.product),onInput:se=>ve("title",se,`p:${te.productId}`)},null,8,["class","modelValue","onUpdate:modelValue","placeholder","disabled","onInput"]),m(te.product)?(r(),h("span",{key:1,class:"bulk-status-icon is-syncing",title:be.$t("Saving...")},[n(qt,{class:"is-loading",size:14},{default:u(()=>[n(c(ln))]),_:1})],8,Twe)):_(te.product)?(r(),h("span",{key:2,class:"bulk-status-icon is-saved",title:be.$t("Saved")},Ie[12]||(Ie[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,Mwe)):k(te.product)||l(te.product)&&y(te.product)?(r(),E(bt,{key:3,content:v(te.product),placement:"top"},{default:u(()=>[o("span",Lwe,[n(qt,{size:16},{default:u(()=>[n(c(Mo))]),_:1})])]),_:2},1032,["content"])):B("",!0)])]),Le("sku")?(r(),h("td",Rwe,[((ne=(Se=te.product)==null?void 0:Se.detail)==null?void 0:ne.variation_type)==="simple"&&((he=te.product.variants)!=null&&he[0])?(r(),E(na,{key:0,class:ue(["fct-bulk-input",{"is-error":x(te.product,"variants.0.sku")}]),modelValue:te.product.variants[0].sku,"onUpdate:modelValue":[se=>te.product.variants[0].sku=se,se=>ve("sku",se,`p:${te.productId}`)],placeholder:"SKU",size:"small",disabled:g(te.product)},null,8,["class","modelValue","onUpdate:modelValue","disabled"])):(r(),h("span",Owe,"—"))])):B("",!0),Le("media")?(r(),h("td",Pwe,[n(bl,{modelValue:te.product.gallery,"onUpdate:modelValue":se=>te.product.gallery=se,"show-url-tab":"",disabled:g(te.product)},null,8,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0),Le("categories")?(r(),h("td",Hwe,[n(Tf,{modelValue:te.product.categories,"onUpdate:modelValue":se=>te.product.categories=se,options:c(Ft).data.categoryOptions,disabled:g(te.product),onChange:se=>{O(te.product,se),ve("categories",te.product.categories,`p:${te.productId}`)}},null,8,["modelValue","onUpdate:modelValue","options","disabled","onChange"])])):B("",!0),Le("description")?(r(),h("td",Nwe,[n(ii,{value:te.product.post_content,placeholder:be.$t("Description"),onClick:se=>G(te.product,"post_content")},null,8,["value","placeholder","onClick"])])):B("",!0),Le("short_description")?(r(),h("td",Kwe,[n(ii,{value:te.product.post_excerpt,placeholder:be.$t("Short description"),onClick:se=>G(te.product,"post_excerpt")},null,8,["value","placeholder","onClick"])])):B("",!0),Le("status")?(r(),h("td",Gwe,[n(Ja,{modelValue:te.product.post_status,"onUpdate:modelValue":se=>te.product.post_status=se,size:"small",class:ue({"is-field-error":x(te.product,"post_status")}),disabled:g(te.product),onChange:se=>ve("status",te.product.post_status,`p:${te.productId}`)},{default:u(()=>[(r(!0),h(P,null,le(c(t).status,se=>(r(),E(ka,{key:se.value,label:be.$t(se.title),value:se.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):B("",!0),Le("product_type")&&((We=te.product)!=null&&We.detail)?(r(),h("td",zwe,[n(Ja,{modelValue:te.product.detail.fulfillment_type,"onUpdate:modelValue":se=>te.product.detail.fulfillment_type=se,size:"small",class:ue({"is-field-error":x(te.product,"detail.fulfillment_type")}),disabled:g(te.product),onChange:se=>ve("product_type",te.product.detail.fulfillment_type,`p:${te.productId}`)},{default:u(()=>[(r(!0),h(P,null,le(c(t).fulfilment,se=>(r(),E(ka,{key:se.value,label:be.$t(se.title),value:se.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):Le("product_type")?(r(),h("td",jwe)):B("",!0),Le("pricing_type")&&((ot=te.product)!=null&&ot.detail)?(r(),h("td",qwe,[n(Ja,{modelValue:te.product.detail.variation_type,"onUpdate:modelValue":se=>te.product.detail.variation_type=se,size:"small",class:ue({"is-field-error":x(te.product,"detail.variation_type")}),disabled:g(te.product),onChange:se=>{c(Ft).handleVariationChanged(te.product,se),ve("pricing_type",se,`p:${te.productId}`)}},{default:u(()=>[(r(!0),h(P,null,le(c(t).variation,se=>(r(),E(ka,{key:se.value,label:be.$t(se.title),value:se.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):Le("pricing_type")?(r(),h("td",Ywe)):B("",!0),Le("payment_type")?(r(),h("td",Wwe,[n(li,{variant:l(te.product)?(qe=te.product.variants)==null?void 0:qe[0]:null,disabled:g(te.product),"has-error":x(te.product,"variants.0.other_info.payment_type"),onPaymentTypeChange:se=>{var ze;L(se),ve("payment_type",(ze=se.other_info)==null?void 0:ze.payment_type,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onPaymentTypeChange"])])):B("",!0),Le("interval")?(r(),h("td",Xwe,[n(si,{variant:l(te.product)?(Ze=te.product.variants)==null?void 0:Ze[0]:null,disabled:g(te.product),"has-error":x(te.product,"variants.0.other_info.repeat_interval"),onChange:se=>{var ze,_t,Me;return ve("interval",(Me=(_t=(ze=te.product.variants)==null?void 0:ze[0])==null?void 0:_t.other_info)==null?void 0:Me.repeat_interval,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("trial_days")?(r(),h("td",Jwe,[n(ni,{variant:l(te.product)?(gt=te.product.variants)==null?void 0:gt[0]:null,disabled:g(te.product),"has-error":x(te.product,"variants.0.other_info.trial_days"),onChange:se=>{var ze,_t,Me;return ve("trial_days",(Me=(_t=(ze=te.product.variants)==null?void 0:ze[0])==null?void 0:_t.other_info)==null?void 0:Me.trial_days,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("best_price")?(r(),h("td",Zwe,[n(ai,{variant:l(te.product)?(tt=te.product.variants)==null?void 0:tt[0]:null,disabled:g(te.product),"has-error":x(te.product,"variants.0.item_price"),onChange:se=>{var ze,_t;return ve("price",(_t=(ze=te.product.variants)==null?void 0:ze[0])==null?void 0:_t.item_price,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("compare_price")?(r(),h("td",eCe,[n(oi,{variant:l(te.product)?(Vt=te.product.variants)==null?void 0:Vt[0]:null,disabled:g(te.product),"has-error":x(te.product,"variants.0.compare_price"),onChange:se=>{var ze,_t;return ve("compare_price",(_t=(ze=te.product.variants)==null?void 0:ze[0])==null?void 0:_t.compare_price,`p:${te.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("track_quantity")?(r(),h("td",tCe,[(fe=te.product)!=null&&fe.detail?(r(),E(ul,{key:0,modelValue:te.product.detail.manage_stock,"onUpdate:modelValue":se=>te.product.detail.manage_stock=se,"active-value":"1","inactive-value":"0",disabled:g(te.product),onChange:se=>{c(Ft).syncStockStatus(te.product),ve("manage_stock",te.product.detail.manage_stock,`p:${te.productId}`)}},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])):B("",!0)])):B("",!0),Le("stock")?(r(),h("td",aCe,[((Ne=(_e=te.product)==null?void 0:_e.detail)==null?void 0:Ne.manage_stock)==="1"&&((ft=(Pe=te.product)==null?void 0:Pe.detail)==null?void 0:ft.variation_type)==="simple"?(r(),E(na,{key:0,modelValue:te.product.detail.total_stock,"onUpdate:modelValue":[se=>te.product.detail.total_stock=se,se=>{var ze;(ze=te.product.variants)!=null&&ze[0]&&(te.product.variants[0].total_stock=se,te.product.variants[0].available=se),c(Ft).syncStockStatus(te.product),ve("stock",se,`p:${te.productId}`)}],disabled:g(te.product),size:"small",placeholder:be.$t("e.g 10")},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):(r(),h("span",lCe,"—"))])):B("",!0),o("td",{class:ue(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":j.value}])},[o("div",sCe,[_(te.product)&&te.product.view_url?(r(),h("a",{key:0,href:te.product.view_url,target:"_blank",class:"bulk-action-btn bulk-view-link",title:be.$t("View Product")},[n(J,{name:"External"})],8,nCe)):B("",!0),n(lt,{tag:"button",size:"x-small",onClick:Ge(se=>S(te.product),["prevent"]),disabled:s.value||g(te.product),title:be.$t("Duplicate")},{default:u(()=>[n(J,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(lt,{tag:"button",size:"x-small",hover:"danger",onClick:Ge(se=>Q(te.product),["prevent"]),disabled:s.value||g(te.product),title:be.$t("Delete")},{default:u(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,Ewe),te.hasVariants?(r(),h("tr",oCe,[o("td",{colspan:Ve.value.length+1,class:"!p-0 !border-b-0"},[n(_a,{accordion:"",visible:!te.collapsed,duration:200},{default:u(()=>[o("table",rCe,[o("colgroup",null,[Ie[13]||(Ie[13]=o("col",{style:{width:"40px"}},null,-1)),(r(!0),h(P,null,le(Ve.value,(se,ze)=>(r(),h("col",{key:ze,style:fa({width:se.width+"px"})},null,4))),128))]),o("tbody",null,[(r(!0),h(P,null,le(te.product.variants,(se,ze)=>{var _t,Me;return r(),h("tr",{key:ze,class:ue(["bulk-variation-row",{"is-selected":c(ee)(`v:${te.productId}:${ze}`)}]),onClick:St=>pe(`v:${te.productId}:${ze}`,St)},[o("td",uCe,[n(Bt,{"model-value":c(ee)(`v:${te.productId}:${ze}`),tabindex:"-1",onChange:St=>c(ie)(`v:${te.productId}:${ze}`,St,we.value)},null,8,["model-value","onChange"])]),o("td",cCe,[o("div",ACe,[Ie[14]||(Ie[14]=o("span",{class:"text-gray-300 text-xs"},"└",-1)),n(na,{size:"small",modelValue:se.variation_title,"onUpdate:modelValue":[St=>se.variation_title=St,St=>ve("title",St,`v:${te.productId}:${ze}`)],placeholder:be.$t("Variation title"),disabled:g(te.product),class:ue({"is-error":F(te.product,ze,"variation_title")})},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),w(te.product,ze)?(r(),E(bt,{key:0,content:b(te.product,ze),placement:"top"},{default:u(()=>[o("span",pCe,[n(qt,{size:14},{default:u(()=>[n(c(Mo))]),_:1})])]),_:2},1032,["content"])):B("",!0)])]),Le("sku")?(r(),h("td",fCe,[n(na,{size:"small",modelValue:se.sku,"onUpdate:modelValue":[St=>se.sku=St,St=>ve("sku",St,`v:${te.productId}:${ze}`)],placeholder:"SKU",disabled:g(te.product),class:ue({"is-error":F(te.product,ze,"sku")})},null,8,["modelValue","onUpdate:modelValue","disabled","class"])])):B("",!0),Le("media")?(r(),h("td",mCe,[n(bl,{modelValue:se.media,"onUpdate:modelValue":St=>se.media=St,"show-url-tab":"",disabled:g(te.product)},null,8,["modelValue","onUpdate:modelValue","disabled"])])):B("",!0),Le("categories")?(r(),h("td",hCe,Ie[15]||(Ie[15]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("description")?(r(),h("td",_Ce,Ie[16]||(Ie[16]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("short_description")?(r(),h("td",vCe,Ie[17]||(Ie[17]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("status")?(r(),h("td",gCe,Ie[18]||(Ie[18]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("product_type")?(r(),h("td",yCe,Ie[19]||(Ie[19]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("pricing_type")?(r(),h("td",bCe,Ie[20]||(Ie[20]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("payment_type")?(r(),h("td",wCe,[n(li,{variant:se,disabled:g(te.product),"has-error":F(te.product,ze,"other_info.payment_type"),onPaymentTypeChange:St=>{var el;L(St),ve("payment_type",(el=St.other_info)==null?void 0:el.payment_type,`v:${te.productId}:${ze}`)}},null,8,["variant","disabled","has-error","onPaymentTypeChange"])])):B("",!0),Le("interval")?(r(),h("td",CCe,[n(si,{variant:se,disabled:g(te.product),"has-error":F(te.product,ze,"other_info.repeat_interval"),onChange:St=>{var el;return ve("interval",(el=se.other_info)==null?void 0:el.repeat_interval,`v:${te.productId}:${ze}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("trial_days")?(r(),h("td",kCe,[n(ni,{variant:se,disabled:g(te.product),"has-error":F(te.product,ze,"other_info.trial_days"),onChange:St=>{var el;return ve("trial_days",(el=se.other_info)==null?void 0:el.trial_days,`v:${te.productId}:${ze}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("best_price")?(r(),h("td",BCe,[n(ai,{variant:se,disabled:g(te.product),"has-error":F(te.product,ze,"item_price"),onChange:St=>ve("price",se.item_price,`v:${te.productId}:${ze}`)},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("compare_price")?(r(),h("td",xCe,[n(oi,{variant:se,disabled:g(te.product),"has-error":F(te.product,ze,"compare_price"),onChange:St=>ve("compare_price",se.compare_price,`v:${te.productId}:${ze}`)},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),Le("track_quantity")?(r(),h("td",SCe,Ie[21]||(Ie[21]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),Le("stock")?(r(),h("td",$Ce,[((Me=(_t=te.product)==null?void 0:_t.detail)==null?void 0:Me.manage_stock)==="1"?(r(),E(na,{key:0,class:"fc-bulk-input",size:"small",modelValue:se.total_stock,"onUpdate:modelValue":[St=>se.total_stock=St,St=>{se.available=St,c(Ft).syncStockStatus(te.product),ve("stock",St,`v:${te.productId}:${ze}`)}],disabled:g(te.product),placeholder:be.$t("e.g 10")},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):(r(),h("span",FCe,"—"))])):B("",!0),o("td",{class:ue(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":j.value}])},[o("div",ECe,[n(lt,{tag:"button",size:"x-small",onClick:Ge(St=>U(te.product,se),["prevent"]),disabled:s.value||g(te.product),title:be.$t("Duplicate")},{default:u(()=>[n(J,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(lt,{tag:"button",size:"x-small",hover:"danger",onClick:Ge(St=>$(te.product,se),["prevent"]),disabled:s.value||g(te.product),title:be.$t("Delete")},{default:u(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,dCe)}),128)),o("tr",UCe,[o("td",{colspan:Ve.value.length+1},[o("div",VCe,[n(it,{size:"small",text:"",type:"primary",onClick:Ge(se=>c(Ft).addVariationToProduct(te.product),["prevent"])},{default:u(()=>[R(" + "+f(be.$t("Add Variant")),1)]),_:2},1032,["onClick"])])],8,ICe)])])])]),_:2},1032,["visible"])],8,iCe)])):B("",!0)],64)}),128)),Ht.value>0?(r(),h("tr",DCe,[o("td",{colspan:Ve.value.length+1,style:fa({height:Ht.value+"px",padding:0,border:"none"})},null,12,QCe)])):B("",!0)]),_:1},8,["columns","sticky-last"])],2)):(r(),E(wt,{key:1,icon:"Empty/ListView","has-dark":!0,text:c(d)("No products yet. Import a CSV or add products manually.")},null,8,["text"]))]),_:1})]}),_:1}),n(Za,{modelValue:X.value.visible,"onUpdate:modelValue":Ie[6]||(Ie[6]=va=>X.value.visible=va),title:de.value,width:"700px","close-on-click-modal":!1,onClosed:Ie[7]||(Ie[7]=va=>X.value.product=null)},{footer:u(()=>[n(it,{onClick:Ie[5]||(Ie[5]=va=>X.value.visible=!1)},{default:u(()=>[R(f(be.$t("Cancel")),1)]),_:1}),n(it,{type:"primary",onClick:Z},{default:u(()=>[R(f(be.$t("Save")),1)]),_:1})]),default:u(()=>[X.value.visible&&X.value.field==="post_content"?(r(),E(ss,{key:0,"model-value":X.value.value,height:300,onUpdate:Y},null,8,["model-value"])):B("",!0),X.value.visible&&X.value.field==="post_excerpt"?(r(),E(na,{key:1,modelValue:X.value.value,"onUpdate:modelValue":Ie[4]||(Ie[4]=va=>X.value.value=va),type:"textarea",rows:6,placeholder:be.$t("Short description")},null,8,["modelValue","placeholder"])):B("",!0)]),_:1},8,["modelValue","title"])])}}};class RCe extends Rd{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:d("All"),publish:d("Published"),draft:d("Draft"),physical:d("Physical"),digital:d("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 d("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||m.page,per_page:_.per_page||m.per_page,total:_.total||0,hasMore:_.page*_.per_page<_.total}}catch(A){const p=((i=A==null?void 0:A.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(([A])=>A.startsWith(s)).map(([,A])=>A).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,A;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 ce.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(d("Product updated successfully"));else if((s=p.errors)!=null&&s.length){const m=p.errors[0];m!=null&&m.fields&&(this.data.productErrors.set(a,m),this.data.productErrors=new Map(this.data.productErrors)),q.error((m==null?void 0:m.message)||"Failed to save product")}}catch(p){const m=((i=p==null?void 0:p.data)==null?void 0:i.message)||"Failed to save product",_=(A=p==null?void 0:p.data)==null?void 0:A.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(m)}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(d("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 m=p.map(_=>_.ID);for(const _ of m)this.data.savingIds.add(_);this.data.savingIds=new Set(this.data.savingIds);try{const _=await ce.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 m)this.data.savingIds.delete(_);this.data.savingIds=new Set(this.data.savingIds),this.data.saveProgress.completed++}const{updatedIds:i,errors:A}=this.data.saveProgress;A.length===0?q.success(`${i.length} product(s) updated successfully`):i.length>0?q.info(`${i.length} product(s) updated, ${A.length} error(s)`):q.error(d("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 ce.post(`products/${a}/duplicate`,{})).product_id;if(i){const p=(await ce.get("products/bulk-edit-data",{search:i,per_page:1})).products||[];if(p.length>0){const m=this.data.products.indexOf(t);this.data.products.splice(m+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 A=(await ce.post(`products/${l}/duplicate`,{})).product_id;if(!A)return;const m=(await ce.get("products/bulk-edit-data",{search:A,per_page:1})).products||[];if(!m.length)return;const _=m[0],g=t.variants||[],y=new Set;for(const k of g)a.includes(k.id)&&k.serial_index!=null&&y.add(k.serial_index);_.variants&&y.size>0&&(_.variants=_.variants.filter(k=>y.has(k.serial_index)));const v=this.data.products.indexOf(t);this.data.products.splice(v+1,0,_),this.markDirty(_.ID)}catch(i){const A=((s=i==null?void 0:i.data)==null?void 0:s.message)||"Failed to duplicate product";q.error(A)}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 ce.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(d("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 A=a?`${a} > ${i.label}`:i.label;l.push({label:A,value:A}),(s=i.children)!=null&&s.length&&l.push(...this.flattenCategoryTree(i.children,A))}return l}async fetchCategories(){try{const a=(await ce.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 rt=RCe.init(),OCe={class:"fct-bulk-edit-page fct-layout-width"},PCe={class:"fct-table-wrapper"},HCe={class:"fct-card-header-top"},NCe={class:"fct-card-header-left flex-1"},KCe={class:"fct-card-header-actions"},GCe={key:0,class:"fct-advanced-filter-toggle-wrapper"},zCe={key:1,class:"fct-btn-group sm hidden md:flex"},jCe={key:0,class:"filter-search-wrap"},qCe={class:"search-bar"},YCe={class:"text-xs text-system-light pt-2 dark:text-gray-300"},WCe={class:"fct-bulk-edit-table-wrap"},XCe={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"},JCe={class:"m-0 text-base"},ZCe={key:0,class:"text-system-mid text-sm font-normal dark:text-gray-300"},e2e={class:"fct-btn-group sm justify-end"},t2e={class:"filter-popover-item"},a2e={class:"filter-popover-title"},l2e={class:"fct-bulk-edit-table"},s2e={key:0,"aria-hidden":"true"},n2e=["colspan"],o2e=["onClick"],i2e=["onClick"],r2e={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},d2e={class:"flex items-center"},u2e=["onClick","title"],c2e={key:0,class:"bulk-collapse-count"},A2e=["title"],p2e={class:"bulk-status-icon is-error"},f2e=["disabled","onClick","title"],m2e={key:0,class:"fct-bulk-media-cell"},h2e={key:1,class:"fct-bulk-sku-cell"},_2e={key:1,class:"text-gray-300 text-sm flex justify-center"},v2e={key:2,class:"fct-bulk-categories-cell"},g2e={key:3,class:"fct-bulk-desc-cell"},y2e={key:4,class:"fct-bulk-short-desc-cell"},b2e={key:5,class:"fct-bulk-status-cell"},w2e={key:6,class:"fct-bulk-product-type-cell"},C2e={class:"bulk-readonly-label"},k2e={key:7,class:"fct-bulk-pricing-type-cell"},B2e={class:"bulk-readonly-label"},x2e={key:8,class:"fct-bulk-payment-type-cell"},S2e={key:9,class:"fct-bulk-interval-cell"},$2e={key:10,class:"fct-bulk-trial-days-cell"},F2e={key:11,class:"fct-bulk-best-price-cell"},E2e={key:12,class:"fct-bulk-compare-price-cell"},U2e={key:13,class:"fct-bulk-qty-cell !pl-5"},I2e={key:14,class:"fct-bulk-stock-cell"},V2e={key:1,class:"text-gray-300 text-sm flex justify-center"},D2e={class:"fct-btn-group sm justify-end"},Q2e={key:0,class:"bulk-variants-block-row"},T2e=["colspan"],M2e={class:"bulk-inner-table",style:{tableLayout:"fixed",width:"100%",borderCollapse:"collapse"}},L2e=["onClick"],R2e={class:"bulk-checkbox-cell"},O2e={class:"fct-bulk-product-title-cell sticky-col",style:{left:"40px"}},P2e={class:"flex items-center gap-1 pl-4"},H2e={class:"bulk-status-icon is-error"},N2e={key:0},K2e={key:1},G2e={key:2},z2e={key:3},j2e={key:4},q2e={key:5},Y2e={key:6},W2e={key:7},X2e={key:8},J2e={key:9},Z2e={key:10},eke={key:11},tke={key:12},ake={key:13,class:"text-center"},lke={key:14},ske={key:1,class:"text-gray-300 text-sm flex justify-center"},nke={class:"fct-btn-group sm justify-end"},oke={key:1,"aria-hidden":"true"},ike=["colspan"],rke={key:1,class:"flex flex-col items-center justify-center py-16 text-center"},dke={class:"text-system-mid text-sm"},uke={key:2,class:"flex items-center justify-center py-8"},cke={class:"text-system-mid text-sm"},Ake={key:1,class:"flex items-center justify-center py-3 border-top"},pke={class:"text-system-mid text-sm"},hr=43,fke=10,Oc=800,Pc=100,mke=200,hke={__name:"BulkEdit",setup(e){const t=Zt().ctx,a=Na(),{options:l}=rt.data,s=ne=>{var he;return((he=ne==null?void 0:ne.detail)==null?void 0:he.variation_type)==="simple"},i=K(()=>rt.data.products),A=K(()=>rt.data.loading),p=K(()=>rt.data.saving),m=K(()=>rt.data.saveProgress),_=K(()=>rt.data.pagination),g=K(()=>rt.data.dirty),y=K(()=>g.value.size),v=K(()=>Math.max(0,_.value.total-i.value.length)),k=K(()=>Math.min(_.value.per_page,v.value)),w=K(()=>{const ne=rt.data.saveProgress;return ne.total?Math.round(ne.completed/ne.total*100):0}),b=od("search-input"),x=()=>{rt.openSearch(),Fe(()=>{var ne;(ne=b.value)==null||ne.focus()})},F=(ne=!1)=>{rt.fetchProducts({},ne)},Q=()=>{rt.saveProducts()},$=ne=>{rt.markDirty(ne.ID)},S=(ne,he)=>{rt.resetPaymentTypeDefaults(he),$(ne)},U=(ne,he)=>{const We=rt.data.categoryOptions;for(const ot of he)We.find(qe=>qe.value===ot)||We.push({label:ot,value:ot});$(ne)},V=ne=>rt.isDirty(ne.ID),D=ne=>rt.isSavingProduct(ne.ID),I=ne=>rt.isSaved(ne.ID),L=ne=>rt.isRowDisabled(ne.ID),O=ne=>rt.isDuplicating(ne.ID),M=ne=>rt.isDeleting(ne.ID),H=ne=>rt.hasError(ne.ID),z=ne=>rt.getError(ne.ID),X=ne=>rt.hasProductLevelError(ne.ID),G=(ne,he)=>rt.hasVariantError(ne.ID,he),Y=(ne,he)=>rt.getVariantError(ne.ID,he),Z=(ne,he)=>rt.hasFieldError(ne.ID,he),de=(ne,he,We)=>rt.hasVariantFieldError(ne.ID,he,We),j=ne=>rt.saveProduct(ne),ge=ne=>rt.duplicateProduct(ne),ie=(ne,he)=>rt.duplicateVariant(ne,he),W=T(!0),{selectedKeys:N,handleRowClick:ae,toggleSelectAll:ee,selectAll:Ae,deselectAll:re,isSelected:Ue,selectedCount:we,isLinkMode:Be,toggleLinkMode:ve}=Mf(),Ce=K(()=>{const ne=[];for(const he of Bt.value)if(ne.push(`p:${he.productId}`),he.hasVariants&&!he.collapsed)for(const We of he.product.variants)ne.push(`v:${We.id}`);return ne}),Oe=ne=>{var he;if(ne.startsWith("p:")){const We=parseInt(ne.slice(2)),ot=Bt.value.find(qe=>qe.productId===We);return ot?{type:"product",data:ot.product,product:ot.product}:null}else if(ne.startsWith("v:")){const We=parseInt(ne.slice(2));for(const ot of Bt.value){const qe=(he=ot.product.variants)==null?void 0:he.find(Ze=>Ze.id===We);if(qe)return{type:"variant",data:qe,product:ot.product}}}return null},Ee=(ne,he,We)=>{!Be.value||!Ue(We)||Rf(ne,he,We,N.value,Oe,$,Cwe)},pe=T(!1),ye=ne=>{ne.key==="Shift"&&(pe.value=!0)},Ve=ne=>{ne.key==="Shift"&&(pe.value=!1)},Le=(ne,he)=>{if(!he.shiftKey||he.target.closest(".bulk-checkbox-cell"))return;he.preventDefault();const We=new Set(N.value);We.has(ne)?We.delete(ne):We.add(ne),N.value=We},At=()=>{const ne=[];for(const he of Bt.value){const We=`p:${he.productId}`,ot=N.value.has(We),qe=[];if(he.product.variants)for(const Ze of he.product.variants)N.value.has(`v:${Ze.id}`)&&qe.push(Ze.id);!ot&&qe.length===0||(ot&&qe.length===0?ne.push({product:he.product,type:"full"}):!ot&&qe.length>0?ne.push({product:he.product,type:"variants-only",variantIds:qe}):ne.push({product:he.product,type:"partial",variantIds:qe}))}return ne},mt=async()=>{const ne=At();if(!ne.length)return;const he=ne.filter(gt=>gt.type==="full").length,We=ne.filter(gt=>gt.type==="partial").length,qe=ne.filter(gt=>gt.type==="variants-only").reduce((gt,tt)=>gt+tt.variantIds.length,0),Ze=[];he>0&&Ze.push(`${he} product(s) with all variants`),We>0&&Ze.push(`${We} product(s) with selected variants`),qe>0&&Ze.push(`${qe} variant(s)`);try{await El.confirm(t.$t("Duplicate %s?").replace("%s",Ze.join(", ")),t.$t("Bulk Duplicate"),{confirmButtonText:t.$t("Duplicate"),cancelButtonText:t.$t("Cancel"),type:"info"})}catch{return}for(const gt of ne)if(gt.type==="full")await rt.duplicateProduct(gt.product);else if(gt.type==="variants-only")for(const tt of gt.variantIds){const Vt=gt.product.variants.find(fe=>fe.id===tt);Vt&&rt.duplicateVariant(gt.product,Vt)}else gt.type==="partial"&&await rt.duplicateProductWithVariants(gt.product,gt.variantIds);re()},Mt=async()=>{const ne=[],he=[];for(const qe of Bt.value){const Ze=`p:${qe.productId}`;if(N.value.has(Ze)){ne.push(qe.product);continue}const tt=[];if(qe.product.variants)for(const Vt of qe.product.variants)N.value.has(`v:${Vt.id}`)&&tt.push(Vt);tt.length>0&&he.push({product:qe.product,variants:tt})}if(!ne.length&&!he.length)return;const We=he.reduce((qe,Ze)=>qe+Ze.variants.length,0),ot=[];ne.length>0&&ot.push(`${ne.length} product(s)`),We>0&&ot.push(`${We} variant(s)`);try{await El.confirm(t.$t("Permanently delete %s? This cannot be undone.").replace("%s",ot.join(" and ")),t.$t("Bulk Delete"),{confirmButtonText:t.$t("Delete"),cancelButtonText:t.$t("Cancel"),type:"warning"})}catch{return}for(const qe of ne)await rt.deleteProduct(qe);for(const{product:qe,variants:Ze}of he)for(const gt of Ze)rt.removeVariant(qe,gt);re()},Dt=async ne=>{const he=ne.ID;if(!he||rt.isDeleting(he))return;const We=ne.post_title||t.$t("Untitled product"),ot=Array.isArray(ne.variants)?ne.variants.length:0,qe=ot>0?t.$t('This will permanently delete "%1$s" and its %2$s variant(s).',We,ot):t.$t('This will permanently delete "%1$s".',We);try{await El.confirm(qe,t.$t("Delete Product"),{confirmButtonText:t.$t("Delete"),cancelButtonText:t.$t("Cancel"),type:"warning"})}catch{return}rt.deleteProduct(ne)},Xe=(ne,he)=>{if(ne.variants.length<=1){rt.removeVariant(ne,he);return}const We=he.variation_title||t.$t("Untitled variant");El.confirm(t.$t('This will remove the variant "%1$s".',We),t.$t("Remove Variant"),{confirmButtonText:t.$t("Remove"),cancelButtonText:t.$t("Cancel"),type:"warning"}).then(()=>{rt.removeVariant(ne,he)}).catch(()=>{})},pt=T({visible:!1,field:"",product:null,value:""}),jt=(ne,he)=>{pt.value={visible:!0,field:he,product:ne,value:ne[he]||""}},Ct=ne=>{pt.value.value=ne},$t=()=>{const{product:ne,field:he,value:We}=pt.value;ne&&(ne[he]=We,$(ne)),pt.value.visible=!1},Ht=K(()=>pt.value.field==="post_content"?t.$t("Edit Description"):t.$t("Edit Short Description")),Nt=T([]),Qt=K(()=>Nt.value.filter(ne=>ne.key==="title"||ne.key==="actions"?!0:rt.isColumnVisible(ne.key))),yt=ne=>rt.isColumnVisible(ne),Xt=()=>{rt.saveColumnWidths(Nt.value)},be=T(new Set),Ie=ne=>{const he=ne.ID;be.value.has(he)?be.value.delete(he):be.value.add(he),be.value=new Set(be.value)},it=ne=>be.value.has(ne.ID),kt=T(0),Bt=K(()=>{let ne=0;return i.value.map(he=>{var fe;const We=he.ID,ot=((fe=he.detail)==null?void 0:fe.variation_type)!=="simple"&&Array.isArray(he.variants)&&he.variants.length>0,qe=ot?he.variants.length:0,Ze=be.value.has(We),gt=ot&&!Ze?qe*hr:0,tt=hr+gt,Vt={product:he,productId:We,hasVariants:ot,variantCount:qe,collapsed:Ze,groupHeight:tt,offset:ne};return ne+=tt,Vt})}),ta=K(()=>{const ne=Bt.value;if(ne.length===0)return 0;const he=ne[ne.length-1];return he.offset+he.groupHeight}),bt=K(()=>{const ne=Bt.value,he=kt.value,We=he+Oc,ot=fke*hr;return ne.filter(qe=>qe.offset+qe.groupHeight>=he-ot&&qe.offset<=We+ot)}),sa=K(()=>bt.value.length===0?0:bt.value[0].offset),na=K(()=>{if(bt.value.length===0)return 0;const ne=bt.value[bt.value.length-1];return ta.value-ne.offset-ne.groupHeight});let qt=null,ka=0;const Ja=()=>{if(A.value||!_.value.hasMore||i.value.length===0)return;ta.value-(kt.value+Oc){const he=ne.target,We=Date.now();qt&&clearTimeout(qt),We-ka>=Pc?(kt.value=he.scrollTop,ka=We,Ja()):qt=setTimeout(()=>{kt.value=he.scrollTop,ka=Date.now(),qt=null,Ja()},Pc)},Za=ne=>({physical:"Physical",digital:"Digital"})[ne]||ne||"—",va=ne=>({simple:"Simple",simple_variations:"Variable"})[ne]||ne||"—";let te=null;const Se=()=>{const ne=a.query.product_ids,he=a.query.variant_ids;ne&&he?rt.fetchProducts({},!1,ne,he):F(!1)};return De(async()=>{te=is(),te.bind("mod+a",ne=>{var We,ot;const he=(We=document.activeElement)==null?void 0:We.tagName;he==="INPUT"||he==="TEXTAREA"||(ot=document.activeElement)!=null&&ot.isContentEditable||(ne.preventDefault(),Ae(Ce.value))}),te.bind("escape",()=>{var he,We;const ne=(he=document.activeElement)==null?void 0:he.tagName;ne==="INPUT"||ne==="TEXTAREA"||(We=document.activeElement)!=null&&We.isContentEditable||(Be.value?ve():re())}),Nt.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}],rt.restoreColumnWidths(Nt.value),rt.setupColumnVisibility(),rt.setupSavedViews(),rt.fetchCategories(),Se(),document.body.classList.add("fct-bulk-page"),window.addEventListener("keydown",ye),window.addEventListener("keyup",Ve)}),Ya(()=>{document.body.classList.remove("fct-bulk-page"),window.removeEventListener("keydown",ye),window.removeEventListener("keyup",Ve),te&&te.reset()}),(ne,he)=>{const We=C("el-button"),ot=C("el-progress"),qe=C("el-switch"),Ze=C("el-tooltip"),gt=C("el-input"),tt=C("el-checkbox"),Vt=C("el-checkbox-group"),fe=C("el-popover"),_e=C("el-icon"),Ne=C("el-option"),Pe=C("el-select"),ft=C("el-dialog");return r(),h("div",OCe,[n(nl,{title:ne.$t("Bulk Edit")},{action:u(()=>[n(We,{type:"primary",onClick:Q,loading:p.value,disabled:p.value||y.value===0},{default:u(()=>[R(f(p.value?ne.$t("Saving %s/%s...").replace("%s",m.value.completed).replace("%s",m.value.total):y.value>0?ne.$t("Save Changes")+` (${y.value})`:ne.$t("Save Changes")),1)]),_:1},8,["loading","disabled"])]),_:1},8,["title"]),p.value?(r(),E(ot,{key:0,percentage:w.value,"stroke-width":6,class:"mb-4"},null,8,["percentage"])):B("",!0),o("div",PCe,[n($e,null,{default:u(()=>[n(Qe,{border_bottom:""},{default:u(()=>[o("div",HCe,[o("div",NCe,[c(rt).getTabsCount()&&!c(rt).isUsingAdvanceFilter()?(r(),E(Am,{key:0,class:ue("hide-animation-on-mobile hidden md:inline-flex classic-tab-style"),table:c(rt)},null,8,["table"])):B("",!0)]),o("div",KCe,[c(rt).isAdvanceFilterEnabled()?(r(),h("div",GCe,[n(qe,{class:"fct-advanced-filter-toggle",onChange:he[0]||(he[0]=se=>{c(rt).onFilterTypeChanged(se)}),"active-value":"advanced","inactive-value":"simple",modelValue:c(rt).data.filterType,"onUpdate:modelValue":he[1]||(he[1]=se=>c(rt).data.filterType=se),"active-text":ne.$t("Advanced Filter"),size:"small"},null,8,["modelValue","active-text"])])):B("",!0),c(rt).isUsingAdvanceFilter()?B("",!0):(r(),h("div",zCe,[c(rt).isSearching()?B("",!0):(r(),E(Ze,{key:0,effect:"light",content:ne.$t("Search"),placement:"top","popper-class":"fct-tooltip"},{default:u(()=>[n(lt,{tag:"button",onClick:Ge(x,["prevent"])},{default:u(()=>[n(J,{name:"Search"})]),_:1})]),_:1},8,["content"]))]))])]),n(lA,{table:c(rt)},null,8,["table"]),c(rt).isSearching()&&!c(rt).isUsingAdvanceFilter()?(r(),h("div",jCe,[o("div",qCe,[n(gt,{ref:"search-input",onClear:he[2]||(he[2]=()=>{c(rt).search()}),onKeyup:he[3]||(he[3]=da(()=>{c(rt).search()},["enter"])),modelValue:c(rt).data.search,"onUpdate:modelValue":he[4]||(he[4]=se=>c(rt).data.search=se),type:"text",placeholder:ne.$t("Search"),clearable:""},{prefix:u(()=>[n(J,{name:"Search"})]),_:1},8,["modelValue","placeholder"]),o("div",YCe,f(c(rt).getSearchHint()),1)]),n(We,{text:"",onClick:he[5]||(he[5]=()=>{c(rt).closeSearch()})},{default:u(()=>[R(f(ne.$t("Cancel")),1)]),_:1})])):B("",!0)]),_:1}),n(xe,{class:"p-0"},{default:u(()=>[o("div",WCe,[i.value.length>0?(r(),h("div",XCe,[o("h5",JCe,[R(f(i.value.length)+" "+f(i.value.length===1?ne.$t("Product"):ne.$t("Products"))+" ",1),_.value.total>i.value.length?(r(),h("span",ZCe,f(ne.$t("of"))+" "+f(_.value.total)+" "+f(ne.$t("total"))+" · "+f(k.value)+" "+f(ne.$t("next")),1)):B("",!0)]),o("div",e2e,[n(We,{disabled:c(we)===0,onClick:mt,size:"small"},{default:u(()=>[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(" "+f(ne.$t("Duplicate")),1)]),_:1,__:[14]},8,["disabled"]),n(We,{disabled:c(we)===0,onClick:Mt,size:"small",type:"danger",plain:""},{default:u(()=>[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(" "+f(ne.$t("Delete")),1)]),_:1,__:[15]},8,["disabled"]),n(We,{class:ue({"is-active":c(Be)}),disabled:c(we)<2&&!c(Be),onClick:c(ve),size:"small"},{default:u(()=>[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(" "+f(c(Be)?ne.$t("Unlink"):ne.$t("Link")),1)]),_:1,__:[16]},8,["class","disabled","onClick"]),n(tt,{modelValue:W.value,"onUpdate:modelValue":he[6]||(he[6]=se=>W.value=se),label:ne.$t("Pin Actions")},null,8,["modelValue","label"]),n(fe,{trigger:"click",placement:"bottom-end",width:"240","popper-class":"filter-popover"},{reference:u(()=>[o("span",null,[n(Ze,{effect:"light",content:ne.$t("Toggle columns"),placement:"top","popper-class":"fct-tooltip"},{default:u(()=>[n(lt,{tag:"button",size:"small"},{default:u(()=>[n(J,{name:"ColumnIcon"})]),_:1})]),_:1},8,["content"])])]),default:u(()=>[o("div",t2e,[o("h3",a2e,f(ne.$t("Columns")),1),n(Vt,{modelValue:c(rt).data.visibleColumns,"onUpdate:modelValue":he[7]||(he[7]=se=>c(rt).data.visibleColumns=se),class:"fct-checkbox-blocks",onChange:he[8]||(he[8]=se=>c(rt).handleColumnVisibilityChange())},{default:u(()=>[(r(!0),h(P,null,le(c(rt).getToggleableColumns(),se=>(r(),E(tt,{key:se.value,value:se.value,label:ne.$t(se.label)},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])])]),_:1})])])):B("",!0),o("div",l2e,[i.value.length>0?(r(),h("div",{key:0,class:ue(["relative",{"is-link-mode":c(Be),"is-shift-held":pe.value}])},[n(Qf,{columns:Qt.value,"sticky-last":W.value,onScroll:ul,onResizeEnd:Xt},{"header-first":u(()=>[Wt(n(tt,{checked:c(we)>0&&c(we)===Ce.value.length,onChange:he[9]||(he[9]=se=>c(ee)(Ce.value))},null,8,["checked"]),[[c(bwe),c(we)>0&&c(we)[R(f(ne.$t("Actions")),1)]),default:u(()=>[sa.value>0?(r(),h("tr",s2e,[o("td",{colspan:Qt.value.length+1,style:fa({height:sa.value+"px",padding:0,border:"none"})},null,12,n2e)])):B("",!0),(r(!0),h(P,null,le(bt.value,se=>{var ze,_t,Me,St,el,oe,me,Te,He,Ye,ht,at,It,Yt,Ma,Et,aa,ga;return r(),h(P,{key:se.productId},[o("tr",{class:ue(["bulk-product-row",{"is-dirty":V(se.product),"is-saving":D(se.product),"is-saved":I(se.product),"has-product-error":H(se.product),"is-selected":c(Ue)(`p:${se.productId}`)}]),onClick:et=>Le(`p:${se.productId}`,et)},[o("td",{class:"bulk-checkbox-cell",onClick:et=>c(ae)(`p:${se.productId}`,et,Ce.value)},[n(tt,{"model-value":c(Ue)(`p:${se.productId}`),tabindex:"-1"},null,8,["model-value"])],8,i2e),o("td",r2e,[o("div",d2e,[se.hasVariants?(r(),h("button",{key:0,class:"bulk-collapse-btn",onClick:Ge(et=>Ie(se.product),["prevent"]),title:it(se.product)?ne.$t("Expand variants"):ne.$t("Collapse variants")},[(r(),h("svg",{class:ue(["bulk-collapse-icon",{"is-collapsed":it(se.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)),it(se.product)?(r(),h("span",c2e,f(se.variantCount),1)):B("",!0)],8,u2e)):B("",!0),n(gt,{class:ue(["fct-bulk-input",{"is-error":Z(se.product,"post_title")}]),modelValue:se.product.post_title,"onUpdate:modelValue":[et=>se.product.post_title=et,et=>{$(se.product),Ee("title",et,`p:${se.productId}`)}],placeholder:ne.$t("Product title"),disabled:L(se.product),size:"small"},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),D(se.product)?(r(),h("span",{key:1,class:"bulk-status-icon is-syncing",title:ne.$t("Saving...")},[n(_e,{class:"is-loading",size:14},{default:u(()=>[n(c(ln))]),_:1})],8,A2e)):X(se.product)||s(se.product)&&H(se.product)?(r(),E(Ze,{key:2,content:z(se.product),placement:"top"},{default:u(()=>[o("span",p2e,[n(_e,{size:16},{default:u(()=>[n(c(Mo))]),_:1})])]),_:2},1032,["content"])):V(se.product)?(r(),h("button",{key:3,class:"bulk-inline-save",disabled:L(se.product),onClick:Ge(et=>j(se.product),["prevent"]),title:ne.$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,f2e)):B("",!0)])]),yt("image")?(r(),h("td",m2e,[n(bl,{modelValue:se.product.gallery,"onUpdate:modelValue":et=>se.product.gallery=et,onChange:et=>$(se.product)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):B("",!0),yt("sku")?(r(),h("td",h2e,[((_t=(ze=se.product)==null?void 0:ze.detail)==null?void 0:_t.variation_type)==="simple"&&((Me=se.product.variants)!=null&&Me[0])?(r(),E(gt,{key:0,class:ue(["fct-bulk-input",{"is-error":Z(se.product,"variants.0.sku")}]),modelValue:se.product.variants[0].sku,"onUpdate:modelValue":[et=>se.product.variants[0].sku=et,et=>{$(se.product),Ee("sku",et,`p:${se.productId}`)}],placeholder:"SKU",size:"small",disabled:L(se.product)},null,8,["modelValue","onUpdate:modelValue","disabled","class"])):(r(),h("span",_2e,"—"))])):B("",!0),yt("categories")?(r(),h("td",v2e,[n(Tf,{modelValue:se.product.categories,"onUpdate:modelValue":et=>se.product.categories=et,options:c(rt).data.categoryOptions,disabled:L(se.product),onChange:et=>{U(se.product,et),Ee("categories",se.product.categories,`p:${se.productId}`)}},null,8,["modelValue","onUpdate:modelValue","options","disabled","onChange"])])):B("",!0),yt("description")?(r(),h("td",g2e,[n(ii,{value:se.product.post_content,placeholder:ne.$t("Description"),onClick:et=>jt(se.product,"post_content")},null,8,["value","placeholder","onClick"])])):B("",!0),yt("short_description")?(r(),h("td",y2e,[n(ii,{value:se.product.post_excerpt,placeholder:ne.$t("Short description"),onClick:et=>jt(se.product,"post_excerpt")},null,8,["value","placeholder","onClick"])])):B("",!0),yt("status")?(r(),h("td",b2e,[n(Pe,{modelValue:se.product.post_status,"onUpdate:modelValue":et=>se.product.post_status=et,size:"small",class:ue({"is-field-error":Z(se.product,"post_status")}),disabled:L(se.product),onChange:et=>{$(se.product),Ee("status",se.product.post_status,`p:${se.productId}`)}},{default:u(()=>[n(Ne,{label:ne.$t("Published"),value:"publish"},null,8,["label"]),n(Ne,{label:ne.$t("Draft"),value:"draft"},null,8,["label"])]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])])):B("",!0),yt("product_type")?(r(),h("td",w2e,[o("span",C2e,f(Za((el=(St=se.product)==null?void 0:St.detail)==null?void 0:el.fulfillment_type)),1)])):B("",!0),yt("pricing_type")?(r(),h("td",k2e,[o("span",B2e,f(va((me=(oe=se.product)==null?void 0:oe.detail)==null?void 0:me.variation_type)),1)])):B("",!0),yt("payment_type")?(r(),h("td",x2e,[n(li,{variant:s(se.product)?(Te=se.product.variants)==null?void 0:Te[0]:null,disabled:L(se.product),"has-error":Z(se.product,"variants.0.other_info.payment_type"),onPaymentTypeChange:et=>{var oa;S(se.product,et),Ee("payment_type",(oa=et.other_info)==null?void 0:oa.payment_type,`p:${se.productId}`)},onChange:et=>$(se.product)},null,8,["variant","disabled","has-error","onPaymentTypeChange","onChange"])])):B("",!0),yt("interval")?(r(),h("td",S2e,[n(si,{variant:s(se.product)?(He=se.product.variants)==null?void 0:He[0]:null,disabled:L(se.product),"has-error":Z(se.product,"variants.0.other_info.repeat_interval"),onChange:et=>{var oa,Ka,Je;$(se.product),Ee("interval",(Je=(Ka=(oa=se.product.variants)==null?void 0:oa[0])==null?void 0:Ka.other_info)==null?void 0:Je.repeat_interval,`p:${se.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("trial_days")?(r(),h("td",$2e,[n(ni,{variant:s(se.product)?(Ye=se.product.variants)==null?void 0:Ye[0]:null,disabled:L(se.product),"has-error":Z(se.product,"variants.0.other_info.trial_days"),onChange:et=>{var oa,Ka,Je;$(se.product),Ee("trial_days",(Je=(Ka=(oa=se.product.variants)==null?void 0:oa[0])==null?void 0:Ka.other_info)==null?void 0:Je.trial_days,`p:${se.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("best_price")?(r(),h("td",F2e,[n(ai,{variant:s(se.product)?(ht=se.product.variants)==null?void 0:ht[0]:null,disabled:L(se.product),"has-error":Z(se.product,"variants.0.item_price"),onChange:et=>{var oa,Ka;$(se.product),Ee("price",(Ka=(oa=se.product.variants)==null?void 0:oa[0])==null?void 0:Ka.item_price,`p:${se.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("compare_price")?(r(),h("td",E2e,[n(oi,{variant:s(se.product)?(at=se.product.variants)==null?void 0:at[0]:null,disabled:L(se.product),"has-error":Z(se.product,"variants.0.compare_price"),onChange:et=>{var oa,Ka;$(se.product),Ee("compare_price",(Ka=(oa=se.product.variants)==null?void 0:oa[0])==null?void 0:Ka.compare_price,`p:${se.productId}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("track_quantity")?(r(),h("td",U2e,[(It=se.product)!=null&&It.detail?(r(),E(qe,{key:0,modelValue:se.product.detail.manage_stock,"onUpdate:modelValue":et=>se.product.detail.manage_stock=et,"active-value":1,"inactive-value":0,disabled:L(se.product),onChange:et=>{$(se.product),c(rt).syncStockStatus(se.product),Ee("manage_stock",se.product.detail.manage_stock,`p:${se.productId}`)}},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])):B("",!0)])):B("",!0),yt("stock")?(r(),h("td",I2e,[(Ma=(Yt=se.product)==null?void 0:Yt.detail)!=null&&Ma.manage_stock&&((aa=(Et=se.product)==null?void 0:Et.detail)==null?void 0:aa.variation_type)==="simple"&&((ga=se.product.variants)!=null&&ga[0])?(r(),E(gt,{key:0,class:"fct-bulk-input",placeholder:ne.$t("e.g 10"),size:"small",modelValue:se.product.variants[0].available,"onUpdate:modelValue":[et=>se.product.variants[0].available=et,et=>{se.product.variants[0].total_stock=et,$(se.product),c(rt).syncStockStatus(se.product),Ee("stock",et,`p:${se.productId}`)}],disabled:L(se.product)},null,8,["placeholder","modelValue","onUpdate:modelValue","disabled"])):(r(),h("span",V2e,"—"))])):B("",!0),o("td",{class:ue(["fct-bulk-actions-cell",{"sticky-col sticky-col-right":W.value}])},[o("div",D2e,[se.product.view_url?(r(),E(lt,{key:0,tag:"a",size:"x-small",href:se.product.view_url,target:"_blank",title:ne.$t("View Product")},{default:u(()=>[n(J,{name:"External"})]),_:2},1032,["href","title"])):B("",!0),n(lt,{tag:"button",size:"x-small",onClick:Ge(et=>ge(se.product),["prevent"]),disabled:p.value||L(se.product)||O(se.product),title:ne.$t("Duplicate")},{default:u(()=>[O(se.product)?(r(),E(_e,{key:0,class:"is-loading",size:14},{default:u(()=>[n(c(ln))]),_:1})):(r(),E(J,{key:1,name:"Copy"}))]),_:2},1032,["onClick","disabled","title"]),n(lt,{tag:"button",size:"x-small",hover:"danger",onClick:Ge(et=>Dt(se.product),["prevent"]),disabled:p.value||L(se.product)||M(se.product),title:ne.$t("Delete")},{default:u(()=>[M(se.product)?(r(),E(_e,{key:0,class:"is-loading",size:14},{default:u(()=>[n(c(ln))]),_:1})):(r(),E(J,{key:1,name:"Delete"}))]),_:2},1032,["onClick","disabled","title"])])],2)],10,o2e),se.hasVariants?(r(),h("tr",Q2e,[o("td",{colspan:Qt.value.length+1,class:"!p-0 !border-b-0"},[n(_a,{accordion:"",visible:!se.collapsed,duration:200},{default:u(()=>[o("table",M2e,[o("colgroup",null,[he[19]||(he[19]=o("col",{style:{width:"40px"}},null,-1)),(r(!0),h(P,null,le(Qt.value,(et,oa)=>(r(),h("col",{key:oa,style:fa({width:et.width+"px"})},null,4))),128))]),o("tbody",null,[(r(!0),h(P,null,le(se.product.variants,(et,oa)=>{var Ka,Je;return r(),h("tr",{key:et.id||oa,class:ue(["bulk-variation-row",{"is-selected":c(Ue)(`v:${et.id}`)}]),onClick:Pt=>Le(`v:${et.id}`,Pt)},[o("td",R2e,[n(tt,{"model-value":c(Ue)(`v:${et.id}`),tabindex:"-1",onChange:Pt=>c(ae)(`v:${et.id}`,Pt,Ce.value)},null,8,["model-value","onChange"])]),o("td",O2e,[o("div",P2e,[he[20]||(he[20]=o("span",{class:"text-gray-300 text-xs"},"└",-1)),n(gt,{size:"small",modelValue:et.variation_title,"onUpdate:modelValue":[Pt=>et.variation_title=Pt,Pt=>{$(se.product),Ee("title",Pt,`v:${et.id}`)}],placeholder:ne.$t("Variation title"),disabled:L(se.product),class:ue({"is-error":de(se.product,oa,"variation_title")})},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"]),G(se.product,oa)?(r(),E(Ze,{key:0,content:Y(se.product,oa),placement:"top"},{default:u(()=>[o("span",H2e,[n(_e,{size:14},{default:u(()=>[n(c(Mo))]),_:1})])]),_:2},1032,["content"])):B("",!0)])]),yt("image")?(r(),h("td",N2e,[n(bl,{modelValue:et.media,"onUpdate:modelValue":Pt=>et.media=Pt,onChange:Pt=>$(se.product)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):B("",!0),yt("sku")?(r(),h("td",K2e,[n(gt,{class:ue(["fct-bulk-input",{"is-error":de(se.product,oa,"sku")}]),size:"small",modelValue:et.sku,"onUpdate:modelValue":[Pt=>et.sku=Pt,Pt=>{$(se.product),Ee("sku",Pt,`v:${et.id}`)}],placeholder:ne.$t("SKU"),disabled:L(se.product)},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"])])):B("",!0),yt("categories")?(r(),h("td",G2e,he[21]||(he[21]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),yt("description")?(r(),h("td",z2e,he[22]||(he[22]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),yt("short_description")?(r(),h("td",j2e,he[23]||(he[23]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),yt("status")?(r(),h("td",q2e,he[24]||(he[24]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),yt("product_type")?(r(),h("td",Y2e,he[25]||(he[25]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),yt("pricing_type")?(r(),h("td",W2e,he[26]||(he[26]=[o("span",{class:"text-gray-300 text-sm flex justify-center"},"—",-1)]))):B("",!0),yt("payment_type")?(r(),h("td",X2e,[n(li,{variant:et,disabled:L(se.product),"has-error":de(se.product,oa,"other_info.payment_type"),onPaymentTypeChange:Pt=>{var rs;S(se.product,Pt),Ee("payment_type",(rs=Pt.other_info)==null?void 0:rs.payment_type,`v:${et.id}`)},onChange:Pt=>$(se.product)},null,8,["variant","disabled","has-error","onPaymentTypeChange","onChange"])])):B("",!0),yt("interval")?(r(),h("td",J2e,[n(si,{variant:et,disabled:L(se.product),"has-error":de(se.product,oa,"other_info.repeat_interval"),onChange:Pt=>{var rs;$(se.product),Ee("interval",(rs=et.other_info)==null?void 0:rs.repeat_interval,`v:${et.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("trial_days")?(r(),h("td",Z2e,[n(ni,{variant:et,disabled:L(se.product),"has-error":de(se.product,oa,"other_info.trial_days"),onChange:Pt=>{var rs;$(se.product),Ee("trial_days",(rs=et.other_info)==null?void 0:rs.trial_days,`v:${et.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("best_price")?(r(),h("td",eke,[n(ai,{variant:et,disabled:L(se.product),"has-error":de(se.product,oa,"item_price"),onChange:Pt=>{$(se.product),Ee("price",et.item_price,`v:${et.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("compare_price")?(r(),h("td",tke,[n(oi,{variant:et,disabled:L(se.product),"has-error":de(se.product,oa,"compare_price"),onChange:Pt=>{$(se.product),Ee("compare_price",et.compare_price,`v:${et.id}`)}},null,8,["variant","disabled","has-error","onChange"])])):B("",!0),yt("track_quantity")?(r(),h("td",ake,he[27]||(he[27]=[o("span",{class:"text-gray-300 text-sm"},"—",-1)]))):B("",!0),yt("stock")?(r(),h("td",lke,[(Je=(Ka=se.product)==null?void 0:Ka.detail)!=null&&Je.manage_stock?(r(),E(gt,{key:0,class:"fct-bulk-input",placeholder:ne.$t("e.g 10"),size:"small",modelValue:et.available,"onUpdate:modelValue":[Pt=>et.available=Pt,Pt=>{et.total_stock=Pt,$(se.product),c(rt).syncStockStatus(se.product),Ee("stock",Pt,`v:${et.id}`)}],disabled:L(se.product)},null,8,["placeholder","modelValue","onUpdate:modelValue","disabled"])):(r(),h("span",ske,"—"))])):B("",!0),o("td",{class:ue(["text-center",{"sticky-col sticky-col-right":W.value}])},[o("div",nke,[n(lt,{tag:"button",size:"x-small",onClick:Ge(Pt=>ie(se.product,et),["prevent"]),disabled:p.value||L(se.product),title:ne.$t("Duplicate")},{default:u(()=>[n(J,{name:"Copy"})]),_:2},1032,["onClick","disabled","title"]),n(lt,{tag:"button",size:"x-small",hover:"danger",onClick:Ge(Pt=>Xe(se.product,et),["prevent"]),disabled:p.value||L(se.product),title:ne.$t("Delete")},{default:u(()=>[n(J,{name:"Delete"})]),_:2},1032,["onClick","disabled","title"])])],2)],10,L2e)}),128))])])]),_:2},1032,["visible"])],8,T2e)])):B("",!0)],64)}),128)),na.value>0?(r(),h("tr",oke,[o("td",{colspan:Qt.value.length+1,style:fa({height:na.value+"px",padding:0,border:"none"})},null,12,ike)])):B("",!0)]),_:1},8,["columns","sticky-last"])],2)):A.value?A.value?(r(),h("div",uke,[n(_e,{class:"is-loading mr-2"},{default:u(()=>he[28]||(he[28]=[o("i",{class:"el-icon-loading"},null,-1)])),_:1,__:[28]}),o("span",cke,f(ne.$t("Loading products...")),1)])):B("",!0):(r(),h("div",rke,[o("p",dke,f(ne.$t("No products found.")),1)]))]),_.value.hasMore&&i.value.length>0&&A.value?(r(),h("div",Ake,[n(_e,{class:"is-loading mr-2"},{default:u(()=>he[29]||(he[29]=[o("i",{class:"el-icon-loading"},null,-1)])),_:1,__:[29]}),o("span",pke,f(ne.$t("Loading"))+" "+f(k.value)+" "+f(ne.$t("more...")),1)])):B("",!0)])]),_:1})]),_:1})]),n(ft,{modelValue:pt.value.visible,"onUpdate:modelValue":he[12]||(he[12]=se=>pt.value.visible=se),title:Ht.value,width:"700px","close-on-click-modal":!1,onClosed:he[13]||(he[13]=se=>pt.value.product=null)},{footer:u(()=>[n(We,{onClick:he[11]||(he[11]=se=>pt.value.visible=!1)},{default:u(()=>[R(f(ne.$t("Cancel")),1)]),_:1}),n(We,{type:"primary",onClick:$t},{default:u(()=>[R(f(ne.$t("Save")),1)]),_:1})]),default:u(()=>[pt.value.visible&&pt.value.field==="post_content"?(r(),E(ss,{key:0,"model-value":pt.value.value,height:300,onUpdate:Ct},null,8,["model-value"])):B("",!0),pt.value.visible&&pt.value.field==="post_excerpt"?(r(),E(gt,{key:1,modelValue:pt.value.value,"onUpdate:modelValue":he[10]||(he[10]=se=>pt.value.value=se),type:"textarea",rows:6,placeholder:ne.$t("Short description")},null,8,["modelValue","placeholder"])):B("",!0)]),_:1},8,["modelValue","title"])])}}},Of=je.get("payment_routes");for(const e of Of)e.props=!0;const _ke=je.get("storage_driver_routes"),Pf=(_ke||[]).filter(e=>e.name!=="s3");for(const e of Pf)e.props=!0;var vke={dashboard:{name:"dashboard",path:"/",component:l8,meta:{active_menu:"dashboard",title:d("Dashboard")}},orders:{path:"/orders",component:QF,meta:{active_menu:"orders",title:d("Orders")},children:[{name:"orders",path:"",component:xv,meta:{active_menu:"orders",title:d("Orders"),permission:"orders/view"}},{name:"view_order",path:":order_id(\\d+)/view",component:WD,props:!0,meta:{active_menu:"orders",title:d("View Order"),permission:["orders/view","orders/manage"]}},{name:"add_order",path:"add",component:$Q,props:!0,meta:{active_menu:"orders",title:d("Create Order"),permission:"orders/create"}}]},products:{name:"products",path:"/products",component:V7,meta:{active_menu:"products",title:d("Products"),permission:"products/view"}},product_route:{path:"/products/:product_id(\\d+)",component:wT,name:"product_route",meta:{active_menu:"products",title:d("Products"),permission:["products/view","products/edit","integrations/manage"]},props:!0,children:[{name:"product_edit",path:"",props:!0,component:yq,meta:{active_menu:"products",title:d("Product Edit"),permission:"products/edit"}},{name:"product_integrations",path:"integrations",props:!0,component:xc,meta:{active_menu:"products",title:d("Integrations"),permission:"integrations/manage"}},{name:"product_integration_feed_editor",path:"integrations/:integration_id/:integration_name",component:uc,meta:{active_menu:"products",title:d("Edit Integration"),permission:"integrations/manage"}},{name:"SingleIntegration",path:"integrations/:integration_id",props:!0,component:FY,meta:{active_menu:"products",title:d("Integrations"),permission:"integrations/manage"}},{name:"product_upgrade_paths",path:"upgrade-paths",props:!0,component:rY,meta:{active_menu:"products",title:d("Upgrade Paths"),permission:"integrations/manage"}},{name:"Integrations",path:"integrations",props:!0,component:xc,meta:{active_menu:"integrations",title:d("Product Integrations"),permission:"integrations/manage"}}]},product_bulk_insert:{name:"product_bulk_insert",path:"/products/bulk-insert",component:LCe,meta:{active_menu:"products",title:d("Product Bulk Insert"),permission:"products/create"}},product_bulk_edit:{name:"product_bulk_edit",path:"/products/bulk-edit",component:hke,meta:{active_menu:"products",title:d("Product Bulk Edit"),permission:"products/edit"}},product_attributes:{name:"product_attributes",path:"/products/attributes",component:Rm,meta:{active_menu:"products",title:d("Attributes"),permission:"products/view"}},product_inventory:{name:"product_inventory",path:"/products/inventory",component:uJ,meta:{active_menu:"products",title:d("Inventory"),permission:"products/view"}},customers:{path:"/customers",component:Og,meta:{active_menu:"customers",permission:["customers/view","customers/manage"]},children:[{name:"customers",path:"/customers",component:A_,meta:{active_menu:"customers",title:d("Customers"),permission:"customers/view"}},{name:"view_customer",path:":customer_id(\\d+)/view",component:IU,props:!0,meta:{active_menu:"customers",title:d("View Customer"),permission:"customers/view"}}]},reports:{name:"reports",path:"/reports",component:xte,meta:{active_menu:"reports",permission:"reports/view"},children:[{name:"reports_overview",path:"overview",component:Ice,meta:{title:d("Overview"),permission:"reports/view"}},{name:"reports_sales",path:"sales",component:aae,meta:{title:d("Sales"),permission:"reports/view"}},{name:"reports_orders",path:"orders",component:vne,meta:{title:d("Orders"),permission:"reports/view"}},{name:"reports_revenue",path:"revenue",component:Jae,meta:{title:d("Revenue"),permission:"reports/view"}},{name:"reports_refunds",path:"refunds",component:toe,meta:{title:d("Refunds"),permission:"reports/view"}},{name:"reports_subscriptions",path:"subscriptions",component:joe,meta:{title:d("Subscriptions"),permission:"reports/view"}},{name:"subscriptions-retention",path:"subscriptions/subscriptions-retention",component:ire,meta:{title:d("Retention"),permission:"reports/view"}},{name:"subscriptions-cohorts",path:"subscriptions/subscriptions-cohorts",component:()=>Jt(()=>import("./chunks/Cohort.js?ver=1.7.1"),[],import.meta.url),meta:{title:d("Cohorts"),permission:"reports/view"}},{name:"future_renewals",path:"subscriptions/future-renewals",component:Aie,meta:{title:d("Future Renewals"),permission:"reports/view"}},{name:"reports_products",path:"products",component:Lue,meta:{title:d("Product"),permission:"reports/view"}},{name:"reports_customer",path:"customer",component:Ire,meta:{title:d("Customer"),permission:"reports/view"}},{name:"reports_sources",path:"sources",component:mde,meta:{title:d("Sources"),permission:"reports/view"}}]},settings:{path:"/settings",component:BE,meta:{active_menu:"settings",title:d("Settings"),permission:["store/settings","store/sensitive"]},children:[{name:"store_settings",path:"store-settings",component:NQ,meta:{active_menu:"settings",title:d("Settings"),permission:"store/settings"},children:[{name:"store_setup",path:"",component:Zl,meta:{title:d("Store Setup")}},{name:"pages_setup",path:"pages_setup",component:Zl,meta:{title:d("Pages Setup")}},{name:"single_product_setup",path:"single_product_setup",component:Zl,meta:{title:d("Product Page")}},{name:"cart_and_checkout",path:"cart_and_checkout",component:Zl,meta:{title:d("Cart & Checkout")}},{name:"subscriptions_setup",path:"subscriptions_setup",component:Zl,meta:{title:d("Subscriptions")}},{name:"checkout_fields",path:"checkout_fields",component:U0e,meta:{}},{name:"appearance",path:"appearance",component:Zl,meta:{title:d("Appearance")}}]},{name:"compliance",path:"compliance",component:Zl,meta:{active_menu:"settings",title:d("Compliance"),permission:"store/settings"}},...je.get("addon_settings_routes",[]).map(e=>({component:Zl,...e})),{name:"product_reviews",path:"product-reviews",component:u0e,meta:{active_menu:"settings",title:d("Product Reviews"),permission:"reviews/manage"}},{name:"email_notifications",path:"email_notifications",component:QJ,meta:{active_menu:"settings",title:d("Notifications"),permission:"store/sensitive"}},{name:"email_mailing_settings",path:"email_mailing_settings",component:$Ae,meta:{active_menu:"settings",title:d("Mailing Settings"),permission:"store/sensitive"}},{name:"reminders",path:"email_mailing_settings/reminders",component:Zl,meta:{active_menu:"settings",title:d("Reminders"),permission:"store/sensitive"}},{name:"email_digest_settings",path:"email_digest_settings",component:TAe,meta:{active_menu:"settings",title:d("Store Digest"),permission:"store/sensitive"}},{path:"email_notifications/:name/",name:"email_notifications/edit",component:uZ,meta:{active_menu:"settings",title:d("Edit Notification"),permission:"store/sensitive"},props:!0},{path:"email_notifications/add",name:"email_notifications/add",component:IZ,meta:{active_menu:"settings",title:d("Add Notification"),permission:"store/sensitive"}},{name:"licensing",path:"licensing",component:AT,meta:{active_menu:"settings",title:d("Licensing"),permission:"store/sensitive"}},{name:"payments",path:"payments",component:YF,meta:{active_menu:"settings",title:d("Payment Settings"),permission:"is_super_admin"}},{name:"gateway",component:CS,path:"payments",children:Of,props:!0,meta:{active_menu:"settings",title:d("Payment Settings"),permission:"is_super_admin"}},{name:"invoice-packing",path:"invoice-packing",component:Iv,meta:{active_menu:"settings",title:d("Invoice & Packing"),permission:"is_super_admin"}},{name:"pdf-template",path:"pdf-template",component:Dv,meta:{active_menu:"settings",title:d("PDF Templates"),permission:"is_super_admin"},children:[{name:"pdf-template-list",path:"",component:Xv,meta:{active_menu:"settings",title:d("PDF Templates"),permission:"is_super_admin"}},{name:"pdf-template-settings",path:"settings",component:Tg,meta:{active_menu:"settings",title:d("PDF Template Settings"),permission:"is_super_admin"}},{name:"edit-pdf-template",path:":template/edit",component:hg,props:!0,meta:{active_menu:"settings",title:d("Edit PDF Template"),permission:"is_super_admin"}}]},{name:"roles",path:"roles",component:mE,meta:{active_menu:"settings",title:d("Role Settings"),permission:"is_super_admin"}},{name:"addons",path:"addons",component:Jce,meta:{active_menu:"settings",title:d("Features & addon"),permission:"is_super_admin"}},{name:"coupons",path:"coupons",component:Qc,meta:{active_menu:"coupons",title:d("Coupons Settings"),permission:"is_super_admin"}},{name:"storage",path:"storage",component:kZ,meta:{active_menu:"settings",title:d("Storage Providers"),permission:"is_super_admin"}},{name:"s3",path:"storage/s3",component:Fc,props:!0,meta:{active_menu:"settings",title:d("S3"),permission:"is_super_admin"}},{name:"payment-design",path:"payments/:method/design",component:$S,meta:{active_menu:"settings",title:d("Gateway"),permission:"is_super_admin"},props:!0},{name:"drivers",component:Fc,path:"storage",children:Pf,props:!0,meta:{active_menu:"settings",title:d("Storage Settings"),permission:"is_super_admin"}},{name:"tax_settings",path:"tax_settings",component:RAe,meta:{active_menu:"settings",title:d("Tax Settings"),permission:"store/settings"},children:[{name:"tax_configurations",path:"",component:Wpe,meta:{}},{name:"tax_rates",path:"tax_rates",component:Afe,meta:{}},{name:"eu",path:"eu",component:O_e,meta:{}},{name:"eu_country_tax_rates",path:"eu/:country/:group",component:Dc,props:!0,meta:{}},{name:"tax-rates-country-single",path:"tax_rates_country_single/:country/:group",component:Dc,props:!0,meta:{}}]}]},integrations:{name:"integrations",path:"/integrations",component:hx,meta:{active_menu:"integrations",title:d("Integrations"),permission:"integrations/view"}},global_feed_editor:{name:"feed_editor",path:"/global_integrations/:integration_id/:integration_name",component:uc,meta:{active_menu:"integrations",title:d("Global Integrations"),permission:"integrations/view"}},integration_editor:{name:"integration_editor",path:"/integrations/:integration_name",component:JS,meta:{active_menu:"integrations",title:d("Integrations"),permission:"integrations/manage"}},coupons:{name:"coupons",path:"/coupons",component:Qc,meta:{active_menu:"coupons",title:d("Coupons"),permission:"coupons/view"}},reviews:{path:"/reviews",component:dge,meta:{active_menu:"products",title:d("Reviews"),permission:"reviews/manage"},beforeEnter:(e,t,a)=>{const l=je.get("modules_settings.reviews");if(!l||l.active!=="yes"){a({name:"dashboard"});return}a()},children:[{name:"reviews",path:"",component:z1e,meta:{active_menu:"products",title:d("Reviews"),permission:"reviews/manage"}},{name:"view_review",path:":review_id(\\d+)/view",component:sbe,props:!0,meta:{active_menu:"products",title:d("View Review"),permission:"reviews/manage"}}]},logs:{name:"logs",path:"/logs",component:gee,meta:{active_menu:"logs",title:d("Logs"),permission:"is_super_admin"}},taxes:{name:"taxes",path:"/taxes",component:Rme,meta:{active_menu:"taxes",title:d("Taxes"),permission:"is_super_admin"}},add_or_edit_coupon_route:{name:"add_or_edit_coupon",path:"/coupons/add_or_edit_coupon/:coupon_id?",component:ige,props:!0,meta:{active_menu:"coupons",title:d("Coupons"),permission:"coupons/manage"}},onboarding:{path:"/onboarding",component:VF,name:"onboarding",meta:{active_menu:"dashboard",title:d("Onboarding"),permission:"is_super_admin"}}};const gke={class:"fct-theme-button-container"},yke={class:"theme-selected-button"},bke={__name:"ThemeToggle",setup(e){const t=T(Re.MODE_LIGHT),a=A=>{t.value!==A&&(t.value=A,Re.apply(A))},l=[{value:"light",label:d("Light"),icon:"Sun"},{value:"dark",label:d("Dark"),icon:"Moon"},{value:"system",label:d("System"),icon:"Tools"}];Os(()=>{const A=document.getElementById("theme-button-container");if(A){const p=A.querySelector(".fct-theme-button-container");p&&p.remove()}t.value=Re.getCurrentTheme(),t.value.toString().startsWith(Re.MODE_SYSTEM)&&(t.value=Re.MODE_SYSTEM)});const s=A=>{Fe(()=>{t.value=Re.getCurrentTheme()})},i=A=>{a(A)};return De(()=>{window.addEventListener(Re.THEME_CHANGE_EVENT,s,!1)}),Ya(()=>{window.removeEventListener(Re.THEME_CHANGE_EVENT,s,!1)}),(A,p)=>{const m=C("el-dropdown-item"),_=C("el-dropdown-menu"),g=C("el-dropdown");return r(),h("div",gke,[n(g,{placement:"bottom-end",trigger:"click","popper-class":"fct-dropdown",onCommand:i},{dropdown:u(()=>[n(_,null,{default:u(()=>[(r(),h(P,null,le(l,y=>n(m,{key:y.value,command:y.value,class:ue({active:t.value===y.value})},{default:u(()=>[n(J,{name:y.icon},null,8,["name"]),R(" "+f(y.label),1)]),_:2},1032,["command","class"])),64))]),_:1})]),default:u(()=>[o("div",yke,[t.value==="light"?(r(),E(J,{key:0,name:"Sun"})):t.value==="dark"?(r(),E(J,{key:1,name:"Moon"})):t.value==="system"?(r(),E(J,{key:2,name:"Tools"})):B("",!0)])]),_:1})])}}};function os(e){return Array.isArray?Array.isArray(e):Kf(e)==="[object Array]"}function wke(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Cke(e){return e==null?"":wke(e)}function Nl(e){return typeof e=="string"}function Hf(e){return typeof e=="number"}function kke(e){return e===!0||e===!1||Bke(e)&&Kf(e)=="[object Boolean]"}function Nf(e){return typeof e=="object"}function Bke(e){return Nf(e)&&e!==null}function _l(e){return e!=null}function _r(e){return!e.trim().length}function Kf(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const xke="Incorrect 'index' type",Ske=e=>`Invalid value for key ${e}`,$ke=e=>`Pattern length exceeds max of ${e}.`,Fke=e=>`Missing ${e} property in key`,Eke=e=>`Property 'weight' in key '${e}' must be a positive integer`,Hc=Object.prototype.hasOwnProperty;class Uke{constructor(t){this._keys=[],this._keyMap={};let a=0;t.forEach(l=>{let s=Gf(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 Gf(e){let t=null,a=null,l=null,s=1,i=null;if(Nl(e)||os(e))l=e,t=Nc(e),a=Jr(e);else{if(!Hc.call(e,"name"))throw new Error(Fke("name"));const A=e.name;if(l=A,Hc.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(Eke(A));t=Nc(A),a=Jr(A),i=e.getFn}return{path:t,id:a,weight:s,src:l,getFn:i}}function Nc(e){return os(e)?e:e.split(".")}function Jr(e){return os(e)?e.join("."):e}function Ike(e,t){let a=[],l=!1;const s=(i,A,p)=>{if(_l(i))if(!A[p])a.push(i);else{let m=A[p];const _=i[m];if(!_l(_))return;if(p===A.length-1&&(Nl(_)||Hf(_)||kke(_)))a.push(Cke(_));else if(os(_)){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,Nl(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();Nl(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 A=s.getFn?s.getFn(t):this.getFn(t,s.path);if(_l(A)){if(os(A)){let p=[];const m=[{nestedArrIndex:-1,value:A}];for(;m.length;){const{nestedArrIndex:_,value:g}=m.pop();if(_l(g))if(Nl(g)&&!_r(g)){let y={v:g,i:_,n:this.norm.get(g)};p.push(y)}else os(g)&&g.forEach((y,v)=>{m.push({nestedArrIndex:v,value:y})})}l.$[i]=p}else if(Nl(A)&&!_r(A)){let p={v:A,n:this.norm.get(A)};l.$[i]=p}}}),this.records.push(l)}toJSON(){return{keys:this.keys,records:this.records}}}function zf(e,t,{getFn:a=Ut.getFn,fieldNormWeight:l=Ut.fieldNormWeight}={}){const s=new Hd({getFn:a,fieldNormWeight:l});return s.setKeys(e.map(Gf)),s.setSources(t),s.create(),s}function Rke(e,{getFn:t=Ut.getFn,fieldNormWeight:a=Ut.fieldNormWeight}={}){const{keys:l,records:s}=e,i=new Hd({getFn:t,fieldNormWeight:a});return i.setKeys(l),i.setIndexRecords(s),i}function Bo(e,{errors:t=0,currentLocation:a=0,expectedLocation:l=0,distance:s=Ut.distance,ignoreLocation:i=Ut.ignoreLocation}={}){const A=t/e.length;if(i)return A;const p=Math.abs(l-a);return s?A+p/s:p?1:A}function Oke(e=[],t=Ut.minMatchCharLength){let a=[],l=-1,s=-1,i=0;for(let A=e.length;i=t&&a.push([l,s]),l=-1)}return e[i-1]&&i-l>=t&&a.push([l,i-1]),a}const Fs=32;function Pke(e,t,a,{location:l=Ut.location,distance:s=Ut.distance,threshold:i=Ut.threshold,findAllMatches:A=Ut.findAllMatches,minMatchCharLength:p=Ut.minMatchCharLength,includeMatches:m=Ut.includeMatches,ignoreLocation:_=Ut.ignoreLocation}={}){if(t.length>Fs)throw new Error($ke(Fs));const g=t.length,y=e.length,v=Math.max(0,Math.min(l,y));let k=i,w=v;const b=p>1||m,x=b?Array(y):[];let F;for(;(F=e.indexOf(t,w))>-1;){let D=Bo(t,{currentLocation:F,expectedLocation:v,distance:s,ignoreLocation:_});if(k=Math.min(D,k),w=F+g,b){let I=0;for(;I=O;X-=1){let G=X-1,Y=a[e.charAt(G)];if(b&&(x[G]=+!!Y),H[X]=(H[X+1]<<1|1)&Y,D&&(H[X]|=(Q[X+1]|Q[X])<<1|1|Q[X+1]),H[X]&U&&($=Bo(t,{errors:D,currentLocation:G,expectedLocation:v,distance:s,ignoreLocation:_}),$<=k)){if(k=$,w=G,w<=v)break;O=Math.max(1,2*v-w)}}if(Bo(t,{errors:D+1,currentLocation:v,expectedLocation:v,distance:s,ignoreLocation:_})>k)break;Q=H}const V={isMatch:w>=0,score:Math.max(.001,$)};if(b){const D=Oke(x,p);D.length?m&&(V.indices=D):V.isMatch=!1}return V}function Hke(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 jf{constructor(t,{location:a=Ut.location,threshold:l=Ut.threshold,distance:s=Ut.distance,includeMatches:i=Ut.includeMatches,findAllMatches:A=Ut.findAllMatches,minMatchCharLength:p=Ut.minMatchCharLength,isCaseSensitive:m=Ut.isCaseSensitive,ignoreDiacritics:_=Ut.ignoreDiacritics,ignoreLocation:g=Ut.ignoreLocation}={}){if(this.options={location:a,threshold:l,distance:s,includeMatches:i,findAllMatches:A,minMatchCharLength:p,isCaseSensitive:m,ignoreDiacritics:_,ignoreLocation:g},t=m?t:t.toLowerCase(),t=_?ri(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const y=(k,w)=>{this.chunks.push({pattern:k,alphabet:Hke(k),startIndex:w})},v=this.pattern.length;if(v>Fs){let k=0;const w=v%Fs,b=v-w;for(;k{const{isMatch:Q,score:$,indices:S}=Pke(t,b,x,{location:i+F,distance:A,threshold:p,findAllMatches:m,minMatchCharLength:_,includeMatches:s,ignoreLocation:g});Q&&(k=!0),v+=$,Q&&S&&(y=[...y,...S])});let w={isMatch:k,score:k?v/this.chunks.length:1};return k&&s&&(w.indices=y),w}}class Bs{constructor(t){this.pattern=t}static isMultiMatch(t){return Kc(t,this.multiRegex)}static isSingleMatch(t){return Kc(t,this.singleRegex)}search(){}}function Kc(e,t){const a=e.match(t);return a?a[1]:null}class Nke extends Bs{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 Kke extends Bs{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 Gke extends Bs{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 zke extends Bs{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 jke extends Bs{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 qke extends Bs{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 qf extends Bs{constructor(t,{location:a=Ut.location,threshold:l=Ut.threshold,distance:s=Ut.distance,includeMatches:i=Ut.includeMatches,findAllMatches:A=Ut.findAllMatches,minMatchCharLength:p=Ut.minMatchCharLength,isCaseSensitive:m=Ut.isCaseSensitive,ignoreDiacritics:_=Ut.ignoreDiacritics,ignoreLocation:g=Ut.ignoreLocation}={}){super(t),this._bitapSearch=new jf(t,{location:a,threshold:l,distance:s,includeMatches:i,findAllMatches:A,minMatchCharLength:p,isCaseSensitive:m,ignoreDiacritics:_,ignoreLocation:g})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Yf extends Bs{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 A=!!s.length;return{isMatch:A,score:A?0:1,indices:s}}}const Zr=[Nke,Yf,Gke,zke,qke,jke,Kke,qf],Gc=Zr.length,Yke=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Wke="|";function Xke(e,t={}){return e.split(Wke).map(a=>{let l=a.trim().split(Yke).filter(i=>i&&!!i.trim()),s=[];for(let i=0,A=l.length;i!!(e[di.AND]||e[di.OR]),tBe=e=>!!e[ad.PATH],aBe=e=>!os(e)&&Nf(e)&&!ld(e),zc=e=>({[di.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Wf(e,t,{auto:a=!0}={}){const l=s=>{let i=Object.keys(s);const A=tBe(s);if(!A&&i.length>1&&!ld(s))return l(zc(s));if(aBe(s)){const m=A?s[ad.PATH]:i[0],_=A?s[ad.PATTERN]:s[m];if(!Nl(_))throw new Error(Ske(m));const g={keyId:Jr(m),pattern:_};return a&&(g.searcher=td(_,t)),g}let p={children:[],operator:i[0]};return i.forEach(m=>{const _=s[m];os(_)&&_.forEach(g=>{p.children.push(l(g))})}),p};return ld(e)||(e=zc(e)),l(e)}function lBe(e,{ignoreFieldNorm:t=Ut.ignoreFieldNorm}){e.forEach(a=>{let l=1;a.matches.forEach(({key:s,norm:i,score:A})=>{const p=s?s.weight:null;l*=Math.pow(A===0&&p?Number.EPSILON:A,(p||1)*(t?1:i))}),a.score=l})}function sBe(e,t){const a=e.matches;t.matches=[],_l(a)&&a.forEach(l=>{if(!_l(l.indices)||!l.indices.length)return;const{indices:s,value:i}=l;let A={indices:s,value:i};l.key&&(A.key=l.key.src),l.idx>-1&&(A.refIndex=l.idx),t.matches.push(A)})}function nBe(e,t){t.score=e.score}function oBe(e,t,{includeMatches:a=Ut.includeMatches,includeScore:l=Ut.includeScore}={}){const s=[];return a&&s.push(sBe),l&&s.push(nBe),e.map(i=>{const{idx:A}=i,p={item:t[A],refIndex:A};return s.length&&s.forEach(m=>{m(i,p)}),p})}class vn{constructor(t,a={},l){this.options={...Ut,...a},this.options.useExtendedSearch,this._keyStore=new Uke(this.options.keys),this.setCollection(t,l)}setCollection(t,a){if(this._docs=t,a&&!(a instanceof Hd))throw new Error(xke);this._myIndex=a||zf(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){_l(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const a=[];for(let l=0,s=this._docs.length;l-1&&(m=m.slice(0,a)),oBe(m,this._docs,{includeMatches:l,includeScore:s})}_searchStringList(t){const a=td(t,this.options),{records:l}=this._myIndex,s=[];return l.forEach(({v:i,i:A,n:p})=>{if(!_l(i))return;const{isMatch:m,score:_,indices:g}=a.searchIn(i);m&&s.push({item:i,idx:A,matches:[{score:_,value:i,norm:p,indices:g}]})}),s}_searchLogical(t){const a=Wf(t,this.options),l=(p,m,_)=>{if(!p.children){const{keyId:y,searcher:v}=p,k=this._findMatches({key:this._keyStore.get(y),value:this._myIndex.getValueForItemAtKeyId(m,y),searcher:v});return k&&k.length?[{idx:_,item:m,matches:k}]:[]}const g=[];for(let y=0,v=p.children.length;y{if(_l(p)){let _=l(a,p,m);_.length&&(i[m]||(i[m]={idx:m,item:p,matches:[]},A.push(i[m])),_.forEach(({matches:g})=>{i[m].matches.push(...g)}))}}),A}_searchObjectList(t){const a=td(t,this.options),{keys:l,records:s}=this._myIndex,i=[];return s.forEach(({$:A,i:p})=>{if(!_l(A))return;let m=[];l.forEach((_,g)=>{m.push(...this._findMatches({key:_,value:A[g],searcher:a}))}),m.length&&i.push({idx:p,item:A,matches:m})}),i}_findMatches({key:t,value:a,searcher:l}){if(!_l(a))return[];let s=[];if(os(a))a.forEach(({v:i,i:A,n:p})=>{if(!_l(i))return;const{isMatch:m,score:_,indices:g}=l.searchIn(i);m&&s.push({score:_,key:t,value:i,idx:A,norm:p,indices:g})});else{const{v:i,n:A}=a,{isMatch:p,score:m,indices:_}=l.searchIn(i);p&&s.push({score:m,key:t,value:i,norm:A,indices:_})}return s}}vn.version="7.1.0";vn.createIndex=zf;vn.parseIndex=Rke;vn.config=Ut;vn.parseQuery=Wf;eBe(Zke);const iBe=(je.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:d("Manage %1$s",t),path:"/settings/payments/"+e.path}}),rBe=[{title:d("Dashboard"),path:"/"},{title:d("Orders"),path:"/orders"},{title:d("Create Order"),path:"/orders/add"},{title:d("Customers"),path:"/customers"},{title:d("Products"),path:"/products"},{title:d("Product Inventory"),path:"/products/inventory"},{title:d("Bulk Import Products"),path:"/products/bulk-insert"},{title:d("Integrations"),path:"/integrations"},{title:d("Coupons"),path:"/coupons"},{title:d("Logs"),path:"/logs"},{title:d("Taxes"),path:"/taxes"},{title:d("Reports"),path:"/reports/overview"},{title:d("Sales Report"),path:"/reports/sales"},{title:d("Orders Report"),path:"/reports/orders"},{title:d("Revenue Report"),path:"/reports/revenue"},{title:d("Refunds Report"),path:"/reports/refunds"},{title:d("Subscriptions Report"),path:"/reports/subscriptions"},{title:d("Future Renewals Report"),path:"/reports/subscriptions/future-renewals"},{title:d("Product Report"),path:"/reports/products"},{title:d("Customer Report"),path:"/reports/customer"},{title:d("Traffic Sources Report"),path:"/reports/sources"},...iBe],dBe=rBe.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}})),uBe=[{title:"Theme",title_resolver:()=>{let t=(Re.isDark()?"dark":"light")==="light"?d("Dark"):d("Light");return d("Change theme to %1$s",t)},data:{type:"action",action:()=>{let t=(Re.isDark()?"dark":"light")==="light"?"dark":"light";Re.apply(t,{fromShortcut:!0})}}}],jc={"/settings/store-settings":d("Store Setup"),"/settings/store-settings/pages_setup":d("Pages Setup"),"/settings/store-settings/single_product_setup":d("Single Product & Order Setup"),"/settings/store-settings/cart_and_checkout":d("Cart and Checkout"),"/settings/compliance":d("Compliance"),"/settings/store-settings/subscriptions_setup":d("Subscriptions Setup"),"/settings/store-settings/checkout_fields":d("Checkout Fields"),"/settings/store-settings/appearance":d("Appearance"),"/settings/email_notifications":d("Email Notifications"),"/settings/email_mailing_settings":d("Mailing Settings"),"/settings/email_mailing_settings/reminders":d("Reminders"),"/settings/licensing":d("Licensing"),"/settings/payments":d("Payment Settings"),"/settings/invoice-packing":d("Invoice & Packing Slips"),"/settings/pdf-template":d("PDF Templates"),"/settings/roles":d("Role Settings"),"/settings/addons":d("Features & Addons"),"/settings/tax_settings":d("Tax Settings"),"/settings/tax_settings/tax_rates":d("Tax Rates"),"/settings/tax_settings/eu":d("EU VAT Settings"),"/settings/storage":d("Storage Providers"),"/settings/coupons":d("Coupon Settings")};let Xf=[];Object.keys(jc).forEach(e=>{const t=jc[e];Xf.push({title:t,data:{type:"action",action:({router:a})=>{a.push({path:e})},description:d("Go to %1$s",t),show_description:!1}})});const cBe=[],ABe={Menu:dBe,Actions:uBe,Settings:Xf,Shortcuts:cBe},sd=[];Object.entries(ABe).forEach(([e,t])=>{t.forEach((a,l)=>{sd.push({...a,id:`${e.toString().toLowerCase()}-${l}`,group:[e]})})});const pBe=()=>({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}]}),fBe={class:"navigable-list-container fct-global-search-result-container"},mBe={key:0,class:"no-results fct-global-search-result-not-found"},hBe={key:1},_Be=["tabindex","onClick","onKeydown"],vBe={__name:"NavigableList",props:{items:{type:Array,required:!0,default:()=>[]},noResultsText:{type:String,default:d("No results found")},onAction:{type:Function,required:!0}},setup(e,{expose:t}){const a=e,l=T(-1),s=od("listContainer"),i=T({}),A=(w,b)=>{b&&(i.value[w]=b)},p=w=>{const b=a.items.length;if(b===0)return;const x=b-1;w==="up"?l.value=l.value<=0?x:l.value-1:w==="down"&&(l.value=l.value>=x?0:l.value+1),m()},m=()=>{const w=s.value,b=i.value[l.value];b&&w&&(b.scrollIntoView({behavior:"smooth",block:"nearest"}),Fe(()=>{b.focus()}))},_=w=>{l.value=w,g(w)},g=w=>{w>=0&&w{l.value=-1};return t({focusList:w=>{w=w??a.items.length-1,w>=0&&(l.value=w,Fe(()=>{i.value[w]&&i.value[w].focus()}))},resetSelection:y,performFirstAction:()=>{a.items.length>0?(l.value=0,setTimeout(()=>{g(0)},200)):l.value=-1}}),ke(()=>a.items,w=>{y(),w.length>0&&Fe(()=>{})},{immediate:!0}),ke(l,()=>{}),(w,b)=>(r(),h("div",fBe,[e.items.length===0?(r(),h("div",mBe,[n(J,{name:"Empty/GlobalSearch"}),R(" "+f(e.noResultsText),1)])):(r(),h("div",hBe,[o("ul",{ref_key:"listContainer",ref:s,class:"navigable-list fct-global-search-result-list"},[(r(!0),h(P,null,le(e.items,(x,F)=>(r(),h("li",{key:F,ref_for:!0,ref:Q=>A(F,Q),class:ue({selected:F===l.value}),tabindex:F,onClick:Q=>_(F),onKeydown:[b[0]||(b[0]=da(Ge(Q=>p("up"),["prevent"]),["arrow-up"])),b[1]||(b[1]=da(Ge(Q=>p("down"),["prevent"]),["arrow-down"])),da(Q=>g(F),["enter"])]},[wa(w.$slots,"default",{item:x,index:F,isSelected:F===l.value},void 0,!0)],42,_Be))),128))],512)]))]))}},nd=nt(vBe,[["__scopeId","data-v-2379fe26"]]),gBe={class:"fct-search-result-label"},yBe={class:"fct-search-result-title"},bBe={key:0,class:"fct-search-result-subtitle"},wBe={key:1,class:"fct-search-result-subtitle"},CBe={class:"action-icon"},kBe={class:"recent-search-title"},BBe={class:"fct-search-result-label"},xBe={class:"fct-search-result-title"},SBe={key:0,class:"fct-search-result-subtitle"},$Be={key:1,class:"fct-search-result-subtitle"},FBe={class:"action-icon"},vr="recent_actions",EBe={__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=Wa();Zt().ctx;const l=e,s=T(0),i=T({}),A=T(),p=(x,F)=>{const $=x.item.data,S=_($.type);if(S==="link"){let U=_($.url);_($.new_tab)?window.open(U,"_blank"):window.location.href=U}else S==="action"&&_($.action);m(x),l.onActionPerformed()},m=x=>{const F=x.item.id;let Q=Tt.get(vr)||[];Q=Q.filter($=>$!==F),Q.unshift(F),Q=Q.slice(0,5),Tt.set(vr,Q)},_=x=>typeof x=="function"?g(x):x,g=async x=>await x({query:l.query,router:a}),y=()=>{var x;(x=A.value)==null||x.resetSelection()},v=()=>{var x;(x=A.value)==null||x.focusList(0)},k=()=>{var x;(x=A.value)==null||x.performFirstAction()};ke(()=>l.searchResults,async()=>{i.value={},i.value=l.searchResults??{},s.value=Object.keys(i.value).length-1;let x=i.value;for(const F of Object.keys(x)){const Q=x[F];Q.item.title_resolver&&(x[F].item.title=await _(Q.item.title_resolver))}i.value={...x}});const w=T([]),b=async()=>{const x=Tt.get(vr)||[];let F=dt.whereIn(l.searchData,"id",x),Q=[];for(const $ of F)typeof $.title_resolver=="function"&&($.title=await _($.title_resolver)),Q.push({item:$});w.value=Q};return De(()=>{b()}),t({focusList:v,resetSelection:y,performFirstAction:k,fetchRecentActions:b}),(x,F)=>(r(),h(P,null,[e.query||w.value.length<1?(r(),E(nd,{key:0,items:e.searchResults,"on-action":p,"no-results-text":c(d)("No matches found"),ref_key:"navigableList",ref:A},{default:u(({item:Q,index:$,isSelected:S})=>{var U,V,D;return[o("span",gBe,[o("span",yBe,f(Q.item.title),1),(U=Q.item)!=null&&U.subtitle?(r(),h("span",bBe,f(Q.item.subtitle),1)):((D=(V=Q.item)==null?void 0:V.data)==null?void 0:D.show_description)===!0?(r(),h("span",wBe,f(Q.item.data.description),1)):B("",!0)]),o("div",CBe,[n(J,{name:"Enter"})])]}),_:1},8,["items","no-results-text"])):B("",!0),!e.query&&w.value.length>0?(r(),h(P,{key:1},[o("span",kBe,f(c(d)("Recent Actions")),1),n(nd,{items:w.value,"on-action":p,"no-results-text":c(d)("No matches found"),ref_key:"navigableList",ref:A},{default:u(({item:Q,index:$,isSelected:S})=>{var U,V,D;return[o("span",BBe,[o("span",xBe,f(Q.item.title),1),(U=Q.item)!=null&&U.subtitle?(r(),h("span",SBe,f(Q.item.subtitle),1)):((D=(V=Q.item)==null?void 0:V.data)==null?void 0:D.show_description)===!0?(r(),h("span",$Be,f(Q.item.data.description),1)):B("",!0)]),o("div",FBe,[n(J,{name:"Enter"})])]}),_:1},8,["items","no-results-text"])],64)):B("",!0)],64))}},UBe=nt(EBe,[["__scopeId","data-v-ccb0ebef"]]),IBe={class:"fct-global-search-product-wrap"},VBe={class:"fct-global-search-product-left-info"},DBe={key:0,class:"type"},QBe={key:0,class:"price-and-status"},TBe={__name:"Product",props:{product:{type:Object,required:!0}},setup(e){const t=l=>l.min_price===l.max_price?zt(l.min_price,!0):`${zt(l.min_price,!0)} - ${zt(l.max_price,!0)}`,a=l=>l==="publish"?d("published"):l==="future"?d("scheduled"):l;return(l,s)=>(r(),h("div",IBe,[o("div",VBe,[n(Ad,{product:e.product},null,8,["product"]),e.product.detail?(r(),h("span",DBe,[R(f(c(Aa).headline(e.product.detail.variation_type))+" ",1),s[0]||(s[0]=o("br",null,null,-1)),R(" "+f(c(Aa).headline(e.product.detail.fulfillment_type)),1)])):B("",!0)]),e.product.detail?(r(),h("span",QBe,[R(f(t(e.product.detail))+" ",1),(r(),E(la,{key:e.product.ID,status:e.product.post_status},{default:u(()=>[R(f(a(e.product.post_status)),1)]),_:1},8,["status"]))])):B("",!0)]))}},MBe={class:"fct-global-search-order-wrap"},LBe={class:"fct-global-search-order-header"},RBe={class:"fct-global-search-order-id"},OBe={class:"items"},PBe={class:"fct-global-search-order-header-meta"},HBe={class:"date"},NBe=["innerHTML"],KBe={class:"customer-name"},GBe={class:"fct-global-search-order-status-wrapper"},zBe=["src","alt"],jBe={__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",MBe,[o("div",LBe,[o("div",RBe,[R(" #"+f(e.order.id)+" ",1),o("span",OBe,f(c(d)("%s Items",e.order.order_items.length)),1)]),o("div",PBe,[o("span",HBe,[n(Sa,{"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:c(zt)(e.order.total_amount,!0,!1,e.order.currency)},null,8,NBe),l[1]||(l[1]=o("span",{class:"circle"},null,-1)),o("span",KBe,f(((i=e.order.customer)==null?void 0:i.full_name)||c(d)("No Name")),1)])]),o("div",GBe,[n(la,{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:c(Aa).headline(e.order.payment_method)},null,8,zBe)):(r(),E(s,{key:1,type:"info",round:"",size:"small",class:"capitalize"},{default:u(()=>[R(f(c(Aa).headline(e.order.payment_method)),1)]),_:1}))])])}}},qBe={class:"fct-global-search-customer-wrap"},YBe={class:"fct-customer-card"},WBe={class:"fct-customer-avatar"},XBe={class:"fct-customer-details"},JBe={class:"fct-customer-name"},ZBe={class:"fct-customer-id"},e8e={class:"fct-customer-email"},t8e={class:"purchase-count"},a8e={class:"date"},l8e={__name:"Customer",props:{customer:{type:Object,required:!0}},setup(e){return(t,a)=>(r(),h("div",qBe,[o("div",YBe,[o("div",WBe,[n(Is,{url:e.customer.photo,name:e.customer.full_name},null,8,["url","name"])]),o("div",XBe,[o("div",JBe,[R(f(e.customer.full_name||t.$t("No Name"))+" ",1),o("span",ZBe,"#"+f(e.customer.id),1)]),o("div",e8e,[R(f(e.customer.email)+" ",1),a[0]||(a[0]=o("span",{class:"circle"},null,-1)),a[1]||(a[1]=R()),o("span",t8e,"Purchase: "+f(e.customer.purchase_count),1)])])]),o("span",a8e,[n(Sa,{"date-time":e.customer.last_purchase_date},null,8,["date-time"])])]))}},s8e={class:"fct-global-search-coupon-wrap"},n8e={class:"amount"},o8e={__name:"Coupon",props:{coupon:{type:Object,required:!0}},setup(e){return(t,a)=>(r(),h("div",s8e,[o("span",null,f(e.coupon.title),1),o("span",null,f(e.coupon.code),1),o("span",n8e,f(c(zt)(e.coupon.amount,!0)),1)]))}},i8e={class:"fct-global-remote-result-container"},r8e={class:"fct-global-remote-result-label"},d8e={class:"text"},u8e={class:"navigable-content"},c8e={class:"action-icon"},A8e={__name:"RemoteResult",emits:["close-modal","onRemoteSearchStateChange"],setup(e,{expose:t,emit:a}){const l=a,s=Wa(),i=T({}),A=T(""),p=T(),m=T({}),_=T([]),g=D=>{y.value=!1,_.value=x.data.tableData,l("onRemoteSearchStateChange",!1)},y=T(!1),v={orders:BA({fetch:!1}),products:Af({fetch:!1}),customers:kA({fetch:!1}),coupons:Df({fetch:!1})},k=()=>{},w=()=>{var D;(D=p.value)==null||D.focusList(0)},b=()=>{var D;(D=p.value)==null||D.performFirstAction()};Os(()=>{for(const D of Object.keys(v))v[D].onDataLoaded(g)});let x=null;const F=()=>{x=v[i.value.key],x.data.search=A.value,y.value=!0,x.fetch(),l("onRemoteSearchStateChange",!0)},Q=hd.debounce(F,800),$=(D,I)=>{if(_.value=[],x&&(x.data.search=""),i.value=I,m.value={title:I.title,key:I.key},!D){A.value="";return}A.value=D,Q()},S=()=>{s.push({name:m.value.key,query:{search:A.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"}},V=D=>{i.value.key in U&&(s.push({name:U[i.value.key].name,params:{[U[i.value.key].key]:D.id||D.ID,action:"edit"}}),l("close-modal"))};return t({fetchData:$,focusList:w,resetSelection:k,performFirstAction:b}),(D,I)=>(r(),h("div",i8e,[o("div",r8e,[o("span",d8e,f(i.value.title),1),m.value.key?(r(),h("span",{key:0,class:"view-all",onClick:S},f(A.value?c(d)('Search "%1$s" in %2$s',A.value,m.value.title):c(d)("See All %s",m.value.title)),1)):B("",!0)]),n(nd,{items:_.value,"on-action":L=>{V(L)},"no-results-text":A.value?c(d)("No matches found for %s",i.value.title):c(d)("Type something to find %s",i.value.title),ref_key:"navigableList",ref:p},{default:u(({item:L,index:O,isSelected:M})=>[o("div",u8e,[i.value.key==="products"?(r(),E(TBe,{key:0,product:L},null,8,["product"])):B("",!0),i.value.key==="orders"?(r(),E(jBe,{key:1,order:L},null,8,["order"])):B("",!0),i.value.key==="customers"?(r(),E(l8e,{key:2,customer:L},null,8,["customer"])):B("",!0),i.value.key==="coupons"?(r(),E(o8e,{key:3,coupon:L},null,8,["coupon"])):B("",!0)]),o("div",c8e,[n(J,{name:"Enter"})])]),_:1},8,["items","on-action","no-results-text"])]))}},p8e={class:"fct-global-search-input-wrap"},f8e=["aria-label"],m8e={class:"fct-setting-search-icon"},h8e={class:"fct-global-search-input-container"},_8e={key:0,class:"searched-item"},v8e={class:"fct-global-searching-for"},g8e={class:"fct-global-searching-for-label"},y8e={class:"fct-global-searching-suggestion-list"},b8e=["onClick"],w8e={class:"dialog-footer is-border"},C8e={class:"fct-search-commands"},k8e={class:"command-key"},B8e={class:"command-key"},x8e={class:"label"},S8e={class:"command-key"},$8e={class:"label"},F8e={class:"label"},E8e={__name:"GlobalSearch",setup(e){Zt().ctx,Wa();const t=T(!1),a=T(""),l=T({}),s=T(),i=T(""),A=T([d("orders"),d("products"),d("customers"),d("coupons"),d("settings"),d("menus"),d("shortcuts...")]),p=T(0),m=T(!0),_=T(0),g=T(null),y=T(null),v=T(70),k=T(40),w=T(1700),b=()=>{Fe(()=>{F()})},x=()=>{var ie,W;V.value?(ie=X.value)==null||ie.resetSelection():(W=$.value)==null||W.resetSelection(),V.value=!1,H.value=!1,Q()},F=()=>{var ie;(ie=s.value)==null||ie.focus()},Q=()=>{V.value=!1,l.value=[],t.value=!1,a.value="",D.value=null},$=T(),S=ie=>{let W=ie.includes(","),N={},ae=[];(W?ie.split(","):[ie]).forEach(re=>{re.includes(":")?U(re,N,ae):ae.push(re)});let Ae=[];return Object.keys(N).forEach(re=>{const Ue=N[re];Ue.length>0?Ue.forEach(we=>{we.length>0?Ae.push({group:"'"+re,title:we}):Ae.push({group:"'"+re})}):Ae.push({group:"'"+re})}),ae.forEach(re=>{re.length>0&&Ae.push({title:re})}),Ae},U=(ie,W,N)=>{if(ie.length===1)return;let ae=ie.split(":"),ee=ae[0],Ae=ae[1];ee.length>0?(W.hasOwnProperty(ee)||(W[ee]=[]),Ae.length>0&&W[ee].push(Ae)):N.push(Ae)},V=T(!1),D=T(null),I=T({o:{key:"orders",title:d("Orders")},p:{key:"products",title:d("Products")},c:{key:"customers",title:d("Customers")},d:{key:"coupons",title:d("Coupons")}}),L=ie=>{D.value=ie,V.value=!0,l.value={},Fe(()=>{var W,N;(W=X.value)==null||W.fetchData(a.value,ie),(N=s.value)==null||N.focus()})},O=()=>{var ie;l.value=[],D.value=null,a.value="",V.value=!1,(ie=s.value)==null||ie.focus(),H.value=!1},M=()=>{var ie;(ie=X.value)==null||ie.fetchData(a.value,D.value)},H=T(!1),z=ie=>{H.value=ie,Fe(()=>{var W;(W=s.value)==null||W.focus()})},X=T(),G=is(),Y=()=>{if(t.value){F();return}const ie=["o","p","c","d"];G.bind(ie,W=>{W.preventDefault();const N=I.value[W.key];N&&L(N)}),t.value=!0,Fe(()=>{var W;(W=$.value)==null||W.fetchRecentActions()}),setTimeout(()=>{G.unbind(ie)},800)};G.bind(["/"],ie=>{!t.value&&Z()||(ie.preventDefault(),Y())});const Z=()=>{const ie=document.activeElement;if(!ie)return!1;const W=ie.tagName;return W==="INPUT"||W==="TEXTAREA"||W==="SELECT"||ie.isContentEditable},de=()=>{if(g.value)return;const ie=()=>{if(s.value&&s.value.length>0)return;const N=A.value[p.value];if(m.value)_.value{y.value=null},w.value));else{if(y.value)return;_.value>0?(_.value--,i.value=N.slice(0,_.value)):(m.value=!0,p.value=(p.value+1)%A.value.length)}},W=()=>{ie();const N=m.value?v.value:y.value?120:k.value;g.value=setTimeout(W,N)};W()},j=T(!1);let ge;return De(()=>{de(),ge=new vn(sd,pBe());const ie=document.getElementById("fct_admin_menu_search");if(ie){const W=ie.querySelector(".fct-global-search-input-wrap");W&&W.remove()}j.value=!!ie,window.fluentCart=window.fluentCart||{},window.fluentCart.openSearch=Y}),xt(()=>{window.fluentCart&&delete window.fluentCart.openSearch}),(ie,W)=>{const N=C("el-input"),ae=C("el-dialog");return r(),h(P,null,[j.value?(r(),E(ci,{key:0,to:"#fct_admin_menu_search"},[o("div",p8e,[o("button",{onClick:Y,type:"button",class:"fct-setting-search-button","aria-label":c(d)("Search")},[o("span",m8e,[n(J,{name:"Search"})]),W[6]||(W[6]=o("span",{class:"fct-global-search-button-keys"},[o("kbd",{class:"fct-global-search-button-key"},"/")],-1))],8,f8e)])])):B("",!0),n(ae,{modelValue:t.value,"onUpdate:modelValue":W[5]||(W[5]=ee=>t.value=ee),onOpened:b,onClosed:x,class:"fct-global-search-container","append-to-body":!0},{header:u(()=>[o("div",h8e,[n(J,{name:"Search",class:"search-icon"}),D.value!=null?(r(),h("div",_8e,[R(f(D.value.title)+" ",1),n(J,{name:"Cross",class:"searched-item-remove",onClick:O})])):B("",!0),n(N,{class:"mousetrap",placeholder:c(d)("Search for %1$s",i.value),autofocus:"",ref_key:"searchRef",ref:s,id:"fct-global-search-input",disabled:H.value,onKeydown:[W[0]||(W[0]=da(Ge(()=>{var ee,Ae;if(V.value){(ee=X.value)==null||ee.focusList();return}(Ae=$.value)==null||Ae.focusList()},["prevent"]),["arrow-down"])),W[1]||(W[1]=da(Ge(()=>{var ee,Ae;if(V.value){(ee=X.value)==null||ee.performFirstAction();return}(Ae=$.value)==null||Ae.performFirstAction()},["prevent"]),["enter"])),W[2]||(W[2]=da(()=>{a.value.length===0&&(D.value=null,V.value=!1)},["backspace"]))],onInput:W[3]||(W[3]=()=>{if(V.value){M();return}let ee=a.value.includes(","),Ae=a.value.includes(":");if(!ee&&!Ae)l.value.value=c(ge).search(a.value);else{const re=S(a.value);l.value.value=c(ge).search({$or:re})}}),modelValue:a.value,"onUpdate:modelValue":W[4]||(W[4]=ee=>a.value=ee),clearable:""},null,8,["placeholder","disabled","modelValue"])])]),default:u(()=>[n(_a,{visible:!D.value&&a.value.length===0,accordion:""},{default:u(()=>[o("div",v8e,[o("div",g8e,f(c(d)("Searching for")),1),o("div",y8e,[(r(!0),h(P,null,le(I.value,ee=>{var Ae;return r(),h("div",{key:ee.key,onClick:re=>L(ee),class:ue(["fct-global-searching-suggestion",((Ae=D.value)==null?void 0:Ae.key)===ee.key?"active":""])},f(ee.title),11,b8e)}),128))])])]),_:1},8,["visible"]),V.value?(r(),E(A8e,{key:0,ref_key:"remoteResultRef",ref:X,query:a.value,tag:D.value,onCloseModal:Q,onOnRemoteSearchStateChange:z},null,8,["query","tag"])):(r(),E(UBe,{key:1,ref_key:"resultListRef",ref:$,query:a.value,"search-results":l.value.value,onActionPerformed:Q,focusInput:F,searchData:c(sd)},null,8,["query","search-results","searchData"])),o("div",w8e,[o("ul",C8e,[o("li",null,[o("span",k8e,[n(J,{name:"ArrowUp"})]),o("span",B8e,[n(J,{name:"ArrowDown"})]),o("span",x8e,f(c(d)("To navigate")),1)]),o("li",null,[o("span",S8e,[n(J,{name:"Enter"})]),o("span",$8e,f(c(d)("To select")),1)]),o("li",null,[W[7]||(W[7]=o("kbd",{class:"command-key"},"esc",-1)),o("span",F8e,f(c(d)("To close")),1)])])])]),_:1},8,["modelValue"])],64)}}},U8e={class:"fl_app fluent-cart-admin-pages"},I8e=Object.assign({name:"DashboardApplication"},{__name:"Application",setup(e){const t=T("");De(()=>{jQuery(".notice:not(.fluent-cart), .error:not(.fluent-cart), #ehp-admin-cb").remove(),t.value=a(),l.value=!!document.getElementById("theme-button-container");const A=document.querySelector(".fct_admin_menu_wrap"),p=()=>{window.scrollY>10?A==null||A.classList.add("scroll-header"):A==null||A.classList.remove("scroll-header")};window.addEventListener("scroll",p)});const a=()=>window.location.href,l=T(!1),s=Na();ke(()=>s.fullPath,()=>{t.value=a()});const i=K(()=>!(s.fullPath.includes("reports")||s.fullPath.includes("settings")));return(A,p)=>{const m=C("router-view");return r(),h("div",null,[n(E8e),i.value?(r(),E(Fa,{key:0})):B("",!0),o("div",U8e,[n(m)]),l.value?(r(),E(ci,{key:1,to:"#theme-button-container"},[n(bke)])):B("",!0)])}}});let qc=!1;function V8e(e){return{data:function(){return{appVars:window.fluentCartAdminApp}},methods:{$get:ce.get,$post:ce.post,$put:ce.put,$del:ce.delete,$t:d,$n:Do,formatMoney(t,a,l=!1){return!t&&l?"":(t||(t="0.00"),je.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),je.get("shop.currency_sign")+" "+t):t)},formatNumber(t,a=!0,l=!1,s){return vt.formatNumber(t,a,l,s)},formatNumberForOrder(t,a,l=!0,s=!1){return vt.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 Tm(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)=>{aA.show(t,a,l,s)},Storage:()=>Tt,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(){qc||(qc=!0,document.addEventListener("click",t=>{t.target.matches(".copyable-content")&&ls.copy(t.target.textContent)}))},currencySign(){return je.get("shop.currency_sign")},getPlaceholderImage(){return pl.productPlaceholder()},saveLocal(t,a){Tt.set(t,a)},getLocal(t){return Tt.get(t)},hasPermission(t){return sn.hasPermission(t)}}}}function D8e(e){e.beforeEach((t,a,l)=>{const s=dt.get(t,"meta.permission");return s?sn.resolve({permission:s,permissionType:dt.get(t,"meta.permissionType")})?l():l({name:"unauthorized"}):(je.get("app_config.env"),l())})}function Q8e(e){const t=A=>A.replace(/\/+$/,"")||"/",a=(A,p)=>{let m=null,_=0;return A.each(function(){const g=jQuery(this).find("a").first().attr("href")||"",y=g.indexOf("#");if(y===-1)return;const v=t(g.slice(y+1));(p===v||p.startsWith(v+"/"))&&v.length>_&&(m=jQuery(this),_=v.length)}),m},l=(A,p)=>{jQuery(".fct_menu li").removeClass("active_admin_menu"),jQuery(".fct_menu li.fct_menu_item_"+p).addClass("active_admin_menu");const m=a(jQuery(".fct_menu li.fct_menu_child_item"),A);m&&(m.addClass("active_admin_menu"),m.closest("li.fct_menu_item").addClass("active_admin_menu")),jQuery(".fct_admin_settings_btn").toggleClass("active_admin_menu",p==="settings")},s=(A,p)=>{const m=jQuery(".fct-offcanvas-menu-item");m.removeClass("active");const _=a(m,A);_?_.addClass("active"):p&&m.filter(".fct-offcanvas-menu-item_"+p).addClass("active")},i=(A,p)=>{const m=jQuery("#toplevel_page_fluent-cart .wp-submenu li");m.removeClass("current");const _=a(m,A);_?_.addClass("current"):p&&m.filter(".fluent_cart_"+p).addClass("current")};e.afterEach((A,p)=>{const m=A.meta.active_menu,_=t(A.path);l(_,m),s(_,m),i(_,m),A.meta.title&&jQuery("head title").text(A.meta.title+" - FluentCart")})}const T8e={mounted(e,t){const a=t.value,l=1e3,s=0,i=performance.now(),A=()=>{const p=performance.now()-i,m=Math.min(p/l,1),_=(s+m*(a-s)).toFixed(2);e.textContent=_,m<1&&requestAnimationFrame(A)};A()},updated(e,t){const a=t.value,l=2e3,s=0,i=performance.now(),A=()=>{const p=performance.now()-i,m=Math.min(p/l,1),_=(s+m*(a-s)).toFixed(2);e.textContent=_,m<1&&requestAnimationFrame(A)};A()}},M8e={__name:"Unauthorized",setup(e){return(t,a)=>(r(),h("span",null,f(c(d)("You are not allowed")),1))}},L8e=window.fluent_cart_admin.hooks.applyFilters("fluent_cart_routes",vke);let Yc=!1;document.addEventListener("fcart_renew_rest_nonce",function(e){Yc||El.alert(d("Your session has expired due to inactivity. Please refresh the page to continue."),d("Session Expired"),{confirmButtonText:d("Reload"),callback:t=>{Yc=!1,window.location.reload()}})});const R8e=[vm,gm,ym,sA,bm,rd,wm,Cm,dd,km,Bm,oA],Wl=dm(I8e);Wl.config.globalProperties.appVars=je.get();Wl.provide("appVars",je.get());Wl.mixin(V8e());Wl.directive("loading",Pm);Wl.directive("animate",T8e);rh(Wl);const Nd=um({routes:[...Object.values(L8e),{path:"/unauthorized",name:"unauthorized",component:M8e,props:!0},{path:"/:path(.*)*",name:"NotFound",component:mi,props:!0}],history:cm(),scrollBehavior(e,t,a){return a||{top:0,behavior:"smooth"}}});Wl.use(Nd);D8e(Nd);Q8e(Nd);R8e.forEach(e=>{Wl.component(e.name,e)});const Kd=je.get("el_strings"),Jf=je.get("datei18");Kd.el.datepicker.weeks=Jf.weekdaysShort;Kd.el.datepicker.months=Jf.monthsShort;Wl.use(Hm,{locale:Kd});Wl.mount("#fluent_cart_plugin_app");if(je.get("has_data_migrations")){let e=0;const t=()=>{ce.post("data-backfills/run").then(a=>{a&&a.status==="running"&&++e<100&&t()}).catch(()=>{})};t()}export{qn as E,Fd as _,IQ as n,cf as r,T4e as s};