import{d as q,t as B,I as K,r as C,n as O,o as r,c as D,N as P,h as S,w as _,e as U,_ as A,R as E,u as N,U as L,S as T,M as W,V as k}from"./index.DXvi0yH9.js";import{s as $}from"./pinia.D9yoqqEz.js";import{u as z}from"./settings-store.BEthvEFu.js";const X=q({__name:"DynamicComponents",props:{sectionParent:{type:String,required:!0},sectionChild:{type:String,required:!0},sectionKey:{type:String,required:!0}},emits:["fieldData"],setup(V,{emit:b}){const F=V,{sectionParent:d,sectionChild:c,sectionKey:M}=B(F),R=z(),{inputValues:e}=$(R),f=K.settings;let y=null;typeof f.controls[d.value][c.value]<"u"&&f.controls[d.value][c.value]!==null&&(y=f.controls[d.value][c.value][M.value]);const l=C(y),i=O({controls:l.value}),v=b,p=C([]);typeof l.value<"u"&&l.value!==null&&(i.controls=l.value.filter(t=>typeof t.hide<"u"&&t.hide?!1:(typeof e.value[t.id]<"u"&&(t.default=e.value[t.id]),!0)));const w=t=>{Object.entries(t).forEach(([n,o])=>{e.value[n]=o}),v("fieldData",e.value)},x=(t,n)=>{const o=t;n.type==="checkbox"&&(o.target.value=o.target.checked),e.value[n.id]=o.target.value,v("fieldData",e.value)},h=t=>{let n="",o="";for(const[a,u]of Object.entries(t)){let s=u;n=a,o=s}p.value[n]=o,e.value[n]=o,i.controls=l.value.filter(a=>typeof a.condition<"u"?a.condition.some(s=>k(s,e.value,l.value,p.value)===s.value)?(typeof e.value[a.id]<"u"&&(a.default=e.value[a.id]),!0):!1:(typeof e.value[a.id]<"u"&&(a.default=e.value[a.id]),!0)),v("fieldData",e.value)},g=t=>{i.controls=l.value.filter(n=>typeof n.condition<"u"&&Array.isArray(n.condition)?n.condition.some(a=>a&&typeof a.key<"u"?k(a,e.value,l.value)===a.value:!1)?(typeof e.value[n.id]<"u"&&e.value[n.id]!==null&&(n.default=e.value[n.id]),!0):!1:(typeof e.value[n.id]<"u"&&e.value[n.id]!==null&&(n.default=e.value[n.id]),!0))},j=t=>{g()};return(t,n)=>(r(!0),D(W,null,P(i.controls,(o,a)=>(r(),D("div",{key:o.id},[(r(),S(T,null,{fallback:_(()=>[U(A)]),default:_(()=>[(r(),S(E(N(L)(o.type)),{params:o,"control-settings":i.controls,"conditional-values":p.value,onInput:u=>x(u,o),onFieldData:w,onConditionalData:h,onSelectedCondition:h,onFieldUpdatedData:g,onPreviewRef:j},null,40,["params","control-settings","conditional-values","onInput"]))]),_:2},1024))]))),128))}});export{X as _};
