import{h as o,i as F,e as u,o as s,d as n,b as N,a as i,u as f,c as j,F as L,g as R,t as x}from"./vue.esm-bundler.js?ver=1.3.20";import{R as w}from"./Rest.js?ver=1.3.20";import{t as r}from"./Translator.js?ver=1.3.20";import{c as A,a as m}from"./CopyToClipboard.js?ver=1.3.20";import"./Arr.js?ver=1.3.20";import"./Animation.js?ver=1.3.20";import"./_plugin-vue_export-helper.js?ver=1.3.20";import"./Badge.js?ver=1.3.20";import"./DynamicIcon.js?ver=1.3.20";import"./Str.js?ver=1.3.20";import"./Notify.js?ver=1.3.20";import"./index.js?ver=1.3.20";const I={class:"fct-global-address-component"},P={class:"setting-fields-inner country"},Z={key:0},$={class:"grid lg:grid-cols-2"},p={class:"setting-fields-inner city"},z={class:"setting-fields-inner postcode"},D={key:1},te={__name:"AddressComponent",props:{name:{type:String,required:!0},field:{type:Object},fieldKey:{type:String},value:{required:!0},variant:{type:String},nesting:{type:Boolean,default:!1},statePath:{type:String},form:{type:Object,required:!0},callback:{type:Function,required:!0},label:{type:String},attribute:{required:!0}},setup(l){const V=l,g=o([]),E=()=>{w.get("address-info/countries").then(t=>{g.value=t.data}).catch(t=>{}).finally(()=>{})},v=o({}),d=o(!1),S=o(!0),k=o(!0),h=o(r("Zip Code")),c=o(r("State")),U=t=>{if(d.value=!0,!t){d.value=!1;return}if(v.value[t]){O(v.value[t]),d.value=!1;return}w.get("address-info/get-country-info",{country_code:t}).then(e=>{v.value[t]=e,O(e)}).catch(e=>{console.log(e,"errors")}).finally(()=>{d.value=!1})},y=o([]),O=t=>{var e,a,b,q,B,C;y.value=(t==null?void 0:t.states)||[],k.value=((a=(e=t==null?void 0:t.address_locale)==null?void 0:e.state)==null?void 0:a.hidden)!==!0,S.value=y.value.length>1,h.value=((q=(b=t==null?void 0:t.address_locale)==null?void 0:b.postcode)==null?void 0:q.label)||r("Zip Code"),c.value=((C=(B=t==null?void 0:t.address_locale)==null?void 0:B.state)==null?void 0:C.label)||r("State")};return F(()=>{E(),V.form.data.values.store_country&&U(V.form.data.values.store_country)}),(t,e)=>(s(),u("div",I,[n("div",P,[i(A,{modelValue:l.form.data.values.store_country,"onUpdate:modelValue":e[0]||(e[0]=a=>l.form.data.values.store_country=a),label:f(r)("Select Country"),filterable:"",options:g.value,onOnChange:e[1]||(e[1]=a=>{l.form.data.values.store_state="",U(a)})},null,8,["modelValue","label","options"])]),!d.value&&k.value?(s(),u("div",Z,[S.value?(s(),j(A,{key:0,modelValue:l.form.data.values.store_state,"onUpdate:modelValue":e[2]||(e[2]=a=>l.form.data.values.store_state=a),label:c.value,filterable:"",options:y.value},null,8,["modelValue","label","options"])):(s(),j(m,{key:1,id:"store_state",modelValue:l.form.data.values.store_state,"onUpdate:modelValue":e[3]||(e[3]=a=>l.form.data.values.store_state=a),label:c.value},null,8,["modelValue","label"]))])):N("",!0),i(m,{modelValue:l.form.data.values.store_address1,"onUpdate:modelValue":e[4]||(e[4]=a=>l.form.data.values.store_address1=a),label:f(r)("Street address")},null,8,["modelValue","label"]),i(m,{modelValue:l.form.data.values.store_address2,"onUpdate:modelValue":e[5]||(e[5]=a=>l.form.data.values.store_address2=a),label:f(r)("Apt, suite, unit")},null,8,["modelValue","label"]),n("div",$,[n("div",p,[i(m,{modelValue:l.form.data.values.store_city,"onUpdate:modelValue":e[6]||(e[6]=a=>l.form.data.values.store_city=a),label:f(r)("City/Town")},null,8,["modelValue","label"])]),n("div",z,[i(m,{modelValue:l.form.data.values.store_postcode,"onUpdate:modelValue":e[7]||(e[7]=a=>l.form.data.values.store_postcode=a),label:h.value},null,8,["modelValue","label"])])]),l.form.data.validationErrors.hasOwnProperty("store_country")?(s(),u("div",D,[(s(!0),u(L,null,R(l.form.data.validationErrors,(a,b)=>(s(),u("span",{class:"fluent-cart-admin-validation-error",key:a},[n("span",null,x(Object.values(a)[0]),1)]))),128))])):N("",!0)]))}};export{te as default};
