PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
← All changes | assets/chunks/OrderCustomerInformation.js +1 -1 trunk → 1.6.5 View file →
@@ -1,5 +1,5 @@
1 -var We=Object.defineProperty;var Je=(e,l,t)=>l in e?We(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t;var Oe=(e,l,t)=>Je(e,typeof l!="symbol"?l+"":l,t);import{h as E,l as z,v as ce,i as Se,r as M,c as B,o as a,w as d,d as s,e as m,a as r,u as c,n as X,F as Y,t as o,b as g,g as ae,f as L,q as Me,M as Ue,k as Be,z as Ke,G as He}from"./vue.esm-bundler.js?ver=1.6.6";import{e as Ze,E as Qe,f as De}from"./index.js?ver=1.6.6";import{t as n,A as Ye,a as Ce}from"./Translator.js?ver=1.6.6";import{_ as Ge}from"./Animation.js?ver=1.6.6";import{P as Xe,B as et}from"./Badge.js?ver=1.6.6";import{R as ie}from"./Rest.js?ver=1.6.6";import{n as W}from"./Notify.js?ver=1.6.6";import{_ as Le}from"./_plugin-vue_export-helper.js?ver=1.6.6";import{_ as tt}from"./Empty.js?ver=1.6.6";import{b as st}from"./common.js?ver=1.6.6";import{I as Ee}from"./IconButton.js?ver=1.6.6";import{_ as ee}from"./DynamicIcon.js?ver=1.6.6";import{_ as lt,C as ke,a as xe,b as Ae}from"./CardBody.js?ver=1.6.6";import{_ as je}from"./UserCan.js?ver=1.6.6";import{A as at}from"./Arr.js?ver=1.6.6";import{A as ot}from"./Asset.js?ver=1.6.6";import{_ as le,a as Ve}from"./AddressComponent2.js?ver=1.6.6";import{L as Fe,u as nt}from"./NotFound.js?ver=1.6.6";import{f as rt}from"./productService.js?ver=1.6.6";const it={class:"fct-customer-edit-modal"},dt={class:"fct-compact-form"},ut={class:"form-heading"},ct={class:"fct-compact-form fct-customer-address-section"},mt={key:0,class:"mt-5"},pt={key:1,class:"form-error-wrap"},ft={class:"dialog-footer"},vt={__name:"NewCustomerModal",props:{customer_id:{type:[String,Number],default:null},customer:{type:Object,default:()=>({})},customerModalInfos:{type:Object,default:()=>({})}},emits:["close-modal","select-new-customer","update:customerModal"],setup(e,{emit:l}){const t=l,u=e,v=E({}),i=E(!1),p=E({}),w=window.fluentCartAdminApp,x=()=>{t("close-modal")},T=()=>{i.value=!0,v.value.wp_user=u.customerModalInfos.manageWpUser,ie.post("customers/",{...v.value}).then(y=>{t("select-new-customer",y.data),t("update:customerModal",!1),W.success(y.message),p.value={}}).catch(y=>{var _;y.status_code=="422"?(W.validationErrors(y),p.value=y.data):W.error((_=y.data)==null?void 0:_.message)}).finally(()=>{i.value=!1})},k=()=>{i.value=!0,v.value.wp_user=u.customerModalInfos.manageWpUser,ie.put("customers/"+u.customer_id,{...v.value}).then(y=>{t("select-new-customer",y.data),t("update:customerModal",!1),W.success(y.message),p.value={}}).catch(y=>{var _;y.status_code=="422"?(W.validationErrors(y),p.value=y.data):W.error((_=y.data)==null?void 0:_.message)}).finally(()=>{i.value=!1})},I=z(()=>u.customerModalInfos.action==="create"?n("Create as wordpress user"):n("Update wordpress user profile")),$=z(()=>u.customerModalInfos.action==="edit"?n("Update Customer"):n("Create Customer")),q=z(()=>{const y={};for(const _ in p.value){const b=p.value[_];y[_]=Array.isArray(b)?b:Object.values(b)}return y});return ce(()=>u.customer,y=>{v.value={id:y.id,email:y.email,full_name:y.full_name,first_name:y.first_name,last_name:y.last_name,state:y.state,city:y.city,country:y.country,postcode:y.postcode,country_name:y.country_name,contact_id:y.contact_id,user_id:y.user_id,wp_user:y.wp_user}},{deep:!0}),Se(()=>{v.value={id:u.customer.id,email:u.customer.email,full_name:u.customer.full_name,first_name:u.customer.first_name,last_name:u.customer.last_name,state:u.customer.state,city:u.customer.city,country:u.customer.country,postcode:u.customer.postcode,country_name:u.customer.country_name,contact_id:u.customer.contact_id,user_id:u.customer.user_id,wp_user:u.customer.wp_user}}),(y,_)=>{const b=M("el-checkbox"),j=M("el-button"),U=M("el-dialog");return a(),B(U,{modelValue:e.customerModalInfos.showModal,"onUpdate:modelValue":_[8]||(_[8]=C=>e.customerModalInfos.showModal=C),title:e.customerModalInfos.title,onClose:_[9]||(_[9]=()=>{p.value={}})},{default:d(()=>[s("div",it,[s("div",dt,[c(w).is_full_name_required?(a(),B(le,{key:0,label:c(n)("Full Name *"),modelValue:v.value.full_name,"onUpdate:modelValue":_[0]||(_[0]=C=>v.value.full_name=C),class:X(p.value.full_name?"is-error":"")},null,8,["label","modelValue","class"])):(a(),m(Y,{key:1},[r(le,{label:c(n)("First Name *"),modelValue:v.value.first_name,"onUpdate:modelValue":_[1]||(_[1]=C=>v.value.first_name=C),class:X(p.value.first_name?"is-error":"")},null,8,["label","modelValue","class"]),r(le,{label:c(n)("Last Name"),modelValue:v.value.last_name,"onUpdate:modelValue":_[2]||(_[2]=C=>v.value.last_name=C),class:X(p.value.last_name?"is-error":"")},null,8,["label","modelValue","class"])],64)),r(le,{type:"email",label:c(n)("Email *"),modelValue:v.value.email,"onUpdate:modelValue":_[3]||(_[3]=C=>v.value.email=C),disabled:e.customer.user_id&&e.customer.user_id!=0,class:X(p.value.email?"is-error":"")},null,8,["label","modelValue","disabled","class"])]),s("h4",ut,o(c(n)("Address")),1),s("div",ct,[r(Ve,{modelValue:v.value,"onUpdate:modelValue":_[4]||(_[4]=C=>v.value=C),validationErrors:p.value},null,8,["modelValue","validationErrors"]),e.customerModalInfos.action==="create"?(a(),m("div",mt,[r(b,{"true-value":"yes","false-value":"no",modelValue:e.customerModalInfos.manageWpUser,"onUpdate:modelValue":_[5]||(_[5]=C=>e.customerModalInfos.manageWpUser=C)},{default:d(()=>[r(Fe,{title:I.value,content:c(n)("We will create a new user for this customer. If a user with the same email already exists, we will associate the customer with that existing user.")},null,8,["title","content"])]),_:1},8,["modelValue"])])):g("",!0),Object.keys(p.value).length?(a(),m("div",pt,[(a(!0),m(Y,null,ae(q.value,(C,S)=>(a(),m("p",{key:S},[(a(!0),m(Y,null,ae(C,Q=>(a(),m("span",{key:Q},o(Q),1))),128))]))),128))])):g("",!0)]),s("div",ft,[r(j,{onClick:x},{default:d(()=>[L(o(c(n)("Cancel")),1)]),_:1}),e.customerModalInfos.action==="edit"?(a(),B(j,{key:0,loading:i.value,type:"primary",onClick:_[6]||(_[6]=C=>k())},{default:d(()=>[L(o($.value),1)]),_:1},8,["loading"])):(a(),B(j,{key:1,type:"primary",loading:i.value,onClick:_[7]||(_[7]=C=>T())},{default:d(()=>[L(o($.value),1)]),_:1},8,["loading"]))])])]),_:1},8,["modelValue","title"])}}},_t={key:1,class:"fct-export-loading"},ht={class:"fct-export-loading-grid"},gt={key:3,class:"fct-export-dialog-content"},yt={class:"fct-export-section"},bt={class:"fct-export-section-heading"},Ct={class:"fct-export-label"},wt={class:"fct-export-section-hint"},kt={class:"fct-export-section"},xt={class:"fct-export-section-heading"},At={class:"fct-export-label"},$t={class:"fct-export-format-options"},St=["aria-pressed","onClick"],Mt={class:"fct-export-format-name"},Lt={class:"fct-export-format-description"},Et={key:0,class:"fct-export-section fct-csv-columns-section"},Vt={class:"fct-export-selection-heading"},It={class:"fct-export-selection-heading-left"},Tt={class:"fct-export-label"},Ot={class:"fct-export-selection-count"},Pt={class:"fct-export-columns-wrap"},Nt={class:"fct-export-columns-grid"},Ut={key:1,class:"fct-export-section fct-json-modules-section"},Bt={class:"fct-export-selection-heading"},Dt={class:"fct-export-selection-heading-left"},jt={class:"fct-export-label"},Ft={class:"fct-export-selection-count"},Rt={class:"fct-export-modules"},qt=["onClick"],zt={key:0,class:"fct-export-required"},Wt={class:"fct-export-memory-note"},Jt={key:4,class:"fct-export-progress-section",role:"status","aria-live":"polite"},Kt={class:"fct-export-progress-title"},Ht={class:"fct-export-progress-meta"},Zt={class:"fct-export-progress-text"},Qt={class:"fct-export-progress-percentage"},Yt={class:"fct-export-progress-note"},Gt={key:5,class:"fct-export-error-section"},Xt={key:6,class:"fct-export-complete-section"},es={class:"dialog-footer"},bo=Object.assign({name:"ExportDialog"},{__name:"ExportDialog",props:{modelValue:{type:Boolean,default:!1},title:{type:String,default:""},selectedCount:{type:Number,default:0},currentPageCount:{type:Number,default:0},totalCount:{type:Number,default:0},itemLabelSingular:{type:String,default:""},itemLabelPlural:{type:String,default:""},hasActiveFilter:{type:Boolean,default:!1},exportState:{type:Object,required:!0}},emits:["update:modelValue","export"],setup(e,{emit:l}){const t=e,u=l,v=E("current_page"),i=E("csv"),p=E(new Set),w=E(new Set),x=z({get(){return t.modelValue},set(F){u("update:modelValue",F)}}),T=z(()=>t.exportState.schema.value||{formats:[],csv_columns:[],json_modules:[]}),k=z(()=>T.value.formats||[]),I=z(()=>T.value.csv_columns||[]),$=z(()=>T.value.json_modules||[]),q=z(()=>p.value.size),y=z(()=>w.value.size),_=z(()=>I.value.length>0&&q.value===I.value.length),b=z(()=>q.value>0&&!_.value),j=z(()=>i.value==="csv"),U=z(()=>i.value==="json"),C=z(()=>t.exportState.isProActive&&!t.exportState.isSchemaLoading.value&&T.value.entity&&!t.exportState.isExporting.value&&!t.exportState.isComplete.value&&!t.exportState.hasError.value),S=z(()=>j.value?q.value===0:y.value===0),Q=z(()=>{const F=v.value==="current_page"&&!t.currentPageCount||v.value==="selected"&&!t.selectedCount||v.value==="search_results"&&!se.value;return t.exportState.isExporting.value||S.value||F}),P=z(()=>t.itemLabelSingular||n("item")),te=z(()=>t.itemLabelPlural||n("items")),se=z(()=>t.hasActiveFilter?t.totalCount:0),O=z(()=>typeof window.showSaveFilePicker=="function"),K=F=>F===1?P.value:te.value,Z=z(()=>{const F=n("All %s",te.value);return t.hasActiveFilter?n("%1$s (%2$s)",F,n("filter applied")):F}),D=z(()=>n("%1$s %2$s matching the current view",se.value,K(se.value))),H=F=>F.value==="json"?n("JSON preserves selected database modules and their related rows."):n("CSV creates one row per record and works well in spreadsheet apps."),de=()=>{var F;i.value=((F=k.value[0])==null?void 0:F.value)||"csv",p.value=new Set(I.value.filter(R=>R.default_selected).map(R=>R.key)),w.value=new Set($.value.filter(R=>R.default_selected||R.required).map(R=>R.key))},h=F=>{const R=new Set(p.value);R.has(F)?R.delete(F):R.add(F),p.value=R},V=F=>{if(F.required)return;const R=new Set(w.value);R.has(F.key)?R.delete(F.key):R.add(F.key),w.value=R},f=()=>{p.value=new Set(I.value.map(F=>F.key))},A=()=>{p.value=new Set},G=F=>{F?f():A()};ce(()=>t.modelValue,F=>{F&&(v.value=t.currentPageCount?"current_page":"all",t.exportState.isExporting.value||t.exportState.resetState(),t.exportState.loadSchema().then(()=>{t.exportState.isExporting.value||de()}).catch(()=>{}))});const N=()=>{S.value||v.value==="search_results"&&!se.value||u("export",{scope:v.value,format:i.value,columns:Array.from(p.value),modules:Array.from(w.value)})},ne=()=>{t.exportState.isExporting.value&&t.exportState.cancelExport(),x.value=!1},ue=()=>{t.exportState.isExporting.value?t.exportState.cancelExport():x.value=!1};return(F,R)=>{const re=M("el-alert"),me=M("el-option"),he=M("el-select"),oe=M("el-icon"),pe=M("el-checkbox"),ge=M("el-progress"),ve=M("el-button"),ye=M("el-dialog");return a(),B(ye,{modelValue:x.value,"onUpdate:modelValue":R[2]||(R[2]=J=>x.value=J),title:e.title||c(n)("Export"),"append-to-body":!0,"close-on-click-modal":!e.exportState.isExporting.value,"close-on-press-escape":!e.exportState.isExporting.value,class:"fct-export-dialog",onClose:ne},{footer:d(()=>[s("div",es,[r(ve,{onClick:ue},{default:d(()=>[L(o(e.exportState.isExporting.value?c(n)("Cancel export"):c(n)("Close")),1)]),_:1}),C.value?(a(),B(ve,{key:0,type:"primary",disabled:Q.value,onClick:N},{default:d(()=>[L(o(c(n)("Export file")),1)]),_:1},8,["disabled"])):g("",!0)])]),default:d(()=>[e.exportState.isProActive?e.exportState.isSchemaLoading.value?(a(),m("div",_t,[R[3]||(R[3]=s("div",{class:"fct-export-loading-line"},null,-1)),R[4]||(R[4]=s("div",{class:"fct-export-loading-line is-short"},null,-1)),s("div",ht,[(a(),m(Y,null,ae(6,J=>s("div",{key:J,class:"fct-export-loading-option"})),64))])])):e.exportState.schemaError.value?(a(),B(re,{key:2,title:e.exportState.schemaError.value,type:"error",closable:!1,"show-icon":""},null,8,["title"])):g("",!0):(a(),B(Xe,{key:0,title:c(n)("Advanced data export is a Pro feature"),text:c(n)("Export configurable CSV files or schema-rich JSON data directly from your browser."),placement:"feature_lock_data_export"},null,8,["title","text"])),C.value?(a(),m("div",gt,[s("section",yt,[s("div",bt,[s("span",Ct,[L(o(c(n)("Records to export"))+" ",1),s("span",wt," ("+o(c(n)("Choose which records to include"))+") ",1)])]),r(he,{modelValue:v.value,"onUpdate:modelValue":R[0]||(R[0]=J=>v.value=J),class:"fct-export-options"},{default:d(()=>[r(me,{value:"current_page",disabled:!e.currentPageCount,label:e.currentPageCount?`${c(n)("Current page")} (${e.currentPageCount} ${K(e.currentPageCount)})`:c(n)("Current page")},null,8,["disabled","label"]),r(me,{value:"all",label:Z.value},null,8,["label"]),r(me,{value:"selected",disabled:!e.selectedCount,label:`${c(n)("Selected")} (${e.selectedCount} ${K(e.selectedCount)})`},null,8,["disabled","label"]),r(me,{value:"search_results",disabled:!se.value,label:D.value},null,8,["disabled","label"])]),_:1},8,["modelValue"])]),s("section",kt,[s("div",xt,[s("span",At,o(c(n)("File format")),1)]),s("div",$t,[(a(!0),m(Y,null,ae(k.value,J=>(a(),m("button",{key:J.value,type:"button",class:X(["fct-export-format-card",{"is-selected":i.value===J.value}]),"aria-pressed":i.value===J.value,onClick:fe=>i.value=J.value},[s("span",Mt,o(J.label),1),s("span",Lt,o(H(J)),1),r(oe,{class:"fct-export-format-check"},{default:d(()=>[r(c(Ze))]),_:1})],10,St))),128))])]),j.value?(a(),m("section",Et,[s("div",Vt,[s("div",It,[s("span",Tt,o(c(n)("CSV columns")),1),s("span",Ot," ("+o(c(n)("%1$s of %2$s selected",q.value,I.value.length))+") ",1)])]),s("div",Pt,[r(pe,{"model-value":_.value,indeterminate:b.value,disabled:!I.value.length,onChange:G},{default:d(()=>[L(o(c(n)("Select all")),1)]),_:1},8,["model-value","indeterminate","disabled"]),s("div",Nt,[(a(!0),m(Y,null,ae(I.value,J=>(a(),B(pe,{key:J.key,"model-value":p.value.has(J.key),onChange:fe=>h(J.key)},{default:d(()=>[L(o(J.label),1)]),_:2},1032,["model-value","onChange"]))),128))])])])):g("",!0),U.value?(a(),m("section",Ut,[s("div",Bt,[s("div",Dt,[s("span",jt,o(c(n)("Data modules")),1),s("span",Ft," ("+o(c(n)("%s selected",y.value))+") ",1)])]),s("div",Rt,[(a(!0),m(Y,null,ae($.value,J=>(a(),m("div",{key:J.key,class:X(["fct-export-module",{"is-selected":w.value.has(J.key),"is-required":J.required}]),onClick:fe=>V(J)},[r(pe,{"model-value":w.value.has(J.key),disabled:J.required,onClick:R[1]||(R[1]=Me(()=>{},["stop"])),onChange:fe=>V(J)},{default:d(()=>[L(o(J.label)+" ",1),J.required?(a(),m("small",zt,o(c(n)("Required")),1)):g("",!0)]),_:2},1032,["model-value","disabled","onChange"]),s("span",null,o(J.description),1)],10,qt))),128))]),T.value.sensitive_values_redacted?(a(),B(re,{key:0,title:c(n)("Authentication hashes, payment tokens, and other credentials are excluded or redacted from JSON exports."),type:"info",closable:!1,"show-icon":""},null,8,["title"])):g("",!0)])):g("",!0),S.value?(a(),B(re,{key:2,title:j.value?c(n)("Select at least one CSV column"):c(n)("Select at least one data module"),type:"warning",closable:!1,"show-icon":""},null,8,["title"])):g("",!0),s("p",Wt,o(O.value?c(n)("Large exports are written to disk batch by batch to keep browser memory low."):c(n)("This browser prepares the final download in memory. For very large exports, use a Chromium-based browser for direct-to-disk writing.")),1)])):g("",!0),e.exportState.isExporting.value?(a(),m("div",Jt,[s("div",Kt,o(c(n)("Exporting %s",te.value)),1),s("div",Ht,[s("span",Zt,o(e.exportState.progress.value.total?c(n)("%1$s of %2$s records written",e.exportState.progress.value.fetched,e.exportState.progress.value.total):c(n)("%s records written",e.exportState.progress.value.fetched)),1),s("span",Qt,o(e.exportState.progress.value.percentage)+"% ",1)]),r(Ge,{visible:!0,fade:"",duration:300},{default:d(()=>[r(ge,{percentage:e.exportState.progress.value.percentage,"stroke-width":6,striped:"","striped-flow":"","show-text":!1,class:"fct-export-progress-bar"},null,8,["percentage"])]),_:1}),s("p",Yt,o(e.exportState.writerMode.value==="direct"?c(n)("Writing each completed batch directly to your file."):c(n)("Keeping each response batch small while preparing the download.")),1)])):g("",!0),e.exportState.hasError.value?(a(),m("div",Gt,[r(re,{title:e.exportState.errorMessage.value||c(n)("Export failed"),type:"error",closable:!1,"show-icon":""},null,8,["title"])])):g("",!0),e.exportState.isComplete.value?(a(),m("div",Xt,[r(re,{title:c(n)("Export completed successfully"),description:c(n)("%s records exported",e.exportState.progress.value.fetched),type:"success",closable:!1,"show-icon":""},null,8,["title","description"])])):g("",!0)]),_:1},8,["modelValue","title","close-on-click-modal","close-on-press-escape"])}}}),ts=new TextEncoder,ss=64*1024*1024,ls=e=>/^[\x00-\x20]*[=+\-@]/.test(e)?"'"+e:e,Pe=e=>e==null?"":(typeof e=="object"&&(e=JSON.stringify(e)),e=ls(String(e)),e.includes(",")||e.includes('"')||e.includes(`
1 +var We=Object.defineProperty;var Je=(e,l,t)=>l in e?We(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t;var Oe=(e,l,t)=>Je(e,typeof l!="symbol"?l+"":l,t);import{h as E,l as z,v as ce,i as Se,r as M,c as B,o as a,w as d,d as s,e as m,a as r,u as c,n as X,F as Y,t as o,b as g,g as ae,f as L,q as Me,M as Ue,k as Be,z as Ke,G as He}from"./vue.esm-bundler.js?ver=1.6.5";import{e as Ze,E as Qe,f as De}from"./index.js?ver=1.6.5";import{t as n,A as Ye,a as Ce}from"./Translator.js?ver=1.6.5";import{_ as Ge}from"./Animation.js?ver=1.6.5";import{P as Xe,B as et}from"./Badge.js?ver=1.6.5";import{R as ie}from"./Rest.js?ver=1.6.5";import{n as W}from"./Notify.js?ver=1.6.5";import{_ as Le}from"./_plugin-vue_export-helper.js?ver=1.6.5";import{_ as tt}from"./Empty.js?ver=1.6.5";import{b as st}from"./common.js?ver=1.6.5";import{I as Ee}from"./IconButton.js?ver=1.6.5";import{_ as ee}from"./DynamicIcon.js?ver=1.6.5";import{_ as lt,C as ke,a as xe,b as Ae}from"./CardBody.js?ver=1.6.5";import{_ as je}from"./UserCan.js?ver=1.6.5";import{A as at}from"./Arr.js?ver=1.6.5";import{A as ot}from"./Asset.js?ver=1.6.5";import{_ as le,a as Ve}from"./AddressComponent2.js?ver=1.6.5";import{L as Fe,u as nt}from"./NotFound.js?ver=1.6.5";import{f as rt}from"./productService.js?ver=1.6.5";const it={class:"fct-customer-edit-modal"},dt={class:"fct-compact-form"},ut={class:"form-heading"},ct={class:"fct-compact-form fct-customer-address-section"},mt={key:0,class:"mt-5"},pt={key:1,class:"form-error-wrap"},ft={class:"dialog-footer"},vt={__name:"NewCustomerModal",props:{customer_id:{type:[String,Number],default:null},customer:{type:Object,default:()=>({})},customerModalInfos:{type:Object,default:()=>({})}},emits:["close-modal","select-new-customer","update:customerModal"],setup(e,{emit:l}){const t=l,u=e,v=E({}),i=E(!1),p=E({}),w=window.fluentCartAdminApp,x=()=>{t("close-modal")},T=()=>{i.value=!0,v.value.wp_user=u.customerModalInfos.manageWpUser,ie.post("customers/",{...v.value}).then(y=>{t("select-new-customer",y.data),t("update:customerModal",!1),W.success(y.message),p.value={}}).catch(y=>{var _;y.status_code=="422"?(W.validationErrors(y),p.value=y.data):W.error((_=y.data)==null?void 0:_.message)}).finally(()=>{i.value=!1})},k=()=>{i.value=!0,v.value.wp_user=u.customerModalInfos.manageWpUser,ie.put("customers/"+u.customer_id,{...v.value}).then(y=>{t("select-new-customer",y.data),t("update:customerModal",!1),W.success(y.message),p.value={}}).catch(y=>{var _;y.status_code=="422"?(W.validationErrors(y),p.value=y.data):W.error((_=y.data)==null?void 0:_.message)}).finally(()=>{i.value=!1})},I=z(()=>u.customerModalInfos.action==="create"?n("Create as wordpress user"):n("Update wordpress user profile")),$=z(()=>u.customerModalInfos.action==="edit"?n("Update Customer"):n("Create Customer")),q=z(()=>{const y={};for(const _ in p.value){const b=p.value[_];y[_]=Array.isArray(b)?b:Object.values(b)}return y});return ce(()=>u.customer,y=>{v.value={id:y.id,email:y.email,full_name:y.full_name,first_name:y.first_name,last_name:y.last_name,state:y.state,city:y.city,country:y.country,postcode:y.postcode,country_name:y.country_name,contact_id:y.contact_id,user_id:y.user_id,wp_user:y.wp_user}},{deep:!0}),Se(()=>{v.value={id:u.customer.id,email:u.customer.email,full_name:u.customer.full_name,first_name:u.customer.first_name,last_name:u.customer.last_name,state:u.customer.state,city:u.customer.city,country:u.customer.country,postcode:u.customer.postcode,country_name:u.customer.country_name,contact_id:u.customer.contact_id,user_id:u.customer.user_id,wp_user:u.customer.wp_user}}),(y,_)=>{const b=M("el-checkbox"),j=M("el-button"),U=M("el-dialog");return a(),B(U,{modelValue:e.customerModalInfos.showModal,"onUpdate:modelValue":_[8]||(_[8]=C=>e.customerModalInfos.showModal=C),title:e.customerModalInfos.title,onClose:_[9]||(_[9]=()=>{p.value={}})},{default:d(()=>[s("div",it,[s("div",dt,[c(w).is_full_name_required?(a(),B(le,{key:0,label:c(n)("Full Name *"),modelValue:v.value.full_name,"onUpdate:modelValue":_[0]||(_[0]=C=>v.value.full_name=C),class:X(p.value.full_name?"is-error":"")},null,8,["label","modelValue","class"])):(a(),m(Y,{key:1},[r(le,{label:c(n)("First Name *"),modelValue:v.value.first_name,"onUpdate:modelValue":_[1]||(_[1]=C=>v.value.first_name=C),class:X(p.value.first_name?"is-error":"")},null,8,["label","modelValue","class"]),r(le,{label:c(n)("Last Name"),modelValue:v.value.last_name,"onUpdate:modelValue":_[2]||(_[2]=C=>v.value.last_name=C),class:X(p.value.last_name?"is-error":"")},null,8,["label","modelValue","class"])],64)),r(le,{type:"email",label:c(n)("Email *"),modelValue:v.value.email,"onUpdate:modelValue":_[3]||(_[3]=C=>v.value.email=C),disabled:e.customer.user_id&&e.customer.user_id!=0,class:X(p.value.email?"is-error":"")},null,8,["label","modelValue","disabled","class"])]),s("h4",ut,o(c(n)("Address")),1),s("div",ct,[r(Ve,{modelValue:v.value,"onUpdate:modelValue":_[4]||(_[4]=C=>v.value=C),validationErrors:p.value},null,8,["modelValue","validationErrors"]),e.customerModalInfos.action==="create"?(a(),m("div",mt,[r(b,{"true-value":"yes","false-value":"no",modelValue:e.customerModalInfos.manageWpUser,"onUpdate:modelValue":_[5]||(_[5]=C=>e.customerModalInfos.manageWpUser=C)},{default:d(()=>[r(Fe,{title:I.value,content:c(n)("We will create a new user for this customer. If a user with the same email already exists, we will associate the customer with that existing user.")},null,8,["title","content"])]),_:1},8,["modelValue"])])):g("",!0),Object.keys(p.value).length?(a(),m("div",pt,[(a(!0),m(Y,null,ae(q.value,(C,S)=>(a(),m("p",{key:S},[(a(!0),m(Y,null,ae(C,Q=>(a(),m("span",{key:Q},o(Q),1))),128))]))),128))])):g("",!0)]),s("div",ft,[r(j,{onClick:x},{default:d(()=>[L(o(c(n)("Cancel")),1)]),_:1}),e.customerModalInfos.action==="edit"?(a(),B(j,{key:0,loading:i.value,type:"primary",onClick:_[6]||(_[6]=C=>k())},{default:d(()=>[L(o($.value),1)]),_:1},8,["loading"])):(a(),B(j,{key:1,type:"primary",loading:i.value,onClick:_[7]||(_[7]=C=>T())},{default:d(()=>[L(o($.value),1)]),_:1},8,["loading"]))])])]),_:1},8,["modelValue","title"])}}},_t={key:1,class:"fct-export-loading"},ht={class:"fct-export-loading-grid"},gt={key:3,class:"fct-export-dialog-content"},yt={class:"fct-export-section"},bt={class:"fct-export-section-heading"},Ct={class:"fct-export-label"},wt={class:"fct-export-section-hint"},kt={class:"fct-export-section"},xt={class:"fct-export-section-heading"},At={class:"fct-export-label"},$t={class:"fct-export-format-options"},St=["aria-pressed","onClick"],Mt={class:"fct-export-format-name"},Lt={class:"fct-export-format-description"},Et={key:0,class:"fct-export-section fct-csv-columns-section"},Vt={class:"fct-export-selection-heading"},It={class:"fct-export-selection-heading-left"},Tt={class:"fct-export-label"},Ot={class:"fct-export-selection-count"},Pt={class:"fct-export-columns-wrap"},Nt={class:"fct-export-columns-grid"},Ut={key:1,class:"fct-export-section fct-json-modules-section"},Bt={class:"fct-export-selection-heading"},Dt={class:"fct-export-selection-heading-left"},jt={class:"fct-export-label"},Ft={class:"fct-export-selection-count"},Rt={class:"fct-export-modules"},qt=["onClick"],zt={key:0,class:"fct-export-required"},Wt={class:"fct-export-memory-note"},Jt={key:4,class:"fct-export-progress-section",role:"status","aria-live":"polite"},Kt={class:"fct-export-progress-title"},Ht={class:"fct-export-progress-meta"},Zt={class:"fct-export-progress-text"},Qt={class:"fct-export-progress-percentage"},Yt={class:"fct-export-progress-note"},Gt={key:5,class:"fct-export-error-section"},Xt={key:6,class:"fct-export-complete-section"},es={class:"dialog-footer"},bo=Object.assign({name:"ExportDialog"},{__name:"ExportDialog",props:{modelValue:{type:Boolean,default:!1},title:{type:String,default:""},selectedCount:{type:Number,default:0},currentPageCount:{type:Number,default:0},totalCount:{type:Number,default:0},itemLabelSingular:{type:String,default:""},itemLabelPlural:{type:String,default:""},hasActiveFilter:{type:Boolean,default:!1},exportState:{type:Object,required:!0}},emits:["update:modelValue","export"],setup(e,{emit:l}){const t=e,u=l,v=E("current_page"),i=E("csv"),p=E(new Set),w=E(new Set),x=z({get(){return t.modelValue},set(F){u("update:modelValue",F)}}),T=z(()=>t.exportState.schema.value||{formats:[],csv_columns:[],json_modules:[]}),k=z(()=>T.value.formats||[]),I=z(()=>T.value.csv_columns||[]),$=z(()=>T.value.json_modules||[]),q=z(()=>p.value.size),y=z(()=>w.value.size),_=z(()=>I.value.length>0&&q.value===I.value.length),b=z(()=>q.value>0&&!_.value),j=z(()=>i.value==="csv"),U=z(()=>i.value==="json"),C=z(()=>t.exportState.isProActive&&!t.exportState.isSchemaLoading.value&&T.value.entity&&!t.exportState.isExporting.value&&!t.exportState.isComplete.value&&!t.exportState.hasError.value),S=z(()=>j.value?q.value===0:y.value===0),Q=z(()=>{const F=v.value==="current_page"&&!t.currentPageCount||v.value==="selected"&&!t.selectedCount||v.value==="search_results"&&!se.value;return t.exportState.isExporting.value||S.value||F}),P=z(()=>t.itemLabelSingular||n("item")),te=z(()=>t.itemLabelPlural||n("items")),se=z(()=>t.hasActiveFilter?t.totalCount:0),O=z(()=>typeof window.showSaveFilePicker=="function"),K=F=>F===1?P.value:te.value,Z=z(()=>{const F=n("All %s",te.value);return t.hasActiveFilter?n("%1$s (%2$s)",F,n("filter applied")):F}),D=z(()=>n("%1$s %2$s matching the current view",se.value,K(se.value))),H=F=>F.value==="json"?n("JSON preserves selected database modules and their related rows."):n("CSV creates one row per record and works well in spreadsheet apps."),de=()=>{var F;i.value=((F=k.value[0])==null?void 0:F.value)||"csv",p.value=new Set(I.value.filter(R=>R.default_selected).map(R=>R.key)),w.value=new Set($.value.filter(R=>R.default_selected||R.required).map(R=>R.key))},h=F=>{const R=new Set(p.value);R.has(F)?R.delete(F):R.add(F),p.value=R},V=F=>{if(F.required)return;const R=new Set(w.value);R.has(F.key)?R.delete(F.key):R.add(F.key),w.value=R},f=()=>{p.value=new Set(I.value.map(F=>F.key))},A=()=>{p.value=new Set},G=F=>{F?f():A()};ce(()=>t.modelValue,F=>{F&&(v.value=t.currentPageCount?"current_page":"all",t.exportState.isExporting.value||t.exportState.resetState(),t.exportState.loadSchema().then(()=>{t.exportState.isExporting.value||de()}).catch(()=>{}))});const N=()=>{S.value||v.value==="search_results"&&!se.value||u("export",{scope:v.value,format:i.value,columns:Array.from(p.value),modules:Array.from(w.value)})},ne=()=>{t.exportState.isExporting.value&&t.exportState.cancelExport(),x.value=!1},ue=()=>{t.exportState.isExporting.value?t.exportState.cancelExport():x.value=!1};return(F,R)=>{const re=M("el-alert"),me=M("el-option"),he=M("el-select"),oe=M("el-icon"),pe=M("el-checkbox"),ge=M("el-progress"),ve=M("el-button"),ye=M("el-dialog");return a(),B(ye,{modelValue:x.value,"onUpdate:modelValue":R[2]||(R[2]=J=>x.value=J),title:e.title||c(n)("Export"),"append-to-body":!0,"close-on-click-modal":!e.exportState.isExporting.value,"close-on-press-escape":!e.exportState.isExporting.value,class:"fct-export-dialog",onClose:ne},{footer:d(()=>[s("div",es,[r(ve,{onClick:ue},{default:d(()=>[L(o(e.exportState.isExporting.value?c(n)("Cancel export"):c(n)("Close")),1)]),_:1}),C.value?(a(),B(ve,{key:0,type:"primary",disabled:Q.value,onClick:N},{default:d(()=>[L(o(c(n)("Export file")),1)]),_:1},8,["disabled"])):g("",!0)])]),default:d(()=>[e.exportState.isProActive?e.exportState.isSchemaLoading.value?(a(),m("div",_t,[R[3]||(R[3]=s("div",{class:"fct-export-loading-line"},null,-1)),R[4]||(R[4]=s("div",{class:"fct-export-loading-line is-short"},null,-1)),s("div",ht,[(a(),m(Y,null,ae(6,J=>s("div",{key:J,class:"fct-export-loading-option"})),64))])])):e.exportState.schemaError.value?(a(),B(re,{key:2,title:e.exportState.schemaError.value,type:"error",closable:!1,"show-icon":""},null,8,["title"])):g("",!0):(a(),B(Xe,{key:0,title:c(n)("Advanced data export is a Pro feature"),text:c(n)("Export configurable CSV files or schema-rich JSON data directly from your browser."),placement:"feature_lock_data_export"},null,8,["title","text"])),C.value?(a(),m("div",gt,[s("section",yt,[s("div",bt,[s("span",Ct,[L(o(c(n)("Records to export"))+" ",1),s("span",wt," ("+o(c(n)("Choose which records to include"))+") ",1)])]),r(he,{modelValue:v.value,"onUpdate:modelValue":R[0]||(R[0]=J=>v.value=J),class:"fct-export-options"},{default:d(()=>[r(me,{value:"current_page",disabled:!e.currentPageCount,label:e.currentPageCount?`${c(n)("Current page")} (${e.currentPageCount} ${K(e.currentPageCount)})`:c(n)("Current page")},null,8,["disabled","label"]),r(me,{value:"all",label:Z.value},null,8,["label"]),r(me,{value:"selected",disabled:!e.selectedCount,label:`${c(n)("Selected")} (${e.selectedCount} ${K(e.selectedCount)})`},null,8,["disabled","label"]),r(me,{value:"search_results",disabled:!se.value,label:D.value},null,8,["disabled","label"])]),_:1},8,["modelValue"])]),s("section",kt,[s("div",xt,[s("span",At,o(c(n)("File format")),1)]),s("div",$t,[(a(!0),m(Y,null,ae(k.value,J=>(a(),m("button",{key:J.value,type:"button",class:X(["fct-export-format-card",{"is-selected":i.value===J.value}]),"aria-pressed":i.value===J.value,onClick:fe=>i.value=J.value},[s("span",Mt,o(J.label),1),s("span",Lt,o(H(J)),1),r(oe,{class:"fct-export-format-check"},{default:d(()=>[r(c(Ze))]),_:1})],10,St))),128))])]),j.value?(a(),m("section",Et,[s("div",Vt,[s("div",It,[s("span",Tt,o(c(n)("CSV columns")),1),s("span",Ot," ("+o(c(n)("%1$s of %2$s selected",q.value,I.value.length))+") ",1)])]),s("div",Pt,[r(pe,{"model-value":_.value,indeterminate:b.value,disabled:!I.value.length,onChange:G},{default:d(()=>[L(o(c(n)("Select all")),1)]),_:1},8,["model-value","indeterminate","disabled"]),s("div",Nt,[(a(!0),m(Y,null,ae(I.value,J=>(a(),B(pe,{key:J.key,"model-value":p.value.has(J.key),onChange:fe=>h(J.key)},{default:d(()=>[L(o(J.label),1)]),_:2},1032,["model-value","onChange"]))),128))])])])):g("",!0),U.value?(a(),m("section",Ut,[s("div",Bt,[s("div",Dt,[s("span",jt,o(c(n)("Data modules")),1),s("span",Ft," ("+o(c(n)("%s selected",y.value))+") ",1)])]),s("div",Rt,[(a(!0),m(Y,null,ae($.value,J=>(a(),m("div",{key:J.key,class:X(["fct-export-module",{"is-selected":w.value.has(J.key),"is-required":J.required}]),onClick:fe=>V(J)},[r(pe,{"model-value":w.value.has(J.key),disabled:J.required,onClick:R[1]||(R[1]=Me(()=>{},["stop"])),onChange:fe=>V(J)},{default:d(()=>[L(o(J.label)+" ",1),J.required?(a(),m("small",zt,o(c(n)("Required")),1)):g("",!0)]),_:2},1032,["model-value","disabled","onChange"]),s("span",null,o(J.description),1)],10,qt))),128))]),T.value.sensitive_values_redacted?(a(),B(re,{key:0,title:c(n)("Authentication hashes, payment tokens, and other credentials are excluded or redacted from JSON exports."),type:"info",closable:!1,"show-icon":""},null,8,["title"])):g("",!0)])):g("",!0),S.value?(a(),B(re,{key:2,title:j.value?c(n)("Select at least one CSV column"):c(n)("Select at least one data module"),type:"warning",closable:!1,"show-icon":""},null,8,["title"])):g("",!0),s("p",Wt,o(O.value?c(n)("Large exports are written to disk batch by batch to keep browser memory low."):c(n)("This browser prepares the final download in memory. For very large exports, use a Chromium-based browser for direct-to-disk writing.")),1)])):g("",!0),e.exportState.isExporting.value?(a(),m("div",Jt,[s("div",Kt,o(c(n)("Exporting %s",te.value)),1),s("div",Ht,[s("span",Zt,o(e.exportState.progress.value.total?c(n)("%1$s of %2$s records written",e.exportState.progress.value.fetched,e.exportState.progress.value.total):c(n)("%s records written",e.exportState.progress.value.fetched)),1),s("span",Qt,o(e.exportState.progress.value.percentage)+"% ",1)]),r(Ge,{visible:!0,fade:"",duration:300},{default:d(()=>[r(ge,{percentage:e.exportState.progress.value.percentage,"stroke-width":6,striped:"","striped-flow":"","show-text":!1,class:"fct-export-progress-bar"},null,8,["percentage"])]),_:1}),s("p",Yt,o(e.exportState.writerMode.value==="direct"?c(n)("Writing each completed batch directly to your file."):c(n)("Keeping each response batch small while preparing the download.")),1)])):g("",!0),e.exportState.hasError.value?(a(),m("div",Gt,[r(re,{title:e.exportState.errorMessage.value||c(n)("Export failed"),type:"error",closable:!1,"show-icon":""},null,8,["title"])])):g("",!0),e.exportState.isComplete.value?(a(),m("div",Xt,[r(re,{title:c(n)("Export completed successfully"),description:c(n)("%s records exported",e.exportState.progress.value.fetched),type:"success",closable:!1,"show-icon":""},null,8,["title","description"])])):g("",!0)]),_:1},8,["modelValue","title","close-on-click-modal","close-on-press-escape"])}}}),ts=new TextEncoder,ss=64*1024*1024,ls=e=>/^[\x00-\x20]*[=+\-@]/.test(e)?"'"+e:e,Pe=e=>e==null?"":(typeof e=="object"&&(e=JSON.stringify(e)),e=ls(String(e)),e.includes(",")||e.includes('"')||e.includes(`
2 2 `)||e.includes("\r")?'"'+e.replace(/"/g,'""')+'"':e);class as{constructor(l){this.filename=l.filename,this.format=l.format,this.entity=l.entity,this.schemaVersion=l.schemaVersion,this.columns=l.columns||[],this.modules=l.modules||[],this.memoryLimitMessage=l.memoryLimitMessage||"Export exceeds the safe in-memory limit.",this.parts=[],this.memoryBytes=0,this.writable=null,this.isFirstJsonRecord=!0,this.mode="memory"}open(){if(typeof window.showSaveFilePicker!="function")return Promise.resolve(this);const l=this.format==="json"?"application/json":"text/csv",t="."+this.format;return window.showSaveFilePicker({suggestedName:this.filename,types:[{description:this.format==="json"?"JSON file":"CSV file",accept:{[l]:[t]}}]}).then(u=>u.createWritable()).then(u=>(this.writable=u,this.mode="direct",this)).catch(u=>Promise.reject(u))}start(){if(this.format==="csv"){const u=this.columns.map(v=>Pe(v.label));return this.write("\uFEFF"+u.join(",")+`\r
3 3 `)}const l={schema_version:this.schemaVersion,entity:this.entity,modules:this.modules},t=JSON.stringify(l).slice(0,-1)+',"records":[';return this.write(t)}writeRecords(l){if(this.format==="csv"){const u=l.map(v=>this.columns.map(i=>Pe(v[i.key])).join(",")).join(`\r
4 4 `);return this.write(u?u+`\r
5 5 `:"")}const t=[];return l.forEach(u=>{this.isFirstJsonRecord||t.push(","),t.push(JSON.stringify(u)),this.isFirstJsonRecord=!1}),this.write(t.join(""))}close(){return(this.format==="json"?this.write("]}"):Promise.resolve()).then(()=>{if(this.writable)return this.writable.close();const t=this.format==="json"?"application/json;charset=utf-8":"text/csv;charset=utf-8",u=new Blob(this.parts,{type:t}),v=URL.createObjectURL(u),i=document.createElement("a");return i.href=v,i.download=this.filename,document.body.appendChild(i),i.click(),i.remove(),window.setTimeout(()=>URL.revokeObjectURL(v),1e3),this.parts=[],this.memoryBytes=0,Promise.resolve()})}abort(){return this.parts=[],this.memoryBytes=0,this.writable&&typeof this.writable.abort=="function"?this.writable.abort().catch(()=>{}):Promise.resolve()}write(l){if(!l)return Promise.resolve();const t=ts.encode(l);return this.writable?this.writable.write(t):this.memoryBytes+t.byteLength>ss?Promise.reject(new Error(this.memoryLimitMessage)):(this.parts.push(t),this.memoryBytes+=t.byteLength,Promise.resolve())}}const Ne=()=>({fetched:0,total:0,percentage:0,batches:0});function Co(e){const l=E(null),t=E(!1),u=E(""),v=E(!1),i=E(!1),p=E(!1),w=E(!1),x=E(""),T=E(""),k=E(Ne()),I=!!Ye.get("app_config.isProActive");let $=null,q=null,y=!1;const _=()=>{v.value=!1,i.value=!1,p.value=!1,w.value=!1,x.value="",T.value="",k.value=Ne()},b=()=>!I||l.value||t.value?Promise.resolve(l.value):(t.value=!0,u.value="",ie.get(`data-export/${e.entity}/schema`).then(O=>(l.value=O.export,l.value)).catch(O=>{var K;return u.value=((K=O==null?void 0:O.data)==null?void 0:K.message)||n("Unable to load export options."),Promise.reject(O)}).finally(()=>{t.value=!1})),j=()=>{v.value&&(i.value=!0,q==null||q.abort())},U=O=>{const K=new Date,Z=[K.getFullYear(),String(K.getMonth()+1).padStart(2,"0"),String(K.getDate()).padStart(2,"0")].join("-");return`${e.filenamePrefix}-${Z}.${O}`},C=O=>{const K={...O||{}};return["page","per_page","with","select","include_ids","query_timestamp"].forEach(Z=>delete K[Z]),K},S=O=>{const K=O.records.length,Z=k.value.total||Number(O.total||0),D=k.value.fetched+K;k.value={fetched:D,total:Z,percentage:Z?Math.min(100,Math.round(D/Z*100)):0,batches:k.value.batches+1}},Q=O=>{var D;const K=((D=O==null?void 0:O.data)==null?void 0:D.message)||(O==null?void 0:O.message)||n("Export failed. Please try again.");return($?$.abort():Promise.resolve()).finally(()=>{q=null,w.value=!0,x.value=K,v.value=!1,$=null})},P=()=>($?$.abort():Promise.resolve()).finally(()=>{q=null,v.value=!1,$=null,W.info(n("Export cancelled"))}),te=async(O,K)=>{var H;let Z=0,D=K;for(;;){if(i.value){await P();return}const de={format:O.format,scope:O.scope,ids:O.ids||[],columns:O.columns||[],modules:O.modules||[],filters:C(O.scope==="all"?e.buildAllParams():e.buildParams()),cursor:Z,max_records:D};q=new AbortController;const h=await ie.post(`data-export/${e.entity}/batch`,de,null,{signal:q.signal});q=null;const V=h==null?void 0:h.export;if(!V||!Array.isArray(V.records))throw new Error(n("The export response was invalid."));if(i.value){await P();return}if(!V.records.length&&!k.value.fetched){await $.abort(),$=null,v.value=!1,W.info(n("No data to export"));return}if(await $.writeRecords(V.records),S(V),k.value.total&&k.value.fetched>=k.value.total||!V.has_more||!V.cursor||!V.records.length){await $.close(),$=null,v.value=!1,p.value=!0,k.value.percentage=100;return}Z=V.cursor,D=Number(((H=V.batch)==null?void 0:H.next_max)||D)}},se=O=>{if(_(),!l.value)return w.value=!0,x.value=n("Export options are not available."),Promise.resolve();const K=l.value.csv_columns.filter(D=>O.columns.includes(D.key)),Z=l.value.json_modules.filter(D=>O.modules.includes(D.key)||D.required).map(D=>D.key);return $=new as({filename:U(O.format),format:O.format,entity:e.entity,schemaVersion:l.value.schema_version,columns:K,modules:Z,memoryLimitMessage:n("This export exceeds the 64 MB safe in-memory limit. Use a Chromium-based browser to write the file directly to disk.")}),v.value=!0,$.open().then(D=>(T.value=D.mode,D.start())).then(()=>{var H;const D=Number(((H=l.value.batching)==null?void 0:H.initial_records)||500);return te(O,D)}).catch(D=>D&&D.name==="AbortError"?(q=null,y?Promise.resolve($==null?void 0:$.abort()).finally(()=>{$=null,v.value=!1}):P()):Q(D))};return Ue(()=>{y=!0,i.value=!0,q==null||q.abort(),$==null||$.abort(),$=null}),{schema:l,isSchemaLoading:t,schemaError:u,isProActive:I,isExporting:v,isCancelled:i,isComplete:p,hasError:w,errorMessage:x,writerMode:T,progress:k,loadSchema:b,startExport:se,cancelExport:j,resetState:_}}const os={name:"OrderUpDownIndicator",props:{order:{type:Object,required:!0}},data(){var e,l;return{upgradeToId:((e=this.order.config)==null?void 0:e.upgraded_to)||null,upgradeFromId:((l=this.order.config)==null?void 0:l.upgraded_from)||null}}},ns={key:0,class:"ml-2"};function rs(e,l,t,u,v,i){const p=M("el-icon"),w=M("el-button"),x=M("router-link"),T=M("el-tooltip");return v.upgradeFromId||v.upgradeToId?(a(),m("span",ns,[v.upgradeFromId?(a(),B(T,{key:0,trigger:"click"},{content:d(()=>[L(o(e.$t("This order has been upgraded from"))+" ",1),r(x,{to:{name:"view_order",params:{order_id:v.upgradeFromId}}},{default:d(()=>[s("strong",null,"#"+o(v.upgradeFromId),1)]),_:1},8,["to"])]),default:d(()=>[r(w,{text:""},{default:d(()=>[r(p,null,{default:d(()=>l[0]||(l[0]=[s("svg",{viewBox:"0 0 24 24",width:"24",height:"24",color:"currentColor",fill:"none"},[s("defs"),s("path",{fill:"currentColor",d:"M11.943,1.75 L12.057,1.75 C14.248,1.75 15.969,1.75 17.312,1.931 C18.689,2.116 19.781,2.503 20.639,3.361 C21.497,4.219 21.884,5.311 22.069,6.688 C22.25,8.031 22.25,9.752 22.25,11.943 L22.25,12.057 C22.25,14.248 22.25,15.969 22.069,17.312 C21.884,18.689 21.497,19.781 20.639,20.639 C19.781,21.497 18.689,21.884 17.312,22.069 C15.969,22.25 14.248,22.25 12.057,22.25 L11.943,22.25 C9.752,22.25 8.031,22.25 6.688,22.069 C5.311,21.884 4.219,21.497 3.361,20.639 C2.503,19.781 2.116,18.689 1.931,17.312 C1.75,15.969 1.75,14.248 1.75,12.057 L1.75,11.943 C1.75,9.752 1.75,8.031 1.931,6.688 C2.116,5.311 2.503,4.219 3.361,3.361 C4.219,2.503 5.311,2.116 6.688,1.931 C8.031,1.75 9.752,1.75 11.943,1.75 L11.943,1.75 Z M4.422,4.422 C3.889,4.955 3.58,5.678 3.417,6.888 C3.252,8.12 3.25,9.74 3.25,12 C3.25,14.26 3.252,15.88 3.417,17.112 C3.58,18.322 3.889,19.045 4.422,19.578 C4.955,20.111 5.678,20.42 6.888,20.583 C8.12,20.748 9.74,20.75 12,20.75 C14.26,20.75 15.88,20.748 17.112,20.583 C18.322,20.42 19.045,20.111 19.578,19.578 C20.111,19.045 20.42,18.322 20.583,17.112 C20.748,15.88 20.75,14.26 20.75,12 C20.75,9.74 20.748,8.12 20.583,6.888 C20.42,5.678 20.111,4.955 19.578,4.422 C19.045,3.889 18.322,3.58 17.112,3.417 C15.88,3.252 14.26,3.25 12,3.25 C9.74,3.25 8.12,3.252 6.888,3.417 C5.678,3.58 4.955,3.889 4.422,4.422 Z M10.038,11.023 C9.749,11.32 9.274,11.326 8.977,11.038 C8.68,10.749 8.673,10.274 8.962,9.977 C9.051,9.886 9.197,9.704 9.41,9.433 L9.457,9.373 C9.647,9.131 9.87,8.847 10.099,8.576 C10.346,8.285 10.621,7.983 10.897,7.749 C11.035,7.631 11.19,7.515 11.358,7.425 C11.519,7.339 11.742,7.25 12,7.25 C12.258,7.25 12.481,7.339 12.642,7.425 C12.81,7.515 12.965,7.631 13.103,7.749 C13.379,7.983 13.654,8.285 13.901,8.576 C14.13,8.847 14.353,9.131 14.543,9.373 L14.543,9.373 L14.59,9.433 C14.804,9.704 14.949,9.886 15.038,9.977 C15.326,10.274 15.32,10.749 15.023,11.038 C14.726,11.326 14.251,11.32 13.962,11.023 C13.805,10.861 13.603,10.604 13.411,10.359 L13.366,10.302 C13.173,10.057 12.967,9.794 12.756,9.545 L12.75,9.538 L12.75,16 C12.75,16.414 12.414,16.75 12,16.75 C11.586,16.75 11.25,16.414 11.25,16 L11.25,9.538 L11.244,9.545 C11.033,9.794 10.827,10.057 10.634,10.302 L10.634,10.302 L10.589,10.359 C10.397,10.604 10.195,10.861 10.038,11.023 Z"})],-1)])),_:1,__:[0]})]),_:1})]),_:1})):g("",!0),v.upgradeToId?(a(),B(T,{key:1,trigger:"click"},{content:d(()=>[L(o(e.$t("This order has been upgraded to"))+" ",1),r(x,{to:{name:"view_order",params:{order_id:v.upgradeToId}}},{default:d(()=>[s("strong",null,"#"+o(v.upgradeToId),1)]),_:1},8,["to"])]),default:d(()=>[r(w,{text:""},{default:d(()=>[r(p,null,{default:d(()=>l[1]||(l[1]=[s("svg",{viewBox:"0 0 24 24",width:"24",height:"24",color:"currentColor",fill:"none"},[s("defs"),s("path",{fill:"currentColor",d:"M3.367,20.63 C1.756,19.02 1.756,16.672 1.756,11.995 L1.756,11.995 C1.756,7.317 1.756,4.97 3.367,3.359 C4.976,1.75 7.324,1.75 12.002,1.75 C16.68,1.75 19.026,1.75 20.637,3.359 C22.247,4.97 22.247,7.318 22.247,11.996 C22.247,16.674 22.247,19.022 20.637,20.631 C19.026,22.242 16.678,22.242 12,22.242 L12.003,22.241 C7.326,22.241 4.976,22.241 3.367,20.63 Z M4.427,4.418 C3.256,5.59 3.256,7.73 3.256,11.994 L3.256,11.995 C3.256,16.259 3.256,18.399 4.427,19.569 C5.597,20.741 7.738,20.741 12.003,20.741 C16.269,20.741 18.408,20.741 19.58,19.569 C20.75,18.399 20.75,16.259 20.75,11.993 L20.75,11.993 C20.75,7.727 20.75,5.588 19.58,4.417 C18.408,3.247 16.268,3.247 12.005,3.247 L12.003,3.248 C7.739,3.248 5.599,3.248 4.427,4.418 Z M12.024,8.951 C12.121,9.047 12.306,9.198 12.578,9.415 L12.654,9.476 L12.654,9.476 C12.894,9.667 13.172,9.888 13.437,10.117 C13.727,10.367 14.029,10.648 14.262,10.932 C14.432,11.139 14.661,11.456 14.726,11.834 C14.729,11.85 14.732,11.866 14.734,11.883 C14.741,11.94 14.745,11.999 14.745,12.059 C14.744,12.083 14.743,12.106 14.74,12.13 C14.693,12.568 14.41,12.933 14.199,13.168 C13.96,13.435 13.661,13.696 13.375,13.93 C13.152,14.112 12.918,14.292 12.71,14.452 C12.651,14.497 12.594,14.541 12.541,14.582 C12.277,14.786 12.109,14.923 12.027,15.007 C11.739,15.305 11.264,15.312 10.967,15.024 C10.669,14.735 10.662,14.26 10.95,13.963 C11.121,13.787 11.382,13.582 11.623,13.396 C11.684,13.349 11.745,13.302 11.807,13.254 C12.012,13.097 12.222,12.935 12.427,12.768 L12.483,12.722 L6.995,12.715 C6.581,12.715 6.246,12.379 6.246,11.964 C6.247,11.55 6.583,11.215 6.997,11.215 L12.422,11.222 C12.191,11.024 11.949,10.832 11.718,10.648 L11.718,10.648 L11.643,10.588 C11.396,10.391 11.134,10.181 10.965,10.012 C10.672,9.72 10.671,9.245 10.964,8.952 C11.257,8.659 11.731,8.658 12.024,8.951 Z M17.754,8.001 L17.745,15.993 C17.744,16.407 17.408,16.743 16.994,16.742 C16.58,16.742 16.244,16.405 16.245,15.991 L16.254,7.999 C16.255,7.585 16.591,7.25 17.005,7.25 C17.419,7.25 17.755,7.587 17.754,8.001 Z"})],-1)])),_:1,__:[1]})]),_:1})]),_:1})):g("",!0)])):g("",!0)}const wo=Le(os,[["render",rs]]);class Re{static copyModern(l){return navigator.clipboard.writeText(l)}static copyLegacy(l){const t=document.createElement("textarea");t.value=l,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select();try{return document.execCommand("copy"),t.remove(),Promise.resolve()}catch{return t.remove(),Promise.reject(new Error(n("Failed to copy text")))}}static async copy(l,t={}){const v={...{showNotification:!0,duration:2e3},...t};v.successMessage=v.successMessage||n("Copied to clipboard"),v.errorMessage=v.successMessage||n("Copied to clipboard");try{return navigator.clipboard&&window.isSecureContext?await this.copyModern(l):await this.copyLegacy(l),v.showNotification&&W.success(v.successMessage),!0}catch{return v.showNotification&&Qe.alert(l,n("Please copy this text: "),{confirmButtonText:n("Close")}),!1}}static copyElement(l,t={}){if(!l)throw new Error(n("Element not provided"));const u=l.textContent||l.value||"";return this.copy(u,t)}}const is={class:"fct-copy-wrap"},ds={key:0,class:"fct-copy-basic"},us={key:1,class:"fct-copy-basic-wrap"},cs={class:"fct-copy-basic"},ms={key:2,class:"fct-copy-advanced flex"},ps=["value","placeholder"],fs=["disabled"],be={__name:"CopyToClipboard",props:{showMode:{type:String,default:""},tooltipText:{type:String,default:n("Copy")},text:[String,Number],placeholder:String,buttonText:{type:String,default:n("Copy")},tooltipContent:{type:String,default:""},placement:{type:String,default:"top-end"}},setup(e){const l=e,t=E(l.text),u=E(null),v=i=>{i.preventDefault();const p=t.value;Re.copy(p)};return ce(()=>l.text,i=>{t.value=i},{deep:!0}),(i,p)=>{const w=M("el-button"),x=M("el-tooltip");return a(),m("div",is,[e.showMode==="basic_copy_btn"?(a(),m("div",ds,[s("span",{ref_key:"copyTooltip",ref:u,class:"copy-tooltip"},o(e.tooltipText),513),s("button",{class:"fct-copy-btn",onClick:v},p[0]||(p[0]=[s("svg",{viewBox:"0 0 20 20","aria-hidden":"true",width:"20",height:"20"},[s("path",{"fill-rule":"evenodd",d:"M6.515 4.75a2 2 0 0 1 1.985-1.75h3a2 2 0 0 1 1.985 1.75h.265a2.25 2.25 0 0 1 2.25 2.25v7.75a2.25 2.25 0 0 1-2.25 2.25h-7.5a2.25 2.25 0 0 1-2.25-2.25v-7.75a2.25 2.25 0 0 1 2.25-2.25h.265Zm1.985-.25h3a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5Zm-1.987 1.73.002.02h-.265a.75.75 0 0 0-.75.75v7.75c0 .414.336.75.75.75h7.5a.75.75 0 0 0 .75-.75v-7.75a.75.75 0 0 0-.75-.75h-.265a2 2 0 0 1-1.985 1.75h-3a2 2 0 0 1-1.987-1.77Z"})],-1)]))])):e.showMode==="icon_with_text"?(a(),m("div",us,[s("div",cs,[s("span",{ref_key:"copyTooltip",ref:u,class:"copy-tooltip"},o(e.tooltipText),513),r(w,{class:"fct-copy-text-btn",text:"",onClick:v},{default:d(()=>[r(ee,{name:"Copy"}),L(" "+o(e.buttonText),1)]),_:1})]),e.tooltipContent?(a(),B(x,{key:0,"popper-class":"fct-tooltip",content:e.tooltipContent,placement:e.placement,"show-after":400,"hide-after":0},{default:d(()=>[s("span",null,[r(ee,{name:"InformationFill",class:"w-4.5 h-4.5"})])]),_:1},8,["content","placement"])):g("",!0)])):(a(),m("div",ms,[s("input",{type:"text",class:"w-full",readonly:"",value:t.value,placeholder:e.placeholder},null,8,ps),s("span",{ref_key:"copyTooltip",ref:u,hidden:"",class:"copy-tooltip"},o(i.$t("Copied!")),513),s("button",{class:"fct-copy-btn flex",onClick:v,disabled:!t.value},[r(ee,{name:"Copy"}),L(" "+o(i.$t("Copy")),1)],8,fs)]))])}}},we=class we{static emptyImage(l=!1){return we.assetUrl()+(l?"images/empty-image-dark.svg":"images/empty-image.svg")}};Oe(we,"assetUrl",()=>ot.url());let $e=we;const vs={components:{DynamicIcon:ee},props:{product:{type:Object},hideProductId:{type:Boolean,default:!1},hideViewIcon:{type:Boolean,default:!1},hideImage:{type:Boolean,default:!1}},data(){return{}},methods:{translate:n,translateNumber:Ce,getImage(e,l=!1){return at.get(e,"featured_media.url")??$e.emptyImage(l)}}},_s={class:"fct-product-info-card w-full"},hs={key:0,class:"fct-product-info-media"},gs=["src","alt"],ys=["src","alt"],bs={class:"fct-product-info-details"},Cs={class:"fct-product-info-name"},ws={class:"product-name"},ks={class:"product-name-inner"},xs=["href"],As={key:0,class:"product-id"},$s={key:1,class:"product-sub-name"};function Ss(e,l,t,u,v,i){var w,x,T,k,I,$,q,y,_;const p=M("DynamicIcon");return a(),m("div",_s,[t.hideImage?g("",!0):(a(),m("div",hs,[s("span",null,[s("img",{class:"block dark:hidden",src:i.getImage((w=t.product)==null?void 0:w.detail),alt:(x=t.product)==null?void 0:x.post_title},null,8,gs),s("img",{class:"hidden dark:block",src:i.getImage((T=t.product)==null?void 0:T.detail,!0),alt:(k=t.product)==null?void 0:k.post_title},null,8,ys)])])),s("div",bs,[s("div",Cs,[s("span",ws,[s("span",ks,o(((I=t.product)==null?void 0:I.post_title)||i.translate("No Name")),1),t.hideViewIcon?g("",!0):(a(),m("a",{key:0,class:"view-link right-1",target:"_blank",href:($=t.product)==null?void 0:$.view_url,onClick:l[0]||(l[0]=Me(()=>{},["stop"]))},[r(p,{class:"w-5 h-5",name:"Eye"})],8,xs))]),t.hideProductId?g("",!0):(a(),m("span",As," #"+o(i.translateNumber((q=t.product)==null?void 0:q.ID)),1)),(y=t.product)!=null&&y.variation_title?(a(),m("span",$s," – "+o((_=t.product)==null?void 0:_.variation_title),1)):g("",!0)])])])}const Ms=Le(vs,[["render",Ss]]),Ls={name:"LicenseTable",components:{ProductInfo:Ms,UserCan:je,RouteCell:lt,DynamicIcon:ee,IconButton:Ee,CopyToClipboard:be,Empty:tt,Badge:et},props:{licenses:{type:Array,required:!0},columns:{type:Array,default(){return["product","order_id","customer","date"]}}},computed:{Clipboard(){return Re},formattedLicense(){return this.licenses.map(e=>{var l;return{...e,product:{...e.product,variation_title:((l=e.product_variant)==null?void 0:l.variation_title)||"n/a"}}})}},methods:{translate:n,formatDate:st,translateNumber:Ce,getProductName(e){var l,t;return(l=e==null?void 0:e.product)!=null&&l.post_title?(t=e==null?void 0:e.product)==null?void 0:t.post_title:"n/a"},getProductVariationName(e){var l,t;return(l=e==null?void 0:e.product_variant)!=null&&l.variation_title?(t=e==null?void 0:e.product_variant)==null?void 0:t.variation_title:"n/a"}}},Es={class:"fct_licenses_table hide-on-mobile"},Vs={class:"fct-license-key-wrap flex flex-col"},Is={class:"fct-license-key max-w-full pr-1"},Ts={class:"fct-license-key-inner pr-2"},Os={key:0},Ps={key:1},Ns={class:"fct_licenses_table_mobile"},Us={class:"fct-table-mobile-wrap"},Bs=["onClick"],Ds={class:"fct-table-mobile-header-left"},js={class:"fct-table-status-col"},Fs={class:"fct-table-activations-col"},Rs={class:"fct-table-mobile-body"},qs=["onClick"],zs={class:"fct-license-key-wrap has-bg"},Ws={class:"fct-license-key"},Js={class:"fct-license-key-inner pr-2"};function Ks(e,l,t,u,v,i){const p=M("Badge"),w=M("router-link"),x=M("DynamicIcon"),T=M("el-tooltip"),k=M("el-table-column"),I=M("ProductInfo"),$=M("RouteCell"),q=M("Empty"),y=M("el-table"),_=M("UserCan");return a(),B(_,{permission:"licenses/view"},{default:d(()=>[s("div",Es,[r(y,{data:i.formattedLicense,class:"w-full compact-table"},{empty:d(()=>[r(q,{icon:"Empty/ListView","has-dark":!0,text:i.translate("No Licenses found based on your filter")},null,8,["text"])]),default:d(()=>[r(k,{label:i.translate("License Key"),width:200},{default:d(b=>{var j;return[s("div",Vs,[s("span",null,[(a(),B(p,{status:b.row.status,key:b.row.id},null,8,["status"]))]),s("span",Is,[s("span",Ts,[r(w,{class:"link",to:{name:"view_license",params:{license_id:(j=b.row)==null?void 0:j.id}}},{default:d(()=>[L(o(b.row.license_key),1)]),_:2},1032,["to"])]),r(T,{content:b.row.license_key,placement:"top","popper-class":"fct-tooltip"},{default:d(()=>[r(x,{class:"cursor-pointer p-1 w-6 h-6 flex-none",name:"Copy",onClick:()=>{i.Clipboard.copy(b.row.license_key,{successMessage:i.translate("License Key copied to clipboard"),errorMessage:i.translate("Failed to copy License Key")})}},null,8,["onClick"])]),_:2},1032,["content"])])])]}),_:1},8,["label"]),t.columns.indexOf("product")!==-1?(a(),B(k,{key:0,width:200,label:i.translate("Product")},{default:d(b=>{var j;return[r($,{class:"link block hover:no-underline",to:{name:"view_license",params:{license_id:(j=b.row)==null?void 0:j.id}}},{default:d(()=>[r(I,{product:b.row.product,hideProductId:!0,hideViewIcon:!0,hideImage:!0},null,8,["product"])]),_:2},1032,["to"])]}),_:1},8,["label"])):g("",!0),t.columns.indexOf("order_id")!==-1?(a(),B(k,{key:1,width:80,label:i.translate("Order ID")},{default:d(b=>[r($,{class:"link order_id block hover:no-underline relative w-full",to:{name:"view_order",params:{order_id:b.row.order_id}}},{default:d(()=>[r(w,{class:"link absolute left-1/2 top-1/2 translate-x-[calc(-50%-16px)] translate-y-[-50%]",to:{name:"view_order",params:{order_id:b.row.order_id}}},{default:d(()=>[L(" #"+o(b.row.order_id),1)]),_:2},1032,["to"])]),_:2},1032,["to"])]),_:1},8,["label"])):g("",!0),t.columns.indexOf("customer")!==-1?(a(),B(k,{key:2,width:100,label:i.translate("Customer")},{default:d(b=>[r(w,{class:"link",to:{name:"view_customer",params:{customer_id:b.row.customer_id}}},{default:d(()=>{var j,U;return[L(o(((U=(j=b.row)==null?void 0:j.customer)==null?void 0:U.full_name)||i.translate("No Name")),1)]}),_:2},1032,["to"])]),_:1},8,["label"])):g("",!0),r(k,{width:90,label:i.translate("Activations")},{default:d(b=>{var j;return[r($,{class:"link block hover:no-underline relative w-full",to:{name:"view_license",params:{license_id:(j=b.row)==null?void 0:j.id}}},{default:d(()=>[L(o(i.translateNumber(b.row.activation_count))+" / "+o(b.row.limit==0?"Unlimited":b.row.limit),1)]),_:2},1032,["to"])]}),_:1},8,["label"]),t.columns.indexOf("date")!==-1?(a(),B(k,{key:3,width:140,label:i.translate("Date")},{default:d(b=>{var j;return[r($,{class:"block hover:no-underline w-full",to:{name:"view_license",params:{license_id:(j=b.row)==null?void 0:j.id}}},{default:d(()=>[s("div",null,[s("span",null,o(i.formatDate(b.row.created_at)),1),l[0]||(l[0]=s("span",{class:"text-gray-300 px-2"},"–",-1)),b.row.expiration_date?(a(),m("span",Os,o(i.formatDate(b.row.expiration_date)),1)):(a(),m("span",Ps,o(i.translate("Lifetime")),1))])]),_:2},1032,["to"])]}),_:1},8,["label"])):g("",!0)]),_:1},8,["data"])]),s("div",Ns,[s("div",Us,[(a(!0),m(Y,null,ae(i.formattedLicense,(b,j)=>(a(),m("div",{key:j,class:"fct-table-mobile-row"},[s("div",{class:"fct-table-mobile-header",onClick:U=>e.$router.push({name:"view_license",params:{license_id:b==null?void 0:b.id}})},[s("div",Ds,[s("div",js,[(a(),B(p,{status:b.status,key:b.id},null,8,["status"]))]),s("div",Fs,o(b.activation_count)+" / "+o(b.limit==0?"Unlimited":b.limit),1)])],8,Bs),s("div",Rs,[s("div",{class:"fct-table-product-col",onClick:U=>e.$router.push({name:"view_license",params:{license_id:b==null?void 0:b.id}})},[r(I,{product:b.product,hideProductId:!0,hideViewIcon:!0,hideImage:!0},null,8,["product"])],8,qs),s("div",zs,[s("div",Ws,[s("div",Js,[r(w,{class:"link",to:{name:"view_license",params:{license_id:b==null?void 0:b.id}}},{default:d(()=>[L(o(b.license_key),1)]),_:2},1032,["to"])]),r(x,{class:"cursor-pointer p-1 w-6 h-6",name:"Copy",onClick:()=>{i.Clipboard.copy(b.license_key,{successMessage:i.translate("License Key copied to clipboard"),errorMessage:i.translate("Failed to copy License Key")})}},null,8,["onClick"])])])])]))),128))])])]),_:1})}const ko=Le(Ls,[["render",Ks]]),Hs={class:"fct_edit_customer_popup"},Zs={key:0,class:"fct-customer-address-business-details"},Qs={class:"fct-customer-address-business-details-title"},Ys={class:"form-error-wrap"},Gs=["innerHTML"],Xs={class:"dialog-footer"},qe=Object.assign({name:"AddOrEditAddressModal"},{__name:"AddOrEditAddressModal",props:["customer_id","modalAction","address","showAddressModal","order_id","customerAddressModalInfos","showSetAsAlsoCheckbox","closing_modal","showBusinessDetailsSection"],emits:["close-modal","update:refresh-address"],setup(e,{emit:l}){const t=e,u=l;E([]);const v=E(!1),i=E({}),p=E(!1),w=E(!1),x=E(!1);E(null);function T(U={}){return{label:"",name:"",email:"",company_name:"",vat_number:"",legal_registration_id:"",phone:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",...U??{}}}const k=E(T(t.address)),I=Be().ctx,$=z(()=>{var U;return((U=window.fluentCartAdminApp)==null?void 0:U.business_details)||{}}),q=z(()=>{var U,C,S,Q;return!!t.showBusinessDetailsSection&&((U=t.modalAction)==null?void 0:U.type)==="billing"&&(((C=$.value.company_name)==null?void 0:C.enabled)||((S=$.value.vat_number)==null?void 0:S.enabled)||((Q=$.value.legal_registration_id)==null?void 0:Q.enabled))});nt().onSave(()=>{t.showAddressModal&&["billing","shipping"].includes(t.modalAction.type)&&(t.modalAction.action==="edit"&&I.address.id!==""?j():t.modalAction.action==="create"&&b())});const _=U=>{let C="";for(const S in U){const Q=U[S],P=Object.values(Q);C+=P+" </br>"}return C},b=()=>{p.value=!0;let U={type:t.modalAction.type,customer_id:t.customer_id,order_id:t.order_id??null},C={...k.value,...U};C.sync=x.value,ie.post("customers/"+t.customer_id+"/address",{...C}).then(S=>{u("update:refresh-address",!1,S.data),W.success(S.message),i.value={}}).catch(S=>{var Q;S.status_code=="422"?(W.validationErrors(S),i.value=S.data):W.error((Q=S.data)==null?void 0:Q.message)}).finally(()=>{v.value=!1,p.value=!1})},j=()=>{w.value=!0;let C={...{type:t.modalAction.type,customer_id:t.customer_id,is_primary:t.address.is_primary,id:t.address.id,order_id:t.order_id&&t.address.is_primary==1?t.order_id:null},...k.value};ie.put("customers/"+t.customer_id+"/address",{...C}).then(S=>{x.value,u("update:refresh-address",!1,S.data),W.success(S.message),i.value={}}).catch(S=>{var Q;S.status_code=="422"?(W.validationErrors(S),i.value=S):W.error((Q=S.data)==null?void 0:Q.message)}).finally(()=>{v.value=!1,w.value=!1})};return ce(()=>t.closing_modal,(U,C)=>{U&&(i.value={})}),ce(()=>t.address,U=>{k.value=T(U)},{deep:!0,immediate:!0}),ce(()=>t.showAddressModal,U=>{U||(k.value=T({}),i.value={})}),(U,C)=>{const S=M("el-form"),Q=M("el-checkbox"),P=M("el-button");return a(),m("div",Hs,[r(S,{"label-position":"top",class:"fct-compact-form","require-asterisk-position":"right"},{default:d(()=>{var te,se,O,K,Z,D;return[r(le,{label:c(n)("Address Label"),class:X(i.value.hasOwnProperty("label")?"is-error":""),modelValue:k.value.label,"onUpdate:modelValue":C[0]||(C[0]=H=>k.value.label=H)},null,8,["label","class","modelValue"]),r(le,{label:c(n)("Name"),required:"",class:X(i.value.hasOwnProperty("name")?"is-error":""),modelValue:k.value.name,"onUpdate:modelValue":C[1]||(C[1]=H=>k.value.name=H)},null,8,["label","class","modelValue"]),r(le,{label:c(n)("Email"),required:"",class:X(i.value.hasOwnProperty("email")?"is-error":""),modelValue:k.value.email,"onUpdate:modelValue":C[2]||(C[2]=H=>k.value.email=H)},null,8,["label","class","modelValue"]),r(le,{label:c(n)("Phone"),required:"",class:X(i.value.hasOwnProperty("phone")?"is-error":""),modelValue:k.value.phone,"onUpdate:modelValue":C[3]||(C[3]=H=>k.value.phone=H)},null,8,["label","class","modelValue"]),r(Ve,{use_additional_address_fields:"",modelValue:k.value,"onUpdate:modelValue":C[4]||(C[4]=H=>k.value=H),validationErrors:i.value},null,8,["modelValue","validationErrors"]),q.value?(a(),m("div",Zs,[s("h3",Qs,o(c(n)("Business Details")),1),(te=$.value.company_name)!=null&&te.enabled?(a(),B(le,{key:0,label:c(n)("Company Name"),required:(se=$.value.company_name)==null?void 0:se.required,class:X(i.value.hasOwnProperty("company_name")?"is-error":""),modelValue:k.value.company_name,"onUpdate:modelValue":C[5]||(C[5]=H=>k.value.company_name=H)},null,8,["label","required","class","modelValue"])):g("",!0),(O=$.value.vat_number)!=null&&O.enabled?(a(),B(le,{key:1,label:c(n)("VAT/GST/Tax Number"),required:(K=$.value.vat_number)==null?void 0:K.required,class:X(i.value.hasOwnProperty("vat_number")?"is-error":""),modelValue:k.value.vat_number,"onUpdate:modelValue":C[6]||(C[6]=H=>k.value.vat_number=H)},null,8,["label","required","class","modelValue"])):g("",!0),(Z=$.value.legal_registration_id)!=null&&Z.enabled?(a(),B(le,{key:2,label:c(n)("Legal Registration ID"),required:(D=$.value.legal_registration_id)==null?void 0:D.required,class:X(i.value.hasOwnProperty("legal_registration_id")?"is-error":""),modelValue:k.value.legal_registration_id,"onUpdate:modelValue":C[7]||(C[7]=H=>k.value.legal_registration_id=H)},null,8,["label","required","class","modelValue"])):g("",!0)])):g("",!0)]}),_:1}),s("div",Ys,[s("p",{class:"form-error-text",innerHTML:_(i.value)},null,8,Gs)]),s("div",Xs,[(e.showSetAsAlsoCheckbox,g("",!0)),e.address.id?(a(),B(P,{key:1,type:"primary",onClick:C[9]||(C[9]=te=>j()),loading:w.value,disabled:w.value},{default:d(()=>[L(o(c(n)("Update Address")),1)]),_:1},8,["loading","disabled"])):(a(),B(P,{key:2,type:"primary",onClick:C[10]||(C[10]=te=>b()),loading:p.value,disabled:p.value},{default:d(()=>[L(o(c(n)("Add Address")),1)]),_:1},8,["loading","disabled"]))])])}}}),el={class:"fct-manage-address-modal"},tl={key:1,class:"fct-manage-address-wrap"},sl=["onClick"],ll={class:"fct-address-action absolute top-0 right-0 pt-2"},al={class:"more-btn"},ol={key:0,class:"empty-text"},nl={key:2,class:"edit_address"},rl={key:3,class:"dialog-footer"},il={name:"ManageAddressModal",props:["showAddressModal","customer_id","modalAction","order_id","showBusinessDetailsSection"],expose:["editAddress"],data(){return{manageAddress:[],address:{},loading:!0,isEditAddress:!1,selectedAddressIndex:null}},computed:{showModal:{get(){return this.showAddressModal},set(e){this.$emit("update:showAddressModal",e)}}},methods:{handleAddressCommand(e){e.action==="edit"?this.editAddress(e.data):e.action==="use"?this.$emit("onAddressSelected",e.data):e.action==="set-as-also"?this.setAsAlso(e.data):e.action==="default"?this.setAddressPrimary(e.data):e.action==="remove"&&this.$confirm(this.$t("Are you sure you want to delete this address?"),this.$t("Warning"),{confirmButtonText:this.$t("Yes, Delete!"),cancelButtonText:this.$t("Cancel"),cancelButtonClass:"el-button--small",confirmButtonClass:"el-button--small",type:"warning"}).then(()=>{this.removeAddress(e.data)}).catch(()=>{})},emitAddNewAddress(e,l=[]){this.$emit("addNewAddress",e,"create",l)},emitAddressSelected(){this.showModal=!1,this.$emit("onAddressSelected",this.manageAddress[this.selectedAddressIndex])},editAddress(e){this.address=e,this.isEditAddress=!0},removeAddress(e){let l=e.id;this.$del("customers/"+this.customer_id+"/address",{address:e}).then(t=>{this.getAddresses(),this.$emit("refresh-address"),this.handleSuccess(t.message),l===this.selectedAddressIndex&&(this.selectedAddressIndex=null)}).catch(t=>{var u;t.status_code=="422"?W.validationErrors(t):W.error((u=t.data)==null?void 0:u.message)}).finally(()=>{this.loading=!1})},setAddressPrimary(e){this.$post("customers/"+this.customer_id+"/address/make-primary",{addressId:e.id,type:e.type}).then(l=>{this.$emit("refresh-address"),this.getAddresses(),this.handleSuccess(l.message)}).catch(l=>{var t;l.status_code=="422"?W.validationErrors(l):W.error((t=l.data)==null?void 0:t.message)}).finally(()=>{this.loading=!1})},getTitle(){return this.modalAction.type==="billing"?this.$t("Manage billing address"):this.$t("Manage shipping address")},fetchAddresses(){this.getAddresses(this.modalAction.type)},getAddresses(e="billing"){this.loading=!0,this.selectedOrders=[],this.$get("customers/"+this.customer_id+"/address",{type:this.modalAction.type}).then(l=>{this.manageAddress=l.addresses}).catch(l=>{this.handleError(l)}).finally(()=>{this.loading=!1})},updateAddress(){this.fetchAddresses(),this.$emit("refresh-address")},setAsAlso(e){const l=this.modalAction.type==="billing"?"shipping":"billing",t={...e,type:l,customer_id:this.customer_id,is_primary:0};delete t.id,delete t.created_at,delete t.updated_at,this.emitAddNewAddress(l,t)}}},dl=Object.assign(il,{setup(e){return(l,t)=>{const u=M("el-skeleton"),v=M("el-tag"),i=M("el-dropdown-item"),p=M("el-dropdown-menu"),w=M("el-dropdown"),x=M("el-icon"),T=M("el-button"),k=M("el-dialog");return a(),m("div",el,[r(k,{modelValue:l.showModal,"onUpdate:modelValue":t[5]||(t[5]=I=>l.showModal=I),onClose:t[6]||(t[6]=()=>{l.selectedAddressIndex=null,l.isEditAddress=!1}),onOpen:l.fetchAddresses,title:l.getTitle(),"append-to-body":!0,"modal-class":"fct-manage-order-address-modal"},{default:d(()=>[l.loading?(a(),B(u,{key:0,animated:"",rows:4})):g("",!0),!l.loading&&!l.isEditAddress?(a(),m("div",tl,[(a(!0),m(Y,null,ae(l.manageAddress,(I,$)=>(a(),m("div",{class:"fct-manage-address-block-wrap",key:I.id},[s("div",{class:X(`cursor-pointer fct-manage-address-block ${I.is_primary==="1"?"default-address":""} ${$===l.selectedAddressIndex?"selected":""} `),onClick:()=>{l.selectedAddressIndex=$}},[I.is_primary==="1"?(a(),B(v,{key:0,type:"info",round:""},{default:d(()=>[L(o(l.$t("Default")),1)]),_:1})):g("",!0),s("p",null,[s("strong",null,o(I.name),1),L(" "+o(l.getOrderAddress(I,"",!0)),1)])],10,sl),s("div",ll,[r(w,{trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:l.handleAddressCommand},{dropdown:d(()=>[r(p,null,{default:d(()=>[r(i,{command:{action:"edit",data:I}},{default:d(()=>[L(o(l.$t("Edit")),1)]),_:2},1032,["command"]),r(i,{command:{action:"use",data:I}},{default:d(()=>[L(o(l.$t("Use this address")),1)]),_:2},1032,["command"]),r(i,{command:{action:"set-as-also",data:I}},{default:d(()=>[L(o(e.modalAction.type==="billing"?l.$t("Copy to Shipping"):l.$t("Copy to Billing")),1)]),_:2},1032,["command"]),I.is_primary!=="1"?(a(),m(Y,{key:0},[r(i,{command:{action:"default",data:I}},{default:d(()=>[L(o(l.$t("Set as default")),1)]),_:2},1032,["command"]),r(i,{command:{action:"remove",data:I},class:"item-destructive"},{default:d(()=>[L(o(l.$t("Delete")),1)]),_:2},1032,["command"])],64)):g("",!0)]),_:2},1024)]),default:d(()=>[s("span",al,[r(ee,{name:"More"})])]),_:2},1032,["onCommand"])])]))),128)),l.manageAddress.length==0?(a(),m("div",ol,o(e.modalAction.type==="billing"?l.$t("No billing address found."):l.$t("No shipping address found.")),1)):g("",!0)])):g("",!0),l.isEditAddress?(a(),m("div",nl,[r(T,{text:"",onClick:t[0]||(t[0]=()=>l.isEditAddress=!1),style:{"margin-bottom":"16px"}},{default:d(()=>[r(x,null,{default:d(()=>[r(c(De))]),_:1}),L(" "+o(l.$t("Manage address")),1)]),_:1}),r(qe,{"onUpdate:refreshAddress":t[1]||(t[1]=I=>{l.isEditAddress=I,l.updateAddress()}),customer_id:e.customer_id,modalAction:e.modalAction,address:l.address,showAddressModal:l.isEditAddress,order_id:e.order_id,showBusinessDetailsSection:e.showBusinessDetailsSection,onCloseModal:t[2]||(t[2]=I=>l.showModal=!1)},null,8,["customer_id","modalAction","address","showAddressModal","order_id","showBusinessDetailsSection"])])):g("",!0),l.isEditAddress?g("",!0):(a(),m("div",rl,[l.selectedAddressIndex!=null?(a(),B(T,{key:0,onClick:t[3]||(t[3]=I=>l.emitAddressSelected())},{default:d(()=>[r(ee,{name:"LocationPin"}),L(" "+o(l.$t("Use this address")),1)]),_:1})):g("",!0),r(T,{onClick:t[4]||(t[4]=I=>l.emitAddNewAddress(e.modalAction.type)),type:"primary"},{default:d(()=>[L(o(l.$t("Add new address")),1)]),_:1})]))]),_:1},8,["modelValue","onOpen","title"])])}}}),ul={class:"fct-term-container"},cl={class:"fct-term-input-wrap"},ml={key:0,class:"fct-term-search-result-button-wrap mb-1.5"},pl={class:"search-text"},fl={key:1,class:"fct-term-search-result-list is-scrollable"},vl=["value","checked","onChange"],_l={key:2,class:"empty-text"},hl={key:0,class:"fct-term-selected-list"},gl={class:"fct-term-selected"},yl={class:"text"},bl={class:"fct-term-list-header"},Cl={class:"fct-term-input-inline-wrap"},wl={key:0,class:"fct-term-list-header-button-wrap"},kl={class:"search-text"},xl={class:"fct-term-list-wrap is-scrollable"},Al={key:0,class:"fct-term-list newly-added-list"},$l={class:"title"},Sl={class:"fct-term-label"},Ml=["value","checked","onChange"],Ll={key:1,class:"fct-term-list to-add-list"},El={class:"title"},Vl={class:"fct-term-label"},Il=["value","checked","onChange"],Tl={key:2,class:"fct-term-list available-list"},Ol={class:"title"},Pl={class:"fct-term-label"},Nl=["value","checked","onChange"],Ul={key:3,class:"empty-text"},Bl={class:"dialog-footer"},ze={__name:"Modal",props:{bindToType:{type:String},bindToId:{type:[String,Number]},selected_labels:{type:Array,default:[]},labelModalIsOpen:{type:Boolean,default:!1},shouldEnableEditing:{type:Boolean,default:!0}},emits:["update:update-label","close-label-modal"],setup(e,{emit:l}){const t=Be().ctx,u=e,v=l,i=E([]),p=E([]),w=E([]),x=E(),T=E(""),k=E([]),I=E([]),$=E(!1),q=E(!1),y=E(u.labelModalIsOpen),_=E("");ce(()=>u.labelModalIsOpen,h=>{y.value=h,h&&(w.value=[...i.value])});const b=h=>{h.stopPropagation(),h.preventDefault(),U()},j=()=>{t.$get("labels").then(h=>{k.value=h.labels,i.value=u.selected_labels}).catch(h=>{var V;h.status_code=="422"?W.validationErrors(h):W.error((V=h.data)==null?void 0:V.message)}).finally(()=>{})},U=(h="")=>{const V=T.value||_.value;t.$post("labels",{value:V,bind_to_type:u.bindToType,bind_to_id:u.bindToId}).then(f=>{T.value="",_.value="",k.value.push(f.data),h!=="insideModal"?i.value.push(f.data.id):p.value.push(f.data.id),v("update:update-label",i.value)}).catch(f=>{W.error(f)})};ce(T,h=>{h?(h=h.trim(),I.value=k.value.filter(V=>V.value.toLowerCase().includes(h.toLowerCase())),$.value=!0):(I.value=[],$.value=!1)});const C=h=>{const V=i.value.indexOf(h);V===-1?i.value.push(h):i.value.splice(V,1),v("update:update-label",i.value)},S=h=>{const V=w.value.indexOf(h);V===-1?w.value.push(h):w.value.splice(V,1)},Q=h=>{const V=p.value.indexOf(h);V===-1?p.value.push(h):p.value.splice(V,1)},P=()=>{i.value=[...w.value,...p.value],p.value=[],v("update:update-label",i.value),H()},te=h=>{const V=i.value.indexOf(h);V!==-1&&(i.value.splice(V,1),v("update:update-label",i.value))},se=h=>{$.value&&!x.value.$el.contains(h.target)&&!q.value.contains(h.target)&&($.value=!1,T.value="")},O=z(()=>k.value.filter(h=>i.value.includes(h.id))),K=z(()=>k.value.filter(h=>p.value.includes(h.id))),Z=z(()=>k.value.filter(h=>w.value.includes(h.id)).filter(h=>h.value.toLowerCase().includes(_.value.trim().toLowerCase()))),D=z(()=>k.value.filter(h=>!w.value.includes(h.id)).filter(h=>!p.value.includes(h.id)).filter(h=>h.value.toLowerCase().includes(_.value.trim().toLowerCase())).sort((h,V)=>h.value.localeCompare(V.value))),H=()=>{v("close-label-modal")},de=z(()=>{const h=_.value.trim().toLowerCase(),V=T.value.trim().toLowerCase();return(h||V)===""||I.value.some(f=>f.value.toLowerCase()===h||f.value.toLowerCase()===V)||Z.value.some(f=>f.value.toLowerCase()===h||f.value.toLowerCase()===V)||D.value.some(f=>f.value.toLowerCase()===h||f.value.toLowerCase()===V)});return Se(()=>{j(),document.addEventListener("click",se)}),Ue(()=>{document.removeEventListener("click",se)}),(h,V)=>{const f=M("el-input"),A=M("el-button"),G=M("el-dialog");return a(),m("div",ul,[s("div",cl,[e.shouldEnableEditing?(a(),B(f,{key:0,ref_key:"inputRef",ref:x,modelValue:T.value,"onUpdate:modelValue":V[0]||(V[0]=N=>T.value=N),onKeydown:Ke(b,["enter"])},null,8,["modelValue"])):g("",!0),$.value?(a(),m("div",{key:1,class:"fct-term-search-result",ref_key:"suggestionsRef",ref:q,style:He(T.value==""?"display: none":"")},[T.value!==""&&!de.value?(a(),m("div",ml,[r(A,{type:"info",plain:"",onClick:U,size:"small"},{default:d(()=>[r(ee,{name:"PlusCircle"}),L(" "+o(h.$t("Add"))+" ",1),s("span",pl,'"'+o(T.value)+'"',1)]),_:1})])):g("",!0),I.value.length>0?(a(),m("ul",fl,[(a(!0),m(Y,null,ae(I.value,(N,ne)=>(a(),m("li",{key:ne},[s("label",null,[s("input",{type:"checkbox",value:N.id,checked:i.value.includes(N.id),onChange:ue=>C(N.id)},null,40,vl),L(" "+o(N.value),1)])]))),128))])):g("",!0),I.value.length===0?(a(),m("p",_l,o(h.$t("No labels found.")),1)):g("",!0)],4)):g("",!0)]),O.value.length>0?(a(),m("ul",hl,[(a(!0),m(Y,null,ae(O.value,N=>(a(),m("li",{key:N.id},[s("div",gl,[s("div",yl,o(N.value),1),e.shouldEnableEditing?(a(),B(ee,{key:0,name:"Cross",onClick:ne=>te(N.id)},null,8,["onClick"])):g("",!0)])]))),128))])):g("",!0),r(G,{"before-close":H,"append-to-body":!0,width:"45%",modelValue:y.value,"onUpdate:modelValue":V[3]||(V[3]=N=>y.value=N),title:h.$t("Add labels"),class:"fct-add-labels-modal"},{default:d(()=>[s("div",bl,[s("div",Cl,[r(f,{modelValue:_.value,"onUpdate:modelValue":V[1]||(V[1]=N=>_.value=N),placeholder:h.$t("Search to find or create labels")},{prefix:d(()=>[r(ee,{name:"Search"})]),_:1},8,["modelValue","placeholder"])]),_.value!==""&&!de.value?(a(),m("div",wl,[r(A,{type:"info",plain:"",onClick:V[2]||(V[2]=N=>U("insideModal")),size:"small"},{default:d(()=>[r(ee,{name:"PlusCircle"}),L(" "+o(h.$t("Add"))+" ",1),s("span",kl,'"'+o(_.value)+'"',1)]),_:1})])):g("",!0)]),s("div",xl,[K.value.length>0?(a(),m("ul",Al,[s("li",$l,o(h.$t("Newly added")),1),(a(!0),m(Y,null,ae(K.value,N=>(a(),m("li",{key:N.id},[s("label",Sl,[s("input",{type:"checkbox",value:N.id,checked:p.value.includes(N.id),onChange:ne=>Q(N.id)},null,40,Ml),L(" "+o(N.value),1)])]))),128))])):g("",!0),Z.value.length>0?(a(),m("ul",Ll,[s("li",El,o(h.$t("To add")),1),(a(!0),m(Y,null,ae(Z.value,N=>(a(),m("li",{key:N.id},[s("label",Vl,[s("input",{type:"checkbox",value:N.id,checked:w.value.includes(N.id),onChange:ne=>S(N.id)},null,40,Il),L(" "+o(N.value),1)])]))),128))])):g("",!0),D.value.length>0?(a(),m("ul",Tl,[s("li",Ol,o(h.$t("Available")),1),(a(!0),m(Y,null,ae(D.value,N=>(a(),m("li",{key:N.id},[s("label",Pl,[s("input",{type:"checkbox",value:N.id,checked:w.value.includes(N.id),onChange:ne=>S(N.id)},null,40,Nl),L(" "+o(N.value),1)])]))),128))])):g("",!0),Z.value.length===0&&D.value.length===0&&K.value.length===0?(a(),m("p",Ul,o(h.$t("No labels found.")),1)):g("",!0)]),s("div",Bl,[r(A,{onClick:H},{default:d(()=>[L(o(h.$t("Cancel")),1)]),_:1}),r(A,{type:"primary",onClick:P},{default:d(()=>[L(o(h.$t("Done")),1)]),_:1})])]),_:1},8,["modelValue","title"])])}}},Dl={class:"fct-admin-sidebar-item"},jl={name:"Labels",components:{IconButton:Ee,LabelModal:ze,DynamicIcon:ee},props:{bindToType:{type:String},bindToId:{type:[String,Number]},selectedLabels:{type:Array,default:()=>[]},shouldEnableEditing:{type:Boolean,default:!0}},data(){return{labelModalIsOpen:!1}},mounted(){},methods:{openLabelModal(){this.labelModalIsOpen=!0},updateLabel(e){this.bindToId&&this.bindToType&&this.$post("labels/update-label-selections",{bind_to_type:this.bindToType,bind_to_id:this.bindToId,selectedLabels:e}).then(l=>{W.success(l.message)}).catch(l=>{W.error(l.message)}),this.$emit("update:update-label",e)},closeLabel(){this.labelModalIsOpen=!1}}},xo=Object.assign(jl,{setup(e){return(l,t)=>(a(),B(je,{permission:"labels/manage"},{default:d(()=>[s("div",null,[r(Ae,null,{default:d(()=>[r(ke,{title:l.$t("Labels"),border_bottom:"",title_size:"small"},{action:d(()=>[e.shouldEnableEditing?(a(),B(Ee,{key:0,size:"x-small",bg:"transparent",tag:"button",border:"transparent",onClick:l.openLabelModal},{default:d(()=>[r(ee,{name:"Edit"})]),_:1},8,["onClick"])):g("",!0)]),_:1},8,["title"]),r(xe,null,{default:d(()=>[s("div",Dl,[r(ze,{bindToType:e.bindToType,bindToId:e.bindToId,labelModalIsOpen:l.labelModalIsOpen,selected_labels:e.selectedLabels,shouldEnableEditing:e.shouldEnableEditing,"onUpdate:updateLabel":l.updateLabel,onCloseLabelModal:t[0]||(t[0]=u=>l.labelModalIsOpen=!1)},null,8,["bindToType","bindToId","labelModalIsOpen","selected_labels","shouldEnableEditing","onUpdate:updateLabel"])])]),_:1})]),_:1})])]),_:1}))}}),Fl={class:"fct-customer-edit-modal"},Rl={key:1,class:"fct-form-group"},ql={class:"label"},zl={style:{display:"flex","align-items":"center",gap:"10px"}},Wl={class:"select-use-option"},Jl={class:"fct-compact-form"},Kl={class:"form-heading"},Hl={class:"fct-compact-form fct-customer-address-section"},Zl={style:{"margin-top":"20px"}},Ql={class:"form-error-wrap"},Yl={class:"form-error-text"},Gl={class:"dialog-footer"},Xl={key:3,class:"dialog-footer"},ea={__name:"ChangeOrderCustomer",props:{orderId:{type:[String,Number],default:null,required:!0}},setup(e){const l=e,t=E(null),u=E([]),v=E(!1),i=E(!1),p=E({}),w=window.fluentCartAdminApp||{},x=E({id:"",email:"",full_name:"",first_name:"",last_name:"",state:"",city:"",country:"",postcode:"",country_name:"",contact_id:"",user_id:"",wp_user:""}),T=y=>{if(!y){u.value=[];return}ie.get("customers/",{search:y}).then(_=>{u.value=_.customers.data}).finally(()=>{})},k=()=>{if(!t.value){W.error(n("Please select a customer"));return}ie.post("orders/"+l.orderId+"/change-customer",{customer_id:t.value}).then(y=>{W.success(y.message),setTimeout(()=>{window.location.reload()},300)}).catch(y=>{var _;W.error((_=y.data)==null?void 0:_.message)}).finally(()=>{})},I=()=>{ie.post("orders/"+l.orderId+"/create-and-change-customer",x.value).then(y=>{W.success(y.message),setTimeout(()=>{window.location.reload()},300),p.value={},i.value=!1}).catch(y=>{var _;y.status_code=="422"?(W.validationErrors(y),p.value=y.data):W.error((_=y.data)==null?void 0:_.message)}).finally(()=>{})},$=()=>{i.value=!0},q=()=>{i.value=!1};return(y,_)=>{const b=M("el-button"),j=M("el-option"),U=M("el-select"),C=M("el-checkbox");return a(),m("div",Fl,[i.value?(a(),m("div",{key:0,onClick:q,style:{"margin-bottom":"10px"}},[r(b,{text:"",style:{"margin-top":"0"}},{default:d(()=>[r(ee,{name:"ArrowLeft"}),L(" "+o(c(n)("Back")),1)]),_:1})])):g("",!0),i.value?g("",!0):(a(),m("div",Rl,[s("label",ql,[L(o(c(n)("Select Customer"))+" ",1),r(b,{text:"",class:"fct-create-customer-btn",onClick:Me($,["prevent"])},{default:d(()=>[r(ee,{name:"Plus"}),L(" "+o(c(n)("Add New Customer")),1)]),_:1})]),s("div",zl,[r(U,{modelValue:t.value,"onUpdate:modelValue":_[0]||(_[0]=S=>t.value=S),remote:!0,"remote-method":T,loading:v.value,filterable:"",clearable:"",placeholder:c(n)("Type to search user"),style:{width:"100%"}},{default:d(()=>[(a(!0),m(Y,null,ae(u.value,S=>(a(),B(j,{key:S.id,label:S.full_name,value:S.id},{default:d(()=>[s("div",Wl,[s("span",null,o(S.full_name),1),s("span",null,o(S.email),1)])]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue","loading","placeholder"])])])),i.value?(a(),m(Y,{key:2},[s("div",Jl,[c(w).is_full_name_required?(a(),B(le,{key:0,label:c(n)("Full Name *"),modelValue:x.value.full_name,"onUpdate:modelValue":_[1]||(_[1]=S=>x.value.full_name=S),class:X(p.value.full_name?"is-error":"")},null,8,["label","modelValue","class"])):(a(),m(Y,{key:1},[r(le,{label:c(n)("First Name *"),modelValue:x.value.first_name,"onUpdate:modelValue":_[2]||(_[2]=S=>x.value.first_name=S),class:X(p.value.first_name?"is-error":"")},null,8,["label","modelValue","class"]),r(le,{label:c(n)("Last Name"),modelValue:x.value.last_name,"onUpdate:modelValue":_[3]||(_[3]=S=>x.value.last_name=S),class:X(p.value.last_name?"is-error":"")},null,8,["label","modelValue","class"])],64)),r(le,{label:c(n)("Email *"),modelValue:x.value.email,"onUpdate:modelValue":_[4]||(_[4]=S=>x.value.email=S),class:X(p.value.email?"is-error":"")},null,8,["label","modelValue","class"])]),s("h4",Kl,o(c(n)("Address")),1),s("div",Hl,[r(Ve,{modelValue:x.value,"onUpdate:modelValue":_[5]||(_[5]=S=>x.value=S)},null,8,["modelValue"]),s("div",Zl,[r(C,{"true-value":"yes","false-value":"no",modelValue:x.value.wp_user,"onUpdate:modelValue":_[6]||(_[6]=S=>x.value.wp_user=S)},{default:d(()=>[r(Fe,{title:c(n)("Create as wordpress user"),content:c(n)("We will create a new user for this customer. If a user with the same email already exists, we will associate the customer with that existing user.")},null,8,["title","content"])]),_:1},8,["modelValue"])]),s("div",Ql,[(a(!0),m(Y,null,ae(p.value,S=>(a(),m("p",Yl,o(S.required),1))),256))])]),s("div",Gl,[r(b,{onClick:_[7]||(_[7]=S=>y.$emit("close"))},{default:d(()=>[L(o(c(n)("Cancel")),1)]),_:1}),r(b,{type:"primary",onClick:I},{default:d(()=>[L(o(c(n)("Create & Attach Customer")),1)]),_:1})])],64)):g("",!0),i.value?g("",!0):(a(),m("div",Xl,[r(b,{type:"primary",onClick:k},{default:d(()=>[L(o(c(n)("Create & Attach Customer")),1)]),_:1})]))])}}},ta={class:"fct-admin-sidebar"},sa={class:"more-btn"},la={key:0,class:"fct-admin-sidebar-item"},aa={class:"name"},oa={class:"email"},na={class:"fct-admin-sidebar-item"},ra={class:"fct-profile-card"},ia=["src","alt"],da={key:0,class:"fct-profile-details"},ua={class:"title"},ca={class:"text"},ma={key:0},pa={class:"text"},fa={key:0,class:"user-info mt-2"},va=["href"],_a={class:"fct-admin-sidebar-item mt-5"},ha={class:"fct-contact-info-list"},ga={class:"flex items-center justify-between gap-2"},ya=["href"],ba={class:"fct-admin-sidebar-item mt-5"},Ca={class:"sidebar-title"},wa={key:0,class:"fct-address-copy-wrap"},ka={class:"text"},xa={key:0,class:"pr-1"},Aa=["innerHTML"],$a={key:1,class:"mt-3"},Sa={class:"pr-1"},Ma=["href"],La={key:1,class:"no-address-text"},Ea={class:"fct-admin-sidebar-item mt-5"},Va={class:"sidebar-title"},Ia={key:0,class:"fct-address-copy-wrap"},Ta={class:"text"},Oa={key:0},Pa=["innerHTML"],Na={key:1,class:"mt-3"},Ua={class:"pr-1"},Ba=["href"],Da={key:1,class:"no-address-text"},ja={class:"fct-admin-sidebar-item"},Fa={class:"flex flex-col gap-2"},Ra={key:0,class:"flex items-baseline gap-1"},qa={class:"shrink-0"},za={key:1,class:"flex items-baseline gap-1"},Wa={class:"shrink-0"},Ja={key:2,class:"flex items-baseline gap-1"},Ka={class:"shrink-0"},Ha={class:"flex items-baseline gap-1"},Za={class:"shrink-0"},Qa={key:3},Ya={class:"block"},Ga={class:"fluent-cart-admin-pages"},Ao={__name:"OrderCustomerInformation",props:{order:{type:Object,default:null},subscription:{type:Object,default:null},shouldEnableEditing:{type:Boolean,default:!0}},emits:["onAddressSelected","onAddressRemove","onOrderUpdated"],setup(e,{emit:l}){var H,de,h,V;const t=e,u=z(()=>t.order||t.subscription||{}),v=z(()=>t.order?t.order.id:t.subscription?t.subscription.parent_order_id:null),i=E([]),p=E((de=(H=u.value)==null?void 0:H.customer)!=null&&de.id?u.value.customer:null),w=E((h=u.value)!=null&&h.billing_address?u.value.billing_address:null),x=E((V=u.value)!=null&&V.shipping_address?u.value.shipping_address:null),T=l,k=E(!1),I=f=>{f==="remove_customer"&&$(),f==="change_customer"?k.value=!0:f==="edit_customer"?S("edit"):f==="manage_billing_address"?te("billing"):f==="manage_shipping_address"&&te("shipping")},$=()=>{u.value.customer_id="",u.value.customer={},p.value=null,w.value=null,x.value=null,T("onAddressRemove"),setTimeout(()=>{O()},50)},q=(f,A)=>{ie.get("customers/",{search:f,with:["admin_customer_search"]}).then(G=>{let N=G.customers.data;i.value=N;let ne=N.map(re=>({id:re.id,value:re.full_name,email:re.email})),ue=jQuery(".fct-customer-autocomplete-dropdown"),F=jQuery(".el-autocomplete-suggestion__list"),R="empty-text";N.length<1?ue.length>0&&(ue.addClass("is-empty-customer"),F.children(`.${R}`).length||F.prepend(`<li class="${R}">No customer found.</li>`)):ue.length>0&&(ue.removeClass("is-empty-customer"),F.children(`.${R}`).remove()),A(ne)}).catch(G=>{W.error(G)})},y=f=>{const A=i.value.find(G=>G.id===f.id)??null;_(A)},_=f=>{p.value=f,u.value.customer=f,u.value.customer_id=f.id,p.value!==null&&(b(),j())},b=()=>{const f=p.value.billing_address;f&&(Array.isArray(f)&&f.length>0?(w.value=f[0],w.value=f.find(A=>A.is_primary.toString()==="1")??w.value):w.value=null,T("onAddressSelected",w.value))},j=()=>{const f=p.value.shipping_address;f&&(Array.isArray(f)&&f.length>0?(x.value=f[0],x.value=f.find(A=>A.is_primary.toString()==="1")??x.value):x.value=null,T("onAddressSelected",x.value))},U=f=>{if(f){if(!v.value){f.type==="shipping"?x.value=f:w.value=f,P.value.showModal=!1,T("onAddressSelected",f);return}ie.post(`orders/${v.value}/update-address-id`,{address_id:f.id,address_type:f.type}).then(A=>{W.success(A.message),f.type==="shipping"?x.value=f:w.value=f,P.value.showModal=!1,T("onAddressSelected",f),A.order&&T("onOrderUpdated",A.order)}).catch(A=>{W.error(A)})}},C=E({showModal:!1,action:"create",title:n("Create New Customer"),customer:{},manageWpUser:"yes"}),S=(f="create")=>{const A=C.value;A.showModal=!0,A.action=f==="create"?"create":"edit",A.title=f==="create"?n("Create New Customer"):n("Edit Customer Information"),A.customer_id=f==="create"?null:p.value.id,A.customer=f==="create"?{}:p.value,A.manageWpUser=f==="create"?"yes":p.value.user_id==="0"?"no":"yes",C.value=A},Q=E(!0),P=E({showManageAddressModal:!1,showModal:!1,modalAction:{type:"billing",action:"create"},title:"",customer_id:"",address_id:"",address:{},address_mock:{name:"",phone:"",email:"",company_name:"",vat_number:"",legal_registration_id:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",is_primary:"0"}}),te=(f="billing",A="edit")=>{P.value.showManageAddressModal=!0,P.value.modalAction.type=f,P.value.modalAction.action=A},se=(f="billing",A="create",G={})=>{Object.keys(G).length>0?(P.value.address={...G},Q.value=!1):P.value.address={...P.value.address_mock},P.value.showModal=!0,P.value.modalAction.type=f,P.value.modalAction.action=A,P.value.showManageAddressModal=!1},O=()=>{let f=jQuery(".el-autocomplete-suggestion__wrap");if(f.length>0){let A=jQuery('<div class="fct-create-customer-button-wrap"><button class="el-button el-button--info el-button--small is-plain"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M1.5 7H12.5M7 1.5V12.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg> Create a new customer</button></div>').on("click",()=>{S()});f.prepend(A)}},K=()=>P.value.modalAction.action==="create"?P.value.modalAction.type==="billing"?n("Add new billing address"):n("Add new shipping Address"):P.value.modalAction.type==="billing"?n("Edit billing address"):n("Edit shipping address"),Z=(f,A)=>{P.value.modalAction.type==="billing"?w.value=A:x.value=A,P.value.showModal=f,P.value.showManageAddressModal=!0,U(A)},D=z(()=>{const f=u.value&&u.value.business_info;return f?!!(f.company_name||f.tax_number||f.legal_registration_id):!1});return ce(()=>u.value,(f,A)=>{f.customer_id!==A.customer_id&&$()}),Se(()=>{O()}),(f,A)=>{var he;const G=M("el-dropdown-item"),N=M("el-dropdown-menu"),ne=M("el-dropdown"),ue=M("el-autocomplete"),F=M("router-link"),R=M("el-icon"),re=M("el-button"),me=M("el-dialog");return a(),m(Y,null,[s("div",ta,[r(Ae,null,{default:d(()=>[r(ke,{title:c(n)("Customer Information"),title_size:"small",border_bottom:""},{action:d(()=>[p.value&&e.shouldEnableEditing?(a(),B(ne,{key:0,trigger:"click",class:"fct-more-option-wrap","popper-class":"fct-dropdown",onCommand:I},{dropdown:d(()=>[r(N,null,{default:d(()=>[r(G,{command:"edit_customer"},{default:d(()=>[L(o(c(n)("Edit customer information")),1)]),_:1}),r(G,{command:"manage_shipping_address"},{default:d(()=>[L(o(c(n)("Manage shipping address")),1)]),_:1}),r(G,{command:"manage_billing_address"},{default:d(()=>[L(o(c(n)("Manage billing address")),1)]),_:1}),v.value?(a(),B(G,{key:0,command:"change_customer"},{default:d(()=>[L(o(c(n)("Change customer")),1)]),_:1})):g("",!0),v.value?g("",!0):(a(),B(G,{key:1,command:"remove_customer"},{default:d(()=>[L(o(c(n)("Remove customer")),1)]),_:1}))]),_:1})]),default:d(()=>[s("span",sa,[r(ee,{name:"More"})])]),_:1})):g("",!0)]),_:1},8,["title"]),r(xe,null,{default:d(()=>{var oe,pe,ge,ve,ye,J,fe,Ie,Te;return[p.value===null?(a(),m("div",la,[r(ue,{"popper-class":"fct-customer-autocomplete-dropdown",clearable:"",modelValue:u.value.customer.full_name,"onUpdate:modelValue":A[0]||(A[0]=_e=>u.value.customer.full_name=_e),"fetch-suggestions":q,placeholder:c(n)("Search or create a customer"),disabled:!1,onSelect:y},{prefix:d(()=>[r(ee,{name:"Search"})]),default:d(_e=>[s("span",aa,o(_e.item.value),1),s("span",oa,o(_e.item.email),1)]),_:1},8,["modelValue","placeholder"])])):(a(),m(Y,{key:1},[s("div",na,[s("div",ra,[s("div",{class:"fct-profile-image cursor-pointer",onClick:A[1]||(A[1]=_e=>f.$router.push({name:"view_customer",params:{customer_id:p.value.id}}))},[s("img",{src:p.value.photo,alt:(oe=p.value)==null?void 0:oe.full_name},null,8,ia)]),p.value.id?(a(),m("div",da,[s("div",ua,[r(F,{to:{name:"view_customer",params:{customer_id:p.value.id}}},{default:d(()=>[L(o(p.value.full_name),1)]),_:1},8,["to"])]),s("span",ca,[p.value.purchase_count>0?(a(),m("span",ma,o(c(Ce)(p.value.purchase_count)),1)):g("",!0),L(" "+o(f.$n("Order","Orders",p.value.purchase_count??0,"No Order")),1)]),s("span",pa,o(c(rt)((pe=p.value)==null?void 0:pe.ltv,!0))+" "+o(c(n)("Lifetime Value")),1)])):g("",!0)]),u.value.customer.user_link?(a(),m("div",fa,[L(o(c(n)("WP User:"))+" ",1),s("a",{href:u.value.customer.user_link,target:"_blank",class:"inline-flex items-center gap-1 dark:text-gray-100 text-primary-500 focus:shadow-none hover:!underline"},[L(" #"+o(c(Ce)(u.value.customer.user_id))+" ",1),r(ee,{name:"Redirect",class:"w-2.5 h-2.5 text-primary-500 dark:text-gray-200"})],8,va)])):g("",!0)]),s("div",_a,[s("ul",ha,[s("li",null,[s("div",ga,[s("a",{class:"text",href:"mailto:"+((ge=u.value.customer)==null?void 0:ge.email)},o(p.value.email),9,ya),r(be,{text:p.value.email,showMode:"basic_copy_btn",tooltipText:c(n)("Copy email")},null,8,["text","tooltipText"])])])])]),s("div",ba,[s("h4",Ca,o(c(n)("Shipping Address")),1),x.value!=null?(a(),m("div",wa,[s("span",ka,[x.value.name?(a(),m("strong",xa,o(x.value.name),1)):g("",!0),s("span",{class:"break-all",innerHTML:f.getOrderAddress({...x.value},"shipping",!0)},null,8,Aa),(J=(ye=(ve=x.value)==null?void 0:ve.meta)==null?void 0:ye.other_data)!=null&&J.phone?(a(),m("span",$a,[s("strong",Sa,o(c(n)("Phone"))+":",1),s("a",{href:"tel:"+x.value.meta.other_data.phone,class:"text-system-mid dark:text-gray-50 hover:underline"},o(x.value.meta.other_data.phone),9,Ma)])):g("",!0)]),r(be,{text:f.getOrderAddress({...x.value},"shipping"),showMode:"basic_copy_btn",tooltipText:c(n)("Copy address")},null,8,["text","tooltipText"])])):(a(),m("p",La,o(c(n)("No shipping address provided")),1))]),s("div",Ea,[s("h4",Va,o(c(n)("Billing Address")),1),w.value!=null?(a(),m("div",Ia,[s("div",Ta,[w.value.name?(a(),m("strong",Oa,o(w.value.name),1)):g("",!0),s("span",{class:"break-all",innerHTML:f.getOrderAddress({...w.value},"billing",!0)},null,8,Pa),(Te=(Ie=(fe=w.value)==null?void 0:fe.meta)==null?void 0:Ie.other_data)!=null&&Te.phone?(a(),m("span",Na,[s("strong",Ua,o(c(n)("Phone"))+":",1),s("a",{href:"tel:"+w.value.meta.other_data.phone,class:"text-system-mid dark:text-gray-50 hover:underline"},o(w.value.meta.other_data.phone),9,Ba)])):g("",!0)]),r(be,{text:f.getOrderAddress({...w.value},"billing"),showMode:"basic_copy_btn",tooltipText:c(n)("Copy address")},null,8,["text","tooltipText"])])):(a(),m("p",Da,o(c(n)("No shipping address provided")),1))])],64))]}),_:1})]),_:1}),D.value?(a(),B(Ae,{key:0,class:"mt-4"},{default:d(()=>[r(ke,{title:c(n)("Business Information"),title_size:"small",border_bottom:""},null,8,["title"]),r(xe,null,{default:d(()=>[s("div",ja,[s("div",Fa,[u.value.business_info.company_name?(a(),m("div",Ra,[s("strong",qa,o(c(n)("Company"))+":",1),s("span",null,o(u.value.business_info.company_name),1)])):g("",!0),u.value.business_info.tax_number?(a(),m("div",za,[s("strong",Wa,o(c(n)("VAT/Tax ID"))+":",1),s("span",null,o(u.value.business_info.tax_number),1)])):g("",!0),u.value.business_info.legal_registration_id?(a(),m("div",Ja,[s("strong",Ka,o(c(n)("Reg. ID"))+":",1),s("span",null,o(u.value.business_info.legal_registration_id),1)])):g("",!0),s("div",Ha,[s("strong",Za,o(c(n)("Charge Reversed"))+":",1),s("span",null,o(u.value.is_reverse_charge_tax_order?c(n)("Yes"):c(n)("No")),1)]),u.value.business_info.reverse_charge_declaration?(a(),m("div",Qa,[s("strong",Ya,o(c(n)("Reverse Charge Declaration"))+":",1),s("span",null,o(u.value.business_info.reverse_charge_declaration),1)])):g("",!0)])])]),_:1})]),_:1})):g("",!0)]),r(vt,{onSelectNewCustomer:A[2]||(A[2]=oe=>{_(oe),C.value.showModal=!1}),customerModalInfos:C.value,customer_id:C.value.customer_id,customer:C.value.customer,onCloseModal:A[3]||(A[3]=oe=>C.value.showModal=!1)},null,8,["customerModalInfos","customer_id","customer"]),r(dl,{modalAction:P.value.modalAction,onOnAddressSelected:U,"onUpdate:showAddressModal":A[4]||(A[4]=oe=>P.value.showManageAddressModal=oe),showAddressModal:P.value.showManageAddressModal,customer_id:(he=p.value)==null?void 0:he.id,order_id:v.value,showBusinessDetailsSection:!0,onAddNewAddress:se},null,8,["modalAction","showAddressModal","customer_id","order_id"]),r(me,{"show-close":!0,modelValue:P.value.showModal,"onUpdate:modelValue":A[7]||(A[7]=oe=>P.value.showModal=oe),"append-to-body":!0,title:K()},{default:d(()=>[s("div",Ga,[r(re,{text:"",onClick:A[5]||(A[5]=()=>{P.value.showManageAddressModal=!0,P.value.showModal=!1}),class:"mb-4"},{default:d(()=>[r(R,null,{default:d(()=>[r(c(De))]),_:1}),L(" "+o(f.$t("Manage address")),1)]),_:1}),r(qe,{"onUpdate:refreshAddress":Z,customerAddressModalInfos:P.value,customer_id:p.value.id,modalAction:P.value.modalAction,address:P.value.address,showAddressModal:P.value.showModal,showSetAsAlsoCheckbox:Q.value,showBusinessDetailsSection:!0,order_id:v.value,onCloseModal:A[6]||(A[6]=()=>{P.value.showModal=!1,P.value.showManageAddressModal=!0})},null,8,["customerAddressModalInfos","customer_id","modalAction","address","showAddressModal","showSetAsAlsoCheckbox","order_id"])])]),_:1},8,["modelValue","title"]),v.value?(a(),B(me,{key:0,modelValue:k.value,"onUpdate:modelValue":A[9]||(A[9]=oe=>k.value=oe),title:f.$t("Change Customer")},{default:d(()=>[r(ea,{"order-id":v.value,onClose:A[8]||(A[8]=oe=>k.value=!1)},null,8,["order-id"])]),_:1},8,["modelValue","title"])):g("",!0)],64)}}};export{Re as C,ko as L,wo as O,Ms as P,bo as _,vt as a,be as b,qe as c,dl as d,xo as e,Ao as f,ea as g,Co as u};