const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DateTimeType-BToBwsJ9.js","assets/vue.runtime.esm-bundler-DAWRyTnP.js","assets/moment-DiFv0SGL.js","assets/DateType-FQ5j8Etm.js","assets/DropdownType-SEp6omm1.js","assets/InputType-DwLyKiT2.js","assets/NumberType-C31Mz-tP.js","assets/PhoneType-DTy7bIz3.js","assets/SwitchType-DhrsZDd_.js","assets/TextAreaType-B5txDcIt.js","assets/TimeType-DrGlWMBR.js","assets/UrlType-Ba_5jX4v.js"])))=>i.map(i=>d[i]);
import{$ as e,C as t,G as n,U as r,Z as i,Zt as a,_ as o,d as s,h as c,q as l,v as u,vt as d,w as f,y as p,z as m}from"./vue.runtime.esm-bundler-DAWRyTnP.js";import{t as h}from"./lodash-B1UAWAaQ.js";import{t as g}from"./preload-helper-BHEY2iq7.js";import{n as _}from"./vue-i18n-C4HYJWrq.js";import{t as v}from"./moment-DiFv0SGL.js";import{Mn as y,Q as b,W as x,nt as S,t as C}from"./main-CgSmSYZA.js";var w={__name:`CreateCustomFieldsSingle`,props:{field:{type:Object,required:!0},customFieldScope:{type:String,required:!0},index:{type:Number,required:!0},store:{type:Object,required:!0},storeProp:{type:String,required:!0}},setup(t){let r=t,{t:i}=_(),a=y({value:{required:x.withMessage(i(`validation.required`),b(r.field.is_required))}},c(()=>r.field),{$scope:r.customFieldScope}),s=c(()=>r.field.type?f(()=>C(Object.assign({"./types/DateTimeType.vue":()=>g(()=>import(`./DateTimeType-BToBwsJ9.js`),__vite__mapDeps([0,1,2])),"./types/DateType.vue":()=>g(()=>import(`./DateType-FQ5j8Etm.js`),__vite__mapDeps([3,1,2])),"./types/DropdownType.vue":()=>g(()=>import(`./DropdownType-SEp6omm1.js`),__vite__mapDeps([4,1])),"./types/InputType.vue":()=>g(()=>import(`./InputType-DwLyKiT2.js`),__vite__mapDeps([5,1])),"./types/NumberType.vue":()=>g(()=>import(`./NumberType-C31Mz-tP.js`),__vite__mapDeps([6,1])),"./types/PhoneType.vue":()=>g(()=>import(`./PhoneType-DTy7bIz3.js`),__vite__mapDeps([7,1])),"./types/SwitchType.vue":()=>g(()=>import(`./SwitchType-DhrsZDd_.js`),__vite__mapDeps([8,1])),"./types/TextAreaType.vue":()=>g(()=>import(`./TextAreaType-B5txDcIt.js`),__vite__mapDeps([9,1])),"./types/TimeType.vue":()=>g(()=>import(`./TimeType-DrGlWMBR.js`),__vite__mapDeps([10,1,2])),"./types/UrlType.vue":()=>g(()=>import(`./UrlType-Ba_5jX4v.js`),__vite__mapDeps([11,1]))}),`./types/${r.field.type}Type.vue`,3)):!1);return(r,i)=>{let c=n(`BaseInputGroup`);return m(),o(c,{label:t.field.label,required:!!t.field.is_required,error:d(a).value.$error&&d(a).value.$errors[0].$message},{default:e(()=>[(m(),o(l(s.value),{modelValue:t.field.value,"onUpdate:modelValue":i[0]||=e=>t.field.value=e,options:t.field.options,invalid:d(a).value.$error,placeholder:t.field.placeholder},null,8,[`modelValue`,`options`,`invalid`,`placeholder`]))]),_:1},8,[`label`,`required`,`error`])}}},T=a(h()),E={key:0},D={__name:`CreateCustomFields`,props:{store:{type:Object,required:!0},storeProp:{type:String,required:!0},isEdit:{type:Boolean,default:!1},type:{type:String,default:null},gridLayout:{type:String,default:`two-column`},isLoading:{type:Boolean,default:null},customFieldScope:{type:String,required:!0}},setup(a){let c=S(),l=a;f();function d(){l.isEdit&&l.store[l.storeProp].fields.forEach(e=>{let t=l.store[l.storeProp].customFields.findIndex(t=>t.id===e.custom_field_id);if(t>-1){let n=e.default_answer;n&&e.custom_field.type===`DateTime`&&(n=v(e.default_answer,`YYYY-MM-DD HH:mm:ss`).format(`YYYY-MM-DD HH:mm`)),l.store[l.storeProp].customFields[t]={...e,id:e.custom_field_id,value:n,label:e.custom_field.label,options:e.custom_field.options,is_required:e.custom_field.is_required,placeholder:e.custom_field.placeholder,order:e.custom_field.order}}})}async function f(){let e=(await c.fetchCustomFields({type:l.type,limit:`all`})).data.data;e.map(e=>e.value=e.default_answer),l.store[l.storeProp].customFields=T.default.sortBy(e,e=>e.order),d()}return i(()=>l.store[l.storeProp].fields,e=>{d()}),(i,c)=>{let l=n(`BaseInputGrid`);return a.store[a.storeProp]&&a.store[a.storeProp].customFields.length>0&&!a.isLoading?(m(),p(`div`,E,[t(l,{layout:a.gridLayout},{default:e(()=>[(m(!0),p(s,null,r(a.store[a.storeProp].customFields,(e,t)=>(m(),o(w,{key:e.id,"custom-field-scope":a.customFieldScope,store:a.store,"store-prop":a.storeProp,index:t,field:e},null,8,[`custom-field-scope`,`store`,`store-prop`,`index`,`field`]))),128))]),_:1},8,[`layout`])])):u(``,!0)}}};export{D as t};