iq-line-form-builder-renderer 1.2.7 → 1.2.9
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.
- package/dist/form-renderer.es.js +626 -600
- package/dist/form-renderer.umd.js +7 -7
- package/dist/page/PageContextProvider.d.ts.map +1 -1
- package/dist/page/hooks/usePageDataSource.d.ts +163 -1
- package/dist/page/hooks/usePageDataSource.d.ts.map +1 -1
- package/dist/page/widgets/DataWidgets.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(ge,S){typeof exports=="object"&&typeof module<"u"?S(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"],S):(ge=typeof globalThis<"u"?globalThis:ge||self,S(ge.FormBuilderRenderer={},ge.React,ge.jsxRuntime,ge.ReactRouterDOM,ge.ReactDOM,ge.Sonner,ge.ReactQuery))})(this,(function(ge,S,c,ha,qc,$t,gn){"use strict";function Yc(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=Yc(S),Es=Yc(qc),ga="iq-fbr",In="95px";function Ns(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:In}}function _s(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 Xc(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=Xc(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Jc(){for(var e,t,r=0,n="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=Xc(e))&&(n&&(n+=" "),n+=t);return n}const Py=(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},Oy=(e,t)=>({classGroupId:e,validator:t}),Qc=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),ks="-",Zc=[],Iy="arbitrary..",My=e=>{const t=Dy(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Ly(i);const a=i.split(ks),d=a[0]===""&&a.length>1?1:0;return ed(a,d,t)},getConflictingClassGroupIds:(i,a)=>{if(a){const d=n[i],u=r[i];return d?u?Py(u,d):d:u||Zc}return r[i]||Zc}}},ed=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const o=e[t],s=r.nextPart.get(o);if(s){const u=ed(e,t+1,s);if(u)return u}const i=r.validators;if(i===null)return;const a=t===0?e.join(ks):e.slice(t).join(ks),d=i.length;for(let u=0;u<d;u++){const l=i[u];if(l.validator(a))return l.classGroupId}},Ly=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?Iy+n:void 0})(),Dy=e=>{const{theme:t,classGroups:r}=e;return By(r,t)},By=(e,t)=>{const r=Qc();for(const n in e){const o=e[n];ya(o,r,n,t)}return r},ya=(e,t,r,n)=>{const o=e.length;for(let s=0;s<o;s++){const i=e[s];$y(i,t,r,n)}},$y=(e,t,r,n)=>{if(typeof e=="string"){jy(e,t,r);return}if(typeof e=="function"){zy(e,t,r,n);return}Uy(e,t,r,n)},jy=(e,t,r)=>{const n=e===""?t:td(t,e);n.classGroupId=r},zy=(e,t,r,n)=>{if(Vy(e)){ya(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(Oy(r,e))},Uy=(e,t,r,n)=>{const o=Object.entries(e),s=o.length;for(let i=0;i<s;i++){const[a,d]=o[i];ya(d,td(t,a),r,n)}},td=(e,t)=>{let r=e;const n=t.split(ks),o=n.length;for(let s=0;s<o;s++){const i=n[s];let a=r.nextPart.get(i);a||(a=Qc(),r.nextPart.set(i,a)),r=a}return r},Vy=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Hy=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)}}},ba="!",rd=":",Wy=[],nd=(e,t,r,n,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:o}),Ry=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=o=>{const s=[];let i=0,a=0,d=0,u;const l=o.length;for(let h=0;h<l;h++){const y=o[h];if(i===0&&a===0){if(y===rd){s.push(o.slice(d,h)),d=h+1;continue}if(y==="/"){u=h;continue}}y==="["?i++:y==="]"?i--:y==="("?a++:y===")"&&a--}const f=s.length===0?o:o.slice(d);let p=f,m=!1;f.endsWith(ba)?(p=f.slice(0,-1),m=!0):f.startsWith(ba)&&(p=f.slice(1),m=!0);const g=u&&u>d?u-d:void 0;return nd(s,m,p,g)};if(t){const o=t+rd,s=n;n=i=>i.startsWith(o)?s(i.slice(o.length)):nd(Wy,!1,i,void 0,!0)}if(r){const o=n;n=s=>r({className:s,parseClassName:o})}return n},Gy=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]==="[",d=t.has(i);a||d?(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}},Ky=e=>({cache:Hy(e.cacheSize),parseClassName:Ry(e),sortModifiers:Gy(e),...My(e)}),qy=/\s+/,Yy=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:o,sortModifiers:s}=t,i=[],a=e.trim().split(qy);let d="";for(let u=a.length-1;u>=0;u-=1){const l=a[u],{isExternal:f,modifiers:p,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:h}=r(l);if(f){d=l+(d.length>0?" "+d:d);continue}let y=!!h,w=n(y?g.substring(0,h):g);if(!w){if(!y){d=l+(d.length>0?" "+d:d);continue}if(w=n(g),!w){d=l+(d.length>0?" "+d:d);continue}y=!1}const v=p.length===0?"":p.length===1?p[0]:s(p).join(":"),x=m?v+ba:v,E=x+w;if(i.indexOf(E)>-1)continue;i.push(E);const P=o(w,y);for(let k=0;k<P.length;++k){const N=P[k];i.push(x+N)}d=l+(d.length>0?" "+d:d)}return d},Xy=(...e)=>{let t=0,r,n,o="";for(;t<e.length;)(r=e[t++])&&(n=od(r))&&(o&&(o+=" "),o+=n);return o},od=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=od(e[n]))&&(r&&(r+=" "),r+=t);return r},Jy=(e,...t)=>{let r,n,o,s;const i=d=>{const u=t.reduce((l,f)=>f(l),e());return r=Ky(u),n=r.cache.get,o=r.cache.set,s=a,a(d)},a=d=>{const u=n(d);if(u)return u;const l=Yy(d,r);return o(d,l),l};return s=i,(...d)=>s(Xy(...d))},Qy=[],Rt=e=>{const t=r=>r[e]||Qy;return t.isThemeGetter=!0,t},sd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,id=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Zy=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,eb=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,tb=/\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$/,rb=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,nb=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ob=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,yn=e=>Zy.test(e),it=e=>!!e&&!Number.isNaN(Number(e)),bn=e=>!!e&&Number.isInteger(Number(e)),va=e=>e.endsWith("%")&&it(e.slice(0,-1)),nn=e=>eb.test(e),ad=()=>!0,sb=e=>tb.test(e)&&!rb.test(e),wa=()=>!1,ib=e=>nb.test(e),ab=e=>ob.test(e),lb=e=>!_e(e)&&!ke(e),cb=e=>vn(e,pd,wa),_e=e=>sd.test(e),Mn=e=>vn(e,md,sb),ld=e=>vn(e,yb,it),db=e=>vn(e,gd,ad),ub=e=>vn(e,hd,wa),cd=e=>vn(e,ud,wa),fb=e=>vn(e,fd,ab),Ts=e=>vn(e,yd,ib),ke=e=>id.test(e),Lo=e=>Ln(e,md),pb=e=>Ln(e,hd),dd=e=>Ln(e,ud),mb=e=>Ln(e,pd),hb=e=>Ln(e,fd),Fs=e=>Ln(e,yd,!0),gb=e=>Ln(e,gd,!0),vn=(e,t,r)=>{const n=sd.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Ln=(e,t,r=!1)=>{const n=id.exec(e);return n?n[1]?t(n[1]):r:!1},ud=e=>e==="position"||e==="percentage",fd=e=>e==="image"||e==="url",pd=e=>e==="length"||e==="size"||e==="bg-size",md=e=>e==="length",yb=e=>e==="number",hd=e=>e==="family-name",gd=e=>e==="number"||e==="weight",yd=e=>e==="shadow",bb=Jy(()=>{const e=Rt("color"),t=Rt("font"),r=Rt("text"),n=Rt("font-weight"),o=Rt("tracking"),s=Rt("leading"),i=Rt("breakpoint"),a=Rt("container"),d=Rt("spacing"),u=Rt("radius"),l=Rt("shadow"),f=Rt("inset-shadow"),p=Rt("text-shadow"),m=Rt("drop-shadow"),g=Rt("blur"),h=Rt("perspective"),y=Rt("aspect"),w=Rt("ease"),v=Rt("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...E(),ke,_e],k=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],C=()=>[ke,_e,d],A=()=>[yn,"full","auto",...C()],I=()=>[bn,"none","subgrid",ke,_e],T=()=>["auto",{span:["full",bn,ke,_e]},bn,ke,_e],W=()=>[bn,"auto",ke,_e],X=()=>["auto","min","max","fr",ke,_e],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],j=()=>["start","end","center","stretch","center-safe","end-safe"],M=()=>["auto",...C()],D=()=>[yn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...C()],L=()=>[yn,"screen","full","dvw","lvw","svw","min","max","fit",...C()],U=()=>[yn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...C()],$=()=>[e,ke,_e],ie=()=>[...E(),dd,cd,{position:[ke,_e]}],V=()=>["no-repeat",{repeat:["","x","y","space","round"]}],K=()=>["auto","cover","contain",mb,cb,{size:[ke,_e]}],J=()=>[va,Lo,Mn],ce=()=>["","none","full",u,ke,_e],ne=()=>["",it,Lo,Mn],G=()=>["solid","dashed","dotted","double"],ee=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Pe=()=>[it,va,dd,cd],oe=()=>["","none",g,ke,_e],re=()=>["none",it,ke,_e],be=()=>["none",it,ke,_e],de=()=>[it,ke,_e],ot=()=>[yn,"full",...C()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[nn],breakpoint:[nn],color:[ad],container:[nn],"drop-shadow":[nn],ease:["in","out","in-out"],font:[lb],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[nn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[nn],shadow:[nn],spacing:["px",it],text:[nn],"text-shadow":[nn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",yn,_e,ke,y]}],container:["container"],columns:[{columns:[it,_e,ke,a]}],"break-after":[{"break-after":x()}],"break-before":[{"break-before":x()}],"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:P()}],overflow:[{overflow:k()}],"overflow-x":[{"overflow-x":k()}],"overflow-y":[{"overflow-y":k()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{"inset-s":A(),start:A()}],end:[{"inset-e":A(),end:A()}],"inset-bs":[{"inset-bs":A()}],"inset-be":[{"inset-be":A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[bn,"auto",ke,_e]}],basis:[{basis:[yn,"full","auto",a,...C()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[it,yn,"auto","initial","none",_e]}],grow:[{grow:["",it,ke,_e]}],shrink:[{shrink:["",it,ke,_e]}],order:[{order:[bn,"first","last","none",ke,_e]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:T()}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:T()}],"row-start":[{"row-start":W()}],"row-end":[{"row-end":W()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":X()}],"auto-rows":[{"auto-rows":X()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...j(),"normal"]}],"justify-self":[{"justify-self":["auto",...j()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...j(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...j(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...j(),"baseline"]}],"place-self":[{"place-self":["auto",...j()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pbs:[{pbs:C()}],pbe:[{pbe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":C()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":C()}],"space-y-reverse":["space-y-reverse"],size:[{size:D()}],"inline-size":[{inline:["auto",...L()]}],"min-inline-size":[{"min-inline":["auto",...L()]}],"max-inline-size":[{"max-inline":["none",...L()]}],"block-size":[{block:["auto",...U()]}],"min-block-size":[{"min-block":["auto",...U()]}],"max-block-size":[{"max-block":["none",...U()]}],w:[{w:[a,"screen",...D()]}],"min-w":[{"min-w":[a,"screen","none",...D()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...D()]}],h:[{h:["screen","lh",...D()]}],"min-h":[{"min-h":["screen","lh","none",...D()]}],"max-h":[{"max-h":["screen","lh",...D()]}],"font-size":[{text:["base",r,Lo,Mn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,gb,db]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",va,_e]}],"font-family":[{font:[pb,ub,t]}],"font-features":[{"font-features":[_e]}],"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,ke,_e]}],"line-clamp":[{"line-clamp":[it,"none",ke,ld]}],leading:[{leading:[s,...C()]}],"list-image":[{"list-image":["none",ke,_e]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ke,_e]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:$()}],"text-color":[{text:$()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[it,"from-font","auto",ke,Mn]}],"text-decoration-color":[{decoration:$()}],"underline-offset":[{"underline-offset":[it,"auto",ke,_e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ke,_e]}],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",ke,_e]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ie()}],"bg-repeat":[{bg:V()}],"bg-size":[{bg:K()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},bn,ke,_e],radial:["",ke,_e],conic:[bn,ke,_e]},hb,fb]}],"bg-color":[{bg:$()}],"gradient-from-pos":[{from:J()}],"gradient-via-pos":[{via:J()}],"gradient-to-pos":[{to:J()}],"gradient-from":[{from:$()}],"gradient-via":[{via:$()}],"gradient-to":[{to:$()}],rounded:[{rounded:ce()}],"rounded-s":[{"rounded-s":ce()}],"rounded-e":[{"rounded-e":ce()}],"rounded-t":[{"rounded-t":ce()}],"rounded-r":[{"rounded-r":ce()}],"rounded-b":[{"rounded-b":ce()}],"rounded-l":[{"rounded-l":ce()}],"rounded-ss":[{"rounded-ss":ce()}],"rounded-se":[{"rounded-se":ce()}],"rounded-ee":[{"rounded-ee":ce()}],"rounded-es":[{"rounded-es":ce()}],"rounded-tl":[{"rounded-tl":ce()}],"rounded-tr":[{"rounded-tr":ce()}],"rounded-br":[{"rounded-br":ce()}],"rounded-bl":[{"rounded-bl":ce()}],"border-w":[{border:ne()}],"border-w-x":[{"border-x":ne()}],"border-w-y":[{"border-y":ne()}],"border-w-s":[{"border-s":ne()}],"border-w-e":[{"border-e":ne()}],"border-w-bs":[{"border-bs":ne()}],"border-w-be":[{"border-be":ne()}],"border-w-t":[{"border-t":ne()}],"border-w-r":[{"border-r":ne()}],"border-w-b":[{"border-b":ne()}],"border-w-l":[{"border-l":ne()}],"divide-x":[{"divide-x":ne()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ne()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"hidden","none"]}],"border-color":[{border:$()}],"border-color-x":[{"border-x":$()}],"border-color-y":[{"border-y":$()}],"border-color-s":[{"border-s":$()}],"border-color-e":[{"border-e":$()}],"border-color-bs":[{"border-bs":$()}],"border-color-be":[{"border-be":$()}],"border-color-t":[{"border-t":$()}],"border-color-r":[{"border-r":$()}],"border-color-b":[{"border-b":$()}],"border-color-l":[{"border-l":$()}],"divide-color":[{divide:$()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[it,ke,_e]}],"outline-w":[{outline:["",it,Lo,Mn]}],"outline-color":[{outline:$()}],shadow:[{shadow:["","none",l,Fs,Ts]}],"shadow-color":[{shadow:$()}],"inset-shadow":[{"inset-shadow":["none",f,Fs,Ts]}],"inset-shadow-color":[{"inset-shadow":$()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:$()}],"ring-offset-w":[{"ring-offset":[it,Mn]}],"ring-offset-color":[{"ring-offset":$()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":$()}],"text-shadow":[{"text-shadow":["none",p,Fs,Ts]}],"text-shadow-color":[{"text-shadow":$()}],opacity:[{opacity:[it,ke,_e]}],"mix-blend":[{"mix-blend":[...ee(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ee()}],"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":[it]}],"mask-image-linear-from-pos":[{"mask-linear-from":Pe()}],"mask-image-linear-to-pos":[{"mask-linear-to":Pe()}],"mask-image-linear-from-color":[{"mask-linear-from":$()}],"mask-image-linear-to-color":[{"mask-linear-to":$()}],"mask-image-t-from-pos":[{"mask-t-from":Pe()}],"mask-image-t-to-pos":[{"mask-t-to":Pe()}],"mask-image-t-from-color":[{"mask-t-from":$()}],"mask-image-t-to-color":[{"mask-t-to":$()}],"mask-image-r-from-pos":[{"mask-r-from":Pe()}],"mask-image-r-to-pos":[{"mask-r-to":Pe()}],"mask-image-r-from-color":[{"mask-r-from":$()}],"mask-image-r-to-color":[{"mask-r-to":$()}],"mask-image-b-from-pos":[{"mask-b-from":Pe()}],"mask-image-b-to-pos":[{"mask-b-to":Pe()}],"mask-image-b-from-color":[{"mask-b-from":$()}],"mask-image-b-to-color":[{"mask-b-to":$()}],"mask-image-l-from-pos":[{"mask-l-from":Pe()}],"mask-image-l-to-pos":[{"mask-l-to":Pe()}],"mask-image-l-from-color":[{"mask-l-from":$()}],"mask-image-l-to-color":[{"mask-l-to":$()}],"mask-image-x-from-pos":[{"mask-x-from":Pe()}],"mask-image-x-to-pos":[{"mask-x-to":Pe()}],"mask-image-x-from-color":[{"mask-x-from":$()}],"mask-image-x-to-color":[{"mask-x-to":$()}],"mask-image-y-from-pos":[{"mask-y-from":Pe()}],"mask-image-y-to-pos":[{"mask-y-to":Pe()}],"mask-image-y-from-color":[{"mask-y-from":$()}],"mask-image-y-to-color":[{"mask-y-to":$()}],"mask-image-radial":[{"mask-radial":[ke,_e]}],"mask-image-radial-from-pos":[{"mask-radial-from":Pe()}],"mask-image-radial-to-pos":[{"mask-radial-to":Pe()}],"mask-image-radial-from-color":[{"mask-radial-from":$()}],"mask-image-radial-to-color":[{"mask-radial-to":$()}],"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":E()}],"mask-image-conic-pos":[{"mask-conic":[it]}],"mask-image-conic-from-pos":[{"mask-conic-from":Pe()}],"mask-image-conic-to-pos":[{"mask-conic-to":Pe()}],"mask-image-conic-from-color":[{"mask-conic-from":$()}],"mask-image-conic-to-color":[{"mask-conic-to":$()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:V()}],"mask-size":[{mask:K()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ke,_e]}],filter:[{filter:["","none",ke,_e]}],blur:[{blur:oe()}],brightness:[{brightness:[it,ke,_e]}],contrast:[{contrast:[it,ke,_e]}],"drop-shadow":[{"drop-shadow":["","none",m,Fs,Ts]}],"drop-shadow-color":[{"drop-shadow":$()}],grayscale:[{grayscale:["",it,ke,_e]}],"hue-rotate":[{"hue-rotate":[it,ke,_e]}],invert:[{invert:["",it,ke,_e]}],saturate:[{saturate:[it,ke,_e]}],sepia:[{sepia:["",it,ke,_e]}],"backdrop-filter":[{"backdrop-filter":["","none",ke,_e]}],"backdrop-blur":[{"backdrop-blur":oe()}],"backdrop-brightness":[{"backdrop-brightness":[it,ke,_e]}],"backdrop-contrast":[{"backdrop-contrast":[it,ke,_e]}],"backdrop-grayscale":[{"backdrop-grayscale":["",it,ke,_e]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[it,ke,_e]}],"backdrop-invert":[{"backdrop-invert":["",it,ke,_e]}],"backdrop-opacity":[{"backdrop-opacity":[it,ke,_e]}],"backdrop-saturate":[{"backdrop-saturate":[it,ke,_e]}],"backdrop-sepia":[{"backdrop-sepia":["",it,ke,_e]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ke,_e]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[it,"initial",ke,_e]}],ease:[{ease:["linear","initial",w,ke,_e]}],delay:[{delay:[it,ke,_e]}],animate:[{animate:["none",v,ke,_e]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,ke,_e]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:re()}],"rotate-x":[{"rotate-x":re()}],"rotate-y":[{"rotate-y":re()}],"rotate-z":[{"rotate-z":re()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":["scale-3d"],skew:[{skew:de()}],"skew-x":[{"skew-x":de()}],"skew-y":[{"skew-y":de()}],transform:[{transform:[ke,_e,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ot()}],"translate-x":[{"translate-x":ot()}],"translate-y":[{"translate-y":ot()}],"translate-z":[{"translate-z":ot()}],"translate-none":["translate-none"],accent:[{accent:$()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:$()}],"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",ke,_e]}],"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":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mbs":[{"scroll-mbs":C()}],"scroll-mbe":[{"scroll-mbe":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pbs":[{"scroll-pbs":C()}],"scroll-pbe":[{"scroll-pbe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"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",ke,_e]}],fill:[{fill:["none",...$()]}],"stroke-w":[{stroke:[it,Lo,Mn,ld]}],stroke:[{stroke:["none",...$()]}],"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 B(...e){return bb(Jc(e))}const vb=["richtext","multiselect","radio","checkboxgroup","signature"],wb=3;function Do(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(wb,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 vb.includes(e.type)?Math.max(t,2):t}function bd(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 Bo(e){const t=e?.size??"md",r=e?.variant??"default";return B(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 vd(e){const t=e?.size??"md",r=e?.variant??"default";return B(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 Sb(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 xb(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 Ab(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 Ps(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 Sa(e){const t=Ps(e);return{width:t>=100?"100%":`${t}%`,maxWidth:"100%"}}function Cb(e){return Sa(e)}function xa(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"||t==="stretch"?t:null}function Aa(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=xa(e.horizontalAlign);if(t)return t;const r=xa(e.contentAlign);if(r)return r;const n=xa(e.cellAlign);return n||"start"}function $o(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 Os(e){switch(e){case"center":return"items-center";case"end":return"items-end";case"stretch":return"items-stretch";default:return"items-start"}}function Ca(e){switch(e){case"center":return"justify-center";case"end":return"justify-end";case"stretch":return"justify-stretch";default:return"justify-start"}}function jo(e){const t=Aa(e.appearance?.contentVerticalAlign);if(t!==null)switch(t){case"center":return"justify-center";case"end":return"justify-end";default:return"justify-start"}return Ca(Ea(e))}const Eb=jo;function Is(e){if(e.type==="billingGrid"||e.type==="table"||Do(e)>1)return!0;const t=Aa(e.appearance?.contentVerticalAlign);if(t==="center"||t==="end")return!1;if(t==="start")return!0;const r=Ea(e);return r!=="center"&&r!=="end"}function wd(e){const t=e[0];if(!t)return Na(void 0);if(e.length===1)return Na(t);const r=Fr(t.appearance);return B("flex flex-col min-h-0 h-full w-full",Os(r),"justify-start")}function Sd(e){const t=Fr(e),r=$o(e);return B("flex flex-col min-h-0 h-full w-full",Os(t),Ca(r))}function xd(e){if(Ps(e)>=100)return"";const r=Fr(e);return r==="center"?"mx-auto":r==="end"?"ml-auto":""}function Ad(e){if(Ps(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 Cd(e){return e?e.widthMode==="full"||e.widthMode==="percent"||typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent):!1}function to(e){return(e.type==="button"||e.type==="editButton")&&!Cd(e.appearance)}function Ed(e){return to(e)?Fr(e.appearance)==="stretch"?{width:"100%",maxWidth:"100%",minWidth:0}:{width:"auto",maxWidth:"100%"}:Sa(e.appearance)}function Nd(e){return Ed(e)}function _d(e){if(to(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 Ad(e.appearance)}function kd(e){return e?e.verticalAlign!=null||e.cellJustify!=null:!1}function Ea(e){return e.type!=="button"&&e.type!=="editButton"||kd(e.appearance)?$o(e.appearance):"start"}function Na(e){if(!e)return Sd(void 0);const t=Fr(e.appearance);return B("flex flex-col min-h-0 h-full w-full",Os(t),jo(e))}function Nb(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 B(Os(Fr(o)),Ca($o(o)))}const _a=S.createContext({gridStretch:!1});function zo(){return S.useContext(_a)}const Td=e=>{let t;const r=new Set,n=(u,l)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const p=t;t=l??(typeof f!="object"||f===null)?f:Object.assign({},t,f),r.forEach(m=>m(t,p))}},o=()=>t,a={setState:n,getState:o,getInitialState:()=>d,subscribe:u=>(r.add(u),()=>r.delete(u))},d=t=e(n,o,a);return a},_b=(e=>e?Td(e):Td),kb=e=>e;function Tb(e,t=kb){const r=S.useSyncExternalStore(e.subscribe,S.useCallback(()=>t(e.getState()),[e,t]),S.useCallback(()=>t(e.getInitialState()),[e,t]));return S.useDebugValue(r),r}const Fd=e=>{const t=_b(e),r=n=>Tb(t,n);return Object.assign(r,t),r},Pd=(e=>e?Fd(e):Fd),Fb=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Pb=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,Ob=/^\+?[\d\s-()]{10,}$/,Ib={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:Fb.test(e),url:e=>typeof e!="string"||!e?!0:Pb.test(e),phone:e=>typeof e!="string"||!e?!0:Ob.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(),d=n[i];return d?d.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 Yr(e,t,r={}){const n=Ib[t.type];if(!n)return!0;const o=n(e,t,r);return o===!1?t.message||Mb(t):typeof o=="string"?o:!0}function Mb(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 ${Lb(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 Lb(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const Db=10;function Ms(e){const t=e.properties;return t?.maxFiles!=null&&t.maxFiles>0?Math.floor(t.maxFiles):t?.multiple===!0?Db:1}function Od(e){return typeof e=="object"&&e!==null&&"url"in e&&typeof e.url=="string"&&e.url.length>0}function Id(e){try{return e.split("?")[0].split("/").filter(Boolean).pop()||e}catch{return e}}function Ls(e){if(e==null)return[];if(typeof e=="string")return e.startsWith("http")?[{url:e,name:Id(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:Id(r)}):Od(r)&&t.push(r);return t}return Od(e)?[e]:[]}function Bb(e,t){return e.slice(0,t)}function ka(e,t){const r=Bb(e,t);return r.length===0?null:t===1?r[0]??null:r}function $b(e){return Ls(e).length}function jb(e){return e==="file"||e==="camera"||e==="photoChoice"}function Ta(e,t){if(!jb(e.type))return;const r=Ms(e);if($b(t)>r)return`Maximum ${r} file(s) allowed`}class Ds{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 f in i){const p=i[f];(p==null||p==="")&&(i[f]="")}const a={fields:i,currentValue:o,previousValue:s,...Ds.functions},d=Object.keys(a),u=Object.values(a),l=new Function(...d,`return ${t}`)(...u);if(l==null)return"";if(typeof l=="string"){if(l.includes("undefined"))return"";const f=l.trim();return f===""||/^\s+$/.test(l)?"":f}return l}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 Md=new Ds;function Ld(e){if(e==null||e==="")return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:Bs(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:Bs(n)}return null}function Bs(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function zb(e,t=new Date){const r=Bs(e),n=Bs(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 Fa(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 Pa(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(t):null}function Ub(e,t){const r=Pa(e);return r?`${t.sourceFieldName}${r}`:t.sourceFieldName}function Dd(e,t,r){const n=Pa(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 Vb(e,t,r){const n=r?Ub(r,e):e.sourceFieldName,o=Ld(t[n]);if(!o)return null;const s=e.referenceDate==="today"||e.referenceDate==null?new Date:Ld(t[e.referenceDate])??new Date;return zb(o,s)[e.part]}function Bd(e,t){const r=Fa(e);return r?Pr(r.sourceFieldName)===Pr(t):!1}function Oa(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=Fa(i);if(!a||!i.name||s&&Pr(a.sourceFieldName)!==s)continue;const d=n??a.sourceFieldName,u=Dd(i.name,d,o);for(const l of u){if(r.has(l))continue;const f=Vb(a,o,l);o[l]=f}}return o}function Hb(e,t,r,n){const o={...t},s=Pr(n);for(const i of e){if(!Bd(i,s)||!i.name)continue;const a=Dd(i.name,n,o);for(const d of a)r.delete(d),o[d]=null}return o}function $d(e,t){const r=Pr(t);return e.some(n=>Bd(n,r))}function jd(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 Wb(e,t,r,n){let o=Ia(e,r);return n&&(o=Dn(o,t,r)),o}function Ia(e,t){return e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(r,n)=>t?.[n]!==void 0&&t[n]!==null?String(t[n]):r)}function Dn(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(d=>d.toLowerCase()===s.toLowerCase());a&&(i=t[a])}return i!=null&&i!==""?String(i):o}),n}function $s(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 Rb(e,t){const r=e[t];return r==null||r===""}function zd(e){const{apiEndpoint:t,apiMethod:r="GET",apiQueryParams:n={},formValues:o,submissionContext:s,apiRealtime:i,additionalRequiredFieldNames:a=[],excludeFormFieldNames:d=[]}=e,u=(r||"GET").toLowerCase(),l=$s(t,n),f=new Set((d||[]).filter(v=>typeof v=="string"&&v.length>0)),p=new Set((a||[]).filter(v=>typeof v=="string"&&v.length>0)),m=new Set([...l,...p]);let g=!1;for(const v of m){const x=!!(i&&l.has(v)),E=p.has(v);if((x||E)&&Rb(o,v)){g=!0;break}}if(g)return{blocked:!0,url:t,postBodyBase:null};let h=t;const y=t.match(/\{(\w+)\}/g)||[];if(h=Ia(h,s),i&&(h=Dn(h,o,s)),n&&Object.keys(n).length>0){const v=n,x=[];if(v.limit){let E=v.limit;i&&(E=Dn(E,o,s)),x.push(`_limit=${encodeURIComponent(E)}`)}if(v.page){let E=v.page;i&&(E=Dn(E,o,s)),x.push(`page=${encodeURIComponent(E)}`)}if(v.sort){let E=v.sort;i&&(E=Dn(E,o,s)),x.push(`sort=${encodeURIComponent(E)}`)}if(v.orderBy){let E=v.orderBy;i&&(E=Dn(E,o,s)),x.push(`orderBy=${encodeURIComponent(E)}`)}if(v.custom?.length&&v.custom.forEach(({key:E,value:P})=>{if(!E||!P)return;let k=Ia(P,s);i&&(k=Dn(k,o,s)),k.match(/\{[^}]+\}/)?k.match(/\{(?!ctx:|\@)(\w+)\}/g)||x.push(`${encodeURIComponent(E)}=`):x.push(`${encodeURIComponent(E)}=${encodeURIComponent(k)}`)}),x.length>0){const E=h.includes("?")?"&":"?";h=`${h}${E}${x.join("&")}`}}if(i&&Object.keys(o).length>0&&u==="get"){const v=k=>k.replace(/\{/g,"").replace(/\}/g,""),x=[];for(const k of n.custom||[])if(k.value){const N=k.value.match(/\{(\w+)\}/g)||[];x.push(...N.map(v))}const E=new Set([...y.map(v),...x]),P={};Object.keys(o).forEach(k=>{!E.has(k)&&!f.has(k)&&(P[k]=o[k])}),Object.keys(P).length>0&&(h=`${h}${h.includes("?")?"&":"?"}${new URLSearchParams(P).toString()}`)}let w=null;if(["post","put","patch"].includes(u))if(i&&Object.keys(o).length>0){w={...o};for(const v of f)delete w[v]}else{w={...o||{}};for(const v of f)delete w[v]}return{blocked:!1,url:h,postBodyBase:w}}const Gb=new Set(["select","multiselect","asyncsearch"]);function Kb(e){return e?.type==="multiselect"?[]:""}function Ud(e){if(!Gb.has(e.type))return[];const t=e.properties??{},r=jd(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,d=r?.apiQueryParams||t.apiQueryParams;if(i&&a)for(const u of $s(i,d))n.add(u);return[...n]}function qb(e,t){const r=Pr(t);return Ud(e).some(n=>Pr(n)===r)}function Yb(e,t){const r=Pr(t);return e.some(n=>qb(n,r))}function Xb(e){const t=new Map;for(const r of e){const n=r.name;if(n)for(const o of Ud(r)){const s=Pr(o),i=t.get(s)??new Set;i.add(n),t.set(s,i)}}return t}function Jb(e,t,r){const n=Pa(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 Qb(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 Zb(e,t,r){const n=Xb(e),o=Pr(r),s=new Set,i=[o];for(;i.length>0;){const u=i.shift(),l=n.get(u);if(l)for(const f of l)s.has(f)||(s.add(f),i.push(f))}const a={...t},d=[];for(const u of s){const l=e.find(p=>p.name===u),f=Kb(l);for(const p of Jb(u,r,a))Qb(a[p],f)||d.push(p),a[p]=f}return{values:a,clearedKeys:d}}function Ma(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}const Nt=Pd((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={},d=new Set,u=new Set,l=new Set;r.fields.forEach(y=>{const w=y.name||y.key||y.id;w&&(y.defaultValue!==void 0&&(y.type==="multiselect"?a[w]=Array.isArray(y.defaultValue)?y.defaultValue:y.defaultValue!=null&&y.defaultValue!==""?[String(y.defaultValue)]:[]:a[w]=y.defaultValue),y.hidden||d.add(w),y.disabled||u.add(w),y.validation?.some(v=>v.type==="required")&&l.add(w))});const f=r.steps?.length||1,p=[];r.fields.forEach(y=>{const w=y.properties;w?.valueSource==="calculated"&&w?.formula&&p.push({field:y.name,formula:w.formula})});const m=p.length>0?Md.calculateAll(p,a):{},g=Oa(r.fields,{...a,...m},new Set),h=s&&!i?{...g,...o.values}:g;e({schema:r,values:h,initialValues:g,errors:{},touched:{},currentStep:0,totalSteps:f,completedSteps:new Set,visibleFields:d,enabledFields:u,requiredFields:l,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 d=new Set(s.derivedFieldDirty);const u=s.values[r];let l={...s.values,[r]:n},f=[];if(i){const p=Pr(r),m=i.fields.find(w=>w.name===p);a==="user"&&m&&Fa(m)&&d.add(r);const g=n==null||n===""||Array.isArray(n)&&n.length===0;if($d(i.fields,r)&&g?l=Hb(i.fields,l,d,r):$d(i.fields,r)&&(l=Oa(i.fields,l,d,r)),a==="user"&&u!==n&&!(Array.isArray(u)&&Array.isArray(n)&&u.length===n.length&&u.every((w,v)=>w===n[v]))&&Yb(i.fields,r)){const w=Zb(i.fields,l,r);l=w.values,f=w.clearedKeys}const y=[];if(i.fields.forEach(w=>{const v=w.properties;v?.valueSource==="calculated"&&v?.formula&&(v.formulaSteps||[]).some(P=>P.type==="field"&&P.fieldName===r)&&y.push({field:w.name,formula:v.formula})}),y.length>0){const w=Md.calculateAll(y,l);l={...l,...w}}}e({values:l,derivedFieldDirty:d}),f.length>0&&e(p=>{const m={...p.errors};for(const g of f)delete m[g];return Object.keys(m).length===Object.keys(p.errors).length?p:{errors:m}}),i?.config.validateOnChange?t().validateField(r):e(p=>{const m={...p.errors};return delete m[r],{errors:m}})},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=Oa(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 d=Yr(o[r],a,o);if(typeof d=="string"){i=d;break}}if(!i){const a=Ta(s,o[r]);a&&(i=a)}return e(a=>{const d={...a.errors};return i?d[r]=i:delete d[r],{errors:d,isValid:Object.keys(d).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 d of a.validation){if(d.type==="required"&&!s.has(a.name))continue;const u=Yr(n[a.name],d,n);if(typeof u=="string"){i[a.name]=u;break}}if(!i[a.name]){const d=Ta(a,n[a.name]);d&&(i[a.name]=d)}}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||!n.steps)return!0;const i=n.steps[r];if(!i)return!0;e({isValidating:!0});const a={};for(const d of i.fields){const u=n.fields.find(l=>l.name===d);if(u&&s.has(u.name)){if(u.validation)for(const l of u.validation){const f=Yr(o[u.name],l,o);if(typeof f=="string"){a[u.name]=f;break}}if(!a[u.name]){const l=Ta(u,o[u.name]);l&&(a[u.name]=l)}}}return e(d=>({errors:{...d.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 Ma(n.visibleFields,o)?n:{visibleFields:o}})},updateEnabled:r=>{e(n=>{const o=new Set(r);return Ma(n.enabledFields,o)?n:{enabledFields:o}})},updateRequired:r=>{e(n=>{const o=new Set(r);return Ma(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{}}}));function ev(){return Nt.getState()}function Vd({schema:e,initialValues:t,onSubmit:r,onChange:n,workflowStepId:o}){const{values:s,errors:i,touched:a,isValidating:d,isSubmitting:u,submitCount:l,isValid:f,currentStep:p,totalSteps:m,completedSteps:g,visibleFields:h,enabledFields:y,requiredFields:w,setSchema:v,setFieldValue:x,setFieldTouched:E,setFieldError:P,setValues:k,resetForm:N,validateField:C,validateForm:A,validateStep:I,nextStep:T,prevStep:W,goToStep:X,setSubmitting:O,incrementSubmitCount:j,saveDraft:M,loadDraft:D,clearDraft:L}=Nt(),U=S.useRef(null);S.useLayoutEffect(()=>{if(v(e,{forceReset:!!o}),t&&Object.keys(t).length>0){const de=Nt.getState().values;k({...de,...t});try{U.current=JSON.stringify(t)}catch{U.current=null}}else U.current=null},[e.id,o]),S.useLayoutEffect(()=>{if(!t||Object.keys(t).length===0)return;let de;try{de=JSON.stringify(t)}catch{return}if(de===U.current)return;const ot=Nt.getState().values;k({...ot,...t}),U.current=de},[t,k]);const $=S.useCallback((de,ot)=>{const Se={...s,[de]:ot};x(de,ot),n?.(Se,de)},[x,n,s]),ie=S.useCallback(async de=>{if(de?.preventDefault(),j(),!await A())return{success:!1,errors:Object.entries(i).map(([Se,xe])=>({field:Se,rule:"validation",message:xe}))};if(!r)return{success:!0};O(!0);try{const Se=await r(s);return Se.success&&L(),Se}catch(Se){return{success:!1,message:Se instanceof Error?Se.message:"Submission failed"}}finally{O(!1)}},[A,r,s,i,j,O,L]),V=S.useCallback(de=>({value:s[de],error:i[de],touched:a[de]||!1,isVisible:h.has(de),isEnabled:y.has(de),isRequired:w.has(de)}),[s,i,a,h,y,w]),K=S.useMemo(()=>{if(!e.steps||e.steps.length===0)return e.fields;const de=e.steps[p];return de?e.fields.filter(ot=>de.fields.includes(ot.name)):[]},[e,p]),J=p===0,ce=p===m-1,ne=S.useCallback(de=>g.has(de),[g]),G=S.useMemo(()=>m<=1?100:Math.round(g.size/m*100),[g.size,m]),ee=S.useCallback(de=>h.has(de),[h]),Pe=S.useCallback(de=>y.has(de),[y]),oe=S.useCallback(de=>w.has(de),[w]),re=S.useMemo(()=>Object.entries(i).filter(([de])=>h.has(de)),[i,h]),be=re.length>0;return{values:s,errors:i,touched:a,isValidating:d,isSubmitting:u,submitCount:l,isValid:f,hasErrors:be,visibleErrors:re,currentStep:p,totalSteps:m,completedSteps:g,currentStepFields:K,isFirstStep:J,isLastStep:ce,isStepCompleted:ne,progress:G,setFieldValue:$,setFieldTouched:E,setFieldError:P,setValues:k,validateField:C,getFieldState:V,shouldShowField:ee,isFieldEnabled:Pe,isFieldRequired:oe,handleSubmit:ie,resetForm:N,validateForm:A,validateStep:I,nextStep:T,prevStep:W,goToStep:X,saveDraft:M,loadDraft:D,clearDraft:L}}function Hd(e){return"logic"in e&&"conditions"in e}function Uo(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 Wd(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 Qe(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;let r=Wd(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=Wd(e,o);Array.isArray(i)&&i.length>0&&(r=Qe(i[0],s))}}return r}const tv=new Set(["section","group","columns","divider","header","sectionHeading","spacer","textLabel","addmore","customizeSections"]);function rv(e){return e===!0||e==="true"?!0:e===!1||e==="false"?!1:e}function nv(e,t){if(e==null||typeof t.path!="string"||!t.path.trim())return!1;const r=Qe(e,t.path),n=rv(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 ov(e,t,r){return e?e==="__allFields__"?t.filter(n=>!tv.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]:[]}const Rd="__buttonResponse:";function sv({fields:e,values:t,buttonResponses:r,prepopulateResponse:n=null,prepopulateResponseRules:o}){const{updateVisibility:s,updateEnabled:i,updateRequired:a,updateReadOnly:d,updateEditable:u,updateFormDisabled:l}=Nt(),f=S.useCallback(k=>k.name||k.key||k.id,[]),p=S.useCallback((k,N)=>{if(!k)return f(N);const C=e.find(A=>A.id===k||A.name===k||A.key===k);return C?f(C):k},[e,f]),m=S.useCallback(k=>{const N=e.find(C=>C.id===k||C.name===k||C.key===k);return N?f(N):k},[e,f]),g=S.useCallback(k=>{const{field:N,operator:C,value:A}=k;if(typeof N=="string"&&N.startsWith(Rd)){const W=N.slice(Rd.length),X=r?.[W],O=Uo(X);return A==="success"?O:A==="failure"?X!=null&&!O:!1}const I=m(N),T=t[I];switch(C){case"equals":return T===A;case"notEquals":return T!==A;case"contains":return typeof T=="string"?T.includes(String(A)):Array.isArray(T)?T.includes(A):!1;case"notContains":return typeof T=="string"?!T.includes(String(A)):Array.isArray(T)?!T.includes(A):!0;case"startsWith":return typeof T=="string"&&T.startsWith(String(A));case"endsWith":return typeof T=="string"&&T.endsWith(String(A));case"greaterThan":return Number(T)>Number(A);case"lessThan":return Number(T)<Number(A);case"greaterThanOrEqual":return Number(T)>=Number(A);case"lessThanOrEqual":return Number(T)<=Number(A);case"isEmpty":return T==null?!0:T instanceof File?!1:typeof T=="string"?T.trim()==="":Array.isArray(T)?(T.length>0&&T[0]instanceof File,T.length===0):typeof T=="object"&&T!==null?Object.keys(T).length===0:!1;case"isNotEmpty":return T==null?!1:T instanceof File?!0:typeof T=="string"?T.trim()!=="":Array.isArray(T)?(T.length>0&&T[0]instanceof File,T.length>0):typeof T=="object"&&T!==null?Object.keys(T).length>0:!1;case"isTrue":return T===!0;case"isFalse":return T===!1;case"isNull":return T==null;case"isNotNull":return T!=null;case"in":return Array.isArray(A)?A.includes(T):!1;case"notIn":return Array.isArray(A)?!A.includes(T):!0;case"between":if(Array.isArray(A)&&A.length===2){const W=Number(T);return W>=Number(A[0])&&W<=Number(A[1])}return!1;case"regex":try{return new RegExp(String(A)).test(String(T))}catch{return!1}default:return!0}},[t,m,r]),h=S.useCallback(k=>{const N=k.conditions.map(C=>Hd(C)?h(C):g(C));return k.logic==="and"?N.every(Boolean):N.some(Boolean)},[g]),y=S.useCallback(k=>Hd(k)?h(k):g(k),[g,h]),w=S.useCallback(()=>{const k=new Set,N=new Set,C=new Set,A=new Set,I=new Set;e.forEach(O=>{const j=f(O);O.hidden||k.add(j),O.disabled||N.add(j),O.validation?.some(M=>M.type==="required")&&C.add(j)});let T=!1;if(n!=null&&o?.length)for(const O of o){if(!nv(n,O.when))continue;const{action:j,target:M}=O.then;if(j==="disableForm")T=!0;else if(j==="enableForm")T=!1;else{const D=ov(M,e,f);for(const L of D)switch(j){case"disable":N.delete(L);break;case"enable":N.add(L);break;case"hide":k.delete(L);break;case"show":k.add(L);break;case"readOnly":A.add(L),I.delete(L);break;case"editable":I.add(L),A.delete(L);break}}}e.forEach(O=>{O.conditions&&O.conditions.forEach(j=>{(y(j.when)?j.then:j.else||[]).forEach(L=>{switch(L.action){case"disableForm":T=!0;break;case"enableForm":T=!1;break;default:{const U=p(L.target,O);switch(L.action){case"show":k.add(U);break;case"hide":k.delete(U);break;case"enable":N.add(U);break;case"disable":N.delete(U);break;case"require":C.add(U);break;case"unrequire":C.delete(U);break}break}}})})});const W=O=>e.filter(j=>j.type!=="editButton"&&(j.name||j.key||j.id)).map(j=>f(j)),X=()=>e.filter(O=>O.type==="button").map(O=>f(O));return e.forEach(O=>{if(O.type!=="editButton")return;const j=f(O);if(!Uo(r?.[j]))return;const M=O.properties;M?.rules&&M.rules.length>0?M.rules.forEach(D=>{const L=[];D.allFields&&L.push(...W(O.id)),D.allButtons&&L.push(...X()),D.fieldNames?.length&&D.fieldNames.forEach(U=>{const $=e.find(ie=>f(ie)===U||ie.id===U||ie.name===U);L.push($?f($):U)}),D.buttonNames?.length&&L.push(...D.buttonNames),L.forEach(U=>{switch(D.action){case"enable":N.add(U),A.delete(U);break;case"disable":N.delete(U);break;case"show":k.add(U);break;case"hide":k.delete(U);break;case"readOnly":A.add(U);break;case"editable":I.add(U);break}})}):((M?.enableFieldNames??[]).forEach(D=>N.add(D)),(M?.disableFieldNames??[]).forEach(D=>N.delete(D)),(M?.showFieldNames??[]).forEach(D=>k.add(D)),(M?.hideFieldNames??[]).forEach(D=>k.delete(D)))}),{visible:Array.from(k),enabled:Array.from(N),required:Array.from(C),readOnly:Array.from(A),editable:Array.from(I),formDisabled:T}},[e,y,f,p,t,r,n,o]),v=S.useMemo(()=>w(),[w]);S.useEffect(()=>{s(v.visible),i(v.enabled),a(v.required),d(v.readOnly??[]),u(v.editable??[]),l(v.formDisabled??!1)},[v,s,i,a,d,u,l]);const x=S.useCallback(k=>v.visible.includes(k),[v.visible]),E=S.useCallback(k=>v.enabled.includes(k),[v.enabled]),P=S.useCallback(k=>v.required.includes(k),[v.required]);return{evaluateCondition:y,evaluateExpression:g,evaluateGroup:h,isFieldVisible:x,isFieldEnabled:E,isFieldRequired:P,visibleFields:v.visible,enabledFields:v.enabled,requiredFields:v.required}}function wn({className:e,type:t,...r}){return c.jsx("input",{type:t,"data-slot":"input",className:B("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 Gd(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Bn(...e){return t=>{let r=!1;const n=e.map(o=>{const s=Gd(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():Gd(e[o],null)}}}}function Ze(...e){return b.useCallback(Bn(...e),e)}var iv=Symbol.for("react.lazy"),js=b[" use ".trim().toString()];function av(e){return typeof e=="object"&&e!==null&&"then"in e}function Kd(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===iv&&"_payload"in e&&av(e._payload)}function La(e){const t=lv(e),r=b.forwardRef((n,o)=>{let{children:s,...i}=n;Kd(s)&&typeof js=="function"&&(s=js(s._payload));const a=b.Children.toArray(s),d=a.find(dv);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}var qd=La("Slot");function lv(e){const t=b.forwardRef((r,n)=>{let{children:o,...s}=r;if(Kd(o)&&typeof js=="function"&&(o=js(o._payload)),b.isValidElement(o)){const i=fv(o),a=uv(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(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 cv=Symbol("radix.slottable");function dv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===cv}function uv(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 d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function fv(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 pv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mv=pv.reduce((e,t)=>{const r=La(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,d=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),hv="Label",Yd=b.forwardRef((e,t)=>c.jsx(mv.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));Yd.displayName=hv;var gv=Yd;function Sn({className:e,...t}){return c.jsx(gv,{"data-slot":"label",className:B("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 ht(e){return`formsmith-field-${e.id}`}function zs(e){return`formsmith-label-${e.id}`}function Vo(e){return`formsmith-desc-${e.id}`}function Ho(e){return`formsmith-error-${e.id}`}function jt(e,t){const r=[];return e.description&&r.push(Vo(e)),t&&r.push(Ho(e)),r.length>0?r.join(" "):void 0}function Jt(e){return e?!0:void 0}const yv={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 xn(e){return e.ui?.cellStyle}function bv(e){const t=e.ui;if(!t)return;const r=t.fontToken?yv[t.fontToken]:void 0;if(!(!r&&!t.wrapperStyle))return{...r,...t.wrapperStyle}}function vv(e){return e.type==="button"||e.type==="editButton"}const Et=({field:e,error:t,isRequired:r,children:n,className:o,hideLabel:s})=>{const{gridStretch:i}=zo(),a=i&&Is(e),d=!(s??e.appearance?.hideLabel)&&e.label,u=e.appearance?.labelPlacement||"top",l=bv(e),f=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,m=Nd(e),g=to(e),h=vv(e),y=Fr(e.appearance);return c.jsx("div",{className:B(Sb(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:l,"data-field-appearance":u,children:c.jsxs("div",{className:B("flex flex-col min-w-0",xd(e.appearance),_d(e),a&&!h&&"flex-1 min-h-0",i&&h&&"shrink-0"),style:m,children:[d&&c.jsxs(Sn,{id:zs(e),htmlFor:ht(e),style:e.ui?.labelStyle,className:B(xb(u,!!t)),children:[e.label,r&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),c.jsxs("div",{className:B(Ab(u),h&&i&&"min-h-min !grow-0 !shrink-0 basis-auto",g&&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:f,children:[n,c.jsxs("div",{className:B("mt-1.5 min-h-[18px]",u==="center"&&"text-center",o?.includes("flex")&&"shrink-0"),children:[e.description&&!t&&c.jsx("p",{id:Vo(e),className:"text-xs text-muted-foreground",style:e.ui?.descriptionStyle,children:e.description}),t&&c.jsx("p",{id:Ho(e),className:"text-xs text-destructive",role:"alert",children:typeof t=="string"?t:String(t||"An error occurred")})]})]})]})})},Da=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=S.useCallback(f=>{r(f.target.value)},[r]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsx(wn,{id:ht(e),type:"text",value:t||"",onChange:l,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":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})})},Xd=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=u?.precision!=null||u?.step!=null&&!Number.isInteger(u.step),f=S.useCallback(m=>{const g=u?.allowNegative!==!1,h=m.target.value,y=l?h.replace(g?/[^\d.-]/g:/[^\d.]/g,""):h.replace(g?/[^\d-]/g:/\D/g,"");if(y===""){r(null);return}const w=parseFloat(y);isNaN(w)||r(w)},[r,u?.allowNegative,l]),p=S.useCallback(m=>{(m.key==="ArrowUp"||m.key==="ArrowDown"||m.key==="PageUp"||m.key==="PageDown")&&m.preventDefault()},[]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[u?.prefix&&c.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.prefix}),c.jsx(wn,{id:ht(e),type:"text",inputMode:l?"decimal":"numeric",autoComplete:"off",value:t??"",onChange:f,onKeyDown:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",u?.prefix&&"pl-8",u?.suffix&&"pr-8",e.appearance?.className)}),u?.suffix&&c.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.suffix})]})})};const wv=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Sv=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),Jd=e=>{const t=Sv(e);return t.charAt(0).toUpperCase()+t.slice(1)},Qd=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),xv=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Av={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 Cv=S.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:s,iconNode:i,...a},d)=>S.createElement("svg",{ref:d,...Av,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:Qd("lucide",o),...!s&&!xv(a)&&{"aria-hidden":"true"},...a},[...i.map(([u,l])=>S.createElement(u,l)),...Array.isArray(s)?s:[s]]));const Gt=(e,t)=>{const r=S.forwardRef(({className:n,...o},s)=>S.createElement(Cv,{ref:s,iconNode:t,className:Qd(`lucide-${wv(Jd(e))}`,`lucide-${e}`,n),...o}));return r.displayName=Jd(e),r};const Ev=Gt("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 Us=Gt("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 Vs=Gt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Wo=Gt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Zd=Gt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Nv=Gt("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const _v=Gt("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 eu=Gt("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const tu=Gt("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=Gt("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 Ro=Gt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const kv=Gt("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 Tv=Gt("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 nu=Gt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Fv=Gt("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 ou=Gt("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 Go=Gt("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 Hs=Gt("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 Ko=Gt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),su=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=S.useCallback(l=>{r(l.target.value)},[r]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[c.jsx(kv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),c.jsx(wn,{id:ht(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":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})},iu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=S.useCallback(l=>{const f=l.target.value.replace(/[^\d\s+\-()]/g,"");r(f)},[r]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[c.jsx(Tv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),c.jsx(wn,{id:ht(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":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})};function Pv({className:e,maxLength:t,showCharacterCount:r=!1,autoResize:n=!1,onChange:o,value:s,...i}){const a=b.useRef(null),[d,u]=b.useState(0),l=f=>{const p=f.target.value;u(p.length),n&&a.current&&(a.current.style.height="auto",a.current.style.height=`${a.current.scrollHeight}px`),o&&o(f)};return b.useEffect(()=>{s&&u(String(s).length)},[s]),c.jsxs("div",{className:"space-y-1",children:[c.jsx("textarea",{ref:a,"data-slot":"textarea",className:B("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:l,value:s,...i}),r&&c.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[c.jsxs("span",{children:[d," characters"]}),t&&c.jsxs("span",{children:[t-d," remaining"]})]})]})}const au=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const{gridStretch:u}=zo(),l=u&&Is(e),f=e.properties,p=S.useCallback(y=>{r(y.target.value)},[r]),m=(t||"").length,g=f?.maxLength,h=g&&g>0;return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:B("relative flex flex-col",l&&"flex-1 min-h-0"),children:[c.jsx(Pv,{id:ht(e),value:t||"",onChange:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,minLength:f?.minLength,maxLength:f?.maxLength,rows:2,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(vd(e.appearance),"resize-y",l&&"min-h-[120px] flex-1 flex-shrink-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),h&&c.jsxs("span",{className:"absolute bottom-2 right-2 text-xs text-muted-foreground",children:[m,"/",g]})]})})};function qo(e,[t,r]){return Math.min(r,Math.max(t,e))}function Me(e,t,{checkForDefaultPrevented:r=!0}={}){return function(o){if(e?.(o),r===!1||!o.defaultPrevented)return t?.(o)}}function Ov(e,t){const r=b.createContext(t),n=s=>{const{children:i,...a}=s,d=b.useMemo(()=>a,Object.values(a));return c.jsx(r.Provider,{value:d,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),d=r.length;r=[...r,i];const u=f=>{const{scope:p,children:m,...g}=f,h=p?.[e]?.[d]||a,y=b.useMemo(()=>g,Object.values(g));return c.jsx(h.Provider,{value:y,children:m})};u.displayName=s+"Provider";function l(f,p){const m=p?.[e]?.[d]||a,g=b.useContext(m);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,l]}const o=()=>{const s=r.map(i=>b.createContext(i));return function(a){const d=a?.[e]||s;return b.useMemo(()=>({[`__scope${e}`]:{...a,[e]:d}}),[a,d])}};return o.scopeName=e,[n,Iv(o,...t)]}function Iv(...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:d,scopeName:u})=>{const f=d(s)[`__scope${u}`];return{...a,...f}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return r.scopeName=t.scopeName,r}function lu(e){const t=Mv(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(Dv);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function Mv(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=$v(o),a=Bv(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(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 Lv=Symbol("radix.slottable");function Dv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Lv}function Bv(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 d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function $v(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 Ba(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:w}=h,v=S.useRef(null),x=S.useRef(new Map).current;return c.jsx(o,{scope:y,itemMap:x,collectionRef:v,children:w})};i.displayName=t;const a=e+"CollectionSlot",d=lu(a),u=S.forwardRef((h,y)=>{const{scope:w,children:v}=h,x=s(a,w),E=Ze(y,x.collectionRef);return c.jsx(d,{ref:E,children:v})});u.displayName=a;const l=e+"CollectionItemSlot",f="data-radix-collection-item",p=lu(l),m=S.forwardRef((h,y)=>{const{scope:w,children:v,...x}=h,E=S.useRef(null),P=Ze(y,E),k=s(l,w);return S.useEffect(()=>(k.itemMap.set(E,{ref:E,...x}),()=>{k.itemMap.delete(E)})),c.jsx(p,{[f]:"",ref:P,children:v})});m.displayName=l;function g(h){const y=s(e+"CollectionConsumer",h);return S.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const x=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((k,N)=>x.indexOf(k.ref.current)-x.indexOf(N.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},g,n]}var jv=b.createContext(void 0);function ro(e){const t=b.useContext(jv);return e||t||"ltr"}function zv(e){const t=Uv(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(Hv);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function Uv(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=Rv(o),a=Wv(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(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 Vv=Symbol("radix.slottable");function Hv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Vv}function Wv(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 d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function Rv(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 Gv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Be=Gv.reduce((e,t)=>{const r=zv(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,d=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Kv(e,t){e&&Es.flushSync(()=>e.dispatchEvent(t))}function ar(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>(...r)=>t.current?.(...r),[])}function qv(e,t=globalThis?.document){const r=ar(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 Yv="DismissableLayer",$a="dismissableLayer.update",Xv="dismissableLayer.pointerDownOutside",Jv="dismissableLayer.focusOutside",cu,du=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ws=b.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...d}=e,u=b.useContext(du),[l,f]=b.useState(null),p=l?.ownerDocument??globalThis?.document,[,m]=b.useState({}),g=Ze(t,N=>f(N)),h=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=h.indexOf(y),v=l?h.indexOf(l):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,E=v>=w,P=ew(N=>{const C=N.target,A=[...u.branches].some(I=>I.contains(C));!E||A||(o?.(N),i?.(N),N.defaultPrevented||a?.())},p),k=tw(N=>{const C=N.target;[...u.branches].some(I=>I.contains(C))||(s?.(N),i?.(N),N.defaultPrevented||a?.())},p);return qv(N=>{v===u.layers.size-1&&(n?.(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},p),b.useEffect(()=>{if(l)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(cu=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(l)),u.layers.add(l),uu(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=cu)}},[l,p,r,u]),b.useEffect(()=>()=>{l&&(u.layers.delete(l),u.layersWithOutsidePointerEventsDisabled.delete(l),uu())},[l,u]),b.useEffect(()=>{const N=()=>m({});return document.addEventListener($a,N),()=>document.removeEventListener($a,N)},[]),c.jsx(Be.div,{...d,ref:g,style:{pointerEvents:x?E?"auto":"none":void 0,...e.style},onFocusCapture:Me(e.onFocusCapture,k.onFocusCapture),onBlurCapture:Me(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:Me(e.onPointerDownCapture,P.onPointerDownCapture)})});Ws.displayName=Yv;var Qv="DismissableLayerBranch",Zv=b.forwardRef((e,t)=>{const r=b.useContext(du),n=b.useRef(null),o=Ze(t,n);return b.useEffect(()=>{const s=n.current;if(s)return r.branches.add(s),()=>{r.branches.delete(s)}},[r.branches]),c.jsx(Be.div,{...e,ref:o})});Zv.displayName=Qv;function ew(e,t=globalThis?.document){const r=ar(e),n=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const s=a=>{if(a.target&&!n.current){let d=function(){fu(Xv,r,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}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 tw(e,t=globalThis?.document){const r=ar(e),n=b.useRef(!1);return b.useEffect(()=>{const o=s=>{s.target&&!n.current&&fu(Jv,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 uu(){const e=new CustomEvent($a);document.dispatchEvent(e)}function fu(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?Kv(o,s):o.dispatchEvent(s)}var ja=0;function za(){b.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??pu()),document.body.insertAdjacentElement("beforeend",e[1]??pu()),ja++,()=>{ja===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ja--}},[])}function pu(){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 Ua="focusScope.autoFocusOnMount",Va="focusScope.autoFocusOnUnmount",mu={bubbles:!1,cancelable:!0},rw="FocusScope",Rs=b.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,d]=b.useState(null),u=ar(o),l=ar(s),f=b.useRef(null),p=Ze(t,h=>d(h)),m=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(n){let h=function(x){if(m.paused||!a)return;const E=x.target;a.contains(E)?f.current=E:An(f.current,{select:!0})},y=function(x){if(m.paused||!a)return;const E=x.relatedTarget;E!==null&&(a.contains(E)||An(f.current,{select:!0}))},w=function(x){if(document.activeElement===document.body)for(const P of x)P.removedNodes.length>0&&An(a)};document.addEventListener("focusin",h),document.addEventListener("focusout",y);const v=new MutationObserver(w);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",y),v.disconnect()}}},[n,a,m.paused]),b.useEffect(()=>{if(a){yu.add(m);const h=document.activeElement;if(!a.contains(h)){const w=new CustomEvent(Ua,mu);a.addEventListener(Ua,u),a.dispatchEvent(w),w.defaultPrevented||(nw(lw(hu(a)),{select:!0}),document.activeElement===h&&An(a))}return()=>{a.removeEventListener(Ua,u),setTimeout(()=>{const w=new CustomEvent(Va,mu);a.addEventListener(Va,l),a.dispatchEvent(w),w.defaultPrevented||An(h??document.body,{select:!0}),a.removeEventListener(Va,l),yu.remove(m)},0)}}},[a,u,l,m]);const g=b.useCallback(h=>{if(!r&&!n||m.paused)return;const y=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,w=document.activeElement;if(y&&w){const v=h.currentTarget,[x,E]=ow(v);x&&E?!h.shiftKey&&w===E?(h.preventDefault(),r&&An(x,{select:!0})):h.shiftKey&&w===x&&(h.preventDefault(),r&&An(E,{select:!0})):w===v&&h.preventDefault()}},[r,n,m.paused]);return c.jsx(Be.div,{tabIndex:-1,...i,ref:p,onKeyDown:g})});Rs.displayName=rw;function nw(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(An(n,{select:t}),document.activeElement!==r)return}function ow(e){const t=hu(e),r=gu(t,e),n=gu(t.reverse(),e);return[r,n]}function hu(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 gu(e,t){for(const r of e)if(!sw(r,{upTo:t}))return r}function sw(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 iw(e){return e instanceof HTMLInputElement&&"select"in e}function An(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&iw(e)&&t&&e.select()}}var yu=aw();function aw(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=bu(e,t),e.unshift(t)},remove(t){e=bu(e,t),e[0]?.resume()}}}function bu(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function lw(e){return e.filter(t=>t.tagName!=="A")}var Qt=globalThis?.document?b.useLayoutEffect:()=>{},cw=b[" useId ".trim().toString()]||(()=>{}),dw=0;function on(e){const[t,r]=b.useState(cw());return Qt(()=>{r(n=>n??String(dw++))},[e]),e||(t?`radix-${t}`:"")}const uw=["top","right","bottom","left"],Cn=Math.min,wr=Math.max,Gs=Math.round,Ks=Math.floor,Xr=e=>({x:e,y:e}),fw={left:"right",right:"left",bottom:"top",top:"bottom"};function Ha(e,t,r){return wr(e,Cn(t,r))}function sn(e,t){return typeof e=="function"?e(t):e}function an(e){return e.split("-")[0]}function no(e){return e.split("-")[1]}function Wa(e){return e==="x"?"y":"x"}function Ra(e){return e==="y"?"height":"width"}function Jr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Ga(e){return Wa(Jr(e))}function pw(e,t,r){r===void 0&&(r=!1);const n=no(e),o=Ga(e),s=Ra(o);let i=o==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=qs(i)),[i,qs(i)]}function mw(e){const t=qs(e);return[Ka(e),t,Ka(t)]}function Ka(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const vu=["left","right"],wu=["right","left"],hw=["top","bottom"],gw=["bottom","top"];function yw(e,t,r){switch(e){case"top":case"bottom":return r?t?wu:vu:t?vu:wu;case"left":case"right":return t?hw:gw;default:return[]}}function bw(e,t,r,n){const o=no(e);let s=yw(an(e),r==="start",n);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ka)))),s}function qs(e){const t=an(e);return fw[t]+e.slice(t.length)}function vw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Su(e){return typeof e!="number"?vw(e):{top:e,right:e,bottom:e,left:e}}function Ys(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 xu(e,t,r){let{reference:n,floating:o}=e;const s=Jr(t),i=Ga(t),a=Ra(i),d=an(t),u=s==="y",l=n.x+n.width/2-o.width/2,f=n.y+n.height/2-o.height/2,p=n[a]/2-o[a]/2;let m;switch(d){case"top":m={x:l,y:n.y-o.height};break;case"bottom":m={x:l,y:n.y+n.height};break;case"right":m={x:n.x+n.width,y:f};break;case"left":m={x:n.x-o.width,y:f};break;default:m={x:n.x,y:n.y}}switch(no(t)){case"start":m[i]-=p*(r&&u?-1:1);break;case"end":m[i]+=p*(r&&u?-1:1);break}return m}async function ww(e,t){var r;t===void 0&&(t={});const{x:n,y:o,platform:s,rects:i,elements:a,strategy:d}=e,{boundary:u="clippingAncestors",rootBoundary:l="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=sn(t,e),g=Su(m),y=a[p?f==="floating"?"reference":"floating":f],w=Ys(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:l,strategy:d})),v=f==="floating"?{x:n,y:o,width:i.floating.width,height:i.floating.height}:i.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},P=Ys(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:d}):v);return{top:(w.top-P.top+g.top)/E.y,bottom:(P.bottom-w.bottom+g.bottom)/E.y,left:(w.left-P.left+g.left)/E.x,right:(P.right-w.right+g.right)/E.x}}const Sw=50,xw=async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:s=[],platform:i}=r,a=i.detectOverflow?i:{...i,detectOverflow:ww},d=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:l,y:f}=xu(u,n,d),p=n,m=0;const g={};for(let h=0;h<s.length;h++){const y=s[h];if(!y)continue;const{name:w,fn:v}=y,{x,y:E,data:P,reset:k}=await v({x:l,y:f,initialPlacement:n,placement:p,strategy:o,middlewareData:g,rects:u,platform:a,elements:{reference:e,floating:t}});l=x??l,f=E??f,g[w]={...g[w],...P},k&&m<Sw&&(m++,typeof k=="object"&&(k.placement&&(p=k.placement),k.rects&&(u=k.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):k.rects),{x:l,y:f}=xu(u,p,d)),h=-1)}return{x:l,y:f,placement:p,strategy:o,middlewareData:g}},Aw=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:o,rects:s,platform:i,elements:a,middlewareData:d}=t,{element:u,padding:l=0}=sn(e,t)||{};if(u==null)return{};const f=Su(l),p={x:r,y:n},m=Ga(o),g=Ra(m),h=await i.getDimensions(u),y=m==="y",w=y?"top":"left",v=y?"bottom":"right",x=y?"clientHeight":"clientWidth",E=s.reference[g]+s.reference[m]-p[m]-s.floating[g],P=p[m]-s.reference[m],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let N=k?k[x]:0;(!N||!await(i.isElement==null?void 0:i.isElement(k)))&&(N=a.floating[x]||s.floating[g]);const C=E/2-P/2,A=N/2-h[g]/2-1,I=Cn(f[w],A),T=Cn(f[v],A),W=I,X=N-h[g]-T,O=N/2-h[g]/2+C,j=Ha(W,O,X),M=!d.arrow&&no(o)!=null&&O!==j&&s.reference[g]/2-(O<W?I:T)-h[g]/2<0,D=M?O<W?O-W:O-X:0;return{[m]:p[m]+D,data:{[m]:j,centerOffset:O-j-D,...M&&{alignmentOffset:D}},reset:M}}}),Cw=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:d,elements:u}=t,{mainAxis:l=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...y}=sn(e,t);if((r=s.arrow)!=null&&r.alignmentOffset)return{};const w=an(o),v=Jr(a),x=an(a)===a,E=await(d.isRTL==null?void 0:d.isRTL(u.floating)),P=p||(x||!h?[qs(a)]:mw(a)),k=g!=="none";!p&&k&&P.push(...bw(a,h,g,E));const N=[a,...P],C=await d.detectOverflow(t,y),A=[];let I=((n=s.flip)==null?void 0:n.overflows)||[];if(l&&A.push(C[w]),f){const O=pw(o,i,E);A.push(C[O[0]],C[O[1]])}if(I=[...I,{placement:o,overflows:A}],!A.every(O=>O<=0)){var T,W;const O=(((T=s.flip)==null?void 0:T.index)||0)+1,j=N[O];if(j&&(!(f==="alignment"?v!==Jr(j):!1)||I.every(L=>Jr(L.placement)===v?L.overflows[0]>0:!0)))return{data:{index:O,overflows:I},reset:{placement:j}};let M=(W=I.filter(D=>D.overflows[0]<=0).sort((D,L)=>D.overflows[1]-L.overflows[1])[0])==null?void 0:W.placement;if(!M)switch(m){case"bestFit":{var X;const D=(X=I.filter(L=>{if(k){const U=Jr(L.placement);return U===v||U==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(U=>U>0).reduce((U,$)=>U+$,0)]).sort((L,U)=>L[1]-U[1])[0])==null?void 0:X[0];D&&(M=D);break}case"initialPlacement":M=a;break}if(o!==M)return{reset:{placement:M}}}return{}}}};function Au(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Cu(e){return uw.some(t=>e[t]>=0)}const Ew=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:n}=t,{strategy:o="referenceHidden",...s}=sn(e,t);switch(o){case"referenceHidden":{const i=await n.detectOverflow(t,{...s,elementContext:"reference"}),a=Au(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Cu(a)}}}case"escaped":{const i=await n.detectOverflow(t,{...s,altBoundary:!0}),a=Au(i,r.floating);return{data:{escapedOffsets:a,escaped:Cu(a)}}}default:return{}}}}},Eu=new Set(["left","top"]);async function Nw(e,t){const{placement:r,platform:n,elements:o}=e,s=await(n.isRTL==null?void 0:n.isRTL(o.floating)),i=an(r),a=no(r),d=Jr(r)==="y",u=Eu.has(i)?-1:1,l=s&&d?-1:1,f=sn(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof g=="number"&&(m=a==="end"?g*-1:g),d?{x:m*l,y:p*u}:{x:p*u,y:m*l}}const _w=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,d=await Nw(t,e);return i===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+d.x,y:s+d.y,data:{...d,placement:i}}}}},kw=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:d={fn:w=>{let{x:v,y:x}=w;return{x:v,y:x}}},...u}=sn(e,t),l={x:r,y:n},f=await s.detectOverflow(t,u),p=Jr(an(o)),m=Wa(p);let g=l[m],h=l[p];if(i){const w=m==="y"?"top":"left",v=m==="y"?"bottom":"right",x=g+f[w],E=g-f[v];g=Ha(x,g,E)}if(a){const w=p==="y"?"top":"left",v=p==="y"?"bottom":"right",x=h+f[w],E=h-f[v];h=Ha(x,h,E)}const y=d.fn({...t,[m]:g,[p]:h});return{...y,data:{x:y.x-r,y:y.y-n,enabled:{[m]:i,[p]:a}}}}}},Tw=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:d=!0,crossAxis:u=!0}=sn(e,t),l={x:r,y:n},f=Jr(o),p=Wa(f);let m=l[p],g=l[f];const h=sn(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(d){const x=p==="y"?"height":"width",E=s.reference[p]-s.floating[x]+y.mainAxis,P=s.reference[p]+s.reference[x]-y.mainAxis;m<E?m=E:m>P&&(m=P)}if(u){var w,v;const x=p==="y"?"width":"height",E=Eu.has(an(o)),P=s.reference[f]-s.floating[x]+(E&&((w=i.offset)==null?void 0:w[f])||0)+(E?0:y.crossAxis),k=s.reference[f]+s.reference[x]+(E?0:((v=i.offset)==null?void 0:v[f])||0)-(E?y.crossAxis:0);g<P?g=P:g>k&&(g=k)}return{[p]:m,[f]:g}}}},Fw=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:d=()=>{},...u}=sn(e,t),l=await i.detectOverflow(t,u),f=an(o),p=no(o),m=Jr(o)==="y",{width:g,height:h}=s.floating;let y,w;f==="top"||f==="bottom"?(y=f,w=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=f,y=p==="end"?"top":"bottom");const v=h-l.top-l.bottom,x=g-l.left-l.right,E=Cn(h-l[y],v),P=Cn(g-l[w],x),k=!t.middlewareData.shift;let N=E,C=P;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(C=x),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(N=v),k&&!p){const I=wr(l.left,0),T=wr(l.right,0),W=wr(l.top,0),X=wr(l.bottom,0);m?C=g-2*(I!==0||T!==0?I+T:wr(l.left,l.right)):N=h-2*(W!==0||X!==0?W+X:wr(l.top,l.bottom))}await d({...t,availableWidth:C,availableHeight:N});const A=await i.getDimensions(a.floating);return g!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}};function Xs(){return typeof window<"u"}function oo(e){return Nu(e)?(e.nodeName||"").toLowerCase():"#document"}function Sr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Qr(e){var t;return(t=(Nu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Nu(e){return Xs()?e instanceof Node||e instanceof Sr(e).Node:!1}function Ur(e){return Xs()?e instanceof Element||e instanceof Sr(e).Element:!1}function ln(e){return Xs()?e instanceof HTMLElement||e instanceof Sr(e).HTMLElement:!1}function _u(e){return!Xs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Sr(e).ShadowRoot}function Yo(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=Vr(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&o!=="inline"&&o!=="contents"}function Pw(e){return/^(table|td|th)$/.test(oo(e))}function Js(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Ow=/transform|translate|scale|rotate|perspective|filter/,Iw=/paint|layout|strict|content/,$n=e=>!!e&&e!=="none";let qa;function Ya(e){const t=Ur(e)?Vr(e):e;return $n(t.transform)||$n(t.translate)||$n(t.scale)||$n(t.rotate)||$n(t.perspective)||!Xa()&&($n(t.backdropFilter)||$n(t.filter))||Ow.test(t.willChange||"")||Iw.test(t.contain||"")}function Mw(e){let t=En(e);for(;ln(t)&&!so(t);){if(Ya(t))return t;if(Js(t))return null;t=En(t)}return null}function Xa(){return qa==null&&(qa=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),qa}function so(e){return/^(html|body|#document)$/.test(oo(e))}function Vr(e){return Sr(e).getComputedStyle(e)}function Qs(e){return Ur(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function En(e){if(oo(e)==="html")return e;const t=e.assignedSlot||e.parentNode||_u(e)&&e.host||Qr(e);return _u(t)?t.host:t}function ku(e){const t=En(e);return so(t)?e.ownerDocument?e.ownerDocument.body:e.body:ln(t)&&Yo(t)?t:ku(t)}function Xo(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const o=ku(e),s=o===((n=e.ownerDocument)==null?void 0:n.body),i=Sr(o);if(s){const a=Ja(i);return t.concat(i,i.visualViewport||[],Yo(o)?o:[],a&&r?Xo(a):[])}else return t.concat(o,Xo(o,[],r))}function Ja(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Tu(e){const t=Vr(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=ln(e),s=o?e.offsetWidth:r,i=o?e.offsetHeight:n,a=Gs(r)!==s||Gs(n)!==i;return a&&(r=s,n=i),{width:r,height:n,$:a}}function Qa(e){return Ur(e)?e:e.contextElement}function io(e){const t=Qa(e);if(!ln(t))return Xr(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:s}=Tu(t);let i=(s?Gs(r.width):r.width)/n,a=(s?Gs(r.height):r.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Lw=Xr(0);function Fu(e){const t=Sr(e);return!Xa()||!t.visualViewport?Lw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Dw(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Sr(e)?!1:t}function jn(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),s=Qa(e);let i=Xr(1);t&&(n?Ur(n)&&(i=io(n)):i=io(e));const a=Dw(s,r,n)?Fu(s):Xr(0);let d=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,l=o.width/i.x,f=o.height/i.y;if(s){const p=Sr(s),m=n&&Ur(n)?Sr(n):n;let g=p,h=Ja(g);for(;h&&n&&m!==g;){const y=io(h),w=h.getBoundingClientRect(),v=Vr(h),x=w.left+(h.clientLeft+parseFloat(v.paddingLeft))*y.x,E=w.top+(h.clientTop+parseFloat(v.paddingTop))*y.y;d*=y.x,u*=y.y,l*=y.x,f*=y.y,d+=x,u+=E,g=Sr(h),h=Ja(g)}}return Ys({width:l,height:f,x:d,y:u})}function Zs(e,t){const r=Qs(e).scrollLeft;return t?t.left+r:jn(Qr(e)).left+r}function Pu(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-Zs(e,r),o=r.top+t.scrollTop;return{x:n,y:o}}function Bw(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const s=o==="fixed",i=Qr(n),a=t?Js(t.floating):!1;if(n===i||a&&s)return r;let d={scrollLeft:0,scrollTop:0},u=Xr(1);const l=Xr(0),f=ln(n);if((f||!f&&!s)&&((oo(n)!=="body"||Yo(i))&&(d=Qs(n)),f)){const m=jn(n);u=io(n),l.x=m.x+n.clientLeft,l.y=m.y+n.clientTop}const p=i&&!f&&!s?Pu(i,d):Xr(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-d.scrollLeft*u.x+l.x+p.x,y:r.y*u.y-d.scrollTop*u.y+l.y+p.y}}function $w(e){return Array.from(e.getClientRects())}function jw(e){const t=Qr(e),r=Qs(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+Zs(e);const a=-r.scrollTop;return Vr(n).direction==="rtl"&&(i+=wr(t.clientWidth,n.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Ou=25;function zw(e,t){const r=Sr(e),n=Qr(e),o=r.visualViewport;let s=n.clientWidth,i=n.clientHeight,a=0,d=0;if(o){s=o.width,i=o.height;const l=Xa();(!l||l&&t==="fixed")&&(a=o.offsetLeft,d=o.offsetTop)}const u=Zs(n);if(u<=0){const l=n.ownerDocument,f=l.body,p=getComputedStyle(f),m=l.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(n.clientWidth-f.clientWidth-m);g<=Ou&&(s-=g)}else u<=Ou&&(s+=u);return{width:s,height:i,x:a,y:d}}function Uw(e,t){const r=jn(e,!0,t==="fixed"),n=r.top+e.clientTop,o=r.left+e.clientLeft,s=ln(e)?io(e):Xr(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,d=o*s.x,u=n*s.y;return{width:i,height:a,x:d,y:u}}function Iu(e,t,r){let n;if(t==="viewport")n=zw(e,r);else if(t==="document")n=jw(Qr(e));else if(Ur(t))n=Uw(t,r);else{const o=Fu(e);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ys(n)}function Mu(e,t){const r=En(e);return r===t||!Ur(r)||so(r)?!1:Vr(r).position==="fixed"||Mu(r,t)}function Vw(e,t){const r=t.get(e);if(r)return r;let n=Xo(e,[],!1).filter(a=>Ur(a)&&oo(a)!=="body"),o=null;const s=Vr(e).position==="fixed";let i=s?En(e):e;for(;Ur(i)&&!so(i);){const a=Vr(i),d=Ya(i);!d&&a.position==="fixed"&&(o=null),(s?!d&&!o:!d&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Yo(i)&&!d&&Mu(e,i))?n=n.filter(l=>l!==i):o=a,i=En(i)}return t.set(e,n),n}function Hw(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const i=[...r==="clippingAncestors"?Js(t)?[]:Vw(t,this._c):[].concat(r),n],a=Iu(t,i[0],o);let d=a.top,u=a.right,l=a.bottom,f=a.left;for(let p=1;p<i.length;p++){const m=Iu(t,i[p],o);d=wr(m.top,d),u=Cn(m.right,u),l=Cn(m.bottom,l),f=wr(m.left,f)}return{width:u-f,height:l-d,x:f,y:d}}function Ww(e){const{width:t,height:r}=Tu(e);return{width:t,height:r}}function Rw(e,t,r){const n=ln(t),o=Qr(t),s=r==="fixed",i=jn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const d=Xr(0);function u(){d.x=Zs(o)}if(n||!n&&!s)if((oo(t)!=="body"||Yo(o))&&(a=Qs(t)),n){const m=jn(t,!0,s,t);d.x=m.x+t.clientLeft,d.y=m.y+t.clientTop}else o&&u();s&&!n&&o&&u();const l=o&&!n&&!s?Pu(o,a):Xr(0),f=i.left+a.scrollLeft-d.x-l.x,p=i.top+a.scrollTop-d.y-l.y;return{x:f,y:p,width:i.width,height:i.height}}function Za(e){return Vr(e).position==="static"}function Lu(e,t){if(!ln(e)||Vr(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Qr(e)===r&&(r=r.ownerDocument.body),r}function Du(e,t){const r=Sr(e);if(Js(e))return r;if(!ln(e)){let o=En(e);for(;o&&!so(o);){if(Ur(o)&&!Za(o))return o;o=En(o)}return r}let n=Lu(e,t);for(;n&&Pw(n)&&Za(n);)n=Lu(n,t);return n&&so(n)&&Za(n)&&!Ya(n)?r:n||Mw(e)||r}const Gw=async function(e){const t=this.getOffsetParent||Du,r=this.getDimensions,n=await r(e.floating);return{reference:Rw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Kw(e){return Vr(e).direction==="rtl"}const qw={convertOffsetParentRelativeRectToViewportRelativeRect:Bw,getDocumentElement:Qr,getClippingRect:Hw,getOffsetParent:Du,getElementRects:Gw,getClientRects:$w,getDimensions:Ww,getScale:io,isElement:Ur,isRTL:Kw};function Bu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Yw(e,t){let r=null,n;const o=Qr(e);function s(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function i(a,d){a===void 0&&(a=!1),d===void 0&&(d=1),s();const u=e.getBoundingClientRect(),{left:l,top:f,width:p,height:m}=u;if(a||t(),!p||!m)return;const g=Ks(f),h=Ks(o.clientWidth-(l+p)),y=Ks(o.clientHeight-(f+m)),w=Ks(l),x={rootMargin:-g+"px "+-h+"px "+-y+"px "+-w+"px",threshold:wr(0,Cn(1,d))||1};let E=!0;function P(k){const N=k[0].intersectionRatio;if(N!==d){if(!E)return i();N?i(!1,N):n=setTimeout(()=>{i(!1,1e-7)},1e3)}N===1&&!Bu(u,e.getBoundingClientRect())&&i(),E=!1}try{r=new IntersectionObserver(P,{...x,root:o.ownerDocument})}catch{r=new IntersectionObserver(P,x)}r.observe(e)}return i(!0),s}function Xw(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:d=!1}=n,u=Qa(e),l=o||s?[...u?Xo(u):[],...t?Xo(t):[]]:[];l.forEach(w=>{o&&w.addEventListener("scroll",r,{passive:!0}),s&&w.addEventListener("resize",r)});const f=u&&a?Yw(u,r):null;let p=-1,m=null;i&&(m=new ResizeObserver(w=>{let[v]=w;v&&v.target===u&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=m)==null||x.observe(t)})),r()}),u&&!d&&m.observe(u),t&&m.observe(t));let g,h=d?jn(e):null;d&&y();function y(){const w=jn(e);h&&!Bu(h,w)&&r(),h=w,g=requestAnimationFrame(y)}return r(),()=>{var w;l.forEach(v=>{o&&v.removeEventListener("scroll",r),s&&v.removeEventListener("resize",r)}),f?.(),(w=m)==null||w.disconnect(),m=null,d&&cancelAnimationFrame(g)}}const Jw=_w,Qw=kw,Zw=Cw,eS=Fw,tS=Ew,$u=Aw,rS=Tw,nS=(e,t,r)=>{const n=new Map,o={platform:qw,...r},s={...o.platform,_c:n};return xw(e,t,{...o,platform:s})};var oS=typeof document<"u",sS=function(){},ei=oS?S.useLayoutEffect:sS;function ti(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(!ti(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)&&!ti(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function ju(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function zu(e,t){const r=ju(e);return Math.round(t*r)/r}function el(e){const t=b.useRef(e);return ei(()=>{t.current=e}),t}function iS(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:d,open:u}=e,[l,f]=b.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=b.useState(n);ti(p,n)||m(n);const[g,h]=b.useState(null),[y,w]=b.useState(null),v=b.useCallback(L=>{L!==k.current&&(k.current=L,h(L))},[]),x=b.useCallback(L=>{L!==N.current&&(N.current=L,w(L))},[]),E=s||g,P=i||y,k=b.useRef(null),N=b.useRef(null),C=b.useRef(l),A=d!=null,I=el(d),T=el(o),W=el(u),X=b.useCallback(()=>{if(!k.current||!N.current)return;const L={placement:t,strategy:r,middleware:p};T.current&&(L.platform=T.current),nS(k.current,N.current,L).then(U=>{const $={...U,isPositioned:W.current!==!1};O.current&&!ti(C.current,$)&&(C.current=$,Es.flushSync(()=>{f($)}))})},[p,t,r,T,W]);ei(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[u]);const O=b.useRef(!1);ei(()=>(O.current=!0,()=>{O.current=!1}),[]),ei(()=>{if(E&&(k.current=E),P&&(N.current=P),E&&P){if(I.current)return I.current(E,P,X);X()}},[E,P,X,I,A]);const j=b.useMemo(()=>({reference:k,floating:N,setReference:v,setFloating:x}),[v,x]),M=b.useMemo(()=>({reference:E,floating:P}),[E,P]),D=b.useMemo(()=>{const L={position:r,left:0,top:0};if(!M.floating)return L;const U=zu(M.floating,l.x),$=zu(M.floating,l.y);return a?{...L,transform:"translate("+U+"px, "+$+"px)",...ju(M.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:U,top:$}},[r,a,M.floating,l.x,l.y]);return b.useMemo(()=>({...l,update:X,refs:j,elements:M,floatingStyles:D}),[l,X,j,M,D])}const aS=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?$u({element:n.current,padding:o}).fn(r):{}:n?$u({element:n,padding:o}).fn(r):{}}}},lS=(e,t)=>{const r=Jw(e);return{name:r.name,fn:r.fn,options:[e,t]}},cS=(e,t)=>{const r=Qw(e);return{name:r.name,fn:r.fn,options:[e,t]}},dS=(e,t)=>({fn:rS(e).fn,options:[e,t]}),uS=(e,t)=>{const r=Zw(e);return{name:r.name,fn:r.fn,options:[e,t]}},fS=(e,t)=>{const r=eS(e);return{name:r.name,fn:r.fn,options:[e,t]}},pS=(e,t)=>{const r=tS(e);return{name:r.name,fn:r.fn,options:[e,t]}},mS=(e,t)=>{const r=aS(e);return{name:r.name,fn:r.fn,options:[e,t]}};var hS="Arrow",Uu=b.forwardRef((e,t)=>{const{children:r,width:n=10,height:o=5,...s}=e;return c.jsx(Be.svg,{...s,ref:t,width:n,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Uu.displayName=hS;var gS=Uu;function Jo(e){const[t,r]=b.useState(void 0);return Qt(()=>{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 d=s.borderBoxSize,u=Array.isArray(d)?d[0]:d;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 tl="Popper",[Vu,ri]=vr(tl),[yS,Hu]=Vu(tl),Wu=e=>{const{__scopePopper:t,children:r}=e,[n,o]=b.useState(null);return c.jsx(yS,{scope:t,anchor:n,onAnchorChange:o,children:r})};Wu.displayName=tl;var Ru="PopperAnchor",Gu=b.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...o}=e,s=Hu(Ru,r),i=b.useRef(null),a=Ze(t,i),d=b.useRef(null);return b.useEffect(()=>{const u=d.current;d.current=n?.current||i.current,u!==d.current&&s.onAnchorChange(d.current)}),n?null:c.jsx(Be.div,{...o,ref:a})});Gu.displayName=Ru;var rl="PopperContent",[bS,vS]=Vu(rl),Ku=b.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:l=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...h}=e,y=Hu(rl,r),[w,v]=b.useState(null),x=Ze(t,G=>v(G)),[E,P]=b.useState(null),k=Jo(E),N=k?.width??0,C=k?.height??0,A=n+(s!=="center"?"-"+s:""),I=typeof l=="number"?l:{top:0,right:0,bottom:0,left:0,...l},T=Array.isArray(u)?u:[u],W=T.length>0,X={padding:I,boundary:T.filter(SS),altBoundary:W},{refs:O,floatingStyles:j,placement:M,isPositioned:D,middlewareData:L}=iS({strategy:"fixed",placement:A,whileElementsMounted:(...G)=>Xw(...G,{animationFrame:m==="always"}),elements:{reference:y.anchor},middleware:[lS({mainAxis:o+C,alignmentAxis:i}),d&&cS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?dS():void 0,...X}),d&&uS({...X}),fS({...X,apply:({elements:G,rects:ee,availableWidth:Pe,availableHeight:oe})=>{const{width:re,height:be}=ee.reference,de=G.floating.style;de.setProperty("--radix-popper-available-width",`${Pe}px`),de.setProperty("--radix-popper-available-height",`${oe}px`),de.setProperty("--radix-popper-anchor-width",`${re}px`),de.setProperty("--radix-popper-anchor-height",`${be}px`)}}),E&&mS({element:E,padding:a}),xS({arrowWidth:N,arrowHeight:C}),p&&pS({strategy:"referenceHidden",...X})]}),[U,$]=Xu(M),ie=ar(g);Qt(()=>{D&&ie?.()},[D,ie]);const V=L.arrow?.x,K=L.arrow?.y,J=L.arrow?.centerOffset!==0,[ce,ne]=b.useState();return Qt(()=>{w&&ne(window.getComputedStyle(w).zIndex)},[w]),c.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...j,transform:D?j.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ce,"--radix-popper-transform-origin":[L.transformOrigin?.x,L.transformOrigin?.y].join(" "),...L.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(bS,{scope:r,placedSide:U,onArrowChange:P,arrowX:V,arrowY:K,shouldHideArrow:J,children:c.jsx(Be.div,{"data-side":U,"data-align":$,...h,ref:x,style:{...h.style,animation:D?void 0:"none"}})})})});Ku.displayName=rl;var qu="PopperArrow",wS={top:"bottom",right:"left",bottom:"top",left:"right"},Yu=b.forwardRef(function(t,r){const{__scopePopper:n,...o}=t,s=vS(qu,n),i=wS[s.placedSide];return c.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:c.jsx(gS,{...o,ref:r,style:{...o.style,display:"block"}})})});Yu.displayName=qu;function SS(e){return e!==null}var xS=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,d=i?0:e.arrowHeight,[u,l]=Xu(r),f={start:"0%",center:"50%",end:"100%"}[l],p=(o.arrow?.x??0)+a/2,m=(o.arrow?.y??0)+d/2;let g="",h="";return u==="bottom"?(g=i?f:`${p}px`,h=`${-d}px`):u==="top"?(g=i?f:`${p}px`,h=`${n.floating.height+d}px`):u==="right"?(g=`${-d}px`,h=i?f:`${m}px`):u==="left"&&(g=`${n.floating.width+d}px`,h=i?f:`${m}px`),{data:{x:g,y:h}}}});function Xu(e){const[t,r="center"]=e.split("-");return[t,r]}var Ju=Wu,nl=Gu,Qu=Ku,Zu=Yu,AS="Portal",ni=b.forwardRef((e,t)=>{const{container:r,...n}=e,[o,s]=b.useState(!1);Qt(()=>s(!0),[]);const i=r||o&&globalThis?.document?.body;return i?qc.createPortal(c.jsx(Be.div,{...n,ref:t}),i):null});ni.displayName=AS;function CS(e){const t=ES(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(_S);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function ES(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=TS(o),a=kS(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(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 NS=Symbol("radix.slottable");function _S(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===NS}function kS(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 d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function TS(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 FS=b[" useInsertionEffect ".trim().toString()]||Qt;function Zr({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[o,s,i]=PS({defaultProp:t,onChange:r}),a=e!==void 0,d=a?e:o;{const l=b.useRef(e!==void 0);b.useEffect(()=>{const f=l.current;f!==a&&console.warn(`${n} is changing from ${f?"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.`),l.current=a},[a,n])}const u=b.useCallback(l=>{if(a){const f=OS(l)?l(e):l;f!==e&&i.current?.(f)}else s(l)},[a,e,s,i]);return[d,u]}function PS({defaultProp:e,onChange:t}){const[r,n]=b.useState(e),o=b.useRef(r),s=b.useRef(t);return FS(()=>{s.current=t},[t]),b.useEffect(()=>{o.current!==r&&(s.current?.(r),o.current=r)},[r,o]),[r,n,s]}function OS(e){return typeof e=="function"}function Qo(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 ef=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"}),IS="VisuallyHidden",MS=b.forwardRef((e,t)=>c.jsx(Be.span,{...e,ref:t,style:{...ef,...e.style}}));MS.displayName=IS;var LS=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ao=new WeakMap,oi=new WeakMap,si={},ol=0,tf=function(e){return e&&(e.host||tf(e.parentNode))},DS=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=tf(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})},BS=function(e,t,r,n){var o=DS(t,Array.isArray(e)?e:[e]);si[r]||(si[r]=new WeakMap);var s=si[r],i=[],a=new Set,d=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var l=function(f){!f||d.has(f)||Array.prototype.forEach.call(f.children,function(p){if(a.has(p))l(p);else try{var m=p.getAttribute(n),g=m!==null&&m!=="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&&g&&oi.set(p,!0),y===1&&p.setAttribute(r,"true"),g||p.setAttribute(n,"true")}catch(w){console.error("aria-hidden: cannot operate on ",p,w)}})};return l(t),a.clear(),ol++,function(){i.forEach(function(f){var p=ao.get(f)-1,m=s.get(f)-1;ao.set(f,p),s.set(f,m),p||(oi.has(f)||f.removeAttribute(n),oi.delete(f)),m||f.removeAttribute(r)}),ol--,ol||(ao=new WeakMap,ao=new WeakMap,oi=new WeakMap,si={})}},sl=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),o=LS(e);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live], script"))),BS(n,o,r,"aria-hidden")):function(){return null}},en=function(){return en=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},en.apply(this,arguments)};function rf(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 $S(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 ii="right-scroll-bar-position",ai="width-before-scroll-bar",jS="with-scroll-bars-hidden",zS="--removed-body-scroll-bar-size";function il(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function US(e,t){var r=S.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 VS=typeof window<"u"?b.useLayoutEffect:b.useEffect,nf=new WeakMap;function HS(e,t){var r=US(null,function(n){return e.forEach(function(o){return il(o,n)})});return VS(function(){var n=nf.get(r);if(n){var o=new Set(n),s=new Set(e),i=r.current;o.forEach(function(a){s.has(a)||il(a,null)}),s.forEach(function(a){o.has(a)||il(a,i)})}nf.set(r,e)},[e]),r}function WS(e){return e}function RS(e,t){t===void 0&&(t=WS);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 d=function(){var l=i;i=[],l.forEach(s)},u=function(){return Promise.resolve().then(d)};u(),r={push:function(l){i.push(l),u()},filter:function(l){return i=i.filter(l),r}}}};return o}function GS(e){e===void 0&&(e={});var t=RS(null);return t.options=en({async:!0,ssr:!1},e),t}var of=function(e){var t=e.sideCar,r=rf(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,en({},r))};of.isSideCarExport=!0;function KS(e,t){return e.useMedium(t),of}var sf=GS(),al=function(){},li=b.forwardRef(function(e,t){var r=b.useRef(null),n=b.useState({onScrollCapture:al,onWheelCapture:al,onTouchMoveCapture:al}),o=n[0],s=n[1],i=e.forwardProps,a=e.children,d=e.className,u=e.removeScrollBar,l=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,g=e.noIsolation,h=e.inert,y=e.allowPinchZoom,w=e.as,v=w===void 0?"div":w,x=e.gapMode,E=rf(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=p,k=HS([r,t]),N=en(en({},E),o);return b.createElement(b.Fragment,null,l&&b.createElement(P,{sideCar:sf,removeScrollBar:u,shards:f,noRelative:m,noIsolation:g,inert:h,setCallbacks:s,allowPinchZoom:!!y,lockRef:r,gapMode:x}),i?b.cloneElement(b.Children.only(a),en(en({},N),{ref:k})):b.createElement(v,en({},N,{className:d,ref:k}),a))});li.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},li.classNames={fullWidth:ai,zeroRight:ii};var qS=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function YS(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=qS();return t&&e.setAttribute("nonce",t),e}function XS(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function JS(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var QS=function(){var e=0,t=null;return{add:function(r){e==0&&(t=YS())&&(XS(t,r),JS(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},ZS=function(){var e=QS();return function(t,r){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},af=function(){var e=ZS(),t=function(r){var n=r.styles,o=r.dynamic;return e(n,o),null};return t},ex={left:0,top:0,right:0,gap:0},ll=function(e){return parseInt(e||"",10)||0},tx=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[ll(r),ll(n),ll(o)]},rx=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ex;var t=tx(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])}},nx=af(),lo="data-scroll-locked",ox=function(e,t,r,n){var o=e.left,s=e.top,i=e.right,a=e.gap;return r===void 0&&(r="margin"),`
|
|
1
|
+
(function(ge,S){typeof exports=="object"&&typeof module<"u"?S(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"],S):(ge=typeof globalThis<"u"?globalThis:ge||self,S(ge.FormBuilderRenderer={},ge.React,ge.jsxRuntime,ge.ReactRouterDOM,ge.ReactDOM,ge.Sonner,ge.ReactQuery))})(this,(function(ge,S,c,ha,qc,$t,gn){"use strict";function Yc(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=Yc(S),Es=Yc(qc),ga="iq-fbr",In="95px";function Ns(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:In}}function _s(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 Xc(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=Xc(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Jc(){for(var e,t,r=0,n="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=Xc(e))&&(n&&(n+=" "),n+=t);return n}const Py=(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},Oy=(e,t)=>({classGroupId:e,validator:t}),Qc=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),ks="-",Zc=[],Iy="arbitrary..",My=e=>{const t=Dy(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Ly(i);const a=i.split(ks),d=a[0]===""&&a.length>1?1:0;return ed(a,d,t)},getConflictingClassGroupIds:(i,a)=>{if(a){const d=n[i],u=r[i];return d?u?Py(u,d):d:u||Zc}return r[i]||Zc}}},ed=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const o=e[t],s=r.nextPart.get(o);if(s){const u=ed(e,t+1,s);if(u)return u}const i=r.validators;if(i===null)return;const a=t===0?e.join(ks):e.slice(t).join(ks),d=i.length;for(let u=0;u<d;u++){const l=i[u];if(l.validator(a))return l.classGroupId}},Ly=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?Iy+n:void 0})(),Dy=e=>{const{theme:t,classGroups:r}=e;return By(r,t)},By=(e,t)=>{const r=Qc();for(const n in e){const o=e[n];ya(o,r,n,t)}return r},ya=(e,t,r,n)=>{const o=e.length;for(let s=0;s<o;s++){const i=e[s];$y(i,t,r,n)}},$y=(e,t,r,n)=>{if(typeof e=="string"){jy(e,t,r);return}if(typeof e=="function"){zy(e,t,r,n);return}Uy(e,t,r,n)},jy=(e,t,r)=>{const n=e===""?t:td(t,e);n.classGroupId=r},zy=(e,t,r,n)=>{if(Vy(e)){ya(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(Oy(r,e))},Uy=(e,t,r,n)=>{const o=Object.entries(e),s=o.length;for(let i=0;i<s;i++){const[a,d]=o[i];ya(d,td(t,a),r,n)}},td=(e,t)=>{let r=e;const n=t.split(ks),o=n.length;for(let s=0;s<o;s++){const i=n[s];let a=r.nextPart.get(i);a||(a=Qc(),r.nextPart.set(i,a)),r=a}return r},Vy=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Hy=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)}}},ba="!",rd=":",Wy=[],nd=(e,t,r,n,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:o}),Ry=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=o=>{const s=[];let i=0,a=0,d=0,u;const l=o.length;for(let h=0;h<l;h++){const y=o[h];if(i===0&&a===0){if(y===rd){s.push(o.slice(d,h)),d=h+1;continue}if(y==="/"){u=h;continue}}y==="["?i++:y==="]"?i--:y==="("?a++:y===")"&&a--}const f=s.length===0?o:o.slice(d);let p=f,m=!1;f.endsWith(ba)?(p=f.slice(0,-1),m=!0):f.startsWith(ba)&&(p=f.slice(1),m=!0);const g=u&&u>d?u-d:void 0;return nd(s,m,p,g)};if(t){const o=t+rd,s=n;n=i=>i.startsWith(o)?s(i.slice(o.length)):nd(Wy,!1,i,void 0,!0)}if(r){const o=n;n=s=>r({className:s,parseClassName:o})}return n},Gy=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]==="[",d=t.has(i);a||d?(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}},Ky=e=>({cache:Hy(e.cacheSize),parseClassName:Ry(e),sortModifiers:Gy(e),...My(e)}),qy=/\s+/,Yy=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:o,sortModifiers:s}=t,i=[],a=e.trim().split(qy);let d="";for(let u=a.length-1;u>=0;u-=1){const l=a[u],{isExternal:f,modifiers:p,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:h}=r(l);if(f){d=l+(d.length>0?" "+d:d);continue}let y=!!h,w=n(y?g.substring(0,h):g);if(!w){if(!y){d=l+(d.length>0?" "+d:d);continue}if(w=n(g),!w){d=l+(d.length>0?" "+d:d);continue}y=!1}const v=p.length===0?"":p.length===1?p[0]:s(p).join(":"),x=m?v+ba:v,E=x+w;if(i.indexOf(E)>-1)continue;i.push(E);const P=o(w,y);for(let _=0;_<P.length;++_){const N=P[_];i.push(x+N)}d=l+(d.length>0?" "+d:d)}return d},Xy=(...e)=>{let t=0,r,n,o="";for(;t<e.length;)(r=e[t++])&&(n=od(r))&&(o&&(o+=" "),o+=n);return o},od=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=od(e[n]))&&(r&&(r+=" "),r+=t);return r},Jy=(e,...t)=>{let r,n,o,s;const i=d=>{const u=t.reduce((l,f)=>f(l),e());return r=Ky(u),n=r.cache.get,o=r.cache.set,s=a,a(d)},a=d=>{const u=n(d);if(u)return u;const l=Yy(d,r);return o(d,l),l};return s=i,(...d)=>s(Xy(...d))},Qy=[],Rt=e=>{const t=r=>r[e]||Qy;return t.isThemeGetter=!0,t},sd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,id=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Zy=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,eb=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,tb=/\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$/,rb=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,nb=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ob=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,yn=e=>Zy.test(e),it=e=>!!e&&!Number.isNaN(Number(e)),bn=e=>!!e&&Number.isInteger(Number(e)),va=e=>e.endsWith("%")&&it(e.slice(0,-1)),nn=e=>eb.test(e),ad=()=>!0,sb=e=>tb.test(e)&&!rb.test(e),wa=()=>!1,ib=e=>nb.test(e),ab=e=>ob.test(e),lb=e=>!_e(e)&&!ke(e),cb=e=>vn(e,pd,wa),_e=e=>sd.test(e),Mn=e=>vn(e,md,sb),ld=e=>vn(e,yb,it),db=e=>vn(e,gd,ad),ub=e=>vn(e,hd,wa),cd=e=>vn(e,ud,wa),fb=e=>vn(e,fd,ab),Ts=e=>vn(e,yd,ib),ke=e=>id.test(e),Lo=e=>Ln(e,md),pb=e=>Ln(e,hd),dd=e=>Ln(e,ud),mb=e=>Ln(e,pd),hb=e=>Ln(e,fd),Fs=e=>Ln(e,yd,!0),gb=e=>Ln(e,gd,!0),vn=(e,t,r)=>{const n=sd.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Ln=(e,t,r=!1)=>{const n=id.exec(e);return n?n[1]?t(n[1]):r:!1},ud=e=>e==="position"||e==="percentage",fd=e=>e==="image"||e==="url",pd=e=>e==="length"||e==="size"||e==="bg-size",md=e=>e==="length",yb=e=>e==="number",hd=e=>e==="family-name",gd=e=>e==="number"||e==="weight",yd=e=>e==="shadow",bb=Jy(()=>{const e=Rt("color"),t=Rt("font"),r=Rt("text"),n=Rt("font-weight"),o=Rt("tracking"),s=Rt("leading"),i=Rt("breakpoint"),a=Rt("container"),d=Rt("spacing"),u=Rt("radius"),l=Rt("shadow"),f=Rt("inset-shadow"),p=Rt("text-shadow"),m=Rt("drop-shadow"),g=Rt("blur"),h=Rt("perspective"),y=Rt("aspect"),w=Rt("ease"),v=Rt("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...E(),ke,_e],_=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],C=()=>[ke,_e,d],A=()=>[yn,"full","auto",...C()],I=()=>[bn,"none","subgrid",ke,_e],T=()=>["auto",{span:["full",bn,ke,_e]},bn,ke,_e],W=()=>[bn,"auto",ke,_e],X=()=>["auto","min","max","fr",ke,_e],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],j=()=>["start","end","center","stretch","center-safe","end-safe"],M=()=>["auto",...C()],D=()=>[yn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...C()],L=()=>[yn,"screen","full","dvw","lvw","svw","min","max","fit",...C()],U=()=>[yn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...C()],$=()=>[e,ke,_e],ie=()=>[...E(),dd,cd,{position:[ke,_e]}],V=()=>["no-repeat",{repeat:["","x","y","space","round"]}],K=()=>["auto","cover","contain",mb,cb,{size:[ke,_e]}],J=()=>[va,Lo,Mn],ce=()=>["","none","full",u,ke,_e],ne=()=>["",it,Lo,Mn],G=()=>["solid","dashed","dotted","double"],ee=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Pe=()=>[it,va,dd,cd],oe=()=>["","none",g,ke,_e],re=()=>["none",it,ke,_e],be=()=>["none",it,ke,_e],de=()=>[it,ke,_e],ot=()=>[yn,"full",...C()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[nn],breakpoint:[nn],color:[ad],container:[nn],"drop-shadow":[nn],ease:["in","out","in-out"],font:[lb],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[nn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[nn],shadow:[nn],spacing:["px",it],text:[nn],"text-shadow":[nn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",yn,_e,ke,y]}],container:["container"],columns:[{columns:[it,_e,ke,a]}],"break-after":[{"break-after":x()}],"break-before":[{"break-before":x()}],"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:P()}],overflow:[{overflow:_()}],"overflow-x":[{"overflow-x":_()}],"overflow-y":[{"overflow-y":_()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{"inset-s":A(),start:A()}],end:[{"inset-e":A(),end:A()}],"inset-bs":[{"inset-bs":A()}],"inset-be":[{"inset-be":A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[bn,"auto",ke,_e]}],basis:[{basis:[yn,"full","auto",a,...C()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[it,yn,"auto","initial","none",_e]}],grow:[{grow:["",it,ke,_e]}],shrink:[{shrink:["",it,ke,_e]}],order:[{order:[bn,"first","last","none",ke,_e]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:T()}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:T()}],"row-start":[{"row-start":W()}],"row-end":[{"row-end":W()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":X()}],"auto-rows":[{"auto-rows":X()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...j(),"normal"]}],"justify-self":[{"justify-self":["auto",...j()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...j(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...j(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...j(),"baseline"]}],"place-self":[{"place-self":["auto",...j()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pbs:[{pbs:C()}],pbe:[{pbe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":C()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":C()}],"space-y-reverse":["space-y-reverse"],size:[{size:D()}],"inline-size":[{inline:["auto",...L()]}],"min-inline-size":[{"min-inline":["auto",...L()]}],"max-inline-size":[{"max-inline":["none",...L()]}],"block-size":[{block:["auto",...U()]}],"min-block-size":[{"min-block":["auto",...U()]}],"max-block-size":[{"max-block":["none",...U()]}],w:[{w:[a,"screen",...D()]}],"min-w":[{"min-w":[a,"screen","none",...D()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...D()]}],h:[{h:["screen","lh",...D()]}],"min-h":[{"min-h":["screen","lh","none",...D()]}],"max-h":[{"max-h":["screen","lh",...D()]}],"font-size":[{text:["base",r,Lo,Mn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,gb,db]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",va,_e]}],"font-family":[{font:[pb,ub,t]}],"font-features":[{"font-features":[_e]}],"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,ke,_e]}],"line-clamp":[{"line-clamp":[it,"none",ke,ld]}],leading:[{leading:[s,...C()]}],"list-image":[{"list-image":["none",ke,_e]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ke,_e]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:$()}],"text-color":[{text:$()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[it,"from-font","auto",ke,Mn]}],"text-decoration-color":[{decoration:$()}],"underline-offset":[{"underline-offset":[it,"auto",ke,_e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ke,_e]}],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",ke,_e]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ie()}],"bg-repeat":[{bg:V()}],"bg-size":[{bg:K()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},bn,ke,_e],radial:["",ke,_e],conic:[bn,ke,_e]},hb,fb]}],"bg-color":[{bg:$()}],"gradient-from-pos":[{from:J()}],"gradient-via-pos":[{via:J()}],"gradient-to-pos":[{to:J()}],"gradient-from":[{from:$()}],"gradient-via":[{via:$()}],"gradient-to":[{to:$()}],rounded:[{rounded:ce()}],"rounded-s":[{"rounded-s":ce()}],"rounded-e":[{"rounded-e":ce()}],"rounded-t":[{"rounded-t":ce()}],"rounded-r":[{"rounded-r":ce()}],"rounded-b":[{"rounded-b":ce()}],"rounded-l":[{"rounded-l":ce()}],"rounded-ss":[{"rounded-ss":ce()}],"rounded-se":[{"rounded-se":ce()}],"rounded-ee":[{"rounded-ee":ce()}],"rounded-es":[{"rounded-es":ce()}],"rounded-tl":[{"rounded-tl":ce()}],"rounded-tr":[{"rounded-tr":ce()}],"rounded-br":[{"rounded-br":ce()}],"rounded-bl":[{"rounded-bl":ce()}],"border-w":[{border:ne()}],"border-w-x":[{"border-x":ne()}],"border-w-y":[{"border-y":ne()}],"border-w-s":[{"border-s":ne()}],"border-w-e":[{"border-e":ne()}],"border-w-bs":[{"border-bs":ne()}],"border-w-be":[{"border-be":ne()}],"border-w-t":[{"border-t":ne()}],"border-w-r":[{"border-r":ne()}],"border-w-b":[{"border-b":ne()}],"border-w-l":[{"border-l":ne()}],"divide-x":[{"divide-x":ne()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ne()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"hidden","none"]}],"border-color":[{border:$()}],"border-color-x":[{"border-x":$()}],"border-color-y":[{"border-y":$()}],"border-color-s":[{"border-s":$()}],"border-color-e":[{"border-e":$()}],"border-color-bs":[{"border-bs":$()}],"border-color-be":[{"border-be":$()}],"border-color-t":[{"border-t":$()}],"border-color-r":[{"border-r":$()}],"border-color-b":[{"border-b":$()}],"border-color-l":[{"border-l":$()}],"divide-color":[{divide:$()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[it,ke,_e]}],"outline-w":[{outline:["",it,Lo,Mn]}],"outline-color":[{outline:$()}],shadow:[{shadow:["","none",l,Fs,Ts]}],"shadow-color":[{shadow:$()}],"inset-shadow":[{"inset-shadow":["none",f,Fs,Ts]}],"inset-shadow-color":[{"inset-shadow":$()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:$()}],"ring-offset-w":[{"ring-offset":[it,Mn]}],"ring-offset-color":[{"ring-offset":$()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":$()}],"text-shadow":[{"text-shadow":["none",p,Fs,Ts]}],"text-shadow-color":[{"text-shadow":$()}],opacity:[{opacity:[it,ke,_e]}],"mix-blend":[{"mix-blend":[...ee(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ee()}],"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":[it]}],"mask-image-linear-from-pos":[{"mask-linear-from":Pe()}],"mask-image-linear-to-pos":[{"mask-linear-to":Pe()}],"mask-image-linear-from-color":[{"mask-linear-from":$()}],"mask-image-linear-to-color":[{"mask-linear-to":$()}],"mask-image-t-from-pos":[{"mask-t-from":Pe()}],"mask-image-t-to-pos":[{"mask-t-to":Pe()}],"mask-image-t-from-color":[{"mask-t-from":$()}],"mask-image-t-to-color":[{"mask-t-to":$()}],"mask-image-r-from-pos":[{"mask-r-from":Pe()}],"mask-image-r-to-pos":[{"mask-r-to":Pe()}],"mask-image-r-from-color":[{"mask-r-from":$()}],"mask-image-r-to-color":[{"mask-r-to":$()}],"mask-image-b-from-pos":[{"mask-b-from":Pe()}],"mask-image-b-to-pos":[{"mask-b-to":Pe()}],"mask-image-b-from-color":[{"mask-b-from":$()}],"mask-image-b-to-color":[{"mask-b-to":$()}],"mask-image-l-from-pos":[{"mask-l-from":Pe()}],"mask-image-l-to-pos":[{"mask-l-to":Pe()}],"mask-image-l-from-color":[{"mask-l-from":$()}],"mask-image-l-to-color":[{"mask-l-to":$()}],"mask-image-x-from-pos":[{"mask-x-from":Pe()}],"mask-image-x-to-pos":[{"mask-x-to":Pe()}],"mask-image-x-from-color":[{"mask-x-from":$()}],"mask-image-x-to-color":[{"mask-x-to":$()}],"mask-image-y-from-pos":[{"mask-y-from":Pe()}],"mask-image-y-to-pos":[{"mask-y-to":Pe()}],"mask-image-y-from-color":[{"mask-y-from":$()}],"mask-image-y-to-color":[{"mask-y-to":$()}],"mask-image-radial":[{"mask-radial":[ke,_e]}],"mask-image-radial-from-pos":[{"mask-radial-from":Pe()}],"mask-image-radial-to-pos":[{"mask-radial-to":Pe()}],"mask-image-radial-from-color":[{"mask-radial-from":$()}],"mask-image-radial-to-color":[{"mask-radial-to":$()}],"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":E()}],"mask-image-conic-pos":[{"mask-conic":[it]}],"mask-image-conic-from-pos":[{"mask-conic-from":Pe()}],"mask-image-conic-to-pos":[{"mask-conic-to":Pe()}],"mask-image-conic-from-color":[{"mask-conic-from":$()}],"mask-image-conic-to-color":[{"mask-conic-to":$()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:V()}],"mask-size":[{mask:K()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ke,_e]}],filter:[{filter:["","none",ke,_e]}],blur:[{blur:oe()}],brightness:[{brightness:[it,ke,_e]}],contrast:[{contrast:[it,ke,_e]}],"drop-shadow":[{"drop-shadow":["","none",m,Fs,Ts]}],"drop-shadow-color":[{"drop-shadow":$()}],grayscale:[{grayscale:["",it,ke,_e]}],"hue-rotate":[{"hue-rotate":[it,ke,_e]}],invert:[{invert:["",it,ke,_e]}],saturate:[{saturate:[it,ke,_e]}],sepia:[{sepia:["",it,ke,_e]}],"backdrop-filter":[{"backdrop-filter":["","none",ke,_e]}],"backdrop-blur":[{"backdrop-blur":oe()}],"backdrop-brightness":[{"backdrop-brightness":[it,ke,_e]}],"backdrop-contrast":[{"backdrop-contrast":[it,ke,_e]}],"backdrop-grayscale":[{"backdrop-grayscale":["",it,ke,_e]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[it,ke,_e]}],"backdrop-invert":[{"backdrop-invert":["",it,ke,_e]}],"backdrop-opacity":[{"backdrop-opacity":[it,ke,_e]}],"backdrop-saturate":[{"backdrop-saturate":[it,ke,_e]}],"backdrop-sepia":[{"backdrop-sepia":["",it,ke,_e]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ke,_e]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[it,"initial",ke,_e]}],ease:[{ease:["linear","initial",w,ke,_e]}],delay:[{delay:[it,ke,_e]}],animate:[{animate:["none",v,ke,_e]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,ke,_e]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:re()}],"rotate-x":[{"rotate-x":re()}],"rotate-y":[{"rotate-y":re()}],"rotate-z":[{"rotate-z":re()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":["scale-3d"],skew:[{skew:de()}],"skew-x":[{"skew-x":de()}],"skew-y":[{"skew-y":de()}],transform:[{transform:[ke,_e,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ot()}],"translate-x":[{"translate-x":ot()}],"translate-y":[{"translate-y":ot()}],"translate-z":[{"translate-z":ot()}],"translate-none":["translate-none"],accent:[{accent:$()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:$()}],"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",ke,_e]}],"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":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mbs":[{"scroll-mbs":C()}],"scroll-mbe":[{"scroll-mbe":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pbs":[{"scroll-pbs":C()}],"scroll-pbe":[{"scroll-pbe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"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",ke,_e]}],fill:[{fill:["none",...$()]}],"stroke-w":[{stroke:[it,Lo,Mn,ld]}],stroke:[{stroke:["none",...$()]}],"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 B(...e){return bb(Jc(e))}const vb=["richtext","multiselect","radio","checkboxgroup","signature"],wb=3;function Do(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(wb,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 vb.includes(e.type)?Math.max(t,2):t}function bd(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 Bo(e){const t=e?.size??"md",r=e?.variant??"default";return B(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 vd(e){const t=e?.size??"md",r=e?.variant??"default";return B(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 Sb(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 xb(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 Ab(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 Ps(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 Sa(e){const t=Ps(e);return{width:t>=100?"100%":`${t}%`,maxWidth:"100%"}}function Cb(e){return Sa(e)}function xa(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"||t==="stretch"?t:null}function Aa(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=xa(e.horizontalAlign);if(t)return t;const r=xa(e.contentAlign);if(r)return r;const n=xa(e.cellAlign);return n||"start"}function $o(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 Os(e){switch(e){case"center":return"items-center";case"end":return"items-end";case"stretch":return"items-stretch";default:return"items-start"}}function Ca(e){switch(e){case"center":return"justify-center";case"end":return"justify-end";case"stretch":return"justify-stretch";default:return"justify-start"}}function jo(e){const t=Aa(e.appearance?.contentVerticalAlign);if(t!==null)switch(t){case"center":return"justify-center";case"end":return"justify-end";default:return"justify-start"}return Ca(Ea(e))}const Eb=jo;function Is(e){if(e.type==="billingGrid"||e.type==="table"||Do(e)>1)return!0;const t=Aa(e.appearance?.contentVerticalAlign);if(t==="center"||t==="end")return!1;if(t==="start")return!0;const r=Ea(e);return r!=="center"&&r!=="end"}function wd(e){const t=e[0];if(!t)return Na(void 0);if(e.length===1)return Na(t);const r=Fr(t.appearance);return B("flex flex-col min-h-0 h-full w-full",Os(r),"justify-start")}function Sd(e){const t=Fr(e),r=$o(e);return B("flex flex-col min-h-0 h-full w-full",Os(t),Ca(r))}function xd(e){if(Ps(e)>=100)return"";const r=Fr(e);return r==="center"?"mx-auto":r==="end"?"ml-auto":""}function Ad(e){if(Ps(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 Cd(e){return e?e.widthMode==="full"||e.widthMode==="percent"||typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent):!1}function to(e){return(e.type==="button"||e.type==="editButton")&&!Cd(e.appearance)}function Ed(e){return to(e)?Fr(e.appearance)==="stretch"?{width:"100%",maxWidth:"100%",minWidth:0}:{width:"auto",maxWidth:"100%"}:Sa(e.appearance)}function Nd(e){return Ed(e)}function _d(e){if(to(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 Ad(e.appearance)}function kd(e){return e?e.verticalAlign!=null||e.cellJustify!=null:!1}function Ea(e){return e.type!=="button"&&e.type!=="editButton"||kd(e.appearance)?$o(e.appearance):"start"}function Na(e){if(!e)return Sd(void 0);const t=Fr(e.appearance);return B("flex flex-col min-h-0 h-full w-full",Os(t),jo(e))}function Nb(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 B(Os(Fr(o)),Ca($o(o)))}const _a=S.createContext({gridStretch:!1});function zo(){return S.useContext(_a)}const Td=e=>{let t;const r=new Set,n=(u,l)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const p=t;t=l??(typeof f!="object"||f===null)?f:Object.assign({},t,f),r.forEach(m=>m(t,p))}},o=()=>t,a={setState:n,getState:o,getInitialState:()=>d,subscribe:u=>(r.add(u),()=>r.delete(u))},d=t=e(n,o,a);return a},_b=(e=>e?Td(e):Td),kb=e=>e;function Tb(e,t=kb){const r=S.useSyncExternalStore(e.subscribe,S.useCallback(()=>t(e.getState()),[e,t]),S.useCallback(()=>t(e.getInitialState()),[e,t]));return S.useDebugValue(r),r}const Fd=e=>{const t=_b(e),r=n=>Tb(t,n);return Object.assign(r,t),r},Pd=(e=>e?Fd(e):Fd),Fb=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Pb=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,Ob=/^\+?[\d\s-()]{10,}$/,Ib={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:Fb.test(e),url:e=>typeof e!="string"||!e?!0:Pb.test(e),phone:e=>typeof e!="string"||!e?!0:Ob.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(),d=n[i];return d?d.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 Yr(e,t,r={}){const n=Ib[t.type];if(!n)return!0;const o=n(e,t,r);return o===!1?t.message||Mb(t):typeof o=="string"?o:!0}function Mb(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 ${Lb(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 Lb(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const Db=10;function Ms(e){const t=e.properties;return t?.maxFiles!=null&&t.maxFiles>0?Math.floor(t.maxFiles):t?.multiple===!0?Db:1}function Od(e){return typeof e=="object"&&e!==null&&"url"in e&&typeof e.url=="string"&&e.url.length>0}function Id(e){try{return e.split("?")[0].split("/").filter(Boolean).pop()||e}catch{return e}}function Ls(e){if(e==null)return[];if(typeof e=="string")return e.startsWith("http")?[{url:e,name:Id(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:Id(r)}):Od(r)&&t.push(r);return t}return Od(e)?[e]:[]}function Bb(e,t){return e.slice(0,t)}function ka(e,t){const r=Bb(e,t);return r.length===0?null:t===1?r[0]??null:r}function $b(e){return Ls(e).length}function jb(e){return e==="file"||e==="camera"||e==="photoChoice"}function Ta(e,t){if(!jb(e.type))return;const r=Ms(e);if($b(t)>r)return`Maximum ${r} file(s) allowed`}class Ds{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 f in i){const p=i[f];(p==null||p==="")&&(i[f]="")}const a={fields:i,currentValue:o,previousValue:s,...Ds.functions},d=Object.keys(a),u=Object.values(a),l=new Function(...d,`return ${t}`)(...u);if(l==null)return"";if(typeof l=="string"){if(l.includes("undefined"))return"";const f=l.trim();return f===""||/^\s+$/.test(l)?"":f}return l}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 Md=new Ds;function Ld(e){if(e==null||e==="")return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:Bs(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:Bs(n)}return null}function Bs(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function zb(e,t=new Date){const r=Bs(e),n=Bs(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 Fa(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 Pa(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(t):null}function Ub(e,t){const r=Pa(e);return r?`${t.sourceFieldName}${r}`:t.sourceFieldName}function Dd(e,t,r){const n=Pa(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 Vb(e,t,r){const n=r?Ub(r,e):e.sourceFieldName,o=Ld(t[n]);if(!o)return null;const s=e.referenceDate==="today"||e.referenceDate==null?new Date:Ld(t[e.referenceDate])??new Date;return zb(o,s)[e.part]}function Bd(e,t){const r=Fa(e);return r?Pr(r.sourceFieldName)===Pr(t):!1}function Oa(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=Fa(i);if(!a||!i.name||s&&Pr(a.sourceFieldName)!==s)continue;const d=n??a.sourceFieldName,u=Dd(i.name,d,o);for(const l of u){if(r.has(l))continue;const f=Vb(a,o,l);o[l]=f}}return o}function Hb(e,t,r,n){const o={...t},s=Pr(n);for(const i of e){if(!Bd(i,s)||!i.name)continue;const a=Dd(i.name,n,o);for(const d of a)r.delete(d),o[d]=null}return o}function $d(e,t){const r=Pr(t);return e.some(n=>Bd(n,r))}function jd(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 Wb(e,t,r,n){let o=Ia(e,r);return n&&(o=Dn(o,t,r)),o}function Ia(e,t){return e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(r,n)=>t?.[n]!==void 0&&t[n]!==null?String(t[n]):r)}function Dn(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(d=>d.toLowerCase()===s.toLowerCase());a&&(i=t[a])}return i!=null&&i!==""?String(i):o}),n}function $s(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 Rb(e,t){const r=e[t];return r==null||r===""}function zd(e){const{apiEndpoint:t,apiMethod:r="GET",apiQueryParams:n={},formValues:o,submissionContext:s,apiRealtime:i,additionalRequiredFieldNames:a=[],excludeFormFieldNames:d=[]}=e,u=(r||"GET").toLowerCase(),l=$s(t,n),f=new Set((d||[]).filter(v=>typeof v=="string"&&v.length>0)),p=new Set((a||[]).filter(v=>typeof v=="string"&&v.length>0)),m=new Set([...l,...p]);let g=!1;for(const v of m){const x=!!(i&&l.has(v)),E=p.has(v);if((x||E)&&Rb(o,v)){g=!0;break}}if(g)return{blocked:!0,url:t,postBodyBase:null};let h=t;const y=t.match(/\{(\w+)\}/g)||[];if(h=Ia(h,s),i&&(h=Dn(h,o,s)),n&&Object.keys(n).length>0){const v=n,x=[];if(v.limit){let E=v.limit;i&&(E=Dn(E,o,s)),x.push(`_limit=${encodeURIComponent(E)}`)}if(v.page){let E=v.page;i&&(E=Dn(E,o,s)),x.push(`page=${encodeURIComponent(E)}`)}if(v.sort){let E=v.sort;i&&(E=Dn(E,o,s)),x.push(`sort=${encodeURIComponent(E)}`)}if(v.orderBy){let E=v.orderBy;i&&(E=Dn(E,o,s)),x.push(`orderBy=${encodeURIComponent(E)}`)}if(v.custom?.length&&v.custom.forEach(({key:E,value:P})=>{if(!E||!P)return;let _=Ia(P,s);i&&(_=Dn(_,o,s)),_.match(/\{[^}]+\}/)?_.match(/\{(?!ctx:|\@)(\w+)\}/g)||x.push(`${encodeURIComponent(E)}=`):x.push(`${encodeURIComponent(E)}=${encodeURIComponent(_)}`)}),x.length>0){const E=h.includes("?")?"&":"?";h=`${h}${E}${x.join("&")}`}}if(i&&Object.keys(o).length>0&&u==="get"){const v=_=>_.replace(/\{/g,"").replace(/\}/g,""),x=[];for(const _ of n.custom||[])if(_.value){const N=_.value.match(/\{(\w+)\}/g)||[];x.push(...N.map(v))}const E=new Set([...y.map(v),...x]),P={};Object.keys(o).forEach(_=>{!E.has(_)&&!f.has(_)&&(P[_]=o[_])}),Object.keys(P).length>0&&(h=`${h}${h.includes("?")?"&":"?"}${new URLSearchParams(P).toString()}`)}let w=null;if(["post","put","patch"].includes(u))if(i&&Object.keys(o).length>0){w={...o};for(const v of f)delete w[v]}else{w={...o||{}};for(const v of f)delete w[v]}return{blocked:!1,url:h,postBodyBase:w}}const Gb=new Set(["select","multiselect","asyncsearch"]);function Kb(e){return e?.type==="multiselect"?[]:""}function Ud(e){if(!Gb.has(e.type))return[];const t=e.properties??{},r=jd(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,d=r?.apiQueryParams||t.apiQueryParams;if(i&&a)for(const u of $s(i,d))n.add(u);return[...n]}function qb(e,t){const r=Pr(t);return Ud(e).some(n=>Pr(n)===r)}function Yb(e,t){const r=Pr(t);return e.some(n=>qb(n,r))}function Xb(e){const t=new Map;for(const r of e){const n=r.name;if(n)for(const o of Ud(r)){const s=Pr(o),i=t.get(s)??new Set;i.add(n),t.set(s,i)}}return t}function Jb(e,t,r){const n=Pa(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 Qb(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 Zb(e,t,r){const n=Xb(e),o=Pr(r),s=new Set,i=[o];for(;i.length>0;){const u=i.shift(),l=n.get(u);if(l)for(const f of l)s.has(f)||(s.add(f),i.push(f))}const a={...t},d=[];for(const u of s){const l=e.find(p=>p.name===u),f=Kb(l);for(const p of Jb(u,r,a))Qb(a[p],f)||d.push(p),a[p]=f}return{values:a,clearedKeys:d}}function Ma(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}const Nt=Pd((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={},d=new Set,u=new Set,l=new Set;r.fields.forEach(y=>{const w=y.name||y.key||y.id;w&&(y.defaultValue!==void 0&&(y.type==="multiselect"?a[w]=Array.isArray(y.defaultValue)?y.defaultValue:y.defaultValue!=null&&y.defaultValue!==""?[String(y.defaultValue)]:[]:a[w]=y.defaultValue),y.hidden||d.add(w),y.disabled||u.add(w),y.validation?.some(v=>v.type==="required")&&l.add(w))});const f=r.steps?.length||1,p=[];r.fields.forEach(y=>{const w=y.properties;w?.valueSource==="calculated"&&w?.formula&&p.push({field:y.name,formula:w.formula})});const m=p.length>0?Md.calculateAll(p,a):{},g=Oa(r.fields,{...a,...m},new Set),h=s&&!i?{...g,...o.values}:g;e({schema:r,values:h,initialValues:g,errors:{},touched:{},currentStep:0,totalSteps:f,completedSteps:new Set,visibleFields:d,enabledFields:u,requiredFields:l,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 d=new Set(s.derivedFieldDirty);const u=s.values[r];let l={...s.values,[r]:n},f=[];if(i){const p=Pr(r),m=i.fields.find(w=>w.name===p);a==="user"&&m&&Fa(m)&&d.add(r);const g=n==null||n===""||Array.isArray(n)&&n.length===0;if($d(i.fields,r)&&g?l=Hb(i.fields,l,d,r):$d(i.fields,r)&&(l=Oa(i.fields,l,d,r)),a==="user"&&u!==n&&!(Array.isArray(u)&&Array.isArray(n)&&u.length===n.length&&u.every((w,v)=>w===n[v]))&&Yb(i.fields,r)){const w=Zb(i.fields,l,r);l=w.values,f=w.clearedKeys}const y=[];if(i.fields.forEach(w=>{const v=w.properties;v?.valueSource==="calculated"&&v?.formula&&(v.formulaSteps||[]).some(P=>P.type==="field"&&P.fieldName===r)&&y.push({field:w.name,formula:v.formula})}),y.length>0){const w=Md.calculateAll(y,l);l={...l,...w}}}e({values:l,derivedFieldDirty:d}),f.length>0&&e(p=>{const m={...p.errors};for(const g of f)delete m[g];return Object.keys(m).length===Object.keys(p.errors).length?p:{errors:m}}),i?.config.validateOnChange?t().validateField(r):e(p=>{const m={...p.errors};return delete m[r],{errors:m}})},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=Oa(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 d=Yr(o[r],a,o);if(typeof d=="string"){i=d;break}}if(!i){const a=Ta(s,o[r]);a&&(i=a)}return e(a=>{const d={...a.errors};return i?d[r]=i:delete d[r],{errors:d,isValid:Object.keys(d).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 d of a.validation){if(d.type==="required"&&!s.has(a.name))continue;const u=Yr(n[a.name],d,n);if(typeof u=="string"){i[a.name]=u;break}}if(!i[a.name]){const d=Ta(a,n[a.name]);d&&(i[a.name]=d)}}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||!n.steps)return!0;const i=n.steps[r];if(!i)return!0;e({isValidating:!0});const a={};for(const d of i.fields){const u=n.fields.find(l=>l.name===d);if(u&&s.has(u.name)){if(u.validation)for(const l of u.validation){const f=Yr(o[u.name],l,o);if(typeof f=="string"){a[u.name]=f;break}}if(!a[u.name]){const l=Ta(u,o[u.name]);l&&(a[u.name]=l)}}}return e(d=>({errors:{...d.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 Ma(n.visibleFields,o)?n:{visibleFields:o}})},updateEnabled:r=>{e(n=>{const o=new Set(r);return Ma(n.enabledFields,o)?n:{enabledFields:o}})},updateRequired:r=>{e(n=>{const o=new Set(r);return Ma(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{}}}));function ev(){return Nt.getState()}function Vd({schema:e,initialValues:t,onSubmit:r,onChange:n,workflowStepId:o}){const{values:s,errors:i,touched:a,isValidating:d,isSubmitting:u,submitCount:l,isValid:f,currentStep:p,totalSteps:m,completedSteps:g,visibleFields:h,enabledFields:y,requiredFields:w,setSchema:v,setFieldValue:x,setFieldTouched:E,setFieldError:P,setValues:_,resetForm:N,validateField:C,validateForm:A,validateStep:I,nextStep:T,prevStep:W,goToStep:X,setSubmitting:O,incrementSubmitCount:j,saveDraft:M,loadDraft:D,clearDraft:L}=Nt(),U=S.useRef(null);S.useLayoutEffect(()=>{if(v(e,{forceReset:!!o}),t&&Object.keys(t).length>0){const de=Nt.getState().values;_({...de,...t});try{U.current=JSON.stringify(t)}catch{U.current=null}}else U.current=null},[e.id,o]),S.useLayoutEffect(()=>{if(!t||Object.keys(t).length===0)return;let de;try{de=JSON.stringify(t)}catch{return}if(de===U.current)return;const ot=Nt.getState().values;_({...ot,...t}),U.current=de},[t,_]);const $=S.useCallback((de,ot)=>{const Se={...s,[de]:ot};x(de,ot),n?.(Se,de)},[x,n,s]),ie=S.useCallback(async de=>{if(de?.preventDefault(),j(),!await A())return{success:!1,errors:Object.entries(i).map(([Se,xe])=>({field:Se,rule:"validation",message:xe}))};if(!r)return{success:!0};O(!0);try{const Se=await r(s);return Se.success&&L(),Se}catch(Se){return{success:!1,message:Se instanceof Error?Se.message:"Submission failed"}}finally{O(!1)}},[A,r,s,i,j,O,L]),V=S.useCallback(de=>({value:s[de],error:i[de],touched:a[de]||!1,isVisible:h.has(de),isEnabled:y.has(de),isRequired:w.has(de)}),[s,i,a,h,y,w]),K=S.useMemo(()=>{if(!e.steps||e.steps.length===0)return e.fields;const de=e.steps[p];return de?e.fields.filter(ot=>de.fields.includes(ot.name)):[]},[e,p]),J=p===0,ce=p===m-1,ne=S.useCallback(de=>g.has(de),[g]),G=S.useMemo(()=>m<=1?100:Math.round(g.size/m*100),[g.size,m]),ee=S.useCallback(de=>h.has(de),[h]),Pe=S.useCallback(de=>y.has(de),[y]),oe=S.useCallback(de=>w.has(de),[w]),re=S.useMemo(()=>Object.entries(i).filter(([de])=>h.has(de)),[i,h]),be=re.length>0;return{values:s,errors:i,touched:a,isValidating:d,isSubmitting:u,submitCount:l,isValid:f,hasErrors:be,visibleErrors:re,currentStep:p,totalSteps:m,completedSteps:g,currentStepFields:K,isFirstStep:J,isLastStep:ce,isStepCompleted:ne,progress:G,setFieldValue:$,setFieldTouched:E,setFieldError:P,setValues:_,validateField:C,getFieldState:V,shouldShowField:ee,isFieldEnabled:Pe,isFieldRequired:oe,handleSubmit:ie,resetForm:N,validateForm:A,validateStep:I,nextStep:T,prevStep:W,goToStep:X,saveDraft:M,loadDraft:D,clearDraft:L}}function Hd(e){return"logic"in e&&"conditions"in e}function Uo(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 Wd(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 Qe(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;let r=Wd(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=Wd(e,o);Array.isArray(i)&&i.length>0&&(r=Qe(i[0],s))}}return r}const tv=new Set(["section","group","columns","divider","header","sectionHeading","spacer","textLabel","addmore","customizeSections"]);function rv(e){return e===!0||e==="true"?!0:e===!1||e==="false"?!1:e}function nv(e,t){if(e==null||typeof t.path!="string"||!t.path.trim())return!1;const r=Qe(e,t.path),n=rv(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 ov(e,t,r){return e?e==="__allFields__"?t.filter(n=>!tv.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]:[]}const Rd="__buttonResponse:";function sv({fields:e,values:t,buttonResponses:r,prepopulateResponse:n=null,prepopulateResponseRules:o}){const{updateVisibility:s,updateEnabled:i,updateRequired:a,updateReadOnly:d,updateEditable:u,updateFormDisabled:l}=Nt(),f=S.useCallback(_=>_.name||_.key||_.id,[]),p=S.useCallback((_,N)=>{if(!_)return f(N);const C=e.find(A=>A.id===_||A.name===_||A.key===_);return C?f(C):_},[e,f]),m=S.useCallback(_=>{const N=e.find(C=>C.id===_||C.name===_||C.key===_);return N?f(N):_},[e,f]),g=S.useCallback(_=>{const{field:N,operator:C,value:A}=_;if(typeof N=="string"&&N.startsWith(Rd)){const W=N.slice(Rd.length),X=r?.[W],O=Uo(X);return A==="success"?O:A==="failure"?X!=null&&!O:!1}const I=m(N),T=t[I];switch(C){case"equals":return T===A;case"notEquals":return T!==A;case"contains":return typeof T=="string"?T.includes(String(A)):Array.isArray(T)?T.includes(A):!1;case"notContains":return typeof T=="string"?!T.includes(String(A)):Array.isArray(T)?!T.includes(A):!0;case"startsWith":return typeof T=="string"&&T.startsWith(String(A));case"endsWith":return typeof T=="string"&&T.endsWith(String(A));case"greaterThan":return Number(T)>Number(A);case"lessThan":return Number(T)<Number(A);case"greaterThanOrEqual":return Number(T)>=Number(A);case"lessThanOrEqual":return Number(T)<=Number(A);case"isEmpty":return T==null?!0:T instanceof File?!1:typeof T=="string"?T.trim()==="":Array.isArray(T)?(T.length>0&&T[0]instanceof File,T.length===0):typeof T=="object"&&T!==null?Object.keys(T).length===0:!1;case"isNotEmpty":return T==null?!1:T instanceof File?!0:typeof T=="string"?T.trim()!=="":Array.isArray(T)?(T.length>0&&T[0]instanceof File,T.length>0):typeof T=="object"&&T!==null?Object.keys(T).length>0:!1;case"isTrue":return T===!0;case"isFalse":return T===!1;case"isNull":return T==null;case"isNotNull":return T!=null;case"in":return Array.isArray(A)?A.includes(T):!1;case"notIn":return Array.isArray(A)?!A.includes(T):!0;case"between":if(Array.isArray(A)&&A.length===2){const W=Number(T);return W>=Number(A[0])&&W<=Number(A[1])}return!1;case"regex":try{return new RegExp(String(A)).test(String(T))}catch{return!1}default:return!0}},[t,m,r]),h=S.useCallback(_=>{const N=_.conditions.map(C=>Hd(C)?h(C):g(C));return _.logic==="and"?N.every(Boolean):N.some(Boolean)},[g]),y=S.useCallback(_=>Hd(_)?h(_):g(_),[g,h]),w=S.useCallback(()=>{const _=new Set,N=new Set,C=new Set,A=new Set,I=new Set;e.forEach(O=>{const j=f(O);O.hidden||_.add(j),O.disabled||N.add(j),O.validation?.some(M=>M.type==="required")&&C.add(j)});let T=!1;if(n!=null&&o?.length)for(const O of o){if(!nv(n,O.when))continue;const{action:j,target:M}=O.then;if(j==="disableForm")T=!0;else if(j==="enableForm")T=!1;else{const D=ov(M,e,f);for(const L of D)switch(j){case"disable":N.delete(L);break;case"enable":N.add(L);break;case"hide":_.delete(L);break;case"show":_.add(L);break;case"readOnly":A.add(L),I.delete(L);break;case"editable":I.add(L),A.delete(L);break}}}e.forEach(O=>{O.conditions&&O.conditions.forEach(j=>{(y(j.when)?j.then:j.else||[]).forEach(L=>{switch(L.action){case"disableForm":T=!0;break;case"enableForm":T=!1;break;default:{const U=p(L.target,O);switch(L.action){case"show":_.add(U);break;case"hide":_.delete(U);break;case"enable":N.add(U);break;case"disable":N.delete(U);break;case"require":C.add(U);break;case"unrequire":C.delete(U);break}break}}})})});const W=O=>e.filter(j=>j.type!=="editButton"&&(j.name||j.key||j.id)).map(j=>f(j)),X=()=>e.filter(O=>O.type==="button").map(O=>f(O));return e.forEach(O=>{if(O.type!=="editButton")return;const j=f(O);if(!Uo(r?.[j]))return;const M=O.properties;M?.rules&&M.rules.length>0?M.rules.forEach(D=>{const L=[];D.allFields&&L.push(...W(O.id)),D.allButtons&&L.push(...X()),D.fieldNames?.length&&D.fieldNames.forEach(U=>{const $=e.find(ie=>f(ie)===U||ie.id===U||ie.name===U);L.push($?f($):U)}),D.buttonNames?.length&&L.push(...D.buttonNames),L.forEach(U=>{switch(D.action){case"enable":N.add(U),A.delete(U);break;case"disable":N.delete(U);break;case"show":_.add(U);break;case"hide":_.delete(U);break;case"readOnly":A.add(U);break;case"editable":I.add(U);break}})}):((M?.enableFieldNames??[]).forEach(D=>N.add(D)),(M?.disableFieldNames??[]).forEach(D=>N.delete(D)),(M?.showFieldNames??[]).forEach(D=>_.add(D)),(M?.hideFieldNames??[]).forEach(D=>_.delete(D)))}),{visible:Array.from(_),enabled:Array.from(N),required:Array.from(C),readOnly:Array.from(A),editable:Array.from(I),formDisabled:T}},[e,y,f,p,t,r,n,o]),v=S.useMemo(()=>w(),[w]);S.useEffect(()=>{s(v.visible),i(v.enabled),a(v.required),d(v.readOnly??[]),u(v.editable??[]),l(v.formDisabled??!1)},[v,s,i,a,d,u,l]);const x=S.useCallback(_=>v.visible.includes(_),[v.visible]),E=S.useCallback(_=>v.enabled.includes(_),[v.enabled]),P=S.useCallback(_=>v.required.includes(_),[v.required]);return{evaluateCondition:y,evaluateExpression:g,evaluateGroup:h,isFieldVisible:x,isFieldEnabled:E,isFieldRequired:P,visibleFields:v.visible,enabledFields:v.enabled,requiredFields:v.required}}function wn({className:e,type:t,...r}){return c.jsx("input",{type:t,"data-slot":"input",className:B("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 Gd(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Bn(...e){return t=>{let r=!1;const n=e.map(o=>{const s=Gd(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():Gd(e[o],null)}}}}function Ze(...e){return b.useCallback(Bn(...e),e)}var iv=Symbol.for("react.lazy"),js=b[" use ".trim().toString()];function av(e){return typeof e=="object"&&e!==null&&"then"in e}function Kd(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===iv&&"_payload"in e&&av(e._payload)}function La(e){const t=lv(e),r=b.forwardRef((n,o)=>{let{children:s,...i}=n;Kd(s)&&typeof js=="function"&&(s=js(s._payload));const a=b.Children.toArray(s),d=a.find(dv);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}var qd=La("Slot");function lv(e){const t=b.forwardRef((r,n)=>{let{children:o,...s}=r;if(Kd(o)&&typeof js=="function"&&(o=js(o._payload)),b.isValidElement(o)){const i=fv(o),a=uv(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(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 cv=Symbol("radix.slottable");function dv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===cv}function uv(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 d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function fv(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 pv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mv=pv.reduce((e,t)=>{const r=La(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,d=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),hv="Label",Yd=b.forwardRef((e,t)=>c.jsx(mv.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));Yd.displayName=hv;var gv=Yd;function Sn({className:e,...t}){return c.jsx(gv,{"data-slot":"label",className:B("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 ht(e){return`formsmith-field-${e.id}`}function zs(e){return`formsmith-label-${e.id}`}function Vo(e){return`formsmith-desc-${e.id}`}function Ho(e){return`formsmith-error-${e.id}`}function jt(e,t){const r=[];return e.description&&r.push(Vo(e)),t&&r.push(Ho(e)),r.length>0?r.join(" "):void 0}function Jt(e){return e?!0:void 0}const yv={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 xn(e){return e.ui?.cellStyle}function bv(e){const t=e.ui;if(!t)return;const r=t.fontToken?yv[t.fontToken]:void 0;if(!(!r&&!t.wrapperStyle))return{...r,...t.wrapperStyle}}function vv(e){return e.type==="button"||e.type==="editButton"}const Et=({field:e,error:t,isRequired:r,children:n,className:o,hideLabel:s})=>{const{gridStretch:i}=zo(),a=i&&Is(e),d=!(s??e.appearance?.hideLabel)&&e.label,u=e.appearance?.labelPlacement||"top",l=bv(e),f=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,m=Nd(e),g=to(e),h=vv(e),y=Fr(e.appearance);return c.jsx("div",{className:B(Sb(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:l,"data-field-appearance":u,children:c.jsxs("div",{className:B("flex flex-col min-w-0",xd(e.appearance),_d(e),a&&!h&&"flex-1 min-h-0",i&&h&&"shrink-0"),style:m,children:[d&&c.jsxs(Sn,{id:zs(e),htmlFor:ht(e),style:e.ui?.labelStyle,className:B(xb(u,!!t)),children:[e.label,r&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),c.jsxs("div",{className:B(Ab(u),h&&i&&"min-h-min !grow-0 !shrink-0 basis-auto",g&&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:f,children:[n,c.jsxs("div",{className:B("mt-1.5 min-h-[18px]",u==="center"&&"text-center",o?.includes("flex")&&"shrink-0"),children:[e.description&&!t&&c.jsx("p",{id:Vo(e),className:"text-xs text-muted-foreground",style:e.ui?.descriptionStyle,children:e.description}),t&&c.jsx("p",{id:Ho(e),className:"text-xs text-destructive",role:"alert",children:typeof t=="string"?t:String(t||"An error occurred")})]})]})]})})},Da=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=S.useCallback(f=>{r(f.target.value)},[r]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsx(wn,{id:ht(e),type:"text",value:t||"",onChange:l,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":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})})},Xd=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=u?.precision!=null||u?.step!=null&&!Number.isInteger(u.step),f=S.useCallback(m=>{const g=u?.allowNegative!==!1,h=m.target.value,y=l?h.replace(g?/[^\d.-]/g:/[^\d.]/g,""):h.replace(g?/[^\d-]/g:/\D/g,"");if(y===""){r(null);return}const w=parseFloat(y);isNaN(w)||r(w)},[r,u?.allowNegative,l]),p=S.useCallback(m=>{(m.key==="ArrowUp"||m.key==="ArrowDown"||m.key==="PageUp"||m.key==="PageDown")&&m.preventDefault()},[]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[u?.prefix&&c.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.prefix}),c.jsx(wn,{id:ht(e),type:"text",inputMode:l?"decimal":"numeric",autoComplete:"off",value:t??"",onChange:f,onKeyDown:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",u?.prefix&&"pl-8",u?.suffix&&"pr-8",e.appearance?.className)}),u?.suffix&&c.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.suffix})]})})};const wv=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Sv=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),Jd=e=>{const t=Sv(e);return t.charAt(0).toUpperCase()+t.slice(1)},Qd=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),xv=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Av={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 Cv=S.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:s,iconNode:i,...a},d)=>S.createElement("svg",{ref:d,...Av,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:Qd("lucide",o),...!s&&!xv(a)&&{"aria-hidden":"true"},...a},[...i.map(([u,l])=>S.createElement(u,l)),...Array.isArray(s)?s:[s]]));const Gt=(e,t)=>{const r=S.forwardRef(({className:n,...o},s)=>S.createElement(Cv,{ref:s,iconNode:t,className:Qd(`lucide-${wv(Jd(e))}`,`lucide-${e}`,n),...o}));return r.displayName=Jd(e),r};const Ev=Gt("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 Us=Gt("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 Vs=Gt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Wo=Gt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Zd=Gt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Nv=Gt("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const _v=Gt("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 eu=Gt("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const tu=Gt("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=Gt("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 Ro=Gt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const kv=Gt("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 Tv=Gt("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 nu=Gt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Fv=Gt("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 ou=Gt("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 Go=Gt("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 Hs=Gt("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 Ko=Gt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),su=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=S.useCallback(l=>{r(l.target.value)},[r]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[c.jsx(kv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),c.jsx(wn,{id:ht(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":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})},iu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=S.useCallback(l=>{const f=l.target.value.replace(/[^\d\s+\-()]/g,"");r(f)},[r]);return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"relative",children:[c.jsx(Tv,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),c.jsx(wn,{id:ht(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":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(Bo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})};function Pv({className:e,maxLength:t,showCharacterCount:r=!1,autoResize:n=!1,onChange:o,value:s,...i}){const a=b.useRef(null),[d,u]=b.useState(0),l=f=>{const p=f.target.value;u(p.length),n&&a.current&&(a.current.style.height="auto",a.current.style.height=`${a.current.scrollHeight}px`),o&&o(f)};return b.useEffect(()=>{s&&u(String(s).length)},[s]),c.jsxs("div",{className:"space-y-1",children:[c.jsx("textarea",{ref:a,"data-slot":"textarea",className:B("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:l,value:s,...i}),r&&c.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[c.jsxs("span",{children:[d," characters"]}),t&&c.jsxs("span",{children:[t-d," remaining"]})]})]})}const au=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const{gridStretch:u}=zo(),l=u&&Is(e),f=e.properties,p=S.useCallback(y=>{r(y.target.value)},[r]),m=(t||"").length,g=f?.maxLength,h=g&&g>0;return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:B("relative flex flex-col",l&&"flex-1 min-h-0"),children:[c.jsx(Pv,{id:ht(e),value:t||"",onChange:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,minLength:f?.minLength,maxLength:f?.maxLength,rows:2,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(vd(e.appearance),"resize-y",l&&"min-h-[120px] flex-1 flex-shrink-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),h&&c.jsxs("span",{className:"absolute bottom-2 right-2 text-xs text-muted-foreground",children:[m,"/",g]})]})})};function qo(e,[t,r]){return Math.min(r,Math.max(t,e))}function Me(e,t,{checkForDefaultPrevented:r=!0}={}){return function(o){if(e?.(o),r===!1||!o.defaultPrevented)return t?.(o)}}function Ov(e,t){const r=b.createContext(t),n=s=>{const{children:i,...a}=s,d=b.useMemo(()=>a,Object.values(a));return c.jsx(r.Provider,{value:d,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),d=r.length;r=[...r,i];const u=f=>{const{scope:p,children:m,...g}=f,h=p?.[e]?.[d]||a,y=b.useMemo(()=>g,Object.values(g));return c.jsx(h.Provider,{value:y,children:m})};u.displayName=s+"Provider";function l(f,p){const m=p?.[e]?.[d]||a,g=b.useContext(m);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,l]}const o=()=>{const s=r.map(i=>b.createContext(i));return function(a){const d=a?.[e]||s;return b.useMemo(()=>({[`__scope${e}`]:{...a,[e]:d}}),[a,d])}};return o.scopeName=e,[n,Iv(o,...t)]}function Iv(...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:d,scopeName:u})=>{const f=d(s)[`__scope${u}`];return{...a,...f}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return r.scopeName=t.scopeName,r}function lu(e){const t=Mv(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(Dv);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function Mv(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=$v(o),a=Bv(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(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 Lv=Symbol("radix.slottable");function Dv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Lv}function Bv(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 d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function $v(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 Ba(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:w}=h,v=S.useRef(null),x=S.useRef(new Map).current;return c.jsx(o,{scope:y,itemMap:x,collectionRef:v,children:w})};i.displayName=t;const a=e+"CollectionSlot",d=lu(a),u=S.forwardRef((h,y)=>{const{scope:w,children:v}=h,x=s(a,w),E=Ze(y,x.collectionRef);return c.jsx(d,{ref:E,children:v})});u.displayName=a;const l=e+"CollectionItemSlot",f="data-radix-collection-item",p=lu(l),m=S.forwardRef((h,y)=>{const{scope:w,children:v,...x}=h,E=S.useRef(null),P=Ze(y,E),_=s(l,w);return S.useEffect(()=>(_.itemMap.set(E,{ref:E,...x}),()=>{_.itemMap.delete(E)})),c.jsx(p,{[f]:"",ref:P,children:v})});m.displayName=l;function g(h){const y=s(e+"CollectionConsumer",h);return S.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const x=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((_,N)=>x.indexOf(_.ref.current)-x.indexOf(N.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},g,n]}var jv=b.createContext(void 0);function ro(e){const t=b.useContext(jv);return e||t||"ltr"}function zv(e){const t=Uv(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(Hv);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function Uv(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=Rv(o),a=Wv(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(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 Vv=Symbol("radix.slottable");function Hv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Vv}function Wv(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 d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function Rv(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 Gv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Be=Gv.reduce((e,t)=>{const r=zv(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,d=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Kv(e,t){e&&Es.flushSync(()=>e.dispatchEvent(t))}function ar(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>(...r)=>t.current?.(...r),[])}function qv(e,t=globalThis?.document){const r=ar(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 Yv="DismissableLayer",$a="dismissableLayer.update",Xv="dismissableLayer.pointerDownOutside",Jv="dismissableLayer.focusOutside",cu,du=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ws=b.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...d}=e,u=b.useContext(du),[l,f]=b.useState(null),p=l?.ownerDocument??globalThis?.document,[,m]=b.useState({}),g=Ze(t,N=>f(N)),h=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=h.indexOf(y),v=l?h.indexOf(l):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,E=v>=w,P=ew(N=>{const C=N.target,A=[...u.branches].some(I=>I.contains(C));!E||A||(o?.(N),i?.(N),N.defaultPrevented||a?.())},p),_=tw(N=>{const C=N.target;[...u.branches].some(I=>I.contains(C))||(s?.(N),i?.(N),N.defaultPrevented||a?.())},p);return qv(N=>{v===u.layers.size-1&&(n?.(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},p),b.useEffect(()=>{if(l)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(cu=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(l)),u.layers.add(l),uu(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=cu)}},[l,p,r,u]),b.useEffect(()=>()=>{l&&(u.layers.delete(l),u.layersWithOutsidePointerEventsDisabled.delete(l),uu())},[l,u]),b.useEffect(()=>{const N=()=>m({});return document.addEventListener($a,N),()=>document.removeEventListener($a,N)},[]),c.jsx(Be.div,{...d,ref:g,style:{pointerEvents:x?E?"auto":"none":void 0,...e.style},onFocusCapture:Me(e.onFocusCapture,_.onFocusCapture),onBlurCapture:Me(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Me(e.onPointerDownCapture,P.onPointerDownCapture)})});Ws.displayName=Yv;var Qv="DismissableLayerBranch",Zv=b.forwardRef((e,t)=>{const r=b.useContext(du),n=b.useRef(null),o=Ze(t,n);return b.useEffect(()=>{const s=n.current;if(s)return r.branches.add(s),()=>{r.branches.delete(s)}},[r.branches]),c.jsx(Be.div,{...e,ref:o})});Zv.displayName=Qv;function ew(e,t=globalThis?.document){const r=ar(e),n=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const s=a=>{if(a.target&&!n.current){let d=function(){fu(Xv,r,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}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 tw(e,t=globalThis?.document){const r=ar(e),n=b.useRef(!1);return b.useEffect(()=>{const o=s=>{s.target&&!n.current&&fu(Jv,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 uu(){const e=new CustomEvent($a);document.dispatchEvent(e)}function fu(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?Kv(o,s):o.dispatchEvent(s)}var ja=0;function za(){b.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??pu()),document.body.insertAdjacentElement("beforeend",e[1]??pu()),ja++,()=>{ja===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ja--}},[])}function pu(){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 Ua="focusScope.autoFocusOnMount",Va="focusScope.autoFocusOnUnmount",mu={bubbles:!1,cancelable:!0},rw="FocusScope",Rs=b.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,d]=b.useState(null),u=ar(o),l=ar(s),f=b.useRef(null),p=Ze(t,h=>d(h)),m=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(n){let h=function(x){if(m.paused||!a)return;const E=x.target;a.contains(E)?f.current=E:An(f.current,{select:!0})},y=function(x){if(m.paused||!a)return;const E=x.relatedTarget;E!==null&&(a.contains(E)||An(f.current,{select:!0}))},w=function(x){if(document.activeElement===document.body)for(const P of x)P.removedNodes.length>0&&An(a)};document.addEventListener("focusin",h),document.addEventListener("focusout",y);const v=new MutationObserver(w);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",y),v.disconnect()}}},[n,a,m.paused]),b.useEffect(()=>{if(a){yu.add(m);const h=document.activeElement;if(!a.contains(h)){const w=new CustomEvent(Ua,mu);a.addEventListener(Ua,u),a.dispatchEvent(w),w.defaultPrevented||(nw(lw(hu(a)),{select:!0}),document.activeElement===h&&An(a))}return()=>{a.removeEventListener(Ua,u),setTimeout(()=>{const w=new CustomEvent(Va,mu);a.addEventListener(Va,l),a.dispatchEvent(w),w.defaultPrevented||An(h??document.body,{select:!0}),a.removeEventListener(Va,l),yu.remove(m)},0)}}},[a,u,l,m]);const g=b.useCallback(h=>{if(!r&&!n||m.paused)return;const y=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,w=document.activeElement;if(y&&w){const v=h.currentTarget,[x,E]=ow(v);x&&E?!h.shiftKey&&w===E?(h.preventDefault(),r&&An(x,{select:!0})):h.shiftKey&&w===x&&(h.preventDefault(),r&&An(E,{select:!0})):w===v&&h.preventDefault()}},[r,n,m.paused]);return c.jsx(Be.div,{tabIndex:-1,...i,ref:p,onKeyDown:g})});Rs.displayName=rw;function nw(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(An(n,{select:t}),document.activeElement!==r)return}function ow(e){const t=hu(e),r=gu(t,e),n=gu(t.reverse(),e);return[r,n]}function hu(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 gu(e,t){for(const r of e)if(!sw(r,{upTo:t}))return r}function sw(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 iw(e){return e instanceof HTMLInputElement&&"select"in e}function An(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&iw(e)&&t&&e.select()}}var yu=aw();function aw(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=bu(e,t),e.unshift(t)},remove(t){e=bu(e,t),e[0]?.resume()}}}function bu(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function lw(e){return e.filter(t=>t.tagName!=="A")}var Qt=globalThis?.document?b.useLayoutEffect:()=>{},cw=b[" useId ".trim().toString()]||(()=>{}),dw=0;function on(e){const[t,r]=b.useState(cw());return Qt(()=>{r(n=>n??String(dw++))},[e]),e||(t?`radix-${t}`:"")}const uw=["top","right","bottom","left"],Cn=Math.min,wr=Math.max,Gs=Math.round,Ks=Math.floor,Xr=e=>({x:e,y:e}),fw={left:"right",right:"left",bottom:"top",top:"bottom"};function Ha(e,t,r){return wr(e,Cn(t,r))}function sn(e,t){return typeof e=="function"?e(t):e}function an(e){return e.split("-")[0]}function no(e){return e.split("-")[1]}function Wa(e){return e==="x"?"y":"x"}function Ra(e){return e==="y"?"height":"width"}function Jr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Ga(e){return Wa(Jr(e))}function pw(e,t,r){r===void 0&&(r=!1);const n=no(e),o=Ga(e),s=Ra(o);let i=o==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=qs(i)),[i,qs(i)]}function mw(e){const t=qs(e);return[Ka(e),t,Ka(t)]}function Ka(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const vu=["left","right"],wu=["right","left"],hw=["top","bottom"],gw=["bottom","top"];function yw(e,t,r){switch(e){case"top":case"bottom":return r?t?wu:vu:t?vu:wu;case"left":case"right":return t?hw:gw;default:return[]}}function bw(e,t,r,n){const o=no(e);let s=yw(an(e),r==="start",n);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ka)))),s}function qs(e){const t=an(e);return fw[t]+e.slice(t.length)}function vw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Su(e){return typeof e!="number"?vw(e):{top:e,right:e,bottom:e,left:e}}function Ys(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 xu(e,t,r){let{reference:n,floating:o}=e;const s=Jr(t),i=Ga(t),a=Ra(i),d=an(t),u=s==="y",l=n.x+n.width/2-o.width/2,f=n.y+n.height/2-o.height/2,p=n[a]/2-o[a]/2;let m;switch(d){case"top":m={x:l,y:n.y-o.height};break;case"bottom":m={x:l,y:n.y+n.height};break;case"right":m={x:n.x+n.width,y:f};break;case"left":m={x:n.x-o.width,y:f};break;default:m={x:n.x,y:n.y}}switch(no(t)){case"start":m[i]-=p*(r&&u?-1:1);break;case"end":m[i]+=p*(r&&u?-1:1);break}return m}async function ww(e,t){var r;t===void 0&&(t={});const{x:n,y:o,platform:s,rects:i,elements:a,strategy:d}=e,{boundary:u="clippingAncestors",rootBoundary:l="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=sn(t,e),g=Su(m),y=a[p?f==="floating"?"reference":"floating":f],w=Ys(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:l,strategy:d})),v=f==="floating"?{x:n,y:o,width:i.floating.width,height:i.floating.height}:i.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},P=Ys(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:d}):v);return{top:(w.top-P.top+g.top)/E.y,bottom:(P.bottom-w.bottom+g.bottom)/E.y,left:(w.left-P.left+g.left)/E.x,right:(P.right-w.right+g.right)/E.x}}const Sw=50,xw=async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:s=[],platform:i}=r,a=i.detectOverflow?i:{...i,detectOverflow:ww},d=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:l,y:f}=xu(u,n,d),p=n,m=0;const g={};for(let h=0;h<s.length;h++){const y=s[h];if(!y)continue;const{name:w,fn:v}=y,{x,y:E,data:P,reset:_}=await v({x:l,y:f,initialPlacement:n,placement:p,strategy:o,middlewareData:g,rects:u,platform:a,elements:{reference:e,floating:t}});l=x??l,f=E??f,g[w]={...g[w],...P},_&&m<Sw&&(m++,typeof _=="object"&&(_.placement&&(p=_.placement),_.rects&&(u=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):_.rects),{x:l,y:f}=xu(u,p,d)),h=-1)}return{x:l,y:f,placement:p,strategy:o,middlewareData:g}},Aw=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:o,rects:s,platform:i,elements:a,middlewareData:d}=t,{element:u,padding:l=0}=sn(e,t)||{};if(u==null)return{};const f=Su(l),p={x:r,y:n},m=Ga(o),g=Ra(m),h=await i.getDimensions(u),y=m==="y",w=y?"top":"left",v=y?"bottom":"right",x=y?"clientHeight":"clientWidth",E=s.reference[g]+s.reference[m]-p[m]-s.floating[g],P=p[m]-s.reference[m],_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let N=_?_[x]:0;(!N||!await(i.isElement==null?void 0:i.isElement(_)))&&(N=a.floating[x]||s.floating[g]);const C=E/2-P/2,A=N/2-h[g]/2-1,I=Cn(f[w],A),T=Cn(f[v],A),W=I,X=N-h[g]-T,O=N/2-h[g]/2+C,j=Ha(W,O,X),M=!d.arrow&&no(o)!=null&&O!==j&&s.reference[g]/2-(O<W?I:T)-h[g]/2<0,D=M?O<W?O-W:O-X:0;return{[m]:p[m]+D,data:{[m]:j,centerOffset:O-j-D,...M&&{alignmentOffset:D}},reset:M}}}),Cw=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:d,elements:u}=t,{mainAxis:l=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...y}=sn(e,t);if((r=s.arrow)!=null&&r.alignmentOffset)return{};const w=an(o),v=Jr(a),x=an(a)===a,E=await(d.isRTL==null?void 0:d.isRTL(u.floating)),P=p||(x||!h?[qs(a)]:mw(a)),_=g!=="none";!p&&_&&P.push(...bw(a,h,g,E));const N=[a,...P],C=await d.detectOverflow(t,y),A=[];let I=((n=s.flip)==null?void 0:n.overflows)||[];if(l&&A.push(C[w]),f){const O=pw(o,i,E);A.push(C[O[0]],C[O[1]])}if(I=[...I,{placement:o,overflows:A}],!A.every(O=>O<=0)){var T,W;const O=(((T=s.flip)==null?void 0:T.index)||0)+1,j=N[O];if(j&&(!(f==="alignment"?v!==Jr(j):!1)||I.every(L=>Jr(L.placement)===v?L.overflows[0]>0:!0)))return{data:{index:O,overflows:I},reset:{placement:j}};let M=(W=I.filter(D=>D.overflows[0]<=0).sort((D,L)=>D.overflows[1]-L.overflows[1])[0])==null?void 0:W.placement;if(!M)switch(m){case"bestFit":{var X;const D=(X=I.filter(L=>{if(_){const U=Jr(L.placement);return U===v||U==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(U=>U>0).reduce((U,$)=>U+$,0)]).sort((L,U)=>L[1]-U[1])[0])==null?void 0:X[0];D&&(M=D);break}case"initialPlacement":M=a;break}if(o!==M)return{reset:{placement:M}}}return{}}}};function Au(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Cu(e){return uw.some(t=>e[t]>=0)}const Ew=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:n}=t,{strategy:o="referenceHidden",...s}=sn(e,t);switch(o){case"referenceHidden":{const i=await n.detectOverflow(t,{...s,elementContext:"reference"}),a=Au(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Cu(a)}}}case"escaped":{const i=await n.detectOverflow(t,{...s,altBoundary:!0}),a=Au(i,r.floating);return{data:{escapedOffsets:a,escaped:Cu(a)}}}default:return{}}}}},Eu=new Set(["left","top"]);async function Nw(e,t){const{placement:r,platform:n,elements:o}=e,s=await(n.isRTL==null?void 0:n.isRTL(o.floating)),i=an(r),a=no(r),d=Jr(r)==="y",u=Eu.has(i)?-1:1,l=s&&d?-1:1,f=sn(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof g=="number"&&(m=a==="end"?g*-1:g),d?{x:m*l,y:p*u}:{x:p*u,y:m*l}}const _w=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,d=await Nw(t,e);return i===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+d.x,y:s+d.y,data:{...d,placement:i}}}}},kw=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:d={fn:w=>{let{x:v,y:x}=w;return{x:v,y:x}}},...u}=sn(e,t),l={x:r,y:n},f=await s.detectOverflow(t,u),p=Jr(an(o)),m=Wa(p);let g=l[m],h=l[p];if(i){const w=m==="y"?"top":"left",v=m==="y"?"bottom":"right",x=g+f[w],E=g-f[v];g=Ha(x,g,E)}if(a){const w=p==="y"?"top":"left",v=p==="y"?"bottom":"right",x=h+f[w],E=h-f[v];h=Ha(x,h,E)}const y=d.fn({...t,[m]:g,[p]:h});return{...y,data:{x:y.x-r,y:y.y-n,enabled:{[m]:i,[p]:a}}}}}},Tw=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:d=!0,crossAxis:u=!0}=sn(e,t),l={x:r,y:n},f=Jr(o),p=Wa(f);let m=l[p],g=l[f];const h=sn(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(d){const x=p==="y"?"height":"width",E=s.reference[p]-s.floating[x]+y.mainAxis,P=s.reference[p]+s.reference[x]-y.mainAxis;m<E?m=E:m>P&&(m=P)}if(u){var w,v;const x=p==="y"?"width":"height",E=Eu.has(an(o)),P=s.reference[f]-s.floating[x]+(E&&((w=i.offset)==null?void 0:w[f])||0)+(E?0:y.crossAxis),_=s.reference[f]+s.reference[x]+(E?0:((v=i.offset)==null?void 0:v[f])||0)-(E?y.crossAxis:0);g<P?g=P:g>_&&(g=_)}return{[p]:m,[f]:g}}}},Fw=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:d=()=>{},...u}=sn(e,t),l=await i.detectOverflow(t,u),f=an(o),p=no(o),m=Jr(o)==="y",{width:g,height:h}=s.floating;let y,w;f==="top"||f==="bottom"?(y=f,w=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=f,y=p==="end"?"top":"bottom");const v=h-l.top-l.bottom,x=g-l.left-l.right,E=Cn(h-l[y],v),P=Cn(g-l[w],x),_=!t.middlewareData.shift;let N=E,C=P;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(C=x),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(N=v),_&&!p){const I=wr(l.left,0),T=wr(l.right,0),W=wr(l.top,0),X=wr(l.bottom,0);m?C=g-2*(I!==0||T!==0?I+T:wr(l.left,l.right)):N=h-2*(W!==0||X!==0?W+X:wr(l.top,l.bottom))}await d({...t,availableWidth:C,availableHeight:N});const A=await i.getDimensions(a.floating);return g!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}};function Xs(){return typeof window<"u"}function oo(e){return Nu(e)?(e.nodeName||"").toLowerCase():"#document"}function Sr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Qr(e){var t;return(t=(Nu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Nu(e){return Xs()?e instanceof Node||e instanceof Sr(e).Node:!1}function Ur(e){return Xs()?e instanceof Element||e instanceof Sr(e).Element:!1}function ln(e){return Xs()?e instanceof HTMLElement||e instanceof Sr(e).HTMLElement:!1}function _u(e){return!Xs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Sr(e).ShadowRoot}function Yo(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=Vr(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&o!=="inline"&&o!=="contents"}function Pw(e){return/^(table|td|th)$/.test(oo(e))}function Js(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Ow=/transform|translate|scale|rotate|perspective|filter/,Iw=/paint|layout|strict|content/,$n=e=>!!e&&e!=="none";let qa;function Ya(e){const t=Ur(e)?Vr(e):e;return $n(t.transform)||$n(t.translate)||$n(t.scale)||$n(t.rotate)||$n(t.perspective)||!Xa()&&($n(t.backdropFilter)||$n(t.filter))||Ow.test(t.willChange||"")||Iw.test(t.contain||"")}function Mw(e){let t=En(e);for(;ln(t)&&!so(t);){if(Ya(t))return t;if(Js(t))return null;t=En(t)}return null}function Xa(){return qa==null&&(qa=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),qa}function so(e){return/^(html|body|#document)$/.test(oo(e))}function Vr(e){return Sr(e).getComputedStyle(e)}function Qs(e){return Ur(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function En(e){if(oo(e)==="html")return e;const t=e.assignedSlot||e.parentNode||_u(e)&&e.host||Qr(e);return _u(t)?t.host:t}function ku(e){const t=En(e);return so(t)?e.ownerDocument?e.ownerDocument.body:e.body:ln(t)&&Yo(t)?t:ku(t)}function Xo(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const o=ku(e),s=o===((n=e.ownerDocument)==null?void 0:n.body),i=Sr(o);if(s){const a=Ja(i);return t.concat(i,i.visualViewport||[],Yo(o)?o:[],a&&r?Xo(a):[])}else return t.concat(o,Xo(o,[],r))}function Ja(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Tu(e){const t=Vr(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=ln(e),s=o?e.offsetWidth:r,i=o?e.offsetHeight:n,a=Gs(r)!==s||Gs(n)!==i;return a&&(r=s,n=i),{width:r,height:n,$:a}}function Qa(e){return Ur(e)?e:e.contextElement}function io(e){const t=Qa(e);if(!ln(t))return Xr(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:s}=Tu(t);let i=(s?Gs(r.width):r.width)/n,a=(s?Gs(r.height):r.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Lw=Xr(0);function Fu(e){const t=Sr(e);return!Xa()||!t.visualViewport?Lw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Dw(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Sr(e)?!1:t}function jn(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),s=Qa(e);let i=Xr(1);t&&(n?Ur(n)&&(i=io(n)):i=io(e));const a=Dw(s,r,n)?Fu(s):Xr(0);let d=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,l=o.width/i.x,f=o.height/i.y;if(s){const p=Sr(s),m=n&&Ur(n)?Sr(n):n;let g=p,h=Ja(g);for(;h&&n&&m!==g;){const y=io(h),w=h.getBoundingClientRect(),v=Vr(h),x=w.left+(h.clientLeft+parseFloat(v.paddingLeft))*y.x,E=w.top+(h.clientTop+parseFloat(v.paddingTop))*y.y;d*=y.x,u*=y.y,l*=y.x,f*=y.y,d+=x,u+=E,g=Sr(h),h=Ja(g)}}return Ys({width:l,height:f,x:d,y:u})}function Zs(e,t){const r=Qs(e).scrollLeft;return t?t.left+r:jn(Qr(e)).left+r}function Pu(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-Zs(e,r),o=r.top+t.scrollTop;return{x:n,y:o}}function Bw(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const s=o==="fixed",i=Qr(n),a=t?Js(t.floating):!1;if(n===i||a&&s)return r;let d={scrollLeft:0,scrollTop:0},u=Xr(1);const l=Xr(0),f=ln(n);if((f||!f&&!s)&&((oo(n)!=="body"||Yo(i))&&(d=Qs(n)),f)){const m=jn(n);u=io(n),l.x=m.x+n.clientLeft,l.y=m.y+n.clientTop}const p=i&&!f&&!s?Pu(i,d):Xr(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-d.scrollLeft*u.x+l.x+p.x,y:r.y*u.y-d.scrollTop*u.y+l.y+p.y}}function $w(e){return Array.from(e.getClientRects())}function jw(e){const t=Qr(e),r=Qs(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+Zs(e);const a=-r.scrollTop;return Vr(n).direction==="rtl"&&(i+=wr(t.clientWidth,n.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Ou=25;function zw(e,t){const r=Sr(e),n=Qr(e),o=r.visualViewport;let s=n.clientWidth,i=n.clientHeight,a=0,d=0;if(o){s=o.width,i=o.height;const l=Xa();(!l||l&&t==="fixed")&&(a=o.offsetLeft,d=o.offsetTop)}const u=Zs(n);if(u<=0){const l=n.ownerDocument,f=l.body,p=getComputedStyle(f),m=l.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(n.clientWidth-f.clientWidth-m);g<=Ou&&(s-=g)}else u<=Ou&&(s+=u);return{width:s,height:i,x:a,y:d}}function Uw(e,t){const r=jn(e,!0,t==="fixed"),n=r.top+e.clientTop,o=r.left+e.clientLeft,s=ln(e)?io(e):Xr(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,d=o*s.x,u=n*s.y;return{width:i,height:a,x:d,y:u}}function Iu(e,t,r){let n;if(t==="viewport")n=zw(e,r);else if(t==="document")n=jw(Qr(e));else if(Ur(t))n=Uw(t,r);else{const o=Fu(e);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ys(n)}function Mu(e,t){const r=En(e);return r===t||!Ur(r)||so(r)?!1:Vr(r).position==="fixed"||Mu(r,t)}function Vw(e,t){const r=t.get(e);if(r)return r;let n=Xo(e,[],!1).filter(a=>Ur(a)&&oo(a)!=="body"),o=null;const s=Vr(e).position==="fixed";let i=s?En(e):e;for(;Ur(i)&&!so(i);){const a=Vr(i),d=Ya(i);!d&&a.position==="fixed"&&(o=null),(s?!d&&!o:!d&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Yo(i)&&!d&&Mu(e,i))?n=n.filter(l=>l!==i):o=a,i=En(i)}return t.set(e,n),n}function Hw(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const i=[...r==="clippingAncestors"?Js(t)?[]:Vw(t,this._c):[].concat(r),n],a=Iu(t,i[0],o);let d=a.top,u=a.right,l=a.bottom,f=a.left;for(let p=1;p<i.length;p++){const m=Iu(t,i[p],o);d=wr(m.top,d),u=Cn(m.right,u),l=Cn(m.bottom,l),f=wr(m.left,f)}return{width:u-f,height:l-d,x:f,y:d}}function Ww(e){const{width:t,height:r}=Tu(e);return{width:t,height:r}}function Rw(e,t,r){const n=ln(t),o=Qr(t),s=r==="fixed",i=jn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const d=Xr(0);function u(){d.x=Zs(o)}if(n||!n&&!s)if((oo(t)!=="body"||Yo(o))&&(a=Qs(t)),n){const m=jn(t,!0,s,t);d.x=m.x+t.clientLeft,d.y=m.y+t.clientTop}else o&&u();s&&!n&&o&&u();const l=o&&!n&&!s?Pu(o,a):Xr(0),f=i.left+a.scrollLeft-d.x-l.x,p=i.top+a.scrollTop-d.y-l.y;return{x:f,y:p,width:i.width,height:i.height}}function Za(e){return Vr(e).position==="static"}function Lu(e,t){if(!ln(e)||Vr(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Qr(e)===r&&(r=r.ownerDocument.body),r}function Du(e,t){const r=Sr(e);if(Js(e))return r;if(!ln(e)){let o=En(e);for(;o&&!so(o);){if(Ur(o)&&!Za(o))return o;o=En(o)}return r}let n=Lu(e,t);for(;n&&Pw(n)&&Za(n);)n=Lu(n,t);return n&&so(n)&&Za(n)&&!Ya(n)?r:n||Mw(e)||r}const Gw=async function(e){const t=this.getOffsetParent||Du,r=this.getDimensions,n=await r(e.floating);return{reference:Rw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Kw(e){return Vr(e).direction==="rtl"}const qw={convertOffsetParentRelativeRectToViewportRelativeRect:Bw,getDocumentElement:Qr,getClippingRect:Hw,getOffsetParent:Du,getElementRects:Gw,getClientRects:$w,getDimensions:Ww,getScale:io,isElement:Ur,isRTL:Kw};function Bu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Yw(e,t){let r=null,n;const o=Qr(e);function s(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function i(a,d){a===void 0&&(a=!1),d===void 0&&(d=1),s();const u=e.getBoundingClientRect(),{left:l,top:f,width:p,height:m}=u;if(a||t(),!p||!m)return;const g=Ks(f),h=Ks(o.clientWidth-(l+p)),y=Ks(o.clientHeight-(f+m)),w=Ks(l),x={rootMargin:-g+"px "+-h+"px "+-y+"px "+-w+"px",threshold:wr(0,Cn(1,d))||1};let E=!0;function P(_){const N=_[0].intersectionRatio;if(N!==d){if(!E)return i();N?i(!1,N):n=setTimeout(()=>{i(!1,1e-7)},1e3)}N===1&&!Bu(u,e.getBoundingClientRect())&&i(),E=!1}try{r=new IntersectionObserver(P,{...x,root:o.ownerDocument})}catch{r=new IntersectionObserver(P,x)}r.observe(e)}return i(!0),s}function Xw(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:d=!1}=n,u=Qa(e),l=o||s?[...u?Xo(u):[],...t?Xo(t):[]]:[];l.forEach(w=>{o&&w.addEventListener("scroll",r,{passive:!0}),s&&w.addEventListener("resize",r)});const f=u&&a?Yw(u,r):null;let p=-1,m=null;i&&(m=new ResizeObserver(w=>{let[v]=w;v&&v.target===u&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=m)==null||x.observe(t)})),r()}),u&&!d&&m.observe(u),t&&m.observe(t));let g,h=d?jn(e):null;d&&y();function y(){const w=jn(e);h&&!Bu(h,w)&&r(),h=w,g=requestAnimationFrame(y)}return r(),()=>{var w;l.forEach(v=>{o&&v.removeEventListener("scroll",r),s&&v.removeEventListener("resize",r)}),f?.(),(w=m)==null||w.disconnect(),m=null,d&&cancelAnimationFrame(g)}}const Jw=_w,Qw=kw,Zw=Cw,eS=Fw,tS=Ew,$u=Aw,rS=Tw,nS=(e,t,r)=>{const n=new Map,o={platform:qw,...r},s={...o.platform,_c:n};return xw(e,t,{...o,platform:s})};var oS=typeof document<"u",sS=function(){},ei=oS?S.useLayoutEffect:sS;function ti(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(!ti(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)&&!ti(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function ju(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function zu(e,t){const r=ju(e);return Math.round(t*r)/r}function el(e){const t=b.useRef(e);return ei(()=>{t.current=e}),t}function iS(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:d,open:u}=e,[l,f]=b.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=b.useState(n);ti(p,n)||m(n);const[g,h]=b.useState(null),[y,w]=b.useState(null),v=b.useCallback(L=>{L!==_.current&&(_.current=L,h(L))},[]),x=b.useCallback(L=>{L!==N.current&&(N.current=L,w(L))},[]),E=s||g,P=i||y,_=b.useRef(null),N=b.useRef(null),C=b.useRef(l),A=d!=null,I=el(d),T=el(o),W=el(u),X=b.useCallback(()=>{if(!_.current||!N.current)return;const L={placement:t,strategy:r,middleware:p};T.current&&(L.platform=T.current),nS(_.current,N.current,L).then(U=>{const $={...U,isPositioned:W.current!==!1};O.current&&!ti(C.current,$)&&(C.current=$,Es.flushSync(()=>{f($)}))})},[p,t,r,T,W]);ei(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[u]);const O=b.useRef(!1);ei(()=>(O.current=!0,()=>{O.current=!1}),[]),ei(()=>{if(E&&(_.current=E),P&&(N.current=P),E&&P){if(I.current)return I.current(E,P,X);X()}},[E,P,X,I,A]);const j=b.useMemo(()=>({reference:_,floating:N,setReference:v,setFloating:x}),[v,x]),M=b.useMemo(()=>({reference:E,floating:P}),[E,P]),D=b.useMemo(()=>{const L={position:r,left:0,top:0};if(!M.floating)return L;const U=zu(M.floating,l.x),$=zu(M.floating,l.y);return a?{...L,transform:"translate("+U+"px, "+$+"px)",...ju(M.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:U,top:$}},[r,a,M.floating,l.x,l.y]);return b.useMemo(()=>({...l,update:X,refs:j,elements:M,floatingStyles:D}),[l,X,j,M,D])}const aS=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?$u({element:n.current,padding:o}).fn(r):{}:n?$u({element:n,padding:o}).fn(r):{}}}},lS=(e,t)=>{const r=Jw(e);return{name:r.name,fn:r.fn,options:[e,t]}},cS=(e,t)=>{const r=Qw(e);return{name:r.name,fn:r.fn,options:[e,t]}},dS=(e,t)=>({fn:rS(e).fn,options:[e,t]}),uS=(e,t)=>{const r=Zw(e);return{name:r.name,fn:r.fn,options:[e,t]}},fS=(e,t)=>{const r=eS(e);return{name:r.name,fn:r.fn,options:[e,t]}},pS=(e,t)=>{const r=tS(e);return{name:r.name,fn:r.fn,options:[e,t]}},mS=(e,t)=>{const r=aS(e);return{name:r.name,fn:r.fn,options:[e,t]}};var hS="Arrow",Uu=b.forwardRef((e,t)=>{const{children:r,width:n=10,height:o=5,...s}=e;return c.jsx(Be.svg,{...s,ref:t,width:n,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Uu.displayName=hS;var gS=Uu;function Jo(e){const[t,r]=b.useState(void 0);return Qt(()=>{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 d=s.borderBoxSize,u=Array.isArray(d)?d[0]:d;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 tl="Popper",[Vu,ri]=vr(tl),[yS,Hu]=Vu(tl),Wu=e=>{const{__scopePopper:t,children:r}=e,[n,o]=b.useState(null);return c.jsx(yS,{scope:t,anchor:n,onAnchorChange:o,children:r})};Wu.displayName=tl;var Ru="PopperAnchor",Gu=b.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...o}=e,s=Hu(Ru,r),i=b.useRef(null),a=Ze(t,i),d=b.useRef(null);return b.useEffect(()=>{const u=d.current;d.current=n?.current||i.current,u!==d.current&&s.onAnchorChange(d.current)}),n?null:c.jsx(Be.div,{...o,ref:a})});Gu.displayName=Ru;var rl="PopperContent",[bS,vS]=Vu(rl),Ku=b.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:l=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...h}=e,y=Hu(rl,r),[w,v]=b.useState(null),x=Ze(t,G=>v(G)),[E,P]=b.useState(null),_=Jo(E),N=_?.width??0,C=_?.height??0,A=n+(s!=="center"?"-"+s:""),I=typeof l=="number"?l:{top:0,right:0,bottom:0,left:0,...l},T=Array.isArray(u)?u:[u],W=T.length>0,X={padding:I,boundary:T.filter(SS),altBoundary:W},{refs:O,floatingStyles:j,placement:M,isPositioned:D,middlewareData:L}=iS({strategy:"fixed",placement:A,whileElementsMounted:(...G)=>Xw(...G,{animationFrame:m==="always"}),elements:{reference:y.anchor},middleware:[lS({mainAxis:o+C,alignmentAxis:i}),d&&cS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?dS():void 0,...X}),d&&uS({...X}),fS({...X,apply:({elements:G,rects:ee,availableWidth:Pe,availableHeight:oe})=>{const{width:re,height:be}=ee.reference,de=G.floating.style;de.setProperty("--radix-popper-available-width",`${Pe}px`),de.setProperty("--radix-popper-available-height",`${oe}px`),de.setProperty("--radix-popper-anchor-width",`${re}px`),de.setProperty("--radix-popper-anchor-height",`${be}px`)}}),E&&mS({element:E,padding:a}),xS({arrowWidth:N,arrowHeight:C}),p&&pS({strategy:"referenceHidden",...X})]}),[U,$]=Xu(M),ie=ar(g);Qt(()=>{D&&ie?.()},[D,ie]);const V=L.arrow?.x,K=L.arrow?.y,J=L.arrow?.centerOffset!==0,[ce,ne]=b.useState();return Qt(()=>{w&&ne(window.getComputedStyle(w).zIndex)},[w]),c.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...j,transform:D?j.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ce,"--radix-popper-transform-origin":[L.transformOrigin?.x,L.transformOrigin?.y].join(" "),...L.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(bS,{scope:r,placedSide:U,onArrowChange:P,arrowX:V,arrowY:K,shouldHideArrow:J,children:c.jsx(Be.div,{"data-side":U,"data-align":$,...h,ref:x,style:{...h.style,animation:D?void 0:"none"}})})})});Ku.displayName=rl;var qu="PopperArrow",wS={top:"bottom",right:"left",bottom:"top",left:"right"},Yu=b.forwardRef(function(t,r){const{__scopePopper:n,...o}=t,s=vS(qu,n),i=wS[s.placedSide];return c.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:c.jsx(gS,{...o,ref:r,style:{...o.style,display:"block"}})})});Yu.displayName=qu;function SS(e){return e!==null}var xS=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,d=i?0:e.arrowHeight,[u,l]=Xu(r),f={start:"0%",center:"50%",end:"100%"}[l],p=(o.arrow?.x??0)+a/2,m=(o.arrow?.y??0)+d/2;let g="",h="";return u==="bottom"?(g=i?f:`${p}px`,h=`${-d}px`):u==="top"?(g=i?f:`${p}px`,h=`${n.floating.height+d}px`):u==="right"?(g=`${-d}px`,h=i?f:`${m}px`):u==="left"&&(g=`${n.floating.width+d}px`,h=i?f:`${m}px`),{data:{x:g,y:h}}}});function Xu(e){const[t,r="center"]=e.split("-");return[t,r]}var Ju=Wu,nl=Gu,Qu=Ku,Zu=Yu,AS="Portal",ni=b.forwardRef((e,t)=>{const{container:r,...n}=e,[o,s]=b.useState(!1);Qt(()=>s(!0),[]);const i=r||o&&globalThis?.document?.body;return i?qc.createPortal(c.jsx(Be.div,{...n,ref:t}),i):null});ni.displayName=AS;function CS(e){const t=ES(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(_S);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function ES(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=TS(o),a=kS(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(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 NS=Symbol("radix.slottable");function _S(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===NS}function kS(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 d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function TS(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 FS=b[" useInsertionEffect ".trim().toString()]||Qt;function Zr({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[o,s,i]=PS({defaultProp:t,onChange:r}),a=e!==void 0,d=a?e:o;{const l=b.useRef(e!==void 0);b.useEffect(()=>{const f=l.current;f!==a&&console.warn(`${n} is changing from ${f?"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.`),l.current=a},[a,n])}const u=b.useCallback(l=>{if(a){const f=OS(l)?l(e):l;f!==e&&i.current?.(f)}else s(l)},[a,e,s,i]);return[d,u]}function PS({defaultProp:e,onChange:t}){const[r,n]=b.useState(e),o=b.useRef(r),s=b.useRef(t);return FS(()=>{s.current=t},[t]),b.useEffect(()=>{o.current!==r&&(s.current?.(r),o.current=r)},[r,o]),[r,n,s]}function OS(e){return typeof e=="function"}function Qo(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 ef=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"}),IS="VisuallyHidden",MS=b.forwardRef((e,t)=>c.jsx(Be.span,{...e,ref:t,style:{...ef,...e.style}}));MS.displayName=IS;var LS=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ao=new WeakMap,oi=new WeakMap,si={},ol=0,tf=function(e){return e&&(e.host||tf(e.parentNode))},DS=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=tf(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})},BS=function(e,t,r,n){var o=DS(t,Array.isArray(e)?e:[e]);si[r]||(si[r]=new WeakMap);var s=si[r],i=[],a=new Set,d=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var l=function(f){!f||d.has(f)||Array.prototype.forEach.call(f.children,function(p){if(a.has(p))l(p);else try{var m=p.getAttribute(n),g=m!==null&&m!=="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&&g&&oi.set(p,!0),y===1&&p.setAttribute(r,"true"),g||p.setAttribute(n,"true")}catch(w){console.error("aria-hidden: cannot operate on ",p,w)}})};return l(t),a.clear(),ol++,function(){i.forEach(function(f){var p=ao.get(f)-1,m=s.get(f)-1;ao.set(f,p),s.set(f,m),p||(oi.has(f)||f.removeAttribute(n),oi.delete(f)),m||f.removeAttribute(r)}),ol--,ol||(ao=new WeakMap,ao=new WeakMap,oi=new WeakMap,si={})}},sl=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),o=LS(e);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live], script"))),BS(n,o,r,"aria-hidden")):function(){return null}},en=function(){return en=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},en.apply(this,arguments)};function rf(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 $S(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 ii="right-scroll-bar-position",ai="width-before-scroll-bar",jS="with-scroll-bars-hidden",zS="--removed-body-scroll-bar-size";function il(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function US(e,t){var r=S.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 VS=typeof window<"u"?b.useLayoutEffect:b.useEffect,nf=new WeakMap;function HS(e,t){var r=US(null,function(n){return e.forEach(function(o){return il(o,n)})});return VS(function(){var n=nf.get(r);if(n){var o=new Set(n),s=new Set(e),i=r.current;o.forEach(function(a){s.has(a)||il(a,null)}),s.forEach(function(a){o.has(a)||il(a,i)})}nf.set(r,e)},[e]),r}function WS(e){return e}function RS(e,t){t===void 0&&(t=WS);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 d=function(){var l=i;i=[],l.forEach(s)},u=function(){return Promise.resolve().then(d)};u(),r={push:function(l){i.push(l),u()},filter:function(l){return i=i.filter(l),r}}}};return o}function GS(e){e===void 0&&(e={});var t=RS(null);return t.options=en({async:!0,ssr:!1},e),t}var of=function(e){var t=e.sideCar,r=rf(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,en({},r))};of.isSideCarExport=!0;function KS(e,t){return e.useMedium(t),of}var sf=GS(),al=function(){},li=b.forwardRef(function(e,t){var r=b.useRef(null),n=b.useState({onScrollCapture:al,onWheelCapture:al,onTouchMoveCapture:al}),o=n[0],s=n[1],i=e.forwardProps,a=e.children,d=e.className,u=e.removeScrollBar,l=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,g=e.noIsolation,h=e.inert,y=e.allowPinchZoom,w=e.as,v=w===void 0?"div":w,x=e.gapMode,E=rf(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=p,_=HS([r,t]),N=en(en({},E),o);return b.createElement(b.Fragment,null,l&&b.createElement(P,{sideCar:sf,removeScrollBar:u,shards:f,noRelative:m,noIsolation:g,inert:h,setCallbacks:s,allowPinchZoom:!!y,lockRef:r,gapMode:x}),i?b.cloneElement(b.Children.only(a),en(en({},N),{ref:_})):b.createElement(v,en({},N,{className:d,ref:_}),a))});li.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},li.classNames={fullWidth:ai,zeroRight:ii};var qS=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function YS(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=qS();return t&&e.setAttribute("nonce",t),e}function XS(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function JS(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var QS=function(){var e=0,t=null;return{add:function(r){e==0&&(t=YS())&&(XS(t,r),JS(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},ZS=function(){var e=QS();return function(t,r){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},af=function(){var e=ZS(),t=function(r){var n=r.styles,o=r.dynamic;return e(n,o),null};return t},ex={left:0,top:0,right:0,gap:0},ll=function(e){return parseInt(e||"",10)||0},tx=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[ll(r),ll(n),ll(o)]},rx=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ex;var t=tx(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])}},nx=af(),lo="data-scroll-locked",ox=function(e,t,r,n){var o=e.left,s=e.top,i=e.right,a=e.gap;return r===void 0&&(r="margin"),`
|
|
2
2
|
.`.concat(jS,` {
|
|
3
3
|
overflow: hidden `).concat(n,`;
|
|
4
4
|
padding-right: `).concat(a,"px ").concat(n,`;
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
`)},lf=function(){var e=parseInt(document.body.getAttribute(lo)||"0",10);return isFinite(e)?e:0},sx=function(){b.useEffect(function(){return document.body.setAttribute(lo,(lf()+1).toString()),function(){var e=lf()-1;e<=0?document.body.removeAttribute(lo):document.body.setAttribute(lo,e.toString())}},[])},ix=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,o=n===void 0?"margin":n;sx();var s=b.useMemo(function(){return rx(o)},[o]);return b.createElement(nx,{styles:ox(s,!t,o,r?"":"!important")})},cl=!1;if(typeof window<"u")try{var ci=Object.defineProperty({},"passive",{get:function(){return cl=!0,!0}});window.addEventListener("test",ci,ci),window.removeEventListener("test",ci,ci)}catch{cl=!1}var co=cl?{passive:!1}:!1,ax=function(e){return e.tagName==="TEXTAREA"},cf=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!ax(e)&&r[t]==="visible")},lx=function(e){return cf(e,"overflowY")},cx=function(e){return cf(e,"overflowX")},df=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var o=uf(e,n);if(o){var s=ff(e,n),i=s[1],a=s[2];if(i>a)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},dx=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},ux=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},uf=function(e,t){return e==="v"?lx(t):cx(t)},ff=function(e,t){return e==="v"?dx(t):ux(t)},fx=function(e,t){return e==="h"&&t==="rtl"?-1:1},px=function(e,t,r,n,o){var s=fx(e,window.getComputedStyle(t).direction),i=s*n,a=r.target,d=t.contains(a),u=!1,l=i>0,f=0,p=0;do{if(!a)break;var m=ff(e,a),g=m[0],h=m[1],y=m[2],w=h-y-s*g;(g||w)&&uf(e,a)&&(f+=w,p+=g);var v=a.parentNode;a=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!d&&a!==document.body||d&&(t.contains(a)||t===a));return(l&&Math.abs(f)<1||!l&&Math.abs(p)<1)&&(u=!0),u},di=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},pf=function(e){return[e.deltaX,e.deltaY]},mf=function(e){return e&&"current"in e?e.current:e},mx=function(e,t){return e[0]===t[0]&&e[1]===t[1]},hx=function(e){return`
|
|
39
39
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
40
40
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
41
|
-
`)},gx=0,uo=[];function yx(e){var t=b.useRef([]),r=b.useRef([0,0]),n=b.useRef(),o=b.useState(gx++)[0],s=b.useState(af)[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=$S([e.lockRef.current],(e.shards||[]).map(mf),!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 w=di(h),v=r.current,x="deltaX"in h?h.deltaX:v[0]-w[0],E="deltaY"in h?h.deltaY:v[1]-w[1],P,k=h.target,N=Math.abs(x)>Math.abs(E)?"h":"v";if("touches"in h&&N==="h"&&k.type==="range")return!1;var C=window.getSelection(),A=C&&C.anchorNode,I=A?A===k||A.contains(k):!1;if(I)return!1;var T=df(N,k);if(!T)return!0;if(T?P=N:(P=N==="v"?"h":"v",T=df(N,k)),!T)return!1;if(!n.current&&"changedTouches"in h&&(x||E)&&(n.current=P),!P)return!0;var W=n.current||P;return px(W,y,h,W==="h"?x:E)},[]),d=b.useCallback(function(h){var y=h;if(!(!uo.length||uo[uo.length-1]!==s)){var w="deltaY"in y?pf(y):di(y),v=t.current.filter(function(P){return P.name===y.type&&(P.target===y.target||y.target===P.shadowParent)&&mx(P.delta,w)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var x=(i.current.shards||[]).map(mf).filter(Boolean).filter(function(P){return P.contains(y.target)}),E=x.length>0?a(y,x[0]):!i.current.noIsolation;E&&y.cancelable&&y.preventDefault()}}},[]),u=b.useCallback(function(h,y,w,v){var x={name:h,delta:y,target:w,should:v,shadowParent:bx(w)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(E){return E!==x})},1)},[]),l=b.useCallback(function(h){r.current=di(h),n.current=void 0},[]),f=b.useCallback(function(h){u(h.type,pf(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 uo.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",d,co),document.addEventListener("touchmove",d,co),document.addEventListener("touchstart",l,co),function(){uo=uo.filter(function(h){return h!==s}),document.removeEventListener("wheel",d,co),document.removeEventListener("touchmove",d,co),document.removeEventListener("touchstart",l,co)}},[]);var m=e.removeScrollBar,g=e.inert;return b.createElement(b.Fragment,null,g?b.createElement(s,{styles:hx(o)}):null,m?b.createElement(ix,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function bx(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const vx=KS(sf,yx);var ui=b.forwardRef(function(e,t){return b.createElement(li,en({},e,{ref:t,sideCar:vx}))});ui.classNames=li.classNames;var wx=[" ","Enter","ArrowUp","ArrowDown"],Sx=[" ","Enter"],zn="Select",[fi,pi,xx]=Ba(zn),[fo]=vr(zn,[xx,ri]),mi=ri(),[Ax,Nn]=fo(zn),[Cx,Ex]=fo(zn),hf=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:d,dir:u,name:l,autoComplete:f,disabled:p,required:m,form:g}=e,h=mi(t),[y,w]=b.useState(null),[v,x]=b.useState(null),[E,P]=b.useState(!1),k=ro(u),[N,C]=Zr({prop:n,defaultProp:o??!1,onChange:s,caller:zn}),[A,I]=Zr({prop:i,defaultProp:a,onChange:d,caller:zn}),T=b.useRef(null),W=y?g||!!y.closest("form"):!0,[X,O]=b.useState(new Set),j=Array.from(X).map(M=>M.props.value).join(";");return c.jsx(Ju,{...h,children:c.jsxs(Ax,{required:m,scope:t,trigger:y,onTriggerChange:w,valueNode:v,onValueNodeChange:x,valueNodeHasChildren:E,onValueNodeHasChildrenChange:P,contentId:on(),value:A,onValueChange:I,open:N,onOpenChange:C,dir:k,triggerPointerDownPosRef:T,disabled:p,children:[c.jsx(fi.Provider,{scope:t,children:c.jsx(Cx,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(M=>{O(D=>new Set(D).add(M))},[]),onNativeOptionRemove:b.useCallback(M=>{O(D=>{const L=new Set(D);return L.delete(M),L})},[]),children:r})}),W?c.jsxs(Bf,{"aria-hidden":!0,required:m,tabIndex:-1,name:l,autoComplete:f,value:A,onChange:M=>I(M.target.value),disabled:p,form:g,children:[A===void 0?c.jsx("option",{value:""}):null,Array.from(X)]},j):null]})})};hf.displayName=zn;var gf="SelectTrigger",yf=b.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...o}=e,s=mi(r),i=Nn(gf,r),a=i.disabled||n,d=Ze(t,i.onTriggerChange),u=pi(r),l=b.useRef("touch"),[f,p,m]=jf(h=>{const y=u().filter(x=>!x.disabled),w=y.find(x=>x.value===i.value),v=zf(y,h,w);v!==void 0&&i.onValueChange(v.value)}),g=h=>{a||(i.onOpenChange(!0),m()),h&&(i.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return c.jsx(nl,{asChild:!0,...s,children:c.jsx(Be.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":$f(i.value)?"":void 0,...o,ref:d,onClick:Me(o.onClick,h=>{h.currentTarget.focus(),l.current!=="mouse"&&g(h)}),onPointerDown:Me(o.onPointerDown,h=>{l.current=h.pointerType;const y=h.target;y.hasPointerCapture(h.pointerId)&&y.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(g(h),h.preventDefault())}),onKeyDown:Me(o.onKeyDown,h=>{const y=f.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&p(h.key),!(y&&h.key===" ")&&wx.includes(h.key)&&(g(),h.preventDefault())})})})});yf.displayName=gf;var bf="SelectValue",vf=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,children:s,placeholder:i="",...a}=e,d=Nn(bf,r),{onValueNodeHasChildrenChange:u}=d,l=s!==void 0,f=Ze(t,d.onValueNodeChange);return Qt(()=>{u(l)},[u,l]),c.jsx(Be.span,{...a,ref:f,style:{pointerEvents:"none"},children:$f(d.value)?c.jsx(c.Fragment,{children:i}):s})});vf.displayName=bf;var Nx="SelectIcon",wf=b.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...o}=e;return c.jsx(Be.span,{"aria-hidden":!0,...o,ref:t,children:n||"▼"})});wf.displayName=Nx;var _x="SelectPortal",Sf=e=>c.jsx(ni,{asChild:!0,...e});Sf.displayName=_x;var Un="SelectContent",xf=b.forwardRef((e,t)=>{const r=Nn(Un,e.__scopeSelect),[n,o]=b.useState();if(Qt(()=>{o(new DocumentFragment)},[]),!r.open){const s=n;return s?Es.createPortal(c.jsx(Af,{scope:e.__scopeSelect,children:c.jsx(fi.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Cf,{...e,ref:t})});xf.displayName=Un;var Hr=10,[Af,_n]=fo(Un),kx="SelectContentImpl",Tx=CS("SelectContent.RemoveScroll"),Cf=b.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:d,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y,...w}=e,v=Nn(Un,r),[x,E]=b.useState(null),[P,k]=b.useState(null),N=Ze(t,G=>E(G)),[C,A]=b.useState(null),[I,T]=b.useState(null),W=pi(r),[X,O]=b.useState(!1),j=b.useRef(!1);b.useEffect(()=>{if(x)return sl(x)},[x]),za();const M=b.useCallback(G=>{const[ee,...Pe]=W().map(be=>be.ref.current),[oe]=Pe.slice(-1),re=document.activeElement;for(const be of G)if(be===re||(be?.scrollIntoView({block:"nearest"}),be===ee&&P&&(P.scrollTop=0),be===oe&&P&&(P.scrollTop=P.scrollHeight),be?.focus(),document.activeElement!==re))return},[W,P]),D=b.useCallback(()=>M([C,x]),[M,C,x]);b.useEffect(()=>{X&&D()},[X,D]);const{onOpenChange:L,triggerPointerDownPosRef:U}=v;b.useEffect(()=>{if(x){let G={x:0,y:0};const ee=oe=>{G={x:Math.abs(Math.round(oe.pageX)-(U.current?.x??0)),y:Math.abs(Math.round(oe.pageY)-(U.current?.y??0))}},Pe=oe=>{G.x<=10&&G.y<=10?oe.preventDefault():x.contains(oe.target)||L(!1),document.removeEventListener("pointermove",ee),U.current=null};return U.current!==null&&(document.addEventListener("pointermove",ee),document.addEventListener("pointerup",Pe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ee),document.removeEventListener("pointerup",Pe,{capture:!0})}}},[x,L,U]),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[$,ie]=jf(G=>{const ee=W().filter(re=>!re.disabled),Pe=ee.find(re=>re.ref.current===document.activeElement),oe=zf(ee,G,Pe);oe&&setTimeout(()=>oe.ref.current.focus())}),V=b.useCallback((G,ee,Pe)=>{const oe=!j.current&&!Pe;(v.value!==void 0&&v.value===ee||oe)&&(A(G),oe&&(j.current=!0))},[v.value]),K=b.useCallback(()=>x?.focus(),[x]),J=b.useCallback((G,ee,Pe)=>{const oe=!j.current&&!Pe;(v.value!==void 0&&v.value===ee||oe)&&T(G)},[v.value]),ce=n==="popper"?dl:Ef,ne=ce===dl?{side:a,sideOffset:d,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y}:{};return c.jsx(Af,{scope:r,content:x,viewport:P,onViewportChange:k,itemRefCallback:V,selectedItem:C,onItemLeave:K,itemTextRefCallback:J,focusSelectedItem:D,selectedItemText:I,position:n,isPositioned:X,searchRef:$,children:c.jsx(ui,{as:Tx,allowPinchZoom:!0,children:c.jsx(Rs,{asChild:!0,trapped:v.open,onMountAutoFocus:G=>{G.preventDefault()},onUnmountAutoFocus:Me(o,G=>{v.trigger?.focus({preventScroll:!0}),G.preventDefault()}),children:c.jsx(Ws,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:G=>G.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:c.jsx(ce,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:G=>G.preventDefault(),...w,...ne,onPlaced:()=>O(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:Me(w.onKeyDown,G=>{const ee=G.ctrlKey||G.altKey||G.metaKey;if(G.key==="Tab"&&G.preventDefault(),!ee&&G.key.length===1&&ie(G.key),["ArrowUp","ArrowDown","Home","End"].includes(G.key)){let oe=W().filter(re=>!re.disabled).map(re=>re.ref.current);if(["ArrowUp","End"].includes(G.key)&&(oe=oe.slice().reverse()),["ArrowUp","ArrowDown"].includes(G.key)){const re=G.target,be=oe.indexOf(re);oe=oe.slice(be+1)}setTimeout(()=>M(oe)),G.preventDefault()}})})})})})})});Cf.displayName=kx;var Fx="SelectItemAlignedPosition",Ef=b.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...o}=e,s=Nn(Un,r),i=_n(Un,r),[a,d]=b.useState(null),[u,l]=b.useState(null),f=Ze(t,N=>l(N)),p=pi(r),m=b.useRef(!1),g=b.useRef(!0),{viewport:h,selectedItem:y,selectedItemText:w,focusSelectedItem:v}=i,x=b.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&h&&y&&w){const N=s.trigger.getBoundingClientRect(),C=u.getBoundingClientRect(),A=s.valueNode.getBoundingClientRect(),I=w.getBoundingClientRect();if(s.dir!=="rtl"){const re=I.left-C.left,be=A.left-re,de=N.left-be,ot=N.width+de,Se=Math.max(ot,C.width),xe=window.innerWidth-Hr,ae=qo(be,[Hr,Math.max(Hr,xe-Se)]);a.style.minWidth=ot+"px",a.style.left=ae+"px"}else{const re=C.right-I.right,be=window.innerWidth-A.right-re,de=window.innerWidth-N.right-be,ot=N.width+de,Se=Math.max(ot,C.width),xe=window.innerWidth-Hr,ae=qo(be,[Hr,Math.max(Hr,xe-Se)]);a.style.minWidth=ot+"px",a.style.right=ae+"px"}const T=p(),W=window.innerHeight-Hr*2,X=h.scrollHeight,O=window.getComputedStyle(u),j=parseInt(O.borderTopWidth,10),M=parseInt(O.paddingTop,10),D=parseInt(O.borderBottomWidth,10),L=parseInt(O.paddingBottom,10),U=j+M+X+L+D,$=Math.min(y.offsetHeight*5,U),ie=window.getComputedStyle(h),V=parseInt(ie.paddingTop,10),K=parseInt(ie.paddingBottom,10),J=N.top+N.height/2-Hr,ce=W-J,ne=y.offsetHeight/2,G=y.offsetTop+ne,ee=j+M+G,Pe=U-ee;if(ee<=J){const re=T.length>0&&y===T[T.length-1].ref.current;a.style.bottom="0px";const be=u.clientHeight-h.offsetTop-h.offsetHeight,de=Math.max(ce,ne+(re?K:0)+be+D),ot=ee+de;a.style.height=ot+"px"}else{const re=T.length>0&&y===T[0].ref.current;a.style.top="0px";const de=Math.max(J,j+h.offsetTop+(re?V:0)+ne)+Pe;a.style.height=de+"px",h.scrollTop=ee-J+h.offsetTop}a.style.margin=`${Hr}px 0`,a.style.minHeight=$+"px",a.style.maxHeight=W+"px",n?.(),requestAnimationFrame(()=>m.current=!0)}},[p,s.trigger,s.valueNode,a,u,h,y,w,s.dir,n]);Qt(()=>x(),[x]);const[E,P]=b.useState();Qt(()=>{u&&P(window.getComputedStyle(u).zIndex)},[u]);const k=b.useCallback(N=>{N&&g.current===!0&&(x(),v?.(),g.current=!1)},[x,v]);return c.jsx(Ox,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:k,children:c.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(Be.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ef.displayName=Fx;var Px="SelectPopperPosition",dl=b.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:o=Hr,...s}=e,i=mi(r);return c.jsx(Qu,{...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)"}})});dl.displayName=Px;var[Ox,ul]=fo(Un,{}),fl="SelectViewport",Nf=b.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...o}=e,s=_n(fl,r),i=ul(fl,r),a=Ze(t,s.onViewportChange),d=b.useRef(0);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(fi.Slot,{scope:r,children:c.jsx(Be.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Me(o.onScroll,u=>{const l=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p?.current&&f){const m=Math.abs(d.current-l.scrollTop);if(m>0){const g=window.innerHeight-Hr*2,h=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),w=Math.max(h,y);if(w<g){const v=w+m,x=Math.min(g,v),E=v-x;f.style.height=x+"px",f.style.bottom==="0px"&&(l.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}d.current=l.scrollTop})})})]})});Nf.displayName=fl;var _f="SelectGroup",[Ix,Mx]=fo(_f),Lx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=on();return c.jsx(Ix,{scope:r,id:o,children:c.jsx(Be.div,{role:"group","aria-labelledby":o,...n,ref:t})})});Lx.displayName=_f;var kf="SelectLabel",Dx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=Mx(kf,r);return c.jsx(Be.div,{id:o.id,...n,ref:t})});Dx.displayName=kf;var hi="SelectItem",[Bx,Tf]=fo(hi),Ff=b.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:o=!1,textValue:s,...i}=e,a=Nn(hi,r),d=_n(hi,r),u=a.value===n,[l,f]=b.useState(s??""),[p,m]=b.useState(!1),g=Ze(t,v=>d.itemRefCallback?.(v,n,o)),h=on(),y=b.useRef("touch"),w=()=>{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 c.jsx(Bx,{scope:r,value:n,disabled:o,textId:h,isSelected:u,onItemTextChange:b.useCallback(v=>{f(x=>x||(v?.textContent??"").trim())},[]),children:c.jsx(fi.ItemSlot,{scope:r,value:n,disabled:o,textValue:l,children:c.jsx(Be.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:g,onFocus:Me(i.onFocus,()=>m(!0)),onBlur:Me(i.onBlur,()=>m(!1)),onClick:Me(i.onClick,()=>{y.current!=="mouse"&&w()}),onPointerUp:Me(i.onPointerUp,()=>{y.current==="mouse"&&w()}),onPointerDown:Me(i.onPointerDown,v=>{y.current=v.pointerType}),onPointerMove:Me(i.onPointerMove,v=>{y.current=v.pointerType,o?d.onItemLeave?.():y.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Me(i.onPointerLeave,v=>{v.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:Me(i.onKeyDown,v=>{d.searchRef?.current!==""&&v.key===" "||(Sx.includes(v.key)&&w(),v.key===" "&&v.preventDefault())})})})})});Ff.displayName=hi;var Zo="SelectItemText",Pf=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,...s}=e,i=Nn(Zo,r),a=_n(Zo,r),d=Tf(Zo,r),u=Ex(Zo,r),[l,f]=b.useState(null),p=Ze(t,w=>f(w),d.onItemTextChange,w=>a.itemTextRefCallback?.(w,d.value,d.disabled)),m=l?.textContent,g=b.useMemo(()=>c.jsx("option",{value:d.value,disabled:d.disabled,children:m},d.value),[d.disabled,d.value,m]),{onNativeOptionAdd:h,onNativeOptionRemove:y}=u;return Qt(()=>(h(g),()=>y(g)),[h,y,g]),c.jsxs(c.Fragment,{children:[c.jsx(Be.span,{id:d.textId,...s,ref:p}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Es.createPortal(s.children,i.valueNode):null]})});Pf.displayName=Zo;var Of="SelectItemIndicator",If=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return Tf(Of,r).isSelected?c.jsx(Be.span,{"aria-hidden":!0,...n,ref:t}):null});If.displayName=Of;var pl="SelectScrollUpButton",Mf=b.forwardRef((e,t)=>{const r=_n(pl,e.__scopeSelect),n=ul(pl,e.__scopeSelect),[o,s]=b.useState(!1),i=Ze(t,n.onScrollButtonChange);return Qt(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=d.scrollTop>0;s(u)};const d=r.viewport;return a(),d.addEventListener("scroll",a),()=>d.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?c.jsx(Df,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:d}=r;a&&d&&(a.scrollTop=a.scrollTop-d.offsetHeight)}}):null});Mf.displayName=pl;var ml="SelectScrollDownButton",Lf=b.forwardRef((e,t)=>{const r=_n(ml,e.__scopeSelect),n=ul(ml,e.__scopeSelect),[o,s]=b.useState(!1),i=Ze(t,n.onScrollButtonChange);return Qt(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=d.scrollHeight-d.clientHeight,l=Math.ceil(d.scrollTop)<u;s(l)};const d=r.viewport;return a(),d.addEventListener("scroll",a),()=>d.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?c.jsx(Df,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:d}=r;a&&d&&(a.scrollTop=a.scrollTop+d.offsetHeight)}}):null});Lf.displayName=ml;var Df=b.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...o}=e,s=_n("SelectScrollButton",r),i=b.useRef(null),a=pi(r),d=b.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return b.useEffect(()=>()=>d(),[d]),Qt(()=>{a().find(l=>l.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),c.jsx(Be.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Me(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(n,50))}),onPointerMove:Me(o.onPointerMove,()=>{s.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(n,50))}),onPointerLeave:Me(o.onPointerLeave,()=>{d()})})}),$x="SelectSeparator",jx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return c.jsx(Be.div,{"aria-hidden":!0,...n,ref:t})});jx.displayName=$x;var hl="SelectArrow",zx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=mi(r),s=Nn(hl,r),i=_n(hl,r);return s.open&&i.position==="popper"?c.jsx(Zu,{...o,...n,ref:t}):null});zx.displayName=hl;var Ux="SelectBubbleInput",Bf=b.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const o=b.useRef(null),s=Ze(n,o),i=Qo(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const d=window.HTMLSelectElement.prototype,l=Object.getOwnPropertyDescriptor(d,"value").set;if(i!==t&&l){const f=new Event("change",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Be.select,{...r,style:{...ef,...r.style},ref:s,defaultValue:t})});Bf.displayName=Ux;function $f(e){return e===""||e===void 0}function jf(e){const t=ar(e),r=b.useRef(""),n=b.useRef(0),o=b.useCallback(i=>{const a=r.current+i;t(a),(function d(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>d(""),1e3))})(a)},[t]),s=b.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,o,s]}function zf(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=Vx(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==r));const d=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==r?d:void 0}function Vx(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Hx=hf,Wx=yf,Rx=vf,Gx=wf,Kx=Sf,qx=xf,Yx=Nf,Xx=Ff,Jx=Pf,Qx=If,Zx=Mf,e0=Lf;function t0({...e}){return c.jsx(Hx,{"data-slot":"select",...e})}function r0({className:e,...t}){return c.jsx(Rx,{"data-slot":"select-value",className:B("truncate min-w-0",e),...t})}function n0({className:e,size:t="default",children:r,...n}){const o=e?.includes("w-full");return c.jsxs(Wx,{"data-slot":"select-trigger","data-size":t,className:B("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,c.jsx(Gx,{asChild:!0,children:c.jsx(Wo,{className:"size-4 opacity-50"})})]})}function o0({className:e,children:t,position:r="popper",...n}){return c.jsx(Kx,{children:c.jsxs(qx,{"data-slot":"select-content",className:B("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:[c.jsx(s0,{}),c.jsx(Yx,{className:B("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),c.jsx(i0,{})]})})}function gl({className:e,children:t,...r}){return c.jsxs(Xx,{"data-slot":"select-item",className:B("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:[c.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:c.jsx(Qx,{children:c.jsx(Vs,{className:"size-4"})})}),c.jsx(Jx,{className:"truncate",children:t})]})}function s0({className:e,...t}){return c.jsx(Zx,{"data-slot":"select-scroll-up-button",className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Nv,{className:"size-4"})})}function i0({className:e,...t}){return c.jsx(e0,{"data-slot":"select-scroll-down-button",className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Wo,{className:"size-4"})})}function Uf(e,t){return function(){return e.apply(t,arguments)}}const{toString:a0}=Object.prototype,{getPrototypeOf:yl}=Object,{iterator:gi,toStringTag:Vf}=Symbol,yi=(e=>t=>{const r=a0.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Wr=e=>(e=e.toLowerCase(),t=>yi(t)===e),bi=e=>t=>typeof t===e,{isArray:po}=Array,mo=bi("undefined");function es(e){return e!==null&&!mo(e)&&e.constructor!==null&&!mo(e.constructor)&&pr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Hf=Wr("ArrayBuffer");function l0(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Hf(e.buffer),t}const c0=bi("string"),pr=bi("function"),Wf=bi("number"),ts=e=>e!==null&&typeof e=="object",d0=e=>e===!0||e===!1,vi=e=>{if(yi(e)!=="object")return!1;const t=yl(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Vf in e)&&!(gi in e)},u0=e=>{if(!ts(e)||es(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},f0=Wr("Date"),p0=Wr("File"),m0=e=>!!(e&&typeof e.uri<"u"),h0=e=>e&&typeof e.getParts<"u",g0=Wr("Blob"),y0=Wr("FileList"),b0=e=>ts(e)&&pr(e.pipe);function v0(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Rf=v0(),Gf=typeof Rf.FormData<"u"?Rf.FormData:void 0,w0=e=>{let t;return e&&(Gf&&e instanceof Gf||pr(e.append)&&((t=yi(e))==="formdata"||t==="object"&&pr(e.toString)&&e.toString()==="[object FormData]"))},S0=Wr("URLSearchParams"),[x0,A0,C0,E0]=["ReadableStream","Request","Response","Headers"].map(Wr),N0=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function rs(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),po(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(es(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 Kf(e,t){if(es(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 Vn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,qf=e=>!mo(e)&&e!==Vn;function bl(){const{caseless:e,skipUndefined:t}=qf(this)&&this||{},r={},n=(o,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;const i=e&&Kf(r,s)||s;vi(r[i])&&vi(o)?r[i]=bl(r[i],o):vi(o)?r[i]=bl({},o):po(o)?r[i]=o.slice():(!t||!mo(o))&&(r[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&rs(arguments[o],n);return r}const _0=(e,t,r,{allOwnKeys:n}={})=>(rs(t,(o,s)=>{r&&pr(o)?Object.defineProperty(e,s,{value:Uf(o,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,s,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),k0=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),T0=(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)},F0=(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&&yl(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},P0=(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},O0=e=>{if(!e)return null;if(po(e))return e;let t=e.length;if(!Wf(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},I0=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&yl(Uint8Array)),M0=(e,t)=>{const n=(e&&e[gi]).call(e);let o;for(;(o=n.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},L0=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},D0=Wr("HTMLFormElement"),B0=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),Yf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),$0=Wr("RegExp"),Xf=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};rs(r,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(n[s]=i||o)}),Object.defineProperties(e,n)},j0=e=>{Xf(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+"'")})}})},z0=(e,t)=>{const r={},n=o=>{o.forEach(s=>{r[s]=!0})};return po(e)?n(e):n(String(e).split(t)),r},U0=()=>{},V0=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function H0(e){return!!(e&&pr(e.append)&&e[Vf]==="FormData"&&e[gi])}const W0=e=>{const t=new Array(10),r=(n,o)=>{if(ts(n)){if(t.indexOf(n)>=0)return;if(es(n))return n;if(!("toJSON"in n)){t[o]=n;const s=po(n)?[]:{};return rs(n,(i,a)=>{const d=r(i,o+1);!mo(d)&&(s[a]=d)}),t[o]=void 0,s}}return n};return r(e,0)},R0=Wr("AsyncFunction"),G0=e=>e&&(ts(e)||pr(e))&&pr(e.then)&&pr(e.catch),Jf=((e,t)=>e?setImmediate:t?((r,n)=>(Vn.addEventListener("message",({source:o,data:s})=>{o===Vn&&s===r&&n.length&&n.shift()()},!1),o=>{n.push(o),Vn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",pr(Vn.postMessage)),K0=typeof queueMicrotask<"u"?queueMicrotask.bind(Vn):typeof process<"u"&&process.nextTick||Jf,R={isArray:po,isArrayBuffer:Hf,isBuffer:es,isFormData:w0,isArrayBufferView:l0,isString:c0,isNumber:Wf,isBoolean:d0,isObject:ts,isPlainObject:vi,isEmptyObject:u0,isReadableStream:x0,isRequest:A0,isResponse:C0,isHeaders:E0,isUndefined:mo,isDate:f0,isFile:p0,isReactNativeBlob:m0,isReactNative:h0,isBlob:g0,isRegExp:$0,isFunction:pr,isStream:b0,isURLSearchParams:S0,isTypedArray:I0,isFileList:y0,forEach:rs,merge:bl,extend:_0,trim:N0,stripBOM:k0,inherits:T0,toFlatObject:F0,kindOf:yi,kindOfTest:Wr,endsWith:P0,toArray:O0,forEachEntry:M0,matchAll:L0,isHTMLForm:D0,hasOwnProperty:Yf,hasOwnProp:Yf,reduceDescriptors:Xf,freezeMethods:j0,toObjectSet:z0,toCamelCase:B0,noop:U0,toFiniteNumber:V0,findKey:Kf,global:Vn,isContextDefined:qf,isSpecCompliantForm:H0,toJSONObject:W0,isAsyncFn:R0,isThenable:G0,setImmediate:Jf,asap:K0,isIterable:e=>e!=null&&pr(e[gi])};let qe=class Ty extends Error{static from(t,r,n,o,s,i){const a=new Ty(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:R.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 q0=null;function vl(e){return R.isPlainObject(e)||R.isArray(e)}function Qf(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function wl(e,t,r){return e?e.concat(t).map(function(o,s){return o=Qf(o),!r&&s?"["+o+"]":o}).join(r?".":""):t}function Y0(e){return R.isArray(e)&&!e.some(vl)}const X0=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function wi(e,t,r){if(!R.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=R.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,y){return!R.isUndefined(y[h])});const n=r.metaTokens,o=r.visitor||l,s=r.dots,i=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&R.isSpecCompliantForm(t);if(!R.isFunction(o))throw new TypeError("visitor must be a function");function u(g){if(g===null)return"";if(R.isDate(g))return g.toISOString();if(R.isBoolean(g))return g.toString();if(!d&&R.isBlob(g))throw new qe("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(g)||R.isTypedArray(g)?d&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function l(g,h,y){let w=g;if(R.isReactNative(t)&&R.isReactNativeBlob(g))return t.append(wl(y,h,s),u(g)),!1;if(g&&!y&&typeof g=="object"){if(R.endsWith(h,"{}"))h=n?h:h.slice(0,-2),g=JSON.stringify(g);else if(R.isArray(g)&&Y0(g)||(R.isFileList(g)||R.endsWith(h,"[]"))&&(w=R.toArray(g)))return h=Qf(h),w.forEach(function(x,E){!(R.isUndefined(x)||x===null)&&t.append(i===!0?wl([h],E,s):i===null?h:h+"[]",u(x))}),!1}return vl(g)?!0:(t.append(wl(y,h,s),u(g)),!1)}const f=[],p=Object.assign(X0,{defaultVisitor:l,convertValue:u,isVisitable:vl});function m(g,h){if(!R.isUndefined(g)){if(f.indexOf(g)!==-1)throw Error("Circular reference detected in "+h.join("."));f.push(g),R.forEach(g,function(w,v){(!(R.isUndefined(w)||w===null)&&o.call(t,w,R.isString(v)?v.trim():v,h,p))===!0&&m(w,h?h.concat(v):[v])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return m(e),t}function Zf(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Sl(e,t){this._pairs=[],e&&wi(e,this,t)}const ep=Sl.prototype;ep.append=function(t,r){this._pairs.push([t,r])},ep.toString=function(t){const r=t?function(n){return t.call(this,n,Zf)}:Zf;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function J0(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function tp(e,t,r){if(!t)return e;const n=r&&r.encode||J0,o=R.isFunction(r)?{serialize:r}:r,s=o&&o.serialize;let i;if(s?i=s(t,o):i=R.isURLSearchParams(t)?t.toString():new Sl(t,o).toString(n),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class rp{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){R.forEach(this.handlers,function(n){n!==null&&t(n)})}}const xl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Q0={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Sl,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Al=typeof window<"u"&&typeof document<"u",Cl=typeof navigator=="object"&&navigator||void 0,Z0=Al&&(!Cl||["ReactNative","NativeScript","NS"].indexOf(Cl.product)<0),eA=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",tA=Al&&window.location.href||"http://localhost",nr={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Al,hasStandardBrowserEnv:Z0,hasStandardBrowserWebWorkerEnv:eA,navigator:Cl,origin:tA},Symbol.toStringTag,{value:"Module"})),...Q0};function rA(e,t){return wi(e,new nr.classes.URLSearchParams,{visitor:function(r,n,o,s){return nr.isNode&&R.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function nA(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function oA(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 np(e){function t(r,n,o,s){let i=r[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),d=s>=r.length;return i=!i&&R.isArray(o)?o.length:i,d?(R.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!a):((!o[i]||!R.isObject(o[i]))&&(o[i]=[]),t(r,n,o[i],s)&&R.isArray(o[i])&&(o[i]=oA(o[i])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const r={};return R.forEachEntry(e,(n,o)=>{t(nA(n),o,r,0)}),r}return null}function sA(e,t,r){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const ns={transitional:xl,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",o=n.indexOf("application/json")>-1,s=R.isObject(t);if(s&&R.isHTMLForm(t)&&(t=new FormData(t)),R.isFormData(t))return o?JSON.stringify(np(t)):t;if(R.isArrayBuffer(t)||R.isBuffer(t)||R.isStream(t)||R.isFile(t)||R.isBlob(t)||R.isReadableStream(t))return t;if(R.isArrayBufferView(t))return t.buffer;if(R.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 rA(t,this.formSerializer).toString();if((a=R.isFileList(t))||n.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return wi(a?{"files[]":t}:t,d&&new d,this.formSerializer)}}return s||o?(r.setContentType("application/json",!1),sA(t)):t}],transformResponse:[function(t){const r=this.transitional||ns.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(R.isResponse(t)||R.isReadableStream(t))return t;if(t&&R.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:nr.classes.FormData,Blob:nr.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};R.forEach(["delete","get","head","post","put","patch"],e=>{ns.headers[e]={}});const iA=R.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"]),aA=e=>{const t={};let r,n,o;return e&&e.split(`
|
|
41
|
+
`)},gx=0,uo=[];function yx(e){var t=b.useRef([]),r=b.useRef([0,0]),n=b.useRef(),o=b.useState(gx++)[0],s=b.useState(af)[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=$S([e.lockRef.current],(e.shards||[]).map(mf),!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 w=di(h),v=r.current,x="deltaX"in h?h.deltaX:v[0]-w[0],E="deltaY"in h?h.deltaY:v[1]-w[1],P,_=h.target,N=Math.abs(x)>Math.abs(E)?"h":"v";if("touches"in h&&N==="h"&&_.type==="range")return!1;var C=window.getSelection(),A=C&&C.anchorNode,I=A?A===_||A.contains(_):!1;if(I)return!1;var T=df(N,_);if(!T)return!0;if(T?P=N:(P=N==="v"?"h":"v",T=df(N,_)),!T)return!1;if(!n.current&&"changedTouches"in h&&(x||E)&&(n.current=P),!P)return!0;var W=n.current||P;return px(W,y,h,W==="h"?x:E)},[]),d=b.useCallback(function(h){var y=h;if(!(!uo.length||uo[uo.length-1]!==s)){var w="deltaY"in y?pf(y):di(y),v=t.current.filter(function(P){return P.name===y.type&&(P.target===y.target||y.target===P.shadowParent)&&mx(P.delta,w)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var x=(i.current.shards||[]).map(mf).filter(Boolean).filter(function(P){return P.contains(y.target)}),E=x.length>0?a(y,x[0]):!i.current.noIsolation;E&&y.cancelable&&y.preventDefault()}}},[]),u=b.useCallback(function(h,y,w,v){var x={name:h,delta:y,target:w,should:v,shadowParent:bx(w)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(E){return E!==x})},1)},[]),l=b.useCallback(function(h){r.current=di(h),n.current=void 0},[]),f=b.useCallback(function(h){u(h.type,pf(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 uo.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",d,co),document.addEventListener("touchmove",d,co),document.addEventListener("touchstart",l,co),function(){uo=uo.filter(function(h){return h!==s}),document.removeEventListener("wheel",d,co),document.removeEventListener("touchmove",d,co),document.removeEventListener("touchstart",l,co)}},[]);var m=e.removeScrollBar,g=e.inert;return b.createElement(b.Fragment,null,g?b.createElement(s,{styles:hx(o)}):null,m?b.createElement(ix,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function bx(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const vx=KS(sf,yx);var ui=b.forwardRef(function(e,t){return b.createElement(li,en({},e,{ref:t,sideCar:vx}))});ui.classNames=li.classNames;var wx=[" ","Enter","ArrowUp","ArrowDown"],Sx=[" ","Enter"],zn="Select",[fi,pi,xx]=Ba(zn),[fo]=vr(zn,[xx,ri]),mi=ri(),[Ax,Nn]=fo(zn),[Cx,Ex]=fo(zn),hf=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:d,dir:u,name:l,autoComplete:f,disabled:p,required:m,form:g}=e,h=mi(t),[y,w]=b.useState(null),[v,x]=b.useState(null),[E,P]=b.useState(!1),_=ro(u),[N,C]=Zr({prop:n,defaultProp:o??!1,onChange:s,caller:zn}),[A,I]=Zr({prop:i,defaultProp:a,onChange:d,caller:zn}),T=b.useRef(null),W=y?g||!!y.closest("form"):!0,[X,O]=b.useState(new Set),j=Array.from(X).map(M=>M.props.value).join(";");return c.jsx(Ju,{...h,children:c.jsxs(Ax,{required:m,scope:t,trigger:y,onTriggerChange:w,valueNode:v,onValueNodeChange:x,valueNodeHasChildren:E,onValueNodeHasChildrenChange:P,contentId:on(),value:A,onValueChange:I,open:N,onOpenChange:C,dir:_,triggerPointerDownPosRef:T,disabled:p,children:[c.jsx(fi.Provider,{scope:t,children:c.jsx(Cx,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(M=>{O(D=>new Set(D).add(M))},[]),onNativeOptionRemove:b.useCallback(M=>{O(D=>{const L=new Set(D);return L.delete(M),L})},[]),children:r})}),W?c.jsxs(Bf,{"aria-hidden":!0,required:m,tabIndex:-1,name:l,autoComplete:f,value:A,onChange:M=>I(M.target.value),disabled:p,form:g,children:[A===void 0?c.jsx("option",{value:""}):null,Array.from(X)]},j):null]})})};hf.displayName=zn;var gf="SelectTrigger",yf=b.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...o}=e,s=mi(r),i=Nn(gf,r),a=i.disabled||n,d=Ze(t,i.onTriggerChange),u=pi(r),l=b.useRef("touch"),[f,p,m]=jf(h=>{const y=u().filter(x=>!x.disabled),w=y.find(x=>x.value===i.value),v=zf(y,h,w);v!==void 0&&i.onValueChange(v.value)}),g=h=>{a||(i.onOpenChange(!0),m()),h&&(i.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return c.jsx(nl,{asChild:!0,...s,children:c.jsx(Be.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":$f(i.value)?"":void 0,...o,ref:d,onClick:Me(o.onClick,h=>{h.currentTarget.focus(),l.current!=="mouse"&&g(h)}),onPointerDown:Me(o.onPointerDown,h=>{l.current=h.pointerType;const y=h.target;y.hasPointerCapture(h.pointerId)&&y.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(g(h),h.preventDefault())}),onKeyDown:Me(o.onKeyDown,h=>{const y=f.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&p(h.key),!(y&&h.key===" ")&&wx.includes(h.key)&&(g(),h.preventDefault())})})})});yf.displayName=gf;var bf="SelectValue",vf=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,children:s,placeholder:i="",...a}=e,d=Nn(bf,r),{onValueNodeHasChildrenChange:u}=d,l=s!==void 0,f=Ze(t,d.onValueNodeChange);return Qt(()=>{u(l)},[u,l]),c.jsx(Be.span,{...a,ref:f,style:{pointerEvents:"none"},children:$f(d.value)?c.jsx(c.Fragment,{children:i}):s})});vf.displayName=bf;var Nx="SelectIcon",wf=b.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...o}=e;return c.jsx(Be.span,{"aria-hidden":!0,...o,ref:t,children:n||"▼"})});wf.displayName=Nx;var _x="SelectPortal",Sf=e=>c.jsx(ni,{asChild:!0,...e});Sf.displayName=_x;var Un="SelectContent",xf=b.forwardRef((e,t)=>{const r=Nn(Un,e.__scopeSelect),[n,o]=b.useState();if(Qt(()=>{o(new DocumentFragment)},[]),!r.open){const s=n;return s?Es.createPortal(c.jsx(Af,{scope:e.__scopeSelect,children:c.jsx(fi.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Cf,{...e,ref:t})});xf.displayName=Un;var Hr=10,[Af,_n]=fo(Un),kx="SelectContentImpl",Tx=CS("SelectContent.RemoveScroll"),Cf=b.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:d,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y,...w}=e,v=Nn(Un,r),[x,E]=b.useState(null),[P,_]=b.useState(null),N=Ze(t,G=>E(G)),[C,A]=b.useState(null),[I,T]=b.useState(null),W=pi(r),[X,O]=b.useState(!1),j=b.useRef(!1);b.useEffect(()=>{if(x)return sl(x)},[x]),za();const M=b.useCallback(G=>{const[ee,...Pe]=W().map(be=>be.ref.current),[oe]=Pe.slice(-1),re=document.activeElement;for(const be of G)if(be===re||(be?.scrollIntoView({block:"nearest"}),be===ee&&P&&(P.scrollTop=0),be===oe&&P&&(P.scrollTop=P.scrollHeight),be?.focus(),document.activeElement!==re))return},[W,P]),D=b.useCallback(()=>M([C,x]),[M,C,x]);b.useEffect(()=>{X&&D()},[X,D]);const{onOpenChange:L,triggerPointerDownPosRef:U}=v;b.useEffect(()=>{if(x){let G={x:0,y:0};const ee=oe=>{G={x:Math.abs(Math.round(oe.pageX)-(U.current?.x??0)),y:Math.abs(Math.round(oe.pageY)-(U.current?.y??0))}},Pe=oe=>{G.x<=10&&G.y<=10?oe.preventDefault():x.contains(oe.target)||L(!1),document.removeEventListener("pointermove",ee),U.current=null};return U.current!==null&&(document.addEventListener("pointermove",ee),document.addEventListener("pointerup",Pe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ee),document.removeEventListener("pointerup",Pe,{capture:!0})}}},[x,L,U]),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[$,ie]=jf(G=>{const ee=W().filter(re=>!re.disabled),Pe=ee.find(re=>re.ref.current===document.activeElement),oe=zf(ee,G,Pe);oe&&setTimeout(()=>oe.ref.current.focus())}),V=b.useCallback((G,ee,Pe)=>{const oe=!j.current&&!Pe;(v.value!==void 0&&v.value===ee||oe)&&(A(G),oe&&(j.current=!0))},[v.value]),K=b.useCallback(()=>x?.focus(),[x]),J=b.useCallback((G,ee,Pe)=>{const oe=!j.current&&!Pe;(v.value!==void 0&&v.value===ee||oe)&&T(G)},[v.value]),ce=n==="popper"?dl:Ef,ne=ce===dl?{side:a,sideOffset:d,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y}:{};return c.jsx(Af,{scope:r,content:x,viewport:P,onViewportChange:_,itemRefCallback:V,selectedItem:C,onItemLeave:K,itemTextRefCallback:J,focusSelectedItem:D,selectedItemText:I,position:n,isPositioned:X,searchRef:$,children:c.jsx(ui,{as:Tx,allowPinchZoom:!0,children:c.jsx(Rs,{asChild:!0,trapped:v.open,onMountAutoFocus:G=>{G.preventDefault()},onUnmountAutoFocus:Me(o,G=>{v.trigger?.focus({preventScroll:!0}),G.preventDefault()}),children:c.jsx(Ws,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:G=>G.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:c.jsx(ce,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:G=>G.preventDefault(),...w,...ne,onPlaced:()=>O(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:Me(w.onKeyDown,G=>{const ee=G.ctrlKey||G.altKey||G.metaKey;if(G.key==="Tab"&&G.preventDefault(),!ee&&G.key.length===1&&ie(G.key),["ArrowUp","ArrowDown","Home","End"].includes(G.key)){let oe=W().filter(re=>!re.disabled).map(re=>re.ref.current);if(["ArrowUp","End"].includes(G.key)&&(oe=oe.slice().reverse()),["ArrowUp","ArrowDown"].includes(G.key)){const re=G.target,be=oe.indexOf(re);oe=oe.slice(be+1)}setTimeout(()=>M(oe)),G.preventDefault()}})})})})})})});Cf.displayName=kx;var Fx="SelectItemAlignedPosition",Ef=b.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...o}=e,s=Nn(Un,r),i=_n(Un,r),[a,d]=b.useState(null),[u,l]=b.useState(null),f=Ze(t,N=>l(N)),p=pi(r),m=b.useRef(!1),g=b.useRef(!0),{viewport:h,selectedItem:y,selectedItemText:w,focusSelectedItem:v}=i,x=b.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&h&&y&&w){const N=s.trigger.getBoundingClientRect(),C=u.getBoundingClientRect(),A=s.valueNode.getBoundingClientRect(),I=w.getBoundingClientRect();if(s.dir!=="rtl"){const re=I.left-C.left,be=A.left-re,de=N.left-be,ot=N.width+de,Se=Math.max(ot,C.width),xe=window.innerWidth-Hr,ae=qo(be,[Hr,Math.max(Hr,xe-Se)]);a.style.minWidth=ot+"px",a.style.left=ae+"px"}else{const re=C.right-I.right,be=window.innerWidth-A.right-re,de=window.innerWidth-N.right-be,ot=N.width+de,Se=Math.max(ot,C.width),xe=window.innerWidth-Hr,ae=qo(be,[Hr,Math.max(Hr,xe-Se)]);a.style.minWidth=ot+"px",a.style.right=ae+"px"}const T=p(),W=window.innerHeight-Hr*2,X=h.scrollHeight,O=window.getComputedStyle(u),j=parseInt(O.borderTopWidth,10),M=parseInt(O.paddingTop,10),D=parseInt(O.borderBottomWidth,10),L=parseInt(O.paddingBottom,10),U=j+M+X+L+D,$=Math.min(y.offsetHeight*5,U),ie=window.getComputedStyle(h),V=parseInt(ie.paddingTop,10),K=parseInt(ie.paddingBottom,10),J=N.top+N.height/2-Hr,ce=W-J,ne=y.offsetHeight/2,G=y.offsetTop+ne,ee=j+M+G,Pe=U-ee;if(ee<=J){const re=T.length>0&&y===T[T.length-1].ref.current;a.style.bottom="0px";const be=u.clientHeight-h.offsetTop-h.offsetHeight,de=Math.max(ce,ne+(re?K:0)+be+D),ot=ee+de;a.style.height=ot+"px"}else{const re=T.length>0&&y===T[0].ref.current;a.style.top="0px";const de=Math.max(J,j+h.offsetTop+(re?V:0)+ne)+Pe;a.style.height=de+"px",h.scrollTop=ee-J+h.offsetTop}a.style.margin=`${Hr}px 0`,a.style.minHeight=$+"px",a.style.maxHeight=W+"px",n?.(),requestAnimationFrame(()=>m.current=!0)}},[p,s.trigger,s.valueNode,a,u,h,y,w,s.dir,n]);Qt(()=>x(),[x]);const[E,P]=b.useState();Qt(()=>{u&&P(window.getComputedStyle(u).zIndex)},[u]);const _=b.useCallback(N=>{N&&g.current===!0&&(x(),v?.(),g.current=!1)},[x,v]);return c.jsx(Ox,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:_,children:c.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(Be.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ef.displayName=Fx;var Px="SelectPopperPosition",dl=b.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:o=Hr,...s}=e,i=mi(r);return c.jsx(Qu,{...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)"}})});dl.displayName=Px;var[Ox,ul]=fo(Un,{}),fl="SelectViewport",Nf=b.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...o}=e,s=_n(fl,r),i=ul(fl,r),a=Ze(t,s.onViewportChange),d=b.useRef(0);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(fi.Slot,{scope:r,children:c.jsx(Be.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Me(o.onScroll,u=>{const l=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p?.current&&f){const m=Math.abs(d.current-l.scrollTop);if(m>0){const g=window.innerHeight-Hr*2,h=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),w=Math.max(h,y);if(w<g){const v=w+m,x=Math.min(g,v),E=v-x;f.style.height=x+"px",f.style.bottom==="0px"&&(l.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}d.current=l.scrollTop})})})]})});Nf.displayName=fl;var _f="SelectGroup",[Ix,Mx]=fo(_f),Lx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=on();return c.jsx(Ix,{scope:r,id:o,children:c.jsx(Be.div,{role:"group","aria-labelledby":o,...n,ref:t})})});Lx.displayName=_f;var kf="SelectLabel",Dx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=Mx(kf,r);return c.jsx(Be.div,{id:o.id,...n,ref:t})});Dx.displayName=kf;var hi="SelectItem",[Bx,Tf]=fo(hi),Ff=b.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:o=!1,textValue:s,...i}=e,a=Nn(hi,r),d=_n(hi,r),u=a.value===n,[l,f]=b.useState(s??""),[p,m]=b.useState(!1),g=Ze(t,v=>d.itemRefCallback?.(v,n,o)),h=on(),y=b.useRef("touch"),w=()=>{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 c.jsx(Bx,{scope:r,value:n,disabled:o,textId:h,isSelected:u,onItemTextChange:b.useCallback(v=>{f(x=>x||(v?.textContent??"").trim())},[]),children:c.jsx(fi.ItemSlot,{scope:r,value:n,disabled:o,textValue:l,children:c.jsx(Be.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:g,onFocus:Me(i.onFocus,()=>m(!0)),onBlur:Me(i.onBlur,()=>m(!1)),onClick:Me(i.onClick,()=>{y.current!=="mouse"&&w()}),onPointerUp:Me(i.onPointerUp,()=>{y.current==="mouse"&&w()}),onPointerDown:Me(i.onPointerDown,v=>{y.current=v.pointerType}),onPointerMove:Me(i.onPointerMove,v=>{y.current=v.pointerType,o?d.onItemLeave?.():y.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Me(i.onPointerLeave,v=>{v.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:Me(i.onKeyDown,v=>{d.searchRef?.current!==""&&v.key===" "||(Sx.includes(v.key)&&w(),v.key===" "&&v.preventDefault())})})})})});Ff.displayName=hi;var Zo="SelectItemText",Pf=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,...s}=e,i=Nn(Zo,r),a=_n(Zo,r),d=Tf(Zo,r),u=Ex(Zo,r),[l,f]=b.useState(null),p=Ze(t,w=>f(w),d.onItemTextChange,w=>a.itemTextRefCallback?.(w,d.value,d.disabled)),m=l?.textContent,g=b.useMemo(()=>c.jsx("option",{value:d.value,disabled:d.disabled,children:m},d.value),[d.disabled,d.value,m]),{onNativeOptionAdd:h,onNativeOptionRemove:y}=u;return Qt(()=>(h(g),()=>y(g)),[h,y,g]),c.jsxs(c.Fragment,{children:[c.jsx(Be.span,{id:d.textId,...s,ref:p}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Es.createPortal(s.children,i.valueNode):null]})});Pf.displayName=Zo;var Of="SelectItemIndicator",If=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return Tf(Of,r).isSelected?c.jsx(Be.span,{"aria-hidden":!0,...n,ref:t}):null});If.displayName=Of;var pl="SelectScrollUpButton",Mf=b.forwardRef((e,t)=>{const r=_n(pl,e.__scopeSelect),n=ul(pl,e.__scopeSelect),[o,s]=b.useState(!1),i=Ze(t,n.onScrollButtonChange);return Qt(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=d.scrollTop>0;s(u)};const d=r.viewport;return a(),d.addEventListener("scroll",a),()=>d.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?c.jsx(Df,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:d}=r;a&&d&&(a.scrollTop=a.scrollTop-d.offsetHeight)}}):null});Mf.displayName=pl;var ml="SelectScrollDownButton",Lf=b.forwardRef((e,t)=>{const r=_n(ml,e.__scopeSelect),n=ul(ml,e.__scopeSelect),[o,s]=b.useState(!1),i=Ze(t,n.onScrollButtonChange);return Qt(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=d.scrollHeight-d.clientHeight,l=Math.ceil(d.scrollTop)<u;s(l)};const d=r.viewport;return a(),d.addEventListener("scroll",a),()=>d.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?c.jsx(Df,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:d}=r;a&&d&&(a.scrollTop=a.scrollTop+d.offsetHeight)}}):null});Lf.displayName=ml;var Df=b.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...o}=e,s=_n("SelectScrollButton",r),i=b.useRef(null),a=pi(r),d=b.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return b.useEffect(()=>()=>d(),[d]),Qt(()=>{a().find(l=>l.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),c.jsx(Be.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Me(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(n,50))}),onPointerMove:Me(o.onPointerMove,()=>{s.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(n,50))}),onPointerLeave:Me(o.onPointerLeave,()=>{d()})})}),$x="SelectSeparator",jx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return c.jsx(Be.div,{"aria-hidden":!0,...n,ref:t})});jx.displayName=$x;var hl="SelectArrow",zx=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=mi(r),s=Nn(hl,r),i=_n(hl,r);return s.open&&i.position==="popper"?c.jsx(Zu,{...o,...n,ref:t}):null});zx.displayName=hl;var Ux="SelectBubbleInput",Bf=b.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const o=b.useRef(null),s=Ze(n,o),i=Qo(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const d=window.HTMLSelectElement.prototype,l=Object.getOwnPropertyDescriptor(d,"value").set;if(i!==t&&l){const f=new Event("change",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Be.select,{...r,style:{...ef,...r.style},ref:s,defaultValue:t})});Bf.displayName=Ux;function $f(e){return e===""||e===void 0}function jf(e){const t=ar(e),r=b.useRef(""),n=b.useRef(0),o=b.useCallback(i=>{const a=r.current+i;t(a),(function d(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>d(""),1e3))})(a)},[t]),s=b.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,o,s]}function zf(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=Vx(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==r));const d=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==r?d:void 0}function Vx(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Hx=hf,Wx=yf,Rx=vf,Gx=wf,Kx=Sf,qx=xf,Yx=Nf,Xx=Ff,Jx=Pf,Qx=If,Zx=Mf,e0=Lf;function t0({...e}){return c.jsx(Hx,{"data-slot":"select",...e})}function r0({className:e,...t}){return c.jsx(Rx,{"data-slot":"select-value",className:B("truncate min-w-0",e),...t})}function n0({className:e,size:t="default",children:r,...n}){const o=e?.includes("w-full");return c.jsxs(Wx,{"data-slot":"select-trigger","data-size":t,className:B("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,c.jsx(Gx,{asChild:!0,children:c.jsx(Wo,{className:"size-4 opacity-50"})})]})}function o0({className:e,children:t,position:r="popper",...n}){return c.jsx(Kx,{children:c.jsxs(qx,{"data-slot":"select-content",className:B("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:[c.jsx(s0,{}),c.jsx(Yx,{className:B("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),c.jsx(i0,{})]})})}function gl({className:e,children:t,...r}){return c.jsxs(Xx,{"data-slot":"select-item",className:B("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:[c.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:c.jsx(Qx,{children:c.jsx(Vs,{className:"size-4"})})}),c.jsx(Jx,{className:"truncate",children:t})]})}function s0({className:e,...t}){return c.jsx(Zx,{"data-slot":"select-scroll-up-button",className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Nv,{className:"size-4"})})}function i0({className:e,...t}){return c.jsx(e0,{"data-slot":"select-scroll-down-button",className:B("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(Wo,{className:"size-4"})})}function Uf(e,t){return function(){return e.apply(t,arguments)}}const{toString:a0}=Object.prototype,{getPrototypeOf:yl}=Object,{iterator:gi,toStringTag:Vf}=Symbol,yi=(e=>t=>{const r=a0.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Wr=e=>(e=e.toLowerCase(),t=>yi(t)===e),bi=e=>t=>typeof t===e,{isArray:po}=Array,mo=bi("undefined");function es(e){return e!==null&&!mo(e)&&e.constructor!==null&&!mo(e.constructor)&&pr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Hf=Wr("ArrayBuffer");function l0(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Hf(e.buffer),t}const c0=bi("string"),pr=bi("function"),Wf=bi("number"),ts=e=>e!==null&&typeof e=="object",d0=e=>e===!0||e===!1,vi=e=>{if(yi(e)!=="object")return!1;const t=yl(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Vf in e)&&!(gi in e)},u0=e=>{if(!ts(e)||es(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},f0=Wr("Date"),p0=Wr("File"),m0=e=>!!(e&&typeof e.uri<"u"),h0=e=>e&&typeof e.getParts<"u",g0=Wr("Blob"),y0=Wr("FileList"),b0=e=>ts(e)&&pr(e.pipe);function v0(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Rf=v0(),Gf=typeof Rf.FormData<"u"?Rf.FormData:void 0,w0=e=>{let t;return e&&(Gf&&e instanceof Gf||pr(e.append)&&((t=yi(e))==="formdata"||t==="object"&&pr(e.toString)&&e.toString()==="[object FormData]"))},S0=Wr("URLSearchParams"),[x0,A0,C0,E0]=["ReadableStream","Request","Response","Headers"].map(Wr),N0=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function rs(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),po(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(es(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 Kf(e,t){if(es(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 Vn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,qf=e=>!mo(e)&&e!==Vn;function bl(){const{caseless:e,skipUndefined:t}=qf(this)&&this||{},r={},n=(o,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;const i=e&&Kf(r,s)||s;vi(r[i])&&vi(o)?r[i]=bl(r[i],o):vi(o)?r[i]=bl({},o):po(o)?r[i]=o.slice():(!t||!mo(o))&&(r[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&rs(arguments[o],n);return r}const _0=(e,t,r,{allOwnKeys:n}={})=>(rs(t,(o,s)=>{r&&pr(o)?Object.defineProperty(e,s,{value:Uf(o,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,s,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),k0=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),T0=(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)},F0=(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&&yl(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},P0=(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},O0=e=>{if(!e)return null;if(po(e))return e;let t=e.length;if(!Wf(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},I0=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&yl(Uint8Array)),M0=(e,t)=>{const n=(e&&e[gi]).call(e);let o;for(;(o=n.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},L0=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},D0=Wr("HTMLFormElement"),B0=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),Yf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),$0=Wr("RegExp"),Xf=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};rs(r,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(n[s]=i||o)}),Object.defineProperties(e,n)},j0=e=>{Xf(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+"'")})}})},z0=(e,t)=>{const r={},n=o=>{o.forEach(s=>{r[s]=!0})};return po(e)?n(e):n(String(e).split(t)),r},U0=()=>{},V0=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function H0(e){return!!(e&&pr(e.append)&&e[Vf]==="FormData"&&e[gi])}const W0=e=>{const t=new Array(10),r=(n,o)=>{if(ts(n)){if(t.indexOf(n)>=0)return;if(es(n))return n;if(!("toJSON"in n)){t[o]=n;const s=po(n)?[]:{};return rs(n,(i,a)=>{const d=r(i,o+1);!mo(d)&&(s[a]=d)}),t[o]=void 0,s}}return n};return r(e,0)},R0=Wr("AsyncFunction"),G0=e=>e&&(ts(e)||pr(e))&&pr(e.then)&&pr(e.catch),Jf=((e,t)=>e?setImmediate:t?((r,n)=>(Vn.addEventListener("message",({source:o,data:s})=>{o===Vn&&s===r&&n.length&&n.shift()()},!1),o=>{n.push(o),Vn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",pr(Vn.postMessage)),K0=typeof queueMicrotask<"u"?queueMicrotask.bind(Vn):typeof process<"u"&&process.nextTick||Jf,R={isArray:po,isArrayBuffer:Hf,isBuffer:es,isFormData:w0,isArrayBufferView:l0,isString:c0,isNumber:Wf,isBoolean:d0,isObject:ts,isPlainObject:vi,isEmptyObject:u0,isReadableStream:x0,isRequest:A0,isResponse:C0,isHeaders:E0,isUndefined:mo,isDate:f0,isFile:p0,isReactNativeBlob:m0,isReactNative:h0,isBlob:g0,isRegExp:$0,isFunction:pr,isStream:b0,isURLSearchParams:S0,isTypedArray:I0,isFileList:y0,forEach:rs,merge:bl,extend:_0,trim:N0,stripBOM:k0,inherits:T0,toFlatObject:F0,kindOf:yi,kindOfTest:Wr,endsWith:P0,toArray:O0,forEachEntry:M0,matchAll:L0,isHTMLForm:D0,hasOwnProperty:Yf,hasOwnProp:Yf,reduceDescriptors:Xf,freezeMethods:j0,toObjectSet:z0,toCamelCase:B0,noop:U0,toFiniteNumber:V0,findKey:Kf,global:Vn,isContextDefined:qf,isSpecCompliantForm:H0,toJSONObject:W0,isAsyncFn:R0,isThenable:G0,setImmediate:Jf,asap:K0,isIterable:e=>e!=null&&pr(e[gi])};let qe=class Ty extends Error{static from(t,r,n,o,s,i){const a=new Ty(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:R.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 q0=null;function vl(e){return R.isPlainObject(e)||R.isArray(e)}function Qf(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function wl(e,t,r){return e?e.concat(t).map(function(o,s){return o=Qf(o),!r&&s?"["+o+"]":o}).join(r?".":""):t}function Y0(e){return R.isArray(e)&&!e.some(vl)}const X0=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function wi(e,t,r){if(!R.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=R.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,y){return!R.isUndefined(y[h])});const n=r.metaTokens,o=r.visitor||l,s=r.dots,i=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&R.isSpecCompliantForm(t);if(!R.isFunction(o))throw new TypeError("visitor must be a function");function u(g){if(g===null)return"";if(R.isDate(g))return g.toISOString();if(R.isBoolean(g))return g.toString();if(!d&&R.isBlob(g))throw new qe("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(g)||R.isTypedArray(g)?d&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function l(g,h,y){let w=g;if(R.isReactNative(t)&&R.isReactNativeBlob(g))return t.append(wl(y,h,s),u(g)),!1;if(g&&!y&&typeof g=="object"){if(R.endsWith(h,"{}"))h=n?h:h.slice(0,-2),g=JSON.stringify(g);else if(R.isArray(g)&&Y0(g)||(R.isFileList(g)||R.endsWith(h,"[]"))&&(w=R.toArray(g)))return h=Qf(h),w.forEach(function(x,E){!(R.isUndefined(x)||x===null)&&t.append(i===!0?wl([h],E,s):i===null?h:h+"[]",u(x))}),!1}return vl(g)?!0:(t.append(wl(y,h,s),u(g)),!1)}const f=[],p=Object.assign(X0,{defaultVisitor:l,convertValue:u,isVisitable:vl});function m(g,h){if(!R.isUndefined(g)){if(f.indexOf(g)!==-1)throw Error("Circular reference detected in "+h.join("."));f.push(g),R.forEach(g,function(w,v){(!(R.isUndefined(w)||w===null)&&o.call(t,w,R.isString(v)?v.trim():v,h,p))===!0&&m(w,h?h.concat(v):[v])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return m(e),t}function Zf(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Sl(e,t){this._pairs=[],e&&wi(e,this,t)}const ep=Sl.prototype;ep.append=function(t,r){this._pairs.push([t,r])},ep.toString=function(t){const r=t?function(n){return t.call(this,n,Zf)}:Zf;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function J0(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function tp(e,t,r){if(!t)return e;const n=r&&r.encode||J0,o=R.isFunction(r)?{serialize:r}:r,s=o&&o.serialize;let i;if(s?i=s(t,o):i=R.isURLSearchParams(t)?t.toString():new Sl(t,o).toString(n),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class rp{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){R.forEach(this.handlers,function(n){n!==null&&t(n)})}}const xl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Q0={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Sl,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Al=typeof window<"u"&&typeof document<"u",Cl=typeof navigator=="object"&&navigator||void 0,Z0=Al&&(!Cl||["ReactNative","NativeScript","NS"].indexOf(Cl.product)<0),eA=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",tA=Al&&window.location.href||"http://localhost",nr={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Al,hasStandardBrowserEnv:Z0,hasStandardBrowserWebWorkerEnv:eA,navigator:Cl,origin:tA},Symbol.toStringTag,{value:"Module"})),...Q0};function rA(e,t){return wi(e,new nr.classes.URLSearchParams,{visitor:function(r,n,o,s){return nr.isNode&&R.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function nA(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function oA(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 np(e){function t(r,n,o,s){let i=r[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),d=s>=r.length;return i=!i&&R.isArray(o)?o.length:i,d?(R.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!a):((!o[i]||!R.isObject(o[i]))&&(o[i]=[]),t(r,n,o[i],s)&&R.isArray(o[i])&&(o[i]=oA(o[i])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const r={};return R.forEachEntry(e,(n,o)=>{t(nA(n),o,r,0)}),r}return null}function sA(e,t,r){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const ns={transitional:xl,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",o=n.indexOf("application/json")>-1,s=R.isObject(t);if(s&&R.isHTMLForm(t)&&(t=new FormData(t)),R.isFormData(t))return o?JSON.stringify(np(t)):t;if(R.isArrayBuffer(t)||R.isBuffer(t)||R.isStream(t)||R.isFile(t)||R.isBlob(t)||R.isReadableStream(t))return t;if(R.isArrayBufferView(t))return t.buffer;if(R.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 rA(t,this.formSerializer).toString();if((a=R.isFileList(t))||n.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return wi(a?{"files[]":t}:t,d&&new d,this.formSerializer)}}return s||o?(r.setContentType("application/json",!1),sA(t)):t}],transformResponse:[function(t){const r=this.transitional||ns.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(R.isResponse(t)||R.isReadableStream(t))return t;if(t&&R.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:nr.classes.FormData,Blob:nr.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};R.forEach(["delete","get","head","post","put","patch"],e=>{ns.headers[e]={}});const iA=R.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"]),aA=e=>{const t={};let r,n,o;return e&&e.split(`
|
|
42
42
|
`).forEach(function(i){o=i.indexOf(":"),r=i.substring(0,o).trim().toLowerCase(),n=i.substring(o+1).trim(),!(!r||t[r]&&iA[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},op=Symbol("internals");function os(e){return e&&String(e).trim().toLowerCase()}function Si(e){return e===!1||e==null?e:R.isArray(e)?e.map(Si):String(e).replace(/[\r\n]+$/,"")}function lA(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 cA=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function El(e,t,r,n,o){if(R.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!R.isString(t)){if(R.isString(n))return t.indexOf(n)!==-1;if(R.isRegExp(n))return n.test(t)}}function dA(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function uA(e,t){const r=R.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,d,u){const l=os(d);if(!l)throw new Error("header name must be a non-empty string");const f=R.findKey(o,l);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||d]=Si(a))}const i=(a,d)=>R.forEach(a,(u,l)=>s(u,l,d));if(R.isPlainObject(t)||t instanceof this.constructor)i(t,r);else if(R.isString(t)&&(t=t.trim())&&!cA(t))i(aA(t),r);else if(R.isObject(t)&&R.isIterable(t)){let a={},d,u;for(const l of t){if(!R.isArray(l))throw TypeError("Object iterator must return a key-value pair");a[u=l[0]]=(d=a[u])?R.isArray(d)?[...d,l[1]]:[d,l[1]]:l[1]}i(a,r)}else t!=null&&s(r,t,n);return this}get(t,r){if(t=os(t),t){const n=R.findKey(this,t);if(n){const o=this[n];if(!r)return o;if(r===!0)return lA(o);if(R.isFunction(r))return r.call(this,o,n);if(R.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=os(t),t){const n=R.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||El(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let o=!1;function s(i){if(i=os(i),i){const a=R.findKey(n,i);a&&(!r||El(n,n[a],a,r))&&(delete n[a],o=!0)}}return R.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||El(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const r=this,n={};return R.forEach(this,(o,s)=>{const i=R.findKey(n,s);if(i){r[i]=Si(o),delete r[s];return}const a=t?dA(s):String(s).trim();a!==s&&delete r[s],r[a]=Si(o),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return R.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&R.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(`
|
|
43
|
-
`)}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[op]=this[op]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=os(i);n[a]||(uA(o,i),n[a]=!0)}return R.isArray(t)?t.forEach(s):s(t),this}};mr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors(mr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),R.freezeMethods(mr);function Nl(e,t){const r=this||ns,n=t||r,o=mr.from(n.headers);let s=n.data;return R.forEach(e,function(a){s=a.call(r,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function sp(e){return!!(e&&e.__CANCEL__)}let ss=class extends qe{constructor(t,r,n){super(t??"canceled",qe.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function ip(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 fA(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function pA(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(d){const u=Date.now(),l=n[s];i||(i=u),r[o]=d,n[o]=u;let f=s,p=0;for(;f!==o;)p+=r[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const m=l&&u-l;return m?Math.round(p*1e3/m):void 0}}function mA(e,t){let r=0,n=1e3/t,o,s;const i=(u,l=Date.now())=>{r=l,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const l=Date.now(),f=l-r;f>=n?i(u,l):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},n-f)))},()=>o&&i(o)]}const xi=(e,t,r=3)=>{let n=0;const o=pA(50,250);return mA(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,d=i-n,u=o(d),l=i<=a;n=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:d,rate:u||void 0,estimated:u&&a&&l?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},r)},ap=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},lp=e=>(...t)=>R.asap(()=>e(...t)),hA=nr.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,nr.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(nr.origin),nr.navigator&&/(msie|trident)/i.test(nr.navigator.userAgent)):()=>!0,gA=nr.hasStandardBrowserEnv?{write(e,t,r,n,o,s,i){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];R.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),R.isString(n)&&a.push(`path=${n}`),R.isString(o)&&a.push(`domain=${o}`),s===!0&&a.push("secure"),R.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 yA(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function bA(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function cp(e,t,r){let n=!yA(t);return e&&(n||r==!1)?bA(e,t):t}const dp=e=>e instanceof mr?{...e}:e;function Hn(e,t){t=t||{};const r={};function n(u,l,f,p){return R.isPlainObject(u)&&R.isPlainObject(l)?R.merge.call({caseless:p},u,l):R.isPlainObject(l)?R.merge({},l):R.isArray(l)?l.slice():l}function o(u,l,f,p){if(R.isUndefined(l)){if(!R.isUndefined(u))return n(void 0,u,f,p)}else return n(u,l,f,p)}function s(u,l){if(!R.isUndefined(l))return n(void 0,l)}function i(u,l){if(R.isUndefined(l)){if(!R.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function a(u,l,f){if(f in t)return n(u,l);if(f in e)return n(void 0,u)}const d={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,l,f)=>o(dp(u),dp(l),f,!0)};return R.forEach(Object.keys({...e,...t}),function(l){if(l==="__proto__"||l==="constructor"||l==="prototype")return;const f=R.hasOwnProp(d,l)?d[l]:o,p=f(e[l],t[l],l);R.isUndefined(p)&&f!==a||(r[l]=p)}),r}const up=e=>{const t=Hn({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=mr.from(i),t.url=tp(cp(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),R.isFormData(r)){if(nr.hasStandardBrowserEnv||nr.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(R.isFunction(r.getHeaders)){const d=r.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([l,f])=>{u.includes(l.toLowerCase())&&i.set(l,f)})}}if(nr.hasStandardBrowserEnv&&(n&&R.isFunction(n)&&(n=n(t)),n||n!==!1&&hA(t.url))){const d=o&&s&&gA.read(s);d&&i.set(o,d)}return t},vA=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=up(e);let s=o.data;const i=mr.from(o.headers).normalize();let{responseType:a,onUploadProgress:d,onDownloadProgress:u}=o,l,f,p,m,g;function h(){m&&m(),g&&g(),o.cancelToken&&o.cancelToken.unsubscribe(l),o.signal&&o.signal.removeEventListener("abort",l)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function w(){if(!y)return;const x=mr.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),P={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:x,config:e,request:y};ip(function(N){r(N),h()},function(N){n(N),h()},P),y=null}"onloadend"in y?y.onloadend=w:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(w)},y.onabort=function(){y&&(n(new qe("Request aborted",qe.ECONNABORTED,e,y)),y=null)},y.onerror=function(E){const P=E&&E.message?E.message:"Network Error",k=new qe(P,qe.ERR_NETWORK,e,y);k.event=E||null,n(k),y=null},y.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const P=o.transitional||xl;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),n(new qe(E,P.clarifyTimeoutError?qe.ETIMEDOUT:qe.ECONNABORTED,e,y)),y=null},s===void 0&&i.setContentType(null),"setRequestHeader"in y&&R.forEach(i.toJSON(),function(E,P){y.setRequestHeader(P,E)}),R.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),u&&([p,g]=xi(u,!0),y.addEventListener("progress",p)),d&&y.upload&&([f,m]=xi(d),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(l=x=>{y&&(n(!x||x.type?new ss(null,e,y):x),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(l),o.signal&&(o.signal.aborted?l():o.signal.addEventListener("abort",l)));const v=fA(o.url);if(v&&nr.protocols.indexOf(v)===-1){n(new qe("Unsupported protocol "+v+":",qe.ERR_BAD_REQUEST,e));return}y.send(s||null)})},wA=(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 l=u instanceof Error?u:this.reason;n.abort(l instanceof qe?l:new ss(l instanceof Error?l.message:l))}};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:d}=n;return d.unsubscribe=()=>R.asap(a),d}},SA=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},xA=async function*(e,t){for await(const r of AA(e))yield*SA(r,t)},AA=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()}},fp=(e,t,r,n)=>{const o=xA(e,t);let s=0,i,a=d=>{i||(i=!0,n&&n(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await o.next();if(u){a(),d.close();return}let f=l.byteLength;if(r){let p=s+=f;r(p)}d.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(d){return a(d),o.return()}},{highWaterMark:2})},pp=64*1024,{isFunction:Ai}=R,CA=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:mp,TextEncoder:hp}=R.global,gp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},EA=e=>{e=R.merge.call({skipUndefined:!0},CA,e);const{fetch:t,Request:r,Response:n}=e,o=t?Ai(t):typeof fetch=="function",s=Ai(r),i=Ai(n);if(!o)return!1;const a=o&&Ai(mp),d=o&&(typeof hp=="function"?(g=>h=>g.encode(h))(new hp):async g=>new Uint8Array(await new r(g).arrayBuffer())),u=s&&a&&gp(()=>{let g=!1;const h=new mp,y=new r(nr.origin,{body:h,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return h.cancel(),g&&!y}),l=i&&a&&gp(()=>R.isReadableStream(new n("").body)),f={stream:l&&(g=>g.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(g=>{!f[g]&&(f[g]=(h,y)=>{let w=h&&h[g];if(w)return w.call(h);throw new qe(`Response type '${g}' is not supported`,qe.ERR_NOT_SUPPORT,y)})});const p=async g=>{if(g==null)return 0;if(R.isBlob(g))return g.size;if(R.isSpecCompliantForm(g))return(await new r(nr.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(R.isArrayBufferView(g)||R.isArrayBuffer(g))return g.byteLength;if(R.isURLSearchParams(g)&&(g=g+""),R.isString(g))return(await d(g)).byteLength},m=async(g,h)=>{const y=R.toFiniteNumber(g.getContentLength());return y??p(h)};return async g=>{let{url:h,method:y,data:w,signal:v,cancelToken:x,timeout:E,onDownloadProgress:P,onUploadProgress:k,responseType:N,headers:C,withCredentials:A="same-origin",fetchOptions:I}=up(g),T=t||fetch;N=N?(N+"").toLowerCase():"text";let W=wA([v,x&&x.toAbortSignal()],E),X=null;const O=W&&W.unsubscribe&&(()=>{W.unsubscribe()});let j;try{if(k&&u&&y!=="get"&&y!=="head"&&(j=await m(C,w))!==0){let ie=new r(h,{method:"POST",body:w,duplex:"half"}),V;if(R.isFormData(w)&&(V=ie.headers.get("content-type"))&&C.setContentType(V),ie.body){const[K,J]=ap(j,xi(lp(k)));w=fp(ie.body,pp,K,J)}}R.isString(A)||(A=A?"include":"omit");const M=s&&"credentials"in r.prototype,D={...I,signal:W,method:y.toUpperCase(),headers:C.normalize().toJSON(),body:w,duplex:"half",credentials:M?A:void 0};X=s&&new r(h,D);let L=await(s?T(X,I):T(h,D));const U=l&&(N==="stream"||N==="response");if(l&&(P||U&&O)){const ie={};["status","statusText","headers"].forEach(ce=>{ie[ce]=L[ce]});const V=R.toFiniteNumber(L.headers.get("content-length")),[K,J]=P&&ap(V,xi(lp(P),!0))||[];L=new n(fp(L.body,pp,K,()=>{J&&J(),O&&O()}),ie)}N=N||"text";let $=await f[R.findKey(f,N)||"text"](L,g);return!U&&O&&O(),await new Promise((ie,V)=>{ip(ie,V,{data:$,headers:mr.from(L.headers),status:L.status,statusText:L.statusText,config:g,request:X})})}catch(M){throw O&&O(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new qe("Network Error",qe.ERR_NETWORK,g,X,M&&M.response),{cause:M.cause||M}):qe.from(M,M&&M.code,g,X,M&&M.response)}}},NA=new Map,yp=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:o}=t,s=[n,o,r];let i=s.length,a=i,d,u,l=NA;for(;a--;)d=s[a],u=l.get(d),u===void 0&&l.set(d,u=a?new Map:EA(t)),l=u;return u};yp();const _l={http:q0,xhr:vA,fetch:{get:yp}};R.forEach(_l,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const bp=e=>`- ${e}`,_A=e=>R.isFunction(e)||e===null||e===!1;function kA(e,t){e=R.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,!_A(n)&&(o=_l[(a=String(n)).toLowerCase()],o===void 0))throw new qe(`Unknown adapter '${a}'`);if(o&&(R.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=r?i.length>1?`since :
|
|
43
|
+
`)}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[op]=this[op]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=os(i);n[a]||(uA(o,i),n[a]=!0)}return R.isArray(t)?t.forEach(s):s(t),this}};mr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors(mr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),R.freezeMethods(mr);function Nl(e,t){const r=this||ns,n=t||r,o=mr.from(n.headers);let s=n.data;return R.forEach(e,function(a){s=a.call(r,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function sp(e){return!!(e&&e.__CANCEL__)}let ss=class extends qe{constructor(t,r,n){super(t??"canceled",qe.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function ip(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 fA(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function pA(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(d){const u=Date.now(),l=n[s];i||(i=u),r[o]=d,n[o]=u;let f=s,p=0;for(;f!==o;)p+=r[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const m=l&&u-l;return m?Math.round(p*1e3/m):void 0}}function mA(e,t){let r=0,n=1e3/t,o,s;const i=(u,l=Date.now())=>{r=l,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const l=Date.now(),f=l-r;f>=n?i(u,l):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},n-f)))},()=>o&&i(o)]}const xi=(e,t,r=3)=>{let n=0;const o=pA(50,250);return mA(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,d=i-n,u=o(d),l=i<=a;n=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:d,rate:u||void 0,estimated:u&&a&&l?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},r)},ap=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},lp=e=>(...t)=>R.asap(()=>e(...t)),hA=nr.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,nr.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(nr.origin),nr.navigator&&/(msie|trident)/i.test(nr.navigator.userAgent)):()=>!0,gA=nr.hasStandardBrowserEnv?{write(e,t,r,n,o,s,i){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];R.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),R.isString(n)&&a.push(`path=${n}`),R.isString(o)&&a.push(`domain=${o}`),s===!0&&a.push("secure"),R.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 yA(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function bA(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function cp(e,t,r){let n=!yA(t);return e&&(n||r==!1)?bA(e,t):t}const dp=e=>e instanceof mr?{...e}:e;function Hn(e,t){t=t||{};const r={};function n(u,l,f,p){return R.isPlainObject(u)&&R.isPlainObject(l)?R.merge.call({caseless:p},u,l):R.isPlainObject(l)?R.merge({},l):R.isArray(l)?l.slice():l}function o(u,l,f,p){if(R.isUndefined(l)){if(!R.isUndefined(u))return n(void 0,u,f,p)}else return n(u,l,f,p)}function s(u,l){if(!R.isUndefined(l))return n(void 0,l)}function i(u,l){if(R.isUndefined(l)){if(!R.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function a(u,l,f){if(f in t)return n(u,l);if(f in e)return n(void 0,u)}const d={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,l,f)=>o(dp(u),dp(l),f,!0)};return R.forEach(Object.keys({...e,...t}),function(l){if(l==="__proto__"||l==="constructor"||l==="prototype")return;const f=R.hasOwnProp(d,l)?d[l]:o,p=f(e[l],t[l],l);R.isUndefined(p)&&f!==a||(r[l]=p)}),r}const up=e=>{const t=Hn({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=mr.from(i),t.url=tp(cp(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),R.isFormData(r)){if(nr.hasStandardBrowserEnv||nr.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(R.isFunction(r.getHeaders)){const d=r.getHeaders(),u=["content-type","content-length"];Object.entries(d).forEach(([l,f])=>{u.includes(l.toLowerCase())&&i.set(l,f)})}}if(nr.hasStandardBrowserEnv&&(n&&R.isFunction(n)&&(n=n(t)),n||n!==!1&&hA(t.url))){const d=o&&s&&gA.read(s);d&&i.set(o,d)}return t},vA=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=up(e);let s=o.data;const i=mr.from(o.headers).normalize();let{responseType:a,onUploadProgress:d,onDownloadProgress:u}=o,l,f,p,m,g;function h(){m&&m(),g&&g(),o.cancelToken&&o.cancelToken.unsubscribe(l),o.signal&&o.signal.removeEventListener("abort",l)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function w(){if(!y)return;const x=mr.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),P={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:x,config:e,request:y};ip(function(N){r(N),h()},function(N){n(N),h()},P),y=null}"onloadend"in y?y.onloadend=w:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(w)},y.onabort=function(){y&&(n(new qe("Request aborted",qe.ECONNABORTED,e,y)),y=null)},y.onerror=function(E){const P=E&&E.message?E.message:"Network Error",_=new qe(P,qe.ERR_NETWORK,e,y);_.event=E||null,n(_),y=null},y.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const P=o.transitional||xl;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),n(new qe(E,P.clarifyTimeoutError?qe.ETIMEDOUT:qe.ECONNABORTED,e,y)),y=null},s===void 0&&i.setContentType(null),"setRequestHeader"in y&&R.forEach(i.toJSON(),function(E,P){y.setRequestHeader(P,E)}),R.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),u&&([p,g]=xi(u,!0),y.addEventListener("progress",p)),d&&y.upload&&([f,m]=xi(d),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(l=x=>{y&&(n(!x||x.type?new ss(null,e,y):x),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(l),o.signal&&(o.signal.aborted?l():o.signal.addEventListener("abort",l)));const v=fA(o.url);if(v&&nr.protocols.indexOf(v)===-1){n(new qe("Unsupported protocol "+v+":",qe.ERR_BAD_REQUEST,e));return}y.send(s||null)})},wA=(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 l=u instanceof Error?u:this.reason;n.abort(l instanceof qe?l:new ss(l instanceof Error?l.message:l))}};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:d}=n;return d.unsubscribe=()=>R.asap(a),d}},SA=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},xA=async function*(e,t){for await(const r of AA(e))yield*SA(r,t)},AA=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()}},fp=(e,t,r,n)=>{const o=xA(e,t);let s=0,i,a=d=>{i||(i=!0,n&&n(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await o.next();if(u){a(),d.close();return}let f=l.byteLength;if(r){let p=s+=f;r(p)}d.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(d){return a(d),o.return()}},{highWaterMark:2})},pp=64*1024,{isFunction:Ai}=R,CA=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:mp,TextEncoder:hp}=R.global,gp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},EA=e=>{e=R.merge.call({skipUndefined:!0},CA,e);const{fetch:t,Request:r,Response:n}=e,o=t?Ai(t):typeof fetch=="function",s=Ai(r),i=Ai(n);if(!o)return!1;const a=o&&Ai(mp),d=o&&(typeof hp=="function"?(g=>h=>g.encode(h))(new hp):async g=>new Uint8Array(await new r(g).arrayBuffer())),u=s&&a&&gp(()=>{let g=!1;const h=new mp,y=new r(nr.origin,{body:h,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return h.cancel(),g&&!y}),l=i&&a&&gp(()=>R.isReadableStream(new n("").body)),f={stream:l&&(g=>g.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(g=>{!f[g]&&(f[g]=(h,y)=>{let w=h&&h[g];if(w)return w.call(h);throw new qe(`Response type '${g}' is not supported`,qe.ERR_NOT_SUPPORT,y)})});const p=async g=>{if(g==null)return 0;if(R.isBlob(g))return g.size;if(R.isSpecCompliantForm(g))return(await new r(nr.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(R.isArrayBufferView(g)||R.isArrayBuffer(g))return g.byteLength;if(R.isURLSearchParams(g)&&(g=g+""),R.isString(g))return(await d(g)).byteLength},m=async(g,h)=>{const y=R.toFiniteNumber(g.getContentLength());return y??p(h)};return async g=>{let{url:h,method:y,data:w,signal:v,cancelToken:x,timeout:E,onDownloadProgress:P,onUploadProgress:_,responseType:N,headers:C,withCredentials:A="same-origin",fetchOptions:I}=up(g),T=t||fetch;N=N?(N+"").toLowerCase():"text";let W=wA([v,x&&x.toAbortSignal()],E),X=null;const O=W&&W.unsubscribe&&(()=>{W.unsubscribe()});let j;try{if(_&&u&&y!=="get"&&y!=="head"&&(j=await m(C,w))!==0){let ie=new r(h,{method:"POST",body:w,duplex:"half"}),V;if(R.isFormData(w)&&(V=ie.headers.get("content-type"))&&C.setContentType(V),ie.body){const[K,J]=ap(j,xi(lp(_)));w=fp(ie.body,pp,K,J)}}R.isString(A)||(A=A?"include":"omit");const M=s&&"credentials"in r.prototype,D={...I,signal:W,method:y.toUpperCase(),headers:C.normalize().toJSON(),body:w,duplex:"half",credentials:M?A:void 0};X=s&&new r(h,D);let L=await(s?T(X,I):T(h,D));const U=l&&(N==="stream"||N==="response");if(l&&(P||U&&O)){const ie={};["status","statusText","headers"].forEach(ce=>{ie[ce]=L[ce]});const V=R.toFiniteNumber(L.headers.get("content-length")),[K,J]=P&&ap(V,xi(lp(P),!0))||[];L=new n(fp(L.body,pp,K,()=>{J&&J(),O&&O()}),ie)}N=N||"text";let $=await f[R.findKey(f,N)||"text"](L,g);return!U&&O&&O(),await new Promise((ie,V)=>{ip(ie,V,{data:$,headers:mr.from(L.headers),status:L.status,statusText:L.statusText,config:g,request:X})})}catch(M){throw O&&O(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new qe("Network Error",qe.ERR_NETWORK,g,X,M&&M.response),{cause:M.cause||M}):qe.from(M,M&&M.code,g,X,M&&M.response)}}},NA=new Map,yp=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:o}=t,s=[n,o,r];let i=s.length,a=i,d,u,l=NA;for(;a--;)d=s[a],u=l.get(d),u===void 0&&l.set(d,u=a?new Map:EA(t)),l=u;return u};yp();const _l={http:q0,xhr:vA,fetch:{get:yp}};R.forEach(_l,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const bp=e=>`- ${e}`,_A=e=>R.isFunction(e)||e===null||e===!1;function kA(e,t){e=R.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,!_A(n)&&(o=_l[(a=String(n)).toLowerCase()],o===void 0))throw new qe(`Unknown adapter '${a}'`);if(o&&(R.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([d,u])=>`adapter ${d} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=r?i.length>1?`since :
|
|
44
44
|
`+i.map(bp).join(`
|
|
45
45
|
`):" "+bp(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 vp={getAdapter:kA,adapters:_l};function kl(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ss(null,e)}function wp(e){return kl(e),e.headers=mr.from(e.headers),e.data=Nl.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),vp.getAdapter(e.adapter||ns.adapter,e)(e).then(function(n){return kl(e),n.data=Nl.call(e,e.transformResponse,n),n.headers=mr.from(n.headers),n},function(n){return sp(n)||(kl(e),n&&n.response&&(n.response.data=Nl.call(e,e.transformResponse,n.response),n.response.headers=mr.from(n.response.headers))),Promise.reject(n)})}const Sp="1.14.0",Ci={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ci[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const xp={};Ci.transitional=function(t,r,n){function o(s,i){return"[Axios v"+Sp+"] 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&&!xp[i]&&(xp[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}},Ci.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function TA(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],d=a===void 0||i(a,s,e);if(d!==!0)throw new qe("option "+s+" must be "+d,qe.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new qe("Unknown option "+s,qe.ERR_BAD_OPTION)}}const Ei={assertOptions:TA,validators:Ci},Or=Ei.validators;let Wn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new rp,response:new rp}}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+=`
|
|
46
|
-
`+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Hn(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&Ei.assertOptions(n,{silentJSONParsing:Or.transitional(Or.boolean),forcedJSONParsing:Or.transitional(Or.boolean),clarifyTimeoutError:Or.transitional(Or.boolean),legacyInterceptorReqResOrdering:Or.transitional(Or.boolean)},!1),o!=null&&(R.isFunction(o)?r.paramsSerializer={serialize:o}:Ei.assertOptions(o,{encode:Or.function,serialize:Or.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Ei.assertOptions(r,{baseUrl:Or.spelling("baseURL"),withXsrfToken:Or.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&R.merge(s.common,s[r.method]);s&&R.forEach(["delete","get","head","post","put","patch","common"],g=>{delete s[g]}),r.headers=mr.concat(i,s);const a=[];let d=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(r)===!1)return;d=d&&h.synchronous;const y=r.transitional||xl;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 l,f=0,p;if(!d){const g=[wp.bind(this),void 0];for(g.unshift(...a),g.push(...u),p=g.length,l=Promise.resolve(r);f<p;)l=l.then(g[f++],g[f++]);return l}p=a.length;let m=r;for(;f<p;){const g=a[f++],h=a[f++];try{m=g(m)}catch(y){h.call(this,y);break}}try{l=wp.call(this,m)}catch(g){return Promise.reject(g)}for(f=0,p=u.length;f<p;)l=l.then(u[f++],u[f++]);return l}getUri(t){t=Hn(this.defaults,t);const r=cp(t.baseURL,t.url,t.allowAbsoluteUrls);return tp(r,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){Wn.prototype[t]=function(r,n){return this.request(Hn(n||{},{method:t,url:r,data:(n||{}).data}))}}),R.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,a){return this.request(Hn(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Wn.prototype[t]=r(),Wn.prototype[t+"Form"]=r(!0)});let FA=class Fy{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 ss(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 Fy(function(o){t=o}),cancel:t}}};function PA(e){return function(r){return e.apply(null,r)}}function OA(e){return R.isObject(e)&&e.isAxiosError===!0}const Tl={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(Tl).forEach(([e,t])=>{Tl[t]=e});function Ap(e){const t=new Wn(e),r=Uf(Wn.prototype.request,t);return R.extend(r,Wn.prototype,t,{allOwnKeys:!0}),R.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return Ap(Hn(e,o))},r}const _t=Ap(ns);_t.Axios=Wn,_t.CanceledError=ss,_t.CancelToken=FA,_t.isCancel=sp,_t.VERSION=Sp,_t.toFormData=wi,_t.AxiosError=qe,_t.Cancel=_t.CanceledError,_t.all=function(t){return Promise.all(t)},_t.spread=PA,_t.isAxiosError=OA,_t.mergeConfig=Hn,_t.AxiosHeaders=mr,_t.formToJSON=e=>np(R.isHTMLForm(e)?new FormData(e):e),_t.getAdapter=vp.getAdapter,_t.HttpStatusCode=Tl,_t.default=_t;const{Axios:HP,AxiosError:IA,CanceledError:WP,isCancel:RP,CancelToken:GP,VERSION:KP,all:qP,Cancel:YP,isAxiosError:XP,spread:JP,toFormData:QP,AxiosHeaders:ZP,HttpStatusCode:eO,formToJSON:tO,getAdapter:rO,mergeConfig:nO}=_t;function or(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 MA(e){const t={array:[],pathPrefixToStrip:""};function r(a,d){if(a===null||typeof a!="object")return null;if(Array.isArray(a)&&a.length>0)return{array:a,fullPath:d};const u=Object.keys(a);for(const l of u){const f=a[l],p=d?`${d}.${l}`:l;if(Array.isArray(f)&&f.length>0)return{array:f,fullPath:p};if(f!==null&&typeof f=="object"){const m=r(f,p);if(m)return m}}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 LA(e){return e.length>=4&&Array.isArray(e[3])&&e[3].length===0}function DA(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(".")?or(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(".")?or(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 Fl(e,t,r){if(!e)return[];if(Array.isArray(e)){if(e.length===0)return[];if(LA(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=>DA(o,t,r))}if(typeof e=="object"){const{array:n,pathPrefixToStrip:o}=MA(e);if(Array.isArray(n)&&n.length>0){const s=d=>!d||!d.trim()||!o?d:d.startsWith(o)?d.substring(o.length).replace(/^\.+/,"")||void 0:d,i=s(t),a=s(r);return Fl(n,i,a)}}return[]}function BA(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 $A(e){return Array.isArray(e)&&e.length>=4&&Array.isArray(e[3])&&e[3].length>0&&Array.isArray(e[3][0])}function jA(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 Cp(e){const{response:t,sourceUrl:r,rowsIndex:n,rowsPath:o,columns:s,columnsQueryParam:i="sf",columnsQueryParamSeparator:a=","}=e;let d;if(o&&o.trim()?d=or(t,o):typeof n=="number"?d=t?.[n]:d=t,!Array.isArray(d)||d.length===0)return[];const u=d.filter(p=>Array.isArray(p));if(u.length===0)return Array.isArray(d[0])?[]:null;if(!Array.isArray(u[0]))return null;const l=jA(r,i,a),f=l.length>0?l:Array.isArray(s)&&s.length>0?s:[];return u.map(p=>{const m={};return(f.length>0?f:Array.from({length:p.length},(h,y)=>`col${y}`)).forEach((h,y)=>{m[h]=p[y]}),m})}function zA(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(f=>f!=null&&typeof f=="object"&&!Array.isArray(f));if(i.length===0)return[];const a=Array.isArray(n)?n.filter(Boolean):[],d=o??" - ",u=f=>{if(r){const p=r.includes(".")?or(f,r):f?.[r];if(p!=null&&String(p).trim()!=="")return String(p)}return String(f?.label??f?.name??f?.title??f?.text??f?.username??f?.email??f?.value??f?.id??f)},l=(f,p)=>{if(s){const m=s.includes(".")?or(f,s):f?.[s];if(m!=null)return String(m)}return String(f?.value??f?.id??f?.key??f?.email??f?.username??f?.label??f?.name??p??f)};return i.map(f=>{let p="";a.length>0&&(p=a.map(h=>or(f,h)).filter(h=>h!=null&&String(h).trim()!=="").map(h=>String(h)).join(d)),p||(p=u(f));const m=l(f,p);return{label:typeof p=="string"?p:String(p??""),value:typeof m=="string"?m:String(m??""),disabled:!!f?.disabled}})}let Ep=null;function UA(e){Ep=e}function Np(){return(Ep?.()??"").replace(/\/+$/,"")}function cn(e){const t=typeof e=="string"?e.trim():"";if(!t||/^https?:\/\//i.test(t))return t;const r=Np();return r?t.startsWith("/")?`${r}${t}`:`${r}/${t}`:t}function _p({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,valueSource:n.valueSource,optionsSource:n.optionsSource}:null,s=e.apidata||null,i=o||s,[a,d]=S.useState([]),[u,l]=S.useState([]),[f,p]=S.useState([]),[m,g]=S.useState(!1),[h,y]=S.useState(null),w=!!(i?.apiEndpoint&&(i?.valueSource==="api"||i?.optionsSource==="api"||n?.valueSource==="api"||n?.optionsSource==="api")),v=e.options||n?.options||[],x=S.useMemo(()=>BA(Array.isArray(v)?v:[]),[v]),E=S.useMemo(()=>{const I=i?.apiEndpoint||n?.apiEndpoint||"",T=i?.apiQueryParams||n?.apiQueryParams;return $s(I,T)},[i?.apiEndpoint,n?.apiEndpoint,i?.apiQueryParams,n?.apiQueryParams]),P=S.useMemo(()=>{const I=new Set;for(const W of n?.dependentFields??[])typeof W=="string"&&W.trim()&&I.add(W.trim());const T=i?.apiClientFilter?.matchField?.trim()||n?.apiClientFilter?.matchField?.trim();return T&&I.add(T),[...I]},[n?.dependentFields,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField]),k=S.useMemo(()=>{const I=new Set([...E,...P]);if(I.size===0)return null;const T={};return I.forEach(W=>{T[W]=t[W]}),JSON.stringify(T)},[E,P,t]),N=S.useMemo(()=>JSON.stringify(r||{}),[r]),C=S.useMemo(()=>{const I=new Set;e.name?.trim()&&I.add(e.name.trim());const T=e.key;return typeof T=="string"&&T.trim()&&I.add(T.trim()),[...I]},[e.name,e.key]);return S.useEffect(()=>{const I=i?.apiEndpoint;if(!w||!I){d([]);return}let T=!1;return(async()=>{a.length===0&&g(!0),y(null);try{const O=i?.apiMethod||n?.apiMethod||"GET",j=i?.apiRealtime||n?.apiRealtime,M=i?.apiQueryParams||n?.apiQueryParams||{},D=zd({apiEndpoint:I,apiMethod:O,apiQueryParams:M,formValues:t,submissionContext:r,apiRealtime:j,additionalRequiredFieldNames:P,excludeFormFieldNames:C});if(D.blocked){T||(d([]),g(!1));return}const L={"Content-Type":"application/json"},U=i?.apiKey||n?.apiKey;U&&(L["X-CSCAPI-KEY"]=U);const $={method:O.toLowerCase(),url:cn(D.url),headers:L};D.postBodyBase!=null&&($.data=D.postBodyBase);const ie=await _t($),V=i?.apiLabelField||n?.apiLabelField,K=i?.apiValueField||n?.apiValueField,J=ie.data;let ce=[];Array.isArray(J)?ce=J:J?.data&&(Array.isArray(J.data)?ce=J.data:J.data?.data&&Array.isArray(J.data.data)?ce=J.data.data:J.data.districts?ce=J.data.districts:J.data.states?ce=J.data.states:J.data.cities&&(ce=J.data.cities)),p(ce);const ne=Fl(ie.data,V,K);l(ne);const G=i?.apiClientFilter||n?.apiClientFilter;let ee=ne;if(G?.filterField&&G?.matchField){const Pe=t[G.matchField];Pe!=null?ee=ne.filter(oe=>{const re=ce.find(de=>String(or(de,K||"code"))===String(oe.value));if(!re)return!1;const be=or(re,G.filterField);return String(be)===String(Pe)}):ee=[]}T||d(ee)}catch(O){if(T)return;let j="Failed to load options";if(O.response){const M=O.response.data;O.response.status===404?j="API endpoint not found.":O.response.status===401?j="Authentication failed.":typeof M=="string"?j=M:M&&typeof M=="object"&&(j=M.error||M.message||M.detail||j)}else O.message&&(j=String(O.message));y(j),a.length===0&&d([])}finally{T||g(!1)}})(),()=>{T=!0}},[w,i?.apiEndpoint,i?.apiMethod,n?.apiEndpoint,n?.apiMethod,k,P,C,N]),S.useEffect(()=>{const I=i?.apiClientFilter||n?.apiClientFilter;if(!w||!I||f.length===0)return;const T=t[I.matchField],W=i?.apiValueField||n?.apiValueField;if(T==null){d([]);return}const X=u.filter(O=>{const j=f.find(D=>String(or(D,W||"code"))===String(O.value));if(!j)return!1;const M=or(j,I.filterField);return String(M)===String(T)});d(X)},[w,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField,i?.apiClientFilter?.filterField,n?.apiClientFilter?.filterField,i?.apiValueField,n?.apiValueField,t[i?.apiClientFilter?.matchField||n?.apiClientFilter?.matchField||""],u,f]),{options:w?a:x,isLoadingOptions:m,optionsError:h}}const kp=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,formValues:d={},submissionContext:u,excludedOptionValues:l,isPrepopulateTarget:f=!1})=>{const p=e.properties,m=p?.apiEndpoint?{apiEndpoint:p.apiEndpoint,valueSource:p.valueSource,optionsSource:p.optionsSource}:null,g=e.apidata||null,h=m||g,y=!!(h?.apiEndpoint&&(h?.valueSource==="api"||h?.optionsSource==="api"||p?.valueSource==="api"||p?.optionsSource==="api")),{options:w,isLoadingOptions:v,optionsError:x}=_p({field:e,formValues:d,submissionContext:u}),E=l?.length?new Set(l.map(String)):null,P=E?w.filter($=>!E.has(String($.value??$.label??""))):w,k="__clear__",N=t!=null&&String(t).trim()!=="",C=N?P.some($=>String($.value??$.label??"")===String(t)):!1,A=S.useMemo(()=>{if(!N||C)return P;const $=String(t);return[{label:$,value:$},...P]},[P,N,C,t]),I=N?String(t):void 0,T=`${ht(e)}-${I??"empty"}`,W=S.useCallback($=>{r($===k?"":$),n?.()},[r,n]),X=e.appearance?.size||"md",O={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},j=e.placeholder||"Select an option",M=p?.apiClientFilter?.matchField?.trim()||h?.apiClientFilter?.matchField?.trim(),D=y&&M&&(d[M]===void 0||d[M]===null||d[M]===""),L=v?"Loading options...":D?`Select ${M} first`:l?.length?"No available options":y?"No options available from API":"No options available";return y&&f&&v?c.jsx(Et,{field:e,error:o||x||void 0,isRequired:i,className:a,children:c.jsxs("div",{role:"status","aria-label":"Loading options",className:B("flex items-center justify-center gap-2 w-full min-w-0 rounded-md border border-input bg-muted/50 text-muted-foreground",O[X],e.appearance?.className),children:[c.jsx(Ro,{className:"h-4 w-4 animate-spin shrink-0"}),c.jsx("span",{className:"truncate",children:"Loading..."})]})}):c.jsx(Et,{field:e,error:o||x||void 0,isRequired:i,className:a,children:c.jsxs(t0,{value:I,onValueChange:W,disabled:s||e.disabled||v&&P.length===0,children:[c.jsx(n0,{id:ht(e),"aria-describedby":jt(e,!!o||!!x),"aria-invalid":Jt(!!o||!!x),"aria-required":i,className:B("w-full min-w-0",O[X],o&&"border-destructive focus-visible:ring-destructive",x&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:c.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[v&&c.jsx(Ro,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"}),P.length===0&&l?.length&&!N?c.jsx("span",{className:"text-muted-foreground truncate",children:"No available options"}):N?c.jsx(r0,{placeholder:j}):c.jsx("span",{className:"text-muted-foreground truncate",children:j})]})}),c.jsx(o0,{children:A.length===0?c.jsx(gl,{value:"__no_options__",disabled:!0,children:L}):c.jsxs(c.Fragment,{children:[N?c.jsx(gl,{value:k,children:j}):null,A.map(($,ie)=>{const V=String($.value??$.label??ie);if(V===k)return null;const K=$.label||$.value||String($);return c.jsx(gl,{value:V,disabled:$.disabled||!1,children:K},V)})]})})]},T)})},Tp=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Fp=Jc,Pp=(e,t)=>r=>{var n;if(t?.variants==null)return Fp(e,r?.class,r?.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(u=>{const l=r?.[u],f=s?.[u];if(l===null)return null;const p=Tp(l)||Tp(f);return o[u][p]}),a=r&&Object.entries(r).reduce((u,l)=>{let[f,p]=l;return p===void 0||(u[f]=p),u},{}),d=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,l)=>{let{class:f,className:p,...m}=l;return Object.entries(m).every(g=>{let[h,y]=g;return Array.isArray(y)?y.includes({...s,...a}[h]):{...s,...a}[h]===y})?[...u,f,p]:u},[]);return Fp(e,i,d,r?.class,r?.className)},VA=Pp("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 Yt({className:e,variant:t,size:r,asChild:n=!1,...o}){const s=n?qd:"button";return c.jsx(s,{"data-slot":"button",className:B(VA({variant:t,size:r,className:e})),...o})}function HA(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var xr=e=>{const{present:t,children:r}=e,n=WA(t),o=typeof r=="function"?r({present:n.isPresent}):b.Children.only(r),s=Ze(n.ref,RA(o));return typeof r=="function"||n.isPresent?b.cloneElement(o,{ref:s}):null};xr.displayName="Presence";function WA(e){const[t,r]=b.useState(),n=b.useRef(null),o=b.useRef(e),s=b.useRef("none"),i=e?"mounted":"unmounted",[a,d]=HA(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const u=Ni(n.current);s.current=a==="mounted"?u:"none"},[a]),Qt(()=>{const u=n.current,l=o.current;if(l!==e){const p=s.current,m=Ni(u);e?d("MOUNT"):m==="none"||u?.display==="none"?d("UNMOUNT"):d(l&&p!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),Qt(()=>{if(t){let u;const l=t.ownerDocument.defaultView??window,f=m=>{const h=Ni(n.current).includes(CSS.escape(m.animationName));if(m.target===t&&h&&(d("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=m=>{m.target===t&&(s.current=Ni(n.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{l.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:b.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function Ni(e){return e?.animationName||"none"}function RA(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 GA(e){const t=KA(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(YA);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function KA(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=JA(o),a=XA(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(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 qA=Symbol("radix.slottable");function YA(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qA}function XA(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 d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function JA(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 _i="Popover",[Op]=vr(_i,[ri]),is=ri(),[QA,kn]=Op(_i),Ip=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=is(t),d=b.useRef(null),[u,l]=b.useState(!1),[f,p]=Zr({prop:n,defaultProp:o??!1,onChange:s,caller:_i});return c.jsx(Ju,{...a,children:c.jsx(QA,{scope:t,contentId:on(),triggerRef:d,open:f,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(m=>!m),[p]),hasCustomAnchor:u,onCustomAnchorAdd:b.useCallback(()=>l(!0),[]),onCustomAnchorRemove:b.useCallback(()=>l(!1),[]),modal:i,children:r})})};Ip.displayName=_i;var Mp="PopoverAnchor",Lp=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=kn(Mp,r),s=is(r),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return b.useEffect(()=>(i(),()=>a()),[i,a]),c.jsx(nl,{...s,...n,ref:t})});Lp.displayName=Mp;var Dp="PopoverTrigger",Bp=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=kn(Dp,r),s=is(r),i=Ze(t,o.triggerRef),a=c.jsx(Be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Vp(o.open),...n,ref:i,onClick:Me(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:c.jsx(nl,{asChild:!0,...s,children:a})});Bp.displayName=Dp;var Pl="PopoverPortal",[ZA,eC]=Op(Pl,{forceMount:void 0}),$p=e=>{const{__scopePopover:t,forceMount:r,children:n,container:o}=e,s=kn(Pl,t);return c.jsx(ZA,{scope:t,forceMount:r,children:c.jsx(xr,{present:r||s.open,children:c.jsx(ni,{asChild:!0,container:o,children:n})})})};$p.displayName=Pl;var ho="PopoverContent",jp=b.forwardRef((e,t)=>{const r=eC(ho,e.__scopePopover),{forceMount:n=r.forceMount,...o}=e,s=kn(ho,e.__scopePopover);return c.jsx(xr,{present:n||s.open,children:s.modal?c.jsx(rC,{...o,ref:t}):c.jsx(nC,{...o,ref:t})})});jp.displayName=ho;var tC=GA("PopoverContent.RemoveScroll"),rC=b.forwardRef((e,t)=>{const r=kn(ho,e.__scopePopover),n=b.useRef(null),o=Ze(t,n),s=b.useRef(!1);return b.useEffect(()=>{const i=n.current;if(i)return sl(i)},[]),c.jsx(ui,{as:tC,allowPinchZoom:!0,children:c.jsx(zp,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Me(e.onCloseAutoFocus,i=>{i.preventDefault(),s.current||r.triggerRef.current?.focus()}),onPointerDownOutside:Me(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,d=a.button===0&&a.ctrlKey===!0,u=a.button===2||d;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Me(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),nC=b.forwardRef((e,t)=>{const r=kn(ho,e.__scopePopover),n=b.useRef(!1),o=b.useRef(!1);return c.jsx(zp,{...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()}})}),zp=b.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:l,...f}=e,p=kn(ho,r),m=is(r);return za(),c.jsx(Rs,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Ws,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:l,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:c.jsx(Qu,{"data-state":Vp(p.open),role:"dialog",id:p.contentId,...m,...f,ref:t,style:{...f.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)"}})})})}),Up="PopoverClose",oC=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=kn(Up,r);return c.jsx(Be.button,{type:"button",...n,ref:t,onClick:Me(e.onClick,()=>o.onOpenChange(!1))})});oC.displayName=Up;var sC="PopoverArrow",iC=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=is(r);return c.jsx(Zu,{...o,...n,ref:t})});iC.displayName=sC;function Vp(e){return e?"open":"closed"}var aC=Ip,lC=Lp,cC=Bp,dC=$p,uC=jp;function Ol({...e}){return c.jsx(aC,{"data-slot":"popover",...e})}function Hp({...e}){return c.jsx(cC,{"data-slot":"popover-trigger",...e})}function Il({className:e,align:t="center",sideOffset:r=4,...n}){return c.jsx(dC,{children:c.jsx(uC,{"data-slot":"popover-content",align:t,sideOffset:r,className:B("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 fC({...e}){return c.jsx(lC,{"data-slot":"popover-anchor",...e})}const Wp={};function Tn(){const e=Wp?.VITE_CLIENT_ID?.trim()||Wp?.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 pC(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 mC(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 Rn=Pd(e=>({viewerContext:void 0,authHeaders:void 0,_setViewerContext:t=>e({viewerContext:pC(t)?t:void 0}),_setAuthHeaders:t=>e({authHeaders:mC(t)}),_reset:()=>e({viewerContext:void 0,authHeaders:void 0})}));function hC(e){Rn.getState()._setViewerContext(e)}function gC(e){Rn.getState()._setAuthHeaders(e)}function yC(){Rn.getState()._reset()}function bC(){return Rn.getState().viewerContext}function Ml(){return Rn.getState().authHeaders}const Rp={};let Gp=null;function vC(e){Gp=e}function wC(){return(Rp?.VITE_API_BASE_URL?.trim()||Rp?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const dn=_t.create({baseURL:wC()});dn.interceptors.request.use(e=>{const t=Tn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=Gp?.();if((!r||Object.keys(r).length===0)&&(r=Ml()),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});function Kp(e){return JSON.stringify(e).slice(1,-1)}function qp(e){const t=e.asyncSearchValueObjectKeys;return Array.isArray(t)?t.map(r=>typeof r=="string"?r.trim():"").filter(Boolean):[]}function SC(e){return e.asyncSearchValueMode==="object"&&qp(e).length>0}function xC(e,t){const r={};for(const n of t){const o=n.trim();if(!o)continue;const s=or(e,o);s==null||typeof s=="object"?r[o]="":r[o]=String(s)}return r}function AC(e,t){const r=t.mode??"debounce",n=Math.max(0,t.intervalMs??300),[o,s]=S.useState(()=>r==="throttle"?e:""),i=S.useRef(0),a=S.useRef(void 0);return S.useEffect(()=>{if(e===""){a.current&&clearTimeout(a.current),s("");return}if(r==="debounce"){const l=setTimeout(()=>s(e),n);return()=>clearTimeout(l)}const d=Date.now(),u=d-i.current;return u>=n?(i.current=d,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 Ll(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 Dl(e,t){return e==null||e===""?!0:t&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length===0:!1}function CC(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 EC(e){if(_t.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 NC(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 Yp(e,t){return typeof t=="number"&&t>0?e.slice(0,t):e}function Bl(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.label=="string"&&t.value!==null&&t.value!==void 0}const Xp=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d,formValues:u={},submissionContext:l})=>{const f=e.properties||{},p=SC(f),m=f.apiEndpoint?.trim()||"",g=f.apiRealtime===!0,h=(f.apiMethod||"GET").toUpperCase()==="POST"?"POST":"GET",y=f.searchInBody===!0,w=h==="POST"||h==="GET"&&y,v=f.searchStrategy??f.searchSchedule??"debounce",x=f.searchIntervalMs??f.intervalMs??300,E=f.minQueryLength??0,P=f.maxResults,k=f.searchQueryParam||"q",N=f.clearable!==!1,C=u,[A,I]=S.useState(()=>Dl(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t)),[T,W]=S.useState(!1),[X,O]=S.useState([]),[j,M]=S.useState([]),[D,L]=S.useState([]),[U,$]=S.useState(!1),[ie,V]=S.useState(null),[K,J]=S.useState(-1),ce=S.useRef(Ll(t,p)),ne=S.useRef(Dl(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t??"")),G=S.useRef(void 0),ee=S.useRef(0),Pe=S.useRef(null),oe=AC(A,{mode:v,intervalMs:x}),re=S.useMemo(()=>X.filter(Bl),[X]);S.useEffect(()=>{if(re.length===0){K!==-1&&J(-1);return}(K<0||K>=re.length)&&J(0)},[K,re.length]);const be=S.useMemo(()=>{const te=$s(m,f.apiQueryParams),pe=new Set(te);for(const We of f.dependentFields||[])We&&pe.add(We);return pe},[m,f.apiQueryParams,f.dependentFields]),de=S.useMemo(()=>{if(be.size===0)return null;const te={};return be.forEach(pe=>{te[pe]=C[pe]}),JSON.stringify(te)},[be,C]),ot=S.useMemo(()=>JSON.stringify(u),[u]),Se=S.useMemo(()=>JSON.stringify(l||{}),[l]);S.useEffect(()=>{const te=Ll(t,p);if(te===ce.current)return;if(ce.current=te,Dl(t,p)){ne.current="",I(""),O([]),M([]),L([]),V(null),W(!1);return}const pe=f.initialDisplayLabel||(!p&&typeof t=="string"?t:"");ne.current=pe,I(pe)},[t,f.initialDisplayLabel,p]),S.useEffect(()=>{if(!m){O([]),M([]),L([]),$(!1);return}if(i||s||e.disabled){O([]),M([]),L([]),$(!1);return}const te=oe;if(te.length<E){O([]),M([]),L([]),$(!1),V(null);return}const pe=zd({apiEndpoint:m,apiMethod:h,apiQueryParams:f.apiQueryParams,formValues:C,submissionContext:l,apiRealtime:g,additionalRequiredFieldNames:f.dependentFields});if(pe.blocked){O([]),M([]),L([]),$(!1),V(null);return}Pe.current?.abort();const We=new AbortController;Pe.current=We;const Pt=++ee.current;return(async()=>{$(!0),V(null);const Te=cn(pe.url),Xe={};w&&(Xe["Content-Type"]="application/json"),f.apiKey&&(Xe["X-CSCAPI-KEY"]=f.apiKey);try{let Ue;if(!w)Ue=(await dn.get(Te,{params:{[k]:te},signal:We.signal,headers:Object.keys(Xe).length?Xe:void 0})).data;else{let It={};pe.postBodyBase&&Object.keys(pe.postBodyBase).length>0?It={...pe.postBodyBase}:g&&Object.keys(C).length>0&&(It={...C});let Er=It;if(f.searchBodyTemplate?.trim()){let sr=f.searchBodyTemplate.replace(/\{\{query\}\}/g,()=>Kp(te)).replace(/\{query\}/g,()=>Kp(te));sr=Wb(sr,C,l,g);const fn=JSON.parse(sr);Er={...It,...fn}}else Er={...It,[k]:te};Ue=(await dn.post(Te,Er,{signal:We.signal,headers:Object.keys(Xe).length?Xe:void 0})).data}if(Pt!==ee.current)return;const ft=f.apiResultsFormat,St=f.apiResultsConfig,xt=ft==="clinicaltables_v3",ze=$A(Ue),pt=xt||ft===void 0&&ze,At=ft==="tuple_array";let Ut=null;pt?Ut=Cp({response:Ue,sourceUrl:Te,rowsIndex:St?.rowsIndex??3,rowsPath:St?.rowsPath,columns:St?.columns,columnsQueryParam:St?.columnsQueryParam??"sf",columnsQueryParamSeparator:St?.columnsQueryParamSeparator??","}):At&&(Ut=Cp({response:Ue,sourceUrl:Te,rowsIndex:St?.rowsIndex,rowsPath:St?.rowsPath,columns:St?.columns,columnsQueryParam:St?.columnsQueryParam,columnsQueryParamSeparator:St?.columnsQueryParamSeparator}));const ur=NC(Ue),Ar=Ut!==null,Vt=Ut&&Array.isArray(Ut)?Ut:Array.isArray(ur)&&ur.every(It=>It&&typeof It=="object"&&!Array.isArray(It))?ur:null;L(Vt??ur);const Po=Array.isArray(f.apiLabelFields)&&f.apiLabelFields.length>0,Xn=Vt&&(Ar||Po)?zA({rows:Vt,apiLabelField:f.apiLabelField,apiLabelFields:f.apiLabelFields,apiLabelSeparator:f.apiLabelSeparator,apiValueField:f.apiValueField}):Fl(Ue,f.apiLabelField,f.apiValueField);M(Xn);const Ct=f.apiClientFilter;let Cr=Xn;if(Ct?.filterField&&Ct?.matchField){const It=C[Ct.matchField];if(It!=null){const Er=f.apiValueField;Cr=Xn.filter(er=>{const fn=(Vt??ur).find(kt=>String(or(kt,Er||"code"))===String(er.value));if(!fn)return!1;const yr=or(fn,Ct.filterField);return String(yr)===String(It)})}else Cr=[]}const Jn=Yp(Cr,P).filter(Bl);O(Jn),J(Jn.length>0?0:-1)}catch(Ue){if(_t.isCancel(Ue)||Ue?.code==="ERR_CANCELED"||Pt!==ee.current)return;O([]),M([]),L([]),V(EC(Ue)),J(-1)}finally{Pt===ee.current&&$(!1)}})(),()=>{We.abort()}},[oe,m,h,y,w,k,E,P,f.apiKey,f.searchBodyTemplate,f.apiLabelField,f.apiLabelFields,f.apiLabelSeparator,f.apiValueField,f.apiQueryParams,f.apiClientFilter,f.apiResultsFormat,f.apiResultsConfig,f.dependentFields,g,C,l,i,s,e.disabled,de,ot,Se]),S.useEffect(()=>{const te=f.apiClientFilter;if(!te||D.length===0||j.length===0)return;const pe=C[te.matchField],We=f.apiValueField;if(pe==null){O([]);return}const Pt=j.filter(Te=>{const Xe=D.find(ft=>String(or(ft,We||"code"))===String(Te.value));if(!Xe)return!1;const Ue=or(Xe,te.filterField);return String(Ue)===String(pe)}),je=Yp(Pt,P).filter(Bl);O(je),J(je.length>0?0:-1)},[f.apiClientFilter,f.apiValueField,C,P,j,D]);const xe=s||e.disabled,ae=i||e.readOnly,ve=S.useCallback(te=>{const pe=te.target.value;ae||xe||(ce.current&&ne.current&&pe!==ne.current&&(ce.current="",ne.current="",r(p?null:"")),I(pe),W(!0),J(-1))},[xe,ae,p,r]),Ye=S.useCallback(te=>{const pe=typeof te?.label=="string"?te.label:String(te?.value??""),We=f.apiValueField||"code";if(p){const Pt=qp(f),je=D.find(Te=>String(or(Te,We))===String(te.value));if(je&&typeof je=="object"&&!Array.isArray(je)&&Pt.length>0){const Te=xC(je,Pt);ce.current=Ll(Te,!0),ne.current=pe,r(Te),I(pe)}else ce.current=`S:${String(te.value)}`,ne.current=pe,r(String(te.value)),I(pe)}else ce.current=`S:${String(te.value)}`,ne.current=pe,r(String(te.value)),I(pe);G.current&&clearTimeout(G.current),W(!1),J(-1),n?.()},[p,n,r,f,D]),ct=S.useCallback(te=>{te.preventDefault(),te.stopPropagation(),!(xe||ae)&&(ce.current="",ne.current="",r(p?null:""),I(""),O([]),M([]),L([]),V(null),W(!1),n?.())},[xe,ae,p,r,n]),Ge=S.useMemo(()=>T&&!ae&&(U||!!ie||re.length>0||oe.length>=E&&!U),[T,ae,U,ie,re.length,oe,E]),Kt=S.useCallback(te=>{if(!(ae||xe))if(te.key==="ArrowDown")te.preventDefault(),W(!0),J(pe=>re.length===0?-1:(pe+1)%re.length);else if(te.key==="ArrowUp")te.preventDefault(),W(!0),J(pe=>re.length===0?-1:pe<=0?re.length-1:pe-1);else if(te.key==="Enter"){const pe=K>=0?re[K]:void 0;Ge&&pe&&!pe.disabled&&(te.preventDefault(),Ye(pe))}else te.key==="Escape"&&W(!1)},[xe,ae,K,Ge,re,Ye]),Je=e.appearance?.size||"md",q={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},$e=ht(e),gt=jt(e,!!(o||ie)),Oe=oe.length>=E&&!U&&!ie&&re.length===0;return c.jsx(Et,{field:e,error:o||ie||void 0,isRequired:a,className:d,children:c.jsxs(Ol,{open:Ge,onOpenChange:te=>{te||W(!1)},children:[c.jsx(fC,{asChild:!0,children:c.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[c.jsx(wn,{id:$e,role:"combobox","aria-expanded":Ge,"aria-autocomplete":"list","aria-controls":Ge?`${$e}-listbox`:void 0,"aria-activedescendant":K>=0?`${$e}-opt-${K}`:void 0,value:A,onChange:ve,onKeyDown:Kt,onFocus:()=>{G.current&&clearTimeout(G.current),!ae&&!xe&&W(!0)},onBlur:()=>{G.current=setTimeout(()=>{W(!1),n?.()},150)},placeholder:e.placeholder||"Search…",disabled:xe,readOnly:ae,"aria-describedby":gt,"aria-invalid":Jt(!!(o||ie)),"aria-required":a,className:B("pr-20",q[Je],(o||ie)&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),c.jsxs("div",{className:"pointer-events-none absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[U&&c.jsx(Ro,{className:"pointer-events-none h-4 w-4 animate-spin text-muted-foreground"}),N&&CC(t,A,p)&&!xe&&!ae&&c.jsx(Yt,{type:"button",variant:"ghost",size:"icon",className:"pointer-events-auto h-8 w-8 shrink-0",onMouseDown:te=>te.preventDefault(),onClick:ct,"aria-label":"Clear",children:c.jsx(Ko,{className:"h-4 w-4"})})]})]})}),c.jsx(Il,{className:"p-0 w-[var(--radix-popover-trigger-width)] min-w-[12rem] overflow-hidden",align:"start",onOpenAutoFocus:te=>te.preventDefault(),onCloseAutoFocus:te=>te.preventDefault(),children:c.jsx("div",{id:`${$e}-listbox`,role:"listbox",children:ie?c.jsx("div",{className:"px-3 py-2 text-sm text-destructive",children:ie}):U?c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground",children:[c.jsx(Ro,{className:"h-4 w-4 animate-spin shrink-0"}),"Loading…"]}):Oe?c.jsx("ul",{className:"py-1","aria-label":"Search results",children:c.jsx("li",{role:"option","aria-disabled":!0,className:"cursor-default select-none px-3 py-2 text-sm text-muted-foreground",onMouseDown:te=>te.preventDefault(),children:"No results found"})}):c.jsx("ul",{className:"max-h-60 overflow-y-auto overscroll-contain py-1","aria-label":"Search results",children:re.map((te,pe)=>c.jsx("li",{id:`${$e}-opt-${pe}`,role:"option","aria-selected":K===pe,className:B(te.disabled?"cursor-not-allowed opacity-60":"cursor-pointer","px-3 py-2 text-sm",K===pe&&"bg-accent text-accent-foreground"),onMouseEnter:()=>J(pe),onMouseDown:We=>We.preventDefault(),onClick:()=>{te.disabled||Ye(te)},children:te.label},`${te.value}-${pe}`))})})})]})})};var ki="Checkbox",[_C]=vr(ki),[kC,$l]=_C(ki);function TC(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:o,disabled:s,form:i,name:a,onCheckedChange:d,required:u,value:l="on",internal_do_not_use_render:f}=e,[p,m]=Zr({prop:r,defaultProp:o??!1,onChange:d,caller:ki}),[g,h]=b.useState(null),[y,w]=b.useState(null),v=b.useRef(!1),x=g?!!i||!!g.closest("form"):!0,E={checked:p,disabled:s,setChecked:m,control:g,setControl:h,name:a,form:i,value:l,hasConsumerStoppedPropagationRef:v,required:u,defaultChecked:Fn(o)?!1:o,isFormControl:x,bubbleInput:y,setBubbleInput:w};return c.jsx(kC,{scope:t,...E,children:FC(f)?f(E):n})}var Jp="CheckboxTrigger",Qp=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},o)=>{const{control:s,value:i,disabled:a,checked:d,required:u,setControl:l,setChecked:f,hasConsumerStoppedPropagationRef:p,isFormControl:m,bubbleInput:g}=$l(Jp,e),h=Ze(o,l),y=b.useRef(d);return b.useEffect(()=>{const w=s?.form;if(w){const v=()=>f(y.current);return w.addEventListener("reset",v),()=>w.removeEventListener("reset",v)}},[s,f]),c.jsx(Be.button,{type:"button",role:"checkbox","aria-checked":Fn(d)?"mixed":d,"aria-required":u,"data-state":om(d),"data-disabled":a?"":void 0,disabled:a,value:i,...n,ref:h,onKeyDown:Me(t,w=>{w.key==="Enter"&&w.preventDefault()}),onClick:Me(r,w=>{f(v=>Fn(v)?!0:!v),g&&m&&(p.current=w.isPropagationStopped(),p.current||w.stopPropagation())})})});Qp.displayName=Jp;var Zp=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:o,defaultChecked:s,required:i,disabled:a,value:d,onCheckedChange:u,form:l,...f}=e;return c.jsx(TC,{__scopeCheckbox:r,checked:o,defaultChecked:s,disabled:a,required:i,onCheckedChange:u,name:n,form:l,value:d,internal_do_not_use_render:({isFormControl:p})=>c.jsxs(c.Fragment,{children:[c.jsx(Qp,{...f,ref:t,__scopeCheckbox:r}),p&&c.jsx(nm,{__scopeCheckbox:r})]})})});Zp.displayName=ki;var em="CheckboxIndicator",tm=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...o}=e,s=$l(em,r);return c.jsx(xr,{present:n||Fn(s.checked)||s.checked===!0,children:c.jsx(Be.span,{"data-state":om(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});tm.displayName=em;var rm="CheckboxBubbleInput",nm=b.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:o,checked:s,defaultChecked:i,required:a,disabled:d,name:u,value:l,form:f,bubbleInput:p,setBubbleInput:m}=$l(rm,e),g=Ze(r,m),h=Qo(s),y=Jo(n);b.useEffect(()=>{const v=p;if(!v)return;const x=window.HTMLInputElement.prototype,P=Object.getOwnPropertyDescriptor(x,"checked").set,k=!o.current;if(h!==s&&P){const N=new Event("click",{bubbles:k});v.indeterminate=Fn(s),P.call(v,Fn(s)?!1:s),v.dispatchEvent(N)}},[p,h,s,o]);const w=b.useRef(Fn(s)?!1:s);return c.jsx(Be.input,{type:"checkbox","aria-hidden":!0,defaultChecked:i??w.current,required:a,disabled:d,name:u,value:l,form:f,...t,tabIndex:-1,ref:g,style:{...t.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});nm.displayName=rm;function FC(e){return typeof e=="function"}function Fn(e){return e==="indeterminate"}function om(e){return Fn(e)?"indeterminate":e?"checked":"unchecked"}function Ti({className:e,...t}){return c.jsx(Zp,{"data-slot":"checkbox",className:B("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:c.jsx(tm,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:c.jsx(Vs,{className:"size-3.5"})})})}const PC=Pp("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 OC({className:e,variant:t,asChild:r=!1,...n}){const o=r?qd:"span";return c.jsx(o,{"data-slot":"badge",className:B(PC({variant:t}),e),...n})}function IC(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var jl="ScrollArea",[sm]=vr(jl),[MC,Ir]=sm(jl),im=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,d]=b.useState(null),[u,l]=b.useState(null),[f,p]=b.useState(null),[m,g]=b.useState(null),[h,y]=b.useState(null),[w,v]=b.useState(0),[x,E]=b.useState(0),[P,k]=b.useState(!1),[N,C]=b.useState(!1),A=Ze(t,T=>d(T)),I=ro(o);return c.jsx(MC,{scope:r,type:n,dir:I,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:l,content:f,onContentChange:p,scrollbarX:m,onScrollbarXChange:g,scrollbarXEnabled:P,onScrollbarXEnabledChange:k,scrollbarY:h,onScrollbarYChange:y,scrollbarYEnabled:N,onScrollbarYEnabledChange:C,onCornerWidthChange:v,onCornerHeightChange:E,children:c.jsx(Be.div,{dir:I,...i,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});im.displayName=jl;var am="ScrollAreaViewport",lm=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...s}=e,i=Ir(am,r),a=b.useRef(null),d=Ze(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(Be.div,{"data-radix-scroll-area-viewport":"",...s,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});lm.displayName=am;var tn="ScrollAreaScrollbar",cm=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Ir(tn,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"?c.jsx(LC,{...n,ref:t,forceMount:r}):o.type==="scroll"?c.jsx(DC,{...n,ref:t,forceMount:r}):o.type==="auto"?c.jsx(dm,{...n,ref:t,forceMount:r}):o.type==="always"?c.jsx(zl,{...n,ref:t}):null});cm.displayName=tn;var LC=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Ir(tn,e.__scopeScrollArea),[s,i]=b.useState(!1);return b.useEffect(()=>{const a=o.scrollArea;let d=0;if(a){const u=()=>{window.clearTimeout(d),i(!0)},l=()=>{d=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",l),()=>{window.clearTimeout(d),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",l)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(xr,{present:r||s,children:c.jsx(dm,{"data-state":s?"visible":"hidden",...n,ref:t})})}),DC=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Ir(tn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Ii(()=>d("SCROLL_END"),100),[a,d]=IC("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(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,d]),b.useEffect(()=>{const u=o.viewport,l=s?"scrollLeft":"scrollTop";if(u){let f=u[l];const p=()=>{const m=u[l];f!==m&&(d("SCROLL"),i()),f=m};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,s,d,i]),c.jsx(xr,{present:r||a!=="hidden",children:c.jsx(zl,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:Me(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Me(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),dm=b.forwardRef((e,t)=>{const r=Ir(tn,e.__scopeScrollArea),{forceMount:n,...o}=e,[s,i]=b.useState(!1),a=e.orientation==="horizontal",d=Ii(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,l=r.viewport.offsetHeight<r.viewport.scrollHeight;i(a?u:l)}},10);return go(r.viewport,d),go(r.content,d),c.jsx(xr,{present:n||s,children:c.jsx(zl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),zl=b.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=Ir(tn,e.__scopeScrollArea),s=b.useRef(null),i=b.useRef(0),[a,d]=b.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=hm(a.viewport,a.content),l={...n,sizes:a,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function f(p,m){return VC(p,i.current,a,m)}return r==="horizontal"?c.jsx(BC,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,m=gm(p,a,o.dir);s.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=f(p,o.dir))}}):r==="vertical"?c.jsx($C,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,m=gm(p,a);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=f(p))}}):null}),BC=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Ir(tn,e.__scopeScrollArea),[i,a]=b.useState(),d=b.useRef(null),u=Ze(t,d,s.onScrollbarXChange);return b.useEffect(()=>{d.current&&a(getComputedStyle(d.current))},[d]),c.jsx(fm,{"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":Oi(r)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.x),onDragScroll:l=>e.onDragScroll(l.x),onWheelScroll:(l,f)=>{if(s.viewport){const p=s.viewport.scrollLeft+l.deltaX;e.onWheelScroll(p),bm(p,f)&&l.preventDefault()}},onResize:()=>{d.current&&s.viewport&&i&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Pi(i.paddingLeft),paddingEnd:Pi(i.paddingRight)}})}})}),$C=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Ir(tn,e.__scopeScrollArea),[i,a]=b.useState(),d=b.useRef(null),u=Ze(t,d,s.onScrollbarYChange);return b.useEffect(()=>{d.current&&a(getComputedStyle(d.current))},[d]),c.jsx(fm,{"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":Oi(r)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.y),onDragScroll:l=>e.onDragScroll(l.y),onWheelScroll:(l,f)=>{if(s.viewport){const p=s.viewport.scrollTop+l.deltaY;e.onWheelScroll(p),bm(p,f)&&l.preventDefault()}},onResize:()=>{d.current&&s.viewport&&i&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Pi(i.paddingTop),paddingEnd:Pi(i.paddingBottom)}})}})}),[jC,um]=sm(tn),fm=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:l,onResize:f,...p}=e,m=Ir(tn,r),[g,h]=b.useState(null),y=Ze(t,A=>h(A)),w=b.useRef(null),v=b.useRef(""),x=m.viewport,E=n.content-n.viewport,P=ar(l),k=ar(d),N=Ii(f,10);function C(A){if(w.current){const I=A.clientX-w.current.left,T=A.clientY-w.current.top;u({x:I,y:T})}}return b.useEffect(()=>{const A=I=>{const T=I.target;g?.contains(T)&&P(I,E)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[x,g,E,P]),b.useEffect(k,[n,k]),go(g,N),go(m.content,N),c.jsx(jC,{scope:r,scrollbar:g,hasThumb:o,onThumbChange:ar(s),onThumbPointerUp:ar(i),onThumbPositionChange:k,onThumbPointerDown:ar(a),children:c.jsx(Be.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:Me(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),w.current=g.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),C(A))}),onPointerMove:Me(e.onPointerMove,C),onPointerUp:Me(e.onPointerUp,A=>{const I=A.target;I.hasPointerCapture(A.pointerId)&&I.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=v.current,m.viewport&&(m.viewport.style.scrollBehavior=""),w.current=null})})})}),Fi="ScrollAreaThumb",pm=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=um(Fi,e.__scopeScrollArea);return c.jsx(xr,{present:r||o.hasThumb,children:c.jsx(zC,{ref:t,...n})})}),zC=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,s=Ir(Fi,r),i=um(Fi,r),{onThumbPositionChange:a}=i,d=Ze(t,f=>i.onThumbChange(f)),u=b.useRef(void 0),l=Ii(()=>{u.current&&(u.current(),u.current=void 0)},100);return b.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(l(),!u.current){const m=HC(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,l,a]),c.jsx(Be.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Me(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),g=f.clientX-m.left,h=f.clientY-m.top;i.onThumbPointerDown({x:g,y:h})}),onPointerUp:Me(e.onPointerUp,i.onThumbPointerUp)})});pm.displayName=Fi;var Ul="ScrollAreaCorner",mm=b.forwardRef((e,t)=>{const r=Ir(Ul,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?c.jsx(UC,{...e,ref:t}):null});mm.displayName=Ul;var UC=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=Ir(Ul,r),[s,i]=b.useState(0),[a,d]=b.useState(0),u=!!(s&&a);return go(o.scrollbarX,()=>{const l=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(l),d(l)}),go(o.scrollbarY,()=>{const l=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(l),i(l)}),u?c.jsx(Be.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 Pi(e){return e?parseInt(e,10):0}function hm(e,t){const r=e/t;return isNaN(r)?0:r}function Oi(e){const t=hm(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function VC(e,t,r,n="ltr"){const o=Oi(r),s=o/2,i=t||s,a=o-i,d=r.scrollbar.paddingStart+i,u=r.scrollbar.size-r.scrollbar.paddingEnd-a,l=r.content-r.viewport,f=n==="ltr"?[0,l]:[l*-1,0];return ym([d,u],f)(e)}function gm(e,t,r="ltr"){const n=Oi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-n,d=r==="ltr"?[0,i]:[i*-1,0],u=qo(e,d);return ym([0,i],[0,a])(u)}function ym(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 bm(e,t){return e>0&&e<t}var HC=(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 Ii(e,t){const r=ar(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 go(e,t){const r=ar(t);Qt(()=>{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 WC=im,RC=lm,GC=mm;function KC({className:e,children:t,...r}){return c.jsxs(WC,{"data-slot":"scroll-area",className:B("relative",e),...r,children:[c.jsx(RC,{"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}),c.jsx(qC,{}),c.jsx(GC,{})]})}function qC({className:e,orientation:t="vertical",...r}){return c.jsx(cm,{"data-slot":"scroll-area-scrollbar",orientation:t,className:B("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:c.jsx(pm,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const vm=({field:e,value:t=[],onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,formValues:d={},submissionContext:u,excludedOptionValues:l})=>{const{options:f,isLoadingOptions:p,optionsError:m}=_p({field:e,formValues:d,submissionContext:u}),g=l?.length?new Set(l.map(String)):null,h=g?f.filter(N=>!g.has(String(N.value??N.label??""))):f,y=Array.isArray(t)?t:[],w=y.map(N=>h.find(C=>String(C.value)===String(N))).filter(Boolean),v=S.useCallback(N=>{const C=y.includes(N)?y.filter(A=>A!==N):[...y,N];r(C),n?.()},[y,r,n]),x=S.useCallback(N=>{r(y.filter(C=>C!==N)),n?.()},[y,r,n]),E=e.appearance?.size||"md",P={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},k=w.length>0?`${w.length} selected`:h.length===0&&l?.length?"No available options":e.placeholder||"Select options";return c.jsxs(Et,{field:e,error:o||m||void 0,isRequired:i,className:a,children:[c.jsxs(Ol,{children:[c.jsx(Hp,{asChild:!0,children:c.jsxs(Yt,{type:"button",variant:"outline",role:"combobox","aria-expanded":void 0,"aria-haspopup":"listbox","aria-multiselectable":"true","aria-describedby":jt(e,!!o||!!m),"aria-invalid":Jt(!!o||!!m),"aria-required":i,id:ht(e),disabled:s||e.disabled||p,className:B("w-full min-w-0 justify-between font-normal",P[E],o&&"border-destructive focus-visible:ring-destructive",m&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:[c.jsx("span",{className:"truncate",children:k}),c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p&&c.jsx(Ro,{className:"h-4 w-4 animate-spin text-muted-foreground"}),c.jsx(Wo,{className:"h-4 w-4 opacity-50"})]})]})}),c.jsx(Il,{className:"w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden",align:"start",children:c.jsx(KC,{className:"h-60 overflow-hidden rounded-md",children:c.jsx("ul",{role:"listbox","aria-multiselectable":"true","aria-label":e.label||e.name||"Options",className:"p-1",children:h.length===0?c.jsx("li",{className:"px-2 py-3 text-sm text-muted-foreground text-center",children:p?"Loading options...":l?.length?"No available options":"No options available"}):h.map(N=>{const C=String(N.value||N.label),A=N.label||N.value||C,I=y.includes(C);return c.jsxs("li",{role:"option","aria-selected":I,className:"flex items-center gap-2 rounded-sm px-2 py-1.5 cursor-pointer hover:bg-accent focus:bg-accent outline-none",onClick:()=>!N.disabled&&v(C),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),N.disabled||v(C))},children:[c.jsx(Ti,{checked:I,disabled:N.disabled,onCheckedChange:()=>!N.disabled&&v(C),onClick:T=>T.stopPropagation(),"aria-hidden":!0,className:"pointer-events-none"}),c.jsx("span",{className:"flex-1 truncate text-sm",children:A})]},C)})})})})]}),w.length>0&&c.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",role:"list","aria-label":"Selected options",children:w.map(N=>{const C=String(N.value||N.label),A=N.label||N.value||C;return c.jsxs(OC,{variant:"secondary",className:"pl-2 pr-1 py-0.5 text-xs font-normal gap-1",children:[c.jsx("span",{className:"truncate max-w-[120px]",children:A}),c.jsx("button",{type:"button","aria-label":`Remove ${A}`,className:"rounded-full p-0.5 hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring",onClick:()=>x(C),tabIndex:-1,children:c.jsx(Ko,{className:"h-3 w-3"})})]},C)})})]})},wm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const d=S.useCallback(u=>{r(u===!0),n?.()},[r,n]);return c.jsxs("div",{className:B("space-y-2",a),children:[c.jsxs("div",{className:"flex items-start space-x-3",children:[c.jsx(Ti,{id:ht(e),checked:t||!1,onCheckedChange:d,disabled:s||e.disabled,"aria-describedby":jt(e,!!o),"aria-required":i,className:B(o&&"border-destructive")}),c.jsxs("div",{className:"grid gap-1.5 leading-none",children:[c.jsxs(Sn,{id:zs(e),htmlFor:ht(e),className:B("text-sm font-medium cursor-pointer",o&&"text-destructive"),children:[e.label,i&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&c.jsx("p",{id:Vo(e),className:"text-xs text-muted-foreground",children:e.description})]})]}),o&&c.jsx("p",{id:Ho(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var Mi="Switch",[YC]=vr(Mi),[XC,JC]=YC(Mi),Sm=b.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:o,defaultChecked:s,required:i,disabled:a,value:d="on",onCheckedChange:u,form:l,...f}=e,[p,m]=b.useState(null),g=Ze(t,x=>m(x)),h=b.useRef(!1),y=p?l||!!p.closest("form"):!0,[w,v]=Zr({prop:o,defaultProp:s??!1,onChange:u,caller:Mi});return c.jsxs(XC,{scope:r,checked:w,disabled:a,children:[c.jsx(Be.button,{type:"button",role:"switch","aria-checked":w,"aria-required":i,"data-state":Em(w),"data-disabled":a?"":void 0,disabled:a,value:d,...f,ref:g,onClick:Me(e.onClick,x=>{v(E=>!E),y&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})}),y&&c.jsx(Cm,{control:p,bubbles:!h.current,name:n,value:d,checked:w,required:i,disabled:a,form:l,style:{transform:"translateX(-100%)"}})]})});Sm.displayName=Mi;var xm="SwitchThumb",Am=b.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,o=JC(xm,r);return c.jsx(Be.span,{"data-state":Em(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:t})});Am.displayName=xm;var QC="SwitchBubbleInput",Cm=b.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Ze(i,s),d=Qo(r),u=Jo(t);return b.useEffect(()=>{const l=i.current;if(!l)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&m){const g=new Event("click",{bubbles:n});m.call(l,r),l.dispatchEvent(g)}},[d,r,n]),c.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}})});Cm.displayName=QC;function Em(e){return e?"checked":"unchecked"}var ZC=Sm,eE=Am;function Nm({className:e,...t}){return c.jsx(ZC,{"data-slot":"switch",className:B("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:c.jsx(eE,{"data-slot":"switch-thumb",className:B("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 tE=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const d=e.properties;let u=null;if(e.metadata)try{u=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata}catch{}const l=u?.onValue??d?.onValue??"On",f=u?.offValue??d?.offValue??"Off",p=u?.onText??d?.onText??l,m=u?.offText??d?.offText??f,g=S.useMemo(()=>{const y=t??e.defaultValue??f;return String(y)===String(l)},[t,e.defaultValue,f,l]),h=S.useCallback(y=>{r(y?l:f),n?.()},[r,n,l,f]);return c.jsxs("div",{className:B("space-y-2",a),children:[c.jsxs("div",{className:"space-y-2",children:[e.label&&c.jsxs(Sn,{id:zs(e),htmlFor:ht(e),className:B("text-sm font-medium block",o&&"text-destructive"),children:[e.label,i&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&c.jsx("p",{id:Vo(e),className:"text-xs text-muted-foreground",children:e.description}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Nm,{id:ht(e),checked:g,onCheckedChange:h,disabled:s||e.disabled,"aria-describedby":jt(e,!!o),"aria-required":i,className:B(o&&"opacity-50")}),c.jsx("span",{className:"text-sm text-foreground font-medium",children:g?p:m})]})]}),o&&c.jsx("p",{id:Ho(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var Vl="rovingFocusGroup.onEntryFocus",rE={bubbles:!1,cancelable:!0},as="RovingFocusGroup",[Hl,_m,nE]=Ba(as),[oE,Li]=vr(as,[nE]),[sE,iE]=oE(as),km=b.forwardRef((e,t)=>c.jsx(Hl.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Hl.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(aE,{...e,ref:t})})}));km.displayName=as;var aE=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:l=!1,...f}=e,p=b.useRef(null),m=Ze(t,p),g=ro(s),[h,y]=Zr({prop:i,defaultProp:a??null,onChange:d,caller:as}),[w,v]=b.useState(!1),x=ar(u),E=_m(r),P=b.useRef(!1),[k,N]=b.useState(0);return b.useEffect(()=>{const C=p.current;if(C)return C.addEventListener(Vl,x),()=>C.removeEventListener(Vl,x)},[x]),c.jsx(sE,{scope:r,orientation:n,dir:g,loop:o,currentTabStopId:h,onItemFocus:b.useCallback(C=>y(C),[y]),onItemShiftTab:b.useCallback(()=>v(!0),[]),onFocusableItemAdd:b.useCallback(()=>N(C=>C+1),[]),onFocusableItemRemove:b.useCallback(()=>N(C=>C-1),[]),children:c.jsx(Be.div,{tabIndex:w||k===0?-1:0,"data-orientation":n,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:Me(e.onMouseDown,()=>{P.current=!0}),onFocus:Me(e.onFocus,C=>{const A=!P.current;if(C.target===C.currentTarget&&A&&!w){const I=new CustomEvent(Vl,rE);if(C.currentTarget.dispatchEvent(I),!I.defaultPrevented){const T=E().filter(M=>M.focusable),W=T.find(M=>M.active),X=T.find(M=>M.id===h),j=[W,X,...T].filter(Boolean).map(M=>M.ref.current);Pm(j,l)}}P.current=!1}),onBlur:Me(e.onBlur,()=>v(!1))})})}),Tm="RovingFocusGroupItem",Fm=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:s,children:i,...a}=e,d=on(),u=s||d,l=iE(Tm,r),f=l.currentTabStopId===u,p=_m(r),{onFocusableItemAdd:m,onFocusableItemRemove:g,currentTabStopId:h}=l;return b.useEffect(()=>{if(n)return m(),()=>g()},[n,m,g]),c.jsx(Hl.ItemSlot,{scope:r,id:u,focusable:n,active:o,children:c.jsx(Be.span,{tabIndex:f?0:-1,"data-orientation":l.orientation,...a,ref:t,onMouseDown:Me(e.onMouseDown,y=>{n?l.onItemFocus(u):y.preventDefault()}),onFocus:Me(e.onFocus,()=>l.onItemFocus(u)),onKeyDown:Me(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){l.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const w=dE(y,l.orientation,l.dir);if(w!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let x=p().filter(E=>E.focusable).map(E=>E.ref.current);if(w==="last")x.reverse();else if(w==="prev"||w==="next"){w==="prev"&&x.reverse();const E=x.indexOf(y.currentTarget);x=l.loop?uE(x,E+1):x.slice(E+1)}setTimeout(()=>Pm(x))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:h!=null}):i})})});Fm.displayName=Tm;var lE={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cE(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function dE(e,t,r){const n=cE(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return lE[n]}function Pm(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function uE(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Om=km,Im=Fm,Wl="Radio",[fE,Mm]=vr(Wl),[pE,mE]=fE(Wl),Lm=b.forwardRef((e,t)=>{const{__scopeRadio:r,name:n,checked:o=!1,required:s,disabled:i,value:a="on",onCheck:d,form:u,...l}=e,[f,p]=b.useState(null),m=Ze(t,y=>p(y)),g=b.useRef(!1),h=f?u||!!f.closest("form"):!0;return c.jsxs(pE,{scope:r,checked:o,disabled:i,children:[c.jsx(Be.button,{type:"button",role:"radio","aria-checked":o,"data-state":jm(o),"data-disabled":i?"":void 0,disabled:i,value:a,...l,ref:m,onClick:Me(e.onClick,y=>{o||d?.(),h&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})}),h&&c.jsx($m,{control:f,bubbles:!g.current,name:n,value:a,checked:o,required:s,disabled:i,form:u,style:{transform:"translateX(-100%)"}})]})});Lm.displayName=Wl;var Dm="RadioIndicator",Bm=b.forwardRef((e,t)=>{const{__scopeRadio:r,forceMount:n,...o}=e,s=mE(Dm,r);return c.jsx(xr,{present:n||s.checked,children:c.jsx(Be.span,{"data-state":jm(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});Bm.displayName=Dm;var hE="RadioBubbleInput",$m=b.forwardRef(({__scopeRadio:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Ze(i,s),d=Qo(r),u=Jo(t);return b.useEffect(()=>{const l=i.current;if(!l)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&m){const g=new Event("click",{bubbles:n});m.call(l,r),l.dispatchEvent(g)}},[d,r,n]),c.jsx(Be.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}})});$m.displayName=hE;function jm(e){return e?"checked":"unchecked"}var gE=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Di="RadioGroup",[yE]=vr(Di,[Li,Mm]),zm=Li(),Um=Mm(),[bE,vE]=yE(Di),Vm=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,name:n,defaultValue:o,value:s,required:i=!1,disabled:a=!1,orientation:d,dir:u,loop:l=!0,onValueChange:f,...p}=e,m=zm(r),g=ro(u),[h,y]=Zr({prop:s,defaultProp:o??null,onChange:f,caller:Di});return c.jsx(bE,{scope:r,name:n,required:i,disabled:a,value:h,onValueChange:y,children:c.jsx(Om,{asChild:!0,...m,orientation:d,dir:g,loop:l,children:c.jsx(Be.div,{role:"radiogroup","aria-required":i,"aria-orientation":d,"data-disabled":a?"":void 0,dir:g,...p,ref:t})})})});Vm.displayName=Di;var Hm="RadioGroupItem",Wm=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,disabled:n,...o}=e,s=vE(Hm,r),i=s.disabled||n,a=zm(r),d=Um(r),u=b.useRef(null),l=Ze(t,u),f=s.value===o.value,p=b.useRef(!1);return b.useEffect(()=>{const m=h=>{gE.includes(h.key)&&(p.current=!0)},g=()=>p.current=!1;return document.addEventListener("keydown",m),document.addEventListener("keyup",g),()=>{document.removeEventListener("keydown",m),document.removeEventListener("keyup",g)}},[]),c.jsx(Im,{asChild:!0,...a,focusable:!i,active:f,children:c.jsx(Lm,{disabled:i,required:s.required,checked:f,...d,...o,name:s.name,ref:l,onCheck:()=>s.onValueChange(o.value),onKeyDown:Me(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:Me(o.onFocus,()=>{p.current&&u.current?.click()})})})});Wm.displayName=Hm;var wE="RadioGroupIndicator",Rm=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,...n}=e,o=Um(r);return c.jsx(Bm,{...o,...n,ref:t})});Rm.displayName=wE;var SE=Vm,xE=Wm,AE=Rm;function CE({className:e,...t}){return c.jsx(SE,{"data-slot":"radio-group",className:B("grid gap-3",e),...t})}function EE({className:e,...t}){return c.jsx(xE,{"data-slot":"radio-group-item",className:B("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:c.jsx(AE,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:c.jsx(eu,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const Gm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,excludedOptionValues:d})=>{const u=e.properties,l=Array.isArray(u?.options)&&u.options.length>0?u.options:Array.isArray(e.options)?e.options:[],f=d?.length?new Set(d.map(String)):null,p=f?l.filter(g=>!f.has(String(g.value??g.label??""))):l,m=S.useCallback(g=>{r(g),n?.()},[r,n]);return c.jsx(Et,{field:e,error:o,isRequired:i,className:a,children:c.jsx(CE,{value:t||"",onValueChange:m,disabled:s||e.disabled||p.length===0,className:"flex flex-col space-y-2","aria-required":i,children:p.length===0?c.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"No available options"}):p.map(g=>c.jsxs("div",{className:"flex items-center space-x-3",children:[c.jsx(EE,{id:`${ht(e)}-${g.value}`,value:g.value,disabled:g.disabled,className:B(o&&"border-destructive")}),c.jsxs(Sn,{htmlFor:`${ht(e)}-${g.value}`,className:B("text-sm font-normal cursor-pointer",g.disabled&&"text-muted-foreground cursor-not-allowed"),children:[g.label,g.description&&c.jsx("span",{className:"block text-xs text-muted-foreground",children:g.description})]})]},g.value))})})},Km=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=S.useCallback(E=>{r(E.target.value)},[r]),f=E=>{if(E)return E==="today"?new Date().toISOString().split("T")[0]:E},p=f(u?.minDate),m=f(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",w={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},v=e.appearance?.labelPlacement||"top",x=!e.appearance?.hideLabel&&e.label;return c.jsxs("div",{className:B("space-y-2 w-fit",v==="left"&&"flex items-start gap-4",d),children:[x&&c.jsxs(Sn,{id:zs(e),htmlFor:ht(e),className:B("text-sm font-medium",v==="left"&&"w-32 pt-2 text-right",o&&"text-destructive"),children:[e.label,a&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),c.jsxs("div",{className:"w-fit",children:[c.jsxs("div",{className:"relative w-fit max-w-full",children:[c.jsx(Ev,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),c.jsx(wn,{id:ht(e),type:h,value:t||"",onChange:l,onBlur:n,disabled:s||e.disabled,readOnly:i||e.readOnly,min:p,max:m,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(w[y],"pl-10 w-fit",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]}),e.description&&!o&&c.jsx("p",{id:Vo(e),className:"mt-1.5 text-xs text-muted-foreground",children:e.description}),o&&c.jsx("p",{id:Ho(e),className:"mt-1.5 text-xs text-destructive",role:"alert",children:o})]})]})};function yo(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 Rl(e,t){return e===1&&t===1}const qm=/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?|$)/i;function Gl(e){return e.type.startsWith("image/")?!0:qm.test(e.name)}function Bi(e){try{const t=e.split("?")[0];return qm.test(t)}catch{return!1}}function Kl({items:e,maxFiles:t,disabled:r,objectUrls:n,failedUrlKeys:o,onImageUrlError:s,onRemove:i,onOpenUrl:a,resolveOpenUrl:d,addSlot:u,className:l}){const f=S.useCallback(p=>{try{return p.split("?")[0].split("/").filter(Boolean).pop()||p}catch{return p}},[]);return c.jsxs("div",{"data-file-like-strip":!0,"data-remove-in-dropzone":!0,className:B("relative w-full h-full flex items-center gap-1 min-h-0 overflow-x-auto",l),children:[e.map((p,m)=>{const g=p instanceof File,h=!g&&p&&"url"in p?p:null,y=h?.url??"",w=`${m}-${y}`,v=h&&o.has(y),x=g?n[m]??null:h&&Bi(y)&&!v?y:null,E=g&&Gl(p)&&!!x||!!h&&Bi(y)&&!v&&!!x,P=g?p.name:h?h.name??f(y):"",k=d?.(m,p),N=h&&y||k||"",C=!!a&&!!N;return c.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:[E&&x?c.jsx("img",{src:x,alt:"",className:"absolute inset-0 h-full w-full object-cover",onError:()=>{h&&s(y)}}):c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-muted/40",children:c.jsx(ru,{className:"h-7 w-7 text-muted-foreground","aria-hidden":!0})}),c.jsxs("div",{className:"absolute top-0.5 right-0.5 z-10 flex items-center gap-0.5",children:[C&&c.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),a(N)},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:c.jsx(tu,{className:"h-3 w-3","aria-hidden":!0})}),c.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),i(m)},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:c.jsx(Ko,{className:"h-3 w-3","aria-hidden":!0})})]}),!E&&P&&c.jsx("span",{className:"sr-only",children:P})]},w+(g?p.name+p.size:""))}),u]})}function ql(e){const[t,r]=S.useState([]);return S.useEffect(()=>{const n=e.map(o=>o instanceof File&&Gl(o)?URL.createObjectURL(o):null);return r(n),()=>{n.forEach(o=>{o&&URL.revokeObjectURL(o)})}},[e]),t}function Yl({item:e,objectUrl:t,failedUrlKeys:r,onImageUrlError:n,onRemove:o,onOpenUrl:s,openTarget:i,disabled:a}){const d=S.useCallback(v=>{try{return v.split("?")[0].split("/").filter(Boolean).pop()||v}catch{return v}},[]),u=e instanceof File,l=!u&&e&&"url"in e?e:null,f=l?.url??"",p=l&&r.has(f),m=u?t:l&&Bi(f)&&!p?f:null,g=u&&Gl(e)&&!!m||!!l&&Bi(f)&&!p&&!!m,h=u?e.name:l?l.name??d(f):"",y=(i?.trim()||f||"").trim(),w=!!s&&!!y;return c.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:[g&&m?c.jsx("img",{src:m,alt:"",className:"absolute inset-0 h-full w-full rounded object-cover",onError:()=>{l&&n(f)}}):c.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded bg-muted/40",children:c.jsx(ru,{className:"h-8 w-8 text-muted-foreground","aria-hidden":!0})}),c.jsxs("div",{className:"absolute top-1 right-1 z-10 flex items-center gap-1",children:[w&&y&&c.jsx("button",{type:"button",onClick:v=>{v.preventDefault(),v.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:c.jsx(tu,{className:"h-3.5 w-3.5","aria-hidden":!0})}),c.jsx("button",{type:"button",onClick:v=>{v.preventDefault(),v.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:c.jsx(Ko,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),!g&&h&&c.jsx("p",{className:"sr-only",children:h})]})}const NE=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,buttonResponses:d})=>{const{gridStretch:u}=zo(),l=u&&Is(e),f=e.properties,p=S.useRef(null),[m,g]=S.useState(!1),[h,y]=S.useState(),[w,v]=S.useState(()=>new Set),[x,E]=S.useState(0),P=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,k=Ms(e),N=S.useMemo(()=>Ls(t),[t]),[C,A]=S.useState(null);S.useEffect(()=>{A(null)},[t,x]);const I=C??N,T=ql(I),W=e.validation?.find(Se=>Se.type==="fileSize"),X=e.validation?.find(Se=>Se.type==="fileType"),O=W?.value?W.value:f?.maxSize??P?.maxSize??10*1024*1024,j=X?.value?X.value:f?.accept??P?.accept??[],M=Array.isArray(j)?j.join(","):"",D=()=>{I.length>=k||p.current?.click()},L=S.useCallback(Se=>{if(W){const xe=Yr(Se,W);if(xe!==!0)return typeof xe=="string"?xe:"File size exceeds the maximum allowed size"}else if(Se.size>O)return`File size must be less than ${yo(O)}`;if(X){const xe=Yr(Se,X);if(xe!==!0)return typeof xe=="string"?xe:"File type is not allowed"}return null},[W,X,O]),U=S.useCallback(Se=>{const xe=ka(Se,k);r(xe),n?.()},[r,n,k]),$=S.useCallback(Se=>{y(void 0);const xe=Array.from(Se),ae=[...I];let ve=null;for(const Ye of xe){if(ae.length>=k)break;const ct=L(Ye);if(ct){ve||(ve=ct);continue}ae.push(Ye)}if(ve&&ae.length===I.length){y(ve);return}ve&&y(ve),A(ae),U(ae)},[I,k,L,U]),ie=S.useCallback(Se=>{const xe=Se.target.files;xe&&xe.length>0&&$(xe),p.current&&(p.current.value="")},[$]),V=S.useCallback(Se=>{if(s)return;const xe=I.filter((ae,ve)=>ve!==Se);E(ae=>ae+1),A(xe),U(xe)},[s,I,U]),K=Se=>{Se.preventDefault(),g(!0)},J=()=>{g(!1)},ce=Se=>{Se.preventDefault(),g(!1),Se.dataTransfer.files?.length&&$(Se.dataTransfer.files)},ne=o||h,G=[];(W||O)&&G.push(`Max size: ${yo(O)}`),X&&j.length>0&&G.push(`Allowed types: ${j.join(", ")}`),k>1&&G.push(`Up to ${k} files`);const ee=e.appearance?.hideLabel??!1,Pe=S.useMemo(()=>{if(!d)return null;const Se=Object.values(d);for(let xe=Se.length-1;xe>=0;xe-=1){const ae=Se[xe],ve=typeof ae?.status=="string"?ae.status.toLowerCase():null;if(ve&&ve!=="success")continue;const Ye=ae?.code;if(typeof Ye=="number"&&(Ye<200||Ye>=300))continue;const ct=ae?.data,Ge=ct?.file_url||ct?.fileUrl||ae?.file_url||ae?.fileUrl;if(typeof Ge=="string"&&Ge.trim())return Ge}return null},[d]),oe=S.useCallback(Se=>{window.open(Se,"_blank","noopener,noreferrer")},[]),re=S.useCallback(Se=>{v(xe=>new Set(xe).add(Se))},[]),be=I.length===0,de=I.length<k,ot=Rl(k,I.length);return c.jsx(Et,{field:e,error:ne,isRequired:i,className:B(a,"!space-y-0"),hideLabel:ee,children:c.jsx("div",{className:B("min-h-[70px] min-w-0 w-full flex flex-col",l?"flex-1 h-full":"h-[70px]"),children:c.jsxs("div",{onClick:Se=>{Se.target.closest("[data-remove-in-dropzone]")||Se.target.closest("[data-no-open-picker]")||D()},onDragOver:K,onDragLeave:J,onDrop:ce,className:B("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",m&&"border-primary bg-primary/10",ne&&"border-destructive",s&&"opacity-50 cursor-not-allowed",!de&&I.length>0&&"cursor-default"),children:[c.jsx("input",{ref:p,id:ht(e),type:"file",accept:M,multiple:k>1,onChange:ie,disabled:s||e.disabled||!de,className:"hidden","aria-describedby":jt(e,!!ne),"aria-invalid":Jt(!!ne),"aria-required":i}),be?c.jsxs(c.Fragment,{children:[c.jsx(Hs,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),c.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:"Drag & drop or click"}),G.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:G.join(" • ")})]}):ot?c.jsx(Yl,{item:I[0],objectUrl:T[0]??null,failedUrlKeys:w,onImageUrlError:re,onRemove:()=>V(0),onOpenUrl:oe,openTarget:I[0]instanceof File?Pe:void 0,disabled:s||e.disabled}):c.jsx(Kl,{items:I,maxFiles:k,disabled:s,objectUrls:T,failedUrlKeys:w,onImageUrlError:re,onRemove:V,resolveOpenUrl:(Se,xe)=>xe instanceof File&&I.length===1&&Pe?.trim()?Pe.trim():null,onOpenUrl:Se=>{Se?.trim()&&oe(Se.trim())},addSlot:de?c.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:Se=>{Se.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:[c.jsx(Hs,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})]})})})};function _E(e){const t=kE(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(FE);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function kE(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=OE(o),a=PE(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(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 TE=Symbol("radix.slottable");function FE(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===TE}function PE(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 d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function OE(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 $i="Dialog",[Ym]=vr($i),[IE,Rr]=Ym($i),Xm=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=b.useRef(null),d=b.useRef(null),[u,l]=Zr({prop:n,defaultProp:o??!1,onChange:s,caller:$i});return c.jsx(IE,{scope:t,triggerRef:a,contentRef:d,contentId:on(),titleId:on(),descriptionId:on(),open:u,onOpenChange:l,onOpenToggle:b.useCallback(()=>l(f=>!f),[l]),modal:i,children:r})};Xm.displayName=$i;var Jm="DialogTrigger",ME=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(Jm,r),s=Ze(t,o.triggerRef);return c.jsx(Be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ql(o.open),...n,ref:s,onClick:Me(e.onClick,o.onOpenToggle)})});ME.displayName=Jm;var Xl="DialogPortal",[LE,Qm]=Ym(Xl,{forceMount:void 0}),Zm=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,s=Rr(Xl,t);return c.jsx(LE,{scope:t,forceMount:r,children:b.Children.map(n,i=>c.jsx(xr,{present:r||s.open,children:c.jsx(ni,{asChild:!0,container:o,children:i})}))})};Zm.displayName=Xl;var ji="DialogOverlay",eh=b.forwardRef((e,t)=>{const r=Qm(ji,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Rr(ji,e.__scopeDialog);return s.modal?c.jsx(xr,{present:n||s.open,children:c.jsx(BE,{...o,ref:t})}):null});eh.displayName=ji;var DE=_E("DialogOverlay.RemoveScroll"),BE=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(ji,r);return c.jsx(ui,{as:DE,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Be.div,{"data-state":Ql(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),Gn="DialogContent",th=b.forwardRef((e,t)=>{const r=Qm(Gn,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Rr(Gn,e.__scopeDialog);return c.jsx(xr,{present:n||s.open,children:s.modal?c.jsx($E,{...o,ref:t}):c.jsx(jE,{...o,ref:t})})});th.displayName=Gn;var $E=b.forwardRef((e,t)=>{const r=Rr(Gn,e.__scopeDialog),n=b.useRef(null),o=Ze(t,r.contentRef,n);return b.useEffect(()=>{const s=n.current;if(s)return sl(s)},[]),c.jsx(rh,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Me(e.onCloseAutoFocus,s=>{s.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Me(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:Me(e.onFocusOutside,s=>s.preventDefault())})}),jE=b.forwardRef((e,t)=>{const r=Rr(Gn,e.__scopeDialog),n=b.useRef(!1),o=b.useRef(!1);return c.jsx(rh,{...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()}})}),rh=b.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Rr(Gn,r),d=b.useRef(null),u=Ze(t,d);return za(),c.jsxs(c.Fragment,{children:[c.jsx(Rs,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Ws,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ql(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(UE,{titleId:a.titleId}),c.jsx(HE,{contentRef:d,descriptionId:a.descriptionId})]})]})}),Jl="DialogTitle",nh=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(Jl,r);return c.jsx(Be.h2,{id:o.titleId,...n,ref:t})});nh.displayName=Jl;var oh="DialogDescription",zE=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(oh,r);return c.jsx(Be.p,{id:o.descriptionId,...n,ref:t})});zE.displayName=oh;var sh="DialogClose",ih=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(sh,r);return c.jsx(Be.button,{type:"button",...n,ref:t,onClick:Me(e.onClick,()=>o.onOpenChange(!1))})});ih.displayName=sh;function Ql(e){return e?"open":"closed"}var ah="DialogTitleWarning",[oO,lh]=Ov(ah,{contentName:Gn,titleName:Jl,docsSlug:"dialog"}),UE=({titleId:e})=>{const t=lh(ah),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
46
|
+
`+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Hn(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&Ei.assertOptions(n,{silentJSONParsing:Or.transitional(Or.boolean),forcedJSONParsing:Or.transitional(Or.boolean),clarifyTimeoutError:Or.transitional(Or.boolean),legacyInterceptorReqResOrdering:Or.transitional(Or.boolean)},!1),o!=null&&(R.isFunction(o)?r.paramsSerializer={serialize:o}:Ei.assertOptions(o,{encode:Or.function,serialize:Or.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Ei.assertOptions(r,{baseUrl:Or.spelling("baseURL"),withXsrfToken:Or.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&R.merge(s.common,s[r.method]);s&&R.forEach(["delete","get","head","post","put","patch","common"],g=>{delete s[g]}),r.headers=mr.concat(i,s);const a=[];let d=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(r)===!1)return;d=d&&h.synchronous;const y=r.transitional||xl;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 l,f=0,p;if(!d){const g=[wp.bind(this),void 0];for(g.unshift(...a),g.push(...u),p=g.length,l=Promise.resolve(r);f<p;)l=l.then(g[f++],g[f++]);return l}p=a.length;let m=r;for(;f<p;){const g=a[f++],h=a[f++];try{m=g(m)}catch(y){h.call(this,y);break}}try{l=wp.call(this,m)}catch(g){return Promise.reject(g)}for(f=0,p=u.length;f<p;)l=l.then(u[f++],u[f++]);return l}getUri(t){t=Hn(this.defaults,t);const r=cp(t.baseURL,t.url,t.allowAbsoluteUrls);return tp(r,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){Wn.prototype[t]=function(r,n){return this.request(Hn(n||{},{method:t,url:r,data:(n||{}).data}))}}),R.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,a){return this.request(Hn(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Wn.prototype[t]=r(),Wn.prototype[t+"Form"]=r(!0)});let FA=class Fy{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 ss(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 Fy(function(o){t=o}),cancel:t}}};function PA(e){return function(r){return e.apply(null,r)}}function OA(e){return R.isObject(e)&&e.isAxiosError===!0}const Tl={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(Tl).forEach(([e,t])=>{Tl[t]=e});function Ap(e){const t=new Wn(e),r=Uf(Wn.prototype.request,t);return R.extend(r,Wn.prototype,t,{allOwnKeys:!0}),R.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return Ap(Hn(e,o))},r}const _t=Ap(ns);_t.Axios=Wn,_t.CanceledError=ss,_t.CancelToken=FA,_t.isCancel=sp,_t.VERSION=Sp,_t.toFormData=wi,_t.AxiosError=qe,_t.Cancel=_t.CanceledError,_t.all=function(t){return Promise.all(t)},_t.spread=PA,_t.isAxiosError=OA,_t.mergeConfig=Hn,_t.AxiosHeaders=mr,_t.formToJSON=e=>np(R.isHTMLForm(e)?new FormData(e):e),_t.getAdapter=vp.getAdapter,_t.HttpStatusCode=Tl,_t.default=_t;const{Axios:GP,AxiosError:IA,CanceledError:KP,isCancel:qP,CancelToken:YP,VERSION:XP,all:JP,Cancel:QP,isAxiosError:ZP,spread:eO,toFormData:tO,AxiosHeaders:rO,HttpStatusCode:nO,formToJSON:oO,getAdapter:sO,mergeConfig:iO}=_t;function or(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 MA(e){const t={array:[],pathPrefixToStrip:""};function r(a,d){if(a===null||typeof a!="object")return null;if(Array.isArray(a)&&a.length>0)return{array:a,fullPath:d};const u=Object.keys(a);for(const l of u){const f=a[l],p=d?`${d}.${l}`:l;if(Array.isArray(f)&&f.length>0)return{array:f,fullPath:p};if(f!==null&&typeof f=="object"){const m=r(f,p);if(m)return m}}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 LA(e){return e.length>=4&&Array.isArray(e[3])&&e[3].length===0}function DA(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(".")?or(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(".")?or(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 Fl(e,t,r){if(!e)return[];if(Array.isArray(e)){if(e.length===0)return[];if(LA(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=>DA(o,t,r))}if(typeof e=="object"){const{array:n,pathPrefixToStrip:o}=MA(e);if(Array.isArray(n)&&n.length>0){const s=d=>!d||!d.trim()||!o?d:d.startsWith(o)?d.substring(o.length).replace(/^\.+/,"")||void 0:d,i=s(t),a=s(r);return Fl(n,i,a)}}return[]}function BA(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 $A(e){return Array.isArray(e)&&e.length>=4&&Array.isArray(e[3])&&e[3].length>0&&Array.isArray(e[3][0])}function jA(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 Cp(e){const{response:t,sourceUrl:r,rowsIndex:n,rowsPath:o,columns:s,columnsQueryParam:i="sf",columnsQueryParamSeparator:a=","}=e;let d;if(o&&o.trim()?d=or(t,o):typeof n=="number"?d=t?.[n]:d=t,!Array.isArray(d)||d.length===0)return[];const u=d.filter(p=>Array.isArray(p));if(u.length===0)return Array.isArray(d[0])?[]:null;if(!Array.isArray(u[0]))return null;const l=jA(r,i,a),f=l.length>0?l:Array.isArray(s)&&s.length>0?s:[];return u.map(p=>{const m={};return(f.length>0?f:Array.from({length:p.length},(h,y)=>`col${y}`)).forEach((h,y)=>{m[h]=p[y]}),m})}function zA(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(f=>f!=null&&typeof f=="object"&&!Array.isArray(f));if(i.length===0)return[];const a=Array.isArray(n)?n.filter(Boolean):[],d=o??" - ",u=f=>{if(r){const p=r.includes(".")?or(f,r):f?.[r];if(p!=null&&String(p).trim()!=="")return String(p)}return String(f?.label??f?.name??f?.title??f?.text??f?.username??f?.email??f?.value??f?.id??f)},l=(f,p)=>{if(s){const m=s.includes(".")?or(f,s):f?.[s];if(m!=null)return String(m)}return String(f?.value??f?.id??f?.key??f?.email??f?.username??f?.label??f?.name??p??f)};return i.map(f=>{let p="";a.length>0&&(p=a.map(h=>or(f,h)).filter(h=>h!=null&&String(h).trim()!=="").map(h=>String(h)).join(d)),p||(p=u(f));const m=l(f,p);return{label:typeof p=="string"?p:String(p??""),value:typeof m=="string"?m:String(m??""),disabled:!!f?.disabled}})}let Ep=null;function UA(e){Ep=e}function Np(){return(Ep?.()??"").replace(/\/+$/,"")}function cn(e){const t=typeof e=="string"?e.trim():"";if(!t||/^https?:\/\//i.test(t))return t;const r=Np();return r?t.startsWith("/")?`${r}${t}`:`${r}/${t}`:t}function _p({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,valueSource:n.valueSource,optionsSource:n.optionsSource}:null,s=e.apidata||null,i=o||s,[a,d]=S.useState([]),[u,l]=S.useState([]),[f,p]=S.useState([]),[m,g]=S.useState(!1),[h,y]=S.useState(null),w=!!(i?.apiEndpoint&&(i?.valueSource==="api"||i?.optionsSource==="api"||n?.valueSource==="api"||n?.optionsSource==="api")),v=e.options||n?.options||[],x=S.useMemo(()=>BA(Array.isArray(v)?v:[]),[v]),E=S.useMemo(()=>{const I=i?.apiEndpoint||n?.apiEndpoint||"",T=i?.apiQueryParams||n?.apiQueryParams;return $s(I,T)},[i?.apiEndpoint,n?.apiEndpoint,i?.apiQueryParams,n?.apiQueryParams]),P=S.useMemo(()=>{const I=new Set;for(const W of n?.dependentFields??[])typeof W=="string"&&W.trim()&&I.add(W.trim());const T=i?.apiClientFilter?.matchField?.trim()||n?.apiClientFilter?.matchField?.trim();return T&&I.add(T),[...I]},[n?.dependentFields,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField]),_=S.useMemo(()=>{const I=new Set([...E,...P]);if(I.size===0)return null;const T={};return I.forEach(W=>{T[W]=t[W]}),JSON.stringify(T)},[E,P,t]),N=S.useMemo(()=>JSON.stringify(r||{}),[r]),C=S.useMemo(()=>{const I=new Set;e.name?.trim()&&I.add(e.name.trim());const T=e.key;return typeof T=="string"&&T.trim()&&I.add(T.trim()),[...I]},[e.name,e.key]);return S.useEffect(()=>{const I=i?.apiEndpoint;if(!w||!I){d([]);return}let T=!1;return(async()=>{a.length===0&&g(!0),y(null);try{const O=i?.apiMethod||n?.apiMethod||"GET",j=i?.apiRealtime||n?.apiRealtime,M=i?.apiQueryParams||n?.apiQueryParams||{},D=zd({apiEndpoint:I,apiMethod:O,apiQueryParams:M,formValues:t,submissionContext:r,apiRealtime:j,additionalRequiredFieldNames:P,excludeFormFieldNames:C});if(D.blocked){T||(d([]),g(!1));return}const L={"Content-Type":"application/json"},U=i?.apiKey||n?.apiKey;U&&(L["X-CSCAPI-KEY"]=U);const $={method:O.toLowerCase(),url:cn(D.url),headers:L};D.postBodyBase!=null&&($.data=D.postBodyBase);const ie=await _t($),V=i?.apiLabelField||n?.apiLabelField,K=i?.apiValueField||n?.apiValueField,J=ie.data;let ce=[];Array.isArray(J)?ce=J:J?.data&&(Array.isArray(J.data)?ce=J.data:J.data?.data&&Array.isArray(J.data.data)?ce=J.data.data:J.data.districts?ce=J.data.districts:J.data.states?ce=J.data.states:J.data.cities&&(ce=J.data.cities)),p(ce);const ne=Fl(ie.data,V,K);l(ne);const G=i?.apiClientFilter||n?.apiClientFilter;let ee=ne;if(G?.filterField&&G?.matchField){const Pe=t[G.matchField];Pe!=null?ee=ne.filter(oe=>{const re=ce.find(de=>String(or(de,K||"code"))===String(oe.value));if(!re)return!1;const be=or(re,G.filterField);return String(be)===String(Pe)}):ee=[]}T||d(ee)}catch(O){if(T)return;let j="Failed to load options";if(O.response){const M=O.response.data;O.response.status===404?j="API endpoint not found.":O.response.status===401?j="Authentication failed.":typeof M=="string"?j=M:M&&typeof M=="object"&&(j=M.error||M.message||M.detail||j)}else O.message&&(j=String(O.message));y(j),a.length===0&&d([])}finally{T||g(!1)}})(),()=>{T=!0}},[w,i?.apiEndpoint,i?.apiMethod,n?.apiEndpoint,n?.apiMethod,_,P,C,N]),S.useEffect(()=>{const I=i?.apiClientFilter||n?.apiClientFilter;if(!w||!I||f.length===0)return;const T=t[I.matchField],W=i?.apiValueField||n?.apiValueField;if(T==null){d([]);return}const X=u.filter(O=>{const j=f.find(D=>String(or(D,W||"code"))===String(O.value));if(!j)return!1;const M=or(j,I.filterField);return String(M)===String(T)});d(X)},[w,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField,i?.apiClientFilter?.filterField,n?.apiClientFilter?.filterField,i?.apiValueField,n?.apiValueField,t[i?.apiClientFilter?.matchField||n?.apiClientFilter?.matchField||""],u,f]),{options:w?a:x,isLoadingOptions:m,optionsError:h}}const kp=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,formValues:d={},submissionContext:u,excludedOptionValues:l,isPrepopulateTarget:f=!1})=>{const p=e.properties,m=p?.apiEndpoint?{apiEndpoint:p.apiEndpoint,valueSource:p.valueSource,optionsSource:p.optionsSource}:null,g=e.apidata||null,h=m||g,y=!!(h?.apiEndpoint&&(h?.valueSource==="api"||h?.optionsSource==="api"||p?.valueSource==="api"||p?.optionsSource==="api")),{options:w,isLoadingOptions:v,optionsError:x}=_p({field:e,formValues:d,submissionContext:u}),E=l?.length?new Set(l.map(String)):null,P=E?w.filter($=>!E.has(String($.value??$.label??""))):w,_="__clear__",N=t!=null&&String(t).trim()!=="",C=N?P.some($=>String($.value??$.label??"")===String(t)):!1,A=S.useMemo(()=>{if(!N||C)return P;const $=String(t);return[{label:$,value:$},...P]},[P,N,C,t]),I=N?String(t):void 0,T=`${ht(e)}-${I??"empty"}`,W=S.useCallback($=>{r($===_?"":$),n?.()},[r,n]),X=e.appearance?.size||"md",O={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},j=e.placeholder||"Select an option",M=p?.apiClientFilter?.matchField?.trim()||h?.apiClientFilter?.matchField?.trim(),D=y&&M&&(d[M]===void 0||d[M]===null||d[M]===""),L=v?"Loading options...":D?`Select ${M} first`:l?.length?"No available options":y?"No options available from API":"No options available";return y&&f&&v?c.jsx(Et,{field:e,error:o||x||void 0,isRequired:i,className:a,children:c.jsxs("div",{role:"status","aria-label":"Loading options",className:B("flex items-center justify-center gap-2 w-full min-w-0 rounded-md border border-input bg-muted/50 text-muted-foreground",O[X],e.appearance?.className),children:[c.jsx(Ro,{className:"h-4 w-4 animate-spin shrink-0"}),c.jsx("span",{className:"truncate",children:"Loading..."})]})}):c.jsx(Et,{field:e,error:o||x||void 0,isRequired:i,className:a,children:c.jsxs(t0,{value:I,onValueChange:W,disabled:s||e.disabled||v&&P.length===0,children:[c.jsx(n0,{id:ht(e),"aria-describedby":jt(e,!!o||!!x),"aria-invalid":Jt(!!o||!!x),"aria-required":i,className:B("w-full min-w-0",O[X],o&&"border-destructive focus-visible:ring-destructive",x&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:c.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[v&&c.jsx(Ro,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"}),P.length===0&&l?.length&&!N?c.jsx("span",{className:"text-muted-foreground truncate",children:"No available options"}):N?c.jsx(r0,{placeholder:j}):c.jsx("span",{className:"text-muted-foreground truncate",children:j})]})}),c.jsx(o0,{children:A.length===0?c.jsx(gl,{value:"__no_options__",disabled:!0,children:L}):c.jsxs(c.Fragment,{children:[N?c.jsx(gl,{value:_,children:j}):null,A.map(($,ie)=>{const V=String($.value??$.label??ie);if(V===_)return null;const K=$.label||$.value||String($);return c.jsx(gl,{value:V,disabled:$.disabled||!1,children:K},V)})]})})]},T)})},Tp=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Fp=Jc,Pp=(e,t)=>r=>{var n;if(t?.variants==null)return Fp(e,r?.class,r?.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(u=>{const l=r?.[u],f=s?.[u];if(l===null)return null;const p=Tp(l)||Tp(f);return o[u][p]}),a=r&&Object.entries(r).reduce((u,l)=>{let[f,p]=l;return p===void 0||(u[f]=p),u},{}),d=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,l)=>{let{class:f,className:p,...m}=l;return Object.entries(m).every(g=>{let[h,y]=g;return Array.isArray(y)?y.includes({...s,...a}[h]):{...s,...a}[h]===y})?[...u,f,p]:u},[]);return Fp(e,i,d,r?.class,r?.className)},VA=Pp("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 Yt({className:e,variant:t,size:r,asChild:n=!1,...o}){const s=n?qd:"button";return c.jsx(s,{"data-slot":"button",className:B(VA({variant:t,size:r,className:e})),...o})}function HA(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var xr=e=>{const{present:t,children:r}=e,n=WA(t),o=typeof r=="function"?r({present:n.isPresent}):b.Children.only(r),s=Ze(n.ref,RA(o));return typeof r=="function"||n.isPresent?b.cloneElement(o,{ref:s}):null};xr.displayName="Presence";function WA(e){const[t,r]=b.useState(),n=b.useRef(null),o=b.useRef(e),s=b.useRef("none"),i=e?"mounted":"unmounted",[a,d]=HA(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const u=Ni(n.current);s.current=a==="mounted"?u:"none"},[a]),Qt(()=>{const u=n.current,l=o.current;if(l!==e){const p=s.current,m=Ni(u);e?d("MOUNT"):m==="none"||u?.display==="none"?d("UNMOUNT"):d(l&&p!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),Qt(()=>{if(t){let u;const l=t.ownerDocument.defaultView??window,f=m=>{const h=Ni(n.current).includes(CSS.escape(m.animationName));if(m.target===t&&h&&(d("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=m=>{m.target===t&&(s.current=Ni(n.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{l.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:b.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function Ni(e){return e?.animationName||"none"}function RA(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 GA(e){const t=KA(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(YA);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function KA(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=JA(o),a=XA(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(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 qA=Symbol("radix.slottable");function YA(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qA}function XA(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 d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function JA(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 _i="Popover",[Op]=vr(_i,[ri]),is=ri(),[QA,kn]=Op(_i),Ip=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=is(t),d=b.useRef(null),[u,l]=b.useState(!1),[f,p]=Zr({prop:n,defaultProp:o??!1,onChange:s,caller:_i});return c.jsx(Ju,{...a,children:c.jsx(QA,{scope:t,contentId:on(),triggerRef:d,open:f,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(m=>!m),[p]),hasCustomAnchor:u,onCustomAnchorAdd:b.useCallback(()=>l(!0),[]),onCustomAnchorRemove:b.useCallback(()=>l(!1),[]),modal:i,children:r})})};Ip.displayName=_i;var Mp="PopoverAnchor",Lp=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=kn(Mp,r),s=is(r),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return b.useEffect(()=>(i(),()=>a()),[i,a]),c.jsx(nl,{...s,...n,ref:t})});Lp.displayName=Mp;var Dp="PopoverTrigger",Bp=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=kn(Dp,r),s=is(r),i=Ze(t,o.triggerRef),a=c.jsx(Be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Vp(o.open),...n,ref:i,onClick:Me(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:c.jsx(nl,{asChild:!0,...s,children:a})});Bp.displayName=Dp;var Pl="PopoverPortal",[ZA,eC]=Op(Pl,{forceMount:void 0}),$p=e=>{const{__scopePopover:t,forceMount:r,children:n,container:o}=e,s=kn(Pl,t);return c.jsx(ZA,{scope:t,forceMount:r,children:c.jsx(xr,{present:r||s.open,children:c.jsx(ni,{asChild:!0,container:o,children:n})})})};$p.displayName=Pl;var ho="PopoverContent",jp=b.forwardRef((e,t)=>{const r=eC(ho,e.__scopePopover),{forceMount:n=r.forceMount,...o}=e,s=kn(ho,e.__scopePopover);return c.jsx(xr,{present:n||s.open,children:s.modal?c.jsx(rC,{...o,ref:t}):c.jsx(nC,{...o,ref:t})})});jp.displayName=ho;var tC=GA("PopoverContent.RemoveScroll"),rC=b.forwardRef((e,t)=>{const r=kn(ho,e.__scopePopover),n=b.useRef(null),o=Ze(t,n),s=b.useRef(!1);return b.useEffect(()=>{const i=n.current;if(i)return sl(i)},[]),c.jsx(ui,{as:tC,allowPinchZoom:!0,children:c.jsx(zp,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Me(e.onCloseAutoFocus,i=>{i.preventDefault(),s.current||r.triggerRef.current?.focus()}),onPointerDownOutside:Me(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,d=a.button===0&&a.ctrlKey===!0,u=a.button===2||d;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Me(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),nC=b.forwardRef((e,t)=>{const r=kn(ho,e.__scopePopover),n=b.useRef(!1),o=b.useRef(!1);return c.jsx(zp,{...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()}})}),zp=b.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:l,...f}=e,p=kn(ho,r),m=is(r);return za(),c.jsx(Rs,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Ws,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:l,onEscapeKeyDown:a,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:c.jsx(Qu,{"data-state":Vp(p.open),role:"dialog",id:p.contentId,...m,...f,ref:t,style:{...f.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)"}})})})}),Up="PopoverClose",oC=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=kn(Up,r);return c.jsx(Be.button,{type:"button",...n,ref:t,onClick:Me(e.onClick,()=>o.onOpenChange(!1))})});oC.displayName=Up;var sC="PopoverArrow",iC=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=is(r);return c.jsx(Zu,{...o,...n,ref:t})});iC.displayName=sC;function Vp(e){return e?"open":"closed"}var aC=Ip,lC=Lp,cC=Bp,dC=$p,uC=jp;function Ol({...e}){return c.jsx(aC,{"data-slot":"popover",...e})}function Hp({...e}){return c.jsx(cC,{"data-slot":"popover-trigger",...e})}function Il({className:e,align:t="center",sideOffset:r=4,...n}){return c.jsx(dC,{children:c.jsx(uC,{"data-slot":"popover-content",align:t,sideOffset:r,className:B("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 fC({...e}){return c.jsx(lC,{"data-slot":"popover-anchor",...e})}const Wp={};function Tn(){const e=Wp?.VITE_CLIENT_ID?.trim()||Wp?.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 pC(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 mC(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 Rn=Pd(e=>({viewerContext:void 0,authHeaders:void 0,_setViewerContext:t=>e({viewerContext:pC(t)?t:void 0}),_setAuthHeaders:t=>e({authHeaders:mC(t)}),_reset:()=>e({viewerContext:void 0,authHeaders:void 0})}));function hC(e){Rn.getState()._setViewerContext(e)}function gC(e){Rn.getState()._setAuthHeaders(e)}function yC(){Rn.getState()._reset()}function bC(){return Rn.getState().viewerContext}function Ml(){return Rn.getState().authHeaders}const Rp={};let Gp=null;function vC(e){Gp=e}function wC(){return(Rp?.VITE_API_BASE_URL?.trim()||Rp?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const dn=_t.create({baseURL:wC()});dn.interceptors.request.use(e=>{const t=Tn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=Gp?.();if((!r||Object.keys(r).length===0)&&(r=Ml()),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});function Kp(e){return JSON.stringify(e).slice(1,-1)}function qp(e){const t=e.asyncSearchValueObjectKeys;return Array.isArray(t)?t.map(r=>typeof r=="string"?r.trim():"").filter(Boolean):[]}function SC(e){return e.asyncSearchValueMode==="object"&&qp(e).length>0}function xC(e,t){const r={};for(const n of t){const o=n.trim();if(!o)continue;const s=or(e,o);s==null||typeof s=="object"?r[o]="":r[o]=String(s)}return r}function AC(e,t){const r=t.mode??"debounce",n=Math.max(0,t.intervalMs??300),[o,s]=S.useState(()=>r==="throttle"?e:""),i=S.useRef(0),a=S.useRef(void 0);return S.useEffect(()=>{if(e===""){a.current&&clearTimeout(a.current),s("");return}if(r==="debounce"){const l=setTimeout(()=>s(e),n);return()=>clearTimeout(l)}const d=Date.now(),u=d-i.current;return u>=n?(i.current=d,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 Ll(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 Dl(e,t){return e==null||e===""?!0:t&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length===0:!1}function CC(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 EC(e){if(_t.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 NC(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 Yp(e,t){return typeof t=="number"&&t>0?e.slice(0,t):e}function Bl(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.label=="string"&&t.value!==null&&t.value!==void 0}const Xp=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d,formValues:u={},submissionContext:l})=>{const f=e.properties||{},p=SC(f),m=f.apiEndpoint?.trim()||"",g=f.apiRealtime===!0,h=(f.apiMethod||"GET").toUpperCase()==="POST"?"POST":"GET",y=f.searchInBody===!0,w=h==="POST"||h==="GET"&&y,v=f.searchStrategy??f.searchSchedule??"debounce",x=f.searchIntervalMs??f.intervalMs??300,E=f.minQueryLength??0,P=f.maxResults,_=f.searchQueryParam||"q",N=f.clearable!==!1,C=u,[A,I]=S.useState(()=>Dl(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t)),[T,W]=S.useState(!1),[X,O]=S.useState([]),[j,M]=S.useState([]),[D,L]=S.useState([]),[U,$]=S.useState(!1),[ie,V]=S.useState(null),[K,J]=S.useState(-1),ce=S.useRef(Ll(t,p)),ne=S.useRef(Dl(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t??"")),G=S.useRef(void 0),ee=S.useRef(0),Pe=S.useRef(null),oe=AC(A,{mode:v,intervalMs:x}),re=S.useMemo(()=>X.filter(Bl),[X]);S.useEffect(()=>{if(re.length===0){K!==-1&&J(-1);return}(K<0||K>=re.length)&&J(0)},[K,re.length]);const be=S.useMemo(()=>{const te=$s(m,f.apiQueryParams),pe=new Set(te);for(const We of f.dependentFields||[])We&&pe.add(We);return pe},[m,f.apiQueryParams,f.dependentFields]),de=S.useMemo(()=>{if(be.size===0)return null;const te={};return be.forEach(pe=>{te[pe]=C[pe]}),JSON.stringify(te)},[be,C]),ot=S.useMemo(()=>JSON.stringify(u),[u]),Se=S.useMemo(()=>JSON.stringify(l||{}),[l]);S.useEffect(()=>{const te=Ll(t,p);if(te===ce.current)return;if(ce.current=te,Dl(t,p)){ne.current="",I(""),O([]),M([]),L([]),V(null),W(!1);return}const pe=f.initialDisplayLabel||(!p&&typeof t=="string"?t:"");ne.current=pe,I(pe)},[t,f.initialDisplayLabel,p]),S.useEffect(()=>{if(!m){O([]),M([]),L([]),$(!1);return}if(i||s||e.disabled){O([]),M([]),L([]),$(!1);return}const te=oe;if(te.length<E){O([]),M([]),L([]),$(!1),V(null);return}const pe=zd({apiEndpoint:m,apiMethod:h,apiQueryParams:f.apiQueryParams,formValues:C,submissionContext:l,apiRealtime:g,additionalRequiredFieldNames:f.dependentFields});if(pe.blocked){O([]),M([]),L([]),$(!1),V(null);return}Pe.current?.abort();const We=new AbortController;Pe.current=We;const Pt=++ee.current;return(async()=>{$(!0),V(null);const Te=cn(pe.url),Xe={};w&&(Xe["Content-Type"]="application/json"),f.apiKey&&(Xe["X-CSCAPI-KEY"]=f.apiKey);try{let Ue;if(!w)Ue=(await dn.get(Te,{params:{[_]:te},signal:We.signal,headers:Object.keys(Xe).length?Xe:void 0})).data;else{let It={};pe.postBodyBase&&Object.keys(pe.postBodyBase).length>0?It={...pe.postBodyBase}:g&&Object.keys(C).length>0&&(It={...C});let Er=It;if(f.searchBodyTemplate?.trim()){let sr=f.searchBodyTemplate.replace(/\{\{query\}\}/g,()=>Kp(te)).replace(/\{query\}/g,()=>Kp(te));sr=Wb(sr,C,l,g);const fn=JSON.parse(sr);Er={...It,...fn}}else Er={...It,[_]:te};Ue=(await dn.post(Te,Er,{signal:We.signal,headers:Object.keys(Xe).length?Xe:void 0})).data}if(Pt!==ee.current)return;const ft=f.apiResultsFormat,St=f.apiResultsConfig,xt=ft==="clinicaltables_v3",ze=$A(Ue),pt=xt||ft===void 0&&ze,At=ft==="tuple_array";let Ut=null;pt?Ut=Cp({response:Ue,sourceUrl:Te,rowsIndex:St?.rowsIndex??3,rowsPath:St?.rowsPath,columns:St?.columns,columnsQueryParam:St?.columnsQueryParam??"sf",columnsQueryParamSeparator:St?.columnsQueryParamSeparator??","}):At&&(Ut=Cp({response:Ue,sourceUrl:Te,rowsIndex:St?.rowsIndex,rowsPath:St?.rowsPath,columns:St?.columns,columnsQueryParam:St?.columnsQueryParam,columnsQueryParamSeparator:St?.columnsQueryParamSeparator}));const ur=NC(Ue),Ar=Ut!==null,Vt=Ut&&Array.isArray(Ut)?Ut:Array.isArray(ur)&&ur.every(It=>It&&typeof It=="object"&&!Array.isArray(It))?ur:null;L(Vt??ur);const Po=Array.isArray(f.apiLabelFields)&&f.apiLabelFields.length>0,Xn=Vt&&(Ar||Po)?zA({rows:Vt,apiLabelField:f.apiLabelField,apiLabelFields:f.apiLabelFields,apiLabelSeparator:f.apiLabelSeparator,apiValueField:f.apiValueField}):Fl(Ue,f.apiLabelField,f.apiValueField);M(Xn);const Ct=f.apiClientFilter;let Cr=Xn;if(Ct?.filterField&&Ct?.matchField){const It=C[Ct.matchField];if(It!=null){const Er=f.apiValueField;Cr=Xn.filter(er=>{const fn=(Vt??ur).find(kt=>String(or(kt,Er||"code"))===String(er.value));if(!fn)return!1;const yr=or(fn,Ct.filterField);return String(yr)===String(It)})}else Cr=[]}const Jn=Yp(Cr,P).filter(Bl);O(Jn),J(Jn.length>0?0:-1)}catch(Ue){if(_t.isCancel(Ue)||Ue?.code==="ERR_CANCELED"||Pt!==ee.current)return;O([]),M([]),L([]),V(EC(Ue)),J(-1)}finally{Pt===ee.current&&$(!1)}})(),()=>{We.abort()}},[oe,m,h,y,w,_,E,P,f.apiKey,f.searchBodyTemplate,f.apiLabelField,f.apiLabelFields,f.apiLabelSeparator,f.apiValueField,f.apiQueryParams,f.apiClientFilter,f.apiResultsFormat,f.apiResultsConfig,f.dependentFields,g,C,l,i,s,e.disabled,de,ot,Se]),S.useEffect(()=>{const te=f.apiClientFilter;if(!te||D.length===0||j.length===0)return;const pe=C[te.matchField],We=f.apiValueField;if(pe==null){O([]);return}const Pt=j.filter(Te=>{const Xe=D.find(ft=>String(or(ft,We||"code"))===String(Te.value));if(!Xe)return!1;const Ue=or(Xe,te.filterField);return String(Ue)===String(pe)}),je=Yp(Pt,P).filter(Bl);O(je),J(je.length>0?0:-1)},[f.apiClientFilter,f.apiValueField,C,P,j,D]);const xe=s||e.disabled,ae=i||e.readOnly,ve=S.useCallback(te=>{const pe=te.target.value;ae||xe||(ce.current&&ne.current&&pe!==ne.current&&(ce.current="",ne.current="",r(p?null:"")),I(pe),W(!0),J(-1))},[xe,ae,p,r]),Ye=S.useCallback(te=>{const pe=typeof te?.label=="string"?te.label:String(te?.value??""),We=f.apiValueField||"code";if(p){const Pt=qp(f),je=D.find(Te=>String(or(Te,We))===String(te.value));if(je&&typeof je=="object"&&!Array.isArray(je)&&Pt.length>0){const Te=xC(je,Pt);ce.current=Ll(Te,!0),ne.current=pe,r(Te),I(pe)}else ce.current=`S:${String(te.value)}`,ne.current=pe,r(String(te.value)),I(pe)}else ce.current=`S:${String(te.value)}`,ne.current=pe,r(String(te.value)),I(pe);G.current&&clearTimeout(G.current),W(!1),J(-1),n?.()},[p,n,r,f,D]),ct=S.useCallback(te=>{te.preventDefault(),te.stopPropagation(),!(xe||ae)&&(ce.current="",ne.current="",r(p?null:""),I(""),O([]),M([]),L([]),V(null),W(!1),n?.())},[xe,ae,p,r,n]),Ge=S.useMemo(()=>T&&!ae&&(U||!!ie||re.length>0||oe.length>=E&&!U),[T,ae,U,ie,re.length,oe,E]),Kt=S.useCallback(te=>{if(!(ae||xe))if(te.key==="ArrowDown")te.preventDefault(),W(!0),J(pe=>re.length===0?-1:(pe+1)%re.length);else if(te.key==="ArrowUp")te.preventDefault(),W(!0),J(pe=>re.length===0?-1:pe<=0?re.length-1:pe-1);else if(te.key==="Enter"){const pe=K>=0?re[K]:void 0;Ge&&pe&&!pe.disabled&&(te.preventDefault(),Ye(pe))}else te.key==="Escape"&&W(!1)},[xe,ae,K,Ge,re,Ye]),Je=e.appearance?.size||"md",q={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},$e=ht(e),gt=jt(e,!!(o||ie)),Oe=oe.length>=E&&!U&&!ie&&re.length===0;return c.jsx(Et,{field:e,error:o||ie||void 0,isRequired:a,className:d,children:c.jsxs(Ol,{open:Ge,onOpenChange:te=>{te||W(!1)},children:[c.jsx(fC,{asChild:!0,children:c.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[c.jsx(wn,{id:$e,role:"combobox","aria-expanded":Ge,"aria-autocomplete":"list","aria-controls":Ge?`${$e}-listbox`:void 0,"aria-activedescendant":K>=0?`${$e}-opt-${K}`:void 0,value:A,onChange:ve,onKeyDown:Kt,onFocus:()=>{G.current&&clearTimeout(G.current),!ae&&!xe&&W(!0)},onBlur:()=>{G.current=setTimeout(()=>{W(!1),n?.()},150)},placeholder:e.placeholder||"Search…",disabled:xe,readOnly:ae,"aria-describedby":gt,"aria-invalid":Jt(!!(o||ie)),"aria-required":a,className:B("pr-20",q[Je],(o||ie)&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),c.jsxs("div",{className:"pointer-events-none absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[U&&c.jsx(Ro,{className:"pointer-events-none h-4 w-4 animate-spin text-muted-foreground"}),N&&CC(t,A,p)&&!xe&&!ae&&c.jsx(Yt,{type:"button",variant:"ghost",size:"icon",className:"pointer-events-auto h-8 w-8 shrink-0",onMouseDown:te=>te.preventDefault(),onClick:ct,"aria-label":"Clear",children:c.jsx(Ko,{className:"h-4 w-4"})})]})]})}),c.jsx(Il,{className:"p-0 w-[var(--radix-popover-trigger-width)] min-w-[12rem] overflow-hidden",align:"start",onOpenAutoFocus:te=>te.preventDefault(),onCloseAutoFocus:te=>te.preventDefault(),children:c.jsx("div",{id:`${$e}-listbox`,role:"listbox",children:ie?c.jsx("div",{className:"px-3 py-2 text-sm text-destructive",children:ie}):U?c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground",children:[c.jsx(Ro,{className:"h-4 w-4 animate-spin shrink-0"}),"Loading…"]}):Oe?c.jsx("ul",{className:"py-1","aria-label":"Search results",children:c.jsx("li",{role:"option","aria-disabled":!0,className:"cursor-default select-none px-3 py-2 text-sm text-muted-foreground",onMouseDown:te=>te.preventDefault(),children:"No results found"})}):c.jsx("ul",{className:"max-h-60 overflow-y-auto overscroll-contain py-1","aria-label":"Search results",children:re.map((te,pe)=>c.jsx("li",{id:`${$e}-opt-${pe}`,role:"option","aria-selected":K===pe,className:B(te.disabled?"cursor-not-allowed opacity-60":"cursor-pointer","px-3 py-2 text-sm",K===pe&&"bg-accent text-accent-foreground"),onMouseEnter:()=>J(pe),onMouseDown:We=>We.preventDefault(),onClick:()=>{te.disabled||Ye(te)},children:te.label},`${te.value}-${pe}`))})})})]})})};var ki="Checkbox",[_C]=vr(ki),[kC,$l]=_C(ki);function TC(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:o,disabled:s,form:i,name:a,onCheckedChange:d,required:u,value:l="on",internal_do_not_use_render:f}=e,[p,m]=Zr({prop:r,defaultProp:o??!1,onChange:d,caller:ki}),[g,h]=b.useState(null),[y,w]=b.useState(null),v=b.useRef(!1),x=g?!!i||!!g.closest("form"):!0,E={checked:p,disabled:s,setChecked:m,control:g,setControl:h,name:a,form:i,value:l,hasConsumerStoppedPropagationRef:v,required:u,defaultChecked:Fn(o)?!1:o,isFormControl:x,bubbleInput:y,setBubbleInput:w};return c.jsx(kC,{scope:t,...E,children:FC(f)?f(E):n})}var Jp="CheckboxTrigger",Qp=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},o)=>{const{control:s,value:i,disabled:a,checked:d,required:u,setControl:l,setChecked:f,hasConsumerStoppedPropagationRef:p,isFormControl:m,bubbleInput:g}=$l(Jp,e),h=Ze(o,l),y=b.useRef(d);return b.useEffect(()=>{const w=s?.form;if(w){const v=()=>f(y.current);return w.addEventListener("reset",v),()=>w.removeEventListener("reset",v)}},[s,f]),c.jsx(Be.button,{type:"button",role:"checkbox","aria-checked":Fn(d)?"mixed":d,"aria-required":u,"data-state":om(d),"data-disabled":a?"":void 0,disabled:a,value:i,...n,ref:h,onKeyDown:Me(t,w=>{w.key==="Enter"&&w.preventDefault()}),onClick:Me(r,w=>{f(v=>Fn(v)?!0:!v),g&&m&&(p.current=w.isPropagationStopped(),p.current||w.stopPropagation())})})});Qp.displayName=Jp;var Zp=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:o,defaultChecked:s,required:i,disabled:a,value:d,onCheckedChange:u,form:l,...f}=e;return c.jsx(TC,{__scopeCheckbox:r,checked:o,defaultChecked:s,disabled:a,required:i,onCheckedChange:u,name:n,form:l,value:d,internal_do_not_use_render:({isFormControl:p})=>c.jsxs(c.Fragment,{children:[c.jsx(Qp,{...f,ref:t,__scopeCheckbox:r}),p&&c.jsx(nm,{__scopeCheckbox:r})]})})});Zp.displayName=ki;var em="CheckboxIndicator",tm=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...o}=e,s=$l(em,r);return c.jsx(xr,{present:n||Fn(s.checked)||s.checked===!0,children:c.jsx(Be.span,{"data-state":om(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});tm.displayName=em;var rm="CheckboxBubbleInput",nm=b.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:o,checked:s,defaultChecked:i,required:a,disabled:d,name:u,value:l,form:f,bubbleInput:p,setBubbleInput:m}=$l(rm,e),g=Ze(r,m),h=Qo(s),y=Jo(n);b.useEffect(()=>{const v=p;if(!v)return;const x=window.HTMLInputElement.prototype,P=Object.getOwnPropertyDescriptor(x,"checked").set,_=!o.current;if(h!==s&&P){const N=new Event("click",{bubbles:_});v.indeterminate=Fn(s),P.call(v,Fn(s)?!1:s),v.dispatchEvent(N)}},[p,h,s,o]);const w=b.useRef(Fn(s)?!1:s);return c.jsx(Be.input,{type:"checkbox","aria-hidden":!0,defaultChecked:i??w.current,required:a,disabled:d,name:u,value:l,form:f,...t,tabIndex:-1,ref:g,style:{...t.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});nm.displayName=rm;function FC(e){return typeof e=="function"}function Fn(e){return e==="indeterminate"}function om(e){return Fn(e)?"indeterminate":e?"checked":"unchecked"}function Ti({className:e,...t}){return c.jsx(Zp,{"data-slot":"checkbox",className:B("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:c.jsx(tm,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:c.jsx(Vs,{className:"size-3.5"})})})}const PC=Pp("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 OC({className:e,variant:t,asChild:r=!1,...n}){const o=r?qd:"span";return c.jsx(o,{"data-slot":"badge",className:B(PC({variant:t}),e),...n})}function IC(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var jl="ScrollArea",[sm]=vr(jl),[MC,Ir]=sm(jl),im=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,d]=b.useState(null),[u,l]=b.useState(null),[f,p]=b.useState(null),[m,g]=b.useState(null),[h,y]=b.useState(null),[w,v]=b.useState(0),[x,E]=b.useState(0),[P,_]=b.useState(!1),[N,C]=b.useState(!1),A=Ze(t,T=>d(T)),I=ro(o);return c.jsx(MC,{scope:r,type:n,dir:I,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:l,content:f,onContentChange:p,scrollbarX:m,onScrollbarXChange:g,scrollbarXEnabled:P,onScrollbarXEnabledChange:_,scrollbarY:h,onScrollbarYChange:y,scrollbarYEnabled:N,onScrollbarYEnabledChange:C,onCornerWidthChange:v,onCornerHeightChange:E,children:c.jsx(Be.div,{dir:I,...i,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});im.displayName=jl;var am="ScrollAreaViewport",lm=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...s}=e,i=Ir(am,r),a=b.useRef(null),d=Ze(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(Be.div,{"data-radix-scroll-area-viewport":"",...s,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});lm.displayName=am;var tn="ScrollAreaScrollbar",cm=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Ir(tn,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"?c.jsx(LC,{...n,ref:t,forceMount:r}):o.type==="scroll"?c.jsx(DC,{...n,ref:t,forceMount:r}):o.type==="auto"?c.jsx(dm,{...n,ref:t,forceMount:r}):o.type==="always"?c.jsx(zl,{...n,ref:t}):null});cm.displayName=tn;var LC=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Ir(tn,e.__scopeScrollArea),[s,i]=b.useState(!1);return b.useEffect(()=>{const a=o.scrollArea;let d=0;if(a){const u=()=>{window.clearTimeout(d),i(!0)},l=()=>{d=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",l),()=>{window.clearTimeout(d),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",l)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(xr,{present:r||s,children:c.jsx(dm,{"data-state":s?"visible":"hidden",...n,ref:t})})}),DC=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Ir(tn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Ii(()=>d("SCROLL_END"),100),[a,d]=IC("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(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,d]),b.useEffect(()=>{const u=o.viewport,l=s?"scrollLeft":"scrollTop";if(u){let f=u[l];const p=()=>{const m=u[l];f!==m&&(d("SCROLL"),i()),f=m};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,s,d,i]),c.jsx(xr,{present:r||a!=="hidden",children:c.jsx(zl,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:Me(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Me(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),dm=b.forwardRef((e,t)=>{const r=Ir(tn,e.__scopeScrollArea),{forceMount:n,...o}=e,[s,i]=b.useState(!1),a=e.orientation==="horizontal",d=Ii(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,l=r.viewport.offsetHeight<r.viewport.scrollHeight;i(a?u:l)}},10);return go(r.viewport,d),go(r.content,d),c.jsx(xr,{present:n||s,children:c.jsx(zl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),zl=b.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=Ir(tn,e.__scopeScrollArea),s=b.useRef(null),i=b.useRef(0),[a,d]=b.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=hm(a.viewport,a.content),l={...n,sizes:a,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function f(p,m){return VC(p,i.current,a,m)}return r==="horizontal"?c.jsx(BC,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,m=gm(p,a,o.dir);s.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=f(p,o.dir))}}):r==="vertical"?c.jsx($C,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,m=gm(p,a);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=f(p))}}):null}),BC=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Ir(tn,e.__scopeScrollArea),[i,a]=b.useState(),d=b.useRef(null),u=Ze(t,d,s.onScrollbarXChange);return b.useEffect(()=>{d.current&&a(getComputedStyle(d.current))},[d]),c.jsx(fm,{"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":Oi(r)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.x),onDragScroll:l=>e.onDragScroll(l.x),onWheelScroll:(l,f)=>{if(s.viewport){const p=s.viewport.scrollLeft+l.deltaX;e.onWheelScroll(p),bm(p,f)&&l.preventDefault()}},onResize:()=>{d.current&&s.viewport&&i&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Pi(i.paddingLeft),paddingEnd:Pi(i.paddingRight)}})}})}),$C=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Ir(tn,e.__scopeScrollArea),[i,a]=b.useState(),d=b.useRef(null),u=Ze(t,d,s.onScrollbarYChange);return b.useEffect(()=>{d.current&&a(getComputedStyle(d.current))},[d]),c.jsx(fm,{"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":Oi(r)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.y),onDragScroll:l=>e.onDragScroll(l.y),onWheelScroll:(l,f)=>{if(s.viewport){const p=s.viewport.scrollTop+l.deltaY;e.onWheelScroll(p),bm(p,f)&&l.preventDefault()}},onResize:()=>{d.current&&s.viewport&&i&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Pi(i.paddingTop),paddingEnd:Pi(i.paddingBottom)}})}})}),[jC,um]=sm(tn),fm=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:l,onResize:f,...p}=e,m=Ir(tn,r),[g,h]=b.useState(null),y=Ze(t,A=>h(A)),w=b.useRef(null),v=b.useRef(""),x=m.viewport,E=n.content-n.viewport,P=ar(l),_=ar(d),N=Ii(f,10);function C(A){if(w.current){const I=A.clientX-w.current.left,T=A.clientY-w.current.top;u({x:I,y:T})}}return b.useEffect(()=>{const A=I=>{const T=I.target;g?.contains(T)&&P(I,E)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[x,g,E,P]),b.useEffect(_,[n,_]),go(g,N),go(m.content,N),c.jsx(jC,{scope:r,scrollbar:g,hasThumb:o,onThumbChange:ar(s),onThumbPointerUp:ar(i),onThumbPositionChange:_,onThumbPointerDown:ar(a),children:c.jsx(Be.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:Me(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),w.current=g.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),C(A))}),onPointerMove:Me(e.onPointerMove,C),onPointerUp:Me(e.onPointerUp,A=>{const I=A.target;I.hasPointerCapture(A.pointerId)&&I.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=v.current,m.viewport&&(m.viewport.style.scrollBehavior=""),w.current=null})})})}),Fi="ScrollAreaThumb",pm=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=um(Fi,e.__scopeScrollArea);return c.jsx(xr,{present:r||o.hasThumb,children:c.jsx(zC,{ref:t,...n})})}),zC=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,s=Ir(Fi,r),i=um(Fi,r),{onThumbPositionChange:a}=i,d=Ze(t,f=>i.onThumbChange(f)),u=b.useRef(void 0),l=Ii(()=>{u.current&&(u.current(),u.current=void 0)},100);return b.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(l(),!u.current){const m=HC(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,l,a]),c.jsx(Be.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Me(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),g=f.clientX-m.left,h=f.clientY-m.top;i.onThumbPointerDown({x:g,y:h})}),onPointerUp:Me(e.onPointerUp,i.onThumbPointerUp)})});pm.displayName=Fi;var Ul="ScrollAreaCorner",mm=b.forwardRef((e,t)=>{const r=Ir(Ul,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?c.jsx(UC,{...e,ref:t}):null});mm.displayName=Ul;var UC=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=Ir(Ul,r),[s,i]=b.useState(0),[a,d]=b.useState(0),u=!!(s&&a);return go(o.scrollbarX,()=>{const l=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(l),d(l)}),go(o.scrollbarY,()=>{const l=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(l),i(l)}),u?c.jsx(Be.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 Pi(e){return e?parseInt(e,10):0}function hm(e,t){const r=e/t;return isNaN(r)?0:r}function Oi(e){const t=hm(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function VC(e,t,r,n="ltr"){const o=Oi(r),s=o/2,i=t||s,a=o-i,d=r.scrollbar.paddingStart+i,u=r.scrollbar.size-r.scrollbar.paddingEnd-a,l=r.content-r.viewport,f=n==="ltr"?[0,l]:[l*-1,0];return ym([d,u],f)(e)}function gm(e,t,r="ltr"){const n=Oi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-n,d=r==="ltr"?[0,i]:[i*-1,0],u=qo(e,d);return ym([0,i],[0,a])(u)}function ym(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 bm(e,t){return e>0&&e<t}var HC=(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 Ii(e,t){const r=ar(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 go(e,t){const r=ar(t);Qt(()=>{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 WC=im,RC=lm,GC=mm;function KC({className:e,children:t,...r}){return c.jsxs(WC,{"data-slot":"scroll-area",className:B("relative",e),...r,children:[c.jsx(RC,{"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}),c.jsx(qC,{}),c.jsx(GC,{})]})}function qC({className:e,orientation:t="vertical",...r}){return c.jsx(cm,{"data-slot":"scroll-area-scrollbar",orientation:t,className:B("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:c.jsx(pm,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const vm=({field:e,value:t=[],onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,formValues:d={},submissionContext:u,excludedOptionValues:l})=>{const{options:f,isLoadingOptions:p,optionsError:m}=_p({field:e,formValues:d,submissionContext:u}),g=l?.length?new Set(l.map(String)):null,h=g?f.filter(N=>!g.has(String(N.value??N.label??""))):f,y=Array.isArray(t)?t:[],w=y.map(N=>h.find(C=>String(C.value)===String(N))).filter(Boolean),v=S.useCallback(N=>{const C=y.includes(N)?y.filter(A=>A!==N):[...y,N];r(C),n?.()},[y,r,n]),x=S.useCallback(N=>{r(y.filter(C=>C!==N)),n?.()},[y,r,n]),E=e.appearance?.size||"md",P={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},_=w.length>0?`${w.length} selected`:h.length===0&&l?.length?"No available options":e.placeholder||"Select options";return c.jsxs(Et,{field:e,error:o||m||void 0,isRequired:i,className:a,children:[c.jsxs(Ol,{children:[c.jsx(Hp,{asChild:!0,children:c.jsxs(Yt,{type:"button",variant:"outline",role:"combobox","aria-expanded":void 0,"aria-haspopup":"listbox","aria-multiselectable":"true","aria-describedby":jt(e,!!o||!!m),"aria-invalid":Jt(!!o||!!m),"aria-required":i,id:ht(e),disabled:s||e.disabled||p,className:B("w-full min-w-0 justify-between font-normal",P[E],o&&"border-destructive focus-visible:ring-destructive",m&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:[c.jsx("span",{className:"truncate",children:_}),c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p&&c.jsx(Ro,{className:"h-4 w-4 animate-spin text-muted-foreground"}),c.jsx(Wo,{className:"h-4 w-4 opacity-50"})]})]})}),c.jsx(Il,{className:"w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden",align:"start",children:c.jsx(KC,{className:"h-60 overflow-hidden rounded-md",children:c.jsx("ul",{role:"listbox","aria-multiselectable":"true","aria-label":e.label||e.name||"Options",className:"p-1",children:h.length===0?c.jsx("li",{className:"px-2 py-3 text-sm text-muted-foreground text-center",children:p?"Loading options...":l?.length?"No available options":"No options available"}):h.map(N=>{const C=String(N.value||N.label),A=N.label||N.value||C,I=y.includes(C);return c.jsxs("li",{role:"option","aria-selected":I,className:"flex items-center gap-2 rounded-sm px-2 py-1.5 cursor-pointer hover:bg-accent focus:bg-accent outline-none",onClick:()=>!N.disabled&&v(C),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),N.disabled||v(C))},children:[c.jsx(Ti,{checked:I,disabled:N.disabled,onCheckedChange:()=>!N.disabled&&v(C),onClick:T=>T.stopPropagation(),"aria-hidden":!0,className:"pointer-events-none"}),c.jsx("span",{className:"flex-1 truncate text-sm",children:A})]},C)})})})})]}),w.length>0&&c.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",role:"list","aria-label":"Selected options",children:w.map(N=>{const C=String(N.value||N.label),A=N.label||N.value||C;return c.jsxs(OC,{variant:"secondary",className:"pl-2 pr-1 py-0.5 text-xs font-normal gap-1",children:[c.jsx("span",{className:"truncate max-w-[120px]",children:A}),c.jsx("button",{type:"button","aria-label":`Remove ${A}`,className:"rounded-full p-0.5 hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring",onClick:()=>x(C),tabIndex:-1,children:c.jsx(Ko,{className:"h-3 w-3"})})]},C)})})]})},wm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const d=S.useCallback(u=>{r(u===!0),n?.()},[r,n]);return c.jsxs("div",{className:B("space-y-2",a),children:[c.jsxs("div",{className:"flex items-start space-x-3",children:[c.jsx(Ti,{id:ht(e),checked:t||!1,onCheckedChange:d,disabled:s||e.disabled,"aria-describedby":jt(e,!!o),"aria-required":i,className:B(o&&"border-destructive")}),c.jsxs("div",{className:"grid gap-1.5 leading-none",children:[c.jsxs(Sn,{id:zs(e),htmlFor:ht(e),className:B("text-sm font-medium cursor-pointer",o&&"text-destructive"),children:[e.label,i&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&c.jsx("p",{id:Vo(e),className:"text-xs text-muted-foreground",children:e.description})]})]}),o&&c.jsx("p",{id:Ho(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var Mi="Switch",[YC]=vr(Mi),[XC,JC]=YC(Mi),Sm=b.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:o,defaultChecked:s,required:i,disabled:a,value:d="on",onCheckedChange:u,form:l,...f}=e,[p,m]=b.useState(null),g=Ze(t,x=>m(x)),h=b.useRef(!1),y=p?l||!!p.closest("form"):!0,[w,v]=Zr({prop:o,defaultProp:s??!1,onChange:u,caller:Mi});return c.jsxs(XC,{scope:r,checked:w,disabled:a,children:[c.jsx(Be.button,{type:"button",role:"switch","aria-checked":w,"aria-required":i,"data-state":Em(w),"data-disabled":a?"":void 0,disabled:a,value:d,...f,ref:g,onClick:Me(e.onClick,x=>{v(E=>!E),y&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})}),y&&c.jsx(Cm,{control:p,bubbles:!h.current,name:n,value:d,checked:w,required:i,disabled:a,form:l,style:{transform:"translateX(-100%)"}})]})});Sm.displayName=Mi;var xm="SwitchThumb",Am=b.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,o=JC(xm,r);return c.jsx(Be.span,{"data-state":Em(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:t})});Am.displayName=xm;var QC="SwitchBubbleInput",Cm=b.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Ze(i,s),d=Qo(r),u=Jo(t);return b.useEffect(()=>{const l=i.current;if(!l)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&m){const g=new Event("click",{bubbles:n});m.call(l,r),l.dispatchEvent(g)}},[d,r,n]),c.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}})});Cm.displayName=QC;function Em(e){return e?"checked":"unchecked"}var ZC=Sm,eE=Am;function Nm({className:e,...t}){return c.jsx(ZC,{"data-slot":"switch",className:B("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:c.jsx(eE,{"data-slot":"switch-thumb",className:B("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 tE=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const d=e.properties;let u=null;if(e.metadata)try{u=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata}catch{}const l=u?.onValue??d?.onValue??"On",f=u?.offValue??d?.offValue??"Off",p=u?.onText??d?.onText??l,m=u?.offText??d?.offText??f,g=S.useMemo(()=>{const y=t??e.defaultValue??f;return String(y)===String(l)},[t,e.defaultValue,f,l]),h=S.useCallback(y=>{r(y?l:f),n?.()},[r,n,l,f]);return c.jsxs("div",{className:B("space-y-2",a),children:[c.jsxs("div",{className:"space-y-2",children:[e.label&&c.jsxs(Sn,{id:zs(e),htmlFor:ht(e),className:B("text-sm font-medium block",o&&"text-destructive"),children:[e.label,i&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&c.jsx("p",{id:Vo(e),className:"text-xs text-muted-foreground",children:e.description}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Nm,{id:ht(e),checked:g,onCheckedChange:h,disabled:s||e.disabled,"aria-describedby":jt(e,!!o),"aria-required":i,className:B(o&&"opacity-50")}),c.jsx("span",{className:"text-sm text-foreground font-medium",children:g?p:m})]})]}),o&&c.jsx("p",{id:Ho(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var Vl="rovingFocusGroup.onEntryFocus",rE={bubbles:!1,cancelable:!0},as="RovingFocusGroup",[Hl,_m,nE]=Ba(as),[oE,Li]=vr(as,[nE]),[sE,iE]=oE(as),km=b.forwardRef((e,t)=>c.jsx(Hl.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Hl.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(aE,{...e,ref:t})})}));km.displayName=as;var aE=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:l=!1,...f}=e,p=b.useRef(null),m=Ze(t,p),g=ro(s),[h,y]=Zr({prop:i,defaultProp:a??null,onChange:d,caller:as}),[w,v]=b.useState(!1),x=ar(u),E=_m(r),P=b.useRef(!1),[_,N]=b.useState(0);return b.useEffect(()=>{const C=p.current;if(C)return C.addEventListener(Vl,x),()=>C.removeEventListener(Vl,x)},[x]),c.jsx(sE,{scope:r,orientation:n,dir:g,loop:o,currentTabStopId:h,onItemFocus:b.useCallback(C=>y(C),[y]),onItemShiftTab:b.useCallback(()=>v(!0),[]),onFocusableItemAdd:b.useCallback(()=>N(C=>C+1),[]),onFocusableItemRemove:b.useCallback(()=>N(C=>C-1),[]),children:c.jsx(Be.div,{tabIndex:w||_===0?-1:0,"data-orientation":n,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:Me(e.onMouseDown,()=>{P.current=!0}),onFocus:Me(e.onFocus,C=>{const A=!P.current;if(C.target===C.currentTarget&&A&&!w){const I=new CustomEvent(Vl,rE);if(C.currentTarget.dispatchEvent(I),!I.defaultPrevented){const T=E().filter(M=>M.focusable),W=T.find(M=>M.active),X=T.find(M=>M.id===h),j=[W,X,...T].filter(Boolean).map(M=>M.ref.current);Pm(j,l)}}P.current=!1}),onBlur:Me(e.onBlur,()=>v(!1))})})}),Tm="RovingFocusGroupItem",Fm=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:s,children:i,...a}=e,d=on(),u=s||d,l=iE(Tm,r),f=l.currentTabStopId===u,p=_m(r),{onFocusableItemAdd:m,onFocusableItemRemove:g,currentTabStopId:h}=l;return b.useEffect(()=>{if(n)return m(),()=>g()},[n,m,g]),c.jsx(Hl.ItemSlot,{scope:r,id:u,focusable:n,active:o,children:c.jsx(Be.span,{tabIndex:f?0:-1,"data-orientation":l.orientation,...a,ref:t,onMouseDown:Me(e.onMouseDown,y=>{n?l.onItemFocus(u):y.preventDefault()}),onFocus:Me(e.onFocus,()=>l.onItemFocus(u)),onKeyDown:Me(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){l.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const w=dE(y,l.orientation,l.dir);if(w!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let x=p().filter(E=>E.focusable).map(E=>E.ref.current);if(w==="last")x.reverse();else if(w==="prev"||w==="next"){w==="prev"&&x.reverse();const E=x.indexOf(y.currentTarget);x=l.loop?uE(x,E+1):x.slice(E+1)}setTimeout(()=>Pm(x))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:h!=null}):i})})});Fm.displayName=Tm;var lE={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cE(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function dE(e,t,r){const n=cE(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return lE[n]}function Pm(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function uE(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Om=km,Im=Fm,Wl="Radio",[fE,Mm]=vr(Wl),[pE,mE]=fE(Wl),Lm=b.forwardRef((e,t)=>{const{__scopeRadio:r,name:n,checked:o=!1,required:s,disabled:i,value:a="on",onCheck:d,form:u,...l}=e,[f,p]=b.useState(null),m=Ze(t,y=>p(y)),g=b.useRef(!1),h=f?u||!!f.closest("form"):!0;return c.jsxs(pE,{scope:r,checked:o,disabled:i,children:[c.jsx(Be.button,{type:"button",role:"radio","aria-checked":o,"data-state":jm(o),"data-disabled":i?"":void 0,disabled:i,value:a,...l,ref:m,onClick:Me(e.onClick,y=>{o||d?.(),h&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})}),h&&c.jsx($m,{control:f,bubbles:!g.current,name:n,value:a,checked:o,required:s,disabled:i,form:u,style:{transform:"translateX(-100%)"}})]})});Lm.displayName=Wl;var Dm="RadioIndicator",Bm=b.forwardRef((e,t)=>{const{__scopeRadio:r,forceMount:n,...o}=e,s=mE(Dm,r);return c.jsx(xr,{present:n||s.checked,children:c.jsx(Be.span,{"data-state":jm(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});Bm.displayName=Dm;var hE="RadioBubbleInput",$m=b.forwardRef(({__scopeRadio:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Ze(i,s),d=Qo(r),u=Jo(t);return b.useEffect(()=>{const l=i.current;if(!l)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(d!==r&&m){const g=new Event("click",{bubbles:n});m.call(l,r),l.dispatchEvent(g)}},[d,r,n]),c.jsx(Be.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}})});$m.displayName=hE;function jm(e){return e?"checked":"unchecked"}var gE=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Di="RadioGroup",[yE]=vr(Di,[Li,Mm]),zm=Li(),Um=Mm(),[bE,vE]=yE(Di),Vm=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,name:n,defaultValue:o,value:s,required:i=!1,disabled:a=!1,orientation:d,dir:u,loop:l=!0,onValueChange:f,...p}=e,m=zm(r),g=ro(u),[h,y]=Zr({prop:s,defaultProp:o??null,onChange:f,caller:Di});return c.jsx(bE,{scope:r,name:n,required:i,disabled:a,value:h,onValueChange:y,children:c.jsx(Om,{asChild:!0,...m,orientation:d,dir:g,loop:l,children:c.jsx(Be.div,{role:"radiogroup","aria-required":i,"aria-orientation":d,"data-disabled":a?"":void 0,dir:g,...p,ref:t})})})});Vm.displayName=Di;var Hm="RadioGroupItem",Wm=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,disabled:n,...o}=e,s=vE(Hm,r),i=s.disabled||n,a=zm(r),d=Um(r),u=b.useRef(null),l=Ze(t,u),f=s.value===o.value,p=b.useRef(!1);return b.useEffect(()=>{const m=h=>{gE.includes(h.key)&&(p.current=!0)},g=()=>p.current=!1;return document.addEventListener("keydown",m),document.addEventListener("keyup",g),()=>{document.removeEventListener("keydown",m),document.removeEventListener("keyup",g)}},[]),c.jsx(Im,{asChild:!0,...a,focusable:!i,active:f,children:c.jsx(Lm,{disabled:i,required:s.required,checked:f,...d,...o,name:s.name,ref:l,onCheck:()=>s.onValueChange(o.value),onKeyDown:Me(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:Me(o.onFocus,()=>{p.current&&u.current?.click()})})})});Wm.displayName=Hm;var wE="RadioGroupIndicator",Rm=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,...n}=e,o=Um(r);return c.jsx(Bm,{...o,...n,ref:t})});Rm.displayName=wE;var SE=Vm,xE=Wm,AE=Rm;function CE({className:e,...t}){return c.jsx(SE,{"data-slot":"radio-group",className:B("grid gap-3",e),...t})}function EE({className:e,...t}){return c.jsx(xE,{"data-slot":"radio-group-item",className:B("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:c.jsx(AE,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:c.jsx(eu,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const Gm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,excludedOptionValues:d})=>{const u=e.properties,l=Array.isArray(u?.options)&&u.options.length>0?u.options:Array.isArray(e.options)?e.options:[],f=d?.length?new Set(d.map(String)):null,p=f?l.filter(g=>!f.has(String(g.value??g.label??""))):l,m=S.useCallback(g=>{r(g),n?.()},[r,n]);return c.jsx(Et,{field:e,error:o,isRequired:i,className:a,children:c.jsx(CE,{value:t||"",onValueChange:m,disabled:s||e.disabled||p.length===0,className:"flex flex-col space-y-2","aria-required":i,children:p.length===0?c.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"No available options"}):p.map(g=>c.jsxs("div",{className:"flex items-center space-x-3",children:[c.jsx(EE,{id:`${ht(e)}-${g.value}`,value:g.value,disabled:g.disabled,className:B(o&&"border-destructive")}),c.jsxs(Sn,{htmlFor:`${ht(e)}-${g.value}`,className:B("text-sm font-normal cursor-pointer",g.disabled&&"text-muted-foreground cursor-not-allowed"),children:[g.label,g.description&&c.jsx("span",{className:"block text-xs text-muted-foreground",children:g.description})]})]},g.value))})})},Km=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=S.useCallback(E=>{r(E.target.value)},[r]),f=E=>{if(E)return E==="today"?new Date().toISOString().split("T")[0]:E},p=f(u?.minDate),m=f(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",w={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},v=e.appearance?.labelPlacement||"top",x=!e.appearance?.hideLabel&&e.label;return c.jsxs("div",{className:B("space-y-2 w-fit",v==="left"&&"flex items-start gap-4",d),children:[x&&c.jsxs(Sn,{id:zs(e),htmlFor:ht(e),className:B("text-sm font-medium",v==="left"&&"w-32 pt-2 text-right",o&&"text-destructive"),children:[e.label,a&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),c.jsxs("div",{className:"w-fit",children:[c.jsxs("div",{className:"relative w-fit max-w-full",children:[c.jsx(Ev,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),c.jsx(wn,{id:ht(e),type:h,value:t||"",onChange:l,onBlur:n,disabled:s||e.disabled,readOnly:i||e.readOnly,min:p,max:m,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:B(w[y],"pl-10 w-fit",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]}),e.description&&!o&&c.jsx("p",{id:Vo(e),className:"mt-1.5 text-xs text-muted-foreground",children:e.description}),o&&c.jsx("p",{id:Ho(e),className:"mt-1.5 text-xs text-destructive",role:"alert",children:o})]})]})};function yo(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 Rl(e,t){return e===1&&t===1}const qm=/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?|$)/i;function Gl(e){return e.type.startsWith("image/")?!0:qm.test(e.name)}function Bi(e){try{const t=e.split("?")[0];return qm.test(t)}catch{return!1}}function Kl({items:e,maxFiles:t,disabled:r,objectUrls:n,failedUrlKeys:o,onImageUrlError:s,onRemove:i,onOpenUrl:a,resolveOpenUrl:d,addSlot:u,className:l}){const f=S.useCallback(p=>{try{return p.split("?")[0].split("/").filter(Boolean).pop()||p}catch{return p}},[]);return c.jsxs("div",{"data-file-like-strip":!0,"data-remove-in-dropzone":!0,className:B("relative w-full h-full flex items-center gap-1 min-h-0 overflow-x-auto",l),children:[e.map((p,m)=>{const g=p instanceof File,h=!g&&p&&"url"in p?p:null,y=h?.url??"",w=`${m}-${y}`,v=h&&o.has(y),x=g?n[m]??null:h&&Bi(y)&&!v?y:null,E=g&&Gl(p)&&!!x||!!h&&Bi(y)&&!v&&!!x,P=g?p.name:h?h.name??f(y):"",_=d?.(m,p),N=h&&y||_||"",C=!!a&&!!N;return c.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:[E&&x?c.jsx("img",{src:x,alt:"",className:"absolute inset-0 h-full w-full object-cover",onError:()=>{h&&s(y)}}):c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-muted/40",children:c.jsx(ru,{className:"h-7 w-7 text-muted-foreground","aria-hidden":!0})}),c.jsxs("div",{className:"absolute top-0.5 right-0.5 z-10 flex items-center gap-0.5",children:[C&&c.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),a(N)},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:c.jsx(tu,{className:"h-3 w-3","aria-hidden":!0})}),c.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),i(m)},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:c.jsx(Ko,{className:"h-3 w-3","aria-hidden":!0})})]}),!E&&P&&c.jsx("span",{className:"sr-only",children:P})]},w+(g?p.name+p.size:""))}),u]})}function ql(e){const[t,r]=S.useState([]);return S.useEffect(()=>{const n=e.map(o=>o instanceof File&&Gl(o)?URL.createObjectURL(o):null);return r(n),()=>{n.forEach(o=>{o&&URL.revokeObjectURL(o)})}},[e]),t}function Yl({item:e,objectUrl:t,failedUrlKeys:r,onImageUrlError:n,onRemove:o,onOpenUrl:s,openTarget:i,disabled:a}){const d=S.useCallback(v=>{try{return v.split("?")[0].split("/").filter(Boolean).pop()||v}catch{return v}},[]),u=e instanceof File,l=!u&&e&&"url"in e?e:null,f=l?.url??"",p=l&&r.has(f),m=u?t:l&&Bi(f)&&!p?f:null,g=u&&Gl(e)&&!!m||!!l&&Bi(f)&&!p&&!!m,h=u?e.name:l?l.name??d(f):"",y=(i?.trim()||f||"").trim(),w=!!s&&!!y;return c.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:[g&&m?c.jsx("img",{src:m,alt:"",className:"absolute inset-0 h-full w-full rounded object-cover",onError:()=>{l&&n(f)}}):c.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded bg-muted/40",children:c.jsx(ru,{className:"h-8 w-8 text-muted-foreground","aria-hidden":!0})}),c.jsxs("div",{className:"absolute top-1 right-1 z-10 flex items-center gap-1",children:[w&&y&&c.jsx("button",{type:"button",onClick:v=>{v.preventDefault(),v.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:c.jsx(tu,{className:"h-3.5 w-3.5","aria-hidden":!0})}),c.jsx("button",{type:"button",onClick:v=>{v.preventDefault(),v.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:c.jsx(Ko,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),!g&&h&&c.jsx("p",{className:"sr-only",children:h})]})}const NE=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,buttonResponses:d})=>{const{gridStretch:u}=zo(),l=u&&Is(e),f=e.properties,p=S.useRef(null),[m,g]=S.useState(!1),[h,y]=S.useState(),[w,v]=S.useState(()=>new Set),[x,E]=S.useState(0),P=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,_=Ms(e),N=S.useMemo(()=>Ls(t),[t]),[C,A]=S.useState(null);S.useEffect(()=>{A(null)},[t,x]);const I=C??N,T=ql(I),W=e.validation?.find(Se=>Se.type==="fileSize"),X=e.validation?.find(Se=>Se.type==="fileType"),O=W?.value?W.value:f?.maxSize??P?.maxSize??10*1024*1024,j=X?.value?X.value:f?.accept??P?.accept??[],M=Array.isArray(j)?j.join(","):"",D=()=>{I.length>=_||p.current?.click()},L=S.useCallback(Se=>{if(W){const xe=Yr(Se,W);if(xe!==!0)return typeof xe=="string"?xe:"File size exceeds the maximum allowed size"}else if(Se.size>O)return`File size must be less than ${yo(O)}`;if(X){const xe=Yr(Se,X);if(xe!==!0)return typeof xe=="string"?xe:"File type is not allowed"}return null},[W,X,O]),U=S.useCallback(Se=>{const xe=ka(Se,_);r(xe),n?.()},[r,n,_]),$=S.useCallback(Se=>{y(void 0);const xe=Array.from(Se),ae=[...I];let ve=null;for(const Ye of xe){if(ae.length>=_)break;const ct=L(Ye);if(ct){ve||(ve=ct);continue}ae.push(Ye)}if(ve&&ae.length===I.length){y(ve);return}ve&&y(ve),A(ae),U(ae)},[I,_,L,U]),ie=S.useCallback(Se=>{const xe=Se.target.files;xe&&xe.length>0&&$(xe),p.current&&(p.current.value="")},[$]),V=S.useCallback(Se=>{if(s)return;const xe=I.filter((ae,ve)=>ve!==Se);E(ae=>ae+1),A(xe),U(xe)},[s,I,U]),K=Se=>{Se.preventDefault(),g(!0)},J=()=>{g(!1)},ce=Se=>{Se.preventDefault(),g(!1),Se.dataTransfer.files?.length&&$(Se.dataTransfer.files)},ne=o||h,G=[];(W||O)&&G.push(`Max size: ${yo(O)}`),X&&j.length>0&&G.push(`Allowed types: ${j.join(", ")}`),_>1&&G.push(`Up to ${_} files`);const ee=e.appearance?.hideLabel??!1,Pe=S.useMemo(()=>{if(!d)return null;const Se=Object.values(d);for(let xe=Se.length-1;xe>=0;xe-=1){const ae=Se[xe],ve=typeof ae?.status=="string"?ae.status.toLowerCase():null;if(ve&&ve!=="success")continue;const Ye=ae?.code;if(typeof Ye=="number"&&(Ye<200||Ye>=300))continue;const ct=ae?.data,Ge=ct?.file_url||ct?.fileUrl||ae?.file_url||ae?.fileUrl;if(typeof Ge=="string"&&Ge.trim())return Ge}return null},[d]),oe=S.useCallback(Se=>{window.open(Se,"_blank","noopener,noreferrer")},[]),re=S.useCallback(Se=>{v(xe=>new Set(xe).add(Se))},[]),be=I.length===0,de=I.length<_,ot=Rl(_,I.length);return c.jsx(Et,{field:e,error:ne,isRequired:i,className:B(a,"!space-y-0"),hideLabel:ee,children:c.jsx("div",{className:B("min-h-[70px] min-w-0 w-full flex flex-col",l?"flex-1 h-full":"h-[70px]"),children:c.jsxs("div",{onClick:Se=>{Se.target.closest("[data-remove-in-dropzone]")||Se.target.closest("[data-no-open-picker]")||D()},onDragOver:K,onDragLeave:J,onDrop:ce,className:B("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",m&&"border-primary bg-primary/10",ne&&"border-destructive",s&&"opacity-50 cursor-not-allowed",!de&&I.length>0&&"cursor-default"),children:[c.jsx("input",{ref:p,id:ht(e),type:"file",accept:M,multiple:_>1,onChange:ie,disabled:s||e.disabled||!de,className:"hidden","aria-describedby":jt(e,!!ne),"aria-invalid":Jt(!!ne),"aria-required":i}),be?c.jsxs(c.Fragment,{children:[c.jsx(Hs,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),c.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:"Drag & drop or click"}),G.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:G.join(" • ")})]}):ot?c.jsx(Yl,{item:I[0],objectUrl:T[0]??null,failedUrlKeys:w,onImageUrlError:re,onRemove:()=>V(0),onOpenUrl:oe,openTarget:I[0]instanceof File?Pe:void 0,disabled:s||e.disabled}):c.jsx(Kl,{items:I,maxFiles:_,disabled:s,objectUrls:T,failedUrlKeys:w,onImageUrlError:re,onRemove:V,resolveOpenUrl:(Se,xe)=>xe instanceof File&&I.length===1&&Pe?.trim()?Pe.trim():null,onOpenUrl:Se=>{Se?.trim()&&oe(Se.trim())},addSlot:de?c.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:Se=>{Se.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:[c.jsx(Hs,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})]})})})};function _E(e){const t=kE(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),d=a.find(FE);if(d){const u=d.props.children,l=a.map(f=>f===d?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return c.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return c.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function kE(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=OE(o),a=PE(s,o.props);return o.type!==b.Fragment&&(a.ref=n?Bn(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 TE=Symbol("radix.slottable");function FE(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===TE}function PE(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 d=s(...a);return o(...a),d}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function OE(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 $i="Dialog",[Ym]=vr($i),[IE,Rr]=Ym($i),Xm=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=b.useRef(null),d=b.useRef(null),[u,l]=Zr({prop:n,defaultProp:o??!1,onChange:s,caller:$i});return c.jsx(IE,{scope:t,triggerRef:a,contentRef:d,contentId:on(),titleId:on(),descriptionId:on(),open:u,onOpenChange:l,onOpenToggle:b.useCallback(()=>l(f=>!f),[l]),modal:i,children:r})};Xm.displayName=$i;var Jm="DialogTrigger",ME=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(Jm,r),s=Ze(t,o.triggerRef);return c.jsx(Be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ql(o.open),...n,ref:s,onClick:Me(e.onClick,o.onOpenToggle)})});ME.displayName=Jm;var Xl="DialogPortal",[LE,Qm]=Ym(Xl,{forceMount:void 0}),Zm=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,s=Rr(Xl,t);return c.jsx(LE,{scope:t,forceMount:r,children:b.Children.map(n,i=>c.jsx(xr,{present:r||s.open,children:c.jsx(ni,{asChild:!0,container:o,children:i})}))})};Zm.displayName=Xl;var ji="DialogOverlay",eh=b.forwardRef((e,t)=>{const r=Qm(ji,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Rr(ji,e.__scopeDialog);return s.modal?c.jsx(xr,{present:n||s.open,children:c.jsx(BE,{...o,ref:t})}):null});eh.displayName=ji;var DE=_E("DialogOverlay.RemoveScroll"),BE=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(ji,r);return c.jsx(ui,{as:DE,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Be.div,{"data-state":Ql(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),Gn="DialogContent",th=b.forwardRef((e,t)=>{const r=Qm(Gn,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Rr(Gn,e.__scopeDialog);return c.jsx(xr,{present:n||s.open,children:s.modal?c.jsx($E,{...o,ref:t}):c.jsx(jE,{...o,ref:t})})});th.displayName=Gn;var $E=b.forwardRef((e,t)=>{const r=Rr(Gn,e.__scopeDialog),n=b.useRef(null),o=Ze(t,r.contentRef,n);return b.useEffect(()=>{const s=n.current;if(s)return sl(s)},[]),c.jsx(rh,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Me(e.onCloseAutoFocus,s=>{s.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Me(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:Me(e.onFocusOutside,s=>s.preventDefault())})}),jE=b.forwardRef((e,t)=>{const r=Rr(Gn,e.__scopeDialog),n=b.useRef(!1),o=b.useRef(!1);return c.jsx(rh,{...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()}})}),rh=b.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Rr(Gn,r),d=b.useRef(null),u=Ze(t,d);return za(),c.jsxs(c.Fragment,{children:[c.jsx(Rs,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Ws,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ql(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(UE,{titleId:a.titleId}),c.jsx(HE,{contentRef:d,descriptionId:a.descriptionId})]})]})}),Jl="DialogTitle",nh=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(Jl,r);return c.jsx(Be.h2,{id:o.titleId,...n,ref:t})});nh.displayName=Jl;var oh="DialogDescription",zE=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(oh,r);return c.jsx(Be.p,{id:o.descriptionId,...n,ref:t})});zE.displayName=oh;var sh="DialogClose",ih=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Rr(sh,r);return c.jsx(Be.button,{type:"button",...n,ref:t,onClick:Me(e.onClick,()=>o.onOpenChange(!1))})});ih.displayName=sh;function Ql(e){return e?"open":"closed"}var ah="DialogTitleWarning",[aO,lh]=Ov(ah,{contentName:Gn,titleName:Jl,docsSlug:"dialog"}),UE=({titleId:e})=>{const t=lh(ah),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},VE="DialogDescriptionWarning",HE=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${lh(VE).contentName}}.`;return b.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},WE=Xm,RE=Zm,GE=eh,KE=th,qE=nh,YE=ih;function XE({...e}){return c.jsx(WE,{"data-slot":"dialog",...e})}function JE({...e}){return c.jsx(RE,{"data-slot":"dialog-portal",...e})}function QE({className:e,...t}){return c.jsx(GE,{"data-slot":"dialog-overlay",className:B("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 ZE({className:e,children:t,showCloseButton:r=!0,...n}){return c.jsxs(JE,{"data-slot":"dialog-portal",children:[c.jsx(QE,{}),c.jsxs(KE,{"data-slot":"dialog-content",className:B("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&&c.jsxs(YE,{"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:[c.jsx(Ko,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function eN({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-header",className:B("flex flex-col gap-2 text-center sm:text-left",e),...t})}function tN({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-footer",className:B("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function rN({className:e,...t}){return c.jsx(qE,{"data-slot":"dialog-title",className:B("text-lg leading-none font-semibold",e),...t})}async function nN(){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 ch(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 dh=({open:e,onOpenChange:t,onCaptured:r,validateFile:n,accept:o,disabled:s,onValidationMessage:i})=>{const a=S.useRef(null),d=S.useRef(null),u=S.useRef(null),l=S.useRef(null),[f,p]=S.useState(null),[m,g]=S.useState(!1),h=S.useCallback(()=>{a.current&&(a.current.srcObject=null)},[]),y=S.useCallback(()=>{u.current&&(u.current.getTracks().forEach(k=>k.stop()),u.current=null),h()},[h]);S.useEffect(()=>{if(!e){y(),p(null),g(!1);return}if(s)return;let k=!1;return p(null),g(!0),nN().then(N=>{if(k){N.getTracks().forEach(C=>C.stop());return}u.current=N,g(!1)}).catch(N=>{if(k)return;g(!1);const C=N instanceof Error?N.message:"Could not access camera";p(C)}),()=>{k=!0,u.current&&(u.current.getTracks().forEach(N=>N.stop()),u.current=null),h()}},[e,s,y,h]);const w=S.useCallback(k=>{a.current=k,k&&u.current&&e&&!f&&!m&&(k.srcObject=u.current,ch(k))},[e,f,m]);S.useLayoutEffect(()=>{if(!e||f||m||!u.current)return;let k=!1,N=0;const C=()=>{if(k)return;const I=a.current;!I||!u.current||(I.srcObject=u.current,ch(I))};C();const A=requestAnimationFrame(()=>{C(),N=requestAnimationFrame(C)});return()=>{k=!0,cancelAnimationFrame(A),cancelAnimationFrame(N),h()}},[e,f,m,h]);const v=S.useCallback(()=>{y(),p(null),g(!1),t(!1),l.current&&(l.current.value="")},[y,t]),x=S.useCallback(()=>{const k=a.current,N=d.current;if(!k||!N||!u.current||k.readyState<2)return;const C=k.videoWidth,A=k.videoHeight;if(C===0||A===0)return;N.width=C,N.height=A;const I=N.getContext("2d");I&&(I.drawImage(k,0,0),N.toBlob(T=>{if(!T)return;const W=new File([T],`camera-capture-${Date.now()}.jpg`,{type:"image/jpeg",lastModified:Date.now()}),X=n(W);if(X){i?.(X);return}i?.(void 0),r(W),v()},"image/jpeg",.92))},[r,n,v,i]),E=S.useCallback(k=>{const N=k.target.files?.[0];if(!N)return;const C=n(N);if(C){i?.(C);return}i?.(void 0),r(N),v(),l.current&&(l.current.value="")},[r,n,v,i]),P=typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function";return c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:l,type:"file",accept:o,capture:"user",onChange:E,className:"hidden","aria-hidden":!0}),c.jsx("canvas",{ref:d,className:"hidden","aria-hidden":!0}),c.jsx(XE,{open:e,onOpenChange:k=>{k||v()},children:c.jsxs(ZE,{className:"sm:max-w-md",showCloseButton:!0,onPointerDownOutside:k=>k.preventDefault(),children:[c.jsx(eN,{children:c.jsx(rN,{children:"Take a photo"})}),f?c.jsxs("div",{className:"space-y-3 py-2",children:[c.jsx("p",{className:"text-sm text-destructive",children:f}),P&&c.jsx("p",{className:"text-xs text-muted-foreground",children:"You can choose an image from your device instead."}),c.jsx(Yt,{type:"button",variant:"outline",className:"w-full",onClick:()=>l.current?.click(),children:"Choose from device"})]}):m?c.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Opening camera…"}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"relative rounded-lg overflow-hidden bg-black aspect-video",children:c.jsx("video",{ref:w,playsInline:!0,muted:!0,className:"w-full h-full object-cover"})}),c.jsxs(tN,{className:"gap-2 sm:gap-0",children:[c.jsx(Yt,{type:"button",variant:"outline",onClick:v,children:"Cancel"}),c.jsx(Yt,{type:"button",onClick:x,children:"Capture photo"})]})]})]})})]})},oN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const d=e.properties,[u,l]=S.useState(),[f,p]=S.useState(!1),[m,g]=S.useState(()=>new Set),[h,y]=S.useState("none"),w=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,v=e.validation?.find(K=>K.type==="fileSize"),x=e.validation?.find(K=>K.type==="fileType"),E=v?.value!=null?v.value:d?.maxSize??w?.maxSize??5*1024*1024,P=x?.value!=null?x.value:d?.accept??w?.accept??["image/*"],k=P.join(",")||"image/*",N=Ms(e),C=S.useCallback(K=>{if(v){const J=Yr(K,v);if(J!==!0)return typeof J=="string"?J:"File size exceeds the maximum allowed size"}else if(K.size>E)return`File size must be less than ${yo(E)}`;if(x){const J=Yr(K,x);if(J!==!0)return typeof J=="string"?J:"File type is not allowed"}return null},[v,x,E]),A=S.useMemo(()=>Ls(t),[t]),I=ql(A),T=S.useCallback(K=>{const J=ka(K,N);r(J),n?.()},[r,n,N]),W=S.useCallback(K=>{const J=C(K);if(J){l(J);return}l(void 0);const ce=[...A];ce.length>=N||(ce.push(K),T(ce),y("none"))},[A,N,C,T]),X=S.useCallback(K=>{const J=A.filter((ce,ne)=>ne!==K);T(J)},[A,T]),O=S.useCallback(()=>{s||A.length>=N||(l(void 0),y("camera"),p(!0))},[s,A.length,N]),j=S.useCallback(K=>{p(K),K||y("none")},[]),M=o||u,D=e.appearance?.hideLabel??!1,L=[];(v||E)&&L.push(`Max size: ${yo(E)}`),x&&P.length>0&&L.push(`Allowed: ${P.join(", ")}`),N>1&&L.push(`Up to ${N} photos`);const U=S.useCallback(K=>{window.open(K,"_blank","noopener,noreferrer")},[]),$=A.length===0,ie=A.length<N,V=Rl(N,A.length);return c.jsxs(Et,{field:e,error:M,isRequired:i,className:B(a,"!space-y-0"),hideLabel:D,children:[c.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:c.jsx("div",{role:"button",tabIndex:s||!ie?-1:0,id:ht(e),onClick:K=>{s||K.target.closest("[data-remove-in-dropzone]")||K.target.closest("[data-no-open-picker]")||A.length>=N||O()},onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),!s&&ie&&O())},className:B("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",M&&"border-destructive",s&&"opacity-50 cursor-not-allowed",f&&h==="camera"&&"opacity-70 pointer-events-none",!ie&&A.length>0&&"cursor-default"),"aria-describedby":jt(e,!!M),"aria-invalid":Jt(!!M),"aria-required":i,children:$?c.jsxs(c.Fragment,{children:[c.jsx(Us,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),c.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:f?"Opening camera…":"Click to open camera"}),L.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:L.join(" • ")})]}):V?c.jsx(Yl,{item:A[0],objectUrl:I[0]??null,failedUrlKeys:m,onImageUrlError:K=>g(J=>new Set(J).add(K)),onRemove:()=>X(0),onOpenUrl:U,disabled:s}):c.jsx(Kl,{items:A,maxFiles:N,disabled:s,objectUrls:I,failedUrlKeys:m,onImageUrlError:K=>g(J=>new Set(J).add(K)),onRemove:X,onOpenUrl:U,addSlot:ie?c.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:K=>{K.stopPropagation(),O()},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:[c.jsx(Us,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})})}),c.jsx(dh,{open:f,onOpenChange:j,onCaptured:W,validateFile:C,accept:k,disabled:s,onValidationMessage:l})]})},sN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,buttonResponses:d})=>{const u=e.properties,l=S.useRef(null),[f,p]=S.useState(),[m,g]=S.useState(!1),[h,y]=S.useState(()=>new Set),[w,v]=S.useState("none"),x=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,E=e.validation?.find(oe=>oe.type==="fileSize"),P=e.validation?.find(oe=>oe.type==="fileType"),k=E?.value?E.value:u?.maxSize??x?.maxSize??5*1024*1024,N=P?.value?P.value:u?.accept??x?.accept??["image/*"],C=Array.isArray(N)?N.join(","):"image/*",A=Ms(e),I=S.useCallback(oe=>{if(E){const re=Yr(oe,E);if(re!==!0)return typeof re=="string"?re:"File size exceeds the maximum allowed size"}else if(oe.size>k)return`File size must be less than ${yo(k)}`;if(P){const re=Yr(oe,P);if(re!==!0)return typeof re=="string"?re:"File type is not allowed"}return null},[E,P,k]),T=S.useMemo(()=>Ls(t),[t]),W=ql(T),X=S.useCallback(oe=>{const re=ka(oe,A);r(re),n?.()},[r,n,A]),O=S.useCallback(oe=>{p(void 0);const re=Array.from(oe),be=[...T];let de=null;for(const ot of re){if(be.length>=A)break;const Se=I(ot);if(Se){de||(de=Se);continue}be.push(ot)}if(de&&be.length===T.length){p(de);return}de&&p(de),X(be),v("none")},[T,A,I,X]),j=S.useCallback(oe=>{const re=oe.target.files;re&&re.length>0&&O(re),l.current&&(l.current.value="")},[O]),M=S.useCallback(oe=>{X(T.filter((re,be)=>be!==oe))},[T,X]),D=S.useCallback(()=>{s||T.length>=A||m||(p(void 0),v("file"),l.current?.click())},[s,T.length,A,m]),L=S.useCallback(()=>{s||T.length>=A||(p(void 0),v("camera"),g(!0))},[s,T.length,A]),U=S.useCallback(oe=>{const re=I(oe);if(re){p(re);return}p(void 0);const be=[...T];be.length>=A||(be.push(oe),X(be),v("none"))},[T,A,I,X]),$=S.useCallback(oe=>{g(oe),oe||v("none")},[]),ie=o||f,V=e.appearance?.hideLabel??!1,K=[];(E||k)&&K.push(`Max size: ${yo(k)}`),P&&N.length>0&&K.push(`Allowed: ${N.join(", ")}`),A>1&&K.push(`Up to ${A} photos`);const J=S.useMemo(()=>{if(!d)return null;const oe=Object.values(d);for(let re=oe.length-1;re>=0;re-=1){const be=oe[re],de=typeof be?.status=="string"?be.status.toLowerCase():null;if(de&&de!=="success")continue;const ot=be?.code;if(typeof ot=="number"&&(ot<200||ot>=300))continue;const Se=be?.data,xe=Se?.file_url||Se?.fileUrl||be?.file_url||be?.fileUrl;if(typeof xe=="string"&&xe.trim())return xe.trim()}return null},[d]),ce=S.useCallback(oe=>{window.open(oe,"_blank","noopener,noreferrer")},[]),ne=T.length===0,G=T.length<A,ee=Rl(A,T.length),Pe=G&&!m?c.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:[c.jsx("button",{type:"button",disabled:s,onClick:oe=>{oe.stopPropagation(),D()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-t","aria-label":"Upload file",title:"Upload",children:c.jsx(Hs,{className:"h-4 w-4","aria-hidden":!0})}),c.jsx("button",{type:"button",disabled:s,onClick:oe=>{oe.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:c.jsx(Us,{className:"h-4 w-4","aria-hidden":!0})})]}):void 0;return c.jsxs(Et,{field:e,error:ie,isRequired:i,className:B(a,"!space-y-0"),hideLabel:V,children:[c.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:c.jsxs("div",{className:B("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",ie&&"border-destructive",s&&"opacity-50"),children:[c.jsx("input",{ref:l,id:ht(e),type:"file",accept:C,multiple:A>1,onChange:j,disabled:s||e.disabled||m||!G,className:"hidden","aria-describedby":jt(e,!!ie),"aria-invalid":Jt(!!ie),"aria-required":i}),ne?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 w-full pointer-events-auto",children:[c.jsxs("div",{className:"flex items-center justify-center gap-3",children:[c.jsxs("button",{type:"button",disabled:s||m,onClick:D,className:B("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none"),children:[c.jsx(Hs,{className:"h-5 w-5","aria-hidden":!0}),c.jsx("span",{children:"Upload"})]}),c.jsxs("button",{type:"button",disabled:s,onClick:L,className:B("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none",m&&"opacity-70"),children:[c.jsx(Us,{className:"h-5 w-5","aria-hidden":!0}),c.jsx("span",{children:"Camera"})]})]}),K.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-2 text-center px-1",children:K.join(" • ")})]}):ee?c.jsx(Yl,{item:T[0],objectUrl:W[0]??null,failedUrlKeys:h,onImageUrlError:oe=>y(re=>new Set(re).add(oe)),onRemove:()=>M(0),onOpenUrl:ce,openTarget:T[0]instanceof File?J:void 0,disabled:s||e.disabled}):c.jsx(Kl,{items:T,maxFiles:A,disabled:s,objectUrls:W,failedUrlKeys:h,onImageUrlError:oe=>y(re=>new Set(re).add(oe)),onRemove:M,resolveOpenUrl:(oe,re)=>re instanceof File&&T.length===1&&J?J:null,onOpenUrl:oe=>{oe?.trim()&&ce(oe.trim())},addSlot:Pe})]})}),c.jsx(dh,{open:m,onOpenChange:$,onCaptured:U,validateFile:I,accept:C,disabled:s,onValidationMessage:p})]})};function ls(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 bo(n)}}catch{}if(e.response){const r=e.response;if(typeof r=="string")try{const n=JSON.parse(r);return bo(n)}catch{return r}else if(typeof r=="object")return bo(r)}return t}if(e instanceof IA)return e.response?.data?bo(e.response.data):e.message||"An unexpected error occurred";if(typeof e=="string")try{const t=JSON.parse(e);return bo(t)}catch{return e}return typeof e=="object"&&e!==null?bo(e):"An unexpected error occurred"}function bo(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"}function iN(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 aN(e,t){try{const r=iN(e);$t.toast.success(r&&r.trim()?r:t)}catch{$t.toast.success(t)}}function Zl(e,t,r){try{const n=r(e);$t.toast.error(n&&n.trim()?n:t)}catch{$t.toast.error(t)}}function lN(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 zi="This field is required";function uh(e,t){if(!t?.length)return e;const r=t.find(n=>n.name===e);return r?.label&&r.label.trim()||e}function ec(e,t){if(!e)return"Please complete the required fields.";if(Array.isArray(e)){const s=e.map(i=>{const a=i.message||zi;if(t?.length&&i.field){const d=uh(i.field,t);return a===zi?`${d} is required`:`${d}: ${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()||zi;if(t?.length){const a=uh(o,t);return i===zi?`${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)`}const cN=/^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/i;function fh(e){const t=e.trim().match(cN);return t?t[1]:e}const dN={applicantId:["id","applicant_id"],applicant_id:["id","applicantId"],id:["applicantId","applicant_id"]};function rn(e,t,r,n,o,s){let i=e;if(o&&typeof e=="string"&&(i=i.replace(/\{resp:([^}]+)\}/g,(a,d)=>{const u=d.trim().split(".");if(u.length<2)return a;const l=u[0],f=u.slice(1).join("."),p=o[l];if(p==null)return a;const m=Qe(p,f);return m==null?a:String(m)}),i.includes("{documentId}")||i.includes("%7BdocumentId%7D"))){let a;for(const d of Object.values(o)){const u=Qe(d,"data.id")??Qe(d,"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 d=t?.documentId??(t&&Qe(t,"documentId")),u=n?.documentId??(n&&Qe(n,"documentId"));d!=null&&d!==""?a=String(d):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,d)=>{const u=d.trim();if(s==null||u==="")return a;const l=Qe(s,u);return l==null?a:String(l)}),i=i.replace(/\{(?:ctx:|\@)(\w+)\}/g,(a,d)=>n&&n[d]!==void 0&&n[d]!==null?String(n[d]):a),i=i.replace(/\{(\w+)\}/g,(a,d)=>{if(a.includes("ctx:")||a.includes("@"))return a;const u=r[d];if(u!=null)return fh(String(u));let l=t[d];if(l==null||l===""){const f=Object.keys(t).find(p=>p.toLowerCase()===d.toLowerCase());f&&(l=t[f])}if((l==null||l==="")&&(l=n?.[d]),l==null||l===""){const f=dN[d];if(f)for(const p of f){const m=t[p]??n?.[p];if(m!=null&&m!==""){l=m;break}}}return l!=null&&l!==""?fh(String(l)):a}),i}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,d=i.metadata,u=typeof d=="object"&&d!==null?d:null,l=a?.submitFieldMapping??u?.submitFieldMapping;if(l&&typeof l=="object"&&Object.keys(l).length>0){const f=s.map(p=>{if(p==null||typeof p!="object")return p;const m={};for(const[g,h]of Object.entries(l))g!=null&&g!==""&&h!=null&&h!==""&&(m[g]=Qe(p,h));return m});n[o]=f;continue}}n[o]=s}return n}function Ui(e){return!!(e instanceof File||Array.isArray(e)&&e.length>0&&e[0]instanceof File)}function uN(e){return Object.values(e).some(t=>Ui(t))}function fN(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 pN(e,t,r){const n={};let o=!1;return Object.entries(e).forEach(([s,i])=>{const a=t?.[s]||s;if(Ui(i)){n[a]=i,o=!0;return}const d=r?.[s]||"string";let u=i;if(d==="number"){const l=Number(i);u=isNaN(l)?i:l}else d==="boolean"?u=i==="true"||i===!0||i==="1"||i===1:d==="date"?u=String(i):i!=null?u=typeof i=="object"?i:String(i):u="";n[a]=u}),{transformed:n,hasFiles:o}}const ph=Object.freeze(Object.defineProperty({__proto__:null,hasFileValues:uN,isFileValue:Ui,prepareFormDataWithFiles:fN,transformFormValuesWithFiles:pN},Symbol.toStringTag,{value:"Module"}));function mN(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 hN(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 d;if(n.fieldPayloadKeys&&typeof n.fieldPayloadKeys=="object"&&!Array.isArray(n.fieldPayloadKeys)){d={};for(const[u,l]of Object.entries(n.fieldPayloadKeys))typeof l=="string"&&l.trim()&&(d[u]=l.trim());Object.keys(d).length===0&&(d=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}:{},...d?{fieldPayloadKeys:d}:{},...n.heading&&typeof n.heading=="object"?{heading:n.heading}:{}})}return t.length>0?t:void 0}function mh(e){return e?.mode==="nested_by_section"}function hh(e){const t=e.payloadKey?.trim();return t||null}function gh(e,t){return t.fieldPayloadKeys?.[e]?.trim()||e}function yh(e,t,r,n){if(!mh(r)||!t?.length)return{...e};const o=new Set([]),s=r?.includeUnassignedAtRoot!==!1,i=new Set,a={};for(const d of t){const u=hh(d);if(!u)continue;const l={};for(const f of d.fieldNames){if(o.has(f)||!(f in e))continue;i.add(f);const p=gh(f,d);l[p]=e[f]}Object.keys(l).length>0&&(a[u]=l)}if(s)for(const[d,u]of Object.entries(e))o.has(d)||i.has(d)||(a[d]=u);return a}function gN(e,t,r){const n={...e??{}};if(!mh(r)||!t?.length)return n;for(const o of t){const s=hh(o);if(s)for(const i of o.fieldNames){if(n[i]?.trim())continue;const a=gh(i,o);n[i]=`${s}.${a}`}}return n}function yN(e){return e==="null"?null:e==="true"?!0:e==="false"?!1:e}function bN(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 vN(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 d=i===n,u=i.startsWith(`${n}__addmore__`);if(!d&&!u||!bN(a))return;const l=Qe(a,o);l==null||l===""||s.push(l)}),s}function Vi(e,t,r,n,o,s){const i=e.trim().match(/^\{respAll:([^}]+)\}$/);if(i){const u=(i[1]||"").trim(),l=u.split("."),f=l.length>=2?l.slice(1).join("."):"";return(f==="data.id"||f==="data.documentId")&&n?.document_ids!=null&&Array.isArray(n.document_ids)?n.document_ids:vN(u,o)}const a=e.trim().match(/^\{(\w+)\}$/);if(a){const u=a[1],l=t[u];if(l!==void 0)return l;const f=Object.keys(t).find(p=>p.toLowerCase()===u.toLowerCase());if(f)return t[f]}const d=rn(e,t,r,n,o,s);return yN(String(d))}const wN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d,onClick:u,onSubmit:l,onReset:f,onCancel:p,isSubmitting:m=!1,formValues:g={},submissionContext:h,bffSubmitApi:y,onBffSubmitResult:w,extraSubmitPayload:v,buttonResponses:x,onButtonApiResponse:E,onValidateForm:P,getValidationErrors:k,allFields:N,onSubmittingChange:C,scopedFormValues:A,scopedFieldNameMap:I,prepopulateResponse:T=null,formSections:W,submitPayload:X})=>{const{gridStretch:O}=zo(),[j,M]=S.useState(!1),D=e.properties,L=ha.useParams(),U=S.useMemo(()=>({...h,...v}),[h,v]),$=S.useMemo(()=>{if(!A||!I||Object.keys(I).length===0)return g;const Je={};return Object.entries(A).forEach(([q,$e])=>{const gt=I[q]||q;gt!==e.name&&(Je[gt]=$e)}),Je},[A,I,g,e.name]),V=(()=>{try{const Je=e.metadata;if(typeof Je=="string")return JSON.parse(Je);if(Je&&typeof Je=="object")return Je}catch{}return null})(),K=D?.submitAction??V?.submitAction,J=D?.apiEndpoint??e.apidata?.apiEndpoint??V?.apiEndpoint;let ce=D?.action||V?.action;!ce&&e.type==="button"&&(ce="submit");const ne=D?.variant||"default",G=D?.size||"default",ee=D?.hideLabel??e.appearance?.hideLabel??!1,Pe=D?.buttonText||e.label||"Button",oe=D?.closeOnCancel??!0,re=async()=>{if(A&&I&&Object.keys(I).length>0||!P)return!0;const Je=await P();if(!Je&&k)try{const q=k();$t.toast.error(ec(q,N??void 0)||"Please fix the errors before submitting.")}catch{$t.toast.error("Please fix the errors before submitting.")}return Je},be=async Je=>{if(Je.preventDefault(),(ce==="submit"?"submit":ce)==="submit"){if(y?.url){if(!await re())return;M(!0),C?.(!0);try{const $e=await ot(),gt=($e?.message??$e?.display_message??"Form submitted successfully!").trim();$t.toast.success(gt||"Form submitted successfully!");const Oe=$e!=null&&typeof $e=="object"?$e:{status:"success",...$e!=null?{data:$e}:{}};E?.(e.name,Oe)}catch($e){const gt=ls($e);$t.toast.error(gt)}finally{M(!1),C?.(!1)}return}if(l){if(!await re())return;M(!0),C?.(!0);try{await l(),E?.(e.name,{status:"success"})}finally{M(!1),C?.(!1)}return}$t.toast.error("Submit not configured. BFF submit API is required for submit buttons.");return}else if(ce==="reset"&&f)f();else if(ce==="cancel")oe?p&&p():f&&f();else if(ce==="download"){const $e=D?.downloadApiEndpoint||V?.downloadApiEndpoint||e.downloadApiEndpoint,gt=D?.downloadApiMethod||V?.downloadApiMethod||e.downloadApiMethod;if($e){M(!0);try{const Oe=gt||"GET",te=cn(rn($e,$,L,U,x,T??void 0)),pe={method:Oe,headers:{}};Oe!=="GET"&&Oe!=="DELETE"&&(pe.headers={"Content-Type":"application/json"});const We=await fetch(te,pe);if(!We.ok)throw new Error(`Download failed: ${We.statusText}`);const Pt=await We.blob(),je=window.URL.createObjectURL(Pt),Te=document.createElement("a");Te.href=je;const Xe=We.headers.get("Content-Disposition");let Ue="download";if(Xe){const ft=Xe.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);ft&&ft[1]&&(Ue=ft[1].replace(/['"]/g,""))}Te.download=Ue,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te),window.URL.revokeObjectURL(je);try{const ft=lN(We);$t.toast.success(ft&&ft.trim()?ft:"Download started.")}catch{$t.toast.success("Download started.")}}catch(Oe){Zl(Oe,"Failed to download file. Please check the API endpoint and try again.",ls)}finally{M(!1)}}else $t.toast.error("Download endpoint is not configured")}else if(ce==="upload"||ce==="custom"){const $e=ce==="custom",gt=$e?"api":D?.uploadAction||V?.uploadAction||"database";if(gt==="database")if(l){M(!0);try{await l(Je)}catch(Oe){throw Oe}finally{M(!1)}}else $t.toast.error("Form submit handler is not available");else if(gt==="api"){const Oe=D?.uploadApiEndpoint||V?.uploadApiEndpoint||e.uploadApiEndpoint;if(D?.uploadApiMethod||V?.uploadApiMethod||e.uploadApiMethod,Oe){if(!await re())return;M(!0);try{const te=await Se();E?.(e.name,te),aN(te,$e?"Custom API call completed successfully!":"Upload completed successfully!")}catch(te){E?.(e.name,{status:"error",code:te?.response?.code??te?.response?.status??null,message:ls(te)}),Zl(te,$e?"Failed to call custom API. Please check the API endpoint and try again.":"Failed to upload. Please check the API endpoint and try again.",ls)}finally{M(!1)}}else $t.toast.error($e?"Custom API endpoint is not configured":"Upload endpoint is not configured")}else gt==="custom"&&$t.toast.info("Custom upload handler is not implemented")}else u?u():r&&t!==void 0&&r(t||"");n?.()},de=async()=>{if(!K||K!=="api"||!J)return null;const Je=D?.apiBodyFields??V?.apiBodyFields;if((D?.apiBodyFieldsOnly??V?.apiBodyFieldsOnly??!1)&&Je?.length){const Te={};return Je.forEach(({key:Xe,value:Ue})=>{const ft=Vi(Ue,$,L,U,x,T??void 0),St=Xe==="user_id"?"context_user_id":Xe;Te[St]=ft}),Te.user_id!==void 0&&Te.user_id!==null&&(Te.context_user_id=Te.context_user_id??Te.user_id,delete Te.user_id),Te}const $e=N?.length?tc($,N):$,gt=D?.apiFieldMapping??V?.apiFieldMapping,Oe=D?.apiFieldTypes??V?.apiFieldTypes,te=D?.apiBodyStructure??V?.apiBodyStructure,pe={...Oe};N?.length&&N.forEach(Te=>{const Xe=Te.name||Te.key;Xe&&(Te.type==="terms"||Te.type==="checkbox")&&(pe[Xe]="boolean")});const{transformFormValuesWithFiles:We}=await Promise.resolve().then(()=>ph),{transformed:Pt}=We($e,gt,pe);let je={};if(te==="flat"?je={...Pt}:je={data:{...Pt}},gt){const Te={};Object.keys(je).forEach(Xe=>{const Ue=gt[Xe]||Xe;Te[Ue]=je[Xe]}),je=Te}return Je?.length&&Je.forEach(({key:Te,value:Xe})=>{const Ue=Vi(Xe,$,L,U,x,T??void 0),ft=Te==="user_id"?"context_user_id":Te;je[ft]=Ue}),je.user_id!==void 0&&je.user_id!==null&&(je.context_user_id=je.context_user_id??je.user_id,delete je.user_id),je.data?.user_id!==void 0&&je.data?.user_id!==null&&(je.data.context_user_id=je.data.context_user_id??je.data.user_id,delete je.data.user_id),je},ot=async()=>{if(!y||!y.url)throw new Error("BFF submit API configuration is missing");const Je=N?.length?tc(g,N):g,q={};Object.keys(Je).forEach(ze=>{const yt=e.name===ze&&e.type==="button",pt=ze.toLowerCase().includes("button");!yt&&!pt&&(q[ze]=Je[ze])});const $e=Object.keys(q).filter(ze=>Ui(q[ze]));$e.forEach(ze=>{q[ze]=""});const gt=yh(q,W,X),Oe={workflow_id:y.payload?.workflow_id||"",current_step_id:y.payload?.current_step_id||"",form_data:gt},te=["workflow_id","current_step_id","form_data","submit_body","submit_api_endpoint","submit_api_method"];if(h&&typeof h=="object"&&Object.entries(h).forEach(([ze,yt])=>{if(yt==null||te.includes(ze))return;const pt=ze==="user_id"?"context_user_id":ze;Oe[pt]=Oe[pt]??yt}),v&&typeof v=="object"&&Object.entries(v).forEach(([ze,yt])=>{if(yt==null||te.includes(ze))return;const pt=ze==="user_id"?"context_user_id":ze;Oe[pt]=Oe[pt]??yt}),K==="api"&&J)try{const ze=await de();if(ze){const yt=D?.apiBodyStructure??V?.apiBodyStructure,pt=D?.apiFieldMapping??V?.apiFieldMapping;$e.forEach(Ut=>{const ur=pt?.[Ut]??Ut,Ar=q[Ut]!==void 0&&typeof q[Ut]=="string"?q[Ut]:"";yt==="flat"?ze[ur]=Ar:ze.data&&typeof ze.data=="object"?ze.data[ur]=Ar:ze[ur]=Ar}),Oe.submit_body=ze;let At=rn(J,$,L,U,x,T??void 0);At=At.replace(/\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}/gi,"$1"),At=cn(At),Oe.submit_api_endpoint=At,Oe.submit_api_method=D?.submitApiMethod||V?.submitApiMethod||"POST"}}catch{}const pe=(y.method||"POST").toUpperCase(),We=$e.length>0,Pt=Oe.submit_api_endpoint??J??"",je=typeof Pt=="string"?Pt.toLowerCase():"",Te=je.includes("/upload")||je.includes("/payments")||je.includes("/bulk-upload"),Xe=We&&Te;let Ue;const ft={...y.headers||{}};if(Xe){const ze=new FormData;ze.append("payload",JSON.stringify(Oe));for(const yt of $e){const pt=Je[yt],At=D?.apiFieldMapping?.[yt]??yt;pt instanceof File?ze.append(At,pt):Array.isArray(pt)&&pt.length>0&&pt[0]instanceof File&&pt.forEach(Ut=>ze.append(At,Ut))}Ue=ze,delete ft["content-type"],delete ft["Content-Type"]}else ft["Content-Type"]="application/json",Ue=JSON.stringify(Oe);const St=await fetch(y.url,{method:pe,headers:ft,body:Ue});if(!St.ok){let ze;const yt=await St.text();try{ze=JSON.parse(yt)}catch{ze={message:yt}}const pt=new Error(`BFF submission failed: ${St.status}`);throw pt.response=ze,pt}const xt=await St.json();return w?.(xt),l&&await l(),xt},Se=async()=>{const Je=D?.uploadApiEndpoint||V?.uploadApiEndpoint;if(!Je)throw new Error("Upload API endpoint is not configured");if(!D)throw new Error("Button properties are not configured");const q=(D.uploadApiMethod||"POST").toUpperCase(),$e=cn(rn(Je,$,L,U,x,T??void 0)),gt=D.apiBodyFieldsOnly??V?.apiBodyFieldsOnly??!1,Oe=D.apiBodyFieldsOnlyFormat??V?.apiBodyFieldsOnlyFormat??"json";let te={},pe;const We={};if(gt&&D.apiBodyFields&&D.apiBodyFields.length>0)if(D.apiBodyFields.forEach(({key:Te,value:Xe})=>{te[Te]=Vi(Xe,$,L,U,x,T??void 0)}),Oe==="multipart"){const Te=new FormData;Object.entries(te).forEach(([Xe,Ue])=>{if(Ue instanceof File){Te.append(Xe,Ue);return}if(Array.isArray(Ue)&&Ue.length>0&&Ue[0]instanceof File){Ue.forEach(ft=>Te.append(Xe,ft));return}Ue!=null&&Te.append(Xe,typeof Ue=="object"?JSON.stringify(Ue):String(Ue))}),pe=Te}else pe=JSON.stringify(te),We["Content-Type"]="application/json";else{const Te=$,{transformFormValuesWithFiles:Xe,prepareFormDataWithFiles:Ue,hasFileValues:ft}=await Promise.resolve().then(()=>ph),{transformed:St,hasFiles:xt}=Xe(Te,D.apiFieldMapping,D.apiFieldTypes);if((D.apiBodyStructure??V?.apiBodyStructure??"nested")==="flat"?te={...St}:te={data:{...St}},D.apiFieldMapping){const yt={};Object.keys(te).forEach(pt=>{const At=D.apiFieldMapping[pt]||pt;yt[At]=te[pt]}),te=yt}if(D.apiBodyFields&&D.apiBodyFields.forEach(({key:yt,value:pt})=>{te[yt]=Vi(pt,$,L,U,x,T??void 0)}),xt||ft(te)){const yt=Ue(te,D.apiFieldMapping);yt?pe=yt:(pe=JSON.stringify(te),We["Content-Type"]="application/json")}else pe=JSON.stringify(te),We["Content-Type"]="application/json"}D.apiHeaders&&D.apiHeaders.forEach(({key:Te,value:Xe})=>{const Ue=rn(Xe,$,L,U,x,T??void 0);(Te.toLowerCase()!=="content-type"||!(pe instanceof FormData))&&(We[Te]=Ue)});let Pt=$e;if(D.apiQueryParams&&D.apiQueryParams.length>0){const Te=new URLSearchParams;D.apiQueryParams.forEach(({key:Xe,value:Ue})=>{const ft=rn(Ue,$,L,U,x,T??void 0);Te.append(Xe,ft)}),Pt=`${$e}?${Te.toString()}`}const je=await fetch(Pt,{method:q,headers:We,body:q!=="GET"?pe:void 0});if(!je.ok){let Te;const Xe=await je.text();try{Te=JSON.parse(Xe)}catch{Te={message:Xe}}const Ue=new Error(`Upload failed: ${je.status}`);throw Ue.response=Te,Ue}try{return await je.json()}catch{return{}}},xe=ce==="submit"?"submit":ce,ve=xe==="submit"?"button":xe==="submit"?"submit":xe==="reset"?"reset":"button",Ye=s||e.disabled||i||e.readOnly||j||xe==="submit"&&m,ct=Pe,Ge=to(e),Kt=Fr(e.appearance)==="stretch";return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,hideLabel:ee,children:c.jsx("div",{className:B(O&&!Ge&&"flex w-full min-w-0 flex-col",O&&Ge&&"min-w-0 shrink-0"),children:c.jsxs(Yt,{id:ht(e),type:ve,variant:ne,size:G,disabled:Ye,onClick:be,className:B(e.appearance?.className,O&&!Ge&&"w-full min-w-0 shrink-0",O&&Ge&&!Kt&&"inline-flex w-auto max-w-full shrink-0",O&&Ge&&Kt&&"inline-flex w-full min-w-0 max-w-full shrink-0"),children:[j&&c.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}),ct]})})})},SN=({field:e,disabled:t,readOnly:r,isRequired:n,className:o,buttonResponses:s,onButtonApiResponse:i})=>{const a=e.properties,d=a?.buttonText??e.label??"Edit",u=a?.variant??"outline",l=a?.size??"default",f=a?.hideLabel??e.appearance?.hideLabel??!1,p=e.name||e.key||e.id,m=Uo(s?.[p]),g=t||e.disabled||r||e.readOnly||m,h=y=>{y.preventDefault(),!g&&i?.(p,{status:"success"})};return c.jsx(Et,{field:e,error:void 0,isRequired:n,className:o,hideLabel:f,children:c.jsx(Yt,{id:ht(e),type:"button",variant:u,size:l,disabled:g,onClick:h,className:B(e.appearance?.className,(!to(e)||Fr(e.appearance)==="stretch")&&"w-full min-w-0"),children:d})})},xN=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,onAddMore:i})=>{const a=e.properties||{},d=a.variant||"outline",u=a.size||"default",l=a.buttonText||e.label||"Add More",f=a.hideLabel??e.appearance?.hideLabel??!1,p=r||n||e.disabled||e.readOnly;return c.jsx(Et,{field:e,error:t,isRequired:o,className:s,hideLabel:f,children:c.jsxs(Yt,{id:ht(e),type:"button",variant:d,size:u,disabled:!!p,onClick:i,className:B("w-fit",e.appearance?.className),children:[c.jsx(nu,{className:"h-4 w-4 mr-1"}),l]})})},bh=S.createContext(null);function AN({value:e,children:t}){return c.jsx(bh.Provider,{value:e,children:t})}function CN(){return S.useContext(bh)}function vh(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function cs(e){return e.name||e.key||e.id}function rc(e){return e.filter(t=>!t.parentId&&t.type==="sectionHeading"&&cs(t))}function EN(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 NN(e){const t=new Map;for(const r of rc(e)){const n=cs(r);for(const o of EN(r))t.set(o,n)}return t}function _N(e,t){const r=t.properties||{},n=Array.isArray(r.sectionHeadingNames)?r.sectionHeadingNames.filter(i=>typeof i=="string"&&i.trim()):[],o=rc(e);if(n.length===0)return o;const s=new Set(n);return o.filter(i=>s.has(cs(i)))}function kN(e){const t={};for(const r of rc(e))t[cs(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 wh(e,t,r,n){if(!e||t==="customizeSections")return!0;const o=vh(e),s=t==="sectionHeading"?o:n.get(o);return s?r[s]!==!1:!0}const TN=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,designMode:i=!1})=>{const a=CN(),d=e.properties||{},u=d.variant||"outline",l=d.size||"default",f=d.buttonText||e.label||"Customise sections",p=d.menuTitle||"VISIBLE SECTIONS",m=d.hideLabel??e.appearance?.hideLabel??!1,g=r||n||e.disabled||e.readOnly,h=S.useMemo(()=>a?.allFields?.length?_N(a.allFields,e):[],[a?.allFields,e]);return c.jsx(Et,{field:e,error:t,isRequired:o,className:s,hideLabel:m,children:c.jsxs(Ol,{children:[c.jsx(Hp,{asChild:!0,children:c.jsxs(Yt,{id:ht(e),type:"button",variant:u,size:l,disabled:!!g,className:B("w-fit gap-2",e.appearance?.className),children:[c.jsx(Fv,{className:"h-4 w-4"}),f]})}),c.jsxs(Il,{align:"end",className:"w-64 p-0",children:[c.jsx("div",{className:"px-3 py-2 border-b",children:c.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:p})}),c.jsx("div",{className:"max-h-64 overflow-auto p-2 space-y-1",children:h.length===0?c.jsx("p",{className:"text-xs text-muted-foreground px-1 py-2",children:"No section headings on this form."}):h.map(y=>{const w=cs(y),v=y.label||w,x=i||!a?!0:a.visibility[w]!==!1;return c.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md px-1 py-1.5 hover:bg-muted/50",children:[c.jsx(Sn,{htmlFor:`ui-section-${e.id}-${w}`,className:"text-xs font-normal truncate",children:v}),c.jsx(Nm,{id:`ui-section-${e.id}-${w}`,checked:x,disabled:i||!a||!!g,onCheckedChange:E=>{!a||i||a.setSectionVisible(w,!!E)}})]},y.id)})})]})]})})},FN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=u?.max||5,f=u?.icon||"star",p=h=>{s||i||e.disabled||e.readOnly||(r(h),n?.())},m=h=>{},g=h=>{const y=t>=h+1,w=B("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 f==="star"?c.jsx(ou,{className:B(w,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h):c.jsx(ou,{className:B(w,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h)};return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{id:ht(e),className:"flex items-center gap-1",role:"radiogroup","aria-label":e.label,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[Array.from({length:l},(h,y)=>g(y)),u?.showValue!==!1&&c.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:t>0?t:""})]})})};var Sh=["PageUp","PageDown"],xh=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Ah={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},vo="Slider",[nc,PN,ON]=Ba(vo),[Ch]=vr(vo,[ON]),[IN,Hi]=Ch(vo),Eh=b.forwardRef((e,t)=>{const{name:r,min:n=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:d=0,defaultValue:u=[n],value:l,onValueChange:f=()=>{},onValueCommit:p=()=>{},inverted:m=!1,form:g,...h}=e,y=b.useRef(new Set),w=b.useRef(0),x=i==="horizontal"?MN:LN,[E=[],P]=Zr({prop:l,defaultProp:u,onChange:T=>{[...y.current][w.current]?.focus(),f(T)}}),k=b.useRef(E);function N(T){const W=zN(E,T);I(T,W)}function C(T){I(T,w.current)}function A(){const T=k.current[w.current];E[w.current]!==T&&p(E)}function I(T,W,{commit:X}={commit:!1}){const O=WN(s),j=RN(Math.round((T-n)/s)*s+n,O),M=qo(j,[n,o]);P((D=[])=>{const L=$N(D,M,W);if(HN(L,d*s)){w.current=L.indexOf(M);const U=String(L)!==String(D);return U&&X&&p(L),U?L:D}else return D})}return c.jsx(IN,{scope:e.__scopeSlider,name:r,disabled:a,min:n,max:o,valueIndexToChangeRef:w,thumbs:y.current,values:E,orientation:i,form:g,children:c.jsx(nc.Provider,{scope:e.__scopeSlider,children:c.jsx(nc.Slot,{scope:e.__scopeSlider,children:c.jsx(x,{"aria-disabled":a,"data-disabled":a?"":void 0,...h,ref:t,onPointerDown:Me(h.onPointerDown,()=>{a||(k.current=E)}),min:n,max:o,inverted:m,onSlideStart:a?void 0:N,onSlideMove:a?void 0:C,onSlideEnd:a?void 0:A,onHomeKeyDown:()=>!a&&I(n,0,{commit:!0}),onEndKeyDown:()=>!a&&I(o,E.length-1,{commit:!0}),onStepKeyDown:({event:T,direction:W})=>{if(!a){const j=Sh.includes(T.key)||T.shiftKey&&xh.includes(T.key)?10:1,M=w.current,D=E[M],L=s*j*W;I(D+L,M,{commit:!0})}}})})})})});Eh.displayName=vo;var[Nh,_h]=Ch(vo,{startEdge:"left",endEdge:"right",size:"width",direction:1}),MN=b.forwardRef((e,t)=>{const{min:r,max:n,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:d,onStepKeyDown:u,...l}=e,[f,p]=b.useState(null),m=Ze(t,x=>p(x)),g=b.useRef(void 0),h=ro(o),y=h==="ltr",w=y&&!s||!y&&s;function v(x){const E=g.current||f.getBoundingClientRect(),P=[0,E.width],N=ic(P,w?[r,n]:[n,r]);return g.current=E,N(x-E.left)}return c.jsx(Nh,{scope:e.__scopeSlider,startEdge:w?"left":"right",endEdge:w?"right":"left",direction:w?1:-1,size:"width",children:c.jsx(kh,{dir:h,"data-orientation":"horizontal",...l,ref:m,style:{...l.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:x=>{const E=v(x.clientX);i?.(E)},onSlideMove:x=>{const E=v(x.clientX);a?.(E)},onSlideEnd:()=>{g.current=void 0,d?.()},onStepKeyDown:x=>{const P=Ah[w?"from-left":"from-right"].includes(x.key);u?.({event:x,direction:P?-1:1})}})})}),LN=b.forwardRef((e,t)=>{const{min:r,max:n,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:d,...u}=e,l=b.useRef(null),f=Ze(t,l),p=b.useRef(void 0),m=!o;function g(h){const y=p.current||l.current.getBoundingClientRect(),w=[0,y.height],x=ic(w,m?[n,r]:[r,n]);return p.current=y,x(h-y.top)}return c.jsx(Nh,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:c.jsx(kh,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:h=>{const y=g(h.clientY);s?.(y)},onSlideMove:h=>{const y=g(h.clientY);i?.(y)},onSlideEnd:()=>{p.current=void 0,a?.()},onStepKeyDown:h=>{const w=Ah[m?"from-bottom":"from-top"].includes(h.key);d?.({event:h,direction:w?-1:1})}})})}),kh=b.forwardRef((e,t)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:d,...u}=e,l=Hi(vo,r);return c.jsx(Be.span,{...u,ref:t,onKeyDown:Me(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):Sh.concat(xh).includes(f.key)&&(d(f),f.preventDefault())}),onPointerDown:Me(e.onPointerDown,f=>{const p=f.target;p.setPointerCapture(f.pointerId),f.preventDefault(),l.thumbs.has(p)?p.focus():n(f)}),onPointerMove:Me(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:Me(e.onPointerUp,f=>{const p=f.target;p.hasPointerCapture(f.pointerId)&&(p.releasePointerCapture(f.pointerId),s(f))})})}),Th="SliderTrack",Fh=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=Hi(Th,r);return c.jsx(Be.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...n,ref:t})});Fh.displayName=Th;var oc="SliderRange",Ph=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=Hi(oc,r),s=_h(oc,r),i=b.useRef(null),a=Ze(t,i),d=o.values.length,u=o.values.map(p=>Mh(p,o.min,o.max)),l=d>1?Math.min(...u):0,f=100-Math.max(...u);return c.jsx(Be.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...n,ref:a,style:{...e.style,[s.startEdge]:l+"%",[s.endEdge]:f+"%"}})});Ph.displayName=oc;var sc="SliderThumb",Oh=b.forwardRef((e,t)=>{const r=PN(e.__scopeSlider),[n,o]=b.useState(null),s=Ze(t,a=>o(a)),i=b.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return c.jsx(DN,{...e,ref:s,index:i})}),DN=b.forwardRef((e,t)=>{const{__scopeSlider:r,index:n,name:o,...s}=e,i=Hi(sc,r),a=_h(sc,r),[d,u]=b.useState(null),l=Ze(t,v=>u(v)),f=d?i.form||!!d.closest("form"):!0,p=Jo(d),m=i.values[n],g=m===void 0?0:Mh(m,i.min,i.max),h=jN(n,i.values.length),y=p?.[a.size],w=y?UN(y,g,a.direction):0;return b.useEffect(()=>{if(d)return i.thumbs.add(d),()=>{i.thumbs.delete(d)}},[d,i.thumbs]),c.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${w}px)`},children:[c.jsx(nc.ItemSlot,{scope:e.__scopeSlider,children:c.jsx(Be.span,{role:"slider","aria-label":e["aria-label"]||h,"aria-valuemin":i.min,"aria-valuenow":m,"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:l,style:m===void 0?{display:"none"}:e.style,onFocus:Me(e.onFocus,()=>{i.valueIndexToChangeRef.current=n})})}),f&&c.jsx(Ih,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},n)]})});Oh.displayName=sc;var BN="RadioBubbleInput",Ih=b.forwardRef(({__scopeSlider:e,value:t,...r},n)=>{const o=b.useRef(null),s=Ze(o,n),i=Qo(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const d=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(d,"value").set;if(i!==t&&l){const f=new Event("input",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Be.input,{style:{display:"none"},...r,ref:s,defaultValue:t})});Ih.displayName=BN;function $N(e=[],t,r){const n=[...e];return n[r]=t,n.sort((o,s)=>o-s)}function Mh(e,t,r){const s=100/(r-t)*(e-t);return qo(s,[0,100])}function jN(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function zN(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 UN(e,t,r){const n=e/2,s=ic([0,50],[0,n]);return(n-s(t)*r)*r}function VN(e){return e.slice(0,-1).map((t,r)=>e[r+1]-t)}function HN(e,t){if(t>0){const r=VN(e);return Math.min(...r)>=t}return!0}function ic(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 WN(e){return(String(e).split(".")[1]||"").length}function RN(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}var GN=Eh,KN=Fh,qN=Ph,YN=Oh;function XN({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 c.jsxs(GN,{"data-slot":"slider",defaultValue:t,value:r,min:n,max:o,className:B("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:[c.jsx(KN,{"data-slot":"slider-track",className:B("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:c.jsx(qN,{"data-slot":"slider-range",className:B("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:i.length},(a,d)=>c.jsx(YN,{"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"},d))]})}const JN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=u?.min??0,f=u?.max??100,p=u?.step??1,m=u?.showValue!==!1,g=u?.marks||[],h=w=>{s||i||e.disabled||e.readOnly||(r(w[0]??l),n?.())},y=t??l;return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[m&&c.jsx("span",{className:"text-sm font-medium",children:y}),!m&&c.jsx("span",{className:"text-sm text-muted-foreground",children:l}),!m&&c.jsx("span",{className:"text-sm text-muted-foreground",children:f})]}),c.jsx(XN,{id:ht(e),value:[y],onValueChange:h,min:l,max:f,step:p,disabled:s||e.disabled||i||e.readOnly,className:B("w-full",o&&"border-destructive",e.appearance?.className),"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a}),g.length>0&&c.jsx("div",{className:"flex justify-between text-xs text-muted-foreground",children:g.map((w,v)=>c.jsx("span",{className:"text-center",children:w.label},v))})]})})},QN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=S.useRef(null),[l,f]=S.useState(!1),p=s||e.disabled||i||e.readOnly,m=S.useCallback(w=>{if(p)return;f(!0);const v=u.current;if(!v)return;const x=v.getContext("2d");if(!x)return;const E=v.getBoundingClientRect(),P="touches"in w?w.touches[0].clientX-E.left:w.clientX-E.left,k="touches"in w?w.touches[0].clientY-E.top:w.clientY-E.top;x.beginPath(),x.moveTo(P,k)},[p]),g=S.useCallback(w=>{if(!l||p)return;const v=u.current;if(!v)return;const x=v.getContext("2d");if(!x)return;const E=v.getBoundingClientRect(),P="touches"in w?w.touches[0].clientX-E.left:w.clientX-E.left,k="touches"in w?w.touches[0].clientY-E.top:w.clientY-E.top;x.lineWidth=2,x.lineCap="round",x.strokeStyle="#000",x.lineTo(P,k),x.stroke(),x.beginPath(),x.moveTo(P,k)},[l,p]),h=S.useCallback(()=>{if(!l)return;f(!1);const w=u.current;if(!w)return;const v=w.toDataURL();r(v),n?.()},[l,r,n]),y=S.useCallback(()=>{const w=u.current;if(!w||p)return;const v=w.getContext("2d");v&&(v.clearRect(0,0,w.width,w.height),r(null),n?.())},[p,r,n]);return S.useEffect(()=>{const w=u.current;if(w&&(w.width=w.offsetWidth,w.height=200,t)){const v=new Image;v.onload=()=>{const x=w.getContext("2d");x&&x.drawImage(v,0,0)},v.src=t}},[t]),c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:B("border-2 border-dashed rounded-lg overflow-hidden",o&&"border-destructive",p&&"opacity-50 cursor-not-allowed"),children:c.jsx("canvas",{ref:u,id:ht(e),className:"w-full cursor-crosshair touch-none",onMouseDown:m,onMouseMove:g,onMouseUp:h,onMouseLeave:h,onTouchStart:m,onTouchMove:g,onTouchEnd:h,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,style:{height:"200px"}})}),!p&&c.jsx("div",{className:"flex justify-end",children:c.jsxs(Yt,{type:"button",variant:"outline",size:"sm",onClick:y,className:"text-xs",children:[c.jsx(Go,{className:"h-3 w-3 mr-1"}),"Clear"]})})]})})},ZN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d,hideRowControls:u=!1,formValues:l,submissionContext:f})=>{const p=e.properties,m=p?.columns||[],g=p?.minRows||1,h=p?.maxRows||10,y=!u&&p?.allowAddRow!==!1,w=!u&&p?.allowDeleteRow!==!1,v=s===!1&&i===!1?!1:s||e.disabled||i||e.readOnly,x=t||[],E=y&&x.length<h,P=w&&x.length>g,k=S.useCallback(()=>{if(!E||v)return;const O={};m.forEach(j=>{O[j.name]=j.defaultValue??""}),r([...x,O]),n?.()},[x,m,E,v,r,n]),N=S.useCallback(O=>{if(!P||v)return;const j=x.filter((M,D)=>D!==O);r(j),n?.()},[x,P,v,r,n]),C=S.useCallback((O,j,M)=>{if(v)return;const D=[...x];D[O]||(D[O]={}),D[O][j]=M,r(D),n?.()},[x,v,r,n]);if(S.useEffect(()=>{if(x.length<g){const O=g-x.length,j=[];for(let M=0;M<O;M++){const D={};m.forEach(L=>{D[L.name]=L.defaultValue??""}),j.push(D)}r([...x,...j])}},[g,m,r,x.length]),m.length===0)return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.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 A=Math.max(1,e.position?.rowSpan??1),I=Math.max(1,e.position?.columnSpan??1),T=Math.max(x.length,1),W=A>=3?"py-4":A>=2?"py-3":"py-2.5",X=I>=3?"px-4":I>=2?"px-3":"px-4";return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{id:ht(e),className:B("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",v&&"opacity-50"),"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.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:[c.jsx("thead",{children:c.jsxs("tr",{className:"border-b border-border bg-muted/60",children:[m.map(O=>c.jsxs("th",{className:B(X,W,"text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground whitespace-nowrap"),children:[O.label,a&&O.validation?.some(j=>j.type==="required")&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]},O.id)),w&&c.jsx("th",{className:"w-12"})]})}),c.jsx("tbody",{className:"h-full",children:x.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:m.length+(w?1:0),className:B(X,"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.'})}):x.map((O,j)=>{const M=x[j],D=M&&typeof M=="object"&&!Array.isArray(M)?{...l??{},...M}:l;return c.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/30 transition-colors last:border-b-0",style:{height:`${100/T}%`},children:[m.map(L=>{const U={...L,name:`${e.name}_${j}_${L.name}`,appearance:{...L.appearance,hideLabel:!0}},$=L.name??"",ie=O[$]!==void 0?O[$]:$&&Object.keys(O).find(G=>G.toLowerCase()===$.toLowerCase())?O[Object.keys(O).find(G=>G.toLowerCase()===$.toLowerCase())]:void 0,V=!!L.readOnly,K=G=>{if(G==null)return"";if(Array.isArray(G))return G.map(ee=>typeof ee=="object"&&ee!==null&&"name"in ee?String(ee.name??ee):String(ee)).join(", ");if(typeof G=="object"&&G!==null&&!(G instanceof Date)){const ee=G;return typeof ee.name=="string"&&typeof ee.code=="string"?`${ee.code} ${ee.name}`.trim():typeof ee.name=="string"?ee.name:typeof ee.code=="string"?ee.code:String(ee.name??ee.code??G)}return String(G)},J=G=>typeof G=="object"&&G!==null&&!Array.isArray(G)?K(G):String(G??""),ce=L.name?.toLowerCase()==="type"||L.label?.toLowerCase()==="type";if(V){const G=K(ie);return c.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:c.jsx("div",{className:"min-w-[120px] text-sm text-foreground",children:ce&&G?c.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}):c.jsx("span",{className:"py-1 block",children:G})})},L.id)}const ne=()=>{switch(L.type){case"text":case"password":case"url":return c.jsx(Da,{field:U,value:J(ie),onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"});case"number":return c.jsx(Xd,{field:U,value:ie??null,onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"});case"email":return c.jsx(su,{field:U,value:J(ie),onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"});case"phone":case"aadhaar":return c.jsx(iu,{field:U,value:J(ie),onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"});case"textarea":return c.jsx(au,{field:U,value:J(ie),onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"});case"select":return c.jsx(kp,{field:U,value:typeof ie=="string"?ie:J(ie),onChange:G=>C(j,L.name,G),disabled:v,className:"w-full",formValues:D,submissionContext:f});case"multiselect":{const G=Array.isArray(ie)?ie:ie!=null&&ie!==""?[String(ie)]:[];return c.jsx(vm,{field:U,value:G,onChange:ee=>C(j,L.name,ee),disabled:v,className:"w-full",formValues:D,submissionContext:f})}case"asyncsearch":return c.jsx(Xp,{field:U,value:ie,onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full",formValues:D,submissionContext:f});case"checkbox":return c.jsx(wm,{field:U,value:ie||!1,onChange:G=>C(j,L.name,G),disabled:v,className:"w-full"});case"radio":case"checkboxgroup":return c.jsx(Gm,{field:U,value:typeof ie=="string"?ie:J(ie),onChange:G=>C(j,L.name,G),disabled:v,className:"w-full"});case"date":case"time":case"datetime":case"daterange":return c.jsx(Km,{field:U,value:typeof ie=="string"?ie:J(ie),onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"});default:return c.jsx(Da,{field:U,value:J(ie),onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"})}};return c.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:c.jsx("div",{className:"min-w-[160px] w-full [&_input]:min-w-[10rem] [&_input]:overflow-visible [&_textarea]:min-h-[2.5rem]",children:ne()})},L.id)}),w&&c.jsx("td",{className:"px-2 py-2",children:c.jsx(Yt,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>N(j),disabled:!P||v,children:c.jsx(Go,{className:"h-4 w-4"})})})]},j)})})]})}),E&&c.jsx("div",{className:"shrink-0 p-3 border-t bg-muted/30",children:c.jsxs(Yt,{type:"button",variant:"outline",size:"sm",onClick:k,disabled:v,className:"w-full",children:[c.jsx(nu,{className:"h-4 w-4 mr-2"}),"Add Row"]})})]})})},e_="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",t_="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",r_="h-8 min-w-[2ch] max-w-full flex-1 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0";function Lh(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 n_(e){const t=e.replace(/[^\d.-]/g,"");if(t===""||t==="-"||t===".")return null;const r=parseFloat(t);return Number.isNaN(r)?null:r}function o_(e){if(e==null||e==="")return"";const t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?"":String(t)}function Dh(e,t){return Lh(e,{format:"currency"},t)}function ds(e){return e==null||e===""}function Bh(e){return e.mode??"editable"}function s_(e,t){return e.kind==="currency"||e.kind==="input"&&e.inputType==="number"?!0:t?.format==="currency"||t?.format==="number"||t?.format==="percent"}function $h(e,t,r){if(e!==void 0){if(e==="")return"";if(s_(t,r)){const n=Number(e);return Number.isNaN(n)?e:n}return e}}function ac(e,t){if(!(!e||!("defaultValue"in e)||e.defaultValue===void 0))return $h(e.defaultValue,e,t)}function lc(e,t,r){if(!t||!ds(e))return e;if(t.kind==="currency"&&Bh(t)==="static"&&t.value!==void 0)return $h(t.value,t,r);const n=ac(t,r);return n!==void 0?n:e}function i_(e,t,r){const n={...t};for(const[o,s]of Object.entries(e)){const i=r.find(d=>d.key===o);if(!ds(n[o]))continue;const a=lc(n[o],s,i);(!ds(a)||s&&"defaultValue"in s&&s.defaultValue==="")&&(n[o]=a)}return n}function Wi(e,t,r){if(!ds(e))return e;const n=ac(t,r);return n!==void 0?n:e}const a_=new Set(["all_items_summary","invoice_discount","grand_total"]);function l_(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"&&!a_.has(r.slotId));default:return e}}function cc(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}function c_(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 d_(e,t,r){const n=u=>cc(r.values[u]),o=(u,l)=>{const f=t.find(p=>p.slotId===u&&p.rowKind==="static");return f?cc(f.values[l]):0},s=(u,l="all")=>l_(t,l).reduce((f,p)=>f+cc(p.values[u]),0),i={...Ds.functions,cell:n,cellInRow:o,SUM:s},a=Object.keys(i),d=Object.values(i);try{const u=new Function(...a,`return (${e});`)(...d);return u==null||typeof u=="number"&&Number.isNaN(u)?null:u}catch{return null}}function wo(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=c_(e,n,o.key);if(s?.kind==="formula"){const i=d_(s.expression,r,n),a=e.columns.find(d=>d.key===o.key);n.values[o.key]=ds(i)?ac(s,a)??i:i}}return{rows:r}}function u_(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 wo(e,{rows:i})}function jh(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,l]of Object.entries(e.cells)){const f=r.find(p=>p.key===u);(l.kind==="api"&&l.path||l.kind==="currency"&&l.mode==="api"&&l.path)&&(a[u]=Wi(Qe(s,l.path),l,f))}const d=a.service??a.tariff_type;return{slotId:e.id,rowKind:"dynamic",rowInstanceId:i,label:typeof d=="string"?d:void 0,values:a}})}function dc(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 uc(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:i_(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:dc(e,r,n)}}function f_(e,t,r,n){const o=uc(e,n),s=e.rowSlots.find(d=>d.kind==="dynamic"&&d.block.id===t);if(!s||s.kind!=="dynamic")return wo(e,o);const i=new Map,a=new Map;for(const d of e.rowSlots)if(d.kind==="static"){const u=o.rows.find(l=>l.slotId===d.row.id&&l.rowKind==="static");u&&i.set(d.row.id,{...u,values:{...u.values}})}else{const u=d.block.id===t?jh(d.block,r,e.columns):o.rows.filter(l=>l.slotId===d.block.id&&l.rowKind==="dynamic");a.set(d.block.id,u.map(l=>({...l,values:{...l.values}})))}return wo(e,{rows:dc(e,i,a)})}function p_(e,t,r){const n=uc(e,r);if(t==null||typeof t!="object"||Array.isArray(t))return wo(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(f=>f.slotId===a.row.id&&f.rowKind==="static")?.values??{}},l=o[a.row.id]??o;for(const[f,p]of Object.entries(a.row.cells)){const m=e.columns.find(g=>g.key===f);(p.kind==="api"&&p.path||p.kind==="currency"&&p.mode==="api"&&p.path)&&(u[f]=Wi(Qe(l,p.path),p,m))}s.set(a.row.id,{slotId:a.row.id,rowKind:"static",rowInstanceId:a.row.id,label:a.row.label,values:u})}else{const d=a.block.apiArrayPath??a.block.id,u=Qe(o,d);i.set(a.block.id,Array.isArray(u)?jh(a.block,u,e.columns):[])}return wo(e,{rows:dc(e,s,i)})}function zh(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 m_(e){const t=e?.color?.trim();return t?{color:t}:{}}function fc(e){return{className:zh(e),style:m_(e)}}function h_(e){return e?!!(e.fontSize||e.bold||e.italic||e.underline||e.color?.trim()):!1}function g_(e,t){if(!e&&!t)return;const r={...e,...t};return h_(r)?r:void 0}function y_(e,t){const r=e?.kind==="label"?g_(t,e.cellStyle):e?.cellStyle;return fc(r)}function pc(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function Uh(e,t){return e?.align?e.align:t?.align??"left"}function b_(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 Vh(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 v_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties??{},l=u.columns??[],f=u.currencySymbol??"₹",p=u.emptyDisplay??"—",m=s||i,g=S.useMemo(()=>{const N=uc(u,t);return wo(u,N)},[u,t]);S.useEffect(()=>{!t?.rows?.length&&g.rows.length&&r(g)},[t,g,r]);const h=S.useCallback((N,C,A,I,T)=>{if(m)return;const W=T==="number"?n_(I):I===""?null:I,X=u_(u,g,N,C,A,W);r(X)},[m,g,r,u]),y=(N,C,A,I,T,W)=>{const X=l.find($=>$.key===T),O=Vh(u,N,C,T),j=pc(Uh(O,X)),M=lc(W,O,X),D=b_(u,N,C),L=D?.kind==="static"?D.row.labelStyle:D?.kind==="dynamic"?D.block.labelStyle:void 0,U=y_(O,L);if(O?.kind==="label")return c.jsx("span",{className:B(U.className||"font-medium",j,!U.style.color&&"text-foreground"),style:U.style,children:I??p});if(O?.kind==="input"&&!m){const $=M==null||M===""?"":String(M);return c.jsx(wn,{type:"text",inputMode:O.inputType==="number"?"decimal":"text",value:$,onChange:ie=>h(A,N,T,ie.target.value,O.inputType),onBlur:n,className:B(e_,j,U.className),style:U.style,disabled:m})}if(O?.kind==="currency"){const $=Bh(O);if($==="static"){const V=O.value!==void 0&&O.value!==""?lc(null,{...O,mode:"static"},X):M;return c.jsx("span",{className:B("tabular-nums",j,U.className),style:U.style,children:Dh(V,{currencySymbol:f,emptyDisplay:p})})}if($==="api"||m)return c.jsx("span",{className:B("tabular-nums",j,U.className),style:U.style,children:Dh(M,{currencySymbol:f,emptyDisplay:p})});const ie=o_(M);return c.jsxs("div",{className:B(t_,j==="text-center"&&"justify-center",j==="text-right"&&"justify-end",j==="text-left"&&"justify-start",U.className),style:U.style,children:[c.jsx("span",{className:"shrink-0 tabular-nums",children:f}),c.jsx(wn,{type:"text",inputMode:"decimal",value:ie,onChange:V=>h(A,N,T,V.target.value,"number"),onBlur:n,className:r_,disabled:m})]})}return O?.kind==="static"?c.jsx("span",{className:B(j,U.className,!U.style.color&&"text-muted-foreground"),style:U.style,children:O.value}):c.jsx("span",{className:B(j,U.className),style:U.style,children:Lh(M,X,{currencySymbol:f,emptyDisplay:p})})},w=u.gridTitle?.trim()??"",v=Math.max(1,e.position?.rowSpan??1),x=Math.max(1,e.position?.columnSpan??1),E=Math.max(g.rows.length,1),P=v>=3?"py-4":v>=2?"py-3":"py-2",k=x>=3?"px-4":x>=2?"px-3":"px-2";return l.length===0?c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this billing grid"})}):c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{id:ht(e),className:B("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",m&&"opacity-70"),"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[w?c.jsx("div",{className:B("shrink-0 px-4 py-2 border-b bg-muted/40",zh(u.gridTitleStyle)||"text-muted-foreground"),style:fc(u.gridTitleStyle).style,children:w}):null,c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:u.minWidth?{minWidth:u.minWidth}:void 0,children:[c.jsx("thead",{children:c.jsx("tr",{className:"border-b border-border bg-muted/60",children:l.map(N=>{const C=fc(N.headerStyle);return c.jsx("th",{className:B(k,P,"text-xs uppercase tracking-wider whitespace-nowrap",pc(N.align),C.className||"font-semibold text-muted-foreground"),style:C.style,children:N.label},N.id)})})}),c.jsx("tbody",{className:"h-full",children:g.rows.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:l.length,className:B(k,"py-8 text-center text-sm text-muted-foreground"),children:"No billing rows configured"})}):g.rows.map(N=>c.jsx("tr",{className:"border-b border-border/60",style:{height:`${100/E}%`},children:l.map(C=>{const A=Vh(u,N.slotId,N.rowKind,C.key),I=Uh(A,C);return c.jsx("td",{className:B(k,P,"align-middle whitespace-nowrap",pc(I)),children:y(N.slotId,N.rowKind,N.rowInstanceId,N.label,C.key,N.values[C.key])},C.id)})},`${N.slotId}-${N.rowInstanceId}`))})]})})]})})};function mc(e,t,r){return p_(e,t,r)}const w_=({field:e,value:t,error:r,disabled:n,isRequired:o,className:s,formValues:i={},submissionContext:a,extraSubmitPayload:d,skipApiCall:u=!1,prepopulateResponse:l=null})=>{const f=e.properties||{},p=f.source??"manual",m=Array.isArray(f.statuses)?f.statuses:[],g=(f.dataPath||"data").trim(),h=f.showStatusText===!0,y=(f.statusTextPath||"data.admissionStatus").trim(),w=f.showCurrentIndicator!==!1,[v,x]=S.useState(null),[E,P]=S.useState(!1),[k,N]=S.useState(null),C=ha.useParams(),A=S.useRef(i),I=S.useRef(a),T=S.useRef(d),W=S.useRef(C);A.current=i,I.current=a,T.current=d,W.current=C;const X=S.useCallback(async()=>{const L=f.apiEndpoint?.trim();if(!L){N("Status API endpoint is not configured");return}P(!0),N(null);try{const U=I.current,$=T.current,ie=U!=null&&typeof U=="object"?{...U,...$||{}}:$||{},V=cn(rn(L,A.current,W.current,ie,void 0,l??void 0)),K=(f.apiMethod||"GET").toUpperCase(),J=await fetch(V,{method:K,headers:K==="POST"?{"Content-Type":"application/json"}:void 0});if(!J.ok)throw new Error(`HTTP ${J.status}`);const ce=await J.json(),ne=g?Qe(ce,g):ce;x(ne&&typeof ne=="object"?ne:{})}catch(U){N(U instanceof Error?U.message:"Failed to load status"),x(null)}finally{P(!1)}},[f.apiEndpoint,f.apiMethod,g,l]);S.useEffect(()=>{p==="api"&&!u&&X()},[p,u,X]);const O=p==="api"?v:t&&typeof t=="object"?(g?Qe(t,g):null)??t:null,j=h&&y&&O?String(Qe(O,y)??Qe({data:O},y)??""):"",M=L=>{if(!O||typeof O!="object")return!1;const U=O[L];return U===!0||U==="true"||U===1};let D=!1;return c.jsx(Et,{field:e,error:r||k||void 0,isRequired:o,className:B(s,"!space-y-0 h-full min-h-0 flex flex-col"),children:c.jsxs("div",{className:"rounded-lg border bg-card p-4 h-full min-h-0 flex flex-col",children:[E&&c.jsx("div",{className:"text-sm text-muted-foreground py-2",children:"Loading status..."}),h&&j&&!E&&c.jsx("p",{className:"text-sm text-muted-foreground mb-3 shrink-0","data-status-text":!0,children:j}),!E&&c.jsx("ul",{className:"flex-1 min-h-0 flex flex-col gap-y-8 overflow-y-auto pr-1 py-1",children:m.map(L=>{const U=M(L.key),$=w&&U&&!D;return $&&(D=!0),c.jsxs("li",{className:B("flex items-center gap-3 text-sm",U?"text-foreground":"text-muted-foreground"),children:[U?c.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:c.jsx(Vs,{className:"h-3 w-3"})}):c.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:c.jsx(eu,{className:"h-2.5 w-2.5 text-muted-foreground/60"})}),c.jsx("span",{className:"flex-1 min-w-0",children:L.label}),$&&c.jsx("span",{className:"shrink-0 text-xs font-medium text-primary",children:"Current"})]},L.key)})}),!E&&m.length===0&&c.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 So(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 S_(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 x_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,submissionContext:d})=>{const u=e.properties||{},{dataSourceContextKey:l,labelField:f="name",valueField:p="email",displayFields:m,displayFieldsSeparator:g=" | ",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:d?Object.keys(d):[],dataSourceContextKey:l,contextKeyValue:d&&l?d[l]:void 0});const w=S.useMemo(()=>{if(!l||!d)return[];const T=d[l];return Array.isArray(T)?T:[]},[l,d]);console.log("[SelectableList] Step 2: contextList from submissionContext",{fieldName:e.name,contextListLength:w.length,contextListSample:w.length>0?w.slice(0,2):[]});const[v,x]=S.useState(()=>w.length>0?w:Array.isArray(t)?t:[]);S.useEffect(()=>{if(w.length>0){console.log("[SelectableList] Step 3: sync fullList from context",{fieldName:e.name,contextListLength:w.length}),x(w);return}Array.isArray(t)&&t.length>0&&x(T=>{const W=T.length===0||t.length>T.length?t:T;return console.log("[SelectableList] Step 3: sync fullList from value",{fieldName:e.name,valueLength:t.length,prevLength:T.length,nextLength:W.length}),W})},[w,t]);const E=S.useMemo(()=>{const T=Array.isArray(t)?t:[];return new Set(T.map(X=>So(X,p)))},[t,p]),P=v.length>0&&v.every(T=>E.has(So(T,p))),k=v.some(T=>E.has(So(T,p))),N=S.useCallback((T,W)=>{const X=So(T,p),O=Array.isArray(t)?t:[];W?E.has(X)||r([...O,T]):r(O.filter(j=>So(j,p)!==X)),n?.()},[t,p,E,r,n]),C=S.useCallback(T=>{r(T===!0?[...v]:[]),n?.()},[v,r,n]),A=v.length>0?v:Array.isArray(t)?t:[],I=s||e.disabled;return console.log("[SelectableList] Data in list",{fieldName:e.name,listLength:A.length,listSource:v.length>0?"fullList":"value",valueLength:Array.isArray(t)?t.length:0,fullListLength:v.length,listData:A.length>0?A:[],listDataFirstThree:A.length>0?A.slice(0,3):[]}),c.jsx("div",{className:B("relative z-10 flex flex-col min-h-0 h-full w-full",A.length>0&&"min-h-[14rem]",a),children:c.jsx(Et,{field:e,error:o,isRequired:i,className:B("flex-1 min-h-0 flex flex-col",A.length>0&&"min-h-[14rem]"),children:c.jsx("div",{className:B("flex-1 min-h-0 flex flex-col",A.length>0&&"min-h-[14rem]"),children:c.jsxs("div",{className:B("flex-1 min-h-0 flex flex-col",A.length>0&&"overflow-visible"),children:[c.jsxs("div",{role:"listbox","aria-multiselectable":!0,className:B("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",A.length>0?"flex-1 min-h-0":"min-h-0"),children:[h&&A.length>0&&c.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:[c.jsx(Ti,{id:`${ht(e)}-select-all`,checked:P?!0:k?"indeterminate":!1,onCheckedChange:C,disabled:I,"aria-label":"Select all"}),c.jsxs(Sn,{htmlFor:`${ht(e)}-select-all`,className:"text-sm font-medium cursor-pointer",children:["Select all (",A.length,")"]}),c.jsxs("div",{className:"flex gap-1 ml-auto",children:[c.jsx(Yt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:I||P,onClick:()=>{r([...v]),n?.()},children:"Select all"}),c.jsx(Yt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:I||!k,onClick:()=>{r([]),n?.()},children:"Unselect all"})]})]}),A.length===0?c.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No items to display."}):c.jsx(c.Fragment,{children:A.map((T,W)=>{const X=So(T,p),O=E.has(X),j=`${ht(e)}-${W}-${X}`;return c.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:[c.jsx(Ti,{id:j,checked:O,onCheckedChange:M=>N(T,M===!0),disabled:I,"aria-describedby":jt(e,!!o)}),c.jsx(Sn,{htmlFor:j,className:"text-sm cursor-pointer flex-1 truncate",children:S_(T,f,m,g)})]},X)})})]}),A.length>0&&E.size===0&&c.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:[c.jsx(_v,{className:"h-4 w-4 shrink-0"}),"Please select at least one item."]})]})})})})},Hh=({field:e,children:t,className:r})=>{const n=e.properties,o=n?.collapsible??!1,s=n?.defaultCollapsed??!1,i=n?.columns??1,[a,d]=S.useState(s),u=()=>{o&&d(!a)},l={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 c.jsxs("div",{className:B("border rounded-lg bg-card",r),children:[c.jsxs("div",{className:B("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&&c.jsx("span",{className:"text-muted-foreground",children:a?c.jsx(Zd,{className:"h-4 w-4"}):c.jsx(Wo,{className:"h-4 w-4"})}),c.jsx("h3",{className:"font-medium text-sm",children:e.label}),e.description&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:e.description})]}),!a&&c.jsx("div",{className:B("p-4 grid gap-4",l[i]),children:t})]})};var A_=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],C_=A_.reduce((e,t)=>{const r=La(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,d=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),E_="Separator",Wh="horizontal",N_=["horizontal","vertical"],Rh=b.forwardRef((e,t)=>{const{decorative:r,orientation:n=Wh,...o}=e,s=__(n)?n:Wh,a=r?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(C_.div,{"data-orientation":s,...a,...o,ref:t})});Rh.displayName=E_;function __(e){return N_.includes(e)}var k_=Rh;function gc({className:e,orientation:t="horizontal",decorative:r=!0,...n}){return c.jsx(k_,{"data-slot":"separator",decorative:r,orientation:t,className:B("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 T_=({field:e,className:t})=>c.jsx("div",{className:B("py-2",t),children:c.jsx(gc,{})}),F_={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"},P_=({field:e,className:t})=>{const r=e.properties,n=r?.headingLevel??"h3",o=r?.showHorizontalLine??!0,s=F_[n],i=n;return c.jsxs("div",{className:B("w-full min-w-0 space-y-1",t),children:[c.jsx(i,{className:B("m-0 text-foreground",s),children:e.label||"Header"}),e.description&&c.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),o&&c.jsx(gc,{className:"w-full"})]})},O_={"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"},I_={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"},M_=({field:e,className:t})=>{const r=e.properties,n=r?.position??"top-left",o=r?.headingLevel??"h3",s=r?.showHorizontalLine??!0,i=O_[n],a=I_[o],d=o;return c.jsxs("div",{className:B("w-full min-w-0 space-y-2",t),children:[c.jsx("div",{className:B("flex w-full",i),children:c.jsx(d,{className:B("m-0 text-foreground",a),children:e.label||"Section Heading"})}),s&&c.jsx(gc,{className:"w-full"})]})},L_=({field:e,className:t})=>{const r=e.appearance?.size||"md",n={sm:"h-4",md:"h-8",lg:"h-12"};return c.jsx("div",{className:B(n[r],t),"aria-hidden":"true"})};function Gh(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 D_(e){if(Array.isArray(e))return e}function B_(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,s,i,a=[],d=!0,u=!1;try{if(s=(r=r.call(e)).next,t!==0)for(;!(d=(n=s.call(r)).done)&&(a.push(n.value),a.length!==t);d=!0);}catch(l){u=!0,o=l}finally{try{if(!d&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return a}}function $_(){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 j_(e,t){return D_(e)||B_(e,t)||z_(e,t)||$_()}function z_(e,t){if(e){if(typeof e=="string")return Gh(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)?Gh(e,t):void 0}}const Kh=Object.entries,qh=Object.setPrototypeOf,U_=Object.isFrozen,V_=Object.getPrototypeOf,H_=Object.getOwnPropertyDescriptor;let lr=Object.freeze,Mr=Object.seal,xo=Object.create,Yh=typeof Reflect<"u"&&Reflect,yc=Yh.apply,bc=Yh.construct;lr||(lr=function(t){return t}),Mr||(Mr=function(t){return t}),yc||(yc=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)}),bc||(bc=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 Ao=zt(Array.prototype.forEach),W_=zt(Array.prototype.lastIndexOf),Xh=zt(Array.prototype.pop),Co=zt(Array.prototype.push),R_=zt(Array.prototype.splice),cr=Array.isArray,us=zt(String.prototype.toLowerCase),vc=zt(String.prototype.toString),Jh=zt(String.prototype.match),Eo=zt(String.prototype.replace),Qh=zt(String.prototype.indexOf),G_=zt(String.prototype.trim),K_=zt(Number.prototype.toString),q_=zt(Boolean.prototype.toString),Zh=typeof BigInt>"u"?null:zt(BigInt.prototype.toString),eg=typeof Symbol>"u"?null:zt(Symbol.prototype.toString),Ot=zt(Object.prototype.hasOwnProperty),fs=zt(Object.prototype.toString),Zt=zt(RegExp.prototype.test),Ri=Y_(TypeError);function zt(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 yc(e,t,n)}}function Y_(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return bc(e,r)}}function nt(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:us;if(qh&&qh(e,null),!cr(t))return e;let n=t.length;for(;n--;){let o=t[n];if(typeof o=="string"){const s=r(o);s!==o&&(U_(t)||(t[n]=s),o=s)}e[o]=!0}return e}function X_(e){for(let t=0;t<e.length;t++)Ot(e,t)||(e[t]=null);return e}function hr(e){const t=xo(null);for(const n of Kh(e)){var r=j_(n,2);const o=r[0],s=r[1];Ot(e,o)&&(cr(s)?t[o]=X_(s):s&&typeof s=="object"&&s.constructor===Object?t[o]=hr(s):t[o]=s)}return t}function J_(e){switch(typeof e){case"string":return e;case"number":return K_(e);case"boolean":return q_(e);case"bigint":return Zh?Zh(e):"0";case"symbol":return eg?eg(e):"Symbol()";case"undefined":return fs(e);case"function":case"object":{if(e===null)return fs(e);const t=e,r=Kn(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 Kn(e,t){for(;e!==null;){const n=H_(e,t);if(n){if(n.get)return zt(n.get);if(typeof n.value=="function")return zt(n.value)}e=V_(e)}function r(){return null}return r}function Q_(e){try{return Zt(e,""),!0}catch{return!1}}const tg=lr(["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"]),wc=lr(["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"]),Sc=lr(["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"]),Z_=lr(["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=lr(["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"]),ek=lr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),rg=lr(["#text"]),ng=lr(["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"]),Ac=lr(["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"]),og=lr(["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"]),Gi=lr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),tk=Mr(/{{[\w\W]*|^[\w\W]*}}/g),rk=Mr(/<%[\w\W]*|^[\w\W]*%>/g),nk=Mr(/\${[\w\W]*/g),ok=Mr(/^data-[\-\w.\u00B7-\uFFFF]+$/),sk=Mr(/^aria-[\-\w]+$/),sg=Mr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ik=Mr(/^(?:\w+script|data):/i),ak=Mr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),lk=Mr(/^html$/i),ck=Mr(/^[a-z][.\w]*(-[.\w]+)+$/i),No={element:1,text:3,progressingInstruction:7,comment:8,document:9},dk=function(){return typeof window>"u"?null:window},uk=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}},ig=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ag(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:dk();const t=Ee=>ag(Ee);if(t.version="3.4.5",t.removed=[],!e||!e.document||e.document.nodeType!==No.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,d=e.Element,u=e.NodeFilter,l=e.NamedNodeMap,f=l===void 0?e.NamedNodeMap||e.MozNamedAttrMap:l,p=e.HTMLFormElement,m=e.DOMParser,g=e.trustedTypes,h=d.prototype,y=Kn(h,"cloneNode"),w=Kn(h,"remove"),v=Kn(h,"nextSibling"),x=Kn(h,"childNodes"),E=Kn(h,"parentNode"),P=a&&a.prototype?Kn(a.prototype,"nodeType"):null;if(typeof i=="function"){const Ee=r.createElement("template");Ee.content&&Ee.content.ownerDocument&&(r=Ee.content.ownerDocument)}let k,N="";const C=r,A=C.implementation,I=C.createNodeIterator,T=C.createDocumentFragment,W=C.getElementsByTagName,X=n.importNode;let O=ig();t.isSupported=typeof Kh=="function"&&typeof E=="function"&&A&&A.createHTMLDocument!==void 0;const j=tk,M=rk,D=nk,L=ok,U=sk,$=ik,ie=ak,V=ck;let K=sg,J=null;const ce=nt({},[...tg,...wc,...Sc,...xc,...rg]);let ne=null;const G=nt({},[...ng,...Ac,...og,...Gi]);let ee=Object.seal(xo(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}})),Pe=null,oe=null;const re=Object.seal(xo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let be=!0,de=!0,ot=!1,Se=!0,xe=!1,ae=!0,ve=!1,Ye=!1,ct=!1,Ge=!1,Kt=!1,Je=!1,q=!0,$e=!1;const gt="user-content-";let Oe=!0,te=!1,pe={},We=null;const Pt=nt({},["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 je=null;const Te=nt({},["audio","video","img","source","image","track"]);let Xe=null;const Ue=nt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ft="http://www.w3.org/1998/Math/MathML",St="http://www.w3.org/2000/svg",xt="http://www.w3.org/1999/xhtml";let ze=xt,yt=!1,pt=null;const At=nt({},[ft,St,xt],vc);let Ut=nt({},["mi","mo","mn","ms","mtext"]),ur=nt({},["annotation-xml"]);const Ar=nt({},["title","style","font","a","script"]);let Vt=null;const Po=["application/xhtml+xml","text/html"],Xn="text/html";let Ct=null,Cr=null;const Jn=r.createElement("form"),It=function(F){return F instanceof RegExp||F instanceof Function},Er=function(){let F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Cr&&Cr===F)return;(!F||typeof F!="object")&&(F={}),F=hr(F),Vt=Po.indexOf(F.PARSER_MEDIA_TYPE)===-1?Xn:F.PARSER_MEDIA_TYPE,Ct=Vt==="application/xhtml+xml"?vc:us,J=Ot(F,"ALLOWED_TAGS")&&cr(F.ALLOWED_TAGS)?nt({},F.ALLOWED_TAGS,Ct):ce,ne=Ot(F,"ALLOWED_ATTR")&&cr(F.ALLOWED_ATTR)?nt({},F.ALLOWED_ATTR,Ct):G,pt=Ot(F,"ALLOWED_NAMESPACES")&&cr(F.ALLOWED_NAMESPACES)?nt({},F.ALLOWED_NAMESPACES,vc):At,Xe=Ot(F,"ADD_URI_SAFE_ATTR")&&cr(F.ADD_URI_SAFE_ATTR)?nt(hr(Ue),F.ADD_URI_SAFE_ATTR,Ct):Ue,je=Ot(F,"ADD_DATA_URI_TAGS")&&cr(F.ADD_DATA_URI_TAGS)?nt(hr(Te),F.ADD_DATA_URI_TAGS,Ct):Te,We=Ot(F,"FORBID_CONTENTS")&&cr(F.FORBID_CONTENTS)?nt({},F.FORBID_CONTENTS,Ct):Pt,Pe=Ot(F,"FORBID_TAGS")&&cr(F.FORBID_TAGS)?nt({},F.FORBID_TAGS,Ct):hr({}),oe=Ot(F,"FORBID_ATTR")&&cr(F.FORBID_ATTR)?nt({},F.FORBID_ATTR,Ct):hr({}),pe=Ot(F,"USE_PROFILES")?F.USE_PROFILES&&typeof F.USE_PROFILES=="object"?hr(F.USE_PROFILES):F.USE_PROFILES:!1,be=F.ALLOW_ARIA_ATTR!==!1,de=F.ALLOW_DATA_ATTR!==!1,ot=F.ALLOW_UNKNOWN_PROTOCOLS||!1,Se=F.ALLOW_SELF_CLOSE_IN_ATTR!==!1,xe=F.SAFE_FOR_TEMPLATES||!1,ae=F.SAFE_FOR_XML!==!1,ve=F.WHOLE_DOCUMENT||!1,Ge=F.RETURN_DOM||!1,Kt=F.RETURN_DOM_FRAGMENT||!1,Je=F.RETURN_TRUSTED_TYPE||!1,ct=F.FORCE_BODY||!1,q=F.SANITIZE_DOM!==!1,$e=F.SANITIZE_NAMED_PROPS||!1,Oe=F.KEEP_CONTENT!==!1,te=F.IN_PLACE||!1,K=Q_(F.ALLOWED_URI_REGEXP)?F.ALLOWED_URI_REGEXP:sg,ze=typeof F.NAMESPACE=="string"?F.NAMESPACE:xt,Ut=Ot(F,"MATHML_TEXT_INTEGRATION_POINTS")&&F.MATHML_TEXT_INTEGRATION_POINTS&&typeof F.MATHML_TEXT_INTEGRATION_POINTS=="object"?hr(F.MATHML_TEXT_INTEGRATION_POINTS):nt({},["mi","mo","mn","ms","mtext"]),ur=Ot(F,"HTML_INTEGRATION_POINTS")&&F.HTML_INTEGRATION_POINTS&&typeof F.HTML_INTEGRATION_POINTS=="object"?hr(F.HTML_INTEGRATION_POINTS):nt({},["annotation-xml"]);const Y=Ot(F,"CUSTOM_ELEMENT_HANDLING")&&F.CUSTOM_ELEMENT_HANDLING&&typeof F.CUSTOM_ELEMENT_HANDLING=="object"?hr(F.CUSTOM_ELEMENT_HANDLING):xo(null);if(ee=xo(null),Ot(Y,"tagNameCheck")&&It(Y.tagNameCheck)&&(ee.tagNameCheck=Y.tagNameCheck),Ot(Y,"attributeNameCheck")&&It(Y.attributeNameCheck)&&(ee.attributeNameCheck=Y.attributeNameCheck),Ot(Y,"allowCustomizedBuiltInElements")&&typeof Y.allowCustomizedBuiltInElements=="boolean"&&(ee.allowCustomizedBuiltInElements=Y.allowCustomizedBuiltInElements),xe&&(de=!1),Kt&&(Ge=!0),pe&&(J=nt({},rg),ne=xo(null),pe.html===!0&&(nt(J,tg),nt(ne,ng)),pe.svg===!0&&(nt(J,wc),nt(ne,Ac),nt(ne,Gi)),pe.svgFilters===!0&&(nt(J,Sc),nt(ne,Ac),nt(ne,Gi)),pe.mathMl===!0&&(nt(J,xc),nt(ne,og),nt(ne,Gi))),re.tagCheck=null,re.attributeCheck=null,Ot(F,"ADD_TAGS")&&(typeof F.ADD_TAGS=="function"?re.tagCheck=F.ADD_TAGS:cr(F.ADD_TAGS)&&(J===ce&&(J=hr(J)),nt(J,F.ADD_TAGS,Ct))),Ot(F,"ADD_ATTR")&&(typeof F.ADD_ATTR=="function"?re.attributeCheck=F.ADD_ATTR:cr(F.ADD_ATTR)&&(ne===G&&(ne=hr(ne)),nt(ne,F.ADD_ATTR,Ct))),Ot(F,"ADD_URI_SAFE_ATTR")&&cr(F.ADD_URI_SAFE_ATTR)&&nt(Xe,F.ADD_URI_SAFE_ATTR,Ct),Ot(F,"FORBID_CONTENTS")&&cr(F.FORBID_CONTENTS)&&(We===Pt&&(We=hr(We)),nt(We,F.FORBID_CONTENTS,Ct)),Ot(F,"ADD_FORBID_CONTENTS")&&cr(F.ADD_FORBID_CONTENTS)&&(We===Pt&&(We=hr(We)),nt(We,F.ADD_FORBID_CONTENTS,Ct)),Oe&&(J["#text"]=!0),ve&&nt(J,["html","head","body"]),J.table&&(nt(J,["tbody"]),delete Pe.tbody),F.TRUSTED_TYPES_POLICY){if(typeof F.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ri('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof F.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ri('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');k=F.TRUSTED_TYPES_POLICY,N=k.createHTML("")}else k===void 0&&(k=uk(g,o)),k!==null&&typeof N=="string"&&(N=k.createHTML(""));lr&&lr(F),Cr=F},er=nt({},[...wc,...Sc,...Z_]),sr=nt({},[...xc,...ek]),fn=function(F){let Y=E(F);(!Y||!Y.tagName)&&(Y={namespaceURI:ze,tagName:"template"});const he=us(F.tagName),st=us(Y.tagName);return pt[F.namespaceURI]?F.namespaceURI===St?Y.namespaceURI===xt?he==="svg":Y.namespaceURI===ft?he==="svg"&&(st==="annotation-xml"||Ut[st]):!!er[he]:F.namespaceURI===ft?Y.namespaceURI===xt?he==="math":Y.namespaceURI===St?he==="math"&&ur[st]:!!sr[he]:F.namespaceURI===xt?Y.namespaceURI===St&&!ur[st]||Y.namespaceURI===ft&&!Ut[st]?!1:!sr[he]&&(Ar[he]||!er[he]):!!(Vt==="application/xhtml+xml"&&pt[F.namespaceURI]):!1},yr=function(F){Co(t.removed,{element:F});try{E(F).removeChild(F)}catch{w(F)}},kt=function(F,Y){try{Co(t.removed,{attribute:Y.getAttributeNode(F),from:Y})}catch{Co(t.removed,{attribute:null,from:Y})}if(Y.removeAttribute(F),F==="is")if(Ge||Kt)try{yr(Y)}catch{}else try{Y.setAttribute(F,"")}catch{}},Ss=function(F){let Y=null,he=null;if(ct)F="<remove></remove>"+F;else{const wt=Jh(F,/^[\r\n\t ]+/);he=wt&&wt[0]}Vt==="application/xhtml+xml"&&ze===xt&&(F='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+F+"</body></html>");const st=k?k.createHTML(F):F;if(ze===xt)try{Y=new m().parseFromString(st,Vt)}catch{}if(!Y||!Y.documentElement){Y=A.createDocument(ze,"template",null);try{Y.documentElement.innerHTML=yt?N:st}catch{}}const Tt=Y.body||Y.documentElement;return F&&he&&Tt.insertBefore(r.createTextNode(he),Tt.childNodes[0]||null),ze===xt?W.call(Y,ve?"html":"body")[0]:ve?Y.documentElement:Tt},Nr=function(F){return I.call(F.ownerDocument||F,F,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Dr=function(F){F.normalize();const Y=I.call(F.ownerDocument||F,F,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let he=Y.nextNode();for(;he;){let st=he.data;Ao([j,M,D],Tt=>{st=Eo(st,Tt," ")}),he.data=st,he=Y.nextNode()}},_r=function(F){return F instanceof p&&(typeof F.nodeName!="string"||typeof F.textContent!="string"||typeof F.removeChild!="function"||!(F.attributes instanceof f)||typeof F.removeAttribute!="function"||typeof F.setAttribute!="function"||typeof F.namespaceURI!="string"||typeof F.insertBefore!="function"||typeof F.hasChildNodes!="function")},br=function(F){if(!P||typeof F!="object"||F===null)return!1;try{return typeof P(F)=="number"}catch{return!1}};function qt(Ee,F,Y){Ao(Ee,he=>{he.call(t,F,Y,Cr)})}const tr=function(F){let Y=null;if(qt(O.beforeSanitizeElements,F,null),_r(F))return yr(F),!0;const he=Ct(F.nodeName);if(qt(O.uponSanitizeElement,F,{tagName:he,allowedTags:J}),ae&&F.hasChildNodes()&&!br(F.firstElementChild)&&Zt(/<[/\w!]/g,F.innerHTML)&&Zt(/<[/\w!]/g,F.textContent)||ae&&F.namespaceURI===xt&&he==="style"&&br(F.firstElementChild)||F.nodeType===No.progressingInstruction||ae&&F.nodeType===No.comment&&Zt(/<[/\w]/g,F.data))return yr(F),!0;if(Pe[he]||!(re.tagCheck instanceof Function&&re.tagCheck(he))&&!J[he]){if(!Pe[he]&&Zi(he)&&(ee.tagNameCheck instanceof RegExp&&Zt(ee.tagNameCheck,he)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(he)))return!1;if(Oe&&!We[he]){const st=E(F)||F.parentNode,Tt=x(F)||F.childNodes;if(Tt&&st){const wt=Tt.length;for(let Mt=wt-1;Mt>=0;--Mt){const $r=y(Tt[Mt],!0);st.insertBefore($r,v(F))}}}return yr(F),!0}return F instanceof d&&!fn(F)||(he==="noscript"||he==="noembed"||he==="noframes")&&Zt(/<\/no(script|embed|frames)/i,F.innerHTML)?(yr(F),!0):(xe&&F.nodeType===No.text&&(Y=F.textContent,Ao([j,M,D],st=>{Y=Eo(Y,st," ")}),F.textContent!==Y&&(Co(t.removed,{element:F.cloneNode()}),F.textContent=Y)),qt(O.afterSanitizeElements,F,null),!1)},Br=function(F,Y,he){if(oe[Y]||q&&(Y==="id"||Y==="name")&&(he in r||he in Jn))return!1;const st=ne[Y]||re.attributeCheck instanceof Function&&re.attributeCheck(Y,F);if(!(de&&!oe[Y]&&Zt(L,Y))){if(!(be&&Zt(U,Y))){if(!st||oe[Y]){if(!(Zi(F)&&(ee.tagNameCheck instanceof RegExp&&Zt(ee.tagNameCheck,F)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(F))&&(ee.attributeNameCheck instanceof RegExp&&Zt(ee.attributeNameCheck,Y)||ee.attributeNameCheck instanceof Function&&ee.attributeNameCheck(Y,F))||Y==="is"&&ee.allowCustomizedBuiltInElements&&(ee.tagNameCheck instanceof RegExp&&Zt(ee.tagNameCheck,he)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(he))))return!1}else if(!Xe[Y]){if(!Zt(K,Eo(he,ie,""))){if(!((Y==="src"||Y==="xlink:href"||Y==="href")&&F!=="script"&&Qh(he,"data:")===0&&je[F])){if(!(ot&&!Zt($,Eo(he,ie,"")))){if(he)return!1}}}}}}return!0},Qi=nt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Zi=function(F){return!Qi[us(F)]&&Zt(V,F)},ea=function(F){qt(O.beforeSanitizeAttributes,F,null);const Y=F.attributes;if(!Y||_r(F))return;const he={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let st=Y.length;for(;st--;){const Tt=Y[st],wt=Tt.name,Mt=Tt.namespaceURI,$r=Tt.value,ir=Ct(wt),Oo=$r;let Lt=wt==="value"?Oo:G_(Oo);if(he.attrName=ir,he.attrValue=Lt,he.keepAttr=!0,he.forceKeepAttr=void 0,qt(O.uponSanitizeAttribute,F,he),Lt=he.attrValue,$e&&(ir==="id"||ir==="name")&&Qh(Lt,gt)!==0&&(kt(wt,F),Lt=gt+Lt),ae&&Zt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Lt)){kt(wt,F);continue}if(ir==="attributename"&&Jh(Lt,"href")){kt(wt,F);continue}if(he.forceKeepAttr)continue;if(!he.keepAttr){kt(wt,F);continue}if(!Se&&Zt(/\/>/i,Lt)){kt(wt,F);continue}xe&&Ao([j,M,D],et=>{Lt=Eo(Lt,et," ")});const ta=Ct(F.nodeName);if(!Br(ta,ir,Lt)){kt(wt,F);continue}if(k&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!Mt)switch(g.getAttributeType(ta,ir)){case"TrustedHTML":{Lt=k.createHTML(Lt);break}case"TrustedScriptURL":{Lt=k.createScriptURL(Lt);break}}if(Lt!==Oo)try{Mt?F.setAttributeNS(Mt,wt,Lt):F.setAttribute(wt,Lt),_r(F)?yr(F):Xh(t.removed)}catch{kt(wt,F)}}qt(O.afterSanitizeAttributes,F,null)},xs=function(F){let Y=null;const he=Nr(F);for(qt(O.beforeSanitizeShadowDOM,F,null);Y=he.nextNode();)qt(O.uponSanitizeShadowNode,Y,null),tr(Y),ea(Y),Y.content instanceof s&&xs(Y.content);qt(O.afterSanitizeShadowDOM,F,null)},kr=function(F){if(F.nodeType===No.element&&F.shadowRoot instanceof s){const st=F.shadowRoot;kr(st),xs(st)}const Y=F.childNodes;if(!Y)return;const he=[];Ao(Y,st=>{Co(he,st)});for(const st of he)kr(st)};return t.sanitize=function(Ee){let F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Y=null,he=null,st=null,Tt=null;if(yt=!Ee,yt&&(Ee="<!-->"),typeof Ee!="string"&&!br(Ee)&&(Ee=J_(Ee),typeof Ee!="string"))throw Ri("dirty is not a string, aborting");if(!t.isSupported)return Ee;if(Ye||Er(F),t.removed=[],typeof Ee=="string"&&(te=!1),te){const $r=Ee.nodeName;if(typeof $r=="string"){const ir=Ct($r);if(!J[ir]||Pe[ir])throw Ri("root node is forbidden and cannot be sanitized in-place")}kr(Ee)}else if(br(Ee))Y=Ss("<!---->"),he=Y.ownerDocument.importNode(Ee,!0),he.nodeType===No.element&&he.nodeName==="BODY"||he.nodeName==="HTML"?Y=he:Y.appendChild(he),kr(he);else{if(!Ge&&!xe&&!ve&&Ee.indexOf("<")===-1)return k&&Je?k.createHTML(Ee):Ee;if(Y=Ss(Ee),!Y)return Ge?null:Je?N:""}Y&&ct&&yr(Y.firstChild);const wt=Nr(te?Ee:Y);for(;st=wt.nextNode();)tr(st),ea(st),st.content instanceof s&&xs(st.content);if(te)return xe&&Dr(Ee),Ee;if(Ge){if(xe&&Dr(Y),Kt)for(Tt=T.call(Y.ownerDocument);Y.firstChild;)Tt.appendChild(Y.firstChild);else Tt=Y;return(ne.shadowroot||ne.shadowrootmode)&&(Tt=X.call(n,Tt,!0)),Tt}let Mt=ve?Y.outerHTML:Y.innerHTML;return ve&&J["!doctype"]&&Y.ownerDocument&&Y.ownerDocument.doctype&&Y.ownerDocument.doctype.name&&Zt(lk,Y.ownerDocument.doctype.name)&&(Mt="<!DOCTYPE "+Y.ownerDocument.doctype.name+`>
|
|
52
|
-
`+Mt),xe&&Ao([j,M,D],$r=>{Mt=Eo(Mt,$r," ")}),k&&Je?k.createHTML(Mt):Mt},t.setConfig=function(){let Ee=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Er(Ee),Ye=!0},t.clearConfig=function(){Cr=null,Ye=!1},t.isValidAttribute=function(Ee,F,Y){Cr||Er({});const he=Ct(Ee),st=Ct(F);return Br(he,st,Y)},t.addHook=function(Ee,F){typeof F=="function"&&Co(O[Ee],F)},t.removeHook=function(Ee,F){if(F!==void 0){const Y=W_(O[Ee],F);return Y===-1?void 0:R_(O[Ee],Y,1)[0]}return Xh(O[Ee])},t.removeHooks=function(Ee){O[Ee]=[]},t.removeAllHooks=function(){O=ig()},t}var fk=ag();const pk=["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"],mk=["href","target","rel","src","alt","title","class","style","colspan","rowspan"];function hk(e){return e?fk.sanitize(e,{ALLOWED_TAGS:[...pk],ALLOWED_ATTR:[...mk],ALLOW_DATA_ATTR:!1}):""}function gk(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=Qe(t,s);return i==null?r?"":n:String(i)}):e}function yk(e){return e&&e.replace(/\{api:[^}]*\}/gi,"").replace(/\{labelapi:[^}]*\}/gi,"").replace(/\{resp:[^}]*\}/gi,"").replace(/\{(?:ctx:|@)\w+\}/gi,"").replace(/\{documentId\}/gi,"").replace(/\{(\w+)\}/g,"")}const lg={sm:"text-sm",md:"text-base",lg:"text-lg"},cg={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"},dg={normal:"font-normal",medium:"font-medium",bold:"font-bold"},Ki={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"};function qn(e){return e.properties??{}}function bk(e){const t=qn(e);return t.textContent!==void 0?t.textContent:e.label??""}function vk(e){return qn(e).textContent===void 0||e.appearance?.hideLabel?!1:!!e.label?.trim()}function wk(e){return e?.contentLayout==="paragraph"?"paragraph":"single"}function Cc(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:a}=t,d=rn(e,r,n,o,s,i),u=gk(d,a,!0);return yk(u)}const Sk=/\{api:[^}]+\}/,xk=/\{labelapi:[^}]+\}/;function Ec(e){return Sk.test(e)}function Nc(e){return xk.test(e)}function Ak(e){const t=e.captionTemplate??"",r=e.descriptionTemplate??"",n=Ec(e.bodyTemplate)||Ec(t)||Ec(r),o=Nc(e.bodyTemplate)||Nc(t)||Nc(r);return!!(n&&e.prepopulateLoading||o&&e.labelApiConfigPresent&&(e.labelApiLoading||e.labelApiResponse===void 0&&e.labelApiError==null))}function ug(e,t){const r=t??qn(e),n=r.variant??"body",o=e.appearance?.size??"md",s=lg[o]??lg.md,i=r.fontWeight??"medium";return n!=="body"?B("m-0 text-foreground",cg[n]??cg.h3,r.fontWeight&&dg[r.fontWeight],r.italic&&"italic",r.underline&&"underline",r.textAlign&&Ki[r.textAlign]):B("m-0 text-foreground",s,dg[i],r.italic&&"italic",r.underline&&"underline",r.textAlign&&Ki[r.textAlign])}function Ck(e,t){const r=(t??qn(e)).variant??"body";return r==="body"?"p":r}function _c(e){const t=[];let r=0,n="";const o=()=>{n&&(t.push({type:"text",value:n}),n="")},s=(i,a,d)=>{if(!e.startsWith(i,r))return!1;const u=e.indexOf(a,r+i.length);if(u===-1)return!1;o();const l=e.slice(r+i.length,u);return t.push({type:d,children:_c(l)}),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 Ek(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function fg(e){return e.map(t=>{if(t.type==="text")return Ek(t.value);const r=fg(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 Nk(e){return e?fg(_c(e)):""}function _k(e,t){return e?t==="markdown-lite"?Nk(e):e:""}function pg(e,t){return e.map((r,n)=>{const o=`${t}-${n}`;if(r.type==="text")return r.value?S.createElement(S.Fragment,{key:o},r.value):null;const s=pg(r.children,o);return r.type==="bold"?S.createElement("strong",{key:o,className:"font-bold"},s):r.type==="italic"?S.createElement("em",{key:o,className:"italic"},s):S.createElement("u",{key:o,className:"underline"},s)})}function mg(e,t){if(!e)return null;if(t!=="markdown-lite")return e;const r=_c(e);return r.length===1&&r[0]?.type==="text"?r[0].value:pg(r,"tl")}const kk="text-label-html prose prose-sm max-w-none [&_p]:m-0 [&_p+p]:mt-2 [&_ul]:my-1 [&_ol]:my-1";function hg(e,t){if(!e)return null;const{field:r,asDescription:n=!1}=t,o=t.textProps??qn(r),s=t.contentLayout??wk(o),i=o.inlineFormat??"none";if(s==="paragraph"){const d=hk(_k(e,i));if(!d)return null;const u=n?B("m-0 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&Ki[o.textAlign]):B(ug(r,o),kk);return S.createElement("div",{className:u,dangerouslySetInnerHTML:{__html:d}})}if(n)return S.createElement("p",{className:B("mt-0.5 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&Ki[o.textAlign])},mg(e,i));const a=Ck(r,o);return S.createElement(a,{className:ug(r,o)},mg(e,i))}function Tk(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 Fk(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o}=t,s=f=>rn(f,r,n,o),i=(e.labelApiMethod??"GET").toUpperCase();let a=cn(s(e.labelApiEndpoint));const d=e.labelApiQueryParams??[];if(d.length){const f=new URLSearchParams;d.forEach(({key:m,value:g})=>{m.trim()&&f.append(m,s(g))});const p=f.toString();p&&(a=`${a}${a.includes("?")?"&":"?"}${p}`)}const u={"Content-Type":"application/json"};(e.labelApiHeaders??[]).forEach(({key:f,value:p})=>{f.trim()&&(u[f]=s(p))});let l;i==="POST"&&(e.labelApiBodyFields??[]).length&&(l={},e.labelApiBodyFields.forEach(({key:f,value:p})=>{f.trim()&&(l[f]=s(p))}));try{return i==="POST"?(await dn.post(a,l??{},{headers:Object.keys(u).length?u:void 0})).data:(await dn.get(a,{headers:Object.keys(u).length?u:void 0})).data}catch(f){const p=f,m=p.response?.status,g=typeof p.response?.data=="string"?p.response.data:p.message??"Request failed";throw new Error(m?`HTTP ${m}: ${g}`:String(g))}}const Pk=({field:e,className:t,formValues:r,urlParams:n,submissionContext:o,buttonResponses:s,prepopulateResponse:i,prepopulateLoading:a=!1})=>{const d=qn(e),u=S.useMemo(()=>Tk(qn(e)),[e.properties]),[l,f]=S.useState(void 0),[p,m]=S.useState(!1),[g,h]=S.useState(null),y=S.useMemo(()=>u?JSON.stringify({endpoint:u.labelApiEndpoint,method:u.labelApiMethod,query:u.labelApiQueryParams,headers:u.labelApiHeaders,body:u.labelApiBodyFields}):"",[u]),w=S.useCallback(async()=>{if(!u){f(void 0),h(null),m(!1);return}m(!0),h(null);try{const W=await Fk(u,{formValues:r??{},urlParams:n??{},submissionContext:o});f(W)}catch(W){f(void 0),h(W instanceof Error?W.message:"Failed to load label API")}finally{m(!1)}},[u,r,n,o]);S.useEffect(()=>{y&&w()},[y,w]);const v=d.textAlign==="center"?"items-center":d.textAlign==="right"?"items-end":d.textAlign==="justify"?"items-stretch":"items-start",x=bk(e),E=vk(e),P=E&&e.label?e.label:"",k=e.description??"",N=Ak({bodyTemplate:x,captionTemplate:P,descriptionTemplate:k,prepopulateLoading:a,labelApiConfigPresent:u!=null,labelApiLoading:p,labelApiResponse:l,labelApiError:g}),C={formValues:r??{},urlParams:n??{},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:l},A=x?Cc(x,C):"",I=E&&e.label?Cc(e.label,C):"",T=k?Cc(k,C):"";return c.jsx("div",{className:B("w-full min-w-0 h-full min-h-[95px] flex flex-col justify-center py-0.5",v,t),children:N?c.jsx("p",{className:"text-sm text-muted-foreground m-0",children:"Loading…"}):c.jsxs(c.Fragment,{children:[g&&u?c.jsx("p",{className:"text-[10px] text-destructive mb-0.5",title:g,children:"Label API failed"}):null,I?c.jsx("div",{className:"text-sm font-medium text-foreground mb-1 w-full",children:I}):null,A?hg(A,{field:e,textProps:d}):null,T?hg(T,{field:e,textProps:d,asDescription:!0}):null]})})},kc=({legend:e,children:t,className:r,collapsible:n=!1,defaultCollapsed:o=!1,headerActions:s,onCollapsedChange:i})=>{const[a,d]=S.useState(o),u=S.useId(),l=f=>{f.stopPropagation(),n&&d(p=>{const m=!p;return i?.(m),m})};return c.jsxs("fieldset",{className:B("min-w-0 rounded-lg border bg-card p-4",r),"data-form-renderer":"config-section-border",children:[n?c.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2 border-b border-border pb-2",children:[c.jsxs("button",{type:"button",className:B("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:l,children:[c.jsx("span",{className:"shrink-0 text-muted-foreground","aria-hidden":!0,children:a?c.jsx(Zd,{className:"h-4 w-4"}):c.jsx(Wo,{className:"h-4 w-4"})}),c.jsx("span",{className:"truncate",children:e})]}),s!=null?c.jsx("div",{className:"shrink-0",children:s}):null]}):c.jsx("legend",{className:"px-1 text-sm font-medium text-foreground",children:e}),!a&&c.jsxs("div",{id:u,className:"space-y-3",children:[!n&&s!=null?c.jsx("div",{className:"flex justify-end",children:s}):null,t]})]})},un=({field:e,value:t,error:r,onChange:n,onBlur:o,disabled:s,readOnly:i,isRequired:a,className:d,formValues:u={},submissionContext:l,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:w,buttonResponses:v,onButtonApiResponse:x,onValidateForm:E,getValidationErrors:P,allFields:k,onSubmittingChange:N,onAddMore:C,scopedFormValues:A,scopedFieldNameMap:I,excludedOptionValues:T,prepopulateMappedFieldNames:W,fieldValueKey:X,hideTableRowControls:O=!1,urlParams:j={},prepopulateResponse:M=null,prepopulateLoading:D=!1,formSections:L,submitPayload:U})=>{switch(e.type){case"divider":return c.jsx(T_,{field:e,className:d});case"header":return c.jsx(P_,{field:e,className:d});case"sectionHeading":return c.jsx(M_,{field:e,className:d});case"spacer":return c.jsx(L_,{field:e,className:d});case"textLabel":return c.jsx(Pk,{field:e,className:d,formValues:u,urlParams:j,submissionContext:l,buttonResponses:v,prepopulateResponse:M??void 0,prepopulateLoading:D});case"status":return c.jsx(w_,{field:e,value:t??null,error:r,disabled:s,isRequired:a,className:d,formValues:u,submissionContext:l,extraSubmitPayload:w,prepopulateResponse:M})}switch(e.type){case"text":case"password":case"url":return c.jsx(Da,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"number":return c.jsx(Xd,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"email":return c.jsx(su,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"phone":case"aadhaar":return c.jsx(iu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"textarea":case"richtext":return c.jsx(au,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"select":{const $=X??e.name??e.key??e.id,ie=!!($&&W?.has($));return c.jsx(kp,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,formValues:u,submissionContext:l,excludedOptionValues:T,isPrepopulateTarget:ie})}case"multiselect":{const $=Array.isArray(t)?t:t!=null&&t!==""?[String(t)]:[];return c.jsx(vm,{field:e,value:$,onChange:ie=>n(ie),onBlur:o,error:r,disabled:s,isRequired:a,className:d,formValues:u,submissionContext:l,excludedOptionValues:T})}case"asyncsearch":return c.jsx(Xp,{field:e,value:t,onChange:$=>n($),onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d,formValues:u,submissionContext:l});case"checkbox":case"terms":return c.jsx(wm,{field:e,value:t||!1,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d});case"toggle":return c.jsx(tE,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d});case"radio":case"checkboxgroup":return c.jsx(Gm,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,excludedOptionValues:T});case"selectablelist":{const $=Array.isArray(t)?t:[];return console.log("[SelectableList] FieldRenderer: passing to SelectableListField",{fieldName:e.name,value:$,valueLength:$.length,submissionContextKeys:l?Object.keys(l):[]}),c.jsx(x_,{field:e,value:$,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,submissionContext:l})}case"date":case"time":case"datetime":case"daterange":return c.jsx(Km,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"file":return c.jsx(NE,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,buttonResponses:v});case"camera":return c.jsx(oN,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d});case"photoChoice":return c.jsx(sN,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,buttonResponses:v});case"signature":return c.jsx(QN,{field:e,value:t||null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"rating":return c.jsx(FN,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"slider":return c.jsx(JN,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"table":return c.jsx(ZN,{field:e,value:t||[],onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d,hideRowControls:O,formValues:u,submissionContext:l});case"billingGrid":return c.jsx(v_,{field:e,value:t||{rows:[]},onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"button":return c.jsx(wN,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,formValues:u,submissionContext:l,buttonResponses:v,onButtonApiResponse:x,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:w,onValidateForm:E,getValidationErrors:P,allFields:k,onSubmittingChange:N,scopedFormValues:A,scopedFieldNameMap:I,prepopulateResponse:M,formSections:L,submitPayload:U});case"editButton":return c.jsx(SN,{field:e,disabled:s,readOnly:i,isRequired:a,className:d,buttonResponses:v,onButtonApiResponse:x});case"addmore":return c.jsx(xN,{field:e,error:r,disabled:s,readOnly:i,isRequired:a,className:d,onAddMore:()=>C?.(e)});case"customizeSections":return c.jsx(TN,{field:e,error:r,disabled:s,readOnly:i,isRequired:a,className:d});default:return c.jsx("div",{className:"p-3 border rounded-md bg-muted/50",children:c.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unsupported field type: ",e.type]})})}},Ok=({steps:e,currentStep:t,completedSteps:r,onStepClick:n,className:o})=>c.jsx("div",{className:B("mb-8",o),children:c.jsx("nav",{"aria-label":"Progress",children:c.jsx("ol",{className:"flex items-center",children:e.map((s,i)=>{const a=r.has(i),d=t===i,u=n&&(a||i===t+1||i<=t);return c.jsxs("li",{className:B("relative",i!==e.length-1&&"pr-8 sm:pr-20 flex-1"),children:[i!==e.length-1&&c.jsx("div",{className:B("absolute top-4 left-8 -right-8 sm:left-12 sm:-right-12 h-0.5",a?"bg-primary":"bg-border"),"aria-hidden":"true"}),c.jsx("button",{type:"button",onClick:()=>u&&n?.(i),disabled:!u,className:B("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",d&&!a&&"border-2 border-primary text-primary",!a&&!d&&"border-2 border-border text-muted-foreground",u&&"cursor-pointer hover:bg-primary/10",!u&&"cursor-default"),"aria-current":d?"step":void 0,children:a?c.jsx(Vs,{className:"h-4 w-4"}):c.jsx("span",{children:i+1})}),c.jsxs("div",{className:"mt-2",children:[c.jsx("span",{className:B("text-sm font-medium",d&&"text-primary",!d&&!a&&"text-muted-foreground"),children:s.name}),s.description&&c.jsx("p",{className:"text-xs text-muted-foreground hidden sm:block",children:s.description})]})]},s.id)})})})});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 gg(e){return Array.isArray(e)?e.map(ps):[]}function Ik(e){if(!e.moduleId)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 t;typeof e.moduleId=="object"&&e.moduleId._id?t=ps(e.moduleId):t=e.moduleId;const r=e.isDefault??!1;if(!r&&!e.tenantId)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:r,moduleId:t,tenantId:e.tenantId||void 0,featureId:e.featureId,config:e.config??void 0}}class Mk{basePath="/api/form-builder/forms";async getForRendering(t,r){if(!Tn())throw new Error("Client ID is required");const o=r!==void 0?`${this.basePath}/${t}/render?version=${r}`:`${this.basePath}/${t}/render`,s=await dn.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,d=i.form||i;if(!d.moduleId&&!i.form?.moduleId)throw new Error(`Form response missing required field: moduleId. Form ID: ${t}. Please ensure the backend returns moduleId in the form response.`);if(!(d.isDefault??i.form?.isDefault??!1)&&!d.tenantId&&!i.form?.tenantId)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&&!d.moduleId&&(d.moduleId=i.form.moduleId),i.form?.tenantId&&!d.tenantId&&(d.tenantId=i.form.tenantId),i.form?.isDefault!==void 0&&d.isDefault===void 0&&(d.isDefault=i.form.isDefault);const l=Ik(d);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 f=gg(i.fields||[]),p=i.layout?ps(i.layout):null,m=gg(i.rules||[]),g=i.module?ps(i.module):void 0,h=i.clientMapping||i.clientOverrides;return{form:l,fields:f,layout:p,rules:m,module:g,clientMapping:h,clientOverrides:h,BFF_submit_api:a||void 0}}}const Lk=new Mk;function Pn({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=c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:B("animate-spin rounded-full border-b-2 border-blue-600 mx-auto mb-4",o[t],e)}),r&&c.jsx("p",{className:"text-gray-600",children:r})]});return n?c.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}const Dk={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."},Bk=300;function $k(){return{...Dk}}function jk(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 zk(e){const t=$k();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:hN(r.sections),submitPayload:mN(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 ms(e,t,r,n){const o=t.map(l=>{let f=[],p={};try{l.options&&(f=JSON.parse(l.options)),l.metadata&&(p=JSON.parse(l.metadata))}catch{}const m=jd(l);m&&Object.assign(p,m),f.length>0&&(p.options=f);const g=[];if(l.validationRequired&&g.push({type:"required",message:"This field is required"}),l.validationMinLength!==null&&l.validationMinLength!==void 0&&g.push({type:"minLength",value:l.validationMinLength,message:`Minimum length is ${l.validationMinLength}`}),l.validationMaxLength!==null&&l.validationMaxLength!==void 0&&g.push({type:"maxLength",value:l.validationMaxLength,message:`Maximum length is ${l.validationMaxLength}`}),l.validationPattern&&g.push({type:"pattern",value:l.validationPattern,message:"Invalid format"}),l.validationRules&&typeof l.validationRules=="object"){const V=l.validationRules;if(V.required===!0&&!g.some(K=>K.type==="required")&&g.push({type:"required",message:"This field is required"}),V.allowLetters!==void 0&&g.push({type:"allowLetters",value:V.allowLetters}),V.allowNumbers!==void 0&&g.push({type:"allowNumbers",value:V.allowNumbers}),V.allowSpecialChars!==void 0&&g.push({type:"allowSpecialChars",value:V.allowSpecialChars}),V.minLetters!==void 0&&typeof V.minLetters=="number"&&g.push({type:"minLetters",value:V.minLetters}),V.maxLetters!==void 0&&typeof V.maxLetters=="number"&&g.push({type:"maxLetters",value:V.maxLetters}),V.minNumbers!==void 0&&typeof V.minNumbers=="number"&&g.push({type:"minNumbers",value:V.minNumbers}),V.maxNumbers!==void 0&&typeof V.maxNumbers=="number"&&g.push({type:"maxNumbers",value:V.maxNumbers}),V.minSpecialChars!==void 0&&typeof V.minSpecialChars=="number"&&g.push({type:"minSpecialChars",value:V.minSpecialChars}),V.maxSpecialChars!==void 0&&typeof V.maxSpecialChars=="number"&&g.push({type:"maxSpecialChars",value:V.maxSpecialChars}),V.fileSize!==void 0&&typeof V.fileSize=="number"){const K=V.fileSize/1048576;g.push({type:"fileSize",value:V.fileSize,message:`File size must be less than ${K.toFixed(2)} MB`})}if(V.fileType!==void 0){const K=Array.isArray(V.fileType)?V.fileType:typeof V.fileType=="string"?V.fileType.split(",").map(J=>J.trim()).filter(Boolean):[];K.length>0&&g.push({type:"fileType",value:K,message:"File type is not allowed"})}}const h=[],y=new Set;n.filter(V=>{const K=typeof V.targetFieldId=="object"?V.targetFieldId.id||V.targetFieldId._id:V.targetFieldId;return!!(K===l.id||K===l._id||K&&l.fieldKey&&K===l.fieldKey)}).forEach(V=>{try{const K=JSON.parse(V.conditionExpression);!K.id&&V.id&&(K.id=V.id);const J=typeof V.targetFieldId=="object"?V.targetFieldId?.id||V.targetFieldId?._id:V.targetFieldId;K.action&&(!K.then||!Array.isArray(K.then)||K.then.length===0)&&(K.then=[{action:K.action,...J&&{target:J}}]),(!K.then||!Array.isArray(K.then)||K.then.length===0)&&V.action&&(K.then=[{action:V.action,...J&&{target:J}}]),K.then&&Array.isArray(K.then)&&J&&(K.then=K.then.map(ne=>!ne.target&&J?{...ne,target:J}:ne));const ce=V.conditionExpression||JSON.stringify(K);if(y.has(ce))return;y.add(ce),h.push(K)}catch{}});const v=l.disabled===!0||p?.disabled===!0||!1;let x=l.readOnly===!0||p?.readOnly===!0||!1;const E=l.hidden===!0||p?.hidden===!0||!1;(p?.valueSource==="calculated"||p?.formula)&&(x=!0);const{disabled:P,readOnly:k,hidden:N,...C}=p,A={};C.hideLabel!==void 0&&(A.hideLabel=C.hideLabel),C.labelPosition!==void 0&&(A.labelPlacement=C.labelPosition),C.size!==void 0&&(A.size=C.size),C.customClass!==void 0&&(A.className=C.customClass);const{labelPosition:I,size:T,customClass:W,visibility:X,...O}=C,j=Object.keys(O).length>0?O:void 0,M=Object.keys(A).length>0?A:void 0,D=l.visibility??p?.visibility??X;let L=jk(D);if(D&&!L){const V=D;(V.visibleToUserType!=null||V.visibleToUserRole!=null||Array.isArray(V.visibleToUserTypes)&&V.visibleToUserTypes.length>0||Array.isArray(V.visibleToUserRoles)&&V.visibleToUserRoles.length>0||Array.isArray(V.visibleToUserIds)&&V.visibleToUserIds.length>0||Array.isArray(V.hiddenFromUserIds)&&V.hiddenFromUserIds.length>0)&&(L={visibleToUserType:V.visibleToUserType??(Array.isArray(V.visibleToUserTypes)?V.visibleToUserTypes[0]:void 0),visibleToUserRole:V.visibleToUserRole??(Array.isArray(V.visibleToUserRoles)?V.visibleToUserRoles[0]:void 0),visibleToUserIds:V.visibleToUserIds,hiddenFromUserIds:V.hiddenFromUserIds})}const U=p?.columnName,ie=!!l.parentFieldId&&typeof U=="string"?U: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:M,validation:g.length>0?g:void 0,conditions:h.length>0?h:void 0,properties:j,visibility:L&&(L.visibleToUserType!=null||L.visibleToUserRole!=null||Array.isArray(L.visibleToUserIds)&&L.visibleToUserIds.length>0||Array.isArray(L.hiddenFromUserIds)&&L.hiddenFromUserIds.length>0)?L:void 0,disabled:v,readOnly:x,hidden:E}});o.forEach((l,f)=>{if(l.visibility){const p=t[f];console.log("[backendToFormSchema] field with visibility",{fieldKey:p?.fieldKey??l.name,name:l.name,type:l.type,parentFieldId:p?.parentFieldId,visibility:l.visibility})}});const s=t;for(let l=0;l<o.length;l++){const f=s[l]?.parentFieldId;if(f){const p=o.find(g=>g.id===f||g.type==="table"&&g.name===f||g.type==="table"&&s[l].fieldKey?.startsWith?.(g.name+"_column_")),m=o[l];if(p&&p.type==="table"&&m){const g=p.properties||{};Array.isArray(g.columns)||(g.columns=[]),g.columns.push(m),p.properties=g}}}const i=o.filter((l,f)=>!s[f]?.parentFieldId);for(const l of i)if(l.type==="table"&&l.properties&&Array.isArray(l.properties.columns)){const f=l.properties.columns;for(const p of f){const m=p.properties?.columnName;typeof m=="string"&&(p.name=m)}f.sort((p,m)=>(p.position?.order??0)-(m.position?.order??0)||(p.position?.column??0)-(m.position?.column??0))}let a;const d=e.config;if(console.log("[Prepopulate] backendToFormSchema config",{formId:e.id,hasRawConfig:d!=null,rawConfigType:typeof d,rawConfigPreview:d!=null?typeof d=="string"?d.slice(0,300):JSON.stringify(d).slice(0,300):null}),d!=null)try{const l=typeof d=="string"?JSON.parse(d):d;l&&typeof l=="object"?a=zk(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=Ns(r);return u&&(a={...a,grid:u}),{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,moduleId:typeof e.moduleId=="string"?e.moduleId:e.moduleId?.id,tenantId:e.tenantId,featureId:e.featureId,isDefault:e.isDefault}}const Uk=3;function _o(e){if(typeof e=="number"&&!Number.isNaN(e))return e}function ko(e,t){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;return _o(r?.cellSlot)??_o(r?.stackSlot)??_o(r?.cellSlotIndex)??_o(r?.slotIndex)??_o(t?.cellSlotIndex)??_o(t?.stackSlot)}function hs(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 qi(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 Tc(e){return[...e].sort((t,r)=>{const n=ko(t.position),o=ko(r.position);return typeof n=="number"&&typeof o=="number"&&n!==o?n-o:String(t.id).localeCompare(String(r.id))})}function gs(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,Do(o)),n=Math.max(n,bd(o,t));return{rowSpan:r,columnSpan:n}}function yg(e){const t=Tc(e);for(const r of t){const n=hs(r.position);if(n)return n}return t.length>=2?"row":"stack"}function bg(e){return Tc(e).slice(0,Uk)}function Vk(e,t){const r=new Map;for(const n of e){if(!t(n)||typeof n.position?.order!="number")continue;const o=qi(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 d=qi(a),u=s.get(d)??[];u.push(a),s.set(d,u)}const i=[...s.values()][0]??[];return bg(i)}function Hk(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:d}=gs(r,n),u=e===s&&t===i-1,l=e>=s&&e<s+a,f=t>=i-1&&t<i-1+d;return l&&f&&!u}function Wk(e,t,r){const n=new Set(r??[]);for(const o of e){const s=o[0]?.position?.order??0,{rowSpan:i}=gs(o,t);for(let a=s;a<s+i;a++)n.add(a)}return n}function Rk(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 Gk(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 gr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function To(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>To(r));if(!gr(e))return e;const t={};for(const[r,n]of Object.entries(e))t[r]=To(n);return t}function wg(e,...t){const r={...e};for(const n of t)if(!(!n||!gr(n)))for(const[o,s]of Object.entries(n)){const i=r[o];gr(s)&&gr(i)?r[o]=wg(i,s):r[o]=s}return r}function Yn(e){return gr(e)?e:{}}function ys(e){if(e==null)return{};if(typeof e=="string"){const t=e.trim();if(!t)return{};try{const r=JSON.parse(t);return gr(r)?To(r):{}}catch{return{}}}return gr(e)?To(e):{}}function Sg(e){const t=e.apidata;return gr(t)&&Object.keys(t).length>0}function Kk(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 qk(e,t){const r=e.appearance,n=gr(r)&&Object.keys(r).length>0?To(r):{},o=Yn(t.appearance),s={...n};for(const[i,a]of Object.entries(o))i!=="heightPercent"&&s[i]===void 0&&(s[i]=To(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 Yk(e,t){const r=Yn(e.position),n=ys(e.metadata),o=Yn(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,d=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:d},l=r.cellGroupId??o.cellGroupId,f=ko(r,{cellSlotIndex:e.cellSlotIndex??o.cellSlotIndex,stackSlot:n.stackSlot??o.stackSlot}),p=hs(r)??hs(o)??(n.stackDirection==="horizontal"||o.stackDirection==="horizontal"?"row":n.stackDirection==="vertical"||o.stackDirection==="vertical"?"stack":void 0);return typeof l=="string"&&(u.cellGroupId=l),typeof f=="number"&&(u.cellSlot=f),(p==="row"||p==="stack")&&(u.sharedCellLayout=p),u}function Xk(e,t){const r=e,n=ys(r.metadata),o=Yn(r.apidata),s=Yn(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),d=(r.type!=null&&String(r.type).trim()!==""?r.type:void 0)??(typeof r.fieldType=="string"?r.fieldType:void 0),u=qk(r,n),l=Yk(r,t),f={...r};return f.properties=i,a!==void 0&&(f.name=a),d!==void 0&&(f.type=d),u!==void 0?f.appearance=u:(!gr(r.appearance)||Object.keys(r.appearance).length===0)&&delete f.appearance,f.position=l,gr(f.appearance)&&delete f.appearance.heightPercent,f}function Jk(e,t){if(!e||typeof e!="object")return!0;const r=e,n=ys(r.metadata),o=Object.keys(n).length===0&&!(typeof r.metadata=="string"&&r.metadata.trim()!==""),s=!Sg(r);if(Kk(r)||!o||!s)return!1;const i=r.position;return!(!(gr(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")||gr(n.appearance)||xg.some(u=>n[u]!==void 0&&(r.appearance==null||gr(r.appearance)&&r.appearance[u]===void 0))||Qk(r))}function Qk(e){const t=Yn(e.position),r=Yn(e.layout),n=ys(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 Yi(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(Jk(o))return o;const i=Xk(o,s);return i!==o&&(r=!0),i});return r?{...e,fields:n}:e}function Zk(e){return Yi(e)}const eT=new Set(["PENDING_PAYMENT","PAYMENT_PENDING","AWAITING_PAYMENT","PAID","PAYMENT_COMPLETED","PAYMENT_FAILED","REFUNDED","AUTHORIZED","CAPTURED","PARTIALLY_PAID"].map(e=>e.toUpperCase()));function Fc(e){return typeof e=="string"&&e.trim()!==""}function Pc(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"||Fc(t.amount)||typeof t.total_amount=="number"||Fc(t.total_amount)||Fc(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"&&eT.has(r.trim().toUpperCase()))}function tT(e){const t=Qe(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 rT(e,t){const r=tT(e);if(!r)return;const n=Qe(e,"data"),o=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(t?.treatFirstItemIdAsPaymentId===!0||Pc(r.item)||o!=null&&Pc(o))return r.id}function nT(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 oT(e){return nT(e).some(t=>t.toLowerCase().includes("payment"))}function sT(e){const t=e.properties,r=e.metadata;return!!(t?.mergeSuccessDataIdAsPaymentId||r?.mergeSuccessDataIdAsPaymentId)}function iT(e,t){if(t?.type!=="button"||!Uo(e))return;const r=Qe(e,"data.id");if(r==null||String(r).trim()==="")return;const n=Qe(e,"data");if(sT(t)||n!=null&&typeof n=="object"&&!Array.isArray(n)&&Pc(n)||oT(t))return r}const aT=new Set(["section","group","columns","divider","header","sectionHeading","spacer","addmore","textLabel","customizeSections"]);function lT(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 cT(e,t){const r=e.properties,n=Array.isArray(r?.linkedFieldNames)?r.linkedFieldNames:[],o=lT(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 Ag(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 dT(e,t){return Ag(e,t).find(r=>r.heading?.enabled)}function Cg(e,t){const r=e.template??"";return(e.mode??"increment")==="fixed"?r:r.replace(/\{n\}/g,String(t+1))}function Eg(e,t,r,n){const o=cT(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||aT.has(i.type)?!1:s.has(a)})}function uT(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 Oc(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 fT(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 d=Oc(a).map(u=>r(u)).filter(Boolean);s.push({section:i,fieldNames:d})}return s}function bs(e,t=0){return e.heading?.enabled?Cg(e.heading,t):e.name}function Ng(e,t,r){if(e.type!=="sectionHeading")return!1;const n=t.heading;return!n?.enabled||!n.headingFieldName?!1:r(e)===n.headingFieldName}function pT(e,t){const r=typeof e.position?.order=="number"?e.position.order:0,n=(e.position?.column??1)-1,o=Do(e),s=bd(e,t);return{row:r,col:n,rowEnd:r+o-1,colEnd:n+s-1}}function Ic(e,t){let r=1/0,n=-1/0,o=1/0,s=-1/0;for(const i of e){const{row:a,col:d,rowEnd:u,colEnd:l}=pT(i,t);r=Math.min(r,a),n=Math.max(n,u),o=Math.min(o,d),s=Math.max(s,l)}return Number.isFinite(r)?{minRow:r,maxRow:n,minCol:o,maxCol:s,rowSpan:n-r+1,colSpan:s-o+1}:null}function mT(e,t,r,n){const o=e.map(l=>t.find(f=>n(f)===l)).filter(l=>!!l&&typeof l.position?.order=="number");if(o.length===0)return null;const s=Ic(o,r);if(!s)return null;const i=o.filter(l=>l.type!=="sectionHeading"),a=i.length>0?i:o,d=Math.min(...a.map(l=>l.position?.order??0)),u=Math.max(1,...a.map(l=>(l.position?.order??d)-d+Do(l)));return{minRow:s.minRow,maxRow:s.maxRow,minCol:s.minCol,maxCol:s.maxCol,blockHeight:u}}function hT(e,t){return e.maxRow+1+t*e.blockHeight}function gT(e,t,r,n){const o=new Map;for(const a of t){const d=r(a);d&&o.set(d,a)}const s=new Map,i=new Set;for(const a of e){const d=a.fieldNames.map(v=>o.get(v)).filter(v=>!!v);if(d.length===0)continue;const u=d.filter(v=>!Ng(v,a.section,r)),l=Ic(d,n);if(!l)continue;const{minRow:f,minCol:p,rowSpan:m,colSpan:g}=l,h=`${f}-${p}`;if(s.has(h))continue;const y=new Set;let w=!1;for(let v=f;v<=f+m-1;v++){for(let x=p;x<=p+g-1;x++){const E=`${v}-${x}`;if(i.has(E)){w=!0;break}y.add(E)}if(w)break}if(!w){for(const v of y)i.add(v);s.set(h,{anchorRow:f,anchorCol:p,rowSpan:m,colSpan:g,run:a,legend:bs(a.section,0),renderFields:u.length>0?u:d})}}return{anchorsByOrigin:s,coveredCells:i}}function yT(e,t,r,n,o,s,i){const a=new Set(i),d=new Map;for(const u of e){const l=_g(u.linkedFields.map(p=>s(p)).filter(Boolean),t),f=l?.section;f?.fieldNames?.length?f.fieldNames:u.templateFieldNames,u.blockIds.forEach((p,m)=>{const g=r.filter(N=>N.id.endsWith(`__${p}`));if(g.length===0||!l)return;const h=Ic(g,o);if(!h)return;const{minRow:y,minCol:w,rowSpan:v,colSpan:x}=h,E=`${y}-${w}`;for(let N=y;N<=y+v-1;N++)for(let C=w;C<=w+x-1;C++)a.add(`${N}-${C}`);const P=l,k=bs(f,m+1);d.set(E,{anchorRow:y,anchorCol:w,rowSpan:v,colSpan:x,run:P,legend:k,renderFields:Oc(g),addMoreMeta:{addMoreFieldName:u.addMoreFieldName,blockId:p,blockIndex:m}})})}return{anchorsByOrigin:d,coveredCells:a}}function bT(e,t,r,n){const o=`${e}-${t}`;return r.has(o)?!n.get(o):!1}function vT(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 wT(e,t,r,n){return!(!n||r.run.section.collapsible!==!0||e===r.anchorRow&&t===r.anchorCol)}function ST(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 xT(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 AT(e,t){return new Map([...e,...t])}function CT(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),d=a?n.get(a):void 0;if(!d){o.push({kind:"field",field:i}),s+=1;continue}const u=[],l=new Set(d.fieldNames);for(;s<e.length;){const p=r(e[s]);if(!p||!l.has(p))break;const m=e[s];Ng(m,d.section,r)||u.push(m),s+=1}if(u.length===0)continue;const f=o[o.length-1];f?.kind==="border"&&f.run.section.id===d.section.id?f.fields.push(...u):o.push({kind:"border",run:d,fields:u})}return o}function _g(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 ET=2*6e4,kg=50;class NT{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<=kg)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-kg)).forEach(([n])=>this.map.delete(n))}}function _T(e){return(e??"").trim()||"default"}function Tg(e){const t=_T(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 Fg=new NT(ET);function Pg(e){const t=Tg(e),r=Fg.get(t);return r?{value:r.value,isStale:r.isStale}:null}function Og(e,t){const r=Tg(e);Fg.set(r,t)}function Ig(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 Mc=({schema:e,formId:t,initialValues:r,onSubmit:n,onChange:o,onValidationError:s,onClose:i,mode:a="fill",className:d,children:u,gridLayout:l,unstyled:f=!1,submissionContext:p,onWorkflowSubmitResult:m,initialExtraSubmitPayload:g,onExtraSubmitPayloadChange:h,workflowStepId:y,viewerContext:w,getViewerContext:v,hideTableRowControls:x=!1,themeVars:E,dark:P=!1,omitRootWrapper:k=!1})=>{const N=Rn(_=>_.viewerContext),C=S.useMemo(()=>{if(w!==void 0)return w;const _=v?.();return _!==void 0?_:N},[w,v,N]),[A,I]=S.useState(e||null),[T,W]=S.useState(!!t&&!e),[X,O]=S.useState(null),j=e?.BFF_submit_api??X,[M,D]=S.useState(!1),[L,U]=S.useState({}),[$,ie]=S.useState({}),[V,K]=S.useState({}),[J,ce]=S.useState({}),[ne,G]=S.useState({}),[ee,Pe]=S.useState(null),oe=ha.useParams(),re=Nt(_=>_.setValues),be=Nt(_=>_.setSubmitting),de=Nt(_=>_.formDisabled),ot=Nt(_=>_.visibleFields),Se=Nt(_=>_.requiredFields),xe=Nt(_=>_.updateVisibility),ae=Nt(_=>_.updateRequired),ve=Nt(_=>_.setFieldError),Ye=S.useRef(!1),ct=S.useRef(void 0),Ge=S.useMemo(()=>{if(!e)return null;const _=e;if(_.form&&Array.isArray(_.form.fields))try{return ms(_.form,_.form.fields,_.form.layout||null,_.form.rules||[])}catch{return e}if(Array.isArray(_.fields)&&_.fields.some(z=>typeof z.metadata=="string"&&z.metadata.startsWith("{")||z.fieldType&&!z.type))try{const z={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 ms(z,_.fields,_.layout||null,_.rules||[])}catch{return e}return e},[e]);S.useEffect(()=>{if(e){const _=e;_.BFF_submit_api&&O(_.BFF_submit_api)}},[e]);const Kt=S.useMemo(()=>{const _=Ge||A,H=_?Yi(_):null;if(!H)return null;const z=H.layout,Z=H.rules,Q=H.clientMapping,le=(Array.isArray(H.fields)?H.fields:[]).map(Le=>{let Ve={...Le};if(Le.validationRules&&typeof Le.validationRules=="object"&&!Le.validation){const fe=Le.validationRules,Fe=[];fe.required===!0&&Fe.push({type:"required",message:"This field is required"}),fe.minLength!==void 0&&typeof fe.minLength=="number"&&Fe.push({type:"minLength",value:fe.minLength,message:`Minimum length is ${fe.minLength}`}),fe.maxLength!==void 0&&typeof fe.maxLength=="number"&&Fe.push({type:"maxLength",value:fe.maxLength,message:`Maximum length is ${fe.maxLength}`}),fe.pattern&&typeof fe.pattern=="string"&&Fe.push({type:"pattern",value:fe.pattern,message:"Invalid format"}),fe.allowLetters!==void 0&&Fe.push({type:"allowLetters",value:fe.allowLetters}),fe.allowNumbers!==void 0&&Fe.push({type:"allowNumbers",value:fe.allowNumbers}),fe.allowSpecialChars!==void 0&&Fe.push({type:"allowSpecialChars",value:fe.allowSpecialChars}),Fe.length>0&&(Ve={...Ve,validation:Fe})}const we=Le.required===!0||Le.isRequired===!0,Ae=Array.isArray(Ve.validation)&&Ve.validation.some(fe=>fe.type==="required");if(we&&!Ae){const fe={type:"required",message:"This field is required"},Fe=Array.isArray(Ve.validation)?Ve.validation:[];Ve={...Ve,validation:[...Fe,fe]}}if(Le.apidata&&typeof Le.apidata=="object"){const fe=Le.apidata,Fe=Ve.properties||{},ye=(Ve.type||Le.fieldType)==="status";if(!Fe.apiEndpoint&&fe.apiEndpoint){const dt={...Fe,apiEndpoint:fe.apiEndpoint,apiMethod:fe.apiMethod,apiKey:fe.apiKey,apiRealtime:fe.apiRealtime,apiAutoDetect:fe.apiAutoDetect,apiLabelField:fe.apiLabelField,apiValueField:fe.apiValueField,apiQueryParams:fe.apiQueryParams,apiClientFilter:fe.apiClientFilter,valueSource:fe.valueSource||(fe.apiEndpoint?"api":void 0),optionsSource:fe.optionsSource||(fe.apiEndpoint?"api":void 0)};ye&&(dt.source=Fe.source??"api",Fe.statuses!==void 0&&(dt.statuses=Fe.statuses),Fe.dataPath!==void 0&&(dt.dataPath=Fe.dataPath),Fe.showStatusText!==void 0&&(dt.showStatusText=Fe.showStatusText),Fe.statusTextPath!==void 0&&(dt.statusTextPath=Fe.statusTextPath),Fe.showCurrentIndicator!==void 0&&(dt.showCurrentIndicator=Fe.showCurrentIndicator)),Ve={...Ve,properties:dt}}}const He=["select","multiselect","radio","checkboxgroup"],rt=Ve.type||Le.fieldType;if(He.includes(rt)){const fe=Le.options,Fe=Ve.properties?.options,ye=Array.isArray(Fe)&&Fe.length>0;if(Array.isArray(fe)&&fe.length>0&&!ye){const dt=Ve.properties||{};Ve={...Ve,properties:{...dt,options:fe}}}}return Ve}),Ce=H.config?.rules,Ne=Z&&Array.isArray(Z)?Z:Ce&&Array.isArray(Ce)?Ce:[],De=Ne.length>0?le.map(Le=>{if((Le.conditions&&Array.isArray(Le.conditions)?Le.conditions:[]).length>0)return Le;const we=Le.id??Le._id,Ae=Le.name||Le.key,He=Ne.filter(Fe=>{const ye=typeof Fe.targetFieldId=="object"?Fe.targetFieldId?.id??Fe.targetFieldId?._id:Fe.targetFieldId;return ye?ye===we||ye===Ae||ye===Le.fieldKey:!1});if(He.length===0)return Le;const rt=[],fe=new Set;return He.forEach(Fe=>{try{const ye=typeof Fe.conditionExpression=="string"?JSON.parse(Fe.conditionExpression):Fe.conditionExpression;if(!ye||typeof ye!="object")return;!ye.id&&Fe.id&&(ye.id=Fe.id);const dt=typeof Fe.targetFieldId=="object"?Fe.targetFieldId?.id??Fe.targetFieldId?._id:Fe.targetFieldId;ye.action&&(!ye.then||!Array.isArray(ye.then)||ye.then.length===0)&&(ye.then=[{action:ye.action,...dt&&{target:dt}}]),(!ye.then||!Array.isArray(ye.then)||ye.then.length===0)&&Fe.action&&(ye.then=[{action:Fe.action,...dt&&{target:dt}}]),ye.then&&Array.isArray(ye.then)&&dt&&(ye.then=ye.then.map(Bt=>!Bt.target&&dt?{...Bt,target:dt}:Bt));const Wt=Fe.conditionExpression??JSON.stringify(ye);if(fe.has(Wt))return;fe.add(Wt),rt.push(ye)}catch{}}),rt.length===0?Le:{...Le,conditions:rt}}):le;let at=H.config||{submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};return!at.layout&&z?typeof z=="object"&&z!==null?at.layout="default":typeof z=="string"&&["default","card","compact"].includes(z)?at.layout=z:at.layout="default":at.layout||(at.layout="default"),Z&&!at.rules&&(at.rules=Z),Q&&!at.clientMapping&&(at.clientMapping=Q),{...H,fields:De,config:at}},[Ge,A]);S.useEffect(()=>{Ge&&Ge!==A&&I(Ge)},[Ge]),S.useEffect(()=>{if(t&&!e){const _=(Tn()??"").trim()||"default",H=Pg({scope:_,formId:t,version:"latest"});H?.value?.schema?(I(H.value.schema),H.value.bffSubmitApi&&O(H.value.bffSubmitApi),W(!1),H.isStale&&Je({background:!0})):Je({background:!1})}},[t,e]);const Je=async({background:_})=>{if(!t)return;const H=t;_||W(!0);try{const z=await Lk.getForRendering(t),Z=ms(z.form,z.fields,z.layout,z.rules);if(H!==t)return;I(Z),z.BFF_submit_api&&O(z.BFF_submit_api);const Q=(Tn()??"").trim()||"default";Og({scope:Q,formId:H,version:"latest"},{schema:Z,bffSubmitApi:z.BFF_submit_api})}catch{}finally{_||W(!1)}};if(T)return c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(Pn,{})});if(!Kt)return c.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Form not found"});const q=Kt,$e=S.useMemo(()=>new Set(Object.keys(q.config?.prepopulateApi?.fieldMapping??{})),[q.config?.prepopulateApi?.fieldMapping]),gt=S.useCallback(async _=>{const H=q?.fields?.length?tc(_,q.fields):_,z=yh(H,q.config?.sections,q.config?.submitPayload);if(n){const Z=p?{...z,...p}:z;return n(Z)}return{success:!0}},[n,p,q?.fields,q.config?.sections,q.config?.submitPayload]),{values:Oe,errors:te,touched:pe,isSubmitting:We,isValid:Pt,submitCount:je,currentStep:Te,totalSteps:Xe,completedSteps:Ue,currentStepFields:ft,isLastStep:St,setFieldValue:xt,setFieldTouched:ze,handleSubmit:yt,validateForm:pt,resetForm:At,nextStep:Ut,goToStep:ur,shouldShowField:Ar,isFieldEnabled:Vt,isFieldRequired:Po,loadDraft:Xn}=Vd({schema:q,initialValues:r,onSubmit:gt,onChange:o,workflowStepId:y});sv({fields:q.fields,values:Oe,buttonResponses:$,prepopulateResponse:ee,prepopulateResponseRules:q.config?.prepopulateResponseRules});const Ct=Nt(_=>_.readOnlyFields),Cr=Nt(_=>_.editableFields),Jn=S.useCallback(_=>Ct.has(_),[Ct]),It=S.useCallback(_=>Cr.has(_),[Cr]);S.useEffect(()=>{q.config?.allowDraft&&a==="fill"&&Xn()},[q.id]),S.useEffect(()=>{ct.current=q.id,Ye.current=!1,U({}),K({}),ce({}),G({}),Pe(null)},[q.id]),S.useEffect(()=>{const _=q.config?.prepopulateApi,H=!!(_?.fieldMapping&&Object.keys(_?.fieldMapping??{}).length>0),z=(q.config?.prepopulateResponseRules?.length??0)>0;if(!_?.enabled||!_.apiEndpoint?.trim()||!H&&!z||Ye.current)return;Ye.current=!0;const Z=q.id;ct.current=q.id;let Q=!1;return D(!0),(async()=>{try{const le=Nt.getState().values,Ce=typeof p=="object"&&p!==null?{...p,...g||{}}:g||{},Ne=se=>rn(se,le,oe,Ce);let De=cn(Ne(_.apiEndpoint));if(_.apiQueryParams?.length){const se=new URLSearchParams;_.apiQueryParams.forEach(({key:Ie,value:me})=>se.append(Ie,Ne(me))),De=`${De}${De.includes("?")?"&":"?"}${se.toString()}`}const at={};_.apiHeaders?.forEach(({key:se,value:Ie})=>{se.trim()&&(at[se]=Ne(Ie))}),at["Content-Type"]=at["Content-Type"]??"application/json";let Ht;if(_.apiMethod==="POST"&&_.apiBodyFields?.length){const se={};_.apiBodyFields.forEach(({key:Ie,value:me})=>{Ie.trim()&&(se[Ie]=Ne(me))}),Ht=JSON.stringify(se)}const Le=await fetch(De,{method:_.apiMethod,headers:at,body:_.apiMethod==="POST"?Ht:void 0});if(!Le.ok){const se=await Le.text();throw new Error(se||`HTTP ${Le.status}`)}const Ve=await Le.json(),we=se=>{try{return se.split("?")[0].split("/").filter(Boolean).pop()||se}catch{return se}},Ae=(se,Ie)=>{if(se==null)return null;const me=typeof se=="string"?se:se instanceof Date?se.toISOString():null;if(!me)return null;const Ke=typeof se=="object"&&se instanceof Date?se:new Date(me);if(Number.isNaN(Ke.getTime()))return null;const ut=mt=>String(mt).padStart(2,"0");if(Ie==="date")return me.length>=10&&me[4]==="-"&&me[7]==="-"?me.slice(0,10):Ke.toISOString().slice(0,10);if(Ie==="time")return`${ut(Ke.getHours())}:${ut(Ke.getMinutes())}:${ut(Ke.getSeconds())}`;if(Ie==="datetime"){const mt=Ke.getFullYear(),tt=Ke.getMonth()+1,ue=Ke.getDate(),bt=Ke.getHours(),Re=Ke.getMinutes(),Ft=Ke.getSeconds();return`${mt}-${ut(tt)}-${ut(ue)}T${ut(bt)}:${ut(Re)}:${ut(Ft)}`}return null},He=(se,Ie)=>{const me=q.fields.find(ue=>ue.name===se||ue.key===se);if(!me)return Ie;if((me.type==="file"||me.type==="camera"||me.type==="photoChoice")&&typeof Ie=="string"&&Ie.startsWith("http"))return{url:Ie,name:we(Ie)};if(me.type==="date"||me.type==="datetime"||me.type==="time"){const ue=Ae(Ie,me.type);if(ue!==null)return ue}if(me.type==="multiselect")return Array.isArray(Ie)?Ie.map(ue=>typeof ue=="string"?ue:String(ue)):typeof Ie=="string"?Ie.trim()===""?[]:Ie.includes(",")?Ie.split(",").map(ue=>ue.trim()).filter(Boolean):[Ie]:Ie!=null&&Ie!==""?[String(Ie)]:[];if(me.type!=="radio"&&me.type!=="select")return Ie;const Ke=me.properties?.options??me.options;if(!Array.isArray(Ke)||Ke.length===0)return Ie;const ut=Ke.map(ue=>ue.value);if(ut.includes(Ie))return Ie;const mt=String(Ie);if(ut.includes(mt))return mt;const tt=Ke.find(ue=>ue.value==Ie);return tt?tt.value:Ie},rt=new Set(q.fields.filter(se=>se.type==="table").map(se=>se.name||se.key)),fe=new Set(q.fields.filter(se=>se.type==="billingGrid").map(se=>se.name||se.key)),Fe=se=>se.name||se.key||se.id,ye={},dt=[],Wt=[],Bt=gN(_?.fieldMapping,q.config?.sections,q.config?.submitPayload);for(const[se,Ie]of Object.entries(Bt)){if(!Ie?.trim()||se.startsWith("__"))continue;const me=Qe(Ve,Ie),Ke=se.indexOf(".");if(Ke>0&&fe.has(se.slice(0,Ke))){const mt=se.slice(0,Ke),tt=se.slice(Ke+1),bt=q.fields.find(Re=>(Re.name||Re.key)===mt)?.properties;if(bt?.rowSlots?.length){const Re=tt.startsWith("__block__")?tt.slice(9):tt,Ft=ye[mt]??Nt.getState().values[mt];Array.isArray(me)?ye[mt]=f_(bt,Re,me,Ft):me!=null&&(ye[mt]=mc(bt,me,Ft))}continue}if(Ke>0&&rt.has(se.slice(0,Ke))){const mt=se.slice(0,Ke),tt=se.slice(Ke+1);dt.push({tableName:mt,columnName:tt,path:Ie});continue}if(fe.has(se)&&me!==void 0&&me!==null&&typeof me=="object"){const tt=q.fields.find(ue=>(ue.name||ue.key)===se)?.properties;if(tt?.rowSlots?.length){if(Array.isArray(me)){const ue=tt.rowSlots.find(bt=>bt.kind==="dynamic");if(ue&&ue.kind==="dynamic"){const bt=ue.block.apiArrayPath??"items";ye[se]=mc(tt,{[bt]:me})}}else ye[se]=mc(tt,me);continue}}if(rt.has(se)&&Array.isArray(me)&&me.length>0&&typeof me[0]=="object"&&me[0]!==null){const tt=q.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],ue=me.map(Ig),bt=Re=>(Re||"").toLowerCase().replace(/\s+/g,"_").trim();ye[se]=ue.map(Re=>{const Ft={};for(const fr of tt){const eo=fr.name??"";Ft[eo]=Re[bt(eo)]??Re[eo]}return Ft});continue}if(me!=null&&(ye[se]=He(se,me)),me==null)continue;let ut=me;if(Array.isArray(me)){const mt=q.fields.find(tt=>Fe(tt)===se);if(mt?.type==="addmore"){Wt.push({addMoreFieldName:se,array:me});continue}if(mt?.type==="multiselect"){const tt=_.multiselectArrayPropertyMap?.[se];tt&&me.length>0&&me.some(ue=>ue!=null&&typeof ue=="object")&&(ut=me.map(ue=>ue!=null&&typeof ue=="object"&&tt in ue?ue[tt]:void 0).filter(ue=>ue!=null))}}ye[se]=He(se,ut)}const lt={},vt={},rr={};for(const{addMoreFieldName:se,array:Ie}of Wt){const me=q.fields.find(bt=>Fe(bt)===se);if(!me||me.type!=="addmore")continue;const Ke=Eg(me,q.fields,q.config?.sections,Fe);if(Ke.length===0)continue;const ut=_.addMoreFieldKeyMap?.[se],mt=Ie.length>0&&Ie[0]!=null&&typeof Ie[0]=="object"?Ie[0]:null;if(mt)for(const bt of Ke){const Re=Fe(bt),Ft=ut&&ut[Re]||Re,fr=mt[Ft];fr!=null&&(ye[Re]=He(Re,fr))}const tt=Ie.slice(1),ue=tt.map((bt,Re)=>`prepop_${se}_${Re}_${Date.now()}`);ue.length>0&&(vt[se]=ue);for(let bt=0;bt<tt.length;bt++){const Re=tt[bt];if(Re==null||typeof Re!="object")continue;const Ft=Re,fr=Ft.id;fr!=null&&String(fr).trim()!==""&&(rr[`${se}__${ue[bt]}`]=String(fr));for(const eo of Ke){const ma=Fe(eo),hP=ut&&ut[ma]||ma,Kc=Ft[hP];if(Kc==null)continue;const gP=`${ma}__addmore__${se}__${ue[bt]}`;lt[gP]=He(ma,Kc)}}}Object.keys(vt).length>0&&K(se=>({...se,...vt})),Object.keys(rr).length>0&&G(se=>({...se,...rr}));const jr=se=>(se||"").toLowerCase().replace(/\s+/g,"_").trim(),Kr=[...new Set(dt.map(se=>se.tableName))];for(const se of Kr){if(Array.isArray(ye[se]))continue;const Ie=dt.find(ue=>ue.tableName===se);if(!Ie?.path?.includes("."))continue;const me=Ie.path.replace(/\.[^.]+$/,""),Ke=Qe(Ve,me);if(!Array.isArray(Ke)||Ke.length===0||typeof Ke[0]!="object"||Ke[0]===null)continue;const mt=q.fields.find(ue=>(ue.name||ue.key)===se)?.properties?.columns||[],tt=Ke.map(Ig);ye[se]=tt.map(ue=>{const bt={};for(const Re of mt){const Ft=Re.name??"",fr=jr(Ft),eo=ue[fr]??ue[Ft];bt[Ft]=eo}return bt})}const zr=(se,Ie)=>{const me=Qe(Ve,se);if(Array.isArray(me))return me;if(me!=null)return[me];if(!se.includes("."))return[];const Ke=se.replace(/\.[^.]+$/,""),ut=Qe(Ve,Ke);return!Array.isArray(ut)||ut.length===0||typeof ut[0]!="object"||ut[0]===null?[]:ut.map(mt=>{const tt=mt[Ie];if(tt!==null&&typeof tt=="object"&&!Array.isArray(tt)&&!(tt instanceof Date)){const ue=tt;return typeof ue.name=="string"&&typeof ue.code=="string"?`${ue.code} ${ue.name}`.trim():typeof ue.name=="string"?ue.name:typeof ue.code=="string"?ue.code:typeof ue.short_code=="string"?ue.short_code:ue.name??ue.code??""}return tt})};for(const{tableName:se,columnName:Ie,path:me}of dt){const Ke=zr(me,Ie),mt=q.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],tt=mt.find(Re=>(Re.name||"").toLowerCase()===Ie.toLowerCase())?.name??Ie;let ue=Array.isArray(ye[se])?ye[se]:[];const bt=Math.max(ue.length,Ke.length);if(bt>ue.length)for(ue=[...ue];ue.length<bt;){const Re={};mt.forEach(Ft=>{Re[Ft.name||""]=""}),ue.push(Re)}else ue=ue.map(Re=>({...Re}));Ke.forEach((Re,Ft)=>{ue[Ft]&&(ue[Ft][tt]=Re)}),ye[se]=ue}if(ct.current===Z){if(Object.keys(ye).length>0||Object.keys(lt).length>0){const Ft={...Nt.getState().values,...ye,...lt};re(Ft)}const Ie=Qe(Ve,"data.user_id"),me=Qe(Ve,"data.items"),Ke=Qe(Ve,"data");let ut=Array.isArray(me)&&me.length>0&&me[0]!=null&&typeof me[0]=="object"&&me[0].id?me[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=Qe(Ve,"data.0.id"));const mt=rT(Ve,{treatFirstItemIdAsPaymentId:_?.treatFirstItemIdAsPaymentId===!0}),tt=Qe(Ve,"data.id"),ue=Qe(Ve,"data.batch_id"),bt=Qe(Ve,"data.program_id"),Re={};Ie!=null&&(Re.context_user_id=Ie),ut!=null&&ut!==""&&(Re.documentId=ut),tt!=null&&String(tt).trim()!==""&&(p?.id===void 0||p?.id===null)&&(Re.id=tt),ue!=null&&String(ue).trim()!==""&&((p?.admission_batch_id===void 0||p?.admission_batch_id===null)&&(Re.admission_batch_id=ue),(p?.batch_id===void 0||p?.batch_id===null)&&(Re.batch_id=ue)),bt!=null&&String(bt).trim()!==""&&(p?.program_id===void 0||p?.program_id===null)&&(Re.program_id=bt),mt!=null&&String(mt).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&(Re.payment_id=mt),Object.keys(Re).length>0&&U(Ft=>{const fr={...Ft,...Re};return h?.(fr),fr}),Pe(Ve)}}catch(le){Q||Zl(le,"Prepopulate request failed.",ls)}finally{D(!1)}})(),()=>{Q=!0}},[q.id,q.config?.prepopulateApi?.enabled,q.config?.prepopulateApi?.apiEndpoint,q.config?.prepopulateApi?.apiMethod,JSON.stringify(q.config?.prepopulateApi?.fieldMapping),q.config?.prepopulateApi?.treatFirstItemIdAsPaymentId,p,g,oe,re,K]),S.useEffect(()=>{Object.keys(te).length>0&&s?.(te)},[te,s]);const Er=Xe>1,er=a==="view",sr=S.useCallback((_,H)=>er||!!H&&!It(_)||Jn(_)&&!It(_),[er,It,Jn]),fn=q.fields.filter(_=>!_.parentId),kt=[...Er?ft:fn.length>0?fn:q.fields].filter(_=>!(!_||typeof _!="object"||!_.name&&!_.key)).sort((_,H)=>{const z=typeof _.position?.order=="number"?_.position.order:typeof _.positionOrder=="number"?_.positionOrder:Number.MAX_SAFE_INTEGER,Z=typeof H.position?.order=="number"?H.position.order:typeof H.positionOrder=="number"?H.positionOrder:Number.MAX_SAFE_INTEGER;if(z!==Z)return z-Z;const Q=typeof _.position?.column=="number"?_.position.column:1,le=typeof H.position?.column=="number"?H.position.column:1;return Q-le}),Ss=S.useCallback(_=>{const H=Nt.getState().errors,z=Object.keys(H).find(Z=>_.includes(Z));z&&requestAnimationFrame(()=>{document.querySelector(`[data-field-name="${z}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})})},[]),Nr=async _=>{if(_?.preventDefault(),Er&&!St){if(!await Ut())try{const Z=Nt.getState().errors;$t.toast.error(ec(Z,q.fields)||"Please fix the errors before continuing."),Ss(kt.map(Q=>Q.name||Q.key||Q.id).filter(Boolean))}catch{$t.toast.error("Please fix the errors before continuing.")}return}const H=await yt(_);if(H&&H.success===!1&&H.errors?.length)try{const z=Nt.getState().errors;$t.toast.error(ec(z,q.fields)||"Submission failed. Please check the form."),Ss(kt.map(Z=>Z.name||Z.key||Z.id).filter(Boolean))}catch{$t.toast.error("Submission failed. Please check the form.")}return H},Dr=S.useCallback(()=>{At(),i&&i()},[At,i]),_r=S.useCallback((_,H)=>{const z=q.fields.find(Q=>Q.type==="button"&&(Q.name===_||Q.key===_)),Z=iT(H,z);Z!=null&&String(Z).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&U(Q=>{const le={...Q,payment_id:Z};return h?.(le),le}),ie(Q=>{const le={...Q,[_]:H};return!Uo(H)||!(z?.type==="button"&&z.properties?.action==="submit")||q.fields.filter(De=>De.type==="editButton").map(De=>De.name).forEach(De=>delete le[De]),le})},[q.fields,p,h]),br=S.useCallback(async()=>await pt(),[pt]),qt=S.useCallback(()=>Nt.getState().errors,[]),tr=S.useMemo(()=>({...g||{},...L}),[g,L]),Br=S.useMemo(()=>({...typeof p=="object"&&p!==null?p:{},...tr}),[p,tr]),Qi=q.config?.layout??q.layout??"default",Zi=["default","card","compact"].includes(Qi)?Qi:"default",ea={default:"",card:"bg-card border rounded-lg shadow-sm p-6",compact:"space-y-2"},xs=S.useMemo(()=>{if(k)return;const _=q.config?.theme?.cssVariables;if(!(!_&&!E))return{..._??{},...E??{}}},[k,q.config?.theme?.cssVariables,E]),kr=S.useMemo(()=>_s({config:q.config,layout:q.layout},l),[q.config,q.layout,l]),Ee=S.useMemo(()=>kr?{...kr,verticalSpacing:kr.verticalSpacing??kr.spacing??"16px",horizontalSpacing:kr.horizontalSpacing??kr.spacing??"16px",rowHeight:kr.rowHeight??In}:null,[kr]),F=Ee!==null;Ee?.rows;const Y=Ee?.columns??3,he=Ee?.verticalSpacing??Ee?.spacing??"16px",st=Ee?.horizontalSpacing??Ee?.spacing??"16px",Tt=Ee?.rowHeight??In,wt=S.useCallback(_=>{if(!C)return!0;const H=_.visibility;if(!H)return!0;const z=H.visibleToUserType??H.user_type,Z=H.visibleToUserRole??H.user_role,Q=Array.isArray(H.visibleToUserIds)?H.visibleToUserIds:Array.isArray(H.users)?H.users:[],le=Array.isArray(H.hiddenFromUserIds)?H.hiddenFromUserIds:[];if(Array.isArray(le)&&le.length>0&&C.userId!=null&&le.includes(C.userId))return!1;if(Q.length>0&&C.userId!=null&&Q.includes(C.userId))return!0;const Ce=z!=null&&z!==""&&C.userType!=null&&C.userType!==z,Ne=Z!=null&&Z!==""&&C.role!=null&&C.role!==Z,De=Q.length>0&&(C.userId==null||!Q.includes(C.userId));return!(Ce||Ne||De)},[C]),Mt=S.useMemo(()=>NN(q.fields),[q.fields]),$r=S.useMemo(()=>kN(q.fields),[q.fields]),[ir,Oo]=S.useState($r);S.useEffect(()=>{Oo($r)},[q.id,$r]);const Lt=S.useCallback((_,H)=>{Oo(z=>z[_]===H?z:{...z,[_]:H})},[]),ta=S.useMemo(()=>({visibility:ir,setSectionVisible:Lt,fieldToHeading:Mt,allFields:q.fields}),[ir,Lt,Mt,q.fields]),et=S.useCallback(_=>_.name||_.key||_.id,[]),Tr=_=>{if(!wt(_))return!1;const H=_.name||_.key||_.id;if(!wh(H,_.type,ir,Mt))return!1;const z=_.hidden===!0;return Ar(H)||!z&&H},yy=S.useCallback(_=>{const H=q.fields.find(Z=>et(Z)===_);if(H)return H.type;const z=vh(_);return q.fields.find(Z=>et(Z)===z)?.type},[q.fields,et]),ra=S.useCallback(_=>wh(_,yy(_),ir,Mt),[ir,Mt,yy]),pn=S.useCallback(_=>ra(_)?Po(_):!1,[ra,Po]);S.useEffect(()=>{const{visibleFields:_,requiredFields:H,errors:z}=Nt.getState(),Z=new Set(_),Q=new Set(H),le=[];for(const Ce of q.fields){const Ne=et(Ce);Ne&&(ra(Ne)||(Z.delete(Ne),Q.delete(Ne),z[Ne]&&le.push(Ne)))}xe(Array.from(Z)),ae(Array.from(Q));for(const Ce of le)ve(Ce,void 0)},[ir,Mt,q.fields,q.id,et,ra,xe,ae,ve,ot,Se]);const Dt=q.config?.sections,Qn=S.useCallback(_=>{let H=_;if(_.type==="table"){const Z=_.properties?.columns;if(Array.isArray(Z)&&Z.length>0){const Q=Z.filter(le=>wt(le));H={..._,properties:{..._.properties,columns:Q}}}}const z=uT(H,Dt,et);return z?{...H,label:Cg(z,0)}:H},[wt,Dt,et]),mn=S.useCallback(_=>Eg(_,q.fields,Dt,et),[q.fields,Dt,et]),Gr=S.useCallback((_,H,z)=>`${_}__addmore__${H}__${z}`,[]),na=S.useCallback((_,H)=>`${_}__${H??"base"}`,[]),oa=S.useCallback((_,H)=>{const z=na(_.id,H);return J[z]??_.defaultCollapsed??!1},[J,na]),Wc=S.useCallback((_,H,z)=>{const Z=na(_,H);ce(Q=>Q[Z]===z?Q:{...Q,[Z]:z})},[na]),sa=S.useMemo(()=>{const _=[],H=q.fields.filter(z=>z.type==="addmore");for(const z of H){const Z=et(z),le=mn(z).find(at=>{if(at.type!=="button")return!1;const Ht=at.properties,Le=at.metadata;let Ve=Ht?.action;if(!Ve&&Le!=null)try{Ve=(typeof Le=="string"?JSON.parse(Le):Le)?.action}catch{}return Ve==="upload"||Ve==="custom"});if(!le)continue;const Ce=et(le),Ne=V[Z]||[],De=Qe($[Ce],"data.id")??Qe($[Ce],"data.documentId")??L.documentId;De!=null&&String(De).trim()!==""&&_.push(String(De));for(const at of Ne){const Ht=Gr(Ce,Z,at),Le=Qe($[Ht],"data.id")??Qe($[Ht],"data.documentId"),Ve=ne[`${Z}__${at}`],we=Le??Ve;we!=null&&String(we).trim()!==""&&_.push(String(we))}}return _},[q.fields,V,$,ne,L.documentId,et,mn,Gr]);S.useEffect(()=>{U(_=>{const H={..._,document_ids:sa},z=_.document_ids;return Array.isArray(z)&&z.length===sa.length&&sa.every((Z,Q)=>z[Q]===Z)?_:H})},[sa]);const ia=S.useCallback((_,H,z,Z)=>{for(const Q of z){const le=et(Q),Ce=Gr(le,_,H),Ne=Z[Ce];if(Ne==null)continue;const De=Q.type;if(De==="file"||De==="camera"||De==="photoChoice"){if(typeof Ne=="object"&&Ne!==null&&("url"in Ne||"name"in Ne)||Array.isArray(Ne)&&Ne.length>0)return!0;continue}if(Array.isArray(Ne)){if(Ne.length>0)return!0;continue}if(typeof Ne=="string"&&Ne.trim()!==""||typeof Ne=="number"&&!Number.isNaN(Ne)||typeof Ne=="boolean"||typeof Ne=="object"&&Ne!==null&&Object.keys(Ne).length>0)return!0}return!1},[et,Gr]),Zn=S.useCallback(_=>{const H=et(_);if(!H)return;if(mn(_).length===0){$t.toast.error("No linked fields configured for this Add More button.");return}const Z=`${Date.now()}_${Math.random().toString(36).slice(2,8)}`;K(Q=>({...Q,[H]:[...Q[H]||[],Z]}))},[et,mn]),aa=S.useCallback((_,H)=>{K(z=>{const Z=z[_]||[],Q=Z.filter(le=>le!==H);if(Q.length===Z.length)return z;if(Q.length===0){const le={...z};return delete le[_],le}return{...z,[_]:Q}})},[]),la=S.useMemo(()=>kt.filter(_=>!_.parentId),[kt]),On=S.useMemo(()=>{const _=[];return kt.filter(z=>z.type==="addmore").sort((z,Z)=>{const Q=z.position?.order??0,le=Z.position?.order??0;return Q-le}).forEach(z=>{const Z=et(z),Q=z.position?.order??0,le=V[Z]||[],Ce=mn(z).sort((Ae,He)=>{const rt=Ae.position?.order??0,fe=He.position?.order??0;return rt!==fe?rt-fe:(Ae.position?.column??1)-(He.position?.column??1)});if(Ce.length===0)return;const Ne=Ag(z,Dt),De=Ne[0]?.fieldNames?.length?Ne[0].fieldNames:Ce.map(Ae=>et(Ae)).filter(Boolean),at=mT(De,la,Y,et),Ht=Math.min(...Ce.map(Ae=>Ae.position?.order??0)),Le=Math.max(1,...Ce.map(Ae=>(Ae.position?.order??Ht)-Ht+Do(Ae))),Ve=at?.blockHeight??Le,we=le.length*Ve;_.push({addMoreFieldName:Z,baseOrder:Q,blockHeight:Ve,blockIds:le,linkedFields:Ce,insertedRows:we,templateFieldNames:De,templateBounds:at})}),_},[kt,la,Y,et,V,mn,Dt]),As=S.useMemo(()=>({}),[]),ca=S.useMemo(()=>On.length===0?kt:kt.map(_=>{const H=_.position?.order??0,z=On.reduce((Z,Q)=>{const le=Q.templateBounds?.maxRow??Q.baseOrder;return H>le?Z+Q.insertedRows:Z},0);return z===0?_:{..._,position:{..._.position,order:H+z}}}),[kt,On]),da=S.useCallback(_=>{const H={};return Object.entries($).forEach(([z,Z])=>{const Q=_[z];Q&&(H[Q]=Z)}),H},[$]),Io=S.useMemo(()=>{const _=[],H={};return On.forEach(z=>{const{addMoreFieldName:Z,blockIds:Q,linkedFields:le,blockHeight:Ce,templateBounds:Ne}=z,De=Math.min(...le.map(Le=>Le.position?.order??0)),Ht=q.fields.find(Le=>et(Le)===Z&&Le.type==="addmore")?.properties;Q.forEach((Le,Ve)=>{const we={},Ae={},He={},rt=Ne?hT(Ne,Ve):z.baseOrder+1+Ve*Ce,fe=ne[`${Z}__${Le}`];le.forEach(ye=>{const dt=et(ye),Wt=Gr(dt,Z,Le),Bt=(ye.position?.order??De)-De;if(we[Wt]=dt,Ae[Wt]=Oe[Wt],!(Ht?.linkedFieldAllowDuplicate?.[dt]??!0)&&(ye.type==="select"||ye.type==="radio"||ye.type==="multiselect")){const vt=[],rr=Oe[dt];rr!=null&&rr!==""&&(Array.isArray(rr)?vt.push(...rr.map(Kr=>String(Kr))):vt.push(String(rr))),Q.filter(Kr=>Kr!==Le).forEach(Kr=>{const zr=Gr(dt,Z,Kr),qr=Oe[zr];qr!=null&&qr!==""&&(Array.isArray(qr)?vt.push(...qr.map(se=>String(se))):vt.push(String(qr)))}),vt.length>0&&(He[Wt]=[...new Set(vt)])}_.push({...ye,id:`${ye.id}__${Le}`,name:Wt,position:{...ye.position,order:rt+Bt}})});const Fe=da(we);Object.keys(we).forEach(ye=>{H[ye]={scopedFormValues:Ae,scopedFieldNameMap:we,scopedButtonResponses:Fe,...fe!=null&&{blockDocumentId:fe},...He[ye]&&{excludedOptionValues:He[ye]}}})})}),{clonedFields:_,scopeByFieldName:H}},[On,ne,et,Gr,Oe,da,q.fields]),Cs=S.useMemo(()=>[...ca,...Io.clonedFields].sort((_,H)=>{const z=_.position?.order??0,Z=H.position?.order??0;if(z!==Z)return z-Z;const Q=_.position?.column??1,le=H.position?.column??1;if(Q!==le)return Q-le;const Ce=ko(_.position)??0,Ne=ko(H.position)??0;return Ce!==Ne?Ce-Ne:String(_.id).localeCompare(String(H.id))}),[ca,Io.clonedFields]),Mo=S.useMemo(()=>Vk(Cs.filter(_=>!_.parentId),Tr),[Cs,Tr]),Rc=S.useCallback((_,H)=>Mo.some(z=>Hk(_,H,z,Y)),[Mo,Y]);Mo.length===0||Math.max(...Mo.map(_=>(_[0]?.position?.order??0)+gs(_,Y).rowSpan));const ua=S.useMemo(()=>fT(Dt,Oc(kt.filter(_=>!_.parentId)),et),[Dt,kt,et]),{anchorsByOrigin:by,coveredCells:vy}=S.useMemo(()=>gT(ua,ca,et,Y),[ua,ca,et,Y]),{anchorsByOrigin:wy,coveredCells:Sy}=S.useMemo(()=>yT(On.map(_=>({addMoreFieldName:_.addMoreFieldName,blockIds:_.blockIds,linkedFields:_.linkedFields,templateFieldNames:_.templateFieldNames})),Dt,Io.clonedFields,la,Y,et,vy),[On,Dt,Io.clonedFields,la,Y,et,vy]),hn=S.useMemo(()=>AT(by,wy),[by,wy]),xy=S.useMemo(()=>Sy,[Sy]),Ay=String(Tt).endsWith("px")?Tt:In,Cy=S.useCallback((_,H)=>{for(let z=0;z<Y;z++){if(z>=H.anchorCol&&z<H.anchorCol+H.colSpan)continue;if(As[`${_}-${z}`]||hn.get(`${_}-${z}`)||vg(_,z,Cs,Tr).length>0||Rc(_,z))return!0}return!1},[Y,As,hn,Cs,Tr,Rc]),Ey=S.useMemo(()=>ST(hn,_=>{const H=_.run.section;return H.collapsible?oa(H,_.addMoreMeta?.blockId):!1},Cy),[hn,oa,Cy]),Ny=S.useMemo(()=>{const _=[];for(const H of Object.keys(As)){const z=Number(H.split("-")[0]);Number.isNaN(z)||_.push(z)}for(const H of hn.values())if(H.renderFields.some(z=>Tr(z)))for(let z=H.anchorRow;z<H.anchorRow+H.rowSpan;z++)_.push(z);return Wk(Mo,Y,_)},[Mo,Y,As,hn,Tr]),{originalToDisplayRow:fa,displayRowCount:uP,sortedOccupiedRows:fP}=S.useMemo(()=>{const _=Rk(Ny);return{originalToDisplayRow:_.originalToDisplay,displayRowCount:_.displayRowCount,sortedOccupiedRows:_.sortedOriginalRows}},[Ny]),_y=Math.max(uP,1),Gc=S.useCallback((_,H=1)=>Gk(_,H,fa),[fa]),ky=S.useMemo(()=>{const _=new Set;for(const H of Ey){const z=fa.get(H);z!==void 0&&_.add(z)}return _},[Ey,fa]),pP=S.useMemo(()=>xT(_y,Ay,ky),[_y,Ay,ky]),mP=S.useMemo(()=>CT(kt.filter(_=>!_.parentId&&Tr(_)),ua,et),[kt,ua,et,Tr]),pa=S.useCallback(_=>{if(F)return null;const H=et(_),z=V[H]||[];if(z.length===0)return null;const Z=mn(_);if(Z.length===0)return null;const Q=dT(_,Dt),le=Z.map(De=>et(De)).filter(Boolean),Ce=_g(le,Dt),Ne=(De,at,Ht,Le,Ve,we,Ae)=>{const He=et(De),rt=Gr(He,H,at),fe=De.hidden===!0;if(!(wt(De)&&(Ar(He)||!fe&&He)))return null;const ye={...De,id:`${De.id}__${at}`,name:rt},Wt=_.properties?.linkedFieldAllowDuplicate?.[He]??!0;let Bt;if(!Wt&&(De.type==="select"||De.type==="radio"||De.type==="multiselect")){const lt=[],vt=Oe[He];vt!=null&&vt!==""&&(Array.isArray(vt)?lt.push(...vt.map(jr=>String(jr))):lt.push(String(vt))),z.filter(jr=>jr!==at).forEach(jr=>{const Kr=Gr(He,H,jr),zr=Oe[Kr];zr!=null&&zr!==""&&(Array.isArray(zr)?lt.push(...zr.map(qr=>String(qr))):lt.push(String(zr)))}),lt.length>0&&(Bt=[...new Set(lt)])}return c.jsx("div",{"data-field-name":rt,"data-form-renderer":"field-wrapper",children:c.jsx(un,{field:ye,value:Oe[rt],error:pe[rt]||je>0?te[rt]:void 0,onChange:lt=>xt(rt,lt),onBlur:()=>ze(rt),disabled:de||!Vt(He)||er||!!De.disabled,readOnly:sr(He,!!De.readOnly),isRequired:pn(He),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:rt,buttonResponses:we,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:Ae,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,scopedFormValues:Ve,scopedFieldNameMap:Le,excludedOptionValues:Bt,hideTableRowControls:x})},ye.id)};return c.jsx("div",{className:"space-y-3 mt-3",children:z.map((De,at)=>{const Ht={},Le={};Z.forEach(Bt=>{const lt=et(Bt),vt=Gr(lt,H,De);Ht[vt]=lt,Le[vt]=Oe[vt]});const Ve=da(Ht),we=ia(H,De,Z,Oe),Ae=Q?.heading!=null?bs(Q,at+1):null,He=ne[`${H}__${De}`],rt=He!=null?{...tr,documentId:He}:tr,fe=Z.map(Bt=>Ne(Bt,De,at,Ht,Le,Ve,rt)).filter(Boolean),ye=Ce?.section?.collapsible===!0,dt=c.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:we,title:we?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:Bt=>{Bt.preventDefault(),Bt.stopPropagation(),aa(H,De)},children:c.jsx(Go,{className:"h-5 w-5","aria-hidden":!0})}),Wt=c.jsxs(c.Fragment,{children:[!ye&&c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Ae?c.jsx("p",{className:"text-sm font-medium text-foreground",children:Ae}):c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Entry ",at+1]}),dt]}),fe]});return c.jsx("div",{className:"rounded-md border p-3 space-y-3",children:Ce?c.jsx(kc,{legend:Ce.section.heading?.enabled?bs(Ce.section,at+1):Ce.section.name,collapsible:Ce.section.collapsible,defaultCollapsed:Ce.section.defaultCollapsed,headerActions:ye?dt:void 0,onCollapsedChange:Bt=>Wc(Ce.section.id,De,Bt),children:Wt}):Wt},`${_.id}-${De}`)})})},[F,V,ne,et,mn,Gr,ia,Oe,pe,je,te,xt,ze,Vt,er,pn,Br,$e,_r,Nr,At,Dr,We,j,m,tr,br,qt,q.fields,be,Ar,wt,da,aa,x,Dt,oe,ee,M]);return c.jsx("div",{className:k?B("relative",d):B(ga,P&&"dark",d),style:xs,"data-form-renderer":k?void 0:"root",children:c.jsxs("div",{className:"relative",children:[M&&c.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:c.jsx(Pn,{})}),c.jsx("form",{onSubmit:Nr,className:f?B("w-full min-w-0"):B("space-y-6 pb-[100px] w-full min-w-0",ea[Zi]),"data-form-renderer":"form","data-form-renderer-layout":F?"grid":"stack",children:c.jsxs(AN,{value:ta,children:[Er&&q.steps&&c.jsx(Ok,{steps:q.steps,currentStep:Te,completedSteps:Ue,onStepClick:ur}),c.jsx(_a.Provider,{value:{gridStretch:F},children:F?c.jsx("div",{className:f?"w-full min-w-0":"grid w-full min-w-0",style:{display:"grid",gridTemplateRows:pP,gridTemplateColumns:`repeat(${Y}, 1fr)`,rowGap:he,columnGap:st},"data-form-renderer":"grid",children:fP.map(_=>Array.from({length:Y},(H,z)=>{const Z=Gc(_);if(!Z)return null;if(Rc(_,z))return c.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:z+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${z}`);if(bT(_,z,xy,hn)){const we=vT(_,z,hn);return we&&wT(_,z,we,oa(we.run.section,we.addMoreMeta?.blockId))?null:c.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:z+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`section-border-cover-${_}-${z}`)}const Q=hn.get(`${_}-${z}`);if(Q){const we=Q.renderFields.filter(lt=>Tr(lt));if(we.length===0)return null;const Ae=Q.addMoreMeta,He=Ae!=null?On.find(lt=>lt.addMoreFieldName===Ae.addMoreFieldName)?.linkedFields??[]:[],rt=Ae!=null?ia(Ae.addMoreFieldName,Ae.blockId,He,Oe):!1,fe=Q.run.section,Fe=Ae?.blockId,ye=oa(fe,Fe),dt=fe.collapsible&&ye?1:Q.rowSpan,Wt=Gc(Q.anchorRow,dt)??Z,Bt=Ae!=null?c.jsx("button",{type:"button",className:B("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",f&&"text-red-600 hover:bg-red-500/10"),disabled:rt,title:rt?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:lt=>{lt.preventDefault(),lt.stopPropagation(),aa(Ae.addMoreFieldName,Ae.blockId)},children:c.jsx(Go,{className:"h-5 w-5","aria-hidden":!0})}):void 0;return c.jsx("div",{className:B("min-h-0 min-w-0",!(fe.collapsible&&ye)&&"self-stretch"),style:{gridRow:Wt,gridColumn:`${z+1} / span ${Q.colSpan}`},"data-form-renderer":"grid-cell","data-form-renderer-config-section-border-cell":!0,children:c.jsx(kc,{legend:Q.legend,className:fe.collapsible&&ye?void 0:"h-full",collapsible:fe.collapsible,defaultCollapsed:fe.defaultCollapsed,headerActions:Bt,onCollapsedChange:lt=>Wc(fe.id,Fe,lt),children:c.jsx("div",{className:"grid w-full min-w-0",style:{gridTemplateColumns:`repeat(${Y}, 1fr)`,gridTemplateRows:`repeat(${Q.rowSpan}, minmax(${String(Tt).endsWith("px")?Tt:In}, auto))`,rowGap:he,columnGap:st},children:we.map(lt=>{const vt=et(lt),rr=Io.scopeByFieldName[vt],jr=rr?.scopedFieldNameMap?.[vt]||vt,Kr=(lt.position?.order??Q.anchorRow)-Q.anchorRow,zr=lt.position?.column??1,{rowSpan:qr,columnSpan:se}=gs([lt],Y),Ie=Ae!=null?ne[`${Ae.addMoreFieldName}__${Ae.blockId}`]:void 0,me=Ie!=null?{...tr,documentId:Ie}:tr;return c.jsx("div",{"data-field-name":vt,"data-form-renderer":"field-wrapper",className:"min-h-0 min-w-0",style:{gridRow:`${Kr+1} / span ${qr}`,gridColumn:`${zr} / span ${se}`,...xn(lt)},children:c.jsx(un,{field:Qn(lt),value:Oe[vt],error:pe[vt]||je>0?te[vt]:void 0,onChange:Ke=>xt(vt,Ke),onBlur:()=>ze(vt),disabled:(lt.type==="table"||lt.type==="billingGrid")&&a==="fill"?!1:de||!Vt(jr)||er||!!lt.disabled,readOnly:(lt.type==="table"||lt.type==="billingGrid")&&a==="fill"?!1:sr(jr,!!lt.readOnly),isRequired:pn(jr),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:vt,buttonResponses:rr?.scopedButtonResponses??$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:me,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,scopedFormValues:rr?.scopedFormValues,scopedFieldNameMap:rr?.scopedFieldNameMap,excludedOptionValues:rr?.excludedOptionValues,hideTableRowControls:x})},lt.id)})})})},`section-border-${Q.run.section.id}-${_}-${z}-${Ae?.blockId??"base"}`)}const le=vg(_,z,Cs,Tr).filter(we=>!(et(we)?.includes("__addmore__")&&xy.has(`${_}-${z}`)));if(le.length===0){const we=As[`${_}-${z}`];if(we){const Ae=q.fields.find(fe=>fe.type==="addmore"&&et(fe)===we.addMoreFieldName),He=Ae!=null?mn(Ae):[],rt=ia(we.addMoreFieldName,we.blockId,He,Oe);return c.jsx("div",{className:"min-h-0 min-w-0 flex flex-col items-center justify-center",style:{gridRow:Z,gridColumn:z+1},"data-form-renderer":"grid-cell","data-form-renderer-add-more-remove":!0,children:c.jsx("button",{type:"button",className:B("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",f&&"text-red-600 hover:bg-red-500/10"),disabled:rt,title:rt?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:fe=>{fe.preventDefault(),fe.stopPropagation(),aa(we.addMoreFieldName,we.blockId)},children:c.jsx(Go,{className:"h-5 w-5","aria-hidden":!0})})},`add-more-remove-${_}-${z}`)}return c.jsx("div",{className:"min-w-0",style:{pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${z}`)}const Ce=le[0],{rowSpan:Ne,columnSpan:De}=gs(le,Y),at=Gc(_,Ne)??Z;if(le.length===1&&Ce.type==="section"){const we=q.fields.filter(Ae=>Ae.parentId===Ce.id&&Ae.position!=null).sort((Ae,He)=>{const rt=typeof Ae.position?.order=="number"?Ae.position.order:0,fe=typeof He.position?.order=="number"?He.position.order:0;return rt-fe});return c.jsx("div",{className:"min-w-0 min-h-0 w-full overflow-hidden flex flex-col h-full",style:{gridRow:at,gridColumn:`${z+1} / span ${De}`,...xn(Ce)},"data-form-renderer":"grid-cell",children:c.jsx(Hh,{field:Ce,children:we.map(Ae=>{const He=Ae.name||Ae.key||Ae.id,rt=Ae.hidden===!0;return wt(Ae)&&(Ar(He)||!rt&&He)?c.jsx("div",{"data-field-name":He,"data-form-renderer":"field-wrapper",children:c.jsx(un,{field:Qn(Ae),value:Oe[He],error:pe[He]||je>0?te[He]:void 0,onChange:Fe=>xt(He,Fe),onBlur:()=>ze(He),disabled:de||!Vt(He)||er||!!Ae.disabled,readOnly:sr(He,!!Ae.readOnly),isRequired:pn(He),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:He,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x})},Ae.id):null})})},Ce.id)}const Ht=yg(le),Le=le.some(we=>["file","camera","photoChoice","addmore","table","billingGrid"].includes(we.type)),Ve=c.jsx("div",{className:B("flex min-h-0 w-full flex-1 gap-3",Ht==="row"?"flex-row items-stretch":"flex-col items-stretch"),children:le.map(we=>{const Ae=we.name||we.key||we.id,He=we.type==="sectionHeading",rt=Io.scopeByFieldName[Ae],fe=rt?.scopedFieldNameMap?.[Ae]||Ae,Fe=rt?.blockDocumentId!=null?{...tr,documentId:rt.blockDocumentId}:tr,ye=we.appearance?.hideLabel??we.properties?.hideLabel??!1,dt=we.type==="table"||we.type==="billingGrid"?we.properties?.minWidth:void 0;return c.jsx("div",{"data-field-name":Ae,"data-form-renderer":"field-wrapper",className:B("flex min-h-0 min-w-0 flex-1 flex-col",jo(we),He&&"items-center justify-center",ye&&"items-center"),style:{...dt?{minWidth:dt}:{},...xn(we)},children:c.jsx(un,{field:Qn(we),value:Oe[Ae],error:pe[Ae]||je>0?te[Ae]:void 0,onChange:Wt=>xt(Ae,Wt),onBlur:()=>ze(Ae),disabled:(we.type==="table"||we.type==="billingGrid")&&a==="fill"?!1:de||!Vt(fe)||er||!!we.disabled,readOnly:(we.type==="table"||we.type==="billingGrid")&&a==="fill"?!1:sr(fe,!!we.readOnly),isRequired:pn(fe),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:Ae,buttonResponses:rt?.scopedButtonResponses??$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:Fe,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,scopedFormValues:rt?.scopedFormValues,scopedFieldNameMap:rt?.scopedFieldNameMap,excludedOptionValues:rt?.excludedOptionValues,hideTableRowControls:x})},we.id)})});return c.jsx("div",{className:B(wd(le),"self-stretch",Le?"overflow-visible":"overflow-hidden"),style:{gridRow:at,gridColumn:`${z+1} / span ${De}`,...xn(le[0])},"data-form-renderer":"grid-cell","data-field-name":le.map(we=>we.name||we.key||we.id).join(","),children:Ve},le.map(we=>we.id).join("-"))}))}):c.jsx("div",{className:f?"":"space-y-4","data-form-renderer":"stack",children:kt.map(_=>{if(!Tr(_))return null;const H=mP.find(Z=>Z.kind==="border"&&Z.fields.some(Q=>Q.id===_.id));if(H)return H.fields[0]?.id!==_.id?null:c.jsx(kc,{legend:bs(H.run.section,0),collapsible:H.run.section.collapsible,defaultCollapsed:H.run.section.defaultCollapsed,onCollapsedChange:Z=>Wc(H.run.section.id,void 0,Z),children:H.fields.map(Z=>{const Q=et(Z);return!Q||!Tr(Z)?null:c.jsxs("div",{"data-field-name":Q,"data-form-renderer":"field-wrapper",style:xn(Z),children:[c.jsx(un,{field:Qn(Z),value:Oe[Q],error:pe[Q]||je>0?te[Q]:void 0,onChange:le=>xt(Q,le),onBlur:()=>ze(Q),disabled:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:de||!Vt(Q)||er||!!Z.disabled,readOnly:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:sr(Q,!!Z.readOnly),isRequired:pn(Q),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:Q,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),Z.type==="addmore"&&pa(Z)]},Z.id)})},`stack-border-${H.run.section.id}-${_.id}`);if(!_.parentId){const Z=kt.filter(le=>!le.parentId&&Tr(le)&&qi(le)===qi(_)),Q=Tc(Z).slice(0,2);if(Q.length>1&&Q[0].id!==_.id)return null;if(Q.length>1){const le=yg(Q);return c.jsx("div",{"data-form-renderer":"shared-cell-stack",className:B("flex w-full min-w-0 gap-3",le==="row"?"flex-row items-stretch":"flex-col"),children:Q.map(Ce=>{const Ne=Ce.name||Ce.key||Ce.id;return c.jsxs("div",{"data-field-name":Ne,"data-form-renderer":"field-wrapper",className:B("min-w-0 flex-1 flex flex-col",jo(Ce)),style:xn(Ce),children:[c.jsx(un,{field:Qn(Ce),value:Oe[Ne],error:pe[Ne]||je>0?te[Ne]:void 0,onChange:De=>xt(Ne,De),onBlur:()=>ze(Ne),disabled:(Ce.type==="table"||Ce.type==="billingGrid")&&a==="fill"?!1:de||!Vt(Ne)||er||!!Ce.disabled,readOnly:(Ce.type==="table"||Ce.type==="billingGrid")&&a==="fill"?!1:sr(Ne,!!Ce.readOnly),isRequired:pn(Ne),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:Ne,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),Ce.type==="addmore"&&pa(Ce)]},Ce.id)})},Q.map(Ce=>Ce.id).join("-"))}}if(_.type==="section"){const Z=q.fields.filter(Q=>Q.parentId===_.id&&Q.position!=null).sort((Q,le)=>{const Ce=typeof Q.position?.order=="number"?Q.position.order:0,Ne=typeof le.position?.order=="number"?le.position.order:0;return Ce-Ne});return c.jsx(Hh,{field:_,children:Z.map(Q=>{const le=Q.name||Q.key||Q.id,Ce=Q.hidden===!0;return wt(Q)&&(Ar(le)||!Ce&&le)?c.jsxs("div",{"data-field-name":le,"data-form-renderer":"field-wrapper",style:xn(Q),children:[c.jsx(un,{field:Qn(Q),value:Oe[le],error:pe[le]||je>0?te[le]:void 0,onChange:De=>xt(le,De),onBlur:()=>ze(le),disabled:de||!Vt(le)||er||!!Q.disabled,readOnly:sr(le,!!Q.readOnly),isRequired:pn(le),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:le,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),Q.type==="addmore"&&pa(Q)]},Q.id):null})},_.id)}const z=_.name||_.key||_.id;return c.jsxs("div",{"data-field-name":z,"data-form-renderer":"field-wrapper",style:xn(_),children:[c.jsx(un,{field:Qn(_),value:Oe[z],error:pe[z]||je>0?te[z]:void 0,onChange:Z=>xt(z,Z),onBlur:()=>ze(z),disabled:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:de||!Vt(z)||er||!!_.disabled,readOnly:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:sr(z,!!_.readOnly),isRequired:pn(z),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:z,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),_.type==="addmore"&&pa(_)]},_.id)})})}),u]})})]})})};function Lc(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Mg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function kT(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,f)=>{if(!l||typeof l!="object")return null;const p={...l};if(l.fieldType&&!p.type&&(p.type=l.fieldType),l.fieldKey&&!p.key&&!p.name&&(p.key=l.fieldKey,p.name=l.fieldKey),typeof l.positionOrder=="number"&&!isNaN(l.positionOrder)?p.order=l.positionOrder:p.order=f,(typeof p.order!="number"||isNaN(p.order))&&(p.order=f),l.options&&typeof l.options=="string")try{p.options=JSON.parse(l.options)}catch{}if(l.metadata&&typeof l.metadata=="string")try{p.metadata=JSON.parse(l.metadata)}catch{}return p}).filter(l=>l!=null).sort((l,f)=>{const p=typeof l.order=="number"?l.order:0,m=typeof f.order=="number"?f.order:0;return p-m});n.forEach((l,f)=>{(!l||typeof l.order!="number"||isNaN(l.order))&&(l.order=f)});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 d=l=>{let f={...l};if(l.conditionExpression&&typeof l.conditionExpression=="string")try{f={...l,conditionExpression:JSON.parse(l.conditionExpression)}}catch{}if(f.targetFieldId){const p=s.find(m=>m._id===f.targetFieldId||m.id===f.targetFieldId||m.fieldKey===f.targetFieldId);if(p){const m=p.key||p.fieldKey||p.name,g=p._id||p.id||f.targetFieldId;f.targetFieldKey=m,f.targetField=m,f.targetFieldById=g}}return f},u={id:r._id,name:r.name,description:r.description??"",version:r.version,status:r.status,fields:s.map((l,f)=>{const p=l,m=typeof l.metadata=="object"&&l.metadata!==null?l.metadata:{},g=m.hidden===!0||l.hidden===!0,h={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(g&&(h.hidden=!0),h.id||(h.id=h.key||h.name),h.key||(h.key=h.id||h.name),h.name||(h.name=h.key||h.id),l.isRequired!==void 0&&(h.required=l.isRequired),l.placeholder&&(h.placeholder=l.placeholder),l.options&&Array.isArray(l.options)&&(h.options=l.options),l.apidata&&(h.apidata=l.apidata),p.appearance&&typeof p.appearance=="object"&&!Array.isArray(p.appearance)&&Object.keys(p.appearance).length>0&&(h.appearance=Lc(p.appearance)),p.ui!==void 0&&(h.ui=Lc(p.ui)),p.visibility!==void 0&&(h.visibility=Lc(p.visibility)),m.disabled!==void 0&&(h.disabled=m.disabled),m.readOnly!==void 0&&(h.readOnly=m.readOnly),m.hideLabel!==void 0&&(h.hideLabel=m.hideLabel,h.properties||(h.properties={}),h.properties.hideLabel=m.hideLabel,h.appearance||(h.appearance={}),h.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 A=l.validationRules,I={...m};if(A.fileSize!==void 0&&(I.maxSize=A.fileSize),A.fileType&&Array.isArray(A.fileType)){const T=[];A.fileType.forEach(W=>{const X=W.startsWith(".")?W:`.${W}`;T.push(X),X===".csv"?T.push("text/csv"):X===".xls"?T.push("application/vnd.ms-excel"):X===".xlsx"&&T.push("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}),I.accept=T}h.metadata=I,I.maxSize!==void 0&&(h.maxSize=I.maxSize),I.accept!==void 0&&(h.accept=I.accept)}else if(m&&Object.keys(m).length>0){if(h.metadata=m,(l.type==="toggle"||l.fieldType==="toggle")&&(m.onValue!==void 0&&(h.onValue=m.onValue),m.offValue!==void 0&&(h.offValue=m.offValue),m.onText!==void 0&&(h.onText=m.onText),m.offText!==void 0&&(h.offText=m.offText)),(l.type==="button"||l.fieldType==="button")&&m.action==="download"&&m.downloadApiEndpoint&&typeof m.downloadApiEndpoint=="string"){let A=m.downloadApiEndpoint;A=A.replace(/\{ctx:([^}]+)\}/g,(I,T)=>{const W=t[T];return W!==void 0?String(W):I}),m.downloadApiEndpoint=A,h.metadata=m,h.downloadApiEndpoint=A}if((l.type==="button"||l.fieldType==="button")&&m.action==="submit"){const A=h.properties||{};m.submitAction!==void 0&&(A.submitAction=m.submitAction),m.submitApiMethod!==void 0&&(A.submitApiMethod=m.submitApiMethod),m.apiBodyStructure!==void 0&&(A.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(A.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(A.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiBodyFields!==void 0&&(A.apiBodyFields=m.apiBodyFields),m.buttonText!==void 0&&(A.buttonText=m.buttonText),m.action!==void 0&&(A.action=m.action),m.variant!==void 0&&(A.variant=m.variant),m.hideLabel!==void 0&&(A.hideLabel=m.hideLabel),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint&&(A.apiEndpoint=l.apidata.apiEndpoint),h.properties=A}if((l.type==="button"||l.fieldType==="button")&&(m.action==="upload"||m.action==="custom")){const A=h.properties||{};m.action!==void 0&&(A.action=m.action),m.buttonText!==void 0&&(A.buttonText=m.buttonText),m.variant!==void 0&&(A.variant=m.variant),m.hideLabel!==void 0&&(A.hideLabel=m.hideLabel),m.uploadAction!==void 0&&(A.uploadAction=m.uploadAction),m.uploadApiEndpoint!==void 0&&(A.uploadApiEndpoint=m.uploadApiEndpoint),m.uploadApiMethod!==void 0&&(A.uploadApiMethod=m.uploadApiMethod),m.apiBodyStructure!==void 0&&(A.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(A.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(A.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiFieldMapping!==void 0&&(A.apiFieldMapping=m.apiFieldMapping),m.apiQueryParams!==void 0&&(A.apiQueryParams=m.apiQueryParams),m.apiBodyFields!==void 0&&(A.apiBodyFields=m.apiBodyFields),m.apiHeaders!==void 0&&(A.apiHeaders=m.apiHeaders),h.properties=A}if(l.type==="status"||l.fieldType==="status"){const A=h.properties||{};if(m.source!==void 0&&(A.source=m.source),m.statuses!==void 0&&(A.statuses=m.statuses),m.dataPath!==void 0&&(A.dataPath=m.dataPath),m.showStatusText!==void 0&&(A.showStatusText=m.showStatusText),m.statusTextPath!==void 0&&(A.statusTextPath=m.statusTextPath),m.showCurrentIndicator!==void 0&&(A.showCurrentIndicator=m.showCurrentIndicator),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint){let I=l.apidata.apiEndpoint;I=I.replace(/\{ctx:([^}]+)\}/g,(T,W)=>{const X=t[W];return X!==void 0?String(X):T}),A.apiEndpoint=I,A.source===void 0&&(A.source="api")}l.apidata?.apiMethod!==void 0&&(A.apiMethod=l.apidata.apiMethod),h.properties=A}if(l.type==="addmore"||l.fieldType==="addmore"){const A=h.properties||{};m.linkedFieldNames!==void 0&&(A.linkedFieldNames=m.linkedFieldNames),m.linkedSectionIds!==void 0&&(A.linkedSectionIds=m.linkedSectionIds),m.linkedFieldAllowDuplicate!==void 0&&(A.linkedFieldAllowDuplicate=m.linkedFieldAllowDuplicate),m.buttonText!==void 0&&(A.buttonText=m.buttonText),m.variant!==void 0&&(A.variant=m.variant),m.size!==void 0&&(A.size=m.size),m.hideLabel!==void 0&&(A.hideLabel=m.hideLabel),h.properties=A}if(l.type==="selectablelist"||l.fieldType==="selectablelist"){const A=h.properties||{};m.submitFieldMapping!==void 0&&(A.submitFieldMapping=m.submitFieldMapping),m.displayFields!==void 0&&(A.displayFields=m.displayFields),m.displayFieldsSeparator!==void 0&&(A.displayFieldsSeparator=m.displayFieldsSeparator),m.dataSourceContextKey!==void 0&&(A.dataSourceContextKey=m.dataSourceContextKey),m.showSelectAll!==void 0&&(A.showSelectAll=m.showSelectAll),m.selectAllByDefault!==void 0&&(A.selectAllByDefault=m.selectAllByDefault),h.properties=A}}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"&&(h.validationRules=l.validationRules),typeof l.order=="number"&&(h.order=l.order);const y=l,w=Mg(y.position),v=l.metadata&&typeof l.metadata=="object"&&!Array.isArray(l.metadata)?l.metadata:{},x=Mg(y.layout),P={order:typeof y.positionOrder=="number"?y.positionOrder:l.order??f,column:typeof w.column=="number"?w.column:typeof y.positionColumn=="number"?y.positionColumn:1,columnSpan:typeof w.columnSpan=="number"?w.columnSpan:typeof w.width=="number"?w.width:typeof y.positionWidth=="number"?y.positionWidth:1,rowSpan:typeof w.rowSpan=="number"?w.rowSpan:typeof y.positionRowSpan=="number"?y.positionRowSpan:1},k=ko(w,{cellSlotIndex:y.cellSlotIndex??x.cellSlotIndex,stackSlot:v.stackSlot??x.stackSlot});typeof k=="number"&&(P.cellSlot=k);const N=w.cellGroupId??x.cellGroupId;typeof N=="string"&&(P.cellGroupId=N);const C=hs(w)??hs(x)??(v.stackDirection==="horizontal"||x.stackDirection==="horizontal"?"row":v.stackDirection==="vertical"||x.stackDirection==="vertical"?"stack":void 0);return(C==="row"||C==="stack")&&(P.sharedCellLayout=C),h.position=P,l.conditions&&Array.isArray(l.conditions)&&(h.conditions=l.conditions),h}).filter(l=>l!=null).sort((l,f)=>{const p=typeof l.order=="number"?l.order:0,m=typeof f.order=="number"?f.order:0;return p-m}),config:{...i,layout:o,...r.rules&&r.rules.length>0&&{rules:r.rules.map(d)},...r.clientMapping&&Object.keys(r.clientMapping).length>0&&{clientMapping:r.clientMapping}},...r.rules&&r.rules.length>0&&{rules:r.rules.map(d)},createdAt:"",updatedAt:"",moduleId:""};return Yi(u)}var Xi="Tabs",[TT]=vr(Xi,[Li]),Lg=Li(),[FT,Dc]=TT(Xi),Dg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:a,activationMode:d="automatic",...u}=e,l=ro(a),[f,p]=Zr({prop:n,onChange:o,defaultProp:s??"",caller:Xi});return c.jsx(FT,{scope:r,baseId:on(),value:f,onValueChange:p,orientation:i,dir:l,activationMode:d,children:c.jsx(Be.div,{dir:l,"data-orientation":i,...u,ref:t})})});Dg.displayName=Xi;var Bg="TabsList",$g=b.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...o}=e,s=Dc(Bg,r),i=Lg(r);return c.jsx(Om,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:n,children:c.jsx(Be.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});$g.displayName=Bg;var jg="TabsTrigger",zg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:o=!1,...s}=e,i=Dc(jg,r),a=Lg(r),d=Hg(i.baseId,n),u=Wg(i.baseId,n),l=n===i.value;return c.jsx(Im,{asChild:!0,...a,focusable:!o,active:l,children:c.jsx(Be.button,{type:"button",role:"tab","aria-selected":l,"aria-controls":u,"data-state":l?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...s,ref:t,onMouseDown:Me(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?i.onValueChange(n):f.preventDefault()}),onKeyDown:Me(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&i.onValueChange(n)}),onFocus:Me(e.onFocus,()=>{const f=i.activationMode!=="manual";!l&&!o&&f&&i.onValueChange(n)})})})});zg.displayName=jg;var Ug="TabsContent",Vg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:o,children:s,...i}=e,a=Dc(Ug,r),d=Hg(a.baseId,n),u=Wg(a.baseId,n),l=n===a.value,f=b.useRef(l);return b.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),c.jsx(xr,{present:o||l,children:({present:p})=>c.jsx(Be.div,{"data-state":l?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":d,hidden:!p,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:p&&s})})});Vg.displayName=Ug;function Hg(e,t){return`${e}-trigger-${t}`}function Wg(e,t){return`${e}-content-${t}`}var PT=Dg,OT=$g,IT=zg,MT=Vg;function Rg({className:e,...t}){return c.jsx(PT,{"data-slot":"tabs",className:B("flex flex-col gap-2",e),...t})}function Gg({className:e,...t}){return c.jsx(OT,{"data-slot":"tabs-list",className:B("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function Kg({className:e,...t}){return c.jsx(IT,{"data-slot":"tabs-trigger",className:B("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 qg({className:e,...t}){return c.jsx(MT,{"data-slot":"tabs-content",className:B("flex-1 outline-none",e),...t})}function dr({className:e="",...t}){return c.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 LT({className:e=""}){return c.jsxs("div",{className:`flex flex-col gap-4 ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:[c.jsxs("div",{className:"flex w-full border-b border-neutral-200 dark:border-neutral-700 gap-0",children:[c.jsx(dr,{className:"h-10 w-24 rounded-none"}),c.jsx(dr,{className:"h-10 w-28 rounded-none ml-1"}),c.jsx(dr,{className:"h-10 w-20 rounded-none ml-1"})]}),c.jsxs("div",{className:"mt-4 flex flex-col gap-4 py-4",children:[c.jsx(dr,{className:"h-4 w-32"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-40"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-36"}),c.jsx(dr,{className:"h-24 w-full"})]})]})}function DT(){return c.jsxs("div",{className:"flex flex-col gap-4 py-4","data-form-renderer":"form-loading-skeleton",children:[c.jsx(dr,{className:"h-4 w-28"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-36"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-24"}),c.jsx(dr,{className:"h-20 w-full"})]})}const BT=3e4,$T=10*6e4,jT=9e4,zT=15*6e4;function UT(e){return e!=null&&"on_success"in e&&e.on_success!=null}function VT(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 Yg=({getWorkflowState:e,moduleId:t,tenantId:r,submissionContext:n,initialValues:o={},getAuthHeaders:s,onSuccess:i,bootstrapFeatureId:a,subjectUserId:d,viewStepId:u,clientId:l,className:f,onWorkflowSubmitResult:p,viewerContext:m,getViewerContext:g,dark:h=!1,themeVars:y})=>{const w=gn.useQueryClient(),v=S.useMemo(()=>[d??"",u??"",l??""],[d,u,l]),x=S.useMemo(()=>({moduleId:t,tenantId:r,subjectUserId:d,viewStepId:u,clientId:l}),[t,r,d,u,l]),[E,P]=S.useState([]),[k,N]=S.useState(null),[C,A]=S.useState(null),[I,T]=S.useState(null),[W,X]=S.useState({}),O=S.useRef(null),j=S.useRef(null),M=S.useRef(null),D=S.useRef(null),L=S.useMemo(()=>E&&Array.isArray(E)?E.filter(ae=>ae.feature_id):[],[E]),U=gn.useQuery({queryKey:["workflow-steps",t,a??"",r??"",v[0],v[1],v[2]],queryFn:()=>e({...x,featureId:a}),staleTime:BT,gcTime:$T}),$=U.isPending,ie=U.error?U.error instanceof Error?U.error.message:"Failed to load workflow steps":null;S.useEffect(()=>{const ae=U.data;if(!ae||E.length>0)return;const ve=ae.steps&&Array.isArray(ae.steps)?ae.steps:[];P(ve);const Ye=ve.filter(ct=>ct.feature_id);if(Ye.length>0){const ct=ae.current_step_id,Ge=ct&&Ye.some(Kt=>Kt.step_id===ct);N(Ge?ct:Ye[0].step_id)}},[U.data,E.length,a]);const V=S.useMemo(()=>{if(!k)return;const ae=E.find(Ye=>Ye.step_id===k),ve=O.current===k;return ae?.feature_id??(ve?D.current:void 0)??void 0},[k,E]),K=gn.useQuery({queryKey:["workflow-step",t,V??"",r??"",v[0],v[1],v[2]],queryFn:()=>e({...x,featureId:V}),enabled:!!V,staleTime:jT,gcTime:zT,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),J=K.isPending,ce=K.error?K.error instanceof Error?K.error.message:"Failed to load form":null;S.useEffect(()=>{!K.data||O.current===k||(A(K.data),T(null),O.current=null,D.current=null)},[K.data,k]),S.useEffect(()=>{T(ce)},[ce]),S.useEffect(()=>{V===void 0&&O.current!==k&&(A(null),T(null),O.current=null,D.current=null)},[V,k]);const ne=S.useMemo(()=>{const ae=C?.form;if(!ae)return null;const ve=(r??Tn()??"").trim()||"default",Ye=Pg({scope:ve,formId:ae._id,version:ae.version});return Ye?.value?Ye.value:kT(C,n)},[C,n,r]),G=S.useMemo(()=>{const ae=C?.BFF_submit_api;if(!ae?.url)return;let ve=ae.url;if(ve.startsWith("http://")||ve.startsWith("https://"))try{const Ge=new URL(ve);ve=Ge.pathname+Ge.search}catch{}const Ye=s?.()??{},ct={...ae.headers||{},"Content-Type":"application/json",...Ye};return{...ae,url:ve,headers:ct}},[C?.BFF_submit_api,s]),ee=S.useMemo(()=>ne?{...ne,status:"published",...G&&{BFF_submit_api:G}}:null,[ne,G]);S.useEffect(()=>{if(!ne?.id)return;const ae=(r??Tn()??"").trim()||"default";Og({scope:ae,formId:ne.id,version:ne.version},ne)},[ne,r]);const Pe=S.useMemo(()=>{if(!ne)return null;const ae=_s({config:ne.config,layout:ne.layout},null);if(!ae)return null;const ve=ae.rows,Ye=ae.columns,ct={verticalSpacing:ae.verticalSpacing??ae.spacing??"16px",horizontalSpacing:ae.horizontalSpacing??ae.spacing??"16px",rowHeight:ae.rowHeight??In};let Ge=1;if(Array.isArray(ne.fields))for(const Je of ne.fields){const q=Je?.position,$e=typeof q?.order=="number"?q.order:0,gt=typeof q?.rowSpan=="number"?q.rowSpan:1;Ge=Math.max(Ge,$e+gt)}return{rows:Math.min(ve,Math.max(1,Ge)),columns:Ye,verticalSpacing:ct.verticalSpacing,horizontalSpacing:ct.horizontalSpacing,rowHeight:ct.rowHeight}},[ne]),oe=S.useMemo(()=>{const ve=ee?.config?.theme?.cssVariables;if(!(!ve&&!y))return{...ve??{},...y??{}}},[ee?.config,y]),re=S.useCallback(()=>{w.invalidateQueries({queryKey:["workflow-steps",t]}),w.invalidateQueries({queryKey:["workflow-step",t]})},[w,t]),be=S.useCallback(ae=>{if(UT(ae)){const Ge=ae.on_success,Kt=Ge?.action;if(Kt==="redirect"&&Ge?.redirect_url){const Je=VT(Ge.redirect_url.trim(),n);window.location.href=Je;return}if(Kt==="move"){const Je=Ge?.next_step_id,q=Ge?.next_step_form;if(Je&&q){O.current=null,D.current=null;const $e=q.featureId??Ge?.next_step_form_id??q._id;w.removeQueries({queryKey:["workflow-step",t,$e,r??"",v[0],v[1],v[2]]}),re(),P(gt=>gt.some(te=>te.step_id===Je)?gt:[...gt,{step_id:Je,step_name:q.name||"Next step",feature_id:$e}]),A(null),N(Je),i?.();return}return}if(Kt==="stay"){re(),i?.();return}}const ve=ae;ve.steps&&Array.isArray(ve.steps)&&P(ve.steps);const Ye=(ve.steps&&Array.isArray(ve.steps)?ve.steps:E).filter(Ge=>Ge.feature_id),ct=ve.current_step_id;ct&&Ye.some(Ge=>Ge.step_id===ct)?N(ct):Ye.length>0&&N(Ye[0].step_id),A(null),re(),i?.(),p?.(ve)},[w,t,r,i,p,E,n,v,re]),de=S.useCallback(async ae=>C?.BFF_submit_api?(i?.(),{success:!0,message:"Saved successfully"}):{success:!1,message:"Submit not configured"},[C?.BFF_submit_api,i]),ot=S.useCallback((ae,ve)=>{},[]),Se=S.useCallback(ae=>{},[]);if($)return c.jsx(LT,{className:f});if(ie)return c.jsx("div",{className:B("rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",f),children:ie});if(L.length===0)return c.jsx("div",{className:B("py-12 text-center text-sm text-muted-foreground",f),children:"No workflow steps configured."});const xe=C?.step_blocked_message;return c.jsx("div",{className:B(ga,h&&"dark","flex flex-col gap-4",f),style:oe,"data-form-renderer":"workflow-steps-view",children:c.jsxs(Rg,{value:k??"",onValueChange:ae=>N(ae),children:[c.jsx(Gg,{className:"w-full justify-start border-b rounded-none h-auto p-0 bg-transparent gap-0","data-form-renderer":"workflow-tabs",children:L.map(ae=>c.jsx(Kg,{value:ae.step_id,className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none","data-form-renderer":"workflow-tab",children:ae.step_name},ae.step_id))}),L.map(ae=>c.jsx(qg,{value:ae.step_id,className:"mt-4 outline-none",children:ae.step_id!==k?null:J?c.jsx(DT,{}):I?c.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:I}):xe&&!C?.form?c.jsx("div",{className:B("rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",f),"data-form-renderer":"workflow-step-blocked",children:xe}):ee?.fields?.length?c.jsxs("div",{className:"py-4 [&_*]:box-border",children:[xe?c.jsx("div",{className:B("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 ve=j.current!==k||M.current!==(ee?.id??null);if(k&&ee&&ve){j.current=k,M.current=ee.id??null;const Ye=Nt.getState();Ye.setSchema(ee,{forceReset:!0});const ct=Nt.getState().values;Ye.setValues({...ct,...o})}return null})(),c.jsx(Mc,{schema:ee,gridLayout:Pe,omitRootWrapper:!0,submissionContext:n,initialValues:o,workflowStepId:k??void 0,viewerContext:m,getViewerContext:g,onSubmit:de,onChange:ot,onValidationError:Se,onClose:()=>{},mode:"fill",unstyled:!0,onWorkflowSubmitResult:be,initialExtraSubmitPayload:Object.keys(W).length>0?W:void 0,onExtraSubmitPayloadChange:ve=>{if(ve&&typeof ve=="object"){const Ye={};ve.context_user_id!=null&&(Ye.context_user_id=ve.context_user_id),ve.id!=null&&(Ye.id=ve.id),ve.batch_id!=null&&(Ye.batch_id=ve.batch_id),ve.admission_batch_id!=null&&(Ye.admission_batch_id=ve.admission_batch_id),ve.program_id!=null&&(Ye.program_id=ve.program_id),Object.keys(Ye).length>0&&X(ct=>({...ct,...Ye}))}}},ee.id)]}):c.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No form schema available for this step."})},ae.step_id))]})})};function HT(e){return typeof e=="object"&&e!==null&&"apiEndpoint"in e}function WT({formSchema:e}){const t=S.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((l,f)=>{const p=`field-${l.id}`;if(a.has(l.id)&&s.push({id:`${p}-duplicate-id`,type:"error",message:`Field "${l.label||l.name||`Field ${f+1}`}" has a duplicate ID`,fieldId:l.id}),a.add(l.id),l.name&&i.has(l.name)&&s.push({id:`${p}-duplicate-name`,type:"error",message:`Field "${l.label||l.name}" has a duplicate name: "${l.name}"`,fieldId:l.id}),l.name&&i.add(l.name),(!l.label||l.label.trim()==="")&&s.push({id:`${p}-missing-label`,type:"warning",message:`Field "${l.name||l.id}" is missing a label`,fieldId:l.id}),(!l.name||l.name.trim()==="")&&s.push({id:`${p}-missing-name`,type:"error",message:`Field "${l.label||l.id}" is missing a field name`,fieldId:l.id}),l.name&&!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l.name)&&s.push({id:`${p}-invalid-name`,type:"error",message:`Field "${l.label||l.name}" has an invalid name. Use only letters, numbers, and underscores.`,fieldId:l.id}),["select","multiselect","radio","checkboxgroup"].includes(l.type)){const h=l.properties;(!h?.options||h.options.length===0)&&s.push({id:`${p}-no-options`,type:"warning",message:`Field "${l.label||l.name}" has no options defined`,fieldId:l.id})}l.parentId&&(e.fields.some(y=>y.id===l.parentId)||s.push({id:`${p}-orphaned`,type:"error",message:`Field "${l.label||l.name}" references a non-existent parent`,fieldId:l.id}));const g=(h,y)=>{if(y.has(h))return!0;y.add(h);const w=e.fields.find(v=>v.id===h);return w?.parentId?g(w.parentId,y):!1};l.parentId&&g(l.id,new Set)&&s.push({id:`${p}-circular-reference`,type:"error",message:`Field "${l.label||l.name}" has a circular parent reference`,fieldId:l.id})}),e.config.workflowTrigger?.workflowId&&(e.fields.some(f=>f.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 d=e.fields.filter(l=>!l.parentId),u=new Map;return d.forEach(l=>{const f=l.position.order;u.has(f)||u.set(f,[]),u.get(f).push(l)}),u.forEach((l,f)=>{l.length>3&&s.push({id:`row-${f}-too-many-fields`,type:"warning",message:`Row ${f+1} has ${l.length} fields (maximum recommended is 3)`})}),s},[e]),r=S.useMemo(()=>t.filter(s=>s.type==="error"),[t]),n=S.useMemo(()=>t.filter(s=>s.type==="warning"),[t]),o=S.useMemo(()=>r.length===0,[r]);return{issues:t,errors:r,warnings:n,isValid:o}}function RT({field:e,value:t,allValues:r,validateOnChange:n=!1,validateOnBlur:o=!0,debounceMs:s=Bk}){const[i,a]=S.useState(),[d,u]=S.useState(!1),l=S.useRef(void 0),f=S.useRef(t),p=S.useCallback(async()=>{if(!e.validation||e.validation.length===0){a(void 0);return}u(!0);let w;for(const v of e.validation){const x=Yr(t,v,r);if(typeof x=="string"){w=x;break}}return a(w),u(!1),w},[e.validation,t,r]),m=S.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{p()},s)},[p,s]);S.useEffect(()=>(n&&f.current!==t&&m(),f.current=t,()=>{l.current&&clearTimeout(l.current)}),[t,n,m]);const g=S.useCallback(()=>{o&&p()},[o,p]),h=S.useCallback(()=>{a(void 0)},[]),y=S.useCallback(w=>{a(w)},[]);return{error:i,isValidating:d,validate:p,handleBlur:g,clearError:h,setCustomError:y}}const Xg="—";function Xt(){return{kind:"static",value:Xg}}function GT(){return{currencySymbol:"₹",emptyDisplay:Xg,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:Xt(),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:Xt(),service:{kind:"api",path:"service"},unit_price:{kind:"api",path:"unit_price"},discount_pct:Xt(),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:Xt(),unit_price:{kind:"formula",expression:"SUM('unit_price', 'data')"},discount_pct:Xt(),discount_amount:{kind:"formula",expression:"SUM('discount_amount', 'data')"},net_price:{kind:"formula",expression:"SUM('net_price', 'data')"},tax_pct:Xt(),total:{kind:"formula",expression:"SUM('total', 'data')"}}}},{kind:"static",row:{id:"invoice_discount",label:"Invoice discount",cells:{tariff_type:{kind:"label"},service:Xt(),unit_price:Xt(),discount_pct:Xt(),discount_amount:{kind:"input",inputType:"number"},net_price:Xt(),tax_pct:Xt(),total:Xt()}}},{kind:"static",row:{id:"grand_total",label:"Grand total",cells:{tariff_type:{kind:"label"},service:Xt(),unit_price:Xt(),discount_pct:Xt(),discount_amount:Xt(),net_price:Xt(),tax_pct:Xt(),total:{kind:"formula",expression:"SUM('total', 'data') - cellInRow('invoice_discount', 'discount_amount')"}}}}]}}const KT={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"}},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:GT()}},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"}}}},Jg={padding:"md",showBorder:!1};function Qg(e,t){const r="full";return e?{padding:e.padding??Jg.padding,maxWidth:e.maxWidth??r,showBorder:e.showBorder??Jg.showBorder}:{padding:"md",maxWidth:r,showBorder:!1}}function qT(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 YT(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 XT(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 JT(e){const t=Qg(e.container,e.layout);return B(XT(e.layout),YT(t.maxWidth,e.layout),qT(t.padding),t.showBorder&&"rounded-lg border border-border")}const Ji=1;function QT(){return{version:Ji,layout:"stack",container:{padding:"md",maxWidth:"full",showBorder:!1},dataBindings:[],widgets:[],filterGroups:[]}}function Zg(e){return{...e,config:e.config??{},children:Array.isArray(e.children)?e.children.map(Zg):void 0}}function ZT(e){return{version:Ji,layout:e.layout??"stack",container:Qg(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(Zg):[],filterGroups:Array.isArray(e.filterGroups)?e.filterGroups:[],eventHandlers:e.eventHandlers??[],navigation:e.navigation}}function eF(e){const t=e;return!t||typeof t!="object"?QT():(t.version!==Ji&&(t.version=Ji),ZT(t))}const ey={};let ty=null;function tF(e){ty=e}function rF(){return(ey?.VITE_API_BASE_URL?.trim()||ey?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const vs=_t.create({baseURL:rF()});vs.interceptors.request.use(e=>{const t=Tn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=ty?.();if((!r||Object.keys(r).length===0)&&(r=Ml()),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 ry(e){const t=await vs.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 Bc(e,t,r){const n=await vs.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 $c(e){const{clientId:t,api:r,context:n,filterState:o}=e,s=await vs.post(`/api/page-builder/clients/${t}/data-sources/execute`,{api:r,context:n,filterState:o});return s.data?.data??s.data}function nF(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t)){if(!o.trim())continue;const s=Qe(e,o);s!==void 0&&(r[n]=s)}return r}const ny=S.createContext(null);function oy(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 oF({schema:e,context:t={},clientId:r,nestingDepth:n=0,onAction:o,getWorkflowState:s,parentContext:i,children:a}){const[d,u]=S.useState(()=>i?i.filterGroups:{}),l=S.useRef(d);l.current=d;const[f,p]=S.useState({}),[m,g]=S.useState("idle"),h=S.useRef(null),y=String(r??t.clientId??i?.clientId??""),w=JSON.stringify(t);S.useEffect(()=>{if(i)return;const C=e.prepopulateApi;if(!C?.enabled||!C.api?.path||!y){p({}),g("idle"),h.current=null;return}const A=JSON.stringify({path:C.api.path,method:C.api.method,queryParams:C.api.queryParams,headers:C.api.headers,bodyFields:C.api.bodyFields,auth:C.api.auth,mapping:C.contextMapping,bindings:e.dataBindings,context:w});if(h.current===A)return;let I=!1;return h.current=A,g("loading"),(async()=>{try{const T=oy(e.dataBindings??[],t),W={...t,...T},X=await $c({clientId:y,api:C.api,context:W});if(I)return;const O=nF(X,C.contextMapping);p({...O,prepopulateResponse:X}),g("ready")}catch{I||(p({}),g("error"))}})(),()=>{I=!0}},[i,e.prepopulateApi,e.dataBindings,w,y]);const v=S.useMemo(()=>{if(i)return{...i.context,...t};const C=oy(e.dataBindings??[],t);return{...t,...C,...f}},[i,t,e.dataBindings,f]),x=String(r??v.clientId??i?.clientId??""),E=S.useCallback((C,A,I)=>{u(T=>({...T,[C]:{...T[C]??{},[A]:I}}))},[]),P=S.useCallback(C=>l.current[C]??{},[]),k=S.useCallback((C,A,I,T)=>{(o??i?.onAction)?.({...C,sourceWidgetId:A,event:I,payload:T})},[o,i?.onAction]),N=S.useMemo(()=>({schema:e,context:v,clientId:x,prepopulateStatus:i?.prepopulateStatus??m,nestingDepth:n,onAction:o??i?.onAction,getWorkflowState:s??i?.getWorkflowState,filterGroups:d,setFilterValue:E,getFilterGroup:P,dispatchAction:k}),[e,v,x,m,n,o,i?.onAction,s,i?.getWorkflowState,d,E,P,k]);return c.jsx(ny.Provider,{value:N,children:a})}function Lr(){const e=S.useContext(ny);if(!e)throw new Error("usePageContext must be used within PageContextProvider");return e}const sF=5,sy=1;function Fo(e){return Number.isFinite(e)?Math.min(sF,Math.max(sy,Math.round(e))):sy}function iF(e,t){const r=Fo(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 aF(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):0}function lF(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 iy(e){return lF(100,Fo(e))}function cF(e){const t=e.trim(),r=/^(\d+(?:\.\d+)?)\s*%?$/.exec(t);return r?aF(Number(r[1])):null}function ay(e,t){const r=Fo(t),n=[];for(let s=0;s<r;s++){const i=cF(e?.[s]??"");if(i===null)return iy(r);n.push(i)}return n.reduce((s,i)=>s+i,0)!==100?iy(r):n}function dF(e){return e==="sm"?"gap-2":e==="lg"?"gap-6":"gap-4"}function ly(e,t){return ay(t,Fo(e)).map(n=>`minmax(0, ${n}fr)`).join(" ")}function uF(e){return e.length?e.map(t=>`minmax(0, ${t}fr)`).join(" "):"minmax(0, 1fr)"}function fF(e,t,r,n){const o=Fo(t),s=iF(e,o),i=ay(r,o);if(!(n?.collapseEmpty!==!1))return{columns:s,gridTemplate:ly(o,r),sourceIndices:s.map((p,m)=>m)};const d=s.map((p,m)=>({colChildren:p,index:m,percent:i[m]??0})).filter(p=>p.colChildren.length>0);if(d.length===0||d.length===s.length)return{columns:s,gridTemplate:ly(o,r),sourceIndices:s.map((p,m)=>m)};const u=d.reduce((p,m)=>p+m.percent,0),l=d.map(p=>u>0?Math.round(p.percent/u*100):Math.round(100/d.length)),f=100-l.reduce((p,m)=>p+m,0);return f!==0&&l.length>0&&(l[0]+=f),{columns:d.map(p=>p.colChildren),gridTemplate:uF(l),sourceIndices:d.map(p=>p.index)}}function jc(e,t="solid"){return e?t==="dashed"?"rounded-md border border-dashed border-border":"rounded-md border border-border":""}function pF(e){return B(jc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-3")}function mF(e){return B(jc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-2")}function hF(e,t){return e.columnBorders?.[t]!==void 0?!!e.columnBorders[t]:!!e.showColumnBorders}function gF(e,t){const r=hF(e,t);return B(jc(r,e.borderStyle??"dashed"),r&&"p-2")}function yF(e){if(e)return{minHeight:`${e}vh`}}function bF({widget:e,renderChildren:t}){const r=e.config,[n,o]=S.useState(r.defaultCollapsed??!1);return c.jsxs("section",{className:B("space-y-4",pF(r)),"data-widget-id":e.id,children:[r.heading&&c.jsx("div",{className:"flex items-center gap-2",children:r.collapsible?c.jsx("button",{type:"button",className:"text-left text-lg font-semibold hover:underline",onClick:()=>o(s=>!s),children:r.heading}):c.jsx("h2",{className:"text-lg font-semibold",children:r.heading})}),r.showDivider&&c.jsx("hr",{className:"border-border"}),!n&&e.children?.length?c.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function vF({widget:e,renderChildren:t}){const r=e.config,n=Fo(r.columns??2),o=r.collapseEmptyColumns!==!1,s=fF(e.children??[],n,r.columnWidths,{collapseEmpty:o});return c.jsx("div",{className:B("grid w-full min-w-0 items-stretch",dF(r.gap),mF(r)),style:{gridTemplateColumns:s.gridTemplate,...yF(r.minHeightPercent)},"data-widget-id":e.id,children:s.columns.map((i,a)=>{const d=s.sourceIndices[a]??a;return c.jsx("div",{className:B("flex min-h-[inherit] min-w-0 flex-col space-y-4 overflow-hidden",gF(r,d)),children:t?.(i)},d)})})}function wF({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 c.jsxs("div",{className:B("rounded-lg p-4",n),"data-widget-id":e.id,children:[(r.title||r.subtitle)&&c.jsxs("div",{className:"mb-4",children:[r.title&&c.jsx("h3",{className:"font-semibold",children:r.title}),r.subtitle&&c.jsx("p",{className:"text-sm text-muted-foreground",children:r.subtitle})]}),e.children?.length?c.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function cy(e,t){if(e.variable){const r=t[e.variable];return r!=null?String(r):e.fallback??e.text??""}return e.text??""}function SF({widget:e}){const t=e.config,{context:r}=Lr(),n=cy(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 c.jsx("div",{role:"heading","aria-level":o,className:B("font-semibold tracking-tight",i,s),"data-widget-id":e.id,children:n})}function xF({widget:e}){const t=e.config,{context:r}=Lr(),n=cy(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 c.jsx("p",{className:B(o,s),"data-widget-id":e.id,children:n})}function AF(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 dy(e,t){const r={...e};for(const[n,o]of Object.entries(r))typeof o=="string"&&(r[n]=AF(o,t));return r}function CF(e,t){return e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=t[n.trim()];return o!=null?String(o):""})}function uy(e,t,r,n){if(e.type==="navigate"){const o=CF(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?dy(e.params,t):void 0},n,"click");return}if(e.type==="workflow"&&e.workflowId){r(e,n,"click");return}r(e,n,"click")}function EF({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Lr();return c.jsx(Yt,{variant:t.variant??"default",size:t.size??"default","data-widget-id":e.id,onClick:()=>uy(t.action,r,n,e.id),children:t.label})}const NF={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between"},_F={sm:"gap-2",md:"gap-3",lg:"gap-4"};function kF({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Lr(),o=t.buttons??[];return c.jsx("div",{className:B("flex flex-wrap items-center",NF[t.align??"start"],_F[t.gap??"sm"],t.wrap===!1&&"flex-nowrap"),"data-widget-id":e.id,children:o.map(s=>c.jsx(Yt,{variant:s.variant??"outline",size:s.size??"default","data-widget-id":e.id,"data-button-id":s.id,onClick:()=>uy(s.action,r,n,e.id),children:s.label},s.id))})}function TF(e){const t=e.prepopulateApi;return!!(t?.enabled&&t.api?.path)}function FF(e,t){const r=Qe(e,t??"");return r===void 0?null:r}function fy(e,t){if(e.mode==="pageApi"&&e.dataSourceRef)return t[e.dataSourceRef];if(e.mode==="api")return e.api}function py({widgetId:e,dataSource:t,enabled:r=!0,page:n,pageSize:o,search:s}){const{schema:i,context:a,clientId:d,getFilterGroup:u,prepopulateStatus:l}=Lr(),f=S.useMemo(()=>t.filterGroupKey?u(t.filterGroupKey):{},[t.filterGroupKey,u]),p=t.mode==="context"&&TF(i),m=r&&(t.mode==="static"||(t.mode==="context"?!p||l!=="loading":!!d)),g=S.useMemo(()=>["page-ds",e,t,a,f,n,o,s,l],[e,t,a,f,n,o,s,l]);return gn.useQuery({queryKey:g,enabled:m,staleTime:fy(t,i.dataApis??{})?.staleTimeMs??3e4,queryFn:async()=>{if(t.mode==="static")return t.staticData;if(t.mode==="context")return FF(a,t.contextPath);const h=fy(t,i.dataApis??{});if(!h)throw new Error(`No API config for data source on widget ${e}`);const y={...a};if(t.requestBindings)for(const x of t.requestBindings){let E;x.source==="binding"?E=a[x.key]:x.source==="filter"&&(E=f[x.key]),E!==void 0&&(y[x.param]=E)}const v={...dy(y,a),...n!==void 0?{page:n,pageSize:o,search:s}:{}};return $c({clientId:d,api:h,context:v,filterState:f})}})}function zc(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 ws(e,t){const r=Qe(e,t.path);return r==null?t.fallback??r:t.formatter?zc(r,t.formatter):r}function PF(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 OF={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"},IF={rectangle:"rounded-lg",square:"aspect-square rounded-lg",circle:"aspect-square rounded-full"},MF={sm:"p-2 text-xs",md:"p-4 text-sm",lg:"p-6 text-base"},Uc={sm:"text-lg",md:"text-2xl",lg:"text-3xl"},LF={sm:"gap-2",md:"gap-3",lg:"gap-4"};function DF({title:e,value:t,trend:r,variant:n="default",shape:o="rectangle",size:s="md",layout:i="vertical",isLoading:a,isError:d}){const u=i==="horizontal";return c.jsxs("div",{className:B(OF[n??"default"],IF[o??"rectangle"],MF[s??"md"],u&&"flex items-center justify-between gap-3"),children:[c.jsxs("div",{className:B(u&&"min-w-0"),children:[e&&c.jsx("p",{className:B("font-medium text-muted-foreground",u?"text-sm":""),children:e}),r!=null&&r!==""&&!u&&c.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:String(r)})]}),a?c.jsx(Pn,{className:"my-2"}):d?c.jsx("p",{className:B("font-bold text-destructive",Uc[s??"md"]),children:"Error"}):c.jsx("p",{className:B("font-bold",u?Uc[s??"md"]:`mt-1 ${Uc[s??"md"]}`),children:String(t)}),u&&r!==null&&r!==void 0&&r!==""&&c.jsx("p",{className:"text-xs text-muted-foreground",children:String(r)})]})}function my({stat:e,widgetId:t}){const{data:r,isLoading:n,isError:o}=py({widgetId:t,dataSource:e.dataSource}),i=(()=>{if(r==null)return e.valueMapping.fallback??"—";if(e.dataSource.mode==="context"){const d=r;return e.valueMapping.formatter?zc(d,e.valueMapping.formatter):d}if(e.dataSource.mode==="static"){const d=e.valueMapping.path?.trim()||"value",u=ws(r,{...e.valueMapping,path:d});if(u!=null)return e.valueMapping.formatter?zc(u,e.valueMapping.formatter):u;if(typeof r=="object"&&r!==null&&!Array.isArray(r)){const l=r;if(l.value!==void 0&&l.value!==null)return l.value}return e.valueMapping.fallback??"—"}return ws(r,e.valueMapping)})(),a=e.trendMapping&&r!==void 0&&e.dataSource.mode!=="context"?ws(r,e.trendMapping):e.trendMapping&&e.dataSource.mode==="context"&&e.trendMapping.path?ws({value:r},e.trendMapping):null;return c.jsx(DF,{title:e.title,value:i,trend:a,variant:e.variant,shape:e.shape,size:e.size,layout:e.layout,isLoading:n,isError:o})}function BF({widget:e}){const t=e.config;return c.jsx("div",{"data-widget-id":e.id,children:c.jsx(my,{stat:t,widgetId:e.id})})}function $F({stat:e,widgetId:t}){return c.jsx(my,{stat:e,widgetId:`${t}-${e.id}`})}function jF({widget:e}){const t=e.config,r=t.stats??[],n=t.columns??1,o=t.direction==="horizontal";return c.jsx("div",{"data-widget-id":e.id,className:B(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",LF[t.gap??"md"]),children:r.map(s=>c.jsx($F,{stat:s,widgetId:e.id},s.id))})}function zF({widget:e}){const t=e.config,{setFilterValue:r}=Lr(),[n,o]=S.useState("");return S.useEffect(()=>{const s=t.debounceMs??300,i=setTimeout(()=>{r(t.filterGroupKey,"search",n)},s);return()=>clearTimeout(i)},[n,t.debounceMs,t.filterGroupKey,r]),c.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 UF(e,t){if(!e)return[];const r=t?Qe(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 VF({widget:e}){const t=e.config,{dispatchAction:r}=Lr(),[n,o]=S.useState(1),[s,i]=S.useState(""),a=t.pagination?.pageSize??10,{data:d,isLoading:u,isError:l}=py({widgetId:e.id,dataSource:t.dataSource,page:n,pageSize:a,search:t.search?.enabled?s:void 0}),f=t.dataSource.mode==="pageApi"?void 0:t.dataSource.api?.itemsPath,p=UF(d,f??"data.items"),m=(g,h)=>{const y=t.dataSource.responseMapping.find(w=>w.target===h);return y?ws(g,y):Qe(g,h)??""};return c.jsxs("div",{className:"space-y-3","data-widget-id":e.id,children:[t.search?.enabled&&c.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:g=>{i(g.target.value),o(1)}}),c.jsx("div",{className:"overflow-x-auto rounded-md border",children:c.jsxs("table",{className:"w-full text-sm",children:[c.jsx("thead",{children:c.jsx("tr",{className:"border-b bg-muted/50",children:t.columns.map(g=>c.jsx("th",{className:B("px-3 py-2 text-left font-medium",g.align==="center"&&"text-center",g.align==="right"&&"text-right"),style:g.width?{width:g.width}:void 0,children:g.header},g.id))})}),c.jsx("tbody",{children:u?c.jsx("tr",{children:c.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center",children:c.jsx(Pn,{})})}):l?c.jsx("tr",{children:c.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-destructive",children:"Failed to load data"})}):p.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-muted-foreground",children:t.emptyMessage??"No data"})}):p.map((g,h)=>c.jsx("tr",{className:"cursor-pointer border-b hover:bg-muted/30",onClick:()=>{r({type:"emit",eventName:"row_click",payload:{row:g}},e.id,"row_click")},children:t.columns.map(y=>c.jsx("td",{className:B("px-3 py-2",y.align==="center"&&"text-center",y.align==="right"&&"text-right"),children:String(m(g,y.field))},y.id))},h))})]})}),t.pagination?.enabled&&c.jsxs("div",{className:"flex items-center justify-between text-sm",children:[c.jsxs("span",{className:"text-muted-foreground",children:["Page ",n]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{type:"button",className:"rounded border px-2 py-1 disabled:opacity-50",disabled:n<=1,onClick:()=>o(g=>Math.max(1,g-1)),children:"Previous"}),c.jsx("button",{type:"button",className:"rounded border px-2 py-1",disabled:p.length<a,onClick:()=>o(g=>g+1),children:"Next"})]})]})]})}const HF=75;function WF(e){return e??HF}function Vc({scrollBehavior:e="page",maxHeightPercent:t,children:r,className:n}){if(e!=="contained")return c.jsx(c.Fragment,{children:r});const o=WF(t);return c.jsx("div",{className:B("min-w-0 overflow-y-auto overflow-x-hidden",n),style:{maxHeight:`${o}vh`},"data-form-embed-scroll":"contained",children:r})}function RF(e,t,r){return["embedded-form",e,t,r??"latest"]}async function GF(e,t){try{const r=await dn.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 KF(e,t,r){const n=r!==void 0?`/api/form-builder/forms/${e}/render?version=${r}`:`/api/form-builder/forms/${e}/render`,o=await dn.get(n,{params:{clientId:t}}),i=o.data?.data??o.data,a=i.form??i,d=i.fields??a.fields??[];let u=i.layout??a.layout??null;(!u||typeof u.columns!="number")&&(u=await GF(e,t));const l=i.rules??a.rules??[],f=ms(a,d,u,l),p=_s({config:f.config,layout:f.layout},Ns(u))??Ns(u);return{schema:f,gridLayout:p}}const qF=300*1e3;function hy({formId:e,mode:t="fill",contextFieldMapping:r,pageContext:n,clientId:o,formVersion:s,scrollBehavior:i,maxHeightPercent:a}){const{data:d,isLoading:u,isError:l,error:f}=gn.useQuery({queryKey:RF(e,o,s),queryFn:()=>KF(e,o,s),staleTime:qF}),p=S.useMemo(()=>PF(n,r),[n,r]);return u?c.jsx(Vc,{scrollBehavior:i,maxHeightPercent:a,children:c.jsx(Pn,{})}):l?c.jsx(Vc,{scrollBehavior:i,maxHeightPercent:a,children:c.jsx("p",{className:"text-sm text-destructive",children:f instanceof Error?f.message:"Failed to load form"})}):d?.schema?c.jsx(Vc,{scrollBehavior:i,maxHeightPercent:a,children:c.jsx(Mc,{schema:d.schema,mode:t,gridLayout:d.gridLayout,initialValues:p,submissionContext:n})}):null}function YF({widget:e}){const t=e.config,{context:r,clientId:n}=Lr();return t.formId?c.jsx(hy,{formId:t.formId,mode:t.mode??"fill",contextFieldMapping:t.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:t.scrollBehavior,maxHeightPercent:t.maxHeightPercent}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured"})}function XF({widget:e}){const t=e.config,{context:r,getWorkflowState:n,clientId:o}=Lr(),s=String(r.moduleId??"");if(!n)return c.jsxs("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground","data-widget-id":e.id,children:["Workflow embed requires ",c.jsx("code",{className:"text-xs",children:"getWorkflowState"})," on PageRenderer. Workflow ID: ",t.workflowId]});if(!s)return c.jsx("p",{className:"text-sm text-destructive","data-widget-id":e.id,children:"moduleId required in page context for workflow embed"});const i={};if(t.contextVariableMapping)for(const[a,d]of Object.entries(t.contextVariableMapping)){const u=r[d];u!=null&&(i[a]=String(u))}return c.jsx(Yg,{getWorkflowState:n,moduleId:s,tenantId:r.tenantId?String(r.tenantId):void 0,clientId:o||void 0,submissionContext:i})}function JF({widget:e}){const t=e.config,{schema:r,dispatchAction:n}=Lr(),o=t.previousPage??r.navigation?.previousPage,s=t.nextPage??r.navigation?.nextPage,i=t.showPrevious!==!1&&!!o,a=t.showNext!==!1&&!!s,d=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",l=f=>{n({type:"navigate_page",pageId:f.pageId},e.id,"click")};return c.jsxs("nav",{className:"space-y-3","data-widget-id":e.id,children:[d&&c.jsx("ol",{className:"flex flex-wrap items-center gap-1 text-sm text-muted-foreground",children:r.navigation.breadcrumbs.map((f,p)=>c.jsxs("li",{className:"flex items-center gap-1",children:[p>0&&c.jsx("span",{children:"/"}),f.href?c.jsx("a",{href:f.href,className:"hover:underline",children:f.label}):c.jsx("span",{children:f.label})]},p))}),c.jsxs("div",{className:B("flex items-center gap-2",u),children:[i&&o&&c.jsx(Yt,{variant:"outline",size:"sm",onClick:()=>l(o),children:o.label??"Previous"}),a&&s&&c.jsx(Yt,{variant:"default",size:"sm",onClick:()=>l(s),children:s.label??"Next"})]})]})}function QF(e,t){return e?.length?e.filter(r=>r.config.tabId===t):[]}const ZF=1;function eP(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 tP(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 rP(e,t,r){return e?new Set(r?[r]:[]):new Set(t.map(n=>n.id))}function nP({tab:e,shouldRender:t,pageContext:r,clientId:n}){return t?e.formId?c.jsx(hy,{formId:e.formId,mode:e.formMode??"fill",contextFieldMapping:e.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:e.scrollBehavior,maxHeightPercent:e.maxHeightPercent}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured for this tab"}):null}function oP({tab:e,shouldLoad:t,shouldRender:r,nestingDepth:n,pageContext:o,clientId:s,onAction:i,getWorkflowState:a}){const d=Lr(),{data:u,isLoading:l,isError:f,error:p}=gn.useQuery({queryKey:["tab-page",e.pageId,e.pageVersion,s],enabled:t&&!!e.pageId,queryFn:async()=>Bc(e.pageId,s,e.pageVersion)});return r?n>=ZF?c.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?l?c.jsx(Pn,{}):f?c.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load page"}):u?c.jsx(Hc,{page:u,context:o,nestingDepth:n+1,inheritContext:!0,onAction:i,getWorkflowState:a,parentContext:d}):null:c.jsx("p",{className:"text-sm text-muted-foreground",children:"No page configured for this tab"}):null}function sP({tab:e,widgetChildren:t,renderChildren:r}){const n=QF(t,e.id);return n.length===0?c.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No widgets in this tab"}):c.jsx(c.Fragment,{children:r?.(n)})}function iP({widget:e,renderChildren:t}){const r=e.config,{context:n,clientId:o,nestingDepth:s,onAction:i,getWorkflowState:a}=Lr(),d=r.tabs??[],u=r.defaultTabId??d[0]?.id??"",l=r.lazyLoad!==!1,[f,p]=S.useState(u),[m,g]=S.useState(()=>rP(l,d,u)),h=w=>{g(v=>new Set(v).add(w)),p(w)},y=S.useMemo(()=>!l,[l]);return d.length===0?c.jsx("p",{className:"text-sm text-muted-foreground","data-widget-id":e.id,children:"No tabs configured"}):c.jsxs(Rg,{value:f,onValueChange:h,className:"w-full","data-widget-id":e.id,children:[c.jsx(Gg,{className:B("mb-4",eP(r.variant)),children:d.map(w=>c.jsx(Kg,{value:w.id,disabled:w.disabled,className:tP(r.variant),children:w.label},w.id))}),d.map(w=>{const v=m.has(w.id),x=y||v,E=y||v;return c.jsxs(qg,{value:w.id,forceMount:y||void 0,className:B("mt-0",y&&"data-[state=inactive]:hidden"),children:[w.contentType==="widgets"&&E&&c.jsx(sP,{tab:w,widgetChildren:e.children??[],renderChildren:t}),w.contentType==="form"&&c.jsx(nP,{tab:w,shouldRender:x,pageContext:n,clientId:o}),w.contentType==="page"&&c.jsx(oP,{tab:w,shouldLoad:x,shouldRender:E,nestingDepth:s,pageContext:n,clientId:o,onAction:i,getWorkflowState:a})]},w.id)})]})}const aP={section:bF,columns:vF,card:wF,tab_group:iP,heading:SF,text:xF,button:EF,button_group:kF,stat_card:BF,stat_grid:jF,data_table:VF,search_filter:zF,form_embed:YF,workflow_embed:XF,page_nav:JF};function lP({widget:e}){return c.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: ",c.jsx("code",{className:"text-xs",children:e.type}),e.label&&c.jsxs("span",{className:"ml-1",children:["(",e.label,")"]})]})}function cP({widget:e,renderChildren:t}){const r=aP[e.type]??lP;return c.jsx(r,{widget:e,renderChildren:t})}function gy(e,t){return e.map(r=>c.jsx(cP,{widget:r,renderChildren:t},r.id))}function Hc({page:e,context:t={},onAction:r,chrome:n="none",className:o,nestingDepth:s=0,getWorkflowState:i,inheritContext:a=!1,parentContext:d}){const u=S.useMemo(()=>eF(e.schema),[e.schema]),l=p=>gy(p,l),f=c.jsxs("div",{className:B("studio-page-content min-h-0 min-w-0",JT(u),o),"data-page-id":e.id,"data-nesting-depth":s,children:[n==="minimal"&&u.meta?.title&&c.jsxs("header",{className:"mb-6 border-b pb-4",children:[c.jsx("h1",{className:"text-2xl font-semibold",children:u.meta.title}),u.meta.description&&c.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u.meta.description})]}),c.jsx("div",{className:"space-y-6",children:gy(u.widgets,l)})]});return a&&d?f:c.jsx(oF,{schema:u,context:t,clientId:String(t.clientId??""),nestingDepth:s,onAction:r,getWorkflowState:i,parentContext:d,children:f})}function dP({clientId:e,tenantId:t,moduleId:r,featureId:n,pageId:o,routePath:s,routeParams:i={},isDefault:a,context:d={},version:u,chrome:l="none",onAction:f,getWorkflowState:p}){const m=S.useMemo(()=>({...i,...d,clientId:e,tenantId:t,moduleId:r,featureId:n}),[i,d,e,t,r,n]),{data:g,isLoading:h,isError:y,error:w}=gn.useQuery({queryKey:["page-resolve",e,t,r,n,o,s,a,u],queryFn:()=>ry({clientId:e,tenantId:t,moduleId:r,featureId:n,routePath:s,isDefault:a,version:u}),enabled:!o}),v=o??g?.pageId,x=u??g?.version,{data:E,isLoading:P,isError:k,error:N}=gn.useQuery({queryKey:["page-render",v,e,x],queryFn:()=>Bc(v,e,x),enabled:!!v});return!o&&h?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx(Pn,{})}):y?c.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:w instanceof Error?w.message:"Failed to resolve page"}):v?P?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx(Pn,{})}):k||!E?c.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:N instanceof Error?N.message:"Failed to load page"}):c.jsx(Hc,{page:E,context:m,chrome:l,nestingDepth:0,onAction:f,getWorkflowState:p}):c.jsx("div",{className:"rounded-md border p-4 text-sm text-muted-foreground",children:"No page found for the given scope or route."})}ge.FIELD_TYPE_REGISTRY=KT,ge.FORM_RENDERER_GRID_ROW_HEIGHT_DEFAULT=In,ge.FORM_RENDERER_ROOT_CLASS=ga,ge.FieldRenderer=un,ge.FormRenderer=Mc,ge.PageRenderer=Hc,ge.RendererFieldLayoutContext=_a,ge.StudioPageHost=dP,ge.WorkflowStepsView=Yg,ge.appearanceControlClasses=Bo,ge.appearanceHasExplicitVerticalIntent=kd,ge.appearanceTextareaClasses=vd,ge.backendToFormSchema=ms,ge.cellAlignmentClasses=Nb,ge.cellVerticalJustifyClassesForField=Eb,ge.effectiveWidthPercent=Ps,ge.executeDataSource=$c,ge.fetchPageRender=Bc,ge.fieldBlockBoxStyle=Cb,ge.fieldBlockBoxStyleForField=Nd,ge.fieldBlockHorizontalPlacementClass=xd,ge.fieldBlockHorizontalSelfClass=Ad,ge.fieldBlockHorizontalSelfClassForField=_d,ge.fieldBlockWidthStyle=Sa,ge.fieldBlockWidthStyleForField=Ed,ge.fieldGridShellFillsCellVertically=Is,ge.formBuilderHttp=dn,ge.formLayoutRecordToGridConfig=Ns,ge.getBusinessApiOrigin=Np,ge.getClientId=Tn,ge.getRendererHostAuthHeaders=Ml,ge.getRendererHostViewerContext=bC,ge.getRendererStore=ev,ge.gridCellFlexClasses=Sd,ge.gridCellFlexClassesForField=Na,ge.gridCellOuterFlexClasses=wd,ge.hasExplicitFieldBlockWidth=Cd,ge.isAsyncSearchFieldProperties=HT,ge.isIntrinsicWidthButtonField=to,ge.normalizeWorkflowFormSchema=Zk,ge.normalizeWorkflowFormToRendererSchema=Yi,ge.pageBuilderHttp=vs,ge.parseContentVerticalAlign=Aa,ge.parseMetadataJson=ys,ge.resetRendererHostAuth=yC,ge.resolveBusinessApiUrl=cn,ge.resolveFormGridLayout=_s,ge.resolvePage=ry,ge.resolvedGridCellVerticalJustifyClasses=jo,ge.resolvedHorizontalAlign=Fr,ge.resolvedVerticalAlign=$o,ge.resolvedVerticalAlignForField=Ea,ge.setBusinessApiOrigin=UA,ge.setFormBuilderAuthProvider=vC,ge.setPageBuilderAuthProvider=tF,ge.setRendererHostAuthHeaders=gC,ge.setRendererHostViewerContext=hC,ge.useFieldValidation=RT,ge.useFormRenderer=Vd,ge.useFormValidation=WT,ge.useRendererFieldLayout=zo,ge.useRendererHostAuthStore=Rn,Object.defineProperty(ge,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},VE="DialogDescriptionWarning",HE=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${lh(VE).contentName}}.`;return b.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},WE=Xm,RE=Zm,GE=eh,KE=th,qE=nh,YE=ih;function XE({...e}){return c.jsx(WE,{"data-slot":"dialog",...e})}function JE({...e}){return c.jsx(RE,{"data-slot":"dialog-portal",...e})}function QE({className:e,...t}){return c.jsx(GE,{"data-slot":"dialog-overlay",className:B("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 ZE({className:e,children:t,showCloseButton:r=!0,...n}){return c.jsxs(JE,{"data-slot":"dialog-portal",children:[c.jsx(QE,{}),c.jsxs(KE,{"data-slot":"dialog-content",className:B("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&&c.jsxs(YE,{"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:[c.jsx(Ko,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function eN({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-header",className:B("flex flex-col gap-2 text-center sm:text-left",e),...t})}function tN({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-footer",className:B("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function rN({className:e,...t}){return c.jsx(qE,{"data-slot":"dialog-title",className:B("text-lg leading-none font-semibold",e),...t})}async function nN(){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 ch(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 dh=({open:e,onOpenChange:t,onCaptured:r,validateFile:n,accept:o,disabled:s,onValidationMessage:i})=>{const a=S.useRef(null),d=S.useRef(null),u=S.useRef(null),l=S.useRef(null),[f,p]=S.useState(null),[m,g]=S.useState(!1),h=S.useCallback(()=>{a.current&&(a.current.srcObject=null)},[]),y=S.useCallback(()=>{u.current&&(u.current.getTracks().forEach(_=>_.stop()),u.current=null),h()},[h]);S.useEffect(()=>{if(!e){y(),p(null),g(!1);return}if(s)return;let _=!1;return p(null),g(!0),nN().then(N=>{if(_){N.getTracks().forEach(C=>C.stop());return}u.current=N,g(!1)}).catch(N=>{if(_)return;g(!1);const C=N instanceof Error?N.message:"Could not access camera";p(C)}),()=>{_=!0,u.current&&(u.current.getTracks().forEach(N=>N.stop()),u.current=null),h()}},[e,s,y,h]);const w=S.useCallback(_=>{a.current=_,_&&u.current&&e&&!f&&!m&&(_.srcObject=u.current,ch(_))},[e,f,m]);S.useLayoutEffect(()=>{if(!e||f||m||!u.current)return;let _=!1,N=0;const C=()=>{if(_)return;const I=a.current;!I||!u.current||(I.srcObject=u.current,ch(I))};C();const A=requestAnimationFrame(()=>{C(),N=requestAnimationFrame(C)});return()=>{_=!0,cancelAnimationFrame(A),cancelAnimationFrame(N),h()}},[e,f,m,h]);const v=S.useCallback(()=>{y(),p(null),g(!1),t(!1),l.current&&(l.current.value="")},[y,t]),x=S.useCallback(()=>{const _=a.current,N=d.current;if(!_||!N||!u.current||_.readyState<2)return;const C=_.videoWidth,A=_.videoHeight;if(C===0||A===0)return;N.width=C,N.height=A;const I=N.getContext("2d");I&&(I.drawImage(_,0,0),N.toBlob(T=>{if(!T)return;const W=new File([T],`camera-capture-${Date.now()}.jpg`,{type:"image/jpeg",lastModified:Date.now()}),X=n(W);if(X){i?.(X);return}i?.(void 0),r(W),v()},"image/jpeg",.92))},[r,n,v,i]),E=S.useCallback(_=>{const N=_.target.files?.[0];if(!N)return;const C=n(N);if(C){i?.(C);return}i?.(void 0),r(N),v(),l.current&&(l.current.value="")},[r,n,v,i]),P=typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function";return c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:l,type:"file",accept:o,capture:"user",onChange:E,className:"hidden","aria-hidden":!0}),c.jsx("canvas",{ref:d,className:"hidden","aria-hidden":!0}),c.jsx(XE,{open:e,onOpenChange:_=>{_||v()},children:c.jsxs(ZE,{className:"sm:max-w-md",showCloseButton:!0,onPointerDownOutside:_=>_.preventDefault(),children:[c.jsx(eN,{children:c.jsx(rN,{children:"Take a photo"})}),f?c.jsxs("div",{className:"space-y-3 py-2",children:[c.jsx("p",{className:"text-sm text-destructive",children:f}),P&&c.jsx("p",{className:"text-xs text-muted-foreground",children:"You can choose an image from your device instead."}),c.jsx(Yt,{type:"button",variant:"outline",className:"w-full",onClick:()=>l.current?.click(),children:"Choose from device"})]}):m?c.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Opening camera…"}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"relative rounded-lg overflow-hidden bg-black aspect-video",children:c.jsx("video",{ref:w,playsInline:!0,muted:!0,className:"w-full h-full object-cover"})}),c.jsxs(tN,{className:"gap-2 sm:gap-0",children:[c.jsx(Yt,{type:"button",variant:"outline",onClick:v,children:"Cancel"}),c.jsx(Yt,{type:"button",onClick:x,children:"Capture photo"})]})]})]})})]})},oN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const d=e.properties,[u,l]=S.useState(),[f,p]=S.useState(!1),[m,g]=S.useState(()=>new Set),[h,y]=S.useState("none"),w=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,v=e.validation?.find(K=>K.type==="fileSize"),x=e.validation?.find(K=>K.type==="fileType"),E=v?.value!=null?v.value:d?.maxSize??w?.maxSize??5*1024*1024,P=x?.value!=null?x.value:d?.accept??w?.accept??["image/*"],_=P.join(",")||"image/*",N=Ms(e),C=S.useCallback(K=>{if(v){const J=Yr(K,v);if(J!==!0)return typeof J=="string"?J:"File size exceeds the maximum allowed size"}else if(K.size>E)return`File size must be less than ${yo(E)}`;if(x){const J=Yr(K,x);if(J!==!0)return typeof J=="string"?J:"File type is not allowed"}return null},[v,x,E]),A=S.useMemo(()=>Ls(t),[t]),I=ql(A),T=S.useCallback(K=>{const J=ka(K,N);r(J),n?.()},[r,n,N]),W=S.useCallback(K=>{const J=C(K);if(J){l(J);return}l(void 0);const ce=[...A];ce.length>=N||(ce.push(K),T(ce),y("none"))},[A,N,C,T]),X=S.useCallback(K=>{const J=A.filter((ce,ne)=>ne!==K);T(J)},[A,T]),O=S.useCallback(()=>{s||A.length>=N||(l(void 0),y("camera"),p(!0))},[s,A.length,N]),j=S.useCallback(K=>{p(K),K||y("none")},[]),M=o||u,D=e.appearance?.hideLabel??!1,L=[];(v||E)&&L.push(`Max size: ${yo(E)}`),x&&P.length>0&&L.push(`Allowed: ${P.join(", ")}`),N>1&&L.push(`Up to ${N} photos`);const U=S.useCallback(K=>{window.open(K,"_blank","noopener,noreferrer")},[]),$=A.length===0,ie=A.length<N,V=Rl(N,A.length);return c.jsxs(Et,{field:e,error:M,isRequired:i,className:B(a,"!space-y-0"),hideLabel:D,children:[c.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:c.jsx("div",{role:"button",tabIndex:s||!ie?-1:0,id:ht(e),onClick:K=>{s||K.target.closest("[data-remove-in-dropzone]")||K.target.closest("[data-no-open-picker]")||A.length>=N||O()},onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),!s&&ie&&O())},className:B("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",M&&"border-destructive",s&&"opacity-50 cursor-not-allowed",f&&h==="camera"&&"opacity-70 pointer-events-none",!ie&&A.length>0&&"cursor-default"),"aria-describedby":jt(e,!!M),"aria-invalid":Jt(!!M),"aria-required":i,children:$?c.jsxs(c.Fragment,{children:[c.jsx(Us,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),c.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:f?"Opening camera…":"Click to open camera"}),L.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:L.join(" • ")})]}):V?c.jsx(Yl,{item:A[0],objectUrl:I[0]??null,failedUrlKeys:m,onImageUrlError:K=>g(J=>new Set(J).add(K)),onRemove:()=>X(0),onOpenUrl:U,disabled:s}):c.jsx(Kl,{items:A,maxFiles:N,disabled:s,objectUrls:I,failedUrlKeys:m,onImageUrlError:K=>g(J=>new Set(J).add(K)),onRemove:X,onOpenUrl:U,addSlot:ie?c.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:K=>{K.stopPropagation(),O()},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:[c.jsx(Us,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})})}),c.jsx(dh,{open:f,onOpenChange:j,onCaptured:W,validateFile:C,accept:_,disabled:s,onValidationMessage:l})]})},sN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,buttonResponses:d})=>{const u=e.properties,l=S.useRef(null),[f,p]=S.useState(),[m,g]=S.useState(!1),[h,y]=S.useState(()=>new Set),[w,v]=S.useState("none"),x=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,E=e.validation?.find(oe=>oe.type==="fileSize"),P=e.validation?.find(oe=>oe.type==="fileType"),_=E?.value?E.value:u?.maxSize??x?.maxSize??5*1024*1024,N=P?.value?P.value:u?.accept??x?.accept??["image/*"],C=Array.isArray(N)?N.join(","):"image/*",A=Ms(e),I=S.useCallback(oe=>{if(E){const re=Yr(oe,E);if(re!==!0)return typeof re=="string"?re:"File size exceeds the maximum allowed size"}else if(oe.size>_)return`File size must be less than ${yo(_)}`;if(P){const re=Yr(oe,P);if(re!==!0)return typeof re=="string"?re:"File type is not allowed"}return null},[E,P,_]),T=S.useMemo(()=>Ls(t),[t]),W=ql(T),X=S.useCallback(oe=>{const re=ka(oe,A);r(re),n?.()},[r,n,A]),O=S.useCallback(oe=>{p(void 0);const re=Array.from(oe),be=[...T];let de=null;for(const ot of re){if(be.length>=A)break;const Se=I(ot);if(Se){de||(de=Se);continue}be.push(ot)}if(de&&be.length===T.length){p(de);return}de&&p(de),X(be),v("none")},[T,A,I,X]),j=S.useCallback(oe=>{const re=oe.target.files;re&&re.length>0&&O(re),l.current&&(l.current.value="")},[O]),M=S.useCallback(oe=>{X(T.filter((re,be)=>be!==oe))},[T,X]),D=S.useCallback(()=>{s||T.length>=A||m||(p(void 0),v("file"),l.current?.click())},[s,T.length,A,m]),L=S.useCallback(()=>{s||T.length>=A||(p(void 0),v("camera"),g(!0))},[s,T.length,A]),U=S.useCallback(oe=>{const re=I(oe);if(re){p(re);return}p(void 0);const be=[...T];be.length>=A||(be.push(oe),X(be),v("none"))},[T,A,I,X]),$=S.useCallback(oe=>{g(oe),oe||v("none")},[]),ie=o||f,V=e.appearance?.hideLabel??!1,K=[];(E||_)&&K.push(`Max size: ${yo(_)}`),P&&N.length>0&&K.push(`Allowed: ${N.join(", ")}`),A>1&&K.push(`Up to ${A} photos`);const J=S.useMemo(()=>{if(!d)return null;const oe=Object.values(d);for(let re=oe.length-1;re>=0;re-=1){const be=oe[re],de=typeof be?.status=="string"?be.status.toLowerCase():null;if(de&&de!=="success")continue;const ot=be?.code;if(typeof ot=="number"&&(ot<200||ot>=300))continue;const Se=be?.data,xe=Se?.file_url||Se?.fileUrl||be?.file_url||be?.fileUrl;if(typeof xe=="string"&&xe.trim())return xe.trim()}return null},[d]),ce=S.useCallback(oe=>{window.open(oe,"_blank","noopener,noreferrer")},[]),ne=T.length===0,G=T.length<A,ee=Rl(A,T.length),Pe=G&&!m?c.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:[c.jsx("button",{type:"button",disabled:s,onClick:oe=>{oe.stopPropagation(),D()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-t","aria-label":"Upload file",title:"Upload",children:c.jsx(Hs,{className:"h-4 w-4","aria-hidden":!0})}),c.jsx("button",{type:"button",disabled:s,onClick:oe=>{oe.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:c.jsx(Us,{className:"h-4 w-4","aria-hidden":!0})})]}):void 0;return c.jsxs(Et,{field:e,error:ie,isRequired:i,className:B(a,"!space-y-0"),hideLabel:V,children:[c.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:c.jsxs("div",{className:B("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",ie&&"border-destructive",s&&"opacity-50"),children:[c.jsx("input",{ref:l,id:ht(e),type:"file",accept:C,multiple:A>1,onChange:j,disabled:s||e.disabled||m||!G,className:"hidden","aria-describedby":jt(e,!!ie),"aria-invalid":Jt(!!ie),"aria-required":i}),ne?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 w-full pointer-events-auto",children:[c.jsxs("div",{className:"flex items-center justify-center gap-3",children:[c.jsxs("button",{type:"button",disabled:s||m,onClick:D,className:B("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none"),children:[c.jsx(Hs,{className:"h-5 w-5","aria-hidden":!0}),c.jsx("span",{children:"Upload"})]}),c.jsxs("button",{type:"button",disabled:s,onClick:L,className:B("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none",m&&"opacity-70"),children:[c.jsx(Us,{className:"h-5 w-5","aria-hidden":!0}),c.jsx("span",{children:"Camera"})]})]}),K.length>0&&c.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-2 text-center px-1",children:K.join(" • ")})]}):ee?c.jsx(Yl,{item:T[0],objectUrl:W[0]??null,failedUrlKeys:h,onImageUrlError:oe=>y(re=>new Set(re).add(oe)),onRemove:()=>M(0),onOpenUrl:ce,openTarget:T[0]instanceof File?J:void 0,disabled:s||e.disabled}):c.jsx(Kl,{items:T,maxFiles:A,disabled:s,objectUrls:W,failedUrlKeys:h,onImageUrlError:oe=>y(re=>new Set(re).add(oe)),onRemove:M,resolveOpenUrl:(oe,re)=>re instanceof File&&T.length===1&&J?J:null,onOpenUrl:oe=>{oe?.trim()&&ce(oe.trim())},addSlot:Pe})]})}),c.jsx(dh,{open:m,onOpenChange:$,onCaptured:U,validateFile:I,accept:C,disabled:s,onValidationMessage:p})]})};function ls(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 bo(n)}}catch{}if(e.response){const r=e.response;if(typeof r=="string")try{const n=JSON.parse(r);return bo(n)}catch{return r}else if(typeof r=="object")return bo(r)}return t}if(e instanceof IA)return e.response?.data?bo(e.response.data):e.message||"An unexpected error occurred";if(typeof e=="string")try{const t=JSON.parse(e);return bo(t)}catch{return e}return typeof e=="object"&&e!==null?bo(e):"An unexpected error occurred"}function bo(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"}function iN(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 aN(e,t){try{const r=iN(e);$t.toast.success(r&&r.trim()?r:t)}catch{$t.toast.success(t)}}function Zl(e,t,r){try{const n=r(e);$t.toast.error(n&&n.trim()?n:t)}catch{$t.toast.error(t)}}function lN(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 zi="This field is required";function uh(e,t){if(!t?.length)return e;const r=t.find(n=>n.name===e);return r?.label&&r.label.trim()||e}function ec(e,t){if(!e)return"Please complete the required fields.";if(Array.isArray(e)){const s=e.map(i=>{const a=i.message||zi;if(t?.length&&i.field){const d=uh(i.field,t);return a===zi?`${d} is required`:`${d}: ${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()||zi;if(t?.length){const a=uh(o,t);return i===zi?`${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)`}const cN=/^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/i;function fh(e){const t=e.trim().match(cN);return t?t[1]:e}const dN={applicantId:["id","applicant_id"],applicant_id:["id","applicantId"],id:["applicantId","applicant_id"]};function rn(e,t,r,n,o,s){let i=e;if(o&&typeof e=="string"&&(i=i.replace(/\{resp:([^}]+)\}/g,(a,d)=>{const u=d.trim().split(".");if(u.length<2)return a;const l=u[0],f=u.slice(1).join("."),p=o[l];if(p==null)return a;const m=Qe(p,f);return m==null?a:String(m)}),i.includes("{documentId}")||i.includes("%7BdocumentId%7D"))){let a;for(const d of Object.values(o)){const u=Qe(d,"data.id")??Qe(d,"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 d=t?.documentId??(t&&Qe(t,"documentId")),u=n?.documentId??(n&&Qe(n,"documentId"));d!=null&&d!==""?a=String(d):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,d)=>{const u=d.trim();if(s==null||u==="")return a;const l=Qe(s,u);return l==null?a:String(l)}),i=i.replace(/\{(?:ctx:|\@)(\w+)\}/g,(a,d)=>n&&n[d]!==void 0&&n[d]!==null?String(n[d]):a),i=i.replace(/\{(\w+)\}/g,(a,d)=>{if(a.includes("ctx:")||a.includes("@"))return a;const u=r[d];if(u!=null)return fh(String(u));let l=t[d];if(l==null||l===""){const f=Object.keys(t).find(p=>p.toLowerCase()===d.toLowerCase());f&&(l=t[f])}if((l==null||l==="")&&(l=n?.[d]),l==null||l===""){const f=dN[d];if(f)for(const p of f){const m=t[p]??n?.[p];if(m!=null&&m!==""){l=m;break}}}return l!=null&&l!==""?fh(String(l)):a}),i}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,d=i.metadata,u=typeof d=="object"&&d!==null?d:null,l=a?.submitFieldMapping??u?.submitFieldMapping;if(l&&typeof l=="object"&&Object.keys(l).length>0){const f=s.map(p=>{if(p==null||typeof p!="object")return p;const m={};for(const[g,h]of Object.entries(l))g!=null&&g!==""&&h!=null&&h!==""&&(m[g]=Qe(p,h));return m});n[o]=f;continue}}n[o]=s}return n}function Ui(e){return!!(e instanceof File||Array.isArray(e)&&e.length>0&&e[0]instanceof File)}function uN(e){return Object.values(e).some(t=>Ui(t))}function fN(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 pN(e,t,r){const n={};let o=!1;return Object.entries(e).forEach(([s,i])=>{const a=t?.[s]||s;if(Ui(i)){n[a]=i,o=!0;return}const d=r?.[s]||"string";let u=i;if(d==="number"){const l=Number(i);u=isNaN(l)?i:l}else d==="boolean"?u=i==="true"||i===!0||i==="1"||i===1:d==="date"?u=String(i):i!=null?u=typeof i=="object"?i:String(i):u="";n[a]=u}),{transformed:n,hasFiles:o}}const ph=Object.freeze(Object.defineProperty({__proto__:null,hasFileValues:uN,isFileValue:Ui,prepareFormDataWithFiles:fN,transformFormValuesWithFiles:pN},Symbol.toStringTag,{value:"Module"}));function mN(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 hN(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 d;if(n.fieldPayloadKeys&&typeof n.fieldPayloadKeys=="object"&&!Array.isArray(n.fieldPayloadKeys)){d={};for(const[u,l]of Object.entries(n.fieldPayloadKeys))typeof l=="string"&&l.trim()&&(d[u]=l.trim());Object.keys(d).length===0&&(d=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}:{},...d?{fieldPayloadKeys:d}:{},...n.heading&&typeof n.heading=="object"?{heading:n.heading}:{}})}return t.length>0?t:void 0}function mh(e){return e?.mode==="nested_by_section"}function hh(e){const t=e.payloadKey?.trim();return t||null}function gh(e,t){return t.fieldPayloadKeys?.[e]?.trim()||e}function yh(e,t,r,n){if(!mh(r)||!t?.length)return{...e};const o=new Set([]),s=r?.includeUnassignedAtRoot!==!1,i=new Set,a={};for(const d of t){const u=hh(d);if(!u)continue;const l={};for(const f of d.fieldNames){if(o.has(f)||!(f in e))continue;i.add(f);const p=gh(f,d);l[p]=e[f]}Object.keys(l).length>0&&(a[u]=l)}if(s)for(const[d,u]of Object.entries(e))o.has(d)||i.has(d)||(a[d]=u);return a}function gN(e,t,r){const n={...e??{}};if(!mh(r)||!t?.length)return n;for(const o of t){const s=hh(o);if(s)for(const i of o.fieldNames){if(n[i]?.trim())continue;const a=gh(i,o);n[i]=`${s}.${a}`}}return n}function yN(e){return e==="null"?null:e==="true"?!0:e==="false"?!1:e}function bN(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 vN(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 d=i===n,u=i.startsWith(`${n}__addmore__`);if(!d&&!u||!bN(a))return;const l=Qe(a,o);l==null||l===""||s.push(l)}),s}function Vi(e,t,r,n,o,s){const i=e.trim().match(/^\{respAll:([^}]+)\}$/);if(i){const u=(i[1]||"").trim(),l=u.split("."),f=l.length>=2?l.slice(1).join("."):"";return(f==="data.id"||f==="data.documentId")&&n?.document_ids!=null&&Array.isArray(n.document_ids)?n.document_ids:vN(u,o)}const a=e.trim().match(/^\{(\w+)\}$/);if(a){const u=a[1],l=t[u];if(l!==void 0)return l;const f=Object.keys(t).find(p=>p.toLowerCase()===u.toLowerCase());if(f)return t[f]}const d=rn(e,t,r,n,o,s);return yN(String(d))}const wN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d,onClick:u,onSubmit:l,onReset:f,onCancel:p,isSubmitting:m=!1,formValues:g={},submissionContext:h,bffSubmitApi:y,onBffSubmitResult:w,extraSubmitPayload:v,buttonResponses:x,onButtonApiResponse:E,onValidateForm:P,getValidationErrors:_,allFields:N,onSubmittingChange:C,scopedFormValues:A,scopedFieldNameMap:I,prepopulateResponse:T=null,formSections:W,submitPayload:X})=>{const{gridStretch:O}=zo(),[j,M]=S.useState(!1),D=e.properties,L=ha.useParams(),U=S.useMemo(()=>({...h,...v}),[h,v]),$=S.useMemo(()=>{if(!A||!I||Object.keys(I).length===0)return g;const Je={};return Object.entries(A).forEach(([q,$e])=>{const gt=I[q]||q;gt!==e.name&&(Je[gt]=$e)}),Je},[A,I,g,e.name]),V=(()=>{try{const Je=e.metadata;if(typeof Je=="string")return JSON.parse(Je);if(Je&&typeof Je=="object")return Je}catch{}return null})(),K=D?.submitAction??V?.submitAction,J=D?.apiEndpoint??e.apidata?.apiEndpoint??V?.apiEndpoint;let ce=D?.action||V?.action;!ce&&e.type==="button"&&(ce="submit");const ne=D?.variant||"default",G=D?.size||"default",ee=D?.hideLabel??e.appearance?.hideLabel??!1,Pe=D?.buttonText||e.label||"Button",oe=D?.closeOnCancel??!0,re=async()=>{if(A&&I&&Object.keys(I).length>0||!P)return!0;const Je=await P();if(!Je&&_)try{const q=_();$t.toast.error(ec(q,N??void 0)||"Please fix the errors before submitting.")}catch{$t.toast.error("Please fix the errors before submitting.")}return Je},be=async Je=>{if(Je.preventDefault(),(ce==="submit"?"submit":ce)==="submit"){if(y?.url){if(!await re())return;M(!0),C?.(!0);try{const $e=await ot(),gt=($e?.message??$e?.display_message??"Form submitted successfully!").trim();$t.toast.success(gt||"Form submitted successfully!");const Oe=$e!=null&&typeof $e=="object"?$e:{status:"success",...$e!=null?{data:$e}:{}};E?.(e.name,Oe)}catch($e){const gt=ls($e);$t.toast.error(gt)}finally{M(!1),C?.(!1)}return}if(l){if(!await re())return;M(!0),C?.(!0);try{await l(),E?.(e.name,{status:"success"})}finally{M(!1),C?.(!1)}return}$t.toast.error("Submit not configured. BFF submit API is required for submit buttons.");return}else if(ce==="reset"&&f)f();else if(ce==="cancel")oe?p&&p():f&&f();else if(ce==="download"){const $e=D?.downloadApiEndpoint||V?.downloadApiEndpoint||e.downloadApiEndpoint,gt=D?.downloadApiMethod||V?.downloadApiMethod||e.downloadApiMethod;if($e){M(!0);try{const Oe=gt||"GET",te=cn(rn($e,$,L,U,x,T??void 0)),pe={method:Oe,headers:{}};Oe!=="GET"&&Oe!=="DELETE"&&(pe.headers={"Content-Type":"application/json"});const We=await fetch(te,pe);if(!We.ok)throw new Error(`Download failed: ${We.statusText}`);const Pt=await We.blob(),je=window.URL.createObjectURL(Pt),Te=document.createElement("a");Te.href=je;const Xe=We.headers.get("Content-Disposition");let Ue="download";if(Xe){const ft=Xe.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);ft&&ft[1]&&(Ue=ft[1].replace(/['"]/g,""))}Te.download=Ue,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te),window.URL.revokeObjectURL(je);try{const ft=lN(We);$t.toast.success(ft&&ft.trim()?ft:"Download started.")}catch{$t.toast.success("Download started.")}}catch(Oe){Zl(Oe,"Failed to download file. Please check the API endpoint and try again.",ls)}finally{M(!1)}}else $t.toast.error("Download endpoint is not configured")}else if(ce==="upload"||ce==="custom"){const $e=ce==="custom",gt=$e?"api":D?.uploadAction||V?.uploadAction||"database";if(gt==="database")if(l){M(!0);try{await l(Je)}catch(Oe){throw Oe}finally{M(!1)}}else $t.toast.error("Form submit handler is not available");else if(gt==="api"){const Oe=D?.uploadApiEndpoint||V?.uploadApiEndpoint||e.uploadApiEndpoint;if(D?.uploadApiMethod||V?.uploadApiMethod||e.uploadApiMethod,Oe){if(!await re())return;M(!0);try{const te=await Se();E?.(e.name,te),aN(te,$e?"Custom API call completed successfully!":"Upload completed successfully!")}catch(te){E?.(e.name,{status:"error",code:te?.response?.code??te?.response?.status??null,message:ls(te)}),Zl(te,$e?"Failed to call custom API. Please check the API endpoint and try again.":"Failed to upload. Please check the API endpoint and try again.",ls)}finally{M(!1)}}else $t.toast.error($e?"Custom API endpoint is not configured":"Upload endpoint is not configured")}else gt==="custom"&&$t.toast.info("Custom upload handler is not implemented")}else u?u():r&&t!==void 0&&r(t||"");n?.()},de=async()=>{if(!K||K!=="api"||!J)return null;const Je=D?.apiBodyFields??V?.apiBodyFields;if((D?.apiBodyFieldsOnly??V?.apiBodyFieldsOnly??!1)&&Je?.length){const Te={};return Je.forEach(({key:Xe,value:Ue})=>{const ft=Vi(Ue,$,L,U,x,T??void 0),St=Xe==="user_id"?"context_user_id":Xe;Te[St]=ft}),Te.user_id!==void 0&&Te.user_id!==null&&(Te.context_user_id=Te.context_user_id??Te.user_id,delete Te.user_id),Te}const $e=N?.length?tc($,N):$,gt=D?.apiFieldMapping??V?.apiFieldMapping,Oe=D?.apiFieldTypes??V?.apiFieldTypes,te=D?.apiBodyStructure??V?.apiBodyStructure,pe={...Oe};N?.length&&N.forEach(Te=>{const Xe=Te.name||Te.key;Xe&&(Te.type==="terms"||Te.type==="checkbox")&&(pe[Xe]="boolean")});const{transformFormValuesWithFiles:We}=await Promise.resolve().then(()=>ph),{transformed:Pt}=We($e,gt,pe);let je={};if(te==="flat"?je={...Pt}:je={data:{...Pt}},gt){const Te={};Object.keys(je).forEach(Xe=>{const Ue=gt[Xe]||Xe;Te[Ue]=je[Xe]}),je=Te}return Je?.length&&Je.forEach(({key:Te,value:Xe})=>{const Ue=Vi(Xe,$,L,U,x,T??void 0),ft=Te==="user_id"?"context_user_id":Te;je[ft]=Ue}),je.user_id!==void 0&&je.user_id!==null&&(je.context_user_id=je.context_user_id??je.user_id,delete je.user_id),je.data?.user_id!==void 0&&je.data?.user_id!==null&&(je.data.context_user_id=je.data.context_user_id??je.data.user_id,delete je.data.user_id),je},ot=async()=>{if(!y||!y.url)throw new Error("BFF submit API configuration is missing");const Je=N?.length?tc(g,N):g,q={};Object.keys(Je).forEach(ze=>{const yt=e.name===ze&&e.type==="button",pt=ze.toLowerCase().includes("button");!yt&&!pt&&(q[ze]=Je[ze])});const $e=Object.keys(q).filter(ze=>Ui(q[ze]));$e.forEach(ze=>{q[ze]=""});const gt=yh(q,W,X),Oe={workflow_id:y.payload?.workflow_id||"",current_step_id:y.payload?.current_step_id||"",form_data:gt},te=["workflow_id","current_step_id","form_data","submit_body","submit_api_endpoint","submit_api_method"];if(h&&typeof h=="object"&&Object.entries(h).forEach(([ze,yt])=>{if(yt==null||te.includes(ze))return;const pt=ze==="user_id"?"context_user_id":ze;Oe[pt]=Oe[pt]??yt}),v&&typeof v=="object"&&Object.entries(v).forEach(([ze,yt])=>{if(yt==null||te.includes(ze))return;const pt=ze==="user_id"?"context_user_id":ze;Oe[pt]=Oe[pt]??yt}),K==="api"&&J)try{const ze=await de();if(ze){const yt=D?.apiBodyStructure??V?.apiBodyStructure,pt=D?.apiFieldMapping??V?.apiFieldMapping;$e.forEach(Ut=>{const ur=pt?.[Ut]??Ut,Ar=q[Ut]!==void 0&&typeof q[Ut]=="string"?q[Ut]:"";yt==="flat"?ze[ur]=Ar:ze.data&&typeof ze.data=="object"?ze.data[ur]=Ar:ze[ur]=Ar}),Oe.submit_body=ze;let At=rn(J,$,L,U,x,T??void 0);At=At.replace(/\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}/gi,"$1"),At=cn(At),Oe.submit_api_endpoint=At,Oe.submit_api_method=D?.submitApiMethod||V?.submitApiMethod||"POST"}}catch{}const pe=(y.method||"POST").toUpperCase(),We=$e.length>0,Pt=Oe.submit_api_endpoint??J??"",je=typeof Pt=="string"?Pt.toLowerCase():"",Te=je.includes("/upload")||je.includes("/payments")||je.includes("/bulk-upload"),Xe=We&&Te;let Ue;const ft={...y.headers||{}};if(Xe){const ze=new FormData;ze.append("payload",JSON.stringify(Oe));for(const yt of $e){const pt=Je[yt],At=D?.apiFieldMapping?.[yt]??yt;pt instanceof File?ze.append(At,pt):Array.isArray(pt)&&pt.length>0&&pt[0]instanceof File&&pt.forEach(Ut=>ze.append(At,Ut))}Ue=ze,delete ft["content-type"],delete ft["Content-Type"]}else ft["Content-Type"]="application/json",Ue=JSON.stringify(Oe);const St=await fetch(y.url,{method:pe,headers:ft,body:Ue});if(!St.ok){let ze;const yt=await St.text();try{ze=JSON.parse(yt)}catch{ze={message:yt}}const pt=new Error(`BFF submission failed: ${St.status}`);throw pt.response=ze,pt}const xt=await St.json();return w?.(xt),l&&await l(),xt},Se=async()=>{const Je=D?.uploadApiEndpoint||V?.uploadApiEndpoint;if(!Je)throw new Error("Upload API endpoint is not configured");if(!D)throw new Error("Button properties are not configured");const q=(D.uploadApiMethod||"POST").toUpperCase(),$e=cn(rn(Je,$,L,U,x,T??void 0)),gt=D.apiBodyFieldsOnly??V?.apiBodyFieldsOnly??!1,Oe=D.apiBodyFieldsOnlyFormat??V?.apiBodyFieldsOnlyFormat??"json";let te={},pe;const We={};if(gt&&D.apiBodyFields&&D.apiBodyFields.length>0)if(D.apiBodyFields.forEach(({key:Te,value:Xe})=>{te[Te]=Vi(Xe,$,L,U,x,T??void 0)}),Oe==="multipart"){const Te=new FormData;Object.entries(te).forEach(([Xe,Ue])=>{if(Ue instanceof File){Te.append(Xe,Ue);return}if(Array.isArray(Ue)&&Ue.length>0&&Ue[0]instanceof File){Ue.forEach(ft=>Te.append(Xe,ft));return}Ue!=null&&Te.append(Xe,typeof Ue=="object"?JSON.stringify(Ue):String(Ue))}),pe=Te}else pe=JSON.stringify(te),We["Content-Type"]="application/json";else{const Te=$,{transformFormValuesWithFiles:Xe,prepareFormDataWithFiles:Ue,hasFileValues:ft}=await Promise.resolve().then(()=>ph),{transformed:St,hasFiles:xt}=Xe(Te,D.apiFieldMapping,D.apiFieldTypes);if((D.apiBodyStructure??V?.apiBodyStructure??"nested")==="flat"?te={...St}:te={data:{...St}},D.apiFieldMapping){const yt={};Object.keys(te).forEach(pt=>{const At=D.apiFieldMapping[pt]||pt;yt[At]=te[pt]}),te=yt}if(D.apiBodyFields&&D.apiBodyFields.forEach(({key:yt,value:pt})=>{te[yt]=Vi(pt,$,L,U,x,T??void 0)}),xt||ft(te)){const yt=Ue(te,D.apiFieldMapping);yt?pe=yt:(pe=JSON.stringify(te),We["Content-Type"]="application/json")}else pe=JSON.stringify(te),We["Content-Type"]="application/json"}D.apiHeaders&&D.apiHeaders.forEach(({key:Te,value:Xe})=>{const Ue=rn(Xe,$,L,U,x,T??void 0);(Te.toLowerCase()!=="content-type"||!(pe instanceof FormData))&&(We[Te]=Ue)});let Pt=$e;if(D.apiQueryParams&&D.apiQueryParams.length>0){const Te=new URLSearchParams;D.apiQueryParams.forEach(({key:Xe,value:Ue})=>{const ft=rn(Ue,$,L,U,x,T??void 0);Te.append(Xe,ft)}),Pt=`${$e}?${Te.toString()}`}const je=await fetch(Pt,{method:q,headers:We,body:q!=="GET"?pe:void 0});if(!je.ok){let Te;const Xe=await je.text();try{Te=JSON.parse(Xe)}catch{Te={message:Xe}}const Ue=new Error(`Upload failed: ${je.status}`);throw Ue.response=Te,Ue}try{return await je.json()}catch{return{}}},xe=ce==="submit"?"submit":ce,ve=xe==="submit"?"button":xe==="submit"?"submit":xe==="reset"?"reset":"button",Ye=s||e.disabled||i||e.readOnly||j||xe==="submit"&&m,ct=Pe,Ge=to(e),Kt=Fr(e.appearance)==="stretch";return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,hideLabel:ee,children:c.jsx("div",{className:B(O&&!Ge&&"flex w-full min-w-0 flex-col",O&&Ge&&"min-w-0 shrink-0"),children:c.jsxs(Yt,{id:ht(e),type:ve,variant:ne,size:G,disabled:Ye,onClick:be,className:B(e.appearance?.className,O&&!Ge&&"w-full min-w-0 shrink-0",O&&Ge&&!Kt&&"inline-flex w-auto max-w-full shrink-0",O&&Ge&&Kt&&"inline-flex w-full min-w-0 max-w-full shrink-0"),children:[j&&c.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}),ct]})})})},SN=({field:e,disabled:t,readOnly:r,isRequired:n,className:o,buttonResponses:s,onButtonApiResponse:i})=>{const a=e.properties,d=a?.buttonText??e.label??"Edit",u=a?.variant??"outline",l=a?.size??"default",f=a?.hideLabel??e.appearance?.hideLabel??!1,p=e.name||e.key||e.id,m=Uo(s?.[p]),g=t||e.disabled||r||e.readOnly||m,h=y=>{y.preventDefault(),!g&&i?.(p,{status:"success"})};return c.jsx(Et,{field:e,error:void 0,isRequired:n,className:o,hideLabel:f,children:c.jsx(Yt,{id:ht(e),type:"button",variant:u,size:l,disabled:g,onClick:h,className:B(e.appearance?.className,(!to(e)||Fr(e.appearance)==="stretch")&&"w-full min-w-0"),children:d})})},xN=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,onAddMore:i})=>{const a=e.properties||{},d=a.variant||"outline",u=a.size||"default",l=a.buttonText||e.label||"Add More",f=a.hideLabel??e.appearance?.hideLabel??!1,p=r||n||e.disabled||e.readOnly;return c.jsx(Et,{field:e,error:t,isRequired:o,className:s,hideLabel:f,children:c.jsxs(Yt,{id:ht(e),type:"button",variant:d,size:u,disabled:!!p,onClick:i,className:B("w-fit",e.appearance?.className),children:[c.jsx(nu,{className:"h-4 w-4 mr-1"}),l]})})},bh=S.createContext(null);function AN({value:e,children:t}){return c.jsx(bh.Provider,{value:e,children:t})}function CN(){return S.useContext(bh)}function vh(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function cs(e){return e.name||e.key||e.id}function rc(e){return e.filter(t=>!t.parentId&&t.type==="sectionHeading"&&cs(t))}function EN(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 NN(e){const t=new Map;for(const r of rc(e)){const n=cs(r);for(const o of EN(r))t.set(o,n)}return t}function _N(e,t){const r=t.properties||{},n=Array.isArray(r.sectionHeadingNames)?r.sectionHeadingNames.filter(i=>typeof i=="string"&&i.trim()):[],o=rc(e);if(n.length===0)return o;const s=new Set(n);return o.filter(i=>s.has(cs(i)))}function kN(e){const t={};for(const r of rc(e))t[cs(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 wh(e,t,r,n){if(!e||t==="customizeSections")return!0;const o=vh(e),s=t==="sectionHeading"?o:n.get(o);return s?r[s]!==!1:!0}const TN=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,designMode:i=!1})=>{const a=CN(),d=e.properties||{},u=d.variant||"outline",l=d.size||"default",f=d.buttonText||e.label||"Customise sections",p=d.menuTitle||"VISIBLE SECTIONS",m=d.hideLabel??e.appearance?.hideLabel??!1,g=r||n||e.disabled||e.readOnly,h=S.useMemo(()=>a?.allFields?.length?_N(a.allFields,e):[],[a?.allFields,e]);return c.jsx(Et,{field:e,error:t,isRequired:o,className:s,hideLabel:m,children:c.jsxs(Ol,{children:[c.jsx(Hp,{asChild:!0,children:c.jsxs(Yt,{id:ht(e),type:"button",variant:u,size:l,disabled:!!g,className:B("w-fit gap-2",e.appearance?.className),children:[c.jsx(Fv,{className:"h-4 w-4"}),f]})}),c.jsxs(Il,{align:"end",className:"w-64 p-0",children:[c.jsx("div",{className:"px-3 py-2 border-b",children:c.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:p})}),c.jsx("div",{className:"max-h-64 overflow-auto p-2 space-y-1",children:h.length===0?c.jsx("p",{className:"text-xs text-muted-foreground px-1 py-2",children:"No section headings on this form."}):h.map(y=>{const w=cs(y),v=y.label||w,x=i||!a?!0:a.visibility[w]!==!1;return c.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md px-1 py-1.5 hover:bg-muted/50",children:[c.jsx(Sn,{htmlFor:`ui-section-${e.id}-${w}`,className:"text-xs font-normal truncate",children:v}),c.jsx(Nm,{id:`ui-section-${e.id}-${w}`,checked:x,disabled:i||!a||!!g,onCheckedChange:E=>{!a||i||a.setSectionVisible(w,!!E)}})]},y.id)})})]})]})})},FN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=u?.max||5,f=u?.icon||"star",p=h=>{s||i||e.disabled||e.readOnly||(r(h),n?.())},m=h=>{},g=h=>{const y=t>=h+1,w=B("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 f==="star"?c.jsx(ou,{className:B(w,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h):c.jsx(ou,{className:B(w,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h)};return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{id:ht(e),className:"flex items-center gap-1",role:"radiogroup","aria-label":e.label,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[Array.from({length:l},(h,y)=>g(y)),u?.showValue!==!1&&c.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:t>0?t:""})]})})};var Sh=["PageUp","PageDown"],xh=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Ah={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},vo="Slider",[nc,PN,ON]=Ba(vo),[Ch]=vr(vo,[ON]),[IN,Hi]=Ch(vo),Eh=b.forwardRef((e,t)=>{const{name:r,min:n=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:d=0,defaultValue:u=[n],value:l,onValueChange:f=()=>{},onValueCommit:p=()=>{},inverted:m=!1,form:g,...h}=e,y=b.useRef(new Set),w=b.useRef(0),x=i==="horizontal"?MN:LN,[E=[],P]=Zr({prop:l,defaultProp:u,onChange:T=>{[...y.current][w.current]?.focus(),f(T)}}),_=b.useRef(E);function N(T){const W=zN(E,T);I(T,W)}function C(T){I(T,w.current)}function A(){const T=_.current[w.current];E[w.current]!==T&&p(E)}function I(T,W,{commit:X}={commit:!1}){const O=WN(s),j=RN(Math.round((T-n)/s)*s+n,O),M=qo(j,[n,o]);P((D=[])=>{const L=$N(D,M,W);if(HN(L,d*s)){w.current=L.indexOf(M);const U=String(L)!==String(D);return U&&X&&p(L),U?L:D}else return D})}return c.jsx(IN,{scope:e.__scopeSlider,name:r,disabled:a,min:n,max:o,valueIndexToChangeRef:w,thumbs:y.current,values:E,orientation:i,form:g,children:c.jsx(nc.Provider,{scope:e.__scopeSlider,children:c.jsx(nc.Slot,{scope:e.__scopeSlider,children:c.jsx(x,{"aria-disabled":a,"data-disabled":a?"":void 0,...h,ref:t,onPointerDown:Me(h.onPointerDown,()=>{a||(_.current=E)}),min:n,max:o,inverted:m,onSlideStart:a?void 0:N,onSlideMove:a?void 0:C,onSlideEnd:a?void 0:A,onHomeKeyDown:()=>!a&&I(n,0,{commit:!0}),onEndKeyDown:()=>!a&&I(o,E.length-1,{commit:!0}),onStepKeyDown:({event:T,direction:W})=>{if(!a){const j=Sh.includes(T.key)||T.shiftKey&&xh.includes(T.key)?10:1,M=w.current,D=E[M],L=s*j*W;I(D+L,M,{commit:!0})}}})})})})});Eh.displayName=vo;var[Nh,_h]=Ch(vo,{startEdge:"left",endEdge:"right",size:"width",direction:1}),MN=b.forwardRef((e,t)=>{const{min:r,max:n,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:d,onStepKeyDown:u,...l}=e,[f,p]=b.useState(null),m=Ze(t,x=>p(x)),g=b.useRef(void 0),h=ro(o),y=h==="ltr",w=y&&!s||!y&&s;function v(x){const E=g.current||f.getBoundingClientRect(),P=[0,E.width],N=ic(P,w?[r,n]:[n,r]);return g.current=E,N(x-E.left)}return c.jsx(Nh,{scope:e.__scopeSlider,startEdge:w?"left":"right",endEdge:w?"right":"left",direction:w?1:-1,size:"width",children:c.jsx(kh,{dir:h,"data-orientation":"horizontal",...l,ref:m,style:{...l.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:x=>{const E=v(x.clientX);i?.(E)},onSlideMove:x=>{const E=v(x.clientX);a?.(E)},onSlideEnd:()=>{g.current=void 0,d?.()},onStepKeyDown:x=>{const P=Ah[w?"from-left":"from-right"].includes(x.key);u?.({event:x,direction:P?-1:1})}})})}),LN=b.forwardRef((e,t)=>{const{min:r,max:n,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:d,...u}=e,l=b.useRef(null),f=Ze(t,l),p=b.useRef(void 0),m=!o;function g(h){const y=p.current||l.current.getBoundingClientRect(),w=[0,y.height],x=ic(w,m?[n,r]:[r,n]);return p.current=y,x(h-y.top)}return c.jsx(Nh,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:c.jsx(kh,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:h=>{const y=g(h.clientY);s?.(y)},onSlideMove:h=>{const y=g(h.clientY);i?.(y)},onSlideEnd:()=>{p.current=void 0,a?.()},onStepKeyDown:h=>{const w=Ah[m?"from-bottom":"from-top"].includes(h.key);d?.({event:h,direction:w?-1:1})}})})}),kh=b.forwardRef((e,t)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:d,...u}=e,l=Hi(vo,r);return c.jsx(Be.span,{...u,ref:t,onKeyDown:Me(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):Sh.concat(xh).includes(f.key)&&(d(f),f.preventDefault())}),onPointerDown:Me(e.onPointerDown,f=>{const p=f.target;p.setPointerCapture(f.pointerId),f.preventDefault(),l.thumbs.has(p)?p.focus():n(f)}),onPointerMove:Me(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:Me(e.onPointerUp,f=>{const p=f.target;p.hasPointerCapture(f.pointerId)&&(p.releasePointerCapture(f.pointerId),s(f))})})}),Th="SliderTrack",Fh=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=Hi(Th,r);return c.jsx(Be.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...n,ref:t})});Fh.displayName=Th;var oc="SliderRange",Ph=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=Hi(oc,r),s=_h(oc,r),i=b.useRef(null),a=Ze(t,i),d=o.values.length,u=o.values.map(p=>Mh(p,o.min,o.max)),l=d>1?Math.min(...u):0,f=100-Math.max(...u);return c.jsx(Be.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...n,ref:a,style:{...e.style,[s.startEdge]:l+"%",[s.endEdge]:f+"%"}})});Ph.displayName=oc;var sc="SliderThumb",Oh=b.forwardRef((e,t)=>{const r=PN(e.__scopeSlider),[n,o]=b.useState(null),s=Ze(t,a=>o(a)),i=b.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return c.jsx(DN,{...e,ref:s,index:i})}),DN=b.forwardRef((e,t)=>{const{__scopeSlider:r,index:n,name:o,...s}=e,i=Hi(sc,r),a=_h(sc,r),[d,u]=b.useState(null),l=Ze(t,v=>u(v)),f=d?i.form||!!d.closest("form"):!0,p=Jo(d),m=i.values[n],g=m===void 0?0:Mh(m,i.min,i.max),h=jN(n,i.values.length),y=p?.[a.size],w=y?UN(y,g,a.direction):0;return b.useEffect(()=>{if(d)return i.thumbs.add(d),()=>{i.thumbs.delete(d)}},[d,i.thumbs]),c.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${w}px)`},children:[c.jsx(nc.ItemSlot,{scope:e.__scopeSlider,children:c.jsx(Be.span,{role:"slider","aria-label":e["aria-label"]||h,"aria-valuemin":i.min,"aria-valuenow":m,"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:l,style:m===void 0?{display:"none"}:e.style,onFocus:Me(e.onFocus,()=>{i.valueIndexToChangeRef.current=n})})}),f&&c.jsx(Ih,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},n)]})});Oh.displayName=sc;var BN="RadioBubbleInput",Ih=b.forwardRef(({__scopeSlider:e,value:t,...r},n)=>{const o=b.useRef(null),s=Ze(o,n),i=Qo(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const d=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(d,"value").set;if(i!==t&&l){const f=new Event("input",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Be.input,{style:{display:"none"},...r,ref:s,defaultValue:t})});Ih.displayName=BN;function $N(e=[],t,r){const n=[...e];return n[r]=t,n.sort((o,s)=>o-s)}function Mh(e,t,r){const s=100/(r-t)*(e-t);return qo(s,[0,100])}function jN(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function zN(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 UN(e,t,r){const n=e/2,s=ic([0,50],[0,n]);return(n-s(t)*r)*r}function VN(e){return e.slice(0,-1).map((t,r)=>e[r+1]-t)}function HN(e,t){if(t>0){const r=VN(e);return Math.min(...r)>=t}return!0}function ic(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 WN(e){return(String(e).split(".")[1]||"").length}function RN(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}var GN=Eh,KN=Fh,qN=Ph,YN=Oh;function XN({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 c.jsxs(GN,{"data-slot":"slider",defaultValue:t,value:r,min:n,max:o,className:B("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:[c.jsx(KN,{"data-slot":"slider-track",className:B("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:c.jsx(qN,{"data-slot":"slider-range",className:B("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:i.length},(a,d)=>c.jsx(YN,{"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"},d))]})}const JN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties,l=u?.min??0,f=u?.max??100,p=u?.step??1,m=u?.showValue!==!1,g=u?.marks||[],h=w=>{s||i||e.disabled||e.readOnly||(r(w[0]??l),n?.())},y=t??l;return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[m&&c.jsx("span",{className:"text-sm font-medium",children:y}),!m&&c.jsx("span",{className:"text-sm text-muted-foreground",children:l}),!m&&c.jsx("span",{className:"text-sm text-muted-foreground",children:f})]}),c.jsx(XN,{id:ht(e),value:[y],onValueChange:h,min:l,max:f,step:p,disabled:s||e.disabled||i||e.readOnly,className:B("w-full",o&&"border-destructive",e.appearance?.className),"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a}),g.length>0&&c.jsx("div",{className:"flex justify-between text-xs text-muted-foreground",children:g.map((w,v)=>c.jsx("span",{className:"text-center",children:w.label},v))})]})})},QN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=S.useRef(null),[l,f]=S.useState(!1),p=s||e.disabled||i||e.readOnly,m=S.useCallback(w=>{if(p)return;f(!0);const v=u.current;if(!v)return;const x=v.getContext("2d");if(!x)return;const E=v.getBoundingClientRect(),P="touches"in w?w.touches[0].clientX-E.left:w.clientX-E.left,_="touches"in w?w.touches[0].clientY-E.top:w.clientY-E.top;x.beginPath(),x.moveTo(P,_)},[p]),g=S.useCallback(w=>{if(!l||p)return;const v=u.current;if(!v)return;const x=v.getContext("2d");if(!x)return;const E=v.getBoundingClientRect(),P="touches"in w?w.touches[0].clientX-E.left:w.clientX-E.left,_="touches"in w?w.touches[0].clientY-E.top:w.clientY-E.top;x.lineWidth=2,x.lineCap="round",x.strokeStyle="#000",x.lineTo(P,_),x.stroke(),x.beginPath(),x.moveTo(P,_)},[l,p]),h=S.useCallback(()=>{if(!l)return;f(!1);const w=u.current;if(!w)return;const v=w.toDataURL();r(v),n?.()},[l,r,n]),y=S.useCallback(()=>{const w=u.current;if(!w||p)return;const v=w.getContext("2d");v&&(v.clearRect(0,0,w.width,w.height),r(null),n?.())},[p,r,n]);return S.useEffect(()=>{const w=u.current;if(w&&(w.width=w.offsetWidth,w.height=200,t)){const v=new Image;v.onload=()=>{const x=w.getContext("2d");x&&x.drawImage(v,0,0)},v.src=t}},[t]),c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:B("border-2 border-dashed rounded-lg overflow-hidden",o&&"border-destructive",p&&"opacity-50 cursor-not-allowed"),children:c.jsx("canvas",{ref:u,id:ht(e),className:"w-full cursor-crosshair touch-none",onMouseDown:m,onMouseMove:g,onMouseUp:h,onMouseLeave:h,onTouchStart:m,onTouchMove:g,onTouchEnd:h,"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,style:{height:"200px"}})}),!p&&c.jsx("div",{className:"flex justify-end",children:c.jsxs(Yt,{type:"button",variant:"outline",size:"sm",onClick:y,className:"text-xs",children:[c.jsx(Go,{className:"h-3 w-3 mr-1"}),"Clear"]})})]})})},ZN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d,hideRowControls:u=!1,formValues:l,submissionContext:f})=>{const p=e.properties,m=p?.columns||[],g=p?.minRows||1,h=p?.maxRows||10,y=!u&&p?.allowAddRow!==!1,w=!u&&p?.allowDeleteRow!==!1,v=s===!1&&i===!1?!1:s||e.disabled||i||e.readOnly,x=t||[],E=y&&x.length<h,P=w&&x.length>g,_=S.useCallback(()=>{if(!E||v)return;const O={};m.forEach(j=>{O[j.name]=j.defaultValue??""}),r([...x,O]),n?.()},[x,m,E,v,r,n]),N=S.useCallback(O=>{if(!P||v)return;const j=x.filter((M,D)=>D!==O);r(j),n?.()},[x,P,v,r,n]),C=S.useCallback((O,j,M)=>{if(v)return;const D=[...x];D[O]||(D[O]={}),D[O][j]=M,r(D),n?.()},[x,v,r,n]);if(S.useEffect(()=>{if(x.length<g){const O=g-x.length,j=[];for(let M=0;M<O;M++){const D={};m.forEach(L=>{D[L.name]=L.defaultValue??""}),j.push(D)}r([...x,...j])}},[g,m,r,x.length]),m.length===0)return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.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 A=Math.max(1,e.position?.rowSpan??1),I=Math.max(1,e.position?.columnSpan??1),T=Math.max(x.length,1),W=A>=3?"py-4":A>=2?"py-3":"py-2.5",X=I>=3?"px-4":I>=2?"px-3":"px-4";return c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{id:ht(e),className:B("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",v&&"opacity-50"),"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.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:[c.jsx("thead",{children:c.jsxs("tr",{className:"border-b border-border bg-muted/60",children:[m.map(O=>c.jsxs("th",{className:B(X,W,"text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground whitespace-nowrap"),children:[O.label,a&&O.validation?.some(j=>j.type==="required")&&c.jsx("span",{className:"text-destructive ml-1",children:"*"})]},O.id)),w&&c.jsx("th",{className:"w-12"})]})}),c.jsx("tbody",{className:"h-full",children:x.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:m.length+(w?1:0),className:B(X,"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.'})}):x.map((O,j)=>{const M=x[j],D=M&&typeof M=="object"&&!Array.isArray(M)?{...l??{},...M}:l;return c.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/30 transition-colors last:border-b-0",style:{height:`${100/T}%`},children:[m.map(L=>{const U={...L,name:`${e.name}_${j}_${L.name}`,appearance:{...L.appearance,hideLabel:!0}},$=L.name??"",ie=O[$]!==void 0?O[$]:$&&Object.keys(O).find(G=>G.toLowerCase()===$.toLowerCase())?O[Object.keys(O).find(G=>G.toLowerCase()===$.toLowerCase())]:void 0,V=!!L.readOnly,K=G=>{if(G==null)return"";if(Array.isArray(G))return G.map(ee=>typeof ee=="object"&&ee!==null&&"name"in ee?String(ee.name??ee):String(ee)).join(", ");if(typeof G=="object"&&G!==null&&!(G instanceof Date)){const ee=G;return typeof ee.name=="string"&&typeof ee.code=="string"?`${ee.code} ${ee.name}`.trim():typeof ee.name=="string"?ee.name:typeof ee.code=="string"?ee.code:String(ee.name??ee.code??G)}return String(G)},J=G=>typeof G=="object"&&G!==null&&!Array.isArray(G)?K(G):String(G??""),ce=L.name?.toLowerCase()==="type"||L.label?.toLowerCase()==="type";if(V){const G=K(ie);return c.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:c.jsx("div",{className:"min-w-[120px] text-sm text-foreground",children:ce&&G?c.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}):c.jsx("span",{className:"py-1 block",children:G})})},L.id)}const ne=()=>{switch(L.type){case"text":case"password":case"url":return c.jsx(Da,{field:U,value:J(ie),onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"});case"number":return c.jsx(Xd,{field:U,value:ie??null,onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"});case"email":return c.jsx(su,{field:U,value:J(ie),onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"});case"phone":case"aadhaar":return c.jsx(iu,{field:U,value:J(ie),onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"});case"textarea":return c.jsx(au,{field:U,value:J(ie),onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"});case"select":return c.jsx(kp,{field:U,value:typeof ie=="string"?ie:J(ie),onChange:G=>C(j,L.name,G),disabled:v,className:"w-full",formValues:D,submissionContext:f});case"multiselect":{const G=Array.isArray(ie)?ie:ie!=null&&ie!==""?[String(ie)]:[];return c.jsx(vm,{field:U,value:G,onChange:ee=>C(j,L.name,ee),disabled:v,className:"w-full",formValues:D,submissionContext:f})}case"asyncsearch":return c.jsx(Xp,{field:U,value:ie,onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full",formValues:D,submissionContext:f});case"checkbox":return c.jsx(wm,{field:U,value:ie||!1,onChange:G=>C(j,L.name,G),disabled:v,className:"w-full"});case"radio":case"checkboxgroup":return c.jsx(Gm,{field:U,value:typeof ie=="string"?ie:J(ie),onChange:G=>C(j,L.name,G),disabled:v,className:"w-full"});case"date":case"time":case"datetime":case"daterange":return c.jsx(Km,{field:U,value:typeof ie=="string"?ie:J(ie),onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"});default:return c.jsx(Da,{field:U,value:J(ie),onChange:G=>C(j,L.name,G),disabled:v,readOnly:v,className:"w-full"})}};return c.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:c.jsx("div",{className:"min-w-[160px] w-full [&_input]:min-w-[10rem] [&_input]:overflow-visible [&_textarea]:min-h-[2.5rem]",children:ne()})},L.id)}),w&&c.jsx("td",{className:"px-2 py-2",children:c.jsx(Yt,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>N(j),disabled:!P||v,children:c.jsx(Go,{className:"h-4 w-4"})})})]},j)})})]})}),E&&c.jsx("div",{className:"shrink-0 p-3 border-t bg-muted/30",children:c.jsxs(Yt,{type:"button",variant:"outline",size:"sm",onClick:_,disabled:v,className:"w-full",children:[c.jsx(nu,{className:"h-4 w-4 mr-2"}),"Add Row"]})})]})})},e_="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",t_="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",r_="h-8 min-w-[2ch] max-w-full flex-1 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0";function Lh(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 n_(e){const t=e.replace(/[^\d.-]/g,"");if(t===""||t==="-"||t===".")return null;const r=parseFloat(t);return Number.isNaN(r)?null:r}function o_(e){if(e==null||e==="")return"";const t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?"":String(t)}function Dh(e,t){return Lh(e,{format:"currency"},t)}function ds(e){return e==null||e===""}function Bh(e){return e.mode??"editable"}function s_(e,t){return e.kind==="currency"||e.kind==="input"&&e.inputType==="number"?!0:t?.format==="currency"||t?.format==="number"||t?.format==="percent"}function $h(e,t,r){if(e!==void 0){if(e==="")return"";if(s_(t,r)){const n=Number(e);return Number.isNaN(n)?e:n}return e}}function ac(e,t){if(!(!e||!("defaultValue"in e)||e.defaultValue===void 0))return $h(e.defaultValue,e,t)}function lc(e,t,r){if(!t||!ds(e))return e;if(t.kind==="currency"&&Bh(t)==="static"&&t.value!==void 0)return $h(t.value,t,r);const n=ac(t,r);return n!==void 0?n:e}function i_(e,t,r){const n={...t};for(const[o,s]of Object.entries(e)){const i=r.find(d=>d.key===o);if(!ds(n[o]))continue;const a=lc(n[o],s,i);(!ds(a)||s&&"defaultValue"in s&&s.defaultValue==="")&&(n[o]=a)}return n}function Wi(e,t,r){if(!ds(e))return e;const n=ac(t,r);return n!==void 0?n:e}const a_=new Set(["all_items_summary","invoice_discount","grand_total"]);function l_(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"&&!a_.has(r.slotId));default:return e}}function cc(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}function c_(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 d_(e,t,r){const n=u=>cc(r.values[u]),o=(u,l)=>{const f=t.find(p=>p.slotId===u&&p.rowKind==="static");return f?cc(f.values[l]):0},s=(u,l="all")=>l_(t,l).reduce((f,p)=>f+cc(p.values[u]),0),i={...Ds.functions,cell:n,cellInRow:o,SUM:s},a=Object.keys(i),d=Object.values(i);try{const u=new Function(...a,`return (${e});`)(...d);return u==null||typeof u=="number"&&Number.isNaN(u)?null:u}catch{return null}}function wo(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=c_(e,n,o.key);if(s?.kind==="formula"){const i=d_(s.expression,r,n),a=e.columns.find(d=>d.key===o.key);n.values[o.key]=ds(i)?ac(s,a)??i:i}}return{rows:r}}function u_(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 wo(e,{rows:i})}function jh(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,l]of Object.entries(e.cells)){const f=r.find(p=>p.key===u);(l.kind==="api"&&l.path||l.kind==="currency"&&l.mode==="api"&&l.path)&&(a[u]=Wi(Qe(s,l.path),l,f))}const d=a.service??a.tariff_type;return{slotId:e.id,rowKind:"dynamic",rowInstanceId:i,label:typeof d=="string"?d:void 0,values:a}})}function dc(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 uc(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:i_(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:dc(e,r,n)}}function f_(e,t,r,n){const o=uc(e,n),s=e.rowSlots.find(d=>d.kind==="dynamic"&&d.block.id===t);if(!s||s.kind!=="dynamic")return wo(e,o);const i=new Map,a=new Map;for(const d of e.rowSlots)if(d.kind==="static"){const u=o.rows.find(l=>l.slotId===d.row.id&&l.rowKind==="static");u&&i.set(d.row.id,{...u,values:{...u.values}})}else{const u=d.block.id===t?jh(d.block,r,e.columns):o.rows.filter(l=>l.slotId===d.block.id&&l.rowKind==="dynamic");a.set(d.block.id,u.map(l=>({...l,values:{...l.values}})))}return wo(e,{rows:dc(e,i,a)})}function p_(e,t,r){const n=uc(e,r);if(t==null||typeof t!="object"||Array.isArray(t))return wo(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(f=>f.slotId===a.row.id&&f.rowKind==="static")?.values??{}},l=o[a.row.id]??o;for(const[f,p]of Object.entries(a.row.cells)){const m=e.columns.find(g=>g.key===f);(p.kind==="api"&&p.path||p.kind==="currency"&&p.mode==="api"&&p.path)&&(u[f]=Wi(Qe(l,p.path),p,m))}s.set(a.row.id,{slotId:a.row.id,rowKind:"static",rowInstanceId:a.row.id,label:a.row.label,values:u})}else{const d=a.block.apiArrayPath??a.block.id,u=Qe(o,d);i.set(a.block.id,Array.isArray(u)?jh(a.block,u,e.columns):[])}return wo(e,{rows:dc(e,s,i)})}function zh(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 m_(e){const t=e?.color?.trim();return t?{color:t}:{}}function fc(e){return{className:zh(e),style:m_(e)}}function h_(e){return e?!!(e.fontSize||e.bold||e.italic||e.underline||e.color?.trim()):!1}function g_(e,t){if(!e&&!t)return;const r={...e,...t};return h_(r)?r:void 0}function y_(e,t){const r=e?.kind==="label"?g_(t,e.cellStyle):e?.cellStyle;return fc(r)}function pc(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function Uh(e,t){return e?.align?e.align:t?.align??"left"}function b_(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 Vh(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 v_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:d})=>{const u=e.properties??{},l=u.columns??[],f=u.currencySymbol??"₹",p=u.emptyDisplay??"—",m=s||i,g=S.useMemo(()=>{const N=uc(u,t);return wo(u,N)},[u,t]);S.useEffect(()=>{!t?.rows?.length&&g.rows.length&&r(g)},[t,g,r]);const h=S.useCallback((N,C,A,I,T)=>{if(m)return;const W=T==="number"?n_(I):I===""?null:I,X=u_(u,g,N,C,A,W);r(X)},[m,g,r,u]),y=(N,C,A,I,T,W)=>{const X=l.find($=>$.key===T),O=Vh(u,N,C,T),j=pc(Uh(O,X)),M=lc(W,O,X),D=b_(u,N,C),L=D?.kind==="static"?D.row.labelStyle:D?.kind==="dynamic"?D.block.labelStyle:void 0,U=y_(O,L);if(O?.kind==="label")return c.jsx("span",{className:B(U.className||"font-medium",j,!U.style.color&&"text-foreground"),style:U.style,children:I??p});if(O?.kind==="input"&&!m){const $=M==null||M===""?"":String(M);return c.jsx(wn,{type:"text",inputMode:O.inputType==="number"?"decimal":"text",value:$,onChange:ie=>h(A,N,T,ie.target.value,O.inputType),onBlur:n,className:B(e_,j,U.className),style:U.style,disabled:m})}if(O?.kind==="currency"){const $=Bh(O);if($==="static"){const V=O.value!==void 0&&O.value!==""?lc(null,{...O,mode:"static"},X):M;return c.jsx("span",{className:B("tabular-nums",j,U.className),style:U.style,children:Dh(V,{currencySymbol:f,emptyDisplay:p})})}if($==="api"||m)return c.jsx("span",{className:B("tabular-nums",j,U.className),style:U.style,children:Dh(M,{currencySymbol:f,emptyDisplay:p})});const ie=o_(M);return c.jsxs("div",{className:B(t_,j==="text-center"&&"justify-center",j==="text-right"&&"justify-end",j==="text-left"&&"justify-start",U.className),style:U.style,children:[c.jsx("span",{className:"shrink-0 tabular-nums",children:f}),c.jsx(wn,{type:"text",inputMode:"decimal",value:ie,onChange:V=>h(A,N,T,V.target.value,"number"),onBlur:n,className:r_,disabled:m})]})}return O?.kind==="static"?c.jsx("span",{className:B(j,U.className,!U.style.color&&"text-muted-foreground"),style:U.style,children:O.value}):c.jsx("span",{className:B(j,U.className),style:U.style,children:Lh(M,X,{currencySymbol:f,emptyDisplay:p})})},w=u.gridTitle?.trim()??"",v=Math.max(1,e.position?.rowSpan??1),x=Math.max(1,e.position?.columnSpan??1),E=Math.max(g.rows.length,1),P=v>=3?"py-4":v>=2?"py-3":"py-2",_=x>=3?"px-4":x>=2?"px-3":"px-2";return l.length===0?c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this billing grid"})}):c.jsx(Et,{field:e,error:o,isRequired:a,className:d,children:c.jsxs("div",{id:ht(e),className:B("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",m&&"opacity-70"),"aria-describedby":jt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[w?c.jsx("div",{className:B("shrink-0 px-4 py-2 border-b bg-muted/40",zh(u.gridTitleStyle)||"text-muted-foreground"),style:fc(u.gridTitleStyle).style,children:w}):null,c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:u.minWidth?{minWidth:u.minWidth}:void 0,children:[c.jsx("thead",{children:c.jsx("tr",{className:"border-b border-border bg-muted/60",children:l.map(N=>{const C=fc(N.headerStyle);return c.jsx("th",{className:B(_,P,"text-xs uppercase tracking-wider whitespace-nowrap",pc(N.align),C.className||"font-semibold text-muted-foreground"),style:C.style,children:N.label},N.id)})})}),c.jsx("tbody",{className:"h-full",children:g.rows.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:l.length,className:B(_,"py-8 text-center text-sm text-muted-foreground"),children:"No billing rows configured"})}):g.rows.map(N=>c.jsx("tr",{className:"border-b border-border/60",style:{height:`${100/E}%`},children:l.map(C=>{const A=Vh(u,N.slotId,N.rowKind,C.key),I=Uh(A,C);return c.jsx("td",{className:B(_,P,"align-middle whitespace-nowrap",pc(I)),children:y(N.slotId,N.rowKind,N.rowInstanceId,N.label,C.key,N.values[C.key])},C.id)})},`${N.slotId}-${N.rowInstanceId}`))})]})})]})})};function mc(e,t,r){return p_(e,t,r)}const w_=({field:e,value:t,error:r,disabled:n,isRequired:o,className:s,formValues:i={},submissionContext:a,extraSubmitPayload:d,skipApiCall:u=!1,prepopulateResponse:l=null})=>{const f=e.properties||{},p=f.source??"manual",m=Array.isArray(f.statuses)?f.statuses:[],g=(f.dataPath||"data").trim(),h=f.showStatusText===!0,y=(f.statusTextPath||"data.admissionStatus").trim(),w=f.showCurrentIndicator!==!1,[v,x]=S.useState(null),[E,P]=S.useState(!1),[_,N]=S.useState(null),C=ha.useParams(),A=S.useRef(i),I=S.useRef(a),T=S.useRef(d),W=S.useRef(C);A.current=i,I.current=a,T.current=d,W.current=C;const X=S.useCallback(async()=>{const L=f.apiEndpoint?.trim();if(!L){N("Status API endpoint is not configured");return}P(!0),N(null);try{const U=I.current,$=T.current,ie=U!=null&&typeof U=="object"?{...U,...$||{}}:$||{},V=cn(rn(L,A.current,W.current,ie,void 0,l??void 0)),K=(f.apiMethod||"GET").toUpperCase(),J=await fetch(V,{method:K,headers:K==="POST"?{"Content-Type":"application/json"}:void 0});if(!J.ok)throw new Error(`HTTP ${J.status}`);const ce=await J.json(),ne=g?Qe(ce,g):ce;x(ne&&typeof ne=="object"?ne:{})}catch(U){N(U instanceof Error?U.message:"Failed to load status"),x(null)}finally{P(!1)}},[f.apiEndpoint,f.apiMethod,g,l]);S.useEffect(()=>{p==="api"&&!u&&X()},[p,u,X]);const O=p==="api"?v:t&&typeof t=="object"?(g?Qe(t,g):null)??t:null,j=h&&y&&O?String(Qe(O,y)??Qe({data:O},y)??""):"",M=L=>{if(!O||typeof O!="object")return!1;const U=O[L];return U===!0||U==="true"||U===1};let D=!1;return c.jsx(Et,{field:e,error:r||_||void 0,isRequired:o,className:B(s,"!space-y-0 h-full min-h-0 flex flex-col"),children:c.jsxs("div",{className:"rounded-lg border bg-card p-4 h-full min-h-0 flex flex-col",children:[E&&c.jsx("div",{className:"text-sm text-muted-foreground py-2",children:"Loading status..."}),h&&j&&!E&&c.jsx("p",{className:"text-sm text-muted-foreground mb-3 shrink-0","data-status-text":!0,children:j}),!E&&c.jsx("ul",{className:"flex-1 min-h-0 flex flex-col gap-y-8 overflow-y-auto pr-1 py-1",children:m.map(L=>{const U=M(L.key),$=w&&U&&!D;return $&&(D=!0),c.jsxs("li",{className:B("flex items-center gap-3 text-sm",U?"text-foreground":"text-muted-foreground"),children:[U?c.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:c.jsx(Vs,{className:"h-3 w-3"})}):c.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:c.jsx(eu,{className:"h-2.5 w-2.5 text-muted-foreground/60"})}),c.jsx("span",{className:"flex-1 min-w-0",children:L.label}),$&&c.jsx("span",{className:"shrink-0 text-xs font-medium text-primary",children:"Current"})]},L.key)})}),!E&&m.length===0&&c.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 So(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 S_(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 x_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,submissionContext:d})=>{const u=e.properties||{},{dataSourceContextKey:l,labelField:f="name",valueField:p="email",displayFields:m,displayFieldsSeparator:g=" | ",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:d?Object.keys(d):[],dataSourceContextKey:l,contextKeyValue:d&&l?d[l]:void 0});const w=S.useMemo(()=>{if(!l||!d)return[];const T=d[l];return Array.isArray(T)?T:[]},[l,d]);console.log("[SelectableList] Step 2: contextList from submissionContext",{fieldName:e.name,contextListLength:w.length,contextListSample:w.length>0?w.slice(0,2):[]});const[v,x]=S.useState(()=>w.length>0?w:Array.isArray(t)?t:[]);S.useEffect(()=>{if(w.length>0){console.log("[SelectableList] Step 3: sync fullList from context",{fieldName:e.name,contextListLength:w.length}),x(w);return}Array.isArray(t)&&t.length>0&&x(T=>{const W=T.length===0||t.length>T.length?t:T;return console.log("[SelectableList] Step 3: sync fullList from value",{fieldName:e.name,valueLength:t.length,prevLength:T.length,nextLength:W.length}),W})},[w,t]);const E=S.useMemo(()=>{const T=Array.isArray(t)?t:[];return new Set(T.map(X=>So(X,p)))},[t,p]),P=v.length>0&&v.every(T=>E.has(So(T,p))),_=v.some(T=>E.has(So(T,p))),N=S.useCallback((T,W)=>{const X=So(T,p),O=Array.isArray(t)?t:[];W?E.has(X)||r([...O,T]):r(O.filter(j=>So(j,p)!==X)),n?.()},[t,p,E,r,n]),C=S.useCallback(T=>{r(T===!0?[...v]:[]),n?.()},[v,r,n]),A=v.length>0?v:Array.isArray(t)?t:[],I=s||e.disabled;return console.log("[SelectableList] Data in list",{fieldName:e.name,listLength:A.length,listSource:v.length>0?"fullList":"value",valueLength:Array.isArray(t)?t.length:0,fullListLength:v.length,listData:A.length>0?A:[],listDataFirstThree:A.length>0?A.slice(0,3):[]}),c.jsx("div",{className:B("relative z-10 flex flex-col min-h-0 h-full w-full",A.length>0&&"min-h-[14rem]",a),children:c.jsx(Et,{field:e,error:o,isRequired:i,className:B("flex-1 min-h-0 flex flex-col",A.length>0&&"min-h-[14rem]"),children:c.jsx("div",{className:B("flex-1 min-h-0 flex flex-col",A.length>0&&"min-h-[14rem]"),children:c.jsxs("div",{className:B("flex-1 min-h-0 flex flex-col",A.length>0&&"overflow-visible"),children:[c.jsxs("div",{role:"listbox","aria-multiselectable":!0,className:B("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",A.length>0?"flex-1 min-h-0":"min-h-0"),children:[h&&A.length>0&&c.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:[c.jsx(Ti,{id:`${ht(e)}-select-all`,checked:P?!0:_?"indeterminate":!1,onCheckedChange:C,disabled:I,"aria-label":"Select all"}),c.jsxs(Sn,{htmlFor:`${ht(e)}-select-all`,className:"text-sm font-medium cursor-pointer",children:["Select all (",A.length,")"]}),c.jsxs("div",{className:"flex gap-1 ml-auto",children:[c.jsx(Yt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:I||P,onClick:()=>{r([...v]),n?.()},children:"Select all"}),c.jsx(Yt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:I||!_,onClick:()=>{r([]),n?.()},children:"Unselect all"})]})]}),A.length===0?c.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No items to display."}):c.jsx(c.Fragment,{children:A.map((T,W)=>{const X=So(T,p),O=E.has(X),j=`${ht(e)}-${W}-${X}`;return c.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:[c.jsx(Ti,{id:j,checked:O,onCheckedChange:M=>N(T,M===!0),disabled:I,"aria-describedby":jt(e,!!o)}),c.jsx(Sn,{htmlFor:j,className:"text-sm cursor-pointer flex-1 truncate",children:S_(T,f,m,g)})]},X)})})]}),A.length>0&&E.size===0&&c.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:[c.jsx(_v,{className:"h-4 w-4 shrink-0"}),"Please select at least one item."]})]})})})})},Hh=({field:e,children:t,className:r})=>{const n=e.properties,o=n?.collapsible??!1,s=n?.defaultCollapsed??!1,i=n?.columns??1,[a,d]=S.useState(s),u=()=>{o&&d(!a)},l={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 c.jsxs("div",{className:B("border rounded-lg bg-card",r),children:[c.jsxs("div",{className:B("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&&c.jsx("span",{className:"text-muted-foreground",children:a?c.jsx(Zd,{className:"h-4 w-4"}):c.jsx(Wo,{className:"h-4 w-4"})}),c.jsx("h3",{className:"font-medium text-sm",children:e.label}),e.description&&c.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:e.description})]}),!a&&c.jsx("div",{className:B("p-4 grid gap-4",l[i]),children:t})]})};var A_=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],C_=A_.reduce((e,t)=>{const r=La(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,d=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),E_="Separator",Wh="horizontal",N_=["horizontal","vertical"],Rh=b.forwardRef((e,t)=>{const{decorative:r,orientation:n=Wh,...o}=e,s=__(n)?n:Wh,a=r?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(C_.div,{"data-orientation":s,...a,...o,ref:t})});Rh.displayName=E_;function __(e){return N_.includes(e)}var k_=Rh;function gc({className:e,orientation:t="horizontal",decorative:r=!0,...n}){return c.jsx(k_,{"data-slot":"separator",decorative:r,orientation:t,className:B("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 T_=({field:e,className:t})=>c.jsx("div",{className:B("py-2",t),children:c.jsx(gc,{})}),F_={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"},P_=({field:e,className:t})=>{const r=e.properties,n=r?.headingLevel??"h3",o=r?.showHorizontalLine??!0,s=F_[n],i=n;return c.jsxs("div",{className:B("w-full min-w-0 space-y-1",t),children:[c.jsx(i,{className:B("m-0 text-foreground",s),children:e.label||"Header"}),e.description&&c.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),o&&c.jsx(gc,{className:"w-full"})]})},O_={"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"},I_={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"},M_=({field:e,className:t})=>{const r=e.properties,n=r?.position??"top-left",o=r?.headingLevel??"h3",s=r?.showHorizontalLine??!0,i=O_[n],a=I_[o],d=o;return c.jsxs("div",{className:B("w-full min-w-0 space-y-2",t),children:[c.jsx("div",{className:B("flex w-full",i),children:c.jsx(d,{className:B("m-0 text-foreground",a),children:e.label||"Section Heading"})}),s&&c.jsx(gc,{className:"w-full"})]})},L_=({field:e,className:t})=>{const r=e.appearance?.size||"md",n={sm:"h-4",md:"h-8",lg:"h-12"};return c.jsx("div",{className:B(n[r],t),"aria-hidden":"true"})};function Gh(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 D_(e){if(Array.isArray(e))return e}function B_(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,s,i,a=[],d=!0,u=!1;try{if(s=(r=r.call(e)).next,t!==0)for(;!(d=(n=s.call(r)).done)&&(a.push(n.value),a.length!==t);d=!0);}catch(l){u=!0,o=l}finally{try{if(!d&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return a}}function $_(){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 j_(e,t){return D_(e)||B_(e,t)||z_(e,t)||$_()}function z_(e,t){if(e){if(typeof e=="string")return Gh(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)?Gh(e,t):void 0}}const Kh=Object.entries,qh=Object.setPrototypeOf,U_=Object.isFrozen,V_=Object.getPrototypeOf,H_=Object.getOwnPropertyDescriptor;let lr=Object.freeze,Mr=Object.seal,xo=Object.create,Yh=typeof Reflect<"u"&&Reflect,yc=Yh.apply,bc=Yh.construct;lr||(lr=function(t){return t}),Mr||(Mr=function(t){return t}),yc||(yc=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)}),bc||(bc=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 Ao=zt(Array.prototype.forEach),W_=zt(Array.prototype.lastIndexOf),Xh=zt(Array.prototype.pop),Co=zt(Array.prototype.push),R_=zt(Array.prototype.splice),cr=Array.isArray,us=zt(String.prototype.toLowerCase),vc=zt(String.prototype.toString),Jh=zt(String.prototype.match),Eo=zt(String.prototype.replace),Qh=zt(String.prototype.indexOf),G_=zt(String.prototype.trim),K_=zt(Number.prototype.toString),q_=zt(Boolean.prototype.toString),Zh=typeof BigInt>"u"?null:zt(BigInt.prototype.toString),eg=typeof Symbol>"u"?null:zt(Symbol.prototype.toString),Ot=zt(Object.prototype.hasOwnProperty),fs=zt(Object.prototype.toString),Zt=zt(RegExp.prototype.test),Ri=Y_(TypeError);function zt(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 yc(e,t,n)}}function Y_(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return bc(e,r)}}function nt(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:us;if(qh&&qh(e,null),!cr(t))return e;let n=t.length;for(;n--;){let o=t[n];if(typeof o=="string"){const s=r(o);s!==o&&(U_(t)||(t[n]=s),o=s)}e[o]=!0}return e}function X_(e){for(let t=0;t<e.length;t++)Ot(e,t)||(e[t]=null);return e}function hr(e){const t=xo(null);for(const n of Kh(e)){var r=j_(n,2);const o=r[0],s=r[1];Ot(e,o)&&(cr(s)?t[o]=X_(s):s&&typeof s=="object"&&s.constructor===Object?t[o]=hr(s):t[o]=s)}return t}function J_(e){switch(typeof e){case"string":return e;case"number":return K_(e);case"boolean":return q_(e);case"bigint":return Zh?Zh(e):"0";case"symbol":return eg?eg(e):"Symbol()";case"undefined":return fs(e);case"function":case"object":{if(e===null)return fs(e);const t=e,r=Kn(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 Kn(e,t){for(;e!==null;){const n=H_(e,t);if(n){if(n.get)return zt(n.get);if(typeof n.value=="function")return zt(n.value)}e=V_(e)}function r(){return null}return r}function Q_(e){try{return Zt(e,""),!0}catch{return!1}}const tg=lr(["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"]),wc=lr(["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"]),Sc=lr(["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"]),Z_=lr(["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=lr(["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"]),ek=lr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),rg=lr(["#text"]),ng=lr(["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"]),Ac=lr(["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"]),og=lr(["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"]),Gi=lr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),tk=Mr(/{{[\w\W]*|^[\w\W]*}}/g),rk=Mr(/<%[\w\W]*|^[\w\W]*%>/g),nk=Mr(/\${[\w\W]*/g),ok=Mr(/^data-[\-\w.\u00B7-\uFFFF]+$/),sk=Mr(/^aria-[\-\w]+$/),sg=Mr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ik=Mr(/^(?:\w+script|data):/i),ak=Mr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),lk=Mr(/^html$/i),ck=Mr(/^[a-z][.\w]*(-[.\w]+)+$/i),No={element:1,text:3,progressingInstruction:7,comment:8,document:9},dk=function(){return typeof window>"u"?null:window},uk=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}},ig=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ag(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:dk();const t=Ee=>ag(Ee);if(t.version="3.4.5",t.removed=[],!e||!e.document||e.document.nodeType!==No.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,d=e.Element,u=e.NodeFilter,l=e.NamedNodeMap,f=l===void 0?e.NamedNodeMap||e.MozNamedAttrMap:l,p=e.HTMLFormElement,m=e.DOMParser,g=e.trustedTypes,h=d.prototype,y=Kn(h,"cloneNode"),w=Kn(h,"remove"),v=Kn(h,"nextSibling"),x=Kn(h,"childNodes"),E=Kn(h,"parentNode"),P=a&&a.prototype?Kn(a.prototype,"nodeType"):null;if(typeof i=="function"){const Ee=r.createElement("template");Ee.content&&Ee.content.ownerDocument&&(r=Ee.content.ownerDocument)}let _,N="";const C=r,A=C.implementation,I=C.createNodeIterator,T=C.createDocumentFragment,W=C.getElementsByTagName,X=n.importNode;let O=ig();t.isSupported=typeof Kh=="function"&&typeof E=="function"&&A&&A.createHTMLDocument!==void 0;const j=tk,M=rk,D=nk,L=ok,U=sk,$=ik,ie=ak,V=ck;let K=sg,J=null;const ce=nt({},[...tg,...wc,...Sc,...xc,...rg]);let ne=null;const G=nt({},[...ng,...Ac,...og,...Gi]);let ee=Object.seal(xo(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}})),Pe=null,oe=null;const re=Object.seal(xo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let be=!0,de=!0,ot=!1,Se=!0,xe=!1,ae=!0,ve=!1,Ye=!1,ct=!1,Ge=!1,Kt=!1,Je=!1,q=!0,$e=!1;const gt="user-content-";let Oe=!0,te=!1,pe={},We=null;const Pt=nt({},["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 je=null;const Te=nt({},["audio","video","img","source","image","track"]);let Xe=null;const Ue=nt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ft="http://www.w3.org/1998/Math/MathML",St="http://www.w3.org/2000/svg",xt="http://www.w3.org/1999/xhtml";let ze=xt,yt=!1,pt=null;const At=nt({},[ft,St,xt],vc);let Ut=nt({},["mi","mo","mn","ms","mtext"]),ur=nt({},["annotation-xml"]);const Ar=nt({},["title","style","font","a","script"]);let Vt=null;const Po=["application/xhtml+xml","text/html"],Xn="text/html";let Ct=null,Cr=null;const Jn=r.createElement("form"),It=function(F){return F instanceof RegExp||F instanceof Function},Er=function(){let F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Cr&&Cr===F)return;(!F||typeof F!="object")&&(F={}),F=hr(F),Vt=Po.indexOf(F.PARSER_MEDIA_TYPE)===-1?Xn:F.PARSER_MEDIA_TYPE,Ct=Vt==="application/xhtml+xml"?vc:us,J=Ot(F,"ALLOWED_TAGS")&&cr(F.ALLOWED_TAGS)?nt({},F.ALLOWED_TAGS,Ct):ce,ne=Ot(F,"ALLOWED_ATTR")&&cr(F.ALLOWED_ATTR)?nt({},F.ALLOWED_ATTR,Ct):G,pt=Ot(F,"ALLOWED_NAMESPACES")&&cr(F.ALLOWED_NAMESPACES)?nt({},F.ALLOWED_NAMESPACES,vc):At,Xe=Ot(F,"ADD_URI_SAFE_ATTR")&&cr(F.ADD_URI_SAFE_ATTR)?nt(hr(Ue),F.ADD_URI_SAFE_ATTR,Ct):Ue,je=Ot(F,"ADD_DATA_URI_TAGS")&&cr(F.ADD_DATA_URI_TAGS)?nt(hr(Te),F.ADD_DATA_URI_TAGS,Ct):Te,We=Ot(F,"FORBID_CONTENTS")&&cr(F.FORBID_CONTENTS)?nt({},F.FORBID_CONTENTS,Ct):Pt,Pe=Ot(F,"FORBID_TAGS")&&cr(F.FORBID_TAGS)?nt({},F.FORBID_TAGS,Ct):hr({}),oe=Ot(F,"FORBID_ATTR")&&cr(F.FORBID_ATTR)?nt({},F.FORBID_ATTR,Ct):hr({}),pe=Ot(F,"USE_PROFILES")?F.USE_PROFILES&&typeof F.USE_PROFILES=="object"?hr(F.USE_PROFILES):F.USE_PROFILES:!1,be=F.ALLOW_ARIA_ATTR!==!1,de=F.ALLOW_DATA_ATTR!==!1,ot=F.ALLOW_UNKNOWN_PROTOCOLS||!1,Se=F.ALLOW_SELF_CLOSE_IN_ATTR!==!1,xe=F.SAFE_FOR_TEMPLATES||!1,ae=F.SAFE_FOR_XML!==!1,ve=F.WHOLE_DOCUMENT||!1,Ge=F.RETURN_DOM||!1,Kt=F.RETURN_DOM_FRAGMENT||!1,Je=F.RETURN_TRUSTED_TYPE||!1,ct=F.FORCE_BODY||!1,q=F.SANITIZE_DOM!==!1,$e=F.SANITIZE_NAMED_PROPS||!1,Oe=F.KEEP_CONTENT!==!1,te=F.IN_PLACE||!1,K=Q_(F.ALLOWED_URI_REGEXP)?F.ALLOWED_URI_REGEXP:sg,ze=typeof F.NAMESPACE=="string"?F.NAMESPACE:xt,Ut=Ot(F,"MATHML_TEXT_INTEGRATION_POINTS")&&F.MATHML_TEXT_INTEGRATION_POINTS&&typeof F.MATHML_TEXT_INTEGRATION_POINTS=="object"?hr(F.MATHML_TEXT_INTEGRATION_POINTS):nt({},["mi","mo","mn","ms","mtext"]),ur=Ot(F,"HTML_INTEGRATION_POINTS")&&F.HTML_INTEGRATION_POINTS&&typeof F.HTML_INTEGRATION_POINTS=="object"?hr(F.HTML_INTEGRATION_POINTS):nt({},["annotation-xml"]);const Y=Ot(F,"CUSTOM_ELEMENT_HANDLING")&&F.CUSTOM_ELEMENT_HANDLING&&typeof F.CUSTOM_ELEMENT_HANDLING=="object"?hr(F.CUSTOM_ELEMENT_HANDLING):xo(null);if(ee=xo(null),Ot(Y,"tagNameCheck")&&It(Y.tagNameCheck)&&(ee.tagNameCheck=Y.tagNameCheck),Ot(Y,"attributeNameCheck")&&It(Y.attributeNameCheck)&&(ee.attributeNameCheck=Y.attributeNameCheck),Ot(Y,"allowCustomizedBuiltInElements")&&typeof Y.allowCustomizedBuiltInElements=="boolean"&&(ee.allowCustomizedBuiltInElements=Y.allowCustomizedBuiltInElements),xe&&(de=!1),Kt&&(Ge=!0),pe&&(J=nt({},rg),ne=xo(null),pe.html===!0&&(nt(J,tg),nt(ne,ng)),pe.svg===!0&&(nt(J,wc),nt(ne,Ac),nt(ne,Gi)),pe.svgFilters===!0&&(nt(J,Sc),nt(ne,Ac),nt(ne,Gi)),pe.mathMl===!0&&(nt(J,xc),nt(ne,og),nt(ne,Gi))),re.tagCheck=null,re.attributeCheck=null,Ot(F,"ADD_TAGS")&&(typeof F.ADD_TAGS=="function"?re.tagCheck=F.ADD_TAGS:cr(F.ADD_TAGS)&&(J===ce&&(J=hr(J)),nt(J,F.ADD_TAGS,Ct))),Ot(F,"ADD_ATTR")&&(typeof F.ADD_ATTR=="function"?re.attributeCheck=F.ADD_ATTR:cr(F.ADD_ATTR)&&(ne===G&&(ne=hr(ne)),nt(ne,F.ADD_ATTR,Ct))),Ot(F,"ADD_URI_SAFE_ATTR")&&cr(F.ADD_URI_SAFE_ATTR)&&nt(Xe,F.ADD_URI_SAFE_ATTR,Ct),Ot(F,"FORBID_CONTENTS")&&cr(F.FORBID_CONTENTS)&&(We===Pt&&(We=hr(We)),nt(We,F.FORBID_CONTENTS,Ct)),Ot(F,"ADD_FORBID_CONTENTS")&&cr(F.ADD_FORBID_CONTENTS)&&(We===Pt&&(We=hr(We)),nt(We,F.ADD_FORBID_CONTENTS,Ct)),Oe&&(J["#text"]=!0),ve&&nt(J,["html","head","body"]),J.table&&(nt(J,["tbody"]),delete Pe.tbody),F.TRUSTED_TYPES_POLICY){if(typeof F.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ri('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof F.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ri('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');_=F.TRUSTED_TYPES_POLICY,N=_.createHTML("")}else _===void 0&&(_=uk(g,o)),_!==null&&typeof N=="string"&&(N=_.createHTML(""));lr&&lr(F),Cr=F},er=nt({},[...wc,...Sc,...Z_]),sr=nt({},[...xc,...ek]),fn=function(F){let Y=E(F);(!Y||!Y.tagName)&&(Y={namespaceURI:ze,tagName:"template"});const he=us(F.tagName),st=us(Y.tagName);return pt[F.namespaceURI]?F.namespaceURI===St?Y.namespaceURI===xt?he==="svg":Y.namespaceURI===ft?he==="svg"&&(st==="annotation-xml"||Ut[st]):!!er[he]:F.namespaceURI===ft?Y.namespaceURI===xt?he==="math":Y.namespaceURI===St?he==="math"&&ur[st]:!!sr[he]:F.namespaceURI===xt?Y.namespaceURI===St&&!ur[st]||Y.namespaceURI===ft&&!Ut[st]?!1:!sr[he]&&(Ar[he]||!er[he]):!!(Vt==="application/xhtml+xml"&&pt[F.namespaceURI]):!1},yr=function(F){Co(t.removed,{element:F});try{E(F).removeChild(F)}catch{w(F)}},kt=function(F,Y){try{Co(t.removed,{attribute:Y.getAttributeNode(F),from:Y})}catch{Co(t.removed,{attribute:null,from:Y})}if(Y.removeAttribute(F),F==="is")if(Ge||Kt)try{yr(Y)}catch{}else try{Y.setAttribute(F,"")}catch{}},Ss=function(F){let Y=null,he=null;if(ct)F="<remove></remove>"+F;else{const wt=Jh(F,/^[\r\n\t ]+/);he=wt&&wt[0]}Vt==="application/xhtml+xml"&&ze===xt&&(F='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+F+"</body></html>");const st=_?_.createHTML(F):F;if(ze===xt)try{Y=new m().parseFromString(st,Vt)}catch{}if(!Y||!Y.documentElement){Y=A.createDocument(ze,"template",null);try{Y.documentElement.innerHTML=yt?N:st}catch{}}const Tt=Y.body||Y.documentElement;return F&&he&&Tt.insertBefore(r.createTextNode(he),Tt.childNodes[0]||null),ze===xt?W.call(Y,ve?"html":"body")[0]:ve?Y.documentElement:Tt},Nr=function(F){return I.call(F.ownerDocument||F,F,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Dr=function(F){F.normalize();const Y=I.call(F.ownerDocument||F,F,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let he=Y.nextNode();for(;he;){let st=he.data;Ao([j,M,D],Tt=>{st=Eo(st,Tt," ")}),he.data=st,he=Y.nextNode()}},_r=function(F){return F instanceof p&&(typeof F.nodeName!="string"||typeof F.textContent!="string"||typeof F.removeChild!="function"||!(F.attributes instanceof f)||typeof F.removeAttribute!="function"||typeof F.setAttribute!="function"||typeof F.namespaceURI!="string"||typeof F.insertBefore!="function"||typeof F.hasChildNodes!="function")},br=function(F){if(!P||typeof F!="object"||F===null)return!1;try{return typeof P(F)=="number"}catch{return!1}};function qt(Ee,F,Y){Ao(Ee,he=>{he.call(t,F,Y,Cr)})}const tr=function(F){let Y=null;if(qt(O.beforeSanitizeElements,F,null),_r(F))return yr(F),!0;const he=Ct(F.nodeName);if(qt(O.uponSanitizeElement,F,{tagName:he,allowedTags:J}),ae&&F.hasChildNodes()&&!br(F.firstElementChild)&&Zt(/<[/\w!]/g,F.innerHTML)&&Zt(/<[/\w!]/g,F.textContent)||ae&&F.namespaceURI===xt&&he==="style"&&br(F.firstElementChild)||F.nodeType===No.progressingInstruction||ae&&F.nodeType===No.comment&&Zt(/<[/\w]/g,F.data))return yr(F),!0;if(Pe[he]||!(re.tagCheck instanceof Function&&re.tagCheck(he))&&!J[he]){if(!Pe[he]&&Zi(he)&&(ee.tagNameCheck instanceof RegExp&&Zt(ee.tagNameCheck,he)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(he)))return!1;if(Oe&&!We[he]){const st=E(F)||F.parentNode,Tt=x(F)||F.childNodes;if(Tt&&st){const wt=Tt.length;for(let Mt=wt-1;Mt>=0;--Mt){const $r=y(Tt[Mt],!0);st.insertBefore($r,v(F))}}}return yr(F),!0}return F instanceof d&&!fn(F)||(he==="noscript"||he==="noembed"||he==="noframes")&&Zt(/<\/no(script|embed|frames)/i,F.innerHTML)?(yr(F),!0):(xe&&F.nodeType===No.text&&(Y=F.textContent,Ao([j,M,D],st=>{Y=Eo(Y,st," ")}),F.textContent!==Y&&(Co(t.removed,{element:F.cloneNode()}),F.textContent=Y)),qt(O.afterSanitizeElements,F,null),!1)},Br=function(F,Y,he){if(oe[Y]||q&&(Y==="id"||Y==="name")&&(he in r||he in Jn))return!1;const st=ne[Y]||re.attributeCheck instanceof Function&&re.attributeCheck(Y,F);if(!(de&&!oe[Y]&&Zt(L,Y))){if(!(be&&Zt(U,Y))){if(!st||oe[Y]){if(!(Zi(F)&&(ee.tagNameCheck instanceof RegExp&&Zt(ee.tagNameCheck,F)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(F))&&(ee.attributeNameCheck instanceof RegExp&&Zt(ee.attributeNameCheck,Y)||ee.attributeNameCheck instanceof Function&&ee.attributeNameCheck(Y,F))||Y==="is"&&ee.allowCustomizedBuiltInElements&&(ee.tagNameCheck instanceof RegExp&&Zt(ee.tagNameCheck,he)||ee.tagNameCheck instanceof Function&&ee.tagNameCheck(he))))return!1}else if(!Xe[Y]){if(!Zt(K,Eo(he,ie,""))){if(!((Y==="src"||Y==="xlink:href"||Y==="href")&&F!=="script"&&Qh(he,"data:")===0&&je[F])){if(!(ot&&!Zt($,Eo(he,ie,"")))){if(he)return!1}}}}}}return!0},Qi=nt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Zi=function(F){return!Qi[us(F)]&&Zt(V,F)},ea=function(F){qt(O.beforeSanitizeAttributes,F,null);const Y=F.attributes;if(!Y||_r(F))return;const he={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let st=Y.length;for(;st--;){const Tt=Y[st],wt=Tt.name,Mt=Tt.namespaceURI,$r=Tt.value,ir=Ct(wt),Oo=$r;let Lt=wt==="value"?Oo:G_(Oo);if(he.attrName=ir,he.attrValue=Lt,he.keepAttr=!0,he.forceKeepAttr=void 0,qt(O.uponSanitizeAttribute,F,he),Lt=he.attrValue,$e&&(ir==="id"||ir==="name")&&Qh(Lt,gt)!==0&&(kt(wt,F),Lt=gt+Lt),ae&&Zt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Lt)){kt(wt,F);continue}if(ir==="attributename"&&Jh(Lt,"href")){kt(wt,F);continue}if(he.forceKeepAttr)continue;if(!he.keepAttr){kt(wt,F);continue}if(!Se&&Zt(/\/>/i,Lt)){kt(wt,F);continue}xe&&Ao([j,M,D],et=>{Lt=Eo(Lt,et," ")});const ta=Ct(F.nodeName);if(!Br(ta,ir,Lt)){kt(wt,F);continue}if(_&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!Mt)switch(g.getAttributeType(ta,ir)){case"TrustedHTML":{Lt=_.createHTML(Lt);break}case"TrustedScriptURL":{Lt=_.createScriptURL(Lt);break}}if(Lt!==Oo)try{Mt?F.setAttributeNS(Mt,wt,Lt):F.setAttribute(wt,Lt),_r(F)?yr(F):Xh(t.removed)}catch{kt(wt,F)}}qt(O.afterSanitizeAttributes,F,null)},xs=function(F){let Y=null;const he=Nr(F);for(qt(O.beforeSanitizeShadowDOM,F,null);Y=he.nextNode();)qt(O.uponSanitizeShadowNode,Y,null),tr(Y),ea(Y),Y.content instanceof s&&xs(Y.content);qt(O.afterSanitizeShadowDOM,F,null)},kr=function(F){if(F.nodeType===No.element&&F.shadowRoot instanceof s){const st=F.shadowRoot;kr(st),xs(st)}const Y=F.childNodes;if(!Y)return;const he=[];Ao(Y,st=>{Co(he,st)});for(const st of he)kr(st)};return t.sanitize=function(Ee){let F=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Y=null,he=null,st=null,Tt=null;if(yt=!Ee,yt&&(Ee="<!-->"),typeof Ee!="string"&&!br(Ee)&&(Ee=J_(Ee),typeof Ee!="string"))throw Ri("dirty is not a string, aborting");if(!t.isSupported)return Ee;if(Ye||Er(F),t.removed=[],typeof Ee=="string"&&(te=!1),te){const $r=Ee.nodeName;if(typeof $r=="string"){const ir=Ct($r);if(!J[ir]||Pe[ir])throw Ri("root node is forbidden and cannot be sanitized in-place")}kr(Ee)}else if(br(Ee))Y=Ss("<!---->"),he=Y.ownerDocument.importNode(Ee,!0),he.nodeType===No.element&&he.nodeName==="BODY"||he.nodeName==="HTML"?Y=he:Y.appendChild(he),kr(he);else{if(!Ge&&!xe&&!ve&&Ee.indexOf("<")===-1)return _&&Je?_.createHTML(Ee):Ee;if(Y=Ss(Ee),!Y)return Ge?null:Je?N:""}Y&&ct&&yr(Y.firstChild);const wt=Nr(te?Ee:Y);for(;st=wt.nextNode();)tr(st),ea(st),st.content instanceof s&&xs(st.content);if(te)return xe&&Dr(Ee),Ee;if(Ge){if(xe&&Dr(Y),Kt)for(Tt=T.call(Y.ownerDocument);Y.firstChild;)Tt.appendChild(Y.firstChild);else Tt=Y;return(ne.shadowroot||ne.shadowrootmode)&&(Tt=X.call(n,Tt,!0)),Tt}let Mt=ve?Y.outerHTML:Y.innerHTML;return ve&&J["!doctype"]&&Y.ownerDocument&&Y.ownerDocument.doctype&&Y.ownerDocument.doctype.name&&Zt(lk,Y.ownerDocument.doctype.name)&&(Mt="<!DOCTYPE "+Y.ownerDocument.doctype.name+`>
|
|
52
|
+
`+Mt),xe&&Ao([j,M,D],$r=>{Mt=Eo(Mt,$r," ")}),_&&Je?_.createHTML(Mt):Mt},t.setConfig=function(){let Ee=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Er(Ee),Ye=!0},t.clearConfig=function(){Cr=null,Ye=!1},t.isValidAttribute=function(Ee,F,Y){Cr||Er({});const he=Ct(Ee),st=Ct(F);return Br(he,st,Y)},t.addHook=function(Ee,F){typeof F=="function"&&Co(O[Ee],F)},t.removeHook=function(Ee,F){if(F!==void 0){const Y=W_(O[Ee],F);return Y===-1?void 0:R_(O[Ee],Y,1)[0]}return Xh(O[Ee])},t.removeHooks=function(Ee){O[Ee]=[]},t.removeAllHooks=function(){O=ig()},t}var fk=ag();const pk=["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"],mk=["href","target","rel","src","alt","title","class","style","colspan","rowspan"];function hk(e){return e?fk.sanitize(e,{ALLOWED_TAGS:[...pk],ALLOWED_ATTR:[...mk],ALLOW_DATA_ATTR:!1}):""}function gk(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=Qe(t,s);return i==null?r?"":n:String(i)}):e}function yk(e){return e&&e.replace(/\{api:[^}]*\}/gi,"").replace(/\{labelapi:[^}]*\}/gi,"").replace(/\{resp:[^}]*\}/gi,"").replace(/\{(?:ctx:|@)\w+\}/gi,"").replace(/\{documentId\}/gi,"").replace(/\{(\w+)\}/g,"")}const lg={sm:"text-sm",md:"text-base",lg:"text-lg"},cg={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"},dg={normal:"font-normal",medium:"font-medium",bold:"font-bold"},Ki={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"};function qn(e){return e.properties??{}}function bk(e){const t=qn(e);return t.textContent!==void 0?t.textContent:e.label??""}function vk(e){return qn(e).textContent===void 0||e.appearance?.hideLabel?!1:!!e.label?.trim()}function wk(e){return e?.contentLayout==="paragraph"?"paragraph":"single"}function Cc(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:a}=t,d=rn(e,r,n,o,s,i),u=gk(d,a,!0);return yk(u)}const Sk=/\{api:[^}]+\}/,xk=/\{labelapi:[^}]+\}/;function Ec(e){return Sk.test(e)}function Nc(e){return xk.test(e)}function Ak(e){const t=e.captionTemplate??"",r=e.descriptionTemplate??"",n=Ec(e.bodyTemplate)||Ec(t)||Ec(r),o=Nc(e.bodyTemplate)||Nc(t)||Nc(r);return!!(n&&e.prepopulateLoading||o&&e.labelApiConfigPresent&&(e.labelApiLoading||e.labelApiResponse===void 0&&e.labelApiError==null))}function ug(e,t){const r=t??qn(e),n=r.variant??"body",o=e.appearance?.size??"md",s=lg[o]??lg.md,i=r.fontWeight??"medium";return n!=="body"?B("m-0 text-foreground",cg[n]??cg.h3,r.fontWeight&&dg[r.fontWeight],r.italic&&"italic",r.underline&&"underline",r.textAlign&&Ki[r.textAlign]):B("m-0 text-foreground",s,dg[i],r.italic&&"italic",r.underline&&"underline",r.textAlign&&Ki[r.textAlign])}function Ck(e,t){const r=(t??qn(e)).variant??"body";return r==="body"?"p":r}function _c(e){const t=[];let r=0,n="";const o=()=>{n&&(t.push({type:"text",value:n}),n="")},s=(i,a,d)=>{if(!e.startsWith(i,r))return!1;const u=e.indexOf(a,r+i.length);if(u===-1)return!1;o();const l=e.slice(r+i.length,u);return t.push({type:d,children:_c(l)}),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 Ek(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function fg(e){return e.map(t=>{if(t.type==="text")return Ek(t.value);const r=fg(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 Nk(e){return e?fg(_c(e)):""}function _k(e,t){return e?t==="markdown-lite"?Nk(e):e:""}function pg(e,t){return e.map((r,n)=>{const o=`${t}-${n}`;if(r.type==="text")return r.value?S.createElement(S.Fragment,{key:o},r.value):null;const s=pg(r.children,o);return r.type==="bold"?S.createElement("strong",{key:o,className:"font-bold"},s):r.type==="italic"?S.createElement("em",{key:o,className:"italic"},s):S.createElement("u",{key:o,className:"underline"},s)})}function mg(e,t){if(!e)return null;if(t!=="markdown-lite")return e;const r=_c(e);return r.length===1&&r[0]?.type==="text"?r[0].value:pg(r,"tl")}const kk="text-label-html prose prose-sm max-w-none [&_p]:m-0 [&_p+p]:mt-2 [&_ul]:my-1 [&_ol]:my-1";function hg(e,t){if(!e)return null;const{field:r,asDescription:n=!1}=t,o=t.textProps??qn(r),s=t.contentLayout??wk(o),i=o.inlineFormat??"none";if(s==="paragraph"){const d=hk(_k(e,i));if(!d)return null;const u=n?B("m-0 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&Ki[o.textAlign]):B(ug(r,o),kk);return S.createElement("div",{className:u,dangerouslySetInnerHTML:{__html:d}})}if(n)return S.createElement("p",{className:B("mt-0.5 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&Ki[o.textAlign])},mg(e,i));const a=Ck(r,o);return S.createElement(a,{className:ug(r,o)},mg(e,i))}function Tk(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 Fk(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o}=t,s=f=>rn(f,r,n,o),i=(e.labelApiMethod??"GET").toUpperCase();let a=cn(s(e.labelApiEndpoint));const d=e.labelApiQueryParams??[];if(d.length){const f=new URLSearchParams;d.forEach(({key:m,value:g})=>{m.trim()&&f.append(m,s(g))});const p=f.toString();p&&(a=`${a}${a.includes("?")?"&":"?"}${p}`)}const u={"Content-Type":"application/json"};(e.labelApiHeaders??[]).forEach(({key:f,value:p})=>{f.trim()&&(u[f]=s(p))});let l;i==="POST"&&(e.labelApiBodyFields??[]).length&&(l={},e.labelApiBodyFields.forEach(({key:f,value:p})=>{f.trim()&&(l[f]=s(p))}));try{return i==="POST"?(await dn.post(a,l??{},{headers:Object.keys(u).length?u:void 0})).data:(await dn.get(a,{headers:Object.keys(u).length?u:void 0})).data}catch(f){const p=f,m=p.response?.status,g=typeof p.response?.data=="string"?p.response.data:p.message??"Request failed";throw new Error(m?`HTTP ${m}: ${g}`:String(g))}}const Pk=({field:e,className:t,formValues:r,urlParams:n,submissionContext:o,buttonResponses:s,prepopulateResponse:i,prepopulateLoading:a=!1})=>{const d=qn(e),u=S.useMemo(()=>Tk(qn(e)),[e.properties]),[l,f]=S.useState(void 0),[p,m]=S.useState(!1),[g,h]=S.useState(null),y=S.useMemo(()=>u?JSON.stringify({endpoint:u.labelApiEndpoint,method:u.labelApiMethod,query:u.labelApiQueryParams,headers:u.labelApiHeaders,body:u.labelApiBodyFields}):"",[u]),w=S.useCallback(async()=>{if(!u){f(void 0),h(null),m(!1);return}m(!0),h(null);try{const W=await Fk(u,{formValues:r??{},urlParams:n??{},submissionContext:o});f(W)}catch(W){f(void 0),h(W instanceof Error?W.message:"Failed to load label API")}finally{m(!1)}},[u,r,n,o]);S.useEffect(()=>{y&&w()},[y,w]);const v=d.textAlign==="center"?"items-center":d.textAlign==="right"?"items-end":d.textAlign==="justify"?"items-stretch":"items-start",x=bk(e),E=vk(e),P=E&&e.label?e.label:"",_=e.description??"",N=Ak({bodyTemplate:x,captionTemplate:P,descriptionTemplate:_,prepopulateLoading:a,labelApiConfigPresent:u!=null,labelApiLoading:p,labelApiResponse:l,labelApiError:g}),C={formValues:r??{},urlParams:n??{},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:l},A=x?Cc(x,C):"",I=E&&e.label?Cc(e.label,C):"",T=_?Cc(_,C):"";return c.jsx("div",{className:B("w-full min-w-0 h-full min-h-[95px] flex flex-col justify-center py-0.5",v,t),children:N?c.jsx("p",{className:"text-sm text-muted-foreground m-0",children:"Loading…"}):c.jsxs(c.Fragment,{children:[g&&u?c.jsx("p",{className:"text-[10px] text-destructive mb-0.5",title:g,children:"Label API failed"}):null,I?c.jsx("div",{className:"text-sm font-medium text-foreground mb-1 w-full",children:I}):null,A?hg(A,{field:e,textProps:d}):null,T?hg(T,{field:e,textProps:d,asDescription:!0}):null]})})},kc=({legend:e,children:t,className:r,collapsible:n=!1,defaultCollapsed:o=!1,headerActions:s,onCollapsedChange:i})=>{const[a,d]=S.useState(o),u=S.useId(),l=f=>{f.stopPropagation(),n&&d(p=>{const m=!p;return i?.(m),m})};return c.jsxs("fieldset",{className:B("min-w-0 rounded-lg border bg-card p-4",r),"data-form-renderer":"config-section-border",children:[n?c.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2 border-b border-border pb-2",children:[c.jsxs("button",{type:"button",className:B("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:l,children:[c.jsx("span",{className:"shrink-0 text-muted-foreground","aria-hidden":!0,children:a?c.jsx(Zd,{className:"h-4 w-4"}):c.jsx(Wo,{className:"h-4 w-4"})}),c.jsx("span",{className:"truncate",children:e})]}),s!=null?c.jsx("div",{className:"shrink-0",children:s}):null]}):c.jsx("legend",{className:"px-1 text-sm font-medium text-foreground",children:e}),!a&&c.jsxs("div",{id:u,className:"space-y-3",children:[!n&&s!=null?c.jsx("div",{className:"flex justify-end",children:s}):null,t]})]})},un=({field:e,value:t,error:r,onChange:n,onBlur:o,disabled:s,readOnly:i,isRequired:a,className:d,formValues:u={},submissionContext:l,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:w,buttonResponses:v,onButtonApiResponse:x,onValidateForm:E,getValidationErrors:P,allFields:_,onSubmittingChange:N,onAddMore:C,scopedFormValues:A,scopedFieldNameMap:I,excludedOptionValues:T,prepopulateMappedFieldNames:W,fieldValueKey:X,hideTableRowControls:O=!1,urlParams:j={},prepopulateResponse:M=null,prepopulateLoading:D=!1,formSections:L,submitPayload:U})=>{switch(e.type){case"divider":return c.jsx(T_,{field:e,className:d});case"header":return c.jsx(P_,{field:e,className:d});case"sectionHeading":return c.jsx(M_,{field:e,className:d});case"spacer":return c.jsx(L_,{field:e,className:d});case"textLabel":return c.jsx(Pk,{field:e,className:d,formValues:u,urlParams:j,submissionContext:l,buttonResponses:v,prepopulateResponse:M??void 0,prepopulateLoading:D});case"status":return c.jsx(w_,{field:e,value:t??null,error:r,disabled:s,isRequired:a,className:d,formValues:u,submissionContext:l,extraSubmitPayload:w,prepopulateResponse:M})}switch(e.type){case"text":case"password":case"url":return c.jsx(Da,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"number":return c.jsx(Xd,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"email":return c.jsx(su,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"phone":case"aadhaar":return c.jsx(iu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"textarea":case"richtext":return c.jsx(au,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"select":{const $=X??e.name??e.key??e.id,ie=!!($&&W?.has($));return c.jsx(kp,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,formValues:u,submissionContext:l,excludedOptionValues:T,isPrepopulateTarget:ie})}case"multiselect":{const $=Array.isArray(t)?t:t!=null&&t!==""?[String(t)]:[];return c.jsx(vm,{field:e,value:$,onChange:ie=>n(ie),onBlur:o,error:r,disabled:s,isRequired:a,className:d,formValues:u,submissionContext:l,excludedOptionValues:T})}case"asyncsearch":return c.jsx(Xp,{field:e,value:t,onChange:$=>n($),onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d,formValues:u,submissionContext:l});case"checkbox":case"terms":return c.jsx(wm,{field:e,value:t||!1,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d});case"toggle":return c.jsx(tE,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d});case"radio":case"checkboxgroup":return c.jsx(Gm,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,excludedOptionValues:T});case"selectablelist":{const $=Array.isArray(t)?t:[];return console.log("[SelectableList] FieldRenderer: passing to SelectableListField",{fieldName:e.name,value:$,valueLength:$.length,submissionContextKeys:l?Object.keys(l):[]}),c.jsx(x_,{field:e,value:$,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,submissionContext:l})}case"date":case"time":case"datetime":case"daterange":return c.jsx(Km,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"file":return c.jsx(NE,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,buttonResponses:v});case"camera":return c.jsx(oN,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d});case"photoChoice":return c.jsx(sN,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:d,buttonResponses:v});case"signature":return c.jsx(QN,{field:e,value:t||null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"rating":return c.jsx(FN,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"slider":return c.jsx(JN,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"table":return c.jsx(ZN,{field:e,value:t||[],onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d,hideRowControls:O,formValues:u,submissionContext:l});case"billingGrid":return c.jsx(v_,{field:e,value:t||{rows:[]},onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d});case"button":return c.jsx(wN,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:d,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,formValues:u,submissionContext:l,buttonResponses:v,onButtonApiResponse:x,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:w,onValidateForm:E,getValidationErrors:P,allFields:_,onSubmittingChange:N,scopedFormValues:A,scopedFieldNameMap:I,prepopulateResponse:M,formSections:L,submitPayload:U});case"editButton":return c.jsx(SN,{field:e,disabled:s,readOnly:i,isRequired:a,className:d,buttonResponses:v,onButtonApiResponse:x});case"addmore":return c.jsx(xN,{field:e,error:r,disabled:s,readOnly:i,isRequired:a,className:d,onAddMore:()=>C?.(e)});case"customizeSections":return c.jsx(TN,{field:e,error:r,disabled:s,readOnly:i,isRequired:a,className:d});default:return c.jsx("div",{className:"p-3 border rounded-md bg-muted/50",children:c.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unsupported field type: ",e.type]})})}},Ok=({steps:e,currentStep:t,completedSteps:r,onStepClick:n,className:o})=>c.jsx("div",{className:B("mb-8",o),children:c.jsx("nav",{"aria-label":"Progress",children:c.jsx("ol",{className:"flex items-center",children:e.map((s,i)=>{const a=r.has(i),d=t===i,u=n&&(a||i===t+1||i<=t);return c.jsxs("li",{className:B("relative",i!==e.length-1&&"pr-8 sm:pr-20 flex-1"),children:[i!==e.length-1&&c.jsx("div",{className:B("absolute top-4 left-8 -right-8 sm:left-12 sm:-right-12 h-0.5",a?"bg-primary":"bg-border"),"aria-hidden":"true"}),c.jsx("button",{type:"button",onClick:()=>u&&n?.(i),disabled:!u,className:B("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",d&&!a&&"border-2 border-primary text-primary",!a&&!d&&"border-2 border-border text-muted-foreground",u&&"cursor-pointer hover:bg-primary/10",!u&&"cursor-default"),"aria-current":d?"step":void 0,children:a?c.jsx(Vs,{className:"h-4 w-4"}):c.jsx("span",{children:i+1})}),c.jsxs("div",{className:"mt-2",children:[c.jsx("span",{className:B("text-sm font-medium",d&&"text-primary",!d&&!a&&"text-muted-foreground"),children:s.name}),s.description&&c.jsx("p",{className:"text-xs text-muted-foreground hidden sm:block",children:s.description})]})]},s.id)})})})});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 gg(e){return Array.isArray(e)?e.map(ps):[]}function Ik(e){if(!e.moduleId)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 t;typeof e.moduleId=="object"&&e.moduleId._id?t=ps(e.moduleId):t=e.moduleId;const r=e.isDefault??!1;if(!r&&!e.tenantId)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:r,moduleId:t,tenantId:e.tenantId||void 0,featureId:e.featureId,config:e.config??void 0}}class Mk{basePath="/api/form-builder/forms";async getForRendering(t,r){if(!Tn())throw new Error("Client ID is required");const o=r!==void 0?`${this.basePath}/${t}/render?version=${r}`:`${this.basePath}/${t}/render`,s=await dn.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,d=i.form||i;if(!d.moduleId&&!i.form?.moduleId)throw new Error(`Form response missing required field: moduleId. Form ID: ${t}. Please ensure the backend returns moduleId in the form response.`);if(!(d.isDefault??i.form?.isDefault??!1)&&!d.tenantId&&!i.form?.tenantId)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&&!d.moduleId&&(d.moduleId=i.form.moduleId),i.form?.tenantId&&!d.tenantId&&(d.tenantId=i.form.tenantId),i.form?.isDefault!==void 0&&d.isDefault===void 0&&(d.isDefault=i.form.isDefault);const l=Ik(d);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 f=gg(i.fields||[]),p=i.layout?ps(i.layout):null,m=gg(i.rules||[]),g=i.module?ps(i.module):void 0,h=i.clientMapping||i.clientOverrides;return{form:l,fields:f,layout:p,rules:m,module:g,clientMapping:h,clientOverrides:h,BFF_submit_api:a||void 0}}}const Lk=new Mk;function Pn({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=c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:B("animate-spin rounded-full border-b-2 border-blue-600 mx-auto mb-4",o[t],e)}),r&&c.jsx("p",{className:"text-gray-600",children:r})]});return n?c.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}const Dk={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."},Bk=300;function $k(){return{...Dk}}function jk(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 zk(e){const t=$k();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:hN(r.sections),submitPayload:mN(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 ms(e,t,r,n){const o=t.map(l=>{let f=[],p={};try{l.options&&(f=JSON.parse(l.options)),l.metadata&&(p=JSON.parse(l.metadata))}catch{}const m=jd(l);m&&Object.assign(p,m),f.length>0&&(p.options=f);const g=[];if(l.validationRequired&&g.push({type:"required",message:"This field is required"}),l.validationMinLength!==null&&l.validationMinLength!==void 0&&g.push({type:"minLength",value:l.validationMinLength,message:`Minimum length is ${l.validationMinLength}`}),l.validationMaxLength!==null&&l.validationMaxLength!==void 0&&g.push({type:"maxLength",value:l.validationMaxLength,message:`Maximum length is ${l.validationMaxLength}`}),l.validationPattern&&g.push({type:"pattern",value:l.validationPattern,message:"Invalid format"}),l.validationRules&&typeof l.validationRules=="object"){const V=l.validationRules;if(V.required===!0&&!g.some(K=>K.type==="required")&&g.push({type:"required",message:"This field is required"}),V.allowLetters!==void 0&&g.push({type:"allowLetters",value:V.allowLetters}),V.allowNumbers!==void 0&&g.push({type:"allowNumbers",value:V.allowNumbers}),V.allowSpecialChars!==void 0&&g.push({type:"allowSpecialChars",value:V.allowSpecialChars}),V.minLetters!==void 0&&typeof V.minLetters=="number"&&g.push({type:"minLetters",value:V.minLetters}),V.maxLetters!==void 0&&typeof V.maxLetters=="number"&&g.push({type:"maxLetters",value:V.maxLetters}),V.minNumbers!==void 0&&typeof V.minNumbers=="number"&&g.push({type:"minNumbers",value:V.minNumbers}),V.maxNumbers!==void 0&&typeof V.maxNumbers=="number"&&g.push({type:"maxNumbers",value:V.maxNumbers}),V.minSpecialChars!==void 0&&typeof V.minSpecialChars=="number"&&g.push({type:"minSpecialChars",value:V.minSpecialChars}),V.maxSpecialChars!==void 0&&typeof V.maxSpecialChars=="number"&&g.push({type:"maxSpecialChars",value:V.maxSpecialChars}),V.fileSize!==void 0&&typeof V.fileSize=="number"){const K=V.fileSize/1048576;g.push({type:"fileSize",value:V.fileSize,message:`File size must be less than ${K.toFixed(2)} MB`})}if(V.fileType!==void 0){const K=Array.isArray(V.fileType)?V.fileType:typeof V.fileType=="string"?V.fileType.split(",").map(J=>J.trim()).filter(Boolean):[];K.length>0&&g.push({type:"fileType",value:K,message:"File type is not allowed"})}}const h=[],y=new Set;n.filter(V=>{const K=typeof V.targetFieldId=="object"?V.targetFieldId.id||V.targetFieldId._id:V.targetFieldId;return!!(K===l.id||K===l._id||K&&l.fieldKey&&K===l.fieldKey)}).forEach(V=>{try{const K=JSON.parse(V.conditionExpression);!K.id&&V.id&&(K.id=V.id);const J=typeof V.targetFieldId=="object"?V.targetFieldId?.id||V.targetFieldId?._id:V.targetFieldId;K.action&&(!K.then||!Array.isArray(K.then)||K.then.length===0)&&(K.then=[{action:K.action,...J&&{target:J}}]),(!K.then||!Array.isArray(K.then)||K.then.length===0)&&V.action&&(K.then=[{action:V.action,...J&&{target:J}}]),K.then&&Array.isArray(K.then)&&J&&(K.then=K.then.map(ne=>!ne.target&&J?{...ne,target:J}:ne));const ce=V.conditionExpression||JSON.stringify(K);if(y.has(ce))return;y.add(ce),h.push(K)}catch{}});const v=l.disabled===!0||p?.disabled===!0||!1;let x=l.readOnly===!0||p?.readOnly===!0||!1;const E=l.hidden===!0||p?.hidden===!0||!1;(p?.valueSource==="calculated"||p?.formula)&&(x=!0);const{disabled:P,readOnly:_,hidden:N,...C}=p,A={};C.hideLabel!==void 0&&(A.hideLabel=C.hideLabel),C.labelPosition!==void 0&&(A.labelPlacement=C.labelPosition),C.size!==void 0&&(A.size=C.size),C.customClass!==void 0&&(A.className=C.customClass);const{labelPosition:I,size:T,customClass:W,visibility:X,...O}=C,j=Object.keys(O).length>0?O:void 0,M=Object.keys(A).length>0?A:void 0,D=l.visibility??p?.visibility??X;let L=jk(D);if(D&&!L){const V=D;(V.visibleToUserType!=null||V.visibleToUserRole!=null||Array.isArray(V.visibleToUserTypes)&&V.visibleToUserTypes.length>0||Array.isArray(V.visibleToUserRoles)&&V.visibleToUserRoles.length>0||Array.isArray(V.visibleToUserIds)&&V.visibleToUserIds.length>0||Array.isArray(V.hiddenFromUserIds)&&V.hiddenFromUserIds.length>0)&&(L={visibleToUserType:V.visibleToUserType??(Array.isArray(V.visibleToUserTypes)?V.visibleToUserTypes[0]:void 0),visibleToUserRole:V.visibleToUserRole??(Array.isArray(V.visibleToUserRoles)?V.visibleToUserRoles[0]:void 0),visibleToUserIds:V.visibleToUserIds,hiddenFromUserIds:V.hiddenFromUserIds})}const U=p?.columnName,ie=!!l.parentFieldId&&typeof U=="string"?U: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:M,validation:g.length>0?g:void 0,conditions:h.length>0?h:void 0,properties:j,visibility:L&&(L.visibleToUserType!=null||L.visibleToUserRole!=null||Array.isArray(L.visibleToUserIds)&&L.visibleToUserIds.length>0||Array.isArray(L.hiddenFromUserIds)&&L.hiddenFromUserIds.length>0)?L:void 0,disabled:v,readOnly:x,hidden:E}});o.forEach((l,f)=>{if(l.visibility){const p=t[f];console.log("[backendToFormSchema] field with visibility",{fieldKey:p?.fieldKey??l.name,name:l.name,type:l.type,parentFieldId:p?.parentFieldId,visibility:l.visibility})}});const s=t;for(let l=0;l<o.length;l++){const f=s[l]?.parentFieldId;if(f){const p=o.find(g=>g.id===f||g.type==="table"&&g.name===f||g.type==="table"&&s[l].fieldKey?.startsWith?.(g.name+"_column_")),m=o[l];if(p&&p.type==="table"&&m){const g=p.properties||{};Array.isArray(g.columns)||(g.columns=[]),g.columns.push(m),p.properties=g}}}const i=o.filter((l,f)=>!s[f]?.parentFieldId);for(const l of i)if(l.type==="table"&&l.properties&&Array.isArray(l.properties.columns)){const f=l.properties.columns;for(const p of f){const m=p.properties?.columnName;typeof m=="string"&&(p.name=m)}f.sort((p,m)=>(p.position?.order??0)-(m.position?.order??0)||(p.position?.column??0)-(m.position?.column??0))}let a;const d=e.config;if(console.log("[Prepopulate] backendToFormSchema config",{formId:e.id,hasRawConfig:d!=null,rawConfigType:typeof d,rawConfigPreview:d!=null?typeof d=="string"?d.slice(0,300):JSON.stringify(d).slice(0,300):null}),d!=null)try{const l=typeof d=="string"?JSON.parse(d):d;l&&typeof l=="object"?a=zk(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=Ns(r);return u&&(a={...a,grid:u}),{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,moduleId:typeof e.moduleId=="string"?e.moduleId:e.moduleId?.id,tenantId:e.tenantId,featureId:e.featureId,isDefault:e.isDefault}}const Uk=3;function _o(e){if(typeof e=="number"&&!Number.isNaN(e))return e}function ko(e,t){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;return _o(r?.cellSlot)??_o(r?.stackSlot)??_o(r?.cellSlotIndex)??_o(r?.slotIndex)??_o(t?.cellSlotIndex)??_o(t?.stackSlot)}function hs(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 qi(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 Tc(e){return[...e].sort((t,r)=>{const n=ko(t.position),o=ko(r.position);return typeof n=="number"&&typeof o=="number"&&n!==o?n-o:String(t.id).localeCompare(String(r.id))})}function gs(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,Do(o)),n=Math.max(n,bd(o,t));return{rowSpan:r,columnSpan:n}}function yg(e){const t=Tc(e);for(const r of t){const n=hs(r.position);if(n)return n}return t.length>=2?"row":"stack"}function bg(e){return Tc(e).slice(0,Uk)}function Vk(e,t){const r=new Map;for(const n of e){if(!t(n)||typeof n.position?.order!="number")continue;const o=qi(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 d=qi(a),u=s.get(d)??[];u.push(a),s.set(d,u)}const i=[...s.values()][0]??[];return bg(i)}function Hk(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:d}=gs(r,n),u=e===s&&t===i-1,l=e>=s&&e<s+a,f=t>=i-1&&t<i-1+d;return l&&f&&!u}function Wk(e,t,r){const n=new Set(r??[]);for(const o of e){const s=o[0]?.position?.order??0,{rowSpan:i}=gs(o,t);for(let a=s;a<s+i;a++)n.add(a)}return n}function Rk(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 Gk(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 gr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function To(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>To(r));if(!gr(e))return e;const t={};for(const[r,n]of Object.entries(e))t[r]=To(n);return t}function wg(e,...t){const r={...e};for(const n of t)if(!(!n||!gr(n)))for(const[o,s]of Object.entries(n)){const i=r[o];gr(s)&&gr(i)?r[o]=wg(i,s):r[o]=s}return r}function Yn(e){return gr(e)?e:{}}function ys(e){if(e==null)return{};if(typeof e=="string"){const t=e.trim();if(!t)return{};try{const r=JSON.parse(t);return gr(r)?To(r):{}}catch{return{}}}return gr(e)?To(e):{}}function Sg(e){const t=e.apidata;return gr(t)&&Object.keys(t).length>0}function Kk(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 qk(e,t){const r=e.appearance,n=gr(r)&&Object.keys(r).length>0?To(r):{},o=Yn(t.appearance),s={...n};for(const[i,a]of Object.entries(o))i!=="heightPercent"&&s[i]===void 0&&(s[i]=To(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 Yk(e,t){const r=Yn(e.position),n=ys(e.metadata),o=Yn(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,d=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:d},l=r.cellGroupId??o.cellGroupId,f=ko(r,{cellSlotIndex:e.cellSlotIndex??o.cellSlotIndex,stackSlot:n.stackSlot??o.stackSlot}),p=hs(r)??hs(o)??(n.stackDirection==="horizontal"||o.stackDirection==="horizontal"?"row":n.stackDirection==="vertical"||o.stackDirection==="vertical"?"stack":void 0);return typeof l=="string"&&(u.cellGroupId=l),typeof f=="number"&&(u.cellSlot=f),(p==="row"||p==="stack")&&(u.sharedCellLayout=p),u}function Xk(e,t){const r=e,n=ys(r.metadata),o=Yn(r.apidata),s=Yn(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),d=(r.type!=null&&String(r.type).trim()!==""?r.type:void 0)??(typeof r.fieldType=="string"?r.fieldType:void 0),u=qk(r,n),l=Yk(r,t),f={...r};return f.properties=i,a!==void 0&&(f.name=a),d!==void 0&&(f.type=d),u!==void 0?f.appearance=u:(!gr(r.appearance)||Object.keys(r.appearance).length===0)&&delete f.appearance,f.position=l,gr(f.appearance)&&delete f.appearance.heightPercent,f}function Jk(e,t){if(!e||typeof e!="object")return!0;const r=e,n=ys(r.metadata),o=Object.keys(n).length===0&&!(typeof r.metadata=="string"&&r.metadata.trim()!==""),s=!Sg(r);if(Kk(r)||!o||!s)return!1;const i=r.position;return!(!(gr(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")||gr(n.appearance)||xg.some(u=>n[u]!==void 0&&(r.appearance==null||gr(r.appearance)&&r.appearance[u]===void 0))||Qk(r))}function Qk(e){const t=Yn(e.position),r=Yn(e.layout),n=ys(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 Yi(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(Jk(o))return o;const i=Xk(o,s);return i!==o&&(r=!0),i});return r?{...e,fields:n}:e}function Zk(e){return Yi(e)}const eT=new Set(["PENDING_PAYMENT","PAYMENT_PENDING","AWAITING_PAYMENT","PAID","PAYMENT_COMPLETED","PAYMENT_FAILED","REFUNDED","AUTHORIZED","CAPTURED","PARTIALLY_PAID"].map(e=>e.toUpperCase()));function Fc(e){return typeof e=="string"&&e.trim()!==""}function Pc(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"||Fc(t.amount)||typeof t.total_amount=="number"||Fc(t.total_amount)||Fc(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"&&eT.has(r.trim().toUpperCase()))}function tT(e){const t=Qe(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 rT(e,t){const r=tT(e);if(!r)return;const n=Qe(e,"data"),o=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(t?.treatFirstItemIdAsPaymentId===!0||Pc(r.item)||o!=null&&Pc(o))return r.id}function nT(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 oT(e){return nT(e).some(t=>t.toLowerCase().includes("payment"))}function sT(e){const t=e.properties,r=e.metadata;return!!(t?.mergeSuccessDataIdAsPaymentId||r?.mergeSuccessDataIdAsPaymentId)}function iT(e,t){if(t?.type!=="button"||!Uo(e))return;const r=Qe(e,"data.id");if(r==null||String(r).trim()==="")return;const n=Qe(e,"data");if(sT(t)||n!=null&&typeof n=="object"&&!Array.isArray(n)&&Pc(n)||oT(t))return r}const aT=new Set(["section","group","columns","divider","header","sectionHeading","spacer","addmore","textLabel","customizeSections"]);function lT(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 cT(e,t){const r=e.properties,n=Array.isArray(r?.linkedFieldNames)?r.linkedFieldNames:[],o=lT(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 Ag(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 dT(e,t){return Ag(e,t).find(r=>r.heading?.enabled)}function Cg(e,t){const r=e.template??"";return(e.mode??"increment")==="fixed"?r:r.replace(/\{n\}/g,String(t+1))}function Eg(e,t,r,n){const o=cT(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||aT.has(i.type)?!1:s.has(a)})}function uT(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 Oc(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 fT(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 d=Oc(a).map(u=>r(u)).filter(Boolean);s.push({section:i,fieldNames:d})}return s}function bs(e,t=0){return e.heading?.enabled?Cg(e.heading,t):e.name}function Ng(e,t,r){if(e.type!=="sectionHeading")return!1;const n=t.heading;return!n?.enabled||!n.headingFieldName?!1:r(e)===n.headingFieldName}function pT(e,t){const r=typeof e.position?.order=="number"?e.position.order:0,n=(e.position?.column??1)-1,o=Do(e),s=bd(e,t);return{row:r,col:n,rowEnd:r+o-1,colEnd:n+s-1}}function Ic(e,t){let r=1/0,n=-1/0,o=1/0,s=-1/0;for(const i of e){const{row:a,col:d,rowEnd:u,colEnd:l}=pT(i,t);r=Math.min(r,a),n=Math.max(n,u),o=Math.min(o,d),s=Math.max(s,l)}return Number.isFinite(r)?{minRow:r,maxRow:n,minCol:o,maxCol:s,rowSpan:n-r+1,colSpan:s-o+1}:null}function mT(e,t,r,n){const o=e.map(l=>t.find(f=>n(f)===l)).filter(l=>!!l&&typeof l.position?.order=="number");if(o.length===0)return null;const s=Ic(o,r);if(!s)return null;const i=o.filter(l=>l.type!=="sectionHeading"),a=i.length>0?i:o,d=Math.min(...a.map(l=>l.position?.order??0)),u=Math.max(1,...a.map(l=>(l.position?.order??d)-d+Do(l)));return{minRow:s.minRow,maxRow:s.maxRow,minCol:s.minCol,maxCol:s.maxCol,blockHeight:u}}function hT(e,t){return e.maxRow+1+t*e.blockHeight}function gT(e,t,r,n){const o=new Map;for(const a of t){const d=r(a);d&&o.set(d,a)}const s=new Map,i=new Set;for(const a of e){const d=a.fieldNames.map(v=>o.get(v)).filter(v=>!!v);if(d.length===0)continue;const u=d.filter(v=>!Ng(v,a.section,r)),l=Ic(d,n);if(!l)continue;const{minRow:f,minCol:p,rowSpan:m,colSpan:g}=l,h=`${f}-${p}`;if(s.has(h))continue;const y=new Set;let w=!1;for(let v=f;v<=f+m-1;v++){for(let x=p;x<=p+g-1;x++){const E=`${v}-${x}`;if(i.has(E)){w=!0;break}y.add(E)}if(w)break}if(!w){for(const v of y)i.add(v);s.set(h,{anchorRow:f,anchorCol:p,rowSpan:m,colSpan:g,run:a,legend:bs(a.section,0),renderFields:u.length>0?u:d})}}return{anchorsByOrigin:s,coveredCells:i}}function yT(e,t,r,n,o,s,i){const a=new Set(i),d=new Map;for(const u of e){const l=_g(u.linkedFields.map(p=>s(p)).filter(Boolean),t),f=l?.section;f?.fieldNames?.length?f.fieldNames:u.templateFieldNames,u.blockIds.forEach((p,m)=>{const g=r.filter(N=>N.id.endsWith(`__${p}`));if(g.length===0||!l)return;const h=Ic(g,o);if(!h)return;const{minRow:y,minCol:w,rowSpan:v,colSpan:x}=h,E=`${y}-${w}`;for(let N=y;N<=y+v-1;N++)for(let C=w;C<=w+x-1;C++)a.add(`${N}-${C}`);const P=l,_=bs(f,m+1);d.set(E,{anchorRow:y,anchorCol:w,rowSpan:v,colSpan:x,run:P,legend:_,renderFields:Oc(g),addMoreMeta:{addMoreFieldName:u.addMoreFieldName,blockId:p,blockIndex:m}})})}return{anchorsByOrigin:d,coveredCells:a}}function bT(e,t,r,n){const o=`${e}-${t}`;return r.has(o)?!n.get(o):!1}function vT(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 wT(e,t,r,n){return!(!n||r.run.section.collapsible!==!0||e===r.anchorRow&&t===r.anchorCol)}function ST(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 xT(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 AT(e,t){return new Map([...e,...t])}function CT(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),d=a?n.get(a):void 0;if(!d){o.push({kind:"field",field:i}),s+=1;continue}const u=[],l=new Set(d.fieldNames);for(;s<e.length;){const p=r(e[s]);if(!p||!l.has(p))break;const m=e[s];Ng(m,d.section,r)||u.push(m),s+=1}if(u.length===0)continue;const f=o[o.length-1];f?.kind==="border"&&f.run.section.id===d.section.id?f.fields.push(...u):o.push({kind:"border",run:d,fields:u})}return o}function _g(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 ET=2*6e4,kg=50;class NT{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<=kg)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-kg)).forEach(([n])=>this.map.delete(n))}}function _T(e){return(e??"").trim()||"default"}function Tg(e){const t=_T(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 Fg=new NT(ET);function Pg(e){const t=Tg(e),r=Fg.get(t);return r?{value:r.value,isStale:r.isStale}:null}function Og(e,t){const r=Tg(e);Fg.set(r,t)}function Ig(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 Mc=({schema:e,formId:t,initialValues:r,onSubmit:n,onChange:o,onValidationError:s,onClose:i,mode:a="fill",className:d,children:u,gridLayout:l,unstyled:f=!1,submissionContext:p,onWorkflowSubmitResult:m,initialExtraSubmitPayload:g,onExtraSubmitPayloadChange:h,workflowStepId:y,viewerContext:w,getViewerContext:v,hideTableRowControls:x=!1,themeVars:E,dark:P=!1,omitRootWrapper:_=!1})=>{const N=Rn(k=>k.viewerContext),C=S.useMemo(()=>{if(w!==void 0)return w;const k=v?.();return k!==void 0?k:N},[w,v,N]),[A,I]=S.useState(e||null),[T,W]=S.useState(!!t&&!e),[X,O]=S.useState(null),j=e?.BFF_submit_api??X,[M,D]=S.useState(!1),[L,U]=S.useState({}),[$,ie]=S.useState({}),[V,K]=S.useState({}),[J,ce]=S.useState({}),[ne,G]=S.useState({}),[ee,Pe]=S.useState(null),oe=ha.useParams(),re=Nt(k=>k.setValues),be=Nt(k=>k.setSubmitting),de=Nt(k=>k.formDisabled),ot=Nt(k=>k.visibleFields),Se=Nt(k=>k.requiredFields),xe=Nt(k=>k.updateVisibility),ae=Nt(k=>k.updateRequired),ve=Nt(k=>k.setFieldError),Ye=S.useRef(!1),ct=S.useRef(void 0),Ge=S.useMemo(()=>{if(!e)return null;const k=e;if(k.form&&Array.isArray(k.form.fields))try{return ms(k.form,k.form.fields,k.form.layout||null,k.form.rules||[])}catch{return e}if(Array.isArray(k.fields)&&k.fields.some(z=>typeof z.metadata=="string"&&z.metadata.startsWith("{")||z.fieldType&&!z.type))try{const z={id:k.id||k._id||"temp",name:k.name||"Form",version:k.version??1,status:k.status||"draft",createdAt:k.createdAt||new Date().toISOString(),updatedAt:k.updatedAt||new Date().toISOString(),createdBy:k.createdBy||"system",category:k.category||"",moduleId:k.moduleId,tenantId:k.tenantId,featureId:k.featureId,isDefault:k.isDefault||!1};return ms(z,k.fields,k.layout||null,k.rules||[])}catch{return e}return e},[e]);S.useEffect(()=>{if(e){const k=e;k.BFF_submit_api&&O(k.BFF_submit_api)}},[e]);const Kt=S.useMemo(()=>{const k=Ge||A,H=k?Yi(k):null;if(!H)return null;const z=H.layout,Z=H.rules,Q=H.clientMapping,le=(Array.isArray(H.fields)?H.fields:[]).map(Le=>{let Ve={...Le};if(Le.validationRules&&typeof Le.validationRules=="object"&&!Le.validation){const fe=Le.validationRules,Fe=[];fe.required===!0&&Fe.push({type:"required",message:"This field is required"}),fe.minLength!==void 0&&typeof fe.minLength=="number"&&Fe.push({type:"minLength",value:fe.minLength,message:`Minimum length is ${fe.minLength}`}),fe.maxLength!==void 0&&typeof fe.maxLength=="number"&&Fe.push({type:"maxLength",value:fe.maxLength,message:`Maximum length is ${fe.maxLength}`}),fe.pattern&&typeof fe.pattern=="string"&&Fe.push({type:"pattern",value:fe.pattern,message:"Invalid format"}),fe.allowLetters!==void 0&&Fe.push({type:"allowLetters",value:fe.allowLetters}),fe.allowNumbers!==void 0&&Fe.push({type:"allowNumbers",value:fe.allowNumbers}),fe.allowSpecialChars!==void 0&&Fe.push({type:"allowSpecialChars",value:fe.allowSpecialChars}),Fe.length>0&&(Ve={...Ve,validation:Fe})}const we=Le.required===!0||Le.isRequired===!0,Ae=Array.isArray(Ve.validation)&&Ve.validation.some(fe=>fe.type==="required");if(we&&!Ae){const fe={type:"required",message:"This field is required"},Fe=Array.isArray(Ve.validation)?Ve.validation:[];Ve={...Ve,validation:[...Fe,fe]}}if(Le.apidata&&typeof Le.apidata=="object"){const fe=Le.apidata,Fe=Ve.properties||{},ye=(Ve.type||Le.fieldType)==="status";if(!Fe.apiEndpoint&&fe.apiEndpoint){const dt={...Fe,apiEndpoint:fe.apiEndpoint,apiMethod:fe.apiMethod,apiKey:fe.apiKey,apiRealtime:fe.apiRealtime,apiAutoDetect:fe.apiAutoDetect,apiLabelField:fe.apiLabelField,apiValueField:fe.apiValueField,apiQueryParams:fe.apiQueryParams,apiClientFilter:fe.apiClientFilter,valueSource:fe.valueSource||(fe.apiEndpoint?"api":void 0),optionsSource:fe.optionsSource||(fe.apiEndpoint?"api":void 0)};ye&&(dt.source=Fe.source??"api",Fe.statuses!==void 0&&(dt.statuses=Fe.statuses),Fe.dataPath!==void 0&&(dt.dataPath=Fe.dataPath),Fe.showStatusText!==void 0&&(dt.showStatusText=Fe.showStatusText),Fe.statusTextPath!==void 0&&(dt.statusTextPath=Fe.statusTextPath),Fe.showCurrentIndicator!==void 0&&(dt.showCurrentIndicator=Fe.showCurrentIndicator)),Ve={...Ve,properties:dt}}}const He=["select","multiselect","radio","checkboxgroup"],rt=Ve.type||Le.fieldType;if(He.includes(rt)){const fe=Le.options,Fe=Ve.properties?.options,ye=Array.isArray(Fe)&&Fe.length>0;if(Array.isArray(fe)&&fe.length>0&&!ye){const dt=Ve.properties||{};Ve={...Ve,properties:{...dt,options:fe}}}}return Ve}),Ce=H.config?.rules,Ne=Z&&Array.isArray(Z)?Z:Ce&&Array.isArray(Ce)?Ce:[],De=Ne.length>0?le.map(Le=>{if((Le.conditions&&Array.isArray(Le.conditions)?Le.conditions:[]).length>0)return Le;const we=Le.id??Le._id,Ae=Le.name||Le.key,He=Ne.filter(Fe=>{const ye=typeof Fe.targetFieldId=="object"?Fe.targetFieldId?.id??Fe.targetFieldId?._id:Fe.targetFieldId;return ye?ye===we||ye===Ae||ye===Le.fieldKey:!1});if(He.length===0)return Le;const rt=[],fe=new Set;return He.forEach(Fe=>{try{const ye=typeof Fe.conditionExpression=="string"?JSON.parse(Fe.conditionExpression):Fe.conditionExpression;if(!ye||typeof ye!="object")return;!ye.id&&Fe.id&&(ye.id=Fe.id);const dt=typeof Fe.targetFieldId=="object"?Fe.targetFieldId?.id??Fe.targetFieldId?._id:Fe.targetFieldId;ye.action&&(!ye.then||!Array.isArray(ye.then)||ye.then.length===0)&&(ye.then=[{action:ye.action,...dt&&{target:dt}}]),(!ye.then||!Array.isArray(ye.then)||ye.then.length===0)&&Fe.action&&(ye.then=[{action:Fe.action,...dt&&{target:dt}}]),ye.then&&Array.isArray(ye.then)&&dt&&(ye.then=ye.then.map(Bt=>!Bt.target&&dt?{...Bt,target:dt}:Bt));const Wt=Fe.conditionExpression??JSON.stringify(ye);if(fe.has(Wt))return;fe.add(Wt),rt.push(ye)}catch{}}),rt.length===0?Le:{...Le,conditions:rt}}):le;let at=H.config||{submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};return!at.layout&&z?typeof z=="object"&&z!==null?at.layout="default":typeof z=="string"&&["default","card","compact"].includes(z)?at.layout=z:at.layout="default":at.layout||(at.layout="default"),Z&&!at.rules&&(at.rules=Z),Q&&!at.clientMapping&&(at.clientMapping=Q),{...H,fields:De,config:at}},[Ge,A]);S.useEffect(()=>{Ge&&Ge!==A&&I(Ge)},[Ge]),S.useEffect(()=>{if(t&&!e){const k=(Tn()??"").trim()||"default",H=Pg({scope:k,formId:t,version:"latest"});H?.value?.schema?(I(H.value.schema),H.value.bffSubmitApi&&O(H.value.bffSubmitApi),W(!1),H.isStale&&Je({background:!0})):Je({background:!1})}},[t,e]);const Je=async({background:k})=>{if(!t)return;const H=t;k||W(!0);try{const z=await Lk.getForRendering(t),Z=ms(z.form,z.fields,z.layout,z.rules);if(H!==t)return;I(Z),z.BFF_submit_api&&O(z.BFF_submit_api);const Q=(Tn()??"").trim()||"default";Og({scope:Q,formId:H,version:"latest"},{schema:Z,bffSubmitApi:z.BFF_submit_api})}catch{}finally{k||W(!1)}};if(T)return c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(Pn,{})});if(!Kt)return c.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Form not found"});const q=Kt,$e=S.useMemo(()=>new Set(Object.keys(q.config?.prepopulateApi?.fieldMapping??{})),[q.config?.prepopulateApi?.fieldMapping]),gt=S.useCallback(async k=>{const H=q?.fields?.length?tc(k,q.fields):k,z=yh(H,q.config?.sections,q.config?.submitPayload);if(n){const Z=p?{...z,...p}:z;return n(Z)}return{success:!0}},[n,p,q?.fields,q.config?.sections,q.config?.submitPayload]),{values:Oe,errors:te,touched:pe,isSubmitting:We,isValid:Pt,submitCount:je,currentStep:Te,totalSteps:Xe,completedSteps:Ue,currentStepFields:ft,isLastStep:St,setFieldValue:xt,setFieldTouched:ze,handleSubmit:yt,validateForm:pt,resetForm:At,nextStep:Ut,goToStep:ur,shouldShowField:Ar,isFieldEnabled:Vt,isFieldRequired:Po,loadDraft:Xn}=Vd({schema:q,initialValues:r,onSubmit:gt,onChange:o,workflowStepId:y});sv({fields:q.fields,values:Oe,buttonResponses:$,prepopulateResponse:ee,prepopulateResponseRules:q.config?.prepopulateResponseRules});const Ct=Nt(k=>k.readOnlyFields),Cr=Nt(k=>k.editableFields),Jn=S.useCallback(k=>Ct.has(k),[Ct]),It=S.useCallback(k=>Cr.has(k),[Cr]);S.useEffect(()=>{q.config?.allowDraft&&a==="fill"&&Xn()},[q.id]),S.useEffect(()=>{ct.current=q.id,Ye.current=!1,U({}),K({}),ce({}),G({}),Pe(null)},[q.id]),S.useEffect(()=>{const k=q.config?.prepopulateApi,H=!!(k?.fieldMapping&&Object.keys(k?.fieldMapping??{}).length>0),z=(q.config?.prepopulateResponseRules?.length??0)>0;if(!k?.enabled||!k.apiEndpoint?.trim()||!H&&!z||Ye.current)return;Ye.current=!0;const Z=q.id;ct.current=q.id;let Q=!1;return D(!0),(async()=>{try{const le=Nt.getState().values,Ce=typeof p=="object"&&p!==null?{...p,...g||{}}:g||{},Ne=se=>rn(se,le,oe,Ce);let De=cn(Ne(k.apiEndpoint));if(k.apiQueryParams?.length){const se=new URLSearchParams;k.apiQueryParams.forEach(({key:Ie,value:me})=>se.append(Ie,Ne(me))),De=`${De}${De.includes("?")?"&":"?"}${se.toString()}`}const at={};k.apiHeaders?.forEach(({key:se,value:Ie})=>{se.trim()&&(at[se]=Ne(Ie))}),at["Content-Type"]=at["Content-Type"]??"application/json";let Ht;if(k.apiMethod==="POST"&&k.apiBodyFields?.length){const se={};k.apiBodyFields.forEach(({key:Ie,value:me})=>{Ie.trim()&&(se[Ie]=Ne(me))}),Ht=JSON.stringify(se)}const Le=await fetch(De,{method:k.apiMethod,headers:at,body:k.apiMethod==="POST"?Ht:void 0});if(!Le.ok){const se=await Le.text();throw new Error(se||`HTTP ${Le.status}`)}const Ve=await Le.json(),we=se=>{try{return se.split("?")[0].split("/").filter(Boolean).pop()||se}catch{return se}},Ae=(se,Ie)=>{if(se==null)return null;const me=typeof se=="string"?se:se instanceof Date?se.toISOString():null;if(!me)return null;const Ke=typeof se=="object"&&se instanceof Date?se:new Date(me);if(Number.isNaN(Ke.getTime()))return null;const ut=mt=>String(mt).padStart(2,"0");if(Ie==="date")return me.length>=10&&me[4]==="-"&&me[7]==="-"?me.slice(0,10):Ke.toISOString().slice(0,10);if(Ie==="time")return`${ut(Ke.getHours())}:${ut(Ke.getMinutes())}:${ut(Ke.getSeconds())}`;if(Ie==="datetime"){const mt=Ke.getFullYear(),tt=Ke.getMonth()+1,ue=Ke.getDate(),bt=Ke.getHours(),Re=Ke.getMinutes(),Ft=Ke.getSeconds();return`${mt}-${ut(tt)}-${ut(ue)}T${ut(bt)}:${ut(Re)}:${ut(Ft)}`}return null},He=(se,Ie)=>{const me=q.fields.find(ue=>ue.name===se||ue.key===se);if(!me)return Ie;if((me.type==="file"||me.type==="camera"||me.type==="photoChoice")&&typeof Ie=="string"&&Ie.startsWith("http"))return{url:Ie,name:we(Ie)};if(me.type==="date"||me.type==="datetime"||me.type==="time"){const ue=Ae(Ie,me.type);if(ue!==null)return ue}if(me.type==="multiselect")return Array.isArray(Ie)?Ie.map(ue=>typeof ue=="string"?ue:String(ue)):typeof Ie=="string"?Ie.trim()===""?[]:Ie.includes(",")?Ie.split(",").map(ue=>ue.trim()).filter(Boolean):[Ie]:Ie!=null&&Ie!==""?[String(Ie)]:[];if(me.type!=="radio"&&me.type!=="select")return Ie;const Ke=me.properties?.options??me.options;if(!Array.isArray(Ke)||Ke.length===0)return Ie;const ut=Ke.map(ue=>ue.value);if(ut.includes(Ie))return Ie;const mt=String(Ie);if(ut.includes(mt))return mt;const tt=Ke.find(ue=>ue.value==Ie);return tt?tt.value:Ie},rt=new Set(q.fields.filter(se=>se.type==="table").map(se=>se.name||se.key)),fe=new Set(q.fields.filter(se=>se.type==="billingGrid").map(se=>se.name||se.key)),Fe=se=>se.name||se.key||se.id,ye={},dt=[],Wt=[],Bt=gN(k?.fieldMapping,q.config?.sections,q.config?.submitPayload);for(const[se,Ie]of Object.entries(Bt)){if(!Ie?.trim()||se.startsWith("__"))continue;const me=Qe(Ve,Ie),Ke=se.indexOf(".");if(Ke>0&&fe.has(se.slice(0,Ke))){const mt=se.slice(0,Ke),tt=se.slice(Ke+1),bt=q.fields.find(Re=>(Re.name||Re.key)===mt)?.properties;if(bt?.rowSlots?.length){const Re=tt.startsWith("__block__")?tt.slice(9):tt,Ft=ye[mt]??Nt.getState().values[mt];Array.isArray(me)?ye[mt]=f_(bt,Re,me,Ft):me!=null&&(ye[mt]=mc(bt,me,Ft))}continue}if(Ke>0&&rt.has(se.slice(0,Ke))){const mt=se.slice(0,Ke),tt=se.slice(Ke+1);dt.push({tableName:mt,columnName:tt,path:Ie});continue}if(fe.has(se)&&me!==void 0&&me!==null&&typeof me=="object"){const tt=q.fields.find(ue=>(ue.name||ue.key)===se)?.properties;if(tt?.rowSlots?.length){if(Array.isArray(me)){const ue=tt.rowSlots.find(bt=>bt.kind==="dynamic");if(ue&&ue.kind==="dynamic"){const bt=ue.block.apiArrayPath??"items";ye[se]=mc(tt,{[bt]:me})}}else ye[se]=mc(tt,me);continue}}if(rt.has(se)&&Array.isArray(me)&&me.length>0&&typeof me[0]=="object"&&me[0]!==null){const tt=q.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],ue=me.map(Ig),bt=Re=>(Re||"").toLowerCase().replace(/\s+/g,"_").trim();ye[se]=ue.map(Re=>{const Ft={};for(const fr of tt){const eo=fr.name??"";Ft[eo]=Re[bt(eo)]??Re[eo]}return Ft});continue}if(me!=null&&(ye[se]=He(se,me)),me==null)continue;let ut=me;if(Array.isArray(me)){const mt=q.fields.find(tt=>Fe(tt)===se);if(mt?.type==="addmore"){Wt.push({addMoreFieldName:se,array:me});continue}if(mt?.type==="multiselect"){const tt=k.multiselectArrayPropertyMap?.[se];tt&&me.length>0&&me.some(ue=>ue!=null&&typeof ue=="object")&&(ut=me.map(ue=>ue!=null&&typeof ue=="object"&&tt in ue?ue[tt]:void 0).filter(ue=>ue!=null))}}ye[se]=He(se,ut)}const lt={},vt={},rr={};for(const{addMoreFieldName:se,array:Ie}of Wt){const me=q.fields.find(bt=>Fe(bt)===se);if(!me||me.type!=="addmore")continue;const Ke=Eg(me,q.fields,q.config?.sections,Fe);if(Ke.length===0)continue;const ut=k.addMoreFieldKeyMap?.[se],mt=Ie.length>0&&Ie[0]!=null&&typeof Ie[0]=="object"?Ie[0]:null;if(mt)for(const bt of Ke){const Re=Fe(bt),Ft=ut&&ut[Re]||Re,fr=mt[Ft];fr!=null&&(ye[Re]=He(Re,fr))}const tt=Ie.slice(1),ue=tt.map((bt,Re)=>`prepop_${se}_${Re}_${Date.now()}`);ue.length>0&&(vt[se]=ue);for(let bt=0;bt<tt.length;bt++){const Re=tt[bt];if(Re==null||typeof Re!="object")continue;const Ft=Re,fr=Ft.id;fr!=null&&String(fr).trim()!==""&&(rr[`${se}__${ue[bt]}`]=String(fr));for(const eo of Ke){const ma=Fe(eo),bP=ut&&ut[ma]||ma,Kc=Ft[bP];if(Kc==null)continue;const vP=`${ma}__addmore__${se}__${ue[bt]}`;lt[vP]=He(ma,Kc)}}}Object.keys(vt).length>0&&K(se=>({...se,...vt})),Object.keys(rr).length>0&&G(se=>({...se,...rr}));const jr=se=>(se||"").toLowerCase().replace(/\s+/g,"_").trim(),Kr=[...new Set(dt.map(se=>se.tableName))];for(const se of Kr){if(Array.isArray(ye[se]))continue;const Ie=dt.find(ue=>ue.tableName===se);if(!Ie?.path?.includes("."))continue;const me=Ie.path.replace(/\.[^.]+$/,""),Ke=Qe(Ve,me);if(!Array.isArray(Ke)||Ke.length===0||typeof Ke[0]!="object"||Ke[0]===null)continue;const mt=q.fields.find(ue=>(ue.name||ue.key)===se)?.properties?.columns||[],tt=Ke.map(Ig);ye[se]=tt.map(ue=>{const bt={};for(const Re of mt){const Ft=Re.name??"",fr=jr(Ft),eo=ue[fr]??ue[Ft];bt[Ft]=eo}return bt})}const zr=(se,Ie)=>{const me=Qe(Ve,se);if(Array.isArray(me))return me;if(me!=null)return[me];if(!se.includes("."))return[];const Ke=se.replace(/\.[^.]+$/,""),ut=Qe(Ve,Ke);return!Array.isArray(ut)||ut.length===0||typeof ut[0]!="object"||ut[0]===null?[]:ut.map(mt=>{const tt=mt[Ie];if(tt!==null&&typeof tt=="object"&&!Array.isArray(tt)&&!(tt instanceof Date)){const ue=tt;return typeof ue.name=="string"&&typeof ue.code=="string"?`${ue.code} ${ue.name}`.trim():typeof ue.name=="string"?ue.name:typeof ue.code=="string"?ue.code:typeof ue.short_code=="string"?ue.short_code:ue.name??ue.code??""}return tt})};for(const{tableName:se,columnName:Ie,path:me}of dt){const Ke=zr(me,Ie),mt=q.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],tt=mt.find(Re=>(Re.name||"").toLowerCase()===Ie.toLowerCase())?.name??Ie;let ue=Array.isArray(ye[se])?ye[se]:[];const bt=Math.max(ue.length,Ke.length);if(bt>ue.length)for(ue=[...ue];ue.length<bt;){const Re={};mt.forEach(Ft=>{Re[Ft.name||""]=""}),ue.push(Re)}else ue=ue.map(Re=>({...Re}));Ke.forEach((Re,Ft)=>{ue[Ft]&&(ue[Ft][tt]=Re)}),ye[se]=ue}if(ct.current===Z){if(Object.keys(ye).length>0||Object.keys(lt).length>0){const Ft={...Nt.getState().values,...ye,...lt};re(Ft)}const Ie=Qe(Ve,"data.user_id"),me=Qe(Ve,"data.items"),Ke=Qe(Ve,"data");let ut=Array.isArray(me)&&me.length>0&&me[0]!=null&&typeof me[0]=="object"&&me[0].id?me[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=Qe(Ve,"data.0.id"));const mt=rT(Ve,{treatFirstItemIdAsPaymentId:k?.treatFirstItemIdAsPaymentId===!0}),tt=Qe(Ve,"data.id"),ue=Qe(Ve,"data.batch_id"),bt=Qe(Ve,"data.program_id"),Re={};Ie!=null&&(Re.context_user_id=Ie),ut!=null&&ut!==""&&(Re.documentId=ut),tt!=null&&String(tt).trim()!==""&&(p?.id===void 0||p?.id===null)&&(Re.id=tt),ue!=null&&String(ue).trim()!==""&&((p?.admission_batch_id===void 0||p?.admission_batch_id===null)&&(Re.admission_batch_id=ue),(p?.batch_id===void 0||p?.batch_id===null)&&(Re.batch_id=ue)),bt!=null&&String(bt).trim()!==""&&(p?.program_id===void 0||p?.program_id===null)&&(Re.program_id=bt),mt!=null&&String(mt).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&(Re.payment_id=mt),Object.keys(Re).length>0&&U(Ft=>{const fr={...Ft,...Re};return h?.(fr),fr}),Pe(Ve)}}catch(le){Q||Zl(le,"Prepopulate request failed.",ls)}finally{D(!1)}})(),()=>{Q=!0}},[q.id,q.config?.prepopulateApi?.enabled,q.config?.prepopulateApi?.apiEndpoint,q.config?.prepopulateApi?.apiMethod,JSON.stringify(q.config?.prepopulateApi?.fieldMapping),q.config?.prepopulateApi?.treatFirstItemIdAsPaymentId,p,g,oe,re,K]),S.useEffect(()=>{Object.keys(te).length>0&&s?.(te)},[te,s]);const Er=Xe>1,er=a==="view",sr=S.useCallback((k,H)=>er||!!H&&!It(k)||Jn(k)&&!It(k),[er,It,Jn]),fn=q.fields.filter(k=>!k.parentId),kt=[...Er?ft:fn.length>0?fn:q.fields].filter(k=>!(!k||typeof k!="object"||!k.name&&!k.key)).sort((k,H)=>{const z=typeof k.position?.order=="number"?k.position.order:typeof k.positionOrder=="number"?k.positionOrder:Number.MAX_SAFE_INTEGER,Z=typeof H.position?.order=="number"?H.position.order:typeof H.positionOrder=="number"?H.positionOrder:Number.MAX_SAFE_INTEGER;if(z!==Z)return z-Z;const Q=typeof k.position?.column=="number"?k.position.column:1,le=typeof H.position?.column=="number"?H.position.column:1;return Q-le}),Ss=S.useCallback(k=>{const H=Nt.getState().errors,z=Object.keys(H).find(Z=>k.includes(Z));z&&requestAnimationFrame(()=>{document.querySelector(`[data-field-name="${z}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})})},[]),Nr=async k=>{if(k?.preventDefault(),Er&&!St){if(!await Ut())try{const Z=Nt.getState().errors;$t.toast.error(ec(Z,q.fields)||"Please fix the errors before continuing."),Ss(kt.map(Q=>Q.name||Q.key||Q.id).filter(Boolean))}catch{$t.toast.error("Please fix the errors before continuing.")}return}const H=await yt(k);if(H&&H.success===!1&&H.errors?.length)try{const z=Nt.getState().errors;$t.toast.error(ec(z,q.fields)||"Submission failed. Please check the form."),Ss(kt.map(Z=>Z.name||Z.key||Z.id).filter(Boolean))}catch{$t.toast.error("Submission failed. Please check the form.")}return H},Dr=S.useCallback(()=>{At(),i&&i()},[At,i]),_r=S.useCallback((k,H)=>{const z=q.fields.find(Q=>Q.type==="button"&&(Q.name===k||Q.key===k)),Z=iT(H,z);Z!=null&&String(Z).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&U(Q=>{const le={...Q,payment_id:Z};return h?.(le),le}),ie(Q=>{const le={...Q,[k]:H};return!Uo(H)||!(z?.type==="button"&&z.properties?.action==="submit")||q.fields.filter(De=>De.type==="editButton").map(De=>De.name).forEach(De=>delete le[De]),le})},[q.fields,p,h]),br=S.useCallback(async()=>await pt(),[pt]),qt=S.useCallback(()=>Nt.getState().errors,[]),tr=S.useMemo(()=>({...g||{},...L}),[g,L]),Br=S.useMemo(()=>({...typeof p=="object"&&p!==null?p:{},...tr}),[p,tr]),Qi=q.config?.layout??q.layout??"default",Zi=["default","card","compact"].includes(Qi)?Qi:"default",ea={default:"",card:"bg-card border rounded-lg shadow-sm p-6",compact:"space-y-2"},xs=S.useMemo(()=>{if(_)return;const k=q.config?.theme?.cssVariables;if(!(!k&&!E))return{...k??{},...E??{}}},[_,q.config?.theme?.cssVariables,E]),kr=S.useMemo(()=>_s({config:q.config,layout:q.layout},l),[q.config,q.layout,l]),Ee=S.useMemo(()=>kr?{...kr,verticalSpacing:kr.verticalSpacing??kr.spacing??"16px",horizontalSpacing:kr.horizontalSpacing??kr.spacing??"16px",rowHeight:kr.rowHeight??In}:null,[kr]),F=Ee!==null;Ee?.rows;const Y=Ee?.columns??3,he=Ee?.verticalSpacing??Ee?.spacing??"16px",st=Ee?.horizontalSpacing??Ee?.spacing??"16px",Tt=Ee?.rowHeight??In,wt=S.useCallback(k=>{if(!C)return!0;const H=k.visibility;if(!H)return!0;const z=H.visibleToUserType??H.user_type,Z=H.visibleToUserRole??H.user_role,Q=Array.isArray(H.visibleToUserIds)?H.visibleToUserIds:Array.isArray(H.users)?H.users:[],le=Array.isArray(H.hiddenFromUserIds)?H.hiddenFromUserIds:[];if(Array.isArray(le)&&le.length>0&&C.userId!=null&&le.includes(C.userId))return!1;if(Q.length>0&&C.userId!=null&&Q.includes(C.userId))return!0;const Ce=z!=null&&z!==""&&C.userType!=null&&C.userType!==z,Ne=Z!=null&&Z!==""&&C.role!=null&&C.role!==Z,De=Q.length>0&&(C.userId==null||!Q.includes(C.userId));return!(Ce||Ne||De)},[C]),Mt=S.useMemo(()=>NN(q.fields),[q.fields]),$r=S.useMemo(()=>kN(q.fields),[q.fields]),[ir,Oo]=S.useState($r);S.useEffect(()=>{Oo($r)},[q.id,$r]);const Lt=S.useCallback((k,H)=>{Oo(z=>z[k]===H?z:{...z,[k]:H})},[]),ta=S.useMemo(()=>({visibility:ir,setSectionVisible:Lt,fieldToHeading:Mt,allFields:q.fields}),[ir,Lt,Mt,q.fields]),et=S.useCallback(k=>k.name||k.key||k.id,[]),Tr=k=>{if(!wt(k))return!1;const H=k.name||k.key||k.id;if(!wh(H,k.type,ir,Mt))return!1;const z=k.hidden===!0;return Ar(H)||!z&&H},yy=S.useCallback(k=>{const H=q.fields.find(Z=>et(Z)===k);if(H)return H.type;const z=vh(k);return q.fields.find(Z=>et(Z)===z)?.type},[q.fields,et]),ra=S.useCallback(k=>wh(k,yy(k),ir,Mt),[ir,Mt,yy]),pn=S.useCallback(k=>ra(k)?Po(k):!1,[ra,Po]);S.useEffect(()=>{const{visibleFields:k,requiredFields:H,errors:z}=Nt.getState(),Z=new Set(k),Q=new Set(H),le=[];for(const Ce of q.fields){const Ne=et(Ce);Ne&&(ra(Ne)||(Z.delete(Ne),Q.delete(Ne),z[Ne]&&le.push(Ne)))}xe(Array.from(Z)),ae(Array.from(Q));for(const Ce of le)ve(Ce,void 0)},[ir,Mt,q.fields,q.id,et,ra,xe,ae,ve,ot,Se]);const Dt=q.config?.sections,Qn=S.useCallback(k=>{let H=k;if(k.type==="table"){const Z=k.properties?.columns;if(Array.isArray(Z)&&Z.length>0){const Q=Z.filter(le=>wt(le));H={...k,properties:{...k.properties,columns:Q}}}}const z=uT(H,Dt,et);return z?{...H,label:Cg(z,0)}:H},[wt,Dt,et]),mn=S.useCallback(k=>Eg(k,q.fields,Dt,et),[q.fields,Dt,et]),Gr=S.useCallback((k,H,z)=>`${k}__addmore__${H}__${z}`,[]),na=S.useCallback((k,H)=>`${k}__${H??"base"}`,[]),oa=S.useCallback((k,H)=>{const z=na(k.id,H);return J[z]??k.defaultCollapsed??!1},[J,na]),Wc=S.useCallback((k,H,z)=>{const Z=na(k,H);ce(Q=>Q[Z]===z?Q:{...Q,[Z]:z})},[na]),sa=S.useMemo(()=>{const k=[],H=q.fields.filter(z=>z.type==="addmore");for(const z of H){const Z=et(z),le=mn(z).find(at=>{if(at.type!=="button")return!1;const Ht=at.properties,Le=at.metadata;let Ve=Ht?.action;if(!Ve&&Le!=null)try{Ve=(typeof Le=="string"?JSON.parse(Le):Le)?.action}catch{}return Ve==="upload"||Ve==="custom"});if(!le)continue;const Ce=et(le),Ne=V[Z]||[],De=Qe($[Ce],"data.id")??Qe($[Ce],"data.documentId")??L.documentId;De!=null&&String(De).trim()!==""&&k.push(String(De));for(const at of Ne){const Ht=Gr(Ce,Z,at),Le=Qe($[Ht],"data.id")??Qe($[Ht],"data.documentId"),Ve=ne[`${Z}__${at}`],we=Le??Ve;we!=null&&String(we).trim()!==""&&k.push(String(we))}}return k},[q.fields,V,$,ne,L.documentId,et,mn,Gr]);S.useEffect(()=>{U(k=>{const H={...k,document_ids:sa},z=k.document_ids;return Array.isArray(z)&&z.length===sa.length&&sa.every((Z,Q)=>z[Q]===Z)?k:H})},[sa]);const ia=S.useCallback((k,H,z,Z)=>{for(const Q of z){const le=et(Q),Ce=Gr(le,k,H),Ne=Z[Ce];if(Ne==null)continue;const De=Q.type;if(De==="file"||De==="camera"||De==="photoChoice"){if(typeof Ne=="object"&&Ne!==null&&("url"in Ne||"name"in Ne)||Array.isArray(Ne)&&Ne.length>0)return!0;continue}if(Array.isArray(Ne)){if(Ne.length>0)return!0;continue}if(typeof Ne=="string"&&Ne.trim()!==""||typeof Ne=="number"&&!Number.isNaN(Ne)||typeof Ne=="boolean"||typeof Ne=="object"&&Ne!==null&&Object.keys(Ne).length>0)return!0}return!1},[et,Gr]),Zn=S.useCallback(k=>{const H=et(k);if(!H)return;if(mn(k).length===0){$t.toast.error("No linked fields configured for this Add More button.");return}const Z=`${Date.now()}_${Math.random().toString(36).slice(2,8)}`;K(Q=>({...Q,[H]:[...Q[H]||[],Z]}))},[et,mn]),aa=S.useCallback((k,H)=>{K(z=>{const Z=z[k]||[],Q=Z.filter(le=>le!==H);if(Q.length===Z.length)return z;if(Q.length===0){const le={...z};return delete le[k],le}return{...z,[k]:Q}})},[]),la=S.useMemo(()=>kt.filter(k=>!k.parentId),[kt]),On=S.useMemo(()=>{const k=[];return kt.filter(z=>z.type==="addmore").sort((z,Z)=>{const Q=z.position?.order??0,le=Z.position?.order??0;return Q-le}).forEach(z=>{const Z=et(z),Q=z.position?.order??0,le=V[Z]||[],Ce=mn(z).sort((Ae,He)=>{const rt=Ae.position?.order??0,fe=He.position?.order??0;return rt!==fe?rt-fe:(Ae.position?.column??1)-(He.position?.column??1)});if(Ce.length===0)return;const Ne=Ag(z,Dt),De=Ne[0]?.fieldNames?.length?Ne[0].fieldNames:Ce.map(Ae=>et(Ae)).filter(Boolean),at=mT(De,la,Y,et),Ht=Math.min(...Ce.map(Ae=>Ae.position?.order??0)),Le=Math.max(1,...Ce.map(Ae=>(Ae.position?.order??Ht)-Ht+Do(Ae))),Ve=at?.blockHeight??Le,we=le.length*Ve;k.push({addMoreFieldName:Z,baseOrder:Q,blockHeight:Ve,blockIds:le,linkedFields:Ce,insertedRows:we,templateFieldNames:De,templateBounds:at})}),k},[kt,la,Y,et,V,mn,Dt]),As=S.useMemo(()=>({}),[]),ca=S.useMemo(()=>On.length===0?kt:kt.map(k=>{const H=k.position?.order??0,z=On.reduce((Z,Q)=>{const le=Q.templateBounds?.maxRow??Q.baseOrder;return H>le?Z+Q.insertedRows:Z},0);return z===0?k:{...k,position:{...k.position,order:H+z}}}),[kt,On]),da=S.useCallback(k=>{const H={};return Object.entries($).forEach(([z,Z])=>{const Q=k[z];Q&&(H[Q]=Z)}),H},[$]),Io=S.useMemo(()=>{const k=[],H={};return On.forEach(z=>{const{addMoreFieldName:Z,blockIds:Q,linkedFields:le,blockHeight:Ce,templateBounds:Ne}=z,De=Math.min(...le.map(Le=>Le.position?.order??0)),Ht=q.fields.find(Le=>et(Le)===Z&&Le.type==="addmore")?.properties;Q.forEach((Le,Ve)=>{const we={},Ae={},He={},rt=Ne?hT(Ne,Ve):z.baseOrder+1+Ve*Ce,fe=ne[`${Z}__${Le}`];le.forEach(ye=>{const dt=et(ye),Wt=Gr(dt,Z,Le),Bt=(ye.position?.order??De)-De;if(we[Wt]=dt,Ae[Wt]=Oe[Wt],!(Ht?.linkedFieldAllowDuplicate?.[dt]??!0)&&(ye.type==="select"||ye.type==="radio"||ye.type==="multiselect")){const vt=[],rr=Oe[dt];rr!=null&&rr!==""&&(Array.isArray(rr)?vt.push(...rr.map(Kr=>String(Kr))):vt.push(String(rr))),Q.filter(Kr=>Kr!==Le).forEach(Kr=>{const zr=Gr(dt,Z,Kr),qr=Oe[zr];qr!=null&&qr!==""&&(Array.isArray(qr)?vt.push(...qr.map(se=>String(se))):vt.push(String(qr)))}),vt.length>0&&(He[Wt]=[...new Set(vt)])}k.push({...ye,id:`${ye.id}__${Le}`,name:Wt,position:{...ye.position,order:rt+Bt}})});const Fe=da(we);Object.keys(we).forEach(ye=>{H[ye]={scopedFormValues:Ae,scopedFieldNameMap:we,scopedButtonResponses:Fe,...fe!=null&&{blockDocumentId:fe},...He[ye]&&{excludedOptionValues:He[ye]}}})})}),{clonedFields:k,scopeByFieldName:H}},[On,ne,et,Gr,Oe,da,q.fields]),Cs=S.useMemo(()=>[...ca,...Io.clonedFields].sort((k,H)=>{const z=k.position?.order??0,Z=H.position?.order??0;if(z!==Z)return z-Z;const Q=k.position?.column??1,le=H.position?.column??1;if(Q!==le)return Q-le;const Ce=ko(k.position)??0,Ne=ko(H.position)??0;return Ce!==Ne?Ce-Ne:String(k.id).localeCompare(String(H.id))}),[ca,Io.clonedFields]),Mo=S.useMemo(()=>Vk(Cs.filter(k=>!k.parentId),Tr),[Cs,Tr]),Rc=S.useCallback((k,H)=>Mo.some(z=>Hk(k,H,z,Y)),[Mo,Y]);Mo.length===0||Math.max(...Mo.map(k=>(k[0]?.position?.order??0)+gs(k,Y).rowSpan));const ua=S.useMemo(()=>fT(Dt,Oc(kt.filter(k=>!k.parentId)),et),[Dt,kt,et]),{anchorsByOrigin:by,coveredCells:vy}=S.useMemo(()=>gT(ua,ca,et,Y),[ua,ca,et,Y]),{anchorsByOrigin:wy,coveredCells:Sy}=S.useMemo(()=>yT(On.map(k=>({addMoreFieldName:k.addMoreFieldName,blockIds:k.blockIds,linkedFields:k.linkedFields,templateFieldNames:k.templateFieldNames})),Dt,Io.clonedFields,la,Y,et,vy),[On,Dt,Io.clonedFields,la,Y,et,vy]),hn=S.useMemo(()=>AT(by,wy),[by,wy]),xy=S.useMemo(()=>Sy,[Sy]),Ay=String(Tt).endsWith("px")?Tt:In,Cy=S.useCallback((k,H)=>{for(let z=0;z<Y;z++){if(z>=H.anchorCol&&z<H.anchorCol+H.colSpan)continue;if(As[`${k}-${z}`]||hn.get(`${k}-${z}`)||vg(k,z,Cs,Tr).length>0||Rc(k,z))return!0}return!1},[Y,As,hn,Cs,Tr,Rc]),Ey=S.useMemo(()=>ST(hn,k=>{const H=k.run.section;return H.collapsible?oa(H,k.addMoreMeta?.blockId):!1},Cy),[hn,oa,Cy]),Ny=S.useMemo(()=>{const k=[];for(const H of Object.keys(As)){const z=Number(H.split("-")[0]);Number.isNaN(z)||k.push(z)}for(const H of hn.values())if(H.renderFields.some(z=>Tr(z)))for(let z=H.anchorRow;z<H.anchorRow+H.rowSpan;z++)k.push(z);return Wk(Mo,Y,k)},[Mo,Y,As,hn,Tr]),{originalToDisplayRow:fa,displayRowCount:mP,sortedOccupiedRows:hP}=S.useMemo(()=>{const k=Rk(Ny);return{originalToDisplayRow:k.originalToDisplay,displayRowCount:k.displayRowCount,sortedOccupiedRows:k.sortedOriginalRows}},[Ny]),_y=Math.max(mP,1),Gc=S.useCallback((k,H=1)=>Gk(k,H,fa),[fa]),ky=S.useMemo(()=>{const k=new Set;for(const H of Ey){const z=fa.get(H);z!==void 0&&k.add(z)}return k},[Ey,fa]),gP=S.useMemo(()=>xT(_y,Ay,ky),[_y,Ay,ky]),yP=S.useMemo(()=>CT(kt.filter(k=>!k.parentId&&Tr(k)),ua,et),[kt,ua,et,Tr]),pa=S.useCallback(k=>{if(F)return null;const H=et(k),z=V[H]||[];if(z.length===0)return null;const Z=mn(k);if(Z.length===0)return null;const Q=dT(k,Dt),le=Z.map(De=>et(De)).filter(Boolean),Ce=_g(le,Dt),Ne=(De,at,Ht,Le,Ve,we,Ae)=>{const He=et(De),rt=Gr(He,H,at),fe=De.hidden===!0;if(!(wt(De)&&(Ar(He)||!fe&&He)))return null;const ye={...De,id:`${De.id}__${at}`,name:rt},Wt=k.properties?.linkedFieldAllowDuplicate?.[He]??!0;let Bt;if(!Wt&&(De.type==="select"||De.type==="radio"||De.type==="multiselect")){const lt=[],vt=Oe[He];vt!=null&&vt!==""&&(Array.isArray(vt)?lt.push(...vt.map(jr=>String(jr))):lt.push(String(vt))),z.filter(jr=>jr!==at).forEach(jr=>{const Kr=Gr(He,H,jr),zr=Oe[Kr];zr!=null&&zr!==""&&(Array.isArray(zr)?lt.push(...zr.map(qr=>String(qr))):lt.push(String(zr)))}),lt.length>0&&(Bt=[...new Set(lt)])}return c.jsx("div",{"data-field-name":rt,"data-form-renderer":"field-wrapper",children:c.jsx(un,{field:ye,value:Oe[rt],error:pe[rt]||je>0?te[rt]:void 0,onChange:lt=>xt(rt,lt),onBlur:()=>ze(rt),disabled:de||!Vt(He)||er||!!De.disabled,readOnly:sr(He,!!De.readOnly),isRequired:pn(He),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:rt,buttonResponses:we,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:Ae,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,scopedFormValues:Ve,scopedFieldNameMap:Le,excludedOptionValues:Bt,hideTableRowControls:x})},ye.id)};return c.jsx("div",{className:"space-y-3 mt-3",children:z.map((De,at)=>{const Ht={},Le={};Z.forEach(Bt=>{const lt=et(Bt),vt=Gr(lt,H,De);Ht[vt]=lt,Le[vt]=Oe[vt]});const Ve=da(Ht),we=ia(H,De,Z,Oe),Ae=Q?.heading!=null?bs(Q,at+1):null,He=ne[`${H}__${De}`],rt=He!=null?{...tr,documentId:He}:tr,fe=Z.map(Bt=>Ne(Bt,De,at,Ht,Le,Ve,rt)).filter(Boolean),ye=Ce?.section?.collapsible===!0,dt=c.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:we,title:we?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:Bt=>{Bt.preventDefault(),Bt.stopPropagation(),aa(H,De)},children:c.jsx(Go,{className:"h-5 w-5","aria-hidden":!0})}),Wt=c.jsxs(c.Fragment,{children:[!ye&&c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Ae?c.jsx("p",{className:"text-sm font-medium text-foreground",children:Ae}):c.jsxs("p",{className:"text-xs text-muted-foreground",children:["Entry ",at+1]}),dt]}),fe]});return c.jsx("div",{className:"rounded-md border p-3 space-y-3",children:Ce?c.jsx(kc,{legend:Ce.section.heading?.enabled?bs(Ce.section,at+1):Ce.section.name,collapsible:Ce.section.collapsible,defaultCollapsed:Ce.section.defaultCollapsed,headerActions:ye?dt:void 0,onCollapsedChange:Bt=>Wc(Ce.section.id,De,Bt),children:Wt}):Wt},`${k.id}-${De}`)})})},[F,V,ne,et,mn,Gr,ia,Oe,pe,je,te,xt,ze,Vt,er,pn,Br,$e,_r,Nr,At,Dr,We,j,m,tr,br,qt,q.fields,be,Ar,wt,da,aa,x,Dt,oe,ee,M]);return c.jsx("div",{className:_?B("relative",d):B(ga,P&&"dark",d),style:xs,"data-form-renderer":_?void 0:"root",children:c.jsxs("div",{className:"relative",children:[M&&c.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:c.jsx(Pn,{})}),c.jsx("form",{onSubmit:Nr,className:f?B("w-full min-w-0"):B("space-y-6 pb-[100px] w-full min-w-0",ea[Zi]),"data-form-renderer":"form","data-form-renderer-layout":F?"grid":"stack",children:c.jsxs(AN,{value:ta,children:[Er&&q.steps&&c.jsx(Ok,{steps:q.steps,currentStep:Te,completedSteps:Ue,onStepClick:ur}),c.jsx(_a.Provider,{value:{gridStretch:F},children:F?c.jsx("div",{className:f?"w-full min-w-0":"grid w-full min-w-0",style:{display:"grid",gridTemplateRows:gP,gridTemplateColumns:`repeat(${Y}, 1fr)`,rowGap:he,columnGap:st},"data-form-renderer":"grid",children:hP.map(k=>Array.from({length:Y},(H,z)=>{const Z=Gc(k);if(!Z)return null;if(Rc(k,z))return c.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:z+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${k}-${z}`);if(bT(k,z,xy,hn)){const we=vT(k,z,hn);return we&&wT(k,z,we,oa(we.run.section,we.addMoreMeta?.blockId))?null:c.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:z+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`section-border-cover-${k}-${z}`)}const Q=hn.get(`${k}-${z}`);if(Q){const we=Q.renderFields.filter(lt=>Tr(lt));if(we.length===0)return null;const Ae=Q.addMoreMeta,He=Ae!=null?On.find(lt=>lt.addMoreFieldName===Ae.addMoreFieldName)?.linkedFields??[]:[],rt=Ae!=null?ia(Ae.addMoreFieldName,Ae.blockId,He,Oe):!1,fe=Q.run.section,Fe=Ae?.blockId,ye=oa(fe,Fe),dt=fe.collapsible&&ye?1:Q.rowSpan,Wt=Gc(Q.anchorRow,dt)??Z,Bt=Ae!=null?c.jsx("button",{type:"button",className:B("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",f&&"text-red-600 hover:bg-red-500/10"),disabled:rt,title:rt?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:lt=>{lt.preventDefault(),lt.stopPropagation(),aa(Ae.addMoreFieldName,Ae.blockId)},children:c.jsx(Go,{className:"h-5 w-5","aria-hidden":!0})}):void 0;return c.jsx("div",{className:B("min-h-0 min-w-0",!(fe.collapsible&&ye)&&"self-stretch"),style:{gridRow:Wt,gridColumn:`${z+1} / span ${Q.colSpan}`},"data-form-renderer":"grid-cell","data-form-renderer-config-section-border-cell":!0,children:c.jsx(kc,{legend:Q.legend,className:fe.collapsible&&ye?void 0:"h-full",collapsible:fe.collapsible,defaultCollapsed:fe.defaultCollapsed,headerActions:Bt,onCollapsedChange:lt=>Wc(fe.id,Fe,lt),children:c.jsx("div",{className:"grid w-full min-w-0",style:{gridTemplateColumns:`repeat(${Y}, 1fr)`,gridTemplateRows:`repeat(${Q.rowSpan}, minmax(${String(Tt).endsWith("px")?Tt:In}, auto))`,rowGap:he,columnGap:st},children:we.map(lt=>{const vt=et(lt),rr=Io.scopeByFieldName[vt],jr=rr?.scopedFieldNameMap?.[vt]||vt,Kr=(lt.position?.order??Q.anchorRow)-Q.anchorRow,zr=lt.position?.column??1,{rowSpan:qr,columnSpan:se}=gs([lt],Y),Ie=Ae!=null?ne[`${Ae.addMoreFieldName}__${Ae.blockId}`]:void 0,me=Ie!=null?{...tr,documentId:Ie}:tr;return c.jsx("div",{"data-field-name":vt,"data-form-renderer":"field-wrapper",className:"min-h-0 min-w-0",style:{gridRow:`${Kr+1} / span ${qr}`,gridColumn:`${zr} / span ${se}`,...xn(lt)},children:c.jsx(un,{field:Qn(lt),value:Oe[vt],error:pe[vt]||je>0?te[vt]:void 0,onChange:Ke=>xt(vt,Ke),onBlur:()=>ze(vt),disabled:(lt.type==="table"||lt.type==="billingGrid")&&a==="fill"?!1:de||!Vt(jr)||er||!!lt.disabled,readOnly:(lt.type==="table"||lt.type==="billingGrid")&&a==="fill"?!1:sr(jr,!!lt.readOnly),isRequired:pn(jr),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:vt,buttonResponses:rr?.scopedButtonResponses??$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:me,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,scopedFormValues:rr?.scopedFormValues,scopedFieldNameMap:rr?.scopedFieldNameMap,excludedOptionValues:rr?.excludedOptionValues,hideTableRowControls:x})},lt.id)})})})},`section-border-${Q.run.section.id}-${k}-${z}-${Ae?.blockId??"base"}`)}const le=vg(k,z,Cs,Tr).filter(we=>!(et(we)?.includes("__addmore__")&&xy.has(`${k}-${z}`)));if(le.length===0){const we=As[`${k}-${z}`];if(we){const Ae=q.fields.find(fe=>fe.type==="addmore"&&et(fe)===we.addMoreFieldName),He=Ae!=null?mn(Ae):[],rt=ia(we.addMoreFieldName,we.blockId,He,Oe);return c.jsx("div",{className:"min-h-0 min-w-0 flex flex-col items-center justify-center",style:{gridRow:Z,gridColumn:z+1},"data-form-renderer":"grid-cell","data-form-renderer-add-more-remove":!0,children:c.jsx("button",{type:"button",className:B("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",f&&"text-red-600 hover:bg-red-500/10"),disabled:rt,title:rt?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:fe=>{fe.preventDefault(),fe.stopPropagation(),aa(we.addMoreFieldName,we.blockId)},children:c.jsx(Go,{className:"h-5 w-5","aria-hidden":!0})})},`add-more-remove-${k}-${z}`)}return c.jsx("div",{className:"min-w-0",style:{pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${k}-${z}`)}const Ce=le[0],{rowSpan:Ne,columnSpan:De}=gs(le,Y),at=Gc(k,Ne)??Z;if(le.length===1&&Ce.type==="section"){const we=q.fields.filter(Ae=>Ae.parentId===Ce.id&&Ae.position!=null).sort((Ae,He)=>{const rt=typeof Ae.position?.order=="number"?Ae.position.order:0,fe=typeof He.position?.order=="number"?He.position.order:0;return rt-fe});return c.jsx("div",{className:"min-w-0 min-h-0 w-full overflow-hidden flex flex-col h-full",style:{gridRow:at,gridColumn:`${z+1} / span ${De}`,...xn(Ce)},"data-form-renderer":"grid-cell",children:c.jsx(Hh,{field:Ce,children:we.map(Ae=>{const He=Ae.name||Ae.key||Ae.id,rt=Ae.hidden===!0;return wt(Ae)&&(Ar(He)||!rt&&He)?c.jsx("div",{"data-field-name":He,"data-form-renderer":"field-wrapper",children:c.jsx(un,{field:Qn(Ae),value:Oe[He],error:pe[He]||je>0?te[He]:void 0,onChange:Fe=>xt(He,Fe),onBlur:()=>ze(He),disabled:de||!Vt(He)||er||!!Ae.disabled,readOnly:sr(He,!!Ae.readOnly),isRequired:pn(He),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:He,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x})},Ae.id):null})})},Ce.id)}const Ht=yg(le),Le=le.some(we=>["file","camera","photoChoice","addmore","table","billingGrid"].includes(we.type)),Ve=c.jsx("div",{className:B("flex min-h-0 w-full flex-1 gap-3",Ht==="row"?"flex-row items-stretch":"flex-col items-stretch"),children:le.map(we=>{const Ae=we.name||we.key||we.id,He=we.type==="sectionHeading",rt=Io.scopeByFieldName[Ae],fe=rt?.scopedFieldNameMap?.[Ae]||Ae,Fe=rt?.blockDocumentId!=null?{...tr,documentId:rt.blockDocumentId}:tr,ye=we.appearance?.hideLabel??we.properties?.hideLabel??!1,dt=we.type==="table"||we.type==="billingGrid"?we.properties?.minWidth:void 0;return c.jsx("div",{"data-field-name":Ae,"data-form-renderer":"field-wrapper",className:B("flex min-h-0 min-w-0 flex-1 flex-col",jo(we),He&&"items-center justify-center",ye&&"items-center"),style:{...dt?{minWidth:dt}:{},...xn(we)},children:c.jsx(un,{field:Qn(we),value:Oe[Ae],error:pe[Ae]||je>0?te[Ae]:void 0,onChange:Wt=>xt(Ae,Wt),onBlur:()=>ze(Ae),disabled:(we.type==="table"||we.type==="billingGrid")&&a==="fill"?!1:de||!Vt(fe)||er||!!we.disabled,readOnly:(we.type==="table"||we.type==="billingGrid")&&a==="fill"?!1:sr(fe,!!we.readOnly),isRequired:pn(fe),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:Ae,buttonResponses:rt?.scopedButtonResponses??$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:Fe,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,scopedFormValues:rt?.scopedFormValues,scopedFieldNameMap:rt?.scopedFieldNameMap,excludedOptionValues:rt?.excludedOptionValues,hideTableRowControls:x})},we.id)})});return c.jsx("div",{className:B(wd(le),"self-stretch",Le?"overflow-visible":"overflow-hidden"),style:{gridRow:at,gridColumn:`${z+1} / span ${De}`,...xn(le[0])},"data-form-renderer":"grid-cell","data-field-name":le.map(we=>we.name||we.key||we.id).join(","),children:Ve},le.map(we=>we.id).join("-"))}))}):c.jsx("div",{className:f?"":"space-y-4","data-form-renderer":"stack",children:kt.map(k=>{if(!Tr(k))return null;const H=yP.find(Z=>Z.kind==="border"&&Z.fields.some(Q=>Q.id===k.id));if(H)return H.fields[0]?.id!==k.id?null:c.jsx(kc,{legend:bs(H.run.section,0),collapsible:H.run.section.collapsible,defaultCollapsed:H.run.section.defaultCollapsed,onCollapsedChange:Z=>Wc(H.run.section.id,void 0,Z),children:H.fields.map(Z=>{const Q=et(Z);return!Q||!Tr(Z)?null:c.jsxs("div",{"data-field-name":Q,"data-form-renderer":"field-wrapper",style:xn(Z),children:[c.jsx(un,{field:Qn(Z),value:Oe[Q],error:pe[Q]||je>0?te[Q]:void 0,onChange:le=>xt(Q,le),onBlur:()=>ze(Q),disabled:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:de||!Vt(Q)||er||!!Z.disabled,readOnly:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:sr(Q,!!Z.readOnly),isRequired:pn(Q),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:Q,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),Z.type==="addmore"&&pa(Z)]},Z.id)})},`stack-border-${H.run.section.id}-${k.id}`);if(!k.parentId){const Z=kt.filter(le=>!le.parentId&&Tr(le)&&qi(le)===qi(k)),Q=Tc(Z).slice(0,2);if(Q.length>1&&Q[0].id!==k.id)return null;if(Q.length>1){const le=yg(Q);return c.jsx("div",{"data-form-renderer":"shared-cell-stack",className:B("flex w-full min-w-0 gap-3",le==="row"?"flex-row items-stretch":"flex-col"),children:Q.map(Ce=>{const Ne=Ce.name||Ce.key||Ce.id;return c.jsxs("div",{"data-field-name":Ne,"data-form-renderer":"field-wrapper",className:B("min-w-0 flex-1 flex flex-col",jo(Ce)),style:xn(Ce),children:[c.jsx(un,{field:Qn(Ce),value:Oe[Ne],error:pe[Ne]||je>0?te[Ne]:void 0,onChange:De=>xt(Ne,De),onBlur:()=>ze(Ne),disabled:(Ce.type==="table"||Ce.type==="billingGrid")&&a==="fill"?!1:de||!Vt(Ne)||er||!!Ce.disabled,readOnly:(Ce.type==="table"||Ce.type==="billingGrid")&&a==="fill"?!1:sr(Ne,!!Ce.readOnly),isRequired:pn(Ne),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:Ne,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),Ce.type==="addmore"&&pa(Ce)]},Ce.id)})},Q.map(Ce=>Ce.id).join("-"))}}if(k.type==="section"){const Z=q.fields.filter(Q=>Q.parentId===k.id&&Q.position!=null).sort((Q,le)=>{const Ce=typeof Q.position?.order=="number"?Q.position.order:0,Ne=typeof le.position?.order=="number"?le.position.order:0;return Ce-Ne});return c.jsx(Hh,{field:k,children:Z.map(Q=>{const le=Q.name||Q.key||Q.id,Ce=Q.hidden===!0;return wt(Q)&&(Ar(le)||!Ce&&le)?c.jsxs("div",{"data-field-name":le,"data-form-renderer":"field-wrapper",style:xn(Q),children:[c.jsx(un,{field:Qn(Q),value:Oe[le],error:pe[le]||je>0?te[le]:void 0,onChange:De=>xt(le,De),onBlur:()=>ze(le),disabled:de||!Vt(le)||er||!!Q.disabled,readOnly:sr(le,!!Q.readOnly),isRequired:pn(le),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:le,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),Q.type==="addmore"&&pa(Q)]},Q.id):null})},k.id)}const z=k.name||k.key||k.id;return c.jsxs("div",{"data-field-name":z,"data-form-renderer":"field-wrapper",style:xn(k),children:[c.jsx(un,{field:Qn(k),value:Oe[z],error:pe[z]||je>0?te[z]:void 0,onChange:Z=>xt(z,Z),onBlur:()=>ze(z),disabled:(k.type==="table"||k.type==="billingGrid")&&a==="fill"?!1:de||!Vt(z)||er||!!k.disabled,readOnly:(k.type==="table"||k.type==="billingGrid")&&a==="fill"?!1:sr(z,!!k.readOnly),isRequired:pn(z),formValues:Oe,submissionContext:Br,prepopulateMappedFieldNames:$e,urlParams:oe,prepopulateResponse:ee,prepopulateLoading:M,formSections:Dt,submitPayload:q.config?.submitPayload,fieldValueKey:z,buttonResponses:$,onButtonApiResponse:_r,onSubmit:Nr,onReset:At,onCancel:Dr,isSubmitting:We,bffSubmitApi:j,onBffSubmitResult:m,extraSubmitPayload:tr,onValidateForm:br,getValidationErrors:qt,allFields:q.fields,onSubmittingChange:be,onAddMore:Zn,hideTableRowControls:x}),k.type==="addmore"&&pa(k)]},k.id)})})}),u]})})]})})};function Lc(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Mg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function kT(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,f)=>{if(!l||typeof l!="object")return null;const p={...l};if(l.fieldType&&!p.type&&(p.type=l.fieldType),l.fieldKey&&!p.key&&!p.name&&(p.key=l.fieldKey,p.name=l.fieldKey),typeof l.positionOrder=="number"&&!isNaN(l.positionOrder)?p.order=l.positionOrder:p.order=f,(typeof p.order!="number"||isNaN(p.order))&&(p.order=f),l.options&&typeof l.options=="string")try{p.options=JSON.parse(l.options)}catch{}if(l.metadata&&typeof l.metadata=="string")try{p.metadata=JSON.parse(l.metadata)}catch{}return p}).filter(l=>l!=null).sort((l,f)=>{const p=typeof l.order=="number"?l.order:0,m=typeof f.order=="number"?f.order:0;return p-m});n.forEach((l,f)=>{(!l||typeof l.order!="number"||isNaN(l.order))&&(l.order=f)});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 d=l=>{let f={...l};if(l.conditionExpression&&typeof l.conditionExpression=="string")try{f={...l,conditionExpression:JSON.parse(l.conditionExpression)}}catch{}if(f.targetFieldId){const p=s.find(m=>m._id===f.targetFieldId||m.id===f.targetFieldId||m.fieldKey===f.targetFieldId);if(p){const m=p.key||p.fieldKey||p.name,g=p._id||p.id||f.targetFieldId;f.targetFieldKey=m,f.targetField=m,f.targetFieldById=g}}return f},u={id:r._id,name:r.name,description:r.description??"",version:r.version,status:r.status,fields:s.map((l,f)=>{const p=l,m=typeof l.metadata=="object"&&l.metadata!==null?l.metadata:{},g=m.hidden===!0||l.hidden===!0,h={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(g&&(h.hidden=!0),h.id||(h.id=h.key||h.name),h.key||(h.key=h.id||h.name),h.name||(h.name=h.key||h.id),l.isRequired!==void 0&&(h.required=l.isRequired),l.placeholder&&(h.placeholder=l.placeholder),l.options&&Array.isArray(l.options)&&(h.options=l.options),l.apidata&&(h.apidata=l.apidata),p.appearance&&typeof p.appearance=="object"&&!Array.isArray(p.appearance)&&Object.keys(p.appearance).length>0&&(h.appearance=Lc(p.appearance)),p.ui!==void 0&&(h.ui=Lc(p.ui)),p.visibility!==void 0&&(h.visibility=Lc(p.visibility)),m.disabled!==void 0&&(h.disabled=m.disabled),m.readOnly!==void 0&&(h.readOnly=m.readOnly),m.hideLabel!==void 0&&(h.hideLabel=m.hideLabel,h.properties||(h.properties={}),h.properties.hideLabel=m.hideLabel,h.appearance||(h.appearance={}),h.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 A=l.validationRules,I={...m};if(A.fileSize!==void 0&&(I.maxSize=A.fileSize),A.fileType&&Array.isArray(A.fileType)){const T=[];A.fileType.forEach(W=>{const X=W.startsWith(".")?W:`.${W}`;T.push(X),X===".csv"?T.push("text/csv"):X===".xls"?T.push("application/vnd.ms-excel"):X===".xlsx"&&T.push("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}),I.accept=T}h.metadata=I,I.maxSize!==void 0&&(h.maxSize=I.maxSize),I.accept!==void 0&&(h.accept=I.accept)}else if(m&&Object.keys(m).length>0){if(h.metadata=m,(l.type==="toggle"||l.fieldType==="toggle")&&(m.onValue!==void 0&&(h.onValue=m.onValue),m.offValue!==void 0&&(h.offValue=m.offValue),m.onText!==void 0&&(h.onText=m.onText),m.offText!==void 0&&(h.offText=m.offText)),(l.type==="button"||l.fieldType==="button")&&m.action==="download"&&m.downloadApiEndpoint&&typeof m.downloadApiEndpoint=="string"){let A=m.downloadApiEndpoint;A=A.replace(/\{ctx:([^}]+)\}/g,(I,T)=>{const W=t[T];return W!==void 0?String(W):I}),m.downloadApiEndpoint=A,h.metadata=m,h.downloadApiEndpoint=A}if((l.type==="button"||l.fieldType==="button")&&m.action==="submit"){const A=h.properties||{};m.submitAction!==void 0&&(A.submitAction=m.submitAction),m.submitApiMethod!==void 0&&(A.submitApiMethod=m.submitApiMethod),m.apiBodyStructure!==void 0&&(A.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(A.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(A.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiBodyFields!==void 0&&(A.apiBodyFields=m.apiBodyFields),m.buttonText!==void 0&&(A.buttonText=m.buttonText),m.action!==void 0&&(A.action=m.action),m.variant!==void 0&&(A.variant=m.variant),m.hideLabel!==void 0&&(A.hideLabel=m.hideLabel),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint&&(A.apiEndpoint=l.apidata.apiEndpoint),h.properties=A}if((l.type==="button"||l.fieldType==="button")&&(m.action==="upload"||m.action==="custom")){const A=h.properties||{};m.action!==void 0&&(A.action=m.action),m.buttonText!==void 0&&(A.buttonText=m.buttonText),m.variant!==void 0&&(A.variant=m.variant),m.hideLabel!==void 0&&(A.hideLabel=m.hideLabel),m.uploadAction!==void 0&&(A.uploadAction=m.uploadAction),m.uploadApiEndpoint!==void 0&&(A.uploadApiEndpoint=m.uploadApiEndpoint),m.uploadApiMethod!==void 0&&(A.uploadApiMethod=m.uploadApiMethod),m.apiBodyStructure!==void 0&&(A.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(A.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(A.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiFieldMapping!==void 0&&(A.apiFieldMapping=m.apiFieldMapping),m.apiQueryParams!==void 0&&(A.apiQueryParams=m.apiQueryParams),m.apiBodyFields!==void 0&&(A.apiBodyFields=m.apiBodyFields),m.apiHeaders!==void 0&&(A.apiHeaders=m.apiHeaders),h.properties=A}if(l.type==="status"||l.fieldType==="status"){const A=h.properties||{};if(m.source!==void 0&&(A.source=m.source),m.statuses!==void 0&&(A.statuses=m.statuses),m.dataPath!==void 0&&(A.dataPath=m.dataPath),m.showStatusText!==void 0&&(A.showStatusText=m.showStatusText),m.statusTextPath!==void 0&&(A.statusTextPath=m.statusTextPath),m.showCurrentIndicator!==void 0&&(A.showCurrentIndicator=m.showCurrentIndicator),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint){let I=l.apidata.apiEndpoint;I=I.replace(/\{ctx:([^}]+)\}/g,(T,W)=>{const X=t[W];return X!==void 0?String(X):T}),A.apiEndpoint=I,A.source===void 0&&(A.source="api")}l.apidata?.apiMethod!==void 0&&(A.apiMethod=l.apidata.apiMethod),h.properties=A}if(l.type==="addmore"||l.fieldType==="addmore"){const A=h.properties||{};m.linkedFieldNames!==void 0&&(A.linkedFieldNames=m.linkedFieldNames),m.linkedSectionIds!==void 0&&(A.linkedSectionIds=m.linkedSectionIds),m.linkedFieldAllowDuplicate!==void 0&&(A.linkedFieldAllowDuplicate=m.linkedFieldAllowDuplicate),m.buttonText!==void 0&&(A.buttonText=m.buttonText),m.variant!==void 0&&(A.variant=m.variant),m.size!==void 0&&(A.size=m.size),m.hideLabel!==void 0&&(A.hideLabel=m.hideLabel),h.properties=A}if(l.type==="selectablelist"||l.fieldType==="selectablelist"){const A=h.properties||{};m.submitFieldMapping!==void 0&&(A.submitFieldMapping=m.submitFieldMapping),m.displayFields!==void 0&&(A.displayFields=m.displayFields),m.displayFieldsSeparator!==void 0&&(A.displayFieldsSeparator=m.displayFieldsSeparator),m.dataSourceContextKey!==void 0&&(A.dataSourceContextKey=m.dataSourceContextKey),m.showSelectAll!==void 0&&(A.showSelectAll=m.showSelectAll),m.selectAllByDefault!==void 0&&(A.selectAllByDefault=m.selectAllByDefault),h.properties=A}}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"&&(h.validationRules=l.validationRules),typeof l.order=="number"&&(h.order=l.order);const y=l,w=Mg(y.position),v=l.metadata&&typeof l.metadata=="object"&&!Array.isArray(l.metadata)?l.metadata:{},x=Mg(y.layout),P={order:typeof y.positionOrder=="number"?y.positionOrder:l.order??f,column:typeof w.column=="number"?w.column:typeof y.positionColumn=="number"?y.positionColumn:1,columnSpan:typeof w.columnSpan=="number"?w.columnSpan:typeof w.width=="number"?w.width:typeof y.positionWidth=="number"?y.positionWidth:1,rowSpan:typeof w.rowSpan=="number"?w.rowSpan:typeof y.positionRowSpan=="number"?y.positionRowSpan:1},_=ko(w,{cellSlotIndex:y.cellSlotIndex??x.cellSlotIndex,stackSlot:v.stackSlot??x.stackSlot});typeof _=="number"&&(P.cellSlot=_);const N=w.cellGroupId??x.cellGroupId;typeof N=="string"&&(P.cellGroupId=N);const C=hs(w)??hs(x)??(v.stackDirection==="horizontal"||x.stackDirection==="horizontal"?"row":v.stackDirection==="vertical"||x.stackDirection==="vertical"?"stack":void 0);return(C==="row"||C==="stack")&&(P.sharedCellLayout=C),h.position=P,l.conditions&&Array.isArray(l.conditions)&&(h.conditions=l.conditions),h}).filter(l=>l!=null).sort((l,f)=>{const p=typeof l.order=="number"?l.order:0,m=typeof f.order=="number"?f.order:0;return p-m}),config:{...i,layout:o,...r.rules&&r.rules.length>0&&{rules:r.rules.map(d)},...r.clientMapping&&Object.keys(r.clientMapping).length>0&&{clientMapping:r.clientMapping}},...r.rules&&r.rules.length>0&&{rules:r.rules.map(d)},createdAt:"",updatedAt:"",moduleId:""};return Yi(u)}var Xi="Tabs",[TT]=vr(Xi,[Li]),Lg=Li(),[FT,Dc]=TT(Xi),Dg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:a,activationMode:d="automatic",...u}=e,l=ro(a),[f,p]=Zr({prop:n,onChange:o,defaultProp:s??"",caller:Xi});return c.jsx(FT,{scope:r,baseId:on(),value:f,onValueChange:p,orientation:i,dir:l,activationMode:d,children:c.jsx(Be.div,{dir:l,"data-orientation":i,...u,ref:t})})});Dg.displayName=Xi;var Bg="TabsList",$g=b.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...o}=e,s=Dc(Bg,r),i=Lg(r);return c.jsx(Om,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:n,children:c.jsx(Be.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});$g.displayName=Bg;var jg="TabsTrigger",zg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:o=!1,...s}=e,i=Dc(jg,r),a=Lg(r),d=Hg(i.baseId,n),u=Wg(i.baseId,n),l=n===i.value;return c.jsx(Im,{asChild:!0,...a,focusable:!o,active:l,children:c.jsx(Be.button,{type:"button",role:"tab","aria-selected":l,"aria-controls":u,"data-state":l?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...s,ref:t,onMouseDown:Me(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?i.onValueChange(n):f.preventDefault()}),onKeyDown:Me(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&i.onValueChange(n)}),onFocus:Me(e.onFocus,()=>{const f=i.activationMode!=="manual";!l&&!o&&f&&i.onValueChange(n)})})})});zg.displayName=jg;var Ug="TabsContent",Vg=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:o,children:s,...i}=e,a=Dc(Ug,r),d=Hg(a.baseId,n),u=Wg(a.baseId,n),l=n===a.value,f=b.useRef(l);return b.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),c.jsx(xr,{present:o||l,children:({present:p})=>c.jsx(Be.div,{"data-state":l?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":d,hidden:!p,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:p&&s})})});Vg.displayName=Ug;function Hg(e,t){return`${e}-trigger-${t}`}function Wg(e,t){return`${e}-content-${t}`}var PT=Dg,OT=$g,IT=zg,MT=Vg;function Rg({className:e,...t}){return c.jsx(PT,{"data-slot":"tabs",className:B("flex flex-col gap-2",e),...t})}function Gg({className:e,...t}){return c.jsx(OT,{"data-slot":"tabs-list",className:B("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function Kg({className:e,...t}){return c.jsx(IT,{"data-slot":"tabs-trigger",className:B("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 qg({className:e,...t}){return c.jsx(MT,{"data-slot":"tabs-content",className:B("flex-1 outline-none",e),...t})}function dr({className:e="",...t}){return c.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 LT({className:e=""}){return c.jsxs("div",{className:`flex flex-col gap-4 ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:[c.jsxs("div",{className:"flex w-full border-b border-neutral-200 dark:border-neutral-700 gap-0",children:[c.jsx(dr,{className:"h-10 w-24 rounded-none"}),c.jsx(dr,{className:"h-10 w-28 rounded-none ml-1"}),c.jsx(dr,{className:"h-10 w-20 rounded-none ml-1"})]}),c.jsxs("div",{className:"mt-4 flex flex-col gap-4 py-4",children:[c.jsx(dr,{className:"h-4 w-32"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-40"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-36"}),c.jsx(dr,{className:"h-24 w-full"})]})]})}function DT(){return c.jsxs("div",{className:"flex flex-col gap-4 py-4","data-form-renderer":"form-loading-skeleton",children:[c.jsx(dr,{className:"h-4 w-28"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-36"}),c.jsx(dr,{className:"h-10 w-full"}),c.jsx(dr,{className:"h-4 w-24"}),c.jsx(dr,{className:"h-20 w-full"})]})}const BT=3e4,$T=10*6e4,jT=9e4,zT=15*6e4;function UT(e){return e!=null&&"on_success"in e&&e.on_success!=null}function VT(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 Yg=({getWorkflowState:e,moduleId:t,tenantId:r,submissionContext:n,initialValues:o={},getAuthHeaders:s,onSuccess:i,bootstrapFeatureId:a,subjectUserId:d,viewStepId:u,clientId:l,className:f,onWorkflowSubmitResult:p,viewerContext:m,getViewerContext:g,dark:h=!1,themeVars:y})=>{const w=gn.useQueryClient(),v=S.useMemo(()=>[d??"",u??"",l??""],[d,u,l]),x=S.useMemo(()=>({moduleId:t,tenantId:r,subjectUserId:d,viewStepId:u,clientId:l}),[t,r,d,u,l]),[E,P]=S.useState([]),[_,N]=S.useState(null),[C,A]=S.useState(null),[I,T]=S.useState(null),[W,X]=S.useState({}),O=S.useRef(null),j=S.useRef(null),M=S.useRef(null),D=S.useRef(null),L=S.useMemo(()=>E&&Array.isArray(E)?E.filter(ae=>ae.feature_id):[],[E]),U=gn.useQuery({queryKey:["workflow-steps",t,a??"",r??"",v[0],v[1],v[2]],queryFn:()=>e({...x,featureId:a}),staleTime:BT,gcTime:$T}),$=U.isPending,ie=U.error?U.error instanceof Error?U.error.message:"Failed to load workflow steps":null;S.useEffect(()=>{const ae=U.data;if(!ae||E.length>0)return;const ve=ae.steps&&Array.isArray(ae.steps)?ae.steps:[];P(ve);const Ye=ve.filter(ct=>ct.feature_id);if(Ye.length>0){const ct=ae.current_step_id,Ge=ct&&Ye.some(Kt=>Kt.step_id===ct);N(Ge?ct:Ye[0].step_id)}},[U.data,E.length,a]);const V=S.useMemo(()=>{if(!_)return;const ae=E.find(Ye=>Ye.step_id===_),ve=O.current===_;return ae?.feature_id??(ve?D.current:void 0)??void 0},[_,E]),K=gn.useQuery({queryKey:["workflow-step",t,V??"",r??"",v[0],v[1],v[2]],queryFn:()=>e({...x,featureId:V}),enabled:!!V,staleTime:jT,gcTime:zT,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),J=K.isPending,ce=K.error?K.error instanceof Error?K.error.message:"Failed to load form":null;S.useEffect(()=>{!K.data||O.current===_||(A(K.data),T(null),O.current=null,D.current=null)},[K.data,_]),S.useEffect(()=>{T(ce)},[ce]),S.useEffect(()=>{V===void 0&&O.current!==_&&(A(null),T(null),O.current=null,D.current=null)},[V,_]);const ne=S.useMemo(()=>{const ae=C?.form;if(!ae)return null;const ve=(r??Tn()??"").trim()||"default",Ye=Pg({scope:ve,formId:ae._id,version:ae.version});return Ye?.value?Ye.value:kT(C,n)},[C,n,r]),G=S.useMemo(()=>{const ae=C?.BFF_submit_api;if(!ae?.url)return;let ve=ae.url;if(ve.startsWith("http://")||ve.startsWith("https://"))try{const Ge=new URL(ve);ve=Ge.pathname+Ge.search}catch{}const Ye=s?.()??{},ct={...ae.headers||{},"Content-Type":"application/json",...Ye};return{...ae,url:ve,headers:ct}},[C?.BFF_submit_api,s]),ee=S.useMemo(()=>ne?{...ne,status:"published",...G&&{BFF_submit_api:G}}:null,[ne,G]);S.useEffect(()=>{if(!ne?.id)return;const ae=(r??Tn()??"").trim()||"default";Og({scope:ae,formId:ne.id,version:ne.version},ne)},[ne,r]);const Pe=S.useMemo(()=>{if(!ne)return null;const ae=_s({config:ne.config,layout:ne.layout},null);if(!ae)return null;const ve=ae.rows,Ye=ae.columns,ct={verticalSpacing:ae.verticalSpacing??ae.spacing??"16px",horizontalSpacing:ae.horizontalSpacing??ae.spacing??"16px",rowHeight:ae.rowHeight??In};let Ge=1;if(Array.isArray(ne.fields))for(const Je of ne.fields){const q=Je?.position,$e=typeof q?.order=="number"?q.order:0,gt=typeof q?.rowSpan=="number"?q.rowSpan:1;Ge=Math.max(Ge,$e+gt)}return{rows:Math.min(ve,Math.max(1,Ge)),columns:Ye,verticalSpacing:ct.verticalSpacing,horizontalSpacing:ct.horizontalSpacing,rowHeight:ct.rowHeight}},[ne]),oe=S.useMemo(()=>{const ve=ee?.config?.theme?.cssVariables;if(!(!ve&&!y))return{...ve??{},...y??{}}},[ee?.config,y]),re=S.useCallback(()=>{w.invalidateQueries({queryKey:["workflow-steps",t]}),w.invalidateQueries({queryKey:["workflow-step",t]})},[w,t]),be=S.useCallback(ae=>{if(UT(ae)){const Ge=ae.on_success,Kt=Ge?.action;if(Kt==="redirect"&&Ge?.redirect_url){const Je=VT(Ge.redirect_url.trim(),n);window.location.href=Je;return}if(Kt==="move"){const Je=Ge?.next_step_id,q=Ge?.next_step_form;if(Je&&q){O.current=null,D.current=null;const $e=q.featureId??Ge?.next_step_form_id??q._id;w.removeQueries({queryKey:["workflow-step",t,$e,r??"",v[0],v[1],v[2]]}),re(),P(gt=>gt.some(te=>te.step_id===Je)?gt:[...gt,{step_id:Je,step_name:q.name||"Next step",feature_id:$e}]),A(null),N(Je),i?.();return}return}if(Kt==="stay"){re(),i?.();return}}const ve=ae;ve.steps&&Array.isArray(ve.steps)&&P(ve.steps);const Ye=(ve.steps&&Array.isArray(ve.steps)?ve.steps:E).filter(Ge=>Ge.feature_id),ct=ve.current_step_id;ct&&Ye.some(Ge=>Ge.step_id===ct)?N(ct):Ye.length>0&&N(Ye[0].step_id),A(null),re(),i?.(),p?.(ve)},[w,t,r,i,p,E,n,v,re]),de=S.useCallback(async ae=>C?.BFF_submit_api?(i?.(),{success:!0,message:"Saved successfully"}):{success:!1,message:"Submit not configured"},[C?.BFF_submit_api,i]),ot=S.useCallback((ae,ve)=>{},[]),Se=S.useCallback(ae=>{},[]);if($)return c.jsx(LT,{className:f});if(ie)return c.jsx("div",{className:B("rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",f),children:ie});if(L.length===0)return c.jsx("div",{className:B("py-12 text-center text-sm text-muted-foreground",f),children:"No workflow steps configured."});const xe=C?.step_blocked_message;return c.jsx("div",{className:B(ga,h&&"dark","flex flex-col gap-4",f),style:oe,"data-form-renderer":"workflow-steps-view",children:c.jsxs(Rg,{value:_??"",onValueChange:ae=>N(ae),children:[c.jsx(Gg,{className:"w-full justify-start border-b rounded-none h-auto p-0 bg-transparent gap-0","data-form-renderer":"workflow-tabs",children:L.map(ae=>c.jsx(Kg,{value:ae.step_id,className:"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none","data-form-renderer":"workflow-tab",children:ae.step_name},ae.step_id))}),L.map(ae=>c.jsx(qg,{value:ae.step_id,className:"mt-4 outline-none",children:ae.step_id!==_?null:J?c.jsx(DT,{}):I?c.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:I}):xe&&!C?.form?c.jsx("div",{className:B("rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",f),"data-form-renderer":"workflow-step-blocked",children:xe}):ee?.fields?.length?c.jsxs("div",{className:"py-4 [&_*]:box-border",children:[xe?c.jsx("div",{className:B("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 ve=j.current!==_||M.current!==(ee?.id??null);if(_&&ee&&ve){j.current=_,M.current=ee.id??null;const Ye=Nt.getState();Ye.setSchema(ee,{forceReset:!0});const ct=Nt.getState().values;Ye.setValues({...ct,...o})}return null})(),c.jsx(Mc,{schema:ee,gridLayout:Pe,omitRootWrapper:!0,submissionContext:n,initialValues:o,workflowStepId:_??void 0,viewerContext:m,getViewerContext:g,onSubmit:de,onChange:ot,onValidationError:Se,onClose:()=>{},mode:"fill",unstyled:!0,onWorkflowSubmitResult:be,initialExtraSubmitPayload:Object.keys(W).length>0?W:void 0,onExtraSubmitPayloadChange:ve=>{if(ve&&typeof ve=="object"){const Ye={};ve.context_user_id!=null&&(Ye.context_user_id=ve.context_user_id),ve.id!=null&&(Ye.id=ve.id),ve.batch_id!=null&&(Ye.batch_id=ve.batch_id),ve.admission_batch_id!=null&&(Ye.admission_batch_id=ve.admission_batch_id),ve.program_id!=null&&(Ye.program_id=ve.program_id),Object.keys(Ye).length>0&&X(ct=>({...ct,...Ye}))}}},ee.id)]}):c.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No form schema available for this step."})},ae.step_id))]})})};function HT(e){return typeof e=="object"&&e!==null&&"apiEndpoint"in e}function WT({formSchema:e}){const t=S.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((l,f)=>{const p=`field-${l.id}`;if(a.has(l.id)&&s.push({id:`${p}-duplicate-id`,type:"error",message:`Field "${l.label||l.name||`Field ${f+1}`}" has a duplicate ID`,fieldId:l.id}),a.add(l.id),l.name&&i.has(l.name)&&s.push({id:`${p}-duplicate-name`,type:"error",message:`Field "${l.label||l.name}" has a duplicate name: "${l.name}"`,fieldId:l.id}),l.name&&i.add(l.name),(!l.label||l.label.trim()==="")&&s.push({id:`${p}-missing-label`,type:"warning",message:`Field "${l.name||l.id}" is missing a label`,fieldId:l.id}),(!l.name||l.name.trim()==="")&&s.push({id:`${p}-missing-name`,type:"error",message:`Field "${l.label||l.id}" is missing a field name`,fieldId:l.id}),l.name&&!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l.name)&&s.push({id:`${p}-invalid-name`,type:"error",message:`Field "${l.label||l.name}" has an invalid name. Use only letters, numbers, and underscores.`,fieldId:l.id}),["select","multiselect","radio","checkboxgroup"].includes(l.type)){const h=l.properties;(!h?.options||h.options.length===0)&&s.push({id:`${p}-no-options`,type:"warning",message:`Field "${l.label||l.name}" has no options defined`,fieldId:l.id})}l.parentId&&(e.fields.some(y=>y.id===l.parentId)||s.push({id:`${p}-orphaned`,type:"error",message:`Field "${l.label||l.name}" references a non-existent parent`,fieldId:l.id}));const g=(h,y)=>{if(y.has(h))return!0;y.add(h);const w=e.fields.find(v=>v.id===h);return w?.parentId?g(w.parentId,y):!1};l.parentId&&g(l.id,new Set)&&s.push({id:`${p}-circular-reference`,type:"error",message:`Field "${l.label||l.name}" has a circular parent reference`,fieldId:l.id})}),e.config.workflowTrigger?.workflowId&&(e.fields.some(f=>f.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 d=e.fields.filter(l=>!l.parentId),u=new Map;return d.forEach(l=>{const f=l.position.order;u.has(f)||u.set(f,[]),u.get(f).push(l)}),u.forEach((l,f)=>{l.length>3&&s.push({id:`row-${f}-too-many-fields`,type:"warning",message:`Row ${f+1} has ${l.length} fields (maximum recommended is 3)`})}),s},[e]),r=S.useMemo(()=>t.filter(s=>s.type==="error"),[t]),n=S.useMemo(()=>t.filter(s=>s.type==="warning"),[t]),o=S.useMemo(()=>r.length===0,[r]);return{issues:t,errors:r,warnings:n,isValid:o}}function RT({field:e,value:t,allValues:r,validateOnChange:n=!1,validateOnBlur:o=!0,debounceMs:s=Bk}){const[i,a]=S.useState(),[d,u]=S.useState(!1),l=S.useRef(void 0),f=S.useRef(t),p=S.useCallback(async()=>{if(!e.validation||e.validation.length===0){a(void 0);return}u(!0);let w;for(const v of e.validation){const x=Yr(t,v,r);if(typeof x=="string"){w=x;break}}return a(w),u(!1),w},[e.validation,t,r]),m=S.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{p()},s)},[p,s]);S.useEffect(()=>(n&&f.current!==t&&m(),f.current=t,()=>{l.current&&clearTimeout(l.current)}),[t,n,m]);const g=S.useCallback(()=>{o&&p()},[o,p]),h=S.useCallback(()=>{a(void 0)},[]),y=S.useCallback(w=>{a(w)},[]);return{error:i,isValidating:d,validate:p,handleBlur:g,clearError:h,setCustomError:y}}const Xg="—";function Xt(){return{kind:"static",value:Xg}}function GT(){return{currencySymbol:"₹",emptyDisplay:Xg,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:Xt(),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:Xt(),service:{kind:"api",path:"service"},unit_price:{kind:"api",path:"unit_price"},discount_pct:Xt(),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:Xt(),unit_price:{kind:"formula",expression:"SUM('unit_price', 'data')"},discount_pct:Xt(),discount_amount:{kind:"formula",expression:"SUM('discount_amount', 'data')"},net_price:{kind:"formula",expression:"SUM('net_price', 'data')"},tax_pct:Xt(),total:{kind:"formula",expression:"SUM('total', 'data')"}}}},{kind:"static",row:{id:"invoice_discount",label:"Invoice discount",cells:{tariff_type:{kind:"label"},service:Xt(),unit_price:Xt(),discount_pct:Xt(),discount_amount:{kind:"input",inputType:"number"},net_price:Xt(),tax_pct:Xt(),total:Xt()}}},{kind:"static",row:{id:"grand_total",label:"Grand total",cells:{tariff_type:{kind:"label"},service:Xt(),unit_price:Xt(),discount_pct:Xt(),discount_amount:Xt(),net_price:Xt(),tax_pct:Xt(),total:{kind:"formula",expression:"SUM('total', 'data') - cellInRow('invoice_discount', 'discount_amount')"}}}}]}}const KT={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"}},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:GT()}},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"}}}},Jg={padding:"md",showBorder:!1};function Qg(e,t){const r="full";return e?{padding:e.padding??Jg.padding,maxWidth:e.maxWidth??r,showBorder:e.showBorder??Jg.showBorder}:{padding:"md",maxWidth:r,showBorder:!1}}function qT(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 YT(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 XT(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 JT(e){const t=Qg(e.container,e.layout);return B(XT(e.layout),YT(t.maxWidth,e.layout),qT(t.padding),t.showBorder&&"rounded-lg border border-border")}const Ji=1;function QT(){return{version:Ji,layout:"stack",container:{padding:"md",maxWidth:"full",showBorder:!1},dataBindings:[],widgets:[],filterGroups:[]}}function Zg(e){return{...e,config:e.config??{},children:Array.isArray(e.children)?e.children.map(Zg):void 0}}function ZT(e){return{version:Ji,layout:e.layout??"stack",container:Qg(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(Zg):[],filterGroups:Array.isArray(e.filterGroups)?e.filterGroups:[],eventHandlers:e.eventHandlers??[],navigation:e.navigation}}function eF(e){const t=e;return!t||typeof t!="object"?QT():(t.version!==Ji&&(t.version=Ji),ZT(t))}const ey={};let ty=null;function tF(e){ty=e}function rF(){return(ey?.VITE_API_BASE_URL?.trim()||ey?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const vs=_t.create({baseURL:rF()});vs.interceptors.request.use(e=>{const t=Tn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=ty?.();if((!r||Object.keys(r).length===0)&&(r=Ml()),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 ry(e){const t=await vs.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 Bc(e,t,r){const n=await vs.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 $c(e){const{clientId:t,api:r,context:n,filterState:o}=e,s=await vs.post(`/api/page-builder/clients/${t}/data-sources/execute`,{api:r,context:n,filterState:o});return s.data?.data??s.data}function nF(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t)){if(!o.trim())continue;const s=Qe(e,o);s!==void 0&&(r[n]=s)}return r}const ny=S.createContext(null);function oF(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 oy(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 sF({schema:e,context:t={},clientId:r,nestingDepth:n=0,onAction:o,getWorkflowState:s,parentContext:i,children:a}){const[d,u]=S.useState(()=>i?i.filterGroups:{}),l=S.useRef(d);l.current=d;const[f,p]=S.useState({}),[m,g]=S.useState(()=>oF(e,{parentContext:i,clientIdProp:r,externalContext:t})),h=S.useRef(null),y=String(r??t.clientId??i?.clientId??""),w=JSON.stringify(t);S.useEffect(()=>{if(i)return;const C=e.prepopulateApi;if(!C?.enabled||!C.api?.path||!y){p({}),g("idle"),h.current=null;return}const A=JSON.stringify({path:C.api.path,method:C.api.method,queryParams:C.api.queryParams,headers:C.api.headers,bodyFields:C.api.bodyFields,auth:C.api.auth,mapping:C.contextMapping,bindings:e.dataBindings,context:w});if(h.current===A)return;let I=!1;return h.current=A,g("loading"),(async()=>{try{const T=oy(e.dataBindings??[],t),W={...t,...T},X=await $c({clientId:y,api:C.api,context:W});if(I)return;const O=nF(X,C.contextMapping);p({...O,prepopulateResponse:X}),g("ready")}catch{I||(p({}),g("error"))}})(),()=>{I=!0,h.current=null}},[i,e.prepopulateApi,e.dataBindings,w,y]);const v=S.useMemo(()=>{if(i)return{...i.context,...t};const C=oy(e.dataBindings??[],t);return{...t,...C,...f}},[i,t,e.dataBindings,f]),x=String(r??v.clientId??i?.clientId??""),E=S.useCallback((C,A,I)=>{u(T=>({...T,[C]:{...T[C]??{},[A]:I}}))},[]),P=S.useCallback(C=>l.current[C]??{},[]),_=S.useCallback((C,A,I,T)=>{(o??i?.onAction)?.({...C,sourceWidgetId:A,event:I,payload:T})},[o,i?.onAction]),N=S.useMemo(()=>({schema:e,context:v,clientId:x,prepopulateStatus:i?.prepopulateStatus??m,nestingDepth:n,onAction:o??i?.onAction,getWorkflowState:s??i?.getWorkflowState,filterGroups:d,setFilterValue:E,getFilterGroup:P,dispatchAction:_}),[e,v,x,m,n,o,i?.onAction,s,i?.getWorkflowState,d,E,P,_]);return c.jsx(ny.Provider,{value:N,children:a})}function Lr(){const e=S.useContext(ny);if(!e)throw new Error("usePageContext must be used within PageContextProvider");return e}const iF=5,sy=1;function Fo(e){return Number.isFinite(e)?Math.min(iF,Math.max(sy,Math.round(e))):sy}function aF(e,t){const r=Fo(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 lF(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):0}function cF(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 iy(e){return cF(100,Fo(e))}function dF(e){const t=e.trim(),r=/^(\d+(?:\.\d+)?)\s*%?$/.exec(t);return r?lF(Number(r[1])):null}function ay(e,t){const r=Fo(t),n=[];for(let s=0;s<r;s++){const i=dF(e?.[s]??"");if(i===null)return iy(r);n.push(i)}return n.reduce((s,i)=>s+i,0)!==100?iy(r):n}function uF(e){return e==="sm"?"gap-2":e==="lg"?"gap-6":"gap-4"}function ly(e,t){return ay(t,Fo(e)).map(n=>`minmax(0, ${n}fr)`).join(" ")}function fF(e){return e.length?e.map(t=>`minmax(0, ${t}fr)`).join(" "):"minmax(0, 1fr)"}function pF(e,t,r,n){const o=Fo(t),s=aF(e,o),i=ay(r,o);if(!(n?.collapseEmpty!==!1))return{columns:s,gridTemplate:ly(o,r),sourceIndices:s.map((p,m)=>m)};const d=s.map((p,m)=>({colChildren:p,index:m,percent:i[m]??0})).filter(p=>p.colChildren.length>0);if(d.length===0||d.length===s.length)return{columns:s,gridTemplate:ly(o,r),sourceIndices:s.map((p,m)=>m)};const u=d.reduce((p,m)=>p+m.percent,0),l=d.map(p=>u>0?Math.round(p.percent/u*100):Math.round(100/d.length)),f=100-l.reduce((p,m)=>p+m,0);return f!==0&&l.length>0&&(l[0]+=f),{columns:d.map(p=>p.colChildren),gridTemplate:fF(l),sourceIndices:d.map(p=>p.index)}}function jc(e,t="solid"){return e?t==="dashed"?"rounded-md border border-dashed border-border":"rounded-md border border-border":""}function mF(e){return B(jc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-3")}function hF(e){return B(jc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-2")}function gF(e,t){return e.columnBorders?.[t]!==void 0?!!e.columnBorders[t]:!!e.showColumnBorders}function yF(e,t){const r=gF(e,t);return B(jc(r,e.borderStyle??"dashed"),r&&"p-2")}function bF(e){if(e)return{minHeight:`${e}vh`}}function vF({widget:e,renderChildren:t}){const r=e.config,[n,o]=S.useState(r.defaultCollapsed??!1);return c.jsxs("section",{className:B("space-y-4",mF(r)),"data-widget-id":e.id,children:[r.heading&&c.jsx("div",{className:"flex items-center gap-2",children:r.collapsible?c.jsx("button",{type:"button",className:"text-left text-lg font-semibold hover:underline",onClick:()=>o(s=>!s),children:r.heading}):c.jsx("h2",{className:"text-lg font-semibold",children:r.heading})}),r.showDivider&&c.jsx("hr",{className:"border-border"}),!n&&e.children?.length?c.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function wF({widget:e,renderChildren:t}){const r=e.config,n=Fo(r.columns??2),o=r.collapseEmptyColumns!==!1,s=pF(e.children??[],n,r.columnWidths,{collapseEmpty:o});return c.jsx("div",{className:B("grid w-full min-w-0 items-stretch",uF(r.gap),hF(r)),style:{gridTemplateColumns:s.gridTemplate,...bF(r.minHeightPercent)},"data-widget-id":e.id,children:s.columns.map((i,a)=>{const d=s.sourceIndices[a]??a;return c.jsx("div",{className:B("flex min-h-[inherit] min-w-0 flex-col space-y-4 overflow-hidden",yF(r,d)),children:t?.(i)},d)})})}function SF({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 c.jsxs("div",{className:B("rounded-lg p-4",n),"data-widget-id":e.id,children:[(r.title||r.subtitle)&&c.jsxs("div",{className:"mb-4",children:[r.title&&c.jsx("h3",{className:"font-semibold",children:r.title}),r.subtitle&&c.jsx("p",{className:"text-sm text-muted-foreground",children:r.subtitle})]}),e.children?.length?c.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function cy(e,t){if(e.variable){const r=t[e.variable];return r!=null?String(r):e.fallback??e.text??""}return e.text??""}function xF({widget:e}){const t=e.config,{context:r}=Lr(),n=cy(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 c.jsx("div",{role:"heading","aria-level":o,className:B("font-semibold tracking-tight",i,s),"data-widget-id":e.id,children:n})}function AF({widget:e}){const t=e.config,{context:r}=Lr(),n=cy(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 c.jsx("p",{className:B(o,s),"data-widget-id":e.id,children:n})}function CF(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 dy(e,t){const r={...e};for(const[n,o]of Object.entries(r))typeof o=="string"&&(r[n]=CF(o,t));return r}function EF(e,t){return e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=t[n.trim()];return o!=null?String(o):""})}function uy(e,t,r,n){if(e.type==="navigate"){const o=EF(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?dy(e.params,t):void 0},n,"click");return}if(e.type==="workflow"&&e.workflowId){r(e,n,"click");return}r(e,n,"click")}function NF({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Lr();return c.jsx(Yt,{variant:t.variant??"default",size:t.size??"default","data-widget-id":e.id,onClick:()=>uy(t.action,r,n,e.id),children:t.label})}const _F={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between"},kF={sm:"gap-2",md:"gap-3",lg:"gap-4"};function TF({widget:e}){const t=e.config,{context:r,dispatchAction:n}=Lr(),o=t.buttons??[];return c.jsx("div",{className:B("flex flex-wrap items-center",_F[t.align??"start"],kF[t.gap??"sm"],t.wrap===!1&&"flex-nowrap"),"data-widget-id":e.id,children:o.map(s=>c.jsx(Yt,{variant:s.variant??"outline",size:s.size??"default","data-widget-id":e.id,"data-button-id":s.id,onClick:()=>uy(s.action,r,n,e.id),children:s.label},s.id))})}function FF(e){const t=e.prepopulateApi;return!!(t?.enabled&&t.api?.path)}function PF(e,t){return e&&(t==="idle"||t==="loading")}function OF(e,t){return!e||t==="ready"||t==="error"}function IF(e,t){const r=Qe(e,t??"");return r===void 0?null:r}function fy(e,t){if(e.mode==="pageApi"&&e.dataSourceRef)return t[e.dataSourceRef];if(e.mode==="api")return e.api}function py({widgetId:e,dataSource:t,enabled:r=!0,page:n,pageSize:o,search:s}){const{schema:i,context:a,clientId:d,getFilterGroup:u,prepopulateStatus:l}=Lr(),f=S.useMemo(()=>t.filterGroupKey?u(t.filterGroupKey):{},[t.filterGroupKey,u]),p=t.mode==="context"&&FF(i),m=PF(p,l),g=r&&(t.mode==="static"||(t.mode==="context"?OF(p,l):!!d)),h=S.useMemo(()=>["page-ds",e,t,a,f,n,o,s,l],[e,t,a,f,n,o,s,l]),y=gn.useQuery({queryKey:h,enabled:g,staleTime:fy(t,i.dataApis??{})?.staleTimeMs??3e4,queryFn:async()=>{if(t.mode==="static")return t.staticData;if(t.mode==="context")return IF(a,t.contextPath);const w=fy(t,i.dataApis??{});if(!w)throw new Error(`No API config for data source on widget ${e}`);const v={...a};if(t.requestBindings)for(const P of t.requestBindings){let _;P.source==="binding"?_=a[P.key]:P.source==="filter"&&(_=f[P.key]),_!==void 0&&(v[P.param]=_)}const E={...dy(v,a),...n!==void 0?{page:n,pageSize:o,search:s}:{}};return $c({clientId:d,api:w,context:E,filterState:f})}});return{...y,isLoading:y.isLoading||m,isPending:y.isPending||m,isFetching:y.isFetching||m}}function zc(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 ws(e,t){const r=Qe(e,t.path);return r==null?t.fallback??r:t.formatter?zc(r,t.formatter):r}function MF(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 LF={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"},DF={rectangle:"rounded-lg",square:"aspect-square rounded-lg",circle:"aspect-square rounded-full"},BF={sm:"p-2 text-xs",md:"p-4 text-sm",lg:"p-6 text-base"},Uc={sm:"text-lg",md:"text-2xl",lg:"text-3xl"},$F={sm:"gap-2",md:"gap-3",lg:"gap-4"};function jF({title:e,value:t,trend:r,variant:n="default",shape:o="rectangle",size:s="md",layout:i="vertical",isLoading:a,isError:d}){const u=i==="horizontal";return c.jsxs("div",{className:B(LF[n??"default"],DF[o??"rectangle"],BF[s??"md"],u&&"flex items-center justify-between gap-3"),children:[c.jsxs("div",{className:B(u&&"min-w-0"),children:[e&&c.jsx("p",{className:B("font-medium text-muted-foreground",u?"text-sm":""),children:e}),r!=null&&r!==""&&!u&&c.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:String(r)})]}),a?c.jsx(Pn,{className:"my-2"}):d?c.jsx("p",{className:B("font-bold text-destructive",Uc[s??"md"]),children:"Error"}):c.jsx("p",{className:B("font-bold",u?Uc[s??"md"]:`mt-1 ${Uc[s??"md"]}`),children:String(t)}),u&&r!==null&&r!==void 0&&r!==""&&c.jsx("p",{className:"text-xs text-muted-foreground",children:String(r)})]})}function my({stat:e,widgetId:t}){const{data:r,isLoading:n,isError:o}=py({widgetId:t,dataSource:e.dataSource}),i=(()=>{if(n)return"";if(r==null)return e.valueMapping.fallback??"—";if(e.dataSource.mode==="context"){const d=r;return e.valueMapping.formatter?zc(d,e.valueMapping.formatter):d}if(e.dataSource.mode==="static"){const d=e.valueMapping.path?.trim()||"value",u=ws(r,{...e.valueMapping,path:d});if(u!=null)return e.valueMapping.formatter?zc(u,e.valueMapping.formatter):u;if(typeof r=="object"&&r!==null&&!Array.isArray(r)){const l=r;if(l.value!==void 0&&l.value!==null)return l.value}return e.valueMapping.fallback??"—"}return ws(r,e.valueMapping)})(),a=e.trendMapping&&r!==void 0&&e.dataSource.mode!=="context"?ws(r,e.trendMapping):e.trendMapping&&e.dataSource.mode==="context"&&e.trendMapping.path?ws({value:r},e.trendMapping):null;return c.jsx(jF,{title:e.title,value:i,trend:a,variant:e.variant,shape:e.shape,size:e.size,layout:e.layout,isLoading:n,isError:o})}function zF({widget:e}){const t=e.config;return c.jsx("div",{"data-widget-id":e.id,children:c.jsx(my,{stat:t,widgetId:e.id})})}function UF({stat:e,widgetId:t}){return c.jsx(my,{stat:e,widgetId:`${t}-${e.id}`})}function VF({widget:e}){const t=e.config,r=t.stats??[],n=t.columns??1,o=t.direction==="horizontal";return c.jsx("div",{"data-widget-id":e.id,className:B(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",$F[t.gap??"md"]),children:r.map(s=>c.jsx(UF,{stat:s,widgetId:e.id},s.id))})}function HF({widget:e}){const t=e.config,{setFilterValue:r}=Lr(),[n,o]=S.useState("");return S.useEffect(()=>{const s=t.debounceMs??300,i=setTimeout(()=>{r(t.filterGroupKey,"search",n)},s);return()=>clearTimeout(i)},[n,t.debounceMs,t.filterGroupKey,r]),c.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 WF(e,t){if(!e)return[];const r=t?Qe(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 RF({widget:e}){const t=e.config,{dispatchAction:r}=Lr(),[n,o]=S.useState(1),[s,i]=S.useState(""),a=t.pagination?.pageSize??10,{data:d,isLoading:u,isError:l}=py({widgetId:e.id,dataSource:t.dataSource,page:n,pageSize:a,search:t.search?.enabled?s:void 0}),f=t.dataSource.mode==="pageApi"?void 0:t.dataSource.api?.itemsPath,p=WF(d,f??"data.items"),m=(g,h)=>{const y=t.dataSource.responseMapping.find(w=>w.target===h);return y?ws(g,y):Qe(g,h)??""};return c.jsxs("div",{className:"space-y-3","data-widget-id":e.id,children:[t.search?.enabled&&c.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:g=>{i(g.target.value),o(1)}}),c.jsx("div",{className:"overflow-x-auto rounded-md border",children:c.jsxs("table",{className:"w-full text-sm",children:[c.jsx("thead",{children:c.jsx("tr",{className:"border-b bg-muted/50",children:t.columns.map(g=>c.jsx("th",{className:B("px-3 py-2 text-left font-medium",g.align==="center"&&"text-center",g.align==="right"&&"text-right"),style:g.width?{width:g.width}:void 0,children:g.header},g.id))})}),c.jsx("tbody",{children:u?c.jsx("tr",{children:c.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center",children:c.jsx(Pn,{})})}):l?c.jsx("tr",{children:c.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-destructive",children:"Failed to load data"})}):p.length===0?c.jsx("tr",{children:c.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-muted-foreground",children:t.emptyMessage??"No data"})}):p.map((g,h)=>c.jsx("tr",{className:"cursor-pointer border-b hover:bg-muted/30",onClick:()=>{r({type:"emit",eventName:"row_click",payload:{row:g}},e.id,"row_click")},children:t.columns.map(y=>c.jsx("td",{className:B("px-3 py-2",y.align==="center"&&"text-center",y.align==="right"&&"text-right"),children:String(m(g,y.field))},y.id))},h))})]})}),t.pagination?.enabled&&c.jsxs("div",{className:"flex items-center justify-between text-sm",children:[c.jsxs("span",{className:"text-muted-foreground",children:["Page ",n]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{type:"button",className:"rounded border px-2 py-1 disabled:opacity-50",disabled:n<=1,onClick:()=>o(g=>Math.max(1,g-1)),children:"Previous"}),c.jsx("button",{type:"button",className:"rounded border px-2 py-1",disabled:p.length<a,onClick:()=>o(g=>g+1),children:"Next"})]})]})]})}const GF=75;function KF(e){return e??GF}function Vc({scrollBehavior:e="page",maxHeightPercent:t,children:r,className:n}){if(e!=="contained")return c.jsx(c.Fragment,{children:r});const o=KF(t);return c.jsx("div",{className:B("min-w-0 overflow-y-auto overflow-x-hidden",n),style:{maxHeight:`${o}vh`},"data-form-embed-scroll":"contained",children:r})}function qF(e,t,r){return["embedded-form",e,t,r??"latest"]}async function YF(e,t){try{const r=await dn.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 XF(e,t,r){const n=r!==void 0?`/api/form-builder/forms/${e}/render?version=${r}`:`/api/form-builder/forms/${e}/render`,o=await dn.get(n,{params:{clientId:t}}),i=o.data?.data??o.data,a=i.form??i,d=i.fields??a.fields??[];let u=i.layout??a.layout??null;(!u||typeof u.columns!="number")&&(u=await YF(e,t));const l=i.rules??a.rules??[],f=ms(a,d,u,l),p=_s({config:f.config,layout:f.layout},Ns(u))??Ns(u);return{schema:f,gridLayout:p}}const JF=300*1e3;function hy({formId:e,mode:t="fill",contextFieldMapping:r,pageContext:n,clientId:o,formVersion:s,scrollBehavior:i,maxHeightPercent:a}){const{data:d,isLoading:u,isError:l,error:f}=gn.useQuery({queryKey:qF(e,o,s),queryFn:()=>XF(e,o,s),staleTime:JF}),p=S.useMemo(()=>MF(n,r),[n,r]);return u?c.jsx(Vc,{scrollBehavior:i,maxHeightPercent:a,children:c.jsx(Pn,{})}):l?c.jsx(Vc,{scrollBehavior:i,maxHeightPercent:a,children:c.jsx("p",{className:"text-sm text-destructive",children:f instanceof Error?f.message:"Failed to load form"})}):d?.schema?c.jsx(Vc,{scrollBehavior:i,maxHeightPercent:a,children:c.jsx(Mc,{schema:d.schema,mode:t,gridLayout:d.gridLayout,initialValues:p,submissionContext:n})}):null}function QF({widget:e}){const t=e.config,{context:r,clientId:n}=Lr();return t.formId?c.jsx(hy,{formId:t.formId,mode:t.mode??"fill",contextFieldMapping:t.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:t.scrollBehavior,maxHeightPercent:t.maxHeightPercent}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured"})}function ZF({widget:e}){const t=e.config,{context:r,getWorkflowState:n,clientId:o}=Lr(),s=String(r.moduleId??"");if(!n)return c.jsxs("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground","data-widget-id":e.id,children:["Workflow embed requires ",c.jsx("code",{className:"text-xs",children:"getWorkflowState"})," on PageRenderer. Workflow ID: ",t.workflowId]});if(!s)return c.jsx("p",{className:"text-sm text-destructive","data-widget-id":e.id,children:"moduleId required in page context for workflow embed"});const i={};if(t.contextVariableMapping)for(const[a,d]of Object.entries(t.contextVariableMapping)){const u=r[d];u!=null&&(i[a]=String(u))}return c.jsx(Yg,{getWorkflowState:n,moduleId:s,tenantId:r.tenantId?String(r.tenantId):void 0,clientId:o||void 0,submissionContext:i})}function eP({widget:e}){const t=e.config,{schema:r,dispatchAction:n}=Lr(),o=t.previousPage??r.navigation?.previousPage,s=t.nextPage??r.navigation?.nextPage,i=t.showPrevious!==!1&&!!o,a=t.showNext!==!1&&!!s,d=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",l=f=>{n({type:"navigate_page",pageId:f.pageId},e.id,"click")};return c.jsxs("nav",{className:"space-y-3","data-widget-id":e.id,children:[d&&c.jsx("ol",{className:"flex flex-wrap items-center gap-1 text-sm text-muted-foreground",children:r.navigation.breadcrumbs.map((f,p)=>c.jsxs("li",{className:"flex items-center gap-1",children:[p>0&&c.jsx("span",{children:"/"}),f.href?c.jsx("a",{href:f.href,className:"hover:underline",children:f.label}):c.jsx("span",{children:f.label})]},p))}),c.jsxs("div",{className:B("flex items-center gap-2",u),children:[i&&o&&c.jsx(Yt,{variant:"outline",size:"sm",onClick:()=>l(o),children:o.label??"Previous"}),a&&s&&c.jsx(Yt,{variant:"default",size:"sm",onClick:()=>l(s),children:s.label??"Next"})]})]})}function tP(e,t){return e?.length?e.filter(r=>r.config.tabId===t):[]}const rP=1;function nP(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 oP(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 sP(e,t,r){return e?new Set(r?[r]:[]):new Set(t.map(n=>n.id))}function iP({tab:e,shouldRender:t,pageContext:r,clientId:n}){return t?e.formId?c.jsx(hy,{formId:e.formId,mode:e.formMode??"fill",contextFieldMapping:e.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:e.scrollBehavior,maxHeightPercent:e.maxHeightPercent}):c.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured for this tab"}):null}function aP({tab:e,shouldLoad:t,shouldRender:r,nestingDepth:n,pageContext:o,clientId:s,onAction:i,getWorkflowState:a}){const d=Lr(),{data:u,isLoading:l,isError:f,error:p}=gn.useQuery({queryKey:["tab-page",e.pageId,e.pageVersion,s],enabled:t&&!!e.pageId,queryFn:async()=>Bc(e.pageId,s,e.pageVersion)});return r?n>=rP?c.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?l?c.jsx(Pn,{}):f?c.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load page"}):u?c.jsx(Hc,{page:u,context:o,nestingDepth:n+1,inheritContext:!0,onAction:i,getWorkflowState:a,parentContext:d}):null:c.jsx("p",{className:"text-sm text-muted-foreground",children:"No page configured for this tab"}):null}function lP({tab:e,widgetChildren:t,renderChildren:r}){const n=tP(t,e.id);return n.length===0?c.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No widgets in this tab"}):c.jsx(c.Fragment,{children:r?.(n)})}function cP({widget:e,renderChildren:t}){const r=e.config,{context:n,clientId:o,nestingDepth:s,onAction:i,getWorkflowState:a}=Lr(),d=r.tabs??[],u=r.defaultTabId??d[0]?.id??"",l=r.lazyLoad!==!1,[f,p]=S.useState(u),[m,g]=S.useState(()=>sP(l,d,u)),h=w=>{g(v=>new Set(v).add(w)),p(w)},y=S.useMemo(()=>!l,[l]);return d.length===0?c.jsx("p",{className:"text-sm text-muted-foreground","data-widget-id":e.id,children:"No tabs configured"}):c.jsxs(Rg,{value:f,onValueChange:h,className:"w-full","data-widget-id":e.id,children:[c.jsx(Gg,{className:B("mb-4",nP(r.variant)),children:d.map(w=>c.jsx(Kg,{value:w.id,disabled:w.disabled,className:oP(r.variant),children:w.label},w.id))}),d.map(w=>{const v=m.has(w.id),x=y||v,E=y||v;return c.jsxs(qg,{value:w.id,forceMount:y||void 0,className:B("mt-0",y&&"data-[state=inactive]:hidden"),children:[w.contentType==="widgets"&&E&&c.jsx(lP,{tab:w,widgetChildren:e.children??[],renderChildren:t}),w.contentType==="form"&&c.jsx(iP,{tab:w,shouldRender:x,pageContext:n,clientId:o}),w.contentType==="page"&&c.jsx(aP,{tab:w,shouldLoad:x,shouldRender:E,nestingDepth:s,pageContext:n,clientId:o,onAction:i,getWorkflowState:a})]},w.id)})]})}const dP={section:vF,columns:wF,card:SF,tab_group:cP,heading:xF,text:AF,button:NF,button_group:TF,stat_card:zF,stat_grid:VF,data_table:RF,search_filter:HF,form_embed:QF,workflow_embed:ZF,page_nav:eP};function uP({widget:e}){return c.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: ",c.jsx("code",{className:"text-xs",children:e.type}),e.label&&c.jsxs("span",{className:"ml-1",children:["(",e.label,")"]})]})}function fP({widget:e,renderChildren:t}){const r=dP[e.type]??uP;return c.jsx(r,{widget:e,renderChildren:t})}function gy(e,t){return e.map(r=>c.jsx(fP,{widget:r,renderChildren:t},r.id))}function Hc({page:e,context:t={},onAction:r,chrome:n="none",className:o,nestingDepth:s=0,getWorkflowState:i,inheritContext:a=!1,parentContext:d}){const u=S.useMemo(()=>eF(e.schema),[e.schema]),l=p=>gy(p,l),f=c.jsxs("div",{className:B("studio-page-content min-h-0 min-w-0",JT(u),o),"data-page-id":e.id,"data-nesting-depth":s,children:[n==="minimal"&&u.meta?.title&&c.jsxs("header",{className:"mb-6 border-b pb-4",children:[c.jsx("h1",{className:"text-2xl font-semibold",children:u.meta.title}),u.meta.description&&c.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u.meta.description})]}),c.jsx("div",{className:"space-y-6",children:gy(u.widgets,l)})]});return a&&d?f:c.jsx(sF,{schema:u,context:t,clientId:String(t.clientId??""),nestingDepth:s,onAction:r,getWorkflowState:i,parentContext:d,children:f})}function pP({clientId:e,tenantId:t,moduleId:r,featureId:n,pageId:o,routePath:s,routeParams:i={},isDefault:a,context:d={},version:u,chrome:l="none",onAction:f,getWorkflowState:p}){const m=S.useMemo(()=>({...i,...d,clientId:e,tenantId:t,moduleId:r,featureId:n}),[i,d,e,t,r,n]),{data:g,isLoading:h,isError:y,error:w}=gn.useQuery({queryKey:["page-resolve",e,t,r,n,o,s,a,u],queryFn:()=>ry({clientId:e,tenantId:t,moduleId:r,featureId:n,routePath:s,isDefault:a,version:u}),enabled:!o}),v=o??g?.pageId,x=u??g?.version,{data:E,isLoading:P,isError:_,error:N}=gn.useQuery({queryKey:["page-render",v,e,x],queryFn:()=>Bc(v,e,x),enabled:!!v});return!o&&h?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx(Pn,{})}):y?c.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:w instanceof Error?w.message:"Failed to resolve page"}):v?P?c.jsx("div",{className:"flex items-center justify-center p-12",children:c.jsx(Pn,{})}):_||!E?c.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:N instanceof Error?N.message:"Failed to load page"}):c.jsx(Hc,{page:E,context:m,chrome:l,nestingDepth:0,onAction:f,getWorkflowState:p}):c.jsx("div",{className:"rounded-md border p-4 text-sm text-muted-foreground",children:"No page found for the given scope or route."})}ge.FIELD_TYPE_REGISTRY=KT,ge.FORM_RENDERER_GRID_ROW_HEIGHT_DEFAULT=In,ge.FORM_RENDERER_ROOT_CLASS=ga,ge.FieldRenderer=un,ge.FormRenderer=Mc,ge.PageRenderer=Hc,ge.RendererFieldLayoutContext=_a,ge.StudioPageHost=pP,ge.WorkflowStepsView=Yg,ge.appearanceControlClasses=Bo,ge.appearanceHasExplicitVerticalIntent=kd,ge.appearanceTextareaClasses=vd,ge.backendToFormSchema=ms,ge.cellAlignmentClasses=Nb,ge.cellVerticalJustifyClassesForField=Eb,ge.effectiveWidthPercent=Ps,ge.executeDataSource=$c,ge.fetchPageRender=Bc,ge.fieldBlockBoxStyle=Cb,ge.fieldBlockBoxStyleForField=Nd,ge.fieldBlockHorizontalPlacementClass=xd,ge.fieldBlockHorizontalSelfClass=Ad,ge.fieldBlockHorizontalSelfClassForField=_d,ge.fieldBlockWidthStyle=Sa,ge.fieldBlockWidthStyleForField=Ed,ge.fieldGridShellFillsCellVertically=Is,ge.formBuilderHttp=dn,ge.formLayoutRecordToGridConfig=Ns,ge.getBusinessApiOrigin=Np,ge.getClientId=Tn,ge.getRendererHostAuthHeaders=Ml,ge.getRendererHostViewerContext=bC,ge.getRendererStore=ev,ge.gridCellFlexClasses=Sd,ge.gridCellFlexClassesForField=Na,ge.gridCellOuterFlexClasses=wd,ge.hasExplicitFieldBlockWidth=Cd,ge.isAsyncSearchFieldProperties=HT,ge.isIntrinsicWidthButtonField=to,ge.normalizeWorkflowFormSchema=Zk,ge.normalizeWorkflowFormToRendererSchema=Yi,ge.pageBuilderHttp=vs,ge.parseContentVerticalAlign=Aa,ge.parseMetadataJson=ys,ge.resetRendererHostAuth=yC,ge.resolveBusinessApiUrl=cn,ge.resolveFormGridLayout=_s,ge.resolvePage=ry,ge.resolvedGridCellVerticalJustifyClasses=jo,ge.resolvedHorizontalAlign=Fr,ge.resolvedVerticalAlign=$o,ge.resolvedVerticalAlignForField=Ea,ge.setBusinessApiOrigin=UA,ge.setFormBuilderAuthProvider=vC,ge.setPageBuilderAuthProvider=tF,ge.setRendererHostAuthHeaders=gC,ge.setRendererHostViewerContext=hC,ge.useFieldValidation=RT,ge.useFormRenderer=Vd,ge.useFormValidation=WT,ge.useRendererFieldLayout=zo,ge.useRendererHostAuthStore=Rn,Object.defineProperty(ge,Symbol.toStringTag,{value:"Module"})}));
|