import{d as B,r as U,aT as o,W as i,a3 as _,bK as y,Q as m,u as r,a2 as $,bh as k,U as c,F as x,b2 as C,bP as E,O as d}from"./vendor-reka-Edfq1EPl.js";import{useForm as T}from"./vendor/inertia-CR4tWtMT.js";import{n as N,g as O,d as j}from"./registry-DyIszw9-.js";import{_ as g}from"./DynamicField.vue_vue_type_script_setup_true_lang-DYH52Q2k.js";import{_ as w}from"./PageHeader.vue_vue_type_script_setup_true_lang-Cr1rE6nR.js";import{_ as P}from"./HorizontalTabNavigation.vue_vue_type_script_setup_true_lang-CsRrMj9y.js";import"./Input.vue_vue_type_script_setup_true_lang-D6nVx0lb.js";import"./LocaleSwitcher.vue_vue_type_script_setup_true_lang-4M-c0Clb.js";const H={key:0,class:"-mx-6 px-6 border-b"},I={key:1,class:"py-6 space-y-4"},K={key:0,class:"text-sm text-muted-foreground"},R=B({__name:"Index",props:{accountDefinition:{},user:{},mfaEnabled:{type:Boolean},recoveryCodes:{}},setup(p){var b;const{t:f}=N(),D=O(),l=p,v=d(()=>l.accountDefinition.sections.flatMap(t=>t.fields).filter(t=>t.component!=="MfaSettings")),V=Object.fromEntries(v.value.map(t=>[t.name,l.user[t.name]??t.default])),a=T(V),u=U(((b=l.accountDefinition.sections[0])==null?void 0:b.key)??"profile"),n=d(()=>l.accountDefinition.sections.find(t=>t.key===u.value)),F=d(()=>l.accountDefinition.sections.length>1);function S(t){return t.fields.some(s=>s.component!=="MfaSettings")}function h(){const t=a;a.optimistic(s=>({user:{...s.user,...Object.fromEntries(v.value.map(e=>[e.name,t[e.name]]))}})).put(`/${D}/account`)}return(t,s)=>(o(),i("form",{onSubmit:E(h,["prevent"])},[_(w,{title:r(f)("builder.account.title")},{actions:y(()=>[n.value&&S(n.value)?(o(),m(j,{key:0,type:"submit",disabled:r(a).processing},{default:y(()=>[$(k(r(f)("builder.account.save")),1)]),_:1},8,["disabled"])):c("",!0)]),_:1},8,["title"]),F.value?(o(),i("div",H,[_(P,{modelValue:u.value,"onUpdate:modelValue":s[0]||(s[0]=e=>u.value=e),tabs:p.accountDefinition.sections.map(e=>({key:e.key,label:e.label}))},null,8,["modelValue","tabs"])])):c("",!0),n.value?(o(),i("div",I,[n.value.description?(o(),i("p",K,k(n.value.description),1)):c("",!0),(o(!0),i(x,null,C(n.value.fields,e=>(o(),i(x,{key:e.name},[e.component!=="MfaSettings"?(o(),m(g,{key:0,field:e,"model-value":r(a)[e.name],error:r(a).errors[e.name],"onUpdate:modelValue":M=>r(a)[e.name]=M},null,8,["field","model-value","error","onUpdate:modelValue"])):(o(),m(g,{key:1,field:e,"model-value":void 0,"onUpdate:modelValue":()=>{}},null,8,["field"]))],64))),128))])):c("",!0)],32))}});export{R as default};
