iq-line-form-builder-renderer 1.2.21 → 1.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- (function(ue,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react"),require("react/jsx-runtime"),require("react-router-dom"),require("react-dom"),require("sonner"),require("@tanstack/react-query")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-router-dom","react-dom","sonner","@tanstack/react-query"],v):(ue=typeof globalThis<"u"?globalThis:ue||self,v(ue.FormBuilderRenderer={},ue.React,ue.jsxRuntime,ue.ReactRouterDOM,ue.ReactDOM,ue.Sonner,ue.ReactQuery))})(this,(function(ue,v,d,Ba,Nd,ct,Nn){"use strict";function kd(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const b=kd(v),js=kd(Nd),$a="iq-fbr",Hn="95px";function zs(e){return!e||typeof e.columns!="number"?null:{rows:e.rows??8,columns:e.columns,verticalSpacing:e.verticalSpacing||e.spacing||"16px",horizontalSpacing:e.horizontalSpacing||e.spacing||"16px",rowHeight:Hn}}function Us(e,t){if(t!=null&&t!==void 0)return t;const r=e.config;if(r?.grid&&typeof r.grid.rows=="number"&&typeof r.grid.columns=="number")return{rows:r.grid.rows,columns:r.grid.columns,verticalSpacing:r.grid.verticalSpacing??r.grid.spacing,horizontalSpacing:r.grid.horizontalSpacing??r.grid.spacing,rowHeight:r.grid.rowHeight,spacing:r.grid.spacing};const n=r?.layout!=null&&typeof r.layout=="object"?r.layout:null;if(n&&typeof n.rows=="number"&&typeof n.columns=="number")return{rows:n.rows,columns:n.columns,verticalSpacing:n.verticalSpacing??n.spacing,horizontalSpacing:n.horizontalSpacing??n.spacing,rowHeight:n.rowHeight,spacing:n.spacing};const o=e.layout;if(o!=null&&typeof o=="object"&&typeof o.rows=="number"&&typeof o.columns=="number"){const s=o;return{rows:s.rows,columns:s.columns,verticalSpacing:s.verticalSpacing??s.spacing,horizontalSpacing:s.horizontalSpacing??s.spacing,rowHeight:s.rowHeight,spacing:s.spacing}}return null}function _d(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(r=_d(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Td(){for(var e,t,r=0,n="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=_d(e))&&(n&&(n+=" "),n+=t);return n}const qb=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},Yb=(e,t)=>({classGroupId:e,validator:t}),Fd=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Vs="-",Pd=[],Xb="arbitrary..",Jb=e=>{const t=Zb(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Qb(i);const a=i.split(Vs),c=a[0]===""&&a.length>1?1:0;return Od(a,c,t)},getConflictingClassGroupIds:(i,a)=>{if(a){const c=n[i],u=r[i];return c?u?qb(u,c):c:u||Pd}return r[i]||Pd}}},Od=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const o=e[t],s=r.nextPart.get(o);if(s){const u=Od(e,t+1,s);if(u)return u}const i=r.validators;if(i===null)return;const a=t===0?e.join(Vs):e.slice(t).join(Vs),c=i.length;for(let u=0;u<c;u++){const f=i[u];if(f.validator(a))return f.classGroupId}},Qb=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?Xb+n:void 0})(),Zb=e=>{const{theme:t,classGroups:r}=e;return ev(r,t)},ev=(e,t)=>{const r=Fd();for(const n in e){const o=e[n];ja(o,r,n,t)}return r},ja=(e,t,r,n)=>{const o=e.length;for(let s=0;s<o;s++){const i=e[s];tv(i,t,r,n)}},tv=(e,t,r,n)=>{if(typeof e=="string"){rv(e,t,r);return}if(typeof e=="function"){nv(e,t,r,n);return}ov(e,t,r,n)},rv=(e,t,r)=>{const n=e===""?t:Id(t,e);n.classGroupId=r},nv=(e,t,r,n)=>{if(sv(e)){ja(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(Yb(r,e))},ov=(e,t,r,n)=>{const o=Object.entries(e),s=o.length;for(let i=0;i<s;i++){const[a,c]=o[i];ja(c,Id(t,a),r,n)}},Id=(e,t)=>{let r=e;const n=t.split(Vs),o=n.length;for(let s=0;s<o;s++){const i=n[s];let a=r.nextPart.get(i);a||(a=Fd(),r.nextPart.set(i,a)),r=a}return r},sv=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,iv=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const o=(s,i)=>{r[s]=i,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(s){let i=r[s];if(i!==void 0)return i;if((i=n[s])!==void 0)return o(s,i),i},set(s,i){s in r?r[s]=i:o(s,i)}}},za="!",Md=":",av=[],Ld=(e,t,r,n,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:o}),lv=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=o=>{const s=[];let i=0,a=0,c=0,u;const f=o.length;for(let h=0;h<f;h++){const y=o[h];if(i===0&&a===0){if(y===Md){s.push(o.slice(c,h)),c=h+1;continue}if(y==="/"){u=h;continue}}y==="["?i++:y==="]"?i--:y==="("?a++:y===")"&&a--}const l=s.length===0?o:o.slice(c);let p=l,g=!1;l.endsWith(za)?(p=l.slice(0,-1),g=!0):l.startsWith(za)&&(p=l.slice(1),g=!0);const m=u&&u>c?u-c:void 0;return Ld(s,g,p,m)};if(t){const o=t+Md,s=n;n=i=>i.startsWith(o)?s(i.slice(o.length)):Ld(av,!1,i,void 0,!0)}if(r){const o=n;n=s=>r({className:s,parseClassName:o})}return n},cv=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let o=[];for(let s=0;s<r.length;s++){const i=r[s],a=i[0]==="[",c=t.has(i);a||c?(o.length>0&&(o.sort(),n.push(...o),o=[]),n.push(i)):o.push(i)}return o.length>0&&(o.sort(),n.push(...o)),n}},dv=e=>({cache:iv(e.cacheSize),parseClassName:lv(e),sortModifiers:cv(e),...Jb(e)}),uv=/\s+/,fv=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:o,sortModifiers:s}=t,i=[],a=e.trim().split(uv);let c="";for(let u=a.length-1;u>=0;u-=1){const f=a[u],{isExternal:l,modifiers:p,hasImportantModifier:g,baseClassName:m,maybePostfixModifierPosition:h}=r(f);if(l){c=f+(c.length>0?" "+c:c);continue}let y=!!h,S=n(y?m.substring(0,h):m);if(!S){if(!y){c=f+(c.length>0?" "+c:c);continue}if(S=n(m),!S){c=f+(c.length>0?" "+c:c);continue}y=!1}const w=p.length===0?"":p.length===1?p[0]:s(p).join(":"),A=g?w+za:w,x=A+S;if(i.indexOf(x)>-1)continue;i.push(x);const F=o(S,y);for(let N=0;N<F.length;++N){const k=F[N];i.push(A+k)}c=f+(c.length>0?" "+c:c)}return c},pv=(...e)=>{let t=0,r,n,o="";for(;t<e.length;)(r=e[t++])&&(n=Dd(r))&&(o&&(o+=" "),o+=n);return o},Dd=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=Dd(e[n]))&&(r&&(r+=" "),r+=t);return r},mv=(e,...t)=>{let r,n,o,s;const i=c=>{const u=t.reduce((f,l)=>l(f),e());return r=dv(u),n=r.cache.get,o=r.cache.set,s=a,a(c)},a=c=>{const u=n(c);if(u)return u;const f=fv(c,r);return o(c,f),f};return s=i,(...c)=>s(pv(...c))},hv=[],Kt=e=>{const t=r=>r[e]||hv;return t.isThemeGetter=!0,t},Bd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,$d=/^\((?:(\w[\w-]*):)?(.+)\)$/i,gv=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,yv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,bv=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,vv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,wv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Sv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,kn=e=>gv.test(e),ot=e=>!!e&&!Number.isNaN(Number(e)),_n=e=>!!e&&Number.isInteger(Number(e)),Ua=e=>e.endsWith("%")&&ot(e.slice(0,-1)),pn=e=>yv.test(e),jd=()=>!0,xv=e=>bv.test(e)&&!vv.test(e),Va=()=>!1,Av=e=>wv.test(e),Cv=e=>Sv.test(e),Ev=e=>!Fe(e)&&!Pe(e),Nv=e=>Tn(e,Rd,Va),Fe=e=>Bd.test(e),Wn=e=>Tn(e,Gd,xv),zd=e=>Tn(e,Mv,ot),kv=e=>Tn(e,qd,jd),_v=e=>Tn(e,Kd,Va),Ud=e=>Tn(e,Hd,Va),Tv=e=>Tn(e,Wd,Cv),Hs=e=>Tn(e,Yd,Av),Pe=e=>$d.test(e),Ko=e=>Rn(e,Gd),Fv=e=>Rn(e,Kd),Vd=e=>Rn(e,Hd),Pv=e=>Rn(e,Rd),Ov=e=>Rn(e,Wd),Ws=e=>Rn(e,Yd,!0),Iv=e=>Rn(e,qd,!0),Tn=(e,t,r)=>{const n=Bd.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Rn=(e,t,r=!1)=>{const n=$d.exec(e);return n?n[1]?t(n[1]):r:!1},Hd=e=>e==="position"||e==="percentage",Wd=e=>e==="image"||e==="url",Rd=e=>e==="length"||e==="size"||e==="bg-size",Gd=e=>e==="length",Mv=e=>e==="number",Kd=e=>e==="family-name",qd=e=>e==="number"||e==="weight",Yd=e=>e==="shadow",Lv=mv(()=>{const e=Kt("color"),t=Kt("font"),r=Kt("text"),n=Kt("font-weight"),o=Kt("tracking"),s=Kt("leading"),i=Kt("breakpoint"),a=Kt("container"),c=Kt("spacing"),u=Kt("radius"),f=Kt("shadow"),l=Kt("inset-shadow"),p=Kt("text-shadow"),g=Kt("drop-shadow"),m=Kt("blur"),h=Kt("perspective"),y=Kt("aspect"),S=Kt("ease"),w=Kt("animate"),A=()=>["auto","avoid","all","avoid-page","page","left","right","column"],x=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],F=()=>[...x(),Pe,Fe],N=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto","contain","none"],T=()=>[Pe,Fe,c],P=()=>[kn,"full","auto",...T()],E=()=>[_n,"none","subgrid",Pe,Fe],C=()=>["auto",{span:["full",_n,Pe,Fe]},_n,Pe,Fe],I=()=>[_n,"auto",Pe,Fe],W=()=>["auto","min","max","fr",Pe,Fe],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],V=()=>["auto",...T()],X=()=>[kn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],L=()=>[kn,"screen","full","dvw","lvw","svw","min","max","fit",...T()],B=()=>[kn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],D=()=>[e,Pe,Fe],K=()=>[...x(),Vd,Ud,{position:[Pe,Fe]}],ae=()=>["no-repeat",{repeat:["","x","y","space","round"]}],j=()=>["auto","cover","contain",Pv,Nv,{size:[Pe,Fe]}],U=()=>[Ua,Ko,Wn],le=()=>["","none","full",u,Pe,Fe],oe=()=>["",ot,Ko,Wn],G=()=>["solid","dashed","dotted","double"],ie=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ce=()=>[ot,Ua,Vd,Ud],ee=()=>["","none",m,Pe,Fe],ne=()=>["none",ot,Pe,Fe],he=()=>["none",ot,Pe,Fe],Ie=()=>[ot,Pe,Fe],Ue=()=>[kn,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[pn],breakpoint:[pn],color:[jd],container:[pn],"drop-shadow":[pn],ease:["in","out","in-out"],font:[Ev],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[pn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[pn],shadow:[pn],spacing:["px",ot],text:[pn],"text-shadow":[pn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",kn,Fe,Pe,y]}],container:["container"],columns:[{columns:[ot,Fe,Pe,a]}],"break-after":[{"break-after":A()}],"break-before":[{"break-before":A()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:F()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[_n,"auto",Pe,Fe]}],basis:[{basis:[kn,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ot,kn,"auto","initial","none",Fe]}],grow:[{grow:["",ot,Pe,Fe]}],shrink:[{shrink:["",ot,Pe,Fe]}],order:[{order:[_n,"first","last","none",Pe,Fe]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:C()}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:C()}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":W()}],"auto-rows":[{"auto-rows":W()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pbs:[{pbs:T()}],pbe:[{pbe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:V()}],mx:[{mx:V()}],my:[{my:V()}],ms:[{ms:V()}],me:[{me:V()}],mbs:[{mbs:V()}],mbe:[{mbe:V()}],mt:[{mt:V()}],mr:[{mr:V()}],mb:[{mb:V()}],ml:[{ml:V()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:X()}],"inline-size":[{inline:["auto",...L()]}],"min-inline-size":[{"min-inline":["auto",...L()]}],"max-inline-size":[{"max-inline":["none",...L()]}],"block-size":[{block:["auto",...B()]}],"min-block-size":[{"min-block":["auto",...B()]}],"max-block-size":[{"max-block":["none",...B()]}],w:[{w:[a,"screen",...X()]}],"min-w":[{"min-w":[a,"screen","none",...X()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...X()]}],h:[{h:["screen","lh",...X()]}],"min-h":[{"min-h":["screen","lh","none",...X()]}],"max-h":[{"max-h":["screen","lh",...X()]}],"font-size":[{text:["base",r,Ko,Wn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Iv,kv]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ua,Fe]}],"font-family":[{font:[Fv,_v,t]}],"font-features":[{"font-features":[Fe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Pe,Fe]}],"line-clamp":[{"line-clamp":[ot,"none",Pe,zd]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",Pe,Fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Pe,Fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[ot,"from-font","auto",Pe,Wn]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[ot,"auto",Pe,Fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Pe,Fe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Pe,Fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:K()}],"bg-repeat":[{bg:ae()}],"bg-size":[{bg:j()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},_n,Pe,Fe],radial:["",Pe,Fe],conic:[_n,Pe,Fe]},Ov,Tv]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:le()}],"rounded-s":[{"rounded-s":le()}],"rounded-e":[{"rounded-e":le()}],"rounded-t":[{"rounded-t":le()}],"rounded-r":[{"rounded-r":le()}],"rounded-b":[{"rounded-b":le()}],"rounded-l":[{"rounded-l":le()}],"rounded-ss":[{"rounded-ss":le()}],"rounded-se":[{"rounded-se":le()}],"rounded-ee":[{"rounded-ee":le()}],"rounded-es":[{"rounded-es":le()}],"rounded-tl":[{"rounded-tl":le()}],"rounded-tr":[{"rounded-tr":le()}],"rounded-br":[{"rounded-br":le()}],"rounded-bl":[{"rounded-bl":le()}],"border-w":[{border:oe()}],"border-w-x":[{"border-x":oe()}],"border-w-y":[{"border-y":oe()}],"border-w-s":[{"border-s":oe()}],"border-w-e":[{"border-e":oe()}],"border-w-bs":[{"border-bs":oe()}],"border-w-be":[{"border-be":oe()}],"border-w-t":[{"border-t":oe()}],"border-w-r":[{"border-r":oe()}],"border-w-b":[{"border-b":oe()}],"border-w-l":[{"border-l":oe()}],"divide-x":[{"divide-x":oe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":oe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ot,Pe,Fe]}],"outline-w":[{outline:["",ot,Ko,Wn]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",f,Ws,Hs]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",l,Ws,Hs]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[ot,Wn]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":oe()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",p,Ws,Hs]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[ot,Pe,Fe]}],"mix-blend":[{"mix-blend":[...ie(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ie()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ot]}],"mask-image-linear-from-pos":[{"mask-linear-from":Ce()}],"mask-image-linear-to-pos":[{"mask-linear-to":Ce()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":Ce()}],"mask-image-t-to-pos":[{"mask-t-to":Ce()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":Ce()}],"mask-image-r-to-pos":[{"mask-r-to":Ce()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":Ce()}],"mask-image-b-to-pos":[{"mask-b-to":Ce()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":Ce()}],"mask-image-l-to-pos":[{"mask-l-to":Ce()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":Ce()}],"mask-image-x-to-pos":[{"mask-x-to":Ce()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":Ce()}],"mask-image-y-to-pos":[{"mask-y-to":Ce()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[Pe,Fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":Ce()}],"mask-image-radial-to-pos":[{"mask-radial-to":Ce()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":x()}],"mask-image-conic-pos":[{"mask-conic":[ot]}],"mask-image-conic-from-pos":[{"mask-conic-from":Ce()}],"mask-image-conic-to-pos":[{"mask-conic-to":Ce()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:K()}],"mask-repeat":[{mask:ae()}],"mask-size":[{mask:j()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Pe,Fe]}],filter:[{filter:["","none",Pe,Fe]}],blur:[{blur:ee()}],brightness:[{brightness:[ot,Pe,Fe]}],contrast:[{contrast:[ot,Pe,Fe]}],"drop-shadow":[{"drop-shadow":["","none",g,Ws,Hs]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",ot,Pe,Fe]}],"hue-rotate":[{"hue-rotate":[ot,Pe,Fe]}],invert:[{invert:["",ot,Pe,Fe]}],saturate:[{saturate:[ot,Pe,Fe]}],sepia:[{sepia:["",ot,Pe,Fe]}],"backdrop-filter":[{"backdrop-filter":["","none",Pe,Fe]}],"backdrop-blur":[{"backdrop-blur":ee()}],"backdrop-brightness":[{"backdrop-brightness":[ot,Pe,Fe]}],"backdrop-contrast":[{"backdrop-contrast":[ot,Pe,Fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ot,Pe,Fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ot,Pe,Fe]}],"backdrop-invert":[{"backdrop-invert":["",ot,Pe,Fe]}],"backdrop-opacity":[{"backdrop-opacity":[ot,Pe,Fe]}],"backdrop-saturate":[{"backdrop-saturate":[ot,Pe,Fe]}],"backdrop-sepia":[{"backdrop-sepia":["",ot,Pe,Fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Pe,Fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ot,"initial",Pe,Fe]}],ease:[{ease:["linear","initial",S,Pe,Fe]}],delay:[{delay:[ot,Pe,Fe]}],animate:[{animate:["none",w,Pe,Fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,Pe,Fe]}],"perspective-origin":[{"perspective-origin":F()}],rotate:[{rotate:ne()}],"rotate-x":[{"rotate-x":ne()}],"rotate-y":[{"rotate-y":ne()}],"rotate-z":[{"rotate-z":ne()}],scale:[{scale:he()}],"scale-x":[{"scale-x":he()}],"scale-y":[{"scale-y":he()}],"scale-z":[{"scale-z":he()}],"scale-3d":["scale-3d"],skew:[{skew:Ie()}],"skew-x":[{"skew-x":Ie()}],"skew-y":[{"skew-y":Ie()}],transform:[{transform:[Pe,Fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:F()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ue()}],"translate-x":[{"translate-x":Ue()}],"translate-y":[{"translate-y":Ue()}],"translate-z":[{"translate-z":Ue()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Pe,Fe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mbs":[{"scroll-mbs":T()}],"scroll-mbe":[{"scroll-mbe":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pbs":[{"scroll-pbs":T()}],"scroll-pbe":[{"scroll-pbe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Pe,Fe]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[ot,Ko,Wn,zd]}],stroke:[{stroke:["none",...D()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function H(...e){return Lv(Td(e))}const Dv=["richtext","multiselect","radio","checkboxgroup","signature"],Bv=3;function qo(e){const t=e.position.rowSpan??1;if(e.type==="billingGrid"||e.type==="table")return Math.max(1,t);if(e.type==="file"||e.type==="camera"||e.type==="photoChoice"||e.type==="textarea")return Math.max(t,1);if(e.type==="status")return Math.max(t,4);if(e.type==="selectablelist")return Math.max(Bv,t);if(e.type==="radio"||e.type==="checkboxgroup"){const r=e.properties?.options;return(Array.isArray(r)?r.length:0)<=2?1:Math.max(t,2)}return Dv.includes(e.type)?Math.max(t,2):t}function Xd(e,t){if(e.type==="table"||e.type==="billingGrid"){const s=e.position.columnSpan??t??1;return t!=null?Math.min(s,t):s}if(e.type!=="radio"&&e.type!=="checkboxgroup"){const s=e.position.columnSpan??1;return t!=null?Math.min(s,t):s}const r=e.properties?.options,n=Array.isArray(r)?r.length:0,o=Math.max(1,Math.ceil(n/2));return t!=null?Math.min(o,t):o}function uo(e){const t=e?.size??"md",r=e?.variant??"default";return H(t==="sm"?"h-8 text-sm":t==="lg"?"min-h-12 text-lg py-2":"h-10 md:text-sm",r==="filled"?"border-transparent bg-muted shadow-none":r==="outlined"?"border-2 bg-transparent":"")}function Jd(e){const t=e?.size??"md",r=e?.variant??"default";return H(t==="sm"?"min-h-[48px] text-sm":t==="lg"?"min-h-[72px] text-lg":"min-h-[56px]",r==="filled"?"border-transparent bg-muted shadow-none":r==="outlined"?"border-2 bg-transparent":"")}function $v(e){switch(e){case"left":return"flex flex-row items-start gap-4";case"right":return"flex flex-row-reverse items-start gap-4";case"center":return"flex flex-col items-center text-center w-full";case"floating":return"relative flex flex-col gap-2 w-full min-w-0";default:return"flex flex-col gap-2 w-full min-w-0"}}function jv(e,t){const r=t?"text-destructive":"";switch(e){case"left":return`shrink-0 w-32 pt-2 text-right text-sm font-medium ${r}`;case"right":return`shrink-0 w-32 pt-2 text-left text-sm font-medium ${r}`;case"center":return`w-full text-center text-sm font-medium ${r}`;case"floating":return`absolute left-3 top-2 z-[1] origin-[0] -translate-y-4 scale-75 bg-background px-1 text-sm ${r}`;default:return`text-sm font-medium ${r}`}}function zv(e){switch(e){case"left":case"right":return"flex-1 min-w-0 min-h-0 flex flex-col";case"center":return"w-full max-w-full flex flex-col flex-1 min-h-0";case"floating":return"flex flex-col flex-1 min-h-0 w-full pt-4";default:return"flex flex-col flex-1 min-h-0 w-full min-w-0"}}function Rs(e){return!e||e.widthMode==="full"?100:typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent)?Math.min(100,Math.max(1,Math.round(e.widthPercent))):(e.widthMode==="percent",100)}function Ha(e){const t=Rs(e);return{width:t>=100?"100%":`${t}%`,maxWidth:"100%"}}function Uv(e){return Ha(e)}function Wa(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"||t==="stretch"?t:null}function Ra(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"?t:null}function Fr(e){if(!e)return"start";const t=Wa(e.horizontalAlign);if(t)return t;const r=Wa(e.contentAlign);if(r)return r;const n=Wa(e.cellAlign);return n||"start"}function Yo(e){if(e?.verticalAlign!=null)return e.verticalAlign;const t=e?.cellJustify;return t==="center"?"center":t==="end"?"end":t==="stretch"?"stretch":t==="start"?"start":"stretch"}function Gs(e){switch(e){case"center":return"items-center";case"end":return"items-end";case"stretch":return"items-stretch";default:return"items-start"}}function Ga(e){switch(e){case"center":return"justify-center";case"end":return"justify-end";case"stretch":return"justify-stretch";default:return"justify-start"}}function Xo(e){const t=Ra(e.appearance?.contentVerticalAlign);if(t!==null)switch(t){case"center":return"justify-center";case"end":return"justify-end";default:return"justify-start"}return Ga(Ka(e))}const Vv=Xo;function Ks(e){if(e.type==="billingGrid"||e.type==="table"||qo(e)>1)return!0;const t=Ra(e.appearance?.contentVerticalAlign);if(t==="center"||t==="end")return!1;if(t==="start")return!0;const r=Ka(e);return r!=="center"&&r!=="end"}function Qd(e){const t=e[0];if(!t)return qa(void 0);if(e.length===1)return qa(t);const r=Fr(t.appearance);return H("flex flex-col min-h-0 h-full w-full",Gs(r),"justify-start")}function Zd(e){const t=Fr(e),r=Yo(e);return H("flex flex-col min-h-0 h-full w-full",Gs(t),Ga(r))}function eu(e){if(Rs(e)>=100)return"";const r=Fr(e);return r==="center"?"mx-auto":r==="end"?"ml-auto":""}function tu(e){if(Rs(e)>=100)return"w-full";const r=Fr(e);return r==="center"||r==="end"?"min-w-0":r==="stretch"?"min-w-0 self-stretch":"min-w-0 self-start"}function ru(e){return e?e.widthMode==="full"||e.widthMode==="percent"||typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent):!1}function fo(e){return(e.type==="button"||e.type==="editButton")&&!ru(e.appearance)}function nu(e){return fo(e)?Fr(e.appearance)==="stretch"?{width:"100%",maxWidth:"100%",minWidth:0}:{width:"auto",maxWidth:"100%"}:Ha(e.appearance)}function ou(e){return nu(e)}function su(e){if(fo(e))switch(Fr(e.appearance)){case"center":return"self-center";case"end":return"self-end";case"stretch":return"self-stretch";default:return"self-start"}return tu(e.appearance)}function iu(e){return e?e.verticalAlign!=null||e.cellJustify!=null:!1}function Ka(e){return e.type!=="button"&&e.type!=="editButton"||iu(e.appearance)?Yo(e.appearance):"start"}function qa(e){if(!e)return Zd(void 0);const t=Fr(e.appearance);return H("flex flex-col min-h-0 h-full w-full",Gs(t),Xo(e))}function Hv(e,t){const r={};e!==void 0&&(r.cellAlign=e),t!==void 0&&(r.cellJustify=t);const o=e===void 0&&t===void 0?void 0:r;return H(Gs(Fr(o)),Ga(Yo(o)))}const Ya=v.createContext({gridStretch:!1});function Jo(){return v.useContext(Ya)}const au=e=>{let t;const r=new Set,n=(u,f)=>{const l=typeof u=="function"?u(t):u;if(!Object.is(l,t)){const p=t;t=f??(typeof l!="object"||l===null)?l:Object.assign({},t,l),r.forEach(g=>g(t,p))}},o=()=>t,a={setState:n,getState:o,getInitialState:()=>c,subscribe:u=>(r.add(u),()=>r.delete(u))},c=t=e(n,o,a);return a},Wv=(e=>e?au(e):au),Rv=e=>e;function Xa(e,t=Rv){const r=v.useSyncExternalStore(e.subscribe,v.useCallback(()=>t(e.getState()),[e,t]),v.useCallback(()=>t(e.getInitialState()),[e,t]));return v.useDebugValue(r),r}const lu=e=>{const t=Wv(e),r=n=>Xa(t,n);return Object.assign(r,t),r},cu=(e=>e?lu(e):lu),Gv=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Kv=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,qv=/^\+?[\d\s-()]{10,}$/,Yv={required:e=>e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e=="boolean"?e===!0:!0,minLength:(e,t)=>{if(typeof e!="string")return!0;const r=t.value;return e.length>=r},maxLength:(e,t)=>{if(typeof e!="string")return!0;const r=t.value;return e.length<=r},min:(e,t)=>{if(typeof e!="number")return!0;const r=t.value;return e>=r},max:(e,t)=>{if(typeof e!="number")return!0;const r=t.value;return e<=r},pattern:(e,t)=>{if(typeof e!="string")return!0;const r=t.value,n=t.params?.flags||"";return new RegExp(r,n).test(e)},email:e=>typeof e!="string"||!e?!0:Gv.test(e),url:e=>typeof e!="string"||!e?!0:Kv.test(e),phone:e=>typeof e!="string"||!e?!0:qv.test(e),date:e=>{if(!e)return!0;const t=new Date(e);return!isNaN(t.getTime())},dateRange:(e,t)=>{if(!e)return!0;const r=new Date(e);if(isNaN(r.getTime()))return!1;const n=t.value,o=new Date;if(o.setHours(0,0,0,0),n.min){const s=n.min==="today"?o:new Date(n.min);if(r<s)return!1}if(n.max){const s=n.max==="today"?o:new Date(n.max);if(r>s)return!1}return!0},fileSize:(e,t)=>{if(!e)return!0;const r=t.value;return e instanceof File?e.size<=r:Array.isArray(e)?e.every(n=>n.size<=r):!0},fileType:(e,t)=>{if(!e)return!0;const r=t.value,n={"text/csv":[".csv"],"application/vnd.ms-excel":[".xls"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":[".xlsx"],"application/pdf":[".pdf"],"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"]},o=s=>r.some(i=>{if(i.endsWith("/*")){const u=i.replace("/*","");if(s.type.startsWith(u))return!0}else if(s.type===i)return!0;const a=s.name.toLowerCase(),c=n[i];return c?c.some(u=>a.endsWith(u)):i.startsWith(".")?a.endsWith(i.toLowerCase()):!1});return e instanceof File?o(e):Array.isArray(e)?e.every(s=>o(s)):!0},allowLetters:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[a-zA-Z]/.test(e),allowNumbers:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[0-9]/.test(e),allowSpecialChars:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[^a-zA-Z0-9\s]/.test(e),minLetters:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[a-zA-Z]/g)||[]).length>=r},maxLetters:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[a-zA-Z]/g)||[]).length<=r},minNumbers:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[0-9]/g)||[]).length>=r},maxNumbers:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[0-9]/g)||[]).length<=r},minSpecialChars:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[^a-zA-Z0-9\s]/g)||[]).length>=r},maxSpecialChars:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[^a-zA-Z0-9\s]/g)||[]).length<=r},custom:(e,t,r)=>!0,async:()=>!0};function rn(e,t,r={}){const n=Yv[t.type];if(!n)return!0;const o=n(e,t,r);return o===!1?t.message||Xv(t):typeof o=="string"?o:!0}function Xv(e){return{required:"This field is required",minLength:`Must be at least ${e.value} characters`,maxLength:`Must be at most ${e.value} characters`,min:`Must be at least ${e.value}`,max:`Must be at most ${e.value}`,pattern:"Invalid format",email:"Please enter a valid email address",url:"Please enter a valid URL",phone:"Please enter a valid phone number",date:"Please enter a valid date",dateRange:"Date is out of allowed range",fileSize:`File size must be less than ${Jv(e.value)}`,fileType:"File type is not allowed",allowLetters:"Letters are not allowed in this field",allowNumbers:"Numbers are not allowed in this field",allowSpecialChars:"Special characters are not allowed in this field",minLetters:`Must contain at least ${e.value} letters`,maxLetters:`Must contain at most ${e.value} letters`,minNumbers:`Must contain at least ${e.value} numbers`,maxNumbers:`Must contain at most ${e.value} numbers`,minSpecialChars:`Must contain at least ${e.value} special characters`,maxSpecialChars:`Must contain at most ${e.value} special characters`,custom:"Validation failed",async:"Validation failed"}[e.type]||"Invalid value"}function Jv(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const Qv=10;function qs(e){const t=e.properties;return t?.maxFiles!=null&&t.maxFiles>0?Math.floor(t.maxFiles):t?.multiple===!0?Qv:1}function du(e){return typeof e=="object"&&e!==null&&"url"in e&&typeof e.url=="string"&&e.url.length>0}function uu(e){try{return e.split("?")[0].split("/").filter(Boolean).pop()||e}catch{return e}}function Ys(e){if(e==null)return[];if(typeof e=="string")return e.startsWith("http")?[{url:e,name:uu(e)}]:[];if(e instanceof File)return[e];if(Array.isArray(e)){const t=[];for(const r of e)r instanceof File?t.push(r):typeof r=="string"&&r.startsWith("http")?t.push({url:r,name:uu(r)}):du(r)&&t.push(r);return t}return du(e)?[e]:[]}function Zv(e,t){return e.slice(0,t)}function Ja(e,t){const r=Zv(e,t);return r.length===0?null:t===1?r[0]??null:r}function ew(e){return Ys(e).length}function tw(e){return e==="file"||e==="camera"||e==="photoChoice"}function Qa(e,t){if(!tw(e.type))return;const r=qs(e);if(ew(t)>r)return`Maximum ${r} file(s) allowed`}const rw=4,nw=2,ow=10;function fu(e){const t=e.properties?.otpLength??e.metadata?.otpLength,r=typeof t=="number"?t:Number(t);return Number.isFinite(r)?Math.min(ow,Math.max(nw,Math.round(r))):rw}function sw(e,t){const r=String(e??"").replace(/\s/g,"").slice(0,t).split("");for(;r.length<t;)r.push("");return r}function iw(e){return e.join("").replace(/\s/g,"")}function Za(e,t){if(e.type!=="otp")return;const r=String(t??"").trim();if(!r)return;const n=fu(e);if(r.length!==n)return`Please enter a ${n}-digit OTP`}class Xs{static functions={SUM:(...t)=>t.flat().filter(n=>typeof n=="number").reduce((n,o)=>n+o,0),AVG:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length===0?0:r.reduce((n,o)=>n+o,0)/r.length},MIN:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length>0?Math.min(...r):0},MAX:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length>0?Math.max(...r):0},ROUND:(t,r=0)=>{const n=Number(t);if(isNaN(n))return 0;const o=Math.pow(10,Number(r));return Math.round(n*o)/o},FLOOR:t=>Math.floor(Number(t)||0),CEIL:t=>Math.ceil(Number(t)||0),ABS:t=>Math.abs(Number(t)||0),CONCAT:(...t)=>t.map(String).join(""),UPPER:t=>String(t).toUpperCase(),LOWER:t=>String(t).toLowerCase(),TRIM:t=>String(t).trim(),LEN:t=>String(t).length,SUBSTR:(t,r,n)=>{const o=String(t),s=Number(r),i=n!==void 0?Number(n):void 0;return o.substring(s,i!==void 0?s+i:void 0)},IF:(t,r,n)=>t?r:n,IFEMPTY:(t,r)=>t==null||t===""?r:t,ISNUMBER:t=>typeof t=="number"&&!isNaN(t),ISEMPTY:t=>t==null?!0:typeof t=="string"?t.trim()==="":Array.isArray(t)?t.length===0:!1,TODAY:()=>new Date().toISOString().split("T")[0],NOW:()=>new Date().toISOString(),YEAR:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getFullYear()},MONTH:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getMonth()+1},DAY:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getDate()},DATEDIFF:(t,r,n="days")=>{const o=new Date(t),s=new Date(r);if(isNaN(o.getTime())||isNaN(s.getTime()))return null;const a=(s.getTime()-o.getTime())/(1e3*60*60*24);switch(n){case"years":return a/365;case"months":return a/30;case"weeks":return a/7;case"hours":return a*24;case"minutes":return a*24*60;default:return a}},COUNT:t=>Array.isArray(t)?t.length:t?1:0,FIRST:t=>Array.isArray(t)?t[0]:t,LAST:t=>Array.isArray(t)?t[t.length-1]:t,SUMFIELD:(...t)=>{const r=t[0],n=t[1];return!Array.isArray(r)||typeof n!="string"?0:r.reduce((o,s)=>{if(typeof s=="object"&&s!==null){const i=s[n];return o+(Number(i)||0)}return o},0)}};calculate(t,r){try{const{fields:n,currentValue:o,previousValue:s}=r,i={...n};for(const l in i){const p=i[l];(p==null||p==="")&&(i[l]="")}const a={fields:i,currentValue:o,previousValue:s,...Xs.functions},c=Object.keys(a),u=Object.values(a),f=new Function(...c,`return ${t}`)(...u);if(f==null)return"";if(typeof f=="string"){if(f.includes("undefined"))return"";const l=f.trim();return l===""||/^\s+$/.test(f)?"":l}return f}catch{return""}}calculateAll(t,r){const n={...r};for(const o of t){const s={fields:n,currentValue:n[o.field],previousValue:r[o.field]},i=this.calculate(o.formula,s);n[o.field]=i===null?"":i}return n}validateFormula(t){try{return new Function("fields",`return ${t}`),{valid:!0}}catch(r){return{valid:!1,error:r instanceof Error?r.message:"Invalid formula"}}}getAvailableFunctions(){return[{name:"SUM",description:"Sum of values"},{name:"AVG",description:"Average of values"},{name:"MIN",description:"Minimum value"},{name:"MAX",description:"Maximum value"},{name:"ROUND",description:"Round to decimal places"},{name:"IF",description:"Conditional value"},{name:"CONCAT",description:"Concatenate strings"},{name:"TODAY",description:"Current date"},{name:"DATEDIFF",description:"Difference between dates"},{name:"COUNT",description:"Count of items"},{name:"SUMFIELD",description:"Sum field in array"}]}}const pu=new Xs;function mu(e){if(e==null||e==="")return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:Js(e);if(typeof e=="string"){const t=e.trim();if(!t)return null;const r=t.match(/^(\d{4})-(\d{2})-(\d{2})/);if(r){const o=new Date(Number(r[1]),Number(r[2])-1,Number(r[3]));return Number.isNaN(o.getTime())?null:o}const n=new Date(t);return Number.isNaN(n.getTime())?null:Js(n)}return null}function Js(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function aw(e,t=new Date){const r=Js(e),n=Js(t);if(n<r)return{years:0,months:0,days:0};let o=n.getFullYear()-r.getFullYear(),s=n.getMonth()-r.getMonth(),i=n.getDate()-r.getDate();if(i<0){s-=1;const a=new Date(n.getFullYear(),n.getMonth(),0).getDate();i+=a}return s<0&&(o-=1,s+=12),{years:Math.max(0,o),months:Math.max(0,s),days:Math.max(0,i)}}function el(e){if(e.type!=="number")return;const t=e.properties?.deriveFromDate;if(!(!t?.sourceFieldName||!t.part))return t}function Pr(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function tl(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(t):null}function lw(e,t){const r=tl(e);return r?`${t.sourceFieldName}${r}`:t.sourceFieldName}function hu(e,t,r){const n=tl(t);if(n)return[`${e}${n}`];const o=new Set([e]),s=`${e}__addmore__`;for(const i of Object.keys(r))(i===e||i.startsWith(s))&&o.add(i);return[...o]}function cw(e,t,r){const n=r?lw(r,e):e.sourceFieldName,o=mu(t[n]);if(!o)return null;const s=e.referenceDate==="today"||e.referenceDate==null?new Date:mu(t[e.referenceDate])??new Date;return aw(o,s)[e.part]}function gu(e,t){const r=el(e);return r?Pr(r.sourceFieldName)===Pr(t):!1}function rl(e,t,r,n){const o={...t},s=n?Pr(n):void 0;for(const i of e){if(i.type!=="number")continue;const a=el(i);if(!a||!i.name||s&&Pr(a.sourceFieldName)!==s)continue;const c=n??a.sourceFieldName,u=hu(i.name,c,o);for(const f of u){if(r.has(f))continue;const l=cw(a,o,f);o[f]=l}}return o}function dw(e,t,r,n){const o={...t},s=Pr(n);for(const i of e){if(!gu(i,s)||!i.name)continue;const a=hu(i.name,n,o);for(const c of a)r.delete(c),o[c]=null}return o}function yu(e,t){const r=Pr(t);return e.some(n=>gu(n,r))}function bu(e){if(e.apidata&&typeof e.apidata=="object")return e.apidata;if(e.metadata)try{const t=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata;if(t.apiEndpoint||t.apiKey||t.valueSource==="api")return{apiKey:t.apiKey,valueSource:t.valueSource,apiEndpoint:t.apiEndpoint,apiAutoDetect:t.apiAutoDetect,apiLabelField:t.apiLabelField,apiValueField:t.apiValueField,apiMethod:t.apiMethod,apiRealtime:t.apiRealtime,apiQueryParams:t.apiQueryParams,apiClientFilter:t.apiClientFilter}}catch{}return null}function nl(e,t,r,n){let o=ol(e,r);return n&&(o=Gn(o,t,r)),o}function ol(e,t){return e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(r,n)=>t?.[n]!==void 0&&t[n]!==null?String(t[n]):r)}function Gn(e,t,r){let n=e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(o,s)=>r?.[s]!==void 0&&r[s]!==null?String(r[s]):o);return n=n.replace(/\{(\w+)\}/g,(o,s)=>{if(o.includes("ctx:")||o.includes("@"))return o;let i=t[s];if(i==null||i===""){const a=Object.keys(t).find(c=>c.toLowerCase()===s.toLowerCase());a&&(i=t[a])}return i!=null&&i!==""?String(i):o}),n}function po(e,t){const r=e.match(/\{(\w+)\}/g)||[],n=[];t?.custom&&t.custom.forEach(({value:s})=>{if(s){const i=s.match(/\{(\w+)\}/g)||[];n.push(...i.filter(a=>!a.includes("ctx:")&&!a.includes("@")))}});const o=r.filter(s=>!s.includes("ctx:")&&!s.includes("@"));return new Set([...o.map(s=>s.replace(/[{}]/g,"")),...n.map(s=>s.replace(/[{}]/g,""))])}function uw(e,t){const r=e[t];return r==null||r===""}function Qs(e){const{apiEndpoint:t,apiMethod:r="GET",apiQueryParams:n={},formValues:o,submissionContext:s,apiRealtime:i,additionalRequiredFieldNames:a=[],excludeFormFieldNames:c=[]}=e,u=(r||"GET").toLowerCase(),f=po(t,n),l=new Set((c||[]).filter(w=>typeof w=="string"&&w.length>0)),p=new Set((a||[]).filter(w=>typeof w=="string"&&w.length>0)),g=new Set([...f,...p]);let m=!1;for(const w of g){const A=!!(i&&f.has(w)),x=p.has(w);if((A||x)&&uw(o,w)){m=!0;break}}if(m)return{blocked:!0,url:t,postBodyBase:null};let h=t;const y=t.match(/\{(\w+)\}/g)||[];if(h=ol(h,s),i&&(h=Gn(h,o,s)),n&&Object.keys(n).length>0){const w=n,A=[];if(w.limit){let x=w.limit;i&&(x=Gn(x,o,s)),A.push(`_limit=${encodeURIComponent(x)}`)}if(w.page){let x=w.page;i&&(x=Gn(x,o,s)),A.push(`page=${encodeURIComponent(x)}`)}if(w.sort){let x=w.sort;i&&(x=Gn(x,o,s)),A.push(`sort=${encodeURIComponent(x)}`)}if(w.orderBy){let x=w.orderBy;i&&(x=Gn(x,o,s)),A.push(`orderBy=${encodeURIComponent(x)}`)}if(w.custom?.length&&w.custom.forEach(({key:x,value:F})=>{if(!x||!F)return;let N=ol(F,s);i&&(N=Gn(N,o,s)),N.match(/\{[^}]+\}/)?N.match(/\{(?!ctx:|\@)(\w+)\}/g)||A.push(`${encodeURIComponent(x)}=`):A.push(`${encodeURIComponent(x)}=${encodeURIComponent(N)}`)}),A.length>0){const x=h.includes("?")?"&":"?";h=`${h}${x}${A.join("&")}`}}if(i&&Object.keys(o).length>0&&u==="get"){const w=N=>N.replace(/\{/g,"").replace(/\}/g,""),A=[];for(const N of n.custom||[])if(N.value){const k=N.value.match(/\{(\w+)\}/g)||[];A.push(...k.map(w))}const x=new Set([...y.map(w),...A]),F={};Object.keys(o).forEach(N=>{!x.has(N)&&!l.has(N)&&(F[N]=o[N])}),Object.keys(F).length>0&&(h=`${h}${h.includes("?")?"&":"?"}${new URLSearchParams(F).toString()}`)}let S=null;if(["post","put","patch"].includes(u))if(i&&Object.keys(o).length>0){S={...o};for(const w of l)delete S[w]}else{S={...o||{}};for(const w of l)delete S[w]}return{blocked:!1,url:h,postBodyBase:S}}const fw=new Set(["select","multiselect","asyncsearch"]);function pw(e){return e?.type==="multiselect"?[]:""}function vu(e){if(!fw.has(e.type))return[];const t=e.properties??{},r=bu(e),n=new Set,o=r?.apiClientFilter?.matchField?.trim()||t.apiClientFilter?.matchField?.trim();o&&n.add(o);const s=[...Array.isArray(t.dependentFields)?t.dependentFields:[],...Array.isArray(r?.dependentFields)?r.dependentFields:[]];for(const u of s)typeof u=="string"&&u.trim()&&n.add(u.trim());const i=r?.apiEndpoint||t.apiEndpoint,a=r?.apiRealtime??t.apiRealtime,c=r?.apiQueryParams||t.apiQueryParams;if(i&&a)for(const u of po(i,c))n.add(u);return[...n]}function mw(e,t){const r=Pr(t);return vu(e).some(n=>Pr(n)===r)}function hw(e,t){const r=Pr(t);return e.some(n=>mw(n,r))}function gw(e){const t=new Map;for(const r of e){const n=r.name;if(n)for(const o of vu(r)){const s=Pr(o),i=t.get(s)??new Set;i.add(n),t.set(s,i)}}return t}function yw(e,t,r){const n=tl(t);if(n)return[`${e}${n}`];const o=new Set([e]),s=`${e}__addmore__`;for(const i of Object.keys(r))(i===e||i.startsWith(s))&&o.add(i);return[...o]}function bw(e,t){return e===t?!0:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((r,n)=>r===t[n]):!1}function vw(e,t,r){const n=gw(e),o=Pr(r),s=new Set,i=[o];for(;i.length>0;){const u=i.shift(),f=n.get(u);if(f)for(const l of f)s.has(l)||(s.add(l),i.push(l))}const a={...t},c=[];for(const u of s){const f=e.find(p=>p.name===u),l=pw(f);for(const p of yw(u,r,a))bw(a[p],l)||c.push(p),a[p]=l}return{values:a,clearedKeys:c}}function sl(e,t){const r=t instanceof Set?t:new Set(t);if(e.size!==r.size)return!1;for(const n of e)if(!r.has(n))return!1;return!0}function wu(){return cu((e,t)=>({schema:null,values:{},initialValues:{},errors:{},touched:{},isValidating:!1,isSubmitting:!1,submitCount:0,isValid:!0,currentStep:0,totalSteps:1,completedSteps:new Set,visibleFields:new Set,enabledFields:new Set,requiredFields:new Set,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:new Set,draftId:null,setSchema:(r,n)=>{const o=t(),s=o.schema!=null&&o.schema.id===r.id,i=n?.forceReset===!0,a={},c=new Set,u=new Set,f=new Set;r.fields.forEach(x=>{const F=x.name||x.key||x.id;F&&(x.defaultValue!==void 0&&(x.type==="multiselect"?a[F]=Array.isArray(x.defaultValue)?x.defaultValue:x.defaultValue!=null&&x.defaultValue!==""?[String(x.defaultValue)]:[]:a[F]=x.defaultValue),x.hidden||c.add(F),x.disabled||u.add(F),x.validation?.some(N=>N.type==="required")&&f.add(F))});const l=r.steps?.length||1,p=typeof n?.initialStepIndex=="number",g=p?Math.max(0,Math.min(n.initialStepIndex,Math.max(0,l-1))):0,m=new Set;for(let x=0;x<g;x++)m.add(x);const h=[];r.fields.forEach(x=>{const F=x.properties;F?.valueSource==="calculated"&&F?.formula&&h.push({field:x.name,formula:F.formula})});const y=h.length>0?pu.calculateAll(h,a):{},S=rl(r.fields,{...a,...y},new Set),A=s&&!(i||p)?{...S,...o.values}:S;e({schema:r,values:A,initialValues:S,errors:{},touched:{},currentStep:g,totalSteps:l,completedSteps:m,visibleFields:c,enabledFields:u,requiredFields:f,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:i||!s?new Set:o.derivedFieldDirty,isValid:!0,draftId:null})},setFieldValue:(r,n,o)=>{const s=t(),i=s.schema,a=o?.source??"user";let c=new Set(s.derivedFieldDirty);const u=s.values[r];let f={...s.values,[r]:n},l=[];if(i){const p=Pr(r),g=i.fields.find(S=>S.name===p);a==="user"&&g&&el(g)&&c.add(r);const m=n==null||n===""||Array.isArray(n)&&n.length===0;if(yu(i.fields,r)&&m?f=dw(i.fields,f,c,r):yu(i.fields,r)&&(f=rl(i.fields,f,c,r)),a==="user"&&u!==n&&!(Array.isArray(u)&&Array.isArray(n)&&u.length===n.length&&u.every((S,w)=>S===n[w]))&&hw(i.fields,r)){const S=vw(i.fields,f,r);f=S.values,l=S.clearedKeys}const y=[];i.fields.forEach(S=>{const w=S.properties;w?.valueSource==="calculated"&&w?.formula&&(w.formulaSteps??[]).some(x=>x.type==="field"&&x.fieldName===r)&&y.push({field:S.name,formula:w.formula})}),y.length>0&&(f={...f,...pu.calculateAll(y,f)})}e({values:f,derivedFieldDirty:c}),l.length>0&&e(p=>{const g={...p.errors};for(const m of l)delete g[m];return Object.keys(g).length===Object.keys(p.errors).length?p:{errors:g}}),i?.config.validateOnChange?t().validateField(r):e(p=>{const g={...p.errors};return delete g[r],{errors:g}})},setFieldTouched:(r,n=!0)=>{e(s=>({touched:{...s.touched,[r]:n}}));const o=t().schema;n&&o?.config.validateOnBlur&&t().validateField(r)},setFieldError:(r,n)=>{e(o=>{const s=!!o.errors[r];if(!n&&!s||n&&o.errors[r]===n)return o;const i={...o.errors};return n?i[r]=n:delete i[r],{errors:i,isValid:Object.keys(i).length===0}})},setValues:r=>{const n=t(),o=n.schema;if(!o){e({values:r});return}const s=rl(o.fields,r,n.derivedFieldDirty);e({values:s})},setErrors:r=>e({errors:r,isValid:Object.keys(r).length===0}),resetForm:()=>{const{initialValues:r}=t();e({values:{...r},errors:{},touched:{},currentStep:0,completedSteps:new Set,derivedFieldDirty:new Set,isValid:!0,submitCount:0})},clearForm:()=>{e({schema:null,values:{},initialValues:{},errors:{},touched:{},currentStep:0,totalSteps:1,completedSteps:new Set,visibleFields:new Set,enabledFields:new Set,requiredFields:new Set,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:new Set,isValid:!0,submitCount:0,draftId:null})},validateField:async r=>{const{schema:n,values:o}=t();if(!n)return;const s=n.fields.find(a=>a.name===r);if(!s)return;e({isValidating:!0});let i;if(s.validation)for(const a of s.validation){const c=rn(o[r],a,o);if(typeof c=="string"){i=c;break}}if(!i){const a=Qa(s,o[r]);a&&(i=a)}return!i&&s.type==="otp"&&(i=Za(s,o[r])),e(a=>{const c={...a.errors};return i?c[r]=i:delete c[r],{errors:c,isValid:Object.keys(c).length===0,isValidating:!1}}),i},validateForm:async()=>{const{schema:r,values:n,visibleFields:o,requiredFields:s}=t();if(!r)return!1;e({isValidating:!0});const i={};for(const a of r.fields)if(o.has(a.name)){if(a.validation)for(const c of a.validation){if(c.type==="required"&&!s.has(a.name))continue;const u=rn(n[a.name],c,n);if(typeof u=="string"){i[a.name]=u;break}}if(!i[a.name]){const c=Qa(a,n[a.name]);c&&(i[a.name]=c)}if(!i[a.name]){const c=Za(a,n[a.name]);c&&(i[a.name]=c)}}return e({errors:i,isValid:Object.keys(i).length===0,isValidating:!1}),Object.keys(i).length===0},validateStep:async r=>{const{schema:n,values:o,visibleFields:s}=t();if(!n?.steps)return!0;const i=n.steps[r];if(!i)return!0;e({isValidating:!0});const a={};for(const c of i.fields){const u=n.fields.find(f=>f.name===c);if(!(!u||!s.has(u.name))){if(u.validation)for(const f of u.validation){const l=rn(o[u.name],f,o);if(typeof l=="string"){a[u.name]=l;break}}if(!a[u.name]){const f=Qa(u,o[u.name]);f&&(a[u.name]=f)}if(!a[u.name]){const f=Za(u,o[u.name]);f&&(a[u.name]=f)}}}return e(c=>({errors:{...c.errors,...a},isValid:Object.keys(a).length===0,isValidating:!1})),Object.keys(a).length===0},nextStep:async()=>{const{currentStep:r,totalSteps:n,schema:o}=t();return o?.steps?.[r]?.validation==="onNext"&&!await t().validateStep(r)?!1:r<n-1?(e(i=>({currentStep:r+1,completedSteps:new Set([...i.completedSteps,r])})),!0):!1},prevStep:()=>{const{currentStep:r}=t();r>0&&e({currentStep:r-1})},goToStep:r=>{const{totalSteps:n,completedSteps:o,currentStep:s}=t();r>=0&&r<n&&(r<=s||o.has(r-1))&&e({currentStep:r})},setSubmitting:r=>e({isSubmitting:r}),incrementSubmitCount:()=>e(r=>({submitCount:r.submitCount+1})),updateVisibility:r=>{e(n=>{const o=new Set(r);return sl(n.visibleFields,o)?n:{visibleFields:o}})},updateEnabled:r=>{e(n=>{const o=new Set(r);return sl(n.enabledFields,o)?n:{enabledFields:o}})},updateRequired:r=>{e(n=>{const o=new Set(r);return sl(n.requiredFields,o)?n:{requiredFields:o}})},updateReadOnly:r=>e({readOnlyFields:new Set(r)}),updateEditable:r=>e({editableFields:new Set(r)}),updateFormDisabled:r=>e({formDisabled:r}),saveDraft:()=>{const{schema:r,values:n}=t();if(!r)return;const o=`formsmith_draft_${r.id}`;try{localStorage.setItem(o,JSON.stringify({values:n,savedAt:new Date().toISOString()})),e({draftId:o})}catch{}},loadDraft:()=>{const{schema:r}=t();if(!r)return!1;const n=`formsmith_draft_${r.id}`;try{const o=localStorage.getItem(n);if(o){const{values:s}=JSON.parse(o);return e({values:s,draftId:n}),!0}}catch{}return!1},clearDraft:()=>{const{schema:r,draftId:n}=t();if(!r)return;const o=n||`formsmith_draft_${r.id}`;try{localStorage.removeItem(o),e({draftId:null})}catch{}}}))}const Kn=wu();function ww(e=Kn){return e.getState()}const Su=v.createContext(null),il=({children:e})=>{const t=v.useRef(null);return t.current||(t.current=wu()),d.jsx(Su.Provider,{value:t.current,children:e})};function Zs(){return v.useContext(Su)??Kn}function Or(e){const t=Zs();return e?Xa(t,e):Xa(t)}function xu({schema:e,initialValues:t,onSubmit:r,onChange:n,workflowStepId:o,initialStepIndex:s}){const{values:i,errors:a,touched:c,isValidating:u,isSubmitting:f,submitCount:l,isValid:p,currentStep:g,totalSteps:m,completedSteps:h,visibleFields:y,enabledFields:S,requiredFields:w,setSchema:A,setFieldValue:x,setFieldTouched:F,setFieldError:N,setValues:k,resetForm:T,validateField:P,validateForm:E,validateStep:C,nextStep:I,prevStep:W,goToStep:M,setSubmitting:z,incrementSubmitCount:V,saveDraft:X,loadDraft:L,clearDraft:B}=Or(),D=Zs(),K=v.useRef(null);v.useLayoutEffect(()=>{if(A(e,{forceReset:!!o||typeof s=="number",initialStepIndex:s}),t&&Object.keys(t).length>0){const re=D.getState().values;k({...re,...t});try{K.current=JSON.stringify(t)}catch{K.current=null}}else K.current=null},[e.id,o,s]),v.useLayoutEffect(()=>{if(!t||Object.keys(t).length===0)return;let re;try{re=JSON.stringify(t)}catch{return}if(re===K.current)return;const ge=D.getState().values;k({...ge,...t}),K.current=re},[t,k]);const ae=v.useCallback((re,ge)=>{const Se={...i,[re]:ge};x(re,ge),n?.(Se,re)},[x,n,i]),j=v.useCallback(async re=>{if(re?.preventDefault(),V(),!await E())return{success:!1,errors:Object.entries(a).map(([Se,pt])=>({field:Se,rule:"validation",message:pt}))};if(!r)return{success:!0};z(!0);try{const Se=await r(i);return Se.success&&B(),Se}catch(Se){return{success:!1,message:Se instanceof Error?Se.message:"Submission failed"}}finally{z(!1)}},[E,r,i,a,V,z,B]),U=v.useCallback(re=>({value:i[re],error:a[re],touched:c[re]||!1,isVisible:y.has(re),isEnabled:S.has(re),isRequired:w.has(re)}),[i,a,c,y,S,w]),le=v.useMemo(()=>{if(!e.steps||e.steps.length===0)return e.fields;const re=e.steps[g];return re?e.fields.filter(ge=>re.fields.includes(ge.name)):[]},[e,g]),oe=g===0,G=g===m-1,ie=v.useCallback(re=>h.has(re),[h]),Ce=v.useMemo(()=>m<=1?100:Math.round(h.size/m*100),[h.size,m]),ee=v.useCallback(re=>y.has(re),[y]),ne=v.useCallback(re=>S.has(re),[S]),he=v.useCallback(re=>w.has(re),[w]),Ie=v.useMemo(()=>Object.entries(a).filter(([re])=>y.has(re)),[a,y]),Ue=Ie.length>0;return{values:i,errors:a,touched:c,isValidating:u,isSubmitting:f,submitCount:l,isValid:p,hasErrors:Ue,visibleErrors:Ie,currentStep:g,totalSteps:m,completedSteps:h,currentStepFields:le,isFirstStep:oe,isLastStep:G,isStepCompleted:ie,progress:Ce,setFieldValue:ae,setFieldTouched:F,setFieldError:N,setValues:k,validateField:P,getFieldState:U,shouldShowField:ee,isFieldEnabled:ne,isFieldRequired:he,handleSubmit:j,resetForm:T,validateForm:E,validateStep:C,nextStep:I,prevStep:W,goToStep:M,saveDraft:X,loadDraft:L,clearDraft:B}}function Au(e){return"logic"in e&&"conditions"in e}function Qo(e){if(e==null||typeof e!="object")return!1;const t=e;if(t.status==="error")return!1;if(t.status==="success"||t.status==="COMPLETED")return!0;const r=t.code;return typeof r=="number"&&r>=200&&r<300||t.data!=null&&t.status!=="error"}function Cu(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;const r=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let n=e;for(const o of r){if(n==null||typeof n!="object")return;n=n[o]}return n}function Ge(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;let r=Cu(e,t);if(r===void 0&&t.includes(".")){const n=t.split(".");if(n.length>=2){const o=n[0],s=n.slice(1).join("."),i=Cu(e,o);Array.isArray(i)&&i.length>0&&(r=Ge(i[0],s))}}return r}const Sw=new Set(["section","group","columns","divider","header","sectionHeading","spacer","textLabel","addmore","customizeSections"]);function xw(e){return e===!0||e==="true"?!0:e===!1||e==="false"?!1:e}function Aw(e,t){if(e==null||typeof t.path!="string"||!t.path.trim())return!1;const r=Ge(e,t.path),n=xw(t.value);switch(t.operator){case"equals":return r===n;case"notEquals":return r!==n;case"contains":return typeof r=="string"?r.includes(String(n)):Array.isArray(r)?r.includes(n):!1;case"notContains":return typeof r=="string"?!r.includes(String(n)):Array.isArray(r)?!r.includes(n):!0;case"startsWith":return typeof r=="string"&&r.startsWith(String(n));case"endsWith":return typeof r=="string"&&r.endsWith(String(n));case"greaterThan":return Number(r)>Number(n);case"lessThan":return Number(r)<Number(n);case"greaterThanOrEqual":return Number(r)>=Number(n);case"lessThanOrEqual":return Number(r)<=Number(n);case"isEmpty":return r==null?!0:typeof r=="string"?r.trim()==="":Array.isArray(r)?r.length===0:typeof r=="object"&&r!==null?Object.keys(r).length===0:!1;case"isNotEmpty":return r==null?!1:typeof r=="string"?r.trim()!=="":Array.isArray(r)?r.length>0:typeof r=="object"&&r!==null?Object.keys(r).length>0:!1;case"isTrue":return r===!0;case"isFalse":return r===!1;case"isNull":return r==null;case"isNotNull":return r!=null;case"in":return Array.isArray(n)?n.includes(r):!1;case"notIn":return Array.isArray(n)?!n.includes(r):!0;case"between":if(Array.isArray(n)&&n.length===2){const o=Number(r);return o>=Number(n[0])&&o<=Number(n[1])}return!1;case"regex":try{return new RegExp(String(n)).test(String(r??""))}catch{return!1}default:return!1}}function Cw(e,t,r){return e?e==="__allFields__"?t.filter(n=>!Sw.has(n.type)).map(n=>r(n)).filter(Boolean):e==="__allButtons__"?t.filter(n=>n.type==="button"||n.type==="editButton").map(n=>r(n)).filter(Boolean):[e]:[]}function Eu(e){return String(e||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_+/g,"_")}function Nu(e,t){const r=Eu(e)||"row",n=Eu(t)||"cell";return`${r}_${n}`}function Ew(e){return e.kind==="static"?e.row.id:e.block.id}function Nw(e,t){let r=e,n=2;for(;t.has(r);)r=`${e}_${n}`,n+=1;return t.add(r),r}function ku(e,t,r,n){const o=e.cellKey?.trim();if(o)return n.add(o),e;const s=Nu(t,r),i=Nw(s,n);return{...e,cellKey:i}}function _u(e){const t=new Set,r=(e.rowSlots??[]).map(n=>{if(n.kind==="static"){const i=n.row.id,a={};for(const[c,u]of Object.entries(n.row.cells))a[c]=ku(u,i,c,t);return{...n,row:{...n.row,cells:a}}}const o=n.block.id,s={};for(const[i,a]of Object.entries(n.block.cells))s[i]=ku(a,o,i,t);return{...n,block:{...n.block,cells:s}}});return{...e,rowSlots:r}}function Tu(e){const t=new Map;for(const r of e.rowSlots??[]){const n=Ew(r),o=r.kind,s=r.kind==="static"?r.row.cells:r.block.cells;for(const[i,a]of Object.entries(s)){const c=a.cellKey?.trim()||Nu(n,i);t.set(c,{slotId:n,rowKind:o,columnKey:i})}}return t}function kw(e,t,r){return t.rowKind==="static"?e.find(n=>n.slotId===t.slotId&&n.rowKind==="static"):r?.slotId===t.slotId&&r.rowKind==="dynamic"?r:e.find(n=>n.slotId===t.slotId&&n.rowKind==="dynamic")}function Fu(e,t,r,n,o){const s=r?.trim();if(!s)return 0;const a=Tu(e).get(s);if(a){if(o?.slotId&&a.slotId!==o.slotId||o?.rowKind&&a.rowKind!==o.rowKind)return 0;const c=kw(t,a,n);return c?al(c.values[a.columnKey]):0}if(n&&s in n.values)return al(n.values[s]);if(o?.slotId){const c=t.find(u=>u.slotId===o.slotId&&(!o.rowKind||u.rowKind===o.rowKind));if(c&&s in c.values)return al(c.values[s])}return 0}function al(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}const Pu="__fieldRef:",Ou="__billingCell:";function _w(e){const t={kind:"static",staticValue:"",fieldName:"",billingFieldName:"",cellKey:""};if(e==null)return t;const r=String(e);if(r.startsWith(Pu))return{...t,kind:"field",fieldName:r.slice(Pu.length)};if(r.startsWith(Ou)){const n=r.slice(Ou.length),o=n.indexOf("|");return o>=0?{...t,kind:"billingCell",billingFieldName:n.slice(0,o),cellKey:n.slice(o+1)}:{...t,kind:"billingCell",cellKey:n}}if(r.startsWith("field:"))return{...t,kind:"field",fieldName:r.slice(6)};if(r.startsWith("billing:")){const n=r.slice(8),o=n.indexOf("|");return o>=0?{...t,kind:"billingCell",billingFieldName:n.slice(0,o),cellKey:n.slice(o+1)}:{...t,kind:"billingCell",cellKey:n}}return{...t,kind:"static",staticValue:r}}function ll(e){return e.name||e.key||e.id}function Tw(e,t){const r=t.find(n=>n.id===e||n.name===e||n.key===e);return r?ll(r):e}function Fw(e,t,r,n){const o=t.trim();if(!o)return;const s=n.filter(a=>a.type==="billingGrid"),i=e?.trim()?s.filter(a=>ll(a)===e||a.name===e||a.id===e):s;for(const a of i){const c=_u(a.properties??{}),u=r[ll(a)];if(!u?.rows?.length)continue;const l=Tu(c).get(o);if(!l)continue;const p=u.rows.find(g=>l.rowKind==="static"?g.slotId===l.slotId&&g.rowKind==="static":g.slotId===l.slotId&&g.rowKind==="dynamic");if(p)return p.values[l.columnKey]}}function Pw(e,t,r){const n=_w(e);if(n.kind==="field"){const o=Tw(n.fieldName,r);return t[o]}return n.kind==="billingCell"?Fw(n.billingFieldName,n.cellKey,t,r):n.staticValue}function Iu(e,t){if(e===t)return!0;if(e==null||t===void 0||t===null)return!1;const r=Number(e),n=Number(t);return!Number.isNaN(r)&&!Number.isNaN(n)&&String(e).trim()!==""&&String(t).trim()!==""?r===n:String(e).trim()===String(t).trim()}const Mu="__buttonResponse:";function Ow({fields:e,values:t,buttonResponses:r,prepopulateResponse:n=null,prepopulateResponseRules:o}){const{updateVisibility:s,updateEnabled:i,updateRequired:a,updateReadOnly:c,updateEditable:u,updateFormDisabled:f}=Or(),l=v.useCallback(N=>N.name||N.key||N.id,[]),p=v.useCallback((N,k)=>{if(!N)return l(k);const T=e.find(P=>P.id===N||P.name===N||P.key===N);return T?l(T):N},[e,l]),g=v.useCallback(N=>{const k=e.find(T=>T.id===N||T.name===N||T.key===N);return k?l(k):N},[e,l]),m=v.useCallback(N=>{const{field:k,operator:T,value:P}=N;if(typeof k=="string"&&k.startsWith(Mu)){const W=k.slice(Mu.length),M=r?.[W],z=Qo(M);return P==="success"?z:P==="failure"?M!=null&&!z:!1}const E=g(k),C=t[E],I=Pw(P,t,e);switch(T){case"equals":return Iu(C,I);case"notEquals":return!Iu(C,I);case"contains":return typeof C=="string"?C.includes(String(I)):Array.isArray(C)?C.includes(I):!1;case"notContains":return typeof C=="string"?!C.includes(String(I)):Array.isArray(C)?!C.includes(I):!0;case"startsWith":return typeof C=="string"&&C.startsWith(String(I));case"endsWith":return typeof C=="string"&&C.endsWith(String(I));case"greaterThan":return Number(C)>Number(I);case"lessThan":return Number(C)<Number(I);case"greaterThanOrEqual":return Number(C)>=Number(I);case"lessThanOrEqual":return Number(C)<=Number(I);case"isEmpty":return C==null?!0:C instanceof File?!1:typeof C=="string"?C.trim()==="":Array.isArray(C)?(C.length>0&&C[0]instanceof File,C.length===0):typeof C=="object"&&C!==null?Object.keys(C).length===0:!1;case"isNotEmpty":return C==null?!1:C instanceof File?!0:typeof C=="string"?C.trim()!=="":Array.isArray(C)?(C.length>0&&C[0]instanceof File,C.length>0):typeof C=="object"&&C!==null?Object.keys(C).length>0:!1;case"isTrue":return C===!0;case"isFalse":return C===!1;case"isNull":return C==null;case"isNotNull":return C!=null;case"in":return Array.isArray(I)?I.includes(C):!1;case"notIn":return Array.isArray(I)?!I.includes(C):!0;case"between":if(Array.isArray(I)&&I.length===2){const W=Number(C);return W>=Number(I[0])&&W<=Number(I[1])}return!1;case"regex":try{return new RegExp(String(I)).test(String(C))}catch{return!1}default:return!0}},[t,g,r,e]),h=v.useCallback(N=>{const k=N.conditions.map(T=>Au(T)?h(T):m(T));return N.logic==="and"?k.every(Boolean):k.some(Boolean)},[m]),y=v.useCallback(N=>Au(N)?h(N):m(N),[m,h]),S=v.useCallback(()=>{const N=new Set,k=new Set,T=new Set,P=new Set,E=new Set;e.forEach(M=>{const z=l(M);M.hidden||N.add(z),M.disabled||k.add(z),M.validation?.some(V=>V.type==="required")&&T.add(z)});let C=!1;if(n!=null&&o?.length)for(const M of o){if(!Aw(n,M.when))continue;const{action:z,target:V}=M.then;if(z==="disableForm")C=!0;else if(z==="enableForm")C=!1;else{const X=Cw(V,e,l);for(const L of X)switch(z){case"disable":k.delete(L);break;case"enable":k.add(L);break;case"hide":N.delete(L);break;case"show":N.add(L);break;case"readOnly":P.add(L),E.delete(L);break;case"editable":E.add(L),P.delete(L);break}}}e.forEach(M=>{M.conditions&&M.conditions.forEach(z=>{(y(z.when)?z.then:z.else||[]).forEach(L=>{switch(L.action){case"disableForm":C=!0;break;case"enableForm":C=!1;break;default:{const B=p(L.target,M);switch(L.action){case"show":N.add(B);break;case"hide":N.delete(B);break;case"enable":k.add(B);break;case"disable":k.delete(B);break;case"require":T.add(B);break;case"unrequire":T.delete(B);break}break}}})})});const I=M=>e.filter(z=>z.type!=="editButton"&&(z.name||z.key||z.id)).map(z=>l(z)),W=()=>e.filter(M=>M.type==="button").map(M=>l(M));return e.forEach(M=>{if(M.type!=="editButton")return;const z=l(M);if(!Qo(r?.[z]))return;const V=M.properties;V?.rules&&V.rules.length>0?V.rules.forEach(X=>{const L=[];X.allFields&&L.push(...I(M.id)),X.allButtons&&L.push(...W()),X.fieldNames?.length&&X.fieldNames.forEach(B=>{const D=e.find(K=>l(K)===B||K.id===B||K.name===B);L.push(D?l(D):B)}),X.buttonNames?.length&&L.push(...X.buttonNames),L.forEach(B=>{switch(X.action){case"enable":k.add(B),P.delete(B);break;case"disable":k.delete(B);break;case"show":N.add(B);break;case"hide":N.delete(B);break;case"readOnly":P.add(B);break;case"editable":E.add(B);break}})}):((V?.enableFieldNames??[]).forEach(X=>k.add(X)),(V?.disableFieldNames??[]).forEach(X=>k.delete(X)),(V?.showFieldNames??[]).forEach(X=>N.add(X)),(V?.hideFieldNames??[]).forEach(X=>N.delete(X)))}),{visible:Array.from(N),enabled:Array.from(k),required:Array.from(T),readOnly:Array.from(P),editable:Array.from(E),formDisabled:C}},[e,y,l,p,t,r,n,o]),w=v.useMemo(()=>S(),[S]);v.useLayoutEffect(()=>{s(w.visible),i(w.enabled),a(w.required),c(w.readOnly??[]),u(w.editable??[]),f(w.formDisabled??!1)},[w,s,i,a,c,u,f]);const A=v.useCallback(N=>w.visible.includes(N),[w.visible]),x=v.useCallback(N=>w.enabled.includes(N),[w.enabled]),F=v.useCallback(N=>w.required.includes(N),[w.required]);return{evaluateCondition:y,evaluateExpression:m,evaluateGroup:h,isFieldVisible:A,isFieldEnabled:x,isFieldRequired:F,visibleFields:w.visible,enabledFields:w.enabled,requiredFields:w.required}}function mn({className:e,type:t,...r}){return d.jsx("input",{type:t,"data-slot":"input",className:H("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground text-foreground dark:bg-secondary dark:border-input border-input flex h-9 w-full min-w-0 rounded-md border bg-background px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...r})}function Lu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function qn(...e){return t=>{let r=!1;const n=e.map(o=>{const s=Lu(o,t);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let o=0;o<n.length;o++){const s=n[o];typeof s=="function"?s():Lu(e[o],null)}}}}function Qe(...e){return b.useCallback(qn(...e),e)}var Iw=Symbol.for("react.lazy"),ei=b[" use ".trim().toString()];function Mw(e){return typeof e=="object"&&e!==null&&"then"in e}function Du(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Iw&&"_payload"in e&&Mw(e._payload)}function cl(e){const t=Lw(e),r=b.forwardRef((n,o)=>{let{children:s,...i}=n;Du(s)&&typeof ei=="function"&&(s=ei(s._payload));const a=b.Children.toArray(s),c=a.find(Bw);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}var Bu=cl("Slot");function Lw(e){const t=b.forwardRef((r,n)=>{let{children:o,...s}=r;if(Du(o)&&typeof ei=="function"&&(o=ei(o._payload)),b.isValidElement(o)){const i=jw(o),a=$w(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Dw=Symbol("radix.slottable");function Bw(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Dw}function $w(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function jw(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var zw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Uw=zw.reduce((e,t)=>{const r=cl(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Vw="Label",$u=b.forwardRef((e,t)=>d.jsx(Uw.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));$u.displayName=Vw;var Hw=$u;function Fn({className:e,...t}){return d.jsx(Hw,{"data-slot":"label",className:H("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50 mb-2",e),...t})}function ft(e){return`formsmith-field-${e.id}`}function ti(e){return`formsmith-label-${e.id}`}function Zo(e){return`formsmith-desc-${e.id}`}function es(e){return`formsmith-error-${e.id}`}function Lt(e,t){const r=[];return e.description&&r.push(Zo(e)),t&&r.push(es(e)),r.length>0?r.join(" "):void 0}function Jt(e){return e?!0:void 0}const Ww={body:{fontSize:"0.875rem",lineHeight:"1.25rem",fontWeight:400},heading:{fontSize:"1.125rem",lineHeight:"1.5rem",fontWeight:600},label:{fontSize:"0.875rem",lineHeight:"1.25rem",fontWeight:500},caption:{fontSize:"0.75rem",lineHeight:"1rem",fontWeight:400,color:"var(--muted-foreground)"}};function Pn(e){return e.ui?.cellStyle}function Rw(e){const t=e.ui;if(!t)return;const r=t.fontToken?Ww[t.fontToken]:void 0;if(!(!r&&!t.wrapperStyle))return{...r,...t.wrapperStyle}}function Gw(e){return e.type==="button"||e.type==="editButton"}const At=({field:e,error:t,isRequired:r,children:n,className:o,hideLabel:s})=>{const{gridStretch:i}=Jo(),a=i&&Ks(e),c=!(s??e.appearance?.hideLabel)&&e.label,u=e.appearance?.labelPlacement||"top",f=Rw(e),l=e.appearance?.minWidth!=null||e.appearance?.minHeight!=null?{...e.appearance.minWidth!=null?{minWidth:e.appearance.minWidth}:{},...e.appearance.minHeight!=null?{minHeight:e.appearance.minHeight}:{}}:void 0,p=e.appearance?.className,g=ou(e),m=fo(e),h=Gw(e),y=Fr(e.appearance);return d.jsx("div",{className:H($v(u),u!=="floating"&&"space-y-2",a&&!h&&"flex-1 min-h-0 h-full",i&&h&&"w-full shrink-0 self-start",p,o),style:f,"data-field-appearance":u,children:d.jsxs("div",{className:H("flex flex-col min-w-0",eu(e.appearance),su(e),a&&!h&&"flex-1 min-h-0",i&&h&&"shrink-0"),style:g,children:[c&&d.jsxs(Fn,{id:ti(e),htmlFor:ft(e),style:e.ui?.labelStyle,className:H(jv(u,!!t)),children:[e.label,r&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),d.jsxs("div",{className:H(zv(u),h&&i&&"min-h-min !grow-0 !shrink-0 basis-auto",m&&y!=="stretch"&&"items-start",h&&y==="stretch"&&"items-start w-full [&_button]:w-full",!h&&y==="stretch"&&"items-stretch",a&&!h&&"flex-1 min-h-0",o?.includes("flex")&&u==="top"&&"flex flex-col min-h-0"),style:l,children:[n,d.jsxs("div",{className:H("mt-1.5 min-h-[18px]",u==="center"&&"text-center",o?.includes("flex")&&"shrink-0"),children:[e.description&&!t&&d.jsx("p",{id:Zo(e),className:"text-xs text-muted-foreground",style:e.ui?.descriptionStyle,children:e.description}),t&&d.jsx("p",{id:es(e),className:"text-xs text-destructive",role:"alert",children:typeof t=="string"?t:String(t||"An error occurred")})]})]})]})})},ri=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=v.useCallback(l=>{r(l.target.value)},[r]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsx(mn,{id:ft(e),type:"text",value:t||"",onChange:f,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,minLength:u?.minLength,maxLength:u?.maxLength,pattern:u?.pattern,autoComplete:u?.autoComplete,inputMode:u?.inputMode,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})})},dl=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=u?.precision!=null||u?.step!=null&&!Number.isInteger(u.step),l=v.useCallback(g=>{const m=u?.allowNegative!==!1,h=g.target.value,y=f?h.replace(m?/[^\d.-]/g:/[^\d.]/g,""):h.replace(m?/[^\d-]/g:/\D/g,"");if(y===""){r(null);return}const S=parseFloat(y);isNaN(S)||r(S)},[r,u?.allowNegative,f]),p=v.useCallback(g=>{(g.key==="ArrowUp"||g.key==="ArrowDown"||g.key==="PageUp"||g.key==="PageDown")&&g.preventDefault()},[]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[u?.prefix&&d.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.prefix}),d.jsx(mn,{id:ft(e),type:"text",inputMode:f?"decimal":"numeric",autoComplete:"off",value:t??"",onChange:l,onKeyDown:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",u?.prefix&&"pl-8",u?.suffix&&"pr-8",e.appearance?.className)}),u?.suffix&&d.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.suffix})]})})};const Kw=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),qw=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),ju=e=>{const t=qw(e);return t.charAt(0).toUpperCase()+t.slice(1)},zu=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),Yw=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Xw={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Jw=v.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:s,iconNode:i,...a},c)=>v.createElement("svg",{ref:c,...Xw,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:zu("lucide",o),...!s&&!Yw(a)&&{"aria-hidden":"true"},...a},[...i.map(([u,f])=>v.createElement(u,f)),...Array.isArray(s)?s:[s]]));const qt=(e,t)=>{const r=v.forwardRef(({className:n,...o},s)=>v.createElement(Jw,{ref:s,iconNode:t,className:zu(`lucide-${Kw(ju(e))}`,`lucide-${e}`,n),...o}));return r.displayName=ju(e),r};const Qw=qt("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const ni=qt("camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);const oi=qt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const ts=qt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Uu=qt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Zw=qt("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const eS=qt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const Vu=qt("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Hu=qt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Wu=qt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const mo=qt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const tS=qt("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const rS=qt("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);const Ru=qt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const nS=qt("sliders-horizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);const Gu=qt("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);const rs=qt("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const si=qt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const ns=qt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Ku=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=v.useCallback(f=>{r(f.target.value)},[r]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[d.jsx(tS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),d.jsx(mn,{id:ft(e),type:"email",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"email@example.com",disabled:s||e.disabled,readOnly:i||e.readOnly,autoComplete:"email",inputMode:"email","aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})},qu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=v.useCallback(f=>{const l=f.target.value.replace(/[^\d\s+\-()]/g,"");r(l)},[r]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[d.jsx(rS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),d.jsx(mn,{id:ft(e),type:"tel",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"+91 12345 67890",disabled:s||e.disabled,readOnly:i||e.readOnly,autoComplete:"tel",inputMode:"tel","aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})};function Yu(e,t){return function(){return e.apply(t,arguments)}}const{toString:oS}=Object.prototype,{getPrototypeOf:ul}=Object,{iterator:ii,toStringTag:Xu}=Symbol,ai=(e=>t=>{const r=oS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Rr=e=>(e=e.toLowerCase(),t=>ai(t)===e),li=e=>t=>typeof t===e,{isArray:ho}=Array,go=li("undefined");function os(e){return e!==null&&!go(e)&&e.constructor!==null&&!go(e.constructor)&&pr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ju=Rr("ArrayBuffer");function sS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ju(e.buffer),t}const iS=li("string"),pr=li("function"),Qu=li("number"),ss=e=>e!==null&&typeof e=="object",aS=e=>e===!0||e===!1,ci=e=>{if(ai(e)!=="object")return!1;const t=ul(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Xu in e)&&!(ii in e)},lS=e=>{if(!ss(e)||os(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},cS=Rr("Date"),dS=Rr("File"),uS=e=>!!(e&&typeof e.uri<"u"),fS=e=>e&&typeof e.getParts<"u",pS=Rr("Blob"),mS=Rr("FileList"),hS=e=>ss(e)&&pr(e.pipe);function gS(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Zu=gS(),ef=typeof Zu.FormData<"u"?Zu.FormData:void 0,yS=e=>{let t;return e&&(ef&&e instanceof ef||pr(e.append)&&((t=ai(e))==="formdata"||t==="object"&&pr(e.toString)&&e.toString()==="[object FormData]"))},bS=Rr("URLSearchParams"),[vS,wS,SS,xS]=["ReadableStream","Request","Response","Headers"].map(Rr),AS=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function is(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),ho(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(os(e))return;const s=r?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(n=0;n<i;n++)a=s[n],t.call(null,e[a],a,e)}}function tf(e,t){if(os(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}const Yn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,rf=e=>!go(e)&&e!==Yn;function fl(){const{caseless:e,skipUndefined:t}=rf(this)&&this||{},r={},n=(o,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;const i=e&&tf(r,s)||s;ci(r[i])&&ci(o)?r[i]=fl(r[i],o):ci(o)?r[i]=fl({},o):ho(o)?r[i]=o.slice():(!t||!go(o))&&(r[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&is(arguments[o],n);return r}const CS=(e,t,r,{allOwnKeys:n}={})=>(is(t,(o,s)=>{r&&pr(o)?Object.defineProperty(e,s,{value:Yu(o,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,s,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),ES=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),NS=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},kS=(e,t,r,n)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!n||n(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=r!==!1&&ul(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},_S=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},TS=e=>{if(!e)return null;if(ho(e))return e;let t=e.length;if(!Qu(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},FS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ul(Uint8Array)),PS=(e,t)=>{const n=(e&&e[ii]).call(e);let o;for(;(o=n.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},OS=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},IS=Rr("HTMLFormElement"),MS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),nf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),LS=Rr("RegExp"),of=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};is(r,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(n[s]=i||o)}),Object.defineProperties(e,n)},DS=e=>{of(e,(t,r)=>{if(pr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(pr(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},BS=(e,t)=>{const r={},n=o=>{o.forEach(s=>{r[s]=!0})};return ho(e)?n(e):n(String(e).split(t)),r},$S=()=>{},jS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function zS(e){return!!(e&&pr(e.append)&&e[Xu]==="FormData"&&e[ii])}const US=e=>{const t=new Array(10),r=(n,o)=>{if(ss(n)){if(t.indexOf(n)>=0)return;if(os(n))return n;if(!("toJSON"in n)){t[o]=n;const s=ho(n)?[]:{};return is(n,(i,a)=>{const c=r(i,o+1);!go(c)&&(s[a]=c)}),t[o]=void 0,s}}return n};return r(e,0)},VS=Rr("AsyncFunction"),HS=e=>e&&(ss(e)||pr(e))&&pr(e.then)&&pr(e.catch),sf=((e,t)=>e?setImmediate:t?((r,n)=>(Yn.addEventListener("message",({source:o,data:s})=>{o===Yn&&s===r&&n.length&&n.shift()()},!1),o=>{n.push(o),Yn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",pr(Yn.postMessage)),WS=typeof queueMicrotask<"u"?queueMicrotask.bind(Yn):typeof process<"u"&&process.nextTick||sf,Y={isArray:ho,isArrayBuffer:Ju,isBuffer:os,isFormData:yS,isArrayBufferView:sS,isString:iS,isNumber:Qu,isBoolean:aS,isObject:ss,isPlainObject:ci,isEmptyObject:lS,isReadableStream:vS,isRequest:wS,isResponse:SS,isHeaders:xS,isUndefined:go,isDate:cS,isFile:dS,isReactNativeBlob:uS,isReactNative:fS,isBlob:pS,isRegExp:LS,isFunction:pr,isStream:hS,isURLSearchParams:bS,isTypedArray:FS,isFileList:mS,forEach:is,merge:fl,extend:CS,trim:AS,stripBOM:ES,inherits:NS,toFlatObject:kS,kindOf:ai,kindOfTest:Rr,endsWith:_S,toArray:TS,forEachEntry:PS,matchAll:OS,isHTMLForm:IS,hasOwnProperty:nf,hasOwnProp:nf,reduceDescriptors:of,freezeMethods:DS,toObjectSet:BS,toCamelCase:MS,noop:$S,toFiniteNumber:jS,findKey:tf,global:Yn,isContextDefined:rf,isSpecCompliantForm:zS,toJSONObject:US,isAsyncFn:VS,isThenable:HS,setImmediate:sf,asap:WS,isIterable:e=>e!=null&&pr(e[ii])};let qe=class Gb extends Error{static from(t,r,n,o,s,i){const a=new Gb(t.message,r||t.code,n,o,s);return a.cause=t,a.name=t.name,t.status!=null&&a.status==null&&(a.status=t.status),i&&Object.assign(a,i),a}constructor(t,r,n,o,s){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),n&&(this.config=n),o&&(this.request=o),s&&(this.response=s,this.status=s.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Y.toJSONObject(this.config),code:this.code,status:this.status}}};qe.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",qe.ERR_BAD_OPTION="ERR_BAD_OPTION",qe.ECONNABORTED="ECONNABORTED",qe.ETIMEDOUT="ETIMEDOUT",qe.ERR_NETWORK="ERR_NETWORK",qe.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",qe.ERR_DEPRECATED="ERR_DEPRECATED",qe.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",qe.ERR_BAD_REQUEST="ERR_BAD_REQUEST",qe.ERR_CANCELED="ERR_CANCELED",qe.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",qe.ERR_INVALID_URL="ERR_INVALID_URL";const RS=null;function pl(e){return Y.isPlainObject(e)||Y.isArray(e)}function af(e){return Y.endsWith(e,"[]")?e.slice(0,-2):e}function ml(e,t,r){return e?e.concat(t).map(function(o,s){return o=af(o),!r&&s?"["+o+"]":o}).join(r?".":""):t}function GS(e){return Y.isArray(e)&&!e.some(pl)}const KS=Y.toFlatObject(Y,{},null,function(t){return/^is[A-Z]/.test(t)});function di(e,t,r){if(!Y.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=Y.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,y){return!Y.isUndefined(y[h])});const n=r.metaTokens,o=r.visitor||f,s=r.dots,i=r.indexes,c=(r.Blob||typeof Blob<"u"&&Blob)&&Y.isSpecCompliantForm(t);if(!Y.isFunction(o))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(Y.isDate(m))return m.toISOString();if(Y.isBoolean(m))return m.toString();if(!c&&Y.isBlob(m))throw new qe("Blob is not supported. Use a Buffer instead.");return Y.isArrayBuffer(m)||Y.isTypedArray(m)?c&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function f(m,h,y){let S=m;if(Y.isReactNative(t)&&Y.isReactNativeBlob(m))return t.append(ml(y,h,s),u(m)),!1;if(m&&!y&&typeof m=="object"){if(Y.endsWith(h,"{}"))h=n?h:h.slice(0,-2),m=JSON.stringify(m);else if(Y.isArray(m)&&GS(m)||(Y.isFileList(m)||Y.endsWith(h,"[]"))&&(S=Y.toArray(m)))return h=af(h),S.forEach(function(A,x){!(Y.isUndefined(A)||A===null)&&t.append(i===!0?ml([h],x,s):i===null?h:h+"[]",u(A))}),!1}return pl(m)?!0:(t.append(ml(y,h,s),u(m)),!1)}const l=[],p=Object.assign(KS,{defaultVisitor:f,convertValue:u,isVisitable:pl});function g(m,h){if(!Y.isUndefined(m)){if(l.indexOf(m)!==-1)throw Error("Circular reference detected in "+h.join("."));l.push(m),Y.forEach(m,function(S,w){(!(Y.isUndefined(S)||S===null)&&o.call(t,S,Y.isString(w)?w.trim():w,h,p))===!0&&g(S,h?h.concat(w):[w])}),l.pop()}}if(!Y.isObject(e))throw new TypeError("data must be an object");return g(e),t}function lf(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function hl(e,t){this._pairs=[],e&&di(e,this,t)}const cf=hl.prototype;cf.append=function(t,r){this._pairs.push([t,r])},cf.toString=function(t){const r=t?function(n){return t.call(this,n,lf)}:lf;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function qS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function df(e,t,r){if(!t)return e;const n=r&&r.encode||qS,o=Y.isFunction(r)?{serialize:r}:r,s=o&&o.serialize;let i;if(s?i=s(t,o):i=Y.isURLSearchParams(t)?t.toString():new hl(t,o).toString(n),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class uf{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Y.forEach(this.handlers,function(n){n!==null&&t(n)})}}const gl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},YS={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:hl,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},yl=typeof window<"u"&&typeof document<"u",bl=typeof navigator=="object"&&navigator||void 0,XS=yl&&(!bl||["ReactNative","NativeScript","NS"].indexOf(bl.product)<0),JS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",QS=yl&&window.location.href||"http://localhost",sr={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yl,hasStandardBrowserEnv:XS,hasStandardBrowserWebWorkerEnv:JS,navigator:bl,origin:QS},Symbol.toStringTag,{value:"Module"})),...YS};function ZS(e,t){return di(e,new sr.classes.URLSearchParams,{visitor:function(r,n,o,s){return sr.isNode&&Y.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function e0(e){return Y.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function t0(e){const t={},r=Object.keys(e);let n;const o=r.length;let s;for(n=0;n<o;n++)s=r[n],t[s]=e[s];return t}function ff(e){function t(r,n,o,s){let i=r[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),c=s>=r.length;return i=!i&&Y.isArray(o)?o.length:i,c?(Y.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!a):((!o[i]||!Y.isObject(o[i]))&&(o[i]=[]),t(r,n,o[i],s)&&Y.isArray(o[i])&&(o[i]=t0(o[i])),!a)}if(Y.isFormData(e)&&Y.isFunction(e.entries)){const r={};return Y.forEachEntry(e,(n,o)=>{t(e0(n),o,r,0)}),r}return null}function r0(e,t,r){if(Y.isString(e))try{return(t||JSON.parse)(e),Y.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const as={transitional:gl,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",o=n.indexOf("application/json")>-1,s=Y.isObject(t);if(s&&Y.isHTMLForm(t)&&(t=new FormData(t)),Y.isFormData(t))return o?JSON.stringify(ff(t)):t;if(Y.isArrayBuffer(t)||Y.isBuffer(t)||Y.isStream(t)||Y.isFile(t)||Y.isBlob(t)||Y.isReadableStream(t))return t;if(Y.isArrayBufferView(t))return t.buffer;if(Y.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return ZS(t,this.formSerializer).toString();if((a=Y.isFileList(t))||n.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return di(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(r.setContentType("application/json",!1),r0(t)):t}],transformResponse:[function(t){const r=this.transitional||as.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(Y.isResponse(t)||Y.isReadableStream(t))return t;if(t&&Y.isString(t)&&(n&&!this.responseType||o)){const i=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?qe.from(a,qe.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:sr.classes.FormData,Blob:sr.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Y.forEach(["delete","get","head","post","put","patch"],e=>{as.headers[e]={}});const n0=Y.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),o0=e=>{const t={};let r,n,o;return e&&e.split(`
2
- `).forEach(function(i){o=i.indexOf(":"),r=i.substring(0,o).trim().toLowerCase(),n=i.substring(o+1).trim(),!(!r||t[r]&&n0[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},pf=Symbol("internals");function ls(e){return e&&String(e).trim().toLowerCase()}function ui(e){return e===!1||e==null?e:Y.isArray(e)?e.map(ui):String(e).replace(/[\r\n]+$/,"")}function s0(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const i0=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function vl(e,t,r,n,o){if(Y.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!Y.isString(t)){if(Y.isString(n))return t.indexOf(n)!==-1;if(Y.isRegExp(n))return n.test(t)}}function a0(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function l0(e,t){const r=Y.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(o,s,i){return this[n].call(this,t,o,s,i)},configurable:!0})})}let mr=class{constructor(t){t&&this.set(t)}set(t,r,n){const o=this;function s(a,c,u){const f=ls(c);if(!f)throw new Error("header name must be a non-empty string");const l=Y.findKey(o,f);(!l||o[l]===void 0||u===!0||u===void 0&&o[l]!==!1)&&(o[l||c]=ui(a))}const i=(a,c)=>Y.forEach(a,(u,f)=>s(u,f,c));if(Y.isPlainObject(t)||t instanceof this.constructor)i(t,r);else if(Y.isString(t)&&(t=t.trim())&&!i0(t))i(o0(t),r);else if(Y.isObject(t)&&Y.isIterable(t)){let a={},c,u;for(const f of t){if(!Y.isArray(f))throw TypeError("Object iterator must return a key-value pair");a[u=f[0]]=(c=a[u])?Y.isArray(c)?[...c,f[1]]:[c,f[1]]:f[1]}i(a,r)}else t!=null&&s(r,t,n);return this}get(t,r){if(t=ls(t),t){const n=Y.findKey(this,t);if(n){const o=this[n];if(!r)return o;if(r===!0)return s0(o);if(Y.isFunction(r))return r.call(this,o,n);if(Y.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=ls(t),t){const n=Y.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||vl(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let o=!1;function s(i){if(i=ls(i),i){const a=Y.findKey(n,i);a&&(!r||vl(n,n[a],a,r))&&(delete n[a],o=!0)}}return Y.isArray(t)?t.forEach(s):s(t),o}clear(t){const r=Object.keys(this);let n=r.length,o=!1;for(;n--;){const s=r[n];(!t||vl(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const r=this,n={};return Y.forEach(this,(o,s)=>{const i=Y.findKey(n,s);if(i){r[i]=ui(o),delete r[s];return}const a=t?a0(s):String(s).trim();a!==s&&delete r[s],r[a]=ui(o),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return Y.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&Y.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
3
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){const n=(this[pf]=this[pf]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=ls(i);n[a]||(l0(o,i),n[a]=!0)}return Y.isArray(t)?t.forEach(s):s(t),this}};mr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Y.reduceDescriptors(mr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),Y.freezeMethods(mr);function wl(e,t){const r=this||as,n=t||r,o=mr.from(n.headers);let s=n.data;return Y.forEach(e,function(a){s=a.call(r,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function mf(e){return!!(e&&e.__CANCEL__)}let cs=class extends qe{constructor(t,r,n){super(t??"canceled",qe.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function hf(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new qe("Request failed with status code "+r.status,[qe.ERR_BAD_REQUEST,qe.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function c0(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function d0(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),f=n[s];i||(i=u),r[o]=c,n[o]=u;let l=s,p=0;for(;l!==o;)p+=r[l++],l=l%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const g=f&&u-f;return g?Math.round(p*1e3/g):void 0}}function u0(e,t){let r=0,n=1e3/t,o,s;const i=(u,f=Date.now())=>{r=f,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const f=Date.now(),l=f-r;l>=n?i(u,f):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},n-l)))},()=>o&&i(o)]}const fi=(e,t,r=3)=>{let n=0;const o=d0(50,250);return u0(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-n,u=o(c),f=i<=a;n=i;const l={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&f?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(l)},r)},gf=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},yf=e=>(...t)=>Y.asap(()=>e(...t)),f0=sr.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,sr.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(sr.origin),sr.navigator&&/(msie|trident)/i.test(sr.navigator.userAgent)):()=>!0,p0=sr.hasStandardBrowserEnv?{write(e,t,r,n,o,s,i){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];Y.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),Y.isString(n)&&a.push(`path=${n}`),Y.isString(o)&&a.push(`domain=${o}`),s===!0&&a.push("secure"),Y.isString(i)&&a.push(`SameSite=${i}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function m0(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function h0(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function bf(e,t,r){let n=!m0(t);return e&&(n||r==!1)?h0(e,t):t}const vf=e=>e instanceof mr?{...e}:e;function Xn(e,t){t=t||{};const r={};function n(u,f,l,p){return Y.isPlainObject(u)&&Y.isPlainObject(f)?Y.merge.call({caseless:p},u,f):Y.isPlainObject(f)?Y.merge({},f):Y.isArray(f)?f.slice():f}function o(u,f,l,p){if(Y.isUndefined(f)){if(!Y.isUndefined(u))return n(void 0,u,l,p)}else return n(u,f,l,p)}function s(u,f){if(!Y.isUndefined(f))return n(void 0,f)}function i(u,f){if(Y.isUndefined(f)){if(!Y.isUndefined(u))return n(void 0,u)}else return n(void 0,f)}function a(u,f,l){if(l in t)return n(u,f);if(l in e)return n(void 0,u)}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,f,l)=>o(vf(u),vf(f),l,!0)};return Y.forEach(Object.keys({...e,...t}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;const l=Y.hasOwnProp(c,f)?c[f]:o,p=l(e[f],t[f],f);Y.isUndefined(p)&&l!==a||(r[f]=p)}),r}const wf=e=>{const t=Xn({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=mr.from(i),t.url=df(bf(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Y.isFormData(r)){if(sr.hasStandardBrowserEnv||sr.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(Y.isFunction(r.getHeaders)){const c=r.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([f,l])=>{u.includes(f.toLowerCase())&&i.set(f,l)})}}if(sr.hasStandardBrowserEnv&&(n&&Y.isFunction(n)&&(n=n(t)),n||n!==!1&&f0(t.url))){const c=o&&s&&p0.read(s);c&&i.set(o,c)}return t},g0=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=wf(e);let s=o.data;const i=mr.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,f,l,p,g,m;function h(){g&&g(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(f),o.signal&&o.signal.removeEventListener("abort",f)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function S(){if(!y)return;const A=mr.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),F={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:A,config:e,request:y};hf(function(k){r(k),h()},function(k){n(k),h()},F),y=null}"onloadend"in y?y.onloadend=S:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(S)},y.onabort=function(){y&&(n(new qe("Request aborted",qe.ECONNABORTED,e,y)),y=null)},y.onerror=function(x){const F=x&&x.message?x.message:"Network Error",N=new qe(F,qe.ERR_NETWORK,e,y);N.event=x||null,n(N),y=null},y.ontimeout=function(){let x=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const F=o.transitional||gl;o.timeoutErrorMessage&&(x=o.timeoutErrorMessage),n(new qe(x,F.clarifyTimeoutError?qe.ETIMEDOUT:qe.ECONNABORTED,e,y)),y=null},s===void 0&&i.setContentType(null),"setRequestHeader"in y&&Y.forEach(i.toJSON(),function(x,F){y.setRequestHeader(F,x)}),Y.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),u&&([p,m]=fi(u,!0),y.addEventListener("progress",p)),c&&y.upload&&([l,g]=fi(c),y.upload.addEventListener("progress",l),y.upload.addEventListener("loadend",g)),(o.cancelToken||o.signal)&&(f=A=>{y&&(n(!A||A.type?new cs(null,e,y):A),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(f),o.signal&&(o.signal.aborted?f():o.signal.addEventListener("abort",f)));const w=c0(o.url);if(w&&sr.protocols.indexOf(w)===-1){n(new qe("Unsupported protocol "+w+":",qe.ERR_BAD_REQUEST,e));return}y.send(s||null)})},y0=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,o;const s=function(u){if(!o){o=!0,a();const f=u instanceof Error?u:this.reason;n.abort(f instanceof qe?f:new cs(f instanceof Error?f.message:f))}};let i=t&&setTimeout(()=>{i=null,s(new qe(`timeout of ${t}ms exceeded`,qe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:c}=n;return c.unsubscribe=()=>Y.asap(a),c}},b0=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,o;for(;n<r;)o=n+t,yield e.slice(n,o),n=o},v0=async function*(e,t){for await(const r of w0(e))yield*b0(r,t)},w0=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},Sf=(e,t,r,n)=>{const o=v0(e,t);let s=0,i,a=c=>{i||(i=!0,n&&n(c))};return new ReadableStream({async pull(c){try{const{done:u,value:f}=await o.next();if(u){a(),c.close();return}let l=f.byteLength;if(r){let p=s+=l;r(p)}c.enqueue(new Uint8Array(f))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},xf=64*1024,{isFunction:pi}=Y,S0=(({Request:e,Response:t})=>({Request:e,Response:t}))(Y.global),{ReadableStream:Af,TextEncoder:Cf}=Y.global,Ef=(e,...t)=>{try{return!!e(...t)}catch{return!1}},x0=e=>{e=Y.merge.call({skipUndefined:!0},S0,e);const{fetch:t,Request:r,Response:n}=e,o=t?pi(t):typeof fetch=="function",s=pi(r),i=pi(n);if(!o)return!1;const a=o&&pi(Af),c=o&&(typeof Cf=="function"?(m=>h=>m.encode(h))(new Cf):async m=>new Uint8Array(await new r(m).arrayBuffer())),u=s&&a&&Ef(()=>{let m=!1;const h=new Af,y=new r(sr.origin,{body:h,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return h.cancel(),m&&!y}),f=i&&a&&Ef(()=>Y.isReadableStream(new n("").body)),l={stream:f&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!l[m]&&(l[m]=(h,y)=>{let S=h&&h[m];if(S)return S.call(h);throw new qe(`Response type '${m}' is not supported`,qe.ERR_NOT_SUPPORT,y)})});const p=async m=>{if(m==null)return 0;if(Y.isBlob(m))return m.size;if(Y.isSpecCompliantForm(m))return(await new r(sr.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(Y.isArrayBufferView(m)||Y.isArrayBuffer(m))return m.byteLength;if(Y.isURLSearchParams(m)&&(m=m+""),Y.isString(m))return(await c(m)).byteLength},g=async(m,h)=>{const y=Y.toFiniteNumber(m.getContentLength());return y??p(h)};return async m=>{let{url:h,method:y,data:S,signal:w,cancelToken:A,timeout:x,onDownloadProgress:F,onUploadProgress:N,responseType:k,headers:T,withCredentials:P="same-origin",fetchOptions:E}=wf(m),C=t||fetch;k=k?(k+"").toLowerCase():"text";let I=y0([w,A&&A.toAbortSignal()],x),W=null;const M=I&&I.unsubscribe&&(()=>{I.unsubscribe()});let z;try{if(N&&u&&y!=="get"&&y!=="head"&&(z=await g(T,S))!==0){let K=new r(h,{method:"POST",body:S,duplex:"half"}),ae;if(Y.isFormData(S)&&(ae=K.headers.get("content-type"))&&T.setContentType(ae),K.body){const[j,U]=gf(z,fi(yf(N)));S=Sf(K.body,xf,j,U)}}Y.isString(P)||(P=P?"include":"omit");const V=s&&"credentials"in r.prototype,X={...E,signal:I,method:y.toUpperCase(),headers:T.normalize().toJSON(),body:S,duplex:"half",credentials:V?P:void 0};W=s&&new r(h,X);let L=await(s?C(W,E):C(h,X));const B=f&&(k==="stream"||k==="response");if(f&&(F||B&&M)){const K={};["status","statusText","headers"].forEach(le=>{K[le]=L[le]});const ae=Y.toFiniteNumber(L.headers.get("content-length")),[j,U]=F&&gf(ae,fi(yf(F),!0))||[];L=new n(Sf(L.body,xf,j,()=>{U&&U(),M&&M()}),K)}k=k||"text";let D=await l[Y.findKey(l,k)||"text"](L,m);return!B&&M&&M(),await new Promise((K,ae)=>{hf(K,ae,{data:D,headers:mr.from(L.headers),status:L.status,statusText:L.statusText,config:m,request:W})})}catch(V){throw M&&M(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new qe("Network Error",qe.ERR_NETWORK,m,W,V&&V.response),{cause:V.cause||V}):qe.from(V,V&&V.code,m,W,V&&V.response)}}},A0=new Map,Nf=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:o}=t,s=[n,o,r];let i=s.length,a=i,c,u,f=A0;for(;a--;)c=s[a],u=f.get(c),u===void 0&&f.set(c,u=a?new Map:x0(t)),f=u;return u};Nf();const Sl={http:RS,xhr:g0,fetch:{get:Nf}};Y.forEach(Sl,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const kf=e=>`- ${e}`,C0=e=>Y.isFunction(e)||e===null||e===!1;function E0(e,t){e=Y.isArray(e)?e:[e];const{length:r}=e;let n,o;const s={};for(let i=0;i<r;i++){n=e[i];let a;if(o=n,!C0(n)&&(o=Sl[(a=String(n)).toLowerCase()],o===void 0))throw new qe(`Unknown adapter '${a}'`);if(o&&(Y.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=r?i.length>1?`since :
4
- `+i.map(kf).join(`
5
- `):" "+kf(i[0]):"as no adapter specified";throw new qe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o}const _f={getAdapter:E0,adapters:Sl};function xl(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new cs(null,e)}function Tf(e){return xl(e),e.headers=mr.from(e.headers),e.data=wl.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),_f.getAdapter(e.adapter||as.adapter,e)(e).then(function(n){return xl(e),n.data=wl.call(e,e.transformResponse,n),n.headers=mr.from(n.headers),n},function(n){return mf(n)||(xl(e),n&&n.response&&(n.response.data=wl.call(e,e.transformResponse,n.response),n.response.headers=mr.from(n.response.headers))),Promise.reject(n)})}const Ff="1.14.0",mi={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{mi[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Pf={};mi.transitional=function(t,r,n){function o(s,i){return"[Axios v"+Ff+"] Transitional option '"+s+"'"+i+(n?". "+n:"")}return(s,i,a)=>{if(t===!1)throw new qe(o(i," has been removed"+(r?" in "+r:"")),qe.ERR_DEPRECATED);return r&&!Pf[i]&&(Pf[i]=!0,console.warn(o(i," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(s,i,a):!0}},mi.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function N0(e,t,r){if(typeof e!="object")throw new qe("options must be an object",qe.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const s=n[o],i=t[s];if(i){const a=e[s],c=a===void 0||i(a,s,e);if(c!==!0)throw new qe("option "+s+" must be "+c,qe.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new qe("Unknown option "+s,qe.ERR_BAD_OPTION)}}const hi={assertOptions:N0,validators:mi},Ir=hi.validators;let Jn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new uf,response:new uf}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
6
- `+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Xn(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&hi.assertOptions(n,{silentJSONParsing:Ir.transitional(Ir.boolean),forcedJSONParsing:Ir.transitional(Ir.boolean),clarifyTimeoutError:Ir.transitional(Ir.boolean),legacyInterceptorReqResOrdering:Ir.transitional(Ir.boolean)},!1),o!=null&&(Y.isFunction(o)?r.paramsSerializer={serialize:o}:hi.assertOptions(o,{encode:Ir.function,serialize:Ir.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),hi.assertOptions(r,{baseUrl:Ir.spelling("baseURL"),withXsrfToken:Ir.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&Y.merge(s.common,s[r.method]);s&&Y.forEach(["delete","get","head","post","put","patch","common"],m=>{delete s[m]}),r.headers=mr.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(r)===!1)return;c=c&&h.synchronous;const y=r.transitional||gl;y&&y.legacyInterceptorReqResOrdering?a.unshift(h.fulfilled,h.rejected):a.push(h.fulfilled,h.rejected)});const u=[];this.interceptors.response.forEach(function(h){u.push(h.fulfilled,h.rejected)});let f,l=0,p;if(!c){const m=[Tf.bind(this),void 0];for(m.unshift(...a),m.push(...u),p=m.length,f=Promise.resolve(r);l<p;)f=f.then(m[l++],m[l++]);return f}p=a.length;let g=r;for(;l<p;){const m=a[l++],h=a[l++];try{g=m(g)}catch(y){h.call(this,y);break}}try{f=Tf.call(this,g)}catch(m){return Promise.reject(m)}for(l=0,p=u.length;l<p;)f=f.then(u[l++],u[l++]);return f}getUri(t){t=Xn(this.defaults,t);const r=bf(t.baseURL,t.url,t.allowAbsoluteUrls);return df(r,t.params,t.paramsSerializer)}};Y.forEach(["delete","get","head","options"],function(t){Jn.prototype[t]=function(r,n){return this.request(Xn(n||{},{method:t,url:r,data:(n||{}).data}))}}),Y.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,a){return this.request(Xn(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Jn.prototype[t]=r(),Jn.prototype[t+"Form"]=r(!0)});let k0=class Kb{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{n.subscribe(a),s=a}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,a){n.reason||(n.reason=new cs(s,i,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Kb(function(o){t=o}),cancel:t}}};function _0(e){return function(r){return e.apply(null,r)}}function T0(e){return Y.isObject(e)&&e.isAxiosError===!0}const Al={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Al).forEach(([e,t])=>{Al[t]=e});function Of(e){const t=new Jn(e),r=Yu(Jn.prototype.request,t);return Y.extend(r,Jn.prototype,t,{allOwnKeys:!0}),Y.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return Of(Xn(e,o))},r}const Ct=Of(as);Ct.Axios=Jn,Ct.CanceledError=cs,Ct.CancelToken=k0,Ct.isCancel=mf,Ct.VERSION=Ff,Ct.toFormData=di,Ct.AxiosError=qe,Ct.Cancel=Ct.CanceledError,Ct.all=function(t){return Promise.all(t)},Ct.spread=_0,Ct.isAxiosError=T0,Ct.mergeConfig=Xn,Ct.AxiosHeaders=mr,Ct.formToJSON=e=>ff(Y.isHTMLForm(e)?new FormData(e):e),Ct.getAdapter=_f.getAdapter,Ct.HttpStatusCode=Al,Ct.default=Ct;const{Axios:tM,AxiosError:F0,CanceledError:rM,isCancel:nM,CancelToken:oM,VERSION:sM,all:iM,Cancel:aM,isAxiosError:lM,spread:cM,toFormData:dM,AxiosHeaders:uM,HttpStatusCode:fM,formToJSON:pM,getAdapter:mM,mergeConfig:hM}=Ct;let If=null;function P0(e){If=e}function Mf(){return(If?.()??"").replace(/\/+$/,"")}function Mr(e){const t=typeof e=="string"?e.trim():"";if(!t||/^https?:\/\//i.test(t))return t;const r=Mf();return r?t.startsWith("/")?`${r}${t}`:`${r}/${t}`:t}const Lf={};function nn(){const e=Lf?.VITE_CLIENT_ID?.trim()||Lf?.VITE_DEFAULT_CLIENT_ID?.trim()||null;return(typeof localStorage<"u"?localStorage.getItem("clientId"):null)||(typeof sessionStorage<"u"?sessionStorage.getItem("clientId"):null)||(typeof window<"u"?new URLSearchParams(window.location.search).get("clientId"):null)||e}function O0(e){return!e||typeof e!="object"?!1:e.userId!=null&&String(e.userId)!==""||e.userType!=null&&String(e.userType)!==""||e.role!=null&&String(e.role)!==""}function I0(e){if(!e||typeof e!="object")return;const t={};for(const[r,n]of Object.entries(e))n!==void 0&&n!==""&&(t[r]=n);return Object.keys(t).length>0?t:void 0}const Qn=cu(e=>({viewerContext:void 0,authHeaders:void 0,_setViewerContext:t=>e({viewerContext:O0(t)?t:void 0}),_setAuthHeaders:t=>e({authHeaders:I0(t)}),_reset:()=>e({viewerContext:void 0,authHeaders:void 0})}));function M0(e){Qn.getState()._setViewerContext(e)}function L0(e){Qn.getState()._setAuthHeaders(e)}function D0(){Qn.getState()._reset()}function Df(){return Qn.getState().viewerContext}function ds(){return Qn.getState().authHeaders}const Bf={};let $f=null;function B0(e){$f=e}function $0(){return(Bf?.VITE_API_BASE_URL?.trim()||Bf?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const Qt=Ct.create({baseURL:$0()});Qt.interceptors.request.use(e=>{const t=nn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=$f?.();if((!r||Object.keys(r).length===0)&&(r=ds()),r){const n=e.headers??{};for(const[o,s]of Object.entries(r))s!==void 0&&s!==""&&(n[o]=s);e.headers=n}return e});const j0=/^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/i;function jf(e){const t=e.trim().match(j0);return t?t[1]:e}const z0={applicantId:["id","applicant_id"],applicant_id:["id","applicantId"],id:["applicantId","applicant_id"]};function Lr(e,t,r,n,o,s){let i=e;if(o&&typeof e=="string"&&(i=i.replace(/\{resp:([^}]+)\}/g,(a,c)=>{const u=c.trim().split(".");if(u.length<2)return a;const f=u[0],l=u.slice(1).join("."),p=o[f];if(p==null)return a;const g=Ge(p,l);return g==null?a:String(g)}),i.includes("{documentId}")||i.includes("%7BdocumentId%7D"))){let a;for(const c of Object.values(o)){const u=Ge(c,"data.id")??Ge(c,"data.documentId");if(u!=null){a=String(u);break}}a&&(i=i.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}if(i.includes("{documentId}")||i.includes("%7BdocumentId%7D")){let a;const c=t?.documentId??(t&&Ge(t,"documentId")),u=n?.documentId??(n&&Ge(n,"documentId"));c!=null&&c!==""?a=String(c):u!=null&&u!==""&&(a=String(u)),a&&(i=i.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}return i=i.replace(/\{api:([^}]+)\}/g,(a,c)=>{const u=c.trim();if(s==null||u==="")return a;const f=Ge(s,u);return f==null?a:String(f)}),i=i.replace(/\{(?:ctx:|\@)(\w+)\}/g,(a,c)=>n&&n[c]!==void 0&&n[c]!==null?String(n[c]):a),i=i.replace(/\{(\w+)\}/g,(a,c)=>{if(a.includes("ctx:")||a.includes("@"))return a;const u=r[c];if(u!=null)return jf(String(u));let f=t[c];if(f==null||f===""){const l=Object.keys(t).find(p=>p.toLowerCase()===c.toLowerCase());l&&(f=t[l])}if((f==null||f==="")&&(f=n?.[c]),f==null||f===""){const l=z0[c];if(l)for(const p of l){const g=t[p]??n?.[p];if(g!=null&&g!==""){f=g;break}}}return f!=null&&f!==""?jf(String(f)):a}),i}const U0=60,V0=3,H0="Resend OTP in {seconds} sec · Attempts remaining: {attempts}",W0="Resend OTP";function R0(e){const t=e.properties?.resend;return!t?.enabled||!t.resendApiEndpoint?.trim()?null:t}function zf(e){const t=Number(e.cooldownSeconds);return!Number.isFinite(t)||t<0?U0:Math.round(t)}function Uf(e){const t=Number(e.maxAttempts);return!Number.isFinite(t)||t<1?V0:Math.round(t)}function Vf(e,t,r){if(!t?.trim()||e==null)return r;const n=Ge(e,t.trim()),o=typeof n=="number"?n:Number(n);return!Number.isFinite(o)||o<0?r:Math.round(o)}function Hf(e,t,r){if(!t?.trim()||e==null)return r;const n=Ge(e,t.trim()),o=typeof n=="number"?n:Number(n);return!Number.isFinite(o)||o<0?r:Math.round(o)}function G0(e,t){const r=Uf(e),n=zf(e),o=e.initialAttemptsPath??"data.attempts_remaining",s=e.initialCooldownPath??"data.resend_cooldown_seconds";return{attemptsRemaining:Vf(t,o,r),secondsRemaining:Hf(t,s,n)}}function K0(e,t,r){Uf(e);const n=zf(e),o=e.attemptsResponsePath??"data.attempts_remaining",s=e.cooldownResponsePath??"data.resend_cooldown_seconds";return{attemptsRemaining:Vf(t,o,r),secondsRemaining:Hf(t,s,n)}}function q0(e,t,r,n){const o=e.resendLinkText?.trim()||W0,s=!n&&t<=0&&r>0;return{seconds:Math.max(0,t),attempts:Math.max(0,r),resendText:o,resendEnabled:s}}function Y0(e,t){const r=e.statusTemplate?.trim()||H0,n=t.seconds>0?` in ${t.seconds} sec`:"",o=t.resendEnabled?t.resendText:t.seconds>0?`${t.resendText}${n}`:t.resendText;return r.replace(/\{seconds\}/g,String(t.seconds)).replace(/\{attempts\}/g,String(t.attempts)).replace(/\{resend\}/g,o)}async function X0(e,t={}){const r=e.resendApiEndpoint?.trim();if(!r)throw new Error("Resend API endpoint is not configured");const{formValues:n={},urlParams:o={},submissionContext:s,prepopulateResponse:i}=t,a=m=>Lr(m,n,o,s,void 0,i),c=(e.resendApiMethod??"POST").toUpperCase();let u=Mr(a(r));const f=e.resendApiQueryParams??[];if(f.length){const m=new URLSearchParams;f.forEach(({key:y,value:S})=>{y.trim()&&m.append(y,a(S))});const h=m.toString();h&&(u=`${u}${u.includes("?")?"&":"?"}${h}`)}const l={};let p=!1;(e.resendApiHeaders??[]).forEach(({key:m,value:h})=>{m.trim()&&(l[m]=a(h))});let g;c!=="GET"&&(e.resendApiBodyFields??[]).length&&(g={},e.resendApiBodyFields.forEach(({key:m,value:h})=>{m.trim()&&(g[m]=a(h))}),p=!0),p&&!l["Content-Type"]&&!l["content-type"]&&(l["Content-Type"]="application/json");try{return c==="GET"?(await Qt.get(u,{headers:Object.keys(l).length?l:void 0})).data:(await Qt.request({url:u,method:c,data:g??{},headers:Object.keys(l).length?l:void 0})).data}catch(m){const h=m,y=h.response?.status,S=typeof h.response?.data=="string"?h.response.data:h.message??"Request failed";throw new Error(y?`HTTP ${y}: ${S}`:String(S))}}function Gr(e){if(e instanceof Error){const t=e.message;if(t&&(t.includes("{")||t.includes("[")))try{const r=t.match(/\{[\s\S]*\}/);if(r){const n=JSON.parse(r[0]);return yo(n)}}catch{}if(e.response){const r=e.response;if(typeof r=="string")try{const n=JSON.parse(r);return yo(n)}catch{return r}else if(typeof r=="object")return yo(r)}return t}if(e instanceof F0)return e.response?.data?yo(e.response.data):e.message||"An unexpected error occurred";if(typeof e=="string")try{const t=JSON.parse(e);return yo(t)}catch{return e}return typeof e=="object"&&e!==null?yo(e):"An unexpected error occurred"}function yo(e){if(e?.display_message&&typeof e.display_message=="string")return e.display_message.trim();if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.error?.explanation&&Array.isArray(e.error.explanation)){const t=e.error.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.explanation&&Array.isArray(e.explanation)){const t=e.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r!=null&&String(r).trim());if(t.length>0)return t.map(r=>typeof r=="string"?r:r?.message||String(r)).join(". ")}return e?.message&&typeof e.message=="string"?e.message:e?.display_message&&typeof e.display_message=="string"?e.display_message:e?.error?.display_message&&typeof e.error.display_message=="string"?e.error.display_message:e?.error?.message&&typeof e.error.message=="string"?e.error.message:e?.error&&typeof e.error=="string"?e.error:"An unexpected error occurred"}const Wf=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u={},urlParams:f={},submissionContext:l,prepopulateResponse:p})=>{const g=fu(e),m=e.properties?.numericOnly!==!1,h=R0(e),y=v.useRef([]),S=v.useMemo(()=>sw(t,g),[t,g]),w=v.useMemo(()=>h?G0(h,p):null,[h,p]),[A,x]=v.useState(()=>w?.secondsRemaining??0),[F,N]=v.useState(()=>w?.attemptsRemaining??0),[k,T]=v.useState(!1);v.useEffect(()=>{y.current=y.current.slice(0,g)},[g]),v.useEffect(()=>{w&&(x(w.secondsRemaining),N(w.attemptsRemaining))},[w]),v.useEffect(()=>{if(!h||A<=0)return;const D=window.setInterval(()=>{x(K=>K<=1?0:K-1)},1e3);return()=>window.clearInterval(D)},[h,A>0]);const P=v.useMemo(()=>h?q0(h,A,F,k):null,[h,A,F,k]),E=v.useMemo(()=>!h||!P?"":Y0(h,P),[h,P]),C=v.useCallback(async()=>{if(!(!h||!P?.resendEnabled||k)){T(!0);try{const D=await X0(h,{formValues:u,urlParams:f,submissionContext:l,prepopulateResponse:p}),K=K0(h,D,F);N(K.attemptsRemaining),x(K.secondsRemaining),r(""),ct.toast.success("OTP sent successfully.")}catch(D){ct.toast.error(Gr(D))}finally{T(!1)}}},[h,P?.resendEnabled,k,u,f,l,p,F,r]),I=v.useCallback(D=>{r(iw(D))},[r]),W=v.useCallback(D=>{const K=y.current[D];K&&(K.focus(),K.select())},[]),M=v.useCallback((D,K=0)=>{const ae=m?D.replace(/\D/g,""):D.replace(/\s/g,"");if(!ae)return;const j=[...S];let U=K;for(let oe=0;oe<ae.length&&U<g;oe+=1)j[U]=ae[oe]??"",U+=1;I(j);const le=Math.min(U,g-1);requestAnimationFrame(()=>W(le))},[S,I,W,m,g]),z=v.useCallback((D,K)=>{if(i||s||e.readOnly||e.disabled)return;const ae=m?K.replace(/\D/g,""):K.slice(-1),j=[...S];j[D]=ae,I(j),ae&&D<g-1&&requestAnimationFrame(()=>W(D+1))},[S,s,I,e.disabled,e.readOnly,W,m,g,i]),V=v.useCallback((D,K)=>{if(K.key==="Backspace"&&!S[D]&&D>0){K.preventDefault();const ae=[...S];ae[D-1]="",I(ae),W(D-1);return}if(K.key==="ArrowLeft"&&D>0){K.preventDefault(),W(D-1);return}K.key==="ArrowRight"&&D<g-1&&(K.preventDefault(),W(D+1))},[S,I,W,g]),X=v.useCallback((D,K)=>{K.preventDefault();const ae=K.clipboardData.getData("text");M(ae,D)},[M]),L=ft(e),B=h?.resendLinkText?.trim()||"Resend OTP";return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsx("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-labelledby":`${L}-label`,"aria-describedby":Lt(e,!!o),children:S.map((D,K)=>d.jsx(mn,{ref:ae=>{y.current[K]=ae},id:K===0?L:`${L}-${K}`,type:m?"tel":"text",inputMode:m?"numeric":"text",autoComplete:K===0?"one-time-code":"off",maxLength:1,value:D,onChange:ae=>z(K,ae.target.value),onKeyDown:ae=>V(K,ae),onPaste:ae=>X(K,ae),onBlur:K===g-1?n:void 0,disabled:s||e.disabled,readOnly:i||e.readOnly,"aria-label":`${e.label||e.name} digit ${K+1} of ${g}`,"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),"h-10 w-10 text-center text-base font-medium p-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)},`${e.id}-otp-${K}`))}),h&&P&&d.jsx("p",{className:"text-sm text-muted-foreground","aria-live":"polite",children:P.resendEnabled?d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"text-primary underline-offset-4 hover:underline disabled:opacity-50",disabled:s||k,onClick:C,children:k?"Sending…":B}),d.jsx("span",{children:` · Attempts remaining: ${F}`})]}):d.jsx("span",{children:F<=0&&A<=0?"No attempts remaining.":E})})]})})};function J0({className:e,maxLength:t,showCharacterCount:r=!1,autoResize:n=!1,onChange:o,value:s,...i}){const a=b.useRef(null),[c,u]=b.useState(0),f=l=>{const p=l.target.value;u(p.length),n&&a.current&&(a.current.style.height="auto",a.current.style.height=`${a.current.scrollHeight}px`),o&&o(l)};return b.useEffect(()=>{s&&u(String(s).length)},[s]),d.jsxs("div",{className:"space-y-1",children:[d.jsx("textarea",{ref:a,"data-slot":"textarea",className:H("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n&&"resize-none",e),maxLength:t,onChange:f,value:s,...i}),r&&d.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[d.jsxs("span",{children:[c," characters"]}),t&&d.jsxs("span",{children:[t-c," remaining"]})]})]})}const Rf=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const{gridStretch:u}=Jo(),f=u&&Ks(e),l=e.properties,p=v.useCallback(y=>{r(y.target.value)},[r]),g=(t||"").length,m=l?.maxLength,h=m&&m>0;return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:H("relative flex flex-col",f&&"flex-1 min-h-0"),children:[d.jsx(J0,{id:ft(e),value:t||"",onChange:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,minLength:l?.minLength,maxLength:l?.maxLength,rows:2,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(Jd(e.appearance),"resize-y",f&&"min-h-[120px] flex-1 flex-shrink-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),h&&d.jsxs("span",{className:"absolute bottom-2 right-2 text-xs text-muted-foreground",children:[g,"/",m]})]})})};function us(e,[t,r]){return Math.min(r,Math.max(t,e))}function De(e,t,{checkForDefaultPrevented:r=!0}={}){return function(o){if(e?.(o),r===!1||!o.defaultPrevented)return t?.(o)}}function Q0(e,t){const r=b.createContext(t),n=s=>{const{children:i,...a}=s,c=b.useMemo(()=>a,Object.values(a));return d.jsx(r.Provider,{value:c,children:i})};n.displayName=e+"Provider";function o(s){const i=b.useContext(r);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[n,o]}function vr(e,t=[]){let r=[];function n(s,i){const a=b.createContext(i),c=r.length;r=[...r,i];const u=l=>{const{scope:p,children:g,...m}=l,h=p?.[e]?.[c]||a,y=b.useMemo(()=>m,Object.values(m));return d.jsx(h.Provider,{value:y,children:g})};u.displayName=s+"Provider";function f(l,p){const g=p?.[e]?.[c]||a,m=b.useContext(g);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${l}\` must be used within \`${s}\``)}return[u,f]}const o=()=>{const s=r.map(i=>b.createContext(i));return function(a){const c=a?.[e]||s;return b.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[n,Z0(o,...t)]}function Z0(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=n.reduce((a,{useScope:c,scopeName:u})=>{const l=c(s)[`__scope${u}`];return{...a,...l}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return r.scopeName=t.scopeName,r}function Gf(e){const t=ex(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(rx);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function ex(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=ox(o),a=nx(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var tx=Symbol("radix.slottable");function rx(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===tx}function nx(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function ox(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function Cl(e){const t=e+"CollectionProvider",[r,n]=vr(t),[o,s]=r(t,{collectionRef:{current:null},itemMap:new Map}),i=h=>{const{scope:y,children:S}=h,w=v.useRef(null),A=v.useRef(new Map).current;return d.jsx(o,{scope:y,itemMap:A,collectionRef:w,children:S})};i.displayName=t;const a=e+"CollectionSlot",c=Gf(a),u=v.forwardRef((h,y)=>{const{scope:S,children:w}=h,A=s(a,S),x=Qe(y,A.collectionRef);return d.jsx(c,{ref:x,children:w})});u.displayName=a;const f=e+"CollectionItemSlot",l="data-radix-collection-item",p=Gf(f),g=v.forwardRef((h,y)=>{const{scope:S,children:w,...A}=h,x=v.useRef(null),F=Qe(y,x),N=s(f,S);return v.useEffect(()=>(N.itemMap.set(x,{ref:x,...A}),()=>{N.itemMap.delete(x)})),d.jsx(p,{[l]:"",ref:F,children:w})});g.displayName=f;function m(h){const y=s(e+"CollectionConsumer",h);return v.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const A=Array.from(w.querySelectorAll(`[${l}]`));return Array.from(y.itemMap.values()).sort((N,k)=>A.indexOf(N.ref.current)-A.indexOf(k.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:u,ItemSlot:g},m,n]}var sx=b.createContext(void 0);function bo(e){const t=b.useContext(sx);return e||t||"ltr"}function ix(e){const t=ax(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(cx);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function ax(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=ux(o),a=dx(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var lx=Symbol("radix.slottable");function cx(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===lx}function dx(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function ux(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var fx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],je=fx.reduce((e,t)=>{const r=ix(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function px(e,t){e&&js.flushSync(()=>e.dispatchEvent(t))}function cr(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>(...r)=>t.current?.(...r),[])}function mx(e,t=globalThis?.document){const r=cr(e);b.useEffect(()=>{const n=o=>{o.key==="Escape"&&r(o)};return t.addEventListener("keydown",n,{capture:!0}),()=>t.removeEventListener("keydown",n,{capture:!0})},[r,t])}var hx="DismissableLayer",El="dismissableLayer.update",gx="dismissableLayer.pointerDownOutside",yx="dismissableLayer.focusOutside",Kf,qf=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),gi=b.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,u=b.useContext(qf),[f,l]=b.useState(null),p=f?.ownerDocument??globalThis?.document,[,g]=b.useState({}),m=Qe(t,k=>l(k)),h=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),S=h.indexOf(y),w=f?h.indexOf(f):-1,A=u.layersWithOutsidePointerEventsDisabled.size>0,x=w>=S,F=wx(k=>{const T=k.target,P=[...u.branches].some(E=>E.contains(T));!x||P||(o?.(k),i?.(k),k.defaultPrevented||a?.())},p),N=Sx(k=>{const T=k.target;[...u.branches].some(E=>E.contains(T))||(s?.(k),i?.(k),k.defaultPrevented||a?.())},p);return mx(k=>{w===u.layers.size-1&&(n?.(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},p),b.useEffect(()=>{if(f)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Kf=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),Yf(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=Kf)}},[f,p,r,u]),b.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),Yf())},[f,u]),b.useEffect(()=>{const k=()=>g({});return document.addEventListener(El,k),()=>document.removeEventListener(El,k)},[]),d.jsx(je.div,{...c,ref:m,style:{pointerEvents:A?x?"auto":"none":void 0,...e.style},onFocusCapture:De(e.onFocusCapture,N.onFocusCapture),onBlurCapture:De(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:De(e.onPointerDownCapture,F.onPointerDownCapture)})});gi.displayName=hx;var bx="DismissableLayerBranch",vx=b.forwardRef((e,t)=>{const r=b.useContext(qf),n=b.useRef(null),o=Qe(t,n);return b.useEffect(()=>{const s=n.current;if(s)return r.branches.add(s),()=>{r.branches.delete(s)}},[r.branches]),d.jsx(je.div,{...e,ref:o})});vx.displayName=bx;function wx(e,t=globalThis?.document){const r=cr(e),n=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const s=a=>{if(a.target&&!n.current){let c=function(){Xf(gx,r,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);n.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,r]),{onPointerDownCapture:()=>n.current=!0}}function Sx(e,t=globalThis?.document){const r=cr(e),n=b.useRef(!1);return b.useEffect(()=>{const o=s=>{s.target&&!n.current&&Xf(yx,r,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function Yf(){const e=new CustomEvent(El);document.dispatchEvent(e)}function Xf(e,t,r,{discrete:n}){const o=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&o.addEventListener(e,t,{once:!0}),n?px(o,s):o.dispatchEvent(s)}var Nl=0;function kl(){b.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Jf()),document.body.insertAdjacentElement("beforeend",e[1]??Jf()),Nl++,()=>{Nl===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Nl--}},[])}function Jf(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var _l="focusScope.autoFocusOnMount",Tl="focusScope.autoFocusOnUnmount",Qf={bubbles:!1,cancelable:!0},xx="FocusScope",yi=b.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=b.useState(null),u=cr(o),f=cr(s),l=b.useRef(null),p=Qe(t,h=>c(h)),g=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(n){let h=function(A){if(g.paused||!a)return;const x=A.target;a.contains(x)?l.current=x:On(l.current,{select:!0})},y=function(A){if(g.paused||!a)return;const x=A.relatedTarget;x!==null&&(a.contains(x)||On(l.current,{select:!0}))},S=function(A){if(document.activeElement===document.body)for(const F of A)F.removedNodes.length>0&&On(a)};document.addEventListener("focusin",h),document.addEventListener("focusout",y);const w=new MutationObserver(S);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",y),w.disconnect()}}},[n,a,g.paused]),b.useEffect(()=>{if(a){tp.add(g);const h=document.activeElement;if(!a.contains(h)){const S=new CustomEvent(_l,Qf);a.addEventListener(_l,u),a.dispatchEvent(S),S.defaultPrevented||(Ax(_x(Zf(a)),{select:!0}),document.activeElement===h&&On(a))}return()=>{a.removeEventListener(_l,u),setTimeout(()=>{const S=new CustomEvent(Tl,Qf);a.addEventListener(Tl,f),a.dispatchEvent(S),S.defaultPrevented||On(h??document.body,{select:!0}),a.removeEventListener(Tl,f),tp.remove(g)},0)}}},[a,u,f,g]);const m=b.useCallback(h=>{if(!r&&!n||g.paused)return;const y=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,S=document.activeElement;if(y&&S){const w=h.currentTarget,[A,x]=Cx(w);A&&x?!h.shiftKey&&S===x?(h.preventDefault(),r&&On(A,{select:!0})):h.shiftKey&&S===A&&(h.preventDefault(),r&&On(x,{select:!0})):S===w&&h.preventDefault()}},[r,n,g.paused]);return d.jsx(je.div,{tabIndex:-1,...i,ref:p,onKeyDown:m})});yi.displayName=xx;function Ax(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(On(n,{select:t}),document.activeElement!==r)return}function Cx(e){const t=Zf(e),r=ep(t,e),n=ep(t.reverse(),e);return[r,n]}function Zf(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const o=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||o?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function ep(e,t){for(const r of e)if(!Ex(r,{upTo:t}))return r}function Ex(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Nx(e){return e instanceof HTMLInputElement&&"select"in e}function On(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&Nx(e)&&t&&e.select()}}var tp=kx();function kx(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=rp(e,t),e.unshift(t)},remove(t){e=rp(e,t),e[0]?.resume()}}}function rp(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function _x(e){return e.filter(t=>t.tagName!=="A")}var tr=globalThis?.document?b.useLayoutEffect:()=>{},Tx=b[" useId ".trim().toString()]||(()=>{}),Fx=0;function hn(e){const[t,r]=b.useState(Tx());return tr(()=>{r(n=>n??String(Fx++))},[e]),e||(t?`radix-${t}`:"")}const Px=["top","right","bottom","left"],In=Math.min,wr=Math.max,bi=Math.round,vi=Math.floor,on=e=>({x:e,y:e}),Ox={left:"right",right:"left",bottom:"top",top:"bottom"};function Fl(e,t,r){return wr(e,In(t,r))}function gn(e,t){return typeof e=="function"?e(t):e}function yn(e){return e.split("-")[0]}function vo(e){return e.split("-")[1]}function Pl(e){return e==="x"?"y":"x"}function Ol(e){return e==="y"?"height":"width"}function sn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Il(e){return Pl(sn(e))}function Ix(e,t,r){r===void 0&&(r=!1);const n=vo(e),o=Il(e),s=Ol(o);let i=o==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=wi(i)),[i,wi(i)]}function Mx(e){const t=wi(e);return[Ml(e),t,Ml(t)]}function Ml(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const np=["left","right"],op=["right","left"],Lx=["top","bottom"],Dx=["bottom","top"];function Bx(e,t,r){switch(e){case"top":case"bottom":return r?t?op:np:t?np:op;case"left":case"right":return t?Lx:Dx;default:return[]}}function $x(e,t,r,n){const o=vo(e);let s=Bx(yn(e),r==="start",n);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ml)))),s}function wi(e){const t=yn(e);return Ox[t]+e.slice(t.length)}function jx(e){return{top:0,right:0,bottom:0,left:0,...e}}function sp(e){return typeof e!="number"?jx(e):{top:e,right:e,bottom:e,left:e}}function Si(e){const{x:t,y:r,width:n,height:o}=e;return{width:n,height:o,top:r,left:t,right:t+n,bottom:r+o,x:t,y:r}}function ip(e,t,r){let{reference:n,floating:o}=e;const s=sn(t),i=Il(t),a=Ol(i),c=yn(t),u=s==="y",f=n.x+n.width/2-o.width/2,l=n.y+n.height/2-o.height/2,p=n[a]/2-o[a]/2;let g;switch(c){case"top":g={x:f,y:n.y-o.height};break;case"bottom":g={x:f,y:n.y+n.height};break;case"right":g={x:n.x+n.width,y:l};break;case"left":g={x:n.x-o.width,y:l};break;default:g={x:n.x,y:n.y}}switch(vo(t)){case"start":g[i]-=p*(r&&u?-1:1);break;case"end":g[i]+=p*(r&&u?-1:1);break}return g}async function zx(e,t){var r;t===void 0&&(t={});const{x:n,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:l="floating",altBoundary:p=!1,padding:g=0}=gn(t,e),m=sp(g),y=a[p?l==="floating"?"reference":"floating":l],S=Si(await s.getClippingRect({element:(r=await(s.isElement==null?void 0:s.isElement(y)))==null||r?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:f,strategy:c})),w=l==="floating"?{x:n,y:o,width:i.floating.width,height:i.floating.height}:i.reference,A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),x=await(s.isElement==null?void 0:s.isElement(A))?await(s.getScale==null?void 0:s.getScale(A))||{x:1,y:1}:{x:1,y:1},F=Si(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:A,strategy:c}):w);return{top:(S.top-F.top+m.top)/x.y,bottom:(F.bottom-S.bottom+m.bottom)/x.y,left:(S.left-F.left+m.left)/x.x,right:(F.right-S.right+m.right)/x.x}}const Ux=50,Vx=async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:s=[],platform:i}=r,a=i.detectOverflow?i:{...i,detectOverflow:zx},c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:l}=ip(u,n,c),p=n,g=0;const m={};for(let h=0;h<s.length;h++){const y=s[h];if(!y)continue;const{name:S,fn:w}=y,{x:A,y:x,data:F,reset:N}=await w({x:f,y:l,initialPlacement:n,placement:p,strategy:o,middlewareData:m,rects:u,platform:a,elements:{reference:e,floating:t}});f=A??f,l=x??l,m[S]={...m[S],...F},N&&g<Ux&&(g++,typeof N=="object"&&(N.placement&&(p=N.placement),N.rects&&(u=N.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):N.rects),{x:f,y:l}=ip(u,p,c)),h=-1)}return{x:f,y:l,placement:p,strategy:o,middlewareData:m}},Hx=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:f=0}=gn(e,t)||{};if(u==null)return{};const l=sp(f),p={x:r,y:n},g=Il(o),m=Ol(g),h=await i.getDimensions(u),y=g==="y",S=y?"top":"left",w=y?"bottom":"right",A=y?"clientHeight":"clientWidth",x=s.reference[m]+s.reference[g]-p[g]-s.floating[m],F=p[g]-s.reference[g],N=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let k=N?N[A]:0;(!k||!await(i.isElement==null?void 0:i.isElement(N)))&&(k=a.floating[A]||s.floating[m]);const T=x/2-F/2,P=k/2-h[m]/2-1,E=In(l[S],P),C=In(l[w],P),I=E,W=k-h[m]-C,M=k/2-h[m]/2+T,z=Fl(I,M,W),V=!c.arrow&&vo(o)!=null&&M!==z&&s.reference[m]/2-(M<I?E:C)-h[m]/2<0,X=V?M<I?M-I:M-W:0;return{[g]:p[g]+X,data:{[g]:z,centerOffset:M-z-X,...V&&{alignmentOffset:X}},reset:V}}}),Wx=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:f=!0,crossAxis:l=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:h=!0,...y}=gn(e,t);if((r=s.arrow)!=null&&r.alignmentOffset)return{};const S=yn(o),w=sn(a),A=yn(a)===a,x=await(c.isRTL==null?void 0:c.isRTL(u.floating)),F=p||(A||!h?[wi(a)]:Mx(a)),N=m!=="none";!p&&N&&F.push(...$x(a,h,m,x));const k=[a,...F],T=await c.detectOverflow(t,y),P=[];let E=((n=s.flip)==null?void 0:n.overflows)||[];if(f&&P.push(T[S]),l){const M=Ix(o,i,x);P.push(T[M[0]],T[M[1]])}if(E=[...E,{placement:o,overflows:P}],!P.every(M=>M<=0)){var C,I;const M=(((C=s.flip)==null?void 0:C.index)||0)+1,z=k[M];if(z&&(!(l==="alignment"?w!==sn(z):!1)||E.every(L=>sn(L.placement)===w?L.overflows[0]>0:!0)))return{data:{index:M,overflows:E},reset:{placement:z}};let V=(I=E.filter(X=>X.overflows[0]<=0).sort((X,L)=>X.overflows[1]-L.overflows[1])[0])==null?void 0:I.placement;if(!V)switch(g){case"bestFit":{var W;const X=(W=E.filter(L=>{if(N){const B=sn(L.placement);return B===w||B==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(B=>B>0).reduce((B,D)=>B+D,0)]).sort((L,B)=>L[1]-B[1])[0])==null?void 0:W[0];X&&(V=X);break}case"initialPlacement":V=a;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function ap(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function lp(e){return Px.some(t=>e[t]>=0)}const Rx=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:n}=t,{strategy:o="referenceHidden",...s}=gn(e,t);switch(o){case"referenceHidden":{const i=await n.detectOverflow(t,{...s,elementContext:"reference"}),a=ap(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:lp(a)}}}case"escaped":{const i=await n.detectOverflow(t,{...s,altBoundary:!0}),a=ap(i,r.floating);return{data:{escapedOffsets:a,escaped:lp(a)}}}default:return{}}}}},cp=new Set(["left","top"]);async function Gx(e,t){const{placement:r,platform:n,elements:o}=e,s=await(n.isRTL==null?void 0:n.isRTL(o.floating)),i=yn(r),a=vo(r),c=sn(r)==="y",u=cp.has(i)?-1:1,f=s&&c?-1:1,l=gn(t,e);let{mainAxis:p,crossAxis:g,alignmentAxis:m}=typeof l=="number"?{mainAxis:l,crossAxis:0,alignmentAxis:null}:{mainAxis:l.mainAxis||0,crossAxis:l.crossAxis||0,alignmentAxis:l.alignmentAxis};return a&&typeof m=="number"&&(g=a==="end"?m*-1:m),c?{x:g*f,y:p*u}:{x:p*u,y:g*f}}const Kx=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:o,y:s,placement:i,middlewareData:a}=t,c=await Gx(t,e);return i===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},qx=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:o,platform:s}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:c={fn:S=>{let{x:w,y:A}=S;return{x:w,y:A}}},...u}=gn(e,t),f={x:r,y:n},l=await s.detectOverflow(t,u),p=sn(yn(o)),g=Pl(p);let m=f[g],h=f[p];if(i){const S=g==="y"?"top":"left",w=g==="y"?"bottom":"right",A=m+l[S],x=m-l[w];m=Fl(A,m,x)}if(a){const S=p==="y"?"top":"left",w=p==="y"?"bottom":"right",A=h+l[S],x=h-l[w];h=Fl(A,h,x)}const y=c.fn({...t,[g]:m,[p]:h});return{...y,data:{x:y.x-r,y:y.y-n,enabled:{[g]:i,[p]:a}}}}}},Yx=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:n,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:c=!0,crossAxis:u=!0}=gn(e,t),f={x:r,y:n},l=sn(o),p=Pl(l);let g=f[p],m=f[l];const h=gn(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){const A=p==="y"?"height":"width",x=s.reference[p]-s.floating[A]+y.mainAxis,F=s.reference[p]+s.reference[A]-y.mainAxis;g<x?g=x:g>F&&(g=F)}if(u){var S,w;const A=p==="y"?"width":"height",x=cp.has(yn(o)),F=s.reference[l]-s.floating[A]+(x&&((S=i.offset)==null?void 0:S[l])||0)+(x?0:y.crossAxis),N=s.reference[l]+s.reference[A]+(x?0:((w=i.offset)==null?void 0:w[l])||0)-(x?y.crossAxis:0);m<F?m=F:m>N&&(m=N)}return{[p]:g,[l]:m}}}},Xx=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:c=()=>{},...u}=gn(e,t),f=await i.detectOverflow(t,u),l=yn(o),p=vo(o),g=sn(o)==="y",{width:m,height:h}=s.floating;let y,S;l==="top"||l==="bottom"?(y=l,S=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(S=l,y=p==="end"?"top":"bottom");const w=h-f.top-f.bottom,A=m-f.left-f.right,x=In(h-f[y],w),F=In(m-f[S],A),N=!t.middlewareData.shift;let k=x,T=F;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(T=A),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(k=w),N&&!p){const E=wr(f.left,0),C=wr(f.right,0),I=wr(f.top,0),W=wr(f.bottom,0);g?T=m-2*(E!==0||C!==0?E+C:wr(f.left,f.right)):k=h-2*(I!==0||W!==0?I+W:wr(f.top,f.bottom))}await c({...t,availableWidth:T,availableHeight:k});const P=await i.getDimensions(a.floating);return m!==P.width||h!==P.height?{reset:{rects:!0}}:{}}}};function xi(){return typeof window<"u"}function wo(e){return dp(e)?(e.nodeName||"").toLowerCase():"#document"}function Sr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function an(e){var t;return(t=(dp(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function dp(e){return xi()?e instanceof Node||e instanceof Sr(e).Node:!1}function Kr(e){return xi()?e instanceof Element||e instanceof Sr(e).Element:!1}function bn(e){return xi()?e instanceof HTMLElement||e instanceof Sr(e).HTMLElement:!1}function up(e){return!xi()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Sr(e).ShadowRoot}function fs(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=qr(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&o!=="inline"&&o!=="contents"}function Jx(e){return/^(table|td|th)$/.test(wo(e))}function Ai(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Qx=/transform|translate|scale|rotate|perspective|filter/,Zx=/paint|layout|strict|content/,Zn=e=>!!e&&e!=="none";let Ll;function Dl(e){const t=Kr(e)?qr(e):e;return Zn(t.transform)||Zn(t.translate)||Zn(t.scale)||Zn(t.rotate)||Zn(t.perspective)||!Bl()&&(Zn(t.backdropFilter)||Zn(t.filter))||Qx.test(t.willChange||"")||Zx.test(t.contain||"")}function eA(e){let t=Mn(e);for(;bn(t)&&!So(t);){if(Dl(t))return t;if(Ai(t))return null;t=Mn(t)}return null}function Bl(){return Ll==null&&(Ll=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ll}function So(e){return/^(html|body|#document)$/.test(wo(e))}function qr(e){return Sr(e).getComputedStyle(e)}function Ci(e){return Kr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Mn(e){if(wo(e)==="html")return e;const t=e.assignedSlot||e.parentNode||up(e)&&e.host||an(e);return up(t)?t.host:t}function fp(e){const t=Mn(e);return So(t)?e.ownerDocument?e.ownerDocument.body:e.body:bn(t)&&fs(t)?t:fp(t)}function ps(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const o=fp(e),s=o===((n=e.ownerDocument)==null?void 0:n.body),i=Sr(o);if(s){const a=$l(i);return t.concat(i,i.visualViewport||[],fs(o)?o:[],a&&r?ps(a):[])}else return t.concat(o,ps(o,[],r))}function $l(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function pp(e){const t=qr(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=bn(e),s=o?e.offsetWidth:r,i=o?e.offsetHeight:n,a=bi(r)!==s||bi(n)!==i;return a&&(r=s,n=i),{width:r,height:n,$:a}}function jl(e){return Kr(e)?e:e.contextElement}function xo(e){const t=jl(e);if(!bn(t))return on(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:s}=pp(t);let i=(s?bi(r.width):r.width)/n,a=(s?bi(r.height):r.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const tA=on(0);function mp(e){const t=Sr(e);return!Bl()||!t.visualViewport?tA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function rA(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Sr(e)?!1:t}function eo(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),s=jl(e);let i=on(1);t&&(n?Kr(n)&&(i=xo(n)):i=xo(e));const a=rA(s,r,n)?mp(s):on(0);let c=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,f=o.width/i.x,l=o.height/i.y;if(s){const p=Sr(s),g=n&&Kr(n)?Sr(n):n;let m=p,h=$l(m);for(;h&&n&&g!==m;){const y=xo(h),S=h.getBoundingClientRect(),w=qr(h),A=S.left+(h.clientLeft+parseFloat(w.paddingLeft))*y.x,x=S.top+(h.clientTop+parseFloat(w.paddingTop))*y.y;c*=y.x,u*=y.y,f*=y.x,l*=y.y,c+=A,u+=x,m=Sr(h),h=$l(m)}}return Si({width:f,height:l,x:c,y:u})}function Ei(e,t){const r=Ci(e).scrollLeft;return t?t.left+r:eo(an(e)).left+r}function hp(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-Ei(e,r),o=r.top+t.scrollTop;return{x:n,y:o}}function nA(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const s=o==="fixed",i=an(n),a=t?Ai(t.floating):!1;if(n===i||a&&s)return r;let c={scrollLeft:0,scrollTop:0},u=on(1);const f=on(0),l=bn(n);if((l||!l&&!s)&&((wo(n)!=="body"||fs(i))&&(c=Ci(n)),l)){const g=eo(n);u=xo(n),f.x=g.x+n.clientLeft,f.y=g.y+n.clientTop}const p=i&&!l&&!s?hp(i,c):on(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-c.scrollLeft*u.x+f.x+p.x,y:r.y*u.y-c.scrollTop*u.y+f.y+p.y}}function oA(e){return Array.from(e.getClientRects())}function sA(e){const t=an(e),r=Ci(e),n=e.ownerDocument.body,o=wr(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=wr(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let i=-r.scrollLeft+Ei(e);const a=-r.scrollTop;return qr(n).direction==="rtl"&&(i+=wr(t.clientWidth,n.clientWidth)-o),{width:o,height:s,x:i,y:a}}const gp=25;function iA(e,t){const r=Sr(e),n=an(e),o=r.visualViewport;let s=n.clientWidth,i=n.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const f=Bl();(!f||f&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}const u=Ei(n);if(u<=0){const f=n.ownerDocument,l=f.body,p=getComputedStyle(l),g=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,m=Math.abs(n.clientWidth-l.clientWidth-g);m<=gp&&(s-=m)}else u<=gp&&(s+=u);return{width:s,height:i,x:a,y:c}}function aA(e,t){const r=eo(e,!0,t==="fixed"),n=r.top+e.clientTop,o=r.left+e.clientLeft,s=bn(e)?xo(e):on(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=n*s.y;return{width:i,height:a,x:c,y:u}}function yp(e,t,r){let n;if(t==="viewport")n=iA(e,r);else if(t==="document")n=sA(an(e));else if(Kr(t))n=aA(t,r);else{const o=mp(e);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Si(n)}function bp(e,t){const r=Mn(e);return r===t||!Kr(r)||So(r)?!1:qr(r).position==="fixed"||bp(r,t)}function lA(e,t){const r=t.get(e);if(r)return r;let n=ps(e,[],!1).filter(a=>Kr(a)&&wo(a)!=="body"),o=null;const s=qr(e).position==="fixed";let i=s?Mn(e):e;for(;Kr(i)&&!So(i);){const a=qr(i),c=Dl(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||fs(i)&&!c&&bp(e,i))?n=n.filter(f=>f!==i):o=a,i=Mn(i)}return t.set(e,n),n}function cA(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const i=[...r==="clippingAncestors"?Ai(t)?[]:lA(t,this._c):[].concat(r),n],a=yp(t,i[0],o);let c=a.top,u=a.right,f=a.bottom,l=a.left;for(let p=1;p<i.length;p++){const g=yp(t,i[p],o);c=wr(g.top,c),u=In(g.right,u),f=In(g.bottom,f),l=wr(g.left,l)}return{width:u-l,height:f-c,x:l,y:c}}function dA(e){const{width:t,height:r}=pp(e);return{width:t,height:r}}function uA(e,t,r){const n=bn(t),o=an(t),s=r==="fixed",i=eo(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=on(0);function u(){c.x=Ei(o)}if(n||!n&&!s)if((wo(t)!=="body"||fs(o))&&(a=Ci(t)),n){const g=eo(t,!0,s,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else o&&u();s&&!n&&o&&u();const f=o&&!n&&!s?hp(o,a):on(0),l=i.left+a.scrollLeft-c.x-f.x,p=i.top+a.scrollTop-c.y-f.y;return{x:l,y:p,width:i.width,height:i.height}}function zl(e){return qr(e).position==="static"}function vp(e,t){if(!bn(e)||qr(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return an(e)===r&&(r=r.ownerDocument.body),r}function wp(e,t){const r=Sr(e);if(Ai(e))return r;if(!bn(e)){let o=Mn(e);for(;o&&!So(o);){if(Kr(o)&&!zl(o))return o;o=Mn(o)}return r}let n=vp(e,t);for(;n&&Jx(n)&&zl(n);)n=vp(n,t);return n&&So(n)&&zl(n)&&!Dl(n)?r:n||eA(e)||r}const fA=async function(e){const t=this.getOffsetParent||wp,r=this.getDimensions,n=await r(e.floating);return{reference:uA(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function pA(e){return qr(e).direction==="rtl"}const mA={convertOffsetParentRelativeRectToViewportRelativeRect:nA,getDocumentElement:an,getClippingRect:cA,getOffsetParent:wp,getElementRects:fA,getClientRects:oA,getDimensions:dA,getScale:xo,isElement:Kr,isRTL:pA};function Sp(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function hA(e,t){let r=null,n;const o=an(e);function s(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:f,top:l,width:p,height:g}=u;if(a||t(),!p||!g)return;const m=vi(l),h=vi(o.clientWidth-(f+p)),y=vi(o.clientHeight-(l+g)),S=vi(f),A={rootMargin:-m+"px "+-h+"px "+-y+"px "+-S+"px",threshold:wr(0,In(1,c))||1};let x=!0;function F(N){const k=N[0].intersectionRatio;if(k!==c){if(!x)return i();k?i(!1,k):n=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!Sp(u,e.getBoundingClientRect())&&i(),x=!1}try{r=new IntersectionObserver(F,{...A,root:o.ownerDocument})}catch{r=new IntersectionObserver(F,A)}r.observe(e)}return i(!0),s}function gA(e,t,r,n){n===void 0&&(n={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,u=jl(e),f=o||s?[...u?ps(u):[],...t?ps(t):[]]:[];f.forEach(S=>{o&&S.addEventListener("scroll",r,{passive:!0}),s&&S.addEventListener("resize",r)});const l=u&&a?hA(u,r):null;let p=-1,g=null;i&&(g=new ResizeObserver(S=>{let[w]=S;w&&w.target===u&&g&&t&&(g.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var A;(A=g)==null||A.observe(t)})),r()}),u&&!c&&g.observe(u),t&&g.observe(t));let m,h=c?eo(e):null;c&&y();function y(){const S=eo(e);h&&!Sp(h,S)&&r(),h=S,m=requestAnimationFrame(y)}return r(),()=>{var S;f.forEach(w=>{o&&w.removeEventListener("scroll",r),s&&w.removeEventListener("resize",r)}),l?.(),(S=g)==null||S.disconnect(),g=null,c&&cancelAnimationFrame(m)}}const yA=Kx,bA=qx,vA=Wx,wA=Xx,SA=Rx,xp=Hx,xA=Yx,AA=(e,t,r)=>{const n=new Map,o={platform:mA,...r},s={...o.platform,_c:n};return Vx(e,t,{...o,platform:s})};var CA=typeof document<"u",EA=function(){},Ni=CA?v.useLayoutEffect:EA;function ki(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,n,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;n--!==0;)if(!ki(e[n],t[n]))return!1;return!0}if(o=Object.keys(e),r=o.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(t,o[n]))return!1;for(n=r;n--!==0;){const s=o[n];if(!(s==="_owner"&&e.$$typeof)&&!ki(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ap(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Cp(e,t){const r=Ap(e);return Math.round(t*r)/r}function Ul(e){const t=b.useRef(e);return Ni(()=>{t.current=e}),t}function NA(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[f,l]=b.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[p,g]=b.useState(n);ki(p,n)||g(n);const[m,h]=b.useState(null),[y,S]=b.useState(null),w=b.useCallback(L=>{L!==N.current&&(N.current=L,h(L))},[]),A=b.useCallback(L=>{L!==k.current&&(k.current=L,S(L))},[]),x=s||m,F=i||y,N=b.useRef(null),k=b.useRef(null),T=b.useRef(f),P=c!=null,E=Ul(c),C=Ul(o),I=Ul(u),W=b.useCallback(()=>{if(!N.current||!k.current)return;const L={placement:t,strategy:r,middleware:p};C.current&&(L.platform=C.current),AA(N.current,k.current,L).then(B=>{const D={...B,isPositioned:I.current!==!1};M.current&&!ki(T.current,D)&&(T.current=D,js.flushSync(()=>{l(D)}))})},[p,t,r,C,I]);Ni(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,l(L=>({...L,isPositioned:!1})))},[u]);const M=b.useRef(!1);Ni(()=>(M.current=!0,()=>{M.current=!1}),[]),Ni(()=>{if(x&&(N.current=x),F&&(k.current=F),x&&F){if(E.current)return E.current(x,F,W);W()}},[x,F,W,E,P]);const z=b.useMemo(()=>({reference:N,floating:k,setReference:w,setFloating:A}),[w,A]),V=b.useMemo(()=>({reference:x,floating:F}),[x,F]),X=b.useMemo(()=>{const L={position:r,left:0,top:0};if(!V.floating)return L;const B=Cp(V.floating,f.x),D=Cp(V.floating,f.y);return a?{...L,transform:"translate("+B+"px, "+D+"px)",...Ap(V.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:B,top:D}},[r,a,V.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:W,refs:z,elements:V,floatingStyles:X}),[f,W,z,V,X])}const kA=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:n,padding:o}=typeof e=="function"?e(r):e;return n&&t(n)?n.current!=null?xp({element:n.current,padding:o}).fn(r):{}:n?xp({element:n,padding:o}).fn(r):{}}}},_A=(e,t)=>{const r=yA(e);return{name:r.name,fn:r.fn,options:[e,t]}},TA=(e,t)=>{const r=bA(e);return{name:r.name,fn:r.fn,options:[e,t]}},FA=(e,t)=>({fn:xA(e).fn,options:[e,t]}),PA=(e,t)=>{const r=vA(e);return{name:r.name,fn:r.fn,options:[e,t]}},OA=(e,t)=>{const r=wA(e);return{name:r.name,fn:r.fn,options:[e,t]}},IA=(e,t)=>{const r=SA(e);return{name:r.name,fn:r.fn,options:[e,t]}},MA=(e,t)=>{const r=kA(e);return{name:r.name,fn:r.fn,options:[e,t]}};var LA="Arrow",Ep=b.forwardRef((e,t)=>{const{children:r,width:n=10,height:o=5,...s}=e;return d.jsx(je.svg,{...s,ref:t,width:n,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ep.displayName=LA;var DA=Ep;function ms(e){const[t,r]=b.useState(void 0);return tr(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;r({width:i,height:a})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),t}var Vl="Popper",[Np,_i]=vr(Vl),[BA,kp]=Np(Vl),_p=e=>{const{__scopePopper:t,children:r}=e,[n,o]=b.useState(null);return d.jsx(BA,{scope:t,anchor:n,onAnchorChange:o,children:r})};_p.displayName=Vl;var Tp="PopperAnchor",Fp=b.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...o}=e,s=kp(Tp,r),i=b.useRef(null),a=Qe(t,i),c=b.useRef(null);return b.useEffect(()=>{const u=c.current;c.current=n?.current||i.current,u!==c.current&&s.onAnchorChange(c.current)}),n?null:d.jsx(je.div,{...o,ref:a})});Fp.displayName=Tp;var Hl="PopperContent",[$A,jA]=Np(Hl),Pp=b.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:l="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:m,...h}=e,y=kp(Hl,r),[S,w]=b.useState(null),A=Qe(t,G=>w(G)),[x,F]=b.useState(null),N=ms(x),k=N?.width??0,T=N?.height??0,P=n+(s!=="center"?"-"+s:""),E=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},C=Array.isArray(u)?u:[u],I=C.length>0,W={padding:E,boundary:C.filter(UA),altBoundary:I},{refs:M,floatingStyles:z,placement:V,isPositioned:X,middlewareData:L}=NA({strategy:"fixed",placement:P,whileElementsMounted:(...G)=>gA(...G,{animationFrame:g==="always"}),elements:{reference:y.anchor},middleware:[_A({mainAxis:o+T,alignmentAxis:i}),c&&TA({mainAxis:!0,crossAxis:!1,limiter:l==="partial"?FA():void 0,...W}),c&&PA({...W}),OA({...W,apply:({elements:G,rects:ie,availableWidth:Ce,availableHeight:ee})=>{const{width:ne,height:he}=ie.reference,Ie=G.floating.style;Ie.setProperty("--radix-popper-available-width",`${Ce}px`),Ie.setProperty("--radix-popper-available-height",`${ee}px`),Ie.setProperty("--radix-popper-anchor-width",`${ne}px`),Ie.setProperty("--radix-popper-anchor-height",`${he}px`)}}),x&&MA({element:x,padding:a}),VA({arrowWidth:k,arrowHeight:T}),p&&IA({strategy:"referenceHidden",...W})]}),[B,D]=Mp(V),K=cr(m);tr(()=>{X&&K?.()},[X,K]);const ae=L.arrow?.x,j=L.arrow?.y,U=L.arrow?.centerOffset!==0,[le,oe]=b.useState();return tr(()=>{S&&oe(window.getComputedStyle(S).zIndex)},[S]),d.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:X?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:le,"--radix-popper-transform-origin":[L.transformOrigin?.x,L.transformOrigin?.y].join(" "),...L.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx($A,{scope:r,placedSide:B,onArrowChange:F,arrowX:ae,arrowY:j,shouldHideArrow:U,children:d.jsx(je.div,{"data-side":B,"data-align":D,...h,ref:A,style:{...h.style,animation:X?void 0:"none"}})})})});Pp.displayName=Hl;var Op="PopperArrow",zA={top:"bottom",right:"left",bottom:"top",left:"right"},Ip=b.forwardRef(function(t,r){const{__scopePopper:n,...o}=t,s=jA(Op,n),i=zA[s.placedSide];return d.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:d.jsx(DA,{...o,ref:r,style:{...o.style,display:"block"}})})});Ip.displayName=Op;function UA(e){return e!==null}var VA=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:n,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,f]=Mp(r),l={start:"0%",center:"50%",end:"100%"}[f],p=(o.arrow?.x??0)+a/2,g=(o.arrow?.y??0)+c/2;let m="",h="";return u==="bottom"?(m=i?l:`${p}px`,h=`${-c}px`):u==="top"?(m=i?l:`${p}px`,h=`${n.floating.height+c}px`):u==="right"?(m=`${-c}px`,h=i?l:`${g}px`):u==="left"&&(m=`${n.floating.width+c}px`,h=i?l:`${g}px`),{data:{x:m,y:h}}}});function Mp(e){const[t,r="center"]=e.split("-");return[t,r]}var Lp=_p,Wl=Fp,Dp=Pp,Bp=Ip,HA="Portal",Ti=b.forwardRef((e,t)=>{const{container:r,...n}=e,[o,s]=b.useState(!1);tr(()=>s(!0),[]);const i=r||o&&globalThis?.document?.body;return i?Nd.createPortal(d.jsx(je.div,{...n,ref:t}),i):null});Ti.displayName=HA;function WA(e){const t=RA(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(KA);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function RA(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=YA(o),a=qA(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var GA=Symbol("radix.slottable");function KA(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===GA}function qA(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function YA(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var XA=b[" useInsertionEffect ".trim().toString()]||tr;function ln({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[o,s,i]=JA({defaultProp:t,onChange:r}),a=e!==void 0,c=a?e:o;{const f=b.useRef(e!==void 0);b.useEffect(()=>{const l=f.current;l!==a&&console.warn(`${n} is changing from ${l?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=a},[a,n])}const u=b.useCallback(f=>{if(a){const l=QA(f)?f(e):f;l!==e&&i.current?.(l)}else s(f)},[a,e,s,i]);return[c,u]}function JA({defaultProp:e,onChange:t}){const[r,n]=b.useState(e),o=b.useRef(r),s=b.useRef(t);return XA(()=>{s.current=t},[t]),b.useEffect(()=>{o.current!==r&&(s.current?.(r),o.current=r)},[r,o]),[r,n,s]}function QA(e){return typeof e=="function"}function hs(e){const t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var $p=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),ZA="VisuallyHidden",eC=b.forwardRef((e,t)=>d.jsx(je.span,{...e,ref:t,style:{...$p,...e.style}}));eC.displayName=ZA;var tC=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ao=new WeakMap,Fi=new WeakMap,Pi={},Rl=0,jp=function(e){return e&&(e.host||jp(e.parentNode))},rC=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=jp(r);return n&&e.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},nC=function(e,t,r,n){var o=rC(t,Array.isArray(e)?e:[e]);Pi[r]||(Pi[r]=new WeakMap);var s=Pi[r],i=[],a=new Set,c=new Set(o),u=function(l){!l||a.has(l)||(a.add(l),u(l.parentNode))};o.forEach(u);var f=function(l){!l||c.has(l)||Array.prototype.forEach.call(l.children,function(p){if(a.has(p))f(p);else try{var g=p.getAttribute(n),m=g!==null&&g!=="false",h=(Ao.get(p)||0)+1,y=(s.get(p)||0)+1;Ao.set(p,h),s.set(p,y),i.push(p),h===1&&m&&Fi.set(p,!0),y===1&&p.setAttribute(r,"true"),m||p.setAttribute(n,"true")}catch(S){console.error("aria-hidden: cannot operate on ",p,S)}})};return f(t),a.clear(),Rl++,function(){i.forEach(function(l){var p=Ao.get(l)-1,g=s.get(l)-1;Ao.set(l,p),s.set(l,g),p||(Fi.has(l)||l.removeAttribute(n),Fi.delete(l)),g||l.removeAttribute(r)}),Rl--,Rl||(Ao=new WeakMap,Ao=new WeakMap,Fi=new WeakMap,Pi={})}},Gl=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),o=tC(e);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live], script"))),nC(n,o,r,"aria-hidden")):function(){return null}},cn=function(){return cn=Object.assign||function(t){for(var r,n=1,o=arguments.length;n<o;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},cn.apply(this,arguments)};function zp(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function oC(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,s;n<o;n++)(s||!(n in t))&&(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Oi="right-scroll-bar-position",Ii="width-before-scroll-bar",sC="with-scroll-bars-hidden",iC="--removed-body-scroll-bar-size";function Kl(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function aC(e,t){var r=v.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(n){var o=r.value;o!==n&&(r.value=n,r.callback(n,o))}}}})[0];return r.callback=t,r.facade}var lC=typeof window<"u"?b.useLayoutEffect:b.useEffect,Up=new WeakMap;function cC(e,t){var r=aC(null,function(n){return e.forEach(function(o){return Kl(o,n)})});return lC(function(){var n=Up.get(r);if(n){var o=new Set(n),s=new Set(e),i=r.current;o.forEach(function(a){s.has(a)||Kl(a,null)}),s.forEach(function(a){o.has(a)||Kl(a,i)})}Up.set(r,e)},[e]),r}function dC(e){return e}function uC(e,t){t===void 0&&(t=dC);var r=[],n=!1,o={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(s){var i=t(s,n);return r.push(i),function(){r=r.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(n=!0;r.length;){var i=r;r=[],i.forEach(s)}r={push:function(a){return s(a)},filter:function(){return r}}},assignMedium:function(s){n=!0;var i=[];if(r.length){var a=r;r=[],a.forEach(s),i=r}var c=function(){var f=i;i=[],f.forEach(s)},u=function(){return Promise.resolve().then(c)};u(),r={push:function(f){i.push(f),u()},filter:function(f){return i=i.filter(f),r}}}};return o}function fC(e){e===void 0&&(e={});var t=uC(null);return t.options=cn({async:!0,ssr:!1},e),t}var Vp=function(e){var t=e.sideCar,r=zp(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=t.read();if(!n)throw new Error("Sidecar medium not found");return b.createElement(n,cn({},r))};Vp.isSideCarExport=!0;function pC(e,t){return e.useMedium(t),Vp}var Hp=fC(),ql=function(){},Mi=b.forwardRef(function(e,t){var r=b.useRef(null),n=b.useState({onScrollCapture:ql,onWheelCapture:ql,onTouchMoveCapture:ql}),o=n[0],s=n[1],i=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,f=e.enabled,l=e.shards,p=e.sideCar,g=e.noRelative,m=e.noIsolation,h=e.inert,y=e.allowPinchZoom,S=e.as,w=S===void 0?"div":S,A=e.gapMode,x=zp(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),F=p,N=cC([r,t]),k=cn(cn({},x),o);return b.createElement(b.Fragment,null,f&&b.createElement(F,{sideCar:Hp,removeScrollBar:u,shards:l,noRelative:g,noIsolation:m,inert:h,setCallbacks:s,allowPinchZoom:!!y,lockRef:r,gapMode:A}),i?b.cloneElement(b.Children.only(a),cn(cn({},k),{ref:N})):b.createElement(w,cn({},k,{className:c,ref:N}),a))});Mi.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Mi.classNames={fullWidth:Ii,zeroRight:Oi};var mC=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function hC(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=mC();return t&&e.setAttribute("nonce",t),e}function gC(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function yC(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var bC=function(){var e=0,t=null;return{add:function(r){e==0&&(t=hC())&&(gC(t,r),yC(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},vC=function(){var e=bC();return function(t,r){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},Wp=function(){var e=vC(),t=function(r){var n=r.styles,o=r.dynamic;return e(n,o),null};return t},wC={left:0,top:0,right:0,gap:0},Yl=function(e){return parseInt(e||"",10)||0},SC=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],n=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Yl(r),Yl(n),Yl(o)]},xC=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return wC;var t=SC(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,n-r+t[2]-t[0])}},AC=Wp(),Co="data-scroll-locked",CC=function(e,t,r,n){var o=e.left,s=e.top,i=e.right,a=e.gap;return r===void 0&&(r="margin"),`
7
- .`.concat(sC,` {
1
+ (function(ue,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react"),require("react/jsx-runtime"),require("react-router-dom"),require("react-dom"),require("sonner"),require("@tanstack/react-query")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-router-dom","react-dom","sonner","@tanstack/react-query"],v):(ue=typeof globalThis<"u"?globalThis:ue||self,v(ue.FormBuilderRenderer={},ue.React,ue.jsxRuntime,ue.ReactRouterDOM,ue.ReactDOM,ue.Sonner,ue.ReactQuery))})(this,(function(ue,v,d,Ba,kd,ct,kn){"use strict";function _d(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const b=_d(v),Vs=_d(kd),$a="iq-fbr",Hn="95px";function Hs(e){return!e||typeof e.columns!="number"?null:{rows:e.rows??8,columns:e.columns,verticalSpacing:e.verticalSpacing||e.spacing||"16px",horizontalSpacing:e.horizontalSpacing||e.spacing||"16px",rowHeight:Hn}}function Ws(e,t){if(t!=null&&t!==void 0)return t;const r=e.config;if(r?.grid&&typeof r.grid.rows=="number"&&typeof r.grid.columns=="number")return{rows:r.grid.rows,columns:r.grid.columns,verticalSpacing:r.grid.verticalSpacing??r.grid.spacing,horizontalSpacing:r.grid.horizontalSpacing??r.grid.spacing,rowHeight:r.grid.rowHeight,spacing:r.grid.spacing};const n=r?.layout!=null&&typeof r.layout=="object"?r.layout:null;if(n&&typeof n.rows=="number"&&typeof n.columns=="number")return{rows:n.rows,columns:n.columns,verticalSpacing:n.verticalSpacing??n.spacing,horizontalSpacing:n.horizontalSpacing??n.spacing,rowHeight:n.rowHeight,spacing:n.spacing};const o=e.layout;if(o!=null&&typeof o=="object"&&typeof o.rows=="number"&&typeof o.columns=="number"){const s=o;return{rows:s.rows,columns:s.columns,verticalSpacing:s.verticalSpacing??s.spacing,horizontalSpacing:s.horizontalSpacing??s.spacing,rowHeight:s.rowHeight,spacing:s.spacing}}return null}function Td(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(r=Td(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Fd(){for(var e,t,r=0,n="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=Td(e))&&(n&&(n+=" "),n+=t);return n}const Jb=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},Qb=(e,t)=>({classGroupId:e,validator:t}),Pd=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Rs="-",Od=[],Zb="arbitrary..",ev=e=>{const t=rv(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return tv(i);const a=i.split(Rs),c=a[0]===""&&a.length>1?1:0;return Id(a,c,t)},getConflictingClassGroupIds:(i,a)=>{if(a){const c=n[i],u=r[i];return c?u?Jb(u,c):c:u||Od}return r[i]||Od}}},Id=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const o=e[t],s=r.nextPart.get(o);if(s){const u=Id(e,t+1,s);if(u)return u}const i=r.validators;if(i===null)return;const a=t===0?e.join(Rs):e.slice(t).join(Rs),c=i.length;for(let u=0;u<c;u++){const f=i[u];if(f.validator(a))return f.classGroupId}},tv=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?Zb+n:void 0})(),rv=e=>{const{theme:t,classGroups:r}=e;return nv(r,t)},nv=(e,t)=>{const r=Pd();for(const n in e){const o=e[n];ja(o,r,n,t)}return r},ja=(e,t,r,n)=>{const o=e.length;for(let s=0;s<o;s++){const i=e[s];ov(i,t,r,n)}},ov=(e,t,r,n)=>{if(typeof e=="string"){sv(e,t,r);return}if(typeof e=="function"){iv(e,t,r,n);return}av(e,t,r,n)},sv=(e,t,r)=>{const n=e===""?t:Md(t,e);n.classGroupId=r},iv=(e,t,r,n)=>{if(lv(e)){ja(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(Qb(r,e))},av=(e,t,r,n)=>{const o=Object.entries(e),s=o.length;for(let i=0;i<s;i++){const[a,c]=o[i];ja(c,Md(t,a),r,n)}},Md=(e,t)=>{let r=e;const n=t.split(Rs),o=n.length;for(let s=0;s<o;s++){const i=n[s];let a=r.nextPart.get(i);a||(a=Pd(),r.nextPart.set(i,a)),r=a}return r},lv=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,cv=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const o=(s,i)=>{r[s]=i,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(s){let i=r[s];if(i!==void 0)return i;if((i=n[s])!==void 0)return o(s,i),i},set(s,i){s in r?r[s]=i:o(s,i)}}},za="!",Ld=":",dv=[],Dd=(e,t,r,n,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:o}),uv=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=o=>{const s=[];let i=0,a=0,c=0,u;const f=o.length;for(let h=0;h<f;h++){const y=o[h];if(i===0&&a===0){if(y===Ld){s.push(o.slice(c,h)),c=h+1;continue}if(y==="/"){u=h;continue}}y==="["?i++:y==="]"?i--:y==="("?a++:y===")"&&a--}const l=s.length===0?o:o.slice(c);let p=l,g=!1;l.endsWith(za)?(p=l.slice(0,-1),g=!0):l.startsWith(za)&&(p=l.slice(1),g=!0);const m=u&&u>c?u-c:void 0;return Dd(s,g,p,m)};if(t){const o=t+Ld,s=n;n=i=>i.startsWith(o)?s(i.slice(o.length)):Dd(dv,!1,i,void 0,!0)}if(r){const o=n;n=s=>r({className:s,parseClassName:o})}return n},fv=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let o=[];for(let s=0;s<r.length;s++){const i=r[s],a=i[0]==="[",c=t.has(i);a||c?(o.length>0&&(o.sort(),n.push(...o),o=[]),n.push(i)):o.push(i)}return o.length>0&&(o.sort(),n.push(...o)),n}},pv=e=>({cache:cv(e.cacheSize),parseClassName:uv(e),sortModifiers:fv(e),...ev(e)}),mv=/\s+/,hv=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:o,sortModifiers:s}=t,i=[],a=e.trim().split(mv);let c="";for(let u=a.length-1;u>=0;u-=1){const f=a[u],{isExternal:l,modifiers:p,hasImportantModifier:g,baseClassName:m,maybePostfixModifierPosition:h}=r(f);if(l){c=f+(c.length>0?" "+c:c);continue}let y=!!h,S=n(y?m.substring(0,h):m);if(!S){if(!y){c=f+(c.length>0?" "+c:c);continue}if(S=n(m),!S){c=f+(c.length>0?" "+c:c);continue}y=!1}const w=p.length===0?"":p.length===1?p[0]:s(p).join(":"),A=g?w+za:w,x=A+S;if(i.indexOf(x)>-1)continue;i.push(x);const F=o(S,y);for(let N=0;N<F.length;++N){const k=F[N];i.push(A+k)}c=f+(c.length>0?" "+c:c)}return c},gv=(...e)=>{let t=0,r,n,o="";for(;t<e.length;)(r=e[t++])&&(n=Bd(r))&&(o&&(o+=" "),o+=n);return o},Bd=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=Bd(e[n]))&&(r&&(r+=" "),r+=t);return r},yv=(e,...t)=>{let r,n,o,s;const i=c=>{const u=t.reduce((f,l)=>l(f),e());return r=pv(u),n=r.cache.get,o=r.cache.set,s=a,a(c)},a=c=>{const u=n(c);if(u)return u;const f=hv(c,r);return o(c,f),f};return s=i,(...c)=>s(gv(...c))},bv=[],Kt=e=>{const t=r=>r[e]||bv;return t.isThemeGetter=!0,t},$d=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,jd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,vv=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,wv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Sv=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,xv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Av=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Cv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_n=e=>vv.test(e),ot=e=>!!e&&!Number.isNaN(Number(e)),Tn=e=>!!e&&Number.isInteger(Number(e)),Ua=e=>e.endsWith("%")&&ot(e.slice(0,-1)),pn=e=>wv.test(e),zd=()=>!0,Ev=e=>Sv.test(e)&&!xv.test(e),Va=()=>!1,Nv=e=>Av.test(e),kv=e=>Cv.test(e),_v=e=>!Fe(e)&&!Pe(e),Tv=e=>Fn(e,Gd,Va),Fe=e=>$d.test(e),Wn=e=>Fn(e,Kd,Ev),Ud=e=>Fn(e,Bv,ot),Fv=e=>Fn(e,Yd,zd),Pv=e=>Fn(e,qd,Va),Vd=e=>Fn(e,Wd,Va),Ov=e=>Fn(e,Rd,kv),Gs=e=>Fn(e,Xd,Nv),Pe=e=>jd.test(e),Ko=e=>Rn(e,Kd),Iv=e=>Rn(e,qd),Hd=e=>Rn(e,Wd),Mv=e=>Rn(e,Gd),Lv=e=>Rn(e,Rd),Ks=e=>Rn(e,Xd,!0),Dv=e=>Rn(e,Yd,!0),Fn=(e,t,r)=>{const n=$d.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Rn=(e,t,r=!1)=>{const n=jd.exec(e);return n?n[1]?t(n[1]):r:!1},Wd=e=>e==="position"||e==="percentage",Rd=e=>e==="image"||e==="url",Gd=e=>e==="length"||e==="size"||e==="bg-size",Kd=e=>e==="length",Bv=e=>e==="number",qd=e=>e==="family-name",Yd=e=>e==="number"||e==="weight",Xd=e=>e==="shadow",$v=yv(()=>{const e=Kt("color"),t=Kt("font"),r=Kt("text"),n=Kt("font-weight"),o=Kt("tracking"),s=Kt("leading"),i=Kt("breakpoint"),a=Kt("container"),c=Kt("spacing"),u=Kt("radius"),f=Kt("shadow"),l=Kt("inset-shadow"),p=Kt("text-shadow"),g=Kt("drop-shadow"),m=Kt("blur"),h=Kt("perspective"),y=Kt("aspect"),S=Kt("ease"),w=Kt("animate"),A=()=>["auto","avoid","all","avoid-page","page","left","right","column"],x=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],F=()=>[...x(),Pe,Fe],N=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto","contain","none"],T=()=>[Pe,Fe,c],P=()=>[_n,"full","auto",...T()],E=()=>[Tn,"none","subgrid",Pe,Fe],C=()=>["auto",{span:["full",Tn,Pe,Fe]},Tn,Pe,Fe],I=()=>[Tn,"auto",Pe,Fe],W=()=>["auto","min","max","fr",Pe,Fe],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],V=()=>["auto",...T()],X=()=>[_n,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],D=()=>[_n,"screen","full","dvw","lvw","svw","min","max","fit",...T()],B=()=>[_n,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],L=()=>[e,Pe,Fe],K=()=>[...x(),Hd,Vd,{position:[Pe,Fe]}],ie=()=>["no-repeat",{repeat:["","x","y","space","round"]}],j=()=>["auto","cover","contain",Mv,Tv,{size:[Pe,Fe]}],U=()=>[Ua,Ko,Wn],le=()=>["","none","full",u,Pe,Fe],oe=()=>["",ot,Ko,Wn],G=()=>["solid","dashed","dotted","double"],ae=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ae=()=>[ot,Ua,Hd,Vd],ee=()=>["","none",m,Pe,Fe],ne=()=>["none",ot,Pe,Fe],he=()=>["none",ot,Pe,Fe],Ie=()=>[ot,Pe,Fe],Ue=()=>[_n,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[pn],breakpoint:[pn],color:[zd],container:[pn],"drop-shadow":[pn],ease:["in","out","in-out"],font:[_v],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[pn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[pn],shadow:[pn],spacing:["px",ot],text:[pn],"text-shadow":[pn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",_n,Fe,Pe,y]}],container:["container"],columns:[{columns:[ot,Fe,Pe,a]}],"break-after":[{"break-after":A()}],"break-before":[{"break-before":A()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:F()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[Tn,"auto",Pe,Fe]}],basis:[{basis:[_n,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ot,_n,"auto","initial","none",Fe]}],grow:[{grow:["",ot,Pe,Fe]}],shrink:[{shrink:["",ot,Pe,Fe]}],order:[{order:[Tn,"first","last","none",Pe,Fe]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:C()}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:C()}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":W()}],"auto-rows":[{"auto-rows":W()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pbs:[{pbs:T()}],pbe:[{pbe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:V()}],mx:[{mx:V()}],my:[{my:V()}],ms:[{ms:V()}],me:[{me:V()}],mbs:[{mbs:V()}],mbe:[{mbe:V()}],mt:[{mt:V()}],mr:[{mr:V()}],mb:[{mb:V()}],ml:[{ml:V()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:X()}],"inline-size":[{inline:["auto",...D()]}],"min-inline-size":[{"min-inline":["auto",...D()]}],"max-inline-size":[{"max-inline":["none",...D()]}],"block-size":[{block:["auto",...B()]}],"min-block-size":[{"min-block":["auto",...B()]}],"max-block-size":[{"max-block":["none",...B()]}],w:[{w:[a,"screen",...X()]}],"min-w":[{"min-w":[a,"screen","none",...X()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...X()]}],h:[{h:["screen","lh",...X()]}],"min-h":[{"min-h":["screen","lh","none",...X()]}],"max-h":[{"max-h":["screen","lh",...X()]}],"font-size":[{text:["base",r,Ko,Wn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Dv,Fv]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ua,Fe]}],"font-family":[{font:[Iv,Pv,t]}],"font-features":[{"font-features":[Fe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Pe,Fe]}],"line-clamp":[{"line-clamp":[ot,"none",Pe,Ud]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",Pe,Fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Pe,Fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:L()}],"text-color":[{text:L()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[ot,"from-font","auto",Pe,Wn]}],"text-decoration-color":[{decoration:L()}],"underline-offset":[{"underline-offset":[ot,"auto",Pe,Fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Pe,Fe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Pe,Fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:K()}],"bg-repeat":[{bg:ie()}],"bg-size":[{bg:j()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Tn,Pe,Fe],radial:["",Pe,Fe],conic:[Tn,Pe,Fe]},Lv,Ov]}],"bg-color":[{bg:L()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:L()}],"gradient-via":[{via:L()}],"gradient-to":[{to:L()}],rounded:[{rounded:le()}],"rounded-s":[{"rounded-s":le()}],"rounded-e":[{"rounded-e":le()}],"rounded-t":[{"rounded-t":le()}],"rounded-r":[{"rounded-r":le()}],"rounded-b":[{"rounded-b":le()}],"rounded-l":[{"rounded-l":le()}],"rounded-ss":[{"rounded-ss":le()}],"rounded-se":[{"rounded-se":le()}],"rounded-ee":[{"rounded-ee":le()}],"rounded-es":[{"rounded-es":le()}],"rounded-tl":[{"rounded-tl":le()}],"rounded-tr":[{"rounded-tr":le()}],"rounded-br":[{"rounded-br":le()}],"rounded-bl":[{"rounded-bl":le()}],"border-w":[{border:oe()}],"border-w-x":[{"border-x":oe()}],"border-w-y":[{"border-y":oe()}],"border-w-s":[{"border-s":oe()}],"border-w-e":[{"border-e":oe()}],"border-w-bs":[{"border-bs":oe()}],"border-w-be":[{"border-be":oe()}],"border-w-t":[{"border-t":oe()}],"border-w-r":[{"border-r":oe()}],"border-w-b":[{"border-b":oe()}],"border-w-l":[{"border-l":oe()}],"divide-x":[{"divide-x":oe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":oe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"hidden","none"]}],"border-color":[{border:L()}],"border-color-x":[{"border-x":L()}],"border-color-y":[{"border-y":L()}],"border-color-s":[{"border-s":L()}],"border-color-e":[{"border-e":L()}],"border-color-bs":[{"border-bs":L()}],"border-color-be":[{"border-be":L()}],"border-color-t":[{"border-t":L()}],"border-color-r":[{"border-r":L()}],"border-color-b":[{"border-b":L()}],"border-color-l":[{"border-l":L()}],"divide-color":[{divide:L()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ot,Pe,Fe]}],"outline-w":[{outline:["",ot,Ko,Wn]}],"outline-color":[{outline:L()}],shadow:[{shadow:["","none",f,Ks,Gs]}],"shadow-color":[{shadow:L()}],"inset-shadow":[{"inset-shadow":["none",l,Ks,Gs]}],"inset-shadow-color":[{"inset-shadow":L()}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:L()}],"ring-offset-w":[{"ring-offset":[ot,Wn]}],"ring-offset-color":[{"ring-offset":L()}],"inset-ring-w":[{"inset-ring":oe()}],"inset-ring-color":[{"inset-ring":L()}],"text-shadow":[{"text-shadow":["none",p,Ks,Gs]}],"text-shadow-color":[{"text-shadow":L()}],opacity:[{opacity:[ot,Pe,Fe]}],"mix-blend":[{"mix-blend":[...ae(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ae()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ot]}],"mask-image-linear-from-pos":[{"mask-linear-from":Ae()}],"mask-image-linear-to-pos":[{"mask-linear-to":Ae()}],"mask-image-linear-from-color":[{"mask-linear-from":L()}],"mask-image-linear-to-color":[{"mask-linear-to":L()}],"mask-image-t-from-pos":[{"mask-t-from":Ae()}],"mask-image-t-to-pos":[{"mask-t-to":Ae()}],"mask-image-t-from-color":[{"mask-t-from":L()}],"mask-image-t-to-color":[{"mask-t-to":L()}],"mask-image-r-from-pos":[{"mask-r-from":Ae()}],"mask-image-r-to-pos":[{"mask-r-to":Ae()}],"mask-image-r-from-color":[{"mask-r-from":L()}],"mask-image-r-to-color":[{"mask-r-to":L()}],"mask-image-b-from-pos":[{"mask-b-from":Ae()}],"mask-image-b-to-pos":[{"mask-b-to":Ae()}],"mask-image-b-from-color":[{"mask-b-from":L()}],"mask-image-b-to-color":[{"mask-b-to":L()}],"mask-image-l-from-pos":[{"mask-l-from":Ae()}],"mask-image-l-to-pos":[{"mask-l-to":Ae()}],"mask-image-l-from-color":[{"mask-l-from":L()}],"mask-image-l-to-color":[{"mask-l-to":L()}],"mask-image-x-from-pos":[{"mask-x-from":Ae()}],"mask-image-x-to-pos":[{"mask-x-to":Ae()}],"mask-image-x-from-color":[{"mask-x-from":L()}],"mask-image-x-to-color":[{"mask-x-to":L()}],"mask-image-y-from-pos":[{"mask-y-from":Ae()}],"mask-image-y-to-pos":[{"mask-y-to":Ae()}],"mask-image-y-from-color":[{"mask-y-from":L()}],"mask-image-y-to-color":[{"mask-y-to":L()}],"mask-image-radial":[{"mask-radial":[Pe,Fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":Ae()}],"mask-image-radial-to-pos":[{"mask-radial-to":Ae()}],"mask-image-radial-from-color":[{"mask-radial-from":L()}],"mask-image-radial-to-color":[{"mask-radial-to":L()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":x()}],"mask-image-conic-pos":[{"mask-conic":[ot]}],"mask-image-conic-from-pos":[{"mask-conic-from":Ae()}],"mask-image-conic-to-pos":[{"mask-conic-to":Ae()}],"mask-image-conic-from-color":[{"mask-conic-from":L()}],"mask-image-conic-to-color":[{"mask-conic-to":L()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:K()}],"mask-repeat":[{mask:ie()}],"mask-size":[{mask:j()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Pe,Fe]}],filter:[{filter:["","none",Pe,Fe]}],blur:[{blur:ee()}],brightness:[{brightness:[ot,Pe,Fe]}],contrast:[{contrast:[ot,Pe,Fe]}],"drop-shadow":[{"drop-shadow":["","none",g,Ks,Gs]}],"drop-shadow-color":[{"drop-shadow":L()}],grayscale:[{grayscale:["",ot,Pe,Fe]}],"hue-rotate":[{"hue-rotate":[ot,Pe,Fe]}],invert:[{invert:["",ot,Pe,Fe]}],saturate:[{saturate:[ot,Pe,Fe]}],sepia:[{sepia:["",ot,Pe,Fe]}],"backdrop-filter":[{"backdrop-filter":["","none",Pe,Fe]}],"backdrop-blur":[{"backdrop-blur":ee()}],"backdrop-brightness":[{"backdrop-brightness":[ot,Pe,Fe]}],"backdrop-contrast":[{"backdrop-contrast":[ot,Pe,Fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ot,Pe,Fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ot,Pe,Fe]}],"backdrop-invert":[{"backdrop-invert":["",ot,Pe,Fe]}],"backdrop-opacity":[{"backdrop-opacity":[ot,Pe,Fe]}],"backdrop-saturate":[{"backdrop-saturate":[ot,Pe,Fe]}],"backdrop-sepia":[{"backdrop-sepia":["",ot,Pe,Fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Pe,Fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ot,"initial",Pe,Fe]}],ease:[{ease:["linear","initial",S,Pe,Fe]}],delay:[{delay:[ot,Pe,Fe]}],animate:[{animate:["none",w,Pe,Fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,Pe,Fe]}],"perspective-origin":[{"perspective-origin":F()}],rotate:[{rotate:ne()}],"rotate-x":[{"rotate-x":ne()}],"rotate-y":[{"rotate-y":ne()}],"rotate-z":[{"rotate-z":ne()}],scale:[{scale:he()}],"scale-x":[{"scale-x":he()}],"scale-y":[{"scale-y":he()}],"scale-z":[{"scale-z":he()}],"scale-3d":["scale-3d"],skew:[{skew:Ie()}],"skew-x":[{"skew-x":Ie()}],"skew-y":[{"skew-y":Ie()}],transform:[{transform:[Pe,Fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:F()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ue()}],"translate-x":[{"translate-x":Ue()}],"translate-y":[{"translate-y":Ue()}],"translate-z":[{"translate-z":Ue()}],"translate-none":["translate-none"],accent:[{accent:L()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:L()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Pe,Fe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mbs":[{"scroll-mbs":T()}],"scroll-mbe":[{"scroll-mbe":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pbs":[{"scroll-pbs":T()}],"scroll-pbe":[{"scroll-pbe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Pe,Fe]}],fill:[{fill:["none",...L()]}],"stroke-w":[{stroke:[ot,Ko,Wn,Ud]}],stroke:[{stroke:["none",...L()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function H(...e){return $v(Fd(e))}const jv=["richtext","multiselect","radio","checkboxgroup","signature"],zv=3;function qo(e){const t=e.position.rowSpan??1;if(e.type==="billingGrid"||e.type==="table")return Math.max(1,t);if(e.type==="file"||e.type==="camera"||e.type==="photoChoice"||e.type==="textarea")return Math.max(t,1);if(e.type==="status")return Math.max(t,4);if(e.type==="selectablelist")return Math.max(zv,t);if(e.type==="radio"||e.type==="checkboxgroup"){const r=e.properties?.options;return(Array.isArray(r)?r.length:0)<=2?1:Math.max(t,2)}return jv.includes(e.type)?Math.max(t,2):t}function Jd(e,t){if(e.type==="table"||e.type==="billingGrid"){const s=e.position.columnSpan??t??1;return t!=null?Math.min(s,t):s}if(e.type!=="radio"&&e.type!=="checkboxgroup"){const s=e.position.columnSpan??1;return t!=null?Math.min(s,t):s}const r=e.properties?.options,n=Array.isArray(r)?r.length:0,o=Math.max(1,Math.ceil(n/2));return t!=null?Math.min(o,t):o}function uo(e){const t=e?.size??"md",r=e?.variant??"default";return H(t==="sm"?"h-8 text-sm":t==="lg"?"min-h-12 text-lg py-2":"h-10 md:text-sm",r==="filled"?"border-transparent bg-muted shadow-none":r==="outlined"?"border-2 bg-transparent":"")}function Qd(e){const t=e?.size??"md",r=e?.variant??"default";return H(t==="sm"?"min-h-[48px] text-sm":t==="lg"?"min-h-[72px] text-lg":"min-h-[56px]",r==="filled"?"border-transparent bg-muted shadow-none":r==="outlined"?"border-2 bg-transparent":"")}function Uv(e){switch(e){case"left":return"flex flex-row items-start gap-4";case"right":return"flex flex-row-reverse items-start gap-4";case"center":return"flex flex-col items-center text-center w-full";case"floating":return"relative flex flex-col gap-2 w-full min-w-0";default:return"flex flex-col gap-2 w-full min-w-0"}}function Vv(e,t){const r=t?"text-destructive":"";switch(e){case"left":return`shrink-0 w-32 pt-2 text-right text-sm font-medium ${r}`;case"right":return`shrink-0 w-32 pt-2 text-left text-sm font-medium ${r}`;case"center":return`w-full text-center text-sm font-medium ${r}`;case"floating":return`absolute left-3 top-2 z-[1] origin-[0] -translate-y-4 scale-75 bg-background px-1 text-sm ${r}`;default:return`text-sm font-medium ${r}`}}function Hv(e){switch(e){case"left":case"right":return"flex-1 min-w-0 min-h-0 flex flex-col";case"center":return"w-full max-w-full flex flex-col flex-1 min-h-0";case"floating":return"flex flex-col flex-1 min-h-0 w-full pt-4";default:return"flex flex-col flex-1 min-h-0 w-full min-w-0"}}function qs(e){return!e||e.widthMode==="full"?100:typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent)?Math.min(100,Math.max(1,Math.round(e.widthPercent))):(e.widthMode==="percent",100)}function Ha(e){const t=qs(e);return{width:t>=100?"100%":`${t}%`,maxWidth:"100%"}}function Wv(e){return Ha(e)}function Wa(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"||t==="stretch"?t:null}function Ra(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"?t:null}function Fr(e){if(!e)return"start";const t=Wa(e.horizontalAlign);if(t)return t;const r=Wa(e.contentAlign);if(r)return r;const n=Wa(e.cellAlign);return n||"start"}function Yo(e){if(e?.verticalAlign!=null)return e.verticalAlign;const t=e?.cellJustify;return t==="center"?"center":t==="end"?"end":t==="stretch"?"stretch":t==="start"?"start":"stretch"}function Ys(e){switch(e){case"center":return"items-center";case"end":return"items-end";case"stretch":return"items-stretch";default:return"items-start"}}function Ga(e){switch(e){case"center":return"justify-center";case"end":return"justify-end";case"stretch":return"justify-stretch";default:return"justify-start"}}function Xo(e){const t=Ra(e.appearance?.contentVerticalAlign);if(t!==null)switch(t){case"center":return"justify-center";case"end":return"justify-end";default:return"justify-start"}return Ga(Ka(e))}const Rv=Xo;function Xs(e){if(e.type==="billingGrid"||e.type==="table"||qo(e)>1)return!0;const t=Ra(e.appearance?.contentVerticalAlign);if(t==="center"||t==="end")return!1;if(t==="start")return!0;const r=Ka(e);return r!=="center"&&r!=="end"}function Zd(e){const t=e[0];if(!t)return qa(void 0);if(e.length===1)return qa(t);const r=Fr(t.appearance);return H("flex flex-col min-h-0 h-full w-full",Ys(r),"justify-start")}function eu(e){const t=Fr(e),r=Yo(e);return H("flex flex-col min-h-0 h-full w-full",Ys(t),Ga(r))}function tu(e){if(qs(e)>=100)return"";const r=Fr(e);return r==="center"?"mx-auto":r==="end"?"ml-auto":""}function ru(e){if(qs(e)>=100)return"w-full";const r=Fr(e);return r==="center"||r==="end"?"min-w-0":r==="stretch"?"min-w-0 self-stretch":"min-w-0 self-start"}function nu(e){return e?e.widthMode==="full"||e.widthMode==="percent"||typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent):!1}function fo(e){return(e.type==="button"||e.type==="editButton")&&!nu(e.appearance)}function ou(e){return fo(e)?Fr(e.appearance)==="stretch"?{width:"100%",maxWidth:"100%",minWidth:0}:{width:"auto",maxWidth:"100%"}:Ha(e.appearance)}function su(e){return ou(e)}function iu(e){if(fo(e))switch(Fr(e.appearance)){case"center":return"self-center";case"end":return"self-end";case"stretch":return"self-stretch";default:return"self-start"}return ru(e.appearance)}function au(e){return e?e.verticalAlign!=null||e.cellJustify!=null:!1}function Ka(e){return e.type!=="button"&&e.type!=="editButton"||au(e.appearance)?Yo(e.appearance):"start"}function qa(e){if(!e)return eu(void 0);const t=Fr(e.appearance);return H("flex flex-col min-h-0 h-full w-full",Ys(t),Xo(e))}function Gv(e,t){const r={};e!==void 0&&(r.cellAlign=e),t!==void 0&&(r.cellJustify=t);const o=e===void 0&&t===void 0?void 0:r;return H(Ys(Fr(o)),Ga(Yo(o)))}const Ya=v.createContext({gridStretch:!1});function Jo(){return v.useContext(Ya)}const lu=e=>{let t;const r=new Set,n=(u,f)=>{const l=typeof u=="function"?u(t):u;if(!Object.is(l,t)){const p=t;t=f??(typeof l!="object"||l===null)?l:Object.assign({},t,l),r.forEach(g=>g(t,p))}},o=()=>t,a={setState:n,getState:o,getInitialState:()=>c,subscribe:u=>(r.add(u),()=>r.delete(u))},c=t=e(n,o,a);return a},Kv=(e=>e?lu(e):lu),qv=e=>e;function Xa(e,t=qv){const r=v.useSyncExternalStore(e.subscribe,v.useCallback(()=>t(e.getState()),[e,t]),v.useCallback(()=>t(e.getInitialState()),[e,t]));return v.useDebugValue(r),r}const cu=e=>{const t=Kv(e),r=n=>Xa(t,n);return Object.assign(r,t),r},du=(e=>e?cu(e):cu),Yv=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Xv=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,Jv=/^\+?[\d\s-()]{10,}$/,Qv={required:e=>e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e=="boolean"?e===!0:!0,minLength:(e,t)=>{if(typeof e!="string")return!0;const r=t.value;return e.length>=r},maxLength:(e,t)=>{if(typeof e!="string")return!0;const r=t.value;return e.length<=r},min:(e,t)=>{if(typeof e!="number")return!0;const r=t.value;return e>=r},max:(e,t)=>{if(typeof e!="number")return!0;const r=t.value;return e<=r},pattern:(e,t)=>{if(typeof e!="string")return!0;const r=t.value,n=t.params?.flags||"";return new RegExp(r,n).test(e)},email:e=>typeof e!="string"||!e?!0:Yv.test(e),url:e=>typeof e!="string"||!e?!0:Xv.test(e),phone:e=>typeof e!="string"||!e?!0:Jv.test(e),date:e=>{if(!e)return!0;const t=new Date(e);return!isNaN(t.getTime())},dateRange:(e,t)=>{if(!e)return!0;const r=new Date(e);if(isNaN(r.getTime()))return!1;const n=t.value,o=new Date;if(o.setHours(0,0,0,0),n.min){const s=n.min==="today"?o:new Date(n.min);if(r<s)return!1}if(n.max){const s=n.max==="today"?o:new Date(n.max);if(r>s)return!1}return!0},fileSize:(e,t)=>{if(!e)return!0;const r=t.value;return e instanceof File?e.size<=r:Array.isArray(e)?e.every(n=>n.size<=r):!0},fileType:(e,t)=>{if(!e)return!0;const r=t.value,n={"text/csv":[".csv"],"application/vnd.ms-excel":[".xls"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":[".xlsx"],"application/pdf":[".pdf"],"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"]},o=s=>r.some(i=>{if(i.endsWith("/*")){const u=i.replace("/*","");if(s.type.startsWith(u))return!0}else if(s.type===i)return!0;const a=s.name.toLowerCase(),c=n[i];return c?c.some(u=>a.endsWith(u)):i.startsWith(".")?a.endsWith(i.toLowerCase()):!1});return e instanceof File?o(e):Array.isArray(e)?e.every(s=>o(s)):!0},allowLetters:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[a-zA-Z]/.test(e),allowNumbers:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[0-9]/.test(e),allowSpecialChars:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[^a-zA-Z0-9\s]/.test(e),minLetters:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[a-zA-Z]/g)||[]).length>=r},maxLetters:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[a-zA-Z]/g)||[]).length<=r},minNumbers:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[0-9]/g)||[]).length>=r},maxNumbers:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[0-9]/g)||[]).length<=r},minSpecialChars:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[^a-zA-Z0-9\s]/g)||[]).length>=r},maxSpecialChars:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[^a-zA-Z0-9\s]/g)||[]).length<=r},custom:(e,t,r)=>!0,async:()=>!0};function rn(e,t,r={}){const n=Qv[t.type];if(!n)return!0;const o=n(e,t,r);return o===!1?t.message||Zv(t):typeof o=="string"?o:!0}function Zv(e){return{required:"This field is required",minLength:`Must be at least ${e.value} characters`,maxLength:`Must be at most ${e.value} characters`,min:`Must be at least ${e.value}`,max:`Must be at most ${e.value}`,pattern:"Invalid format",email:"Please enter a valid email address",url:"Please enter a valid URL",phone:"Please enter a valid phone number",date:"Please enter a valid date",dateRange:"Date is out of allowed range",fileSize:`File size must be less than ${ew(e.value)}`,fileType:"File type is not allowed",allowLetters:"Letters are not allowed in this field",allowNumbers:"Numbers are not allowed in this field",allowSpecialChars:"Special characters are not allowed in this field",minLetters:`Must contain at least ${e.value} letters`,maxLetters:`Must contain at most ${e.value} letters`,minNumbers:`Must contain at least ${e.value} numbers`,maxNumbers:`Must contain at most ${e.value} numbers`,minSpecialChars:`Must contain at least ${e.value} special characters`,maxSpecialChars:`Must contain at most ${e.value} special characters`,custom:"Validation failed",async:"Validation failed"}[e.type]||"Invalid value"}function ew(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const tw=10;function Js(e){const t=e.properties;return t?.maxFiles!=null&&t.maxFiles>0?Math.floor(t.maxFiles):t?.multiple===!0?tw:1}function uu(e){return typeof e=="object"&&e!==null&&"url"in e&&typeof e.url=="string"&&e.url.length>0}function fu(e){try{return e.split("?")[0].split("/").filter(Boolean).pop()||e}catch{return e}}function Qs(e){if(e==null)return[];if(typeof e=="string")return e.startsWith("http")?[{url:e,name:fu(e)}]:[];if(e instanceof File)return[e];if(Array.isArray(e)){const t=[];for(const r of e)r instanceof File?t.push(r):typeof r=="string"&&r.startsWith("http")?t.push({url:r,name:fu(r)}):uu(r)&&t.push(r);return t}return uu(e)?[e]:[]}function rw(e,t){return e.slice(0,t)}function Ja(e,t){const r=rw(e,t);return r.length===0?null:t===1?r[0]??null:r}function nw(e){return Qs(e).length}function ow(e){return e==="file"||e==="camera"||e==="photoChoice"}function Qa(e,t){if(!ow(e.type))return;const r=Js(e);if(nw(t)>r)return`Maximum ${r} file(s) allowed`}const sw=4,iw=2,aw=10;function pu(e){const t=e.properties?.otpLength??e.metadata?.otpLength,r=typeof t=="number"?t:Number(t);return Number.isFinite(r)?Math.min(aw,Math.max(iw,Math.round(r))):sw}function lw(e,t){const r=String(e??"").replace(/\s/g,"").slice(0,t).split("");for(;r.length<t;)r.push("");return r}function cw(e){return e.join("").replace(/\s/g,"")}function Za(e,t){if(e.type!=="otp")return;const r=String(t??"").trim();if(!r)return;const n=pu(e);if(r.length!==n)return`Please enter a ${n}-digit OTP`}class Zs{static functions={SUM:(...t)=>t.flat().filter(n=>typeof n=="number").reduce((n,o)=>n+o,0),AVG:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length===0?0:r.reduce((n,o)=>n+o,0)/r.length},MIN:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length>0?Math.min(...r):0},MAX:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length>0?Math.max(...r):0},ROUND:(t,r=0)=>{const n=Number(t);if(isNaN(n))return 0;const o=Math.pow(10,Number(r));return Math.round(n*o)/o},FLOOR:t=>Math.floor(Number(t)||0),CEIL:t=>Math.ceil(Number(t)||0),ABS:t=>Math.abs(Number(t)||0),CONCAT:(...t)=>t.map(String).join(""),UPPER:t=>String(t).toUpperCase(),LOWER:t=>String(t).toLowerCase(),TRIM:t=>String(t).trim(),LEN:t=>String(t).length,SUBSTR:(t,r,n)=>{const o=String(t),s=Number(r),i=n!==void 0?Number(n):void 0;return o.substring(s,i!==void 0?s+i:void 0)},IF:(t,r,n)=>t?r:n,IFEMPTY:(t,r)=>t==null||t===""?r:t,ISNUMBER:t=>typeof t=="number"&&!isNaN(t),ISEMPTY:t=>t==null?!0:typeof t=="string"?t.trim()==="":Array.isArray(t)?t.length===0:!1,TODAY:()=>new Date().toISOString().split("T")[0],NOW:()=>new Date().toISOString(),YEAR:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getFullYear()},MONTH:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getMonth()+1},DAY:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getDate()},DATEDIFF:(t,r,n="days")=>{const o=new Date(t),s=new Date(r);if(isNaN(o.getTime())||isNaN(s.getTime()))return null;const a=(s.getTime()-o.getTime())/(1e3*60*60*24);switch(n){case"years":return a/365;case"months":return a/30;case"weeks":return a/7;case"hours":return a*24;case"minutes":return a*24*60;default:return a}},COUNT:t=>Array.isArray(t)?t.length:t?1:0,FIRST:t=>Array.isArray(t)?t[0]:t,LAST:t=>Array.isArray(t)?t[t.length-1]:t,SUMFIELD:(...t)=>{const r=t[0],n=t[1];return!Array.isArray(r)||typeof n!="string"?0:r.reduce((o,s)=>{if(typeof s=="object"&&s!==null){const i=s[n];return o+(Number(i)||0)}return o},0)}};calculate(t,r){try{const{fields:n,currentValue:o,previousValue:s}=r,i={...n};for(const l in i){const p=i[l];(p==null||p==="")&&(i[l]="")}const a={fields:i,currentValue:o,previousValue:s,...Zs.functions},c=Object.keys(a),u=Object.values(a),f=new Function(...c,`return ${t}`)(...u);if(f==null)return"";if(typeof f=="string"){if(f.includes("undefined"))return"";const l=f.trim();return l===""||/^\s+$/.test(f)?"":l}return f}catch{return""}}calculateAll(t,r){const n={...r};for(const o of t){const s={fields:n,currentValue:n[o.field],previousValue:r[o.field]},i=this.calculate(o.formula,s);n[o.field]=i===null?"":i}return n}validateFormula(t){try{return new Function("fields",`return ${t}`),{valid:!0}}catch(r){return{valid:!1,error:r instanceof Error?r.message:"Invalid formula"}}}getAvailableFunctions(){return[{name:"SUM",description:"Sum of values"},{name:"AVG",description:"Average of values"},{name:"MIN",description:"Minimum value"},{name:"MAX",description:"Maximum value"},{name:"ROUND",description:"Round to decimal places"},{name:"IF",description:"Conditional value"},{name:"CONCAT",description:"Concatenate strings"},{name:"TODAY",description:"Current date"},{name:"DATEDIFF",description:"Difference between dates"},{name:"COUNT",description:"Count of items"},{name:"SUMFIELD",description:"Sum field in array"}]}}const mu=new Zs;function hu(e){if(e==null||e==="")return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:ei(e);if(typeof e=="string"){const t=e.trim();if(!t)return null;const r=t.match(/^(\d{4})-(\d{2})-(\d{2})/);if(r){const o=new Date(Number(r[1]),Number(r[2])-1,Number(r[3]));return Number.isNaN(o.getTime())?null:o}const n=new Date(t);return Number.isNaN(n.getTime())?null:ei(n)}return null}function ei(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function dw(e,t=new Date){const r=ei(e),n=ei(t);if(n<r)return{years:0,months:0,days:0};let o=n.getFullYear()-r.getFullYear(),s=n.getMonth()-r.getMonth(),i=n.getDate()-r.getDate();if(i<0){s-=1;const a=new Date(n.getFullYear(),n.getMonth(),0).getDate();i+=a}return s<0&&(o-=1,s+=12),{years:Math.max(0,o),months:Math.max(0,s),days:Math.max(0,i)}}function el(e){if(e.type!=="number")return;const t=e.properties?.deriveFromDate;if(!(!t?.sourceFieldName||!t.part))return t}function Pr(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function tl(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(t):null}function uw(e,t){const r=tl(e);return r?`${t.sourceFieldName}${r}`:t.sourceFieldName}function gu(e,t,r){const n=tl(t);if(n)return[`${e}${n}`];const o=new Set([e]),s=`${e}__addmore__`;for(const i of Object.keys(r))(i===e||i.startsWith(s))&&o.add(i);return[...o]}function fw(e,t,r){const n=r?uw(r,e):e.sourceFieldName,o=hu(t[n]);if(!o)return null;const s=e.referenceDate==="today"||e.referenceDate==null?new Date:hu(t[e.referenceDate])??new Date;return dw(o,s)[e.part]}function yu(e,t){const r=el(e);return r?Pr(r.sourceFieldName)===Pr(t):!1}function rl(e,t,r,n){const o={...t},s=n?Pr(n):void 0;for(const i of e){if(i.type!=="number")continue;const a=el(i);if(!a||!i.name||s&&Pr(a.sourceFieldName)!==s)continue;const c=n??a.sourceFieldName,u=gu(i.name,c,o);for(const f of u){if(r.has(f))continue;const l=fw(a,o,f);o[f]=l}}return o}function pw(e,t,r,n){const o={...t},s=Pr(n);for(const i of e){if(!yu(i,s)||!i.name)continue;const a=gu(i.name,n,o);for(const c of a)r.delete(c),o[c]=null}return o}function bu(e,t){const r=Pr(t);return e.some(n=>yu(n,r))}function vu(e){if(e.apidata&&typeof e.apidata=="object")return e.apidata;if(e.metadata)try{const t=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata;if(t.apiEndpoint||t.apiKey||t.valueSource==="api")return{apiKey:t.apiKey,valueSource:t.valueSource,apiEndpoint:t.apiEndpoint,apiAutoDetect:t.apiAutoDetect,apiLabelField:t.apiLabelField,apiValueField:t.apiValueField,apiMethod:t.apiMethod,apiRealtime:t.apiRealtime,apiQueryParams:t.apiQueryParams,apiClientFilter:t.apiClientFilter}}catch{}return null}function nl(e,t,r,n){let o=ol(e,r);return n&&(o=Gn(o,t,r)),o}function ol(e,t){return e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(r,n)=>t?.[n]!==void 0&&t[n]!==null?String(t[n]):r)}function Gn(e,t,r){let n=e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(o,s)=>r?.[s]!==void 0&&r[s]!==null?String(r[s]):o);return n=n.replace(/\{(\w+)\}/g,(o,s)=>{if(o.includes("ctx:")||o.includes("@"))return o;let i=t[s];if(i==null||i===""){const a=Object.keys(t).find(c=>c.toLowerCase()===s.toLowerCase());a&&(i=t[a])}return i!=null&&i!==""?String(i):o}),n}function po(e,t){const r=e.match(/\{(\w+)\}/g)||[],n=[];t?.custom&&t.custom.forEach(({value:s})=>{if(s){const i=s.match(/\{(\w+)\}/g)||[];n.push(...i.filter(a=>!a.includes("ctx:")&&!a.includes("@")))}});const o=r.filter(s=>!s.includes("ctx:")&&!s.includes("@"));return new Set([...o.map(s=>s.replace(/[{}]/g,"")),...n.map(s=>s.replace(/[{}]/g,""))])}function mw(e,t){const r=e[t];return r==null||r===""}function ti(e){const{apiEndpoint:t,apiMethod:r="GET",apiQueryParams:n={},formValues:o,submissionContext:s,apiRealtime:i,additionalRequiredFieldNames:a=[],excludeFormFieldNames:c=[]}=e,u=(r||"GET").toLowerCase(),f=po(t,n),l=new Set((c||[]).filter(w=>typeof w=="string"&&w.length>0)),p=new Set((a||[]).filter(w=>typeof w=="string"&&w.length>0)),g=new Set([...f,...p]);let m=!1;for(const w of g){const A=!!(i&&f.has(w)),x=p.has(w);if((A||x)&&mw(o,w)){m=!0;break}}if(m)return{blocked:!0,url:t,postBodyBase:null};let h=t;const y=t.match(/\{(\w+)\}/g)||[];if(h=ol(h,s),i&&(h=Gn(h,o,s)),n&&Object.keys(n).length>0){const w=n,A=[];if(w.limit){let x=w.limit;i&&(x=Gn(x,o,s)),A.push(`_limit=${encodeURIComponent(x)}`)}if(w.page){let x=w.page;i&&(x=Gn(x,o,s)),A.push(`page=${encodeURIComponent(x)}`)}if(w.sort){let x=w.sort;i&&(x=Gn(x,o,s)),A.push(`sort=${encodeURIComponent(x)}`)}if(w.orderBy){let x=w.orderBy;i&&(x=Gn(x,o,s)),A.push(`orderBy=${encodeURIComponent(x)}`)}if(w.custom?.length&&w.custom.forEach(({key:x,value:F})=>{if(!x||!F)return;let N=ol(F,s);i&&(N=Gn(N,o,s)),N.match(/\{[^}]+\}/)?N.match(/\{(?!ctx:|\@)(\w+)\}/g)||A.push(`${encodeURIComponent(x)}=`):A.push(`${encodeURIComponent(x)}=${encodeURIComponent(N)}`)}),A.length>0){const x=h.includes("?")?"&":"?";h=`${h}${x}${A.join("&")}`}}if(i&&Object.keys(o).length>0&&u==="get"){const w=N=>N.replace(/\{/g,"").replace(/\}/g,""),A=[];for(const N of n.custom||[])if(N.value){const k=N.value.match(/\{(\w+)\}/g)||[];A.push(...k.map(w))}const x=new Set([...y.map(w),...A]),F={};Object.keys(o).forEach(N=>{!x.has(N)&&!l.has(N)&&(F[N]=o[N])}),Object.keys(F).length>0&&(h=`${h}${h.includes("?")?"&":"?"}${new URLSearchParams(F).toString()}`)}let S=null;if(["post","put","patch"].includes(u))if(i&&Object.keys(o).length>0){S={...o};for(const w of l)delete S[w]}else{S={...o||{}};for(const w of l)delete S[w]}return{blocked:!1,url:h,postBodyBase:S}}const hw=new Set(["select","multiselect","asyncsearch"]);function gw(e){return e?.type==="multiselect"?[]:""}function wu(e){if(!hw.has(e.type))return[];const t=e.properties??{},r=vu(e),n=new Set,o=r?.apiClientFilter?.matchField?.trim()||t.apiClientFilter?.matchField?.trim();o&&n.add(o);const s=[...Array.isArray(t.dependentFields)?t.dependentFields:[],...Array.isArray(r?.dependentFields)?r.dependentFields:[]];for(const u of s)typeof u=="string"&&u.trim()&&n.add(u.trim());const i=r?.apiEndpoint||t.apiEndpoint,a=r?.apiRealtime??t.apiRealtime,c=r?.apiQueryParams||t.apiQueryParams;if(i&&a)for(const u of po(i,c))n.add(u);return[...n]}function yw(e,t){const r=Pr(t);return wu(e).some(n=>Pr(n)===r)}function bw(e,t){const r=Pr(t);return e.some(n=>yw(n,r))}function vw(e){const t=new Map;for(const r of e){const n=r.name;if(n)for(const o of wu(r)){const s=Pr(o),i=t.get(s)??new Set;i.add(n),t.set(s,i)}}return t}function ww(e,t,r){const n=tl(t);if(n)return[`${e}${n}`];const o=new Set([e]),s=`${e}__addmore__`;for(const i of Object.keys(r))(i===e||i.startsWith(s))&&o.add(i);return[...o]}function Sw(e,t){return e===t?!0:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((r,n)=>r===t[n]):!1}function xw(e,t,r){const n=vw(e),o=Pr(r),s=new Set,i=[o];for(;i.length>0;){const u=i.shift(),f=n.get(u);if(f)for(const l of f)s.has(l)||(s.add(l),i.push(l))}const a={...t},c=[];for(const u of s){const f=e.find(p=>p.name===u),l=gw(f);for(const p of ww(u,r,a))Sw(a[p],l)||c.push(p),a[p]=l}return{values:a,clearedKeys:c}}function sl(e,t){const r=t instanceof Set?t:new Set(t);if(e.size!==r.size)return!1;for(const n of e)if(!r.has(n))return!1;return!0}function Su(){return du((e,t)=>({schema:null,values:{},initialValues:{},errors:{},touched:{},isValidating:!1,isSubmitting:!1,submitCount:0,isValid:!0,currentStep:0,totalSteps:1,completedSteps:new Set,visibleFields:new Set,enabledFields:new Set,requiredFields:new Set,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:new Set,draftId:null,setSchema:(r,n)=>{const o=t(),s=o.schema!=null&&o.schema.id===r.id,i=n?.forceReset===!0,a={},c=new Set,u=new Set,f=new Set;r.fields.forEach(x=>{const F=x.name||x.key||x.id;F&&(x.defaultValue!==void 0&&(x.type==="multiselect"?a[F]=Array.isArray(x.defaultValue)?x.defaultValue:x.defaultValue!=null&&x.defaultValue!==""?[String(x.defaultValue)]:[]:a[F]=x.defaultValue),x.hidden||c.add(F),x.disabled||u.add(F),x.validation?.some(N=>N.type==="required")&&f.add(F))});const l=r.steps?.length||1,p=typeof n?.initialStepIndex=="number",g=p?Math.max(0,Math.min(n.initialStepIndex,Math.max(0,l-1))):0,m=new Set;for(let x=0;x<g;x++)m.add(x);const h=[];r.fields.forEach(x=>{const F=x.properties;F?.valueSource==="calculated"&&F?.formula&&h.push({field:x.name,formula:F.formula})});const y=h.length>0?mu.calculateAll(h,a):{},S=rl(r.fields,{...a,...y},new Set),A=s&&!(i||p)?{...S,...o.values}:S;e({schema:r,values:A,initialValues:S,errors:{},touched:{},currentStep:g,totalSteps:l,completedSteps:m,visibleFields:c,enabledFields:u,requiredFields:f,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:i||!s?new Set:o.derivedFieldDirty,isValid:!0,draftId:null})},setFieldValue:(r,n,o)=>{const s=t(),i=s.schema,a=o?.source??"user";let c=new Set(s.derivedFieldDirty);const u=s.values[r];let f={...s.values,[r]:n},l=[];if(i){const p=Pr(r),g=i.fields.find(S=>S.name===p);a==="user"&&g&&el(g)&&c.add(r);const m=n==null||n===""||Array.isArray(n)&&n.length===0;if(bu(i.fields,r)&&m?f=pw(i.fields,f,c,r):bu(i.fields,r)&&(f=rl(i.fields,f,c,r)),a==="user"&&u!==n&&!(Array.isArray(u)&&Array.isArray(n)&&u.length===n.length&&u.every((S,w)=>S===n[w]))&&bw(i.fields,r)){const S=xw(i.fields,f,r);f=S.values,l=S.clearedKeys}const y=[];i.fields.forEach(S=>{const w=S.properties;w?.valueSource==="calculated"&&w?.formula&&(w.formulaSteps??[]).some(x=>x.type==="field"&&x.fieldName===r)&&y.push({field:S.name,formula:w.formula})}),y.length>0&&(f={...f,...mu.calculateAll(y,f)})}e({values:f,derivedFieldDirty:c}),l.length>0&&e(p=>{const g={...p.errors};for(const m of l)delete g[m];return Object.keys(g).length===Object.keys(p.errors).length?p:{errors:g}}),i?.config.validateOnChange?t().validateField(r):e(p=>{const g={...p.errors};return delete g[r],{errors:g}})},setFieldTouched:(r,n=!0)=>{e(s=>({touched:{...s.touched,[r]:n}}));const o=t().schema;n&&o?.config.validateOnBlur&&t().validateField(r)},setFieldError:(r,n)=>{e(o=>{const s=!!o.errors[r];if(!n&&!s||n&&o.errors[r]===n)return o;const i={...o.errors};return n?i[r]=n:delete i[r],{errors:i,isValid:Object.keys(i).length===0}})},setValues:r=>{const n=t(),o=n.schema;if(!o){e({values:r});return}const s=rl(o.fields,r,n.derivedFieldDirty);e({values:s})},setErrors:r=>e({errors:r,isValid:Object.keys(r).length===0}),resetForm:()=>{const{initialValues:r}=t();e({values:{...r},errors:{},touched:{},currentStep:0,completedSteps:new Set,derivedFieldDirty:new Set,isValid:!0,submitCount:0})},clearForm:()=>{e({schema:null,values:{},initialValues:{},errors:{},touched:{},currentStep:0,totalSteps:1,completedSteps:new Set,visibleFields:new Set,enabledFields:new Set,requiredFields:new Set,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:new Set,isValid:!0,submitCount:0,draftId:null})},validateField:async r=>{const{schema:n,values:o}=t();if(!n)return;const s=n.fields.find(a=>a.name===r);if(!s)return;e({isValidating:!0});let i;if(s.validation)for(const a of s.validation){const c=rn(o[r],a,o);if(typeof c=="string"){i=c;break}}if(!i){const a=Qa(s,o[r]);a&&(i=a)}return!i&&s.type==="otp"&&(i=Za(s,o[r])),e(a=>{const c={...a.errors};return i?c[r]=i:delete c[r],{errors:c,isValid:Object.keys(c).length===0,isValidating:!1}}),i},validateForm:async()=>{const{schema:r,values:n,visibleFields:o,requiredFields:s}=t();if(!r)return!1;e({isValidating:!0});const i={};for(const a of r.fields)if(o.has(a.name)){if(a.validation)for(const c of a.validation){if(c.type==="required"&&!s.has(a.name))continue;const u=rn(n[a.name],c,n);if(typeof u=="string"){i[a.name]=u;break}}if(!i[a.name]){const c=Qa(a,n[a.name]);c&&(i[a.name]=c)}if(!i[a.name]){const c=Za(a,n[a.name]);c&&(i[a.name]=c)}}return e({errors:i,isValid:Object.keys(i).length===0,isValidating:!1}),Object.keys(i).length===0},validateStep:async r=>{const{schema:n,values:o,visibleFields:s}=t();if(!n?.steps)return!0;const i=n.steps[r];if(!i)return!0;e({isValidating:!0});const a={};for(const c of i.fields){const u=n.fields.find(f=>f.name===c);if(!(!u||!s.has(u.name))){if(u.validation)for(const f of u.validation){const l=rn(o[u.name],f,o);if(typeof l=="string"){a[u.name]=l;break}}if(!a[u.name]){const f=Qa(u,o[u.name]);f&&(a[u.name]=f)}if(!a[u.name]){const f=Za(u,o[u.name]);f&&(a[u.name]=f)}}}return e(c=>({errors:{...c.errors,...a},isValid:Object.keys(a).length===0,isValidating:!1})),Object.keys(a).length===0},nextStep:async()=>{const{currentStep:r,totalSteps:n,schema:o}=t();return o?.steps?.[r]?.validation==="onNext"&&!await t().validateStep(r)?!1:r<n-1?(e(i=>({currentStep:r+1,completedSteps:new Set([...i.completedSteps,r])})),!0):!1},prevStep:()=>{const{currentStep:r}=t();r>0&&e({currentStep:r-1})},goToStep:r=>{const{totalSteps:n,completedSteps:o,currentStep:s}=t();r>=0&&r<n&&(r<=s||o.has(r-1))&&e({currentStep:r})},setSubmitting:r=>e({isSubmitting:r}),incrementSubmitCount:()=>e(r=>({submitCount:r.submitCount+1})),updateVisibility:r=>{e(n=>{const o=new Set(r);return sl(n.visibleFields,o)?n:{visibleFields:o}})},updateEnabled:r=>{e(n=>{const o=new Set(r);return sl(n.enabledFields,o)?n:{enabledFields:o}})},updateRequired:r=>{e(n=>{const o=new Set(r);return sl(n.requiredFields,o)?n:{requiredFields:o}})},updateReadOnly:r=>e({readOnlyFields:new Set(r)}),updateEditable:r=>e({editableFields:new Set(r)}),updateFormDisabled:r=>e({formDisabled:r}),saveDraft:()=>{const{schema:r,values:n}=t();if(!r)return;const o=`formsmith_draft_${r.id}`;try{localStorage.setItem(o,JSON.stringify({values:n,savedAt:new Date().toISOString()})),e({draftId:o})}catch{}},loadDraft:()=>{const{schema:r}=t();if(!r)return!1;const n=`formsmith_draft_${r.id}`;try{const o=localStorage.getItem(n);if(o){const{values:s}=JSON.parse(o);return e({values:s,draftId:n}),!0}}catch{}return!1},clearDraft:()=>{const{schema:r,draftId:n}=t();if(!r)return;const o=n||`formsmith_draft_${r.id}`;try{localStorage.removeItem(o),e({draftId:null})}catch{}}}))}const Kn=Su();function Aw(e=Kn){return e.getState()}const xu=v.createContext(null),il=({children:e})=>{const t=v.useRef(null);return t.current||(t.current=Su()),d.jsx(xu.Provider,{value:t.current,children:e})};function ri(){return v.useContext(xu)??Kn}function Or(e){const t=ri();return e?Xa(t,e):Xa(t)}function Au({schema:e,initialValues:t,onSubmit:r,onChange:n,workflowStepId:o,initialStepIndex:s}){const{values:i,errors:a,touched:c,isValidating:u,isSubmitting:f,submitCount:l,isValid:p,currentStep:g,totalSteps:m,completedSteps:h,visibleFields:y,enabledFields:S,requiredFields:w,setSchema:A,setFieldValue:x,setFieldTouched:F,setFieldError:N,setValues:k,resetForm:T,validateField:P,validateForm:E,validateStep:C,nextStep:I,prevStep:W,goToStep:M,setSubmitting:z,incrementSubmitCount:V,saveDraft:X,loadDraft:D,clearDraft:B}=Or(),L=ri(),K=v.useRef(null);v.useLayoutEffect(()=>{if(A(e,{forceReset:!!o||typeof s=="number",initialStepIndex:s}),t&&Object.keys(t).length>0){const re=L.getState().values;k({...re,...t});try{K.current=JSON.stringify(t)}catch{K.current=null}}else K.current=null},[e.id,o,s]),v.useLayoutEffect(()=>{if(!t||Object.keys(t).length===0)return;let re;try{re=JSON.stringify(t)}catch{return}if(re===K.current)return;const ge=L.getState().values;k({...ge,...t}),K.current=re},[t,k]);const ie=v.useCallback((re,ge)=>{const Se={...i,[re]:ge};x(re,ge),n?.(Se,re)},[x,n,i]),j=v.useCallback(async re=>{if(re?.preventDefault(),V(),!await E())return{success:!1,errors:Object.entries(a).map(([Se,pt])=>({field:Se,rule:"validation",message:pt}))};if(!r)return{success:!0};z(!0);try{const Se=await r(i);return Se.success&&B(),Se}catch(Se){return{success:!1,message:Se instanceof Error?Se.message:"Submission failed"}}finally{z(!1)}},[E,r,i,a,V,z,B]),U=v.useCallback(re=>({value:i[re],error:a[re],touched:c[re]||!1,isVisible:y.has(re),isEnabled:S.has(re),isRequired:w.has(re)}),[i,a,c,y,S,w]),le=v.useMemo(()=>{if(!e.steps||e.steps.length===0)return e.fields;const re=e.steps[g];return re?e.fields.filter(ge=>re.fields.includes(ge.name)):[]},[e,g]),oe=g===0,G=g===m-1,ae=v.useCallback(re=>h.has(re),[h]),Ae=v.useMemo(()=>m<=1?100:Math.round(h.size/m*100),[h.size,m]),ee=v.useCallback(re=>y.has(re),[y]),ne=v.useCallback(re=>S.has(re),[S]),he=v.useCallback(re=>w.has(re),[w]),Ie=v.useMemo(()=>Object.entries(a).filter(([re])=>y.has(re)),[a,y]),Ue=Ie.length>0;return{values:i,errors:a,touched:c,isValidating:u,isSubmitting:f,submitCount:l,isValid:p,hasErrors:Ue,visibleErrors:Ie,currentStep:g,totalSteps:m,completedSteps:h,currentStepFields:le,isFirstStep:oe,isLastStep:G,isStepCompleted:ae,progress:Ae,setFieldValue:ie,setFieldTouched:F,setFieldError:N,setValues:k,validateField:P,getFieldState:U,shouldShowField:ee,isFieldEnabled:ne,isFieldRequired:he,handleSubmit:j,resetForm:T,validateForm:E,validateStep:C,nextStep:I,prevStep:W,goToStep:M,saveDraft:X,loadDraft:D,clearDraft:B}}function Cu(e){return"logic"in e&&"conditions"in e}function Qo(e){if(e==null||typeof e!="object")return!1;const t=e;if(t.status==="error")return!1;if(t.status==="success"||t.status==="COMPLETED")return!0;const r=t.code;return typeof r=="number"&&r>=200&&r<300||t.data!=null&&t.status!=="error"}function Eu(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;const r=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let n=e;for(const o of r){if(n==null||typeof n!="object")return;n=n[o]}return n}function Re(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;let r=Eu(e,t);if(r===void 0&&t.includes(".")){const n=t.split(".");if(n.length>=2){const o=n[0],s=n.slice(1).join("."),i=Eu(e,o);Array.isArray(i)&&i.length>0&&(r=Re(i[0],s))}}return r}const Cw=new Set(["section","group","columns","divider","header","sectionHeading","spacer","textLabel","addmore","customizeSections"]);function Ew(e){return e===!0||e==="true"?!0:e===!1||e==="false"?!1:e}function Nw(e,t){if(e==null||typeof t.path!="string"||!t.path.trim())return!1;const r=Re(e,t.path),n=Ew(t.value);switch(t.operator){case"equals":return r===n;case"notEquals":return r!==n;case"contains":return typeof r=="string"?r.includes(String(n)):Array.isArray(r)?r.includes(n):!1;case"notContains":return typeof r=="string"?!r.includes(String(n)):Array.isArray(r)?!r.includes(n):!0;case"startsWith":return typeof r=="string"&&r.startsWith(String(n));case"endsWith":return typeof r=="string"&&r.endsWith(String(n));case"greaterThan":return Number(r)>Number(n);case"lessThan":return Number(r)<Number(n);case"greaterThanOrEqual":return Number(r)>=Number(n);case"lessThanOrEqual":return Number(r)<=Number(n);case"isEmpty":return r==null?!0:typeof r=="string"?r.trim()==="":Array.isArray(r)?r.length===0:typeof r=="object"&&r!==null?Object.keys(r).length===0:!1;case"isNotEmpty":return r==null?!1:typeof r=="string"?r.trim()!=="":Array.isArray(r)?r.length>0:typeof r=="object"&&r!==null?Object.keys(r).length>0:!1;case"isTrue":return r===!0;case"isFalse":return r===!1;case"isNull":return r==null;case"isNotNull":return r!=null;case"in":return Array.isArray(n)?n.includes(r):!1;case"notIn":return Array.isArray(n)?!n.includes(r):!0;case"between":if(Array.isArray(n)&&n.length===2){const o=Number(r);return o>=Number(n[0])&&o<=Number(n[1])}return!1;case"regex":try{return new RegExp(String(n)).test(String(r??""))}catch{return!1}default:return!1}}function kw(e,t,r){return e?e==="__allFields__"?t.filter(n=>!Cw.has(n.type)).map(n=>r(n)).filter(Boolean):e==="__allButtons__"?t.filter(n=>n.type==="button"||n.type==="editButton").map(n=>r(n)).filter(Boolean):[e]:[]}function Nu(e){return String(e||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_+/g,"_")}function ku(e,t){const r=Nu(e)||"row",n=Nu(t)||"cell";return`${r}_${n}`}function _w(e){return e.kind==="static"?e.row.id:e.block.id}function Tw(e,t){let r=e,n=2;for(;t.has(r);)r=`${e}_${n}`,n+=1;return t.add(r),r}function _u(e,t,r,n){const o=e.cellKey?.trim();if(o)return n.add(o),e;const s=ku(t,r),i=Tw(s,n);return{...e,cellKey:i}}function Tu(e){const t=new Set,r=(e.rowSlots??[]).map(n=>{if(n.kind==="static"){const i=n.row.id,a={};for(const[c,u]of Object.entries(n.row.cells))a[c]=_u(u,i,c,t);return{...n,row:{...n.row,cells:a}}}const o=n.block.id,s={};for(const[i,a]of Object.entries(n.block.cells))s[i]=_u(a,o,i,t);return{...n,block:{...n.block,cells:s}}});return{...e,rowSlots:r}}function Fu(e){const t=new Map;for(const r of e.rowSlots??[]){const n=_w(r),o=r.kind,s=r.kind==="static"?r.row.cells:r.block.cells;for(const[i,a]of Object.entries(s)){const c=a.cellKey?.trim()||ku(n,i);t.set(c,{slotId:n,rowKind:o,columnKey:i})}}return t}function Fw(e,t,r){return t.rowKind==="static"?e.find(n=>n.slotId===t.slotId&&n.rowKind==="static"):r?.slotId===t.slotId&&r.rowKind==="dynamic"?r:e.find(n=>n.slotId===t.slotId&&n.rowKind==="dynamic")}function Pu(e,t,r,n,o){const s=r?.trim();if(!s)return 0;const a=Fu(e).get(s);if(a){if(o?.slotId&&a.slotId!==o.slotId||o?.rowKind&&a.rowKind!==o.rowKind)return 0;const c=Fw(t,a,n);return c?al(c.values[a.columnKey]):0}if(n&&s in n.values)return al(n.values[s]);if(o?.slotId){const c=t.find(u=>u.slotId===o.slotId&&(!o.rowKind||u.rowKind===o.rowKind));if(c&&s in c.values)return al(c.values[s])}return 0}function al(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}const Ou="__fieldRef:",Iu="__billingCell:";function Pw(e){const t={kind:"static",staticValue:"",fieldName:"",billingFieldName:"",cellKey:""};if(e==null)return t;const r=String(e);if(r.startsWith(Ou))return{...t,kind:"field",fieldName:r.slice(Ou.length)};if(r.startsWith(Iu)){const n=r.slice(Iu.length),o=n.indexOf("|");return o>=0?{...t,kind:"billingCell",billingFieldName:n.slice(0,o),cellKey:n.slice(o+1)}:{...t,kind:"billingCell",cellKey:n}}if(r.startsWith("field:"))return{...t,kind:"field",fieldName:r.slice(6)};if(r.startsWith("billing:")){const n=r.slice(8),o=n.indexOf("|");return o>=0?{...t,kind:"billingCell",billingFieldName:n.slice(0,o),cellKey:n.slice(o+1)}:{...t,kind:"billingCell",cellKey:n}}return{...t,kind:"static",staticValue:r}}function ll(e){return e.name||e.key||e.id}function Ow(e,t){const r=t.find(n=>n.id===e||n.name===e||n.key===e);return r?ll(r):e}function Iw(e,t,r,n){const o=t.trim();if(!o)return;const s=n.filter(a=>a.type==="billingGrid"),i=e?.trim()?s.filter(a=>ll(a)===e||a.name===e||a.id===e):s;for(const a of i){const c=Tu(a.properties??{}),u=r[ll(a)];if(!u?.rows?.length)continue;const l=Fu(c).get(o);if(!l)continue;const p=u.rows.find(g=>l.rowKind==="static"?g.slotId===l.slotId&&g.rowKind==="static":g.slotId===l.slotId&&g.rowKind==="dynamic");if(p)return p.values[l.columnKey]}}function Mw(e,t,r){const n=Pw(e);if(n.kind==="field"){const o=Ow(n.fieldName,r);return t[o]}return n.kind==="billingCell"?Iw(n.billingFieldName,n.cellKey,t,r):n.staticValue}function Mu(e,t){if(e===t)return!0;if(e==null||t===void 0||t===null)return!1;const r=Number(e),n=Number(t);return!Number.isNaN(r)&&!Number.isNaN(n)&&String(e).trim()!==""&&String(t).trim()!==""?r===n:String(e).trim()===String(t).trim()}const Lu="__buttonResponse:";function Lw({fields:e,values:t,buttonResponses:r,prepopulateResponse:n=null,prepopulateResponseRules:o}){const{updateVisibility:s,updateEnabled:i,updateRequired:a,updateReadOnly:c,updateEditable:u,updateFormDisabled:f}=Or(),l=v.useCallback(N=>N.name||N.key||N.id,[]),p=v.useCallback((N,k)=>{if(!N)return l(k);const T=e.find(P=>P.id===N||P.name===N||P.key===N);return T?l(T):N},[e,l]),g=v.useCallback(N=>{const k=e.find(T=>T.id===N||T.name===N||T.key===N);return k?l(k):N},[e,l]),m=v.useCallback(N=>{const{field:k,operator:T,value:P}=N;if(typeof k=="string"&&k.startsWith(Lu)){const W=k.slice(Lu.length),M=r?.[W],z=Qo(M);return P==="success"?z:P==="failure"?M!=null&&!z:!1}const E=g(k),C=t[E],I=Mw(P,t,e);switch(T){case"equals":return Mu(C,I);case"notEquals":return!Mu(C,I);case"contains":return typeof C=="string"?C.includes(String(I)):Array.isArray(C)?C.includes(I):!1;case"notContains":return typeof C=="string"?!C.includes(String(I)):Array.isArray(C)?!C.includes(I):!0;case"startsWith":return typeof C=="string"&&C.startsWith(String(I));case"endsWith":return typeof C=="string"&&C.endsWith(String(I));case"greaterThan":return Number(C)>Number(I);case"lessThan":return Number(C)<Number(I);case"greaterThanOrEqual":return Number(C)>=Number(I);case"lessThanOrEqual":return Number(C)<=Number(I);case"isEmpty":return C==null?!0:C instanceof File?!1:typeof C=="string"?C.trim()==="":Array.isArray(C)?(C.length>0&&C[0]instanceof File,C.length===0):typeof C=="object"&&C!==null?Object.keys(C).length===0:!1;case"isNotEmpty":return C==null?!1:C instanceof File?!0:typeof C=="string"?C.trim()!=="":Array.isArray(C)?(C.length>0&&C[0]instanceof File,C.length>0):typeof C=="object"&&C!==null?Object.keys(C).length>0:!1;case"isTrue":return C===!0;case"isFalse":return C===!1;case"isNull":return C==null;case"isNotNull":return C!=null;case"in":return Array.isArray(I)?I.includes(C):!1;case"notIn":return Array.isArray(I)?!I.includes(C):!0;case"between":if(Array.isArray(I)&&I.length===2){const W=Number(C);return W>=Number(I[0])&&W<=Number(I[1])}return!1;case"regex":try{return new RegExp(String(I)).test(String(C))}catch{return!1}default:return!0}},[t,g,r,e]),h=v.useCallback(N=>{const k=N.conditions.map(T=>Cu(T)?h(T):m(T));return N.logic==="and"?k.every(Boolean):k.some(Boolean)},[m]),y=v.useCallback(N=>Cu(N)?h(N):m(N),[m,h]),S=v.useCallback(()=>{const N=new Set,k=new Set,T=new Set,P=new Set,E=new Set;e.forEach(M=>{const z=l(M);M.hidden||N.add(z),M.disabled||k.add(z),M.validation?.some(V=>V.type==="required")&&T.add(z)});let C=!1;if(n!=null&&o?.length)for(const M of o){if(!Nw(n,M.when))continue;const{action:z,target:V}=M.then;if(z==="disableForm")C=!0;else if(z==="enableForm")C=!1;else{const X=kw(V,e,l);for(const D of X)switch(z){case"disable":k.delete(D);break;case"enable":k.add(D);break;case"hide":N.delete(D);break;case"show":N.add(D);break;case"readOnly":P.add(D),E.delete(D);break;case"editable":E.add(D),P.delete(D);break}}}e.forEach(M=>{M.conditions&&M.conditions.forEach(z=>{(y(z.when)?z.then:z.else||[]).forEach(D=>{switch(D.action){case"disableForm":C=!0;break;case"enableForm":C=!1;break;default:{const B=p(D.target,M);switch(D.action){case"show":N.add(B);break;case"hide":N.delete(B);break;case"enable":k.add(B);break;case"disable":k.delete(B);break;case"require":T.add(B);break;case"unrequire":T.delete(B);break}break}}})})});const I=M=>e.filter(z=>z.type!=="editButton"&&(z.name||z.key||z.id)).map(z=>l(z)),W=()=>e.filter(M=>M.type==="button").map(M=>l(M));return e.forEach(M=>{if(M.type!=="editButton")return;const z=l(M);if(!Qo(r?.[z]))return;const V=M.properties;V?.rules&&V.rules.length>0?V.rules.forEach(X=>{const D=[];X.allFields&&D.push(...I(M.id)),X.allButtons&&D.push(...W()),X.fieldNames?.length&&X.fieldNames.forEach(B=>{const L=e.find(K=>l(K)===B||K.id===B||K.name===B);D.push(L?l(L):B)}),X.buttonNames?.length&&D.push(...X.buttonNames),D.forEach(B=>{switch(X.action){case"enable":k.add(B),P.delete(B);break;case"disable":k.delete(B);break;case"show":N.add(B);break;case"hide":N.delete(B);break;case"readOnly":P.add(B);break;case"editable":E.add(B);break}})}):((V?.enableFieldNames??[]).forEach(X=>k.add(X)),(V?.disableFieldNames??[]).forEach(X=>k.delete(X)),(V?.showFieldNames??[]).forEach(X=>N.add(X)),(V?.hideFieldNames??[]).forEach(X=>N.delete(X)))}),{visible:Array.from(N),enabled:Array.from(k),required:Array.from(T),readOnly:Array.from(P),editable:Array.from(E),formDisabled:C}},[e,y,l,p,t,r,n,o]),w=v.useMemo(()=>S(),[S]);v.useLayoutEffect(()=>{s(w.visible),i(w.enabled),a(w.required),c(w.readOnly??[]),u(w.editable??[]),f(w.formDisabled??!1)},[w,s,i,a,c,u,f]);const A=v.useCallback(N=>w.visible.includes(N),[w.visible]),x=v.useCallback(N=>w.enabled.includes(N),[w.enabled]),F=v.useCallback(N=>w.required.includes(N),[w.required]);return{evaluateCondition:y,evaluateExpression:m,evaluateGroup:h,isFieldVisible:A,isFieldEnabled:x,isFieldRequired:F,visibleFields:w.visible,enabledFields:w.enabled,requiredFields:w.required}}function mn({className:e,type:t,...r}){return d.jsx("input",{type:t,"data-slot":"input",className:H("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground text-foreground dark:bg-secondary dark:border-input border-input flex h-9 w-full min-w-0 rounded-md border bg-background px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...r})}function Du(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function qn(...e){return t=>{let r=!1;const n=e.map(o=>{const s=Du(o,t);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let o=0;o<n.length;o++){const s=n[o];typeof s=="function"?s():Du(e[o],null)}}}}function Qe(...e){return b.useCallback(qn(...e),e)}var Dw=Symbol.for("react.lazy"),ni=b[" use ".trim().toString()];function Bw(e){return typeof e=="object"&&e!==null&&"then"in e}function Bu(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Dw&&"_payload"in e&&Bw(e._payload)}function cl(e){const t=$w(e),r=b.forwardRef((n,o)=>{let{children:s,...i}=n;Bu(s)&&typeof ni=="function"&&(s=ni(s._payload));const a=b.Children.toArray(s),c=a.find(zw);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}var $u=cl("Slot");function $w(e){const t=b.forwardRef((r,n)=>{let{children:o,...s}=r;if(Bu(o)&&typeof ni=="function"&&(o=ni(o._payload)),b.isValidElement(o)){const i=Vw(o),a=Uw(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var jw=Symbol("radix.slottable");function zw(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===jw}function Uw(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function Vw(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Hw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ww=Hw.reduce((e,t)=>{const r=cl(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Rw="Label",ju=b.forwardRef((e,t)=>d.jsx(Ww.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));ju.displayName=Rw;var Gw=ju;function Pn({className:e,...t}){return d.jsx(Gw,{"data-slot":"label",className:H("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50 mb-2",e),...t})}function ft(e){return`formsmith-field-${e.id}`}function oi(e){return`formsmith-label-${e.id}`}function Zo(e){return`formsmith-desc-${e.id}`}function es(e){return`formsmith-error-${e.id}`}function Lt(e,t){const r=[];return e.description&&r.push(Zo(e)),t&&r.push(es(e)),r.length>0?r.join(" "):void 0}function Jt(e){return e?!0:void 0}const Kw={body:{fontSize:"0.875rem",lineHeight:"1.25rem",fontWeight:400},heading:{fontSize:"1.125rem",lineHeight:"1.5rem",fontWeight:600},label:{fontSize:"0.875rem",lineHeight:"1.25rem",fontWeight:500},caption:{fontSize:"0.75rem",lineHeight:"1rem",fontWeight:400,color:"var(--muted-foreground)"}};function On(e){return e.ui?.cellStyle}function qw(e){const t=e.ui;if(!t)return;const r=t.fontToken?Kw[t.fontToken]:void 0;if(!(!r&&!t.wrapperStyle))return{...r,...t.wrapperStyle}}function Yw(e){return e.type==="button"||e.type==="editButton"}const At=({field:e,error:t,isRequired:r,children:n,className:o,hideLabel:s})=>{const{gridStretch:i}=Jo(),a=i&&Xs(e),c=!(s??e.appearance?.hideLabel)&&e.label,u=e.appearance?.labelPlacement||"top",f=qw(e),l=e.appearance?.minWidth!=null||e.appearance?.minHeight!=null?{...e.appearance.minWidth!=null?{minWidth:e.appearance.minWidth}:{},...e.appearance.minHeight!=null?{minHeight:e.appearance.minHeight}:{}}:void 0,p=e.appearance?.className,g=su(e),m=fo(e),h=Yw(e),y=Fr(e.appearance);return d.jsx("div",{className:H(Uv(u),u!=="floating"&&"space-y-2",a&&!h&&"flex-1 min-h-0 h-full",i&&h&&"w-full shrink-0 self-start",p,o),style:f,"data-field-appearance":u,children:d.jsxs("div",{className:H("flex flex-col min-w-0",tu(e.appearance),iu(e),a&&!h&&"flex-1 min-h-0",i&&h&&"shrink-0"),style:g,children:[c&&d.jsxs(Pn,{id:oi(e),htmlFor:ft(e),style:e.ui?.labelStyle,className:H(Vv(u,!!t)),children:[e.label,r&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),d.jsxs("div",{className:H(Hv(u),h&&i&&"min-h-min !grow-0 !shrink-0 basis-auto",m&&y!=="stretch"&&"items-start",h&&y==="stretch"&&"items-start w-full [&_button]:w-full",!h&&y==="stretch"&&"items-stretch",a&&!h&&"flex-1 min-h-0",o?.includes("flex")&&u==="top"&&"flex flex-col min-h-0"),style:l,children:[n,d.jsxs("div",{className:H("mt-1.5 min-h-[18px]",u==="center"&&"text-center",o?.includes("flex")&&"shrink-0"),children:[e.description&&!t&&d.jsx("p",{id:Zo(e),className:"text-xs text-muted-foreground",style:e.ui?.descriptionStyle,children:e.description}),t&&d.jsx("p",{id:es(e),className:"text-xs text-destructive",role:"alert",children:typeof t=="string"?t:String(t||"An error occurred")})]})]})]})})},si=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=v.useCallback(l=>{r(l.target.value)},[r]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsx(mn,{id:ft(e),type:"text",value:t||"",onChange:f,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,minLength:u?.minLength,maxLength:u?.maxLength,pattern:u?.pattern,autoComplete:u?.autoComplete,inputMode:u?.inputMode,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})})},dl=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=u?.precision!=null||u?.step!=null&&!Number.isInteger(u.step),l=v.useCallback(g=>{const m=u?.allowNegative!==!1,h=g.target.value,y=f?h.replace(m?/[^\d.-]/g:/[^\d.]/g,""):h.replace(m?/[^\d-]/g:/\D/g,"");if(y===""){r(null);return}const S=parseFloat(y);isNaN(S)||r(S)},[r,u?.allowNegative,f]),p=v.useCallback(g=>{(g.key==="ArrowUp"||g.key==="ArrowDown"||g.key==="PageUp"||g.key==="PageDown")&&g.preventDefault()},[]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[u?.prefix&&d.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.prefix}),d.jsx(mn,{id:ft(e),type:"text",inputMode:f?"decimal":"numeric",autoComplete:"off",value:t??"",onChange:l,onKeyDown:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",u?.prefix&&"pl-8",u?.suffix&&"pr-8",e.appearance?.className)}),u?.suffix&&d.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.suffix})]})})};const Xw=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Jw=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),zu=e=>{const t=Jw(e);return t.charAt(0).toUpperCase()+t.slice(1)},Uu=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),Qw=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Zw={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const eS=v.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:s,iconNode:i,...a},c)=>v.createElement("svg",{ref:c,...Zw,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:Uu("lucide",o),...!s&&!Qw(a)&&{"aria-hidden":"true"},...a},[...i.map(([u,f])=>v.createElement(u,f)),...Array.isArray(s)?s:[s]]));const qt=(e,t)=>{const r=v.forwardRef(({className:n,...o},s)=>v.createElement(eS,{ref:s,iconNode:t,className:Uu(`lucide-${Xw(zu(e))}`,`lucide-${e}`,n),...o}));return r.displayName=zu(e),r};const tS=qt("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const ii=qt("camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);const ai=qt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const ts=qt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Vu=qt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const rS=qt("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const nS=qt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const Hu=qt("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Wu=qt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ru=qt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const mo=qt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const oS=qt("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const sS=qt("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);const Gu=qt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const iS=qt("sliders-horizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);const Ku=qt("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);const rs=qt("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const li=qt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const ns=qt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),qu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=v.useCallback(f=>{r(f.target.value)},[r]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[d.jsx(oS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),d.jsx(mn,{id:ft(e),type:"email",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"email@example.com",disabled:s||e.disabled,readOnly:i||e.readOnly,autoComplete:"email",inputMode:"email","aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})},Yu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=v.useCallback(f=>{const l=f.target.value.replace(/[^\d\s+\-()]/g,"");r(l)},[r]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[d.jsx(sS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),d.jsx(mn,{id:ft(e),type:"tel",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"+91 12345 67890",disabled:s||e.disabled,readOnly:i||e.readOnly,autoComplete:"tel",inputMode:"tel","aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})};function Xu(e,t){return function(){return e.apply(t,arguments)}}const{toString:aS}=Object.prototype,{getPrototypeOf:ul}=Object,{iterator:ci,toStringTag:Ju}=Symbol,di=(e=>t=>{const r=aS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Wr=e=>(e=e.toLowerCase(),t=>di(t)===e),ui=e=>t=>typeof t===e,{isArray:ho}=Array,go=ui("undefined");function os(e){return e!==null&&!go(e)&&e.constructor!==null&&!go(e.constructor)&&pr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Qu=Wr("ArrayBuffer");function lS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Qu(e.buffer),t}const cS=ui("string"),pr=ui("function"),Zu=ui("number"),ss=e=>e!==null&&typeof e=="object",dS=e=>e===!0||e===!1,fi=e=>{if(di(e)!=="object")return!1;const t=ul(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Ju in e)&&!(ci in e)},uS=e=>{if(!ss(e)||os(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},fS=Wr("Date"),pS=Wr("File"),mS=e=>!!(e&&typeof e.uri<"u"),hS=e=>e&&typeof e.getParts<"u",gS=Wr("Blob"),yS=Wr("FileList"),bS=e=>ss(e)&&pr(e.pipe);function vS(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const ef=vS(),tf=typeof ef.FormData<"u"?ef.FormData:void 0,wS=e=>{let t;return e&&(tf&&e instanceof tf||pr(e.append)&&((t=di(e))==="formdata"||t==="object"&&pr(e.toString)&&e.toString()==="[object FormData]"))},SS=Wr("URLSearchParams"),[xS,AS,CS,ES]=["ReadableStream","Request","Response","Headers"].map(Wr),NS=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function is(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),ho(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(os(e))return;const s=r?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(n=0;n<i;n++)a=s[n],t.call(null,e[a],a,e)}}function rf(e,t){if(os(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}const Yn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,nf=e=>!go(e)&&e!==Yn;function fl(){const{caseless:e,skipUndefined:t}=nf(this)&&this||{},r={},n=(o,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;const i=e&&rf(r,s)||s;fi(r[i])&&fi(o)?r[i]=fl(r[i],o):fi(o)?r[i]=fl({},o):ho(o)?r[i]=o.slice():(!t||!go(o))&&(r[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&is(arguments[o],n);return r}const kS=(e,t,r,{allOwnKeys:n}={})=>(is(t,(o,s)=>{r&&pr(o)?Object.defineProperty(e,s,{value:Xu(o,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,s,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),_S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),TS=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},FS=(e,t,r,n)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!n||n(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=r!==!1&&ul(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},PS=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},OS=e=>{if(!e)return null;if(ho(e))return e;let t=e.length;if(!Zu(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},IS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ul(Uint8Array)),MS=(e,t)=>{const n=(e&&e[ci]).call(e);let o;for(;(o=n.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},LS=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},DS=Wr("HTMLFormElement"),BS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),of=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),$S=Wr("RegExp"),sf=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};is(r,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(n[s]=i||o)}),Object.defineProperties(e,n)},jS=e=>{sf(e,(t,r)=>{if(pr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(pr(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},zS=(e,t)=>{const r={},n=o=>{o.forEach(s=>{r[s]=!0})};return ho(e)?n(e):n(String(e).split(t)),r},US=()=>{},VS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function HS(e){return!!(e&&pr(e.append)&&e[Ju]==="FormData"&&e[ci])}const WS=e=>{const t=new Array(10),r=(n,o)=>{if(ss(n)){if(t.indexOf(n)>=0)return;if(os(n))return n;if(!("toJSON"in n)){t[o]=n;const s=ho(n)?[]:{};return is(n,(i,a)=>{const c=r(i,o+1);!go(c)&&(s[a]=c)}),t[o]=void 0,s}}return n};return r(e,0)},RS=Wr("AsyncFunction"),GS=e=>e&&(ss(e)||pr(e))&&pr(e.then)&&pr(e.catch),af=((e,t)=>e?setImmediate:t?((r,n)=>(Yn.addEventListener("message",({source:o,data:s})=>{o===Yn&&s===r&&n.length&&n.shift()()},!1),o=>{n.push(o),Yn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",pr(Yn.postMessage)),KS=typeof queueMicrotask<"u"?queueMicrotask.bind(Yn):typeof process<"u"&&process.nextTick||af,Y={isArray:ho,isArrayBuffer:Qu,isBuffer:os,isFormData:wS,isArrayBufferView:lS,isString:cS,isNumber:Zu,isBoolean:dS,isObject:ss,isPlainObject:fi,isEmptyObject:uS,isReadableStream:xS,isRequest:AS,isResponse:CS,isHeaders:ES,isUndefined:go,isDate:fS,isFile:pS,isReactNativeBlob:mS,isReactNative:hS,isBlob:gS,isRegExp:$S,isFunction:pr,isStream:bS,isURLSearchParams:SS,isTypedArray:IS,isFileList:yS,forEach:is,merge:fl,extend:kS,trim:NS,stripBOM:_S,inherits:TS,toFlatObject:FS,kindOf:di,kindOfTest:Wr,endsWith:PS,toArray:OS,forEachEntry:MS,matchAll:LS,isHTMLForm:DS,hasOwnProperty:of,hasOwnProp:of,reduceDescriptors:sf,freezeMethods:jS,toObjectSet:zS,toCamelCase:BS,noop:US,toFiniteNumber:VS,findKey:rf,global:Yn,isContextDefined:nf,isSpecCompliantForm:HS,toJSONObject:WS,isAsyncFn:RS,isThenable:GS,setImmediate:af,asap:KS,isIterable:e=>e!=null&&pr(e[ci])};let Ke=class Yb extends Error{static from(t,r,n,o,s,i){const a=new Yb(t.message,r||t.code,n,o,s);return a.cause=t,a.name=t.name,t.status!=null&&a.status==null&&(a.status=t.status),i&&Object.assign(a,i),a}constructor(t,r,n,o,s){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),n&&(this.config=n),o&&(this.request=o),s&&(this.response=s,this.status=s.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Y.toJSONObject(this.config),code:this.code,status:this.status}}};Ke.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Ke.ERR_BAD_OPTION="ERR_BAD_OPTION",Ke.ECONNABORTED="ECONNABORTED",Ke.ETIMEDOUT="ETIMEDOUT",Ke.ERR_NETWORK="ERR_NETWORK",Ke.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Ke.ERR_DEPRECATED="ERR_DEPRECATED",Ke.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Ke.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Ke.ERR_CANCELED="ERR_CANCELED",Ke.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Ke.ERR_INVALID_URL="ERR_INVALID_URL";const qS=null;function pl(e){return Y.isPlainObject(e)||Y.isArray(e)}function lf(e){return Y.endsWith(e,"[]")?e.slice(0,-2):e}function ml(e,t,r){return e?e.concat(t).map(function(o,s){return o=lf(o),!r&&s?"["+o+"]":o}).join(r?".":""):t}function YS(e){return Y.isArray(e)&&!e.some(pl)}const XS=Y.toFlatObject(Y,{},null,function(t){return/^is[A-Z]/.test(t)});function pi(e,t,r){if(!Y.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=Y.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,y){return!Y.isUndefined(y[h])});const n=r.metaTokens,o=r.visitor||f,s=r.dots,i=r.indexes,c=(r.Blob||typeof Blob<"u"&&Blob)&&Y.isSpecCompliantForm(t);if(!Y.isFunction(o))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(Y.isDate(m))return m.toISOString();if(Y.isBoolean(m))return m.toString();if(!c&&Y.isBlob(m))throw new Ke("Blob is not supported. Use a Buffer instead.");return Y.isArrayBuffer(m)||Y.isTypedArray(m)?c&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function f(m,h,y){let S=m;if(Y.isReactNative(t)&&Y.isReactNativeBlob(m))return t.append(ml(y,h,s),u(m)),!1;if(m&&!y&&typeof m=="object"){if(Y.endsWith(h,"{}"))h=n?h:h.slice(0,-2),m=JSON.stringify(m);else if(Y.isArray(m)&&YS(m)||(Y.isFileList(m)||Y.endsWith(h,"[]"))&&(S=Y.toArray(m)))return h=lf(h),S.forEach(function(A,x){!(Y.isUndefined(A)||A===null)&&t.append(i===!0?ml([h],x,s):i===null?h:h+"[]",u(A))}),!1}return pl(m)?!0:(t.append(ml(y,h,s),u(m)),!1)}const l=[],p=Object.assign(XS,{defaultVisitor:f,convertValue:u,isVisitable:pl});function g(m,h){if(!Y.isUndefined(m)){if(l.indexOf(m)!==-1)throw Error("Circular reference detected in "+h.join("."));l.push(m),Y.forEach(m,function(S,w){(!(Y.isUndefined(S)||S===null)&&o.call(t,S,Y.isString(w)?w.trim():w,h,p))===!0&&g(S,h?h.concat(w):[w])}),l.pop()}}if(!Y.isObject(e))throw new TypeError("data must be an object");return g(e),t}function cf(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function hl(e,t){this._pairs=[],e&&pi(e,this,t)}const df=hl.prototype;df.append=function(t,r){this._pairs.push([t,r])},df.toString=function(t){const r=t?function(n){return t.call(this,n,cf)}:cf;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function JS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function uf(e,t,r){if(!t)return e;const n=r&&r.encode||JS,o=Y.isFunction(r)?{serialize:r}:r,s=o&&o.serialize;let i;if(s?i=s(t,o):i=Y.isURLSearchParams(t)?t.toString():new hl(t,o).toString(n),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class ff{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Y.forEach(this.handlers,function(n){n!==null&&t(n)})}}const gl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},QS={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:hl,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},yl=typeof window<"u"&&typeof document<"u",bl=typeof navigator=="object"&&navigator||void 0,ZS=yl&&(!bl||["ReactNative","NativeScript","NS"].indexOf(bl.product)<0),e0=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",t0=yl&&window.location.href||"http://localhost",or={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yl,hasStandardBrowserEnv:ZS,hasStandardBrowserWebWorkerEnv:e0,navigator:bl,origin:t0},Symbol.toStringTag,{value:"Module"})),...QS};function r0(e,t){return pi(e,new or.classes.URLSearchParams,{visitor:function(r,n,o,s){return or.isNode&&Y.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function n0(e){return Y.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function o0(e){const t={},r=Object.keys(e);let n;const o=r.length;let s;for(n=0;n<o;n++)s=r[n],t[s]=e[s];return t}function pf(e){function t(r,n,o,s){let i=r[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),c=s>=r.length;return i=!i&&Y.isArray(o)?o.length:i,c?(Y.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!a):((!o[i]||!Y.isObject(o[i]))&&(o[i]=[]),t(r,n,o[i],s)&&Y.isArray(o[i])&&(o[i]=o0(o[i])),!a)}if(Y.isFormData(e)&&Y.isFunction(e.entries)){const r={};return Y.forEachEntry(e,(n,o)=>{t(n0(n),o,r,0)}),r}return null}function s0(e,t,r){if(Y.isString(e))try{return(t||JSON.parse)(e),Y.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const as={transitional:gl,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",o=n.indexOf("application/json")>-1,s=Y.isObject(t);if(s&&Y.isHTMLForm(t)&&(t=new FormData(t)),Y.isFormData(t))return o?JSON.stringify(pf(t)):t;if(Y.isArrayBuffer(t)||Y.isBuffer(t)||Y.isStream(t)||Y.isFile(t)||Y.isBlob(t)||Y.isReadableStream(t))return t;if(Y.isArrayBufferView(t))return t.buffer;if(Y.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return r0(t,this.formSerializer).toString();if((a=Y.isFileList(t))||n.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return pi(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(r.setContentType("application/json",!1),s0(t)):t}],transformResponse:[function(t){const r=this.transitional||as.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(Y.isResponse(t)||Y.isReadableStream(t))return t;if(t&&Y.isString(t)&&(n&&!this.responseType||o)){const i=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Ke.from(a,Ke.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:or.classes.FormData,Blob:or.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Y.forEach(["delete","get","head","post","put","patch"],e=>{as.headers[e]={}});const i0=Y.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),a0=e=>{const t={};let r,n,o;return e&&e.split(`
2
+ `).forEach(function(i){o=i.indexOf(":"),r=i.substring(0,o).trim().toLowerCase(),n=i.substring(o+1).trim(),!(!r||t[r]&&i0[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},mf=Symbol("internals");function ls(e){return e&&String(e).trim().toLowerCase()}function mi(e){return e===!1||e==null?e:Y.isArray(e)?e.map(mi):String(e).replace(/[\r\n]+$/,"")}function l0(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const c0=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function vl(e,t,r,n,o){if(Y.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!Y.isString(t)){if(Y.isString(n))return t.indexOf(n)!==-1;if(Y.isRegExp(n))return n.test(t)}}function d0(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function u0(e,t){const r=Y.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(o,s,i){return this[n].call(this,t,o,s,i)},configurable:!0})})}let mr=class{constructor(t){t&&this.set(t)}set(t,r,n){const o=this;function s(a,c,u){const f=ls(c);if(!f)throw new Error("header name must be a non-empty string");const l=Y.findKey(o,f);(!l||o[l]===void 0||u===!0||u===void 0&&o[l]!==!1)&&(o[l||c]=mi(a))}const i=(a,c)=>Y.forEach(a,(u,f)=>s(u,f,c));if(Y.isPlainObject(t)||t instanceof this.constructor)i(t,r);else if(Y.isString(t)&&(t=t.trim())&&!c0(t))i(a0(t),r);else if(Y.isObject(t)&&Y.isIterable(t)){let a={},c,u;for(const f of t){if(!Y.isArray(f))throw TypeError("Object iterator must return a key-value pair");a[u=f[0]]=(c=a[u])?Y.isArray(c)?[...c,f[1]]:[c,f[1]]:f[1]}i(a,r)}else t!=null&&s(r,t,n);return this}get(t,r){if(t=ls(t),t){const n=Y.findKey(this,t);if(n){const o=this[n];if(!r)return o;if(r===!0)return l0(o);if(Y.isFunction(r))return r.call(this,o,n);if(Y.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=ls(t),t){const n=Y.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||vl(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let o=!1;function s(i){if(i=ls(i),i){const a=Y.findKey(n,i);a&&(!r||vl(n,n[a],a,r))&&(delete n[a],o=!0)}}return Y.isArray(t)?t.forEach(s):s(t),o}clear(t){const r=Object.keys(this);let n=r.length,o=!1;for(;n--;){const s=r[n];(!t||vl(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const r=this,n={};return Y.forEach(this,(o,s)=>{const i=Y.findKey(n,s);if(i){r[i]=mi(o),delete r[s];return}const a=t?d0(s):String(s).trim();a!==s&&delete r[s],r[a]=mi(o),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return Y.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&Y.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
3
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){const n=(this[mf]=this[mf]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=ls(i);n[a]||(u0(o,i),n[a]=!0)}return Y.isArray(t)?t.forEach(s):s(t),this}};mr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Y.reduceDescriptors(mr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),Y.freezeMethods(mr);function wl(e,t){const r=this||as,n=t||r,o=mr.from(n.headers);let s=n.data;return Y.forEach(e,function(a){s=a.call(r,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function hf(e){return!!(e&&e.__CANCEL__)}let cs=class extends Ke{constructor(t,r,n){super(t??"canceled",Ke.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function gf(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Ke("Request failed with status code "+r.status,[Ke.ERR_BAD_REQUEST,Ke.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function f0(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function p0(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),f=n[s];i||(i=u),r[o]=c,n[o]=u;let l=s,p=0;for(;l!==o;)p+=r[l++],l=l%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const g=f&&u-f;return g?Math.round(p*1e3/g):void 0}}function m0(e,t){let r=0,n=1e3/t,o,s;const i=(u,f=Date.now())=>{r=f,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const f=Date.now(),l=f-r;l>=n?i(u,f):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},n-l)))},()=>o&&i(o)]}const hi=(e,t,r=3)=>{let n=0;const o=p0(50,250);return m0(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-n,u=o(c),f=i<=a;n=i;const l={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&f?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(l)},r)},yf=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},bf=e=>(...t)=>Y.asap(()=>e(...t)),h0=or.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,or.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(or.origin),or.navigator&&/(msie|trident)/i.test(or.navigator.userAgent)):()=>!0,g0=or.hasStandardBrowserEnv?{write(e,t,r,n,o,s,i){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];Y.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),Y.isString(n)&&a.push(`path=${n}`),Y.isString(o)&&a.push(`domain=${o}`),s===!0&&a.push("secure"),Y.isString(i)&&a.push(`SameSite=${i}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function y0(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function b0(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function vf(e,t,r){let n=!y0(t);return e&&(n||r==!1)?b0(e,t):t}const wf=e=>e instanceof mr?{...e}:e;function Xn(e,t){t=t||{};const r={};function n(u,f,l,p){return Y.isPlainObject(u)&&Y.isPlainObject(f)?Y.merge.call({caseless:p},u,f):Y.isPlainObject(f)?Y.merge({},f):Y.isArray(f)?f.slice():f}function o(u,f,l,p){if(Y.isUndefined(f)){if(!Y.isUndefined(u))return n(void 0,u,l,p)}else return n(u,f,l,p)}function s(u,f){if(!Y.isUndefined(f))return n(void 0,f)}function i(u,f){if(Y.isUndefined(f)){if(!Y.isUndefined(u))return n(void 0,u)}else return n(void 0,f)}function a(u,f,l){if(l in t)return n(u,f);if(l in e)return n(void 0,u)}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,f,l)=>o(wf(u),wf(f),l,!0)};return Y.forEach(Object.keys({...e,...t}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;const l=Y.hasOwnProp(c,f)?c[f]:o,p=l(e[f],t[f],f);Y.isUndefined(p)&&l!==a||(r[f]=p)}),r}const Sf=e=>{const t=Xn({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=mr.from(i),t.url=uf(vf(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Y.isFormData(r)){if(or.hasStandardBrowserEnv||or.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(Y.isFunction(r.getHeaders)){const c=r.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([f,l])=>{u.includes(f.toLowerCase())&&i.set(f,l)})}}if(or.hasStandardBrowserEnv&&(n&&Y.isFunction(n)&&(n=n(t)),n||n!==!1&&h0(t.url))){const c=o&&s&&g0.read(s);c&&i.set(o,c)}return t},v0=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=Sf(e);let s=o.data;const i=mr.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,f,l,p,g,m;function h(){g&&g(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(f),o.signal&&o.signal.removeEventListener("abort",f)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function S(){if(!y)return;const A=mr.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),F={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:A,config:e,request:y};gf(function(k){r(k),h()},function(k){n(k),h()},F),y=null}"onloadend"in y?y.onloadend=S:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(S)},y.onabort=function(){y&&(n(new Ke("Request aborted",Ke.ECONNABORTED,e,y)),y=null)},y.onerror=function(x){const F=x&&x.message?x.message:"Network Error",N=new Ke(F,Ke.ERR_NETWORK,e,y);N.event=x||null,n(N),y=null},y.ontimeout=function(){let x=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const F=o.transitional||gl;o.timeoutErrorMessage&&(x=o.timeoutErrorMessage),n(new Ke(x,F.clarifyTimeoutError?Ke.ETIMEDOUT:Ke.ECONNABORTED,e,y)),y=null},s===void 0&&i.setContentType(null),"setRequestHeader"in y&&Y.forEach(i.toJSON(),function(x,F){y.setRequestHeader(F,x)}),Y.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),u&&([p,m]=hi(u,!0),y.addEventListener("progress",p)),c&&y.upload&&([l,g]=hi(c),y.upload.addEventListener("progress",l),y.upload.addEventListener("loadend",g)),(o.cancelToken||o.signal)&&(f=A=>{y&&(n(!A||A.type?new cs(null,e,y):A),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(f),o.signal&&(o.signal.aborted?f():o.signal.addEventListener("abort",f)));const w=f0(o.url);if(w&&or.protocols.indexOf(w)===-1){n(new Ke("Unsupported protocol "+w+":",Ke.ERR_BAD_REQUEST,e));return}y.send(s||null)})},w0=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,o;const s=function(u){if(!o){o=!0,a();const f=u instanceof Error?u:this.reason;n.abort(f instanceof Ke?f:new cs(f instanceof Error?f.message:f))}};let i=t&&setTimeout(()=>{i=null,s(new Ke(`timeout of ${t}ms exceeded`,Ke.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:c}=n;return c.unsubscribe=()=>Y.asap(a),c}},S0=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,o;for(;n<r;)o=n+t,yield e.slice(n,o),n=o},x0=async function*(e,t){for await(const r of A0(e))yield*S0(r,t)},A0=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},xf=(e,t,r,n)=>{const o=x0(e,t);let s=0,i,a=c=>{i||(i=!0,n&&n(c))};return new ReadableStream({async pull(c){try{const{done:u,value:f}=await o.next();if(u){a(),c.close();return}let l=f.byteLength;if(r){let p=s+=l;r(p)}c.enqueue(new Uint8Array(f))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},Af=64*1024,{isFunction:gi}=Y,C0=(({Request:e,Response:t})=>({Request:e,Response:t}))(Y.global),{ReadableStream:Cf,TextEncoder:Ef}=Y.global,Nf=(e,...t)=>{try{return!!e(...t)}catch{return!1}},E0=e=>{e=Y.merge.call({skipUndefined:!0},C0,e);const{fetch:t,Request:r,Response:n}=e,o=t?gi(t):typeof fetch=="function",s=gi(r),i=gi(n);if(!o)return!1;const a=o&&gi(Cf),c=o&&(typeof Ef=="function"?(m=>h=>m.encode(h))(new Ef):async m=>new Uint8Array(await new r(m).arrayBuffer())),u=s&&a&&Nf(()=>{let m=!1;const h=new Cf,y=new r(or.origin,{body:h,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return h.cancel(),m&&!y}),f=i&&a&&Nf(()=>Y.isReadableStream(new n("").body)),l={stream:f&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!l[m]&&(l[m]=(h,y)=>{let S=h&&h[m];if(S)return S.call(h);throw new Ke(`Response type '${m}' is not supported`,Ke.ERR_NOT_SUPPORT,y)})});const p=async m=>{if(m==null)return 0;if(Y.isBlob(m))return m.size;if(Y.isSpecCompliantForm(m))return(await new r(or.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(Y.isArrayBufferView(m)||Y.isArrayBuffer(m))return m.byteLength;if(Y.isURLSearchParams(m)&&(m=m+""),Y.isString(m))return(await c(m)).byteLength},g=async(m,h)=>{const y=Y.toFiniteNumber(m.getContentLength());return y??p(h)};return async m=>{let{url:h,method:y,data:S,signal:w,cancelToken:A,timeout:x,onDownloadProgress:F,onUploadProgress:N,responseType:k,headers:T,withCredentials:P="same-origin",fetchOptions:E}=Sf(m),C=t||fetch;k=k?(k+"").toLowerCase():"text";let I=w0([w,A&&A.toAbortSignal()],x),W=null;const M=I&&I.unsubscribe&&(()=>{I.unsubscribe()});let z;try{if(N&&u&&y!=="get"&&y!=="head"&&(z=await g(T,S))!==0){let K=new r(h,{method:"POST",body:S,duplex:"half"}),ie;if(Y.isFormData(S)&&(ie=K.headers.get("content-type"))&&T.setContentType(ie),K.body){const[j,U]=yf(z,hi(bf(N)));S=xf(K.body,Af,j,U)}}Y.isString(P)||(P=P?"include":"omit");const V=s&&"credentials"in r.prototype,X={...E,signal:I,method:y.toUpperCase(),headers:T.normalize().toJSON(),body:S,duplex:"half",credentials:V?P:void 0};W=s&&new r(h,X);let D=await(s?C(W,E):C(h,X));const B=f&&(k==="stream"||k==="response");if(f&&(F||B&&M)){const K={};["status","statusText","headers"].forEach(le=>{K[le]=D[le]});const ie=Y.toFiniteNumber(D.headers.get("content-length")),[j,U]=F&&yf(ie,hi(bf(F),!0))||[];D=new n(xf(D.body,Af,j,()=>{U&&U(),M&&M()}),K)}k=k||"text";let L=await l[Y.findKey(l,k)||"text"](D,m);return!B&&M&&M(),await new Promise((K,ie)=>{gf(K,ie,{data:L,headers:mr.from(D.headers),status:D.status,statusText:D.statusText,config:m,request:W})})}catch(V){throw M&&M(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new Ke("Network Error",Ke.ERR_NETWORK,m,W,V&&V.response),{cause:V.cause||V}):Ke.from(V,V&&V.code,m,W,V&&V.response)}}},N0=new Map,kf=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:o}=t,s=[n,o,r];let i=s.length,a=i,c,u,f=N0;for(;a--;)c=s[a],u=f.get(c),u===void 0&&f.set(c,u=a?new Map:E0(t)),f=u;return u};kf();const Sl={http:qS,xhr:v0,fetch:{get:kf}};Y.forEach(Sl,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const _f=e=>`- ${e}`,k0=e=>Y.isFunction(e)||e===null||e===!1;function _0(e,t){e=Y.isArray(e)?e:[e];const{length:r}=e;let n,o;const s={};for(let i=0;i<r;i++){n=e[i];let a;if(o=n,!k0(n)&&(o=Sl[(a=String(n)).toLowerCase()],o===void 0))throw new Ke(`Unknown adapter '${a}'`);if(o&&(Y.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=r?i.length>1?`since :
4
+ `+i.map(_f).join(`
5
+ `):" "+_f(i[0]):"as no adapter specified";throw new Ke("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o}const Tf={getAdapter:_0,adapters:Sl};function xl(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new cs(null,e)}function Ff(e){return xl(e),e.headers=mr.from(e.headers),e.data=wl.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Tf.getAdapter(e.adapter||as.adapter,e)(e).then(function(n){return xl(e),n.data=wl.call(e,e.transformResponse,n),n.headers=mr.from(n.headers),n},function(n){return hf(n)||(xl(e),n&&n.response&&(n.response.data=wl.call(e,e.transformResponse,n.response),n.response.headers=mr.from(n.response.headers))),Promise.reject(n)})}const Pf="1.14.0",yi={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{yi[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Of={};yi.transitional=function(t,r,n){function o(s,i){return"[Axios v"+Pf+"] Transitional option '"+s+"'"+i+(n?". "+n:"")}return(s,i,a)=>{if(t===!1)throw new Ke(o(i," has been removed"+(r?" in "+r:"")),Ke.ERR_DEPRECATED);return r&&!Of[i]&&(Of[i]=!0,console.warn(o(i," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(s,i,a):!0}},yi.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function T0(e,t,r){if(typeof e!="object")throw new Ke("options must be an object",Ke.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const s=n[o],i=t[s];if(i){const a=e[s],c=a===void 0||i(a,s,e);if(c!==!0)throw new Ke("option "+s+" must be "+c,Ke.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Ke("Unknown option "+s,Ke.ERR_BAD_OPTION)}}const bi={assertOptions:T0,validators:yi},Ir=bi.validators;let Jn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new ff,response:new ff}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
6
+ `+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Xn(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&bi.assertOptions(n,{silentJSONParsing:Ir.transitional(Ir.boolean),forcedJSONParsing:Ir.transitional(Ir.boolean),clarifyTimeoutError:Ir.transitional(Ir.boolean),legacyInterceptorReqResOrdering:Ir.transitional(Ir.boolean)},!1),o!=null&&(Y.isFunction(o)?r.paramsSerializer={serialize:o}:bi.assertOptions(o,{encode:Ir.function,serialize:Ir.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),bi.assertOptions(r,{baseUrl:Ir.spelling("baseURL"),withXsrfToken:Ir.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&Y.merge(s.common,s[r.method]);s&&Y.forEach(["delete","get","head","post","put","patch","common"],m=>{delete s[m]}),r.headers=mr.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(r)===!1)return;c=c&&h.synchronous;const y=r.transitional||gl;y&&y.legacyInterceptorReqResOrdering?a.unshift(h.fulfilled,h.rejected):a.push(h.fulfilled,h.rejected)});const u=[];this.interceptors.response.forEach(function(h){u.push(h.fulfilled,h.rejected)});let f,l=0,p;if(!c){const m=[Ff.bind(this),void 0];for(m.unshift(...a),m.push(...u),p=m.length,f=Promise.resolve(r);l<p;)f=f.then(m[l++],m[l++]);return f}p=a.length;let g=r;for(;l<p;){const m=a[l++],h=a[l++];try{g=m(g)}catch(y){h.call(this,y);break}}try{f=Ff.call(this,g)}catch(m){return Promise.reject(m)}for(l=0,p=u.length;l<p;)f=f.then(u[l++],u[l++]);return f}getUri(t){t=Xn(this.defaults,t);const r=vf(t.baseURL,t.url,t.allowAbsoluteUrls);return uf(r,t.params,t.paramsSerializer)}};Y.forEach(["delete","get","head","options"],function(t){Jn.prototype[t]=function(r,n){return this.request(Xn(n||{},{method:t,url:r,data:(n||{}).data}))}}),Y.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,a){return this.request(Xn(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Jn.prototype[t]=r(),Jn.prototype[t+"Form"]=r(!0)});let F0=class Xb{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{n.subscribe(a),s=a}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,a){n.reason||(n.reason=new cs(s,i,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Xb(function(o){t=o}),cancel:t}}};function P0(e){return function(r){return e.apply(null,r)}}function O0(e){return Y.isObject(e)&&e.isAxiosError===!0}const Al={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Al).forEach(([e,t])=>{Al[t]=e});function If(e){const t=new Jn(e),r=Xu(Jn.prototype.request,t);return Y.extend(r,Jn.prototype,t,{allOwnKeys:!0}),Y.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return If(Xn(e,o))},r}const Ct=If(as);Ct.Axios=Jn,Ct.CanceledError=cs,Ct.CancelToken=F0,Ct.isCancel=hf,Ct.VERSION=Pf,Ct.toFormData=pi,Ct.AxiosError=Ke,Ct.Cancel=Ct.CanceledError,Ct.all=function(t){return Promise.all(t)},Ct.spread=P0,Ct.isAxiosError=O0,Ct.mergeConfig=Xn,Ct.AxiosHeaders=mr,Ct.formToJSON=e=>pf(Y.isHTMLForm(e)?new FormData(e):e),Ct.getAdapter=Tf.getAdapter,Ct.HttpStatusCode=Al,Ct.default=Ct;const{Axios:oM,AxiosError:I0,CanceledError:sM,isCancel:iM,CancelToken:aM,VERSION:lM,all:cM,Cancel:dM,isAxiosError:uM,spread:fM,toFormData:pM,AxiosHeaders:mM,HttpStatusCode:hM,formToJSON:gM,getAdapter:yM,mergeConfig:bM}=Ct;let Mf=null;function M0(e){Mf=e}function Lf(){return(Mf?.()??"").replace(/\/+$/,"")}function Mr(e){const t=typeof e=="string"?e.trim():"";if(!t||/^https?:\/\//i.test(t))return t;const r=Lf();return r?t.startsWith("/")?`${r}${t}`:`${r}/${t}`:t}const Df={};function nn(){const e=Df?.VITE_CLIENT_ID?.trim()||Df?.VITE_DEFAULT_CLIENT_ID?.trim()||null;return(typeof localStorage<"u"?localStorage.getItem("clientId"):null)||(typeof sessionStorage<"u"?sessionStorage.getItem("clientId"):null)||(typeof window<"u"?new URLSearchParams(window.location.search).get("clientId"):null)||e}function L0(e){return!e||typeof e!="object"?!1:e.userId!=null&&String(e.userId)!==""||e.userType!=null&&String(e.userType)!==""||e.role!=null&&String(e.role)!==""}function D0(e){if(!e||typeof e!="object")return;const t={};for(const[r,n]of Object.entries(e))n!==void 0&&n!==""&&(t[r]=n);return Object.keys(t).length>0?t:void 0}const Qn=du(e=>({viewerContext:void 0,authHeaders:void 0,_setViewerContext:t=>e({viewerContext:L0(t)?t:void 0}),_setAuthHeaders:t=>e({authHeaders:D0(t)}),_reset:()=>e({viewerContext:void 0,authHeaders:void 0})}));function B0(e){Qn.getState()._setViewerContext(e)}function $0(e){Qn.getState()._setAuthHeaders(e)}function j0(){Qn.getState()._reset()}function Bf(){return Qn.getState().viewerContext}function ds(){return Qn.getState().authHeaders}const $f={};let jf=null;function z0(e){jf=e}function U0(){return($f?.VITE_API_BASE_URL?.trim()||$f?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const Qt=Ct.create({baseURL:U0()});Qt.interceptors.request.use(e=>{const t=nn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=jf?.();if((!r||Object.keys(r).length===0)&&(r=ds()),r){const n=e.headers??{};for(const[o,s]of Object.entries(r))s!==void 0&&s!==""&&(n[o]=s);e.headers=n}return e});const V0=/^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/i;function zf(e){const t=e.trim().match(V0);return t?t[1]:e}const H0={applicantId:["id","applicant_id"],applicant_id:["id","applicantId"],id:["applicantId","applicant_id"]};function Rr(e,t,r,n,o,s){let i=e;if(o&&typeof e=="string"&&(i=i.replace(/\{resp:([^}]+)\}/g,(a,c)=>{const u=c.trim().split(".");if(u.length<2)return a;const f=u[0],l=u.slice(1).join("."),p=o[f];if(p==null)return a;const g=Re(p,l);return g==null?a:String(g)}),i.includes("{documentId}")||i.includes("%7BdocumentId%7D"))){let a;for(const c of Object.values(o)){const u=Re(c,"data.id")??Re(c,"data.documentId");if(u!=null){a=String(u);break}}a&&(i=i.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}if(i.includes("{documentId}")||i.includes("%7BdocumentId%7D")){let a;const c=t?.documentId??(t&&Re(t,"documentId")),u=n?.documentId??(n&&Re(n,"documentId"));c!=null&&c!==""?a=String(c):u!=null&&u!==""&&(a=String(u)),a&&(i=i.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}return i=i.replace(/\{api:([^}]+)\}/g,(a,c)=>{const u=c.trim();if(s==null||u==="")return a;const f=Re(s,u);return f==null?a:String(f)}),i=i.replace(/\{(?:ctx:|\@)(\w+)\}/g,(a,c)=>n&&n[c]!==void 0&&n[c]!==null?String(n[c]):a),i=i.replace(/\{(\w+)\}/g,(a,c)=>{if(a.includes("ctx:")||a.includes("@"))return a;const u=r[c];if(u!=null)return zf(String(u));let f=t[c];if(f==null||f===""){const l=Object.keys(t).find(p=>p.toLowerCase()===c.toLowerCase());l&&(f=t[l])}if((f==null||f==="")&&(f=n?.[c]),f==null||f===""){const l=H0[c];if(l)for(const p of l){const g=t[p]??n?.[p];if(g!=null&&g!==""){f=g;break}}}return f!=null&&f!==""?zf(String(f)):a}),i}const W0=60,R0=3,G0="Resend OTP in {seconds} sec · Attempts remaining: {attempts}",K0="Resend OTP";function q0(e){const t=e.properties?.resend;return!t?.enabled||!t.resendApiEndpoint?.trim()?null:t}function Uf(e){const t=Number(e.cooldownSeconds);return!Number.isFinite(t)||t<0?W0:Math.round(t)}function Vf(e){const t=Number(e.maxAttempts);return!Number.isFinite(t)||t<1?R0:Math.round(t)}function Hf(e,t,r){if(!t?.trim()||e==null)return r;const n=Re(e,t.trim()),o=typeof n=="number"?n:Number(n);return!Number.isFinite(o)||o<0?r:Math.round(o)}function Wf(e,t,r){if(!t?.trim()||e==null)return r;const n=Re(e,t.trim()),o=typeof n=="number"?n:Number(n);return!Number.isFinite(o)||o<0?r:Math.round(o)}function Y0(e,t){const r=Vf(e),n=Uf(e),o=e.initialAttemptsPath??"data.attempts_remaining",s=e.initialCooldownPath??"data.resend_cooldown_seconds";return{attemptsRemaining:Hf(t,o,r),secondsRemaining:Wf(t,s,n)}}function X0(e,t,r){Vf(e);const n=Uf(e),o=e.attemptsResponsePath??"data.attempts_remaining",s=e.cooldownResponsePath??"data.resend_cooldown_seconds";return{attemptsRemaining:Hf(t,o,r),secondsRemaining:Wf(t,s,n)}}function J0(e,t,r,n){const o=e.resendLinkText?.trim()||K0,s=!n&&t<=0&&r>0;return{seconds:Math.max(0,t),attempts:Math.max(0,r),resendText:o,resendEnabled:s}}function Q0(e,t){const r=e.statusTemplate?.trim()||G0,n=t.seconds>0?` in ${t.seconds} sec`:"",o=t.resendEnabled?t.resendText:t.seconds>0?`${t.resendText}${n}`:t.resendText;return r.replace(/\{seconds\}/g,String(t.seconds)).replace(/\{attempts\}/g,String(t.attempts)).replace(/\{resend\}/g,o)}async function Z0(e,t={}){const r=e.resendApiEndpoint?.trim();if(!r)throw new Error("Resend API endpoint is not configured");const{formValues:n={},urlParams:o={},submissionContext:s,prepopulateResponse:i}=t,a=m=>Rr(m,n,o,s,void 0,i),c=(e.resendApiMethod??"POST").toUpperCase();let u=Mr(a(r));const f=e.resendApiQueryParams??[];if(f.length){const m=new URLSearchParams;f.forEach(({key:y,value:S})=>{y.trim()&&m.append(y,a(S))});const h=m.toString();h&&(u=`${u}${u.includes("?")?"&":"?"}${h}`)}const l={};let p=!1;(e.resendApiHeaders??[]).forEach(({key:m,value:h})=>{m.trim()&&(l[m]=a(h))});let g;c!=="GET"&&(e.resendApiBodyFields??[]).length&&(g={},e.resendApiBodyFields.forEach(({key:m,value:h})=>{m.trim()&&(g[m]=a(h))}),p=!0),p&&!l["Content-Type"]&&!l["content-type"]&&(l["Content-Type"]="application/json");try{return c==="GET"?(await Qt.get(u,{headers:Object.keys(l).length?l:void 0})).data:(await Qt.request({url:u,method:c,data:g??{},headers:Object.keys(l).length?l:void 0})).data}catch(m){const h=m,y=h.response?.status,S=typeof h.response?.data=="string"?h.response.data:h.message??"Request failed";throw new Error(y?`HTTP ${y}: ${S}`:String(S))}}function Gr(e){if(e instanceof Error){const t=e.message;if(t&&(t.includes("{")||t.includes("[")))try{const r=t.match(/\{[\s\S]*\}/);if(r){const n=JSON.parse(r[0]);return yo(n)}}catch{}if(e.response){const r=e.response;if(typeof r=="string")try{const n=JSON.parse(r);return yo(n)}catch{return r}else if(typeof r=="object")return yo(r)}return t}if(e instanceof I0)return e.response?.data?yo(e.response.data):e.message||"An unexpected error occurred";if(typeof e=="string")try{const t=JSON.parse(e);return yo(t)}catch{return e}return typeof e=="object"&&e!==null?yo(e):"An unexpected error occurred"}function yo(e){if(e?.display_message&&typeof e.display_message=="string")return e.display_message.trim();if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.error?.explanation&&Array.isArray(e.error.explanation)){const t=e.error.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.explanation&&Array.isArray(e.explanation)){const t=e.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r!=null&&String(r).trim());if(t.length>0)return t.map(r=>typeof r=="string"?r:r?.message||String(r)).join(". ")}return e?.message&&typeof e.message=="string"?e.message:e?.display_message&&typeof e.display_message=="string"?e.display_message:e?.error?.display_message&&typeof e.error.display_message=="string"?e.error.display_message:e?.error?.message&&typeof e.error.message=="string"?e.error.message:e?.error&&typeof e.error=="string"?e.error:"An unexpected error occurred"}const Rf=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u={},urlParams:f={},submissionContext:l,prepopulateResponse:p})=>{const g=pu(e),m=e.properties?.numericOnly!==!1,h=q0(e),y=v.useRef([]),S=v.useMemo(()=>lw(t,g),[t,g]),w=v.useMemo(()=>h?Y0(h,p):null,[h,p]),[A,x]=v.useState(()=>w?.secondsRemaining??0),[F,N]=v.useState(()=>w?.attemptsRemaining??0),[k,T]=v.useState(!1);v.useEffect(()=>{y.current=y.current.slice(0,g)},[g]),v.useEffect(()=>{w&&(x(w.secondsRemaining),N(w.attemptsRemaining))},[w]),v.useEffect(()=>{if(!h||A<=0)return;const L=window.setInterval(()=>{x(K=>K<=1?0:K-1)},1e3);return()=>window.clearInterval(L)},[h,A>0]);const P=v.useMemo(()=>h?J0(h,A,F,k):null,[h,A,F,k]),E=v.useMemo(()=>!h||!P?"":Q0(h,P),[h,P]),C=v.useCallback(async()=>{if(!(!h||!P?.resendEnabled||k)){T(!0);try{const L=await Z0(h,{formValues:u,urlParams:f,submissionContext:l,prepopulateResponse:p}),K=X0(h,L,F);N(K.attemptsRemaining),x(K.secondsRemaining),r(""),ct.toast.success("OTP sent successfully.")}catch(L){ct.toast.error(Gr(L))}finally{T(!1)}}},[h,P?.resendEnabled,k,u,f,l,p,F,r]),I=v.useCallback(L=>{r(cw(L))},[r]),W=v.useCallback(L=>{const K=y.current[L];K&&(K.focus(),K.select())},[]),M=v.useCallback((L,K=0)=>{const ie=m?L.replace(/\D/g,""):L.replace(/\s/g,"");if(!ie)return;const j=[...S];let U=K;for(let oe=0;oe<ie.length&&U<g;oe+=1)j[U]=ie[oe]??"",U+=1;I(j);const le=Math.min(U,g-1);requestAnimationFrame(()=>W(le))},[S,I,W,m,g]),z=v.useCallback((L,K)=>{if(i||s||e.readOnly||e.disabled)return;const ie=m?K.replace(/\D/g,""):K.slice(-1),j=[...S];j[L]=ie,I(j),ie&&L<g-1&&requestAnimationFrame(()=>W(L+1))},[S,s,I,e.disabled,e.readOnly,W,m,g,i]),V=v.useCallback((L,K)=>{if(K.key==="Backspace"&&!S[L]&&L>0){K.preventDefault();const ie=[...S];ie[L-1]="",I(ie),W(L-1);return}if(K.key==="ArrowLeft"&&L>0){K.preventDefault(),W(L-1);return}K.key==="ArrowRight"&&L<g-1&&(K.preventDefault(),W(L+1))},[S,I,W,g]),X=v.useCallback((L,K)=>{K.preventDefault();const ie=K.clipboardData.getData("text");M(ie,L)},[M]),D=ft(e),B=h?.resendLinkText?.trim()||"Resend OTP";return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsx("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-labelledby":`${D}-label`,"aria-describedby":Lt(e,!!o),children:S.map((L,K)=>d.jsx(mn,{ref:ie=>{y.current[K]=ie},id:K===0?D:`${D}-${K}`,type:m?"tel":"text",inputMode:m?"numeric":"text",autoComplete:K===0?"one-time-code":"off",maxLength:1,value:L,onChange:ie=>z(K,ie.target.value),onKeyDown:ie=>V(K,ie),onPaste:ie=>X(K,ie),onBlur:K===g-1?n:void 0,disabled:s||e.disabled,readOnly:i||e.readOnly,"aria-label":`${e.label||e.name} digit ${K+1} of ${g}`,"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),"h-10 w-10 text-center text-base font-medium p-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)},`${e.id}-otp-${K}`))}),h&&P&&d.jsx("p",{className:"text-sm text-muted-foreground","aria-live":"polite",children:P.resendEnabled?d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"text-primary underline-offset-4 hover:underline disabled:opacity-50",disabled:s||k,onClick:C,children:k?"Sending…":B}),d.jsx("span",{children:` · Attempts remaining: ${F}`})]}):d.jsx("span",{children:F<=0&&A<=0?"No attempts remaining.":E})})]})})};function ex({className:e,maxLength:t,showCharacterCount:r=!1,autoResize:n=!1,onChange:o,value:s,...i}){const a=b.useRef(null),[c,u]=b.useState(0),f=l=>{const p=l.target.value;u(p.length),n&&a.current&&(a.current.style.height="auto",a.current.style.height=`${a.current.scrollHeight}px`),o&&o(l)};return b.useEffect(()=>{s&&u(String(s).length)},[s]),d.jsxs("div",{className:"space-y-1",children:[d.jsx("textarea",{ref:a,"data-slot":"textarea",className:H("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n&&"resize-none",e),maxLength:t,onChange:f,value:s,...i}),r&&d.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[d.jsxs("span",{children:[c," characters"]}),t&&d.jsxs("span",{children:[t-c," remaining"]})]})]})}const Gf=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const{gridStretch:u}=Jo(),f=u&&Xs(e),l=e.properties,p=v.useCallback(y=>{r(y.target.value)},[r]),g=(t||"").length,m=l?.maxLength,h=m&&m>0;return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:H("relative flex flex-col",f&&"flex-1 min-h-0"),children:[d.jsx(ex,{id:ft(e),value:t||"",onChange:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,minLength:l?.minLength,maxLength:l?.maxLength,rows:2,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(Qd(e.appearance),"resize-y",f&&"min-h-[120px] flex-1 flex-shrink-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),h&&d.jsxs("span",{className:"absolute bottom-2 right-2 text-xs text-muted-foreground",children:[g,"/",m]})]})})};function us(e,[t,r]){return Math.min(r,Math.max(t,e))}function De(e,t,{checkForDefaultPrevented:r=!0}={}){return function(o){if(e?.(o),r===!1||!o.defaultPrevented)return t?.(o)}}function tx(e,t){const r=b.createContext(t),n=s=>{const{children:i,...a}=s,c=b.useMemo(()=>a,Object.values(a));return d.jsx(r.Provider,{value:c,children:i})};n.displayName=e+"Provider";function o(s){const i=b.useContext(r);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[n,o]}function vr(e,t=[]){let r=[];function n(s,i){const a=b.createContext(i),c=r.length;r=[...r,i];const u=l=>{const{scope:p,children:g,...m}=l,h=p?.[e]?.[c]||a,y=b.useMemo(()=>m,Object.values(m));return d.jsx(h.Provider,{value:y,children:g})};u.displayName=s+"Provider";function f(l,p){const g=p?.[e]?.[c]||a,m=b.useContext(g);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${l}\` must be used within \`${s}\``)}return[u,f]}const o=()=>{const s=r.map(i=>b.createContext(i));return function(a){const c=a?.[e]||s;return b.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[n,rx(o,...t)]}function rx(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=n.reduce((a,{useScope:c,scopeName:u})=>{const l=c(s)[`__scope${u}`];return{...a,...l}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return r.scopeName=t.scopeName,r}function Kf(e){const t=nx(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(sx);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function nx(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=ax(o),a=ix(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ox=Symbol("radix.slottable");function sx(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ox}function ix(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function ax(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function Cl(e){const t=e+"CollectionProvider",[r,n]=vr(t),[o,s]=r(t,{collectionRef:{current:null},itemMap:new Map}),i=h=>{const{scope:y,children:S}=h,w=v.useRef(null),A=v.useRef(new Map).current;return d.jsx(o,{scope:y,itemMap:A,collectionRef:w,children:S})};i.displayName=t;const a=e+"CollectionSlot",c=Kf(a),u=v.forwardRef((h,y)=>{const{scope:S,children:w}=h,A=s(a,S),x=Qe(y,A.collectionRef);return d.jsx(c,{ref:x,children:w})});u.displayName=a;const f=e+"CollectionItemSlot",l="data-radix-collection-item",p=Kf(f),g=v.forwardRef((h,y)=>{const{scope:S,children:w,...A}=h,x=v.useRef(null),F=Qe(y,x),N=s(f,S);return v.useEffect(()=>(N.itemMap.set(x,{ref:x,...A}),()=>{N.itemMap.delete(x)})),d.jsx(p,{[l]:"",ref:F,children:w})});g.displayName=f;function m(h){const y=s(e+"CollectionConsumer",h);return v.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const A=Array.from(w.querySelectorAll(`[${l}]`));return Array.from(y.itemMap.values()).sort((N,k)=>A.indexOf(N.ref.current)-A.indexOf(k.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:u,ItemSlot:g},m,n]}var lx=b.createContext(void 0);function bo(e){const t=b.useContext(lx);return e||t||"ltr"}function cx(e){const t=dx(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(fx);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function dx(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=mx(o),a=px(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ux=Symbol("radix.slottable");function fx(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ux}function px(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function mx(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var hx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],je=hx.reduce((e,t)=>{const r=cx(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function gx(e,t){e&&Vs.flushSync(()=>e.dispatchEvent(t))}function cr(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>(...r)=>t.current?.(...r),[])}function yx(e,t=globalThis?.document){const r=cr(e);b.useEffect(()=>{const n=o=>{o.key==="Escape"&&r(o)};return t.addEventListener("keydown",n,{capture:!0}),()=>t.removeEventListener("keydown",n,{capture:!0})},[r,t])}var bx="DismissableLayer",El="dismissableLayer.update",vx="dismissableLayer.pointerDownOutside",wx="dismissableLayer.focusOutside",qf,Yf=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),vi=b.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,u=b.useContext(Yf),[f,l]=b.useState(null),p=f?.ownerDocument??globalThis?.document,[,g]=b.useState({}),m=Qe(t,k=>l(k)),h=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),S=h.indexOf(y),w=f?h.indexOf(f):-1,A=u.layersWithOutsidePointerEventsDisabled.size>0,x=w>=S,F=Ax(k=>{const T=k.target,P=[...u.branches].some(E=>E.contains(T));!x||P||(o?.(k),i?.(k),k.defaultPrevented||a?.())},p),N=Cx(k=>{const T=k.target;[...u.branches].some(E=>E.contains(T))||(s?.(k),i?.(k),k.defaultPrevented||a?.())},p);return yx(k=>{w===u.layers.size-1&&(n?.(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},p),b.useEffect(()=>{if(f)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(qf=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),Xf(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=qf)}},[f,p,r,u]),b.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),Xf())},[f,u]),b.useEffect(()=>{const k=()=>g({});return document.addEventListener(El,k),()=>document.removeEventListener(El,k)},[]),d.jsx(je.div,{...c,ref:m,style:{pointerEvents:A?x?"auto":"none":void 0,...e.style},onFocusCapture:De(e.onFocusCapture,N.onFocusCapture),onBlurCapture:De(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:De(e.onPointerDownCapture,F.onPointerDownCapture)})});vi.displayName=bx;var Sx="DismissableLayerBranch",xx=b.forwardRef((e,t)=>{const r=b.useContext(Yf),n=b.useRef(null),o=Qe(t,n);return b.useEffect(()=>{const s=n.current;if(s)return r.branches.add(s),()=>{r.branches.delete(s)}},[r.branches]),d.jsx(je.div,{...e,ref:o})});xx.displayName=Sx;function Ax(e,t=globalThis?.document){const r=cr(e),n=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const s=a=>{if(a.target&&!n.current){let c=function(){Jf(vx,r,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);n.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,r]),{onPointerDownCapture:()=>n.current=!0}}function Cx(e,t=globalThis?.document){const r=cr(e),n=b.useRef(!1);return b.useEffect(()=>{const o=s=>{s.target&&!n.current&&Jf(wx,r,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function Xf(){const e=new CustomEvent(El);document.dispatchEvent(e)}function Jf(e,t,r,{discrete:n}){const o=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&o.addEventListener(e,t,{once:!0}),n?gx(o,s):o.dispatchEvent(s)}var Nl=0;function kl(){b.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Qf()),document.body.insertAdjacentElement("beforeend",e[1]??Qf()),Nl++,()=>{Nl===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Nl--}},[])}function Qf(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var _l="focusScope.autoFocusOnMount",Tl="focusScope.autoFocusOnUnmount",Zf={bubbles:!1,cancelable:!0},Ex="FocusScope",wi=b.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=b.useState(null),u=cr(o),f=cr(s),l=b.useRef(null),p=Qe(t,h=>c(h)),g=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(n){let h=function(A){if(g.paused||!a)return;const x=A.target;a.contains(x)?l.current=x:In(l.current,{select:!0})},y=function(A){if(g.paused||!a)return;const x=A.relatedTarget;x!==null&&(a.contains(x)||In(l.current,{select:!0}))},S=function(A){if(document.activeElement===document.body)for(const F of A)F.removedNodes.length>0&&In(a)};document.addEventListener("focusin",h),document.addEventListener("focusout",y);const w=new MutationObserver(S);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",y),w.disconnect()}}},[n,a,g.paused]),b.useEffect(()=>{if(a){rp.add(g);const h=document.activeElement;if(!a.contains(h)){const S=new CustomEvent(_l,Zf);a.addEventListener(_l,u),a.dispatchEvent(S),S.defaultPrevented||(Nx(Px(ep(a)),{select:!0}),document.activeElement===h&&In(a))}return()=>{a.removeEventListener(_l,u),setTimeout(()=>{const S=new CustomEvent(Tl,Zf);a.addEventListener(Tl,f),a.dispatchEvent(S),S.defaultPrevented||In(h??document.body,{select:!0}),a.removeEventListener(Tl,f),rp.remove(g)},0)}}},[a,u,f,g]);const m=b.useCallback(h=>{if(!r&&!n||g.paused)return;const y=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,S=document.activeElement;if(y&&S){const w=h.currentTarget,[A,x]=kx(w);A&&x?!h.shiftKey&&S===x?(h.preventDefault(),r&&In(A,{select:!0})):h.shiftKey&&S===A&&(h.preventDefault(),r&&In(x,{select:!0})):S===w&&h.preventDefault()}},[r,n,g.paused]);return d.jsx(je.div,{tabIndex:-1,...i,ref:p,onKeyDown:m})});wi.displayName=Ex;function Nx(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(In(n,{select:t}),document.activeElement!==r)return}function kx(e){const t=ep(e),r=tp(t,e),n=tp(t.reverse(),e);return[r,n]}function ep(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const o=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||o?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function tp(e,t){for(const r of e)if(!_x(r,{upTo:t}))return r}function _x(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Tx(e){return e instanceof HTMLInputElement&&"select"in e}function In(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&Tx(e)&&t&&e.select()}}var rp=Fx();function Fx(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=np(e,t),e.unshift(t)},remove(t){e=np(e,t),e[0]?.resume()}}}function np(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function Px(e){return e.filter(t=>t.tagName!=="A")}var tr=globalThis?.document?b.useLayoutEffect:()=>{},Ox=b[" useId ".trim().toString()]||(()=>{}),Ix=0;function hn(e){const[t,r]=b.useState(Ox());return tr(()=>{r(n=>n??String(Ix++))},[e]),e||(t?`radix-${t}`:"")}const Mx=["top","right","bottom","left"],Mn=Math.min,wr=Math.max,Si=Math.round,xi=Math.floor,on=e=>({x:e,y:e}),Lx={left:"right",right:"left",bottom:"top",top:"bottom"};function Fl(e,t,r){return wr(e,Mn(t,r))}function gn(e,t){return typeof e=="function"?e(t):e}function yn(e){return e.split("-")[0]}function vo(e){return e.split("-")[1]}function Pl(e){return e==="x"?"y":"x"}function Ol(e){return e==="y"?"height":"width"}function sn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Il(e){return Pl(sn(e))}function Dx(e,t,r){r===void 0&&(r=!1);const n=vo(e),o=Il(e),s=Ol(o);let i=o==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ai(i)),[i,Ai(i)]}function Bx(e){const t=Ai(e);return[Ml(e),t,Ml(t)]}function Ml(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const op=["left","right"],sp=["right","left"],$x=["top","bottom"],jx=["bottom","top"];function zx(e,t,r){switch(e){case"top":case"bottom":return r?t?sp:op:t?op:sp;case"left":case"right":return t?$x:jx;default:return[]}}function Ux(e,t,r,n){const o=vo(e);let s=zx(yn(e),r==="start",n);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ml)))),s}function Ai(e){const t=yn(e);return Lx[t]+e.slice(t.length)}function Vx(e){return{top:0,right:0,bottom:0,left:0,...e}}function ip(e){return typeof e!="number"?Vx(e):{top:e,right:e,bottom:e,left:e}}function Ci(e){const{x:t,y:r,width:n,height:o}=e;return{width:n,height:o,top:r,left:t,right:t+n,bottom:r+o,x:t,y:r}}function ap(e,t,r){let{reference:n,floating:o}=e;const s=sn(t),i=Il(t),a=Ol(i),c=yn(t),u=s==="y",f=n.x+n.width/2-o.width/2,l=n.y+n.height/2-o.height/2,p=n[a]/2-o[a]/2;let g;switch(c){case"top":g={x:f,y:n.y-o.height};break;case"bottom":g={x:f,y:n.y+n.height};break;case"right":g={x:n.x+n.width,y:l};break;case"left":g={x:n.x-o.width,y:l};break;default:g={x:n.x,y:n.y}}switch(vo(t)){case"start":g[i]-=p*(r&&u?-1:1);break;case"end":g[i]+=p*(r&&u?-1:1);break}return g}async function Hx(e,t){var r;t===void 0&&(t={});const{x:n,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:l="floating",altBoundary:p=!1,padding:g=0}=gn(t,e),m=ip(g),y=a[p?l==="floating"?"reference":"floating":l],S=Ci(await s.getClippingRect({element:(r=await(s.isElement==null?void 0:s.isElement(y)))==null||r?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:f,strategy:c})),w=l==="floating"?{x:n,y:o,width:i.floating.width,height:i.floating.height}:i.reference,A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),x=await(s.isElement==null?void 0:s.isElement(A))?await(s.getScale==null?void 0:s.getScale(A))||{x:1,y:1}:{x:1,y:1},F=Ci(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:A,strategy:c}):w);return{top:(S.top-F.top+m.top)/x.y,bottom:(F.bottom-S.bottom+m.bottom)/x.y,left:(S.left-F.left+m.left)/x.x,right:(F.right-S.right+m.right)/x.x}}const Wx=50,Rx=async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:s=[],platform:i}=r,a=i.detectOverflow?i:{...i,detectOverflow:Hx},c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:l}=ap(u,n,c),p=n,g=0;const m={};for(let h=0;h<s.length;h++){const y=s[h];if(!y)continue;const{name:S,fn:w}=y,{x:A,y:x,data:F,reset:N}=await w({x:f,y:l,initialPlacement:n,placement:p,strategy:o,middlewareData:m,rects:u,platform:a,elements:{reference:e,floating:t}});f=A??f,l=x??l,m[S]={...m[S],...F},N&&g<Wx&&(g++,typeof N=="object"&&(N.placement&&(p=N.placement),N.rects&&(u=N.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):N.rects),{x:f,y:l}=ap(u,p,c)),h=-1)}return{x:f,y:l,placement:p,strategy:o,middlewareData:m}},Gx=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:f=0}=gn(e,t)||{};if(u==null)return{};const l=ip(f),p={x:r,y:n},g=Il(o),m=Ol(g),h=await i.getDimensions(u),y=g==="y",S=y?"top":"left",w=y?"bottom":"right",A=y?"clientHeight":"clientWidth",x=s.reference[m]+s.reference[g]-p[g]-s.floating[m],F=p[g]-s.reference[g],N=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let k=N?N[A]:0;(!k||!await(i.isElement==null?void 0:i.isElement(N)))&&(k=a.floating[A]||s.floating[m]);const T=x/2-F/2,P=k/2-h[m]/2-1,E=Mn(l[S],P),C=Mn(l[w],P),I=E,W=k-h[m]-C,M=k/2-h[m]/2+T,z=Fl(I,M,W),V=!c.arrow&&vo(o)!=null&&M!==z&&s.reference[m]/2-(M<I?E:C)-h[m]/2<0,X=V?M<I?M-I:M-W:0;return{[g]:p[g]+X,data:{[g]:z,centerOffset:M-z-X,...V&&{alignmentOffset:X}},reset:V}}}),Kx=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:f=!0,crossAxis:l=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:h=!0,...y}=gn(e,t);if((r=s.arrow)!=null&&r.alignmentOffset)return{};const S=yn(o),w=sn(a),A=yn(a)===a,x=await(c.isRTL==null?void 0:c.isRTL(u.floating)),F=p||(A||!h?[Ai(a)]:Bx(a)),N=m!=="none";!p&&N&&F.push(...Ux(a,h,m,x));const k=[a,...F],T=await c.detectOverflow(t,y),P=[];let E=((n=s.flip)==null?void 0:n.overflows)||[];if(f&&P.push(T[S]),l){const M=Dx(o,i,x);P.push(T[M[0]],T[M[1]])}if(E=[...E,{placement:o,overflows:P}],!P.every(M=>M<=0)){var C,I;const M=(((C=s.flip)==null?void 0:C.index)||0)+1,z=k[M];if(z&&(!(l==="alignment"?w!==sn(z):!1)||E.every(D=>sn(D.placement)===w?D.overflows[0]>0:!0)))return{data:{index:M,overflows:E},reset:{placement:z}};let V=(I=E.filter(X=>X.overflows[0]<=0).sort((X,D)=>X.overflows[1]-D.overflows[1])[0])==null?void 0:I.placement;if(!V)switch(g){case"bestFit":{var W;const X=(W=E.filter(D=>{if(N){const B=sn(D.placement);return B===w||B==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(B=>B>0).reduce((B,L)=>B+L,0)]).sort((D,B)=>D[1]-B[1])[0])==null?void 0:W[0];X&&(V=X);break}case"initialPlacement":V=a;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function lp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function cp(e){return Mx.some(t=>e[t]>=0)}const qx=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:n}=t,{strategy:o="referenceHidden",...s}=gn(e,t);switch(o){case"referenceHidden":{const i=await n.detectOverflow(t,{...s,elementContext:"reference"}),a=lp(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:cp(a)}}}case"escaped":{const i=await n.detectOverflow(t,{...s,altBoundary:!0}),a=lp(i,r.floating);return{data:{escapedOffsets:a,escaped:cp(a)}}}default:return{}}}}},dp=new Set(["left","top"]);async function Yx(e,t){const{placement:r,platform:n,elements:o}=e,s=await(n.isRTL==null?void 0:n.isRTL(o.floating)),i=yn(r),a=vo(r),c=sn(r)==="y",u=dp.has(i)?-1:1,f=s&&c?-1:1,l=gn(t,e);let{mainAxis:p,crossAxis:g,alignmentAxis:m}=typeof l=="number"?{mainAxis:l,crossAxis:0,alignmentAxis:null}:{mainAxis:l.mainAxis||0,crossAxis:l.crossAxis||0,alignmentAxis:l.alignmentAxis};return a&&typeof m=="number"&&(g=a==="end"?m*-1:m),c?{x:g*f,y:p*u}:{x:p*u,y:g*f}}const Xx=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:o,y:s,placement:i,middlewareData:a}=t,c=await Yx(t,e);return i===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},Jx=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:o,platform:s}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:c={fn:S=>{let{x:w,y:A}=S;return{x:w,y:A}}},...u}=gn(e,t),f={x:r,y:n},l=await s.detectOverflow(t,u),p=sn(yn(o)),g=Pl(p);let m=f[g],h=f[p];if(i){const S=g==="y"?"top":"left",w=g==="y"?"bottom":"right",A=m+l[S],x=m-l[w];m=Fl(A,m,x)}if(a){const S=p==="y"?"top":"left",w=p==="y"?"bottom":"right",A=h+l[S],x=h-l[w];h=Fl(A,h,x)}const y=c.fn({...t,[g]:m,[p]:h});return{...y,data:{x:y.x-r,y:y.y-n,enabled:{[g]:i,[p]:a}}}}}},Qx=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:n,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:c=!0,crossAxis:u=!0}=gn(e,t),f={x:r,y:n},l=sn(o),p=Pl(l);let g=f[p],m=f[l];const h=gn(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){const A=p==="y"?"height":"width",x=s.reference[p]-s.floating[A]+y.mainAxis,F=s.reference[p]+s.reference[A]-y.mainAxis;g<x?g=x:g>F&&(g=F)}if(u){var S,w;const A=p==="y"?"width":"height",x=dp.has(yn(o)),F=s.reference[l]-s.floating[A]+(x&&((S=i.offset)==null?void 0:S[l])||0)+(x?0:y.crossAxis),N=s.reference[l]+s.reference[A]+(x?0:((w=i.offset)==null?void 0:w[l])||0)-(x?y.crossAxis:0);m<F?m=F:m>N&&(m=N)}return{[p]:g,[l]:m}}}},Zx=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:c=()=>{},...u}=gn(e,t),f=await i.detectOverflow(t,u),l=yn(o),p=vo(o),g=sn(o)==="y",{width:m,height:h}=s.floating;let y,S;l==="top"||l==="bottom"?(y=l,S=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(S=l,y=p==="end"?"top":"bottom");const w=h-f.top-f.bottom,A=m-f.left-f.right,x=Mn(h-f[y],w),F=Mn(m-f[S],A),N=!t.middlewareData.shift;let k=x,T=F;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(T=A),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(k=w),N&&!p){const E=wr(f.left,0),C=wr(f.right,0),I=wr(f.top,0),W=wr(f.bottom,0);g?T=m-2*(E!==0||C!==0?E+C:wr(f.left,f.right)):k=h-2*(I!==0||W!==0?I+W:wr(f.top,f.bottom))}await c({...t,availableWidth:T,availableHeight:k});const P=await i.getDimensions(a.floating);return m!==P.width||h!==P.height?{reset:{rects:!0}}:{}}}};function Ei(){return typeof window<"u"}function wo(e){return up(e)?(e.nodeName||"").toLowerCase():"#document"}function Sr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function an(e){var t;return(t=(up(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function up(e){return Ei()?e instanceof Node||e instanceof Sr(e).Node:!1}function Kr(e){return Ei()?e instanceof Element||e instanceof Sr(e).Element:!1}function bn(e){return Ei()?e instanceof HTMLElement||e instanceof Sr(e).HTMLElement:!1}function fp(e){return!Ei()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Sr(e).ShadowRoot}function fs(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=qr(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&o!=="inline"&&o!=="contents"}function eA(e){return/^(table|td|th)$/.test(wo(e))}function Ni(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const tA=/transform|translate|scale|rotate|perspective|filter/,rA=/paint|layout|strict|content/,Zn=e=>!!e&&e!=="none";let Ll;function Dl(e){const t=Kr(e)?qr(e):e;return Zn(t.transform)||Zn(t.translate)||Zn(t.scale)||Zn(t.rotate)||Zn(t.perspective)||!Bl()&&(Zn(t.backdropFilter)||Zn(t.filter))||tA.test(t.willChange||"")||rA.test(t.contain||"")}function nA(e){let t=Ln(e);for(;bn(t)&&!So(t);){if(Dl(t))return t;if(Ni(t))return null;t=Ln(t)}return null}function Bl(){return Ll==null&&(Ll=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ll}function So(e){return/^(html|body|#document)$/.test(wo(e))}function qr(e){return Sr(e).getComputedStyle(e)}function ki(e){return Kr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ln(e){if(wo(e)==="html")return e;const t=e.assignedSlot||e.parentNode||fp(e)&&e.host||an(e);return fp(t)?t.host:t}function pp(e){const t=Ln(e);return So(t)?e.ownerDocument?e.ownerDocument.body:e.body:bn(t)&&fs(t)?t:pp(t)}function ps(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const o=pp(e),s=o===((n=e.ownerDocument)==null?void 0:n.body),i=Sr(o);if(s){const a=$l(i);return t.concat(i,i.visualViewport||[],fs(o)?o:[],a&&r?ps(a):[])}else return t.concat(o,ps(o,[],r))}function $l(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function mp(e){const t=qr(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=bn(e),s=o?e.offsetWidth:r,i=o?e.offsetHeight:n,a=Si(r)!==s||Si(n)!==i;return a&&(r=s,n=i),{width:r,height:n,$:a}}function jl(e){return Kr(e)?e:e.contextElement}function xo(e){const t=jl(e);if(!bn(t))return on(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:s}=mp(t);let i=(s?Si(r.width):r.width)/n,a=(s?Si(r.height):r.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const oA=on(0);function hp(e){const t=Sr(e);return!Bl()||!t.visualViewport?oA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function sA(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Sr(e)?!1:t}function eo(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),s=jl(e);let i=on(1);t&&(n?Kr(n)&&(i=xo(n)):i=xo(e));const a=sA(s,r,n)?hp(s):on(0);let c=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,f=o.width/i.x,l=o.height/i.y;if(s){const p=Sr(s),g=n&&Kr(n)?Sr(n):n;let m=p,h=$l(m);for(;h&&n&&g!==m;){const y=xo(h),S=h.getBoundingClientRect(),w=qr(h),A=S.left+(h.clientLeft+parseFloat(w.paddingLeft))*y.x,x=S.top+(h.clientTop+parseFloat(w.paddingTop))*y.y;c*=y.x,u*=y.y,f*=y.x,l*=y.y,c+=A,u+=x,m=Sr(h),h=$l(m)}}return Ci({width:f,height:l,x:c,y:u})}function _i(e,t){const r=ki(e).scrollLeft;return t?t.left+r:eo(an(e)).left+r}function gp(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-_i(e,r),o=r.top+t.scrollTop;return{x:n,y:o}}function iA(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const s=o==="fixed",i=an(n),a=t?Ni(t.floating):!1;if(n===i||a&&s)return r;let c={scrollLeft:0,scrollTop:0},u=on(1);const f=on(0),l=bn(n);if((l||!l&&!s)&&((wo(n)!=="body"||fs(i))&&(c=ki(n)),l)){const g=eo(n);u=xo(n),f.x=g.x+n.clientLeft,f.y=g.y+n.clientTop}const p=i&&!l&&!s?gp(i,c):on(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-c.scrollLeft*u.x+f.x+p.x,y:r.y*u.y-c.scrollTop*u.y+f.y+p.y}}function aA(e){return Array.from(e.getClientRects())}function lA(e){const t=an(e),r=ki(e),n=e.ownerDocument.body,o=wr(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=wr(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let i=-r.scrollLeft+_i(e);const a=-r.scrollTop;return qr(n).direction==="rtl"&&(i+=wr(t.clientWidth,n.clientWidth)-o),{width:o,height:s,x:i,y:a}}const yp=25;function cA(e,t){const r=Sr(e),n=an(e),o=r.visualViewport;let s=n.clientWidth,i=n.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const f=Bl();(!f||f&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}const u=_i(n);if(u<=0){const f=n.ownerDocument,l=f.body,p=getComputedStyle(l),g=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,m=Math.abs(n.clientWidth-l.clientWidth-g);m<=yp&&(s-=m)}else u<=yp&&(s+=u);return{width:s,height:i,x:a,y:c}}function dA(e,t){const r=eo(e,!0,t==="fixed"),n=r.top+e.clientTop,o=r.left+e.clientLeft,s=bn(e)?xo(e):on(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=n*s.y;return{width:i,height:a,x:c,y:u}}function bp(e,t,r){let n;if(t==="viewport")n=cA(e,r);else if(t==="document")n=lA(an(e));else if(Kr(t))n=dA(t,r);else{const o=hp(e);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ci(n)}function vp(e,t){const r=Ln(e);return r===t||!Kr(r)||So(r)?!1:qr(r).position==="fixed"||vp(r,t)}function uA(e,t){const r=t.get(e);if(r)return r;let n=ps(e,[],!1).filter(a=>Kr(a)&&wo(a)!=="body"),o=null;const s=qr(e).position==="fixed";let i=s?Ln(e):e;for(;Kr(i)&&!So(i);){const a=qr(i),c=Dl(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||fs(i)&&!c&&vp(e,i))?n=n.filter(f=>f!==i):o=a,i=Ln(i)}return t.set(e,n),n}function fA(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const i=[...r==="clippingAncestors"?Ni(t)?[]:uA(t,this._c):[].concat(r),n],a=bp(t,i[0],o);let c=a.top,u=a.right,f=a.bottom,l=a.left;for(let p=1;p<i.length;p++){const g=bp(t,i[p],o);c=wr(g.top,c),u=Mn(g.right,u),f=Mn(g.bottom,f),l=wr(g.left,l)}return{width:u-l,height:f-c,x:l,y:c}}function pA(e){const{width:t,height:r}=mp(e);return{width:t,height:r}}function mA(e,t,r){const n=bn(t),o=an(t),s=r==="fixed",i=eo(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=on(0);function u(){c.x=_i(o)}if(n||!n&&!s)if((wo(t)!=="body"||fs(o))&&(a=ki(t)),n){const g=eo(t,!0,s,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else o&&u();s&&!n&&o&&u();const f=o&&!n&&!s?gp(o,a):on(0),l=i.left+a.scrollLeft-c.x-f.x,p=i.top+a.scrollTop-c.y-f.y;return{x:l,y:p,width:i.width,height:i.height}}function zl(e){return qr(e).position==="static"}function wp(e,t){if(!bn(e)||qr(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return an(e)===r&&(r=r.ownerDocument.body),r}function Sp(e,t){const r=Sr(e);if(Ni(e))return r;if(!bn(e)){let o=Ln(e);for(;o&&!So(o);){if(Kr(o)&&!zl(o))return o;o=Ln(o)}return r}let n=wp(e,t);for(;n&&eA(n)&&zl(n);)n=wp(n,t);return n&&So(n)&&zl(n)&&!Dl(n)?r:n||nA(e)||r}const hA=async function(e){const t=this.getOffsetParent||Sp,r=this.getDimensions,n=await r(e.floating);return{reference:mA(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function gA(e){return qr(e).direction==="rtl"}const yA={convertOffsetParentRelativeRectToViewportRelativeRect:iA,getDocumentElement:an,getClippingRect:fA,getOffsetParent:Sp,getElementRects:hA,getClientRects:aA,getDimensions:pA,getScale:xo,isElement:Kr,isRTL:gA};function xp(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function bA(e,t){let r=null,n;const o=an(e);function s(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:f,top:l,width:p,height:g}=u;if(a||t(),!p||!g)return;const m=xi(l),h=xi(o.clientWidth-(f+p)),y=xi(o.clientHeight-(l+g)),S=xi(f),A={rootMargin:-m+"px "+-h+"px "+-y+"px "+-S+"px",threshold:wr(0,Mn(1,c))||1};let x=!0;function F(N){const k=N[0].intersectionRatio;if(k!==c){if(!x)return i();k?i(!1,k):n=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!xp(u,e.getBoundingClientRect())&&i(),x=!1}try{r=new IntersectionObserver(F,{...A,root:o.ownerDocument})}catch{r=new IntersectionObserver(F,A)}r.observe(e)}return i(!0),s}function vA(e,t,r,n){n===void 0&&(n={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,u=jl(e),f=o||s?[...u?ps(u):[],...t?ps(t):[]]:[];f.forEach(S=>{o&&S.addEventListener("scroll",r,{passive:!0}),s&&S.addEventListener("resize",r)});const l=u&&a?bA(u,r):null;let p=-1,g=null;i&&(g=new ResizeObserver(S=>{let[w]=S;w&&w.target===u&&g&&t&&(g.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var A;(A=g)==null||A.observe(t)})),r()}),u&&!c&&g.observe(u),t&&g.observe(t));let m,h=c?eo(e):null;c&&y();function y(){const S=eo(e);h&&!xp(h,S)&&r(),h=S,m=requestAnimationFrame(y)}return r(),()=>{var S;f.forEach(w=>{o&&w.removeEventListener("scroll",r),s&&w.removeEventListener("resize",r)}),l?.(),(S=g)==null||S.disconnect(),g=null,c&&cancelAnimationFrame(m)}}const wA=Xx,SA=Jx,xA=Kx,AA=Zx,CA=qx,Ap=Gx,EA=Qx,NA=(e,t,r)=>{const n=new Map,o={platform:yA,...r},s={...o.platform,_c:n};return Rx(e,t,{...o,platform:s})};var kA=typeof document<"u",_A=function(){},Ti=kA?v.useLayoutEffect:_A;function Fi(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,n,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;n--!==0;)if(!Fi(e[n],t[n]))return!1;return!0}if(o=Object.keys(e),r=o.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(t,o[n]))return!1;for(n=r;n--!==0;){const s=o[n];if(!(s==="_owner"&&e.$$typeof)&&!Fi(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Cp(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ep(e,t){const r=Cp(e);return Math.round(t*r)/r}function Ul(e){const t=b.useRef(e);return Ti(()=>{t.current=e}),t}function TA(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[f,l]=b.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[p,g]=b.useState(n);Fi(p,n)||g(n);const[m,h]=b.useState(null),[y,S]=b.useState(null),w=b.useCallback(D=>{D!==N.current&&(N.current=D,h(D))},[]),A=b.useCallback(D=>{D!==k.current&&(k.current=D,S(D))},[]),x=s||m,F=i||y,N=b.useRef(null),k=b.useRef(null),T=b.useRef(f),P=c!=null,E=Ul(c),C=Ul(o),I=Ul(u),W=b.useCallback(()=>{if(!N.current||!k.current)return;const D={placement:t,strategy:r,middleware:p};C.current&&(D.platform=C.current),NA(N.current,k.current,D).then(B=>{const L={...B,isPositioned:I.current!==!1};M.current&&!Fi(T.current,L)&&(T.current=L,Vs.flushSync(()=>{l(L)}))})},[p,t,r,C,I]);Ti(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,l(D=>({...D,isPositioned:!1})))},[u]);const M=b.useRef(!1);Ti(()=>(M.current=!0,()=>{M.current=!1}),[]),Ti(()=>{if(x&&(N.current=x),F&&(k.current=F),x&&F){if(E.current)return E.current(x,F,W);W()}},[x,F,W,E,P]);const z=b.useMemo(()=>({reference:N,floating:k,setReference:w,setFloating:A}),[w,A]),V=b.useMemo(()=>({reference:x,floating:F}),[x,F]),X=b.useMemo(()=>{const D={position:r,left:0,top:0};if(!V.floating)return D;const B=Ep(V.floating,f.x),L=Ep(V.floating,f.y);return a?{...D,transform:"translate("+B+"px, "+L+"px)",...Cp(V.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:B,top:L}},[r,a,V.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:W,refs:z,elements:V,floatingStyles:X}),[f,W,z,V,X])}const FA=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:n,padding:o}=typeof e=="function"?e(r):e;return n&&t(n)?n.current!=null?Ap({element:n.current,padding:o}).fn(r):{}:n?Ap({element:n,padding:o}).fn(r):{}}}},PA=(e,t)=>{const r=wA(e);return{name:r.name,fn:r.fn,options:[e,t]}},OA=(e,t)=>{const r=SA(e);return{name:r.name,fn:r.fn,options:[e,t]}},IA=(e,t)=>({fn:EA(e).fn,options:[e,t]}),MA=(e,t)=>{const r=xA(e);return{name:r.name,fn:r.fn,options:[e,t]}},LA=(e,t)=>{const r=AA(e);return{name:r.name,fn:r.fn,options:[e,t]}},DA=(e,t)=>{const r=CA(e);return{name:r.name,fn:r.fn,options:[e,t]}},BA=(e,t)=>{const r=FA(e);return{name:r.name,fn:r.fn,options:[e,t]}};var $A="Arrow",Np=b.forwardRef((e,t)=>{const{children:r,width:n=10,height:o=5,...s}=e;return d.jsx(je.svg,{...s,ref:t,width:n,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});Np.displayName=$A;var jA=Np;function ms(e){const[t,r]=b.useState(void 0);return tr(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;r({width:i,height:a})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),t}var Vl="Popper",[kp,Pi]=vr(Vl),[zA,_p]=kp(Vl),Tp=e=>{const{__scopePopper:t,children:r}=e,[n,o]=b.useState(null);return d.jsx(zA,{scope:t,anchor:n,onAnchorChange:o,children:r})};Tp.displayName=Vl;var Fp="PopperAnchor",Pp=b.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...o}=e,s=_p(Fp,r),i=b.useRef(null),a=Qe(t,i),c=b.useRef(null);return b.useEffect(()=>{const u=c.current;c.current=n?.current||i.current,u!==c.current&&s.onAnchorChange(c.current)}),n?null:d.jsx(je.div,{...o,ref:a})});Pp.displayName=Fp;var Hl="PopperContent",[UA,VA]=kp(Hl),Op=b.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:l="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:m,...h}=e,y=_p(Hl,r),[S,w]=b.useState(null),A=Qe(t,G=>w(G)),[x,F]=b.useState(null),N=ms(x),k=N?.width??0,T=N?.height??0,P=n+(s!=="center"?"-"+s:""),E=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},C=Array.isArray(u)?u:[u],I=C.length>0,W={padding:E,boundary:C.filter(WA),altBoundary:I},{refs:M,floatingStyles:z,placement:V,isPositioned:X,middlewareData:D}=TA({strategy:"fixed",placement:P,whileElementsMounted:(...G)=>vA(...G,{animationFrame:g==="always"}),elements:{reference:y.anchor},middleware:[PA({mainAxis:o+T,alignmentAxis:i}),c&&OA({mainAxis:!0,crossAxis:!1,limiter:l==="partial"?IA():void 0,...W}),c&&MA({...W}),LA({...W,apply:({elements:G,rects:ae,availableWidth:Ae,availableHeight:ee})=>{const{width:ne,height:he}=ae.reference,Ie=G.floating.style;Ie.setProperty("--radix-popper-available-width",`${Ae}px`),Ie.setProperty("--radix-popper-available-height",`${ee}px`),Ie.setProperty("--radix-popper-anchor-width",`${ne}px`),Ie.setProperty("--radix-popper-anchor-height",`${he}px`)}}),x&&BA({element:x,padding:a}),RA({arrowWidth:k,arrowHeight:T}),p&&DA({strategy:"referenceHidden",...W})]}),[B,L]=Lp(V),K=cr(m);tr(()=>{X&&K?.()},[X,K]);const ie=D.arrow?.x,j=D.arrow?.y,U=D.arrow?.centerOffset!==0,[le,oe]=b.useState();return tr(()=>{S&&oe(window.getComputedStyle(S).zIndex)},[S]),d.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:X?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:le,"--radix-popper-transform-origin":[D.transformOrigin?.x,D.transformOrigin?.y].join(" "),...D.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(UA,{scope:r,placedSide:B,onArrowChange:F,arrowX:ie,arrowY:j,shouldHideArrow:U,children:d.jsx(je.div,{"data-side":B,"data-align":L,...h,ref:A,style:{...h.style,animation:X?void 0:"none"}})})})});Op.displayName=Hl;var Ip="PopperArrow",HA={top:"bottom",right:"left",bottom:"top",left:"right"},Mp=b.forwardRef(function(t,r){const{__scopePopper:n,...o}=t,s=VA(Ip,n),i=HA[s.placedSide];return d.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:d.jsx(jA,{...o,ref:r,style:{...o.style,display:"block"}})})});Mp.displayName=Ip;function WA(e){return e!==null}var RA=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:n,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,f]=Lp(r),l={start:"0%",center:"50%",end:"100%"}[f],p=(o.arrow?.x??0)+a/2,g=(o.arrow?.y??0)+c/2;let m="",h="";return u==="bottom"?(m=i?l:`${p}px`,h=`${-c}px`):u==="top"?(m=i?l:`${p}px`,h=`${n.floating.height+c}px`):u==="right"?(m=`${-c}px`,h=i?l:`${g}px`):u==="left"&&(m=`${n.floating.width+c}px`,h=i?l:`${g}px`),{data:{x:m,y:h}}}});function Lp(e){const[t,r="center"]=e.split("-");return[t,r]}var Dp=Tp,Wl=Pp,Bp=Op,$p=Mp,GA="Portal",Oi=b.forwardRef((e,t)=>{const{container:r,...n}=e,[o,s]=b.useState(!1);tr(()=>s(!0),[]);const i=r||o&&globalThis?.document?.body;return i?kd.createPortal(d.jsx(je.div,{...n,ref:t}),i):null});Oi.displayName=GA;function KA(e){const t=qA(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(XA);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function qA(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=QA(o),a=JA(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var YA=Symbol("radix.slottable");function XA(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===YA}function JA(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function QA(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var ZA=b[" useInsertionEffect ".trim().toString()]||tr;function ln({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[o,s,i]=eC({defaultProp:t,onChange:r}),a=e!==void 0,c=a?e:o;{const f=b.useRef(e!==void 0);b.useEffect(()=>{const l=f.current;l!==a&&console.warn(`${n} is changing from ${l?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=a},[a,n])}const u=b.useCallback(f=>{if(a){const l=tC(f)?f(e):f;l!==e&&i.current?.(l)}else s(f)},[a,e,s,i]);return[c,u]}function eC({defaultProp:e,onChange:t}){const[r,n]=b.useState(e),o=b.useRef(r),s=b.useRef(t);return ZA(()=>{s.current=t},[t]),b.useEffect(()=>{o.current!==r&&(s.current?.(r),o.current=r)},[r,o]),[r,n,s]}function tC(e){return typeof e=="function"}function hs(e){const t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var jp=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),rC="VisuallyHidden",nC=b.forwardRef((e,t)=>d.jsx(je.span,{...e,ref:t,style:{...jp,...e.style}}));nC.displayName=rC;var oC=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ao=new WeakMap,Ii=new WeakMap,Mi={},Rl=0,zp=function(e){return e&&(e.host||zp(e.parentNode))},sC=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=zp(r);return n&&e.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},iC=function(e,t,r,n){var o=sC(t,Array.isArray(e)?e:[e]);Mi[r]||(Mi[r]=new WeakMap);var s=Mi[r],i=[],a=new Set,c=new Set(o),u=function(l){!l||a.has(l)||(a.add(l),u(l.parentNode))};o.forEach(u);var f=function(l){!l||c.has(l)||Array.prototype.forEach.call(l.children,function(p){if(a.has(p))f(p);else try{var g=p.getAttribute(n),m=g!==null&&g!=="false",h=(Ao.get(p)||0)+1,y=(s.get(p)||0)+1;Ao.set(p,h),s.set(p,y),i.push(p),h===1&&m&&Ii.set(p,!0),y===1&&p.setAttribute(r,"true"),m||p.setAttribute(n,"true")}catch(S){console.error("aria-hidden: cannot operate on ",p,S)}})};return f(t),a.clear(),Rl++,function(){i.forEach(function(l){var p=Ao.get(l)-1,g=s.get(l)-1;Ao.set(l,p),s.set(l,g),p||(Ii.has(l)||l.removeAttribute(n),Ii.delete(l)),g||l.removeAttribute(r)}),Rl--,Rl||(Ao=new WeakMap,Ao=new WeakMap,Ii=new WeakMap,Mi={})}},Gl=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),o=oC(e);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live], script"))),iC(n,o,r,"aria-hidden")):function(){return null}},cn=function(){return cn=Object.assign||function(t){for(var r,n=1,o=arguments.length;n<o;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},cn.apply(this,arguments)};function Up(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function aC(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,s;n<o;n++)(s||!(n in t))&&(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Li="right-scroll-bar-position",Di="width-before-scroll-bar",lC="with-scroll-bars-hidden",cC="--removed-body-scroll-bar-size";function Kl(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function dC(e,t){var r=v.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(n){var o=r.value;o!==n&&(r.value=n,r.callback(n,o))}}}})[0];return r.callback=t,r.facade}var uC=typeof window<"u"?b.useLayoutEffect:b.useEffect,Vp=new WeakMap;function fC(e,t){var r=dC(null,function(n){return e.forEach(function(o){return Kl(o,n)})});return uC(function(){var n=Vp.get(r);if(n){var o=new Set(n),s=new Set(e),i=r.current;o.forEach(function(a){s.has(a)||Kl(a,null)}),s.forEach(function(a){o.has(a)||Kl(a,i)})}Vp.set(r,e)},[e]),r}function pC(e){return e}function mC(e,t){t===void 0&&(t=pC);var r=[],n=!1,o={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(s){var i=t(s,n);return r.push(i),function(){r=r.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(n=!0;r.length;){var i=r;r=[],i.forEach(s)}r={push:function(a){return s(a)},filter:function(){return r}}},assignMedium:function(s){n=!0;var i=[];if(r.length){var a=r;r=[],a.forEach(s),i=r}var c=function(){var f=i;i=[],f.forEach(s)},u=function(){return Promise.resolve().then(c)};u(),r={push:function(f){i.push(f),u()},filter:function(f){return i=i.filter(f),r}}}};return o}function hC(e){e===void 0&&(e={});var t=mC(null);return t.options=cn({async:!0,ssr:!1},e),t}var Hp=function(e){var t=e.sideCar,r=Up(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=t.read();if(!n)throw new Error("Sidecar medium not found");return b.createElement(n,cn({},r))};Hp.isSideCarExport=!0;function gC(e,t){return e.useMedium(t),Hp}var Wp=hC(),ql=function(){},Bi=b.forwardRef(function(e,t){var r=b.useRef(null),n=b.useState({onScrollCapture:ql,onWheelCapture:ql,onTouchMoveCapture:ql}),o=n[0],s=n[1],i=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,f=e.enabled,l=e.shards,p=e.sideCar,g=e.noRelative,m=e.noIsolation,h=e.inert,y=e.allowPinchZoom,S=e.as,w=S===void 0?"div":S,A=e.gapMode,x=Up(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),F=p,N=fC([r,t]),k=cn(cn({},x),o);return b.createElement(b.Fragment,null,f&&b.createElement(F,{sideCar:Wp,removeScrollBar:u,shards:l,noRelative:g,noIsolation:m,inert:h,setCallbacks:s,allowPinchZoom:!!y,lockRef:r,gapMode:A}),i?b.cloneElement(b.Children.only(a),cn(cn({},k),{ref:N})):b.createElement(w,cn({},k,{className:c,ref:N}),a))});Bi.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Bi.classNames={fullWidth:Di,zeroRight:Li};var yC=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function bC(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=yC();return t&&e.setAttribute("nonce",t),e}function vC(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function wC(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var SC=function(){var e=0,t=null;return{add:function(r){e==0&&(t=bC())&&(vC(t,r),wC(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},xC=function(){var e=SC();return function(t,r){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},Rp=function(){var e=xC(),t=function(r){var n=r.styles,o=r.dynamic;return e(n,o),null};return t},AC={left:0,top:0,right:0,gap:0},Yl=function(e){return parseInt(e||"",10)||0},CC=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],n=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Yl(r),Yl(n),Yl(o)]},EC=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return AC;var t=CC(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,n-r+t[2]-t[0])}},NC=Rp(),Co="data-scroll-locked",kC=function(e,t,r,n){var o=e.left,s=e.top,i=e.right,a=e.gap;return r===void 0&&(r="margin"),`
7
+ .`.concat(lC,` {
8
8
  overflow: hidden `).concat(n,`;
9
9
  padding-right: `).concat(a,"px ").concat(n,`;
10
10
  }
@@ -21,32 +21,32 @@
21
21
  `),r==="padding"&&"padding-right: ".concat(a,"px ").concat(n,";")].filter(Boolean).join(""),`
22
22
  }
23
23
 
24
- .`).concat(Oi,` {
24
+ .`).concat(Li,` {
25
25
  right: `).concat(a,"px ").concat(n,`;
26
26
  }
27
27
 
28
- .`).concat(Ii,` {
28
+ .`).concat(Di,` {
29
29
  margin-right: `).concat(a,"px ").concat(n,`;
30
30
  }
31
31
 
32
- .`).concat(Oi," .").concat(Oi,` {
32
+ .`).concat(Li," .").concat(Li,` {
33
33
  right: 0 `).concat(n,`;
34
34
  }
35
35
 
36
- .`).concat(Ii," .").concat(Ii,` {
36
+ .`).concat(Di," .").concat(Di,` {
37
37
  margin-right: 0 `).concat(n,`;
38
38
  }
39
39
 
40
40
  body[`).concat(Co,`] {
41
- `).concat(iC,": ").concat(a,`px;
41
+ `).concat(cC,": ").concat(a,`px;
42
42
  }
43
- `)},Rp=function(){var e=parseInt(document.body.getAttribute(Co)||"0",10);return isFinite(e)?e:0},EC=function(){b.useEffect(function(){return document.body.setAttribute(Co,(Rp()+1).toString()),function(){var e=Rp()-1;e<=0?document.body.removeAttribute(Co):document.body.setAttribute(Co,e.toString())}},[])},NC=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,o=n===void 0?"margin":n;EC();var s=b.useMemo(function(){return xC(o)},[o]);return b.createElement(AC,{styles:CC(s,!t,o,r?"":"!important")})},Xl=!1;if(typeof window<"u")try{var Li=Object.defineProperty({},"passive",{get:function(){return Xl=!0,!0}});window.addEventListener("test",Li,Li),window.removeEventListener("test",Li,Li)}catch{Xl=!1}var Eo=Xl?{passive:!1}:!1,kC=function(e){return e.tagName==="TEXTAREA"},Gp=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!kC(e)&&r[t]==="visible")},_C=function(e){return Gp(e,"overflowY")},TC=function(e){return Gp(e,"overflowX")},Kp=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var o=qp(e,n);if(o){var s=Yp(e,n),i=s[1],a=s[2];if(i>a)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},FC=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},PC=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},qp=function(e,t){return e==="v"?_C(t):TC(t)},Yp=function(e,t){return e==="v"?FC(t):PC(t)},OC=function(e,t){return e==="h"&&t==="rtl"?-1:1},IC=function(e,t,r,n,o){var s=OC(e,window.getComputedStyle(t).direction),i=s*n,a=r.target,c=t.contains(a),u=!1,f=i>0,l=0,p=0;do{if(!a)break;var g=Yp(e,a),m=g[0],h=g[1],y=g[2],S=h-y-s*m;(m||S)&&qp(e,a)&&(l+=S,p+=m);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(f&&Math.abs(l)<1||!f&&Math.abs(p)<1)&&(u=!0),u},Di=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Xp=function(e){return[e.deltaX,e.deltaY]},Jp=function(e){return e&&"current"in e?e.current:e},MC=function(e,t){return e[0]===t[0]&&e[1]===t[1]},LC=function(e){return`
43
+ `)},Gp=function(){var e=parseInt(document.body.getAttribute(Co)||"0",10);return isFinite(e)?e:0},_C=function(){b.useEffect(function(){return document.body.setAttribute(Co,(Gp()+1).toString()),function(){var e=Gp()-1;e<=0?document.body.removeAttribute(Co):document.body.setAttribute(Co,e.toString())}},[])},TC=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,o=n===void 0?"margin":n;_C();var s=b.useMemo(function(){return EC(o)},[o]);return b.createElement(NC,{styles:kC(s,!t,o,r?"":"!important")})},Xl=!1;if(typeof window<"u")try{var $i=Object.defineProperty({},"passive",{get:function(){return Xl=!0,!0}});window.addEventListener("test",$i,$i),window.removeEventListener("test",$i,$i)}catch{Xl=!1}var Eo=Xl?{passive:!1}:!1,FC=function(e){return e.tagName==="TEXTAREA"},Kp=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!FC(e)&&r[t]==="visible")},PC=function(e){return Kp(e,"overflowY")},OC=function(e){return Kp(e,"overflowX")},qp=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var o=Yp(e,n);if(o){var s=Xp(e,n),i=s[1],a=s[2];if(i>a)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},IC=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},MC=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},Yp=function(e,t){return e==="v"?PC(t):OC(t)},Xp=function(e,t){return e==="v"?IC(t):MC(t)},LC=function(e,t){return e==="h"&&t==="rtl"?-1:1},DC=function(e,t,r,n,o){var s=LC(e,window.getComputedStyle(t).direction),i=s*n,a=r.target,c=t.contains(a),u=!1,f=i>0,l=0,p=0;do{if(!a)break;var g=Xp(e,a),m=g[0],h=g[1],y=g[2],S=h-y-s*m;(m||S)&&Yp(e,a)&&(l+=S,p+=m);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(f&&Math.abs(l)<1||!f&&Math.abs(p)<1)&&(u=!0),u},ji=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Jp=function(e){return[e.deltaX,e.deltaY]},Qp=function(e){return e&&"current"in e?e.current:e},BC=function(e,t){return e[0]===t[0]&&e[1]===t[1]},$C=function(e){return`
44
44
  .block-interactivity-`.concat(e,` {pointer-events: none;}
45
45
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
46
- `)},DC=0,No=[];function BC(e){var t=b.useRef([]),r=b.useRef([0,0]),n=b.useRef(),o=b.useState(DC++)[0],s=b.useState(Wp)[0],i=b.useRef(e);b.useEffect(function(){i.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=oC([e.lockRef.current],(e.shards||[]).map(Jp),!0).filter(Boolean);return h.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=b.useCallback(function(h,y){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!i.current.allowPinchZoom;var S=Di(h),w=r.current,A="deltaX"in h?h.deltaX:w[0]-S[0],x="deltaY"in h?h.deltaY:w[1]-S[1],F,N=h.target,k=Math.abs(A)>Math.abs(x)?"h":"v";if("touches"in h&&k==="h"&&N.type==="range")return!1;var T=window.getSelection(),P=T&&T.anchorNode,E=P?P===N||P.contains(N):!1;if(E)return!1;var C=Kp(k,N);if(!C)return!0;if(C?F=k:(F=k==="v"?"h":"v",C=Kp(k,N)),!C)return!1;if(!n.current&&"changedTouches"in h&&(A||x)&&(n.current=F),!F)return!0;var I=n.current||F;return IC(I,y,h,I==="h"?A:x)},[]),c=b.useCallback(function(h){var y=h;if(!(!No.length||No[No.length-1]!==s)){var S="deltaY"in y?Xp(y):Di(y),w=t.current.filter(function(F){return F.name===y.type&&(F.target===y.target||y.target===F.shadowParent)&&MC(F.delta,S)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var A=(i.current.shards||[]).map(Jp).filter(Boolean).filter(function(F){return F.contains(y.target)}),x=A.length>0?a(y,A[0]):!i.current.noIsolation;x&&y.cancelable&&y.preventDefault()}}},[]),u=b.useCallback(function(h,y,S,w){var A={name:h,delta:y,target:S,should:w,shadowParent:$C(S)};t.current.push(A),setTimeout(function(){t.current=t.current.filter(function(x){return x!==A})},1)},[]),f=b.useCallback(function(h){r.current=Di(h),n.current=void 0},[]),l=b.useCallback(function(h){u(h.type,Xp(h),h.target,a(h,e.lockRef.current))},[]),p=b.useCallback(function(h){u(h.type,Di(h),h.target,a(h,e.lockRef.current))},[]);b.useEffect(function(){return No.push(s),e.setCallbacks({onScrollCapture:l,onWheelCapture:l,onTouchMoveCapture:p}),document.addEventListener("wheel",c,Eo),document.addEventListener("touchmove",c,Eo),document.addEventListener("touchstart",f,Eo),function(){No=No.filter(function(h){return h!==s}),document.removeEventListener("wheel",c,Eo),document.removeEventListener("touchmove",c,Eo),document.removeEventListener("touchstart",f,Eo)}},[]);var g=e.removeScrollBar,m=e.inert;return b.createElement(b.Fragment,null,m?b.createElement(s,{styles:LC(o)}):null,g?b.createElement(NC,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function $C(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const jC=pC(Hp,BC);var Bi=b.forwardRef(function(e,t){return b.createElement(Mi,cn({},e,{ref:t,sideCar:jC}))});Bi.classNames=Mi.classNames;var zC=[" ","Enter","ArrowUp","ArrowDown"],UC=[" ","Enter"],to="Select",[$i,ji,VC]=Cl(to),[ko]=vr(to,[VC,_i]),zi=_i(),[HC,Ln]=ko(to),[WC,RC]=ko(to),Qp=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:f,autoComplete:l,disabled:p,required:g,form:m}=e,h=zi(t),[y,S]=b.useState(null),[w,A]=b.useState(null),[x,F]=b.useState(!1),N=bo(u),[k,T]=ln({prop:n,defaultProp:o??!1,onChange:s,caller:to}),[P,E]=ln({prop:i,defaultProp:a,onChange:c,caller:to}),C=b.useRef(null),I=y?m||!!y.closest("form"):!0,[W,M]=b.useState(new Set),z=Array.from(W).map(V=>V.props.value).join(";");return d.jsx(Lp,{...h,children:d.jsxs(HC,{required:g,scope:t,trigger:y,onTriggerChange:S,valueNode:w,onValueNodeChange:A,valueNodeHasChildren:x,onValueNodeHasChildrenChange:F,contentId:hn(),value:P,onValueChange:E,open:k,onOpenChange:T,dir:N,triggerPointerDownPosRef:C,disabled:p,children:[d.jsx($i.Provider,{scope:t,children:d.jsx(WC,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(V=>{M(X=>new Set(X).add(V))},[]),onNativeOptionRemove:b.useCallback(V=>{M(X=>{const L=new Set(X);return L.delete(V),L})},[]),children:r})}),I?d.jsxs(wm,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:l,value:P,onChange:V=>E(V.target.value),disabled:p,form:m,children:[P===void 0?d.jsx("option",{value:""}):null,Array.from(W)]},z):null]})})};Qp.displayName=to;var Zp="SelectTrigger",em=b.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...o}=e,s=zi(r),i=Ln(Zp,r),a=i.disabled||n,c=Qe(t,i.onTriggerChange),u=ji(r),f=b.useRef("touch"),[l,p,g]=xm(h=>{const y=u().filter(A=>!A.disabled),S=y.find(A=>A.value===i.value),w=Am(y,h,S);w!==void 0&&i.onValueChange(w.value)}),m=h=>{a||(i.onOpenChange(!0),g()),h&&(i.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return d.jsx(Wl,{asChild:!0,...s,children:d.jsx(je.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Sm(i.value)?"":void 0,...o,ref:c,onClick:De(o.onClick,h=>{h.currentTarget.focus(),f.current!=="mouse"&&m(h)}),onPointerDown:De(o.onPointerDown,h=>{f.current=h.pointerType;const y=h.target;y.hasPointerCapture(h.pointerId)&&y.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(m(h),h.preventDefault())}),onKeyDown:De(o.onKeyDown,h=>{const y=l.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&p(h.key),!(y&&h.key===" ")&&zC.includes(h.key)&&(m(),h.preventDefault())})})})});em.displayName=Zp;var tm="SelectValue",rm=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,children:s,placeholder:i="",...a}=e,c=Ln(tm,r),{onValueNodeHasChildrenChange:u}=c,f=s!==void 0,l=Qe(t,c.onValueNodeChange);return tr(()=>{u(f)},[u,f]),d.jsx(je.span,{...a,ref:l,style:{pointerEvents:"none"},children:Sm(c.value)?d.jsx(d.Fragment,{children:i}):s})});rm.displayName=tm;var GC="SelectIcon",nm=b.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...o}=e;return d.jsx(je.span,{"aria-hidden":!0,...o,ref:t,children:n||"▼"})});nm.displayName=GC;var KC="SelectPortal",om=e=>d.jsx(Ti,{asChild:!0,...e});om.displayName=KC;var ro="SelectContent",sm=b.forwardRef((e,t)=>{const r=Ln(ro,e.__scopeSelect),[n,o]=b.useState();if(tr(()=>{o(new DocumentFragment)},[]),!r.open){const s=n;return s?js.createPortal(d.jsx(im,{scope:e.__scopeSelect,children:d.jsx($i.Slot,{scope:e.__scopeSelect,children:d.jsx("div",{children:e.children})})}),s):null}return d.jsx(am,{...e,ref:t})});sm.displayName=ro;var Yr=10,[im,Dn]=ko(ro),qC="SelectContentImpl",YC=WA("SelectContent.RemoveScroll"),am=b.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:l,collisionBoundary:p,collisionPadding:g,sticky:m,hideWhenDetached:h,avoidCollisions:y,...S}=e,w=Ln(ro,r),[A,x]=b.useState(null),[F,N]=b.useState(null),k=Qe(t,G=>x(G)),[T,P]=b.useState(null),[E,C]=b.useState(null),I=ji(r),[W,M]=b.useState(!1),z=b.useRef(!1);b.useEffect(()=>{if(A)return Gl(A)},[A]),kl();const V=b.useCallback(G=>{const[ie,...Ce]=I().map(he=>he.ref.current),[ee]=Ce.slice(-1),ne=document.activeElement;for(const he of G)if(he===ne||(he?.scrollIntoView({block:"nearest"}),he===ie&&F&&(F.scrollTop=0),he===ee&&F&&(F.scrollTop=F.scrollHeight),he?.focus(),document.activeElement!==ne))return},[I,F]),X=b.useCallback(()=>V([T,A]),[V,T,A]);b.useEffect(()=>{W&&X()},[W,X]);const{onOpenChange:L,triggerPointerDownPosRef:B}=w;b.useEffect(()=>{if(A){let G={x:0,y:0};const ie=ee=>{G={x:Math.abs(Math.round(ee.pageX)-(B.current?.x??0)),y:Math.abs(Math.round(ee.pageY)-(B.current?.y??0))}},Ce=ee=>{G.x<=10&&G.y<=10?ee.preventDefault():A.contains(ee.target)||L(!1),document.removeEventListener("pointermove",ie),B.current=null};return B.current!==null&&(document.addEventListener("pointermove",ie),document.addEventListener("pointerup",Ce,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ie),document.removeEventListener("pointerup",Ce,{capture:!0})}}},[A,L,B]),b.useEffect(()=>{const G=()=>L(!1);return window.addEventListener("blur",G),window.addEventListener("resize",G),()=>{window.removeEventListener("blur",G),window.removeEventListener("resize",G)}},[L]);const[D,K]=xm(G=>{const ie=I().filter(ne=>!ne.disabled),Ce=ie.find(ne=>ne.ref.current===document.activeElement),ee=Am(ie,G,Ce);ee&&setTimeout(()=>ee.ref.current.focus())}),ae=b.useCallback((G,ie,Ce)=>{const ee=!z.current&&!Ce;(w.value!==void 0&&w.value===ie||ee)&&(P(G),ee&&(z.current=!0))},[w.value]),j=b.useCallback(()=>A?.focus(),[A]),U=b.useCallback((G,ie,Ce)=>{const ee=!z.current&&!Ce;(w.value!==void 0&&w.value===ie||ee)&&C(G)},[w.value]),le=n==="popper"?Jl:lm,oe=le===Jl?{side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:l,collisionBoundary:p,collisionPadding:g,sticky:m,hideWhenDetached:h,avoidCollisions:y}:{};return d.jsx(im,{scope:r,content:A,viewport:F,onViewportChange:N,itemRefCallback:ae,selectedItem:T,onItemLeave:j,itemTextRefCallback:U,focusSelectedItem:X,selectedItemText:E,position:n,isPositioned:W,searchRef:D,children:d.jsx(Bi,{as:YC,allowPinchZoom:!0,children:d.jsx(yi,{asChild:!0,trapped:w.open,onMountAutoFocus:G=>{G.preventDefault()},onUnmountAutoFocus:De(o,G=>{w.trigger?.focus({preventScroll:!0}),G.preventDefault()}),children:d.jsx(gi,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:G=>G.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:d.jsx(le,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:G=>G.preventDefault(),...S,...oe,onPlaced:()=>M(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:De(S.onKeyDown,G=>{const ie=G.ctrlKey||G.altKey||G.metaKey;if(G.key==="Tab"&&G.preventDefault(),!ie&&G.key.length===1&&K(G.key),["ArrowUp","ArrowDown","Home","End"].includes(G.key)){let ee=I().filter(ne=>!ne.disabled).map(ne=>ne.ref.current);if(["ArrowUp","End"].includes(G.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(G.key)){const ne=G.target,he=ee.indexOf(ne);ee=ee.slice(he+1)}setTimeout(()=>V(ee)),G.preventDefault()}})})})})})})});am.displayName=qC;var XC="SelectItemAlignedPosition",lm=b.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...o}=e,s=Ln(ro,r),i=Dn(ro,r),[a,c]=b.useState(null),[u,f]=b.useState(null),l=Qe(t,k=>f(k)),p=ji(r),g=b.useRef(!1),m=b.useRef(!0),{viewport:h,selectedItem:y,selectedItemText:S,focusSelectedItem:w}=i,A=b.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&h&&y&&S){const k=s.trigger.getBoundingClientRect(),T=u.getBoundingClientRect(),P=s.valueNode.getBoundingClientRect(),E=S.getBoundingClientRect();if(s.dir!=="rtl"){const ne=E.left-T.left,he=P.left-ne,Ie=k.left-he,Ue=k.width+Ie,re=Math.max(Ue,T.width),ge=window.innerWidth-Yr,Se=us(he,[Yr,Math.max(Yr,ge-re)]);a.style.minWidth=Ue+"px",a.style.left=Se+"px"}else{const ne=T.right-E.right,he=window.innerWidth-P.right-ne,Ie=window.innerWidth-k.right-he,Ue=k.width+Ie,re=Math.max(Ue,T.width),ge=window.innerWidth-Yr,Se=us(he,[Yr,Math.max(Yr,ge-re)]);a.style.minWidth=Ue+"px",a.style.right=Se+"px"}const C=p(),I=window.innerHeight-Yr*2,W=h.scrollHeight,M=window.getComputedStyle(u),z=parseInt(M.borderTopWidth,10),V=parseInt(M.paddingTop,10),X=parseInt(M.borderBottomWidth,10),L=parseInt(M.paddingBottom,10),B=z+V+W+L+X,D=Math.min(y.offsetHeight*5,B),K=window.getComputedStyle(h),ae=parseInt(K.paddingTop,10),j=parseInt(K.paddingBottom,10),U=k.top+k.height/2-Yr,le=I-U,oe=y.offsetHeight/2,G=y.offsetTop+oe,ie=z+V+G,Ce=B-ie;if(ie<=U){const ne=C.length>0&&y===C[C.length-1].ref.current;a.style.bottom="0px";const he=u.clientHeight-h.offsetTop-h.offsetHeight,Ie=Math.max(le,oe+(ne?j:0)+he+X),Ue=ie+Ie;a.style.height=Ue+"px"}else{const ne=C.length>0&&y===C[0].ref.current;a.style.top="0px";const Ie=Math.max(U,z+h.offsetTop+(ne?ae:0)+oe)+Ce;a.style.height=Ie+"px",h.scrollTop=ie-U+h.offsetTop}a.style.margin=`${Yr}px 0`,a.style.minHeight=D+"px",a.style.maxHeight=I+"px",n?.(),requestAnimationFrame(()=>g.current=!0)}},[p,s.trigger,s.valueNode,a,u,h,y,S,s.dir,n]);tr(()=>A(),[A]);const[x,F]=b.useState();tr(()=>{u&&F(window.getComputedStyle(u).zIndex)},[u]);const N=b.useCallback(k=>{k&&m.current===!0&&(A(),w?.(),m.current=!1)},[A,w]);return d.jsx(QC,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:g,onScrollButtonChange:N,children:d.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:x},children:d.jsx(je.div,{...o,ref:l,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});lm.displayName=XC;var JC="SelectPopperPosition",Jl=b.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:o=Yr,...s}=e,i=zi(r);return d.jsx(Dp,{...i,...s,ref:t,align:n,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Jl.displayName=JC;var[QC,Ql]=ko(ro,{}),Zl="SelectViewport",cm=b.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...o}=e,s=Dn(Zl,r),i=Ql(Zl,r),a=Qe(t,s.onViewportChange),c=b.useRef(0);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),d.jsx($i.Slot,{scope:r,children:d.jsx(je.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:De(o.onScroll,u=>{const f=u.currentTarget,{contentWrapper:l,shouldExpandOnScrollRef:p}=i;if(p?.current&&l){const g=Math.abs(c.current-f.scrollTop);if(g>0){const m=window.innerHeight-Yr*2,h=parseFloat(l.style.minHeight),y=parseFloat(l.style.height),S=Math.max(h,y);if(S<m){const w=S+g,A=Math.min(m,w),x=w-A;l.style.height=A+"px",l.style.bottom==="0px"&&(f.scrollTop=x>0?x:0,l.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})});cm.displayName=Zl;var dm="SelectGroup",[ZC,eE]=ko(dm),tE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=hn();return d.jsx(ZC,{scope:r,id:o,children:d.jsx(je.div,{role:"group","aria-labelledby":o,...n,ref:t})})});tE.displayName=dm;var um="SelectLabel",rE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=eE(um,r);return d.jsx(je.div,{id:o.id,...n,ref:t})});rE.displayName=um;var Ui="SelectItem",[nE,fm]=ko(Ui),pm=b.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:o=!1,textValue:s,...i}=e,a=Ln(Ui,r),c=Dn(Ui,r),u=a.value===n,[f,l]=b.useState(s??""),[p,g]=b.useState(!1),m=Qe(t,w=>c.itemRefCallback?.(w,n,o)),h=hn(),y=b.useRef("touch"),S=()=>{o||(a.onValueChange(n),a.onOpenChange(!1))};if(n==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d.jsx(nE,{scope:r,value:n,disabled:o,textId:h,isSelected:u,onItemTextChange:b.useCallback(w=>{l(A=>A||(w?.textContent??"").trim())},[]),children:d.jsx($i.ItemSlot,{scope:r,value:n,disabled:o,textValue:f,children:d.jsx(je.div,{role:"option","aria-labelledby":h,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:m,onFocus:De(i.onFocus,()=>g(!0)),onBlur:De(i.onBlur,()=>g(!1)),onClick:De(i.onClick,()=>{y.current!=="mouse"&&S()}),onPointerUp:De(i.onPointerUp,()=>{y.current==="mouse"&&S()}),onPointerDown:De(i.onPointerDown,w=>{y.current=w.pointerType}),onPointerMove:De(i.onPointerMove,w=>{y.current=w.pointerType,o?c.onItemLeave?.():y.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:De(i.onPointerLeave,w=>{w.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:De(i.onKeyDown,w=>{c.searchRef?.current!==""&&w.key===" "||(UC.includes(w.key)&&S(),w.key===" "&&w.preventDefault())})})})})});pm.displayName=Ui;var gs="SelectItemText",mm=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,...s}=e,i=Ln(gs,r),a=Dn(gs,r),c=fm(gs,r),u=RC(gs,r),[f,l]=b.useState(null),p=Qe(t,S=>l(S),c.onItemTextChange,S=>a.itemTextRefCallback?.(S,c.value,c.disabled)),g=f?.textContent,m=b.useMemo(()=>d.jsx("option",{value:c.value,disabled:c.disabled,children:g},c.value),[c.disabled,c.value,g]),{onNativeOptionAdd:h,onNativeOptionRemove:y}=u;return tr(()=>(h(m),()=>y(m)),[h,y,m]),d.jsxs(d.Fragment,{children:[d.jsx(je.span,{id:c.textId,...s,ref:p}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?js.createPortal(s.children,i.valueNode):null]})});mm.displayName=gs;var hm="SelectItemIndicator",gm=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return fm(hm,r).isSelected?d.jsx(je.span,{"aria-hidden":!0,...n,ref:t}):null});gm.displayName=hm;var ec="SelectScrollUpButton",ym=b.forwardRef((e,t)=>{const r=Dn(ec,e.__scopeSelect),n=Ql(ec,e.__scopeSelect),[o,s]=b.useState(!1),i=Qe(t,n.onScrollButtonChange);return tr(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=r.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?d.jsx(vm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=r;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});ym.displayName=ec;var tc="SelectScrollDownButton",bm=b.forwardRef((e,t)=>{const r=Dn(tc,e.__scopeSelect),n=Ql(tc,e.__scopeSelect),[o,s]=b.useState(!1),i=Qe(t,n.onScrollButtonChange);return tr(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,f=Math.ceil(c.scrollTop)<u;s(f)};const c=r.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?d.jsx(vm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=r;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});bm.displayName=tc;var vm=b.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...o}=e,s=Dn("SelectScrollButton",r),i=b.useRef(null),a=ji(r),c=b.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return b.useEffect(()=>()=>c(),[c]),tr(()=>{a().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),d.jsx(je.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:De(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(n,50))}),onPointerMove:De(o.onPointerMove,()=>{s.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(n,50))}),onPointerLeave:De(o.onPointerLeave,()=>{c()})})}),oE="SelectSeparator",sE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return d.jsx(je.div,{"aria-hidden":!0,...n,ref:t})});sE.displayName=oE;var rc="SelectArrow",iE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=zi(r),s=Ln(rc,r),i=Dn(rc,r);return s.open&&i.position==="popper"?d.jsx(Bp,{...o,...n,ref:t}):null});iE.displayName=rc;var aE="SelectBubbleInput",wm=b.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const o=b.useRef(null),s=Qe(n,o),i=hs(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&f){const l=new Event("change",{bubbles:!0});f.call(a,t),a.dispatchEvent(l)}},[i,t]),d.jsx(je.select,{...r,style:{...$p,...r.style},ref:s,defaultValue:t})});wm.displayName=aE;function Sm(e){return e===""||e===void 0}function xm(e){const t=cr(e),r=b.useRef(""),n=b.useRef(0),o=b.useCallback(i=>{const a=r.current+i;t(a),(function c(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>c(""),1e3))})(a)},[t]),s=b.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,o,s]}function Am(e,t,r){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=r?e.indexOf(r):-1;let i=lE(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==r));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==r?c:void 0}function lE(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var cE=Qp,dE=em,uE=rm,fE=nm,pE=om,mE=sm,hE=cm,gE=pm,yE=mm,bE=gm,vE=ym,wE=bm;function SE({...e}){return d.jsx(cE,{"data-slot":"select",...e})}function xE({className:e,...t}){return d.jsx(uE,{"data-slot":"select-value",className:H("truncate min-w-0",e),...t})}function AE({className:e,size:t="default",children:r,...n}){const o=e?.includes("w-full");return d.jsxs(dE,{"data-slot":"select-trigger","data-size":t,className:H("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",o&&"min-w-0",e),...n,children:[r,d.jsx(fE,{asChild:!0,children:d.jsx(ts,{className:"size-4 opacity-50"})})]})}function CE({className:e,children:t,position:r="popper",...n}){return d.jsx(pE,{children:d.jsxs(mE,{"data-slot":"select-content",className:H("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...n,children:[d.jsx(EE,{}),d.jsx(hE,{className:H("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),d.jsx(NE,{})]})})}function nc({className:e,children:t,...r}){return d.jsxs(gE,{"data-slot":"select-item",className:H("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...r,children:[d.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:d.jsx(bE,{children:d.jsx(oi,{className:"size-4"})})}),d.jsx(yE,{className:"truncate",children:t})]})}function EE({className:e,...t}){return d.jsx(vE,{"data-slot":"select-scroll-up-button",className:H("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(Zw,{className:"size-4"})})}function NE({className:e,...t}){return d.jsx(wE,{"data-slot":"select-scroll-down-button",className:H("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(ts,{className:"size-4"})})}function Ut(e,t){if(!t||t.trim()===""||e==null)return;const r=t.split(".").filter(Boolean);let n=e;for(const o of r){if(n==null)return;n=n[o]}return n}function Cm(e){const t={array:[],pathPrefixToStrip:""};function r(a,c){if(a===null||typeof a!="object")return null;if(Array.isArray(a)&&a.length>0)return{array:a,fullPath:c};const u=Object.keys(a);for(const f of u){const l=a[f],p=c?`${c}.${f}`:f;if(Array.isArray(l)&&l.length>0)return{array:l,fullPath:p};if(l!==null&&typeof l=="object"){const g=r(l,p);if(g)return g}}return null}const n=r(e,"");if(!n)return t;const{array:o,fullPath:s}=n,i=s?`data.${s}.`:"";return{array:o,pathPrefixToStrip:i}}function kE(e){return e.length>=4&&Array.isArray(e[3])&&e[3].length===0}function _E(e,t,r){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"){const s=String(e);return{label:s,value:s,disabled:!1}}if(e==null)return{label:"",value:"",disabled:!0};if(typeof e!="object"||Array.isArray(e)){const s=Array.isArray(e)?"":String(e);return{label:s,value:s,disabled:!1}}let n,o;if(t){const s=t.includes(".")?Ut(e,t):e[t];n=String(s!==void 0?s:e.label??e.name??e.title??e.text??e.username??e.email??e.value??e.id??"")}else n=String(e.label??e.name??e.title??e.text??e.username??e.email??e.value??e.id??"");if(r){const s=r.includes(".")?Ut(e,r):e[r];o=String(s!==void 0?s:e.value??e.id??e.key??e.email??e.username??e.label??e.name??"")}else o=String(e.value??e.id??e.key??e.email??e.username??e.label??e.name??"");return{label:String(n??""),value:String(o??""),disabled:!!e.disabled}}function ys(e,t,r){if(!e)return[];if(Array.isArray(e)){if(e.length===0)return[];if(kE(e))return[];const n=e.filter(o=>o!=null);return n.length===0?[]:n.every(o=>typeof o=="string")?n.map(o=>({label:o,value:o,disabled:!1})):n.map(o=>_E(o,t,r))}if(typeof e=="object"){const{array:n,pathPrefixToStrip:o}=Cm(e);if(Array.isArray(n)&&n.length>0){const s=c=>!c||!c.trim()||!o?c:c.startsWith(o)?c.substring(o.length).replace(/^\.+/,"")||void 0:c,i=s(t),a=s(r);return ys(n,i,a)}}return[]}function TE(e){return!Array.isArray(e)||e.length===0?[]:e.filter(t=>t!=null).map((t,r)=>{if(typeof t=="string")return{label:t,value:t};if(typeof t=="object"&&t!==null){const n=t.label||t.value||String(t),o=t.value||t.label||String(t);return!n&&!o?{label:`Option ${r+1}`,value:String(r)}:{label:String(n),value:String(o),disabled:t.disabled||!1}}return{label:String(t),value:String(t)}})}function FE(e){return Array.isArray(e)&&e.length>=4&&Array.isArray(e[3])&&e[3].length>0&&Array.isArray(e[3][0])}function PE(e,t,r){if(!e)return[];try{const o=new URL(e).searchParams.get(t);return o?o.split(r).map(s=>s.trim()).filter(Boolean):[]}catch{const n=e.indexOf("?");if(n<0)return[];const o=e.slice(n+1);try{const i=new URLSearchParams(o).get(t);return i?i.split(r).map(a=>a.trim()).filter(Boolean):[]}catch{return[]}}}function Em(e){const{response:t,sourceUrl:r,rowsIndex:n,rowsPath:o,columns:s,columnsQueryParam:i="sf",columnsQueryParamSeparator:a=","}=e;let c;if(o&&o.trim()?c=Ut(t,o):typeof n=="number"?c=t?.[n]:c=t,!Array.isArray(c)||c.length===0)return[];const u=c.filter(p=>Array.isArray(p));if(u.length===0)return Array.isArray(c[0])?[]:null;if(!Array.isArray(u[0]))return null;const f=PE(r,i,a),l=f.length>0?f:Array.isArray(s)&&s.length>0?s:[];return u.map(p=>{const g={};return(l.length>0?l:Array.from({length:p.length},(h,y)=>`col${y}`)).forEach((h,y)=>{g[h]=p[y]}),g})}function OE(e){const{rows:t,apiLabelField:r,apiLabelFields:n,apiLabelSeparator:o,apiValueField:s}=e;if(!Array.isArray(t)||t.length===0)return[];const i=t.filter(l=>l!=null&&typeof l=="object"&&!Array.isArray(l));if(i.length===0)return[];const a=Array.isArray(n)?n.filter(Boolean):[],c=o??" - ",u=l=>{if(r){const p=r.includes(".")?Ut(l,r):l?.[r];if(p!=null&&String(p).trim()!=="")return String(p)}return String(l?.label??l?.name??l?.title??l?.text??l?.username??l?.email??l?.value??l?.id??l)},f=(l,p)=>{if(s){const g=s.includes(".")?Ut(l,s):l?.[s];if(g!=null)return String(g)}return String(l?.value??l?.id??l?.key??l?.email??l?.username??l?.label??l?.name??p??l)};return i.map(l=>{let p="";a.length>0&&(p=a.map(h=>Ut(l,h)).filter(h=>h!=null&&String(h).trim()!=="").map(h=>String(h)).join(c)),p||(p=u(l));const g=f(l,p);return{label:typeof p=="string"?p:String(p??""),value:typeof g=="string"?g:String(g??""),disabled:!!l?.disabled}})}function Nm(e){return e!=null&&!Array.isArray(e)&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean")}function IE(e,t){const{array:r,pathPrefixToStrip:n}=Cm(e);if(!Array.isArray(r)||r.length===0)return null;const o=new Set([t]);n&&t.startsWith(n)&&o.add(t.slice(n.length).replace(/^\.+/,""));const s=t.match(/^data\.data\.(.+)$/);s?.[1]&&o.add(s[1]);const i=r[0];for(const a of o){if(!a)continue;const c=a.includes(".")?Ut(i,a):i?.[a];if(Nm(c))return String(c)}return null}function ME(e,t,r){if(e==null)return null;const n=t?.trim(),o=r?.trim()||n;if(!n&&!o)return null;if(n){const i=Ut(e,n);if(Nm(i))return String(i);const a=IE(e,n);if(a!=null)return a}const s=ys(e,o,n||o);if(s.length>0){const i=s[0].value;if(i!=null&&String(i).trim()!=="")return String(i)}return null}function LE(e){if(e?.token!=null&&String(e.token).trim()!=="")return String(e.token);const t=ds(),r=t?.Authorization??t?.authorization;if(r?.trim()){const n=r.match(/^Bearer\s+(.+)$/i);return n?n[1]:r}}function km(e,t){const r=LE(t);if(!r)return e;let n=e.replace(/\{token\}/g,r);return n=n.replace(/\{authorization\}/gi,()=>r.startsWith("Bearer ")?r:`Bearer ${r}`),n}function Bn(e,t){const r={},{formValues:n={},submissionContext:o,apiRealtime:s}=t;for(const{key:i,value:a}of e??[]){const c=i?.trim();if(!c||a==null)continue;let u=nl(String(a),n,o,s);u=km(u,o),r[c]=u}return r}const DE=new Set(["authorization"]);function BE(e){return DE.has(e.trim().toLowerCase())}function Vi(e){return(e??[]).filter(t=>!BE(t.key))}function Hi(e){if(!e?.length)return null;const t=e.find(r=>r.key.toLowerCase()==="authorization");if(t?.value?.trim()){const r=t.value.trim();if(r.toLowerCase().startsWith("basic ")){const n=r.slice(6).trim();if(n.includes("{")||n.includes("}")){const o=n.split(":");if(o.length>=2)return{type:"basic",username:o[0].trim(),password:o.slice(1).join(":").trim()}}try{const o=atob(n),s=o.indexOf(":");if(s>=0)return{type:"basic",username:o.slice(0,s),password:o.slice(s+1)}}catch{return{type:"basic",username:"",password:""}}}return r.toLowerCase().startsWith("bearer ")?{type:"bearer",token:r.slice(7).trim()}:{type:"bearer",token:r}}return null}function $E(e){return!e||e.type==="none"?{type:"none"}:e.type==="bearer"?{type:"bearer",token:e.token?.trim()??""}:e.type==="apiKey"?{type:"apiKey",headerName:e.headerName?.trim()||"X-API-Key",apiKey:e.apiKey?.trim()??""}:{type:"basic",username:e.username?.trim()??"",password:e.password?.trim()??""}}function Wi(e,t){const{formValues:r={},submissionContext:n,urlParams:o={},apiRealtime:s}=t;let i=Lr(e,r,o,n);return i=km(i,n),s!==void 0&&(i=nl(i,r,n,s)),i}function Ri(e,t={}){const r=$E(e),n={};if(r.type==="bearer"){const o=r.token??"";if(!o.trim())return n;const s=Wi(o,t).trim();return s&&(n.Authorization=s.toLowerCase().startsWith("bearer ")?s:`Bearer ${s}`),n}if(r.type==="apiKey"){const o=r.apiKey??"";return o.trim()&&(n[r.headerName||"X-API-Key"]=Wi(o,t)),n}if(r.type==="basic"){const o=r.username??"",s=r.password??"";if(!o.trim()&&!s.trim())return n;const i=Wi(o,t),a=Wi(s,t);n.Authorization=`Basic ${btoa(`${i}:${a}`)}`}return n}function _m({field:e,formValues:t={},submissionContext:r}){const n=e.properties,o=n?.apiEndpoint?{apiEndpoint:n.apiEndpoint,apiMethod:n.apiMethod,apiKey:n.apiKey,apiRealtime:n.apiRealtime,apiAutoDetect:n.apiAutoDetect,apiLabelField:n.apiLabelField,apiValueField:n.apiValueField,apiQueryParams:n.apiQueryParams,apiClientFilter:n.apiClientFilter,apiHeaders:n.apiHeaders,apiBodyFields:n.apiBodyFields,apiAuth:n.apiAuth,valueSource:n.valueSource,optionsSource:n.optionsSource}:null,s=e.apidata||null,i=o||s,[a,c]=v.useState([]),[u,f]=v.useState([]),[l,p]=v.useState([]),[g,m]=v.useState(!1),[h,y]=v.useState(null),S=!!(i?.apiEndpoint&&(i?.valueSource==="api"||i?.optionsSource==="api"||n?.valueSource==="api"||n?.optionsSource==="api")),w=e.options||n?.options||[],A=v.useMemo(()=>TE(Array.isArray(w)?w:[]),[w]),x=v.useMemo(()=>{const E=i?.apiEndpoint||n?.apiEndpoint||"",C=i?.apiQueryParams||n?.apiQueryParams;return po(E,C)},[i?.apiEndpoint,n?.apiEndpoint,i?.apiQueryParams,n?.apiQueryParams]),F=v.useMemo(()=>{const E=new Set;for(const I of n?.dependentFields??[])typeof I=="string"&&I.trim()&&E.add(I.trim());const C=i?.apiClientFilter?.matchField?.trim()||n?.apiClientFilter?.matchField?.trim();return C&&E.add(C),[...E]},[n?.dependentFields,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField]),N=v.useMemo(()=>{const E=new Set([...x,...F]);if(E.size===0)return null;const C={};return E.forEach(I=>{C[I]=t[I]}),JSON.stringify(C)},[x,F,t]),k=v.useMemo(()=>JSON.stringify(r||{}),[r]),T=v.useMemo(()=>{const E=new Set;e.name?.trim()&&E.add(e.name.trim());const C=e.key;return typeof C=="string"&&C.trim()&&E.add(C.trim()),[...E]},[e.name,e.key]);return v.useEffect(()=>{const E=i?.apiEndpoint;if(!S||!E){c([]);return}let C=!1;return(async()=>{a.length===0&&m(!0),y(null);try{const M=i?.apiMethod||n?.apiMethod||"GET",z=i?.apiRealtime||n?.apiRealtime,V=i?.apiQueryParams||n?.apiQueryParams||{},X=Qs({apiEndpoint:E,apiMethod:M,apiQueryParams:V,formValues:t,submissionContext:r,apiRealtime:z,additionalRequiredFieldNames:F,excludeFormFieldNames:T});if(X.blocked){C||(c([]),m(!1));return}const L={"Content-Type":"application/json"},B=i?.apiKey||n?.apiKey;B&&(L["X-CSCAPI-KEY"]=B);const D=i?.apiAuth??n?.apiAuth??s?.apiAuth??Hi(i?.apiHeaders??n?.apiHeaders??s?.apiHeaders)??{type:"none"},K=Ri(D,{formValues:t,submissionContext:r,apiRealtime:z});Object.assign(L,K);const ae=i?.apiHeaders??n?.apiHeaders??s?.apiHeaders,j=i?.apiBodyFields??n?.apiBodyFields??s?.apiBodyFields,U=Bn(Vi(ae),{formValues:t,submissionContext:r,apiRealtime:z});Object.assign(L,U);const le=Bn(j,{formValues:t,submissionContext:r,apiRealtime:z}),oe={method:M.toLowerCase(),url:Mr(X.url),headers:L};(X.postBodyBase!=null||Object.keys(le).length>0)&&(oe.data={...X.postBodyBase??{},...le});const G=await Ct(oe),ie=i?.apiLabelField||n?.apiLabelField,Ce=i?.apiValueField||n?.apiValueField,ee=G.data;let ne=[];Array.isArray(ee)?ne=ee:ee?.data&&(Array.isArray(ee.data)?ne=ee.data:ee.data?.data&&Array.isArray(ee.data.data)?ne=ee.data.data:ee.data.districts?ne=ee.data.districts:ee.data.states?ne=ee.data.states:ee.data.cities&&(ne=ee.data.cities)),p(ne);const he=ys(G.data,ie,Ce);f(he);const Ie=i?.apiClientFilter||n?.apiClientFilter;let Ue=he;if(Ie?.filterField&&Ie?.matchField){const re=t[Ie.matchField];re!=null?Ue=he.filter(ge=>{const Se=ne.find(Dt=>String(Ut(Dt,Ce||"code"))===String(ge.value));if(!Se)return!1;const pt=Ut(Se,Ie.filterField);return String(pt)===String(re)}):Ue=[]}C||c(Ue)}catch(M){if(C)return;let z="Failed to load options";if(M.response){const V=M.response.data;M.response.status===404?z="API endpoint not found.":M.response.status===401?z="Authentication failed.":typeof V=="string"?z=V:V&&typeof V=="object"&&(z=V.error||V.message||V.detail||z)}else M.message&&(z=String(M.message));y(z),a.length===0&&c([])}finally{C||m(!1)}})(),()=>{C=!0}},[S,i?.apiEndpoint,i?.apiMethod,n?.apiEndpoint,n?.apiMethod,N,F,T,k]),v.useEffect(()=>{const E=i?.apiClientFilter||n?.apiClientFilter;if(!S||!E||l.length===0)return;const C=t[E.matchField],I=i?.apiValueField||n?.apiValueField;if(C==null){c([]);return}const W=u.filter(M=>{const z=l.find(X=>String(Ut(X,I||"code"))===String(M.value));if(!z)return!1;const V=Ut(z,E.filterField);return String(V)===String(C)});c(W)},[S,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField,i?.apiClientFilter?.filterField,n?.apiClientFilter?.filterField,i?.apiValueField,n?.apiValueField,t[i?.apiClientFilter?.matchField||n?.apiClientFilter?.matchField||""],u,l]),{options:S?a:A,isLoadingOptions:g,optionsError:h}}const Tm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,formValues:c={},submissionContext:u,excludedOptionValues:f,isPrepopulateTarget:l=!1})=>{const p=e.properties,g=p?.apiEndpoint?{apiEndpoint:p.apiEndpoint,valueSource:p.valueSource,optionsSource:p.optionsSource}:null,m=e.apidata||null,h=g||m,y=!!(h?.apiEndpoint&&(h?.valueSource==="api"||h?.optionsSource==="api"||p?.valueSource==="api"||p?.optionsSource==="api")),{options:S,isLoadingOptions:w,optionsError:A}=_m({field:e,formValues:c,submissionContext:u}),x=f?.length?new Set(f.map(String)):null,F=x?S.filter(D=>!x.has(String(D.value??D.label??""))):S,N="__clear__",k=t!=null&&String(t).trim()!=="",T=k?F.some(D=>String(D.value??D.label??"")===String(t)):!1,P=v.useMemo(()=>{if(!k||T)return F;const D=String(t);return[{label:D,value:D},...F]},[F,k,T,t]),E=k?String(t):void 0,C=`${ft(e)}-${E??"empty"}`,I=v.useCallback(D=>{r(D===N?"":D),n?.()},[r,n]),W=e.appearance?.size||"md",M={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},z=e.placeholder||"Select an option",V=p?.apiClientFilter?.matchField?.trim()||h?.apiClientFilter?.matchField?.trim(),X=y&&V&&(c[V]===void 0||c[V]===null||c[V]===""),L=w?"Loading options...":X?`Select ${V} first`:f?.length?"No available options":y?"No options available from API":"No options available";return y&&l&&w?d.jsx(At,{field:e,error:o||A||void 0,isRequired:i,className:a,children:d.jsxs("div",{role:"status","aria-label":"Loading options",className:H("flex items-center justify-center gap-2 w-full min-w-0 rounded-md border border-input bg-muted/50 text-muted-foreground",M[W],e.appearance?.className),children:[d.jsx(mo,{className:"h-4 w-4 animate-spin shrink-0"}),d.jsx("span",{className:"truncate",children:"Loading..."})]})}):d.jsx(At,{field:e,error:o||A||void 0,isRequired:i,className:a,children:d.jsxs(SE,{value:E,onValueChange:I,disabled:s||e.disabled||w&&F.length===0,children:[d.jsx(AE,{id:ft(e),"aria-describedby":Lt(e,!!o||!!A),"aria-invalid":Jt(!!o||!!A),"aria-required":i,className:H("w-full min-w-0",M[W],o&&"border-destructive focus-visible:ring-destructive",A&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:d.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[w&&d.jsx(mo,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"}),F.length===0&&f?.length&&!k?d.jsx("span",{className:"text-muted-foreground truncate",children:"No available options"}):k?d.jsx(xE,{placeholder:z}):d.jsx("span",{className:"text-muted-foreground truncate",children:z})]})}),d.jsx(CE,{children:P.length===0?d.jsx(nc,{value:"__no_options__",disabled:!0,children:L}):d.jsxs(d.Fragment,{children:[k?d.jsx(nc,{value:N,children:z}):null,P.map((D,K)=>{const ae=String(D.value??D.label??K);if(ae===N)return null;const j=D.label||D.value||String(D);return d.jsx(nc,{value:ae,disabled:D.disabled||!1,children:j},ae)})]})})]},C)})},Fm=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Pm=Td,Om=(e,t)=>r=>{var n;if(t?.variants==null)return Pm(e,r?.class,r?.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(u=>{const f=r?.[u],l=s?.[u];if(f===null)return null;const p=Fm(f)||Fm(l);return o[u][p]}),a=r&&Object.entries(r).reduce((u,f)=>{let[l,p]=f;return p===void 0||(u[l]=p),u},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,f)=>{let{class:l,className:p,...g}=f;return Object.entries(g).every(m=>{let[h,y]=m;return Array.isArray(y)?y.includes({...s,...a}[h]):{...s,...a}[h]===y})?[...u,l,p]:u},[]);return Pm(e,i,c,r?.class,r?.className)},jE=Om("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all cursor-pointer disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function Zt({className:e,variant:t,size:r,asChild:n=!1,...o}){const s=n?Bu:"button";return d.jsx(s,{"data-slot":"button",className:H(jE({variant:t,size:r,className:e})),...o})}function zE(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var xr=e=>{const{present:t,children:r}=e,n=UE(t),o=typeof r=="function"?r({present:n.isPresent}):b.Children.only(r),s=Qe(n.ref,VE(o));return typeof r=="function"||n.isPresent?b.cloneElement(o,{ref:s}):null};xr.displayName="Presence";function UE(e){const[t,r]=b.useState(),n=b.useRef(null),o=b.useRef(e),s=b.useRef("none"),i=e?"mounted":"unmounted",[a,c]=zE(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const u=Gi(n.current);s.current=a==="mounted"?u:"none"},[a]),tr(()=>{const u=n.current,f=o.current;if(f!==e){const p=s.current,g=Gi(u);e?c("MOUNT"):g==="none"||u?.display==="none"?c("UNMOUNT"):c(f&&p!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),tr(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,l=g=>{const h=Gi(n.current).includes(CSS.escape(g.animationName));if(g.target===t&&h&&(c("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=g=>{g.target===t&&(s.current=Gi(n.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",l),t.addEventListener("animationend",l),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",l),t.removeEventListener("animationend",l)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:b.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function Gi(e){return e?.animationName||"none"}function VE(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function HE(e){const t=WE(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(GE);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function WE(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=qE(o),a=KE(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var RE=Symbol("radix.slottable");function GE(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===RE}function KE(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function qE(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Ki="Popover",[Im]=vr(Ki,[_i]),bs=_i(),[YE,$n]=Im(Ki),Mm=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=bs(t),c=b.useRef(null),[u,f]=b.useState(!1),[l,p]=ln({prop:n,defaultProp:o??!1,onChange:s,caller:Ki});return d.jsx(Lp,{...a,children:d.jsx(YE,{scope:t,contentId:hn(),triggerRef:c,open:l,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(g=>!g),[p]),hasCustomAnchor:u,onCustomAnchorAdd:b.useCallback(()=>f(!0),[]),onCustomAnchorRemove:b.useCallback(()=>f(!1),[]),modal:i,children:r})})};Mm.displayName=Ki;var Lm="PopoverAnchor",Dm=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(Lm,r),s=bs(r),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return b.useEffect(()=>(i(),()=>a()),[i,a]),d.jsx(Wl,{...s,...n,ref:t})});Dm.displayName=Lm;var Bm="PopoverTrigger",$m=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(Bm,r),s=bs(r),i=Qe(t,o.triggerRef),a=d.jsx(je.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Hm(o.open),...n,ref:i,onClick:De(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:d.jsx(Wl,{asChild:!0,...s,children:a})});$m.displayName=Bm;var oc="PopoverPortal",[XE,JE]=Im(oc,{forceMount:void 0}),jm=e=>{const{__scopePopover:t,forceMount:r,children:n,container:o}=e,s=$n(oc,t);return d.jsx(XE,{scope:t,forceMount:r,children:d.jsx(xr,{present:r||s.open,children:d.jsx(Ti,{asChild:!0,container:o,children:n})})})};jm.displayName=oc;var _o="PopoverContent",zm=b.forwardRef((e,t)=>{const r=JE(_o,e.__scopePopover),{forceMount:n=r.forceMount,...o}=e,s=$n(_o,e.__scopePopover);return d.jsx(xr,{present:n||s.open,children:s.modal?d.jsx(ZE,{...o,ref:t}):d.jsx(eN,{...o,ref:t})})});zm.displayName=_o;var QE=HE("PopoverContent.RemoveScroll"),ZE=b.forwardRef((e,t)=>{const r=$n(_o,e.__scopePopover),n=b.useRef(null),o=Qe(t,n),s=b.useRef(!1);return b.useEffect(()=>{const i=n.current;if(i)return Gl(i)},[]),d.jsx(Bi,{as:QE,allowPinchZoom:!0,children:d.jsx(Um,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:De(e.onCloseAutoFocus,i=>{i.preventDefault(),s.current||r.triggerRef.current?.focus()}),onPointerDownOutside:De(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0,u=a.button===2||c;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:De(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),eN=b.forwardRef((e,t)=>{const r=$n(_o,e.__scopePopover),n=b.useRef(!1),o=b.useRef(!1);return d.jsx(Um,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(n.current||r.triggerRef.current?.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;r.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Um=b.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:f,...l}=e,p=$n(_o,r),g=bs(r);return kl(),d.jsx(yi,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(gi,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:f,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:d.jsx(Dp,{"data-state":Hm(p.open),role:"dialog",id:p.contentId,...g,...l,ref:t,style:{...l.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Vm="PopoverClose",tN=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(Vm,r);return d.jsx(je.button,{type:"button",...n,ref:t,onClick:De(e.onClick,()=>o.onOpenChange(!1))})});tN.displayName=Vm;var rN="PopoverArrow",nN=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=bs(r);return d.jsx(Bp,{...o,...n,ref:t})});nN.displayName=rN;function Hm(e){return e?"open":"closed"}var oN=Mm,sN=Dm,iN=$m,aN=jm,lN=zm;function sc({...e}){return d.jsx(oN,{"data-slot":"popover",...e})}function Wm({...e}){return d.jsx(iN,{"data-slot":"popover-trigger",...e})}function ic({className:e,align:t="center",sideOffset:r=4,...n}){return d.jsx(aN,{children:d.jsx(lN,{"data-slot":"popover-content",align:t,sideOffset:r,className:H("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden pointer-events-auto",e),...n})})}function cN({...e}){return d.jsx(sN,{"data-slot":"popover-anchor",...e})}function Rm(e){return JSON.stringify(e).slice(1,-1)}function Gm(e){const t=e.asyncSearchValueObjectKeys;return Array.isArray(t)?t.map(r=>typeof r=="string"?r.trim():"").filter(Boolean):[]}function dN(e){return e.asyncSearchValueMode==="object"&&Gm(e).length>0}function uN(e,t){const r={};for(const n of t){const o=n.trim();if(!o)continue;const s=Ut(e,o);s==null||typeof s=="object"?r[o]="":r[o]=String(s)}return r}function fN(e,t){const r=t.mode??"debounce",n=Math.max(0,t.intervalMs??300),[o,s]=v.useState(()=>r==="throttle"?e:""),i=v.useRef(0),a=v.useRef(void 0);return v.useEffect(()=>{if(e===""){a.current&&clearTimeout(a.current),s("");return}if(r==="debounce"){const f=setTimeout(()=>s(e),n);return()=>clearTimeout(f)}const c=Date.now(),u=c-i.current;return u>=n?(i.current=c,s(e),()=>{a.current&&clearTimeout(a.current)}):(a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i.current=Date.now(),s(e),a.current=void 0},n-u),()=>{a.current&&clearTimeout(a.current)})},[e,r,n]),o}function ac(e,t){if(e==null||e==="")return"";if(t&&typeof e=="object"&&!Array.isArray(e)){const r=e,o=Object.keys(r).sort().map(s=>[s,r[s]??""]);return`O:${JSON.stringify(o)}`}return typeof e=="string"?`S:${e}`:""}function lc(e,t){return e==null||e===""?!0:t&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length===0:!1}function pN(e,t,r){return t.trim()!==""?!0:e==null||e===""?!1:r&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length>0:typeof e=="string"&&e.length>0}function mN(e){if(Ct.isAxiosError(e)){const t=e.response?.status,r=e.response?.data;if(t===404)return"Search endpoint not found.";if(t===401)return"Authentication failed.";if(r&&typeof r=="object"){const n=r,o=n.error??n.message??n.detail??n.explanation;if(typeof o=="string")return o}if(typeof r=="string")return r;if(t)return`Request failed (${t})`}return e instanceof Error?e.message:"Search failed"}function hN(e){if(e==null)return[];if(Array.isArray(e))return e;const t=e;if(!t?.data)return[];const r=t.data;return Array.isArray(r)?r:r?.data&&Array.isArray(r.data)?r.data:Array.isArray(r?.districts)?r.districts:Array.isArray(r?.states)?r.states:Array.isArray(r?.cities)?r.cities:[]}function Km(e,t){return typeof t=="number"&&t>0?e.slice(0,t):e}function cc(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.label=="string"&&t.value!==null&&t.value!==void 0}const qm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u={},submissionContext:f})=>{const l=e.properties||{},p=dN(l),g=l.apiEndpoint?.trim()||"",m=l.apiRealtime===!0,h=(l.apiMethod||"GET").toUpperCase()==="POST"?"POST":"GET",y=l.searchInBody===!0,S=h==="POST"||h==="GET"&&y,w=l.searchStrategy??l.searchSchedule??"debounce",A=l.searchIntervalMs??l.intervalMs??300,x=l.minQueryLength??0,F=l.maxResults,N=l.searchQueryParam||"q",k=l.clearable!==!1,T=u,[P,E]=v.useState(()=>lc(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?l.initialDisplayLabel||"":l.initialDisplayLabel||String(t)),[C,I]=v.useState(!1),[W,M]=v.useState([]),[z,V]=v.useState([]),[X,L]=v.useState([]),[B,D]=v.useState(!1),[K,ae]=v.useState(null),[j,U]=v.useState(-1),le=v.useRef(ac(t,p)),oe=v.useRef(lc(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?l.initialDisplayLabel||"":l.initialDisplayLabel||String(t??"")),G=v.useRef(void 0),ie=v.useRef(0),Ce=v.useRef(null),ee=fN(P,{mode:w,intervalMs:A}),ne=v.useMemo(()=>W.filter(cc),[W]);v.useEffect(()=>{if(ne.length===0){j!==-1&&U(-1);return}(j<0||j>=ne.length)&&U(0)},[j,ne.length]);const he=v.useMemo(()=>{const J=po(g,l.apiQueryParams),$=new Set(J);for(const fe of l.dependentFields||[])fe&&$.add(fe);return $},[g,l.apiQueryParams,l.dependentFields]),Ie=v.useMemo(()=>{if(he.size===0)return null;const J={};return he.forEach($=>{J[$]=T[$]}),JSON.stringify(J)},[he,T]),Ue=v.useMemo(()=>JSON.stringify(u),[u]),re=v.useMemo(()=>JSON.stringify(f||{}),[f]);v.useEffect(()=>{const J=ac(t,p);if(J===le.current)return;if(le.current=J,lc(t,p)){oe.current="",E(""),M([]),V([]),L([]),ae(null),I(!1);return}const $=l.initialDisplayLabel||(!p&&typeof t=="string"?t:"");oe.current=$,E($)},[t,l.initialDisplayLabel,p]),v.useEffect(()=>{if(!g){M([]),V([]),L([]),D(!1);return}if(i||s||e.disabled){M([]),V([]),L([]),D(!1);return}const J=ee;if(J.length<x){M([]),V([]),L([]),D(!1),ae(null);return}const $=Qs({apiEndpoint:g,apiMethod:h,apiQueryParams:l.apiQueryParams,formValues:T,submissionContext:f,apiRealtime:m,additionalRequiredFieldNames:l.dependentFields});if($.blocked){M([]),V([]),L([]),D(!1),ae(null);return}Ce.current?.abort();const fe=new AbortController;Ce.current=fe;const it=++ie.current;return(async()=>{D(!0),ae(null);const Ye=Mr($.url),Me={};S&&(Me["Content-Type"]="application/json"),l.apiKey&&(Me["X-CSCAPI-KEY"]=l.apiKey);const xe=l.apiAuth??Hi(l.apiHeaders)??{type:"none"},et=Ri(xe,{formValues:T,submissionContext:f,apiRealtime:m});Object.assign(Me,et);const We=Bn(Vi(l.apiHeaders),{formValues:T,submissionContext:f,apiRealtime:m});Object.assign(Me,We);const dt=Bn(l.apiBodyFields,{formValues:T,submissionContext:f,apiRealtime:m});try{let bt;if(!S)bt=(await Qt.get(Ye,{params:{[N]:J},signal:fe.signal,headers:Object.keys(Me).length?Me:void 0})).data;else{let $t={};$.postBodyBase&&Object.keys($.postBodyBase).length>0?$t={...$.postBodyBase}:m&&Object.keys(T).length>0&&($t={...T}),$t={...$t,...dt};let Ht=$t;if(l.searchBodyTemplate?.trim()){let Jr=l.searchBodyTemplate.replace(/\{\{query\}\}/g,()=>Rm(J)).replace(/\{query\}/g,()=>Rm(J));Jr=nl(Jr,T,f,m);const Yt=JSON.parse(Jr);Ht={...$t,...Yt}}else Ht={...$t,[N]:J};bt=(await Qt.post(Ye,Ht,{signal:fe.signal,headers:Object.keys(Me).length?Me:void 0})).data}if(it!==ie.current)return;const ir=l.apiResultsFormat,xt=l.apiResultsConfig,$e=ir==="clinicaltables_v3",gt=FE(bt),kt=$e||ir===void 0&&gt,nr=ir==="tuple_array";let yr=null;kt?yr=Em({response:bt,sourceUrl:Ye,rowsIndex:xt?.rowsIndex??3,rowsPath:xt?.rowsPath,columns:xt?.columns,columnsQueryParam:xt?.columnsQueryParam??"sf",columnsQueryParamSeparator:xt?.columnsQueryParamSeparator??","}):nr&&(yr=Em({response:bt,sourceUrl:Ye,rowsIndex:xt?.rowsIndex,rowsPath:xt?.rowsPath,columns:xt?.columns,columnsQueryParam:xt?.columnsQueryParam,columnsQueryParamSeparator:xt?.columnsQueryParamSeparator}));const Er=hN(bt),Ot=yr!==null,Nr=yr&&Array.isArray(yr)?yr:Array.isArray(Er)&&Er.every($t=>$t&&typeof $t=="object"&&!Array.isArray($t))?Er:null;L(Nr??Er);const ar=Array.isArray(l.apiLabelFields)&&l.apiLabelFields.length>0,Sn=Nr&&(Ot||ar)?OE({rows:Nr,apiLabelField:l.apiLabelField,apiLabelFields:l.apiLabelFields,apiLabelSeparator:l.apiLabelSeparator,apiValueField:l.apiValueField}):ys(bt,l.apiLabelField,l.apiValueField);V(Sn);const un=l.apiClientFilter;let jr=Sn;if(un?.filterField&&un?.matchField){const $t=T[un.matchField];if($t!=null){const Ht=l.apiValueField;jr=Sn.filter(br=>{const Yt=(Nr??Er).find(Un=>String(Ut(Un,Ht||"code"))===String(br.value));if(!Yt)return!1;const lr=Ut(Yt,un.filterField);return String(lr)===String($t)})}else jr=[]}const zn=Km(jr,F).filter(cc);M(zn),U(zn.length>0?0:-1)}catch(bt){if(Ct.isCancel(bt)||bt?.code==="ERR_CANCELED"||it!==ie.current)return;M([]),V([]),L([]),ae(mN(bt)),U(-1)}finally{it===ie.current&&D(!1)}})(),()=>{fe.abort()}},[ee,g,h,y,S,N,x,F,l.apiKey,l.searchBodyTemplate,l.apiLabelField,l.apiLabelFields,l.apiLabelSeparator,l.apiValueField,l.apiQueryParams,l.apiClientFilter,l.apiResultsFormat,l.apiResultsConfig,l.dependentFields,m,T,f,i,s,e.disabled,Ie,Ue,re]),v.useEffect(()=>{const J=l.apiClientFilter;if(!J||X.length===0||z.length===0)return;const $=T[J.matchField],fe=l.apiValueField;if($==null){M([]);return}const it=z.filter(Ye=>{const Me=X.find(et=>String(Ut(et,fe||"code"))===String(Ye.value));if(!Me)return!1;const xe=Ut(Me,J.filterField);return String(xe)===String($)}),Te=Km(it,F).filter(cc);M(Te),U(Te.length>0?0:-1)},[l.apiClientFilter,l.apiValueField,T,F,z,X]);const ge=s||e.disabled,Se=i||e.readOnly,pt=v.useCallback(J=>{const $=J.target.value;Se||ge||(le.current&&oe.current&&$!==oe.current&&(le.current="",oe.current="",r(p?null:"")),E($),I(!0),U(-1))},[ge,Se,p,r]),Dt=v.useCallback(J=>{const $=typeof J?.label=="string"?J.label:String(J?.value??""),fe=l.apiValueField||"code";if(p){const it=Gm(l),Te=X.find(Ye=>String(Ut(Ye,fe))===String(J.value));if(Te&&typeof Te=="object"&&!Array.isArray(Te)&&it.length>0){const Ye=uN(Te,it);le.current=ac(Ye,!0),oe.current=$,r(Ye),E($)}else le.current=`S:${String(J.value)}`,oe.current=$,r(String(J.value)),E($)}else le.current=`S:${String(J.value)}`,oe.current=$,r(String(J.value)),E($);G.current&&clearTimeout(G.current),I(!1),U(-1),n?.()},[p,n,r,l,X]),Bt=v.useCallback(J=>{J.preventDefault(),J.stopPropagation(),!(ge||Se)&&(le.current="",oe.current="",r(p?null:""),E(""),M([]),V([]),L([]),ae(null),I(!1),n?.())},[ge,Se,p,r,n]),Pt=v.useMemo(()=>C&&!Se&&(B||!!K||ne.length>0||ee.length>=x&&!B),[C,Se,B,K,ne.length,ee,x]),Ar=v.useCallback(J=>{if(!(Se||ge))if(J.key==="ArrowDown")J.preventDefault(),I(!0),U($=>ne.length===0?-1:($+1)%ne.length);else if(J.key==="ArrowUp")J.preventDefault(),I(!0),U($=>ne.length===0?-1:$<=0?ne.length-1:$-1);else if(J.key==="Enter"){const $=j>=0?ne[j]:void 0;Pt&&$&&!$.disabled&&(J.preventDefault(),Dt($))}else J.key==="Escape"&&I(!1)},[ge,Se,j,Pt,ne,Dt]),Nt=e.appearance?.size||"md",Cr={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},Xe=ft(e),ve=Lt(e,!!(o||K)),ce=ee.length>=x&&!B&&!K&&ne.length===0;return d.jsx(At,{field:e,error:o||K||void 0,isRequired:a,className:c,children:d.jsxs(sc,{open:Pt,onOpenChange:J=>{J||I(!1)},children:[d.jsx(cN,{asChild:!0,children:d.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[d.jsx(mn,{id:Xe,role:"combobox","aria-expanded":Pt,"aria-autocomplete":"list","aria-controls":Pt?`${Xe}-listbox`:void 0,"aria-activedescendant":j>=0?`${Xe}-opt-${j}`:void 0,value:P,onChange:pt,onKeyDown:Ar,onFocus:()=>{G.current&&clearTimeout(G.current),!Se&&!ge&&I(!0)},onBlur:()=>{G.current=setTimeout(()=>{I(!1),n?.()},150)},placeholder:e.placeholder||"Search…",disabled:ge,readOnly:Se,"aria-describedby":ve,"aria-invalid":Jt(!!(o||K)),"aria-required":a,className:H("pr-20",Cr[Nt],(o||K)&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),d.jsxs("div",{className:"pointer-events-none absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[B&&d.jsx(mo,{className:"pointer-events-none h-4 w-4 animate-spin text-muted-foreground"}),k&&pN(t,P,p)&&!ge&&!Se&&d.jsx(Zt,{type:"button",variant:"ghost",size:"icon",className:"pointer-events-auto h-8 w-8 shrink-0",onMouseDown:J=>J.preventDefault(),onClick:Bt,"aria-label":"Clear",children:d.jsx(ns,{className:"h-4 w-4"})})]})]})}),d.jsx(ic,{className:"p-0 w-[var(--radix-popover-trigger-width)] min-w-[12rem] overflow-hidden",align:"start",onOpenAutoFocus:J=>J.preventDefault(),onCloseAutoFocus:J=>J.preventDefault(),children:d.jsx("div",{id:`${Xe}-listbox`,role:"listbox",children:K?d.jsx("div",{className:"px-3 py-2 text-sm text-destructive",children:K}):B?d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground",children:[d.jsx(mo,{className:"h-4 w-4 animate-spin shrink-0"}),"Loading…"]}):ce?d.jsx("ul",{className:"py-1","aria-label":"Search results",children:d.jsx("li",{role:"option","aria-disabled":!0,className:"cursor-default select-none px-3 py-2 text-sm text-muted-foreground",onMouseDown:J=>J.preventDefault(),children:"No results found"})}):d.jsx("ul",{className:"max-h-60 overflow-y-auto overscroll-contain py-1","aria-label":"Search results",children:ne.map((J,$)=>d.jsx("li",{id:`${Xe}-opt-${$}`,role:"option","aria-selected":j===$,className:H(J.disabled?"cursor-not-allowed opacity-60":"cursor-pointer","px-3 py-2 text-sm",j===$&&"bg-accent text-accent-foreground"),onMouseEnter:()=>U($),onMouseDown:fe=>fe.preventDefault(),onClick:()=>{J.disabled||Dt(J)},children:J.label},`${J.value}-${$}`))})})})]})})};var qi="Checkbox",[gN]=vr(qi),[yN,dc]=gN(qi);function bN(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:o,disabled:s,form:i,name:a,onCheckedChange:c,required:u,value:f="on",internal_do_not_use_render:l}=e,[p,g]=ln({prop:r,defaultProp:o??!1,onChange:c,caller:qi}),[m,h]=b.useState(null),[y,S]=b.useState(null),w=b.useRef(!1),A=m?!!i||!!m.closest("form"):!0,x={checked:p,disabled:s,setChecked:g,control:m,setControl:h,name:a,form:i,value:f,hasConsumerStoppedPropagationRef:w,required:u,defaultChecked:jn(o)?!1:o,isFormControl:A,bubbleInput:y,setBubbleInput:S};return d.jsx(yN,{scope:t,...x,children:vN(l)?l(x):n})}var Ym="CheckboxTrigger",Xm=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},o)=>{const{control:s,value:i,disabled:a,checked:c,required:u,setControl:f,setChecked:l,hasConsumerStoppedPropagationRef:p,isFormControl:g,bubbleInput:m}=dc(Ym,e),h=Qe(o,f),y=b.useRef(c);return b.useEffect(()=>{const S=s?.form;if(S){const w=()=>l(y.current);return S.addEventListener("reset",w),()=>S.removeEventListener("reset",w)}},[s,l]),d.jsx(je.button,{type:"button",role:"checkbox","aria-checked":jn(c)?"mixed":c,"aria-required":u,"data-state":rh(c),"data-disabled":a?"":void 0,disabled:a,value:i,...n,ref:h,onKeyDown:De(t,S=>{S.key==="Enter"&&S.preventDefault()}),onClick:De(r,S=>{l(w=>jn(w)?!0:!w),m&&g&&(p.current=S.isPropagationStopped(),p.current||S.stopPropagation())})})});Xm.displayName=Ym;var Jm=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:o,defaultChecked:s,required:i,disabled:a,value:c,onCheckedChange:u,form:f,...l}=e;return d.jsx(bN,{__scopeCheckbox:r,checked:o,defaultChecked:s,disabled:a,required:i,onCheckedChange:u,name:n,form:f,value:c,internal_do_not_use_render:({isFormControl:p})=>d.jsxs(d.Fragment,{children:[d.jsx(Xm,{...l,ref:t,__scopeCheckbox:r}),p&&d.jsx(th,{__scopeCheckbox:r})]})})});Jm.displayName=qi;var Qm="CheckboxIndicator",Zm=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...o}=e,s=dc(Qm,r);return d.jsx(xr,{present:n||jn(s.checked)||s.checked===!0,children:d.jsx(je.span,{"data-state":rh(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});Zm.displayName=Qm;var eh="CheckboxBubbleInput",th=b.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:o,checked:s,defaultChecked:i,required:a,disabled:c,name:u,value:f,form:l,bubbleInput:p,setBubbleInput:g}=dc(eh,e),m=Qe(r,g),h=hs(s),y=ms(n);b.useEffect(()=>{const w=p;if(!w)return;const A=window.HTMLInputElement.prototype,F=Object.getOwnPropertyDescriptor(A,"checked").set,N=!o.current;if(h!==s&&F){const k=new Event("click",{bubbles:N});w.indeterminate=jn(s),F.call(w,jn(s)?!1:s),w.dispatchEvent(k)}},[p,h,s,o]);const S=b.useRef(jn(s)?!1:s);return d.jsx(je.input,{type:"checkbox","aria-hidden":!0,defaultChecked:i??S.current,required:a,disabled:c,name:u,value:f,form:l,...t,tabIndex:-1,ref:m,style:{...t.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});th.displayName=eh;function vN(e){return typeof e=="function"}function jn(e){return e==="indeterminate"}function rh(e){return jn(e)?"indeterminate":e?"checked":"unchecked"}function Yi({className:e,...t}){return d.jsx(Jm,{"data-slot":"checkbox",className:H("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(Zm,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:d.jsx(oi,{className:"size-3.5"})})})}const wN=Om("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-destructive-foreground [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",warning:"border-transparent bg-orange-500 text-white [a&]:hover:bg-orange-600 focus-visible:ring-orange-500/20",success:"border-transparent bg-green-500 text-white [a&]:hover:bg-green-600 focus-visible:ring-green-500/20",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function SN({className:e,variant:t,asChild:r=!1,...n}){const o=r?Bu:"span";return d.jsx(o,{"data-slot":"badge",className:H(wN({variant:t}),e),...n})}function xN(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var uc="ScrollArea",[nh]=vr(uc),[AN,Dr]=nh(uc),oh=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=b.useState(null),[u,f]=b.useState(null),[l,p]=b.useState(null),[g,m]=b.useState(null),[h,y]=b.useState(null),[S,w]=b.useState(0),[A,x]=b.useState(0),[F,N]=b.useState(!1),[k,T]=b.useState(!1),P=Qe(t,C=>c(C)),E=bo(o);return d.jsx(AN,{scope:r,type:n,dir:E,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:f,content:l,onContentChange:p,scrollbarX:g,onScrollbarXChange:m,scrollbarXEnabled:F,onScrollbarXEnabledChange:N,scrollbarY:h,onScrollbarYChange:y,scrollbarYEnabled:k,onScrollbarYEnabledChange:T,onCornerWidthChange:w,onCornerHeightChange:x,children:d.jsx(je.div,{dir:E,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":A+"px",...e.style}})})});oh.displayName=uc;var sh="ScrollAreaViewport",ih=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...s}=e,i=Dr(sh,r),a=b.useRef(null),c=Qe(t,a,i.onViewportChange);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),d.jsx(je.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});ih.displayName=sh;var dn="ScrollAreaScrollbar",ah=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Dr(dn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return b.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?d.jsx(CN,{...n,ref:t,forceMount:r}):o.type==="scroll"?d.jsx(EN,{...n,ref:t,forceMount:r}):o.type==="auto"?d.jsx(lh,{...n,ref:t,forceMount:r}):o.type==="always"?d.jsx(fc,{...n,ref:t}):null});ah.displayName=dn;var CN=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Dr(dn,e.__scopeScrollArea),[s,i]=b.useState(!1);return b.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},f=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",f),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",f)}}},[o.scrollArea,o.scrollHideDelay]),d.jsx(xr,{present:r||s,children:d.jsx(lh,{"data-state":s?"visible":"hidden",...n,ref:t})})}),EN=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Dr(dn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Zi(()=>c("SCROLL_END"),100),[a,c]=xN("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return b.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),b.useEffect(()=>{const u=o.viewport,f=s?"scrollLeft":"scrollTop";if(u){let l=u[f];const p=()=>{const g=u[f];l!==g&&(c("SCROLL"),i()),l=g};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,s,c,i]),d.jsx(xr,{present:r||a!=="hidden",children:d.jsx(fc,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:De(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:De(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),lh=b.forwardRef((e,t)=>{const r=Dr(dn,e.__scopeScrollArea),{forceMount:n,...o}=e,[s,i]=b.useState(!1),a=e.orientation==="horizontal",c=Zi(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,f=r.viewport.offsetHeight<r.viewport.scrollHeight;i(a?u:f)}},10);return To(r.viewport,c),To(r.content,c),d.jsx(xr,{present:n||s,children:d.jsx(fc,{"data-state":s?"visible":"hidden",...o,ref:t})})}),fc=b.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=Dr(dn,e.__scopeScrollArea),s=b.useRef(null),i=b.useRef(0),[a,c]=b.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=ph(a.viewport,a.content),f={...n,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function l(p,g){return PN(p,i.current,a,g)}return r==="horizontal"?d.jsx(NN,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,g=mh(p,a,o.dir);s.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=l(p,o.dir))}}):r==="vertical"?d.jsx(kN,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,g=mh(p,a);s.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=l(p))}}):null}),NN=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Dr(dn,e.__scopeScrollArea),[i,a]=b.useState(),c=b.useRef(null),u=Qe(t,c,s.onScrollbarXChange);return b.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),d.jsx(dh,{"data-orientation":"horizontal",...o,ref:u,sizes:r,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Qi(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.x),onDragScroll:f=>e.onDragScroll(f.x),onWheelScroll:(f,l)=>{if(s.viewport){const p=s.viewport.scrollLeft+f.deltaX;e.onWheelScroll(p),gh(p,l)&&f.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Ji(i.paddingLeft),paddingEnd:Ji(i.paddingRight)}})}})}),kN=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Dr(dn,e.__scopeScrollArea),[i,a]=b.useState(),c=b.useRef(null),u=Qe(t,c,s.onScrollbarYChange);return b.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),d.jsx(dh,{"data-orientation":"vertical",...o,ref:u,sizes:r,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Qi(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.y),onDragScroll:f=>e.onDragScroll(f.y),onWheelScroll:(f,l)=>{if(s.viewport){const p=s.viewport.scrollTop+f.deltaY;e.onWheelScroll(p),gh(p,l)&&f.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Ji(i.paddingTop),paddingEnd:Ji(i.paddingBottom)}})}})}),[_N,ch]=nh(dn),dh=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:f,onResize:l,...p}=e,g=Dr(dn,r),[m,h]=b.useState(null),y=Qe(t,P=>h(P)),S=b.useRef(null),w=b.useRef(""),A=g.viewport,x=n.content-n.viewport,F=cr(f),N=cr(c),k=Zi(l,10);function T(P){if(S.current){const E=P.clientX-S.current.left,C=P.clientY-S.current.top;u({x:E,y:C})}}return b.useEffect(()=>{const P=E=>{const C=E.target;m?.contains(C)&&F(E,x)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[A,m,x,F]),b.useEffect(N,[n,N]),To(m,k),To(g.content,k),d.jsx(_N,{scope:r,scrollbar:m,hasThumb:o,onThumbChange:cr(s),onThumbPointerUp:cr(i),onThumbPositionChange:N,onThumbPointerDown:cr(a),children:d.jsx(je.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:De(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),S.current=m.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),T(P))}),onPointerMove:De(e.onPointerMove,T),onPointerUp:De(e.onPointerUp,P=>{const E=P.target;E.hasPointerCapture(P.pointerId)&&E.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=w.current,g.viewport&&(g.viewport.style.scrollBehavior=""),S.current=null})})})}),Xi="ScrollAreaThumb",uh=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=ch(Xi,e.__scopeScrollArea);return d.jsx(xr,{present:r||o.hasThumb,children:d.jsx(TN,{ref:t,...n})})}),TN=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,s=Dr(Xi,r),i=ch(Xi,r),{onThumbPositionChange:a}=i,c=Qe(t,l=>i.onThumbChange(l)),u=b.useRef(void 0),f=Zi(()=>{u.current&&(u.current(),u.current=void 0)},100);return b.useEffect(()=>{const l=s.viewport;if(l){const p=()=>{if(f(),!u.current){const g=ON(l,a);u.current=g,a()}};return a(),l.addEventListener("scroll",p),()=>l.removeEventListener("scroll",p)}},[s.viewport,f,a]),d.jsx(je.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:De(e.onPointerDownCapture,l=>{const g=l.target.getBoundingClientRect(),m=l.clientX-g.left,h=l.clientY-g.top;i.onThumbPointerDown({x:m,y:h})}),onPointerUp:De(e.onPointerUp,i.onThumbPointerUp)})});uh.displayName=Xi;var pc="ScrollAreaCorner",fh=b.forwardRef((e,t)=>{const r=Dr(pc,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?d.jsx(FN,{...e,ref:t}):null});fh.displayName=pc;var FN=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=Dr(pc,r),[s,i]=b.useState(0),[a,c]=b.useState(0),u=!!(s&&a);return To(o.scrollbarX,()=>{const f=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(f),c(f)}),To(o.scrollbarY,()=>{const f=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(f),i(f)}),u?d.jsx(je.div,{...n,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Ji(e){return e?parseInt(e,10):0}function ph(e,t){const r=e/t;return isNaN(r)?0:r}function Qi(e){const t=ph(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function PN(e,t,r,n="ltr"){const o=Qi(r),s=o/2,i=t||s,a=o-i,c=r.scrollbar.paddingStart+i,u=r.scrollbar.size-r.scrollbar.paddingEnd-a,f=r.content-r.viewport,l=n==="ltr"?[0,f]:[f*-1,0];return hh([c,u],l)(e)}function mh(e,t,r="ltr"){const n=Qi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-n,c=r==="ltr"?[0,i]:[i*-1,0],u=us(e,c);return hh([0,i],[0,a])(u)}function hh(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function gh(e,t){return e>0&&e<t}var ON=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return(function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=r.left!==s.left,a=r.top!==s.top;(i||a)&&t(),r=s,n=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(n)};function Zi(e,t){const r=cr(e),n=b.useRef(0);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),b.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function To(e,t){const r=cr(t);tr(()=>{let n=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return o.observe(e),()=>{window.cancelAnimationFrame(n),o.unobserve(e)}}},[e,r])}var IN=oh,MN=ih,LN=fh;function DN({className:e,children:t,...r}){return d.jsxs(IN,{"data-slot":"scroll-area",className:H("relative",e),...r,children:[d.jsx(MN,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),d.jsx(BN,{}),d.jsx(LN,{})]})}function BN({className:e,orientation:t="vertical",...r}){return d.jsx(ah,{"data-slot":"scroll-area-scrollbar",orientation:t,className:H("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...r,children:d.jsx(uh,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const yh=({field:e,value:t=[],onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,formValues:c={},submissionContext:u,excludedOptionValues:f})=>{const{options:l,isLoadingOptions:p,optionsError:g}=_m({field:e,formValues:c,submissionContext:u}),m=f?.length?new Set(f.map(String)):null,h=m?l.filter(k=>!m.has(String(k.value??k.label??""))):l,y=Array.isArray(t)?t:[],S=y.map(k=>h.find(T=>String(T.value)===String(k))).filter(Boolean),w=v.useCallback(k=>{const T=y.includes(k)?y.filter(P=>P!==k):[...y,k];r(T),n?.()},[y,r,n]),A=v.useCallback(k=>{r(y.filter(T=>T!==k)),n?.()},[y,r,n]),x=e.appearance?.size||"md",F={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},N=S.length>0?`${S.length} selected`:h.length===0&&f?.length?"No available options":e.placeholder||"Select options";return d.jsxs(At,{field:e,error:o||g||void 0,isRequired:i,className:a,children:[d.jsxs(sc,{children:[d.jsx(Wm,{asChild:!0,children:d.jsxs(Zt,{type:"button",variant:"outline",role:"combobox","aria-expanded":void 0,"aria-haspopup":"listbox","aria-multiselectable":"true","aria-describedby":Lt(e,!!o||!!g),"aria-invalid":Jt(!!o||!!g),"aria-required":i,id:ft(e),disabled:s||e.disabled||p,className:H("w-full min-w-0 justify-between font-normal",F[x],o&&"border-destructive focus-visible:ring-destructive",g&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:[d.jsx("span",{className:"truncate",children:N}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p&&d.jsx(mo,{className:"h-4 w-4 animate-spin text-muted-foreground"}),d.jsx(ts,{className:"h-4 w-4 opacity-50"})]})]})}),d.jsx(ic,{className:"w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden",align:"start",children:d.jsx(DN,{className:"h-60 overflow-hidden rounded-md",children:d.jsx("ul",{role:"listbox","aria-multiselectable":"true","aria-label":e.label||e.name||"Options",className:"p-1",children:h.length===0?d.jsx("li",{className:"px-2 py-3 text-sm text-muted-foreground text-center",children:p?"Loading options...":f?.length?"No available options":"No options available"}):h.map(k=>{const T=String(k.value||k.label),P=k.label||k.value||T,E=y.includes(T);return d.jsxs("li",{role:"option","aria-selected":E,className:"flex items-center gap-2 rounded-sm px-2 py-1.5 cursor-pointer hover:bg-accent focus:bg-accent outline-none",onClick:()=>!k.disabled&&w(T),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),k.disabled||w(T))},children:[d.jsx(Yi,{checked:E,disabled:k.disabled,onCheckedChange:()=>!k.disabled&&w(T),onClick:C=>C.stopPropagation(),"aria-hidden":!0,className:"pointer-events-none"}),d.jsx("span",{className:"flex-1 truncate text-sm",children:P})]},T)})})})})]}),S.length>0&&d.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",role:"list","aria-label":"Selected options",children:S.map(k=>{const T=String(k.value||k.label),P=k.label||k.value||T;return d.jsxs(SN,{variant:"secondary",className:"pl-2 pr-1 py-0.5 text-xs font-normal gap-1",children:[d.jsx("span",{className:"truncate max-w-[120px]",children:P}),d.jsx("button",{type:"button","aria-label":`Remove ${P}`,className:"rounded-full p-0.5 hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring",onClick:()=>A(T),tabIndex:-1,children:d.jsx(ns,{className:"h-3 w-3"})})]},T)})})]})},bh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const c=v.useCallback(u=>{r(u===!0),n?.()},[r,n]);return d.jsxs("div",{className:H("space-y-2",a),children:[d.jsxs("div",{className:"flex items-start space-x-3",children:[d.jsx(Yi,{id:ft(e),checked:t||!1,onCheckedChange:c,disabled:s||e.disabled,"aria-describedby":Lt(e,!!o),"aria-required":i,className:H(o&&"border-destructive")}),d.jsxs("div",{className:"grid gap-1.5 leading-none",children:[d.jsxs(Fn,{id:ti(e),htmlFor:ft(e),className:H("text-sm font-medium cursor-pointer",o&&"text-destructive"),children:[e.label,i&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&d.jsx("p",{id:Zo(e),className:"text-xs text-muted-foreground",children:e.description})]})]}),o&&d.jsx("p",{id:es(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var ea="Switch",[$N]=vr(ea),[jN,zN]=$N(ea),vh=b.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:f,...l}=e,[p,g]=b.useState(null),m=Qe(t,A=>g(A)),h=b.useRef(!1),y=p?f||!!p.closest("form"):!0,[S,w]=ln({prop:o,defaultProp:s??!1,onChange:u,caller:ea});return d.jsxs(jN,{scope:r,checked:S,disabled:a,children:[d.jsx(je.button,{type:"button",role:"switch","aria-checked":S,"aria-required":i,"data-state":Ah(S),"data-disabled":a?"":void 0,disabled:a,value:c,...l,ref:m,onClick:De(e.onClick,A=>{w(x=>!x),y&&(h.current=A.isPropagationStopped(),h.current||A.stopPropagation())})}),y&&d.jsx(xh,{control:p,bubbles:!h.current,name:n,value:c,checked:S,required:i,disabled:a,form:f,style:{transform:"translateX(-100%)"}})]})});vh.displayName=ea;var wh="SwitchThumb",Sh=b.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,o=zN(wh,r);return d.jsx(je.span,{"data-state":Ah(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:t})});Sh.displayName=wh;var UN="SwitchBubbleInput",xh=b.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Qe(i,s),c=hs(r),u=ms(t);return b.useEffect(()=>{const f=i.current;if(!f)return;const l=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(l,"checked").set;if(c!==r&&g){const m=new Event("click",{bubbles:n});g.call(f,r),f.dispatchEvent(m)}},[c,r,n]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});xh.displayName=UN;function Ah(e){return e?"checked":"unchecked"}var VN=vh,HN=Sh;function Ch({className:e,...t}){return d.jsx(VN,{"data-slot":"switch",className:H("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(HN,{"data-slot":"switch-thumb",className:H("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const WN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const c=e.properties;let u=null;if(e.metadata)try{u=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata}catch{}const f=u?.onValue??c?.onValue??"On",l=u?.offValue??c?.offValue??"Off",p=u?.onText??c?.onText??f,g=u?.offText??c?.offText??l,m=v.useMemo(()=>{const y=t??e.defaultValue??l;return String(y)===String(f)},[t,e.defaultValue,l,f]),h=v.useCallback(y=>{r(y?f:l),n?.()},[r,n,f,l]);return d.jsxs("div",{className:H("space-y-2",a),children:[d.jsxs("div",{className:"space-y-2",children:[e.label&&d.jsxs(Fn,{id:ti(e),htmlFor:ft(e),className:H("text-sm font-medium block",o&&"text-destructive"),children:[e.label,i&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&d.jsx("p",{id:Zo(e),className:"text-xs text-muted-foreground",children:e.description}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Ch,{id:ft(e),checked:m,onCheckedChange:h,disabled:s||e.disabled,"aria-describedby":Lt(e,!!o),"aria-required":i,className:H(o&&"opacity-50")}),d.jsx("span",{className:"text-sm text-foreground font-medium",children:m?p:g})]})]}),o&&d.jsx("p",{id:es(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var mc="rovingFocusGroup.onEntryFocus",RN={bubbles:!1,cancelable:!0},vs="RovingFocusGroup",[hc,Eh,GN]=Cl(vs),[KN,ta]=vr(vs,[GN]),[qN,YN]=KN(vs),Nh=b.forwardRef((e,t)=>d.jsx(hc.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(hc.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(XN,{...e,ref:t})})}));Nh.displayName=vs;var XN=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...l}=e,p=b.useRef(null),g=Qe(t,p),m=bo(s),[h,y]=ln({prop:i,defaultProp:a??null,onChange:c,caller:vs}),[S,w]=b.useState(!1),A=cr(u),x=Eh(r),F=b.useRef(!1),[N,k]=b.useState(0);return b.useEffect(()=>{const T=p.current;if(T)return T.addEventListener(mc,A),()=>T.removeEventListener(mc,A)},[A]),d.jsx(qN,{scope:r,orientation:n,dir:m,loop:o,currentTabStopId:h,onItemFocus:b.useCallback(T=>y(T),[y]),onItemShiftTab:b.useCallback(()=>w(!0),[]),onFocusableItemAdd:b.useCallback(()=>k(T=>T+1),[]),onFocusableItemRemove:b.useCallback(()=>k(T=>T-1),[]),children:d.jsx(je.div,{tabIndex:S||N===0?-1:0,"data-orientation":n,...l,ref:g,style:{outline:"none",...e.style},onMouseDown:De(e.onMouseDown,()=>{F.current=!0}),onFocus:De(e.onFocus,T=>{const P=!F.current;if(T.target===T.currentTarget&&P&&!S){const E=new CustomEvent(mc,RN);if(T.currentTarget.dispatchEvent(E),!E.defaultPrevented){const C=x().filter(V=>V.focusable),I=C.find(V=>V.active),W=C.find(V=>V.id===h),z=[I,W,...C].filter(Boolean).map(V=>V.ref.current);Th(z,f)}}F.current=!1}),onBlur:De(e.onBlur,()=>w(!1))})})}),kh="RovingFocusGroupItem",_h=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=hn(),u=s||c,f=YN(kh,r),l=f.currentTabStopId===u,p=Eh(r),{onFocusableItemAdd:g,onFocusableItemRemove:m,currentTabStopId:h}=f;return b.useEffect(()=>{if(n)return g(),()=>m()},[n,g,m]),d.jsx(hc.ItemSlot,{scope:r,id:u,focusable:n,active:o,children:d.jsx(je.span,{tabIndex:l?0:-1,"data-orientation":f.orientation,...a,ref:t,onMouseDown:De(e.onMouseDown,y=>{n?f.onItemFocus(u):y.preventDefault()}),onFocus:De(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:De(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){f.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const S=ZN(y,f.orientation,f.dir);if(S!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let A=p().filter(x=>x.focusable).map(x=>x.ref.current);if(S==="last")A.reverse();else if(S==="prev"||S==="next"){S==="prev"&&A.reverse();const x=A.indexOf(y.currentTarget);A=f.loop?ek(A,x+1):A.slice(x+1)}setTimeout(()=>Th(A))}}),children:typeof i=="function"?i({isCurrentTabStop:l,hasTabStop:h!=null}):i})})});_h.displayName=kh;var JN={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function QN(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ZN(e,t,r){const n=QN(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return JN[n]}function Th(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function ek(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Fh=Nh,Ph=_h,gc="Radio",[tk,Oh]=vr(gc),[rk,nk]=tk(gc),Ih=b.forwardRef((e,t)=>{const{__scopeRadio:r,name:n,checked:o=!1,required:s,disabled:i,value:a="on",onCheck:c,form:u,...f}=e,[l,p]=b.useState(null),g=Qe(t,y=>p(y)),m=b.useRef(!1),h=l?u||!!l.closest("form"):!0;return d.jsxs(rk,{scope:r,checked:o,disabled:i,children:[d.jsx(je.button,{type:"button",role:"radio","aria-checked":o,"data-state":Bh(o),"data-disabled":i?"":void 0,disabled:i,value:a,...f,ref:g,onClick:De(e.onClick,y=>{o||c?.(),h&&(m.current=y.isPropagationStopped(),m.current||y.stopPropagation())})}),h&&d.jsx(Dh,{control:l,bubbles:!m.current,name:n,value:a,checked:o,required:s,disabled:i,form:u,style:{transform:"translateX(-100%)"}})]})});Ih.displayName=gc;var Mh="RadioIndicator",Lh=b.forwardRef((e,t)=>{const{__scopeRadio:r,forceMount:n,...o}=e,s=nk(Mh,r);return d.jsx(xr,{present:n||s.checked,children:d.jsx(je.span,{"data-state":Bh(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});Lh.displayName=Mh;var ok="RadioBubbleInput",Dh=b.forwardRef(({__scopeRadio:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Qe(i,s),c=hs(r),u=ms(t);return b.useEffect(()=>{const f=i.current;if(!f)return;const l=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(l,"checked").set;if(c!==r&&g){const m=new Event("click",{bubbles:n});g.call(f,r),f.dispatchEvent(m)}},[c,r,n]),d.jsx(je.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Dh.displayName=ok;function Bh(e){return e?"checked":"unchecked"}var sk=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],ra="RadioGroup",[ik]=vr(ra,[ta,Oh]),$h=ta(),jh=Oh(),[ak,lk]=ik(ra),zh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,name:n,defaultValue:o,value:s,required:i=!1,disabled:a=!1,orientation:c,dir:u,loop:f=!0,onValueChange:l,...p}=e,g=$h(r),m=bo(u),[h,y]=ln({prop:s,defaultProp:o??null,onChange:l,caller:ra});return d.jsx(ak,{scope:r,name:n,required:i,disabled:a,value:h,onValueChange:y,children:d.jsx(Fh,{asChild:!0,...g,orientation:c,dir:m,loop:f,children:d.jsx(je.div,{role:"radiogroup","aria-required":i,"aria-orientation":c,"data-disabled":a?"":void 0,dir:m,...p,ref:t})})})});zh.displayName=ra;var Uh="RadioGroupItem",Vh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,disabled:n,...o}=e,s=lk(Uh,r),i=s.disabled||n,a=$h(r),c=jh(r),u=b.useRef(null),f=Qe(t,u),l=s.value===o.value,p=b.useRef(!1);return b.useEffect(()=>{const g=h=>{sk.includes(h.key)&&(p.current=!0)},m=()=>p.current=!1;return document.addEventListener("keydown",g),document.addEventListener("keyup",m),()=>{document.removeEventListener("keydown",g),document.removeEventListener("keyup",m)}},[]),d.jsx(Ph,{asChild:!0,...a,focusable:!i,active:l,children:d.jsx(Ih,{disabled:i,required:s.required,checked:l,...c,...o,name:s.name,ref:f,onCheck:()=>s.onValueChange(o.value),onKeyDown:De(g=>{g.key==="Enter"&&g.preventDefault()}),onFocus:De(o.onFocus,()=>{p.current&&u.current?.click()})})})});Vh.displayName=Uh;var ck="RadioGroupIndicator",Hh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,...n}=e,o=jh(r);return d.jsx(Lh,{...o,...n,ref:t})});Hh.displayName=ck;var dk=zh,uk=Vh,fk=Hh;function pk({className:e,...t}){return d.jsx(dk,{"data-slot":"radio-group",className:H("grid gap-3",e),...t})}function mk({className:e,...t}){return d.jsx(uk,{"data-slot":"radio-group-item",className:H("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(fk,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:d.jsx(Vu,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const Wh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,excludedOptionValues:c})=>{const u=e.properties,f=Array.isArray(u?.options)&&u.options.length>0?u.options:Array.isArray(e.options)?e.options:[],l=c?.length?new Set(c.map(String)):null,p=l?f.filter(m=>!l.has(String(m.value??m.label??""))):f,g=v.useCallback(m=>{r(m),n?.()},[r,n]);return d.jsx(At,{field:e,error:o,isRequired:i,className:a,children:d.jsx(pk,{value:t||"",onValueChange:g,disabled:s||e.disabled||p.length===0,className:"flex flex-col space-y-2","aria-required":i,children:p.length===0?d.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"No available options"}):p.map(m=>d.jsxs("div",{className:"flex items-center space-x-3",children:[d.jsx(mk,{id:`${ft(e)}-${m.value}`,value:m.value,disabled:m.disabled,className:H(o&&"border-destructive")}),d.jsxs(Fn,{htmlFor:`${ft(e)}-${m.value}`,className:H("text-sm font-normal cursor-pointer",m.disabled&&"text-muted-foreground cursor-not-allowed"),children:[m.label,m.description&&d.jsx("span",{className:"block text-xs text-muted-foreground",children:m.description})]})]},m.value))})})},Rh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=v.useCallback(x=>{r(x.target.value)},[r]),l=x=>{if(x)return x==="today"?new Date().toISOString().split("T")[0]:x},p=l(u?.minDate),g=l(u?.maxDate),h=(()=>{switch(e.type){case"time":return"time";case"datetime":return"datetime-local";case"daterange":return"date";default:return"date"}})(),y=e.appearance?.size||"md",S={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},w=e.appearance?.labelPlacement||"top",A=!e.appearance?.hideLabel&&e.label;return d.jsxs("div",{className:H("space-y-2 w-fit",w==="left"&&"flex items-start gap-4",c),children:[A&&d.jsxs(Fn,{id:ti(e),htmlFor:ft(e),className:H("text-sm font-medium",w==="left"&&"w-32 pt-2 text-right",o&&"text-destructive"),children:[e.label,a&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),d.jsxs("div",{className:"w-fit",children:[d.jsxs("div",{className:"relative w-fit max-w-full",children:[d.jsx(Qw,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),d.jsx(mn,{id:ft(e),type:h,value:t||"",onChange:f,onBlur:n,disabled:s||e.disabled,readOnly:i||e.readOnly,min:p,max:g,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(S[y],"pl-10 w-fit",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]}),e.description&&!o&&d.jsx("p",{id:Zo(e),className:"mt-1.5 text-xs text-muted-foreground",children:e.description}),o&&d.jsx("p",{id:es(e),className:"mt-1.5 text-xs text-destructive",role:"alert",children:o})]})]})};function Fo(e){if(e===0)return"0 Bytes";const t=1024,r=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,n)).toFixed(2))+" "+r[n]}function yc(e,t){return e===1&&t===1}const Gh=/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?|$)/i;function bc(e){return e.type.startsWith("image/")?!0:Gh.test(e.name)}function na(e){try{const t=e.split("?")[0];return Gh.test(t)}catch{return!1}}function vc({items:e,maxFiles:t,disabled:r,objectUrls:n,failedUrlKeys:o,onImageUrlError:s,onRemove:i,onOpenUrl:a,resolveOpenUrl:c,addSlot:u,className:f}){const l=v.useCallback(p=>{try{return p.split("?")[0].split("/").filter(Boolean).pop()||p}catch{return p}},[]);return d.jsxs("div",{"data-file-like-strip":!0,"data-remove-in-dropzone":!0,className:H("relative w-full h-full flex items-center gap-1 min-h-0 overflow-x-auto",f),children:[e.map((p,g)=>{const m=p instanceof File,h=!m&&p&&"url"in p?p:null,y=h?.url??"",S=`${g}-${y}`,w=h&&o.has(y),A=m?n[g]??null:h&&na(y)&&!w?y:null,x=m&&bc(p)&&!!A||!!h&&na(y)&&!w&&!!A,F=m?p.name:h?h.name??l(y):"",N=c?.(g,p),k=h&&y||N||"",T=!!a&&!!k;return d.jsxs("div",{className:"relative h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded overflow-hidden border border-border/60 bg-muted/30",children:[x&&A?d.jsx("img",{src:A,alt:"",className:"absolute inset-0 h-full w-full object-cover",onError:()=>{h&&s(y)}}):d.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-muted/40",children:d.jsx(Wu,{className:"h-7 w-7 text-muted-foreground","aria-hidden":!0})}),d.jsxs("div",{className:"absolute top-0.5 right-0.5 z-10 flex items-center gap-0.5",children:[T&&d.jsx("button",{type:"button",onClick:P=>{P.preventDefault(),P.stopPropagation(),a(k)},disabled:r,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:d.jsx(Hu,{className:"h-3 w-3","aria-hidden":!0})}),d.jsx("button",{type:"button",onClick:P=>{P.preventDefault(),P.stopPropagation(),i(g)},disabled:r,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-destructive hover:bg-background focus:outline-none focus:ring-2 focus:ring-destructive","aria-label":"Remove file",title:"Remove file",children:d.jsx(ns,{className:"h-3 w-3","aria-hidden":!0})})]}),!x&&F&&d.jsx("span",{className:"sr-only",children:F})]},S+(m?p.name+p.size:""))}),u]})}function wc(e){const[t,r]=v.useState([]);return v.useEffect(()=>{const n=e.map(o=>o instanceof File&&bc(o)?URL.createObjectURL(o):null);return r(n),()=>{n.forEach(o=>{o&&URL.revokeObjectURL(o)})}},[e]),t}function Sc({item:e,objectUrl:t,failedUrlKeys:r,onImageUrlError:n,onRemove:o,onOpenUrl:s,openTarget:i,disabled:a}){const c=v.useCallback(w=>{try{return w.split("?")[0].split("/").filter(Boolean).pop()||w}catch{return w}},[]),u=e instanceof File,f=!u&&e&&"url"in e?e:null,l=f?.url??"",p=f&&r.has(l),g=u?t:f&&na(l)&&!p?l:null,m=u&&bc(e)&&!!g||!!f&&na(l)&&!p&&!!g,h=u?e.name:f?f.name??c(l):"",y=(i?.trim()||l||"").trim(),S=!!s&&!!y;return d.jsxs("div",{"data-file-like-full-bleed":!0,"data-remove-in-dropzone":!0,className:"relative h-full w-full min-h-[58px] min-w-0 flex items-center justify-center",children:[m&&g?d.jsx("img",{src:g,alt:"",className:"absolute inset-0 h-full w-full rounded object-cover",onError:()=>{f&&n(l)}}):d.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded bg-muted/40",children:d.jsx(Wu,{className:"h-8 w-8 text-muted-foreground","aria-hidden":!0})}),d.jsxs("div",{className:"absolute top-1 right-1 z-10 flex items-center gap-1",children:[S&&y&&d.jsx("button",{type:"button",onClick:w=>{w.preventDefault(),w.stopPropagation(),s(y)},disabled:a,className:"inline-flex h-6 w-6 items-center justify-center rounded bg-background/85 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:d.jsx(Hu,{className:"h-3.5 w-3.5","aria-hidden":!0})}),d.jsx("button",{type:"button",onClick:w=>{w.preventDefault(),w.stopPropagation(),o()},disabled:a,className:"inline-flex h-6 w-6 items-center justify-center rounded bg-background/85 text-destructive hover:bg-background focus:outline-none focus:ring-2 focus:ring-destructive","aria-label":"Remove file",title:"Remove file",children:d.jsx(ns,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),!m&&h&&d.jsx("p",{className:"sr-only",children:h})]})}const hk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,buttonResponses:c})=>{const{gridStretch:u}=Jo(),f=u&&Ks(e),l=e.properties,p=v.useRef(null),[g,m]=v.useState(!1),[h,y]=v.useState(),[S,w]=v.useState(()=>new Set),[A,x]=v.useState(0),F=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,N=qs(e),k=v.useMemo(()=>Ys(t),[t]),[T,P]=v.useState(null);v.useEffect(()=>{P(null)},[t,A]);const E=T??k,C=wc(E),I=e.validation?.find(re=>re.type==="fileSize"),W=e.validation?.find(re=>re.type==="fileType"),M=I?.value?I.value:l?.maxSize??F?.maxSize??10*1024*1024,z=W?.value?W.value:l?.accept??F?.accept??[],V=Array.isArray(z)?z.join(","):"",X=()=>{E.length>=N||p.current?.click()},L=v.useCallback(re=>{if(I){const ge=rn(re,I);if(ge!==!0)return typeof ge=="string"?ge:"File size exceeds the maximum allowed size"}else if(re.size>M)return`File size must be less than ${Fo(M)}`;if(W){const ge=rn(re,W);if(ge!==!0)return typeof ge=="string"?ge:"File type is not allowed"}return null},[I,W,M]),B=v.useCallback(re=>{const ge=Ja(re,N);r(ge),n?.()},[r,n,N]),D=v.useCallback(re=>{y(void 0);const ge=Array.from(re),Se=[...E];let pt=null;for(const Dt of ge){if(Se.length>=N)break;const Bt=L(Dt);if(Bt){pt||(pt=Bt);continue}Se.push(Dt)}if(pt&&Se.length===E.length){y(pt);return}pt&&y(pt),P(Se),B(Se)},[E,N,L,B]),K=v.useCallback(re=>{const ge=re.target.files;ge&&ge.length>0&&D(ge),p.current&&(p.current.value="")},[D]),ae=v.useCallback(re=>{if(s)return;const ge=E.filter((Se,pt)=>pt!==re);x(Se=>Se+1),P(ge),B(ge)},[s,E,B]),j=re=>{re.preventDefault(),m(!0)},U=()=>{m(!1)},le=re=>{re.preventDefault(),m(!1),re.dataTransfer.files?.length&&D(re.dataTransfer.files)},oe=o||h,G=[];(I||M)&&G.push(`Max size: ${Fo(M)}`),W&&z.length>0&&G.push(`Allowed types: ${z.join(", ")}`),N>1&&G.push(`Up to ${N} files`);const ie=e.appearance?.hideLabel??!1,Ce=v.useMemo(()=>{if(!c)return null;const re=Object.values(c);for(let ge=re.length-1;ge>=0;ge-=1){const Se=re[ge],pt=typeof Se?.status=="string"?Se.status.toLowerCase():null;if(pt&&pt!=="success")continue;const Dt=Se?.code;if(typeof Dt=="number"&&(Dt<200||Dt>=300))continue;const Bt=Se?.data,Pt=Bt?.file_url||Bt?.fileUrl||Se?.file_url||Se?.fileUrl;if(typeof Pt=="string"&&Pt.trim())return Pt}return null},[c]),ee=v.useCallback(re=>{window.open(re,"_blank","noopener,noreferrer")},[]),ne=v.useCallback(re=>{w(ge=>new Set(ge).add(re))},[]),he=E.length===0,Ie=E.length<N,Ue=yc(N,E.length);return d.jsx(At,{field:e,error:oe,isRequired:i,className:H(a,"!space-y-0"),hideLabel:ie,children:d.jsx("div",{className:H("min-h-[70px] min-w-0 w-full flex flex-col",f?"flex-1 h-full":"h-[70px]"),children:d.jsxs("div",{onClick:re=>{re.target.closest("[data-remove-in-dropzone]")||re.target.closest("[data-no-open-picker]")||X()},onDragOver:j,onDragLeave:U,onDrop:le,className:H("border-2 border-dashed rounded-lg p-1.5 text-center cursor-pointer transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",g&&"border-primary bg-primary/10",oe&&"border-destructive",s&&"opacity-50 cursor-not-allowed",!Ie&&E.length>0&&"cursor-default"),children:[d.jsx("input",{ref:p,id:ft(e),type:"file",accept:V,multiple:N>1,onChange:K,disabled:s||e.disabled||!Ie,className:"hidden","aria-describedby":Lt(e,!!oe),"aria-invalid":Jt(!!oe),"aria-required":i}),he?d.jsxs(d.Fragment,{children:[d.jsx(si,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),d.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:"Drag & drop or click"}),G.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:G.join(" • ")})]}):Ue?d.jsx(Sc,{item:E[0],objectUrl:C[0]??null,failedUrlKeys:S,onImageUrlError:ne,onRemove:()=>ae(0),onOpenUrl:ee,openTarget:E[0]instanceof File?Ce:void 0,disabled:s||e.disabled}):d.jsx(vc,{items:E,maxFiles:N,disabled:s,objectUrls:C,failedUrlKeys:S,onImageUrlError:ne,onRemove:ae,resolveOpenUrl:(re,ge)=>ge instanceof File&&E.length===1&&Ce?.trim()?Ce.trim():null,onOpenUrl:re=>{re?.trim()&&ee(re.trim())},addSlot:Ie?d.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:re=>{re.stopPropagation(),p.current?.click()},disabled:s||e.disabled,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center text-muted-foreground hover:border-primary hover:bg-primary/5 text-[10px] leading-tight px-0.5",children:[d.jsx(si,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})]})})})};function gk(e){const t=yk(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(vk);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function yk(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=Sk(o),a=wk(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var bk=Symbol("radix.slottable");function vk(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===bk}function wk(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function Sk(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var oa="Dialog",[Kh]=vr(oa),[xk,Xr]=Kh(oa),qh=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=b.useRef(null),c=b.useRef(null),[u,f]=ln({prop:n,defaultProp:o??!1,onChange:s,caller:oa});return d.jsx(xk,{scope:t,triggerRef:a,contentRef:c,contentId:hn(),titleId:hn(),descriptionId:hn(),open:u,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(l=>!l),[f]),modal:i,children:r})};qh.displayName=oa;var Yh="DialogTrigger",Ak=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(Yh,r),s=Qe(t,o.triggerRef);return d.jsx(je.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Cc(o.open),...n,ref:s,onClick:De(e.onClick,o.onOpenToggle)})});Ak.displayName=Yh;var xc="DialogPortal",[Ck,Xh]=Kh(xc,{forceMount:void 0}),Jh=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,s=Xr(xc,t);return d.jsx(Ck,{scope:t,forceMount:r,children:b.Children.map(n,i=>d.jsx(xr,{present:r||s.open,children:d.jsx(Ti,{asChild:!0,container:o,children:i})}))})};Jh.displayName=xc;var sa="DialogOverlay",Qh=b.forwardRef((e,t)=>{const r=Xh(sa,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Xr(sa,e.__scopeDialog);return s.modal?d.jsx(xr,{present:n||s.open,children:d.jsx(Nk,{...o,ref:t})}):null});Qh.displayName=sa;var Ek=gk("DialogOverlay.RemoveScroll"),Nk=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(sa,r);return d.jsx(Bi,{as:Ek,allowPinchZoom:!0,shards:[o.contentRef],children:d.jsx(je.div,{"data-state":Cc(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),no="DialogContent",Zh=b.forwardRef((e,t)=>{const r=Xh(no,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Xr(no,e.__scopeDialog);return d.jsx(xr,{present:n||s.open,children:s.modal?d.jsx(kk,{...o,ref:t}):d.jsx(_k,{...o,ref:t})})});Zh.displayName=no;var kk=b.forwardRef((e,t)=>{const r=Xr(no,e.__scopeDialog),n=b.useRef(null),o=Qe(t,r.contentRef,n);return b.useEffect(()=>{const s=n.current;if(s)return Gl(s)},[]),d.jsx(eg,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:De(e.onCloseAutoFocus,s=>{s.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:De(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:De(e.onFocusOutside,s=>s.preventDefault())})}),_k=b.forwardRef((e,t)=>{const r=Xr(no,e.__scopeDialog),n=b.useRef(!1),o=b.useRef(!1);return d.jsx(eg,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(n.current||r.triggerRef.current?.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;r.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),eg=b.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Xr(no,r),c=b.useRef(null),u=Qe(t,c);return kl(),d.jsxs(d.Fragment,{children:[d.jsx(yi,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(gi,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Cc(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(Fk,{titleId:a.titleId}),d.jsx(Ok,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Ac="DialogTitle",tg=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(Ac,r);return d.jsx(je.h2,{id:o.titleId,...n,ref:t})});tg.displayName=Ac;var rg="DialogDescription",Tk=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(rg,r);return d.jsx(je.p,{id:o.descriptionId,...n,ref:t})});Tk.displayName=rg;var ng="DialogClose",og=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(ng,r);return d.jsx(je.button,{type:"button",...n,ref:t,onClick:De(e.onClick,()=>o.onOpenChange(!1))})});og.displayName=ng;function Cc(e){return e?"open":"closed"}var sg="DialogTitleWarning",[gM,ig]=Q0(sg,{contentName:no,titleName:Ac,docsSlug:"dialog"}),Fk=({titleId:e})=>{const t=ig(sg),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
46
+ `)},jC=0,No=[];function zC(e){var t=b.useRef([]),r=b.useRef([0,0]),n=b.useRef(),o=b.useState(jC++)[0],s=b.useState(Rp)[0],i=b.useRef(e);b.useEffect(function(){i.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=aC([e.lockRef.current],(e.shards||[]).map(Qp),!0).filter(Boolean);return h.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=b.useCallback(function(h,y){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!i.current.allowPinchZoom;var S=ji(h),w=r.current,A="deltaX"in h?h.deltaX:w[0]-S[0],x="deltaY"in h?h.deltaY:w[1]-S[1],F,N=h.target,k=Math.abs(A)>Math.abs(x)?"h":"v";if("touches"in h&&k==="h"&&N.type==="range")return!1;var T=window.getSelection(),P=T&&T.anchorNode,E=P?P===N||P.contains(N):!1;if(E)return!1;var C=qp(k,N);if(!C)return!0;if(C?F=k:(F=k==="v"?"h":"v",C=qp(k,N)),!C)return!1;if(!n.current&&"changedTouches"in h&&(A||x)&&(n.current=F),!F)return!0;var I=n.current||F;return DC(I,y,h,I==="h"?A:x)},[]),c=b.useCallback(function(h){var y=h;if(!(!No.length||No[No.length-1]!==s)){var S="deltaY"in y?Jp(y):ji(y),w=t.current.filter(function(F){return F.name===y.type&&(F.target===y.target||y.target===F.shadowParent)&&BC(F.delta,S)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var A=(i.current.shards||[]).map(Qp).filter(Boolean).filter(function(F){return F.contains(y.target)}),x=A.length>0?a(y,A[0]):!i.current.noIsolation;x&&y.cancelable&&y.preventDefault()}}},[]),u=b.useCallback(function(h,y,S,w){var A={name:h,delta:y,target:S,should:w,shadowParent:UC(S)};t.current.push(A),setTimeout(function(){t.current=t.current.filter(function(x){return x!==A})},1)},[]),f=b.useCallback(function(h){r.current=ji(h),n.current=void 0},[]),l=b.useCallback(function(h){u(h.type,Jp(h),h.target,a(h,e.lockRef.current))},[]),p=b.useCallback(function(h){u(h.type,ji(h),h.target,a(h,e.lockRef.current))},[]);b.useEffect(function(){return No.push(s),e.setCallbacks({onScrollCapture:l,onWheelCapture:l,onTouchMoveCapture:p}),document.addEventListener("wheel",c,Eo),document.addEventListener("touchmove",c,Eo),document.addEventListener("touchstart",f,Eo),function(){No=No.filter(function(h){return h!==s}),document.removeEventListener("wheel",c,Eo),document.removeEventListener("touchmove",c,Eo),document.removeEventListener("touchstart",f,Eo)}},[]);var g=e.removeScrollBar,m=e.inert;return b.createElement(b.Fragment,null,m?b.createElement(s,{styles:$C(o)}):null,g?b.createElement(TC,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function UC(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const VC=gC(Wp,zC);var zi=b.forwardRef(function(e,t){return b.createElement(Bi,cn({},e,{ref:t,sideCar:VC}))});zi.classNames=Bi.classNames;var HC=[" ","Enter","ArrowUp","ArrowDown"],WC=[" ","Enter"],to="Select",[Ui,Vi,RC]=Cl(to),[ko]=vr(to,[RC,Pi]),Hi=Pi(),[GC,Dn]=ko(to),[KC,qC]=ko(to),Zp=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:f,autoComplete:l,disabled:p,required:g,form:m}=e,h=Hi(t),[y,S]=b.useState(null),[w,A]=b.useState(null),[x,F]=b.useState(!1),N=bo(u),[k,T]=ln({prop:n,defaultProp:o??!1,onChange:s,caller:to}),[P,E]=ln({prop:i,defaultProp:a,onChange:c,caller:to}),C=b.useRef(null),I=y?m||!!y.closest("form"):!0,[W,M]=b.useState(new Set),z=Array.from(W).map(V=>V.props.value).join(";");return d.jsx(Dp,{...h,children:d.jsxs(GC,{required:g,scope:t,trigger:y,onTriggerChange:S,valueNode:w,onValueNodeChange:A,valueNodeHasChildren:x,onValueNodeHasChildrenChange:F,contentId:hn(),value:P,onValueChange:E,open:k,onOpenChange:T,dir:N,triggerPointerDownPosRef:C,disabled:p,children:[d.jsx(Ui.Provider,{scope:t,children:d.jsx(KC,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(V=>{M(X=>new Set(X).add(V))},[]),onNativeOptionRemove:b.useCallback(V=>{M(X=>{const D=new Set(X);return D.delete(V),D})},[]),children:r})}),I?d.jsxs(Sm,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:l,value:P,onChange:V=>E(V.target.value),disabled:p,form:m,children:[P===void 0?d.jsx("option",{value:""}):null,Array.from(W)]},z):null]})})};Zp.displayName=to;var em="SelectTrigger",tm=b.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...o}=e,s=Hi(r),i=Dn(em,r),a=i.disabled||n,c=Qe(t,i.onTriggerChange),u=Vi(r),f=b.useRef("touch"),[l,p,g]=Am(h=>{const y=u().filter(A=>!A.disabled),S=y.find(A=>A.value===i.value),w=Cm(y,h,S);w!==void 0&&i.onValueChange(w.value)}),m=h=>{a||(i.onOpenChange(!0),g()),h&&(i.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return d.jsx(Wl,{asChild:!0,...s,children:d.jsx(je.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":xm(i.value)?"":void 0,...o,ref:c,onClick:De(o.onClick,h=>{h.currentTarget.focus(),f.current!=="mouse"&&m(h)}),onPointerDown:De(o.onPointerDown,h=>{f.current=h.pointerType;const y=h.target;y.hasPointerCapture(h.pointerId)&&y.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(m(h),h.preventDefault())}),onKeyDown:De(o.onKeyDown,h=>{const y=l.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&p(h.key),!(y&&h.key===" ")&&HC.includes(h.key)&&(m(),h.preventDefault())})})})});tm.displayName=em;var rm="SelectValue",nm=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,children:s,placeholder:i="",...a}=e,c=Dn(rm,r),{onValueNodeHasChildrenChange:u}=c,f=s!==void 0,l=Qe(t,c.onValueNodeChange);return tr(()=>{u(f)},[u,f]),d.jsx(je.span,{...a,ref:l,style:{pointerEvents:"none"},children:xm(c.value)?d.jsx(d.Fragment,{children:i}):s})});nm.displayName=rm;var YC="SelectIcon",om=b.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...o}=e;return d.jsx(je.span,{"aria-hidden":!0,...o,ref:t,children:n||"▼"})});om.displayName=YC;var XC="SelectPortal",sm=e=>d.jsx(Oi,{asChild:!0,...e});sm.displayName=XC;var ro="SelectContent",im=b.forwardRef((e,t)=>{const r=Dn(ro,e.__scopeSelect),[n,o]=b.useState();if(tr(()=>{o(new DocumentFragment)},[]),!r.open){const s=n;return s?Vs.createPortal(d.jsx(am,{scope:e.__scopeSelect,children:d.jsx(Ui.Slot,{scope:e.__scopeSelect,children:d.jsx("div",{children:e.children})})}),s):null}return d.jsx(lm,{...e,ref:t})});im.displayName=ro;var Yr=10,[am,Bn]=ko(ro),JC="SelectContentImpl",QC=KA("SelectContent.RemoveScroll"),lm=b.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:l,collisionBoundary:p,collisionPadding:g,sticky:m,hideWhenDetached:h,avoidCollisions:y,...S}=e,w=Dn(ro,r),[A,x]=b.useState(null),[F,N]=b.useState(null),k=Qe(t,G=>x(G)),[T,P]=b.useState(null),[E,C]=b.useState(null),I=Vi(r),[W,M]=b.useState(!1),z=b.useRef(!1);b.useEffect(()=>{if(A)return Gl(A)},[A]),kl();const V=b.useCallback(G=>{const[ae,...Ae]=I().map(he=>he.ref.current),[ee]=Ae.slice(-1),ne=document.activeElement;for(const he of G)if(he===ne||(he?.scrollIntoView({block:"nearest"}),he===ae&&F&&(F.scrollTop=0),he===ee&&F&&(F.scrollTop=F.scrollHeight),he?.focus(),document.activeElement!==ne))return},[I,F]),X=b.useCallback(()=>V([T,A]),[V,T,A]);b.useEffect(()=>{W&&X()},[W,X]);const{onOpenChange:D,triggerPointerDownPosRef:B}=w;b.useEffect(()=>{if(A){let G={x:0,y:0};const ae=ee=>{G={x:Math.abs(Math.round(ee.pageX)-(B.current?.x??0)),y:Math.abs(Math.round(ee.pageY)-(B.current?.y??0))}},Ae=ee=>{G.x<=10&&G.y<=10?ee.preventDefault():A.contains(ee.target)||D(!1),document.removeEventListener("pointermove",ae),B.current=null};return B.current!==null&&(document.addEventListener("pointermove",ae),document.addEventListener("pointerup",Ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ae),document.removeEventListener("pointerup",Ae,{capture:!0})}}},[A,D,B]),b.useEffect(()=>{const G=()=>D(!1);return window.addEventListener("blur",G),window.addEventListener("resize",G),()=>{window.removeEventListener("blur",G),window.removeEventListener("resize",G)}},[D]);const[L,K]=Am(G=>{const ae=I().filter(ne=>!ne.disabled),Ae=ae.find(ne=>ne.ref.current===document.activeElement),ee=Cm(ae,G,Ae);ee&&setTimeout(()=>ee.ref.current.focus())}),ie=b.useCallback((G,ae,Ae)=>{const ee=!z.current&&!Ae;(w.value!==void 0&&w.value===ae||ee)&&(P(G),ee&&(z.current=!0))},[w.value]),j=b.useCallback(()=>A?.focus(),[A]),U=b.useCallback((G,ae,Ae)=>{const ee=!z.current&&!Ae;(w.value!==void 0&&w.value===ae||ee)&&C(G)},[w.value]),le=n==="popper"?Jl:cm,oe=le===Jl?{side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:l,collisionBoundary:p,collisionPadding:g,sticky:m,hideWhenDetached:h,avoidCollisions:y}:{};return d.jsx(am,{scope:r,content:A,viewport:F,onViewportChange:N,itemRefCallback:ie,selectedItem:T,onItemLeave:j,itemTextRefCallback:U,focusSelectedItem:X,selectedItemText:E,position:n,isPositioned:W,searchRef:L,children:d.jsx(zi,{as:QC,allowPinchZoom:!0,children:d.jsx(wi,{asChild:!0,trapped:w.open,onMountAutoFocus:G=>{G.preventDefault()},onUnmountAutoFocus:De(o,G=>{w.trigger?.focus({preventScroll:!0}),G.preventDefault()}),children:d.jsx(vi,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:G=>G.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:d.jsx(le,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:G=>G.preventDefault(),...S,...oe,onPlaced:()=>M(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:De(S.onKeyDown,G=>{const ae=G.ctrlKey||G.altKey||G.metaKey;if(G.key==="Tab"&&G.preventDefault(),!ae&&G.key.length===1&&K(G.key),["ArrowUp","ArrowDown","Home","End"].includes(G.key)){let ee=I().filter(ne=>!ne.disabled).map(ne=>ne.ref.current);if(["ArrowUp","End"].includes(G.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(G.key)){const ne=G.target,he=ee.indexOf(ne);ee=ee.slice(he+1)}setTimeout(()=>V(ee)),G.preventDefault()}})})})})})})});lm.displayName=JC;var ZC="SelectItemAlignedPosition",cm=b.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...o}=e,s=Dn(ro,r),i=Bn(ro,r),[a,c]=b.useState(null),[u,f]=b.useState(null),l=Qe(t,k=>f(k)),p=Vi(r),g=b.useRef(!1),m=b.useRef(!0),{viewport:h,selectedItem:y,selectedItemText:S,focusSelectedItem:w}=i,A=b.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&h&&y&&S){const k=s.trigger.getBoundingClientRect(),T=u.getBoundingClientRect(),P=s.valueNode.getBoundingClientRect(),E=S.getBoundingClientRect();if(s.dir!=="rtl"){const ne=E.left-T.left,he=P.left-ne,Ie=k.left-he,Ue=k.width+Ie,re=Math.max(Ue,T.width),ge=window.innerWidth-Yr,Se=us(he,[Yr,Math.max(Yr,ge-re)]);a.style.minWidth=Ue+"px",a.style.left=Se+"px"}else{const ne=T.right-E.right,he=window.innerWidth-P.right-ne,Ie=window.innerWidth-k.right-he,Ue=k.width+Ie,re=Math.max(Ue,T.width),ge=window.innerWidth-Yr,Se=us(he,[Yr,Math.max(Yr,ge-re)]);a.style.minWidth=Ue+"px",a.style.right=Se+"px"}const C=p(),I=window.innerHeight-Yr*2,W=h.scrollHeight,M=window.getComputedStyle(u),z=parseInt(M.borderTopWidth,10),V=parseInt(M.paddingTop,10),X=parseInt(M.borderBottomWidth,10),D=parseInt(M.paddingBottom,10),B=z+V+W+D+X,L=Math.min(y.offsetHeight*5,B),K=window.getComputedStyle(h),ie=parseInt(K.paddingTop,10),j=parseInt(K.paddingBottom,10),U=k.top+k.height/2-Yr,le=I-U,oe=y.offsetHeight/2,G=y.offsetTop+oe,ae=z+V+G,Ae=B-ae;if(ae<=U){const ne=C.length>0&&y===C[C.length-1].ref.current;a.style.bottom="0px";const he=u.clientHeight-h.offsetTop-h.offsetHeight,Ie=Math.max(le,oe+(ne?j:0)+he+X),Ue=ae+Ie;a.style.height=Ue+"px"}else{const ne=C.length>0&&y===C[0].ref.current;a.style.top="0px";const Ie=Math.max(U,z+h.offsetTop+(ne?ie:0)+oe)+Ae;a.style.height=Ie+"px",h.scrollTop=ae-U+h.offsetTop}a.style.margin=`${Yr}px 0`,a.style.minHeight=L+"px",a.style.maxHeight=I+"px",n?.(),requestAnimationFrame(()=>g.current=!0)}},[p,s.trigger,s.valueNode,a,u,h,y,S,s.dir,n]);tr(()=>A(),[A]);const[x,F]=b.useState();tr(()=>{u&&F(window.getComputedStyle(u).zIndex)},[u]);const N=b.useCallback(k=>{k&&m.current===!0&&(A(),w?.(),m.current=!1)},[A,w]);return d.jsx(tE,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:g,onScrollButtonChange:N,children:d.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:x},children:d.jsx(je.div,{...o,ref:l,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});cm.displayName=ZC;var eE="SelectPopperPosition",Jl=b.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:o=Yr,...s}=e,i=Hi(r);return d.jsx(Bp,{...i,...s,ref:t,align:n,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Jl.displayName=eE;var[tE,Ql]=ko(ro,{}),Zl="SelectViewport",dm=b.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...o}=e,s=Bn(Zl,r),i=Ql(Zl,r),a=Qe(t,s.onViewportChange),c=b.useRef(0);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),d.jsx(Ui.Slot,{scope:r,children:d.jsx(je.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:De(o.onScroll,u=>{const f=u.currentTarget,{contentWrapper:l,shouldExpandOnScrollRef:p}=i;if(p?.current&&l){const g=Math.abs(c.current-f.scrollTop);if(g>0){const m=window.innerHeight-Yr*2,h=parseFloat(l.style.minHeight),y=parseFloat(l.style.height),S=Math.max(h,y);if(S<m){const w=S+g,A=Math.min(m,w),x=w-A;l.style.height=A+"px",l.style.bottom==="0px"&&(f.scrollTop=x>0?x:0,l.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})});dm.displayName=Zl;var um="SelectGroup",[rE,nE]=ko(um),oE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=hn();return d.jsx(rE,{scope:r,id:o,children:d.jsx(je.div,{role:"group","aria-labelledby":o,...n,ref:t})})});oE.displayName=um;var fm="SelectLabel",sE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=nE(fm,r);return d.jsx(je.div,{id:o.id,...n,ref:t})});sE.displayName=fm;var Wi="SelectItem",[iE,pm]=ko(Wi),mm=b.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:o=!1,textValue:s,...i}=e,a=Dn(Wi,r),c=Bn(Wi,r),u=a.value===n,[f,l]=b.useState(s??""),[p,g]=b.useState(!1),m=Qe(t,w=>c.itemRefCallback?.(w,n,o)),h=hn(),y=b.useRef("touch"),S=()=>{o||(a.onValueChange(n),a.onOpenChange(!1))};if(n==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d.jsx(iE,{scope:r,value:n,disabled:o,textId:h,isSelected:u,onItemTextChange:b.useCallback(w=>{l(A=>A||(w?.textContent??"").trim())},[]),children:d.jsx(Ui.ItemSlot,{scope:r,value:n,disabled:o,textValue:f,children:d.jsx(je.div,{role:"option","aria-labelledby":h,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:m,onFocus:De(i.onFocus,()=>g(!0)),onBlur:De(i.onBlur,()=>g(!1)),onClick:De(i.onClick,()=>{y.current!=="mouse"&&S()}),onPointerUp:De(i.onPointerUp,()=>{y.current==="mouse"&&S()}),onPointerDown:De(i.onPointerDown,w=>{y.current=w.pointerType}),onPointerMove:De(i.onPointerMove,w=>{y.current=w.pointerType,o?c.onItemLeave?.():y.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:De(i.onPointerLeave,w=>{w.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:De(i.onKeyDown,w=>{c.searchRef?.current!==""&&w.key===" "||(WC.includes(w.key)&&S(),w.key===" "&&w.preventDefault())})})})})});mm.displayName=Wi;var gs="SelectItemText",hm=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,...s}=e,i=Dn(gs,r),a=Bn(gs,r),c=pm(gs,r),u=qC(gs,r),[f,l]=b.useState(null),p=Qe(t,S=>l(S),c.onItemTextChange,S=>a.itemTextRefCallback?.(S,c.value,c.disabled)),g=f?.textContent,m=b.useMemo(()=>d.jsx("option",{value:c.value,disabled:c.disabled,children:g},c.value),[c.disabled,c.value,g]),{onNativeOptionAdd:h,onNativeOptionRemove:y}=u;return tr(()=>(h(m),()=>y(m)),[h,y,m]),d.jsxs(d.Fragment,{children:[d.jsx(je.span,{id:c.textId,...s,ref:p}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Vs.createPortal(s.children,i.valueNode):null]})});hm.displayName=gs;var gm="SelectItemIndicator",ym=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return pm(gm,r).isSelected?d.jsx(je.span,{"aria-hidden":!0,...n,ref:t}):null});ym.displayName=gm;var ec="SelectScrollUpButton",bm=b.forwardRef((e,t)=>{const r=Bn(ec,e.__scopeSelect),n=Ql(ec,e.__scopeSelect),[o,s]=b.useState(!1),i=Qe(t,n.onScrollButtonChange);return tr(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=r.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?d.jsx(wm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=r;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});bm.displayName=ec;var tc="SelectScrollDownButton",vm=b.forwardRef((e,t)=>{const r=Bn(tc,e.__scopeSelect),n=Ql(tc,e.__scopeSelect),[o,s]=b.useState(!1),i=Qe(t,n.onScrollButtonChange);return tr(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,f=Math.ceil(c.scrollTop)<u;s(f)};const c=r.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?d.jsx(wm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=r;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});vm.displayName=tc;var wm=b.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...o}=e,s=Bn("SelectScrollButton",r),i=b.useRef(null),a=Vi(r),c=b.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return b.useEffect(()=>()=>c(),[c]),tr(()=>{a().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),d.jsx(je.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:De(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(n,50))}),onPointerMove:De(o.onPointerMove,()=>{s.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(n,50))}),onPointerLeave:De(o.onPointerLeave,()=>{c()})})}),aE="SelectSeparator",lE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return d.jsx(je.div,{"aria-hidden":!0,...n,ref:t})});lE.displayName=aE;var rc="SelectArrow",cE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=Hi(r),s=Dn(rc,r),i=Bn(rc,r);return s.open&&i.position==="popper"?d.jsx($p,{...o,...n,ref:t}):null});cE.displayName=rc;var dE="SelectBubbleInput",Sm=b.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const o=b.useRef(null),s=Qe(n,o),i=hs(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&f){const l=new Event("change",{bubbles:!0});f.call(a,t),a.dispatchEvent(l)}},[i,t]),d.jsx(je.select,{...r,style:{...jp,...r.style},ref:s,defaultValue:t})});Sm.displayName=dE;function xm(e){return e===""||e===void 0}function Am(e){const t=cr(e),r=b.useRef(""),n=b.useRef(0),o=b.useCallback(i=>{const a=r.current+i;t(a),(function c(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>c(""),1e3))})(a)},[t]),s=b.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,o,s]}function Cm(e,t,r){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=r?e.indexOf(r):-1;let i=uE(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==r));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==r?c:void 0}function uE(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var fE=Zp,pE=tm,mE=nm,hE=om,gE=sm,yE=im,bE=dm,vE=mm,wE=hm,SE=ym,xE=bm,AE=vm;function CE({...e}){return d.jsx(fE,{"data-slot":"select",...e})}function EE({className:e,...t}){return d.jsx(mE,{"data-slot":"select-value",className:H("truncate min-w-0",e),...t})}function NE({className:e,size:t="default",children:r,...n}){const o=e?.includes("w-full");return d.jsxs(pE,{"data-slot":"select-trigger","data-size":t,className:H("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",o&&"min-w-0",e),...n,children:[r,d.jsx(hE,{asChild:!0,children:d.jsx(ts,{className:"size-4 opacity-50"})})]})}function kE({className:e,children:t,position:r="popper",...n}){return d.jsx(gE,{children:d.jsxs(yE,{"data-slot":"select-content",className:H("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...n,children:[d.jsx(_E,{}),d.jsx(bE,{className:H("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),d.jsx(TE,{})]})})}function nc({className:e,children:t,...r}){return d.jsxs(vE,{"data-slot":"select-item",className:H("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...r,children:[d.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:d.jsx(SE,{children:d.jsx(ai,{className:"size-4"})})}),d.jsx(wE,{className:"truncate",children:t})]})}function _E({className:e,...t}){return d.jsx(xE,{"data-slot":"select-scroll-up-button",className:H("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(rS,{className:"size-4"})})}function TE({className:e,...t}){return d.jsx(AE,{"data-slot":"select-scroll-down-button",className:H("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(ts,{className:"size-4"})})}function Ut(e,t){if(!t||t.trim()===""||e==null)return;const r=t.split(".").filter(Boolean);let n=e;for(const o of r){if(n==null)return;n=n[o]}return n}function Em(e){const t={array:[],pathPrefixToStrip:""};function r(a,c){if(a===null||typeof a!="object")return null;if(Array.isArray(a)&&a.length>0)return{array:a,fullPath:c};const u=Object.keys(a);for(const f of u){const l=a[f],p=c?`${c}.${f}`:f;if(Array.isArray(l)&&l.length>0)return{array:l,fullPath:p};if(l!==null&&typeof l=="object"){const g=r(l,p);if(g)return g}}return null}const n=r(e,"");if(!n)return t;const{array:o,fullPath:s}=n,i=s?`data.${s}.`:"";return{array:o,pathPrefixToStrip:i}}function FE(e){return e.length>=4&&Array.isArray(e[3])&&e[3].length===0}function PE(e,t,r){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"){const s=String(e);return{label:s,value:s,disabled:!1}}if(e==null)return{label:"",value:"",disabled:!0};if(typeof e!="object"||Array.isArray(e)){const s=Array.isArray(e)?"":String(e);return{label:s,value:s,disabled:!1}}let n,o;if(t){const s=t.includes(".")?Ut(e,t):e[t];n=String(s!==void 0?s:e.label??e.name??e.title??e.text??e.username??e.email??e.value??e.id??"")}else n=String(e.label??e.name??e.title??e.text??e.username??e.email??e.value??e.id??"");if(r){const s=r.includes(".")?Ut(e,r):e[r];o=String(s!==void 0?s:e.value??e.id??e.key??e.email??e.username??e.label??e.name??"")}else o=String(e.value??e.id??e.key??e.email??e.username??e.label??e.name??"");return{label:String(n??""),value:String(o??""),disabled:!!e.disabled}}function ys(e,t,r){if(!e)return[];if(Array.isArray(e)){if(e.length===0)return[];if(FE(e))return[];const n=e.filter(o=>o!=null);return n.length===0?[]:n.every(o=>typeof o=="string")?n.map(o=>({label:o,value:o,disabled:!1})):n.map(o=>PE(o,t,r))}if(typeof e=="object"){const{array:n,pathPrefixToStrip:o}=Em(e);if(Array.isArray(n)&&n.length>0){const s=c=>!c||!c.trim()||!o?c:c.startsWith(o)?c.substring(o.length).replace(/^\.+/,"")||void 0:c,i=s(t),a=s(r);return ys(n,i,a)}}return[]}function OE(e){return!Array.isArray(e)||e.length===0?[]:e.filter(t=>t!=null).map((t,r)=>{if(typeof t=="string")return{label:t,value:t};if(typeof t=="object"&&t!==null){const n=t.label||t.value||String(t),o=t.value||t.label||String(t);return!n&&!o?{label:`Option ${r+1}`,value:String(r)}:{label:String(n),value:String(o),disabled:t.disabled||!1}}return{label:String(t),value:String(t)}})}function IE(e){return Array.isArray(e)&&e.length>=4&&Array.isArray(e[3])&&e[3].length>0&&Array.isArray(e[3][0])}function ME(e,t,r){if(!e)return[];try{const o=new URL(e).searchParams.get(t);return o?o.split(r).map(s=>s.trim()).filter(Boolean):[]}catch{const n=e.indexOf("?");if(n<0)return[];const o=e.slice(n+1);try{const i=new URLSearchParams(o).get(t);return i?i.split(r).map(a=>a.trim()).filter(Boolean):[]}catch{return[]}}}function Nm(e){const{response:t,sourceUrl:r,rowsIndex:n,rowsPath:o,columns:s,columnsQueryParam:i="sf",columnsQueryParamSeparator:a=","}=e;let c;if(o&&o.trim()?c=Ut(t,o):typeof n=="number"?c=t?.[n]:c=t,!Array.isArray(c)||c.length===0)return[];const u=c.filter(p=>Array.isArray(p));if(u.length===0)return Array.isArray(c[0])?[]:null;if(!Array.isArray(u[0]))return null;const f=ME(r,i,a),l=f.length>0?f:Array.isArray(s)&&s.length>0?s:[];return u.map(p=>{const g={};return(l.length>0?l:Array.from({length:p.length},(h,y)=>`col${y}`)).forEach((h,y)=>{g[h]=p[y]}),g})}function LE(e){const{rows:t,apiLabelField:r,apiLabelFields:n,apiLabelSeparator:o,apiValueField:s}=e;if(!Array.isArray(t)||t.length===0)return[];const i=t.filter(l=>l!=null&&typeof l=="object"&&!Array.isArray(l));if(i.length===0)return[];const a=Array.isArray(n)?n.filter(Boolean):[],c=o??" - ",u=l=>{if(r){const p=r.includes(".")?Ut(l,r):l?.[r];if(p!=null&&String(p).trim()!=="")return String(p)}return String(l?.label??l?.name??l?.title??l?.text??l?.username??l?.email??l?.value??l?.id??l)},f=(l,p)=>{if(s){const g=s.includes(".")?Ut(l,s):l?.[s];if(g!=null)return String(g)}return String(l?.value??l?.id??l?.key??l?.email??l?.username??l?.label??l?.name??p??l)};return i.map(l=>{let p="";a.length>0&&(p=a.map(h=>Ut(l,h)).filter(h=>h!=null&&String(h).trim()!=="").map(h=>String(h)).join(c)),p||(p=u(l));const g=f(l,p);return{label:typeof p=="string"?p:String(p??""),value:typeof g=="string"?g:String(g??""),disabled:!!l?.disabled}})}function km(e){return e!=null&&!Array.isArray(e)&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean")}function DE(e,t){const{array:r,pathPrefixToStrip:n}=Em(e);if(!Array.isArray(r)||r.length===0)return null;const o=new Set([t]);n&&t.startsWith(n)&&o.add(t.slice(n.length).replace(/^\.+/,""));const s=t.match(/^data\.data\.(.+)$/);s?.[1]&&o.add(s[1]);const i=r[0];for(const a of o){if(!a)continue;const c=a.includes(".")?Ut(i,a):i?.[a];if(km(c))return String(c)}return null}function BE(e,t,r){if(e==null)return null;const n=t?.trim(),o=r?.trim()||n;if(!n&&!o)return null;if(n){const i=Ut(e,n);if(km(i))return String(i);const a=DE(e,n);if(a!=null)return a}const s=ys(e,o,n||o);if(s.length>0){const i=s[0].value;if(i!=null&&String(i).trim()!=="")return String(i)}return null}function $E(e){if(e?.token!=null&&String(e.token).trim()!=="")return String(e.token);const t=ds(),r=t?.Authorization??t?.authorization;if(r?.trim()){const n=r.match(/^Bearer\s+(.+)$/i);return n?n[1]:r}}function _m(e,t){const r=$E(t);if(!r)return e;let n=e.replace(/\{token\}/g,r);return n=n.replace(/\{authorization\}/gi,()=>r.startsWith("Bearer ")?r:`Bearer ${r}`),n}function vn(e,t){const r={},{formValues:n={},submissionContext:o,apiRealtime:s}=t;for(const{key:i,value:a}of e??[]){const c=i?.trim();if(!c||a==null)continue;let u=nl(String(a),n,o,s);u=_m(u,o),r[c]=u}return r}const jE=new Set(["authorization"]);function zE(e){return jE.has(e.trim().toLowerCase())}function bs(e){return(e??[]).filter(t=>!zE(t.key))}function vs(e){if(!e?.length)return null;const t=e.find(r=>r.key.toLowerCase()==="authorization");if(t?.value?.trim()){const r=t.value.trim();if(r.toLowerCase().startsWith("basic ")){const n=r.slice(6).trim();if(n.includes("{")||n.includes("}")){const o=n.split(":");if(o.length>=2)return{type:"basic",username:o[0].trim(),password:o.slice(1).join(":").trim()}}try{const o=atob(n),s=o.indexOf(":");if(s>=0)return{type:"basic",username:o.slice(0,s),password:o.slice(s+1)}}catch{return{type:"basic",username:"",password:""}}}return r.toLowerCase().startsWith("bearer ")?{type:"bearer",token:r.slice(7).trim()}:{type:"bearer",token:r}}return null}function UE(e){return!e||e.type==="none"?{type:"none"}:e.type==="bearer"?{type:"bearer",token:e.token?.trim()??""}:e.type==="apiKey"?{type:"apiKey",headerName:e.headerName?.trim()||"X-API-Key",apiKey:e.apiKey?.trim()??""}:{type:"basic",username:e.username?.trim()??"",password:e.password?.trim()??""}}function Ri(e,t){const{formValues:r={},submissionContext:n,urlParams:o={},apiRealtime:s}=t;let i=Rr(e,r,o,n);return i=_m(i,n),s!==void 0&&(i=nl(i,r,n,s)),i}function ws(e,t={}){const r=UE(e),n={};if(r.type==="bearer"){const o=r.token??"";if(!o.trim())return n;const s=Ri(o,t).trim();return s&&(n.Authorization=s.toLowerCase().startsWith("bearer ")?s:`Bearer ${s}`),n}if(r.type==="apiKey"){const o=r.apiKey??"";return o.trim()&&(n[r.headerName||"X-API-Key"]=Ri(o,t)),n}if(r.type==="basic"){const o=r.username??"",s=r.password??"";if(!o.trim()&&!s.trim())return n;const i=Ri(o,t),a=Ri(s,t);n.Authorization=`Basic ${btoa(`${i}:${a}`)}`}return n}function VE(e,t={}){const r=e.apiAuth??vs(e.apiHeaders)??{type:"none"},n=ws(r,t);return Object.assign(n,vn(bs(e.apiHeaders),t)),n}function Tm({field:e,formValues:t={},submissionContext:r}){const n=e.properties,o=n?.apiEndpoint?{apiEndpoint:n.apiEndpoint,apiMethod:n.apiMethod,apiKey:n.apiKey,apiRealtime:n.apiRealtime,apiAutoDetect:n.apiAutoDetect,apiLabelField:n.apiLabelField,apiValueField:n.apiValueField,apiQueryParams:n.apiQueryParams,apiClientFilter:n.apiClientFilter,apiHeaders:n.apiHeaders,apiBodyFields:n.apiBodyFields,apiAuth:n.apiAuth,valueSource:n.valueSource,optionsSource:n.optionsSource}:null,s=e.apidata||null,i=o||s,[a,c]=v.useState([]),[u,f]=v.useState([]),[l,p]=v.useState([]),[g,m]=v.useState(!1),[h,y]=v.useState(null),S=!!(i?.apiEndpoint&&(i?.valueSource==="api"||i?.optionsSource==="api"||n?.valueSource==="api"||n?.optionsSource==="api")),w=e.options||n?.options||[],A=v.useMemo(()=>OE(Array.isArray(w)?w:[]),[w]),x=v.useMemo(()=>{const E=i?.apiEndpoint||n?.apiEndpoint||"",C=i?.apiQueryParams||n?.apiQueryParams;return po(E,C)},[i?.apiEndpoint,n?.apiEndpoint,i?.apiQueryParams,n?.apiQueryParams]),F=v.useMemo(()=>{const E=new Set;for(const I of n?.dependentFields??[])typeof I=="string"&&I.trim()&&E.add(I.trim());const C=i?.apiClientFilter?.matchField?.trim()||n?.apiClientFilter?.matchField?.trim();return C&&E.add(C),[...E]},[n?.dependentFields,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField]),N=v.useMemo(()=>{const E=new Set([...x,...F]);if(E.size===0)return null;const C={};return E.forEach(I=>{C[I]=t[I]}),JSON.stringify(C)},[x,F,t]),k=v.useMemo(()=>JSON.stringify(r||{}),[r]),T=v.useMemo(()=>{const E=new Set;e.name?.trim()&&E.add(e.name.trim());const C=e.key;return typeof C=="string"&&C.trim()&&E.add(C.trim()),[...E]},[e.name,e.key]);return v.useEffect(()=>{const E=i?.apiEndpoint;if(!S||!E){c([]);return}let C=!1;return(async()=>{a.length===0&&m(!0),y(null);try{const M=i?.apiMethod||n?.apiMethod||"GET",z=i?.apiRealtime||n?.apiRealtime,V=i?.apiQueryParams||n?.apiQueryParams||{},X=ti({apiEndpoint:E,apiMethod:M,apiQueryParams:V,formValues:t,submissionContext:r,apiRealtime:z,additionalRequiredFieldNames:F,excludeFormFieldNames:T});if(X.blocked){C||(c([]),m(!1));return}const D={"Content-Type":"application/json"},B=i?.apiKey||n?.apiKey;B&&(D["X-CSCAPI-KEY"]=B);const L=i?.apiAuth??n?.apiAuth??s?.apiAuth??vs(i?.apiHeaders??n?.apiHeaders??s?.apiHeaders)??{type:"none"},K=ws(L,{formValues:t,submissionContext:r,apiRealtime:z});Object.assign(D,K);const ie=i?.apiHeaders??n?.apiHeaders??s?.apiHeaders,j=i?.apiBodyFields??n?.apiBodyFields??s?.apiBodyFields,U=vn(bs(ie),{formValues:t,submissionContext:r,apiRealtime:z});Object.assign(D,U);const le=vn(j,{formValues:t,submissionContext:r,apiRealtime:z}),oe={method:M.toLowerCase(),url:Mr(X.url),headers:D};(X.postBodyBase!=null||Object.keys(le).length>0)&&(oe.data={...X.postBodyBase??{},...le});const G=await Ct(oe),ae=i?.apiLabelField||n?.apiLabelField,Ae=i?.apiValueField||n?.apiValueField,ee=G.data;let ne=[];Array.isArray(ee)?ne=ee:ee?.data&&(Array.isArray(ee.data)?ne=ee.data:ee.data?.data&&Array.isArray(ee.data.data)?ne=ee.data.data:ee.data.districts?ne=ee.data.districts:ee.data.states?ne=ee.data.states:ee.data.cities&&(ne=ee.data.cities)),p(ne);const he=ys(G.data,ae,Ae);f(he);const Ie=i?.apiClientFilter||n?.apiClientFilter;let Ue=he;if(Ie?.filterField&&Ie?.matchField){const re=t[Ie.matchField];re!=null?Ue=he.filter(ge=>{const Se=ne.find(Dt=>String(Ut(Dt,Ae||"code"))===String(ge.value));if(!Se)return!1;const pt=Ut(Se,Ie.filterField);return String(pt)===String(re)}):Ue=[]}C||c(Ue)}catch(M){if(C)return;let z="Failed to load options";if(M.response){const V=M.response.data;M.response.status===404?z="API endpoint not found.":M.response.status===401?z="Authentication failed.":typeof V=="string"?z=V:V&&typeof V=="object"&&(z=V.error||V.message||V.detail||z)}else M.message&&(z=String(M.message));y(z),a.length===0&&c([])}finally{C||m(!1)}})(),()=>{C=!0}},[S,i?.apiEndpoint,i?.apiMethod,n?.apiEndpoint,n?.apiMethod,N,F,T,k]),v.useEffect(()=>{const E=i?.apiClientFilter||n?.apiClientFilter;if(!S||!E||l.length===0)return;const C=t[E.matchField],I=i?.apiValueField||n?.apiValueField;if(C==null){c([]);return}const W=u.filter(M=>{const z=l.find(X=>String(Ut(X,I||"code"))===String(M.value));if(!z)return!1;const V=Ut(z,E.filterField);return String(V)===String(C)});c(W)},[S,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField,i?.apiClientFilter?.filterField,n?.apiClientFilter?.filterField,i?.apiValueField,n?.apiValueField,t[i?.apiClientFilter?.matchField||n?.apiClientFilter?.matchField||""],u,l]),{options:S?a:A,isLoadingOptions:g,optionsError:h}}const Fm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,formValues:c={},submissionContext:u,excludedOptionValues:f,isPrepopulateTarget:l=!1})=>{const p=e.properties,g=p?.apiEndpoint?{apiEndpoint:p.apiEndpoint,valueSource:p.valueSource,optionsSource:p.optionsSource}:null,m=e.apidata||null,h=g||m,y=!!(h?.apiEndpoint&&(h?.valueSource==="api"||h?.optionsSource==="api"||p?.valueSource==="api"||p?.optionsSource==="api")),{options:S,isLoadingOptions:w,optionsError:A}=Tm({field:e,formValues:c,submissionContext:u}),x=f?.length?new Set(f.map(String)):null,F=x?S.filter(L=>!x.has(String(L.value??L.label??""))):S,N="__clear__",k=t!=null&&String(t).trim()!=="",T=k?F.some(L=>String(L.value??L.label??"")===String(t)):!1,P=v.useMemo(()=>{if(!k||T)return F;const L=String(t);return[{label:L,value:L},...F]},[F,k,T,t]),E=k?String(t):void 0,C=`${ft(e)}-${E??"empty"}`,I=v.useCallback(L=>{r(L===N?"":L),n?.()},[r,n]),W=e.appearance?.size||"md",M={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},z=e.placeholder||"Select an option",V=p?.apiClientFilter?.matchField?.trim()||h?.apiClientFilter?.matchField?.trim(),X=y&&V&&(c[V]===void 0||c[V]===null||c[V]===""),D=w?"Loading options...":X?`Select ${V} first`:f?.length?"No available options":y?"No options available from API":"No options available";return y&&l&&w?d.jsx(At,{field:e,error:o||A||void 0,isRequired:i,className:a,children:d.jsxs("div",{role:"status","aria-label":"Loading options",className:H("flex items-center justify-center gap-2 w-full min-w-0 rounded-md border border-input bg-muted/50 text-muted-foreground",M[W],e.appearance?.className),children:[d.jsx(mo,{className:"h-4 w-4 animate-spin shrink-0"}),d.jsx("span",{className:"truncate",children:"Loading..."})]})}):d.jsx(At,{field:e,error:o||A||void 0,isRequired:i,className:a,children:d.jsxs(CE,{value:E,onValueChange:I,disabled:s||e.disabled||w&&F.length===0,children:[d.jsx(NE,{id:ft(e),"aria-describedby":Lt(e,!!o||!!A),"aria-invalid":Jt(!!o||!!A),"aria-required":i,className:H("w-full min-w-0",M[W],o&&"border-destructive focus-visible:ring-destructive",A&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:d.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[w&&d.jsx(mo,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"}),F.length===0&&f?.length&&!k?d.jsx("span",{className:"text-muted-foreground truncate",children:"No available options"}):k?d.jsx(EE,{placeholder:z}):d.jsx("span",{className:"text-muted-foreground truncate",children:z})]})}),d.jsx(kE,{children:P.length===0?d.jsx(nc,{value:"__no_options__",disabled:!0,children:D}):d.jsxs(d.Fragment,{children:[k?d.jsx(nc,{value:N,children:z}):null,P.map((L,K)=>{const ie=String(L.value??L.label??K);if(ie===N)return null;const j=L.label||L.value||String(L);return d.jsx(nc,{value:ie,disabled:L.disabled||!1,children:j},ie)})]})})]},C)})},Pm=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Om=Fd,Im=(e,t)=>r=>{var n;if(t?.variants==null)return Om(e,r?.class,r?.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(u=>{const f=r?.[u],l=s?.[u];if(f===null)return null;const p=Pm(f)||Pm(l);return o[u][p]}),a=r&&Object.entries(r).reduce((u,f)=>{let[l,p]=f;return p===void 0||(u[l]=p),u},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,f)=>{let{class:l,className:p,...g}=f;return Object.entries(g).every(m=>{let[h,y]=m;return Array.isArray(y)?y.includes({...s,...a}[h]):{...s,...a}[h]===y})?[...u,l,p]:u},[]);return Om(e,i,c,r?.class,r?.className)},HE=Im("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all cursor-pointer disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function Zt({className:e,variant:t,size:r,asChild:n=!1,...o}){const s=n?$u:"button";return d.jsx(s,{"data-slot":"button",className:H(HE({variant:t,size:r,className:e})),...o})}function WE(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var xr=e=>{const{present:t,children:r}=e,n=RE(t),o=typeof r=="function"?r({present:n.isPresent}):b.Children.only(r),s=Qe(n.ref,GE(o));return typeof r=="function"||n.isPresent?b.cloneElement(o,{ref:s}):null};xr.displayName="Presence";function RE(e){const[t,r]=b.useState(),n=b.useRef(null),o=b.useRef(e),s=b.useRef("none"),i=e?"mounted":"unmounted",[a,c]=WE(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const u=Gi(n.current);s.current=a==="mounted"?u:"none"},[a]),tr(()=>{const u=n.current,f=o.current;if(f!==e){const p=s.current,g=Gi(u);e?c("MOUNT"):g==="none"||u?.display==="none"?c("UNMOUNT"):c(f&&p!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),tr(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,l=g=>{const h=Gi(n.current).includes(CSS.escape(g.animationName));if(g.target===t&&h&&(c("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=g=>{g.target===t&&(s.current=Gi(n.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",l),t.addEventListener("animationend",l),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",l),t.removeEventListener("animationend",l)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:b.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function Gi(e){return e?.animationName||"none"}function GE(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function KE(e){const t=qE(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(XE);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function qE(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=QE(o),a=JE(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var YE=Symbol("radix.slottable");function XE(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===YE}function JE(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function QE(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Ki="Popover",[Mm]=vr(Ki,[Pi]),Ss=Pi(),[ZE,$n]=Mm(Ki),Lm=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=Ss(t),c=b.useRef(null),[u,f]=b.useState(!1),[l,p]=ln({prop:n,defaultProp:o??!1,onChange:s,caller:Ki});return d.jsx(Dp,{...a,children:d.jsx(ZE,{scope:t,contentId:hn(),triggerRef:c,open:l,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(g=>!g),[p]),hasCustomAnchor:u,onCustomAnchorAdd:b.useCallback(()=>f(!0),[]),onCustomAnchorRemove:b.useCallback(()=>f(!1),[]),modal:i,children:r})})};Lm.displayName=Ki;var Dm="PopoverAnchor",Bm=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(Dm,r),s=Ss(r),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return b.useEffect(()=>(i(),()=>a()),[i,a]),d.jsx(Wl,{...s,...n,ref:t})});Bm.displayName=Dm;var $m="PopoverTrigger",jm=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n($m,r),s=Ss(r),i=Qe(t,o.triggerRef),a=d.jsx(je.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Wm(o.open),...n,ref:i,onClick:De(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:d.jsx(Wl,{asChild:!0,...s,children:a})});jm.displayName=$m;var oc="PopoverPortal",[eN,tN]=Mm(oc,{forceMount:void 0}),zm=e=>{const{__scopePopover:t,forceMount:r,children:n,container:o}=e,s=$n(oc,t);return d.jsx(eN,{scope:t,forceMount:r,children:d.jsx(xr,{present:r||s.open,children:d.jsx(Oi,{asChild:!0,container:o,children:n})})})};zm.displayName=oc;var _o="PopoverContent",Um=b.forwardRef((e,t)=>{const r=tN(_o,e.__scopePopover),{forceMount:n=r.forceMount,...o}=e,s=$n(_o,e.__scopePopover);return d.jsx(xr,{present:n||s.open,children:s.modal?d.jsx(nN,{...o,ref:t}):d.jsx(oN,{...o,ref:t})})});Um.displayName=_o;var rN=KE("PopoverContent.RemoveScroll"),nN=b.forwardRef((e,t)=>{const r=$n(_o,e.__scopePopover),n=b.useRef(null),o=Qe(t,n),s=b.useRef(!1);return b.useEffect(()=>{const i=n.current;if(i)return Gl(i)},[]),d.jsx(zi,{as:rN,allowPinchZoom:!0,children:d.jsx(Vm,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:De(e.onCloseAutoFocus,i=>{i.preventDefault(),s.current||r.triggerRef.current?.focus()}),onPointerDownOutside:De(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0,u=a.button===2||c;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:De(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),oN=b.forwardRef((e,t)=>{const r=$n(_o,e.__scopePopover),n=b.useRef(!1),o=b.useRef(!1);return d.jsx(Vm,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(n.current||r.triggerRef.current?.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;r.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Vm=b.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:f,...l}=e,p=$n(_o,r),g=Ss(r);return kl(),d.jsx(wi,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(vi,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:f,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:d.jsx(Bp,{"data-state":Wm(p.open),role:"dialog",id:p.contentId,...g,...l,ref:t,style:{...l.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Hm="PopoverClose",sN=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(Hm,r);return d.jsx(je.button,{type:"button",...n,ref:t,onClick:De(e.onClick,()=>o.onOpenChange(!1))})});sN.displayName=Hm;var iN="PopoverArrow",aN=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=Ss(r);return d.jsx($p,{...o,...n,ref:t})});aN.displayName=iN;function Wm(e){return e?"open":"closed"}var lN=Lm,cN=Bm,dN=jm,uN=zm,fN=Um;function sc({...e}){return d.jsx(lN,{"data-slot":"popover",...e})}function Rm({...e}){return d.jsx(dN,{"data-slot":"popover-trigger",...e})}function ic({className:e,align:t="center",sideOffset:r=4,...n}){return d.jsx(uN,{children:d.jsx(fN,{"data-slot":"popover-content",align:t,sideOffset:r,className:H("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden pointer-events-auto",e),...n})})}function pN({...e}){return d.jsx(cN,{"data-slot":"popover-anchor",...e})}function Gm(e){return JSON.stringify(e).slice(1,-1)}function Km(e){const t=e.asyncSearchValueObjectKeys;return Array.isArray(t)?t.map(r=>typeof r=="string"?r.trim():"").filter(Boolean):[]}function mN(e){return e.asyncSearchValueMode==="object"&&Km(e).length>0}function hN(e,t){const r={};for(const n of t){const o=n.trim();if(!o)continue;const s=Ut(e,o);s==null||typeof s=="object"?r[o]="":r[o]=String(s)}return r}function gN(e,t){const r=t.mode??"debounce",n=Math.max(0,t.intervalMs??300),[o,s]=v.useState(()=>r==="throttle"?e:""),i=v.useRef(0),a=v.useRef(void 0);return v.useEffect(()=>{if(e===""){a.current&&clearTimeout(a.current),s("");return}if(r==="debounce"){const f=setTimeout(()=>s(e),n);return()=>clearTimeout(f)}const c=Date.now(),u=c-i.current;return u>=n?(i.current=c,s(e),()=>{a.current&&clearTimeout(a.current)}):(a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i.current=Date.now(),s(e),a.current=void 0},n-u),()=>{a.current&&clearTimeout(a.current)})},[e,r,n]),o}function ac(e,t){if(e==null||e==="")return"";if(t&&typeof e=="object"&&!Array.isArray(e)){const r=e,o=Object.keys(r).sort().map(s=>[s,r[s]??""]);return`O:${JSON.stringify(o)}`}return typeof e=="string"?`S:${e}`:""}function lc(e,t){return e==null||e===""?!0:t&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length===0:!1}function yN(e,t,r){return t.trim()!==""?!0:e==null||e===""?!1:r&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length>0:typeof e=="string"&&e.length>0}function bN(e){if(Ct.isAxiosError(e)){const t=e.response?.status,r=e.response?.data;if(t===404)return"Search endpoint not found.";if(t===401)return"Authentication failed.";if(r&&typeof r=="object"){const n=r,o=n.error??n.message??n.detail??n.explanation;if(typeof o=="string")return o}if(typeof r=="string")return r;if(t)return`Request failed (${t})`}return e instanceof Error?e.message:"Search failed"}function vN(e){if(e==null)return[];if(Array.isArray(e))return e;const t=e;if(!t?.data)return[];const r=t.data;return Array.isArray(r)?r:r?.data&&Array.isArray(r.data)?r.data:Array.isArray(r?.districts)?r.districts:Array.isArray(r?.states)?r.states:Array.isArray(r?.cities)?r.cities:[]}function qm(e,t){return typeof t=="number"&&t>0?e.slice(0,t):e}function cc(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.label=="string"&&t.value!==null&&t.value!==void 0}const Ym=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u={},submissionContext:f})=>{const l=e.properties||{},p=mN(l),g=l.apiEndpoint?.trim()||"",m=l.apiRealtime===!0,h=(l.apiMethod||"GET").toUpperCase()==="POST"?"POST":"GET",y=l.searchInBody===!0,S=h==="POST"||h==="GET"&&y,w=l.searchStrategy??l.searchSchedule??"debounce",A=l.searchIntervalMs??l.intervalMs??300,x=l.minQueryLength??0,F=l.maxResults,N=l.searchQueryParam||"q",k=l.clearable!==!1,T=u,[P,E]=v.useState(()=>lc(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?l.initialDisplayLabel||"":l.initialDisplayLabel||String(t)),[C,I]=v.useState(!1),[W,M]=v.useState([]),[z,V]=v.useState([]),[X,D]=v.useState([]),[B,L]=v.useState(!1),[K,ie]=v.useState(null),[j,U]=v.useState(-1),le=v.useRef(ac(t,p)),oe=v.useRef(lc(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?l.initialDisplayLabel||"":l.initialDisplayLabel||String(t??"")),G=v.useRef(void 0),ae=v.useRef(0),Ae=v.useRef(null),ee=gN(P,{mode:w,intervalMs:A}),ne=v.useMemo(()=>W.filter(cc),[W]);v.useEffect(()=>{if(ne.length===0){j!==-1&&U(-1);return}(j<0||j>=ne.length)&&U(0)},[j,ne.length]);const he=v.useMemo(()=>{const J=po(g,l.apiQueryParams),$=new Set(J);for(const fe of l.dependentFields||[])fe&&$.add(fe);return $},[g,l.apiQueryParams,l.dependentFields]),Ie=v.useMemo(()=>{if(he.size===0)return null;const J={};return he.forEach($=>{J[$]=T[$]}),JSON.stringify(J)},[he,T]),Ue=v.useMemo(()=>JSON.stringify(u),[u]),re=v.useMemo(()=>JSON.stringify(f||{}),[f]);v.useEffect(()=>{const J=ac(t,p);if(J===le.current)return;if(le.current=J,lc(t,p)){oe.current="",E(""),M([]),V([]),D([]),ie(null),I(!1);return}const $=l.initialDisplayLabel||(!p&&typeof t=="string"?t:"");oe.current=$,E($)},[t,l.initialDisplayLabel,p]),v.useEffect(()=>{if(!g){M([]),V([]),D([]),L(!1);return}if(i||s||e.disabled){M([]),V([]),D([]),L(!1);return}const J=ee;if(J.length<x){M([]),V([]),D([]),L(!1),ie(null);return}const $=ti({apiEndpoint:g,apiMethod:h,apiQueryParams:l.apiQueryParams,formValues:T,submissionContext:f,apiRealtime:m,additionalRequiredFieldNames:l.dependentFields});if($.blocked){M([]),V([]),D([]),L(!1),ie(null);return}Ae.current?.abort();const fe=new AbortController;Ae.current=fe;const st=++ae.current;return(async()=>{L(!0),ie(null);const Ye=Mr($.url),Me={};S&&(Me["Content-Type"]="application/json"),l.apiKey&&(Me["X-CSCAPI-KEY"]=l.apiKey);const Ce=l.apiAuth??vs(l.apiHeaders)??{type:"none"},nt=ws(Ce,{formValues:T,submissionContext:f,apiRealtime:m});Object.assign(Me,nt);const qe=vn(bs(l.apiHeaders),{formValues:T,submissionContext:f,apiRealtime:m});Object.assign(Me,qe);const dt=vn(l.apiBodyFields,{formValues:T,submissionContext:f,apiRealtime:m});try{let bt;if(!S)bt=(await Qt.get(Ye,{params:{[N]:J},signal:fe.signal,headers:Object.keys(Me).length?Me:void 0})).data;else{let $t={};$.postBodyBase&&Object.keys($.postBodyBase).length>0?$t={...$.postBodyBase}:m&&Object.keys(T).length>0&&($t={...T}),$t={...$t,...dt};let Ht=$t;if(l.searchBodyTemplate?.trim()){let Jr=l.searchBodyTemplate.replace(/\{\{query\}\}/g,()=>Gm(J)).replace(/\{query\}/g,()=>Gm(J));Jr=nl(Jr,T,f,m);const Yt=JSON.parse(Jr);Ht={...$t,...Yt}}else Ht={...$t,[N]:J};bt=(await Qt.post(Ye,Ht,{signal:fe.signal,headers:Object.keys(Me).length?Me:void 0})).data}if(st!==ae.current)return;const sr=l.apiResultsFormat,xt=l.apiResultsConfig,$e=sr==="clinicaltables_v3",gt=IE(bt),_t=$e||sr===void 0&&gt,yr=sr==="tuple_array";let ir=null;_t?ir=Nm({response:bt,sourceUrl:Ye,rowsIndex:xt?.rowsIndex??3,rowsPath:xt?.rowsPath,columns:xt?.columns,columnsQueryParam:xt?.columnsQueryParam??"sf",columnsQueryParamSeparator:xt?.columnsQueryParamSeparator??","}):yr&&(ir=Nm({response:bt,sourceUrl:Ye,rowsIndex:xt?.rowsIndex,rowsPath:xt?.rowsPath,columns:xt?.columns,columnsQueryParam:xt?.columnsQueryParam,columnsQueryParamSeparator:xt?.columnsQueryParamSeparator}));const Er=vN(bt),Et=ir!==null,Nr=ir&&Array.isArray(ir)?ir:Array.isArray(Er)&&Er.every($t=>$t&&typeof $t=="object"&&!Array.isArray($t))?Er:null;D(Nr??Er);const ar=Array.isArray(l.apiLabelFields)&&l.apiLabelFields.length>0,xn=Nr&&(Et||ar)?LE({rows:Nr,apiLabelField:l.apiLabelField,apiLabelFields:l.apiLabelFields,apiLabelSeparator:l.apiLabelSeparator,apiValueField:l.apiValueField}):ys(bt,l.apiLabelField,l.apiValueField);V(xn);const un=l.apiClientFilter;let $r=xn;if(un?.filterField&&un?.matchField){const $t=T[un.matchField];if($t!=null){const Ht=l.apiValueField;$r=xn.filter(br=>{const Yt=(Nr??Er).find(Un=>String(Ut(Un,Ht||"code"))===String(br.value));if(!Yt)return!1;const lr=Ut(Yt,un.filterField);return String(lr)===String($t)})}else $r=[]}const zn=qm($r,F).filter(cc);M(zn),U(zn.length>0?0:-1)}catch(bt){if(Ct.isCancel(bt)||bt?.code==="ERR_CANCELED"||st!==ae.current)return;M([]),V([]),D([]),ie(bN(bt)),U(-1)}finally{st===ae.current&&L(!1)}})(),()=>{fe.abort()}},[ee,g,h,y,S,N,x,F,l.apiKey,l.searchBodyTemplate,l.apiLabelField,l.apiLabelFields,l.apiLabelSeparator,l.apiValueField,l.apiQueryParams,l.apiClientFilter,l.apiResultsFormat,l.apiResultsConfig,l.dependentFields,m,T,f,i,s,e.disabled,Ie,Ue,re]),v.useEffect(()=>{const J=l.apiClientFilter;if(!J||X.length===0||z.length===0)return;const $=T[J.matchField],fe=l.apiValueField;if($==null){M([]);return}const st=z.filter(Ye=>{const Me=X.find(nt=>String(Ut(nt,fe||"code"))===String(Ye.value));if(!Me)return!1;const Ce=Ut(Me,J.filterField);return String(Ce)===String($)}),Te=qm(st,F).filter(cc);M(Te),U(Te.length>0?0:-1)},[l.apiClientFilter,l.apiValueField,T,F,z,X]);const ge=s||e.disabled,Se=i||e.readOnly,pt=v.useCallback(J=>{const $=J.target.value;Se||ge||(le.current&&oe.current&&$!==oe.current&&(le.current="",oe.current="",r(p?null:"")),E($),I(!0),U(-1))},[ge,Se,p,r]),Dt=v.useCallback(J=>{const $=typeof J?.label=="string"?J.label:String(J?.value??""),fe=l.apiValueField||"code";if(p){const st=Km(l),Te=X.find(Ye=>String(Ut(Ye,fe))===String(J.value));if(Te&&typeof Te=="object"&&!Array.isArray(Te)&&st.length>0){const Ye=hN(Te,st);le.current=ac(Ye,!0),oe.current=$,r(Ye),E($)}else le.current=`S:${String(J.value)}`,oe.current=$,r(String(J.value)),E($)}else le.current=`S:${String(J.value)}`,oe.current=$,r(String(J.value)),E($);G.current&&clearTimeout(G.current),I(!1),U(-1),n?.()},[p,n,r,l,X]),Bt=v.useCallback(J=>{J.preventDefault(),J.stopPropagation(),!(ge||Se)&&(le.current="",oe.current="",r(p?null:""),E(""),M([]),V([]),D([]),ie(null),I(!1),n?.())},[ge,Se,p,r,n]),Ot=v.useMemo(()=>C&&!Se&&(B||!!K||ne.length>0||ee.length>=x&&!B),[C,Se,B,K,ne.length,ee,x]),Ar=v.useCallback(J=>{if(!(Se||ge))if(J.key==="ArrowDown")J.preventDefault(),I(!0),U($=>ne.length===0?-1:($+1)%ne.length);else if(J.key==="ArrowUp")J.preventDefault(),I(!0),U($=>ne.length===0?-1:$<=0?ne.length-1:$-1);else if(J.key==="Enter"){const $=j>=0?ne[j]:void 0;Ot&&$&&!$.disabled&&(J.preventDefault(),Dt($))}else J.key==="Escape"&&I(!1)},[ge,Se,j,Ot,ne,Dt]),kt=e.appearance?.size||"md",Cr={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},Xe=ft(e),ve=Lt(e,!!(o||K)),ce=ee.length>=x&&!B&&!K&&ne.length===0;return d.jsx(At,{field:e,error:o||K||void 0,isRequired:a,className:c,children:d.jsxs(sc,{open:Ot,onOpenChange:J=>{J||I(!1)},children:[d.jsx(pN,{asChild:!0,children:d.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[d.jsx(mn,{id:Xe,role:"combobox","aria-expanded":Ot,"aria-autocomplete":"list","aria-controls":Ot?`${Xe}-listbox`:void 0,"aria-activedescendant":j>=0?`${Xe}-opt-${j}`:void 0,value:P,onChange:pt,onKeyDown:Ar,onFocus:()=>{G.current&&clearTimeout(G.current),!Se&&!ge&&I(!0)},onBlur:()=>{G.current=setTimeout(()=>{I(!1),n?.()},150)},placeholder:e.placeholder||"Search…",disabled:ge,readOnly:Se,"aria-describedby":ve,"aria-invalid":Jt(!!(o||K)),"aria-required":a,className:H("pr-20",Cr[kt],(o||K)&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),d.jsxs("div",{className:"pointer-events-none absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[B&&d.jsx(mo,{className:"pointer-events-none h-4 w-4 animate-spin text-muted-foreground"}),k&&yN(t,P,p)&&!ge&&!Se&&d.jsx(Zt,{type:"button",variant:"ghost",size:"icon",className:"pointer-events-auto h-8 w-8 shrink-0",onMouseDown:J=>J.preventDefault(),onClick:Bt,"aria-label":"Clear",children:d.jsx(ns,{className:"h-4 w-4"})})]})]})}),d.jsx(ic,{className:"p-0 w-[var(--radix-popover-trigger-width)] min-w-[12rem] overflow-hidden",align:"start",onOpenAutoFocus:J=>J.preventDefault(),onCloseAutoFocus:J=>J.preventDefault(),children:d.jsx("div",{id:`${Xe}-listbox`,role:"listbox",children:K?d.jsx("div",{className:"px-3 py-2 text-sm text-destructive",children:K}):B?d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground",children:[d.jsx(mo,{className:"h-4 w-4 animate-spin shrink-0"}),"Loading…"]}):ce?d.jsx("ul",{className:"py-1","aria-label":"Search results",children:d.jsx("li",{role:"option","aria-disabled":!0,className:"cursor-default select-none px-3 py-2 text-sm text-muted-foreground",onMouseDown:J=>J.preventDefault(),children:"No results found"})}):d.jsx("ul",{className:"max-h-60 overflow-y-auto overscroll-contain py-1","aria-label":"Search results",children:ne.map((J,$)=>d.jsx("li",{id:`${Xe}-opt-${$}`,role:"option","aria-selected":j===$,className:H(J.disabled?"cursor-not-allowed opacity-60":"cursor-pointer","px-3 py-2 text-sm",j===$&&"bg-accent text-accent-foreground"),onMouseEnter:()=>U($),onMouseDown:fe=>fe.preventDefault(),onClick:()=>{J.disabled||Dt(J)},children:J.label},`${J.value}-${$}`))})})})]})})};var qi="Checkbox",[wN]=vr(qi),[SN,dc]=wN(qi);function xN(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:o,disabled:s,form:i,name:a,onCheckedChange:c,required:u,value:f="on",internal_do_not_use_render:l}=e,[p,g]=ln({prop:r,defaultProp:o??!1,onChange:c,caller:qi}),[m,h]=b.useState(null),[y,S]=b.useState(null),w=b.useRef(!1),A=m?!!i||!!m.closest("form"):!0,x={checked:p,disabled:s,setChecked:g,control:m,setControl:h,name:a,form:i,value:f,hasConsumerStoppedPropagationRef:w,required:u,defaultChecked:jn(o)?!1:o,isFormControl:A,bubbleInput:y,setBubbleInput:S};return d.jsx(SN,{scope:t,...x,children:AN(l)?l(x):n})}var Xm="CheckboxTrigger",Jm=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},o)=>{const{control:s,value:i,disabled:a,checked:c,required:u,setControl:f,setChecked:l,hasConsumerStoppedPropagationRef:p,isFormControl:g,bubbleInput:m}=dc(Xm,e),h=Qe(o,f),y=b.useRef(c);return b.useEffect(()=>{const S=s?.form;if(S){const w=()=>l(y.current);return S.addEventListener("reset",w),()=>S.removeEventListener("reset",w)}},[s,l]),d.jsx(je.button,{type:"button",role:"checkbox","aria-checked":jn(c)?"mixed":c,"aria-required":u,"data-state":nh(c),"data-disabled":a?"":void 0,disabled:a,value:i,...n,ref:h,onKeyDown:De(t,S=>{S.key==="Enter"&&S.preventDefault()}),onClick:De(r,S=>{l(w=>jn(w)?!0:!w),m&&g&&(p.current=S.isPropagationStopped(),p.current||S.stopPropagation())})})});Jm.displayName=Xm;var Qm=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:o,defaultChecked:s,required:i,disabled:a,value:c,onCheckedChange:u,form:f,...l}=e;return d.jsx(xN,{__scopeCheckbox:r,checked:o,defaultChecked:s,disabled:a,required:i,onCheckedChange:u,name:n,form:f,value:c,internal_do_not_use_render:({isFormControl:p})=>d.jsxs(d.Fragment,{children:[d.jsx(Jm,{...l,ref:t,__scopeCheckbox:r}),p&&d.jsx(rh,{__scopeCheckbox:r})]})})});Qm.displayName=qi;var Zm="CheckboxIndicator",eh=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...o}=e,s=dc(Zm,r);return d.jsx(xr,{present:n||jn(s.checked)||s.checked===!0,children:d.jsx(je.span,{"data-state":nh(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});eh.displayName=Zm;var th="CheckboxBubbleInput",rh=b.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:o,checked:s,defaultChecked:i,required:a,disabled:c,name:u,value:f,form:l,bubbleInput:p,setBubbleInput:g}=dc(th,e),m=Qe(r,g),h=hs(s),y=ms(n);b.useEffect(()=>{const w=p;if(!w)return;const A=window.HTMLInputElement.prototype,F=Object.getOwnPropertyDescriptor(A,"checked").set,N=!o.current;if(h!==s&&F){const k=new Event("click",{bubbles:N});w.indeterminate=jn(s),F.call(w,jn(s)?!1:s),w.dispatchEvent(k)}},[p,h,s,o]);const S=b.useRef(jn(s)?!1:s);return d.jsx(je.input,{type:"checkbox","aria-hidden":!0,defaultChecked:i??S.current,required:a,disabled:c,name:u,value:f,form:l,...t,tabIndex:-1,ref:m,style:{...t.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});rh.displayName=th;function AN(e){return typeof e=="function"}function jn(e){return e==="indeterminate"}function nh(e){return jn(e)?"indeterminate":e?"checked":"unchecked"}function Yi({className:e,...t}){return d.jsx(Qm,{"data-slot":"checkbox",className:H("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(eh,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:d.jsx(ai,{className:"size-3.5"})})})}const CN=Im("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-destructive-foreground [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",warning:"border-transparent bg-orange-500 text-white [a&]:hover:bg-orange-600 focus-visible:ring-orange-500/20",success:"border-transparent bg-green-500 text-white [a&]:hover:bg-green-600 focus-visible:ring-green-500/20",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function EN({className:e,variant:t,asChild:r=!1,...n}){const o=r?$u:"span";return d.jsx(o,{"data-slot":"badge",className:H(CN({variant:t}),e),...n})}function NN(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var uc="ScrollArea",[oh]=vr(uc),[kN,Lr]=oh(uc),sh=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=b.useState(null),[u,f]=b.useState(null),[l,p]=b.useState(null),[g,m]=b.useState(null),[h,y]=b.useState(null),[S,w]=b.useState(0),[A,x]=b.useState(0),[F,N]=b.useState(!1),[k,T]=b.useState(!1),P=Qe(t,C=>c(C)),E=bo(o);return d.jsx(kN,{scope:r,type:n,dir:E,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:f,content:l,onContentChange:p,scrollbarX:g,onScrollbarXChange:m,scrollbarXEnabled:F,onScrollbarXEnabledChange:N,scrollbarY:h,onScrollbarYChange:y,scrollbarYEnabled:k,onScrollbarYEnabledChange:T,onCornerWidthChange:w,onCornerHeightChange:x,children:d.jsx(je.div,{dir:E,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":A+"px",...e.style}})})});sh.displayName=uc;var ih="ScrollAreaViewport",ah=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...s}=e,i=Lr(ih,r),a=b.useRef(null),c=Qe(t,a,i.onViewportChange);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),d.jsx(je.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});ah.displayName=ih;var dn="ScrollAreaScrollbar",lh=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Lr(dn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return b.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?d.jsx(_N,{...n,ref:t,forceMount:r}):o.type==="scroll"?d.jsx(TN,{...n,ref:t,forceMount:r}):o.type==="auto"?d.jsx(ch,{...n,ref:t,forceMount:r}):o.type==="always"?d.jsx(fc,{...n,ref:t}):null});lh.displayName=dn;var _N=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Lr(dn,e.__scopeScrollArea),[s,i]=b.useState(!1);return b.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},f=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",f),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",f)}}},[o.scrollArea,o.scrollHideDelay]),d.jsx(xr,{present:r||s,children:d.jsx(ch,{"data-state":s?"visible":"hidden",...n,ref:t})})}),TN=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Lr(dn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Zi(()=>c("SCROLL_END"),100),[a,c]=NN("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return b.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),b.useEffect(()=>{const u=o.viewport,f=s?"scrollLeft":"scrollTop";if(u){let l=u[f];const p=()=>{const g=u[f];l!==g&&(c("SCROLL"),i()),l=g};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,s,c,i]),d.jsx(xr,{present:r||a!=="hidden",children:d.jsx(fc,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:De(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:De(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),ch=b.forwardRef((e,t)=>{const r=Lr(dn,e.__scopeScrollArea),{forceMount:n,...o}=e,[s,i]=b.useState(!1),a=e.orientation==="horizontal",c=Zi(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,f=r.viewport.offsetHeight<r.viewport.scrollHeight;i(a?u:f)}},10);return To(r.viewport,c),To(r.content,c),d.jsx(xr,{present:n||s,children:d.jsx(fc,{"data-state":s?"visible":"hidden",...o,ref:t})})}),fc=b.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=Lr(dn,e.__scopeScrollArea),s=b.useRef(null),i=b.useRef(0),[a,c]=b.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=mh(a.viewport,a.content),f={...n,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function l(p,g){return LN(p,i.current,a,g)}return r==="horizontal"?d.jsx(FN,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,g=hh(p,a,o.dir);s.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=l(p,o.dir))}}):r==="vertical"?d.jsx(PN,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,g=hh(p,a);s.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=l(p))}}):null}),FN=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Lr(dn,e.__scopeScrollArea),[i,a]=b.useState(),c=b.useRef(null),u=Qe(t,c,s.onScrollbarXChange);return b.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),d.jsx(uh,{"data-orientation":"horizontal",...o,ref:u,sizes:r,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Qi(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.x),onDragScroll:f=>e.onDragScroll(f.x),onWheelScroll:(f,l)=>{if(s.viewport){const p=s.viewport.scrollLeft+f.deltaX;e.onWheelScroll(p),yh(p,l)&&f.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Ji(i.paddingLeft),paddingEnd:Ji(i.paddingRight)}})}})}),PN=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Lr(dn,e.__scopeScrollArea),[i,a]=b.useState(),c=b.useRef(null),u=Qe(t,c,s.onScrollbarYChange);return b.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),d.jsx(uh,{"data-orientation":"vertical",...o,ref:u,sizes:r,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Qi(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.y),onDragScroll:f=>e.onDragScroll(f.y),onWheelScroll:(f,l)=>{if(s.viewport){const p=s.viewport.scrollTop+f.deltaY;e.onWheelScroll(p),yh(p,l)&&f.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Ji(i.paddingTop),paddingEnd:Ji(i.paddingBottom)}})}})}),[ON,dh]=oh(dn),uh=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:f,onResize:l,...p}=e,g=Lr(dn,r),[m,h]=b.useState(null),y=Qe(t,P=>h(P)),S=b.useRef(null),w=b.useRef(""),A=g.viewport,x=n.content-n.viewport,F=cr(f),N=cr(c),k=Zi(l,10);function T(P){if(S.current){const E=P.clientX-S.current.left,C=P.clientY-S.current.top;u({x:E,y:C})}}return b.useEffect(()=>{const P=E=>{const C=E.target;m?.contains(C)&&F(E,x)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[A,m,x,F]),b.useEffect(N,[n,N]),To(m,k),To(g.content,k),d.jsx(ON,{scope:r,scrollbar:m,hasThumb:o,onThumbChange:cr(s),onThumbPointerUp:cr(i),onThumbPositionChange:N,onThumbPointerDown:cr(a),children:d.jsx(je.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:De(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),S.current=m.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),T(P))}),onPointerMove:De(e.onPointerMove,T),onPointerUp:De(e.onPointerUp,P=>{const E=P.target;E.hasPointerCapture(P.pointerId)&&E.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=w.current,g.viewport&&(g.viewport.style.scrollBehavior=""),S.current=null})})})}),Xi="ScrollAreaThumb",fh=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=dh(Xi,e.__scopeScrollArea);return d.jsx(xr,{present:r||o.hasThumb,children:d.jsx(IN,{ref:t,...n})})}),IN=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,s=Lr(Xi,r),i=dh(Xi,r),{onThumbPositionChange:a}=i,c=Qe(t,l=>i.onThumbChange(l)),u=b.useRef(void 0),f=Zi(()=>{u.current&&(u.current(),u.current=void 0)},100);return b.useEffect(()=>{const l=s.viewport;if(l){const p=()=>{if(f(),!u.current){const g=DN(l,a);u.current=g,a()}};return a(),l.addEventListener("scroll",p),()=>l.removeEventListener("scroll",p)}},[s.viewport,f,a]),d.jsx(je.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:De(e.onPointerDownCapture,l=>{const g=l.target.getBoundingClientRect(),m=l.clientX-g.left,h=l.clientY-g.top;i.onThumbPointerDown({x:m,y:h})}),onPointerUp:De(e.onPointerUp,i.onThumbPointerUp)})});fh.displayName=Xi;var pc="ScrollAreaCorner",ph=b.forwardRef((e,t)=>{const r=Lr(pc,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?d.jsx(MN,{...e,ref:t}):null});ph.displayName=pc;var MN=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=Lr(pc,r),[s,i]=b.useState(0),[a,c]=b.useState(0),u=!!(s&&a);return To(o.scrollbarX,()=>{const f=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(f),c(f)}),To(o.scrollbarY,()=>{const f=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(f),i(f)}),u?d.jsx(je.div,{...n,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Ji(e){return e?parseInt(e,10):0}function mh(e,t){const r=e/t;return isNaN(r)?0:r}function Qi(e){const t=mh(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function LN(e,t,r,n="ltr"){const o=Qi(r),s=o/2,i=t||s,a=o-i,c=r.scrollbar.paddingStart+i,u=r.scrollbar.size-r.scrollbar.paddingEnd-a,f=r.content-r.viewport,l=n==="ltr"?[0,f]:[f*-1,0];return gh([c,u],l)(e)}function hh(e,t,r="ltr"){const n=Qi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-n,c=r==="ltr"?[0,i]:[i*-1,0],u=us(e,c);return gh([0,i],[0,a])(u)}function gh(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function yh(e,t){return e>0&&e<t}var DN=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return(function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=r.left!==s.left,a=r.top!==s.top;(i||a)&&t(),r=s,n=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(n)};function Zi(e,t){const r=cr(e),n=b.useRef(0);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),b.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function To(e,t){const r=cr(t);tr(()=>{let n=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return o.observe(e),()=>{window.cancelAnimationFrame(n),o.unobserve(e)}}},[e,r])}var BN=sh,$N=ah,jN=ph;function zN({className:e,children:t,...r}){return d.jsxs(BN,{"data-slot":"scroll-area",className:H("relative",e),...r,children:[d.jsx($N,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),d.jsx(UN,{}),d.jsx(jN,{})]})}function UN({className:e,orientation:t="vertical",...r}){return d.jsx(lh,{"data-slot":"scroll-area-scrollbar",orientation:t,className:H("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...r,children:d.jsx(fh,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const bh=({field:e,value:t=[],onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,formValues:c={},submissionContext:u,excludedOptionValues:f})=>{const{options:l,isLoadingOptions:p,optionsError:g}=Tm({field:e,formValues:c,submissionContext:u}),m=f?.length?new Set(f.map(String)):null,h=m?l.filter(k=>!m.has(String(k.value??k.label??""))):l,y=Array.isArray(t)?t:[],S=y.map(k=>h.find(T=>String(T.value)===String(k))).filter(Boolean),w=v.useCallback(k=>{const T=y.includes(k)?y.filter(P=>P!==k):[...y,k];r(T),n?.()},[y,r,n]),A=v.useCallback(k=>{r(y.filter(T=>T!==k)),n?.()},[y,r,n]),x=e.appearance?.size||"md",F={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},N=S.length>0?`${S.length} selected`:h.length===0&&f?.length?"No available options":e.placeholder||"Select options";return d.jsxs(At,{field:e,error:o||g||void 0,isRequired:i,className:a,children:[d.jsxs(sc,{children:[d.jsx(Rm,{asChild:!0,children:d.jsxs(Zt,{type:"button",variant:"outline",role:"combobox","aria-expanded":void 0,"aria-haspopup":"listbox","aria-multiselectable":"true","aria-describedby":Lt(e,!!o||!!g),"aria-invalid":Jt(!!o||!!g),"aria-required":i,id:ft(e),disabled:s||e.disabled||p,className:H("w-full min-w-0 justify-between font-normal",F[x],o&&"border-destructive focus-visible:ring-destructive",g&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:[d.jsx("span",{className:"truncate",children:N}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p&&d.jsx(mo,{className:"h-4 w-4 animate-spin text-muted-foreground"}),d.jsx(ts,{className:"h-4 w-4 opacity-50"})]})]})}),d.jsx(ic,{className:"w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden",align:"start",children:d.jsx(zN,{className:"h-60 overflow-hidden rounded-md",children:d.jsx("ul",{role:"listbox","aria-multiselectable":"true","aria-label":e.label||e.name||"Options",className:"p-1",children:h.length===0?d.jsx("li",{className:"px-2 py-3 text-sm text-muted-foreground text-center",children:p?"Loading options...":f?.length?"No available options":"No options available"}):h.map(k=>{const T=String(k.value||k.label),P=k.label||k.value||T,E=y.includes(T);return d.jsxs("li",{role:"option","aria-selected":E,className:"flex items-center gap-2 rounded-sm px-2 py-1.5 cursor-pointer hover:bg-accent focus:bg-accent outline-none",onClick:()=>!k.disabled&&w(T),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),k.disabled||w(T))},children:[d.jsx(Yi,{checked:E,disabled:k.disabled,onCheckedChange:()=>!k.disabled&&w(T),onClick:C=>C.stopPropagation(),"aria-hidden":!0,className:"pointer-events-none"}),d.jsx("span",{className:"flex-1 truncate text-sm",children:P})]},T)})})})})]}),S.length>0&&d.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",role:"list","aria-label":"Selected options",children:S.map(k=>{const T=String(k.value||k.label),P=k.label||k.value||T;return d.jsxs(EN,{variant:"secondary",className:"pl-2 pr-1 py-0.5 text-xs font-normal gap-1",children:[d.jsx("span",{className:"truncate max-w-[120px]",children:P}),d.jsx("button",{type:"button","aria-label":`Remove ${P}`,className:"rounded-full p-0.5 hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring",onClick:()=>A(T),tabIndex:-1,children:d.jsx(ns,{className:"h-3 w-3"})})]},T)})})]})},vh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const c=v.useCallback(u=>{r(u===!0),n?.()},[r,n]);return d.jsxs("div",{className:H("space-y-2",a),children:[d.jsxs("div",{className:"flex items-start space-x-3",children:[d.jsx(Yi,{id:ft(e),checked:t||!1,onCheckedChange:c,disabled:s||e.disabled,"aria-describedby":Lt(e,!!o),"aria-required":i,className:H(o&&"border-destructive")}),d.jsxs("div",{className:"grid gap-1.5 leading-none",children:[d.jsxs(Pn,{id:oi(e),htmlFor:ft(e),className:H("text-sm font-medium cursor-pointer",o&&"text-destructive"),children:[e.label,i&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&d.jsx("p",{id:Zo(e),className:"text-xs text-muted-foreground",children:e.description})]})]}),o&&d.jsx("p",{id:es(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var ea="Switch",[VN]=vr(ea),[HN,WN]=VN(ea),wh=b.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:f,...l}=e,[p,g]=b.useState(null),m=Qe(t,A=>g(A)),h=b.useRef(!1),y=p?f||!!p.closest("form"):!0,[S,w]=ln({prop:o,defaultProp:s??!1,onChange:u,caller:ea});return d.jsxs(HN,{scope:r,checked:S,disabled:a,children:[d.jsx(je.button,{type:"button",role:"switch","aria-checked":S,"aria-required":i,"data-state":Ch(S),"data-disabled":a?"":void 0,disabled:a,value:c,...l,ref:m,onClick:De(e.onClick,A=>{w(x=>!x),y&&(h.current=A.isPropagationStopped(),h.current||A.stopPropagation())})}),y&&d.jsx(Ah,{control:p,bubbles:!h.current,name:n,value:c,checked:S,required:i,disabled:a,form:f,style:{transform:"translateX(-100%)"}})]})});wh.displayName=ea;var Sh="SwitchThumb",xh=b.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,o=WN(Sh,r);return d.jsx(je.span,{"data-state":Ch(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:t})});xh.displayName=Sh;var RN="SwitchBubbleInput",Ah=b.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Qe(i,s),c=hs(r),u=ms(t);return b.useEffect(()=>{const f=i.current;if(!f)return;const l=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(l,"checked").set;if(c!==r&&g){const m=new Event("click",{bubbles:n});g.call(f,r),f.dispatchEvent(m)}},[c,r,n]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Ah.displayName=RN;function Ch(e){return e?"checked":"unchecked"}var GN=wh,KN=xh;function Eh({className:e,...t}){return d.jsx(GN,{"data-slot":"switch",className:H("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(KN,{"data-slot":"switch-thumb",className:H("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const qN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const c=e.properties;let u=null;if(e.metadata)try{u=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata}catch{}const f=u?.onValue??c?.onValue??"On",l=u?.offValue??c?.offValue??"Off",p=u?.onText??c?.onText??f,g=u?.offText??c?.offText??l,m=v.useMemo(()=>{const y=t??e.defaultValue??l;return String(y)===String(f)},[t,e.defaultValue,l,f]),h=v.useCallback(y=>{r(y?f:l),n?.()},[r,n,f,l]);return d.jsxs("div",{className:H("space-y-2",a),children:[d.jsxs("div",{className:"space-y-2",children:[e.label&&d.jsxs(Pn,{id:oi(e),htmlFor:ft(e),className:H("text-sm font-medium block",o&&"text-destructive"),children:[e.label,i&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&d.jsx("p",{id:Zo(e),className:"text-xs text-muted-foreground",children:e.description}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Eh,{id:ft(e),checked:m,onCheckedChange:h,disabled:s||e.disabled,"aria-describedby":Lt(e,!!o),"aria-required":i,className:H(o&&"opacity-50")}),d.jsx("span",{className:"text-sm text-foreground font-medium",children:m?p:g})]})]}),o&&d.jsx("p",{id:es(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var mc="rovingFocusGroup.onEntryFocus",YN={bubbles:!1,cancelable:!0},xs="RovingFocusGroup",[hc,Nh,XN]=Cl(xs),[JN,ta]=vr(xs,[XN]),[QN,ZN]=JN(xs),kh=b.forwardRef((e,t)=>d.jsx(hc.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(hc.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(ek,{...e,ref:t})})}));kh.displayName=xs;var ek=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...l}=e,p=b.useRef(null),g=Qe(t,p),m=bo(s),[h,y]=ln({prop:i,defaultProp:a??null,onChange:c,caller:xs}),[S,w]=b.useState(!1),A=cr(u),x=Nh(r),F=b.useRef(!1),[N,k]=b.useState(0);return b.useEffect(()=>{const T=p.current;if(T)return T.addEventListener(mc,A),()=>T.removeEventListener(mc,A)},[A]),d.jsx(QN,{scope:r,orientation:n,dir:m,loop:o,currentTabStopId:h,onItemFocus:b.useCallback(T=>y(T),[y]),onItemShiftTab:b.useCallback(()=>w(!0),[]),onFocusableItemAdd:b.useCallback(()=>k(T=>T+1),[]),onFocusableItemRemove:b.useCallback(()=>k(T=>T-1),[]),children:d.jsx(je.div,{tabIndex:S||N===0?-1:0,"data-orientation":n,...l,ref:g,style:{outline:"none",...e.style},onMouseDown:De(e.onMouseDown,()=>{F.current=!0}),onFocus:De(e.onFocus,T=>{const P=!F.current;if(T.target===T.currentTarget&&P&&!S){const E=new CustomEvent(mc,YN);if(T.currentTarget.dispatchEvent(E),!E.defaultPrevented){const C=x().filter(V=>V.focusable),I=C.find(V=>V.active),W=C.find(V=>V.id===h),z=[I,W,...C].filter(Boolean).map(V=>V.ref.current);Fh(z,f)}}F.current=!1}),onBlur:De(e.onBlur,()=>w(!1))})})}),_h="RovingFocusGroupItem",Th=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=hn(),u=s||c,f=ZN(_h,r),l=f.currentTabStopId===u,p=Nh(r),{onFocusableItemAdd:g,onFocusableItemRemove:m,currentTabStopId:h}=f;return b.useEffect(()=>{if(n)return g(),()=>m()},[n,g,m]),d.jsx(hc.ItemSlot,{scope:r,id:u,focusable:n,active:o,children:d.jsx(je.span,{tabIndex:l?0:-1,"data-orientation":f.orientation,...a,ref:t,onMouseDown:De(e.onMouseDown,y=>{n?f.onItemFocus(u):y.preventDefault()}),onFocus:De(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:De(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){f.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const S=nk(y,f.orientation,f.dir);if(S!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let A=p().filter(x=>x.focusable).map(x=>x.ref.current);if(S==="last")A.reverse();else if(S==="prev"||S==="next"){S==="prev"&&A.reverse();const x=A.indexOf(y.currentTarget);A=f.loop?ok(A,x+1):A.slice(x+1)}setTimeout(()=>Fh(A))}}),children:typeof i=="function"?i({isCurrentTabStop:l,hasTabStop:h!=null}):i})})});Th.displayName=_h;var tk={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function rk(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function nk(e,t,r){const n=rk(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return tk[n]}function Fh(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function ok(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Ph=kh,Oh=Th,gc="Radio",[sk,Ih]=vr(gc),[ik,ak]=sk(gc),Mh=b.forwardRef((e,t)=>{const{__scopeRadio:r,name:n,checked:o=!1,required:s,disabled:i,value:a="on",onCheck:c,form:u,...f}=e,[l,p]=b.useState(null),g=Qe(t,y=>p(y)),m=b.useRef(!1),h=l?u||!!l.closest("form"):!0;return d.jsxs(ik,{scope:r,checked:o,disabled:i,children:[d.jsx(je.button,{type:"button",role:"radio","aria-checked":o,"data-state":$h(o),"data-disabled":i?"":void 0,disabled:i,value:a,...f,ref:g,onClick:De(e.onClick,y=>{o||c?.(),h&&(m.current=y.isPropagationStopped(),m.current||y.stopPropagation())})}),h&&d.jsx(Bh,{control:l,bubbles:!m.current,name:n,value:a,checked:o,required:s,disabled:i,form:u,style:{transform:"translateX(-100%)"}})]})});Mh.displayName=gc;var Lh="RadioIndicator",Dh=b.forwardRef((e,t)=>{const{__scopeRadio:r,forceMount:n,...o}=e,s=ak(Lh,r);return d.jsx(xr,{present:n||s.checked,children:d.jsx(je.span,{"data-state":$h(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});Dh.displayName=Lh;var lk="RadioBubbleInput",Bh=b.forwardRef(({__scopeRadio:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Qe(i,s),c=hs(r),u=ms(t);return b.useEffect(()=>{const f=i.current;if(!f)return;const l=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(l,"checked").set;if(c!==r&&g){const m=new Event("click",{bubbles:n});g.call(f,r),f.dispatchEvent(m)}},[c,r,n]),d.jsx(je.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Bh.displayName=lk;function $h(e){return e?"checked":"unchecked"}var ck=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],ra="RadioGroup",[dk]=vr(ra,[ta,Ih]),jh=ta(),zh=Ih(),[uk,fk]=dk(ra),Uh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,name:n,defaultValue:o,value:s,required:i=!1,disabled:a=!1,orientation:c,dir:u,loop:f=!0,onValueChange:l,...p}=e,g=jh(r),m=bo(u),[h,y]=ln({prop:s,defaultProp:o??null,onChange:l,caller:ra});return d.jsx(uk,{scope:r,name:n,required:i,disabled:a,value:h,onValueChange:y,children:d.jsx(Ph,{asChild:!0,...g,orientation:c,dir:m,loop:f,children:d.jsx(je.div,{role:"radiogroup","aria-required":i,"aria-orientation":c,"data-disabled":a?"":void 0,dir:m,...p,ref:t})})})});Uh.displayName=ra;var Vh="RadioGroupItem",Hh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,disabled:n,...o}=e,s=fk(Vh,r),i=s.disabled||n,a=jh(r),c=zh(r),u=b.useRef(null),f=Qe(t,u),l=s.value===o.value,p=b.useRef(!1);return b.useEffect(()=>{const g=h=>{ck.includes(h.key)&&(p.current=!0)},m=()=>p.current=!1;return document.addEventListener("keydown",g),document.addEventListener("keyup",m),()=>{document.removeEventListener("keydown",g),document.removeEventListener("keyup",m)}},[]),d.jsx(Oh,{asChild:!0,...a,focusable:!i,active:l,children:d.jsx(Mh,{disabled:i,required:s.required,checked:l,...c,...o,name:s.name,ref:f,onCheck:()=>s.onValueChange(o.value),onKeyDown:De(g=>{g.key==="Enter"&&g.preventDefault()}),onFocus:De(o.onFocus,()=>{p.current&&u.current?.click()})})})});Hh.displayName=Vh;var pk="RadioGroupIndicator",Wh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,...n}=e,o=zh(r);return d.jsx(Dh,{...o,...n,ref:t})});Wh.displayName=pk;var mk=Uh,hk=Hh,gk=Wh;function yk({className:e,...t}){return d.jsx(mk,{"data-slot":"radio-group",className:H("grid gap-3",e),...t})}function bk({className:e,...t}){return d.jsx(hk,{"data-slot":"radio-group-item",className:H("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(gk,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:d.jsx(Hu,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const Rh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,excludedOptionValues:c})=>{const u=e.properties,f=Array.isArray(u?.options)&&u.options.length>0?u.options:Array.isArray(e.options)?e.options:[],l=c?.length?new Set(c.map(String)):null,p=l?f.filter(m=>!l.has(String(m.value??m.label??""))):f,g=v.useCallback(m=>{r(m),n?.()},[r,n]);return d.jsx(At,{field:e,error:o,isRequired:i,className:a,children:d.jsx(yk,{value:t||"",onValueChange:g,disabled:s||e.disabled||p.length===0,className:"flex flex-col space-y-2","aria-required":i,children:p.length===0?d.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"No available options"}):p.map(m=>d.jsxs("div",{className:"flex items-center space-x-3",children:[d.jsx(bk,{id:`${ft(e)}-${m.value}`,value:m.value,disabled:m.disabled,className:H(o&&"border-destructive")}),d.jsxs(Pn,{htmlFor:`${ft(e)}-${m.value}`,className:H("text-sm font-normal cursor-pointer",m.disabled&&"text-muted-foreground cursor-not-allowed"),children:[m.label,m.description&&d.jsx("span",{className:"block text-xs text-muted-foreground",children:m.description})]})]},m.value))})})},Gh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=v.useCallback(x=>{r(x.target.value)},[r]),l=x=>{if(x)return x==="today"?new Date().toISOString().split("T")[0]:x},p=l(u?.minDate),g=l(u?.maxDate),h=(()=>{switch(e.type){case"time":return"time";case"datetime":return"datetime-local";case"daterange":return"date";default:return"date"}})(),y=e.appearance?.size||"md",S={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},w=e.appearance?.labelPlacement||"top",A=!e.appearance?.hideLabel&&e.label;return d.jsxs("div",{className:H("space-y-2 w-fit",w==="left"&&"flex items-start gap-4",c),children:[A&&d.jsxs(Pn,{id:oi(e),htmlFor:ft(e),className:H("text-sm font-medium",w==="left"&&"w-32 pt-2 text-right",o&&"text-destructive"),children:[e.label,a&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),d.jsxs("div",{className:"w-fit",children:[d.jsxs("div",{className:"relative w-fit max-w-full",children:[d.jsx(tS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),d.jsx(mn,{id:ft(e),type:h,value:t||"",onChange:f,onBlur:n,disabled:s||e.disabled,readOnly:i||e.readOnly,min:p,max:g,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(S[y],"pl-10 w-fit",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]}),e.description&&!o&&d.jsx("p",{id:Zo(e),className:"mt-1.5 text-xs text-muted-foreground",children:e.description}),o&&d.jsx("p",{id:es(e),className:"mt-1.5 text-xs text-destructive",role:"alert",children:o})]})]})};function Fo(e){if(e===0)return"0 Bytes";const t=1024,r=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,n)).toFixed(2))+" "+r[n]}function yc(e,t){return e===1&&t===1}const Kh=/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?|$)/i;function bc(e){return e.type.startsWith("image/")?!0:Kh.test(e.name)}function na(e){try{const t=e.split("?")[0];return Kh.test(t)}catch{return!1}}function vc({items:e,maxFiles:t,disabled:r,objectUrls:n,failedUrlKeys:o,onImageUrlError:s,onRemove:i,onOpenUrl:a,resolveOpenUrl:c,addSlot:u,className:f}){const l=v.useCallback(p=>{try{return p.split("?")[0].split("/").filter(Boolean).pop()||p}catch{return p}},[]);return d.jsxs("div",{"data-file-like-strip":!0,"data-remove-in-dropzone":!0,className:H("relative w-full h-full flex items-center gap-1 min-h-0 overflow-x-auto",f),children:[e.map((p,g)=>{const m=p instanceof File,h=!m&&p&&"url"in p?p:null,y=h?.url??"",S=`${g}-${y}`,w=h&&o.has(y),A=m?n[g]??null:h&&na(y)&&!w?y:null,x=m&&bc(p)&&!!A||!!h&&na(y)&&!w&&!!A,F=m?p.name:h?h.name??l(y):"",N=c?.(g,p),k=h&&y||N||"",T=!!a&&!!k;return d.jsxs("div",{className:"relative h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded overflow-hidden border border-border/60 bg-muted/30",children:[x&&A?d.jsx("img",{src:A,alt:"",className:"absolute inset-0 h-full w-full object-cover",onError:()=>{h&&s(y)}}):d.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-muted/40",children:d.jsx(Ru,{className:"h-7 w-7 text-muted-foreground","aria-hidden":!0})}),d.jsxs("div",{className:"absolute top-0.5 right-0.5 z-10 flex items-center gap-0.5",children:[T&&d.jsx("button",{type:"button",onClick:P=>{P.preventDefault(),P.stopPropagation(),a(k)},disabled:r,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:d.jsx(Wu,{className:"h-3 w-3","aria-hidden":!0})}),d.jsx("button",{type:"button",onClick:P=>{P.preventDefault(),P.stopPropagation(),i(g)},disabled:r,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-destructive hover:bg-background focus:outline-none focus:ring-2 focus:ring-destructive","aria-label":"Remove file",title:"Remove file",children:d.jsx(ns,{className:"h-3 w-3","aria-hidden":!0})})]}),!x&&F&&d.jsx("span",{className:"sr-only",children:F})]},S+(m?p.name+p.size:""))}),u]})}function wc(e){const[t,r]=v.useState([]);return v.useEffect(()=>{const n=e.map(o=>o instanceof File&&bc(o)?URL.createObjectURL(o):null);return r(n),()=>{n.forEach(o=>{o&&URL.revokeObjectURL(o)})}},[e]),t}function Sc({item:e,objectUrl:t,failedUrlKeys:r,onImageUrlError:n,onRemove:o,onOpenUrl:s,openTarget:i,disabled:a}){const c=v.useCallback(w=>{try{return w.split("?")[0].split("/").filter(Boolean).pop()||w}catch{return w}},[]),u=e instanceof File,f=!u&&e&&"url"in e?e:null,l=f?.url??"",p=f&&r.has(l),g=u?t:f&&na(l)&&!p?l:null,m=u&&bc(e)&&!!g||!!f&&na(l)&&!p&&!!g,h=u?e.name:f?f.name??c(l):"",y=(i?.trim()||l||"").trim(),S=!!s&&!!y;return d.jsxs("div",{"data-file-like-full-bleed":!0,"data-remove-in-dropzone":!0,className:"relative h-full w-full min-h-[58px] min-w-0 flex items-center justify-center",children:[m&&g?d.jsx("img",{src:g,alt:"",className:"absolute inset-0 h-full w-full rounded object-cover",onError:()=>{f&&n(l)}}):d.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded bg-muted/40",children:d.jsx(Ru,{className:"h-8 w-8 text-muted-foreground","aria-hidden":!0})}),d.jsxs("div",{className:"absolute top-1 right-1 z-10 flex items-center gap-1",children:[S&&y&&d.jsx("button",{type:"button",onClick:w=>{w.preventDefault(),w.stopPropagation(),s(y)},disabled:a,className:"inline-flex h-6 w-6 items-center justify-center rounded bg-background/85 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:d.jsx(Wu,{className:"h-3.5 w-3.5","aria-hidden":!0})}),d.jsx("button",{type:"button",onClick:w=>{w.preventDefault(),w.stopPropagation(),o()},disabled:a,className:"inline-flex h-6 w-6 items-center justify-center rounded bg-background/85 text-destructive hover:bg-background focus:outline-none focus:ring-2 focus:ring-destructive","aria-label":"Remove file",title:"Remove file",children:d.jsx(ns,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),!m&&h&&d.jsx("p",{className:"sr-only",children:h})]})}const vk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,buttonResponses:c})=>{const{gridStretch:u}=Jo(),f=u&&Xs(e),l=e.properties,p=v.useRef(null),[g,m]=v.useState(!1),[h,y]=v.useState(),[S,w]=v.useState(()=>new Set),[A,x]=v.useState(0),F=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,N=Js(e),k=v.useMemo(()=>Qs(t),[t]),[T,P]=v.useState(null);v.useEffect(()=>{P(null)},[t,A]);const E=T??k,C=wc(E),I=e.validation?.find(re=>re.type==="fileSize"),W=e.validation?.find(re=>re.type==="fileType"),M=I?.value?I.value:l?.maxSize??F?.maxSize??10*1024*1024,z=W?.value?W.value:l?.accept??F?.accept??[],V=Array.isArray(z)?z.join(","):"",X=()=>{E.length>=N||p.current?.click()},D=v.useCallback(re=>{if(I){const ge=rn(re,I);if(ge!==!0)return typeof ge=="string"?ge:"File size exceeds the maximum allowed size"}else if(re.size>M)return`File size must be less than ${Fo(M)}`;if(W){const ge=rn(re,W);if(ge!==!0)return typeof ge=="string"?ge:"File type is not allowed"}return null},[I,W,M]),B=v.useCallback(re=>{const ge=Ja(re,N);r(ge),n?.()},[r,n,N]),L=v.useCallback(re=>{y(void 0);const ge=Array.from(re),Se=[...E];let pt=null;for(const Dt of ge){if(Se.length>=N)break;const Bt=D(Dt);if(Bt){pt||(pt=Bt);continue}Se.push(Dt)}if(pt&&Se.length===E.length){y(pt);return}pt&&y(pt),P(Se),B(Se)},[E,N,D,B]),K=v.useCallback(re=>{const ge=re.target.files;ge&&ge.length>0&&L(ge),p.current&&(p.current.value="")},[L]),ie=v.useCallback(re=>{if(s)return;const ge=E.filter((Se,pt)=>pt!==re);x(Se=>Se+1),P(ge),B(ge)},[s,E,B]),j=re=>{re.preventDefault(),m(!0)},U=()=>{m(!1)},le=re=>{re.preventDefault(),m(!1),re.dataTransfer.files?.length&&L(re.dataTransfer.files)},oe=o||h,G=[];(I||M)&&G.push(`Max size: ${Fo(M)}`),W&&z.length>0&&G.push(`Allowed types: ${z.join(", ")}`),N>1&&G.push(`Up to ${N} files`);const ae=e.appearance?.hideLabel??!1,Ae=v.useMemo(()=>{if(!c)return null;const re=Object.values(c);for(let ge=re.length-1;ge>=0;ge-=1){const Se=re[ge],pt=typeof Se?.status=="string"?Se.status.toLowerCase():null;if(pt&&pt!=="success")continue;const Dt=Se?.code;if(typeof Dt=="number"&&(Dt<200||Dt>=300))continue;const Bt=Se?.data,Ot=Bt?.file_url||Bt?.fileUrl||Se?.file_url||Se?.fileUrl;if(typeof Ot=="string"&&Ot.trim())return Ot}return null},[c]),ee=v.useCallback(re=>{window.open(re,"_blank","noopener,noreferrer")},[]),ne=v.useCallback(re=>{w(ge=>new Set(ge).add(re))},[]),he=E.length===0,Ie=E.length<N,Ue=yc(N,E.length);return d.jsx(At,{field:e,error:oe,isRequired:i,className:H(a,"!space-y-0"),hideLabel:ae,children:d.jsx("div",{className:H("min-h-[70px] min-w-0 w-full flex flex-col",f?"flex-1 h-full":"h-[70px]"),children:d.jsxs("div",{onClick:re=>{re.target.closest("[data-remove-in-dropzone]")||re.target.closest("[data-no-open-picker]")||X()},onDragOver:j,onDragLeave:U,onDrop:le,className:H("border-2 border-dashed rounded-lg p-1.5 text-center cursor-pointer transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",g&&"border-primary bg-primary/10",oe&&"border-destructive",s&&"opacity-50 cursor-not-allowed",!Ie&&E.length>0&&"cursor-default"),children:[d.jsx("input",{ref:p,id:ft(e),type:"file",accept:V,multiple:N>1,onChange:K,disabled:s||e.disabled||!Ie,className:"hidden","aria-describedby":Lt(e,!!oe),"aria-invalid":Jt(!!oe),"aria-required":i}),he?d.jsxs(d.Fragment,{children:[d.jsx(li,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),d.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:"Drag & drop or click"}),G.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:G.join(" • ")})]}):Ue?d.jsx(Sc,{item:E[0],objectUrl:C[0]??null,failedUrlKeys:S,onImageUrlError:ne,onRemove:()=>ie(0),onOpenUrl:ee,openTarget:E[0]instanceof File?Ae:void 0,disabled:s||e.disabled}):d.jsx(vc,{items:E,maxFiles:N,disabled:s,objectUrls:C,failedUrlKeys:S,onImageUrlError:ne,onRemove:ie,resolveOpenUrl:(re,ge)=>ge instanceof File&&E.length===1&&Ae?.trim()?Ae.trim():null,onOpenUrl:re=>{re?.trim()&&ee(re.trim())},addSlot:Ie?d.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:re=>{re.stopPropagation(),p.current?.click()},disabled:s||e.disabled,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center text-muted-foreground hover:border-primary hover:bg-primary/5 text-[10px] leading-tight px-0.5",children:[d.jsx(li,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})]})})})};function wk(e){const t=Sk(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(Ak);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function Sk(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=Ek(o),a=Ck(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var xk=Symbol("radix.slottable");function Ak(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xk}function Ck(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function Ek(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var oa="Dialog",[qh]=vr(oa),[Nk,Xr]=qh(oa),Yh=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=b.useRef(null),c=b.useRef(null),[u,f]=ln({prop:n,defaultProp:o??!1,onChange:s,caller:oa});return d.jsx(Nk,{scope:t,triggerRef:a,contentRef:c,contentId:hn(),titleId:hn(),descriptionId:hn(),open:u,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(l=>!l),[f]),modal:i,children:r})};Yh.displayName=oa;var Xh="DialogTrigger",kk=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(Xh,r),s=Qe(t,o.triggerRef);return d.jsx(je.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Cc(o.open),...n,ref:s,onClick:De(e.onClick,o.onOpenToggle)})});kk.displayName=Xh;var xc="DialogPortal",[_k,Jh]=qh(xc,{forceMount:void 0}),Qh=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,s=Xr(xc,t);return d.jsx(_k,{scope:t,forceMount:r,children:b.Children.map(n,i=>d.jsx(xr,{present:r||s.open,children:d.jsx(Oi,{asChild:!0,container:o,children:i})}))})};Qh.displayName=xc;var sa="DialogOverlay",Zh=b.forwardRef((e,t)=>{const r=Jh(sa,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Xr(sa,e.__scopeDialog);return s.modal?d.jsx(xr,{present:n||s.open,children:d.jsx(Fk,{...o,ref:t})}):null});Zh.displayName=sa;var Tk=wk("DialogOverlay.RemoveScroll"),Fk=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(sa,r);return d.jsx(zi,{as:Tk,allowPinchZoom:!0,shards:[o.contentRef],children:d.jsx(je.div,{"data-state":Cc(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),no="DialogContent",eg=b.forwardRef((e,t)=>{const r=Jh(no,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Xr(no,e.__scopeDialog);return d.jsx(xr,{present:n||s.open,children:s.modal?d.jsx(Pk,{...o,ref:t}):d.jsx(Ok,{...o,ref:t})})});eg.displayName=no;var Pk=b.forwardRef((e,t)=>{const r=Xr(no,e.__scopeDialog),n=b.useRef(null),o=Qe(t,r.contentRef,n);return b.useEffect(()=>{const s=n.current;if(s)return Gl(s)},[]),d.jsx(tg,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:De(e.onCloseAutoFocus,s=>{s.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:De(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:De(e.onFocusOutside,s=>s.preventDefault())})}),Ok=b.forwardRef((e,t)=>{const r=Xr(no,e.__scopeDialog),n=b.useRef(!1),o=b.useRef(!1);return d.jsx(tg,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(n.current||r.triggerRef.current?.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;r.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),tg=b.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Xr(no,r),c=b.useRef(null),u=Qe(t,c);return kl(),d.jsxs(d.Fragment,{children:[d.jsx(wi,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(vi,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Cc(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(Mk,{titleId:a.titleId}),d.jsx(Dk,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Ac="DialogTitle",rg=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(Ac,r);return d.jsx(je.h2,{id:o.titleId,...n,ref:t})});rg.displayName=Ac;var ng="DialogDescription",Ik=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(ng,r);return d.jsx(je.p,{id:o.descriptionId,...n,ref:t})});Ik.displayName=ng;var og="DialogClose",sg=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(og,r);return d.jsx(je.button,{type:"button",...n,ref:t,onClick:De(e.onClick,()=>o.onOpenChange(!1))})});sg.displayName=og;function Cc(e){return e?"open":"closed"}var ig="DialogTitleWarning",[vM,ag]=tx(ig,{contentName:no,titleName:Ac,docsSlug:"dialog"}),Mk=({titleId:e})=>{const t=ag(ig),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
47
47
 
48
48
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
49
49
 
50
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},Pk="DialogDescriptionWarning",Ok=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ig(Pk).contentName}}.`;return b.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Ik=qh,Mk=Jh,Lk=Qh,Dk=Zh,Bk=tg,$k=og;function ag({...e}){return d.jsx(Ik,{"data-slot":"dialog",...e})}function jk({...e}){return d.jsx(Mk,{"data-slot":"dialog-portal",...e})}function zk({className:e,...t}){return d.jsx(Lk,{"data-slot":"dialog-overlay",className:H("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function lg({className:e,children:t,showCloseButton:r=!0,...n}){return d.jsxs(jk,{"data-slot":"dialog-portal",children:[d.jsx(zk,{}),d.jsxs(Dk,{"data-slot":"dialog-content",className:H("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...n,children:[t,r&&d.jsxs($k,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[d.jsx(ns,{}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function cg({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-header",className:H("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Uk({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-footer",className:H("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function dg({className:e,...t}){return d.jsx(Bk,{"data-slot":"dialog-title",className:H("text-lg leading-none font-semibold",e),...t})}async function Vk(){const e={width:{ideal:1280},height:{ideal:720}},t=[{facingMode:{ideal:"environment"},...e},{facingMode:{ideal:"user"},...e},{...e},{}];let r;for(const n of t)try{return await navigator.mediaDevices.getUserMedia({video:Object.keys(n).length>0?n:!0,audio:!1})}catch(o){r=o}throw r instanceof Error?r:new Error("Could not access camera")}function ug(e){const t=()=>e.play();t().catch(()=>{requestAnimationFrame(()=>{t().catch(()=>{const r=()=>{t().catch(()=>{})};e.addEventListener("loadedmetadata",r,{once:!0}),e.addEventListener("canplay",r,{once:!0})})})})}const fg=({open:e,onOpenChange:t,onCaptured:r,validateFile:n,accept:o,disabled:s,onValidationMessage:i})=>{const a=v.useRef(null),c=v.useRef(null),u=v.useRef(null),f=v.useRef(null),[l,p]=v.useState(null),[g,m]=v.useState(!1),h=v.useCallback(()=>{a.current&&(a.current.srcObject=null)},[]),y=v.useCallback(()=>{u.current&&(u.current.getTracks().forEach(N=>N.stop()),u.current=null),h()},[h]);v.useEffect(()=>{if(!e){y(),p(null),m(!1);return}if(s)return;let N=!1;return p(null),m(!0),Vk().then(k=>{if(N){k.getTracks().forEach(T=>T.stop());return}u.current=k,m(!1)}).catch(k=>{if(N)return;m(!1);const T=k instanceof Error?k.message:"Could not access camera";p(T)}),()=>{N=!0,u.current&&(u.current.getTracks().forEach(k=>k.stop()),u.current=null),h()}},[e,s,y,h]);const S=v.useCallback(N=>{a.current=N,N&&u.current&&e&&!l&&!g&&(N.srcObject=u.current,ug(N))},[e,l,g]);v.useLayoutEffect(()=>{if(!e||l||g||!u.current)return;let N=!1,k=0;const T=()=>{if(N)return;const E=a.current;!E||!u.current||(E.srcObject=u.current,ug(E))};T();const P=requestAnimationFrame(()=>{T(),k=requestAnimationFrame(T)});return()=>{N=!0,cancelAnimationFrame(P),cancelAnimationFrame(k),h()}},[e,l,g,h]);const w=v.useCallback(()=>{y(),p(null),m(!1),t(!1),f.current&&(f.current.value="")},[y,t]),A=v.useCallback(()=>{const N=a.current,k=c.current;if(!N||!k||!u.current||N.readyState<2)return;const T=N.videoWidth,P=N.videoHeight;if(T===0||P===0)return;k.width=T,k.height=P;const E=k.getContext("2d");E&&(E.drawImage(N,0,0),k.toBlob(C=>{if(!C)return;const I=new File([C],`camera-capture-${Date.now()}.jpg`,{type:"image/jpeg",lastModified:Date.now()}),W=n(I);if(W){i?.(W);return}i?.(void 0),r(I),w()},"image/jpeg",.92))},[r,n,w,i]),x=v.useCallback(N=>{const k=N.target.files?.[0];if(!k)return;const T=n(k);if(T){i?.(T);return}i?.(void 0),r(k),w(),f.current&&(f.current.value="")},[r,n,w,i]),F=typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function";return d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:f,type:"file",accept:o,capture:"user",onChange:x,className:"hidden","aria-hidden":!0}),d.jsx("canvas",{ref:c,className:"hidden","aria-hidden":!0}),d.jsx(ag,{open:e,onOpenChange:N=>{N||w()},children:d.jsxs(lg,{className:"sm:max-w-md",showCloseButton:!0,onPointerDownOutside:N=>N.preventDefault(),children:[d.jsx(cg,{children:d.jsx(dg,{children:"Take a photo"})}),l?d.jsxs("div",{className:"space-y-3 py-2",children:[d.jsx("p",{className:"text-sm text-destructive",children:l}),F&&d.jsx("p",{className:"text-xs text-muted-foreground",children:"You can choose an image from your device instead."}),d.jsx(Zt,{type:"button",variant:"outline",className:"w-full",onClick:()=>f.current?.click(),children:"Choose from device"})]}):g?d.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Opening camera…"}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"relative rounded-lg overflow-hidden bg-black aspect-video",children:d.jsx("video",{ref:S,playsInline:!0,muted:!0,className:"w-full h-full object-cover"})}),d.jsxs(Uk,{className:"gap-2 sm:gap-0",children:[d.jsx(Zt,{type:"button",variant:"outline",onClick:w,children:"Cancel"}),d.jsx(Zt,{type:"button",onClick:A,children:"Capture photo"})]})]})]})})]})},Hk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const c=e.properties,[u,f]=v.useState(),[l,p]=v.useState(!1),[g,m]=v.useState(()=>new Set),[h,y]=v.useState("none"),S=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,w=e.validation?.find(j=>j.type==="fileSize"),A=e.validation?.find(j=>j.type==="fileType"),x=w?.value!=null?w.value:c?.maxSize??S?.maxSize??5*1024*1024,F=A?.value!=null?A.value:c?.accept??S?.accept??["image/*"],N=F.join(",")||"image/*",k=qs(e),T=v.useCallback(j=>{if(w){const U=rn(j,w);if(U!==!0)return typeof U=="string"?U:"File size exceeds the maximum allowed size"}else if(j.size>x)return`File size must be less than ${Fo(x)}`;if(A){const U=rn(j,A);if(U!==!0)return typeof U=="string"?U:"File type is not allowed"}return null},[w,A,x]),P=v.useMemo(()=>Ys(t),[t]),E=wc(P),C=v.useCallback(j=>{const U=Ja(j,k);r(U),n?.()},[r,n,k]),I=v.useCallback(j=>{const U=T(j);if(U){f(U);return}f(void 0);const le=[...P];le.length>=k||(le.push(j),C(le),y("none"))},[P,k,T,C]),W=v.useCallback(j=>{const U=P.filter((le,oe)=>oe!==j);C(U)},[P,C]),M=v.useCallback(()=>{s||P.length>=k||(f(void 0),y("camera"),p(!0))},[s,P.length,k]),z=v.useCallback(j=>{p(j),j||y("none")},[]),V=o||u,X=e.appearance?.hideLabel??!1,L=[];(w||x)&&L.push(`Max size: ${Fo(x)}`),A&&F.length>0&&L.push(`Allowed: ${F.join(", ")}`),k>1&&L.push(`Up to ${k} photos`);const B=v.useCallback(j=>{window.open(j,"_blank","noopener,noreferrer")},[]),D=P.length===0,K=P.length<k,ae=yc(k,P.length);return d.jsxs(At,{field:e,error:V,isRequired:i,className:H(a,"!space-y-0"),hideLabel:X,children:[d.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:d.jsx("div",{role:"button",tabIndex:s||!K?-1:0,id:ft(e),onClick:j=>{s||j.target.closest("[data-remove-in-dropzone]")||j.target.closest("[data-no-open-picker]")||P.length>=k||M()},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),!s&&K&&M())},className:H("border-2 border-dashed rounded-lg p-1.5 text-center cursor-pointer transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",V&&"border-destructive",s&&"opacity-50 cursor-not-allowed",l&&h==="camera"&&"opacity-70 pointer-events-none",!K&&P.length>0&&"cursor-default"),"aria-describedby":Lt(e,!!V),"aria-invalid":Jt(!!V),"aria-required":i,children:D?d.jsxs(d.Fragment,{children:[d.jsx(ni,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),d.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:l?"Opening camera…":"Click to open camera"}),L.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:L.join(" • ")})]}):ae?d.jsx(Sc,{item:P[0],objectUrl:E[0]??null,failedUrlKeys:g,onImageUrlError:j=>m(U=>new Set(U).add(j)),onRemove:()=>W(0),onOpenUrl:B,disabled:s}):d.jsx(vc,{items:P,maxFiles:k,disabled:s,objectUrls:E,failedUrlKeys:g,onImageUrlError:j=>m(U=>new Set(U).add(j)),onRemove:W,onOpenUrl:B,addSlot:K?d.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:j=>{j.stopPropagation(),M()},disabled:s,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center text-muted-foreground hover:border-primary hover:bg-primary/5 text-[10px] leading-tight px-0.5",children:[d.jsx(ni,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})})}),d.jsx(fg,{open:l,onOpenChange:z,onCaptured:I,validateFile:T,accept:N,disabled:s,onValidationMessage:f})]})},Wk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,buttonResponses:c})=>{const u=e.properties,f=v.useRef(null),[l,p]=v.useState(),[g,m]=v.useState(!1),[h,y]=v.useState(()=>new Set),[S,w]=v.useState("none"),A=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,x=e.validation?.find(ee=>ee.type==="fileSize"),F=e.validation?.find(ee=>ee.type==="fileType"),N=x?.value?x.value:u?.maxSize??A?.maxSize??5*1024*1024,k=F?.value?F.value:u?.accept??A?.accept??["image/*"],T=Array.isArray(k)?k.join(","):"image/*",P=qs(e),E=v.useCallback(ee=>{if(x){const ne=rn(ee,x);if(ne!==!0)return typeof ne=="string"?ne:"File size exceeds the maximum allowed size"}else if(ee.size>N)return`File size must be less than ${Fo(N)}`;if(F){const ne=rn(ee,F);if(ne!==!0)return typeof ne=="string"?ne:"File type is not allowed"}return null},[x,F,N]),C=v.useMemo(()=>Ys(t),[t]),I=wc(C),W=v.useCallback(ee=>{const ne=Ja(ee,P);r(ne),n?.()},[r,n,P]),M=v.useCallback(ee=>{p(void 0);const ne=Array.from(ee),he=[...C];let Ie=null;for(const Ue of ne){if(he.length>=P)break;const re=E(Ue);if(re){Ie||(Ie=re);continue}he.push(Ue)}if(Ie&&he.length===C.length){p(Ie);return}Ie&&p(Ie),W(he),w("none")},[C,P,E,W]),z=v.useCallback(ee=>{const ne=ee.target.files;ne&&ne.length>0&&M(ne),f.current&&(f.current.value="")},[M]),V=v.useCallback(ee=>{W(C.filter((ne,he)=>he!==ee))},[C,W]),X=v.useCallback(()=>{s||C.length>=P||g||(p(void 0),w("file"),f.current?.click())},[s,C.length,P,g]),L=v.useCallback(()=>{s||C.length>=P||(p(void 0),w("camera"),m(!0))},[s,C.length,P]),B=v.useCallback(ee=>{const ne=E(ee);if(ne){p(ne);return}p(void 0);const he=[...C];he.length>=P||(he.push(ee),W(he),w("none"))},[C,P,E,W]),D=v.useCallback(ee=>{m(ee),ee||w("none")},[]),K=o||l,ae=e.appearance?.hideLabel??!1,j=[];(x||N)&&j.push(`Max size: ${Fo(N)}`),F&&k.length>0&&j.push(`Allowed: ${k.join(", ")}`),P>1&&j.push(`Up to ${P} photos`);const U=v.useMemo(()=>{if(!c)return null;const ee=Object.values(c);for(let ne=ee.length-1;ne>=0;ne-=1){const he=ee[ne],Ie=typeof he?.status=="string"?he.status.toLowerCase():null;if(Ie&&Ie!=="success")continue;const Ue=he?.code;if(typeof Ue=="number"&&(Ue<200||Ue>=300))continue;const re=he?.data,ge=re?.file_url||re?.fileUrl||he?.file_url||he?.fileUrl;if(typeof ge=="string"&&ge.trim())return ge.trim()}return null},[c]),le=v.useCallback(ee=>{window.open(ee,"_blank","noopener,noreferrer")},[]),oe=C.length===0,G=C.length<P,ie=yc(P,C.length),Ce=G&&!g?d.jsxs("div",{"data-no-open-picker":!0,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center gap-0.5 text-muted-foreground",children:[d.jsx("button",{type:"button",disabled:s,onClick:ee=>{ee.stopPropagation(),X()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-t","aria-label":"Upload file",title:"Upload",children:d.jsx(si,{className:"h-4 w-4","aria-hidden":!0})}),d.jsx("button",{type:"button",disabled:s,onClick:ee=>{ee.stopPropagation(),L()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-b border-t border-border/50","aria-label":"Open camera",title:"Camera",children:d.jsx(ni,{className:"h-4 w-4","aria-hidden":!0})})]}):void 0;return d.jsxs(At,{field:e,error:K,isRequired:i,className:H(a,"!space-y-0"),hideLabel:ae,children:[d.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:d.jsxs("div",{className:H("border-2 border-dashed rounded-lg p-1.5 transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",K&&"border-destructive",s&&"opacity-50"),children:[d.jsx("input",{ref:f,id:ft(e),type:"file",accept:T,multiple:P>1,onChange:z,disabled:s||e.disabled||g||!G,className:"hidden","aria-describedby":Lt(e,!!K),"aria-invalid":Jt(!!K),"aria-required":i}),oe?d.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 w-full pointer-events-auto",children:[d.jsxs("div",{className:"flex items-center justify-center gap-3",children:[d.jsxs("button",{type:"button",disabled:s||g,onClick:X,className:H("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none"),children:[d.jsx(si,{className:"h-5 w-5","aria-hidden":!0}),d.jsx("span",{children:"Upload"})]}),d.jsxs("button",{type:"button",disabled:s,onClick:L,className:H("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none",g&&"opacity-70"),children:[d.jsx(ni,{className:"h-5 w-5","aria-hidden":!0}),d.jsx("span",{children:"Camera"})]})]}),j.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-2 text-center px-1",children:j.join(" • ")})]}):ie?d.jsx(Sc,{item:C[0],objectUrl:I[0]??null,failedUrlKeys:h,onImageUrlError:ee=>y(ne=>new Set(ne).add(ee)),onRemove:()=>V(0),onOpenUrl:le,openTarget:C[0]instanceof File?U:void 0,disabled:s||e.disabled}):d.jsx(vc,{items:C,maxFiles:P,disabled:s,objectUrls:I,failedUrlKeys:h,onImageUrlError:ee=>y(ne=>new Set(ne).add(ee)),onRemove:V,resolveOpenUrl:(ee,ne)=>ne instanceof File&&C.length===1&&U?U:null,onOpenUrl:ee=>{ee?.trim()&&le(ee.trim())},addSlot:Ce})]})}),d.jsx(fg,{open:g,onOpenChange:D,onCaptured:B,validateFile:E,accept:T,disabled:s,onValidationMessage:p})]})};function Rk(e){if(e==null||typeof e!="object")return;const t=e;if(typeof t.message=="string"&&t.message.trim())return t.message.trim();if(typeof t.display_message=="string"&&t.display_message.trim())return t.display_message.trim();if(t.data&&typeof t.data=="object"){const r=t.data;if(typeof r.message=="string"&&r.message.trim())return r.message.trim();if(typeof r.success_message=="string"&&r.success_message.trim())return r.success_message.trim();if(typeof r.display_message=="string"&&r.display_message.trim())return r.display_message.trim()}if(typeof t.success_message=="string"&&t.success_message.trim())return t.success_message.trim()}function pg(e,t){try{const r=Rk(e);ct.toast.success(r&&r.trim()?r:t)}catch{ct.toast.success(t)}}function ia(e,t,r){try{const n=r(e);ct.toast.error(n&&n.trim()?n:t)}catch{ct.toast.error(t)}}function Gk(e){const t=e.headers,r=["X-Message","X-Success-Message","X-Toast-Message","X-Success-Msg"];for(const n of r){const o=t.get(n);if(o&&typeof o=="string"&&o.trim())return o.trim()}}const aa="This field is required";function mg(e,t){if(!t?.length)return e;const r=t.find(n=>n.name===e);return r?.label&&r.label.trim()||e}function la(e,t){if(!e)return"Please complete the required fields.";if(Array.isArray(e)){const s=e.map(i=>{const a=i.message||aa;if(t?.length&&i.field){const c=mg(i.field,t);return a===aa?`${c} is required`:`${c}: ${a}`}return a}).filter(i=>typeof i=="string"&&i.length>0);return s.length===0?"Please complete the required fields.":s.length===1?s[0]:`${s[0]} (and ${s.length-1} more)`}const n=Object.entries(e).map(([o,s])=>{const i=s?.trim()||aa;if(t?.length){const a=mg(o,t);return i===aa?`${a} is required`:`${a}: ${i}`}return i}).filter(o=>typeof o=="string"&&o.length>0);return n.length===0?"Please complete the required fields.":n.length===1?n[0]:`${n[0]} (and ${n.length-1} more)`}function hg(e){if(e==null||typeof e!="object")return!1;const t=e;if(t.status==="error")return!0;const r=t.code;return typeof r=="number"&&(r<200||r>=300)}function Kk(e){return!hg(e)}function qk(e,t,r){if(!t||!Kk(e))return;const n=t.fieldMapping;if(n&&Object.keys(n).length>0)for(const[s,i]of Object.entries(n)){if(!s.trim()||!i?.trim())continue;const a=Ge(e,i.trim());a!=null&&r.setFieldValue(s.trim(),a)}const o=t.contextMapping;if(o&&Object.keys(o).length>0&&r.onContextUpdate){const s={};for(const[i,a]of Object.entries(o)){if(!i.trim()||!a?.trim())continue;const c=Ge(e,a.trim());c!=null&&(s[i.trim()]=c)}Object.keys(s).length>0&&r.onContextUpdate(s)}}function Yk(e=Kn){const{totalSteps:t,currentStep:r}=e.getState();return t>1&&r<t-1}async function Ec(e,t=Kn){const r=await t.getState().nextStep();if(!r)try{const n=t.getState(),o=n.errors;Object.keys(o).length>0?ct.toast.error(la(o,e)||"Please fix the errors before continuing."):n.totalSteps<=1||n.currentStep>=n.totalSteps-1?ct.toast.error("You are already on the last page."):ct.toast.error("Please fix the errors before continuing.")}catch{ct.toast.error("Please fix the errors before continuing.")}return r}function Xk(e=Kn){e.getState().prevStep()}const Jk=3;function Po(e){if(typeof e=="number"&&!Number.isNaN(e))return e}function Oo(e,t){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;return Po(r?.cellSlot)??Po(r?.stackSlot)??Po(r?.cellSlotIndex)??Po(r?.slotIndex)??Po(t?.cellSlotIndex)??Po(t?.stackSlot)}function ws(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;if(t?.sharedCellLayout==="row"||t?.sharedCellLayout==="stack")return t.sharedCellLayout;if(t?.stackDirection==="horizontal")return"row";if(t?.stackDirection==="vertical")return"stack"}function ca(e){const t=typeof e.position?.order=="number"?e.position.order:-1,r=typeof e.position?.column=="number"?e.position.column:1,n=e.position?.cellGroupId??"_";return`${t}:${r}:${n}`}function Nc(e){return[...e].sort((t,r)=>{const n=Oo(t.position),o=Oo(r.position);return typeof n=="number"&&typeof o=="number"&&n!==o?n-o:String(t.id).localeCompare(String(r.id))})}function Ss(e,t){if(e.length===0)return{rowSpan:1,columnSpan:1};let r=1,n=1;for(const o of e)r=Math.max(r,qo(o)),n=Math.max(n,Xd(o,t));return{rowSpan:r,columnSpan:n}}function gg(e){const t=Nc(e);for(const r of t){const n=ws(r.position);if(n)return n}return t.length>=2?"row":"stack"}function yg(e){return Nc(e).slice(0,Jk)}function Qk(e,t){const r=new Map;for(const n of e){if(!t(n)||typeof n.position?.order!="number")continue;const o=ca(n),s=r.get(o)??[];s.push(n),r.set(o,s)}return Array.from(r.values()).map(n=>yg(n))}function bg(e,t,r,n){const o=r.filter(a=>n(a)&&typeof a.position?.order=="number"&&a.position.order===e&&(a.position.column??1)===t+1);if(o.length===0)return[];const s=new Map;for(const a of o){const c=ca(a),u=s.get(c)??[];u.push(a),s.set(c,u)}const i=[...s.values()][0]??[];return yg(i)}function Zk(e,t,r,n){const o=r[0],s=o.position?.order,i=o.position?.column??1;if(typeof s!="number")return!1;const{rowSpan:a,columnSpan:c}=Ss(r,n),u=e===s&&t===i-1,f=e>=s&&e<s+a,l=t>=i-1&&t<i-1+c;return f&&l&&!u}function e_(e,t,r){const n=new Set(r??[]);for(const o of e){const s=o[0]?.position?.order??0,{rowSpan:i}=Ss(o,t);for(let a=s;a<s+i;a++)n.add(a)}return n}function t_(e){const t=[...e].sort((n,o)=>n-o),r=new Map;return t.forEach((n,o)=>r.set(n,o)),{originalToDisplay:r,displayRowCount:Math.max(t.length,1),sortedOriginalRows:t}}function r_(e,t,r){const n=r.get(e);if(n===void 0)return;let o=0;for(let s=e;s<e+t&&r.has(s);s++)o++;return`${n+1} / span ${Math.max(o,1)}`}function hr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Io(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>Io(r));if(!hr(e))return e;const t={};for(const[r,n]of Object.entries(e))t[r]=Io(n);return t}function vg(e,...t){const r={...e};for(const n of t)if(!(!n||!hr(n)))for(const[o,s]of Object.entries(n)){const i=r[o];hr(s)&&hr(i)?r[o]=vg(i,s):r[o]=s}return r}function oo(e){return hr(e)?e:{}}function xs(e){if(e==null)return{};if(typeof e=="string"){const t=e.trim();if(!t)return{};try{const r=JSON.parse(t);return hr(r)?Io(r):{}}catch{return{}}}return hr(e)?Io(e):{}}function wg(e){const t=e.apidata;return hr(t)&&Object.keys(t).length>0}function n_(e){if(typeof e.metadata=="string"&&e.metadata.trim()!==""||typeof e.metadata=="object"&&e.metadata!==null&&!Array.isArray(e.metadata)&&Object.keys(e.metadata).length>0||wg(e))return!0;const t=e.fieldKey,r=e.fieldType,n=e.name,o=e.type;return!!(t&&(!n||String(n).trim()==="")||r&&(!o||String(o).trim()==="")||t&&n&&t!==n||r&&o&&r!==o||!n&&e.key&&typeof e.key=="string")}const Sg=["hideLabel","contentAlign","contentVerticalAlign","labelPlacement","widthPercent","widthMode","className","verticalAlign","horizontalAlign","cellAlign","cellJustify","size","variant","minWidth","minHeight"];function o_(e,t){const r=e.appearance,n=hr(r)&&Object.keys(r).length>0?Io(r):{},o=oo(t.appearance),s={...n};for(const[i,a]of Object.entries(o))i!=="heightPercent"&&s[i]===void 0&&(s[i]=Io(a));for(const i of Sg)s[i]===void 0&&t[i]!==void 0&&(s[i]=t[i]);return delete s.heightPercent,Object.keys(s).length>0?s:void 0}function s_(e,t){const r=oo(e.position),n=xs(e.metadata),o=oo(e.layout),s=typeof r.order=="number"&&!Number.isNaN(r.order)?r.order:typeof e.positionOrder=="number"?e.positionOrder:typeof e.order=="number"?e.order:typeof e.positionRow=="number"?e.positionRow:t,i=typeof r.column=="number"&&!Number.isNaN(r.column)?r.column:typeof e.positionColumn=="number"?e.positionColumn:1,a=typeof r.columnSpan=="number"&&!Number.isNaN(r.columnSpan)?r.columnSpan:typeof e.positionWidth=="number"?e.positionWidth:1,c=typeof r.rowSpan=="number"&&!Number.isNaN(r.rowSpan)?r.rowSpan:typeof e.positionRowSpan=="number"?e.positionRowSpan:1,u={order:s,column:i,columnSpan:a,rowSpan:c},f=r.cellGroupId??o.cellGroupId,l=Oo(r,{cellSlotIndex:e.cellSlotIndex??o.cellSlotIndex,stackSlot:n.stackSlot??o.stackSlot}),p=ws(r)??ws(o)??(n.stackDirection==="horizontal"||o.stackDirection==="horizontal"?"row":n.stackDirection==="vertical"||o.stackDirection==="vertical"?"stack":void 0);return typeof f=="string"&&(u.cellGroupId=f),typeof l=="number"&&(u.cellSlot=l),(p==="row"||p==="stack")&&(u.sharedCellLayout=p),u}function i_(e,t){const r=e,n=xs(r.metadata),o=oo(r.apidata),s=oo(r.properties),i=vg({},n,o,s),a=(r.name!=null&&String(r.name).trim()!==""?r.name:void 0)??(typeof r.fieldKey=="string"?r.fieldKey:void 0)??(typeof r.key=="string"?r.key:void 0),c=(r.type!=null&&String(r.type).trim()!==""?r.type:void 0)??(typeof r.fieldType=="string"?r.fieldType:void 0),u=o_(r,n),f=s_(r,t),l={...r};return l.properties=i,a!==void 0&&(l.name=a),c!==void 0&&(l.type=c),u!==void 0?l.appearance=u:(!hr(r.appearance)||Object.keys(r.appearance).length===0)&&delete l.appearance,l.position=f,hr(l.appearance)&&delete l.appearance.heightPercent,l}function a_(e,t){if(!e||typeof e!="object")return!0;const r=e,n=xs(r.metadata),o=Object.keys(n).length===0&&!(typeof r.metadata=="string"&&r.metadata.trim()!==""),s=!wg(r);if(n_(r)||!o||!s)return!1;const i=r.position;return!(!(hr(i)&&typeof i.order=="number"&&!Number.isNaN(i.order))&&(typeof r.positionRow=="number"||typeof r.positionColumn=="number"||typeof r.positionWidth=="number"||typeof r.positionRowSpan=="number"||typeof r.positionOrder=="number")||hr(n.appearance)||Sg.some(u=>n[u]!==void 0&&(r.appearance==null||hr(r.appearance)&&r.appearance[u]===void 0))||l_(r))}function l_(e){const t=oo(e.position),r=oo(e.layout),n=xs(e.metadata);return(typeof e.cellSlotIndex=="number"||typeof t.stackSlot=="number"||typeof t.cellSlot=="number"||typeof t.cellSlotIndex=="number"||typeof n.stackSlot=="number"||typeof r.stackSlot=="number")&&typeof t.cellSlot!="number"||(t.stackDirection==="horizontal"||t.stackDirection==="vertical"||n.stackDirection==="horizontal"||n.stackDirection==="vertical"||r.stackDirection==="horizontal"||r.stackDirection==="vertical")&&t.sharedCellLayout!=="row"&&t.sharedCellLayout!=="stack"}function da(e){if(e==null||typeof e!="object")return e;const t=e.fields;if(!Array.isArray(t))return e;let r=!1;const n=t.map((o,s)=>{if(a_(o))return o;const i=i_(o,s);return i!==o&&(r=!0),i});return r?{...e,fields:n}:e}function c_(e){return da(e)}function d_(e){const t=e.steps;if(!Array.isArray(t)||t.length<2)return;const r=[];for(const n of t){if(!n||typeof n!="object")continue;const o=n,s=typeof o.id=="string"&&o.id.trim()?o.id.trim():void 0,i=typeof o.name=="string"&&o.name.trim()?o.name.trim():void 0,a=Array.isArray(o.fields)?o.fields.filter(c=>typeof c=="string"&&c.trim()!==""):[];!s||!i||r.push({id:s,name:i,...typeof o.description=="string"&&o.description.trim()?{description:o.description.trim()}:{},fields:a,validation:o.validation==="onSubmit"?"onSubmit":"onNext"})}return r.length>=2?r:void 0}function kc(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function xg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Ag(e,t){const r=e.form;if(!r)throw new Error("workflowStateToFormSchema requires workflowState.form to be set");const n=r.fields.filter(l=>l!=null&&l!==void 0).map((l,p)=>{if(!l||typeof l!="object")return null;const g={...l};if(l.fieldType&&!g.type&&(g.type=l.fieldType),l.fieldKey&&!g.key&&!g.name&&(g.key=l.fieldKey,g.name=l.fieldKey),typeof l.positionOrder=="number"&&!isNaN(l.positionOrder)?g.order=l.positionOrder:g.order=p,(typeof g.order!="number"||isNaN(g.order))&&(g.order=p),l.options&&typeof l.options=="string")try{g.options=JSON.parse(l.options)}catch{}if(l.metadata&&typeof l.metadata=="string")try{g.metadata=JSON.parse(l.metadata)}catch{}return g}).filter(l=>l!=null).sort((l,p)=>{const g=typeof l.order=="number"?l.order:0,m=typeof p.order=="number"?p.order:0;return g-m});n.forEach((l,p)=>{(!l||typeof l.order!="number"||isNaN(l.order))&&(l.order=p)});let o=r.layout;if(o){const l={...o};if(l.breakpoints&&typeof l.breakpoints=="string")try{l.breakpoints=JSON.parse(l.breakpoints)}catch{}if(l.responsiveConfig&&typeof l.responsiveConfig=="string")try{l.responsiveConfig=JSON.parse(l.responsiveConfig)}catch{}o=l}const s=n.filter(l=>l!=null&&typeof l=="object"&&typeof l.order=="number"&&!isNaN(l.order));let i={};const a=r.config;if(a!=null)if(typeof a=="string")try{i=JSON.parse(a)}catch{}else typeof a=="object"&&a!==null&&(i={...a});const c=l=>{let p={...l};if(l.conditionExpression&&typeof l.conditionExpression=="string")try{p={...l,conditionExpression:JSON.parse(l.conditionExpression)}}catch{}if(p.targetFieldId){const g=s.find(m=>m._id===p.targetFieldId||m.id===p.targetFieldId||m.fieldKey===p.targetFieldId);if(g){const m=g.key||g.fieldKey||g.name,h=g._id||g.id||p.targetFieldId;p.targetFieldKey=m,p.targetField=m,p.targetFieldById=h}}return p},u=d_(r),f={id:r._id,name:r.name,description:r.description??"",version:r.version,status:r.status,fields:s.map((l,p)=>{const g=l,m=typeof l.metadata=="object"&&l.metadata!==null?l.metadata:{},h=m.hidden===!0||l.hidden===!0,y={id:l._id||l.id||l.fieldKey,type:l.type||l.fieldType,label:l.label,key:l.key||l.fieldKey||l.name,name:l.name||l.fieldKey||l.key};if(h&&(y.hidden=!0),y.id||(y.id=y.key||y.name),y.key||(y.key=y.id||y.name),y.name||(y.name=y.key||y.id),l.isRequired!==void 0&&(y.required=l.isRequired),l.placeholder&&(y.placeholder=l.placeholder),l.options&&Array.isArray(l.options)&&(y.options=l.options),l.apidata&&(y.apidata=l.apidata),g.appearance&&typeof g.appearance=="object"&&!Array.isArray(g.appearance)&&Object.keys(g.appearance).length>0&&(y.appearance=kc(g.appearance)),g.ui!==void 0&&(y.ui=kc(g.ui)),g.visibility!==void 0&&(y.visibility=kc(g.visibility)),m.disabled!==void 0&&(y.disabled=m.disabled),m.readOnly!==void 0&&(y.readOnly=m.readOnly),m.hideLabel!==void 0&&(y.hideLabel=m.hideLabel,y.properties||(y.properties={}),y.properties.hideLabel=m.hideLabel,y.appearance||(y.appearance={}),y.appearance.hideLabel=m.hideLabel),(l.type==="file"||l.fieldType==="file"||l.type==="camera"||l.fieldType==="camera"||l.type==="photoChoice"||l.fieldType==="photoChoice")&&l.validationRules){const E=l.validationRules,C={...m};if(E.fileSize!==void 0&&(C.maxSize=E.fileSize),E.fileType&&Array.isArray(E.fileType)){const I=[];E.fileType.forEach(W=>{const M=W.startsWith(".")?W:`.${W}`;I.push(M),M===".csv"?I.push("text/csv"):M===".xls"?I.push("application/vnd.ms-excel"):M===".xlsx"&&I.push("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}),C.accept=I}y.metadata=C,C.maxSize!==void 0&&(y.maxSize=C.maxSize),C.accept!==void 0&&(y.accept=C.accept)}else if(m&&Object.keys(m).length>0){if(y.metadata=m,(l.type==="toggle"||l.fieldType==="toggle")&&(m.onValue!==void 0&&(y.onValue=m.onValue),m.offValue!==void 0&&(y.offValue=m.offValue),m.onText!==void 0&&(y.onText=m.onText),m.offText!==void 0&&(y.offText=m.offText)),(l.type==="button"||l.fieldType==="button")&&m.action==="download"&&m.downloadApiEndpoint&&typeof m.downloadApiEndpoint=="string"){let E=m.downloadApiEndpoint;E=E.replace(/\{ctx:([^}]+)\}/g,(C,I)=>{const W=t[I];return W!==void 0?String(W):C}),m.downloadApiEndpoint=E,y.metadata=m,y.downloadApiEndpoint=E}if((l.type==="button"||l.fieldType==="button")&&m.action==="submit"){const E=y.properties||{};m.submitAction!==void 0&&(E.submitAction=m.submitAction),m.submitApiMethod!==void 0&&(E.submitApiMethod=m.submitApiMethod),m.apiBodyStructure!==void 0&&(E.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(E.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(E.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiBodyFields!==void 0&&(E.apiBodyFields=m.apiBodyFields),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.action!==void 0&&(E.action=m.action),m.variant!==void 0&&(E.variant=m.variant),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint&&(E.apiEndpoint=l.apidata.apiEndpoint),y.properties=E}if((l.type==="button"||l.fieldType==="button")&&(m.action==="upload"||m.action==="custom")){const E=y.properties||{};m.action!==void 0&&(E.action=m.action),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.variant!==void 0&&(E.variant=m.variant),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),m.uploadAction!==void 0&&(E.uploadAction=m.uploadAction),m.uploadApiEndpoint!==void 0&&(E.uploadApiEndpoint=m.uploadApiEndpoint),m.uploadApiMethod!==void 0&&(E.uploadApiMethod=m.uploadApiMethod),m.apiBodyStructure!==void 0&&(E.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(E.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(E.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiFieldMapping!==void 0&&(E.apiFieldMapping=m.apiFieldMapping),m.apiQueryParams!==void 0&&(E.apiQueryParams=m.apiQueryParams),m.apiBodyFields!==void 0&&(E.apiBodyFields=m.apiBodyFields),m.apiHeaders!==void 0&&(E.apiHeaders=m.apiHeaders),y.properties=E}if(l.type==="status"||l.fieldType==="status"){const E=y.properties||{};if(m.source!==void 0&&(E.source=m.source),m.statuses!==void 0&&(E.statuses=m.statuses),m.dataPath!==void 0&&(E.dataPath=m.dataPath),m.showStatusText!==void 0&&(E.showStatusText=m.showStatusText),m.statusTextPath!==void 0&&(E.statusTextPath=m.statusTextPath),m.showCurrentIndicator!==void 0&&(E.showCurrentIndicator=m.showCurrentIndicator),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint){let C=l.apidata.apiEndpoint;C=C.replace(/\{ctx:([^}]+)\}/g,(I,W)=>{const M=t[W];return M!==void 0?String(M):I}),E.apiEndpoint=C,E.source===void 0&&(E.source="api")}l.apidata?.apiMethod!==void 0&&(E.apiMethod=l.apidata.apiMethod),y.properties=E}if(l.type==="addmore"||l.fieldType==="addmore"){const E=y.properties||{};m.linkedFieldNames!==void 0&&(E.linkedFieldNames=m.linkedFieldNames),m.linkedSectionIds!==void 0&&(E.linkedSectionIds=m.linkedSectionIds),m.linkedFieldAllowDuplicate!==void 0&&(E.linkedFieldAllowDuplicate=m.linkedFieldAllowDuplicate),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.variant!==void 0&&(E.variant=m.variant),m.size!==void 0&&(E.size=m.size),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),y.properties=E}if(l.type==="selectablelist"||l.fieldType==="selectablelist"){const E=y.properties||{};m.submitFieldMapping!==void 0&&(E.submitFieldMapping=m.submitFieldMapping),m.displayFields!==void 0&&(E.displayFields=m.displayFields),m.displayFieldsSeparator!==void 0&&(E.displayFieldsSeparator=m.displayFieldsSeparator),m.dataSourceContextKey!==void 0&&(E.dataSourceContextKey=m.dataSourceContextKey),m.showSelectAll!==void 0&&(E.showSelectAll=m.showSelectAll),m.selectAllByDefault!==void 0&&(E.selectAllByDefault=m.selectAllByDefault),y.properties=E}}l.validationRules&&l.type!=="file"&&l.fieldType!=="file"&&l.type!=="camera"&&l.fieldType!=="camera"&&l.type!=="photoChoice"&&l.fieldType!=="photoChoice"&&l.type!=="status"&&l.fieldType!=="status"&&(y.validationRules=l.validationRules),typeof l.order=="number"&&(y.order=l.order);const S=l,w=xg(S.position),A=l.metadata&&typeof l.metadata=="object"&&!Array.isArray(l.metadata)?l.metadata:{},x=xg(S.layout),N={order:typeof S.positionOrder=="number"?S.positionOrder:l.order??p,column:typeof w.column=="number"?w.column:typeof S.positionColumn=="number"?S.positionColumn:1,columnSpan:typeof w.columnSpan=="number"?w.columnSpan:typeof w.width=="number"?w.width:typeof S.positionWidth=="number"?S.positionWidth:1,rowSpan:typeof w.rowSpan=="number"?w.rowSpan:typeof S.positionRowSpan=="number"?S.positionRowSpan:1},k=Oo(w,{cellSlotIndex:S.cellSlotIndex??x.cellSlotIndex,stackSlot:A.stackSlot??x.stackSlot});typeof k=="number"&&(N.cellSlot=k);const T=w.cellGroupId??x.cellGroupId;typeof T=="string"&&(N.cellGroupId=T);const P=ws(w)??ws(x)??(A.stackDirection==="horizontal"||x.stackDirection==="horizontal"?"row":A.stackDirection==="vertical"||x.stackDirection==="vertical"?"stack":void 0);return(P==="row"||P==="stack")&&(N.sharedCellLayout=P),y.position=N,l.conditions&&Array.isArray(l.conditions)&&(y.conditions=l.conditions),y}).filter(l=>l!=null).sort((l,p)=>{const g=typeof l.order=="number"?l.order:0,m=typeof p.order=="number"?p.order:0;return g-m}),config:{...i,layout:o,...r.rules&&r.rules.length>0&&{rules:r.rules.map(c)},...r.clientMapping&&Object.keys(r.clientMapping).length>0&&{clientMapping:r.clientMapping}},...r.rules&&r.rules.length>0&&{rules:r.rules.map(c)},createdAt:"",updatedAt:"",moduleId:"",...u?{steps:u}:{}};return da(f)}function vn({className:e,size:t="md",text:r="Loading...",fullScreen:n=!1}){const o={sm:"h-6 w-6",md:"h-12 w-12",lg:"h-16 w-16"},s=d.jsxs("div",{className:"text-center",children:[d.jsx("div",{className:H("animate-spin rounded-full border-b-2 border-blue-600 mx-auto mb-4",o[t],e)}),r&&d.jsx("p",{className:"text-gray-600",children:r})]});return n?d.jsx("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50 flex items-center justify-center",children:s}):s}function u_(e,t){if(!e?.url)return;let r=e.url;if(r.startsWith("http://")||r.startsWith("https://"))try{const s=new URL(r);r=s.pathname+s.search}catch{}const n=t?.()??{},o={...e.headers||{},"Content-Type":"application/json",...n};return{...e,url:r,headers:o}}const Cg=({open:e,onOpenChange:t,title:r,mode:n,loading:o=!1,workflowState:s,formSchema:i,formDefinitionId:a,submissionContext:c={},onWorkflowSubmitResult:u,getAuthHeaders:f})=>{const l=v.useMemo(()=>{if(n==="form"&&i)return i;if(n==="workflow"&&s?.form){const g=Object.fromEntries(Object.entries(c).map(([y,S])=>[y,S==null?"":String(S)])),m=Ag(s,g),h=u_(s.BFF_submit_api,f);return h?{...m,status:"published",BFF_submit_api:h}:m}return null},[n,i,s,c,f]),p=s?.step_blocked_message;return d.jsx(ag,{open:e,onOpenChange:t,children:d.jsxs(lg,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[r?d.jsx(cg,{children:d.jsx(dg,{children:r})}):null,d.jsxs("div",{className:"relative min-h-[12rem]",children:[o&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:d.jsx(vn,{})}),p&&d.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:p}),l?d.jsx(il,{children:d.jsx(Ps,{schema:l,submissionContext:c,onWorkflowSubmitResult:u,onClose:()=>t(!1),workflowStepId:s?.current_step_id,omitRootWrapper:!0})}):a&&n==="form"?d.jsx(il,{children:d.jsx(Ps,{formId:a,submissionContext:c,onClose:()=>t(!1),omitRootWrapper:!0})}):!o&&d.jsx("p",{className:"text-sm text-muted-foreground",children:n==="workflow"?"No form available for this step.":"Form could not be loaded."})]})]})})},Eg=v.createContext(null);function Ng(){return v.useContext(Eg)}function _c(e,t){if(!e?.length||!t)return{};const r={};return e.forEach(n=>{t[n]!==void 0&&(r[n]=t[n])}),r}const kg=({handlers:e,moduleId:t,submissionContext:r={},getAuthHeaders:n,onParentWorkflowSubmitResult:o,children:s})=>{const[i,a]=v.useState(!1),[c,u]=v.useState(),[f,l]=v.useState("workflow"),[p,g]=v.useState(null),[m,h]=v.useState(null),[y,S]=v.useState(),[w,A]=v.useState({}),[x,F]=v.useState(!1),N=v.useMemo(()=>({...r,...w}),[r,w]),k=v.useCallback(()=>{a(!1),g(null),h(null),S(void 0),A({})},[]),T=v.useCallback(async(W,M)=>{if(!W.workflowId?.trim())throw new Error("workflowId is required for openWorkflowModal");const z=_c(W.passFields,M);F(!0),u(W.modalTitle),l("workflow"),A(z);try{const V=await e.getWorkflowStateById({workflowId:W.workflowId.trim(),moduleId:t,entryStepId:W.entryStepId?.trim()||void 0,passContext:z});g(V),h(null),S(void 0),a(!0)}finally{F(!1)}},[e,t]),P=v.useCallback(async(W,M)=>{if(!W.formDefinitionId?.trim())throw new Error("formDefinitionId is required for openFormModal");const z=_c(W.passFields,M);F(!0),u(W.modalTitle),l("form"),A(z),g(null);try{if(e.getFormSchemaById){const V=await e.getFormSchemaById(W.formDefinitionId.trim());h(V),S(void 0)}else h(null),S(W.formDefinitionId.trim());a(!0)}finally{F(!1)}},[e]),E=v.useCallback(async(W,M)=>{const z=M?.workflowId?.trim()||p?.workflow_id||"";if(!z||!W?.trim())throw new Error("workflowId and targetStepId are required for gotoStep");const V={...w,..._c(void 0,M?.formValues)};F(!0);try{const X=await e.navigateWorkflowStep({workflowId:z,moduleId:t,targetStepId:W.trim(),passContext:V});i?(g(X),l("workflow"),h(null),S(void 0)):o?.(X)}finally{F(!1)}},[e,t,w,i,p?.workflow_id,o]),C=v.useCallback(async W=>{o?.(W);const M=p?.workflow_id;if(M)try{const z=await e.getWorkflowStateById({workflowId:M,moduleId:t,passContext:w});g(z)}catch{}},[e,t,w,o,p?.workflow_id]),I=v.useMemo(()=>({isModalActive:i,openWorkflowModal:T,openFormModal:P,navigateToStep:E}),[i,T,P,E]);return d.jsxs(Eg.Provider,{value:I,children:[s,d.jsx(Cg,{open:i,onOpenChange:W=>{W||k()},title:c,mode:f,loading:x,workflowState:p,formSchema:m,formDefinitionId:y,submissionContext:N,onWorkflowSubmitResult:C,getAuthHeaders:n})]})};function Tc(e,t){if(!t?.length)return e;const r=new Map;for(const o of t){const s=o.name||o.key||o.id;s&&r.set(s,o)}const n={};for(const[o,s]of Object.entries(e)){const i=r.get(o);if(i?.type==="selectablelist"&&Array.isArray(s)&&s.length>0){const a=i.properties,c=i.metadata,u=typeof c=="object"&&c!==null?c:null,f=a?.submitFieldMapping??u?.submitFieldMapping;if(f&&typeof f=="object"&&Object.keys(f).length>0){const l=s.map(p=>{if(p==null||typeof p!="object")return p;const g={};for(const[m,h]of Object.entries(f))m!=null&&m!==""&&h!=null&&h!==""&&(g[m]=Ge(p,h));return g});n[o]=l;continue}}n[o]=s}return n}function ua(e){return!!(e instanceof File||Array.isArray(e)&&e.length>0&&e[0]instanceof File)}function f_(e){return Object.values(e).some(t=>ua(t))}function p_(e,t){const r=new FormData;let n=!1;return Object.entries(e).forEach(([o,s])=>{const i=t?.[o]||o;s instanceof File?(r.append(i,s),n=!0):Array.isArray(s)&&s.length>0&&s[0]instanceof File?(s.forEach(a=>{r.append(i,a)}),n=!0):s!=null&&(typeof s=="object"?r.append(i,JSON.stringify(s)):r.append(i,String(s)))}),n?r:null}function m_(e,t,r){const n={};let o=!1;return Object.entries(e).forEach(([s,i])=>{const a=t?.[s]||s;if(ua(i)){n[a]=i,o=!0;return}const c=r?.[s]||"string";let u=i;if(c==="number"){const f=Number(i);u=isNaN(f)?i:f}else c==="boolean"?u=i==="true"||i===!0||i==="1"||i===1:c==="date"?u=String(i):i!=null?u=typeof i=="object"?i:String(i):u="";n[a]=u}),{transformed:n,hasFiles:o}}const _g=Object.freeze(Object.defineProperty({__proto__:null,hasFileValues:f_,isFileValue:ua,prepareFormDataWithFiles:p_,transformFormValuesWithFiles:m_},Symbol.toStringTag,{value:"Module"}));function h_(e){if(!e||typeof e!="object")return;const t=e;return(t.mode==="nested_by_section"?"nested_by_section":"flat")==="flat"?{mode:"flat"}:{mode:"nested_by_section",includeUnassignedAtRoot:t.includeUnassignedAtRoot!==!1}}function g_(e){if(!Array.isArray(e))return;const t=[];for(const r of e){if(!r||typeof r!="object")continue;const n=r,o=typeof n.id=="string"&&n.id.trim()?n.id.trim():"",s=typeof n.name=="string"&&n.name.trim()?n.name.trim():"";if(!o||!s)continue;const i=Array.isArray(n.fieldNames)?[...new Set(n.fieldNames.filter(u=>typeof u=="string"&&u.trim().length>0).map(u=>u.trim()))]:[],a=typeof n.payloadKey=="string"&&n.payloadKey.trim()?n.payloadKey.trim():void 0;let c;if(n.fieldPayloadKeys&&typeof n.fieldPayloadKeys=="object"&&!Array.isArray(n.fieldPayloadKeys)){c={};for(const[u,f]of Object.entries(n.fieldPayloadKeys))typeof f=="string"&&f.trim()&&(c[u]=f.trim());Object.keys(c).length===0&&(c=void 0)}t.push({id:o,name:s,fieldNames:i,...n.showBorder===!0?{showBorder:!0}:{},...n.collapsible===!0?{collapsible:!0}:{},...n.defaultCollapsed===!0?{defaultCollapsed:!0}:{},...a?{payloadKey:a}:{},...c?{fieldPayloadKeys:c}:{},...n.heading&&typeof n.heading=="object"?{heading:n.heading}:{}})}return t.length>0?t:void 0}function Tg(e){return e?.mode==="nested_by_section"}function Fg(e){const t=e.payloadKey?.trim();return t||null}function Pg(e,t){return t.fieldPayloadKeys?.[e]?.trim()||e}function Og(e,t,r,n){if(!Tg(r)||!t?.length)return{...e};const o=new Set([]),s=r?.includeUnassignedAtRoot!==!1,i=new Set,a={};for(const c of t){const u=Fg(c);if(!u)continue;const f={};for(const l of c.fieldNames){if(o.has(l)||!(l in e))continue;i.add(l);const p=Pg(l,c);f[p]=e[l]}Object.keys(f).length>0&&(a[u]=f)}if(s)for(const[c,u]of Object.entries(e))o.has(c)||i.has(c)||(a[c]=u);return a}function y_(e,t,r){const n={...e??{}};if(!Tg(r)||!t?.length)return n;for(const o of t){const s=Fg(o);if(s)for(const i of o.fieldNames){if(n[i]?.trim())continue;const a=Pg(i,o);n[i]=`${s}.${a}`}}return n}function b_(e){return e==="null"?null:e==="true"?!0:e==="false"?!1:e}function v_(e){const t=e,r=typeof t?.status=="string"?t.status.toLowerCase():null;if(r&&r!=="success")return!1;const n=t?.code;return!(typeof n=="number"&&(n<200||n>=300))}function w_(e,t){if(!t)return[];const r=e.trim().split(".");if(r.length<2)return[];const n=r[0],o=r.slice(1).join("."),s=[];return Object.entries(t).forEach(([i,a])=>{const c=i===n,u=i.startsWith(`${n}__addmore__`);if(!c&&!u||!v_(a))return;const f=Ge(a,o);f==null||f===""||s.push(f)}),s}function fa(e,t,r,n,o,s){const i=e.trim().match(/^\{respAll:([^}]+)\}$/);if(i){const u=(i[1]||"").trim(),f=u.split("."),l=f.length>=2?f.slice(1).join("."):"";return(l==="data.id"||l==="data.documentId")&&n?.document_ids!=null&&Array.isArray(n.document_ids)?n.document_ids:w_(u,o)}const a=e.trim().match(/^\{(\w+)\}$/);if(a){const u=a[1],f=t[u];if(f!==void 0)return f;const l=Object.keys(t).find(p=>p.toLowerCase()===u.toLowerCase());if(l)return t[l]}const c=Lr(e,t,r,n,o,s);return b_(String(c))}const S_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,onClick:u,onSubmit:f,onReset:l,onCancel:p,isSubmitting:g=!1,formValues:m={},submissionContext:h,bffSubmitApi:y,onBffSubmitResult:S,extraSubmitPayload:w,buttonResponses:A,onButtonApiResponse:x,onValidateForm:F,getValidationErrors:N,allFields:k,onSubmittingChange:T,scopedFormValues:P,scopedFieldNameMap:E,prepopulateResponse:C=null,formSections:I,submitPayload:W})=>{const{gridStretch:M}=Jo(),z=Ng(),V=Zs(),[X,L]=v.useState(!1),B=e.properties,D=Ba.useParams(),K=v.useMemo(()=>({...h,...w}),[h,w]),ae=v.useMemo(()=>{if(!P||!E||Object.keys(E).length===0)return m;const Xe={};return Object.entries(P).forEach(([ve,ce])=>{const J=E[ve]||ve;J!==e.name&&(Xe[J]=ce)}),Xe},[P,E,m,e.name]),U=(()=>{try{const Xe=e.metadata;if(typeof Xe=="string")return JSON.parse(Xe);if(Xe&&typeof Xe=="object")return Xe}catch{}return null})(),le=B?.submitAction??U?.submitAction,oe=B?.apiEndpoint??e.apidata?.apiEndpoint??U?.apiEndpoint;let G=B?.action||U?.action;!G&&e.type==="button"&&(G="submit");const ie=B?.variant||"default",Ce=B?.size||"default",ee=B?.hideLabel??e.appearance?.hideLabel??!1,ne=B?.buttonText||e.label||"Button",he=B?.closeOnCancel??!0,Ie=async()=>{if(P&&E&&Object.keys(E).length>0||!F)return!0;const Xe=await F();if(!Xe&&N)try{const ve=N();ct.toast.error(la(ve,k??void 0)||"Please fix the errors before submitting.")}catch{ct.toast.error("Please fix the errors before submitting.")}return Xe},Ue=async Xe=>{Xe.preventDefault();const ve=G==="submit"?"submit":G;if(G==="next"){await Ec(k??void 0,V);return}if(G==="prev"){Xk(V);return}if(G==="saveAndNext"){if(!(B?.uploadApiEndpoint||U?.uploadApiEndpoint||e.uploadApiEndpoint)?.trim()){ct.toast.error("API endpoint is not configured for Save & Next.");return}if(!await Ie())return;L(!0);try{const J=await Se();x?.(e.name,J),hg(J)||pg(J,"Saved successfully."),await Ec(k??void 0,V)}catch(J){x?.(e.name,{status:"error",code:J?.response?.code??J?.response?.status??null,message:Gr(J)}),ia(J,"Failed to save. Please check the API endpoint and try again.",Gr)}finally{L(!1)}return}if(G==="openWorkflowModal"){const ce=B?.workflowId??U?.workflowId;if(!z){ct.toast.error("Workflow modal is not configured for this form.");return}if(!ce?.trim()){ct.toast.error("Workflow is not configured for this button.");return}L(!0);try{await z.openWorkflowModal({workflowId:ce.trim(),entryStepId:B?.entryStepId??U?.entryStepId,modalTitle:B?.modalTitle??U?.modalTitle??e.label,passFields:B?.passFields??U?.passFields},ae)}catch(J){ct.toast.error(Gr(J))}finally{L(!1)}return}if(G==="openFormModal"){const ce=B?.formDefinitionId??U?.formDefinitionId;if(!z){ct.toast.error("Form modal is not configured for this form.");return}if(!ce?.trim()){ct.toast.error("Form is not configured for this button.");return}L(!0);try{await z.openFormModal({formDefinitionId:ce.trim(),modalTitle:B?.modalTitle??U?.modalTitle??e.label,passFields:B?.passFields??U?.passFields},ae)}catch(J){ct.toast.error(Gr(J))}finally{L(!1)}return}if(G==="gotoStep"){const ce=B?.targetStepId??U?.targetStepId;if(!z){ct.toast.error("Step navigation is not configured for this form.");return}if(!ce?.trim()){ct.toast.error("Target step is not configured for this button.");return}const J=B?.workflowId??U?.workflowId??y?.payload?.workflow_id;L(!0);try{await z.navigateToStep(ce.trim(),{workflowId:typeof J=="string"?J:void 0,formValues:ae})}catch($){ct.toast.error(Gr($))}finally{L(!1)}return}if(ve==="submit"){if(Yk(V)){await Ec(k??void 0,V);return}if(y?.url){if(!await Ie())return;L(!0),T?.(!0);try{const ce=await ge(),J=(ce?.message??ce?.display_message??"Form submitted successfully!").trim();ct.toast.success(J||"Form submitted successfully!");const $=ce!=null&&typeof ce=="object"?ce:{status:"success",...ce!=null?{data:ce}:{}};x?.(e.name,$)}catch(ce){const J=Gr(ce);ct.toast.error(J)}finally{L(!1),T?.(!1)}return}if(f){if(!await Ie())return;L(!0),T?.(!0);try{await f(),x?.(e.name,{status:"success"})}finally{L(!1),T?.(!1)}return}ct.toast.error("Submit not configured. BFF submit API is required for submit buttons.");return}else if(G==="reset"&&l)l();else if(G==="cancel")he?p&&p():l&&l();else if(G==="download"){const ce=B?.downloadApiEndpoint||U?.downloadApiEndpoint||e.downloadApiEndpoint,J=B?.downloadApiMethod||U?.downloadApiMethod||e.downloadApiMethod;if(ce){L(!0);try{const $=J||"GET",fe=Mr(Lr(ce,ae,D,K,A,C??void 0)),it={method:$,headers:{}};$!=="GET"&&$!=="DELETE"&&(it.headers={"Content-Type":"application/json"});const Te=await fetch(fe,it);if(!Te.ok)throw new Error(`Download failed: ${Te.statusText}`);const Ye=await Te.blob(),Me=window.URL.createObjectURL(Ye),xe=document.createElement("a");xe.href=Me;const et=Te.headers.get("Content-Disposition");let We="download";if(et){const dt=et.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);dt&&dt[1]&&(We=dt[1].replace(/['"]/g,""))}xe.download=We,document.body.appendChild(xe),xe.click(),document.body.removeChild(xe),window.URL.revokeObjectURL(Me);try{const dt=Gk(Te);ct.toast.success(dt&&dt.trim()?dt:"Download started.")}catch{ct.toast.success("Download started.")}}catch($){ia($,"Failed to download file. Please check the API endpoint and try again.",Gr)}finally{L(!1)}}else ct.toast.error("Download endpoint is not configured")}else if(G==="upload"||G==="custom"){const ce=G==="custom",J=ce?"api":B?.uploadAction||U?.uploadAction||"database";if(J==="database")if(f){L(!0);try{await f(Xe)}catch($){throw $}finally{L(!1)}}else ct.toast.error("Form submit handler is not available");else if(J==="api"){const $=B?.uploadApiEndpoint||U?.uploadApiEndpoint||e.uploadApiEndpoint;if(B?.uploadApiMethod||U?.uploadApiMethod||e.uploadApiMethod,$){if(!await Ie())return;L(!0);try{const fe=await Se();x?.(e.name,fe),pg(fe,ce?"Custom API call completed successfully!":"Upload completed successfully!")}catch(fe){x?.(e.name,{status:"error",code:fe?.response?.code??fe?.response?.status??null,message:Gr(fe)}),ia(fe,ce?"Failed to call custom API. Please check the API endpoint and try again.":"Failed to upload. Please check the API endpoint and try again.",Gr)}finally{L(!1)}}else ct.toast.error(ce?"Custom API endpoint is not configured":"Upload endpoint is not configured")}else J==="custom"&&ct.toast.info("Custom upload handler is not implemented")}else u?u():r&&t!==void 0&&r(t||"");n?.()},re=async()=>{if(!le||le!=="api"||!oe)return null;const Xe=B?.apiBodyFields??U?.apiBodyFields;if((B?.apiBodyFieldsOnly??U?.apiBodyFieldsOnly??!1)&&Xe?.length){const xe={};return Xe.forEach(({key:et,value:We})=>{const dt=fa(We,ae,D,K,A,C??void 0),bt=et==="user_id"?"context_user_id":et;xe[bt]=dt}),xe.user_id!==void 0&&xe.user_id!==null&&(xe.context_user_id=xe.context_user_id??xe.user_id,delete xe.user_id),xe}const ce=k?.length?Tc(ae,k):ae,J=B?.apiFieldMapping??U?.apiFieldMapping,$=B?.apiFieldTypes??U?.apiFieldTypes,fe=B?.apiBodyStructure??U?.apiBodyStructure,it={...$};k?.length&&k.forEach(xe=>{const et=xe.name||xe.key;et&&(xe.type==="terms"||xe.type==="checkbox")&&(it[et]="boolean")});const{transformFormValuesWithFiles:Te}=await Promise.resolve().then(()=>_g),{transformed:Ye}=Te(ce,J,it);let Me={};if(fe==="flat"?Me={...Ye}:Me={data:{...Ye}},J){const xe={};Object.keys(Me).forEach(et=>{const We=J[et]||et;xe[We]=Me[et]}),Me=xe}return Xe?.length&&Xe.forEach(({key:xe,value:et})=>{const We=fa(et,ae,D,K,A,C??void 0),dt=xe==="user_id"?"context_user_id":xe;Me[dt]=We}),Me.user_id!==void 0&&Me.user_id!==null&&(Me.context_user_id=Me.context_user_id??Me.user_id,delete Me.user_id),Me.data?.user_id!==void 0&&Me.data?.user_id!==null&&(Me.data.context_user_id=Me.data.context_user_id??Me.data.user_id,delete Me.data.user_id),Me},ge=async()=>{if(!y||!y.url)throw new Error("BFF submit API configuration is missing");const Xe=k?.length?Tc(m,k):m,ve={};Object.keys(Xe).forEach($e=>{const gt=e.name===$e&&e.type==="button",vt=$e.toLowerCase().includes("button");!gt&&!vt&&(ve[$e]=Xe[$e])});const ce=Object.keys(ve).filter($e=>ua(ve[$e]));ce.forEach($e=>{ve[$e]=""});const J=Og(ve,I,W),$={workflow_id:y.payload?.workflow_id||"",current_step_id:y.payload?.current_step_id||"",form_data:J},fe=y.payload?.context_user_id??y.payload?.user_id;fe!=null&&String(fe).trim()!==""&&($.context_user_id=String(fe).trim());const it=["workflow_id","current_step_id","form_data","submit_body","submit_api_endpoint","submit_api_method"];if(h&&typeof h=="object"&&Object.entries(h).forEach(([$e,gt])=>{if(gt==null||it.includes($e))return;const vt=$e==="user_id"?"context_user_id":$e;$[vt]=$[vt]??gt}),w&&typeof w=="object"&&Object.entries(w).forEach(([$e,gt])=>{if(gt==null||it.includes($e))return;const vt=$e==="user_id"?"context_user_id":$e;$[vt]=$[vt]??gt}),le==="api"&&oe)try{const $e=await re();if($e){const gt=B?.apiBodyStructure??U?.apiBodyStructure,vt=B?.apiFieldMapping??U?.apiFieldMapping;ce.forEach(nr=>{const yr=vt?.[nr]??nr,Er=ve[nr]!==void 0&&typeof ve[nr]=="string"?ve[nr]:"";gt==="flat"?$e[yr]=Er:$e.data&&typeof $e.data=="object"?$e.data[yr]=Er:$e[yr]=Er}),$.submit_body=$e;let kt=Lr(oe,ae,D,K,A,C??void 0);kt=kt.replace(/\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}/gi,"$1"),kt=Mr(kt),$.submit_api_endpoint=kt,$.submit_api_method=B?.submitApiMethod||U?.submitApiMethod||"POST"}}catch{}const Te=(y.method||"POST").toUpperCase(),Ye=ce.length>0,Me=$.submit_api_endpoint??oe??"",xe=typeof Me=="string"?Me.toLowerCase():"",et=xe.includes("/upload")||xe.includes("/payments")||xe.includes("/bulk-upload"),We=Ye&&et;let dt;const bt={...y.headers||{}};if(We){const $e=new FormData;$e.append("payload",JSON.stringify($));for(const gt of ce){const vt=Xe[gt],kt=B?.apiFieldMapping?.[gt]??gt;vt instanceof File?$e.append(kt,vt):Array.isArray(vt)&&vt.length>0&&vt[0]instanceof File&&vt.forEach(nr=>$e.append(kt,nr))}dt=$e,delete bt["content-type"],delete bt["Content-Type"]}else bt["Content-Type"]="application/json",dt=JSON.stringify($);const ir=await fetch(y.url,{method:Te,headers:bt,body:dt});if(!ir.ok){let $e;const gt=await ir.text();try{$e=JSON.parse(gt)}catch{$e={message:gt}}const vt=new Error(`BFF submission failed: ${ir.status}`);throw vt.response=$e,vt}const xt=await ir.json();return S?.(xt),f&&await f(),xt},Se=async()=>{const Xe=B?.uploadApiEndpoint||U?.uploadApiEndpoint;if(!Xe)throw new Error("Upload API endpoint is not configured");if(!B)throw new Error("Button properties are not configured");const ve=(B.uploadApiMethod||"POST").toUpperCase(),ce=Mr(Lr(Xe,ae,D,K,A,C??void 0)),J=B.apiBodyFieldsOnly??U?.apiBodyFieldsOnly??!1,$=B.apiBodyFieldsOnlyFormat??U?.apiBodyFieldsOnlyFormat??"json";let fe={},it;const Te={};if(J&&B.apiBodyFields&&B.apiBodyFields.length>0)if(B.apiBodyFields.forEach(({key:xe,value:et})=>{fe[xe]=fa(et,ae,D,K,A,C??void 0)}),$==="multipart"){const xe=new FormData;Object.entries(fe).forEach(([et,We])=>{if(We instanceof File){xe.append(et,We);return}if(Array.isArray(We)&&We.length>0&&We[0]instanceof File){We.forEach(dt=>xe.append(et,dt));return}We!=null&&xe.append(et,typeof We=="object"?JSON.stringify(We):String(We))}),it=xe}else it=JSON.stringify(fe),Te["Content-Type"]="application/json";else{const xe=ae,{transformFormValuesWithFiles:et,prepareFormDataWithFiles:We,hasFileValues:dt}=await Promise.resolve().then(()=>_g),{transformed:bt,hasFiles:ir}=et(xe,B.apiFieldMapping,B.apiFieldTypes);if((B.apiBodyStructure??U?.apiBodyStructure??"nested")==="flat"?fe={...bt}:fe={data:{...bt}},B.apiFieldMapping){const $e={};Object.keys(fe).forEach(gt=>{const vt=B.apiFieldMapping[gt]||gt;$e[vt]=fe[gt]}),fe=$e}if(B.apiBodyFields&&B.apiBodyFields.forEach(({key:$e,value:gt})=>{fe[$e]=fa(gt,ae,D,K,A,C??void 0)}),ir||dt(fe)){const $e=We(fe,B.apiFieldMapping);$e?it=$e:(it=JSON.stringify(fe),Te["Content-Type"]="application/json")}else it=JSON.stringify(fe),Te["Content-Type"]="application/json"}B.apiHeaders&&B.apiHeaders.forEach(({key:xe,value:et})=>{const We=Lr(et,ae,D,K,A,C??void 0);(xe.toLowerCase()!=="content-type"||!(it instanceof FormData))&&(Te[xe]=We)});let Ye=ce;if(B.apiQueryParams&&B.apiQueryParams.length>0){const xe=new URLSearchParams;B.apiQueryParams.forEach(({key:et,value:We})=>{const dt=Lr(We,ae,D,K,A,C??void 0);xe.append(et,dt)}),Ye=`${ce}?${xe.toString()}`}const Me=await fetch(Ye,{method:ve,headers:Te,body:ve!=="GET"?it:void 0});if(!Me.ok){let xe;const et=await Me.text();try{xe=JSON.parse(et)}catch{xe={message:et}}const We=new Error(`Upload failed: ${Me.status}`);throw We.response=xe,We}try{return await Me.json()}catch{return{}}},pt=G==="submit"?"submit":G,Bt=pt==="submit"?"button":pt==="submit"?"submit":pt==="reset"?"reset":"button",Pt=s||e.disabled||i||e.readOnly||X||pt==="submit"&&g,Ar=ne,Nt=fo(e),Cr=Fr(e.appearance)==="stretch";return d.jsx(At,{field:e,error:o,isRequired:a,className:c,hideLabel:ee,children:d.jsx("div",{className:H(M&&!Nt&&"flex w-full min-w-0 flex-col",M&&Nt&&"min-w-0 shrink-0"),children:d.jsxs(Zt,{id:ft(e),type:Bt,variant:ie,size:Ce,disabled:Pt,onClick:Ue,className:H(e.appearance?.className,M&&!Nt&&"w-full min-w-0 shrink-0",M&&Nt&&!Cr&&"inline-flex w-auto max-w-full shrink-0",M&&Nt&&Cr&&"inline-flex w-full min-w-0 max-w-full shrink-0"),children:[X&&d.jsx("span",{className:"inline-block h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent mr-2","aria-hidden":!0}),Ar]})})})},x_=({field:e,disabled:t,readOnly:r,isRequired:n,className:o,buttonResponses:s,onButtonApiResponse:i})=>{const a=e.properties,c=a?.buttonText??e.label??"Edit",u=a?.variant??"outline",f=a?.size??"default",l=a?.hideLabel??e.appearance?.hideLabel??!1,p=e.name||e.key||e.id,g=Qo(s?.[p]),m=t||e.disabled||r||e.readOnly||g,h=y=>{y.preventDefault(),!m&&i?.(p,{status:"success"})};return d.jsx(At,{field:e,error:void 0,isRequired:n,className:o,hideLabel:l,children:d.jsx(Zt,{id:ft(e),type:"button",variant:u,size:f,disabled:m,onClick:h,className:H(e.appearance?.className,(!fo(e)||Fr(e.appearance)==="stretch")&&"w-full min-w-0"),children:c})})},A_=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,onAddMore:i})=>{const a=e.properties||{},c=a.variant||"outline",u=a.size||"default",f=a.buttonText||e.label||"Add More",l=a.hideLabel??e.appearance?.hideLabel??!1,p=r||n||e.disabled||e.readOnly;return d.jsx(At,{field:e,error:t,isRequired:o,className:s,hideLabel:l,children:d.jsxs(Zt,{id:ft(e),type:"button",variant:c,size:u,disabled:!!p,onClick:i,className:H("w-fit",e.appearance?.className),children:[d.jsx(Ru,{className:"h-4 w-4 mr-1"}),f]})})},Ig=v.createContext(null);function C_({value:e,children:t}){return d.jsx(Ig.Provider,{value:e,children:t})}function E_(){return v.useContext(Ig)}function Mg(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function As(e){return e.name||e.key||e.id}function Fc(e){return e.filter(t=>!t.parentId&&t.type==="sectionHeading"&&As(t))}function N_(e){if(e.type!=="sectionHeading")return[];const t=e.properties||{};return Array.isArray(t.linkedFieldNames)?t.linkedFieldNames.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function k_(e){const t=new Map;for(const r of Fc(e)){const n=As(r);for(const o of N_(r))t.set(o,n)}return t}function __(e,t){const r=t.properties||{},n=Array.isArray(r.sectionHeadingNames)?r.sectionHeadingNames.filter(i=>typeof i=="string"&&i.trim()):[],o=Fc(e);if(n.length===0)return o;const s=new Set(n);return o.filter(i=>s.has(As(i)))}function T_(e){const t={};for(const r of Fc(e))t[As(r)]=!0;for(const r of e){if(r.type!=="customizeSections")continue;const n=r.properties||{};for(const o of n.defaultHiddenSectionNames??[])typeof o=="string"&&o.trim()&&(t[o.trim()]=!1)}return t}function Lg(e,t,r,n){if(!e||t==="customizeSections")return!0;const o=Mg(e),s=t==="sectionHeading"?o:n.get(o);return s?r[s]!==!1:!0}const F_=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,designMode:i=!1})=>{const a=E_(),c=e.properties||{},u=c.variant||"outline",f=c.size||"default",l=c.buttonText||e.label||"Customise sections",p=c.menuTitle||"VISIBLE SECTIONS",g=c.hideLabel??e.appearance?.hideLabel??!1,m=r||n||e.disabled||e.readOnly,h=v.useMemo(()=>a?.allFields?.length?__(a.allFields,e):[],[a?.allFields,e]);return d.jsx(At,{field:e,error:t,isRequired:o,className:s,hideLabel:g,children:d.jsxs(sc,{children:[d.jsx(Wm,{asChild:!0,children:d.jsxs(Zt,{id:ft(e),type:"button",variant:u,size:f,disabled:!!m,className:H("w-fit gap-2",e.appearance?.className),children:[d.jsx(nS,{className:"h-4 w-4"}),l]})}),d.jsxs(ic,{align:"end",className:"w-64 p-0",children:[d.jsx("div",{className:"px-3 py-2 border-b",children:d.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:p})}),d.jsx("div",{className:"max-h-64 overflow-auto p-2 space-y-1",children:h.length===0?d.jsx("p",{className:"text-xs text-muted-foreground px-1 py-2",children:"No section headings on this form."}):h.map(y=>{const S=As(y),w=y.label||S,A=i||!a?!0:a.visibility[S]!==!1;return d.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md px-1 py-1.5 hover:bg-muted/50",children:[d.jsx(Fn,{htmlFor:`ui-section-${e.id}-${S}`,className:"text-xs font-normal truncate",children:w}),d.jsx(Ch,{id:`ui-section-${e.id}-${S}`,checked:A,disabled:i||!a||!!m,onCheckedChange:x=>{!a||i||a.setSectionVisible(S,!!x)}})]},y.id)})})]})]})})},P_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=u?.max||5,l=u?.icon||"star",p=h=>{s||i||e.disabled||e.readOnly||(r(h),n?.())},g=h=>{},m=h=>{const y=t>=h+1,S=H("transition-colors cursor-pointer",y?"fill-yellow-400 text-yellow-400":"text-muted-foreground",(s||i||e.disabled||e.readOnly)&&"cursor-not-allowed opacity-50",!(s||i||e.disabled||e.readOnly)&&"hover:text-yellow-400");return l==="star"?d.jsx(Gu,{className:H(S,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>g()},h):d.jsx(Gu,{className:H(S,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>g()},h)};return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:"flex items-center gap-1",role:"radiogroup","aria-label":e.label,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[Array.from({length:f},(h,y)=>m(y)),u?.showValue!==!1&&d.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:t>0?t:""})]})})};var Dg=["PageUp","PageDown"],Bg=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],$g={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Mo="Slider",[Pc,O_,I_]=Cl(Mo),[jg]=vr(Mo,[I_]),[M_,pa]=jg(Mo),zg=b.forwardRef((e,t)=>{const{name:r,min:n=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[n],value:f,onValueChange:l=()=>{},onValueCommit:p=()=>{},inverted:g=!1,form:m,...h}=e,y=b.useRef(new Set),S=b.useRef(0),A=i==="horizontal"?L_:D_,[x=[],F]=ln({prop:f,defaultProp:u,onChange:C=>{[...y.current][S.current]?.focus(),l(C)}}),N=b.useRef(x);function k(C){const I=U_(x,C);E(C,I)}function T(C){E(C,S.current)}function P(){const C=N.current[S.current];x[S.current]!==C&&p(x)}function E(C,I,{commit:W}={commit:!1}){const M=R_(s),z=G_(Math.round((C-n)/s)*s+n,M),V=us(z,[n,o]);F((X=[])=>{const L=j_(X,V,I);if(W_(L,c*s)){S.current=L.indexOf(V);const B=String(L)!==String(X);return B&&W&&p(L),B?L:X}else return X})}return d.jsx(M_,{scope:e.__scopeSlider,name:r,disabled:a,min:n,max:o,valueIndexToChangeRef:S,thumbs:y.current,values:x,orientation:i,form:m,children:d.jsx(Pc.Provider,{scope:e.__scopeSlider,children:d.jsx(Pc.Slot,{scope:e.__scopeSlider,children:d.jsx(A,{"aria-disabled":a,"data-disabled":a?"":void 0,...h,ref:t,onPointerDown:De(h.onPointerDown,()=>{a||(N.current=x)}),min:n,max:o,inverted:g,onSlideStart:a?void 0:k,onSlideMove:a?void 0:T,onSlideEnd:a?void 0:P,onHomeKeyDown:()=>!a&&E(n,0,{commit:!0}),onEndKeyDown:()=>!a&&E(o,x.length-1,{commit:!0}),onStepKeyDown:({event:C,direction:I})=>{if(!a){const z=Dg.includes(C.key)||C.shiftKey&&Bg.includes(C.key)?10:1,V=S.current,X=x[V],L=s*z*I;E(X+L,V,{commit:!0})}}})})})})});zg.displayName=Mo;var[Ug,Vg]=jg(Mo,{startEdge:"left",endEdge:"right",size:"width",direction:1}),L_=b.forwardRef((e,t)=>{const{min:r,max:n,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...f}=e,[l,p]=b.useState(null),g=Qe(t,A=>p(A)),m=b.useRef(void 0),h=bo(o),y=h==="ltr",S=y&&!s||!y&&s;function w(A){const x=m.current||l.getBoundingClientRect(),F=[0,x.width],k=Mc(F,S?[r,n]:[n,r]);return m.current=x,k(A-x.left)}return d.jsx(Ug,{scope:e.__scopeSlider,startEdge:S?"left":"right",endEdge:S?"right":"left",direction:S?1:-1,size:"width",children:d.jsx(Hg,{dir:h,"data-orientation":"horizontal",...f,ref:g,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:A=>{const x=w(A.clientX);i?.(x)},onSlideMove:A=>{const x=w(A.clientX);a?.(x)},onSlideEnd:()=>{m.current=void 0,c?.()},onStepKeyDown:A=>{const F=$g[S?"from-left":"from-right"].includes(A.key);u?.({event:A,direction:F?-1:1})}})})}),D_=b.forwardRef((e,t)=>{const{min:r,max:n,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,f=b.useRef(null),l=Qe(t,f),p=b.useRef(void 0),g=!o;function m(h){const y=p.current||f.current.getBoundingClientRect(),S=[0,y.height],A=Mc(S,g?[n,r]:[r,n]);return p.current=y,A(h-y.top)}return d.jsx(Ug,{scope:e.__scopeSlider,startEdge:g?"bottom":"top",endEdge:g?"top":"bottom",size:"height",direction:g?1:-1,children:d.jsx(Hg,{"data-orientation":"vertical",...u,ref:l,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:h=>{const y=m(h.clientY);s?.(y)},onSlideMove:h=>{const y=m(h.clientY);i?.(y)},onSlideEnd:()=>{p.current=void 0,a?.()},onStepKeyDown:h=>{const S=$g[g?"from-bottom":"from-top"].includes(h.key);c?.({event:h,direction:S?-1:1})}})})}),Hg=b.forwardRef((e,t)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,f=pa(Mo,r);return d.jsx(je.span,{...u,ref:t,onKeyDown:De(e.onKeyDown,l=>{l.key==="Home"?(i(l),l.preventDefault()):l.key==="End"?(a(l),l.preventDefault()):Dg.concat(Bg).includes(l.key)&&(c(l),l.preventDefault())}),onPointerDown:De(e.onPointerDown,l=>{const p=l.target;p.setPointerCapture(l.pointerId),l.preventDefault(),f.thumbs.has(p)?p.focus():n(l)}),onPointerMove:De(e.onPointerMove,l=>{l.target.hasPointerCapture(l.pointerId)&&o(l)}),onPointerUp:De(e.onPointerUp,l=>{const p=l.target;p.hasPointerCapture(l.pointerId)&&(p.releasePointerCapture(l.pointerId),s(l))})})}),Wg="SliderTrack",Rg=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=pa(Wg,r);return d.jsx(je.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...n,ref:t})});Rg.displayName=Wg;var Oc="SliderRange",Gg=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=pa(Oc,r),s=Vg(Oc,r),i=b.useRef(null),a=Qe(t,i),c=o.values.length,u=o.values.map(p=>Yg(p,o.min,o.max)),f=c>1?Math.min(...u):0,l=100-Math.max(...u);return d.jsx(je.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...n,ref:a,style:{...e.style,[s.startEdge]:f+"%",[s.endEdge]:l+"%"}})});Gg.displayName=Oc;var Ic="SliderThumb",Kg=b.forwardRef((e,t)=>{const r=O_(e.__scopeSlider),[n,o]=b.useState(null),s=Qe(t,a=>o(a)),i=b.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return d.jsx(B_,{...e,ref:s,index:i})}),B_=b.forwardRef((e,t)=>{const{__scopeSlider:r,index:n,name:o,...s}=e,i=pa(Ic,r),a=Vg(Ic,r),[c,u]=b.useState(null),f=Qe(t,w=>u(w)),l=c?i.form||!!c.closest("form"):!0,p=ms(c),g=i.values[n],m=g===void 0?0:Yg(g,i.min,i.max),h=z_(n,i.values.length),y=p?.[a.size],S=y?V_(y,m,a.direction):0;return b.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),d.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${m}% + ${S}px)`},children:[d.jsx(Pc.ItemSlot,{scope:e.__scopeSlider,children:d.jsx(je.span,{role:"slider","aria-label":e["aria-label"]||h,"aria-valuemin":i.min,"aria-valuenow":g,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:f,style:g===void 0?{display:"none"}:e.style,onFocus:De(e.onFocus,()=>{i.valueIndexToChangeRef.current=n})})}),l&&d.jsx(qg,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:g},n)]})});Kg.displayName=Ic;var $_="RadioBubbleInput",qg=b.forwardRef(({__scopeSlider:e,value:t,...r},n)=>{const o=b.useRef(null),s=Qe(o,n),i=hs(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&f){const l=new Event("input",{bubbles:!0});f.call(a,t),a.dispatchEvent(l)}},[i,t]),d.jsx(je.input,{style:{display:"none"},...r,ref:s,defaultValue:t})});qg.displayName=$_;function j_(e=[],t,r){const n=[...e];return n[r]=t,n.sort((o,s)=>o-s)}function Yg(e,t,r){const s=100/(r-t)*(e-t);return us(s,[0,100])}function z_(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function U_(e,t){if(e.length===1)return 0;const r=e.map(o=>Math.abs(o-t)),n=Math.min(...r);return r.indexOf(n)}function V_(e,t,r){const n=e/2,s=Mc([0,50],[0,n]);return(n-s(t)*r)*r}function H_(e){return e.slice(0,-1).map((t,r)=>e[r+1]-t)}function W_(e,t){if(t>0){const r=H_(e);return Math.min(...r)>=t}return!0}function Mc(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function R_(e){return(String(e).split(".")[1]||"").length}function G_(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}var K_=zg,q_=Rg,Y_=Gg,X_=Kg;function J_({className:e,defaultValue:t,value:r,min:n=0,max:o=100,...s}){const i=b.useMemo(()=>Array.isArray(r)?r:Array.isArray(t)?t:[n,o],[r,t,n,o]);return d.jsxs(K_,{"data-slot":"slider",defaultValue:t,value:r,min:n,max:o,className:H("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...s,children:[d.jsx(q_,{"data-slot":"slider-track",className:H("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:d.jsx(Y_,{"data-slot":"slider-range",className:H("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:i.length},(a,c)=>d.jsx(X_,{"data-slot":"slider-thumb",className:"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},c))]})}const Q_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=u?.min??0,l=u?.max??100,p=u?.step??1,g=u?.showValue!==!1,m=u?.marks||[],h=S=>{s||i||e.disabled||e.readOnly||(r(S[0]??f),n?.())},y=t??f;return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[g&&d.jsx("span",{className:"text-sm font-medium",children:y}),!g&&d.jsx("span",{className:"text-sm text-muted-foreground",children:f}),!g&&d.jsx("span",{className:"text-sm text-muted-foreground",children:l})]}),d.jsx(J_,{id:ft(e),value:[y],onValueChange:h,min:f,max:l,step:p,disabled:s||e.disabled||i||e.readOnly,className:H("w-full",o&&"border-destructive",e.appearance?.className),"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a}),m.length>0&&d.jsx("div",{className:"flex justify-between text-xs text-muted-foreground",children:m.map((S,w)=>d.jsx("span",{className:"text-center",children:S.label},w))})]})})},Z_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=v.useRef(null),[f,l]=v.useState(!1),p=s||e.disabled||i||e.readOnly,g=v.useCallback(S=>{if(p)return;l(!0);const w=u.current;if(!w)return;const A=w.getContext("2d");if(!A)return;const x=w.getBoundingClientRect(),F="touches"in S?S.touches[0].clientX-x.left:S.clientX-x.left,N="touches"in S?S.touches[0].clientY-x.top:S.clientY-x.top;A.beginPath(),A.moveTo(F,N)},[p]),m=v.useCallback(S=>{if(!f||p)return;const w=u.current;if(!w)return;const A=w.getContext("2d");if(!A)return;const x=w.getBoundingClientRect(),F="touches"in S?S.touches[0].clientX-x.left:S.clientX-x.left,N="touches"in S?S.touches[0].clientY-x.top:S.clientY-x.top;A.lineWidth=2,A.lineCap="round",A.strokeStyle="#000",A.lineTo(F,N),A.stroke(),A.beginPath(),A.moveTo(F,N)},[f,p]),h=v.useCallback(()=>{if(!f)return;l(!1);const S=u.current;if(!S)return;const w=S.toDataURL();r(w),n?.()},[f,r,n]),y=v.useCallback(()=>{const S=u.current;if(!S||p)return;const w=S.getContext("2d");w&&(w.clearRect(0,0,S.width,S.height),r(null),n?.())},[p,r,n]);return v.useEffect(()=>{const S=u.current;if(S&&(S.width=S.offsetWidth,S.height=200,t)){const w=new Image;w.onload=()=>{const A=S.getContext("2d");A&&A.drawImage(w,0,0)},w.src=t}},[t]),d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsx("div",{className:H("border-2 border-dashed rounded-lg overflow-hidden",o&&"border-destructive",p&&"opacity-50 cursor-not-allowed"),children:d.jsx("canvas",{ref:u,id:ft(e),className:"w-full cursor-crosshair touch-none",onMouseDown:g,onMouseMove:m,onMouseUp:h,onMouseLeave:h,onTouchStart:g,onTouchMove:m,onTouchEnd:h,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,style:{height:"200px"}})}),!p&&d.jsx("div",{className:"flex justify-end",children:d.jsxs(Zt,{type:"button",variant:"outline",size:"sm",onClick:y,className:"text-xs",children:[d.jsx(rs,{className:"h-3 w-3 mr-1"}),"Clear"]})})]})})},eT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,hideRowControls:u=!1,formValues:f,submissionContext:l})=>{const p=e.properties,g=p?.columns||[],m=p?.minRows||1,h=p?.maxRows||10,y=!u&&p?.allowAddRow!==!1,S=!u&&p?.allowDeleteRow!==!1,w=s===!1&&i===!1?!1:s||e.disabled||i||e.readOnly,A=t||[],x=y&&A.length<h,F=S&&A.length>m,N=v.useCallback(()=>{if(!x||w)return;const M={};g.forEach(z=>{M[z.name]=z.defaultValue??""}),r([...A,M]),n?.()},[A,g,x,w,r,n]),k=v.useCallback(M=>{if(!F||w)return;const z=A.filter((V,X)=>X!==M);r(z),n?.()},[A,F,w,r,n]),T=v.useCallback((M,z,V)=>{if(w)return;const X=[...A];X[M]||(X[M]={}),X[M][z]=V,r(X),n?.()},[A,w,r,n]);if(v.useEffect(()=>{if(A.length<m){const M=m-A.length,z=[];for(let V=0;V<M;V++){const X={};g.forEach(L=>{X[L.name]=L.defaultValue??""}),z.push(X)}r([...A,...z])}},[m,g,r,A.length]),g.length===0)return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this table field"})});const P=Math.max(1,e.position?.rowSpan??1),E=Math.max(1,e.position?.columnSpan??1),C=Math.max(A.length,1),I=P>=3?"py-4":P>=2?"py-3":"py-2.5",W=E>=3?"px-4":E>=2?"px-3":"px-4";return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:H("flex h-full min-h-0 w-full min-w-0 flex-1 flex-col border rounded-lg overflow-hidden shadow-sm bg-background",o&&"border-destructive",w&&"opacity-50"),"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[d.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:d.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:p?.minWidth?{minWidth:p.minWidth}:void 0,children:[d.jsx("thead",{children:d.jsxs("tr",{className:"border-b border-border bg-muted/60",children:[g.map(M=>d.jsxs("th",{className:H(W,I,"text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground whitespace-nowrap"),children:[M.label,a&&M.validation?.some(z=>z.type==="required")&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]},M.id)),S&&d.jsx("th",{className:"w-12"})]})}),d.jsx("tbody",{className:"h-full",children:A.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:g.length+(S?1:0),className:H(W,"py-8 text-center text-sm text-muted-foreground"),children:u?"No rows to display.":'No rows added yet. Click "Add Row" to get started.'})}):A.map((M,z)=>{const V=A[z],X=V&&typeof V=="object"&&!Array.isArray(V)?{...f??{},...V}:f;return d.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/30 transition-colors last:border-b-0",style:{height:`${100/C}%`},children:[g.map(L=>{const B={...L,name:`${e.name}_${z}_${L.name}`,appearance:{...L.appearance,hideLabel:!0}},D=L.name??"",K=M[D]!==void 0?M[D]:D&&Object.keys(M).find(G=>G.toLowerCase()===D.toLowerCase())?M[Object.keys(M).find(G=>G.toLowerCase()===D.toLowerCase())]:void 0,ae=!!L.readOnly,j=G=>{if(G==null)return"";if(Array.isArray(G))return G.map(ie=>typeof ie=="object"&&ie!==null&&"name"in ie?String(ie.name??ie):String(ie)).join(", ");if(typeof G=="object"&&G!==null&&!(G instanceof Date)){const ie=G;return typeof ie.name=="string"&&typeof ie.code=="string"?`${ie.code} ${ie.name}`.trim():typeof ie.name=="string"?ie.name:typeof ie.code=="string"?ie.code:String(ie.name??ie.code??G)}return String(G)},U=G=>typeof G=="object"&&G!==null&&!Array.isArray(G)?j(G):String(G??""),le=L.name?.toLowerCase()==="type"||L.label?.toLowerCase()==="type";if(ae){const G=j(K);return d.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:d.jsx("div",{className:"min-w-[120px] text-sm text-foreground",children:le&&G?d.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 text-primary px-2.5 py-0.5 text-xs font-medium",children:G}):d.jsx("span",{className:"py-1 block",children:G})})},L.id)}const oe=()=>{switch(L.type){case"text":case"password":case"url":return d.jsx(ri,{field:B,value:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"number":return d.jsx(dl,{field:B,value:K??null,onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"email":return d.jsx(Ku,{field:B,value:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"phone":case"aadhaar":return d.jsx(qu,{field:B,value:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"otp":return d.jsx(Wf,{field:B,value:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"textarea":return d.jsx(Rf,{field:B,value:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"select":return d.jsx(Tm,{field:B,value:typeof K=="string"?K:U(K),onChange:G=>T(z,L.name,G),disabled:w,className:"w-full",formValues:X,submissionContext:l});case"multiselect":{const G=Array.isArray(K)?K:K!=null&&K!==""?[String(K)]:[];return d.jsx(yh,{field:B,value:G,onChange:ie=>T(z,L.name,ie),disabled:w,className:"w-full",formValues:X,submissionContext:l})}case"asyncsearch":return d.jsx(qm,{field:B,value:K,onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full",formValues:X,submissionContext:l});case"checkbox":return d.jsx(bh,{field:B,value:K||!1,onChange:G=>T(z,L.name,G),disabled:w,className:"w-full"});case"radio":case"checkboxgroup":return d.jsx(Wh,{field:B,value:typeof K=="string"?K:U(K),onChange:G=>T(z,L.name,G),disabled:w,className:"w-full"});case"date":case"time":case"datetime":case"daterange":return d.jsx(Rh,{field:B,value:typeof K=="string"?K:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});default:return d.jsx(ri,{field:B,value:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"})}};return d.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:d.jsx("div",{className:"min-w-[160px] w-full [&_input]:min-w-[10rem] [&_input]:overflow-visible [&_textarea]:min-h-[2.5rem]",children:oe()})},L.id)}),S&&d.jsx("td",{className:"px-2 py-2",children:d.jsx(Zt,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>k(z),disabled:!F||w,children:d.jsx(rs,{className:"h-4 w-4"})})})]},z)})})]})}),x&&d.jsx("div",{className:"shrink-0 p-3 border-t bg-muted/30",children:d.jsxs(Zt,{type:"button",variant:"outline",size:"sm",onClick:N,disabled:w,className:"w-full",children:[d.jsx(Ru,{className:"h-4 w-4 mr-2"}),"Add Row"]})})]})})},tT="h-8 min-h-8 rounded-md border border-input bg-background px-2 text-sm shadow-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30",rT="flex min-h-8 w-full items-center gap-0.5 rounded-md border border-input bg-background px-2 focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30",nT="h-8 min-w-[2ch] max-w-full flex-1 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0",oT="align-top max-w-0 whitespace-normal break-words",Cs="block min-w-0 break-words";function Xg(e,t,r){const n=r?.emptyDisplay??"—";if(e==null||e==="")return n;const o=t?.format??"text",s=typeof e=="number"?e:Number(e);switch(o){case"currency":return Number.isNaN(s)?n:`${r?.currencySymbol??"₹"}${s.toLocaleString("en-IN",{minimumFractionDigits:0,maximumFractionDigits:2})}`;case"percent":return Number.isNaN(s)?n:`${s}%`;case"number":return Number.isNaN(s)?n:String(s);default:return String(e)}}function sT(e){const t=e.replace(/[^\d.-]/g,"");if(t===""||t==="-"||t===".")return null;const r=parseFloat(t);return Number.isNaN(r)?null:r}function iT(e){if(e==null||e==="")return"";const t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?"":String(t)}function Jg(e,t){return Xg(e,{format:"currency"},t)}function Es(e){return e==null||e===""}function Qg(e){return e.mode??"editable"}function aT(e,t){return e.kind==="currency"||e.kind==="input"&&e.inputType==="number"?!0:t?.format==="currency"||t?.format==="number"||t?.format==="percent"}function Zg(e,t,r){if(e!==void 0){if(e==="")return"";if(aT(t,r)){const n=Number(e);return Number.isNaN(n)?e:n}return e}}function Lc(e,t){if(!(!e||!("defaultValue"in e)||e.defaultValue===void 0))return Zg(e.defaultValue,e,t)}function Dc(e,t,r){if(!t||!Es(e))return e;if(t.kind==="currency"&&Qg(t)==="static"&&t.value!==void 0)return Zg(t.value,t,r);const n=Lc(t,r);return n!==void 0?n:e}function lT(e,t,r){const n={...t};for(const[o,s]of Object.entries(e)){const i=r.find(c=>c.key===o);if(!Es(n[o]))continue;const a=Dc(n[o],s,i);(!Es(a)||s&&"defaultValue"in s&&s.defaultValue==="")&&(n[o]=a)}return n}function ma(e,t,r){if(!Es(e))return e;const n=Lc(t,r);return n!==void 0?n:e}const cT=new Set(["all_items_summary","invoice_discount","grand_total"]);function dT(e,t){switch(t){case"dynamic":return e.filter(r=>r.rowKind==="dynamic");case"static":return e.filter(r=>r.rowKind==="static");case"all":return e;case"data":return e.filter(r=>r.rowKind==="dynamic"||r.rowKind==="static"&&!cT.has(r.slotId));default:return e}}function uT(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}function fT(e,t,r){const n=e.rowSlots.find(o=>o.kind==="static"?o.row.id===t.slotId:o.kind==="dynamic"&&o.block.id===t.slotId);if(n)return n.kind==="static"?n.row.cells[r]:n.block.cells[r]}function pT(e,t,r,n){const o=f=>Fu(n,t,f,r),s=(f,l)=>Fu(n,t,l,r,{slotId:f,rowKind:"static"}),i=(f,l="all")=>dT(t,l).reduce((p,g)=>p+uT(g.values[f]),0),a={...Xs.functions,cell:o,cellInRow:s,SUM:i},c=Object.keys(a),u=Object.values(a);try{const f=new Function(...c,`return (${e});`)(...u);return f==null||typeof f=="number"&&Number.isNaN(f)?null:f}catch{return null}}function mT(e,t){return e.length!==t.length?!1:e.every((r,n)=>{const o=t[n];return r.slotId===o.slotId&&r.rowInstanceId===o.rowInstanceId&&JSON.stringify(r.values)===JSON.stringify(o.values)})}function hT(e,t){const r=t.rows.map(n=>({...n,values:{...n.values}}));for(const n of r)for(const o of e.columns){const s=fT(e,n,o.key);if(s?.kind==="formula"){const i=pT(s.expression,r,n,e),a=e.columns.find(c=>c.key===o.key);n.values[o.key]=Es(i)?Lc(s,a)??i:i}}return{rows:r}}function Lo(e,t,r=8){let n={rows:t.rows.map(o=>({...o,values:{...o.values}}))};for(let o=0;o<r;o++){const s=hT(e,n);if(mT(s.rows,n.rows))return s;n=s}return n}function gT(e,t,r,n,o,s){const i=t.rows.map(a=>a.rowInstanceId!==r||a.slotId!==n?a:{...a,values:{...a.values,[o]:s}});return Lo(e,{rows:i})}function ey(e,t,r=[]){return t.map((n,o)=>{const s=typeof n=="object"&&n!==null?n:{},i=e.rowIdField&&s[e.rowIdField]!=null?String(s[e.rowIdField]):String(o),a={};for(const[u,f]of Object.entries(e.cells)){const l=r.find(p=>p.key===u);(f.kind==="api"&&f.path||f.kind==="currency"&&f.mode==="api"&&f.path)&&(a[u]=ma(Ge(s,f.path),f,l))}const c=a.service??a.tariff_type;return{slotId:e.id,rowKind:"dynamic",rowInstanceId:i,label:typeof c=="string"?c:void 0,values:a}})}function Bc(e,t,r){const n=[];for(const o of e.rowSlots)if(o.kind==="static"){const s=t.get(o.row.id);s&&n.push(s)}else n.push(...r.get(o.block.id)??[]);return n}function $c(e,t){const r=new Map,n=new Map;for(const o of e.rowSlots)if(o.kind==="static"){const s=t?.rows.find(i=>i.slotId===o.row.id&&i.rowKind==="static");r.set(o.row.id,{slotId:o.row.id,rowKind:"static",rowInstanceId:o.row.id,label:o.row.label,values:lT(o.row.cells,s?.values?{...s.values}:{},e.columns)})}else{const s=t?.rows.filter(i=>i.slotId===o.block.id&&i.rowKind==="dynamic")??[];n.set(o.block.id,s.map(i=>({...i,values:{...i.values}})))}return{rows:Bc(e,r,n)}}function yT(e,t,r,n){const o=$c(e,n),s=e.rowSlots.find(c=>c.kind==="dynamic"&&c.block.id===t);if(!s||s.kind!=="dynamic")return Lo(e,o);const i=new Map,a=new Map;for(const c of e.rowSlots)if(c.kind==="static"){const u=o.rows.find(f=>f.slotId===c.row.id&&f.rowKind==="static");u&&i.set(c.row.id,{...u,values:{...u.values}})}else{const u=c.block.id===t?ey(c.block,r,e.columns):o.rows.filter(f=>f.slotId===c.block.id&&f.rowKind==="dynamic");a.set(c.block.id,u.map(f=>({...f,values:{...f.values}})))}return Lo(e,{rows:Bc(e,i,a)})}function ty(e,t,r){const n=$c(e,r);if(t==null||typeof t!="object"||Array.isArray(t))return Lo(e,n);const o=t,s=new Map,i=new Map;for(const a of e.rowSlots)if(a.kind==="static"){const u={...n.rows.find(l=>l.slotId===a.row.id&&l.rowKind==="static")?.values??{}},f=o[a.row.id]??o;for(const[l,p]of Object.entries(a.row.cells)){const g=e.columns.find(m=>m.key===l);(p.kind==="api"&&p.path||p.kind==="currency"&&p.mode==="api"&&p.path)&&(u[l]=ma(Ge(f,p.path),p,g))}s.set(a.row.id,{slotId:a.row.id,rowKind:"static",rowInstanceId:a.row.id,label:a.row.label,values:u})}else{const c=a.block.apiArrayPath??a.block.id,u=Ge(o,c);i.set(a.block.id,Array.isArray(u)?ey(a.block,u,e.columns):[])}return Lo(e,{rows:Bc(e,s,i)})}function ry(e){if(!e)return"";const t=[];switch(e.fontSize){case"xs":t.push("text-xs");break;case"sm":t.push("text-sm");break;case"base":t.push("text-base");break;case"lg":t.push("text-lg");break;case"xl":t.push("text-xl");break}return e.bold?t.push("font-bold"):e.fontSize&&t.push("font-medium"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),t.join(" ")}function bT(e){const t=e?.color?.trim();return t?{color:t}:{}}function jc(e){return{className:ry(e),style:bT(e)}}function vT(e){return e?!!(e.fontSize||e.bold||e.italic||e.underline||e.color?.trim()):!1}function wT(e,t){if(!e&&!t)return;const r={...e,...t};return vT(r)?r:void 0}function ST(e,t){const r=e?.kind==="label"?wT(t,e.cellStyle):e?.cellStyle;return jc(r)}function zc(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function ny(e,t){return e?.align?e.align:t?.align??"left"}function oy(e){const t=e.properties,r=t?.apiEndpoint?{apiEndpoint:t.apiEndpoint,apiMethod:t.apiMethod,apiKey:t.apiKey,apiRealtime:t.apiRealtime,apiQueryParams:t.apiQueryParams,apiHeaders:t.apiHeaders,apiBodyFields:t.apiBodyFields,apiAuth:t.apiAuth,valueSource:t.valueSource,dependentFields:t.dependentFields,apiResponsePath:t.apiResponsePath}:null,n=e.apidata||null;return r||n}function sy(e){if(e.type!=="billingGrid")return!1;const t=oy(e),r=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||r?.valueSource==="api"))}function xT(e,t,r){let n=e;if(r?.trim()&&(n=Ge(e,r.trim())),n==null)return null;if(Array.isArray(n)){const o=t.rowSlots.find(s=>s.kind==="dynamic");return o?.kind==="dynamic"?{[o.block.apiArrayPath?.trim()||o.block.id]:n}:null}return typeof n=="object"?n:null}function ha(e){return JSON.stringify(e?.rows??[])}function AT({field:e,properties:t,formValues:r={},submissionContext:n,value:o,onChange:s}){const i=sy(e),a=oy(e),[c,u]=v.useState(!1),[f,l]=v.useState(null),p=v.useRef(""),g=v.useRef(o);g.current=o;const m=v.useMemo(()=>{const x=a?.apiEndpoint||"",F=a?.apiQueryParams;return po(x,F)},[a?.apiEndpoint,a?.apiQueryParams]),h=v.useMemo(()=>{const x=new Set;for(const F of a?.dependentFields??[])typeof F=="string"&&F.trim()&&x.add(F.trim());return[...x]},[a?.dependentFields]),y=v.useMemo(()=>{const x=new Set([...m,...h]);if(x.size===0)return null;const F={};return x.forEach(N=>{F[N]=r[N]}),JSON.stringify(F)},[m,h,r]),S=v.useMemo(()=>JSON.stringify(n||{}),[n]),w=v.useMemo(()=>{const x=new Set;e.name?.trim()&&x.add(e.name.trim());const F=e.key;return typeof F=="string"&&F.trim()&&x.add(F.trim()),[...x]},[e.name,e.key]),A=v.useMemo(()=>JSON.stringify({rowSlots:t.rowSlots,columns:t.columns}),[t.rowSlots,t.columns]);return v.useEffect(()=>{const x=a?.apiEndpoint;if(!i||!x)return;let F=!1;const N=T=>{if(F)return;const P=ha(T),E=ha(g.current);P!==E&&p.current!==P&&(p.current=P,s(T))};return(async()=>{u(!0),l(null);try{const T=a?.apiMethod||"GET",P=a?.apiRealtime,E=Qs({apiEndpoint:x,apiMethod:T,apiQueryParams:a?.apiQueryParams||{},formValues:r,submissionContext:n,apiRealtime:P,additionalRequiredFieldNames:h,excludeFormFieldNames:w});if(E.blocked){F||u(!1);return}const C={"Content-Type":"application/json"};a?.apiKey&&(C["X-CSCAPI-KEY"]=a.apiKey);const I=a?.apiAuth??Hi(a?.apiHeaders)??{type:"none"};Object.assign(C,Ri(I,{formValues:r,submissionContext:n,apiRealtime:P})),Object.assign(C,Bn(Vi(a?.apiHeaders),{formValues:r,submissionContext:n,apiRealtime:P}));const W=Bn(a?.apiBodyFields,{formValues:r,submissionContext:n,apiRealtime:P}),M={method:T.toLowerCase(),url:Mr(E.url),headers:C};(E.postBodyBase!=null||Object.keys(W).length>0)&&(M.data={...E.postBodyBase??{},...W});const z=await Ct(M),V=xT(z.data,t,a?.apiResponsePath);if(!V){F||l("API response could not be mapped to billing grid rows.");return}const X=ty(t,V,g.current);N(X)}catch(T){if(F)return;let P="Failed to load billing data";const E=T;if(E.response){const C=E.response.data;if(E.response.status===404)P="API endpoint not found.";else if(E.response.status===401)P="Authentication failed.";else if(typeof C=="string")P=C;else if(C&&typeof C=="object"){const I=C;P=I.error||I.message||I.detail||P}}else E.message&&(P=String(E.message));l(P)}finally{F||u(!1)}})(),()=>{F=!0}},[i,a?.apiEndpoint,a?.apiMethod,a?.apiResponsePath,y,h,w,S,A]),{isLoading:c,error:f}}function CT(e,t,r){return e.rowSlots.find(n=>r==="static"?n.kind==="static"&&n.row.id===t:n.kind==="dynamic"&&n.block.id===t)}function iy(e,t,r,n){const o=e.rowSlots.find(s=>r==="static"?s.kind==="static"&&s.row.id===t:s.kind==="dynamic"&&s.block.id===t);if(o)return o.kind==="static"?o.row.cells[n]:o.block.cells[n]}const ET=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f})=>{const l=e.properties??{},p=l.columns??[],g=l.currencySymbol??"₹",m=l.emptyDisplay??"—",h=s||i,y=sy(e),{isLoading:S}=AT({field:e,properties:l,formValues:u,submissionContext:f,value:t,onChange:r}),w=v.useMemo(()=>{const C=$c(l,t);return Lo(l,C)},[l,t]),A=v.useRef("");v.useEffect(()=>{const C=ha(w),I=ha(t);C===I||C===A.current||(A.current=C,r(w))},[w,t,r]),v.useEffect(()=>{!t?.rows?.length&&w.rows.length&&!y&&r(w)},[t,w,r,y]);const x=v.useCallback((C,I,W,M,z)=>{if(h)return;const V=z==="number"?sT(M):M===""?null:M,X=gT(l,w,C,I,W,V);r(X)},[h,w,r,l]),F=(C,I,W,M,z,V)=>{const X=p.find(U=>U.key===z),L=iy(l,C,I,z),B=zc(ny(L,X)),D=Dc(V,L,X),K=CT(l,C,I),ae=K?.kind==="static"?K.row.labelStyle:K?.kind==="dynamic"?K.block.labelStyle:void 0,j=ST(L,ae);if(L?.kind==="label")return d.jsx("span",{className:H(Cs,j.className||"font-medium",B,!j.style.color&&"text-foreground"),style:j.style,children:M??m});if(L?.kind==="input"&&!h){const U=D==null||D===""?"":String(D);return d.jsx(mn,{type:"text",inputMode:L.inputType==="number"?"decimal":"text",value:U,onChange:le=>x(W,C,z,le.target.value,L.inputType),onBlur:n,className:H(tT,"w-full min-w-0",B,j.className),style:j.style,disabled:h})}if(L?.kind==="currency"){const U=Qg(L);if(U==="static"){const oe=L.value!==void 0&&L.value!==""?Dc(null,{...L,mode:"static"},X):D;return d.jsx("span",{className:H(Cs,"tabular-nums",B,j.className),style:j.style,children:Jg(oe,{currencySymbol:g,emptyDisplay:m})})}if(U==="api"||h)return d.jsx("span",{className:H(Cs,"tabular-nums",B,j.className),style:j.style,children:Jg(D,{currencySymbol:g,emptyDisplay:m})});const le=iT(D);return d.jsxs("div",{className:H(rT,B==="text-center"&&"justify-center",B==="text-right"&&"justify-end",B==="text-left"&&"justify-start",j.className),style:j.style,children:[d.jsx("span",{className:"shrink-0 tabular-nums",children:g}),d.jsx(mn,{type:"text",inputMode:"decimal",value:le,onChange:oe=>x(W,C,z,oe.target.value,"number"),onBlur:n,className:nT,disabled:h})]})}return L?.kind==="static"?d.jsx("span",{className:H(Cs,B,j.className,!j.style.color&&"text-muted-foreground"),style:j.style,children:L.value}):d.jsx("span",{className:H(Cs,B,j.className),style:j.style,children:Xg(D,X,{currencySymbol:g,emptyDisplay:m})})},N=l.gridTitle?.trim()??"",k=Math.max(1,e.position?.rowSpan??1),T=Math.max(1,e.position?.columnSpan??1),P=k>=3?"py-4":k>=2?"py-3":"py-2",E=T>=3?"px-4":T>=2?"px-3":"px-2";return p.length===0?d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this billing grid"})}):d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:H("relative flex h-full min-h-0 w-full min-w-0 max-w-full flex-1 flex-col border rounded-lg overflow-hidden shadow-sm bg-background",o&&"border-destructive",h&&"opacity-70"),"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[S&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60",children:d.jsx(mo,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),N?d.jsx("div",{className:H("shrink-0 px-4 py-2 border-b bg-muted/40",ry(l.gridTitleStyle)||"text-muted-foreground"),style:jc(l.gridTitleStyle).style,children:N}):null,d.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:d.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:l.minWidth?{minWidth:l.minWidth}:void 0,children:[d.jsx("thead",{children:d.jsx("tr",{className:"border-b border-border bg-muted/60",children:p.map(C=>{const I=jc(C.headerStyle);return d.jsx("th",{className:H(E,P,"text-xs uppercase tracking-wider whitespace-nowrap",zc(C.align),I.className||"font-semibold text-muted-foreground"),style:I.style,children:C.label},C.id)})})}),d.jsx("tbody",{className:"h-full",children:w.rows.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:p.length,className:H(E,"py-8 text-center text-sm text-muted-foreground"),children:"No billing rows configured"})}):w.rows.map(C=>d.jsx("tr",{className:"border-b border-border/60",children:p.map(I=>{const W=iy(l,C.slotId,C.rowKind,I.key),M=ny(W,I);return d.jsx("td",{className:H(E,P,oT,zc(M)),children:F(C.slotId,C.rowKind,C.rowInstanceId,C.label,I.key,C.values[I.key])},I.id)})},`${C.slotId}-${C.rowInstanceId}`))})]})})]})})};function Uc(e,t,r){return ty(e,t,r)}const NT=({field:e,value:t,error:r,disabled:n,isRequired:o,className:s,formValues:i={},submissionContext:a,extraSubmitPayload:c,skipApiCall:u=!1,prepopulateResponse:f=null})=>{const l=e.properties||{},p=l.source??"manual",g=Array.isArray(l.statuses)?l.statuses:[],m=(l.dataPath||"data").trim(),h=l.showStatusText===!0,y=(l.statusTextPath||"data.admissionStatus").trim(),S=l.showCurrentIndicator!==!1,[w,A]=v.useState(null),[x,F]=v.useState(!1),[N,k]=v.useState(null),T=Ba.useParams(),P=v.useRef(i),E=v.useRef(a),C=v.useRef(c),I=v.useRef(T);P.current=i,E.current=a,C.current=c,I.current=T;const W=v.useCallback(async()=>{const L=l.apiEndpoint?.trim();if(!L){k("Status API endpoint is not configured");return}F(!0),k(null);try{const B=E.current,D=C.current,K=B!=null&&typeof B=="object"?{...B,...D||{}}:D||{},ae=Mr(Lr(L,P.current,I.current,K,void 0,f??void 0)),j=(l.apiMethod||"GET").toUpperCase(),U=await fetch(ae,{method:j,headers:j==="POST"?{"Content-Type":"application/json"}:void 0});if(!U.ok)throw new Error(`HTTP ${U.status}`);const le=await U.json(),oe=m?Ge(le,m):le;A(oe&&typeof oe=="object"?oe:{})}catch(B){k(B instanceof Error?B.message:"Failed to load status"),A(null)}finally{F(!1)}},[l.apiEndpoint,l.apiMethod,m,f]);v.useEffect(()=>{p==="api"&&!u&&W()},[p,u,W]);const M=p==="api"?w:t&&typeof t=="object"?(m?Ge(t,m):null)??t:null,z=h&&y&&M?String(Ge(M,y)??Ge({data:M},y)??""):"",V=L=>{if(!M||typeof M!="object")return!1;const B=M[L];return B===!0||B==="true"||B===1};let X=!1;return d.jsx(At,{field:e,error:r||N||void 0,isRequired:o,className:H(s,"!space-y-0 h-full min-h-0 flex flex-col"),children:d.jsxs("div",{className:"rounded-lg border bg-card p-4 h-full min-h-0 flex flex-col",children:[x&&d.jsx("div",{className:"text-sm text-muted-foreground py-2",children:"Loading status..."}),h&&z&&!x&&d.jsx("p",{className:"text-sm text-muted-foreground mb-3 shrink-0","data-status-text":!0,children:z}),!x&&d.jsx("ul",{className:"flex-1 min-h-0 flex flex-col gap-y-8 overflow-y-auto pr-1 py-1",children:g.map(L=>{const B=V(L.key),D=S&&B&&!X;return D&&(X=!0),d.jsxs("li",{className:H("flex items-center gap-3 text-sm",B?"text-foreground":"text-muted-foreground"),children:[B?d.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-green-600 text-white","aria-hidden":!0,children:d.jsx(oi,{className:"h-3 w-3"})}):d.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 border-muted-foreground/40 bg-muted/50","aria-hidden":!0,children:d.jsx(Vu,{className:"h-2.5 w-2.5 text-muted-foreground/60"})}),d.jsx("span",{className:"flex-1 min-w-0",children:L.label}),D&&d.jsx("span",{className:"shrink-0 text-xs font-medium text-primary",children:"Current"})]},L.key)})}),!x&&g.length===0&&d.jsx("p",{className:"text-sm text-muted-foreground",children:"No statuses configured."})]})})};function Vc(e,t){if(!t||!e)return;const r=t.split(".");let n=e;for(const o of r){if(n==null||typeof n!="object")return;n=n[o]}return n}function Do(e,t){if(t){const r=Vc(e,t);if(r!=null)return String(r)}return e.email!=null?String(e.email):e.personal_email!=null?String(e.personal_email):e.id!=null?String(e.id):JSON.stringify(e)}function kT(e,t,r,n){if(r?.length){const s=n??" | ",i=r.map(a=>Vc(e,a)).filter(a=>a!=null).map(a=>String(a));if(i.length)return i.join(s)}if(t){const s=Vc(e,t);if(s!=null)return String(s)}if(e.name!=null&&e.email!=null)return`${e.name} <${e.email}>`;if(e.name!=null)return String(e.name);if(e.email!=null)return String(e.email);const o=e.personal_email;return o!=null?String(o):JSON.stringify(e)}const _T=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,submissionContext:c})=>{const u=e.properties||{},{dataSourceContextKey:f,labelField:l="name",valueField:p="email",displayFields:g,displayFieldsSeparator:m=" | ",showSelectAll:h=!0,selectAllByDefault:y=!0}=u;console.log("[SelectableList] Step 1: render",{fieldName:e.name,valueIsArray:Array.isArray(t),valueLength:Array.isArray(t)?t.length:0,valueSample:Array.isArray(t)&&t.length>0?t.slice(0,2):t,submissionContextKeys:c?Object.keys(c):[],dataSourceContextKey:f,contextKeyValue:c&&f?c[f]:void 0});const S=v.useMemo(()=>{if(!f||!c)return[];const C=c[f];return Array.isArray(C)?C:[]},[f,c]);console.log("[SelectableList] Step 2: contextList from submissionContext",{fieldName:e.name,contextListLength:S.length,contextListSample:S.length>0?S.slice(0,2):[]});const[w,A]=v.useState(()=>S.length>0?S:Array.isArray(t)?t:[]);v.useEffect(()=>{if(S.length>0){console.log("[SelectableList] Step 3: sync fullList from context",{fieldName:e.name,contextListLength:S.length}),A(S);return}Array.isArray(t)&&t.length>0&&A(C=>{const I=C.length===0||t.length>C.length?t:C;return console.log("[SelectableList] Step 3: sync fullList from value",{fieldName:e.name,valueLength:t.length,prevLength:C.length,nextLength:I.length}),I})},[S,t]);const x=v.useMemo(()=>{const C=Array.isArray(t)?t:[];return new Set(C.map(W=>Do(W,p)))},[t,p]),F=w.length>0&&w.every(C=>x.has(Do(C,p))),N=w.some(C=>x.has(Do(C,p))),k=v.useCallback((C,I)=>{const W=Do(C,p),M=Array.isArray(t)?t:[];I?x.has(W)||r([...M,C]):r(M.filter(z=>Do(z,p)!==W)),n?.()},[t,p,x,r,n]),T=v.useCallback(C=>{r(C===!0?[...w]:[]),n?.()},[w,r,n]),P=w.length>0?w:Array.isArray(t)?t:[],E=s||e.disabled;return console.log("[SelectableList] Data in list",{fieldName:e.name,listLength:P.length,listSource:w.length>0?"fullList":"value",valueLength:Array.isArray(t)?t.length:0,fullListLength:w.length,listData:P.length>0?P:[],listDataFirstThree:P.length>0?P.slice(0,3):[]}),d.jsx("div",{className:H("relative z-10 flex flex-col min-h-0 h-full w-full",P.length>0&&"min-h-[14rem]",a),children:d.jsx(At,{field:e,error:o,isRequired:i,className:H("flex-1 min-h-0 flex flex-col",P.length>0&&"min-h-[14rem]"),children:d.jsx("div",{className:H("flex-1 min-h-0 flex flex-col",P.length>0&&"min-h-[14rem]"),children:d.jsxs("div",{className:H("flex-1 min-h-0 flex flex-col",P.length>0&&"overflow-visible"),children:[d.jsxs("div",{role:"listbox","aria-multiselectable":!0,className:H("border rounded-md divide-y overflow-y-auto overflow-x-hidden bg-muted/30 overscroll-contain touch-pan-y pb-3 pr-3 z-20 relative",P.length>0?"flex-1 min-h-0":"min-h-0"),children:[h&&P.length>0&&d.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 sticky top-0 bg-background border-b z-10 shrink-0",children:[d.jsx(Yi,{id:`${ft(e)}-select-all`,checked:F?!0:N?"indeterminate":!1,onCheckedChange:T,disabled:E,"aria-label":"Select all"}),d.jsxs(Fn,{htmlFor:`${ft(e)}-select-all`,className:"text-sm font-medium cursor-pointer",children:["Select all (",P.length,")"]}),d.jsxs("div",{className:"flex gap-1 ml-auto",children:[d.jsx(Zt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:E||F,onClick:()=>{r([...w]),n?.()},children:"Select all"}),d.jsx(Zt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:E||!N,onClick:()=>{r([]),n?.()},children:"Unselect all"})]})]}),P.length===0?d.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No items to display."}):d.jsx(d.Fragment,{children:P.map((C,I)=>{const W=Do(C,p),M=x.has(W),z=`${ft(e)}-${I}-${W}`;return d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 min-h-[2.5rem] hover:bg-muted/50 shrink-0",role:"row",children:[d.jsx(Yi,{id:z,checked:M,onCheckedChange:V=>k(C,V===!0),disabled:E,"aria-describedby":Lt(e,!!o)}),d.jsx(Fn,{htmlFor:z,className:"text-sm cursor-pointer flex-1 truncate",children:kT(C,l,g,m)})]},W)})})]}),P.length>0&&x.size===0&&d.jsxs("p",{className:"flex items-center gap-1.5 mt-2 text-sm text-amber-600 dark:text-amber-500 shrink-0",role:"status",children:[d.jsx(eS,{className:"h-4 w-4 shrink-0"}),"Please select at least one item."]})]})})})})},ay=({field:e,children:t,className:r})=>{const n=e.properties,o=n?.collapsible??!1,s=n?.defaultCollapsed??!1,i=n?.columns??1,[a,c]=v.useState(s),u=()=>{o&&c(!a)},f={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"};return d.jsxs("div",{className:H("border rounded-lg bg-card",r),children:[d.jsxs("div",{className:H("flex items-center gap-2 px-4 py-3 border-b bg-muted/50",o&&"cursor-pointer hover:bg-muted/70 transition-colors"),onClick:u,children:[o&&d.jsx("span",{className:"text-muted-foreground",children:a?d.jsx(Uu,{className:"h-4 w-4"}):d.jsx(ts,{className:"h-4 w-4"})}),d.jsx("h3",{className:"font-medium text-sm",children:e.label}),e.description&&d.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:e.description})]}),!a&&d.jsx("div",{className:H("p-4 grid gap-4",f[i]),children:t})]})};var TT=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],FT=TT.reduce((e,t)=>{const r=cl(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),PT="Separator",ly="horizontal",OT=["horizontal","vertical"],cy=b.forwardRef((e,t)=>{const{decorative:r,orientation:n=ly,...o}=e,s=IT(n)?n:ly,a=r?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return d.jsx(FT.div,{"data-orientation":s,...a,...o,ref:t})});cy.displayName=PT;function IT(e){return OT.includes(e)}var MT=cy;function Hc({className:e,orientation:t="horizontal",decorative:r=!0,...n}){return d.jsx(MT,{"data-slot":"separator",decorative:r,orientation:t,className:H("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...n})}const LT=({field:e,className:t})=>d.jsx("div",{className:H("py-2",t),children:d.jsx(Hc,{})}),DT={h1:"text-3xl font-bold",h2:"text-2xl font-bold",h3:"text-xl font-semibold",h4:"text-lg font-semibold",h5:"text-base font-medium",h6:"text-sm font-medium"},BT=({field:e,className:t})=>{const r=e.properties,n=r?.headingLevel??"h3",o=r?.showHorizontalLine??!0,s=DT[n],i=n;return d.jsxs("div",{className:H("w-full min-w-0 space-y-1",t),children:[d.jsx(i,{className:H("m-0 text-foreground",s),children:e.label||"Header"}),e.description&&d.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),o&&d.jsx(Hc,{className:"w-full"})]})},$T={"top-left":"justify-start","top-center":"justify-center","top-right":"justify-end","middle-left":"justify-start",center:"justify-center","middle-right":"justify-end","bottom-left":"justify-start","bottom-center":"justify-center","bottom-right":"justify-end"},jT={h1:"text-3xl font-bold",h2:"text-2xl font-bold",h3:"text-xl font-semibold",h4:"text-lg font-semibold",h5:"text-base font-medium",h6:"text-sm font-medium"},zT=({field:e,className:t})=>{const r=e.properties,n=r?.position??"top-left",o=r?.headingLevel??"h3",s=r?.showHorizontalLine??!0,i=$T[n],a=jT[o],c=o;return d.jsxs("div",{className:H("w-full min-w-0 space-y-2",t),children:[d.jsx("div",{className:H("flex w-full",i),children:d.jsx(c,{className:H("m-0 text-foreground",a),children:e.label||"Section Heading"})}),s&&d.jsx(Hc,{className:"w-full"})]})},UT=({field:e,className:t})=>{const r=e.appearance?.size||"md",n={sm:"h-4",md:"h-8",lg:"h-12"};return d.jsx("div",{className:H(n[r],t),"aria-hidden":"true"})};function dy(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function VT(e){if(Array.isArray(e))return e}function HT(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,s,i,a=[],c=!0,u=!1;try{if(s=(r=r.call(e)).next,t!==0)for(;!(c=(n=s.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(f){u=!0,o=f}finally{try{if(!c&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return a}}function WT(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
51
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function RT(e,t){return VT(e)||HT(e,t)||GT(e,t)||WT()}function GT(e,t){if(e){if(typeof e=="string")return dy(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?dy(e,t):void 0}}const uy=Object.entries,fy=Object.setPrototypeOf,KT=Object.isFrozen,qT=Object.getPrototypeOf,YT=Object.getOwnPropertyDescriptor;let dr=Object.freeze,Br=Object.seal,Bo=Object.create,py=typeof Reflect<"u"&&Reflect,Wc=py.apply,Rc=py.construct;dr||(dr=function(t){return t}),Br||(Br=function(t){return t}),Wc||(Wc=function(t,r){for(var n=arguments.length,o=new Array(n>2?n-2:0),s=2;s<n;s++)o[s-2]=arguments[s];return t.apply(r,o)}),Rc||(Rc=function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return new t(...n)});const $o=Vt(Array.prototype.forEach),XT=Vt(Array.prototype.lastIndexOf),my=Vt(Array.prototype.pop),jo=Vt(Array.prototype.push),JT=Vt(Array.prototype.splice),ur=Array.isArray,Ns=Vt(String.prototype.toLowerCase),Gc=Vt(String.prototype.toString),hy=Vt(String.prototype.match),zo=Vt(String.prototype.replace),gy=Vt(String.prototype.indexOf),QT=Vt(String.prototype.trim),ZT=Vt(Number.prototype.toString),eF=Vt(Boolean.prototype.toString),yy=typeof BigInt>"u"?null:Vt(BigInt.prototype.toString),by=typeof Symbol>"u"?null:Vt(Symbol.prototype.toString),Mt=Vt(Object.prototype.hasOwnProperty),ks=Vt(Object.prototype.toString),rr=Vt(RegExp.prototype.test),ga=tF(TypeError);function Vt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return Wc(e,t,n)}}function tF(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return Rc(e,r)}}function rt(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ns;if(fy&&fy(e,null),!ur(t))return e;let n=t.length;for(;n--;){let o=t[n];if(typeof o=="string"){const s=r(o);s!==o&&(KT(t)||(t[n]=s),o=s)}e[o]=!0}return e}function rF(e){for(let t=0;t<e.length;t++)Mt(e,t)||(e[t]=null);return e}function gr(e){const t=Bo(null);for(const n of uy(e)){var r=RT(n,2);const o=r[0],s=r[1];Mt(e,o)&&(ur(s)?t[o]=rF(s):s&&typeof s=="object"&&s.constructor===Object?t[o]=gr(s):t[o]=s)}return t}function nF(e){switch(typeof e){case"string":return e;case"number":return ZT(e);case"boolean":return eF(e);case"bigint":return yy?yy(e):"0";case"symbol":return by?by(e):"Symbol()";case"undefined":return ks(e);case"function":case"object":{if(e===null)return ks(e);const t=e,r=so(t,"toString");if(typeof r=="function"){const n=r(t);return typeof n=="string"?n:ks(n)}return ks(e)}default:return ks(e)}}function so(e,t){for(;e!==null;){const n=YT(e,t);if(n){if(n.get)return Vt(n.get);if(typeof n.value=="function")return Vt(n.value)}e=qT(e)}function r(){return null}return r}function oF(e){try{return rr(e,""),!0}catch{return!1}}const vy=dr(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Kc=dr(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),qc=dr(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),sF=dr(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Yc=dr(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),iF=dr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wy=dr(["#text"]),Sy=dr(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Xc=dr(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),xy=dr(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),ya=dr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),aF=Br(/{{[\w\W]*|^[\w\W]*}}/g),lF=Br(/<%[\w\W]*|^[\w\W]*%>/g),cF=Br(/\${[\w\W]*/g),dF=Br(/^data-[\-\w.\u00B7-\uFFFF]+$/),uF=Br(/^aria-[\-\w]+$/),Ay=Br(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),fF=Br(/^(?:\w+script|data):/i),pF=Br(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),mF=Br(/^html$/i),hF=Br(/^[a-z][.\w]*(-[.\w]+)+$/i),Uo={element:1,text:3,progressingInstruction:7,comment:8,document:9},gF=function(){return typeof window>"u"?null:window},yF=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const o="data-tt-policy-suffix";r&&r.hasAttribute(o)&&(n=r.getAttribute(o));const s="dompurify"+(n?"#"+n:"");try{return t.createPolicy(s,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Cy=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ey(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:gF();const t=_e=>Ey(_e);if(t.version="3.4.5",t.removed=[],!e||!e.document||e.document.nodeType!==Uo.document||!e.Element)return t.isSupported=!1,t;let r=e.document;const n=r,o=n.currentScript,s=e.DocumentFragment,i=e.HTMLTemplateElement,a=e.Node,c=e.Element,u=e.NodeFilter,f=e.NamedNodeMap,l=f===void 0?e.NamedNodeMap||e.MozNamedAttrMap:f,p=e.HTMLFormElement,g=e.DOMParser,m=e.trustedTypes,h=c.prototype,y=so(h,"cloneNode"),S=so(h,"remove"),w=so(h,"nextSibling"),A=so(h,"childNodes"),x=so(h,"parentNode"),F=a&&a.prototype?so(a.prototype,"nodeType"):null;if(typeof i=="function"){const _e=r.createElement("template");_e.content&&_e.content.ownerDocument&&(r=_e.content.ownerDocument)}let N,k="";const T=r,P=T.implementation,E=T.createNodeIterator,C=T.createDocumentFragment,I=T.getElementsByTagName,W=n.importNode;let M=Cy();t.isSupported=typeof uy=="function"&&typeof x=="function"&&P&&P.createHTMLDocument!==void 0;const z=aF,V=lF,X=cF,L=dF,B=uF,D=fF,K=pF,ae=hF;let j=Ay,U=null;const le=rt({},[...vy,...Kc,...qc,...Yc,...wy]);let oe=null;const G=rt({},[...Sy,...Xc,...xy,...ya]);let ie=Object.seal(Bo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ce=null,ee=null;const ne=Object.seal(Bo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let he=!0,Ie=!0,Ue=!1,re=!0,ge=!1,Se=!0,pt=!1,Dt=!1,Bt=!1,Pt=!1,Ar=!1,Nt=!1,Cr=!0,Xe=!1;const ve="user-content-";let ce=!0,J=!1,$={},fe=null;const it=rt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Te=null;const Ye=rt({},["audio","video","img","source","image","track"]);let Me=null;const xe=rt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),et="http://www.w3.org/1998/Math/MathML",We="http://www.w3.org/2000/svg",dt="http://www.w3.org/1999/xhtml";let bt=dt,ir=!1,xt=null;const $e=rt({},[et,We,dt],Gc);let gt=rt({},["mi","mo","mn","ms","mtext"]),vt=rt({},["annotation-xml"]);const kt=rt({},["title","style","font","a","script"]);let nr=null;const yr=["application/xhtml+xml","text/html"],Er="text/html";let Ot=null,Nr=null;const ar=r.createElement("form"),Sn=function(O){return O instanceof RegExp||O instanceof Function},un=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Nr&&Nr===O)return;(!O||typeof O!="object")&&(O={}),O=gr(O),nr=yr.indexOf(O.PARSER_MEDIA_TYPE)===-1?Er:O.PARSER_MEDIA_TYPE,Ot=nr==="application/xhtml+xml"?Gc:Ns,U=Mt(O,"ALLOWED_TAGS")&&ur(O.ALLOWED_TAGS)?rt({},O.ALLOWED_TAGS,Ot):le,oe=Mt(O,"ALLOWED_ATTR")&&ur(O.ALLOWED_ATTR)?rt({},O.ALLOWED_ATTR,Ot):G,xt=Mt(O,"ALLOWED_NAMESPACES")&&ur(O.ALLOWED_NAMESPACES)?rt({},O.ALLOWED_NAMESPACES,Gc):$e,Me=Mt(O,"ADD_URI_SAFE_ATTR")&&ur(O.ADD_URI_SAFE_ATTR)?rt(gr(xe),O.ADD_URI_SAFE_ATTR,Ot):xe,Te=Mt(O,"ADD_DATA_URI_TAGS")&&ur(O.ADD_DATA_URI_TAGS)?rt(gr(Ye),O.ADD_DATA_URI_TAGS,Ot):Ye,fe=Mt(O,"FORBID_CONTENTS")&&ur(O.FORBID_CONTENTS)?rt({},O.FORBID_CONTENTS,Ot):it,Ce=Mt(O,"FORBID_TAGS")&&ur(O.FORBID_TAGS)?rt({},O.FORBID_TAGS,Ot):gr({}),ee=Mt(O,"FORBID_ATTR")&&ur(O.FORBID_ATTR)?rt({},O.FORBID_ATTR,Ot):gr({}),$=Mt(O,"USE_PROFILES")?O.USE_PROFILES&&typeof O.USE_PROFILES=="object"?gr(O.USE_PROFILES):O.USE_PROFILES:!1,he=O.ALLOW_ARIA_ATTR!==!1,Ie=O.ALLOW_DATA_ATTR!==!1,Ue=O.ALLOW_UNKNOWN_PROTOCOLS||!1,re=O.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ge=O.SAFE_FOR_TEMPLATES||!1,Se=O.SAFE_FOR_XML!==!1,pt=O.WHOLE_DOCUMENT||!1,Pt=O.RETURN_DOM||!1,Ar=O.RETURN_DOM_FRAGMENT||!1,Nt=O.RETURN_TRUSTED_TYPE||!1,Bt=O.FORCE_BODY||!1,Cr=O.SANITIZE_DOM!==!1,Xe=O.SANITIZE_NAMED_PROPS||!1,ce=O.KEEP_CONTENT!==!1,J=O.IN_PLACE||!1,j=oF(O.ALLOWED_URI_REGEXP)?O.ALLOWED_URI_REGEXP:Ay,bt=typeof O.NAMESPACE=="string"?O.NAMESPACE:dt,gt=Mt(O,"MATHML_TEXT_INTEGRATION_POINTS")&&O.MATHML_TEXT_INTEGRATION_POINTS&&typeof O.MATHML_TEXT_INTEGRATION_POINTS=="object"?gr(O.MATHML_TEXT_INTEGRATION_POINTS):rt({},["mi","mo","mn","ms","mtext"]),vt=Mt(O,"HTML_INTEGRATION_POINTS")&&O.HTML_INTEGRATION_POINTS&&typeof O.HTML_INTEGRATION_POINTS=="object"?gr(O.HTML_INTEGRATION_POINTS):rt({},["annotation-xml"]);const te=Mt(O,"CUSTOM_ELEMENT_HANDLING")&&O.CUSTOM_ELEMENT_HANDLING&&typeof O.CUSTOM_ELEMENT_HANDLING=="object"?gr(O.CUSTOM_ELEMENT_HANDLING):Bo(null);if(ie=Bo(null),Mt(te,"tagNameCheck")&&Sn(te.tagNameCheck)&&(ie.tagNameCheck=te.tagNameCheck),Mt(te,"attributeNameCheck")&&Sn(te.attributeNameCheck)&&(ie.attributeNameCheck=te.attributeNameCheck),Mt(te,"allowCustomizedBuiltInElements")&&typeof te.allowCustomizedBuiltInElements=="boolean"&&(ie.allowCustomizedBuiltInElements=te.allowCustomizedBuiltInElements),ge&&(Ie=!1),Ar&&(Pt=!0),$&&(U=rt({},wy),oe=Bo(null),$.html===!0&&(rt(U,vy),rt(oe,Sy)),$.svg===!0&&(rt(U,Kc),rt(oe,Xc),rt(oe,ya)),$.svgFilters===!0&&(rt(U,qc),rt(oe,Xc),rt(oe,ya)),$.mathMl===!0&&(rt(U,Yc),rt(oe,xy),rt(oe,ya))),ne.tagCheck=null,ne.attributeCheck=null,Mt(O,"ADD_TAGS")&&(typeof O.ADD_TAGS=="function"?ne.tagCheck=O.ADD_TAGS:ur(O.ADD_TAGS)&&(U===le&&(U=gr(U)),rt(U,O.ADD_TAGS,Ot))),Mt(O,"ADD_ATTR")&&(typeof O.ADD_ATTR=="function"?ne.attributeCheck=O.ADD_ATTR:ur(O.ADD_ATTR)&&(oe===G&&(oe=gr(oe)),rt(oe,O.ADD_ATTR,Ot))),Mt(O,"ADD_URI_SAFE_ATTR")&&ur(O.ADD_URI_SAFE_ATTR)&&rt(Me,O.ADD_URI_SAFE_ATTR,Ot),Mt(O,"FORBID_CONTENTS")&&ur(O.FORBID_CONTENTS)&&(fe===it&&(fe=gr(fe)),rt(fe,O.FORBID_CONTENTS,Ot)),Mt(O,"ADD_FORBID_CONTENTS")&&ur(O.ADD_FORBID_CONTENTS)&&(fe===it&&(fe=gr(fe)),rt(fe,O.ADD_FORBID_CONTENTS,Ot)),ce&&(U["#text"]=!0),pt&&rt(U,["html","head","body"]),U.table&&(rt(U,["tbody"]),delete Ce.tbody),O.TRUSTED_TYPES_POLICY){if(typeof O.TRUSTED_TYPES_POLICY.createHTML!="function")throw ga('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof O.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ga('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=O.TRUSTED_TYPES_POLICY,k=N.createHTML("")}else N===void 0&&(N=yF(m,o)),N!==null&&typeof k=="string"&&(k=N.createHTML(""));dr&&dr(O),Nr=O},jr=rt({},[...Kc,...qc,...sF]),zn=rt({},[...Yc,...iF]),$t=function(O){let te=x(O);(!te||!te.tagName)&&(te={namespaceURI:bt,tagName:"template"});const we=Ns(O.tagName),st=Ns(te.tagName);return xt[O.namespaceURI]?O.namespaceURI===We?te.namespaceURI===dt?we==="svg":te.namespaceURI===et?we==="svg"&&(st==="annotation-xml"||gt[st]):!!jr[we]:O.namespaceURI===et?te.namespaceURI===dt?we==="math":te.namespaceURI===We?we==="math"&&vt[st]:!!zn[we]:O.namespaceURI===dt?te.namespaceURI===We&&!vt[st]||te.namespaceURI===et&&!gt[st]?!1:!zn[we]&&(kt[we]||!jr[we]):!!(nr==="application/xhtml+xml"&&xt[O.namespaceURI]):!1},Ht=function(O){jo(t.removed,{element:O});try{x(O).removeChild(O)}catch{S(O)}},br=function(O,te){try{jo(t.removed,{attribute:te.getAttributeNode(O),from:te})}catch{jo(t.removed,{attribute:null,from:te})}if(te.removeAttribute(O),O==="is")if(Pt||Ar)try{Ht(te)}catch{}else try{te.setAttribute(O,"")}catch{}},Jr=function(O){let te=null,we=null;if(Bt)O="<remove></remove>"+O;else{const St=hy(O,/^[\r\n\t ]+/);we=St&&St[0]}nr==="application/xhtml+xml"&&bt===dt&&(O='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+O+"</body></html>");const st=N?N.createHTML(O):O;if(bt===dt)try{te=new g().parseFromString(st,nr)}catch{}if(!te||!te.documentElement){te=P.createDocument(bt,"template",null);try{te.documentElement.innerHTML=ir?k:st}catch{}}const wt=te.body||te.documentElement;return O&&we&&wt.insertBefore(r.createTextNode(we),wt.childNodes[0]||null),bt===dt?I.call(te,pt?"html":"body")[0]:pt?te.documentElement:wt},Yt=function(O){return E.call(O.ownerDocument||O,O,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},lr=function(O){O.normalize();const te=E.call(O.ownerDocument||O,O,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let we=te.nextNode();for(;we;){let st=we.data;$o([z,V,X],wt=>{st=zo(st,wt," ")}),we.data=st,we=te.nextNode()}},Un=function(O){return O instanceof p&&(typeof O.nodeName!="string"||typeof O.textContent!="string"||typeof O.removeChild!="function"||!(O.attributes instanceof l)||typeof O.removeAttribute!="function"||typeof O.setAttribute!="function"||typeof O.namespaceURI!="string"||typeof O.insertBefore!="function"||typeof O.hasChildNodes!="function")},Ls=function(O){if(!F||typeof O!="object"||O===null)return!1;try{return typeof F(O)=="number"}catch{return!1}};function _t(_e,O,te){$o(_e,we=>{we.call(t,O,te,Nr)})}const Ds=function(O){let te=null;if(_t(M.beforeSanitizeElements,O,null),Un(O))return Ht(O),!0;const we=Ot(O.nodeName);if(_t(M.uponSanitizeElement,O,{tagName:we,allowedTags:U}),Se&&O.hasChildNodes()&&!Ls(O.firstElementChild)&&rr(/<[/\w!]/g,O.innerHTML)&&rr(/<[/\w!]/g,O.textContent)||Se&&O.namespaceURI===dt&&we==="style"&&Ls(O.firstElementChild)||O.nodeType===Uo.progressingInstruction||Se&&O.nodeType===Uo.comment&&rr(/<[/\w]/g,O.data))return Ht(O),!0;if(Ce[we]||!(ne.tagCheck instanceof Function&&ne.tagCheck(we))&&!U[we]){if(!Ce[we]&&zr(we)&&(ie.tagNameCheck instanceof RegExp&&rr(ie.tagNameCheck,we)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(we)))return!1;if(ce&&!fe[we]){const st=x(O)||O.parentNode,wt=A(O)||O.childNodes;if(wt&&st){const St=wt.length;for(let Wt=St-1;Wt>=0;--Wt){const Et=y(wt[Wt],!0);st.insertBefore(Et,w(O))}}}return Ht(O),!0}return O instanceof c&&!$t(O)||(we==="noscript"||we==="noembed"||we==="noframes")&&rr(/<\/no(script|embed|frames)/i,O.innerHTML)?(Ht(O),!0):(ge&&O.nodeType===Uo.text&&(te=O.textContent,$o([z,V,X],st=>{te=zo(te,st," ")}),O.textContent!==te&&(jo(t.removed,{element:O.cloneNode()}),O.textContent=te)),_t(M.afterSanitizeElements,O,null),!1)},kr=function(O,te,we){if(ee[te]||Cr&&(te==="id"||te==="name")&&(we in r||we in ar))return!1;const st=oe[te]||ne.attributeCheck instanceof Function&&ne.attributeCheck(te,O);if(!(Ie&&!ee[te]&&rr(L,te))){if(!(he&&rr(B,te))){if(!st||ee[te]){if(!(zr(O)&&(ie.tagNameCheck instanceof RegExp&&rr(ie.tagNameCheck,O)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(O))&&(ie.attributeNameCheck instanceof RegExp&&rr(ie.attributeNameCheck,te)||ie.attributeNameCheck instanceof Function&&ie.attributeNameCheck(te,O))||te==="is"&&ie.allowCustomizedBuiltInElements&&(ie.tagNameCheck instanceof RegExp&&rr(ie.tagNameCheck,we)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(we))))return!1}else if(!Me[te]){if(!rr(j,zo(we,K,""))){if(!((te==="src"||te==="xlink:href"||te==="href")&&O!=="script"&&gy(we,"data:")===0&&Te[O])){if(!(Ue&&!rr(D,zo(we,K,"")))){if(we)return!1}}}}}}return!0},Qr=rt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),zr=function(O){return!Qr[Ns(O)]&&rr(ae,O)},Ur=function(O){_t(M.beforeSanitizeAttributes,O,null);const te=O.attributes;if(!te||Un(O))return;const we={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:oe,forceKeepAttr:void 0};let st=te.length;for(;st--;){const wt=te[st],St=wt.name,Wt=wt.namespaceURI,Et=wt.value,Vr=Ot(St),Ho=Et;let It=St==="value"?Ho:QT(Ho);if(we.attrName=Vr,we.attrValue=It,we.keepAttr=!0,we.forceKeepAttr=void 0,_t(M.uponSanitizeAttribute,O,we),It=we.attrValue,Xe&&(Vr==="id"||Vr==="name")&&gy(It,ve)!==0&&(br(St,O),It=ve+It),Se&&rr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,It)){br(St,O);continue}if(Vr==="attributename"&&hy(It,"href")){br(St,O);continue}if(we.forceKeepAttr)continue;if(!we.keepAttr){br(St,O);continue}if(!re&&rr(/\/>/i,It)){br(St,O);continue}ge&&$o([z,V,X],xn=>{It=zo(It,xn," ")});const fn=Ot(O.nodeName);if(!kr(fn,Vr,It)){br(St,O);continue}if(N&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Wt)switch(m.getAttributeType(fn,Vr)){case"TrustedHTML":{It=N.createHTML(It);break}case"TrustedScriptURL":{It=N.createScriptURL(It);break}}if(It!==Ho)try{Wt?O.setAttributeNS(Wt,St,It):O.setAttribute(St,It),Un(O)?Ht(O):my(t.removed)}catch{br(St,O)}}_t(M.afterSanitizeAttributes,O,null)},_r=function(O){let te=null;const we=Yt(O);for(_t(M.beforeSanitizeShadowDOM,O,null);te=we.nextNode();)_t(M.uponSanitizeShadowNode,te,null),Ds(te),Ur(te),te.content instanceof s&&_r(te.content);_t(M.afterSanitizeShadowDOM,O,null)},Xt=function(O){if(O.nodeType===Uo.element&&O.shadowRoot instanceof s){const st=O.shadowRoot;Xt(st),_r(st)}const te=O.childNodes;if(!te)return;const we=[];$o(te,st=>{jo(we,st)});for(const st of we)Xt(st)};return t.sanitize=function(_e){let O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},te=null,we=null,st=null,wt=null;if(ir=!_e,ir&&(_e="<!-->"),typeof _e!="string"&&!Ls(_e)&&(_e=nF(_e),typeof _e!="string"))throw ga("dirty is not a string, aborting");if(!t.isSupported)return _e;if(Dt||un(O),t.removed=[],typeof _e=="string"&&(J=!1),J){const Et=_e.nodeName;if(typeof Et=="string"){const Vr=Ot(Et);if(!U[Vr]||Ce[Vr])throw ga("root node is forbidden and cannot be sanitized in-place")}Xt(_e)}else if(Ls(_e))te=Jr("<!---->"),we=te.ownerDocument.importNode(_e,!0),we.nodeType===Uo.element&&we.nodeName==="BODY"||we.nodeName==="HTML"?te=we:te.appendChild(we),Xt(we);else{if(!Pt&&!ge&&!pt&&_e.indexOf("<")===-1)return N&&Nt?N.createHTML(_e):_e;if(te=Jr(_e),!te)return Pt?null:Nt?k:""}te&&Bt&&Ht(te.firstChild);const St=Yt(J?_e:te);for(;st=St.nextNode();)Ds(st),Ur(st),st.content instanceof s&&_r(st.content);if(J)return ge&&lr(_e),_e;if(Pt){if(ge&&lr(te),Ar)for(wt=C.call(te.ownerDocument);te.firstChild;)wt.appendChild(te.firstChild);else wt=te;return(oe.shadowroot||oe.shadowrootmode)&&(wt=W.call(n,wt,!0)),wt}let Wt=pt?te.outerHTML:te.innerHTML;return pt&&U["!doctype"]&&te.ownerDocument&&te.ownerDocument.doctype&&te.ownerDocument.doctype.name&&rr(mF,te.ownerDocument.doctype.name)&&(Wt="<!DOCTYPE "+te.ownerDocument.doctype.name+`>
52
- `+Wt),ge&&$o([z,V,X],Et=>{Wt=zo(Wt,Et," ")}),N&&Nt?N.createHTML(Wt):Wt},t.setConfig=function(){let _e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};un(_e),Dt=!0},t.clearConfig=function(){Nr=null,Dt=!1},t.isValidAttribute=function(_e,O,te){Nr||un({});const we=Ot(_e),st=Ot(O);return kr(we,st,te)},t.addHook=function(_e,O){typeof O=="function"&&jo(M[_e],O)},t.removeHook=function(_e,O){if(O!==void 0){const te=XT(M[_e],O);return te===-1?void 0:JT(M[_e],te,1)[0]}return my(M[_e])},t.removeHooks=function(_e){M[_e]=[]},t.removeAllHooks=function(){M=Cy()},t}var bF=Ey();const vF=["a","b","br","div","em","h1","h2","h3","h4","h5","h6","i","img","li","ol","p","span","strong","table","tbody","td","th","thead","tr","u","ul"],wF=["href","target","rel","src","alt","title","class","style","colspan","rowspan"];function SF(e){return e?bF.sanitize(e,{ALLOWED_TAGS:[...vF],ALLOWED_ATTR:[...wF],ALLOW_DATA_ATTR:!1}):""}function xF(e,t,r=!1){return e.includes("{labelapi:")?e.replace(/\{labelapi:([^}]+)\}/g,(n,o)=>{const s=o.trim();if(s===""||t==null)return r?"":n;const i=Ge(t,s);return i==null?r?"":n:String(i)}):e}function AF(e){return e&&e.replace(/\{api:[^}]*\}/gi,"").replace(/\{labelapi:[^}]*\}/gi,"").replace(/\{resp:[^}]*\}/gi,"").replace(/\{(?:ctx:|@)\w+\}/gi,"").replace(/\{documentId\}/gi,"").replace(/\{(\w+)\}/g,"")}const Ny={sm:"text-sm",md:"text-base",lg:"text-lg"},ky={h1:"text-4xl font-bold tracking-tight",h2:"text-3xl font-semibold tracking-tight",h3:"text-2xl font-semibold",h4:"text-xl font-semibold",h5:"text-lg font-medium",h6:"text-base font-medium"},_y={normal:"font-normal",medium:"font-medium",bold:"font-bold"},ba={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"};function io(e){return e.properties??{}}function CF(e){const t=io(e);return t.textContent!==void 0?t.textContent:e.label??""}function EF(e){return io(e).textContent===void 0||e.appearance?.hideLabel?!1:!!e.label?.trim()}function NF(e){return e?.contentLayout==="paragraph"?"paragraph":"single"}function Jc(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:a}=t,c=Lr(e,r,n,o,s,i),u=xF(c,a,!0);return AF(u)}const kF=/\{api:[^}]+\}/,_F=/\{labelapi:[^}]+\}/;function Qc(e){return kF.test(e)}function Zc(e){return _F.test(e)}function TF(e){const t=e.captionTemplate??"",r=e.descriptionTemplate??"",n=Qc(e.bodyTemplate)||Qc(t)||Qc(r),o=Zc(e.bodyTemplate)||Zc(t)||Zc(r);return!!(n&&e.prepopulateLoading||o&&e.labelApiConfigPresent&&(e.labelApiLoading||e.labelApiResponse===void 0&&e.labelApiError==null))}function Ty(e,t){const r=t??io(e),n=r.variant??"body",o=e.appearance?.size??"md",s=Ny[o]??Ny.md,i=r.fontWeight??"medium";return n!=="body"?H("m-0 text-foreground",ky[n]??ky.h3,r.fontWeight&&_y[r.fontWeight],r.italic&&"italic",r.underline&&"underline",r.textAlign&&ba[r.textAlign]):H("m-0 text-foreground",s,_y[i],r.italic&&"italic",r.underline&&"underline",r.textAlign&&ba[r.textAlign])}function FF(e,t){const r=(t??io(e)).variant??"body";return r==="body"?"p":r}function ed(e){const t=[];let r=0,n="";const o=()=>{n&&(t.push({type:"text",value:n}),n="")},s=(i,a,c)=>{if(!e.startsWith(i,r))return!1;const u=e.indexOf(a,r+i.length);if(u===-1)return!1;o();const f=e.slice(r+i.length,u);return t.push({type:c,children:ed(f)}),r=u+a.length,!0};for(;r<e.length;){if(e[r]==="\\"&&r+1<e.length){n+=e[r+1],r+=2;continue}s("**","**","bold")||s("__","__","underline")||s("*","*","italic")||s("_","_","italic")||(n+=e[r],r+=1)}return o(),t}function PF(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Fy(e){return e.map(t=>{if(t.type==="text")return PF(t.value);const r=Fy(t.children);return t.type==="bold"?`<strong class="font-bold">${r}</strong>`:t.type==="italic"?`<em class="italic">${r}</em>`:`<u class="underline">${r}</u>`}).join("")}function OF(e){return e?Fy(ed(e)):""}function IF(e,t){return e?t==="markdown-lite"?OF(e):e:""}function Py(e,t){return e.map((r,n)=>{const o=`${t}-${n}`;if(r.type==="text")return r.value?v.createElement(v.Fragment,{key:o},r.value):null;const s=Py(r.children,o);return r.type==="bold"?v.createElement("strong",{key:o,className:"font-bold"},s):r.type==="italic"?v.createElement("em",{key:o,className:"italic"},s):v.createElement("u",{key:o,className:"underline"},s)})}function Oy(e,t){if(!e)return null;if(t!=="markdown-lite")return e;const r=ed(e);return r.length===1&&r[0]?.type==="text"?r[0].value:Py(r,"tl")}const MF="text-label-html prose prose-sm max-w-none [&_p]:m-0 [&_p+p]:mt-2 [&_ul]:my-1 [&_ol]:my-1";function Iy(e,t){if(!e)return null;const{field:r,asDescription:n=!1}=t,o=t.textProps??io(r),s=t.contentLayout??NF(o),i=o.inlineFormat??"none";if(s==="paragraph"){const c=SF(IF(e,i));if(!c)return null;const u=n?H("m-0 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&ba[o.textAlign]):H(Ty(r,o),MF);return v.createElement("div",{className:u,dangerouslySetInnerHTML:{__html:c}})}if(n)return v.createElement("p",{className:H("mt-0.5 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&ba[o.textAlign])},Oy(e,i));const a=FF(r,o);return v.createElement(a,{className:Ty(r,o)},Oy(e,i))}function LF(e){const t=e.labelApiEndpoint?.trim();return!e.labelApiEnabled||!t?null:{labelApiEndpoint:t,labelApiMethod:e.labelApiMethod??"GET",labelApiQueryParams:e.labelApiQueryParams,labelApiHeaders:e.labelApiHeaders,labelApiBodyFields:e.labelApiBodyFields}}async function DF(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o}=t,s=l=>Lr(l,r,n,o),i=(e.labelApiMethod??"GET").toUpperCase();let a=Mr(s(e.labelApiEndpoint));const c=e.labelApiQueryParams??[];if(c.length){const l=new URLSearchParams;c.forEach(({key:g,value:m})=>{g.trim()&&l.append(g,s(m))});const p=l.toString();p&&(a=`${a}${a.includes("?")?"&":"?"}${p}`)}const u={"Content-Type":"application/json"};(e.labelApiHeaders??[]).forEach(({key:l,value:p})=>{l.trim()&&(u[l]=s(p))});let f;i==="POST"&&(e.labelApiBodyFields??[]).length&&(f={},e.labelApiBodyFields.forEach(({key:l,value:p})=>{l.trim()&&(f[l]=s(p))}));try{return i==="POST"?(await Qt.post(a,f??{},{headers:Object.keys(u).length?u:void 0})).data:(await Qt.get(a,{headers:Object.keys(u).length?u:void 0})).data}catch(l){const p=l,g=p.response?.status,m=typeof p.response?.data=="string"?p.response.data:p.message??"Request failed";throw new Error(g?`HTTP ${g}: ${m}`:String(m))}}const BF=({field:e,className:t,formValues:r,urlParams:n,submissionContext:o,buttonResponses:s,prepopulateResponse:i,prepopulateLoading:a=!1})=>{const c=io(e),u=v.useMemo(()=>LF(io(e)),[e.properties]),[f,l]=v.useState(void 0),[p,g]=v.useState(!1),[m,h]=v.useState(null),y=v.useMemo(()=>u?JSON.stringify({endpoint:u.labelApiEndpoint,method:u.labelApiMethod,query:u.labelApiQueryParams,headers:u.labelApiHeaders,body:u.labelApiBodyFields}):"",[u]),S=v.useCallback(async()=>{if(!u){l(void 0),h(null),g(!1);return}g(!0),h(null);try{const I=await DF(u,{formValues:r??{},urlParams:n??{},submissionContext:o});l(I)}catch(I){l(void 0),h(I instanceof Error?I.message:"Failed to load label API")}finally{g(!1)}},[u,r,n,o]);v.useEffect(()=>{y&&S()},[y,S]);const w=c.textAlign==="center"?"items-center":c.textAlign==="right"?"items-end":c.textAlign==="justify"?"items-stretch":"items-start",A=CF(e),x=EF(e),F=x&&e.label?e.label:"",N=e.description??"",k=TF({bodyTemplate:A,captionTemplate:F,descriptionTemplate:N,prepopulateLoading:a,labelApiConfigPresent:u!=null,labelApiLoading:p,labelApiResponse:f,labelApiError:m}),T={formValues:r??{},urlParams:n??{},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:f},P=A?Jc(A,T):"",E=x&&e.label?Jc(e.label,T):"",C=N?Jc(N,T):"";return d.jsx("div",{className:H("w-full min-w-0 h-full min-h-[95px] flex flex-col justify-center py-0.5",w,t),children:k?d.jsx("p",{className:"text-sm text-muted-foreground m-0",children:"Loading…"}):d.jsxs(d.Fragment,{children:[m&&u?d.jsx("p",{className:"text-[10px] text-destructive mb-0.5",title:m,children:"Label API failed"}):null,E?d.jsx("div",{className:"text-sm font-medium text-foreground mb-1 w-full",children:E}):null,P?Iy(P,{field:e,textProps:c}):null,C?Iy(C,{field:e,textProps:c,asDescription:!0}):null]})})},td=({legend:e,children:t,className:r,collapsible:n=!1,defaultCollapsed:o=!1,headerActions:s,onCollapsedChange:i})=>{const[a,c]=v.useState(o),u=v.useId(),f=l=>{l.stopPropagation(),n&&c(p=>{const g=!p;return i?.(g),g})};return d.jsxs("fieldset",{className:H("min-w-0 rounded-lg border bg-card p-4",r),"data-form-renderer":"config-section-border",children:[n?d.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2 border-b border-border pb-2",children:[d.jsxs("button",{type:"button",className:H("flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-medium text-foreground","cursor-pointer rounded-sm hover:bg-muted/70 transition-colors focus:outline-none focus:ring-2 focus:ring-ring"),"aria-expanded":!a,"aria-controls":u,onClick:f,children:[d.jsx("span",{className:"shrink-0 text-muted-foreground","aria-hidden":!0,children:a?d.jsx(Uu,{className:"h-4 w-4"}):d.jsx(ts,{className:"h-4 w-4"})}),d.jsx("span",{className:"truncate",children:e})]}),s!=null?d.jsx("div",{className:"shrink-0",children:s}):null]}):d.jsx("legend",{className:"px-1 text-sm font-medium text-foreground",children:e}),!a&&d.jsxs("div",{id:u,className:"space-y-3",children:[!n&&s!=null?d.jsx("div",{className:"flex justify-end",children:s}):null,t]})]})};function My(e){const t=e.properties,r=t?.apiEndpoint?{apiEndpoint:t.apiEndpoint,apiMethod:t.apiMethod,apiKey:t.apiKey,apiRealtime:t.apiRealtime,apiAutoDetect:t.apiAutoDetect,apiLabelField:t.apiLabelField,apiValueField:t.apiValueField,apiQueryParams:t.apiQueryParams,apiClientFilter:t.apiClientFilter,apiHeaders:t.apiHeaders,apiBodyFields:t.apiBodyFields,apiAuth:t.apiAuth,valueSource:t.valueSource,dependentFields:t.dependentFields}:null,n=e.apidata||null;return r||n}function rd(e){const t=My(e),r=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||r?.valueSource==="api"))}function Ly({field:e,formValues:t={},submissionContext:r,value:n,onChange:o,clearWhenBlocked:s=!0}){const i=e.properties,a=My(e),c=rd(e),[u,f]=v.useState(!1),[l,p]=v.useState(null),g=v.useRef(null),m=v.useRef(n);m.current=n;const h=v.useMemo(()=>{const F=a?.apiEndpoint||i?.apiEndpoint||"",N=a?.apiQueryParams||i?.apiQueryParams;return po(F,N)},[a?.apiEndpoint,i?.apiEndpoint,a?.apiQueryParams,i?.apiQueryParams]),y=v.useMemo(()=>{const F=new Set;for(const k of i?.dependentFields??a?.dependentFields??[])typeof k=="string"&&k.trim()&&F.add(k.trim());const N=a?.apiClientFilter?.matchField?.trim()||i?.apiClientFilter?.matchField?.trim();return N&&F.add(N),[...F]},[i?.dependentFields,a?.dependentFields,a?.apiClientFilter?.matchField,i?.apiClientFilter?.matchField]),S=v.useMemo(()=>{const F=new Set([...h,...y]);if(F.size===0)return null;const N={};return F.forEach(k=>{N[k]=t[k]}),JSON.stringify(N)},[h,y,t]),w=v.useMemo(()=>JSON.stringify(r||{}),[r]),A=v.useMemo(()=>{const F=new Set;e.name?.trim()&&F.add(e.name.trim());const N=e.key;return typeof N=="string"&&N.trim()&&F.add(N.trim()),[...F]},[e.name,e.key]),x=e.type==="number"?null:"";return v.useEffect(()=>{const F=a?.apiEndpoint;if(!c||!F)return;let N=!1;const k=P=>{if(N)return;const E=m.current;if(P==null||P.trim()===""){s&&E!==x&&E!==void 0&&(g.current=null,o(x));return}if(e.type==="number"){const C=Number(P),I=Number.isFinite(C)?C:null;E!==I&&g.current!==P&&(g.current=P,o(I));return}String(E??"")!==P&&g.current!==P&&(g.current=P,o(P))};return(async()=>{f(!0),p(null);try{const P=a?.apiMethod||i?.apiMethod||"GET",E=a?.apiRealtime||i?.apiRealtime,C=a?.apiQueryParams||i?.apiQueryParams||{},I=Qs({apiEndpoint:F,apiMethod:P,apiQueryParams:C,formValues:t,submissionContext:r,apiRealtime:E,additionalRequiredFieldNames:y,excludeFormFieldNames:A});if(I.blocked){N||(f(!1),s&&k(null));return}const W={"Content-Type":"application/json"},M=a?.apiKey||i?.apiKey;M&&(W["X-CSCAPI-KEY"]=M);const z=e.apidata,V=a?.apiAuth??i?.apiAuth??z?.apiAuth??Hi(a?.apiHeaders??i?.apiHeaders??z?.apiHeaders)??{type:"none"},X=Ri(V,{formValues:t,submissionContext:r,apiRealtime:E});Object.assign(W,X);const L=a?.apiHeaders??i?.apiHeaders??z?.apiHeaders,B=a?.apiBodyFields??i?.apiBodyFields??z?.apiBodyFields,D=Bn(Vi(L),{formValues:t,submissionContext:r,apiRealtime:E});Object.assign(W,D);const K=Bn(B,{formValues:t,submissionContext:r,apiRealtime:E}),ae={method:P.toLowerCase(),url:Mr(I.url),headers:W};(I.postBodyBase!=null||Object.keys(K).length>0)&&(ae.data={...I.postBodyBase??{},...K});const j=await Ct(ae),U=a?.apiLabelField||i?.apiLabelField,le=a?.apiValueField||i?.apiValueField,oe=a?.apiClientFilter||i?.apiClientFilter;let G=ME(j.data,le,U);if(oe?.filterField&&oe?.matchField&&G!=null){const ie=t[oe.matchField];if(ie==null)G=null;else{const Ce=ys(j.data,U,le),ee=Array.isArray(j.data)?j.data:j.data?.data?.data&&Array.isArray(j.data.data.data)?j.data.data.data:j.data?.data&&Array.isArray(j.data.data)?j.data.data:[],ne=Ce.filter(he=>{const Ie=ee.find(re=>String(Ut(re,le||"code"))===String(he.value));if(!Ie)return!1;const Ue=Ut(Ie,oe.filterField);return String(Ue)===String(ie)});G=ne.length>0?ne[0].value:null}}N||k(G)}catch(P){if(N)return;let E="Failed to load value";const C=P;if(C.response){const I=C.response.data;if(C.response.status===404)E="API endpoint not found.";else if(C.response.status===401)E="Authentication failed.";else if(typeof I=="string")E=I;else if(I&&typeof I=="object"){const W=I;E=W.error||W.message||W.detail||E}}else C.message&&(E=String(C.message));p(E)}finally{N||f(!1)}})(),()=>{N=!0}},[c,a?.apiEndpoint,a?.apiMethod,a?.apiValueField,a?.apiLabelField,i?.apiEndpoint,i?.apiMethod,i?.apiValueField,i?.apiLabelField,S,y,A,w,e.type,s,x]),{isLoading:u,error:l}}const $F=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:s,readOnly:i,...a})=>{const{isLoading:c}=Ly({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return d.jsx(ri,{field:e,value:t||"",onChange:r,disabled:s||c,readOnly:i||c,...a})},jF=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:s,readOnly:i,...a})=>{const{isLoading:c}=Ly({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return d.jsx(dl,{field:e,value:t??null,onChange:r,disabled:s||c,readOnly:i||c,...a})},wn=({field:e,value:t,error:r,onChange:n,onBlur:o,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u={},submissionContext:f,onSubmit:l,onReset:p,onCancel:g,isSubmitting:m,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:S,buttonResponses:w,onButtonApiResponse:A,onValidateForm:x,getValidationErrors:F,allFields:N,onSubmittingChange:k,onAddMore:T,scopedFormValues:P,scopedFieldNameMap:E,excludedOptionValues:C,prepopulateMappedFieldNames:I,fieldValueKey:W,hideTableRowControls:M=!1,urlParams:z={},prepopulateResponse:V=null,prepopulateLoading:X=!1,formSections:L,submitPayload:B})=>{switch(e.type){case"divider":return d.jsx(LT,{field:e,className:c});case"header":return d.jsx(BT,{field:e,className:c});case"sectionHeading":return d.jsx(zT,{field:e,className:c});case"spacer":return d.jsx(UT,{field:e,className:c});case"textLabel":return d.jsx(BF,{field:e,className:c,formValues:u,urlParams:z,submissionContext:f,buttonResponses:w,prepopulateResponse:V??void 0,prepopulateLoading:X});case"status":return d.jsx(NT,{field:e,value:t??null,error:r,disabled:s,isRequired:a,className:c,formValues:u,submissionContext:f,extraSubmitPayload:S,prepopulateResponse:V})}switch(e.type){case"text":case"password":case"url":return e.type==="text"&&rd(e)?d.jsx($F,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f}):d.jsx(ri,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"number":return rd(e)?d.jsx(jF,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f}):d.jsx(dl,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"email":return d.jsx(Ku,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"phone":case"aadhaar":return d.jsx(qu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"otp":return d.jsx(Wf,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,urlParams:z,submissionContext:{...typeof f=="object"&&f!==null?f:{},...S??{}},prepopulateResponse:V});case"textarea":case"richtext":return d.jsx(Rf,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"select":{const D=W??e.name??e.key??e.id,K=!!(D&&I?.has(D));return d.jsx(Tm,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,formValues:u,submissionContext:f,excludedOptionValues:C,isPrepopulateTarget:K})}case"multiselect":{const D=Array.isArray(t)?t:t!=null&&t!==""?[String(t)]:[];return d.jsx(yh,{field:e,value:D,onChange:K=>n(K),onBlur:o,error:r,disabled:s,isRequired:a,className:c,formValues:u,submissionContext:f,excludedOptionValues:C})}case"asyncsearch":return d.jsx(qm,{field:e,value:t,onChange:D=>n(D),onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f});case"checkbox":case"terms":return d.jsx(bh,{field:e,value:t||!1,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c});case"toggle":return d.jsx(WN,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c});case"radio":case"checkboxgroup":return d.jsx(Wh,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,excludedOptionValues:C});case"selectablelist":{const D=Array.isArray(t)?t:[];return console.log("[SelectableList] FieldRenderer: passing to SelectableListField",{fieldName:e.name,value:D,valueLength:D.length,submissionContextKeys:f?Object.keys(f):[]}),d.jsx(_T,{field:e,value:D,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,submissionContext:f})}case"date":case"time":case"datetime":case"daterange":return d.jsx(Rh,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"file":return d.jsx(hk,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,buttonResponses:w});case"camera":return d.jsx(Hk,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c});case"photoChoice":return d.jsx(Wk,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,buttonResponses:w});case"signature":return d.jsx(Z_,{field:e,value:t||null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"rating":return d.jsx(P_,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"slider":return d.jsx(Q_,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"table":return d.jsx(eT,{field:e,value:t||[],onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,hideRowControls:M,formValues:u,submissionContext:f});case"billingGrid":return d.jsx(ET,{field:e,value:t||{rows:[]},onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f});case"button":return d.jsx(S_,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,onSubmit:l,onReset:p,onCancel:g,isSubmitting:m,formValues:u,submissionContext:f,buttonResponses:w,onButtonApiResponse:A,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:S,onValidateForm:x,getValidationErrors:F,allFields:N,onSubmittingChange:k,scopedFormValues:P,scopedFieldNameMap:E,prepopulateResponse:V,formSections:L,submitPayload:B});case"editButton":return d.jsx(x_,{field:e,disabled:s,readOnly:i,isRequired:a,className:c,buttonResponses:w,onButtonApiResponse:A});case"addmore":return d.jsx(A_,{field:e,error:r,disabled:s,readOnly:i,isRequired:a,className:c,onAddMore:()=>T?.(e)});case"customizeSections":return d.jsx(F_,{field:e,error:r,disabled:s,readOnly:i,isRequired:a,className:c});default:return d.jsx("div",{className:"p-3 border rounded-md bg-muted/50",children:d.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unsupported field type: ",e.type]})})}};function _s(e){if(!e)return e;const t={...e};return e._id&&!e.id&&(t.id=e._id),delete t._id,t.formDefinitionId&&typeof t.formDefinitionId=="object"&&(t.formDefinitionId=t.formDefinitionId._id||t.formDefinitionId.id||t.formDefinitionId),t}function Dy(e){return Array.isArray(e)?e.map(_s):[]}function zF(e){const t=!!e.standalone_form;if(!e.moduleId&&!t)throw new Error(`Form response missing required field: moduleId. Form ID: ${e._id||e.id}. Please ensure the backend returns moduleId when fetching forms.`);if(!e._id&&!e.id)throw new Error("Form response missing required field: id. Please ensure the backend returns _id or id when fetching forms.");let r;e.moduleId&&(typeof e.moduleId=="object"&&e.moduleId._id?r=_s(e.moduleId):r=e.moduleId);const n=e.isDefault??!1;if(!n&&!e.tenantId&&!t)throw new Error(`Form response missing required field: tenantId. Form ID: ${e._id||e.id}. Please ensure the backend returns tenantId when fetching non-default forms.`);return{id:e._id||e.id,name:e.name,description:e.description||"",version:e.version??1,status:e.status||"draft",category:e.category||"",createdAt:e.createdAt||new Date().toISOString(),updatedAt:e.updatedAt||e.createdAt||new Date().toISOString(),createdBy:e.createdBy||"",isActive:e.isActive??!0,isDefault:n,...r!==void 0&&{moduleId:r},tenantId:e.tenantId||void 0,featureId:e.featureId,config:e.config??void 0,standalone_form:t}}class UF{basePath="/api/form-builder/forms";async getForRendering(t,r){if(!nn())throw new Error("Client ID is required");const o=r!==void 0?`${this.basePath}/${t}/render?version=${r}`:`${this.basePath}/${t}/render`,s=await Qt.get(o),i=s.data?.data||s.data,a=i?.BFF_submit_api||i?.bff_submit_api||s.data?.BFF_submit_api||s.data?.bff_submit_api,c=i.form||i,u=!!(c.standalone_form??i.form?.standalone_form);if(!c.moduleId&&!i.form?.moduleId&&!u)throw new Error(`Form response missing required field: moduleId. Form ID: ${t}. Please ensure the backend returns moduleId in the form response.`);if(!(c.isDefault??i.form?.isDefault??!1)&&!c.tenantId&&!i.form?.tenantId&&!u)throw new Error(`Form response missing required field: tenantId. Form ID: ${t}. Please ensure the backend returns tenantId for non-default forms.`);i.form?.moduleId&&!c.moduleId&&(c.moduleId=i.form.moduleId),i.form?.tenantId&&!c.tenantId&&(c.tenantId=i.form.tenantId),i.form?.isDefault!==void 0&&c.isDefault===void 0&&(c.isDefault=i.form.isDefault);const l=zF(c);i.form?.moduleId&&(typeof i.form.moduleId=="object"&&i.form.moduleId._id?l.moduleId=_s(i.form.moduleId):typeof i.form.moduleId=="string"&&(l.moduleId=i.form.moduleId));const p=Dy(i.fields||[]),g=i.layout?_s(i.layout):null,m=Dy(i.rules||[]),h=i.module?_s(i.module):void 0,y=i.clientMapping||i.clientOverrides;return{form:l,fields:p,layout:g,rules:m,module:h,clientMapping:y,clientOverrides:y,BFF_submit_api:a||void 0}}}const VF=new UF,HF={submitAction:"database",autoSave:!0,autoSaveInterval:30,showProgressBar:!0,allowDraft:!0,validateOnChange:!1,validateOnBlur:!0,showFieldErrors:"inline",layout:"default",submitButtonText:"Submit",resetButtonText:"Reset",showReset:!1,successMessage:"Form submitted successfully!",errorMessage:"An error occurred. Please try again."},WF=300;function RF(){return{...HF}}function GF(e){if(!e||typeof e!="object")return;const t=e,r=t.user_type??t.visibleToUserType??"",n=t.user_role??t.visibleToUserRole??"",o=Array.isArray(t.users)?t.users:Array.isArray(t.visibleToUserIds)?t.visibleToUserIds:[];if(!(r!=null&&r!==""||n!=null&&n!==""||o.length>0))return;const i={};return r!=null&&r!==""&&(i.visibleToUserType=r),n!=null&&n!==""&&(i.visibleToUserRole=n),o.length>0&&(i.visibleToUserIds=o),i}function KF(e){const t=RF();if(!e||typeof e!="object")return t;const r=e;return{...t,submitAction:r.submitAction||t.submitAction,apiEndpoint:r.apiEndpoint,dbTable:r.dbTable,emailTo:r.emailTo,workflowTrigger:r.workflowTrigger,workflowSubmissionConfig:r.workflowSubmissionConfig,prepopulateApi:r.prepopulateApi,prepopulateResponseRules:r.prepopulateResponseRules??void 0,sections:g_(r.sections),submitPayload:h_(r.submitPayload),autoSave:r.autoSave,autoSaveInterval:r.autoSaveInterval,showProgressBar:r.showProgressBar,allowDraft:r.allowDraft,validateOnChange:r.validateOnChange,validateOnBlur:r.validateOnBlur,showFieldErrors:r.showFieldErrors,layout:r.layout,submitButtonText:r.submitButtonText,resetButtonText:r.resetButtonText,showReset:r.showReset,successMessage:r.successMessage,successRedirect:r.successRedirect,errorMessage:r.errorMessage}}function Ts(e,t,r,n){const o=t.map(l=>{let p=[],g={};try{l.options&&(p=JSON.parse(l.options)),l.metadata&&(g=JSON.parse(l.metadata))}catch{}const m=bu(l);m&&Object.assign(g,m),p.length>0&&(g.options=p);const h=[];if(l.validationRequired&&h.push({type:"required",message:"This field is required"}),l.validationMinLength!==null&&l.validationMinLength!==void 0&&h.push({type:"minLength",value:l.validationMinLength,message:`Minimum length is ${l.validationMinLength}`}),l.validationMaxLength!==null&&l.validationMaxLength!==void 0&&h.push({type:"maxLength",value:l.validationMaxLength,message:`Maximum length is ${l.validationMaxLength}`}),l.validationPattern&&h.push({type:"pattern",value:l.validationPattern,message:"Invalid format"}),l.validationRules&&typeof l.validationRules=="object"){const j=l.validationRules;if(j.required===!0&&!h.some(U=>U.type==="required")&&h.push({type:"required",message:"This field is required"}),j.allowLetters!==void 0&&h.push({type:"allowLetters",value:j.allowLetters}),j.allowNumbers!==void 0&&h.push({type:"allowNumbers",value:j.allowNumbers}),j.allowSpecialChars!==void 0&&h.push({type:"allowSpecialChars",value:j.allowSpecialChars}),j.minLetters!==void 0&&typeof j.minLetters=="number"&&h.push({type:"minLetters",value:j.minLetters}),j.maxLetters!==void 0&&typeof j.maxLetters=="number"&&h.push({type:"maxLetters",value:j.maxLetters}),j.minNumbers!==void 0&&typeof j.minNumbers=="number"&&h.push({type:"minNumbers",value:j.minNumbers}),j.maxNumbers!==void 0&&typeof j.maxNumbers=="number"&&h.push({type:"maxNumbers",value:j.maxNumbers}),j.minSpecialChars!==void 0&&typeof j.minSpecialChars=="number"&&h.push({type:"minSpecialChars",value:j.minSpecialChars}),j.maxSpecialChars!==void 0&&typeof j.maxSpecialChars=="number"&&h.push({type:"maxSpecialChars",value:j.maxSpecialChars}),j.fileSize!==void 0&&typeof j.fileSize=="number"){const U=j.fileSize/1048576;h.push({type:"fileSize",value:j.fileSize,message:`File size must be less than ${U.toFixed(2)} MB`})}if(j.fileType!==void 0){const U=Array.isArray(j.fileType)?j.fileType:typeof j.fileType=="string"?j.fileType.split(",").map(le=>le.trim()).filter(Boolean):[];U.length>0&&h.push({type:"fileType",value:U,message:"File type is not allowed"})}}const y=[],S=new Set;n.filter(j=>{const U=typeof j.targetFieldId=="object"?j.targetFieldId.id||j.targetFieldId._id:j.targetFieldId;return!!(U===l.id||U===l._id||U&&l.fieldKey&&U===l.fieldKey)}).forEach(j=>{try{const U=JSON.parse(j.conditionExpression);!U.id&&j.id&&(U.id=j.id);const le=typeof j.targetFieldId=="object"?j.targetFieldId?.id||j.targetFieldId?._id:j.targetFieldId;U.action&&(!U.then||!Array.isArray(U.then)||U.then.length===0)&&(U.then=[{action:U.action,...le&&{target:le}}]),(!U.then||!Array.isArray(U.then)||U.then.length===0)&&j.action&&(U.then=[{action:j.action,...le&&{target:le}}]),U.then&&Array.isArray(U.then)&&le&&(U.then=U.then.map(G=>!G.target&&le?{...G,target:le}:G));const oe=j.conditionExpression||JSON.stringify(U);if(S.has(oe))return;S.add(oe),y.push(U)}catch{}});const A=l.disabled===!0||g?.disabled===!0||!1;let x=l.readOnly===!0||g?.readOnly===!0||!1;const F=l.hidden===!0||g?.hidden===!0||!1;(g?.valueSource==="calculated"||g?.formula)&&(x=!0);const{disabled:N,readOnly:k,hidden:T,...P}=g,E={};P.hideLabel!==void 0&&(E.hideLabel=P.hideLabel),P.labelPosition!==void 0&&(E.labelPlacement=P.labelPosition),P.size!==void 0&&(E.size=P.size),P.customClass!==void 0&&(E.className=P.customClass);const{labelPosition:C,size:I,customClass:W,visibility:M,...z}=P,V=Object.keys(z).length>0?z:void 0,X=Object.keys(E).length>0?E:void 0,L=l.visibility??g?.visibility??M;let B=GF(L);if(L&&!B){const j=L;(j.visibleToUserType!=null||j.visibleToUserRole!=null||Array.isArray(j.visibleToUserTypes)&&j.visibleToUserTypes.length>0||Array.isArray(j.visibleToUserRoles)&&j.visibleToUserRoles.length>0||Array.isArray(j.visibleToUserIds)&&j.visibleToUserIds.length>0||Array.isArray(j.hiddenFromUserIds)&&j.hiddenFromUserIds.length>0)&&(B={visibleToUserType:j.visibleToUserType??(Array.isArray(j.visibleToUserTypes)?j.visibleToUserTypes[0]:void 0),visibleToUserRole:j.visibleToUserRole??(Array.isArray(j.visibleToUserRoles)?j.visibleToUserRoles[0]:void 0),visibleToUserIds:j.visibleToUserIds,hiddenFromUserIds:j.hiddenFromUserIds})}const D=g?.columnName,ae=!!l.parentFieldId&&typeof D=="string"?D:l.fieldKey;return{id:l.id,type:l.fieldType,name:ae,label:l.label,description:l.helpText||void 0,placeholder:l.placeholder||void 0,defaultValue:l.defaultValue||void 0,position:{order:typeof l.positionOrder=="number"?l.positionOrder:l.positionRow??0,column:typeof l.positionColumn=="number"?l.positionColumn:1,columnSpan:typeof l.positionWidth=="number"?l.positionWidth:1},parentId:void 0,appearance:X,validation:h.length>0?h:void 0,conditions:y.length>0?y:void 0,properties:V,visibility:B&&(B.visibleToUserType!=null||B.visibleToUserRole!=null||Array.isArray(B.visibleToUserIds)&&B.visibleToUserIds.length>0||Array.isArray(B.hiddenFromUserIds)&&B.hiddenFromUserIds.length>0)?B:void 0,disabled:A,readOnly:x,hidden:F}});o.forEach((l,p)=>{if(l.visibility){const g=t[p];console.log("[backendToFormSchema] field with visibility",{fieldKey:g?.fieldKey??l.name,name:l.name,type:l.type,parentFieldId:g?.parentFieldId,visibility:l.visibility})}});const s=t;for(let l=0;l<o.length;l++){const p=s[l]?.parentFieldId;if(p){const g=o.find(h=>h.id===p||h.type==="table"&&h.name===p||h.type==="table"&&s[l].fieldKey?.startsWith?.(h.name+"_column_")),m=o[l];if(g&&g.type==="table"&&m){const h=g.properties||{};Array.isArray(h.columns)||(h.columns=[]),h.columns.push(m),g.properties=h}}}const i=o.filter((l,p)=>!s[p]?.parentFieldId);for(const l of i)if(l.type==="table"&&l.properties&&Array.isArray(l.properties.columns)){const p=l.properties.columns;for(const g of p){const m=g.properties?.columnName;typeof m=="string"&&(g.name=m)}p.sort((g,m)=>(g.position?.order??0)-(m.position?.order??0)||(g.position?.column??0)-(m.position?.column??0))}let a;const c=e.config;if(console.log("[Prepopulate] backendToFormSchema config",{formId:e.id,hasRawConfig:c!=null,rawConfigType:typeof c,rawConfigPreview:c!=null?typeof c=="string"?c.slice(0,300):JSON.stringify(c).slice(0,300):null}),c!=null)try{const l=typeof c=="string"?JSON.parse(c):c;l&&typeof l=="object"?a=KF(l):a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"}}catch{a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"}}else a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};const u=zs(r);u&&(a={...a,grid:u});const f=typeof e.moduleId=="string"?e.moduleId:e.moduleId?.id;return{id:e.id,name:e.name,description:e.description,version:e.version,status:e.status,config:a,fields:i,createdAt:e.createdAt,updatedAt:e.updatedAt,createdBy:e.createdBy,category:e.category,...f?{moduleId:f}:{},standalone_form:e.standalone_form,tenantId:e.tenantId,featureId:e.featureId,isDefault:e.isDefault}}const qF=new Set(["PENDING_PAYMENT","PAYMENT_PENDING","AWAITING_PAYMENT","PAID","PAYMENT_COMPLETED","PAYMENT_FAILED","REFUNDED","AUTHORIZED","CAPTURED","PARTIALLY_PAID"].map(e=>e.toUpperCase()));function nd(e){return typeof e=="string"&&e.trim()!==""}function od(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;const t=e;if(t.payment_type!=null&&t.payment_type!==""||t.payment_mode!=null&&t.payment_mode!==""||t.transaction_id!=null&&String(t.transaction_id).trim()!==""||t.payment_status!=null&&String(t.payment_status).trim()!==""||typeof t.amount=="number"||nd(t.amount)||typeof t.total_amount=="number"||nd(t.total_amount)||nd(t.currency)||t.gateway!=null&&String(t.gateway).trim()!==""||t.razorpay_order_id!=null&&String(t.razorpay_order_id).trim()!==""||t.stripe_payment_intent!=null&&String(t.stripe_payment_intent).trim()!=="")return!0;const r=t.status;return!!(typeof r=="string"&&qF.has(r.trim().toUpperCase()))}function YF(e){const t=Ge(e,"data.items");if(!Array.isArray(t)||t.length===0)return;const r=t[0];if(r==null||typeof r!="object")return;const n=r;if(!(n.id===void 0||n.id===null||n.id===""))return{item:n,id:n.id}}function XF(e,t){const r=YF(e);if(!r)return;const n=Ge(e,"data"),o=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(t?.treatFirstItemIdAsPaymentId===!0||od(r.item)||o!=null&&od(o))return r.id}function JF(e){const t=e.properties,r=e.metadata;return[t?.uploadApiEndpoint,t?.apiEndpoint,r?.uploadApiEndpoint,r?.apiEndpoint].filter(o=>typeof o=="string"&&o.length>0)}function QF(e){return JF(e).some(t=>t.toLowerCase().includes("payment"))}function ZF(e){const t=e.properties,r=e.metadata;return!!(t?.mergeSuccessDataIdAsPaymentId||r?.mergeSuccessDataIdAsPaymentId)}function eP(e,t){if(t?.type!=="button"||!Qo(e))return;const r=Ge(e,"data.id");if(r==null||String(r).trim()==="")return;const n=Ge(e,"data");if(ZF(t)||n!=null&&typeof n=="object"&&!Array.isArray(n)&&od(n)||QF(t))return r}const tP=new Set(["section","group","columns","divider","header","sectionHeading","spacer","addmore","textLabel","customizeSections"]);function rP(e,t){if(!e.length||!t?.length)return[];const r=new Map(t.map(o=>[o.id,o])),n=[];for(const o of e){const s=r.get(o);if(s?.fieldNames?.length)for(const i of s.fieldNames)i&&!n.includes(i)&&n.push(i)}return n}function nP(e,t){const r=e.properties,n=Array.isArray(r?.linkedFieldNames)?r.linkedFieldNames:[],o=rP(Array.isArray(r?.linkedSectionIds)?r.linkedSectionIds:[],t),s=new Set,i=[];for(const a of[...n,...o])!a||s.has(a)||(s.add(a),i.push(a));return i}function By(e,t){const r=e.properties,n=Array.isArray(r?.linkedSectionIds)?r.linkedSectionIds:[];if(!n.length||!t?.length)return[];const o=new Map(t.map(s=>[s.id,s]));return n.map(s=>o.get(s)).filter(s=>!!s)}function oP(e,t){return By(e,t).find(r=>r.heading?.enabled)}function $y(e,t){const r=e.template??"";return(e.mode??"increment")==="fixed"?r:r.replace(/\{n\}/g,String(t+1))}function jy(e,t,r,n){const o=nP(e,r);if(o.length===0)return[];const s=new Set(o);return t.filter(i=>{const a=n(i);return!a||i.id===e.id||tP.has(i.type)?!1:s.has(a)})}function sP(e,t,r){if(e.type!=="sectionHeading"||!t?.length)return;const n=r(e);if(n)for(const o of t){const s=o.heading;if(s?.enabled&&s.headingFieldName===n)return s}}function sd(e){return[...e].sort((t,r)=>{const n=t.position?.order??0,o=r.position?.order??0;if(n!==o)return n-o;const s=t.position?.column??1,i=r.position?.column??1;return s-i})}function iP(e,t,r){if(!e?.length)return[];const n=e.filter(i=>i.showBorder===!0);if(n.length===0)return[];const o=new Map;for(const i of t){const a=r(i);a&&o.set(a,i)}const s=[];for(const i of n){const a=i.fieldNames.map(u=>o.get(u)).filter(u=>!!u);if(a.length===0)continue;const c=sd(a).map(u=>r(u)).filter(Boolean);s.push({section:i,fieldNames:c})}return s}function Fs(e,t=0){return e.heading?.enabled?$y(e.heading,t):e.name}function zy(e,t,r){if(e.type!=="sectionHeading")return!1;const n=t.heading;return!n?.enabled||!n.headingFieldName?!1:r(e)===n.headingFieldName}function aP(e,t){const r=typeof e.position?.order=="number"?e.position.order:0,n=(e.position?.column??1)-1,o=qo(e),s=Xd(e,t);return{row:r,col:n,rowEnd:r+o-1,colEnd:n+s-1}}function id(e,t){let r=1/0,n=-1/0,o=1/0,s=-1/0;for(const i of e){const{row:a,col:c,rowEnd:u,colEnd:f}=aP(i,t);r=Math.min(r,a),n=Math.max(n,u),o=Math.min(o,c),s=Math.max(s,f)}return Number.isFinite(r)?{minRow:r,maxRow:n,minCol:o,maxCol:s,rowSpan:n-r+1,colSpan:s-o+1}:null}function lP(e,t,r,n){const o=e.map(f=>t.find(l=>n(l)===f)).filter(f=>!!f&&typeof f.position?.order=="number");if(o.length===0)return null;const s=id(o,r);if(!s)return null;const i=o.filter(f=>f.type!=="sectionHeading"),a=i.length>0?i:o,c=Math.min(...a.map(f=>f.position?.order??0)),u=Math.max(1,...a.map(f=>(f.position?.order??c)-c+qo(f)));return{minRow:s.minRow,maxRow:s.maxRow,minCol:s.minCol,maxCol:s.maxCol,blockHeight:u}}function cP(e,t){return e.maxRow+1+t*e.blockHeight}function dP(e,t,r,n){const o=new Map;for(const a of t){const c=r(a);c&&o.set(c,a)}const s=new Map,i=new Set;for(const a of e){const c=a.fieldNames.map(w=>o.get(w)).filter(w=>!!w);if(c.length===0)continue;const u=c.filter(w=>!zy(w,a.section,r)),f=id(c,n);if(!f)continue;const{minRow:l,minCol:p,rowSpan:g,colSpan:m}=f,h=`${l}-${p}`;if(s.has(h))continue;const y=new Set;let S=!1;for(let w=l;w<=l+g-1;w++){for(let A=p;A<=p+m-1;A++){const x=`${w}-${A}`;if(i.has(x)){S=!0;break}y.add(x)}if(S)break}if(!S){for(const w of y)i.add(w);s.set(h,{anchorRow:l,anchorCol:p,rowSpan:g,colSpan:m,run:a,legend:Fs(a.section,0),renderFields:u.length>0?u:c})}}return{anchorsByOrigin:s,coveredCells:i}}function uP(e,t,r,n,o,s,i){const a=new Set(i),c=new Map;for(const u of e){const f=Uy(u.linkedFields.map(p=>s(p)).filter(Boolean),t),l=f?.section;l?.fieldNames?.length?l.fieldNames:u.templateFieldNames,u.blockIds.forEach((p,g)=>{const m=r.filter(k=>k.id.endsWith(`__${p}`));if(m.length===0||!f)return;const h=id(m,o);if(!h)return;const{minRow:y,minCol:S,rowSpan:w,colSpan:A}=h,x=`${y}-${S}`;for(let k=y;k<=y+w-1;k++)for(let T=S;T<=S+A-1;T++)a.add(`${k}-${T}`);const F=f,N=Fs(l,g+1);c.set(x,{anchorRow:y,anchorCol:S,rowSpan:w,colSpan:A,run:F,legend:N,renderFields:sd(m),addMoreMeta:{addMoreFieldName:u.addMoreFieldName,blockId:p,blockIndex:g}})})}return{anchorsByOrigin:c,coveredCells:a}}function fP(e,t,r,n){const o=`${e}-${t}`;return r.has(o)?!n.get(o):!1}function pP(e,t,r){for(const n of r.values())if(e>=n.anchorRow&&e<n.anchorRow+n.rowSpan&&t>=n.anchorCol&&t<n.anchorCol+n.colSpan)return n}function mP(e,t,r,n){return!(!n||r.run.section.collapsible!==!0||e===r.anchorRow&&t===r.anchorCol)}function hP(e,t,r){const n=new Set;for(const o of e.values())if(t(o))for(let s=o.anchorRow+1;s<o.anchorRow+o.rowSpan;s++)r(s,o)||n.add(s);return n}function gP(e,t,r){const n=o=>r.has(o)?"minmax(0, auto)":`minmax(${t}, auto)`;return Array.from({length:e},(o,s)=>n(s)).join(" ")}function yP(e,t){return new Map([...e,...t])}function bP(e,t,r){if(t.length===0)return e.map(i=>({kind:"field",field:i}));const n=new Map;for(const i of t)for(const a of i.fieldNames)n.set(a,i);const o=[];let s=0;for(;s<e.length;){const i=e[s],a=r(i),c=a?n.get(a):void 0;if(!c){o.push({kind:"field",field:i}),s+=1;continue}const u=[],f=new Set(c.fieldNames);for(;s<e.length;){const p=r(e[s]);if(!p||!f.has(p))break;const g=e[s];zy(g,c.section,r)||u.push(g),s+=1}if(u.length===0)continue;const l=o[o.length-1];l?.kind==="border"&&l.run.section.id===c.section.id?l.fields.push(...u):o.push({kind:"border",run:c,fields:u})}return o}function Uy(e,t){if(!t?.length)return;const r=new Set(e);for(const n of t){if(n.showBorder!==!0)continue;const o=n.fieldNames.filter(s=>r.has(s));if(o.length>0)return{section:n,fieldNames:o}}}const vP=({steps:e,currentStep:t,completedSteps:r,onStepClick:n,className:o})=>d.jsx("div",{className:H("mb-8",o),children:d.jsx("nav",{"aria-label":"Progress",children:d.jsx("ol",{className:"flex items-center",children:e.map((s,i)=>{const a=r.has(i),c=t===i,u=n&&(a||i===t+1||i<=t);return d.jsxs("li",{className:H("relative",i!==e.length-1&&"pr-8 sm:pr-20 flex-1"),children:[i!==e.length-1&&d.jsx("div",{className:H("absolute top-4 left-8 -right-8 sm:left-12 sm:-right-12 h-0.5",a?"bg-primary":"bg-border"),"aria-hidden":"true"}),d.jsx("button",{type:"button",onClick:()=>u&&n?.(i),disabled:!u,className:H("relative flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium","transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",a&&"bg-primary text-primary-foreground",c&&!a&&"border-2 border-primary text-primary",!a&&!c&&"border-2 border-border text-muted-foreground",u&&"cursor-pointer hover:bg-primary/10",!u&&"cursor-default"),"aria-current":c?"step":void 0,children:a?d.jsx(oi,{className:"h-4 w-4"}):d.jsx("span",{children:i+1})}),d.jsxs("div",{className:"mt-2",children:[d.jsx("span",{className:H("text-sm font-medium",c&&"text-primary",!c&&!a&&"text-muted-foreground"),children:s.name}),s.description&&d.jsx("p",{className:"text-xs text-muted-foreground hidden sm:block",children:s.description})]})]},s.id)})})})}),wP=2*6e4,Vy=50;class SP{map=new Map;ttlMs;constructor(t){this.ttlMs=t}get(t){const r=this.map.get(t);if(!r)return null;const o=Date.now()-r.storedAtMs>this.ttlMs;return{value:r.value,isStale:o}}set(t,r){this.map.set(t,{value:r,storedAtMs:Date.now()}),this.enforceMax()}delete(t){this.map.delete(t)}clear(){this.map.clear()}enforceMax(){if(this.map.size<=Vy)return;const t=Array.from(this.map.entries());t.sort((n,o)=>n[1].storedAtMs-o[1].storedAtMs),t.slice(0,Math.max(0,this.map.size-Vy)).forEach(([n])=>this.map.delete(n))}}function xP(e){return(e??"").trim()||"default"}function Hy(e){const t=xP(e.scope),r=String(e.formId??"").trim(),n=e.version===void 0||e.version===null?"latest":String(e.version).trim();return`form-render:${t}:${r}:${n}`}const Wy=new SP(wP);function Ry(e){const t=Hy(e),r=Wy.get(t);return r?{value:r.value,isStale:r.isStale}:null}function Gy(e,t){const r=Hy(e);Wy.set(r,t)}function Ky(e){const t={};for(const[n,o]of Object.entries(e)){if(o==null){t[n]=o;continue}if(Array.isArray(o)){t[n]=o;continue}if(typeof o=="object"&&!(o instanceof Date)){const s=o;typeof s.name=="string"&&typeof s.code=="string"?t[n]=`${s.code} ${s.name}`.trim():typeof s.name=="string"?t[n]=s.name:typeof s.code=="string"?t[n]=s.code:typeof s.short_code=="string"?t[n]=s.short_code:t[n]=s.name??s.code??"";continue}t[n]=o}const r=t.time_slot??e.time_slot;return typeof r=="string"&&r.includes(" - ")&&(t.start=r.split(" - ")[0].trim()),t}const Ps=({schema:e,formId:t,initialValues:r,onSubmit:n,onChange:o,onValidationError:s,onClose:i,mode:a="fill",className:c,children:u,gridLayout:f,unstyled:l=!1,submissionContext:p,onWorkflowSubmitResult:g,initialExtraSubmitPayload:m,onExtraSubmitPayloadChange:h,workflowStepId:y,initialStepIndex:S,viewerContext:w,getViewerContext:A,hideTableRowControls:x=!1,themeVars:F,dark:N=!1,omitRootWrapper:k=!1,moduleId:T,workflowModalHandlers:P,getAuthHeaders:E})=>{const C=Qn(_=>_.viewerContext),I=v.useMemo(()=>{if(w!==void 0)return w;const _=A?.();return _!==void 0?_:C},[w,A,C]),[W,M]=v.useState(e||null),[z,V]=v.useState(!!t&&!e),[X,L]=v.useState(null),B=e?.BFF_submit_api??X,[D,K]=v.useState(!1),[ae,j]=v.useState({}),[U,le]=v.useState({}),[oe,G]=v.useState({}),[ie,Ce]=v.useState({}),[ee,ne]=v.useState({}),[he,Ie]=v.useState(null),Ue=Ba.useParams(),re=Or(_=>_.setValues),ge=Or(_=>_.setSubmitting),Se=Or(_=>_.formDisabled),pt=Or(_=>_.visibleFields),Dt=Or(_=>_.requiredFields),Bt=Or(_=>_.updateVisibility),Pt=Or(_=>_.updateRequired),Ar=Or(_=>_.setFieldError),Nt=Zs(),Cr=v.useRef(!1),Xe=v.useRef(void 0),ve=v.useMemo(()=>{if(!e)return null;const _=e;if(_.form&&Array.isArray(_.form.fields))try{return Ts(_.form,_.form.fields,_.form.layout||null,_.form.rules||[])}catch{return e}if(Array.isArray(_.fields)&&_.fields.some(R=>typeof R.metadata=="string"&&R.metadata.startsWith("{")||R.fieldType&&!R.type))try{const R={id:_.id||_._id||"temp",name:_.name||"Form",version:_.version??1,status:_.status||"draft",createdAt:_.createdAt||new Date().toISOString(),updatedAt:_.updatedAt||new Date().toISOString(),createdBy:_.createdBy||"system",category:_.category||"",moduleId:_.moduleId,tenantId:_.tenantId,featureId:_.featureId,isDefault:_.isDefault||!1};return Ts(R,_.fields,_.layout||null,_.rules||[])}catch{return e}return e},[e]);v.useEffect(()=>{if(e){const _=e;_.BFF_submit_api&&L(_.BFF_submit_api)}},[e]);const ce=v.useMemo(()=>{const _=ve||W,q=_?da(_):null;if(!q)return null;const R=q.layout,Z=q.rules,Q=q.clientMapping,de=(Array.isArray(q.fields)?q.fields:[]).map(Be=>{let Ve={...Be};if(Be.validationRules&&typeof Be.validationRules=="object"&&!Be.validation){const pe=Be.validationRules,Oe=[];pe.required===!0&&Oe.push({type:"required",message:"This field is required"}),pe.minLength!==void 0&&typeof pe.minLength=="number"&&Oe.push({type:"minLength",value:pe.minLength,message:`Minimum length is ${pe.minLength}`}),pe.maxLength!==void 0&&typeof pe.maxLength=="number"&&Oe.push({type:"maxLength",value:pe.maxLength,message:`Maximum length is ${pe.maxLength}`}),pe.pattern&&typeof pe.pattern=="string"&&Oe.push({type:"pattern",value:pe.pattern,message:"Invalid format"}),pe.allowLetters!==void 0&&Oe.push({type:"allowLetters",value:pe.allowLetters}),pe.allowNumbers!==void 0&&Oe.push({type:"allowNumbers",value:pe.allowNumbers}),pe.allowSpecialChars!==void 0&&Oe.push({type:"allowSpecialChars",value:pe.allowSpecialChars}),Oe.length>0&&(Ve={...Ve,validation:Oe})}const Ne=Be.required===!0||Be.isRequired===!0,ke=Array.isArray(Ve.validation)&&Ve.validation.some(pe=>pe.type==="required");if(Ne&&!ke){const pe={type:"required",message:"This field is required"},Oe=Array.isArray(Ve.validation)?Ve.validation:[];Ve={...Ve,validation:[...Oe,pe]}}if(Be.apidata&&typeof Be.apidata=="object"){const pe=Be.apidata,Oe=Ve.properties||{},Ae=(Ve.type||Be.fieldType)==="status";if(!Oe.apiEndpoint&&pe.apiEndpoint){const lt={...Oe,apiEndpoint:pe.apiEndpoint,apiMethod:pe.apiMethod,apiKey:pe.apiKey,apiRealtime:pe.apiRealtime,apiAutoDetect:pe.apiAutoDetect,apiLabelField:pe.apiLabelField,apiValueField:pe.apiValueField,apiQueryParams:pe.apiQueryParams,apiClientFilter:pe.apiClientFilter,apiHeaders:pe.apiHeaders,apiBodyFields:pe.apiBodyFields,apiAuth:pe.apiAuth,valueSource:pe.valueSource||(pe.apiEndpoint?"api":void 0),optionsSource:pe.optionsSource||(pe.apiEndpoint?"api":void 0),dependentFields:pe.dependentFields,apiResponsePath:pe.apiResponsePath};Ae&&(lt.source=Oe.source??"api",Oe.statuses!==void 0&&(lt.statuses=Oe.statuses),Oe.dataPath!==void 0&&(lt.dataPath=Oe.dataPath),Oe.showStatusText!==void 0&&(lt.showStatusText=Oe.showStatusText),Oe.statusTextPath!==void 0&&(lt.statusTextPath=Oe.statusTextPath),Oe.showCurrentIndicator!==void 0&&(lt.showCurrentIndicator=Oe.showCurrentIndicator)),Ve={...Ve,properties:lt}}}const ze=["select","multiselect","radio","checkboxgroup"],tt=Ve.type||Be.fieldType;if(ze.includes(tt)){const pe=Be.options,Oe=Ve.properties?.options,Ae=Array.isArray(Oe)&&Oe.length>0;if(Array.isArray(pe)&&pe.length>0&&!Ae){const lt=Ve.properties||{};Ve={...Ve,properties:{...lt,options:pe}}}}return Ve}),ye=q.config?.rules,Ee=Z&&Array.isArray(Z)?Z:ye&&Array.isArray(ye)?ye:[],He=Ee.length>0?de.map(Be=>{if((Be.conditions&&Array.isArray(Be.conditions)?Be.conditions:[]).length>0)return Be;const Ne=Be.id??Be._id,ke=Be.name||Be.key,ze=Ee.filter(Oe=>{const Ae=typeof Oe.targetFieldId=="object"?Oe.targetFieldId?.id??Oe.targetFieldId?._id:Oe.targetFieldId;return Ae?Ae===Ne||Ae===ke||Ae===Be.fieldKey:!1});if(ze.length===0)return Be;const tt=[],pe=new Set;return ze.forEach(Oe=>{try{const Ae=typeof Oe.conditionExpression=="string"?JSON.parse(Oe.conditionExpression):Oe.conditionExpression;if(!Ae||typeof Ae!="object")return;!Ae.id&&Oe.id&&(Ae.id=Oe.id);const lt=typeof Oe.targetFieldId=="object"?Oe.targetFieldId?.id??Oe.targetFieldId?._id:Oe.targetFieldId;Ae.action&&(!Ae.then||!Array.isArray(Ae.then)||Ae.then.length===0)&&(Ae.then=[{action:Ae.action,...lt&&{target:lt}}]),(!Ae.then||!Array.isArray(Ae.then)||Ae.then.length===0)&&Oe.action&&(Ae.then=[{action:Oe.action,...lt&&{target:lt}}]),Ae.then&&Array.isArray(Ae.then)&&lt&&(Ae.then=Ae.then.map(zt=>!zt.target&&lt?{...zt,target:lt}:zt));const Gt=Oe.conditionExpression??JSON.stringify(Ae);if(pe.has(Gt))return;pe.add(Gt),tt.push(Ae)}catch{}}),tt.length===0?Be:{...Be,conditions:tt}}):de;let Je=q.config||{submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};return!Je.layout&&R?typeof R=="object"&&R!==null?Je.layout="default":typeof R=="string"&&["default","card","compact"].includes(R)?Je.layout=R:Je.layout="default":Je.layout||(Je.layout="default"),Z&&!Je.rules&&(Je.rules=Z),Q&&!Je.clientMapping&&(Je.clientMapping=Q),{...q,fields:He,config:Je}},[ve,W]);v.useEffect(()=>{ve&&ve!==W&&M(ve)},[ve]),v.useEffect(()=>{if(t&&!e){const _=(nn()??"").trim()||"default",q=Ry({scope:_,formId:t,version:"latest"});q?.value?.schema?(M(q.value.schema),q.value.bffSubmitApi&&L(q.value.bffSubmitApi),V(!1),q.isStale&&J({background:!0})):J({background:!1})}},[t,e]);const J=async({background:_})=>{if(!t)return;const q=t;_||V(!0);try{const R=await VF.getForRendering(t),Z=Ts(R.form,R.fields,R.layout,R.rules);if(q!==t)return;M(Z),R.BFF_submit_api&&L(R.BFF_submit_api);const Q=(nn()??"").trim()||"default";Gy({scope:Q,formId:q,version:"latest"},{schema:Z,bffSubmitApi:R.BFF_submit_api})}catch{}finally{_||V(!1)}};if(z)return d.jsx("div",{className:"flex items-center justify-center py-12",children:d.jsx(vn,{})});if(!ce)return d.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Form not found"});const $=ce,fe=v.useMemo(()=>new Set(Object.keys($.config?.prepopulateApi?.fieldMapping??{})),[$.config?.prepopulateApi?.fieldMapping]),it=v.useCallback(async _=>{const q=$?.fields?.length?Tc(_,$.fields):_,R=Og(q,$.config?.sections,$.config?.submitPayload);if(n){const Z=p?{...R,...p}:R;return n(Z)}return{success:!0}},[n,p,$?.fields,$.config?.sections,$.config?.submitPayload]),{values:Te,errors:Ye,touched:Me,isSubmitting:xe,isValid:et,submitCount:We,totalSteps:dt,currentStepFields:bt,isLastStep:ir,setFieldValue:xt,setFieldTouched:$e,handleSubmit:gt,validateForm:vt,resetForm:kt,nextStep:nr,goToStep:yr,currentStep:Er,completedSteps:Ot,loadDraft:Nr}=xu({schema:$,initialValues:r,onSubmit:it,onChange:o,workflowStepId:y,initialStepIndex:S}),{isFieldEnabled:ar,isFieldRequired:Sn,isFieldVisible:un}=Ow({fields:$.fields,values:Te,buttonResponses:U,prepopulateResponse:he,prepopulateResponseRules:$.config?.prepopulateResponseRules}),jr=un,zn=Or(_=>_.readOnlyFields),$t=Or(_=>_.editableFields),Ht=v.useCallback(_=>zn.has(_),[zn]),br=v.useCallback(_=>$t.has(_),[$t]);v.useEffect(()=>{$.config?.allowDraft&&a==="fill"&&Nr()},[$.id]),v.useEffect(()=>{Xe.current=$.id,Cr.current=!1,j({}),G({}),Ce({}),ne({}),Ie(null)},[$.id]),v.useEffect(()=>{const _=$.config?.prepopulateApi,q=!!(_?.fieldMapping&&Object.keys(_?.fieldMapping??{}).length>0),R=($.config?.prepopulateResponseRules?.length??0)>0;if(!_?.enabled||!_.apiEndpoint?.trim()||!q&&!R||Cr.current)return;Cr.current=!0;const Z=$.id;Xe.current=$.id;let Q=!1;return K(!0),(async()=>{try{const de=Nt.getState().values,ye=typeof p=="object"&&p!==null?{...p,...m||{}}:m||{},Ee=se=>Lr(se,de,Ue,ye);let He=Mr(Ee(_.apiEndpoint));if(_.apiQueryParams?.length){const se=new URLSearchParams;_.apiQueryParams.forEach(({key:Le,value:be})=>se.append(Le,Ee(be))),He=`${He}${He.includes("?")?"&":"?"}${se.toString()}`}const Je={};_.apiHeaders?.forEach(({key:se,value:Le})=>{se.trim()&&(Je[se]=Ee(Le))}),Je["Content-Type"]=Je["Content-Type"]??"application/json";let Rt;if(_.apiMethod==="POST"&&_.apiBodyFields?.length){const se={};_.apiBodyFields.forEach(({key:Le,value:be})=>{Le.trim()&&(se[Le]=Ee(be))}),Rt=JSON.stringify(se)}const Be=await fetch(He,{method:_.apiMethod,headers:Je,body:_.apiMethod==="POST"?Rt:void 0});if(!Be.ok){const se=await Be.text();throw new Error(se||`HTTP ${Be.status}`)}const Ve=await Be.json(),Ne=se=>{try{return se.split("?")[0].split("/").filter(Boolean).pop()||se}catch{return se}},ke=(se,Le)=>{if(se==null)return null;const be=typeof se=="string"?se:se instanceof Date?se.toISOString():null;if(!be)return null;const Ke=typeof se=="object"&&se instanceof Date?se:new Date(be);if(Number.isNaN(Ke.getTime()))return null;const ut=mt=>String(mt).padStart(2,"0");if(Le==="date")return be.length>=10&&be[4]==="-"&&be[7]==="-"?be.slice(0,10):Ke.toISOString().slice(0,10);if(Le==="time")return`${ut(Ke.getHours())}:${ut(Ke.getMinutes())}:${ut(Ke.getSeconds())}`;if(Le==="datetime"){const mt=Ke.getFullYear(),Ze=Ke.getMonth()+1,me=Ke.getDate(),ht=Ke.getHours(),Re=Ke.getMinutes(),Tt=Ke.getSeconds();return`${mt}-${ut(Ze)}-${ut(me)}T${ut(ht)}:${ut(Re)}:${ut(Tt)}`}return null},ze=(se,Le)=>{const be=$.fields.find(me=>me.name===se||me.key===se);if(!be)return Le;if((be.type==="file"||be.type==="camera"||be.type==="photoChoice")&&typeof Le=="string"&&Le.startsWith("http"))return{url:Le,name:Ne(Le)};if(be.type==="date"||be.type==="datetime"||be.type==="time"){const me=ke(Le,be.type);if(me!==null)return me}if(be.type==="multiselect")return Array.isArray(Le)?Le.map(me=>typeof me=="string"?me:String(me)):typeof Le=="string"?Le.trim()===""?[]:Le.includes(",")?Le.split(",").map(me=>me.trim()).filter(Boolean):[Le]:Le!=null&&Le!==""?[String(Le)]:[];if(be.type!=="radio"&&be.type!=="select")return Le;const Ke=be.properties?.options??be.options;if(!Array.isArray(Ke)||Ke.length===0)return Le;const ut=Ke.map(me=>me.value);if(ut.includes(Le))return Le;const mt=String(Le);if(ut.includes(mt))return mt;const Ze=Ke.find(me=>me.value==Le);return Ze?Ze.value:Le},tt=new Set($.fields.filter(se=>se.type==="table").map(se=>se.name||se.key)),pe=new Set($.fields.filter(se=>se.type==="billingGrid").map(se=>se.name||se.key)),Oe=se=>se.name||se.key||se.id,Ae={},lt=[],Gt=[],zt=y_(_?.fieldMapping,$.config?.sections,$.config?.submitPayload);for(const[se,Le]of Object.entries(zt)){if(!Le?.trim()||se.startsWith("__"))continue;const be=Ge(Ve,Le),Ke=se.indexOf(".");if(Ke>0&&pe.has(se.slice(0,Ke))){const mt=se.slice(0,Ke),Ze=se.slice(Ke+1),ht=$.fields.find(Re=>(Re.name||Re.key)===mt)?.properties;if(ht?.rowSlots?.length){const Re=Ze.startsWith("__block__")?Ze.slice(9):Ze,Tt=Ae[mt]??Nt.getState().values[mt];Array.isArray(be)?Ae[mt]=yT(ht,Re,be,Tt):be!=null&&(Ae[mt]=Uc(ht,be,Tt))}continue}if(Ke>0&&tt.has(se.slice(0,Ke))){const mt=se.slice(0,Ke),Ze=se.slice(Ke+1);lt.push({tableName:mt,columnName:Ze,path:Le});continue}if(pe.has(se)&&be!==void 0&&be!==null&&typeof be=="object"){const Ze=$.fields.find(me=>(me.name||me.key)===se)?.properties;if(Ze?.rowSlots?.length){if(Array.isArray(be)){const me=Ze.rowSlots.find(ht=>ht.kind==="dynamic");if(me&&me.kind==="dynamic"){const ht=me.block.apiArrayPath??"items";Ae[se]=Uc(Ze,{[ht]:be})}}else Ae[se]=Uc(Ze,be);continue}}if(tt.has(se)&&Array.isArray(be)&&be.length>0&&typeof be[0]=="object"&&be[0]!==null){const Ze=$.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],me=be.map(Ky),ht=Re=>(Re||"").toLowerCase().replace(/\s+/g,"_").trim();Ae[se]=me.map(Re=>{const Tt={};for(const fr of Ze){const co=fr.name??"";Tt[co]=Re[ht(co)]??Re[co]}return Tt});continue}if(be!=null&&(Ae[se]=ze(se,be)),be==null)continue;let ut=be;if(Array.isArray(be)){const mt=$.fields.find(Ze=>Oe(Ze)===se);if(mt?.type==="addmore"){Gt.push({addMoreFieldName:se,array:be});continue}if(mt?.type==="multiselect"){const Ze=_.multiselectArrayPropertyMap?.[se];Ze&&be.length>0&&be.some(me=>me!=null&&typeof me=="object")&&(ut=be.map(me=>me!=null&&typeof me=="object"&&Ze in me?me[Ze]:void 0).filter(me=>me!=null))}}Ae[se]=ze(se,ut)}const at={},yt={},or={};for(const{addMoreFieldName:se,array:Le}of Gt){const be=$.fields.find(ht=>Oe(ht)===se);if(!be||be.type!=="addmore")continue;const Ke=jy(be,$.fields,$.config?.sections,Oe);if(Ke.length===0)continue;const ut=_.addMoreFieldKeyMap?.[se],mt=Le.length>0&&Le[0]!=null&&typeof Le[0]=="object"?Le[0]:null;if(mt)for(const ht of Ke){const Re=Oe(ht),Tt=ut&&ut[Re]||Re,fr=mt[Tt];fr!=null&&(Ae[Re]=ze(Re,fr))}const Ze=Le.slice(1),me=Ze.map((ht,Re)=>`prepop_${se}_${Re}_${Date.now()}`);me.length>0&&(yt[se]=me);for(let ht=0;ht<Ze.length;ht++){const Re=Ze[ht];if(Re==null||typeof Re!="object")continue;const Tt=Re,fr=Tt.id;fr!=null&&String(fr).trim()!==""&&(or[`${se}__${me[ht]}`]=String(fr));for(const co of Ke){const Da=Oe(co),kI=ut&&ut[Da]||Da,Ed=Tt[kI];if(Ed==null)continue;const _I=`${Da}__addmore__${se}__${me[ht]}`;at[_I]=ze(Da,Ed)}}}Object.keys(yt).length>0&&G(se=>({...se,...yt})),Object.keys(or).length>0&&ne(se=>({...se,...or}));const Hr=se=>(se||"").toLowerCase().replace(/\s+/g,"_").trim(),en=[...new Set(lt.map(se=>se.tableName))];for(const se of en){if(Array.isArray(Ae[se]))continue;const Le=lt.find(me=>me.tableName===se);if(!Le?.path?.includes("."))continue;const be=Le.path.replace(/\.[^.]+$/,""),Ke=Ge(Ve,be);if(!Array.isArray(Ke)||Ke.length===0||typeof Ke[0]!="object"||Ke[0]===null)continue;const mt=$.fields.find(me=>(me.name||me.key)===se)?.properties?.columns||[],Ze=Ke.map(Ky);Ae[se]=Ze.map(me=>{const ht={};for(const Re of mt){const Tt=Re.name??"",fr=Hr(Tt),co=me[fr]??me[Tt];ht[Tt]=co}return ht})}const Wr=(se,Le)=>{const be=Ge(Ve,se);if(Array.isArray(be))return be;if(be!=null)return[be];if(!se.includes("."))return[];const Ke=se.replace(/\.[^.]+$/,""),ut=Ge(Ve,Ke);return!Array.isArray(ut)||ut.length===0||typeof ut[0]!="object"||ut[0]===null?[]:ut.map(mt=>{const Ze=mt[Le];if(Ze!==null&&typeof Ze=="object"&&!Array.isArray(Ze)&&!(Ze instanceof Date)){const me=Ze;return typeof me.name=="string"&&typeof me.code=="string"?`${me.code} ${me.name}`.trim():typeof me.name=="string"?me.name:typeof me.code=="string"?me.code:typeof me.short_code=="string"?me.short_code:me.name??me.code??""}return Ze})};for(const{tableName:se,columnName:Le,path:be}of lt){const Ke=Wr(be,Le),mt=$.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],Ze=mt.find(Re=>(Re.name||"").toLowerCase()===Le.toLowerCase())?.name??Le;let me=Array.isArray(Ae[se])?Ae[se]:[];const ht=Math.max(me.length,Ke.length);if(ht>me.length)for(me=[...me];me.length<ht;){const Re={};mt.forEach(Tt=>{Re[Tt.name||""]=""}),me.push(Re)}else me=me.map(Re=>({...Re}));Ke.forEach((Re,Tt)=>{me[Tt]&&(me[Tt][Ze]=Re)}),Ae[se]=me}if(Xe.current===Z){if(Object.keys(Ae).length>0||Object.keys(at).length>0){const Tt={...Nt.getState().values,...Ae,...at};re(Tt)}const Le=Ge(Ve,"data.user_id"),be=Ge(Ve,"data.items"),Ke=Ge(Ve,"data");let ut=Array.isArray(be)&&be.length>0&&be[0]!=null&&typeof be[0]=="object"&&be[0].id?be[0].id:void 0;ut===void 0&&Array.isArray(Ke)&&Ke.length>0&&Ke[0]!=null&&typeof Ke[0]=="object"&&Ke[0].id&&(ut=Ke[0].id),ut===void 0&&(ut=Ge(Ve,"data.0.id"));const mt=XF(Ve,{treatFirstItemIdAsPaymentId:_?.treatFirstItemIdAsPaymentId===!0}),Ze=Ge(Ve,"data.id"),me=Ge(Ve,"data.batch_id"),ht=Ge(Ve,"data.program_id"),Re={};Le!=null&&(Re.context_user_id=Le),ut!=null&&ut!==""&&(Re.documentId=ut),Ze!=null&&String(Ze).trim()!==""&&(p?.id===void 0||p?.id===null)&&(Re.id=Ze),me!=null&&String(me).trim()!==""&&((p?.admission_batch_id===void 0||p?.admission_batch_id===null)&&(Re.admission_batch_id=me),(p?.batch_id===void 0||p?.batch_id===null)&&(Re.batch_id=me)),ht!=null&&String(ht).trim()!==""&&(p?.program_id===void 0||p?.program_id===null)&&(Re.program_id=ht),mt!=null&&String(mt).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&(Re.payment_id=mt),Object.keys(Re).length>0&&j(Tt=>{const fr={...Tt,...Re};return h?.(fr),fr}),Ie(Ve)}}catch(de){Q||ia(de,"Prepopulate request failed.",Gr)}finally{K(!1)}})(),()=>{Q=!0}},[$.id,$.config?.prepopulateApi?.enabled,$.config?.prepopulateApi?.apiEndpoint,$.config?.prepopulateApi?.apiMethod,JSON.stringify($.config?.prepopulateApi?.fieldMapping),$.config?.prepopulateApi?.treatFirstItemIdAsPaymentId,p,m,Ue,re,G]),v.useEffect(()=>{Object.keys(Ye).length>0&&s?.(Ye)},[Ye,s]);const Jr=dt>1,Yt=a==="view",lr=v.useCallback((_,q)=>Yt||!!q&&!br(_)||Ht(_)&&!br(_),[Yt,br,Ht]),Un=$.fields.filter(_=>!_.parentId),_t=[...Jr?bt:Un.length>0?Un:$.fields].filter(_=>!(!_||typeof _!="object"||!_.name&&!_.key)).sort((_,q)=>{const R=typeof _.position?.order=="number"?_.position.order:typeof _.positionOrder=="number"?_.positionOrder:Number.MAX_SAFE_INTEGER,Z=typeof q.position?.order=="number"?q.position.order:typeof q.positionOrder=="number"?q.positionOrder:Number.MAX_SAFE_INTEGER;if(R!==Z)return R-Z;const Q=typeof _.position?.column=="number"?_.position.column:1,de=typeof q.position?.column=="number"?q.position.column:1;return Q-de}),Ds=v.useCallback(_=>{const q=Nt.getState().errors,R=Object.keys(q).find(Z=>_.includes(Z));R&&requestAnimationFrame(()=>{document.querySelector(`[data-field-name="${R}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})})},[]),kr=async _=>{if(_?.preventDefault(),Jr&&!ir){if(!await nr())try{const Z=Nt.getState().errors;ct.toast.error(la(Z,$.fields)||"Please fix the errors before continuing."),Ds(_t.map(Q=>Q.name||Q.key||Q.id).filter(Boolean))}catch{ct.toast.error("Please fix the errors before continuing.")}return}const q=await gt(_);if(q&&q.success===!1&&q.errors?.length)try{const R=Nt.getState().errors;ct.toast.error(la(R,$.fields)||"Submission failed. Please check the form."),Ds(_t.map(Z=>Z.name||Z.key||Z.id).filter(Boolean))}catch{ct.toast.error("Submission failed. Please check the form.")}return q},Qr=v.useCallback(()=>{kt(),i&&i()},[kt,i]),zr=v.useCallback((_,q)=>{const R=$.fields.find(de=>de.type==="button"&&(de.name===_||de.key===_)),Z=R?.properties,Q=eP(q,R);Q!=null&&String(Q).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&j(de=>{const ye={...de,payment_id:Q};return h?.(ye),ye}),R&&Z?.apiSuccessConfig&&qk(q,Z.apiSuccessConfig,{setFieldValue:(de,ye)=>Nt.getState().setFieldValue(de,ye),onContextUpdate:de=>{j(ye=>{const Ee={...ye,...de};return h?.(Ee),Ee})}}),le(de=>{const ye={...de,[_]:q};return!Qo(q)||!(R?.type==="button"&&R.properties?.action==="submit")||$.fields.filter(Je=>Je.type==="editButton").map(Je=>Je.name).forEach(Je=>delete ye[Je]),ye})},[$.fields,p,h,Nt]),Ur=v.useCallback(async()=>await vt(),[vt]),_r=v.useCallback(()=>Nt.getState().errors,[]),Xt=v.useMemo(()=>({...m||{},...ae}),[m,ae]),_e=v.useMemo(()=>({...typeof p=="object"&&p!==null?p:{},...Xt}),[p,Xt]),O=$.config?.layout??$.layout??"default",te=["default","card","compact"].includes(O)?O:"default",we={default:"",card:"bg-card border rounded-lg shadow-sm p-6",compact:"space-y-2"},st=v.useMemo(()=>{if(k)return;const _=$.config?.theme?.cssVariables;if(!(!_&&!F))return{..._??{},...F??{}}},[k,$.config?.theme?.cssVariables,F]),wt=v.useMemo(()=>Us({config:$.config,layout:$.layout},f),[$.config,$.layout,f]),St=v.useMemo(()=>wt?{...wt,verticalSpacing:wt.verticalSpacing??wt.spacing??"16px",horizontalSpacing:wt.horizontalSpacing??wt.spacing??"16px",rowHeight:wt.rowHeight??Hn}:null,[wt]),Wt=St!==null;St?.rows;const Et=St?.columns??3,Vr=St?.verticalSpacing??St?.spacing??"16px",Ho=St?.horizontalSpacing??St?.spacing??"16px",It=St?.rowHeight??Hn,fn=v.useCallback(_=>{if(!I)return!0;const q=_.visibility;if(!q)return!0;const R=q.visibleToUserType??q.user_type,Z=q.visibleToUserRole??q.user_role,Q=Array.isArray(q.visibleToUserIds)?q.visibleToUserIds:Array.isArray(q.users)?q.users:[],de=Array.isArray(q.hiddenFromUserIds)?q.hiddenFromUserIds:[];if(Array.isArray(de)&&de.length>0&&I.userId!=null&&de.includes(I.userId))return!1;if(Q.length>0&&I.userId!=null&&Q.includes(I.userId))return!0;const ye=R!=null&&R!==""&&I.userType!=null&&I.userType!==R,Ee=Z!=null&&Z!==""&&I.role!=null&&I.role!==Z,He=Q.length>0&&(I.userId==null||!Q.includes(I.userId));return!(ye||Ee||He)},[I]),xn=v.useMemo(()=>k_($.fields),[$.fields]),Sd=v.useMemo(()=>T_($.fields),[$.fields]),[Wo,Pb]=v.useState(Sd);v.useEffect(()=>{Pb(Sd)},[$.id,Sd]);const Ob=v.useCallback((_,q)=>{Pb(R=>R[_]===q?R:{...R,[_]:q})},[]),xI=v.useMemo(()=>({visibility:Wo,setSectionVisible:Ob,fieldToHeading:xn,allFields:$.fields}),[Wo,Ob,xn,$.fields]),nt=v.useCallback(_=>_.name||_.key||_.id,[]),Tr=_=>{if(!fn(_))return!1;const q=_.name||_.key||_.id;if(!Lg(q,_.type,Wo,xn))return!1;const R=_.hidden===!0;return jr(q)||!R&&q},Ib=v.useCallback(_=>{const q=$.fields.find(Z=>nt(Z)===_);if(q)return q.type;const R=Mg(_);return $.fields.find(Z=>nt(Z)===R)?.type},[$.fields,nt]),Ca=v.useCallback(_=>Lg(_,Ib(_),Wo,xn),[Wo,xn,Ib]),An=v.useCallback(_=>Ca(_)?Sn(_):!1,[Ca,Sn]);v.useEffect(()=>{const{visibleFields:_,requiredFields:q,errors:R}=Nt.getState(),Z=new Set(_),Q=new Set(q),de=[];for(const ye of $.fields){const Ee=nt(ye);Ee&&(Ca(Ee)||(Z.delete(Ee),Q.delete(Ee),R[Ee]&&de.push(Ee)))}Bt(Array.from(Z)),Pt(Array.from(Q));for(const ye of de)Ar(ye,void 0)},[Wo,xn,$.fields,$.id,nt,Ca,Bt,Pt,Ar,pt,Dt]);const jt=$.config?.sections,ao=v.useCallback(_=>{const q=nt(_);let R=_;if(_.type==="table"){const Q=_.properties?.columns;if(Array.isArray(Q)&&Q.length>0){const de=Q.filter(ye=>fn(ye));R={..._,properties:{..._.properties,columns:de}}}}const Z=sP(R,jt,nt);return Z&&(R={...R,label:$y(Z,0)}),{...R,disabled:!ar(q),readOnly:lr(q,!!R.readOnly)}},[fn,jt,nt,ar,lr]),Cn=v.useCallback(_=>jy(_,$.fields,jt,nt),[$.fields,jt,nt]),Zr=v.useCallback((_,q,R)=>`${_}__addmore__${q}__${R}`,[]),Ea=v.useCallback((_,q)=>`${_}__${q??"base"}`,[]),Na=v.useCallback((_,q)=>{const R=Ea(_.id,q);return ie[R]??_.defaultCollapsed??!1},[ie,Ea]),xd=v.useCallback((_,q,R)=>{const Z=Ea(_,q);Ce(Q=>Q[Z]===R?Q:{...Q,[Z]:R})},[Ea]),ka=v.useMemo(()=>{const _=[],q=$.fields.filter(R=>R.type==="addmore");for(const R of q){const Z=nt(R),de=Cn(R).find(Je=>{if(Je.type!=="button")return!1;const Rt=Je.properties,Be=Je.metadata;let Ve=Rt?.action;if(!Ve&&Be!=null)try{Ve=(typeof Be=="string"?JSON.parse(Be):Be)?.action}catch{}return Ve==="upload"||Ve==="custom"});if(!de)continue;const ye=nt(de),Ee=oe[Z]||[],He=Ge(U[ye],"data.id")??Ge(U[ye],"data.documentId")??ae.documentId;He!=null&&String(He).trim()!==""&&_.push(String(He));for(const Je of Ee){const Rt=Zr(ye,Z,Je),Be=Ge(U[Rt],"data.id")??Ge(U[Rt],"data.documentId"),Ve=ee[`${Z}__${Je}`],Ne=Be??Ve;Ne!=null&&String(Ne).trim()!==""&&_.push(String(Ne))}}return _},[$.fields,oe,U,ee,ae.documentId,nt,Cn,Zr]);v.useEffect(()=>{j(_=>{const q={..._,document_ids:ka},R=_.document_ids;return Array.isArray(R)&&R.length===ka.length&&ka.every((Z,Q)=>R[Q]===Z)?_:q})},[ka]);const _a=v.useCallback((_,q,R,Z)=>{for(const Q of R){const de=nt(Q),ye=Zr(de,_,q),Ee=Z[ye];if(Ee==null)continue;const He=Q.type;if(He==="file"||He==="camera"||He==="photoChoice"){if(typeof Ee=="object"&&Ee!==null&&("url"in Ee||"name"in Ee)||Array.isArray(Ee)&&Ee.length>0)return!0;continue}if(Array.isArray(Ee)){if(Ee.length>0)return!0;continue}if(typeof Ee=="string"&&Ee.trim()!==""||typeof Ee=="number"&&!Number.isNaN(Ee)||typeof Ee=="boolean"||typeof Ee=="object"&&Ee!==null&&Object.keys(Ee).length>0)return!0}return!1},[nt,Zr]),lo=v.useCallback(_=>{const q=nt(_);if(!q)return;if(Cn(_).length===0){ct.toast.error("No linked fields configured for this Add More button.");return}const Z=`${Date.now()}_${Math.random().toString(36).slice(2,8)}`;G(Q=>({...Q,[q]:[...Q[q]||[],Z]}))},[nt,Cn]),Ta=v.useCallback((_,q)=>{G(R=>{const Z=R[_]||[],Q=Z.filter(de=>de!==q);if(Q.length===Z.length)return R;if(Q.length===0){const de={...R};return delete de[_],de}return{...R,[_]:Q}})},[]),Fa=v.useMemo(()=>_t.filter(_=>!_.parentId),[_t]),Vn=v.useMemo(()=>{const _=[];return _t.filter(R=>R.type==="addmore").sort((R,Z)=>{const Q=R.position?.order??0,de=Z.position?.order??0;return Q-de}).forEach(R=>{const Z=nt(R),Q=R.position?.order??0,de=oe[Z]||[],ye=Cn(R).sort((ke,ze)=>{const tt=ke.position?.order??0,pe=ze.position?.order??0;return tt!==pe?tt-pe:(ke.position?.column??1)-(ze.position?.column??1)});if(ye.length===0)return;const Ee=By(R,jt),He=Ee[0]?.fieldNames?.length?Ee[0].fieldNames:ye.map(ke=>nt(ke)).filter(Boolean),Je=lP(He,Fa,Et,nt),Rt=Math.min(...ye.map(ke=>ke.position?.order??0)),Be=Math.max(1,...ye.map(ke=>(ke.position?.order??Rt)-Rt+qo(ke))),Ve=Je?.blockHeight??Be,Ne=de.length*Ve;_.push({addMoreFieldName:Z,baseOrder:Q,blockHeight:Ve,blockIds:de,linkedFields:ye,insertedRows:Ne,templateFieldNames:He,templateBounds:Je})}),_},[_t,Fa,Et,nt,oe,Cn,jt]),Bs=v.useMemo(()=>({}),[]),Pa=v.useMemo(()=>Vn.length===0?_t:_t.map(_=>{const q=_.position?.order??0,R=Vn.reduce((Z,Q)=>{const de=Q.templateBounds?.maxRow??Q.baseOrder;return q>de?Z+Q.insertedRows:Z},0);return R===0?_:{..._,position:{..._.position,order:q+R}}}),[_t,Vn]),Oa=v.useCallback(_=>{const q={};return Object.entries(U).forEach(([R,Z])=>{const Q=_[R];Q&&(q[Q]=Z)}),q},[U]),Ro=v.useMemo(()=>{const _=[],q={};return Vn.forEach(R=>{const{addMoreFieldName:Z,blockIds:Q,linkedFields:de,blockHeight:ye,templateBounds:Ee}=R,He=Math.min(...de.map(Be=>Be.position?.order??0)),Rt=$.fields.find(Be=>nt(Be)===Z&&Be.type==="addmore")?.properties;Q.forEach((Be,Ve)=>{const Ne={},ke={},ze={},tt=Ee?cP(Ee,Ve):R.baseOrder+1+Ve*ye,pe=ee[`${Z}__${Be}`];de.forEach(Ae=>{const lt=nt(Ae),Gt=Zr(lt,Z,Be),zt=(Ae.position?.order??He)-He;if(Ne[Gt]=lt,ke[Gt]=Te[Gt],!(Rt?.linkedFieldAllowDuplicate?.[lt]??!0)&&(Ae.type==="select"||Ae.type==="radio"||Ae.type==="multiselect")){const yt=[],or=Te[lt];or!=null&&or!==""&&(Array.isArray(or)?yt.push(...or.map(en=>String(en))):yt.push(String(or))),Q.filter(en=>en!==Be).forEach(en=>{const Wr=Zr(lt,Z,en),tn=Te[Wr];tn!=null&&tn!==""&&(Array.isArray(tn)?yt.push(...tn.map(se=>String(se))):yt.push(String(tn)))}),yt.length>0&&(ze[Gt]=[...new Set(yt)])}_.push({...Ae,id:`${Ae.id}__${Be}`,name:Gt,position:{...Ae.position,order:tt+zt}})});const Oe=Oa(Ne);Object.keys(Ne).forEach(Ae=>{q[Ae]={scopedFormValues:ke,scopedFieldNameMap:Ne,scopedButtonResponses:Oe,...pe!=null&&{blockDocumentId:pe},...ze[Ae]&&{excludedOptionValues:ze[Ae]}}})})}),{clonedFields:_,scopeByFieldName:q}},[Vn,ee,nt,Zr,Te,Oa,$.fields]),$s=v.useMemo(()=>[...Pa,...Ro.clonedFields].sort((_,q)=>{const R=_.position?.order??0,Z=q.position?.order??0;if(R!==Z)return R-Z;const Q=_.position?.column??1,de=q.position?.column??1;if(Q!==de)return Q-de;const ye=Oo(_.position)??0,Ee=Oo(q.position)??0;return ye!==Ee?ye-Ee:String(_.id).localeCompare(String(q.id))}),[Pa,Ro.clonedFields]),Go=v.useMemo(()=>Qk($s.filter(_=>!_.parentId),Tr),[$s,Tr]),Ad=v.useCallback((_,q)=>Go.some(R=>Zk(_,q,R,Et)),[Go,Et]);Go.length===0||Math.max(...Go.map(_=>(_[0]?.position?.order??0)+Ss(_,Et).rowSpan));const Ia=v.useMemo(()=>iP(jt,sd(_t.filter(_=>!_.parentId)),nt),[jt,_t,nt]),{anchorsByOrigin:Mb,coveredCells:Lb}=v.useMemo(()=>dP(Ia,Pa,nt,Et),[Ia,Pa,nt,Et]),{anchorsByOrigin:Db,coveredCells:Bb}=v.useMemo(()=>uP(Vn.map(_=>({addMoreFieldName:_.addMoreFieldName,blockIds:_.blockIds,linkedFields:_.linkedFields,templateFieldNames:_.templateFieldNames})),jt,Ro.clonedFields,Fa,Et,nt,Lb),[Vn,jt,Ro.clonedFields,Fa,Et,nt,Lb]),En=v.useMemo(()=>yP(Mb,Db),[Mb,Db]),$b=v.useMemo(()=>Bb,[Bb]),jb=String(It).endsWith("px")?It:Hn,zb=v.useCallback((_,q)=>{for(let R=0;R<Et;R++){if(R>=q.anchorCol&&R<q.anchorCol+q.colSpan)continue;if(Bs[`${_}-${R}`]||En.get(`${_}-${R}`)||bg(_,R,$s,Tr).length>0||Ad(_,R))return!0}return!1},[Et,Bs,En,$s,Tr,Ad]),Ub=v.useMemo(()=>hP(En,_=>{const q=_.run.section;return q.collapsible?Na(q,_.addMoreMeta?.blockId):!1},zb),[En,Na,zb]),Vb=v.useMemo(()=>{const _=[];for(const q of Object.keys(Bs)){const R=Number(q.split("-")[0]);Number.isNaN(R)||_.push(R)}for(const q of En.values())if(q.renderFields.some(R=>Tr(R)))for(let R=q.anchorRow;R<q.anchorRow+q.rowSpan;R++)_.push(R);return e_(Go,Et,_)},[Go,Et,Bs,En,Tr]),{originalToDisplayRow:Ma,displayRowCount:AI,sortedOccupiedRows:CI}=v.useMemo(()=>{const _=t_(Vb);return{originalToDisplayRow:_.originalToDisplay,displayRowCount:_.displayRowCount,sortedOccupiedRows:_.sortedOriginalRows}},[Vb]),Hb=Math.max(AI,1),Cd=v.useCallback((_,q=1)=>r_(_,q,Ma),[Ma]),Wb=v.useMemo(()=>{const _=new Set;for(const q of Ub){const R=Ma.get(q);R!==void 0&&_.add(R)}return _},[Ub,Ma]),EI=v.useMemo(()=>gP(Hb,jb,Wb),[Hb,jb,Wb]),NI=v.useMemo(()=>bP(_t.filter(_=>!_.parentId&&Tr(_)),Ia,nt),[_t,Ia,nt,Tr]),La=v.useCallback(_=>{if(Wt)return null;const q=nt(_),R=oe[q]||[];if(R.length===0)return null;const Z=Cn(_);if(Z.length===0)return null;const Q=oP(_,jt),de=Z.map(He=>nt(He)).filter(Boolean),ye=Uy(de,jt),Ee=(He,Je,Rt,Be,Ve,Ne,ke)=>{const ze=nt(He),tt=Zr(ze,q,Je),pe=He.hidden===!0;if(!(fn(He)&&(jr(ze)||!pe&&ze)))return null;const Ae={...He,id:`${He.id}__${Je}`,name:tt,disabled:!ar(ze),readOnly:lr(ze,!!He.readOnly)},Gt=_.properties?.linkedFieldAllowDuplicate?.[ze]??!0;let zt;if(!Gt&&(He.type==="select"||He.type==="radio"||He.type==="multiselect")){const at=[],yt=Te[ze];yt!=null&&yt!==""&&(Array.isArray(yt)?at.push(...yt.map(Hr=>String(Hr))):at.push(String(yt))),R.filter(Hr=>Hr!==Je).forEach(Hr=>{const en=Zr(ze,q,Hr),Wr=Te[en];Wr!=null&&Wr!==""&&(Array.isArray(Wr)?at.push(...Wr.map(tn=>String(tn))):at.push(String(Wr)))}),at.length>0&&(zt=[...new Set(at)])}return d.jsx("div",{"data-field-name":tt,"data-form-renderer":"field-wrapper",children:d.jsx(wn,{field:Ae,value:Te[tt],error:Me[tt]||We>0?Ye[tt]:void 0,onChange:at=>xt(tt,at),onBlur:()=>$e(tt),disabled:Se||!ar(ze)||Yt,readOnly:lr(ze,!!He.readOnly),isRequired:An(ze),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:tt,buttonResponses:Ne,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:ke,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,scopedFormValues:Ve,scopedFieldNameMap:Be,excludedOptionValues:zt,hideTableRowControls:x})},Ae.id)};return d.jsx("div",{className:"space-y-3 mt-3",children:R.map((He,Je)=>{const Rt={},Be={};Z.forEach(zt=>{const at=nt(zt),yt=Zr(at,q,He);Rt[yt]=at,Be[yt]=Te[yt]});const Ve=Oa(Rt),Ne=_a(q,He,Z,Te),ke=Q?.heading!=null?Fs(Q,Je+1):null,ze=ee[`${q}__${He}`],tt=ze!=null?{...Xt,documentId:ze}:Xt,pe=Z.map(zt=>Ee(zt,He,Je,Rt,Be,Ve,tt)).filter(Boolean),Ae=ye?.section?.collapsible===!0,lt=d.jsx("button",{type:"button",className:"inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",disabled:Ne,title:Ne?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:zt=>{zt.preventDefault(),zt.stopPropagation(),Ta(q,He)},children:d.jsx(rs,{className:"h-5 w-5","aria-hidden":!0})}),Gt=d.jsxs(d.Fragment,{children:[!Ae&&d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ke?d.jsx("p",{className:"text-sm font-medium text-foreground",children:ke}):d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Entry ",Je+1]}),lt]}),pe]});return d.jsx("div",{className:"rounded-md border p-3 space-y-3",children:ye?d.jsx(td,{legend:ye.section.heading?.enabled?Fs(ye.section,Je+1):ye.section.name,collapsible:ye.section.collapsible,defaultCollapsed:ye.section.defaultCollapsed,headerActions:Ae?lt:void 0,onCollapsedChange:zt=>xd(ye.section.id,He,zt),children:Gt}):Gt},`${_.id}-${He}`)})})},[Wt,oe,ee,nt,Cn,Zr,_a,Te,Me,We,Ye,xt,$e,ar,Yt,An,_e,fe,zr,kr,kt,Qr,xe,B,g,Xt,Ur,_r,$.fields,ge,jr,fn,Oa,Ta,x,jt,Ue,he,D]),Rb=d.jsx("div",{className:k?H("relative",c):H($a,N&&"dark",c),style:st,"data-form-renderer":k?void 0:"root",children:d.jsxs("div",{className:"relative",children:[D&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:d.jsx(vn,{})}),d.jsx("form",{onSubmit:kr,className:l?H("w-full min-w-0"):H("space-y-6 pb-[100px] w-full min-w-0",we[te]),"data-form-renderer":"form","data-form-renderer-layout":Wt?"grid":"stack",children:d.jsxs(C_,{value:xI,children:[Jr&&$.steps&&d.jsx(vP,{steps:$.steps,currentStep:Er,completedSteps:Ot,onStepClick:yr}),d.jsx(Ya.Provider,{value:{gridStretch:Wt},children:Wt?d.jsx("div",{className:l?"w-full min-w-0":"grid w-full min-w-0",style:{display:"grid",gridTemplateRows:EI,gridTemplateColumns:`repeat(${Et}, 1fr)`,rowGap:Vr,columnGap:Ho},"data-form-renderer":"grid",children:CI.map(_=>Array.from({length:Et},(q,R)=>{const Z=Cd(_);if(!Z)return null;if(Ad(_,R))return d.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:R+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${R}`);if(fP(_,R,$b,En)){const Ne=pP(_,R,En);return Ne&&mP(_,R,Ne,Na(Ne.run.section,Ne.addMoreMeta?.blockId))?null:d.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:R+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`section-border-cover-${_}-${R}`)}const Q=En.get(`${_}-${R}`);if(Q){const Ne=Q.renderFields.filter(at=>Tr(at));if(Ne.length===0)return null;const ke=Q.addMoreMeta,ze=ke!=null?Vn.find(at=>at.addMoreFieldName===ke.addMoreFieldName)?.linkedFields??[]:[],tt=ke!=null?_a(ke.addMoreFieldName,ke.blockId,ze,Te):!1,pe=Q.run.section,Oe=ke?.blockId,Ae=Na(pe,Oe),lt=pe.collapsible&&Ae?1:Q.rowSpan,Gt=Cd(Q.anchorRow,lt)??Z,zt=ke!=null?d.jsx("button",{type:"button",className:H("inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",l&&"text-red-600 hover:bg-red-500/10"),disabled:tt,title:tt?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:at=>{at.preventDefault(),at.stopPropagation(),Ta(ke.addMoreFieldName,ke.blockId)},children:d.jsx(rs,{className:"h-5 w-5","aria-hidden":!0})}):void 0;return d.jsx("div",{className:H("min-h-0 min-w-0",!(pe.collapsible&&Ae)&&"self-stretch"),style:{gridRow:Gt,gridColumn:`${R+1} / span ${Q.colSpan}`},"data-form-renderer":"grid-cell","data-form-renderer-config-section-border-cell":!0,children:d.jsx(td,{legend:Q.legend,className:pe.collapsible&&Ae?void 0:"h-full",collapsible:pe.collapsible,defaultCollapsed:pe.defaultCollapsed,headerActions:zt,onCollapsedChange:at=>xd(pe.id,Oe,at),children:d.jsx("div",{className:"grid w-full min-w-0",style:{gridTemplateColumns:`repeat(${Et}, 1fr)`,gridTemplateRows:`repeat(${Q.rowSpan}, minmax(${String(It).endsWith("px")?It:Hn}, auto))`,rowGap:Vr,columnGap:Ho},children:Ne.map(at=>{const yt=nt(at),or=Ro.scopeByFieldName[yt],Hr=or?.scopedFieldNameMap?.[yt]||yt,en=(at.position?.order??Q.anchorRow)-Q.anchorRow,Wr=at.position?.column??1,{rowSpan:tn,columnSpan:se}=Ss([at],Et),Le=ke!=null?ee[`${ke.addMoreFieldName}__${ke.blockId}`]:void 0,be=Le!=null?{...Xt,documentId:Le}:Xt;return d.jsx("div",{"data-field-name":yt,"data-form-renderer":"field-wrapper",className:"min-h-0 min-w-0",style:{gridRow:`${en+1} / span ${tn}`,gridColumn:`${Wr} / span ${se}`,...Pn(at)},children:d.jsx(wn,{field:ao(at),value:Te[yt],error:Me[yt]||We>0?Ye[yt]:void 0,onChange:Ke=>xt(yt,Ke),onBlur:()=>$e(yt),disabled:(at.type==="table"||at.type==="billingGrid")&&a==="fill"?!1:Se||!ar(Hr)||Yt,readOnly:(at.type==="table"||at.type==="billingGrid")&&a==="fill"?!1:lr(Hr,!!at.readOnly),isRequired:An(Hr),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:yt,buttonResponses:or?.scopedButtonResponses??U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:be,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,scopedFormValues:or?.scopedFormValues,scopedFieldNameMap:or?.scopedFieldNameMap,excludedOptionValues:or?.excludedOptionValues,hideTableRowControls:x})},at.id)})})})},`section-border-${Q.run.section.id}-${_}-${R}-${ke?.blockId??"base"}`)}const de=bg(_,R,$s,Tr).filter(Ne=>!(nt(Ne)?.includes("__addmore__")&&$b.has(`${_}-${R}`)));if(de.length===0){const Ne=Bs[`${_}-${R}`];if(Ne){const ke=$.fields.find(pe=>pe.type==="addmore"&&nt(pe)===Ne.addMoreFieldName),ze=ke!=null?Cn(ke):[],tt=_a(Ne.addMoreFieldName,Ne.blockId,ze,Te);return d.jsx("div",{className:"min-h-0 min-w-0 flex flex-col items-center justify-center",style:{gridRow:Z,gridColumn:R+1},"data-form-renderer":"grid-cell","data-form-renderer-add-more-remove":!0,children:d.jsx("button",{type:"button",className:H("inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",l&&"text-red-600 hover:bg-red-500/10"),disabled:tt,title:tt?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:pe=>{pe.preventDefault(),pe.stopPropagation(),Ta(Ne.addMoreFieldName,Ne.blockId)},children:d.jsx(rs,{className:"h-5 w-5","aria-hidden":!0})})},`add-more-remove-${_}-${R}`)}return d.jsx("div",{className:"min-w-0",style:{pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${R}`)}const ye=de[0],{rowSpan:Ee,columnSpan:He}=Ss(de,Et),Je=Cd(_,Ee)??Z;if(de.length===1&&ye.type==="section"){const Ne=$.fields.filter(ke=>ke.parentId===ye.id&&ke.position!=null).sort((ke,ze)=>{const tt=typeof ke.position?.order=="number"?ke.position.order:0,pe=typeof ze.position?.order=="number"?ze.position.order:0;return tt-pe});return d.jsx("div",{className:"min-w-0 min-h-0 w-full overflow-hidden flex flex-col h-full",style:{gridRow:Je,gridColumn:`${R+1} / span ${He}`,...Pn(ye)},"data-form-renderer":"grid-cell",children:d.jsx(ay,{field:ye,children:Ne.map(ke=>{const ze=ke.name||ke.key||ke.id,tt=ke.hidden===!0;return fn(ke)&&(jr(ze)||!tt&&ze)?d.jsx("div",{"data-field-name":ze,"data-form-renderer":"field-wrapper",children:d.jsx(wn,{field:ao(ke),value:Te[ze],error:Me[ze]||We>0?Ye[ze]:void 0,onChange:Oe=>xt(ze,Oe),onBlur:()=>$e(ze),disabled:Se||!ar(ze)||Yt,readOnly:lr(ze,!!ke.readOnly),isRequired:An(ze),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:ze,buttonResponses:U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x})},ke.id):null})})},ye.id)}const Rt=gg(de),Be=de.some(Ne=>["file","camera","photoChoice","addmore","table","billingGrid"].includes(Ne.type)),Ve=d.jsx("div",{className:H("flex min-h-0 w-full flex-1 gap-3",Rt==="row"?"flex-row items-stretch":"flex-col items-stretch"),children:de.map(Ne=>{const ke=Ne.name||Ne.key||Ne.id,ze=Ne.type==="sectionHeading",tt=Ro.scopeByFieldName[ke],pe=tt?.scopedFieldNameMap?.[ke]||ke,Oe=tt?.blockDocumentId!=null?{...Xt,documentId:tt.blockDocumentId}:Xt,Ae=Ne.appearance?.hideLabel??Ne.properties?.hideLabel??!1,lt=Ne.type==="table"||Ne.type==="billingGrid"?Ne.properties?.minWidth:void 0;return d.jsx("div",{"data-field-name":ke,"data-form-renderer":"field-wrapper",className:H("flex min-h-0 min-w-0 flex-1 flex-col",Xo(Ne),ze&&"items-center justify-center",Ae&&"items-center"),style:{...lt?{minWidth:lt}:{},...Pn(Ne)},children:d.jsx(wn,{field:ao(Ne),value:Te[ke],error:Me[ke]||We>0?Ye[ke]:void 0,onChange:Gt=>xt(ke,Gt),onBlur:()=>$e(ke),disabled:(Ne.type==="table"||Ne.type==="billingGrid")&&a==="fill"?!1:Se||!ar(pe)||Yt,readOnly:(Ne.type==="table"||Ne.type==="billingGrid")&&a==="fill"?!1:lr(pe,!!Ne.readOnly),isRequired:An(pe),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:ke,buttonResponses:tt?.scopedButtonResponses??U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Oe,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,scopedFormValues:tt?.scopedFormValues,scopedFieldNameMap:tt?.scopedFieldNameMap,excludedOptionValues:tt?.excludedOptionValues,hideTableRowControls:x})},Ne.id)})});return d.jsx("div",{className:H(Qd(de),"self-stretch",Be?"overflow-visible":"overflow-hidden"),style:{gridRow:Je,gridColumn:`${R+1} / span ${He}`,...Pn(de[0])},"data-form-renderer":"grid-cell","data-field-name":de.map(Ne=>Ne.name||Ne.key||Ne.id).join(","),children:Ve},de.map(Ne=>Ne.id).join("-"))}))}):d.jsx("div",{className:l?"":"space-y-4","data-form-renderer":"stack",children:_t.map(_=>{if(!Tr(_))return null;const q=NI.find(Z=>Z.kind==="border"&&Z.fields.some(Q=>Q.id===_.id));if(q)return q.fields[0]?.id!==_.id?null:d.jsx(td,{legend:Fs(q.run.section,0),collapsible:q.run.section.collapsible,defaultCollapsed:q.run.section.defaultCollapsed,onCollapsedChange:Z=>xd(q.run.section.id,void 0,Z),children:q.fields.map(Z=>{const Q=nt(Z);return!Q||!Tr(Z)?null:d.jsxs("div",{"data-field-name":Q,"data-form-renderer":"field-wrapper",style:Pn(Z),children:[d.jsx(wn,{field:ao(Z),value:Te[Q],error:Me[Q]||We>0?Ye[Q]:void 0,onChange:de=>xt(Q,de),onBlur:()=>$e(Q),disabled:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:Se||!ar(Q)||Yt,readOnly:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:lr(Q,!!Z.readOnly),isRequired:An(Q),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:Q,buttonResponses:U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),Z.type==="addmore"&&La(Z)]},Z.id)})},`stack-border-${q.run.section.id}-${_.id}`);if(!_.parentId){const Z=_t.filter(de=>!de.parentId&&Tr(de)&&ca(de)===ca(_)),Q=Nc(Z).slice(0,2);if(Q.length>1&&Q[0].id!==_.id)return null;if(Q.length>1){const de=gg(Q);return d.jsx("div",{"data-form-renderer":"shared-cell-stack",className:H("flex w-full min-w-0 gap-3",de==="row"?"flex-row items-stretch":"flex-col"),children:Q.map(ye=>{const Ee=ye.name||ye.key||ye.id;return d.jsxs("div",{"data-field-name":Ee,"data-form-renderer":"field-wrapper",className:H("min-w-0 flex-1 flex flex-col",Xo(ye)),style:Pn(ye),children:[d.jsx(wn,{field:ao(ye),value:Te[Ee],error:Me[Ee]||We>0?Ye[Ee]:void 0,onChange:He=>xt(Ee,He),onBlur:()=>$e(Ee),disabled:(ye.type==="table"||ye.type==="billingGrid")&&a==="fill"?!1:Se||!ar(Ee)||Yt,readOnly:(ye.type==="table"||ye.type==="billingGrid")&&a==="fill"?!1:lr(Ee,!!ye.readOnly),isRequired:An(Ee),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:Ee,buttonResponses:U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),ye.type==="addmore"&&La(ye)]},ye.id)})},Q.map(ye=>ye.id).join("-"))}}if(_.type==="section"){const Z=$.fields.filter(Q=>Q.parentId===_.id&&Q.position!=null).sort((Q,de)=>{const ye=typeof Q.position?.order=="number"?Q.position.order:0,Ee=typeof de.position?.order=="number"?de.position.order:0;return ye-Ee});return d.jsx(ay,{field:_,children:Z.map(Q=>{const de=Q.name||Q.key||Q.id,ye=Q.hidden===!0;return fn(Q)&&(jr(de)||!ye&&de)?d.jsxs("div",{"data-field-name":de,"data-form-renderer":"field-wrapper",style:Pn(Q),children:[d.jsx(wn,{field:ao(Q),value:Te[de],error:Me[de]||We>0?Ye[de]:void 0,onChange:He=>xt(de,He),onBlur:()=>$e(de),disabled:Se||!ar(de)||Yt,readOnly:lr(de,!!Q.readOnly),isRequired:An(de),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:de,buttonResponses:U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),Q.type==="addmore"&&La(Q)]},Q.id):null})},_.id)}const R=_.name||_.key||_.id;return d.jsxs("div",{"data-field-name":R,"data-form-renderer":"field-wrapper",style:Pn(_),children:[d.jsx(wn,{field:ao(_),value:Te[R],error:Me[R]||We>0?Ye[R]:void 0,onChange:Z=>xt(R,Z),onBlur:()=>$e(R),disabled:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:Se||!ar(R)||Yt,readOnly:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:lr(R,!!_.readOnly),isRequired:An(R),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:R,buttonResponses:U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),_.type==="addmore"&&La(_)]},_.id)})})}),u]})})]})});return P?d.jsx(kg,{handlers:P,moduleId:T??"",submissionContext:p,getAuthHeaders:E,onParentWorkflowSubmitResult:g,children:Rb}):Rb};var va="Tabs",[AP]=vr(va,[ta]),qy=ta(),[CP,ad]=AP(va),Yy=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:a,activationMode:c="automatic",...u}=e,f=bo(a),[l,p]=ln({prop:n,onChange:o,defaultProp:s??"",caller:va});return d.jsx(CP,{scope:r,baseId:hn(),value:l,onValueChange:p,orientation:i,dir:f,activationMode:c,children:d.jsx(je.div,{dir:f,"data-orientation":i,...u,ref:t})})});Yy.displayName=va;var Xy="TabsList",Jy=b.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...o}=e,s=ad(Xy,r),i=qy(r);return d.jsx(Fh,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:n,children:d.jsx(je.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});Jy.displayName=Xy;var Qy="TabsTrigger",Zy=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:o=!1,...s}=e,i=ad(Qy,r),a=qy(r),c=rb(i.baseId,n),u=nb(i.baseId,n),f=n===i.value;return d.jsx(Ph,{asChild:!0,...a,focusable:!o,active:f,children:d.jsx(je.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":u,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...s,ref:t,onMouseDown:De(e.onMouseDown,l=>{!o&&l.button===0&&l.ctrlKey===!1?i.onValueChange(n):l.preventDefault()}),onKeyDown:De(e.onKeyDown,l=>{[" ","Enter"].includes(l.key)&&i.onValueChange(n)}),onFocus:De(e.onFocus,()=>{const l=i.activationMode!=="manual";!f&&!o&&l&&i.onValueChange(n)})})})});Zy.displayName=Qy;var eb="TabsContent",tb=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:o,children:s,...i}=e,a=ad(eb,r),c=rb(a.baseId,n),u=nb(a.baseId,n),f=n===a.value,l=b.useRef(f);return b.useEffect(()=>{const p=requestAnimationFrame(()=>l.current=!1);return()=>cancelAnimationFrame(p)},[]),d.jsx(xr,{present:o||f,children:({present:p})=>d.jsx(je.div,{"data-state":f?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!p,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:l.current?"0s":void 0},children:p&&s})})});tb.displayName=eb;function rb(e,t){return`${e}-trigger-${t}`}function nb(e,t){return`${e}-content-${t}`}var EP=Yy,NP=Jy,kP=Zy,_P=tb;function ob({className:e,...t}){return d.jsx(EP,{"data-slot":"tabs",className:H("flex flex-col gap-2",e),...t})}function ld({className:e,...t}){return d.jsx(NP,{"data-slot":"tabs-list",className:H("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function cd({className:e,...t}){return d.jsx(kP,{"data-slot":"tabs-trigger",className:H("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function sb({className:e,...t}){return d.jsx(_P,{"data-slot":"tabs-content",className:H("flex-1 outline-none",e),...t})}const TP="w-full justify-start border-b rounded-none h-auto p-0 bg-transparent gap-0",FP="rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none",PP=({steps:e,position:t,sidebarWidth:r,sticky:n=!0,stickyOffset:o="1rem",sidebarMaxHeight:s="calc(100vh - 6rem)"})=>{if(t==="top")return d.jsx(ld,{className:TP,"data-form-renderer":"workflow-tabs",children:e.map(c=>d.jsx(cd,{value:c.step_id,className:FP,"data-form-renderer":"workflow-tab",children:c.step_name},c.step_id))});const i=t==="left"||t==="right",a=i?{...r?{width:r,flexShrink:0}:{},...n?{top:o}:{},maxHeight:s}:void 0;return d.jsx(ld,{className:H("bg-transparent p-0 gap-0 rounded-none h-auto",i?H("flex flex-col items-stretch shrink-0 self-start z-10 bg-background overflow-y-auto",n&&"sticky",t==="left"?"border-r pr-2":"border-l pl-2",!r&&"w-56"):H("w-full justify-start",t==="bottom"?"border-t pt-0":"border-b")),style:a,"data-form-renderer":"workflow-tabs","data-form-renderer-nav-position":t,children:e.map(c=>d.jsx(cd,{value:c.step_id,className:H("rounded-none shadow-none data-[state=active]:shadow-none text-sm",i?H("justify-start w-full px-3 py-2.5 border-b-0",t==="left"?"border-l-2 border-transparent data-[state=active]:border-primary":"border-r-2 border-transparent data-[state=active]:border-primary"):H("border-b-2 border-transparent data-[state=active]:border-primary",t==="bottom"&&"border-t-2 border-b-0 data-[state=active]:border-t-primary")),"data-form-renderer":"workflow-tab",children:c.step_name},c.step_id))})},OP=new Set(["top","bottom","left","right"]),Os={position:"top",sticky:!0,stickyOffset:"1rem",sidebarMaxHeight:"calc(100vh - 6rem)"};function ib(e){return typeof e=="string"&&OP.has(e)}function IP(...e){for(const t of e){const r=t?.ui_config?.stepsNavigation;if(r&&typeof r=="object")return r}}function dd(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function ud(e={},...t){const r=IP(...t),n=(e.position&&ib(e.position)?e.position:void 0)??(r?.position&&ib(r.position)?r.position:Os.position),o=dd(e.sidebarWidth,r?.sidebarWidth),s=typeof e.sticky=="boolean"?e.sticky:typeof r?.sticky=="boolean"?r.sticky:Os.sticky,i=dd(e.stickyOffset,r?.stickyOffset)??Os.stickyOffset,a=dd(e.sidebarMaxHeight,r?.sidebarMaxHeight)??Os.sidebarMaxHeight;return{position:n,sidebarWidth:o,sticky:s,stickyOffset:i,sidebarMaxHeight:a}}function MP(e,...t){return ud({position:e},...t).position}function LP(e){return e==="left"||e==="right"}function Ft({className:e="",...t}){return d.jsx("div",{"data-slot":"skeleton","data-form-renderer":"skeleton",className:`animate-pulse rounded-md bg-neutral-200 dark:bg-neutral-700 ${e}`.trim(),...t})}function DP({className:e="",position:t="top"}){if(t==="left"||t==="right")return d.jsxs("div",{className:`flex gap-4 ${t==="right"?"flex-row-reverse":"flex-row"} ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:[d.jsxs("div",{className:`flex w-56 shrink-0 flex-col gap-1 border-neutral-200 dark:border-neutral-700 py-1 ${t==="left"?"border-r pr-2":"border-l pl-2"}`,children:[d.jsx(Ft,{className:"h-10 w-full rounded-none"}),d.jsx(Ft,{className:"h-10 w-full rounded-none"}),d.jsx(Ft,{className:"h-10 w-full rounded-none"})]}),d.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-4 py-4",children:[d.jsx(Ft,{className:"h-4 w-32"}),d.jsx(Ft,{className:"h-10 w-full"}),d.jsx(Ft,{className:"h-4 w-40"}),d.jsx(Ft,{className:"h-10 w-full"}),d.jsx(Ft,{className:"h-24 w-full"})]})]});const n=d.jsxs("div",{className:`flex w-full gap-0 ${t==="bottom"?"border-t border-neutral-200 pt-0 dark:border-neutral-700":"border-b border-neutral-200 dark:border-neutral-700"}`,children:[d.jsx(Ft,{className:"h-10 w-24 rounded-none"}),d.jsx(Ft,{className:"h-10 w-28 rounded-none ml-1"}),d.jsx(Ft,{className:"h-10 w-20 rounded-none ml-1"})]}),o=d.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[d.jsx(Ft,{className:"h-4 w-32"}),d.jsx(Ft,{className:"h-10 w-full"}),d.jsx(Ft,{className:"h-4 w-40"}),d.jsx(Ft,{className:"h-10 w-full"}),d.jsx(Ft,{className:"h-4 w-36"}),d.jsx(Ft,{className:"h-24 w-full"})]});return d.jsx("div",{className:`flex flex-col gap-4 ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:t==="bottom"?d.jsxs(d.Fragment,{children:[o,n]}):d.jsxs(d.Fragment,{children:[n,d.jsx("div",{className:"mt-4",children:o})]})})}function BP(){return d.jsxs("div",{className:"flex flex-col gap-4 py-4","data-form-renderer":"form-loading-skeleton",children:[d.jsx(Ft,{className:"h-4 w-28"}),d.jsx(Ft,{className:"h-10 w-full"}),d.jsx(Ft,{className:"h-4 w-36"}),d.jsx(Ft,{className:"h-10 w-full"}),d.jsx(Ft,{className:"h-4 w-24"}),d.jsx(Ft,{className:"h-20 w-full"})]})}const $P=3e4,jP=10*6e4,zP=9e4,UP=15*6e4;function VP(e){return e!=null&&"on_success"in e&&e.on_success!=null}function HP(e,t){if(!t||typeof t!="object")return e;let r=e;return Object.entries(t).forEach(([n,o])=>{o!=null&&o!==""&&(r=r.replace(new RegExp(`\\{${n}\\}`,"g"),String(o)))}),r}const ab=({getWorkflowState:e,moduleId:t,tenantId:r,submissionContext:n,initialValues:o={},getAuthHeaders:s,onSuccess:i,bootstrapFeatureId:a,subjectUserId:c,viewStepId:u,clientId:f,className:l,onWorkflowSubmitResult:p,viewerContext:g,getViewerContext:m,dark:h=!1,themeVars:y,stepsNavigationPosition:S,stepsNavigationSidebarWidth:w,stepsNavigationSticky:A,stepsNavigationStickyOffset:x,stepsNavigationSidebarMaxHeight:F,workflowModalHandlers:N})=>{const k=Nn.useQueryClient(),T=v.useMemo(()=>[c??"",u??"",f??""],[c,u,f]),P=v.useMemo(()=>({moduleId:t,tenantId:r,subjectUserId:c,viewStepId:u,clientId:f}),[t,r,c,u,f]),[E,C]=v.useState([]),[I,W]=v.useState(null),[M,z]=v.useState(null),[V,X]=v.useState(null),[L,B]=v.useState({}),D=v.useRef(null),K=v.useRef(null),ae=v.useRef(null),j=v.useRef(null),U=v.useMemo(()=>E&&Array.isArray(E)?E.filter(ve=>ve.feature_id):[],[E]),le=Nn.useQuery({queryKey:["workflow-steps",t,a??"",r??"",T[0],T[1],T[2]],queryFn:()=>e({...P,featureId:a}),staleTime:$P,gcTime:jP}),oe=le.isPending,G=le.error?le.error instanceof Error?le.error.message:"Failed to load workflow steps":null;v.useEffect(()=>{const ve=le.data;if(!ve||E.length>0)return;const ce=ve.steps&&Array.isArray(ve.steps)?ve.steps:[];C(ce);const J=ce.filter($=>$.feature_id);if(J.length>0){const $=ve.current_step_id,fe=$&&J.some(it=>it.step_id===$);W(fe?$:J[0].step_id)}},[le.data,E.length,a]);const ie=v.useMemo(()=>{if(!I)return;const ve=E.find(J=>J.step_id===I),ce=D.current===I;return ve?.feature_id??(ce?j.current:void 0)??void 0},[I,E]),Ce=Nn.useQuery({queryKey:["workflow-step",t,ie??"",r??"",T[0],T[1],T[2]],queryFn:()=>e({...P,featureId:ie}),enabled:!!ie,staleTime:zP,gcTime:UP,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),ee=Ce.isPending,ne=Ce.error?Ce.error instanceof Error?Ce.error.message:"Failed to load form":null,he=v.useMemo(()=>ud({position:S,sidebarWidth:w,sticky:A,stickyOffset:x,sidebarMaxHeight:F},M,le.data),[S,w,A,x,F,M,le.data]),Ie=he.position,Ue=LP(Ie);v.useEffect(()=>{!Ce.data||D.current===I||(z(Ce.data),X(null),D.current=null,j.current=null)},[Ce.data,I]),v.useEffect(()=>{X(ne)},[ne]),v.useEffect(()=>{ie===void 0&&D.current!==I&&(z(null),X(null),D.current=null,j.current=null)},[ie,I]);const re=v.useMemo(()=>{const ve=M?.form;if(!ve)return null;const ce=(r??nn()??"").trim()||"default",J=Ry({scope:ce,formId:ve._id,version:ve.version});return J?.value?J.value:Ag(M,n)},[M,n,r]),ge=v.useMemo(()=>{const ve=M?.BFF_submit_api;if(!ve?.url)return;let ce=ve.url;if(ce.startsWith("http://")||ce.startsWith("https://"))try{const fe=new URL(ce);ce=fe.pathname+fe.search}catch{}const J=s?.()??{},$={...ve.headers||{},"Content-Type":"application/json",...J};return{...ve,url:ce,headers:$}},[M?.BFF_submit_api,s]),Se=v.useMemo(()=>re?{...re,status:"published",...ge&&{BFF_submit_api:ge}}:null,[re,ge]);v.useEffect(()=>{if(!re?.id)return;const ve=(r??nn()??"").trim()||"default";Gy({scope:ve,formId:re.id,version:re.version},re)},[re,r]);const pt=v.useMemo(()=>{if(!re)return null;const ve=Us({config:re.config,layout:re.layout},null);if(!ve)return null;const ce=ve.rows,J=ve.columns,$={verticalSpacing:ve.verticalSpacing??ve.spacing??"16px",horizontalSpacing:ve.horizontalSpacing??ve.spacing??"16px",rowHeight:ve.rowHeight??Hn};let fe=1;if(Array.isArray(re.fields))for(const Te of re.fields){const Ye=Te?.position,Me=typeof Ye?.order=="number"?Ye.order:0,xe=typeof Ye?.rowSpan=="number"?Ye.rowSpan:1;fe=Math.max(fe,Me+xe)}return{rows:Math.min(ce,Math.max(1,fe)),columns:J,verticalSpacing:$.verticalSpacing,horizontalSpacing:$.horizontalSpacing,rowHeight:$.rowHeight}},[re]),Dt=v.useMemo(()=>{const ce=Se?.config?.theme?.cssVariables;if(!(!ce&&!y))return{...ce??{},...y??{}}},[Se?.config,y]),Bt=v.useCallback(()=>{k.invalidateQueries({queryKey:["workflow-steps",t]}),k.invalidateQueries({queryKey:["workflow-step",t]})},[k,t]),Pt=v.useCallback(ve=>{if(VP(ve)){const fe=ve.on_success,it=fe?.action;if(it==="redirect"&&fe?.redirect_url){const Te=HP(fe.redirect_url.trim(),n);window.location.href=Te;return}if(it==="move"){const Te=fe?.next_step_id,Ye=fe?.next_step_form;if(Te&&Ye){D.current=null,j.current=null;const Me=Ye.featureId??fe?.next_step_form_id??Ye._id;k.removeQueries({queryKey:["workflow-step",t,Me,r??"",T[0],T[1],T[2]]}),Bt(),C(xe=>xe.some(We=>We.step_id===Te)?xe:[...xe,{step_id:Te,step_name:Ye.name||"Next step",feature_id:Me}]),z(null),W(Te),i?.();return}return}if(it==="stay"){Bt(),i?.();return}}const ce=ve;ce.steps&&Array.isArray(ce.steps)&&C(ce.steps);const J=(ce.steps&&Array.isArray(ce.steps)?ce.steps:E).filter(fe=>fe.feature_id),$=ce.current_step_id;$&&J.some(fe=>fe.step_id===$)?W($):J.length>0&&W(J[0].step_id),z(null),Bt(),i?.(),p?.(ce)},[k,t,r,i,p,E,n,T,Bt]),Ar=v.useCallback(async ve=>M?.BFF_submit_api?(i?.(),{success:!0,message:"Saved successfully"}):{success:!1,message:"Submit not configured"},[M?.BFF_submit_api,i]),Nt=v.useCallback((ve,ce)=>{},[]),Cr=v.useCallback(ve=>{},[]);if(oe)return d.jsx(DP,{className:l,position:S??he.position});if(G)return d.jsx("div",{className:H("rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",l),children:G});if(U.length===0)return d.jsx("div",{className:H("py-12 text-center text-sm text-muted-foreground",l),children:"No workflow steps configured."});const Xe=M?.step_blocked_message;return d.jsx("div",{className:H($a,h&&"dark","flex flex-col gap-4",l),style:Dt,"data-form-renderer":"workflow-steps-view",children:d.jsxs(ob,{value:I??"",onValueChange:ve=>W(ve),className:H(Ie!=="top"&&"gap-4",Ue&&"flex-row items-start",Ie==="right"&&"flex-row-reverse",Ie==="bottom"&&"flex-col-reverse"),orientation:Ue?"vertical":"horizontal",children:[d.jsx(PP,{steps:U,position:Ie,sidebarWidth:he.sidebarWidth,sticky:he.sticky,stickyOffset:he.stickyOffset,sidebarMaxHeight:he.sidebarMaxHeight}),U.map(ve=>d.jsx(sb,{value:ve.step_id,className:H("outline-none",Ue?"mt-0 flex-1 min-w-0":"mt-4"),children:ve.step_id!==I?null:ee?d.jsx(BP,{}):V?d.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:V}):Xe&&!M?.form?d.jsx("div",{className:H("rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",l),"data-form-renderer":"workflow-step-blocked",children:Xe}):Se?.fields?.length?d.jsxs("div",{className:"py-4 [&_*]:box-border",children:[Xe?d.jsx("div",{className:H("mb-4 rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200"),"data-form-renderer":"workflow-step-blocked",children:Xe}):null,(()=>{const ce=K.current!==I||ae.current!==(Se?.id??null);if(I&&Se&&ce){K.current=I,ae.current=Se.id??null;const J=Kn.getState();J.setSchema(Se,{forceReset:!0});const $=Kn.getState().values;J.setValues({...$,...o})}return null})(),d.jsx(Ps,{schema:Se,gridLayout:pt,omitRootWrapper:!0,moduleId:t,workflowModalHandlers:N,getAuthHeaders:s,submissionContext:n,initialValues:o,workflowStepId:I??void 0,viewerContext:g,getViewerContext:m,onSubmit:Ar,onChange:Nt,onValidationError:Cr,onClose:()=>{},mode:"fill",unstyled:!0,onWorkflowSubmitResult:Pt,initialExtraSubmitPayload:Object.keys(L).length>0?L:void 0,onExtraSubmitPayloadChange:ce=>{if(ce&&typeof ce=="object"){const J={};ce.context_user_id!=null&&(J.context_user_id=ce.context_user_id),ce.id!=null&&(J.id=ce.id),ce.batch_id!=null&&(J.batch_id=ce.batch_id),ce.admission_batch_id!=null&&(J.admission_batch_id=ce.admission_batch_id),ce.program_id!=null&&(J.program_id=ce.program_id),Object.keys(J).length>0&&B($=>({...$,...J}))}}},Se.id)]}):d.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No form schema available for this step."})},ve.step_id))]})})},wa=new Map;function WP(e){if(e){wa.delete(e);return}wa.clear()}async function Sa(e,t,r){const n=wa.get(t);if(n!==void 0)return n;const o=e.replace(/\/$/,""),i=!!(await Qt.get(`${o}/${encodeURIComponent(t)}/meta`,{headers:r})).data?.standalone_workflow;return wa.set(t,i),i}function xa(e){const t={...e.getAuthHeaders?.()??{}};return e.clientId&&(t["x-client-id"]=e.clientId),e.userId&&(t["x-user-id"]=e.userId),t}function fd(e,t){Object.entries(t).forEach(([r,n])=>{n&&e.set(r,n)})}function lb(e){const t=e.bffWorkflowsBasePath.replace(/\/$/,""),r=()=>xa({getAuthHeaders:e.getAuthHeaders,clientId:e.clientId,userId:e.userId}),n=o=>o?.trim()||e.moduleId?.trim()||"";return{async getWorkflowStateById({workflowId:o,moduleId:s,entryStepId:i}){const a=o.trim(),c=r();if(await Sa(t,a,c)){const p=new URLSearchParams;e.clientId&&p.set("client_id",e.clientId),e.userId&&p.set("user_id",e.userId),fd(p,{entry_step_id:i});const g=p.toString();return(await Qt.get(`${t}/${encodeURIComponent(a)}/standalone-state${g?`?${g}`:""}`,{headers:c})).data}const f=new URLSearchParams;return f.set("module_id",n(s)),e.clientId&&f.set("client_id",e.clientId),e.userId&&f.set("user_id",e.userId),fd(f,{entry_step_id:i}),(await Qt.get(`${t}/${encodeURIComponent(a)}/state?${f.toString()}`,{headers:c})).data},async navigateWorkflowStep({workflowId:o,moduleId:s,targetStepId:i}){const a=o.trim(),c=r();if(await Sa(t,a,c))return(await Qt.post(`${t}/${encodeURIComponent(a)}/standalone-navigate-step`,{workflow_id:a,target_step_id:i},{headers:c})).data;const f=n(s);return(await Qt.post(`${t}/modules/${encodeURIComponent(f)}/navigate-step`,{workflow_id:a,target_step_id:i},{headers:c})).data}}}async function cb(e){const t=e.bffWorkflowsBasePath.replace(/\/$/,""),r=xa({getAuthHeaders:e.getAuthHeaders,clientId:e.clientId,userId:e.subjectUserId});if(e.workflowId?.trim()){const i=e.workflowId.trim();if(await Sa(t,i,r)){const c=new URLSearchParams;e.clientId&&c.set("client_id",e.clientId),e.subjectUserId&&c.set("user_id",e.subjectUserId),fd(c,{step_id:e.viewStepId});const u=c.toString();return(await Qt.get(`${t}/${encodeURIComponent(i)}/standalone-state${u?`?${u}`:""}`,{headers:r})).data}}const n=new URLSearchParams;n.set("module_id",e.moduleId),e.featureId&&n.set("feature_id",e.featureId),e.tenantId&&n.set("tenant_id",e.tenantId),e.subjectUserId&&n.set("user_id",e.subjectUserId),e.viewStepId&&n.set("step_id",e.viewStepId),e.clientId&&n.set("client_id",e.clientId);const o=e.workflowId?.trim()?`${t}/${encodeURIComponent(e.workflowId.trim())}/state?${n.toString()}`:`${t}/modules/${encodeURIComponent(e.moduleId)}/state?${n.toString()}`;return(await Qt.get(o,{headers:r})).data}function RP(e){return typeof e=="object"&&e!==null&&"apiEndpoint"in e}function GP({formSchema:e}){const t=v.useMemo(()=>{if(!e)return[];const s=[];(!e.name||e.name.trim()==="")&&s.push({id:"form-name-required",type:"error",message:"Form name is required"});const i=new Set,a=new Set;e.fields.forEach((f,l)=>{const p=`field-${f.id}`;if(a.has(f.id)&&s.push({id:`${p}-duplicate-id`,type:"error",message:`Field "${f.label||f.name||`Field ${l+1}`}" has a duplicate ID`,fieldId:f.id}),a.add(f.id),f.name&&i.has(f.name)&&s.push({id:`${p}-duplicate-name`,type:"error",message:`Field "${f.label||f.name}" has a duplicate name: "${f.name}"`,fieldId:f.id}),f.name&&i.add(f.name),(!f.label||f.label.trim()==="")&&s.push({id:`${p}-missing-label`,type:"warning",message:`Field "${f.name||f.id}" is missing a label`,fieldId:f.id}),(!f.name||f.name.trim()==="")&&s.push({id:`${p}-missing-name`,type:"error",message:`Field "${f.label||f.id}" is missing a field name`,fieldId:f.id}),f.name&&!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(f.name)&&s.push({id:`${p}-invalid-name`,type:"error",message:`Field "${f.label||f.name}" has an invalid name. Use only letters, numbers, and underscores.`,fieldId:f.id}),["select","multiselect","radio","checkboxgroup"].includes(f.type)){const h=f.properties;(!h?.options||h.options.length===0)&&s.push({id:`${p}-no-options`,type:"warning",message:`Field "${f.label||f.name}" has no options defined`,fieldId:f.id})}f.parentId&&(e.fields.some(y=>y.id===f.parentId)||s.push({id:`${p}-orphaned`,type:"error",message:`Field "${f.label||f.name}" references a non-existent parent`,fieldId:f.id}));const m=(h,y)=>{if(y.has(h))return!0;y.add(h);const S=e.fields.find(w=>w.id===h);return S?.parentId?m(S.parentId,y):!1};f.parentId&&m(f.id,new Set)&&s.push({id:`${p}-circular-reference`,type:"error",message:`Field "${f.label||f.name}" has a circular parent reference`,fieldId:f.id})}),e.config.workflowTrigger?.workflowId&&(e.fields.some(l=>l.validation?.some(p=>p.type==="required"))||s.push({id:"workflow-no-required-fields",type:"info",message:"Form linked to workflow but has no required fields"}));const c=e.fields.filter(f=>!f.parentId),u=new Map;return c.forEach(f=>{const l=f.position.order;u.has(l)||u.set(l,[]),u.get(l).push(f)}),u.forEach((f,l)=>{f.length>3&&s.push({id:`row-${l}-too-many-fields`,type:"warning",message:`Row ${l+1} has ${f.length} fields (maximum recommended is 3)`})}),s},[e]),r=v.useMemo(()=>t.filter(s=>s.type==="error"),[t]),n=v.useMemo(()=>t.filter(s=>s.type==="warning"),[t]),o=v.useMemo(()=>r.length===0,[r]);return{issues:t,errors:r,warnings:n,isValid:o}}function KP({field:e,value:t,allValues:r,validateOnChange:n=!1,validateOnBlur:o=!0,debounceMs:s=WF}){const[i,a]=v.useState(),[c,u]=v.useState(!1),f=v.useRef(void 0),l=v.useRef(t),p=v.useCallback(async()=>{if(!e.validation||e.validation.length===0){a(void 0);return}u(!0);let S;for(const w of e.validation){const A=rn(t,w,r);if(typeof A=="string"){S=A;break}}return a(S),u(!1),S},[e.validation,t,r]),g=v.useCallback(()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{p()},s)},[p,s]);v.useEffect(()=>(n&&l.current!==t&&g(),l.current=t,()=>{f.current&&clearTimeout(f.current)}),[t,n,g]);const m=v.useCallback(()=>{o&&p()},[o,p]),h=v.useCallback(()=>{a(void 0)},[]),y=v.useCallback(S=>{a(S)},[]);return{error:i,isValidating:c,validate:p,handleBlur:m,clearError:h,setCustomError:y}}const db="—";function er(){return{kind:"static",value:db}}function qP(){return _u({currencySymbol:"₹",emptyDisplay:db,columns:[{id:"col_tariff",key:"tariff_type",label:"Tariff type",format:"text",align:"left"},{id:"col_service",key:"service",label:"Service",format:"text",align:"left"},{id:"col_unit",key:"unit_price",label:"Unit price",format:"currency",align:"right"},{id:"col_disc_pct",key:"discount_pct",label:"Discount (%)",format:"percent",align:"right"},{id:"col_disc_amt",key:"discount_amount",label:"Discount (₹)",format:"currency",align:"right"},{id:"col_net",key:"net_price",label:"Net price",format:"currency",align:"right"},{id:"col_tax",key:"tax_pct",label:"Tax (%)",format:"percent",align:"right"},{id:"col_total",key:"total",label:"Total",format:"currency",align:"right"}],rowSlots:[{kind:"static",row:{id:"registration_fee",label:"Registration fee",cells:{tariff_type:{kind:"label"},service:er(),unit_price:{kind:"api",path:"unit_price"},discount_pct:{kind:"input",inputType:"number"},discount_amount:{kind:"formula",expression:"cell('unit_price') * cell('discount_pct') / 100"},net_price:{kind:"formula",expression:"cell('unit_price') - cell('discount_amount')"},tax_pct:{kind:"api",path:"tax_pct"},total:{kind:"formula",expression:"cell('net_price') * (1 + cell('tax_pct') / 100)"}}}},{kind:"dynamic",block:{id:"line_items",apiArrayPath:"items",rowIdField:"id",cells:{tariff_type:er(),service:{kind:"api",path:"service"},unit_price:{kind:"api",path:"unit_price"},discount_pct:er(),discount_amount:{kind:"formula",expression:"cell('unit_price') * cell('discount_pct') / 100"},net_price:{kind:"formula",expression:"cell('unit_price') - cell('discount_amount')"},tax_pct:{kind:"api",path:"tax_pct"},total:{kind:"formula",expression:"cell('net_price') * (1 + cell('tax_pct') / 100)"}}}},{kind:"static",row:{id:"all_items_summary",label:"All items summary",cells:{tariff_type:{kind:"label"},service:er(),unit_price:{kind:"formula",expression:"SUM('unit_price', 'data')"},discount_pct:er(),discount_amount:{kind:"formula",expression:"SUM('discount_amount', 'data')"},net_price:{kind:"formula",expression:"SUM('net_price', 'data')"},tax_pct:er(),total:{kind:"formula",expression:"SUM('total', 'data')"}}}},{kind:"static",row:{id:"invoice_discount",label:"Invoice discount",cells:{tariff_type:{kind:"label"},service:er(),unit_price:er(),discount_pct:er(),discount_amount:{kind:"input",inputType:"number"},net_price:er(),tax_pct:er(),total:er()}}},{kind:"static",row:{id:"grand_total",label:"Grand total",cells:{tariff_type:{kind:"label"},service:er(),unit_price:er(),discount_pct:er(),discount_amount:er(),net_price:er(),tax_pct:er(),total:{kind:"formula",expression:"SUM('total', 'data') - cellInRow('invoice_discount', 'discount_amount')"}}}}]})}const YP={text:{type:"text",label:"Text Input",icon:"Type",category:"input",description:"Single line text input",defaultProps:{label:"Text Field",name:"text_field",placeholder:"Enter text..."}},number:{type:"number",label:"Number Input",icon:"Hash",category:"input",description:"Numeric input with optional constraints",defaultProps:{label:"Number Field",name:"number_field",placeholder:"0",properties:{min:0,step:1}}},email:{type:"email",label:"Email",icon:"Mail",category:"input",description:"Email address input with validation",defaultProps:{label:"Email",name:"email_field",placeholder:"example@domain.com",validation:[{type:"email"}]}},phone:{type:"phone",label:"Phone",icon:"Phone",category:"input",description:"Phone number input",defaultProps:{label:"Phone Number",name:"phone_field",placeholder:"+91 12345 67890"}},otp:{type:"otp",label:"OTP",icon:"ShieldCheck",category:"input",description:"One-time password with separate digit boxes",defaultProps:{label:"OTP",name:"otp_field",properties:{otpLength:4,numericOnly:!0},validation:[{type:"required",message:"Please enter the OTP"}]}},password:{type:"password",label:"Password",icon:"Lock",category:"input",description:"Secure password input",defaultProps:{label:"Password",name:"password_field",placeholder:"••••••••"}},url:{type:"url",label:"URL",icon:"Link",category:"input",description:"URL input with validation",defaultProps:{label:"URL",name:"url_field",placeholder:"https://example.com",validation:[{type:"url"}]}},date:{type:"date",label:"Date",icon:"Calendar",category:"datetime",description:"Date picker",defaultProps:{label:"Date",name:"date_field",placeholder:"Select date"}},time:{type:"time",label:"Time",icon:"Clock",category:"datetime",description:"Time picker",defaultProps:{label:"Time",name:"time_field",placeholder:"Select time"}},datetime:{type:"datetime",label:"Date & Time",icon:"CalendarClock",category:"datetime",description:"Combined date and time picker",defaultProps:{label:"Date & Time",name:"datetime_field",placeholder:"Select date and time"}},daterange:{type:"daterange",label:"Date Range",icon:"CalendarRange",category:"datetime",description:"Select a range of dates",defaultProps:{label:"Date Range",name:"daterange_field",placeholder:"Select date range"}},select:{type:"select",label:"Dropdown",icon:"ChevronDown",category:"selection",description:"Single selection dropdown",defaultProps:{label:"Select",name:"select_field",placeholder:"Select an option",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],searchable:!0,clearable:!0}}},multiselect:{type:"multiselect",label:"Multi Select",icon:"ListChecks",category:"selection",description:"Multiple selection dropdown",defaultProps:{label:"Multi Select",name:"multiselect_field",placeholder:"Select options",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],searchable:!0}}},radio:{type:"radio",label:"Radio Group",icon:"CircleDot",category:"selection",description:"Single selection radio buttons",defaultProps:{label:"Radio Group",name:"radio_field",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}]}}},checkbox:{type:"checkbox",label:"Checkbox",icon:"CheckSquare",category:"selection",description:"Single checkbox for boolean values",defaultProps:{label:"I agree to the terms",name:"checkbox_field"}},toggle:{type:"toggle",label:"Toggle",icon:"ToggleLeft",category:"selection",description:"Toggle switch with configurable text values",defaultProps:{label:"Toggle",name:"toggle_field",description:"Toggle to switch between states",properties:{onValue:"On",offValue:"Off"}}},checkboxgroup:{type:"checkboxgroup",label:"Checkbox Group",icon:"CheckSquare",category:"selection",description:"Multiple checkboxes for selecting multiple values",defaultProps:{label:"Checkbox Group",name:"checkboxgroup_field",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}]}}},selectablelist:{type:"selectablelist",label:"Selectable List",icon:"ListChecks",category:"selection",description:"List from response or context; select all or specific items. Value = selected array.",defaultProps:{label:"Recipients",name:"recipients",properties:{dataSourceContextKey:"recipients",labelField:"name",valueField:"email",showSelectAll:!0,selectAllByDefault:!0}}},asyncsearch:{type:"asyncsearch",label:"Async Search",icon:"Search",category:"selection",description:"Typeahead search against an API; submitted value is the selected option value.",defaultProps:{label:"Search",name:"async_search",placeholder:"Type to search…",properties:{apiEndpoint:"/api/form-builder/search",apiMethod:"GET",searchQueryParam:"q",searchSchedule:"debounce",intervalMs:300,minQueryLength:0,clearable:!0}}},terms:{type:"terms",label:"Terms & Conditions",icon:"FileText",category:"special",description:"Terms and conditions confirmation checkbox",defaultProps:{label:"I confirm that the details are true to my knowledge",name:"terms_conditions",validation:[{type:"required"}]}},textarea:{type:"textarea",label:"Text Area",icon:"AlignLeft",category:"rich",description:"Multi-line text input",defaultProps:{label:"Text Area",name:"textarea_field",placeholder:"Enter your text here...",properties:{minLength:0,maxLength:1e3}}},richtext:{type:"richtext",label:"Rich Text",icon:"FileText",category:"rich",description:"Rich text editor with formatting",defaultProps:{label:"Rich Text",name:"richtext_field"}},file:{type:"file",label:"File Upload",icon:"Upload",category:"rich",description:"File upload with drag and drop",defaultProps:{label:"File Upload",name:"file_field",properties:{accept:["image/*","application/pdf"],maxSize:5*1024*1024}}},camera:{type:"camera",label:"Use camera",icon:"Camera",category:"rich",description:"Take a photo with your camera",defaultProps:{label:"Take photo",name:"camera_field",properties:{accept:["image/*"],maxSize:5*1024*1024,multiple:!1}}},photoChoice:{type:"photoChoice",label:"Photo (upload or camera)",icon:"ImagePlus",category:"rich",description:"Upload a file or capture with the camera",defaultProps:{label:"Photo",name:"photo_choice_field",properties:{accept:["image/*"],maxSize:5*1024*1024,maxFiles:1}}},signature:{type:"signature",label:"Signature",icon:"Pencil",category:"rich",description:"Digital signature capture",defaultProps:{label:"Signature",name:"signature_field"}},rating:{type:"rating",label:"Rating",icon:"Star",category:"rich",description:"Star rating input",defaultProps:{label:"Rating",name:"rating_field",properties:{max:5,allowHalf:!1,icon:"star"}}},slider:{type:"slider",label:"Slider",icon:"SlidersHorizontal",category:"rich",description:"Numeric slider input",defaultProps:{label:"Slider",name:"slider_field",properties:{min:0,max:100,step:1,showValue:!0}}},table:{type:"table",label:"Table",icon:"Table",category:"special",description:"Repeatable table rows",defaultProps:{label:"Table",name:"table_field",properties:{columns:[],minRows:1,maxRows:10,allowAddRow:!0,allowDeleteRow:!0}}},billingGrid:{type:"billingGrid",label:"Billing Grid",icon:"Receipt",category:"special",description:"Configurable billing/tariff grid with formulas and API line items",defaultProps:{label:"Billing",name:"billing",properties:qP()}},aadhaar:{type:"aadhaar",label:"Aadhaar",icon:"CreditCard",category:"special",description:"Indian Aadhaar number input",defaultProps:{label:"Aadhaar Number",name:"aadhaar_field",placeholder:"XXXX XXXX XXXX"}},section:{type:"section",label:"Section",icon:"LayoutPanelTop",category:"container",description:"Group fields in a collapsible section",defaultProps:{label:"Section",name:"section",properties:{collapsible:!0,defaultCollapsed:!1,columns:1}}},group:{type:"group",label:"Group",icon:"Group",category:"container",description:"Group fields without visual separator",defaultProps:{label:"Group",name:"group"}},columns:{type:"columns",label:"Columns",icon:"Columns",category:"container",description:"Multi-column layout",defaultProps:{label:"Columns",name:"columns",properties:{columns:2}}},divider:{type:"divider",label:"Divider",icon:"Minus",category:"visual",description:"Horizontal line separator",defaultProps:{label:"",name:"divider"}},header:{type:"header",label:"Header",icon:"Heading",category:"visual",description:"Section header text (full row, configurable size)",defaultProps:{label:"Header",name:"header",properties:{headingLevel:"h3",showHorizontalLine:!0}}},sectionHeading:{type:"sectionHeading",label:"Section Heading",icon:"Heading",category:"visual",description:"Heading inside a grid box with configurable position and size",defaultProps:{label:"Section Heading",name:"section_heading",properties:{position:"top-left",headingLevel:"h3",showHorizontalLine:!0}}},spacer:{type:"spacer",label:"Spacer",icon:"Space",category:"visual",description:"Empty space for padding",defaultProps:{label:"",name:"spacer"}},textLabel:{type:"textLabel",label:"Text Label",icon:"Tag",category:"visual",description:"Standalone label text (no input)",defaultProps:{label:"Label",name:"text_label"}},status:{type:"status",label:"Status",icon:"ListChecks",category:"visual",description:"Populate status from Status API; label + response key; true = completed",defaultProps:{label:"Admission Status",name:"status_field",properties:{source:"api",statuses:[{label:"Registered",key:"registered"},{label:"Form Submitted",key:"formSubmitted"},{label:"Documents Verification",key:"documentsVerification"},{label:"Photos Clicked",key:"photosClicked"},{label:"Fitness Verification",key:"fitnessVerification"},{label:"Payment Completed",key:"paymentCompleted"},{label:"Hostel Allotted",key:"hostelAllotted"},{label:"Admission Completed",key:"admissionCompleted"}],showStatusText:!1,statusTextPath:"admissionStatus",showCurrentIndicator:!0}}},button:{type:"button",label:"Button",icon:"MousePointerClick",category:"special",description:"Clickable button element",defaultProps:{label:"Button",name:"button_field",properties:{variant:"default",size:"default",action:"download"}}},editButton:{type:"editButton",label:"Edit Button",icon:"Pencil",category:"special",description:"Toggle edit mode: enable/disable or show/hide other fields and buttons (no API call)",defaultProps:{label:"Edit",name:"edit_button",properties:{buttonText:"Edit",variant:"outline",size:"default",hideLabel:!1,rules:[]}}},addmore:{type:"addmore",label:"Add More",icon:"Plus",category:"special",description:"Duplicate linked fields as a new runtime block",defaultProps:{label:"Add More",name:"addmore_field",properties:{linkedFieldNames:[],linkedSectionIds:[],variant:"outline",size:"default"}}},customizeSections:{type:"customizeSections",label:"Customise Sections",icon:"ListFilter",category:"special",description:"Show or hide UI sections defined by Section Heading fields",defaultProps:{label:"Customise Sections",name:"customize_sections",properties:{sectionHeadingNames:[],defaultHiddenSectionNames:[],variant:"outline",size:"default",buttonText:"Customise sections",menuTitle:"VISIBLE SECTIONS"}}}},ub={padding:"md",showBorder:!1};function fb(e,t){const r="full";return e?{padding:e.padding??ub.padding,maxWidth:e.maxWidth??r,showBorder:e.showBorder??ub.showBorder}:{padding:"md",maxWidth:r,showBorder:!1}}function XP(e){switch(e??"md"){case"none":return"";case"sm":return"p-3";case"lg":return"p-6 md:p-8";default:return"p-4 md:p-6"}}function JP(e,t){if(t==="full-bleed")return"w-full max-w-none";switch(e??"full"){case"full":return"w-full max-w-none";case"sm":return"mx-auto w-full max-w-screen-sm";case"md":return"mx-auto w-full max-w-screen-md";case"lg":return"mx-auto w-full max-w-screen-lg";case"xl":return"mx-auto w-full max-w-screen-xl";case"2xl":return"mx-auto w-full max-w-2xl";case"4xl":return"mx-auto w-full max-w-4xl";case"5xl":return"mx-auto w-full max-w-5xl";case"6xl":return"mx-auto w-full max-w-6xl";case"7xl":return"mx-auto w-full max-w-7xl";default:return"w-full max-w-none"}}function QP(e){switch(e){case"sidebar-main":return"grid grid-cols-1 gap-6 lg:grid-cols-[240px_1fr]";case"full-bleed":return"w-full";default:return"w-full"}}function ZP(e){const t=fb(e.container,e.layout);return H(QP(e.layout),JP(t.maxWidth,e.layout),XP(t.padding),t.showBorder&&"rounded-lg border border-border")}const Aa=1;function eO(){return{version:Aa,layout:"stack",container:{padding:"md",maxWidth:"full",showBorder:!1},dataBindings:[],widgets:[],filterGroups:[]}}function pb(e){return{...e,config:e.config??{},children:Array.isArray(e.children)?e.children.map(pb):void 0}}function tO(e){return{version:Aa,layout:e.layout??"stack",container:fb(e.container,e.layout),meta:e.meta,dataBindings:Array.isArray(e.dataBindings)?e.dataBindings:[],dataApis:e.dataApis??{},prepopulateApi:e.prepopulateApi,widgets:Array.isArray(e.widgets)?e.widgets.map(pb):[],filterGroups:Array.isArray(e.filterGroups)?e.filterGroups:[],eventHandlers:e.eventHandlers??[],navigation:e.navigation}}function rO(e){const t=e;return!t||typeof t!="object"?eO():(t.version!==Aa&&(t.version=Aa),tO(t))}const mb={};let hb=null;function nO(e){hb=e}function oO(){return(mb?.VITE_API_BASE_URL?.trim()||mb?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const Is=Ct.create({baseURL:oO()});Is.interceptors.request.use(e=>{const t=nn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=hb?.();if((!r||Object.keys(r).length===0)&&(r=ds()),r){const n=e.headers??{};for(const[o,s]of Object.entries(r))s!==void 0&&s!==""&&(n[o]=s);e.headers=n}return e});async function gb(e){const t=await Is.get("/api/page-builder/pages/resolve",{params:e}),r=t.data?.data??t.data;if(!r?.pageId)throw new Error("Page resolve failed: no pageId returned");return r}async function pd(e,t,r){const n=await Is.get(`/api/page-builder/pages/${e}/render`,{params:{clientId:t,...r!==void 0?{version:r}:{}}}),o=n.data?.data??n.data;if(!o?.schema)throw new Error("Page render failed: no schema returned");return o}async function md(e){const{clientId:t,api:r,context:n,filterState:o}=e,s=await Is.post(`/api/page-builder/clients/${t}/data-sources/execute`,{api:r,context:n,filterState:o});return s.data?.data??s.data}function sO(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t)){if(!o.trim())continue;const s=Ge(e,o);s!==void 0&&(r[n]=s)}return r}const hd=v.createContext(null);function iO(e,t){if(t.parentContext)return"idle";const r=e.prepopulateApi,n=String(t.clientIdProp??t.externalContext.clientId??"");return r?.enabled&&r.api?.path&&n?"loading":"idle"}function yb(e,t){const r={};for(const n of e){let o;switch(n.source){case"route.param":o=n.param?t[n.param]:void 0;break;case"route.query":o=n.param?t[n.param]:void 0;break;case"context.user":o=n.param?t.user?.[n.param]:t.user;break;case"context.client":o=n.param?t.client?.[n.param]:t.client??t.clientId;break;case"context.tenant":o=n.param?t.tenant?.[n.param]:t.tenant??t.tenantId;break;case"static":o=n.value;break;case"widget.state":o=n.sample;break;default:o=void 0}o===void 0&&n.sample!==void 0&&(o=n.sample),o!==void 0&&(r[n.key]=o)}return r}function aO({schema:e,context:t={},clientId:r,nestingDepth:n=0,onAction:o,getWorkflowState:s,workflowModalHandlers:i,getAuthHeaders:a,parentContext:c,children:u}){const[f,l]=v.useState(()=>c?c.filterGroups:{}),p=v.useRef(f);p.current=f;const[g,m]=v.useState({}),[h,y]=v.useState(()=>iO(e,{parentContext:c,clientIdProp:r,externalContext:t})),S=v.useRef(null),w=String(r??t.clientId??c?.clientId??""),A=JSON.stringify(t);v.useEffect(()=>{if(c)return;const E=e.prepopulateApi;if(!E?.enabled||!E.api?.path||!w){m({}),y("idle"),S.current=null;return}const C=JSON.stringify({path:E.api.path,method:E.api.method,queryParams:E.api.queryParams,headers:E.api.headers,bodyFields:E.api.bodyFields,auth:E.api.auth,mapping:E.contextMapping,bindings:e.dataBindings,context:A});if(S.current===C)return;let I=!1;return S.current=C,y("loading"),(async()=>{try{const W=yb(e.dataBindings??[],t),M={...t,...W},z=await md({clientId:w,api:E.api,context:M});if(I)return;const V=sO(z,E.contextMapping);m({...V,prepopulateResponse:z}),y("ready")}catch{I||(m({}),y("error"))}})(),()=>{I=!0,S.current=null}},[c,e.prepopulateApi,e.dataBindings,A,w]);const x=v.useMemo(()=>{if(c)return{...c.context,...t};const E=yb(e.dataBindings??[],t);return{...t,...E,...g}},[c,t,e.dataBindings,g]),F=String(r??x.clientId??c?.clientId??""),N=v.useCallback((E,C,I)=>{l(W=>({...W,[E]:{...W[E]??{},[C]:I}}))},[]),k=v.useCallback(E=>p.current[E]??{},[]),T=v.useCallback((E,C,I,W)=>{(o??c?.onAction)?.({...E,sourceWidgetId:C,event:I,payload:W})},[o,c?.onAction]),P=v.useMemo(()=>({schema:e,context:x,clientId:F,prepopulateStatus:c?.prepopulateStatus??h,nestingDepth:n,onAction:o??c?.onAction,getWorkflowState:s??c?.getWorkflowState,workflowModalHandlers:i??c?.workflowModalHandlers,getAuthHeaders:a??c?.getAuthHeaders,filterGroups:f,setFilterValue:N,getFilterGroup:k,dispatchAction:T}),[e,x,F,h,n,o,c?.onAction,s,c?.getWorkflowState,i,c?.workflowModalHandlers,a,c?.getAuthHeaders,f,N,k,T]);return d.jsx(hd.Provider,{value:P,children:u})}function $r(){const e=v.useContext(hd);if(!e)throw new Error("usePageContext must be used within PageContextProvider");return e}function lO(){return v.useContext(hd)}const cO=5,bb=1;function Vo(e){return Number.isFinite(e)?Math.min(cO,Math.max(bb,Math.round(e))):bb}function dO(e,t){const r=Vo(t),n=Array.from({length:r},()=>[]);return e.forEach((o,s)=>{const i=o.config,a=i.columnIndex!==void 0?Math.min(Math.max(0,i.columnIndex),r-1):s%r;n[a].push(o)}),n}function uO(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):0}function fO(e,t){const r=Math.max(1,t),n=Math.min(100,Math.max(0,Math.round(e))),o=Math.floor(n/r),s=n-o*r;return Array.from({length:r},(i,a)=>o+(a<s?1:0))}function vb(e){return fO(100,Vo(e))}function pO(e){const t=e.trim(),r=/^(\d+(?:\.\d+)?)\s*%?$/.exec(t);return r?uO(Number(r[1])):null}function wb(e,t){const r=Vo(t),n=[];for(let s=0;s<r;s++){const i=pO(e?.[s]??"");if(i===null)return vb(r);n.push(i)}return n.reduce((s,i)=>s+i,0)!==100?vb(r):n}function mO(e){return e==="sm"?"gap-2":e==="lg"?"gap-6":"gap-4"}function Sb(e,t){return wb(t,Vo(e)).map(n=>`minmax(0, ${n}fr)`).join(" ")}function hO(e){return e.length?e.map(t=>`minmax(0, ${t}fr)`).join(" "):"minmax(0, 1fr)"}function gO(e,t,r,n){const o=Vo(t),s=dO(e,o),i=wb(r,o);if(!(n?.collapseEmpty!==!1))return{columns:s,gridTemplate:Sb(o,r),sourceIndices:s.map((p,g)=>g)};const c=s.map((p,g)=>({colChildren:p,index:g,percent:i[g]??0})).filter(p=>p.colChildren.length>0);if(c.length===0||c.length===s.length)return{columns:s,gridTemplate:Sb(o,r),sourceIndices:s.map((p,g)=>g)};const u=c.reduce((p,g)=>p+g.percent,0),f=c.map(p=>u>0?Math.round(p.percent/u*100):Math.round(100/c.length)),l=100-f.reduce((p,g)=>p+g,0);return l!==0&&f.length>0&&(f[0]+=l),{columns:c.map(p=>p.colChildren),gridTemplate:hO(f),sourceIndices:c.map(p=>p.index)}}function gd(e,t="solid"){return e?t==="dashed"?"rounded-md border border-dashed border-border":"rounded-md border border-border":""}function yO(e){return H(gd(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-3")}function bO(e){return H(gd(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-2")}function vO(e,t){return e.columnBorders?.[t]!==void 0?!!e.columnBorders[t]:!!e.showColumnBorders}function wO(e,t){const r=vO(e,t);return H(gd(r,e.borderStyle??"dashed"),r&&"p-2")}function SO(e){if(e)return{minHeight:`${e}vh`}}function xO({widget:e,renderChildren:t}){const r=e.config,[n,o]=v.useState(r.defaultCollapsed??!1);return d.jsxs("section",{className:H("space-y-4",yO(r)),"data-widget-id":e.id,children:[r.heading&&d.jsx("div",{className:"flex items-center gap-2",children:r.collapsible?d.jsx("button",{type:"button",className:"text-left text-lg font-semibold hover:underline",onClick:()=>o(s=>!s),children:r.heading}):d.jsx("h2",{className:"text-lg font-semibold",children:r.heading})}),r.showDivider&&d.jsx("hr",{className:"border-border"}),!n&&e.children?.length?d.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function AO({widget:e,renderChildren:t}){const r=e.config,n=Vo(r.columns??2),o=r.collapseEmptyColumns!==!1,s=gO(e.children??[],n,r.columnWidths,{collapseEmpty:o});return d.jsx("div",{className:H("grid w-full min-w-0 items-stretch",mO(r.gap),bO(r)),style:{gridTemplateColumns:s.gridTemplate,...SO(r.minHeightPercent)},"data-widget-id":e.id,children:s.columns.map((i,a)=>{const c=s.sourceIndices[a]??a;return d.jsx("div",{className:H("flex min-h-[inherit] min-w-0 flex-col space-y-4 overflow-hidden",wO(r,c)),children:t?.(i)},c)})})}function CO({widget:e,renderChildren:t}){const r=e.config,n=r.variant==="outline"?"border bg-background":r.variant==="elevated"?"border bg-background shadow-md":"border bg-card";return d.jsxs("div",{className:H("rounded-lg p-4",n),"data-widget-id":e.id,children:[(r.title||r.subtitle)&&d.jsxs("div",{className:"mb-4",children:[r.title&&d.jsx("h3",{className:"font-semibold",children:r.title}),r.subtitle&&d.jsx("p",{className:"text-sm text-muted-foreground",children:r.subtitle})]}),e.children?.length?d.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function xb(e,t){if(e.variable){const r=t[e.variable];return r!=null?String(r):e.fallback??e.text??""}return e.text??""}function EO({widget:e}){const t=e.config,{context:r}=$r(),n=xb(t,r),o=t.level??2,s=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left",i=o===1?"text-3xl":o===2?"text-2xl":o===3?"text-xl":"text-lg";return d.jsx("div",{role:"heading","aria-level":o,className:H("font-semibold tracking-tight",i,s),"data-widget-id":e.id,children:n})}function NO({widget:e}){const t=e.config,{context:r}=$r(),n=xb(t,r),o=t.preset==="caption"?"text-sm text-muted-foreground":t.preset==="small"?"text-xs text-muted-foreground":"text-base",s=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left";return d.jsx("p",{className:H(o,s),"data-widget-id":e.id,children:n})}function kO(e,t){return!e||typeof e!="string"?e:e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=n.trim(),s=t[o];return s==null?"":String(s)})}function Ab(e,t){const r={...e};for(const[n,o]of Object.entries(r))typeof o=="string"&&(r[n]=kO(o,t));return r}function _O(e,t){return e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=t[n.trim()];return o!=null?String(o):""})}function Cb(e,t,r,n){if(e.type==="navigate"){const o=_O(e.href,t);if(!o.trim())return;e.openIn==="new"?window.open(o,"_blank","noopener,noreferrer"):window.location.assign(o);return}if(e.type==="navigate_page"&&e.pageId){r({...e,params:e.params?Ab(e.params,t):void 0},n,"click");return}if(e.type==="workflow"&&e.workflowId){r(e,n,"click");return}r(e,n,"click")}function TO({widget:e}){const t=e.config,{context:r,dispatchAction:n}=$r();return d.jsx(Zt,{variant:t.variant??"default",size:t.size??"default","data-widget-id":e.id,onClick:()=>Cb(t.action,r,n,e.id),children:t.label})}const FO={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between"},PO={sm:"gap-2",md:"gap-3",lg:"gap-4"};function OO({widget:e}){const t=e.config,{context:r,dispatchAction:n}=$r(),o=t.buttons??[];return d.jsx("div",{className:H("flex flex-wrap items-center",FO[t.align??"start"],PO[t.gap??"sm"],t.wrap===!1&&"flex-nowrap"),"data-widget-id":e.id,children:o.map(s=>d.jsx(Zt,{variant:s.variant??"outline",size:s.size??"default","data-widget-id":e.id,"data-button-id":s.id,onClick:()=>Cb(s.action,r,n,e.id),children:s.label},s.id))})}function IO(e){const t=e.prepopulateApi;return!!(t?.enabled&&t.api?.path)}function MO(e,t){return e&&(t==="idle"||t==="loading")}function LO(e,t){return!e||t==="ready"||t==="error"}function DO(e,t){const r=Ge(e,t??"");return r===void 0?null:r}function Eb(e,t){if(e.mode==="pageApi"&&e.dataSourceRef)return t[e.dataSourceRef];if(e.mode==="api")return e.api}function Nb({widgetId:e,dataSource:t,enabled:r=!0,page:n,pageSize:o,search:s}){const{schema:i,context:a,clientId:c,getFilterGroup:u,prepopulateStatus:f}=$r(),l=v.useMemo(()=>t.filterGroupKey?u(t.filterGroupKey):{},[t.filterGroupKey,u]),p=t.mode==="context"&&IO(i),g=MO(p,f),m=r&&(t.mode==="static"||(t.mode==="context"?LO(p,f):!!c)),h=v.useMemo(()=>["page-ds",e,t,a,l,n,o,s,f],[e,t,a,l,n,o,s,f]),y=Nn.useQuery({queryKey:h,enabled:m,staleTime:Eb(t,i.dataApis??{})?.staleTimeMs??3e4,queryFn:async()=>{if(t.mode==="static")return t.staticData;if(t.mode==="context")return DO(a,t.contextPath);const S=Eb(t,i.dataApis??{});if(!S)throw new Error(`No API config for data source on widget ${e}`);const w={...a};if(t.requestBindings)for(const F of t.requestBindings){let N;F.source==="binding"?N=a[F.key]:F.source==="filter"&&(N=l[F.key]),N!==void 0&&(w[F.param]=N)}const x={...Ab(w,a),...n!==void 0?{page:n,pageSize:o,search:s}:{}};return md({clientId:c,api:S,context:x,filterState:l})}});return{...y,isLoading:y.isLoading||g,isPending:y.isPending||g,isFetching:y.isFetching||g}}function yd(e,t){if(e==null)return"";if(!t||t.type==="none")return String(e);switch(t.type){case"number":{const r=Number(e);return Number.isNaN(r)?String(e):r.toFixed(t.decimals??0)}case"currency":{const r=Number(e);return Number.isNaN(r)?String(e):new Intl.NumberFormat(void 0,{style:"currency",currency:t.currency??"USD"}).format(r)}case"percent":{const r=Number(e);return Number.isNaN(r)?String(e):`${r.toFixed(t.decimals??0)}%`}case"date":{const r=new Date(String(e));return Number.isNaN(r.getTime())?String(e):r.toLocaleDateString(void 0,{...t.format?{}:{}})}case"template":return t.template.replace(/\{\{value\}\}/g,String(e));default:return String(e)}}function Ms(e,t){const r=Ge(e,t.path);return r==null?t.fallback??r:t.formatter?yd(r,t.formatter):r}function BO(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t))o in e&&(r[n]=e[o]);return r}const $O={default:"border bg-card",success:"border border-green-200 bg-green-50 text-green-900",warning:"border border-amber-200 bg-amber-50 text-amber-900",danger:"border border-red-200 bg-red-50 text-red-900"},jO={rectangle:"rounded-lg",square:"aspect-square rounded-lg",circle:"aspect-square rounded-full"},zO={sm:"p-2 text-xs",md:"p-4 text-sm",lg:"p-6 text-base"},bd={sm:"text-lg",md:"text-2xl",lg:"text-3xl"},UO={sm:"gap-2",md:"gap-3",lg:"gap-4"};function VO({title:e,value:t,trend:r,variant:n="default",shape:o="rectangle",size:s="md",layout:i="vertical",isLoading:a,isError:c}){const u=i==="horizontal";return d.jsxs("div",{className:H($O[n??"default"],jO[o??"rectangle"],zO[s??"md"],u&&"flex items-center justify-between gap-3"),children:[d.jsxs("div",{className:H(u&&"min-w-0"),children:[e&&d.jsx("p",{className:H("font-medium text-muted-foreground",u?"text-sm":""),children:e}),r!=null&&r!==""&&!u&&d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:String(r)})]}),a?d.jsx(vn,{className:"my-2"}):c?d.jsx("p",{className:H("font-bold text-destructive",bd[s??"md"]),children:"Error"}):d.jsx("p",{className:H("font-bold",u?bd[s??"md"]:`mt-1 ${bd[s??"md"]}`),children:String(t)}),u&&r!==null&&r!==void 0&&r!==""&&d.jsx("p",{className:"text-xs text-muted-foreground",children:String(r)})]})}function kb({stat:e,widgetId:t}){const{data:r,isLoading:n,isError:o}=Nb({widgetId:t,dataSource:e.dataSource}),i=(()=>{if(n)return"";if(r==null)return e.valueMapping.fallback??"—";if(e.dataSource.mode==="context"){const c=r;return e.valueMapping.formatter?yd(c,e.valueMapping.formatter):c}if(e.dataSource.mode==="static"){const c=e.valueMapping.path?.trim()||"value",u=Ms(r,{...e.valueMapping,path:c});if(u!=null)return e.valueMapping.formatter?yd(u,e.valueMapping.formatter):u;if(typeof r=="object"&&r!==null&&!Array.isArray(r)){const f=r;if(f.value!==void 0&&f.value!==null)return f.value}return e.valueMapping.fallback??"—"}return Ms(r,e.valueMapping)})(),a=e.trendMapping&&r!==void 0&&e.dataSource.mode!=="context"?Ms(r,e.trendMapping):e.trendMapping&&e.dataSource.mode==="context"&&e.trendMapping.path?Ms({value:r},e.trendMapping):null;return d.jsx(VO,{title:e.title,value:i,trend:a,variant:e.variant,shape:e.shape,size:e.size,layout:e.layout,isLoading:n,isError:o})}function HO({widget:e}){const t=e.config;return d.jsx("div",{"data-widget-id":e.id,children:d.jsx(kb,{stat:t,widgetId:e.id})})}function WO({stat:e,widgetId:t}){return d.jsx(kb,{stat:e,widgetId:`${t}-${e.id}`})}function RO({widget:e}){const t=e.config,r=t.stats??[],n=t.columns??1,o=t.direction==="horizontal";return d.jsx("div",{"data-widget-id":e.id,className:H(o?"flex flex-wrap":"grid",!o&&n===1&&"grid-cols-1",!o&&n===2&&"grid-cols-2",!o&&n===3&&"grid-cols-3",!o&&n===4&&"grid-cols-4",UO[t.gap??"md"]),children:r.map(s=>d.jsx(WO,{stat:s,widgetId:e.id},s.id))})}function GO({widget:e}){const t=e.config,{setFilterValue:r}=$r(),[n,o]=v.useState("");return v.useEffect(()=>{const s=t.debounceMs??300,i=setTimeout(()=>{r(t.filterGroupKey,"search",n)},s);return()=>clearTimeout(i)},[n,t.debounceMs,t.filterGroupKey,r]),d.jsx("input",{type:"search",className:"flex h-9 w-full max-w-sm rounded-md border border-input bg-background px-3 py-1 text-sm shadow-xs",placeholder:t.placeholder??"Search…",value:n,onChange:s=>o(s.target.value),"data-widget-id":e.id})}function KO(e,t){if(!e)return[];const r=t?Ge(e,t):e;if(Array.isArray(r))return r;if(typeof r=="object"&&r!==null){const n=r;if(Array.isArray(n.items))return n.items;if(Array.isArray(n.data))return n.data}return[]}function qO({widget:e}){const t=e.config,{dispatchAction:r}=$r(),[n,o]=v.useState(1),[s,i]=v.useState(""),a=t.pagination?.pageSize??10,{data:c,isLoading:u,isError:f}=Nb({widgetId:e.id,dataSource:t.dataSource,page:n,pageSize:a,search:t.search?.enabled?s:void 0}),l=t.dataSource.mode==="pageApi"?void 0:t.dataSource.api?.itemsPath,p=KO(c,l??"data.items"),g=(m,h)=>{const y=t.dataSource.responseMapping.find(S=>S.target===h);return y?Ms(m,y):Ge(m,h)??""};return d.jsxs("div",{className:"space-y-3","data-widget-id":e.id,children:[t.search?.enabled&&d.jsx("input",{type:"search",className:"flex h-9 w-full max-w-sm rounded-md border border-input bg-background px-3 py-1 text-sm",placeholder:t.search.placeholder??"Search…",value:s,onChange:m=>{i(m.target.value),o(1)}}),d.jsx("div",{className:"overflow-x-auto rounded-md border",children:d.jsxs("table",{className:"w-full text-sm",children:[d.jsx("thead",{children:d.jsx("tr",{className:"border-b bg-muted/50",children:t.columns.map(m=>d.jsx("th",{className:H("px-3 py-2 text-left font-medium",m.align==="center"&&"text-center",m.align==="right"&&"text-right"),style:m.width?{width:m.width}:void 0,children:m.header},m.id))})}),d.jsx("tbody",{children:u?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center",children:d.jsx(vn,{})})}):f?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-destructive",children:"Failed to load data"})}):p.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-muted-foreground",children:t.emptyMessage??"No data"})}):p.map((m,h)=>d.jsx("tr",{className:"cursor-pointer border-b hover:bg-muted/30",onClick:()=>{r({type:"emit",eventName:"row_click",payload:{row:m}},e.id,"row_click")},children:t.columns.map(y=>d.jsx("td",{className:H("px-3 py-2",y.align==="center"&&"text-center",y.align==="right"&&"text-right"),children:String(g(m,y.field))},y.id))},h))})]})}),t.pagination?.enabled&&d.jsxs("div",{className:"flex items-center justify-between text-sm",children:[d.jsxs("span",{className:"text-muted-foreground",children:["Page ",n]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",className:"rounded border px-2 py-1 disabled:opacity-50",disabled:n<=1,onClick:()=>o(m=>Math.max(1,m-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"rounded border px-2 py-1",disabled:p.length<a,onClick:()=>o(m=>m+1),children:"Next"})]})]})]})}const YO=75;function XO(e){return e??YO}function JO(e){return e?"rounded-md border border-border p-3":""}function vd({scrollBehavior:e="page",maxHeightPercent:t,children:r,className:n}){if(e!=="contained")return n?d.jsx("div",{className:n,children:r}):d.jsx(d.Fragment,{children:r});const o=XO(t);return d.jsx("div",{className:H("min-w-0 overflow-y-auto overflow-x-hidden",n),style:{maxHeight:`${o}vh`},"data-form-embed-scroll":"contained",children:r})}function QO(e,t,r){return["embedded-form",e,t,r??"latest"]}async function ZO(e,t){try{const r=await Qt.get(`/api/form-builder/form-layouts/form/${e}`,{params:{clientId:t}});let n=r.data?.data??r.data;for(;n&&typeof n=="object"&&!Array.isArray(n)&&n.data!=null&&typeof n.data=="object"&&!("rows"in n)&&!("columns"in n)&&!("formDefinitionId"in n);)n=n.data;return!n||typeof n!="object"||Array.isArray(n)||!("rows"in n)&&!("columns"in n)&&!("formDefinitionId"in n)?null:n}catch{return null}}async function eI(e,t,r){const n=r!==void 0?`/api/form-builder/forms/${e}/render?version=${r}`:`/api/form-builder/forms/${e}/render`,o=await Qt.get(n,{params:{clientId:t}}),i=o.data?.data??o.data,a=i.form??i,c=i.fields??a.fields??[];let u=i.layout??a.layout??null;(!u||typeof u.columns!="number")&&(u=await ZO(e,t));const f=i.rules??a.rules??[],l=Ts(a,c,u,f),p=Us({config:l.config,layout:l.layout},zs(u))??zs(u);return{schema:l,gridLayout:p}}const tI=300*1e3;function _b({formId:e,mode:t="fill",contextFieldMapping:r,pageContext:n,clientId:o,formVersion:s,scrollBehavior:i,maxHeightPercent:a,showBorder:c}){const u=lO(),{data:f,isLoading:l,isError:p,error:g}=Nn.useQuery({queryKey:QO(e,o,s),queryFn:()=>eI(e,o,s),staleTime:tI}),m=v.useMemo(()=>BO(n,r),[n,r]),h=JO(c);if(l)return d.jsx(vd,{scrollBehavior:i,maxHeightPercent:a,className:h,children:d.jsx(vn,{})});if(p)return d.jsx(vd,{scrollBehavior:i,maxHeightPercent:a,className:h,children:d.jsx("p",{className:"text-sm text-destructive",children:g instanceof Error?g.message:"Failed to load form"})});if(!f?.schema)return null;const y=typeof f.schema.moduleId=="string"?f.schema.moduleId.trim():"",S=u?.context.moduleId!=null?String(u.context.moduleId).trim():"",w=y||S||void 0;return d.jsx(vd,{scrollBehavior:i,maxHeightPercent:a,className:h,children:d.jsx(Ps,{schema:f.schema,mode:t,gridLayout:f.gridLayout,initialValues:m,submissionContext:n,moduleId:w,workflowModalHandlers:u?.workflowModalHandlers,getAuthHeaders:u?.getAuthHeaders})})}function rI({widget:e}){const t=e.config,{context:r,clientId:n}=$r();return t.formId?d.jsx(_b,{formId:t.formId,mode:t.mode??"fill",contextFieldMapping:t.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:t.scrollBehavior,maxHeightPercent:t.maxHeightPercent,showBorder:t.showBorder}):d.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured"})}function nI({widget:e}){const t=e.config,{context:r,getWorkflowState:n,workflowModalHandlers:o,clientId:s}=$r(),i=String(r.moduleId??"");if(!n)return d.jsxs("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground","data-widget-id":e.id,children:["Workflow embed requires ",d.jsx("code",{className:"text-xs",children:"getWorkflowState"})," on PageRenderer. Workflow ID: ",t.workflowId]});if(!i)return d.jsx("p",{className:"text-sm text-destructive","data-widget-id":e.id,children:"moduleId required in page context for workflow embed"});const a={};if(t.contextVariableMapping)for(const[c,u]of Object.entries(t.contextVariableMapping)){const f=r[u];f!=null&&(a[c]=String(f))}return d.jsx(ab,{getWorkflowState:n,workflowModalHandlers:o,moduleId:i,tenantId:r.tenantId?String(r.tenantId):void 0,clientId:s||void 0,submissionContext:a})}function oI({widget:e}){const t=e.config,{schema:r,dispatchAction:n}=$r(),o=t.previousPage??r.navigation?.previousPage,s=t.nextPage??r.navigation?.nextPage,i=t.showPrevious!==!1&&!!o,a=t.showNext!==!1&&!!s,c=t.showBreadcrumbs&&r.navigation?.breadcrumbs?.length,u=t.align==="center"?"justify-center":t.align==="right"?"justify-end":t.align==="space-between"?"justify-between":"justify-start",f=l=>{n({type:"navigate_page",pageId:l.pageId},e.id,"click")};return d.jsxs("nav",{className:"space-y-3","data-widget-id":e.id,children:[c&&d.jsx("ol",{className:"flex flex-wrap items-center gap-1 text-sm text-muted-foreground",children:r.navigation.breadcrumbs.map((l,p)=>d.jsxs("li",{className:"flex items-center gap-1",children:[p>0&&d.jsx("span",{children:"/"}),l.href?d.jsx("a",{href:l.href,className:"hover:underline",children:l.label}):d.jsx("span",{children:l.label})]},p))}),d.jsxs("div",{className:H("flex items-center gap-2",u),children:[i&&o&&d.jsx(Zt,{variant:"outline",size:"sm",onClick:()=>f(o),children:o.label??"Previous"}),a&&s&&d.jsx(Zt,{variant:"default",size:"sm",onClick:()=>f(s),children:s.label??"Next"})]})]})}function sI(e,t){return e?.length?e.filter(r=>r.config.tabId===t):[]}const iI=1;function aI(e){switch(e){case"pills":return"bg-transparent gap-1 p-0 h-auto";case"underline":return"bg-transparent rounded-none border-b p-0 h-auto w-full justify-start gap-4";default:return""}}function lI(e){switch(e){case"pills":return"rounded-full data-[state=active]:bg-primary data-[state=active]:text-primary-foreground";case"underline":return"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none bg-transparent";default:return""}}function cI(e,t,r){return e?new Set(r?[r]:[]):new Set(t.map(n=>n.id))}function dI({tab:e,shouldRender:t,pageContext:r,clientId:n}){return t?e.formId?d.jsx(_b,{formId:e.formId,mode:e.formMode??"fill",contextFieldMapping:e.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:e.scrollBehavior,maxHeightPercent:e.maxHeightPercent,showBorder:e.showBorder}):d.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured for this tab"}):null}function uI({tab:e,shouldLoad:t,shouldRender:r,nestingDepth:n,pageContext:o,clientId:s,onAction:i,getWorkflowState:a}){const c=$r(),{data:u,isLoading:f,isError:l,error:p}=Nn.useQuery({queryKey:["tab-page",e.pageId,e.pageVersion,s],enabled:t&&!!e.pageId,queryFn:async()=>pd(e.pageId,s,e.pageVersion)});return r?n>=iI?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:"Nested page tabs not supported"}):e.pageId?f?d.jsx(vn,{}):l?d.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load page"}):u?d.jsx(wd,{page:u,context:o,nestingDepth:n+1,inheritContext:!0,onAction:i,getWorkflowState:a,parentContext:c}):null:d.jsx("p",{className:"text-sm text-muted-foreground",children:"No page configured for this tab"}):null}function fI({tab:e,widgetChildren:t,renderChildren:r}){const n=sI(t,e.id);return n.length===0?d.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No widgets in this tab"}):d.jsx(d.Fragment,{children:r?.(n)})}function pI({widget:e,renderChildren:t}){const r=e.config,{context:n,clientId:o,nestingDepth:s,onAction:i,getWorkflowState:a}=$r(),c=r.tabs??[],u=r.defaultTabId??c[0]?.id??"",f=r.lazyLoad!==!1,[l,p]=v.useState(u),[g,m]=v.useState(()=>cI(f,c,u)),h=S=>{m(w=>new Set(w).add(S)),p(S)},y=v.useMemo(()=>!f,[f]);return c.length===0?d.jsx("p",{className:"text-sm text-muted-foreground","data-widget-id":e.id,children:"No tabs configured"}):d.jsxs(ob,{value:l,onValueChange:h,className:"w-full","data-widget-id":e.id,children:[d.jsx(ld,{className:H("mb-4",aI(r.variant)),children:c.map(S=>d.jsx(cd,{value:S.id,disabled:S.disabled,className:lI(r.variant),children:S.label},S.id))}),c.map(S=>{const w=g.has(S.id),A=y||w,x=y||w;return d.jsxs(sb,{value:S.id,forceMount:y||void 0,className:H("mt-0",y&&"data-[state=inactive]:hidden"),children:[S.contentType==="widgets"&&x&&d.jsx(fI,{tab:S,widgetChildren:e.children??[],renderChildren:t}),S.contentType==="form"&&d.jsx(dI,{tab:S,shouldRender:A,pageContext:n,clientId:o}),S.contentType==="page"&&d.jsx(uI,{tab:S,shouldLoad:A,shouldRender:x,nestingDepth:s,pageContext:n,clientId:o,onAction:i,getWorkflowState:a})]},S.id)})]})}const mI={section:xO,columns:AO,card:CO,tab_group:pI,heading:EO,text:NO,button:TO,button_group:OO,stat_card:HO,stat_grid:RO,data_table:qO,search_filter:GO,form_embed:rI,workflow_embed:nI,page_nav:oI};function hI({widget:e}){return d.jsxs("div",{className:"rounded-md border border-dashed border-muted-foreground/40 bg-muted/20 p-3 text-sm text-muted-foreground","data-widget-id":e.id,"data-widget-type":e.type,children:["Unsupported widget: ",d.jsx("code",{className:"text-xs",children:e.type}),e.label&&d.jsxs("span",{className:"ml-1",children:["(",e.label,")"]})]})}function gI({widget:e,renderChildren:t}){const r=mI[e.type]??hI;return d.jsx(r,{widget:e,renderChildren:t})}function Tb(e,t){return e.map(r=>d.jsx(gI,{widget:r,renderChildren:t},r.id))}const yI="/api/bff/workflows";function bI(e){const t=e.moduleId??e.module_id;return t!=null?String(t).trim():""}function Fb(e){const t=Df(),r=e.userId??e.user_id??t?.userId;return r!=null&&String(r).trim()!==""?String(r):void 0}function vI(e){const t=String(e.clientId??nn()??""),r=Fb(e);return()=>xa({getAuthHeaders:()=>ds()??{},clientId:t||void 0,userId:r})}function wI(e,t){const r=bI(e);if(!r)return null;const n=t?.bffWorkflowsBasePath??yI,o=String(e.clientId??nn()??""),s=Fb(e),i=vI(e),a=t?.workflowModalHandlers??lb({bffWorkflowsBasePath:n,moduleId:r,getAuthHeaders:i,clientId:o||void 0,userId:s});return{getWorkflowState:t?.getWorkflowState??(u=>cb({bffWorkflowsBasePath:n,moduleId:u.moduleId,featureId:u.featureId,tenantId:u.tenantId,subjectUserId:u.subjectUserId,viewStepId:u.viewStepId,clientId:u.clientId??(o||void 0),getAuthHeaders:i})),workflowModalHandlers:a,getAuthHeaders:i,moduleId:r}}function wd({page:e,context:t={},onAction:r,chrome:n="none",className:o,nestingDepth:s=0,getWorkflowState:i,workflowModalHandlers:a,getAuthHeaders:c,inheritContext:u=!1,parentContext:f}){const l=v.useMemo(()=>rO(e.schema),[e.schema]),p=v.useMemo(()=>{const h=wI(t,{getWorkflowState:i,workflowModalHandlers:a});return{getWorkflowState:i??h?.getWorkflowState,workflowModalHandlers:a??h?.workflowModalHandlers,getAuthHeaders:c??h?.getAuthHeaders}},[t,i,a,c]),g=h=>Tb(h,g),m=d.jsxs("div",{className:H("studio-page-content min-h-0 min-w-0",ZP(l),o),"data-page-id":e.id,"data-nesting-depth":s,children:[n==="minimal"&&l.meta?.title&&d.jsxs("header",{className:"mb-6 border-b pb-4",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:l.meta.title}),l.meta.description&&d.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:l.meta.description})]}),d.jsx("div",{className:"space-y-6",children:Tb(l.widgets,g)})]});return u&&f?m:d.jsx(aO,{schema:l,context:t,clientId:String(t.clientId??""),nestingDepth:s,onAction:r,getWorkflowState:p.getWorkflowState,workflowModalHandlers:p.workflowModalHandlers,getAuthHeaders:p.getAuthHeaders,parentContext:f,children:m})}function SI({clientId:e,tenantId:t,moduleId:r,featureId:n,pageId:o,routePath:s,routeParams:i={},isDefault:a,context:c={},version:u,chrome:f="none",onAction:l,getWorkflowState:p,workflowModalHandlers:g,getAuthHeaders:m}){const h=v.useMemo(()=>({...i,...c,clientId:e,tenantId:t,moduleId:r,featureId:n}),[i,c,e,t,r,n]),{data:y,isLoading:S,isError:w,error:A}=Nn.useQuery({queryKey:["page-resolve",e,t,r,n,o,s,a,u],queryFn:()=>gb({clientId:e,tenantId:t,moduleId:r,featureId:n,routePath:s,isDefault:a,version:u}),enabled:!o}),x=o??y?.pageId,F=u??y?.version,{data:N,isLoading:k,isError:T,error:P}=Nn.useQuery({queryKey:["page-render",x,e,F],queryFn:()=>pd(x,e,F),enabled:!!x});return!o&&S?d.jsx("div",{className:"flex items-center justify-center p-12",children:d.jsx(vn,{})}):w?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:A instanceof Error?A.message:"Failed to resolve page"}):x?k?d.jsx("div",{className:"flex items-center justify-center p-12",children:d.jsx(vn,{})}):T||!N?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:P instanceof Error?P.message:"Failed to load page"}):d.jsx(wd,{page:N,context:h,chrome:f,nestingDepth:0,onAction:l,getWorkflowState:p,workflowModalHandlers:g,getAuthHeaders:m}):d.jsx("div",{className:"rounded-md border p-4 text-sm text-muted-foreground",children:"No page found for the given scope or route."})}ue.FIELD_TYPE_REGISTRY=YP,ue.FORM_RENDERER_GRID_ROW_HEIGHT_DEFAULT=Hn,ue.FORM_RENDERER_ROOT_CLASS=$a,ue.FieldRenderer=wn,ue.FormRenderer=Ps,ue.PageRenderer=wd,ue.RendererFieldLayoutContext=Ya,ue.RendererStoreProvider=il,ue.STEPS_NAV_RUNTIME_DEFAULTS=Os,ue.StudioPageHost=SI,ue.WorkflowFormModal=Cg,ue.WorkflowModalProvider=kg,ue.WorkflowStepsView=ab,ue.appearanceControlClasses=uo,ue.appearanceHasExplicitVerticalIntent=iu,ue.appearanceTextareaClasses=Jd,ue.backendToFormSchema=Ts,ue.buildBffWorkflowAuthHeaders=xa,ue.cellAlignmentClasses=Hv,ue.cellVerticalJustifyClassesForField=Vv,ue.clearWorkflowStandaloneCache=WP,ue.createBffWorkflowModalHandlers=lb,ue.effectiveWidthPercent=Rs,ue.executeDataSource=md,ue.fetchBffWorkflowState=cb,ue.fetchPageRender=pd,ue.fetchWorkflowStandaloneFlag=Sa,ue.fieldBlockBoxStyle=Uv,ue.fieldBlockBoxStyleForField=ou,ue.fieldBlockHorizontalPlacementClass=eu,ue.fieldBlockHorizontalSelfClass=tu,ue.fieldBlockHorizontalSelfClassForField=su,ue.fieldBlockWidthStyle=Ha,ue.fieldBlockWidthStyleForField=nu,ue.fieldGridShellFillsCellVertically=Ks,ue.formBuilderHttp=Qt,ue.formLayoutRecordToGridConfig=zs,ue.getBusinessApiOrigin=Mf,ue.getClientId=nn,ue.getRendererHostAuthHeaders=ds,ue.getRendererHostViewerContext=Df,ue.getRendererStore=ww,ue.gridCellFlexClasses=Zd,ue.gridCellFlexClassesForField=qa,ue.gridCellOuterFlexClasses=Qd,ue.hasExplicitFieldBlockWidth=ru,ue.isAsyncSearchFieldProperties=RP,ue.isIntrinsicWidthButtonField=fo,ue.normalizeWorkflowFormSchema=c_,ue.normalizeWorkflowFormToRendererSchema=da,ue.pageBuilderHttp=Is,ue.parseContentVerticalAlign=Ra,ue.parseMetadataJson=xs,ue.resetRendererHostAuth=D0,ue.resolveBusinessApiUrl=Mr,ue.resolveFormGridLayout=Us,ue.resolvePage=gb,ue.resolveWorkflowStepsNavigationConfig=ud,ue.resolveWorkflowStepsNavigationPosition=MP,ue.resolvedGridCellVerticalJustifyClasses=Xo,ue.resolvedHorizontalAlign=Fr,ue.resolvedVerticalAlign=Yo,ue.resolvedVerticalAlignForField=Ka,ue.setBusinessApiOrigin=P0,ue.setFormBuilderAuthProvider=B0,ue.setPageBuilderAuthProvider=nO,ue.setRendererHostAuthHeaders=L0,ue.setRendererHostViewerContext=M0,ue.useFieldValidation=KP,ue.useFormRenderer=xu,ue.useFormValidation=GP,ue.useRendererFieldLayout=Jo,ue.useRendererHostAuthStore=Qn,ue.useWorkflowModal=Ng,Object.defineProperty(ue,Symbol.toStringTag,{value:"Module"})}));
50
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},Lk="DialogDescriptionWarning",Dk=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ag(Lk).contentName}}.`;return b.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Bk=Yh,$k=Qh,jk=Zh,zk=eg,Uk=rg,Vk=sg;function lg({...e}){return d.jsx(Bk,{"data-slot":"dialog",...e})}function Hk({...e}){return d.jsx($k,{"data-slot":"dialog-portal",...e})}function Wk({className:e,...t}){return d.jsx(jk,{"data-slot":"dialog-overlay",className:H("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function cg({className:e,children:t,showCloseButton:r=!0,...n}){return d.jsxs(Hk,{"data-slot":"dialog-portal",children:[d.jsx(Wk,{}),d.jsxs(zk,{"data-slot":"dialog-content",className:H("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...n,children:[t,r&&d.jsxs(Vk,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[d.jsx(ns,{}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function dg({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-header",className:H("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Rk({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-footer",className:H("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function ug({className:e,...t}){return d.jsx(Uk,{"data-slot":"dialog-title",className:H("text-lg leading-none font-semibold",e),...t})}async function Gk(){const e={width:{ideal:1280},height:{ideal:720}},t=[{facingMode:{ideal:"environment"},...e},{facingMode:{ideal:"user"},...e},{...e},{}];let r;for(const n of t)try{return await navigator.mediaDevices.getUserMedia({video:Object.keys(n).length>0?n:!0,audio:!1})}catch(o){r=o}throw r instanceof Error?r:new Error("Could not access camera")}function fg(e){const t=()=>e.play();t().catch(()=>{requestAnimationFrame(()=>{t().catch(()=>{const r=()=>{t().catch(()=>{})};e.addEventListener("loadedmetadata",r,{once:!0}),e.addEventListener("canplay",r,{once:!0})})})})}const pg=({open:e,onOpenChange:t,onCaptured:r,validateFile:n,accept:o,disabled:s,onValidationMessage:i})=>{const a=v.useRef(null),c=v.useRef(null),u=v.useRef(null),f=v.useRef(null),[l,p]=v.useState(null),[g,m]=v.useState(!1),h=v.useCallback(()=>{a.current&&(a.current.srcObject=null)},[]),y=v.useCallback(()=>{u.current&&(u.current.getTracks().forEach(N=>N.stop()),u.current=null),h()},[h]);v.useEffect(()=>{if(!e){y(),p(null),m(!1);return}if(s)return;let N=!1;return p(null),m(!0),Gk().then(k=>{if(N){k.getTracks().forEach(T=>T.stop());return}u.current=k,m(!1)}).catch(k=>{if(N)return;m(!1);const T=k instanceof Error?k.message:"Could not access camera";p(T)}),()=>{N=!0,u.current&&(u.current.getTracks().forEach(k=>k.stop()),u.current=null),h()}},[e,s,y,h]);const S=v.useCallback(N=>{a.current=N,N&&u.current&&e&&!l&&!g&&(N.srcObject=u.current,fg(N))},[e,l,g]);v.useLayoutEffect(()=>{if(!e||l||g||!u.current)return;let N=!1,k=0;const T=()=>{if(N)return;const E=a.current;!E||!u.current||(E.srcObject=u.current,fg(E))};T();const P=requestAnimationFrame(()=>{T(),k=requestAnimationFrame(T)});return()=>{N=!0,cancelAnimationFrame(P),cancelAnimationFrame(k),h()}},[e,l,g,h]);const w=v.useCallback(()=>{y(),p(null),m(!1),t(!1),f.current&&(f.current.value="")},[y,t]),A=v.useCallback(()=>{const N=a.current,k=c.current;if(!N||!k||!u.current||N.readyState<2)return;const T=N.videoWidth,P=N.videoHeight;if(T===0||P===0)return;k.width=T,k.height=P;const E=k.getContext("2d");E&&(E.drawImage(N,0,0),k.toBlob(C=>{if(!C)return;const I=new File([C],`camera-capture-${Date.now()}.jpg`,{type:"image/jpeg",lastModified:Date.now()}),W=n(I);if(W){i?.(W);return}i?.(void 0),r(I),w()},"image/jpeg",.92))},[r,n,w,i]),x=v.useCallback(N=>{const k=N.target.files?.[0];if(!k)return;const T=n(k);if(T){i?.(T);return}i?.(void 0),r(k),w(),f.current&&(f.current.value="")},[r,n,w,i]),F=typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function";return d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:f,type:"file",accept:o,capture:"user",onChange:x,className:"hidden","aria-hidden":!0}),d.jsx("canvas",{ref:c,className:"hidden","aria-hidden":!0}),d.jsx(lg,{open:e,onOpenChange:N=>{N||w()},children:d.jsxs(cg,{className:"sm:max-w-md",showCloseButton:!0,onPointerDownOutside:N=>N.preventDefault(),children:[d.jsx(dg,{children:d.jsx(ug,{children:"Take a photo"})}),l?d.jsxs("div",{className:"space-y-3 py-2",children:[d.jsx("p",{className:"text-sm text-destructive",children:l}),F&&d.jsx("p",{className:"text-xs text-muted-foreground",children:"You can choose an image from your device instead."}),d.jsx(Zt,{type:"button",variant:"outline",className:"w-full",onClick:()=>f.current?.click(),children:"Choose from device"})]}):g?d.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Opening camera…"}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"relative rounded-lg overflow-hidden bg-black aspect-video",children:d.jsx("video",{ref:S,playsInline:!0,muted:!0,className:"w-full h-full object-cover"})}),d.jsxs(Rk,{className:"gap-2 sm:gap-0",children:[d.jsx(Zt,{type:"button",variant:"outline",onClick:w,children:"Cancel"}),d.jsx(Zt,{type:"button",onClick:A,children:"Capture photo"})]})]})]})})]})},Kk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const c=e.properties,[u,f]=v.useState(),[l,p]=v.useState(!1),[g,m]=v.useState(()=>new Set),[h,y]=v.useState("none"),S=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,w=e.validation?.find(j=>j.type==="fileSize"),A=e.validation?.find(j=>j.type==="fileType"),x=w?.value!=null?w.value:c?.maxSize??S?.maxSize??5*1024*1024,F=A?.value!=null?A.value:c?.accept??S?.accept??["image/*"],N=F.join(",")||"image/*",k=Js(e),T=v.useCallback(j=>{if(w){const U=rn(j,w);if(U!==!0)return typeof U=="string"?U:"File size exceeds the maximum allowed size"}else if(j.size>x)return`File size must be less than ${Fo(x)}`;if(A){const U=rn(j,A);if(U!==!0)return typeof U=="string"?U:"File type is not allowed"}return null},[w,A,x]),P=v.useMemo(()=>Qs(t),[t]),E=wc(P),C=v.useCallback(j=>{const U=Ja(j,k);r(U),n?.()},[r,n,k]),I=v.useCallback(j=>{const U=T(j);if(U){f(U);return}f(void 0);const le=[...P];le.length>=k||(le.push(j),C(le),y("none"))},[P,k,T,C]),W=v.useCallback(j=>{const U=P.filter((le,oe)=>oe!==j);C(U)},[P,C]),M=v.useCallback(()=>{s||P.length>=k||(f(void 0),y("camera"),p(!0))},[s,P.length,k]),z=v.useCallback(j=>{p(j),j||y("none")},[]),V=o||u,X=e.appearance?.hideLabel??!1,D=[];(w||x)&&D.push(`Max size: ${Fo(x)}`),A&&F.length>0&&D.push(`Allowed: ${F.join(", ")}`),k>1&&D.push(`Up to ${k} photos`);const B=v.useCallback(j=>{window.open(j,"_blank","noopener,noreferrer")},[]),L=P.length===0,K=P.length<k,ie=yc(k,P.length);return d.jsxs(At,{field:e,error:V,isRequired:i,className:H(a,"!space-y-0"),hideLabel:X,children:[d.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:d.jsx("div",{role:"button",tabIndex:s||!K?-1:0,id:ft(e),onClick:j=>{s||j.target.closest("[data-remove-in-dropzone]")||j.target.closest("[data-no-open-picker]")||P.length>=k||M()},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),!s&&K&&M())},className:H("border-2 border-dashed rounded-lg p-1.5 text-center cursor-pointer transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",V&&"border-destructive",s&&"opacity-50 cursor-not-allowed",l&&h==="camera"&&"opacity-70 pointer-events-none",!K&&P.length>0&&"cursor-default"),"aria-describedby":Lt(e,!!V),"aria-invalid":Jt(!!V),"aria-required":i,children:L?d.jsxs(d.Fragment,{children:[d.jsx(ii,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),d.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:l?"Opening camera…":"Click to open camera"}),D.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:D.join(" • ")})]}):ie?d.jsx(Sc,{item:P[0],objectUrl:E[0]??null,failedUrlKeys:g,onImageUrlError:j=>m(U=>new Set(U).add(j)),onRemove:()=>W(0),onOpenUrl:B,disabled:s}):d.jsx(vc,{items:P,maxFiles:k,disabled:s,objectUrls:E,failedUrlKeys:g,onImageUrlError:j=>m(U=>new Set(U).add(j)),onRemove:W,onOpenUrl:B,addSlot:K?d.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:j=>{j.stopPropagation(),M()},disabled:s,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center text-muted-foreground hover:border-primary hover:bg-primary/5 text-[10px] leading-tight px-0.5",children:[d.jsx(ii,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})})}),d.jsx(pg,{open:l,onOpenChange:z,onCaptured:I,validateFile:T,accept:N,disabled:s,onValidationMessage:f})]})},qk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,buttonResponses:c})=>{const u=e.properties,f=v.useRef(null),[l,p]=v.useState(),[g,m]=v.useState(!1),[h,y]=v.useState(()=>new Set),[S,w]=v.useState("none"),A=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,x=e.validation?.find(ee=>ee.type==="fileSize"),F=e.validation?.find(ee=>ee.type==="fileType"),N=x?.value?x.value:u?.maxSize??A?.maxSize??5*1024*1024,k=F?.value?F.value:u?.accept??A?.accept??["image/*"],T=Array.isArray(k)?k.join(","):"image/*",P=Js(e),E=v.useCallback(ee=>{if(x){const ne=rn(ee,x);if(ne!==!0)return typeof ne=="string"?ne:"File size exceeds the maximum allowed size"}else if(ee.size>N)return`File size must be less than ${Fo(N)}`;if(F){const ne=rn(ee,F);if(ne!==!0)return typeof ne=="string"?ne:"File type is not allowed"}return null},[x,F,N]),C=v.useMemo(()=>Qs(t),[t]),I=wc(C),W=v.useCallback(ee=>{const ne=Ja(ee,P);r(ne),n?.()},[r,n,P]),M=v.useCallback(ee=>{p(void 0);const ne=Array.from(ee),he=[...C];let Ie=null;for(const Ue of ne){if(he.length>=P)break;const re=E(Ue);if(re){Ie||(Ie=re);continue}he.push(Ue)}if(Ie&&he.length===C.length){p(Ie);return}Ie&&p(Ie),W(he),w("none")},[C,P,E,W]),z=v.useCallback(ee=>{const ne=ee.target.files;ne&&ne.length>0&&M(ne),f.current&&(f.current.value="")},[M]),V=v.useCallback(ee=>{W(C.filter((ne,he)=>he!==ee))},[C,W]),X=v.useCallback(()=>{s||C.length>=P||g||(p(void 0),w("file"),f.current?.click())},[s,C.length,P,g]),D=v.useCallback(()=>{s||C.length>=P||(p(void 0),w("camera"),m(!0))},[s,C.length,P]),B=v.useCallback(ee=>{const ne=E(ee);if(ne){p(ne);return}p(void 0);const he=[...C];he.length>=P||(he.push(ee),W(he),w("none"))},[C,P,E,W]),L=v.useCallback(ee=>{m(ee),ee||w("none")},[]),K=o||l,ie=e.appearance?.hideLabel??!1,j=[];(x||N)&&j.push(`Max size: ${Fo(N)}`),F&&k.length>0&&j.push(`Allowed: ${k.join(", ")}`),P>1&&j.push(`Up to ${P} photos`);const U=v.useMemo(()=>{if(!c)return null;const ee=Object.values(c);for(let ne=ee.length-1;ne>=0;ne-=1){const he=ee[ne],Ie=typeof he?.status=="string"?he.status.toLowerCase():null;if(Ie&&Ie!=="success")continue;const Ue=he?.code;if(typeof Ue=="number"&&(Ue<200||Ue>=300))continue;const re=he?.data,ge=re?.file_url||re?.fileUrl||he?.file_url||he?.fileUrl;if(typeof ge=="string"&&ge.trim())return ge.trim()}return null},[c]),le=v.useCallback(ee=>{window.open(ee,"_blank","noopener,noreferrer")},[]),oe=C.length===0,G=C.length<P,ae=yc(P,C.length),Ae=G&&!g?d.jsxs("div",{"data-no-open-picker":!0,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center gap-0.5 text-muted-foreground",children:[d.jsx("button",{type:"button",disabled:s,onClick:ee=>{ee.stopPropagation(),X()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-t","aria-label":"Upload file",title:"Upload",children:d.jsx(li,{className:"h-4 w-4","aria-hidden":!0})}),d.jsx("button",{type:"button",disabled:s,onClick:ee=>{ee.stopPropagation(),D()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-b border-t border-border/50","aria-label":"Open camera",title:"Camera",children:d.jsx(ii,{className:"h-4 w-4","aria-hidden":!0})})]}):void 0;return d.jsxs(At,{field:e,error:K,isRequired:i,className:H(a,"!space-y-0"),hideLabel:ie,children:[d.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:d.jsxs("div",{className:H("border-2 border-dashed rounded-lg p-1.5 transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",K&&"border-destructive",s&&"opacity-50"),children:[d.jsx("input",{ref:f,id:ft(e),type:"file",accept:T,multiple:P>1,onChange:z,disabled:s||e.disabled||g||!G,className:"hidden","aria-describedby":Lt(e,!!K),"aria-invalid":Jt(!!K),"aria-required":i}),oe?d.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 w-full pointer-events-auto",children:[d.jsxs("div",{className:"flex items-center justify-center gap-3",children:[d.jsxs("button",{type:"button",disabled:s||g,onClick:X,className:H("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none"),children:[d.jsx(li,{className:"h-5 w-5","aria-hidden":!0}),d.jsx("span",{children:"Upload"})]}),d.jsxs("button",{type:"button",disabled:s,onClick:D,className:H("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none",g&&"opacity-70"),children:[d.jsx(ii,{className:"h-5 w-5","aria-hidden":!0}),d.jsx("span",{children:"Camera"})]})]}),j.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-2 text-center px-1",children:j.join(" • ")})]}):ae?d.jsx(Sc,{item:C[0],objectUrl:I[0]??null,failedUrlKeys:h,onImageUrlError:ee=>y(ne=>new Set(ne).add(ee)),onRemove:()=>V(0),onOpenUrl:le,openTarget:C[0]instanceof File?U:void 0,disabled:s||e.disabled}):d.jsx(vc,{items:C,maxFiles:P,disabled:s,objectUrls:I,failedUrlKeys:h,onImageUrlError:ee=>y(ne=>new Set(ne).add(ee)),onRemove:V,resolveOpenUrl:(ee,ne)=>ne instanceof File&&C.length===1&&U?U:null,onOpenUrl:ee=>{ee?.trim()&&le(ee.trim())},addSlot:Ae})]})}),d.jsx(pg,{open:g,onOpenChange:L,onCaptured:B,validateFile:E,accept:T,disabled:s,onValidationMessage:p})]})};function Yk(e){if(e==null||typeof e!="object")return;const t=e;if(typeof t.message=="string"&&t.message.trim())return t.message.trim();if(typeof t.display_message=="string"&&t.display_message.trim())return t.display_message.trim();if(t.data&&typeof t.data=="object"){const r=t.data;if(typeof r.message=="string"&&r.message.trim())return r.message.trim();if(typeof r.success_message=="string"&&r.success_message.trim())return r.success_message.trim();if(typeof r.display_message=="string"&&r.display_message.trim())return r.display_message.trim()}if(typeof t.success_message=="string"&&t.success_message.trim())return t.success_message.trim()}function mg(e,t){try{const r=Yk(e);ct.toast.success(r&&r.trim()?r:t)}catch{ct.toast.success(t)}}function ia(e,t,r){try{const n=r(e);ct.toast.error(n&&n.trim()?n:t)}catch{ct.toast.error(t)}}function Xk(e){const t=e.headers,r=["X-Message","X-Success-Message","X-Toast-Message","X-Success-Msg"];for(const n of r){const o=t.get(n);if(o&&typeof o=="string"&&o.trim())return o.trim()}}const aa="This field is required";function hg(e,t){if(!t?.length)return e;const r=t.find(n=>n.name===e);return r?.label&&r.label.trim()||e}function la(e,t){if(!e)return"Please complete the required fields.";if(Array.isArray(e)){const s=e.map(i=>{const a=i.message||aa;if(t?.length&&i.field){const c=hg(i.field,t);return a===aa?`${c} is required`:`${c}: ${a}`}return a}).filter(i=>typeof i=="string"&&i.length>0);return s.length===0?"Please complete the required fields.":s.length===1?s[0]:`${s[0]} (and ${s.length-1} more)`}const n=Object.entries(e).map(([o,s])=>{const i=s?.trim()||aa;if(t?.length){const a=hg(o,t);return i===aa?`${a} is required`:`${a}: ${i}`}return i}).filter(o=>typeof o=="string"&&o.length>0);return n.length===0?"Please complete the required fields.":n.length===1?n[0]:`${n[0]} (and ${n.length-1} more)`}function gg(e){if(e==null||typeof e!="object")return!1;const t=e;if(t.status==="error")return!0;const r=t.code;return typeof r=="number"&&(r<200||r>=300)}function Jk(e){return!gg(e)}function Qk(e,t,r){if(!t||!Jk(e))return;const n=t.fieldMapping;if(n&&Object.keys(n).length>0)for(const[s,i]of Object.entries(n)){if(!s.trim()||!i?.trim())continue;const a=Re(e,i.trim());a!=null&&r.setFieldValue(s.trim(),a)}const o=t.contextMapping;if(o&&Object.keys(o).length>0&&r.onContextUpdate){const s={};for(const[i,a]of Object.entries(o)){if(!i.trim()||!a?.trim())continue;const c=Re(e,a.trim());c!=null&&(s[i.trim()]=c)}Object.keys(s).length>0&&r.onContextUpdate(s)}}function Zk(e=Kn){const{totalSteps:t,currentStep:r}=e.getState();return t>1&&r<t-1}async function Ec(e,t=Kn){const r=await t.getState().nextStep();if(!r)try{const n=t.getState(),o=n.errors;Object.keys(o).length>0?ct.toast.error(la(o,e)||"Please fix the errors before continuing."):n.totalSteps<=1||n.currentStep>=n.totalSteps-1?ct.toast.error("You are already on the last page."):ct.toast.error("Please fix the errors before continuing.")}catch{ct.toast.error("Please fix the errors before continuing.")}return r}function e_(e=Kn){e.getState().prevStep()}const t_=3;function Po(e){if(typeof e=="number"&&!Number.isNaN(e))return e}function Oo(e,t){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;return Po(r?.cellSlot)??Po(r?.stackSlot)??Po(r?.cellSlotIndex)??Po(r?.slotIndex)??Po(t?.cellSlotIndex)??Po(t?.stackSlot)}function As(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;if(t?.sharedCellLayout==="row"||t?.sharedCellLayout==="stack")return t.sharedCellLayout;if(t?.stackDirection==="horizontal")return"row";if(t?.stackDirection==="vertical")return"stack"}function ca(e){const t=typeof e.position?.order=="number"?e.position.order:-1,r=typeof e.position?.column=="number"?e.position.column:1,n=e.position?.cellGroupId??"_";return`${t}:${r}:${n}`}function Nc(e){return[...e].sort((t,r)=>{const n=Oo(t.position),o=Oo(r.position);return typeof n=="number"&&typeof o=="number"&&n!==o?n-o:String(t.id).localeCompare(String(r.id))})}function Cs(e,t){if(e.length===0)return{rowSpan:1,columnSpan:1};let r=1,n=1;for(const o of e)r=Math.max(r,qo(o)),n=Math.max(n,Jd(o,t));return{rowSpan:r,columnSpan:n}}function yg(e){const t=Nc(e);for(const r of t){const n=As(r.position);if(n)return n}return t.length>=2?"row":"stack"}function bg(e){return Nc(e).slice(0,t_)}function r_(e,t){const r=new Map;for(const n of e){if(!t(n)||typeof n.position?.order!="number")continue;const o=ca(n),s=r.get(o)??[];s.push(n),r.set(o,s)}return Array.from(r.values()).map(n=>bg(n))}function vg(e,t,r,n){const o=r.filter(a=>n(a)&&typeof a.position?.order=="number"&&a.position.order===e&&(a.position.column??1)===t+1);if(o.length===0)return[];const s=new Map;for(const a of o){const c=ca(a),u=s.get(c)??[];u.push(a),s.set(c,u)}const i=[...s.values()][0]??[];return bg(i)}function n_(e,t,r,n){const o=r[0],s=o.position?.order,i=o.position?.column??1;if(typeof s!="number")return!1;const{rowSpan:a,columnSpan:c}=Cs(r,n),u=e===s&&t===i-1,f=e>=s&&e<s+a,l=t>=i-1&&t<i-1+c;return f&&l&&!u}function o_(e,t,r){const n=new Set(r??[]);for(const o of e){const s=o[0]?.position?.order??0,{rowSpan:i}=Cs(o,t);for(let a=s;a<s+i;a++)n.add(a)}return n}function s_(e){const t=[...e].sort((n,o)=>n-o),r=new Map;return t.forEach((n,o)=>r.set(n,o)),{originalToDisplay:r,displayRowCount:Math.max(t.length,1),sortedOriginalRows:t}}function i_(e,t,r){const n=r.get(e);if(n===void 0)return;let o=0;for(let s=e;s<e+t&&r.has(s);s++)o++;return`${n+1} / span ${Math.max(o,1)}`}function hr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Io(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>Io(r));if(!hr(e))return e;const t={};for(const[r,n]of Object.entries(e))t[r]=Io(n);return t}function wg(e,...t){const r={...e};for(const n of t)if(!(!n||!hr(n)))for(const[o,s]of Object.entries(n)){const i=r[o];hr(s)&&hr(i)?r[o]=wg(i,s):r[o]=s}return r}function oo(e){return hr(e)?e:{}}function Es(e){if(e==null)return{};if(typeof e=="string"){const t=e.trim();if(!t)return{};try{const r=JSON.parse(t);return hr(r)?Io(r):{}}catch{return{}}}return hr(e)?Io(e):{}}function Sg(e){const t=e.apidata;return hr(t)&&Object.keys(t).length>0}function a_(e){if(typeof e.metadata=="string"&&e.metadata.trim()!==""||typeof e.metadata=="object"&&e.metadata!==null&&!Array.isArray(e.metadata)&&Object.keys(e.metadata).length>0||Sg(e))return!0;const t=e.fieldKey,r=e.fieldType,n=e.name,o=e.type;return!!(t&&(!n||String(n).trim()==="")||r&&(!o||String(o).trim()==="")||t&&n&&t!==n||r&&o&&r!==o||!n&&e.key&&typeof e.key=="string")}const xg=["hideLabel","contentAlign","contentVerticalAlign","labelPlacement","widthPercent","widthMode","className","verticalAlign","horizontalAlign","cellAlign","cellJustify","size","variant","minWidth","minHeight"];function l_(e,t){const r=e.appearance,n=hr(r)&&Object.keys(r).length>0?Io(r):{},o=oo(t.appearance),s={...n};for(const[i,a]of Object.entries(o))i!=="heightPercent"&&s[i]===void 0&&(s[i]=Io(a));for(const i of xg)s[i]===void 0&&t[i]!==void 0&&(s[i]=t[i]);return delete s.heightPercent,Object.keys(s).length>0?s:void 0}function c_(e,t){const r=oo(e.position),n=Es(e.metadata),o=oo(e.layout),s=typeof r.order=="number"&&!Number.isNaN(r.order)?r.order:typeof e.positionOrder=="number"?e.positionOrder:typeof e.order=="number"?e.order:typeof e.positionRow=="number"?e.positionRow:t,i=typeof r.column=="number"&&!Number.isNaN(r.column)?r.column:typeof e.positionColumn=="number"?e.positionColumn:1,a=typeof r.columnSpan=="number"&&!Number.isNaN(r.columnSpan)?r.columnSpan:typeof e.positionWidth=="number"?e.positionWidth:1,c=typeof r.rowSpan=="number"&&!Number.isNaN(r.rowSpan)?r.rowSpan:typeof e.positionRowSpan=="number"?e.positionRowSpan:1,u={order:s,column:i,columnSpan:a,rowSpan:c},f=r.cellGroupId??o.cellGroupId,l=Oo(r,{cellSlotIndex:e.cellSlotIndex??o.cellSlotIndex,stackSlot:n.stackSlot??o.stackSlot}),p=As(r)??As(o)??(n.stackDirection==="horizontal"||o.stackDirection==="horizontal"?"row":n.stackDirection==="vertical"||o.stackDirection==="vertical"?"stack":void 0);return typeof f=="string"&&(u.cellGroupId=f),typeof l=="number"&&(u.cellSlot=l),(p==="row"||p==="stack")&&(u.sharedCellLayout=p),u}function d_(e,t){const r=e,n=Es(r.metadata),o=oo(r.apidata),s=oo(r.properties),i=wg({},n,o,s),a=(r.name!=null&&String(r.name).trim()!==""?r.name:void 0)??(typeof r.fieldKey=="string"?r.fieldKey:void 0)??(typeof r.key=="string"?r.key:void 0),c=(r.type!=null&&String(r.type).trim()!==""?r.type:void 0)??(typeof r.fieldType=="string"?r.fieldType:void 0),u=l_(r,n),f=c_(r,t),l={...r};return l.properties=i,a!==void 0&&(l.name=a),c!==void 0&&(l.type=c),u!==void 0?l.appearance=u:(!hr(r.appearance)||Object.keys(r.appearance).length===0)&&delete l.appearance,l.position=f,hr(l.appearance)&&delete l.appearance.heightPercent,l}function u_(e,t){if(!e||typeof e!="object")return!0;const r=e,n=Es(r.metadata),o=Object.keys(n).length===0&&!(typeof r.metadata=="string"&&r.metadata.trim()!==""),s=!Sg(r);if(a_(r)||!o||!s)return!1;const i=r.position;return!(!(hr(i)&&typeof i.order=="number"&&!Number.isNaN(i.order))&&(typeof r.positionRow=="number"||typeof r.positionColumn=="number"||typeof r.positionWidth=="number"||typeof r.positionRowSpan=="number"||typeof r.positionOrder=="number")||hr(n.appearance)||xg.some(u=>n[u]!==void 0&&(r.appearance==null||hr(r.appearance)&&r.appearance[u]===void 0))||f_(r))}function f_(e){const t=oo(e.position),r=oo(e.layout),n=Es(e.metadata);return(typeof e.cellSlotIndex=="number"||typeof t.stackSlot=="number"||typeof t.cellSlot=="number"||typeof t.cellSlotIndex=="number"||typeof n.stackSlot=="number"||typeof r.stackSlot=="number")&&typeof t.cellSlot!="number"||(t.stackDirection==="horizontal"||t.stackDirection==="vertical"||n.stackDirection==="horizontal"||n.stackDirection==="vertical"||r.stackDirection==="horizontal"||r.stackDirection==="vertical")&&t.sharedCellLayout!=="row"&&t.sharedCellLayout!=="stack"}function da(e){if(e==null||typeof e!="object")return e;const t=e.fields;if(!Array.isArray(t))return e;let r=!1;const n=t.map((o,s)=>{if(u_(o))return o;const i=d_(o,s);return i!==o&&(r=!0),i});return r?{...e,fields:n}:e}function p_(e){return da(e)}function m_(e){const t=e.steps;if(!Array.isArray(t)||t.length<2)return;const r=[];for(const n of t){if(!n||typeof n!="object")continue;const o=n,s=typeof o.id=="string"&&o.id.trim()?o.id.trim():void 0,i=typeof o.name=="string"&&o.name.trim()?o.name.trim():void 0,a=Array.isArray(o.fields)?o.fields.filter(c=>typeof c=="string"&&c.trim()!==""):[];!s||!i||r.push({id:s,name:i,...typeof o.description=="string"&&o.description.trim()?{description:o.description.trim()}:{},fields:a,validation:o.validation==="onSubmit"?"onSubmit":"onNext"})}return r.length>=2?r:void 0}function kc(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Ag(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Cg(e,t){const r=e.form;if(!r)throw new Error("workflowStateToFormSchema requires workflowState.form to be set");const n=r.fields.filter(l=>l!=null&&l!==void 0).map((l,p)=>{if(!l||typeof l!="object")return null;const g={...l};if(l.fieldType&&!g.type&&(g.type=l.fieldType),l.fieldKey&&!g.key&&!g.name&&(g.key=l.fieldKey,g.name=l.fieldKey),typeof l.positionOrder=="number"&&!isNaN(l.positionOrder)?g.order=l.positionOrder:g.order=p,(typeof g.order!="number"||isNaN(g.order))&&(g.order=p),l.options&&typeof l.options=="string")try{g.options=JSON.parse(l.options)}catch{}if(l.metadata&&typeof l.metadata=="string")try{g.metadata=JSON.parse(l.metadata)}catch{}return g}).filter(l=>l!=null).sort((l,p)=>{const g=typeof l.order=="number"?l.order:0,m=typeof p.order=="number"?p.order:0;return g-m});n.forEach((l,p)=>{(!l||typeof l.order!="number"||isNaN(l.order))&&(l.order=p)});let o=r.layout;if(o){const l={...o};if(l.breakpoints&&typeof l.breakpoints=="string")try{l.breakpoints=JSON.parse(l.breakpoints)}catch{}if(l.responsiveConfig&&typeof l.responsiveConfig=="string")try{l.responsiveConfig=JSON.parse(l.responsiveConfig)}catch{}o=l}const s=n.filter(l=>l!=null&&typeof l=="object"&&typeof l.order=="number"&&!isNaN(l.order));let i={};const a=r.config;if(a!=null)if(typeof a=="string")try{i=JSON.parse(a)}catch{}else typeof a=="object"&&a!==null&&(i={...a});const c=l=>{let p={...l};if(l.conditionExpression&&typeof l.conditionExpression=="string")try{p={...l,conditionExpression:JSON.parse(l.conditionExpression)}}catch{}if(p.targetFieldId){const g=s.find(m=>m._id===p.targetFieldId||m.id===p.targetFieldId||m.fieldKey===p.targetFieldId);if(g){const m=g.key||g.fieldKey||g.name,h=g._id||g.id||p.targetFieldId;p.targetFieldKey=m,p.targetField=m,p.targetFieldById=h}}return p},u=m_(r),f={id:r._id,name:r.name,description:r.description??"",version:r.version,status:r.status,fields:s.map((l,p)=>{const g=l,m=typeof l.metadata=="object"&&l.metadata!==null?l.metadata:{},h=m.hidden===!0||l.hidden===!0,y={id:l._id||l.id||l.fieldKey,type:l.type||l.fieldType,label:l.label,key:l.key||l.fieldKey||l.name,name:l.name||l.fieldKey||l.key};if(h&&(y.hidden=!0),y.id||(y.id=y.key||y.name),y.key||(y.key=y.id||y.name),y.name||(y.name=y.key||y.id),l.isRequired!==void 0&&(y.required=l.isRequired),l.placeholder&&(y.placeholder=l.placeholder),l.options&&Array.isArray(l.options)&&(y.options=l.options),l.apidata&&(y.apidata=l.apidata),g.appearance&&typeof g.appearance=="object"&&!Array.isArray(g.appearance)&&Object.keys(g.appearance).length>0&&(y.appearance=kc(g.appearance)),g.ui!==void 0&&(y.ui=kc(g.ui)),g.visibility!==void 0&&(y.visibility=kc(g.visibility)),m.disabled!==void 0&&(y.disabled=m.disabled),m.readOnly!==void 0&&(y.readOnly=m.readOnly),m.hideLabel!==void 0&&(y.hideLabel=m.hideLabel,y.properties||(y.properties={}),y.properties.hideLabel=m.hideLabel,y.appearance||(y.appearance={}),y.appearance.hideLabel=m.hideLabel),(l.type==="file"||l.fieldType==="file"||l.type==="camera"||l.fieldType==="camera"||l.type==="photoChoice"||l.fieldType==="photoChoice")&&l.validationRules){const E=l.validationRules,C={...m};if(E.fileSize!==void 0&&(C.maxSize=E.fileSize),E.fileType&&Array.isArray(E.fileType)){const I=[];E.fileType.forEach(W=>{const M=W.startsWith(".")?W:`.${W}`;I.push(M),M===".csv"?I.push("text/csv"):M===".xls"?I.push("application/vnd.ms-excel"):M===".xlsx"&&I.push("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}),C.accept=I}y.metadata=C,C.maxSize!==void 0&&(y.maxSize=C.maxSize),C.accept!==void 0&&(y.accept=C.accept)}else if(m&&Object.keys(m).length>0){if(y.metadata=m,(l.type==="toggle"||l.fieldType==="toggle")&&(m.onValue!==void 0&&(y.onValue=m.onValue),m.offValue!==void 0&&(y.offValue=m.offValue),m.onText!==void 0&&(y.onText=m.onText),m.offText!==void 0&&(y.offText=m.offText)),(l.type==="button"||l.fieldType==="button")&&m.action==="download"&&m.downloadApiEndpoint&&typeof m.downloadApiEndpoint=="string"){let E=m.downloadApiEndpoint;E=E.replace(/\{ctx:([^}]+)\}/g,(C,I)=>{const W=t[I];return W!==void 0?String(W):C}),m.downloadApiEndpoint=E,y.metadata=m,y.downloadApiEndpoint=E}if((l.type==="button"||l.fieldType==="button")&&m.action==="submit"){const E=y.properties||{};m.submitAction!==void 0&&(E.submitAction=m.submitAction),m.submitApiMethod!==void 0&&(E.submitApiMethod=m.submitApiMethod),m.apiBodyStructure!==void 0&&(E.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(E.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(E.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiBodyFields!==void 0&&(E.apiBodyFields=m.apiBodyFields),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.action!==void 0&&(E.action=m.action),m.variant!==void 0&&(E.variant=m.variant),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint&&(E.apiEndpoint=l.apidata.apiEndpoint),y.properties=E}if((l.type==="button"||l.fieldType==="button")&&(m.action==="upload"||m.action==="custom")){const E=y.properties||{};m.action!==void 0&&(E.action=m.action),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.variant!==void 0&&(E.variant=m.variant),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),m.uploadAction!==void 0&&(E.uploadAction=m.uploadAction),m.uploadApiEndpoint!==void 0&&(E.uploadApiEndpoint=m.uploadApiEndpoint),m.uploadApiMethod!==void 0&&(E.uploadApiMethod=m.uploadApiMethod),m.apiBodyStructure!==void 0&&(E.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(E.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(E.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiFieldMapping!==void 0&&(E.apiFieldMapping=m.apiFieldMapping),m.apiQueryParams!==void 0&&(E.apiQueryParams=m.apiQueryParams),m.apiBodyFields!==void 0&&(E.apiBodyFields=m.apiBodyFields),m.apiHeaders!==void 0&&(E.apiHeaders=m.apiHeaders),y.properties=E}if(l.type==="status"||l.fieldType==="status"){const E=y.properties||{};if(m.source!==void 0&&(E.source=m.source),m.statuses!==void 0&&(E.statuses=m.statuses),m.dataPath!==void 0&&(E.dataPath=m.dataPath),m.showStatusText!==void 0&&(E.showStatusText=m.showStatusText),m.statusTextPath!==void 0&&(E.statusTextPath=m.statusTextPath),m.showCurrentIndicator!==void 0&&(E.showCurrentIndicator=m.showCurrentIndicator),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint){let C=l.apidata.apiEndpoint;C=C.replace(/\{ctx:([^}]+)\}/g,(I,W)=>{const M=t[W];return M!==void 0?String(M):I}),E.apiEndpoint=C,E.source===void 0&&(E.source="api")}l.apidata?.apiMethod!==void 0&&(E.apiMethod=l.apidata.apiMethod),y.properties=E}if(l.type==="addmore"||l.fieldType==="addmore"){const E=y.properties||{};m.linkedFieldNames!==void 0&&(E.linkedFieldNames=m.linkedFieldNames),m.linkedSectionIds!==void 0&&(E.linkedSectionIds=m.linkedSectionIds),m.linkedFieldAllowDuplicate!==void 0&&(E.linkedFieldAllowDuplicate=m.linkedFieldAllowDuplicate),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.variant!==void 0&&(E.variant=m.variant),m.size!==void 0&&(E.size=m.size),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),y.properties=E}if(l.type==="selectablelist"||l.fieldType==="selectablelist"){const E=y.properties||{};m.submitFieldMapping!==void 0&&(E.submitFieldMapping=m.submitFieldMapping),m.displayFields!==void 0&&(E.displayFields=m.displayFields),m.displayFieldsSeparator!==void 0&&(E.displayFieldsSeparator=m.displayFieldsSeparator),m.dataSourceContextKey!==void 0&&(E.dataSourceContextKey=m.dataSourceContextKey),m.showSelectAll!==void 0&&(E.showSelectAll=m.showSelectAll),m.selectAllByDefault!==void 0&&(E.selectAllByDefault=m.selectAllByDefault),y.properties=E}}l.validationRules&&l.type!=="file"&&l.fieldType!=="file"&&l.type!=="camera"&&l.fieldType!=="camera"&&l.type!=="photoChoice"&&l.fieldType!=="photoChoice"&&l.type!=="status"&&l.fieldType!=="status"&&(y.validationRules=l.validationRules),typeof l.order=="number"&&(y.order=l.order);const S=l,w=Ag(S.position),A=l.metadata&&typeof l.metadata=="object"&&!Array.isArray(l.metadata)?l.metadata:{},x=Ag(S.layout),N={order:typeof S.positionOrder=="number"?S.positionOrder:l.order??p,column:typeof w.column=="number"?w.column:typeof S.positionColumn=="number"?S.positionColumn:1,columnSpan:typeof w.columnSpan=="number"?w.columnSpan:typeof w.width=="number"?w.width:typeof S.positionWidth=="number"?S.positionWidth:1,rowSpan:typeof w.rowSpan=="number"?w.rowSpan:typeof S.positionRowSpan=="number"?S.positionRowSpan:1},k=Oo(w,{cellSlotIndex:S.cellSlotIndex??x.cellSlotIndex,stackSlot:A.stackSlot??x.stackSlot});typeof k=="number"&&(N.cellSlot=k);const T=w.cellGroupId??x.cellGroupId;typeof T=="string"&&(N.cellGroupId=T);const P=As(w)??As(x)??(A.stackDirection==="horizontal"||x.stackDirection==="horizontal"?"row":A.stackDirection==="vertical"||x.stackDirection==="vertical"?"stack":void 0);return(P==="row"||P==="stack")&&(N.sharedCellLayout=P),y.position=N,l.conditions&&Array.isArray(l.conditions)&&(y.conditions=l.conditions),y}).filter(l=>l!=null).sort((l,p)=>{const g=typeof l.order=="number"?l.order:0,m=typeof p.order=="number"?p.order:0;return g-m}),config:{...i,layout:o,...r.rules&&r.rules.length>0&&{rules:r.rules.map(c)},...r.clientMapping&&Object.keys(r.clientMapping).length>0&&{clientMapping:r.clientMapping}},...r.rules&&r.rules.length>0&&{rules:r.rules.map(c)},createdAt:"",updatedAt:"",moduleId:"",...u?{steps:u}:{}};return da(f)}function wn({className:e,size:t="md",text:r="Loading...",fullScreen:n=!1}){const o={sm:"h-6 w-6",md:"h-12 w-12",lg:"h-16 w-16"},s=d.jsxs("div",{className:"text-center",children:[d.jsx("div",{className:H("animate-spin rounded-full border-b-2 border-blue-600 mx-auto mb-4",o[t],e)}),r&&d.jsx("p",{className:"text-gray-600",children:r})]});return n?d.jsx("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50 flex items-center justify-center",children:s}):s}function h_(e,t){if(!e?.url)return;let r=e.url;if(r.startsWith("http://")||r.startsWith("https://"))try{const s=new URL(r);r=s.pathname+s.search}catch{}const n=t?.()??{},o={...e.headers||{},"Content-Type":"application/json",...n};return{...e,url:r,headers:o}}const Eg=({open:e,onOpenChange:t,title:r,mode:n,loading:o=!1,workflowState:s,formSchema:i,formDefinitionId:a,submissionContext:c={},onWorkflowSubmitResult:u,getAuthHeaders:f})=>{const l=v.useMemo(()=>{if(n==="form"&&i)return i;if(n==="workflow"&&s?.form){const g=Object.fromEntries(Object.entries(c).map(([y,S])=>[y,S==null?"":String(S)])),m=Cg(s,g),h=h_(s.BFF_submit_api,f);return h?{...m,status:"published",BFF_submit_api:h}:m}return null},[n,i,s,c,f]),p=s?.step_blocked_message;return d.jsx(lg,{open:e,onOpenChange:t,children:d.jsxs(cg,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[r?d.jsx(dg,{children:d.jsx(ug,{children:r})}):null,d.jsxs("div",{className:"relative min-h-[12rem]",children:[o&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:d.jsx(wn,{})}),p&&d.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:p}),l?d.jsx(il,{children:d.jsx(Ms,{schema:l,submissionContext:c,onWorkflowSubmitResult:u,onClose:()=>t(!1),workflowStepId:s?.current_step_id,omitRootWrapper:!0})}):a&&n==="form"?d.jsx(il,{children:d.jsx(Ms,{formId:a,submissionContext:c,onClose:()=>t(!1),omitRootWrapper:!0})}):!o&&d.jsx("p",{className:"text-sm text-muted-foreground",children:n==="workflow"?"No form available for this step.":"Form could not be loaded."})]})]})})},Ng=v.createContext(null);function kg(){return v.useContext(Ng)}function _c(e,t){if(!e?.length||!t)return{};const r={};return e.forEach(n=>{t[n]!==void 0&&(r[n]=t[n])}),r}const _g=({handlers:e,moduleId:t,submissionContext:r={},getAuthHeaders:n,onParentWorkflowSubmitResult:o,children:s})=>{const[i,a]=v.useState(!1),[c,u]=v.useState(),[f,l]=v.useState("workflow"),[p,g]=v.useState(null),[m,h]=v.useState(null),[y,S]=v.useState(),[w,A]=v.useState({}),[x,F]=v.useState(!1),N=v.useMemo(()=>({...r,...w}),[r,w]),k=v.useCallback(()=>{a(!1),g(null),h(null),S(void 0),A({})},[]),T=v.useCallback(async(W,M)=>{if(!W.workflowId?.trim())throw new Error("workflowId is required for openWorkflowModal");const z=_c(W.passFields,M);F(!0),u(W.modalTitle),l("workflow"),A(z);try{const V=await e.getWorkflowStateById({workflowId:W.workflowId.trim(),moduleId:t,entryStepId:W.entryStepId?.trim()||void 0,passContext:z});g(V),h(null),S(void 0),a(!0)}finally{F(!1)}},[e,t]),P=v.useCallback(async(W,M)=>{if(!W.formDefinitionId?.trim())throw new Error("formDefinitionId is required for openFormModal");const z=_c(W.passFields,M);F(!0),u(W.modalTitle),l("form"),A(z),g(null);try{if(e.getFormSchemaById){const V=await e.getFormSchemaById(W.formDefinitionId.trim());h(V),S(void 0)}else h(null),S(W.formDefinitionId.trim());a(!0)}finally{F(!1)}},[e]),E=v.useCallback(async(W,M)=>{const z=M?.workflowId?.trim()||p?.workflow_id||"";if(!z||!W?.trim())throw new Error("workflowId and targetStepId are required for gotoStep");const V={...w,..._c(void 0,M?.formValues)};F(!0);try{const X=await e.navigateWorkflowStep({workflowId:z,moduleId:t,targetStepId:W.trim(),passContext:V});i?(g(X),l("workflow"),h(null),S(void 0)):o?.(X)}finally{F(!1)}},[e,t,w,i,p?.workflow_id,o]),C=v.useCallback(async W=>{o?.(W);const M=p?.workflow_id;if(M)try{const z=await e.getWorkflowStateById({workflowId:M,moduleId:t,passContext:w});g(z)}catch{}},[e,t,w,o,p?.workflow_id]),I=v.useMemo(()=>({isModalActive:i,openWorkflowModal:T,openFormModal:P,navigateToStep:E}),[i,T,P,E]);return d.jsxs(Ng.Provider,{value:I,children:[s,d.jsx(Eg,{open:i,onOpenChange:W=>{W||k()},title:c,mode:f,loading:x,workflowState:p,formSchema:m,formDefinitionId:y,submissionContext:N,onWorkflowSubmitResult:C,getAuthHeaders:n})]})};function Tc(e,t){if(!t?.length)return e;const r=new Map;for(const o of t){const s=o.name||o.key||o.id;s&&r.set(s,o)}const n={};for(const[o,s]of Object.entries(e)){const i=r.get(o);if(i?.type==="selectablelist"&&Array.isArray(s)&&s.length>0){const a=i.properties,c=i.metadata,u=typeof c=="object"&&c!==null?c:null,f=a?.submitFieldMapping??u?.submitFieldMapping;if(f&&typeof f=="object"&&Object.keys(f).length>0){const l=s.map(p=>{if(p==null||typeof p!="object")return p;const g={};for(const[m,h]of Object.entries(f))m!=null&&m!==""&&h!=null&&h!==""&&(g[m]=Re(p,h));return g});n[o]=l;continue}}n[o]=s}return n}function ua(e){return!!(e instanceof File||Array.isArray(e)&&e.length>0&&e[0]instanceof File)}function g_(e){return Object.values(e).some(t=>ua(t))}function y_(e,t){const r=new FormData;let n=!1;return Object.entries(e).forEach(([o,s])=>{const i=t?.[o]||o;s instanceof File?(r.append(i,s),n=!0):Array.isArray(s)&&s.length>0&&s[0]instanceof File?(s.forEach(a=>{r.append(i,a)}),n=!0):s!=null&&(typeof s=="object"?r.append(i,JSON.stringify(s)):r.append(i,String(s)))}),n?r:null}function b_(e,t,r){const n={};let o=!1;return Object.entries(e).forEach(([s,i])=>{const a=t?.[s]||s;if(ua(i)){n[a]=i,o=!0;return}const c=r?.[s]||"string";let u=i;if(c==="number"){const f=Number(i);u=isNaN(f)?i:f}else c==="boolean"?u=i==="true"||i===!0||i==="1"||i===1:c==="date"?u=String(i):i!=null?u=typeof i=="object"?i:String(i):u="";n[a]=u}),{transformed:n,hasFiles:o}}const Tg=Object.freeze(Object.defineProperty({__proto__:null,hasFileValues:g_,isFileValue:ua,prepareFormDataWithFiles:y_,transformFormValuesWithFiles:b_},Symbol.toStringTag,{value:"Module"}));function v_(e){if(!e||typeof e!="object")return;const t=e;return(t.mode==="nested_by_section"?"nested_by_section":"flat")==="flat"?{mode:"flat"}:{mode:"nested_by_section",includeUnassignedAtRoot:t.includeUnassignedAtRoot!==!1}}function w_(e){if(!Array.isArray(e))return;const t=[];for(const r of e){if(!r||typeof r!="object")continue;const n=r,o=typeof n.id=="string"&&n.id.trim()?n.id.trim():"",s=typeof n.name=="string"&&n.name.trim()?n.name.trim():"";if(!o||!s)continue;const i=Array.isArray(n.fieldNames)?[...new Set(n.fieldNames.filter(u=>typeof u=="string"&&u.trim().length>0).map(u=>u.trim()))]:[],a=typeof n.payloadKey=="string"&&n.payloadKey.trim()?n.payloadKey.trim():void 0;let c;if(n.fieldPayloadKeys&&typeof n.fieldPayloadKeys=="object"&&!Array.isArray(n.fieldPayloadKeys)){c={};for(const[u,f]of Object.entries(n.fieldPayloadKeys))typeof f=="string"&&f.trim()&&(c[u]=f.trim());Object.keys(c).length===0&&(c=void 0)}t.push({id:o,name:s,fieldNames:i,...n.showBorder===!0?{showBorder:!0}:{},...n.collapsible===!0?{collapsible:!0}:{},...n.defaultCollapsed===!0?{defaultCollapsed:!0}:{},...a?{payloadKey:a}:{},...c?{fieldPayloadKeys:c}:{},...n.heading&&typeof n.heading=="object"?{heading:n.heading}:{}})}return t.length>0?t:void 0}function Fg(e){return e?.mode==="nested_by_section"}function Pg(e){const t=e.payloadKey?.trim();return t||null}function Og(e,t){return t.fieldPayloadKeys?.[e]?.trim()||e}function Ig(e,t,r,n){if(!Fg(r)||!t?.length)return{...e};const o=new Set([]),s=r?.includeUnassignedAtRoot!==!1,i=new Set,a={};for(const c of t){const u=Pg(c);if(!u)continue;const f={};for(const l of c.fieldNames){if(o.has(l)||!(l in e))continue;i.add(l);const p=Og(l,c);f[p]=e[l]}Object.keys(f).length>0&&(a[u]=f)}if(s)for(const[c,u]of Object.entries(e))o.has(c)||i.has(c)||(a[c]=u);return a}function S_(e,t,r){const n={...e??{}};if(!Fg(r)||!t?.length)return n;for(const o of t){const s=Pg(o);if(s)for(const i of o.fieldNames){if(n[i]?.trim())continue;const a=Og(i,o);n[i]=`${s}.${a}`}}return n}function x_(e){return e==="null"?null:e==="true"?!0:e==="false"?!1:e}function A_(e){const t=e,r=typeof t?.status=="string"?t.status.toLowerCase():null;if(r&&r!=="success")return!1;const n=t?.code;return!(typeof n=="number"&&(n<200||n>=300))}function C_(e,t){if(!t)return[];const r=e.trim().split(".");if(r.length<2)return[];const n=r[0],o=r.slice(1).join("."),s=[];return Object.entries(t).forEach(([i,a])=>{const c=i===n,u=i.startsWith(`${n}__addmore__`);if(!c&&!u||!A_(a))return;const f=Re(a,o);f==null||f===""||s.push(f)}),s}function Fc(e,t,r){return VE({apiAuth:e?.apiAuth??t?.apiAuth,apiHeaders:e?.apiHeaders??t?.apiHeaders},{formValues:r.formValues,submissionContext:r.submissionContext})}function Mg(e,t,r){Object.entries(t).forEach(([n,o])=>{n.toLowerCase()==="content-type"&&r instanceof FormData||(e[n]=o)})}function fa(e,t,r,n,o,s){const i=e.trim().match(/^\{respAll:([^}]+)\}$/);if(i){const u=(i[1]||"").trim(),f=u.split("."),l=f.length>=2?f.slice(1).join("."):"";return(l==="data.id"||l==="data.documentId")&&n?.document_ids!=null&&Array.isArray(n.document_ids)?n.document_ids:C_(u,o)}const a=e.trim().match(/^\{(\w+)\}$/);if(a){const u=a[1],f=t[u];if(f!==void 0)return f;const l=Object.keys(t).find(p=>p.toLowerCase()===u.toLowerCase());if(l)return t[l]}const c=Rr(e,t,r,n,o,s);return x_(String(c))}const E_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,onClick:u,onSubmit:f,onReset:l,onCancel:p,isSubmitting:g=!1,formValues:m={},submissionContext:h,bffSubmitApi:y,onBffSubmitResult:S,extraSubmitPayload:w,buttonResponses:A,onButtonApiResponse:x,onValidateForm:F,getValidationErrors:N,allFields:k,onSubmittingChange:T,scopedFormValues:P,scopedFieldNameMap:E,prepopulateResponse:C=null,formSections:I,submitPayload:W})=>{const{gridStretch:M}=Jo(),z=kg(),V=ri(),[X,D]=v.useState(!1),B=e.properties,L=Ba.useParams(),K=v.useMemo(()=>({...h,...w}),[h,w]),ie=v.useMemo(()=>{if(!P||!E||Object.keys(E).length===0)return m;const Xe={};return Object.entries(P).forEach(([ve,ce])=>{const J=E[ve]||ve;J!==e.name&&(Xe[J]=ce)}),Xe},[P,E,m,e.name]),U=(()=>{try{const Xe=e.metadata;if(typeof Xe=="string")return JSON.parse(Xe);if(Xe&&typeof Xe=="object")return Xe}catch{}return null})(),le=B?.submitAction??U?.submitAction,oe=B?.apiEndpoint??e.apidata?.apiEndpoint??U?.apiEndpoint;let G=B?.action||U?.action;!G&&e.type==="button"&&(G="submit");const ae=B?.variant||"default",Ae=B?.size||"default",ee=B?.hideLabel??e.appearance?.hideLabel??!1,ne=B?.buttonText||e.label||"Button",he=B?.closeOnCancel??!0,Ie=async()=>{if(P&&E&&Object.keys(E).length>0||!F)return!0;const Xe=await F();if(!Xe&&N)try{const ve=N();ct.toast.error(la(ve,k??void 0)||"Please fix the errors before submitting.")}catch{ct.toast.error("Please fix the errors before submitting.")}return Xe},Ue=async Xe=>{Xe.preventDefault();const ve=G==="submit"?"submit":G;if(G==="next"){await Ec(k??void 0,V);return}if(G==="prev"){e_(V);return}if(G==="saveAndNext"){if(!(B?.uploadApiEndpoint||U?.uploadApiEndpoint||e.uploadApiEndpoint)?.trim()){ct.toast.error("API endpoint is not configured for Save & Next.");return}if(!await Ie())return;D(!0);try{const J=await Se();x?.(e.name,J),gg(J)||mg(J,"Saved successfully."),await Ec(k??void 0,V)}catch(J){x?.(e.name,{status:"error",code:J?.response?.code??J?.response?.status??null,message:Gr(J)}),ia(J,"Failed to save. Please check the API endpoint and try again.",Gr)}finally{D(!1)}return}if(G==="openWorkflowModal"){const ce=B?.workflowId??U?.workflowId;if(!z){ct.toast.error("Workflow modal is not configured for this form.");return}if(!ce?.trim()){ct.toast.error("Workflow is not configured for this button.");return}D(!0);try{await z.openWorkflowModal({workflowId:ce.trim(),entryStepId:B?.entryStepId??U?.entryStepId,modalTitle:B?.modalTitle??U?.modalTitle??e.label,passFields:B?.passFields??U?.passFields},ie)}catch(J){ct.toast.error(Gr(J))}finally{D(!1)}return}if(G==="openFormModal"){const ce=B?.formDefinitionId??U?.formDefinitionId;if(!z){ct.toast.error("Form modal is not configured for this form.");return}if(!ce?.trim()){ct.toast.error("Form is not configured for this button.");return}D(!0);try{await z.openFormModal({formDefinitionId:ce.trim(),modalTitle:B?.modalTitle??U?.modalTitle??e.label,passFields:B?.passFields??U?.passFields},ie)}catch(J){ct.toast.error(Gr(J))}finally{D(!1)}return}if(G==="gotoStep"){const ce=B?.targetStepId??U?.targetStepId;if(!z){ct.toast.error("Step navigation is not configured for this form.");return}if(!ce?.trim()){ct.toast.error("Target step is not configured for this button.");return}const J=B?.workflowId??U?.workflowId??y?.payload?.workflow_id;D(!0);try{await z.navigateToStep(ce.trim(),{workflowId:typeof J=="string"?J:void 0,formValues:ie})}catch($){ct.toast.error(Gr($))}finally{D(!1)}return}if(ve==="submit"){if(Zk(V)){await Ec(k??void 0,V);return}if(y?.url){if(!await Ie())return;D(!0),T?.(!0);try{const ce=await ge(),J=(ce?.message??ce?.display_message??"Form submitted successfully!").trim();ct.toast.success(J||"Form submitted successfully!");const $=ce!=null&&typeof ce=="object"?ce:{status:"success",...ce!=null?{data:ce}:{}};x?.(e.name,$)}catch(ce){const J=Gr(ce);ct.toast.error(J)}finally{D(!1),T?.(!1)}return}if(f){if(!await Ie())return;D(!0),T?.(!0);try{await f(),x?.(e.name,{status:"success"})}finally{D(!1),T?.(!1)}return}ct.toast.error("Submit not configured. BFF submit API is required for submit buttons.");return}else if(G==="reset"&&l)l();else if(G==="cancel")he?p&&p():l&&l();else if(G==="download"){const ce=B?.downloadApiEndpoint||U?.downloadApiEndpoint||e.downloadApiEndpoint,J=B?.downloadApiMethod||U?.downloadApiMethod||e.downloadApiMethod;if(ce){D(!0);try{const $=J||"GET",fe=Mr(Rr(ce,ie,L,K,A,C??void 0)),st={method:$,headers:{}};$!=="GET"&&$!=="DELETE"&&(st.headers={"Content-Type":"application/json"}),Mg(st.headers,Fc(B,U,{formValues:ie,urlParams:L,submissionContext:K}));const Te=await fetch(fe,st);if(!Te.ok)throw new Error(`Download failed: ${Te.statusText}`);const Ye=await Te.blob(),Me=window.URL.createObjectURL(Ye),Ce=document.createElement("a");Ce.href=Me;const nt=Te.headers.get("Content-Disposition");let qe="download";if(nt){const dt=nt.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);dt&&dt[1]&&(qe=dt[1].replace(/['"]/g,""))}Ce.download=qe,document.body.appendChild(Ce),Ce.click(),document.body.removeChild(Ce),window.URL.revokeObjectURL(Me);try{const dt=Xk(Te);ct.toast.success(dt&&dt.trim()?dt:"Download started.")}catch{ct.toast.success("Download started.")}}catch($){ia($,"Failed to download file. Please check the API endpoint and try again.",Gr)}finally{D(!1)}}else ct.toast.error("Download endpoint is not configured")}else if(G==="upload"||G==="custom"){const ce=G==="custom",J=ce?"api":B?.uploadAction||U?.uploadAction||"database";if(J==="database")if(f){D(!0);try{await f(Xe)}catch($){throw $}finally{D(!1)}}else ct.toast.error("Form submit handler is not available");else if(J==="api"){const $=B?.uploadApiEndpoint||U?.uploadApiEndpoint||e.uploadApiEndpoint;if(B?.uploadApiMethod||U?.uploadApiMethod||e.uploadApiMethod,$){if(!await Ie())return;D(!0);try{const fe=await Se();x?.(e.name,fe),mg(fe,ce?"Custom API call completed successfully!":"Upload completed successfully!")}catch(fe){x?.(e.name,{status:"error",code:fe?.response?.code??fe?.response?.status??null,message:Gr(fe)}),ia(fe,ce?"Failed to call custom API. Please check the API endpoint and try again.":"Failed to upload. Please check the API endpoint and try again.",Gr)}finally{D(!1)}}else ct.toast.error(ce?"Custom API endpoint is not configured":"Upload endpoint is not configured")}else J==="custom"&&ct.toast.info("Custom upload handler is not implemented")}else u?u():r&&t!==void 0&&r(t||"");n?.()},re=async()=>{if(!le||le!=="api"||!oe)return null;const Xe=B?.apiBodyFields??U?.apiBodyFields;if((B?.apiBodyFieldsOnly??U?.apiBodyFieldsOnly??!1)&&Xe?.length){const Ce={};return Xe.forEach(({key:nt,value:qe})=>{const dt=fa(qe,ie,L,K,A,C??void 0),bt=nt==="user_id"?"context_user_id":nt;Ce[bt]=dt}),Ce.user_id!==void 0&&Ce.user_id!==null&&(Ce.context_user_id=Ce.context_user_id??Ce.user_id,delete Ce.user_id),Ce}const ce=k?.length?Tc(ie,k):ie,J=B?.apiFieldMapping??U?.apiFieldMapping,$=B?.apiFieldTypes??U?.apiFieldTypes,fe=B?.apiBodyStructure??U?.apiBodyStructure,st={...$};k?.length&&k.forEach(Ce=>{const nt=Ce.name||Ce.key;nt&&(Ce.type==="terms"||Ce.type==="checkbox")&&(st[nt]="boolean")});const{transformFormValuesWithFiles:Te}=await Promise.resolve().then(()=>Tg),{transformed:Ye}=Te(ce,J,st);let Me={};if(fe==="flat"?Me={...Ye}:Me={data:{...Ye}},J){const Ce={};Object.keys(Me).forEach(nt=>{const qe=J[nt]||nt;Ce[qe]=Me[nt]}),Me=Ce}return Xe?.length&&Xe.forEach(({key:Ce,value:nt})=>{const qe=fa(nt,ie,L,K,A,C??void 0),dt=Ce==="user_id"?"context_user_id":Ce;Me[dt]=qe}),Me.user_id!==void 0&&Me.user_id!==null&&(Me.context_user_id=Me.context_user_id??Me.user_id,delete Me.user_id),Me.data?.user_id!==void 0&&Me.data?.user_id!==null&&(Me.data.context_user_id=Me.data.context_user_id??Me.data.user_id,delete Me.data.user_id),Me},ge=async()=>{if(!y||!y.url)throw new Error("BFF submit API configuration is missing");const Xe=k?.length?Tc(m,k):m,ve={};Object.keys(Xe).forEach($e=>{const gt=e.name===$e&&e.type==="button",vt=$e.toLowerCase().includes("button");!gt&&!vt&&(ve[$e]=Xe[$e])});const ce=Object.keys(ve).filter($e=>ua(ve[$e]));ce.forEach($e=>{ve[$e]=""});const J=Ig(ve,I,W),$={workflow_id:y.payload?.workflow_id||"",current_step_id:y.payload?.current_step_id||"",form_data:J},fe=y.payload?.context_user_id??y.payload?.user_id;fe!=null&&String(fe).trim()!==""&&($.context_user_id=String(fe).trim());const st=["workflow_id","current_step_id","form_data","submit_body","submit_api_endpoint","submit_api_method"];if(h&&typeof h=="object"&&Object.entries(h).forEach(([$e,gt])=>{if(gt==null||st.includes($e))return;const vt=$e==="user_id"?"context_user_id":$e;$[vt]=$[vt]??gt}),w&&typeof w=="object"&&Object.entries(w).forEach(([$e,gt])=>{if(gt==null||st.includes($e))return;const vt=$e==="user_id"?"context_user_id":$e;$[vt]=$[vt]??gt}),le==="api"&&oe)try{const $e=await re();if($e){const gt=B?.apiBodyStructure??U?.apiBodyStructure,vt=B?.apiFieldMapping??U?.apiFieldMapping;ce.forEach(ir=>{const Er=vt?.[ir]??ir,Et=ve[ir]!==void 0&&typeof ve[ir]=="string"?ve[ir]:"";gt==="flat"?$e[Er]=Et:$e.data&&typeof $e.data=="object"?$e.data[Er]=Et:$e[Er]=Et}),$.submit_body=$e;let _t=Rr(oe,ie,L,K,A,C??void 0);_t=_t.replace(/\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}/gi,"$1"),_t=Mr(_t),$.submit_api_endpoint=_t,$.submit_api_method=B?.submitApiMethod||U?.submitApiMethod||"POST";const yr=Fc(B,U,{formValues:ie,urlParams:L,submissionContext:K});Object.keys(yr).length>0&&($.submit_api_headers=yr)}}catch{}const Te=(y.method||"POST").toUpperCase(),Ye=ce.length>0,Me=$.submit_api_endpoint??oe??"",Ce=typeof Me=="string"?Me.toLowerCase():"",nt=Ce.includes("/upload")||Ce.includes("/payments")||Ce.includes("/bulk-upload"),qe=Ye&&nt;let dt;const bt={...y.headers||{}};if(qe){const $e=new FormData;$e.append("payload",JSON.stringify($));for(const gt of ce){const vt=Xe[gt],_t=B?.apiFieldMapping?.[gt]??gt;vt instanceof File?$e.append(_t,vt):Array.isArray(vt)&&vt.length>0&&vt[0]instanceof File&&vt.forEach(yr=>$e.append(_t,yr))}dt=$e,delete bt["content-type"],delete bt["Content-Type"]}else bt["Content-Type"]="application/json",dt=JSON.stringify($);const sr=await fetch(y.url,{method:Te,headers:bt,body:dt});if(!sr.ok){let $e;const gt=await sr.text();try{$e=JSON.parse(gt)}catch{$e={message:gt}}const vt=new Error(`BFF submission failed: ${sr.status}`);throw vt.response=$e,vt}const xt=await sr.json();return S?.(xt),f&&await f(),xt},Se=async()=>{const Xe=B?.uploadApiEndpoint||U?.uploadApiEndpoint;if(!Xe)throw new Error("Upload API endpoint is not configured");if(!B)throw new Error("Button properties are not configured");const ve=(B.uploadApiMethod||"POST").toUpperCase(),ce=Mr(Rr(Xe,ie,L,K,A,C??void 0)),J=B.apiBodyFieldsOnly??U?.apiBodyFieldsOnly??!1,$=B.apiBodyFieldsOnlyFormat??U?.apiBodyFieldsOnlyFormat??"json";let fe={},st;const Te={};if(J&&B.apiBodyFields&&B.apiBodyFields.length>0)if(B.apiBodyFields.forEach(({key:Ce,value:nt})=>{fe[Ce]=fa(nt,ie,L,K,A,C??void 0)}),$==="multipart"){const Ce=new FormData;Object.entries(fe).forEach(([nt,qe])=>{if(qe instanceof File){Ce.append(nt,qe);return}if(Array.isArray(qe)&&qe.length>0&&qe[0]instanceof File){qe.forEach(dt=>Ce.append(nt,dt));return}qe!=null&&Ce.append(nt,typeof qe=="object"?JSON.stringify(qe):String(qe))}),st=Ce}else st=JSON.stringify(fe),Te["Content-Type"]="application/json";else{const Ce=ie,{transformFormValuesWithFiles:nt,prepareFormDataWithFiles:qe,hasFileValues:dt}=await Promise.resolve().then(()=>Tg),{transformed:bt,hasFiles:sr}=nt(Ce,B.apiFieldMapping,B.apiFieldTypes);if((B.apiBodyStructure??U?.apiBodyStructure??"nested")==="flat"?fe={...bt}:fe={data:{...bt}},B.apiFieldMapping){const $e={};Object.keys(fe).forEach(gt=>{const vt=B.apiFieldMapping[gt]||gt;$e[vt]=fe[gt]}),fe=$e}if(B.apiBodyFields&&B.apiBodyFields.forEach(({key:$e,value:gt})=>{fe[$e]=fa(gt,ie,L,K,A,C??void 0)}),sr||dt(fe)){const $e=qe(fe,B.apiFieldMapping);$e?st=$e:(st=JSON.stringify(fe),Te["Content-Type"]="application/json")}else st=JSON.stringify(fe),Te["Content-Type"]="application/json"}Mg(Te,Fc(B,U,{formValues:ie,submissionContext:K}),st);let Ye=ce;if(B.apiQueryParams&&B.apiQueryParams.length>0){const Ce=new URLSearchParams;B.apiQueryParams.forEach(({key:nt,value:qe})=>{const dt=Rr(qe,ie,L,K,A,C??void 0);Ce.append(nt,dt)}),Ye=`${ce}?${Ce.toString()}`}const Me=await fetch(Ye,{method:ve,headers:Te,body:ve!=="GET"?st:void 0});if(!Me.ok){let Ce;const nt=await Me.text();try{Ce=JSON.parse(nt)}catch{Ce={message:nt}}const qe=new Error(`Upload failed: ${Me.status}`);throw qe.response=Ce,qe}try{return await Me.json()}catch{return{}}},pt=G==="submit"?"submit":G,Bt=pt==="submit"?"button":pt==="submit"?"submit":pt==="reset"?"reset":"button",Ot=s||e.disabled||i||e.readOnly||X||pt==="submit"&&g,Ar=ne,kt=fo(e),Cr=Fr(e.appearance)==="stretch";return d.jsx(At,{field:e,error:o,isRequired:a,className:c,hideLabel:ee,children:d.jsx("div",{className:H(M&&!kt&&"flex w-full min-w-0 flex-col",M&&kt&&"min-w-0 shrink-0"),children:d.jsxs(Zt,{id:ft(e),type:Bt,variant:ae,size:Ae,disabled:Ot,onClick:Ue,className:H(e.appearance?.className,M&&!kt&&"w-full min-w-0 shrink-0",M&&kt&&!Cr&&"inline-flex w-auto max-w-full shrink-0",M&&kt&&Cr&&"inline-flex w-full min-w-0 max-w-full shrink-0"),children:[X&&d.jsx("span",{className:"inline-block h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent mr-2","aria-hidden":!0}),Ar]})})})},N_=({field:e,disabled:t,readOnly:r,isRequired:n,className:o,buttonResponses:s,onButtonApiResponse:i})=>{const a=e.properties,c=a?.buttonText??e.label??"Edit",u=a?.variant??"outline",f=a?.size??"default",l=a?.hideLabel??e.appearance?.hideLabel??!1,p=e.name||e.key||e.id,g=Qo(s?.[p]),m=t||e.disabled||r||e.readOnly||g,h=y=>{y.preventDefault(),!m&&i?.(p,{status:"success"})};return d.jsx(At,{field:e,error:void 0,isRequired:n,className:o,hideLabel:l,children:d.jsx(Zt,{id:ft(e),type:"button",variant:u,size:f,disabled:m,onClick:h,className:H(e.appearance?.className,(!fo(e)||Fr(e.appearance)==="stretch")&&"w-full min-w-0"),children:c})})},k_=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,onAddMore:i})=>{const a=e.properties||{},c=a.variant||"outline",u=a.size||"default",f=a.buttonText||e.label||"Add More",l=a.hideLabel??e.appearance?.hideLabel??!1,p=r||n||e.disabled||e.readOnly;return d.jsx(At,{field:e,error:t,isRequired:o,className:s,hideLabel:l,children:d.jsxs(Zt,{id:ft(e),type:"button",variant:c,size:u,disabled:!!p,onClick:i,className:H("w-fit",e.appearance?.className),children:[d.jsx(Gu,{className:"h-4 w-4 mr-1"}),f]})})},Lg=v.createContext(null);function __({value:e,children:t}){return d.jsx(Lg.Provider,{value:e,children:t})}function T_(){return v.useContext(Lg)}function Dg(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function Ns(e){return e.name||e.key||e.id}function Pc(e){return e.filter(t=>!t.parentId&&t.type==="sectionHeading"&&Ns(t))}function F_(e){if(e.type!=="sectionHeading")return[];const t=e.properties||{};return Array.isArray(t.linkedFieldNames)?t.linkedFieldNames.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function P_(e){const t=new Map;for(const r of Pc(e)){const n=Ns(r);for(const o of F_(r))t.set(o,n)}return t}function O_(e,t){const r=t.properties||{},n=Array.isArray(r.sectionHeadingNames)?r.sectionHeadingNames.filter(i=>typeof i=="string"&&i.trim()):[],o=Pc(e);if(n.length===0)return o;const s=new Set(n);return o.filter(i=>s.has(Ns(i)))}function I_(e){const t={};for(const r of Pc(e))t[Ns(r)]=!0;for(const r of e){if(r.type!=="customizeSections")continue;const n=r.properties||{};for(const o of n.defaultHiddenSectionNames??[])typeof o=="string"&&o.trim()&&(t[o.trim()]=!1)}return t}function Bg(e,t,r,n){if(!e||t==="customizeSections")return!0;const o=Dg(e),s=t==="sectionHeading"?o:n.get(o);return s?r[s]!==!1:!0}const M_=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,designMode:i=!1})=>{const a=T_(),c=e.properties||{},u=c.variant||"outline",f=c.size||"default",l=c.buttonText||e.label||"Customise sections",p=c.menuTitle||"VISIBLE SECTIONS",g=c.hideLabel??e.appearance?.hideLabel??!1,m=r||n||e.disabled||e.readOnly,h=v.useMemo(()=>a?.allFields?.length?O_(a.allFields,e):[],[a?.allFields,e]);return d.jsx(At,{field:e,error:t,isRequired:o,className:s,hideLabel:g,children:d.jsxs(sc,{children:[d.jsx(Rm,{asChild:!0,children:d.jsxs(Zt,{id:ft(e),type:"button",variant:u,size:f,disabled:!!m,className:H("w-fit gap-2",e.appearance?.className),children:[d.jsx(iS,{className:"h-4 w-4"}),l]})}),d.jsxs(ic,{align:"end",className:"w-64 p-0",children:[d.jsx("div",{className:"px-3 py-2 border-b",children:d.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:p})}),d.jsx("div",{className:"max-h-64 overflow-auto p-2 space-y-1",children:h.length===0?d.jsx("p",{className:"text-xs text-muted-foreground px-1 py-2",children:"No section headings on this form."}):h.map(y=>{const S=Ns(y),w=y.label||S,A=i||!a?!0:a.visibility[S]!==!1;return d.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md px-1 py-1.5 hover:bg-muted/50",children:[d.jsx(Pn,{htmlFor:`ui-section-${e.id}-${S}`,className:"text-xs font-normal truncate",children:w}),d.jsx(Eh,{id:`ui-section-${e.id}-${S}`,checked:A,disabled:i||!a||!!m,onCheckedChange:x=>{!a||i||a.setSectionVisible(S,!!x)}})]},y.id)})})]})]})})},L_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=u?.max||5,l=u?.icon||"star",p=h=>{s||i||e.disabled||e.readOnly||(r(h),n?.())},g=h=>{},m=h=>{const y=t>=h+1,S=H("transition-colors cursor-pointer",y?"fill-yellow-400 text-yellow-400":"text-muted-foreground",(s||i||e.disabled||e.readOnly)&&"cursor-not-allowed opacity-50",!(s||i||e.disabled||e.readOnly)&&"hover:text-yellow-400");return l==="star"?d.jsx(Ku,{className:H(S,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>g()},h):d.jsx(Ku,{className:H(S,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>g()},h)};return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:"flex items-center gap-1",role:"radiogroup","aria-label":e.label,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[Array.from({length:f},(h,y)=>m(y)),u?.showValue!==!1&&d.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:t>0?t:""})]})})};var $g=["PageUp","PageDown"],jg=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],zg={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Mo="Slider",[Oc,D_,B_]=Cl(Mo),[Ug]=vr(Mo,[B_]),[$_,pa]=Ug(Mo),Vg=b.forwardRef((e,t)=>{const{name:r,min:n=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[n],value:f,onValueChange:l=()=>{},onValueCommit:p=()=>{},inverted:g=!1,form:m,...h}=e,y=b.useRef(new Set),S=b.useRef(0),A=i==="horizontal"?j_:z_,[x=[],F]=ln({prop:f,defaultProp:u,onChange:C=>{[...y.current][S.current]?.focus(),l(C)}}),N=b.useRef(x);function k(C){const I=R_(x,C);E(C,I)}function T(C){E(C,S.current)}function P(){const C=N.current[S.current];x[S.current]!==C&&p(x)}function E(C,I,{commit:W}={commit:!1}){const M=Y_(s),z=X_(Math.round((C-n)/s)*s+n,M),V=us(z,[n,o]);F((X=[])=>{const D=H_(X,V,I);if(q_(D,c*s)){S.current=D.indexOf(V);const B=String(D)!==String(X);return B&&W&&p(D),B?D:X}else return X})}return d.jsx($_,{scope:e.__scopeSlider,name:r,disabled:a,min:n,max:o,valueIndexToChangeRef:S,thumbs:y.current,values:x,orientation:i,form:m,children:d.jsx(Oc.Provider,{scope:e.__scopeSlider,children:d.jsx(Oc.Slot,{scope:e.__scopeSlider,children:d.jsx(A,{"aria-disabled":a,"data-disabled":a?"":void 0,...h,ref:t,onPointerDown:De(h.onPointerDown,()=>{a||(N.current=x)}),min:n,max:o,inverted:g,onSlideStart:a?void 0:k,onSlideMove:a?void 0:T,onSlideEnd:a?void 0:P,onHomeKeyDown:()=>!a&&E(n,0,{commit:!0}),onEndKeyDown:()=>!a&&E(o,x.length-1,{commit:!0}),onStepKeyDown:({event:C,direction:I})=>{if(!a){const z=$g.includes(C.key)||C.shiftKey&&jg.includes(C.key)?10:1,V=S.current,X=x[V],D=s*z*I;E(X+D,V,{commit:!0})}}})})})})});Vg.displayName=Mo;var[Hg,Wg]=Ug(Mo,{startEdge:"left",endEdge:"right",size:"width",direction:1}),j_=b.forwardRef((e,t)=>{const{min:r,max:n,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...f}=e,[l,p]=b.useState(null),g=Qe(t,A=>p(A)),m=b.useRef(void 0),h=bo(o),y=h==="ltr",S=y&&!s||!y&&s;function w(A){const x=m.current||l.getBoundingClientRect(),F=[0,x.width],k=Lc(F,S?[r,n]:[n,r]);return m.current=x,k(A-x.left)}return d.jsx(Hg,{scope:e.__scopeSlider,startEdge:S?"left":"right",endEdge:S?"right":"left",direction:S?1:-1,size:"width",children:d.jsx(Rg,{dir:h,"data-orientation":"horizontal",...f,ref:g,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:A=>{const x=w(A.clientX);i?.(x)},onSlideMove:A=>{const x=w(A.clientX);a?.(x)},onSlideEnd:()=>{m.current=void 0,c?.()},onStepKeyDown:A=>{const F=zg[S?"from-left":"from-right"].includes(A.key);u?.({event:A,direction:F?-1:1})}})})}),z_=b.forwardRef((e,t)=>{const{min:r,max:n,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,f=b.useRef(null),l=Qe(t,f),p=b.useRef(void 0),g=!o;function m(h){const y=p.current||f.current.getBoundingClientRect(),S=[0,y.height],A=Lc(S,g?[n,r]:[r,n]);return p.current=y,A(h-y.top)}return d.jsx(Hg,{scope:e.__scopeSlider,startEdge:g?"bottom":"top",endEdge:g?"top":"bottom",size:"height",direction:g?1:-1,children:d.jsx(Rg,{"data-orientation":"vertical",...u,ref:l,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:h=>{const y=m(h.clientY);s?.(y)},onSlideMove:h=>{const y=m(h.clientY);i?.(y)},onSlideEnd:()=>{p.current=void 0,a?.()},onStepKeyDown:h=>{const S=zg[g?"from-bottom":"from-top"].includes(h.key);c?.({event:h,direction:S?-1:1})}})})}),Rg=b.forwardRef((e,t)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,f=pa(Mo,r);return d.jsx(je.span,{...u,ref:t,onKeyDown:De(e.onKeyDown,l=>{l.key==="Home"?(i(l),l.preventDefault()):l.key==="End"?(a(l),l.preventDefault()):$g.concat(jg).includes(l.key)&&(c(l),l.preventDefault())}),onPointerDown:De(e.onPointerDown,l=>{const p=l.target;p.setPointerCapture(l.pointerId),l.preventDefault(),f.thumbs.has(p)?p.focus():n(l)}),onPointerMove:De(e.onPointerMove,l=>{l.target.hasPointerCapture(l.pointerId)&&o(l)}),onPointerUp:De(e.onPointerUp,l=>{const p=l.target;p.hasPointerCapture(l.pointerId)&&(p.releasePointerCapture(l.pointerId),s(l))})})}),Gg="SliderTrack",Kg=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=pa(Gg,r);return d.jsx(je.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...n,ref:t})});Kg.displayName=Gg;var Ic="SliderRange",qg=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=pa(Ic,r),s=Wg(Ic,r),i=b.useRef(null),a=Qe(t,i),c=o.values.length,u=o.values.map(p=>Jg(p,o.min,o.max)),f=c>1?Math.min(...u):0,l=100-Math.max(...u);return d.jsx(je.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...n,ref:a,style:{...e.style,[s.startEdge]:f+"%",[s.endEdge]:l+"%"}})});qg.displayName=Ic;var Mc="SliderThumb",Yg=b.forwardRef((e,t)=>{const r=D_(e.__scopeSlider),[n,o]=b.useState(null),s=Qe(t,a=>o(a)),i=b.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return d.jsx(U_,{...e,ref:s,index:i})}),U_=b.forwardRef((e,t)=>{const{__scopeSlider:r,index:n,name:o,...s}=e,i=pa(Mc,r),a=Wg(Mc,r),[c,u]=b.useState(null),f=Qe(t,w=>u(w)),l=c?i.form||!!c.closest("form"):!0,p=ms(c),g=i.values[n],m=g===void 0?0:Jg(g,i.min,i.max),h=W_(n,i.values.length),y=p?.[a.size],S=y?G_(y,m,a.direction):0;return b.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),d.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${m}% + ${S}px)`},children:[d.jsx(Oc.ItemSlot,{scope:e.__scopeSlider,children:d.jsx(je.span,{role:"slider","aria-label":e["aria-label"]||h,"aria-valuemin":i.min,"aria-valuenow":g,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:f,style:g===void 0?{display:"none"}:e.style,onFocus:De(e.onFocus,()=>{i.valueIndexToChangeRef.current=n})})}),l&&d.jsx(Xg,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:g},n)]})});Yg.displayName=Mc;var V_="RadioBubbleInput",Xg=b.forwardRef(({__scopeSlider:e,value:t,...r},n)=>{const o=b.useRef(null),s=Qe(o,n),i=hs(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&f){const l=new Event("input",{bubbles:!0});f.call(a,t),a.dispatchEvent(l)}},[i,t]),d.jsx(je.input,{style:{display:"none"},...r,ref:s,defaultValue:t})});Xg.displayName=V_;function H_(e=[],t,r){const n=[...e];return n[r]=t,n.sort((o,s)=>o-s)}function Jg(e,t,r){const s=100/(r-t)*(e-t);return us(s,[0,100])}function W_(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function R_(e,t){if(e.length===1)return 0;const r=e.map(o=>Math.abs(o-t)),n=Math.min(...r);return r.indexOf(n)}function G_(e,t,r){const n=e/2,s=Lc([0,50],[0,n]);return(n-s(t)*r)*r}function K_(e){return e.slice(0,-1).map((t,r)=>e[r+1]-t)}function q_(e,t){if(t>0){const r=K_(e);return Math.min(...r)>=t}return!0}function Lc(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function Y_(e){return(String(e).split(".")[1]||"").length}function X_(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}var J_=Vg,Q_=Kg,Z_=qg,eT=Yg;function tT({className:e,defaultValue:t,value:r,min:n=0,max:o=100,...s}){const i=b.useMemo(()=>Array.isArray(r)?r:Array.isArray(t)?t:[n,o],[r,t,n,o]);return d.jsxs(J_,{"data-slot":"slider",defaultValue:t,value:r,min:n,max:o,className:H("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...s,children:[d.jsx(Q_,{"data-slot":"slider-track",className:H("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:d.jsx(Z_,{"data-slot":"slider-range",className:H("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:i.length},(a,c)=>d.jsx(eT,{"data-slot":"slider-thumb",className:"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},c))]})}const rT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=u?.min??0,l=u?.max??100,p=u?.step??1,g=u?.showValue!==!1,m=u?.marks||[],h=S=>{s||i||e.disabled||e.readOnly||(r(S[0]??f),n?.())},y=t??f;return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[g&&d.jsx("span",{className:"text-sm font-medium",children:y}),!g&&d.jsx("span",{className:"text-sm text-muted-foreground",children:f}),!g&&d.jsx("span",{className:"text-sm text-muted-foreground",children:l})]}),d.jsx(tT,{id:ft(e),value:[y],onValueChange:h,min:f,max:l,step:p,disabled:s||e.disabled||i||e.readOnly,className:H("w-full",o&&"border-destructive",e.appearance?.className),"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a}),m.length>0&&d.jsx("div",{className:"flex justify-between text-xs text-muted-foreground",children:m.map((S,w)=>d.jsx("span",{className:"text-center",children:S.label},w))})]})})},nT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=v.useRef(null),[f,l]=v.useState(!1),p=s||e.disabled||i||e.readOnly,g=v.useCallback(S=>{if(p)return;l(!0);const w=u.current;if(!w)return;const A=w.getContext("2d");if(!A)return;const x=w.getBoundingClientRect(),F="touches"in S?S.touches[0].clientX-x.left:S.clientX-x.left,N="touches"in S?S.touches[0].clientY-x.top:S.clientY-x.top;A.beginPath(),A.moveTo(F,N)},[p]),m=v.useCallback(S=>{if(!f||p)return;const w=u.current;if(!w)return;const A=w.getContext("2d");if(!A)return;const x=w.getBoundingClientRect(),F="touches"in S?S.touches[0].clientX-x.left:S.clientX-x.left,N="touches"in S?S.touches[0].clientY-x.top:S.clientY-x.top;A.lineWidth=2,A.lineCap="round",A.strokeStyle="#000",A.lineTo(F,N),A.stroke(),A.beginPath(),A.moveTo(F,N)},[f,p]),h=v.useCallback(()=>{if(!f)return;l(!1);const S=u.current;if(!S)return;const w=S.toDataURL();r(w),n?.()},[f,r,n]),y=v.useCallback(()=>{const S=u.current;if(!S||p)return;const w=S.getContext("2d");w&&(w.clearRect(0,0,S.width,S.height),r(null),n?.())},[p,r,n]);return v.useEffect(()=>{const S=u.current;if(S&&(S.width=S.offsetWidth,S.height=200,t)){const w=new Image;w.onload=()=>{const A=S.getContext("2d");A&&A.drawImage(w,0,0)},w.src=t}},[t]),d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsx("div",{className:H("border-2 border-dashed rounded-lg overflow-hidden",o&&"border-destructive",p&&"opacity-50 cursor-not-allowed"),children:d.jsx("canvas",{ref:u,id:ft(e),className:"w-full cursor-crosshair touch-none",onMouseDown:g,onMouseMove:m,onMouseUp:h,onMouseLeave:h,onTouchStart:g,onTouchMove:m,onTouchEnd:h,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,style:{height:"200px"}})}),!p&&d.jsx("div",{className:"flex justify-end",children:d.jsxs(Zt,{type:"button",variant:"outline",size:"sm",onClick:y,className:"text-xs",children:[d.jsx(rs,{className:"h-3 w-3 mr-1"}),"Clear"]})})]})})},oT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,hideRowControls:u=!1,formValues:f,submissionContext:l})=>{const p=e.properties,g=p?.columns||[],m=p?.minRows||1,h=p?.maxRows||10,y=!u&&p?.allowAddRow!==!1,S=!u&&p?.allowDeleteRow!==!1,w=s===!1&&i===!1?!1:s||e.disabled||i||e.readOnly,A=t||[],x=y&&A.length<h,F=S&&A.length>m,N=v.useCallback(()=>{if(!x||w)return;const M={};g.forEach(z=>{M[z.name]=z.defaultValue??""}),r([...A,M]),n?.()},[A,g,x,w,r,n]),k=v.useCallback(M=>{if(!F||w)return;const z=A.filter((V,X)=>X!==M);r(z),n?.()},[A,F,w,r,n]),T=v.useCallback((M,z,V)=>{if(w)return;const X=[...A];X[M]||(X[M]={}),X[M][z]=V,r(X),n?.()},[A,w,r,n]);if(v.useEffect(()=>{if(A.length<m){const M=m-A.length,z=[];for(let V=0;V<M;V++){const X={};g.forEach(D=>{X[D.name]=D.defaultValue??""}),z.push(X)}r([...A,...z])}},[m,g,r,A.length]),g.length===0)return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this table field"})});const P=Math.max(1,e.position?.rowSpan??1),E=Math.max(1,e.position?.columnSpan??1),C=Math.max(A.length,1),I=P>=3?"py-4":P>=2?"py-3":"py-2.5",W=E>=3?"px-4":E>=2?"px-3":"px-4";return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:H("flex h-full min-h-0 w-full min-w-0 flex-1 flex-col border rounded-lg overflow-hidden shadow-sm bg-background",o&&"border-destructive",w&&"opacity-50"),"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[d.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:d.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:p?.minWidth?{minWidth:p.minWidth}:void 0,children:[d.jsx("thead",{children:d.jsxs("tr",{className:"border-b border-border bg-muted/60",children:[g.map(M=>d.jsxs("th",{className:H(W,I,"text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground whitespace-nowrap"),children:[M.label,a&&M.validation?.some(z=>z.type==="required")&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]},M.id)),S&&d.jsx("th",{className:"w-12"})]})}),d.jsx("tbody",{className:"h-full",children:A.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:g.length+(S?1:0),className:H(W,"py-8 text-center text-sm text-muted-foreground"),children:u?"No rows to display.":'No rows added yet. Click "Add Row" to get started.'})}):A.map((M,z)=>{const V=A[z],X=V&&typeof V=="object"&&!Array.isArray(V)?{...f??{},...V}:f;return d.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/30 transition-colors last:border-b-0",style:{height:`${100/C}%`},children:[g.map(D=>{const B={...D,name:`${e.name}_${z}_${D.name}`,appearance:{...D.appearance,hideLabel:!0}},L=D.name??"",K=M[L]!==void 0?M[L]:L&&Object.keys(M).find(G=>G.toLowerCase()===L.toLowerCase())?M[Object.keys(M).find(G=>G.toLowerCase()===L.toLowerCase())]:void 0,ie=!!D.readOnly,j=G=>{if(G==null)return"";if(Array.isArray(G))return G.map(ae=>typeof ae=="object"&&ae!==null&&"name"in ae?String(ae.name??ae):String(ae)).join(", ");if(typeof G=="object"&&G!==null&&!(G instanceof Date)){const ae=G;return typeof ae.name=="string"&&typeof ae.code=="string"?`${ae.code} ${ae.name}`.trim():typeof ae.name=="string"?ae.name:typeof ae.code=="string"?ae.code:String(ae.name??ae.code??G)}return String(G)},U=G=>typeof G=="object"&&G!==null&&!Array.isArray(G)?j(G):String(G??""),le=D.name?.toLowerCase()==="type"||D.label?.toLowerCase()==="type";if(ie){const G=j(K);return d.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:d.jsx("div",{className:"min-w-[120px] text-sm text-foreground",children:le&&G?d.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 text-primary px-2.5 py-0.5 text-xs font-medium",children:G}):d.jsx("span",{className:"py-1 block",children:G})})},D.id)}const oe=()=>{switch(D.type){case"text":case"password":case"url":return d.jsx(si,{field:B,value:U(K),onChange:G=>T(z,D.name,G),disabled:w,readOnly:w,className:"w-full"});case"number":return d.jsx(dl,{field:B,value:K??null,onChange:G=>T(z,D.name,G),disabled:w,readOnly:w,className:"w-full"});case"email":return d.jsx(qu,{field:B,value:U(K),onChange:G=>T(z,D.name,G),disabled:w,readOnly:w,className:"w-full"});case"phone":case"aadhaar":return d.jsx(Yu,{field:B,value:U(K),onChange:G=>T(z,D.name,G),disabled:w,readOnly:w,className:"w-full"});case"otp":return d.jsx(Rf,{field:B,value:U(K),onChange:G=>T(z,D.name,G),disabled:w,readOnly:w,className:"w-full"});case"textarea":return d.jsx(Gf,{field:B,value:U(K),onChange:G=>T(z,D.name,G),disabled:w,readOnly:w,className:"w-full"});case"select":return d.jsx(Fm,{field:B,value:typeof K=="string"?K:U(K),onChange:G=>T(z,D.name,G),disabled:w,className:"w-full",formValues:X,submissionContext:l});case"multiselect":{const G=Array.isArray(K)?K:K!=null&&K!==""?[String(K)]:[];return d.jsx(bh,{field:B,value:G,onChange:ae=>T(z,D.name,ae),disabled:w,className:"w-full",formValues:X,submissionContext:l})}case"asyncsearch":return d.jsx(Ym,{field:B,value:K,onChange:G=>T(z,D.name,G),disabled:w,readOnly:w,className:"w-full",formValues:X,submissionContext:l});case"checkbox":return d.jsx(vh,{field:B,value:K||!1,onChange:G=>T(z,D.name,G),disabled:w,className:"w-full"});case"radio":case"checkboxgroup":return d.jsx(Rh,{field:B,value:typeof K=="string"?K:U(K),onChange:G=>T(z,D.name,G),disabled:w,className:"w-full"});case"date":case"time":case"datetime":case"daterange":return d.jsx(Gh,{field:B,value:typeof K=="string"?K:U(K),onChange:G=>T(z,D.name,G),disabled:w,readOnly:w,className:"w-full"});default:return d.jsx(si,{field:B,value:U(K),onChange:G=>T(z,D.name,G),disabled:w,readOnly:w,className:"w-full"})}};return d.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:d.jsx("div",{className:"min-w-[160px] w-full [&_input]:min-w-[10rem] [&_input]:overflow-visible [&_textarea]:min-h-[2.5rem]",children:oe()})},D.id)}),S&&d.jsx("td",{className:"px-2 py-2",children:d.jsx(Zt,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>k(z),disabled:!F||w,children:d.jsx(rs,{className:"h-4 w-4"})})})]},z)})})]})}),x&&d.jsx("div",{className:"shrink-0 p-3 border-t bg-muted/30",children:d.jsxs(Zt,{type:"button",variant:"outline",size:"sm",onClick:N,disabled:w,className:"w-full",children:[d.jsx(Gu,{className:"h-4 w-4 mr-2"}),"Add Row"]})})]})})},sT="h-8 min-h-8 rounded-md border border-input bg-background px-2 text-sm shadow-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30",iT="flex min-h-8 w-full items-center gap-0.5 rounded-md border border-input bg-background px-2 focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30",aT="h-8 min-w-[2ch] max-w-full flex-1 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0",lT="align-top max-w-0 whitespace-normal break-words",ks="block min-w-0 break-words";function Qg(e,t,r){const n=r?.emptyDisplay??"—";if(e==null||e==="")return n;const o=t?.format??"text",s=typeof e=="number"?e:Number(e);switch(o){case"currency":return Number.isNaN(s)?n:`${r?.currencySymbol??"₹"}${s.toLocaleString("en-IN",{minimumFractionDigits:0,maximumFractionDigits:2})}`;case"percent":return Number.isNaN(s)?n:`${s}%`;case"number":return Number.isNaN(s)?n:String(s);default:return String(e)}}function cT(e){const t=e.replace(/[^\d.-]/g,"");if(t===""||t==="-"||t===".")return null;const r=parseFloat(t);return Number.isNaN(r)?null:r}function dT(e){if(e==null||e==="")return"";const t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?"":String(t)}function Zg(e,t){return Qg(e,{format:"currency"},t)}function _s(e){return e==null||e===""}function ey(e){return e.mode??"editable"}function uT(e,t){return e.kind==="currency"||e.kind==="input"&&e.inputType==="number"?!0:t?.format==="currency"||t?.format==="number"||t?.format==="percent"}function ty(e,t,r){if(e!==void 0){if(e==="")return"";if(uT(t,r)){const n=Number(e);return Number.isNaN(n)?e:n}return e}}function Dc(e,t){if(!(!e||!("defaultValue"in e)||e.defaultValue===void 0))return ty(e.defaultValue,e,t)}function Bc(e,t,r){if(!t||!_s(e))return e;if(t.kind==="currency"&&ey(t)==="static"&&t.value!==void 0)return ty(t.value,t,r);const n=Dc(t,r);return n!==void 0?n:e}function fT(e,t,r){const n={...t};for(const[o,s]of Object.entries(e)){const i=r.find(c=>c.key===o);if(!_s(n[o]))continue;const a=Bc(n[o],s,i);(!_s(a)||s&&"defaultValue"in s&&s.defaultValue==="")&&(n[o]=a)}return n}function ma(e,t,r){if(!_s(e))return e;const n=Dc(t,r);return n!==void 0?n:e}const pT=new Set(["all_items_summary","invoice_discount","grand_total"]);function mT(e,t){switch(t){case"dynamic":return e.filter(r=>r.rowKind==="dynamic");case"static":return e.filter(r=>r.rowKind==="static");case"all":return e;case"data":return e.filter(r=>r.rowKind==="dynamic"||r.rowKind==="static"&&!pT.has(r.slotId));default:return e}}function hT(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}function gT(e,t,r){const n=e.rowSlots.find(o=>o.kind==="static"?o.row.id===t.slotId:o.kind==="dynamic"&&o.block.id===t.slotId);if(n)return n.kind==="static"?n.row.cells[r]:n.block.cells[r]}function yT(e,t,r,n){const o=f=>Pu(n,t,f,r),s=(f,l)=>Pu(n,t,l,r,{slotId:f,rowKind:"static"}),i=(f,l="all")=>mT(t,l).reduce((p,g)=>p+hT(g.values[f]),0),a={...Zs.functions,cell:o,cellInRow:s,SUM:i},c=Object.keys(a),u=Object.values(a);try{const f=new Function(...c,`return (${e});`)(...u);return f==null||typeof f=="number"&&Number.isNaN(f)?null:f}catch{return null}}function bT(e,t){return e.length!==t.length?!1:e.every((r,n)=>{const o=t[n];return r.slotId===o.slotId&&r.rowInstanceId===o.rowInstanceId&&JSON.stringify(r.values)===JSON.stringify(o.values)})}function vT(e,t){const r=t.rows.map(n=>({...n,values:{...n.values}}));for(const n of r)for(const o of e.columns){const s=gT(e,n,o.key);if(s?.kind==="formula"){const i=yT(s.expression,r,n,e),a=e.columns.find(c=>c.key===o.key);n.values[o.key]=_s(i)?Dc(s,a)??i:i}}return{rows:r}}function Lo(e,t,r=8){let n={rows:t.rows.map(o=>({...o,values:{...o.values}}))};for(let o=0;o<r;o++){const s=vT(e,n);if(bT(s.rows,n.rows))return s;n=s}return n}function wT(e,t,r,n,o,s){const i=t.rows.map(a=>a.rowInstanceId!==r||a.slotId!==n?a:{...a,values:{...a.values,[o]:s}});return Lo(e,{rows:i})}function ry(e,t,r=[]){return t.map((n,o)=>{const s=typeof n=="object"&&n!==null?n:{},i=e.rowIdField&&s[e.rowIdField]!=null?String(s[e.rowIdField]):String(o),a={};for(const[u,f]of Object.entries(e.cells)){const l=r.find(p=>p.key===u);(f.kind==="api"&&f.path||f.kind==="currency"&&f.mode==="api"&&f.path)&&(a[u]=ma(Re(s,f.path),f,l))}const c=a.service??a.tariff_type;return{slotId:e.id,rowKind:"dynamic",rowInstanceId:i,label:typeof c=="string"?c:void 0,values:a}})}function $c(e,t,r){const n=[];for(const o of e.rowSlots)if(o.kind==="static"){const s=t.get(o.row.id);s&&n.push(s)}else n.push(...r.get(o.block.id)??[]);return n}function jc(e,t){const r=new Map,n=new Map;for(const o of e.rowSlots)if(o.kind==="static"){const s=t?.rows.find(i=>i.slotId===o.row.id&&i.rowKind==="static");r.set(o.row.id,{slotId:o.row.id,rowKind:"static",rowInstanceId:o.row.id,label:o.row.label,values:fT(o.row.cells,s?.values?{...s.values}:{},e.columns)})}else{const s=t?.rows.filter(i=>i.slotId===o.block.id&&i.rowKind==="dynamic")??[];n.set(o.block.id,s.map(i=>({...i,values:{...i.values}})))}return{rows:$c(e,r,n)}}function ST(e,t,r,n){const o=jc(e,n),s=e.rowSlots.find(c=>c.kind==="dynamic"&&c.block.id===t);if(!s||s.kind!=="dynamic")return Lo(e,o);const i=new Map,a=new Map;for(const c of e.rowSlots)if(c.kind==="static"){const u=o.rows.find(f=>f.slotId===c.row.id&&f.rowKind==="static");u&&i.set(c.row.id,{...u,values:{...u.values}})}else{const u=c.block.id===t?ry(c.block,r,e.columns):o.rows.filter(f=>f.slotId===c.block.id&&f.rowKind==="dynamic");a.set(c.block.id,u.map(f=>({...f,values:{...f.values}})))}return Lo(e,{rows:$c(e,i,a)})}function ny(e,t,r){const n=jc(e,r);if(t==null||typeof t!="object"||Array.isArray(t))return Lo(e,n);const o=t,s=new Map,i=new Map;for(const a of e.rowSlots)if(a.kind==="static"){const u={...n.rows.find(l=>l.slotId===a.row.id&&l.rowKind==="static")?.values??{}},f=o[a.row.id]??o;for(const[l,p]of Object.entries(a.row.cells)){const g=e.columns.find(m=>m.key===l);(p.kind==="api"&&p.path||p.kind==="currency"&&p.mode==="api"&&p.path)&&(u[l]=ma(Re(f,p.path),p,g))}s.set(a.row.id,{slotId:a.row.id,rowKind:"static",rowInstanceId:a.row.id,label:a.row.label,values:u})}else{const c=a.block.apiArrayPath??a.block.id,u=Re(o,c);i.set(a.block.id,Array.isArray(u)?ry(a.block,u,e.columns):[])}return Lo(e,{rows:$c(e,s,i)})}function oy(e){if(!e)return"";const t=[];switch(e.fontSize){case"xs":t.push("text-xs");break;case"sm":t.push("text-sm");break;case"base":t.push("text-base");break;case"lg":t.push("text-lg");break;case"xl":t.push("text-xl");break}return e.bold?t.push("font-bold"):e.fontSize&&t.push("font-medium"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),t.join(" ")}function xT(e){const t=e?.color?.trim();return t?{color:t}:{}}function zc(e){return{className:oy(e),style:xT(e)}}function AT(e){return e?!!(e.fontSize||e.bold||e.italic||e.underline||e.color?.trim()):!1}function CT(e,t){if(!e&&!t)return;const r={...e,...t};return AT(r)?r:void 0}function ET(e,t){const r=e?.kind==="label"?CT(t,e.cellStyle):e?.cellStyle;return zc(r)}function Uc(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function sy(e,t){return e?.align?e.align:t?.align??"left"}function iy(e){const t=e.properties,r=t?.apiEndpoint?{apiEndpoint:t.apiEndpoint,apiMethod:t.apiMethod,apiKey:t.apiKey,apiRealtime:t.apiRealtime,apiQueryParams:t.apiQueryParams,apiHeaders:t.apiHeaders,apiBodyFields:t.apiBodyFields,apiAuth:t.apiAuth,valueSource:t.valueSource,dependentFields:t.dependentFields,apiResponsePath:t.apiResponsePath}:null,n=e.apidata||null;return r||n}function ay(e){if(e.type!=="billingGrid")return!1;const t=iy(e),r=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||r?.valueSource==="api"))}function NT(e,t,r){let n=e;if(r?.trim()&&(n=Re(e,r.trim())),n==null)return null;if(Array.isArray(n)){const o=t.rowSlots.find(s=>s.kind==="dynamic");return o?.kind==="dynamic"?{[o.block.apiArrayPath?.trim()||o.block.id]:n}:null}return typeof n=="object"?n:null}function ha(e){return JSON.stringify(e?.rows??[])}function kT({field:e,properties:t,formValues:r={},submissionContext:n,value:o,onChange:s}){const i=ay(e),a=iy(e),[c,u]=v.useState(!1),[f,l]=v.useState(null),p=v.useRef(""),g=v.useRef(o);g.current=o;const m=v.useMemo(()=>{const x=a?.apiEndpoint||"",F=a?.apiQueryParams;return po(x,F)},[a?.apiEndpoint,a?.apiQueryParams]),h=v.useMemo(()=>{const x=new Set;for(const F of a?.dependentFields??[])typeof F=="string"&&F.trim()&&x.add(F.trim());return[...x]},[a?.dependentFields]),y=v.useMemo(()=>{const x=new Set([...m,...h]);if(x.size===0)return null;const F={};return x.forEach(N=>{F[N]=r[N]}),JSON.stringify(F)},[m,h,r]),S=v.useMemo(()=>JSON.stringify(n||{}),[n]),w=v.useMemo(()=>{const x=new Set;e.name?.trim()&&x.add(e.name.trim());const F=e.key;return typeof F=="string"&&F.trim()&&x.add(F.trim()),[...x]},[e.name,e.key]),A=v.useMemo(()=>JSON.stringify({rowSlots:t.rowSlots,columns:t.columns}),[t.rowSlots,t.columns]);return v.useEffect(()=>{const x=a?.apiEndpoint;if(!i||!x)return;let F=!1;const N=T=>{if(F)return;const P=ha(T),E=ha(g.current);P!==E&&p.current!==P&&(p.current=P,s(T))};return(async()=>{u(!0),l(null);try{const T=a?.apiMethod||"GET",P=a?.apiRealtime,E=ti({apiEndpoint:x,apiMethod:T,apiQueryParams:a?.apiQueryParams||{},formValues:r,submissionContext:n,apiRealtime:P,additionalRequiredFieldNames:h,excludeFormFieldNames:w});if(E.blocked){F||u(!1);return}const C={"Content-Type":"application/json"};a?.apiKey&&(C["X-CSCAPI-KEY"]=a.apiKey);const I=a?.apiAuth??vs(a?.apiHeaders)??{type:"none"};Object.assign(C,ws(I,{formValues:r,submissionContext:n,apiRealtime:P})),Object.assign(C,vn(bs(a?.apiHeaders),{formValues:r,submissionContext:n,apiRealtime:P}));const W=vn(a?.apiBodyFields,{formValues:r,submissionContext:n,apiRealtime:P}),M={method:T.toLowerCase(),url:Mr(E.url),headers:C};(E.postBodyBase!=null||Object.keys(W).length>0)&&(M.data={...E.postBodyBase??{},...W});const z=await Ct(M),V=NT(z.data,t,a?.apiResponsePath);if(!V){F||l("API response could not be mapped to billing grid rows.");return}const X=ny(t,V,g.current);N(X)}catch(T){if(F)return;let P="Failed to load billing data";const E=T;if(E.response){const C=E.response.data;if(E.response.status===404)P="API endpoint not found.";else if(E.response.status===401)P="Authentication failed.";else if(typeof C=="string")P=C;else if(C&&typeof C=="object"){const I=C;P=I.error||I.message||I.detail||P}}else E.message&&(P=String(E.message));l(P)}finally{F||u(!1)}})(),()=>{F=!0}},[i,a?.apiEndpoint,a?.apiMethod,a?.apiResponsePath,y,h,w,S,A]),{isLoading:c,error:f}}function _T(e,t,r){return e.rowSlots.find(n=>r==="static"?n.kind==="static"&&n.row.id===t:n.kind==="dynamic"&&n.block.id===t)}function ly(e,t,r,n){const o=e.rowSlots.find(s=>r==="static"?s.kind==="static"&&s.row.id===t:s.kind==="dynamic"&&s.block.id===t);if(o)return o.kind==="static"?o.row.cells[n]:o.block.cells[n]}const TT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f})=>{const l=e.properties??{},p=l.columns??[],g=l.currencySymbol??"₹",m=l.emptyDisplay??"—",h=s||i,y=ay(e),{isLoading:S}=kT({field:e,properties:l,formValues:u,submissionContext:f,value:t,onChange:r}),w=v.useMemo(()=>{const C=jc(l,t);return Lo(l,C)},[l,t]),A=v.useRef("");v.useEffect(()=>{const C=ha(w),I=ha(t);C===I||C===A.current||(A.current=C,r(w))},[w,t,r]),v.useEffect(()=>{!t?.rows?.length&&w.rows.length&&!y&&r(w)},[t,w,r,y]);const x=v.useCallback((C,I,W,M,z)=>{if(h)return;const V=z==="number"?cT(M):M===""?null:M,X=wT(l,w,C,I,W,V);r(X)},[h,w,r,l]),F=(C,I,W,M,z,V)=>{const X=p.find(U=>U.key===z),D=ly(l,C,I,z),B=Uc(sy(D,X)),L=Bc(V,D,X),K=_T(l,C,I),ie=K?.kind==="static"?K.row.labelStyle:K?.kind==="dynamic"?K.block.labelStyle:void 0,j=ET(D,ie);if(D?.kind==="label")return d.jsx("span",{className:H(ks,j.className||"font-medium",B,!j.style.color&&"text-foreground"),style:j.style,children:M??m});if(D?.kind==="input"&&!h){const U=L==null||L===""?"":String(L);return d.jsx(mn,{type:"text",inputMode:D.inputType==="number"?"decimal":"text",value:U,onChange:le=>x(W,C,z,le.target.value,D.inputType),onBlur:n,className:H(sT,"w-full min-w-0",B,j.className),style:j.style,disabled:h})}if(D?.kind==="currency"){const U=ey(D);if(U==="static"){const oe=D.value!==void 0&&D.value!==""?Bc(null,{...D,mode:"static"},X):L;return d.jsx("span",{className:H(ks,"tabular-nums",B,j.className),style:j.style,children:Zg(oe,{currencySymbol:g,emptyDisplay:m})})}if(U==="api"||h)return d.jsx("span",{className:H(ks,"tabular-nums",B,j.className),style:j.style,children:Zg(L,{currencySymbol:g,emptyDisplay:m})});const le=dT(L);return d.jsxs("div",{className:H(iT,B==="text-center"&&"justify-center",B==="text-right"&&"justify-end",B==="text-left"&&"justify-start",j.className),style:j.style,children:[d.jsx("span",{className:"shrink-0 tabular-nums",children:g}),d.jsx(mn,{type:"text",inputMode:"decimal",value:le,onChange:oe=>x(W,C,z,oe.target.value,"number"),onBlur:n,className:aT,disabled:h})]})}return D?.kind==="static"?d.jsx("span",{className:H(ks,B,j.className,!j.style.color&&"text-muted-foreground"),style:j.style,children:D.value}):d.jsx("span",{className:H(ks,B,j.className),style:j.style,children:Qg(L,X,{currencySymbol:g,emptyDisplay:m})})},N=l.gridTitle?.trim()??"",k=Math.max(1,e.position?.rowSpan??1),T=Math.max(1,e.position?.columnSpan??1),P=k>=3?"py-4":k>=2?"py-3":"py-2",E=T>=3?"px-4":T>=2?"px-3":"px-2";return p.length===0?d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this billing grid"})}):d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:H("relative flex h-full min-h-0 w-full min-w-0 max-w-full flex-1 flex-col border rounded-lg overflow-hidden shadow-sm bg-background",o&&"border-destructive",h&&"opacity-70"),"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[S&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60",children:d.jsx(mo,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),N?d.jsx("div",{className:H("shrink-0 px-4 py-2 border-b bg-muted/40",oy(l.gridTitleStyle)||"text-muted-foreground"),style:zc(l.gridTitleStyle).style,children:N}):null,d.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:d.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:l.minWidth?{minWidth:l.minWidth}:void 0,children:[d.jsx("thead",{children:d.jsx("tr",{className:"border-b border-border bg-muted/60",children:p.map(C=>{const I=zc(C.headerStyle);return d.jsx("th",{className:H(E,P,"text-xs uppercase tracking-wider whitespace-nowrap",Uc(C.align),I.className||"font-semibold text-muted-foreground"),style:I.style,children:C.label},C.id)})})}),d.jsx("tbody",{className:"h-full",children:w.rows.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:p.length,className:H(E,"py-8 text-center text-sm text-muted-foreground"),children:"No billing rows configured"})}):w.rows.map(C=>d.jsx("tr",{className:"border-b border-border/60",children:p.map(I=>{const W=ly(l,C.slotId,C.rowKind,I.key),M=sy(W,I);return d.jsx("td",{className:H(E,P,lT,Uc(M)),children:F(C.slotId,C.rowKind,C.rowInstanceId,C.label,I.key,C.values[I.key])},I.id)})},`${C.slotId}-${C.rowInstanceId}`))})]})})]})})};function Vc(e,t,r){return ny(e,t,r)}const FT=({field:e,value:t,error:r,disabled:n,isRequired:o,className:s,formValues:i={},submissionContext:a,extraSubmitPayload:c,skipApiCall:u=!1,prepopulateResponse:f=null})=>{const l=e.properties||{},p=l.source??"manual",g=Array.isArray(l.statuses)?l.statuses:[],m=(l.dataPath||"data").trim(),h=l.showStatusText===!0,y=(l.statusTextPath||"data.admissionStatus").trim(),S=l.showCurrentIndicator!==!1,[w,A]=v.useState(null),[x,F]=v.useState(!1),[N,k]=v.useState(null),T=Ba.useParams(),P=v.useRef(i),E=v.useRef(a),C=v.useRef(c),I=v.useRef(T);P.current=i,E.current=a,C.current=c,I.current=T;const W=v.useCallback(async()=>{const D=l.apiEndpoint?.trim();if(!D){k("Status API endpoint is not configured");return}F(!0),k(null);try{const B=E.current,L=C.current,K=B!=null&&typeof B=="object"?{...B,...L||{}}:L||{},ie=Mr(Rr(D,P.current,I.current,K,void 0,f??void 0)),j=(l.apiMethod||"GET").toUpperCase(),U=await fetch(ie,{method:j,headers:j==="POST"?{"Content-Type":"application/json"}:void 0});if(!U.ok)throw new Error(`HTTP ${U.status}`);const le=await U.json(),oe=m?Re(le,m):le;A(oe&&typeof oe=="object"?oe:{})}catch(B){k(B instanceof Error?B.message:"Failed to load status"),A(null)}finally{F(!1)}},[l.apiEndpoint,l.apiMethod,m,f]);v.useEffect(()=>{p==="api"&&!u&&W()},[p,u,W]);const M=p==="api"?w:t&&typeof t=="object"?(m?Re(t,m):null)??t:null,z=h&&y&&M?String(Re(M,y)??Re({data:M},y)??""):"",V=D=>{if(!M||typeof M!="object")return!1;const B=M[D];return B===!0||B==="true"||B===1};let X=!1;return d.jsx(At,{field:e,error:r||N||void 0,isRequired:o,className:H(s,"!space-y-0 h-full min-h-0 flex flex-col"),children:d.jsxs("div",{className:"rounded-lg border bg-card p-4 h-full min-h-0 flex flex-col",children:[x&&d.jsx("div",{className:"text-sm text-muted-foreground py-2",children:"Loading status..."}),h&&z&&!x&&d.jsx("p",{className:"text-sm text-muted-foreground mb-3 shrink-0","data-status-text":!0,children:z}),!x&&d.jsx("ul",{className:"flex-1 min-h-0 flex flex-col gap-y-8 overflow-y-auto pr-1 py-1",children:g.map(D=>{const B=V(D.key),L=S&&B&&!X;return L&&(X=!0),d.jsxs("li",{className:H("flex items-center gap-3 text-sm",B?"text-foreground":"text-muted-foreground"),children:[B?d.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-green-600 text-white","aria-hidden":!0,children:d.jsx(ai,{className:"h-3 w-3"})}):d.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 border-muted-foreground/40 bg-muted/50","aria-hidden":!0,children:d.jsx(Hu,{className:"h-2.5 w-2.5 text-muted-foreground/60"})}),d.jsx("span",{className:"flex-1 min-w-0",children:D.label}),L&&d.jsx("span",{className:"shrink-0 text-xs font-medium text-primary",children:"Current"})]},D.key)})}),!x&&g.length===0&&d.jsx("p",{className:"text-sm text-muted-foreground",children:"No statuses configured."})]})})};function Hc(e,t){if(!t||!e)return;const r=t.split(".");let n=e;for(const o of r){if(n==null||typeof n!="object")return;n=n[o]}return n}function Do(e,t){if(t){const r=Hc(e,t);if(r!=null)return String(r)}return e.email!=null?String(e.email):e.personal_email!=null?String(e.personal_email):e.id!=null?String(e.id):JSON.stringify(e)}function PT(e,t,r,n){if(r?.length){const s=n??" | ",i=r.map(a=>Hc(e,a)).filter(a=>a!=null).map(a=>String(a));if(i.length)return i.join(s)}if(t){const s=Hc(e,t);if(s!=null)return String(s)}if(e.name!=null&&e.email!=null)return`${e.name} <${e.email}>`;if(e.name!=null)return String(e.name);if(e.email!=null)return String(e.email);const o=e.personal_email;return o!=null?String(o):JSON.stringify(e)}const OT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,submissionContext:c})=>{const u=e.properties||{},{dataSourceContextKey:f,labelField:l="name",valueField:p="email",displayFields:g,displayFieldsSeparator:m=" | ",showSelectAll:h=!0,selectAllByDefault:y=!0}=u;console.log("[SelectableList] Step 1: render",{fieldName:e.name,valueIsArray:Array.isArray(t),valueLength:Array.isArray(t)?t.length:0,valueSample:Array.isArray(t)&&t.length>0?t.slice(0,2):t,submissionContextKeys:c?Object.keys(c):[],dataSourceContextKey:f,contextKeyValue:c&&f?c[f]:void 0});const S=v.useMemo(()=>{if(!f||!c)return[];const C=c[f];return Array.isArray(C)?C:[]},[f,c]);console.log("[SelectableList] Step 2: contextList from submissionContext",{fieldName:e.name,contextListLength:S.length,contextListSample:S.length>0?S.slice(0,2):[]});const[w,A]=v.useState(()=>S.length>0?S:Array.isArray(t)?t:[]);v.useEffect(()=>{if(S.length>0){console.log("[SelectableList] Step 3: sync fullList from context",{fieldName:e.name,contextListLength:S.length}),A(S);return}Array.isArray(t)&&t.length>0&&A(C=>{const I=C.length===0||t.length>C.length?t:C;return console.log("[SelectableList] Step 3: sync fullList from value",{fieldName:e.name,valueLength:t.length,prevLength:C.length,nextLength:I.length}),I})},[S,t]);const x=v.useMemo(()=>{const C=Array.isArray(t)?t:[];return new Set(C.map(W=>Do(W,p)))},[t,p]),F=w.length>0&&w.every(C=>x.has(Do(C,p))),N=w.some(C=>x.has(Do(C,p))),k=v.useCallback((C,I)=>{const W=Do(C,p),M=Array.isArray(t)?t:[];I?x.has(W)||r([...M,C]):r(M.filter(z=>Do(z,p)!==W)),n?.()},[t,p,x,r,n]),T=v.useCallback(C=>{r(C===!0?[...w]:[]),n?.()},[w,r,n]),P=w.length>0?w:Array.isArray(t)?t:[],E=s||e.disabled;return console.log("[SelectableList] Data in list",{fieldName:e.name,listLength:P.length,listSource:w.length>0?"fullList":"value",valueLength:Array.isArray(t)?t.length:0,fullListLength:w.length,listData:P.length>0?P:[],listDataFirstThree:P.length>0?P.slice(0,3):[]}),d.jsx("div",{className:H("relative z-10 flex flex-col min-h-0 h-full w-full",P.length>0&&"min-h-[14rem]",a),children:d.jsx(At,{field:e,error:o,isRequired:i,className:H("flex-1 min-h-0 flex flex-col",P.length>0&&"min-h-[14rem]"),children:d.jsx("div",{className:H("flex-1 min-h-0 flex flex-col",P.length>0&&"min-h-[14rem]"),children:d.jsxs("div",{className:H("flex-1 min-h-0 flex flex-col",P.length>0&&"overflow-visible"),children:[d.jsxs("div",{role:"listbox","aria-multiselectable":!0,className:H("border rounded-md divide-y overflow-y-auto overflow-x-hidden bg-muted/30 overscroll-contain touch-pan-y pb-3 pr-3 z-20 relative",P.length>0?"flex-1 min-h-0":"min-h-0"),children:[h&&P.length>0&&d.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 sticky top-0 bg-background border-b z-10 shrink-0",children:[d.jsx(Yi,{id:`${ft(e)}-select-all`,checked:F?!0:N?"indeterminate":!1,onCheckedChange:T,disabled:E,"aria-label":"Select all"}),d.jsxs(Pn,{htmlFor:`${ft(e)}-select-all`,className:"text-sm font-medium cursor-pointer",children:["Select all (",P.length,")"]}),d.jsxs("div",{className:"flex gap-1 ml-auto",children:[d.jsx(Zt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:E||F,onClick:()=>{r([...w]),n?.()},children:"Select all"}),d.jsx(Zt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:E||!N,onClick:()=>{r([]),n?.()},children:"Unselect all"})]})]}),P.length===0?d.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No items to display."}):d.jsx(d.Fragment,{children:P.map((C,I)=>{const W=Do(C,p),M=x.has(W),z=`${ft(e)}-${I}-${W}`;return d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 min-h-[2.5rem] hover:bg-muted/50 shrink-0",role:"row",children:[d.jsx(Yi,{id:z,checked:M,onCheckedChange:V=>k(C,V===!0),disabled:E,"aria-describedby":Lt(e,!!o)}),d.jsx(Pn,{htmlFor:z,className:"text-sm cursor-pointer flex-1 truncate",children:PT(C,l,g,m)})]},W)})})]}),P.length>0&&x.size===0&&d.jsxs("p",{className:"flex items-center gap-1.5 mt-2 text-sm text-amber-600 dark:text-amber-500 shrink-0",role:"status",children:[d.jsx(nS,{className:"h-4 w-4 shrink-0"}),"Please select at least one item."]})]})})})})},cy=({field:e,children:t,className:r})=>{const n=e.properties,o=n?.collapsible??!1,s=n?.defaultCollapsed??!1,i=n?.columns??1,[a,c]=v.useState(s),u=()=>{o&&c(!a)},f={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"};return d.jsxs("div",{className:H("border rounded-lg bg-card",r),children:[d.jsxs("div",{className:H("flex items-center gap-2 px-4 py-3 border-b bg-muted/50",o&&"cursor-pointer hover:bg-muted/70 transition-colors"),onClick:u,children:[o&&d.jsx("span",{className:"text-muted-foreground",children:a?d.jsx(Vu,{className:"h-4 w-4"}):d.jsx(ts,{className:"h-4 w-4"})}),d.jsx("h3",{className:"font-medium text-sm",children:e.label}),e.description&&d.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:e.description})]}),!a&&d.jsx("div",{className:H("p-4 grid gap-4",f[i]),children:t})]})};var IT=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],MT=IT.reduce((e,t)=>{const r=cl(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),LT="Separator",dy="horizontal",DT=["horizontal","vertical"],uy=b.forwardRef((e,t)=>{const{decorative:r,orientation:n=dy,...o}=e,s=BT(n)?n:dy,a=r?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return d.jsx(MT.div,{"data-orientation":s,...a,...o,ref:t})});uy.displayName=LT;function BT(e){return DT.includes(e)}var $T=uy;function Wc({className:e,orientation:t="horizontal",decorative:r=!0,...n}){return d.jsx($T,{"data-slot":"separator",decorative:r,orientation:t,className:H("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...n})}const jT=({field:e,className:t})=>d.jsx("div",{className:H("py-2",t),children:d.jsx(Wc,{})}),zT={h1:"text-3xl font-bold",h2:"text-2xl font-bold",h3:"text-xl font-semibold",h4:"text-lg font-semibold",h5:"text-base font-medium",h6:"text-sm font-medium"},UT=({field:e,className:t})=>{const r=e.properties,n=r?.headingLevel??"h3",o=r?.showHorizontalLine??!0,s=zT[n],i=n;return d.jsxs("div",{className:H("w-full min-w-0 space-y-1",t),children:[d.jsx(i,{className:H("m-0 text-foreground",s),children:e.label||"Header"}),e.description&&d.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),o&&d.jsx(Wc,{className:"w-full"})]})},VT={"top-left":"justify-start","top-center":"justify-center","top-right":"justify-end","middle-left":"justify-start",center:"justify-center","middle-right":"justify-end","bottom-left":"justify-start","bottom-center":"justify-center","bottom-right":"justify-end"},HT={h1:"text-3xl font-bold",h2:"text-2xl font-bold",h3:"text-xl font-semibold",h4:"text-lg font-semibold",h5:"text-base font-medium",h6:"text-sm font-medium"},WT=({field:e,className:t})=>{const r=e.properties,n=r?.position??"top-left",o=r?.headingLevel??"h3",s=r?.showHorizontalLine??!0,i=VT[n],a=HT[o],c=o;return d.jsxs("div",{className:H("w-full min-w-0 space-y-2",t),children:[d.jsx("div",{className:H("flex w-full",i),children:d.jsx(c,{className:H("m-0 text-foreground",a),children:e.label||"Section Heading"})}),s&&d.jsx(Wc,{className:"w-full"})]})},RT=({field:e,className:t})=>{const r=e.appearance?.size||"md",n={sm:"h-4",md:"h-8",lg:"h-12"};return d.jsx("div",{className:H(n[r],t),"aria-hidden":"true"})};function fy(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function GT(e){if(Array.isArray(e))return e}function KT(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,s,i,a=[],c=!0,u=!1;try{if(s=(r=r.call(e)).next,t!==0)for(;!(c=(n=s.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(f){u=!0,o=f}finally{try{if(!c&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return a}}function qT(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
51
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function YT(e,t){return GT(e)||KT(e,t)||XT(e,t)||qT()}function XT(e,t){if(e){if(typeof e=="string")return fy(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?fy(e,t):void 0}}const py=Object.entries,my=Object.setPrototypeOf,JT=Object.isFrozen,QT=Object.getPrototypeOf,ZT=Object.getOwnPropertyDescriptor;let dr=Object.freeze,Dr=Object.seal,Bo=Object.create,hy=typeof Reflect<"u"&&Reflect,Rc=hy.apply,Gc=hy.construct;dr||(dr=function(t){return t}),Dr||(Dr=function(t){return t}),Rc||(Rc=function(t,r){for(var n=arguments.length,o=new Array(n>2?n-2:0),s=2;s<n;s++)o[s-2]=arguments[s];return t.apply(r,o)}),Gc||(Gc=function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return new t(...n)});const $o=Vt(Array.prototype.forEach),eF=Vt(Array.prototype.lastIndexOf),gy=Vt(Array.prototype.pop),jo=Vt(Array.prototype.push),tF=Vt(Array.prototype.splice),ur=Array.isArray,Ts=Vt(String.prototype.toLowerCase),Kc=Vt(String.prototype.toString),yy=Vt(String.prototype.match),zo=Vt(String.prototype.replace),by=Vt(String.prototype.indexOf),rF=Vt(String.prototype.trim),nF=Vt(Number.prototype.toString),oF=Vt(Boolean.prototype.toString),vy=typeof BigInt>"u"?null:Vt(BigInt.prototype.toString),wy=typeof Symbol>"u"?null:Vt(Symbol.prototype.toString),Mt=Vt(Object.prototype.hasOwnProperty),Fs=Vt(Object.prototype.toString),rr=Vt(RegExp.prototype.test),ga=sF(TypeError);function Vt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return Rc(e,t,n)}}function sF(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return Gc(e,r)}}function tt(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ts;if(my&&my(e,null),!ur(t))return e;let n=t.length;for(;n--;){let o=t[n];if(typeof o=="string"){const s=r(o);s!==o&&(JT(t)||(t[n]=s),o=s)}e[o]=!0}return e}function iF(e){for(let t=0;t<e.length;t++)Mt(e,t)||(e[t]=null);return e}function gr(e){const t=Bo(null);for(const n of py(e)){var r=YT(n,2);const o=r[0],s=r[1];Mt(e,o)&&(ur(s)?t[o]=iF(s):s&&typeof s=="object"&&s.constructor===Object?t[o]=gr(s):t[o]=s)}return t}function aF(e){switch(typeof e){case"string":return e;case"number":return nF(e);case"boolean":return oF(e);case"bigint":return vy?vy(e):"0";case"symbol":return wy?wy(e):"Symbol()";case"undefined":return Fs(e);case"function":case"object":{if(e===null)return Fs(e);const t=e,r=so(t,"toString");if(typeof r=="function"){const n=r(t);return typeof n=="string"?n:Fs(n)}return Fs(e)}default:return Fs(e)}}function so(e,t){for(;e!==null;){const n=ZT(e,t);if(n){if(n.get)return Vt(n.get);if(typeof n.value=="function")return Vt(n.value)}e=QT(e)}function r(){return null}return r}function lF(e){try{return rr(e,""),!0}catch{return!1}}const Sy=dr(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),qc=dr(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Yc=dr(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),cF=dr(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Xc=dr(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),dF=dr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),xy=dr(["#text"]),Ay=dr(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Jc=dr(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Cy=dr(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),ya=dr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),uF=Dr(/{{[\w\W]*|^[\w\W]*}}/g),fF=Dr(/<%[\w\W]*|^[\w\W]*%>/g),pF=Dr(/\${[\w\W]*/g),mF=Dr(/^data-[\-\w.\u00B7-\uFFFF]+$/),hF=Dr(/^aria-[\-\w]+$/),Ey=Dr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),gF=Dr(/^(?:\w+script|data):/i),yF=Dr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),bF=Dr(/^html$/i),vF=Dr(/^[a-z][.\w]*(-[.\w]+)+$/i),Uo={element:1,text:3,progressingInstruction:7,comment:8,document:9},wF=function(){return typeof window>"u"?null:window},SF=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const o="data-tt-policy-suffix";r&&r.hasAttribute(o)&&(n=r.getAttribute(o));const s="dompurify"+(n?"#"+n:"");try{return t.createPolicy(s,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Ny=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ky(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:wF();const t=_e=>ky(_e);if(t.version="3.4.5",t.removed=[],!e||!e.document||e.document.nodeType!==Uo.document||!e.Element)return t.isSupported=!1,t;let r=e.document;const n=r,o=n.currentScript,s=e.DocumentFragment,i=e.HTMLTemplateElement,a=e.Node,c=e.Element,u=e.NodeFilter,f=e.NamedNodeMap,l=f===void 0?e.NamedNodeMap||e.MozNamedAttrMap:f,p=e.HTMLFormElement,g=e.DOMParser,m=e.trustedTypes,h=c.prototype,y=so(h,"cloneNode"),S=so(h,"remove"),w=so(h,"nextSibling"),A=so(h,"childNodes"),x=so(h,"parentNode"),F=a&&a.prototype?so(a.prototype,"nodeType"):null;if(typeof i=="function"){const _e=r.createElement("template");_e.content&&_e.content.ownerDocument&&(r=_e.content.ownerDocument)}let N,k="";const T=r,P=T.implementation,E=T.createNodeIterator,C=T.createDocumentFragment,I=T.getElementsByTagName,W=n.importNode;let M=Ny();t.isSupported=typeof py=="function"&&typeof x=="function"&&P&&P.createHTMLDocument!==void 0;const z=uF,V=fF,X=pF,D=mF,B=hF,L=gF,K=yF,ie=vF;let j=Ey,U=null;const le=tt({},[...Sy,...qc,...Yc,...Xc,...xy]);let oe=null;const G=tt({},[...Ay,...Jc,...Cy,...ya]);let ae=Object.seal(Bo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,ee=null;const ne=Object.seal(Bo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let he=!0,Ie=!0,Ue=!1,re=!0,ge=!1,Se=!0,pt=!1,Dt=!1,Bt=!1,Ot=!1,Ar=!1,kt=!1,Cr=!0,Xe=!1;const ve="user-content-";let ce=!0,J=!1,$={},fe=null;const st=tt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Te=null;const Ye=tt({},["audio","video","img","source","image","track"]);let Me=null;const Ce=tt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),nt="http://www.w3.org/1998/Math/MathML",qe="http://www.w3.org/2000/svg",dt="http://www.w3.org/1999/xhtml";let bt=dt,sr=!1,xt=null;const $e=tt({},[nt,qe,dt],Kc);let gt=tt({},["mi","mo","mn","ms","mtext"]),vt=tt({},["annotation-xml"]);const _t=tt({},["title","style","font","a","script"]);let yr=null;const ir=["application/xhtml+xml","text/html"],Er="text/html";let Et=null,Nr=null;const ar=r.createElement("form"),xn=function(O){return O instanceof RegExp||O instanceof Function},un=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Nr&&Nr===O)return;(!O||typeof O!="object")&&(O={}),O=gr(O),yr=ir.indexOf(O.PARSER_MEDIA_TYPE)===-1?Er:O.PARSER_MEDIA_TYPE,Et=yr==="application/xhtml+xml"?Kc:Ts,U=Mt(O,"ALLOWED_TAGS")&&ur(O.ALLOWED_TAGS)?tt({},O.ALLOWED_TAGS,Et):le,oe=Mt(O,"ALLOWED_ATTR")&&ur(O.ALLOWED_ATTR)?tt({},O.ALLOWED_ATTR,Et):G,xt=Mt(O,"ALLOWED_NAMESPACES")&&ur(O.ALLOWED_NAMESPACES)?tt({},O.ALLOWED_NAMESPACES,Kc):$e,Me=Mt(O,"ADD_URI_SAFE_ATTR")&&ur(O.ADD_URI_SAFE_ATTR)?tt(gr(Ce),O.ADD_URI_SAFE_ATTR,Et):Ce,Te=Mt(O,"ADD_DATA_URI_TAGS")&&ur(O.ADD_DATA_URI_TAGS)?tt(gr(Ye),O.ADD_DATA_URI_TAGS,Et):Ye,fe=Mt(O,"FORBID_CONTENTS")&&ur(O.FORBID_CONTENTS)?tt({},O.FORBID_CONTENTS,Et):st,Ae=Mt(O,"FORBID_TAGS")&&ur(O.FORBID_TAGS)?tt({},O.FORBID_TAGS,Et):gr({}),ee=Mt(O,"FORBID_ATTR")&&ur(O.FORBID_ATTR)?tt({},O.FORBID_ATTR,Et):gr({}),$=Mt(O,"USE_PROFILES")?O.USE_PROFILES&&typeof O.USE_PROFILES=="object"?gr(O.USE_PROFILES):O.USE_PROFILES:!1,he=O.ALLOW_ARIA_ATTR!==!1,Ie=O.ALLOW_DATA_ATTR!==!1,Ue=O.ALLOW_UNKNOWN_PROTOCOLS||!1,re=O.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ge=O.SAFE_FOR_TEMPLATES||!1,Se=O.SAFE_FOR_XML!==!1,pt=O.WHOLE_DOCUMENT||!1,Ot=O.RETURN_DOM||!1,Ar=O.RETURN_DOM_FRAGMENT||!1,kt=O.RETURN_TRUSTED_TYPE||!1,Bt=O.FORCE_BODY||!1,Cr=O.SANITIZE_DOM!==!1,Xe=O.SANITIZE_NAMED_PROPS||!1,ce=O.KEEP_CONTENT!==!1,J=O.IN_PLACE||!1,j=lF(O.ALLOWED_URI_REGEXP)?O.ALLOWED_URI_REGEXP:Ey,bt=typeof O.NAMESPACE=="string"?O.NAMESPACE:dt,gt=Mt(O,"MATHML_TEXT_INTEGRATION_POINTS")&&O.MATHML_TEXT_INTEGRATION_POINTS&&typeof O.MATHML_TEXT_INTEGRATION_POINTS=="object"?gr(O.MATHML_TEXT_INTEGRATION_POINTS):tt({},["mi","mo","mn","ms","mtext"]),vt=Mt(O,"HTML_INTEGRATION_POINTS")&&O.HTML_INTEGRATION_POINTS&&typeof O.HTML_INTEGRATION_POINTS=="object"?gr(O.HTML_INTEGRATION_POINTS):tt({},["annotation-xml"]);const te=Mt(O,"CUSTOM_ELEMENT_HANDLING")&&O.CUSTOM_ELEMENT_HANDLING&&typeof O.CUSTOM_ELEMENT_HANDLING=="object"?gr(O.CUSTOM_ELEMENT_HANDLING):Bo(null);if(ae=Bo(null),Mt(te,"tagNameCheck")&&xn(te.tagNameCheck)&&(ae.tagNameCheck=te.tagNameCheck),Mt(te,"attributeNameCheck")&&xn(te.attributeNameCheck)&&(ae.attributeNameCheck=te.attributeNameCheck),Mt(te,"allowCustomizedBuiltInElements")&&typeof te.allowCustomizedBuiltInElements=="boolean"&&(ae.allowCustomizedBuiltInElements=te.allowCustomizedBuiltInElements),ge&&(Ie=!1),Ar&&(Ot=!0),$&&(U=tt({},xy),oe=Bo(null),$.html===!0&&(tt(U,Sy),tt(oe,Ay)),$.svg===!0&&(tt(U,qc),tt(oe,Jc),tt(oe,ya)),$.svgFilters===!0&&(tt(U,Yc),tt(oe,Jc),tt(oe,ya)),$.mathMl===!0&&(tt(U,Xc),tt(oe,Cy),tt(oe,ya))),ne.tagCheck=null,ne.attributeCheck=null,Mt(O,"ADD_TAGS")&&(typeof O.ADD_TAGS=="function"?ne.tagCheck=O.ADD_TAGS:ur(O.ADD_TAGS)&&(U===le&&(U=gr(U)),tt(U,O.ADD_TAGS,Et))),Mt(O,"ADD_ATTR")&&(typeof O.ADD_ATTR=="function"?ne.attributeCheck=O.ADD_ATTR:ur(O.ADD_ATTR)&&(oe===G&&(oe=gr(oe)),tt(oe,O.ADD_ATTR,Et))),Mt(O,"ADD_URI_SAFE_ATTR")&&ur(O.ADD_URI_SAFE_ATTR)&&tt(Me,O.ADD_URI_SAFE_ATTR,Et),Mt(O,"FORBID_CONTENTS")&&ur(O.FORBID_CONTENTS)&&(fe===st&&(fe=gr(fe)),tt(fe,O.FORBID_CONTENTS,Et)),Mt(O,"ADD_FORBID_CONTENTS")&&ur(O.ADD_FORBID_CONTENTS)&&(fe===st&&(fe=gr(fe)),tt(fe,O.ADD_FORBID_CONTENTS,Et)),ce&&(U["#text"]=!0),pt&&tt(U,["html","head","body"]),U.table&&(tt(U,["tbody"]),delete Ae.tbody),O.TRUSTED_TYPES_POLICY){if(typeof O.TRUSTED_TYPES_POLICY.createHTML!="function")throw ga('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof O.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ga('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=O.TRUSTED_TYPES_POLICY,k=N.createHTML("")}else N===void 0&&(N=SF(m,o)),N!==null&&typeof k=="string"&&(k=N.createHTML(""));dr&&dr(O),Nr=O},$r=tt({},[...qc,...Yc,...cF]),zn=tt({},[...Xc,...dF]),$t=function(O){let te=x(O);(!te||!te.tagName)&&(te={namespaceURI:bt,tagName:"template"});const we=Ts(O.tagName),it=Ts(te.tagName);return xt[O.namespaceURI]?O.namespaceURI===qe?te.namespaceURI===dt?we==="svg":te.namespaceURI===nt?we==="svg"&&(it==="annotation-xml"||gt[it]):!!$r[we]:O.namespaceURI===nt?te.namespaceURI===dt?we==="math":te.namespaceURI===qe?we==="math"&&vt[it]:!!zn[we]:O.namespaceURI===dt?te.namespaceURI===qe&&!vt[it]||te.namespaceURI===nt&&!gt[it]?!1:!zn[we]&&(_t[we]||!$r[we]):!!(yr==="application/xhtml+xml"&&xt[O.namespaceURI]):!1},Ht=function(O){jo(t.removed,{element:O});try{x(O).removeChild(O)}catch{S(O)}},br=function(O,te){try{jo(t.removed,{attribute:te.getAttributeNode(O),from:te})}catch{jo(t.removed,{attribute:null,from:te})}if(te.removeAttribute(O),O==="is")if(Ot||Ar)try{Ht(te)}catch{}else try{te.setAttribute(O,"")}catch{}},Jr=function(O){let te=null,we=null;if(Bt)O="<remove></remove>"+O;else{const St=yy(O,/^[\r\n\t ]+/);we=St&&St[0]}yr==="application/xhtml+xml"&&bt===dt&&(O='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+O+"</body></html>");const it=N?N.createHTML(O):O;if(bt===dt)try{te=new g().parseFromString(it,yr)}catch{}if(!te||!te.documentElement){te=P.createDocument(bt,"template",null);try{te.documentElement.innerHTML=sr?k:it}catch{}}const wt=te.body||te.documentElement;return O&&we&&wt.insertBefore(r.createTextNode(we),wt.childNodes[0]||null),bt===dt?I.call(te,pt?"html":"body")[0]:pt?te.documentElement:wt},Yt=function(O){return E.call(O.ownerDocument||O,O,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},lr=function(O){O.normalize();const te=E.call(O.ownerDocument||O,O,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let we=te.nextNode();for(;we;){let it=we.data;$o([z,V,X],wt=>{it=zo(it,wt," ")}),we.data=it,we=te.nextNode()}},Un=function(O){return O instanceof p&&(typeof O.nodeName!="string"||typeof O.textContent!="string"||typeof O.removeChild!="function"||!(O.attributes instanceof l)||typeof O.removeAttribute!="function"||typeof O.setAttribute!="function"||typeof O.namespaceURI!="string"||typeof O.insertBefore!="function"||typeof O.hasChildNodes!="function")},$s=function(O){if(!F||typeof O!="object"||O===null)return!1;try{return typeof F(O)=="number"}catch{return!1}};function Tt(_e,O,te){$o(_e,we=>{we.call(t,O,te,Nr)})}const js=function(O){let te=null;if(Tt(M.beforeSanitizeElements,O,null),Un(O))return Ht(O),!0;const we=Et(O.nodeName);if(Tt(M.uponSanitizeElement,O,{tagName:we,allowedTags:U}),Se&&O.hasChildNodes()&&!$s(O.firstElementChild)&&rr(/<[/\w!]/g,O.innerHTML)&&rr(/<[/\w!]/g,O.textContent)||Se&&O.namespaceURI===dt&&we==="style"&&$s(O.firstElementChild)||O.nodeType===Uo.progressingInstruction||Se&&O.nodeType===Uo.comment&&rr(/<[/\w]/g,O.data))return Ht(O),!0;if(Ae[we]||!(ne.tagCheck instanceof Function&&ne.tagCheck(we))&&!U[we]){if(!Ae[we]&&jr(we)&&(ae.tagNameCheck instanceof RegExp&&rr(ae.tagNameCheck,we)||ae.tagNameCheck instanceof Function&&ae.tagNameCheck(we)))return!1;if(ce&&!fe[we]){const it=x(O)||O.parentNode,wt=A(O)||O.childNodes;if(wt&&it){const St=wt.length;for(let Wt=St-1;Wt>=0;--Wt){const Nt=y(wt[Wt],!0);it.insertBefore(Nt,w(O))}}}return Ht(O),!0}return O instanceof c&&!$t(O)||(we==="noscript"||we==="noembed"||we==="noframes")&&rr(/<\/no(script|embed|frames)/i,O.innerHTML)?(Ht(O),!0):(ge&&O.nodeType===Uo.text&&(te=O.textContent,$o([z,V,X],it=>{te=zo(te,it," ")}),O.textContent!==te&&(jo(t.removed,{element:O.cloneNode()}),O.textContent=te)),Tt(M.afterSanitizeElements,O,null),!1)},kr=function(O,te,we){if(ee[te]||Cr&&(te==="id"||te==="name")&&(we in r||we in ar))return!1;const it=oe[te]||ne.attributeCheck instanceof Function&&ne.attributeCheck(te,O);if(!(Ie&&!ee[te]&&rr(D,te))){if(!(he&&rr(B,te))){if(!it||ee[te]){if(!(jr(O)&&(ae.tagNameCheck instanceof RegExp&&rr(ae.tagNameCheck,O)||ae.tagNameCheck instanceof Function&&ae.tagNameCheck(O))&&(ae.attributeNameCheck instanceof RegExp&&rr(ae.attributeNameCheck,te)||ae.attributeNameCheck instanceof Function&&ae.attributeNameCheck(te,O))||te==="is"&&ae.allowCustomizedBuiltInElements&&(ae.tagNameCheck instanceof RegExp&&rr(ae.tagNameCheck,we)||ae.tagNameCheck instanceof Function&&ae.tagNameCheck(we))))return!1}else if(!Me[te]){if(!rr(j,zo(we,K,""))){if(!((te==="src"||te==="xlink:href"||te==="href")&&O!=="script"&&by(we,"data:")===0&&Te[O])){if(!(Ue&&!rr(L,zo(we,K,"")))){if(we)return!1}}}}}}return!0},Qr=tt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),jr=function(O){return!Qr[Ts(O)]&&rr(ie,O)},zr=function(O){Tt(M.beforeSanitizeAttributes,O,null);const te=O.attributes;if(!te||Un(O))return;const we={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:oe,forceKeepAttr:void 0};let it=te.length;for(;it--;){const wt=te[it],St=wt.name,Wt=wt.namespaceURI,Nt=wt.value,Ur=Et(St),Ho=Nt;let It=St==="value"?Ho:rF(Ho);if(we.attrName=Ur,we.attrValue=It,we.keepAttr=!0,we.forceKeepAttr=void 0,Tt(M.uponSanitizeAttribute,O,we),It=we.attrValue,Xe&&(Ur==="id"||Ur==="name")&&by(It,ve)!==0&&(br(St,O),It=ve+It),Se&&rr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,It)){br(St,O);continue}if(Ur==="attributename"&&yy(It,"href")){br(St,O);continue}if(we.forceKeepAttr)continue;if(!we.keepAttr){br(St,O);continue}if(!re&&rr(/\/>/i,It)){br(St,O);continue}ge&&$o([z,V,X],An=>{It=zo(It,An," ")});const fn=Et(O.nodeName);if(!kr(fn,Ur,It)){br(St,O);continue}if(N&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Wt)switch(m.getAttributeType(fn,Ur)){case"TrustedHTML":{It=N.createHTML(It);break}case"TrustedScriptURL":{It=N.createScriptURL(It);break}}if(It!==Ho)try{Wt?O.setAttributeNS(Wt,St,It):O.setAttribute(St,It),Un(O)?Ht(O):gy(t.removed)}catch{br(St,O)}}Tt(M.afterSanitizeAttributes,O,null)},_r=function(O){let te=null;const we=Yt(O);for(Tt(M.beforeSanitizeShadowDOM,O,null);te=we.nextNode();)Tt(M.uponSanitizeShadowNode,te,null),js(te),zr(te),te.content instanceof s&&_r(te.content);Tt(M.afterSanitizeShadowDOM,O,null)},Xt=function(O){if(O.nodeType===Uo.element&&O.shadowRoot instanceof s){const it=O.shadowRoot;Xt(it),_r(it)}const te=O.childNodes;if(!te)return;const we=[];$o(te,it=>{jo(we,it)});for(const it of we)Xt(it)};return t.sanitize=function(_e){let O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},te=null,we=null,it=null,wt=null;if(sr=!_e,sr&&(_e="<!-->"),typeof _e!="string"&&!$s(_e)&&(_e=aF(_e),typeof _e!="string"))throw ga("dirty is not a string, aborting");if(!t.isSupported)return _e;if(Dt||un(O),t.removed=[],typeof _e=="string"&&(J=!1),J){const Nt=_e.nodeName;if(typeof Nt=="string"){const Ur=Et(Nt);if(!U[Ur]||Ae[Ur])throw ga("root node is forbidden and cannot be sanitized in-place")}Xt(_e)}else if($s(_e))te=Jr("<!---->"),we=te.ownerDocument.importNode(_e,!0),we.nodeType===Uo.element&&we.nodeName==="BODY"||we.nodeName==="HTML"?te=we:te.appendChild(we),Xt(we);else{if(!Ot&&!ge&&!pt&&_e.indexOf("<")===-1)return N&&kt?N.createHTML(_e):_e;if(te=Jr(_e),!te)return Ot?null:kt?k:""}te&&Bt&&Ht(te.firstChild);const St=Yt(J?_e:te);for(;it=St.nextNode();)js(it),zr(it),it.content instanceof s&&_r(it.content);if(J)return ge&&lr(_e),_e;if(Ot){if(ge&&lr(te),Ar)for(wt=C.call(te.ownerDocument);te.firstChild;)wt.appendChild(te.firstChild);else wt=te;return(oe.shadowroot||oe.shadowrootmode)&&(wt=W.call(n,wt,!0)),wt}let Wt=pt?te.outerHTML:te.innerHTML;return pt&&U["!doctype"]&&te.ownerDocument&&te.ownerDocument.doctype&&te.ownerDocument.doctype.name&&rr(bF,te.ownerDocument.doctype.name)&&(Wt="<!DOCTYPE "+te.ownerDocument.doctype.name+`>
52
+ `+Wt),ge&&$o([z,V,X],Nt=>{Wt=zo(Wt,Nt," ")}),N&&kt?N.createHTML(Wt):Wt},t.setConfig=function(){let _e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};un(_e),Dt=!0},t.clearConfig=function(){Nr=null,Dt=!1},t.isValidAttribute=function(_e,O,te){Nr||un({});const we=Et(_e),it=Et(O);return kr(we,it,te)},t.addHook=function(_e,O){typeof O=="function"&&jo(M[_e],O)},t.removeHook=function(_e,O){if(O!==void 0){const te=eF(M[_e],O);return te===-1?void 0:tF(M[_e],te,1)[0]}return gy(M[_e])},t.removeHooks=function(_e){M[_e]=[]},t.removeAllHooks=function(){M=Ny()},t}var xF=ky();const AF=["a","b","br","div","em","h1","h2","h3","h4","h5","h6","i","img","li","ol","p","span","strong","table","tbody","td","th","thead","tr","u","ul"],CF=["href","target","rel","src","alt","title","class","style","colspan","rowspan"];function EF(e){return e?xF.sanitize(e,{ALLOWED_TAGS:[...AF],ALLOWED_ATTR:[...CF],ALLOW_DATA_ATTR:!1}):""}function NF(e,t,r=!1){return e.includes("{labelapi:")?e.replace(/\{labelapi:([^}]+)\}/g,(n,o)=>{const s=o.trim();if(s===""||t==null)return r?"":n;const i=Re(t,s);return i==null?r?"":n:String(i)}):e}function kF(e){return e&&e.replace(/\{api:[^}]*\}/gi,"").replace(/\{labelapi:[^}]*\}/gi,"").replace(/\{resp:[^}]*\}/gi,"").replace(/\{(?:ctx:|@)\w+\}/gi,"").replace(/\{documentId\}/gi,"").replace(/\{(\w+)\}/g,"")}const _y={sm:"text-sm",md:"text-base",lg:"text-lg"},Ty={h1:"text-4xl font-bold tracking-tight",h2:"text-3xl font-semibold tracking-tight",h3:"text-2xl font-semibold",h4:"text-xl font-semibold",h5:"text-lg font-medium",h6:"text-base font-medium"},Fy={normal:"font-normal",medium:"font-medium",bold:"font-bold"},ba={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"};function io(e){return e.properties??{}}function _F(e){const t=io(e);return t.textContent!==void 0?t.textContent:e.label??""}function TF(e){return io(e).textContent===void 0||e.appearance?.hideLabel?!1:!!e.label?.trim()}function FF(e){return e?.contentLayout==="paragraph"?"paragraph":"single"}function Qc(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:a}=t,c=Rr(e,r,n,o,s,i),u=NF(c,a,!0);return kF(u)}const PF=/\{api:[^}]+\}/,OF=/\{labelapi:[^}]+\}/;function Zc(e){return PF.test(e)}function ed(e){return OF.test(e)}function IF(e){const t=e.captionTemplate??"",r=e.descriptionTemplate??"",n=Zc(e.bodyTemplate)||Zc(t)||Zc(r),o=ed(e.bodyTemplate)||ed(t)||ed(r);return!!(n&&e.prepopulateLoading||o&&e.labelApiConfigPresent&&(e.labelApiLoading||e.labelApiResponse===void 0&&e.labelApiError==null))}function Py(e,t){const r=t??io(e),n=r.variant??"body",o=e.appearance?.size??"md",s=_y[o]??_y.md,i=r.fontWeight??"medium";return n!=="body"?H("m-0 text-foreground",Ty[n]??Ty.h3,r.fontWeight&&Fy[r.fontWeight],r.italic&&"italic",r.underline&&"underline",r.textAlign&&ba[r.textAlign]):H("m-0 text-foreground",s,Fy[i],r.italic&&"italic",r.underline&&"underline",r.textAlign&&ba[r.textAlign])}function MF(e,t){const r=(t??io(e)).variant??"body";return r==="body"?"p":r}function td(e){const t=[];let r=0,n="";const o=()=>{n&&(t.push({type:"text",value:n}),n="")},s=(i,a,c)=>{if(!e.startsWith(i,r))return!1;const u=e.indexOf(a,r+i.length);if(u===-1)return!1;o();const f=e.slice(r+i.length,u);return t.push({type:c,children:td(f)}),r=u+a.length,!0};for(;r<e.length;){if(e[r]==="\\"&&r+1<e.length){n+=e[r+1],r+=2;continue}s("**","**","bold")||s("__","__","underline")||s("*","*","italic")||s("_","_","italic")||(n+=e[r],r+=1)}return o(),t}function LF(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Oy(e){return e.map(t=>{if(t.type==="text")return LF(t.value);const r=Oy(t.children);return t.type==="bold"?`<strong class="font-bold">${r}</strong>`:t.type==="italic"?`<em class="italic">${r}</em>`:`<u class="underline">${r}</u>`}).join("")}function DF(e){return e?Oy(td(e)):""}function BF(e,t){return e?t==="markdown-lite"?DF(e):e:""}function Iy(e,t){return e.map((r,n)=>{const o=`${t}-${n}`;if(r.type==="text")return r.value?v.createElement(v.Fragment,{key:o},r.value):null;const s=Iy(r.children,o);return r.type==="bold"?v.createElement("strong",{key:o,className:"font-bold"},s):r.type==="italic"?v.createElement("em",{key:o,className:"italic"},s):v.createElement("u",{key:o,className:"underline"},s)})}function My(e,t){if(!e)return null;if(t!=="markdown-lite")return e;const r=td(e);return r.length===1&&r[0]?.type==="text"?r[0].value:Iy(r,"tl")}const $F="text-label-html prose prose-sm max-w-none [&_p]:m-0 [&_p+p]:mt-2 [&_ul]:my-1 [&_ol]:my-1";function Ly(e,t){if(!e)return null;const{field:r,asDescription:n=!1}=t,o=t.textProps??io(r),s=t.contentLayout??FF(o),i=o.inlineFormat??"none";if(s==="paragraph"){const c=EF(BF(e,i));if(!c)return null;const u=n?H("m-0 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&ba[o.textAlign]):H(Py(r,o),$F);return v.createElement("div",{className:u,dangerouslySetInnerHTML:{__html:c}})}if(n)return v.createElement("p",{className:H("mt-0.5 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&ba[o.textAlign])},My(e,i));const a=MF(r,o);return v.createElement(a,{className:Py(r,o)},My(e,i))}function jF(e){const t=e.labelApiEndpoint?.trim();return!e.labelApiEnabled||!t?null:{labelApiEndpoint:t,labelApiMethod:e.labelApiMethod??"GET",labelApiQueryParams:e.labelApiQueryParams,labelApiHeaders:e.labelApiHeaders,labelApiBodyFields:e.labelApiBodyFields}}async function zF(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o}=t,s=l=>Rr(l,r,n,o),i=(e.labelApiMethod??"GET").toUpperCase();let a=Mr(s(e.labelApiEndpoint));const c=e.labelApiQueryParams??[];if(c.length){const l=new URLSearchParams;c.forEach(({key:g,value:m})=>{g.trim()&&l.append(g,s(m))});const p=l.toString();p&&(a=`${a}${a.includes("?")?"&":"?"}${p}`)}const u={"Content-Type":"application/json"};(e.labelApiHeaders??[]).forEach(({key:l,value:p})=>{l.trim()&&(u[l]=s(p))});let f;i==="POST"&&(e.labelApiBodyFields??[]).length&&(f={},e.labelApiBodyFields.forEach(({key:l,value:p})=>{l.trim()&&(f[l]=s(p))}));try{return i==="POST"?(await Qt.post(a,f??{},{headers:Object.keys(u).length?u:void 0})).data:(await Qt.get(a,{headers:Object.keys(u).length?u:void 0})).data}catch(l){const p=l,g=p.response?.status,m=typeof p.response?.data=="string"?p.response.data:p.message??"Request failed";throw new Error(g?`HTTP ${g}: ${m}`:String(m))}}const UF=({field:e,className:t,formValues:r,urlParams:n,submissionContext:o,buttonResponses:s,prepopulateResponse:i,prepopulateLoading:a=!1})=>{const c=io(e),u=v.useMemo(()=>jF(io(e)),[e.properties]),[f,l]=v.useState(void 0),[p,g]=v.useState(!1),[m,h]=v.useState(null),y=v.useMemo(()=>u?JSON.stringify({endpoint:u.labelApiEndpoint,method:u.labelApiMethod,query:u.labelApiQueryParams,headers:u.labelApiHeaders,body:u.labelApiBodyFields}):"",[u]),S=v.useCallback(async()=>{if(!u){l(void 0),h(null),g(!1);return}g(!0),h(null);try{const I=await zF(u,{formValues:r??{},urlParams:n??{},submissionContext:o});l(I)}catch(I){l(void 0),h(I instanceof Error?I.message:"Failed to load label API")}finally{g(!1)}},[u,r,n,o]);v.useEffect(()=>{y&&S()},[y,S]);const w=c.textAlign==="center"?"items-center":c.textAlign==="right"?"items-end":c.textAlign==="justify"?"items-stretch":"items-start",A=_F(e),x=TF(e),F=x&&e.label?e.label:"",N=e.description??"",k=IF({bodyTemplate:A,captionTemplate:F,descriptionTemplate:N,prepopulateLoading:a,labelApiConfigPresent:u!=null,labelApiLoading:p,labelApiResponse:f,labelApiError:m}),T={formValues:r??{},urlParams:n??{},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:f},P=A?Qc(A,T):"",E=x&&e.label?Qc(e.label,T):"",C=N?Qc(N,T):"";return d.jsx("div",{className:H("w-full min-w-0 h-full min-h-[95px] flex flex-col justify-center py-0.5",w,t),children:k?d.jsx("p",{className:"text-sm text-muted-foreground m-0",children:"Loading…"}):d.jsxs(d.Fragment,{children:[m&&u?d.jsx("p",{className:"text-[10px] text-destructive mb-0.5",title:m,children:"Label API failed"}):null,E?d.jsx("div",{className:"text-sm font-medium text-foreground mb-1 w-full",children:E}):null,P?Ly(P,{field:e,textProps:c}):null,C?Ly(C,{field:e,textProps:c,asDescription:!0}):null]})})},rd=({legend:e,children:t,className:r,collapsible:n=!1,defaultCollapsed:o=!1,headerActions:s,onCollapsedChange:i})=>{const[a,c]=v.useState(o),u=v.useId(),f=l=>{l.stopPropagation(),n&&c(p=>{const g=!p;return i?.(g),g})};return d.jsxs("fieldset",{className:H("min-w-0 rounded-lg border bg-card p-4",r),"data-form-renderer":"config-section-border",children:[n?d.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2 border-b border-border pb-2",children:[d.jsxs("button",{type:"button",className:H("flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-medium text-foreground","cursor-pointer rounded-sm hover:bg-muted/70 transition-colors focus:outline-none focus:ring-2 focus:ring-ring"),"aria-expanded":!a,"aria-controls":u,onClick:f,children:[d.jsx("span",{className:"shrink-0 text-muted-foreground","aria-hidden":!0,children:a?d.jsx(Vu,{className:"h-4 w-4"}):d.jsx(ts,{className:"h-4 w-4"})}),d.jsx("span",{className:"truncate",children:e})]}),s!=null?d.jsx("div",{className:"shrink-0",children:s}):null]}):d.jsx("legend",{className:"px-1 text-sm font-medium text-foreground",children:e}),!a&&d.jsxs("div",{id:u,className:"space-y-3",children:[!n&&s!=null?d.jsx("div",{className:"flex justify-end",children:s}):null,t]})]})};function Dy(e){const t=e.properties,r=t?.apiEndpoint?{apiEndpoint:t.apiEndpoint,apiMethod:t.apiMethod,apiKey:t.apiKey,apiRealtime:t.apiRealtime,apiAutoDetect:t.apiAutoDetect,apiLabelField:t.apiLabelField,apiValueField:t.apiValueField,apiQueryParams:t.apiQueryParams,apiClientFilter:t.apiClientFilter,apiHeaders:t.apiHeaders,apiBodyFields:t.apiBodyFields,apiAuth:t.apiAuth,valueSource:t.valueSource,dependentFields:t.dependentFields}:null,n=e.apidata||null;return r||n}function nd(e){const t=Dy(e),r=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||r?.valueSource==="api"))}function By({field:e,formValues:t={},submissionContext:r,value:n,onChange:o,clearWhenBlocked:s=!0}){const i=e.properties,a=Dy(e),c=nd(e),[u,f]=v.useState(!1),[l,p]=v.useState(null),g=v.useRef(null),m=v.useRef(n);m.current=n;const h=v.useMemo(()=>{const F=a?.apiEndpoint||i?.apiEndpoint||"",N=a?.apiQueryParams||i?.apiQueryParams;return po(F,N)},[a?.apiEndpoint,i?.apiEndpoint,a?.apiQueryParams,i?.apiQueryParams]),y=v.useMemo(()=>{const F=new Set;for(const k of i?.dependentFields??a?.dependentFields??[])typeof k=="string"&&k.trim()&&F.add(k.trim());const N=a?.apiClientFilter?.matchField?.trim()||i?.apiClientFilter?.matchField?.trim();return N&&F.add(N),[...F]},[i?.dependentFields,a?.dependentFields,a?.apiClientFilter?.matchField,i?.apiClientFilter?.matchField]),S=v.useMemo(()=>{const F=new Set([...h,...y]);if(F.size===0)return null;const N={};return F.forEach(k=>{N[k]=t[k]}),JSON.stringify(N)},[h,y,t]),w=v.useMemo(()=>JSON.stringify(r||{}),[r]),A=v.useMemo(()=>{const F=new Set;e.name?.trim()&&F.add(e.name.trim());const N=e.key;return typeof N=="string"&&N.trim()&&F.add(N.trim()),[...F]},[e.name,e.key]),x=e.type==="number"?null:"";return v.useEffect(()=>{const F=a?.apiEndpoint;if(!c||!F)return;let N=!1;const k=P=>{if(N)return;const E=m.current;if(P==null||P.trim()===""){s&&E!==x&&E!==void 0&&(g.current=null,o(x));return}if(e.type==="number"){const C=Number(P),I=Number.isFinite(C)?C:null;E!==I&&g.current!==P&&(g.current=P,o(I));return}String(E??"")!==P&&g.current!==P&&(g.current=P,o(P))};return(async()=>{f(!0),p(null);try{const P=a?.apiMethod||i?.apiMethod||"GET",E=a?.apiRealtime||i?.apiRealtime,C=a?.apiQueryParams||i?.apiQueryParams||{},I=ti({apiEndpoint:F,apiMethod:P,apiQueryParams:C,formValues:t,submissionContext:r,apiRealtime:E,additionalRequiredFieldNames:y,excludeFormFieldNames:A});if(I.blocked){N||(f(!1),s&&k(null));return}const W={"Content-Type":"application/json"},M=a?.apiKey||i?.apiKey;M&&(W["X-CSCAPI-KEY"]=M);const z=e.apidata,V=a?.apiAuth??i?.apiAuth??z?.apiAuth??vs(a?.apiHeaders??i?.apiHeaders??z?.apiHeaders)??{type:"none"},X=ws(V,{formValues:t,submissionContext:r,apiRealtime:E});Object.assign(W,X);const D=a?.apiHeaders??i?.apiHeaders??z?.apiHeaders,B=a?.apiBodyFields??i?.apiBodyFields??z?.apiBodyFields,L=vn(bs(D),{formValues:t,submissionContext:r,apiRealtime:E});Object.assign(W,L);const K=vn(B,{formValues:t,submissionContext:r,apiRealtime:E}),ie={method:P.toLowerCase(),url:Mr(I.url),headers:W};(I.postBodyBase!=null||Object.keys(K).length>0)&&(ie.data={...I.postBodyBase??{},...K});const j=await Ct(ie),U=a?.apiLabelField||i?.apiLabelField,le=a?.apiValueField||i?.apiValueField,oe=a?.apiClientFilter||i?.apiClientFilter;let G=BE(j.data,le,U);if(oe?.filterField&&oe?.matchField&&G!=null){const ae=t[oe.matchField];if(ae==null)G=null;else{const Ae=ys(j.data,U,le),ee=Array.isArray(j.data)?j.data:j.data?.data?.data&&Array.isArray(j.data.data.data)?j.data.data.data:j.data?.data&&Array.isArray(j.data.data)?j.data.data:[],ne=Ae.filter(he=>{const Ie=ee.find(re=>String(Ut(re,le||"code"))===String(he.value));if(!Ie)return!1;const Ue=Ut(Ie,oe.filterField);return String(Ue)===String(ae)});G=ne.length>0?ne[0].value:null}}N||k(G)}catch(P){if(N)return;let E="Failed to load value";const C=P;if(C.response){const I=C.response.data;if(C.response.status===404)E="API endpoint not found.";else if(C.response.status===401)E="Authentication failed.";else if(typeof I=="string")E=I;else if(I&&typeof I=="object"){const W=I;E=W.error||W.message||W.detail||E}}else C.message&&(E=String(C.message));p(E)}finally{N||f(!1)}})(),()=>{N=!0}},[c,a?.apiEndpoint,a?.apiMethod,a?.apiValueField,a?.apiLabelField,i?.apiEndpoint,i?.apiMethod,i?.apiValueField,i?.apiLabelField,S,y,A,w,e.type,s,x]),{isLoading:u,error:l}}const VF=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:s,readOnly:i,...a})=>{const{isLoading:c}=By({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return d.jsx(si,{field:e,value:t||"",onChange:r,disabled:s||c,readOnly:i||c,...a})},HF=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:s,readOnly:i,...a})=>{const{isLoading:c}=By({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return d.jsx(dl,{field:e,value:t??null,onChange:r,disabled:s||c,readOnly:i||c,...a})},Sn=({field:e,value:t,error:r,onChange:n,onBlur:o,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u={},submissionContext:f,onSubmit:l,onReset:p,onCancel:g,isSubmitting:m,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:S,buttonResponses:w,onButtonApiResponse:A,onValidateForm:x,getValidationErrors:F,allFields:N,onSubmittingChange:k,onAddMore:T,scopedFormValues:P,scopedFieldNameMap:E,excludedOptionValues:C,prepopulateMappedFieldNames:I,fieldValueKey:W,hideTableRowControls:M=!1,urlParams:z={},prepopulateResponse:V=null,prepopulateLoading:X=!1,formSections:D,submitPayload:B})=>{switch(e.type){case"divider":return d.jsx(jT,{field:e,className:c});case"header":return d.jsx(UT,{field:e,className:c});case"sectionHeading":return d.jsx(WT,{field:e,className:c});case"spacer":return d.jsx(RT,{field:e,className:c});case"textLabel":return d.jsx(UF,{field:e,className:c,formValues:u,urlParams:z,submissionContext:f,buttonResponses:w,prepopulateResponse:V??void 0,prepopulateLoading:X});case"status":return d.jsx(FT,{field:e,value:t??null,error:r,disabled:s,isRequired:a,className:c,formValues:u,submissionContext:f,extraSubmitPayload:S,prepopulateResponse:V})}switch(e.type){case"text":case"password":case"url":return e.type==="text"&&nd(e)?d.jsx(VF,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f}):d.jsx(si,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"number":return nd(e)?d.jsx(HF,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f}):d.jsx(dl,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"email":return d.jsx(qu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"phone":case"aadhaar":return d.jsx(Yu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"otp":return d.jsx(Rf,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,urlParams:z,submissionContext:{...typeof f=="object"&&f!==null?f:{},...S??{}},prepopulateResponse:V});case"textarea":case"richtext":return d.jsx(Gf,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"select":{const L=W??e.name??e.key??e.id,K=!!(L&&I?.has(L));return d.jsx(Fm,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,formValues:u,submissionContext:f,excludedOptionValues:C,isPrepopulateTarget:K})}case"multiselect":{const L=Array.isArray(t)?t:t!=null&&t!==""?[String(t)]:[];return d.jsx(bh,{field:e,value:L,onChange:K=>n(K),onBlur:o,error:r,disabled:s,isRequired:a,className:c,formValues:u,submissionContext:f,excludedOptionValues:C})}case"asyncsearch":return d.jsx(Ym,{field:e,value:t,onChange:L=>n(L),onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f});case"checkbox":case"terms":return d.jsx(vh,{field:e,value:t||!1,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c});case"toggle":return d.jsx(qN,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c});case"radio":case"checkboxgroup":return d.jsx(Rh,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,excludedOptionValues:C});case"selectablelist":{const L=Array.isArray(t)?t:[];return console.log("[SelectableList] FieldRenderer: passing to SelectableListField",{fieldName:e.name,value:L,valueLength:L.length,submissionContextKeys:f?Object.keys(f):[]}),d.jsx(OT,{field:e,value:L,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,submissionContext:f})}case"date":case"time":case"datetime":case"daterange":return d.jsx(Gh,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"file":return d.jsx(vk,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,buttonResponses:w});case"camera":return d.jsx(Kk,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c});case"photoChoice":return d.jsx(qk,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,buttonResponses:w});case"signature":return d.jsx(nT,{field:e,value:t||null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"rating":return d.jsx(L_,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"slider":return d.jsx(rT,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"table":return d.jsx(oT,{field:e,value:t||[],onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,hideRowControls:M,formValues:u,submissionContext:f});case"billingGrid":return d.jsx(TT,{field:e,value:t||{rows:[]},onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f});case"button":return d.jsx(E_,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,onSubmit:l,onReset:p,onCancel:g,isSubmitting:m,formValues:u,submissionContext:f,buttonResponses:w,onButtonApiResponse:A,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:S,onValidateForm:x,getValidationErrors:F,allFields:N,onSubmittingChange:k,scopedFormValues:P,scopedFieldNameMap:E,prepopulateResponse:V,formSections:D,submitPayload:B});case"editButton":return d.jsx(N_,{field:e,disabled:s,readOnly:i,isRequired:a,className:c,buttonResponses:w,onButtonApiResponse:A});case"addmore":return d.jsx(k_,{field:e,error:r,disabled:s,readOnly:i,isRequired:a,className:c,onAddMore:()=>T?.(e)});case"customizeSections":return d.jsx(M_,{field:e,error:r,disabled:s,readOnly:i,isRequired:a,className:c});default:return d.jsx("div",{className:"p-3 border rounded-md bg-muted/50",children:d.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unsupported field type: ",e.type]})})}};function Ps(e){if(!e)return e;const t={...e};return e._id&&!e.id&&(t.id=e._id),delete t._id,t.formDefinitionId&&typeof t.formDefinitionId=="object"&&(t.formDefinitionId=t.formDefinitionId._id||t.formDefinitionId.id||t.formDefinitionId),t}function $y(e){return Array.isArray(e)?e.map(Ps):[]}function WF(e){const t=!!e.standalone_form;if(!e.moduleId&&!t)throw new Error(`Form response missing required field: moduleId. Form ID: ${e._id||e.id}. Please ensure the backend returns moduleId when fetching forms.`);if(!e._id&&!e.id)throw new Error("Form response missing required field: id. Please ensure the backend returns _id or id when fetching forms.");let r;e.moduleId&&(typeof e.moduleId=="object"&&e.moduleId._id?r=Ps(e.moduleId):r=e.moduleId);const n=e.isDefault??!1;if(!n&&!e.tenantId&&!t)throw new Error(`Form response missing required field: tenantId. Form ID: ${e._id||e.id}. Please ensure the backend returns tenantId when fetching non-default forms.`);return{id:e._id||e.id,name:e.name,description:e.description||"",version:e.version??1,status:e.status||"draft",category:e.category||"",createdAt:e.createdAt||new Date().toISOString(),updatedAt:e.updatedAt||e.createdAt||new Date().toISOString(),createdBy:e.createdBy||"",isActive:e.isActive??!0,isDefault:n,...r!==void 0&&{moduleId:r},tenantId:e.tenantId||void 0,featureId:e.featureId,config:e.config??void 0,standalone_form:t}}class RF{basePath="/api/form-builder/forms";async getForRendering(t,r){if(!nn())throw new Error("Client ID is required");const o=r!==void 0?`${this.basePath}/${t}/render?version=${r}`:`${this.basePath}/${t}/render`,s=await Qt.get(o),i=s.data?.data||s.data,a=i?.BFF_submit_api||i?.bff_submit_api||s.data?.BFF_submit_api||s.data?.bff_submit_api,c=i.form||i,u=!!(c.standalone_form??i.form?.standalone_form);if(!c.moduleId&&!i.form?.moduleId&&!u)throw new Error(`Form response missing required field: moduleId. Form ID: ${t}. Please ensure the backend returns moduleId in the form response.`);if(!(c.isDefault??i.form?.isDefault??!1)&&!c.tenantId&&!i.form?.tenantId&&!u)throw new Error(`Form response missing required field: tenantId. Form ID: ${t}. Please ensure the backend returns tenantId for non-default forms.`);i.form?.moduleId&&!c.moduleId&&(c.moduleId=i.form.moduleId),i.form?.tenantId&&!c.tenantId&&(c.tenantId=i.form.tenantId),i.form?.isDefault!==void 0&&c.isDefault===void 0&&(c.isDefault=i.form.isDefault);const l=WF(c);i.form?.moduleId&&(typeof i.form.moduleId=="object"&&i.form.moduleId._id?l.moduleId=Ps(i.form.moduleId):typeof i.form.moduleId=="string"&&(l.moduleId=i.form.moduleId));const p=$y(i.fields||[]),g=i.layout?Ps(i.layout):null,m=$y(i.rules||[]),h=i.module?Ps(i.module):void 0,y=i.clientMapping||i.clientOverrides;return{form:l,fields:p,layout:g,rules:m,module:h,clientMapping:y,clientOverrides:y,BFF_submit_api:a||void 0}}}const GF=new RF,KF={submitAction:"database",autoSave:!0,autoSaveInterval:30,showProgressBar:!0,allowDraft:!0,validateOnChange:!1,validateOnBlur:!0,showFieldErrors:"inline",layout:"default",submitButtonText:"Submit",resetButtonText:"Reset",showReset:!1,successMessage:"Form submitted successfully!",errorMessage:"An error occurred. Please try again."},qF=300;function YF(){return{...KF}}function XF(e){if(!e||typeof e!="object")return;const t=e,r=t.user_type??t.visibleToUserType??"",n=t.user_role??t.visibleToUserRole??"",o=Array.isArray(t.users)?t.users:Array.isArray(t.visibleToUserIds)?t.visibleToUserIds:[];if(!(r!=null&&r!==""||n!=null&&n!==""||o.length>0))return;const i={};return r!=null&&r!==""&&(i.visibleToUserType=r),n!=null&&n!==""&&(i.visibleToUserRole=n),o.length>0&&(i.visibleToUserIds=o),i}function JF(e){const t=YF();if(!e||typeof e!="object")return t;const r=e;return{...t,submitAction:r.submitAction||t.submitAction,apiEndpoint:r.apiEndpoint,dbTable:r.dbTable,emailTo:r.emailTo,workflowTrigger:r.workflowTrigger,workflowSubmissionConfig:r.workflowSubmissionConfig,prepopulateApi:r.prepopulateApi,prepopulateResponseRules:r.prepopulateResponseRules??void 0,sections:w_(r.sections),submitPayload:v_(r.submitPayload),autoSave:r.autoSave,autoSaveInterval:r.autoSaveInterval,showProgressBar:r.showProgressBar,allowDraft:r.allowDraft,validateOnChange:r.validateOnChange,validateOnBlur:r.validateOnBlur,showFieldErrors:r.showFieldErrors,layout:r.layout,submitButtonText:r.submitButtonText,resetButtonText:r.resetButtonText,showReset:r.showReset,successMessage:r.successMessage,successRedirect:r.successRedirect,errorMessage:r.errorMessage}}function Os(e,t,r,n){const o=t.map(l=>{let p=[],g={};try{l.options&&(p=JSON.parse(l.options)),l.metadata&&(g=JSON.parse(l.metadata))}catch{}const m=vu(l);m&&Object.assign(g,m),p.length>0&&(g.options=p);const h=[];if(l.validationRequired&&h.push({type:"required",message:"This field is required"}),l.validationMinLength!==null&&l.validationMinLength!==void 0&&h.push({type:"minLength",value:l.validationMinLength,message:`Minimum length is ${l.validationMinLength}`}),l.validationMaxLength!==null&&l.validationMaxLength!==void 0&&h.push({type:"maxLength",value:l.validationMaxLength,message:`Maximum length is ${l.validationMaxLength}`}),l.validationPattern&&h.push({type:"pattern",value:l.validationPattern,message:"Invalid format"}),l.validationRules&&typeof l.validationRules=="object"){const j=l.validationRules;if(j.required===!0&&!h.some(U=>U.type==="required")&&h.push({type:"required",message:"This field is required"}),j.allowLetters!==void 0&&h.push({type:"allowLetters",value:j.allowLetters}),j.allowNumbers!==void 0&&h.push({type:"allowNumbers",value:j.allowNumbers}),j.allowSpecialChars!==void 0&&h.push({type:"allowSpecialChars",value:j.allowSpecialChars}),j.minLetters!==void 0&&typeof j.minLetters=="number"&&h.push({type:"minLetters",value:j.minLetters}),j.maxLetters!==void 0&&typeof j.maxLetters=="number"&&h.push({type:"maxLetters",value:j.maxLetters}),j.minNumbers!==void 0&&typeof j.minNumbers=="number"&&h.push({type:"minNumbers",value:j.minNumbers}),j.maxNumbers!==void 0&&typeof j.maxNumbers=="number"&&h.push({type:"maxNumbers",value:j.maxNumbers}),j.minSpecialChars!==void 0&&typeof j.minSpecialChars=="number"&&h.push({type:"minSpecialChars",value:j.minSpecialChars}),j.maxSpecialChars!==void 0&&typeof j.maxSpecialChars=="number"&&h.push({type:"maxSpecialChars",value:j.maxSpecialChars}),j.fileSize!==void 0&&typeof j.fileSize=="number"){const U=j.fileSize/1048576;h.push({type:"fileSize",value:j.fileSize,message:`File size must be less than ${U.toFixed(2)} MB`})}if(j.fileType!==void 0){const U=Array.isArray(j.fileType)?j.fileType:typeof j.fileType=="string"?j.fileType.split(",").map(le=>le.trim()).filter(Boolean):[];U.length>0&&h.push({type:"fileType",value:U,message:"File type is not allowed"})}}const y=[],S=new Set;n.filter(j=>{const U=typeof j.targetFieldId=="object"?j.targetFieldId.id||j.targetFieldId._id:j.targetFieldId;return!!(U===l.id||U===l._id||U&&l.fieldKey&&U===l.fieldKey)}).forEach(j=>{try{const U=JSON.parse(j.conditionExpression);!U.id&&j.id&&(U.id=j.id);const le=typeof j.targetFieldId=="object"?j.targetFieldId?.id||j.targetFieldId?._id:j.targetFieldId;U.action&&(!U.then||!Array.isArray(U.then)||U.then.length===0)&&(U.then=[{action:U.action,...le&&{target:le}}]),(!U.then||!Array.isArray(U.then)||U.then.length===0)&&j.action&&(U.then=[{action:j.action,...le&&{target:le}}]),U.then&&Array.isArray(U.then)&&le&&(U.then=U.then.map(G=>!G.target&&le?{...G,target:le}:G));const oe=j.conditionExpression||JSON.stringify(U);if(S.has(oe))return;S.add(oe),y.push(U)}catch{}});const A=l.disabled===!0||g?.disabled===!0||!1;let x=l.readOnly===!0||g?.readOnly===!0||!1;const F=l.hidden===!0||g?.hidden===!0||!1;(g?.valueSource==="calculated"||g?.formula)&&(x=!0);const{disabled:N,readOnly:k,hidden:T,...P}=g,E={};P.hideLabel!==void 0&&(E.hideLabel=P.hideLabel),P.labelPosition!==void 0&&(E.labelPlacement=P.labelPosition),P.size!==void 0&&(E.size=P.size),P.customClass!==void 0&&(E.className=P.customClass);const{labelPosition:C,size:I,customClass:W,visibility:M,...z}=P,V=Object.keys(z).length>0?z:void 0,X=Object.keys(E).length>0?E:void 0,D=l.visibility??g?.visibility??M;let B=XF(D);if(D&&!B){const j=D;(j.visibleToUserType!=null||j.visibleToUserRole!=null||Array.isArray(j.visibleToUserTypes)&&j.visibleToUserTypes.length>0||Array.isArray(j.visibleToUserRoles)&&j.visibleToUserRoles.length>0||Array.isArray(j.visibleToUserIds)&&j.visibleToUserIds.length>0||Array.isArray(j.hiddenFromUserIds)&&j.hiddenFromUserIds.length>0)&&(B={visibleToUserType:j.visibleToUserType??(Array.isArray(j.visibleToUserTypes)?j.visibleToUserTypes[0]:void 0),visibleToUserRole:j.visibleToUserRole??(Array.isArray(j.visibleToUserRoles)?j.visibleToUserRoles[0]:void 0),visibleToUserIds:j.visibleToUserIds,hiddenFromUserIds:j.hiddenFromUserIds})}const L=g?.columnName,ie=!!l.parentFieldId&&typeof L=="string"?L:l.fieldKey;return{id:l.id,type:l.fieldType,name:ie,label:l.label,description:l.helpText||void 0,placeholder:l.placeholder||void 0,defaultValue:l.defaultValue||void 0,position:{order:typeof l.positionOrder=="number"?l.positionOrder:l.positionRow??0,column:typeof l.positionColumn=="number"?l.positionColumn:1,columnSpan:typeof l.positionWidth=="number"?l.positionWidth:1},parentId:void 0,appearance:X,validation:h.length>0?h:void 0,conditions:y.length>0?y:void 0,properties:V,visibility:B&&(B.visibleToUserType!=null||B.visibleToUserRole!=null||Array.isArray(B.visibleToUserIds)&&B.visibleToUserIds.length>0||Array.isArray(B.hiddenFromUserIds)&&B.hiddenFromUserIds.length>0)?B:void 0,disabled:A,readOnly:x,hidden:F}});o.forEach((l,p)=>{if(l.visibility){const g=t[p];console.log("[backendToFormSchema] field with visibility",{fieldKey:g?.fieldKey??l.name,name:l.name,type:l.type,parentFieldId:g?.parentFieldId,visibility:l.visibility})}});const s=t;for(let l=0;l<o.length;l++){const p=s[l]?.parentFieldId;if(p){const g=o.find(h=>h.id===p||h.type==="table"&&h.name===p||h.type==="table"&&s[l].fieldKey?.startsWith?.(h.name+"_column_")),m=o[l];if(g&&g.type==="table"&&m){const h=g.properties||{};Array.isArray(h.columns)||(h.columns=[]),h.columns.push(m),g.properties=h}}}const i=o.filter((l,p)=>!s[p]?.parentFieldId);for(const l of i)if(l.type==="table"&&l.properties&&Array.isArray(l.properties.columns)){const p=l.properties.columns;for(const g of p){const m=g.properties?.columnName;typeof m=="string"&&(g.name=m)}p.sort((g,m)=>(g.position?.order??0)-(m.position?.order??0)||(g.position?.column??0)-(m.position?.column??0))}let a;const c=e.config;if(console.log("[Prepopulate] backendToFormSchema config",{formId:e.id,hasRawConfig:c!=null,rawConfigType:typeof c,rawConfigPreview:c!=null?typeof c=="string"?c.slice(0,300):JSON.stringify(c).slice(0,300):null}),c!=null)try{const l=typeof c=="string"?JSON.parse(c):c;l&&typeof l=="object"?a=JF(l):a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"}}catch{a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"}}else a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};const u=Hs(r);u&&(a={...a,grid:u});const f=typeof e.moduleId=="string"?e.moduleId:e.moduleId?.id;return{id:e.id,name:e.name,description:e.description,version:e.version,status:e.status,config:a,fields:i,createdAt:e.createdAt,updatedAt:e.updatedAt,createdBy:e.createdBy,category:e.category,...f?{moduleId:f}:{},standalone_form:e.standalone_form,tenantId:e.tenantId,featureId:e.featureId,isDefault:e.isDefault}}const QF=new Set(["PENDING_PAYMENT","PAYMENT_PENDING","AWAITING_PAYMENT","PAID","PAYMENT_COMPLETED","PAYMENT_FAILED","REFUNDED","AUTHORIZED","CAPTURED","PARTIALLY_PAID"].map(e=>e.toUpperCase()));function od(e){return typeof e=="string"&&e.trim()!==""}function sd(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;const t=e;if(t.payment_type!=null&&t.payment_type!==""||t.payment_mode!=null&&t.payment_mode!==""||t.transaction_id!=null&&String(t.transaction_id).trim()!==""||t.payment_status!=null&&String(t.payment_status).trim()!==""||typeof t.amount=="number"||od(t.amount)||typeof t.total_amount=="number"||od(t.total_amount)||od(t.currency)||t.gateway!=null&&String(t.gateway).trim()!==""||t.razorpay_order_id!=null&&String(t.razorpay_order_id).trim()!==""||t.stripe_payment_intent!=null&&String(t.stripe_payment_intent).trim()!=="")return!0;const r=t.status;return!!(typeof r=="string"&&QF.has(r.trim().toUpperCase()))}function ZF(e){const t=Re(e,"data.items");if(!Array.isArray(t)||t.length===0)return;const r=t[0];if(r==null||typeof r!="object")return;const n=r;if(!(n.id===void 0||n.id===null||n.id===""))return{item:n,id:n.id}}function eP(e,t){const r=ZF(e);if(!r)return;const n=Re(e,"data"),o=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(t?.treatFirstItemIdAsPaymentId===!0||sd(r.item)||o!=null&&sd(o))return r.id}function tP(e){const t=e.properties,r=e.metadata;return[t?.uploadApiEndpoint,t?.apiEndpoint,r?.uploadApiEndpoint,r?.apiEndpoint].filter(o=>typeof o=="string"&&o.length>0)}function rP(e){return tP(e).some(t=>t.toLowerCase().includes("payment"))}function nP(e){const t=e.properties,r=e.metadata;return!!(t?.mergeSuccessDataIdAsPaymentId||r?.mergeSuccessDataIdAsPaymentId)}function oP(e,t){if(t?.type!=="button"||!Qo(e))return;const r=Re(e,"data.id");if(r==null||String(r).trim()==="")return;const n=Re(e,"data");if(nP(t)||n!=null&&typeof n=="object"&&!Array.isArray(n)&&sd(n)||rP(t))return r}const sP=new Set(["section","group","columns","divider","header","sectionHeading","spacer","addmore","textLabel","customizeSections"]);function iP(e,t){if(!e.length||!t?.length)return[];const r=new Map(t.map(o=>[o.id,o])),n=[];for(const o of e){const s=r.get(o);if(s?.fieldNames?.length)for(const i of s.fieldNames)i&&!n.includes(i)&&n.push(i)}return n}function aP(e,t){const r=e.properties,n=Array.isArray(r?.linkedFieldNames)?r.linkedFieldNames:[],o=iP(Array.isArray(r?.linkedSectionIds)?r.linkedSectionIds:[],t),s=new Set,i=[];for(const a of[...n,...o])!a||s.has(a)||(s.add(a),i.push(a));return i}function jy(e,t){const r=e.properties,n=Array.isArray(r?.linkedSectionIds)?r.linkedSectionIds:[];if(!n.length||!t?.length)return[];const o=new Map(t.map(s=>[s.id,s]));return n.map(s=>o.get(s)).filter(s=>!!s)}function lP(e,t){return jy(e,t).find(r=>r.heading?.enabled)}function zy(e,t){const r=e.template??"";return(e.mode??"increment")==="fixed"?r:r.replace(/\{n\}/g,String(t+1))}function Uy(e,t,r,n){const o=aP(e,r);if(o.length===0)return[];const s=new Set(o);return t.filter(i=>{const a=n(i);return!a||i.id===e.id||sP.has(i.type)?!1:s.has(a)})}function cP(e,t,r){if(e.type!=="sectionHeading"||!t?.length)return;const n=r(e);if(n)for(const o of t){const s=o.heading;if(s?.enabled&&s.headingFieldName===n)return s}}function id(e){return[...e].sort((t,r)=>{const n=t.position?.order??0,o=r.position?.order??0;if(n!==o)return n-o;const s=t.position?.column??1,i=r.position?.column??1;return s-i})}function dP(e,t,r){if(!e?.length)return[];const n=e.filter(i=>i.showBorder===!0);if(n.length===0)return[];const o=new Map;for(const i of t){const a=r(i);a&&o.set(a,i)}const s=[];for(const i of n){const a=i.fieldNames.map(u=>o.get(u)).filter(u=>!!u);if(a.length===0)continue;const c=id(a).map(u=>r(u)).filter(Boolean);s.push({section:i,fieldNames:c})}return s}function Is(e,t=0){return e.heading?.enabled?zy(e.heading,t):e.name}function Vy(e,t,r){if(e.type!=="sectionHeading")return!1;const n=t.heading;return!n?.enabled||!n.headingFieldName?!1:r(e)===n.headingFieldName}function uP(e,t){const r=typeof e.position?.order=="number"?e.position.order:0,n=(e.position?.column??1)-1,o=qo(e),s=Jd(e,t);return{row:r,col:n,rowEnd:r+o-1,colEnd:n+s-1}}function ad(e,t){let r=1/0,n=-1/0,o=1/0,s=-1/0;for(const i of e){const{row:a,col:c,rowEnd:u,colEnd:f}=uP(i,t);r=Math.min(r,a),n=Math.max(n,u),o=Math.min(o,c),s=Math.max(s,f)}return Number.isFinite(r)?{minRow:r,maxRow:n,minCol:o,maxCol:s,rowSpan:n-r+1,colSpan:s-o+1}:null}function fP(e,t,r,n){const o=e.map(f=>t.find(l=>n(l)===f)).filter(f=>!!f&&typeof f.position?.order=="number");if(o.length===0)return null;const s=ad(o,r);if(!s)return null;const i=o.filter(f=>f.type!=="sectionHeading"),a=i.length>0?i:o,c=Math.min(...a.map(f=>f.position?.order??0)),u=Math.max(1,...a.map(f=>(f.position?.order??c)-c+qo(f)));return{minRow:s.minRow,maxRow:s.maxRow,minCol:s.minCol,maxCol:s.maxCol,blockHeight:u}}function pP(e,t){return e.maxRow+1+t*e.blockHeight}function mP(e,t,r,n){const o=new Map;for(const a of t){const c=r(a);c&&o.set(c,a)}const s=new Map,i=new Set;for(const a of e){const c=a.fieldNames.map(w=>o.get(w)).filter(w=>!!w);if(c.length===0)continue;const u=c.filter(w=>!Vy(w,a.section,r)),f=ad(c,n);if(!f)continue;const{minRow:l,minCol:p,rowSpan:g,colSpan:m}=f,h=`${l}-${p}`;if(s.has(h))continue;const y=new Set;let S=!1;for(let w=l;w<=l+g-1;w++){for(let A=p;A<=p+m-1;A++){const x=`${w}-${A}`;if(i.has(x)){S=!0;break}y.add(x)}if(S)break}if(!S){for(const w of y)i.add(w);s.set(h,{anchorRow:l,anchorCol:p,rowSpan:g,colSpan:m,run:a,legend:Is(a.section,0),renderFields:u.length>0?u:c})}}return{anchorsByOrigin:s,coveredCells:i}}function hP(e,t,r,n,o,s,i){const a=new Set(i),c=new Map;for(const u of e){const f=Hy(u.linkedFields.map(p=>s(p)).filter(Boolean),t),l=f?.section;l?.fieldNames?.length?l.fieldNames:u.templateFieldNames,u.blockIds.forEach((p,g)=>{const m=r.filter(k=>k.id.endsWith(`__${p}`));if(m.length===0||!f)return;const h=ad(m,o);if(!h)return;const{minRow:y,minCol:S,rowSpan:w,colSpan:A}=h,x=`${y}-${S}`;for(let k=y;k<=y+w-1;k++)for(let T=S;T<=S+A-1;T++)a.add(`${k}-${T}`);const F=f,N=Is(l,g+1);c.set(x,{anchorRow:y,anchorCol:S,rowSpan:w,colSpan:A,run:F,legend:N,renderFields:id(m),addMoreMeta:{addMoreFieldName:u.addMoreFieldName,blockId:p,blockIndex:g}})})}return{anchorsByOrigin:c,coveredCells:a}}function gP(e,t,r,n){const o=`${e}-${t}`;return r.has(o)?!n.get(o):!1}function yP(e,t,r){for(const n of r.values())if(e>=n.anchorRow&&e<n.anchorRow+n.rowSpan&&t>=n.anchorCol&&t<n.anchorCol+n.colSpan)return n}function bP(e,t,r,n){return!(!n||r.run.section.collapsible!==!0||e===r.anchorRow&&t===r.anchorCol)}function vP(e,t,r){const n=new Set;for(const o of e.values())if(t(o))for(let s=o.anchorRow+1;s<o.anchorRow+o.rowSpan;s++)r(s,o)||n.add(s);return n}function wP(e,t,r){const n=o=>r.has(o)?"minmax(0, auto)":`minmax(${t}, auto)`;return Array.from({length:e},(o,s)=>n(s)).join(" ")}function SP(e,t){return new Map([...e,...t])}function xP(e,t,r){if(t.length===0)return e.map(i=>({kind:"field",field:i}));const n=new Map;for(const i of t)for(const a of i.fieldNames)n.set(a,i);const o=[];let s=0;for(;s<e.length;){const i=e[s],a=r(i),c=a?n.get(a):void 0;if(!c){o.push({kind:"field",field:i}),s+=1;continue}const u=[],f=new Set(c.fieldNames);for(;s<e.length;){const p=r(e[s]);if(!p||!f.has(p))break;const g=e[s];Vy(g,c.section,r)||u.push(g),s+=1}if(u.length===0)continue;const l=o[o.length-1];l?.kind==="border"&&l.run.section.id===c.section.id?l.fields.push(...u):o.push({kind:"border",run:c,fields:u})}return o}function Hy(e,t){if(!t?.length)return;const r=new Set(e);for(const n of t){if(n.showBorder!==!0)continue;const o=n.fieldNames.filter(s=>r.has(s));if(o.length>0)return{section:n,fieldNames:o}}}const AP=({steps:e,currentStep:t,completedSteps:r,onStepClick:n,className:o})=>d.jsx("div",{className:H("mb-8",o),children:d.jsx("nav",{"aria-label":"Progress",children:d.jsx("ol",{className:"flex items-center",children:e.map((s,i)=>{const a=r.has(i),c=t===i,u=n&&(a||i===t+1||i<=t);return d.jsxs("li",{className:H("relative",i!==e.length-1&&"pr-8 sm:pr-20 flex-1"),children:[i!==e.length-1&&d.jsx("div",{className:H("absolute top-4 left-8 -right-8 sm:left-12 sm:-right-12 h-0.5",a?"bg-primary":"bg-border"),"aria-hidden":"true"}),d.jsx("button",{type:"button",onClick:()=>u&&n?.(i),disabled:!u,className:H("relative flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium","transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",a&&"bg-primary text-primary-foreground",c&&!a&&"border-2 border-primary text-primary",!a&&!c&&"border-2 border-border text-muted-foreground",u&&"cursor-pointer hover:bg-primary/10",!u&&"cursor-default"),"aria-current":c?"step":void 0,children:a?d.jsx(ai,{className:"h-4 w-4"}):d.jsx("span",{children:i+1})}),d.jsxs("div",{className:"mt-2",children:[d.jsx("span",{className:H("text-sm font-medium",c&&"text-primary",!c&&!a&&"text-muted-foreground"),children:s.name}),s.description&&d.jsx("p",{className:"text-xs text-muted-foreground hidden sm:block",children:s.description})]})]},s.id)})})})}),CP=2*6e4,Wy=50;class EP{map=new Map;ttlMs;constructor(t){this.ttlMs=t}get(t){const r=this.map.get(t);if(!r)return null;const o=Date.now()-r.storedAtMs>this.ttlMs;return{value:r.value,isStale:o}}set(t,r){this.map.set(t,{value:r,storedAtMs:Date.now()}),this.enforceMax()}delete(t){this.map.delete(t)}clear(){this.map.clear()}enforceMax(){if(this.map.size<=Wy)return;const t=Array.from(this.map.entries());t.sort((n,o)=>n[1].storedAtMs-o[1].storedAtMs),t.slice(0,Math.max(0,this.map.size-Wy)).forEach(([n])=>this.map.delete(n))}}function NP(e){return(e??"").trim()||"default"}function Ry(e){const t=NP(e.scope),r=String(e.formId??"").trim(),n=e.version===void 0||e.version===null?"latest":String(e.version).trim();return`form-render:${t}:${r}:${n}`}const Gy=new EP(CP);function Ky(e){const t=Ry(e),r=Gy.get(t);return r?{value:r.value,isStale:r.isStale}:null}function qy(e,t){const r=Ry(e);Gy.set(r,t)}function Yy(e){const t={};for(const[n,o]of Object.entries(e)){if(o==null){t[n]=o;continue}if(Array.isArray(o)){t[n]=o;continue}if(typeof o=="object"&&!(o instanceof Date)){const s=o;typeof s.name=="string"&&typeof s.code=="string"?t[n]=`${s.code} ${s.name}`.trim():typeof s.name=="string"?t[n]=s.name:typeof s.code=="string"?t[n]=s.code:typeof s.short_code=="string"?t[n]=s.short_code:t[n]=s.name??s.code??"";continue}t[n]=o}const r=t.time_slot??e.time_slot;return typeof r=="string"&&r.includes(" - ")&&(t.start=r.split(" - ")[0].trim()),t}const Ms=({schema:e,formId:t,initialValues:r,onSubmit:n,onChange:o,onValidationError:s,onClose:i,mode:a="fill",className:c,children:u,gridLayout:f,unstyled:l=!1,submissionContext:p,onWorkflowSubmitResult:g,initialExtraSubmitPayload:m,onExtraSubmitPayloadChange:h,workflowStepId:y,initialStepIndex:S,viewerContext:w,getViewerContext:A,hideTableRowControls:x=!1,themeVars:F,dark:N=!1,omitRootWrapper:k=!1,moduleId:T,workflowModalHandlers:P,getAuthHeaders:E})=>{const C=Qn(_=>_.viewerContext),I=v.useMemo(()=>{if(w!==void 0)return w;const _=A?.();return _!==void 0?_:C},[w,A,C]),[W,M]=v.useState(e||null),[z,V]=v.useState(!!t&&!e),[X,D]=v.useState(null),B=e?.BFF_submit_api??X,[L,K]=v.useState(!1),[ie,j]=v.useState({}),[U,le]=v.useState({}),[oe,G]=v.useState({}),[ae,Ae]=v.useState({}),[ee,ne]=v.useState({}),[he,Ie]=v.useState(null),Ue=Ba.useParams(),re=Or(_=>_.setValues),ge=Or(_=>_.setSubmitting),Se=Or(_=>_.formDisabled),pt=Or(_=>_.visibleFields),Dt=Or(_=>_.requiredFields),Bt=Or(_=>_.updateVisibility),Ot=Or(_=>_.updateRequired),Ar=Or(_=>_.setFieldError),kt=ri(),Cr=v.useRef(!1),Xe=v.useRef(void 0),ve=v.useMemo(()=>{if(!e)return null;const _=e;if(_.form&&Array.isArray(_.form.fields))try{return Os(_.form,_.form.fields,_.form.layout||null,_.form.rules||[])}catch{return e}if(Array.isArray(_.fields)&&_.fields.some(R=>typeof R.metadata=="string"&&R.metadata.startsWith("{")||R.fieldType&&!R.type))try{const R={id:_.id||_._id||"temp",name:_.name||"Form",version:_.version??1,status:_.status||"draft",createdAt:_.createdAt||new Date().toISOString(),updatedAt:_.updatedAt||new Date().toISOString(),createdBy:_.createdBy||"system",category:_.category||"",moduleId:_.moduleId,tenantId:_.tenantId,featureId:_.featureId,isDefault:_.isDefault||!1};return Os(R,_.fields,_.layout||null,_.rules||[])}catch{return e}return e},[e]);v.useEffect(()=>{if(e){const _=e;_.BFF_submit_api&&D(_.BFF_submit_api)}},[e]);const ce=v.useMemo(()=>{const _=ve||W,q=_?da(_):null;if(!q)return null;const R=q.layout,Z=q.rules,Q=q.clientMapping,de=(Array.isArray(q.fields)?q.fields:[]).map(Be=>{let Ve={...Be};if(Be.validationRules&&typeof Be.validationRules=="object"&&!Be.validation){const pe=Be.validationRules,Oe=[];pe.required===!0&&Oe.push({type:"required",message:"This field is required"}),pe.minLength!==void 0&&typeof pe.minLength=="number"&&Oe.push({type:"minLength",value:pe.minLength,message:`Minimum length is ${pe.minLength}`}),pe.maxLength!==void 0&&typeof pe.maxLength=="number"&&Oe.push({type:"maxLength",value:pe.maxLength,message:`Maximum length is ${pe.maxLength}`}),pe.pattern&&typeof pe.pattern=="string"&&Oe.push({type:"pattern",value:pe.pattern,message:"Invalid format"}),pe.allowLetters!==void 0&&Oe.push({type:"allowLetters",value:pe.allowLetters}),pe.allowNumbers!==void 0&&Oe.push({type:"allowNumbers",value:pe.allowNumbers}),pe.allowSpecialChars!==void 0&&Oe.push({type:"allowSpecialChars",value:pe.allowSpecialChars}),Oe.length>0&&(Ve={...Ve,validation:Oe})}const Ne=Be.required===!0||Be.isRequired===!0,ke=Array.isArray(Ve.validation)&&Ve.validation.some(pe=>pe.type==="required");if(Ne&&!ke){const pe={type:"required",message:"This field is required"},Oe=Array.isArray(Ve.validation)?Ve.validation:[];Ve={...Ve,validation:[...Oe,pe]}}if(Be.apidata&&typeof Be.apidata=="object"){const pe=Be.apidata,Oe=Ve.properties||{},xe=(Ve.type||Be.fieldType)==="status";if(!Oe.apiEndpoint&&pe.apiEndpoint){const lt={...Oe,apiEndpoint:pe.apiEndpoint,apiMethod:pe.apiMethod,apiKey:pe.apiKey,apiRealtime:pe.apiRealtime,apiAutoDetect:pe.apiAutoDetect,apiLabelField:pe.apiLabelField,apiValueField:pe.apiValueField,apiQueryParams:pe.apiQueryParams,apiClientFilter:pe.apiClientFilter,apiHeaders:pe.apiHeaders,apiBodyFields:pe.apiBodyFields,apiAuth:pe.apiAuth,valueSource:pe.valueSource||(pe.apiEndpoint?"api":void 0),optionsSource:pe.optionsSource||(pe.apiEndpoint?"api":void 0),dependentFields:pe.dependentFields,apiResponsePath:pe.apiResponsePath};xe&&(lt.source=Oe.source??"api",Oe.statuses!==void 0&&(lt.statuses=Oe.statuses),Oe.dataPath!==void 0&&(lt.dataPath=Oe.dataPath),Oe.showStatusText!==void 0&&(lt.showStatusText=Oe.showStatusText),Oe.statusTextPath!==void 0&&(lt.statusTextPath=Oe.statusTextPath),Oe.showCurrentIndicator!==void 0&&(lt.showCurrentIndicator=Oe.showCurrentIndicator)),Ve={...Ve,properties:lt}}}const ze=["select","multiselect","radio","checkboxgroup"],et=Ve.type||Be.fieldType;if(ze.includes(et)){const pe=Be.options,Oe=Ve.properties?.options,xe=Array.isArray(Oe)&&Oe.length>0;if(Array.isArray(pe)&&pe.length>0&&!xe){const lt=Ve.properties||{};Ve={...Ve,properties:{...lt,options:pe}}}}return Ve}),ye=q.config?.rules,Ee=Z&&Array.isArray(Z)?Z:ye&&Array.isArray(ye)?ye:[],He=Ee.length>0?de.map(Be=>{if((Be.conditions&&Array.isArray(Be.conditions)?Be.conditions:[]).length>0)return Be;const Ne=Be.id??Be._id,ke=Be.name||Be.key,ze=Ee.filter(Oe=>{const xe=typeof Oe.targetFieldId=="object"?Oe.targetFieldId?.id??Oe.targetFieldId?._id:Oe.targetFieldId;return xe?xe===Ne||xe===ke||xe===Be.fieldKey:!1});if(ze.length===0)return Be;const et=[],pe=new Set;return ze.forEach(Oe=>{try{const xe=typeof Oe.conditionExpression=="string"?JSON.parse(Oe.conditionExpression):Oe.conditionExpression;if(!xe||typeof xe!="object")return;!xe.id&&Oe.id&&(xe.id=Oe.id);const lt=typeof Oe.targetFieldId=="object"?Oe.targetFieldId?.id??Oe.targetFieldId?._id:Oe.targetFieldId;xe.action&&(!xe.then||!Array.isArray(xe.then)||xe.then.length===0)&&(xe.then=[{action:xe.action,...lt&&{target:lt}}]),(!xe.then||!Array.isArray(xe.then)||xe.then.length===0)&&Oe.action&&(xe.then=[{action:Oe.action,...lt&&{target:lt}}]),xe.then&&Array.isArray(xe.then)&&lt&&(xe.then=xe.then.map(zt=>!zt.target&&lt?{...zt,target:lt}:zt));const Gt=Oe.conditionExpression??JSON.stringify(xe);if(pe.has(Gt))return;pe.add(Gt),et.push(xe)}catch{}}),et.length===0?Be:{...Be,conditions:et}}):de;let Je=q.config||{submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};return!Je.layout&&R?typeof R=="object"&&R!==null?Je.layout="default":typeof R=="string"&&["default","card","compact"].includes(R)?Je.layout=R:Je.layout="default":Je.layout||(Je.layout="default"),Z&&!Je.rules&&(Je.rules=Z),Q&&!Je.clientMapping&&(Je.clientMapping=Q),{...q,fields:He,config:Je}},[ve,W]);v.useEffect(()=>{ve&&ve!==W&&M(ve)},[ve]),v.useEffect(()=>{if(t&&!e){const _=(nn()??"").trim()||"default",q=Ky({scope:_,formId:t,version:"latest"});q?.value?.schema?(M(q.value.schema),q.value.bffSubmitApi&&D(q.value.bffSubmitApi),V(!1),q.isStale&&J({background:!0})):J({background:!1})}},[t,e]);const J=async({background:_})=>{if(!t)return;const q=t;_||V(!0);try{const R=await GF.getForRendering(t),Z=Os(R.form,R.fields,R.layout,R.rules);if(q!==t)return;M(Z),R.BFF_submit_api&&D(R.BFF_submit_api);const Q=(nn()??"").trim()||"default";qy({scope:Q,formId:q,version:"latest"},{schema:Z,bffSubmitApi:R.BFF_submit_api})}catch{}finally{_||V(!1)}};if(z)return d.jsx("div",{className:"flex items-center justify-center py-12",children:d.jsx(wn,{})});if(!ce)return d.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Form not found"});const $=ce,fe=v.useMemo(()=>new Set(Object.keys($.config?.prepopulateApi?.fieldMapping??{})),[$.config?.prepopulateApi?.fieldMapping]),st=v.useCallback(async _=>{const q=$?.fields?.length?Tc(_,$.fields):_,R=Ig(q,$.config?.sections,$.config?.submitPayload);if(n){const Z=p?{...R,...p}:R;return n(Z)}return{success:!0}},[n,p,$?.fields,$.config?.sections,$.config?.submitPayload]),{values:Te,errors:Ye,touched:Me,isSubmitting:Ce,isValid:nt,submitCount:qe,totalSteps:dt,currentStepFields:bt,isLastStep:sr,setFieldValue:xt,setFieldTouched:$e,handleSubmit:gt,validateForm:vt,resetForm:_t,nextStep:yr,goToStep:ir,currentStep:Er,completedSteps:Et,loadDraft:Nr}=Au({schema:$,initialValues:r,onSubmit:st,onChange:o,workflowStepId:y,initialStepIndex:S}),{isFieldEnabled:ar,isFieldRequired:xn,isFieldVisible:un}=Lw({fields:$.fields,values:Te,buttonResponses:U,prepopulateResponse:he,prepopulateResponseRules:$.config?.prepopulateResponseRules}),$r=un,zn=Or(_=>_.readOnlyFields),$t=Or(_=>_.editableFields),Ht=v.useCallback(_=>zn.has(_),[zn]),br=v.useCallback(_=>$t.has(_),[$t]);v.useEffect(()=>{$.config?.allowDraft&&a==="fill"&&Nr()},[$.id]),v.useEffect(()=>{Xe.current=$.id,Cr.current=!1,j({}),G({}),Ae({}),ne({}),Ie(null)},[$.id]),v.useEffect(()=>{const _=$.config?.prepopulateApi,q=!!(_?.fieldMapping&&Object.keys(_?.fieldMapping??{}).length>0),R=($.config?.prepopulateResponseRules?.length??0)>0;if(!_?.enabled||!_.apiEndpoint?.trim()||!q&&!R||Cr.current)return;Cr.current=!0;const Z=$.id;Xe.current=$.id;let Q=!1;return K(!0),(async()=>{try{const de=kt.getState().values,ye=typeof p=="object"&&p!==null?{...p,...m||{}}:m||{},Ee=se=>Rr(se,de,Ue,ye);let He=Mr(Ee(_.apiEndpoint));if(_.apiQueryParams?.length){const se=new URLSearchParams;_.apiQueryParams.forEach(({key:Le,value:be})=>se.append(Le,Ee(be))),He=`${He}${He.includes("?")?"&":"?"}${se.toString()}`}const Je={};_.apiHeaders?.forEach(({key:se,value:Le})=>{se.trim()&&(Je[se]=Ee(Le))}),Je["Content-Type"]=Je["Content-Type"]??"application/json";let Rt;if(_.apiMethod==="POST"&&_.apiBodyFields?.length){const se={};_.apiBodyFields.forEach(({key:Le,value:be})=>{Le.trim()&&(se[Le]=Ee(be))}),Rt=JSON.stringify(se)}const Be=await fetch(He,{method:_.apiMethod,headers:Je,body:_.apiMethod==="POST"?Rt:void 0});if(!Be.ok){const se=await Be.text();throw new Error(se||`HTTP ${Be.status}`)}const Ve=await Be.json(),Ne=se=>{try{return se.split("?")[0].split("/").filter(Boolean).pop()||se}catch{return se}},ke=(se,Le)=>{if(se==null)return null;const be=typeof se=="string"?se:se instanceof Date?se.toISOString():null;if(!be)return null;const Ge=typeof se=="object"&&se instanceof Date?se:new Date(be);if(Number.isNaN(Ge.getTime()))return null;const ut=mt=>String(mt).padStart(2,"0");if(Le==="date")return be.length>=10&&be[4]==="-"&&be[7]==="-"?be.slice(0,10):Ge.toISOString().slice(0,10);if(Le==="time")return`${ut(Ge.getHours())}:${ut(Ge.getMinutes())}:${ut(Ge.getSeconds())}`;if(Le==="datetime"){const mt=Ge.getFullYear(),Ze=Ge.getMonth()+1,me=Ge.getDate(),ht=Ge.getHours(),We=Ge.getMinutes(),Ft=Ge.getSeconds();return`${mt}-${ut(Ze)}-${ut(me)}T${ut(ht)}:${ut(We)}:${ut(Ft)}`}return null},ze=(se,Le)=>{const be=$.fields.find(me=>me.name===se||me.key===se);if(!be)return Le;if((be.type==="file"||be.type==="camera"||be.type==="photoChoice")&&typeof Le=="string"&&Le.startsWith("http"))return{url:Le,name:Ne(Le)};if(be.type==="date"||be.type==="datetime"||be.type==="time"){const me=ke(Le,be.type);if(me!==null)return me}if(be.type==="multiselect")return Array.isArray(Le)?Le.map(me=>typeof me=="string"?me:String(me)):typeof Le=="string"?Le.trim()===""?[]:Le.includes(",")?Le.split(",").map(me=>me.trim()).filter(Boolean):[Le]:Le!=null&&Le!==""?[String(Le)]:[];if(be.type!=="radio"&&be.type!=="select")return Le;const Ge=be.properties?.options??be.options;if(!Array.isArray(Ge)||Ge.length===0)return Le;const ut=Ge.map(me=>me.value);if(ut.includes(Le))return Le;const mt=String(Le);if(ut.includes(mt))return mt;const Ze=Ge.find(me=>me.value==Le);return Ze?Ze.value:Le},et=new Set($.fields.filter(se=>se.type==="table").map(se=>se.name||se.key)),pe=new Set($.fields.filter(se=>se.type==="billingGrid").map(se=>se.name||se.key)),Oe=se=>se.name||se.key||se.id,xe={},lt=[],Gt=[],zt=S_(_?.fieldMapping,$.config?.sections,$.config?.submitPayload);for(const[se,Le]of Object.entries(zt)){if(!Le?.trim()||se.startsWith("__"))continue;const be=Re(Ve,Le),Ge=se.indexOf(".");if(Ge>0&&pe.has(se.slice(0,Ge))){const mt=se.slice(0,Ge),Ze=se.slice(Ge+1),ht=$.fields.find(We=>(We.name||We.key)===mt)?.properties;if(ht?.rowSlots?.length){const We=Ze.startsWith("__block__")?Ze.slice(9):Ze,Ft=xe[mt]??kt.getState().values[mt];Array.isArray(be)?xe[mt]=ST(ht,We,be,Ft):be!=null&&(xe[mt]=Vc(ht,be,Ft))}continue}if(Ge>0&&et.has(se.slice(0,Ge))){const mt=se.slice(0,Ge),Ze=se.slice(Ge+1);lt.push({tableName:mt,columnName:Ze,path:Le});continue}if(pe.has(se)&&be!==void 0&&be!==null&&typeof be=="object"){const Ze=$.fields.find(me=>(me.name||me.key)===se)?.properties;if(Ze?.rowSlots?.length){if(Array.isArray(be)){const me=Ze.rowSlots.find(ht=>ht.kind==="dynamic");if(me&&me.kind==="dynamic"){const ht=me.block.apiArrayPath??"items";xe[se]=Vc(Ze,{[ht]:be})}}else xe[se]=Vc(Ze,be);continue}}if(et.has(se)&&Array.isArray(be)&&be.length>0&&typeof be[0]=="object"&&be[0]!==null){const Ze=$.fields.find(We=>(We.name||We.key)===se)?.properties?.columns||[],me=be.map(Yy),ht=We=>(We||"").toLowerCase().replace(/\s+/g,"_").trim();xe[se]=me.map(We=>{const Ft={};for(const fr of Ze){const co=fr.name??"";Ft[co]=We[ht(co)]??We[co]}return Ft});continue}if(be!=null&&(xe[se]=ze(se,be)),be==null)continue;let ut=be;if(Array.isArray(be)){const mt=$.fields.find(Ze=>Oe(Ze)===se);if(mt?.type==="addmore"){Gt.push({addMoreFieldName:se,array:be});continue}if(mt?.type==="multiselect"){const Ze=_.multiselectArrayPropertyMap?.[se];Ze&&be.length>0&&be.some(me=>me!=null&&typeof me=="object")&&(ut=be.map(me=>me!=null&&typeof me=="object"&&Ze in me?me[Ze]:void 0).filter(me=>me!=null))}}xe[se]=ze(se,ut)}const at={},yt={},nr={};for(const{addMoreFieldName:se,array:Le}of Gt){const be=$.fields.find(ht=>Oe(ht)===se);if(!be||be.type!=="addmore")continue;const Ge=Uy(be,$.fields,$.config?.sections,Oe);if(Ge.length===0)continue;const ut=_.addMoreFieldKeyMap?.[se],mt=Le.length>0&&Le[0]!=null&&typeof Le[0]=="object"?Le[0]:null;if(mt)for(const ht of Ge){const We=Oe(ht),Ft=ut&&ut[We]||We,fr=mt[Ft];fr!=null&&(xe[We]=ze(We,fr))}const Ze=Le.slice(1),me=Ze.map((ht,We)=>`prepop_${se}_${We}_${Date.now()}`);me.length>0&&(yt[se]=me);for(let ht=0;ht<Ze.length;ht++){const We=Ze[ht];if(We==null||typeof We!="object")continue;const Ft=We,fr=Ft.id;fr!=null&&String(fr).trim()!==""&&(nr[`${se}__${me[ht]}`]=String(fr));for(const co of Ge){const Da=Oe(co),FI=ut&&ut[Da]||Da,Nd=Ft[FI];if(Nd==null)continue;const PI=`${Da}__addmore__${se}__${me[ht]}`;at[PI]=ze(Da,Nd)}}}Object.keys(yt).length>0&&G(se=>({...se,...yt})),Object.keys(nr).length>0&&ne(se=>({...se,...nr}));const Vr=se=>(se||"").toLowerCase().replace(/\s+/g,"_").trim(),en=[...new Set(lt.map(se=>se.tableName))];for(const se of en){if(Array.isArray(xe[se]))continue;const Le=lt.find(me=>me.tableName===se);if(!Le?.path?.includes("."))continue;const be=Le.path.replace(/\.[^.]+$/,""),Ge=Re(Ve,be);if(!Array.isArray(Ge)||Ge.length===0||typeof Ge[0]!="object"||Ge[0]===null)continue;const mt=$.fields.find(me=>(me.name||me.key)===se)?.properties?.columns||[],Ze=Ge.map(Yy);xe[se]=Ze.map(me=>{const ht={};for(const We of mt){const Ft=We.name??"",fr=Vr(Ft),co=me[fr]??me[Ft];ht[Ft]=co}return ht})}const Hr=(se,Le)=>{const be=Re(Ve,se);if(Array.isArray(be))return be;if(be!=null)return[be];if(!se.includes("."))return[];const Ge=se.replace(/\.[^.]+$/,""),ut=Re(Ve,Ge);return!Array.isArray(ut)||ut.length===0||typeof ut[0]!="object"||ut[0]===null?[]:ut.map(mt=>{const Ze=mt[Le];if(Ze!==null&&typeof Ze=="object"&&!Array.isArray(Ze)&&!(Ze instanceof Date)){const me=Ze;return typeof me.name=="string"&&typeof me.code=="string"?`${me.code} ${me.name}`.trim():typeof me.name=="string"?me.name:typeof me.code=="string"?me.code:typeof me.short_code=="string"?me.short_code:me.name??me.code??""}return Ze})};for(const{tableName:se,columnName:Le,path:be}of lt){const Ge=Hr(be,Le),mt=$.fields.find(We=>(We.name||We.key)===se)?.properties?.columns||[],Ze=mt.find(We=>(We.name||"").toLowerCase()===Le.toLowerCase())?.name??Le;let me=Array.isArray(xe[se])?xe[se]:[];const ht=Math.max(me.length,Ge.length);if(ht>me.length)for(me=[...me];me.length<ht;){const We={};mt.forEach(Ft=>{We[Ft.name||""]=""}),me.push(We)}else me=me.map(We=>({...We}));Ge.forEach((We,Ft)=>{me[Ft]&&(me[Ft][Ze]=We)}),xe[se]=me}if(Xe.current===Z){if(Object.keys(xe).length>0||Object.keys(at).length>0){const Ft={...kt.getState().values,...xe,...at};re(Ft)}const Le=Re(Ve,"data.user_id"),be=Re(Ve,"data.items"),Ge=Re(Ve,"data");let ut=Array.isArray(be)&&be.length>0&&be[0]!=null&&typeof be[0]=="object"&&be[0].id?be[0].id:void 0;ut===void 0&&Array.isArray(Ge)&&Ge.length>0&&Ge[0]!=null&&typeof Ge[0]=="object"&&Ge[0].id&&(ut=Ge[0].id),ut===void 0&&(ut=Re(Ve,"data.0.id"));const mt=eP(Ve,{treatFirstItemIdAsPaymentId:_?.treatFirstItemIdAsPaymentId===!0}),Ze=Re(Ve,"data.id"),me=Re(Ve,"data.batch_id"),ht=Re(Ve,"data.program_id"),We={};Le!=null&&(We.context_user_id=Le),ut!=null&&ut!==""&&(We.documentId=ut),Ze!=null&&String(Ze).trim()!==""&&(p?.id===void 0||p?.id===null)&&(We.id=Ze),me!=null&&String(me).trim()!==""&&((p?.admission_batch_id===void 0||p?.admission_batch_id===null)&&(We.admission_batch_id=me),(p?.batch_id===void 0||p?.batch_id===null)&&(We.batch_id=me)),ht!=null&&String(ht).trim()!==""&&(p?.program_id===void 0||p?.program_id===null)&&(We.program_id=ht),mt!=null&&String(mt).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&(We.payment_id=mt),Object.keys(We).length>0&&j(Ft=>{const fr={...Ft,...We};return h?.(fr),fr}),Ie(Ve)}}catch(de){Q||ia(de,"Prepopulate request failed.",Gr)}finally{K(!1)}})(),()=>{Q=!0}},[$.id,$.config?.prepopulateApi?.enabled,$.config?.prepopulateApi?.apiEndpoint,$.config?.prepopulateApi?.apiMethod,JSON.stringify($.config?.prepopulateApi?.fieldMapping),$.config?.prepopulateApi?.treatFirstItemIdAsPaymentId,p,m,Ue,re,G]),v.useEffect(()=>{Object.keys(Ye).length>0&&s?.(Ye)},[Ye,s]);const Jr=dt>1,Yt=a==="view",lr=v.useCallback((_,q)=>Yt||!!q&&!br(_)||Ht(_)&&!br(_),[Yt,br,Ht]),Un=$.fields.filter(_=>!_.parentId),Tt=[...Jr?bt:Un.length>0?Un:$.fields].filter(_=>!(!_||typeof _!="object"||!_.name&&!_.key)).sort((_,q)=>{const R=typeof _.position?.order=="number"?_.position.order:typeof _.positionOrder=="number"?_.positionOrder:Number.MAX_SAFE_INTEGER,Z=typeof q.position?.order=="number"?q.position.order:typeof q.positionOrder=="number"?q.positionOrder:Number.MAX_SAFE_INTEGER;if(R!==Z)return R-Z;const Q=typeof _.position?.column=="number"?_.position.column:1,de=typeof q.position?.column=="number"?q.position.column:1;return Q-de}),js=v.useCallback(_=>{const q=kt.getState().errors,R=Object.keys(q).find(Z=>_.includes(Z));R&&requestAnimationFrame(()=>{document.querySelector(`[data-field-name="${R}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})})},[]),kr=async _=>{if(_?.preventDefault(),Jr&&!sr){if(!await yr())try{const Z=kt.getState().errors;ct.toast.error(la(Z,$.fields)||"Please fix the errors before continuing."),js(Tt.map(Q=>Q.name||Q.key||Q.id).filter(Boolean))}catch{ct.toast.error("Please fix the errors before continuing.")}return}const q=await gt(_);if(q&&q.success===!1&&q.errors?.length)try{const R=kt.getState().errors;ct.toast.error(la(R,$.fields)||"Submission failed. Please check the form."),js(Tt.map(Z=>Z.name||Z.key||Z.id).filter(Boolean))}catch{ct.toast.error("Submission failed. Please check the form.")}return q},Qr=v.useCallback(()=>{_t(),i&&i()},[_t,i]),jr=v.useCallback((_,q)=>{const R=$.fields.find(de=>de.type==="button"&&(de.name===_||de.key===_)),Z=R?.properties,Q=oP(q,R);Q!=null&&String(Q).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&j(de=>{const ye={...de,payment_id:Q};return h?.(ye),ye}),R&&Z?.apiSuccessConfig&&Qk(q,Z.apiSuccessConfig,{setFieldValue:(de,ye)=>kt.getState().setFieldValue(de,ye),onContextUpdate:de=>{j(ye=>{const Ee={...ye,...de};return h?.(Ee),Ee})}}),le(de=>{const ye={...de,[_]:q};return!Qo(q)||!(R?.type==="button"&&R.properties?.action==="submit")||$.fields.filter(Je=>Je.type==="editButton").map(Je=>Je.name).forEach(Je=>delete ye[Je]),ye})},[$.fields,p,h,kt]),zr=v.useCallback(async()=>await vt(),[vt]),_r=v.useCallback(()=>kt.getState().errors,[]),Xt=v.useMemo(()=>({...m||{},...ie}),[m,ie]),_e=v.useMemo(()=>({...typeof p=="object"&&p!==null?p:{},...Xt}),[p,Xt]),O=$.config?.layout??$.layout??"default",te=["default","card","compact"].includes(O)?O:"default",we={default:"",card:"bg-card border rounded-lg shadow-sm p-6",compact:"space-y-2"},it=v.useMemo(()=>{if(k)return;const _=$.config?.theme?.cssVariables;if(!(!_&&!F))return{..._??{},...F??{}}},[k,$.config?.theme?.cssVariables,F]),wt=v.useMemo(()=>Ws({config:$.config,layout:$.layout},f),[$.config,$.layout,f]),St=v.useMemo(()=>wt?{...wt,verticalSpacing:wt.verticalSpacing??wt.spacing??"16px",horizontalSpacing:wt.horizontalSpacing??wt.spacing??"16px",rowHeight:wt.rowHeight??Hn}:null,[wt]),Wt=St!==null;St?.rows;const Nt=St?.columns??3,Ur=St?.verticalSpacing??St?.spacing??"16px",Ho=St?.horizontalSpacing??St?.spacing??"16px",It=St?.rowHeight??Hn,fn=v.useCallback(_=>{if(!I)return!0;const q=_.visibility;if(!q)return!0;const R=q.visibleToUserType??q.user_type,Z=q.visibleToUserRole??q.user_role,Q=Array.isArray(q.visibleToUserIds)?q.visibleToUserIds:Array.isArray(q.users)?q.users:[],de=Array.isArray(q.hiddenFromUserIds)?q.hiddenFromUserIds:[];if(Array.isArray(de)&&de.length>0&&I.userId!=null&&de.includes(I.userId))return!1;if(Q.length>0&&I.userId!=null&&Q.includes(I.userId))return!0;const ye=R!=null&&R!==""&&I.userType!=null&&I.userType!==R,Ee=Z!=null&&Z!==""&&I.role!=null&&I.role!==Z,He=Q.length>0&&(I.userId==null||!Q.includes(I.userId));return!(ye||Ee||He)},[I]),An=v.useMemo(()=>P_($.fields),[$.fields]),xd=v.useMemo(()=>I_($.fields),[$.fields]),[Wo,Mb]=v.useState(xd);v.useEffect(()=>{Mb(xd)},[$.id,xd]);const Lb=v.useCallback((_,q)=>{Mb(R=>R[_]===q?R:{...R,[_]:q})},[]),EI=v.useMemo(()=>({visibility:Wo,setSectionVisible:Lb,fieldToHeading:An,allFields:$.fields}),[Wo,Lb,An,$.fields]),rt=v.useCallback(_=>_.name||_.key||_.id,[]),Tr=_=>{if(!fn(_))return!1;const q=_.name||_.key||_.id;if(!Bg(q,_.type,Wo,An))return!1;const R=_.hidden===!0;return $r(q)||!R&&q},Db=v.useCallback(_=>{const q=$.fields.find(Z=>rt(Z)===_);if(q)return q.type;const R=Dg(_);return $.fields.find(Z=>rt(Z)===R)?.type},[$.fields,rt]),Ca=v.useCallback(_=>Bg(_,Db(_),Wo,An),[Wo,An,Db]),Cn=v.useCallback(_=>Ca(_)?xn(_):!1,[Ca,xn]);v.useEffect(()=>{const{visibleFields:_,requiredFields:q,errors:R}=kt.getState(),Z=new Set(_),Q=new Set(q),de=[];for(const ye of $.fields){const Ee=rt(ye);Ee&&(Ca(Ee)||(Z.delete(Ee),Q.delete(Ee),R[Ee]&&de.push(Ee)))}Bt(Array.from(Z)),Ot(Array.from(Q));for(const ye of de)Ar(ye,void 0)},[Wo,An,$.fields,$.id,rt,Ca,Bt,Ot,Ar,pt,Dt]);const jt=$.config?.sections,ao=v.useCallback(_=>{const q=rt(_);let R=_;if(_.type==="table"){const Q=_.properties?.columns;if(Array.isArray(Q)&&Q.length>0){const de=Q.filter(ye=>fn(ye));R={..._,properties:{..._.properties,columns:de}}}}const Z=cP(R,jt,rt);return Z&&(R={...R,label:zy(Z,0)}),{...R,disabled:!ar(q),readOnly:lr(q,!!R.readOnly)}},[fn,jt,rt,ar,lr]),En=v.useCallback(_=>Uy(_,$.fields,jt,rt),[$.fields,jt,rt]),Zr=v.useCallback((_,q,R)=>`${_}__addmore__${q}__${R}`,[]),Ea=v.useCallback((_,q)=>`${_}__${q??"base"}`,[]),Na=v.useCallback((_,q)=>{const R=Ea(_.id,q);return ae[R]??_.defaultCollapsed??!1},[ae,Ea]),Ad=v.useCallback((_,q,R)=>{const Z=Ea(_,q);Ae(Q=>Q[Z]===R?Q:{...Q,[Z]:R})},[Ea]),ka=v.useMemo(()=>{const _=[],q=$.fields.filter(R=>R.type==="addmore");for(const R of q){const Z=rt(R),de=En(R).find(Je=>{if(Je.type!=="button")return!1;const Rt=Je.properties,Be=Je.metadata;let Ve=Rt?.action;if(!Ve&&Be!=null)try{Ve=(typeof Be=="string"?JSON.parse(Be):Be)?.action}catch{}return Ve==="upload"||Ve==="custom"});if(!de)continue;const ye=rt(de),Ee=oe[Z]||[],He=Re(U[ye],"data.id")??Re(U[ye],"data.documentId")??ie.documentId;He!=null&&String(He).trim()!==""&&_.push(String(He));for(const Je of Ee){const Rt=Zr(ye,Z,Je),Be=Re(U[Rt],"data.id")??Re(U[Rt],"data.documentId"),Ve=ee[`${Z}__${Je}`],Ne=Be??Ve;Ne!=null&&String(Ne).trim()!==""&&_.push(String(Ne))}}return _},[$.fields,oe,U,ee,ie.documentId,rt,En,Zr]);v.useEffect(()=>{j(_=>{const q={..._,document_ids:ka},R=_.document_ids;return Array.isArray(R)&&R.length===ka.length&&ka.every((Z,Q)=>R[Q]===Z)?_:q})},[ka]);const _a=v.useCallback((_,q,R,Z)=>{for(const Q of R){const de=rt(Q),ye=Zr(de,_,q),Ee=Z[ye];if(Ee==null)continue;const He=Q.type;if(He==="file"||He==="camera"||He==="photoChoice"){if(typeof Ee=="object"&&Ee!==null&&("url"in Ee||"name"in Ee)||Array.isArray(Ee)&&Ee.length>0)return!0;continue}if(Array.isArray(Ee)){if(Ee.length>0)return!0;continue}if(typeof Ee=="string"&&Ee.trim()!==""||typeof Ee=="number"&&!Number.isNaN(Ee)||typeof Ee=="boolean"||typeof Ee=="object"&&Ee!==null&&Object.keys(Ee).length>0)return!0}return!1},[rt,Zr]),lo=v.useCallback(_=>{const q=rt(_);if(!q)return;if(En(_).length===0){ct.toast.error("No linked fields configured for this Add More button.");return}const Z=`${Date.now()}_${Math.random().toString(36).slice(2,8)}`;G(Q=>({...Q,[q]:[...Q[q]||[],Z]}))},[rt,En]),Ta=v.useCallback((_,q)=>{G(R=>{const Z=R[_]||[],Q=Z.filter(de=>de!==q);if(Q.length===Z.length)return R;if(Q.length===0){const de={...R};return delete de[_],de}return{...R,[_]:Q}})},[]),Fa=v.useMemo(()=>Tt.filter(_=>!_.parentId),[Tt]),Vn=v.useMemo(()=>{const _=[];return Tt.filter(R=>R.type==="addmore").sort((R,Z)=>{const Q=R.position?.order??0,de=Z.position?.order??0;return Q-de}).forEach(R=>{const Z=rt(R),Q=R.position?.order??0,de=oe[Z]||[],ye=En(R).sort((ke,ze)=>{const et=ke.position?.order??0,pe=ze.position?.order??0;return et!==pe?et-pe:(ke.position?.column??1)-(ze.position?.column??1)});if(ye.length===0)return;const Ee=jy(R,jt),He=Ee[0]?.fieldNames?.length?Ee[0].fieldNames:ye.map(ke=>rt(ke)).filter(Boolean),Je=fP(He,Fa,Nt,rt),Rt=Math.min(...ye.map(ke=>ke.position?.order??0)),Be=Math.max(1,...ye.map(ke=>(ke.position?.order??Rt)-Rt+qo(ke))),Ve=Je?.blockHeight??Be,Ne=de.length*Ve;_.push({addMoreFieldName:Z,baseOrder:Q,blockHeight:Ve,blockIds:de,linkedFields:ye,insertedRows:Ne,templateFieldNames:He,templateBounds:Je})}),_},[Tt,Fa,Nt,rt,oe,En,jt]),zs=v.useMemo(()=>({}),[]),Pa=v.useMemo(()=>Vn.length===0?Tt:Tt.map(_=>{const q=_.position?.order??0,R=Vn.reduce((Z,Q)=>{const de=Q.templateBounds?.maxRow??Q.baseOrder;return q>de?Z+Q.insertedRows:Z},0);return R===0?_:{..._,position:{..._.position,order:q+R}}}),[Tt,Vn]),Oa=v.useCallback(_=>{const q={};return Object.entries(U).forEach(([R,Z])=>{const Q=_[R];Q&&(q[Q]=Z)}),q},[U]),Ro=v.useMemo(()=>{const _=[],q={};return Vn.forEach(R=>{const{addMoreFieldName:Z,blockIds:Q,linkedFields:de,blockHeight:ye,templateBounds:Ee}=R,He=Math.min(...de.map(Be=>Be.position?.order??0)),Rt=$.fields.find(Be=>rt(Be)===Z&&Be.type==="addmore")?.properties;Q.forEach((Be,Ve)=>{const Ne={},ke={},ze={},et=Ee?pP(Ee,Ve):R.baseOrder+1+Ve*ye,pe=ee[`${Z}__${Be}`];de.forEach(xe=>{const lt=rt(xe),Gt=Zr(lt,Z,Be),zt=(xe.position?.order??He)-He;if(Ne[Gt]=lt,ke[Gt]=Te[Gt],!(Rt?.linkedFieldAllowDuplicate?.[lt]??!0)&&(xe.type==="select"||xe.type==="radio"||xe.type==="multiselect")){const yt=[],nr=Te[lt];nr!=null&&nr!==""&&(Array.isArray(nr)?yt.push(...nr.map(en=>String(en))):yt.push(String(nr))),Q.filter(en=>en!==Be).forEach(en=>{const Hr=Zr(lt,Z,en),tn=Te[Hr];tn!=null&&tn!==""&&(Array.isArray(tn)?yt.push(...tn.map(se=>String(se))):yt.push(String(tn)))}),yt.length>0&&(ze[Gt]=[...new Set(yt)])}_.push({...xe,id:`${xe.id}__${Be}`,name:Gt,position:{...xe.position,order:et+zt}})});const Oe=Oa(Ne);Object.keys(Ne).forEach(xe=>{q[xe]={scopedFormValues:ke,scopedFieldNameMap:Ne,scopedButtonResponses:Oe,...pe!=null&&{blockDocumentId:pe},...ze[xe]&&{excludedOptionValues:ze[xe]}}})})}),{clonedFields:_,scopeByFieldName:q}},[Vn,ee,rt,Zr,Te,Oa,$.fields]),Us=v.useMemo(()=>[...Pa,...Ro.clonedFields].sort((_,q)=>{const R=_.position?.order??0,Z=q.position?.order??0;if(R!==Z)return R-Z;const Q=_.position?.column??1,de=q.position?.column??1;if(Q!==de)return Q-de;const ye=Oo(_.position)??0,Ee=Oo(q.position)??0;return ye!==Ee?ye-Ee:String(_.id).localeCompare(String(q.id))}),[Pa,Ro.clonedFields]),Go=v.useMemo(()=>r_(Us.filter(_=>!_.parentId),Tr),[Us,Tr]),Cd=v.useCallback((_,q)=>Go.some(R=>n_(_,q,R,Nt)),[Go,Nt]);Go.length===0||Math.max(...Go.map(_=>(_[0]?.position?.order??0)+Cs(_,Nt).rowSpan));const Ia=v.useMemo(()=>dP(jt,id(Tt.filter(_=>!_.parentId)),rt),[jt,Tt,rt]),{anchorsByOrigin:Bb,coveredCells:$b}=v.useMemo(()=>mP(Ia,Pa,rt,Nt),[Ia,Pa,rt,Nt]),{anchorsByOrigin:jb,coveredCells:zb}=v.useMemo(()=>hP(Vn.map(_=>({addMoreFieldName:_.addMoreFieldName,blockIds:_.blockIds,linkedFields:_.linkedFields,templateFieldNames:_.templateFieldNames})),jt,Ro.clonedFields,Fa,Nt,rt,$b),[Vn,jt,Ro.clonedFields,Fa,Nt,rt,$b]),Nn=v.useMemo(()=>SP(Bb,jb),[Bb,jb]),Ub=v.useMemo(()=>zb,[zb]),Vb=String(It).endsWith("px")?It:Hn,Hb=v.useCallback((_,q)=>{for(let R=0;R<Nt;R++){if(R>=q.anchorCol&&R<q.anchorCol+q.colSpan)continue;if(zs[`${_}-${R}`]||Nn.get(`${_}-${R}`)||vg(_,R,Us,Tr).length>0||Cd(_,R))return!0}return!1},[Nt,zs,Nn,Us,Tr,Cd]),Wb=v.useMemo(()=>vP(Nn,_=>{const q=_.run.section;return q.collapsible?Na(q,_.addMoreMeta?.blockId):!1},Hb),[Nn,Na,Hb]),Rb=v.useMemo(()=>{const _=[];for(const q of Object.keys(zs)){const R=Number(q.split("-")[0]);Number.isNaN(R)||_.push(R)}for(const q of Nn.values())if(q.renderFields.some(R=>Tr(R)))for(let R=q.anchorRow;R<q.anchorRow+q.rowSpan;R++)_.push(R);return o_(Go,Nt,_)},[Go,Nt,zs,Nn,Tr]),{originalToDisplayRow:Ma,displayRowCount:NI,sortedOccupiedRows:kI}=v.useMemo(()=>{const _=s_(Rb);return{originalToDisplayRow:_.originalToDisplay,displayRowCount:_.displayRowCount,sortedOccupiedRows:_.sortedOriginalRows}},[Rb]),Gb=Math.max(NI,1),Ed=v.useCallback((_,q=1)=>i_(_,q,Ma),[Ma]),Kb=v.useMemo(()=>{const _=new Set;for(const q of Wb){const R=Ma.get(q);R!==void 0&&_.add(R)}return _},[Wb,Ma]),_I=v.useMemo(()=>wP(Gb,Vb,Kb),[Gb,Vb,Kb]),TI=v.useMemo(()=>xP(Tt.filter(_=>!_.parentId&&Tr(_)),Ia,rt),[Tt,Ia,rt,Tr]),La=v.useCallback(_=>{if(Wt)return null;const q=rt(_),R=oe[q]||[];if(R.length===0)return null;const Z=En(_);if(Z.length===0)return null;const Q=lP(_,jt),de=Z.map(He=>rt(He)).filter(Boolean),ye=Hy(de,jt),Ee=(He,Je,Rt,Be,Ve,Ne,ke)=>{const ze=rt(He),et=Zr(ze,q,Je),pe=He.hidden===!0;if(!(fn(He)&&($r(ze)||!pe&&ze)))return null;const xe={...He,id:`${He.id}__${Je}`,name:et,disabled:!ar(ze),readOnly:lr(ze,!!He.readOnly)},Gt=_.properties?.linkedFieldAllowDuplicate?.[ze]??!0;let zt;if(!Gt&&(He.type==="select"||He.type==="radio"||He.type==="multiselect")){const at=[],yt=Te[ze];yt!=null&&yt!==""&&(Array.isArray(yt)?at.push(...yt.map(Vr=>String(Vr))):at.push(String(yt))),R.filter(Vr=>Vr!==Je).forEach(Vr=>{const en=Zr(ze,q,Vr),Hr=Te[en];Hr!=null&&Hr!==""&&(Array.isArray(Hr)?at.push(...Hr.map(tn=>String(tn))):at.push(String(Hr)))}),at.length>0&&(zt=[...new Set(at)])}return d.jsx("div",{"data-field-name":et,"data-form-renderer":"field-wrapper",children:d.jsx(Sn,{field:xe,value:Te[et],error:Me[et]||qe>0?Ye[et]:void 0,onChange:at=>xt(et,at),onBlur:()=>$e(et),disabled:Se||!ar(ze)||Yt,readOnly:lr(ze,!!He.readOnly),isRequired:Cn(ze),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:L,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:et,buttonResponses:Ne,onButtonApiResponse:jr,onSubmit:kr,onReset:_t,onCancel:Qr,isSubmitting:Ce,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:ke,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,scopedFormValues:Ve,scopedFieldNameMap:Be,excludedOptionValues:zt,hideTableRowControls:x})},xe.id)};return d.jsx("div",{className:"space-y-3 mt-3",children:R.map((He,Je)=>{const Rt={},Be={};Z.forEach(zt=>{const at=rt(zt),yt=Zr(at,q,He);Rt[yt]=at,Be[yt]=Te[yt]});const Ve=Oa(Rt),Ne=_a(q,He,Z,Te),ke=Q?.heading!=null?Is(Q,Je+1):null,ze=ee[`${q}__${He}`],et=ze!=null?{...Xt,documentId:ze}:Xt,pe=Z.map(zt=>Ee(zt,He,Je,Rt,Be,Ve,et)).filter(Boolean),xe=ye?.section?.collapsible===!0,lt=d.jsx("button",{type:"button",className:"inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",disabled:Ne,title:Ne?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:zt=>{zt.preventDefault(),zt.stopPropagation(),Ta(q,He)},children:d.jsx(rs,{className:"h-5 w-5","aria-hidden":!0})}),Gt=d.jsxs(d.Fragment,{children:[!xe&&d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ke?d.jsx("p",{className:"text-sm font-medium text-foreground",children:ke}):d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Entry ",Je+1]}),lt]}),pe]});return d.jsx("div",{className:"rounded-md border p-3 space-y-3",children:ye?d.jsx(rd,{legend:ye.section.heading?.enabled?Is(ye.section,Je+1):ye.section.name,collapsible:ye.section.collapsible,defaultCollapsed:ye.section.defaultCollapsed,headerActions:xe?lt:void 0,onCollapsedChange:zt=>Ad(ye.section.id,He,zt),children:Gt}):Gt},`${_.id}-${He}`)})})},[Wt,oe,ee,rt,En,Zr,_a,Te,Me,qe,Ye,xt,$e,ar,Yt,Cn,_e,fe,jr,kr,_t,Qr,Ce,B,g,Xt,zr,_r,$.fields,ge,$r,fn,Oa,Ta,x,jt,Ue,he,L]),qb=d.jsx("div",{className:k?H("relative",c):H($a,N&&"dark",c),style:it,"data-form-renderer":k?void 0:"root",children:d.jsxs("div",{className:"relative",children:[L&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:d.jsx(wn,{})}),d.jsx("form",{onSubmit:kr,className:l?H("w-full min-w-0"):H("space-y-6 pb-[100px] w-full min-w-0",we[te]),"data-form-renderer":"form","data-form-renderer-layout":Wt?"grid":"stack",children:d.jsxs(__,{value:EI,children:[Jr&&$.steps&&d.jsx(AP,{steps:$.steps,currentStep:Er,completedSteps:Et,onStepClick:ir}),d.jsx(Ya.Provider,{value:{gridStretch:Wt},children:Wt?d.jsx("div",{className:l?"w-full min-w-0":"grid w-full min-w-0",style:{display:"grid",gridTemplateRows:_I,gridTemplateColumns:`repeat(${Nt}, 1fr)`,rowGap:Ur,columnGap:Ho},"data-form-renderer":"grid",children:kI.map(_=>Array.from({length:Nt},(q,R)=>{const Z=Ed(_);if(!Z)return null;if(Cd(_,R))return d.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:R+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${R}`);if(gP(_,R,Ub,Nn)){const Ne=yP(_,R,Nn);return Ne&&bP(_,R,Ne,Na(Ne.run.section,Ne.addMoreMeta?.blockId))?null:d.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:R+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`section-border-cover-${_}-${R}`)}const Q=Nn.get(`${_}-${R}`);if(Q){const Ne=Q.renderFields.filter(at=>Tr(at));if(Ne.length===0)return null;const ke=Q.addMoreMeta,ze=ke!=null?Vn.find(at=>at.addMoreFieldName===ke.addMoreFieldName)?.linkedFields??[]:[],et=ke!=null?_a(ke.addMoreFieldName,ke.blockId,ze,Te):!1,pe=Q.run.section,Oe=ke?.blockId,xe=Na(pe,Oe),lt=pe.collapsible&&xe?1:Q.rowSpan,Gt=Ed(Q.anchorRow,lt)??Z,zt=ke!=null?d.jsx("button",{type:"button",className:H("inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",l&&"text-red-600 hover:bg-red-500/10"),disabled:et,title:et?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:at=>{at.preventDefault(),at.stopPropagation(),Ta(ke.addMoreFieldName,ke.blockId)},children:d.jsx(rs,{className:"h-5 w-5","aria-hidden":!0})}):void 0;return d.jsx("div",{className:H("min-h-0 min-w-0",!(pe.collapsible&&xe)&&"self-stretch"),style:{gridRow:Gt,gridColumn:`${R+1} / span ${Q.colSpan}`},"data-form-renderer":"grid-cell","data-form-renderer-config-section-border-cell":!0,children:d.jsx(rd,{legend:Q.legend,className:pe.collapsible&&xe?void 0:"h-full",collapsible:pe.collapsible,defaultCollapsed:pe.defaultCollapsed,headerActions:zt,onCollapsedChange:at=>Ad(pe.id,Oe,at),children:d.jsx("div",{className:"grid w-full min-w-0",style:{gridTemplateColumns:`repeat(${Nt}, 1fr)`,gridTemplateRows:`repeat(${Q.rowSpan}, minmax(${String(It).endsWith("px")?It:Hn}, auto))`,rowGap:Ur,columnGap:Ho},children:Ne.map(at=>{const yt=rt(at),nr=Ro.scopeByFieldName[yt],Vr=nr?.scopedFieldNameMap?.[yt]||yt,en=(at.position?.order??Q.anchorRow)-Q.anchorRow,Hr=at.position?.column??1,{rowSpan:tn,columnSpan:se}=Cs([at],Nt),Le=ke!=null?ee[`${ke.addMoreFieldName}__${ke.blockId}`]:void 0,be=Le!=null?{...Xt,documentId:Le}:Xt;return d.jsx("div",{"data-field-name":yt,"data-form-renderer":"field-wrapper",className:"min-h-0 min-w-0",style:{gridRow:`${en+1} / span ${tn}`,gridColumn:`${Hr} / span ${se}`,...On(at)},children:d.jsx(Sn,{field:ao(at),value:Te[yt],error:Me[yt]||qe>0?Ye[yt]:void 0,onChange:Ge=>xt(yt,Ge),onBlur:()=>$e(yt),disabled:(at.type==="table"||at.type==="billingGrid")&&a==="fill"?!1:Se||!ar(Vr)||Yt,readOnly:(at.type==="table"||at.type==="billingGrid")&&a==="fill"?!1:lr(Vr,!!at.readOnly),isRequired:Cn(Vr),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:L,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:yt,buttonResponses:nr?.scopedButtonResponses??U,onButtonApiResponse:jr,onSubmit:kr,onReset:_t,onCancel:Qr,isSubmitting:Ce,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:be,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,scopedFormValues:nr?.scopedFormValues,scopedFieldNameMap:nr?.scopedFieldNameMap,excludedOptionValues:nr?.excludedOptionValues,hideTableRowControls:x})},at.id)})})})},`section-border-${Q.run.section.id}-${_}-${R}-${ke?.blockId??"base"}`)}const de=vg(_,R,Us,Tr).filter(Ne=>!(rt(Ne)?.includes("__addmore__")&&Ub.has(`${_}-${R}`)));if(de.length===0){const Ne=zs[`${_}-${R}`];if(Ne){const ke=$.fields.find(pe=>pe.type==="addmore"&&rt(pe)===Ne.addMoreFieldName),ze=ke!=null?En(ke):[],et=_a(Ne.addMoreFieldName,Ne.blockId,ze,Te);return d.jsx("div",{className:"min-h-0 min-w-0 flex flex-col items-center justify-center",style:{gridRow:Z,gridColumn:R+1},"data-form-renderer":"grid-cell","data-form-renderer-add-more-remove":!0,children:d.jsx("button",{type:"button",className:H("inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",l&&"text-red-600 hover:bg-red-500/10"),disabled:et,title:et?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:pe=>{pe.preventDefault(),pe.stopPropagation(),Ta(Ne.addMoreFieldName,Ne.blockId)},children:d.jsx(rs,{className:"h-5 w-5","aria-hidden":!0})})},`add-more-remove-${_}-${R}`)}return d.jsx("div",{className:"min-w-0",style:{pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${R}`)}const ye=de[0],{rowSpan:Ee,columnSpan:He}=Cs(de,Nt),Je=Ed(_,Ee)??Z;if(de.length===1&&ye.type==="section"){const Ne=$.fields.filter(ke=>ke.parentId===ye.id&&ke.position!=null).sort((ke,ze)=>{const et=typeof ke.position?.order=="number"?ke.position.order:0,pe=typeof ze.position?.order=="number"?ze.position.order:0;return et-pe});return d.jsx("div",{className:"min-w-0 min-h-0 w-full overflow-hidden flex flex-col h-full",style:{gridRow:Je,gridColumn:`${R+1} / span ${He}`,...On(ye)},"data-form-renderer":"grid-cell",children:d.jsx(cy,{field:ye,children:Ne.map(ke=>{const ze=ke.name||ke.key||ke.id,et=ke.hidden===!0;return fn(ke)&&($r(ze)||!et&&ze)?d.jsx("div",{"data-field-name":ze,"data-form-renderer":"field-wrapper",children:d.jsx(Sn,{field:ao(ke),value:Te[ze],error:Me[ze]||qe>0?Ye[ze]:void 0,onChange:Oe=>xt(ze,Oe),onBlur:()=>$e(ze),disabled:Se||!ar(ze)||Yt,readOnly:lr(ze,!!ke.readOnly),isRequired:Cn(ze),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:L,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:ze,buttonResponses:U,onButtonApiResponse:jr,onSubmit:kr,onReset:_t,onCancel:Qr,isSubmitting:Ce,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x})},ke.id):null})})},ye.id)}const Rt=yg(de),Be=de.some(Ne=>["file","camera","photoChoice","addmore","table","billingGrid"].includes(Ne.type)),Ve=d.jsx("div",{className:H("flex min-h-0 w-full flex-1 gap-3",Rt==="row"?"flex-row items-stretch":"flex-col items-stretch"),children:de.map(Ne=>{const ke=Ne.name||Ne.key||Ne.id,ze=Ne.type==="sectionHeading",et=Ro.scopeByFieldName[ke],pe=et?.scopedFieldNameMap?.[ke]||ke,Oe=et?.blockDocumentId!=null?{...Xt,documentId:et.blockDocumentId}:Xt,xe=Ne.appearance?.hideLabel??Ne.properties?.hideLabel??!1,lt=Ne.type==="table"||Ne.type==="billingGrid"?Ne.properties?.minWidth:void 0;return d.jsx("div",{"data-field-name":ke,"data-form-renderer":"field-wrapper",className:H("flex min-h-0 min-w-0 flex-1 flex-col",Xo(Ne),ze&&"items-center justify-center",xe&&"items-center"),style:{...lt?{minWidth:lt}:{},...On(Ne)},children:d.jsx(Sn,{field:ao(Ne),value:Te[ke],error:Me[ke]||qe>0?Ye[ke]:void 0,onChange:Gt=>xt(ke,Gt),onBlur:()=>$e(ke),disabled:(Ne.type==="table"||Ne.type==="billingGrid")&&a==="fill"?!1:Se||!ar(pe)||Yt,readOnly:(Ne.type==="table"||Ne.type==="billingGrid")&&a==="fill"?!1:lr(pe,!!Ne.readOnly),isRequired:Cn(pe),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:L,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:ke,buttonResponses:et?.scopedButtonResponses??U,onButtonApiResponse:jr,onSubmit:kr,onReset:_t,onCancel:Qr,isSubmitting:Ce,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Oe,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,scopedFormValues:et?.scopedFormValues,scopedFieldNameMap:et?.scopedFieldNameMap,excludedOptionValues:et?.excludedOptionValues,hideTableRowControls:x})},Ne.id)})});return d.jsx("div",{className:H(Zd(de),"self-stretch",Be?"overflow-visible":"overflow-hidden"),style:{gridRow:Je,gridColumn:`${R+1} / span ${He}`,...On(de[0])},"data-form-renderer":"grid-cell","data-field-name":de.map(Ne=>Ne.name||Ne.key||Ne.id).join(","),children:Ve},de.map(Ne=>Ne.id).join("-"))}))}):d.jsx("div",{className:l?"":"space-y-4","data-form-renderer":"stack",children:Tt.map(_=>{if(!Tr(_))return null;const q=TI.find(Z=>Z.kind==="border"&&Z.fields.some(Q=>Q.id===_.id));if(q)return q.fields[0]?.id!==_.id?null:d.jsx(rd,{legend:Is(q.run.section,0),collapsible:q.run.section.collapsible,defaultCollapsed:q.run.section.defaultCollapsed,onCollapsedChange:Z=>Ad(q.run.section.id,void 0,Z),children:q.fields.map(Z=>{const Q=rt(Z);return!Q||!Tr(Z)?null:d.jsxs("div",{"data-field-name":Q,"data-form-renderer":"field-wrapper",style:On(Z),children:[d.jsx(Sn,{field:ao(Z),value:Te[Q],error:Me[Q]||qe>0?Ye[Q]:void 0,onChange:de=>xt(Q,de),onBlur:()=>$e(Q),disabled:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:Se||!ar(Q)||Yt,readOnly:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:lr(Q,!!Z.readOnly),isRequired:Cn(Q),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:L,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:Q,buttonResponses:U,onButtonApiResponse:jr,onSubmit:kr,onReset:_t,onCancel:Qr,isSubmitting:Ce,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),Z.type==="addmore"&&La(Z)]},Z.id)})},`stack-border-${q.run.section.id}-${_.id}`);if(!_.parentId){const Z=Tt.filter(de=>!de.parentId&&Tr(de)&&ca(de)===ca(_)),Q=Nc(Z).slice(0,2);if(Q.length>1&&Q[0].id!==_.id)return null;if(Q.length>1){const de=yg(Q);return d.jsx("div",{"data-form-renderer":"shared-cell-stack",className:H("flex w-full min-w-0 gap-3",de==="row"?"flex-row items-stretch":"flex-col"),children:Q.map(ye=>{const Ee=ye.name||ye.key||ye.id;return d.jsxs("div",{"data-field-name":Ee,"data-form-renderer":"field-wrapper",className:H("min-w-0 flex-1 flex flex-col",Xo(ye)),style:On(ye),children:[d.jsx(Sn,{field:ao(ye),value:Te[Ee],error:Me[Ee]||qe>0?Ye[Ee]:void 0,onChange:He=>xt(Ee,He),onBlur:()=>$e(Ee),disabled:(ye.type==="table"||ye.type==="billingGrid")&&a==="fill"?!1:Se||!ar(Ee)||Yt,readOnly:(ye.type==="table"||ye.type==="billingGrid")&&a==="fill"?!1:lr(Ee,!!ye.readOnly),isRequired:Cn(Ee),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:L,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:Ee,buttonResponses:U,onButtonApiResponse:jr,onSubmit:kr,onReset:_t,onCancel:Qr,isSubmitting:Ce,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),ye.type==="addmore"&&La(ye)]},ye.id)})},Q.map(ye=>ye.id).join("-"))}}if(_.type==="section"){const Z=$.fields.filter(Q=>Q.parentId===_.id&&Q.position!=null).sort((Q,de)=>{const ye=typeof Q.position?.order=="number"?Q.position.order:0,Ee=typeof de.position?.order=="number"?de.position.order:0;return ye-Ee});return d.jsx(cy,{field:_,children:Z.map(Q=>{const de=Q.name||Q.key||Q.id,ye=Q.hidden===!0;return fn(Q)&&($r(de)||!ye&&de)?d.jsxs("div",{"data-field-name":de,"data-form-renderer":"field-wrapper",style:On(Q),children:[d.jsx(Sn,{field:ao(Q),value:Te[de],error:Me[de]||qe>0?Ye[de]:void 0,onChange:He=>xt(de,He),onBlur:()=>$e(de),disabled:Se||!ar(de)||Yt,readOnly:lr(de,!!Q.readOnly),isRequired:Cn(de),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:L,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:de,buttonResponses:U,onButtonApiResponse:jr,onSubmit:kr,onReset:_t,onCancel:Qr,isSubmitting:Ce,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),Q.type==="addmore"&&La(Q)]},Q.id):null})},_.id)}const R=_.name||_.key||_.id;return d.jsxs("div",{"data-field-name":R,"data-form-renderer":"field-wrapper",style:On(_),children:[d.jsx(Sn,{field:ao(_),value:Te[R],error:Me[R]||qe>0?Ye[R]:void 0,onChange:Z=>xt(R,Z),onBlur:()=>$e(R),disabled:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:Se||!ar(R)||Yt,readOnly:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:lr(R,!!_.readOnly),isRequired:Cn(R),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:L,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:R,buttonResponses:U,onButtonApiResponse:jr,onSubmit:kr,onReset:_t,onCancel:Qr,isSubmitting:Ce,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:zr,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),_.type==="addmore"&&La(_)]},_.id)})})}),u]})})]})});return P?d.jsx(_g,{handlers:P,moduleId:T??"",submissionContext:p,getAuthHeaders:E,onParentWorkflowSubmitResult:g,children:qb}):qb};var va="Tabs",[kP]=vr(va,[ta]),Xy=ta(),[_P,ld]=kP(va),Jy=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:a,activationMode:c="automatic",...u}=e,f=bo(a),[l,p]=ln({prop:n,onChange:o,defaultProp:s??"",caller:va});return d.jsx(_P,{scope:r,baseId:hn(),value:l,onValueChange:p,orientation:i,dir:f,activationMode:c,children:d.jsx(je.div,{dir:f,"data-orientation":i,...u,ref:t})})});Jy.displayName=va;var Qy="TabsList",Zy=b.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...o}=e,s=ld(Qy,r),i=Xy(r);return d.jsx(Ph,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:n,children:d.jsx(je.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});Zy.displayName=Qy;var eb="TabsTrigger",tb=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:o=!1,...s}=e,i=ld(eb,r),a=Xy(r),c=ob(i.baseId,n),u=sb(i.baseId,n),f=n===i.value;return d.jsx(Oh,{asChild:!0,...a,focusable:!o,active:f,children:d.jsx(je.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":u,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...s,ref:t,onMouseDown:De(e.onMouseDown,l=>{!o&&l.button===0&&l.ctrlKey===!1?i.onValueChange(n):l.preventDefault()}),onKeyDown:De(e.onKeyDown,l=>{[" ","Enter"].includes(l.key)&&i.onValueChange(n)}),onFocus:De(e.onFocus,()=>{const l=i.activationMode!=="manual";!f&&!o&&l&&i.onValueChange(n)})})})});tb.displayName=eb;var rb="TabsContent",nb=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:o,children:s,...i}=e,a=ld(rb,r),c=ob(a.baseId,n),u=sb(a.baseId,n),f=n===a.value,l=b.useRef(f);return b.useEffect(()=>{const p=requestAnimationFrame(()=>l.current=!1);return()=>cancelAnimationFrame(p)},[]),d.jsx(xr,{present:o||f,children:({present:p})=>d.jsx(je.div,{"data-state":f?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!p,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:l.current?"0s":void 0},children:p&&s})})});nb.displayName=rb;function ob(e,t){return`${e}-trigger-${t}`}function sb(e,t){return`${e}-content-${t}`}var TP=Jy,FP=Zy,PP=tb,OP=nb;function ib({className:e,...t}){return d.jsx(TP,{"data-slot":"tabs",className:H("flex flex-col gap-2",e),...t})}function cd({className:e,...t}){return d.jsx(FP,{"data-slot":"tabs-list",className:H("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function dd({className:e,...t}){return d.jsx(PP,{"data-slot":"tabs-trigger",className:H("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function ab({className:e,...t}){return d.jsx(OP,{"data-slot":"tabs-content",className:H("flex-1 outline-none",e),...t})}const IP="w-full justify-start border-b rounded-none h-auto p-0 bg-transparent gap-0",MP="rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none",LP=({steps:e,position:t,sidebarWidth:r,sticky:n=!0,stickyOffset:o="1rem",sidebarMaxHeight:s="calc(100vh - 6rem)"})=>{if(t==="top")return d.jsx(cd,{className:IP,"data-form-renderer":"workflow-tabs",children:e.map(c=>d.jsx(dd,{value:c.step_id,className:MP,"data-form-renderer":"workflow-tab",children:c.step_name},c.step_id))});const i=t==="left"||t==="right",a=i?{...r?{width:r,flexShrink:0}:{},...n?{top:o}:{},maxHeight:s}:void 0;return d.jsx(cd,{className:H("bg-transparent p-0 gap-0 rounded-none h-auto",i?H("flex flex-col items-stretch shrink-0 self-start z-10 bg-background overflow-y-auto",n&&"sticky",t==="left"?"border-r pr-2":"border-l pl-2",!r&&"w-56"):H("w-full justify-start",t==="bottom"?"border-t pt-0":"border-b")),style:a,"data-form-renderer":"workflow-tabs","data-form-renderer-nav-position":t,children:e.map(c=>d.jsx(dd,{value:c.step_id,className:H("rounded-none shadow-none data-[state=active]:shadow-none text-sm",i?H("justify-start w-full px-3 py-2.5 border-b-0",t==="left"?"border-l-2 border-transparent data-[state=active]:border-primary":"border-r-2 border-transparent data-[state=active]:border-primary"):H("border-b-2 border-transparent data-[state=active]:border-primary",t==="bottom"&&"border-t-2 border-b-0 data-[state=active]:border-t-primary")),"data-form-renderer":"workflow-tab",children:c.step_name},c.step_id))})},DP=new Set(["top","bottom","left","right"]),Ls={position:"top",sticky:!0,stickyOffset:"1rem",sidebarMaxHeight:"calc(100vh - 6rem)"};function lb(e){return typeof e=="string"&&DP.has(e)}function BP(...e){for(const t of e){const r=t?.ui_config?.stepsNavigation;if(r&&typeof r=="object")return r}}function ud(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function fd(e={},...t){const r=BP(...t),n=(e.position&&lb(e.position)?e.position:void 0)??(r?.position&&lb(r.position)?r.position:Ls.position),o=ud(e.sidebarWidth,r?.sidebarWidth),s=typeof e.sticky=="boolean"?e.sticky:typeof r?.sticky=="boolean"?r.sticky:Ls.sticky,i=ud(e.stickyOffset,r?.stickyOffset)??Ls.stickyOffset,a=ud(e.sidebarMaxHeight,r?.sidebarMaxHeight)??Ls.sidebarMaxHeight;return{position:n,sidebarWidth:o,sticky:s,stickyOffset:i,sidebarMaxHeight:a}}function $P(e,...t){return fd({position:e},...t).position}function jP(e){return e==="left"||e==="right"}function Pt({className:e="",...t}){return d.jsx("div",{"data-slot":"skeleton","data-form-renderer":"skeleton",className:`animate-pulse rounded-md bg-neutral-200 dark:bg-neutral-700 ${e}`.trim(),...t})}function zP({className:e="",position:t="top"}){if(t==="left"||t==="right")return d.jsxs("div",{className:`flex gap-4 ${t==="right"?"flex-row-reverse":"flex-row"} ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:[d.jsxs("div",{className:`flex w-56 shrink-0 flex-col gap-1 border-neutral-200 dark:border-neutral-700 py-1 ${t==="left"?"border-r pr-2":"border-l pl-2"}`,children:[d.jsx(Pt,{className:"h-10 w-full rounded-none"}),d.jsx(Pt,{className:"h-10 w-full rounded-none"}),d.jsx(Pt,{className:"h-10 w-full rounded-none"})]}),d.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-4 py-4",children:[d.jsx(Pt,{className:"h-4 w-32"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-40"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-24 w-full"})]})]});const n=d.jsxs("div",{className:`flex w-full gap-0 ${t==="bottom"?"border-t border-neutral-200 pt-0 dark:border-neutral-700":"border-b border-neutral-200 dark:border-neutral-700"}`,children:[d.jsx(Pt,{className:"h-10 w-24 rounded-none"}),d.jsx(Pt,{className:"h-10 w-28 rounded-none ml-1"}),d.jsx(Pt,{className:"h-10 w-20 rounded-none ml-1"})]}),o=d.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[d.jsx(Pt,{className:"h-4 w-32"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-40"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-36"}),d.jsx(Pt,{className:"h-24 w-full"})]});return d.jsx("div",{className:`flex flex-col gap-4 ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:t==="bottom"?d.jsxs(d.Fragment,{children:[o,n]}):d.jsxs(d.Fragment,{children:[n,d.jsx("div",{className:"mt-4",children:o})]})})}function UP(){return d.jsxs("div",{className:"flex flex-col gap-4 py-4","data-form-renderer":"form-loading-skeleton",children:[d.jsx(Pt,{className:"h-4 w-28"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-36"}),d.jsx(Pt,{className:"h-10 w-full"}),d.jsx(Pt,{className:"h-4 w-24"}),d.jsx(Pt,{className:"h-20 w-full"})]})}const VP=3e4,HP=10*6e4,WP=9e4,RP=15*6e4;function GP(e){return e!=null&&"on_success"in e&&e.on_success!=null}function KP(e,t){if(!t||typeof t!="object")return e;let r=e;return Object.entries(t).forEach(([n,o])=>{o!=null&&o!==""&&(r=r.replace(new RegExp(`\\{${n}\\}`,"g"),String(o)))}),r}const cb=({getWorkflowState:e,moduleId:t,tenantId:r,submissionContext:n,initialValues:o={},getAuthHeaders:s,onSuccess:i,bootstrapFeatureId:a,subjectUserId:c,viewStepId:u,clientId:f,className:l,onWorkflowSubmitResult:p,viewerContext:g,getViewerContext:m,dark:h=!1,themeVars:y,stepsNavigationPosition:S,stepsNavigationSidebarWidth:w,stepsNavigationSticky:A,stepsNavigationStickyOffset:x,stepsNavigationSidebarMaxHeight:F,workflowModalHandlers:N})=>{const k=kn.useQueryClient(),T=v.useMemo(()=>[c??"",u??"",f??""],[c,u,f]),P=v.useMemo(()=>({moduleId:t,tenantId:r,subjectUserId:c,viewStepId:u,clientId:f}),[t,r,c,u,f]),[E,C]=v.useState([]),[I,W]=v.useState(null),[M,z]=v.useState(null),[V,X]=v.useState(null),[D,B]=v.useState({}),L=v.useRef(null),K=v.useRef(null),ie=v.useRef(null),j=v.useRef(null),U=v.useMemo(()=>E&&Array.isArray(E)?E.filter(ve=>ve.feature_id):[],[E]),le=kn.useQuery({queryKey:["workflow-steps",t,a??"",r??"",T[0],T[1],T[2]],queryFn:()=>e({...P,featureId:a}),staleTime:VP,gcTime:HP}),oe=le.isPending,G=le.error?le.error instanceof Error?le.error.message:"Failed to load workflow steps":null;v.useEffect(()=>{const ve=le.data;if(!ve||E.length>0)return;const ce=ve.steps&&Array.isArray(ve.steps)?ve.steps:[];C(ce);const J=ce.filter($=>$.feature_id);if(J.length>0){const $=ve.current_step_id,fe=$&&J.some(st=>st.step_id===$);W(fe?$:J[0].step_id)}},[le.data,E.length,a]);const ae=v.useMemo(()=>{if(!I)return;const ve=E.find(J=>J.step_id===I),ce=L.current===I;return ve?.feature_id??(ce?j.current:void 0)??void 0},[I,E]),Ae=kn.useQuery({queryKey:["workflow-step",t,ae??"",r??"",T[0],T[1],T[2]],queryFn:()=>e({...P,featureId:ae}),enabled:!!ae,staleTime:WP,gcTime:RP,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),ee=Ae.isPending,ne=Ae.error?Ae.error instanceof Error?Ae.error.message:"Failed to load form":null,he=v.useMemo(()=>fd({position:S,sidebarWidth:w,sticky:A,stickyOffset:x,sidebarMaxHeight:F},M,le.data),[S,w,A,x,F,M,le.data]),Ie=he.position,Ue=jP(Ie);v.useEffect(()=>{!Ae.data||L.current===I||(z(Ae.data),X(null),L.current=null,j.current=null)},[Ae.data,I]),v.useEffect(()=>{X(ne)},[ne]),v.useEffect(()=>{ae===void 0&&L.current!==I&&(z(null),X(null),L.current=null,j.current=null)},[ae,I]);const re=v.useMemo(()=>{const ve=M?.form;if(!ve)return null;const ce=(r??nn()??"").trim()||"default",J=Ky({scope:ce,formId:ve._id,version:ve.version});return J?.value?J.value:Cg(M,n)},[M,n,r]),ge=v.useMemo(()=>{const ve=M?.BFF_submit_api;if(!ve?.url)return;let ce=ve.url;if(ce.startsWith("http://")||ce.startsWith("https://"))try{const fe=new URL(ce);ce=fe.pathname+fe.search}catch{}const J=s?.()??{},$={...ve.headers||{},"Content-Type":"application/json",...J};return{...ve,url:ce,headers:$}},[M?.BFF_submit_api,s]),Se=v.useMemo(()=>re?{...re,status:"published",...ge&&{BFF_submit_api:ge}}:null,[re,ge]);v.useEffect(()=>{if(!re?.id)return;const ve=(r??nn()??"").trim()||"default";qy({scope:ve,formId:re.id,version:re.version},re)},[re,r]);const pt=v.useMemo(()=>{if(!re)return null;const ve=Ws({config:re.config,layout:re.layout},null);if(!ve)return null;const ce=ve.rows,J=ve.columns,$={verticalSpacing:ve.verticalSpacing??ve.spacing??"16px",horizontalSpacing:ve.horizontalSpacing??ve.spacing??"16px",rowHeight:ve.rowHeight??Hn};let fe=1;if(Array.isArray(re.fields))for(const Te of re.fields){const Ye=Te?.position,Me=typeof Ye?.order=="number"?Ye.order:0,Ce=typeof Ye?.rowSpan=="number"?Ye.rowSpan:1;fe=Math.max(fe,Me+Ce)}return{rows:Math.min(ce,Math.max(1,fe)),columns:J,verticalSpacing:$.verticalSpacing,horizontalSpacing:$.horizontalSpacing,rowHeight:$.rowHeight}},[re]),Dt=v.useMemo(()=>{const ce=Se?.config?.theme?.cssVariables;if(!(!ce&&!y))return{...ce??{},...y??{}}},[Se?.config,y]),Bt=v.useCallback(()=>{k.invalidateQueries({queryKey:["workflow-steps",t]}),k.invalidateQueries({queryKey:["workflow-step",t]})},[k,t]),Ot=v.useCallback(ve=>{if(GP(ve)){const fe=ve.on_success,st=fe?.action;if(st==="redirect"&&fe?.redirect_url){const Te=KP(fe.redirect_url.trim(),n);window.location.href=Te;return}if(st==="move"){const Te=fe?.next_step_id,Ye=fe?.next_step_form;if(Te&&Ye){L.current=null,j.current=null;const Me=Ye.featureId??fe?.next_step_form_id??Ye._id;k.removeQueries({queryKey:["workflow-step",t,Me,r??"",T[0],T[1],T[2]]}),Bt(),C(Ce=>Ce.some(qe=>qe.step_id===Te)?Ce:[...Ce,{step_id:Te,step_name:Ye.name||"Next step",feature_id:Me}]),z(null),W(Te),i?.();return}return}if(st==="stay"){Bt(),i?.();return}}const ce=ve;ce.steps&&Array.isArray(ce.steps)&&C(ce.steps);const J=(ce.steps&&Array.isArray(ce.steps)?ce.steps:E).filter(fe=>fe.feature_id),$=ce.current_step_id;$&&J.some(fe=>fe.step_id===$)?W($):J.length>0&&W(J[0].step_id),z(null),Bt(),i?.(),p?.(ce)},[k,t,r,i,p,E,n,T,Bt]),Ar=v.useCallback(async ve=>M?.BFF_submit_api?(i?.(),{success:!0,message:"Saved successfully"}):{success:!1,message:"Submit not configured"},[M?.BFF_submit_api,i]),kt=v.useCallback((ve,ce)=>{},[]),Cr=v.useCallback(ve=>{},[]);if(oe)return d.jsx(zP,{className:l,position:S??he.position});if(G)return d.jsx("div",{className:H("rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",l),children:G});if(U.length===0)return d.jsx("div",{className:H("py-12 text-center text-sm text-muted-foreground",l),children:"No workflow steps configured."});const Xe=M?.step_blocked_message;return d.jsx("div",{className:H($a,h&&"dark","flex flex-col gap-4",l),style:Dt,"data-form-renderer":"workflow-steps-view",children:d.jsxs(ib,{value:I??"",onValueChange:ve=>W(ve),className:H(Ie!=="top"&&"gap-4",Ue&&"flex-row items-start",Ie==="right"&&"flex-row-reverse",Ie==="bottom"&&"flex-col-reverse"),orientation:Ue?"vertical":"horizontal",children:[d.jsx(LP,{steps:U,position:Ie,sidebarWidth:he.sidebarWidth,sticky:he.sticky,stickyOffset:he.stickyOffset,sidebarMaxHeight:he.sidebarMaxHeight}),U.map(ve=>d.jsx(ab,{value:ve.step_id,className:H("outline-none",Ue?"mt-0 flex-1 min-w-0":"mt-4"),children:ve.step_id!==I?null:ee?d.jsx(UP,{}):V?d.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:V}):Xe&&!M?.form?d.jsx("div",{className:H("rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",l),"data-form-renderer":"workflow-step-blocked",children:Xe}):Se?.fields?.length?d.jsxs("div",{className:"py-4 [&_*]:box-border",children:[Xe?d.jsx("div",{className:H("mb-4 rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200"),"data-form-renderer":"workflow-step-blocked",children:Xe}):null,(()=>{const ce=K.current!==I||ie.current!==(Se?.id??null);if(I&&Se&&ce){K.current=I,ie.current=Se.id??null;const J=Kn.getState();J.setSchema(Se,{forceReset:!0});const $=Kn.getState().values;J.setValues({...$,...o})}return null})(),d.jsx(Ms,{schema:Se,gridLayout:pt,omitRootWrapper:!0,moduleId:t,workflowModalHandlers:N,getAuthHeaders:s,submissionContext:n,initialValues:o,workflowStepId:I??void 0,viewerContext:g,getViewerContext:m,onSubmit:Ar,onChange:kt,onValidationError:Cr,onClose:()=>{},mode:"fill",unstyled:!0,onWorkflowSubmitResult:Ot,initialExtraSubmitPayload:Object.keys(D).length>0?D:void 0,onExtraSubmitPayloadChange:ce=>{if(ce&&typeof ce=="object"){const J={};ce.context_user_id!=null&&(J.context_user_id=ce.context_user_id),ce.id!=null&&(J.id=ce.id),ce.batch_id!=null&&(J.batch_id=ce.batch_id),ce.admission_batch_id!=null&&(J.admission_batch_id=ce.admission_batch_id),ce.program_id!=null&&(J.program_id=ce.program_id),Object.keys(J).length>0&&B($=>({...$,...J}))}}},Se.id)]}):d.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No form schema available for this step."})},ve.step_id))]})})},wa=new Map;function qP(e){if(e){wa.delete(e);return}wa.clear()}async function Sa(e,t,r){const n=wa.get(t);if(n!==void 0)return n;const o=e.replace(/\/$/,""),i=!!(await Qt.get(`${o}/${encodeURIComponent(t)}/meta`,{headers:r})).data?.standalone_workflow;return wa.set(t,i),i}function xa(e){const t={...e.getAuthHeaders?.()??{}};return e.clientId&&(t["x-client-id"]=e.clientId),e.userId&&(t["x-user-id"]=e.userId),t}function pd(e,t){Object.entries(t).forEach(([r,n])=>{n&&e.set(r,n)})}function db(e){const t=e.bffWorkflowsBasePath.replace(/\/$/,""),r=()=>xa({getAuthHeaders:e.getAuthHeaders,clientId:e.clientId,userId:e.userId}),n=o=>o?.trim()||e.moduleId?.trim()||"";return{async getWorkflowStateById({workflowId:o,moduleId:s,entryStepId:i}){const a=o.trim(),c=r();if(await Sa(t,a,c)){const p=new URLSearchParams;e.clientId&&p.set("client_id",e.clientId),e.userId&&p.set("user_id",e.userId),pd(p,{entry_step_id:i});const g=p.toString();return(await Qt.get(`${t}/${encodeURIComponent(a)}/standalone-state${g?`?${g}`:""}`,{headers:c})).data}const f=new URLSearchParams;return f.set("module_id",n(s)),e.clientId&&f.set("client_id",e.clientId),e.userId&&f.set("user_id",e.userId),pd(f,{entry_step_id:i}),(await Qt.get(`${t}/${encodeURIComponent(a)}/state?${f.toString()}`,{headers:c})).data},async navigateWorkflowStep({workflowId:o,moduleId:s,targetStepId:i}){const a=o.trim(),c=r();if(await Sa(t,a,c))return(await Qt.post(`${t}/${encodeURIComponent(a)}/standalone-navigate-step`,{workflow_id:a,target_step_id:i},{headers:c})).data;const f=n(s);return(await Qt.post(`${t}/modules/${encodeURIComponent(f)}/navigate-step`,{workflow_id:a,target_step_id:i},{headers:c})).data}}}async function ub(e){const t=e.bffWorkflowsBasePath.replace(/\/$/,""),r=xa({getAuthHeaders:e.getAuthHeaders,clientId:e.clientId,userId:e.subjectUserId});if(e.workflowId?.trim()){const i=e.workflowId.trim();if(await Sa(t,i,r)){const c=new URLSearchParams;e.clientId&&c.set("client_id",e.clientId),e.subjectUserId&&c.set("user_id",e.subjectUserId),pd(c,{step_id:e.viewStepId});const u=c.toString();return(await Qt.get(`${t}/${encodeURIComponent(i)}/standalone-state${u?`?${u}`:""}`,{headers:r})).data}}const n=new URLSearchParams;n.set("module_id",e.moduleId),e.featureId&&n.set("feature_id",e.featureId),e.tenantId&&n.set("tenant_id",e.tenantId),e.subjectUserId&&n.set("user_id",e.subjectUserId),e.viewStepId&&n.set("step_id",e.viewStepId),e.clientId&&n.set("client_id",e.clientId);const o=e.workflowId?.trim()?`${t}/${encodeURIComponent(e.workflowId.trim())}/state?${n.toString()}`:`${t}/modules/${encodeURIComponent(e.moduleId)}/state?${n.toString()}`;return(await Qt.get(o,{headers:r})).data}function YP(e){return typeof e=="object"&&e!==null&&"apiEndpoint"in e}function XP({formSchema:e}){const t=v.useMemo(()=>{if(!e)return[];const s=[];(!e.name||e.name.trim()==="")&&s.push({id:"form-name-required",type:"error",message:"Form name is required"});const i=new Set,a=new Set;e.fields.forEach((f,l)=>{const p=`field-${f.id}`;if(a.has(f.id)&&s.push({id:`${p}-duplicate-id`,type:"error",message:`Field "${f.label||f.name||`Field ${l+1}`}" has a duplicate ID`,fieldId:f.id}),a.add(f.id),f.name&&i.has(f.name)&&s.push({id:`${p}-duplicate-name`,type:"error",message:`Field "${f.label||f.name}" has a duplicate name: "${f.name}"`,fieldId:f.id}),f.name&&i.add(f.name),(!f.label||f.label.trim()==="")&&s.push({id:`${p}-missing-label`,type:"warning",message:`Field "${f.name||f.id}" is missing a label`,fieldId:f.id}),(!f.name||f.name.trim()==="")&&s.push({id:`${p}-missing-name`,type:"error",message:`Field "${f.label||f.id}" is missing a field name`,fieldId:f.id}),f.name&&!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(f.name)&&s.push({id:`${p}-invalid-name`,type:"error",message:`Field "${f.label||f.name}" has an invalid name. Use only letters, numbers, and underscores.`,fieldId:f.id}),["select","multiselect","radio","checkboxgroup"].includes(f.type)){const h=f.properties;(!h?.options||h.options.length===0)&&s.push({id:`${p}-no-options`,type:"warning",message:`Field "${f.label||f.name}" has no options defined`,fieldId:f.id})}f.parentId&&(e.fields.some(y=>y.id===f.parentId)||s.push({id:`${p}-orphaned`,type:"error",message:`Field "${f.label||f.name}" references a non-existent parent`,fieldId:f.id}));const m=(h,y)=>{if(y.has(h))return!0;y.add(h);const S=e.fields.find(w=>w.id===h);return S?.parentId?m(S.parentId,y):!1};f.parentId&&m(f.id,new Set)&&s.push({id:`${p}-circular-reference`,type:"error",message:`Field "${f.label||f.name}" has a circular parent reference`,fieldId:f.id})}),e.config.workflowTrigger?.workflowId&&(e.fields.some(l=>l.validation?.some(p=>p.type==="required"))||s.push({id:"workflow-no-required-fields",type:"info",message:"Form linked to workflow but has no required fields"}));const c=e.fields.filter(f=>!f.parentId),u=new Map;return c.forEach(f=>{const l=f.position.order;u.has(l)||u.set(l,[]),u.get(l).push(f)}),u.forEach((f,l)=>{f.length>3&&s.push({id:`row-${l}-too-many-fields`,type:"warning",message:`Row ${l+1} has ${f.length} fields (maximum recommended is 3)`})}),s},[e]),r=v.useMemo(()=>t.filter(s=>s.type==="error"),[t]),n=v.useMemo(()=>t.filter(s=>s.type==="warning"),[t]),o=v.useMemo(()=>r.length===0,[r]);return{issues:t,errors:r,warnings:n,isValid:o}}function JP({field:e,value:t,allValues:r,validateOnChange:n=!1,validateOnBlur:o=!0,debounceMs:s=qF}){const[i,a]=v.useState(),[c,u]=v.useState(!1),f=v.useRef(void 0),l=v.useRef(t),p=v.useCallback(async()=>{if(!e.validation||e.validation.length===0){a(void 0);return}u(!0);let S;for(const w of e.validation){const A=rn(t,w,r);if(typeof A=="string"){S=A;break}}return a(S),u(!1),S},[e.validation,t,r]),g=v.useCallback(()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{p()},s)},[p,s]);v.useEffect(()=>(n&&l.current!==t&&g(),l.current=t,()=>{f.current&&clearTimeout(f.current)}),[t,n,g]);const m=v.useCallback(()=>{o&&p()},[o,p]),h=v.useCallback(()=>{a(void 0)},[]),y=v.useCallback(S=>{a(S)},[]);return{error:i,isValidating:c,validate:p,handleBlur:m,clearError:h,setCustomError:y}}const fb="—";function er(){return{kind:"static",value:fb}}function QP(){return Tu({currencySymbol:"₹",emptyDisplay:fb,columns:[{id:"col_tariff",key:"tariff_type",label:"Tariff type",format:"text",align:"left"},{id:"col_service",key:"service",label:"Service",format:"text",align:"left"},{id:"col_unit",key:"unit_price",label:"Unit price",format:"currency",align:"right"},{id:"col_disc_pct",key:"discount_pct",label:"Discount (%)",format:"percent",align:"right"},{id:"col_disc_amt",key:"discount_amount",label:"Discount (₹)",format:"currency",align:"right"},{id:"col_net",key:"net_price",label:"Net price",format:"currency",align:"right"},{id:"col_tax",key:"tax_pct",label:"Tax (%)",format:"percent",align:"right"},{id:"col_total",key:"total",label:"Total",format:"currency",align:"right"}],rowSlots:[{kind:"static",row:{id:"registration_fee",label:"Registration fee",cells:{tariff_type:{kind:"label"},service:er(),unit_price:{kind:"api",path:"unit_price"},discount_pct:{kind:"input",inputType:"number"},discount_amount:{kind:"formula",expression:"cell('unit_price') * cell('discount_pct') / 100"},net_price:{kind:"formula",expression:"cell('unit_price') - cell('discount_amount')"},tax_pct:{kind:"api",path:"tax_pct"},total:{kind:"formula",expression:"cell('net_price') * (1 + cell('tax_pct') / 100)"}}}},{kind:"dynamic",block:{id:"line_items",apiArrayPath:"items",rowIdField:"id",cells:{tariff_type:er(),service:{kind:"api",path:"service"},unit_price:{kind:"api",path:"unit_price"},discount_pct:er(),discount_amount:{kind:"formula",expression:"cell('unit_price') * cell('discount_pct') / 100"},net_price:{kind:"formula",expression:"cell('unit_price') - cell('discount_amount')"},tax_pct:{kind:"api",path:"tax_pct"},total:{kind:"formula",expression:"cell('net_price') * (1 + cell('tax_pct') / 100)"}}}},{kind:"static",row:{id:"all_items_summary",label:"All items summary",cells:{tariff_type:{kind:"label"},service:er(),unit_price:{kind:"formula",expression:"SUM('unit_price', 'data')"},discount_pct:er(),discount_amount:{kind:"formula",expression:"SUM('discount_amount', 'data')"},net_price:{kind:"formula",expression:"SUM('net_price', 'data')"},tax_pct:er(),total:{kind:"formula",expression:"SUM('total', 'data')"}}}},{kind:"static",row:{id:"invoice_discount",label:"Invoice discount",cells:{tariff_type:{kind:"label"},service:er(),unit_price:er(),discount_pct:er(),discount_amount:{kind:"input",inputType:"number"},net_price:er(),tax_pct:er(),total:er()}}},{kind:"static",row:{id:"grand_total",label:"Grand total",cells:{tariff_type:{kind:"label"},service:er(),unit_price:er(),discount_pct:er(),discount_amount:er(),net_price:er(),tax_pct:er(),total:{kind:"formula",expression:"SUM('total', 'data') - cellInRow('invoice_discount', 'discount_amount')"}}}}]})}const ZP={text:{type:"text",label:"Text Input",icon:"Type",category:"input",description:"Single line text input",defaultProps:{label:"Text Field",name:"text_field",placeholder:"Enter text..."}},number:{type:"number",label:"Number Input",icon:"Hash",category:"input",description:"Numeric input with optional constraints",defaultProps:{label:"Number Field",name:"number_field",placeholder:"0",properties:{min:0,step:1}}},email:{type:"email",label:"Email",icon:"Mail",category:"input",description:"Email address input with validation",defaultProps:{label:"Email",name:"email_field",placeholder:"example@domain.com",validation:[{type:"email"}]}},phone:{type:"phone",label:"Phone",icon:"Phone",category:"input",description:"Phone number input",defaultProps:{label:"Phone Number",name:"phone_field",placeholder:"+91 12345 67890"}},otp:{type:"otp",label:"OTP",icon:"ShieldCheck",category:"input",description:"One-time password with separate digit boxes",defaultProps:{label:"OTP",name:"otp_field",properties:{otpLength:4,numericOnly:!0},validation:[{type:"required",message:"Please enter the OTP"}]}},password:{type:"password",label:"Password",icon:"Lock",category:"input",description:"Secure password input",defaultProps:{label:"Password",name:"password_field",placeholder:"••••••••"}},url:{type:"url",label:"URL",icon:"Link",category:"input",description:"URL input with validation",defaultProps:{label:"URL",name:"url_field",placeholder:"https://example.com",validation:[{type:"url"}]}},date:{type:"date",label:"Date",icon:"Calendar",category:"datetime",description:"Date picker",defaultProps:{label:"Date",name:"date_field",placeholder:"Select date"}},time:{type:"time",label:"Time",icon:"Clock",category:"datetime",description:"Time picker",defaultProps:{label:"Time",name:"time_field",placeholder:"Select time"}},datetime:{type:"datetime",label:"Date & Time",icon:"CalendarClock",category:"datetime",description:"Combined date and time picker",defaultProps:{label:"Date & Time",name:"datetime_field",placeholder:"Select date and time"}},daterange:{type:"daterange",label:"Date Range",icon:"CalendarRange",category:"datetime",description:"Select a range of dates",defaultProps:{label:"Date Range",name:"daterange_field",placeholder:"Select date range"}},select:{type:"select",label:"Dropdown",icon:"ChevronDown",category:"selection",description:"Single selection dropdown",defaultProps:{label:"Select",name:"select_field",placeholder:"Select an option",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],searchable:!0,clearable:!0}}},multiselect:{type:"multiselect",label:"Multi Select",icon:"ListChecks",category:"selection",description:"Multiple selection dropdown",defaultProps:{label:"Multi Select",name:"multiselect_field",placeholder:"Select options",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],searchable:!0}}},radio:{type:"radio",label:"Radio Group",icon:"CircleDot",category:"selection",description:"Single selection radio buttons",defaultProps:{label:"Radio Group",name:"radio_field",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}]}}},checkbox:{type:"checkbox",label:"Checkbox",icon:"CheckSquare",category:"selection",description:"Single checkbox for boolean values",defaultProps:{label:"I agree to the terms",name:"checkbox_field"}},toggle:{type:"toggle",label:"Toggle",icon:"ToggleLeft",category:"selection",description:"Toggle switch with configurable text values",defaultProps:{label:"Toggle",name:"toggle_field",description:"Toggle to switch between states",properties:{onValue:"On",offValue:"Off"}}},checkboxgroup:{type:"checkboxgroup",label:"Checkbox Group",icon:"CheckSquare",category:"selection",description:"Multiple checkboxes for selecting multiple values",defaultProps:{label:"Checkbox Group",name:"checkboxgroup_field",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}]}}},selectablelist:{type:"selectablelist",label:"Selectable List",icon:"ListChecks",category:"selection",description:"List from response or context; select all or specific items. Value = selected array.",defaultProps:{label:"Recipients",name:"recipients",properties:{dataSourceContextKey:"recipients",labelField:"name",valueField:"email",showSelectAll:!0,selectAllByDefault:!0}}},asyncsearch:{type:"asyncsearch",label:"Async Search",icon:"Search",category:"selection",description:"Typeahead search against an API; submitted value is the selected option value.",defaultProps:{label:"Search",name:"async_search",placeholder:"Type to search…",properties:{apiEndpoint:"/api/form-builder/search",apiMethod:"GET",searchQueryParam:"q",searchSchedule:"debounce",intervalMs:300,minQueryLength:0,clearable:!0}}},terms:{type:"terms",label:"Terms & Conditions",icon:"FileText",category:"special",description:"Terms and conditions confirmation checkbox",defaultProps:{label:"I confirm that the details are true to my knowledge",name:"terms_conditions",validation:[{type:"required"}]}},textarea:{type:"textarea",label:"Text Area",icon:"AlignLeft",category:"rich",description:"Multi-line text input",defaultProps:{label:"Text Area",name:"textarea_field",placeholder:"Enter your text here...",properties:{minLength:0,maxLength:1e3}}},richtext:{type:"richtext",label:"Rich Text",icon:"FileText",category:"rich",description:"Rich text editor with formatting",defaultProps:{label:"Rich Text",name:"richtext_field"}},file:{type:"file",label:"File Upload",icon:"Upload",category:"rich",description:"File upload with drag and drop",defaultProps:{label:"File Upload",name:"file_field",properties:{accept:["image/*","application/pdf"],maxSize:5*1024*1024}}},camera:{type:"camera",label:"Use camera",icon:"Camera",category:"rich",description:"Take a photo with your camera",defaultProps:{label:"Take photo",name:"camera_field",properties:{accept:["image/*"],maxSize:5*1024*1024,multiple:!1}}},photoChoice:{type:"photoChoice",label:"Photo (upload or camera)",icon:"ImagePlus",category:"rich",description:"Upload a file or capture with the camera",defaultProps:{label:"Photo",name:"photo_choice_field",properties:{accept:["image/*"],maxSize:5*1024*1024,maxFiles:1}}},signature:{type:"signature",label:"Signature",icon:"Pencil",category:"rich",description:"Digital signature capture",defaultProps:{label:"Signature",name:"signature_field"}},rating:{type:"rating",label:"Rating",icon:"Star",category:"rich",description:"Star rating input",defaultProps:{label:"Rating",name:"rating_field",properties:{max:5,allowHalf:!1,icon:"star"}}},slider:{type:"slider",label:"Slider",icon:"SlidersHorizontal",category:"rich",description:"Numeric slider input",defaultProps:{label:"Slider",name:"slider_field",properties:{min:0,max:100,step:1,showValue:!0}}},table:{type:"table",label:"Table",icon:"Table",category:"special",description:"Repeatable table rows",defaultProps:{label:"Table",name:"table_field",properties:{columns:[],minRows:1,maxRows:10,allowAddRow:!0,allowDeleteRow:!0}}},billingGrid:{type:"billingGrid",label:"Billing Grid",icon:"Receipt",category:"special",description:"Configurable billing/tariff grid with formulas and API line items",defaultProps:{label:"Billing",name:"billing",properties:QP()}},aadhaar:{type:"aadhaar",label:"Aadhaar",icon:"CreditCard",category:"special",description:"Indian Aadhaar number input",defaultProps:{label:"Aadhaar Number",name:"aadhaar_field",placeholder:"XXXX XXXX XXXX"}},section:{type:"section",label:"Section",icon:"LayoutPanelTop",category:"container",description:"Group fields in a collapsible section",defaultProps:{label:"Section",name:"section",properties:{collapsible:!0,defaultCollapsed:!1,columns:1}}},group:{type:"group",label:"Group",icon:"Group",category:"container",description:"Group fields without visual separator",defaultProps:{label:"Group",name:"group"}},columns:{type:"columns",label:"Columns",icon:"Columns",category:"container",description:"Multi-column layout",defaultProps:{label:"Columns",name:"columns",properties:{columns:2}}},divider:{type:"divider",label:"Divider",icon:"Minus",category:"visual",description:"Horizontal line separator",defaultProps:{label:"",name:"divider"}},header:{type:"header",label:"Header",icon:"Heading",category:"visual",description:"Section header text (full row, configurable size)",defaultProps:{label:"Header",name:"header",properties:{headingLevel:"h3",showHorizontalLine:!0}}},sectionHeading:{type:"sectionHeading",label:"Section Heading",icon:"Heading",category:"visual",description:"Heading inside a grid box with configurable position and size",defaultProps:{label:"Section Heading",name:"section_heading",properties:{position:"top-left",headingLevel:"h3",showHorizontalLine:!0}}},spacer:{type:"spacer",label:"Spacer",icon:"Space",category:"visual",description:"Empty space for padding",defaultProps:{label:"",name:"spacer"}},textLabel:{type:"textLabel",label:"Text Label",icon:"Tag",category:"visual",description:"Standalone label text (no input)",defaultProps:{label:"Label",name:"text_label"}},status:{type:"status",label:"Status",icon:"ListChecks",category:"visual",description:"Populate status from Status API; label + response key; true = completed",defaultProps:{label:"Admission Status",name:"status_field",properties:{source:"api",statuses:[{label:"Registered",key:"registered"},{label:"Form Submitted",key:"formSubmitted"},{label:"Documents Verification",key:"documentsVerification"},{label:"Photos Clicked",key:"photosClicked"},{label:"Fitness Verification",key:"fitnessVerification"},{label:"Payment Completed",key:"paymentCompleted"},{label:"Hostel Allotted",key:"hostelAllotted"},{label:"Admission Completed",key:"admissionCompleted"}],showStatusText:!1,statusTextPath:"admissionStatus",showCurrentIndicator:!0}}},button:{type:"button",label:"Button",icon:"MousePointerClick",category:"special",description:"Clickable button element",defaultProps:{label:"Button",name:"button_field",properties:{variant:"default",size:"default",action:"download"}}},editButton:{type:"editButton",label:"Edit Button",icon:"Pencil",category:"special",description:"Toggle edit mode: enable/disable or show/hide other fields and buttons (no API call)",defaultProps:{label:"Edit",name:"edit_button",properties:{buttonText:"Edit",variant:"outline",size:"default",hideLabel:!1,rules:[]}}},addmore:{type:"addmore",label:"Add More",icon:"Plus",category:"special",description:"Duplicate linked fields as a new runtime block",defaultProps:{label:"Add More",name:"addmore_field",properties:{linkedFieldNames:[],linkedSectionIds:[],variant:"outline",size:"default"}}},customizeSections:{type:"customizeSections",label:"Customise Sections",icon:"ListFilter",category:"special",description:"Show or hide UI sections defined by Section Heading fields",defaultProps:{label:"Customise Sections",name:"customize_sections",properties:{sectionHeadingNames:[],defaultHiddenSectionNames:[],variant:"outline",size:"default",buttonText:"Customise sections",menuTitle:"VISIBLE SECTIONS"}}}},pb={padding:"md",showBorder:!1};function mb(e,t){const r="full";return e?{padding:e.padding??pb.padding,maxWidth:e.maxWidth??r,showBorder:e.showBorder??pb.showBorder}:{padding:"md",maxWidth:r,showBorder:!1}}function eO(e){switch(e??"md"){case"none":return"";case"sm":return"p-3";case"lg":return"p-6 md:p-8";default:return"p-4 md:p-6"}}function tO(e,t){if(t==="full-bleed")return"w-full max-w-none";switch(e??"full"){case"full":return"w-full max-w-none";case"sm":return"mx-auto w-full max-w-screen-sm";case"md":return"mx-auto w-full max-w-screen-md";case"lg":return"mx-auto w-full max-w-screen-lg";case"xl":return"mx-auto w-full max-w-screen-xl";case"2xl":return"mx-auto w-full max-w-2xl";case"4xl":return"mx-auto w-full max-w-4xl";case"5xl":return"mx-auto w-full max-w-5xl";case"6xl":return"mx-auto w-full max-w-6xl";case"7xl":return"mx-auto w-full max-w-7xl";default:return"w-full max-w-none"}}function rO(e){switch(e){case"sidebar-main":return"grid grid-cols-1 gap-6 lg:grid-cols-[240px_1fr]";case"full-bleed":return"w-full";default:return"w-full"}}function nO(e){const t=mb(e.container,e.layout);return H(rO(e.layout),tO(t.maxWidth,e.layout),eO(t.padding),t.showBorder&&"rounded-lg border border-border")}const Aa=1;function oO(){return{version:Aa,layout:"stack",container:{padding:"md",maxWidth:"full",showBorder:!1},dataBindings:[],widgets:[],filterGroups:[]}}function hb(e){return{...e,config:e.config??{},children:Array.isArray(e.children)?e.children.map(hb):void 0}}function sO(e){return{version:Aa,layout:e.layout??"stack",container:mb(e.container,e.layout),meta:e.meta,dataBindings:Array.isArray(e.dataBindings)?e.dataBindings:[],dataApis:e.dataApis??{},prepopulateApi:e.prepopulateApi,widgets:Array.isArray(e.widgets)?e.widgets.map(hb):[],filterGroups:Array.isArray(e.filterGroups)?e.filterGroups:[],eventHandlers:e.eventHandlers??[],navigation:e.navigation}}function iO(e){const t=e;return!t||typeof t!="object"?oO():(t.version!==Aa&&(t.version=Aa),sO(t))}const gb={};let yb=null;function aO(e){yb=e}function lO(){return(gb?.VITE_API_BASE_URL?.trim()||gb?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const Ds=Ct.create({baseURL:lO()});Ds.interceptors.request.use(e=>{const t=nn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=yb?.();if((!r||Object.keys(r).length===0)&&(r=ds()),r){const n=e.headers??{};for(const[o,s]of Object.entries(r))s!==void 0&&s!==""&&(n[o]=s);e.headers=n}return e});async function bb(e){const t=await Ds.get("/api/page-builder/pages/resolve",{params:e}),r=t.data?.data??t.data;if(!r?.pageId)throw new Error("Page resolve failed: no pageId returned");return r}async function md(e,t,r){const n=await Ds.get(`/api/page-builder/pages/${e}/render`,{params:{clientId:t,...r!==void 0?{version:r}:{}}}),o=n.data?.data??n.data;if(!o?.schema)throw new Error("Page render failed: no schema returned");return o}async function hd(e){const{clientId:t,api:r,context:n,filterState:o}=e,s=await Ds.post(`/api/page-builder/clients/${t}/data-sources/execute`,{api:r,context:n,filterState:o});return s.data?.data??s.data}function cO(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t)){if(!o.trim())continue;const s=Re(e,o);s!==void 0&&(r[n]=s)}return r}const gd=v.createContext(null);function dO(e,t){if(t.parentContext)return"idle";const r=e.prepopulateApi,n=String(t.clientIdProp??t.externalContext.clientId??"");return r?.enabled&&r.api?.path&&n?"loading":"idle"}function vb(e,t){const r={};for(const n of e){let o;switch(n.source){case"route.param":o=n.param?t[n.param]:void 0;break;case"route.query":o=n.param?t[n.param]:void 0;break;case"context.user":o=n.param?t.user?.[n.param]:t.user;break;case"context.client":o=n.param?t.client?.[n.param]:t.client??t.clientId;break;case"context.tenant":o=n.param?t.tenant?.[n.param]:t.tenant??t.tenantId;break;case"static":o=n.value;break;case"widget.state":o=n.sample;break;default:o=void 0}o===void 0&&n.sample!==void 0&&(o=n.sample),o!==void 0&&(r[n.key]=o)}return r}function uO({schema:e,context:t={},clientId:r,nestingDepth:n=0,onAction:o,getWorkflowState:s,workflowModalHandlers:i,getAuthHeaders:a,parentContext:c,children:u}){const[f,l]=v.useState(()=>c?c.filterGroups:{}),p=v.useRef(f);p.current=f;const[g,m]=v.useState({}),[h,y]=v.useState(()=>dO(e,{parentContext:c,clientIdProp:r,externalContext:t})),S=v.useRef(null),w=String(r??t.clientId??c?.clientId??""),A=JSON.stringify(t);v.useEffect(()=>{if(c)return;const E=e.prepopulateApi;if(!E?.enabled||!E.api?.path||!w){m({}),y("idle"),S.current=null;return}const C=JSON.stringify({path:E.api.path,method:E.api.method,queryParams:E.api.queryParams,headers:E.api.headers,bodyFields:E.api.bodyFields,auth:E.api.auth,mapping:E.contextMapping,bindings:e.dataBindings,context:A});if(S.current===C)return;let I=!1;return S.current=C,y("loading"),(async()=>{try{const W=vb(e.dataBindings??[],t),M={...t,...W},z=await hd({clientId:w,api:E.api,context:M});if(I)return;const V=cO(z,E.contextMapping);m({...V,prepopulateResponse:z}),y("ready")}catch{I||(m({}),y("error"))}})(),()=>{I=!0,S.current=null}},[c,e.prepopulateApi,e.dataBindings,A,w]);const x=v.useMemo(()=>{if(c)return{...c.context,...t};const E=vb(e.dataBindings??[],t);return{...t,...E,...g}},[c,t,e.dataBindings,g]),F=String(r??x.clientId??c?.clientId??""),N=v.useCallback((E,C,I)=>{l(W=>({...W,[E]:{...W[E]??{},[C]:I}}))},[]),k=v.useCallback(E=>p.current[E]??{},[]),T=v.useCallback((E,C,I,W)=>{(o??c?.onAction)?.({...E,sourceWidgetId:C,event:I,payload:W})},[o,c?.onAction]),P=v.useMemo(()=>({schema:e,context:x,clientId:F,prepopulateStatus:c?.prepopulateStatus??h,nestingDepth:n,onAction:o??c?.onAction,getWorkflowState:s??c?.getWorkflowState,workflowModalHandlers:i??c?.workflowModalHandlers,getAuthHeaders:a??c?.getAuthHeaders,filterGroups:f,setFilterValue:N,getFilterGroup:k,dispatchAction:T}),[e,x,F,h,n,o,c?.onAction,s,c?.getWorkflowState,i,c?.workflowModalHandlers,a,c?.getAuthHeaders,f,N,k,T]);return d.jsx(gd.Provider,{value:P,children:u})}function Br(){const e=v.useContext(gd);if(!e)throw new Error("usePageContext must be used within PageContextProvider");return e}function fO(){return v.useContext(gd)}const pO=5,wb=1;function Vo(e){return Number.isFinite(e)?Math.min(pO,Math.max(wb,Math.round(e))):wb}function mO(e,t){const r=Vo(t),n=Array.from({length:r},()=>[]);return e.forEach((o,s)=>{const i=o.config,a=i.columnIndex!==void 0?Math.min(Math.max(0,i.columnIndex),r-1):s%r;n[a].push(o)}),n}function hO(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):0}function gO(e,t){const r=Math.max(1,t),n=Math.min(100,Math.max(0,Math.round(e))),o=Math.floor(n/r),s=n-o*r;return Array.from({length:r},(i,a)=>o+(a<s?1:0))}function Sb(e){return gO(100,Vo(e))}function yO(e){const t=e.trim(),r=/^(\d+(?:\.\d+)?)\s*%?$/.exec(t);return r?hO(Number(r[1])):null}function xb(e,t){const r=Vo(t),n=[];for(let s=0;s<r;s++){const i=yO(e?.[s]??"");if(i===null)return Sb(r);n.push(i)}return n.reduce((s,i)=>s+i,0)!==100?Sb(r):n}function bO(e){return e==="sm"?"gap-2":e==="lg"?"gap-6":"gap-4"}function Ab(e,t){return xb(t,Vo(e)).map(n=>`minmax(0, ${n}fr)`).join(" ")}function vO(e){return e.length?e.map(t=>`minmax(0, ${t}fr)`).join(" "):"minmax(0, 1fr)"}function wO(e,t,r,n){const o=Vo(t),s=mO(e,o),i=xb(r,o);if(!(n?.collapseEmpty!==!1))return{columns:s,gridTemplate:Ab(o,r),sourceIndices:s.map((p,g)=>g)};const c=s.map((p,g)=>({colChildren:p,index:g,percent:i[g]??0})).filter(p=>p.colChildren.length>0);if(c.length===0||c.length===s.length)return{columns:s,gridTemplate:Ab(o,r),sourceIndices:s.map((p,g)=>g)};const u=c.reduce((p,g)=>p+g.percent,0),f=c.map(p=>u>0?Math.round(p.percent/u*100):Math.round(100/c.length)),l=100-f.reduce((p,g)=>p+g,0);return l!==0&&f.length>0&&(f[0]+=l),{columns:c.map(p=>p.colChildren),gridTemplate:vO(f),sourceIndices:c.map(p=>p.index)}}function yd(e,t="solid"){return e?t==="dashed"?"rounded-md border border-dashed border-border":"rounded-md border border-border":""}function SO(e){return H(yd(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-3")}function xO(e){return H(yd(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-2")}function AO(e,t){return e.columnBorders?.[t]!==void 0?!!e.columnBorders[t]:!!e.showColumnBorders}function CO(e,t){const r=AO(e,t);return H(yd(r,e.borderStyle??"dashed"),r&&"p-2")}function EO(e){if(e)return{minHeight:`${e}vh`}}function NO({widget:e,renderChildren:t}){const r=e.config,[n,o]=v.useState(r.defaultCollapsed??!1);return d.jsxs("section",{className:H("space-y-4",SO(r)),"data-widget-id":e.id,children:[r.heading&&d.jsx("div",{className:"flex items-center gap-2",children:r.collapsible?d.jsx("button",{type:"button",className:"text-left text-lg font-semibold hover:underline",onClick:()=>o(s=>!s),children:r.heading}):d.jsx("h2",{className:"text-lg font-semibold",children:r.heading})}),r.showDivider&&d.jsx("hr",{className:"border-border"}),!n&&e.children?.length?d.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function kO({widget:e,renderChildren:t}){const r=e.config,n=Vo(r.columns??2),o=r.collapseEmptyColumns!==!1,s=wO(e.children??[],n,r.columnWidths,{collapseEmpty:o});return d.jsx("div",{className:H("grid w-full min-w-0 items-stretch",bO(r.gap),xO(r)),style:{gridTemplateColumns:s.gridTemplate,...EO(r.minHeightPercent)},"data-widget-id":e.id,children:s.columns.map((i,a)=>{const c=s.sourceIndices[a]??a;return d.jsx("div",{className:H("flex min-h-[inherit] min-w-0 flex-col space-y-4 overflow-hidden",CO(r,c)),children:t?.(i)},c)})})}function _O({widget:e,renderChildren:t}){const r=e.config,n=r.variant==="outline"?"border bg-background":r.variant==="elevated"?"border bg-background shadow-md":"border bg-card";return d.jsxs("div",{className:H("rounded-lg p-4",n),"data-widget-id":e.id,children:[(r.title||r.subtitle)&&d.jsxs("div",{className:"mb-4",children:[r.title&&d.jsx("h3",{className:"font-semibold",children:r.title}),r.subtitle&&d.jsx("p",{className:"text-sm text-muted-foreground",children:r.subtitle})]}),e.children?.length?d.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function Cb(e,t){if(e.variable){const r=t[e.variable];return r!=null?String(r):e.fallback??e.text??""}return e.text??""}function TO({widget:e}){const t=e.config,{context:r}=Br(),n=Cb(t,r),o=t.level??2,s=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left",i=o===1?"text-3xl":o===2?"text-2xl":o===3?"text-xl":"text-lg";return d.jsx("div",{role:"heading","aria-level":o,className:H("font-semibold tracking-tight",i,s),"data-widget-id":e.id,children:n})}function FO({widget:e}){const t=e.config,{context:r}=Br(),n=Cb(t,r),o=t.preset==="caption"?"text-sm text-muted-foreground":t.preset==="small"?"text-xs text-muted-foreground":"text-base",s=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left";return d.jsx("p",{className:H(o,s),"data-widget-id":e.id,children:n})}function PO(e,t){return!e||typeof e!="string"?e:e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=n.trim(),s=t[o];return s==null?"":String(s)})}function Eb(e,t){const r={...e};for(const[n,o]of Object.entries(r))typeof o=="string"&&(r[n]=PO(o,t));return r}function OO(e,t){return e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=t[n.trim()];return o!=null?String(o):""})}function Nb(e,t,r,n){if(e.type==="navigate"){const o=OO(e.href,t);if(!o.trim())return;e.openIn==="new"?window.open(o,"_blank","noopener,noreferrer"):window.location.assign(o);return}if(e.type==="navigate_page"&&e.pageId){r({...e,params:e.params?Eb(e.params,t):void 0},n,"click");return}if(e.type==="workflow"&&e.workflowId){r(e,n,"click");return}r(e,n,"click")}function IO({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Br();return d.jsx(Zt,{variant:t.variant??"default",size:t.size??"default","data-widget-id":e.id,onClick:()=>Nb(t.action,r,n,e.id),children:t.label})}const MO={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between"},LO={sm:"gap-2",md:"gap-3",lg:"gap-4"};function DO({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Br(),o=t.buttons??[];return d.jsx("div",{className:H("flex flex-wrap items-center",MO[t.align??"start"],LO[t.gap??"sm"],t.wrap===!1&&"flex-nowrap"),"data-widget-id":e.id,children:o.map(s=>d.jsx(Zt,{variant:s.variant??"outline",size:s.size??"default","data-widget-id":e.id,"data-button-id":s.id,onClick:()=>Nb(s.action,r,n,e.id),children:s.label},s.id))})}function BO(e){const t=e.prepopulateApi;return!!(t?.enabled&&t.api?.path)}function $O(e,t){return e&&(t==="idle"||t==="loading")}function jO(e,t){return!e||t==="ready"||t==="error"}function zO(e,t){const r=Re(e,t??"");return r===void 0?null:r}function kb(e,t){if(e.mode==="pageApi"&&e.dataSourceRef)return t[e.dataSourceRef];if(e.mode==="api")return e.api}function _b({widgetId:e,dataSource:t,enabled:r=!0,page:n,pageSize:o,search:s}){const{schema:i,context:a,clientId:c,getFilterGroup:u,prepopulateStatus:f}=Br(),l=v.useMemo(()=>t.filterGroupKey?u(t.filterGroupKey):{},[t.filterGroupKey,u]),p=t.mode==="context"&&BO(i),g=$O(p,f),m=r&&(t.mode==="static"||(t.mode==="context"?jO(p,f):!!c)),h=v.useMemo(()=>["page-ds",e,t,a,l,n,o,s,f],[e,t,a,l,n,o,s,f]),y=kn.useQuery({queryKey:h,enabled:m,staleTime:kb(t,i.dataApis??{})?.staleTimeMs??3e4,queryFn:async()=>{if(t.mode==="static")return t.staticData;if(t.mode==="context")return zO(a,t.contextPath);const S=kb(t,i.dataApis??{});if(!S)throw new Error(`No API config for data source on widget ${e}`);const w={...a};if(t.requestBindings)for(const F of t.requestBindings){let N;F.source==="binding"?N=a[F.key]:F.source==="filter"&&(N=l[F.key]),N!==void 0&&(w[F.param]=N)}const x={...Eb(w,a),...n!==void 0?{page:n,pageSize:o,search:s}:{}};return hd({clientId:c,api:S,context:x,filterState:l})}});return{...y,isLoading:y.isLoading||g,isPending:y.isPending||g,isFetching:y.isFetching||g}}function bd(e,t){if(e==null)return"";if(!t||t.type==="none")return String(e);switch(t.type){case"number":{const r=Number(e);return Number.isNaN(r)?String(e):r.toFixed(t.decimals??0)}case"currency":{const r=Number(e);return Number.isNaN(r)?String(e):new Intl.NumberFormat(void 0,{style:"currency",currency:t.currency??"USD"}).format(r)}case"percent":{const r=Number(e);return Number.isNaN(r)?String(e):`${r.toFixed(t.decimals??0)}%`}case"date":{const r=new Date(String(e));return Number.isNaN(r.getTime())?String(e):r.toLocaleDateString(void 0,{...t.format?{}:{}})}case"template":return t.template.replace(/\{\{value\}\}/g,String(e));default:return String(e)}}function Bs(e,t){const r=Re(e,t.path);return r==null?t.fallback??r:t.formatter?bd(r,t.formatter):r}function UO(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t))o in e&&(r[n]=e[o]);return r}const VO={default:"border bg-card",success:"border border-green-200 bg-green-50 text-green-900",warning:"border border-amber-200 bg-amber-50 text-amber-900",danger:"border border-red-200 bg-red-50 text-red-900"},HO={rectangle:"rounded-lg",square:"aspect-square rounded-lg",circle:"aspect-square rounded-full"},WO={sm:"p-2 text-xs",md:"p-4 text-sm",lg:"p-6 text-base"},vd={sm:"text-lg",md:"text-2xl",lg:"text-3xl"},RO={sm:"gap-2",md:"gap-3",lg:"gap-4"};function GO({title:e,value:t,trend:r,variant:n="default",shape:o="rectangle",size:s="md",layout:i="vertical",isLoading:a,isError:c}){const u=i==="horizontal";return d.jsxs("div",{className:H(VO[n??"default"],HO[o??"rectangle"],WO[s??"md"],u&&"flex items-center justify-between gap-3"),children:[d.jsxs("div",{className:H(u&&"min-w-0"),children:[e&&d.jsx("p",{className:H("font-medium text-muted-foreground",u?"text-sm":""),children:e}),r!=null&&r!==""&&!u&&d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:String(r)})]}),a?d.jsx(wn,{className:"my-2"}):c?d.jsx("p",{className:H("font-bold text-destructive",vd[s??"md"]),children:"Error"}):d.jsx("p",{className:H("font-bold",u?vd[s??"md"]:`mt-1 ${vd[s??"md"]}`),children:String(t)}),u&&r!==null&&r!==void 0&&r!==""&&d.jsx("p",{className:"text-xs text-muted-foreground",children:String(r)})]})}function Tb({stat:e,widgetId:t}){const{data:r,isLoading:n,isError:o}=_b({widgetId:t,dataSource:e.dataSource}),i=(()=>{if(n)return"";if(r==null)return e.valueMapping.fallback??"—";if(e.dataSource.mode==="context"){const c=r;return e.valueMapping.formatter?bd(c,e.valueMapping.formatter):c}if(e.dataSource.mode==="static"){const c=e.valueMapping.path?.trim()||"value",u=Bs(r,{...e.valueMapping,path:c});if(u!=null)return e.valueMapping.formatter?bd(u,e.valueMapping.formatter):u;if(typeof r=="object"&&r!==null&&!Array.isArray(r)){const f=r;if(f.value!==void 0&&f.value!==null)return f.value}return e.valueMapping.fallback??"—"}return Bs(r,e.valueMapping)})(),a=e.trendMapping&&r!==void 0&&e.dataSource.mode!=="context"?Bs(r,e.trendMapping):e.trendMapping&&e.dataSource.mode==="context"&&e.trendMapping.path?Bs({value:r},e.trendMapping):null;return d.jsx(GO,{title:e.title,value:i,trend:a,variant:e.variant,shape:e.shape,size:e.size,layout:e.layout,isLoading:n,isError:o})}function KO({widget:e}){const t=e.config;return d.jsx("div",{"data-widget-id":e.id,children:d.jsx(Tb,{stat:t,widgetId:e.id})})}function qO({stat:e,widgetId:t}){return d.jsx(Tb,{stat:e,widgetId:`${t}-${e.id}`})}function YO({widget:e}){const t=e.config,r=t.stats??[],n=t.columns??1,o=t.direction==="horizontal";return d.jsx("div",{"data-widget-id":e.id,className:H(o?"flex flex-wrap":"grid",!o&&n===1&&"grid-cols-1",!o&&n===2&&"grid-cols-2",!o&&n===3&&"grid-cols-3",!o&&n===4&&"grid-cols-4",RO[t.gap??"md"]),children:r.map(s=>d.jsx(qO,{stat:s,widgetId:e.id},s.id))})}function XO({widget:e}){const t=e.config,{setFilterValue:r}=Br(),[n,o]=v.useState("");return v.useEffect(()=>{const s=t.debounceMs??300,i=setTimeout(()=>{r(t.filterGroupKey,"search",n)},s);return()=>clearTimeout(i)},[n,t.debounceMs,t.filterGroupKey,r]),d.jsx("input",{type:"search",className:"flex h-9 w-full max-w-sm rounded-md border border-input bg-background px-3 py-1 text-sm shadow-xs",placeholder:t.placeholder??"Search…",value:n,onChange:s=>o(s.target.value),"data-widget-id":e.id})}function JO(e,t){if(!e)return[];const r=t?Re(e,t):e;if(Array.isArray(r))return r;if(typeof r=="object"&&r!==null){const n=r;if(Array.isArray(n.items))return n.items;if(Array.isArray(n.data))return n.data}return[]}function QO({widget:e}){const t=e.config,{dispatchAction:r}=Br(),[n,o]=v.useState(1),[s,i]=v.useState(""),a=t.pagination?.pageSize??10,{data:c,isLoading:u,isError:f}=_b({widgetId:e.id,dataSource:t.dataSource,page:n,pageSize:a,search:t.search?.enabled?s:void 0}),l=t.dataSource.mode==="pageApi"?void 0:t.dataSource.api?.itemsPath,p=JO(c,l??"data.items"),g=(m,h)=>{const y=t.dataSource.responseMapping.find(S=>S.target===h);return y?Bs(m,y):Re(m,h)??""};return d.jsxs("div",{className:"space-y-3","data-widget-id":e.id,children:[t.search?.enabled&&d.jsx("input",{type:"search",className:"flex h-9 w-full max-w-sm rounded-md border border-input bg-background px-3 py-1 text-sm",placeholder:t.search.placeholder??"Search…",value:s,onChange:m=>{i(m.target.value),o(1)}}),d.jsx("div",{className:"overflow-x-auto rounded-md border",children:d.jsxs("table",{className:"w-full text-sm",children:[d.jsx("thead",{children:d.jsx("tr",{className:"border-b bg-muted/50",children:t.columns.map(m=>d.jsx("th",{className:H("px-3 py-2 text-left font-medium",m.align==="center"&&"text-center",m.align==="right"&&"text-right"),style:m.width?{width:m.width}:void 0,children:m.header},m.id))})}),d.jsx("tbody",{children:u?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center",children:d.jsx(wn,{})})}):f?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-destructive",children:"Failed to load data"})}):p.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-muted-foreground",children:t.emptyMessage??"No data"})}):p.map((m,h)=>d.jsx("tr",{className:"cursor-pointer border-b hover:bg-muted/30",onClick:()=>{r({type:"emit",eventName:"row_click",payload:{row:m}},e.id,"row_click")},children:t.columns.map(y=>d.jsx("td",{className:H("px-3 py-2",y.align==="center"&&"text-center",y.align==="right"&&"text-right"),children:String(g(m,y.field))},y.id))},h))})]})}),t.pagination?.enabled&&d.jsxs("div",{className:"flex items-center justify-between text-sm",children:[d.jsxs("span",{className:"text-muted-foreground",children:["Page ",n]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",className:"rounded border px-2 py-1 disabled:opacity-50",disabled:n<=1,onClick:()=>o(m=>Math.max(1,m-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"rounded border px-2 py-1",disabled:p.length<a,onClick:()=>o(m=>m+1),children:"Next"})]})]})]})}const ZO=75;function eI(e){return e??ZO}function tI(e){return e?"rounded-md border border-border p-3":""}function wd({scrollBehavior:e="page",maxHeightPercent:t,children:r,className:n}){if(e!=="contained")return n?d.jsx("div",{className:n,children:r}):d.jsx(d.Fragment,{children:r});const o=eI(t);return d.jsx("div",{className:H("min-w-0 overflow-y-auto overflow-x-hidden",n),style:{maxHeight:`${o}vh`},"data-form-embed-scroll":"contained",children:r})}const rI="/api/bff/workflows";function nI(e){const t=e.moduleId??e.module_id;return t!=null?String(t).trim():""}function Fb(e){const t=Bf(),r=e.userId??e.user_id??t?.userId;return r!=null&&String(r).trim()!==""?String(r):void 0}function oI(e){const t=String(e.clientId??nn()??""),r=Fb(e);return()=>xa({getAuthHeaders:()=>ds()??{},clientId:t||void 0,userId:r})}function Pb(e,t){const r=nI(e);if(!r)return null;const n=t?.bffWorkflowsBasePath??rI,o=String(e.clientId??nn()??""),s=Fb(e),i=oI(e),a=t?.workflowModalHandlers??db({bffWorkflowsBasePath:n,moduleId:r,getAuthHeaders:i,clientId:o||void 0,userId:s});return{getWorkflowState:t?.getWorkflowState??(u=>ub({bffWorkflowsBasePath:n,moduleId:u.moduleId,featureId:u.featureId,tenantId:u.tenantId,subjectUserId:u.subjectUserId,viewStepId:u.viewStepId,clientId:u.clientId??(o||void 0),getAuthHeaders:i})),workflowModalHandlers:a,getAuthHeaders:i,moduleId:r}}function sI(e,t,r){return["embedded-form",e,t,r??"latest"]}async function iI(e,t){try{const r=await Qt.get(`/api/form-builder/form-layouts/form/${e}`,{params:{clientId:t}});let n=r.data?.data??r.data;for(;n&&typeof n=="object"&&!Array.isArray(n)&&n.data!=null&&typeof n.data=="object"&&!("rows"in n)&&!("columns"in n)&&!("formDefinitionId"in n);)n=n.data;return!n||typeof n!="object"||Array.isArray(n)||!("rows"in n)&&!("columns"in n)&&!("formDefinitionId"in n)?null:n}catch{return null}}async function aI(e,t,r){const n=r!==void 0?`/api/form-builder/forms/${e}/render?version=${r}`:`/api/form-builder/forms/${e}/render`,o=await Qt.get(n,{params:{clientId:t}}),i=o.data?.data??o.data,a=i.form??i,c=i.fields??a.fields??[];let u=i.layout??a.layout??null;(!u||typeof u.columns!="number")&&(u=await iI(e,t));const f=i.rules??a.rules??[],l=Os(a,c,u,f),p=Ws({config:l.config,layout:l.layout},Hs(u))??Hs(u);return{schema:l,gridLayout:p}}const lI=300*1e3;function Ob({formId:e,mode:t="fill",contextFieldMapping:r,pageContext:n,clientId:o,formVersion:s,scrollBehavior:i,maxHeightPercent:a,showBorder:c}){const u=fO(),{data:f,isLoading:l,isError:p,error:g}=kn.useQuery({queryKey:sI(e,o,s),queryFn:()=>aI(e,o,s),staleTime:lI}),m=v.useMemo(()=>UO(n,r),[n,r]),h=tI(c),y=typeof f?.schema?.moduleId=="string"?f.schema.moduleId.trim():"",S=u?.context.moduleId!=null?String(u.context.moduleId).trim():"",w=y||S||void 0,A=v.useMemo(()=>u?.workflowModalHandlers||!w?null:Pb({...n,clientId:o||n.clientId,moduleId:w}),[u?.workflowModalHandlers,w,n,o]),x=u?.workflowModalHandlers??A?.workflowModalHandlers,F=u?.getAuthHeaders??A?.getAuthHeaders;return l?d.jsx(wd,{scrollBehavior:i,maxHeightPercent:a,className:h,children:d.jsx(wn,{})}):p?d.jsx(wd,{scrollBehavior:i,maxHeightPercent:a,className:h,children:d.jsx("p",{className:"text-sm text-destructive",children:g instanceof Error?g.message:"Failed to load form"})}):f?.schema?d.jsx(wd,{scrollBehavior:i,maxHeightPercent:a,className:h,children:d.jsx(Ms,{schema:f.schema,mode:t,gridLayout:f.gridLayout,initialValues:m,submissionContext:n,moduleId:w,workflowModalHandlers:x,getAuthHeaders:F})}):null}function cI({widget:e}){const t=e.config,{context:r,clientId:n}=Br();return t.formId?d.jsx(Ob,{formId:t.formId,mode:t.mode??"fill",contextFieldMapping:t.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:t.scrollBehavior,maxHeightPercent:t.maxHeightPercent,showBorder:t.showBorder}):d.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured"})}function dI({widget:e}){const t=e.config,{context:r,getWorkflowState:n,workflowModalHandlers:o,clientId:s}=Br(),i=String(r.moduleId??"");if(!n)return d.jsxs("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground","data-widget-id":e.id,children:["Workflow embed requires ",d.jsx("code",{className:"text-xs",children:"getWorkflowState"})," on PageRenderer. Workflow ID: ",t.workflowId]});if(!i)return d.jsx("p",{className:"text-sm text-destructive","data-widget-id":e.id,children:"moduleId required in page context for workflow embed"});const a={};if(t.contextVariableMapping)for(const[c,u]of Object.entries(t.contextVariableMapping)){const f=r[u];f!=null&&(a[c]=String(f))}return d.jsx(cb,{getWorkflowState:n,workflowModalHandlers:o,moduleId:i,tenantId:r.tenantId?String(r.tenantId):void 0,clientId:s||void 0,submissionContext:a})}function uI({widget:e}){const t=e.config,{schema:r,dispatchAction:n}=Br(),o=t.previousPage??r.navigation?.previousPage,s=t.nextPage??r.navigation?.nextPage,i=t.showPrevious!==!1&&!!o,a=t.showNext!==!1&&!!s,c=t.showBreadcrumbs&&r.navigation?.breadcrumbs?.length,u=t.align==="center"?"justify-center":t.align==="right"?"justify-end":t.align==="space-between"?"justify-between":"justify-start",f=l=>{n({type:"navigate_page",pageId:l.pageId},e.id,"click")};return d.jsxs("nav",{className:"space-y-3","data-widget-id":e.id,children:[c&&d.jsx("ol",{className:"flex flex-wrap items-center gap-1 text-sm text-muted-foreground",children:r.navigation.breadcrumbs.map((l,p)=>d.jsxs("li",{className:"flex items-center gap-1",children:[p>0&&d.jsx("span",{children:"/"}),l.href?d.jsx("a",{href:l.href,className:"hover:underline",children:l.label}):d.jsx("span",{children:l.label})]},p))}),d.jsxs("div",{className:H("flex items-center gap-2",u),children:[i&&o&&d.jsx(Zt,{variant:"outline",size:"sm",onClick:()=>f(o),children:o.label??"Previous"}),a&&s&&d.jsx(Zt,{variant:"default",size:"sm",onClick:()=>f(s),children:s.label??"Next"})]})]})}function fI(e,t){return e?.length?e.filter(r=>r.config.tabId===t):[]}const pI=1;function mI(e){switch(e){case"pills":return"bg-transparent gap-1 p-0 h-auto";case"underline":return"bg-transparent rounded-none border-b p-0 h-auto w-full justify-start gap-4";default:return""}}function hI(e){switch(e){case"pills":return"rounded-full data-[state=active]:bg-primary data-[state=active]:text-primary-foreground";case"underline":return"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none bg-transparent";default:return""}}function gI(e,t,r){return e?new Set(r?[r]:[]):new Set(t.map(n=>n.id))}function yI({tab:e,shouldRender:t,pageContext:r,clientId:n}){return t?e.formId?d.jsx(Ob,{formId:e.formId,mode:e.formMode??"fill",contextFieldMapping:e.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:e.scrollBehavior,maxHeightPercent:e.maxHeightPercent,showBorder:e.showBorder}):d.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured for this tab"}):null}function bI({tab:e,shouldLoad:t,shouldRender:r,nestingDepth:n,pageContext:o,clientId:s,onAction:i,getWorkflowState:a}){const c=Br(),{data:u,isLoading:f,isError:l,error:p}=kn.useQuery({queryKey:["tab-page",e.pageId,e.pageVersion,s],enabled:t&&!!e.pageId,queryFn:async()=>md(e.pageId,s,e.pageVersion)});return r?n>=pI?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:"Nested page tabs not supported"}):e.pageId?f?d.jsx(wn,{}):l?d.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load page"}):u?d.jsx(Sd,{page:u,context:o,nestingDepth:n+1,inheritContext:!0,onAction:i,getWorkflowState:a,parentContext:c}):null:d.jsx("p",{className:"text-sm text-muted-foreground",children:"No page configured for this tab"}):null}function vI({tab:e,widgetChildren:t,renderChildren:r}){const n=fI(t,e.id);return n.length===0?d.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No widgets in this tab"}):d.jsx(d.Fragment,{children:r?.(n)})}function wI({widget:e,renderChildren:t}){const r=e.config,{context:n,clientId:o,nestingDepth:s,onAction:i,getWorkflowState:a}=Br(),c=r.tabs??[],u=r.defaultTabId??c[0]?.id??"",f=r.lazyLoad!==!1,[l,p]=v.useState(u),[g,m]=v.useState(()=>gI(f,c,u)),h=S=>{m(w=>new Set(w).add(S)),p(S)},y=v.useMemo(()=>!f,[f]);return c.length===0?d.jsx("p",{className:"text-sm text-muted-foreground","data-widget-id":e.id,children:"No tabs configured"}):d.jsxs(ib,{value:l,onValueChange:h,className:"w-full","data-widget-id":e.id,children:[d.jsx(cd,{className:H("mb-4",mI(r.variant)),children:c.map(S=>d.jsx(dd,{value:S.id,disabled:S.disabled,className:hI(r.variant),children:S.label},S.id))}),c.map(S=>{const w=g.has(S.id),A=y||w,x=y||w;return d.jsxs(ab,{value:S.id,forceMount:y||void 0,className:H("mt-0",y&&"data-[state=inactive]:hidden"),children:[S.contentType==="widgets"&&x&&d.jsx(vI,{tab:S,widgetChildren:e.children??[],renderChildren:t}),S.contentType==="form"&&d.jsx(yI,{tab:S,shouldRender:A,pageContext:n,clientId:o}),S.contentType==="page"&&d.jsx(bI,{tab:S,shouldLoad:A,shouldRender:x,nestingDepth:s,pageContext:n,clientId:o,onAction:i,getWorkflowState:a})]},S.id)})]})}const SI={section:NO,columns:kO,card:_O,tab_group:wI,heading:TO,text:FO,button:IO,button_group:DO,stat_card:KO,stat_grid:YO,data_table:QO,search_filter:XO,form_embed:cI,workflow_embed:dI,page_nav:uI};function xI({widget:e}){return d.jsxs("div",{className:"rounded-md border border-dashed border-muted-foreground/40 bg-muted/20 p-3 text-sm text-muted-foreground","data-widget-id":e.id,"data-widget-type":e.type,children:["Unsupported widget: ",d.jsx("code",{className:"text-xs",children:e.type}),e.label&&d.jsxs("span",{className:"ml-1",children:["(",e.label,")"]})]})}function AI({widget:e,renderChildren:t}){const r=SI[e.type]??xI;return d.jsx(r,{widget:e,renderChildren:t})}function Ib(e,t){return e.map(r=>d.jsx(AI,{widget:r,renderChildren:t},r.id))}function Sd({page:e,context:t={},onAction:r,chrome:n="none",className:o,nestingDepth:s=0,getWorkflowState:i,workflowModalHandlers:a,getAuthHeaders:c,inheritContext:u=!1,parentContext:f}){const l=v.useMemo(()=>iO(e.schema),[e.schema]),p=v.useMemo(()=>{const h=Pb(t,{getWorkflowState:i,workflowModalHandlers:a});return{getWorkflowState:i??h?.getWorkflowState,workflowModalHandlers:a??h?.workflowModalHandlers,getAuthHeaders:c??h?.getAuthHeaders}},[t,i,a,c]),g=h=>Ib(h,g),m=d.jsxs("div",{className:H("studio-page-content min-h-0 min-w-0",nO(l),o),"data-page-id":e.id,"data-nesting-depth":s,children:[n==="minimal"&&l.meta?.title&&d.jsxs("header",{className:"mb-6 border-b pb-4",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:l.meta.title}),l.meta.description&&d.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:l.meta.description})]}),d.jsx("div",{className:"space-y-6",children:Ib(l.widgets,g)})]});return u&&f?m:d.jsx(uO,{schema:l,context:t,clientId:String(t.clientId??""),nestingDepth:s,onAction:r,getWorkflowState:p.getWorkflowState,workflowModalHandlers:p.workflowModalHandlers,getAuthHeaders:p.getAuthHeaders,parentContext:f,children:m})}function CI({clientId:e,tenantId:t,moduleId:r,featureId:n,pageId:o,routePath:s,routeParams:i={},isDefault:a,context:c={},version:u,chrome:f="none",onAction:l,getWorkflowState:p,workflowModalHandlers:g,getAuthHeaders:m}){const h=v.useMemo(()=>({...i,...c,clientId:e,tenantId:t,moduleId:r,featureId:n}),[i,c,e,t,r,n]),{data:y,isLoading:S,isError:w,error:A}=kn.useQuery({queryKey:["page-resolve",e,t,r,n,o,s,a,u],queryFn:()=>bb({clientId:e,tenantId:t,moduleId:r,featureId:n,routePath:s,isDefault:a,version:u}),enabled:!o}),x=o??y?.pageId,F=u??y?.version,{data:N,isLoading:k,isError:T,error:P}=kn.useQuery({queryKey:["page-render",x,e,F],queryFn:()=>md(x,e,F),enabled:!!x});return!o&&S?d.jsx("div",{className:"flex items-center justify-center p-12",children:d.jsx(wn,{})}):w?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:A instanceof Error?A.message:"Failed to resolve page"}):x?k?d.jsx("div",{className:"flex items-center justify-center p-12",children:d.jsx(wn,{})}):T||!N?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:P instanceof Error?P.message:"Failed to load page"}):d.jsx(Sd,{page:N,context:h,chrome:f,nestingDepth:0,onAction:l,getWorkflowState:p,workflowModalHandlers:g,getAuthHeaders:m}):d.jsx("div",{className:"rounded-md border p-4 text-sm text-muted-foreground",children:"No page found for the given scope or route."})}ue.FIELD_TYPE_REGISTRY=ZP,ue.FORM_RENDERER_GRID_ROW_HEIGHT_DEFAULT=Hn,ue.FORM_RENDERER_ROOT_CLASS=$a,ue.FieldRenderer=Sn,ue.FormRenderer=Ms,ue.PageRenderer=Sd,ue.RendererFieldLayoutContext=Ya,ue.RendererStoreProvider=il,ue.STEPS_NAV_RUNTIME_DEFAULTS=Ls,ue.StudioPageHost=CI,ue.WorkflowFormModal=Eg,ue.WorkflowModalProvider=_g,ue.WorkflowStepsView=cb,ue.appearanceControlClasses=uo,ue.appearanceHasExplicitVerticalIntent=au,ue.appearanceTextareaClasses=Qd,ue.backendToFormSchema=Os,ue.buildBffWorkflowAuthHeaders=xa,ue.cellAlignmentClasses=Gv,ue.cellVerticalJustifyClassesForField=Rv,ue.clearWorkflowStandaloneCache=qP,ue.createBffWorkflowModalHandlers=db,ue.effectiveWidthPercent=qs,ue.executeDataSource=hd,ue.fetchBffWorkflowState=ub,ue.fetchPageRender=md,ue.fetchWorkflowStandaloneFlag=Sa,ue.fieldBlockBoxStyle=Wv,ue.fieldBlockBoxStyleForField=su,ue.fieldBlockHorizontalPlacementClass=tu,ue.fieldBlockHorizontalSelfClass=ru,ue.fieldBlockHorizontalSelfClassForField=iu,ue.fieldBlockWidthStyle=Ha,ue.fieldBlockWidthStyleForField=ou,ue.fieldGridShellFillsCellVertically=Xs,ue.formBuilderHttp=Qt,ue.formLayoutRecordToGridConfig=Hs,ue.getBusinessApiOrigin=Lf,ue.getClientId=nn,ue.getRendererHostAuthHeaders=ds,ue.getRendererHostViewerContext=Bf,ue.getRendererStore=Aw,ue.gridCellFlexClasses=eu,ue.gridCellFlexClassesForField=qa,ue.gridCellOuterFlexClasses=Zd,ue.hasExplicitFieldBlockWidth=nu,ue.isAsyncSearchFieldProperties=YP,ue.isIntrinsicWidthButtonField=fo,ue.normalizeWorkflowFormSchema=p_,ue.normalizeWorkflowFormToRendererSchema=da,ue.pageBuilderHttp=Ds,ue.parseContentVerticalAlign=Ra,ue.parseMetadataJson=Es,ue.resetRendererHostAuth=j0,ue.resolveBusinessApiUrl=Mr,ue.resolveFormGridLayout=Ws,ue.resolvePage=bb,ue.resolveWorkflowStepsNavigationConfig=fd,ue.resolveWorkflowStepsNavigationPosition=$P,ue.resolvedGridCellVerticalJustifyClasses=Xo,ue.resolvedHorizontalAlign=Fr,ue.resolvedVerticalAlign=Yo,ue.resolvedVerticalAlignForField=Ka,ue.setBusinessApiOrigin=M0,ue.setFormBuilderAuthProvider=z0,ue.setPageBuilderAuthProvider=aO,ue.setRendererHostAuthHeaders=$0,ue.setRendererHostViewerContext=B0,ue.useFieldValidation=JP,ue.useFormRenderer=Au,ue.useFormValidation=XP,ue.useRendererFieldLayout=Jo,ue.useRendererHostAuthStore=Qn,ue.useWorkflowModal=kg,Object.defineProperty(ue,Symbol.toStringTag,{value:"Module"})}));