PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.6
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.6
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/shipping.js +2 -2 1.3.28 → 1.6.6 View file →
@@ -1,2 +1,2 @@
1 -import{h as x,r as d,S as ce,e as m,o,R as pe,c as U,w as a,a as e,u as l,f as z,t as u,d as g,l as te,v as Fe,i as ge,b as I,n as me,F as se,g as ie,z as Ze,q as Pe,x as Ee}from"./chunks/vue.esm-bundler.js?ver=1.3.28";import{T as xe,_ as fe,a as Ce}from"./chunks/RouteCell.js?ver=1.3.28";import{t,A as De}from"./chunks/Translator.js?ver=1.3.28";import{A as Me}from"./chunks/Arr.js?ver=1.3.28";import{R as j}from"./chunks/Rest.js?ver=1.3.28";import{I as de}from"./chunks/IconButton.js?ver=1.3.28";import{_ as ee}from"./chunks/DynamicIcon.js?ver=1.3.28";import{n as P}from"./chunks/Notify.js?ver=1.3.28";import{_ as Se}from"./chunks/_plugin-vue_export-helper.js?ver=1.3.28";import{u as ve,o as Ue}from"./chunks/vue-router.js?ver=1.3.28";import{S as _e,u as Ne,c as ke,a as $e,_ as Re}from"./chunks/countries.js?ver=1.3.28";import{C as re,a as ne,b as oe}from"./chunks/CardBody.js?ver=1.3.28";import{b as he,E as Oe}from"./chunks/index.js?ver=1.3.28";import{_ as ze,u as qe}from"./chunks/NotFound.js?ver=1.3.28";import{B as We}from"./chunks/Badge.js?ver=1.3.28";import{_ as Ie}from"./chunks/Animation.js?ver=1.3.28";import"./chunks/Model.js?ver=1.3.28";import"./chunks/Url.js?ver=1.3.28";import"./chunks/Str.js?ver=1.3.28";import"./chunks/dayjs.min.js?ver=1.3.28";import"./chunks/timezone.js?ver=1.3.28";import"./chunks/index3.js?ver=1.3.28";import"./chunks/Utils.js?ver=1.3.28";import"./chunks/TransitionAccordion.js?ver=1.3.28";import"./chunks/Asset.js?ver=1.3.28";class Be extends xe{constructor(c){super(c),this.shippingClassId=(c==null?void 0:c.shipping_class_id)??void 0}setupInitialData(){super.setupInitialData(),this.data.sorting.sortBy="id",this.data.sorting.sortType="DESC"}getTabs(){return null}getToggleableColumns(){return[{label:t("Regions"),value:"regions"},{label:t("Shipping Methods"),value:"methods_count"}]}getSortableColumns(){return[{label:t("Zone Name"),value:"name"},{label:t("Order"),value:"order"}]}getSearchHint(){return t("Search by zone name")}buildQueryParams(){const c=super.buildQueryParams();return this.shippingClassId!==void 0&&(c.shipping_class_id=this.shippingClassId),c}getFetchUrl(){return"shipping/zones"}parseResponse(c){return c.shipping_zones}getTableName(){return"shipping_zone_table"}getAdvanceFilterOptions(){return Me.get(window,"fluentCartAdminApp.filter_options.shipping_zone_filter_options")}getSearchGuideOptions(){return[]}useFullWidthSearch(){return!0}with(){return["methodsCount"]}}function Le($){return Be.init($)}const je={class:"shipping-zones-table"},He={key:0},Je={key:1,class:"text-muted"},Ke={key:0},Ge={key:1,class:"text-muted"},Qe={class:"fct-btn-group sm justify-end pr-4"},Ye={__name:"ShippingZonesTable",props:{shipping_zones:{type:Array,required:!0},columns:{type:Array,default:()=>[]}},emits:["refresh"],setup($,{emit:c}){const C=c,v=x(!1),r=f=>{v.value=!0,j.delete(`/shipping/zones/${f}`).then(w=>{P.success(w.message||t("Shipping zone deleted successfully")),C("refresh")}).catch(w=>{console.error("Error deleting shipping zone:",w),P.error(w.message)}).finally(()=>{v.value=!1})};return(f,w)=>{const b=d("el-table-column"),i=d("el-popconfirm"),N=d("el-table"),Z=ce("loading");return o(),m("div",je,[pe((o(),U(N,{data:$.shipping_zones,class:"w-full compact-table responsive full-compact"},{default:a(()=>[e(b,{prop:"name",label:l(t)("Zone Name")},{default:a(S=>[e(fe,{to:{name:"view_shipping_zone",params:{zone_id:S.row.id}}},{default:a(()=>[z(u(S.row.name),1)]),_:2},1032,["to"])]),_:1},8,["label"]),e(b,{label:l(t)("Country")},{default:a(S=>[e(fe,{to:{name:"view_shipping_zone",params:{zone_id:S.row.id}}},{default:a(()=>[S.row.formatted_region?(o(),m("div",He,[g("span",null,u(S.row.formatted_region),1)])):(o(),m("div",Je,u(l(t)("Applied To All Countries")),1))]),_:2},1032,["to"])]),_:1},8,["label"]),e(b,{label:l(t)("Shipping Methods"),width:"180"},{default:a(S=>[e(fe,{to:{name:"view_shipping_zone",params:{zone_id:S.row.id}}},{default:a(()=>[S.row.methods_count>0?(o(),m("div",Ke,u(l(t)("%s methods",S.row.methods_count)),1)):(o(),m("div",Ge,u(l(t)("No methods")),1))]),_:2},1032,["to"])]),_:1},8,["label"]),e(b,{label:l(t)("Actions"),width:"200",align:"right"},{default:a(S=>[g("div",Qe,[e(de,{size:"small",onClick:E=>f.$router.push({name:"view_shipping_zone",params:{zone_id:S.row.id}}),class:"cursor-pointer"},{default:a(()=>[e(ee,{name:"Edit"})]),_:2},1032,["onClick"]),e(i,{title:l(t)("Are you sure to delete this shipping zone?"),onConfirm:E=>r(S.row.id),width:"220"},{reference:a(()=>[e(de,{size:"small",class:"cursor-pointer"},{default:a(()=>[e(ee,{name:"Delete"})]),_:1})]),_:2},1032,["title","onConfirm"])])]),_:1},8,["label"])]),_:1},8,["data"])),[[Z,v.value]])])}}},Xe=Se(Ye,[["__scopeId","data-v-4219a2eb"]]),et={class:"shipping-zones-loader"},tt={class:"shipping-zones-table"},lt={class:"table-cell"},at={class:"table-cell"},st={class:"table-cell"},nt={class:"table-cell"},ot={__name:"ShippingZonesLoader",props:{shippingZoneTable:{type:Object,required:!0},nextPageCount:{type:Number,default:0}},setup($){const c=$,C=Array.from({length:c.nextPageCount},(v,r)=>r+1);return(v,r)=>{const f=d("el-skeleton-item"),w=d("el-skeleton"),b=d("el-table-column"),i=d("el-table");return o(),m("div",et,[g("div",tt,[e(i,{data:l(C),class:"w-full compact-table responsive"},{default:a(()=>[e(b,{prop:"name",label:l(t)("Zone Name")},{default:a(()=>[g("div",lt,[e(w,{animated:""},{template:a(()=>[e(f,{varient:"p",class:"w-[120px]"})]),_:1})])]),_:1},8,["label"]),e(b,{label:l(t)("Regions")},{default:a(()=>[g("div",at,[e(w,{animated:""},{template:a(()=>[e(f,{varient:"p",class:"w-[150px]"})]),_:1})])]),_:1},8,["label"]),e(b,{label:l(t)("Shipping Methods"),width:"180"},{default:a(()=>[g("div",st,[e(w,{animated:""},{template:a(()=>[e(f,{varient:"p",class:"w-[200px]"})]),_:1})])]),_:1},8,["label"]),e(b,{label:l(t)("Actions"),width:"200",align:"right"},{default:a(()=>[g("div",nt,[e(w,{animated:""},{template:a(()=>[e(f,{varient:"p",class:"w-[120px]"})]),_:1})])]),_:1},8,["label"])]),_:1},8,["data"])])])}}},it={class:"setting-wrap"},rt={class:"setting-wrap-inner"},ut={class:"text-sm text-gray-500 mb-3"},dt={class:"fct-all-shipping-zones-wrap"},ct={key:1},pt={__name:"AllShippingZones",setup($){const c=ve(),C=Le({shipping_class_id:0});return(v,r)=>{const f=d("el-button");return o(),m("div",it,[e(_e,{heading:l(t)("Shipping Zones"),"show-save-button":!1},{action:a(()=>[e(f,{type:"primary",onClick:r[0]||(r[0]=w=>l(c).push({name:"add_shipping_zone"})),size:"small"},{default:a(()=>[z(u(l(t)("Add Shipping Zone")),1)]),_:1})]),_:1},8,["heading"]),g("div",rt,[g("p",ut,u(l(t)("These are the general shipping zones that apply to all products. For class-specific zones, visit the individual shipping class page.")),1),g("div",dt,[e(Ce,{table:l(C)},{default:a(()=>[l(C).isLoading()?(o(),U(ot,{key:0,shippingZoneTable:l(C),"next-page-count":l(C).nextPageCount},null,8,["shippingZoneTable","next-page-count"])):(o(),m("div",ct,[e(Xe,{shipping_zones:l(C).getTableData(),columns:l(C).data.columns,onRefresh:r[1]||(r[1]=w=>l(C).fetch())},null,8,["shipping_zones","columns"])]))]),_:1},8,["table"])])])])}}},_t={class:"single-shipping-zone-loader"},mt={class:"single-page-header flex items-center justify-between"},gt={class:"fct-page-header__actions"},ht={__name:"SingleShippingZoneLoader",setup($){return(c,C)=>{const v=d("el-skeleton-item"),r=d("el-skeleton"),f=d("el-breadcrumb-item"),w=d("el-breadcrumb");return o(),m("div",_t,[g("div",mt,[e(w,{"separator-icon":l(he)},{default:a(()=>[e(f,null,{default:a(()=>[e(r,{animated:"",class:"h-4"},{template:a(()=>[e(v,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(r,{animated:"",class:"h-4"},{template:a(()=>[e(v,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(r,{animated:"",class:"h-4"},{template:a(()=>[e(v,{variant:"p",class:"w-[60px] h-4"})]),_:1})]),_:1})]),_:1},8,["separator-icon"]),g("div",gt,[e(r,{animated:"",class:"h-9 w-[172px]"},{template:a(()=>[e(v,{variant:"p",class:"w-full h-9 rounded"})]),_:1})])]),e(l(oe),{class:"mb-4"},{default:a(()=>[e(l(re),{title:l(t)("Zone Details"),border_bottom:"",title_size:"small"},null,8,["title"]),e(l(ne),null,{default:a(()=>[e(r,{rows:4,animated:!0})]),_:1})]),_:1}),e(l(oe),{class:"mb-4"},{default:a(()=>[e(l(re),{title:l(t)("Shipping Methods"),border_bottom:"",title_size:"small"},null,8,["title"]),e(l(ne),null,{default:a(()=>[e(r,{rows:4,animated:!0})]),_:1})]),_:1})])}}},ft={class:"fct-weight-tiers-editor"},vt={class:"mb-2 text-sm text-gray-500"},bt={key:0,style:{color:"var(--el-color-danger)","font-size":"12px","line-height":"1.2",margin:"4px 0 0"}},yt={key:0,style:{color:"var(--el-color-danger)","font-size":"12px","line-height":"1.2",margin:"4px 0 0"}},wt={class:"mt-2 flex items-center gap-2"},xt={key:0,class:"text-xs text-gray-400"},Ct={__name:"WeightTiersEditor",props:{modelValue:{type:Array,default:()=>[]},weightUnit:{type:String,default:"kg"}},emits:["update:modelValue"],setup($,{emit:c}){const C=$,v=c,r=x(C.modelValue.length>0?[...C.modelValue]:[{min:0,max:0,cost:0}]),f=te(()=>{const y=r.value[r.value.length-1];return y&&y.max<=0}),w=y=>{const p=r.value[y];return y===r.value.length-1&&p.max<=0?"":p.max>0&&p.max<=p.min?t("Max must be greater than %s",p.min):""},b=y=>{if(y===0)return"";const p=r.value[y-1],M=r.value[y];return p.max<=0?"":M.min<p.max?t("Overlaps with previous tier (max %s)",p.max):""},i=y=>b(y)||w(y),N=te(()=>r.value.some((y,p)=>i(p))),Z=te(()=>f.value||N.value);Fe(()=>C.modelValue,y=>{y&&y.length>0?r.value=[...y]:r.value=[{min:0,max:0,cost:0}]},{deep:!0});const S=()=>{if(Z.value)return;const y=r.value[r.value.length-1],p=y&&y.max>0?parseFloat((y.max+.01).toFixed(2)):0;r.value.push({min:p,max:0,cost:0}),B()},E=y=>{r.value.splice(y,1),B()},W=()=>{r.value.sort((y,p)=>(y.min||0)-(p.min||0));for(let y=0;y<r.value.length-1;y++)r.value[y].max<=0&&(r.value[y].max=parseFloat((r.value[y].min+1).toFixed(2)))},B=()=>{W(),v("update:modelValue",[...r.value])},V=()=>{B()};return ge(()=>{C.modelValue.length||B()}),(y,p)=>{const M=d("el-input-number"),T=d("el-table-column"),O=d("el-button"),K=d("el-table");return o(),m("div",ft,[g("div",vt,u(l(t)("Define weight ranges and their shipping costs. Set max to 0 for unlimited.")),1),e(K,{data:r.value,size:"small",class:"w-full"},{default:a(()=>[e(T,{label:l(t)("Min Weight (%s)",$.weightUnit),"min-width":"120"},{default:a(D=>[e(M,{modelValue:D.row.min,"onUpdate:modelValue":H=>D.row.min=H,min:0,precision:2,step:.1,size:"small","controls-position":"right",onChange:V,class:me(["w-full",{"is-error":b(D.$index)}])},null,8,["modelValue","onUpdate:modelValue","class"]),b(D.$index)?(o(),m("p",bt,u(b(D.$index)),1)):I("",!0)]),_:1},8,["label"]),e(T,{label:l(t)("Max Weight (%s)",$.weightUnit),"min-width":"120"},{default:a(D=>[e(M,{modelValue:D.row.max,"onUpdate:modelValue":H=>D.row.max=H,min:0,precision:2,step:.1,size:"small","controls-position":"right",onChange:V,class:me(["w-full",{"is-error":w(D.$index)}])},null,8,["modelValue","onUpdate:modelValue","class"]),w(D.$index)?(o(),m("p",yt,u(w(D.$index)),1)):I("",!0)]),_:1},8,["label"]),e(T,{label:l(t)("Cost"),"min-width":"120"},{default:a(D=>[e(M,{modelValue:D.row.cost,"onUpdate:modelValue":H=>D.row.cost=H,min:0,precision:2,step:.5,size:"small","controls-position":"right",onChange:V,class:"w-full"},null,8,["modelValue","onUpdate:modelValue"])]),_:1},8,["label"]),e(T,{label:l(t)("Actions"),width:"60",align:"center"},{default:a(D=>[r.value.length>1?(o(),U(O,{key:0,type:"danger",text:"",size:"small","aria-label":l(t)("Remove tier"),onClick:H=>E(D.$index)},{default:a(()=>[e(ee,{name:"Delete",class:"w-3 h-3"})]),_:2},1032,["aria-label","onClick"])):I("",!0)]),_:1},8,["label"])]),_:1},8,["data"]),g("div",wt,[e(O,{size:"small",onClick:S,disabled:Z.value},{default:a(()=>[e(ee,{name:"Plus",class:"w-3 h-3 mr-1"}),z(" "+u(l(t)("Add Tier")),1)]),_:1},8,["disabled"]),f.value?(o(),m("span",xt,u(l(t)("Last tier has unlimited range (max = 0). Set a max value to add more tiers.")),1)):I("",!0)])])}}},St={class:"fct-shipping-methods-wrap"},kt={class:"shipping-methods-list"},$t={key:0,class:"flex flex-wrap gap-1"},zt={key:1,class:"text-muted"},Vt={key:0},Tt={key:1},At={key:2},Ft={key:3},Zt={key:0},Pt={key:1},Et={key:0},Dt={key:1},Mt={class:"flex items-center gap-1"},Ut={class:"no-methods"},Nt={class:"el-form-item__label"},Rt={key:0,class:"form-help-text mt-1"},Ot={key:0,class:"form-help-text mt-1"},qt={class:"dialog-footer"},Wt={__name:"ShippingMethods",props:{zone_id:{type:[String,Number],required:!0},methods:{type:Array,required:!1,default:()=>[]},country:{type:String,default:""}},emits:["fetchShippingMethods"],setup($,{emit:c}){const C=De.get("shop.weight_unit")||"kg",v=$,r=c,f=x(!1),w=x(null),b=x(!1),i=x({zone_id:v.zone_id,method_id:0,title:"",type:"flat_rate",settings:{configure_rate:"per_item",class_aggregation:"sum_all"},amount:0,is_enabled:1,states:[],meta:{description:""}}),N=x(!1),Z=x([]),S=te(()=>v.country==="all"||v.country==="selection"),E=x({title:[{required:!0,message:t("Please enter a method title"),trigger:"blur"}],type:[{required:!0,message:t("Please select a method type"),trigger:"blur"}]}),W=x("States"),B=()=>{i.value={zone_id:v.zone_id,method_id:0,title:"",type:"flat_rate",settings:{configure_rate:"per_item",class_aggregation:"sum_all",weight_tiers:[]},amount:0,is_enabled:1,states:[],meta:{description:""}},f.value=!0},V=()=>{if(i.value.type==="free_shipping"||i.value.settings.configure_rate!=="per_weight")return!0;const n=i.value.settings.weight_tiers||[];return n.length?n.every(h=>!h.cost||h.cost<=0)?(P.error(t("Weight tiers must have a cost greater than zero")),!1):!0:(P.error(t("Please add at least one weight tier")),!1)},y=()=>{V()&&(b.value=!0,j.post("shipping/methods",i.value).then(n=>{P.success(n.message),f.value=!1,r("fetchShippingMethods")}).catch(n=>{let s="";if(n.status_code=="422")for(const h in n.data){const A=n.data[h],k=Object.values(A)[0];s+=k+`
2 -`}s||(s=t("Failed to save shipping method")),P.error(s)}).finally(()=>{b.value=!1}))},p=()=>{V()&&(b.value=!0,j.put("shipping/methods",i.value).then(n=>{P.success(n.message),f.value=!1,r("fetchShippingMethods")}).catch(n=>{P.error(t("Failed to update shipping method"))}).finally(()=>{b.value=!1}))},M=n=>{j.delete("/shipping/methods/"+n).then(s=>{P.success(s.message),r("fetchShippingMethods")}).catch(s=>{P.error(t("Failed to delete shipping method"))})},T=x([{label:t("Flat Rate"),value:"flat_rate"},{label:t("Free Shipping"),value:"free_shipping"},{label:t("Local Pickup"),value:"local_pickup"}]),O=n=>{var s;i.value={zone_id:v.zone_id,method_id:n.id,title:n.title,type:n.type,settings:{configure_rate:"per_item",class_aggregation:"sum_all",weight_tiers:[],...n.settings||{}},amount:n.amount,is_enabled:n.is_enabled?1:0,states:n.states,meta:{description:((s=n.meta)==null?void 0:s.description)||""}},f.value=!0},K=te(()=>{if(i.value.settings.configure_rate==="per_order")return t("Single charge for the entire order.");if(i.value.settings.configure_rate==="per_item")return t("Charge per item in the cart.");if(i.value.settings.configure_rate==="per_price")return t("Percentage of the total amount of the order");if(i.value.settings.configure_rate==="per_weight")return t("Cost based on total weight of items in the cart.")}),D=te(()=>{if(i.value.settings.class_aggregation==="sum_all")return t("Sums of all shipping classes.");if(i.value.settings.class_aggregation==="highest_class")return t("Cost of the highest class among all the classes.")}),H=n=>{if(n==="per_order")return t("Per Order");if(n==="per_item")return t("Per Item");if(n==="per_price")return t("Percentage");if(n==="per_weight")return t("Per Weight")},q=()=>{!v.country||v.country==="all"||v.country==="selection"||(N.value=!0,j.get("/shipping/zone/states",{country_code:v.country}).then(n=>{var s,h,A,k,L,G,Q;Z.value=(s=n.data)==null?void 0:s.states,(k=(A=(h=n.data)==null?void 0:h.address_locale)==null?void 0:A.state)!=null&&k.label&&(W.value=(Q=(G=(L=n.data)==null?void 0:L.address_locale)==null?void 0:G.state)==null?void 0:Q.label)}).catch(n=>{P.error(t("Failed to load states"))}).finally(()=>{N.value=!1}))};return(n,s)=>{const h=d("el-button"),A=d("el-table-column"),k=d("el-tag"),L=d("el-popconfirm"),G=d("el-table"),Q=d("el-switch"),J=d("el-form-item"),X=d("el-input"),R=d("el-option"),le=d("el-select"),ae=d("el-col"),F=d("el-row"),be=d("el-form"),Te=d("el-drawer"),Ae=ce("loading");return o(),m("div",St,[$.zone_id?(o(),U(l(oe),{key:0,class:"mb-4 overflow-hidden"},{default:a(()=>[e(l(re),{title:l(t)("Shipping Methods")},{action:a(()=>[e(h,{type:"primary",onClick:B},{default:a(()=>[z(u(l(t)("Add Shipping Method")),1)]),_:1})]),_:1},8,["title"]),e(l(ne),null,{default:a(()=>[g("div",kt,[e(G,{data:$.methods,class:"w-full"},{empty:a(()=>[g("div",Ut,[g("p",null,u(l(t)("No shipping methods found for this zone. Add a shipping method to define how products are shipped in this zone.")),1)])]),default:a(()=>[e(A,{prop:"title",label:l(t)("Method Title")},null,8,["label"]),e(A,{label:l(t)("States")},{default:a(_=>[_.row.formatted_states&&_.row.formatted_states.length>0?(o(),m("div",$t,[(o(!0),m(se,null,ie(_.row.formatted_states.slice(0,3),(Y,ue)=>(o(),U(k,{key:ue,type:"info"},{default:a(()=>[z(u(Y),1)]),_:2},1024))),128)),_.row.formatted_states.length>3?(o(),U(k,{key:0,type:"info"},{default:a(()=>[z(" +"+u(_.row.formatted_states.length-3),1)]),_:2},1024)):I("",!0)])):(o(),m("div",zt,u(l(t)("Applied To All States")),1))]),_:1},8,["label"]),e(A,{prop:"type",label:l(t)("Method Type")},{default:a(_=>{var Y;return[z(u(((Y=T.value.find(ue=>ue.value===_.row.type))==null?void 0:Y.label)??_.row.type),1)]}),_:1},8,["label"]),e(A,{prop:"amount",label:l(t)("Amount"),width:"100px"},{default:a(_=>{var Y,ue;return[_.row.type==="free_shipping"?(o(),m("span",Vt,u(l(t)("Free")),1)):((Y=_.row.settings)==null?void 0:Y.configure_rate)==="per_weight"?(o(),m("span",Tt," — ")):((ue=_.row.settings)==null?void 0:ue.configure_rate)==="per_price"?(o(),m("span",At,u(_.row.amount)+"% ",1)):(o(),m("span",Ft,u(_.row.amount),1))]}),_:1},8,["label"]),e(A,{prop:"configure_rate",label:l(t)("Configure Rate")},{default:a(_=>[_.row.type==="free_shipping"?(o(),m("span",Zt," -- ")):(o(),m("span",Pt,u(H(_.row.settings.configure_rate)),1))]),_:1},8,["label"]),e(A,{prop:"class_aggregation",label:l(t)("Class Aggregation"),width:"200px"},{default:a(_=>[_.row.type==="free_shipping"?(o(),m("span",Et," -- ")):(o(),m("span",Dt,u(_.row.settings.class_aggregation==="highest_class"?l(t)("Highest Class"):l(t)("Sum All")),1))]),_:1},8,["label"]),e(A,{prop:"is_enabled",label:l(t)("Enabled")},{default:a(_=>[e(We,{type:_.row.is_enabled?"success":"info"},{default:a(()=>[z(u(_.row.is_enabled?l(t)("Enabled"):l(t)("Disabled")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),e(A,{label:l(t)("Actions"),width:"100"},{default:a(_=>[g("div",Mt,[e(de,{size:"small",class:"cursor-pointer",hover:"primary",bg:"transparent","aria-label":l(t)("Edit"),onClick:Y=>O(_.row)},{default:a(()=>[e(ee,{name:"Edit"})]),_:2},1032,["aria-label","onClick"]),e(L,{title:l(t)("Are you sure to delete this shipping method?"),onConfirm:Y=>M(_.row.id)},{reference:a(()=>[e(de,{size:"small",class:"cursor-pointer",hover:"danger",bg:"transparent","aria-label":l(t)("Delete")},{default:a(()=>[e(ee,{name:"Delete"})]),_:1},8,["aria-label"])]),_:2},1032,["title","onConfirm"])])]),_:1},8,["label"])]),_:1},8,["data"])])]),_:1})]),_:1})):(o(),U(l(oe),{key:1},{default:a(()=>[e(l(ne),null,{default:a(()=>[z(u(l(t)("No Shipping Zone Id provided")),1)]),_:1})]),_:1})),e(Te,{modelValue:f.value,"onUpdate:modelValue":s[12]||(s[12]=_=>f.value=_),title:i.value.method_id?l(t)("Edit Shipping Method"):l(t)("Add Shipping Method"),"aria-label":i.value.method_id?l(t)("Edit Shipping Method"):l(t)("Add Shipping Method"),width:"500px","append-to-body":"","close-on-click-modal":!0,class:"fct-shipping-method-drawer",onOpen:q},{footer:a(()=>[g("span",qt,[e(h,{onClick:s[11]||(s[11]=_=>f.value=!1)},{default:a(()=>[z(u(l(t)("Cancel")),1)]),_:1}),i.value.method_id?(o(),U(h,{key:0,type:"primary",onClick:p,loading:b.value},{default:a(()=>[z(u(l(t)("Update")),1)]),_:1},8,["loading"])):(o(),U(h,{key:1,type:"primary",onClick:y,loading:b.value},{default:a(()=>[z(u(l(t)("Save")),1)]),_:1},8,["loading"]))])]),default:a(()=>[e(be,{model:i.value,rules:E.value,ref_key:"methodFormRef",ref:w,"label-position":"top","require-asterisk-position":"right"},{default:a(()=>[e(J,{prop:"is_enabled"},{label:a(()=>[g("span",Nt,[e(Q,{modelValue:i.value.is_enabled,"onUpdate:modelValue":s[0]||(s[0]=_=>i.value.is_enabled=_),"active-value":1,"inactive-value":0},null,8,["modelValue"]),z(" "+u(l(t)("Enable Shipping Method")),1)])]),_:1}),e(J,{label:l(t)("Method Title"),prop:"title"},{default:a(()=>[e(X,{modelValue:i.value.title,"onUpdate:modelValue":s[1]||(s[1]=_=>i.value.title=_),placeholder:l(t)("Enter method title")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),!S.value&&Z.value.length>0?pe((o(),U(J,{key:0,label:W.value},{default:a(()=>[e(le,{modelValue:i.value.states,"onUpdate:modelValue":s[2]||(s[2]=_=>i.value.states=_),multiple:"",filterable:"",clearable:"",placeholder:l(t)("Select %s",W.value||"States")},{default:a(()=>[(o(!0),m(se,null,ie(Z.value,(_,Y)=>(o(),U(R,{key:Y,label:_.name,value:_.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])),[[Ae,N.value]]):I("",!0),e(F,{gutter:12},{default:a(()=>[e(ae,{lg:i.value.settings.configure_rate=="per_weight"?24:12},{default:a(()=>[e(J,{label:l(t)("Method Type"),prop:"type"},{default:a(()=>[e(le,{modelValue:i.value.type,"onUpdate:modelValue":s[3]||(s[3]=_=>i.value.type=_),onChange:s[4]||(s[4]=_=>{_==="free_shipping"&&(i.value.amount=0,i.value.settings.configure_rate="",i.value.settings.class_aggregation="")})},{default:a(()=>[(o(!0),m(se,null,ie(T.value,_=>(o(),U(R,{key:_.value,label:_.label,value:_.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1},8,["lg"]),i.value.type!=="free_shipping"?(o(),m(se,{key:0},[i.value.settings.configure_rate!=="per_weight"?(o(),U(ae,{key:0,lg:12},{default:a(()=>[e(J,{label:l(t)("Amount"),prop:"amount"},{default:a(()=>[e(X,{type:"number",min:"0",modelValue:i.value.amount,"onUpdate:modelValue":s[5]||(s[5]=_=>i.value.amount=_),placeholder:l(t)("Enter amount")},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})):I("",!0),e(ae,{lg:24},{default:a(()=>[e(J,{label:l(t)("Configure Rate")},{default:a(()=>[e(le,{modelValue:i.value.settings.configure_rate,"onUpdate:modelValue":s[6]||(s[6]=_=>i.value.settings.configure_rate=_),onChange:s[7]||(s[7]=_=>{_==="per_weight"&&(i.value.amount=0)})},{default:a(()=>[e(R,{label:l(t)("Per Order"),value:"per_order"},null,8,["label"]),e(R,{label:l(t)("Per Item"),value:"per_item"},null,8,["label"]),e(R,{label:l(t)("Percentage"),value:"per_price"},null,8,["label"]),e(R,{label:l(t)("Per Weight"),value:"per_weight"},null,8,["label"])]),_:1},8,["modelValue"]),i.value.settings.configure_rate?(o(),m("div",Rt,u(K.value),1)):I("",!0)]),_:1},8,["label"])]),_:1}),i.value.settings.configure_rate==="per_weight"?(o(),U(ae,{key:1,lg:24},{default:a(()=>[e(J,{label:l(t)("Weight Tiers")},{default:a(()=>[e(Ct,{modelValue:i.value.settings.weight_tiers,"onUpdate:modelValue":s[8]||(s[8]=_=>i.value.settings.weight_tiers=_),"weight-unit":l(C)},null,8,["modelValue","weight-unit"])]),_:1},8,["label"])]),_:1})):I("",!0),e(ae,{lg:24},{default:a(()=>[e(J,{label:l(t)("Class Aggregation")},{default:a(()=>[e(le,{modelValue:i.value.settings.class_aggregation,"onUpdate:modelValue":s[9]||(s[9]=_=>i.value.settings.class_aggregation=_)},{default:a(()=>[e(R,{label:l(t)("Combined Cost"),value:"sum_all"},null,8,["label"]),e(R,{label:l(t)("Highest Cost"),value:"highest_class"},null,8,["label"])]),_:1},8,["modelValue"]),i.value.settings.class_aggregation?(o(),m("div",Ot,u(D.value),1)):I("",!0)]),_:1},8,["label"])]),_:1})],64)):I("",!0),e(ae,{lg:24},{default:a(()=>[e(J,{label:l(t)("Description")},{default:a(()=>[e(X,{modelValue:i.value.meta.description,"onUpdate:modelValue":s[10]||(s[10]=_=>i.value.meta.description=_),type:"textarea",rows:2,placeholder:l(t)("Enter description")},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title","aria-label"])])}}},Ve=Se(Wt,[["__scopeId","data-v-cc79479a"]]),It={class:"setting-wrap"},Bt={key:0,class:"cmd"},Lt={class:"setting-wrap-inner"},jt={class:"fct-single-shipping-zone-page"},Ht={key:0},Jt={key:2,class:"fct-single-shipping-zone"},Kt=["aria-label"],Gt=["aria-checked","onClick","onKeydown"],Qt={class:"fct-coverage-selector-content"},Yt={class:"fct-coverage-selector-title"},Xt={class:"fct-coverage-selector-desc"},ye={__name:"SingleShippingZone",props:{zone_id:{type:[String,Number],required:!1}},setup($){const c=$,C=ve(),v=Ne();v.bind(["mod+s"],s=>{s.preventDefault(),n()});const r=x(null),f=x(null),w=x(!1),b=x(!1),i=x({name:"",region:"",meta:null}),N=x({name:[{required:!0,message:t("Please enter a zone name"),trigger:"blur"}]}),Z=x([]),S=x([]),E=x("selected"),W=[{value:"whole_world",title:t("Whole world"),desc:t("Ship to every country and territory")},{value:"selected",title:t("Selected countries only"),desc:t("Ship exclusively to the countries you choose")},{value:"excluded",title:t("All countries except"),desc:t("Ship everywhere, excluding specific countries")}],B=x({show:!1,message:"",buttonText:"",route:""}),V=te(()=>!!c.zone_id),y=x([]),p=te(()=>y.value.map(s=>{const h=s.countries.map(L=>L.code),A=S.value.filter(L=>h.includes(L)).length,k=A>0?`${s.name} (${A}/${s.countries.length})`:`${s.name} (${s.countries.length})`;return{value:"continent_"+s.code,label:k,children:s.countries.map(L=>({value:L.code,label:L.name}))}})),M=()=>{j.get("shipping/zone/countries").then(s=>{y.value=(s.continents||[]).map(h=>({code:h.code,name:h.name,countries:h.countries}))}).catch(s=>{console.error("Error fetching countries:",s),y.value=[{code:"ALL",name:"",countries:ke.map(h=>({code:h.code2,name:h.name}))}]})},T=()=>{V.value&&(w.value=!0,j.get(`shipping/zones/${c.zone_id}`).then(s=>{const h=s.shipping_zone;i.value.name=h.name,i.value.region=h.region||"",i.value.meta=h.meta||null,Z.value=h.methods||[],h.region==="all"?(E.value="whole_world",S.value=[]):h.region==="selection"&&h.meta?(E.value=h.meta.selection_type==="excluded"?"excluded":"selected",S.value=h.meta.countries||[]):h.region&&h.region!=="all"?(E.value="selected",S.value=[h.region]):(E.value="selected",S.value=[])}).catch(s=>{console.error("Error fetching zone data:",s),B.value={show:!0,message:t("Shipping zone not found"),buttonText:t("Back to Shipping Zones"),route:{name:"all_shipping_zones"}}}).finally(()=>{w.value=!1,Ee(()=>D())}))},O=s=>{E.value=s,q()},K=()=>{S.value=S.value.filter(s=>!s.startsWith("continent_")),q()},D=()=>{var h,A,k;const s=((A=(h=f.value)==null?void 0:h.$el)==null?void 0:A.querySelector(".el-select__wrapper"))||((k=f.value)==null?void 0:k.$el);!s||!s.offsetWidth||document.documentElement.style.setProperty("--fct-country-input-width",s.offsetWidth+"px")},H=()=>{D()},q=()=>{if(E.value==="whole_world"){i.value.region="all",i.value.meta=null;return}const s=S.value,h=E.value==="excluded"?"excluded":"included";s.length===0?(i.value.region="",i.value.meta=null):s.length===1&&h==="included"?(i.value.region=s[0],i.value.meta=null):(i.value.region="selection",i.value.meta={countries:s,selection_type:h})},n=()=>{r.value.validate(s=>{if(!s)return;q(),b.value=!0;const h=V.value?"put":"post",A=`shipping/zones${V.value?`/${c.zone_id}`:""}`;j[h](A,i.value).then(k=>{P.success(k.message),V.value?T():C.push({name:"view_shipping_zone",params:{zone_id:k.shipping_zone.id}})}).catch(k=>{var L;k&&k.status_code=="422"?P.validationErrors(k):P.error(((L=k==null?void 0:k.data)==null?void 0:L.message)||(k==null?void 0:k.message)||t("Failed to save shipping zone")),console.error("Error saving shipping zone:",k)}).finally(()=>{b.value=!1})})};return ge(()=>{M(),T()}),Ue(()=>{v.unbind("mod+s")}),(s,h)=>{const A=d("el-breadcrumb-item"),k=d("el-breadcrumb"),L=d("el-button"),G=d("el-input"),Q=d("el-form-item"),J=d("el-tree-select"),X=d("el-form");return o(),m("div",It,[e(_e,{"show-save-button":!1},{heading:a(()=>[e(k,{class:"mb-0","separator-icon":l(he)},{default:a(()=>[e(A,{to:{name:"shipping"}},{default:a(()=>[z(u(l(t)("Shipping Zones")),1)]),_:1}),e(A,null,{default:a(()=>[z(u(V.value?l(t)("Edit Shipping Zone"):l(t)("Add Shipping Zone")),1)]),_:1}),V.value?(o(),U(A,{key:0},{default:a(()=>[z(u(i.value.name),1)]),_:1})):I("",!0)]),_:1},8,["separator-icon"])]),action:a(()=>[e(L,{type:"primary",onClick:n,loading:b.value,size:"small"},{default:a(()=>[b.value?I("",!0):(o(),m("span",Bt,"⌘s")),z(" "+u(b.value?l(t)("Saving"):l(t)("Save")),1)]),_:1},8,["loading"])]),_:1}),g("div",Lt,[g("div",jt,[w.value?(o(),m("div",Ht,[e(ht)])):B.value.show?(o(),U(ze,{key:1,message:B.value.message,"button-text":B.value.buttonText,route:B.value.route},null,8,["message","button-text","route"])):(o(),m("div",Jt,[e(l(oe),null,{default:a(()=>[e(l(re),{title:l(t)("Zone Details"),border_bottom:""},null,8,["title"]),e(l(ne),null,{default:a(()=>[e(X,{model:i.value,rules:N.value,ref_key:"zoneFormRef",ref:r,"label-position":"top","require-asterisk-position":"right"},{default:a(()=>[e(Q,{label:l(t)("Zone Name"),prop:"name"},{default:a(()=>[e(G,{modelValue:i.value.name,"onUpdate:modelValue":h[0]||(h[0]=R=>i.value.name=R),placeholder:l(t)("Enter zone name")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),e(Q,{label:l(t)("Coverage"),prop:"region",class:"mt-2 mb-0",required:""},{default:a(()=>[g("ul",{class:"fct-coverage-selector",role:"radiogroup","aria-label":l(t)("Coverage")},[(o(),m(se,null,ie(W,R=>g("li",{key:R.value,class:me({active:E.value===R.value}),role:"radio",tabindex:"0","aria-checked":E.value===R.value,onClick:le=>O(R.value),onKeydown:Ze(Pe(le=>O(R.value),["prevent"]),["enter","space"])},[g("div",Qt,[g("span",Yt,u(R.title),1),g("span",Xt,u(R.desc),1)]),h[2]||(h[2]=g("div",{class:"fct-coverage-selector-dot-wrap"},[g("span",{class:"fct-coverage-selector-dot"})],-1))],42,Gt)),64))],8,Kt)]),_:1},8,["label"]),e(Ie,{visible:E.value!=="whole_world",accordion:""},{default:a(()=>[e(Q,{label:l(t)("Countries"),class:"mt-6 mb-0",required:""},{default:a(()=>[e(J,{ref_key:"countryTreeRef",ref:f,modelValue:S.value,"onUpdate:modelValue":h[1]||(h[1]=R=>S.value=R),data:p.value,multiple:"",filterable:"","show-checkbox":"","collapse-tags":"","collapse-tags-tooltip":"","max-collapse-tags":3,"render-after-expand":!1,"node-key":"value",props:{label:"label",children:"children"},placeholder:l(t)("Type to search countries..."),"popper-class":"fct-country-tree-popper",teleported:!0,onCheck:K,onVisibleChange:H},null,8,["modelValue","data","placeholder"]),S.value.length>0?(o(),m("div",{key:0,class:me(["fct-coverage-hint",{"is-warning":E.value==="excluded"}])},u(E.value==="excluded"?l(t)("Ships everywhere except the countries listed above."):l(t)("Only ships to the countries listed above.")),3)):I("",!0)]),_:1},8,["label"])]),_:1},8,["visible"])]),_:1},8,["model","rules"])]),_:1})]),_:1}),V.value?(o(),U(Ve,{key:0,zone_id:c.zone_id,methods:Z.value,onFetchShippingMethods:T,country:i.value.region},null,8,["zone_id","methods","country"])):I("",!0)]))])])])}}};class el extends xe{setupInitialData(){super.setupInitialData(),this.data.sorting.sortBy="id",this.data.sorting.sortType="DESC"}getTabs(){return null}getToggleableColumns(){return[{label:t("Cost"),value:"cost"},{label:t("Type"),value:"type"}]}getSortableColumns(){return[{label:t("Class Name"),value:"name"},{label:t("Cost"),value:"cost"}]}getSearchHint(){return t("Search by class name")}getFetchUrl(){return"shipping/classes"}parseResponse(c){return c.shipping_classes}getTableName(){return"shipping_class_table"}getAdvanceFilterOptions(){return null}getSearchGuideOptions(){return[]}useFullWidthSearch(){return!0}}function tl($){return el.init($)}const ll={class:"shipping-classes-table"},al={class:"fct-btn-group sm justify-end"},sl={__name:"ShippingClassesTable",props:{shipping_classes:{type:Array,required:!0},columns:{type:Array,default:()=>[]}},emits:["refresh"],setup($,{emit:c}){const C=c,v=x(!1),r=x(!1),f=x(null),w=N=>{v.value=!0,j.delete(`/shipping/classes/${N}`).then(Z=>{P.success(Z.message),C("refresh")}).catch(Z=>{console.error("Error deleting shipping class:",Z),P.error(t("Failed to delete shipping class"))}).finally(()=>{v.value=!1})},b=N=>{f.value=N,r.value=!0},i=()=>{C("refresh")};return(N,Z)=>{const S=d("el-table-column"),E=d("el-popconfirm"),W=d("el-table"),B=ce("loading");return o(),m("div",ll,[pe((o(),U(W,{data:$.shipping_classes,class:"w-full responsive"},{default:a(()=>[e(S,{prop:"name",label:l(t)("Class Name")},{default:a(V=>[z(u(V.row.name),1)]),_:1},8,["label"]),e(S,{prop:"cost",label:l(t)("Cost"),width:"150"},{default:a(V=>[z(u(V.row.cost)+u(V.row.type==="percentage"?"%":""),1)]),_:1},8,["label"]),e(S,{prop:"type",label:l(t)("Type"),width:"150"},{default:a(V=>[z(u(V.row.type==="fixed"?l(t)("Fixed Amount"):l(t)("Percentage")),1)]),_:1},8,["label"]),e(S,{prop:"per_item",label:l(t)("Per Item"),width:"150"},{default:a(V=>[z(u(V.row.per_item==1?l(t)("Yes"):l(t)("No")),1)]),_:1},8,["label"]),e(S,{label:l(t)("Actions"),width:"200",align:"right"},{default:a(V=>[g("div",al,[e(de,{size:"small",onClick:y=>b(V.row),class:"cursor-pointer"},{default:a(()=>[e(ee,{name:"Edit"})]),_:2},1032,["onClick"]),e(E,{title:l(t)("Are you sure to delete this shipping class?"),onConfirm:y=>w(V.row.id),width:"220"},{reference:a(()=>[e(de,{size:"small",class:"cursor-pointer"},{default:a(()=>[e(ee,{name:"Delete"})]),_:1})]),_:2},1032,["title","onConfirm"])])]),_:1},8,["label"])]),_:1},8,["data"])),[[B,v.value]]),e($e,{modelValue:r.value,"onUpdate:modelValue":Z[0]||(Z[0]=V=>r.value=V),"class-data":f.value,onSaved:i},null,8,["modelValue","class-data"])])}}},nl={class:"shipping-classes-loader"},ol={class:"shipping-classes-table"},il={class:"table-cell"},rl={class:"table-cell"},ul={class:"table-cell"},dl={class:"table-cell"},cl={__name:"ShippingClassesLoader",props:{shippingClassTable:{type:Object,required:!0},nextPageCount:{type:Array,default:()=>[1,2,3,4,5]}},setup($){return(c,C)=>{const v=d("el-skeleton-item"),r=d("el-skeleton"),f=d("el-table-column"),w=d("el-table");return o(),m("div",nl,[g("div",ol,[e(w,{data:[],class:"w-full compact-table responsive"},{default:a(()=>[e(f,{prop:"name",label:l(t)("Class Name")},{default:a(()=>[g("div",il,[e(r,{animated:""},{template:a(()=>[e(v,{varient:"p",class:"w-[120px]"})]),_:1})])]),_:1},8,["label"]),e(f,{label:l(t)("Cost")},{default:a(()=>[g("div",rl,[e(r,{animated:""},{template:a(()=>[e(v,{varient:"p",class:"w-[80px]"})]),_:1})])]),_:1},8,["label"]),e(f,{label:l(t)("Type")},{default:a(()=>[g("div",ul,[e(r,{animated:""},{template:a(()=>[e(v,{varient:"p",class:"w-[100px]"})]),_:1})])]),_:1},8,["label"]),e(f,{label:l(t)("Actions"),width:"200",align:"right"},{default:a(()=>[g("div",dl,[e(r,{animated:""},{template:a(()=>[e(v,{varient:"p",class:"w-[80px]"})]),_:1})])]),_:1},8,["label"])]),_:1})])])}}},pl={class:"setting-wrap"},_l={class:"setting-wrap-inner"},ml={class:"fct-all-shipping-classes-wrap"},gl={key:1},hl={__name:"AllShippingClasses",setup($){const c=tl(),C=x(!1),v=x(null),r=()=>{v.value=null,C.value=!0},f=()=>{c.fetch(),C.value=!1};return(w,b)=>(o(),m("div",pl,[e(_e,{heading:l(t)("Shipping Classes"),"save-button-text":l(t)("Add Shipping Class"),onOnSave:r},null,8,["heading","save-button-text"]),g("div",_l,[g("div",ml,[e(Ce,{table:l(c)},{default:a(()=>[l(c).isLoading()?(o(),U(cl,{key:0,shippingClassTable:l(c),"next-page-count":l(c).nextPageCount},null,8,["shippingClassTable","next-page-count"])):(o(),m("div",gl,[e(sl,{shipping_classes:l(c).getTableData(),columns:l(c).data.columns,onRefresh:b[0]||(b[0]=i=>l(c).fetch())},null,8,["shipping_classes","columns"])]))]),_:1},8,["table"])]),e($e,{modelValue:C.value,"onUpdate:modelValue":b[1]||(b[1]=i=>C.value=i),"class-data":v.value,onSaved:f},null,8,["modelValue","class-data"])])]))}},fl={class:"single-shipping-zone-loader"},vl={class:"single-page-header flex items-center justify-between"},bl={class:"fct-page-header__actions"},yl={__name:"SingleShippingClassLoader",setup($){return(c,C)=>{const v=d("el-skeleton-item"),r=d("el-skeleton"),f=d("el-breadcrumb-item"),w=d("el-breadcrumb");return o(),m("div",fl,[g("div",vl,[e(w,{"separator-icon":l(he)},{default:a(()=>[e(f,null,{default:a(()=>[e(r,{animated:"",class:"h-4"},{template:a(()=>[e(v,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(r,{animated:"",class:"h-4"},{template:a(()=>[e(v,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(r,{animated:"",class:"h-4"},{template:a(()=>[e(v,{variant:"p",class:"w-[60px] h-4"})]),_:1})]),_:1})]),_:1},8,["separator-icon"]),g("div",bl,[e(r,{animated:"",class:"h-9 w-[172px]"},{template:a(()=>[e(v,{variant:"p",class:"w-full h-9 rounded"})]),_:1})])]),e(l(oe),{class:"mb-4"},{default:a(()=>[e(l(re),{title:l(t)("Class Details"),border_bottom:"",title_size:"small"},null,8,["title"]),e(l(ne),null,{default:a(()=>[e(r,{rows:4,animated:!0})]),_:1})]),_:1})])}}},wl={class:"setting-wrap fct-single-shipping-class-page"},xl={class:"setting-wrap-inner"},Cl={key:0},Sl={key:2,class:"fct-single-shipping-class"},kl={class:"form-help-text w-full"},$l={class:"form-help-text"},zl={key:0,class:"mt-4"},Vl={class:"text-gray-500 text-sm mb-3"},Tl={key:0,class:"py-8"},Al={key:1,class:"text-center py-4 text-gray-400"},Fl={key:2},Zl={class:"flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-gray-800"},Pl={class:"text-gray-500 ml-2"},El={class:"flex items-center gap-1"},Dl={class:"p-0"},we={__name:"SingleShippingClass",props:{class_id:{type:[String,Number],required:!1}},setup($){const c=qe(),C=$,v=ve();c.onSave(()=>{T()});const r=x(null),f=x(!1),w=x(!1),b=x({name:"",description:"",cost:0,type:"fixed"}),i=x(!1),N=x([]),Z=x(!1),S=x(!1),E=x(null),W=x({name:"",region:"all"}),B=ke,V=x({name:[{required:!0,message:t("Please enter a class name"),trigger:"blur"}],cost:[{required:!0,message:t("Please enter a cost"),trigger:"blur"}],type:[{required:!0,message:t("Please select a cost type"),trigger:"blur"}]}),y=x({show:!1,message:"",buttonText:"",route:""}),p=te(()=>!!C.class_id),M=()=>{if(!p.value){f.value=!1;return}f.value=!0,j.get(`/shipping/classes/${C.class_id}`).then(q=>{const n=q.shipping_class;b.value={name:n.name,description:n.description||"",cost:n.cost,type:n.type},n.zones&&(N.value=n.zones)}).catch(q=>{y.value={show:!0,message:t("The shipping class you are looking for does not exist or has been deleted."),buttonText:t("Go to Shipping Classes"),route:{name:"shipping_classes"}}}).finally(()=>{f.value=!1})},T=()=>{r.value.validate(q=>{if(!q)return;w.value=!0;const n=p.value?"put":"post",s=p.value?`/shipping/classes/${C.class_id}`:"/shipping/classes";j[n](s,b.value).then(h=>{P.success(h.message),p.value||v.push({name:"view_shipping_class",params:{class_id:h.shipping_class.id}})}).catch(h=>{P.error(t("Failed to save shipping class"))}).finally(()=>{w.value=!1})})},O=()=>{p.value&&(i.value=!0,j.get(`/shipping/classes/${C.class_id}/profile`).then(q=>{var n;N.value=((n=q.shipping_class)==null?void 0:n.zones)||[]}).catch(q=>{P.error(t("Failed to load shipping profile"))}).finally(()=>{i.value=!1}))},K=()=>{W.value={name:"",region:"all"},Z.value=!0},D=()=>{E.value.validate(q=>{q&&(S.value=!0,j.post("/shipping/zones",{...W.value,shipping_class_id:C.class_id}).then(n=>{P.success(n.message),Z.value=!1,O()}).catch(n=>{P.error(t("Failed to save shipping zone"))}).finally(()=>{S.value=!1}))})},H=q=>{j.delete(`/shipping/zones/${q}`).then(n=>{P.success(n.message),O()}).catch(n=>{P.error(t("Failed to delete shipping zone"))})};return ge(()=>{M()}),(q,n)=>{const s=d("el-breadcrumb-item"),h=d("el-breadcrumb"),A=d("el-input"),k=d("el-form-item"),L=d("el-input-number"),G=d("el-option"),Q=d("el-select"),J=d("el-form"),X=d("el-button"),R=d("el-popconfirm"),le=d("el-drawer"),ae=ce("loading");return o(),m("div",wl,[e(_e,{"save-button-text":l(t)("Save Shipping Class"),"loading-text":l(t)("Saving Shipping Class"),loading:w.value,onOnSave:T},{heading:a(()=>[e(h,{"separator-icon":l(he)},{default:a(()=>[e(s,{to:{name:"shipping_classes"}},{default:a(()=>[z(u(l(t)("Shipping Classes")),1)]),_:1}),e(s,null,{default:a(()=>[z(u(p.value?l(t)("Edit Shipping Class"):l(t)("Add Shipping Class")),1)]),_:1}),p.value?(o(),U(s,{key:0},{default:a(()=>[z(u(b.value.name),1)]),_:1})):I("",!0)]),_:1},8,["separator-icon"])]),_:1},8,["save-button-text","loading-text","loading"]),g("div",xl,[f.value?(o(),m("div",Cl,[e(yl)])):y.value.show?(o(),U(ze,{key:1,message:y.value.message,"button-text":y.value.buttonText,route:y.value.route},null,8,["message","button-text","route"])):(o(),m("div",Sl,[e(l(oe),null,{default:a(()=>[e(l(re),{title:l(t)("Class Details"),border_bottom:"",title_size:"small"},null,8,["title"]),e(l(ne),null,{default:a(()=>[e(J,{model:b.value,rules:V.value,ref_key:"classFormRef",ref:r,"label-position":"top"},{default:a(()=>[e(k,{label:l(t)("Class Name"),prop:"name"},{default:a(()=>[e(A,{modelValue:b.value.name,"onUpdate:modelValue":n[0]||(n[0]=F=>b.value.name=F),placeholder:l(t)("Enter class name")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),e(k,{label:l(t)("Description")},{default:a(()=>[e(A,{modelValue:b.value.description,"onUpdate:modelValue":n[1]||(n[1]=F=>b.value.description=F),type:"textarea",rows:2,placeholder:l(t)("Enter description (optional)")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),e(k,{label:l(t)("Cost"),prop:"cost"},{default:a(()=>[e(L,{modelValue:b.value.cost,"onUpdate:modelValue":n[2]||(n[2]=F=>b.value.cost=F),precision:2,min:0,step:1,class:"w-full max-w-[200px]"},null,8,["modelValue"]),g("div",kl,u(l(t)("Additional cost for products in this shipping class")),1)]),_:1},8,["label"]),e(k,{label:l(t)("Cost Type"),prop:"type"},{default:a(()=>[e(Q,{modelValue:b.value.type,"onUpdate:modelValue":n[3]||(n[3]=F=>b.value.type=F),style:{width:"100%"}},{default:a(()=>[e(G,{label:l(t)("Fixed Amount"),value:"fixed"},null,8,["label"]),e(G,{label:l(t)("Percentage"),value:"percentage"},null,8,["label"])]),_:1},8,["modelValue"]),g("div",$l,u(l(t)("How this cost should be applied to the shipping rate")),1)]),_:1},8,["label"])]),_:1},8,["model","rules"])]),_:1})]),_:1}),p.value?(o(),m("div",zl,[e(l(oe),null,{default:a(()=>[e(l(re),{title:l(t)("Shipping Profile"),border_bottom:"",title_size:"small"},{action:a(()=>[e(X,{type:"primary",size:"small",onClick:K},{default:a(()=>[z(u(l(t)("Add Zone")),1)]),_:1})]),_:1},8,["title"]),e(l(ne),null,{default:a(()=>[g("p",Vl,u(l(t)("Define shipping zones and methods specific to this class. Products with this class will use these rates instead of the general shipping zones.")),1),i.value?pe((o(),m("div",Tl,null,512)),[[ae,!0]]):N.value.length===0?(o(),m("div",Al,u(l(t)("No class-specific zones yet. Products in this class will use the general shipping zones.")),1)):(o(),m("div",Fl,[(o(!0),m(se,null,ie(N.value,F=>(o(),m("div",{key:F.id,class:"mb-4 border rounded-md overflow-hidden"},[g("div",Zl,[g("div",null,[g("strong",null,u(F.name),1),g("span",Pl,"("+u(F.formatted_region)+")",1)]),g("div",El,[e(R,{title:l(t)("Delete this zone and its methods?"),onConfirm:be=>H(F.id)},{reference:a(()=>[e(X,{size:"small",type:"danger",text:""},{default:a(()=>[z(u(l(t)("Delete Zone")),1)]),_:1})]),_:2},1032,["title","onConfirm"])])]),g("div",Dl,[e(Ve,{zone_id:F.id,methods:F.methods||[],country:F.region,onFetchShippingMethods:O},null,8,["zone_id","methods","country"])])]))),128))]))]),_:1})]),_:1})])):I("",!0),e(le,{modelValue:Z.value,"onUpdate:modelValue":n[7]||(n[7]=F=>Z.value=F),title:l(t)("Add Zone to Shipping Class"),"aria-label":l(t)("Add Zone to Shipping Class"),width:"500px","append-to-body":""},{footer:a(()=>[e(X,{onClick:n[6]||(n[6]=F=>Z.value=!1)},{default:a(()=>[z(u(l(t)("Cancel")),1)]),_:1}),e(X,{type:"primary",onClick:D,loading:S.value,disabled:S.value},{default:a(()=>[z(u(l(t)("Save")),1)]),_:1},8,["loading","disabled"])]),default:a(()=>[e(J,{model:W.value,ref_key:"zoneFormRef",ref:E,"label-position":"top"},{default:a(()=>[e(k,{label:l(t)("Zone Name"),prop:"name",rules:[{required:!0,message:l(t)("Zone name is required"),trigger:"blur"}]},{default:a(()=>[e(A,{modelValue:W.value.name,"onUpdate:modelValue":n[4]||(n[4]=F=>W.value.name=F),placeholder:l(t)("Enter zone name")},null,8,["modelValue","placeholder"])]),_:1},8,["label","rules"]),e(k,{label:l(t)("Region")},{default:a(()=>[e(Q,{modelValue:W.value.region,"onUpdate:modelValue":n[5]||(n[5]=F=>W.value.region=F),filterable:"",placeholder:l(t)("Select country or Whole World")},{default:a(()=>[e(G,{label:l(t)("Whole World"),value:"all"},null,8,["label"]),(o(!0),m(se,null,ie(l(B),F=>(o(),U(G,{key:F.code2,label:F.name,value:F.code2},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1},8,["model"])]),_:1},8,["modelValue","title","aria-label"])]))])])}}},Ml={class:"setting-wrap"},Ul={class:"setting-wrap-inner"},Nl={class:"fct-packages-list"},Rl={key:0,class:"fct-packages-empty"},Ol={class:"text-gray-500"},ql={key:1,class:"fct-packages-empty"},Wl={class:"text-gray-500"},Il={key:2,class:"fct-packages-cards"},Bl={class:"fct-package-card-left"},Ll={class:"fct-package-card-icon"},jl={class:"fct-package-card-info"},Hl={class:"fct-package-card-name"},Jl={class:"fct-package-card-dims"},Kl={class:"fct-package-card-right"},Gl={__name:"AllShippingPackages",setup($){const c=x([]),C=x(!1),v=x(!1),r=x(!1),f=x(null),w=x(!1),b={box:"Box",envelope:"Envelope",soft_package:"SoftPackage"},i=()=>{C.value=!0,v.value=!1,j.get("shipping/packages").then(p=>{c.value=p.packages||[]}).catch(p=>{v.value=!0,P.error(t("Failed to load packages"))}).finally(()=>{C.value=!1})},N=p=>w.value?Promise.resolve():(w.value=!0,j.post("shipping/packages",{packages:c.value}).then(M=>{c.value=M.packages||c.value,r.value=!1,P.success(M.message)}).catch(M=>{p&&(c.value=p),P.error(t("Failed to save packages"))}).finally(()=>{w.value=!1})),Z=()=>{v.value||w.value||(f.value=null,r.value=!0)},S=p=>{w.value||(f.value={...p},r.value=!0)},E=p=>{const M=JSON.parse(JSON.stringify(c.value));if(p.is_default&&c.value.forEach(T=>{T.is_default=!1}),f.value){const T=c.value.findIndex(O=>O.slug===f.value.slug);T!==-1&&(c.value[T]=p)}else{let T=p.slug,O=1;for(;c.value.some(K=>K.slug===T);)T=p.slug+"-"+O,O++;p.slug=T,c.value.push(p)}N(M)},W=p=>{if(w.value)return;const M=JSON.parse(JSON.stringify(c.value));c.value.forEach(T=>{T.is_default=T.slug===p.slug}),N(M)},B=p=>{w.value||Oe.confirm(t("Are you sure you want to delete this package?"),t("Delete Package"),{confirmButtonText:t("Delete"),cancelButtonText:t("Cancel"),type:"warning"}).then(()=>{const M=JSON.parse(JSON.stringify(c.value)),T=c.value.findIndex(O=>O.slug===p.slug);T!==-1&&(c.value.splice(T,1),N(M))}).catch(()=>{})},V=p=>p.type==="envelope"?p.length+" × "+p.width+" "+p.dimension_unit:p.length+" × "+p.width+" × "+p.height+" "+p.dimension_unit,y=p=>p.weight+" "+p.weight_unit;return ge(()=>{i()}),(p,M)=>{const T=d("el-button"),O=d("el-tag"),K=d("el-dropdown-item"),D=d("el-dropdown-menu"),H=d("el-dropdown"),q=ce("loading");return o(),m("div",Ml,[e(_e,{heading:l(t)("Packages"),"save-button-text":l(t)("Add Package"),onOnSave:Z},null,8,["heading","save-button-text"]),g("div",Ul,[pe((o(),m("div",Nl,[v.value&&!C.value?(o(),m("div",Rl,[g("p",Ol,u(l(t)("Failed to load packages.")),1),e(T,{type:"primary",size:"small",class:"mt-3",onClick:i},{default:a(()=>[z(u(l(t)("Retry")),1)]),_:1})])):c.value.length===0&&!C.value?(o(),m("div",ql,[g("p",Wl,u(l(t)("No packages defined yet. Add a package to define how your products are packaged for shipping.")),1)])):(o(),m("div",Il,[(o(!0),m(se,null,ie(c.value,n=>(o(),m("div",{key:n.slug,class:"fct-package-card"},[g("div",Bl,[g("span",Ll,[e(ee,{name:b[n.type]||"Box"},null,8,["name"])]),g("div",jl,[g("div",Hl,u(n.name),1),g("div",Jl,u(V(n))+", "+u(y(n)),1)])]),g("div",Kl,[n.is_default?(o(),U(O,{key:0,type:"info",size:"small",effect:"plain"},{default:a(()=>[z(u(l(t)("Store default")),1)]),_:1})):I("",!0),e(H,{class:"fct-more-option-wrap","popper-class":"fct-dropdown",trigger:"click",onCommand:s=>{s==="edit"?S(n):s==="default"?W(n):s==="delete"&&B(n)}},{dropdown:a(()=>[e(D,null,{default:a(()=>[e(K,{command:"edit"},{default:a(()=>[z(u(l(t)("Edit")),1)]),_:1}),n.is_default?I("",!0):(o(),U(K,{key:0,command:"default"},{default:a(()=>[z(u(l(t)("Set as default")),1)]),_:1})),e(K,{command:"delete",class:"item-destructive"},{default:a(()=>[z(u(l(t)("Delete")),1)]),_:1})]),_:2},1024)]),default:a(()=>[e(T,{class:"more-btn","aria-label":l(t)("Package actions")},{default:a(()=>[e(ee,{name:"More"})]),_:1},8,["aria-label"])]),_:2},1032,["onCommand"])])]))),128))]))])),[[q,C.value]]),e(Re,{modelValue:r.value,"onUpdate:modelValue":M[0]||(M[0]=n=>r.value=n),"edit-data":f.value,saving:w.value,onSave:E},null,8,["modelValue","edit-data","saving"])])])}}};window.fluent_cart_admin.hooks.addFilter("fluent_cart_routes","fluent_shipping",function($){return $.settings&&$.settings.children&&$.settings.children.push({name:"shipping",path:"shipping",component:pt,meta:{active_menu:"shipping",title:t("Shipping Zones"),permission:["store/settings","store/sensitive"]}},{name:"view_shipping_zone",path:"shipping/zone/:zone_id/edit",component:ye,props:!0,meta:{active_menu:"settings",title:t("Edit Shipping Zone"),permission:["store/settings","store/sensitive"]}},{name:"add_shipping_zone",path:"shipping/zone/add",component:ye,meta:{active_menu:"settings",title:t("Add Shipping Zone"),permission:["store/settings","store/sensitive"]}},{name:"shipping_classes",path:"shipping/shipping_classes",component:hl,meta:{active_menu:"settings",title:t("Shipping Classes"),permission:["store/settings","store/sensitive"]}},{name:"view_shipping_class",path:"shipping/shipping_classes/:class_id/edit",component:we,props:!0,meta:{active_menu:"settings",title:t("Edit Shipping Class"),permission:["store/settings","store/sensitive"]}},{name:"add_shipping_class",path:"shipping/shipping_classes/add",component:we,meta:{active_menu:"settings",title:t("Add Shipping Class"),permission:["store/settings","store/sensitive"]}},{name:"shipping_packages",path:"shipping/packages",component:Gl,meta:{active_menu:"settings",title:t("Packages"),permission:["store/settings","store/sensitive"]}}),$});
1 +import{h as w,r as d,U as ce,e as m,o,I as pe,c as U,w as a,a as e,u as l,f as z,t as u,d as g,l as te,v as Pe,i as he,b as I,n as ge,F as se,g as ie,z as Ze,q as De,x as Me}from"./chunks/vue.esm-bundler.js?ver=1.6.6";import{T as ke,_ as Ce,B as Ee}from"./chunks/Badge.js?ver=1.6.6";import{t,A as Ue}from"./chunks/Translator.js?ver=1.6.6";import{A as Ne}from"./chunks/Arr.js?ver=1.6.6";import{_ as ve,C as re,a as ne,b as oe}from"./chunks/CardBody.js?ver=1.6.6";import{R as j}from"./chunks/Rest.js?ver=1.6.6";import{I as de}from"./chunks/IconButton.js?ver=1.6.6";import{_ as ee}from"./chunks/DynamicIcon.js?ver=1.6.6";import{n as P}from"./chunks/Notify.js?ver=1.6.6";import{_ as Se}from"./chunks/_plugin-vue_export-helper.js?ver=1.6.6";import{u as be,o as Re}from"./chunks/vue-router.js?ver=1.6.6";import{S as _e,_ as me,u as Oe,c as $e,b as ze,a as qe}from"./chunks/countries.js?ver=1.6.6";import{b as fe,E as We}from"./chunks/index.js?ver=1.6.6";import{_ as Ve,u as Ie}from"./chunks/NotFound.js?ver=1.6.6";import{_ as Be}from"./chunks/Animation.js?ver=1.6.6";import"./chunks/Model.js?ver=1.6.6";import"./chunks/common.js?ver=1.6.6";import"./chunks/dayjs.min.js?ver=1.6.6";import"./chunks/Str.js?ver=1.6.6";import"./chunks/timezone.js?ver=1.6.6";import"./chunks/weekOfYear.js?ver=1.6.6";import"./chunks/Utils.js?ver=1.6.6";import"./chunks/CurrencyFormatter.js?ver=1.6.6";import"./chunks/Url.js?ver=1.6.6";import"./chunks/index3.js?ver=1.6.6";import"./chunks/TransitionAccordion.js?ver=1.6.6";import"./chunks/preload-helper.js?ver=1.6.6";import"./chunks/Asset.js?ver=1.6.6";class Le extends ke{constructor(c){super(c),this.shippingClassId=(c==null?void 0:c.shipping_class_id)??void 0}setupInitialData(){super.setupInitialData(),this.data.sorting.sortBy="id",this.data.sorting.sortType="DESC"}getTabs(){return null}getToggleableColumns(){return[{label:t("Regions"),value:"regions"},{label:t("Shipping Methods"),value:"methods_count"}]}getSearchHint(){return t("Search by zone name")}buildQueryParams(){const c=super.buildQueryParams();return this.shippingClassId!==void 0&&(c.shipping_class_id=this.shippingClassId),c}getFetchUrl(){return"shipping/zones"}parseResponse(c){return c.shipping_zones}getTableName(){return"shipping_zone_table"}getAdvanceFilterOptions(){return Ne.get(window,"fluentCartAdminApp.filter_options.shipping_zone_filter_options")}getSearchGuideOptions(){return[]}useFullWidthSearch(){return!0}with(){return["admin_shipping_zone_list"]}}function je(S){return Le.init(S)}const He={class:"shipping-zones-table"},Je={key:0},Ke={key:1,class:"text-muted"},Ge={key:0},Qe={key:1,class:"text-muted"},Ye={class:"fct-btn-group sm justify-end pr-4"},Xe={__name:"ShippingZonesTable",props:{shipping_zones:{type:Array,required:!0},columns:{type:Array,default:()=>[]}},emits:["refresh"],setup(S,{emit:c}){const k=c,v=w(!1),r=f=>{v.value=!0,j.delete(`/shipping/zones/${f}`).then(x=>{P.success(x.message||t("Shipping zone deleted successfully")),k("refresh")}).catch(x=>{P.error(x.message)}).finally(()=>{v.value=!1})};return(f,x)=>{const b=d("el-table-column"),i=d("el-popconfirm"),N=d("el-table"),Z=ce("loading");return o(),m("div",He,[pe((o(),U(N,{data:S.shipping_zones,class:"w-full compact-table responsive full-compact"},{default:a(()=>[e(b,{prop:"name",label:l(t)("Zone Name")},{default:a(C=>[e(ve,{to:{name:"view_shipping_zone",params:{zone_id:C.row.id}}},{default:a(()=>[z(u(C.row.name),1)]),_:2},1032,["to"])]),_:1},8,["label"]),e(b,{label:l(t)("Country")},{default:a(C=>[e(ve,{to:{name:"view_shipping_zone",params:{zone_id:C.row.id}}},{default:a(()=>[C.row.formatted_region?(o(),m("div",Je,[g("span",null,u(C.row.formatted_region),1)])):(o(),m("div",Ke,u(l(t)("Applied To All Countries")),1))]),_:2},1032,["to"])]),_:1},8,["label"]),e(b,{label:l(t)("Shipping Methods"),width:"180"},{default:a(C=>[e(ve,{to:{name:"view_shipping_zone",params:{zone_id:C.row.id}}},{default:a(()=>[C.row.methods_count>0?(o(),m("div",Ge,u(l(t)("%s methods",C.row.methods_count)),1)):(o(),m("div",Qe,u(l(t)("No methods")),1))]),_:2},1032,["to"])]),_:1},8,["label"]),e(b,{label:l(t)("Actions"),width:"200",align:"right"},{default:a(C=>[g("div",Ye,[e(de,{size:"small",onClick:D=>f.$router.push({name:"view_shipping_zone",params:{zone_id:C.row.id}}),class:"cursor-pointer"},{default:a(()=>[e(ee,{name:"Edit"})]),_:2},1032,["onClick"]),e(i,{title:l(t)("Are you sure to delete this shipping zone?"),onConfirm:D=>r(C.row.id),width:"220"},{reference:a(()=>[e(de,{size:"small",class:"cursor-pointer"},{default:a(()=>[e(ee,{name:"Delete"})]),_:1})]),_:2},1032,["title","onConfirm"])])]),_:1},8,["label"])]),_:1},8,["data"])),[[Z,v.value]])])}}},et=Se(Xe,[["__scopeId","data-v-2c17e590"]]),tt={class:"shipping-zones-loader"},lt={class:"shipping-zones-table"},at={class:"table-cell"},st={class:"table-cell"},nt={class:"table-cell"},ot={class:"table-cell"},it={__name:"ShippingZonesLoader",props:{shippingZoneTable:{type:Object,required:!0},nextPageCount:{type:Number,default:0}},setup(S){const c=S,k=Array.from({length:c.nextPageCount},(v,r)=>r+1);return(v,r)=>{const f=d("el-skeleton-item"),x=d("el-skeleton"),b=d("el-table-column"),i=d("el-table");return o(),m("div",tt,[g("div",lt,[e(i,{data:l(k),class:"w-full compact-table responsive"},{default:a(()=>[e(b,{prop:"name",label:l(t)("Zone Name")},{default:a(()=>[g("div",at,[e(x,{animated:""},{template:a(()=>[e(f,{varient:"p",class:"w-[120px]"})]),_:1})])]),_:1},8,["label"]),e(b,{label:l(t)("Regions")},{default:a(()=>[g("div",st,[e(x,{animated:""},{template:a(()=>[e(f,{varient:"p",class:"w-[150px]"})]),_:1})])]),_:1},8,["label"]),e(b,{label:l(t)("Shipping Methods"),width:"180"},{default:a(()=>[g("div",nt,[e(x,{animated:""},{template:a(()=>[e(f,{varient:"p",class:"w-[200px]"})]),_:1})])]),_:1},8,["label"]),e(b,{label:l(t)("Actions"),width:"200",align:"right"},{default:a(()=>[g("div",ot,[e(x,{animated:""},{template:a(()=>[e(f,{varient:"p",class:"w-[120px]"})]),_:1})])]),_:1},8,["label"])]),_:1},8,["data"])])])}}},rt={class:"setting-wrap"},ut={class:"setting-wrap-inner"},dt={class:"text-sm text-system-mid mb-3 dark:text-gray-300"},ct={class:"fct-all-shipping-zones-wrap"},pt={key:1},_t={__name:"AllShippingZones",setup(S){const c=be(),k=je({shipping_class_id:0});return(v,r)=>{const f=d("el-button");return o(),m("div",rt,[e(_e,{heading:l(t)("Shipping Zones"),"show-save-button":!1},{action:a(()=>[e(f,{type:"primary",onClick:r[0]||(r[0]=x=>l(c).push({name:"add_shipping_zone"})),size:"small"},{default:a(()=>[z(u(l(t)("Add Shipping Zone")),1)]),_:1})]),_:1},8,["heading"]),g("div",ut,[e(me),g("p",dt,u(l(t)("These are the general shipping zones that apply to all products. For class-specific zones, visit the individual shipping class page.")),1),g("div",ct,[e(Ce,{table:l(k)},{default:a(()=>[l(k).isLoading()?(o(),U(it,{key:0,shippingZoneTable:l(k),"next-page-count":l(k).nextPageCount},null,8,["shippingZoneTable","next-page-count"])):(o(),m("div",pt,[e(et,{shipping_zones:l(k).getTableData(),columns:l(k).data.columns,onRefresh:r[1]||(r[1]=x=>l(k).fetch())},null,8,["shipping_zones","columns"])]))]),_:1},8,["table"])])])])}}},mt={class:"single-shipping-zone-loader"},gt={class:"single-page-header flex items-center justify-between"},ht={class:"fct-page-header__actions"},ft={__name:"SingleShippingZoneLoader",setup(S){return(c,k)=>{const v=d("el-skeleton-item"),r=d("el-skeleton"),f=d("el-breadcrumb-item"),x=d("el-breadcrumb");return o(),m("div",mt,[g("div",gt,[e(x,{"separator-icon":l(fe)},{default:a(()=>[e(f,null,{default:a(()=>[e(r,{animated:"",class:"h-4"},{template:a(()=>[e(v,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(r,{animated:"",class:"h-4"},{template:a(()=>[e(v,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(r,{animated:"",class:"h-4"},{template:a(()=>[e(v,{variant:"p",class:"w-[60px] h-4"})]),_:1})]),_:1})]),_:1},8,["separator-icon"]),g("div",ht,[e(r,{animated:"",class:"h-9 w-[172px]"},{template:a(()=>[e(v,{variant:"p",class:"w-full h-9 rounded"})]),_:1})])]),e(l(oe),{class:"mb-4"},{default:a(()=>[e(l(re),{title:l(t)("Zone Details"),border_bottom:"",title_size:"small"},null,8,["title"]),e(l(ne),null,{default:a(()=>[e(r,{rows:4,animated:!0})]),_:1})]),_:1}),e(l(oe),{class:"mb-4"},{default:a(()=>[e(l(re),{title:l(t)("Shipping Methods"),border_bottom:"",title_size:"small"},null,8,["title"]),e(l(ne),null,{default:a(()=>[e(r,{rows:4,animated:!0})]),_:1})]),_:1})])}}},vt={class:"fct-weight-tiers-editor"},bt={class:"mb-2 text-sm text-gray-500"},yt={key:0,style:{color:"var(--el-color-danger)","font-size":"12px","line-height":"1.2",margin:"4px 0 0"}},wt={key:0,style:{color:"var(--el-color-danger)","font-size":"12px","line-height":"1.2",margin:"4px 0 0"}},xt={class:"mt-2 flex items-center gap-2"},kt={key:0,class:"text-xs text-gray-400"},Ct={__name:"WeightTiersEditor",props:{modelValue:{type:Array,default:()=>[]},weightUnit:{type:String,default:"kg"}},emits:["update:modelValue"],setup(S,{emit:c}){const k=S,v=c,r=w(k.modelValue.length>0?[...k.modelValue]:[{min:0,max:0,cost:0}]),f=te(()=>{const y=r.value[r.value.length-1];return y&&y.max<=0}),x=y=>{const p=r.value[y];return y===r.value.length-1&&p.max<=0?"":p.max>0&&p.max<=p.min?t("Max must be greater than %s",p.min):""},b=y=>{if(y===0)return"";const p=r.value[y-1],E=r.value[y];return p.max<=0?"":E.min<p.max?t("Overlaps with previous tier (max %s)",p.max):""},i=y=>b(y)||x(y),N=te(()=>r.value.some((y,p)=>i(p))),Z=te(()=>f.value||N.value);Pe(()=>k.modelValue,y=>{y&&y.length>0?r.value=[...y]:r.value=[{min:0,max:0,cost:0}]},{deep:!0});const C=()=>{if(Z.value)return;const y=r.value[r.value.length-1],p=y&&y.max>0?parseFloat((y.max+.01).toFixed(2)):0;r.value.push({min:p,max:0,cost:0}),B()},D=y=>{r.value.splice(y,1),B()},W=()=>{r.value.sort((y,p)=>(y.min||0)-(p.min||0));for(let y=0;y<r.value.length-1;y++)r.value[y].max<=0&&(r.value[y].max=parseFloat((r.value[y].min+1).toFixed(2)))},B=()=>{W(),v("update:modelValue",[...r.value])},V=()=>{B()};return he(()=>{k.modelValue.length||B()}),(y,p)=>{const E=d("el-input-number"),T=d("el-table-column"),O=d("el-button"),K=d("el-table");return o(),m("div",vt,[g("div",bt,u(l(t)("Define weight ranges and their shipping costs. Set max to 0 for unlimited.")),1),e(K,{data:r.value,size:"small",class:"w-full"},{default:a(()=>[e(T,{label:l(t)("Min Weight (%s)",S.weightUnit),"min-width":"120"},{default:a(M=>[e(E,{modelValue:M.row.min,"onUpdate:modelValue":H=>M.row.min=H,min:0,precision:2,step:.1,size:"small","controls-position":"right",onChange:V,class:ge(["w-full",{"is-error":b(M.$index)}])},null,8,["modelValue","onUpdate:modelValue","class"]),b(M.$index)?(o(),m("p",yt,u(b(M.$index)),1)):I("",!0)]),_:1},8,["label"]),e(T,{label:l(t)("Max Weight (%s)",S.weightUnit),"min-width":"120"},{default:a(M=>[e(E,{modelValue:M.row.max,"onUpdate:modelValue":H=>M.row.max=H,min:0,precision:2,step:.1,size:"small","controls-position":"right",onChange:V,class:ge(["w-full",{"is-error":x(M.$index)}])},null,8,["modelValue","onUpdate:modelValue","class"]),x(M.$index)?(o(),m("p",wt,u(x(M.$index)),1)):I("",!0)]),_:1},8,["label"]),e(T,{label:l(t)("Cost"),"min-width":"120"},{default:a(M=>[e(E,{modelValue:M.row.cost,"onUpdate:modelValue":H=>M.row.cost=H,min:0,precision:2,step:.5,size:"small","controls-position":"right",onChange:V,class:"w-full"},null,8,["modelValue","onUpdate:modelValue"])]),_:1},8,["label"]),e(T,{label:l(t)("Actions"),width:"60",align:"center"},{default:a(M=>[r.value.length>1?(o(),U(O,{key:0,type:"danger",text:"",size:"small","aria-label":l(t)("Remove tier"),onClick:H=>D(M.$index)},{default:a(()=>[e(ee,{name:"Delete",class:"w-3 h-3"})]),_:2},1032,["aria-label","onClick"])):I("",!0)]),_:1},8,["label"])]),_:1},8,["data"]),g("div",xt,[e(O,{size:"small",onClick:C,disabled:Z.value},{default:a(()=>[e(ee,{name:"Plus",class:"w-3 h-3 mr-1"}),z(" "+u(l(t)("Add Tier")),1)]),_:1},8,["disabled"]),f.value?(o(),m("span",kt,u(l(t)("Last tier has unlimited range (max = 0). Set a max value to add more tiers.")),1)):I("",!0)])])}}},St={class:"fct-shipping-methods-wrap"},$t={class:"shipping-methods-list"},zt={key:0,class:"flex flex-wrap gap-1"},Vt={key:1,class:"text-muted"},Tt={key:0},At={key:1},Ft={key:2},Pt={key:3},Zt={key:0},Dt={key:1},Mt={key:0},Et={key:1},Ut={class:"flex items-center gap-1"},Nt={class:"no-methods"},Rt={class:"el-form-item__label"},Ot={key:0,class:"form-help-text mt-1"},qt={key:0,class:"form-help-text mt-1"},Wt={class:"dialog-footer"},It={__name:"ShippingMethods",props:{zone_id:{type:[String,Number],required:!0},methods:{type:Array,required:!1,default:()=>[]},country:{type:String,default:""}},emits:["fetchShippingMethods"],setup(S,{emit:c}){const k=Ue.get("shop.weight_unit")||"kg",v=S,r=c,f=w(!1),x=w(null),b=w(!1),i=w({zone_id:v.zone_id,method_id:0,title:"",type:"flat_rate",settings:{configure_rate:"per_item",class_aggregation:"sum_all"},amount:0,is_enabled:1,states:[],meta:{description:""}}),N=w(!1),Z=w([]),C=te(()=>v.country==="all"||v.country==="selection"),D=w({title:[{required:!0,message:t("Please enter a method title"),trigger:"blur"}],type:[{required:!0,message:t("Please select a method type"),trigger:"blur"}]}),W=w("States"),B=()=>{i.value={zone_id:v.zone_id,method_id:0,title:"",type:"flat_rate",settings:{configure_rate:"per_item",class_aggregation:"sum_all",weight_tiers:[]},amount:0,is_enabled:1,states:[],meta:{description:""}},f.value=!0},V=()=>{if(i.value.type==="free_shipping"||i.value.settings.configure_rate!=="per_weight")return!0;const s=i.value.settings.weight_tiers||[];return s.length?s.every(h=>!h.cost||h.cost<=0)?(P.error(t("Weight tiers must have a cost greater than zero")),!1):!0:(P.error(t("Please add at least one weight tier")),!1)},y=()=>{V()&&(b.value=!0,j.post("shipping/methods",i.value).then(s=>{P.success(s.message),f.value=!1,r("fetchShippingMethods")}).catch(s=>{let n="";if(s.status_code=="422")for(const h in s.data){const A=s.data[h],$=Object.values(A)[0];n+=$+`
2 +`}n||(n=t("Failed to save shipping method")),P.error(n)}).finally(()=>{b.value=!1}))},p=()=>{V()&&(b.value=!0,j.put("shipping/methods",i.value).then(s=>{P.success(s.message),f.value=!1,r("fetchShippingMethods")}).catch(s=>{P.error(t("Failed to update shipping method"))}).finally(()=>{b.value=!1}))},E=s=>{j.delete("/shipping/methods/"+s).then(n=>{P.success(n.message),r("fetchShippingMethods")}).catch(n=>{P.error(t("Failed to delete shipping method"))})},T=w([{label:t("Flat Rate"),value:"flat_rate"},{label:t("Free Shipping"),value:"free_shipping"},{label:t("Local Pickup"),value:"local_pickup"}]),O=s=>{var n;i.value={zone_id:v.zone_id,method_id:s.id,title:s.title,type:s.type,settings:{configure_rate:"per_item",class_aggregation:"sum_all",weight_tiers:[],...s.settings||{}},amount:s.amount,is_enabled:s.is_enabled?1:0,states:s.states,meta:{description:((n=s.meta)==null?void 0:n.description)||""}},f.value=!0},K=te(()=>{if(i.value.settings.configure_rate==="per_order")return t("Single charge for the entire order.");if(i.value.settings.configure_rate==="per_item")return t("Charge per item in the cart.");if(i.value.settings.configure_rate==="per_price")return t("Percentage of the total amount of the order");if(i.value.settings.configure_rate==="per_weight")return t("Cost based on total weight of items in the cart.")}),M=te(()=>{if(i.value.settings.class_aggregation==="sum_all")return t("Sums of all shipping classes.");if(i.value.settings.class_aggregation==="highest_class")return t("Cost of the highest class among all the classes.")}),H=s=>{if(s==="per_order")return t("Per Order");if(s==="per_item")return t("Per Item");if(s==="per_price")return t("Percentage");if(s==="per_weight")return t("Per Weight")},q=()=>{!v.country||v.country==="all"||v.country==="selection"||(N.value=!0,j.get("/shipping/zone/states",{country_code:v.country}).then(s=>{var n,h,A,$,L,G,Q;Z.value=(n=s.data)==null?void 0:n.states,($=(A=(h=s.data)==null?void 0:h.address_locale)==null?void 0:A.state)!=null&&$.label&&(W.value=(Q=(G=(L=s.data)==null?void 0:L.address_locale)==null?void 0:G.state)==null?void 0:Q.label)}).catch(s=>{P.error(t("Failed to load states"))}).finally(()=>{N.value=!1}))};return(s,n)=>{const h=d("el-button"),A=d("el-table-column"),$=d("el-tag"),L=d("el-popconfirm"),G=d("el-table"),Q=d("el-switch"),J=d("el-form-item"),X=d("el-input"),R=d("el-option"),le=d("el-select"),ae=d("el-col"),F=d("el-row"),ye=d("el-form"),Ae=d("el-drawer"),Fe=ce("loading");return o(),m("div",St,[S.zone_id?(o(),U(l(oe),{key:0,class:"mb-4 overflow-hidden"},{default:a(()=>[e(l(re),{title:l(t)("Shipping Methods")},{action:a(()=>[e(h,{type:"primary",onClick:B},{default:a(()=>[z(u(l(t)("Add Shipping Method")),1)]),_:1})]),_:1},8,["title"]),e(l(ne),null,{default:a(()=>[g("div",$t,[e(G,{data:S.methods,class:"w-full"},{empty:a(()=>[g("div",Nt,[g("p",null,u(l(t)("No shipping methods found for this zone. Add a shipping method to define how products are shipped in this zone.")),1)])]),default:a(()=>[e(A,{prop:"title",label:l(t)("Method Title")},null,8,["label"]),e(A,{label:l(t)("States")},{default:a(_=>[_.row.formatted_states&&_.row.formatted_states.length>0?(o(),m("div",zt,[(o(!0),m(se,null,ie(_.row.formatted_states.slice(0,3),(Y,ue)=>(o(),U($,{key:ue,type:"info"},{default:a(()=>[z(u(Y),1)]),_:2},1024))),128)),_.row.formatted_states.length>3?(o(),U($,{key:0,type:"info"},{default:a(()=>[z(" +"+u(_.row.formatted_states.length-3),1)]),_:2},1024)):I("",!0)])):(o(),m("div",Vt,u(l(t)("Applied To All States")),1))]),_:1},8,["label"]),e(A,{prop:"type",label:l(t)("Method Type")},{default:a(_=>{var Y;return[z(u(((Y=T.value.find(ue=>ue.value===_.row.type))==null?void 0:Y.label)??_.row.type),1)]}),_:1},8,["label"]),e(A,{prop:"amount",label:l(t)("Amount"),width:"100px"},{default:a(_=>{var Y,ue;return[_.row.type==="free_shipping"?(o(),m("span",Tt,u(l(t)("Free")),1)):((Y=_.row.settings)==null?void 0:Y.configure_rate)==="per_weight"?(o(),m("span",At," — ")):((ue=_.row.settings)==null?void 0:ue.configure_rate)==="per_price"?(o(),m("span",Ft,u(_.row.amount)+"% ",1)):(o(),m("span",Pt,u(_.row.amount),1))]}),_:1},8,["label"]),e(A,{prop:"configure_rate",label:l(t)("Configure Rate")},{default:a(_=>[_.row.type==="free_shipping"?(o(),m("span",Zt," -- ")):(o(),m("span",Dt,u(H(_.row.settings.configure_rate)),1))]),_:1},8,["label"]),e(A,{prop:"class_aggregation",label:l(t)("Class Aggregation"),width:"200px"},{default:a(_=>[_.row.type==="free_shipping"?(o(),m("span",Mt," -- ")):(o(),m("span",Et,u(_.row.settings.class_aggregation==="highest_class"?l(t)("Highest Class"):l(t)("Sum All")),1))]),_:1},8,["label"]),e(A,{prop:"is_enabled",label:l(t)("Enabled")},{default:a(_=>[e(Ee,{type:_.row.is_enabled?"success":"info"},{default:a(()=>[z(u(_.row.is_enabled?l(t)("Enabled"):l(t)("Disabled")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),e(A,{label:l(t)("Actions"),width:"100"},{default:a(_=>[g("div",Ut,[e(de,{size:"small",class:"cursor-pointer",hover:"primary",bg:"transparent","aria-label":l(t)("Edit"),onClick:Y=>O(_.row)},{default:a(()=>[e(ee,{name:"Edit"})]),_:2},1032,["aria-label","onClick"]),e(L,{title:l(t)("Are you sure to delete this shipping method?"),onConfirm:Y=>E(_.row.id)},{reference:a(()=>[e(de,{size:"small",class:"cursor-pointer",hover:"danger",bg:"transparent","aria-label":l(t)("Delete")},{default:a(()=>[e(ee,{name:"Delete"})]),_:1},8,["aria-label"])]),_:2},1032,["title","onConfirm"])])]),_:1},8,["label"])]),_:1},8,["data"])])]),_:1})]),_:1})):(o(),U(l(oe),{key:1},{default:a(()=>[e(l(ne),null,{default:a(()=>[z(u(l(t)("No Shipping Zone Id provided")),1)]),_:1})]),_:1})),e(Ae,{modelValue:f.value,"onUpdate:modelValue":n[12]||(n[12]=_=>f.value=_),title:i.value.method_id?l(t)("Edit Shipping Method"):l(t)("Add Shipping Method"),"aria-label":i.value.method_id?l(t)("Edit Shipping Method"):l(t)("Add Shipping Method"),width:"500px","append-to-body":"","close-on-click-modal":!0,class:"fct-shipping-method-drawer",onOpen:q},{footer:a(()=>[g("span",Wt,[e(h,{onClick:n[11]||(n[11]=_=>f.value=!1)},{default:a(()=>[z(u(l(t)("Cancel")),1)]),_:1}),i.value.method_id?(o(),U(h,{key:0,type:"primary",onClick:p,loading:b.value},{default:a(()=>[z(u(l(t)("Update")),1)]),_:1},8,["loading"])):(o(),U(h,{key:1,type:"primary",onClick:y,loading:b.value},{default:a(()=>[z(u(l(t)("Save")),1)]),_:1},8,["loading"]))])]),default:a(()=>[e(ye,{model:i.value,rules:D.value,ref_key:"methodFormRef",ref:x,"label-position":"top","require-asterisk-position":"right"},{default:a(()=>[e(J,{prop:"is_enabled"},{label:a(()=>[g("span",Rt,[e(Q,{modelValue:i.value.is_enabled,"onUpdate:modelValue":n[0]||(n[0]=_=>i.value.is_enabled=_),"active-value":1,"inactive-value":0},null,8,["modelValue"]),z(" "+u(l(t)("Enable Shipping Method")),1)])]),_:1}),e(J,{label:l(t)("Method Title"),prop:"title"},{default:a(()=>[e(X,{modelValue:i.value.title,"onUpdate:modelValue":n[1]||(n[1]=_=>i.value.title=_),placeholder:l(t)("Enter method title")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),!C.value&&Z.value.length>0?pe((o(),U(J,{key:0,label:W.value},{default:a(()=>[e(le,{modelValue:i.value.states,"onUpdate:modelValue":n[2]||(n[2]=_=>i.value.states=_),multiple:"",filterable:"",clearable:"",placeholder:l(t)("Select %s",W.value||"States")},{default:a(()=>[(o(!0),m(se,null,ie(Z.value,(_,Y)=>(o(),U(R,{key:Y,label:_.name,value:_.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])),[[Fe,N.value]]):I("",!0),e(F,{gutter:12},{default:a(()=>[e(ae,{lg:i.value.settings.configure_rate=="per_weight"?24:12},{default:a(()=>[e(J,{label:l(t)("Method Type"),prop:"type"},{default:a(()=>[e(le,{modelValue:i.value.type,"onUpdate:modelValue":n[3]||(n[3]=_=>i.value.type=_),onChange:n[4]||(n[4]=_=>{_==="free_shipping"&&(i.value.amount=0,i.value.settings.configure_rate="",i.value.settings.class_aggregation="")})},{default:a(()=>[(o(!0),m(se,null,ie(T.value,_=>(o(),U(R,{key:_.value,label:_.label,value:_.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1},8,["lg"]),i.value.type!=="free_shipping"?(o(),m(se,{key:0},[i.value.settings.configure_rate!=="per_weight"?(o(),U(ae,{key:0,lg:12},{default:a(()=>[e(J,{label:l(t)("Amount"),prop:"amount"},{default:a(()=>[e(X,{type:"number",min:"0",modelValue:i.value.amount,"onUpdate:modelValue":n[5]||(n[5]=_=>i.value.amount=_),placeholder:l(t)("Enter amount")},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})):I("",!0),e(ae,{lg:24},{default:a(()=>[e(J,{label:l(t)("Configure Rate")},{default:a(()=>[e(le,{modelValue:i.value.settings.configure_rate,"onUpdate:modelValue":n[6]||(n[6]=_=>i.value.settings.configure_rate=_),onChange:n[7]||(n[7]=_=>{_==="per_weight"&&(i.value.amount=0)})},{default:a(()=>[e(R,{label:l(t)("Per Order"),value:"per_order"},null,8,["label"]),e(R,{label:l(t)("Per Item"),value:"per_item"},null,8,["label"]),e(R,{label:l(t)("Percentage"),value:"per_price"},null,8,["label"]),e(R,{label:l(t)("Per Weight"),value:"per_weight"},null,8,["label"])]),_:1},8,["modelValue"]),i.value.settings.configure_rate?(o(),m("div",Ot,u(K.value),1)):I("",!0)]),_:1},8,["label"])]),_:1}),i.value.settings.configure_rate==="per_weight"?(o(),U(ae,{key:1,lg:24},{default:a(()=>[e(J,{label:l(t)("Weight Tiers")},{default:a(()=>[e(Ct,{modelValue:i.value.settings.weight_tiers,"onUpdate:modelValue":n[8]||(n[8]=_=>i.value.settings.weight_tiers=_),"weight-unit":l(k)},null,8,["modelValue","weight-unit"])]),_:1},8,["label"])]),_:1})):I("",!0),e(ae,{lg:24},{default:a(()=>[e(J,{label:l(t)("Class Aggregation")},{default:a(()=>[e(le,{modelValue:i.value.settings.class_aggregation,"onUpdate:modelValue":n[9]||(n[9]=_=>i.value.settings.class_aggregation=_)},{default:a(()=>[e(R,{label:l(t)("Combined Cost"),value:"sum_all"},null,8,["label"]),e(R,{label:l(t)("Highest Cost"),value:"highest_class"},null,8,["label"])]),_:1},8,["modelValue"]),i.value.settings.class_aggregation?(o(),m("div",qt,u(M.value),1)):I("",!0)]),_:1},8,["label"])]),_:1})],64)):I("",!0),e(ae,{lg:24},{default:a(()=>[e(J,{label:l(t)("Description")},{default:a(()=>[e(X,{modelValue:i.value.meta.description,"onUpdate:modelValue":n[10]||(n[10]=_=>i.value.meta.description=_),type:"textarea",rows:2,placeholder:l(t)("Enter description")},null,8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1})]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title","aria-label"])])}}},Te=Se(It,[["__scopeId","data-v-26cc69b4"]]),Bt={class:"setting-wrap"},Lt={key:0,class:"cmd"},jt={class:"setting-wrap-inner"},Ht={class:"fct-single-shipping-zone-page"},Jt={key:0},Kt={key:2,class:"fct-single-shipping-zone"},Gt=["aria-label"],Qt=["aria-checked","onClick","onKeydown"],Yt={class:"fct-coverage-selector-content"},Xt={class:"fct-coverage-selector-title"},el={class:"fct-coverage-selector-desc"},we={__name:"SingleShippingZone",props:{zone_id:{type:[String,Number],required:!1}},setup(S){const c=S,k=be(),v=Oe();v.bind(["mod+s"],n=>{n.preventDefault(),s()});const r=w(null),f=w(null),x=w(!1),b=w(!1),i=w({name:"",region:"",meta:null}),N=w({name:[{required:!0,message:t("Please enter a zone name"),trigger:"blur"}]}),Z=w([]),C=w([]),D=w("selected"),W=[{value:"whole_world",title:t("Whole world"),desc:t("Ship to every country and territory")},{value:"selected",title:t("Selected countries only"),desc:t("Ship exclusively to the countries you choose")},{value:"excluded",title:t("All countries except"),desc:t("Ship everywhere, excluding specific countries")}],B=w({show:!1,message:"",buttonText:"",route:""}),V=te(()=>!!c.zone_id),y=w([]),p=te(()=>y.value.map(n=>{const h=n.countries.map(L=>L.code),A=C.value.filter(L=>h.includes(L)).length,$=A>0?`${n.name} (${A}/${n.countries.length})`:`${n.name} (${n.countries.length})`;return{value:"continent_"+n.code,label:$,children:n.countries.map(L=>({value:L.code,label:L.name}))}})),E=()=>{j.get("shipping/zone/countries").then(n=>{y.value=(n.continents||[]).map(h=>({code:h.code,name:h.name,countries:h.countries}))}).catch(n=>{y.value=[{code:"ALL",name:"",countries:$e.map(h=>({code:h.code2,name:h.name}))}]})},T=()=>{V.value&&(x.value=!0,j.get(`shipping/zones/${c.zone_id}`).then(n=>{const h=n.shipping_zone;i.value.name=h.name,i.value.region=h.region||"",i.value.meta=h.meta||null,Z.value=h.methods||[],h.region==="all"?(D.value="whole_world",C.value=[]):h.region==="selection"&&h.meta?(D.value=h.meta.selection_type==="excluded"?"excluded":"selected",C.value=h.meta.countries||[]):h.region&&h.region!=="all"?(D.value="selected",C.value=[h.region]):(D.value="selected",C.value=[])}).catch(n=>{B.value={show:!0,message:t("Shipping zone not found"),buttonText:t("Back to Shipping Zones"),route:{name:"all_shipping_zones"}}}).finally(()=>{x.value=!1,Me(()=>M())}))},O=n=>{D.value=n,q()},K=()=>{C.value=C.value.filter(n=>!n.startsWith("continent_")),q()},M=()=>{var h,A,$;const n=((A=(h=f.value)==null?void 0:h.$el)==null?void 0:A.querySelector(".el-select__wrapper"))||(($=f.value)==null?void 0:$.$el);!n||!n.offsetWidth||document.documentElement.style.setProperty("--fct-country-input-width",n.offsetWidth+"px")},H=()=>{M()},q=()=>{if(D.value==="whole_world"){i.value.region="all",i.value.meta=null;return}const n=C.value,h=D.value==="excluded"?"excluded":"included";n.length===0?(i.value.region="",i.value.meta=null):n.length===1&&h==="included"?(i.value.region=n[0],i.value.meta=null):(i.value.region="selection",i.value.meta={countries:n,selection_type:h})},s=()=>{r.value.validate(n=>{if(!n)return;q(),b.value=!0;const h=V.value?"put":"post",A=`shipping/zones${V.value?`/${c.zone_id}`:""}`;j[h](A,i.value).then($=>{P.success($.message),V.value?T():k.push({name:"view_shipping_zone",params:{zone_id:$.shipping_zone.id}})}).catch($=>{var L;$&&$.status_code=="422"?P.validationErrors($):P.error(((L=$==null?void 0:$.data)==null?void 0:L.message)||($==null?void 0:$.message)||t("Failed to save shipping zone"))}).finally(()=>{b.value=!1})})};return he(()=>{E(),T()}),Re(()=>{v.unbind("mod+s")}),(n,h)=>{const A=d("el-breadcrumb-item"),$=d("el-breadcrumb"),L=d("el-button"),G=d("el-input"),Q=d("el-form-item"),J=d("el-tree-select"),X=d("el-form");return o(),m("div",Bt,[e(_e,{"show-save-button":!1},{heading:a(()=>[e($,{class:"mb-0","separator-icon":l(fe)},{default:a(()=>[e(A,{to:{name:"shipping"}},{default:a(()=>[z(u(l(t)("Shipping Zones")),1)]),_:1}),e(A,null,{default:a(()=>[z(u(V.value?l(t)("Edit Shipping Zone"):l(t)("Add Shipping Zone")),1)]),_:1}),V.value?(o(),U(A,{key:0},{default:a(()=>[z(u(i.value.name),1)]),_:1})):I("",!0)]),_:1},8,["separator-icon"])]),action:a(()=>[e(L,{type:"primary",onClick:s,loading:b.value,size:"small"},{default:a(()=>[b.value?I("",!0):(o(),m("span",Lt,"⌘s")),z(" "+u(b.value?l(t)("Saving"):l(t)("Save")),1)]),_:1},8,["loading"])]),_:1}),g("div",jt,[e(me),g("div",Ht,[x.value?(o(),m("div",Jt,[e(ft)])):B.value.show?(o(),U(Ve,{key:1,message:B.value.message,"button-text":B.value.buttonText,route:B.value.route},null,8,["message","button-text","route"])):(o(),m("div",Kt,[e(l(oe),null,{default:a(()=>[e(l(re),{title:l(t)("Zone Details"),border_bottom:""},null,8,["title"]),e(l(ne),null,{default:a(()=>[e(X,{model:i.value,rules:N.value,ref_key:"zoneFormRef",ref:r,"label-position":"top","require-asterisk-position":"right"},{default:a(()=>[e(Q,{label:l(t)("Zone Name"),prop:"name"},{default:a(()=>[e(G,{modelValue:i.value.name,"onUpdate:modelValue":h[0]||(h[0]=R=>i.value.name=R),placeholder:l(t)("Enter zone name")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),e(Q,{label:l(t)("Coverage"),prop:"region",class:"mt-2 mb-0",required:""},{default:a(()=>[g("ul",{class:"fct-coverage-selector",role:"radiogroup","aria-label":l(t)("Coverage")},[(o(),m(se,null,ie(W,R=>g("li",{key:R.value,class:ge({active:D.value===R.value}),role:"radio",tabindex:"0","aria-checked":D.value===R.value,onClick:le=>O(R.value),onKeydown:Ze(De(le=>O(R.value),["prevent"]),["enter","space"])},[g("div",Yt,[g("span",Xt,u(R.title),1),g("span",el,u(R.desc),1)]),h[2]||(h[2]=g("div",{class:"fct-coverage-selector-dot-wrap"},[g("span",{class:"fct-coverage-selector-dot"})],-1))],42,Qt)),64))],8,Gt)]),_:1},8,["label"]),e(Be,{visible:D.value!=="whole_world",accordion:""},{default:a(()=>[e(Q,{label:l(t)("Countries"),class:"mt-6 mb-0",required:""},{default:a(()=>[e(J,{ref_key:"countryTreeRef",ref:f,modelValue:C.value,"onUpdate:modelValue":h[1]||(h[1]=R=>C.value=R),data:p.value,multiple:"",filterable:"","show-checkbox":"","collapse-tags":"","collapse-tags-tooltip":"","max-collapse-tags":3,"render-after-expand":!1,"node-key":"value",props:{label:"label",children:"children"},placeholder:l(t)("Type to search countries..."),"popper-class":"fct-country-tree-popper",teleported:!0,onCheck:K,onVisibleChange:H},null,8,["modelValue","data","placeholder"]),C.value.length>0?(o(),m("div",{key:0,class:ge(["fct-coverage-hint",{"is-warning":D.value==="excluded"}])},u(D.value==="excluded"?l(t)("Ships everywhere except the countries listed above."):l(t)("Only ships to the countries listed above.")),3)):I("",!0)]),_:1},8,["label"])]),_:1},8,["visible"])]),_:1},8,["model","rules"])]),_:1})]),_:1}),V.value?(o(),U(Te,{key:0,zone_id:c.zone_id,methods:Z.value,onFetchShippingMethods:T,country:i.value.region},null,8,["zone_id","methods","country"])):I("",!0)]))])])])}}};class tl extends ke{setupInitialData(){super.setupInitialData(),this.data.sorting.sortBy="id",this.data.sorting.sortType="DESC"}getTabs(){return null}getToggleableColumns(){return[{label:t("Cost"),value:"cost"},{label:t("Type"),value:"type"}]}getSearchHint(){return t("Search by class name")}getFetchUrl(){return"shipping/classes"}parseResponse(c){return c.shipping_classes}getTableName(){return"shipping_class_table"}getAdvanceFilterOptions(){return null}getSearchGuideOptions(){return[]}useFullWidthSearch(){return!0}}function ll(S){return tl.init(S)}const al={class:"shipping-classes-table"},sl={class:"fct-btn-group sm justify-end"},nl={__name:"ShippingClassesTable",props:{shipping_classes:{type:Array,required:!0},columns:{type:Array,default:()=>[]}},emits:["refresh"],setup(S,{emit:c}){const k=c,v=w(!1),r=w(!1),f=w(null),x=N=>{v.value=!0,j.delete(`/shipping/classes/${N}`).then(Z=>{P.success(Z.message),k("refresh")}).catch(Z=>{P.error(t("Failed to delete shipping class"))}).finally(()=>{v.value=!1})},b=N=>{f.value=N,r.value=!0},i=()=>{k("refresh")};return(N,Z)=>{const C=d("el-table-column"),D=d("el-popconfirm"),W=d("el-table"),B=ce("loading");return o(),m("div",al,[pe((o(),U(W,{data:S.shipping_classes,class:"w-full responsive"},{default:a(()=>[e(C,{prop:"name",label:l(t)("Class Name")},{default:a(V=>[z(u(V.row.name),1)]),_:1},8,["label"]),e(C,{prop:"cost",label:l(t)("Cost"),width:"150"},{default:a(V=>[z(u(V.row.cost)+u(V.row.type==="percentage"?"%":""),1)]),_:1},8,["label"]),e(C,{prop:"type",label:l(t)("Type"),width:"150"},{default:a(V=>[z(u(V.row.type==="fixed"?l(t)("Fixed Amount"):l(t)("Percentage")),1)]),_:1},8,["label"]),e(C,{prop:"per_item",label:l(t)("Per Item"),width:"150"},{default:a(V=>[z(u(V.row.per_item==1?l(t)("Yes"):l(t)("No")),1)]),_:1},8,["label"]),e(C,{label:l(t)("Actions"),width:"200",align:"right"},{default:a(V=>[g("div",sl,[e(de,{size:"small",onClick:y=>b(V.row),class:"cursor-pointer"},{default:a(()=>[e(ee,{name:"Edit"})]),_:2},1032,["onClick"]),e(D,{title:l(t)("Are you sure to delete this shipping class?"),onConfirm:y=>x(V.row.id),width:"220"},{reference:a(()=>[e(de,{size:"small",class:"cursor-pointer"},{default:a(()=>[e(ee,{name:"Delete"})]),_:1})]),_:2},1032,["title","onConfirm"])])]),_:1},8,["label"])]),_:1},8,["data"])),[[B,v.value]]),e(ze,{modelValue:r.value,"onUpdate:modelValue":Z[0]||(Z[0]=V=>r.value=V),"class-data":f.value,onSaved:i},null,8,["modelValue","class-data"])])}}},ol={class:"shipping-classes-loader"},il={class:"shipping-classes-table"},rl={class:"table-cell"},ul={class:"table-cell"},dl={class:"table-cell"},cl={class:"table-cell"},pl={__name:"ShippingClassesLoader",props:{shippingClassTable:{type:Object,required:!0},nextPageCount:{type:Array,default:()=>[1,2,3,4,5]}},setup(S){return(c,k)=>{const v=d("el-skeleton-item"),r=d("el-skeleton"),f=d("el-table-column"),x=d("el-table");return o(),m("div",ol,[g("div",il,[e(x,{data:[],class:"w-full compact-table responsive"},{default:a(()=>[e(f,{prop:"name",label:l(t)("Class Name")},{default:a(()=>[g("div",rl,[e(r,{animated:""},{template:a(()=>[e(v,{varient:"p",class:"w-[120px]"})]),_:1})])]),_:1},8,["label"]),e(f,{label:l(t)("Cost")},{default:a(()=>[g("div",ul,[e(r,{animated:""},{template:a(()=>[e(v,{varient:"p",class:"w-[80px]"})]),_:1})])]),_:1},8,["label"]),e(f,{label:l(t)("Type")},{default:a(()=>[g("div",dl,[e(r,{animated:""},{template:a(()=>[e(v,{varient:"p",class:"w-[100px]"})]),_:1})])]),_:1},8,["label"]),e(f,{label:l(t)("Actions"),width:"200",align:"right"},{default:a(()=>[g("div",cl,[e(r,{animated:""},{template:a(()=>[e(v,{varient:"p",class:"w-[80px]"})]),_:1})])]),_:1},8,["label"])]),_:1})])])}}},_l={class:"setting-wrap"},ml={class:"setting-wrap-inner"},gl={class:"fct-all-shipping-classes-wrap"},hl={key:1},fl={__name:"AllShippingClasses",setup(S){const c=ll(),k=w(!1),v=w(null),r=()=>{v.value=null,k.value=!0},f=()=>{c.fetch(),k.value=!1};return(x,b)=>(o(),m("div",_l,[e(_e,{heading:l(t)("Shipping Classes"),"save-button-text":l(t)("Add Shipping Class"),onOnSave:r},null,8,["heading","save-button-text"]),g("div",ml,[e(me),g("div",gl,[e(Ce,{table:l(c)},{default:a(()=>[l(c).isLoading()?(o(),U(pl,{key:0,shippingClassTable:l(c),"next-page-count":l(c).nextPageCount},null,8,["shippingClassTable","next-page-count"])):(o(),m("div",hl,[e(nl,{shipping_classes:l(c).getTableData(),columns:l(c).data.columns,onRefresh:b[0]||(b[0]=i=>l(c).fetch())},null,8,["shipping_classes","columns"])]))]),_:1},8,["table"])]),e(ze,{modelValue:k.value,"onUpdate:modelValue":b[1]||(b[1]=i=>k.value=i),"class-data":v.value,onSaved:f},null,8,["modelValue","class-data"])])]))}},vl={class:"single-shipping-zone-loader"},bl={class:"single-page-header flex items-center justify-between"},yl={class:"fct-page-header__actions"},wl={__name:"SingleShippingClassLoader",setup(S){return(c,k)=>{const v=d("el-skeleton-item"),r=d("el-skeleton"),f=d("el-breadcrumb-item"),x=d("el-breadcrumb");return o(),m("div",vl,[g("div",bl,[e(x,{"separator-icon":l(fe)},{default:a(()=>[e(f,null,{default:a(()=>[e(r,{animated:"",class:"h-4"},{template:a(()=>[e(v,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(r,{animated:"",class:"h-4"},{template:a(()=>[e(v,{variant:"p",class:"w-[90px] h-4"})]),_:1})]),_:1}),e(f,null,{default:a(()=>[e(r,{animated:"",class:"h-4"},{template:a(()=>[e(v,{variant:"p",class:"w-[60px] h-4"})]),_:1})]),_:1})]),_:1},8,["separator-icon"]),g("div",yl,[e(r,{animated:"",class:"h-9 w-[172px]"},{template:a(()=>[e(v,{variant:"p",class:"w-full h-9 rounded"})]),_:1})])]),e(l(oe),{class:"mb-4"},{default:a(()=>[e(l(re),{title:l(t)("Class Details"),border_bottom:"",title_size:"small"},null,8,["title"]),e(l(ne),null,{default:a(()=>[e(r,{rows:4,animated:!0})]),_:1})]),_:1})])}}},xl={class:"setting-wrap fct-single-shipping-class-page"},kl={class:"setting-wrap-inner"},Cl={key:0},Sl={key:2,class:"fct-single-shipping-class"},$l={class:"form-help-text w-full"},zl={class:"form-help-text"},Vl={key:0,class:"mt-4"},Tl={class:"text-gray-500 text-sm mb-3"},Al={key:0,class:"py-8"},Fl={key:1,class:"text-center py-4 text-gray-400"},Pl={key:2},Zl={class:"flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-gray-800"},Dl={class:"text-gray-500 ml-2"},Ml={class:"flex items-center gap-1"},El={class:"p-0"},xe={__name:"SingleShippingClass",props:{class_id:{type:[String,Number],required:!1}},setup(S){const c=Ie(),k=S,v=be();c.onSave(()=>{T()});const r=w(null),f=w(!1),x=w(!1),b=w({name:"",description:"",cost:0,type:"fixed"}),i=w(!1),N=w([]),Z=w(!1),C=w(!1),D=w(null),W=w({name:"",region:"all"}),B=$e,V=w({name:[{required:!0,message:t("Please enter a class name"),trigger:"blur"}],cost:[{required:!0,message:t("Please enter a cost"),trigger:"blur"}],type:[{required:!0,message:t("Please select a cost type"),trigger:"blur"}]}),y=w({show:!1,message:"",buttonText:"",route:""}),p=te(()=>!!k.class_id),E=()=>{if(!p.value){f.value=!1;return}f.value=!0,j.get(`/shipping/classes/${k.class_id}`).then(q=>{const s=q.shipping_class;b.value={name:s.name,description:s.description||"",cost:s.cost,type:s.type},s.zones&&(N.value=s.zones)}).catch(q=>{y.value={show:!0,message:t("The shipping class you are looking for does not exist or has been deleted."),buttonText:t("Go to Shipping Classes"),route:{name:"shipping_classes"}}}).finally(()=>{f.value=!1})},T=()=>{r.value.validate(q=>{if(!q)return;x.value=!0;const s=p.value?"put":"post",n=p.value?`/shipping/classes/${k.class_id}`:"/shipping/classes";j[s](n,b.value).then(h=>{P.success(h.message),p.value||v.push({name:"view_shipping_class",params:{class_id:h.shipping_class.id}})}).catch(h=>{P.error(t("Failed to save shipping class"))}).finally(()=>{x.value=!1})})},O=()=>{p.value&&(i.value=!0,j.get(`/shipping/classes/${k.class_id}/profile`).then(q=>{var s;N.value=((s=q.shipping_class)==null?void 0:s.zones)||[]}).catch(q=>{P.error(t("Failed to load shipping profile"))}).finally(()=>{i.value=!1}))},K=()=>{W.value={name:"",region:"all"},Z.value=!0},M=()=>{D.value.validate(q=>{q&&(C.value=!0,j.post("/shipping/zones",{...W.value,shipping_class_id:k.class_id}).then(s=>{P.success(s.message),Z.value=!1,O()}).catch(s=>{P.error(t("Failed to save shipping zone"))}).finally(()=>{C.value=!1}))})},H=q=>{j.delete(`/shipping/zones/${q}`).then(s=>{P.success(s.message),O()}).catch(s=>{P.error(t("Failed to delete shipping zone"))})};return he(()=>{E()}),(q,s)=>{const n=d("el-breadcrumb-item"),h=d("el-breadcrumb"),A=d("el-input"),$=d("el-form-item"),L=d("el-input-number"),G=d("el-option"),Q=d("el-select"),J=d("el-form"),X=d("el-button"),R=d("el-popconfirm"),le=d("el-drawer"),ae=ce("loading");return o(),m("div",xl,[e(_e,{"save-button-text":l(t)("Save Shipping Class"),"loading-text":l(t)("Saving Shipping Class"),loading:x.value,onOnSave:T},{heading:a(()=>[e(h,{"separator-icon":l(fe)},{default:a(()=>[e(n,{to:{name:"shipping_classes"}},{default:a(()=>[z(u(l(t)("Shipping Classes")),1)]),_:1}),e(n,null,{default:a(()=>[z(u(p.value?l(t)("Edit Shipping Class"):l(t)("Add Shipping Class")),1)]),_:1}),p.value?(o(),U(n,{key:0},{default:a(()=>[z(u(b.value.name),1)]),_:1})):I("",!0)]),_:1},8,["separator-icon"])]),_:1},8,["save-button-text","loading-text","loading"]),g("div",kl,[e(me),f.value?(o(),m("div",Cl,[e(wl)])):y.value.show?(o(),U(Ve,{key:1,message:y.value.message,"button-text":y.value.buttonText,route:y.value.route},null,8,["message","button-text","route"])):(o(),m("div",Sl,[e(l(oe),null,{default:a(()=>[e(l(re),{title:l(t)("Class Details"),border_bottom:"",title_size:"small"},null,8,["title"]),e(l(ne),null,{default:a(()=>[e(J,{model:b.value,rules:V.value,ref_key:"classFormRef",ref:r,"label-position":"top"},{default:a(()=>[e($,{label:l(t)("Class Name"),prop:"name"},{default:a(()=>[e(A,{modelValue:b.value.name,"onUpdate:modelValue":s[0]||(s[0]=F=>b.value.name=F),placeholder:l(t)("Enter class name")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),e($,{label:l(t)("Description")},{default:a(()=>[e(A,{modelValue:b.value.description,"onUpdate:modelValue":s[1]||(s[1]=F=>b.value.description=F),type:"textarea",rows:2,placeholder:l(t)("Enter description (optional)")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),e($,{label:l(t)("Cost"),prop:"cost"},{default:a(()=>[e(L,{modelValue:b.value.cost,"onUpdate:modelValue":s[2]||(s[2]=F=>b.value.cost=F),precision:2,min:0,step:1,class:"w-full max-w-[200px]"},null,8,["modelValue"]),g("div",$l,u(l(t)("Additional cost for products in this shipping class")),1)]),_:1},8,["label"]),e($,{label:l(t)("Cost Type"),prop:"type"},{default:a(()=>[e(Q,{modelValue:b.value.type,"onUpdate:modelValue":s[3]||(s[3]=F=>b.value.type=F),style:{width:"100%"}},{default:a(()=>[e(G,{label:l(t)("Fixed Amount"),value:"fixed"},null,8,["label"]),e(G,{label:l(t)("Percentage"),value:"percentage"},null,8,["label"])]),_:1},8,["modelValue"]),g("div",zl,u(l(t)("How this cost should be applied to the shipping rate")),1)]),_:1},8,["label"])]),_:1},8,["model","rules"])]),_:1})]),_:1}),p.value?(o(),m("div",Vl,[e(l(oe),null,{default:a(()=>[e(l(re),{title:l(t)("Shipping Profile"),border_bottom:"",title_size:"small"},{action:a(()=>[e(X,{type:"primary",size:"small",onClick:K},{default:a(()=>[z(u(l(t)("Add Zone")),1)]),_:1})]),_:1},8,["title"]),e(l(ne),null,{default:a(()=>[g("p",Tl,u(l(t)("Define shipping zones and methods specific to this class. Products with this class will use these rates instead of the general shipping zones.")),1),i.value?pe((o(),m("div",Al,null,512)),[[ae,!0]]):N.value.length===0?(o(),m("div",Fl,u(l(t)("No class-specific zones yet. Products in this class will use the general shipping zones.")),1)):(o(),m("div",Pl,[(o(!0),m(se,null,ie(N.value,F=>(o(),m("div",{key:F.id,class:"mb-4 border rounded-md overflow-hidden"},[g("div",Zl,[g("div",null,[g("strong",null,u(F.name),1),g("span",Dl,"("+u(F.formatted_region)+")",1)]),g("div",Ml,[e(R,{title:l(t)("Delete this zone and its methods?"),onConfirm:ye=>H(F.id)},{reference:a(()=>[e(X,{size:"small",type:"danger",text:""},{default:a(()=>[z(u(l(t)("Delete Zone")),1)]),_:1})]),_:2},1032,["title","onConfirm"])])]),g("div",El,[e(Te,{zone_id:F.id,methods:F.methods||[],country:F.region,onFetchShippingMethods:O},null,8,["zone_id","methods","country"])])]))),128))]))]),_:1})]),_:1})])):I("",!0),e(le,{modelValue:Z.value,"onUpdate:modelValue":s[7]||(s[7]=F=>Z.value=F),title:l(t)("Add Zone to Shipping Class"),"aria-label":l(t)("Add Zone to Shipping Class"),width:"500px","append-to-body":""},{footer:a(()=>[e(X,{onClick:s[6]||(s[6]=F=>Z.value=!1)},{default:a(()=>[z(u(l(t)("Cancel")),1)]),_:1}),e(X,{type:"primary",onClick:M,loading:C.value,disabled:C.value},{default:a(()=>[z(u(l(t)("Save")),1)]),_:1},8,["loading","disabled"])]),default:a(()=>[e(J,{model:W.value,ref_key:"zoneFormRef",ref:D,"label-position":"top"},{default:a(()=>[e($,{label:l(t)("Zone Name"),prop:"name",rules:[{required:!0,message:l(t)("Zone name is required"),trigger:"blur"}]},{default:a(()=>[e(A,{modelValue:W.value.name,"onUpdate:modelValue":s[4]||(s[4]=F=>W.value.name=F),placeholder:l(t)("Enter zone name")},null,8,["modelValue","placeholder"])]),_:1},8,["label","rules"]),e($,{label:l(t)("Region")},{default:a(()=>[e(Q,{modelValue:W.value.region,"onUpdate:modelValue":s[5]||(s[5]=F=>W.value.region=F),filterable:"",placeholder:l(t)("Select country or Whole World")},{default:a(()=>[e(G,{label:l(t)("Whole World"),value:"all"},null,8,["label"]),(o(!0),m(se,null,ie(l(B),F=>(o(),U(G,{key:F.code2,label:F.name,value:F.code2},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1},8,["model"])]),_:1},8,["modelValue","title","aria-label"])]))])])}}},Ul={class:"setting-wrap"},Nl={class:"setting-wrap-inner"},Rl={class:"fct-packages-list"},Ol={key:0,class:"fct-packages-empty"},ql={class:"text-gray-500"},Wl={key:1,class:"fct-packages-empty"},Il={class:"text-gray-500"},Bl={key:2,class:"fct-packages-cards"},Ll={class:"fct-package-card-left"},jl={class:"fct-package-card-icon"},Hl={class:"fct-package-card-info"},Jl={class:"fct-package-card-name"},Kl={class:"fct-package-card-dims"},Gl={class:"fct-package-card-right"},Ql={__name:"AllShippingPackages",setup(S){const c=w([]),k=w(!1),v=w(!1),r=w(!1),f=w(null),x=w(!1),b={box:"Box",envelope:"Envelope",soft_package:"SoftPackage"},i=()=>{k.value=!0,v.value=!1,j.get("shipping/packages").then(p=>{c.value=p.packages||[]}).catch(p=>{v.value=!0,P.error(t("Failed to load packages"))}).finally(()=>{k.value=!1})},N=p=>x.value?Promise.resolve():(x.value=!0,j.post("shipping/packages",{packages:c.value}).then(E=>{c.value=E.packages||c.value,r.value=!1,P.success(E.message)}).catch(E=>{p&&(c.value=p),P.error(t("Failed to save packages"))}).finally(()=>{x.value=!1})),Z=()=>{v.value||x.value||(f.value=null,r.value=!0)},C=p=>{x.value||(f.value={...p},r.value=!0)},D=p=>{const E=JSON.parse(JSON.stringify(c.value));if(p.is_default&&c.value.forEach(T=>{T.is_default=!1}),f.value){const T=c.value.findIndex(O=>O.slug===f.value.slug);T!==-1&&(c.value[T]=p)}else{let T=p.slug,O=1;for(;c.value.some(K=>K.slug===T);)T=p.slug+"-"+O,O++;p.slug=T,c.value.push(p)}N(E)},W=p=>{if(x.value)return;const E=JSON.parse(JSON.stringify(c.value));c.value.forEach(T=>{T.is_default=T.slug===p.slug}),N(E)},B=p=>{x.value||We.confirm(t("Are you sure you want to delete this package?"),t("Delete Package"),{confirmButtonText:t("Delete"),cancelButtonText:t("Cancel"),type:"warning"}).then(()=>{const E=JSON.parse(JSON.stringify(c.value)),T=c.value.findIndex(O=>O.slug===p.slug);T!==-1&&(c.value.splice(T,1),N(E))}).catch(()=>{})},V=p=>p.type==="envelope"?p.length+" × "+p.width+" "+p.dimension_unit:p.length+" × "+p.width+" × "+p.height+" "+p.dimension_unit,y=p=>p.weight+" "+p.weight_unit;return he(()=>{i()}),(p,E)=>{const T=d("el-button"),O=d("el-tag"),K=d("el-dropdown-item"),M=d("el-dropdown-menu"),H=d("el-dropdown"),q=ce("loading");return o(),m("div",Ul,[e(_e,{heading:l(t)("Packages"),"save-button-text":l(t)("Add Package"),onOnSave:Z},null,8,["heading","save-button-text"]),g("div",Nl,[e(me),pe((o(),m("div",Rl,[v.value&&!k.value?(o(),m("div",Ol,[g("p",ql,u(l(t)("Failed to load packages.")),1),e(T,{type:"primary",size:"small",class:"mt-3",onClick:i},{default:a(()=>[z(u(l(t)("Retry")),1)]),_:1})])):c.value.length===0&&!k.value?(o(),m("div",Wl,[g("p",Il,u(l(t)("No packages defined yet. Add a package to define how your products are packaged for shipping.")),1)])):(o(),m("div",Bl,[(o(!0),m(se,null,ie(c.value,s=>(o(),m("div",{key:s.slug,class:"fct-package-card"},[g("div",Ll,[g("span",jl,[e(ee,{name:b[s.type]||"Box"},null,8,["name"])]),g("div",Hl,[g("div",Jl,u(s.name),1),g("div",Kl,u(V(s))+", "+u(y(s)),1)])]),g("div",Gl,[s.is_default?(o(),U(O,{key:0,type:"info",size:"small",effect:"plain"},{default:a(()=>[z(u(l(t)("Store default")),1)]),_:1})):I("",!0),e(H,{class:"fct-more-option-wrap","popper-class":"fct-dropdown",trigger:"click",onCommand:n=>{n==="edit"?C(s):n==="default"?W(s):n==="delete"&&B(s)}},{dropdown:a(()=>[e(M,null,{default:a(()=>[e(K,{command:"edit"},{default:a(()=>[z(u(l(t)("Edit")),1)]),_:1}),s.is_default?I("",!0):(o(),U(K,{key:0,command:"default"},{default:a(()=>[z(u(l(t)("Set as default")),1)]),_:1})),e(K,{command:"delete",class:"item-destructive"},{default:a(()=>[z(u(l(t)("Delete")),1)]),_:1})]),_:2},1024)]),default:a(()=>[e(T,{class:"more-btn","aria-label":l(t)("Package actions")},{default:a(()=>[e(ee,{name:"More"})]),_:1},8,["aria-label"])]),_:2},1032,["onCommand"])])]))),128))]))])),[[q,k.value]]),e(qe,{modelValue:r.value,"onUpdate:modelValue":E[0]||(E[0]=s=>r.value=s),"edit-data":f.value,saving:x.value,onSave:D},null,8,["modelValue","edit-data","saving"])])])}}};window.fluent_cart_admin.hooks.addFilter("fluent_cart_routes","fluent_shipping",function(S){return S.settings&&S.settings.children&&S.settings.children.push({name:"shipping",path:"shipping",component:_t,meta:{active_menu:"shipping",title:t("Shipping Zones"),permission:["store/settings","store/sensitive"]}},{name:"view_shipping_zone",path:"shipping/zone/:zone_id/edit",component:we,props:!0,meta:{active_menu:"settings",title:t("Edit Shipping Zone"),permission:["store/settings","store/sensitive"]}},{name:"add_shipping_zone",path:"shipping/zone/add",component:we,meta:{active_menu:"settings",title:t("Add Shipping Zone"),permission:["store/settings","store/sensitive"]}},{name:"shipping_classes",path:"shipping/shipping_classes",component:fl,meta:{active_menu:"settings",title:t("Shipping Classes"),permission:["store/settings","store/sensitive"]}},{name:"view_shipping_class",path:"shipping/shipping_classes/:class_id/edit",component:xe,props:!0,meta:{active_menu:"settings",title:t("Edit Shipping Class"),permission:["store/settings","store/sensitive"]}},{name:"add_shipping_class",path:"shipping/shipping_classes/add",component:xe,meta:{active_menu:"settings",title:t("Add Shipping Class"),permission:["store/settings","store/sensitive"]}},{name:"shipping_packages",path:"shipping/packages",component:Ql,meta:{active_menu:"settings",title:t("Packages"),permission:["store/settings","store/sensitive"]}}),S});