iq-line-form-builder-renderer 1.2.19 → 1.2.21
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 +15150 -14021
- package/dist/form-renderer.umd.js +31 -31
- package/dist/page/PageContextProvider.d.ts +6 -1
- package/dist/page/PageContextProvider.d.ts.map +1 -1
- package/dist/page/PageRenderer.d.ts +1 -1
- package/dist/page/PageRenderer.d.ts.map +1 -1
- package/dist/page/StudioPageHost.d.ts +1 -1
- package/dist/page/StudioPageHost.d.ts.map +1 -1
- package/dist/page/embeds/EmbeddedForm.d.ts.map +1 -1
- package/dist/page/types/page.d.ts +5 -0
- package/dist/page/types/page.d.ts.map +1 -1
- package/dist/page/utils/resolvePageWorkflowHandlers.d.ts +17 -0
- package/dist/page/utils/resolvePageWorkflowHandlers.d.ts.map +1 -0
- package/dist/page/widgets/WorkflowEmbedWidget.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/components/fields/ButtonField.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/components/fields/OtpField.d.ts +20 -0
- package/dist/pages/systemAdmin/modules/formbuilder/components/fields/OtpField.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/components/fields/TableField.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/components/fields/buttonNavigationHandlers.d.ts +7 -0
- package/dist/pages/systemAdmin/modules/formbuilder/components/fields/buttonNavigationHandlers.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/components/fields/index.d.ts +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/components/fields/index.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/FieldRenderer.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/FormRenderer.d.ts +9 -0
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/FormRenderer.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/Skeleton.d.ts +2 -1
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/Skeleton.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/WorkflowFormModal.d.ts +20 -0
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/WorkflowFormModal.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/WorkflowModalContext.d.ts +24 -0
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/WorkflowModalContext.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/WorkflowStepsNavigation.d.ts +13 -0
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/WorkflowStepsNavigation.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/WorkflowStepsView.d.ts +14 -1
- package/dist/pages/systemAdmin/modules/formbuilder/components/renderer/WorkflowStepsView.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/constants/fieldTypes.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/hooks/useFormRenderer.d.ts +3 -1
- package/dist/pages/systemAdmin/modules/formbuilder/hooks/useFormRenderer.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/services/formService.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/store/RendererStoreContext.d.ts +14 -0
- package/dist/pages/systemAdmin/modules/formbuilder/store/RendererStoreContext.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/store/rendererStore.d.ts +4 -60
- package/dist/pages/systemAdmin/modules/formbuilder/store/rendererStore.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/store/rendererStoreFactory.d.ts +62 -0
- package/dist/pages/systemAdmin/modules/formbuilder/store/rendererStoreFactory.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/types/backend.types.d.ts +3 -1
- package/dist/pages/systemAdmin/modules/formbuilder/types/backend.types.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/types/field.d.ts +70 -3
- package/dist/pages/systemAdmin/modules/formbuilder/types/field.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/types/form.d.ts +4 -1
- package/dist/pages/systemAdmin/modules/formbuilder/types/form.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/types/workflow.d.ts +13 -0
- package/dist/pages/systemAdmin/modules/formbuilder/types/workflow.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/types/workflowModal.d.ts +33 -0
- package/dist/pages/systemAdmin/modules/formbuilder/types/workflowModal.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/accessibilityUtils.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/utils/bffWorkflowRouting.d.ts +14 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/bffWorkflowRouting.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/buttonApiSuccessUtils.d.ts +15 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/buttonApiSuccessUtils.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/createBffWorkflowModalHandlers.d.ts +26 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/createBffWorkflowModalHandlers.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/formSteps/formStepsRuntime.d.ts +6 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/formSteps/formStepsRuntime.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/formSteps/index.d.ts +2 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/formSteps/index.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/otpFieldUtils.d.ts +8 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/otpFieldUtils.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/otpResendUtils.d.ts +34 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/otpResendUtils.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/schemaConverter.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/utils/valueFormatter.d.ts.map +1 -1
- package/dist/pages/systemAdmin/modules/formbuilder/utils/workflowStepsNavigation.d.ts +28 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/workflowStepsNavigation.d.ts.map +1 -0
- package/dist/pages/systemAdmin/modules/formbuilder/utils/workflowToFormSchema.d.ts.map +1 -1
- package/dist/renderer/index.d.ts +13 -2
- package/dist/renderer/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
(function(be,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):(be=typeof globalThis<"u"?globalThis:be||self,S(be.FormBuilderRenderer={},be.React,be.jsxRuntime,be.ReactRouterDOM,be.ReactDOM,be.Sonner,be.ReactQuery))})(this,(function(be,S,d,ka,ad,Bt,wr){"use strict";function ld(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const b=ld(S),Oi=ld(ad),_a="iq-fbr",$r="95px";function Ii(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:$r}}function Mi(e,t){if(t!=null&&t!==void 0)return t;const n=e.config;if(n?.grid&&typeof n.grid.rows=="number"&&typeof n.grid.columns=="number")return{rows:n.grid.rows,columns:n.grid.columns,verticalSpacing:n.grid.verticalSpacing??n.grid.spacing,horizontalSpacing:n.grid.horizontalSpacing??n.grid.spacing,rowHeight:n.grid.rowHeight,spacing:n.grid.spacing};const r=n?.layout!=null&&typeof n.layout=="object"?n.layout:null;if(r&&typeof r.rows=="number"&&typeof r.columns=="number")return{rows:r.rows,columns:r.columns,verticalSpacing:r.verticalSpacing??r.spacing,horizontalSpacing:r.horizontalSpacing??r.spacing,rowHeight:r.rowHeight,spacing:r.spacing};const o=e.layout;if(o!=null&&typeof o=="object"&&typeof o.rows=="number"&&typeof o.columns=="number"){const i=o;return{rows:i.rows,columns:i.columns,verticalSpacing:i.verticalSpacing??i.spacing,horizontalSpacing:i.horizontalSpacing??i.spacing,rowHeight:i.rowHeight,spacing:i.spacing}}return null}function cd(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=cd(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function dd(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=cd(e))&&(r&&(r+=" "),r+=t);return r}const ib=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},sb=(e,t)=>({classGroupId:e,validator:t}),ud=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Li="-",fd=[],ab="arbitrary..",lb=e=>{const t=db(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:s=>{if(s.startsWith("[")&&s.endsWith("]"))return cb(s);const a=s.split(Li),c=a[0]===""&&a.length>1?1:0;return pd(a,c,t)},getConflictingClassGroupIds:(s,a)=>{if(a){const c=r[s],u=n[s];return c?u?ib(u,c):c:u||fd}return n[s]||fd}}},pd=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],i=n.nextPart.get(o);if(i){const u=pd(e,t+1,i);if(u)return u}const s=n.validators;if(s===null)return;const a=t===0?e.join(Li):e.slice(t).join(Li),c=s.length;for(let u=0;u<c;u++){const l=s[u];if(l.validator(a))return l.classGroupId}},cb=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?ab+r:void 0})(),db=e=>{const{theme:t,classGroups:n}=e;return ub(n,t)},ub=(e,t)=>{const n=ud();for(const r in e){const o=e[r];Ta(o,n,r,t)}return n},Ta=(e,t,n,r)=>{const o=e.length;for(let i=0;i<o;i++){const s=e[i];fb(s,t,n,r)}},fb=(e,t,n,r)=>{if(typeof e=="string"){pb(e,t,n);return}if(typeof e=="function"){mb(e,t,n,r);return}hb(e,t,n,r)},pb=(e,t,n)=>{const r=e===""?t:md(t,e);r.classGroupId=n},mb=(e,t,n,r)=>{if(gb(e)){Ta(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(sb(n,e))},hb=(e,t,n,r)=>{const o=Object.entries(e),i=o.length;for(let s=0;s<i;s++){const[a,c]=o[s];Ta(c,md(t,a),n,r)}},md=(e,t)=>{let n=e;const r=t.split(Li),o=r.length;for(let i=0;i<o;i++){const s=r[i];let a=n.nextPart.get(s);a||(a=ud(),n.nextPart.set(s,a)),n=a}return n},gb=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,yb=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(i,s)=>{n[i]=s,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(i){let s=n[i];if(s!==void 0)return s;if((s=r[i])!==void 0)return o(i,s),s},set(i,s){i in n?n[i]=s:o(i,s)}}},Fa="!",hd=":",bb=[],gd=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),vb=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=o=>{const i=[];let s=0,a=0,c=0,u;const l=o.length;for(let h=0;h<l;h++){const y=o[h];if(s===0&&a===0){if(y===hd){i.push(o.slice(c,h)),c=h+1;continue}if(y==="/"){u=h;continue}}y==="["?s++:y==="]"?s--:y==="("?a++:y===")"&&a--}const f=i.length===0?o:o.slice(c);let p=f,m=!1;f.endsWith(Fa)?(p=f.slice(0,-1),m=!0):f.startsWith(Fa)&&(p=f.slice(1),m=!0);const g=u&&u>c?u-c:void 0;return gd(i,m,p,g)};if(t){const o=t+hd,i=r;r=s=>s.startsWith(o)?i(s.slice(o.length)):gd(bb,!1,s,void 0,!0)}if(n){const o=r;r=i=>n({className:i,parseClassName:o})}return r},wb=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let o=[];for(let i=0;i<n.length;i++){const s=n[i],a=s[0]==="[",c=t.has(s);a||c?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(s)):o.push(s)}return o.length>0&&(o.sort(),r.push(...o)),r}},Sb=e=>({cache:yb(e.cacheSize),parseClassName:vb(e),sortModifiers:wb(e),...lb(e)}),xb=/\s+/,Ab=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:i}=t,s=[],a=e.trim().split(xb);let c="";for(let u=a.length-1;u>=0;u-=1){const l=a[u],{isExternal:f,modifiers:p,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:h}=n(l);if(f){c=l+(c.length>0?" "+c:c);continue}let y=!!h,w=r(y?g.substring(0,h):g);if(!w){if(!y){c=l+(c.length>0?" "+c:c);continue}if(w=r(g),!w){c=l+(c.length>0?" "+c:c);continue}y=!1}const v=p.length===0?"":p.length===1?p[0]:i(p).join(":"),x=m?v+Fa:v,C=x+w;if(s.indexOf(C)>-1)continue;s.push(C);const F=o(w,y);for(let N=0;N<F.length;++N){const T=F[N];s.push(x+T)}c=l+(c.length>0?" "+c:c)}return c},Cb=(...e)=>{let t=0,n,r,o="";for(;t<e.length;)(n=e[t++])&&(r=yd(n))&&(o&&(o+=" "),o+=r);return o},yd=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=yd(e[r]))&&(n&&(n+=" "),n+=t);return n},Eb=(e,...t)=>{let n,r,o,i;const s=c=>{const u=t.reduce((l,f)=>f(l),e());return n=Sb(u),r=n.cache.get,o=n.cache.set,i=a,a(c)},a=c=>{const u=r(c);if(u)return u;const l=Ab(c,n);return o(c,l),l};return i=s,(...c)=>i(Cb(...c))},Nb=[],Rt=e=>{const t=n=>n[e]||Nb;return t.isThemeGetter=!0,t},bd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,vd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,kb=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,_b=/^(\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$/,Fb=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Pb=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ob=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Sr=e=>kb.test(e),at=e=>!!e&&!Number.isNaN(Number(e)),xr=e=>!!e&&Number.isInteger(Number(e)),Pa=e=>e.endsWith("%")&&at(e.slice(0,-1)),ar=e=>_b.test(e),wd=()=>!0,Ib=e=>Tb.test(e)&&!Fb.test(e),Oa=()=>!1,Mb=e=>Pb.test(e),Lb=e=>Ob.test(e),Db=e=>!ke(e)&&!_e(e),Bb=e=>Ar(e,Nd,Oa),ke=e=>bd.test(e),jr=e=>Ar(e,kd,Ib),Sd=e=>Ar(e,Rb,at),$b=e=>Ar(e,Td,wd),jb=e=>Ar(e,_d,Oa),xd=e=>Ar(e,Cd,Oa),zb=e=>Ar(e,Ed,Lb),Di=e=>Ar(e,Fd,Mb),_e=e=>vd.test(e),zo=e=>zr(e,kd),Vb=e=>zr(e,_d),Ad=e=>zr(e,Cd),Ub=e=>zr(e,Nd),Hb=e=>zr(e,Ed),Bi=e=>zr(e,Fd,!0),Wb=e=>zr(e,Td,!0),Ar=(e,t,n)=>{const r=bd.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},zr=(e,t,n=!1)=>{const r=vd.exec(e);return r?r[1]?t(r[1]):n:!1},Cd=e=>e==="position"||e==="percentage",Ed=e=>e==="image"||e==="url",Nd=e=>e==="length"||e==="size"||e==="bg-size",kd=e=>e==="length",Rb=e=>e==="number",_d=e=>e==="family-name",Td=e=>e==="number"||e==="weight",Fd=e=>e==="shadow",Kb=Eb(()=>{const e=Rt("color"),t=Rt("font"),n=Rt("text"),r=Rt("font-weight"),o=Rt("tracking"),i=Rt("leading"),s=Rt("breakpoint"),a=Rt("container"),c=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"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],F=()=>[...C(),_e,ke],N=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto","contain","none"],k=()=>[_e,ke,c],A=()=>[Sr,"full","auto",...k()],O=()=>[xr,"none","subgrid",_e,ke],E=()=>["auto",{span:["full",xr,_e,ke]},xr,_e,ke],L=()=>[xr,"auto",_e,ke],G=()=>["auto","min","max","fr",_e,ke],I=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],$=()=>["start","end","center","stretch","center-safe","end-safe"],D=()=>["auto",...k()],B=()=>[Sr,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...k()],M=()=>[Sr,"screen","full","dvw","lvw","svw","min","max","fit",...k()],W=()=>[Sr,"screen","full","lh","dvh","lvh","svh","min","max","fit",...k()],j=()=>[e,_e,ke],ie=()=>[...C(),Ad,xd,{position:[_e,ke]}],H=()=>["no-repeat",{repeat:["","x","y","space","round"]}],U=()=>["auto","cover","contain",Ub,Bb,{size:[_e,ke]}],J=()=>[Pa,zo,jr],de=()=>["","none","full",u,_e,ke],ne=()=>["",at,zo,jr],q=()=>["solid","dashed","dotted","double"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Te=()=>[at,Pa,Ad,xd],Q=()=>["","none",g,_e,ke],te=()=>["none",at,_e,ke],ge=()=>["none",at,_e,ke],ce=()=>[at,_e,ke],Xe=()=>[Sr,"full",...k()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ar],breakpoint:[ar],color:[wd],container:[ar],"drop-shadow":[ar],ease:["in","out","in-out"],font:[Db],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ar],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ar],shadow:[ar],spacing:["px",at],text:[ar],"text-shadow":[ar],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Sr,ke,_e,y]}],container:["container"],columns:[{columns:[at,ke,_e,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:F()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],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:[xr,"auto",_e,ke]}],basis:[{basis:[Sr,"full","auto",a,...k()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[at,Sr,"auto","initial","none",ke]}],grow:[{grow:["",at,_e,ke]}],shrink:[{shrink:["",at,_e,ke]}],order:[{order:[xr,"first","last","none",_e,ke]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:E()}],"col-start":[{"col-start":L()}],"col-end":[{"col-end":L()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:E()}],"row-start":[{"row-start":L()}],"row-end":[{"row-end":L()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":G()}],"auto-rows":[{"auto-rows":G()}],gap:[{gap:k()}],"gap-x":[{"gap-x":k()}],"gap-y":[{"gap-y":k()}],"justify-content":[{justify:[...I(),"normal"]}],"justify-items":[{"justify-items":[...$(),"normal"]}],"justify-self":[{"justify-self":["auto",...$()]}],"align-content":[{content:["normal",...I()]}],"align-items":[{items:[...$(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...$(),{baseline:["","last"]}]}],"place-content":[{"place-content":I()}],"place-items":[{"place-items":[...$(),"baseline"]}],"place-self":[{"place-self":["auto",...$()]}],p:[{p:k()}],px:[{px:k()}],py:[{py:k()}],ps:[{ps:k()}],pe:[{pe:k()}],pbs:[{pbs:k()}],pbe:[{pbe:k()}],pt:[{pt:k()}],pr:[{pr:k()}],pb:[{pb:k()}],pl:[{pl:k()}],m:[{m:D()}],mx:[{mx:D()}],my:[{my:D()}],ms:[{ms:D()}],me:[{me:D()}],mbs:[{mbs:D()}],mbe:[{mbe:D()}],mt:[{mt:D()}],mr:[{mr:D()}],mb:[{mb:D()}],ml:[{ml:D()}],"space-x":[{"space-x":k()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":k()}],"space-y-reverse":["space-y-reverse"],size:[{size:B()}],"inline-size":[{inline:["auto",...M()]}],"min-inline-size":[{"min-inline":["auto",...M()]}],"max-inline-size":[{"max-inline":["none",...M()]}],"block-size":[{block:["auto",...W()]}],"min-block-size":[{"min-block":["auto",...W()]}],"max-block-size":[{"max-block":["none",...W()]}],w:[{w:[a,"screen",...B()]}],"min-w":[{"min-w":[a,"screen","none",...B()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},...B()]}],h:[{h:["screen","lh",...B()]}],"min-h":[{"min-h":["screen","lh","none",...B()]}],"max-h":[{"max-h":["screen","lh",...B()]}],"font-size":[{text:["base",n,zo,jr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Wb,$b]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Pa,ke]}],"font-family":[{font:[Vb,jb,t]}],"font-features":[{"font-features":[ke]}],"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,_e,ke]}],"line-clamp":[{"line-clamp":[at,"none",_e,Sd]}],leading:[{leading:[i,...k()]}],"list-image":[{"list-image":["none",_e,ke]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",_e,ke]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:j()}],"text-color":[{text:j()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...q(),"wavy"]}],"text-decoration-thickness":[{decoration:[at,"from-font","auto",_e,jr]}],"text-decoration-color":[{decoration:j()}],"underline-offset":[{"underline-offset":[at,"auto",_e,ke]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:k()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",_e,ke]}],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",_e,ke]}],"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:H()}],"bg-size":[{bg:U()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},xr,_e,ke],radial:["",_e,ke],conic:[xr,_e,ke]},Hb,zb]}],"bg-color":[{bg:j()}],"gradient-from-pos":[{from:J()}],"gradient-via-pos":[{via:J()}],"gradient-to-pos":[{to:J()}],"gradient-from":[{from:j()}],"gradient-via":[{via:j()}],"gradient-to":[{to:j()}],rounded:[{rounded:de()}],"rounded-s":[{"rounded-s":de()}],"rounded-e":[{"rounded-e":de()}],"rounded-t":[{"rounded-t":de()}],"rounded-r":[{"rounded-r":de()}],"rounded-b":[{"rounded-b":de()}],"rounded-l":[{"rounded-l":de()}],"rounded-ss":[{"rounded-ss":de()}],"rounded-se":[{"rounded-se":de()}],"rounded-ee":[{"rounded-ee":de()}],"rounded-es":[{"rounded-es":de()}],"rounded-tl":[{"rounded-tl":de()}],"rounded-tr":[{"rounded-tr":de()}],"rounded-br":[{"rounded-br":de()}],"rounded-bl":[{"rounded-bl":de()}],"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:[...q(),"hidden","none"]}],"divide-style":[{divide:[...q(),"hidden","none"]}],"border-color":[{border:j()}],"border-color-x":[{"border-x":j()}],"border-color-y":[{"border-y":j()}],"border-color-s":[{"border-s":j()}],"border-color-e":[{"border-e":j()}],"border-color-bs":[{"border-bs":j()}],"border-color-be":[{"border-be":j()}],"border-color-t":[{"border-t":j()}],"border-color-r":[{"border-r":j()}],"border-color-b":[{"border-b":j()}],"border-color-l":[{"border-l":j()}],"divide-color":[{divide:j()}],"outline-style":[{outline:[...q(),"none","hidden"]}],"outline-offset":[{"outline-offset":[at,_e,ke]}],"outline-w":[{outline:["",at,zo,jr]}],"outline-color":[{outline:j()}],shadow:[{shadow:["","none",l,Bi,Di]}],"shadow-color":[{shadow:j()}],"inset-shadow":[{"inset-shadow":["none",f,Bi,Di]}],"inset-shadow-color":[{"inset-shadow":j()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:j()}],"ring-offset-w":[{"ring-offset":[at,jr]}],"ring-offset-color":[{"ring-offset":j()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":j()}],"text-shadow":[{"text-shadow":["none",p,Bi,Di]}],"text-shadow-color":[{"text-shadow":j()}],opacity:[{opacity:[at,_e,ke]}],"mix-blend":[{"mix-blend":[...re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":re()}],"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":[at]}],"mask-image-linear-from-pos":[{"mask-linear-from":Te()}],"mask-image-linear-to-pos":[{"mask-linear-to":Te()}],"mask-image-linear-from-color":[{"mask-linear-from":j()}],"mask-image-linear-to-color":[{"mask-linear-to":j()}],"mask-image-t-from-pos":[{"mask-t-from":Te()}],"mask-image-t-to-pos":[{"mask-t-to":Te()}],"mask-image-t-from-color":[{"mask-t-from":j()}],"mask-image-t-to-color":[{"mask-t-to":j()}],"mask-image-r-from-pos":[{"mask-r-from":Te()}],"mask-image-r-to-pos":[{"mask-r-to":Te()}],"mask-image-r-from-color":[{"mask-r-from":j()}],"mask-image-r-to-color":[{"mask-r-to":j()}],"mask-image-b-from-pos":[{"mask-b-from":Te()}],"mask-image-b-to-pos":[{"mask-b-to":Te()}],"mask-image-b-from-color":[{"mask-b-from":j()}],"mask-image-b-to-color":[{"mask-b-to":j()}],"mask-image-l-from-pos":[{"mask-l-from":Te()}],"mask-image-l-to-pos":[{"mask-l-to":Te()}],"mask-image-l-from-color":[{"mask-l-from":j()}],"mask-image-l-to-color":[{"mask-l-to":j()}],"mask-image-x-from-pos":[{"mask-x-from":Te()}],"mask-image-x-to-pos":[{"mask-x-to":Te()}],"mask-image-x-from-color":[{"mask-x-from":j()}],"mask-image-x-to-color":[{"mask-x-to":j()}],"mask-image-y-from-pos":[{"mask-y-from":Te()}],"mask-image-y-to-pos":[{"mask-y-to":Te()}],"mask-image-y-from-color":[{"mask-y-from":j()}],"mask-image-y-to-color":[{"mask-y-to":j()}],"mask-image-radial":[{"mask-radial":[_e,ke]}],"mask-image-radial-from-pos":[{"mask-radial-from":Te()}],"mask-image-radial-to-pos":[{"mask-radial-to":Te()}],"mask-image-radial-from-color":[{"mask-radial-from":j()}],"mask-image-radial-to-color":[{"mask-radial-to":j()}],"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":C()}],"mask-image-conic-pos":[{"mask-conic":[at]}],"mask-image-conic-from-pos":[{"mask-conic-from":Te()}],"mask-image-conic-to-pos":[{"mask-conic-to":Te()}],"mask-image-conic-from-color":[{"mask-conic-from":j()}],"mask-image-conic-to-color":[{"mask-conic-to":j()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:H()}],"mask-size":[{mask:U()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",_e,ke]}],filter:[{filter:["","none",_e,ke]}],blur:[{blur:Q()}],brightness:[{brightness:[at,_e,ke]}],contrast:[{contrast:[at,_e,ke]}],"drop-shadow":[{"drop-shadow":["","none",m,Bi,Di]}],"drop-shadow-color":[{"drop-shadow":j()}],grayscale:[{grayscale:["",at,_e,ke]}],"hue-rotate":[{"hue-rotate":[at,_e,ke]}],invert:[{invert:["",at,_e,ke]}],saturate:[{saturate:[at,_e,ke]}],sepia:[{sepia:["",at,_e,ke]}],"backdrop-filter":[{"backdrop-filter":["","none",_e,ke]}],"backdrop-blur":[{"backdrop-blur":Q()}],"backdrop-brightness":[{"backdrop-brightness":[at,_e,ke]}],"backdrop-contrast":[{"backdrop-contrast":[at,_e,ke]}],"backdrop-grayscale":[{"backdrop-grayscale":["",at,_e,ke]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[at,_e,ke]}],"backdrop-invert":[{"backdrop-invert":["",at,_e,ke]}],"backdrop-opacity":[{"backdrop-opacity":[at,_e,ke]}],"backdrop-saturate":[{"backdrop-saturate":[at,_e,ke]}],"backdrop-sepia":[{"backdrop-sepia":["",at,_e,ke]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":k()}],"border-spacing-x":[{"border-spacing-x":k()}],"border-spacing-y":[{"border-spacing-y":k()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",_e,ke]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[at,"initial",_e,ke]}],ease:[{ease:["linear","initial",w,_e,ke]}],delay:[{delay:[at,_e,ke]}],animate:[{animate:["none",v,_e,ke]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,_e,ke]}],"perspective-origin":[{"perspective-origin":F()}],rotate:[{rotate:te()}],"rotate-x":[{"rotate-x":te()}],"rotate-y":[{"rotate-y":te()}],"rotate-z":[{"rotate-z":te()}],scale:[{scale:ge()}],"scale-x":[{"scale-x":ge()}],"scale-y":[{"scale-y":ge()}],"scale-z":[{"scale-z":ge()}],"scale-3d":["scale-3d"],skew:[{skew:ce()}],"skew-x":[{"skew-x":ce()}],"skew-y":[{"skew-y":ce()}],transform:[{transform:[_e,ke,"","none","gpu","cpu"]}],"transform-origin":[{origin:F()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Xe()}],"translate-x":[{"translate-x":Xe()}],"translate-y":[{"translate-y":Xe()}],"translate-z":[{"translate-z":Xe()}],"translate-none":["translate-none"],accent:[{accent:j()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:j()}],"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",_e,ke]}],"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":k()}],"scroll-mx":[{"scroll-mx":k()}],"scroll-my":[{"scroll-my":k()}],"scroll-ms":[{"scroll-ms":k()}],"scroll-me":[{"scroll-me":k()}],"scroll-mbs":[{"scroll-mbs":k()}],"scroll-mbe":[{"scroll-mbe":k()}],"scroll-mt":[{"scroll-mt":k()}],"scroll-mr":[{"scroll-mr":k()}],"scroll-mb":[{"scroll-mb":k()}],"scroll-ml":[{"scroll-ml":k()}],"scroll-p":[{"scroll-p":k()}],"scroll-px":[{"scroll-px":k()}],"scroll-py":[{"scroll-py":k()}],"scroll-ps":[{"scroll-ps":k()}],"scroll-pe":[{"scroll-pe":k()}],"scroll-pbs":[{"scroll-pbs":k()}],"scroll-pbe":[{"scroll-pbe":k()}],"scroll-pt":[{"scroll-pt":k()}],"scroll-pr":[{"scroll-pr":k()}],"scroll-pb":[{"scroll-pb":k()}],"scroll-pl":[{"scroll-pl":k()}],"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",_e,ke]}],fill:[{fill:["none",...j()]}],"stroke-w":[{stroke:[at,zo,jr,Sd]}],stroke:[{stroke:["none",...j()]}],"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 z(...e){return Kb(dd(e))}const Gb=["richtext","multiselect","radio","checkboxgroup","signature"],qb=3;function Vo(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(qb,t);if(e.type==="radio"||e.type==="checkboxgroup"){const n=e.properties?.options;return(Array.isArray(n)?n.length:0)<=2?1:Math.max(t,2)}return Gb.includes(e.type)?Math.max(t,2):t}function Pd(e,t){if(e.type==="table"||e.type==="billingGrid"){const i=e.position.columnSpan??t??1;return t!=null?Math.min(i,t):i}if(e.type!=="radio"&&e.type!=="checkboxgroup"){const i=e.position.columnSpan??1;return t!=null?Math.min(i,t):i}const n=e.properties?.options,r=Array.isArray(n)?n.length:0,o=Math.max(1,Math.ceil(r/2));return t!=null?Math.min(o,t):o}function Uo(e){const t=e?.size??"md",n=e?.variant??"default";return z(t==="sm"?"h-8 text-sm":t==="lg"?"min-h-12 text-lg py-2":"h-10 md:text-sm",n==="filled"?"border-transparent bg-muted shadow-none":n==="outlined"?"border-2 bg-transparent":"")}function Od(e){const t=e?.size??"md",n=e?.variant??"default";return z(t==="sm"?"min-h-[48px] text-sm":t==="lg"?"min-h-[72px] text-lg":"min-h-[56px]",n==="filled"?"border-transparent bg-muted shadow-none":n==="outlined"?"border-2 bg-transparent":"")}function Yb(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 n=t?"text-destructive":"";switch(e){case"left":return`shrink-0 w-32 pt-2 text-right text-sm font-medium ${n}`;case"right":return`shrink-0 w-32 pt-2 text-left text-sm font-medium ${n}`;case"center":return`w-full text-center text-sm font-medium ${n}`;case"floating":return`absolute left-3 top-2 z-[1] origin-[0] -translate-y-4 scale-75 bg-background px-1 text-sm ${n}`;default:return`text-sm font-medium ${n}`}}function Jb(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 $i(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 Ia(e){const t=$i(e);return{width:t>=100?"100%":`${t}%`,maxWidth:"100%"}}function Qb(e){return Ia(e)}function Ma(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"||t==="stretch"?t:null}function La(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"?t:null}function kn(e){if(!e)return"start";const t=Ma(e.horizontalAlign);if(t)return t;const n=Ma(e.contentAlign);if(n)return n;const r=Ma(e.cellAlign);return r||"start"}function Ho(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 ji(e){switch(e){case"center":return"items-center";case"end":return"items-end";case"stretch":return"items-stretch";default:return"items-start"}}function Da(e){switch(e){case"center":return"justify-center";case"end":return"justify-end";case"stretch":return"justify-stretch";default:return"justify-start"}}function Wo(e){const t=La(e.appearance?.contentVerticalAlign);if(t!==null)switch(t){case"center":return"justify-center";case"end":return"justify-end";default:return"justify-start"}return Da(Ba(e))}const Zb=Wo;function zi(e){if(e.type==="billingGrid"||e.type==="table"||Vo(e)>1)return!0;const t=La(e.appearance?.contentVerticalAlign);if(t==="center"||t==="end")return!1;if(t==="start")return!0;const n=Ba(e);return n!=="center"&&n!=="end"}function Id(e){const t=e[0];if(!t)return $a(void 0);if(e.length===1)return $a(t);const n=kn(t.appearance);return z("flex flex-col min-h-0 h-full w-full",ji(n),"justify-start")}function Md(e){const t=kn(e),n=Ho(e);return z("flex flex-col min-h-0 h-full w-full",ji(t),Da(n))}function Ld(e){if($i(e)>=100)return"";const n=kn(e);return n==="center"?"mx-auto":n==="end"?"ml-auto":""}function Dd(e){if($i(e)>=100)return"w-full";const n=kn(e);return n==="center"||n==="end"?"min-w-0":n==="stretch"?"min-w-0 self-stretch":"min-w-0 self-start"}function Bd(e){return e?e.widthMode==="full"||e.widthMode==="percent"||typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent):!1}function oo(e){return(e.type==="button"||e.type==="editButton")&&!Bd(e.appearance)}function $d(e){return oo(e)?kn(e.appearance)==="stretch"?{width:"100%",maxWidth:"100%",minWidth:0}:{width:"auto",maxWidth:"100%"}:Ia(e.appearance)}function jd(e){return $d(e)}function zd(e){if(oo(e))switch(kn(e.appearance)){case"center":return"self-center";case"end":return"self-end";case"stretch":return"self-stretch";default:return"self-start"}return Dd(e.appearance)}function Vd(e){return e?e.verticalAlign!=null||e.cellJustify!=null:!1}function Ba(e){return e.type!=="button"&&e.type!=="editButton"||Vd(e.appearance)?Ho(e.appearance):"start"}function $a(e){if(!e)return Md(void 0);const t=kn(e.appearance);return z("flex flex-col min-h-0 h-full w-full",ji(t),Wo(e))}function ev(e,t){const n={};e!==void 0&&(n.cellAlign=e),t!==void 0&&(n.cellJustify=t);const o=e===void 0&&t===void 0?void 0:n;return z(ji(kn(o)),Da(Ho(o)))}const ja=S.createContext({gridStretch:!1});function Ro(){return S.useContext(ja)}const Ud=e=>{let t;const n=new Set,r=(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),n.forEach(m=>m(t,p))}},o=()=>t,a={setState:r,getState:o,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u))},c=t=e(r,o,a);return a},tv=(e=>e?Ud(e):Ud),nv=e=>e;function rv(e,t=nv){const n=S.useSyncExternalStore(e.subscribe,S.useCallback(()=>t(e.getState()),[e,t]),S.useCallback(()=>t(e.getInitialState()),[e,t]));return S.useDebugValue(n),n}const Hd=e=>{const t=tv(e),n=r=>rv(t,r);return Object.assign(n,t),n},Wd=(e=>e?Hd(e):Hd),ov=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,iv=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,sv=/^\+?[\d\s-()]{10,}$/,av={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 n=t.value;return e.length>=n},maxLength:(e,t)=>{if(typeof e!="string")return!0;const n=t.value;return e.length<=n},min:(e,t)=>{if(typeof e!="number")return!0;const n=t.value;return e>=n},max:(e,t)=>{if(typeof e!="number")return!0;const n=t.value;return e<=n},pattern:(e,t)=>{if(typeof e!="string")return!0;const n=t.value,r=t.params?.flags||"";return new RegExp(n,r).test(e)},email:e=>typeof e!="string"||!e?!0:ov.test(e),url:e=>typeof e!="string"||!e?!0:iv.test(e),phone:e=>typeof e!="string"||!e?!0:sv.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 n=new Date(e);if(isNaN(n.getTime()))return!1;const r=t.value,o=new Date;if(o.setHours(0,0,0,0),r.min){const i=r.min==="today"?o:new Date(r.min);if(n<i)return!1}if(r.max){const i=r.max==="today"?o:new Date(r.max);if(n>i)return!1}return!0},fileSize:(e,t)=>{if(!e)return!0;const n=t.value;return e instanceof File?e.size<=n:Array.isArray(e)?e.every(r=>r.size<=n):!0},fileType:(e,t)=>{if(!e)return!0;const n=t.value,r={"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=i=>n.some(s=>{if(s.endsWith("/*")){const u=s.replace("/*","");if(i.type.startsWith(u))return!0}else if(i.type===s)return!0;const a=i.name.toLowerCase(),c=r[s];return c?c.some(u=>a.endsWith(u)):s.startsWith(".")?a.endsWith(s.toLowerCase()):!1});return e instanceof File?o(e):Array.isArray(e)?e.every(i=>o(i)):!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 n=t.value;return(e.match(/[a-zA-Z]/g)||[]).length>=n},maxLetters:(e,t)=>{if(typeof e!="string"||!e)return!0;const n=t.value;return(e.match(/[a-zA-Z]/g)||[]).length<=n},minNumbers:(e,t)=>{if(typeof e!="string"||!e)return!0;const n=t.value;return(e.match(/[0-9]/g)||[]).length>=n},maxNumbers:(e,t)=>{if(typeof e!="string"||!e)return!0;const n=t.value;return(e.match(/[0-9]/g)||[]).length<=n},minSpecialChars:(e,t)=>{if(typeof e!="string"||!e)return!0;const n=t.value;return(e.match(/[^a-zA-Z0-9\s]/g)||[]).length>=n},maxSpecialChars:(e,t)=>{if(typeof e!="string"||!e)return!0;const n=t.value;return(e.match(/[^a-zA-Z0-9\s]/g)||[]).length<=n},custom:(e,t,n)=>!0,async:()=>!0};function Xn(e,t,n={}){const r=av[t.type];if(!r)return!0;const o=r(e,t,n);return o===!1?t.message||lv(t):typeof o=="string"?o:!0}function lv(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 ${cv(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 cv(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const dv=10;function Vi(e){const t=e.properties;return t?.maxFiles!=null&&t.maxFiles>0?Math.floor(t.maxFiles):t?.multiple===!0?dv:1}function Rd(e){return typeof e=="object"&&e!==null&&"url"in e&&typeof e.url=="string"&&e.url.length>0}function Kd(e){try{return e.split("?")[0].split("/").filter(Boolean).pop()||e}catch{return e}}function Ui(e){if(e==null)return[];if(typeof e=="string")return e.startsWith("http")?[{url:e,name:Kd(e)}]:[];if(e instanceof File)return[e];if(Array.isArray(e)){const t=[];for(const n of e)n instanceof File?t.push(n):typeof n=="string"&&n.startsWith("http")?t.push({url:n,name:Kd(n)}):Rd(n)&&t.push(n);return t}return Rd(e)?[e]:[]}function uv(e,t){return e.slice(0,t)}function za(e,t){const n=uv(e,t);return n.length===0?null:t===1?n[0]??null:n}function fv(e){return Ui(e).length}function pv(e){return e==="file"||e==="camera"||e==="photoChoice"}function Va(e,t){if(!pv(e.type))return;const n=Vi(e);if(fv(t)>n)return`Maximum ${n} file(s) allowed`}class Hi{static functions={SUM:(...t)=>t.flat().filter(r=>typeof r=="number").reduce((r,o)=>r+o,0),AVG:(...t)=>{const n=t.flat().filter(r=>typeof r=="number");return n.length===0?0:n.reduce((r,o)=>r+o,0)/n.length},MIN:(...t)=>{const n=t.flat().filter(r=>typeof r=="number");return n.length>0?Math.min(...n):0},MAX:(...t)=>{const n=t.flat().filter(r=>typeof r=="number");return n.length>0?Math.max(...n):0},ROUND:(t,n=0)=>{const r=Number(t);if(isNaN(r))return 0;const o=Math.pow(10,Number(n));return Math.round(r*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,n,r)=>{const o=String(t),i=Number(n),s=r!==void 0?Number(r):void 0;return o.substring(i,s!==void 0?i+s:void 0)},IF:(t,n,r)=>t?n:r,IFEMPTY:(t,n)=>t==null||t===""?n: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 n=new Date(t);return isNaN(n.getTime())?null:n.getFullYear()},MONTH:t=>{const n=new Date(t);return isNaN(n.getTime())?null:n.getMonth()+1},DAY:t=>{const n=new Date(t);return isNaN(n.getTime())?null:n.getDate()},DATEDIFF:(t,n,r="days")=>{const o=new Date(t),i=new Date(n);if(isNaN(o.getTime())||isNaN(i.getTime()))return null;const a=(i.getTime()-o.getTime())/(1e3*60*60*24);switch(r){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 n=t[0],r=t[1];return!Array.isArray(n)||typeof r!="string"?0:n.reduce((o,i)=>{if(typeof i=="object"&&i!==null){const s=i[r];return o+(Number(s)||0)}return o},0)}};calculate(t,n){try{const{fields:r,currentValue:o,previousValue:i}=n,s={...r};for(const f in s){const p=s[f];(p==null||p==="")&&(s[f]="")}const a={fields:s,currentValue:o,previousValue:i,...Hi.functions},c=Object.keys(a),u=Object.values(a),l=new Function(...c,`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,n){const r={...n};for(const o of t){const i={fields:r,currentValue:r[o.field],previousValue:n[o.field]},s=this.calculate(o.formula,i);r[o.field]=s===null?"":s}return r}validateFormula(t){try{return new Function("fields",`return ${t}`),{valid:!0}}catch(n){return{valid:!1,error:n instanceof Error?n.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 Gd=new Hi;function qd(e){if(e==null||e==="")return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:Wi(e);if(typeof e=="string"){const t=e.trim();if(!t)return null;const n=t.match(/^(\d{4})-(\d{2})-(\d{2})/);if(n){const o=new Date(Number(n[1]),Number(n[2])-1,Number(n[3]));return Number.isNaN(o.getTime())?null:o}const r=new Date(t);return Number.isNaN(r.getTime())?null:Wi(r)}return null}function Wi(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function mv(e,t=new Date){const n=Wi(e),r=Wi(t);if(r<n)return{years:0,months:0,days:0};let o=r.getFullYear()-n.getFullYear(),i=r.getMonth()-n.getMonth(),s=r.getDate()-n.getDate();if(s<0){i-=1;const a=new Date(r.getFullYear(),r.getMonth(),0).getDate();s+=a}return i<0&&(o-=1,i+=12),{years:Math.max(0,o),months:Math.max(0,i),days:Math.max(0,s)}}function Ua(e){if(e.type!=="number")return;const t=e.properties?.deriveFromDate;if(!(!t?.sourceFieldName||!t.part))return t}function _n(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function Ha(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(t):null}function hv(e,t){const n=Ha(e);return n?`${t.sourceFieldName}${n}`:t.sourceFieldName}function Yd(e,t,n){const r=Ha(t);if(r)return[`${e}${r}`];const o=new Set([e]),i=`${e}__addmore__`;for(const s of Object.keys(n))(s===e||s.startsWith(i))&&o.add(s);return[...o]}function gv(e,t,n){const r=n?hv(n,e):e.sourceFieldName,o=qd(t[r]);if(!o)return null;const i=e.referenceDate==="today"||e.referenceDate==null?new Date:qd(t[e.referenceDate])??new Date;return mv(o,i)[e.part]}function Xd(e,t){const n=Ua(e);return n?_n(n.sourceFieldName)===_n(t):!1}function Wa(e,t,n,r){const o={...t},i=r?_n(r):void 0;for(const s of e){if(s.type!=="number")continue;const a=Ua(s);if(!a||!s.name||i&&_n(a.sourceFieldName)!==i)continue;const c=r??a.sourceFieldName,u=Yd(s.name,c,o);for(const l of u){if(n.has(l))continue;const f=gv(a,o,l);o[l]=f}}return o}function yv(e,t,n,r){const o={...t},i=_n(r);for(const s of e){if(!Xd(s,i)||!s.name)continue;const a=Yd(s.name,r,o);for(const c of a)n.delete(c),o[c]=null}return o}function Jd(e,t){const n=_n(t);return e.some(r=>Xd(r,n))}function Qd(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 Ra(e,t,n,r){let o=Ka(e,n);return r&&(o=Vr(o,t,n)),o}function Ka(e,t){return e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(n,r)=>t?.[r]!==void 0&&t[r]!==null?String(t[r]):n)}function Vr(e,t,n){let r=e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(o,i)=>n?.[i]!==void 0&&n[i]!==null?String(n[i]):o);return r=r.replace(/\{(\w+)\}/g,(o,i)=>{if(o.includes("ctx:")||o.includes("@"))return o;let s=t[i];if(s==null||s===""){const a=Object.keys(t).find(c=>c.toLowerCase()===i.toLowerCase());a&&(s=t[a])}return s!=null&&s!==""?String(s):o}),r}function io(e,t){const n=e.match(/\{(\w+)\}/g)||[],r=[];t?.custom&&t.custom.forEach(({value:i})=>{if(i){const s=i.match(/\{(\w+)\}/g)||[];r.push(...s.filter(a=>!a.includes("ctx:")&&!a.includes("@")))}});const o=n.filter(i=>!i.includes("ctx:")&&!i.includes("@"));return new Set([...o.map(i=>i.replace(/[{}]/g,"")),...r.map(i=>i.replace(/[{}]/g,""))])}function bv(e,t){const n=e[t];return n==null||n===""}function Ri(e){const{apiEndpoint:t,apiMethod:n="GET",apiQueryParams:r={},formValues:o,submissionContext:i,apiRealtime:s,additionalRequiredFieldNames:a=[],excludeFormFieldNames:c=[]}=e,u=(n||"GET").toLowerCase(),l=io(t,r),f=new Set((c||[]).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=!!(s&&l.has(v)),C=p.has(v);if((x||C)&&bv(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=Ka(h,i),s&&(h=Vr(h,o,i)),r&&Object.keys(r).length>0){const v=r,x=[];if(v.limit){let C=v.limit;s&&(C=Vr(C,o,i)),x.push(`_limit=${encodeURIComponent(C)}`)}if(v.page){let C=v.page;s&&(C=Vr(C,o,i)),x.push(`page=${encodeURIComponent(C)}`)}if(v.sort){let C=v.sort;s&&(C=Vr(C,o,i)),x.push(`sort=${encodeURIComponent(C)}`)}if(v.orderBy){let C=v.orderBy;s&&(C=Vr(C,o,i)),x.push(`orderBy=${encodeURIComponent(C)}`)}if(v.custom?.length&&v.custom.forEach(({key:C,value:F})=>{if(!C||!F)return;let N=Ka(F,i);s&&(N=Vr(N,o,i)),N.match(/\{[^}]+\}/)?N.match(/\{(?!ctx:|\@)(\w+)\}/g)||x.push(`${encodeURIComponent(C)}=`):x.push(`${encodeURIComponent(C)}=${encodeURIComponent(N)}`)}),x.length>0){const C=h.includes("?")?"&":"?";h=`${h}${C}${x.join("&")}`}}if(s&&Object.keys(o).length>0&&u==="get"){const v=N=>N.replace(/\{/g,"").replace(/\}/g,""),x=[];for(const N of r.custom||[])if(N.value){const T=N.value.match(/\{(\w+)\}/g)||[];x.push(...T.map(v))}const C=new Set([...y.map(v),...x]),F={};Object.keys(o).forEach(N=>{!C.has(N)&&!f.has(N)&&(F[N]=o[N])}),Object.keys(F).length>0&&(h=`${h}${h.includes("?")?"&":"?"}${new URLSearchParams(F).toString()}`)}let w=null;if(["post","put","patch"].includes(u))if(s&&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 vv=new Set(["select","multiselect","asyncsearch"]);function wv(e){return e?.type==="multiselect"?[]:""}function Zd(e){if(!vv.has(e.type))return[];const t=e.properties??{},n=Qd(e),r=new Set,o=n?.apiClientFilter?.matchField?.trim()||t.apiClientFilter?.matchField?.trim();o&&r.add(o);const i=[...Array.isArray(t.dependentFields)?t.dependentFields:[],...Array.isArray(n?.dependentFields)?n.dependentFields:[]];for(const u of i)typeof u=="string"&&u.trim()&&r.add(u.trim());const s=n?.apiEndpoint||t.apiEndpoint,a=n?.apiRealtime??t.apiRealtime,c=n?.apiQueryParams||t.apiQueryParams;if(s&&a)for(const u of io(s,c))r.add(u);return[...r]}function Sv(e,t){const n=_n(t);return Zd(e).some(r=>_n(r)===n)}function xv(e,t){const n=_n(t);return e.some(r=>Sv(r,n))}function Av(e){const t=new Map;for(const n of e){const r=n.name;if(r)for(const o of Zd(n)){const i=_n(o),s=t.get(i)??new Set;s.add(r),t.set(i,s)}}return t}function Cv(e,t,n){const r=Ha(t);if(r)return[`${e}${r}`];const o=new Set([e]),i=`${e}__addmore__`;for(const s of Object.keys(n))(s===e||s.startsWith(i))&&o.add(s);return[...o]}function Ev(e,t){return e===t?!0:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,r)=>n===t[r]):!1}function Nv(e,t,n){const r=Av(e),o=_n(n),i=new Set,s=[o];for(;s.length>0;){const u=s.shift(),l=r.get(u);if(l)for(const f of l)i.has(f)||(i.add(f),s.push(f))}const a={...t},c=[];for(const u of i){const l=e.find(p=>p.name===u),f=wv(l);for(const p of Cv(u,n,a))Ev(a[p],f)||c.push(p),a[p]=f}return{values:a,clearedKeys:c}}function Ga(e,t){const n=t instanceof Set?t:new Set(t);if(e.size!==n.size)return!1;for(const r of e)if(!n.has(r))return!1;return!0}const Nt=Wd((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:(n,r)=>{const o=t(),i=o.schema!=null&&o.schema.id===n.id,s=r?.forceReset===!0,a={},c=new Set,u=new Set,l=new Set;n.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||c.add(w),y.disabled||u.add(w),y.validation?.some(v=>v.type==="required")&&l.add(w))});const f=n.steps?.length||1,p=[];n.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?Gd.calculateAll(p,a):{},g=Wa(n.fields,{...a,...m},new Set),h=i&&!s?{...g,...o.values}:g;e({schema:n,values:h,initialValues:g,errors:{},touched:{},currentStep:0,totalSteps:f,completedSteps:new Set,visibleFields:c,enabledFields:u,requiredFields:l,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:s||!i?new Set:o.derivedFieldDirty,isValid:!0,draftId:null})},setFieldValue:(n,r,o)=>{const i=t(),s=i.schema,a=o?.source??"user";let c=new Set(i.derivedFieldDirty);const u=i.values[n];let l={...i.values,[n]:r},f=[];if(s){const p=_n(n),m=s.fields.find(w=>w.name===p);a==="user"&&m&&Ua(m)&&c.add(n);const g=r==null||r===""||Array.isArray(r)&&r.length===0;if(Jd(s.fields,n)&&g?l=yv(s.fields,l,c,n):Jd(s.fields,n)&&(l=Wa(s.fields,l,c,n)),a==="user"&&u!==r&&!(Array.isArray(u)&&Array.isArray(r)&&u.length===r.length&&u.every((w,v)=>w===r[v]))&&xv(s.fields,n)){const w=Nv(s.fields,l,n);l=w.values,f=w.clearedKeys}const y=[];if(s.fields.forEach(w=>{const v=w.properties;v?.valueSource==="calculated"&&v?.formula&&(v.formulaSteps||[]).some(F=>F.type==="field"&&F.fieldName===n)&&y.push({field:w.name,formula:v.formula})}),y.length>0){const w=Gd.calculateAll(y,l);l={...l,...w}}}e({values:l,derivedFieldDirty:c}),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}}),s?.config.validateOnChange?t().validateField(n):e(p=>{const m={...p.errors};return delete m[n],{errors:m}})},setFieldTouched:(n,r=!0)=>{e(i=>({touched:{...i.touched,[n]:r}}));const o=t().schema;r&&o?.config.validateOnBlur&&t().validateField(n)},setFieldError:(n,r)=>{e(o=>{const i=!!o.errors[n];if(!r&&!i||r&&o.errors[n]===r)return o;const s={...o.errors};return r?s[n]=r:delete s[n],{errors:s,isValid:Object.keys(s).length===0}})},setValues:n=>{const r=t(),o=r.schema;if(!o){e({values:n});return}const i=Wa(o.fields,n,r.derivedFieldDirty);e({values:i})},setErrors:n=>{e({errors:n,isValid:Object.keys(n).length===0})},resetForm:()=>{const{initialValues:n}=t();e({values:{...n},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 n=>{const{schema:r,values:o}=t();if(!r)return;const i=r.fields.find(a=>a.name===n);if(!i)return;e({isValidating:!0});let s;if(i.validation)for(const a of i.validation){const c=Xn(o[n],a,o);if(typeof c=="string"){s=c;break}}if(!s){const a=Va(i,o[n]);a&&(s=a)}return e(a=>{const c={...a.errors};return s?c[n]=s:delete c[n],{errors:c,isValid:Object.keys(c).length===0,isValidating:!1}}),s},validateForm:async()=>{const{schema:n,values:r,visibleFields:o,requiredFields:i}=t();if(!n)return!1;e({isValidating:!0});const s={};for(const a of n.fields)if(o.has(a.name)){if(a.validation)for(const c of a.validation){if(c.type==="required"&&!i.has(a.name))continue;const u=Xn(r[a.name],c,r);if(typeof u=="string"){s[a.name]=u;break}}if(!s[a.name]){const c=Va(a,r[a.name]);c&&(s[a.name]=c)}}return e({errors:s,isValid:Object.keys(s).length===0,isValidating:!1}),Object.keys(s).length===0},validateStep:async n=>{const{schema:r,values:o,visibleFields:i}=t();if(!r||!r.steps)return!0;const s=r.steps[n];if(!s)return!0;e({isValidating:!0});const a={};for(const c of s.fields){const u=r.fields.find(l=>l.name===c);if(u&&i.has(u.name)){if(u.validation)for(const l of u.validation){const f=Xn(o[u.name],l,o);if(typeof f=="string"){a[u.name]=f;break}}if(!a[u.name]){const l=Va(u,o[u.name]);l&&(a[u.name]=l)}}}return e(c=>({errors:{...c.errors,...a},isValid:Object.keys(a).length===0,isValidating:!1})),Object.keys(a).length===0},nextStep:async()=>{const{currentStep:n,totalSteps:r,schema:o}=t();return o?.steps?.[n]?.validation==="onNext"&&!await t().validateStep(n)?!1:n<r-1?(e(s=>({currentStep:n+1,completedSteps:new Set([...s.completedSteps,n])})),!0):!1},prevStep:()=>{const{currentStep:n}=t();n>0&&e({currentStep:n-1})},goToStep:n=>{const{totalSteps:r,completedSteps:o,currentStep:i}=t();n>=0&&n<r&&(n<=i||o.has(n-1))&&e({currentStep:n})},setSubmitting:n=>e({isSubmitting:n}),incrementSubmitCount:()=>{e(n=>({submitCount:n.submitCount+1}))},updateVisibility:n=>{e(r=>{const o=new Set(n);return Ga(r.visibleFields,o)?r:{visibleFields:o}})},updateEnabled:n=>{e(r=>{const o=new Set(n);return Ga(r.enabledFields,o)?r:{enabledFields:o}})},updateRequired:n=>{e(r=>{const o=new Set(n);return Ga(r.requiredFields,o)?r:{requiredFields:o}})},updateReadOnly:n=>{e({readOnlyFields:new Set(n)})},updateEditable:n=>{e({editableFields:new Set(n)})},updateFormDisabled:n=>{e({formDisabled:n})},saveDraft:()=>{const{schema:n,values:r}=t();if(!n)return;const o=`formsmith_draft_${n.id}`;try{localStorage.setItem(o,JSON.stringify({values:r,savedAt:new Date().toISOString()})),e({draftId:o})}catch{}},loadDraft:()=>{const{schema:n}=t();if(!n)return!1;const r=`formsmith_draft_${n.id}`;try{const o=localStorage.getItem(r);if(o){const{values:i}=JSON.parse(o);return e({values:i,draftId:r}),!0}}catch{}return!1},clearDraft:()=>{const{schema:n,draftId:r}=t();if(!n)return;const o=r||`formsmith_draft_${n.id}`;try{localStorage.removeItem(o),e({draftId:null})}catch{}}}));function kv(){return Nt.getState()}function eu({schema:e,initialValues:t,onSubmit:n,onChange:r,workflowStepId:o}){const{values:i,errors:s,touched:a,isValidating:c,isSubmitting:u,submitCount:l,isValid:f,currentStep:p,totalSteps:m,completedSteps:g,visibleFields:h,enabledFields:y,requiredFields:w,setSchema:v,setFieldValue:x,setFieldTouched:C,setFieldError:F,setValues:N,resetForm:T,validateField:k,validateForm:A,validateStep:O,nextStep:E,prevStep:L,goToStep:G,setSubmitting:I,incrementSubmitCount:$,saveDraft:D,loadDraft:B,clearDraft:M}=Nt(),W=S.useRef(null);S.useLayoutEffect(()=>{if(v(e,{forceReset:!!o}),t&&Object.keys(t).length>0){const ce=Nt.getState().values;N({...ce,...t});try{W.current=JSON.stringify(t)}catch{W.current=null}}else W.current=null},[e.id,o]),S.useLayoutEffect(()=>{if(!t||Object.keys(t).length===0)return;let ce;try{ce=JSON.stringify(t)}catch{return}if(ce===W.current)return;const Xe=Nt.getState().values;N({...Xe,...t}),W.current=ce},[t,N]);const j=S.useCallback((ce,Xe)=>{const ye={...i,[ce]:Xe};x(ce,Xe),r?.(ye,ce)},[x,r,i]),ie=S.useCallback(async ce=>{if(ce?.preventDefault(),$(),!await A())return{success:!1,errors:Object.entries(s).map(([ye,Se])=>({field:ye,rule:"validation",message:Se}))};if(!n)return{success:!0};I(!0);try{const ye=await n(i);return ye.success&&M(),ye}catch(ye){return{success:!1,message:ye instanceof Error?ye.message:"Submission failed"}}finally{I(!1)}},[A,n,i,s,$,I,M]),H=S.useCallback(ce=>({value:i[ce],error:s[ce],touched:a[ce]||!1,isVisible:h.has(ce),isEnabled:y.has(ce),isRequired:w.has(ce)}),[i,s,a,h,y,w]),U=S.useMemo(()=>{if(!e.steps||e.steps.length===0)return e.fields;const ce=e.steps[p];return ce?e.fields.filter(Xe=>ce.fields.includes(Xe.name)):[]},[e,p]),J=p===0,de=p===m-1,ne=S.useCallback(ce=>g.has(ce),[g]),q=S.useMemo(()=>m<=1?100:Math.round(g.size/m*100),[g.size,m]),re=S.useCallback(ce=>h.has(ce),[h]),Te=S.useCallback(ce=>y.has(ce),[y]),Q=S.useCallback(ce=>w.has(ce),[w]),te=S.useMemo(()=>Object.entries(s).filter(([ce])=>h.has(ce)),[s,h]),ge=te.length>0;return{values:i,errors:s,touched:a,isValidating:c,isSubmitting:u,submitCount:l,isValid:f,hasErrors:ge,visibleErrors:te,currentStep:p,totalSteps:m,completedSteps:g,currentStepFields:U,isFirstStep:J,isLastStep:de,isStepCompleted:ne,progress:q,setFieldValue:j,setFieldTouched:C,setFieldError:F,setValues:N,validateField:k,getFieldState:H,shouldShowField:re,isFieldEnabled:Te,isFieldRequired:Q,handleSubmit:ie,resetForm:T,validateForm:A,validateStep:O,nextStep:E,prevStep:L,goToStep:G,saveDraft:D,loadDraft:B,clearDraft:M}}function tu(e){return"logic"in e&&"conditions"in e}function Ko(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 n=t.code;return typeof n=="number"&&n>=200&&n<300||t.data!=null&&t.status!=="error"}function nu(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;const n=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let r=e;for(const o of n){if(r==null||typeof r!="object")return;r=r[o]}return r}function Qe(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;let n=nu(e,t);if(n===void 0&&t.includes(".")){const r=t.split(".");if(r.length>=2){const o=r[0],i=r.slice(1).join("."),s=nu(e,o);Array.isArray(s)&&s.length>0&&(n=Qe(s[0],i))}}return n}const _v=new Set(["section","group","columns","divider","header","sectionHeading","spacer","textLabel","addmore","customizeSections"]);function Tv(e){return e===!0||e==="true"?!0:e===!1||e==="false"?!1:e}function Fv(e,t){if(e==null||typeof t.path!="string"||!t.path.trim())return!1;const n=Qe(e,t.path),r=Tv(t.value);switch(t.operator){case"equals":return n===r;case"notEquals":return n!==r;case"contains":return typeof n=="string"?n.includes(String(r)):Array.isArray(n)?n.includes(r):!1;case"notContains":return typeof n=="string"?!n.includes(String(r)):Array.isArray(n)?!n.includes(r):!0;case"startsWith":return typeof n=="string"&&n.startsWith(String(r));case"endsWith":return typeof n=="string"&&n.endsWith(String(r));case"greaterThan":return Number(n)>Number(r);case"lessThan":return Number(n)<Number(r);case"greaterThanOrEqual":return Number(n)>=Number(r);case"lessThanOrEqual":return Number(n)<=Number(r);case"isEmpty":return n==null?!0:typeof n=="string"?n.trim()==="":Array.isArray(n)?n.length===0:typeof n=="object"&&n!==null?Object.keys(n).length===0:!1;case"isNotEmpty":return n==null?!1:typeof n=="string"?n.trim()!=="":Array.isArray(n)?n.length>0:typeof n=="object"&&n!==null?Object.keys(n).length>0:!1;case"isTrue":return n===!0;case"isFalse":return n===!1;case"isNull":return n==null;case"isNotNull":return n!=null;case"in":return Array.isArray(r)?r.includes(n):!1;case"notIn":return Array.isArray(r)?!r.includes(n):!0;case"between":if(Array.isArray(r)&&r.length===2){const o=Number(n);return o>=Number(r[0])&&o<=Number(r[1])}return!1;case"regex":try{return new RegExp(String(r)).test(String(n??""))}catch{return!1}default:return!1}}function Pv(e,t,n){return e?e==="__allFields__"?t.filter(r=>!_v.has(r.type)).map(r=>n(r)).filter(Boolean):e==="__allButtons__"?t.filter(r=>r.type==="button"||r.type==="editButton").map(r=>n(r)).filter(Boolean):[e]:[]}function ru(e){return String(e||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_+/g,"_")}function ou(e,t){const n=ru(e)||"row",r=ru(t)||"cell";return`${n}_${r}`}function Ov(e){return e.kind==="static"?e.row.id:e.block.id}function Iv(e,t){let n=e,r=2;for(;t.has(n);)n=`${e}_${r}`,r+=1;return t.add(n),n}function iu(e,t,n,r){const o=e.cellKey?.trim();if(o)return r.add(o),e;const i=ou(t,n),s=Iv(i,r);return{...e,cellKey:s}}function su(e){const t=new Set,n=(e.rowSlots??[]).map(r=>{if(r.kind==="static"){const s=r.row.id,a={};for(const[c,u]of Object.entries(r.row.cells))a[c]=iu(u,s,c,t);return{...r,row:{...r.row,cells:a}}}const o=r.block.id,i={};for(const[s,a]of Object.entries(r.block.cells))i[s]=iu(a,o,s,t);return{...r,block:{...r.block,cells:i}}});return{...e,rowSlots:n}}function au(e){const t=new Map;for(const n of e.rowSlots??[]){const r=Ov(n),o=n.kind,i=n.kind==="static"?n.row.cells:n.block.cells;for(const[s,a]of Object.entries(i)){const c=a.cellKey?.trim()||ou(r,s);t.set(c,{slotId:r,rowKind:o,columnKey:s})}}return t}function Mv(e,t,n){return t.rowKind==="static"?e.find(r=>r.slotId===t.slotId&&r.rowKind==="static"):n?.slotId===t.slotId&&n.rowKind==="dynamic"?n:e.find(r=>r.slotId===t.slotId&&r.rowKind==="dynamic")}function lu(e,t,n,r,o){const i=n?.trim();if(!i)return 0;const a=au(e).get(i);if(a){if(o?.slotId&&a.slotId!==o.slotId||o?.rowKind&&a.rowKind!==o.rowKind)return 0;const c=Mv(t,a,r);return c?qa(c.values[a.columnKey]):0}if(r&&i in r.values)return qa(r.values[i]);if(o?.slotId){const c=t.find(u=>u.slotId===o.slotId&&(!o.rowKind||u.rowKind===o.rowKind));if(c&&i in c.values)return qa(c.values[i])}return 0}function qa(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}const cu="__fieldRef:",du="__billingCell:";function Lv(e){const t={kind:"static",staticValue:"",fieldName:"",billingFieldName:"",cellKey:""};if(e==null)return t;const n=String(e);if(n.startsWith(cu))return{...t,kind:"field",fieldName:n.slice(cu.length)};if(n.startsWith(du)){const r=n.slice(du.length),o=r.indexOf("|");return o>=0?{...t,kind:"billingCell",billingFieldName:r.slice(0,o),cellKey:r.slice(o+1)}:{...t,kind:"billingCell",cellKey:r}}if(n.startsWith("field:"))return{...t,kind:"field",fieldName:n.slice(6)};if(n.startsWith("billing:")){const r=n.slice(8),o=r.indexOf("|");return o>=0?{...t,kind:"billingCell",billingFieldName:r.slice(0,o),cellKey:r.slice(o+1)}:{...t,kind:"billingCell",cellKey:r}}return{...t,kind:"static",staticValue:n}}function Ya(e){return e.name||e.key||e.id}function Dv(e,t){const n=t.find(r=>r.id===e||r.name===e||r.key===e);return n?Ya(n):e}function Bv(e,t,n,r){const o=t.trim();if(!o)return;const i=r.filter(a=>a.type==="billingGrid"),s=e?.trim()?i.filter(a=>Ya(a)===e||a.name===e||a.id===e):i;for(const a of s){const c=su(a.properties??{}),u=n[Ya(a)];if(!u?.rows?.length)continue;const f=au(c).get(o);if(!f)continue;const p=u.rows.find(m=>f.rowKind==="static"?m.slotId===f.slotId&&m.rowKind==="static":m.slotId===f.slotId&&m.rowKind==="dynamic");if(p)return p.values[f.columnKey]}}function $v(e,t,n){const r=Lv(e);if(r.kind==="field"){const o=Dv(r.fieldName,n);return t[o]}return r.kind==="billingCell"?Bv(r.billingFieldName,r.cellKey,t,n):r.staticValue}function uu(e,t){if(e===t)return!0;if(e==null||t===void 0||t===null)return!1;const n=Number(e),r=Number(t);return!Number.isNaN(n)&&!Number.isNaN(r)&&String(e).trim()!==""&&String(t).trim()!==""?n===r:String(e).trim()===String(t).trim()}const fu="__buttonResponse:";function jv({fields:e,values:t,buttonResponses:n,prepopulateResponse:r=null,prepopulateResponseRules:o}){const{updateVisibility:i,updateEnabled:s,updateRequired:a,updateReadOnly:c,updateEditable:u,updateFormDisabled:l}=Nt(),f=S.useCallback(N=>N.name||N.key||N.id,[]),p=S.useCallback((N,T)=>{if(!N)return f(T);const k=e.find(A=>A.id===N||A.name===N||A.key===N);return k?f(k):N},[e,f]),m=S.useCallback(N=>{const T=e.find(k=>k.id===N||k.name===N||k.key===N);return T?f(T):N},[e,f]),g=S.useCallback(N=>{const{field:T,operator:k,value:A}=N;if(typeof T=="string"&&T.startsWith(fu)){const G=T.slice(fu.length),I=n?.[G],$=Ko(I);return A==="success"?$:A==="failure"?I!=null&&!$:!1}const O=m(T),E=t[O],L=$v(A,t,e);switch(k){case"equals":return uu(E,L);case"notEquals":return!uu(E,L);case"contains":return typeof E=="string"?E.includes(String(L)):Array.isArray(E)?E.includes(L):!1;case"notContains":return typeof E=="string"?!E.includes(String(L)):Array.isArray(E)?!E.includes(L):!0;case"startsWith":return typeof E=="string"&&E.startsWith(String(L));case"endsWith":return typeof E=="string"&&E.endsWith(String(L));case"greaterThan":return Number(E)>Number(L);case"lessThan":return Number(E)<Number(L);case"greaterThanOrEqual":return Number(E)>=Number(L);case"lessThanOrEqual":return Number(E)<=Number(L);case"isEmpty":return E==null?!0:E instanceof File?!1:typeof E=="string"?E.trim()==="":Array.isArray(E)?(E.length>0&&E[0]instanceof File,E.length===0):typeof E=="object"&&E!==null?Object.keys(E).length===0:!1;case"isNotEmpty":return E==null?!1:E instanceof File?!0:typeof E=="string"?E.trim()!=="":Array.isArray(E)?(E.length>0&&E[0]instanceof File,E.length>0):typeof E=="object"&&E!==null?Object.keys(E).length>0:!1;case"isTrue":return E===!0;case"isFalse":return E===!1;case"isNull":return E==null;case"isNotNull":return E!=null;case"in":return Array.isArray(L)?L.includes(E):!1;case"notIn":return Array.isArray(L)?!L.includes(E):!0;case"between":if(Array.isArray(L)&&L.length===2){const G=Number(E);return G>=Number(L[0])&&G<=Number(L[1])}return!1;case"regex":try{return new RegExp(String(L)).test(String(E))}catch{return!1}default:return!0}},[t,m,n,e]),h=S.useCallback(N=>{const T=N.conditions.map(k=>tu(k)?h(k):g(k));return N.logic==="and"?T.every(Boolean):T.some(Boolean)},[g]),y=S.useCallback(N=>tu(N)?h(N):g(N),[g,h]),w=S.useCallback(()=>{const N=new Set,T=new Set,k=new Set,A=new Set,O=new Set;e.forEach(I=>{const $=f(I);I.hidden||N.add($),I.disabled||T.add($),I.validation?.some(D=>D.type==="required")&&k.add($)});let E=!1;if(r!=null&&o?.length)for(const I of o){if(!Fv(r,I.when))continue;const{action:$,target:D}=I.then;if($==="disableForm")E=!0;else if($==="enableForm")E=!1;else{const B=Pv(D,e,f);for(const M of B)switch($){case"disable":T.delete(M);break;case"enable":T.add(M);break;case"hide":N.delete(M);break;case"show":N.add(M);break;case"readOnly":A.add(M),O.delete(M);break;case"editable":O.add(M),A.delete(M);break}}}e.forEach(I=>{I.conditions&&I.conditions.forEach($=>{(y($.when)?$.then:$.else||[]).forEach(M=>{switch(M.action){case"disableForm":E=!0;break;case"enableForm":E=!1;break;default:{const W=p(M.target,I);switch(M.action){case"show":N.add(W);break;case"hide":N.delete(W);break;case"enable":T.add(W);break;case"disable":T.delete(W);break;case"require":k.add(W);break;case"unrequire":k.delete(W);break}break}}})})});const L=I=>e.filter($=>$.type!=="editButton"&&($.name||$.key||$.id)).map($=>f($)),G=()=>e.filter(I=>I.type==="button").map(I=>f(I));return e.forEach(I=>{if(I.type!=="editButton")return;const $=f(I);if(!Ko(n?.[$]))return;const D=I.properties;D?.rules&&D.rules.length>0?D.rules.forEach(B=>{const M=[];B.allFields&&M.push(...L(I.id)),B.allButtons&&M.push(...G()),B.fieldNames?.length&&B.fieldNames.forEach(W=>{const j=e.find(ie=>f(ie)===W||ie.id===W||ie.name===W);M.push(j?f(j):W)}),B.buttonNames?.length&&M.push(...B.buttonNames),M.forEach(W=>{switch(B.action){case"enable":T.add(W),A.delete(W);break;case"disable":T.delete(W);break;case"show":N.add(W);break;case"hide":N.delete(W);break;case"readOnly":A.add(W);break;case"editable":O.add(W);break}})}):((D?.enableFieldNames??[]).forEach(B=>T.add(B)),(D?.disableFieldNames??[]).forEach(B=>T.delete(B)),(D?.showFieldNames??[]).forEach(B=>N.add(B)),(D?.hideFieldNames??[]).forEach(B=>N.delete(B)))}),{visible:Array.from(N),enabled:Array.from(T),required:Array.from(k),readOnly:Array.from(A),editable:Array.from(O),formDisabled:E}},[e,y,f,p,t,n,r,o]),v=S.useMemo(()=>w(),[w]);S.useLayoutEffect(()=>{i(v.visible),s(v.enabled),a(v.required),c(v.readOnly??[]),u(v.editable??[]),l(v.formDisabled??!1)},[v,i,s,a,c,u,l]);const x=S.useCallback(N=>v.visible.includes(N),[v.visible]),C=S.useCallback(N=>v.enabled.includes(N),[v.enabled]),F=S.useCallback(N=>v.required.includes(N),[v.required]);return{evaluateCondition:y,evaluateExpression:g,evaluateGroup:h,isFieldVisible:x,isFieldEnabled:C,isFieldRequired:F,visibleFields:v.visible,enabledFields:v.enabled,requiredFields:v.required}}function Cr({className:e,type:t,...n}){return d.jsx("input",{type:t,"data-slot":"input",className:z("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),...n})}function pu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ur(...e){return t=>{let n=!1;const r=e.map(o=>{const i=pu(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():pu(e[o],null)}}}}function Ze(...e){return b.useCallback(Ur(...e),e)}var zv=Symbol.for("react.lazy"),Ki=b[" use ".trim().toString()];function Vv(e){return typeof e=="object"&&e!==null&&"then"in e}function mu(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===zv&&"_payload"in e&&Vv(e._payload)}function Xa(e){const t=Uv(e),n=b.forwardRef((r,o)=>{let{children:i,...s}=r;mu(i)&&typeof Ki=="function"&&(i=Ki(i._payload));const a=b.Children.toArray(i),c=a.find(Wv);if(c){const u=c.props.children,l=a.map(f=>f===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return d.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}var hu=Xa("Slot");function Uv(e){const t=b.forwardRef((n,r)=>{let{children:o,...i}=n;if(mu(o)&&typeof Ki=="function"&&(o=Ki(o._payload)),b.isValidElement(o)){const s=Kv(o),a=Rv(i,o.props);return o.type!==b.Fragment&&(a.ref=r?Ur(r,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Hv=Symbol("radix.slottable");function Wv(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Hv}function Rv(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Kv(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?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"],qv=Gv.reduce((e,t)=>{const n=Xa(`Primitive.${t}`),r=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,c=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Yv="Label",gu=b.forwardRef((e,t)=>d.jsx(qv.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));gu.displayName=Yv;var Xv=gu;function Er({className:e,...t}){return d.jsx(Xv,{"data-slot":"label",className:z("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 Gi(e){return`formsmith-label-${e.id}`}function Go(e){return`formsmith-desc-${e.id}`}function qo(e){return`formsmith-error-${e.id}`}function $t(e,t){const n=[];return e.description&&n.push(Go(e)),t&&n.push(qo(e)),n.length>0?n.join(" "):void 0}function Qt(e){return e?!0:void 0}const Jv={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 Nr(e){return e.ui?.cellStyle}function Qv(e){const t=e.ui;if(!t)return;const n=t.fontToken?Jv[t.fontToken]:void 0;if(!(!n&&!t.wrapperStyle))return{...n,...t.wrapperStyle}}function Zv(e){return e.type==="button"||e.type==="editButton"}const Et=({field:e,error:t,isRequired:n,children:r,className:o,hideLabel:i})=>{const{gridStretch:s}=Ro(),a=s&&zi(e),c=!(i??e.appearance?.hideLabel)&&e.label,u=e.appearance?.labelPlacement||"top",l=Qv(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=jd(e),g=oo(e),h=Zv(e),y=kn(e.appearance);return d.jsx("div",{className:z(Yb(u),u!=="floating"&&"space-y-2",a&&!h&&"flex-1 min-h-0 h-full",s&&h&&"w-full shrink-0 self-start",p,o),style:l,"data-field-appearance":u,children:d.jsxs("div",{className:z("flex flex-col min-w-0",Ld(e.appearance),zd(e),a&&!h&&"flex-1 min-h-0",s&&h&&"shrink-0"),style:m,children:[c&&d.jsxs(Er,{id:Gi(e),htmlFor:ht(e),style:e.ui?.labelStyle,className:z(Xb(u,!!t)),children:[e.label,n&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),d.jsxs("div",{className:z(Jb(u),h&&s&&"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:[r,d.jsxs("div",{className:z("mt-1.5 min-h-[18px]",u==="center"&&"text-center",o?.includes("flex")&&"shrink-0"),children:[e.description&&!t&&d.jsx("p",{id:Go(e),className:"text-xs text-muted-foreground",style:e.ui?.descriptionStyle,children:e.description}),t&&d.jsx("p",{id:qo(e),className:"text-xs text-destructive",role:"alert",children:typeof t=="string"?t:String(t||"An error occurred")})]})]})]})})},qi=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=e.properties,l=S.useCallback(f=>{n(f.target.value)},[n]);return d.jsx(Et,{field:e,error:o,isRequired:a,className:c,children:d.jsx(Cr,{id:ht(e),type:"text",value:t||"",onChange:l,onBlur:r,placeholder:e.placeholder,disabled:i||e.disabled,readOnly:s||e.readOnly,minLength:u?.minLength,maxLength:u?.maxLength,pattern:u?.pattern,autoComplete:u?.autoComplete,inputMode:u?.inputMode,"aria-describedby":$t(e,!!o),"aria-invalid":Qt(!!o),"aria-required":a,className:z(Uo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})})},Ja=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{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===""){n(null);return}const w=parseFloat(y);isNaN(w)||n(w)},[n,u?.allowNegative,l]),p=S.useCallback(m=>{(m.key==="ArrowUp"||m.key==="ArrowDown"||m.key==="PageUp"||m.key==="PageDown")&&m.preventDefault()},[]);return d.jsx(Et,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[u?.prefix&&d.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.prefix}),d.jsx(Cr,{id:ht(e),type:"text",inputMode:l?"decimal":"numeric",autoComplete:"off",value:t??"",onChange:f,onKeyDown:p,onBlur:r,placeholder:e.placeholder,disabled:i||e.disabled,readOnly:s||e.readOnly,"aria-describedby":$t(e,!!o),"aria-invalid":Qt(!!o),"aria-required":a,className:z(Uo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",u?.prefix&&"pl-8",u?.suffix&&"pr-8",e.appearance?.className)}),u?.suffix&&d.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.suffix})]})})};const ew=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),tw=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),yu=e=>{const t=tw(e);return t.charAt(0).toUpperCase()+t.slice(1)},bu=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),nw=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var rw={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 ow=S.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:s,...a},c)=>S.createElement("svg",{ref:c,...rw,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:bu("lucide",o),...!i&&!nw(a)&&{"aria-hidden":"true"},...a},[...s.map(([u,l])=>S.createElement(u,l)),...Array.isArray(i)?i:[i]]));const Kt=(e,t)=>{const n=S.forwardRef(({className:r,...o},i)=>S.createElement(ow,{ref:i,iconNode:t,className:bu(`lucide-${ew(yu(e))}`,`lucide-${e}`,r),...o}));return n.displayName=yu(e),n};const iw=Kt("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 Yi=Kt("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 Xi=Kt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Yo=Kt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const vu=Kt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const sw=Kt("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const aw=Kt("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 wu=Kt("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Su=Kt("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 xu=Kt("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 so=Kt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const lw=Kt("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 cw=Kt("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 Au=Kt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const dw=Kt("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 Cu=Kt("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 Xo=Kt("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 Ji=Kt("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 Jo=Kt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Eu=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=S.useCallback(l=>{n(l.target.value)},[n]);return d.jsx(Et,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[d.jsx(lw,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),d.jsx(Cr,{id:ht(e),type:"email",value:t||"",onChange:u,onBlur:r,placeholder:e.placeholder||"email@example.com",disabled:i||e.disabled,readOnly:s||e.readOnly,autoComplete:"email",inputMode:"email","aria-describedby":$t(e,!!o),"aria-invalid":Qt(!!o),"aria-required":a,className:z(Uo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})},Nu=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=S.useCallback(l=>{const f=l.target.value.replace(/[^\d\s+\-()]/g,"");n(f)},[n]);return d.jsx(Et,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[d.jsx(cw,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),d.jsx(Cr,{id:ht(e),type:"tel",value:t||"",onChange:u,onBlur:r,placeholder:e.placeholder||"+91 12345 67890",disabled:i||e.disabled,readOnly:s||e.readOnly,autoComplete:"tel",inputMode:"tel","aria-describedby":$t(e,!!o),"aria-invalid":Qt(!!o),"aria-required":a,className:z(Uo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})};function uw({className:e,maxLength:t,showCharacterCount:n=!1,autoResize:r=!1,onChange:o,value:i,...s}){const a=b.useRef(null),[c,u]=b.useState(0),l=f=>{const p=f.target.value;u(p.length),r&&a.current&&(a.current.style.height="auto",a.current.style.height=`${a.current.scrollHeight}px`),o&&o(f)};return b.useEffect(()=>{i&&u(String(i).length)},[i]),d.jsxs("div",{className:"space-y-1",children:[d.jsx("textarea",{ref:a,"data-slot":"textarea",className:z("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",r&&"resize-none",e),maxLength:t,onChange:l,value:i,...s}),n&&d.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[d.jsxs("span",{children:[c," characters"]}),t&&d.jsxs("span",{children:[t-c," remaining"]})]})]})}const ku=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const{gridStretch:u}=Ro(),l=u&&zi(e),f=e.properties,p=S.useCallback(y=>{n(y.target.value)},[n]),m=(t||"").length,g=f?.maxLength,h=g&&g>0;return d.jsx(Et,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:z("relative flex flex-col",l&&"flex-1 min-h-0"),children:[d.jsx(uw,{id:ht(e),value:t||"",onChange:p,onBlur:r,placeholder:e.placeholder,disabled:i||e.disabled,readOnly:s||e.readOnly,minLength:f?.minLength,maxLength:f?.maxLength,rows:2,"aria-describedby":$t(e,!!o),"aria-invalid":Qt(!!o),"aria-required":a,className:z(Od(e.appearance),"resize-y",l&&"min-h-[120px] flex-1 flex-shrink-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),h&&d.jsxs("span",{className:"absolute bottom-2 right-2 text-xs text-muted-foreground",children:[m,"/",g]})]})})};function Qo(e,[t,n]){return Math.min(n,Math.max(t,e))}function Le(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function fw(e,t){const n=b.createContext(t),r=i=>{const{children:s,...a}=i,c=b.useMemo(()=>a,Object.values(a));return d.jsx(n.Provider,{value:c,children:s})};r.displayName=e+"Provider";function o(i){const s=b.useContext(n);if(s)return s;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,o]}function Sn(e,t=[]){let n=[];function r(i,s){const a=b.createContext(s),c=n.length;n=[...n,s];const u=f=>{const{scope:p,children:m,...g}=f,h=p?.[e]?.[c]||a,y=b.useMemo(()=>g,Object.values(g));return d.jsx(h.Provider,{value:y,children:m})};u.displayName=i+"Provider";function l(f,p){const m=p?.[e]?.[c]||a,g=b.useContext(m);if(g)return g;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return[u,l]}const o=()=>{const i=n.map(s=>b.createContext(s));return function(a){const c=a?.[e]||i;return b.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,pw(o,...t)]}function pw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:c,scopeName:u})=>{const f=c(i)[`__scope${u}`];return{...a,...f}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function _u(e){const t=mw(e),n=b.forwardRef((r,o)=>{const{children:i,...s}=r,a=b.Children.toArray(i),c=a.find(gw);if(c){const u=c.props.children,l=a.map(f=>f===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return d.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function mw(e){const t=b.forwardRef((n,r)=>{const{children:o,...i}=n;if(b.isValidElement(o)){const s=bw(o),a=yw(i,o.props);return o.type!==b.Fragment&&(a.ref=r?Ur(r,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var hw=Symbol("radix.slottable");function gw(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===hw}function yw(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function bw(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Qa(e){const t=e+"CollectionProvider",[n,r]=Sn(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=h=>{const{scope:y,children:w}=h,v=S.useRef(null),x=S.useRef(new Map).current;return d.jsx(o,{scope:y,itemMap:x,collectionRef:v,children:w})};s.displayName=t;const a=e+"CollectionSlot",c=_u(a),u=S.forwardRef((h,y)=>{const{scope:w,children:v}=h,x=i(a,w),C=Ze(y,x.collectionRef);return d.jsx(c,{ref:C,children:v})});u.displayName=a;const l=e+"CollectionItemSlot",f="data-radix-collection-item",p=_u(l),m=S.forwardRef((h,y)=>{const{scope:w,children:v,...x}=h,C=S.useRef(null),F=Ze(y,C),N=i(l,w);return S.useEffect(()=>(N.itemMap.set(C,{ref:C,...x}),()=>{N.itemMap.delete(C)})),d.jsx(p,{[f]:"",ref:F,children:v})});m.displayName=l;function g(h){const y=i(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,T)=>x.indexOf(N.ref.current)-x.indexOf(T.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:s,Slot:u,ItemSlot:m},g,r]}var vw=b.createContext(void 0);function ao(e){const t=b.useContext(vw);return e||t||"ltr"}function ww(e){const t=Sw(e),n=b.forwardRef((r,o)=>{const{children:i,...s}=r,a=b.Children.toArray(i),c=a.find(Aw);if(c){const u=c.props.children,l=a.map(f=>f===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return d.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function Sw(e){const t=b.forwardRef((n,r)=>{const{children:o,...i}=n;if(b.isValidElement(o)){const s=Ew(o),a=Cw(i,o.props);return o.type!==b.Fragment&&(a.ref=r?Ur(r,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var xw=Symbol("radix.slottable");function Aw(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xw}function Cw(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Ew(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Nw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$e=Nw.reduce((e,t)=>{const n=ww(`Primitive.${t}`),r=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,c=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function kw(e,t){e&&Oi.flushSync(()=>e.dispatchEvent(t))}function sn(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>(...n)=>t.current?.(...n),[])}function _w(e,t=globalThis?.document){const n=sn(e);b.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Tw="DismissableLayer",Za="dismissableLayer.update",Fw="dismissableLayer.pointerDownOutside",Pw="dismissableLayer.focusOutside",Tu,Fu=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Qi=b.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:a,...c}=e,u=b.useContext(Fu),[l,f]=b.useState(null),p=l?.ownerDocument??globalThis?.document,[,m]=b.useState({}),g=Ze(t,T=>f(T)),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,C=v>=w,F=Mw(T=>{const k=T.target,A=[...u.branches].some(O=>O.contains(k));!C||A||(o?.(T),s?.(T),T.defaultPrevented||a?.())},p),N=Lw(T=>{const k=T.target;[...u.branches].some(O=>O.contains(k))||(i?.(T),s?.(T),T.defaultPrevented||a?.())},p);return _w(T=>{v===u.layers.size-1&&(r?.(T),!T.defaultPrevented&&a&&(T.preventDefault(),a()))},p),b.useEffect(()=>{if(l)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Tu=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(l)),u.layers.add(l),Pu(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=Tu)}},[l,p,n,u]),b.useEffect(()=>()=>{l&&(u.layers.delete(l),u.layersWithOutsidePointerEventsDisabled.delete(l),Pu())},[l,u]),b.useEffect(()=>{const T=()=>m({});return document.addEventListener(Za,T),()=>document.removeEventListener(Za,T)},[]),d.jsx($e.div,{...c,ref:g,style:{pointerEvents:x?C?"auto":"none":void 0,...e.style},onFocusCapture:Le(e.onFocusCapture,N.onFocusCapture),onBlurCapture:Le(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Le(e.onPointerDownCapture,F.onPointerDownCapture)})});Qi.displayName=Tw;var Ow="DismissableLayerBranch",Iw=b.forwardRef((e,t)=>{const n=b.useContext(Fu),r=b.useRef(null),o=Ze(t,r);return b.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),d.jsx($e.div,{...e,ref:o})});Iw.displayName=Ow;function Mw(e,t=globalThis?.document){const n=sn(e),r=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const i=a=>{if(a.target&&!r.current){let c=function(){Ou(Fw,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Lw(e,t=globalThis?.document){const n=sn(e),r=b.useRef(!1);return b.useEffect(()=>{const o=i=>{i.target&&!r.current&&Ou(Pw,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Pu(){const e=new CustomEvent(Za);document.dispatchEvent(e)}function Ou(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?kw(o,i):o.dispatchEvent(i)}var el=0;function tl(){b.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Iu()),document.body.insertAdjacentElement("beforeend",e[1]??Iu()),el++,()=>{el===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),el--}},[])}function Iu(){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 nl="focusScope.autoFocusOnMount",rl="focusScope.autoFocusOnUnmount",Mu={bubbles:!1,cancelable:!0},Dw="FocusScope",Zi=b.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=e,[a,c]=b.useState(null),u=sn(o),l=sn(i),f=b.useRef(null),p=Ze(t,h=>c(h)),m=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let h=function(x){if(m.paused||!a)return;const C=x.target;a.contains(C)?f.current=C:kr(f.current,{select:!0})},y=function(x){if(m.paused||!a)return;const C=x.relatedTarget;C!==null&&(a.contains(C)||kr(f.current,{select:!0}))},w=function(x){if(document.activeElement===document.body)for(const F of x)F.removedNodes.length>0&&kr(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()}}},[r,a,m.paused]),b.useEffect(()=>{if(a){Bu.add(m);const h=document.activeElement;if(!a.contains(h)){const w=new CustomEvent(nl,Mu);a.addEventListener(nl,u),a.dispatchEvent(w),w.defaultPrevented||(Bw(Uw(Lu(a)),{select:!0}),document.activeElement===h&&kr(a))}return()=>{a.removeEventListener(nl,u),setTimeout(()=>{const w=new CustomEvent(rl,Mu);a.addEventListener(rl,l),a.dispatchEvent(w),w.defaultPrevented||kr(h??document.body,{select:!0}),a.removeEventListener(rl,l),Bu.remove(m)},0)}}},[a,u,l,m]);const g=b.useCallback(h=>{if(!n&&!r||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,C]=$w(v);x&&C?!h.shiftKey&&w===C?(h.preventDefault(),n&&kr(x,{select:!0})):h.shiftKey&&w===x&&(h.preventDefault(),n&&kr(C,{select:!0})):w===v&&h.preventDefault()}},[n,r,m.paused]);return d.jsx($e.div,{tabIndex:-1,...s,ref:p,onKeyDown:g})});Zi.displayName=Dw;function Bw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(kr(r,{select:t}),document.activeElement!==n)return}function $w(e){const t=Lu(e),n=Du(t,e),r=Du(t.reverse(),e);return[n,r]}function Lu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Du(e,t){for(const n of e)if(!jw(n,{upTo:t}))return n}function jw(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 zw(e){return e instanceof HTMLInputElement&&"select"in e}function kr(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&zw(e)&&t&&e.select()}}var Bu=Vw();function Vw(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=$u(e,t),e.unshift(t)},remove(t){e=$u(e,t),e[0]?.resume()}}}function $u(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Uw(e){return e.filter(t=>t.tagName!=="A")}var Zt=globalThis?.document?b.useLayoutEffect:()=>{},Hw=b[" useId ".trim().toString()]||(()=>{}),Ww=0;function lr(e){const[t,n]=b.useState(Hw());return Zt(()=>{n(r=>r??String(Ww++))},[e]),e||(t?`radix-${t}`:"")}const Rw=["top","right","bottom","left"],_r=Math.min,xn=Math.max,es=Math.round,ts=Math.floor,Jn=e=>({x:e,y:e}),Kw={left:"right",right:"left",bottom:"top",top:"bottom"};function ol(e,t,n){return xn(e,_r(t,n))}function cr(e,t){return typeof e=="function"?e(t):e}function dr(e){return e.split("-")[0]}function lo(e){return e.split("-")[1]}function il(e){return e==="x"?"y":"x"}function sl(e){return e==="y"?"height":"width"}function Qn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function al(e){return il(Qn(e))}function Gw(e,t,n){n===void 0&&(n=!1);const r=lo(e),o=al(e),i=sl(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=ns(s)),[s,ns(s)]}function qw(e){const t=ns(e);return[ll(e),t,ll(t)]}function ll(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const ju=["left","right"],zu=["right","left"],Yw=["top","bottom"],Xw=["bottom","top"];function Jw(e,t,n){switch(e){case"top":case"bottom":return n?t?zu:ju:t?ju:zu;case"left":case"right":return t?Yw:Xw;default:return[]}}function Qw(e,t,n,r){const o=lo(e);let i=Jw(dr(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(ll)))),i}function ns(e){const t=dr(e);return Kw[t]+e.slice(t.length)}function Zw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Vu(e){return typeof e!="number"?Zw(e):{top:e,right:e,bottom:e,left:e}}function rs(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Uu(e,t,n){let{reference:r,floating:o}=e;const i=Qn(t),s=al(t),a=sl(s),c=dr(t),u=i==="y",l=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let m;switch(c){case"top":m={x:l,y:r.y-o.height};break;case"bottom":m={x:l,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(lo(t)){case"start":m[s]-=p*(n&&u?-1:1);break;case"end":m[s]+=p*(n&&u?-1:1);break}return m}async function eS(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:l="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=cr(t,e),g=Vu(m),y=a[p?f==="floating"?"reference":"floating":f],w=rs(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:u,rootBoundary:l,strategy:c})),v=f==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),C=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},F=rs(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:x,strategy:c}):v);return{top:(w.top-F.top+g.top)/C.y,bottom:(F.bottom-w.bottom+g.bottom)/C.y,left:(w.left-F.left+g.left)/C.x,right:(F.right-w.right+g.right)/C.x}}const tS=50,nS=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,a=s.detectOverflow?s:{...s,detectOverflow:eS},c=await(s.isRTL==null?void 0:s.isRTL(t));let u=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:l,y:f}=Uu(u,r,c),p=r,m=0;const g={};for(let h=0;h<i.length;h++){const y=i[h];if(!y)continue;const{name:w,fn:v}=y,{x,y:C,data:F,reset:N}=await v({x:l,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:g,rects:u,platform:a,elements:{reference:e,floating:t}});l=x??l,f=C??f,g[w]={...g[w],...F},N&&m<tS&&(m++,typeof N=="object"&&(N.placement&&(p=N.placement),N.rects&&(u=N.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):N.rects),{x:l,y:f}=Uu(u,p,c)),h=-1)}return{x:l,y:f,placement:p,strategy:o,middlewareData:g}},rS=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:a,middlewareData:c}=t,{element:u,padding:l=0}=cr(e,t)||{};if(u==null)return{};const f=Vu(l),p={x:n,y:r},m=al(o),g=sl(m),h=await s.getDimensions(u),y=m==="y",w=y?"top":"left",v=y?"bottom":"right",x=y?"clientHeight":"clientWidth",C=i.reference[g]+i.reference[m]-p[m]-i.floating[g],F=p[m]-i.reference[m],N=await(s.getOffsetParent==null?void 0:s.getOffsetParent(u));let T=N?N[x]:0;(!T||!await(s.isElement==null?void 0:s.isElement(N)))&&(T=a.floating[x]||i.floating[g]);const k=C/2-F/2,A=T/2-h[g]/2-1,O=_r(f[w],A),E=_r(f[v],A),L=O,G=T-h[g]-E,I=T/2-h[g]/2+k,$=ol(L,I,G),D=!c.arrow&&lo(o)!=null&&I!==$&&i.reference[g]/2-(I<L?O:E)-h[g]/2<0,B=D?I<L?I-L:I-G:0;return{[m]:p[m]+B,data:{[m]:$,centerOffset:I-$-B,...D&&{alignmentOffset:B}},reset:D}}}),oS=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:l=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...y}=cr(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=dr(o),v=Qn(a),x=dr(a)===a,C=await(c.isRTL==null?void 0:c.isRTL(u.floating)),F=p||(x||!h?[ns(a)]:qw(a)),N=g!=="none";!p&&N&&F.push(...Qw(a,h,g,C));const T=[a,...F],k=await c.detectOverflow(t,y),A=[];let O=((r=i.flip)==null?void 0:r.overflows)||[];if(l&&A.push(k[w]),f){const I=Gw(o,s,C);A.push(k[I[0]],k[I[1]])}if(O=[...O,{placement:o,overflows:A}],!A.every(I=>I<=0)){var E,L;const I=(((E=i.flip)==null?void 0:E.index)||0)+1,$=T[I];if($&&(!(f==="alignment"?v!==Qn($):!1)||O.every(M=>Qn(M.placement)===v?M.overflows[0]>0:!0)))return{data:{index:I,overflows:O},reset:{placement:$}};let D=(L=O.filter(B=>B.overflows[0]<=0).sort((B,M)=>B.overflows[1]-M.overflows[1])[0])==null?void 0:L.placement;if(!D)switch(m){case"bestFit":{var G;const B=(G=O.filter(M=>{if(N){const W=Qn(M.placement);return W===v||W==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(W=>W>0).reduce((W,j)=>W+j,0)]).sort((M,W)=>M[1]-W[1])[0])==null?void 0:G[0];B&&(D=B);break}case"initialPlacement":D=a;break}if(o!==D)return{reset:{placement:D}}}return{}}}};function Hu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Wu(e){return Rw.some(t=>e[t]>=0)}const iS=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=cr(e,t);switch(o){case"referenceHidden":{const s=await r.detectOverflow(t,{...i,elementContext:"reference"}),a=Hu(s,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Wu(a)}}}case"escaped":{const s=await r.detectOverflow(t,{...i,altBoundary:!0}),a=Hu(s,n.floating);return{data:{escapedOffsets:a,escaped:Wu(a)}}}default:return{}}}}},Ru=new Set(["left","top"]);async function sS(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=dr(n),a=lo(n),c=Qn(n)==="y",u=Ru.has(s)?-1:1,l=i&&c?-1:1,f=cr(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),c?{x:m*l,y:p*u}:{x:p*u,y:m*l}}const aS=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:a}=t,c=await sS(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:i+c.y,data:{...c,placement:s}}}}},lS=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:i}=t,{mainAxis:s=!0,crossAxis:a=!1,limiter:c={fn:w=>{let{x:v,y:x}=w;return{x:v,y:x}}},...u}=cr(e,t),l={x:n,y:r},f=await i.detectOverflow(t,u),p=Qn(dr(o)),m=il(p);let g=l[m],h=l[p];if(s){const w=m==="y"?"top":"left",v=m==="y"?"bottom":"right",x=g+f[w],C=g-f[v];g=ol(x,g,C)}if(a){const w=p==="y"?"top":"left",v=p==="y"?"bottom":"right",x=h+f[w],C=h-f[v];h=ol(x,h,C)}const y=c.fn({...t,[m]:g,[p]:h});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[m]:s,[p]:a}}}}}},cS=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:a=0,mainAxis:c=!0,crossAxis:u=!0}=cr(e,t),l={x:n,y:r},f=Qn(o),p=il(f);let m=l[p],g=l[f];const h=cr(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){const x=p==="y"?"height":"width",C=i.reference[p]-i.floating[x]+y.mainAxis,F=i.reference[p]+i.reference[x]-y.mainAxis;m<C?m=C:m>F&&(m=F)}if(u){var w,v;const x=p==="y"?"width":"height",C=Ru.has(dr(o)),F=i.reference[f]-i.floating[x]+(C&&((w=s.offset)==null?void 0:w[f])||0)+(C?0:y.crossAxis),N=i.reference[f]+i.reference[x]+(C?0:((v=s.offset)==null?void 0:v[f])||0)-(C?y.crossAxis:0);g<F?g=F:g>N&&(g=N)}return{[p]:m,[f]:g}}}},dS=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:s,elements:a}=t,{apply:c=()=>{},...u}=cr(e,t),l=await s.detectOverflow(t,u),f=dr(o),p=lo(o),m=Qn(o)==="y",{width:g,height:h}=i.floating;let y,w;f==="top"||f==="bottom"?(y=f,w=p===(await(s.isRTL==null?void 0:s.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,C=_r(h-l[y],v),F=_r(g-l[w],x),N=!t.middlewareData.shift;let T=C,k=F;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(k=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(T=v),N&&!p){const O=xn(l.left,0),E=xn(l.right,0),L=xn(l.top,0),G=xn(l.bottom,0);m?k=g-2*(O!==0||E!==0?O+E:xn(l.left,l.right)):T=h-2*(L!==0||G!==0?L+G:xn(l.top,l.bottom))}await c({...t,availableWidth:k,availableHeight:T});const A=await s.getDimensions(a.floating);return g!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}};function os(){return typeof window<"u"}function co(e){return Ku(e)?(e.nodeName||"").toLowerCase():"#document"}function An(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Zn(e){var t;return(t=(Ku(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ku(e){return os()?e instanceof Node||e instanceof An(e).Node:!1}function Bn(e){return os()?e instanceof Element||e instanceof An(e).Element:!1}function ur(e){return os()?e instanceof HTMLElement||e instanceof An(e).HTMLElement:!1}function Gu(e){return!os()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof An(e).ShadowRoot}function Zo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=$n(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function uS(e){return/^(table|td|th)$/.test(co(e))}function is(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const fS=/transform|translate|scale|rotate|perspective|filter/,pS=/paint|layout|strict|content/,Hr=e=>!!e&&e!=="none";let cl;function dl(e){const t=Bn(e)?$n(e):e;return Hr(t.transform)||Hr(t.translate)||Hr(t.scale)||Hr(t.rotate)||Hr(t.perspective)||!ul()&&(Hr(t.backdropFilter)||Hr(t.filter))||fS.test(t.willChange||"")||pS.test(t.contain||"")}function mS(e){let t=Tr(e);for(;ur(t)&&!uo(t);){if(dl(t))return t;if(is(t))return null;t=Tr(t)}return null}function ul(){return cl==null&&(cl=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),cl}function uo(e){return/^(html|body|#document)$/.test(co(e))}function $n(e){return An(e).getComputedStyle(e)}function ss(e){return Bn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Tr(e){if(co(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Gu(e)&&e.host||Zn(e);return Gu(t)?t.host:t}function qu(e){const t=Tr(e);return uo(t)?e.ownerDocument?e.ownerDocument.body:e.body:ur(t)&&Zo(t)?t:qu(t)}function ei(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=qu(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=An(o);if(i){const a=fl(s);return t.concat(s,s.visualViewport||[],Zo(o)?o:[],a&&n?ei(a):[])}else return t.concat(o,ei(o,[],n))}function fl(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Yu(e){const t=$n(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=ur(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,a=es(n)!==i||es(r)!==s;return a&&(n=i,r=s),{width:n,height:r,$:a}}function pl(e){return Bn(e)?e:e.contextElement}function fo(e){const t=pl(e);if(!ur(t))return Jn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=Yu(t);let s=(i?es(n.width):n.width)/r,a=(i?es(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const hS=Jn(0);function Xu(e){const t=An(e);return!ul()||!t.visualViewport?hS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function gS(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==An(e)?!1:t}function Wr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=pl(e);let s=Jn(1);t&&(r?Bn(r)&&(s=fo(r)):s=fo(e));const a=gS(i,n,r)?Xu(i):Jn(0);let c=(o.left+a.x)/s.x,u=(o.top+a.y)/s.y,l=o.width/s.x,f=o.height/s.y;if(i){const p=An(i),m=r&&Bn(r)?An(r):r;let g=p,h=fl(g);for(;h&&r&&m!==g;){const y=fo(h),w=h.getBoundingClientRect(),v=$n(h),x=w.left+(h.clientLeft+parseFloat(v.paddingLeft))*y.x,C=w.top+(h.clientTop+parseFloat(v.paddingTop))*y.y;c*=y.x,u*=y.y,l*=y.x,f*=y.y,c+=x,u+=C,g=An(h),h=fl(g)}}return rs({width:l,height:f,x:c,y:u})}function as(e,t){const n=ss(e).scrollLeft;return t?t.left+n:Wr(Zn(e)).left+n}function Ju(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-as(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function yS(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=Zn(r),a=t?is(t.floating):!1;if(r===s||a&&i)return n;let c={scrollLeft:0,scrollTop:0},u=Jn(1);const l=Jn(0),f=ur(r);if((f||!f&&!i)&&((co(r)!=="body"||Zo(s))&&(c=ss(r)),f)){const m=Wr(r);u=fo(r),l.x=m.x+r.clientLeft,l.y=m.y+r.clientTop}const p=s&&!f&&!i?Ju(s,c):Jn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+l.x+p.x,y:n.y*u.y-c.scrollTop*u.y+l.y+p.y}}function bS(e){return Array.from(e.getClientRects())}function vS(e){const t=Zn(e),n=ss(e),r=e.ownerDocument.body,o=xn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=xn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+as(e);const a=-n.scrollTop;return $n(r).direction==="rtl"&&(s+=xn(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:a}}const Qu=25;function wS(e,t){const n=An(e),r=Zn(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,a=0,c=0;if(o){i=o.width,s=o.height;const l=ul();(!l||l&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}const u=as(r);if(u<=0){const l=r.ownerDocument,f=l.body,p=getComputedStyle(f),m=l.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-f.clientWidth-m);g<=Qu&&(i-=g)}else u<=Qu&&(i+=u);return{width:i,height:s,x:a,y:c}}function SS(e,t){const n=Wr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=ur(e)?fo(e):Jn(1),s=e.clientWidth*i.x,a=e.clientHeight*i.y,c=o*i.x,u=r*i.y;return{width:s,height:a,x:c,y:u}}function Zu(e,t,n){let r;if(t==="viewport")r=wS(e,n);else if(t==="document")r=vS(Zn(e));else if(Bn(t))r=SS(t,n);else{const o=Xu(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return rs(r)}function ef(e,t){const n=Tr(e);return n===t||!Bn(n)||uo(n)?!1:$n(n).position==="fixed"||ef(n,t)}function xS(e,t){const n=t.get(e);if(n)return n;let r=ei(e,[],!1).filter(a=>Bn(a)&&co(a)!=="body"),o=null;const i=$n(e).position==="fixed";let s=i?Tr(e):e;for(;Bn(s)&&!uo(s);){const a=$n(s),c=dl(s);!c&&a.position==="fixed"&&(o=null),(i?!c&&!o:!c&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Zo(s)&&!c&&ef(e,s))?r=r.filter(l=>l!==s):o=a,s=Tr(s)}return t.set(e,r),r}function AS(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?is(t)?[]:xS(t,this._c):[].concat(n),r],a=Zu(t,s[0],o);let c=a.top,u=a.right,l=a.bottom,f=a.left;for(let p=1;p<s.length;p++){const m=Zu(t,s[p],o);c=xn(m.top,c),u=_r(m.right,u),l=_r(m.bottom,l),f=xn(m.left,f)}return{width:u-f,height:l-c,x:f,y:c}}function CS(e){const{width:t,height:n}=Yu(e);return{width:t,height:n}}function ES(e,t,n){const r=ur(t),o=Zn(t),i=n==="fixed",s=Wr(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const c=Jn(0);function u(){c.x=as(o)}if(r||!r&&!i)if((co(t)!=="body"||Zo(o))&&(a=ss(t)),r){const m=Wr(t,!0,i,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();i&&!r&&o&&u();const l=o&&!r&&!i?Ju(o,a):Jn(0),f=s.left+a.scrollLeft-c.x-l.x,p=s.top+a.scrollTop-c.y-l.y;return{x:f,y:p,width:s.width,height:s.height}}function ml(e){return $n(e).position==="static"}function tf(e,t){if(!ur(e)||$n(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Zn(e)===n&&(n=n.ownerDocument.body),n}function nf(e,t){const n=An(e);if(is(e))return n;if(!ur(e)){let o=Tr(e);for(;o&&!uo(o);){if(Bn(o)&&!ml(o))return o;o=Tr(o)}return n}let r=tf(e,t);for(;r&&uS(r)&&ml(r);)r=tf(r,t);return r&&uo(r)&&ml(r)&&!dl(r)?n:r||mS(e)||n}const NS=async function(e){const t=this.getOffsetParent||nf,n=this.getDimensions,r=await n(e.floating);return{reference:ES(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function kS(e){return $n(e).direction==="rtl"}const _S={convertOffsetParentRelativeRectToViewportRelativeRect:yS,getDocumentElement:Zn,getClippingRect:AS,getOffsetParent:nf,getElementRects:NS,getClientRects:bS,getDimensions:CS,getScale:fo,isElement:Bn,isRTL:kS};function rf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function TS(e,t){let n=null,r;const o=Zn(e);function i(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function s(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),i();const u=e.getBoundingClientRect(),{left:l,top:f,width:p,height:m}=u;if(a||t(),!p||!m)return;const g=ts(f),h=ts(o.clientWidth-(l+p)),y=ts(o.clientHeight-(f+m)),w=ts(l),x={rootMargin:-g+"px "+-h+"px "+-y+"px "+-w+"px",threshold:xn(0,_r(1,c))||1};let C=!0;function F(N){const T=N[0].intersectionRatio;if(T!==c){if(!C)return s();T?s(!1,T):r=setTimeout(()=>{s(!1,1e-7)},1e3)}T===1&&!rf(u,e.getBoundingClientRect())&&s(),C=!1}try{n=new IntersectionObserver(F,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(F,x)}n.observe(e)}return s(!0),i}function FS(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=pl(e),l=o||i?[...u?ei(u):[],...t?ei(t):[]]:[];l.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),i&&w.addEventListener("resize",n)});const f=u&&a?TS(u,n):null;let p=-1,m=null;s&&(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)})),n()}),u&&!c&&m.observe(u),t&&m.observe(t));let g,h=c?Wr(e):null;c&&y();function y(){const w=Wr(e);h&&!rf(h,w)&&n(),h=w,g=requestAnimationFrame(y)}return n(),()=>{var w;l.forEach(v=>{o&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),f?.(),(w=m)==null||w.disconnect(),m=null,c&&cancelAnimationFrame(g)}}const PS=aS,OS=lS,IS=oS,MS=dS,LS=iS,of=rS,DS=cS,BS=(e,t,n)=>{const r=new Map,o={platform:_S,...n},i={...o.platform,_c:r};return nS(e,t,{...o,platform:i})};var $S=typeof document<"u",jS=function(){},ls=$S?S.useLayoutEffect:jS;function cs(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 n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!cs(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!cs(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function sf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function af(e,t){const n=sf(e);return Math.round(t*n)/n}function hl(e){const t=b.useRef(e);return ls(()=>{t.current=e}),t}function zS(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[l,f]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=b.useState(r);cs(p,r)||m(r);const[g,h]=b.useState(null),[y,w]=b.useState(null),v=b.useCallback(M=>{M!==N.current&&(N.current=M,h(M))},[]),x=b.useCallback(M=>{M!==T.current&&(T.current=M,w(M))},[]),C=i||g,F=s||y,N=b.useRef(null),T=b.useRef(null),k=b.useRef(l),A=c!=null,O=hl(c),E=hl(o),L=hl(u),G=b.useCallback(()=>{if(!N.current||!T.current)return;const M={placement:t,strategy:n,middleware:p};E.current&&(M.platform=E.current),BS(N.current,T.current,M).then(W=>{const j={...W,isPositioned:L.current!==!1};I.current&&!cs(k.current,j)&&(k.current=j,Oi.flushSync(()=>{f(j)}))})},[p,t,n,E,L]);ls(()=>{u===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,f(M=>({...M,isPositioned:!1})))},[u]);const I=b.useRef(!1);ls(()=>(I.current=!0,()=>{I.current=!1}),[]),ls(()=>{if(C&&(N.current=C),F&&(T.current=F),C&&F){if(O.current)return O.current(C,F,G);G()}},[C,F,G,O,A]);const $=b.useMemo(()=>({reference:N,floating:T,setReference:v,setFloating:x}),[v,x]),D=b.useMemo(()=>({reference:C,floating:F}),[C,F]),B=b.useMemo(()=>{const M={position:n,left:0,top:0};if(!D.floating)return M;const W=af(D.floating,l.x),j=af(D.floating,l.y);return a?{...M,transform:"translate("+W+"px, "+j+"px)",...sf(D.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:j}},[n,a,D.floating,l.x,l.y]);return b.useMemo(()=>({...l,update:G,refs:$,elements:D,floatingStyles:B}),[l,G,$,D,B])}const VS=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?of({element:r.current,padding:o}).fn(n):{}:r?of({element:r,padding:o}).fn(n):{}}}},US=(e,t)=>{const n=PS(e);return{name:n.name,fn:n.fn,options:[e,t]}},HS=(e,t)=>{const n=OS(e);return{name:n.name,fn:n.fn,options:[e,t]}},WS=(e,t)=>({fn:DS(e).fn,options:[e,t]}),RS=(e,t)=>{const n=IS(e);return{name:n.name,fn:n.fn,options:[e,t]}},KS=(e,t)=>{const n=MS(e);return{name:n.name,fn:n.fn,options:[e,t]}},GS=(e,t)=>{const n=LS(e);return{name:n.name,fn:n.fn,options:[e,t]}},qS=(e,t)=>{const n=VS(e);return{name:n.name,fn:n.fn,options:[e,t]}};var YS="Arrow",lf=b.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return d.jsx($e.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});lf.displayName=YS;var XS=lf;function ti(e){const[t,n]=b.useState(void 0);return Zt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,a;if("borderBoxSize"in i){const c=i.borderBoxSize,u=Array.isArray(c)?c[0]:c;s=u.inlineSize,a=u.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var gl="Popper",[cf,ds]=Sn(gl),[JS,df]=cf(gl),uf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=b.useState(null);return d.jsx(JS,{scope:t,anchor:r,onAnchorChange:o,children:n})};uf.displayName=gl;var ff="PopperAnchor",pf=b.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=df(ff,n),s=b.useRef(null),a=Ze(t,s),c=b.useRef(null);return b.useEffect(()=>{const u=c.current;c.current=r?.current||s.current,u!==c.current&&i.onAnchorChange(c.current)}),r?null:d.jsx($e.div,{...o,ref:a})});pf.displayName=ff;var yl="PopperContent",[QS,ZS]=cf(yl),mf=b.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:l=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...h}=e,y=df(yl,n),[w,v]=b.useState(null),x=Ze(t,q=>v(q)),[C,F]=b.useState(null),N=ti(C),T=N?.width??0,k=N?.height??0,A=r+(i!=="center"?"-"+i:""),O=typeof l=="number"?l:{top:0,right:0,bottom:0,left:0,...l},E=Array.isArray(u)?u:[u],L=E.length>0,G={padding:O,boundary:E.filter(t0),altBoundary:L},{refs:I,floatingStyles:$,placement:D,isPositioned:B,middlewareData:M}=zS({strategy:"fixed",placement:A,whileElementsMounted:(...q)=>FS(...q,{animationFrame:m==="always"}),elements:{reference:y.anchor},middleware:[US({mainAxis:o+k,alignmentAxis:s}),c&&HS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?WS():void 0,...G}),c&&RS({...G}),KS({...G,apply:({elements:q,rects:re,availableWidth:Te,availableHeight:Q})=>{const{width:te,height:ge}=re.reference,ce=q.floating.style;ce.setProperty("--radix-popper-available-width",`${Te}px`),ce.setProperty("--radix-popper-available-height",`${Q}px`),ce.setProperty("--radix-popper-anchor-width",`${te}px`),ce.setProperty("--radix-popper-anchor-height",`${ge}px`)}}),C&&qS({element:C,padding:a}),n0({arrowWidth:T,arrowHeight:k}),p&&GS({strategy:"referenceHidden",...G})]}),[W,j]=yf(D),ie=sn(g);Zt(()=>{B&&ie?.()},[B,ie]);const H=M.arrow?.x,U=M.arrow?.y,J=M.arrow?.centerOffset!==0,[de,ne]=b.useState();return Zt(()=>{w&&ne(window.getComputedStyle(w).zIndex)},[w]),d.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:B?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:de,"--radix-popper-transform-origin":[M.transformOrigin?.x,M.transformOrigin?.y].join(" "),...M.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(QS,{scope:n,placedSide:W,onArrowChange:F,arrowX:H,arrowY:U,shouldHideArrow:J,children:d.jsx($e.div,{"data-side":W,"data-align":j,...h,ref:x,style:{...h.style,animation:B?void 0:"none"}})})})});mf.displayName=yl;var hf="PopperArrow",e0={top:"bottom",right:"left",bottom:"top",left:"right"},gf=b.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=ZS(hf,r),s=e0[i.placedSide];return d.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:d.jsx(XS,{...o,ref:n,style:{...o.style,display:"block"}})})});gf.displayName=hf;function t0(e){return e!==null}var n0=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,s=o.arrow?.centerOffset!==0,a=s?0:e.arrowWidth,c=s?0:e.arrowHeight,[u,l]=yf(n),f={start:"0%",center:"50%",end:"100%"}[l],p=(o.arrow?.x??0)+a/2,m=(o.arrow?.y??0)+c/2;let g="",h="";return u==="bottom"?(g=s?f:`${p}px`,h=`${-c}px`):u==="top"?(g=s?f:`${p}px`,h=`${r.floating.height+c}px`):u==="right"?(g=`${-c}px`,h=s?f:`${m}px`):u==="left"&&(g=`${r.floating.width+c}px`,h=s?f:`${m}px`),{data:{x:g,y:h}}}});function yf(e){const[t,n="center"]=e.split("-");return[t,n]}var bf=uf,bl=pf,vf=mf,wf=gf,r0="Portal",us=b.forwardRef((e,t)=>{const{container:n,...r}=e,[o,i]=b.useState(!1);Zt(()=>i(!0),[]);const s=n||o&&globalThis?.document?.body;return s?ad.createPortal(d.jsx($e.div,{...r,ref:t}),s):null});us.displayName=r0;function o0(e){const t=i0(e),n=b.forwardRef((r,o)=>{const{children:i,...s}=r,a=b.Children.toArray(i),c=a.find(a0);if(c){const u=c.props.children,l=a.map(f=>f===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return d.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function i0(e){const t=b.forwardRef((n,r)=>{const{children:o,...i}=n;if(b.isValidElement(o)){const s=c0(o),a=l0(i,o.props);return o.type!==b.Fragment&&(a.ref=r?Ur(r,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var s0=Symbol("radix.slottable");function a0(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===s0}function l0(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function c0(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var d0=b[" useInsertionEffect ".trim().toString()]||Zt;function er({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,s]=u0({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const l=b.useRef(e!==void 0);b.useEffect(()=>{const f=l.current;f!==a&&console.warn(`${r} 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,r])}const u=b.useCallback(l=>{if(a){const f=f0(l)?l(e):l;f!==e&&s.current?.(f)}else i(l)},[a,e,i,s]);return[c,u]}function u0({defaultProp:e,onChange:t}){const[n,r]=b.useState(e),o=b.useRef(n),i=b.useRef(t);return d0(()=>{i.current=t},[t]),b.useEffect(()=>{o.current!==n&&(i.current?.(n),o.current=n)},[n,o]),[n,r,i]}function f0(e){return typeof e=="function"}function ni(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 Sf=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"}),p0="VisuallyHidden",m0=b.forwardRef((e,t)=>d.jsx($e.span,{...e,ref:t,style:{...Sf,...e.style}}));m0.displayName=p0;var h0=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},po=new WeakMap,fs=new WeakMap,ps={},vl=0,xf=function(e){return e&&(e.host||xf(e.parentNode))},g0=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=xf(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},y0=function(e,t,n,r){var o=g0(t,Array.isArray(e)?e:[e]);ps[n]||(ps[n]=new WeakMap);var i=ps[n],s=[],a=new Set,c=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var l=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(p){if(a.has(p))l(p);else try{var m=p.getAttribute(r),g=m!==null&&m!=="false",h=(po.get(p)||0)+1,y=(i.get(p)||0)+1;po.set(p,h),i.set(p,y),s.push(p),h===1&&g&&fs.set(p,!0),y===1&&p.setAttribute(n,"true"),g||p.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",p,w)}})};return l(t),a.clear(),vl++,function(){s.forEach(function(f){var p=po.get(f)-1,m=i.get(f)-1;po.set(f,p),i.set(f,m),p||(fs.has(f)||f.removeAttribute(r),fs.delete(f)),m||f.removeAttribute(n)}),vl--,vl||(po=new WeakMap,po=new WeakMap,fs=new WeakMap,ps={})}},wl=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=h0(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),y0(r,o,n,"aria-hidden")):function(){return null}},tr=function(){return tr=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},tr.apply(this,arguments)};function Af(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function b0(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var ms="right-scroll-bar-position",hs="width-before-scroll-bar",v0="with-scroll-bars-hidden",w0="--removed-body-scroll-bar-size";function Sl(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function S0(e,t){var n=S.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var x0=typeof window<"u"?b.useLayoutEffect:b.useEffect,Cf=new WeakMap;function A0(e,t){var n=S0(null,function(r){return e.forEach(function(o){return Sl(o,r)})});return x0(function(){var r=Cf.get(n);if(r){var o=new Set(r),i=new Set(e),s=n.current;o.forEach(function(a){i.has(a)||Sl(a,null)}),i.forEach(function(a){o.has(a)||Sl(a,s)})}Cf.set(n,e)},[e]),n}function C0(e){return e}function E0(e,t){t===void 0&&(t=C0);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var s=t(i,r);return n.push(s),function(){n=n.filter(function(a){return a!==s})}},assignSyncMedium:function(i){for(r=!0;n.length;){var s=n;n=[],s.forEach(i)}n={push:function(a){return i(a)},filter:function(){return n}}},assignMedium:function(i){r=!0;var s=[];if(n.length){var a=n;n=[],a.forEach(i),s=n}var c=function(){var l=s;s=[],l.forEach(i)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(l){s.push(l),u()},filter:function(l){return s=s.filter(l),n}}}};return o}function N0(e){e===void 0&&(e={});var t=E0(null);return t.options=tr({async:!0,ssr:!1},e),t}var Ef=function(e){var t=e.sideCar,n=Af(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return b.createElement(r,tr({},n))};Ef.isSideCarExport=!0;function k0(e,t){return e.useMedium(t),Ef}var Nf=N0(),xl=function(){},gs=b.forwardRef(function(e,t){var n=b.useRef(null),r=b.useState({onScrollCapture:xl,onWheelCapture:xl,onTouchMoveCapture:xl}),o=r[0],i=r[1],s=e.forwardProps,a=e.children,c=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,C=Af(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),F=p,N=A0([n,t]),T=tr(tr({},C),o);return b.createElement(b.Fragment,null,l&&b.createElement(F,{sideCar:Nf,removeScrollBar:u,shards:f,noRelative:m,noIsolation:g,inert:h,setCallbacks:i,allowPinchZoom:!!y,lockRef:n,gapMode:x}),s?b.cloneElement(b.Children.only(a),tr(tr({},T),{ref:N})):b.createElement(v,tr({},T,{className:c,ref:N}),a))});gs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},gs.classNames={fullWidth:hs,zeroRight:ms};var _0=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function T0(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=_0();return t&&e.setAttribute("nonce",t),e}function F0(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function P0(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var O0=function(){var e=0,t=null;return{add:function(n){e==0&&(t=T0())&&(F0(t,n),P0(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},I0=function(){var e=O0();return function(t,n){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},kf=function(){var e=I0(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},M0={left:0,top:0,right:0,gap:0},Al=function(e){return parseInt(e||"",10)||0},L0=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Al(n),Al(r),Al(o)]},D0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return M0;var t=L0(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},B0=kf(),mo="data-scroll-locked",$0=function(e,t,n,r){var o=e.left,i=e.top,s=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
2
|
-
|
|
3
|
-
overflow: hidden `).concat(r,`;
|
|
4
|
-
|
|
1
|
+
(function(ue,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react"),require("react/jsx-runtime"),require("react-router-dom"),require("react-dom"),require("sonner"),require("@tanstack/react-query")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","react-router-dom","react-dom","sonner","@tanstack/react-query"],v):(ue=typeof globalThis<"u"?globalThis:ue||self,v(ue.FormBuilderRenderer={},ue.React,ue.jsxRuntime,ue.ReactRouterDOM,ue.ReactDOM,ue.Sonner,ue.ReactQuery))})(this,(function(ue,v,d,Ba,Nd,ct,Nn){"use strict";function kd(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const b=kd(v),js=kd(Nd),$a="iq-fbr",Hn="95px";function zs(e){return!e||typeof e.columns!="number"?null:{rows:e.rows??8,columns:e.columns,verticalSpacing:e.verticalSpacing||e.spacing||"16px",horizontalSpacing:e.horizontalSpacing||e.spacing||"16px",rowHeight:Hn}}function Us(e,t){if(t!=null&&t!==void 0)return t;const r=e.config;if(r?.grid&&typeof r.grid.rows=="number"&&typeof r.grid.columns=="number")return{rows:r.grid.rows,columns:r.grid.columns,verticalSpacing:r.grid.verticalSpacing??r.grid.spacing,horizontalSpacing:r.grid.horizontalSpacing??r.grid.spacing,rowHeight:r.grid.rowHeight,spacing:r.grid.spacing};const n=r?.layout!=null&&typeof r.layout=="object"?r.layout:null;if(n&&typeof n.rows=="number"&&typeof n.columns=="number")return{rows:n.rows,columns:n.columns,verticalSpacing:n.verticalSpacing??n.spacing,horizontalSpacing:n.horizontalSpacing??n.spacing,rowHeight:n.rowHeight,spacing:n.spacing};const o=e.layout;if(o!=null&&typeof o=="object"&&typeof o.rows=="number"&&typeof o.columns=="number"){const s=o;return{rows:s.rows,columns:s.columns,verticalSpacing:s.verticalSpacing??s.spacing,horizontalSpacing:s.horizontalSpacing??s.spacing,rowHeight:s.rowHeight,spacing:s.spacing}}return null}function _d(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(r=_d(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Td(){for(var e,t,r=0,n="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=_d(e))&&(n&&(n+=" "),n+=t);return n}const qb=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},Yb=(e,t)=>({classGroupId:e,validator:t}),Fd=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Vs="-",Pd=[],Xb="arbitrary..",Jb=e=>{const t=Zb(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Qb(i);const a=i.split(Vs),c=a[0]===""&&a.length>1?1:0;return Od(a,c,t)},getConflictingClassGroupIds:(i,a)=>{if(a){const c=n[i],u=r[i];return c?u?qb(u,c):c:u||Pd}return r[i]||Pd}}},Od=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const o=e[t],s=r.nextPart.get(o);if(s){const u=Od(e,t+1,s);if(u)return u}const i=r.validators;if(i===null)return;const a=t===0?e.join(Vs):e.slice(t).join(Vs),c=i.length;for(let u=0;u<c;u++){const f=i[u];if(f.validator(a))return f.classGroupId}},Qb=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?Xb+n:void 0})(),Zb=e=>{const{theme:t,classGroups:r}=e;return ev(r,t)},ev=(e,t)=>{const r=Fd();for(const n in e){const o=e[n];ja(o,r,n,t)}return r},ja=(e,t,r,n)=>{const o=e.length;for(let s=0;s<o;s++){const i=e[s];tv(i,t,r,n)}},tv=(e,t,r,n)=>{if(typeof e=="string"){rv(e,t,r);return}if(typeof e=="function"){nv(e,t,r,n);return}ov(e,t,r,n)},rv=(e,t,r)=>{const n=e===""?t:Id(t,e);n.classGroupId=r},nv=(e,t,r,n)=>{if(sv(e)){ja(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(Yb(r,e))},ov=(e,t,r,n)=>{const o=Object.entries(e),s=o.length;for(let i=0;i<s;i++){const[a,c]=o[i];ja(c,Id(t,a),r,n)}},Id=(e,t)=>{let r=e;const n=t.split(Vs),o=n.length;for(let s=0;s<o;s++){const i=n[s];let a=r.nextPart.get(i);a||(a=Fd(),r.nextPart.set(i,a)),r=a}return r},sv=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,iv=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const o=(s,i)=>{r[s]=i,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(s){let i=r[s];if(i!==void 0)return i;if((i=n[s])!==void 0)return o(s,i),i},set(s,i){s in r?r[s]=i:o(s,i)}}},za="!",Md=":",av=[],Ld=(e,t,r,n,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:o}),lv=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=o=>{const s=[];let i=0,a=0,c=0,u;const f=o.length;for(let h=0;h<f;h++){const y=o[h];if(i===0&&a===0){if(y===Md){s.push(o.slice(c,h)),c=h+1;continue}if(y==="/"){u=h;continue}}y==="["?i++:y==="]"?i--:y==="("?a++:y===")"&&a--}const l=s.length===0?o:o.slice(c);let p=l,g=!1;l.endsWith(za)?(p=l.slice(0,-1),g=!0):l.startsWith(za)&&(p=l.slice(1),g=!0);const m=u&&u>c?u-c:void 0;return Ld(s,g,p,m)};if(t){const o=t+Md,s=n;n=i=>i.startsWith(o)?s(i.slice(o.length)):Ld(av,!1,i,void 0,!0)}if(r){const o=n;n=s=>r({className:s,parseClassName:o})}return n},cv=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let o=[];for(let s=0;s<r.length;s++){const i=r[s],a=i[0]==="[",c=t.has(i);a||c?(o.length>0&&(o.sort(),n.push(...o),o=[]),n.push(i)):o.push(i)}return o.length>0&&(o.sort(),n.push(...o)),n}},dv=e=>({cache:iv(e.cacheSize),parseClassName:lv(e),sortModifiers:cv(e),...Jb(e)}),uv=/\s+/,fv=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:o,sortModifiers:s}=t,i=[],a=e.trim().split(uv);let c="";for(let u=a.length-1;u>=0;u-=1){const f=a[u],{isExternal:l,modifiers:p,hasImportantModifier:g,baseClassName:m,maybePostfixModifierPosition:h}=r(f);if(l){c=f+(c.length>0?" "+c:c);continue}let y=!!h,S=n(y?m.substring(0,h):m);if(!S){if(!y){c=f+(c.length>0?" "+c:c);continue}if(S=n(m),!S){c=f+(c.length>0?" "+c:c);continue}y=!1}const w=p.length===0?"":p.length===1?p[0]:s(p).join(":"),A=g?w+za:w,x=A+S;if(i.indexOf(x)>-1)continue;i.push(x);const F=o(S,y);for(let N=0;N<F.length;++N){const k=F[N];i.push(A+k)}c=f+(c.length>0?" "+c:c)}return c},pv=(...e)=>{let t=0,r,n,o="";for(;t<e.length;)(r=e[t++])&&(n=Dd(r))&&(o&&(o+=" "),o+=n);return o},Dd=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=Dd(e[n]))&&(r&&(r+=" "),r+=t);return r},mv=(e,...t)=>{let r,n,o,s;const i=c=>{const u=t.reduce((f,l)=>l(f),e());return r=dv(u),n=r.cache.get,o=r.cache.set,s=a,a(c)},a=c=>{const u=n(c);if(u)return u;const f=fv(c,r);return o(c,f),f};return s=i,(...c)=>s(pv(...c))},hv=[],Kt=e=>{const t=r=>r[e]||hv;return t.isThemeGetter=!0,t},Bd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,$d=/^\((?:(\w[\w-]*):)?(.+)\)$/i,gv=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,yv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,bv=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,vv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,wv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Sv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,kn=e=>gv.test(e),ot=e=>!!e&&!Number.isNaN(Number(e)),_n=e=>!!e&&Number.isInteger(Number(e)),Ua=e=>e.endsWith("%")&&ot(e.slice(0,-1)),pn=e=>yv.test(e),jd=()=>!0,xv=e=>bv.test(e)&&!vv.test(e),Va=()=>!1,Av=e=>wv.test(e),Cv=e=>Sv.test(e),Ev=e=>!Fe(e)&&!Pe(e),Nv=e=>Tn(e,Rd,Va),Fe=e=>Bd.test(e),Wn=e=>Tn(e,Gd,xv),zd=e=>Tn(e,Mv,ot),kv=e=>Tn(e,qd,jd),_v=e=>Tn(e,Kd,Va),Ud=e=>Tn(e,Hd,Va),Tv=e=>Tn(e,Wd,Cv),Hs=e=>Tn(e,Yd,Av),Pe=e=>$d.test(e),Ko=e=>Rn(e,Gd),Fv=e=>Rn(e,Kd),Vd=e=>Rn(e,Hd),Pv=e=>Rn(e,Rd),Ov=e=>Rn(e,Wd),Ws=e=>Rn(e,Yd,!0),Iv=e=>Rn(e,qd,!0),Tn=(e,t,r)=>{const n=Bd.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Rn=(e,t,r=!1)=>{const n=$d.exec(e);return n?n[1]?t(n[1]):r:!1},Hd=e=>e==="position"||e==="percentage",Wd=e=>e==="image"||e==="url",Rd=e=>e==="length"||e==="size"||e==="bg-size",Gd=e=>e==="length",Mv=e=>e==="number",Kd=e=>e==="family-name",qd=e=>e==="number"||e==="weight",Yd=e=>e==="shadow",Lv=mv(()=>{const e=Kt("color"),t=Kt("font"),r=Kt("text"),n=Kt("font-weight"),o=Kt("tracking"),s=Kt("leading"),i=Kt("breakpoint"),a=Kt("container"),c=Kt("spacing"),u=Kt("radius"),f=Kt("shadow"),l=Kt("inset-shadow"),p=Kt("text-shadow"),g=Kt("drop-shadow"),m=Kt("blur"),h=Kt("perspective"),y=Kt("aspect"),S=Kt("ease"),w=Kt("animate"),A=()=>["auto","avoid","all","avoid-page","page","left","right","column"],x=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],F=()=>[...x(),Pe,Fe],N=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto","contain","none"],T=()=>[Pe,Fe,c],P=()=>[kn,"full","auto",...T()],E=()=>[_n,"none","subgrid",Pe,Fe],C=()=>["auto",{span:["full",_n,Pe,Fe]},_n,Pe,Fe],I=()=>[_n,"auto",Pe,Fe],W=()=>["auto","min","max","fr",Pe,Fe],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],V=()=>["auto",...T()],X=()=>[kn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],L=()=>[kn,"screen","full","dvw","lvw","svw","min","max","fit",...T()],B=()=>[kn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],D=()=>[e,Pe,Fe],K=()=>[...x(),Vd,Ud,{position:[Pe,Fe]}],ae=()=>["no-repeat",{repeat:["","x","y","space","round"]}],j=()=>["auto","cover","contain",Pv,Nv,{size:[Pe,Fe]}],U=()=>[Ua,Ko,Wn],le=()=>["","none","full",u,Pe,Fe],oe=()=>["",ot,Ko,Wn],G=()=>["solid","dashed","dotted","double"],ie=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Ce=()=>[ot,Ua,Vd,Ud],ee=()=>["","none",m,Pe,Fe],ne=()=>["none",ot,Pe,Fe],he=()=>["none",ot,Pe,Fe],Ie=()=>[ot,Pe,Fe],Ue=()=>[kn,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[pn],breakpoint:[pn],color:[jd],container:[pn],"drop-shadow":[pn],ease:["in","out","in-out"],font:[Ev],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[pn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[pn],shadow:[pn],spacing:["px",ot],text:[pn],"text-shadow":[pn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",kn,Fe,Pe,y]}],container:["container"],columns:[{columns:[ot,Fe,Pe,a]}],"break-after":[{"break-after":A()}],"break-before":[{"break-before":A()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:F()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[_n,"auto",Pe,Fe]}],basis:[{basis:[kn,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ot,kn,"auto","initial","none",Fe]}],grow:[{grow:["",ot,Pe,Fe]}],shrink:[{shrink:["",ot,Pe,Fe]}],order:[{order:[_n,"first","last","none",Pe,Fe]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:C()}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:C()}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":W()}],"auto-rows":[{"auto-rows":W()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pbs:[{pbs:T()}],pbe:[{pbe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:V()}],mx:[{mx:V()}],my:[{my:V()}],ms:[{ms:V()}],me:[{me:V()}],mbs:[{mbs:V()}],mbe:[{mbe:V()}],mt:[{mt:V()}],mr:[{mr:V()}],mb:[{mb:V()}],ml:[{ml:V()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:X()}],"inline-size":[{inline:["auto",...L()]}],"min-inline-size":[{"min-inline":["auto",...L()]}],"max-inline-size":[{"max-inline":["none",...L()]}],"block-size":[{block:["auto",...B()]}],"min-block-size":[{"min-block":["auto",...B()]}],"max-block-size":[{"max-block":["none",...B()]}],w:[{w:[a,"screen",...X()]}],"min-w":[{"min-w":[a,"screen","none",...X()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...X()]}],h:[{h:["screen","lh",...X()]}],"min-h":[{"min-h":["screen","lh","none",...X()]}],"max-h":[{"max-h":["screen","lh",...X()]}],"font-size":[{text:["base",r,Ko,Wn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Iv,kv]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ua,Fe]}],"font-family":[{font:[Fv,_v,t]}],"font-features":[{"font-features":[Fe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Pe,Fe]}],"line-clamp":[{"line-clamp":[ot,"none",Pe,zd]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",Pe,Fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Pe,Fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...G(),"wavy"]}],"text-decoration-thickness":[{decoration:[ot,"from-font","auto",Pe,Wn]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[ot,"auto",Pe,Fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Pe,Fe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Pe,Fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:K()}],"bg-repeat":[{bg:ae()}],"bg-size":[{bg:j()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},_n,Pe,Fe],radial:["",Pe,Fe],conic:[_n,Pe,Fe]},Ov,Tv]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:le()}],"rounded-s":[{"rounded-s":le()}],"rounded-e":[{"rounded-e":le()}],"rounded-t":[{"rounded-t":le()}],"rounded-r":[{"rounded-r":le()}],"rounded-b":[{"rounded-b":le()}],"rounded-l":[{"rounded-l":le()}],"rounded-ss":[{"rounded-ss":le()}],"rounded-se":[{"rounded-se":le()}],"rounded-ee":[{"rounded-ee":le()}],"rounded-es":[{"rounded-es":le()}],"rounded-tl":[{"rounded-tl":le()}],"rounded-tr":[{"rounded-tr":le()}],"rounded-br":[{"rounded-br":le()}],"rounded-bl":[{"rounded-bl":le()}],"border-w":[{border:oe()}],"border-w-x":[{"border-x":oe()}],"border-w-y":[{"border-y":oe()}],"border-w-s":[{"border-s":oe()}],"border-w-e":[{"border-e":oe()}],"border-w-bs":[{"border-bs":oe()}],"border-w-be":[{"border-be":oe()}],"border-w-t":[{"border-t":oe()}],"border-w-r":[{"border-r":oe()}],"border-w-b":[{"border-b":oe()}],"border-w-l":[{"border-l":oe()}],"divide-x":[{"divide-x":oe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":oe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...G(),"hidden","none"]}],"divide-style":[{divide:[...G(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...G(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ot,Pe,Fe]}],"outline-w":[{outline:["",ot,Ko,Wn]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",f,Ws,Hs]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",l,Ws,Hs]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[ot,Wn]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":oe()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",p,Ws,Hs]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[ot,Pe,Fe]}],"mix-blend":[{"mix-blend":[...ie(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ie()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ot]}],"mask-image-linear-from-pos":[{"mask-linear-from":Ce()}],"mask-image-linear-to-pos":[{"mask-linear-to":Ce()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":Ce()}],"mask-image-t-to-pos":[{"mask-t-to":Ce()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":Ce()}],"mask-image-r-to-pos":[{"mask-r-to":Ce()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":Ce()}],"mask-image-b-to-pos":[{"mask-b-to":Ce()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":Ce()}],"mask-image-l-to-pos":[{"mask-l-to":Ce()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":Ce()}],"mask-image-x-to-pos":[{"mask-x-to":Ce()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":Ce()}],"mask-image-y-to-pos":[{"mask-y-to":Ce()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[Pe,Fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":Ce()}],"mask-image-radial-to-pos":[{"mask-radial-to":Ce()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":x()}],"mask-image-conic-pos":[{"mask-conic":[ot]}],"mask-image-conic-from-pos":[{"mask-conic-from":Ce()}],"mask-image-conic-to-pos":[{"mask-conic-to":Ce()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:K()}],"mask-repeat":[{mask:ae()}],"mask-size":[{mask:j()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Pe,Fe]}],filter:[{filter:["","none",Pe,Fe]}],blur:[{blur:ee()}],brightness:[{brightness:[ot,Pe,Fe]}],contrast:[{contrast:[ot,Pe,Fe]}],"drop-shadow":[{"drop-shadow":["","none",g,Ws,Hs]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",ot,Pe,Fe]}],"hue-rotate":[{"hue-rotate":[ot,Pe,Fe]}],invert:[{invert:["",ot,Pe,Fe]}],saturate:[{saturate:[ot,Pe,Fe]}],sepia:[{sepia:["",ot,Pe,Fe]}],"backdrop-filter":[{"backdrop-filter":["","none",Pe,Fe]}],"backdrop-blur":[{"backdrop-blur":ee()}],"backdrop-brightness":[{"backdrop-brightness":[ot,Pe,Fe]}],"backdrop-contrast":[{"backdrop-contrast":[ot,Pe,Fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ot,Pe,Fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ot,Pe,Fe]}],"backdrop-invert":[{"backdrop-invert":["",ot,Pe,Fe]}],"backdrop-opacity":[{"backdrop-opacity":[ot,Pe,Fe]}],"backdrop-saturate":[{"backdrop-saturate":[ot,Pe,Fe]}],"backdrop-sepia":[{"backdrop-sepia":["",ot,Pe,Fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Pe,Fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ot,"initial",Pe,Fe]}],ease:[{ease:["linear","initial",S,Pe,Fe]}],delay:[{delay:[ot,Pe,Fe]}],animate:[{animate:["none",w,Pe,Fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,Pe,Fe]}],"perspective-origin":[{"perspective-origin":F()}],rotate:[{rotate:ne()}],"rotate-x":[{"rotate-x":ne()}],"rotate-y":[{"rotate-y":ne()}],"rotate-z":[{"rotate-z":ne()}],scale:[{scale:he()}],"scale-x":[{"scale-x":he()}],"scale-y":[{"scale-y":he()}],"scale-z":[{"scale-z":he()}],"scale-3d":["scale-3d"],skew:[{skew:Ie()}],"skew-x":[{"skew-x":Ie()}],"skew-y":[{"skew-y":Ie()}],transform:[{transform:[Pe,Fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:F()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ue()}],"translate-x":[{"translate-x":Ue()}],"translate-y":[{"translate-y":Ue()}],"translate-z":[{"translate-z":Ue()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Pe,Fe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mbs":[{"scroll-mbs":T()}],"scroll-mbe":[{"scroll-mbe":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pbs":[{"scroll-pbs":T()}],"scroll-pbe":[{"scroll-pbe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Pe,Fe]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[ot,Ko,Wn,zd]}],stroke:[{stroke:["none",...D()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function H(...e){return Lv(Td(e))}const Dv=["richtext","multiselect","radio","checkboxgroup","signature"],Bv=3;function qo(e){const t=e.position.rowSpan??1;if(e.type==="billingGrid"||e.type==="table")return Math.max(1,t);if(e.type==="file"||e.type==="camera"||e.type==="photoChoice"||e.type==="textarea")return Math.max(t,1);if(e.type==="status")return Math.max(t,4);if(e.type==="selectablelist")return Math.max(Bv,t);if(e.type==="radio"||e.type==="checkboxgroup"){const r=e.properties?.options;return(Array.isArray(r)?r.length:0)<=2?1:Math.max(t,2)}return Dv.includes(e.type)?Math.max(t,2):t}function Xd(e,t){if(e.type==="table"||e.type==="billingGrid"){const s=e.position.columnSpan??t??1;return t!=null?Math.min(s,t):s}if(e.type!=="radio"&&e.type!=="checkboxgroup"){const s=e.position.columnSpan??1;return t!=null?Math.min(s,t):s}const r=e.properties?.options,n=Array.isArray(r)?r.length:0,o=Math.max(1,Math.ceil(n/2));return t!=null?Math.min(o,t):o}function uo(e){const t=e?.size??"md",r=e?.variant??"default";return H(t==="sm"?"h-8 text-sm":t==="lg"?"min-h-12 text-lg py-2":"h-10 md:text-sm",r==="filled"?"border-transparent bg-muted shadow-none":r==="outlined"?"border-2 bg-transparent":"")}function Jd(e){const t=e?.size??"md",r=e?.variant??"default";return H(t==="sm"?"min-h-[48px] text-sm":t==="lg"?"min-h-[72px] text-lg":"min-h-[56px]",r==="filled"?"border-transparent bg-muted shadow-none":r==="outlined"?"border-2 bg-transparent":"")}function $v(e){switch(e){case"left":return"flex flex-row items-start gap-4";case"right":return"flex flex-row-reverse items-start gap-4";case"center":return"flex flex-col items-center text-center w-full";case"floating":return"relative flex flex-col gap-2 w-full min-w-0";default:return"flex flex-col gap-2 w-full min-w-0"}}function jv(e,t){const r=t?"text-destructive":"";switch(e){case"left":return`shrink-0 w-32 pt-2 text-right text-sm font-medium ${r}`;case"right":return`shrink-0 w-32 pt-2 text-left text-sm font-medium ${r}`;case"center":return`w-full text-center text-sm font-medium ${r}`;case"floating":return`absolute left-3 top-2 z-[1] origin-[0] -translate-y-4 scale-75 bg-background px-1 text-sm ${r}`;default:return`text-sm font-medium ${r}`}}function zv(e){switch(e){case"left":case"right":return"flex-1 min-w-0 min-h-0 flex flex-col";case"center":return"w-full max-w-full flex flex-col flex-1 min-h-0";case"floating":return"flex flex-col flex-1 min-h-0 w-full pt-4";default:return"flex flex-col flex-1 min-h-0 w-full min-w-0"}}function Rs(e){return!e||e.widthMode==="full"?100:typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent)?Math.min(100,Math.max(1,Math.round(e.widthPercent))):(e.widthMode==="percent",100)}function Ha(e){const t=Rs(e);return{width:t>=100?"100%":`${t}%`,maxWidth:"100%"}}function Uv(e){return Ha(e)}function Wa(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"||t==="stretch"?t:null}function Ra(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t==="start"||t==="center"||t==="end"?t:null}function Fr(e){if(!e)return"start";const t=Wa(e.horizontalAlign);if(t)return t;const r=Wa(e.contentAlign);if(r)return r;const n=Wa(e.cellAlign);return n||"start"}function Yo(e){if(e?.verticalAlign!=null)return e.verticalAlign;const t=e?.cellJustify;return t==="center"?"center":t==="end"?"end":t==="stretch"?"stretch":t==="start"?"start":"stretch"}function Gs(e){switch(e){case"center":return"items-center";case"end":return"items-end";case"stretch":return"items-stretch";default:return"items-start"}}function Ga(e){switch(e){case"center":return"justify-center";case"end":return"justify-end";case"stretch":return"justify-stretch";default:return"justify-start"}}function Xo(e){const t=Ra(e.appearance?.contentVerticalAlign);if(t!==null)switch(t){case"center":return"justify-center";case"end":return"justify-end";default:return"justify-start"}return Ga(Ka(e))}const Vv=Xo;function Ks(e){if(e.type==="billingGrid"||e.type==="table"||qo(e)>1)return!0;const t=Ra(e.appearance?.contentVerticalAlign);if(t==="center"||t==="end")return!1;if(t==="start")return!0;const r=Ka(e);return r!=="center"&&r!=="end"}function Qd(e){const t=e[0];if(!t)return qa(void 0);if(e.length===1)return qa(t);const r=Fr(t.appearance);return H("flex flex-col min-h-0 h-full w-full",Gs(r),"justify-start")}function Zd(e){const t=Fr(e),r=Yo(e);return H("flex flex-col min-h-0 h-full w-full",Gs(t),Ga(r))}function eu(e){if(Rs(e)>=100)return"";const r=Fr(e);return r==="center"?"mx-auto":r==="end"?"ml-auto":""}function tu(e){if(Rs(e)>=100)return"w-full";const r=Fr(e);return r==="center"||r==="end"?"min-w-0":r==="stretch"?"min-w-0 self-stretch":"min-w-0 self-start"}function ru(e){return e?e.widthMode==="full"||e.widthMode==="percent"||typeof e.widthPercent=="number"&&!Number.isNaN(e.widthPercent):!1}function fo(e){return(e.type==="button"||e.type==="editButton")&&!ru(e.appearance)}function nu(e){return fo(e)?Fr(e.appearance)==="stretch"?{width:"100%",maxWidth:"100%",minWidth:0}:{width:"auto",maxWidth:"100%"}:Ha(e.appearance)}function ou(e){return nu(e)}function su(e){if(fo(e))switch(Fr(e.appearance)){case"center":return"self-center";case"end":return"self-end";case"stretch":return"self-stretch";default:return"self-start"}return tu(e.appearance)}function iu(e){return e?e.verticalAlign!=null||e.cellJustify!=null:!1}function Ka(e){return e.type!=="button"&&e.type!=="editButton"||iu(e.appearance)?Yo(e.appearance):"start"}function qa(e){if(!e)return Zd(void 0);const t=Fr(e.appearance);return H("flex flex-col min-h-0 h-full w-full",Gs(t),Xo(e))}function Hv(e,t){const r={};e!==void 0&&(r.cellAlign=e),t!==void 0&&(r.cellJustify=t);const o=e===void 0&&t===void 0?void 0:r;return H(Gs(Fr(o)),Ga(Yo(o)))}const Ya=v.createContext({gridStretch:!1});function Jo(){return v.useContext(Ya)}const au=e=>{let t;const r=new Set,n=(u,f)=>{const l=typeof u=="function"?u(t):u;if(!Object.is(l,t)){const p=t;t=f??(typeof l!="object"||l===null)?l:Object.assign({},t,l),r.forEach(g=>g(t,p))}},o=()=>t,a={setState:n,getState:o,getInitialState:()=>c,subscribe:u=>(r.add(u),()=>r.delete(u))},c=t=e(n,o,a);return a},Wv=(e=>e?au(e):au),Rv=e=>e;function Xa(e,t=Rv){const r=v.useSyncExternalStore(e.subscribe,v.useCallback(()=>t(e.getState()),[e,t]),v.useCallback(()=>t(e.getInitialState()),[e,t]));return v.useDebugValue(r),r}const lu=e=>{const t=Wv(e),r=n=>Xa(t,n);return Object.assign(r,t),r},cu=(e=>e?lu(e):lu),Gv=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Kv=/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/,qv=/^\+?[\d\s-()]{10,}$/,Yv={required:e=>e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e=="boolean"?e===!0:!0,minLength:(e,t)=>{if(typeof e!="string")return!0;const r=t.value;return e.length>=r},maxLength:(e,t)=>{if(typeof e!="string")return!0;const r=t.value;return e.length<=r},min:(e,t)=>{if(typeof e!="number")return!0;const r=t.value;return e>=r},max:(e,t)=>{if(typeof e!="number")return!0;const r=t.value;return e<=r},pattern:(e,t)=>{if(typeof e!="string")return!0;const r=t.value,n=t.params?.flags||"";return new RegExp(r,n).test(e)},email:e=>typeof e!="string"||!e?!0:Gv.test(e),url:e=>typeof e!="string"||!e?!0:Kv.test(e),phone:e=>typeof e!="string"||!e?!0:qv.test(e),date:e=>{if(!e)return!0;const t=new Date(e);return!isNaN(t.getTime())},dateRange:(e,t)=>{if(!e)return!0;const r=new Date(e);if(isNaN(r.getTime()))return!1;const n=t.value,o=new Date;if(o.setHours(0,0,0,0),n.min){const s=n.min==="today"?o:new Date(n.min);if(r<s)return!1}if(n.max){const s=n.max==="today"?o:new Date(n.max);if(r>s)return!1}return!0},fileSize:(e,t)=>{if(!e)return!0;const r=t.value;return e instanceof File?e.size<=r:Array.isArray(e)?e.every(n=>n.size<=r):!0},fileType:(e,t)=>{if(!e)return!0;const r=t.value,n={"text/csv":[".csv"],"application/vnd.ms-excel":[".xls"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":[".xlsx"],"application/pdf":[".pdf"],"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"]},o=s=>r.some(i=>{if(i.endsWith("/*")){const u=i.replace("/*","");if(s.type.startsWith(u))return!0}else if(s.type===i)return!0;const a=s.name.toLowerCase(),c=n[i];return c?c.some(u=>a.endsWith(u)):i.startsWith(".")?a.endsWith(i.toLowerCase()):!1});return e instanceof File?o(e):Array.isArray(e)?e.every(s=>o(s)):!0},allowLetters:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[a-zA-Z]/.test(e),allowNumbers:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[0-9]/.test(e),allowSpecialChars:(e,t)=>typeof e!="string"||!e||t.value?!0:!/[^a-zA-Z0-9\s]/.test(e),minLetters:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[a-zA-Z]/g)||[]).length>=r},maxLetters:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[a-zA-Z]/g)||[]).length<=r},minNumbers:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[0-9]/g)||[]).length>=r},maxNumbers:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[0-9]/g)||[]).length<=r},minSpecialChars:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[^a-zA-Z0-9\s]/g)||[]).length>=r},maxSpecialChars:(e,t)=>{if(typeof e!="string"||!e)return!0;const r=t.value;return(e.match(/[^a-zA-Z0-9\s]/g)||[]).length<=r},custom:(e,t,r)=>!0,async:()=>!0};function rn(e,t,r={}){const n=Yv[t.type];if(!n)return!0;const o=n(e,t,r);return o===!1?t.message||Xv(t):typeof o=="string"?o:!0}function Xv(e){return{required:"This field is required",minLength:`Must be at least ${e.value} characters`,maxLength:`Must be at most ${e.value} characters`,min:`Must be at least ${e.value}`,max:`Must be at most ${e.value}`,pattern:"Invalid format",email:"Please enter a valid email address",url:"Please enter a valid URL",phone:"Please enter a valid phone number",date:"Please enter a valid date",dateRange:"Date is out of allowed range",fileSize:`File size must be less than ${Jv(e.value)}`,fileType:"File type is not allowed",allowLetters:"Letters are not allowed in this field",allowNumbers:"Numbers are not allowed in this field",allowSpecialChars:"Special characters are not allowed in this field",minLetters:`Must contain at least ${e.value} letters`,maxLetters:`Must contain at most ${e.value} letters`,minNumbers:`Must contain at least ${e.value} numbers`,maxNumbers:`Must contain at most ${e.value} numbers`,minSpecialChars:`Must contain at least ${e.value} special characters`,maxSpecialChars:`Must contain at most ${e.value} special characters`,custom:"Validation failed",async:"Validation failed"}[e.type]||"Invalid value"}function Jv(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const Qv=10;function qs(e){const t=e.properties;return t?.maxFiles!=null&&t.maxFiles>0?Math.floor(t.maxFiles):t?.multiple===!0?Qv:1}function du(e){return typeof e=="object"&&e!==null&&"url"in e&&typeof e.url=="string"&&e.url.length>0}function uu(e){try{return e.split("?")[0].split("/").filter(Boolean).pop()||e}catch{return e}}function Ys(e){if(e==null)return[];if(typeof e=="string")return e.startsWith("http")?[{url:e,name:uu(e)}]:[];if(e instanceof File)return[e];if(Array.isArray(e)){const t=[];for(const r of e)r instanceof File?t.push(r):typeof r=="string"&&r.startsWith("http")?t.push({url:r,name:uu(r)}):du(r)&&t.push(r);return t}return du(e)?[e]:[]}function Zv(e,t){return e.slice(0,t)}function Ja(e,t){const r=Zv(e,t);return r.length===0?null:t===1?r[0]??null:r}function ew(e){return Ys(e).length}function tw(e){return e==="file"||e==="camera"||e==="photoChoice"}function Qa(e,t){if(!tw(e.type))return;const r=qs(e);if(ew(t)>r)return`Maximum ${r} file(s) allowed`}const rw=4,nw=2,ow=10;function fu(e){const t=e.properties?.otpLength??e.metadata?.otpLength,r=typeof t=="number"?t:Number(t);return Number.isFinite(r)?Math.min(ow,Math.max(nw,Math.round(r))):rw}function sw(e,t){const r=String(e??"").replace(/\s/g,"").slice(0,t).split("");for(;r.length<t;)r.push("");return r}function iw(e){return e.join("").replace(/\s/g,"")}function Za(e,t){if(e.type!=="otp")return;const r=String(t??"").trim();if(!r)return;const n=fu(e);if(r.length!==n)return`Please enter a ${n}-digit OTP`}class Xs{static functions={SUM:(...t)=>t.flat().filter(n=>typeof n=="number").reduce((n,o)=>n+o,0),AVG:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length===0?0:r.reduce((n,o)=>n+o,0)/r.length},MIN:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length>0?Math.min(...r):0},MAX:(...t)=>{const r=t.flat().filter(n=>typeof n=="number");return r.length>0?Math.max(...r):0},ROUND:(t,r=0)=>{const n=Number(t);if(isNaN(n))return 0;const o=Math.pow(10,Number(r));return Math.round(n*o)/o},FLOOR:t=>Math.floor(Number(t)||0),CEIL:t=>Math.ceil(Number(t)||0),ABS:t=>Math.abs(Number(t)||0),CONCAT:(...t)=>t.map(String).join(""),UPPER:t=>String(t).toUpperCase(),LOWER:t=>String(t).toLowerCase(),TRIM:t=>String(t).trim(),LEN:t=>String(t).length,SUBSTR:(t,r,n)=>{const o=String(t),s=Number(r),i=n!==void 0?Number(n):void 0;return o.substring(s,i!==void 0?s+i:void 0)},IF:(t,r,n)=>t?r:n,IFEMPTY:(t,r)=>t==null||t===""?r:t,ISNUMBER:t=>typeof t=="number"&&!isNaN(t),ISEMPTY:t=>t==null?!0:typeof t=="string"?t.trim()==="":Array.isArray(t)?t.length===0:!1,TODAY:()=>new Date().toISOString().split("T")[0],NOW:()=>new Date().toISOString(),YEAR:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getFullYear()},MONTH:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getMonth()+1},DAY:t=>{const r=new Date(t);return isNaN(r.getTime())?null:r.getDate()},DATEDIFF:(t,r,n="days")=>{const o=new Date(t),s=new Date(r);if(isNaN(o.getTime())||isNaN(s.getTime()))return null;const a=(s.getTime()-o.getTime())/(1e3*60*60*24);switch(n){case"years":return a/365;case"months":return a/30;case"weeks":return a/7;case"hours":return a*24;case"minutes":return a*24*60;default:return a}},COUNT:t=>Array.isArray(t)?t.length:t?1:0,FIRST:t=>Array.isArray(t)?t[0]:t,LAST:t=>Array.isArray(t)?t[t.length-1]:t,SUMFIELD:(...t)=>{const r=t[0],n=t[1];return!Array.isArray(r)||typeof n!="string"?0:r.reduce((o,s)=>{if(typeof s=="object"&&s!==null){const i=s[n];return o+(Number(i)||0)}return o},0)}};calculate(t,r){try{const{fields:n,currentValue:o,previousValue:s}=r,i={...n};for(const l in i){const p=i[l];(p==null||p==="")&&(i[l]="")}const a={fields:i,currentValue:o,previousValue:s,...Xs.functions},c=Object.keys(a),u=Object.values(a),f=new Function(...c,`return ${t}`)(...u);if(f==null)return"";if(typeof f=="string"){if(f.includes("undefined"))return"";const l=f.trim();return l===""||/^\s+$/.test(f)?"":l}return f}catch{return""}}calculateAll(t,r){const n={...r};for(const o of t){const s={fields:n,currentValue:n[o.field],previousValue:r[o.field]},i=this.calculate(o.formula,s);n[o.field]=i===null?"":i}return n}validateFormula(t){try{return new Function("fields",`return ${t}`),{valid:!0}}catch(r){return{valid:!1,error:r instanceof Error?r.message:"Invalid formula"}}}getAvailableFunctions(){return[{name:"SUM",description:"Sum of values"},{name:"AVG",description:"Average of values"},{name:"MIN",description:"Minimum value"},{name:"MAX",description:"Maximum value"},{name:"ROUND",description:"Round to decimal places"},{name:"IF",description:"Conditional value"},{name:"CONCAT",description:"Concatenate strings"},{name:"TODAY",description:"Current date"},{name:"DATEDIFF",description:"Difference between dates"},{name:"COUNT",description:"Count of items"},{name:"SUMFIELD",description:"Sum field in array"}]}}const pu=new Xs;function mu(e){if(e==null||e==="")return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:Js(e);if(typeof e=="string"){const t=e.trim();if(!t)return null;const r=t.match(/^(\d{4})-(\d{2})-(\d{2})/);if(r){const o=new Date(Number(r[1]),Number(r[2])-1,Number(r[3]));return Number.isNaN(o.getTime())?null:o}const n=new Date(t);return Number.isNaN(n.getTime())?null:Js(n)}return null}function Js(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function aw(e,t=new Date){const r=Js(e),n=Js(t);if(n<r)return{years:0,months:0,days:0};let o=n.getFullYear()-r.getFullYear(),s=n.getMonth()-r.getMonth(),i=n.getDate()-r.getDate();if(i<0){s-=1;const a=new Date(n.getFullYear(),n.getMonth(),0).getDate();i+=a}return s<0&&(o-=1,s+=12),{years:Math.max(0,o),months:Math.max(0,s),days:Math.max(0,i)}}function el(e){if(e.type!=="number")return;const t=e.properties?.deriveFromDate;if(!(!t?.sourceFieldName||!t.part))return t}function Pr(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function tl(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(t):null}function lw(e,t){const r=tl(e);return r?`${t.sourceFieldName}${r}`:t.sourceFieldName}function hu(e,t,r){const n=tl(t);if(n)return[`${e}${n}`];const o=new Set([e]),s=`${e}__addmore__`;for(const i of Object.keys(r))(i===e||i.startsWith(s))&&o.add(i);return[...o]}function cw(e,t,r){const n=r?lw(r,e):e.sourceFieldName,o=mu(t[n]);if(!o)return null;const s=e.referenceDate==="today"||e.referenceDate==null?new Date:mu(t[e.referenceDate])??new Date;return aw(o,s)[e.part]}function gu(e,t){const r=el(e);return r?Pr(r.sourceFieldName)===Pr(t):!1}function rl(e,t,r,n){const o={...t},s=n?Pr(n):void 0;for(const i of e){if(i.type!=="number")continue;const a=el(i);if(!a||!i.name||s&&Pr(a.sourceFieldName)!==s)continue;const c=n??a.sourceFieldName,u=hu(i.name,c,o);for(const f of u){if(r.has(f))continue;const l=cw(a,o,f);o[f]=l}}return o}function dw(e,t,r,n){const o={...t},s=Pr(n);for(const i of e){if(!gu(i,s)||!i.name)continue;const a=hu(i.name,n,o);for(const c of a)r.delete(c),o[c]=null}return o}function yu(e,t){const r=Pr(t);return e.some(n=>gu(n,r))}function bu(e){if(e.apidata&&typeof e.apidata=="object")return e.apidata;if(e.metadata)try{const t=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata;if(t.apiEndpoint||t.apiKey||t.valueSource==="api")return{apiKey:t.apiKey,valueSource:t.valueSource,apiEndpoint:t.apiEndpoint,apiAutoDetect:t.apiAutoDetect,apiLabelField:t.apiLabelField,apiValueField:t.apiValueField,apiMethod:t.apiMethod,apiRealtime:t.apiRealtime,apiQueryParams:t.apiQueryParams,apiClientFilter:t.apiClientFilter}}catch{}return null}function nl(e,t,r,n){let o=ol(e,r);return n&&(o=Gn(o,t,r)),o}function ol(e,t){return e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(r,n)=>t?.[n]!==void 0&&t[n]!==null?String(t[n]):r)}function Gn(e,t,r){let n=e.replace(/\{(?:ctx:|\@)(\w+)\}/g,(o,s)=>r?.[s]!==void 0&&r[s]!==null?String(r[s]):o);return n=n.replace(/\{(\w+)\}/g,(o,s)=>{if(o.includes("ctx:")||o.includes("@"))return o;let i=t[s];if(i==null||i===""){const a=Object.keys(t).find(c=>c.toLowerCase()===s.toLowerCase());a&&(i=t[a])}return i!=null&&i!==""?String(i):o}),n}function po(e,t){const r=e.match(/\{(\w+)\}/g)||[],n=[];t?.custom&&t.custom.forEach(({value:s})=>{if(s){const i=s.match(/\{(\w+)\}/g)||[];n.push(...i.filter(a=>!a.includes("ctx:")&&!a.includes("@")))}});const o=r.filter(s=>!s.includes("ctx:")&&!s.includes("@"));return new Set([...o.map(s=>s.replace(/[{}]/g,"")),...n.map(s=>s.replace(/[{}]/g,""))])}function uw(e,t){const r=e[t];return r==null||r===""}function Qs(e){const{apiEndpoint:t,apiMethod:r="GET",apiQueryParams:n={},formValues:o,submissionContext:s,apiRealtime:i,additionalRequiredFieldNames:a=[],excludeFormFieldNames:c=[]}=e,u=(r||"GET").toLowerCase(),f=po(t,n),l=new Set((c||[]).filter(w=>typeof w=="string"&&w.length>0)),p=new Set((a||[]).filter(w=>typeof w=="string"&&w.length>0)),g=new Set([...f,...p]);let m=!1;for(const w of g){const A=!!(i&&f.has(w)),x=p.has(w);if((A||x)&&uw(o,w)){m=!0;break}}if(m)return{blocked:!0,url:t,postBodyBase:null};let h=t;const y=t.match(/\{(\w+)\}/g)||[];if(h=ol(h,s),i&&(h=Gn(h,o,s)),n&&Object.keys(n).length>0){const w=n,A=[];if(w.limit){let x=w.limit;i&&(x=Gn(x,o,s)),A.push(`_limit=${encodeURIComponent(x)}`)}if(w.page){let x=w.page;i&&(x=Gn(x,o,s)),A.push(`page=${encodeURIComponent(x)}`)}if(w.sort){let x=w.sort;i&&(x=Gn(x,o,s)),A.push(`sort=${encodeURIComponent(x)}`)}if(w.orderBy){let x=w.orderBy;i&&(x=Gn(x,o,s)),A.push(`orderBy=${encodeURIComponent(x)}`)}if(w.custom?.length&&w.custom.forEach(({key:x,value:F})=>{if(!x||!F)return;let N=ol(F,s);i&&(N=Gn(N,o,s)),N.match(/\{[^}]+\}/)?N.match(/\{(?!ctx:|\@)(\w+)\}/g)||A.push(`${encodeURIComponent(x)}=`):A.push(`${encodeURIComponent(x)}=${encodeURIComponent(N)}`)}),A.length>0){const x=h.includes("?")?"&":"?";h=`${h}${x}${A.join("&")}`}}if(i&&Object.keys(o).length>0&&u==="get"){const w=N=>N.replace(/\{/g,"").replace(/\}/g,""),A=[];for(const N of n.custom||[])if(N.value){const k=N.value.match(/\{(\w+)\}/g)||[];A.push(...k.map(w))}const x=new Set([...y.map(w),...A]),F={};Object.keys(o).forEach(N=>{!x.has(N)&&!l.has(N)&&(F[N]=o[N])}),Object.keys(F).length>0&&(h=`${h}${h.includes("?")?"&":"?"}${new URLSearchParams(F).toString()}`)}let S=null;if(["post","put","patch"].includes(u))if(i&&Object.keys(o).length>0){S={...o};for(const w of l)delete S[w]}else{S={...o||{}};for(const w of l)delete S[w]}return{blocked:!1,url:h,postBodyBase:S}}const fw=new Set(["select","multiselect","asyncsearch"]);function pw(e){return e?.type==="multiselect"?[]:""}function vu(e){if(!fw.has(e.type))return[];const t=e.properties??{},r=bu(e),n=new Set,o=r?.apiClientFilter?.matchField?.trim()||t.apiClientFilter?.matchField?.trim();o&&n.add(o);const s=[...Array.isArray(t.dependentFields)?t.dependentFields:[],...Array.isArray(r?.dependentFields)?r.dependentFields:[]];for(const u of s)typeof u=="string"&&u.trim()&&n.add(u.trim());const i=r?.apiEndpoint||t.apiEndpoint,a=r?.apiRealtime??t.apiRealtime,c=r?.apiQueryParams||t.apiQueryParams;if(i&&a)for(const u of po(i,c))n.add(u);return[...n]}function mw(e,t){const r=Pr(t);return vu(e).some(n=>Pr(n)===r)}function hw(e,t){const r=Pr(t);return e.some(n=>mw(n,r))}function gw(e){const t=new Map;for(const r of e){const n=r.name;if(n)for(const o of vu(r)){const s=Pr(o),i=t.get(s)??new Set;i.add(n),t.set(s,i)}}return t}function yw(e,t,r){const n=tl(t);if(n)return[`${e}${n}`];const o=new Set([e]),s=`${e}__addmore__`;for(const i of Object.keys(r))(i===e||i.startsWith(s))&&o.add(i);return[...o]}function bw(e,t){return e===t?!0:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((r,n)=>r===t[n]):!1}function vw(e,t,r){const n=gw(e),o=Pr(r),s=new Set,i=[o];for(;i.length>0;){const u=i.shift(),f=n.get(u);if(f)for(const l of f)s.has(l)||(s.add(l),i.push(l))}const a={...t},c=[];for(const u of s){const f=e.find(p=>p.name===u),l=pw(f);for(const p of yw(u,r,a))bw(a[p],l)||c.push(p),a[p]=l}return{values:a,clearedKeys:c}}function sl(e,t){const r=t instanceof Set?t:new Set(t);if(e.size!==r.size)return!1;for(const n of e)if(!r.has(n))return!1;return!0}function wu(){return cu((e,t)=>({schema:null,values:{},initialValues:{},errors:{},touched:{},isValidating:!1,isSubmitting:!1,submitCount:0,isValid:!0,currentStep:0,totalSteps:1,completedSteps:new Set,visibleFields:new Set,enabledFields:new Set,requiredFields:new Set,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:new Set,draftId:null,setSchema:(r,n)=>{const o=t(),s=o.schema!=null&&o.schema.id===r.id,i=n?.forceReset===!0,a={},c=new Set,u=new Set,f=new Set;r.fields.forEach(x=>{const F=x.name||x.key||x.id;F&&(x.defaultValue!==void 0&&(x.type==="multiselect"?a[F]=Array.isArray(x.defaultValue)?x.defaultValue:x.defaultValue!=null&&x.defaultValue!==""?[String(x.defaultValue)]:[]:a[F]=x.defaultValue),x.hidden||c.add(F),x.disabled||u.add(F),x.validation?.some(N=>N.type==="required")&&f.add(F))});const l=r.steps?.length||1,p=typeof n?.initialStepIndex=="number",g=p?Math.max(0,Math.min(n.initialStepIndex,Math.max(0,l-1))):0,m=new Set;for(let x=0;x<g;x++)m.add(x);const h=[];r.fields.forEach(x=>{const F=x.properties;F?.valueSource==="calculated"&&F?.formula&&h.push({field:x.name,formula:F.formula})});const y=h.length>0?pu.calculateAll(h,a):{},S=rl(r.fields,{...a,...y},new Set),A=s&&!(i||p)?{...S,...o.values}:S;e({schema:r,values:A,initialValues:S,errors:{},touched:{},currentStep:g,totalSteps:l,completedSteps:m,visibleFields:c,enabledFields:u,requiredFields:f,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:i||!s?new Set:o.derivedFieldDirty,isValid:!0,draftId:null})},setFieldValue:(r,n,o)=>{const s=t(),i=s.schema,a=o?.source??"user";let c=new Set(s.derivedFieldDirty);const u=s.values[r];let f={...s.values,[r]:n},l=[];if(i){const p=Pr(r),g=i.fields.find(S=>S.name===p);a==="user"&&g&&el(g)&&c.add(r);const m=n==null||n===""||Array.isArray(n)&&n.length===0;if(yu(i.fields,r)&&m?f=dw(i.fields,f,c,r):yu(i.fields,r)&&(f=rl(i.fields,f,c,r)),a==="user"&&u!==n&&!(Array.isArray(u)&&Array.isArray(n)&&u.length===n.length&&u.every((S,w)=>S===n[w]))&&hw(i.fields,r)){const S=vw(i.fields,f,r);f=S.values,l=S.clearedKeys}const y=[];i.fields.forEach(S=>{const w=S.properties;w?.valueSource==="calculated"&&w?.formula&&(w.formulaSteps??[]).some(x=>x.type==="field"&&x.fieldName===r)&&y.push({field:S.name,formula:w.formula})}),y.length>0&&(f={...f,...pu.calculateAll(y,f)})}e({values:f,derivedFieldDirty:c}),l.length>0&&e(p=>{const g={...p.errors};for(const m of l)delete g[m];return Object.keys(g).length===Object.keys(p.errors).length?p:{errors:g}}),i?.config.validateOnChange?t().validateField(r):e(p=>{const g={...p.errors};return delete g[r],{errors:g}})},setFieldTouched:(r,n=!0)=>{e(s=>({touched:{...s.touched,[r]:n}}));const o=t().schema;n&&o?.config.validateOnBlur&&t().validateField(r)},setFieldError:(r,n)=>{e(o=>{const s=!!o.errors[r];if(!n&&!s||n&&o.errors[r]===n)return o;const i={...o.errors};return n?i[r]=n:delete i[r],{errors:i,isValid:Object.keys(i).length===0}})},setValues:r=>{const n=t(),o=n.schema;if(!o){e({values:r});return}const s=rl(o.fields,r,n.derivedFieldDirty);e({values:s})},setErrors:r=>e({errors:r,isValid:Object.keys(r).length===0}),resetForm:()=>{const{initialValues:r}=t();e({values:{...r},errors:{},touched:{},currentStep:0,completedSteps:new Set,derivedFieldDirty:new Set,isValid:!0,submitCount:0})},clearForm:()=>{e({schema:null,values:{},initialValues:{},errors:{},touched:{},currentStep:0,totalSteps:1,completedSteps:new Set,visibleFields:new Set,enabledFields:new Set,requiredFields:new Set,readOnlyFields:new Set,editableFields:new Set,formDisabled:!1,derivedFieldDirty:new Set,isValid:!0,submitCount:0,draftId:null})},validateField:async r=>{const{schema:n,values:o}=t();if(!n)return;const s=n.fields.find(a=>a.name===r);if(!s)return;e({isValidating:!0});let i;if(s.validation)for(const a of s.validation){const c=rn(o[r],a,o);if(typeof c=="string"){i=c;break}}if(!i){const a=Qa(s,o[r]);a&&(i=a)}return!i&&s.type==="otp"&&(i=Za(s,o[r])),e(a=>{const c={...a.errors};return i?c[r]=i:delete c[r],{errors:c,isValid:Object.keys(c).length===0,isValidating:!1}}),i},validateForm:async()=>{const{schema:r,values:n,visibleFields:o,requiredFields:s}=t();if(!r)return!1;e({isValidating:!0});const i={};for(const a of r.fields)if(o.has(a.name)){if(a.validation)for(const c of a.validation){if(c.type==="required"&&!s.has(a.name))continue;const u=rn(n[a.name],c,n);if(typeof u=="string"){i[a.name]=u;break}}if(!i[a.name]){const c=Qa(a,n[a.name]);c&&(i[a.name]=c)}if(!i[a.name]){const c=Za(a,n[a.name]);c&&(i[a.name]=c)}}return e({errors:i,isValid:Object.keys(i).length===0,isValidating:!1}),Object.keys(i).length===0},validateStep:async r=>{const{schema:n,values:o,visibleFields:s}=t();if(!n?.steps)return!0;const i=n.steps[r];if(!i)return!0;e({isValidating:!0});const a={};for(const c of i.fields){const u=n.fields.find(f=>f.name===c);if(!(!u||!s.has(u.name))){if(u.validation)for(const f of u.validation){const l=rn(o[u.name],f,o);if(typeof l=="string"){a[u.name]=l;break}}if(!a[u.name]){const f=Qa(u,o[u.name]);f&&(a[u.name]=f)}if(!a[u.name]){const f=Za(u,o[u.name]);f&&(a[u.name]=f)}}}return e(c=>({errors:{...c.errors,...a},isValid:Object.keys(a).length===0,isValidating:!1})),Object.keys(a).length===0},nextStep:async()=>{const{currentStep:r,totalSteps:n,schema:o}=t();return o?.steps?.[r]?.validation==="onNext"&&!await t().validateStep(r)?!1:r<n-1?(e(i=>({currentStep:r+1,completedSteps:new Set([...i.completedSteps,r])})),!0):!1},prevStep:()=>{const{currentStep:r}=t();r>0&&e({currentStep:r-1})},goToStep:r=>{const{totalSteps:n,completedSteps:o,currentStep:s}=t();r>=0&&r<n&&(r<=s||o.has(r-1))&&e({currentStep:r})},setSubmitting:r=>e({isSubmitting:r}),incrementSubmitCount:()=>e(r=>({submitCount:r.submitCount+1})),updateVisibility:r=>{e(n=>{const o=new Set(r);return sl(n.visibleFields,o)?n:{visibleFields:o}})},updateEnabled:r=>{e(n=>{const o=new Set(r);return sl(n.enabledFields,o)?n:{enabledFields:o}})},updateRequired:r=>{e(n=>{const o=new Set(r);return sl(n.requiredFields,o)?n:{requiredFields:o}})},updateReadOnly:r=>e({readOnlyFields:new Set(r)}),updateEditable:r=>e({editableFields:new Set(r)}),updateFormDisabled:r=>e({formDisabled:r}),saveDraft:()=>{const{schema:r,values:n}=t();if(!r)return;const o=`formsmith_draft_${r.id}`;try{localStorage.setItem(o,JSON.stringify({values:n,savedAt:new Date().toISOString()})),e({draftId:o})}catch{}},loadDraft:()=>{const{schema:r}=t();if(!r)return!1;const n=`formsmith_draft_${r.id}`;try{const o=localStorage.getItem(n);if(o){const{values:s}=JSON.parse(o);return e({values:s,draftId:n}),!0}}catch{}return!1},clearDraft:()=>{const{schema:r,draftId:n}=t();if(!r)return;const o=n||`formsmith_draft_${r.id}`;try{localStorage.removeItem(o),e({draftId:null})}catch{}}}))}const Kn=wu();function ww(e=Kn){return e.getState()}const Su=v.createContext(null),il=({children:e})=>{const t=v.useRef(null);return t.current||(t.current=wu()),d.jsx(Su.Provider,{value:t.current,children:e})};function Zs(){return v.useContext(Su)??Kn}function Or(e){const t=Zs();return e?Xa(t,e):Xa(t)}function xu({schema:e,initialValues:t,onSubmit:r,onChange:n,workflowStepId:o,initialStepIndex:s}){const{values:i,errors:a,touched:c,isValidating:u,isSubmitting:f,submitCount:l,isValid:p,currentStep:g,totalSteps:m,completedSteps:h,visibleFields:y,enabledFields:S,requiredFields:w,setSchema:A,setFieldValue:x,setFieldTouched:F,setFieldError:N,setValues:k,resetForm:T,validateField:P,validateForm:E,validateStep:C,nextStep:I,prevStep:W,goToStep:M,setSubmitting:z,incrementSubmitCount:V,saveDraft:X,loadDraft:L,clearDraft:B}=Or(),D=Zs(),K=v.useRef(null);v.useLayoutEffect(()=>{if(A(e,{forceReset:!!o||typeof s=="number",initialStepIndex:s}),t&&Object.keys(t).length>0){const re=D.getState().values;k({...re,...t});try{K.current=JSON.stringify(t)}catch{K.current=null}}else K.current=null},[e.id,o,s]),v.useLayoutEffect(()=>{if(!t||Object.keys(t).length===0)return;let re;try{re=JSON.stringify(t)}catch{return}if(re===K.current)return;const ge=D.getState().values;k({...ge,...t}),K.current=re},[t,k]);const ae=v.useCallback((re,ge)=>{const Se={...i,[re]:ge};x(re,ge),n?.(Se,re)},[x,n,i]),j=v.useCallback(async re=>{if(re?.preventDefault(),V(),!await E())return{success:!1,errors:Object.entries(a).map(([Se,pt])=>({field:Se,rule:"validation",message:pt}))};if(!r)return{success:!0};z(!0);try{const Se=await r(i);return Se.success&&B(),Se}catch(Se){return{success:!1,message:Se instanceof Error?Se.message:"Submission failed"}}finally{z(!1)}},[E,r,i,a,V,z,B]),U=v.useCallback(re=>({value:i[re],error:a[re],touched:c[re]||!1,isVisible:y.has(re),isEnabled:S.has(re),isRequired:w.has(re)}),[i,a,c,y,S,w]),le=v.useMemo(()=>{if(!e.steps||e.steps.length===0)return e.fields;const re=e.steps[g];return re?e.fields.filter(ge=>re.fields.includes(ge.name)):[]},[e,g]),oe=g===0,G=g===m-1,ie=v.useCallback(re=>h.has(re),[h]),Ce=v.useMemo(()=>m<=1?100:Math.round(h.size/m*100),[h.size,m]),ee=v.useCallback(re=>y.has(re),[y]),ne=v.useCallback(re=>S.has(re),[S]),he=v.useCallback(re=>w.has(re),[w]),Ie=v.useMemo(()=>Object.entries(a).filter(([re])=>y.has(re)),[a,y]),Ue=Ie.length>0;return{values:i,errors:a,touched:c,isValidating:u,isSubmitting:f,submitCount:l,isValid:p,hasErrors:Ue,visibleErrors:Ie,currentStep:g,totalSteps:m,completedSteps:h,currentStepFields:le,isFirstStep:oe,isLastStep:G,isStepCompleted:ie,progress:Ce,setFieldValue:ae,setFieldTouched:F,setFieldError:N,setValues:k,validateField:P,getFieldState:U,shouldShowField:ee,isFieldEnabled:ne,isFieldRequired:he,handleSubmit:j,resetForm:T,validateForm:E,validateStep:C,nextStep:I,prevStep:W,goToStep:M,saveDraft:X,loadDraft:L,clearDraft:B}}function Au(e){return"logic"in e&&"conditions"in e}function Qo(e){if(e==null||typeof e!="object")return!1;const t=e;if(t.status==="error")return!1;if(t.status==="success"||t.status==="COMPLETED")return!0;const r=t.code;return typeof r=="number"&&r>=200&&r<300||t.data!=null&&t.status!=="error"}function Cu(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;const r=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let n=e;for(const o of r){if(n==null||typeof n!="object")return;n=n[o]}return n}function Ge(e,t){if(e==null||typeof t!="string"||t.trim()==="")return;let r=Cu(e,t);if(r===void 0&&t.includes(".")){const n=t.split(".");if(n.length>=2){const o=n[0],s=n.slice(1).join("."),i=Cu(e,o);Array.isArray(i)&&i.length>0&&(r=Ge(i[0],s))}}return r}const Sw=new Set(["section","group","columns","divider","header","sectionHeading","spacer","textLabel","addmore","customizeSections"]);function xw(e){return e===!0||e==="true"?!0:e===!1||e==="false"?!1:e}function Aw(e,t){if(e==null||typeof t.path!="string"||!t.path.trim())return!1;const r=Ge(e,t.path),n=xw(t.value);switch(t.operator){case"equals":return r===n;case"notEquals":return r!==n;case"contains":return typeof r=="string"?r.includes(String(n)):Array.isArray(r)?r.includes(n):!1;case"notContains":return typeof r=="string"?!r.includes(String(n)):Array.isArray(r)?!r.includes(n):!0;case"startsWith":return typeof r=="string"&&r.startsWith(String(n));case"endsWith":return typeof r=="string"&&r.endsWith(String(n));case"greaterThan":return Number(r)>Number(n);case"lessThan":return Number(r)<Number(n);case"greaterThanOrEqual":return Number(r)>=Number(n);case"lessThanOrEqual":return Number(r)<=Number(n);case"isEmpty":return r==null?!0:typeof r=="string"?r.trim()==="":Array.isArray(r)?r.length===0:typeof r=="object"&&r!==null?Object.keys(r).length===0:!1;case"isNotEmpty":return r==null?!1:typeof r=="string"?r.trim()!=="":Array.isArray(r)?r.length>0:typeof r=="object"&&r!==null?Object.keys(r).length>0:!1;case"isTrue":return r===!0;case"isFalse":return r===!1;case"isNull":return r==null;case"isNotNull":return r!=null;case"in":return Array.isArray(n)?n.includes(r):!1;case"notIn":return Array.isArray(n)?!n.includes(r):!0;case"between":if(Array.isArray(n)&&n.length===2){const o=Number(r);return o>=Number(n[0])&&o<=Number(n[1])}return!1;case"regex":try{return new RegExp(String(n)).test(String(r??""))}catch{return!1}default:return!1}}function Cw(e,t,r){return e?e==="__allFields__"?t.filter(n=>!Sw.has(n.type)).map(n=>r(n)).filter(Boolean):e==="__allButtons__"?t.filter(n=>n.type==="button"||n.type==="editButton").map(n=>r(n)).filter(Boolean):[e]:[]}function Eu(e){return String(e||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").replace(/_+/g,"_")}function Nu(e,t){const r=Eu(e)||"row",n=Eu(t)||"cell";return`${r}_${n}`}function Ew(e){return e.kind==="static"?e.row.id:e.block.id}function Nw(e,t){let r=e,n=2;for(;t.has(r);)r=`${e}_${n}`,n+=1;return t.add(r),r}function ku(e,t,r,n){const o=e.cellKey?.trim();if(o)return n.add(o),e;const s=Nu(t,r),i=Nw(s,n);return{...e,cellKey:i}}function _u(e){const t=new Set,r=(e.rowSlots??[]).map(n=>{if(n.kind==="static"){const i=n.row.id,a={};for(const[c,u]of Object.entries(n.row.cells))a[c]=ku(u,i,c,t);return{...n,row:{...n.row,cells:a}}}const o=n.block.id,s={};for(const[i,a]of Object.entries(n.block.cells))s[i]=ku(a,o,i,t);return{...n,block:{...n.block,cells:s}}});return{...e,rowSlots:r}}function Tu(e){const t=new Map;for(const r of e.rowSlots??[]){const n=Ew(r),o=r.kind,s=r.kind==="static"?r.row.cells:r.block.cells;for(const[i,a]of Object.entries(s)){const c=a.cellKey?.trim()||Nu(n,i);t.set(c,{slotId:n,rowKind:o,columnKey:i})}}return t}function kw(e,t,r){return t.rowKind==="static"?e.find(n=>n.slotId===t.slotId&&n.rowKind==="static"):r?.slotId===t.slotId&&r.rowKind==="dynamic"?r:e.find(n=>n.slotId===t.slotId&&n.rowKind==="dynamic")}function Fu(e,t,r,n,o){const s=r?.trim();if(!s)return 0;const a=Tu(e).get(s);if(a){if(o?.slotId&&a.slotId!==o.slotId||o?.rowKind&&a.rowKind!==o.rowKind)return 0;const c=kw(t,a,n);return c?al(c.values[a.columnKey]):0}if(n&&s in n.values)return al(n.values[s]);if(o?.slotId){const c=t.find(u=>u.slotId===o.slotId&&(!o.rowKind||u.rowKind===o.rowKind));if(c&&s in c.values)return al(c.values[s])}return 0}function al(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}const Pu="__fieldRef:",Ou="__billingCell:";function _w(e){const t={kind:"static",staticValue:"",fieldName:"",billingFieldName:"",cellKey:""};if(e==null)return t;const r=String(e);if(r.startsWith(Pu))return{...t,kind:"field",fieldName:r.slice(Pu.length)};if(r.startsWith(Ou)){const n=r.slice(Ou.length),o=n.indexOf("|");return o>=0?{...t,kind:"billingCell",billingFieldName:n.slice(0,o),cellKey:n.slice(o+1)}:{...t,kind:"billingCell",cellKey:n}}if(r.startsWith("field:"))return{...t,kind:"field",fieldName:r.slice(6)};if(r.startsWith("billing:")){const n=r.slice(8),o=n.indexOf("|");return o>=0?{...t,kind:"billingCell",billingFieldName:n.slice(0,o),cellKey:n.slice(o+1)}:{...t,kind:"billingCell",cellKey:n}}return{...t,kind:"static",staticValue:r}}function ll(e){return e.name||e.key||e.id}function Tw(e,t){const r=t.find(n=>n.id===e||n.name===e||n.key===e);return r?ll(r):e}function Fw(e,t,r,n){const o=t.trim();if(!o)return;const s=n.filter(a=>a.type==="billingGrid"),i=e?.trim()?s.filter(a=>ll(a)===e||a.name===e||a.id===e):s;for(const a of i){const c=_u(a.properties??{}),u=r[ll(a)];if(!u?.rows?.length)continue;const l=Tu(c).get(o);if(!l)continue;const p=u.rows.find(g=>l.rowKind==="static"?g.slotId===l.slotId&&g.rowKind==="static":g.slotId===l.slotId&&g.rowKind==="dynamic");if(p)return p.values[l.columnKey]}}function Pw(e,t,r){const n=_w(e);if(n.kind==="field"){const o=Tw(n.fieldName,r);return t[o]}return n.kind==="billingCell"?Fw(n.billingFieldName,n.cellKey,t,r):n.staticValue}function Iu(e,t){if(e===t)return!0;if(e==null||t===void 0||t===null)return!1;const r=Number(e),n=Number(t);return!Number.isNaN(r)&&!Number.isNaN(n)&&String(e).trim()!==""&&String(t).trim()!==""?r===n:String(e).trim()===String(t).trim()}const Mu="__buttonResponse:";function Ow({fields:e,values:t,buttonResponses:r,prepopulateResponse:n=null,prepopulateResponseRules:o}){const{updateVisibility:s,updateEnabled:i,updateRequired:a,updateReadOnly:c,updateEditable:u,updateFormDisabled:f}=Or(),l=v.useCallback(N=>N.name||N.key||N.id,[]),p=v.useCallback((N,k)=>{if(!N)return l(k);const T=e.find(P=>P.id===N||P.name===N||P.key===N);return T?l(T):N},[e,l]),g=v.useCallback(N=>{const k=e.find(T=>T.id===N||T.name===N||T.key===N);return k?l(k):N},[e,l]),m=v.useCallback(N=>{const{field:k,operator:T,value:P}=N;if(typeof k=="string"&&k.startsWith(Mu)){const W=k.slice(Mu.length),M=r?.[W],z=Qo(M);return P==="success"?z:P==="failure"?M!=null&&!z:!1}const E=g(k),C=t[E],I=Pw(P,t,e);switch(T){case"equals":return Iu(C,I);case"notEquals":return!Iu(C,I);case"contains":return typeof C=="string"?C.includes(String(I)):Array.isArray(C)?C.includes(I):!1;case"notContains":return typeof C=="string"?!C.includes(String(I)):Array.isArray(C)?!C.includes(I):!0;case"startsWith":return typeof C=="string"&&C.startsWith(String(I));case"endsWith":return typeof C=="string"&&C.endsWith(String(I));case"greaterThan":return Number(C)>Number(I);case"lessThan":return Number(C)<Number(I);case"greaterThanOrEqual":return Number(C)>=Number(I);case"lessThanOrEqual":return Number(C)<=Number(I);case"isEmpty":return C==null?!0:C instanceof File?!1:typeof C=="string"?C.trim()==="":Array.isArray(C)?(C.length>0&&C[0]instanceof File,C.length===0):typeof C=="object"&&C!==null?Object.keys(C).length===0:!1;case"isNotEmpty":return C==null?!1:C instanceof File?!0:typeof C=="string"?C.trim()!=="":Array.isArray(C)?(C.length>0&&C[0]instanceof File,C.length>0):typeof C=="object"&&C!==null?Object.keys(C).length>0:!1;case"isTrue":return C===!0;case"isFalse":return C===!1;case"isNull":return C==null;case"isNotNull":return C!=null;case"in":return Array.isArray(I)?I.includes(C):!1;case"notIn":return Array.isArray(I)?!I.includes(C):!0;case"between":if(Array.isArray(I)&&I.length===2){const W=Number(C);return W>=Number(I[0])&&W<=Number(I[1])}return!1;case"regex":try{return new RegExp(String(I)).test(String(C))}catch{return!1}default:return!0}},[t,g,r,e]),h=v.useCallback(N=>{const k=N.conditions.map(T=>Au(T)?h(T):m(T));return N.logic==="and"?k.every(Boolean):k.some(Boolean)},[m]),y=v.useCallback(N=>Au(N)?h(N):m(N),[m,h]),S=v.useCallback(()=>{const N=new Set,k=new Set,T=new Set,P=new Set,E=new Set;e.forEach(M=>{const z=l(M);M.hidden||N.add(z),M.disabled||k.add(z),M.validation?.some(V=>V.type==="required")&&T.add(z)});let C=!1;if(n!=null&&o?.length)for(const M of o){if(!Aw(n,M.when))continue;const{action:z,target:V}=M.then;if(z==="disableForm")C=!0;else if(z==="enableForm")C=!1;else{const X=Cw(V,e,l);for(const L of X)switch(z){case"disable":k.delete(L);break;case"enable":k.add(L);break;case"hide":N.delete(L);break;case"show":N.add(L);break;case"readOnly":P.add(L),E.delete(L);break;case"editable":E.add(L),P.delete(L);break}}}e.forEach(M=>{M.conditions&&M.conditions.forEach(z=>{(y(z.when)?z.then:z.else||[]).forEach(L=>{switch(L.action){case"disableForm":C=!0;break;case"enableForm":C=!1;break;default:{const B=p(L.target,M);switch(L.action){case"show":N.add(B);break;case"hide":N.delete(B);break;case"enable":k.add(B);break;case"disable":k.delete(B);break;case"require":T.add(B);break;case"unrequire":T.delete(B);break}break}}})})});const I=M=>e.filter(z=>z.type!=="editButton"&&(z.name||z.key||z.id)).map(z=>l(z)),W=()=>e.filter(M=>M.type==="button").map(M=>l(M));return e.forEach(M=>{if(M.type!=="editButton")return;const z=l(M);if(!Qo(r?.[z]))return;const V=M.properties;V?.rules&&V.rules.length>0?V.rules.forEach(X=>{const L=[];X.allFields&&L.push(...I(M.id)),X.allButtons&&L.push(...W()),X.fieldNames?.length&&X.fieldNames.forEach(B=>{const D=e.find(K=>l(K)===B||K.id===B||K.name===B);L.push(D?l(D):B)}),X.buttonNames?.length&&L.push(...X.buttonNames),L.forEach(B=>{switch(X.action){case"enable":k.add(B),P.delete(B);break;case"disable":k.delete(B);break;case"show":N.add(B);break;case"hide":N.delete(B);break;case"readOnly":P.add(B);break;case"editable":E.add(B);break}})}):((V?.enableFieldNames??[]).forEach(X=>k.add(X)),(V?.disableFieldNames??[]).forEach(X=>k.delete(X)),(V?.showFieldNames??[]).forEach(X=>N.add(X)),(V?.hideFieldNames??[]).forEach(X=>N.delete(X)))}),{visible:Array.from(N),enabled:Array.from(k),required:Array.from(T),readOnly:Array.from(P),editable:Array.from(E),formDisabled:C}},[e,y,l,p,t,r,n,o]),w=v.useMemo(()=>S(),[S]);v.useLayoutEffect(()=>{s(w.visible),i(w.enabled),a(w.required),c(w.readOnly??[]),u(w.editable??[]),f(w.formDisabled??!1)},[w,s,i,a,c,u,f]);const A=v.useCallback(N=>w.visible.includes(N),[w.visible]),x=v.useCallback(N=>w.enabled.includes(N),[w.enabled]),F=v.useCallback(N=>w.required.includes(N),[w.required]);return{evaluateCondition:y,evaluateExpression:m,evaluateGroup:h,isFieldVisible:A,isFieldEnabled:x,isFieldRequired:F,visibleFields:w.visible,enabledFields:w.enabled,requiredFields:w.required}}function mn({className:e,type:t,...r}){return d.jsx("input",{type:t,"data-slot":"input",className:H("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground text-foreground dark:bg-secondary dark:border-input border-input flex h-9 w-full min-w-0 rounded-md border bg-background px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...r})}function Lu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function qn(...e){return t=>{let r=!1;const n=e.map(o=>{const s=Lu(o,t);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let o=0;o<n.length;o++){const s=n[o];typeof s=="function"?s():Lu(e[o],null)}}}}function Qe(...e){return b.useCallback(qn(...e),e)}var Iw=Symbol.for("react.lazy"),ei=b[" use ".trim().toString()];function Mw(e){return typeof e=="object"&&e!==null&&"then"in e}function Du(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Iw&&"_payload"in e&&Mw(e._payload)}function cl(e){const t=Lw(e),r=b.forwardRef((n,o)=>{let{children:s,...i}=n;Du(s)&&typeof ei=="function"&&(s=ei(s._payload));const a=b.Children.toArray(s),c=a.find(Bw);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}var Bu=cl("Slot");function Lw(e){const t=b.forwardRef((r,n)=>{let{children:o,...s}=r;if(Du(o)&&typeof ei=="function"&&(o=ei(o._payload)),b.isValidElement(o)){const i=jw(o),a=$w(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Dw=Symbol("radix.slottable");function Bw(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Dw}function $w(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function jw(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var zw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Uw=zw.reduce((e,t)=>{const r=cl(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Vw="Label",$u=b.forwardRef((e,t)=>d.jsx(Uw.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));$u.displayName=Vw;var Hw=$u;function Fn({className:e,...t}){return d.jsx(Hw,{"data-slot":"label",className:H("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50 mb-2",e),...t})}function ft(e){return`formsmith-field-${e.id}`}function ti(e){return`formsmith-label-${e.id}`}function Zo(e){return`formsmith-desc-${e.id}`}function es(e){return`formsmith-error-${e.id}`}function Lt(e,t){const r=[];return e.description&&r.push(Zo(e)),t&&r.push(es(e)),r.length>0?r.join(" "):void 0}function Jt(e){return e?!0:void 0}const Ww={body:{fontSize:"0.875rem",lineHeight:"1.25rem",fontWeight:400},heading:{fontSize:"1.125rem",lineHeight:"1.5rem",fontWeight:600},label:{fontSize:"0.875rem",lineHeight:"1.25rem",fontWeight:500},caption:{fontSize:"0.75rem",lineHeight:"1rem",fontWeight:400,color:"var(--muted-foreground)"}};function Pn(e){return e.ui?.cellStyle}function Rw(e){const t=e.ui;if(!t)return;const r=t.fontToken?Ww[t.fontToken]:void 0;if(!(!r&&!t.wrapperStyle))return{...r,...t.wrapperStyle}}function Gw(e){return e.type==="button"||e.type==="editButton"}const At=({field:e,error:t,isRequired:r,children:n,className:o,hideLabel:s})=>{const{gridStretch:i}=Jo(),a=i&&Ks(e),c=!(s??e.appearance?.hideLabel)&&e.label,u=e.appearance?.labelPlacement||"top",f=Rw(e),l=e.appearance?.minWidth!=null||e.appearance?.minHeight!=null?{...e.appearance.minWidth!=null?{minWidth:e.appearance.minWidth}:{},...e.appearance.minHeight!=null?{minHeight:e.appearance.minHeight}:{}}:void 0,p=e.appearance?.className,g=ou(e),m=fo(e),h=Gw(e),y=Fr(e.appearance);return d.jsx("div",{className:H($v(u),u!=="floating"&&"space-y-2",a&&!h&&"flex-1 min-h-0 h-full",i&&h&&"w-full shrink-0 self-start",p,o),style:f,"data-field-appearance":u,children:d.jsxs("div",{className:H("flex flex-col min-w-0",eu(e.appearance),su(e),a&&!h&&"flex-1 min-h-0",i&&h&&"shrink-0"),style:g,children:[c&&d.jsxs(Fn,{id:ti(e),htmlFor:ft(e),style:e.ui?.labelStyle,className:H(jv(u,!!t)),children:[e.label,r&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),d.jsxs("div",{className:H(zv(u),h&&i&&"min-h-min !grow-0 !shrink-0 basis-auto",m&&y!=="stretch"&&"items-start",h&&y==="stretch"&&"items-start w-full [&_button]:w-full",!h&&y==="stretch"&&"items-stretch",a&&!h&&"flex-1 min-h-0",o?.includes("flex")&&u==="top"&&"flex flex-col min-h-0"),style:l,children:[n,d.jsxs("div",{className:H("mt-1.5 min-h-[18px]",u==="center"&&"text-center",o?.includes("flex")&&"shrink-0"),children:[e.description&&!t&&d.jsx("p",{id:Zo(e),className:"text-xs text-muted-foreground",style:e.ui?.descriptionStyle,children:e.description}),t&&d.jsx("p",{id:es(e),className:"text-xs text-destructive",role:"alert",children:typeof t=="string"?t:String(t||"An error occurred")})]})]})]})})},ri=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=v.useCallback(l=>{r(l.target.value)},[r]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsx(mn,{id:ft(e),type:"text",value:t||"",onChange:f,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,minLength:u?.minLength,maxLength:u?.maxLength,pattern:u?.pattern,autoComplete:u?.autoComplete,inputMode:u?.inputMode,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})})},dl=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=u?.precision!=null||u?.step!=null&&!Number.isInteger(u.step),l=v.useCallback(g=>{const m=u?.allowNegative!==!1,h=g.target.value,y=f?h.replace(m?/[^\d.-]/g:/[^\d.]/g,""):h.replace(m?/[^\d-]/g:/\D/g,"");if(y===""){r(null);return}const S=parseFloat(y);isNaN(S)||r(S)},[r,u?.allowNegative,f]),p=v.useCallback(g=>{(g.key==="ArrowUp"||g.key==="ArrowDown"||g.key==="PageUp"||g.key==="PageDown")&&g.preventDefault()},[]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[u?.prefix&&d.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.prefix}),d.jsx(mn,{id:ft(e),type:"text",inputMode:f?"decimal":"numeric",autoComplete:"off",value:t??"",onChange:l,onKeyDown:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),o&&"border-destructive focus-visible:ring-destructive",u?.prefix&&"pl-8",u?.suffix&&"pr-8",e.appearance?.className)}),u?.suffix&&d.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:u.suffix})]})})};const Kw=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),qw=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),ju=e=>{const t=qw(e);return t.charAt(0).toUpperCase()+t.slice(1)},zu=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),Yw=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Xw={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Jw=v.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:s,iconNode:i,...a},c)=>v.createElement("svg",{ref:c,...Xw,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:zu("lucide",o),...!s&&!Yw(a)&&{"aria-hidden":"true"},...a},[...i.map(([u,f])=>v.createElement(u,f)),...Array.isArray(s)?s:[s]]));const qt=(e,t)=>{const r=v.forwardRef(({className:n,...o},s)=>v.createElement(Jw,{ref:s,iconNode:t,className:zu(`lucide-${Kw(ju(e))}`,`lucide-${e}`,n),...o}));return r.displayName=ju(e),r};const Qw=qt("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const ni=qt("camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);const oi=qt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const ts=qt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Uu=qt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Zw=qt("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const eS=qt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const Vu=qt("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Hu=qt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Wu=qt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const mo=qt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const tS=qt("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const rS=qt("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);const Ru=qt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const nS=qt("sliders-horizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);const Gu=qt("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);const rs=qt("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const si=qt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const ns=qt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Ku=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=v.useCallback(f=>{r(f.target.value)},[r]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[d.jsx(tS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),d.jsx(mn,{id:ft(e),type:"email",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"email@example.com",disabled:s||e.disabled,readOnly:i||e.readOnly,autoComplete:"email",inputMode:"email","aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})},qu=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=v.useCallback(f=>{const l=f.target.value.replace(/[^\d\s+\-()]/g,"");r(l)},[r]);return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"relative",children:[d.jsx(rS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),d.jsx(mn,{id:ft(e),type:"tel",value:t||"",onChange:u,onBlur:n,placeholder:e.placeholder||"+91 12345 67890",disabled:s||e.disabled,readOnly:i||e.readOnly,autoComplete:"tel",inputMode:"tel","aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),"pl-10",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]})})};function Yu(e,t){return function(){return e.apply(t,arguments)}}const{toString:oS}=Object.prototype,{getPrototypeOf:ul}=Object,{iterator:ii,toStringTag:Xu}=Symbol,ai=(e=>t=>{const r=oS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Rr=e=>(e=e.toLowerCase(),t=>ai(t)===e),li=e=>t=>typeof t===e,{isArray:ho}=Array,go=li("undefined");function os(e){return e!==null&&!go(e)&&e.constructor!==null&&!go(e.constructor)&&pr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ju=Rr("ArrayBuffer");function sS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ju(e.buffer),t}const iS=li("string"),pr=li("function"),Qu=li("number"),ss=e=>e!==null&&typeof e=="object",aS=e=>e===!0||e===!1,ci=e=>{if(ai(e)!=="object")return!1;const t=ul(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Xu in e)&&!(ii in e)},lS=e=>{if(!ss(e)||os(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},cS=Rr("Date"),dS=Rr("File"),uS=e=>!!(e&&typeof e.uri<"u"),fS=e=>e&&typeof e.getParts<"u",pS=Rr("Blob"),mS=Rr("FileList"),hS=e=>ss(e)&&pr(e.pipe);function gS(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Zu=gS(),ef=typeof Zu.FormData<"u"?Zu.FormData:void 0,yS=e=>{let t;return e&&(ef&&e instanceof ef||pr(e.append)&&((t=ai(e))==="formdata"||t==="object"&&pr(e.toString)&&e.toString()==="[object FormData]"))},bS=Rr("URLSearchParams"),[vS,wS,SS,xS]=["ReadableStream","Request","Response","Headers"].map(Rr),AS=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function is(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),ho(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(os(e))return;const s=r?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(n=0;n<i;n++)a=s[n],t.call(null,e[a],a,e)}}function tf(e,t){if(os(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}const Yn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,rf=e=>!go(e)&&e!==Yn;function fl(){const{caseless:e,skipUndefined:t}=rf(this)&&this||{},r={},n=(o,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;const i=e&&tf(r,s)||s;ci(r[i])&&ci(o)?r[i]=fl(r[i],o):ci(o)?r[i]=fl({},o):ho(o)?r[i]=o.slice():(!t||!go(o))&&(r[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&is(arguments[o],n);return r}const CS=(e,t,r,{allOwnKeys:n}={})=>(is(t,(o,s)=>{r&&pr(o)?Object.defineProperty(e,s,{value:Yu(o,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,s,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),ES=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),NS=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},kS=(e,t,r,n)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!n||n(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=r!==!1&&ul(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},_S=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},TS=e=>{if(!e)return null;if(ho(e))return e;let t=e.length;if(!Qu(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},FS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ul(Uint8Array)),PS=(e,t)=>{const n=(e&&e[ii]).call(e);let o;for(;(o=n.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},OS=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},IS=Rr("HTMLFormElement"),MS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),nf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),LS=Rr("RegExp"),of=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};is(r,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(n[s]=i||o)}),Object.defineProperties(e,n)},DS=e=>{of(e,(t,r)=>{if(pr(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(pr(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},BS=(e,t)=>{const r={},n=o=>{o.forEach(s=>{r[s]=!0})};return ho(e)?n(e):n(String(e).split(t)),r},$S=()=>{},jS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function zS(e){return!!(e&&pr(e.append)&&e[Xu]==="FormData"&&e[ii])}const US=e=>{const t=new Array(10),r=(n,o)=>{if(ss(n)){if(t.indexOf(n)>=0)return;if(os(n))return n;if(!("toJSON"in n)){t[o]=n;const s=ho(n)?[]:{};return is(n,(i,a)=>{const c=r(i,o+1);!go(c)&&(s[a]=c)}),t[o]=void 0,s}}return n};return r(e,0)},VS=Rr("AsyncFunction"),HS=e=>e&&(ss(e)||pr(e))&&pr(e.then)&&pr(e.catch),sf=((e,t)=>e?setImmediate:t?((r,n)=>(Yn.addEventListener("message",({source:o,data:s})=>{o===Yn&&s===r&&n.length&&n.shift()()},!1),o=>{n.push(o),Yn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",pr(Yn.postMessage)),WS=typeof queueMicrotask<"u"?queueMicrotask.bind(Yn):typeof process<"u"&&process.nextTick||sf,Y={isArray:ho,isArrayBuffer:Ju,isBuffer:os,isFormData:yS,isArrayBufferView:sS,isString:iS,isNumber:Qu,isBoolean:aS,isObject:ss,isPlainObject:ci,isEmptyObject:lS,isReadableStream:vS,isRequest:wS,isResponse:SS,isHeaders:xS,isUndefined:go,isDate:cS,isFile:dS,isReactNativeBlob:uS,isReactNative:fS,isBlob:pS,isRegExp:LS,isFunction:pr,isStream:hS,isURLSearchParams:bS,isTypedArray:FS,isFileList:mS,forEach:is,merge:fl,extend:CS,trim:AS,stripBOM:ES,inherits:NS,toFlatObject:kS,kindOf:ai,kindOfTest:Rr,endsWith:_S,toArray:TS,forEachEntry:PS,matchAll:OS,isHTMLForm:IS,hasOwnProperty:nf,hasOwnProp:nf,reduceDescriptors:of,freezeMethods:DS,toObjectSet:BS,toCamelCase:MS,noop:$S,toFiniteNumber:jS,findKey:tf,global:Yn,isContextDefined:rf,isSpecCompliantForm:zS,toJSONObject:US,isAsyncFn:VS,isThenable:HS,setImmediate:sf,asap:WS,isIterable:e=>e!=null&&pr(e[ii])};let qe=class Gb extends Error{static from(t,r,n,o,s,i){const a=new Gb(t.message,r||t.code,n,o,s);return a.cause=t,a.name=t.name,t.status!=null&&a.status==null&&(a.status=t.status),i&&Object.assign(a,i),a}constructor(t,r,n,o,s){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),n&&(this.config=n),o&&(this.request=o),s&&(this.response=s,this.status=s.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Y.toJSONObject(this.config),code:this.code,status:this.status}}};qe.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",qe.ERR_BAD_OPTION="ERR_BAD_OPTION",qe.ECONNABORTED="ECONNABORTED",qe.ETIMEDOUT="ETIMEDOUT",qe.ERR_NETWORK="ERR_NETWORK",qe.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",qe.ERR_DEPRECATED="ERR_DEPRECATED",qe.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",qe.ERR_BAD_REQUEST="ERR_BAD_REQUEST",qe.ERR_CANCELED="ERR_CANCELED",qe.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",qe.ERR_INVALID_URL="ERR_INVALID_URL";const RS=null;function pl(e){return Y.isPlainObject(e)||Y.isArray(e)}function af(e){return Y.endsWith(e,"[]")?e.slice(0,-2):e}function ml(e,t,r){return e?e.concat(t).map(function(o,s){return o=af(o),!r&&s?"["+o+"]":o}).join(r?".":""):t}function GS(e){return Y.isArray(e)&&!e.some(pl)}const KS=Y.toFlatObject(Y,{},null,function(t){return/^is[A-Z]/.test(t)});function di(e,t,r){if(!Y.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=Y.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,y){return!Y.isUndefined(y[h])});const n=r.metaTokens,o=r.visitor||f,s=r.dots,i=r.indexes,c=(r.Blob||typeof Blob<"u"&&Blob)&&Y.isSpecCompliantForm(t);if(!Y.isFunction(o))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(Y.isDate(m))return m.toISOString();if(Y.isBoolean(m))return m.toString();if(!c&&Y.isBlob(m))throw new qe("Blob is not supported. Use a Buffer instead.");return Y.isArrayBuffer(m)||Y.isTypedArray(m)?c&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function f(m,h,y){let S=m;if(Y.isReactNative(t)&&Y.isReactNativeBlob(m))return t.append(ml(y,h,s),u(m)),!1;if(m&&!y&&typeof m=="object"){if(Y.endsWith(h,"{}"))h=n?h:h.slice(0,-2),m=JSON.stringify(m);else if(Y.isArray(m)&&GS(m)||(Y.isFileList(m)||Y.endsWith(h,"[]"))&&(S=Y.toArray(m)))return h=af(h),S.forEach(function(A,x){!(Y.isUndefined(A)||A===null)&&t.append(i===!0?ml([h],x,s):i===null?h:h+"[]",u(A))}),!1}return pl(m)?!0:(t.append(ml(y,h,s),u(m)),!1)}const l=[],p=Object.assign(KS,{defaultVisitor:f,convertValue:u,isVisitable:pl});function g(m,h){if(!Y.isUndefined(m)){if(l.indexOf(m)!==-1)throw Error("Circular reference detected in "+h.join("."));l.push(m),Y.forEach(m,function(S,w){(!(Y.isUndefined(S)||S===null)&&o.call(t,S,Y.isString(w)?w.trim():w,h,p))===!0&&g(S,h?h.concat(w):[w])}),l.pop()}}if(!Y.isObject(e))throw new TypeError("data must be an object");return g(e),t}function lf(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function hl(e,t){this._pairs=[],e&&di(e,this,t)}const cf=hl.prototype;cf.append=function(t,r){this._pairs.push([t,r])},cf.toString=function(t){const r=t?function(n){return t.call(this,n,lf)}:lf;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function qS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function df(e,t,r){if(!t)return e;const n=r&&r.encode||qS,o=Y.isFunction(r)?{serialize:r}:r,s=o&&o.serialize;let i;if(s?i=s(t,o):i=Y.isURLSearchParams(t)?t.toString():new hl(t,o).toString(n),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class uf{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Y.forEach(this.handlers,function(n){n!==null&&t(n)})}}const gl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},YS={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:hl,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},yl=typeof window<"u"&&typeof document<"u",bl=typeof navigator=="object"&&navigator||void 0,XS=yl&&(!bl||["ReactNative","NativeScript","NS"].indexOf(bl.product)<0),JS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",QS=yl&&window.location.href||"http://localhost",sr={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yl,hasStandardBrowserEnv:XS,hasStandardBrowserWebWorkerEnv:JS,navigator:bl,origin:QS},Symbol.toStringTag,{value:"Module"})),...YS};function ZS(e,t){return di(e,new sr.classes.URLSearchParams,{visitor:function(r,n,o,s){return sr.isNode&&Y.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function e0(e){return Y.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function t0(e){const t={},r=Object.keys(e);let n;const o=r.length;let s;for(n=0;n<o;n++)s=r[n],t[s]=e[s];return t}function ff(e){function t(r,n,o,s){let i=r[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),c=s>=r.length;return i=!i&&Y.isArray(o)?o.length:i,c?(Y.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!a):((!o[i]||!Y.isObject(o[i]))&&(o[i]=[]),t(r,n,o[i],s)&&Y.isArray(o[i])&&(o[i]=t0(o[i])),!a)}if(Y.isFormData(e)&&Y.isFunction(e.entries)){const r={};return Y.forEachEntry(e,(n,o)=>{t(e0(n),o,r,0)}),r}return null}function r0(e,t,r){if(Y.isString(e))try{return(t||JSON.parse)(e),Y.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const as={transitional:gl,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",o=n.indexOf("application/json")>-1,s=Y.isObject(t);if(s&&Y.isHTMLForm(t)&&(t=new FormData(t)),Y.isFormData(t))return o?JSON.stringify(ff(t)):t;if(Y.isArrayBuffer(t)||Y.isBuffer(t)||Y.isStream(t)||Y.isFile(t)||Y.isBlob(t)||Y.isReadableStream(t))return t;if(Y.isArrayBufferView(t))return t.buffer;if(Y.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return ZS(t,this.formSerializer).toString();if((a=Y.isFileList(t))||n.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return di(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(r.setContentType("application/json",!1),r0(t)):t}],transformResponse:[function(t){const r=this.transitional||as.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(Y.isResponse(t)||Y.isReadableStream(t))return t;if(t&&Y.isString(t)&&(n&&!this.responseType||o)){const i=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?qe.from(a,qe.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:sr.classes.FormData,Blob:sr.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Y.forEach(["delete","get","head","post","put","patch"],e=>{as.headers[e]={}});const n0=Y.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),o0=e=>{const t={};let r,n,o;return e&&e.split(`
|
|
2
|
+
`).forEach(function(i){o=i.indexOf(":"),r=i.substring(0,o).trim().toLowerCase(),n=i.substring(o+1).trim(),!(!r||t[r]&&n0[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},pf=Symbol("internals");function ls(e){return e&&String(e).trim().toLowerCase()}function ui(e){return e===!1||e==null?e:Y.isArray(e)?e.map(ui):String(e).replace(/[\r\n]+$/,"")}function s0(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const i0=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function vl(e,t,r,n,o){if(Y.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!Y.isString(t)){if(Y.isString(n))return t.indexOf(n)!==-1;if(Y.isRegExp(n))return n.test(t)}}function a0(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function l0(e,t){const r=Y.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(o,s,i){return this[n].call(this,t,o,s,i)},configurable:!0})})}let mr=class{constructor(t){t&&this.set(t)}set(t,r,n){const o=this;function s(a,c,u){const f=ls(c);if(!f)throw new Error("header name must be a non-empty string");const l=Y.findKey(o,f);(!l||o[l]===void 0||u===!0||u===void 0&&o[l]!==!1)&&(o[l||c]=ui(a))}const i=(a,c)=>Y.forEach(a,(u,f)=>s(u,f,c));if(Y.isPlainObject(t)||t instanceof this.constructor)i(t,r);else if(Y.isString(t)&&(t=t.trim())&&!i0(t))i(o0(t),r);else if(Y.isObject(t)&&Y.isIterable(t)){let a={},c,u;for(const f of t){if(!Y.isArray(f))throw TypeError("Object iterator must return a key-value pair");a[u=f[0]]=(c=a[u])?Y.isArray(c)?[...c,f[1]]:[c,f[1]]:f[1]}i(a,r)}else t!=null&&s(r,t,n);return this}get(t,r){if(t=ls(t),t){const n=Y.findKey(this,t);if(n){const o=this[n];if(!r)return o;if(r===!0)return s0(o);if(Y.isFunction(r))return r.call(this,o,n);if(Y.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=ls(t),t){const n=Y.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||vl(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let o=!1;function s(i){if(i=ls(i),i){const a=Y.findKey(n,i);a&&(!r||vl(n,n[a],a,r))&&(delete n[a],o=!0)}}return Y.isArray(t)?t.forEach(s):s(t),o}clear(t){const r=Object.keys(this);let n=r.length,o=!1;for(;n--;){const s=r[n];(!t||vl(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const r=this,n={};return Y.forEach(this,(o,s)=>{const i=Y.findKey(n,s);if(i){r[i]=ui(o),delete r[s];return}const a=t?a0(s):String(s).trim();a!==s&&delete r[s],r[a]=ui(o),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return Y.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&Y.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){const n=(this[pf]=this[pf]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=ls(i);n[a]||(l0(o,i),n[a]=!0)}return Y.isArray(t)?t.forEach(s):s(t),this}};mr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Y.reduceDescriptors(mr.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),Y.freezeMethods(mr);function wl(e,t){const r=this||as,n=t||r,o=mr.from(n.headers);let s=n.data;return Y.forEach(e,function(a){s=a.call(r,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function mf(e){return!!(e&&e.__CANCEL__)}let cs=class extends qe{constructor(t,r,n){super(t??"canceled",qe.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function hf(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new qe("Request failed with status code "+r.status,[qe.ERR_BAD_REQUEST,qe.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function c0(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function d0(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),f=n[s];i||(i=u),r[o]=c,n[o]=u;let l=s,p=0;for(;l!==o;)p+=r[l++],l=l%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const g=f&&u-f;return g?Math.round(p*1e3/g):void 0}}function u0(e,t){let r=0,n=1e3/t,o,s;const i=(u,f=Date.now())=>{r=f,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const f=Date.now(),l=f-r;l>=n?i(u,f):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},n-l)))},()=>o&&i(o)]}const fi=(e,t,r=3)=>{let n=0;const o=d0(50,250);return u0(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-n,u=o(c),f=i<=a;n=i;const l={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&f?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(l)},r)},gf=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},yf=e=>(...t)=>Y.asap(()=>e(...t)),f0=sr.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,sr.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(sr.origin),sr.navigator&&/(msie|trident)/i.test(sr.navigator.userAgent)):()=>!0,p0=sr.hasStandardBrowserEnv?{write(e,t,r,n,o,s,i){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];Y.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),Y.isString(n)&&a.push(`path=${n}`),Y.isString(o)&&a.push(`domain=${o}`),s===!0&&a.push("secure"),Y.isString(i)&&a.push(`SameSite=${i}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function m0(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function h0(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function bf(e,t,r){let n=!m0(t);return e&&(n||r==!1)?h0(e,t):t}const vf=e=>e instanceof mr?{...e}:e;function Xn(e,t){t=t||{};const r={};function n(u,f,l,p){return Y.isPlainObject(u)&&Y.isPlainObject(f)?Y.merge.call({caseless:p},u,f):Y.isPlainObject(f)?Y.merge({},f):Y.isArray(f)?f.slice():f}function o(u,f,l,p){if(Y.isUndefined(f)){if(!Y.isUndefined(u))return n(void 0,u,l,p)}else return n(u,f,l,p)}function s(u,f){if(!Y.isUndefined(f))return n(void 0,f)}function i(u,f){if(Y.isUndefined(f)){if(!Y.isUndefined(u))return n(void 0,u)}else return n(void 0,f)}function a(u,f,l){if(l in t)return n(u,f);if(l in e)return n(void 0,u)}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,f,l)=>o(vf(u),vf(f),l,!0)};return Y.forEach(Object.keys({...e,...t}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;const l=Y.hasOwnProp(c,f)?c[f]:o,p=l(e[f],t[f],f);Y.isUndefined(p)&&l!==a||(r[f]=p)}),r}const wf=e=>{const t=Xn({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=mr.from(i),t.url=df(bf(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Y.isFormData(r)){if(sr.hasStandardBrowserEnv||sr.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(Y.isFunction(r.getHeaders)){const c=r.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([f,l])=>{u.includes(f.toLowerCase())&&i.set(f,l)})}}if(sr.hasStandardBrowserEnv&&(n&&Y.isFunction(n)&&(n=n(t)),n||n!==!1&&f0(t.url))){const c=o&&s&&p0.read(s);c&&i.set(o,c)}return t},g0=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=wf(e);let s=o.data;const i=mr.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,f,l,p,g,m;function h(){g&&g(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(f),o.signal&&o.signal.removeEventListener("abort",f)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function S(){if(!y)return;const A=mr.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),F={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:A,config:e,request:y};hf(function(k){r(k),h()},function(k){n(k),h()},F),y=null}"onloadend"in y?y.onloadend=S:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(S)},y.onabort=function(){y&&(n(new qe("Request aborted",qe.ECONNABORTED,e,y)),y=null)},y.onerror=function(x){const F=x&&x.message?x.message:"Network Error",N=new qe(F,qe.ERR_NETWORK,e,y);N.event=x||null,n(N),y=null},y.ontimeout=function(){let x=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const F=o.transitional||gl;o.timeoutErrorMessage&&(x=o.timeoutErrorMessage),n(new qe(x,F.clarifyTimeoutError?qe.ETIMEDOUT:qe.ECONNABORTED,e,y)),y=null},s===void 0&&i.setContentType(null),"setRequestHeader"in y&&Y.forEach(i.toJSON(),function(x,F){y.setRequestHeader(F,x)}),Y.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),u&&([p,m]=fi(u,!0),y.addEventListener("progress",p)),c&&y.upload&&([l,g]=fi(c),y.upload.addEventListener("progress",l),y.upload.addEventListener("loadend",g)),(o.cancelToken||o.signal)&&(f=A=>{y&&(n(!A||A.type?new cs(null,e,y):A),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(f),o.signal&&(o.signal.aborted?f():o.signal.addEventListener("abort",f)));const w=c0(o.url);if(w&&sr.protocols.indexOf(w)===-1){n(new qe("Unsupported protocol "+w+":",qe.ERR_BAD_REQUEST,e));return}y.send(s||null)})},y0=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,o;const s=function(u){if(!o){o=!0,a();const f=u instanceof Error?u:this.reason;n.abort(f instanceof qe?f:new cs(f instanceof Error?f.message:f))}};let i=t&&setTimeout(()=>{i=null,s(new qe(`timeout of ${t}ms exceeded`,qe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:c}=n;return c.unsubscribe=()=>Y.asap(a),c}},b0=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,o;for(;n<r;)o=n+t,yield e.slice(n,o),n=o},v0=async function*(e,t){for await(const r of w0(e))yield*b0(r,t)},w0=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},Sf=(e,t,r,n)=>{const o=v0(e,t);let s=0,i,a=c=>{i||(i=!0,n&&n(c))};return new ReadableStream({async pull(c){try{const{done:u,value:f}=await o.next();if(u){a(),c.close();return}let l=f.byteLength;if(r){let p=s+=l;r(p)}c.enqueue(new Uint8Array(f))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},xf=64*1024,{isFunction:pi}=Y,S0=(({Request:e,Response:t})=>({Request:e,Response:t}))(Y.global),{ReadableStream:Af,TextEncoder:Cf}=Y.global,Ef=(e,...t)=>{try{return!!e(...t)}catch{return!1}},x0=e=>{e=Y.merge.call({skipUndefined:!0},S0,e);const{fetch:t,Request:r,Response:n}=e,o=t?pi(t):typeof fetch=="function",s=pi(r),i=pi(n);if(!o)return!1;const a=o&&pi(Af),c=o&&(typeof Cf=="function"?(m=>h=>m.encode(h))(new Cf):async m=>new Uint8Array(await new r(m).arrayBuffer())),u=s&&a&&Ef(()=>{let m=!1;const h=new Af,y=new r(sr.origin,{body:h,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return h.cancel(),m&&!y}),f=i&&a&&Ef(()=>Y.isReadableStream(new n("").body)),l={stream:f&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!l[m]&&(l[m]=(h,y)=>{let S=h&&h[m];if(S)return S.call(h);throw new qe(`Response type '${m}' is not supported`,qe.ERR_NOT_SUPPORT,y)})});const p=async m=>{if(m==null)return 0;if(Y.isBlob(m))return m.size;if(Y.isSpecCompliantForm(m))return(await new r(sr.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(Y.isArrayBufferView(m)||Y.isArrayBuffer(m))return m.byteLength;if(Y.isURLSearchParams(m)&&(m=m+""),Y.isString(m))return(await c(m)).byteLength},g=async(m,h)=>{const y=Y.toFiniteNumber(m.getContentLength());return y??p(h)};return async m=>{let{url:h,method:y,data:S,signal:w,cancelToken:A,timeout:x,onDownloadProgress:F,onUploadProgress:N,responseType:k,headers:T,withCredentials:P="same-origin",fetchOptions:E}=wf(m),C=t||fetch;k=k?(k+"").toLowerCase():"text";let I=y0([w,A&&A.toAbortSignal()],x),W=null;const M=I&&I.unsubscribe&&(()=>{I.unsubscribe()});let z;try{if(N&&u&&y!=="get"&&y!=="head"&&(z=await g(T,S))!==0){let K=new r(h,{method:"POST",body:S,duplex:"half"}),ae;if(Y.isFormData(S)&&(ae=K.headers.get("content-type"))&&T.setContentType(ae),K.body){const[j,U]=gf(z,fi(yf(N)));S=Sf(K.body,xf,j,U)}}Y.isString(P)||(P=P?"include":"omit");const V=s&&"credentials"in r.prototype,X={...E,signal:I,method:y.toUpperCase(),headers:T.normalize().toJSON(),body:S,duplex:"half",credentials:V?P:void 0};W=s&&new r(h,X);let L=await(s?C(W,E):C(h,X));const B=f&&(k==="stream"||k==="response");if(f&&(F||B&&M)){const K={};["status","statusText","headers"].forEach(le=>{K[le]=L[le]});const ae=Y.toFiniteNumber(L.headers.get("content-length")),[j,U]=F&&gf(ae,fi(yf(F),!0))||[];L=new n(Sf(L.body,xf,j,()=>{U&&U(),M&&M()}),K)}k=k||"text";let D=await l[Y.findKey(l,k)||"text"](L,m);return!B&&M&&M(),await new Promise((K,ae)=>{hf(K,ae,{data:D,headers:mr.from(L.headers),status:L.status,statusText:L.statusText,config:m,request:W})})}catch(V){throw M&&M(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new qe("Network Error",qe.ERR_NETWORK,m,W,V&&V.response),{cause:V.cause||V}):qe.from(V,V&&V.code,m,W,V&&V.response)}}},A0=new Map,Nf=e=>{let t=e&&e.env||{};const{fetch:r,Request:n,Response:o}=t,s=[n,o,r];let i=s.length,a=i,c,u,f=A0;for(;a--;)c=s[a],u=f.get(c),u===void 0&&f.set(c,u=a?new Map:x0(t)),f=u;return u};Nf();const Sl={http:RS,xhr:g0,fetch:{get:Nf}};Y.forEach(Sl,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const kf=e=>`- ${e}`,C0=e=>Y.isFunction(e)||e===null||e===!1;function E0(e,t){e=Y.isArray(e)?e:[e];const{length:r}=e;let n,o;const s={};for(let i=0;i<r;i++){n=e[i];let a;if(o=n,!C0(n)&&(o=Sl[(a=String(n)).toLowerCase()],o===void 0))throw new qe(`Unknown adapter '${a}'`);if(o&&(Y.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=r?i.length>1?`since :
|
|
4
|
+
`+i.map(kf).join(`
|
|
5
|
+
`):" "+kf(i[0]):"as no adapter specified";throw new qe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o}const _f={getAdapter:E0,adapters:Sl};function xl(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new cs(null,e)}function Tf(e){return xl(e),e.headers=mr.from(e.headers),e.data=wl.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),_f.getAdapter(e.adapter||as.adapter,e)(e).then(function(n){return xl(e),n.data=wl.call(e,e.transformResponse,n),n.headers=mr.from(n.headers),n},function(n){return mf(n)||(xl(e),n&&n.response&&(n.response.data=wl.call(e,e.transformResponse,n.response),n.response.headers=mr.from(n.response.headers))),Promise.reject(n)})}const Ff="1.14.0",mi={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{mi[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Pf={};mi.transitional=function(t,r,n){function o(s,i){return"[Axios v"+Ff+"] Transitional option '"+s+"'"+i+(n?". "+n:"")}return(s,i,a)=>{if(t===!1)throw new qe(o(i," has been removed"+(r?" in "+r:"")),qe.ERR_DEPRECATED);return r&&!Pf[i]&&(Pf[i]=!0,console.warn(o(i," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(s,i,a):!0}},mi.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function N0(e,t,r){if(typeof e!="object")throw new qe("options must be an object",qe.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const s=n[o],i=t[s];if(i){const a=e[s],c=a===void 0||i(a,s,e);if(c!==!0)throw new qe("option "+s+" must be "+c,qe.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new qe("Unknown option "+s,qe.ERR_BAD_OPTION)}}const hi={assertOptions:N0,validators:mi},Ir=hi.validators;let Jn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new uf,response:new uf}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
6
|
+
`+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Xn(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&hi.assertOptions(n,{silentJSONParsing:Ir.transitional(Ir.boolean),forcedJSONParsing:Ir.transitional(Ir.boolean),clarifyTimeoutError:Ir.transitional(Ir.boolean),legacyInterceptorReqResOrdering:Ir.transitional(Ir.boolean)},!1),o!=null&&(Y.isFunction(o)?r.paramsSerializer={serialize:o}:hi.assertOptions(o,{encode:Ir.function,serialize:Ir.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),hi.assertOptions(r,{baseUrl:Ir.spelling("baseURL"),withXsrfToken:Ir.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&Y.merge(s.common,s[r.method]);s&&Y.forEach(["delete","get","head","post","put","patch","common"],m=>{delete s[m]}),r.headers=mr.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(r)===!1)return;c=c&&h.synchronous;const y=r.transitional||gl;y&&y.legacyInterceptorReqResOrdering?a.unshift(h.fulfilled,h.rejected):a.push(h.fulfilled,h.rejected)});const u=[];this.interceptors.response.forEach(function(h){u.push(h.fulfilled,h.rejected)});let f,l=0,p;if(!c){const m=[Tf.bind(this),void 0];for(m.unshift(...a),m.push(...u),p=m.length,f=Promise.resolve(r);l<p;)f=f.then(m[l++],m[l++]);return f}p=a.length;let g=r;for(;l<p;){const m=a[l++],h=a[l++];try{g=m(g)}catch(y){h.call(this,y);break}}try{f=Tf.call(this,g)}catch(m){return Promise.reject(m)}for(l=0,p=u.length;l<p;)f=f.then(u[l++],u[l++]);return f}getUri(t){t=Xn(this.defaults,t);const r=bf(t.baseURL,t.url,t.allowAbsoluteUrls);return df(r,t.params,t.paramsSerializer)}};Y.forEach(["delete","get","head","options"],function(t){Jn.prototype[t]=function(r,n){return this.request(Xn(n||{},{method:t,url:r,data:(n||{}).data}))}}),Y.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,a){return this.request(Xn(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Jn.prototype[t]=r(),Jn.prototype[t+"Form"]=r(!0)});let k0=class Kb{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{n.subscribe(a),s=a}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,a){n.reason||(n.reason=new cs(s,i,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Kb(function(o){t=o}),cancel:t}}};function _0(e){return function(r){return e.apply(null,r)}}function T0(e){return Y.isObject(e)&&e.isAxiosError===!0}const Al={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Al).forEach(([e,t])=>{Al[t]=e});function Of(e){const t=new Jn(e),r=Yu(Jn.prototype.request,t);return Y.extend(r,Jn.prototype,t,{allOwnKeys:!0}),Y.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return Of(Xn(e,o))},r}const Ct=Of(as);Ct.Axios=Jn,Ct.CanceledError=cs,Ct.CancelToken=k0,Ct.isCancel=mf,Ct.VERSION=Ff,Ct.toFormData=di,Ct.AxiosError=qe,Ct.Cancel=Ct.CanceledError,Ct.all=function(t){return Promise.all(t)},Ct.spread=_0,Ct.isAxiosError=T0,Ct.mergeConfig=Xn,Ct.AxiosHeaders=mr,Ct.formToJSON=e=>ff(Y.isHTMLForm(e)?new FormData(e):e),Ct.getAdapter=_f.getAdapter,Ct.HttpStatusCode=Al,Ct.default=Ct;const{Axios:tM,AxiosError:F0,CanceledError:rM,isCancel:nM,CancelToken:oM,VERSION:sM,all:iM,Cancel:aM,isAxiosError:lM,spread:cM,toFormData:dM,AxiosHeaders:uM,HttpStatusCode:fM,formToJSON:pM,getAdapter:mM,mergeConfig:hM}=Ct;let If=null;function P0(e){If=e}function Mf(){return(If?.()??"").replace(/\/+$/,"")}function Mr(e){const t=typeof e=="string"?e.trim():"";if(!t||/^https?:\/\//i.test(t))return t;const r=Mf();return r?t.startsWith("/")?`${r}${t}`:`${r}/${t}`:t}const Lf={};function nn(){const e=Lf?.VITE_CLIENT_ID?.trim()||Lf?.VITE_DEFAULT_CLIENT_ID?.trim()||null;return(typeof localStorage<"u"?localStorage.getItem("clientId"):null)||(typeof sessionStorage<"u"?sessionStorage.getItem("clientId"):null)||(typeof window<"u"?new URLSearchParams(window.location.search).get("clientId"):null)||e}function O0(e){return!e||typeof e!="object"?!1:e.userId!=null&&String(e.userId)!==""||e.userType!=null&&String(e.userType)!==""||e.role!=null&&String(e.role)!==""}function I0(e){if(!e||typeof e!="object")return;const t={};for(const[r,n]of Object.entries(e))n!==void 0&&n!==""&&(t[r]=n);return Object.keys(t).length>0?t:void 0}const Qn=cu(e=>({viewerContext:void 0,authHeaders:void 0,_setViewerContext:t=>e({viewerContext:O0(t)?t:void 0}),_setAuthHeaders:t=>e({authHeaders:I0(t)}),_reset:()=>e({viewerContext:void 0,authHeaders:void 0})}));function M0(e){Qn.getState()._setViewerContext(e)}function L0(e){Qn.getState()._setAuthHeaders(e)}function D0(){Qn.getState()._reset()}function Df(){return Qn.getState().viewerContext}function ds(){return Qn.getState().authHeaders}const Bf={};let $f=null;function B0(e){$f=e}function $0(){return(Bf?.VITE_API_BASE_URL?.trim()||Bf?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const Qt=Ct.create({baseURL:$0()});Qt.interceptors.request.use(e=>{const t=nn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=$f?.();if((!r||Object.keys(r).length===0)&&(r=ds()),r){const n=e.headers??{};for(const[o,s]of Object.entries(r))s!==void 0&&s!==""&&(n[o]=s);e.headers=n}return e});const j0=/^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/i;function jf(e){const t=e.trim().match(j0);return t?t[1]:e}const z0={applicantId:["id","applicant_id"],applicant_id:["id","applicantId"],id:["applicantId","applicant_id"]};function Lr(e,t,r,n,o,s){let i=e;if(o&&typeof e=="string"&&(i=i.replace(/\{resp:([^}]+)\}/g,(a,c)=>{const u=c.trim().split(".");if(u.length<2)return a;const f=u[0],l=u.slice(1).join("."),p=o[f];if(p==null)return a;const g=Ge(p,l);return g==null?a:String(g)}),i.includes("{documentId}")||i.includes("%7BdocumentId%7D"))){let a;for(const c of Object.values(o)){const u=Ge(c,"data.id")??Ge(c,"data.documentId");if(u!=null){a=String(u);break}}a&&(i=i.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}if(i.includes("{documentId}")||i.includes("%7BdocumentId%7D")){let a;const c=t?.documentId??(t&&Ge(t,"documentId")),u=n?.documentId??(n&&Ge(n,"documentId"));c!=null&&c!==""?a=String(c):u!=null&&u!==""&&(a=String(u)),a&&(i=i.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}return i=i.replace(/\{api:([^}]+)\}/g,(a,c)=>{const u=c.trim();if(s==null||u==="")return a;const f=Ge(s,u);return f==null?a:String(f)}),i=i.replace(/\{(?:ctx:|\@)(\w+)\}/g,(a,c)=>n&&n[c]!==void 0&&n[c]!==null?String(n[c]):a),i=i.replace(/\{(\w+)\}/g,(a,c)=>{if(a.includes("ctx:")||a.includes("@"))return a;const u=r[c];if(u!=null)return jf(String(u));let f=t[c];if(f==null||f===""){const l=Object.keys(t).find(p=>p.toLowerCase()===c.toLowerCase());l&&(f=t[l])}if((f==null||f==="")&&(f=n?.[c]),f==null||f===""){const l=z0[c];if(l)for(const p of l){const g=t[p]??n?.[p];if(g!=null&&g!==""){f=g;break}}}return f!=null&&f!==""?jf(String(f)):a}),i}const U0=60,V0=3,H0="Resend OTP in {seconds} sec · Attempts remaining: {attempts}",W0="Resend OTP";function R0(e){const t=e.properties?.resend;return!t?.enabled||!t.resendApiEndpoint?.trim()?null:t}function zf(e){const t=Number(e.cooldownSeconds);return!Number.isFinite(t)||t<0?U0:Math.round(t)}function Uf(e){const t=Number(e.maxAttempts);return!Number.isFinite(t)||t<1?V0:Math.round(t)}function Vf(e,t,r){if(!t?.trim()||e==null)return r;const n=Ge(e,t.trim()),o=typeof n=="number"?n:Number(n);return!Number.isFinite(o)||o<0?r:Math.round(o)}function Hf(e,t,r){if(!t?.trim()||e==null)return r;const n=Ge(e,t.trim()),o=typeof n=="number"?n:Number(n);return!Number.isFinite(o)||o<0?r:Math.round(o)}function G0(e,t){const r=Uf(e),n=zf(e),o=e.initialAttemptsPath??"data.attempts_remaining",s=e.initialCooldownPath??"data.resend_cooldown_seconds";return{attemptsRemaining:Vf(t,o,r),secondsRemaining:Hf(t,s,n)}}function K0(e,t,r){Uf(e);const n=zf(e),o=e.attemptsResponsePath??"data.attempts_remaining",s=e.cooldownResponsePath??"data.resend_cooldown_seconds";return{attemptsRemaining:Vf(t,o,r),secondsRemaining:Hf(t,s,n)}}function q0(e,t,r,n){const o=e.resendLinkText?.trim()||W0,s=!n&&t<=0&&r>0;return{seconds:Math.max(0,t),attempts:Math.max(0,r),resendText:o,resendEnabled:s}}function Y0(e,t){const r=e.statusTemplate?.trim()||H0,n=t.seconds>0?` in ${t.seconds} sec`:"",o=t.resendEnabled?t.resendText:t.seconds>0?`${t.resendText}${n}`:t.resendText;return r.replace(/\{seconds\}/g,String(t.seconds)).replace(/\{attempts\}/g,String(t.attempts)).replace(/\{resend\}/g,o)}async function X0(e,t={}){const r=e.resendApiEndpoint?.trim();if(!r)throw new Error("Resend API endpoint is not configured");const{formValues:n={},urlParams:o={},submissionContext:s,prepopulateResponse:i}=t,a=m=>Lr(m,n,o,s,void 0,i),c=(e.resendApiMethod??"POST").toUpperCase();let u=Mr(a(r));const f=e.resendApiQueryParams??[];if(f.length){const m=new URLSearchParams;f.forEach(({key:y,value:S})=>{y.trim()&&m.append(y,a(S))});const h=m.toString();h&&(u=`${u}${u.includes("?")?"&":"?"}${h}`)}const l={};let p=!1;(e.resendApiHeaders??[]).forEach(({key:m,value:h})=>{m.trim()&&(l[m]=a(h))});let g;c!=="GET"&&(e.resendApiBodyFields??[]).length&&(g={},e.resendApiBodyFields.forEach(({key:m,value:h})=>{m.trim()&&(g[m]=a(h))}),p=!0),p&&!l["Content-Type"]&&!l["content-type"]&&(l["Content-Type"]="application/json");try{return c==="GET"?(await Qt.get(u,{headers:Object.keys(l).length?l:void 0})).data:(await Qt.request({url:u,method:c,data:g??{},headers:Object.keys(l).length?l:void 0})).data}catch(m){const h=m,y=h.response?.status,S=typeof h.response?.data=="string"?h.response.data:h.message??"Request failed";throw new Error(y?`HTTP ${y}: ${S}`:String(S))}}function Gr(e){if(e instanceof Error){const t=e.message;if(t&&(t.includes("{")||t.includes("[")))try{const r=t.match(/\{[\s\S]*\}/);if(r){const n=JSON.parse(r[0]);return yo(n)}}catch{}if(e.response){const r=e.response;if(typeof r=="string")try{const n=JSON.parse(r);return yo(n)}catch{return r}else if(typeof r=="object")return yo(r)}return t}if(e instanceof F0)return e.response?.data?yo(e.response.data):e.message||"An unexpected error occurred";if(typeof e=="string")try{const t=JSON.parse(e);return yo(t)}catch{return e}return typeof e=="object"&&e!==null?yo(e):"An unexpected error occurred"}function yo(e){if(e?.display_message&&typeof e.display_message=="string")return e.display_message.trim();if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.error?.explanation&&Array.isArray(e.error.explanation)){const t=e.error.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.explanation&&Array.isArray(e.explanation)){const t=e.explanation.filter(r=>r&&typeof r=="string");if(t.length>0)return t.join(". ")}if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(r=>r!=null&&String(r).trim());if(t.length>0)return t.map(r=>typeof r=="string"?r:r?.message||String(r)).join(". ")}return e?.message&&typeof e.message=="string"?e.message:e?.display_message&&typeof e.display_message=="string"?e.display_message:e?.error?.display_message&&typeof e.error.display_message=="string"?e.error.display_message:e?.error?.message&&typeof e.error.message=="string"?e.error.message:e?.error&&typeof e.error=="string"?e.error:"An unexpected error occurred"}const Wf=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u={},urlParams:f={},submissionContext:l,prepopulateResponse:p})=>{const g=fu(e),m=e.properties?.numericOnly!==!1,h=R0(e),y=v.useRef([]),S=v.useMemo(()=>sw(t,g),[t,g]),w=v.useMemo(()=>h?G0(h,p):null,[h,p]),[A,x]=v.useState(()=>w?.secondsRemaining??0),[F,N]=v.useState(()=>w?.attemptsRemaining??0),[k,T]=v.useState(!1);v.useEffect(()=>{y.current=y.current.slice(0,g)},[g]),v.useEffect(()=>{w&&(x(w.secondsRemaining),N(w.attemptsRemaining))},[w]),v.useEffect(()=>{if(!h||A<=0)return;const D=window.setInterval(()=>{x(K=>K<=1?0:K-1)},1e3);return()=>window.clearInterval(D)},[h,A>0]);const P=v.useMemo(()=>h?q0(h,A,F,k):null,[h,A,F,k]),E=v.useMemo(()=>!h||!P?"":Y0(h,P),[h,P]),C=v.useCallback(async()=>{if(!(!h||!P?.resendEnabled||k)){T(!0);try{const D=await X0(h,{formValues:u,urlParams:f,submissionContext:l,prepopulateResponse:p}),K=K0(h,D,F);N(K.attemptsRemaining),x(K.secondsRemaining),r(""),ct.toast.success("OTP sent successfully.")}catch(D){ct.toast.error(Gr(D))}finally{T(!1)}}},[h,P?.resendEnabled,k,u,f,l,p,F,r]),I=v.useCallback(D=>{r(iw(D))},[r]),W=v.useCallback(D=>{const K=y.current[D];K&&(K.focus(),K.select())},[]),M=v.useCallback((D,K=0)=>{const ae=m?D.replace(/\D/g,""):D.replace(/\s/g,"");if(!ae)return;const j=[...S];let U=K;for(let oe=0;oe<ae.length&&U<g;oe+=1)j[U]=ae[oe]??"",U+=1;I(j);const le=Math.min(U,g-1);requestAnimationFrame(()=>W(le))},[S,I,W,m,g]),z=v.useCallback((D,K)=>{if(i||s||e.readOnly||e.disabled)return;const ae=m?K.replace(/\D/g,""):K.slice(-1),j=[...S];j[D]=ae,I(j),ae&&D<g-1&&requestAnimationFrame(()=>W(D+1))},[S,s,I,e.disabled,e.readOnly,W,m,g,i]),V=v.useCallback((D,K)=>{if(K.key==="Backspace"&&!S[D]&&D>0){K.preventDefault();const ae=[...S];ae[D-1]="",I(ae),W(D-1);return}if(K.key==="ArrowLeft"&&D>0){K.preventDefault(),W(D-1);return}K.key==="ArrowRight"&&D<g-1&&(K.preventDefault(),W(D+1))},[S,I,W,g]),X=v.useCallback((D,K)=>{K.preventDefault();const ae=K.clipboardData.getData("text");M(ae,D)},[M]),L=ft(e),B=h?.resendLinkText?.trim()||"Resend OTP";return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsx("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-labelledby":`${L}-label`,"aria-describedby":Lt(e,!!o),children:S.map((D,K)=>d.jsx(mn,{ref:ae=>{y.current[K]=ae},id:K===0?L:`${L}-${K}`,type:m?"tel":"text",inputMode:m?"numeric":"text",autoComplete:K===0?"one-time-code":"off",maxLength:1,value:D,onChange:ae=>z(K,ae.target.value),onKeyDown:ae=>V(K,ae),onPaste:ae=>X(K,ae),onBlur:K===g-1?n:void 0,disabled:s||e.disabled,readOnly:i||e.readOnly,"aria-label":`${e.label||e.name} digit ${K+1} of ${g}`,"aria-invalid":Jt(!!o),"aria-required":a,className:H(uo(e.appearance),"h-10 w-10 text-center text-base font-medium p-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)},`${e.id}-otp-${K}`))}),h&&P&&d.jsx("p",{className:"text-sm text-muted-foreground","aria-live":"polite",children:P.resendEnabled?d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"text-primary underline-offset-4 hover:underline disabled:opacity-50",disabled:s||k,onClick:C,children:k?"Sending…":B}),d.jsx("span",{children:` · Attempts remaining: ${F}`})]}):d.jsx("span",{children:F<=0&&A<=0?"No attempts remaining.":E})})]})})};function J0({className:e,maxLength:t,showCharacterCount:r=!1,autoResize:n=!1,onChange:o,value:s,...i}){const a=b.useRef(null),[c,u]=b.useState(0),f=l=>{const p=l.target.value;u(p.length),n&&a.current&&(a.current.style.height="auto",a.current.style.height=`${a.current.scrollHeight}px`),o&&o(l)};return b.useEffect(()=>{s&&u(String(s).length)},[s]),d.jsxs("div",{className:"space-y-1",children:[d.jsx("textarea",{ref:a,"data-slot":"textarea",className:H("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n&&"resize-none",e),maxLength:t,onChange:f,value:s,...i}),r&&d.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[d.jsxs("span",{children:[c," characters"]}),t&&d.jsxs("span",{children:[t-c," remaining"]})]})]})}const Rf=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const{gridStretch:u}=Jo(),f=u&&Ks(e),l=e.properties,p=v.useCallback(y=>{r(y.target.value)},[r]),g=(t||"").length,m=l?.maxLength,h=m&&m>0;return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:H("relative flex flex-col",f&&"flex-1 min-h-0"),children:[d.jsx(J0,{id:ft(e),value:t||"",onChange:p,onBlur:n,placeholder:e.placeholder,disabled:s||e.disabled,readOnly:i||e.readOnly,minLength:l?.minLength,maxLength:l?.maxLength,rows:2,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(Jd(e.appearance),"resize-y",f&&"min-h-[120px] flex-1 flex-shrink-0",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),h&&d.jsxs("span",{className:"absolute bottom-2 right-2 text-xs text-muted-foreground",children:[g,"/",m]})]})})};function us(e,[t,r]){return Math.min(r,Math.max(t,e))}function De(e,t,{checkForDefaultPrevented:r=!0}={}){return function(o){if(e?.(o),r===!1||!o.defaultPrevented)return t?.(o)}}function Q0(e,t){const r=b.createContext(t),n=s=>{const{children:i,...a}=s,c=b.useMemo(()=>a,Object.values(a));return d.jsx(r.Provider,{value:c,children:i})};n.displayName=e+"Provider";function o(s){const i=b.useContext(r);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[n,o]}function vr(e,t=[]){let r=[];function n(s,i){const a=b.createContext(i),c=r.length;r=[...r,i];const u=l=>{const{scope:p,children:g,...m}=l,h=p?.[e]?.[c]||a,y=b.useMemo(()=>m,Object.values(m));return d.jsx(h.Provider,{value:y,children:g})};u.displayName=s+"Provider";function f(l,p){const g=p?.[e]?.[c]||a,m=b.useContext(g);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${l}\` must be used within \`${s}\``)}return[u,f]}const o=()=>{const s=r.map(i=>b.createContext(i));return function(a){const c=a?.[e]||s;return b.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[n,Z0(o,...t)]}function Z0(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=n.reduce((a,{useScope:c,scopeName:u})=>{const l=c(s)[`__scope${u}`];return{...a,...l}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return r.scopeName=t.scopeName,r}function Gf(e){const t=ex(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(rx);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function ex(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=ox(o),a=nx(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var tx=Symbol("radix.slottable");function rx(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===tx}function nx(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function ox(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function Cl(e){const t=e+"CollectionProvider",[r,n]=vr(t),[o,s]=r(t,{collectionRef:{current:null},itemMap:new Map}),i=h=>{const{scope:y,children:S}=h,w=v.useRef(null),A=v.useRef(new Map).current;return d.jsx(o,{scope:y,itemMap:A,collectionRef:w,children:S})};i.displayName=t;const a=e+"CollectionSlot",c=Gf(a),u=v.forwardRef((h,y)=>{const{scope:S,children:w}=h,A=s(a,S),x=Qe(y,A.collectionRef);return d.jsx(c,{ref:x,children:w})});u.displayName=a;const f=e+"CollectionItemSlot",l="data-radix-collection-item",p=Gf(f),g=v.forwardRef((h,y)=>{const{scope:S,children:w,...A}=h,x=v.useRef(null),F=Qe(y,x),N=s(f,S);return v.useEffect(()=>(N.itemMap.set(x,{ref:x,...A}),()=>{N.itemMap.delete(x)})),d.jsx(p,{[l]:"",ref:F,children:w})});g.displayName=f;function m(h){const y=s(e+"CollectionConsumer",h);return v.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const A=Array.from(w.querySelectorAll(`[${l}]`));return Array.from(y.itemMap.values()).sort((N,k)=>A.indexOf(N.ref.current)-A.indexOf(k.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:u,ItemSlot:g},m,n]}var sx=b.createContext(void 0);function bo(e){const t=b.useContext(sx);return e||t||"ltr"}function ix(e){const t=ax(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(cx);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function ax(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=ux(o),a=dx(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var lx=Symbol("radix.slottable");function cx(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===lx}function dx(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function ux(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var fx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],je=fx.reduce((e,t)=>{const r=ix(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function px(e,t){e&&js.flushSync(()=>e.dispatchEvent(t))}function cr(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>(...r)=>t.current?.(...r),[])}function mx(e,t=globalThis?.document){const r=cr(e);b.useEffect(()=>{const n=o=>{o.key==="Escape"&&r(o)};return t.addEventListener("keydown",n,{capture:!0}),()=>t.removeEventListener("keydown",n,{capture:!0})},[r,t])}var hx="DismissableLayer",El="dismissableLayer.update",gx="dismissableLayer.pointerDownOutside",yx="dismissableLayer.focusOutside",Kf,qf=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),gi=b.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,u=b.useContext(qf),[f,l]=b.useState(null),p=f?.ownerDocument??globalThis?.document,[,g]=b.useState({}),m=Qe(t,k=>l(k)),h=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),S=h.indexOf(y),w=f?h.indexOf(f):-1,A=u.layersWithOutsidePointerEventsDisabled.size>0,x=w>=S,F=wx(k=>{const T=k.target,P=[...u.branches].some(E=>E.contains(T));!x||P||(o?.(k),i?.(k),k.defaultPrevented||a?.())},p),N=Sx(k=>{const T=k.target;[...u.branches].some(E=>E.contains(T))||(s?.(k),i?.(k),k.defaultPrevented||a?.())},p);return mx(k=>{w===u.layers.size-1&&(n?.(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},p),b.useEffect(()=>{if(f)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Kf=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),Yf(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=Kf)}},[f,p,r,u]),b.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),Yf())},[f,u]),b.useEffect(()=>{const k=()=>g({});return document.addEventListener(El,k),()=>document.removeEventListener(El,k)},[]),d.jsx(je.div,{...c,ref:m,style:{pointerEvents:A?x?"auto":"none":void 0,...e.style},onFocusCapture:De(e.onFocusCapture,N.onFocusCapture),onBlurCapture:De(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:De(e.onPointerDownCapture,F.onPointerDownCapture)})});gi.displayName=hx;var bx="DismissableLayerBranch",vx=b.forwardRef((e,t)=>{const r=b.useContext(qf),n=b.useRef(null),o=Qe(t,n);return b.useEffect(()=>{const s=n.current;if(s)return r.branches.add(s),()=>{r.branches.delete(s)}},[r.branches]),d.jsx(je.div,{...e,ref:o})});vx.displayName=bx;function wx(e,t=globalThis?.document){const r=cr(e),n=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const s=a=>{if(a.target&&!n.current){let c=function(){Xf(gx,r,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);n.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,r]),{onPointerDownCapture:()=>n.current=!0}}function Sx(e,t=globalThis?.document){const r=cr(e),n=b.useRef(!1);return b.useEffect(()=>{const o=s=>{s.target&&!n.current&&Xf(yx,r,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function Yf(){const e=new CustomEvent(El);document.dispatchEvent(e)}function Xf(e,t,r,{discrete:n}){const o=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&o.addEventListener(e,t,{once:!0}),n?px(o,s):o.dispatchEvent(s)}var Nl=0;function kl(){b.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Jf()),document.body.insertAdjacentElement("beforeend",e[1]??Jf()),Nl++,()=>{Nl===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Nl--}},[])}function Jf(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var _l="focusScope.autoFocusOnMount",Tl="focusScope.autoFocusOnUnmount",Qf={bubbles:!1,cancelable:!0},xx="FocusScope",yi=b.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=b.useState(null),u=cr(o),f=cr(s),l=b.useRef(null),p=Qe(t,h=>c(h)),g=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(n){let h=function(A){if(g.paused||!a)return;const x=A.target;a.contains(x)?l.current=x:On(l.current,{select:!0})},y=function(A){if(g.paused||!a)return;const x=A.relatedTarget;x!==null&&(a.contains(x)||On(l.current,{select:!0}))},S=function(A){if(document.activeElement===document.body)for(const F of A)F.removedNodes.length>0&&On(a)};document.addEventListener("focusin",h),document.addEventListener("focusout",y);const w=new MutationObserver(S);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",y),w.disconnect()}}},[n,a,g.paused]),b.useEffect(()=>{if(a){tp.add(g);const h=document.activeElement;if(!a.contains(h)){const S=new CustomEvent(_l,Qf);a.addEventListener(_l,u),a.dispatchEvent(S),S.defaultPrevented||(Ax(_x(Zf(a)),{select:!0}),document.activeElement===h&&On(a))}return()=>{a.removeEventListener(_l,u),setTimeout(()=>{const S=new CustomEvent(Tl,Qf);a.addEventListener(Tl,f),a.dispatchEvent(S),S.defaultPrevented||On(h??document.body,{select:!0}),a.removeEventListener(Tl,f),tp.remove(g)},0)}}},[a,u,f,g]);const m=b.useCallback(h=>{if(!r&&!n||g.paused)return;const y=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,S=document.activeElement;if(y&&S){const w=h.currentTarget,[A,x]=Cx(w);A&&x?!h.shiftKey&&S===x?(h.preventDefault(),r&&On(A,{select:!0})):h.shiftKey&&S===A&&(h.preventDefault(),r&&On(x,{select:!0})):S===w&&h.preventDefault()}},[r,n,g.paused]);return d.jsx(je.div,{tabIndex:-1,...i,ref:p,onKeyDown:m})});yi.displayName=xx;function Ax(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(On(n,{select:t}),document.activeElement!==r)return}function Cx(e){const t=Zf(e),r=ep(t,e),n=ep(t.reverse(),e);return[r,n]}function Zf(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const o=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||o?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function ep(e,t){for(const r of e)if(!Ex(r,{upTo:t}))return r}function Ex(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Nx(e){return e instanceof HTMLInputElement&&"select"in e}function On(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&Nx(e)&&t&&e.select()}}var tp=kx();function kx(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=rp(e,t),e.unshift(t)},remove(t){e=rp(e,t),e[0]?.resume()}}}function rp(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function _x(e){return e.filter(t=>t.tagName!=="A")}var tr=globalThis?.document?b.useLayoutEffect:()=>{},Tx=b[" useId ".trim().toString()]||(()=>{}),Fx=0;function hn(e){const[t,r]=b.useState(Tx());return tr(()=>{r(n=>n??String(Fx++))},[e]),e||(t?`radix-${t}`:"")}const Px=["top","right","bottom","left"],In=Math.min,wr=Math.max,bi=Math.round,vi=Math.floor,on=e=>({x:e,y:e}),Ox={left:"right",right:"left",bottom:"top",top:"bottom"};function Fl(e,t,r){return wr(e,In(t,r))}function gn(e,t){return typeof e=="function"?e(t):e}function yn(e){return e.split("-")[0]}function vo(e){return e.split("-")[1]}function Pl(e){return e==="x"?"y":"x"}function Ol(e){return e==="y"?"height":"width"}function sn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Il(e){return Pl(sn(e))}function Ix(e,t,r){r===void 0&&(r=!1);const n=vo(e),o=Il(e),s=Ol(o);let i=o==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=wi(i)),[i,wi(i)]}function Mx(e){const t=wi(e);return[Ml(e),t,Ml(t)]}function Ml(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const np=["left","right"],op=["right","left"],Lx=["top","bottom"],Dx=["bottom","top"];function Bx(e,t,r){switch(e){case"top":case"bottom":return r?t?op:np:t?np:op;case"left":case"right":return t?Lx:Dx;default:return[]}}function $x(e,t,r,n){const o=vo(e);let s=Bx(yn(e),r==="start",n);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ml)))),s}function wi(e){const t=yn(e);return Ox[t]+e.slice(t.length)}function jx(e){return{top:0,right:0,bottom:0,left:0,...e}}function sp(e){return typeof e!="number"?jx(e):{top:e,right:e,bottom:e,left:e}}function Si(e){const{x:t,y:r,width:n,height:o}=e;return{width:n,height:o,top:r,left:t,right:t+n,bottom:r+o,x:t,y:r}}function ip(e,t,r){let{reference:n,floating:o}=e;const s=sn(t),i=Il(t),a=Ol(i),c=yn(t),u=s==="y",f=n.x+n.width/2-o.width/2,l=n.y+n.height/2-o.height/2,p=n[a]/2-o[a]/2;let g;switch(c){case"top":g={x:f,y:n.y-o.height};break;case"bottom":g={x:f,y:n.y+n.height};break;case"right":g={x:n.x+n.width,y:l};break;case"left":g={x:n.x-o.width,y:l};break;default:g={x:n.x,y:n.y}}switch(vo(t)){case"start":g[i]-=p*(r&&u?-1:1);break;case"end":g[i]+=p*(r&&u?-1:1);break}return g}async function zx(e,t){var r;t===void 0&&(t={});const{x:n,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:l="floating",altBoundary:p=!1,padding:g=0}=gn(t,e),m=sp(g),y=a[p?l==="floating"?"reference":"floating":l],S=Si(await s.getClippingRect({element:(r=await(s.isElement==null?void 0:s.isElement(y)))==null||r?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:f,strategy:c})),w=l==="floating"?{x:n,y:o,width:i.floating.width,height:i.floating.height}:i.reference,A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),x=await(s.isElement==null?void 0:s.isElement(A))?await(s.getScale==null?void 0:s.getScale(A))||{x:1,y:1}:{x:1,y:1},F=Si(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:A,strategy:c}):w);return{top:(S.top-F.top+m.top)/x.y,bottom:(F.bottom-S.bottom+m.bottom)/x.y,left:(S.left-F.left+m.left)/x.x,right:(F.right-S.right+m.right)/x.x}}const Ux=50,Vx=async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:s=[],platform:i}=r,a=i.detectOverflow?i:{...i,detectOverflow:zx},c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:l}=ip(u,n,c),p=n,g=0;const m={};for(let h=0;h<s.length;h++){const y=s[h];if(!y)continue;const{name:S,fn:w}=y,{x:A,y:x,data:F,reset:N}=await w({x:f,y:l,initialPlacement:n,placement:p,strategy:o,middlewareData:m,rects:u,platform:a,elements:{reference:e,floating:t}});f=A??f,l=x??l,m[S]={...m[S],...F},N&&g<Ux&&(g++,typeof N=="object"&&(N.placement&&(p=N.placement),N.rects&&(u=N.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):N.rects),{x:f,y:l}=ip(u,p,c)),h=-1)}return{x:f,y:l,placement:p,strategy:o,middlewareData:m}},Hx=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:f=0}=gn(e,t)||{};if(u==null)return{};const l=sp(f),p={x:r,y:n},g=Il(o),m=Ol(g),h=await i.getDimensions(u),y=g==="y",S=y?"top":"left",w=y?"bottom":"right",A=y?"clientHeight":"clientWidth",x=s.reference[m]+s.reference[g]-p[g]-s.floating[m],F=p[g]-s.reference[g],N=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let k=N?N[A]:0;(!k||!await(i.isElement==null?void 0:i.isElement(N)))&&(k=a.floating[A]||s.floating[m]);const T=x/2-F/2,P=k/2-h[m]/2-1,E=In(l[S],P),C=In(l[w],P),I=E,W=k-h[m]-C,M=k/2-h[m]/2+T,z=Fl(I,M,W),V=!c.arrow&&vo(o)!=null&&M!==z&&s.reference[m]/2-(M<I?E:C)-h[m]/2<0,X=V?M<I?M-I:M-W:0;return{[g]:p[g]+X,data:{[g]:z,centerOffset:M-z-X,...V&&{alignmentOffset:X}},reset:V}}}),Wx=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:f=!0,crossAxis:l=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:h=!0,...y}=gn(e,t);if((r=s.arrow)!=null&&r.alignmentOffset)return{};const S=yn(o),w=sn(a),A=yn(a)===a,x=await(c.isRTL==null?void 0:c.isRTL(u.floating)),F=p||(A||!h?[wi(a)]:Mx(a)),N=m!=="none";!p&&N&&F.push(...$x(a,h,m,x));const k=[a,...F],T=await c.detectOverflow(t,y),P=[];let E=((n=s.flip)==null?void 0:n.overflows)||[];if(f&&P.push(T[S]),l){const M=Ix(o,i,x);P.push(T[M[0]],T[M[1]])}if(E=[...E,{placement:o,overflows:P}],!P.every(M=>M<=0)){var C,I;const M=(((C=s.flip)==null?void 0:C.index)||0)+1,z=k[M];if(z&&(!(l==="alignment"?w!==sn(z):!1)||E.every(L=>sn(L.placement)===w?L.overflows[0]>0:!0)))return{data:{index:M,overflows:E},reset:{placement:z}};let V=(I=E.filter(X=>X.overflows[0]<=0).sort((X,L)=>X.overflows[1]-L.overflows[1])[0])==null?void 0:I.placement;if(!V)switch(g){case"bestFit":{var W;const X=(W=E.filter(L=>{if(N){const B=sn(L.placement);return B===w||B==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(B=>B>0).reduce((B,D)=>B+D,0)]).sort((L,B)=>L[1]-B[1])[0])==null?void 0:W[0];X&&(V=X);break}case"initialPlacement":V=a;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function ap(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function lp(e){return Px.some(t=>e[t]>=0)}const Rx=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:n}=t,{strategy:o="referenceHidden",...s}=gn(e,t);switch(o){case"referenceHidden":{const i=await n.detectOverflow(t,{...s,elementContext:"reference"}),a=ap(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:lp(a)}}}case"escaped":{const i=await n.detectOverflow(t,{...s,altBoundary:!0}),a=ap(i,r.floating);return{data:{escapedOffsets:a,escaped:lp(a)}}}default:return{}}}}},cp=new Set(["left","top"]);async function Gx(e,t){const{placement:r,platform:n,elements:o}=e,s=await(n.isRTL==null?void 0:n.isRTL(o.floating)),i=yn(r),a=vo(r),c=sn(r)==="y",u=cp.has(i)?-1:1,f=s&&c?-1:1,l=gn(t,e);let{mainAxis:p,crossAxis:g,alignmentAxis:m}=typeof l=="number"?{mainAxis:l,crossAxis:0,alignmentAxis:null}:{mainAxis:l.mainAxis||0,crossAxis:l.crossAxis||0,alignmentAxis:l.alignmentAxis};return a&&typeof m=="number"&&(g=a==="end"?m*-1:m),c?{x:g*f,y:p*u}:{x:p*u,y:g*f}}const Kx=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:o,y:s,placement:i,middlewareData:a}=t,c=await Gx(t,e);return i===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},qx=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:o,platform:s}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:c={fn:S=>{let{x:w,y:A}=S;return{x:w,y:A}}},...u}=gn(e,t),f={x:r,y:n},l=await s.detectOverflow(t,u),p=sn(yn(o)),g=Pl(p);let m=f[g],h=f[p];if(i){const S=g==="y"?"top":"left",w=g==="y"?"bottom":"right",A=m+l[S],x=m-l[w];m=Fl(A,m,x)}if(a){const S=p==="y"?"top":"left",w=p==="y"?"bottom":"right",A=h+l[S],x=h-l[w];h=Fl(A,h,x)}const y=c.fn({...t,[g]:m,[p]:h});return{...y,data:{x:y.x-r,y:y.y-n,enabled:{[g]:i,[p]:a}}}}}},Yx=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:n,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:c=!0,crossAxis:u=!0}=gn(e,t),f={x:r,y:n},l=sn(o),p=Pl(l);let g=f[p],m=f[l];const h=gn(a,t),y=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){const A=p==="y"?"height":"width",x=s.reference[p]-s.floating[A]+y.mainAxis,F=s.reference[p]+s.reference[A]-y.mainAxis;g<x?g=x:g>F&&(g=F)}if(u){var S,w;const A=p==="y"?"width":"height",x=cp.has(yn(o)),F=s.reference[l]-s.floating[A]+(x&&((S=i.offset)==null?void 0:S[l])||0)+(x?0:y.crossAxis),N=s.reference[l]+s.reference[A]+(x?0:((w=i.offset)==null?void 0:w[l])||0)-(x?y.crossAxis:0);m<F?m=F:m>N&&(m=N)}return{[p]:g,[l]:m}}}},Xx=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:c=()=>{},...u}=gn(e,t),f=await i.detectOverflow(t,u),l=yn(o),p=vo(o),g=sn(o)==="y",{width:m,height:h}=s.floating;let y,S;l==="top"||l==="bottom"?(y=l,S=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(S=l,y=p==="end"?"top":"bottom");const w=h-f.top-f.bottom,A=m-f.left-f.right,x=In(h-f[y],w),F=In(m-f[S],A),N=!t.middlewareData.shift;let k=x,T=F;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(T=A),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(k=w),N&&!p){const E=wr(f.left,0),C=wr(f.right,0),I=wr(f.top,0),W=wr(f.bottom,0);g?T=m-2*(E!==0||C!==0?E+C:wr(f.left,f.right)):k=h-2*(I!==0||W!==0?I+W:wr(f.top,f.bottom))}await c({...t,availableWidth:T,availableHeight:k});const P=await i.getDimensions(a.floating);return m!==P.width||h!==P.height?{reset:{rects:!0}}:{}}}};function xi(){return typeof window<"u"}function wo(e){return dp(e)?(e.nodeName||"").toLowerCase():"#document"}function Sr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function an(e){var t;return(t=(dp(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function dp(e){return xi()?e instanceof Node||e instanceof Sr(e).Node:!1}function Kr(e){return xi()?e instanceof Element||e instanceof Sr(e).Element:!1}function bn(e){return xi()?e instanceof HTMLElement||e instanceof Sr(e).HTMLElement:!1}function up(e){return!xi()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Sr(e).ShadowRoot}function fs(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=qr(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&o!=="inline"&&o!=="contents"}function Jx(e){return/^(table|td|th)$/.test(wo(e))}function Ai(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Qx=/transform|translate|scale|rotate|perspective|filter/,Zx=/paint|layout|strict|content/,Zn=e=>!!e&&e!=="none";let Ll;function Dl(e){const t=Kr(e)?qr(e):e;return Zn(t.transform)||Zn(t.translate)||Zn(t.scale)||Zn(t.rotate)||Zn(t.perspective)||!Bl()&&(Zn(t.backdropFilter)||Zn(t.filter))||Qx.test(t.willChange||"")||Zx.test(t.contain||"")}function eA(e){let t=Mn(e);for(;bn(t)&&!So(t);){if(Dl(t))return t;if(Ai(t))return null;t=Mn(t)}return null}function Bl(){return Ll==null&&(Ll=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ll}function So(e){return/^(html|body|#document)$/.test(wo(e))}function qr(e){return Sr(e).getComputedStyle(e)}function Ci(e){return Kr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Mn(e){if(wo(e)==="html")return e;const t=e.assignedSlot||e.parentNode||up(e)&&e.host||an(e);return up(t)?t.host:t}function fp(e){const t=Mn(e);return So(t)?e.ownerDocument?e.ownerDocument.body:e.body:bn(t)&&fs(t)?t:fp(t)}function ps(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const o=fp(e),s=o===((n=e.ownerDocument)==null?void 0:n.body),i=Sr(o);if(s){const a=$l(i);return t.concat(i,i.visualViewport||[],fs(o)?o:[],a&&r?ps(a):[])}else return t.concat(o,ps(o,[],r))}function $l(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function pp(e){const t=qr(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=bn(e),s=o?e.offsetWidth:r,i=o?e.offsetHeight:n,a=bi(r)!==s||bi(n)!==i;return a&&(r=s,n=i),{width:r,height:n,$:a}}function jl(e){return Kr(e)?e:e.contextElement}function xo(e){const t=jl(e);if(!bn(t))return on(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:s}=pp(t);let i=(s?bi(r.width):r.width)/n,a=(s?bi(r.height):r.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const tA=on(0);function mp(e){const t=Sr(e);return!Bl()||!t.visualViewport?tA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function rA(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Sr(e)?!1:t}function eo(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),s=jl(e);let i=on(1);t&&(n?Kr(n)&&(i=xo(n)):i=xo(e));const a=rA(s,r,n)?mp(s):on(0);let c=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,f=o.width/i.x,l=o.height/i.y;if(s){const p=Sr(s),g=n&&Kr(n)?Sr(n):n;let m=p,h=$l(m);for(;h&&n&&g!==m;){const y=xo(h),S=h.getBoundingClientRect(),w=qr(h),A=S.left+(h.clientLeft+parseFloat(w.paddingLeft))*y.x,x=S.top+(h.clientTop+parseFloat(w.paddingTop))*y.y;c*=y.x,u*=y.y,f*=y.x,l*=y.y,c+=A,u+=x,m=Sr(h),h=$l(m)}}return Si({width:f,height:l,x:c,y:u})}function Ei(e,t){const r=Ci(e).scrollLeft;return t?t.left+r:eo(an(e)).left+r}function hp(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-Ei(e,r),o=r.top+t.scrollTop;return{x:n,y:o}}function nA(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const s=o==="fixed",i=an(n),a=t?Ai(t.floating):!1;if(n===i||a&&s)return r;let c={scrollLeft:0,scrollTop:0},u=on(1);const f=on(0),l=bn(n);if((l||!l&&!s)&&((wo(n)!=="body"||fs(i))&&(c=Ci(n)),l)){const g=eo(n);u=xo(n),f.x=g.x+n.clientLeft,f.y=g.y+n.clientTop}const p=i&&!l&&!s?hp(i,c):on(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-c.scrollLeft*u.x+f.x+p.x,y:r.y*u.y-c.scrollTop*u.y+f.y+p.y}}function oA(e){return Array.from(e.getClientRects())}function sA(e){const t=an(e),r=Ci(e),n=e.ownerDocument.body,o=wr(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=wr(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let i=-r.scrollLeft+Ei(e);const a=-r.scrollTop;return qr(n).direction==="rtl"&&(i+=wr(t.clientWidth,n.clientWidth)-o),{width:o,height:s,x:i,y:a}}const gp=25;function iA(e,t){const r=Sr(e),n=an(e),o=r.visualViewport;let s=n.clientWidth,i=n.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const f=Bl();(!f||f&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}const u=Ei(n);if(u<=0){const f=n.ownerDocument,l=f.body,p=getComputedStyle(l),g=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,m=Math.abs(n.clientWidth-l.clientWidth-g);m<=gp&&(s-=m)}else u<=gp&&(s+=u);return{width:s,height:i,x:a,y:c}}function aA(e,t){const r=eo(e,!0,t==="fixed"),n=r.top+e.clientTop,o=r.left+e.clientLeft,s=bn(e)?xo(e):on(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=n*s.y;return{width:i,height:a,x:c,y:u}}function yp(e,t,r){let n;if(t==="viewport")n=iA(e,r);else if(t==="document")n=sA(an(e));else if(Kr(t))n=aA(t,r);else{const o=mp(e);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Si(n)}function bp(e,t){const r=Mn(e);return r===t||!Kr(r)||So(r)?!1:qr(r).position==="fixed"||bp(r,t)}function lA(e,t){const r=t.get(e);if(r)return r;let n=ps(e,[],!1).filter(a=>Kr(a)&&wo(a)!=="body"),o=null;const s=qr(e).position==="fixed";let i=s?Mn(e):e;for(;Kr(i)&&!So(i);){const a=qr(i),c=Dl(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||fs(i)&&!c&&bp(e,i))?n=n.filter(f=>f!==i):o=a,i=Mn(i)}return t.set(e,n),n}function cA(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const i=[...r==="clippingAncestors"?Ai(t)?[]:lA(t,this._c):[].concat(r),n],a=yp(t,i[0],o);let c=a.top,u=a.right,f=a.bottom,l=a.left;for(let p=1;p<i.length;p++){const g=yp(t,i[p],o);c=wr(g.top,c),u=In(g.right,u),f=In(g.bottom,f),l=wr(g.left,l)}return{width:u-l,height:f-c,x:l,y:c}}function dA(e){const{width:t,height:r}=pp(e);return{width:t,height:r}}function uA(e,t,r){const n=bn(t),o=an(t),s=r==="fixed",i=eo(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=on(0);function u(){c.x=Ei(o)}if(n||!n&&!s)if((wo(t)!=="body"||fs(o))&&(a=Ci(t)),n){const g=eo(t,!0,s,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else o&&u();s&&!n&&o&&u();const f=o&&!n&&!s?hp(o,a):on(0),l=i.left+a.scrollLeft-c.x-f.x,p=i.top+a.scrollTop-c.y-f.y;return{x:l,y:p,width:i.width,height:i.height}}function zl(e){return qr(e).position==="static"}function vp(e,t){if(!bn(e)||qr(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return an(e)===r&&(r=r.ownerDocument.body),r}function wp(e,t){const r=Sr(e);if(Ai(e))return r;if(!bn(e)){let o=Mn(e);for(;o&&!So(o);){if(Kr(o)&&!zl(o))return o;o=Mn(o)}return r}let n=vp(e,t);for(;n&&Jx(n)&&zl(n);)n=vp(n,t);return n&&So(n)&&zl(n)&&!Dl(n)?r:n||eA(e)||r}const fA=async function(e){const t=this.getOffsetParent||wp,r=this.getDimensions,n=await r(e.floating);return{reference:uA(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function pA(e){return qr(e).direction==="rtl"}const mA={convertOffsetParentRelativeRectToViewportRelativeRect:nA,getDocumentElement:an,getClippingRect:cA,getOffsetParent:wp,getElementRects:fA,getClientRects:oA,getDimensions:dA,getScale:xo,isElement:Kr,isRTL:pA};function Sp(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function hA(e,t){let r=null,n;const o=an(e);function s(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:f,top:l,width:p,height:g}=u;if(a||t(),!p||!g)return;const m=vi(l),h=vi(o.clientWidth-(f+p)),y=vi(o.clientHeight-(l+g)),S=vi(f),A={rootMargin:-m+"px "+-h+"px "+-y+"px "+-S+"px",threshold:wr(0,In(1,c))||1};let x=!0;function F(N){const k=N[0].intersectionRatio;if(k!==c){if(!x)return i();k?i(!1,k):n=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!Sp(u,e.getBoundingClientRect())&&i(),x=!1}try{r=new IntersectionObserver(F,{...A,root:o.ownerDocument})}catch{r=new IntersectionObserver(F,A)}r.observe(e)}return i(!0),s}function gA(e,t,r,n){n===void 0&&(n={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,u=jl(e),f=o||s?[...u?ps(u):[],...t?ps(t):[]]:[];f.forEach(S=>{o&&S.addEventListener("scroll",r,{passive:!0}),s&&S.addEventListener("resize",r)});const l=u&&a?hA(u,r):null;let p=-1,g=null;i&&(g=new ResizeObserver(S=>{let[w]=S;w&&w.target===u&&g&&t&&(g.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var A;(A=g)==null||A.observe(t)})),r()}),u&&!c&&g.observe(u),t&&g.observe(t));let m,h=c?eo(e):null;c&&y();function y(){const S=eo(e);h&&!Sp(h,S)&&r(),h=S,m=requestAnimationFrame(y)}return r(),()=>{var S;f.forEach(w=>{o&&w.removeEventListener("scroll",r),s&&w.removeEventListener("resize",r)}),l?.(),(S=g)==null||S.disconnect(),g=null,c&&cancelAnimationFrame(m)}}const yA=Kx,bA=qx,vA=Wx,wA=Xx,SA=Rx,xp=Hx,xA=Yx,AA=(e,t,r)=>{const n=new Map,o={platform:mA,...r},s={...o.platform,_c:n};return Vx(e,t,{...o,platform:s})};var CA=typeof document<"u",EA=function(){},Ni=CA?v.useLayoutEffect:EA;function ki(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,n,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;n--!==0;)if(!ki(e[n],t[n]))return!1;return!0}if(o=Object.keys(e),r=o.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(t,o[n]))return!1;for(n=r;n--!==0;){const s=o[n];if(!(s==="_owner"&&e.$$typeof)&&!ki(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ap(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Cp(e,t){const r=Ap(e);return Math.round(t*r)/r}function Ul(e){const t=b.useRef(e);return Ni(()=>{t.current=e}),t}function NA(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[f,l]=b.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[p,g]=b.useState(n);ki(p,n)||g(n);const[m,h]=b.useState(null),[y,S]=b.useState(null),w=b.useCallback(L=>{L!==N.current&&(N.current=L,h(L))},[]),A=b.useCallback(L=>{L!==k.current&&(k.current=L,S(L))},[]),x=s||m,F=i||y,N=b.useRef(null),k=b.useRef(null),T=b.useRef(f),P=c!=null,E=Ul(c),C=Ul(o),I=Ul(u),W=b.useCallback(()=>{if(!N.current||!k.current)return;const L={placement:t,strategy:r,middleware:p};C.current&&(L.platform=C.current),AA(N.current,k.current,L).then(B=>{const D={...B,isPositioned:I.current!==!1};M.current&&!ki(T.current,D)&&(T.current=D,js.flushSync(()=>{l(D)}))})},[p,t,r,C,I]);Ni(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,l(L=>({...L,isPositioned:!1})))},[u]);const M=b.useRef(!1);Ni(()=>(M.current=!0,()=>{M.current=!1}),[]),Ni(()=>{if(x&&(N.current=x),F&&(k.current=F),x&&F){if(E.current)return E.current(x,F,W);W()}},[x,F,W,E,P]);const z=b.useMemo(()=>({reference:N,floating:k,setReference:w,setFloating:A}),[w,A]),V=b.useMemo(()=>({reference:x,floating:F}),[x,F]),X=b.useMemo(()=>{const L={position:r,left:0,top:0};if(!V.floating)return L;const B=Cp(V.floating,f.x),D=Cp(V.floating,f.y);return a?{...L,transform:"translate("+B+"px, "+D+"px)",...Ap(V.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:B,top:D}},[r,a,V.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:W,refs:z,elements:V,floatingStyles:X}),[f,W,z,V,X])}const kA=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:n,padding:o}=typeof e=="function"?e(r):e;return n&&t(n)?n.current!=null?xp({element:n.current,padding:o}).fn(r):{}:n?xp({element:n,padding:o}).fn(r):{}}}},_A=(e,t)=>{const r=yA(e);return{name:r.name,fn:r.fn,options:[e,t]}},TA=(e,t)=>{const r=bA(e);return{name:r.name,fn:r.fn,options:[e,t]}},FA=(e,t)=>({fn:xA(e).fn,options:[e,t]}),PA=(e,t)=>{const r=vA(e);return{name:r.name,fn:r.fn,options:[e,t]}},OA=(e,t)=>{const r=wA(e);return{name:r.name,fn:r.fn,options:[e,t]}},IA=(e,t)=>{const r=SA(e);return{name:r.name,fn:r.fn,options:[e,t]}},MA=(e,t)=>{const r=kA(e);return{name:r.name,fn:r.fn,options:[e,t]}};var LA="Arrow",Ep=b.forwardRef((e,t)=>{const{children:r,width:n=10,height:o=5,...s}=e;return d.jsx(je.svg,{...s,ref:t,width:n,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ep.displayName=LA;var DA=Ep;function ms(e){const[t,r]=b.useState(void 0);return tr(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;r({width:i,height:a})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),t}var Vl="Popper",[Np,_i]=vr(Vl),[BA,kp]=Np(Vl),_p=e=>{const{__scopePopper:t,children:r}=e,[n,o]=b.useState(null);return d.jsx(BA,{scope:t,anchor:n,onAnchorChange:o,children:r})};_p.displayName=Vl;var Tp="PopperAnchor",Fp=b.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...o}=e,s=kp(Tp,r),i=b.useRef(null),a=Qe(t,i),c=b.useRef(null);return b.useEffect(()=>{const u=c.current;c.current=n?.current||i.current,u!==c.current&&s.onAnchorChange(c.current)}),n?null:d.jsx(je.div,{...o,ref:a})});Fp.displayName=Tp;var Hl="PopperContent",[$A,jA]=Np(Hl),Pp=b.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:l="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:m,...h}=e,y=kp(Hl,r),[S,w]=b.useState(null),A=Qe(t,G=>w(G)),[x,F]=b.useState(null),N=ms(x),k=N?.width??0,T=N?.height??0,P=n+(s!=="center"?"-"+s:""),E=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},C=Array.isArray(u)?u:[u],I=C.length>0,W={padding:E,boundary:C.filter(UA),altBoundary:I},{refs:M,floatingStyles:z,placement:V,isPositioned:X,middlewareData:L}=NA({strategy:"fixed",placement:P,whileElementsMounted:(...G)=>gA(...G,{animationFrame:g==="always"}),elements:{reference:y.anchor},middleware:[_A({mainAxis:o+T,alignmentAxis:i}),c&&TA({mainAxis:!0,crossAxis:!1,limiter:l==="partial"?FA():void 0,...W}),c&&PA({...W}),OA({...W,apply:({elements:G,rects:ie,availableWidth:Ce,availableHeight:ee})=>{const{width:ne,height:he}=ie.reference,Ie=G.floating.style;Ie.setProperty("--radix-popper-available-width",`${Ce}px`),Ie.setProperty("--radix-popper-available-height",`${ee}px`),Ie.setProperty("--radix-popper-anchor-width",`${ne}px`),Ie.setProperty("--radix-popper-anchor-height",`${he}px`)}}),x&&MA({element:x,padding:a}),VA({arrowWidth:k,arrowHeight:T}),p&&IA({strategy:"referenceHidden",...W})]}),[B,D]=Mp(V),K=cr(m);tr(()=>{X&&K?.()},[X,K]);const ae=L.arrow?.x,j=L.arrow?.y,U=L.arrow?.centerOffset!==0,[le,oe]=b.useState();return tr(()=>{S&&oe(window.getComputedStyle(S).zIndex)},[S]),d.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:X?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:le,"--radix-popper-transform-origin":[L.transformOrigin?.x,L.transformOrigin?.y].join(" "),...L.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx($A,{scope:r,placedSide:B,onArrowChange:F,arrowX:ae,arrowY:j,shouldHideArrow:U,children:d.jsx(je.div,{"data-side":B,"data-align":D,...h,ref:A,style:{...h.style,animation:X?void 0:"none"}})})})});Pp.displayName=Hl;var Op="PopperArrow",zA={top:"bottom",right:"left",bottom:"top",left:"right"},Ip=b.forwardRef(function(t,r){const{__scopePopper:n,...o}=t,s=jA(Op,n),i=zA[s.placedSide];return d.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:d.jsx(DA,{...o,ref:r,style:{...o.style,display:"block"}})})});Ip.displayName=Op;function UA(e){return e!==null}var VA=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:n,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,f]=Mp(r),l={start:"0%",center:"50%",end:"100%"}[f],p=(o.arrow?.x??0)+a/2,g=(o.arrow?.y??0)+c/2;let m="",h="";return u==="bottom"?(m=i?l:`${p}px`,h=`${-c}px`):u==="top"?(m=i?l:`${p}px`,h=`${n.floating.height+c}px`):u==="right"?(m=`${-c}px`,h=i?l:`${g}px`):u==="left"&&(m=`${n.floating.width+c}px`,h=i?l:`${g}px`),{data:{x:m,y:h}}}});function Mp(e){const[t,r="center"]=e.split("-");return[t,r]}var Lp=_p,Wl=Fp,Dp=Pp,Bp=Ip,HA="Portal",Ti=b.forwardRef((e,t)=>{const{container:r,...n}=e,[o,s]=b.useState(!1);tr(()=>s(!0),[]);const i=r||o&&globalThis?.document?.body;return i?Nd.createPortal(d.jsx(je.div,{...n,ref:t}),i):null});Ti.displayName=HA;function WA(e){const t=RA(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(KA);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function RA(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=YA(o),a=qA(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var GA=Symbol("radix.slottable");function KA(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===GA}function qA(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function YA(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var XA=b[" useInsertionEffect ".trim().toString()]||tr;function ln({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[o,s,i]=JA({defaultProp:t,onChange:r}),a=e!==void 0,c=a?e:o;{const f=b.useRef(e!==void 0);b.useEffect(()=>{const l=f.current;l!==a&&console.warn(`${n} is changing from ${l?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=a},[a,n])}const u=b.useCallback(f=>{if(a){const l=QA(f)?f(e):f;l!==e&&i.current?.(l)}else s(f)},[a,e,s,i]);return[c,u]}function JA({defaultProp:e,onChange:t}){const[r,n]=b.useState(e),o=b.useRef(r),s=b.useRef(t);return XA(()=>{s.current=t},[t]),b.useEffect(()=>{o.current!==r&&(s.current?.(r),o.current=r)},[r,o]),[r,n,s]}function QA(e){return typeof e=="function"}function hs(e){const t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var $p=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),ZA="VisuallyHidden",eC=b.forwardRef((e,t)=>d.jsx(je.span,{...e,ref:t,style:{...$p,...e.style}}));eC.displayName=ZA;var tC=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ao=new WeakMap,Fi=new WeakMap,Pi={},Rl=0,jp=function(e){return e&&(e.host||jp(e.parentNode))},rC=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=jp(r);return n&&e.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},nC=function(e,t,r,n){var o=rC(t,Array.isArray(e)?e:[e]);Pi[r]||(Pi[r]=new WeakMap);var s=Pi[r],i=[],a=new Set,c=new Set(o),u=function(l){!l||a.has(l)||(a.add(l),u(l.parentNode))};o.forEach(u);var f=function(l){!l||c.has(l)||Array.prototype.forEach.call(l.children,function(p){if(a.has(p))f(p);else try{var g=p.getAttribute(n),m=g!==null&&g!=="false",h=(Ao.get(p)||0)+1,y=(s.get(p)||0)+1;Ao.set(p,h),s.set(p,y),i.push(p),h===1&&m&&Fi.set(p,!0),y===1&&p.setAttribute(r,"true"),m||p.setAttribute(n,"true")}catch(S){console.error("aria-hidden: cannot operate on ",p,S)}})};return f(t),a.clear(),Rl++,function(){i.forEach(function(l){var p=Ao.get(l)-1,g=s.get(l)-1;Ao.set(l,p),s.set(l,g),p||(Fi.has(l)||l.removeAttribute(n),Fi.delete(l)),g||l.removeAttribute(r)}),Rl--,Rl||(Ao=new WeakMap,Ao=new WeakMap,Fi=new WeakMap,Pi={})}},Gl=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),o=tC(e);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live], script"))),nC(n,o,r,"aria-hidden")):function(){return null}},cn=function(){return cn=Object.assign||function(t){for(var r,n=1,o=arguments.length;n<o;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},cn.apply(this,arguments)};function zp(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function oC(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,s;n<o;n++)(s||!(n in t))&&(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Oi="right-scroll-bar-position",Ii="width-before-scroll-bar",sC="with-scroll-bars-hidden",iC="--removed-body-scroll-bar-size";function Kl(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function aC(e,t){var r=v.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(n){var o=r.value;o!==n&&(r.value=n,r.callback(n,o))}}}})[0];return r.callback=t,r.facade}var lC=typeof window<"u"?b.useLayoutEffect:b.useEffect,Up=new WeakMap;function cC(e,t){var r=aC(null,function(n){return e.forEach(function(o){return Kl(o,n)})});return lC(function(){var n=Up.get(r);if(n){var o=new Set(n),s=new Set(e),i=r.current;o.forEach(function(a){s.has(a)||Kl(a,null)}),s.forEach(function(a){o.has(a)||Kl(a,i)})}Up.set(r,e)},[e]),r}function dC(e){return e}function uC(e,t){t===void 0&&(t=dC);var r=[],n=!1,o={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(s){var i=t(s,n);return r.push(i),function(){r=r.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(n=!0;r.length;){var i=r;r=[],i.forEach(s)}r={push:function(a){return s(a)},filter:function(){return r}}},assignMedium:function(s){n=!0;var i=[];if(r.length){var a=r;r=[],a.forEach(s),i=r}var c=function(){var f=i;i=[],f.forEach(s)},u=function(){return Promise.resolve().then(c)};u(),r={push:function(f){i.push(f),u()},filter:function(f){return i=i.filter(f),r}}}};return o}function fC(e){e===void 0&&(e={});var t=uC(null);return t.options=cn({async:!0,ssr:!1},e),t}var Vp=function(e){var t=e.sideCar,r=zp(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=t.read();if(!n)throw new Error("Sidecar medium not found");return b.createElement(n,cn({},r))};Vp.isSideCarExport=!0;function pC(e,t){return e.useMedium(t),Vp}var Hp=fC(),ql=function(){},Mi=b.forwardRef(function(e,t){var r=b.useRef(null),n=b.useState({onScrollCapture:ql,onWheelCapture:ql,onTouchMoveCapture:ql}),o=n[0],s=n[1],i=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,f=e.enabled,l=e.shards,p=e.sideCar,g=e.noRelative,m=e.noIsolation,h=e.inert,y=e.allowPinchZoom,S=e.as,w=S===void 0?"div":S,A=e.gapMode,x=zp(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),F=p,N=cC([r,t]),k=cn(cn({},x),o);return b.createElement(b.Fragment,null,f&&b.createElement(F,{sideCar:Hp,removeScrollBar:u,shards:l,noRelative:g,noIsolation:m,inert:h,setCallbacks:s,allowPinchZoom:!!y,lockRef:r,gapMode:A}),i?b.cloneElement(b.Children.only(a),cn(cn({},k),{ref:N})):b.createElement(w,cn({},k,{className:c,ref:N}),a))});Mi.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Mi.classNames={fullWidth:Ii,zeroRight:Oi};var mC=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function hC(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=mC();return t&&e.setAttribute("nonce",t),e}function gC(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function yC(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var bC=function(){var e=0,t=null;return{add:function(r){e==0&&(t=hC())&&(gC(t,r),yC(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},vC=function(){var e=bC();return function(t,r){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},Wp=function(){var e=vC(),t=function(r){var n=r.styles,o=r.dynamic;return e(n,o),null};return t},wC={left:0,top:0,right:0,gap:0},Yl=function(e){return parseInt(e||"",10)||0},SC=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],n=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Yl(r),Yl(n),Yl(o)]},xC=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return wC;var t=SC(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,n-r+t[2]-t[0])}},AC=Wp(),Co="data-scroll-locked",CC=function(e,t,r,n){var o=e.left,s=e.top,i=e.right,a=e.gap;return r===void 0&&(r="margin"),`
|
|
7
|
+
.`.concat(sC,` {
|
|
8
|
+
overflow: hidden `).concat(n,`;
|
|
9
|
+
padding-right: `).concat(a,"px ").concat(n,`;
|
|
5
10
|
}
|
|
6
|
-
body[`).concat(
|
|
7
|
-
overflow: hidden `).concat(
|
|
11
|
+
body[`).concat(Co,`] {
|
|
12
|
+
overflow: hidden `).concat(n,`;
|
|
8
13
|
overscroll-behavior: contain;
|
|
9
|
-
`).concat([t&&"position: relative ".concat(
|
|
14
|
+
`).concat([t&&"position: relative ".concat(n,";"),r==="margin"&&`
|
|
10
15
|
padding-left: `.concat(o,`px;
|
|
11
|
-
padding-top: `).concat(
|
|
12
|
-
padding-right: `).concat(
|
|
16
|
+
padding-top: `).concat(s,`px;
|
|
17
|
+
padding-right: `).concat(i,`px;
|
|
13
18
|
margin-left:0;
|
|
14
19
|
margin-top:0;
|
|
15
|
-
margin-right: `).concat(a,"px ").concat(
|
|
16
|
-
`),
|
|
20
|
+
margin-right: `).concat(a,"px ").concat(n,`;
|
|
21
|
+
`),r==="padding"&&"padding-right: ".concat(a,"px ").concat(n,";")].filter(Boolean).join(""),`
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
.`).concat(
|
|
20
|
-
right: `).concat(a,"px ").concat(
|
|
24
|
+
.`).concat(Oi,` {
|
|
25
|
+
right: `).concat(a,"px ").concat(n,`;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
.`).concat(
|
|
24
|
-
margin-right: `).concat(a,"px ").concat(
|
|
28
|
+
.`).concat(Ii,` {
|
|
29
|
+
margin-right: `).concat(a,"px ").concat(n,`;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
.`).concat(
|
|
28
|
-
right: 0 `).concat(
|
|
32
|
+
.`).concat(Oi," .").concat(Oi,` {
|
|
33
|
+
right: 0 `).concat(n,`;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
.`).concat(
|
|
32
|
-
margin-right: 0 `).concat(
|
|
36
|
+
.`).concat(Ii," .").concat(Ii,` {
|
|
37
|
+
margin-right: 0 `).concat(n,`;
|
|
33
38
|
}
|
|
34
39
|
|
|
35
|
-
body[`).concat(
|
|
36
|
-
`).concat(
|
|
40
|
+
body[`).concat(Co,`] {
|
|
41
|
+
`).concat(iC,": ").concat(a,`px;
|
|
37
42
|
}
|
|
38
|
-
`)},
|
|
43
|
+
`)},Rp=function(){var e=parseInt(document.body.getAttribute(Co)||"0",10);return isFinite(e)?e:0},EC=function(){b.useEffect(function(){return document.body.setAttribute(Co,(Rp()+1).toString()),function(){var e=Rp()-1;e<=0?document.body.removeAttribute(Co):document.body.setAttribute(Co,e.toString())}},[])},NC=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,o=n===void 0?"margin":n;EC();var s=b.useMemo(function(){return xC(o)},[o]);return b.createElement(AC,{styles:CC(s,!t,o,r?"":"!important")})},Xl=!1;if(typeof window<"u")try{var Li=Object.defineProperty({},"passive",{get:function(){return Xl=!0,!0}});window.addEventListener("test",Li,Li),window.removeEventListener("test",Li,Li)}catch{Xl=!1}var Eo=Xl?{passive:!1}:!1,kC=function(e){return e.tagName==="TEXTAREA"},Gp=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!kC(e)&&r[t]==="visible")},_C=function(e){return Gp(e,"overflowY")},TC=function(e){return Gp(e,"overflowX")},Kp=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var o=qp(e,n);if(o){var s=Yp(e,n),i=s[1],a=s[2];if(i>a)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},FC=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},PC=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},qp=function(e,t){return e==="v"?_C(t):TC(t)},Yp=function(e,t){return e==="v"?FC(t):PC(t)},OC=function(e,t){return e==="h"&&t==="rtl"?-1:1},IC=function(e,t,r,n,o){var s=OC(e,window.getComputedStyle(t).direction),i=s*n,a=r.target,c=t.contains(a),u=!1,f=i>0,l=0,p=0;do{if(!a)break;var g=Yp(e,a),m=g[0],h=g[1],y=g[2],S=h-y-s*m;(m||S)&&qp(e,a)&&(l+=S,p+=m);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(f&&Math.abs(l)<1||!f&&Math.abs(p)<1)&&(u=!0),u},Di=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Xp=function(e){return[e.deltaX,e.deltaY]},Jp=function(e){return e&&"current"in e?e.current:e},MC=function(e,t){return e[0]===t[0]&&e[1]===t[1]},LC=function(e){return`
|
|
39
44
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
40
45
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
41
|
-
`)},X0=0,go=[];function J0(e){var t=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),o=b.useState(X0++)[0],i=b.useState(kf)[0],s=b.useRef(e);b.useEffect(function(){s.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=b0([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!s.current.allowPinchZoom;var w=bs(h),v=n.current,x="deltaX"in h?h.deltaX:v[0]-w[0],C="deltaY"in h?h.deltaY:v[1]-w[1],F,N=h.target,T=Math.abs(x)>Math.abs(C)?"h":"v";if("touches"in h&&T==="h"&&N.type==="range")return!1;var k=window.getSelection(),A=k&&k.anchorNode,O=A?A===N||A.contains(N):!1;if(O)return!1;var E=Ff(T,N);if(!E)return!0;if(E?F=T:(F=T==="v"?"h":"v",E=Ff(T,N)),!E)return!1;if(!r.current&&"changedTouches"in h&&(x||C)&&(r.current=F),!F)return!0;var L=r.current||F;return G0(L,y,h,L==="h"?x:C)},[]),c=b.useCallback(function(h){var y=h;if(!(!go.length||go[go.length-1]!==i)){var w="deltaY"in y?If(y):bs(y),v=t.current.filter(function(F){return F.name===y.type&&(F.target===y.target||y.target===F.shadowParent)&&q0(F.delta,w)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var x=(s.current.shards||[]).map(Mf).filter(Boolean).filter(function(F){return F.contains(y.target)}),C=x.length>0?a(y,x[0]):!s.current.noIsolation;C&&y.cancelable&&y.preventDefault()}}},[]),u=b.useCallback(function(h,y,w,v){var x={name:h,delta:y,target:w,should:v,shadowParent:Q0(w)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(C){return C!==x})},1)},[]),l=b.useCallback(function(h){n.current=bs(h),r.current=void 0},[]),f=b.useCallback(function(h){u(h.type,If(h),h.target,a(h,e.lockRef.current))},[]),p=b.useCallback(function(h){u(h.type,bs(h),h.target,a(h,e.lockRef.current))},[]);b.useEffect(function(){return go.push(i),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",c,ho),document.addEventListener("touchmove",c,ho),document.addEventListener("touchstart",l,ho),function(){go=go.filter(function(h){return h!==i}),document.removeEventListener("wheel",c,ho),document.removeEventListener("touchmove",c,ho),document.removeEventListener("touchstart",l,ho)}},[]);var m=e.removeScrollBar,g=e.inert;return b.createElement(b.Fragment,null,g?b.createElement(i,{styles:Y0(o)}):null,m?b.createElement(z0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Q0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Z0=k0(Nf,J0);var vs=b.forwardRef(function(e,t){return b.createElement(gs,tr({},e,{ref:t,sideCar:Z0}))});vs.classNames=gs.classNames;var ex=[" ","Enter","ArrowUp","ArrowDown"],tx=[" ","Enter"],Rr="Select",[ws,Ss,nx]=Qa(Rr),[yo]=Sn(Rr,[nx,ds]),xs=ds(),[rx,Fr]=yo(Rr),[ox,ix]=yo(Rr),Lf=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:i,value:s,defaultValue:a,onValueChange:c,dir:u,name:l,autoComplete:f,disabled:p,required:m,form:g}=e,h=xs(t),[y,w]=b.useState(null),[v,x]=b.useState(null),[C,F]=b.useState(!1),N=ao(u),[T,k]=er({prop:r,defaultProp:o??!1,onChange:i,caller:Rr}),[A,O]=er({prop:s,defaultProp:a,onChange:c,caller:Rr}),E=b.useRef(null),L=y?g||!!y.closest("form"):!0,[G,I]=b.useState(new Set),$=Array.from(G).map(D=>D.props.value).join(";");return d.jsx(bf,{...h,children:d.jsxs(rx,{required:m,scope:t,trigger:y,onTriggerChange:w,valueNode:v,onValueNodeChange:x,valueNodeHasChildren:C,onValueNodeHasChildrenChange:F,contentId:lr(),value:A,onValueChange:O,open:T,onOpenChange:k,dir:N,triggerPointerDownPosRef:E,disabled:p,children:[d.jsx(ws.Provider,{scope:t,children:d.jsx(ox,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(D=>{I(B=>new Set(B).add(D))},[]),onNativeOptionRemove:b.useCallback(D=>{I(B=>{const M=new Set(B);return M.delete(D),M})},[]),children:n})}),L?d.jsxs(rp,{"aria-hidden":!0,required:m,tabIndex:-1,name:l,autoComplete:f,value:A,onChange:D=>O(D.target.value),disabled:p,form:g,children:[A===void 0?d.jsx("option",{value:""}):null,Array.from(G)]},$):null]})})};Lf.displayName=Rr;var Df="SelectTrigger",Bf=b.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,i=xs(n),s=Fr(Df,n),a=s.disabled||r,c=Ze(t,s.onTriggerChange),u=Ss(n),l=b.useRef("touch"),[f,p,m]=ip(h=>{const y=u().filter(x=>!x.disabled),w=y.find(x=>x.value===s.value),v=sp(y,h,w);v!==void 0&&s.onValueChange(v.value)}),g=h=>{a||(s.onOpenChange(!0),m()),h&&(s.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return d.jsx(bl,{asChild:!0,...i,children:d.jsx($e.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":op(s.value)?"":void 0,...o,ref:c,onClick:Le(o.onClick,h=>{h.currentTarget.focus(),l.current!=="mouse"&&g(h)}),onPointerDown:Le(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:Le(o.onKeyDown,h=>{const y=f.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&p(h.key),!(y&&h.key===" ")&&ex.includes(h.key)&&(g(),h.preventDefault())})})})});Bf.displayName=Df;var $f="SelectValue",jf=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:s="",...a}=e,c=Fr($f,n),{onValueNodeHasChildrenChange:u}=c,l=i!==void 0,f=Ze(t,c.onValueNodeChange);return Zt(()=>{u(l)},[u,l]),d.jsx($e.span,{...a,ref:f,style:{pointerEvents:"none"},children:op(c.value)?d.jsx(d.Fragment,{children:s}):i})});jf.displayName=$f;var sx="SelectIcon",zf=b.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return d.jsx($e.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});zf.displayName=sx;var ax="SelectPortal",Vf=e=>d.jsx(us,{asChild:!0,...e});Vf.displayName=ax;var Kr="SelectContent",Uf=b.forwardRef((e,t)=>{const n=Fr(Kr,e.__scopeSelect),[r,o]=b.useState();if(Zt(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?Oi.createPortal(d.jsx(Hf,{scope:e.__scopeSelect,children:d.jsx(ws.Slot,{scope:e.__scopeSelect,children:d.jsx("div",{children:e.children})})}),i):null}return d.jsx(Wf,{...e,ref:t})});Uf.displayName=Kr;var jn=10,[Hf,Pr]=yo(Kr),lx="SelectContentImpl",cx=o0("SelectContent.RemoveScroll"),Wf=b.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:s,side:a,sideOffset:c,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y,...w}=e,v=Fr(Kr,n),[x,C]=b.useState(null),[F,N]=b.useState(null),T=Ze(t,q=>C(q)),[k,A]=b.useState(null),[O,E]=b.useState(null),L=Ss(n),[G,I]=b.useState(!1),$=b.useRef(!1);b.useEffect(()=>{if(x)return wl(x)},[x]),tl();const D=b.useCallback(q=>{const[re,...Te]=L().map(ge=>ge.ref.current),[Q]=Te.slice(-1),te=document.activeElement;for(const ge of q)if(ge===te||(ge?.scrollIntoView({block:"nearest"}),ge===re&&F&&(F.scrollTop=0),ge===Q&&F&&(F.scrollTop=F.scrollHeight),ge?.focus(),document.activeElement!==te))return},[L,F]),B=b.useCallback(()=>D([k,x]),[D,k,x]);b.useEffect(()=>{G&&B()},[G,B]);const{onOpenChange:M,triggerPointerDownPosRef:W}=v;b.useEffect(()=>{if(x){let q={x:0,y:0};const re=Q=>{q={x:Math.abs(Math.round(Q.pageX)-(W.current?.x??0)),y:Math.abs(Math.round(Q.pageY)-(W.current?.y??0))}},Te=Q=>{q.x<=10&&q.y<=10?Q.preventDefault():x.contains(Q.target)||M(!1),document.removeEventListener("pointermove",re),W.current=null};return W.current!==null&&(document.addEventListener("pointermove",re),document.addEventListener("pointerup",Te,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",re),document.removeEventListener("pointerup",Te,{capture:!0})}}},[x,M,W]),b.useEffect(()=>{const q=()=>M(!1);return window.addEventListener("blur",q),window.addEventListener("resize",q),()=>{window.removeEventListener("blur",q),window.removeEventListener("resize",q)}},[M]);const[j,ie]=ip(q=>{const re=L().filter(te=>!te.disabled),Te=re.find(te=>te.ref.current===document.activeElement),Q=sp(re,q,Te);Q&&setTimeout(()=>Q.ref.current.focus())}),H=b.useCallback((q,re,Te)=>{const Q=!$.current&&!Te;(v.value!==void 0&&v.value===re||Q)&&(A(q),Q&&($.current=!0))},[v.value]),U=b.useCallback(()=>x?.focus(),[x]),J=b.useCallback((q,re,Te)=>{const Q=!$.current&&!Te;(v.value!==void 0&&v.value===re||Q)&&E(q)},[v.value]),de=r==="popper"?El:Rf,ne=de===El?{side:a,sideOffset:c,align:u,alignOffset:l,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:h,avoidCollisions:y}:{};return d.jsx(Hf,{scope:n,content:x,viewport:F,onViewportChange:N,itemRefCallback:H,selectedItem:k,onItemLeave:U,itemTextRefCallback:J,focusSelectedItem:B,selectedItemText:O,position:r,isPositioned:G,searchRef:j,children:d.jsx(vs,{as:cx,allowPinchZoom:!0,children:d.jsx(Zi,{asChild:!0,trapped:v.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:Le(o,q=>{v.trigger?.focus({preventScroll:!0}),q.preventDefault()}),children:d.jsx(Qi,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:q=>q.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:d.jsx(de,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:q=>q.preventDefault(),...w,...ne,onPlaced:()=>I(!0),ref:T,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:Le(w.onKeyDown,q=>{const re=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!re&&q.key.length===1&&ie(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let Q=L().filter(te=>!te.disabled).map(te=>te.ref.current);if(["ArrowUp","End"].includes(q.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const te=q.target,ge=Q.indexOf(te);Q=Q.slice(ge+1)}setTimeout(()=>D(Q)),q.preventDefault()}})})})})})})});Wf.displayName=lx;var dx="SelectItemAlignedPosition",Rf=b.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,i=Fr(Kr,n),s=Pr(Kr,n),[a,c]=b.useState(null),[u,l]=b.useState(null),f=Ze(t,T=>l(T)),p=Ss(n),m=b.useRef(!1),g=b.useRef(!0),{viewport:h,selectedItem:y,selectedItemText:w,focusSelectedItem:v}=s,x=b.useCallback(()=>{if(i.trigger&&i.valueNode&&a&&u&&h&&y&&w){const T=i.trigger.getBoundingClientRect(),k=u.getBoundingClientRect(),A=i.valueNode.getBoundingClientRect(),O=w.getBoundingClientRect();if(i.dir!=="rtl"){const te=O.left-k.left,ge=A.left-te,ce=T.left-ge,Xe=T.width+ce,ye=Math.max(Xe,k.width),Se=window.innerWidth-jn,ae=Qo(ge,[jn,Math.max(jn,Se-ye)]);a.style.minWidth=Xe+"px",a.style.left=ae+"px"}else{const te=k.right-O.right,ge=window.innerWidth-A.right-te,ce=window.innerWidth-T.right-ge,Xe=T.width+ce,ye=Math.max(Xe,k.width),Se=window.innerWidth-jn,ae=Qo(ge,[jn,Math.max(jn,Se-ye)]);a.style.minWidth=Xe+"px",a.style.right=ae+"px"}const E=p(),L=window.innerHeight-jn*2,G=h.scrollHeight,I=window.getComputedStyle(u),$=parseInt(I.borderTopWidth,10),D=parseInt(I.paddingTop,10),B=parseInt(I.borderBottomWidth,10),M=parseInt(I.paddingBottom,10),W=$+D+G+M+B,j=Math.min(y.offsetHeight*5,W),ie=window.getComputedStyle(h),H=parseInt(ie.paddingTop,10),U=parseInt(ie.paddingBottom,10),J=T.top+T.height/2-jn,de=L-J,ne=y.offsetHeight/2,q=y.offsetTop+ne,re=$+D+q,Te=W-re;if(re<=J){const te=E.length>0&&y===E[E.length-1].ref.current;a.style.bottom="0px";const ge=u.clientHeight-h.offsetTop-h.offsetHeight,ce=Math.max(de,ne+(te?U:0)+ge+B),Xe=re+ce;a.style.height=Xe+"px"}else{const te=E.length>0&&y===E[0].ref.current;a.style.top="0px";const ce=Math.max(J,$+h.offsetTop+(te?H:0)+ne)+Te;a.style.height=ce+"px",h.scrollTop=re-J+h.offsetTop}a.style.margin=`${jn}px 0`,a.style.minHeight=j+"px",a.style.maxHeight=L+"px",r?.(),requestAnimationFrame(()=>m.current=!0)}},[p,i.trigger,i.valueNode,a,u,h,y,w,i.dir,r]);Zt(()=>x(),[x]);const[C,F]=b.useState();Zt(()=>{u&&F(window.getComputedStyle(u).zIndex)},[u]);const N=b.useCallback(T=>{T&&g.current===!0&&(x(),v?.(),g.current=!1)},[x,v]);return d.jsx(fx,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:N,children:d.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:C},children:d.jsx($e.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Rf.displayName=dx;var ux="SelectPopperPosition",El=b.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=jn,...i}=e,s=xs(n);return d.jsx(vf,{...s,...i,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...i.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)"}})});El.displayName=ux;var[fx,Nl]=yo(Kr,{}),kl="SelectViewport",Kf=b.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,i=Pr(kl,n),s=Nl(kl,n),a=Ze(t,i.onViewportChange),c=b.useRef(0);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),d.jsx(ws.Slot,{scope:n,children:d.jsx($e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Le(o.onScroll,u=>{const l=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=s;if(p?.current&&f){const m=Math.abs(c.current-l.scrollTop);if(m>0){const g=window.innerHeight-jn*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),C=v-x;f.style.height=x+"px",f.style.bottom==="0px"&&(l.scrollTop=C>0?C:0,f.style.justifyContent="flex-end")}}}c.current=l.scrollTop})})})]})});Kf.displayName=kl;var Gf="SelectGroup",[px,mx]=yo(Gf),hx=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=lr();return d.jsx(px,{scope:n,id:o,children:d.jsx($e.div,{role:"group","aria-labelledby":o,...r,ref:t})})});hx.displayName=Gf;var qf="SelectLabel",gx=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=mx(qf,n);return d.jsx($e.div,{id:o.id,...r,ref:t})});gx.displayName=qf;var As="SelectItem",[yx,Yf]=yo(As),Xf=b.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...s}=e,a=Fr(As,n),c=Pr(As,n),u=a.value===r,[l,f]=b.useState(i??""),[p,m]=b.useState(!1),g=Ze(t,v=>c.itemRefCallback?.(v,r,o)),h=lr(),y=b.useRef("touch"),w=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d.jsx(yx,{scope:n,value:r,disabled:o,textId:h,isSelected:u,onItemTextChange:b.useCallback(v=>{f(x=>x||(v?.textContent??"").trim())},[]),children:d.jsx(ws.ItemSlot,{scope:n,value:r,disabled:o,textValue:l,children:d.jsx($e.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,...s,ref:g,onFocus:Le(s.onFocus,()=>m(!0)),onBlur:Le(s.onBlur,()=>m(!1)),onClick:Le(s.onClick,()=>{y.current!=="mouse"&&w()}),onPointerUp:Le(s.onPointerUp,()=>{y.current==="mouse"&&w()}),onPointerDown:Le(s.onPointerDown,v=>{y.current=v.pointerType}),onPointerMove:Le(s.onPointerMove,v=>{y.current=v.pointerType,o?c.onItemLeave?.():y.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Le(s.onPointerLeave,v=>{v.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Le(s.onKeyDown,v=>{c.searchRef?.current!==""&&v.key===" "||(tx.includes(v.key)&&w(),v.key===" "&&v.preventDefault())})})})})});Xf.displayName=As;var ri="SelectItemText",Jf=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...i}=e,s=Fr(ri,n),a=Pr(ri,n),c=Yf(ri,n),u=ix(ri,n),[l,f]=b.useState(null),p=Ze(t,w=>f(w),c.onItemTextChange,w=>a.itemTextRefCallback?.(w,c.value,c.disabled)),m=l?.textContent,g=b.useMemo(()=>d.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:h,onNativeOptionRemove:y}=u;return Zt(()=>(h(g),()=>y(g)),[h,y,g]),d.jsxs(d.Fragment,{children:[d.jsx($e.span,{id:c.textId,...i,ref:p}),c.isSelected&&s.valueNode&&!s.valueNodeHasChildren?Oi.createPortal(i.children,s.valueNode):null]})});Jf.displayName=ri;var Qf="SelectItemIndicator",Zf=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Yf(Qf,n).isSelected?d.jsx($e.span,{"aria-hidden":!0,...r,ref:t}):null});Zf.displayName=Qf;var _l="SelectScrollUpButton",ep=b.forwardRef((e,t)=>{const n=Pr(_l,e.__scopeSelect),r=Nl(_l,e.__scopeSelect),[o,i]=b.useState(!1),s=Ze(t,r.onScrollButtonChange);return Zt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollTop>0;i(u)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(np,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});ep.displayName=_l;var Tl="SelectScrollDownButton",tp=b.forwardRef((e,t)=>{const n=Pr(Tl,e.__scopeSelect),r=Nl(Tl,e.__scopeSelect),[o,i]=b.useState(!1),s=Ze(t,r.onScrollButtonChange);return Zt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,l=Math.ceil(c.scrollTop)<u;i(l)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(np,{...e,ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});tp.displayName=Tl;var np=b.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,i=Pr("SelectScrollButton",n),s=b.useRef(null),a=Ss(n),c=b.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return b.useEffect(()=>()=>c(),[c]),Zt(()=>{a().find(l=>l.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),d.jsx($e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Le(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:Le(o.onPointerMove,()=>{i.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:Le(o.onPointerLeave,()=>{c()})})}),bx="SelectSeparator",vx=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return d.jsx($e.div,{"aria-hidden":!0,...r,ref:t})});vx.displayName=bx;var Fl="SelectArrow",wx=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=xs(n),i=Fr(Fl,n),s=Pr(Fl,n);return i.open&&s.position==="popper"?d.jsx(wf,{...o,...r,ref:t}):null});wx.displayName=Fl;var Sx="SelectBubbleInput",rp=b.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=b.useRef(null),i=Ze(r,o),s=ni(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,l=Object.getOwnPropertyDescriptor(c,"value").set;if(s!==t&&l){const f=new Event("change",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[s,t]),d.jsx($e.select,{...n,style:{...Sf,...n.style},ref:i,defaultValue:t})});rp.displayName=Sx;function op(e){return e===""||e===void 0}function ip(e){const t=sn(e),n=b.useRef(""),r=b.useRef(0),o=b.useCallback(s=>{const a=n.current+s;t(a),(function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))})(a)},[t]),i=b.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,i]}function sp(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=xx(e,Math.max(i,0));o.length===1&&(s=s.filter(u=>u!==n));const c=s.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function xx(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ax=Lf,Cx=Bf,Ex=jf,Nx=zf,kx=Vf,_x=Uf,Tx=Kf,Fx=Xf,Px=Jf,Ox=Zf,Ix=ep,Mx=tp;function Lx({...e}){return d.jsx(Ax,{"data-slot":"select",...e})}function Dx({className:e,...t}){return d.jsx(Ex,{"data-slot":"select-value",className:z("truncate min-w-0",e),...t})}function Bx({className:e,size:t="default",children:n,...r}){const o=e?.includes("w-full");return d.jsxs(Cx,{"data-slot":"select-trigger","data-size":t,className:z("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),...r,children:[n,d.jsx(Nx,{asChild:!0,children:d.jsx(Yo,{className:"size-4 opacity-50"})})]})}function $x({className:e,children:t,position:n="popper",...r}){return d.jsx(kx,{children:d.jsxs(_x,{"data-slot":"select-content",className:z("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",n==="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:n,...r,children:[d.jsx(jx,{}),d.jsx(Tx,{className:z("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),d.jsx(zx,{})]})})}function Pl({className:e,children:t,...n}){return d.jsxs(Fx,{"data-slot":"select-item",className:z("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),...n,children:[d.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:d.jsx(Ox,{children:d.jsx(Xi,{className:"size-4"})})}),d.jsx(Px,{className:"truncate",children:t})]})}function jx({className:e,...t}){return d.jsx(Ix,{"data-slot":"select-scroll-up-button",className:z("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(sw,{className:"size-4"})})}function zx({className:e,...t}){return d.jsx(Mx,{"data-slot":"select-scroll-down-button",className:z("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(Yo,{className:"size-4"})})}function ap(e,t){return function(){return e.apply(t,arguments)}}const{toString:Vx}=Object.prototype,{getPrototypeOf:Ol}=Object,{iterator:Cs,toStringTag:lp}=Symbol,Es=(e=>t=>{const n=Vx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),zn=e=>(e=e.toLowerCase(),t=>Es(t)===e),Ns=e=>t=>typeof t===e,{isArray:bo}=Array,vo=Ns("undefined");function oi(e){return e!==null&&!vo(e)&&e.constructor!==null&&!vo(e.constructor)&&hn(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const cp=zn("ArrayBuffer");function Ux(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&cp(e.buffer),t}const Hx=Ns("string"),hn=Ns("function"),dp=Ns("number"),ii=e=>e!==null&&typeof e=="object",Wx=e=>e===!0||e===!1,ks=e=>{if(Es(e)!=="object")return!1;const t=Ol(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(lp in e)&&!(Cs in e)},Rx=e=>{if(!ii(e)||oi(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Kx=zn("Date"),Gx=zn("File"),qx=e=>!!(e&&typeof e.uri<"u"),Yx=e=>e&&typeof e.getParts<"u",Xx=zn("Blob"),Jx=zn("FileList"),Qx=e=>ii(e)&&hn(e.pipe);function Zx(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const up=Zx(),fp=typeof up.FormData<"u"?up.FormData:void 0,eA=e=>{let t;return e&&(fp&&e instanceof fp||hn(e.append)&&((t=Es(e))==="formdata"||t==="object"&&hn(e.toString)&&e.toString()==="[object FormData]"))},tA=zn("URLSearchParams"),[nA,rA,oA,iA]=["ReadableStream","Request","Response","Headers"].map(zn),sA=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function si(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),bo(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(oi(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length;let a;for(r=0;r<s;r++)a=i[r],t.call(null,e[a],a,e)}}function pp(e,t){if(oi(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Gr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,mp=e=>!vo(e)&&e!==Gr;function Il(){const{caseless:e,skipUndefined:t}=mp(this)&&this||{},n={},r=(o,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const s=e&&pp(n,i)||i;ks(n[s])&&ks(o)?n[s]=Il(n[s],o):ks(o)?n[s]=Il({},o):bo(o)?n[s]=o.slice():(!t||!vo(o))&&(n[s]=o)};for(let o=0,i=arguments.length;o<i;o++)arguments[o]&&si(arguments[o],r);return n}const aA=(e,t,n,{allOwnKeys:r}={})=>(si(t,(o,i)=>{n&&hn(o)?Object.defineProperty(e,i,{value:ap(o,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),lA=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),cA=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},dA=(e,t,n,r)=>{let o,i,s;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],(!r||r(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=n!==!1&&Ol(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},uA=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},fA=e=>{if(!e)return null;if(bo(e))return e;let t=e.length;if(!dp(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},pA=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ol(Uint8Array)),mA=(e,t)=>{const r=(e&&e[Cs]).call(e);let o;for(;(o=r.next())&&!o.done;){const i=o.value;t.call(e,i[0],i[1])}},hA=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},gA=zn("HTMLFormElement"),yA=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),hp=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),bA=zn("RegExp"),gp=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};si(n,(o,i)=>{let s;(s=t(o,i,e))!==!1&&(r[i]=s||o)}),Object.defineProperties(e,r)},vA=e=>{gp(e,(t,n)=>{if(hn(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(hn(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},wA=(e,t)=>{const n={},r=o=>{o.forEach(i=>{n[i]=!0})};return bo(e)?r(e):r(String(e).split(t)),n},SA=()=>{},xA=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function AA(e){return!!(e&&hn(e.append)&&e[lp]==="FormData"&&e[Cs])}const CA=e=>{const t=new Array(10),n=(r,o)=>{if(ii(r)){if(t.indexOf(r)>=0)return;if(oi(r))return r;if(!("toJSON"in r)){t[o]=r;const i=bo(r)?[]:{};return si(r,(s,a)=>{const c=n(s,o+1);!vo(c)&&(i[a]=c)}),t[o]=void 0,i}}return r};return n(e,0)},EA=zn("AsyncFunction"),NA=e=>e&&(ii(e)||hn(e))&&hn(e.then)&&hn(e.catch),yp=((e,t)=>e?setImmediate:t?((n,r)=>(Gr.addEventListener("message",({source:o,data:i})=>{o===Gr&&i===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Gr.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",hn(Gr.postMessage)),kA=typeof queueMicrotask<"u"?queueMicrotask.bind(Gr):typeof process<"u"&&process.nextTick||yp,K={isArray:bo,isArrayBuffer:cp,isBuffer:oi,isFormData:eA,isArrayBufferView:Ux,isString:Hx,isNumber:dp,isBoolean:Wx,isObject:ii,isPlainObject:ks,isEmptyObject:Rx,isReadableStream:nA,isRequest:rA,isResponse:oA,isHeaders:iA,isUndefined:vo,isDate:Kx,isFile:Gx,isReactNativeBlob:qx,isReactNative:Yx,isBlob:Xx,isRegExp:bA,isFunction:hn,isStream:Qx,isURLSearchParams:tA,isTypedArray:pA,isFileList:Jx,forEach:si,merge:Il,extend:aA,trim:sA,stripBOM:lA,inherits:cA,toFlatObject:dA,kindOf:Es,kindOfTest:zn,endsWith:uA,toArray:fA,forEachEntry:mA,matchAll:hA,isHTMLForm:gA,hasOwnProperty:hp,hasOwnProp:hp,reduceDescriptors:gp,freezeMethods:vA,toObjectSet:wA,toCamelCase:yA,noop:SA,toFiniteNumber:xA,findKey:pp,global:Gr,isContextDefined:mp,isSpecCompliantForm:AA,toJSONObject:CA,isAsyncFn:EA,isThenable:NA,setImmediate:yp,asap:kA,isIterable:e=>e!=null&&hn(e[Cs])};let Ye=class rb extends Error{static from(t,n,r,o,i,s){const a=new rb(t.message,n||t.code,r,o,i);return a.cause=t,a.name=t.name,t.status!=null&&a.status==null&&(a.status=t.status),s&&Object.assign(a,s),a}constructor(t,n,r,o,i){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),o&&(this.request=o),i&&(this.response=i,this.status=i.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:K.toJSONObject(this.config),code:this.code,status:this.status}}};Ye.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Ye.ERR_BAD_OPTION="ERR_BAD_OPTION",Ye.ECONNABORTED="ECONNABORTED",Ye.ETIMEDOUT="ETIMEDOUT",Ye.ERR_NETWORK="ERR_NETWORK",Ye.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Ye.ERR_DEPRECATED="ERR_DEPRECATED",Ye.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Ye.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Ye.ERR_CANCELED="ERR_CANCELED",Ye.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Ye.ERR_INVALID_URL="ERR_INVALID_URL";const _A=null;function Ml(e){return K.isPlainObject(e)||K.isArray(e)}function bp(e){return K.endsWith(e,"[]")?e.slice(0,-2):e}function Ll(e,t,n){return e?e.concat(t).map(function(o,i){return o=bp(o),!n&&i?"["+o+"]":o}).join(n?".":""):t}function TA(e){return K.isArray(e)&&!e.some(Ml)}const FA=K.toFlatObject(K,{},null,function(t){return/^is[A-Z]/.test(t)});function _s(e,t,n){if(!K.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=K.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,y){return!K.isUndefined(y[h])});const r=n.metaTokens,o=n.visitor||l,i=n.dots,s=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&K.isSpecCompliantForm(t);if(!K.isFunction(o))throw new TypeError("visitor must be a function");function u(g){if(g===null)return"";if(K.isDate(g))return g.toISOString();if(K.isBoolean(g))return g.toString();if(!c&&K.isBlob(g))throw new Ye("Blob is not supported. Use a Buffer instead.");return K.isArrayBuffer(g)||K.isTypedArray(g)?c&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function l(g,h,y){let w=g;if(K.isReactNative(t)&&K.isReactNativeBlob(g))return t.append(Ll(y,h,i),u(g)),!1;if(g&&!y&&typeof g=="object"){if(K.endsWith(h,"{}"))h=r?h:h.slice(0,-2),g=JSON.stringify(g);else if(K.isArray(g)&&TA(g)||(K.isFileList(g)||K.endsWith(h,"[]"))&&(w=K.toArray(g)))return h=bp(h),w.forEach(function(x,C){!(K.isUndefined(x)||x===null)&&t.append(s===!0?Ll([h],C,i):s===null?h:h+"[]",u(x))}),!1}return Ml(g)?!0:(t.append(Ll(y,h,i),u(g)),!1)}const f=[],p=Object.assign(FA,{defaultVisitor:l,convertValue:u,isVisitable:Ml});function m(g,h){if(!K.isUndefined(g)){if(f.indexOf(g)!==-1)throw Error("Circular reference detected in "+h.join("."));f.push(g),K.forEach(g,function(w,v){(!(K.isUndefined(w)||w===null)&&o.call(t,w,K.isString(v)?v.trim():v,h,p))===!0&&m(w,h?h.concat(v):[v])}),f.pop()}}if(!K.isObject(e))throw new TypeError("data must be an object");return m(e),t}function vp(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Dl(e,t){this._pairs=[],e&&_s(e,this,t)}const wp=Dl.prototype;wp.append=function(t,n){this._pairs.push([t,n])},wp.toString=function(t){const n=t?function(r){return t.call(this,r,vp)}:vp;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function PA(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Sp(e,t,n){if(!t)return e;const r=n&&n.encode||PA,o=K.isFunction(n)?{serialize:n}:n,i=o&&o.serialize;let s;if(i?s=i(t,o):s=K.isURLSearchParams(t)?t.toString():new Dl(t,o).toString(r),s){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class xp{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){K.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Bl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},OA={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Dl,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},$l=typeof window<"u"&&typeof document<"u",jl=typeof navigator=="object"&&navigator||void 0,IA=$l&&(!jl||["ReactNative","NativeScript","NS"].indexOf(jl.product)<0),MA=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",LA=$l&&window.location.href||"http://localhost",on={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:$l,hasStandardBrowserEnv:IA,hasStandardBrowserWebWorkerEnv:MA,navigator:jl,origin:LA},Symbol.toStringTag,{value:"Module"})),...OA};function DA(e,t){return _s(e,new on.classes.URLSearchParams,{visitor:function(n,r,o,i){return on.isNode&&K.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function BA(e){return K.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function $A(e){const t={},n=Object.keys(e);let r;const o=n.length;let i;for(r=0;r<o;r++)i=n[r],t[i]=e[i];return t}function Ap(e){function t(n,r,o,i){let s=n[i++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),c=i>=n.length;return s=!s&&K.isArray(o)?o.length:s,c?(K.hasOwnProp(o,s)?o[s]=[o[s],r]:o[s]=r,!a):((!o[s]||!K.isObject(o[s]))&&(o[s]=[]),t(n,r,o[s],i)&&K.isArray(o[s])&&(o[s]=$A(o[s])),!a)}if(K.isFormData(e)&&K.isFunction(e.entries)){const n={};return K.forEachEntry(e,(r,o)=>{t(BA(r),o,n,0)}),n}return null}function jA(e,t,n){if(K.isString(e))try{return(t||JSON.parse)(e),K.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const ai={transitional:Bl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,i=K.isObject(t);if(i&&K.isHTMLForm(t)&&(t=new FormData(t)),K.isFormData(t))return o?JSON.stringify(Ap(t)):t;if(K.isArrayBuffer(t)||K.isBuffer(t)||K.isStream(t)||K.isFile(t)||K.isBlob(t)||K.isReadableStream(t))return t;if(K.isArrayBufferView(t))return t.buffer;if(K.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return DA(t,this.formSerializer).toString();if((a=K.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return _s(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return i||o?(n.setContentType("application/json",!1),jA(t)):t}],transformResponse:[function(t){const n=this.transitional||ai.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(K.isResponse(t)||K.isReadableStream(t))return t;if(t&&K.isString(t)&&(r&&!this.responseType||o)){const s=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(s)throw a.name==="SyntaxError"?Ye.from(a,Ye.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:on.classes.FormData,Blob:on.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};K.forEach(["delete","get","head","post","put","patch"],e=>{ai.headers[e]={}});const zA=K.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"]),VA=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
42
|
-
`).forEach(function(s){o=s.indexOf(":"),n=s.substring(0,o).trim().toLowerCase(),r=s.substring(o+1).trim(),!(!n||t[n]&&zA[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Cp=Symbol("internals");function li(e){return e&&String(e).trim().toLowerCase()}function Ts(e){return e===!1||e==null?e:K.isArray(e)?e.map(Ts):String(e).replace(/[\r\n]+$/,"")}function UA(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const HA=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function zl(e,t,n,r,o){if(K.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!K.isString(t)){if(K.isString(r))return t.indexOf(r)!==-1;if(K.isRegExp(r))return r.test(t)}}function WA(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function RA(e,t){const n=K.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,i,s){return this[r].call(this,t,o,i,s)},configurable:!0})})}let gn=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function i(a,c,u){const l=li(c);if(!l)throw new Error("header name must be a non-empty string");const f=K.findKey(o,l);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||c]=Ts(a))}const s=(a,c)=>K.forEach(a,(u,l)=>i(u,l,c));if(K.isPlainObject(t)||t instanceof this.constructor)s(t,n);else if(K.isString(t)&&(t=t.trim())&&!HA(t))s(VA(t),n);else if(K.isObject(t)&&K.isIterable(t)){let a={},c,u;for(const l of t){if(!K.isArray(l))throw TypeError("Object iterator must return a key-value pair");a[u=l[0]]=(c=a[u])?K.isArray(c)?[...c,l[1]]:[c,l[1]]:l[1]}s(a,n)}else t!=null&&i(n,t,r);return this}get(t,n){if(t=li(t),t){const r=K.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return UA(o);if(K.isFunction(n))return n.call(this,o,r);if(K.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=li(t),t){const r=K.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||zl(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function i(s){if(s=li(s),s){const a=K.findKey(r,s);a&&(!n||zl(r,r[a],a,n))&&(delete r[a],o=!0)}}return K.isArray(t)?t.forEach(i):i(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const i=n[r];(!t||zl(this,this[i],i,t,!0))&&(delete this[i],o=!0)}return o}normalize(t){const n=this,r={};return K.forEach(this,(o,i)=>{const s=K.findKey(r,i);if(s){n[s]=Ts(o),delete n[i];return}const a=t?WA(i):String(i).trim();a!==i&&delete n[i],n[a]=Ts(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return K.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&K.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).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,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Cp]=this[Cp]={accessors:{}}).accessors,o=this.prototype;function i(s){const a=li(s);r[a]||(RA(o,s),r[a]=!0)}return K.isArray(t)?t.forEach(i):i(t),this}};gn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),K.reduceDescriptors(gn.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),K.freezeMethods(gn);function Vl(e,t){const n=this||ai,r=t||n,o=gn.from(r.headers);let i=r.data;return K.forEach(e,function(a){i=a.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function Ep(e){return!!(e&&e.__CANCEL__)}let ci=class extends Ye{constructor(t,n,r){super(t??"canceled",Ye.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function Np(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ye("Request failed with status code "+n.status,[Ye.ERR_BAD_REQUEST,Ye.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function KA(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function GA(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,i=0,s;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),l=r[i];s||(s=u),n[o]=c,r[o]=u;let f=i,p=0;for(;f!==o;)p+=n[f++],f=f%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),u-s<t)return;const m=l&&u-l;return m?Math.round(p*1e3/m):void 0}}function qA(e,t){let n=0,r=1e3/t,o,i;const s=(u,l=Date.now())=>{n=l,o=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{const l=Date.now(),f=l-n;f>=r?s(u,l):(o=u,i||(i=setTimeout(()=>{i=null,s(o)},r-f)))},()=>o&&s(o)]}const Fs=(e,t,n=3)=>{let r=0;const o=GA(50,250);return qA(i=>{const s=i.loaded,a=i.lengthComputable?i.total:void 0,c=s-r,u=o(c),l=s<=a;r=s;const f={loaded:s,total:a,progress:a?s/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&l?(a-s)/u:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},kp=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},_p=e=>(...t)=>K.asap(()=>e(...t)),YA=on.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,on.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(on.origin),on.navigator&&/(msie|trident)/i.test(on.navigator.userAgent)):()=>!0,XA=on.hasStandardBrowserEnv?{write(e,t,n,r,o,i,s){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];K.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),K.isString(r)&&a.push(`path=${r}`),K.isString(o)&&a.push(`domain=${o}`),i===!0&&a.push("secure"),K.isString(s)&&a.push(`SameSite=${s}`),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 JA(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function QA(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Tp(e,t,n){let r=!JA(t);return e&&(r||n==!1)?QA(e,t):t}const Fp=e=>e instanceof gn?{...e}:e;function qr(e,t){t=t||{};const n={};function r(u,l,f,p){return K.isPlainObject(u)&&K.isPlainObject(l)?K.merge.call({caseless:p},u,l):K.isPlainObject(l)?K.merge({},l):K.isArray(l)?l.slice():l}function o(u,l,f,p){if(K.isUndefined(l)){if(!K.isUndefined(u))return r(void 0,u,f,p)}else return r(u,l,f,p)}function i(u,l){if(!K.isUndefined(l))return r(void 0,l)}function s(u,l){if(K.isUndefined(l)){if(!K.isUndefined(u))return r(void 0,u)}else return r(void 0,l)}function a(u,l,f){if(f in t)return r(u,l);if(f in e)return r(void 0,u)}const c={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(u,l,f)=>o(Fp(u),Fp(l),f,!0)};return K.forEach(Object.keys({...e,...t}),function(l){if(l==="__proto__"||l==="constructor"||l==="prototype")return;const f=K.hasOwnProp(c,l)?c[l]:o,p=f(e[l],t[l],l);K.isUndefined(p)&&f!==a||(n[l]=p)}),n}const Pp=e=>{const t=qr({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:i,headers:s,auth:a}=t;if(t.headers=s=gn.from(s),t.url=Sp(Tp(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),K.isFormData(n)){if(on.hasStandardBrowserEnv||on.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(K.isFunction(n.getHeaders)){const c=n.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([l,f])=>{u.includes(l.toLowerCase())&&s.set(l,f)})}}if(on.hasStandardBrowserEnv&&(r&&K.isFunction(r)&&(r=r(t)),r||r!==!1&&YA(t.url))){const c=o&&i&&XA.read(i);c&&s.set(o,c)}return t},ZA=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Pp(e);let i=o.data;const s=gn.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,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=gn.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),F={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:x,config:e,request:y};Np(function(T){n(T),h()},function(T){r(T),h()},F),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&&(r(new Ye("Request aborted",Ye.ECONNABORTED,e,y)),y=null)},y.onerror=function(C){const F=C&&C.message?C.message:"Network Error",N=new Ye(F,Ye.ERR_NETWORK,e,y);N.event=C||null,r(N),y=null},y.ontimeout=function(){let C=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const F=o.transitional||Bl;o.timeoutErrorMessage&&(C=o.timeoutErrorMessage),r(new Ye(C,F.clarifyTimeoutError?Ye.ETIMEDOUT:Ye.ECONNABORTED,e,y)),y=null},i===void 0&&s.setContentType(null),"setRequestHeader"in y&&K.forEach(s.toJSON(),function(C,F){y.setRequestHeader(F,C)}),K.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),u&&([p,g]=Fs(u,!0),y.addEventListener("progress",p)),c&&y.upload&&([f,m]=Fs(c),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(l=x=>{y&&(r(!x||x.type?new ci(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=KA(o.url);if(v&&on.protocols.indexOf(v)===-1){r(new Ye("Unsupported protocol "+v+":",Ye.ERR_BAD_REQUEST,e));return}y.send(i||null)})},eC=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const i=function(u){if(!o){o=!0,a();const l=u instanceof Error?u:this.reason;r.abort(l instanceof Ye?l:new ci(l instanceof Error?l.message:l))}};let s=t&&setTimeout(()=>{s=null,i(new Ye(`timeout of ${t}ms exceeded`,Ye.ETIMEDOUT))},t);const a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),e=null)};e.forEach(u=>u.addEventListener("abort",i));const{signal:c}=r;return c.unsubscribe=()=>K.asap(a),c}},tC=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},nC=async function*(e,t){for await(const n of rC(e))yield*tC(n,t)},rC=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Op=(e,t,n,r)=>{const o=nC(e,t);let i=0,s,a=c=>{s||(s=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:u,value:l}=await o.next();if(u){a(),c.close();return}let f=l.byteLength;if(n){let p=i+=f;n(p)}c.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},Ip=64*1024,{isFunction:Ps}=K,oC=(({Request:e,Response:t})=>({Request:e,Response:t}))(K.global),{ReadableStream:Mp,TextEncoder:Lp}=K.global,Dp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},iC=e=>{e=K.merge.call({skipUndefined:!0},oC,e);const{fetch:t,Request:n,Response:r}=e,o=t?Ps(t):typeof fetch=="function",i=Ps(n),s=Ps(r);if(!o)return!1;const a=o&&Ps(Mp),c=o&&(typeof Lp=="function"?(g=>h=>g.encode(h))(new Lp):async g=>new Uint8Array(await new n(g).arrayBuffer())),u=i&&a&&Dp(()=>{let g=!1;const h=new Mp,y=new n(on.origin,{body:h,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return h.cancel(),g&&!y}),l=s&&a&&Dp(()=>K.isReadableStream(new r("").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 Ye(`Response type '${g}' is not supported`,Ye.ERR_NOT_SUPPORT,y)})});const p=async g=>{if(g==null)return 0;if(K.isBlob(g))return g.size;if(K.isSpecCompliantForm(g))return(await new n(on.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(K.isArrayBufferView(g)||K.isArrayBuffer(g))return g.byteLength;if(K.isURLSearchParams(g)&&(g=g+""),K.isString(g))return(await c(g)).byteLength},m=async(g,h)=>{const y=K.toFiniteNumber(g.getContentLength());return y??p(h)};return async g=>{let{url:h,method:y,data:w,signal:v,cancelToken:x,timeout:C,onDownloadProgress:F,onUploadProgress:N,responseType:T,headers:k,withCredentials:A="same-origin",fetchOptions:O}=Pp(g),E=t||fetch;T=T?(T+"").toLowerCase():"text";let L=eC([v,x&&x.toAbortSignal()],C),G=null;const I=L&&L.unsubscribe&&(()=>{L.unsubscribe()});let $;try{if(N&&u&&y!=="get"&&y!=="head"&&($=await m(k,w))!==0){let ie=new n(h,{method:"POST",body:w,duplex:"half"}),H;if(K.isFormData(w)&&(H=ie.headers.get("content-type"))&&k.setContentType(H),ie.body){const[U,J]=kp($,Fs(_p(N)));w=Op(ie.body,Ip,U,J)}}K.isString(A)||(A=A?"include":"omit");const D=i&&"credentials"in n.prototype,B={...O,signal:L,method:y.toUpperCase(),headers:k.normalize().toJSON(),body:w,duplex:"half",credentials:D?A:void 0};G=i&&new n(h,B);let M=await(i?E(G,O):E(h,B));const W=l&&(T==="stream"||T==="response");if(l&&(F||W&&I)){const ie={};["status","statusText","headers"].forEach(de=>{ie[de]=M[de]});const H=K.toFiniteNumber(M.headers.get("content-length")),[U,J]=F&&kp(H,Fs(_p(F),!0))||[];M=new r(Op(M.body,Ip,U,()=>{J&&J(),I&&I()}),ie)}T=T||"text";let j=await f[K.findKey(f,T)||"text"](M,g);return!W&&I&&I(),await new Promise((ie,H)=>{Np(ie,H,{data:j,headers:gn.from(M.headers),status:M.status,statusText:M.statusText,config:g,request:G})})}catch(D){throw I&&I(),D&&D.name==="TypeError"&&/Load failed|fetch/i.test(D.message)?Object.assign(new Ye("Network Error",Ye.ERR_NETWORK,g,G,D&&D.response),{cause:D.cause||D}):Ye.from(D,D&&D.code,g,G,D&&D.response)}}},sC=new Map,Bp=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:o}=t,i=[r,o,n];let s=i.length,a=s,c,u,l=sC;for(;a--;)c=i[a],u=l.get(c),u===void 0&&l.set(c,u=a?new Map:iC(t)),l=u;return u};Bp();const Ul={http:_A,xhr:ZA,fetch:{get:Bp}};K.forEach(Ul,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const $p=e=>`- ${e}`,aC=e=>K.isFunction(e)||e===null||e===!1;function lC(e,t){e=K.isArray(e)?e:[e];const{length:n}=e;let r,o;const i={};for(let s=0;s<n;s++){r=e[s];let a;if(o=r,!aC(r)&&(o=Ul[(a=String(r)).toLowerCase()],o===void 0))throw new Ye(`Unknown adapter '${a}'`);if(o&&(K.isFunction(o)||(o=o.get(t))))break;i[a||"#"+s]=o}if(!o){const s=Object.entries(i).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?s.length>1?`since :
|
|
44
|
-
`+s.map($p).join(`
|
|
45
|
-
`):" "+$p(s[0]):"as no adapter specified";throw new Ye("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o}const jp={getAdapter:lC,adapters:Ul};function Hl(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ci(null,e)}function zp(e){return Hl(e),e.headers=gn.from(e.headers),e.data=Vl.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),jp.getAdapter(e.adapter||ai.adapter,e)(e).then(function(r){return Hl(e),r.data=Vl.call(e,e.transformResponse,r),r.headers=gn.from(r.headers),r},function(r){return Ep(r)||(Hl(e),r&&r.response&&(r.response.data=Vl.call(e,e.transformResponse,r.response),r.response.headers=gn.from(r.response.headers))),Promise.reject(r)})}const Vp="1.14.0",Os={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Os[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Up={};Os.transitional=function(t,n,r){function o(i,s){return"[Axios v"+Vp+"] Transitional option '"+i+"'"+s+(r?". "+r:"")}return(i,s,a)=>{if(t===!1)throw new Ye(o(s," has been removed"+(n?" in "+n:"")),Ye.ERR_DEPRECATED);return n&&!Up[s]&&(Up[s]=!0,console.warn(o(s," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,s,a):!0}},Os.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function cC(e,t,n){if(typeof e!="object")throw new Ye("options must be an object",Ye.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],s=t[i];if(s){const a=e[i],c=a===void 0||s(a,i,e);if(c!==!0)throw new Ye("option "+i+" must be "+c,Ye.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ye("Unknown option "+i,Ye.ERR_BAD_OPTION)}}const Is={assertOptions:cC,validators:Os},Tn=Is.validators;let Yr=class{constructor(t){this.defaults=t||{},this.interceptors={request:new xp,response:new xp}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const i=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
46
|
-
`+i):r.stack=i}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=qr(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:i}=n;r!==void 0&&Is.assertOptions(r,{silentJSONParsing:Tn.transitional(Tn.boolean),forcedJSONParsing:Tn.transitional(Tn.boolean),clarifyTimeoutError:Tn.transitional(Tn.boolean),legacyInterceptorReqResOrdering:Tn.transitional(Tn.boolean)},!1),o!=null&&(K.isFunction(o)?n.paramsSerializer={serialize:o}:Is.assertOptions(o,{encode:Tn.function,serialize:Tn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Is.assertOptions(n,{baseUrl:Tn.spelling("baseURL"),withXsrfToken:Tn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let s=i&&K.merge(i.common,i[n.method]);i&&K.forEach(["delete","get","head","post","put","patch","common"],g=>{delete i[g]}),n.headers=gn.concat(s,i);const a=[];let c=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(n)===!1)return;c=c&&h.synchronous;const y=n.transitional||Bl;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(!c){const g=[zp.bind(this),void 0];for(g.unshift(...a),g.push(...u),p=g.length,l=Promise.resolve(n);f<p;)l=l.then(g[f++],g[f++]);return l}p=a.length;let m=n;for(;f<p;){const g=a[f++],h=a[f++];try{m=g(m)}catch(y){h.call(this,y);break}}try{l=zp.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=qr(this.defaults,t);const n=Tp(t.baseURL,t.url,t.allowAbsoluteUrls);return Sp(n,t.params,t.paramsSerializer)}};K.forEach(["delete","get","head","options"],function(t){Yr.prototype[t]=function(n,r){return this.request(qr(r||{},{method:t,url:n,data:(r||{}).data}))}}),K.forEach(["post","put","patch"],function(t){function n(r){return function(i,s,a){return this.request(qr(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}Yr.prototype[t]=n(),Yr.prototype[t+"Form"]=n(!0)});let dC=class ob{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(o=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](o);r._listeners=null}),this.promise.then=o=>{let i;const s=new Promise(a=>{r.subscribe(a),i=a}).then(o);return s.cancel=function(){r.unsubscribe(i)},s},t(function(i,s,a){r.reason||(r.reason=new ci(i,s,a),n(r.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 n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new ob(function(o){t=o}),cancel:t}}};function uC(e){return function(n){return e.apply(null,n)}}function fC(e){return K.isObject(e)&&e.isAxiosError===!0}const Wl={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(Wl).forEach(([e,t])=>{Wl[t]=e});function Hp(e){const t=new Yr(e),n=ap(Yr.prototype.request,t);return K.extend(n,Yr.prototype,t,{allOwnKeys:!0}),K.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Hp(qr(e,o))},n}const St=Hp(ai);St.Axios=Yr,St.CanceledError=ci,St.CancelToken=dC,St.isCancel=Ep,St.VERSION=Vp,St.toFormData=_s,St.AxiosError=Ye,St.Cancel=St.CanceledError,St.all=function(t){return Promise.all(t)},St.spread=uC,St.isAxiosError=fC,St.mergeConfig=qr,St.AxiosHeaders=gn,St.formToJSON=e=>Ap(K.isHTMLForm(e)?new FormData(e):e),St.getAdapter=jp.getAdapter,St.HttpStatusCode=Wl,St.default=St;const{Axios:jO,AxiosError:pC,CanceledError:zO,isCancel:VO,CancelToken:UO,VERSION:HO,all:WO,Cancel:RO,isAxiosError:KO,spread:GO,toFormData:qO,AxiosHeaders:YO,HttpStatusCode:XO,formToJSON:JO,getAdapter:QO,mergeConfig:ZO}=St;function jt(e,t){if(!t||t.trim()===""||e==null)return;const n=t.split(".").filter(Boolean);let r=e;for(const o of n){if(r==null)return;r=r[o]}return r}function Wp(e){const t={array:[],pathPrefixToStrip:""};function n(a,c){if(a===null||typeof a!="object")return null;if(Array.isArray(a)&&a.length>0)return{array:a,fullPath:c};const u=Object.keys(a);for(const l of u){const f=a[l],p=c?`${c}.${l}`:l;if(Array.isArray(f)&&f.length>0)return{array:f,fullPath:p};if(f!==null&&typeof f=="object"){const m=n(f,p);if(m)return m}}return null}const r=n(e,"");if(!r)return t;const{array:o,fullPath:i}=r,s=i?`data.${i}.`:"";return{array:o,pathPrefixToStrip:s}}function mC(e){return e.length>=4&&Array.isArray(e[3])&&e[3].length===0}function hC(e,t,n){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"){const i=String(e);return{label:i,value:i,disabled:!1}}if(e==null)return{label:"",value:"",disabled:!0};if(typeof e!="object"||Array.isArray(e)){const i=Array.isArray(e)?"":String(e);return{label:i,value:i,disabled:!1}}let r,o;if(t){const i=t.includes(".")?jt(e,t):e[t];r=String(i!==void 0?i:e.label??e.name??e.title??e.text??e.username??e.email??e.value??e.id??"")}else r=String(e.label??e.name??e.title??e.text??e.username??e.email??e.value??e.id??"");if(n){const i=n.includes(".")?jt(e,n):e[n];o=String(i!==void 0?i: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(r??""),value:String(o??""),disabled:!!e.disabled}}function di(e,t,n){if(!e)return[];if(Array.isArray(e)){if(e.length===0)return[];if(mC(e))return[];const r=e.filter(o=>o!=null);return r.length===0?[]:r.every(o=>typeof o=="string")?r.map(o=>({label:o,value:o,disabled:!1})):r.map(o=>hC(o,t,n))}if(typeof e=="object"){const{array:r,pathPrefixToStrip:o}=Wp(e);if(Array.isArray(r)&&r.length>0){const i=c=>!c||!c.trim()||!o?c:c.startsWith(o)?c.substring(o.length).replace(/^\.+/,"")||void 0:c,s=i(t),a=i(n);return di(r,s,a)}}return[]}function gC(e){return!Array.isArray(e)||e.length===0?[]:e.filter(t=>t!=null).map((t,n)=>{if(typeof t=="string")return{label:t,value:t};if(typeof t=="object"&&t!==null){const r=t.label||t.value||String(t),o=t.value||t.label||String(t);return!r&&!o?{label:`Option ${n+1}`,value:String(n)}:{label:String(r),value:String(o),disabled:t.disabled||!1}}return{label:String(t),value:String(t)}})}function yC(e){return Array.isArray(e)&&e.length>=4&&Array.isArray(e[3])&&e[3].length>0&&Array.isArray(e[3][0])}function bC(e,t,n){if(!e)return[];try{const o=new URL(e).searchParams.get(t);return o?o.split(n).map(i=>i.trim()).filter(Boolean):[]}catch{const r=e.indexOf("?");if(r<0)return[];const o=e.slice(r+1);try{const s=new URLSearchParams(o).get(t);return s?s.split(n).map(a=>a.trim()).filter(Boolean):[]}catch{return[]}}}function Rp(e){const{response:t,sourceUrl:n,rowsIndex:r,rowsPath:o,columns:i,columnsQueryParam:s="sf",columnsQueryParamSeparator:a=","}=e;let c;if(o&&o.trim()?c=jt(t,o):typeof r=="number"?c=t?.[r]:c=t,!Array.isArray(c)||c.length===0)return[];const u=c.filter(p=>Array.isArray(p));if(u.length===0)return Array.isArray(c[0])?[]:null;if(!Array.isArray(u[0]))return null;const l=bC(n,s,a),f=l.length>0?l:Array.isArray(i)&&i.length>0?i:[];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 vC(e){const{rows:t,apiLabelField:n,apiLabelFields:r,apiLabelSeparator:o,apiValueField:i}=e;if(!Array.isArray(t)||t.length===0)return[];const s=t.filter(f=>f!=null&&typeof f=="object"&&!Array.isArray(f));if(s.length===0)return[];const a=Array.isArray(r)?r.filter(Boolean):[],c=o??" - ",u=f=>{if(n){const p=n.includes(".")?jt(f,n):f?.[n];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(i){const m=i.includes(".")?jt(f,i):f?.[i];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 s.map(f=>{let p="";a.length>0&&(p=a.map(h=>jt(f,h)).filter(h=>h!=null&&String(h).trim()!=="").map(h=>String(h)).join(c)),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}})}function Kp(e){return e!=null&&!Array.isArray(e)&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean")}function wC(e,t){const{array:n,pathPrefixToStrip:r}=Wp(e);if(!Array.isArray(n)||n.length===0)return null;const o=new Set([t]);r&&t.startsWith(r)&&o.add(t.slice(r.length).replace(/^\.+/,""));const i=t.match(/^data\.data\.(.+)$/);i?.[1]&&o.add(i[1]);const s=n[0];for(const a of o){if(!a)continue;const c=a.includes(".")?jt(s,a):s?.[a];if(Kp(c))return String(c)}return null}function SC(e,t,n){if(e==null)return null;const r=t?.trim(),o=n?.trim()||r;if(!r&&!o)return null;if(r){const s=jt(e,r);if(Kp(s))return String(s);const a=wC(e,r);if(a!=null)return a}const i=di(e,o,r||o);if(i.length>0){const s=i[0].value;if(s!=null&&String(s).trim()!=="")return String(s)}return null}let Gp=null;function xC(e){Gp=e}function qp(){return(Gp?.()??"").replace(/\/+$/,"")}function Vn(e){const t=typeof e=="string"?e.trim():"";if(!t||/^https?:\/\//i.test(t))return t;const n=qp();return n?t.startsWith("/")?`${n}${t}`:`${n}/${t}`:t}function AC(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 CC(e){if(!e||typeof e!="object")return;const t={};for(const[n,r]of Object.entries(e))r!==void 0&&r!==""&&(t[n]=r);return Object.keys(t).length>0?t:void 0}const Xr=Wd(e=>({viewerContext:void 0,authHeaders:void 0,_setViewerContext:t=>e({viewerContext:AC(t)?t:void 0}),_setAuthHeaders:t=>e({authHeaders:CC(t)}),_reset:()=>e({viewerContext:void 0,authHeaders:void 0})}));function EC(e){Xr.getState()._setViewerContext(e)}function NC(e){Xr.getState()._setAuthHeaders(e)}function kC(){Xr.getState()._reset()}function _C(){return Xr.getState().viewerContext}function Ms(){return Xr.getState().authHeaders}function TC(e){if(e?.token!=null&&String(e.token).trim()!=="")return String(e.token);const t=Ms(),n=t?.Authorization??t?.authorization;if(n?.trim()){const r=n.match(/^Bearer\s+(.+)$/i);return r?r[1]:n}}function Yp(e,t){const n=TC(t);if(!n)return e;let r=e.replace(/\{token\}/g,n);return r=r.replace(/\{authorization\}/gi,()=>n.startsWith("Bearer ")?n:`Bearer ${n}`),r}function Or(e,t){const n={},{formValues:r={},submissionContext:o,apiRealtime:i}=t;for(const{key:s,value:a}of e??[]){const c=s?.trim();if(!c||a==null)continue;let u=Ra(String(a),r,o,i);u=Yp(u,o),n[c]=u}return n}const FC=/^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/i;function Xp(e){const t=e.trim().match(FC);return t?t[1]:e}const PC={applicantId:["id","applicant_id"],applicant_id:["id","applicantId"],id:["applicantId","applicant_id"]};function Un(e,t,n,r,o,i){let s=e;if(o&&typeof e=="string"&&(s=s.replace(/\{resp:([^}]+)\}/g,(a,c)=>{const u=c.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)}),s.includes("{documentId}")||s.includes("%7BdocumentId%7D"))){let a;for(const c of Object.values(o)){const u=Qe(c,"data.id")??Qe(c,"data.documentId");if(u!=null){a=String(u);break}}a&&(s=s.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}if(s.includes("{documentId}")||s.includes("%7BdocumentId%7D")){let a;const c=t?.documentId??(t&&Qe(t,"documentId")),u=r?.documentId??(r&&Qe(r,"documentId"));c!=null&&c!==""?a=String(c):u!=null&&u!==""&&(a=String(u)),a&&(s=s.replace(/\{documentId\}/g,a).replace(/%7BdocumentId%7D/gi,a))}return s=s.replace(/\{api:([^}]+)\}/g,(a,c)=>{const u=c.trim();if(i==null||u==="")return a;const l=Qe(i,u);return l==null?a:String(l)}),s=s.replace(/\{(?:ctx:|\@)(\w+)\}/g,(a,c)=>r&&r[c]!==void 0&&r[c]!==null?String(r[c]):a),s=s.replace(/\{(\w+)\}/g,(a,c)=>{if(a.includes("ctx:")||a.includes("@"))return a;const u=n[c];if(u!=null)return Xp(String(u));let l=t[c];if(l==null||l===""){const f=Object.keys(t).find(p=>p.toLowerCase()===c.toLowerCase());f&&(l=t[f])}if((l==null||l==="")&&(l=r?.[c]),l==null||l===""){const f=PC[c];if(f)for(const p of f){const m=t[p]??r?.[p];if(m!=null&&m!==""){l=m;break}}}return l!=null&&l!==""?Xp(String(l)):a}),s}const OC=new Set(["authorization"]);function IC(e){return OC.has(e.trim().toLowerCase())}function Ls(e){return(e??[]).filter(t=>!IC(t.key))}function Ds(e){if(!e?.length)return null;const t=e.find(n=>n.key.toLowerCase()==="authorization");if(t?.value?.trim()){const n=t.value.trim();if(n.toLowerCase().startsWith("basic ")){const r=n.slice(6).trim();if(r.includes("{")||r.includes("}")){const o=r.split(":");if(o.length>=2)return{type:"basic",username:o[0].trim(),password:o.slice(1).join(":").trim()}}try{const o=atob(r),i=o.indexOf(":");if(i>=0)return{type:"basic",username:o.slice(0,i),password:o.slice(i+1)}}catch{return{type:"basic",username:"",password:""}}}return n.toLowerCase().startsWith("bearer ")?{type:"bearer",token:n.slice(7).trim()}:{type:"bearer",token:n}}return null}function MC(e){return!e||e.type==="none"?{type:"none"}:e.type==="bearer"?{type:"bearer",token:e.token?.trim()??""}:e.type==="apiKey"?{type:"apiKey",headerName:e.headerName?.trim()||"X-API-Key",apiKey:e.apiKey?.trim()??""}:{type:"basic",username:e.username?.trim()??"",password:e.password?.trim()??""}}function Bs(e,t){const{formValues:n={},submissionContext:r,urlParams:o={},apiRealtime:i}=t;let s=Un(e,n,o,r);return s=Yp(s,r),i!==void 0&&(s=Ra(s,n,r,i)),s}function $s(e,t={}){const n=MC(e),r={};if(n.type==="bearer"){const o=n.token??"";if(!o.trim())return r;const i=Bs(o,t).trim();return i&&(r.Authorization=i.toLowerCase().startsWith("bearer ")?i:`Bearer ${i}`),r}if(n.type==="apiKey"){const o=n.apiKey??"";return o.trim()&&(r[n.headerName||"X-API-Key"]=Bs(o,t)),r}if(n.type==="basic"){const o=n.username??"",i=n.password??"";if(!o.trim()&&!i.trim())return r;const s=Bs(o,t),a=Bs(i,t);r.Authorization=`Basic ${btoa(`${s}:${a}`)}`}return r}function Jp({field:e,formValues:t={},submissionContext:n}){const r=e.properties,o=r?.apiEndpoint?{apiEndpoint:r.apiEndpoint,apiMethod:r.apiMethod,apiKey:r.apiKey,apiRealtime:r.apiRealtime,apiAutoDetect:r.apiAutoDetect,apiLabelField:r.apiLabelField,apiValueField:r.apiValueField,apiQueryParams:r.apiQueryParams,apiClientFilter:r.apiClientFilter,apiHeaders:r.apiHeaders,apiBodyFields:r.apiBodyFields,apiAuth:r.apiAuth,valueSource:r.valueSource,optionsSource:r.optionsSource}:null,i=e.apidata||null,s=o||i,[a,c]=S.useState([]),[u,l]=S.useState([]),[f,p]=S.useState([]),[m,g]=S.useState(!1),[h,y]=S.useState(null),w=!!(s?.apiEndpoint&&(s?.valueSource==="api"||s?.optionsSource==="api"||r?.valueSource==="api"||r?.optionsSource==="api")),v=e.options||r?.options||[],x=S.useMemo(()=>gC(Array.isArray(v)?v:[]),[v]),C=S.useMemo(()=>{const O=s?.apiEndpoint||r?.apiEndpoint||"",E=s?.apiQueryParams||r?.apiQueryParams;return io(O,E)},[s?.apiEndpoint,r?.apiEndpoint,s?.apiQueryParams,r?.apiQueryParams]),F=S.useMemo(()=>{const O=new Set;for(const L of r?.dependentFields??[])typeof L=="string"&&L.trim()&&O.add(L.trim());const E=s?.apiClientFilter?.matchField?.trim()||r?.apiClientFilter?.matchField?.trim();return E&&O.add(E),[...O]},[r?.dependentFields,s?.apiClientFilter?.matchField,r?.apiClientFilter?.matchField]),N=S.useMemo(()=>{const O=new Set([...C,...F]);if(O.size===0)return null;const E={};return O.forEach(L=>{E[L]=t[L]}),JSON.stringify(E)},[C,F,t]),T=S.useMemo(()=>JSON.stringify(n||{}),[n]),k=S.useMemo(()=>{const O=new Set;e.name?.trim()&&O.add(e.name.trim());const E=e.key;return typeof E=="string"&&E.trim()&&O.add(E.trim()),[...O]},[e.name,e.key]);return S.useEffect(()=>{const O=s?.apiEndpoint;if(!w||!O){c([]);return}let E=!1;return(async()=>{a.length===0&&g(!0),y(null);try{const I=s?.apiMethod||r?.apiMethod||"GET",$=s?.apiRealtime||r?.apiRealtime,D=s?.apiQueryParams||r?.apiQueryParams||{},B=Ri({apiEndpoint:O,apiMethod:I,apiQueryParams:D,formValues:t,submissionContext:n,apiRealtime:$,additionalRequiredFieldNames:F,excludeFormFieldNames:k});if(B.blocked){E||(c([]),g(!1));return}const M={"Content-Type":"application/json"},W=s?.apiKey||r?.apiKey;W&&(M["X-CSCAPI-KEY"]=W);const j=s?.apiAuth??r?.apiAuth??i?.apiAuth??Ds(s?.apiHeaders??r?.apiHeaders??i?.apiHeaders)??{type:"none"},ie=$s(j,{formValues:t,submissionContext:n,apiRealtime:$});Object.assign(M,ie);const H=s?.apiHeaders??r?.apiHeaders??i?.apiHeaders,U=s?.apiBodyFields??r?.apiBodyFields??i?.apiBodyFields,J=Or(Ls(H),{formValues:t,submissionContext:n,apiRealtime:$});Object.assign(M,J);const de=Or(U,{formValues:t,submissionContext:n,apiRealtime:$}),ne={method:I.toLowerCase(),url:Vn(B.url),headers:M};(B.postBodyBase!=null||Object.keys(de).length>0)&&(ne.data={...B.postBodyBase??{},...de});const q=await St(ne),re=s?.apiLabelField||r?.apiLabelField,Te=s?.apiValueField||r?.apiValueField,Q=q.data;let te=[];Array.isArray(Q)?te=Q:Q?.data&&(Array.isArray(Q.data)?te=Q.data:Q.data?.data&&Array.isArray(Q.data.data)?te=Q.data.data:Q.data.districts?te=Q.data.districts:Q.data.states?te=Q.data.states:Q.data.cities&&(te=Q.data.cities)),p(te);const ge=di(q.data,re,Te);l(ge);const ce=s?.apiClientFilter||r?.apiClientFilter;let Xe=ge;if(ce?.filterField&&ce?.matchField){const ye=t[ce.matchField];ye!=null?Xe=ge.filter(Se=>{const ae=te.find(He=>String(jt(He,Te||"code"))===String(Se.value));if(!ae)return!1;const ve=jt(ae,ce.filterField);return String(ve)===String(ye)}):Xe=[]}E||c(Xe)}catch(I){if(E)return;let $="Failed to load options";if(I.response){const D=I.response.data;I.response.status===404?$="API endpoint not found.":I.response.status===401?$="Authentication failed.":typeof D=="string"?$=D:D&&typeof D=="object"&&($=D.error||D.message||D.detail||$)}else I.message&&($=String(I.message));y($),a.length===0&&c([])}finally{E||g(!1)}})(),()=>{E=!0}},[w,s?.apiEndpoint,s?.apiMethod,r?.apiEndpoint,r?.apiMethod,N,F,k,T]),S.useEffect(()=>{const O=s?.apiClientFilter||r?.apiClientFilter;if(!w||!O||f.length===0)return;const E=t[O.matchField],L=s?.apiValueField||r?.apiValueField;if(E==null){c([]);return}const G=u.filter(I=>{const $=f.find(B=>String(jt(B,L||"code"))===String(I.value));if(!$)return!1;const D=jt($,O.filterField);return String(D)===String(E)});c(G)},[w,s?.apiClientFilter?.matchField,r?.apiClientFilter?.matchField,s?.apiClientFilter?.filterField,r?.apiClientFilter?.filterField,s?.apiValueField,r?.apiValueField,t[s?.apiClientFilter?.matchField||r?.apiClientFilter?.matchField||""],u,f]),{options:w?a:x,isLoadingOptions:m,optionsError:h}}const Qp=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,isRequired:s,className:a,formValues:c={},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}=Jp({field:e,formValues:c,submissionContext:u}),C=l?.length?new Set(l.map(String)):null,F=C?w.filter(j=>!C.has(String(j.value??j.label??""))):w,N="__clear__",T=t!=null&&String(t).trim()!=="",k=T?F.some(j=>String(j.value??j.label??"")===String(t)):!1,A=S.useMemo(()=>{if(!T||k)return F;const j=String(t);return[{label:j,value:j},...F]},[F,T,k,t]),O=T?String(t):void 0,E=`${ht(e)}-${O??"empty"}`,L=S.useCallback(j=>{n(j===N?"":j),r?.()},[n,r]),G=e.appearance?.size||"md",I={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},$=e.placeholder||"Select an option",D=p?.apiClientFilter?.matchField?.trim()||h?.apiClientFilter?.matchField?.trim(),B=y&&D&&(c[D]===void 0||c[D]===null||c[D]===""),M=v?"Loading options...":B?`Select ${D} first`:l?.length?"No available options":y?"No options available from API":"No options available";return y&&f&&v?d.jsx(Et,{field:e,error:o||x||void 0,isRequired:s,className:a,children:d.jsxs("div",{role:"status","aria-label":"Loading options",className:z("flex items-center justify-center gap-2 w-full min-w-0 rounded-md border border-input bg-muted/50 text-muted-foreground",I[G],e.appearance?.className),children:[d.jsx(so,{className:"h-4 w-4 animate-spin shrink-0"}),d.jsx("span",{className:"truncate",children:"Loading..."})]})}):d.jsx(Et,{field:e,error:o||x||void 0,isRequired:s,className:a,children:d.jsxs(Lx,{value:O,onValueChange:L,disabled:i||e.disabled||v&&F.length===0,children:[d.jsx(Bx,{id:ht(e),"aria-describedby":$t(e,!!o||!!x),"aria-invalid":Qt(!!o||!!x),"aria-required":s,className:z("w-full min-w-0",I[G],o&&"border-destructive focus-visible:ring-destructive",x&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:d.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[v&&d.jsx(so,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"}),F.length===0&&l?.length&&!T?d.jsx("span",{className:"text-muted-foreground truncate",children:"No available options"}):T?d.jsx(Dx,{placeholder:$}):d.jsx("span",{className:"text-muted-foreground truncate",children:$})]})}),d.jsx($x,{children:A.length===0?d.jsx(Pl,{value:"__no_options__",disabled:!0,children:M}):d.jsxs(d.Fragment,{children:[T?d.jsx(Pl,{value:N,children:$}):null,A.map((j,ie)=>{const H=String(j.value??j.label??ie);if(H===N)return null;const U=j.label||j.value||String(j);return d.jsx(Pl,{value:H,disabled:j.disabled||!1,children:U},H)})]})})]},E)})},Zp=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,em=dd,tm=(e,t)=>n=>{var r;if(t?.variants==null)return em(e,n?.class,n?.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(u=>{const l=n?.[u],f=i?.[u];if(l===null)return null;const p=Zp(l)||Zp(f);return o[u][p]}),a=n&&Object.entries(n).reduce((u,l)=>{let[f,p]=l;return p===void 0||(u[f]=p),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.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({...i,...a}[h]):{...i,...a}[h]===y})?[...u,f,p]:u},[]);return em(e,s,c,n?.class,n?.className)},LC=tm("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:n,asChild:r=!1,...o}){const i=r?hu:"button";return d.jsx(i,{"data-slot":"button",className:z(LC({variant:t,size:n,className:e})),...o})}function DC(e,t){return b.useReducer((n,r)=>t[n][r]??n,e)}var Cn=e=>{const{present:t,children:n}=e,r=BC(t),o=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),i=Ze(r.ref,$C(o));return typeof n=="function"||r.isPresent?b.cloneElement(o,{ref:i}):null};Cn.displayName="Presence";function BC(e){const[t,n]=b.useState(),r=b.useRef(null),o=b.useRef(e),i=b.useRef("none"),s=e?"mounted":"unmounted",[a,c]=DC(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const u=js(r.current);i.current=a==="mounted"?u:"none"},[a]),Zt(()=>{const u=r.current,l=o.current;if(l!==e){const p=i.current,m=js(u);e?c("MOUNT"):m==="none"||u?.display==="none"?c("UNMOUNT"):c(l&&p!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),Zt(()=>{if(t){let u;const l=t.ownerDocument.defaultView??window,f=m=>{const h=js(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&h&&(c("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&&(i.current=js(r.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 c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:b.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function js(e){return e?.animationName||"none"}function $C(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function jC(e){const t=zC(e),n=b.forwardRef((r,o)=>{const{children:i,...s}=r,a=b.Children.toArray(i),c=a.find(UC);if(c){const u=c.props.children,l=a.map(f=>f===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return d.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function zC(e){const t=b.forwardRef((n,r)=>{const{children:o,...i}=n;if(b.isValidElement(o)){const s=WC(o),a=HC(i,o.props);return o.type!==b.Fragment&&(a.ref=r?Ur(r,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var VC=Symbol("radix.slottable");function UC(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===VC}function HC(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function WC(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var zs="Popover",[nm]=Sn(zs,[ds]),ui=ds(),[RC,Ir]=nm(zs),rm=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=ui(t),c=b.useRef(null),[u,l]=b.useState(!1),[f,p]=er({prop:r,defaultProp:o??!1,onChange:i,caller:zs});return d.jsx(bf,{...a,children:d.jsx(RC,{scope:t,contentId:lr(),triggerRef:c,open:f,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(m=>!m),[p]),hasCustomAnchor:u,onCustomAnchorAdd:b.useCallback(()=>l(!0),[]),onCustomAnchorRemove:b.useCallback(()=>l(!1),[]),modal:s,children:n})})};rm.displayName=zs;var om="PopoverAnchor",im=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ir(om,n),i=ui(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return b.useEffect(()=>(s(),()=>a()),[s,a]),d.jsx(bl,{...i,...r,ref:t})});im.displayName=om;var sm="PopoverTrigger",am=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ir(sm,n),i=ui(n),s=Ze(t,o.triggerRef),a=d.jsx($e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":fm(o.open),...r,ref:s,onClick:Le(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:d.jsx(bl,{asChild:!0,...i,children:a})});am.displayName=sm;var Rl="PopoverPortal",[KC,GC]=nm(Rl,{forceMount:void 0}),lm=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Ir(Rl,t);return d.jsx(KC,{scope:t,forceMount:n,children:d.jsx(Cn,{present:n||i.open,children:d.jsx(us,{asChild:!0,container:o,children:r})})})};lm.displayName=Rl;var wo="PopoverContent",cm=b.forwardRef((e,t)=>{const n=GC(wo,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Ir(wo,e.__scopePopover);return d.jsx(Cn,{present:r||i.open,children:i.modal?d.jsx(YC,{...o,ref:t}):d.jsx(XC,{...o,ref:t})})});cm.displayName=wo;var qC=jC("PopoverContent.RemoveScroll"),YC=b.forwardRef((e,t)=>{const n=Ir(wo,e.__scopePopover),r=b.useRef(null),o=Ze(t,r),i=b.useRef(!1);return b.useEffect(()=>{const s=r.current;if(s)return wl(s)},[]),d.jsx(vs,{as:qC,allowPinchZoom:!0,children:d.jsx(dm,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Le(e.onCloseAutoFocus,s=>{s.preventDefault(),i.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Le(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0,u=a.button===2||c;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Le(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),XC=b.forwardRef((e,t)=>{const n=Ir(wo,e.__scopePopover),r=b.useRef(!1),o=b.useRef(!1);return d.jsx(dm,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),dm=b.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:l,...f}=e,p=Ir(wo,n),m=ui(n);return tl(),d.jsx(Zi,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:d.jsx(Qi,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:l,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:d.jsx(vf,{"data-state":fm(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)"}})})})}),um="PopoverClose",JC=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ir(um,n);return d.jsx($e.button,{type:"button",...r,ref:t,onClick:Le(e.onClick,()=>o.onOpenChange(!1))})});JC.displayName=um;var QC="PopoverArrow",ZC=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=ui(n);return d.jsx(wf,{...o,...r,ref:t})});ZC.displayName=QC;function fm(e){return e?"open":"closed"}var eE=rm,tE=im,nE=am,rE=lm,oE=cm;function Kl({...e}){return d.jsx(eE,{"data-slot":"popover",...e})}function pm({...e}){return d.jsx(nE,{"data-slot":"popover-trigger",...e})}function Gl({className:e,align:t="center",sideOffset:n=4,...r}){return d.jsx(rE,{children:d.jsx(oE,{"data-slot":"popover-content",align:t,sideOffset:n,className:z("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),...r})})}function iE({...e}){return d.jsx(tE,{"data-slot":"popover-anchor",...e})}const mm={};function Mr(){const e=mm?.VITE_CLIENT_ID?.trim()||mm?.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}const hm={};let gm=null;function sE(e){gm=e}function aE(){return(hm?.VITE_API_BASE_URL?.trim()||hm?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const fr=St.create({baseURL:aE()});fr.interceptors.request.use(e=>{const t=Mr();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let n=gm?.();if((!n||Object.keys(n).length===0)&&(n=Ms()),n){const r=e.headers??{};for(const[o,i]of Object.entries(n))i!==void 0&&i!==""&&(r[o]=i);e.headers=r}return e});function ym(e){return JSON.stringify(e).slice(1,-1)}function bm(e){const t=e.asyncSearchValueObjectKeys;return Array.isArray(t)?t.map(n=>typeof n=="string"?n.trim():"").filter(Boolean):[]}function lE(e){return e.asyncSearchValueMode==="object"&&bm(e).length>0}function cE(e,t){const n={};for(const r of t){const o=r.trim();if(!o)continue;const i=jt(e,o);i==null||typeof i=="object"?n[o]="":n[o]=String(i)}return n}function dE(e,t){const n=t.mode??"debounce",r=Math.max(0,t.intervalMs??300),[o,i]=S.useState(()=>n==="throttle"?e:""),s=S.useRef(0),a=S.useRef(void 0);return S.useEffect(()=>{if(e===""){a.current&&clearTimeout(a.current),i("");return}if(n==="debounce"){const l=setTimeout(()=>i(e),r);return()=>clearTimeout(l)}const c=Date.now(),u=c-s.current;return u>=r?(s.current=c,i(e),()=>{a.current&&clearTimeout(a.current)}):(a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{s.current=Date.now(),i(e),a.current=void 0},r-u),()=>{a.current&&clearTimeout(a.current)})},[e,n,r]),o}function ql(e,t){if(e==null||e==="")return"";if(t&&typeof e=="object"&&!Array.isArray(e)){const n=e,o=Object.keys(n).sort().map(i=>[i,n[i]??""]);return`O:${JSON.stringify(o)}`}return typeof e=="string"?`S:${e}`:""}function Yl(e,t){return e==null||e===""?!0:t&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length===0:!1}function uE(e,t,n){return t.trim()!==""?!0:e==null||e===""?!1:n&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length>0:typeof e=="string"&&e.length>0}function fE(e){if(St.isAxiosError(e)){const t=e.response?.status,n=e.response?.data;if(t===404)return"Search endpoint not found.";if(t===401)return"Authentication failed.";if(n&&typeof n=="object"){const r=n,o=r.error??r.message??r.detail??r.explanation;if(typeof o=="string")return o}if(typeof n=="string")return n;if(t)return`Request failed (${t})`}return e instanceof Error?e.message:"Search failed"}function pE(e){if(e==null)return[];if(Array.isArray(e))return e;const t=e;if(!t?.data)return[];const n=t.data;return Array.isArray(n)?n:n?.data&&Array.isArray(n.data)?n.data:Array.isArray(n?.districts)?n.districts:Array.isArray(n?.states)?n.states:Array.isArray(n?.cities)?n.cities:[]}function vm(e,t){return typeof t=="number"&&t>0?e.slice(0,t):e}function Xl(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.label=="string"&&t.value!==null&&t.value!==void 0}const wm=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u={},submissionContext:l})=>{const f=e.properties||{},p=lE(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,C=f.minQueryLength??0,F=f.maxResults,N=f.searchQueryParam||"q",T=f.clearable!==!1,k=u,[A,O]=S.useState(()=>Yl(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t)),[E,L]=S.useState(!1),[G,I]=S.useState([]),[$,D]=S.useState([]),[B,M]=S.useState([]),[W,j]=S.useState(!1),[ie,H]=S.useState(null),[U,J]=S.useState(-1),de=S.useRef(ql(t,p)),ne=S.useRef(Yl(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?f.initialDisplayLabel||"":f.initialDisplayLabel||String(t??"")),q=S.useRef(void 0),re=S.useRef(0),Te=S.useRef(null),Q=dE(A,{mode:v,intervalMs:x}),te=S.useMemo(()=>G.filter(Xl),[G]);S.useEffect(()=>{if(te.length===0){U!==-1&&J(-1);return}(U<0||U>=te.length)&&J(0)},[U,te.length]);const ge=S.useMemo(()=>{const oe=io(m,f.apiQueryParams),me=new Set(oe);for(const We of f.dependentFields||[])We&&me.add(We);return me},[m,f.apiQueryParams,f.dependentFields]),ce=S.useMemo(()=>{if(ge.size===0)return null;const oe={};return ge.forEach(me=>{oe[me]=k[me]}),JSON.stringify(oe)},[ge,k]),Xe=S.useMemo(()=>JSON.stringify(u),[u]),ye=S.useMemo(()=>JSON.stringify(l||{}),[l]);S.useEffect(()=>{const oe=ql(t,p);if(oe===de.current)return;if(de.current=oe,Yl(t,p)){ne.current="",O(""),I([]),D([]),M([]),H(null),L(!1);return}const me=f.initialDisplayLabel||(!p&&typeof t=="string"?t:"");ne.current=me,O(me)},[t,f.initialDisplayLabel,p]),S.useEffect(()=>{if(!m){I([]),D([]),M([]),j(!1);return}if(s||i||e.disabled){I([]),D([]),M([]),j(!1);return}const oe=Q;if(oe.length<C){I([]),D([]),M([]),j(!1),H(null);return}const me=Ri({apiEndpoint:m,apiMethod:h,apiQueryParams:f.apiQueryParams,formValues:k,submissionContext:l,apiRealtime:g,additionalRequiredFieldNames:f.dependentFields});if(me.blocked){I([]),D([]),M([]),j(!1),H(null);return}Te.current?.abort();const We=new AbortController;Te.current=We;const Tt=++re.current;return(async()=>{j(!0),H(null);const Fe=Vn(me.url),Ge={};w&&(Ge["Content-Type"]="application/json"),f.apiKey&&(Ge["X-CSCAPI-KEY"]=f.apiKey);const nt=f.apiAuth??Ds(f.apiHeaders)??{type:"none"},yt=$s(nt,{formValues:k,submissionContext:l,apiRealtime:g});Object.assign(Ge,yt);const Jt=Or(Ls(f.apiHeaders),{formValues:k,submissionContext:l,apiRealtime:g});Object.assign(Ge,Jt);const xt=Or(f.apiBodyFields,{formValues:k,submissionContext:l,apiRealtime:g});try{let Pe;if(!w)Pe=(await fr.get(Fe,{params:{[N]:oe},signal:We.signal,headers:Object.keys(Ge).length?Ge:void 0})).data;else{let wt={};me.postBodyBase&&Object.keys(me.postBodyBase).length>0?wt={...me.postBodyBase}:g&&Object.keys(k).length>0&&(wt={...k}),wt={...wt,...xt};let Ut=wt;if(f.searchBodyTemplate?.trim()){let Ft=f.searchBodyTemplate.replace(/\{\{query\}\}/g,()=>ym(oe)).replace(/\{query\}/g,()=>ym(oe));Ft=Ra(Ft,k,l,g);const ir=JSON.parse(Ft);Ut={...wt,...ir}}else Ut={...wt,[N]:oe};Pe=(await fr.post(Fe,Ut,{signal:We.signal,headers:Object.keys(Ge).length?Ge:void 0})).data}if(Tt!==re.current)return;const ft=f.apiResultsFormat,et=f.apiResultsConfig,At=ft==="clinicaltables_v3",dn=yC(Pe),mr=At||ft===void 0&&dn,Vt=ft==="tuple_array";let Wn=null;mr?Wn=Rp({response:Pe,sourceUrl:Fe,rowsIndex:et?.rowsIndex??3,rowsPath:et?.rowsPath,columns:et?.columns,columnsQueryParam:et?.columnsQueryParam??"sf",columnsQueryParamSeparator:et?.columnsQueryParamSeparator??","}):Vt&&(Wn=Rp({response:Pe,sourceUrl:Fe,rowsIndex:et?.rowsIndex,rowsPath:et?.rowsPath,columns:et?.columns,columnsQueryParam:et?.columnsQueryParam,columnsQueryParamSeparator:et?.columnsQueryParamSeparator}));const hr=pE(Pe),Ct=Wn!==null,vn=Wn&&Array.isArray(Wn)?Wn:Array.isArray(hr)&&hr.every(wt=>wt&&typeof wt=="object"&&!Array.isArray(wt))?hr:null;M(vn??hr);const Do=Array.isArray(f.apiLabelFields)&&f.apiLabelFields.length>0,gr=vn&&(Ct||Do)?vC({rows:vn,apiLabelField:f.apiLabelField,apiLabelFields:f.apiLabelFields,apiLabelSeparator:f.apiLabelSeparator,apiValueField:f.apiValueField}):di(Pe,f.apiLabelField,f.apiValueField);D(gr);const In=f.apiClientFilter;let or=gr;if(In?.filterField&&In?.matchField){const wt=k[In.matchField];if(wt!=null){const Ut=f.apiValueField;or=gr.filter(Rn=>{const ir=(vn??hr).find(fn=>String(jt(fn,Ut||"code"))===String(Rn.value));if(!ir)return!1;const un=jt(ir,In.filterField);return String(un)===String(wt)})}else or=[]}const tn=vm(or,F).filter(Xl);I(tn),J(tn.length>0?0:-1)}catch(Pe){if(St.isCancel(Pe)||Pe?.code==="ERR_CANCELED"||Tt!==re.current)return;I([]),D([]),M([]),H(fE(Pe)),J(-1)}finally{Tt===re.current&&j(!1)}})(),()=>{We.abort()}},[Q,m,h,y,w,N,C,F,f.apiKey,f.searchBodyTemplate,f.apiLabelField,f.apiLabelFields,f.apiLabelSeparator,f.apiValueField,f.apiQueryParams,f.apiClientFilter,f.apiResultsFormat,f.apiResultsConfig,f.dependentFields,g,k,l,s,i,e.disabled,ce,Xe,ye]),S.useEffect(()=>{const oe=f.apiClientFilter;if(!oe||B.length===0||$.length===0)return;const me=k[oe.matchField],We=f.apiValueField;if(me==null){I([]);return}const Tt=$.filter(Fe=>{const Ge=B.find(yt=>String(jt(yt,We||"code"))===String(Fe.value));if(!Ge)return!1;const nt=jt(Ge,oe.filterField);return String(nt)===String(me)}),ze=vm(Tt,F).filter(Xl);I(ze),J(ze.length>0?0:-1)},[f.apiClientFilter,f.apiValueField,k,F,$,B]);const Se=i||e.disabled,ae=s||e.readOnly,ve=S.useCallback(oe=>{const me=oe.target.value;ae||Se||(de.current&&ne.current&&me!==ne.current&&(de.current="",ne.current="",n(p?null:"")),O(me),L(!0),J(-1))},[Se,ae,p,n]),He=S.useCallback(oe=>{const me=typeof oe?.label=="string"?oe.label:String(oe?.value??""),We=f.apiValueField||"code";if(p){const Tt=bm(f),ze=B.find(Fe=>String(jt(Fe,We))===String(oe.value));if(ze&&typeof ze=="object"&&!Array.isArray(ze)&&Tt.length>0){const Fe=cE(ze,Tt);de.current=ql(Fe,!0),ne.current=me,n(Fe),O(me)}else de.current=`S:${String(oe.value)}`,ne.current=me,n(String(oe.value)),O(me)}else de.current=`S:${String(oe.value)}`,ne.current=me,n(String(oe.value)),O(me);q.current&&clearTimeout(q.current),L(!1),J(-1),r?.()},[p,r,n,f,B]),dt=S.useCallback(oe=>{oe.preventDefault(),oe.stopPropagation(),!(Se||ae)&&(de.current="",ne.current="",n(p?null:""),O(""),I([]),D([]),M([]),H(null),L(!1),r?.())},[Se,ae,p,n,r]),Ke=S.useMemo(()=>E&&!ae&&(W||!!ie||te.length>0||Q.length>=C&&!W),[E,ae,W,ie,te.length,Q,C]),Gt=S.useCallback(oe=>{if(!(ae||Se))if(oe.key==="ArrowDown")oe.preventDefault(),L(!0),J(me=>te.length===0?-1:(me+1)%te.length);else if(oe.key==="ArrowUp")oe.preventDefault(),L(!0),J(me=>te.length===0?-1:me<=0?te.length-1:me-1);else if(oe.key==="Enter"){const me=U>=0?te[U]:void 0;Ke&&me&&!me.disabled&&(oe.preventDefault(),He(me))}else oe.key==="Escape"&&L(!1)},[Se,ae,U,Ke,te,He]),Je=e.appearance?.size||"md",Y={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},je=ht(e),gt=$t(e,!!(o||ie)),Ie=Q.length>=C&&!W&&!ie&&te.length===0;return d.jsx(Et,{field:e,error:o||ie||void 0,isRequired:a,className:c,children:d.jsxs(Kl,{open:Ke,onOpenChange:oe=>{oe||L(!1)},children:[d.jsx(iE,{asChild:!0,children:d.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[d.jsx(Cr,{id:je,role:"combobox","aria-expanded":Ke,"aria-autocomplete":"list","aria-controls":Ke?`${je}-listbox`:void 0,"aria-activedescendant":U>=0?`${je}-opt-${U}`:void 0,value:A,onChange:ve,onKeyDown:Gt,onFocus:()=>{q.current&&clearTimeout(q.current),!ae&&!Se&&L(!0)},onBlur:()=>{q.current=setTimeout(()=>{L(!1),r?.()},150)},placeholder:e.placeholder||"Search…",disabled:Se,readOnly:ae,"aria-describedby":gt,"aria-invalid":Qt(!!(o||ie)),"aria-required":a,className:z("pr-20",Y[Je],(o||ie)&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),d.jsxs("div",{className:"pointer-events-none absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[W&&d.jsx(so,{className:"pointer-events-none h-4 w-4 animate-spin text-muted-foreground"}),T&&uE(t,A,p)&&!Se&&!ae&&d.jsx(Yt,{type:"button",variant:"ghost",size:"icon",className:"pointer-events-auto h-8 w-8 shrink-0",onMouseDown:oe=>oe.preventDefault(),onClick:dt,"aria-label":"Clear",children:d.jsx(Jo,{className:"h-4 w-4"})})]})]})}),d.jsx(Gl,{className:"p-0 w-[var(--radix-popover-trigger-width)] min-w-[12rem] overflow-hidden",align:"start",onOpenAutoFocus:oe=>oe.preventDefault(),onCloseAutoFocus:oe=>oe.preventDefault(),children:d.jsx("div",{id:`${je}-listbox`,role:"listbox",children:ie?d.jsx("div",{className:"px-3 py-2 text-sm text-destructive",children:ie}):W?d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground",children:[d.jsx(so,{className:"h-4 w-4 animate-spin shrink-0"}),"Loading…"]}):Ie?d.jsx("ul",{className:"py-1","aria-label":"Search results",children:d.jsx("li",{role:"option","aria-disabled":!0,className:"cursor-default select-none px-3 py-2 text-sm text-muted-foreground",onMouseDown:oe=>oe.preventDefault(),children:"No results found"})}):d.jsx("ul",{className:"max-h-60 overflow-y-auto overscroll-contain py-1","aria-label":"Search results",children:te.map((oe,me)=>d.jsx("li",{id:`${je}-opt-${me}`,role:"option","aria-selected":U===me,className:z(oe.disabled?"cursor-not-allowed opacity-60":"cursor-pointer","px-3 py-2 text-sm",U===me&&"bg-accent text-accent-foreground"),onMouseEnter:()=>J(me),onMouseDown:We=>We.preventDefault(),onClick:()=>{oe.disabled||He(oe)},children:oe.label},`${oe.value}-${me}`))})})})]})})};var Vs="Checkbox",[mE]=Sn(Vs),[hE,Jl]=mE(Vs);function gE(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:o,disabled:i,form:s,name:a,onCheckedChange:c,required:u,value:l="on",internal_do_not_use_render:f}=e,[p,m]=er({prop:n,defaultProp:o??!1,onChange:c,caller:Vs}),[g,h]=b.useState(null),[y,w]=b.useState(null),v=b.useRef(!1),x=g?!!s||!!g.closest("form"):!0,C={checked:p,disabled:i,setChecked:m,control:g,setControl:h,name:a,form:s,value:l,hasConsumerStoppedPropagationRef:v,required:u,defaultChecked:Lr(o)?!1:o,isFormControl:x,bubbleInput:y,setBubbleInput:w};return d.jsx(hE,{scope:t,...C,children:yE(f)?f(C):r})}var Sm="CheckboxTrigger",xm=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},o)=>{const{control:i,value:s,disabled:a,checked:c,required:u,setControl:l,setChecked:f,hasConsumerStoppedPropagationRef:p,isFormControl:m,bubbleInput:g}=Jl(Sm,e),h=Ze(o,l),y=b.useRef(c);return b.useEffect(()=>{const w=i?.form;if(w){const v=()=>f(y.current);return w.addEventListener("reset",v),()=>w.removeEventListener("reset",v)}},[i,f]),d.jsx($e.button,{type:"button",role:"checkbox","aria-checked":Lr(c)?"mixed":c,"aria-required":u,"data-state":_m(c),"data-disabled":a?"":void 0,disabled:a,value:s,...r,ref:h,onKeyDown:Le(t,w=>{w.key==="Enter"&&w.preventDefault()}),onClick:Le(n,w=>{f(v=>Lr(v)?!0:!v),g&&m&&(p.current=w.isPropagationStopped(),p.current||w.stopPropagation())})})});xm.displayName=Sm;var Am=b.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:c,onCheckedChange:u,form:l,...f}=e;return d.jsx(gE,{__scopeCheckbox:n,checked:o,defaultChecked:i,disabled:a,required:s,onCheckedChange:u,name:r,form:l,value:c,internal_do_not_use_render:({isFormControl:p})=>d.jsxs(d.Fragment,{children:[d.jsx(xm,{...f,ref:t,__scopeCheckbox:n}),p&&d.jsx(km,{__scopeCheckbox:n})]})})});Am.displayName=Vs;var Cm="CheckboxIndicator",Em=b.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=Jl(Cm,n);return d.jsx(Cn,{present:r||Lr(i.checked)||i.checked===!0,children:d.jsx($e.span,{"data-state":_m(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});Em.displayName=Cm;var Nm="CheckboxBubbleInput",km=b.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:o,checked:i,defaultChecked:s,required:a,disabled:c,name:u,value:l,form:f,bubbleInput:p,setBubbleInput:m}=Jl(Nm,e),g=Ze(n,m),h=ni(i),y=ti(r);b.useEffect(()=>{const v=p;if(!v)return;const x=window.HTMLInputElement.prototype,F=Object.getOwnPropertyDescriptor(x,"checked").set,N=!o.current;if(h!==i&&F){const T=new Event("click",{bubbles:N});v.indeterminate=Lr(i),F.call(v,Lr(i)?!1:i),v.dispatchEvent(T)}},[p,h,i,o]);const w=b.useRef(Lr(i)?!1:i);return d.jsx($e.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??w.current,required:a,disabled:c,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%)"}})});km.displayName=Nm;function yE(e){return typeof e=="function"}function Lr(e){return e==="indeterminate"}function _m(e){return Lr(e)?"indeterminate":e?"checked":"unchecked"}function Us({className:e,...t}){return d.jsx(Am,{"data-slot":"checkbox",className:z("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(Em,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:d.jsx(Xi,{className:"size-3.5"})})})}const bE=tm("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 vE({className:e,variant:t,asChild:n=!1,...r}){const o=n?hu:"span";return d.jsx(o,{"data-slot":"badge",className:z(bE({variant:t}),e),...r})}function wE(e,t){return b.useReducer((n,r)=>t[n][r]??n,e)}var Ql="ScrollArea",[Tm]=Sn(Ql),[SE,Fn]=Tm(Ql),Fm=b.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:i=600,...s}=e,[a,c]=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,C]=b.useState(0),[F,N]=b.useState(!1),[T,k]=b.useState(!1),A=Ze(t,E=>c(E)),O=ao(o);return d.jsx(SE,{scope:n,type:r,dir:O,scrollHideDelay:i,scrollArea:a,viewport:u,onViewportChange:l,content:f,onContentChange:p,scrollbarX:m,onScrollbarXChange:g,scrollbarXEnabled:F,onScrollbarXEnabledChange:N,scrollbarY:h,onScrollbarYChange:y,scrollbarYEnabled:T,onScrollbarYEnabledChange:k,onCornerWidthChange:v,onCornerHeightChange:C,children:d.jsx($e.div,{dir:O,...s,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});Fm.displayName=Ql;var Pm="ScrollAreaViewport",Om=b.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...i}=e,s=Fn(Pm,n),a=b.useRef(null),c=Ze(t,a,s.onViewportChange);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),d.jsx($e.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Om.displayName=Pm;var nr="ScrollAreaScrollbar",Im=b.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Fn(nr,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:s}=o,a=e.orientation==="horizontal";return b.useEffect(()=>(a?i(!0):s(!0),()=>{a?i(!1):s(!1)}),[a,i,s]),o.type==="hover"?d.jsx(xE,{...r,ref:t,forceMount:n}):o.type==="scroll"?d.jsx(AE,{...r,ref:t,forceMount:n}):o.type==="auto"?d.jsx(Mm,{...r,ref:t,forceMount:n}):o.type==="always"?d.jsx(Zl,{...r,ref:t}):null});Im.displayName=nr;var xE=b.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Fn(nr,e.__scopeScrollArea),[i,s]=b.useState(!1);return b.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),s(!0)},l=()=>{c=window.setTimeout(()=>s(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",l),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",l)}}},[o.scrollArea,o.scrollHideDelay]),d.jsx(Cn,{present:n||i,children:d.jsx(Mm,{"data-state":i?"visible":"hidden",...r,ref:t})})}),AE=b.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Fn(nr,e.__scopeScrollArea),i=e.orientation==="horizontal",s=Ks(()=>c("SCROLL_END"),100),[a,c]=wE("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return b.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),b.useEffect(()=>{const u=o.viewport,l=i?"scrollLeft":"scrollTop";if(u){let f=u[l];const p=()=>{const m=u[l];f!==m&&(c("SCROLL"),s()),f=m};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,i,c,s]),d.jsx(Cn,{present:n||a!=="hidden",children:d.jsx(Zl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:Le(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Le(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Mm=b.forwardRef((e,t)=>{const n=Fn(nr,e.__scopeScrollArea),{forceMount:r,...o}=e,[i,s]=b.useState(!1),a=e.orientation==="horizontal",c=Ks(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,l=n.viewport.offsetHeight<n.viewport.scrollHeight;s(a?u:l)}},10);return So(n.viewport,c),So(n.content,c),d.jsx(Cn,{present:r||i,children:d.jsx(Zl,{"data-state":i?"visible":"hidden",...o,ref:t})})}),Zl=b.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Fn(nr,e.__scopeScrollArea),i=b.useRef(null),s=b.useRef(0),[a,c]=b.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=jm(a.viewport,a.content),l={...r,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:p=>i.current=p,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:p=>s.current=p};function f(p,m){return TE(p,s.current,a,m)}return n==="horizontal"?d.jsx(CE,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollLeft,m=zm(p,a,o.dir);i.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))}}):n==="vertical"?d.jsx(EE,{...l,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const p=o.viewport.scrollTop,m=zm(p,a);i.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}),CE=b.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=Fn(nr,e.__scopeScrollArea),[s,a]=b.useState(),c=b.useRef(null),u=Ze(t,c,i.onScrollbarXChange);return b.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),d.jsx(Dm,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Rs(n)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.x),onDragScroll:l=>e.onDragScroll(l.x),onWheelScroll:(l,f)=>{if(i.viewport){const p=i.viewport.scrollLeft+l.deltaX;e.onWheelScroll(p),Um(p,f)&&l.preventDefault()}},onResize:()=>{c.current&&i.viewport&&s&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Ws(s.paddingLeft),paddingEnd:Ws(s.paddingRight)}})}})}),EE=b.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=Fn(nr,e.__scopeScrollArea),[s,a]=b.useState(),c=b.useRef(null),u=Ze(t,c,i.onScrollbarYChange);return b.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),d.jsx(Dm,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Rs(n)+"px",...e.style},onThumbPointerDown:l=>e.onThumbPointerDown(l.y),onDragScroll:l=>e.onDragScroll(l.y),onWheelScroll:(l,f)=>{if(i.viewport){const p=i.viewport.scrollTop+l.deltaY;e.onWheelScroll(p),Um(p,f)&&l.preventDefault()}},onResize:()=>{c.current&&i.viewport&&s&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Ws(s.paddingTop),paddingEnd:Ws(s.paddingBottom)}})}})}),[NE,Lm]=Tm(nr),Dm=b.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:i,onThumbPointerUp:s,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:l,onResize:f,...p}=e,m=Fn(nr,n),[g,h]=b.useState(null),y=Ze(t,A=>h(A)),w=b.useRef(null),v=b.useRef(""),x=m.viewport,C=r.content-r.viewport,F=sn(l),N=sn(c),T=Ks(f,10);function k(A){if(w.current){const O=A.clientX-w.current.left,E=A.clientY-w.current.top;u({x:O,y:E})}}return b.useEffect(()=>{const A=O=>{const E=O.target;g?.contains(E)&&F(O,C)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[x,g,C,F]),b.useEffect(N,[r,N]),So(g,T),So(m.content,T),d.jsx(NE,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:sn(i),onThumbPointerUp:sn(s),onThumbPositionChange:N,onThumbPointerDown:sn(a),children:d.jsx($e.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:Le(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"),k(A))}),onPointerMove:Le(e.onPointerMove,k),onPointerUp:Le(e.onPointerUp,A=>{const O=A.target;O.hasPointerCapture(A.pointerId)&&O.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=v.current,m.viewport&&(m.viewport.style.scrollBehavior=""),w.current=null})})})}),Hs="ScrollAreaThumb",Bm=b.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Lm(Hs,e.__scopeScrollArea);return d.jsx(Cn,{present:n||o.hasThumb,children:d.jsx(kE,{ref:t,...r})})}),kE=b.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,i=Fn(Hs,n),s=Lm(Hs,n),{onThumbPositionChange:a}=s,c=Ze(t,f=>s.onThumbChange(f)),u=b.useRef(void 0),l=Ks(()=>{u.current&&(u.current(),u.current=void 0)},100);return b.useEffect(()=>{const f=i.viewport;if(f){const p=()=>{if(l(),!u.current){const m=FE(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[i.viewport,l,a]),d.jsx($e.div,{"data-state":s.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Le(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),g=f.clientX-m.left,h=f.clientY-m.top;s.onThumbPointerDown({x:g,y:h})}),onPointerUp:Le(e.onPointerUp,s.onThumbPointerUp)})});Bm.displayName=Hs;var ec="ScrollAreaCorner",$m=b.forwardRef((e,t)=>{const n=Fn(ec,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?d.jsx(_E,{...e,ref:t}):null});$m.displayName=ec;var _E=b.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Fn(ec,n),[i,s]=b.useState(0),[a,c]=b.useState(0),u=!!(i&&a);return So(o.scrollbarX,()=>{const l=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(l),c(l)}),So(o.scrollbarY,()=>{const l=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(l),s(l)}),u?d.jsx($e.div,{...r,ref:t,style:{width:i,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Ws(e){return e?parseInt(e,10):0}function jm(e,t){const n=e/t;return isNaN(n)?0:n}function Rs(e){const t=jm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function TE(e,t,n,r="ltr"){const o=Rs(n),i=o/2,s=t||i,a=o-s,c=n.scrollbar.paddingStart+s,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,l=n.content-n.viewport,f=r==="ltr"?[0,l]:[l*-1,0];return Vm([c,u],f)(e)}function zm(e,t,n="ltr"){const r=Rs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,s=t.content-t.viewport,a=i-r,c=n==="ltr"?[0,s]:[s*-1,0],u=Qo(e,c);return Vm([0,s],[0,a])(u)}function Vm(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Um(e,t){return e>0&&e<t}var FE=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function o(){const i={left:e.scrollLeft,top:e.scrollTop},s=n.left!==i.left,a=n.top!==i.top;(s||a)&&t(),n=i,r=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(r)};function Ks(e,t){const n=sn(e),r=b.useRef(0);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),b.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function So(e,t){const n=sn(t);Zt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var PE=Fm,OE=Om,IE=$m;function ME({className:e,children:t,...n}){return d.jsxs(PE,{"data-slot":"scroll-area",className:z("relative",e),...n,children:[d.jsx(OE,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),d.jsx(LE,{}),d.jsx(IE,{})]})}function LE({className:e,orientation:t="vertical",...n}){return d.jsx(Im,{"data-slot":"scroll-area-scrollbar",orientation:t,className:z("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),...n,children:d.jsx(Bm,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Hm=({field:e,value:t=[],onChange:n,onBlur:r,error:o,disabled:i,isRequired:s,className:a,formValues:c={},submissionContext:u,excludedOptionValues:l})=>{const{options:f,isLoadingOptions:p,optionsError:m}=Jp({field:e,formValues:c,submissionContext:u}),g=l?.length?new Set(l.map(String)):null,h=g?f.filter(T=>!g.has(String(T.value??T.label??""))):f,y=Array.isArray(t)?t:[],w=y.map(T=>h.find(k=>String(k.value)===String(T))).filter(Boolean),v=S.useCallback(T=>{const k=y.includes(T)?y.filter(A=>A!==T):[...y,T];n(k),r?.()},[y,n,r]),x=S.useCallback(T=>{n(y.filter(k=>k!==T)),r?.()},[y,n,r]),C=e.appearance?.size||"md",F={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},N=w.length>0?`${w.length} selected`:h.length===0&&l?.length?"No available options":e.placeholder||"Select options";return d.jsxs(Et,{field:e,error:o||m||void 0,isRequired:s,className:a,children:[d.jsxs(Kl,{children:[d.jsx(pm,{asChild:!0,children:d.jsxs(Yt,{type:"button",variant:"outline",role:"combobox","aria-expanded":void 0,"aria-haspopup":"listbox","aria-multiselectable":"true","aria-describedby":$t(e,!!o||!!m),"aria-invalid":Qt(!!o||!!m),"aria-required":s,id:ht(e),disabled:i||e.disabled||p,className:z("w-full min-w-0 justify-between font-normal",F[C],o&&"border-destructive focus-visible:ring-destructive",m&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:[d.jsx("span",{className:"truncate",children:N}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p&&d.jsx(so,{className:"h-4 w-4 animate-spin text-muted-foreground"}),d.jsx(Yo,{className:"h-4 w-4 opacity-50"})]})]})}),d.jsx(Gl,{className:"w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden",align:"start",children:d.jsx(ME,{className:"h-60 overflow-hidden rounded-md",children:d.jsx("ul",{role:"listbox","aria-multiselectable":"true","aria-label":e.label||e.name||"Options",className:"p-1",children:h.length===0?d.jsx("li",{className:"px-2 py-3 text-sm text-muted-foreground text-center",children:p?"Loading options...":l?.length?"No available options":"No options available"}):h.map(T=>{const k=String(T.value||T.label),A=T.label||T.value||k,O=y.includes(k);return d.jsxs("li",{role:"option","aria-selected":O,className:"flex items-center gap-2 rounded-sm px-2 py-1.5 cursor-pointer hover:bg-accent focus:bg-accent outline-none",onClick:()=>!T.disabled&&v(k),onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),T.disabled||v(k))},children:[d.jsx(Us,{checked:O,disabled:T.disabled,onCheckedChange:()=>!T.disabled&&v(k),onClick:E=>E.stopPropagation(),"aria-hidden":!0,className:"pointer-events-none"}),d.jsx("span",{className:"flex-1 truncate text-sm",children:A})]},k)})})})})]}),w.length>0&&d.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",role:"list","aria-label":"Selected options",children:w.map(T=>{const k=String(T.value||T.label),A=T.label||T.value||k;return d.jsxs(vE,{variant:"secondary",className:"pl-2 pr-1 py-0.5 text-xs font-normal gap-1",children:[d.jsx("span",{className:"truncate max-w-[120px]",children:A}),d.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(k),tabIndex:-1,children:d.jsx(Jo,{className:"h-3 w-3"})})]},k)})})]})},Wm=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,isRequired:s,className:a})=>{const c=S.useCallback(u=>{n(u===!0),r?.()},[n,r]);return d.jsxs("div",{className:z("space-y-2",a),children:[d.jsxs("div",{className:"flex items-start space-x-3",children:[d.jsx(Us,{id:ht(e),checked:t||!1,onCheckedChange:c,disabled:i||e.disabled,"aria-describedby":$t(e,!!o),"aria-required":s,className:z(o&&"border-destructive")}),d.jsxs("div",{className:"grid gap-1.5 leading-none",children:[d.jsxs(Er,{id:Gi(e),htmlFor:ht(e),className:z("text-sm font-medium cursor-pointer",o&&"text-destructive"),children:[e.label,s&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&d.jsx("p",{id:Go(e),className:"text-xs text-muted-foreground",children:e.description})]})]}),o&&d.jsx("p",{id:qo(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var Gs="Switch",[DE]=Sn(Gs),[BE,$E]=DE(Gs),Rm=b.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:c="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]=er({prop:o,defaultProp:i??!1,onChange:u,caller:Gs});return d.jsxs(BE,{scope:n,checked:w,disabled:a,children:[d.jsx($e.button,{type:"button",role:"switch","aria-checked":w,"aria-required":s,"data-state":Ym(w),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:g,onClick:Le(e.onClick,x=>{v(C=>!C),y&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})}),y&&d.jsx(qm,{control:p,bubbles:!h.current,name:r,value:c,checked:w,required:s,disabled:a,form:l,style:{transform:"translateX(-100%)"}})]})});Rm.displayName=Gs;var Km="SwitchThumb",Gm=b.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=$E(Km,n);return d.jsx($e.span,{"data-state":Ym(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Gm.displayName=Km;var jE="SwitchBubbleInput",qm=b.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},i)=>{const s=b.useRef(null),a=Ze(s,i),c=ni(n),u=ti(t);return b.useEffect(()=>{const l=s.current;if(!l)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const g=new Event("click",{bubbles:r});m.call(l,n),l.dispatchEvent(g)}},[c,n,r]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});qm.displayName=jE;function Ym(e){return e?"checked":"unchecked"}var zE=Rm,VE=Gm;function Xm({className:e,...t}){return d.jsx(zE,{"data-slot":"switch",className:z("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(VE,{"data-slot":"switch-thumb",className:z("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 UE=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,isRequired:s,className:a})=>{const c=e.properties;let u=null;if(e.metadata)try{u=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata}catch{}const l=u?.onValue??c?.onValue??"On",f=u?.offValue??c?.offValue??"Off",p=u?.onText??c?.onText??l,m=u?.offText??c?.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=>{n(y?l:f),r?.()},[n,r,l,f]);return d.jsxs("div",{className:z("space-y-2",a),children:[d.jsxs("div",{className:"space-y-2",children:[e.label&&d.jsxs(Er,{id:Gi(e),htmlFor:ht(e),className:z("text-sm font-medium block",o&&"text-destructive"),children:[e.label,s&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&d.jsx("p",{id:Go(e),className:"text-xs text-muted-foreground",children:e.description}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Xm,{id:ht(e),checked:g,onCheckedChange:h,disabled:i||e.disabled,"aria-describedby":$t(e,!!o),"aria-required":s,className:z(o&&"opacity-50")}),d.jsx("span",{className:"text-sm text-foreground font-medium",children:g?p:m})]})]}),o&&d.jsx("p",{id:qo(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var tc="rovingFocusGroup.onEntryFocus",HE={bubbles:!1,cancelable:!0},fi="RovingFocusGroup",[nc,Jm,WE]=Qa(fi),[RE,qs]=Sn(fi,[WE]),[KE,GE]=RE(fi),Qm=b.forwardRef((e,t)=>d.jsx(nc.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(nc.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(qE,{...e,ref:t})})}));Qm.displayName=fi;var qE=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:l=!1,...f}=e,p=b.useRef(null),m=Ze(t,p),g=ao(i),[h,y]=er({prop:s,defaultProp:a??null,onChange:c,caller:fi}),[w,v]=b.useState(!1),x=sn(u),C=Jm(n),F=b.useRef(!1),[N,T]=b.useState(0);return b.useEffect(()=>{const k=p.current;if(k)return k.addEventListener(tc,x),()=>k.removeEventListener(tc,x)},[x]),d.jsx(KE,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:h,onItemFocus:b.useCallback(k=>y(k),[y]),onItemShiftTab:b.useCallback(()=>v(!0),[]),onFocusableItemAdd:b.useCallback(()=>T(k=>k+1),[]),onFocusableItemRemove:b.useCallback(()=>T(k=>k-1),[]),children:d.jsx($e.div,{tabIndex:w||N===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:Le(e.onMouseDown,()=>{F.current=!0}),onFocus:Le(e.onFocus,k=>{const A=!F.current;if(k.target===k.currentTarget&&A&&!w){const O=new CustomEvent(tc,HE);if(k.currentTarget.dispatchEvent(O),!O.defaultPrevented){const E=C().filter(D=>D.focusable),L=E.find(D=>D.active),G=E.find(D=>D.id===h),$=[L,G,...E].filter(Boolean).map(D=>D.ref.current);th($,l)}}F.current=!1}),onBlur:Le(e.onBlur,()=>v(!1))})})}),Zm="RovingFocusGroupItem",eh=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:s,...a}=e,c=lr(),u=i||c,l=GE(Zm,n),f=l.currentTabStopId===u,p=Jm(n),{onFocusableItemAdd:m,onFocusableItemRemove:g,currentTabStopId:h}=l;return b.useEffect(()=>{if(r)return m(),()=>g()},[r,m,g]),d.jsx(nc.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:d.jsx($e.span,{tabIndex:f?0:-1,"data-orientation":l.orientation,...a,ref:t,onMouseDown:Le(e.onMouseDown,y=>{r?l.onItemFocus(u):y.preventDefault()}),onFocus:Le(e.onFocus,()=>l.onItemFocus(u)),onKeyDown:Le(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){l.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const w=JE(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(C=>C.focusable).map(C=>C.ref.current);if(w==="last")x.reverse();else if(w==="prev"||w==="next"){w==="prev"&&x.reverse();const C=x.indexOf(y.currentTarget);x=l.loop?QE(x,C+1):x.slice(C+1)}setTimeout(()=>th(x))}}),children:typeof s=="function"?s({isCurrentTabStop:f,hasTabStop:h!=null}):s})})});eh.displayName=Zm;var YE={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function XE(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function JE(e,t,n){const r=XE(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return YE[r]}function th(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function QE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var nh=Qm,rh=eh,rc="Radio",[ZE,oh]=Sn(rc),[eN,tN]=ZE(rc),ih=b.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:o=!1,required:i,disabled:s,value:a="on",onCheck:c,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 d.jsxs(eN,{scope:n,checked:o,disabled:s,children:[d.jsx($e.button,{type:"button",role:"radio","aria-checked":o,"data-state":ch(o),"data-disabled":s?"":void 0,disabled:s,value:a,...l,ref:m,onClick:Le(e.onClick,y=>{o||c?.(),h&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})}),h&&d.jsx(lh,{control:f,bubbles:!g.current,name:r,value:a,checked:o,required:i,disabled:s,form:u,style:{transform:"translateX(-100%)"}})]})});ih.displayName=rc;var sh="RadioIndicator",ah=b.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...o}=e,i=tN(sh,n);return d.jsx(Cn,{present:r||i.checked,children:d.jsx($e.span,{"data-state":ch(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t})})});ah.displayName=sh;var nN="RadioBubbleInput",lh=b.forwardRef(({__scopeRadio:e,control:t,checked:n,bubbles:r=!0,...o},i)=>{const s=b.useRef(null),a=Ze(s,i),c=ni(n),u=ti(t);return b.useEffect(()=>{const l=s.current;if(!l)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const g=new Event("click",{bubbles:r});m.call(l,n),l.dispatchEvent(g)}},[c,n,r]),d.jsx($e.input,{type:"radio","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});lh.displayName=nN;function ch(e){return e?"checked":"unchecked"}var rN=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Ys="RadioGroup",[oN]=Sn(Ys,[qs,oh]),dh=qs(),uh=oh(),[iN,sN]=oN(Ys),fh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:o,value:i,required:s=!1,disabled:a=!1,orientation:c,dir:u,loop:l=!0,onValueChange:f,...p}=e,m=dh(n),g=ao(u),[h,y]=er({prop:i,defaultProp:o??null,onChange:f,caller:Ys});return d.jsx(iN,{scope:n,name:r,required:s,disabled:a,value:h,onValueChange:y,children:d.jsx(nh,{asChild:!0,...m,orientation:c,dir:g,loop:l,children:d.jsx($e.div,{role:"radiogroup","aria-required":s,"aria-orientation":c,"data-disabled":a?"":void 0,dir:g,...p,ref:t})})})});fh.displayName=Ys;var ph="RadioGroupItem",mh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...o}=e,i=sN(ph,n),s=i.disabled||r,a=dh(n),c=uh(n),u=b.useRef(null),l=Ze(t,u),f=i.value===o.value,p=b.useRef(!1);return b.useEffect(()=>{const m=h=>{rN.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)}},[]),d.jsx(rh,{asChild:!0,...a,focusable:!s,active:f,children:d.jsx(ih,{disabled:s,required:i.required,checked:f,...c,...o,name:i.name,ref:l,onCheck:()=>i.onValueChange(o.value),onKeyDown:Le(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:Le(o.onFocus,()=>{p.current&&u.current?.click()})})})});mh.displayName=ph;var aN="RadioGroupIndicator",hh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,o=uh(n);return d.jsx(ah,{...o,...r,ref:t})});hh.displayName=aN;var lN=fh,cN=mh,dN=hh;function uN({className:e,...t}){return d.jsx(lN,{"data-slot":"radio-group",className:z("grid gap-3",e),...t})}function fN({className:e,...t}){return d.jsx(cN,{"data-slot":"radio-group-item",className:z("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(dN,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:d.jsx(wu,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const gh=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,isRequired:s,className:a,excludedOptionValues:c})=>{const u=e.properties,l=Array.isArray(u?.options)&&u.options.length>0?u.options:Array.isArray(e.options)?e.options:[],f=c?.length?new Set(c.map(String)):null,p=f?l.filter(g=>!f.has(String(g.value??g.label??""))):l,m=S.useCallback(g=>{n(g),r?.()},[n,r]);return d.jsx(Et,{field:e,error:o,isRequired:s,className:a,children:d.jsx(uN,{value:t||"",onValueChange:m,disabled:i||e.disabled||p.length===0,className:"flex flex-col space-y-2","aria-required":s,children:p.length===0?d.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"No available options"}):p.map(g=>d.jsxs("div",{className:"flex items-center space-x-3",children:[d.jsx(fN,{id:`${ht(e)}-${g.value}`,value:g.value,disabled:g.disabled,className:z(o&&"border-destructive")}),d.jsxs(Er,{htmlFor:`${ht(e)}-${g.value}`,className:z("text-sm font-normal cursor-pointer",g.disabled&&"text-muted-foreground cursor-not-allowed"),children:[g.label,g.description&&d.jsx("span",{className:"block text-xs text-muted-foreground",children:g.description})]})]},g.value))})})},yh=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=e.properties,l=S.useCallback(C=>{n(C.target.value)},[n]),f=C=>{if(C)return C==="today"?new Date().toISOString().split("T")[0]:C},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 d.jsxs("div",{className:z("space-y-2 w-fit",v==="left"&&"flex items-start gap-4",c),children:[x&&d.jsxs(Er,{id:Gi(e),htmlFor:ht(e),className:z("text-sm font-medium",v==="left"&&"w-32 pt-2 text-right",o&&"text-destructive"),children:[e.label,a&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),d.jsxs("div",{className:"w-fit",children:[d.jsxs("div",{className:"relative w-fit max-w-full",children:[d.jsx(iw,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),d.jsx(Cr,{id:ht(e),type:h,value:t||"",onChange:l,onBlur:r,disabled:i||e.disabled,readOnly:s||e.readOnly,min:p,max:m,"aria-describedby":$t(e,!!o),"aria-invalid":Qt(!!o),"aria-required":a,className:z(w[y],"pl-10 w-fit",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]}),e.description&&!o&&d.jsx("p",{id:Go(e),className:"mt-1.5 text-xs text-muted-foreground",children:e.description}),o&&d.jsx("p",{id:qo(e),className:"mt-1.5 text-xs text-destructive",role:"alert",children:o})]})]})};function xo(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(2))+" "+n[r]}function oc(e,t){return e===1&&t===1}const bh=/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?|$)/i;function ic(e){return e.type.startsWith("image/")?!0:bh.test(e.name)}function Xs(e){try{const t=e.split("?")[0];return bh.test(t)}catch{return!1}}function sc({items:e,maxFiles:t,disabled:n,objectUrls:r,failedUrlKeys:o,onImageUrlError:i,onRemove:s,onOpenUrl:a,resolveOpenUrl:c,addSlot:u,className:l}){const f=S.useCallback(p=>{try{return p.split("?")[0].split("/").filter(Boolean).pop()||p}catch{return p}},[]);return d.jsxs("div",{"data-file-like-strip":!0,"data-remove-in-dropzone":!0,className:z("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?r[m]??null:h&&Xs(y)&&!v?y:null,C=g&&ic(p)&&!!x||!!h&&Xs(y)&&!v&&!!x,F=g?p.name:h?h.name??f(y):"",N=c?.(m,p),T=h&&y||N||"",k=!!a&&!!T;return d.jsxs("div",{className:"relative h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded overflow-hidden border border-border/60 bg-muted/30",children:[C&&x?d.jsx("img",{src:x,alt:"",className:"absolute inset-0 h-full w-full object-cover",onError:()=>{h&&i(y)}}):d.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-muted/40",children:d.jsx(xu,{className:"h-7 w-7 text-muted-foreground","aria-hidden":!0})}),d.jsxs("div",{className:"absolute top-0.5 right-0.5 z-10 flex items-center gap-0.5",children:[k&&d.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),a(T)},disabled:n,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:d.jsx(Su,{className:"h-3 w-3","aria-hidden":!0})}),d.jsx("button",{type:"button",onClick:A=>{A.preventDefault(),A.stopPropagation(),s(m)},disabled:n,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-destructive hover:bg-background focus:outline-none focus:ring-2 focus:ring-destructive","aria-label":"Remove file",title:"Remove file",children:d.jsx(Jo,{className:"h-3 w-3","aria-hidden":!0})})]}),!C&&F&&d.jsx("span",{className:"sr-only",children:F})]},w+(g?p.name+p.size:""))}),u]})}function ac(e){const[t,n]=S.useState([]);return S.useEffect(()=>{const r=e.map(o=>o instanceof File&&ic(o)?URL.createObjectURL(o):null);return n(r),()=>{r.forEach(o=>{o&&URL.revokeObjectURL(o)})}},[e]),t}function lc({item:e,objectUrl:t,failedUrlKeys:n,onImageUrlError:r,onRemove:o,onOpenUrl:i,openTarget:s,disabled:a}){const c=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&&n.has(f),m=u?t:l&&Xs(f)&&!p?f:null,g=u&&ic(e)&&!!m||!!l&&Xs(f)&&!p&&!!m,h=u?e.name:l?l.name??c(f):"",y=(s?.trim()||f||"").trim(),w=!!i&&!!y;return d.jsxs("div",{"data-file-like-full-bleed":!0,"data-remove-in-dropzone":!0,className:"relative h-full w-full min-h-[58px] min-w-0 flex items-center justify-center",children:[g&&m?d.jsx("img",{src:m,alt:"",className:"absolute inset-0 h-full w-full rounded object-cover",onError:()=>{l&&r(f)}}):d.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded bg-muted/40",children:d.jsx(xu,{className:"h-8 w-8 text-muted-foreground","aria-hidden":!0})}),d.jsxs("div",{className:"absolute top-1 right-1 z-10 flex items-center gap-1",children:[w&&y&&d.jsx("button",{type:"button",onClick:v=>{v.preventDefault(),v.stopPropagation(),i(y)},disabled:a,className:"inline-flex h-6 w-6 items-center justify-center rounded bg-background/85 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:d.jsx(Su,{className:"h-3.5 w-3.5","aria-hidden":!0})}),d.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:d.jsx(Jo,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),!g&&h&&d.jsx("p",{className:"sr-only",children:h})]})}const pN=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,isRequired:s,className:a,buttonResponses:c})=>{const{gridStretch:u}=Ro(),l=u&&zi(e),f=e.properties,p=S.useRef(null),[m,g]=S.useState(!1),[h,y]=S.useState(),[w,v]=S.useState(()=>new Set),[x,C]=S.useState(0),F=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,N=Vi(e),T=S.useMemo(()=>Ui(t),[t]),[k,A]=S.useState(null);S.useEffect(()=>{A(null)},[t,x]);const O=k??T,E=ac(O),L=e.validation?.find(ye=>ye.type==="fileSize"),G=e.validation?.find(ye=>ye.type==="fileType"),I=L?.value?L.value:f?.maxSize??F?.maxSize??10*1024*1024,$=G?.value?G.value:f?.accept??F?.accept??[],D=Array.isArray($)?$.join(","):"",B=()=>{O.length>=N||p.current?.click()},M=S.useCallback(ye=>{if(L){const Se=Xn(ye,L);if(Se!==!0)return typeof Se=="string"?Se:"File size exceeds the maximum allowed size"}else if(ye.size>I)return`File size must be less than ${xo(I)}`;if(G){const Se=Xn(ye,G);if(Se!==!0)return typeof Se=="string"?Se:"File type is not allowed"}return null},[L,G,I]),W=S.useCallback(ye=>{const Se=za(ye,N);n(Se),r?.()},[n,r,N]),j=S.useCallback(ye=>{y(void 0);const Se=Array.from(ye),ae=[...O];let ve=null;for(const He of Se){if(ae.length>=N)break;const dt=M(He);if(dt){ve||(ve=dt);continue}ae.push(He)}if(ve&&ae.length===O.length){y(ve);return}ve&&y(ve),A(ae),W(ae)},[O,N,M,W]),ie=S.useCallback(ye=>{const Se=ye.target.files;Se&&Se.length>0&&j(Se),p.current&&(p.current.value="")},[j]),H=S.useCallback(ye=>{if(i)return;const Se=O.filter((ae,ve)=>ve!==ye);C(ae=>ae+1),A(Se),W(Se)},[i,O,W]),U=ye=>{ye.preventDefault(),g(!0)},J=()=>{g(!1)},de=ye=>{ye.preventDefault(),g(!1),ye.dataTransfer.files?.length&&j(ye.dataTransfer.files)},ne=o||h,q=[];(L||I)&&q.push(`Max size: ${xo(I)}`),G&&$.length>0&&q.push(`Allowed types: ${$.join(", ")}`),N>1&&q.push(`Up to ${N} files`);const re=e.appearance?.hideLabel??!1,Te=S.useMemo(()=>{if(!c)return null;const ye=Object.values(c);for(let Se=ye.length-1;Se>=0;Se-=1){const ae=ye[Se],ve=typeof ae?.status=="string"?ae.status.toLowerCase():null;if(ve&&ve!=="success")continue;const He=ae?.code;if(typeof He=="number"&&(He<200||He>=300))continue;const dt=ae?.data,Ke=dt?.file_url||dt?.fileUrl||ae?.file_url||ae?.fileUrl;if(typeof Ke=="string"&&Ke.trim())return Ke}return null},[c]),Q=S.useCallback(ye=>{window.open(ye,"_blank","noopener,noreferrer")},[]),te=S.useCallback(ye=>{v(Se=>new Set(Se).add(ye))},[]),ge=O.length===0,ce=O.length<N,Xe=oc(N,O.length);return d.jsx(Et,{field:e,error:ne,isRequired:s,className:z(a,"!space-y-0"),hideLabel:re,children:d.jsx("div",{className:z("min-h-[70px] min-w-0 w-full flex flex-col",l?"flex-1 h-full":"h-[70px]"),children:d.jsxs("div",{onClick:ye=>{ye.target.closest("[data-remove-in-dropzone]")||ye.target.closest("[data-no-open-picker]")||B()},onDragOver:U,onDragLeave:J,onDrop:de,className:z("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",i&&"opacity-50 cursor-not-allowed",!ce&&O.length>0&&"cursor-default"),children:[d.jsx("input",{ref:p,id:ht(e),type:"file",accept:D,multiple:N>1,onChange:ie,disabled:i||e.disabled||!ce,className:"hidden","aria-describedby":$t(e,!!ne),"aria-invalid":Qt(!!ne),"aria-required":s}),ge?d.jsxs(d.Fragment,{children:[d.jsx(Ji,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),d.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:"Drag & drop or click"}),q.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:q.join(" • ")})]}):Xe?d.jsx(lc,{item:O[0],objectUrl:E[0]??null,failedUrlKeys:w,onImageUrlError:te,onRemove:()=>H(0),onOpenUrl:Q,openTarget:O[0]instanceof File?Te:void 0,disabled:i||e.disabled}):d.jsx(sc,{items:O,maxFiles:N,disabled:i,objectUrls:E,failedUrlKeys:w,onImageUrlError:te,onRemove:H,resolveOpenUrl:(ye,Se)=>Se instanceof File&&O.length===1&&Te?.trim()?Te.trim():null,onOpenUrl:ye=>{ye?.trim()&&Q(ye.trim())},addSlot:ce?d.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:ye=>{ye.stopPropagation(),p.current?.click()},disabled:i||e.disabled,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center text-muted-foreground hover:border-primary hover:bg-primary/5 text-[10px] leading-tight px-0.5",children:[d.jsx(Ji,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})]})})})};function mN(e){const t=hN(e),n=b.forwardRef((r,o)=>{const{children:i,...s}=r,a=b.Children.toArray(i),c=a.find(yN);if(c){const u=c.props.children,l=a.map(f=>f===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:f);return d.jsx(t,{...s,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,l):null})}return d.jsx(t,{...s,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function hN(e){const t=b.forwardRef((n,r)=>{const{children:o,...i}=n;if(b.isValidElement(o)){const s=vN(o),a=bN(i,o.props);return o.type!==b.Fragment&&(a.ref=r?Ur(r,s):s),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var gN=Symbol("radix.slottable");function yN(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===gN}function bN(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{const c=i(...a);return o(...a),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function vN(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Js="Dialog",[vh]=Sn(Js),[wN,Hn]=vh(Js),wh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!0}=e,a=b.useRef(null),c=b.useRef(null),[u,l]=er({prop:r,defaultProp:o??!1,onChange:i,caller:Js});return d.jsx(wN,{scope:t,triggerRef:a,contentRef:c,contentId:lr(),titleId:lr(),descriptionId:lr(),open:u,onOpenChange:l,onOpenToggle:b.useCallback(()=>l(f=>!f),[l]),modal:s,children:n})};wh.displayName=Js;var Sh="DialogTrigger",SN=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Hn(Sh,n),i=Ze(t,o.triggerRef);return d.jsx($e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":uc(o.open),...r,ref:i,onClick:Le(e.onClick,o.onOpenToggle)})});SN.displayName=Sh;var cc="DialogPortal",[xN,xh]=vh(cc,{forceMount:void 0}),Ah=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=Hn(cc,t);return d.jsx(xN,{scope:t,forceMount:n,children:b.Children.map(r,s=>d.jsx(Cn,{present:n||i.open,children:d.jsx(us,{asChild:!0,container:o,children:s})}))})};Ah.displayName=cc;var Qs="DialogOverlay",Ch=b.forwardRef((e,t)=>{const n=xh(Qs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Hn(Qs,e.__scopeDialog);return i.modal?d.jsx(Cn,{present:r||i.open,children:d.jsx(CN,{...o,ref:t})}):null});Ch.displayName=Qs;var AN=mN("DialogOverlay.RemoveScroll"),CN=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Hn(Qs,n);return d.jsx(vs,{as:AN,allowPinchZoom:!0,shards:[o.contentRef],children:d.jsx($e.div,{"data-state":uc(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Jr="DialogContent",Eh=b.forwardRef((e,t)=>{const n=xh(Jr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Hn(Jr,e.__scopeDialog);return d.jsx(Cn,{present:r||i.open,children:i.modal?d.jsx(EN,{...o,ref:t}):d.jsx(NN,{...o,ref:t})})});Eh.displayName=Jr;var EN=b.forwardRef((e,t)=>{const n=Hn(Jr,e.__scopeDialog),r=b.useRef(null),o=Ze(t,n.contentRef,r);return b.useEffect(()=>{const i=r.current;if(i)return wl(i)},[]),d.jsx(Nh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Le(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Le(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&i.preventDefault()}),onFocusOutside:Le(e.onFocusOutside,i=>i.preventDefault())})}),NN=b.forwardRef((e,t)=>{const n=Hn(Jr,e.__scopeDialog),r=b.useRef(!1),o=b.useRef(!1);return d.jsx(Nh,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),Nh=b.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...s}=e,a=Hn(Jr,n),c=b.useRef(null),u=Ze(t,c);return tl(),d.jsxs(d.Fragment,{children:[d.jsx(Zi,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:d.jsx(Qi,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":uc(a.open),...s,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(_N,{titleId:a.titleId}),d.jsx(FN,{contentRef:c,descriptionId:a.descriptionId})]})]})}),dc="DialogTitle",kh=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Hn(dc,n);return d.jsx($e.h2,{id:o.titleId,...r,ref:t})});kh.displayName=dc;var _h="DialogDescription",kN=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Hn(_h,n);return d.jsx($e.p,{id:o.descriptionId,...r,ref:t})});kN.displayName=_h;var Th="DialogClose",Fh=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Hn(Th,n);return d.jsx($e.button,{type:"button",...r,ref:t,onClick:Le(e.onClick,()=>o.onOpenChange(!1))})});Fh.displayName=Th;function uc(e){return e?"open":"closed"}var Ph="DialogTitleWarning",[eI,Oh]=fw(Ph,{contentName:Jr,titleName:dc,docsSlug:"dialog"}),_N=({titleId:e})=>{const t=Oh(Ph),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
46
|
+
`)},DC=0,No=[];function BC(e){var t=b.useRef([]),r=b.useRef([0,0]),n=b.useRef(),o=b.useState(DC++)[0],s=b.useState(Wp)[0],i=b.useRef(e);b.useEffect(function(){i.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=oC([e.lockRef.current],(e.shards||[]).map(Jp),!0).filter(Boolean);return h.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=b.useCallback(function(h,y){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!i.current.allowPinchZoom;var S=Di(h),w=r.current,A="deltaX"in h?h.deltaX:w[0]-S[0],x="deltaY"in h?h.deltaY:w[1]-S[1],F,N=h.target,k=Math.abs(A)>Math.abs(x)?"h":"v";if("touches"in h&&k==="h"&&N.type==="range")return!1;var T=window.getSelection(),P=T&&T.anchorNode,E=P?P===N||P.contains(N):!1;if(E)return!1;var C=Kp(k,N);if(!C)return!0;if(C?F=k:(F=k==="v"?"h":"v",C=Kp(k,N)),!C)return!1;if(!n.current&&"changedTouches"in h&&(A||x)&&(n.current=F),!F)return!0;var I=n.current||F;return IC(I,y,h,I==="h"?A:x)},[]),c=b.useCallback(function(h){var y=h;if(!(!No.length||No[No.length-1]!==s)){var S="deltaY"in y?Xp(y):Di(y),w=t.current.filter(function(F){return F.name===y.type&&(F.target===y.target||y.target===F.shadowParent)&&MC(F.delta,S)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var A=(i.current.shards||[]).map(Jp).filter(Boolean).filter(function(F){return F.contains(y.target)}),x=A.length>0?a(y,A[0]):!i.current.noIsolation;x&&y.cancelable&&y.preventDefault()}}},[]),u=b.useCallback(function(h,y,S,w){var A={name:h,delta:y,target:S,should:w,shadowParent:$C(S)};t.current.push(A),setTimeout(function(){t.current=t.current.filter(function(x){return x!==A})},1)},[]),f=b.useCallback(function(h){r.current=Di(h),n.current=void 0},[]),l=b.useCallback(function(h){u(h.type,Xp(h),h.target,a(h,e.lockRef.current))},[]),p=b.useCallback(function(h){u(h.type,Di(h),h.target,a(h,e.lockRef.current))},[]);b.useEffect(function(){return No.push(s),e.setCallbacks({onScrollCapture:l,onWheelCapture:l,onTouchMoveCapture:p}),document.addEventListener("wheel",c,Eo),document.addEventListener("touchmove",c,Eo),document.addEventListener("touchstart",f,Eo),function(){No=No.filter(function(h){return h!==s}),document.removeEventListener("wheel",c,Eo),document.removeEventListener("touchmove",c,Eo),document.removeEventListener("touchstart",f,Eo)}},[]);var g=e.removeScrollBar,m=e.inert;return b.createElement(b.Fragment,null,m?b.createElement(s,{styles:LC(o)}):null,g?b.createElement(NC,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function $C(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const jC=pC(Hp,BC);var Bi=b.forwardRef(function(e,t){return b.createElement(Mi,cn({},e,{ref:t,sideCar:jC}))});Bi.classNames=Mi.classNames;var zC=[" ","Enter","ArrowUp","ArrowDown"],UC=[" ","Enter"],to="Select",[$i,ji,VC]=Cl(to),[ko]=vr(to,[VC,_i]),zi=_i(),[HC,Ln]=ko(to),[WC,RC]=ko(to),Qp=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:f,autoComplete:l,disabled:p,required:g,form:m}=e,h=zi(t),[y,S]=b.useState(null),[w,A]=b.useState(null),[x,F]=b.useState(!1),N=bo(u),[k,T]=ln({prop:n,defaultProp:o??!1,onChange:s,caller:to}),[P,E]=ln({prop:i,defaultProp:a,onChange:c,caller:to}),C=b.useRef(null),I=y?m||!!y.closest("form"):!0,[W,M]=b.useState(new Set),z=Array.from(W).map(V=>V.props.value).join(";");return d.jsx(Lp,{...h,children:d.jsxs(HC,{required:g,scope:t,trigger:y,onTriggerChange:S,valueNode:w,onValueNodeChange:A,valueNodeHasChildren:x,onValueNodeHasChildrenChange:F,contentId:hn(),value:P,onValueChange:E,open:k,onOpenChange:T,dir:N,triggerPointerDownPosRef:C,disabled:p,children:[d.jsx($i.Provider,{scope:t,children:d.jsx(WC,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(V=>{M(X=>new Set(X).add(V))},[]),onNativeOptionRemove:b.useCallback(V=>{M(X=>{const L=new Set(X);return L.delete(V),L})},[]),children:r})}),I?d.jsxs(wm,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:l,value:P,onChange:V=>E(V.target.value),disabled:p,form:m,children:[P===void 0?d.jsx("option",{value:""}):null,Array.from(W)]},z):null]})})};Qp.displayName=to;var Zp="SelectTrigger",em=b.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...o}=e,s=zi(r),i=Ln(Zp,r),a=i.disabled||n,c=Qe(t,i.onTriggerChange),u=ji(r),f=b.useRef("touch"),[l,p,g]=xm(h=>{const y=u().filter(A=>!A.disabled),S=y.find(A=>A.value===i.value),w=Am(y,h,S);w!==void 0&&i.onValueChange(w.value)}),m=h=>{a||(i.onOpenChange(!0),g()),h&&(i.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return d.jsx(Wl,{asChild:!0,...s,children:d.jsx(je.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Sm(i.value)?"":void 0,...o,ref:c,onClick:De(o.onClick,h=>{h.currentTarget.focus(),f.current!=="mouse"&&m(h)}),onPointerDown:De(o.onPointerDown,h=>{f.current=h.pointerType;const y=h.target;y.hasPointerCapture(h.pointerId)&&y.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(m(h),h.preventDefault())}),onKeyDown:De(o.onKeyDown,h=>{const y=l.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&p(h.key),!(y&&h.key===" ")&&zC.includes(h.key)&&(m(),h.preventDefault())})})})});em.displayName=Zp;var tm="SelectValue",rm=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,children:s,placeholder:i="",...a}=e,c=Ln(tm,r),{onValueNodeHasChildrenChange:u}=c,f=s!==void 0,l=Qe(t,c.onValueNodeChange);return tr(()=>{u(f)},[u,f]),d.jsx(je.span,{...a,ref:l,style:{pointerEvents:"none"},children:Sm(c.value)?d.jsx(d.Fragment,{children:i}):s})});rm.displayName=tm;var GC="SelectIcon",nm=b.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...o}=e;return d.jsx(je.span,{"aria-hidden":!0,...o,ref:t,children:n||"▼"})});nm.displayName=GC;var KC="SelectPortal",om=e=>d.jsx(Ti,{asChild:!0,...e});om.displayName=KC;var ro="SelectContent",sm=b.forwardRef((e,t)=>{const r=Ln(ro,e.__scopeSelect),[n,o]=b.useState();if(tr(()=>{o(new DocumentFragment)},[]),!r.open){const s=n;return s?js.createPortal(d.jsx(im,{scope:e.__scopeSelect,children:d.jsx($i.Slot,{scope:e.__scopeSelect,children:d.jsx("div",{children:e.children})})}),s):null}return d.jsx(am,{...e,ref:t})});sm.displayName=ro;var Yr=10,[im,Dn]=ko(ro),qC="SelectContentImpl",YC=WA("SelectContent.RemoveScroll"),am=b.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:l,collisionBoundary:p,collisionPadding:g,sticky:m,hideWhenDetached:h,avoidCollisions:y,...S}=e,w=Ln(ro,r),[A,x]=b.useState(null),[F,N]=b.useState(null),k=Qe(t,G=>x(G)),[T,P]=b.useState(null),[E,C]=b.useState(null),I=ji(r),[W,M]=b.useState(!1),z=b.useRef(!1);b.useEffect(()=>{if(A)return Gl(A)},[A]),kl();const V=b.useCallback(G=>{const[ie,...Ce]=I().map(he=>he.ref.current),[ee]=Ce.slice(-1),ne=document.activeElement;for(const he of G)if(he===ne||(he?.scrollIntoView({block:"nearest"}),he===ie&&F&&(F.scrollTop=0),he===ee&&F&&(F.scrollTop=F.scrollHeight),he?.focus(),document.activeElement!==ne))return},[I,F]),X=b.useCallback(()=>V([T,A]),[V,T,A]);b.useEffect(()=>{W&&X()},[W,X]);const{onOpenChange:L,triggerPointerDownPosRef:B}=w;b.useEffect(()=>{if(A){let G={x:0,y:0};const ie=ee=>{G={x:Math.abs(Math.round(ee.pageX)-(B.current?.x??0)),y:Math.abs(Math.round(ee.pageY)-(B.current?.y??0))}},Ce=ee=>{G.x<=10&&G.y<=10?ee.preventDefault():A.contains(ee.target)||L(!1),document.removeEventListener("pointermove",ie),B.current=null};return B.current!==null&&(document.addEventListener("pointermove",ie),document.addEventListener("pointerup",Ce,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ie),document.removeEventListener("pointerup",Ce,{capture:!0})}}},[A,L,B]),b.useEffect(()=>{const G=()=>L(!1);return window.addEventListener("blur",G),window.addEventListener("resize",G),()=>{window.removeEventListener("blur",G),window.removeEventListener("resize",G)}},[L]);const[D,K]=xm(G=>{const ie=I().filter(ne=>!ne.disabled),Ce=ie.find(ne=>ne.ref.current===document.activeElement),ee=Am(ie,G,Ce);ee&&setTimeout(()=>ee.ref.current.focus())}),ae=b.useCallback((G,ie,Ce)=>{const ee=!z.current&&!Ce;(w.value!==void 0&&w.value===ie||ee)&&(P(G),ee&&(z.current=!0))},[w.value]),j=b.useCallback(()=>A?.focus(),[A]),U=b.useCallback((G,ie,Ce)=>{const ee=!z.current&&!Ce;(w.value!==void 0&&w.value===ie||ee)&&C(G)},[w.value]),le=n==="popper"?Jl:lm,oe=le===Jl?{side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:l,collisionBoundary:p,collisionPadding:g,sticky:m,hideWhenDetached:h,avoidCollisions:y}:{};return d.jsx(im,{scope:r,content:A,viewport:F,onViewportChange:N,itemRefCallback:ae,selectedItem:T,onItemLeave:j,itemTextRefCallback:U,focusSelectedItem:X,selectedItemText:E,position:n,isPositioned:W,searchRef:D,children:d.jsx(Bi,{as:YC,allowPinchZoom:!0,children:d.jsx(yi,{asChild:!0,trapped:w.open,onMountAutoFocus:G=>{G.preventDefault()},onUnmountAutoFocus:De(o,G=>{w.trigger?.focus({preventScroll:!0}),G.preventDefault()}),children:d.jsx(gi,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:G=>G.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:d.jsx(le,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:G=>G.preventDefault(),...S,...oe,onPlaced:()=>M(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:De(S.onKeyDown,G=>{const ie=G.ctrlKey||G.altKey||G.metaKey;if(G.key==="Tab"&&G.preventDefault(),!ie&&G.key.length===1&&K(G.key),["ArrowUp","ArrowDown","Home","End"].includes(G.key)){let ee=I().filter(ne=>!ne.disabled).map(ne=>ne.ref.current);if(["ArrowUp","End"].includes(G.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(G.key)){const ne=G.target,he=ee.indexOf(ne);ee=ee.slice(he+1)}setTimeout(()=>V(ee)),G.preventDefault()}})})})})})})});am.displayName=qC;var XC="SelectItemAlignedPosition",lm=b.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...o}=e,s=Ln(ro,r),i=Dn(ro,r),[a,c]=b.useState(null),[u,f]=b.useState(null),l=Qe(t,k=>f(k)),p=ji(r),g=b.useRef(!1),m=b.useRef(!0),{viewport:h,selectedItem:y,selectedItemText:S,focusSelectedItem:w}=i,A=b.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&h&&y&&S){const k=s.trigger.getBoundingClientRect(),T=u.getBoundingClientRect(),P=s.valueNode.getBoundingClientRect(),E=S.getBoundingClientRect();if(s.dir!=="rtl"){const ne=E.left-T.left,he=P.left-ne,Ie=k.left-he,Ue=k.width+Ie,re=Math.max(Ue,T.width),ge=window.innerWidth-Yr,Se=us(he,[Yr,Math.max(Yr,ge-re)]);a.style.minWidth=Ue+"px",a.style.left=Se+"px"}else{const ne=T.right-E.right,he=window.innerWidth-P.right-ne,Ie=window.innerWidth-k.right-he,Ue=k.width+Ie,re=Math.max(Ue,T.width),ge=window.innerWidth-Yr,Se=us(he,[Yr,Math.max(Yr,ge-re)]);a.style.minWidth=Ue+"px",a.style.right=Se+"px"}const C=p(),I=window.innerHeight-Yr*2,W=h.scrollHeight,M=window.getComputedStyle(u),z=parseInt(M.borderTopWidth,10),V=parseInt(M.paddingTop,10),X=parseInt(M.borderBottomWidth,10),L=parseInt(M.paddingBottom,10),B=z+V+W+L+X,D=Math.min(y.offsetHeight*5,B),K=window.getComputedStyle(h),ae=parseInt(K.paddingTop,10),j=parseInt(K.paddingBottom,10),U=k.top+k.height/2-Yr,le=I-U,oe=y.offsetHeight/2,G=y.offsetTop+oe,ie=z+V+G,Ce=B-ie;if(ie<=U){const ne=C.length>0&&y===C[C.length-1].ref.current;a.style.bottom="0px";const he=u.clientHeight-h.offsetTop-h.offsetHeight,Ie=Math.max(le,oe+(ne?j:0)+he+X),Ue=ie+Ie;a.style.height=Ue+"px"}else{const ne=C.length>0&&y===C[0].ref.current;a.style.top="0px";const Ie=Math.max(U,z+h.offsetTop+(ne?ae:0)+oe)+Ce;a.style.height=Ie+"px",h.scrollTop=ie-U+h.offsetTop}a.style.margin=`${Yr}px 0`,a.style.minHeight=D+"px",a.style.maxHeight=I+"px",n?.(),requestAnimationFrame(()=>g.current=!0)}},[p,s.trigger,s.valueNode,a,u,h,y,S,s.dir,n]);tr(()=>A(),[A]);const[x,F]=b.useState();tr(()=>{u&&F(window.getComputedStyle(u).zIndex)},[u]);const N=b.useCallback(k=>{k&&m.current===!0&&(A(),w?.(),m.current=!1)},[A,w]);return d.jsx(QC,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:g,onScrollButtonChange:N,children:d.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:x},children:d.jsx(je.div,{...o,ref:l,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});lm.displayName=XC;var JC="SelectPopperPosition",Jl=b.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:o=Yr,...s}=e,i=zi(r);return d.jsx(Dp,{...i,...s,ref:t,align:n,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Jl.displayName=JC;var[QC,Ql]=ko(ro,{}),Zl="SelectViewport",cm=b.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...o}=e,s=Dn(Zl,r),i=Ql(Zl,r),a=Qe(t,s.onViewportChange),c=b.useRef(0);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),d.jsx($i.Slot,{scope:r,children:d.jsx(je.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:De(o.onScroll,u=>{const f=u.currentTarget,{contentWrapper:l,shouldExpandOnScrollRef:p}=i;if(p?.current&&l){const g=Math.abs(c.current-f.scrollTop);if(g>0){const m=window.innerHeight-Yr*2,h=parseFloat(l.style.minHeight),y=parseFloat(l.style.height),S=Math.max(h,y);if(S<m){const w=S+g,A=Math.min(m,w),x=w-A;l.style.height=A+"px",l.style.bottom==="0px"&&(f.scrollTop=x>0?x:0,l.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})});cm.displayName=Zl;var dm="SelectGroup",[ZC,eE]=ko(dm),tE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=hn();return d.jsx(ZC,{scope:r,id:o,children:d.jsx(je.div,{role:"group","aria-labelledby":o,...n,ref:t})})});tE.displayName=dm;var um="SelectLabel",rE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=eE(um,r);return d.jsx(je.div,{id:o.id,...n,ref:t})});rE.displayName=um;var Ui="SelectItem",[nE,fm]=ko(Ui),pm=b.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:o=!1,textValue:s,...i}=e,a=Ln(Ui,r),c=Dn(Ui,r),u=a.value===n,[f,l]=b.useState(s??""),[p,g]=b.useState(!1),m=Qe(t,w=>c.itemRefCallback?.(w,n,o)),h=hn(),y=b.useRef("touch"),S=()=>{o||(a.onValueChange(n),a.onOpenChange(!1))};if(n==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d.jsx(nE,{scope:r,value:n,disabled:o,textId:h,isSelected:u,onItemTextChange:b.useCallback(w=>{l(A=>A||(w?.textContent??"").trim())},[]),children:d.jsx($i.ItemSlot,{scope:r,value:n,disabled:o,textValue:f,children:d.jsx(je.div,{role:"option","aria-labelledby":h,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:m,onFocus:De(i.onFocus,()=>g(!0)),onBlur:De(i.onBlur,()=>g(!1)),onClick:De(i.onClick,()=>{y.current!=="mouse"&&S()}),onPointerUp:De(i.onPointerUp,()=>{y.current==="mouse"&&S()}),onPointerDown:De(i.onPointerDown,w=>{y.current=w.pointerType}),onPointerMove:De(i.onPointerMove,w=>{y.current=w.pointerType,o?c.onItemLeave?.():y.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:De(i.onPointerLeave,w=>{w.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:De(i.onKeyDown,w=>{c.searchRef?.current!==""&&w.key===" "||(UC.includes(w.key)&&S(),w.key===" "&&w.preventDefault())})})})})});pm.displayName=Ui;var gs="SelectItemText",mm=b.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,...s}=e,i=Ln(gs,r),a=Dn(gs,r),c=fm(gs,r),u=RC(gs,r),[f,l]=b.useState(null),p=Qe(t,S=>l(S),c.onItemTextChange,S=>a.itemTextRefCallback?.(S,c.value,c.disabled)),g=f?.textContent,m=b.useMemo(()=>d.jsx("option",{value:c.value,disabled:c.disabled,children:g},c.value),[c.disabled,c.value,g]),{onNativeOptionAdd:h,onNativeOptionRemove:y}=u;return tr(()=>(h(m),()=>y(m)),[h,y,m]),d.jsxs(d.Fragment,{children:[d.jsx(je.span,{id:c.textId,...s,ref:p}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?js.createPortal(s.children,i.valueNode):null]})});mm.displayName=gs;var hm="SelectItemIndicator",gm=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return fm(hm,r).isSelected?d.jsx(je.span,{"aria-hidden":!0,...n,ref:t}):null});gm.displayName=hm;var ec="SelectScrollUpButton",ym=b.forwardRef((e,t)=>{const r=Dn(ec,e.__scopeSelect),n=Ql(ec,e.__scopeSelect),[o,s]=b.useState(!1),i=Qe(t,n.onScrollButtonChange);return tr(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=r.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?d.jsx(vm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=r;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});ym.displayName=ec;var tc="SelectScrollDownButton",bm=b.forwardRef((e,t)=>{const r=Dn(tc,e.__scopeSelect),n=Ql(tc,e.__scopeSelect),[o,s]=b.useState(!1),i=Qe(t,n.onScrollButtonChange);return tr(()=>{if(r.viewport&&r.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,f=Math.ceil(c.scrollTop)<u;s(f)};const c=r.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),o?d.jsx(vm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=r;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});bm.displayName=tc;var vm=b.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...o}=e,s=Dn("SelectScrollButton",r),i=b.useRef(null),a=ji(r),c=b.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return b.useEffect(()=>()=>c(),[c]),tr(()=>{a().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),d.jsx(je.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:De(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(n,50))}),onPointerMove:De(o.onPointerMove,()=>{s.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(n,50))}),onPointerLeave:De(o.onPointerLeave,()=>{c()})})}),oE="SelectSeparator",sE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return d.jsx(je.div,{"aria-hidden":!0,...n,ref:t})});sE.displayName=oE;var rc="SelectArrow",iE=b.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=zi(r),s=Ln(rc,r),i=Dn(rc,r);return s.open&&i.position==="popper"?d.jsx(Bp,{...o,...n,ref:t}):null});iE.displayName=rc;var aE="SelectBubbleInput",wm=b.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const o=b.useRef(null),s=Qe(n,o),i=hs(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&f){const l=new Event("change",{bubbles:!0});f.call(a,t),a.dispatchEvent(l)}},[i,t]),d.jsx(je.select,{...r,style:{...$p,...r.style},ref:s,defaultValue:t})});wm.displayName=aE;function Sm(e){return e===""||e===void 0}function xm(e){const t=cr(e),r=b.useRef(""),n=b.useRef(0),o=b.useCallback(i=>{const a=r.current+i;t(a),(function c(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>c(""),1e3))})(a)},[t]),s=b.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,o,s]}function Am(e,t,r){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=r?e.indexOf(r):-1;let i=lE(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==r));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==r?c:void 0}function lE(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var cE=Qp,dE=em,uE=rm,fE=nm,pE=om,mE=sm,hE=cm,gE=pm,yE=mm,bE=gm,vE=ym,wE=bm;function SE({...e}){return d.jsx(cE,{"data-slot":"select",...e})}function xE({className:e,...t}){return d.jsx(uE,{"data-slot":"select-value",className:H("truncate min-w-0",e),...t})}function AE({className:e,size:t="default",children:r,...n}){const o=e?.includes("w-full");return d.jsxs(dE,{"data-slot":"select-trigger","data-size":t,className:H("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",o&&"min-w-0",e),...n,children:[r,d.jsx(fE,{asChild:!0,children:d.jsx(ts,{className:"size-4 opacity-50"})})]})}function CE({className:e,children:t,position:r="popper",...n}){return d.jsx(pE,{children:d.jsxs(mE,{"data-slot":"select-content",className:H("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...n,children:[d.jsx(EE,{}),d.jsx(hE,{className:H("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),d.jsx(NE,{})]})})}function nc({className:e,children:t,...r}){return d.jsxs(gE,{"data-slot":"select-item",className:H("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...r,children:[d.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:d.jsx(bE,{children:d.jsx(oi,{className:"size-4"})})}),d.jsx(yE,{className:"truncate",children:t})]})}function EE({className:e,...t}){return d.jsx(vE,{"data-slot":"select-scroll-up-button",className:H("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(Zw,{className:"size-4"})})}function NE({className:e,...t}){return d.jsx(wE,{"data-slot":"select-scroll-down-button",className:H("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(ts,{className:"size-4"})})}function Ut(e,t){if(!t||t.trim()===""||e==null)return;const r=t.split(".").filter(Boolean);let n=e;for(const o of r){if(n==null)return;n=n[o]}return n}function Cm(e){const t={array:[],pathPrefixToStrip:""};function r(a,c){if(a===null||typeof a!="object")return null;if(Array.isArray(a)&&a.length>0)return{array:a,fullPath:c};const u=Object.keys(a);for(const f of u){const l=a[f],p=c?`${c}.${f}`:f;if(Array.isArray(l)&&l.length>0)return{array:l,fullPath:p};if(l!==null&&typeof l=="object"){const g=r(l,p);if(g)return g}}return null}const n=r(e,"");if(!n)return t;const{array:o,fullPath:s}=n,i=s?`data.${s}.`:"";return{array:o,pathPrefixToStrip:i}}function kE(e){return e.length>=4&&Array.isArray(e[3])&&e[3].length===0}function _E(e,t,r){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"){const s=String(e);return{label:s,value:s,disabled:!1}}if(e==null)return{label:"",value:"",disabled:!0};if(typeof e!="object"||Array.isArray(e)){const s=Array.isArray(e)?"":String(e);return{label:s,value:s,disabled:!1}}let n,o;if(t){const s=t.includes(".")?Ut(e,t):e[t];n=String(s!==void 0?s:e.label??e.name??e.title??e.text??e.username??e.email??e.value??e.id??"")}else n=String(e.label??e.name??e.title??e.text??e.username??e.email??e.value??e.id??"");if(r){const s=r.includes(".")?Ut(e,r):e[r];o=String(s!==void 0?s:e.value??e.id??e.key??e.email??e.username??e.label??e.name??"")}else o=String(e.value??e.id??e.key??e.email??e.username??e.label??e.name??"");return{label:String(n??""),value:String(o??""),disabled:!!e.disabled}}function ys(e,t,r){if(!e)return[];if(Array.isArray(e)){if(e.length===0)return[];if(kE(e))return[];const n=e.filter(o=>o!=null);return n.length===0?[]:n.every(o=>typeof o=="string")?n.map(o=>({label:o,value:o,disabled:!1})):n.map(o=>_E(o,t,r))}if(typeof e=="object"){const{array:n,pathPrefixToStrip:o}=Cm(e);if(Array.isArray(n)&&n.length>0){const s=c=>!c||!c.trim()||!o?c:c.startsWith(o)?c.substring(o.length).replace(/^\.+/,"")||void 0:c,i=s(t),a=s(r);return ys(n,i,a)}}return[]}function TE(e){return!Array.isArray(e)||e.length===0?[]:e.filter(t=>t!=null).map((t,r)=>{if(typeof t=="string")return{label:t,value:t};if(typeof t=="object"&&t!==null){const n=t.label||t.value||String(t),o=t.value||t.label||String(t);return!n&&!o?{label:`Option ${r+1}`,value:String(r)}:{label:String(n),value:String(o),disabled:t.disabled||!1}}return{label:String(t),value:String(t)}})}function FE(e){return Array.isArray(e)&&e.length>=4&&Array.isArray(e[3])&&e[3].length>0&&Array.isArray(e[3][0])}function PE(e,t,r){if(!e)return[];try{const o=new URL(e).searchParams.get(t);return o?o.split(r).map(s=>s.trim()).filter(Boolean):[]}catch{const n=e.indexOf("?");if(n<0)return[];const o=e.slice(n+1);try{const i=new URLSearchParams(o).get(t);return i?i.split(r).map(a=>a.trim()).filter(Boolean):[]}catch{return[]}}}function Em(e){const{response:t,sourceUrl:r,rowsIndex:n,rowsPath:o,columns:s,columnsQueryParam:i="sf",columnsQueryParamSeparator:a=","}=e;let c;if(o&&o.trim()?c=Ut(t,o):typeof n=="number"?c=t?.[n]:c=t,!Array.isArray(c)||c.length===0)return[];const u=c.filter(p=>Array.isArray(p));if(u.length===0)return Array.isArray(c[0])?[]:null;if(!Array.isArray(u[0]))return null;const f=PE(r,i,a),l=f.length>0?f:Array.isArray(s)&&s.length>0?s:[];return u.map(p=>{const g={};return(l.length>0?l:Array.from({length:p.length},(h,y)=>`col${y}`)).forEach((h,y)=>{g[h]=p[y]}),g})}function OE(e){const{rows:t,apiLabelField:r,apiLabelFields:n,apiLabelSeparator:o,apiValueField:s}=e;if(!Array.isArray(t)||t.length===0)return[];const i=t.filter(l=>l!=null&&typeof l=="object"&&!Array.isArray(l));if(i.length===0)return[];const a=Array.isArray(n)?n.filter(Boolean):[],c=o??" - ",u=l=>{if(r){const p=r.includes(".")?Ut(l,r):l?.[r];if(p!=null&&String(p).trim()!=="")return String(p)}return String(l?.label??l?.name??l?.title??l?.text??l?.username??l?.email??l?.value??l?.id??l)},f=(l,p)=>{if(s){const g=s.includes(".")?Ut(l,s):l?.[s];if(g!=null)return String(g)}return String(l?.value??l?.id??l?.key??l?.email??l?.username??l?.label??l?.name??p??l)};return i.map(l=>{let p="";a.length>0&&(p=a.map(h=>Ut(l,h)).filter(h=>h!=null&&String(h).trim()!=="").map(h=>String(h)).join(c)),p||(p=u(l));const g=f(l,p);return{label:typeof p=="string"?p:String(p??""),value:typeof g=="string"?g:String(g??""),disabled:!!l?.disabled}})}function Nm(e){return e!=null&&!Array.isArray(e)&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean")}function IE(e,t){const{array:r,pathPrefixToStrip:n}=Cm(e);if(!Array.isArray(r)||r.length===0)return null;const o=new Set([t]);n&&t.startsWith(n)&&o.add(t.slice(n.length).replace(/^\.+/,""));const s=t.match(/^data\.data\.(.+)$/);s?.[1]&&o.add(s[1]);const i=r[0];for(const a of o){if(!a)continue;const c=a.includes(".")?Ut(i,a):i?.[a];if(Nm(c))return String(c)}return null}function ME(e,t,r){if(e==null)return null;const n=t?.trim(),o=r?.trim()||n;if(!n&&!o)return null;if(n){const i=Ut(e,n);if(Nm(i))return String(i);const a=IE(e,n);if(a!=null)return a}const s=ys(e,o,n||o);if(s.length>0){const i=s[0].value;if(i!=null&&String(i).trim()!=="")return String(i)}return null}function LE(e){if(e?.token!=null&&String(e.token).trim()!=="")return String(e.token);const t=ds(),r=t?.Authorization??t?.authorization;if(r?.trim()){const n=r.match(/^Bearer\s+(.+)$/i);return n?n[1]:r}}function km(e,t){const r=LE(t);if(!r)return e;let n=e.replace(/\{token\}/g,r);return n=n.replace(/\{authorization\}/gi,()=>r.startsWith("Bearer ")?r:`Bearer ${r}`),n}function Bn(e,t){const r={},{formValues:n={},submissionContext:o,apiRealtime:s}=t;for(const{key:i,value:a}of e??[]){const c=i?.trim();if(!c||a==null)continue;let u=nl(String(a),n,o,s);u=km(u,o),r[c]=u}return r}const DE=new Set(["authorization"]);function BE(e){return DE.has(e.trim().toLowerCase())}function Vi(e){return(e??[]).filter(t=>!BE(t.key))}function Hi(e){if(!e?.length)return null;const t=e.find(r=>r.key.toLowerCase()==="authorization");if(t?.value?.trim()){const r=t.value.trim();if(r.toLowerCase().startsWith("basic ")){const n=r.slice(6).trim();if(n.includes("{")||n.includes("}")){const o=n.split(":");if(o.length>=2)return{type:"basic",username:o[0].trim(),password:o.slice(1).join(":").trim()}}try{const o=atob(n),s=o.indexOf(":");if(s>=0)return{type:"basic",username:o.slice(0,s),password:o.slice(s+1)}}catch{return{type:"basic",username:"",password:""}}}return r.toLowerCase().startsWith("bearer ")?{type:"bearer",token:r.slice(7).trim()}:{type:"bearer",token:r}}return null}function $E(e){return!e||e.type==="none"?{type:"none"}:e.type==="bearer"?{type:"bearer",token:e.token?.trim()??""}:e.type==="apiKey"?{type:"apiKey",headerName:e.headerName?.trim()||"X-API-Key",apiKey:e.apiKey?.trim()??""}:{type:"basic",username:e.username?.trim()??"",password:e.password?.trim()??""}}function Wi(e,t){const{formValues:r={},submissionContext:n,urlParams:o={},apiRealtime:s}=t;let i=Lr(e,r,o,n);return i=km(i,n),s!==void 0&&(i=nl(i,r,n,s)),i}function Ri(e,t={}){const r=$E(e),n={};if(r.type==="bearer"){const o=r.token??"";if(!o.trim())return n;const s=Wi(o,t).trim();return s&&(n.Authorization=s.toLowerCase().startsWith("bearer ")?s:`Bearer ${s}`),n}if(r.type==="apiKey"){const o=r.apiKey??"";return o.trim()&&(n[r.headerName||"X-API-Key"]=Wi(o,t)),n}if(r.type==="basic"){const o=r.username??"",s=r.password??"";if(!o.trim()&&!s.trim())return n;const i=Wi(o,t),a=Wi(s,t);n.Authorization=`Basic ${btoa(`${i}:${a}`)}`}return n}function _m({field:e,formValues:t={},submissionContext:r}){const n=e.properties,o=n?.apiEndpoint?{apiEndpoint:n.apiEndpoint,apiMethod:n.apiMethod,apiKey:n.apiKey,apiRealtime:n.apiRealtime,apiAutoDetect:n.apiAutoDetect,apiLabelField:n.apiLabelField,apiValueField:n.apiValueField,apiQueryParams:n.apiQueryParams,apiClientFilter:n.apiClientFilter,apiHeaders:n.apiHeaders,apiBodyFields:n.apiBodyFields,apiAuth:n.apiAuth,valueSource:n.valueSource,optionsSource:n.optionsSource}:null,s=e.apidata||null,i=o||s,[a,c]=v.useState([]),[u,f]=v.useState([]),[l,p]=v.useState([]),[g,m]=v.useState(!1),[h,y]=v.useState(null),S=!!(i?.apiEndpoint&&(i?.valueSource==="api"||i?.optionsSource==="api"||n?.valueSource==="api"||n?.optionsSource==="api")),w=e.options||n?.options||[],A=v.useMemo(()=>TE(Array.isArray(w)?w:[]),[w]),x=v.useMemo(()=>{const E=i?.apiEndpoint||n?.apiEndpoint||"",C=i?.apiQueryParams||n?.apiQueryParams;return po(E,C)},[i?.apiEndpoint,n?.apiEndpoint,i?.apiQueryParams,n?.apiQueryParams]),F=v.useMemo(()=>{const E=new Set;for(const I of n?.dependentFields??[])typeof I=="string"&&I.trim()&&E.add(I.trim());const C=i?.apiClientFilter?.matchField?.trim()||n?.apiClientFilter?.matchField?.trim();return C&&E.add(C),[...E]},[n?.dependentFields,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField]),N=v.useMemo(()=>{const E=new Set([...x,...F]);if(E.size===0)return null;const C={};return E.forEach(I=>{C[I]=t[I]}),JSON.stringify(C)},[x,F,t]),k=v.useMemo(()=>JSON.stringify(r||{}),[r]),T=v.useMemo(()=>{const E=new Set;e.name?.trim()&&E.add(e.name.trim());const C=e.key;return typeof C=="string"&&C.trim()&&E.add(C.trim()),[...E]},[e.name,e.key]);return v.useEffect(()=>{const E=i?.apiEndpoint;if(!S||!E){c([]);return}let C=!1;return(async()=>{a.length===0&&m(!0),y(null);try{const M=i?.apiMethod||n?.apiMethod||"GET",z=i?.apiRealtime||n?.apiRealtime,V=i?.apiQueryParams||n?.apiQueryParams||{},X=Qs({apiEndpoint:E,apiMethod:M,apiQueryParams:V,formValues:t,submissionContext:r,apiRealtime:z,additionalRequiredFieldNames:F,excludeFormFieldNames:T});if(X.blocked){C||(c([]),m(!1));return}const L={"Content-Type":"application/json"},B=i?.apiKey||n?.apiKey;B&&(L["X-CSCAPI-KEY"]=B);const D=i?.apiAuth??n?.apiAuth??s?.apiAuth??Hi(i?.apiHeaders??n?.apiHeaders??s?.apiHeaders)??{type:"none"},K=Ri(D,{formValues:t,submissionContext:r,apiRealtime:z});Object.assign(L,K);const ae=i?.apiHeaders??n?.apiHeaders??s?.apiHeaders,j=i?.apiBodyFields??n?.apiBodyFields??s?.apiBodyFields,U=Bn(Vi(ae),{formValues:t,submissionContext:r,apiRealtime:z});Object.assign(L,U);const le=Bn(j,{formValues:t,submissionContext:r,apiRealtime:z}),oe={method:M.toLowerCase(),url:Mr(X.url),headers:L};(X.postBodyBase!=null||Object.keys(le).length>0)&&(oe.data={...X.postBodyBase??{},...le});const G=await Ct(oe),ie=i?.apiLabelField||n?.apiLabelField,Ce=i?.apiValueField||n?.apiValueField,ee=G.data;let ne=[];Array.isArray(ee)?ne=ee:ee?.data&&(Array.isArray(ee.data)?ne=ee.data:ee.data?.data&&Array.isArray(ee.data.data)?ne=ee.data.data:ee.data.districts?ne=ee.data.districts:ee.data.states?ne=ee.data.states:ee.data.cities&&(ne=ee.data.cities)),p(ne);const he=ys(G.data,ie,Ce);f(he);const Ie=i?.apiClientFilter||n?.apiClientFilter;let Ue=he;if(Ie?.filterField&&Ie?.matchField){const re=t[Ie.matchField];re!=null?Ue=he.filter(ge=>{const Se=ne.find(Dt=>String(Ut(Dt,Ce||"code"))===String(ge.value));if(!Se)return!1;const pt=Ut(Se,Ie.filterField);return String(pt)===String(re)}):Ue=[]}C||c(Ue)}catch(M){if(C)return;let z="Failed to load options";if(M.response){const V=M.response.data;M.response.status===404?z="API endpoint not found.":M.response.status===401?z="Authentication failed.":typeof V=="string"?z=V:V&&typeof V=="object"&&(z=V.error||V.message||V.detail||z)}else M.message&&(z=String(M.message));y(z),a.length===0&&c([])}finally{C||m(!1)}})(),()=>{C=!0}},[S,i?.apiEndpoint,i?.apiMethod,n?.apiEndpoint,n?.apiMethod,N,F,T,k]),v.useEffect(()=>{const E=i?.apiClientFilter||n?.apiClientFilter;if(!S||!E||l.length===0)return;const C=t[E.matchField],I=i?.apiValueField||n?.apiValueField;if(C==null){c([]);return}const W=u.filter(M=>{const z=l.find(X=>String(Ut(X,I||"code"))===String(M.value));if(!z)return!1;const V=Ut(z,E.filterField);return String(V)===String(C)});c(W)},[S,i?.apiClientFilter?.matchField,n?.apiClientFilter?.matchField,i?.apiClientFilter?.filterField,n?.apiClientFilter?.filterField,i?.apiValueField,n?.apiValueField,t[i?.apiClientFilter?.matchField||n?.apiClientFilter?.matchField||""],u,l]),{options:S?a:A,isLoadingOptions:g,optionsError:h}}const Tm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,formValues:c={},submissionContext:u,excludedOptionValues:f,isPrepopulateTarget:l=!1})=>{const p=e.properties,g=p?.apiEndpoint?{apiEndpoint:p.apiEndpoint,valueSource:p.valueSource,optionsSource:p.optionsSource}:null,m=e.apidata||null,h=g||m,y=!!(h?.apiEndpoint&&(h?.valueSource==="api"||h?.optionsSource==="api"||p?.valueSource==="api"||p?.optionsSource==="api")),{options:S,isLoadingOptions:w,optionsError:A}=_m({field:e,formValues:c,submissionContext:u}),x=f?.length?new Set(f.map(String)):null,F=x?S.filter(D=>!x.has(String(D.value??D.label??""))):S,N="__clear__",k=t!=null&&String(t).trim()!=="",T=k?F.some(D=>String(D.value??D.label??"")===String(t)):!1,P=v.useMemo(()=>{if(!k||T)return F;const D=String(t);return[{label:D,value:D},...F]},[F,k,T,t]),E=k?String(t):void 0,C=`${ft(e)}-${E??"empty"}`,I=v.useCallback(D=>{r(D===N?"":D),n?.()},[r,n]),W=e.appearance?.size||"md",M={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},z=e.placeholder||"Select an option",V=p?.apiClientFilter?.matchField?.trim()||h?.apiClientFilter?.matchField?.trim(),X=y&&V&&(c[V]===void 0||c[V]===null||c[V]===""),L=w?"Loading options...":X?`Select ${V} first`:f?.length?"No available options":y?"No options available from API":"No options available";return y&&l&&w?d.jsx(At,{field:e,error:o||A||void 0,isRequired:i,className:a,children:d.jsxs("div",{role:"status","aria-label":"Loading options",className:H("flex items-center justify-center gap-2 w-full min-w-0 rounded-md border border-input bg-muted/50 text-muted-foreground",M[W],e.appearance?.className),children:[d.jsx(mo,{className:"h-4 w-4 animate-spin shrink-0"}),d.jsx("span",{className:"truncate",children:"Loading..."})]})}):d.jsx(At,{field:e,error:o||A||void 0,isRequired:i,className:a,children:d.jsxs(SE,{value:E,onValueChange:I,disabled:s||e.disabled||w&&F.length===0,children:[d.jsx(AE,{id:ft(e),"aria-describedby":Lt(e,!!o||!!A),"aria-invalid":Jt(!!o||!!A),"aria-required":i,className:H("w-full min-w-0",M[W],o&&"border-destructive focus-visible:ring-destructive",A&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:d.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[w&&d.jsx(mo,{className:"h-4 w-4 animate-spin text-muted-foreground shrink-0"}),F.length===0&&f?.length&&!k?d.jsx("span",{className:"text-muted-foreground truncate",children:"No available options"}):k?d.jsx(xE,{placeholder:z}):d.jsx("span",{className:"text-muted-foreground truncate",children:z})]})}),d.jsx(CE,{children:P.length===0?d.jsx(nc,{value:"__no_options__",disabled:!0,children:L}):d.jsxs(d.Fragment,{children:[k?d.jsx(nc,{value:N,children:z}):null,P.map((D,K)=>{const ae=String(D.value??D.label??K);if(ae===N)return null;const j=D.label||D.value||String(D);return d.jsx(nc,{value:ae,disabled:D.disabled||!1,children:j},ae)})]})})]},C)})},Fm=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Pm=Td,Om=(e,t)=>r=>{var n;if(t?.variants==null)return Pm(e,r?.class,r?.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(u=>{const f=r?.[u],l=s?.[u];if(f===null)return null;const p=Fm(f)||Fm(l);return o[u][p]}),a=r&&Object.entries(r).reduce((u,f)=>{let[l,p]=f;return p===void 0||(u[l]=p),u},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,f)=>{let{class:l,className:p,...g}=f;return Object.entries(g).every(m=>{let[h,y]=m;return Array.isArray(y)?y.includes({...s,...a}[h]):{...s,...a}[h]===y})?[...u,l,p]:u},[]);return Pm(e,i,c,r?.class,r?.className)},jE=Om("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all cursor-pointer disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function Zt({className:e,variant:t,size:r,asChild:n=!1,...o}){const s=n?Bu:"button";return d.jsx(s,{"data-slot":"button",className:H(jE({variant:t,size:r,className:e})),...o})}function zE(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var xr=e=>{const{present:t,children:r}=e,n=UE(t),o=typeof r=="function"?r({present:n.isPresent}):b.Children.only(r),s=Qe(n.ref,VE(o));return typeof r=="function"||n.isPresent?b.cloneElement(o,{ref:s}):null};xr.displayName="Presence";function UE(e){const[t,r]=b.useState(),n=b.useRef(null),o=b.useRef(e),s=b.useRef("none"),i=e?"mounted":"unmounted",[a,c]=zE(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const u=Gi(n.current);s.current=a==="mounted"?u:"none"},[a]),tr(()=>{const u=n.current,f=o.current;if(f!==e){const p=s.current,g=Gi(u);e?c("MOUNT"):g==="none"||u?.display==="none"?c("UNMOUNT"):c(f&&p!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),tr(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,l=g=>{const h=Gi(n.current).includes(CSS.escape(g.animationName));if(g.target===t&&h&&(c("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=g=>{g.target===t&&(s.current=Gi(n.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",l),t.addEventListener("animationend",l),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",l),t.removeEventListener("animationend",l)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:b.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function Gi(e){return e?.animationName||"none"}function VE(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function HE(e){const t=WE(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(GE);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function WE(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=qE(o),a=KE(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var RE=Symbol("radix.slottable");function GE(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===RE}function KE(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function qE(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Ki="Popover",[Im]=vr(Ki,[_i]),bs=_i(),[YE,$n]=Im(Ki),Mm=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=bs(t),c=b.useRef(null),[u,f]=b.useState(!1),[l,p]=ln({prop:n,defaultProp:o??!1,onChange:s,caller:Ki});return d.jsx(Lp,{...a,children:d.jsx(YE,{scope:t,contentId:hn(),triggerRef:c,open:l,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(g=>!g),[p]),hasCustomAnchor:u,onCustomAnchorAdd:b.useCallback(()=>f(!0),[]),onCustomAnchorRemove:b.useCallback(()=>f(!1),[]),modal:i,children:r})})};Mm.displayName=Ki;var Lm="PopoverAnchor",Dm=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(Lm,r),s=bs(r),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return b.useEffect(()=>(i(),()=>a()),[i,a]),d.jsx(Wl,{...s,...n,ref:t})});Dm.displayName=Lm;var Bm="PopoverTrigger",$m=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(Bm,r),s=bs(r),i=Qe(t,o.triggerRef),a=d.jsx(je.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Hm(o.open),...n,ref:i,onClick:De(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:d.jsx(Wl,{asChild:!0,...s,children:a})});$m.displayName=Bm;var oc="PopoverPortal",[XE,JE]=Im(oc,{forceMount:void 0}),jm=e=>{const{__scopePopover:t,forceMount:r,children:n,container:o}=e,s=$n(oc,t);return d.jsx(XE,{scope:t,forceMount:r,children:d.jsx(xr,{present:r||s.open,children:d.jsx(Ti,{asChild:!0,container:o,children:n})})})};jm.displayName=oc;var _o="PopoverContent",zm=b.forwardRef((e,t)=>{const r=JE(_o,e.__scopePopover),{forceMount:n=r.forceMount,...o}=e,s=$n(_o,e.__scopePopover);return d.jsx(xr,{present:n||s.open,children:s.modal?d.jsx(ZE,{...o,ref:t}):d.jsx(eN,{...o,ref:t})})});zm.displayName=_o;var QE=HE("PopoverContent.RemoveScroll"),ZE=b.forwardRef((e,t)=>{const r=$n(_o,e.__scopePopover),n=b.useRef(null),o=Qe(t,n),s=b.useRef(!1);return b.useEffect(()=>{const i=n.current;if(i)return Gl(i)},[]),d.jsx(Bi,{as:QE,allowPinchZoom:!0,children:d.jsx(Um,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:De(e.onCloseAutoFocus,i=>{i.preventDefault(),s.current||r.triggerRef.current?.focus()}),onPointerDownOutside:De(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0,u=a.button===2||c;s.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:De(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),eN=b.forwardRef((e,t)=>{const r=$n(_o,e.__scopePopover),n=b.useRef(!1),o=b.useRef(!1);return d.jsx(Um,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(n.current||r.triggerRef.current?.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;r.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Um=b.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:f,...l}=e,p=$n(_o,r),g=bs(r);return kl(),d.jsx(yi,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(gi,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:f,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:d.jsx(Dp,{"data-state":Hm(p.open),role:"dialog",id:p.contentId,...g,...l,ref:t,style:{...l.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Vm="PopoverClose",tN=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=$n(Vm,r);return d.jsx(je.button,{type:"button",...n,ref:t,onClick:De(e.onClick,()=>o.onOpenChange(!1))})});tN.displayName=Vm;var rN="PopoverArrow",nN=b.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,o=bs(r);return d.jsx(Bp,{...o,...n,ref:t})});nN.displayName=rN;function Hm(e){return e?"open":"closed"}var oN=Mm,sN=Dm,iN=$m,aN=jm,lN=zm;function sc({...e}){return d.jsx(oN,{"data-slot":"popover",...e})}function Wm({...e}){return d.jsx(iN,{"data-slot":"popover-trigger",...e})}function ic({className:e,align:t="center",sideOffset:r=4,...n}){return d.jsx(aN,{children:d.jsx(lN,{"data-slot":"popover-content",align:t,sideOffset:r,className:H("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden pointer-events-auto",e),...n})})}function cN({...e}){return d.jsx(sN,{"data-slot":"popover-anchor",...e})}function Rm(e){return JSON.stringify(e).slice(1,-1)}function Gm(e){const t=e.asyncSearchValueObjectKeys;return Array.isArray(t)?t.map(r=>typeof r=="string"?r.trim():"").filter(Boolean):[]}function dN(e){return e.asyncSearchValueMode==="object"&&Gm(e).length>0}function uN(e,t){const r={};for(const n of t){const o=n.trim();if(!o)continue;const s=Ut(e,o);s==null||typeof s=="object"?r[o]="":r[o]=String(s)}return r}function fN(e,t){const r=t.mode??"debounce",n=Math.max(0,t.intervalMs??300),[o,s]=v.useState(()=>r==="throttle"?e:""),i=v.useRef(0),a=v.useRef(void 0);return v.useEffect(()=>{if(e===""){a.current&&clearTimeout(a.current),s("");return}if(r==="debounce"){const f=setTimeout(()=>s(e),n);return()=>clearTimeout(f)}const c=Date.now(),u=c-i.current;return u>=n?(i.current=c,s(e),()=>{a.current&&clearTimeout(a.current)}):(a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i.current=Date.now(),s(e),a.current=void 0},n-u),()=>{a.current&&clearTimeout(a.current)})},[e,r,n]),o}function ac(e,t){if(e==null||e==="")return"";if(t&&typeof e=="object"&&!Array.isArray(e)){const r=e,o=Object.keys(r).sort().map(s=>[s,r[s]??""]);return`O:${JSON.stringify(o)}`}return typeof e=="string"?`S:${e}`:""}function lc(e,t){return e==null||e===""?!0:t&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length===0:!1}function pN(e,t,r){return t.trim()!==""?!0:e==null||e===""?!1:r&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).length>0:typeof e=="string"&&e.length>0}function mN(e){if(Ct.isAxiosError(e)){const t=e.response?.status,r=e.response?.data;if(t===404)return"Search endpoint not found.";if(t===401)return"Authentication failed.";if(r&&typeof r=="object"){const n=r,o=n.error??n.message??n.detail??n.explanation;if(typeof o=="string")return o}if(typeof r=="string")return r;if(t)return`Request failed (${t})`}return e instanceof Error?e.message:"Search failed"}function hN(e){if(e==null)return[];if(Array.isArray(e))return e;const t=e;if(!t?.data)return[];const r=t.data;return Array.isArray(r)?r:r?.data&&Array.isArray(r.data)?r.data:Array.isArray(r?.districts)?r.districts:Array.isArray(r?.states)?r.states:Array.isArray(r?.cities)?r.cities:[]}function Km(e,t){return typeof t=="number"&&t>0?e.slice(0,t):e}function cc(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.label=="string"&&t.value!==null&&t.value!==void 0}const qm=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u={},submissionContext:f})=>{const l=e.properties||{},p=dN(l),g=l.apiEndpoint?.trim()||"",m=l.apiRealtime===!0,h=(l.apiMethod||"GET").toUpperCase()==="POST"?"POST":"GET",y=l.searchInBody===!0,S=h==="POST"||h==="GET"&&y,w=l.searchStrategy??l.searchSchedule??"debounce",A=l.searchIntervalMs??l.intervalMs??300,x=l.minQueryLength??0,F=l.maxResults,N=l.searchQueryParam||"q",k=l.clearable!==!1,T=u,[P,E]=v.useState(()=>lc(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?l.initialDisplayLabel||"":l.initialDisplayLabel||String(t)),[C,I]=v.useState(!1),[W,M]=v.useState([]),[z,V]=v.useState([]),[X,L]=v.useState([]),[B,D]=v.useState(!1),[K,ae]=v.useState(null),[j,U]=v.useState(-1),le=v.useRef(ac(t,p)),oe=v.useRef(lc(t,p)?"":p&&typeof t=="object"&&t!==null&&!Array.isArray(t)?l.initialDisplayLabel||"":l.initialDisplayLabel||String(t??"")),G=v.useRef(void 0),ie=v.useRef(0),Ce=v.useRef(null),ee=fN(P,{mode:w,intervalMs:A}),ne=v.useMemo(()=>W.filter(cc),[W]);v.useEffect(()=>{if(ne.length===0){j!==-1&&U(-1);return}(j<0||j>=ne.length)&&U(0)},[j,ne.length]);const he=v.useMemo(()=>{const J=po(g,l.apiQueryParams),$=new Set(J);for(const fe of l.dependentFields||[])fe&&$.add(fe);return $},[g,l.apiQueryParams,l.dependentFields]),Ie=v.useMemo(()=>{if(he.size===0)return null;const J={};return he.forEach($=>{J[$]=T[$]}),JSON.stringify(J)},[he,T]),Ue=v.useMemo(()=>JSON.stringify(u),[u]),re=v.useMemo(()=>JSON.stringify(f||{}),[f]);v.useEffect(()=>{const J=ac(t,p);if(J===le.current)return;if(le.current=J,lc(t,p)){oe.current="",E(""),M([]),V([]),L([]),ae(null),I(!1);return}const $=l.initialDisplayLabel||(!p&&typeof t=="string"?t:"");oe.current=$,E($)},[t,l.initialDisplayLabel,p]),v.useEffect(()=>{if(!g){M([]),V([]),L([]),D(!1);return}if(i||s||e.disabled){M([]),V([]),L([]),D(!1);return}const J=ee;if(J.length<x){M([]),V([]),L([]),D(!1),ae(null);return}const $=Qs({apiEndpoint:g,apiMethod:h,apiQueryParams:l.apiQueryParams,formValues:T,submissionContext:f,apiRealtime:m,additionalRequiredFieldNames:l.dependentFields});if($.blocked){M([]),V([]),L([]),D(!1),ae(null);return}Ce.current?.abort();const fe=new AbortController;Ce.current=fe;const it=++ie.current;return(async()=>{D(!0),ae(null);const Ye=Mr($.url),Me={};S&&(Me["Content-Type"]="application/json"),l.apiKey&&(Me["X-CSCAPI-KEY"]=l.apiKey);const xe=l.apiAuth??Hi(l.apiHeaders)??{type:"none"},et=Ri(xe,{formValues:T,submissionContext:f,apiRealtime:m});Object.assign(Me,et);const We=Bn(Vi(l.apiHeaders),{formValues:T,submissionContext:f,apiRealtime:m});Object.assign(Me,We);const dt=Bn(l.apiBodyFields,{formValues:T,submissionContext:f,apiRealtime:m});try{let bt;if(!S)bt=(await Qt.get(Ye,{params:{[N]:J},signal:fe.signal,headers:Object.keys(Me).length?Me:void 0})).data;else{let $t={};$.postBodyBase&&Object.keys($.postBodyBase).length>0?$t={...$.postBodyBase}:m&&Object.keys(T).length>0&&($t={...T}),$t={...$t,...dt};let Ht=$t;if(l.searchBodyTemplate?.trim()){let Jr=l.searchBodyTemplate.replace(/\{\{query\}\}/g,()=>Rm(J)).replace(/\{query\}/g,()=>Rm(J));Jr=nl(Jr,T,f,m);const Yt=JSON.parse(Jr);Ht={...$t,...Yt}}else Ht={...$t,[N]:J};bt=(await Qt.post(Ye,Ht,{signal:fe.signal,headers:Object.keys(Me).length?Me:void 0})).data}if(it!==ie.current)return;const ir=l.apiResultsFormat,xt=l.apiResultsConfig,$e=ir==="clinicaltables_v3",gt=FE(bt),kt=$e||ir===void 0&>,nr=ir==="tuple_array";let yr=null;kt?yr=Em({response:bt,sourceUrl:Ye,rowsIndex:xt?.rowsIndex??3,rowsPath:xt?.rowsPath,columns:xt?.columns,columnsQueryParam:xt?.columnsQueryParam??"sf",columnsQueryParamSeparator:xt?.columnsQueryParamSeparator??","}):nr&&(yr=Em({response:bt,sourceUrl:Ye,rowsIndex:xt?.rowsIndex,rowsPath:xt?.rowsPath,columns:xt?.columns,columnsQueryParam:xt?.columnsQueryParam,columnsQueryParamSeparator:xt?.columnsQueryParamSeparator}));const Er=hN(bt),Ot=yr!==null,Nr=yr&&Array.isArray(yr)?yr:Array.isArray(Er)&&Er.every($t=>$t&&typeof $t=="object"&&!Array.isArray($t))?Er:null;L(Nr??Er);const ar=Array.isArray(l.apiLabelFields)&&l.apiLabelFields.length>0,Sn=Nr&&(Ot||ar)?OE({rows:Nr,apiLabelField:l.apiLabelField,apiLabelFields:l.apiLabelFields,apiLabelSeparator:l.apiLabelSeparator,apiValueField:l.apiValueField}):ys(bt,l.apiLabelField,l.apiValueField);V(Sn);const un=l.apiClientFilter;let jr=Sn;if(un?.filterField&&un?.matchField){const $t=T[un.matchField];if($t!=null){const Ht=l.apiValueField;jr=Sn.filter(br=>{const Yt=(Nr??Er).find(Un=>String(Ut(Un,Ht||"code"))===String(br.value));if(!Yt)return!1;const lr=Ut(Yt,un.filterField);return String(lr)===String($t)})}else jr=[]}const zn=Km(jr,F).filter(cc);M(zn),U(zn.length>0?0:-1)}catch(bt){if(Ct.isCancel(bt)||bt?.code==="ERR_CANCELED"||it!==ie.current)return;M([]),V([]),L([]),ae(mN(bt)),U(-1)}finally{it===ie.current&&D(!1)}})(),()=>{fe.abort()}},[ee,g,h,y,S,N,x,F,l.apiKey,l.searchBodyTemplate,l.apiLabelField,l.apiLabelFields,l.apiLabelSeparator,l.apiValueField,l.apiQueryParams,l.apiClientFilter,l.apiResultsFormat,l.apiResultsConfig,l.dependentFields,m,T,f,i,s,e.disabled,Ie,Ue,re]),v.useEffect(()=>{const J=l.apiClientFilter;if(!J||X.length===0||z.length===0)return;const $=T[J.matchField],fe=l.apiValueField;if($==null){M([]);return}const it=z.filter(Ye=>{const Me=X.find(et=>String(Ut(et,fe||"code"))===String(Ye.value));if(!Me)return!1;const xe=Ut(Me,J.filterField);return String(xe)===String($)}),Te=Km(it,F).filter(cc);M(Te),U(Te.length>0?0:-1)},[l.apiClientFilter,l.apiValueField,T,F,z,X]);const ge=s||e.disabled,Se=i||e.readOnly,pt=v.useCallback(J=>{const $=J.target.value;Se||ge||(le.current&&oe.current&&$!==oe.current&&(le.current="",oe.current="",r(p?null:"")),E($),I(!0),U(-1))},[ge,Se,p,r]),Dt=v.useCallback(J=>{const $=typeof J?.label=="string"?J.label:String(J?.value??""),fe=l.apiValueField||"code";if(p){const it=Gm(l),Te=X.find(Ye=>String(Ut(Ye,fe))===String(J.value));if(Te&&typeof Te=="object"&&!Array.isArray(Te)&&it.length>0){const Ye=uN(Te,it);le.current=ac(Ye,!0),oe.current=$,r(Ye),E($)}else le.current=`S:${String(J.value)}`,oe.current=$,r(String(J.value)),E($)}else le.current=`S:${String(J.value)}`,oe.current=$,r(String(J.value)),E($);G.current&&clearTimeout(G.current),I(!1),U(-1),n?.()},[p,n,r,l,X]),Bt=v.useCallback(J=>{J.preventDefault(),J.stopPropagation(),!(ge||Se)&&(le.current="",oe.current="",r(p?null:""),E(""),M([]),V([]),L([]),ae(null),I(!1),n?.())},[ge,Se,p,r,n]),Pt=v.useMemo(()=>C&&!Se&&(B||!!K||ne.length>0||ee.length>=x&&!B),[C,Se,B,K,ne.length,ee,x]),Ar=v.useCallback(J=>{if(!(Se||ge))if(J.key==="ArrowDown")J.preventDefault(),I(!0),U($=>ne.length===0?-1:($+1)%ne.length);else if(J.key==="ArrowUp")J.preventDefault(),I(!0),U($=>ne.length===0?-1:$<=0?ne.length-1:$-1);else if(J.key==="Enter"){const $=j>=0?ne[j]:void 0;Pt&&$&&!$.disabled&&(J.preventDefault(),Dt($))}else J.key==="Escape"&&I(!1)},[ge,Se,j,Pt,ne,Dt]),Nt=e.appearance?.size||"md",Cr={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},Xe=ft(e),ve=Lt(e,!!(o||K)),ce=ee.length>=x&&!B&&!K&&ne.length===0;return d.jsx(At,{field:e,error:o||K||void 0,isRequired:a,className:c,children:d.jsxs(sc,{open:Pt,onOpenChange:J=>{J||I(!1)},children:[d.jsx(cN,{asChild:!0,children:d.jsxs("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:[d.jsx(mn,{id:Xe,role:"combobox","aria-expanded":Pt,"aria-autocomplete":"list","aria-controls":Pt?`${Xe}-listbox`:void 0,"aria-activedescendant":j>=0?`${Xe}-opt-${j}`:void 0,value:P,onChange:pt,onKeyDown:Ar,onFocus:()=>{G.current&&clearTimeout(G.current),!Se&&!ge&&I(!0)},onBlur:()=>{G.current=setTimeout(()=>{I(!1),n?.()},150)},placeholder:e.placeholder||"Search…",disabled:ge,readOnly:Se,"aria-describedby":ve,"aria-invalid":Jt(!!(o||K)),"aria-required":a,className:H("pr-20",Cr[Nt],(o||K)&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)}),d.jsxs("div",{className:"pointer-events-none absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[B&&d.jsx(mo,{className:"pointer-events-none h-4 w-4 animate-spin text-muted-foreground"}),k&&pN(t,P,p)&&!ge&&!Se&&d.jsx(Zt,{type:"button",variant:"ghost",size:"icon",className:"pointer-events-auto h-8 w-8 shrink-0",onMouseDown:J=>J.preventDefault(),onClick:Bt,"aria-label":"Clear",children:d.jsx(ns,{className:"h-4 w-4"})})]})]})}),d.jsx(ic,{className:"p-0 w-[var(--radix-popover-trigger-width)] min-w-[12rem] overflow-hidden",align:"start",onOpenAutoFocus:J=>J.preventDefault(),onCloseAutoFocus:J=>J.preventDefault(),children:d.jsx("div",{id:`${Xe}-listbox`,role:"listbox",children:K?d.jsx("div",{className:"px-3 py-2 text-sm text-destructive",children:K}):B?d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground",children:[d.jsx(mo,{className:"h-4 w-4 animate-spin shrink-0"}),"Loading…"]}):ce?d.jsx("ul",{className:"py-1","aria-label":"Search results",children:d.jsx("li",{role:"option","aria-disabled":!0,className:"cursor-default select-none px-3 py-2 text-sm text-muted-foreground",onMouseDown:J=>J.preventDefault(),children:"No results found"})}):d.jsx("ul",{className:"max-h-60 overflow-y-auto overscroll-contain py-1","aria-label":"Search results",children:ne.map((J,$)=>d.jsx("li",{id:`${Xe}-opt-${$}`,role:"option","aria-selected":j===$,className:H(J.disabled?"cursor-not-allowed opacity-60":"cursor-pointer","px-3 py-2 text-sm",j===$&&"bg-accent text-accent-foreground"),onMouseEnter:()=>U($),onMouseDown:fe=>fe.preventDefault(),onClick:()=>{J.disabled||Dt(J)},children:J.label},`${J.value}-${$}`))})})})]})})};var qi="Checkbox",[gN]=vr(qi),[yN,dc]=gN(qi);function bN(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:o,disabled:s,form:i,name:a,onCheckedChange:c,required:u,value:f="on",internal_do_not_use_render:l}=e,[p,g]=ln({prop:r,defaultProp:o??!1,onChange:c,caller:qi}),[m,h]=b.useState(null),[y,S]=b.useState(null),w=b.useRef(!1),A=m?!!i||!!m.closest("form"):!0,x={checked:p,disabled:s,setChecked:g,control:m,setControl:h,name:a,form:i,value:f,hasConsumerStoppedPropagationRef:w,required:u,defaultChecked:jn(o)?!1:o,isFormControl:A,bubbleInput:y,setBubbleInput:S};return d.jsx(yN,{scope:t,...x,children:vN(l)?l(x):n})}var Ym="CheckboxTrigger",Xm=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},o)=>{const{control:s,value:i,disabled:a,checked:c,required:u,setControl:f,setChecked:l,hasConsumerStoppedPropagationRef:p,isFormControl:g,bubbleInput:m}=dc(Ym,e),h=Qe(o,f),y=b.useRef(c);return b.useEffect(()=>{const S=s?.form;if(S){const w=()=>l(y.current);return S.addEventListener("reset",w),()=>S.removeEventListener("reset",w)}},[s,l]),d.jsx(je.button,{type:"button",role:"checkbox","aria-checked":jn(c)?"mixed":c,"aria-required":u,"data-state":rh(c),"data-disabled":a?"":void 0,disabled:a,value:i,...n,ref:h,onKeyDown:De(t,S=>{S.key==="Enter"&&S.preventDefault()}),onClick:De(r,S=>{l(w=>jn(w)?!0:!w),m&&g&&(p.current=S.isPropagationStopped(),p.current||S.stopPropagation())})})});Xm.displayName=Ym;var Jm=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:o,defaultChecked:s,required:i,disabled:a,value:c,onCheckedChange:u,form:f,...l}=e;return d.jsx(bN,{__scopeCheckbox:r,checked:o,defaultChecked:s,disabled:a,required:i,onCheckedChange:u,name:n,form:f,value:c,internal_do_not_use_render:({isFormControl:p})=>d.jsxs(d.Fragment,{children:[d.jsx(Xm,{...l,ref:t,__scopeCheckbox:r}),p&&d.jsx(th,{__scopeCheckbox:r})]})})});Jm.displayName=qi;var Qm="CheckboxIndicator",Zm=b.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...o}=e,s=dc(Qm,r);return d.jsx(xr,{present:n||jn(s.checked)||s.checked===!0,children:d.jsx(je.span,{"data-state":rh(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});Zm.displayName=Qm;var eh="CheckboxBubbleInput",th=b.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:o,checked:s,defaultChecked:i,required:a,disabled:c,name:u,value:f,form:l,bubbleInput:p,setBubbleInput:g}=dc(eh,e),m=Qe(r,g),h=hs(s),y=ms(n);b.useEffect(()=>{const w=p;if(!w)return;const A=window.HTMLInputElement.prototype,F=Object.getOwnPropertyDescriptor(A,"checked").set,N=!o.current;if(h!==s&&F){const k=new Event("click",{bubbles:N});w.indeterminate=jn(s),F.call(w,jn(s)?!1:s),w.dispatchEvent(k)}},[p,h,s,o]);const S=b.useRef(jn(s)?!1:s);return d.jsx(je.input,{type:"checkbox","aria-hidden":!0,defaultChecked:i??S.current,required:a,disabled:c,name:u,value:f,form:l,...t,tabIndex:-1,ref:m,style:{...t.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});th.displayName=eh;function vN(e){return typeof e=="function"}function jn(e){return e==="indeterminate"}function rh(e){return jn(e)?"indeterminate":e?"checked":"unchecked"}function Yi({className:e,...t}){return d.jsx(Jm,{"data-slot":"checkbox",className:H("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(Zm,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:d.jsx(oi,{className:"size-3.5"})})})}const wN=Om("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-destructive-foreground [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",warning:"border-transparent bg-orange-500 text-white [a&]:hover:bg-orange-600 focus-visible:ring-orange-500/20",success:"border-transparent bg-green-500 text-white [a&]:hover:bg-green-600 focus-visible:ring-green-500/20",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function SN({className:e,variant:t,asChild:r=!1,...n}){const o=r?Bu:"span";return d.jsx(o,{"data-slot":"badge",className:H(wN({variant:t}),e),...n})}function xN(e,t){return b.useReducer((r,n)=>t[r][n]??r,e)}var uc="ScrollArea",[nh]=vr(uc),[AN,Dr]=nh(uc),oh=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=b.useState(null),[u,f]=b.useState(null),[l,p]=b.useState(null),[g,m]=b.useState(null),[h,y]=b.useState(null),[S,w]=b.useState(0),[A,x]=b.useState(0),[F,N]=b.useState(!1),[k,T]=b.useState(!1),P=Qe(t,C=>c(C)),E=bo(o);return d.jsx(AN,{scope:r,type:n,dir:E,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:f,content:l,onContentChange:p,scrollbarX:g,onScrollbarXChange:m,scrollbarXEnabled:F,onScrollbarXEnabledChange:N,scrollbarY:h,onScrollbarYChange:y,scrollbarYEnabled:k,onScrollbarYEnabledChange:T,onCornerWidthChange:w,onCornerHeightChange:x,children:d.jsx(je.div,{dir:E,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":A+"px",...e.style}})})});oh.displayName=uc;var sh="ScrollAreaViewport",ih=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...s}=e,i=Dr(sh,r),a=b.useRef(null),c=Qe(t,a,i.onViewportChange);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),d.jsx(je.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});ih.displayName=sh;var dn="ScrollAreaScrollbar",ah=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Dr(dn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return b.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?d.jsx(CN,{...n,ref:t,forceMount:r}):o.type==="scroll"?d.jsx(EN,{...n,ref:t,forceMount:r}):o.type==="auto"?d.jsx(lh,{...n,ref:t,forceMount:r}):o.type==="always"?d.jsx(fc,{...n,ref:t}):null});ah.displayName=dn;var CN=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Dr(dn,e.__scopeScrollArea),[s,i]=b.useState(!1);return b.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},f=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",f),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",f)}}},[o.scrollArea,o.scrollHideDelay]),d.jsx(xr,{present:r||s,children:d.jsx(lh,{"data-state":s?"visible":"hidden",...n,ref:t})})}),EN=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Dr(dn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Zi(()=>c("SCROLL_END"),100),[a,c]=xN("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return b.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),b.useEffect(()=>{const u=o.viewport,f=s?"scrollLeft":"scrollTop";if(u){let l=u[f];const p=()=>{const g=u[f];l!==g&&(c("SCROLL"),i()),l=g};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,s,c,i]),d.jsx(xr,{present:r||a!=="hidden",children:d.jsx(fc,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:De(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:De(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),lh=b.forwardRef((e,t)=>{const r=Dr(dn,e.__scopeScrollArea),{forceMount:n,...o}=e,[s,i]=b.useState(!1),a=e.orientation==="horizontal",c=Zi(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,f=r.viewport.offsetHeight<r.viewport.scrollHeight;i(a?u:f)}},10);return To(r.viewport,c),To(r.content,c),d.jsx(xr,{present:n||s,children:d.jsx(fc,{"data-state":s?"visible":"hidden",...o,ref:t})})}),fc=b.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=Dr(dn,e.__scopeScrollArea),s=b.useRef(null),i=b.useRef(0),[a,c]=b.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=ph(a.viewport,a.content),f={...n,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function l(p,g){return PN(p,i.current,a,g)}return r==="horizontal"?d.jsx(NN,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,g=mh(p,a,o.dir);s.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=l(p,o.dir))}}):r==="vertical"?d.jsx(kN,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,g=mh(p,a);s.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=l(p))}}):null}),NN=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Dr(dn,e.__scopeScrollArea),[i,a]=b.useState(),c=b.useRef(null),u=Qe(t,c,s.onScrollbarXChange);return b.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),d.jsx(dh,{"data-orientation":"horizontal",...o,ref:u,sizes:r,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Qi(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.x),onDragScroll:f=>e.onDragScroll(f.x),onWheelScroll:(f,l)=>{if(s.viewport){const p=s.viewport.scrollLeft+f.deltaX;e.onWheelScroll(p),gh(p,l)&&f.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Ji(i.paddingLeft),paddingEnd:Ji(i.paddingRight)}})}})}),kN=b.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Dr(dn,e.__scopeScrollArea),[i,a]=b.useState(),c=b.useRef(null),u=Qe(t,c,s.onScrollbarYChange);return b.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),d.jsx(dh,{"data-orientation":"vertical",...o,ref:u,sizes:r,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Qi(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.y),onDragScroll:f=>e.onDragScroll(f.y),onWheelScroll:(f,l)=>{if(s.viewport){const p=s.viewport.scrollTop+f.deltaY;e.onWheelScroll(p),gh(p,l)&&f.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Ji(i.paddingTop),paddingEnd:Ji(i.paddingBottom)}})}})}),[_N,ch]=nh(dn),dh=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:f,onResize:l,...p}=e,g=Dr(dn,r),[m,h]=b.useState(null),y=Qe(t,P=>h(P)),S=b.useRef(null),w=b.useRef(""),A=g.viewport,x=n.content-n.viewport,F=cr(f),N=cr(c),k=Zi(l,10);function T(P){if(S.current){const E=P.clientX-S.current.left,C=P.clientY-S.current.top;u({x:E,y:C})}}return b.useEffect(()=>{const P=E=>{const C=E.target;m?.contains(C)&&F(E,x)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[A,m,x,F]),b.useEffect(N,[n,N]),To(m,k),To(g.content,k),d.jsx(_N,{scope:r,scrollbar:m,hasThumb:o,onThumbChange:cr(s),onThumbPointerUp:cr(i),onThumbPositionChange:N,onThumbPointerDown:cr(a),children:d.jsx(je.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:De(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),S.current=m.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),T(P))}),onPointerMove:De(e.onPointerMove,T),onPointerUp:De(e.onPointerUp,P=>{const E=P.target;E.hasPointerCapture(P.pointerId)&&E.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=w.current,g.viewport&&(g.viewport.style.scrollBehavior=""),S.current=null})})})}),Xi="ScrollAreaThumb",uh=b.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=ch(Xi,e.__scopeScrollArea);return d.jsx(xr,{present:r||o.hasThumb,children:d.jsx(TN,{ref:t,...n})})}),TN=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,s=Dr(Xi,r),i=ch(Xi,r),{onThumbPositionChange:a}=i,c=Qe(t,l=>i.onThumbChange(l)),u=b.useRef(void 0),f=Zi(()=>{u.current&&(u.current(),u.current=void 0)},100);return b.useEffect(()=>{const l=s.viewport;if(l){const p=()=>{if(f(),!u.current){const g=ON(l,a);u.current=g,a()}};return a(),l.addEventListener("scroll",p),()=>l.removeEventListener("scroll",p)}},[s.viewport,f,a]),d.jsx(je.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:De(e.onPointerDownCapture,l=>{const g=l.target.getBoundingClientRect(),m=l.clientX-g.left,h=l.clientY-g.top;i.onThumbPointerDown({x:m,y:h})}),onPointerUp:De(e.onPointerUp,i.onThumbPointerUp)})});uh.displayName=Xi;var pc="ScrollAreaCorner",fh=b.forwardRef((e,t)=>{const r=Dr(pc,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?d.jsx(FN,{...e,ref:t}):null});fh.displayName=pc;var FN=b.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=Dr(pc,r),[s,i]=b.useState(0),[a,c]=b.useState(0),u=!!(s&&a);return To(o.scrollbarX,()=>{const f=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(f),c(f)}),To(o.scrollbarY,()=>{const f=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(f),i(f)}),u?d.jsx(je.div,{...n,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Ji(e){return e?parseInt(e,10):0}function ph(e,t){const r=e/t;return isNaN(r)?0:r}function Qi(e){const t=ph(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function PN(e,t,r,n="ltr"){const o=Qi(r),s=o/2,i=t||s,a=o-i,c=r.scrollbar.paddingStart+i,u=r.scrollbar.size-r.scrollbar.paddingEnd-a,f=r.content-r.viewport,l=n==="ltr"?[0,f]:[f*-1,0];return hh([c,u],l)(e)}function mh(e,t,r="ltr"){const n=Qi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-n,c=r==="ltr"?[0,i]:[i*-1,0],u=us(e,c);return hh([0,i],[0,a])(u)}function hh(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function gh(e,t){return e>0&&e<t}var ON=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return(function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=r.left!==s.left,a=r.top!==s.top;(i||a)&&t(),r=s,n=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(n)};function Zi(e,t){const r=cr(e),n=b.useRef(0);return b.useEffect(()=>()=>window.clearTimeout(n.current),[]),b.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function To(e,t){const r=cr(t);tr(()=>{let n=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return o.observe(e),()=>{window.cancelAnimationFrame(n),o.unobserve(e)}}},[e,r])}var IN=oh,MN=ih,LN=fh;function DN({className:e,children:t,...r}){return d.jsxs(IN,{"data-slot":"scroll-area",className:H("relative",e),...r,children:[d.jsx(MN,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),d.jsx(BN,{}),d.jsx(LN,{})]})}function BN({className:e,orientation:t="vertical",...r}){return d.jsx(ah,{"data-slot":"scroll-area-scrollbar",orientation:t,className:H("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...r,children:d.jsx(uh,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const yh=({field:e,value:t=[],onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,formValues:c={},submissionContext:u,excludedOptionValues:f})=>{const{options:l,isLoadingOptions:p,optionsError:g}=_m({field:e,formValues:c,submissionContext:u}),m=f?.length?new Set(f.map(String)):null,h=m?l.filter(k=>!m.has(String(k.value??k.label??""))):l,y=Array.isArray(t)?t:[],S=y.map(k=>h.find(T=>String(T.value)===String(k))).filter(Boolean),w=v.useCallback(k=>{const T=y.includes(k)?y.filter(P=>P!==k):[...y,k];r(T),n?.()},[y,r,n]),A=v.useCallback(k=>{r(y.filter(T=>T!==k)),n?.()},[y,r,n]),x=e.appearance?.size||"md",F={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},N=S.length>0?`${S.length} selected`:h.length===0&&f?.length?"No available options":e.placeholder||"Select options";return d.jsxs(At,{field:e,error:o||g||void 0,isRequired:i,className:a,children:[d.jsxs(sc,{children:[d.jsx(Wm,{asChild:!0,children:d.jsxs(Zt,{type:"button",variant:"outline",role:"combobox","aria-expanded":void 0,"aria-haspopup":"listbox","aria-multiselectable":"true","aria-describedby":Lt(e,!!o||!!g),"aria-invalid":Jt(!!o||!!g),"aria-required":i,id:ft(e),disabled:s||e.disabled||p,className:H("w-full min-w-0 justify-between font-normal",F[x],o&&"border-destructive focus-visible:ring-destructive",g&&"border-destructive focus-visible:ring-destructive",e.appearance?.className),children:[d.jsx("span",{className:"truncate",children:N}),d.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[p&&d.jsx(mo,{className:"h-4 w-4 animate-spin text-muted-foreground"}),d.jsx(ts,{className:"h-4 w-4 opacity-50"})]})]})}),d.jsx(ic,{className:"w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden",align:"start",children:d.jsx(DN,{className:"h-60 overflow-hidden rounded-md",children:d.jsx("ul",{role:"listbox","aria-multiselectable":"true","aria-label":e.label||e.name||"Options",className:"p-1",children:h.length===0?d.jsx("li",{className:"px-2 py-3 text-sm text-muted-foreground text-center",children:p?"Loading options...":f?.length?"No available options":"No options available"}):h.map(k=>{const T=String(k.value||k.label),P=k.label||k.value||T,E=y.includes(T);return d.jsxs("li",{role:"option","aria-selected":E,className:"flex items-center gap-2 rounded-sm px-2 py-1.5 cursor-pointer hover:bg-accent focus:bg-accent outline-none",onClick:()=>!k.disabled&&w(T),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),k.disabled||w(T))},children:[d.jsx(Yi,{checked:E,disabled:k.disabled,onCheckedChange:()=>!k.disabled&&w(T),onClick:C=>C.stopPropagation(),"aria-hidden":!0,className:"pointer-events-none"}),d.jsx("span",{className:"flex-1 truncate text-sm",children:P})]},T)})})})})]}),S.length>0&&d.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",role:"list","aria-label":"Selected options",children:S.map(k=>{const T=String(k.value||k.label),P=k.label||k.value||T;return d.jsxs(SN,{variant:"secondary",className:"pl-2 pr-1 py-0.5 text-xs font-normal gap-1",children:[d.jsx("span",{className:"truncate max-w-[120px]",children:P}),d.jsx("button",{type:"button","aria-label":`Remove ${P}`,className:"rounded-full p-0.5 hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring",onClick:()=>A(T),tabIndex:-1,children:d.jsx(ns,{className:"h-3 w-3"})})]},T)})})]})},bh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const c=v.useCallback(u=>{r(u===!0),n?.()},[r,n]);return d.jsxs("div",{className:H("space-y-2",a),children:[d.jsxs("div",{className:"flex items-start space-x-3",children:[d.jsx(Yi,{id:ft(e),checked:t||!1,onCheckedChange:c,disabled:s||e.disabled,"aria-describedby":Lt(e,!!o),"aria-required":i,className:H(o&&"border-destructive")}),d.jsxs("div",{className:"grid gap-1.5 leading-none",children:[d.jsxs(Fn,{id:ti(e),htmlFor:ft(e),className:H("text-sm font-medium cursor-pointer",o&&"text-destructive"),children:[e.label,i&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&d.jsx("p",{id:Zo(e),className:"text-xs text-muted-foreground",children:e.description})]})]}),o&&d.jsx("p",{id:es(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var ea="Switch",[$N]=vr(ea),[jN,zN]=$N(ea),vh=b.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:f,...l}=e,[p,g]=b.useState(null),m=Qe(t,A=>g(A)),h=b.useRef(!1),y=p?f||!!p.closest("form"):!0,[S,w]=ln({prop:o,defaultProp:s??!1,onChange:u,caller:ea});return d.jsxs(jN,{scope:r,checked:S,disabled:a,children:[d.jsx(je.button,{type:"button",role:"switch","aria-checked":S,"aria-required":i,"data-state":Ah(S),"data-disabled":a?"":void 0,disabled:a,value:c,...l,ref:m,onClick:De(e.onClick,A=>{w(x=>!x),y&&(h.current=A.isPropagationStopped(),h.current||A.stopPropagation())})}),y&&d.jsx(xh,{control:p,bubbles:!h.current,name:n,value:c,checked:S,required:i,disabled:a,form:f,style:{transform:"translateX(-100%)"}})]})});vh.displayName=ea;var wh="SwitchThumb",Sh=b.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,o=zN(wh,r);return d.jsx(je.span,{"data-state":Ah(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:t})});Sh.displayName=wh;var UN="SwitchBubbleInput",xh=b.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Qe(i,s),c=hs(r),u=ms(t);return b.useEffect(()=>{const f=i.current;if(!f)return;const l=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(l,"checked").set;if(c!==r&&g){const m=new Event("click",{bubbles:n});g.call(f,r),f.dispatchEvent(m)}},[c,r,n]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});xh.displayName=UN;function Ah(e){return e?"checked":"unchecked"}var VN=vh,HN=Sh;function Ch({className:e,...t}){return d.jsx(VN,{"data-slot":"switch",className:H("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(HN,{"data-slot":"switch-thumb",className:H("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const WN=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const c=e.properties;let u=null;if(e.metadata)try{u=typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata}catch{}const f=u?.onValue??c?.onValue??"On",l=u?.offValue??c?.offValue??"Off",p=u?.onText??c?.onText??f,g=u?.offText??c?.offText??l,m=v.useMemo(()=>{const y=t??e.defaultValue??l;return String(y)===String(f)},[t,e.defaultValue,l,f]),h=v.useCallback(y=>{r(y?f:l),n?.()},[r,n,f,l]);return d.jsxs("div",{className:H("space-y-2",a),children:[d.jsxs("div",{className:"space-y-2",children:[e.label&&d.jsxs(Fn,{id:ti(e),htmlFor:ft(e),className:H("text-sm font-medium block",o&&"text-destructive"),children:[e.label,i&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.description&&!o&&d.jsx("p",{id:Zo(e),className:"text-xs text-muted-foreground",children:e.description}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(Ch,{id:ft(e),checked:m,onCheckedChange:h,disabled:s||e.disabled,"aria-describedby":Lt(e,!!o),"aria-required":i,className:H(o&&"opacity-50")}),d.jsx("span",{className:"text-sm text-foreground font-medium",children:m?p:g})]})]}),o&&d.jsx("p",{id:es(e),className:"text-xs text-destructive",role:"alert",children:o})]})};var mc="rovingFocusGroup.onEntryFocus",RN={bubbles:!1,cancelable:!0},vs="RovingFocusGroup",[hc,Eh,GN]=Cl(vs),[KN,ta]=vr(vs,[GN]),[qN,YN]=KN(vs),Nh=b.forwardRef((e,t)=>d.jsx(hc.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(hc.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(XN,{...e,ref:t})})}));Nh.displayName=vs;var XN=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...l}=e,p=b.useRef(null),g=Qe(t,p),m=bo(s),[h,y]=ln({prop:i,defaultProp:a??null,onChange:c,caller:vs}),[S,w]=b.useState(!1),A=cr(u),x=Eh(r),F=b.useRef(!1),[N,k]=b.useState(0);return b.useEffect(()=>{const T=p.current;if(T)return T.addEventListener(mc,A),()=>T.removeEventListener(mc,A)},[A]),d.jsx(qN,{scope:r,orientation:n,dir:m,loop:o,currentTabStopId:h,onItemFocus:b.useCallback(T=>y(T),[y]),onItemShiftTab:b.useCallback(()=>w(!0),[]),onFocusableItemAdd:b.useCallback(()=>k(T=>T+1),[]),onFocusableItemRemove:b.useCallback(()=>k(T=>T-1),[]),children:d.jsx(je.div,{tabIndex:S||N===0?-1:0,"data-orientation":n,...l,ref:g,style:{outline:"none",...e.style},onMouseDown:De(e.onMouseDown,()=>{F.current=!0}),onFocus:De(e.onFocus,T=>{const P=!F.current;if(T.target===T.currentTarget&&P&&!S){const E=new CustomEvent(mc,RN);if(T.currentTarget.dispatchEvent(E),!E.defaultPrevented){const C=x().filter(V=>V.focusable),I=C.find(V=>V.active),W=C.find(V=>V.id===h),z=[I,W,...C].filter(Boolean).map(V=>V.ref.current);Th(z,f)}}F.current=!1}),onBlur:De(e.onBlur,()=>w(!1))})})}),kh="RovingFocusGroupItem",_h=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=hn(),u=s||c,f=YN(kh,r),l=f.currentTabStopId===u,p=Eh(r),{onFocusableItemAdd:g,onFocusableItemRemove:m,currentTabStopId:h}=f;return b.useEffect(()=>{if(n)return g(),()=>m()},[n,g,m]),d.jsx(hc.ItemSlot,{scope:r,id:u,focusable:n,active:o,children:d.jsx(je.span,{tabIndex:l?0:-1,"data-orientation":f.orientation,...a,ref:t,onMouseDown:De(e.onMouseDown,y=>{n?f.onItemFocus(u):y.preventDefault()}),onFocus:De(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:De(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){f.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const S=ZN(y,f.orientation,f.dir);if(S!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let A=p().filter(x=>x.focusable).map(x=>x.ref.current);if(S==="last")A.reverse();else if(S==="prev"||S==="next"){S==="prev"&&A.reverse();const x=A.indexOf(y.currentTarget);A=f.loop?ek(A,x+1):A.slice(x+1)}setTimeout(()=>Th(A))}}),children:typeof i=="function"?i({isCurrentTabStop:l,hasTabStop:h!=null}):i})})});_h.displayName=kh;var JN={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function QN(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ZN(e,t,r){const n=QN(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return JN[n]}function Th(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function ek(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var Fh=Nh,Ph=_h,gc="Radio",[tk,Oh]=vr(gc),[rk,nk]=tk(gc),Ih=b.forwardRef((e,t)=>{const{__scopeRadio:r,name:n,checked:o=!1,required:s,disabled:i,value:a="on",onCheck:c,form:u,...f}=e,[l,p]=b.useState(null),g=Qe(t,y=>p(y)),m=b.useRef(!1),h=l?u||!!l.closest("form"):!0;return d.jsxs(rk,{scope:r,checked:o,disabled:i,children:[d.jsx(je.button,{type:"button",role:"radio","aria-checked":o,"data-state":Bh(o),"data-disabled":i?"":void 0,disabled:i,value:a,...f,ref:g,onClick:De(e.onClick,y=>{o||c?.(),h&&(m.current=y.isPropagationStopped(),m.current||y.stopPropagation())})}),h&&d.jsx(Dh,{control:l,bubbles:!m.current,name:n,value:a,checked:o,required:s,disabled:i,form:u,style:{transform:"translateX(-100%)"}})]})});Ih.displayName=gc;var Mh="RadioIndicator",Lh=b.forwardRef((e,t)=>{const{__scopeRadio:r,forceMount:n,...o}=e,s=nk(Mh,r);return d.jsx(xr,{present:n||s.checked,children:d.jsx(je.span,{"data-state":Bh(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});Lh.displayName=Mh;var ok="RadioBubbleInput",Dh=b.forwardRef(({__scopeRadio:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const i=b.useRef(null),a=Qe(i,s),c=hs(r),u=ms(t);return b.useEffect(()=>{const f=i.current;if(!f)return;const l=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(l,"checked").set;if(c!==r&&g){const m=new Event("click",{bubbles:n});g.call(f,r),f.dispatchEvent(m)}},[c,r,n]),d.jsx(je.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Dh.displayName=ok;function Bh(e){return e?"checked":"unchecked"}var sk=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],ra="RadioGroup",[ik]=vr(ra,[ta,Oh]),$h=ta(),jh=Oh(),[ak,lk]=ik(ra),zh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,name:n,defaultValue:o,value:s,required:i=!1,disabled:a=!1,orientation:c,dir:u,loop:f=!0,onValueChange:l,...p}=e,g=$h(r),m=bo(u),[h,y]=ln({prop:s,defaultProp:o??null,onChange:l,caller:ra});return d.jsx(ak,{scope:r,name:n,required:i,disabled:a,value:h,onValueChange:y,children:d.jsx(Fh,{asChild:!0,...g,orientation:c,dir:m,loop:f,children:d.jsx(je.div,{role:"radiogroup","aria-required":i,"aria-orientation":c,"data-disabled":a?"":void 0,dir:m,...p,ref:t})})})});zh.displayName=ra;var Uh="RadioGroupItem",Vh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,disabled:n,...o}=e,s=lk(Uh,r),i=s.disabled||n,a=$h(r),c=jh(r),u=b.useRef(null),f=Qe(t,u),l=s.value===o.value,p=b.useRef(!1);return b.useEffect(()=>{const g=h=>{sk.includes(h.key)&&(p.current=!0)},m=()=>p.current=!1;return document.addEventListener("keydown",g),document.addEventListener("keyup",m),()=>{document.removeEventListener("keydown",g),document.removeEventListener("keyup",m)}},[]),d.jsx(Ph,{asChild:!0,...a,focusable:!i,active:l,children:d.jsx(Ih,{disabled:i,required:s.required,checked:l,...c,...o,name:s.name,ref:f,onCheck:()=>s.onValueChange(o.value),onKeyDown:De(g=>{g.key==="Enter"&&g.preventDefault()}),onFocus:De(o.onFocus,()=>{p.current&&u.current?.click()})})})});Vh.displayName=Uh;var ck="RadioGroupIndicator",Hh=b.forwardRef((e,t)=>{const{__scopeRadioGroup:r,...n}=e,o=jh(r);return d.jsx(Lh,{...o,...n,ref:t})});Hh.displayName=ck;var dk=zh,uk=Vh,fk=Hh;function pk({className:e,...t}){return d.jsx(dk,{"data-slot":"radio-group",className:H("grid gap-3",e),...t})}function mk({className:e,...t}){return d.jsx(uk,{"data-slot":"radio-group-item",className:H("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(fk,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:d.jsx(Vu,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}const Wh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,excludedOptionValues:c})=>{const u=e.properties,f=Array.isArray(u?.options)&&u.options.length>0?u.options:Array.isArray(e.options)?e.options:[],l=c?.length?new Set(c.map(String)):null,p=l?f.filter(m=>!l.has(String(m.value??m.label??""))):f,g=v.useCallback(m=>{r(m),n?.()},[r,n]);return d.jsx(At,{field:e,error:o,isRequired:i,className:a,children:d.jsx(pk,{value:t||"",onValueChange:g,disabled:s||e.disabled||p.length===0,className:"flex flex-col space-y-2","aria-required":i,children:p.length===0?d.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"No available options"}):p.map(m=>d.jsxs("div",{className:"flex items-center space-x-3",children:[d.jsx(mk,{id:`${ft(e)}-${m.value}`,value:m.value,disabled:m.disabled,className:H(o&&"border-destructive")}),d.jsxs(Fn,{htmlFor:`${ft(e)}-${m.value}`,className:H("text-sm font-normal cursor-pointer",m.disabled&&"text-muted-foreground cursor-not-allowed"),children:[m.label,m.description&&d.jsx("span",{className:"block text-xs text-muted-foreground",children:m.description})]})]},m.value))})})},Rh=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=v.useCallback(x=>{r(x.target.value)},[r]),l=x=>{if(x)return x==="today"?new Date().toISOString().split("T")[0]:x},p=l(u?.minDate),g=l(u?.maxDate),h=(()=>{switch(e.type){case"time":return"time";case"datetime":return"datetime-local";case"daterange":return"date";default:return"date"}})(),y=e.appearance?.size||"md",S={sm:"h-8 text-sm",md:"h-10",lg:"h-12 text-lg"},w=e.appearance?.labelPlacement||"top",A=!e.appearance?.hideLabel&&e.label;return d.jsxs("div",{className:H("space-y-2 w-fit",w==="left"&&"flex items-start gap-4",c),children:[A&&d.jsxs(Fn,{id:ti(e),htmlFor:ft(e),className:H("text-sm font-medium",w==="left"&&"w-32 pt-2 text-right",o&&"text-destructive"),children:[e.label,a&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),d.jsxs("div",{className:"w-fit",children:[d.jsxs("div",{className:"relative w-fit max-w-full",children:[d.jsx(Qw,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),d.jsx(mn,{id:ft(e),type:h,value:t||"",onChange:f,onBlur:n,disabled:s||e.disabled,readOnly:i||e.readOnly,min:p,max:g,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,className:H(S[y],"pl-10 w-fit",o&&"border-destructive focus-visible:ring-destructive",e.appearance?.className)})]}),e.description&&!o&&d.jsx("p",{id:Zo(e),className:"mt-1.5 text-xs text-muted-foreground",children:e.description}),o&&d.jsx("p",{id:es(e),className:"mt-1.5 text-xs text-destructive",role:"alert",children:o})]})]})};function Fo(e){if(e===0)return"0 Bytes";const t=1024,r=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,n)).toFixed(2))+" "+r[n]}function yc(e,t){return e===1&&t===1}const Gh=/\.(jpg|jpeg|png|gif|webp|bmp|svg)(\?|$)/i;function bc(e){return e.type.startsWith("image/")?!0:Gh.test(e.name)}function na(e){try{const t=e.split("?")[0];return Gh.test(t)}catch{return!1}}function vc({items:e,maxFiles:t,disabled:r,objectUrls:n,failedUrlKeys:o,onImageUrlError:s,onRemove:i,onOpenUrl:a,resolveOpenUrl:c,addSlot:u,className:f}){const l=v.useCallback(p=>{try{return p.split("?")[0].split("/").filter(Boolean).pop()||p}catch{return p}},[]);return d.jsxs("div",{"data-file-like-strip":!0,"data-remove-in-dropzone":!0,className:H("relative w-full h-full flex items-center gap-1 min-h-0 overflow-x-auto",f),children:[e.map((p,g)=>{const m=p instanceof File,h=!m&&p&&"url"in p?p:null,y=h?.url??"",S=`${g}-${y}`,w=h&&o.has(y),A=m?n[g]??null:h&&na(y)&&!w?y:null,x=m&&bc(p)&&!!A||!!h&&na(y)&&!w&&!!A,F=m?p.name:h?h.name??l(y):"",N=c?.(g,p),k=h&&y||N||"",T=!!a&&!!k;return d.jsxs("div",{className:"relative h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded overflow-hidden border border-border/60 bg-muted/30",children:[x&&A?d.jsx("img",{src:A,alt:"",className:"absolute inset-0 h-full w-full object-cover",onError:()=>{h&&s(y)}}):d.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-muted/40",children:d.jsx(Wu,{className:"h-7 w-7 text-muted-foreground","aria-hidden":!0})}),d.jsxs("div",{className:"absolute top-0.5 right-0.5 z-10 flex items-center gap-0.5",children:[T&&d.jsx("button",{type:"button",onClick:P=>{P.preventDefault(),P.stopPropagation(),a(k)},disabled:r,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:d.jsx(Hu,{className:"h-3 w-3","aria-hidden":!0})}),d.jsx("button",{type:"button",onClick:P=>{P.preventDefault(),P.stopPropagation(),i(g)},disabled:r,className:"inline-flex h-5 w-5 items-center justify-center rounded bg-background/90 text-destructive hover:bg-background focus:outline-none focus:ring-2 focus:ring-destructive","aria-label":"Remove file",title:"Remove file",children:d.jsx(ns,{className:"h-3 w-3","aria-hidden":!0})})]}),!x&&F&&d.jsx("span",{className:"sr-only",children:F})]},S+(m?p.name+p.size:""))}),u]})}function wc(e){const[t,r]=v.useState([]);return v.useEffect(()=>{const n=e.map(o=>o instanceof File&&bc(o)?URL.createObjectURL(o):null);return r(n),()=>{n.forEach(o=>{o&&URL.revokeObjectURL(o)})}},[e]),t}function Sc({item:e,objectUrl:t,failedUrlKeys:r,onImageUrlError:n,onRemove:o,onOpenUrl:s,openTarget:i,disabled:a}){const c=v.useCallback(w=>{try{return w.split("?")[0].split("/").filter(Boolean).pop()||w}catch{return w}},[]),u=e instanceof File,f=!u&&e&&"url"in e?e:null,l=f?.url??"",p=f&&r.has(l),g=u?t:f&&na(l)&&!p?l:null,m=u&&bc(e)&&!!g||!!f&&na(l)&&!p&&!!g,h=u?e.name:f?f.name??c(l):"",y=(i?.trim()||l||"").trim(),S=!!s&&!!y;return d.jsxs("div",{"data-file-like-full-bleed":!0,"data-remove-in-dropzone":!0,className:"relative h-full w-full min-h-[58px] min-w-0 flex items-center justify-center",children:[m&&g?d.jsx("img",{src:g,alt:"",className:"absolute inset-0 h-full w-full rounded object-cover",onError:()=>{f&&n(l)}}):d.jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded bg-muted/40",children:d.jsx(Wu,{className:"h-8 w-8 text-muted-foreground","aria-hidden":!0})}),d.jsxs("div",{className:"absolute top-1 right-1 z-10 flex items-center gap-1",children:[S&&y&&d.jsx("button",{type:"button",onClick:w=>{w.preventDefault(),w.stopPropagation(),s(y)},disabled:a,className:"inline-flex h-6 w-6 items-center justify-center rounded bg-background/85 text-foreground hover:bg-background focus:outline-none focus:ring-2 focus:ring-primary","aria-label":"Open file",title:"Open file",children:d.jsx(Hu,{className:"h-3.5 w-3.5","aria-hidden":!0})}),d.jsx("button",{type:"button",onClick:w=>{w.preventDefault(),w.stopPropagation(),o()},disabled:a,className:"inline-flex h-6 w-6 items-center justify-center rounded bg-background/85 text-destructive hover:bg-background focus:outline-none focus:ring-2 focus:ring-destructive","aria-label":"Remove file",title:"Remove file",children:d.jsx(ns,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),!m&&h&&d.jsx("p",{className:"sr-only",children:h})]})}const hk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,buttonResponses:c})=>{const{gridStretch:u}=Jo(),f=u&&Ks(e),l=e.properties,p=v.useRef(null),[g,m]=v.useState(!1),[h,y]=v.useState(),[S,w]=v.useState(()=>new Set),[A,x]=v.useState(0),F=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,N=qs(e),k=v.useMemo(()=>Ys(t),[t]),[T,P]=v.useState(null);v.useEffect(()=>{P(null)},[t,A]);const E=T??k,C=wc(E),I=e.validation?.find(re=>re.type==="fileSize"),W=e.validation?.find(re=>re.type==="fileType"),M=I?.value?I.value:l?.maxSize??F?.maxSize??10*1024*1024,z=W?.value?W.value:l?.accept??F?.accept??[],V=Array.isArray(z)?z.join(","):"",X=()=>{E.length>=N||p.current?.click()},L=v.useCallback(re=>{if(I){const ge=rn(re,I);if(ge!==!0)return typeof ge=="string"?ge:"File size exceeds the maximum allowed size"}else if(re.size>M)return`File size must be less than ${Fo(M)}`;if(W){const ge=rn(re,W);if(ge!==!0)return typeof ge=="string"?ge:"File type is not allowed"}return null},[I,W,M]),B=v.useCallback(re=>{const ge=Ja(re,N);r(ge),n?.()},[r,n,N]),D=v.useCallback(re=>{y(void 0);const ge=Array.from(re),Se=[...E];let pt=null;for(const Dt of ge){if(Se.length>=N)break;const Bt=L(Dt);if(Bt){pt||(pt=Bt);continue}Se.push(Dt)}if(pt&&Se.length===E.length){y(pt);return}pt&&y(pt),P(Se),B(Se)},[E,N,L,B]),K=v.useCallback(re=>{const ge=re.target.files;ge&&ge.length>0&&D(ge),p.current&&(p.current.value="")},[D]),ae=v.useCallback(re=>{if(s)return;const ge=E.filter((Se,pt)=>pt!==re);x(Se=>Se+1),P(ge),B(ge)},[s,E,B]),j=re=>{re.preventDefault(),m(!0)},U=()=>{m(!1)},le=re=>{re.preventDefault(),m(!1),re.dataTransfer.files?.length&&D(re.dataTransfer.files)},oe=o||h,G=[];(I||M)&&G.push(`Max size: ${Fo(M)}`),W&&z.length>0&&G.push(`Allowed types: ${z.join(", ")}`),N>1&&G.push(`Up to ${N} files`);const ie=e.appearance?.hideLabel??!1,Ce=v.useMemo(()=>{if(!c)return null;const re=Object.values(c);for(let ge=re.length-1;ge>=0;ge-=1){const Se=re[ge],pt=typeof Se?.status=="string"?Se.status.toLowerCase():null;if(pt&&pt!=="success")continue;const Dt=Se?.code;if(typeof Dt=="number"&&(Dt<200||Dt>=300))continue;const Bt=Se?.data,Pt=Bt?.file_url||Bt?.fileUrl||Se?.file_url||Se?.fileUrl;if(typeof Pt=="string"&&Pt.trim())return Pt}return null},[c]),ee=v.useCallback(re=>{window.open(re,"_blank","noopener,noreferrer")},[]),ne=v.useCallback(re=>{w(ge=>new Set(ge).add(re))},[]),he=E.length===0,Ie=E.length<N,Ue=yc(N,E.length);return d.jsx(At,{field:e,error:oe,isRequired:i,className:H(a,"!space-y-0"),hideLabel:ie,children:d.jsx("div",{className:H("min-h-[70px] min-w-0 w-full flex flex-col",f?"flex-1 h-full":"h-[70px]"),children:d.jsxs("div",{onClick:re=>{re.target.closest("[data-remove-in-dropzone]")||re.target.closest("[data-no-open-picker]")||X()},onDragOver:j,onDragLeave:U,onDrop:le,className:H("border-2 border-dashed rounded-lg p-1.5 text-center cursor-pointer transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",g&&"border-primary bg-primary/10",oe&&"border-destructive",s&&"opacity-50 cursor-not-allowed",!Ie&&E.length>0&&"cursor-default"),children:[d.jsx("input",{ref:p,id:ft(e),type:"file",accept:V,multiple:N>1,onChange:K,disabled:s||e.disabled||!Ie,className:"hidden","aria-describedby":Lt(e,!!oe),"aria-invalid":Jt(!!oe),"aria-required":i}),he?d.jsxs(d.Fragment,{children:[d.jsx(si,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),d.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:"Drag & drop or click"}),G.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:G.join(" • ")})]}):Ue?d.jsx(Sc,{item:E[0],objectUrl:C[0]??null,failedUrlKeys:S,onImageUrlError:ne,onRemove:()=>ae(0),onOpenUrl:ee,openTarget:E[0]instanceof File?Ce:void 0,disabled:s||e.disabled}):d.jsx(vc,{items:E,maxFiles:N,disabled:s,objectUrls:C,failedUrlKeys:S,onImageUrlError:ne,onRemove:ae,resolveOpenUrl:(re,ge)=>ge instanceof File&&E.length===1&&Ce?.trim()?Ce.trim():null,onOpenUrl:re=>{re?.trim()&&ee(re.trim())},addSlot:Ie?d.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:re=>{re.stopPropagation(),p.current?.click()},disabled:s||e.disabled,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center text-muted-foreground hover:border-primary hover:bg-primary/5 text-[10px] leading-tight px-0.5",children:[d.jsx(si,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})]})})})};function gk(e){const t=yk(e),r=b.forwardRef((n,o)=>{const{children:s,...i}=n,a=b.Children.toArray(s),c=a.find(vk);if(c){const u=c.props.children,f=a.map(l=>l===c?b.Children.count(u)>1?b.Children.only(null):b.isValidElement(u)?u.props.children:null:l);return d.jsx(t,{...i,ref:o,children:b.isValidElement(u)?b.cloneElement(u,void 0,f):null})}return d.jsx(t,{...i,ref:o,children:s})});return r.displayName=`${e}.Slot`,r}function yk(e){const t=b.forwardRef((r,n)=>{const{children:o,...s}=r;if(b.isValidElement(o)){const i=Sk(o),a=wk(s,o.props);return o.type!==b.Fragment&&(a.ref=n?qn(n,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var bk=Symbol("radix.slottable");function vk(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===bk}function wk(e,t){const r={...t};for(const n in t){const o=e[n],s=t[n];/^on[A-Z]/.test(n)?o&&s?r[n]=(...a)=>{const c=s(...a);return o(...a),c}:o&&(r[n]=o):n==="style"?r[n]={...o,...s}:n==="className"&&(r[n]=[o,s].filter(Boolean).join(" "))}return{...e,...r}}function Sk(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var oa="Dialog",[Kh]=vr(oa),[xk,Xr]=Kh(oa),qh=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=b.useRef(null),c=b.useRef(null),[u,f]=ln({prop:n,defaultProp:o??!1,onChange:s,caller:oa});return d.jsx(xk,{scope:t,triggerRef:a,contentRef:c,contentId:hn(),titleId:hn(),descriptionId:hn(),open:u,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(l=>!l),[f]),modal:i,children:r})};qh.displayName=oa;var Yh="DialogTrigger",Ak=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(Yh,r),s=Qe(t,o.triggerRef);return d.jsx(je.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Cc(o.open),...n,ref:s,onClick:De(e.onClick,o.onOpenToggle)})});Ak.displayName=Yh;var xc="DialogPortal",[Ck,Xh]=Kh(xc,{forceMount:void 0}),Jh=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,s=Xr(xc,t);return d.jsx(Ck,{scope:t,forceMount:r,children:b.Children.map(n,i=>d.jsx(xr,{present:r||s.open,children:d.jsx(Ti,{asChild:!0,container:o,children:i})}))})};Jh.displayName=xc;var sa="DialogOverlay",Qh=b.forwardRef((e,t)=>{const r=Xh(sa,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Xr(sa,e.__scopeDialog);return s.modal?d.jsx(xr,{present:n||s.open,children:d.jsx(Nk,{...o,ref:t})}):null});Qh.displayName=sa;var Ek=gk("DialogOverlay.RemoveScroll"),Nk=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(sa,r);return d.jsx(Bi,{as:Ek,allowPinchZoom:!0,shards:[o.contentRef],children:d.jsx(je.div,{"data-state":Cc(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),no="DialogContent",Zh=b.forwardRef((e,t)=>{const r=Xh(no,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Xr(no,e.__scopeDialog);return d.jsx(xr,{present:n||s.open,children:s.modal?d.jsx(kk,{...o,ref:t}):d.jsx(_k,{...o,ref:t})})});Zh.displayName=no;var kk=b.forwardRef((e,t)=>{const r=Xr(no,e.__scopeDialog),n=b.useRef(null),o=Qe(t,r.contentRef,n);return b.useEffect(()=>{const s=n.current;if(s)return Gl(s)},[]),d.jsx(eg,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:De(e.onCloseAutoFocus,s=>{s.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:De(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:De(e.onFocusOutside,s=>s.preventDefault())})}),_k=b.forwardRef((e,t)=>{const r=Xr(no,e.__scopeDialog),n=b.useRef(!1),o=b.useRef(!1);return d.jsx(eg,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{e.onCloseAutoFocus?.(s),s.defaultPrevented||(n.current||r.triggerRef.current?.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{e.onInteractOutside?.(s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;r.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),eg=b.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Xr(no,r),c=b.useRef(null),u=Qe(t,c);return kl(),d.jsxs(d.Fragment,{children:[d.jsx(yi,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(gi,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Cc(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(Fk,{titleId:a.titleId}),d.jsx(Ok,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Ac="DialogTitle",tg=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(Ac,r);return d.jsx(je.h2,{id:o.titleId,...n,ref:t})});tg.displayName=Ac;var rg="DialogDescription",Tk=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(rg,r);return d.jsx(je.p,{id:o.descriptionId,...n,ref:t})});Tk.displayName=rg;var ng="DialogClose",og=b.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Xr(ng,r);return d.jsx(je.button,{type:"button",...n,ref:t,onClick:De(e.onClick,()=>o.onOpenChange(!1))})});og.displayName=ng;function Cc(e){return e?"open":"closed"}var sg="DialogTitleWarning",[gM,ig]=Q0(sg,{contentName:no,titleName:Ac,docsSlug:"dialog"}),Fk=({titleId:e})=>{const t=ig(sg),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
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(n))},[n,e]),null},TN="DialogDescriptionWarning",FN=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Oh(TN).contentName}}.`;return b.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},PN=wh,ON=Ah,IN=Ch,MN=Eh,LN=kh,DN=Fh;function BN({...e}){return d.jsx(PN,{"data-slot":"dialog",...e})}function $N({...e}){return d.jsx(ON,{"data-slot":"dialog-portal",...e})}function jN({className:e,...t}){return d.jsx(IN,{"data-slot":"dialog-overlay",className:z("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 zN({className:e,children:t,showCloseButton:n=!0,...r}){return d.jsxs($N,{"data-slot":"dialog-portal",children:[d.jsx(jN,{}),d.jsxs(MN,{"data-slot":"dialog-content",className:z("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),...r,children:[t,n&&d.jsxs(DN,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[d.jsx(Jo,{}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function VN({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-header",className:z("flex flex-col gap-2 text-center sm:text-left",e),...t})}function UN({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-footer",className:z("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function HN({className:e,...t}){return d.jsx(LN,{"data-slot":"dialog-title",className:z("text-lg leading-none font-semibold",e),...t})}async function WN(){const e={width:{ideal:1280},height:{ideal:720}},t=[{facingMode:{ideal:"environment"},...e},{facingMode:{ideal:"user"},...e},{...e},{}];let n;for(const r of t)try{return await navigator.mediaDevices.getUserMedia({video:Object.keys(r).length>0?r:!0,audio:!1})}catch(o){n=o}throw n instanceof Error?n:new Error("Could not access camera")}function Ih(e){const t=()=>e.play();t().catch(()=>{requestAnimationFrame(()=>{t().catch(()=>{const n=()=>{t().catch(()=>{})};e.addEventListener("loadedmetadata",n,{once:!0}),e.addEventListener("canplay",n,{once:!0})})})})}const Mh=({open:e,onOpenChange:t,onCaptured:n,validateFile:r,accept:o,disabled:i,onValidationMessage:s})=>{const a=S.useRef(null),c=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(N=>N.stop()),u.current=null),h()},[h]);S.useEffect(()=>{if(!e){y(),p(null),g(!1);return}if(i)return;let N=!1;return p(null),g(!0),WN().then(T=>{if(N){T.getTracks().forEach(k=>k.stop());return}u.current=T,g(!1)}).catch(T=>{if(N)return;g(!1);const k=T instanceof Error?T.message:"Could not access camera";p(k)}),()=>{N=!0,u.current&&(u.current.getTracks().forEach(T=>T.stop()),u.current=null),h()}},[e,i,y,h]);const w=S.useCallback(N=>{a.current=N,N&&u.current&&e&&!f&&!m&&(N.srcObject=u.current,Ih(N))},[e,f,m]);S.useLayoutEffect(()=>{if(!e||f||m||!u.current)return;let N=!1,T=0;const k=()=>{if(N)return;const O=a.current;!O||!u.current||(O.srcObject=u.current,Ih(O))};k();const A=requestAnimationFrame(()=>{k(),T=requestAnimationFrame(k)});return()=>{N=!0,cancelAnimationFrame(A),cancelAnimationFrame(T),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 N=a.current,T=c.current;if(!N||!T||!u.current||N.readyState<2)return;const k=N.videoWidth,A=N.videoHeight;if(k===0||A===0)return;T.width=k,T.height=A;const O=T.getContext("2d");O&&(O.drawImage(N,0,0),T.toBlob(E=>{if(!E)return;const L=new File([E],`camera-capture-${Date.now()}.jpg`,{type:"image/jpeg",lastModified:Date.now()}),G=r(L);if(G){s?.(G);return}s?.(void 0),n(L),v()},"image/jpeg",.92))},[n,r,v,s]),C=S.useCallback(N=>{const T=N.target.files?.[0];if(!T)return;const k=r(T);if(k){s?.(k);return}s?.(void 0),n(T),v(),l.current&&(l.current.value="")},[n,r,v,s]),F=typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function";return d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:l,type:"file",accept:o,capture:"user",onChange:C,className:"hidden","aria-hidden":!0}),d.jsx("canvas",{ref:c,className:"hidden","aria-hidden":!0}),d.jsx(BN,{open:e,onOpenChange:N=>{N||v()},children:d.jsxs(zN,{className:"sm:max-w-md",showCloseButton:!0,onPointerDownOutside:N=>N.preventDefault(),children:[d.jsx(VN,{children:d.jsx(HN,{children:"Take a photo"})}),f?d.jsxs("div",{className:"space-y-3 py-2",children:[d.jsx("p",{className:"text-sm text-destructive",children:f}),F&&d.jsx("p",{className:"text-xs text-muted-foreground",children:"You can choose an image from your device instead."}),d.jsx(Yt,{type:"button",variant:"outline",className:"w-full",onClick:()=>l.current?.click(),children:"Choose from device"})]}):m?d.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Opening camera…"}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"relative rounded-lg overflow-hidden bg-black aspect-video",children:d.jsx("video",{ref:w,playsInline:!0,muted:!0,className:"w-full h-full object-cover"})}),d.jsxs(UN,{className:"gap-2 sm:gap-0",children:[d.jsx(Yt,{type:"button",variant:"outline",onClick:v,children:"Cancel"}),d.jsx(Yt,{type:"button",onClick:x,children:"Capture photo"})]})]})]})})]})},RN=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,isRequired:s,className:a})=>{const c=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(U=>U.type==="fileSize"),x=e.validation?.find(U=>U.type==="fileType"),C=v?.value!=null?v.value:c?.maxSize??w?.maxSize??5*1024*1024,F=x?.value!=null?x.value:c?.accept??w?.accept??["image/*"],N=F.join(",")||"image/*",T=Vi(e),k=S.useCallback(U=>{if(v){const J=Xn(U,v);if(J!==!0)return typeof J=="string"?J:"File size exceeds the maximum allowed size"}else if(U.size>C)return`File size must be less than ${xo(C)}`;if(x){const J=Xn(U,x);if(J!==!0)return typeof J=="string"?J:"File type is not allowed"}return null},[v,x,C]),A=S.useMemo(()=>Ui(t),[t]),O=ac(A),E=S.useCallback(U=>{const J=za(U,T);n(J),r?.()},[n,r,T]),L=S.useCallback(U=>{const J=k(U);if(J){l(J);return}l(void 0);const de=[...A];de.length>=T||(de.push(U),E(de),y("none"))},[A,T,k,E]),G=S.useCallback(U=>{const J=A.filter((de,ne)=>ne!==U);E(J)},[A,E]),I=S.useCallback(()=>{i||A.length>=T||(l(void 0),y("camera"),p(!0))},[i,A.length,T]),$=S.useCallback(U=>{p(U),U||y("none")},[]),D=o||u,B=e.appearance?.hideLabel??!1,M=[];(v||C)&&M.push(`Max size: ${xo(C)}`),x&&F.length>0&&M.push(`Allowed: ${F.join(", ")}`),T>1&&M.push(`Up to ${T} photos`);const W=S.useCallback(U=>{window.open(U,"_blank","noopener,noreferrer")},[]),j=A.length===0,ie=A.length<T,H=oc(T,A.length);return d.jsxs(Et,{field:e,error:D,isRequired:s,className:z(a,"!space-y-0"),hideLabel:B,children:[d.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:d.jsx("div",{role:"button",tabIndex:i||!ie?-1:0,id:ht(e),onClick:U=>{i||U.target.closest("[data-remove-in-dropzone]")||U.target.closest("[data-no-open-picker]")||A.length>=T||I()},onKeyDown:U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),!i&&ie&&I())},className:z("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",D&&"border-destructive",i&&"opacity-50 cursor-not-allowed",f&&h==="camera"&&"opacity-70 pointer-events-none",!ie&&A.length>0&&"cursor-default"),"aria-describedby":$t(e,!!D),"aria-invalid":Qt(!!D),"aria-required":s,children:j?d.jsxs(d.Fragment,{children:[d.jsx(Yi,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),d.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:f?"Opening camera…":"Click to open camera"}),M.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:M.join(" • ")})]}):H?d.jsx(lc,{item:A[0],objectUrl:O[0]??null,failedUrlKeys:m,onImageUrlError:U=>g(J=>new Set(J).add(U)),onRemove:()=>G(0),onOpenUrl:W,disabled:i}):d.jsx(sc,{items:A,maxFiles:T,disabled:i,objectUrls:O,failedUrlKeys:m,onImageUrlError:U=>g(J=>new Set(J).add(U)),onRemove:G,onOpenUrl:W,addSlot:ie?d.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:U=>{U.stopPropagation(),I()},disabled:i,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center text-muted-foreground hover:border-primary hover:bg-primary/5 text-[10px] leading-tight px-0.5",children:[d.jsx(Yi,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})})}),d.jsx(Mh,{open:f,onOpenChange:$,onCaptured:L,validateFile:k,accept:N,disabled:i,onValidationMessage:l})]})},KN=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,isRequired:s,className:a,buttonResponses:c})=>{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,C=e.validation?.find(Q=>Q.type==="fileSize"),F=e.validation?.find(Q=>Q.type==="fileType"),N=C?.value?C.value:u?.maxSize??x?.maxSize??5*1024*1024,T=F?.value?F.value:u?.accept??x?.accept??["image/*"],k=Array.isArray(T)?T.join(","):"image/*",A=Vi(e),O=S.useCallback(Q=>{if(C){const te=Xn(Q,C);if(te!==!0)return typeof te=="string"?te:"File size exceeds the maximum allowed size"}else if(Q.size>N)return`File size must be less than ${xo(N)}`;if(F){const te=Xn(Q,F);if(te!==!0)return typeof te=="string"?te:"File type is not allowed"}return null},[C,F,N]),E=S.useMemo(()=>Ui(t),[t]),L=ac(E),G=S.useCallback(Q=>{const te=za(Q,A);n(te),r?.()},[n,r,A]),I=S.useCallback(Q=>{p(void 0);const te=Array.from(Q),ge=[...E];let ce=null;for(const Xe of te){if(ge.length>=A)break;const ye=O(Xe);if(ye){ce||(ce=ye);continue}ge.push(Xe)}if(ce&&ge.length===E.length){p(ce);return}ce&&p(ce),G(ge),v("none")},[E,A,O,G]),$=S.useCallback(Q=>{const te=Q.target.files;te&&te.length>0&&I(te),l.current&&(l.current.value="")},[I]),D=S.useCallback(Q=>{G(E.filter((te,ge)=>ge!==Q))},[E,G]),B=S.useCallback(()=>{i||E.length>=A||m||(p(void 0),v("file"),l.current?.click())},[i,E.length,A,m]),M=S.useCallback(()=>{i||E.length>=A||(p(void 0),v("camera"),g(!0))},[i,E.length,A]),W=S.useCallback(Q=>{const te=O(Q);if(te){p(te);return}p(void 0);const ge=[...E];ge.length>=A||(ge.push(Q),G(ge),v("none"))},[E,A,O,G]),j=S.useCallback(Q=>{g(Q),Q||v("none")},[]),ie=o||f,H=e.appearance?.hideLabel??!1,U=[];(C||N)&&U.push(`Max size: ${xo(N)}`),F&&T.length>0&&U.push(`Allowed: ${T.join(", ")}`),A>1&&U.push(`Up to ${A} photos`);const J=S.useMemo(()=>{if(!c)return null;const Q=Object.values(c);for(let te=Q.length-1;te>=0;te-=1){const ge=Q[te],ce=typeof ge?.status=="string"?ge.status.toLowerCase():null;if(ce&&ce!=="success")continue;const Xe=ge?.code;if(typeof Xe=="number"&&(Xe<200||Xe>=300))continue;const ye=ge?.data,Se=ye?.file_url||ye?.fileUrl||ge?.file_url||ge?.fileUrl;if(typeof Se=="string"&&Se.trim())return Se.trim()}return null},[c]),de=S.useCallback(Q=>{window.open(Q,"_blank","noopener,noreferrer")},[]),ne=E.length===0,q=E.length<A,re=oc(A,E.length),Te=q&&!m?d.jsxs("div",{"data-no-open-picker":!0,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center gap-0.5 text-muted-foreground",children:[d.jsx("button",{type:"button",disabled:i,onClick:Q=>{Q.stopPropagation(),B()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-t","aria-label":"Upload file",title:"Upload",children:d.jsx(Ji,{className:"h-4 w-4","aria-hidden":!0})}),d.jsx("button",{type:"button",disabled:i,onClick:Q=>{Q.stopPropagation(),M()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-b border-t border-border/50","aria-label":"Open camera",title:"Camera",children:d.jsx(Yi,{className:"h-4 w-4","aria-hidden":!0})})]}):void 0;return d.jsxs(Et,{field:e,error:ie,isRequired:s,className:z(a,"!space-y-0"),hideLabel:H,children:[d.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:d.jsxs("div",{className:z("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",i&&"opacity-50"),children:[d.jsx("input",{ref:l,id:ht(e),type:"file",accept:k,multiple:A>1,onChange:$,disabled:i||e.disabled||m||!q,className:"hidden","aria-describedby":$t(e,!!ie),"aria-invalid":Qt(!!ie),"aria-required":s}),ne?d.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 w-full pointer-events-auto",children:[d.jsxs("div",{className:"flex items-center justify-center gap-3",children:[d.jsxs("button",{type:"button",disabled:i||m,onClick:B,className:z("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",i&&"pointer-events-none"),children:[d.jsx(Ji,{className:"h-5 w-5","aria-hidden":!0}),d.jsx("span",{children:"Upload"})]}),d.jsxs("button",{type:"button",disabled:i,onClick:M,className:z("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",i&&"pointer-events-none",m&&"opacity-70"),children:[d.jsx(Yi,{className:"h-5 w-5","aria-hidden":!0}),d.jsx("span",{children:"Camera"})]})]}),U.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-2 text-center px-1",children:U.join(" • ")})]}):re?d.jsx(lc,{item:E[0],objectUrl:L[0]??null,failedUrlKeys:h,onImageUrlError:Q=>y(te=>new Set(te).add(Q)),onRemove:()=>D(0),onOpenUrl:de,openTarget:E[0]instanceof File?J:void 0,disabled:i||e.disabled}):d.jsx(sc,{items:E,maxFiles:A,disabled:i,objectUrls:L,failedUrlKeys:h,onImageUrlError:Q=>y(te=>new Set(te).add(Q)),onRemove:D,resolveOpenUrl:(Q,te)=>te instanceof File&&E.length===1&&J?J:null,onOpenUrl:Q=>{Q?.trim()&&de(Q.trim())},addSlot:Te})]})}),d.jsx(Mh,{open:m,onOpenChange:j,onCaptured:W,validateFile:O,accept:k,disabled:i,onValidationMessage:p})]})};function pi(e){if(e instanceof Error){const t=e.message;if(t&&(t.includes("{")||t.includes("[")))try{const n=t.match(/\{[\s\S]*\}/);if(n){const r=JSON.parse(n[0]);return Ao(r)}}catch{}if(e.response){const n=e.response;if(typeof n=="string")try{const r=JSON.parse(n);return Ao(r)}catch{return n}else if(typeof n=="object")return Ao(n)}return t}if(e instanceof pC)return e.response?.data?Ao(e.response.data):e.message||"An unexpected error occurred";if(typeof e=="string")try{const t=JSON.parse(e);return Ao(t)}catch{return e}return typeof e=="object"&&e!==null?Ao(e):"An unexpected error occurred"}function Ao(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(n=>n&&typeof n=="string");if(t.length>0)return t.join(". ")}if(e?.error?.explanation&&Array.isArray(e.error.explanation)){const t=e.error.explanation.filter(n=>n&&typeof n=="string");if(t.length>0)return t.join(". ")}if(e?.explanation&&Array.isArray(e.explanation)){const t=e.explanation.filter(n=>n&&typeof n=="string");if(t.length>0)return t.join(". ")}if(e?.errors&&Array.isArray(e.errors)){const t=e.errors.filter(n=>n!=null&&String(n).trim());if(t.length>0)return t.map(n=>typeof n=="string"?n:n?.message||String(n)).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 GN(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 n=t.data;if(typeof n.message=="string"&&n.message.trim())return n.message.trim();if(typeof n.success_message=="string"&&n.success_message.trim())return n.success_message.trim();if(typeof n.display_message=="string"&&n.display_message.trim())return n.display_message.trim()}if(typeof t.success_message=="string"&&t.success_message.trim())return t.success_message.trim()}function qN(e,t){try{const n=GN(e);Bt.toast.success(n&&n.trim()?n:t)}catch{Bt.toast.success(t)}}function fc(e,t,n){try{const r=n(e);Bt.toast.error(r&&r.trim()?r:t)}catch{Bt.toast.error(t)}}function YN(e){const t=e.headers,n=["X-Message","X-Success-Message","X-Toast-Message","X-Success-Msg"];for(const r of n){const o=t.get(r);if(o&&typeof o=="string"&&o.trim())return o.trim()}}const Zs="This field is required";function Lh(e,t){if(!t?.length)return e;const n=t.find(r=>r.name===e);return n?.label&&n.label.trim()||e}function pc(e,t){if(!e)return"Please complete the required fields.";if(Array.isArray(e)){const i=e.map(s=>{const a=s.message||Zs;if(t?.length&&s.field){const c=Lh(s.field,t);return a===Zs?`${c} is required`:`${c}: ${a}`}return a}).filter(s=>typeof s=="string"&&s.length>0);return i.length===0?"Please complete the required fields.":i.length===1?i[0]:`${i[0]} (and ${i.length-1} more)`}const r=Object.entries(e).map(([o,i])=>{const s=i?.trim()||Zs;if(t?.length){const a=Lh(o,t);return s===Zs?`${a} is required`:`${a}: ${s}`}return s}).filter(o=>typeof o=="string"&&o.length>0);return r.length===0?"Please complete the required fields.":r.length===1?r[0]:`${r[0]} (and ${r.length-1} more)`}function mc(e,t){if(!t?.length)return e;const n=new Map;for(const o of t){const i=o.name||o.key||o.id;i&&n.set(i,o)}const r={};for(const[o,i]of Object.entries(e)){const s=n.get(o);if(s?.type==="selectablelist"&&Array.isArray(i)&&i.length>0){const a=s.properties,c=s.metadata,u=typeof c=="object"&&c!==null?c:null,l=a?.submitFieldMapping??u?.submitFieldMapping;if(l&&typeof l=="object"&&Object.keys(l).length>0){const f=i.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});r[o]=f;continue}}r[o]=i}return r}function ea(e){return!!(e instanceof File||Array.isArray(e)&&e.length>0&&e[0]instanceof File)}function XN(e){return Object.values(e).some(t=>ea(t))}function JN(e,t){const n=new FormData;let r=!1;return Object.entries(e).forEach(([o,i])=>{const s=t?.[o]||o;i instanceof File?(n.append(s,i),r=!0):Array.isArray(i)&&i.length>0&&i[0]instanceof File?(i.forEach(a=>{n.append(s,a)}),r=!0):i!=null&&(typeof i=="object"?n.append(s,JSON.stringify(i)):n.append(s,String(i)))}),r?n:null}function QN(e,t,n){const r={};let o=!1;return Object.entries(e).forEach(([i,s])=>{const a=t?.[i]||i;if(ea(s)){r[a]=s,o=!0;return}const c=n?.[i]||"string";let u=s;if(c==="number"){const l=Number(s);u=isNaN(l)?s:l}else c==="boolean"?u=s==="true"||s===!0||s==="1"||s===1:c==="date"?u=String(s):s!=null?u=typeof s=="object"?s:String(s):u="";r[a]=u}),{transformed:r,hasFiles:o}}const Dh=Object.freeze(Object.defineProperty({__proto__:null,hasFileValues:XN,isFileValue:ea,prepareFormDataWithFiles:JN,transformFormValuesWithFiles:QN},Symbol.toStringTag,{value:"Module"}));function ZN(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 ek(e){if(!Array.isArray(e))return;const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n,o=typeof r.id=="string"&&r.id.trim()?r.id.trim():"",i=typeof r.name=="string"&&r.name.trim()?r.name.trim():"";if(!o||!i)continue;const s=Array.isArray(r.fieldNames)?[...new Set(r.fieldNames.filter(u=>typeof u=="string"&&u.trim().length>0).map(u=>u.trim()))]:[],a=typeof r.payloadKey=="string"&&r.payloadKey.trim()?r.payloadKey.trim():void 0;let c;if(r.fieldPayloadKeys&&typeof r.fieldPayloadKeys=="object"&&!Array.isArray(r.fieldPayloadKeys)){c={};for(const[u,l]of Object.entries(r.fieldPayloadKeys))typeof l=="string"&&l.trim()&&(c[u]=l.trim());Object.keys(c).length===0&&(c=void 0)}t.push({id:o,name:i,fieldNames:s,...r.showBorder===!0?{showBorder:!0}:{},...r.collapsible===!0?{collapsible:!0}:{},...r.defaultCollapsed===!0?{defaultCollapsed:!0}:{},...a?{payloadKey:a}:{},...c?{fieldPayloadKeys:c}:{},...r.heading&&typeof r.heading=="object"?{heading:r.heading}:{}})}return t.length>0?t:void 0}function Bh(e){return e?.mode==="nested_by_section"}function $h(e){const t=e.payloadKey?.trim();return t||null}function jh(e,t){return t.fieldPayloadKeys?.[e]?.trim()||e}function zh(e,t,n,r){if(!Bh(n)||!t?.length)return{...e};const o=new Set([]),i=n?.includeUnassignedAtRoot!==!1,s=new Set,a={};for(const c of t){const u=$h(c);if(!u)continue;const l={};for(const f of c.fieldNames){if(o.has(f)||!(f in e))continue;s.add(f);const p=jh(f,c);l[p]=e[f]}Object.keys(l).length>0&&(a[u]=l)}if(i)for(const[c,u]of Object.entries(e))o.has(c)||s.has(c)||(a[c]=u);return a}function tk(e,t,n){const r={...e??{}};if(!Bh(n)||!t?.length)return r;for(const o of t){const i=$h(o);if(i)for(const s of o.fieldNames){if(r[s]?.trim())continue;const a=jh(s,o);r[s]=`${i}.${a}`}}return r}function nk(e){return e==="null"?null:e==="true"?!0:e==="false"?!1:e}function rk(e){const t=e,n=typeof t?.status=="string"?t.status.toLowerCase():null;if(n&&n!=="success")return!1;const r=t?.code;return!(typeof r=="number"&&(r<200||r>=300))}function ok(e,t){if(!t)return[];const n=e.trim().split(".");if(n.length<2)return[];const r=n[0],o=n.slice(1).join("."),i=[];return Object.entries(t).forEach(([s,a])=>{const c=s===r,u=s.startsWith(`${r}__addmore__`);if(!c&&!u||!rk(a))return;const l=Qe(a,o);l==null||l===""||i.push(l)}),i}function ta(e,t,n,r,o,i){const s=e.trim().match(/^\{respAll:([^}]+)\}$/);if(s){const u=(s[1]||"").trim(),l=u.split("."),f=l.length>=2?l.slice(1).join("."):"";return(f==="data.id"||f==="data.documentId")&&r?.document_ids!=null&&Array.isArray(r.document_ids)?r.document_ids:ok(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 c=Un(e,t,n,r,o,i);return nk(String(c))}const ik=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,readOnly:s,isRequired:a,className:c,onClick:u,onSubmit:l,onReset:f,onCancel:p,isSubmitting:m=!1,formValues:g={},submissionContext:h,bffSubmitApi:y,onBffSubmitResult:w,extraSubmitPayload:v,buttonResponses:x,onButtonApiResponse:C,onValidateForm:F,getValidationErrors:N,allFields:T,onSubmittingChange:k,scopedFormValues:A,scopedFieldNameMap:O,prepopulateResponse:E=null,formSections:L,submitPayload:G})=>{const{gridStretch:I}=Ro(),[$,D]=S.useState(!1),B=e.properties,M=ka.useParams(),W=S.useMemo(()=>({...h,...v}),[h,v]),j=S.useMemo(()=>{if(!A||!O||Object.keys(O).length===0)return g;const Je={};return Object.entries(A).forEach(([Y,je])=>{const gt=O[Y]||Y;gt!==e.name&&(Je[gt]=je)}),Je},[A,O,g,e.name]),H=(()=>{try{const Je=e.metadata;if(typeof Je=="string")return JSON.parse(Je);if(Je&&typeof Je=="object")return Je}catch{}return null})(),U=B?.submitAction??H?.submitAction,J=B?.apiEndpoint??e.apidata?.apiEndpoint??H?.apiEndpoint;let de=B?.action||H?.action;!de&&e.type==="button"&&(de="submit");const ne=B?.variant||"default",q=B?.size||"default",re=B?.hideLabel??e.appearance?.hideLabel??!1,Te=B?.buttonText||e.label||"Button",Q=B?.closeOnCancel??!0,te=async()=>{if(A&&O&&Object.keys(O).length>0||!F)return!0;const Je=await F();if(!Je&&N)try{const Y=N();Bt.toast.error(pc(Y,T??void 0)||"Please fix the errors before submitting.")}catch{Bt.toast.error("Please fix the errors before submitting.")}return Je},ge=async Je=>{if(Je.preventDefault(),(de==="submit"?"submit":de)==="submit"){if(y?.url){if(!await te())return;D(!0),k?.(!0);try{const je=await Xe(),gt=(je?.message??je?.display_message??"Form submitted successfully!").trim();Bt.toast.success(gt||"Form submitted successfully!");const Ie=je!=null&&typeof je=="object"?je:{status:"success",...je!=null?{data:je}:{}};C?.(e.name,Ie)}catch(je){const gt=pi(je);Bt.toast.error(gt)}finally{D(!1),k?.(!1)}return}if(l){if(!await te())return;D(!0),k?.(!0);try{await l(),C?.(e.name,{status:"success"})}finally{D(!1),k?.(!1)}return}Bt.toast.error("Submit not configured. BFF submit API is required for submit buttons.");return}else if(de==="reset"&&f)f();else if(de==="cancel")Q?p&&p():f&&f();else if(de==="download"){const je=B?.downloadApiEndpoint||H?.downloadApiEndpoint||e.downloadApiEndpoint,gt=B?.downloadApiMethod||H?.downloadApiMethod||e.downloadApiMethod;if(je){D(!0);try{const Ie=gt||"GET",oe=Vn(Un(je,j,M,W,x,E??void 0)),me={method:Ie,headers:{}};Ie!=="GET"&&Ie!=="DELETE"&&(me.headers={"Content-Type":"application/json"});const We=await fetch(oe,me);if(!We.ok)throw new Error(`Download failed: ${We.statusText}`);const Tt=await We.blob(),ze=window.URL.createObjectURL(Tt),Fe=document.createElement("a");Fe.href=ze;const Ge=We.headers.get("Content-Disposition");let nt="download";if(Ge){const yt=Ge.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);yt&&yt[1]&&(nt=yt[1].replace(/['"]/g,""))}Fe.download=nt,document.body.appendChild(Fe),Fe.click(),document.body.removeChild(Fe),window.URL.revokeObjectURL(ze);try{const yt=YN(We);Bt.toast.success(yt&&yt.trim()?yt:"Download started.")}catch{Bt.toast.success("Download started.")}}catch(Ie){fc(Ie,"Failed to download file. Please check the API endpoint and try again.",pi)}finally{D(!1)}}else Bt.toast.error("Download endpoint is not configured")}else if(de==="upload"||de==="custom"){const je=de==="custom",gt=je?"api":B?.uploadAction||H?.uploadAction||"database";if(gt==="database")if(l){D(!0);try{await l(Je)}catch(Ie){throw Ie}finally{D(!1)}}else Bt.toast.error("Form submit handler is not available");else if(gt==="api"){const Ie=B?.uploadApiEndpoint||H?.uploadApiEndpoint||e.uploadApiEndpoint;if(B?.uploadApiMethod||H?.uploadApiMethod||e.uploadApiMethod,Ie){if(!await te())return;D(!0);try{const oe=await ye();C?.(e.name,oe),qN(oe,je?"Custom API call completed successfully!":"Upload completed successfully!")}catch(oe){C?.(e.name,{status:"error",code:oe?.response?.code??oe?.response?.status??null,message:pi(oe)}),fc(oe,je?"Failed to call custom API. Please check the API endpoint and try again.":"Failed to upload. Please check the API endpoint and try again.",pi)}finally{D(!1)}}else Bt.toast.error(je?"Custom API endpoint is not configured":"Upload endpoint is not configured")}else gt==="custom"&&Bt.toast.info("Custom upload handler is not implemented")}else u?u():n&&t!==void 0&&n(t||"");r?.()},ce=async()=>{if(!U||U!=="api"||!J)return null;const Je=B?.apiBodyFields??H?.apiBodyFields;if((B?.apiBodyFieldsOnly??H?.apiBodyFieldsOnly??!1)&&Je?.length){const Fe={};return Je.forEach(({key:Ge,value:nt})=>{const yt=ta(nt,j,M,W,x,E??void 0),Jt=Ge==="user_id"?"context_user_id":Ge;Fe[Jt]=yt}),Fe.user_id!==void 0&&Fe.user_id!==null&&(Fe.context_user_id=Fe.context_user_id??Fe.user_id,delete Fe.user_id),Fe}const je=T?.length?mc(j,T):j,gt=B?.apiFieldMapping??H?.apiFieldMapping,Ie=B?.apiFieldTypes??H?.apiFieldTypes,oe=B?.apiBodyStructure??H?.apiBodyStructure,me={...Ie};T?.length&&T.forEach(Fe=>{const Ge=Fe.name||Fe.key;Ge&&(Fe.type==="terms"||Fe.type==="checkbox")&&(me[Ge]="boolean")});const{transformFormValuesWithFiles:We}=await Promise.resolve().then(()=>Dh),{transformed:Tt}=We(je,gt,me);let ze={};if(oe==="flat"?ze={...Tt}:ze={data:{...Tt}},gt){const Fe={};Object.keys(ze).forEach(Ge=>{const nt=gt[Ge]||Ge;Fe[nt]=ze[Ge]}),ze=Fe}return Je?.length&&Je.forEach(({key:Fe,value:Ge})=>{const nt=ta(Ge,j,M,W,x,E??void 0),yt=Fe==="user_id"?"context_user_id":Fe;ze[yt]=nt}),ze.user_id!==void 0&&ze.user_id!==null&&(ze.context_user_id=ze.context_user_id??ze.user_id,delete ze.user_id),ze.data?.user_id!==void 0&&ze.data?.user_id!==null&&(ze.data.context_user_id=ze.data.context_user_id??ze.data.user_id,delete ze.data.user_id),ze},Xe=async()=>{if(!y||!y.url)throw new Error("BFF submit API configuration is missing");const Je=T?.length?mc(g,T):g,Y={};Object.keys(Je).forEach(Pe=>{const ft=e.name===Pe&&e.type==="button",et=Pe.toLowerCase().includes("button");!ft&&!et&&(Y[Pe]=Je[Pe])});const je=Object.keys(Y).filter(Pe=>ea(Y[Pe]));je.forEach(Pe=>{Y[Pe]=""});const gt=zh(Y,L,G),Ie={workflow_id:y.payload?.workflow_id||"",current_step_id:y.payload?.current_step_id||"",form_data:gt},oe=["workflow_id","current_step_id","form_data","submit_body","submit_api_endpoint","submit_api_method"];if(h&&typeof h=="object"&&Object.entries(h).forEach(([Pe,ft])=>{if(ft==null||oe.includes(Pe))return;const et=Pe==="user_id"?"context_user_id":Pe;Ie[et]=Ie[et]??ft}),v&&typeof v=="object"&&Object.entries(v).forEach(([Pe,ft])=>{if(ft==null||oe.includes(Pe))return;const et=Pe==="user_id"?"context_user_id":Pe;Ie[et]=Ie[et]??ft}),U==="api"&&J)try{const Pe=await ce();if(Pe){const ft=B?.apiBodyStructure??H?.apiBodyStructure,et=B?.apiFieldMapping??H?.apiFieldMapping;je.forEach(dn=>{const rr=et?.[dn]??dn,mr=Y[dn]!==void 0&&typeof Y[dn]=="string"?Y[dn]:"";ft==="flat"?Pe[rr]=mr:Pe.data&&typeof Pe.data=="object"?Pe.data[rr]=mr:Pe[rr]=mr}),Ie.submit_body=Pe;let At=Un(J,j,M,W,x,E??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=Vn(At),Ie.submit_api_endpoint=At,Ie.submit_api_method=B?.submitApiMethod||H?.submitApiMethod||"POST"}}catch{}const me=(y.method||"POST").toUpperCase(),We=je.length>0,Tt=Ie.submit_api_endpoint??J??"",ze=typeof Tt=="string"?Tt.toLowerCase():"",Fe=ze.includes("/upload")||ze.includes("/payments")||ze.includes("/bulk-upload"),Ge=We&&Fe;let nt;const yt={...y.headers||{}};if(Ge){const Pe=new FormData;Pe.append("payload",JSON.stringify(Ie));for(const ft of je){const et=Je[ft],At=B?.apiFieldMapping?.[ft]??ft;et instanceof File?Pe.append(At,et):Array.isArray(et)&&et.length>0&&et[0]instanceof File&&et.forEach(dn=>Pe.append(At,dn))}nt=Pe,delete yt["content-type"],delete yt["Content-Type"]}else yt["Content-Type"]="application/json",nt=JSON.stringify(Ie);const Jt=await fetch(y.url,{method:me,headers:yt,body:nt});if(!Jt.ok){let Pe;const ft=await Jt.text();try{Pe=JSON.parse(ft)}catch{Pe={message:ft}}const et=new Error(`BFF submission failed: ${Jt.status}`);throw et.response=Pe,et}const xt=await Jt.json();return w?.(xt),l&&await l(),xt},ye=async()=>{const Je=B?.uploadApiEndpoint||H?.uploadApiEndpoint;if(!Je)throw new Error("Upload API endpoint is not configured");if(!B)throw new Error("Button properties are not configured");const Y=(B.uploadApiMethod||"POST").toUpperCase(),je=Vn(Un(Je,j,M,W,x,E??void 0)),gt=B.apiBodyFieldsOnly??H?.apiBodyFieldsOnly??!1,Ie=B.apiBodyFieldsOnlyFormat??H?.apiBodyFieldsOnlyFormat??"json";let oe={},me;const We={};if(gt&&B.apiBodyFields&&B.apiBodyFields.length>0)if(B.apiBodyFields.forEach(({key:Fe,value:Ge})=>{oe[Fe]=ta(Ge,j,M,W,x,E??void 0)}),Ie==="multipart"){const Fe=new FormData;Object.entries(oe).forEach(([Ge,nt])=>{if(nt instanceof File){Fe.append(Ge,nt);return}if(Array.isArray(nt)&&nt.length>0&&nt[0]instanceof File){nt.forEach(yt=>Fe.append(Ge,yt));return}nt!=null&&Fe.append(Ge,typeof nt=="object"?JSON.stringify(nt):String(nt))}),me=Fe}else me=JSON.stringify(oe),We["Content-Type"]="application/json";else{const Fe=j,{transformFormValuesWithFiles:Ge,prepareFormDataWithFiles:nt,hasFileValues:yt}=await Promise.resolve().then(()=>Dh),{transformed:Jt,hasFiles:xt}=Ge(Fe,B.apiFieldMapping,B.apiFieldTypes);if((B.apiBodyStructure??H?.apiBodyStructure??"nested")==="flat"?oe={...Jt}:oe={data:{...Jt}},B.apiFieldMapping){const ft={};Object.keys(oe).forEach(et=>{const At=B.apiFieldMapping[et]||et;ft[At]=oe[et]}),oe=ft}if(B.apiBodyFields&&B.apiBodyFields.forEach(({key:ft,value:et})=>{oe[ft]=ta(et,j,M,W,x,E??void 0)}),xt||yt(oe)){const ft=nt(oe,B.apiFieldMapping);ft?me=ft:(me=JSON.stringify(oe),We["Content-Type"]="application/json")}else me=JSON.stringify(oe),We["Content-Type"]="application/json"}B.apiHeaders&&B.apiHeaders.forEach(({key:Fe,value:Ge})=>{const nt=Un(Ge,j,M,W,x,E??void 0);(Fe.toLowerCase()!=="content-type"||!(me instanceof FormData))&&(We[Fe]=nt)});let Tt=je;if(B.apiQueryParams&&B.apiQueryParams.length>0){const Fe=new URLSearchParams;B.apiQueryParams.forEach(({key:Ge,value:nt})=>{const yt=Un(nt,j,M,W,x,E??void 0);Fe.append(Ge,yt)}),Tt=`${je}?${Fe.toString()}`}const ze=await fetch(Tt,{method:Y,headers:We,body:Y!=="GET"?me:void 0});if(!ze.ok){let Fe;const Ge=await ze.text();try{Fe=JSON.parse(Ge)}catch{Fe={message:Ge}}const nt=new Error(`Upload failed: ${ze.status}`);throw nt.response=Fe,nt}try{return await ze.json()}catch{return{}}},Se=de==="submit"?"submit":de,ve=Se==="submit"?"button":Se==="submit"?"submit":Se==="reset"?"reset":"button",He=i||e.disabled||s||e.readOnly||$||Se==="submit"&&m,dt=Te,Ke=oo(e),Gt=kn(e.appearance)==="stretch";return d.jsx(Et,{field:e,error:o,isRequired:a,className:c,hideLabel:re,children:d.jsx("div",{className:z(I&&!Ke&&"flex w-full min-w-0 flex-col",I&&Ke&&"min-w-0 shrink-0"),children:d.jsxs(Yt,{id:ht(e),type:ve,variant:ne,size:q,disabled:He,onClick:ge,className:z(e.appearance?.className,I&&!Ke&&"w-full min-w-0 shrink-0",I&&Ke&&!Gt&&"inline-flex w-auto max-w-full shrink-0",I&&Ke&&Gt&&"inline-flex w-full min-w-0 max-w-full shrink-0"),children:[$&&d.jsx("span",{className:"inline-block h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent mr-2","aria-hidden":!0}),dt]})})})},sk=({field:e,disabled:t,readOnly:n,isRequired:r,className:o,buttonResponses:i,onButtonApiResponse:s})=>{const a=e.properties,c=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=Ko(i?.[p]),g=t||e.disabled||n||e.readOnly||m,h=y=>{y.preventDefault(),!g&&s?.(p,{status:"success"})};return d.jsx(Et,{field:e,error:void 0,isRequired:r,className:o,hideLabel:f,children:d.jsx(Yt,{id:ht(e),type:"button",variant:u,size:l,disabled:g,onClick:h,className:z(e.appearance?.className,(!oo(e)||kn(e.appearance)==="stretch")&&"w-full min-w-0"),children:c})})},ak=({field:e,error:t,disabled:n,readOnly:r,isRequired:o,className:i,onAddMore:s})=>{const a=e.properties||{},c=a.variant||"outline",u=a.size||"default",l=a.buttonText||e.label||"Add More",f=a.hideLabel??e.appearance?.hideLabel??!1,p=n||r||e.disabled||e.readOnly;return d.jsx(Et,{field:e,error:t,isRequired:o,className:i,hideLabel:f,children:d.jsxs(Yt,{id:ht(e),type:"button",variant:c,size:u,disabled:!!p,onClick:s,className:z("w-fit",e.appearance?.className),children:[d.jsx(Au,{className:"h-4 w-4 mr-1"}),l]})})},Vh=S.createContext(null);function lk({value:e,children:t}){return d.jsx(Vh.Provider,{value:e,children:t})}function ck(){return S.useContext(Vh)}function Uh(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function mi(e){return e.name||e.key||e.id}function hc(e){return e.filter(t=>!t.parentId&&t.type==="sectionHeading"&&mi(t))}function dk(e){if(e.type!=="sectionHeading")return[];const t=e.properties||{};return Array.isArray(t.linkedFieldNames)?t.linkedFieldNames.filter(n=>typeof n=="string"&&n.trim().length>0):[]}function uk(e){const t=new Map;for(const n of hc(e)){const r=mi(n);for(const o of dk(n))t.set(o,r)}return t}function fk(e,t){const n=t.properties||{},r=Array.isArray(n.sectionHeadingNames)?n.sectionHeadingNames.filter(s=>typeof s=="string"&&s.trim()):[],o=hc(e);if(r.length===0)return o;const i=new Set(r);return o.filter(s=>i.has(mi(s)))}function pk(e){const t={};for(const n of hc(e))t[mi(n)]=!0;for(const n of e){if(n.type!=="customizeSections")continue;const r=n.properties||{};for(const o of r.defaultHiddenSectionNames??[])typeof o=="string"&&o.trim()&&(t[o.trim()]=!1)}return t}function Hh(e,t,n,r){if(!e||t==="customizeSections")return!0;const o=Uh(e),i=t==="sectionHeading"?o:r.get(o);return i?n[i]!==!1:!0}const mk=({field:e,error:t,disabled:n,readOnly:r,isRequired:o,className:i,designMode:s=!1})=>{const a=ck(),c=e.properties||{},u=c.variant||"outline",l=c.size||"default",f=c.buttonText||e.label||"Customise sections",p=c.menuTitle||"VISIBLE SECTIONS",m=c.hideLabel??e.appearance?.hideLabel??!1,g=n||r||e.disabled||e.readOnly,h=S.useMemo(()=>a?.allFields?.length?fk(a.allFields,e):[],[a?.allFields,e]);return d.jsx(Et,{field:e,error:t,isRequired:o,className:i,hideLabel:m,children:d.jsxs(Kl,{children:[d.jsx(pm,{asChild:!0,children:d.jsxs(Yt,{id:ht(e),type:"button",variant:u,size:l,disabled:!!g,className:z("w-fit gap-2",e.appearance?.className),children:[d.jsx(dw,{className:"h-4 w-4"}),f]})}),d.jsxs(Gl,{align:"end",className:"w-64 p-0",children:[d.jsx("div",{className:"px-3 py-2 border-b",children:d.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:p})}),d.jsx("div",{className:"max-h-64 overflow-auto p-2 space-y-1",children:h.length===0?d.jsx("p",{className:"text-xs text-muted-foreground px-1 py-2",children:"No section headings on this form."}):h.map(y=>{const w=mi(y),v=y.label||w,x=s||!a?!0:a.visibility[w]!==!1;return d.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md px-1 py-1.5 hover:bg-muted/50",children:[d.jsx(Er,{htmlFor:`ui-section-${e.id}-${w}`,className:"text-xs font-normal truncate",children:v}),d.jsx(Xm,{id:`ui-section-${e.id}-${w}`,checked:x,disabled:s||!a||!!g,onCheckedChange:C=>{!a||s||a.setSectionVisible(w,!!C)}})]},y.id)})})]})]})})},hk=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=e.properties,l=u?.max||5,f=u?.icon||"star",p=h=>{i||s||e.disabled||e.readOnly||(n(h),r?.())},m=h=>{},g=h=>{const y=t>=h+1,w=z("transition-colors cursor-pointer",y?"fill-yellow-400 text-yellow-400":"text-muted-foreground",(i||s||e.disabled||e.readOnly)&&"cursor-not-allowed opacity-50",!(i||s||e.disabled||e.readOnly)&&"hover:text-yellow-400");return f==="star"?d.jsx(Cu,{className:z(w,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h):d.jsx(Cu,{className:z(w,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>m()},h)};return d.jsx(Et,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ht(e),className:"flex items-center gap-1",role:"radiogroup","aria-label":e.label,"aria-describedby":$t(e,!!o),"aria-invalid":Qt(!!o),"aria-required":a,children:[Array.from({length:l},(h,y)=>g(y)),u?.showValue!==!1&&d.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:t>0?t:""})]})})};var Wh=["PageUp","PageDown"],Rh=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Kh={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Co="Slider",[gc,gk,yk]=Qa(Co),[Gh]=Sn(Co,[yk]),[bk,na]=Gh(Co),qh=b.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:i=1,orientation:s="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:l,onValueChange:f=()=>{},onValueCommit:p=()=>{},inverted:m=!1,form:g,...h}=e,y=b.useRef(new Set),w=b.useRef(0),x=s==="horizontal"?vk:wk,[C=[],F]=er({prop:l,defaultProp:u,onChange:E=>{[...y.current][w.current]?.focus(),f(E)}}),N=b.useRef(C);function T(E){const L=Ek(C,E);O(E,L)}function k(E){O(E,w.current)}function A(){const E=N.current[w.current];C[w.current]!==E&&p(C)}function O(E,L,{commit:G}={commit:!1}){const I=Tk(i),$=Fk(Math.round((E-r)/i)*i+r,I),D=Qo($,[r,o]);F((B=[])=>{const M=Ak(B,D,L);if(_k(M,c*i)){w.current=M.indexOf(D);const W=String(M)!==String(B);return W&&G&&p(M),W?M:B}else return B})}return d.jsx(bk,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:w,thumbs:y.current,values:C,orientation:s,form:g,children:d.jsx(gc.Provider,{scope:e.__scopeSlider,children:d.jsx(gc.Slot,{scope:e.__scopeSlider,children:d.jsx(x,{"aria-disabled":a,"data-disabled":a?"":void 0,...h,ref:t,onPointerDown:Le(h.onPointerDown,()=>{a||(N.current=C)}),min:r,max:o,inverted:m,onSlideStart:a?void 0:T,onSlideMove:a?void 0:k,onSlideEnd:a?void 0:A,onHomeKeyDown:()=>!a&&O(r,0,{commit:!0}),onEndKeyDown:()=>!a&&O(o,C.length-1,{commit:!0}),onStepKeyDown:({event:E,direction:L})=>{if(!a){const $=Wh.includes(E.key)||E.shiftKey&&Rh.includes(E.key)?10:1,D=w.current,B=C[D],M=i*$*L;O(B+M,D,{commit:!0})}}})})})})});qh.displayName=Co;var[Yh,Xh]=Gh(Co,{startEdge:"left",endEdge:"right",size:"width",direction:1}),vk=b.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:i,onSlideStart:s,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...l}=e,[f,p]=b.useState(null),m=Ze(t,x=>p(x)),g=b.useRef(void 0),h=ao(o),y=h==="ltr",w=y&&!i||!y&&i;function v(x){const C=g.current||f.getBoundingClientRect(),F=[0,C.width],T=vc(F,w?[n,r]:[r,n]);return g.current=C,T(x-C.left)}return d.jsx(Yh,{scope:e.__scopeSlider,startEdge:w?"left":"right",endEdge:w?"right":"left",direction:w?1:-1,size:"width",children:d.jsx(Jh,{dir:h,"data-orientation":"horizontal",...l,ref:m,style:{...l.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:x=>{const C=v(x.clientX);s?.(C)},onSlideMove:x=>{const C=v(x.clientX);a?.(C)},onSlideEnd:()=>{g.current=void 0,c?.()},onStepKeyDown:x=>{const F=Kh[w?"from-left":"from-right"].includes(x.key);u?.({event:x,direction:F?-1:1})}})})}),wk=b.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:i,onSlideMove:s,onSlideEnd:a,onStepKeyDown:c,...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=vc(w,m?[r,n]:[n,r]);return p.current=y,x(h-y.top)}return d.jsx(Yh,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:d.jsx(Jh,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:h=>{const y=g(h.clientY);i?.(y)},onSlideMove:h=>{const y=g(h.clientY);s?.(y)},onSlideEnd:()=>{p.current=void 0,a?.()},onStepKeyDown:h=>{const w=Kh[m?"from-bottom":"from-top"].includes(h.key);c?.({event:h,direction:w?-1:1})}})})}),Jh=b.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:i,onHomeKeyDown:s,onEndKeyDown:a,onStepKeyDown:c,...u}=e,l=na(Co,n);return d.jsx($e.span,{...u,ref:t,onKeyDown:Le(e.onKeyDown,f=>{f.key==="Home"?(s(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):Wh.concat(Rh).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:Le(e.onPointerDown,f=>{const p=f.target;p.setPointerCapture(f.pointerId),f.preventDefault(),l.thumbs.has(p)?p.focus():r(f)}),onPointerMove:Le(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:Le(e.onPointerUp,f=>{const p=f.target;p.hasPointerCapture(f.pointerId)&&(p.releasePointerCapture(f.pointerId),i(f))})})}),Qh="SliderTrack",Zh=b.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=na(Qh,n);return d.jsx($e.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});Zh.displayName=Qh;var yc="SliderRange",eg=b.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=na(yc,n),i=Xh(yc,n),s=b.useRef(null),a=Ze(t,s),c=o.values.length,u=o.values.map(p=>rg(p,o.min,o.max)),l=c>1?Math.min(...u):0,f=100-Math.max(...u);return d.jsx($e.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{...e.style,[i.startEdge]:l+"%",[i.endEdge]:f+"%"}})});eg.displayName=yc;var bc="SliderThumb",tg=b.forwardRef((e,t)=>{const n=gk(e.__scopeSlider),[r,o]=b.useState(null),i=Ze(t,a=>o(a)),s=b.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return d.jsx(Sk,{...e,ref:i,index:s})}),Sk=b.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...i}=e,s=na(bc,n),a=Xh(bc,n),[c,u]=b.useState(null),l=Ze(t,v=>u(v)),f=c?s.form||!!c.closest("form"):!0,p=ti(c),m=s.values[r],g=m===void 0?0:rg(m,s.min,s.max),h=Ck(r,s.values.length),y=p?.[a.size],w=y?Nk(y,g,a.direction):0;return b.useEffect(()=>{if(c)return s.thumbs.add(c),()=>{s.thumbs.delete(c)}},[c,s.thumbs]),d.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${w}px)`},children:[d.jsx(gc.ItemSlot,{scope:e.__scopeSlider,children:d.jsx($e.span,{role:"slider","aria-label":e["aria-label"]||h,"aria-valuemin":s.min,"aria-valuenow":m,"aria-valuemax":s.max,"aria-orientation":s.orientation,"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,tabIndex:s.disabled?void 0:0,...i,ref:l,style:m===void 0?{display:"none"}:e.style,onFocus:Le(e.onFocus,()=>{s.valueIndexToChangeRef.current=r})})}),f&&d.jsx(ng,{name:o??(s.name?s.name+(s.values.length>1?"[]":""):void 0),form:s.form,value:m},r)]})});tg.displayName=bc;var xk="RadioBubbleInput",ng=b.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=b.useRef(null),i=Ze(o,r),s=ni(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(c,"value").set;if(s!==t&&l){const f=new Event("input",{bubbles:!0});l.call(a,t),a.dispatchEvent(f)}},[s,t]),d.jsx($e.input,{style:{display:"none"},...n,ref:i,defaultValue:t})});ng.displayName=xk;function Ak(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,i)=>o-i)}function rg(e,t,n){const i=100/(n-t)*(e-t);return Qo(i,[0,100])}function Ck(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function Ek(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function Nk(e,t,n){const r=e/2,i=vc([0,50],[0,r]);return(r-i(t)*n)*n}function kk(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function _k(e,t){if(t>0){const n=kk(e);return Math.min(...n)>=t}return!0}function vc(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Tk(e){return(String(e).split(".")[1]||"").length}function Fk(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var Pk=qh,Ok=Zh,Ik=eg,Mk=tg;function Lk({className:e,defaultValue:t,value:n,min:r=0,max:o=100,...i}){const s=b.useMemo(()=>Array.isArray(n)?n:Array.isArray(t)?t:[r,o],[n,t,r,o]);return d.jsxs(Pk,{"data-slot":"slider",defaultValue:t,value:n,min:r,max:o,className:z("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),...i,children:[d.jsx(Ok,{"data-slot":"slider-track",className:z("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:d.jsx(Ik,{"data-slot":"slider-range",className:z("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:s.length},(a,c)=>d.jsx(Mk,{"data-slot":"slider-thumb",className:"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},c))]})}const Dk=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{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=>{i||s||e.disabled||e.readOnly||(n(w[0]??l),r?.())},y=t??l;return d.jsx(Et,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[m&&d.jsx("span",{className:"text-sm font-medium",children:y}),!m&&d.jsx("span",{className:"text-sm text-muted-foreground",children:l}),!m&&d.jsx("span",{className:"text-sm text-muted-foreground",children:f})]}),d.jsx(Lk,{id:ht(e),value:[y],onValueChange:h,min:l,max:f,step:p,disabled:i||e.disabled||s||e.readOnly,className:z("w-full",o&&"border-destructive",e.appearance?.className),"aria-describedby":$t(e,!!o),"aria-invalid":Qt(!!o),"aria-required":a}),g.length>0&&d.jsx("div",{className:"flex justify-between text-xs text-muted-foreground",children:g.map((w,v)=>d.jsx("span",{className:"text-center",children:w.label},v))})]})})},Bk=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,readOnly:s,isRequired:a,className:c})=>{const u=S.useRef(null),[l,f]=S.useState(!1),p=i||e.disabled||s||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 C=v.getBoundingClientRect(),F="touches"in w?w.touches[0].clientX-C.left:w.clientX-C.left,N="touches"in w?w.touches[0].clientY-C.top:w.clientY-C.top;x.beginPath(),x.moveTo(F,N)},[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 C=v.getBoundingClientRect(),F="touches"in w?w.touches[0].clientX-C.left:w.clientX-C.left,N="touches"in w?w.touches[0].clientY-C.top:w.clientY-C.top;x.lineWidth=2,x.lineCap="round",x.strokeStyle="#000",x.lineTo(F,N),x.stroke(),x.beginPath(),x.moveTo(F,N)},[l,p]),h=S.useCallback(()=>{if(!l)return;f(!1);const w=u.current;if(!w)return;const v=w.toDataURL();n(v),r?.()},[l,n,r]),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),n(null),r?.())},[p,n,r]);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]),d.jsx(Et,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsx("div",{className:z("border-2 border-dashed rounded-lg overflow-hidden",o&&"border-destructive",p&&"opacity-50 cursor-not-allowed"),children:d.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":$t(e,!!o),"aria-invalid":Qt(!!o),"aria-required":a,style:{height:"200px"}})}),!p&&d.jsx("div",{className:"flex justify-end",children:d.jsxs(Yt,{type:"button",variant:"outline",size:"sm",onClick:y,className:"text-xs",children:[d.jsx(Xo,{className:"h-3 w-3 mr-1"}),"Clear"]})})]})})},$k=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,readOnly:s,isRequired:a,className:c,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=i===!1&&s===!1?!1:i||e.disabled||s||e.readOnly,x=t||[],C=y&&x.length<h,F=w&&x.length>g,N=S.useCallback(()=>{if(!C||v)return;const I={};m.forEach($=>{I[$.name]=$.defaultValue??""}),n([...x,I]),r?.()},[x,m,C,v,n,r]),T=S.useCallback(I=>{if(!F||v)return;const $=x.filter((D,B)=>B!==I);n($),r?.()},[x,F,v,n,r]),k=S.useCallback((I,$,D)=>{if(v)return;const B=[...x];B[I]||(B[I]={}),B[I][$]=D,n(B),r?.()},[x,v,n,r]);if(S.useEffect(()=>{if(x.length<g){const I=g-x.length,$=[];for(let D=0;D<I;D++){const B={};m.forEach(M=>{B[M.name]=M.defaultValue??""}),$.push(B)}n([...x,...$])}},[g,m,n,x.length]),m.length===0)return d.jsx(Et,{field:e,error:o,isRequired:a,className:c,children:d.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this table field"})});const A=Math.max(1,e.position?.rowSpan??1),O=Math.max(1,e.position?.columnSpan??1),E=Math.max(x.length,1),L=A>=3?"py-4":A>=2?"py-3":"py-2.5",G=O>=3?"px-4":O>=2?"px-3":"px-4";return d.jsx(Et,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ht(e),className:z("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":$t(e,!!o),"aria-invalid":Qt(!!o),"aria-required":a,children:[d.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:d.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:p?.minWidth?{minWidth:p.minWidth}:void 0,children:[d.jsx("thead",{children:d.jsxs("tr",{className:"border-b border-border bg-muted/60",children:[m.map(I=>d.jsxs("th",{className:z(G,L,"text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground whitespace-nowrap"),children:[I.label,a&&I.validation?.some($=>$.type==="required")&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]},I.id)),w&&d.jsx("th",{className:"w-12"})]})}),d.jsx("tbody",{className:"h-full",children:x.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:m.length+(w?1:0),className:z(G,"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((I,$)=>{const D=x[$],B=D&&typeof D=="object"&&!Array.isArray(D)?{...l??{},...D}:l;return d.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/30 transition-colors last:border-b-0",style:{height:`${100/E}%`},children:[m.map(M=>{const W={...M,name:`${e.name}_${$}_${M.name}`,appearance:{...M.appearance,hideLabel:!0}},j=M.name??"",ie=I[j]!==void 0?I[j]:j&&Object.keys(I).find(q=>q.toLowerCase()===j.toLowerCase())?I[Object.keys(I).find(q=>q.toLowerCase()===j.toLowerCase())]:void 0,H=!!M.readOnly,U=q=>{if(q==null)return"";if(Array.isArray(q))return q.map(re=>typeof re=="object"&&re!==null&&"name"in re?String(re.name??re):String(re)).join(", ");if(typeof q=="object"&&q!==null&&!(q instanceof Date)){const re=q;return typeof re.name=="string"&&typeof re.code=="string"?`${re.code} ${re.name}`.trim():typeof re.name=="string"?re.name:typeof re.code=="string"?re.code:String(re.name??re.code??q)}return String(q)},J=q=>typeof q=="object"&&q!==null&&!Array.isArray(q)?U(q):String(q??""),de=M.name?.toLowerCase()==="type"||M.label?.toLowerCase()==="type";if(H){const q=U(ie);return d.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:d.jsx("div",{className:"min-w-[120px] text-sm text-foreground",children:de&&q?d.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 text-primary px-2.5 py-0.5 text-xs font-medium",children:q}):d.jsx("span",{className:"py-1 block",children:q})})},M.id)}const ne=()=>{switch(M.type){case"text":case"password":case"url":return d.jsx(qi,{field:W,value:J(ie),onChange:q=>k($,M.name,q),disabled:v,readOnly:v,className:"w-full"});case"number":return d.jsx(Ja,{field:W,value:ie??null,onChange:q=>k($,M.name,q),disabled:v,readOnly:v,className:"w-full"});case"email":return d.jsx(Eu,{field:W,value:J(ie),onChange:q=>k($,M.name,q),disabled:v,readOnly:v,className:"w-full"});case"phone":case"aadhaar":return d.jsx(Nu,{field:W,value:J(ie),onChange:q=>k($,M.name,q),disabled:v,readOnly:v,className:"w-full"});case"textarea":return d.jsx(ku,{field:W,value:J(ie),onChange:q=>k($,M.name,q),disabled:v,readOnly:v,className:"w-full"});case"select":return d.jsx(Qp,{field:W,value:typeof ie=="string"?ie:J(ie),onChange:q=>k($,M.name,q),disabled:v,className:"w-full",formValues:B,submissionContext:f});case"multiselect":{const q=Array.isArray(ie)?ie:ie!=null&&ie!==""?[String(ie)]:[];return d.jsx(Hm,{field:W,value:q,onChange:re=>k($,M.name,re),disabled:v,className:"w-full",formValues:B,submissionContext:f})}case"asyncsearch":return d.jsx(wm,{field:W,value:ie,onChange:q=>k($,M.name,q),disabled:v,readOnly:v,className:"w-full",formValues:B,submissionContext:f});case"checkbox":return d.jsx(Wm,{field:W,value:ie||!1,onChange:q=>k($,M.name,q),disabled:v,className:"w-full"});case"radio":case"checkboxgroup":return d.jsx(gh,{field:W,value:typeof ie=="string"?ie:J(ie),onChange:q=>k($,M.name,q),disabled:v,className:"w-full"});case"date":case"time":case"datetime":case"daterange":return d.jsx(yh,{field:W,value:typeof ie=="string"?ie:J(ie),onChange:q=>k($,M.name,q),disabled:v,readOnly:v,className:"w-full"});default:return d.jsx(qi,{field:W,value:J(ie),onChange:q=>k($,M.name,q),disabled:v,readOnly:v,className:"w-full"})}};return d.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:d.jsx("div",{className:"min-w-[160px] w-full [&_input]:min-w-[10rem] [&_input]:overflow-visible [&_textarea]:min-h-[2.5rem]",children:ne()})},M.id)}),w&&d.jsx("td",{className:"px-2 py-2",children:d.jsx(Yt,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>T($),disabled:!F||v,children:d.jsx(Xo,{className:"h-4 w-4"})})})]},$)})})]})}),C&&d.jsx("div",{className:"shrink-0 p-3 border-t bg-muted/30",children:d.jsxs(Yt,{type:"button",variant:"outline",size:"sm",onClick:N,disabled:v,className:"w-full",children:[d.jsx(Au,{className:"h-4 w-4 mr-2"}),"Add Row"]})})]})})},jk="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",zk="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",Vk="h-8 min-w-[2ch] max-w-full flex-1 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0",Uk="align-top max-w-0 whitespace-normal break-words",hi="block min-w-0 break-words";function og(e,t,n){const r=n?.emptyDisplay??"—";if(e==null||e==="")return r;const o=t?.format??"text",i=typeof e=="number"?e:Number(e);switch(o){case"currency":return Number.isNaN(i)?r:`${n?.currencySymbol??"₹"}${i.toLocaleString("en-IN",{minimumFractionDigits:0,maximumFractionDigits:2})}`;case"percent":return Number.isNaN(i)?r:`${i}%`;case"number":return Number.isNaN(i)?r:String(i);default:return String(e)}}function Hk(e){const t=e.replace(/[^\d.-]/g,"");if(t===""||t==="-"||t===".")return null;const n=parseFloat(t);return Number.isNaN(n)?null:n}function Wk(e){if(e==null||e==="")return"";const t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?"":String(t)}function ig(e,t){return og(e,{format:"currency"},t)}function gi(e){return e==null||e===""}function sg(e){return e.mode??"editable"}function Rk(e,t){return e.kind==="currency"||e.kind==="input"&&e.inputType==="number"?!0:t?.format==="currency"||t?.format==="number"||t?.format==="percent"}function ag(e,t,n){if(e!==void 0){if(e==="")return"";if(Rk(t,n)){const r=Number(e);return Number.isNaN(r)?e:r}return e}}function wc(e,t){if(!(!e||!("defaultValue"in e)||e.defaultValue===void 0))return ag(e.defaultValue,e,t)}function Sc(e,t,n){if(!t||!gi(e))return e;if(t.kind==="currency"&&sg(t)==="static"&&t.value!==void 0)return ag(t.value,t,n);const r=wc(t,n);return r!==void 0?r:e}function Kk(e,t,n){const r={...t};for(const[o,i]of Object.entries(e)){const s=n.find(c=>c.key===o);if(!gi(r[o]))continue;const a=Sc(r[o],i,s);(!gi(a)||i&&"defaultValue"in i&&i.defaultValue==="")&&(r[o]=a)}return r}function ra(e,t,n){if(!gi(e))return e;const r=wc(t,n);return r!==void 0?r:e}const Gk=new Set(["all_items_summary","invoice_discount","grand_total"]);function qk(e,t){switch(t){case"dynamic":return e.filter(n=>n.rowKind==="dynamic");case"static":return e.filter(n=>n.rowKind==="static");case"all":return e;case"data":return e.filter(n=>n.rowKind==="dynamic"||n.rowKind==="static"&&!Gk.has(n.slotId));default:return e}}function Yk(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}function Xk(e,t,n){const r=e.rowSlots.find(o=>o.kind==="static"?o.row.id===t.slotId:o.kind==="dynamic"&&o.block.id===t.slotId);if(r)return r.kind==="static"?r.row.cells[n]:r.block.cells[n]}function Jk(e,t,n,r){const o=l=>lu(r,t,l,n),i=(l,f)=>lu(r,t,f,n,{slotId:l,rowKind:"static"}),s=(l,f="all")=>qk(t,f).reduce((p,m)=>p+Yk(m.values[l]),0),a={...Hi.functions,cell:o,cellInRow:i,SUM:s},c=Object.keys(a),u=Object.values(a);try{const l=new Function(...c,`return (${e});`)(...u);return l==null||typeof l=="number"&&Number.isNaN(l)?null:l}catch{return null}}function Qk(e,t){return e.length!==t.length?!1:e.every((n,r)=>{const o=t[r];return n.slotId===o.slotId&&n.rowInstanceId===o.rowInstanceId&&JSON.stringify(n.values)===JSON.stringify(o.values)})}function Zk(e,t){const n=t.rows.map(r=>({...r,values:{...r.values}}));for(const r of n)for(const o of e.columns){const i=Xk(e,r,o.key);if(i?.kind==="formula"){const s=Jk(i.expression,n,r,e),a=e.columns.find(c=>c.key===o.key);r.values[o.key]=gi(s)?wc(i,a)??s:s}}return{rows:n}}function Eo(e,t,n=8){let r={rows:t.rows.map(o=>({...o,values:{...o.values}}))};for(let o=0;o<n;o++){const i=Zk(e,r);if(Qk(i.rows,r.rows))return i;r=i}return r}function e_(e,t,n,r,o,i){const s=t.rows.map(a=>a.rowInstanceId!==n||a.slotId!==r?a:{...a,values:{...a.values,[o]:i}});return Eo(e,{rows:s})}function lg(e,t,n=[]){return t.map((r,o)=>{const i=typeof r=="object"&&r!==null?r:{},s=e.rowIdField&&i[e.rowIdField]!=null?String(i[e.rowIdField]):String(o),a={};for(const[u,l]of Object.entries(e.cells)){const f=n.find(p=>p.key===u);(l.kind==="api"&&l.path||l.kind==="currency"&&l.mode==="api"&&l.path)&&(a[u]=ra(Qe(i,l.path),l,f))}const c=a.service??a.tariff_type;return{slotId:e.id,rowKind:"dynamic",rowInstanceId:s,label:typeof c=="string"?c:void 0,values:a}})}function xc(e,t,n){const r=[];for(const o of e.rowSlots)if(o.kind==="static"){const i=t.get(o.row.id);i&&r.push(i)}else r.push(...n.get(o.block.id)??[]);return r}function Ac(e,t){const n=new Map,r=new Map;for(const o of e.rowSlots)if(o.kind==="static"){const i=t?.rows.find(s=>s.slotId===o.row.id&&s.rowKind==="static");n.set(o.row.id,{slotId:o.row.id,rowKind:"static",rowInstanceId:o.row.id,label:o.row.label,values:Kk(o.row.cells,i?.values?{...i.values}:{},e.columns)})}else{const i=t?.rows.filter(s=>s.slotId===o.block.id&&s.rowKind==="dynamic")??[];r.set(o.block.id,i.map(s=>({...s,values:{...s.values}})))}return{rows:xc(e,n,r)}}function t_(e,t,n,r){const o=Ac(e,r),i=e.rowSlots.find(c=>c.kind==="dynamic"&&c.block.id===t);if(!i||i.kind!=="dynamic")return Eo(e,o);const s=new Map,a=new Map;for(const c of e.rowSlots)if(c.kind==="static"){const u=o.rows.find(l=>l.slotId===c.row.id&&l.rowKind==="static");u&&s.set(c.row.id,{...u,values:{...u.values}})}else{const u=c.block.id===t?lg(c.block,n,e.columns):o.rows.filter(l=>l.slotId===c.block.id&&l.rowKind==="dynamic");a.set(c.block.id,u.map(l=>({...l,values:{...l.values}})))}return Eo(e,{rows:xc(e,s,a)})}function cg(e,t,n){const r=Ac(e,n);if(t==null||typeof t!="object"||Array.isArray(t))return Eo(e,r);const o=t,i=new Map,s=new Map;for(const a of e.rowSlots)if(a.kind==="static"){const u={...r.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]=ra(Qe(l,p.path),p,m))}i.set(a.row.id,{slotId:a.row.id,rowKind:"static",rowInstanceId:a.row.id,label:a.row.label,values:u})}else{const c=a.block.apiArrayPath??a.block.id,u=Qe(o,c);s.set(a.block.id,Array.isArray(u)?lg(a.block,u,e.columns):[])}return Eo(e,{rows:xc(e,i,s)})}function dg(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 n_(e){const t=e?.color?.trim();return t?{color:t}:{}}function Cc(e){return{className:dg(e),style:n_(e)}}function r_(e){return e?!!(e.fontSize||e.bold||e.italic||e.underline||e.color?.trim()):!1}function o_(e,t){if(!e&&!t)return;const n={...e,...t};return r_(n)?n:void 0}function i_(e,t){const n=e?.kind==="label"?o_(t,e.cellStyle):e?.cellStyle;return Cc(n)}function Ec(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function ug(e,t){return e?.align?e.align:t?.align??"left"}function fg(e){const t=e.properties,n=t?.apiEndpoint?{apiEndpoint:t.apiEndpoint,apiMethod:t.apiMethod,apiKey:t.apiKey,apiRealtime:t.apiRealtime,apiQueryParams:t.apiQueryParams,apiHeaders:t.apiHeaders,apiBodyFields:t.apiBodyFields,apiAuth:t.apiAuth,valueSource:t.valueSource,dependentFields:t.dependentFields,apiResponsePath:t.apiResponsePath}:null,r=e.apidata||null;return n||r}function pg(e){if(e.type!=="billingGrid")return!1;const t=fg(e),n=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||n?.valueSource==="api"))}function s_(e,t,n){let r=e;if(n?.trim()&&(r=Qe(e,n.trim())),r==null)return null;if(Array.isArray(r)){const o=t.rowSlots.find(i=>i.kind==="dynamic");return o?.kind==="dynamic"?{[o.block.apiArrayPath?.trim()||o.block.id]:r}:null}return typeof r=="object"?r:null}function oa(e){return JSON.stringify(e?.rows??[])}function a_({field:e,properties:t,formValues:n={},submissionContext:r,value:o,onChange:i}){const s=pg(e),a=fg(e),[c,u]=S.useState(!1),[l,f]=S.useState(null),p=S.useRef(""),m=S.useRef(o);m.current=o;const g=S.useMemo(()=>{const C=a?.apiEndpoint||"",F=a?.apiQueryParams;return io(C,F)},[a?.apiEndpoint,a?.apiQueryParams]),h=S.useMemo(()=>{const C=new Set;for(const F of a?.dependentFields??[])typeof F=="string"&&F.trim()&&C.add(F.trim());return[...C]},[a?.dependentFields]),y=S.useMemo(()=>{const C=new Set([...g,...h]);if(C.size===0)return null;const F={};return C.forEach(N=>{F[N]=n[N]}),JSON.stringify(F)},[g,h,n]),w=S.useMemo(()=>JSON.stringify(r||{}),[r]),v=S.useMemo(()=>{const C=new Set;e.name?.trim()&&C.add(e.name.trim());const F=e.key;return typeof F=="string"&&F.trim()&&C.add(F.trim()),[...C]},[e.name,e.key]),x=S.useMemo(()=>JSON.stringify({rowSlots:t.rowSlots,columns:t.columns}),[t.rowSlots,t.columns]);return S.useEffect(()=>{const C=a?.apiEndpoint;if(!s||!C)return;let F=!1;const N=k=>{if(F)return;const A=oa(k),O=oa(m.current);A!==O&&p.current!==A&&(p.current=A,i(k))};return(async()=>{u(!0),f(null);try{const k=a?.apiMethod||"GET",A=a?.apiRealtime,O=Ri({apiEndpoint:C,apiMethod:k,apiQueryParams:a?.apiQueryParams||{},formValues:n,submissionContext:r,apiRealtime:A,additionalRequiredFieldNames:h,excludeFormFieldNames:v});if(O.blocked){F||u(!1);return}const E={"Content-Type":"application/json"};a?.apiKey&&(E["X-CSCAPI-KEY"]=a.apiKey);const L=a?.apiAuth??Ds(a?.apiHeaders)??{type:"none"};Object.assign(E,$s(L,{formValues:n,submissionContext:r,apiRealtime:A})),Object.assign(E,Or(Ls(a?.apiHeaders),{formValues:n,submissionContext:r,apiRealtime:A}));const G=Or(a?.apiBodyFields,{formValues:n,submissionContext:r,apiRealtime:A}),I={method:k.toLowerCase(),url:Vn(O.url),headers:E};(O.postBodyBase!=null||Object.keys(G).length>0)&&(I.data={...O.postBodyBase??{},...G});const $=await St(I),D=s_($.data,t,a?.apiResponsePath);if(!D){F||f("API response could not be mapped to billing grid rows.");return}const B=cg(t,D,m.current);N(B)}catch(k){if(F)return;let A="Failed to load billing data";const O=k;if(O.response){const E=O.response.data;if(O.response.status===404)A="API endpoint not found.";else if(O.response.status===401)A="Authentication failed.";else if(typeof E=="string")A=E;else if(E&&typeof E=="object"){const L=E;A=L.error||L.message||L.detail||A}}else O.message&&(A=String(O.message));f(A)}finally{F||u(!1)}})(),()=>{F=!0}},[s,a?.apiEndpoint,a?.apiMethod,a?.apiResponsePath,y,h,v,w,x]),{isLoading:c,error:l}}function l_(e,t,n){return e.rowSlots.find(r=>n==="static"?r.kind==="static"&&r.row.id===t:r.kind==="dynamic"&&r.block.id===t)}function mg(e,t,n,r){const o=e.rowSlots.find(i=>n==="static"?i.kind==="static"&&i.row.id===t:i.kind==="dynamic"&&i.block.id===t);if(o)return o.kind==="static"?o.row.cells[r]:o.block.cells[r]}const c_=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:l})=>{const f=e.properties??{},p=f.columns??[],m=f.currencySymbol??"₹",g=f.emptyDisplay??"—",h=i||s,y=pg(e),{isLoading:w}=a_({field:e,properties:f,formValues:u,submissionContext:l,value:t,onChange:n}),v=S.useMemo(()=>{const E=Ac(f,t);return Eo(f,E)},[f,t]),x=S.useRef("");S.useEffect(()=>{const E=oa(v),L=oa(t);E===L||E===x.current||(x.current=E,n(v))},[v,t,n]),S.useEffect(()=>{!t?.rows?.length&&v.rows.length&&!y&&n(v)},[t,v,n,y]);const C=S.useCallback((E,L,G,I,$)=>{if(h)return;const D=$==="number"?Hk(I):I===""?null:I,B=e_(f,v,E,L,G,D);n(B)},[h,v,n,f]),F=(E,L,G,I,$,D)=>{const B=p.find(J=>J.key===$),M=mg(f,E,L,$),W=Ec(ug(M,B)),j=Sc(D,M,B),ie=l_(f,E,L),H=ie?.kind==="static"?ie.row.labelStyle:ie?.kind==="dynamic"?ie.block.labelStyle:void 0,U=i_(M,H);if(M?.kind==="label")return d.jsx("span",{className:z(hi,U.className||"font-medium",W,!U.style.color&&"text-foreground"),style:U.style,children:I??g});if(M?.kind==="input"&&!h){const J=j==null||j===""?"":String(j);return d.jsx(Cr,{type:"text",inputMode:M.inputType==="number"?"decimal":"text",value:J,onChange:de=>C(G,E,$,de.target.value,M.inputType),onBlur:r,className:z(jk,"w-full min-w-0",W,U.className),style:U.style,disabled:h})}if(M?.kind==="currency"){const J=sg(M);if(J==="static"){const ne=M.value!==void 0&&M.value!==""?Sc(null,{...M,mode:"static"},B):j;return d.jsx("span",{className:z(hi,"tabular-nums",W,U.className),style:U.style,children:ig(ne,{currencySymbol:m,emptyDisplay:g})})}if(J==="api"||h)return d.jsx("span",{className:z(hi,"tabular-nums",W,U.className),style:U.style,children:ig(j,{currencySymbol:m,emptyDisplay:g})});const de=Wk(j);return d.jsxs("div",{className:z(zk,W==="text-center"&&"justify-center",W==="text-right"&&"justify-end",W==="text-left"&&"justify-start",U.className),style:U.style,children:[d.jsx("span",{className:"shrink-0 tabular-nums",children:m}),d.jsx(Cr,{type:"text",inputMode:"decimal",value:de,onChange:ne=>C(G,E,$,ne.target.value,"number"),onBlur:r,className:Vk,disabled:h})]})}return M?.kind==="static"?d.jsx("span",{className:z(hi,W,U.className,!U.style.color&&"text-muted-foreground"),style:U.style,children:M.value}):d.jsx("span",{className:z(hi,W,U.className),style:U.style,children:og(j,B,{currencySymbol:m,emptyDisplay:g})})},N=f.gridTitle?.trim()??"",T=Math.max(1,e.position?.rowSpan??1),k=Math.max(1,e.position?.columnSpan??1),A=T>=3?"py-4":T>=2?"py-3":"py-2",O=k>=3?"px-4":k>=2?"px-3":"px-2";return p.length===0?d.jsx(Et,{field:e,error:o,isRequired:a,className:c,children:d.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this billing grid"})}):d.jsx(Et,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ht(e),className:z("relative flex h-full min-h-0 w-full min-w-0 max-w-full flex-1 flex-col border rounded-lg overflow-hidden shadow-sm bg-background",o&&"border-destructive",h&&"opacity-70"),"aria-describedby":$t(e,!!o),"aria-invalid":Qt(!!o),"aria-required":a,children:[w&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60",children:d.jsx(so,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),N?d.jsx("div",{className:z("shrink-0 px-4 py-2 border-b bg-muted/40",dg(f.gridTitleStyle)||"text-muted-foreground"),style:Cc(f.gridTitleStyle).style,children:N}):null,d.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:d.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:f.minWidth?{minWidth:f.minWidth}:void 0,children:[d.jsx("thead",{children:d.jsx("tr",{className:"border-b border-border bg-muted/60",children:p.map(E=>{const L=Cc(E.headerStyle);return d.jsx("th",{className:z(O,A,"text-xs uppercase tracking-wider whitespace-nowrap",Ec(E.align),L.className||"font-semibold text-muted-foreground"),style:L.style,children:E.label},E.id)})})}),d.jsx("tbody",{className:"h-full",children:v.rows.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:p.length,className:z(O,"py-8 text-center text-sm text-muted-foreground"),children:"No billing rows configured"})}):v.rows.map(E=>d.jsx("tr",{className:"border-b border-border/60",children:p.map(L=>{const G=mg(f,E.slotId,E.rowKind,L.key),I=ug(G,L);return d.jsx("td",{className:z(O,A,Uk,Ec(I)),children:F(E.slotId,E.rowKind,E.rowInstanceId,E.label,L.key,E.values[L.key])},L.id)})},`${E.slotId}-${E.rowInstanceId}`))})]})})]})})};function Nc(e,t,n){return cg(e,t,n)}const d_=({field:e,value:t,error:n,disabled:r,isRequired:o,className:i,formValues:s={},submissionContext:a,extraSubmitPayload:c,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),[C,F]=S.useState(!1),[N,T]=S.useState(null),k=ka.useParams(),A=S.useRef(s),O=S.useRef(a),E=S.useRef(c),L=S.useRef(k);A.current=s,O.current=a,E.current=c,L.current=k;const G=S.useCallback(async()=>{const M=f.apiEndpoint?.trim();if(!M){T("Status API endpoint is not configured");return}F(!0),T(null);try{const W=O.current,j=E.current,ie=W!=null&&typeof W=="object"?{...W,...j||{}}:j||{},H=Vn(Un(M,A.current,L.current,ie,void 0,l??void 0)),U=(f.apiMethod||"GET").toUpperCase(),J=await fetch(H,{method:U,headers:U==="POST"?{"Content-Type":"application/json"}:void 0});if(!J.ok)throw new Error(`HTTP ${J.status}`);const de=await J.json(),ne=g?Qe(de,g):de;x(ne&&typeof ne=="object"?ne:{})}catch(W){T(W instanceof Error?W.message:"Failed to load status"),x(null)}finally{F(!1)}},[f.apiEndpoint,f.apiMethod,g,l]);S.useEffect(()=>{p==="api"&&!u&&G()},[p,u,G]);const I=p==="api"?v:t&&typeof t=="object"?(g?Qe(t,g):null)??t:null,$=h&&y&&I?String(Qe(I,y)??Qe({data:I},y)??""):"",D=M=>{if(!I||typeof I!="object")return!1;const W=I[M];return W===!0||W==="true"||W===1};let B=!1;return d.jsx(Et,{field:e,error:n||N||void 0,isRequired:o,className:z(i,"!space-y-0 h-full min-h-0 flex flex-col"),children:d.jsxs("div",{className:"rounded-lg border bg-card p-4 h-full min-h-0 flex flex-col",children:[C&&d.jsx("div",{className:"text-sm text-muted-foreground py-2",children:"Loading status..."}),h&&$&&!C&&d.jsx("p",{className:"text-sm text-muted-foreground mb-3 shrink-0","data-status-text":!0,children:$}),!C&&d.jsx("ul",{className:"flex-1 min-h-0 flex flex-col gap-y-8 overflow-y-auto pr-1 py-1",children:m.map(M=>{const W=D(M.key),j=w&&W&&!B;return j&&(B=!0),d.jsxs("li",{className:z("flex items-center gap-3 text-sm",W?"text-foreground":"text-muted-foreground"),children:[W?d.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-green-600 text-white","aria-hidden":!0,children:d.jsx(Xi,{className:"h-3 w-3"})}):d.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 border-muted-foreground/40 bg-muted/50","aria-hidden":!0,children:d.jsx(wu,{className:"h-2.5 w-2.5 text-muted-foreground/60"})}),d.jsx("span",{className:"flex-1 min-w-0",children:M.label}),j&&d.jsx("span",{className:"shrink-0 text-xs font-medium text-primary",children:"Current"})]},M.key)})}),!C&&m.length===0&&d.jsx("p",{className:"text-sm text-muted-foreground",children:"No statuses configured."})]})})};function kc(e,t){if(!t||!e)return;const n=t.split(".");let r=e;for(const o of n){if(r==null||typeof r!="object")return;r=r[o]}return r}function No(e,t){if(t){const n=kc(e,t);if(n!=null)return String(n)}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 u_(e,t,n,r){if(n?.length){const i=r??" | ",s=n.map(a=>kc(e,a)).filter(a=>a!=null).map(a=>String(a));if(s.length)return s.join(i)}if(t){const i=kc(e,t);if(i!=null)return String(i)}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 f_=({field:e,value:t,onChange:n,onBlur:r,error:o,disabled:i,isRequired:s,className:a,submissionContext:c})=>{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:c?Object.keys(c):[],dataSourceContextKey:l,contextKeyValue:c&&l?c[l]:void 0});const w=S.useMemo(()=>{if(!l||!c)return[];const E=c[l];return Array.isArray(E)?E:[]},[l,c]);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(E=>{const L=E.length===0||t.length>E.length?t:E;return console.log("[SelectableList] Step 3: sync fullList from value",{fieldName:e.name,valueLength:t.length,prevLength:E.length,nextLength:L.length}),L})},[w,t]);const C=S.useMemo(()=>{const E=Array.isArray(t)?t:[];return new Set(E.map(G=>No(G,p)))},[t,p]),F=v.length>0&&v.every(E=>C.has(No(E,p))),N=v.some(E=>C.has(No(E,p))),T=S.useCallback((E,L)=>{const G=No(E,p),I=Array.isArray(t)?t:[];L?C.has(G)||n([...I,E]):n(I.filter($=>No($,p)!==G)),r?.()},[t,p,C,n,r]),k=S.useCallback(E=>{n(E===!0?[...v]:[]),r?.()},[v,n,r]),A=v.length>0?v:Array.isArray(t)?t:[],O=i||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):[]}),d.jsx("div",{className:z("relative z-10 flex flex-col min-h-0 h-full w-full",A.length>0&&"min-h-[14rem]",a),children:d.jsx(Et,{field:e,error:o,isRequired:s,className:z("flex-1 min-h-0 flex flex-col",A.length>0&&"min-h-[14rem]"),children:d.jsx("div",{className:z("flex-1 min-h-0 flex flex-col",A.length>0&&"min-h-[14rem]"),children:d.jsxs("div",{className:z("flex-1 min-h-0 flex flex-col",A.length>0&&"overflow-visible"),children:[d.jsxs("div",{role:"listbox","aria-multiselectable":!0,className:z("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&&d.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 sticky top-0 bg-background border-b z-10 shrink-0",children:[d.jsx(Us,{id:`${ht(e)}-select-all`,checked:F?!0:N?"indeterminate":!1,onCheckedChange:k,disabled:O,"aria-label":"Select all"}),d.jsxs(Er,{htmlFor:`${ht(e)}-select-all`,className:"text-sm font-medium cursor-pointer",children:["Select all (",A.length,")"]}),d.jsxs("div",{className:"flex gap-1 ml-auto",children:[d.jsx(Yt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:O||F,onClick:()=>{n([...v]),r?.()},children:"Select all"}),d.jsx(Yt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:O||!N,onClick:()=>{n([]),r?.()},children:"Unselect all"})]})]}),A.length===0?d.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No items to display."}):d.jsx(d.Fragment,{children:A.map((E,L)=>{const G=No(E,p),I=C.has(G),$=`${ht(e)}-${L}-${G}`;return d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 min-h-[2.5rem] hover:bg-muted/50 shrink-0",role:"row",children:[d.jsx(Us,{id:$,checked:I,onCheckedChange:D=>T(E,D===!0),disabled:O,"aria-describedby":$t(e,!!o)}),d.jsx(Er,{htmlFor:$,className:"text-sm cursor-pointer flex-1 truncate",children:u_(E,f,m,g)})]},G)})})]}),A.length>0&&C.size===0&&d.jsxs("p",{className:"flex items-center gap-1.5 mt-2 text-sm text-amber-600 dark:text-amber-500 shrink-0",role:"status",children:[d.jsx(aw,{className:"h-4 w-4 shrink-0"}),"Please select at least one item."]})]})})})})},hg=({field:e,children:t,className:n})=>{const r=e.properties,o=r?.collapsible??!1,i=r?.defaultCollapsed??!1,s=r?.columns??1,[a,c]=S.useState(i),u=()=>{o&&c(!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 d.jsxs("div",{className:z("border rounded-lg bg-card",n),children:[d.jsxs("div",{className:z("flex items-center gap-2 px-4 py-3 border-b bg-muted/50",o&&"cursor-pointer hover:bg-muted/70 transition-colors"),onClick:u,children:[o&&d.jsx("span",{className:"text-muted-foreground",children:a?d.jsx(vu,{className:"h-4 w-4"}):d.jsx(Yo,{className:"h-4 w-4"})}),d.jsx("h3",{className:"font-medium text-sm",children:e.label}),e.description&&d.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:e.description})]}),!a&&d.jsx("div",{className:z("p-4 grid gap-4",l[s]),children:t})]})};var p_=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],m_=p_.reduce((e,t)=>{const n=Xa(`Primitive.${t}`),r=b.forwardRef((o,i)=>{const{asChild:s,...a}=o,c=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),h_="Separator",gg="horizontal",g_=["horizontal","vertical"],yg=b.forwardRef((e,t)=>{const{decorative:n,orientation:r=gg,...o}=e,i=y_(r)?r:gg,a=n?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return d.jsx(m_.div,{"data-orientation":i,...a,...o,ref:t})});yg.displayName=h_;function y_(e){return g_.includes(e)}var b_=yg;function _c({className:e,orientation:t="horizontal",decorative:n=!0,...r}){return d.jsx(b_,{"data-slot":"separator",decorative:n,orientation:t,className:z("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),...r})}const v_=({field:e,className:t})=>d.jsx("div",{className:z("py-2",t),children:d.jsx(_c,{})}),w_={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"},S_=({field:e,className:t})=>{const n=e.properties,r=n?.headingLevel??"h3",o=n?.showHorizontalLine??!0,i=w_[r],s=r;return d.jsxs("div",{className:z("w-full min-w-0 space-y-1",t),children:[d.jsx(s,{className:z("m-0 text-foreground",i),children:e.label||"Header"}),e.description&&d.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),o&&d.jsx(_c,{className:"w-full"})]})},x_={"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"},A_={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"},C_=({field:e,className:t})=>{const n=e.properties,r=n?.position??"top-left",o=n?.headingLevel??"h3",i=n?.showHorizontalLine??!0,s=x_[r],a=A_[o],c=o;return d.jsxs("div",{className:z("w-full min-w-0 space-y-2",t),children:[d.jsx("div",{className:z("flex w-full",s),children:d.jsx(c,{className:z("m-0 text-foreground",a),children:e.label||"Section Heading"})}),i&&d.jsx(_c,{className:"w-full"})]})},E_=({field:e,className:t})=>{const n=e.appearance?.size||"md",r={sm:"h-4",md:"h-8",lg:"h-12"};return d.jsx("div",{className:z(r[n],t),"aria-hidden":"true"})};function bg(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function N_(e){if(Array.isArray(e))return e}function k_(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,s,a=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(a.push(r.value),a.length!==t);c=!0);}catch(l){u=!0,o=l}finally{try{if(!c&&n.return!=null&&(s=n.return(),Object(s)!==s))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 T_(e,t){return N_(e)||k_(e,t)||F_(e,t)||__()}function F_(e,t){if(e){if(typeof e=="string")return bg(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bg(e,t):void 0}}const vg=Object.entries,wg=Object.setPrototypeOf,P_=Object.isFrozen,O_=Object.getPrototypeOf,I_=Object.getOwnPropertyDescriptor;let an=Object.freeze,Pn=Object.seal,ko=Object.create,Sg=typeof Reflect<"u"&&Reflect,Tc=Sg.apply,Fc=Sg.construct;an||(an=function(t){return t}),Pn||(Pn=function(t){return t}),Tc||(Tc=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return t.apply(n,o)}),Fc||(Fc=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new t(...r)});const _o=zt(Array.prototype.forEach),M_=zt(Array.prototype.lastIndexOf),xg=zt(Array.prototype.pop),To=zt(Array.prototype.push),L_=zt(Array.prototype.splice),ln=Array.isArray,yi=zt(String.prototype.toLowerCase),Pc=zt(String.prototype.toString),Ag=zt(String.prototype.match),Fo=zt(String.prototype.replace),Cg=zt(String.prototype.indexOf),D_=zt(String.prototype.trim),B_=zt(Number.prototype.toString),$_=zt(Boolean.prototype.toString),Eg=typeof BigInt>"u"?null:zt(BigInt.prototype.toString),Ng=typeof Symbol>"u"?null:zt(Symbol.prototype.toString),Ot=zt(Object.prototype.hasOwnProperty),bi=zt(Object.prototype.toString),en=zt(RegExp.prototype.test),ia=j_(TypeError);function zt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Tc(e,t,r)}}function j_(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Fc(e,n)}}function ot(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:yi;if(wg&&wg(e,null),!ln(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const i=n(o);i!==o&&(P_(t)||(t[r]=i),o=i)}e[o]=!0}return e}function z_(e){for(let t=0;t<e.length;t++)Ot(e,t)||(e[t]=null);return e}function yn(e){const t=ko(null);for(const r of vg(e)){var n=T_(r,2);const o=n[0],i=n[1];Ot(e,o)&&(ln(i)?t[o]=z_(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=yn(i):t[o]=i)}return t}function V_(e){switch(typeof e){case"string":return e;case"number":return B_(e);case"boolean":return $_(e);case"bigint":return Eg?Eg(e):"0";case"symbol":return Ng?Ng(e):"Symbol()";case"undefined":return bi(e);case"function":case"object":{if(e===null)return bi(e);const t=e,n=Qr(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:bi(r)}return bi(e)}default:return bi(e)}}function Qr(e,t){for(;e!==null;){const r=I_(e,t);if(r){if(r.get)return zt(r.get);if(typeof r.value=="function")return zt(r.value)}e=O_(e)}function n(){return null}return n}function U_(e){try{return en(e,""),!0}catch{return!1}}const kg=an(["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"]),Oc=an(["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"]),Ic=an(["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"]),H_=an(["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"]),Mc=an(["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"]),W_=an(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),_g=an(["#text"]),Tg=an(["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"]),Lc=an(["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"]),Fg=an(["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"]),sa=an(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),R_=Pn(/{{[\w\W]*|^[\w\W]*}}/g),K_=Pn(/<%[\w\W]*|^[\w\W]*%>/g),G_=Pn(/\${[\w\W]*/g),q_=Pn(/^data-[\-\w.\u00B7-\uFFFF]+$/),Y_=Pn(/^aria-[\-\w]+$/),Pg=Pn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),X_=Pn(/^(?:\w+script|data):/i),J_=Pn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Q_=Pn(/^html$/i),Z_=Pn(/^[a-z][.\w]*(-[.\w]+)+$/i),Po={element:1,text:3,progressingInstruction:7,comment:8,document:9},eT=function(){return typeof window>"u"?null:window},tT=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Og=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ig(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:eT();const t=Ee=>Ig(Ee);if(t.version="3.4.5",t.removed=[],!e||!e.document||e.document.nodeType!==Po.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,o=r.currentScript,i=e.DocumentFragment,s=e.HTMLTemplateElement,a=e.Node,c=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=c.prototype,y=Qr(h,"cloneNode"),w=Qr(h,"remove"),v=Qr(h,"nextSibling"),x=Qr(h,"childNodes"),C=Qr(h,"parentNode"),F=a&&a.prototype?Qr(a.prototype,"nodeType"):null;if(typeof s=="function"){const Ee=n.createElement("template");Ee.content&&Ee.content.ownerDocument&&(n=Ee.content.ownerDocument)}let N,T="";const k=n,A=k.implementation,O=k.createNodeIterator,E=k.createDocumentFragment,L=k.getElementsByTagName,G=r.importNode;let I=Og();t.isSupported=typeof vg=="function"&&typeof C=="function"&&A&&A.createHTMLDocument!==void 0;const $=R_,D=K_,B=G_,M=q_,W=Y_,j=X_,ie=J_,H=Z_;let U=Pg,J=null;const de=ot({},[...kg,...Oc,...Ic,...Mc,..._g]);let ne=null;const q=ot({},[...Tg,...Lc,...Fg,...sa]);let re=Object.seal(ko(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}})),Te=null,Q=null;const te=Object.seal(ko(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ge=!0,ce=!0,Xe=!1,ye=!0,Se=!1,ae=!0,ve=!1,He=!1,dt=!1,Ke=!1,Gt=!1,Je=!1,Y=!0,je=!1;const gt="user-content-";let Ie=!0,oe=!1,me={},We=null;const Tt=ot({},["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 ze=null;const Fe=ot({},["audio","video","img","source","image","track"]);let Ge=null;const nt=ot({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),yt="http://www.w3.org/1998/Math/MathML",Jt="http://www.w3.org/2000/svg",xt="http://www.w3.org/1999/xhtml";let Pe=xt,ft=!1,et=null;const At=ot({},[yt,Jt,xt],Pc);let dn=ot({},["mi","mo","mn","ms","mtext"]),rr=ot({},["annotation-xml"]);const mr=ot({},["title","style","font","a","script"]);let Vt=null;const Wn=["application/xhtml+xml","text/html"],hr="text/html";let Ct=null,vn=null;const Do=n.createElement("form"),gr=function(P){return P instanceof RegExp||P instanceof Function},In=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(vn&&vn===P)return;(!P||typeof P!="object")&&(P={}),P=yn(P),Vt=Wn.indexOf(P.PARSER_MEDIA_TYPE)===-1?hr:P.PARSER_MEDIA_TYPE,Ct=Vt==="application/xhtml+xml"?Pc:yi,J=Ot(P,"ALLOWED_TAGS")&&ln(P.ALLOWED_TAGS)?ot({},P.ALLOWED_TAGS,Ct):de,ne=Ot(P,"ALLOWED_ATTR")&&ln(P.ALLOWED_ATTR)?ot({},P.ALLOWED_ATTR,Ct):q,et=Ot(P,"ALLOWED_NAMESPACES")&&ln(P.ALLOWED_NAMESPACES)?ot({},P.ALLOWED_NAMESPACES,Pc):At,Ge=Ot(P,"ADD_URI_SAFE_ATTR")&&ln(P.ADD_URI_SAFE_ATTR)?ot(yn(nt),P.ADD_URI_SAFE_ATTR,Ct):nt,ze=Ot(P,"ADD_DATA_URI_TAGS")&&ln(P.ADD_DATA_URI_TAGS)?ot(yn(Fe),P.ADD_DATA_URI_TAGS,Ct):Fe,We=Ot(P,"FORBID_CONTENTS")&&ln(P.FORBID_CONTENTS)?ot({},P.FORBID_CONTENTS,Ct):Tt,Te=Ot(P,"FORBID_TAGS")&&ln(P.FORBID_TAGS)?ot({},P.FORBID_TAGS,Ct):yn({}),Q=Ot(P,"FORBID_ATTR")&&ln(P.FORBID_ATTR)?ot({},P.FORBID_ATTR,Ct):yn({}),me=Ot(P,"USE_PROFILES")?P.USE_PROFILES&&typeof P.USE_PROFILES=="object"?yn(P.USE_PROFILES):P.USE_PROFILES:!1,ge=P.ALLOW_ARIA_ATTR!==!1,ce=P.ALLOW_DATA_ATTR!==!1,Xe=P.ALLOW_UNKNOWN_PROTOCOLS||!1,ye=P.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Se=P.SAFE_FOR_TEMPLATES||!1,ae=P.SAFE_FOR_XML!==!1,ve=P.WHOLE_DOCUMENT||!1,Ke=P.RETURN_DOM||!1,Gt=P.RETURN_DOM_FRAGMENT||!1,Je=P.RETURN_TRUSTED_TYPE||!1,dt=P.FORCE_BODY||!1,Y=P.SANITIZE_DOM!==!1,je=P.SANITIZE_NAMED_PROPS||!1,Ie=P.KEEP_CONTENT!==!1,oe=P.IN_PLACE||!1,U=U_(P.ALLOWED_URI_REGEXP)?P.ALLOWED_URI_REGEXP:Pg,Pe=typeof P.NAMESPACE=="string"?P.NAMESPACE:xt,dn=Ot(P,"MATHML_TEXT_INTEGRATION_POINTS")&&P.MATHML_TEXT_INTEGRATION_POINTS&&typeof P.MATHML_TEXT_INTEGRATION_POINTS=="object"?yn(P.MATHML_TEXT_INTEGRATION_POINTS):ot({},["mi","mo","mn","ms","mtext"]),rr=Ot(P,"HTML_INTEGRATION_POINTS")&&P.HTML_INTEGRATION_POINTS&&typeof P.HTML_INTEGRATION_POINTS=="object"?yn(P.HTML_INTEGRATION_POINTS):ot({},["annotation-xml"]);const ee=Ot(P,"CUSTOM_ELEMENT_HANDLING")&&P.CUSTOM_ELEMENT_HANDLING&&typeof P.CUSTOM_ELEMENT_HANDLING=="object"?yn(P.CUSTOM_ELEMENT_HANDLING):ko(null);if(re=ko(null),Ot(ee,"tagNameCheck")&&gr(ee.tagNameCheck)&&(re.tagNameCheck=ee.tagNameCheck),Ot(ee,"attributeNameCheck")&&gr(ee.attributeNameCheck)&&(re.attributeNameCheck=ee.attributeNameCheck),Ot(ee,"allowCustomizedBuiltInElements")&&typeof ee.allowCustomizedBuiltInElements=="boolean"&&(re.allowCustomizedBuiltInElements=ee.allowCustomizedBuiltInElements),Se&&(ce=!1),Gt&&(Ke=!0),me&&(J=ot({},_g),ne=ko(null),me.html===!0&&(ot(J,kg),ot(ne,Tg)),me.svg===!0&&(ot(J,Oc),ot(ne,Lc),ot(ne,sa)),me.svgFilters===!0&&(ot(J,Ic),ot(ne,Lc),ot(ne,sa)),me.mathMl===!0&&(ot(J,Mc),ot(ne,Fg),ot(ne,sa))),te.tagCheck=null,te.attributeCheck=null,Ot(P,"ADD_TAGS")&&(typeof P.ADD_TAGS=="function"?te.tagCheck=P.ADD_TAGS:ln(P.ADD_TAGS)&&(J===de&&(J=yn(J)),ot(J,P.ADD_TAGS,Ct))),Ot(P,"ADD_ATTR")&&(typeof P.ADD_ATTR=="function"?te.attributeCheck=P.ADD_ATTR:ln(P.ADD_ATTR)&&(ne===q&&(ne=yn(ne)),ot(ne,P.ADD_ATTR,Ct))),Ot(P,"ADD_URI_SAFE_ATTR")&&ln(P.ADD_URI_SAFE_ATTR)&&ot(Ge,P.ADD_URI_SAFE_ATTR,Ct),Ot(P,"FORBID_CONTENTS")&&ln(P.FORBID_CONTENTS)&&(We===Tt&&(We=yn(We)),ot(We,P.FORBID_CONTENTS,Ct)),Ot(P,"ADD_FORBID_CONTENTS")&&ln(P.ADD_FORBID_CONTENTS)&&(We===Tt&&(We=yn(We)),ot(We,P.ADD_FORBID_CONTENTS,Ct)),Ie&&(J["#text"]=!0),ve&&ot(J,["html","head","body"]),J.table&&(ot(J,["tbody"]),delete Te.tbody),P.TRUSTED_TYPES_POLICY){if(typeof P.TRUSTED_TYPES_POLICY.createHTML!="function")throw ia('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof P.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ia('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=P.TRUSTED_TYPES_POLICY,T=N.createHTML("")}else N===void 0&&(N=tT(g,o)),N!==null&&typeof T=="string"&&(T=N.createHTML(""));an&&an(P),vn=P},or=ot({},[...Oc,...Ic,...H_]),tn=ot({},[...Mc,...W_]),wt=function(P){let ee=C(P);(!ee||!ee.tagName)&&(ee={namespaceURI:Pe,tagName:"template"});const le=yi(P.tagName),st=yi(ee.tagName);return et[P.namespaceURI]?P.namespaceURI===Jt?ee.namespaceURI===xt?le==="svg":ee.namespaceURI===yt?le==="svg"&&(st==="annotation-xml"||dn[st]):!!or[le]:P.namespaceURI===yt?ee.namespaceURI===xt?le==="math":ee.namespaceURI===Jt?le==="math"&&rr[st]:!!tn[le]:P.namespaceURI===xt?ee.namespaceURI===Jt&&!rr[st]||ee.namespaceURI===yt&&!dn[st]?!1:!tn[le]&&(mr[le]||!or[le]):!!(Vt==="application/xhtml+xml"&&et[P.namespaceURI]):!1},Ut=function(P){To(t.removed,{element:P});try{C(P).removeChild(P)}catch{w(P)}},Rn=function(P,ee){try{To(t.removed,{attribute:ee.getAttributeNode(P),from:ee})}catch{To(t.removed,{attribute:null,from:ee})}if(ee.removeAttribute(P),P==="is")if(Ke||Gt)try{Ut(ee)}catch{}else try{ee.setAttribute(P,"")}catch{}},Ft=function(P){let ee=null,le=null;if(dt)P="<remove></remove>"+P;else{const kt=Ag(P,/^[\r\n\t ]+/);le=kt&&kt[0]}Vt==="application/xhtml+xml"&&Pe===xt&&(P='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+P+"</body></html>");const st=N?N.createHTML(P):P;if(Pe===xt)try{ee=new m().parseFromString(st,Vt)}catch{}if(!ee||!ee.documentElement){ee=A.createDocument(Pe,"template",null);try{ee.documentElement.innerHTML=ft?T:st}catch{}}const Pt=ee.body||ee.documentElement;return P&&le&&Pt.insertBefore(n.createTextNode(le),Pt.childNodes[0]||null),Pe===xt?L.call(ee,ve?"html":"body")[0]:ve?ee.documentElement:Pt},ir=function(P){return O.call(P.ownerDocument||P,P,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},un=function(P){P.normalize();const ee=O.call(P.ownerDocument||P,P,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let le=ee.nextNode();for(;le;){let st=le.data;_o([$,D,B],Pt=>{st=Fo(st,Pt," ")}),le.data=st,le=ee.nextNode()}},fn=function(P){return P instanceof p&&(typeof P.nodeName!="string"||typeof P.textContent!="string"||typeof P.removeChild!="function"||!(P.attributes instanceof f)||typeof P.removeAttribute!="function"||typeof P.setAttribute!="function"||typeof P.namespaceURI!="string"||typeof P.insertBefore!="function"||typeof P.hasChildNodes!="function")},wn=function(P){if(!F||typeof P!="object"||P===null)return!1;try{return typeof F(P)=="number"}catch{return!1}};function qt(Ee,P,ee){_o(Ee,le=>{le.call(t,P,ee,vn)})}const Mn=function(P){let ee=null;if(qt(I.beforeSanitizeElements,P,null),fn(P))return Ut(P),!0;const le=Ct(P.nodeName);if(qt(I.uponSanitizeElement,P,{tagName:le,allowedTags:J}),ae&&P.hasChildNodes()&&!wn(P.firstElementChild)&&en(/<[/\w!]/g,P.innerHTML)&&en(/<[/\w!]/g,P.textContent)||ae&&P.namespaceURI===xt&&le==="style"&&wn(P.firstElementChild)||P.nodeType===Po.progressingInstruction||ae&&P.nodeType===Po.comment&&en(/<[/\w]/g,P.data))return Ut(P),!0;if(Te[le]||!(te.tagCheck instanceof Function&&te.tagCheck(le))&&!J[le]){if(!Te[le]&&ki(le)&&(re.tagNameCheck instanceof RegExp&&en(re.tagNameCheck,le)||re.tagNameCheck instanceof Function&&re.tagNameCheck(le)))return!1;if(Ie&&!We[le]){const st=C(P)||P.parentNode,Pt=x(P)||P.childNodes;if(Pt&&st){const kt=Pt.length;for(let It=kt-1;It>=0;--It){const pn=y(Pt[It],!0);st.insertBefore(pn,v(P))}}}return Ut(P),!0}return P instanceof c&&!wt(P)||(le==="noscript"||le==="noembed"||le==="noframes")&&en(/<\/no(script|embed|frames)/i,P.innerHTML)?(Ut(P),!0):(Se&&P.nodeType===Po.text&&(ee=P.textContent,_o([$,D,B],st=>{ee=Fo(ee,st," ")}),P.textContent!==ee&&(To(t.removed,{element:P.cloneNode()}),P.textContent=ee)),qt(I.afterSanitizeElements,P,null),!1)},nn=function(P,ee,le){if(Q[ee]||Y&&(ee==="id"||ee==="name")&&(le in n||le in Do))return!1;const st=ne[ee]||te.attributeCheck instanceof Function&&te.attributeCheck(ee,P);if(!(ce&&!Q[ee]&&en(M,ee))){if(!(ge&&en(W,ee))){if(!st||Q[ee]){if(!(ki(P)&&(re.tagNameCheck instanceof RegExp&&en(re.tagNameCheck,P)||re.tagNameCheck instanceof Function&&re.tagNameCheck(P))&&(re.attributeNameCheck instanceof RegExp&&en(re.attributeNameCheck,ee)||re.attributeNameCheck instanceof Function&&re.attributeNameCheck(ee,P))||ee==="is"&&re.allowCustomizedBuiltInElements&&(re.tagNameCheck instanceof RegExp&&en(re.tagNameCheck,le)||re.tagNameCheck instanceof Function&&re.tagNameCheck(le))))return!1}else if(!Ge[ee]){if(!en(U,Fo(le,ie,""))){if(!((ee==="src"||ee==="xlink:href"||ee==="href")&&P!=="script"&&Cg(le,"data:")===0&&ze[P])){if(!(Xe&&!en(j,Fo(le,ie,"")))){if(le)return!1}}}}}}return!0},Kn=ot({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ki=function(P){return!Kn[yi(P)]&&en(H,P)},fa=function(P){qt(I.beforeSanitizeAttributes,P,null);const ee=P.attributes;if(!ee||fn(P))return;const le={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ne,forceKeepAttr:void 0};let st=ee.length;for(;st--;){const Pt=ee[st],kt=Pt.name,It=Pt.namespaceURI,pn=Pt.value,En=Ct(kt),sr=pn;let Mt=kt==="value"?sr:D_(sr);if(le.attrName=En,le.attrValue=Mt,le.keepAttr=!0,le.forceKeepAttr=void 0,qt(I.uponSanitizeAttribute,P,le),Mt=le.attrValue,je&&(En==="id"||En==="name")&&Cg(Mt,gt)!==0&&(Rn(kt,P),Mt=gt+Mt),ae&&en(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Mt)){Rn(kt,P);continue}if(En==="attributename"&&Ag(Mt,"href")){Rn(kt,P);continue}if(le.forceKeepAttr)continue;if(!le.keepAttr){Rn(kt,P);continue}if(!ye&&en(/\/>/i,Mt)){Rn(kt,P);continue}Se&&_o([$,D,B],pa=>{Mt=Fo(Mt,pa," ")});const Ti=Ct(P.nodeName);if(!nn(Ti,En,Mt)){Rn(kt,P);continue}if(N&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!It)switch(g.getAttributeType(Ti,En)){case"TrustedHTML":{Mt=N.createHTML(Mt);break}case"TrustedScriptURL":{Mt=N.createScriptURL(Mt);break}}if(Mt!==sr)try{It?P.setAttributeNS(It,kt,Mt):P.setAttribute(kt,Mt),fn(P)?Ut(P):xg(t.removed)}catch{Rn(kt,P)}}qt(I.afterSanitizeAttributes,P,null)},_i=function(P){let ee=null;const le=ir(P);for(qt(I.beforeSanitizeShadowDOM,P,null);ee=le.nextNode();)qt(I.uponSanitizeShadowNode,ee,null),Mn(ee),fa(ee),ee.content instanceof i&&_i(ee.content);qt(I.afterSanitizeShadowDOM,P,null)},Bo=function(P){if(P.nodeType===Po.element&&P.shadowRoot instanceof i){const st=P.shadowRoot;Bo(st),_i(st)}const ee=P.childNodes;if(!ee)return;const le=[];_o(ee,st=>{To(le,st)});for(const st of le)Bo(st)};return t.sanitize=function(Ee){let P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ee=null,le=null,st=null,Pt=null;if(ft=!Ee,ft&&(Ee="<!-->"),typeof Ee!="string"&&!wn(Ee)&&(Ee=V_(Ee),typeof Ee!="string"))throw ia("dirty is not a string, aborting");if(!t.isSupported)return Ee;if(He||In(P),t.removed=[],typeof Ee=="string"&&(oe=!1),oe){const pn=Ee.nodeName;if(typeof pn=="string"){const En=Ct(pn);if(!J[En]||Te[En])throw ia("root node is forbidden and cannot be sanitized in-place")}Bo(Ee)}else if(wn(Ee))ee=Ft("<!---->"),le=ee.ownerDocument.importNode(Ee,!0),le.nodeType===Po.element&&le.nodeName==="BODY"||le.nodeName==="HTML"?ee=le:ee.appendChild(le),Bo(le);else{if(!Ke&&!Se&&!ve&&Ee.indexOf("<")===-1)return N&&Je?N.createHTML(Ee):Ee;if(ee=Ft(Ee),!ee)return Ke?null:Je?T:""}ee&&dt&&Ut(ee.firstChild);const kt=ir(oe?Ee:ee);for(;st=kt.nextNode();)Mn(st),fa(st),st.content instanceof i&&_i(st.content);if(oe)return Se&&un(Ee),Ee;if(Ke){if(Se&&un(ee),Gt)for(Pt=E.call(ee.ownerDocument);ee.firstChild;)Pt.appendChild(ee.firstChild);else Pt=ee;return(ne.shadowroot||ne.shadowrootmode)&&(Pt=G.call(r,Pt,!0)),Pt}let It=ve?ee.outerHTML:ee.innerHTML;return ve&&J["!doctype"]&&ee.ownerDocument&&ee.ownerDocument.doctype&&ee.ownerDocument.doctype.name&&en(Q_,ee.ownerDocument.doctype.name)&&(It="<!DOCTYPE "+ee.ownerDocument.doctype.name+`>
|
|
52
|
-
`+It),Se&&_o([$,D,B],pn=>{It=Fo(It,pn," ")}),N&&Je?N.createHTML(It):It},t.setConfig=function(){let Ee=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};In(Ee),He=!0},t.clearConfig=function(){vn=null,He=!1},t.isValidAttribute=function(Ee,P,ee){vn||In({});const le=Ct(Ee),st=Ct(P);return nn(le,st,ee)},t.addHook=function(Ee,P){typeof P=="function"&&To(I[Ee],P)},t.removeHook=function(Ee,P){if(P!==void 0){const ee=M_(I[Ee],P);return ee===-1?void 0:L_(I[Ee],ee,1)[0]}return xg(I[Ee])},t.removeHooks=function(Ee){I[Ee]=[]},t.removeAllHooks=function(){I=Og()},t}var nT=Ig();const rT=["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"],oT=["href","target","rel","src","alt","title","class","style","colspan","rowspan"];function iT(e){return e?nT.sanitize(e,{ALLOWED_TAGS:[...rT],ALLOWED_ATTR:[...oT],ALLOW_DATA_ATTR:!1}):""}function sT(e,t,n=!1){return e.includes("{labelapi:")?e.replace(/\{labelapi:([^}]+)\}/g,(r,o)=>{const i=o.trim();if(i===""||t==null)return n?"":r;const s=Qe(t,i);return s==null?n?"":r:String(s)}):e}function aT(e){return e&&e.replace(/\{api:[^}]*\}/gi,"").replace(/\{labelapi:[^}]*\}/gi,"").replace(/\{resp:[^}]*\}/gi,"").replace(/\{(?:ctx:|@)\w+\}/gi,"").replace(/\{documentId\}/gi,"").replace(/\{(\w+)\}/g,"")}const Mg={sm:"text-sm",md:"text-base",lg:"text-lg"},Lg={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"},aa={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"};function Zr(e){return e.properties??{}}function lT(e){const t=Zr(e);return t.textContent!==void 0?t.textContent:e.label??""}function cT(e){return Zr(e).textContent===void 0||e.appearance?.hideLabel?!1:!!e.label?.trim()}function dT(e){return e?.contentLayout==="paragraph"?"paragraph":"single"}function Dc(e,t={}){const{formValues:n={},urlParams:r={},submissionContext:o,buttonResponses:i,prepopulateResponse:s,labelApiResponse:a}=t,c=Un(e,n,r,o,i,s),u=sT(c,a,!0);return aT(u)}const uT=/\{api:[^}]+\}/,fT=/\{labelapi:[^}]+\}/;function Bc(e){return uT.test(e)}function $c(e){return fT.test(e)}function pT(e){const t=e.captionTemplate??"",n=e.descriptionTemplate??"",r=Bc(e.bodyTemplate)||Bc(t)||Bc(n),o=$c(e.bodyTemplate)||$c(t)||$c(n);return!!(r&&e.prepopulateLoading||o&&e.labelApiConfigPresent&&(e.labelApiLoading||e.labelApiResponse===void 0&&e.labelApiError==null))}function Bg(e,t){const n=t??Zr(e),r=n.variant??"body",o=e.appearance?.size??"md",i=Mg[o]??Mg.md,s=n.fontWeight??"medium";return r!=="body"?z("m-0 text-foreground",Lg[r]??Lg.h3,n.fontWeight&&Dg[n.fontWeight],n.italic&&"italic",n.underline&&"underline",n.textAlign&&aa[n.textAlign]):z("m-0 text-foreground",i,Dg[s],n.italic&&"italic",n.underline&&"underline",n.textAlign&&aa[n.textAlign])}function mT(e,t){const n=(t??Zr(e)).variant??"body";return n==="body"?"p":n}function jc(e){const t=[];let n=0,r="";const o=()=>{r&&(t.push({type:"text",value:r}),r="")},i=(s,a,c)=>{if(!e.startsWith(s,n))return!1;const u=e.indexOf(a,n+s.length);if(u===-1)return!1;o();const l=e.slice(n+s.length,u);return t.push({type:c,children:jc(l)}),n=u+a.length,!0};for(;n<e.length;){if(e[n]==="\\"&&n+1<e.length){r+=e[n+1],n+=2;continue}i("**","**","bold")||i("__","__","underline")||i("*","*","italic")||i("_","_","italic")||(r+=e[n],n+=1)}return o(),t}function hT(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function $g(e){return e.map(t=>{if(t.type==="text")return hT(t.value);const n=$g(t.children);return t.type==="bold"?`<strong class="font-bold">${n}</strong>`:t.type==="italic"?`<em class="italic">${n}</em>`:`<u class="underline">${n}</u>`}).join("")}function gT(e){return e?$g(jc(e)):""}function yT(e,t){return e?t==="markdown-lite"?gT(e):e:""}function jg(e,t){return e.map((n,r)=>{const o=`${t}-${r}`;if(n.type==="text")return n.value?S.createElement(S.Fragment,{key:o},n.value):null;const i=jg(n.children,o);return n.type==="bold"?S.createElement("strong",{key:o,className:"font-bold"},i):n.type==="italic"?S.createElement("em",{key:o,className:"italic"},i):S.createElement("u",{key:o,className:"underline"},i)})}function zg(e,t){if(!e)return null;if(t!=="markdown-lite")return e;const n=jc(e);return n.length===1&&n[0]?.type==="text"?n[0].value:jg(n,"tl")}const bT="text-label-html prose prose-sm max-w-none [&_p]:m-0 [&_p+p]:mt-2 [&_ul]:my-1 [&_ol]:my-1";function Vg(e,t){if(!e)return null;const{field:n,asDescription:r=!1}=t,o=t.textProps??Zr(n),i=t.contentLayout??dT(o),s=o.inlineFormat??"none";if(i==="paragraph"){const c=iT(yT(e,s));if(!c)return null;const u=r?z("m-0 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&aa[o.textAlign]):z(Bg(n,o),bT);return S.createElement("div",{className:u,dangerouslySetInnerHTML:{__html:c}})}if(r)return S.createElement("p",{className:z("mt-0.5 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&aa[o.textAlign])},zg(e,s));const a=mT(n,o);return S.createElement(a,{className:Bg(n,o)},zg(e,s))}function vT(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 wT(e,t={}){const{formValues:n={},urlParams:r={},submissionContext:o}=t,i=f=>Un(f,n,r,o),s=(e.labelApiMethod??"GET").toUpperCase();let a=Vn(i(e.labelApiEndpoint));const c=e.labelApiQueryParams??[];if(c.length){const f=new URLSearchParams;c.forEach(({key:m,value:g})=>{m.trim()&&f.append(m,i(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]=i(p))});let l;s==="POST"&&(e.labelApiBodyFields??[]).length&&(l={},e.labelApiBodyFields.forEach(({key:f,value:p})=>{f.trim()&&(l[f]=i(p))}));try{return s==="POST"?(await fr.post(a,l??{},{headers:Object.keys(u).length?u:void 0})).data:(await fr.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 ST=({field:e,className:t,formValues:n,urlParams:r,submissionContext:o,buttonResponses:i,prepopulateResponse:s,prepopulateLoading:a=!1})=>{const c=Zr(e),u=S.useMemo(()=>vT(Zr(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 L=await wT(u,{formValues:n??{},urlParams:r??{},submissionContext:o});f(L)}catch(L){f(void 0),h(L instanceof Error?L.message:"Failed to load label API")}finally{m(!1)}},[u,n,r,o]);S.useEffect(()=>{y&&w()},[y,w]);const v=c.textAlign==="center"?"items-center":c.textAlign==="right"?"items-end":c.textAlign==="justify"?"items-stretch":"items-start",x=lT(e),C=cT(e),F=C&&e.label?e.label:"",N=e.description??"",T=pT({bodyTemplate:x,captionTemplate:F,descriptionTemplate:N,prepopulateLoading:a,labelApiConfigPresent:u!=null,labelApiLoading:p,labelApiResponse:l,labelApiError:g}),k={formValues:n??{},urlParams:r??{},submissionContext:o,buttonResponses:i,prepopulateResponse:s,labelApiResponse:l},A=x?Dc(x,k):"",O=C&&e.label?Dc(e.label,k):"",E=N?Dc(N,k):"";return d.jsx("div",{className:z("w-full min-w-0 h-full min-h-[95px] flex flex-col justify-center py-0.5",v,t),children:T?d.jsx("p",{className:"text-sm text-muted-foreground m-0",children:"Loading…"}):d.jsxs(d.Fragment,{children:[g&&u?d.jsx("p",{className:"text-[10px] text-destructive mb-0.5",title:g,children:"Label API failed"}):null,O?d.jsx("div",{className:"text-sm font-medium text-foreground mb-1 w-full",children:O}):null,A?Vg(A,{field:e,textProps:c}):null,E?Vg(E,{field:e,textProps:c,asDescription:!0}):null]})})},zc=({legend:e,children:t,className:n,collapsible:r=!1,defaultCollapsed:o=!1,headerActions:i,onCollapsedChange:s})=>{const[a,c]=S.useState(o),u=S.useId(),l=f=>{f.stopPropagation(),r&&c(p=>{const m=!p;return s?.(m),m})};return d.jsxs("fieldset",{className:z("min-w-0 rounded-lg border bg-card p-4",n),"data-form-renderer":"config-section-border",children:[r?d.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2 border-b border-border pb-2",children:[d.jsxs("button",{type:"button",className:z("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:[d.jsx("span",{className:"shrink-0 text-muted-foreground","aria-hidden":!0,children:a?d.jsx(vu,{className:"h-4 w-4"}):d.jsx(Yo,{className:"h-4 w-4"})}),d.jsx("span",{className:"truncate",children:e})]}),i!=null?d.jsx("div",{className:"shrink-0",children:i}):null]}):d.jsx("legend",{className:"px-1 text-sm font-medium text-foreground",children:e}),!a&&d.jsxs("div",{id:u,className:"space-y-3",children:[!r&&i!=null?d.jsx("div",{className:"flex justify-end",children:i}):null,t]})]})};function Ug(e){const t=e.properties,n=t?.apiEndpoint?{apiEndpoint:t.apiEndpoint,apiMethod:t.apiMethod,apiKey:t.apiKey,apiRealtime:t.apiRealtime,apiAutoDetect:t.apiAutoDetect,apiLabelField:t.apiLabelField,apiValueField:t.apiValueField,apiQueryParams:t.apiQueryParams,apiClientFilter:t.apiClientFilter,apiHeaders:t.apiHeaders,apiBodyFields:t.apiBodyFields,apiAuth:t.apiAuth,valueSource:t.valueSource,dependentFields:t.dependentFields}:null,r=e.apidata||null;return n||r}function Vc(e){const t=Ug(e),n=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||n?.valueSource==="api"))}function Hg({field:e,formValues:t={},submissionContext:n,value:r,onChange:o,clearWhenBlocked:i=!0}){const s=e.properties,a=Ug(e),c=Vc(e),[u,l]=S.useState(!1),[f,p]=S.useState(null),m=S.useRef(null),g=S.useRef(r);g.current=r;const h=S.useMemo(()=>{const F=a?.apiEndpoint||s?.apiEndpoint||"",N=a?.apiQueryParams||s?.apiQueryParams;return io(F,N)},[a?.apiEndpoint,s?.apiEndpoint,a?.apiQueryParams,s?.apiQueryParams]),y=S.useMemo(()=>{const F=new Set;for(const T of s?.dependentFields??a?.dependentFields??[])typeof T=="string"&&T.trim()&&F.add(T.trim());const N=a?.apiClientFilter?.matchField?.trim()||s?.apiClientFilter?.matchField?.trim();return N&&F.add(N),[...F]},[s?.dependentFields,a?.dependentFields,a?.apiClientFilter?.matchField,s?.apiClientFilter?.matchField]),w=S.useMemo(()=>{const F=new Set([...h,...y]);if(F.size===0)return null;const N={};return F.forEach(T=>{N[T]=t[T]}),JSON.stringify(N)},[h,y,t]),v=S.useMemo(()=>JSON.stringify(n||{}),[n]),x=S.useMemo(()=>{const F=new Set;e.name?.trim()&&F.add(e.name.trim());const N=e.key;return typeof N=="string"&&N.trim()&&F.add(N.trim()),[...F]},[e.name,e.key]),C=e.type==="number"?null:"";return S.useEffect(()=>{const F=a?.apiEndpoint;if(!c||!F)return;let N=!1;const T=A=>{if(N)return;const O=g.current;if(A==null||A.trim()===""){i&&O!==C&&O!==void 0&&(m.current=null,o(C));return}if(e.type==="number"){const E=Number(A),L=Number.isFinite(E)?E:null;O!==L&&m.current!==A&&(m.current=A,o(L));return}String(O??"")!==A&&m.current!==A&&(m.current=A,o(A))};return(async()=>{l(!0),p(null);try{const A=a?.apiMethod||s?.apiMethod||"GET",O=a?.apiRealtime||s?.apiRealtime,E=a?.apiQueryParams||s?.apiQueryParams||{},L=Ri({apiEndpoint:F,apiMethod:A,apiQueryParams:E,formValues:t,submissionContext:n,apiRealtime:O,additionalRequiredFieldNames:y,excludeFormFieldNames:x});if(L.blocked){N||(l(!1),i&&T(null));return}const G={"Content-Type":"application/json"},I=a?.apiKey||s?.apiKey;I&&(G["X-CSCAPI-KEY"]=I);const $=e.apidata,D=a?.apiAuth??s?.apiAuth??$?.apiAuth??Ds(a?.apiHeaders??s?.apiHeaders??$?.apiHeaders)??{type:"none"},B=$s(D,{formValues:t,submissionContext:n,apiRealtime:O});Object.assign(G,B);const M=a?.apiHeaders??s?.apiHeaders??$?.apiHeaders,W=a?.apiBodyFields??s?.apiBodyFields??$?.apiBodyFields,j=Or(Ls(M),{formValues:t,submissionContext:n,apiRealtime:O});Object.assign(G,j);const ie=Or(W,{formValues:t,submissionContext:n,apiRealtime:O}),H={method:A.toLowerCase(),url:Vn(L.url),headers:G};(L.postBodyBase!=null||Object.keys(ie).length>0)&&(H.data={...L.postBodyBase??{},...ie});const U=await St(H),J=a?.apiLabelField||s?.apiLabelField,de=a?.apiValueField||s?.apiValueField,ne=a?.apiClientFilter||s?.apiClientFilter;let q=SC(U.data,de,J);if(ne?.filterField&&ne?.matchField&&q!=null){const re=t[ne.matchField];if(re==null)q=null;else{const Te=di(U.data,J,de),Q=Array.isArray(U.data)?U.data:U.data?.data?.data&&Array.isArray(U.data.data.data)?U.data.data.data:U.data?.data&&Array.isArray(U.data.data)?U.data.data:[],te=Te.filter(ge=>{const ce=Q.find(ye=>String(jt(ye,de||"code"))===String(ge.value));if(!ce)return!1;const Xe=jt(ce,ne.filterField);return String(Xe)===String(re)});q=te.length>0?te[0].value:null}}N||T(q)}catch(A){if(N)return;let O="Failed to load value";const E=A;if(E.response){const L=E.response.data;if(E.response.status===404)O="API endpoint not found.";else if(E.response.status===401)O="Authentication failed.";else if(typeof L=="string")O=L;else if(L&&typeof L=="object"){const G=L;O=G.error||G.message||G.detail||O}}else E.message&&(O=String(E.message));p(O)}finally{N||l(!1)}})(),()=>{N=!0}},[c,a?.apiEndpoint,a?.apiMethod,a?.apiValueField,a?.apiLabelField,s?.apiEndpoint,s?.apiMethod,s?.apiValueField,s?.apiLabelField,w,y,x,v,e.type,i,C]),{isLoading:u,error:f}}const xT=({field:e,value:t,onChange:n,formValues:r,submissionContext:o,disabled:i,readOnly:s,...a})=>{const{isLoading:c}=Hg({field:e,formValues:r,submissionContext:o,value:t,onChange:n});return d.jsx(qi,{field:e,value:t||"",onChange:n,disabled:i||c,readOnly:s||c,...a})},AT=({field:e,value:t,onChange:n,formValues:r,submissionContext:o,disabled:i,readOnly:s,...a})=>{const{isLoading:c}=Hg({field:e,formValues:r,submissionContext:o,value:t,onChange:n});return d.jsx(Ja,{field:e,value:t??null,onChange:n,disabled:i||c,readOnly:s||c,...a})},pr=({field:e,value:t,error:n,onChange:r,onBlur:o,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u={},submissionContext:l,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:w,buttonResponses:v,onButtonApiResponse:x,onValidateForm:C,getValidationErrors:F,allFields:N,onSubmittingChange:T,onAddMore:k,scopedFormValues:A,scopedFieldNameMap:O,excludedOptionValues:E,prepopulateMappedFieldNames:L,fieldValueKey:G,hideTableRowControls:I=!1,urlParams:$={},prepopulateResponse:D=null,prepopulateLoading:B=!1,formSections:M,submitPayload:W})=>{switch(e.type){case"divider":return d.jsx(v_,{field:e,className:c});case"header":return d.jsx(S_,{field:e,className:c});case"sectionHeading":return d.jsx(C_,{field:e,className:c});case"spacer":return d.jsx(E_,{field:e,className:c});case"textLabel":return d.jsx(ST,{field:e,className:c,formValues:u,urlParams:$,submissionContext:l,buttonResponses:v,prepopulateResponse:D??void 0,prepopulateLoading:B});case"status":return d.jsx(d_,{field:e,value:t??null,error:n,disabled:i,isRequired:a,className:c,formValues:u,submissionContext:l,extraSubmitPayload:w,prepopulateResponse:D})}switch(e.type){case"text":case"password":case"url":return e.type==="text"&&Vc(e)?d.jsx(xT,{field:e,value:t||"",onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:l}):d.jsx(qi,{field:e,value:t||"",onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c});case"number":return Vc(e)?d.jsx(AT,{field:e,value:t??null,onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:l}):d.jsx(Ja,{field:e,value:t??null,onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c});case"email":return d.jsx(Eu,{field:e,value:t||"",onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c});case"phone":case"aadhaar":return d.jsx(Nu,{field:e,value:t||"",onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c});case"textarea":case"richtext":return d.jsx(ku,{field:e,value:t||"",onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c});case"select":{const j=G??e.name??e.key??e.id,ie=!!(j&&L?.has(j));return d.jsx(Qp,{field:e,value:t||"",onChange:r,onBlur:o,error:n,disabled:i,isRequired:a,className:c,formValues:u,submissionContext:l,excludedOptionValues:E,isPrepopulateTarget:ie})}case"multiselect":{const j=Array.isArray(t)?t:t!=null&&t!==""?[String(t)]:[];return d.jsx(Hm,{field:e,value:j,onChange:ie=>r(ie),onBlur:o,error:n,disabled:i,isRequired:a,className:c,formValues:u,submissionContext:l,excludedOptionValues:E})}case"asyncsearch":return d.jsx(wm,{field:e,value:t,onChange:j=>r(j),onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:l});case"checkbox":case"terms":return d.jsx(Wm,{field:e,value:t||!1,onChange:r,onBlur:o,error:n,disabled:i,isRequired:a,className:c});case"toggle":return d.jsx(UE,{field:e,value:t||"",onChange:r,onBlur:o,error:n,disabled:i,isRequired:a,className:c});case"radio":case"checkboxgroup":return d.jsx(gh,{field:e,value:t||"",onChange:r,onBlur:o,error:n,disabled:i,isRequired:a,className:c,excludedOptionValues:E});case"selectablelist":{const j=Array.isArray(t)?t:[];return console.log("[SelectableList] FieldRenderer: passing to SelectableListField",{fieldName:e.name,value:j,valueLength:j.length,submissionContextKeys:l?Object.keys(l):[]}),d.jsx(f_,{field:e,value:j,onChange:r,onBlur:o,error:n,disabled:i,isRequired:a,className:c,submissionContext:l})}case"date":case"time":case"datetime":case"daterange":return d.jsx(yh,{field:e,value:t||"",onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c});case"file":return d.jsx(pN,{field:e,value:t,onChange:r,onBlur:o,error:n,disabled:i,isRequired:a,className:c,buttonResponses:v});case"camera":return d.jsx(RN,{field:e,value:t??null,onChange:r,onBlur:o,error:n,disabled:i,isRequired:a,className:c});case"photoChoice":return d.jsx(KN,{field:e,value:t??null,onChange:r,onBlur:o,error:n,disabled:i,isRequired:a,className:c,buttonResponses:v});case"signature":return d.jsx(Bk,{field:e,value:t||null,onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c});case"rating":return d.jsx(hk,{field:e,value:t||0,onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c});case"slider":return d.jsx(Dk,{field:e,value:t||0,onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c});case"table":return d.jsx($k,{field:e,value:t||[],onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c,hideRowControls:I,formValues:u,submissionContext:l});case"billingGrid":return d.jsx(c_,{field:e,value:t||{rows:[]},onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c,formValues:u,submissionContext:l});case"button":return d.jsx(ik,{field:e,value:t,onChange:r,onBlur:o,error:n,disabled:i,readOnly:s,isRequired:a,className:c,onSubmit:f,onReset:p,onCancel:m,isSubmitting:g,formValues:u,submissionContext:l,buttonResponses:v,onButtonApiResponse:x,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:w,onValidateForm:C,getValidationErrors:F,allFields:N,onSubmittingChange:T,scopedFormValues:A,scopedFieldNameMap:O,prepopulateResponse:D,formSections:M,submitPayload:W});case"editButton":return d.jsx(sk,{field:e,disabled:i,readOnly:s,isRequired:a,className:c,buttonResponses:v,onButtonApiResponse:x});case"addmore":return d.jsx(ak,{field:e,error:n,disabled:i,readOnly:s,isRequired:a,className:c,onAddMore:()=>k?.(e)});case"customizeSections":return d.jsx(mk,{field:e,error:n,disabled:i,readOnly:s,isRequired:a,className:c});default:return d.jsx("div",{className:"p-3 border rounded-md bg-muted/50",children:d.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unsupported field type: ",e.type]})})}},CT=({steps:e,currentStep:t,completedSteps:n,onStepClick:r,className:o})=>d.jsx("div",{className:z("mb-8",o),children:d.jsx("nav",{"aria-label":"Progress",children:d.jsx("ol",{className:"flex items-center",children:e.map((i,s)=>{const a=n.has(s),c=t===s,u=r&&(a||s===t+1||s<=t);return d.jsxs("li",{className:z("relative",s!==e.length-1&&"pr-8 sm:pr-20 flex-1"),children:[s!==e.length-1&&d.jsx("div",{className:z("absolute top-4 left-8 -right-8 sm:left-12 sm:-right-12 h-0.5",a?"bg-primary":"bg-border"),"aria-hidden":"true"}),d.jsx("button",{type:"button",onClick:()=>u&&r?.(s),disabled:!u,className:z("relative flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium","transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",a&&"bg-primary text-primary-foreground",c&&!a&&"border-2 border-primary text-primary",!a&&!c&&"border-2 border-border text-muted-foreground",u&&"cursor-pointer hover:bg-primary/10",!u&&"cursor-default"),"aria-current":c?"step":void 0,children:a?d.jsx(Xi,{className:"h-4 w-4"}):d.jsx("span",{children:s+1})}),d.jsxs("div",{className:"mt-2",children:[d.jsx("span",{className:z("text-sm font-medium",c&&"text-primary",!c&&!a&&"text-muted-foreground"),children:i.name}),i.description&&d.jsx("p",{className:"text-xs text-muted-foreground hidden sm:block",children:i.description})]})]},i.id)})})})});function vi(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 Wg(e){return Array.isArray(e)?e.map(vi):[]}function ET(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=vi(e.moduleId):t=e.moduleId;const n=e.isDefault??!1;if(!n&&!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:n,moduleId:t,tenantId:e.tenantId||void 0,featureId:e.featureId,config:e.config??void 0}}class NT{basePath="/api/form-builder/forms";async getForRendering(t,n){if(!Mr())throw new Error("Client ID is required");const o=n!==void 0?`${this.basePath}/${t}/render?version=${n}`:`${this.basePath}/${t}/render`,i=await fr.get(o),s=i.data?.data||i.data,a=s?.BFF_submit_api||s?.bff_submit_api||i.data?.BFF_submit_api||i.data?.bff_submit_api,c=s.form||s;if(!c.moduleId&&!s.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(!(c.isDefault??s.form?.isDefault??!1)&&!c.tenantId&&!s.form?.tenantId)throw new Error(`Form response missing required field: tenantId. Form ID: ${t}. Please ensure the backend returns tenantId for non-default forms.`);s.form?.moduleId&&!c.moduleId&&(c.moduleId=s.form.moduleId),s.form?.tenantId&&!c.tenantId&&(c.tenantId=s.form.tenantId),s.form?.isDefault!==void 0&&c.isDefault===void 0&&(c.isDefault=s.form.isDefault);const l=ET(c);s.form?.moduleId&&(typeof s.form.moduleId=="object"&&s.form.moduleId._id?l.moduleId=vi(s.form.moduleId):typeof s.form.moduleId=="string"&&(l.moduleId=s.form.moduleId));const f=Wg(s.fields||[]),p=s.layout?vi(s.layout):null,m=Wg(s.rules||[]),g=s.module?vi(s.module):void 0,h=s.clientMapping||s.clientOverrides;return{form:l,fields:f,layout:p,rules:m,module:g,clientMapping:h,clientOverrides:h,BFF_submit_api:a||void 0}}}const kT=new NT;function Dr({className:e,size:t="md",text:n="Loading...",fullScreen:r=!1}){const o={sm:"h-6 w-6",md:"h-12 w-12",lg:"h-16 w-16"},i=d.jsxs("div",{className:"text-center",children:[d.jsx("div",{className:z("animate-spin rounded-full border-b-2 border-blue-600 mx-auto mb-4",o[t],e)}),n&&d.jsx("p",{className:"text-gray-600",children:n})]});return r?d.jsx("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50 flex items-center justify-center",children:i}):i}const _T={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."},TT=300;function FT(){return{..._T}}function PT(e){if(!e||typeof e!="object")return;const t=e,n=t.user_type??t.visibleToUserType??"",r=t.user_role??t.visibleToUserRole??"",o=Array.isArray(t.users)?t.users:Array.isArray(t.visibleToUserIds)?t.visibleToUserIds:[];if(!(n!=null&&n!==""||r!=null&&r!==""||o.length>0))return;const s={};return n!=null&&n!==""&&(s.visibleToUserType=n),r!=null&&r!==""&&(s.visibleToUserRole=r),o.length>0&&(s.visibleToUserIds=o),s}function OT(e){const t=FT();if(!e||typeof e!="object")return t;const n=e;return{...t,submitAction:n.submitAction||t.submitAction,apiEndpoint:n.apiEndpoint,dbTable:n.dbTable,emailTo:n.emailTo,workflowTrigger:n.workflowTrigger,workflowSubmissionConfig:n.workflowSubmissionConfig,prepopulateApi:n.prepopulateApi,prepopulateResponseRules:n.prepopulateResponseRules??void 0,sections:ek(n.sections),submitPayload:ZN(n.submitPayload),autoSave:n.autoSave,autoSaveInterval:n.autoSaveInterval,showProgressBar:n.showProgressBar,allowDraft:n.allowDraft,validateOnChange:n.validateOnChange,validateOnBlur:n.validateOnBlur,showFieldErrors:n.showFieldErrors,layout:n.layout,submitButtonText:n.submitButtonText,resetButtonText:n.resetButtonText,showReset:n.showReset,successMessage:n.successMessage,successRedirect:n.successRedirect,errorMessage:n.errorMessage}}function wi(e,t,n,r){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=Qd(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 H=l.validationRules;if(H.required===!0&&!g.some(U=>U.type==="required")&&g.push({type:"required",message:"This field is required"}),H.allowLetters!==void 0&&g.push({type:"allowLetters",value:H.allowLetters}),H.allowNumbers!==void 0&&g.push({type:"allowNumbers",value:H.allowNumbers}),H.allowSpecialChars!==void 0&&g.push({type:"allowSpecialChars",value:H.allowSpecialChars}),H.minLetters!==void 0&&typeof H.minLetters=="number"&&g.push({type:"minLetters",value:H.minLetters}),H.maxLetters!==void 0&&typeof H.maxLetters=="number"&&g.push({type:"maxLetters",value:H.maxLetters}),H.minNumbers!==void 0&&typeof H.minNumbers=="number"&&g.push({type:"minNumbers",value:H.minNumbers}),H.maxNumbers!==void 0&&typeof H.maxNumbers=="number"&&g.push({type:"maxNumbers",value:H.maxNumbers}),H.minSpecialChars!==void 0&&typeof H.minSpecialChars=="number"&&g.push({type:"minSpecialChars",value:H.minSpecialChars}),H.maxSpecialChars!==void 0&&typeof H.maxSpecialChars=="number"&&g.push({type:"maxSpecialChars",value:H.maxSpecialChars}),H.fileSize!==void 0&&typeof H.fileSize=="number"){const U=H.fileSize/1048576;g.push({type:"fileSize",value:H.fileSize,message:`File size must be less than ${U.toFixed(2)} MB`})}if(H.fileType!==void 0){const U=Array.isArray(H.fileType)?H.fileType:typeof H.fileType=="string"?H.fileType.split(",").map(J=>J.trim()).filter(Boolean):[];U.length>0&&g.push({type:"fileType",value:U,message:"File type is not allowed"})}}const h=[],y=new Set;r.filter(H=>{const U=typeof H.targetFieldId=="object"?H.targetFieldId.id||H.targetFieldId._id:H.targetFieldId;return!!(U===l.id||U===l._id||U&&l.fieldKey&&U===l.fieldKey)}).forEach(H=>{try{const U=JSON.parse(H.conditionExpression);!U.id&&H.id&&(U.id=H.id);const J=typeof H.targetFieldId=="object"?H.targetFieldId?.id||H.targetFieldId?._id:H.targetFieldId;U.action&&(!U.then||!Array.isArray(U.then)||U.then.length===0)&&(U.then=[{action:U.action,...J&&{target:J}}]),(!U.then||!Array.isArray(U.then)||U.then.length===0)&&H.action&&(U.then=[{action:H.action,...J&&{target:J}}]),U.then&&Array.isArray(U.then)&&J&&(U.then=U.then.map(ne=>!ne.target&&J?{...ne,target:J}:ne));const de=H.conditionExpression||JSON.stringify(U);if(y.has(de))return;y.add(de),h.push(U)}catch{}});const v=l.disabled===!0||p?.disabled===!0||!1;let x=l.readOnly===!0||p?.readOnly===!0||!1;const C=l.hidden===!0||p?.hidden===!0||!1;(p?.valueSource==="calculated"||p?.formula)&&(x=!0);const{disabled:F,readOnly:N,hidden:T,...k}=p,A={};k.hideLabel!==void 0&&(A.hideLabel=k.hideLabel),k.labelPosition!==void 0&&(A.labelPlacement=k.labelPosition),k.size!==void 0&&(A.size=k.size),k.customClass!==void 0&&(A.className=k.customClass);const{labelPosition:O,size:E,customClass:L,visibility:G,...I}=k,$=Object.keys(I).length>0?I:void 0,D=Object.keys(A).length>0?A:void 0,B=l.visibility??p?.visibility??G;let M=PT(B);if(B&&!M){const H=B;(H.visibleToUserType!=null||H.visibleToUserRole!=null||Array.isArray(H.visibleToUserTypes)&&H.visibleToUserTypes.length>0||Array.isArray(H.visibleToUserRoles)&&H.visibleToUserRoles.length>0||Array.isArray(H.visibleToUserIds)&&H.visibleToUserIds.length>0||Array.isArray(H.hiddenFromUserIds)&&H.hiddenFromUserIds.length>0)&&(M={visibleToUserType:H.visibleToUserType??(Array.isArray(H.visibleToUserTypes)?H.visibleToUserTypes[0]:void 0),visibleToUserRole:H.visibleToUserRole??(Array.isArray(H.visibleToUserRoles)?H.visibleToUserRoles[0]:void 0),visibleToUserIds:H.visibleToUserIds,hiddenFromUserIds:H.hiddenFromUserIds})}const W=p?.columnName,ie=!!l.parentFieldId&&typeof W=="string"?W: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:D,validation:g.length>0?g:void 0,conditions:h.length>0?h:void 0,properties:$,visibility:M&&(M.visibleToUserType!=null||M.visibleToUserRole!=null||Array.isArray(M.visibleToUserIds)&&M.visibleToUserIds.length>0||Array.isArray(M.hiddenFromUserIds)&&M.hiddenFromUserIds.length>0)?M:void 0,disabled:v,readOnly:x,hidden:C}});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 i=t;for(let l=0;l<o.length;l++){const f=i[l]?.parentFieldId;if(f){const p=o.find(g=>g.id===f||g.type==="table"&&g.name===f||g.type==="table"&&i[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 s=o.filter((l,f)=>!i[f]?.parentFieldId);for(const l of s)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 c=e.config;if(console.log("[Prepopulate] backendToFormSchema config",{formId:e.id,hasRawConfig:c!=null,rawConfigType:typeof c,rawConfigPreview:c!=null?typeof c=="string"?c.slice(0,300):JSON.stringify(c).slice(0,300):null}),c!=null)try{const l=typeof c=="string"?JSON.parse(c):c;l&&typeof l=="object"?a=OT(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=Ii(n);return u&&(a={...a,grid:u}),{id:e.id,name:e.name,description:e.description,version:e.version,status:e.status,config:a,fields:s,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 IT=3;function Oo(e){if(typeof e=="number"&&!Number.isNaN(e))return e}function Io(e,t){const n=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;return Oo(n?.cellSlot)??Oo(n?.stackSlot)??Oo(n?.cellSlotIndex)??Oo(n?.slotIndex)??Oo(t?.cellSlotIndex)??Oo(t?.stackSlot)}function Si(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 la(e){const t=typeof e.position?.order=="number"?e.position.order:-1,n=typeof e.position?.column=="number"?e.position.column:1,r=e.position?.cellGroupId??"_";return`${t}:${n}:${r}`}function Uc(e){return[...e].sort((t,n)=>{const r=Io(t.position),o=Io(n.position);return typeof r=="number"&&typeof o=="number"&&r!==o?r-o:String(t.id).localeCompare(String(n.id))})}function xi(e,t){if(e.length===0)return{rowSpan:1,columnSpan:1};let n=1,r=1;for(const o of e)n=Math.max(n,Vo(o)),r=Math.max(r,Pd(o,t));return{rowSpan:n,columnSpan:r}}function Rg(e){const t=Uc(e);for(const n of t){const r=Si(n.position);if(r)return r}return t.length>=2?"row":"stack"}function Kg(e){return Uc(e).slice(0,IT)}function MT(e,t){const n=new Map;for(const r of e){if(!t(r)||typeof r.position?.order!="number")continue;const o=la(r),i=n.get(o)??[];i.push(r),n.set(o,i)}return Array.from(n.values()).map(r=>Kg(r))}function Gg(e,t,n,r){const o=n.filter(a=>r(a)&&typeof a.position?.order=="number"&&a.position.order===e&&(a.position.column??1)===t+1);if(o.length===0)return[];const i=new Map;for(const a of o){const c=la(a),u=i.get(c)??[];u.push(a),i.set(c,u)}const s=[...i.values()][0]??[];return Kg(s)}function LT(e,t,n,r){const o=n[0],i=o.position?.order,s=o.position?.column??1;if(typeof i!="number")return!1;const{rowSpan:a,columnSpan:c}=xi(n,r),u=e===i&&t===s-1,l=e>=i&&e<i+a,f=t>=s-1&&t<s-1+c;return l&&f&&!u}function DT(e,t,n){const r=new Set(n??[]);for(const o of e){const i=o[0]?.position?.order??0,{rowSpan:s}=xi(o,t);for(let a=i;a<i+s;a++)r.add(a)}return r}function BT(e){const t=[...e].sort((r,o)=>r-o),n=new Map;return t.forEach((r,o)=>n.set(r,o)),{originalToDisplay:n,displayRowCount:Math.max(t.length,1),sortedOriginalRows:t}}function $T(e,t,n){const r=n.get(e);if(r===void 0)return;let o=0;for(let i=e;i<e+t&&n.has(i);i++)o++;return`${r+1} / span ${Math.max(o,1)}`}function bn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Mo(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(n=>Mo(n));if(!bn(e))return e;const t={};for(const[n,r]of Object.entries(e))t[n]=Mo(r);return t}function qg(e,...t){const n={...e};for(const r of t)if(!(!r||!bn(r)))for(const[o,i]of Object.entries(r)){const s=n[o];bn(i)&&bn(s)?n[o]=qg(s,i):n[o]=i}return n}function eo(e){return bn(e)?e:{}}function Ai(e){if(e==null)return{};if(typeof e=="string"){const t=e.trim();if(!t)return{};try{const n=JSON.parse(t);return bn(n)?Mo(n):{}}catch{return{}}}return bn(e)?Mo(e):{}}function Yg(e){const t=e.apidata;return bn(t)&&Object.keys(t).length>0}function jT(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||Yg(e))return!0;const t=e.fieldKey,n=e.fieldType,r=e.name,o=e.type;return!!(t&&(!r||String(r).trim()==="")||n&&(!o||String(o).trim()==="")||t&&r&&t!==r||n&&o&&n!==o||!r&&e.key&&typeof e.key=="string")}const Xg=["hideLabel","contentAlign","contentVerticalAlign","labelPlacement","widthPercent","widthMode","className","verticalAlign","horizontalAlign","cellAlign","cellJustify","size","variant","minWidth","minHeight"];function zT(e,t){const n=e.appearance,r=bn(n)&&Object.keys(n).length>0?Mo(n):{},o=eo(t.appearance),i={...r};for(const[s,a]of Object.entries(o))s!=="heightPercent"&&i[s]===void 0&&(i[s]=Mo(a));for(const s of Xg)i[s]===void 0&&t[s]!==void 0&&(i[s]=t[s]);return delete i.heightPercent,Object.keys(i).length>0?i:void 0}function VT(e,t){const n=eo(e.position),r=Ai(e.metadata),o=eo(e.layout),i=typeof n.order=="number"&&!Number.isNaN(n.order)?n.order:typeof e.positionOrder=="number"?e.positionOrder:typeof e.order=="number"?e.order:typeof e.positionRow=="number"?e.positionRow:t,s=typeof n.column=="number"&&!Number.isNaN(n.column)?n.column:typeof e.positionColumn=="number"?e.positionColumn:1,a=typeof n.columnSpan=="number"&&!Number.isNaN(n.columnSpan)?n.columnSpan:typeof e.positionWidth=="number"?e.positionWidth:1,c=typeof n.rowSpan=="number"&&!Number.isNaN(n.rowSpan)?n.rowSpan:typeof e.positionRowSpan=="number"?e.positionRowSpan:1,u={order:i,column:s,columnSpan:a,rowSpan:c},l=n.cellGroupId??o.cellGroupId,f=Io(n,{cellSlotIndex:e.cellSlotIndex??o.cellSlotIndex,stackSlot:r.stackSlot??o.stackSlot}),p=Si(n)??Si(o)??(r.stackDirection==="horizontal"||o.stackDirection==="horizontal"?"row":r.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 UT(e,t){const n=e,r=Ai(n.metadata),o=eo(n.apidata),i=eo(n.properties),s=qg({},r,o,i),a=(n.name!=null&&String(n.name).trim()!==""?n.name:void 0)??(typeof n.fieldKey=="string"?n.fieldKey:void 0)??(typeof n.key=="string"?n.key:void 0),c=(n.type!=null&&String(n.type).trim()!==""?n.type:void 0)??(typeof n.fieldType=="string"?n.fieldType:void 0),u=zT(n,r),l=VT(n,t),f={...n};return f.properties=s,a!==void 0&&(f.name=a),c!==void 0&&(f.type=c),u!==void 0?f.appearance=u:(!bn(n.appearance)||Object.keys(n.appearance).length===0)&&delete f.appearance,f.position=l,bn(f.appearance)&&delete f.appearance.heightPercent,f}function HT(e,t){if(!e||typeof e!="object")return!0;const n=e,r=Ai(n.metadata),o=Object.keys(r).length===0&&!(typeof n.metadata=="string"&&n.metadata.trim()!==""),i=!Yg(n);if(jT(n)||!o||!i)return!1;const s=n.position;return!(!(bn(s)&&typeof s.order=="number"&&!Number.isNaN(s.order))&&(typeof n.positionRow=="number"||typeof n.positionColumn=="number"||typeof n.positionWidth=="number"||typeof n.positionRowSpan=="number"||typeof n.positionOrder=="number")||bn(r.appearance)||Xg.some(u=>r[u]!==void 0&&(n.appearance==null||bn(n.appearance)&&n.appearance[u]===void 0))||WT(n))}function WT(e){const t=eo(e.position),n=eo(e.layout),r=Ai(e.metadata);return(typeof e.cellSlotIndex=="number"||typeof t.stackSlot=="number"||typeof t.cellSlot=="number"||typeof t.cellSlotIndex=="number"||typeof r.stackSlot=="number"||typeof n.stackSlot=="number")&&typeof t.cellSlot!="number"||(t.stackDirection==="horizontal"||t.stackDirection==="vertical"||r.stackDirection==="horizontal"||r.stackDirection==="vertical"||n.stackDirection==="horizontal"||n.stackDirection==="vertical")&&t.sharedCellLayout!=="row"&&t.sharedCellLayout!=="stack"}function ca(e){if(e==null||typeof e!="object")return e;const t=e.fields;if(!Array.isArray(t))return e;let n=!1;const r=t.map((o,i)=>{if(HT(o))return o;const s=UT(o,i);return s!==o&&(n=!0),s});return n?{...e,fields:r}:e}function RT(e){return ca(e)}const KT=new Set(["PENDING_PAYMENT","PAYMENT_PENDING","AWAITING_PAYMENT","PAID","PAYMENT_COMPLETED","PAYMENT_FAILED","REFUNDED","AUTHORIZED","CAPTURED","PARTIALLY_PAID"].map(e=>e.toUpperCase()));function Hc(e){return typeof e=="string"&&e.trim()!==""}function Wc(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"||Hc(t.amount)||typeof t.total_amount=="number"||Hc(t.total_amount)||Hc(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 n=t.status;return!!(typeof n=="string"&&KT.has(n.trim().toUpperCase()))}function GT(e){const t=Qe(e,"data.items");if(!Array.isArray(t)||t.length===0)return;const n=t[0];if(n==null||typeof n!="object")return;const r=n;if(!(r.id===void 0||r.id===null||r.id===""))return{item:r,id:r.id}}function qT(e,t){const n=GT(e);if(!n)return;const r=Qe(e,"data"),o=r!=null&&typeof r=="object"&&!Array.isArray(r)?r:void 0;if(t?.treatFirstItemIdAsPaymentId===!0||Wc(n.item)||o!=null&&Wc(o))return n.id}function YT(e){const t=e.properties,n=e.metadata;return[t?.uploadApiEndpoint,t?.apiEndpoint,n?.uploadApiEndpoint,n?.apiEndpoint].filter(o=>typeof o=="string"&&o.length>0)}function XT(e){return YT(e).some(t=>t.toLowerCase().includes("payment"))}function JT(e){const t=e.properties,n=e.metadata;return!!(t?.mergeSuccessDataIdAsPaymentId||n?.mergeSuccessDataIdAsPaymentId)}function QT(e,t){if(t?.type!=="button"||!Ko(e))return;const n=Qe(e,"data.id");if(n==null||String(n).trim()==="")return;const r=Qe(e,"data");if(JT(t)||r!=null&&typeof r=="object"&&!Array.isArray(r)&&Wc(r)||XT(t))return n}const ZT=new Set(["section","group","columns","divider","header","sectionHeading","spacer","addmore","textLabel","customizeSections"]);function eF(e,t){if(!e.length||!t?.length)return[];const n=new Map(t.map(o=>[o.id,o])),r=[];for(const o of e){const i=n.get(o);if(i?.fieldNames?.length)for(const s of i.fieldNames)s&&!r.includes(s)&&r.push(s)}return r}function tF(e,t){const n=e.properties,r=Array.isArray(n?.linkedFieldNames)?n.linkedFieldNames:[],o=eF(Array.isArray(n?.linkedSectionIds)?n.linkedSectionIds:[],t),i=new Set,s=[];for(const a of[...r,...o])!a||i.has(a)||(i.add(a),s.push(a));return s}function Jg(e,t){const n=e.properties,r=Array.isArray(n?.linkedSectionIds)?n.linkedSectionIds:[];if(!r.length||!t?.length)return[];const o=new Map(t.map(i=>[i.id,i]));return r.map(i=>o.get(i)).filter(i=>!!i)}function nF(e,t){return Jg(e,t).find(n=>n.heading?.enabled)}function Qg(e,t){const n=e.template??"";return(e.mode??"increment")==="fixed"?n:n.replace(/\{n\}/g,String(t+1))}function Zg(e,t,n,r){const o=tF(e,n);if(o.length===0)return[];const i=new Set(o);return t.filter(s=>{const a=r(s);return!a||s.id===e.id||ZT.has(s.type)?!1:i.has(a)})}function rF(e,t,n){if(e.type!=="sectionHeading"||!t?.length)return;const r=n(e);if(r)for(const o of t){const i=o.heading;if(i?.enabled&&i.headingFieldName===r)return i}}function Rc(e){return[...e].sort((t,n)=>{const r=t.position?.order??0,o=n.position?.order??0;if(r!==o)return r-o;const i=t.position?.column??1,s=n.position?.column??1;return i-s})}function oF(e,t,n){if(!e?.length)return[];const r=e.filter(s=>s.showBorder===!0);if(r.length===0)return[];const o=new Map;for(const s of t){const a=n(s);a&&o.set(a,s)}const i=[];for(const s of r){const a=s.fieldNames.map(u=>o.get(u)).filter(u=>!!u);if(a.length===0)continue;const c=Rc(a).map(u=>n(u)).filter(Boolean);i.push({section:s,fieldNames:c})}return i}function Ci(e,t=0){return e.heading?.enabled?Qg(e.heading,t):e.name}function ey(e,t,n){if(e.type!=="sectionHeading")return!1;const r=t.heading;return!r?.enabled||!r.headingFieldName?!1:n(e)===r.headingFieldName}function iF(e,t){const n=typeof e.position?.order=="number"?e.position.order:0,r=(e.position?.column??1)-1,o=Vo(e),i=Pd(e,t);return{row:n,col:r,rowEnd:n+o-1,colEnd:r+i-1}}function Kc(e,t){let n=1/0,r=-1/0,o=1/0,i=-1/0;for(const s of e){const{row:a,col:c,rowEnd:u,colEnd:l}=iF(s,t);n=Math.min(n,a),r=Math.max(r,u),o=Math.min(o,c),i=Math.max(i,l)}return Number.isFinite(n)?{minRow:n,maxRow:r,minCol:o,maxCol:i,rowSpan:r-n+1,colSpan:i-o+1}:null}function sF(e,t,n,r){const o=e.map(l=>t.find(f=>r(f)===l)).filter(l=>!!l&&typeof l.position?.order=="number");if(o.length===0)return null;const i=Kc(o,n);if(!i)return null;const s=o.filter(l=>l.type!=="sectionHeading"),a=s.length>0?s:o,c=Math.min(...a.map(l=>l.position?.order??0)),u=Math.max(1,...a.map(l=>(l.position?.order??c)-c+Vo(l)));return{minRow:i.minRow,maxRow:i.maxRow,minCol:i.minCol,maxCol:i.maxCol,blockHeight:u}}function aF(e,t){return e.maxRow+1+t*e.blockHeight}function lF(e,t,n,r){const o=new Map;for(const a of t){const c=n(a);c&&o.set(c,a)}const i=new Map,s=new Set;for(const a of e){const c=a.fieldNames.map(v=>o.get(v)).filter(v=>!!v);if(c.length===0)continue;const u=c.filter(v=>!ey(v,a.section,n)),l=Kc(c,r);if(!l)continue;const{minRow:f,minCol:p,rowSpan:m,colSpan:g}=l,h=`${f}-${p}`;if(i.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 C=`${v}-${x}`;if(s.has(C)){w=!0;break}y.add(C)}if(w)break}if(!w){for(const v of y)s.add(v);i.set(h,{anchorRow:f,anchorCol:p,rowSpan:m,colSpan:g,run:a,legend:Ci(a.section,0),renderFields:u.length>0?u:c})}}return{anchorsByOrigin:i,coveredCells:s}}function cF(e,t,n,r,o,i,s){const a=new Set(s),c=new Map;for(const u of e){const l=ty(u.linkedFields.map(p=>i(p)).filter(Boolean),t),f=l?.section;f?.fieldNames?.length?f.fieldNames:u.templateFieldNames,u.blockIds.forEach((p,m)=>{const g=n.filter(T=>T.id.endsWith(`__${p}`));if(g.length===0||!l)return;const h=Kc(g,o);if(!h)return;const{minRow:y,minCol:w,rowSpan:v,colSpan:x}=h,C=`${y}-${w}`;for(let T=y;T<=y+v-1;T++)for(let k=w;k<=w+x-1;k++)a.add(`${T}-${k}`);const F=l,N=Ci(f,m+1);c.set(C,{anchorRow:y,anchorCol:w,rowSpan:v,colSpan:x,run:F,legend:N,renderFields:Rc(g),addMoreMeta:{addMoreFieldName:u.addMoreFieldName,blockId:p,blockIndex:m}})})}return{anchorsByOrigin:c,coveredCells:a}}function dF(e,t,n,r){const o=`${e}-${t}`;return n.has(o)?!r.get(o):!1}function uF(e,t,n){for(const r of n.values())if(e>=r.anchorRow&&e<r.anchorRow+r.rowSpan&&t>=r.anchorCol&&t<r.anchorCol+r.colSpan)return r}function fF(e,t,n,r){return!(!r||n.run.section.collapsible!==!0||e===n.anchorRow&&t===n.anchorCol)}function pF(e,t,n){const r=new Set;for(const o of e.values())if(t(o))for(let i=o.anchorRow+1;i<o.anchorRow+o.rowSpan;i++)n(i,o)||r.add(i);return r}function mF(e,t,n){const r=o=>n.has(o)?"minmax(0, auto)":`minmax(${t}, auto)`;return Array.from({length:e},(o,i)=>r(i)).join(" ")}function hF(e,t){return new Map([...e,...t])}function gF(e,t,n){if(t.length===0)return e.map(s=>({kind:"field",field:s}));const r=new Map;for(const s of t)for(const a of s.fieldNames)r.set(a,s);const o=[];let i=0;for(;i<e.length;){const s=e[i],a=n(s),c=a?r.get(a):void 0;if(!c){o.push({kind:"field",field:s}),i+=1;continue}const u=[],l=new Set(c.fieldNames);for(;i<e.length;){const p=n(e[i]);if(!p||!l.has(p))break;const m=e[i];ey(m,c.section,n)||u.push(m),i+=1}if(u.length===0)continue;const f=o[o.length-1];f?.kind==="border"&&f.run.section.id===c.section.id?f.fields.push(...u):o.push({kind:"border",run:c,fields:u})}return o}function ty(e,t){if(!t?.length)return;const n=new Set(e);for(const r of t){if(r.showBorder!==!0)continue;const o=r.fieldNames.filter(i=>n.has(i));if(o.length>0)return{section:r,fieldNames:o}}}const yF=2*6e4,ny=50;class bF{map=new Map;ttlMs;constructor(t){this.ttlMs=t}get(t){const n=this.map.get(t);if(!n)return null;const o=Date.now()-n.storedAtMs>this.ttlMs;return{value:n.value,isStale:o}}set(t,n){this.map.set(t,{value:n,storedAtMs:Date.now()}),this.enforceMax()}delete(t){this.map.delete(t)}clear(){this.map.clear()}enforceMax(){if(this.map.size<=ny)return;const t=Array.from(this.map.entries());t.sort((r,o)=>r[1].storedAtMs-o[1].storedAtMs),t.slice(0,Math.max(0,this.map.size-ny)).forEach(([r])=>this.map.delete(r))}}function vF(e){return(e??"").trim()||"default"}function ry(e){const t=vF(e.scope),n=String(e.formId??"").trim(),r=e.version===void 0||e.version===null?"latest":String(e.version).trim();return`form-render:${t}:${n}:${r}`}const oy=new bF(yF);function iy(e){const t=ry(e),n=oy.get(t);return n?{value:n.value,isStale:n.isStale}:null}function sy(e,t){const n=ry(e);oy.set(n,t)}function ay(e){const t={};for(const[r,o]of Object.entries(e)){if(o==null){t[r]=o;continue}if(Array.isArray(o)){t[r]=o;continue}if(typeof o=="object"&&!(o instanceof Date)){const i=o;typeof i.name=="string"&&typeof i.code=="string"?t[r]=`${i.code} ${i.name}`.trim():typeof i.name=="string"?t[r]=i.name:typeof i.code=="string"?t[r]=i.code:typeof i.short_code=="string"?t[r]=i.short_code:t[r]=i.name??i.code??"";continue}t[r]=o}const n=t.time_slot??e.time_slot;return typeof n=="string"&&n.includes(" - ")&&(t.start=n.split(" - ")[0].trim()),t}const Gc=({schema:e,formId:t,initialValues:n,onSubmit:r,onChange:o,onValidationError:i,onClose:s,mode:a="fill",className:c,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:C,dark:F=!1,omitRootWrapper:N=!1})=>{const T=Xr(_=>_.viewerContext),k=S.useMemo(()=>{if(w!==void 0)return w;const _=v?.();return _!==void 0?_:T},[w,v,T]),[A,O]=S.useState(e||null),[E,L]=S.useState(!!t&&!e),[G,I]=S.useState(null),$=e?.BFF_submit_api??G,[D,B]=S.useState(!1),[M,W]=S.useState({}),[j,ie]=S.useState({}),[H,U]=S.useState({}),[J,de]=S.useState({}),[ne,q]=S.useState({}),[re,Te]=S.useState(null),Q=ka.useParams(),te=Nt(_=>_.setValues),ge=Nt(_=>_.setSubmitting),ce=Nt(_=>_.formDisabled),Xe=Nt(_=>_.visibleFields),ye=Nt(_=>_.requiredFields),Se=Nt(_=>_.updateVisibility),ae=Nt(_=>_.updateRequired),ve=Nt(_=>_.setFieldError),He=S.useRef(!1),dt=S.useRef(void 0),Ke=S.useMemo(()=>{if(!e)return null;const _=e;if(_.form&&Array.isArray(_.form.fields))try{return wi(_.form,_.form.fields,_.form.layout||null,_.form.rules||[])}catch{return e}if(Array.isArray(_.fields)&&_.fields.some(V=>typeof V.metadata=="string"&&V.metadata.startsWith("{")||V.fieldType&&!V.type))try{const V={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 wi(V,_.fields,_.layout||null,_.rules||[])}catch{return e}return e},[e]);S.useEffect(()=>{if(e){const _=e;_.BFF_submit_api&&I(_.BFF_submit_api)}},[e]);const Gt=S.useMemo(()=>{const _=Ke||A,R=_?ca(_):null;if(!R)return null;const V=R.layout,Z=R.rules,X=R.clientMapping,ue=(Array.isArray(R.fields)?R.fields:[]).map(De=>{let Ue={...De};if(De.validationRules&&typeof De.validationRules=="object"&&!De.validation){const fe=De.validationRules,Oe=[];fe.required===!0&&Oe.push({type:"required",message:"This field is required"}),fe.minLength!==void 0&&typeof fe.minLength=="number"&&Oe.push({type:"minLength",value:fe.minLength,message:`Minimum length is ${fe.minLength}`}),fe.maxLength!==void 0&&typeof fe.maxLength=="number"&&Oe.push({type:"maxLength",value:fe.maxLength,message:`Maximum length is ${fe.maxLength}`}),fe.pattern&&typeof fe.pattern=="string"&&Oe.push({type:"pattern",value:fe.pattern,message:"Invalid format"}),fe.allowLetters!==void 0&&Oe.push({type:"allowLetters",value:fe.allowLetters}),fe.allowNumbers!==void 0&&Oe.push({type:"allowNumbers",value:fe.allowNumbers}),fe.allowSpecialChars!==void 0&&Oe.push({type:"allowSpecialChars",value:fe.allowSpecialChars}),Oe.length>0&&(Ue={...Ue,validation:Oe})}const xe=De.required===!0||De.isRequired===!0,Ce=Array.isArray(Ue.validation)&&Ue.validation.some(fe=>fe.type==="required");if(xe&&!Ce){const fe={type:"required",message:"This field is required"},Oe=Array.isArray(Ue.validation)?Ue.validation:[];Ue={...Ue,validation:[...Oe,fe]}}if(De.apidata&&typeof De.apidata=="object"){const fe=De.apidata,Oe=Ue.properties||{},we=(Ue.type||De.fieldType)==="status";if(!Oe.apiEndpoint&&fe.apiEndpoint){const ut={...Oe,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,apiHeaders:fe.apiHeaders,apiBodyFields:fe.apiBodyFields,apiAuth:fe.apiAuth,valueSource:fe.valueSource||(fe.apiEndpoint?"api":void 0),optionsSource:fe.optionsSource||(fe.apiEndpoint?"api":void 0),dependentFields:fe.dependentFields,apiResponsePath:fe.apiResponsePath};we&&(ut.source=Oe.source??"api",Oe.statuses!==void 0&&(ut.statuses=Oe.statuses),Oe.dataPath!==void 0&&(ut.dataPath=Oe.dataPath),Oe.showStatusText!==void 0&&(ut.showStatusText=Oe.showStatusText),Oe.statusTextPath!==void 0&&(ut.statusTextPath=Oe.statusTextPath),Oe.showCurrentIndicator!==void 0&&(ut.showCurrentIndicator=Oe.showCurrentIndicator)),Ue={...Ue,properties:ut}}}const Ve=["select","multiselect","radio","checkboxgroup"],rt=Ue.type||De.fieldType;if(Ve.includes(rt)){const fe=De.options,Oe=Ue.properties?.options,we=Array.isArray(Oe)&&Oe.length>0;if(Array.isArray(fe)&&fe.length>0&&!we){const ut=Ue.properties||{};Ue={...Ue,properties:{...ut,options:fe}}}}return Ue}),Ae=R.config?.rules,Ne=Z&&Array.isArray(Z)?Z:Ae&&Array.isArray(Ae)?Ae:[],Be=Ne.length>0?ue.map(De=>{if((De.conditions&&Array.isArray(De.conditions)?De.conditions:[]).length>0)return De;const xe=De.id??De._id,Ce=De.name||De.key,Ve=Ne.filter(Oe=>{const we=typeof Oe.targetFieldId=="object"?Oe.targetFieldId?.id??Oe.targetFieldId?._id:Oe.targetFieldId;return we?we===xe||we===Ce||we===De.fieldKey:!1});if(Ve.length===0)return De;const rt=[],fe=new Set;return Ve.forEach(Oe=>{try{const we=typeof Oe.conditionExpression=="string"?JSON.parse(Oe.conditionExpression):Oe.conditionExpression;if(!we||typeof we!="object")return;!we.id&&Oe.id&&(we.id=Oe.id);const ut=typeof Oe.targetFieldId=="object"?Oe.targetFieldId?.id??Oe.targetFieldId?._id:Oe.targetFieldId;we.action&&(!we.then||!Array.isArray(we.then)||we.then.length===0)&&(we.then=[{action:we.action,...ut&&{target:ut}}]),(!we.then||!Array.isArray(we.then)||we.then.length===0)&&Oe.action&&(we.then=[{action:Oe.action,...ut&&{target:ut}}]),we.then&&Array.isArray(we.then)&&ut&&(we.then=we.then.map(Dt=>!Dt.target&&ut?{...Dt,target:ut}:Dt));const Wt=Oe.conditionExpression??JSON.stringify(we);if(fe.has(Wt))return;fe.add(Wt),rt.push(we)}catch{}}),rt.length===0?De:{...De,conditions:rt}}):ue;let lt=R.config||{submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};return!lt.layout&&V?typeof V=="object"&&V!==null?lt.layout="default":typeof V=="string"&&["default","card","compact"].includes(V)?lt.layout=V:lt.layout="default":lt.layout||(lt.layout="default"),Z&&!lt.rules&&(lt.rules=Z),X&&!lt.clientMapping&&(lt.clientMapping=X),{...R,fields:Be,config:lt}},[Ke,A]);S.useEffect(()=>{Ke&&Ke!==A&&O(Ke)},[Ke]),S.useEffect(()=>{if(t&&!e){const _=(Mr()??"").trim()||"default",R=iy({scope:_,formId:t,version:"latest"});R?.value?.schema?(O(R.value.schema),R.value.bffSubmitApi&&I(R.value.bffSubmitApi),L(!1),R.isStale&&Je({background:!0})):Je({background:!1})}},[t,e]);const Je=async({background:_})=>{if(!t)return;const R=t;_||L(!0);try{const V=await kT.getForRendering(t),Z=wi(V.form,V.fields,V.layout,V.rules);if(R!==t)return;O(Z),V.BFF_submit_api&&I(V.BFF_submit_api);const X=(Mr()??"").trim()||"default";sy({scope:X,formId:R,version:"latest"},{schema:Z,bffSubmitApi:V.BFF_submit_api})}catch{}finally{_||L(!1)}};if(E)return d.jsx("div",{className:"flex items-center justify-center py-12",children:d.jsx(Dr,{})});if(!Gt)return d.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Form not found"});const Y=Gt,je=S.useMemo(()=>new Set(Object.keys(Y.config?.prepopulateApi?.fieldMapping??{})),[Y.config?.prepopulateApi?.fieldMapping]),gt=S.useCallback(async _=>{const R=Y?.fields?.length?mc(_,Y.fields):_,V=zh(R,Y.config?.sections,Y.config?.submitPayload);if(r){const Z=p?{...V,...p}:V;return r(Z)}return{success:!0}},[r,p,Y?.fields,Y.config?.sections,Y.config?.submitPayload]),{values:Ie,errors:oe,touched:me,isSubmitting:We,isValid:Tt,submitCount:ze,currentStep:Fe,totalSteps:Ge,completedSteps:nt,currentStepFields:yt,isLastStep:Jt,setFieldValue:xt,setFieldTouched:Pe,handleSubmit:ft,validateForm:et,resetForm:At,nextStep:dn,goToStep:rr,loadDraft:mr}=eu({schema:Y,initialValues:n,onSubmit:gt,onChange:o,workflowStepId:y}),{isFieldEnabled:Vt,isFieldRequired:Wn,isFieldVisible:hr}=jv({fields:Y.fields,values:Ie,buttonResponses:j,prepopulateResponse:re,prepopulateResponseRules:Y.config?.prepopulateResponseRules}),Ct=hr,vn=Nt(_=>_.readOnlyFields),Do=Nt(_=>_.editableFields),gr=S.useCallback(_=>vn.has(_),[vn]),In=S.useCallback(_=>Do.has(_),[Do]);S.useEffect(()=>{Y.config?.allowDraft&&a==="fill"&&mr()},[Y.id]),S.useEffect(()=>{dt.current=Y.id,He.current=!1,W({}),U({}),de({}),q({}),Te(null)},[Y.id]),S.useEffect(()=>{const _=Y.config?.prepopulateApi,R=!!(_?.fieldMapping&&Object.keys(_?.fieldMapping??{}).length>0),V=(Y.config?.prepopulateResponseRules?.length??0)>0;if(!_?.enabled||!_.apiEndpoint?.trim()||!R&&!V||He.current)return;He.current=!0;const Z=Y.id;dt.current=Y.id;let X=!1;return B(!0),(async()=>{try{const ue=Nt.getState().values,Ae=typeof p=="object"&&p!==null?{...p,...g||{}}:g||{},Ne=se=>Un(se,ue,Q,Ae);let Be=Vn(Ne(_.apiEndpoint));if(_.apiQueryParams?.length){const se=new URLSearchParams;_.apiQueryParams.forEach(({key:Me,value:he})=>se.append(Me,Ne(he))),Be=`${Be}${Be.includes("?")?"&":"?"}${se.toString()}`}const lt={};_.apiHeaders?.forEach(({key:se,value:Me})=>{se.trim()&&(lt[se]=Ne(Me))}),lt["Content-Type"]=lt["Content-Type"]??"application/json";let Ht;if(_.apiMethod==="POST"&&_.apiBodyFields?.length){const se={};_.apiBodyFields.forEach(({key:Me,value:he})=>{Me.trim()&&(se[Me]=Ne(he))}),Ht=JSON.stringify(se)}const De=await fetch(Be,{method:_.apiMethod,headers:lt,body:_.apiMethod==="POST"?Ht:void 0});if(!De.ok){const se=await De.text();throw new Error(se||`HTTP ${De.status}`)}const Ue=await De.json(),xe=se=>{try{return se.split("?")[0].split("/").filter(Boolean).pop()||se}catch{return se}},Ce=(se,Me)=>{if(se==null)return null;const he=typeof se=="string"?se:se instanceof Date?se.toISOString():null;if(!he)return null;const qe=typeof se=="object"&&se instanceof Date?se:new Date(he);if(Number.isNaN(qe.getTime()))return null;const pt=mt=>String(mt).padStart(2,"0");if(Me==="date")return he.length>=10&&he[4]==="-"&&he[7]==="-"?he.slice(0,10):qe.toISOString().slice(0,10);if(Me==="time")return`${pt(qe.getHours())}:${pt(qe.getMinutes())}:${pt(qe.getSeconds())}`;if(Me==="datetime"){const mt=qe.getFullYear(),tt=qe.getMonth()+1,pe=qe.getDate(),bt=qe.getHours(),Re=qe.getMinutes(),_t=qe.getSeconds();return`${mt}-${pt(tt)}-${pt(pe)}T${pt(bt)}:${pt(Re)}:${pt(_t)}`}return null},Ve=(se,Me)=>{const he=Y.fields.find(pe=>pe.name===se||pe.key===se);if(!he)return Me;if((he.type==="file"||he.type==="camera"||he.type==="photoChoice")&&typeof Me=="string"&&Me.startsWith("http"))return{url:Me,name:xe(Me)};if(he.type==="date"||he.type==="datetime"||he.type==="time"){const pe=Ce(Me,he.type);if(pe!==null)return pe}if(he.type==="multiselect")return Array.isArray(Me)?Me.map(pe=>typeof pe=="string"?pe:String(pe)):typeof Me=="string"?Me.trim()===""?[]:Me.includes(",")?Me.split(",").map(pe=>pe.trim()).filter(Boolean):[Me]:Me!=null&&Me!==""?[String(Me)]:[];if(he.type!=="radio"&&he.type!=="select")return Me;const qe=he.properties?.options??he.options;if(!Array.isArray(qe)||qe.length===0)return Me;const pt=qe.map(pe=>pe.value);if(pt.includes(Me))return Me;const mt=String(Me);if(pt.includes(mt))return mt;const tt=qe.find(pe=>pe.value==Me);return tt?tt.value:Me},rt=new Set(Y.fields.filter(se=>se.type==="table").map(se=>se.name||se.key)),fe=new Set(Y.fields.filter(se=>se.type==="billingGrid").map(se=>se.name||se.key)),Oe=se=>se.name||se.key||se.id,we={},ut=[],Wt=[],Dt=tk(_?.fieldMapping,Y.config?.sections,Y.config?.submitPayload);for(const[se,Me]of Object.entries(Dt)){if(!Me?.trim()||se.startsWith("__"))continue;const he=Qe(Ue,Me),qe=se.indexOf(".");if(qe>0&&fe.has(se.slice(0,qe))){const mt=se.slice(0,qe),tt=se.slice(qe+1),bt=Y.fields.find(Re=>(Re.name||Re.key)===mt)?.properties;if(bt?.rowSlots?.length){const Re=tt.startsWith("__block__")?tt.slice(9):tt,_t=we[mt]??Nt.getState().values[mt];Array.isArray(he)?we[mt]=t_(bt,Re,he,_t):he!=null&&(we[mt]=Nc(bt,he,_t))}continue}if(qe>0&&rt.has(se.slice(0,qe))){const mt=se.slice(0,qe),tt=se.slice(qe+1);ut.push({tableName:mt,columnName:tt,path:Me});continue}if(fe.has(se)&&he!==void 0&&he!==null&&typeof he=="object"){const tt=Y.fields.find(pe=>(pe.name||pe.key)===se)?.properties;if(tt?.rowSlots?.length){if(Array.isArray(he)){const pe=tt.rowSlots.find(bt=>bt.kind==="dynamic");if(pe&&pe.kind==="dynamic"){const bt=pe.block.apiArrayPath??"items";we[se]=Nc(tt,{[bt]:he})}}else we[se]=Nc(tt,he);continue}}if(rt.has(se)&&Array.isArray(he)&&he.length>0&&typeof he[0]=="object"&&he[0]!==null){const tt=Y.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],pe=he.map(ay),bt=Re=>(Re||"").toLowerCase().replace(/\s+/g,"_").trim();we[se]=pe.map(Re=>{const _t={};for(const mn of tt){const ro=mn.name??"";_t[ro]=Re[bt(ro)]??Re[ro]}return _t});continue}if(he!=null&&(we[se]=Ve(se,he)),he==null)continue;let pt=he;if(Array.isArray(he)){const mt=Y.fields.find(tt=>Oe(tt)===se);if(mt?.type==="addmore"){Wt.push({addMoreFieldName:se,array:he});continue}if(mt?.type==="multiselect"){const tt=_.multiselectArrayPropertyMap?.[se];tt&&he.length>0&&he.some(pe=>pe!=null&&typeof pe=="object")&&(pt=he.map(pe=>pe!=null&&typeof pe=="object"&&tt in pe?pe[tt]:void 0).filter(pe=>pe!=null))}}we[se]=Ve(se,pt)}const ct={},vt={},rn={};for(const{addMoreFieldName:se,array:Me}of Wt){const he=Y.fields.find(bt=>Oe(bt)===se);if(!he||he.type!=="addmore")continue;const qe=Zg(he,Y.fields,Y.config?.sections,Oe);if(qe.length===0)continue;const pt=_.addMoreFieldKeyMap?.[se],mt=Me.length>0&&Me[0]!=null&&typeof Me[0]=="object"?Me[0]:null;if(mt)for(const bt of qe){const Re=Oe(bt),_t=pt&&pt[Re]||Re,mn=mt[_t];mn!=null&&(we[Re]=Ve(Re,mn))}const tt=Me.slice(1),pe=tt.map((bt,Re)=>`prepop_${se}_${Re}_${Date.now()}`);pe.length>0&&(vt[se]=pe);for(let bt=0;bt<tt.length;bt++){const Re=tt[bt];if(Re==null||typeof Re!="object")continue;const _t=Re,mn=_t.id;mn!=null&&String(mn).trim()!==""&&(rn[`${se}__${pe[bt]}`]=String(mn));for(const ro of qe){const Na=Oe(ro),uO=pt&&pt[Na]||Na,sd=_t[uO];if(sd==null)continue;const fO=`${Na}__addmore__${se}__${pe[bt]}`;ct[fO]=Ve(Na,sd)}}}Object.keys(vt).length>0&&U(se=>({...se,...vt})),Object.keys(rn).length>0&&q(se=>({...se,...rn}));const Ln=se=>(se||"").toLowerCase().replace(/\s+/g,"_").trim(),qn=[...new Set(ut.map(se=>se.tableName))];for(const se of qn){if(Array.isArray(we[se]))continue;const Me=ut.find(pe=>pe.tableName===se);if(!Me?.path?.includes("."))continue;const he=Me.path.replace(/\.[^.]+$/,""),qe=Qe(Ue,he);if(!Array.isArray(qe)||qe.length===0||typeof qe[0]!="object"||qe[0]===null)continue;const mt=Y.fields.find(pe=>(pe.name||pe.key)===se)?.properties?.columns||[],tt=qe.map(ay);we[se]=tt.map(pe=>{const bt={};for(const Re of mt){const _t=Re.name??"",mn=Ln(_t),ro=pe[mn]??pe[_t];bt[_t]=ro}return bt})}const Dn=(se,Me)=>{const he=Qe(Ue,se);if(Array.isArray(he))return he;if(he!=null)return[he];if(!se.includes("."))return[];const qe=se.replace(/\.[^.]+$/,""),pt=Qe(Ue,qe);return!Array.isArray(pt)||pt.length===0||typeof pt[0]!="object"||pt[0]===null?[]:pt.map(mt=>{const tt=mt[Me];if(tt!==null&&typeof tt=="object"&&!Array.isArray(tt)&&!(tt instanceof Date)){const pe=tt;return typeof pe.name=="string"&&typeof pe.code=="string"?`${pe.code} ${pe.name}`.trim():typeof pe.name=="string"?pe.name:typeof pe.code=="string"?pe.code:typeof pe.short_code=="string"?pe.short_code:pe.name??pe.code??""}return tt})};for(const{tableName:se,columnName:Me,path:he}of ut){const qe=Dn(he,Me),mt=Y.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],tt=mt.find(Re=>(Re.name||"").toLowerCase()===Me.toLowerCase())?.name??Me;let pe=Array.isArray(we[se])?we[se]:[];const bt=Math.max(pe.length,qe.length);if(bt>pe.length)for(pe=[...pe];pe.length<bt;){const Re={};mt.forEach(_t=>{Re[_t.name||""]=""}),pe.push(Re)}else pe=pe.map(Re=>({...Re}));qe.forEach((Re,_t)=>{pe[_t]&&(pe[_t][tt]=Re)}),we[se]=pe}if(dt.current===Z){if(Object.keys(we).length>0||Object.keys(ct).length>0){const _t={...Nt.getState().values,...we,...ct};te(_t)}const Me=Qe(Ue,"data.user_id"),he=Qe(Ue,"data.items"),qe=Qe(Ue,"data");let pt=Array.isArray(he)&&he.length>0&&he[0]!=null&&typeof he[0]=="object"&&he[0].id?he[0].id:void 0;pt===void 0&&Array.isArray(qe)&&qe.length>0&&qe[0]!=null&&typeof qe[0]=="object"&&qe[0].id&&(pt=qe[0].id),pt===void 0&&(pt=Qe(Ue,"data.0.id"));const mt=qT(Ue,{treatFirstItemIdAsPaymentId:_?.treatFirstItemIdAsPaymentId===!0}),tt=Qe(Ue,"data.id"),pe=Qe(Ue,"data.batch_id"),bt=Qe(Ue,"data.program_id"),Re={};Me!=null&&(Re.context_user_id=Me),pt!=null&&pt!==""&&(Re.documentId=pt),tt!=null&&String(tt).trim()!==""&&(p?.id===void 0||p?.id===null)&&(Re.id=tt),pe!=null&&String(pe).trim()!==""&&((p?.admission_batch_id===void 0||p?.admission_batch_id===null)&&(Re.admission_batch_id=pe),(p?.batch_id===void 0||p?.batch_id===null)&&(Re.batch_id=pe)),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&&W(_t=>{const mn={..._t,...Re};return h?.(mn),mn}),Te(Ue)}}catch(ue){X||fc(ue,"Prepopulate request failed.",pi)}finally{B(!1)}})(),()=>{X=!0}},[Y.id,Y.config?.prepopulateApi?.enabled,Y.config?.prepopulateApi?.apiEndpoint,Y.config?.prepopulateApi?.apiMethod,JSON.stringify(Y.config?.prepopulateApi?.fieldMapping),Y.config?.prepopulateApi?.treatFirstItemIdAsPaymentId,p,g,Q,te,U]),S.useEffect(()=>{Object.keys(oe).length>0&&i?.(oe)},[oe,i]);const or=Ge>1,tn=a==="view",wt=S.useCallback((_,R)=>tn||!!R&&!In(_)||gr(_)&&!In(_),[tn,In,gr]),Ut=Y.fields.filter(_=>!_.parentId),Ft=[...or?yt:Ut.length>0?Ut:Y.fields].filter(_=>!(!_||typeof _!="object"||!_.name&&!_.key)).sort((_,R)=>{const V=typeof _.position?.order=="number"?_.position.order:typeof _.positionOrder=="number"?_.positionOrder:Number.MAX_SAFE_INTEGER,Z=typeof R.position?.order=="number"?R.position.order:typeof R.positionOrder=="number"?R.positionOrder:Number.MAX_SAFE_INTEGER;if(V!==Z)return V-Z;const X=typeof _.position?.column=="number"?_.position.column:1,ue=typeof R.position?.column=="number"?R.position.column:1;return X-ue}),ir=S.useCallback(_=>{const R=Nt.getState().errors,V=Object.keys(R).find(Z=>_.includes(Z));V&&requestAnimationFrame(()=>{document.querySelector(`[data-field-name="${V}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})})},[]),un=async _=>{if(_?.preventDefault(),or&&!Jt){if(!await dn())try{const Z=Nt.getState().errors;Bt.toast.error(pc(Z,Y.fields)||"Please fix the errors before continuing."),ir(Ft.map(X=>X.name||X.key||X.id).filter(Boolean))}catch{Bt.toast.error("Please fix the errors before continuing.")}return}const R=await ft(_);if(R&&R.success===!1&&R.errors?.length)try{const V=Nt.getState().errors;Bt.toast.error(pc(V,Y.fields)||"Submission failed. Please check the form."),ir(Ft.map(Z=>Z.name||Z.key||Z.id).filter(Boolean))}catch{Bt.toast.error("Submission failed. Please check the form.")}return R},fn=S.useCallback(()=>{At(),s&&s()},[At,s]),wn=S.useCallback((_,R)=>{const V=Y.fields.find(X=>X.type==="button"&&(X.name===_||X.key===_)),Z=QT(R,V);Z!=null&&String(Z).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&W(X=>{const ue={...X,payment_id:Z};return h?.(ue),ue}),ie(X=>{const ue={...X,[_]:R};return!Ko(R)||!(V?.type==="button"&&V.properties?.action==="submit")||Y.fields.filter(Be=>Be.type==="editButton").map(Be=>Be.name).forEach(Be=>delete ue[Be]),ue})},[Y.fields,p,h]),qt=S.useCallback(async()=>await et(),[et]),Mn=S.useCallback(()=>Nt.getState().errors,[]),nn=S.useMemo(()=>({...g||{},...M}),[g,M]),Kn=S.useMemo(()=>({...typeof p=="object"&&p!==null?p:{},...nn}),[p,nn]),ki=Y.config?.layout??Y.layout??"default",fa=["default","card","compact"].includes(ki)?ki:"default",_i={default:"",card:"bg-card border rounded-lg shadow-sm p-6",compact:"space-y-2"},Bo=S.useMemo(()=>{if(N)return;const _=Y.config?.theme?.cssVariables;if(!(!_&&!C))return{..._??{},...C??{}}},[N,Y.config?.theme?.cssVariables,C]),Ee=S.useMemo(()=>Mi({config:Y.config,layout:Y.layout},l),[Y.config,Y.layout,l]),P=S.useMemo(()=>Ee?{...Ee,verticalSpacing:Ee.verticalSpacing??Ee.spacing??"16px",horizontalSpacing:Ee.horizontalSpacing??Ee.spacing??"16px",rowHeight:Ee.rowHeight??$r}:null,[Ee]),ee=P!==null;P?.rows;const le=P?.columns??3,st=P?.verticalSpacing??P?.spacing??"16px",Pt=P?.horizontalSpacing??P?.spacing??"16px",kt=P?.rowHeight??$r,It=S.useCallback(_=>{if(!k)return!0;const R=_.visibility;if(!R)return!0;const V=R.visibleToUserType??R.user_type,Z=R.visibleToUserRole??R.user_role,X=Array.isArray(R.visibleToUserIds)?R.visibleToUserIds:Array.isArray(R.users)?R.users:[],ue=Array.isArray(R.hiddenFromUserIds)?R.hiddenFromUserIds:[];if(Array.isArray(ue)&&ue.length>0&&k.userId!=null&&ue.includes(k.userId))return!1;if(X.length>0&&k.userId!=null&&X.includes(k.userId))return!0;const Ae=V!=null&&V!==""&&k.userType!=null&&k.userType!==V,Ne=Z!=null&&Z!==""&&k.role!=null&&k.role!==Z,Be=X.length>0&&(k.userId==null||!X.includes(k.userId));return!(Ae||Ne||Be)},[k]),pn=S.useMemo(()=>uk(Y.fields),[Y.fields]),En=S.useMemo(()=>pk(Y.fields),[Y.fields]),[sr,Mt]=S.useState(En);S.useEffect(()=>{Mt(En)},[Y.id,En]);const Ti=S.useCallback((_,R)=>{Mt(V=>V[_]===R?V:{...V,[_]:R})},[]),pa=S.useMemo(()=>({visibility:sr,setSectionVisible:Ti,fieldToHeading:pn,allFields:Y.fields}),[sr,Ti,pn,Y.fields]),it=S.useCallback(_=>_.name||_.key||_.id,[]),Nn=_=>{if(!It(_))return!1;const R=_.name||_.key||_.id;if(!Hh(R,_.type,sr,pn))return!1;const V=_.hidden===!0;return Ct(R)||!V&&R},Ry=S.useCallback(_=>{const R=Y.fields.find(Z=>it(Z)===_);if(R)return R.type;const V=Uh(_);return Y.fields.find(Z=>it(Z)===V)?.type},[Y.fields,it]),ma=S.useCallback(_=>Hh(_,Ry(_),sr,pn),[sr,pn,Ry]),yr=S.useCallback(_=>ma(_)?Wn(_):!1,[ma,Wn]);S.useEffect(()=>{const{visibleFields:_,requiredFields:R,errors:V}=Nt.getState(),Z=new Set(_),X=new Set(R),ue=[];for(const Ae of Y.fields){const Ne=it(Ae);Ne&&(ma(Ne)||(Z.delete(Ne),X.delete(Ne),V[Ne]&&ue.push(Ne)))}Se(Array.from(Z)),ae(Array.from(X));for(const Ae of ue)ve(Ae,void 0)},[sr,pn,Y.fields,Y.id,it,ma,Se,ae,ve,Xe,ye]);const Lt=Y.config?.sections,to=S.useCallback(_=>{const R=it(_);let V=_;if(_.type==="table"){const X=_.properties?.columns;if(Array.isArray(X)&&X.length>0){const ue=X.filter(Ae=>It(Ae));V={..._,properties:{..._.properties,columns:ue}}}}const Z=rF(V,Lt,it);return Z&&(V={...V,label:Qg(Z,0)}),{...V,disabled:!Vt(R),readOnly:wt(R,!!V.readOnly)}},[It,Lt,it,Vt,wt]),br=S.useCallback(_=>Zg(_,Y.fields,Lt,it),[Y.fields,Lt,it]),Gn=S.useCallback((_,R,V)=>`${_}__addmore__${R}__${V}`,[]),ha=S.useCallback((_,R)=>`${_}__${R??"base"}`,[]),ga=S.useCallback((_,R)=>{const V=ha(_.id,R);return J[V]??_.defaultCollapsed??!1},[J,ha]),rd=S.useCallback((_,R,V)=>{const Z=ha(_,R);de(X=>X[Z]===V?X:{...X,[Z]:V})},[ha]),ya=S.useMemo(()=>{const _=[],R=Y.fields.filter(V=>V.type==="addmore");for(const V of R){const Z=it(V),ue=br(V).find(lt=>{if(lt.type!=="button")return!1;const Ht=lt.properties,De=lt.metadata;let Ue=Ht?.action;if(!Ue&&De!=null)try{Ue=(typeof De=="string"?JSON.parse(De):De)?.action}catch{}return Ue==="upload"||Ue==="custom"});if(!ue)continue;const Ae=it(ue),Ne=H[Z]||[],Be=Qe(j[Ae],"data.id")??Qe(j[Ae],"data.documentId")??M.documentId;Be!=null&&String(Be).trim()!==""&&_.push(String(Be));for(const lt of Ne){const Ht=Gn(Ae,Z,lt),De=Qe(j[Ht],"data.id")??Qe(j[Ht],"data.documentId"),Ue=ne[`${Z}__${lt}`],xe=De??Ue;xe!=null&&String(xe).trim()!==""&&_.push(String(xe))}}return _},[Y.fields,H,j,ne,M.documentId,it,br,Gn]);S.useEffect(()=>{W(_=>{const R={..._,document_ids:ya},V=_.document_ids;return Array.isArray(V)&&V.length===ya.length&&ya.every((Z,X)=>V[X]===Z)?_:R})},[ya]);const ba=S.useCallback((_,R,V,Z)=>{for(const X of V){const ue=it(X),Ae=Gn(ue,_,R),Ne=Z[Ae];if(Ne==null)continue;const Be=X.type;if(Be==="file"||Be==="camera"||Be==="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},[it,Gn]),no=S.useCallback(_=>{const R=it(_);if(!R)return;if(br(_).length===0){Bt.toast.error("No linked fields configured for this Add More button.");return}const Z=`${Date.now()}_${Math.random().toString(36).slice(2,8)}`;U(X=>({...X,[R]:[...X[R]||[],Z]}))},[it,br]),va=S.useCallback((_,R)=>{U(V=>{const Z=V[_]||[],X=Z.filter(ue=>ue!==R);if(X.length===Z.length)return V;if(X.length===0){const ue={...V};return delete ue[_],ue}return{...V,[_]:X}})},[]),wa=S.useMemo(()=>Ft.filter(_=>!_.parentId),[Ft]),Br=S.useMemo(()=>{const _=[];return Ft.filter(V=>V.type==="addmore").sort((V,Z)=>{const X=V.position?.order??0,ue=Z.position?.order??0;return X-ue}).forEach(V=>{const Z=it(V),X=V.position?.order??0,ue=H[Z]||[],Ae=br(V).sort((Ce,Ve)=>{const rt=Ce.position?.order??0,fe=Ve.position?.order??0;return rt!==fe?rt-fe:(Ce.position?.column??1)-(Ve.position?.column??1)});if(Ae.length===0)return;const Ne=Jg(V,Lt),Be=Ne[0]?.fieldNames?.length?Ne[0].fieldNames:Ae.map(Ce=>it(Ce)).filter(Boolean),lt=sF(Be,wa,le,it),Ht=Math.min(...Ae.map(Ce=>Ce.position?.order??0)),De=Math.max(1,...Ae.map(Ce=>(Ce.position?.order??Ht)-Ht+Vo(Ce))),Ue=lt?.blockHeight??De,xe=ue.length*Ue;_.push({addMoreFieldName:Z,baseOrder:X,blockHeight:Ue,blockIds:ue,linkedFields:Ae,insertedRows:xe,templateFieldNames:Be,templateBounds:lt})}),_},[Ft,wa,le,it,H,br,Lt]),Fi=S.useMemo(()=>({}),[]),Sa=S.useMemo(()=>Br.length===0?Ft:Ft.map(_=>{const R=_.position?.order??0,V=Br.reduce((Z,X)=>{const ue=X.templateBounds?.maxRow??X.baseOrder;return R>ue?Z+X.insertedRows:Z},0);return V===0?_:{..._,position:{..._.position,order:R+V}}}),[Ft,Br]),xa=S.useCallback(_=>{const R={};return Object.entries(j).forEach(([V,Z])=>{const X=_[V];X&&(R[X]=Z)}),R},[j]),$o=S.useMemo(()=>{const _=[],R={};return Br.forEach(V=>{const{addMoreFieldName:Z,blockIds:X,linkedFields:ue,blockHeight:Ae,templateBounds:Ne}=V,Be=Math.min(...ue.map(De=>De.position?.order??0)),Ht=Y.fields.find(De=>it(De)===Z&&De.type==="addmore")?.properties;X.forEach((De,Ue)=>{const xe={},Ce={},Ve={},rt=Ne?aF(Ne,Ue):V.baseOrder+1+Ue*Ae,fe=ne[`${Z}__${De}`];ue.forEach(we=>{const ut=it(we),Wt=Gn(ut,Z,De),Dt=(we.position?.order??Be)-Be;if(xe[Wt]=ut,Ce[Wt]=Ie[Wt],!(Ht?.linkedFieldAllowDuplicate?.[ut]??!0)&&(we.type==="select"||we.type==="radio"||we.type==="multiselect")){const vt=[],rn=Ie[ut];rn!=null&&rn!==""&&(Array.isArray(rn)?vt.push(...rn.map(qn=>String(qn))):vt.push(String(rn))),X.filter(qn=>qn!==De).forEach(qn=>{const Dn=Gn(ut,Z,qn),Yn=Ie[Dn];Yn!=null&&Yn!==""&&(Array.isArray(Yn)?vt.push(...Yn.map(se=>String(se))):vt.push(String(Yn)))}),vt.length>0&&(Ve[Wt]=[...new Set(vt)])}_.push({...we,id:`${we.id}__${De}`,name:Wt,position:{...we.position,order:rt+Dt}})});const Oe=xa(xe);Object.keys(xe).forEach(we=>{R[we]={scopedFormValues:Ce,scopedFieldNameMap:xe,scopedButtonResponses:Oe,...fe!=null&&{blockDocumentId:fe},...Ve[we]&&{excludedOptionValues:Ve[we]}}})})}),{clonedFields:_,scopeByFieldName:R}},[Br,ne,it,Gn,Ie,xa,Y.fields]),Pi=S.useMemo(()=>[...Sa,...$o.clonedFields].sort((_,R)=>{const V=_.position?.order??0,Z=R.position?.order??0;if(V!==Z)return V-Z;const X=_.position?.column??1,ue=R.position?.column??1;if(X!==ue)return X-ue;const Ae=Io(_.position)??0,Ne=Io(R.position)??0;return Ae!==Ne?Ae-Ne:String(_.id).localeCompare(String(R.id))}),[Sa,$o.clonedFields]),jo=S.useMemo(()=>MT(Pi.filter(_=>!_.parentId),Nn),[Pi,Nn]),od=S.useCallback((_,R)=>jo.some(V=>LT(_,R,V,le)),[jo,le]);jo.length===0||Math.max(...jo.map(_=>(_[0]?.position?.order??0)+xi(_,le).rowSpan));const Aa=S.useMemo(()=>oF(Lt,Rc(Ft.filter(_=>!_.parentId)),it),[Lt,Ft,it]),{anchorsByOrigin:Ky,coveredCells:Gy}=S.useMemo(()=>lF(Aa,Sa,it,le),[Aa,Sa,it,le]),{anchorsByOrigin:qy,coveredCells:Yy}=S.useMemo(()=>cF(Br.map(_=>({addMoreFieldName:_.addMoreFieldName,blockIds:_.blockIds,linkedFields:_.linkedFields,templateFieldNames:_.templateFieldNames})),Lt,$o.clonedFields,wa,le,it,Gy),[Br,Lt,$o.clonedFields,wa,le,it,Gy]),vr=S.useMemo(()=>hF(Ky,qy),[Ky,qy]),Xy=S.useMemo(()=>Yy,[Yy]),Jy=String(kt).endsWith("px")?kt:$r,Qy=S.useCallback((_,R)=>{for(let V=0;V<le;V++){if(V>=R.anchorCol&&V<R.anchorCol+R.colSpan)continue;if(Fi[`${_}-${V}`]||vr.get(`${_}-${V}`)||Gg(_,V,Pi,Nn).length>0||od(_,V))return!0}return!1},[le,Fi,vr,Pi,Nn,od]),Zy=S.useMemo(()=>pF(vr,_=>{const R=_.run.section;return R.collapsible?ga(R,_.addMoreMeta?.blockId):!1},Qy),[vr,ga,Qy]),eb=S.useMemo(()=>{const _=[];for(const R of Object.keys(Fi)){const V=Number(R.split("-")[0]);Number.isNaN(V)||_.push(V)}for(const R of vr.values())if(R.renderFields.some(V=>Nn(V)))for(let V=R.anchorRow;V<R.anchorRow+R.rowSpan;V++)_.push(V);return DT(jo,le,_)},[jo,le,Fi,vr,Nn]),{originalToDisplayRow:Ca,displayRowCount:aO,sortedOccupiedRows:lO}=S.useMemo(()=>{const _=BT(eb);return{originalToDisplayRow:_.originalToDisplay,displayRowCount:_.displayRowCount,sortedOccupiedRows:_.sortedOriginalRows}},[eb]),tb=Math.max(aO,1),id=S.useCallback((_,R=1)=>$T(_,R,Ca),[Ca]),nb=S.useMemo(()=>{const _=new Set;for(const R of Zy){const V=Ca.get(R);V!==void 0&&_.add(V)}return _},[Zy,Ca]),cO=S.useMemo(()=>mF(tb,Jy,nb),[tb,Jy,nb]),dO=S.useMemo(()=>gF(Ft.filter(_=>!_.parentId&&Nn(_)),Aa,it),[Ft,Aa,it,Nn]),Ea=S.useCallback(_=>{if(ee)return null;const R=it(_),V=H[R]||[];if(V.length===0)return null;const Z=br(_);if(Z.length===0)return null;const X=nF(_,Lt),ue=Z.map(Be=>it(Be)).filter(Boolean),Ae=ty(ue,Lt),Ne=(Be,lt,Ht,De,Ue,xe,Ce)=>{const Ve=it(Be),rt=Gn(Ve,R,lt),fe=Be.hidden===!0;if(!(It(Be)&&(Ct(Ve)||!fe&&Ve)))return null;const we={...Be,id:`${Be.id}__${lt}`,name:rt,disabled:!Vt(Ve),readOnly:wt(Ve,!!Be.readOnly)},Wt=_.properties?.linkedFieldAllowDuplicate?.[Ve]??!0;let Dt;if(!Wt&&(Be.type==="select"||Be.type==="radio"||Be.type==="multiselect")){const ct=[],vt=Ie[Ve];vt!=null&&vt!==""&&(Array.isArray(vt)?ct.push(...vt.map(Ln=>String(Ln))):ct.push(String(vt))),V.filter(Ln=>Ln!==lt).forEach(Ln=>{const qn=Gn(Ve,R,Ln),Dn=Ie[qn];Dn!=null&&Dn!==""&&(Array.isArray(Dn)?ct.push(...Dn.map(Yn=>String(Yn))):ct.push(String(Dn)))}),ct.length>0&&(Dt=[...new Set(ct)])}return d.jsx("div",{"data-field-name":rt,"data-form-renderer":"field-wrapper",children:d.jsx(pr,{field:we,value:Ie[rt],error:me[rt]||ze>0?oe[rt]:void 0,onChange:ct=>xt(rt,ct),onBlur:()=>Pe(rt),disabled:ce||!Vt(Ve)||tn,readOnly:wt(Ve,!!Be.readOnly),isRequired:yr(Ve),formValues:Ie,submissionContext:Kn,prepopulateMappedFieldNames:je,urlParams:Q,prepopulateResponse:re,prepopulateLoading:D,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:rt,buttonResponses:xe,onButtonApiResponse:wn,onSubmit:un,onReset:At,onCancel:fn,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:Ce,onValidateForm:qt,getValidationErrors:Mn,allFields:Y.fields,onSubmittingChange:ge,scopedFormValues:Ue,scopedFieldNameMap:De,excludedOptionValues:Dt,hideTableRowControls:x})},we.id)};return d.jsx("div",{className:"space-y-3 mt-3",children:V.map((Be,lt)=>{const Ht={},De={};Z.forEach(Dt=>{const ct=it(Dt),vt=Gn(ct,R,Be);Ht[vt]=ct,De[vt]=Ie[vt]});const Ue=xa(Ht),xe=ba(R,Be,Z,Ie),Ce=X?.heading!=null?Ci(X,lt+1):null,Ve=ne[`${R}__${Be}`],rt=Ve!=null?{...nn,documentId:Ve}:nn,fe=Z.map(Dt=>Ne(Dt,Be,lt,Ht,De,Ue,rt)).filter(Boolean),we=Ae?.section?.collapsible===!0,ut=d.jsx("button",{type:"button",className:"inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",disabled:xe,title:xe?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:Dt=>{Dt.preventDefault(),Dt.stopPropagation(),va(R,Be)},children:d.jsx(Xo,{className:"h-5 w-5","aria-hidden":!0})}),Wt=d.jsxs(d.Fragment,{children:[!we&&d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Ce?d.jsx("p",{className:"text-sm font-medium text-foreground",children:Ce}):d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Entry ",lt+1]}),ut]}),fe]});return d.jsx("div",{className:"rounded-md border p-3 space-y-3",children:Ae?d.jsx(zc,{legend:Ae.section.heading?.enabled?Ci(Ae.section,lt+1):Ae.section.name,collapsible:Ae.section.collapsible,defaultCollapsed:Ae.section.defaultCollapsed,headerActions:we?ut:void 0,onCollapsedChange:Dt=>rd(Ae.section.id,Be,Dt),children:Wt}):Wt},`${_.id}-${Be}`)})})},[ee,H,ne,it,br,Gn,ba,Ie,me,ze,oe,xt,Pe,Vt,tn,yr,Kn,je,wn,un,At,fn,We,$,m,nn,qt,Mn,Y.fields,ge,Ct,It,xa,va,x,Lt,Q,re,D]);return d.jsx("div",{className:N?z("relative",c):z(_a,F&&"dark",c),style:Bo,"data-form-renderer":N?void 0:"root",children:d.jsxs("div",{className:"relative",children:[D&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:d.jsx(Dr,{})}),d.jsx("form",{onSubmit:un,className:f?z("w-full min-w-0"):z("space-y-6 pb-[100px] w-full min-w-0",_i[fa]),"data-form-renderer":"form","data-form-renderer-layout":ee?"grid":"stack",children:d.jsxs(lk,{value:pa,children:[or&&Y.steps&&d.jsx(CT,{steps:Y.steps,currentStep:Fe,completedSteps:nt,onStepClick:rr}),d.jsx(ja.Provider,{value:{gridStretch:ee},children:ee?d.jsx("div",{className:f?"w-full min-w-0":"grid w-full min-w-0",style:{display:"grid",gridTemplateRows:cO,gridTemplateColumns:`repeat(${le}, 1fr)`,rowGap:st,columnGap:Pt},"data-form-renderer":"grid",children:lO.map(_=>Array.from({length:le},(R,V)=>{const Z=id(_);if(!Z)return null;if(od(_,V))return d.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:V+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${V}`);if(dF(_,V,Xy,vr)){const xe=uF(_,V,vr);return xe&&fF(_,V,xe,ga(xe.run.section,xe.addMoreMeta?.blockId))?null:d.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:V+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`section-border-cover-${_}-${V}`)}const X=vr.get(`${_}-${V}`);if(X){const xe=X.renderFields.filter(ct=>Nn(ct));if(xe.length===0)return null;const Ce=X.addMoreMeta,Ve=Ce!=null?Br.find(ct=>ct.addMoreFieldName===Ce.addMoreFieldName)?.linkedFields??[]:[],rt=Ce!=null?ba(Ce.addMoreFieldName,Ce.blockId,Ve,Ie):!1,fe=X.run.section,Oe=Ce?.blockId,we=ga(fe,Oe),ut=fe.collapsible&&we?1:X.rowSpan,Wt=id(X.anchorRow,ut)??Z,Dt=Ce!=null?d.jsx("button",{type:"button",className:z("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:ct=>{ct.preventDefault(),ct.stopPropagation(),va(Ce.addMoreFieldName,Ce.blockId)},children:d.jsx(Xo,{className:"h-5 w-5","aria-hidden":!0})}):void 0;return d.jsx("div",{className:z("min-h-0 min-w-0",!(fe.collapsible&&we)&&"self-stretch"),style:{gridRow:Wt,gridColumn:`${V+1} / span ${X.colSpan}`},"data-form-renderer":"grid-cell","data-form-renderer-config-section-border-cell":!0,children:d.jsx(zc,{legend:X.legend,className:fe.collapsible&&we?void 0:"h-full",collapsible:fe.collapsible,defaultCollapsed:fe.defaultCollapsed,headerActions:Dt,onCollapsedChange:ct=>rd(fe.id,Oe,ct),children:d.jsx("div",{className:"grid w-full min-w-0",style:{gridTemplateColumns:`repeat(${le}, 1fr)`,gridTemplateRows:`repeat(${X.rowSpan}, minmax(${String(kt).endsWith("px")?kt:$r}, auto))`,rowGap:st,columnGap:Pt},children:xe.map(ct=>{const vt=it(ct),rn=$o.scopeByFieldName[vt],Ln=rn?.scopedFieldNameMap?.[vt]||vt,qn=(ct.position?.order??X.anchorRow)-X.anchorRow,Dn=ct.position?.column??1,{rowSpan:Yn,columnSpan:se}=xi([ct],le),Me=Ce!=null?ne[`${Ce.addMoreFieldName}__${Ce.blockId}`]:void 0,he=Me!=null?{...nn,documentId:Me}:nn;return d.jsx("div",{"data-field-name":vt,"data-form-renderer":"field-wrapper",className:"min-h-0 min-w-0",style:{gridRow:`${qn+1} / span ${Yn}`,gridColumn:`${Dn} / span ${se}`,...Nr(ct)},children:d.jsx(pr,{field:to(ct),value:Ie[vt],error:me[vt]||ze>0?oe[vt]:void 0,onChange:qe=>xt(vt,qe),onBlur:()=>Pe(vt),disabled:(ct.type==="table"||ct.type==="billingGrid")&&a==="fill"?!1:ce||!Vt(Ln)||tn,readOnly:(ct.type==="table"||ct.type==="billingGrid")&&a==="fill"?!1:wt(Ln,!!ct.readOnly),isRequired:yr(Ln),formValues:Ie,submissionContext:Kn,prepopulateMappedFieldNames:je,urlParams:Q,prepopulateResponse:re,prepopulateLoading:D,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:vt,buttonResponses:rn?.scopedButtonResponses??j,onButtonApiResponse:wn,onSubmit:un,onReset:At,onCancel:fn,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:he,onValidateForm:qt,getValidationErrors:Mn,allFields:Y.fields,onSubmittingChange:ge,onAddMore:no,scopedFormValues:rn?.scopedFormValues,scopedFieldNameMap:rn?.scopedFieldNameMap,excludedOptionValues:rn?.excludedOptionValues,hideTableRowControls:x})},ct.id)})})})},`section-border-${X.run.section.id}-${_}-${V}-${Ce?.blockId??"base"}`)}const ue=Gg(_,V,Pi,Nn).filter(xe=>!(it(xe)?.includes("__addmore__")&&Xy.has(`${_}-${V}`)));if(ue.length===0){const xe=Fi[`${_}-${V}`];if(xe){const Ce=Y.fields.find(fe=>fe.type==="addmore"&&it(fe)===xe.addMoreFieldName),Ve=Ce!=null?br(Ce):[],rt=ba(xe.addMoreFieldName,xe.blockId,Ve,Ie);return d.jsx("div",{className:"min-h-0 min-w-0 flex flex-col items-center justify-center",style:{gridRow:Z,gridColumn:V+1},"data-form-renderer":"grid-cell","data-form-renderer-add-more-remove":!0,children:d.jsx("button",{type:"button",className:z("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(),va(xe.addMoreFieldName,xe.blockId)},children:d.jsx(Xo,{className:"h-5 w-5","aria-hidden":!0})})},`add-more-remove-${_}-${V}`)}return d.jsx("div",{className:"min-w-0",style:{pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${V}`)}const Ae=ue[0],{rowSpan:Ne,columnSpan:Be}=xi(ue,le),lt=id(_,Ne)??Z;if(ue.length===1&&Ae.type==="section"){const xe=Y.fields.filter(Ce=>Ce.parentId===Ae.id&&Ce.position!=null).sort((Ce,Ve)=>{const rt=typeof Ce.position?.order=="number"?Ce.position.order:0,fe=typeof Ve.position?.order=="number"?Ve.position.order:0;return rt-fe});return d.jsx("div",{className:"min-w-0 min-h-0 w-full overflow-hidden flex flex-col h-full",style:{gridRow:lt,gridColumn:`${V+1} / span ${Be}`,...Nr(Ae)},"data-form-renderer":"grid-cell",children:d.jsx(hg,{field:Ae,children:xe.map(Ce=>{const Ve=Ce.name||Ce.key||Ce.id,rt=Ce.hidden===!0;return It(Ce)&&(Ct(Ve)||!rt&&Ve)?d.jsx("div",{"data-field-name":Ve,"data-form-renderer":"field-wrapper",children:d.jsx(pr,{field:to(Ce),value:Ie[Ve],error:me[Ve]||ze>0?oe[Ve]:void 0,onChange:Oe=>xt(Ve,Oe),onBlur:()=>Pe(Ve),disabled:ce||!Vt(Ve)||tn,readOnly:wt(Ve,!!Ce.readOnly),isRequired:yr(Ve),formValues:Ie,submissionContext:Kn,prepopulateMappedFieldNames:je,urlParams:Q,prepopulateResponse:re,prepopulateLoading:D,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:Ve,buttonResponses:j,onButtonApiResponse:wn,onSubmit:un,onReset:At,onCancel:fn,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:nn,onValidateForm:qt,getValidationErrors:Mn,allFields:Y.fields,onSubmittingChange:ge,onAddMore:no,hideTableRowControls:x})},Ce.id):null})})},Ae.id)}const Ht=Rg(ue),De=ue.some(xe=>["file","camera","photoChoice","addmore","table","billingGrid"].includes(xe.type)),Ue=d.jsx("div",{className:z("flex min-h-0 w-full flex-1 gap-3",Ht==="row"?"flex-row items-stretch":"flex-col items-stretch"),children:ue.map(xe=>{const Ce=xe.name||xe.key||xe.id,Ve=xe.type==="sectionHeading",rt=$o.scopeByFieldName[Ce],fe=rt?.scopedFieldNameMap?.[Ce]||Ce,Oe=rt?.blockDocumentId!=null?{...nn,documentId:rt.blockDocumentId}:nn,we=xe.appearance?.hideLabel??xe.properties?.hideLabel??!1,ut=xe.type==="table"||xe.type==="billingGrid"?xe.properties?.minWidth:void 0;return d.jsx("div",{"data-field-name":Ce,"data-form-renderer":"field-wrapper",className:z("flex min-h-0 min-w-0 flex-1 flex-col",Wo(xe),Ve&&"items-center justify-center",we&&"items-center"),style:{...ut?{minWidth:ut}:{},...Nr(xe)},children:d.jsx(pr,{field:to(xe),value:Ie[Ce],error:me[Ce]||ze>0?oe[Ce]:void 0,onChange:Wt=>xt(Ce,Wt),onBlur:()=>Pe(Ce),disabled:(xe.type==="table"||xe.type==="billingGrid")&&a==="fill"?!1:ce||!Vt(fe)||tn,readOnly:(xe.type==="table"||xe.type==="billingGrid")&&a==="fill"?!1:wt(fe,!!xe.readOnly),isRequired:yr(fe),formValues:Ie,submissionContext:Kn,prepopulateMappedFieldNames:je,urlParams:Q,prepopulateResponse:re,prepopulateLoading:D,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:Ce,buttonResponses:rt?.scopedButtonResponses??j,onButtonApiResponse:wn,onSubmit:un,onReset:At,onCancel:fn,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:Oe,onValidateForm:qt,getValidationErrors:Mn,allFields:Y.fields,onSubmittingChange:ge,onAddMore:no,scopedFormValues:rt?.scopedFormValues,scopedFieldNameMap:rt?.scopedFieldNameMap,excludedOptionValues:rt?.excludedOptionValues,hideTableRowControls:x})},xe.id)})});return d.jsx("div",{className:z(Id(ue),"self-stretch",De?"overflow-visible":"overflow-hidden"),style:{gridRow:lt,gridColumn:`${V+1} / span ${Be}`,...Nr(ue[0])},"data-form-renderer":"grid-cell","data-field-name":ue.map(xe=>xe.name||xe.key||xe.id).join(","),children:Ue},ue.map(xe=>xe.id).join("-"))}))}):d.jsx("div",{className:f?"":"space-y-4","data-form-renderer":"stack",children:Ft.map(_=>{if(!Nn(_))return null;const R=dO.find(Z=>Z.kind==="border"&&Z.fields.some(X=>X.id===_.id));if(R)return R.fields[0]?.id!==_.id?null:d.jsx(zc,{legend:Ci(R.run.section,0),collapsible:R.run.section.collapsible,defaultCollapsed:R.run.section.defaultCollapsed,onCollapsedChange:Z=>rd(R.run.section.id,void 0,Z),children:R.fields.map(Z=>{const X=it(Z);return!X||!Nn(Z)?null:d.jsxs("div",{"data-field-name":X,"data-form-renderer":"field-wrapper",style:Nr(Z),children:[d.jsx(pr,{field:to(Z),value:Ie[X],error:me[X]||ze>0?oe[X]:void 0,onChange:ue=>xt(X,ue),onBlur:()=>Pe(X),disabled:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:ce||!Vt(X)||tn,readOnly:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:wt(X,!!Z.readOnly),isRequired:yr(X),formValues:Ie,submissionContext:Kn,prepopulateMappedFieldNames:je,urlParams:Q,prepopulateResponse:re,prepopulateLoading:D,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:X,buttonResponses:j,onButtonApiResponse:wn,onSubmit:un,onReset:At,onCancel:fn,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:nn,onValidateForm:qt,getValidationErrors:Mn,allFields:Y.fields,onSubmittingChange:ge,onAddMore:no,hideTableRowControls:x}),Z.type==="addmore"&&Ea(Z)]},Z.id)})},`stack-border-${R.run.section.id}-${_.id}`);if(!_.parentId){const Z=Ft.filter(ue=>!ue.parentId&&Nn(ue)&&la(ue)===la(_)),X=Uc(Z).slice(0,2);if(X.length>1&&X[0].id!==_.id)return null;if(X.length>1){const ue=Rg(X);return d.jsx("div",{"data-form-renderer":"shared-cell-stack",className:z("flex w-full min-w-0 gap-3",ue==="row"?"flex-row items-stretch":"flex-col"),children:X.map(Ae=>{const Ne=Ae.name||Ae.key||Ae.id;return d.jsxs("div",{"data-field-name":Ne,"data-form-renderer":"field-wrapper",className:z("min-w-0 flex-1 flex flex-col",Wo(Ae)),style:Nr(Ae),children:[d.jsx(pr,{field:to(Ae),value:Ie[Ne],error:me[Ne]||ze>0?oe[Ne]:void 0,onChange:Be=>xt(Ne,Be),onBlur:()=>Pe(Ne),disabled:(Ae.type==="table"||Ae.type==="billingGrid")&&a==="fill"?!1:ce||!Vt(Ne)||tn,readOnly:(Ae.type==="table"||Ae.type==="billingGrid")&&a==="fill"?!1:wt(Ne,!!Ae.readOnly),isRequired:yr(Ne),formValues:Ie,submissionContext:Kn,prepopulateMappedFieldNames:je,urlParams:Q,prepopulateResponse:re,prepopulateLoading:D,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:Ne,buttonResponses:j,onButtonApiResponse:wn,onSubmit:un,onReset:At,onCancel:fn,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:nn,onValidateForm:qt,getValidationErrors:Mn,allFields:Y.fields,onSubmittingChange:ge,onAddMore:no,hideTableRowControls:x}),Ae.type==="addmore"&&Ea(Ae)]},Ae.id)})},X.map(Ae=>Ae.id).join("-"))}}if(_.type==="section"){const Z=Y.fields.filter(X=>X.parentId===_.id&&X.position!=null).sort((X,ue)=>{const Ae=typeof X.position?.order=="number"?X.position.order:0,Ne=typeof ue.position?.order=="number"?ue.position.order:0;return Ae-Ne});return d.jsx(hg,{field:_,children:Z.map(X=>{const ue=X.name||X.key||X.id,Ae=X.hidden===!0;return It(X)&&(Ct(ue)||!Ae&&ue)?d.jsxs("div",{"data-field-name":ue,"data-form-renderer":"field-wrapper",style:Nr(X),children:[d.jsx(pr,{field:to(X),value:Ie[ue],error:me[ue]||ze>0?oe[ue]:void 0,onChange:Be=>xt(ue,Be),onBlur:()=>Pe(ue),disabled:ce||!Vt(ue)||tn,readOnly:wt(ue,!!X.readOnly),isRequired:yr(ue),formValues:Ie,submissionContext:Kn,prepopulateMappedFieldNames:je,urlParams:Q,prepopulateResponse:re,prepopulateLoading:D,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:ue,buttonResponses:j,onButtonApiResponse:wn,onSubmit:un,onReset:At,onCancel:fn,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:nn,onValidateForm:qt,getValidationErrors:Mn,allFields:Y.fields,onSubmittingChange:ge,onAddMore:no,hideTableRowControls:x}),X.type==="addmore"&&Ea(X)]},X.id):null})},_.id)}const V=_.name||_.key||_.id;return d.jsxs("div",{"data-field-name":V,"data-form-renderer":"field-wrapper",style:Nr(_),children:[d.jsx(pr,{field:to(_),value:Ie[V],error:me[V]||ze>0?oe[V]:void 0,onChange:Z=>xt(V,Z),onBlur:()=>Pe(V),disabled:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:ce||!Vt(V)||tn,readOnly:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:wt(V,!!_.readOnly),isRequired:yr(V),formValues:Ie,submissionContext:Kn,prepopulateMappedFieldNames:je,urlParams:Q,prepopulateResponse:re,prepopulateLoading:D,formSections:Lt,submitPayload:Y.config?.submitPayload,fieldValueKey:V,buttonResponses:j,onButtonApiResponse:wn,onSubmit:un,onReset:At,onCancel:fn,isSubmitting:We,bffSubmitApi:$,onBffSubmitResult:m,extraSubmitPayload:nn,onValidateForm:qt,getValidationErrors:Mn,allFields:Y.fields,onSubmittingChange:ge,onAddMore:no,hideTableRowControls:x}),_.type==="addmore"&&Ea(_)]},_.id)})})}),u]})})]})})};function qc(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function ly(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function wF(e,t){const n=e.form;if(!n)throw new Error("workflowStateToFormSchema requires workflowState.form to be set");const r=n.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});r.forEach((l,f)=>{(!l||typeof l.order!="number"||isNaN(l.order))&&(l.order=f)});let o=n.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 i=r.filter(l=>l!=null&&typeof l=="object"&&typeof l.order=="number"&&!isNaN(l.order));let s={};const a=n.config;if(a!=null)if(typeof a=="string")try{s=JSON.parse(a)}catch{}else typeof a=="object"&&a!==null&&(s={...a});const c=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=i.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:n._id,name:n.name,description:n.description??"",version:n.version,status:n.status,fields:i.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=qc(p.appearance)),p.ui!==void 0&&(h.ui=qc(p.ui)),p.visibility!==void 0&&(h.visibility=qc(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,O={...m};if(A.fileSize!==void 0&&(O.maxSize=A.fileSize),A.fileType&&Array.isArray(A.fileType)){const E=[];A.fileType.forEach(L=>{const G=L.startsWith(".")?L:`.${L}`;E.push(G),G===".csv"?E.push("text/csv"):G===".xls"?E.push("application/vnd.ms-excel"):G===".xlsx"&&E.push("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}),O.accept=E}h.metadata=O,O.maxSize!==void 0&&(h.maxSize=O.maxSize),O.accept!==void 0&&(h.accept=O.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,(O,E)=>{const L=t[E];return L!==void 0?String(L):O}),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 O=l.apidata.apiEndpoint;O=O.replace(/\{ctx:([^}]+)\}/g,(E,L)=>{const G=t[L];return G!==void 0?String(G):E}),A.apiEndpoint=O,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=ly(y.position),v=l.metadata&&typeof l.metadata=="object"&&!Array.isArray(l.metadata)?l.metadata:{},x=ly(y.layout),F={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},N=Io(w,{cellSlotIndex:y.cellSlotIndex??x.cellSlotIndex,stackSlot:v.stackSlot??x.stackSlot});typeof N=="number"&&(F.cellSlot=N);const T=w.cellGroupId??x.cellGroupId;typeof T=="string"&&(F.cellGroupId=T);const k=Si(w)??Si(x)??(v.stackDirection==="horizontal"||x.stackDirection==="horizontal"?"row":v.stackDirection==="vertical"||x.stackDirection==="vertical"?"stack":void 0);return(k==="row"||k==="stack")&&(F.sharedCellLayout=k),h.position=F,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:{...s,layout:o,...n.rules&&n.rules.length>0&&{rules:n.rules.map(c)},...n.clientMapping&&Object.keys(n.clientMapping).length>0&&{clientMapping:n.clientMapping}},...n.rules&&n.rules.length>0&&{rules:n.rules.map(c)},createdAt:"",updatedAt:"",moduleId:""};return ca(u)}var da="Tabs",[SF]=Sn(da,[qs]),cy=qs(),[xF,Yc]=SF(da),dy=b.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:c="automatic",...u}=e,l=ao(a),[f,p]=er({prop:r,onChange:o,defaultProp:i??"",caller:da});return d.jsx(xF,{scope:n,baseId:lr(),value:f,onValueChange:p,orientation:s,dir:l,activationMode:c,children:d.jsx($e.div,{dir:l,"data-orientation":s,...u,ref:t})})});dy.displayName=da;var uy="TabsList",fy=b.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Yc(uy,n),s=cy(n);return d.jsx(nh,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:r,children:d.jsx($e.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});fy.displayName=uy;var py="TabsTrigger",my=b.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=Yc(py,n),a=cy(n),c=yy(s.baseId,r),u=by(s.baseId,r),l=r===s.value;return d.jsx(rh,{asChild:!0,...a,focusable:!o,active:l,children:d.jsx($e.button,{type:"button",role:"tab","aria-selected":l,"aria-controls":u,"data-state":l?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...i,ref:t,onMouseDown:Le(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(r):f.preventDefault()}),onKeyDown:Le(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(r)}),onFocus:Le(e.onFocus,()=>{const f=s.activationMode!=="manual";!l&&!o&&f&&s.onValueChange(r)})})})});my.displayName=py;var hy="TabsContent",gy=b.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=Yc(hy,n),c=yy(a.baseId,r),u=by(a.baseId,r),l=r===a.value,f=b.useRef(l);return b.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),d.jsx(Cn,{present:o||l,children:({present:p})=>d.jsx($e.div,{"data-state":l?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!p,id:u,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:p&&i})})});gy.displayName=hy;function yy(e,t){return`${e}-trigger-${t}`}function by(e,t){return`${e}-content-${t}`}var AF=dy,CF=fy,EF=my,NF=gy;function vy({className:e,...t}){return d.jsx(AF,{"data-slot":"tabs",className:z("flex flex-col gap-2",e),...t})}function wy({className:e,...t}){return d.jsx(CF,{"data-slot":"tabs-list",className:z("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function Sy({className:e,...t}){return d.jsx(EF,{"data-slot":"tabs-trigger",className:z("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 xy({className:e,...t}){return d.jsx(NF,{"data-slot":"tabs-content",className:z("flex-1 outline-none",e),...t})}function cn({className:e="",...t}){return d.jsx("div",{"data-slot":"skeleton","data-form-renderer":"skeleton",className:`animate-pulse rounded-md bg-neutral-200 dark:bg-neutral-700 ${e}`.trim(),...t})}function kF({className:e=""}){return d.jsxs("div",{className:`flex flex-col gap-4 ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:[d.jsxs("div",{className:"flex w-full border-b border-neutral-200 dark:border-neutral-700 gap-0",children:[d.jsx(cn,{className:"h-10 w-24 rounded-none"}),d.jsx(cn,{className:"h-10 w-28 rounded-none ml-1"}),d.jsx(cn,{className:"h-10 w-20 rounded-none ml-1"})]}),d.jsxs("div",{className:"mt-4 flex flex-col gap-4 py-4",children:[d.jsx(cn,{className:"h-4 w-32"}),d.jsx(cn,{className:"h-10 w-full"}),d.jsx(cn,{className:"h-4 w-40"}),d.jsx(cn,{className:"h-10 w-full"}),d.jsx(cn,{className:"h-4 w-36"}),d.jsx(cn,{className:"h-24 w-full"})]})]})}function _F(){return d.jsxs("div",{className:"flex flex-col gap-4 py-4","data-form-renderer":"form-loading-skeleton",children:[d.jsx(cn,{className:"h-4 w-28"}),d.jsx(cn,{className:"h-10 w-full"}),d.jsx(cn,{className:"h-4 w-36"}),d.jsx(cn,{className:"h-10 w-full"}),d.jsx(cn,{className:"h-4 w-24"}),d.jsx(cn,{className:"h-20 w-full"})]})}const TF=3e4,FF=10*6e4,PF=9e4,OF=15*6e4;function IF(e){return e!=null&&"on_success"in e&&e.on_success!=null}function MF(e,t){if(!t||typeof t!="object")return e;let n=e;return Object.entries(t).forEach(([r,o])=>{o!=null&&o!==""&&(n=n.replace(new RegExp(`\\{${r}\\}`,"g"),String(o)))}),n}const Ay=({getWorkflowState:e,moduleId:t,tenantId:n,submissionContext:r,initialValues:o={},getAuthHeaders:i,onSuccess:s,bootstrapFeatureId:a,subjectUserId:c,viewStepId:u,clientId:l,className:f,onWorkflowSubmitResult:p,viewerContext:m,getViewerContext:g,dark:h=!1,themeVars:y})=>{const w=wr.useQueryClient(),v=S.useMemo(()=>[c??"",u??"",l??""],[c,u,l]),x=S.useMemo(()=>({moduleId:t,tenantId:n,subjectUserId:c,viewStepId:u,clientId:l}),[t,n,c,u,l]),[C,F]=S.useState([]),[N,T]=S.useState(null),[k,A]=S.useState(null),[O,E]=S.useState(null),[L,G]=S.useState({}),I=S.useRef(null),$=S.useRef(null),D=S.useRef(null),B=S.useRef(null),M=S.useMemo(()=>C&&Array.isArray(C)?C.filter(ae=>ae.feature_id):[],[C]),W=wr.useQuery({queryKey:["workflow-steps",t,a??"",n??"",v[0],v[1],v[2]],queryFn:()=>e({...x,featureId:a}),staleTime:TF,gcTime:FF}),j=W.isPending,ie=W.error?W.error instanceof Error?W.error.message:"Failed to load workflow steps":null;S.useEffect(()=>{const ae=W.data;if(!ae||C.length>0)return;const ve=ae.steps&&Array.isArray(ae.steps)?ae.steps:[];F(ve);const He=ve.filter(dt=>dt.feature_id);if(He.length>0){const dt=ae.current_step_id,Ke=dt&&He.some(Gt=>Gt.step_id===dt);T(Ke?dt:He[0].step_id)}},[W.data,C.length,a]);const H=S.useMemo(()=>{if(!N)return;const ae=C.find(He=>He.step_id===N),ve=I.current===N;return ae?.feature_id??(ve?B.current:void 0)??void 0},[N,C]),U=wr.useQuery({queryKey:["workflow-step",t,H??"",n??"",v[0],v[1],v[2]],queryFn:()=>e({...x,featureId:H}),enabled:!!H,staleTime:PF,gcTime:OF,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),J=U.isPending,de=U.error?U.error instanceof Error?U.error.message:"Failed to load form":null;S.useEffect(()=>{!U.data||I.current===N||(A(U.data),E(null),I.current=null,B.current=null)},[U.data,N]),S.useEffect(()=>{E(de)},[de]),S.useEffect(()=>{H===void 0&&I.current!==N&&(A(null),E(null),I.current=null,B.current=null)},[H,N]);const ne=S.useMemo(()=>{const ae=k?.form;if(!ae)return null;const ve=(n??Mr()??"").trim()||"default",He=iy({scope:ve,formId:ae._id,version:ae.version});return He?.value?He.value:wF(k,r)},[k,r,n]),q=S.useMemo(()=>{const ae=k?.BFF_submit_api;if(!ae?.url)return;let ve=ae.url;if(ve.startsWith("http://")||ve.startsWith("https://"))try{const Ke=new URL(ve);ve=Ke.pathname+Ke.search}catch{}const He=i?.()??{},dt={...ae.headers||{},"Content-Type":"application/json",...He};return{...ae,url:ve,headers:dt}},[k?.BFF_submit_api,i]),re=S.useMemo(()=>ne?{...ne,status:"published",...q&&{BFF_submit_api:q}}:null,[ne,q]);S.useEffect(()=>{if(!ne?.id)return;const ae=(n??Mr()??"").trim()||"default";sy({scope:ae,formId:ne.id,version:ne.version},ne)},[ne,n]);const Te=S.useMemo(()=>{if(!ne)return null;const ae=Mi({config:ne.config,layout:ne.layout},null);if(!ae)return null;const ve=ae.rows,He=ae.columns,dt={verticalSpacing:ae.verticalSpacing??ae.spacing??"16px",horizontalSpacing:ae.horizontalSpacing??ae.spacing??"16px",rowHeight:ae.rowHeight??$r};let Ke=1;if(Array.isArray(ne.fields))for(const Je of ne.fields){const Y=Je?.position,je=typeof Y?.order=="number"?Y.order:0,gt=typeof Y?.rowSpan=="number"?Y.rowSpan:1;Ke=Math.max(Ke,je+gt)}return{rows:Math.min(ve,Math.max(1,Ke)),columns:He,verticalSpacing:dt.verticalSpacing,horizontalSpacing:dt.horizontalSpacing,rowHeight:dt.rowHeight}},[ne]),Q=S.useMemo(()=>{const ve=re?.config?.theme?.cssVariables;if(!(!ve&&!y))return{...ve??{},...y??{}}},[re?.config,y]),te=S.useCallback(()=>{w.invalidateQueries({queryKey:["workflow-steps",t]}),w.invalidateQueries({queryKey:["workflow-step",t]})},[w,t]),ge=S.useCallback(ae=>{if(IF(ae)){const Ke=ae.on_success,Gt=Ke?.action;if(Gt==="redirect"&&Ke?.redirect_url){const Je=MF(Ke.redirect_url.trim(),r);window.location.href=Je;return}if(Gt==="move"){const Je=Ke?.next_step_id,Y=Ke?.next_step_form;if(Je&&Y){I.current=null,B.current=null;const je=Y.featureId??Ke?.next_step_form_id??Y._id;w.removeQueries({queryKey:["workflow-step",t,je,n??"",v[0],v[1],v[2]]}),te(),F(gt=>gt.some(oe=>oe.step_id===Je)?gt:[...gt,{step_id:Je,step_name:Y.name||"Next step",feature_id:je}]),A(null),T(Je),s?.();return}return}if(Gt==="stay"){te(),s?.();return}}const ve=ae;ve.steps&&Array.isArray(ve.steps)&&F(ve.steps);const He=(ve.steps&&Array.isArray(ve.steps)?ve.steps:C).filter(Ke=>Ke.feature_id),dt=ve.current_step_id;dt&&He.some(Ke=>Ke.step_id===dt)?T(dt):He.length>0&&T(He[0].step_id),A(null),te(),s?.(),p?.(ve)},[w,t,n,s,p,C,r,v,te]),ce=S.useCallback(async ae=>k?.BFF_submit_api?(s?.(),{success:!0,message:"Saved successfully"}):{success:!1,message:"Submit not configured"},[k?.BFF_submit_api,s]),Xe=S.useCallback((ae,ve)=>{},[]),ye=S.useCallback(ae=>{},[]);if(j)return d.jsx(kF,{className:f});if(ie)return d.jsx("div",{className:z("rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",f),children:ie});if(M.length===0)return d.jsx("div",{className:z("py-12 text-center text-sm text-muted-foreground",f),children:"No workflow steps configured."});const Se=k?.step_blocked_message;return d.jsx("div",{className:z(_a,h&&"dark","flex flex-col gap-4",f),style:Q,"data-form-renderer":"workflow-steps-view",children:d.jsxs(vy,{value:N??"",onValueChange:ae=>T(ae),children:[d.jsx(wy,{className:"w-full justify-start border-b rounded-none h-auto p-0 bg-transparent gap-0","data-form-renderer":"workflow-tabs",children:M.map(ae=>d.jsx(Sy,{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))}),M.map(ae=>d.jsx(xy,{value:ae.step_id,className:"mt-4 outline-none",children:ae.step_id!==N?null:J?d.jsx(_F,{}):O?d.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:O}):Se&&!k?.form?d.jsx("div",{className:z("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:Se}):re?.fields?.length?d.jsxs("div",{className:"py-4 [&_*]:box-border",children:[Se?d.jsx("div",{className:z("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:Se}):null,(()=>{const ve=$.current!==N||D.current!==(re?.id??null);if(N&&re&&ve){$.current=N,D.current=re.id??null;const He=Nt.getState();He.setSchema(re,{forceReset:!0});const dt=Nt.getState().values;He.setValues({...dt,...o})}return null})(),d.jsx(Gc,{schema:re,gridLayout:Te,omitRootWrapper:!0,submissionContext:r,initialValues:o,workflowStepId:N??void 0,viewerContext:m,getViewerContext:g,onSubmit:ce,onChange:Xe,onValidationError:ye,onClose:()=>{},mode:"fill",unstyled:!0,onWorkflowSubmitResult:ge,initialExtraSubmitPayload:Object.keys(L).length>0?L:void 0,onExtraSubmitPayloadChange:ve=>{if(ve&&typeof ve=="object"){const He={};ve.context_user_id!=null&&(He.context_user_id=ve.context_user_id),ve.id!=null&&(He.id=ve.id),ve.batch_id!=null&&(He.batch_id=ve.batch_id),ve.admission_batch_id!=null&&(He.admission_batch_id=ve.admission_batch_id),ve.program_id!=null&&(He.program_id=ve.program_id),Object.keys(He).length>0&&G(dt=>({...dt,...He}))}}},re.id)]}):d.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No form schema available for this step."})},ae.step_id))]})})};function LF(e){return typeof e=="object"&&e!==null&&"apiEndpoint"in e}function DF({formSchema:e}){const t=S.useMemo(()=>{if(!e)return[];const i=[];(!e.name||e.name.trim()==="")&&i.push({id:"form-name-required",type:"error",message:"Form name is required"});const s=new Set,a=new Set;e.fields.forEach((l,f)=>{const p=`field-${l.id}`;if(a.has(l.id)&&i.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&&s.has(l.name)&&i.push({id:`${p}-duplicate-name`,type:"error",message:`Field "${l.label||l.name}" has a duplicate name: "${l.name}"`,fieldId:l.id}),l.name&&s.add(l.name),(!l.label||l.label.trim()==="")&&i.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()==="")&&i.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)&&i.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)&&i.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)||i.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)&&i.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"))||i.push({id:"workflow-no-required-fields",type:"info",message:"Form linked to workflow but has no required fields"}));const c=e.fields.filter(l=>!l.parentId),u=new Map;return c.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&&i.push({id:`row-${f}-too-many-fields`,type:"warning",message:`Row ${f+1} has ${l.length} fields (maximum recommended is 3)`})}),i},[e]),n=S.useMemo(()=>t.filter(i=>i.type==="error"),[t]),r=S.useMemo(()=>t.filter(i=>i.type==="warning"),[t]),o=S.useMemo(()=>n.length===0,[n]);return{issues:t,errors:n,warnings:r,isValid:o}}function BF({field:e,value:t,allValues:n,validateOnChange:r=!1,validateOnBlur:o=!0,debounceMs:i=TT}){const[s,a]=S.useState(),[c,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=Xn(t,v,n);if(typeof x=="string"){w=x;break}}return a(w),u(!1),w},[e.validation,t,n]),m=S.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{p()},i)},[p,i]);S.useEffect(()=>(r&&f.current!==t&&m(),f.current=t,()=>{l.current&&clearTimeout(l.current)}),[t,r,m]);const g=S.useCallback(()=>{o&&p()},[o,p]),h=S.useCallback(()=>{a(void 0)},[]),y=S.useCallback(w=>{a(w)},[]);return{error:s,isValidating:c,validate:p,handleBlur:g,clearError:h,setCustomError:y}}const Cy="—";function Xt(){return{kind:"static",value:Cy}}function $F(){return su({currencySymbol:"₹",emptyDisplay:Cy,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 jF={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:$F()}},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"}}}},Ey={padding:"md",showBorder:!1};function Ny(e,t){const n="full";return e?{padding:e.padding??Ey.padding,maxWidth:e.maxWidth??n,showBorder:e.showBorder??Ey.showBorder}:{padding:"md",maxWidth:n,showBorder:!1}}function zF(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 VF(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 UF(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 HF(e){const t=Ny(e.container,e.layout);return z(UF(e.layout),VF(t.maxWidth,e.layout),zF(t.padding),t.showBorder&&"rounded-lg border border-border")}const ua=1;function WF(){return{version:ua,layout:"stack",container:{padding:"md",maxWidth:"full",showBorder:!1},dataBindings:[],widgets:[],filterGroups:[]}}function ky(e){return{...e,config:e.config??{},children:Array.isArray(e.children)?e.children.map(ky):void 0}}function RF(e){return{version:ua,layout:e.layout??"stack",container:Ny(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(ky):[],filterGroups:Array.isArray(e.filterGroups)?e.filterGroups:[],eventHandlers:e.eventHandlers??[],navigation:e.navigation}}function KF(e){const t=e;return!t||typeof t!="object"?WF():(t.version!==ua&&(t.version=ua),RF(t))}const _y={};let Ty=null;function GF(e){Ty=e}function qF(){return(_y?.VITE_API_BASE_URL?.trim()||_y?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const Ei=St.create({baseURL:qF()});Ei.interceptors.request.use(e=>{const t=Mr();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let n=Ty?.();if((!n||Object.keys(n).length===0)&&(n=Ms()),n){const r=e.headers??{};for(const[o,i]of Object.entries(n))i!==void 0&&i!==""&&(r[o]=i);e.headers=r}return e});async function Fy(e){const t=await Ei.get("/api/page-builder/pages/resolve",{params:e}),n=t.data?.data??t.data;if(!n?.pageId)throw new Error("Page resolve failed: no pageId returned");return n}async function Xc(e,t,n){const r=await Ei.get(`/api/page-builder/pages/${e}/render`,{params:{clientId:t,...n!==void 0?{version:n}:{}}}),o=r.data?.data??r.data;if(!o?.schema)throw new Error("Page render failed: no schema returned");return o}async function Jc(e){const{clientId:t,api:n,context:r,filterState:o}=e,i=await Ei.post(`/api/page-builder/clients/${t}/data-sources/execute`,{api:n,context:r,filterState:o});return i.data?.data??i.data}function YF(e,t){if(!t)return{};const n={};for(const[r,o]of Object.entries(t)){if(!o.trim())continue;const i=Qe(e,o);i!==void 0&&(n[r]=i)}return n}const Py=S.createContext(null);function XF(e,t){if(t.parentContext)return"idle";const n=e.prepopulateApi,r=String(t.clientIdProp??t.externalContext.clientId??"");return n?.enabled&&n.api?.path&&r?"loading":"idle"}function Oy(e,t){const n={};for(const r of e){let o;switch(r.source){case"route.param":o=r.param?t[r.param]:void 0;break;case"route.query":o=r.param?t[r.param]:void 0;break;case"context.user":o=r.param?t.user?.[r.param]:t.user;break;case"context.client":o=r.param?t.client?.[r.param]:t.client??t.clientId;break;case"context.tenant":o=r.param?t.tenant?.[r.param]:t.tenant??t.tenantId;break;case"static":o=r.value;break;case"widget.state":o=r.sample;break;default:o=void 0}o===void 0&&r.sample!==void 0&&(o=r.sample),o!==void 0&&(n[r.key]=o)}return n}function JF({schema:e,context:t={},clientId:n,nestingDepth:r=0,onAction:o,getWorkflowState:i,parentContext:s,children:a}){const[c,u]=S.useState(()=>s?s.filterGroups:{}),l=S.useRef(c);l.current=c;const[f,p]=S.useState({}),[m,g]=S.useState(()=>XF(e,{parentContext:s,clientIdProp:n,externalContext:t})),h=S.useRef(null),y=String(n??t.clientId??s?.clientId??""),w=JSON.stringify(t);S.useEffect(()=>{if(s)return;const k=e.prepopulateApi;if(!k?.enabled||!k.api?.path||!y){p({}),g("idle"),h.current=null;return}const A=JSON.stringify({path:k.api.path,method:k.api.method,queryParams:k.api.queryParams,headers:k.api.headers,bodyFields:k.api.bodyFields,auth:k.api.auth,mapping:k.contextMapping,bindings:e.dataBindings,context:w});if(h.current===A)return;let O=!1;return h.current=A,g("loading"),(async()=>{try{const E=Oy(e.dataBindings??[],t),L={...t,...E},G=await Jc({clientId:y,api:k.api,context:L});if(O)return;const I=YF(G,k.contextMapping);p({...I,prepopulateResponse:G}),g("ready")}catch{O||(p({}),g("error"))}})(),()=>{O=!0,h.current=null}},[s,e.prepopulateApi,e.dataBindings,w,y]);const v=S.useMemo(()=>{if(s)return{...s.context,...t};const k=Oy(e.dataBindings??[],t);return{...t,...k,...f}},[s,t,e.dataBindings,f]),x=String(n??v.clientId??s?.clientId??""),C=S.useCallback((k,A,O)=>{u(E=>({...E,[k]:{...E[k]??{},[A]:O}}))},[]),F=S.useCallback(k=>l.current[k]??{},[]),N=S.useCallback((k,A,O,E)=>{(o??s?.onAction)?.({...k,sourceWidgetId:A,event:O,payload:E})},[o,s?.onAction]),T=S.useMemo(()=>({schema:e,context:v,clientId:x,prepopulateStatus:s?.prepopulateStatus??m,nestingDepth:r,onAction:o??s?.onAction,getWorkflowState:i??s?.getWorkflowState,filterGroups:c,setFilterValue:C,getFilterGroup:F,dispatchAction:N}),[e,v,x,m,r,o,s?.onAction,i,s?.getWorkflowState,c,C,F,N]);return d.jsx(Py.Provider,{value:T,children:a})}function On(){const e=S.useContext(Py);if(!e)throw new Error("usePageContext must be used within PageContextProvider");return e}const QF=5,Iy=1;function Lo(e){return Number.isFinite(e)?Math.min(QF,Math.max(Iy,Math.round(e))):Iy}function ZF(e,t){const n=Lo(t),r=Array.from({length:n},()=>[]);return e.forEach((o,i)=>{const s=o.config,a=s.columnIndex!==void 0?Math.min(Math.max(0,s.columnIndex),n-1):i%n;r[a].push(o)}),r}function eP(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):0}function tP(e,t){const n=Math.max(1,t),r=Math.min(100,Math.max(0,Math.round(e))),o=Math.floor(r/n),i=r-o*n;return Array.from({length:n},(s,a)=>o+(a<i?1:0))}function My(e){return tP(100,Lo(e))}function nP(e){const t=e.trim(),n=/^(\d+(?:\.\d+)?)\s*%?$/.exec(t);return n?eP(Number(n[1])):null}function Ly(e,t){const n=Lo(t),r=[];for(let i=0;i<n;i++){const s=nP(e?.[i]??"");if(s===null)return My(n);r.push(s)}return r.reduce((i,s)=>i+s,0)!==100?My(n):r}function rP(e){return e==="sm"?"gap-2":e==="lg"?"gap-6":"gap-4"}function Dy(e,t){return Ly(t,Lo(e)).map(r=>`minmax(0, ${r}fr)`).join(" ")}function oP(e){return e.length?e.map(t=>`minmax(0, ${t}fr)`).join(" "):"minmax(0, 1fr)"}function iP(e,t,n,r){const o=Lo(t),i=ZF(e,o),s=Ly(n,o);if(!(r?.collapseEmpty!==!1))return{columns:i,gridTemplate:Dy(o,n),sourceIndices:i.map((p,m)=>m)};const c=i.map((p,m)=>({colChildren:p,index:m,percent:s[m]??0})).filter(p=>p.colChildren.length>0);if(c.length===0||c.length===i.length)return{columns:i,gridTemplate:Dy(o,n),sourceIndices:i.map((p,m)=>m)};const u=c.reduce((p,m)=>p+m.percent,0),l=c.map(p=>u>0?Math.round(p.percent/u*100):Math.round(100/c.length)),f=100-l.reduce((p,m)=>p+m,0);return f!==0&&l.length>0&&(l[0]+=f),{columns:c.map(p=>p.colChildren),gridTemplate:oP(l),sourceIndices:c.map(p=>p.index)}}function Qc(e,t="solid"){return e?t==="dashed"?"rounded-md border border-dashed border-border":"rounded-md border border-border":""}function sP(e){return z(Qc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-3")}function aP(e){return z(Qc(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-2")}function lP(e,t){return e.columnBorders?.[t]!==void 0?!!e.columnBorders[t]:!!e.showColumnBorders}function cP(e,t){const n=lP(e,t);return z(Qc(n,e.borderStyle??"dashed"),n&&"p-2")}function dP(e){if(e)return{minHeight:`${e}vh`}}function uP({widget:e,renderChildren:t}){const n=e.config,[r,o]=S.useState(n.defaultCollapsed??!1);return d.jsxs("section",{className:z("space-y-4",sP(n)),"data-widget-id":e.id,children:[n.heading&&d.jsx("div",{className:"flex items-center gap-2",children:n.collapsible?d.jsx("button",{type:"button",className:"text-left text-lg font-semibold hover:underline",onClick:()=>o(i=>!i),children:n.heading}):d.jsx("h2",{className:"text-lg font-semibold",children:n.heading})}),n.showDivider&&d.jsx("hr",{className:"border-border"}),!r&&e.children?.length?d.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function fP({widget:e,renderChildren:t}){const n=e.config,r=Lo(n.columns??2),o=n.collapseEmptyColumns!==!1,i=iP(e.children??[],r,n.columnWidths,{collapseEmpty:o});return d.jsx("div",{className:z("grid w-full min-w-0 items-stretch",rP(n.gap),aP(n)),style:{gridTemplateColumns:i.gridTemplate,...dP(n.minHeightPercent)},"data-widget-id":e.id,children:i.columns.map((s,a)=>{const c=i.sourceIndices[a]??a;return d.jsx("div",{className:z("flex min-h-[inherit] min-w-0 flex-col space-y-4 overflow-hidden",cP(n,c)),children:t?.(s)},c)})})}function pP({widget:e,renderChildren:t}){const n=e.config,r=n.variant==="outline"?"border bg-background":n.variant==="elevated"?"border bg-background shadow-md":"border bg-card";return d.jsxs("div",{className:z("rounded-lg p-4",r),"data-widget-id":e.id,children:[(n.title||n.subtitle)&&d.jsxs("div",{className:"mb-4",children:[n.title&&d.jsx("h3",{className:"font-semibold",children:n.title}),n.subtitle&&d.jsx("p",{className:"text-sm text-muted-foreground",children:n.subtitle})]}),e.children?.length?d.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function By(e,t){if(e.variable){const n=t[e.variable];return n!=null?String(n):e.fallback??e.text??""}return e.text??""}function mP({widget:e}){const t=e.config,{context:n}=On(),r=By(t,n),o=t.level??2,i=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left",s=o===1?"text-3xl":o===2?"text-2xl":o===3?"text-xl":"text-lg";return d.jsx("div",{role:"heading","aria-level":o,className:z("font-semibold tracking-tight",s,i),"data-widget-id":e.id,children:r})}function hP({widget:e}){const t=e.config,{context:n}=On(),r=By(t,n),o=t.preset==="caption"?"text-sm text-muted-foreground":t.preset==="small"?"text-xs text-muted-foreground":"text-base",i=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left";return d.jsx("p",{className:z(o,i),"data-widget-id":e.id,children:r})}function gP(e,t){return!e||typeof e!="string"?e:e.replace(/\{\{([^}]+)\}\}/g,(n,r)=>{const o=r.trim(),i=t[o];return i==null?"":String(i)})}function $y(e,t){const n={...e};for(const[r,o]of Object.entries(n))typeof o=="string"&&(n[r]=gP(o,t));return n}function yP(e,t){return e.replace(/\{\{([^}]+)\}\}/g,(n,r)=>{const o=t[r.trim()];return o!=null?String(o):""})}function jy(e,t,n,r){if(e.type==="navigate"){const o=yP(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){n({...e,params:e.params?$y(e.params,t):void 0},r,"click");return}if(e.type==="workflow"&&e.workflowId){n(e,r,"click");return}n(e,r,"click")}function bP({widget:e}){const t=e.config,{context:n,dispatchAction:r}=On();return d.jsx(Yt,{variant:t.variant??"default",size:t.size??"default","data-widget-id":e.id,onClick:()=>jy(t.action,n,r,e.id),children:t.label})}const vP={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between"},wP={sm:"gap-2",md:"gap-3",lg:"gap-4"};function SP({widget:e}){const t=e.config,{context:n,dispatchAction:r}=On(),o=t.buttons??[];return d.jsx("div",{className:z("flex flex-wrap items-center",vP[t.align??"start"],wP[t.gap??"sm"],t.wrap===!1&&"flex-nowrap"),"data-widget-id":e.id,children:o.map(i=>d.jsx(Yt,{variant:i.variant??"outline",size:i.size??"default","data-widget-id":e.id,"data-button-id":i.id,onClick:()=>jy(i.action,n,r,e.id),children:i.label},i.id))})}function xP(e){const t=e.prepopulateApi;return!!(t?.enabled&&t.api?.path)}function AP(e,t){return e&&(t==="idle"||t==="loading")}function CP(e,t){return!e||t==="ready"||t==="error"}function EP(e,t){const n=Qe(e,t??"");return n===void 0?null:n}function zy(e,t){if(e.mode==="pageApi"&&e.dataSourceRef)return t[e.dataSourceRef];if(e.mode==="api")return e.api}function Vy({widgetId:e,dataSource:t,enabled:n=!0,page:r,pageSize:o,search:i}){const{schema:s,context:a,clientId:c,getFilterGroup:u,prepopulateStatus:l}=On(),f=S.useMemo(()=>t.filterGroupKey?u(t.filterGroupKey):{},[t.filterGroupKey,u]),p=t.mode==="context"&&xP(s),m=AP(p,l),g=n&&(t.mode==="static"||(t.mode==="context"?CP(p,l):!!c)),h=S.useMemo(()=>["page-ds",e,t,a,f,r,o,i,l],[e,t,a,f,r,o,i,l]),y=wr.useQuery({queryKey:h,enabled:g,staleTime:zy(t,s.dataApis??{})?.staleTimeMs??3e4,queryFn:async()=>{if(t.mode==="static")return t.staticData;if(t.mode==="context")return EP(a,t.contextPath);const w=zy(t,s.dataApis??{});if(!w)throw new Error(`No API config for data source on widget ${e}`);const v={...a};if(t.requestBindings)for(const F of t.requestBindings){let N;F.source==="binding"?N=a[F.key]:F.source==="filter"&&(N=f[F.key]),N!==void 0&&(v[F.param]=N)}const C={...$y(v,a),...r!==void 0?{page:r,pageSize:o,search:i}:{}};return Jc({clientId:c,api:w,context:C,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 n=Number(e);return Number.isNaN(n)?String(e):n.toFixed(t.decimals??0)}case"currency":{const n=Number(e);return Number.isNaN(n)?String(e):new Intl.NumberFormat(void 0,{style:"currency",currency:t.currency??"USD"}).format(n)}case"percent":{const n=Number(e);return Number.isNaN(n)?String(e):`${n.toFixed(t.decimals??0)}%`}case"date":{const n=new Date(String(e));return Number.isNaN(n.getTime())?String(e):n.toLocaleDateString(void 0,{...t.format?{}:{}})}case"template":return t.template.replace(/\{\{value\}\}/g,String(e));default:return String(e)}}function Ni(e,t){const n=Qe(e,t.path);return n==null?t.fallback??n:t.formatter?Zc(n,t.formatter):n}function NP(e,t){if(!t)return{};const n={};for(const[r,o]of Object.entries(t))o in e&&(n[r]=e[o]);return n}const kP={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"},_P={rectangle:"rounded-lg",square:"aspect-square rounded-lg",circle:"aspect-square rounded-full"},TP={sm:"p-2 text-xs",md:"p-4 text-sm",lg:"p-6 text-base"},ed={sm:"text-lg",md:"text-2xl",lg:"text-3xl"},FP={sm:"gap-2",md:"gap-3",lg:"gap-4"};function PP({title:e,value:t,trend:n,variant:r="default",shape:o="rectangle",size:i="md",layout:s="vertical",isLoading:a,isError:c}){const u=s==="horizontal";return d.jsxs("div",{className:z(kP[r??"default"],_P[o??"rectangle"],TP[i??"md"],u&&"flex items-center justify-between gap-3"),children:[d.jsxs("div",{className:z(u&&"min-w-0"),children:[e&&d.jsx("p",{className:z("font-medium text-muted-foreground",u?"text-sm":""),children:e}),n!=null&&n!==""&&!u&&d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:String(n)})]}),a?d.jsx(Dr,{className:"my-2"}):c?d.jsx("p",{className:z("font-bold text-destructive",ed[i??"md"]),children:"Error"}):d.jsx("p",{className:z("font-bold",u?ed[i??"md"]:`mt-1 ${ed[i??"md"]}`),children:String(t)}),u&&n!==null&&n!==void 0&&n!==""&&d.jsx("p",{className:"text-xs text-muted-foreground",children:String(n)})]})}function Uy({stat:e,widgetId:t}){const{data:n,isLoading:r,isError:o}=Vy({widgetId:t,dataSource:e.dataSource}),s=(()=>{if(r)return"";if(n==null)return e.valueMapping.fallback??"—";if(e.dataSource.mode==="context"){const c=n;return e.valueMapping.formatter?Zc(c,e.valueMapping.formatter):c}if(e.dataSource.mode==="static"){const c=e.valueMapping.path?.trim()||"value",u=Ni(n,{...e.valueMapping,path:c});if(u!=null)return e.valueMapping.formatter?Zc(u,e.valueMapping.formatter):u;if(typeof n=="object"&&n!==null&&!Array.isArray(n)){const l=n;if(l.value!==void 0&&l.value!==null)return l.value}return e.valueMapping.fallback??"—"}return Ni(n,e.valueMapping)})(),a=e.trendMapping&&n!==void 0&&e.dataSource.mode!=="context"?Ni(n,e.trendMapping):e.trendMapping&&e.dataSource.mode==="context"&&e.trendMapping.path?Ni({value:n},e.trendMapping):null;return d.jsx(PP,{title:e.title,value:s,trend:a,variant:e.variant,shape:e.shape,size:e.size,layout:e.layout,isLoading:r,isError:o})}function OP({widget:e}){const t=e.config;return d.jsx("div",{"data-widget-id":e.id,children:d.jsx(Uy,{stat:t,widgetId:e.id})})}function IP({stat:e,widgetId:t}){return d.jsx(Uy,{stat:e,widgetId:`${t}-${e.id}`})}function MP({widget:e}){const t=e.config,n=t.stats??[],r=t.columns??1,o=t.direction==="horizontal";return d.jsx("div",{"data-widget-id":e.id,className:z(o?"flex flex-wrap":"grid",!o&&r===1&&"grid-cols-1",!o&&r===2&&"grid-cols-2",!o&&r===3&&"grid-cols-3",!o&&r===4&&"grid-cols-4",FP[t.gap??"md"]),children:n.map(i=>d.jsx(IP,{stat:i,widgetId:e.id},i.id))})}function LP({widget:e}){const t=e.config,{setFilterValue:n}=On(),[r,o]=S.useState("");return S.useEffect(()=>{const i=t.debounceMs??300,s=setTimeout(()=>{n(t.filterGroupKey,"search",r)},i);return()=>clearTimeout(s)},[r,t.debounceMs,t.filterGroupKey,n]),d.jsx("input",{type:"search",className:"flex h-9 w-full max-w-sm rounded-md border border-input bg-background px-3 py-1 text-sm shadow-xs",placeholder:t.placeholder??"Search…",value:r,onChange:i=>o(i.target.value),"data-widget-id":e.id})}function DP(e,t){if(!e)return[];const n=t?Qe(e,t):e;if(Array.isArray(n))return n;if(typeof n=="object"&&n!==null){const r=n;if(Array.isArray(r.items))return r.items;if(Array.isArray(r.data))return r.data}return[]}function BP({widget:e}){const t=e.config,{dispatchAction:n}=On(),[r,o]=S.useState(1),[i,s]=S.useState(""),a=t.pagination?.pageSize??10,{data:c,isLoading:u,isError:l}=Vy({widgetId:e.id,dataSource:t.dataSource,page:r,pageSize:a,search:t.search?.enabled?i:void 0}),f=t.dataSource.mode==="pageApi"?void 0:t.dataSource.api?.itemsPath,p=DP(c,f??"data.items"),m=(g,h)=>{const y=t.dataSource.responseMapping.find(w=>w.target===h);return y?Ni(g,y):Qe(g,h)??""};return d.jsxs("div",{className:"space-y-3","data-widget-id":e.id,children:[t.search?.enabled&&d.jsx("input",{type:"search",className:"flex h-9 w-full max-w-sm rounded-md border border-input bg-background px-3 py-1 text-sm",placeholder:t.search.placeholder??"Search…",value:i,onChange:g=>{s(g.target.value),o(1)}}),d.jsx("div",{className:"overflow-x-auto rounded-md border",children:d.jsxs("table",{className:"w-full text-sm",children:[d.jsx("thead",{children:d.jsx("tr",{className:"border-b bg-muted/50",children:t.columns.map(g=>d.jsx("th",{className:z("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))})}),d.jsx("tbody",{children:u?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center",children:d.jsx(Dr,{})})}):l?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-destructive",children:"Failed to load data"})}):p.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-muted-foreground",children:t.emptyMessage??"No data"})}):p.map((g,h)=>d.jsx("tr",{className:"cursor-pointer border-b hover:bg-muted/30",onClick:()=>{n({type:"emit",eventName:"row_click",payload:{row:g}},e.id,"row_click")},children:t.columns.map(y=>d.jsx("td",{className:z("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&&d.jsxs("div",{className:"flex items-center justify-between text-sm",children:[d.jsxs("span",{className:"text-muted-foreground",children:["Page ",r]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",className:"rounded border px-2 py-1 disabled:opacity-50",disabled:r<=1,onClick:()=>o(g=>Math.max(1,g-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"rounded border px-2 py-1",disabled:p.length<a,onClick:()=>o(g=>g+1),children:"Next"})]})]})]})}const $P=75;function jP(e){return e??$P}function zP(e){return e?"rounded-md border border-border p-3":""}function td({scrollBehavior:e="page",maxHeightPercent:t,children:n,className:r}){if(e!=="contained")return r?d.jsx("div",{className:r,children:n}):d.jsx(d.Fragment,{children:n});const o=jP(t);return d.jsx("div",{className:z("min-w-0 overflow-y-auto overflow-x-hidden",r),style:{maxHeight:`${o}vh`},"data-form-embed-scroll":"contained",children:n})}function VP(e,t,n){return["embedded-form",e,t,n??"latest"]}async function UP(e,t){try{const n=await fr.get(`/api/form-builder/form-layouts/form/${e}`,{params:{clientId:t}});let r=n.data?.data??n.data;for(;r&&typeof r=="object"&&!Array.isArray(r)&&r.data!=null&&typeof r.data=="object"&&!("rows"in r)&&!("columns"in r)&&!("formDefinitionId"in r);)r=r.data;return!r||typeof r!="object"||Array.isArray(r)||!("rows"in r)&&!("columns"in r)&&!("formDefinitionId"in r)?null:r}catch{return null}}async function HP(e,t,n){const r=n!==void 0?`/api/form-builder/forms/${e}/render?version=${n}`:`/api/form-builder/forms/${e}/render`,o=await fr.get(r,{params:{clientId:t}}),s=o.data?.data??o.data,a=s.form??s,c=s.fields??a.fields??[];let u=s.layout??a.layout??null;(!u||typeof u.columns!="number")&&(u=await UP(e,t));const l=s.rules??a.rules??[],f=wi(a,c,u,l),p=Mi({config:f.config,layout:f.layout},Ii(u))??Ii(u);return{schema:f,gridLayout:p}}const WP=300*1e3;function Hy({formId:e,mode:t="fill",contextFieldMapping:n,pageContext:r,clientId:o,formVersion:i,scrollBehavior:s,maxHeightPercent:a,showBorder:c}){const{data:u,isLoading:l,isError:f,error:p}=wr.useQuery({queryKey:VP(e,o,i),queryFn:()=>HP(e,o,i),staleTime:WP}),m=S.useMemo(()=>NP(r,n),[r,n]),g=zP(c);return l?d.jsx(td,{scrollBehavior:s,maxHeightPercent:a,className:g,children:d.jsx(Dr,{})}):f?d.jsx(td,{scrollBehavior:s,maxHeightPercent:a,className:g,children:d.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load form"})}):u?.schema?d.jsx(td,{scrollBehavior:s,maxHeightPercent:a,className:g,children:d.jsx(Gc,{schema:u.schema,mode:t,gridLayout:u.gridLayout,initialValues:m,submissionContext:r})}):null}function RP({widget:e}){const t=e.config,{context:n,clientId:r}=On();return t.formId?d.jsx(Hy,{formId:t.formId,mode:t.mode??"fill",contextFieldMapping:t.contextFieldMapping,pageContext:n,clientId:r,scrollBehavior:t.scrollBehavior,maxHeightPercent:t.maxHeightPercent,showBorder:t.showBorder}):d.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured"})}function KP({widget:e}){const t=e.config,{context:n,getWorkflowState:r,clientId:o}=On(),i=String(n.moduleId??"");if(!r)return d.jsxs("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground","data-widget-id":e.id,children:["Workflow embed requires ",d.jsx("code",{className:"text-xs",children:"getWorkflowState"})," on PageRenderer. Workflow ID: ",t.workflowId]});if(!i)return d.jsx("p",{className:"text-sm text-destructive","data-widget-id":e.id,children:"moduleId required in page context for workflow embed"});const s={};if(t.contextVariableMapping)for(const[a,c]of Object.entries(t.contextVariableMapping)){const u=n[c];u!=null&&(s[a]=String(u))}return d.jsx(Ay,{getWorkflowState:r,moduleId:i,tenantId:n.tenantId?String(n.tenantId):void 0,clientId:o||void 0,submissionContext:s})}function GP({widget:e}){const t=e.config,{schema:n,dispatchAction:r}=On(),o=t.previousPage??n.navigation?.previousPage,i=t.nextPage??n.navigation?.nextPage,s=t.showPrevious!==!1&&!!o,a=t.showNext!==!1&&!!i,c=t.showBreadcrumbs&&n.navigation?.breadcrumbs?.length,u=t.align==="center"?"justify-center":t.align==="right"?"justify-end":t.align==="space-between"?"justify-between":"justify-start",l=f=>{r({type:"navigate_page",pageId:f.pageId},e.id,"click")};return d.jsxs("nav",{className:"space-y-3","data-widget-id":e.id,children:[c&&d.jsx("ol",{className:"flex flex-wrap items-center gap-1 text-sm text-muted-foreground",children:n.navigation.breadcrumbs.map((f,p)=>d.jsxs("li",{className:"flex items-center gap-1",children:[p>0&&d.jsx("span",{children:"/"}),f.href?d.jsx("a",{href:f.href,className:"hover:underline",children:f.label}):d.jsx("span",{children:f.label})]},p))}),d.jsxs("div",{className:z("flex items-center gap-2",u),children:[s&&o&&d.jsx(Yt,{variant:"outline",size:"sm",onClick:()=>l(o),children:o.label??"Previous"}),a&&i&&d.jsx(Yt,{variant:"default",size:"sm",onClick:()=>l(i),children:i.label??"Next"})]})]})}function qP(e,t){return e?.length?e.filter(n=>n.config.tabId===t):[]}const YP=1;function XP(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 JP(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 QP(e,t,n){return e?new Set(n?[n]:[]):new Set(t.map(r=>r.id))}function ZP({tab:e,shouldRender:t,pageContext:n,clientId:r}){return t?e.formId?d.jsx(Hy,{formId:e.formId,mode:e.formMode??"fill",contextFieldMapping:e.contextFieldMapping,pageContext:n,clientId:r,scrollBehavior:e.scrollBehavior,maxHeightPercent:e.maxHeightPercent,showBorder:e.showBorder}):d.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured for this tab"}):null}function eO({tab:e,shouldLoad:t,shouldRender:n,nestingDepth:r,pageContext:o,clientId:i,onAction:s,getWorkflowState:a}){const c=On(),{data:u,isLoading:l,isError:f,error:p}=wr.useQuery({queryKey:["tab-page",e.pageId,e.pageVersion,i],enabled:t&&!!e.pageId,queryFn:async()=>Xc(e.pageId,i,e.pageVersion)});return n?r>=YP?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:"Nested page tabs not supported"}):e.pageId?l?d.jsx(Dr,{}):f?d.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load page"}):u?d.jsx(nd,{page:u,context:o,nestingDepth:r+1,inheritContext:!0,onAction:s,getWorkflowState:a,parentContext:c}):null:d.jsx("p",{className:"text-sm text-muted-foreground",children:"No page configured for this tab"}):null}function tO({tab:e,widgetChildren:t,renderChildren:n}){const r=qP(t,e.id);return r.length===0?d.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No widgets in this tab"}):d.jsx(d.Fragment,{children:n?.(r)})}function nO({widget:e,renderChildren:t}){const n=e.config,{context:r,clientId:o,nestingDepth:i,onAction:s,getWorkflowState:a}=On(),c=n.tabs??[],u=n.defaultTabId??c[0]?.id??"",l=n.lazyLoad!==!1,[f,p]=S.useState(u),[m,g]=S.useState(()=>QP(l,c,u)),h=w=>{g(v=>new Set(v).add(w)),p(w)},y=S.useMemo(()=>!l,[l]);return c.length===0?d.jsx("p",{className:"text-sm text-muted-foreground","data-widget-id":e.id,children:"No tabs configured"}):d.jsxs(vy,{value:f,onValueChange:h,className:"w-full","data-widget-id":e.id,children:[d.jsx(wy,{className:z("mb-4",XP(n.variant)),children:c.map(w=>d.jsx(Sy,{value:w.id,disabled:w.disabled,className:JP(n.variant),children:w.label},w.id))}),c.map(w=>{const v=m.has(w.id),x=y||v,C=y||v;return d.jsxs(xy,{value:w.id,forceMount:y||void 0,className:z("mt-0",y&&"data-[state=inactive]:hidden"),children:[w.contentType==="widgets"&&C&&d.jsx(tO,{tab:w,widgetChildren:e.children??[],renderChildren:t}),w.contentType==="form"&&d.jsx(ZP,{tab:w,shouldRender:x,pageContext:r,clientId:o}),w.contentType==="page"&&d.jsx(eO,{tab:w,shouldLoad:x,shouldRender:C,nestingDepth:i,pageContext:r,clientId:o,onAction:s,getWorkflowState:a})]},w.id)})]})}const rO={section:uP,columns:fP,card:pP,tab_group:nO,heading:mP,text:hP,button:bP,button_group:SP,stat_card:OP,stat_grid:MP,data_table:BP,search_filter:LP,form_embed:RP,workflow_embed:KP,page_nav:GP};function oO({widget:e}){return d.jsxs("div",{className:"rounded-md border border-dashed border-muted-foreground/40 bg-muted/20 p-3 text-sm text-muted-foreground","data-widget-id":e.id,"data-widget-type":e.type,children:["Unsupported widget: ",d.jsx("code",{className:"text-xs",children:e.type}),e.label&&d.jsxs("span",{className:"ml-1",children:["(",e.label,")"]})]})}function iO({widget:e,renderChildren:t}){const n=rO[e.type]??oO;return d.jsx(n,{widget:e,renderChildren:t})}function Wy(e,t){return e.map(n=>d.jsx(iO,{widget:n,renderChildren:t},n.id))}function nd({page:e,context:t={},onAction:n,chrome:r="none",className:o,nestingDepth:i=0,getWorkflowState:s,inheritContext:a=!1,parentContext:c}){const u=S.useMemo(()=>KF(e.schema),[e.schema]),l=p=>Wy(p,l),f=d.jsxs("div",{className:z("studio-page-content min-h-0 min-w-0",HF(u),o),"data-page-id":e.id,"data-nesting-depth":i,children:[r==="minimal"&&u.meta?.title&&d.jsxs("header",{className:"mb-6 border-b pb-4",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:u.meta.title}),u.meta.description&&d.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u.meta.description})]}),d.jsx("div",{className:"space-y-6",children:Wy(u.widgets,l)})]});return a&&c?f:d.jsx(JF,{schema:u,context:t,clientId:String(t.clientId??""),nestingDepth:i,onAction:n,getWorkflowState:s,parentContext:c,children:f})}function sO({clientId:e,tenantId:t,moduleId:n,featureId:r,pageId:o,routePath:i,routeParams:s={},isDefault:a,context:c={},version:u,chrome:l="none",onAction:f,getWorkflowState:p}){const m=S.useMemo(()=>({...s,...c,clientId:e,tenantId:t,moduleId:n,featureId:r}),[s,c,e,t,n,r]),{data:g,isLoading:h,isError:y,error:w}=wr.useQuery({queryKey:["page-resolve",e,t,n,r,o,i,a,u],queryFn:()=>Fy({clientId:e,tenantId:t,moduleId:n,featureId:r,routePath:i,isDefault:a,version:u}),enabled:!o}),v=o??g?.pageId,x=u??g?.version,{data:C,isLoading:F,isError:N,error:T}=wr.useQuery({queryKey:["page-render",v,e,x],queryFn:()=>Xc(v,e,x),enabled:!!v});return!o&&h?d.jsx("div",{className:"flex items-center justify-center p-12",children:d.jsx(Dr,{})}):y?d.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?F?d.jsx("div",{className:"flex items-center justify-center p-12",children:d.jsx(Dr,{})}):N||!C?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:T instanceof Error?T.message:"Failed to load page"}):d.jsx(nd,{page:C,context:m,chrome:l,nestingDepth:0,onAction:f,getWorkflowState:p}):d.jsx("div",{className:"rounded-md border p-4 text-sm text-muted-foreground",children:"No page found for the given scope or route."})}be.FIELD_TYPE_REGISTRY=jF,be.FORM_RENDERER_GRID_ROW_HEIGHT_DEFAULT=$r,be.FORM_RENDERER_ROOT_CLASS=_a,be.FieldRenderer=pr,be.FormRenderer=Gc,be.PageRenderer=nd,be.RendererFieldLayoutContext=ja,be.StudioPageHost=sO,be.WorkflowStepsView=Ay,be.appearanceControlClasses=Uo,be.appearanceHasExplicitVerticalIntent=Vd,be.appearanceTextareaClasses=Od,be.backendToFormSchema=wi,be.cellAlignmentClasses=ev,be.cellVerticalJustifyClassesForField=Zb,be.effectiveWidthPercent=$i,be.executeDataSource=Jc,be.fetchPageRender=Xc,be.fieldBlockBoxStyle=Qb,be.fieldBlockBoxStyleForField=jd,be.fieldBlockHorizontalPlacementClass=Ld,be.fieldBlockHorizontalSelfClass=Dd,be.fieldBlockHorizontalSelfClassForField=zd,be.fieldBlockWidthStyle=Ia,be.fieldBlockWidthStyleForField=$d,be.fieldGridShellFillsCellVertically=zi,be.formBuilderHttp=fr,be.formLayoutRecordToGridConfig=Ii,be.getBusinessApiOrigin=qp,be.getClientId=Mr,be.getRendererHostAuthHeaders=Ms,be.getRendererHostViewerContext=_C,be.getRendererStore=kv,be.gridCellFlexClasses=Md,be.gridCellFlexClassesForField=$a,be.gridCellOuterFlexClasses=Id,be.hasExplicitFieldBlockWidth=Bd,be.isAsyncSearchFieldProperties=LF,be.isIntrinsicWidthButtonField=oo,be.normalizeWorkflowFormSchema=RT,be.normalizeWorkflowFormToRendererSchema=ca,be.pageBuilderHttp=Ei,be.parseContentVerticalAlign=La,be.parseMetadataJson=Ai,be.resetRendererHostAuth=kC,be.resolveBusinessApiUrl=Vn,be.resolveFormGridLayout=Mi,be.resolvePage=Fy,be.resolvedGridCellVerticalJustifyClasses=Wo,be.resolvedHorizontalAlign=kn,be.resolvedVerticalAlign=Ho,be.resolvedVerticalAlignForField=Ba,be.setBusinessApiOrigin=xC,be.setFormBuilderAuthProvider=sE,be.setPageBuilderAuthProvider=GF,be.setRendererHostAuthHeaders=NC,be.setRendererHostViewerContext=EC,be.useFieldValidation=BF,be.useFormRenderer=eu,be.useFormValidation=DF,be.useRendererFieldLayout=Ro,be.useRendererHostAuthStore=Xr,Object.defineProperty(be,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},Pk="DialogDescriptionWarning",Ok=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ig(Pk).contentName}}.`;return b.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Ik=qh,Mk=Jh,Lk=Qh,Dk=Zh,Bk=tg,$k=og;function ag({...e}){return d.jsx(Ik,{"data-slot":"dialog",...e})}function jk({...e}){return d.jsx(Mk,{"data-slot":"dialog-portal",...e})}function zk({className:e,...t}){return d.jsx(Lk,{"data-slot":"dialog-overlay",className:H("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function lg({className:e,children:t,showCloseButton:r=!0,...n}){return d.jsxs(jk,{"data-slot":"dialog-portal",children:[d.jsx(zk,{}),d.jsxs(Dk,{"data-slot":"dialog-content",className:H("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...n,children:[t,r&&d.jsxs($k,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[d.jsx(ns,{}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function cg({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-header",className:H("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Uk({className:e,...t}){return d.jsx("div",{"data-slot":"dialog-footer",className:H("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function dg({className:e,...t}){return d.jsx(Bk,{"data-slot":"dialog-title",className:H("text-lg leading-none font-semibold",e),...t})}async function Vk(){const e={width:{ideal:1280},height:{ideal:720}},t=[{facingMode:{ideal:"environment"},...e},{facingMode:{ideal:"user"},...e},{...e},{}];let r;for(const n of t)try{return await navigator.mediaDevices.getUserMedia({video:Object.keys(n).length>0?n:!0,audio:!1})}catch(o){r=o}throw r instanceof Error?r:new Error("Could not access camera")}function ug(e){const t=()=>e.play();t().catch(()=>{requestAnimationFrame(()=>{t().catch(()=>{const r=()=>{t().catch(()=>{})};e.addEventListener("loadedmetadata",r,{once:!0}),e.addEventListener("canplay",r,{once:!0})})})})}const fg=({open:e,onOpenChange:t,onCaptured:r,validateFile:n,accept:o,disabled:s,onValidationMessage:i})=>{const a=v.useRef(null),c=v.useRef(null),u=v.useRef(null),f=v.useRef(null),[l,p]=v.useState(null),[g,m]=v.useState(!1),h=v.useCallback(()=>{a.current&&(a.current.srcObject=null)},[]),y=v.useCallback(()=>{u.current&&(u.current.getTracks().forEach(N=>N.stop()),u.current=null),h()},[h]);v.useEffect(()=>{if(!e){y(),p(null),m(!1);return}if(s)return;let N=!1;return p(null),m(!0),Vk().then(k=>{if(N){k.getTracks().forEach(T=>T.stop());return}u.current=k,m(!1)}).catch(k=>{if(N)return;m(!1);const T=k instanceof Error?k.message:"Could not access camera";p(T)}),()=>{N=!0,u.current&&(u.current.getTracks().forEach(k=>k.stop()),u.current=null),h()}},[e,s,y,h]);const S=v.useCallback(N=>{a.current=N,N&&u.current&&e&&!l&&!g&&(N.srcObject=u.current,ug(N))},[e,l,g]);v.useLayoutEffect(()=>{if(!e||l||g||!u.current)return;let N=!1,k=0;const T=()=>{if(N)return;const E=a.current;!E||!u.current||(E.srcObject=u.current,ug(E))};T();const P=requestAnimationFrame(()=>{T(),k=requestAnimationFrame(T)});return()=>{N=!0,cancelAnimationFrame(P),cancelAnimationFrame(k),h()}},[e,l,g,h]);const w=v.useCallback(()=>{y(),p(null),m(!1),t(!1),f.current&&(f.current.value="")},[y,t]),A=v.useCallback(()=>{const N=a.current,k=c.current;if(!N||!k||!u.current||N.readyState<2)return;const T=N.videoWidth,P=N.videoHeight;if(T===0||P===0)return;k.width=T,k.height=P;const E=k.getContext("2d");E&&(E.drawImage(N,0,0),k.toBlob(C=>{if(!C)return;const I=new File([C],`camera-capture-${Date.now()}.jpg`,{type:"image/jpeg",lastModified:Date.now()}),W=n(I);if(W){i?.(W);return}i?.(void 0),r(I),w()},"image/jpeg",.92))},[r,n,w,i]),x=v.useCallback(N=>{const k=N.target.files?.[0];if(!k)return;const T=n(k);if(T){i?.(T);return}i?.(void 0),r(k),w(),f.current&&(f.current.value="")},[r,n,w,i]),F=typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function";return d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:f,type:"file",accept:o,capture:"user",onChange:x,className:"hidden","aria-hidden":!0}),d.jsx("canvas",{ref:c,className:"hidden","aria-hidden":!0}),d.jsx(ag,{open:e,onOpenChange:N=>{N||w()},children:d.jsxs(lg,{className:"sm:max-w-md",showCloseButton:!0,onPointerDownOutside:N=>N.preventDefault(),children:[d.jsx(cg,{children:d.jsx(dg,{children:"Take a photo"})}),l?d.jsxs("div",{className:"space-y-3 py-2",children:[d.jsx("p",{className:"text-sm text-destructive",children:l}),F&&d.jsx("p",{className:"text-xs text-muted-foreground",children:"You can choose an image from your device instead."}),d.jsx(Zt,{type:"button",variant:"outline",className:"w-full",onClick:()=>f.current?.click(),children:"Choose from device"})]}):g?d.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:"Opening camera…"}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"relative rounded-lg overflow-hidden bg-black aspect-video",children:d.jsx("video",{ref:S,playsInline:!0,muted:!0,className:"w-full h-full object-cover"})}),d.jsxs(Uk,{className:"gap-2 sm:gap-0",children:[d.jsx(Zt,{type:"button",variant:"outline",onClick:w,children:"Cancel"}),d.jsx(Zt,{type:"button",onClick:A,children:"Capture photo"})]})]})]})})]})},Hk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a})=>{const c=e.properties,[u,f]=v.useState(),[l,p]=v.useState(!1),[g,m]=v.useState(()=>new Set),[h,y]=v.useState("none"),S=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,w=e.validation?.find(j=>j.type==="fileSize"),A=e.validation?.find(j=>j.type==="fileType"),x=w?.value!=null?w.value:c?.maxSize??S?.maxSize??5*1024*1024,F=A?.value!=null?A.value:c?.accept??S?.accept??["image/*"],N=F.join(",")||"image/*",k=qs(e),T=v.useCallback(j=>{if(w){const U=rn(j,w);if(U!==!0)return typeof U=="string"?U:"File size exceeds the maximum allowed size"}else if(j.size>x)return`File size must be less than ${Fo(x)}`;if(A){const U=rn(j,A);if(U!==!0)return typeof U=="string"?U:"File type is not allowed"}return null},[w,A,x]),P=v.useMemo(()=>Ys(t),[t]),E=wc(P),C=v.useCallback(j=>{const U=Ja(j,k);r(U),n?.()},[r,n,k]),I=v.useCallback(j=>{const U=T(j);if(U){f(U);return}f(void 0);const le=[...P];le.length>=k||(le.push(j),C(le),y("none"))},[P,k,T,C]),W=v.useCallback(j=>{const U=P.filter((le,oe)=>oe!==j);C(U)},[P,C]),M=v.useCallback(()=>{s||P.length>=k||(f(void 0),y("camera"),p(!0))},[s,P.length,k]),z=v.useCallback(j=>{p(j),j||y("none")},[]),V=o||u,X=e.appearance?.hideLabel??!1,L=[];(w||x)&&L.push(`Max size: ${Fo(x)}`),A&&F.length>0&&L.push(`Allowed: ${F.join(", ")}`),k>1&&L.push(`Up to ${k} photos`);const B=v.useCallback(j=>{window.open(j,"_blank","noopener,noreferrer")},[]),D=P.length===0,K=P.length<k,ae=yc(k,P.length);return d.jsxs(At,{field:e,error:V,isRequired:i,className:H(a,"!space-y-0"),hideLabel:X,children:[d.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:d.jsx("div",{role:"button",tabIndex:s||!K?-1:0,id:ft(e),onClick:j=>{s||j.target.closest("[data-remove-in-dropzone]")||j.target.closest("[data-no-open-picker]")||P.length>=k||M()},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),!s&&K&&M())},className:H("border-2 border-dashed rounded-lg p-1.5 text-center cursor-pointer transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",V&&"border-destructive",s&&"opacity-50 cursor-not-allowed",l&&h==="camera"&&"opacity-70 pointer-events-none",!K&&P.length>0&&"cursor-default"),"aria-describedby":Lt(e,!!V),"aria-invalid":Jt(!!V),"aria-required":i,children:D?d.jsxs(d.Fragment,{children:[d.jsx(ni,{className:"mx-auto h-5 w-5 text-muted-foreground flex-shrink-0"}),d.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight line-clamp-1",children:l?"Opening camera…":"Click to open camera"}),L.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-1",children:L.join(" • ")})]}):ae?d.jsx(Sc,{item:P[0],objectUrl:E[0]??null,failedUrlKeys:g,onImageUrlError:j=>m(U=>new Set(U).add(j)),onRemove:()=>W(0),onOpenUrl:B,disabled:s}):d.jsx(vc,{items:P,maxFiles:k,disabled:s,objectUrls:E,failedUrlKeys:g,onImageUrlError:j=>m(U=>new Set(U).add(j)),onRemove:W,onOpenUrl:B,addSlot:K?d.jsxs("button",{type:"button","data-no-open-picker":!0,onClick:j=>{j.stopPropagation(),M()},disabled:s,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center text-muted-foreground hover:border-primary hover:bg-primary/5 text-[10px] leading-tight px-0.5",children:[d.jsx(ni,{className:"h-4 w-4 mb-0.5","aria-hidden":!0}),"Add"]}):void 0})})}),d.jsx(fg,{open:l,onOpenChange:z,onCaptured:I,validateFile:T,accept:N,disabled:s,onValidationMessage:f})]})},Wk=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,buttonResponses:c})=>{const u=e.properties,f=v.useRef(null),[l,p]=v.useState(),[g,m]=v.useState(!1),[h,y]=v.useState(()=>new Set),[S,w]=v.useState("none"),A=e.metadata?typeof e.metadata=="string"?JSON.parse(e.metadata):e.metadata:null,x=e.validation?.find(ee=>ee.type==="fileSize"),F=e.validation?.find(ee=>ee.type==="fileType"),N=x?.value?x.value:u?.maxSize??A?.maxSize??5*1024*1024,k=F?.value?F.value:u?.accept??A?.accept??["image/*"],T=Array.isArray(k)?k.join(","):"image/*",P=qs(e),E=v.useCallback(ee=>{if(x){const ne=rn(ee,x);if(ne!==!0)return typeof ne=="string"?ne:"File size exceeds the maximum allowed size"}else if(ee.size>N)return`File size must be less than ${Fo(N)}`;if(F){const ne=rn(ee,F);if(ne!==!0)return typeof ne=="string"?ne:"File type is not allowed"}return null},[x,F,N]),C=v.useMemo(()=>Ys(t),[t]),I=wc(C),W=v.useCallback(ee=>{const ne=Ja(ee,P);r(ne),n?.()},[r,n,P]),M=v.useCallback(ee=>{p(void 0);const ne=Array.from(ee),he=[...C];let Ie=null;for(const Ue of ne){if(he.length>=P)break;const re=E(Ue);if(re){Ie||(Ie=re);continue}he.push(Ue)}if(Ie&&he.length===C.length){p(Ie);return}Ie&&p(Ie),W(he),w("none")},[C,P,E,W]),z=v.useCallback(ee=>{const ne=ee.target.files;ne&&ne.length>0&&M(ne),f.current&&(f.current.value="")},[M]),V=v.useCallback(ee=>{W(C.filter((ne,he)=>he!==ee))},[C,W]),X=v.useCallback(()=>{s||C.length>=P||g||(p(void 0),w("file"),f.current?.click())},[s,C.length,P,g]),L=v.useCallback(()=>{s||C.length>=P||(p(void 0),w("camera"),m(!0))},[s,C.length,P]),B=v.useCallback(ee=>{const ne=E(ee);if(ne){p(ne);return}p(void 0);const he=[...C];he.length>=P||(he.push(ee),W(he),w("none"))},[C,P,E,W]),D=v.useCallback(ee=>{m(ee),ee||w("none")},[]),K=o||l,ae=e.appearance?.hideLabel??!1,j=[];(x||N)&&j.push(`Max size: ${Fo(N)}`),F&&k.length>0&&j.push(`Allowed: ${k.join(", ")}`),P>1&&j.push(`Up to ${P} photos`);const U=v.useMemo(()=>{if(!c)return null;const ee=Object.values(c);for(let ne=ee.length-1;ne>=0;ne-=1){const he=ee[ne],Ie=typeof he?.status=="string"?he.status.toLowerCase():null;if(Ie&&Ie!=="success")continue;const Ue=he?.code;if(typeof Ue=="number"&&(Ue<200||Ue>=300))continue;const re=he?.data,ge=re?.file_url||re?.fileUrl||he?.file_url||he?.fileUrl;if(typeof ge=="string"&&ge.trim())return ge.trim()}return null},[c]),le=v.useCallback(ee=>{window.open(ee,"_blank","noopener,noreferrer")},[]),oe=C.length===0,G=C.length<P,ie=yc(P,C.length),Ce=G&&!g?d.jsxs("div",{"data-no-open-picker":!0,className:"h-[56px] w-[56px] min-w-[56px] flex-shrink-0 rounded border border-dashed border-muted-foreground/40 flex flex-col items-center justify-center gap-0.5 text-muted-foreground",children:[d.jsx("button",{type:"button",disabled:s,onClick:ee=>{ee.stopPropagation(),X()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-t","aria-label":"Upload file",title:"Upload",children:d.jsx(si,{className:"h-4 w-4","aria-hidden":!0})}),d.jsx("button",{type:"button",disabled:s,onClick:ee=>{ee.stopPropagation(),L()},className:"flex flex-1 w-full items-center justify-center hover:bg-primary/10 rounded-b border-t border-border/50","aria-label":"Open camera",title:"Camera",children:d.jsx(ni,{className:"h-4 w-4","aria-hidden":!0})})]}):void 0;return d.jsxs(At,{field:e,error:K,isRequired:i,className:H(a,"!space-y-0"),hideLabel:ae,children:[d.jsx("div",{className:"h-[70px] min-h-[70px] min-w-0 w-full flex flex-col",children:d.jsxs("div",{className:H("border-2 border-dashed rounded-lg p-1.5 transition-colors flex-1 min-h-0 flex flex-col items-center justify-center","hover:border-primary hover:bg-primary/5",K&&"border-destructive",s&&"opacity-50"),children:[d.jsx("input",{ref:f,id:ft(e),type:"file",accept:T,multiple:P>1,onChange:z,disabled:s||e.disabled||g||!G,className:"hidden","aria-describedby":Lt(e,!!K),"aria-invalid":Jt(!!K),"aria-required":i}),oe?d.jsxs("div",{className:"flex flex-col items-center justify-center gap-1 w-full pointer-events-auto",children:[d.jsxs("div",{className:"flex items-center justify-center gap-3",children:[d.jsxs("button",{type:"button",disabled:s||g,onClick:X,className:H("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none"),children:[d.jsx(si,{className:"h-5 w-5","aria-hidden":!0}),d.jsx("span",{children:"Upload"})]}),d.jsxs("button",{type:"button",disabled:s,onClick:L,className:H("inline-flex flex-col items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground",s&&"pointer-events-none",g&&"opacity-70"),children:[d.jsx(ni,{className:"h-5 w-5","aria-hidden":!0}),d.jsx("span",{children:"Camera"})]})]}),j.length>0&&d.jsx("p",{className:"text-[10px] text-muted-foreground line-clamp-2 text-center px-1",children:j.join(" • ")})]}):ie?d.jsx(Sc,{item:C[0],objectUrl:I[0]??null,failedUrlKeys:h,onImageUrlError:ee=>y(ne=>new Set(ne).add(ee)),onRemove:()=>V(0),onOpenUrl:le,openTarget:C[0]instanceof File?U:void 0,disabled:s||e.disabled}):d.jsx(vc,{items:C,maxFiles:P,disabled:s,objectUrls:I,failedUrlKeys:h,onImageUrlError:ee=>y(ne=>new Set(ne).add(ee)),onRemove:V,resolveOpenUrl:(ee,ne)=>ne instanceof File&&C.length===1&&U?U:null,onOpenUrl:ee=>{ee?.trim()&&le(ee.trim())},addSlot:Ce})]})}),d.jsx(fg,{open:g,onOpenChange:D,onCaptured:B,validateFile:E,accept:T,disabled:s,onValidationMessage:p})]})};function Rk(e){if(e==null||typeof e!="object")return;const t=e;if(typeof t.message=="string"&&t.message.trim())return t.message.trim();if(typeof t.display_message=="string"&&t.display_message.trim())return t.display_message.trim();if(t.data&&typeof t.data=="object"){const r=t.data;if(typeof r.message=="string"&&r.message.trim())return r.message.trim();if(typeof r.success_message=="string"&&r.success_message.trim())return r.success_message.trim();if(typeof r.display_message=="string"&&r.display_message.trim())return r.display_message.trim()}if(typeof t.success_message=="string"&&t.success_message.trim())return t.success_message.trim()}function pg(e,t){try{const r=Rk(e);ct.toast.success(r&&r.trim()?r:t)}catch{ct.toast.success(t)}}function ia(e,t,r){try{const n=r(e);ct.toast.error(n&&n.trim()?n:t)}catch{ct.toast.error(t)}}function Gk(e){const t=e.headers,r=["X-Message","X-Success-Message","X-Toast-Message","X-Success-Msg"];for(const n of r){const o=t.get(n);if(o&&typeof o=="string"&&o.trim())return o.trim()}}const aa="This field is required";function mg(e,t){if(!t?.length)return e;const r=t.find(n=>n.name===e);return r?.label&&r.label.trim()||e}function la(e,t){if(!e)return"Please complete the required fields.";if(Array.isArray(e)){const s=e.map(i=>{const a=i.message||aa;if(t?.length&&i.field){const c=mg(i.field,t);return a===aa?`${c} is required`:`${c}: ${a}`}return a}).filter(i=>typeof i=="string"&&i.length>0);return s.length===0?"Please complete the required fields.":s.length===1?s[0]:`${s[0]} (and ${s.length-1} more)`}const n=Object.entries(e).map(([o,s])=>{const i=s?.trim()||aa;if(t?.length){const a=mg(o,t);return i===aa?`${a} is required`:`${a}: ${i}`}return i}).filter(o=>typeof o=="string"&&o.length>0);return n.length===0?"Please complete the required fields.":n.length===1?n[0]:`${n[0]} (and ${n.length-1} more)`}function hg(e){if(e==null||typeof e!="object")return!1;const t=e;if(t.status==="error")return!0;const r=t.code;return typeof r=="number"&&(r<200||r>=300)}function Kk(e){return!hg(e)}function qk(e,t,r){if(!t||!Kk(e))return;const n=t.fieldMapping;if(n&&Object.keys(n).length>0)for(const[s,i]of Object.entries(n)){if(!s.trim()||!i?.trim())continue;const a=Ge(e,i.trim());a!=null&&r.setFieldValue(s.trim(),a)}const o=t.contextMapping;if(o&&Object.keys(o).length>0&&r.onContextUpdate){const s={};for(const[i,a]of Object.entries(o)){if(!i.trim()||!a?.trim())continue;const c=Ge(e,a.trim());c!=null&&(s[i.trim()]=c)}Object.keys(s).length>0&&r.onContextUpdate(s)}}function Yk(e=Kn){const{totalSteps:t,currentStep:r}=e.getState();return t>1&&r<t-1}async function Ec(e,t=Kn){const r=await t.getState().nextStep();if(!r)try{const n=t.getState(),o=n.errors;Object.keys(o).length>0?ct.toast.error(la(o,e)||"Please fix the errors before continuing."):n.totalSteps<=1||n.currentStep>=n.totalSteps-1?ct.toast.error("You are already on the last page."):ct.toast.error("Please fix the errors before continuing.")}catch{ct.toast.error("Please fix the errors before continuing.")}return r}function Xk(e=Kn){e.getState().prevStep()}const Jk=3;function Po(e){if(typeof e=="number"&&!Number.isNaN(e))return e}function Oo(e,t){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;return Po(r?.cellSlot)??Po(r?.stackSlot)??Po(r?.cellSlotIndex)??Po(r?.slotIndex)??Po(t?.cellSlotIndex)??Po(t?.stackSlot)}function ws(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:void 0;if(t?.sharedCellLayout==="row"||t?.sharedCellLayout==="stack")return t.sharedCellLayout;if(t?.stackDirection==="horizontal")return"row";if(t?.stackDirection==="vertical")return"stack"}function ca(e){const t=typeof e.position?.order=="number"?e.position.order:-1,r=typeof e.position?.column=="number"?e.position.column:1,n=e.position?.cellGroupId??"_";return`${t}:${r}:${n}`}function Nc(e){return[...e].sort((t,r)=>{const n=Oo(t.position),o=Oo(r.position);return typeof n=="number"&&typeof o=="number"&&n!==o?n-o:String(t.id).localeCompare(String(r.id))})}function Ss(e,t){if(e.length===0)return{rowSpan:1,columnSpan:1};let r=1,n=1;for(const o of e)r=Math.max(r,qo(o)),n=Math.max(n,Xd(o,t));return{rowSpan:r,columnSpan:n}}function gg(e){const t=Nc(e);for(const r of t){const n=ws(r.position);if(n)return n}return t.length>=2?"row":"stack"}function yg(e){return Nc(e).slice(0,Jk)}function Qk(e,t){const r=new Map;for(const n of e){if(!t(n)||typeof n.position?.order!="number")continue;const o=ca(n),s=r.get(o)??[];s.push(n),r.set(o,s)}return Array.from(r.values()).map(n=>yg(n))}function bg(e,t,r,n){const o=r.filter(a=>n(a)&&typeof a.position?.order=="number"&&a.position.order===e&&(a.position.column??1)===t+1);if(o.length===0)return[];const s=new Map;for(const a of o){const c=ca(a),u=s.get(c)??[];u.push(a),s.set(c,u)}const i=[...s.values()][0]??[];return yg(i)}function Zk(e,t,r,n){const o=r[0],s=o.position?.order,i=o.position?.column??1;if(typeof s!="number")return!1;const{rowSpan:a,columnSpan:c}=Ss(r,n),u=e===s&&t===i-1,f=e>=s&&e<s+a,l=t>=i-1&&t<i-1+c;return f&&l&&!u}function e_(e,t,r){const n=new Set(r??[]);for(const o of e){const s=o[0]?.position?.order??0,{rowSpan:i}=Ss(o,t);for(let a=s;a<s+i;a++)n.add(a)}return n}function t_(e){const t=[...e].sort((n,o)=>n-o),r=new Map;return t.forEach((n,o)=>r.set(n,o)),{originalToDisplay:r,displayRowCount:Math.max(t.length,1),sortedOriginalRows:t}}function r_(e,t,r){const n=r.get(e);if(n===void 0)return;let o=0;for(let s=e;s<e+t&&r.has(s);s++)o++;return`${n+1} / span ${Math.max(o,1)}`}function hr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Io(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>Io(r));if(!hr(e))return e;const t={};for(const[r,n]of Object.entries(e))t[r]=Io(n);return t}function vg(e,...t){const r={...e};for(const n of t)if(!(!n||!hr(n)))for(const[o,s]of Object.entries(n)){const i=r[o];hr(s)&&hr(i)?r[o]=vg(i,s):r[o]=s}return r}function oo(e){return hr(e)?e:{}}function xs(e){if(e==null)return{};if(typeof e=="string"){const t=e.trim();if(!t)return{};try{const r=JSON.parse(t);return hr(r)?Io(r):{}}catch{return{}}}return hr(e)?Io(e):{}}function wg(e){const t=e.apidata;return hr(t)&&Object.keys(t).length>0}function n_(e){if(typeof e.metadata=="string"&&e.metadata.trim()!==""||typeof e.metadata=="object"&&e.metadata!==null&&!Array.isArray(e.metadata)&&Object.keys(e.metadata).length>0||wg(e))return!0;const t=e.fieldKey,r=e.fieldType,n=e.name,o=e.type;return!!(t&&(!n||String(n).trim()==="")||r&&(!o||String(o).trim()==="")||t&&n&&t!==n||r&&o&&r!==o||!n&&e.key&&typeof e.key=="string")}const Sg=["hideLabel","contentAlign","contentVerticalAlign","labelPlacement","widthPercent","widthMode","className","verticalAlign","horizontalAlign","cellAlign","cellJustify","size","variant","minWidth","minHeight"];function o_(e,t){const r=e.appearance,n=hr(r)&&Object.keys(r).length>0?Io(r):{},o=oo(t.appearance),s={...n};for(const[i,a]of Object.entries(o))i!=="heightPercent"&&s[i]===void 0&&(s[i]=Io(a));for(const i of Sg)s[i]===void 0&&t[i]!==void 0&&(s[i]=t[i]);return delete s.heightPercent,Object.keys(s).length>0?s:void 0}function s_(e,t){const r=oo(e.position),n=xs(e.metadata),o=oo(e.layout),s=typeof r.order=="number"&&!Number.isNaN(r.order)?r.order:typeof e.positionOrder=="number"?e.positionOrder:typeof e.order=="number"?e.order:typeof e.positionRow=="number"?e.positionRow:t,i=typeof r.column=="number"&&!Number.isNaN(r.column)?r.column:typeof e.positionColumn=="number"?e.positionColumn:1,a=typeof r.columnSpan=="number"&&!Number.isNaN(r.columnSpan)?r.columnSpan:typeof e.positionWidth=="number"?e.positionWidth:1,c=typeof r.rowSpan=="number"&&!Number.isNaN(r.rowSpan)?r.rowSpan:typeof e.positionRowSpan=="number"?e.positionRowSpan:1,u={order:s,column:i,columnSpan:a,rowSpan:c},f=r.cellGroupId??o.cellGroupId,l=Oo(r,{cellSlotIndex:e.cellSlotIndex??o.cellSlotIndex,stackSlot:n.stackSlot??o.stackSlot}),p=ws(r)??ws(o)??(n.stackDirection==="horizontal"||o.stackDirection==="horizontal"?"row":n.stackDirection==="vertical"||o.stackDirection==="vertical"?"stack":void 0);return typeof f=="string"&&(u.cellGroupId=f),typeof l=="number"&&(u.cellSlot=l),(p==="row"||p==="stack")&&(u.sharedCellLayout=p),u}function i_(e,t){const r=e,n=xs(r.metadata),o=oo(r.apidata),s=oo(r.properties),i=vg({},n,o,s),a=(r.name!=null&&String(r.name).trim()!==""?r.name:void 0)??(typeof r.fieldKey=="string"?r.fieldKey:void 0)??(typeof r.key=="string"?r.key:void 0),c=(r.type!=null&&String(r.type).trim()!==""?r.type:void 0)??(typeof r.fieldType=="string"?r.fieldType:void 0),u=o_(r,n),f=s_(r,t),l={...r};return l.properties=i,a!==void 0&&(l.name=a),c!==void 0&&(l.type=c),u!==void 0?l.appearance=u:(!hr(r.appearance)||Object.keys(r.appearance).length===0)&&delete l.appearance,l.position=f,hr(l.appearance)&&delete l.appearance.heightPercent,l}function a_(e,t){if(!e||typeof e!="object")return!0;const r=e,n=xs(r.metadata),o=Object.keys(n).length===0&&!(typeof r.metadata=="string"&&r.metadata.trim()!==""),s=!wg(r);if(n_(r)||!o||!s)return!1;const i=r.position;return!(!(hr(i)&&typeof i.order=="number"&&!Number.isNaN(i.order))&&(typeof r.positionRow=="number"||typeof r.positionColumn=="number"||typeof r.positionWidth=="number"||typeof r.positionRowSpan=="number"||typeof r.positionOrder=="number")||hr(n.appearance)||Sg.some(u=>n[u]!==void 0&&(r.appearance==null||hr(r.appearance)&&r.appearance[u]===void 0))||l_(r))}function l_(e){const t=oo(e.position),r=oo(e.layout),n=xs(e.metadata);return(typeof e.cellSlotIndex=="number"||typeof t.stackSlot=="number"||typeof t.cellSlot=="number"||typeof t.cellSlotIndex=="number"||typeof n.stackSlot=="number"||typeof r.stackSlot=="number")&&typeof t.cellSlot!="number"||(t.stackDirection==="horizontal"||t.stackDirection==="vertical"||n.stackDirection==="horizontal"||n.stackDirection==="vertical"||r.stackDirection==="horizontal"||r.stackDirection==="vertical")&&t.sharedCellLayout!=="row"&&t.sharedCellLayout!=="stack"}function da(e){if(e==null||typeof e!="object")return e;const t=e.fields;if(!Array.isArray(t))return e;let r=!1;const n=t.map((o,s)=>{if(a_(o))return o;const i=i_(o,s);return i!==o&&(r=!0),i});return r?{...e,fields:n}:e}function c_(e){return da(e)}function d_(e){const t=e.steps;if(!Array.isArray(t)||t.length<2)return;const r=[];for(const n of t){if(!n||typeof n!="object")continue;const o=n,s=typeof o.id=="string"&&o.id.trim()?o.id.trim():void 0,i=typeof o.name=="string"&&o.name.trim()?o.name.trim():void 0,a=Array.isArray(o.fields)?o.fields.filter(c=>typeof c=="string"&&c.trim()!==""):[];!s||!i||r.push({id:s,name:i,...typeof o.description=="string"&&o.description.trim()?{description:o.description.trim()}:{},fields:a,validation:o.validation==="onSubmit"?"onSubmit":"onNext"})}return r.length>=2?r:void 0}function kc(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function xg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Ag(e,t){const r=e.form;if(!r)throw new Error("workflowStateToFormSchema requires workflowState.form to be set");const n=r.fields.filter(l=>l!=null&&l!==void 0).map((l,p)=>{if(!l||typeof l!="object")return null;const g={...l};if(l.fieldType&&!g.type&&(g.type=l.fieldType),l.fieldKey&&!g.key&&!g.name&&(g.key=l.fieldKey,g.name=l.fieldKey),typeof l.positionOrder=="number"&&!isNaN(l.positionOrder)?g.order=l.positionOrder:g.order=p,(typeof g.order!="number"||isNaN(g.order))&&(g.order=p),l.options&&typeof l.options=="string")try{g.options=JSON.parse(l.options)}catch{}if(l.metadata&&typeof l.metadata=="string")try{g.metadata=JSON.parse(l.metadata)}catch{}return g}).filter(l=>l!=null).sort((l,p)=>{const g=typeof l.order=="number"?l.order:0,m=typeof p.order=="number"?p.order:0;return g-m});n.forEach((l,p)=>{(!l||typeof l.order!="number"||isNaN(l.order))&&(l.order=p)});let o=r.layout;if(o){const l={...o};if(l.breakpoints&&typeof l.breakpoints=="string")try{l.breakpoints=JSON.parse(l.breakpoints)}catch{}if(l.responsiveConfig&&typeof l.responsiveConfig=="string")try{l.responsiveConfig=JSON.parse(l.responsiveConfig)}catch{}o=l}const s=n.filter(l=>l!=null&&typeof l=="object"&&typeof l.order=="number"&&!isNaN(l.order));let i={};const a=r.config;if(a!=null)if(typeof a=="string")try{i=JSON.parse(a)}catch{}else typeof a=="object"&&a!==null&&(i={...a});const c=l=>{let p={...l};if(l.conditionExpression&&typeof l.conditionExpression=="string")try{p={...l,conditionExpression:JSON.parse(l.conditionExpression)}}catch{}if(p.targetFieldId){const g=s.find(m=>m._id===p.targetFieldId||m.id===p.targetFieldId||m.fieldKey===p.targetFieldId);if(g){const m=g.key||g.fieldKey||g.name,h=g._id||g.id||p.targetFieldId;p.targetFieldKey=m,p.targetField=m,p.targetFieldById=h}}return p},u=d_(r),f={id:r._id,name:r.name,description:r.description??"",version:r.version,status:r.status,fields:s.map((l,p)=>{const g=l,m=typeof l.metadata=="object"&&l.metadata!==null?l.metadata:{},h=m.hidden===!0||l.hidden===!0,y={id:l._id||l.id||l.fieldKey,type:l.type||l.fieldType,label:l.label,key:l.key||l.fieldKey||l.name,name:l.name||l.fieldKey||l.key};if(h&&(y.hidden=!0),y.id||(y.id=y.key||y.name),y.key||(y.key=y.id||y.name),y.name||(y.name=y.key||y.id),l.isRequired!==void 0&&(y.required=l.isRequired),l.placeholder&&(y.placeholder=l.placeholder),l.options&&Array.isArray(l.options)&&(y.options=l.options),l.apidata&&(y.apidata=l.apidata),g.appearance&&typeof g.appearance=="object"&&!Array.isArray(g.appearance)&&Object.keys(g.appearance).length>0&&(y.appearance=kc(g.appearance)),g.ui!==void 0&&(y.ui=kc(g.ui)),g.visibility!==void 0&&(y.visibility=kc(g.visibility)),m.disabled!==void 0&&(y.disabled=m.disabled),m.readOnly!==void 0&&(y.readOnly=m.readOnly),m.hideLabel!==void 0&&(y.hideLabel=m.hideLabel,y.properties||(y.properties={}),y.properties.hideLabel=m.hideLabel,y.appearance||(y.appearance={}),y.appearance.hideLabel=m.hideLabel),(l.type==="file"||l.fieldType==="file"||l.type==="camera"||l.fieldType==="camera"||l.type==="photoChoice"||l.fieldType==="photoChoice")&&l.validationRules){const E=l.validationRules,C={...m};if(E.fileSize!==void 0&&(C.maxSize=E.fileSize),E.fileType&&Array.isArray(E.fileType)){const I=[];E.fileType.forEach(W=>{const M=W.startsWith(".")?W:`.${W}`;I.push(M),M===".csv"?I.push("text/csv"):M===".xls"?I.push("application/vnd.ms-excel"):M===".xlsx"&&I.push("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}),C.accept=I}y.metadata=C,C.maxSize!==void 0&&(y.maxSize=C.maxSize),C.accept!==void 0&&(y.accept=C.accept)}else if(m&&Object.keys(m).length>0){if(y.metadata=m,(l.type==="toggle"||l.fieldType==="toggle")&&(m.onValue!==void 0&&(y.onValue=m.onValue),m.offValue!==void 0&&(y.offValue=m.offValue),m.onText!==void 0&&(y.onText=m.onText),m.offText!==void 0&&(y.offText=m.offText)),(l.type==="button"||l.fieldType==="button")&&m.action==="download"&&m.downloadApiEndpoint&&typeof m.downloadApiEndpoint=="string"){let E=m.downloadApiEndpoint;E=E.replace(/\{ctx:([^}]+)\}/g,(C,I)=>{const W=t[I];return W!==void 0?String(W):C}),m.downloadApiEndpoint=E,y.metadata=m,y.downloadApiEndpoint=E}if((l.type==="button"||l.fieldType==="button")&&m.action==="submit"){const E=y.properties||{};m.submitAction!==void 0&&(E.submitAction=m.submitAction),m.submitApiMethod!==void 0&&(E.submitApiMethod=m.submitApiMethod),m.apiBodyStructure!==void 0&&(E.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(E.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(E.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiBodyFields!==void 0&&(E.apiBodyFields=m.apiBodyFields),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.action!==void 0&&(E.action=m.action),m.variant!==void 0&&(E.variant=m.variant),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint&&(E.apiEndpoint=l.apidata.apiEndpoint),y.properties=E}if((l.type==="button"||l.fieldType==="button")&&(m.action==="upload"||m.action==="custom")){const E=y.properties||{};m.action!==void 0&&(E.action=m.action),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.variant!==void 0&&(E.variant=m.variant),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),m.uploadAction!==void 0&&(E.uploadAction=m.uploadAction),m.uploadApiEndpoint!==void 0&&(E.uploadApiEndpoint=m.uploadApiEndpoint),m.uploadApiMethod!==void 0&&(E.uploadApiMethod=m.uploadApiMethod),m.apiBodyStructure!==void 0&&(E.apiBodyStructure=m.apiBodyStructure),m.apiBodyFieldsOnly!==void 0&&(E.apiBodyFieldsOnly=m.apiBodyFieldsOnly),m.apiBodyFieldsOnlyFormat!==void 0&&(E.apiBodyFieldsOnlyFormat=m.apiBodyFieldsOnlyFormat),m.apiFieldMapping!==void 0&&(E.apiFieldMapping=m.apiFieldMapping),m.apiQueryParams!==void 0&&(E.apiQueryParams=m.apiQueryParams),m.apiBodyFields!==void 0&&(E.apiBodyFields=m.apiBodyFields),m.apiHeaders!==void 0&&(E.apiHeaders=m.apiHeaders),y.properties=E}if(l.type==="status"||l.fieldType==="status"){const E=y.properties||{};if(m.source!==void 0&&(E.source=m.source),m.statuses!==void 0&&(E.statuses=m.statuses),m.dataPath!==void 0&&(E.dataPath=m.dataPath),m.showStatusText!==void 0&&(E.showStatusText=m.showStatusText),m.statusTextPath!==void 0&&(E.statusTextPath=m.statusTextPath),m.showCurrentIndicator!==void 0&&(E.showCurrentIndicator=m.showCurrentIndicator),l.apidata&&typeof l.apidata=="object"&&l.apidata.apiEndpoint){let C=l.apidata.apiEndpoint;C=C.replace(/\{ctx:([^}]+)\}/g,(I,W)=>{const M=t[W];return M!==void 0?String(M):I}),E.apiEndpoint=C,E.source===void 0&&(E.source="api")}l.apidata?.apiMethod!==void 0&&(E.apiMethod=l.apidata.apiMethod),y.properties=E}if(l.type==="addmore"||l.fieldType==="addmore"){const E=y.properties||{};m.linkedFieldNames!==void 0&&(E.linkedFieldNames=m.linkedFieldNames),m.linkedSectionIds!==void 0&&(E.linkedSectionIds=m.linkedSectionIds),m.linkedFieldAllowDuplicate!==void 0&&(E.linkedFieldAllowDuplicate=m.linkedFieldAllowDuplicate),m.buttonText!==void 0&&(E.buttonText=m.buttonText),m.variant!==void 0&&(E.variant=m.variant),m.size!==void 0&&(E.size=m.size),m.hideLabel!==void 0&&(E.hideLabel=m.hideLabel),y.properties=E}if(l.type==="selectablelist"||l.fieldType==="selectablelist"){const E=y.properties||{};m.submitFieldMapping!==void 0&&(E.submitFieldMapping=m.submitFieldMapping),m.displayFields!==void 0&&(E.displayFields=m.displayFields),m.displayFieldsSeparator!==void 0&&(E.displayFieldsSeparator=m.displayFieldsSeparator),m.dataSourceContextKey!==void 0&&(E.dataSourceContextKey=m.dataSourceContextKey),m.showSelectAll!==void 0&&(E.showSelectAll=m.showSelectAll),m.selectAllByDefault!==void 0&&(E.selectAllByDefault=m.selectAllByDefault),y.properties=E}}l.validationRules&&l.type!=="file"&&l.fieldType!=="file"&&l.type!=="camera"&&l.fieldType!=="camera"&&l.type!=="photoChoice"&&l.fieldType!=="photoChoice"&&l.type!=="status"&&l.fieldType!=="status"&&(y.validationRules=l.validationRules),typeof l.order=="number"&&(y.order=l.order);const S=l,w=xg(S.position),A=l.metadata&&typeof l.metadata=="object"&&!Array.isArray(l.metadata)?l.metadata:{},x=xg(S.layout),N={order:typeof S.positionOrder=="number"?S.positionOrder:l.order??p,column:typeof w.column=="number"?w.column:typeof S.positionColumn=="number"?S.positionColumn:1,columnSpan:typeof w.columnSpan=="number"?w.columnSpan:typeof w.width=="number"?w.width:typeof S.positionWidth=="number"?S.positionWidth:1,rowSpan:typeof w.rowSpan=="number"?w.rowSpan:typeof S.positionRowSpan=="number"?S.positionRowSpan:1},k=Oo(w,{cellSlotIndex:S.cellSlotIndex??x.cellSlotIndex,stackSlot:A.stackSlot??x.stackSlot});typeof k=="number"&&(N.cellSlot=k);const T=w.cellGroupId??x.cellGroupId;typeof T=="string"&&(N.cellGroupId=T);const P=ws(w)??ws(x)??(A.stackDirection==="horizontal"||x.stackDirection==="horizontal"?"row":A.stackDirection==="vertical"||x.stackDirection==="vertical"?"stack":void 0);return(P==="row"||P==="stack")&&(N.sharedCellLayout=P),y.position=N,l.conditions&&Array.isArray(l.conditions)&&(y.conditions=l.conditions),y}).filter(l=>l!=null).sort((l,p)=>{const g=typeof l.order=="number"?l.order:0,m=typeof p.order=="number"?p.order:0;return g-m}),config:{...i,layout:o,...r.rules&&r.rules.length>0&&{rules:r.rules.map(c)},...r.clientMapping&&Object.keys(r.clientMapping).length>0&&{clientMapping:r.clientMapping}},...r.rules&&r.rules.length>0&&{rules:r.rules.map(c)},createdAt:"",updatedAt:"",moduleId:"",...u?{steps:u}:{}};return da(f)}function vn({className:e,size:t="md",text:r="Loading...",fullScreen:n=!1}){const o={sm:"h-6 w-6",md:"h-12 w-12",lg:"h-16 w-16"},s=d.jsxs("div",{className:"text-center",children:[d.jsx("div",{className:H("animate-spin rounded-full border-b-2 border-blue-600 mx-auto mb-4",o[t],e)}),r&&d.jsx("p",{className:"text-gray-600",children:r})]});return n?d.jsx("div",{className:"min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50 flex items-center justify-center",children:s}):s}function u_(e,t){if(!e?.url)return;let r=e.url;if(r.startsWith("http://")||r.startsWith("https://"))try{const s=new URL(r);r=s.pathname+s.search}catch{}const n=t?.()??{},o={...e.headers||{},"Content-Type":"application/json",...n};return{...e,url:r,headers:o}}const Cg=({open:e,onOpenChange:t,title:r,mode:n,loading:o=!1,workflowState:s,formSchema:i,formDefinitionId:a,submissionContext:c={},onWorkflowSubmitResult:u,getAuthHeaders:f})=>{const l=v.useMemo(()=>{if(n==="form"&&i)return i;if(n==="workflow"&&s?.form){const g=Object.fromEntries(Object.entries(c).map(([y,S])=>[y,S==null?"":String(S)])),m=Ag(s,g),h=u_(s.BFF_submit_api,f);return h?{...m,status:"published",BFF_submit_api:h}:m}return null},[n,i,s,c,f]),p=s?.step_blocked_message;return d.jsx(ag,{open:e,onOpenChange:t,children:d.jsxs(lg,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[r?d.jsx(cg,{children:d.jsx(dg,{children:r})}):null,d.jsxs("div",{className:"relative min-h-[12rem]",children:[o&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:d.jsx(vn,{})}),p&&d.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:p}),l?d.jsx(il,{children:d.jsx(Ps,{schema:l,submissionContext:c,onWorkflowSubmitResult:u,onClose:()=>t(!1),workflowStepId:s?.current_step_id,omitRootWrapper:!0})}):a&&n==="form"?d.jsx(il,{children:d.jsx(Ps,{formId:a,submissionContext:c,onClose:()=>t(!1),omitRootWrapper:!0})}):!o&&d.jsx("p",{className:"text-sm text-muted-foreground",children:n==="workflow"?"No form available for this step.":"Form could not be loaded."})]})]})})},Eg=v.createContext(null);function Ng(){return v.useContext(Eg)}function _c(e,t){if(!e?.length||!t)return{};const r={};return e.forEach(n=>{t[n]!==void 0&&(r[n]=t[n])}),r}const kg=({handlers:e,moduleId:t,submissionContext:r={},getAuthHeaders:n,onParentWorkflowSubmitResult:o,children:s})=>{const[i,a]=v.useState(!1),[c,u]=v.useState(),[f,l]=v.useState("workflow"),[p,g]=v.useState(null),[m,h]=v.useState(null),[y,S]=v.useState(),[w,A]=v.useState({}),[x,F]=v.useState(!1),N=v.useMemo(()=>({...r,...w}),[r,w]),k=v.useCallback(()=>{a(!1),g(null),h(null),S(void 0),A({})},[]),T=v.useCallback(async(W,M)=>{if(!W.workflowId?.trim())throw new Error("workflowId is required for openWorkflowModal");const z=_c(W.passFields,M);F(!0),u(W.modalTitle),l("workflow"),A(z);try{const V=await e.getWorkflowStateById({workflowId:W.workflowId.trim(),moduleId:t,entryStepId:W.entryStepId?.trim()||void 0,passContext:z});g(V),h(null),S(void 0),a(!0)}finally{F(!1)}},[e,t]),P=v.useCallback(async(W,M)=>{if(!W.formDefinitionId?.trim())throw new Error("formDefinitionId is required for openFormModal");const z=_c(W.passFields,M);F(!0),u(W.modalTitle),l("form"),A(z),g(null);try{if(e.getFormSchemaById){const V=await e.getFormSchemaById(W.formDefinitionId.trim());h(V),S(void 0)}else h(null),S(W.formDefinitionId.trim());a(!0)}finally{F(!1)}},[e]),E=v.useCallback(async(W,M)=>{const z=M?.workflowId?.trim()||p?.workflow_id||"";if(!z||!W?.trim())throw new Error("workflowId and targetStepId are required for gotoStep");const V={...w,..._c(void 0,M?.formValues)};F(!0);try{const X=await e.navigateWorkflowStep({workflowId:z,moduleId:t,targetStepId:W.trim(),passContext:V});i?(g(X),l("workflow"),h(null),S(void 0)):o?.(X)}finally{F(!1)}},[e,t,w,i,p?.workflow_id,o]),C=v.useCallback(async W=>{o?.(W);const M=p?.workflow_id;if(M)try{const z=await e.getWorkflowStateById({workflowId:M,moduleId:t,passContext:w});g(z)}catch{}},[e,t,w,o,p?.workflow_id]),I=v.useMemo(()=>({isModalActive:i,openWorkflowModal:T,openFormModal:P,navigateToStep:E}),[i,T,P,E]);return d.jsxs(Eg.Provider,{value:I,children:[s,d.jsx(Cg,{open:i,onOpenChange:W=>{W||k()},title:c,mode:f,loading:x,workflowState:p,formSchema:m,formDefinitionId:y,submissionContext:N,onWorkflowSubmitResult:C,getAuthHeaders:n})]})};function Tc(e,t){if(!t?.length)return e;const r=new Map;for(const o of t){const s=o.name||o.key||o.id;s&&r.set(s,o)}const n={};for(const[o,s]of Object.entries(e)){const i=r.get(o);if(i?.type==="selectablelist"&&Array.isArray(s)&&s.length>0){const a=i.properties,c=i.metadata,u=typeof c=="object"&&c!==null?c:null,f=a?.submitFieldMapping??u?.submitFieldMapping;if(f&&typeof f=="object"&&Object.keys(f).length>0){const l=s.map(p=>{if(p==null||typeof p!="object")return p;const g={};for(const[m,h]of Object.entries(f))m!=null&&m!==""&&h!=null&&h!==""&&(g[m]=Ge(p,h));return g});n[o]=l;continue}}n[o]=s}return n}function ua(e){return!!(e instanceof File||Array.isArray(e)&&e.length>0&&e[0]instanceof File)}function f_(e){return Object.values(e).some(t=>ua(t))}function p_(e,t){const r=new FormData;let n=!1;return Object.entries(e).forEach(([o,s])=>{const i=t?.[o]||o;s instanceof File?(r.append(i,s),n=!0):Array.isArray(s)&&s.length>0&&s[0]instanceof File?(s.forEach(a=>{r.append(i,a)}),n=!0):s!=null&&(typeof s=="object"?r.append(i,JSON.stringify(s)):r.append(i,String(s)))}),n?r:null}function m_(e,t,r){const n={};let o=!1;return Object.entries(e).forEach(([s,i])=>{const a=t?.[s]||s;if(ua(i)){n[a]=i,o=!0;return}const c=r?.[s]||"string";let u=i;if(c==="number"){const f=Number(i);u=isNaN(f)?i:f}else c==="boolean"?u=i==="true"||i===!0||i==="1"||i===1:c==="date"?u=String(i):i!=null?u=typeof i=="object"?i:String(i):u="";n[a]=u}),{transformed:n,hasFiles:o}}const _g=Object.freeze(Object.defineProperty({__proto__:null,hasFileValues:f_,isFileValue:ua,prepareFormDataWithFiles:p_,transformFormValuesWithFiles:m_},Symbol.toStringTag,{value:"Module"}));function h_(e){if(!e||typeof e!="object")return;const t=e;return(t.mode==="nested_by_section"?"nested_by_section":"flat")==="flat"?{mode:"flat"}:{mode:"nested_by_section",includeUnassignedAtRoot:t.includeUnassignedAtRoot!==!1}}function g_(e){if(!Array.isArray(e))return;const t=[];for(const r of e){if(!r||typeof r!="object")continue;const n=r,o=typeof n.id=="string"&&n.id.trim()?n.id.trim():"",s=typeof n.name=="string"&&n.name.trim()?n.name.trim():"";if(!o||!s)continue;const i=Array.isArray(n.fieldNames)?[...new Set(n.fieldNames.filter(u=>typeof u=="string"&&u.trim().length>0).map(u=>u.trim()))]:[],a=typeof n.payloadKey=="string"&&n.payloadKey.trim()?n.payloadKey.trim():void 0;let c;if(n.fieldPayloadKeys&&typeof n.fieldPayloadKeys=="object"&&!Array.isArray(n.fieldPayloadKeys)){c={};for(const[u,f]of Object.entries(n.fieldPayloadKeys))typeof f=="string"&&f.trim()&&(c[u]=f.trim());Object.keys(c).length===0&&(c=void 0)}t.push({id:o,name:s,fieldNames:i,...n.showBorder===!0?{showBorder:!0}:{},...n.collapsible===!0?{collapsible:!0}:{},...n.defaultCollapsed===!0?{defaultCollapsed:!0}:{},...a?{payloadKey:a}:{},...c?{fieldPayloadKeys:c}:{},...n.heading&&typeof n.heading=="object"?{heading:n.heading}:{}})}return t.length>0?t:void 0}function Tg(e){return e?.mode==="nested_by_section"}function Fg(e){const t=e.payloadKey?.trim();return t||null}function Pg(e,t){return t.fieldPayloadKeys?.[e]?.trim()||e}function Og(e,t,r,n){if(!Tg(r)||!t?.length)return{...e};const o=new Set([]),s=r?.includeUnassignedAtRoot!==!1,i=new Set,a={};for(const c of t){const u=Fg(c);if(!u)continue;const f={};for(const l of c.fieldNames){if(o.has(l)||!(l in e))continue;i.add(l);const p=Pg(l,c);f[p]=e[l]}Object.keys(f).length>0&&(a[u]=f)}if(s)for(const[c,u]of Object.entries(e))o.has(c)||i.has(c)||(a[c]=u);return a}function y_(e,t,r){const n={...e??{}};if(!Tg(r)||!t?.length)return n;for(const o of t){const s=Fg(o);if(s)for(const i of o.fieldNames){if(n[i]?.trim())continue;const a=Pg(i,o);n[i]=`${s}.${a}`}}return n}function b_(e){return e==="null"?null:e==="true"?!0:e==="false"?!1:e}function v_(e){const t=e,r=typeof t?.status=="string"?t.status.toLowerCase():null;if(r&&r!=="success")return!1;const n=t?.code;return!(typeof n=="number"&&(n<200||n>=300))}function w_(e,t){if(!t)return[];const r=e.trim().split(".");if(r.length<2)return[];const n=r[0],o=r.slice(1).join("."),s=[];return Object.entries(t).forEach(([i,a])=>{const c=i===n,u=i.startsWith(`${n}__addmore__`);if(!c&&!u||!v_(a))return;const f=Ge(a,o);f==null||f===""||s.push(f)}),s}function fa(e,t,r,n,o,s){const i=e.trim().match(/^\{respAll:([^}]+)\}$/);if(i){const u=(i[1]||"").trim(),f=u.split("."),l=f.length>=2?f.slice(1).join("."):"";return(l==="data.id"||l==="data.documentId")&&n?.document_ids!=null&&Array.isArray(n.document_ids)?n.document_ids:w_(u,o)}const a=e.trim().match(/^\{(\w+)\}$/);if(a){const u=a[1],f=t[u];if(f!==void 0)return f;const l=Object.keys(t).find(p=>p.toLowerCase()===u.toLowerCase());if(l)return t[l]}const c=Lr(e,t,r,n,o,s);return b_(String(c))}const S_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,onClick:u,onSubmit:f,onReset:l,onCancel:p,isSubmitting:g=!1,formValues:m={},submissionContext:h,bffSubmitApi:y,onBffSubmitResult:S,extraSubmitPayload:w,buttonResponses:A,onButtonApiResponse:x,onValidateForm:F,getValidationErrors:N,allFields:k,onSubmittingChange:T,scopedFormValues:P,scopedFieldNameMap:E,prepopulateResponse:C=null,formSections:I,submitPayload:W})=>{const{gridStretch:M}=Jo(),z=Ng(),V=Zs(),[X,L]=v.useState(!1),B=e.properties,D=Ba.useParams(),K=v.useMemo(()=>({...h,...w}),[h,w]),ae=v.useMemo(()=>{if(!P||!E||Object.keys(E).length===0)return m;const Xe={};return Object.entries(P).forEach(([ve,ce])=>{const J=E[ve]||ve;J!==e.name&&(Xe[J]=ce)}),Xe},[P,E,m,e.name]),U=(()=>{try{const Xe=e.metadata;if(typeof Xe=="string")return JSON.parse(Xe);if(Xe&&typeof Xe=="object")return Xe}catch{}return null})(),le=B?.submitAction??U?.submitAction,oe=B?.apiEndpoint??e.apidata?.apiEndpoint??U?.apiEndpoint;let G=B?.action||U?.action;!G&&e.type==="button"&&(G="submit");const ie=B?.variant||"default",Ce=B?.size||"default",ee=B?.hideLabel??e.appearance?.hideLabel??!1,ne=B?.buttonText||e.label||"Button",he=B?.closeOnCancel??!0,Ie=async()=>{if(P&&E&&Object.keys(E).length>0||!F)return!0;const Xe=await F();if(!Xe&&N)try{const ve=N();ct.toast.error(la(ve,k??void 0)||"Please fix the errors before submitting.")}catch{ct.toast.error("Please fix the errors before submitting.")}return Xe},Ue=async Xe=>{Xe.preventDefault();const ve=G==="submit"?"submit":G;if(G==="next"){await Ec(k??void 0,V);return}if(G==="prev"){Xk(V);return}if(G==="saveAndNext"){if(!(B?.uploadApiEndpoint||U?.uploadApiEndpoint||e.uploadApiEndpoint)?.trim()){ct.toast.error("API endpoint is not configured for Save & Next.");return}if(!await Ie())return;L(!0);try{const J=await Se();x?.(e.name,J),hg(J)||pg(J,"Saved successfully."),await Ec(k??void 0,V)}catch(J){x?.(e.name,{status:"error",code:J?.response?.code??J?.response?.status??null,message:Gr(J)}),ia(J,"Failed to save. Please check the API endpoint and try again.",Gr)}finally{L(!1)}return}if(G==="openWorkflowModal"){const ce=B?.workflowId??U?.workflowId;if(!z){ct.toast.error("Workflow modal is not configured for this form.");return}if(!ce?.trim()){ct.toast.error("Workflow is not configured for this button.");return}L(!0);try{await z.openWorkflowModal({workflowId:ce.trim(),entryStepId:B?.entryStepId??U?.entryStepId,modalTitle:B?.modalTitle??U?.modalTitle??e.label,passFields:B?.passFields??U?.passFields},ae)}catch(J){ct.toast.error(Gr(J))}finally{L(!1)}return}if(G==="openFormModal"){const ce=B?.formDefinitionId??U?.formDefinitionId;if(!z){ct.toast.error("Form modal is not configured for this form.");return}if(!ce?.trim()){ct.toast.error("Form is not configured for this button.");return}L(!0);try{await z.openFormModal({formDefinitionId:ce.trim(),modalTitle:B?.modalTitle??U?.modalTitle??e.label,passFields:B?.passFields??U?.passFields},ae)}catch(J){ct.toast.error(Gr(J))}finally{L(!1)}return}if(G==="gotoStep"){const ce=B?.targetStepId??U?.targetStepId;if(!z){ct.toast.error("Step navigation is not configured for this form.");return}if(!ce?.trim()){ct.toast.error("Target step is not configured for this button.");return}const J=B?.workflowId??U?.workflowId??y?.payload?.workflow_id;L(!0);try{await z.navigateToStep(ce.trim(),{workflowId:typeof J=="string"?J:void 0,formValues:ae})}catch($){ct.toast.error(Gr($))}finally{L(!1)}return}if(ve==="submit"){if(Yk(V)){await Ec(k??void 0,V);return}if(y?.url){if(!await Ie())return;L(!0),T?.(!0);try{const ce=await ge(),J=(ce?.message??ce?.display_message??"Form submitted successfully!").trim();ct.toast.success(J||"Form submitted successfully!");const $=ce!=null&&typeof ce=="object"?ce:{status:"success",...ce!=null?{data:ce}:{}};x?.(e.name,$)}catch(ce){const J=Gr(ce);ct.toast.error(J)}finally{L(!1),T?.(!1)}return}if(f){if(!await Ie())return;L(!0),T?.(!0);try{await f(),x?.(e.name,{status:"success"})}finally{L(!1),T?.(!1)}return}ct.toast.error("Submit not configured. BFF submit API is required for submit buttons.");return}else if(G==="reset"&&l)l();else if(G==="cancel")he?p&&p():l&&l();else if(G==="download"){const ce=B?.downloadApiEndpoint||U?.downloadApiEndpoint||e.downloadApiEndpoint,J=B?.downloadApiMethod||U?.downloadApiMethod||e.downloadApiMethod;if(ce){L(!0);try{const $=J||"GET",fe=Mr(Lr(ce,ae,D,K,A,C??void 0)),it={method:$,headers:{}};$!=="GET"&&$!=="DELETE"&&(it.headers={"Content-Type":"application/json"});const Te=await fetch(fe,it);if(!Te.ok)throw new Error(`Download failed: ${Te.statusText}`);const Ye=await Te.blob(),Me=window.URL.createObjectURL(Ye),xe=document.createElement("a");xe.href=Me;const et=Te.headers.get("Content-Disposition");let We="download";if(et){const dt=et.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);dt&&dt[1]&&(We=dt[1].replace(/['"]/g,""))}xe.download=We,document.body.appendChild(xe),xe.click(),document.body.removeChild(xe),window.URL.revokeObjectURL(Me);try{const dt=Gk(Te);ct.toast.success(dt&&dt.trim()?dt:"Download started.")}catch{ct.toast.success("Download started.")}}catch($){ia($,"Failed to download file. Please check the API endpoint and try again.",Gr)}finally{L(!1)}}else ct.toast.error("Download endpoint is not configured")}else if(G==="upload"||G==="custom"){const ce=G==="custom",J=ce?"api":B?.uploadAction||U?.uploadAction||"database";if(J==="database")if(f){L(!0);try{await f(Xe)}catch($){throw $}finally{L(!1)}}else ct.toast.error("Form submit handler is not available");else if(J==="api"){const $=B?.uploadApiEndpoint||U?.uploadApiEndpoint||e.uploadApiEndpoint;if(B?.uploadApiMethod||U?.uploadApiMethod||e.uploadApiMethod,$){if(!await Ie())return;L(!0);try{const fe=await Se();x?.(e.name,fe),pg(fe,ce?"Custom API call completed successfully!":"Upload completed successfully!")}catch(fe){x?.(e.name,{status:"error",code:fe?.response?.code??fe?.response?.status??null,message:Gr(fe)}),ia(fe,ce?"Failed to call custom API. Please check the API endpoint and try again.":"Failed to upload. Please check the API endpoint and try again.",Gr)}finally{L(!1)}}else ct.toast.error(ce?"Custom API endpoint is not configured":"Upload endpoint is not configured")}else J==="custom"&&ct.toast.info("Custom upload handler is not implemented")}else u?u():r&&t!==void 0&&r(t||"");n?.()},re=async()=>{if(!le||le!=="api"||!oe)return null;const Xe=B?.apiBodyFields??U?.apiBodyFields;if((B?.apiBodyFieldsOnly??U?.apiBodyFieldsOnly??!1)&&Xe?.length){const xe={};return Xe.forEach(({key:et,value:We})=>{const dt=fa(We,ae,D,K,A,C??void 0),bt=et==="user_id"?"context_user_id":et;xe[bt]=dt}),xe.user_id!==void 0&&xe.user_id!==null&&(xe.context_user_id=xe.context_user_id??xe.user_id,delete xe.user_id),xe}const ce=k?.length?Tc(ae,k):ae,J=B?.apiFieldMapping??U?.apiFieldMapping,$=B?.apiFieldTypes??U?.apiFieldTypes,fe=B?.apiBodyStructure??U?.apiBodyStructure,it={...$};k?.length&&k.forEach(xe=>{const et=xe.name||xe.key;et&&(xe.type==="terms"||xe.type==="checkbox")&&(it[et]="boolean")});const{transformFormValuesWithFiles:Te}=await Promise.resolve().then(()=>_g),{transformed:Ye}=Te(ce,J,it);let Me={};if(fe==="flat"?Me={...Ye}:Me={data:{...Ye}},J){const xe={};Object.keys(Me).forEach(et=>{const We=J[et]||et;xe[We]=Me[et]}),Me=xe}return Xe?.length&&Xe.forEach(({key:xe,value:et})=>{const We=fa(et,ae,D,K,A,C??void 0),dt=xe==="user_id"?"context_user_id":xe;Me[dt]=We}),Me.user_id!==void 0&&Me.user_id!==null&&(Me.context_user_id=Me.context_user_id??Me.user_id,delete Me.user_id),Me.data?.user_id!==void 0&&Me.data?.user_id!==null&&(Me.data.context_user_id=Me.data.context_user_id??Me.data.user_id,delete Me.data.user_id),Me},ge=async()=>{if(!y||!y.url)throw new Error("BFF submit API configuration is missing");const Xe=k?.length?Tc(m,k):m,ve={};Object.keys(Xe).forEach($e=>{const gt=e.name===$e&&e.type==="button",vt=$e.toLowerCase().includes("button");!gt&&!vt&&(ve[$e]=Xe[$e])});const ce=Object.keys(ve).filter($e=>ua(ve[$e]));ce.forEach($e=>{ve[$e]=""});const J=Og(ve,I,W),$={workflow_id:y.payload?.workflow_id||"",current_step_id:y.payload?.current_step_id||"",form_data:J},fe=y.payload?.context_user_id??y.payload?.user_id;fe!=null&&String(fe).trim()!==""&&($.context_user_id=String(fe).trim());const it=["workflow_id","current_step_id","form_data","submit_body","submit_api_endpoint","submit_api_method"];if(h&&typeof h=="object"&&Object.entries(h).forEach(([$e,gt])=>{if(gt==null||it.includes($e))return;const vt=$e==="user_id"?"context_user_id":$e;$[vt]=$[vt]??gt}),w&&typeof w=="object"&&Object.entries(w).forEach(([$e,gt])=>{if(gt==null||it.includes($e))return;const vt=$e==="user_id"?"context_user_id":$e;$[vt]=$[vt]??gt}),le==="api"&&oe)try{const $e=await re();if($e){const gt=B?.apiBodyStructure??U?.apiBodyStructure,vt=B?.apiFieldMapping??U?.apiFieldMapping;ce.forEach(nr=>{const yr=vt?.[nr]??nr,Er=ve[nr]!==void 0&&typeof ve[nr]=="string"?ve[nr]:"";gt==="flat"?$e[yr]=Er:$e.data&&typeof $e.data=="object"?$e.data[yr]=Er:$e[yr]=Er}),$.submit_body=$e;let kt=Lr(oe,ae,D,K,A,C??void 0);kt=kt.replace(/\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}/gi,"$1"),kt=Mr(kt),$.submit_api_endpoint=kt,$.submit_api_method=B?.submitApiMethod||U?.submitApiMethod||"POST"}}catch{}const Te=(y.method||"POST").toUpperCase(),Ye=ce.length>0,Me=$.submit_api_endpoint??oe??"",xe=typeof Me=="string"?Me.toLowerCase():"",et=xe.includes("/upload")||xe.includes("/payments")||xe.includes("/bulk-upload"),We=Ye&&et;let dt;const bt={...y.headers||{}};if(We){const $e=new FormData;$e.append("payload",JSON.stringify($));for(const gt of ce){const vt=Xe[gt],kt=B?.apiFieldMapping?.[gt]??gt;vt instanceof File?$e.append(kt,vt):Array.isArray(vt)&&vt.length>0&&vt[0]instanceof File&&vt.forEach(nr=>$e.append(kt,nr))}dt=$e,delete bt["content-type"],delete bt["Content-Type"]}else bt["Content-Type"]="application/json",dt=JSON.stringify($);const ir=await fetch(y.url,{method:Te,headers:bt,body:dt});if(!ir.ok){let $e;const gt=await ir.text();try{$e=JSON.parse(gt)}catch{$e={message:gt}}const vt=new Error(`BFF submission failed: ${ir.status}`);throw vt.response=$e,vt}const xt=await ir.json();return S?.(xt),f&&await f(),xt},Se=async()=>{const Xe=B?.uploadApiEndpoint||U?.uploadApiEndpoint;if(!Xe)throw new Error("Upload API endpoint is not configured");if(!B)throw new Error("Button properties are not configured");const ve=(B.uploadApiMethod||"POST").toUpperCase(),ce=Mr(Lr(Xe,ae,D,K,A,C??void 0)),J=B.apiBodyFieldsOnly??U?.apiBodyFieldsOnly??!1,$=B.apiBodyFieldsOnlyFormat??U?.apiBodyFieldsOnlyFormat??"json";let fe={},it;const Te={};if(J&&B.apiBodyFields&&B.apiBodyFields.length>0)if(B.apiBodyFields.forEach(({key:xe,value:et})=>{fe[xe]=fa(et,ae,D,K,A,C??void 0)}),$==="multipart"){const xe=new FormData;Object.entries(fe).forEach(([et,We])=>{if(We instanceof File){xe.append(et,We);return}if(Array.isArray(We)&&We.length>0&&We[0]instanceof File){We.forEach(dt=>xe.append(et,dt));return}We!=null&&xe.append(et,typeof We=="object"?JSON.stringify(We):String(We))}),it=xe}else it=JSON.stringify(fe),Te["Content-Type"]="application/json";else{const xe=ae,{transformFormValuesWithFiles:et,prepareFormDataWithFiles:We,hasFileValues:dt}=await Promise.resolve().then(()=>_g),{transformed:bt,hasFiles:ir}=et(xe,B.apiFieldMapping,B.apiFieldTypes);if((B.apiBodyStructure??U?.apiBodyStructure??"nested")==="flat"?fe={...bt}:fe={data:{...bt}},B.apiFieldMapping){const $e={};Object.keys(fe).forEach(gt=>{const vt=B.apiFieldMapping[gt]||gt;$e[vt]=fe[gt]}),fe=$e}if(B.apiBodyFields&&B.apiBodyFields.forEach(({key:$e,value:gt})=>{fe[$e]=fa(gt,ae,D,K,A,C??void 0)}),ir||dt(fe)){const $e=We(fe,B.apiFieldMapping);$e?it=$e:(it=JSON.stringify(fe),Te["Content-Type"]="application/json")}else it=JSON.stringify(fe),Te["Content-Type"]="application/json"}B.apiHeaders&&B.apiHeaders.forEach(({key:xe,value:et})=>{const We=Lr(et,ae,D,K,A,C??void 0);(xe.toLowerCase()!=="content-type"||!(it instanceof FormData))&&(Te[xe]=We)});let Ye=ce;if(B.apiQueryParams&&B.apiQueryParams.length>0){const xe=new URLSearchParams;B.apiQueryParams.forEach(({key:et,value:We})=>{const dt=Lr(We,ae,D,K,A,C??void 0);xe.append(et,dt)}),Ye=`${ce}?${xe.toString()}`}const Me=await fetch(Ye,{method:ve,headers:Te,body:ve!=="GET"?it:void 0});if(!Me.ok){let xe;const et=await Me.text();try{xe=JSON.parse(et)}catch{xe={message:et}}const We=new Error(`Upload failed: ${Me.status}`);throw We.response=xe,We}try{return await Me.json()}catch{return{}}},pt=G==="submit"?"submit":G,Bt=pt==="submit"?"button":pt==="submit"?"submit":pt==="reset"?"reset":"button",Pt=s||e.disabled||i||e.readOnly||X||pt==="submit"&&g,Ar=ne,Nt=fo(e),Cr=Fr(e.appearance)==="stretch";return d.jsx(At,{field:e,error:o,isRequired:a,className:c,hideLabel:ee,children:d.jsx("div",{className:H(M&&!Nt&&"flex w-full min-w-0 flex-col",M&&Nt&&"min-w-0 shrink-0"),children:d.jsxs(Zt,{id:ft(e),type:Bt,variant:ie,size:Ce,disabled:Pt,onClick:Ue,className:H(e.appearance?.className,M&&!Nt&&"w-full min-w-0 shrink-0",M&&Nt&&!Cr&&"inline-flex w-auto max-w-full shrink-0",M&&Nt&&Cr&&"inline-flex w-full min-w-0 max-w-full shrink-0"),children:[X&&d.jsx("span",{className:"inline-block h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent mr-2","aria-hidden":!0}),Ar]})})})},x_=({field:e,disabled:t,readOnly:r,isRequired:n,className:o,buttonResponses:s,onButtonApiResponse:i})=>{const a=e.properties,c=a?.buttonText??e.label??"Edit",u=a?.variant??"outline",f=a?.size??"default",l=a?.hideLabel??e.appearance?.hideLabel??!1,p=e.name||e.key||e.id,g=Qo(s?.[p]),m=t||e.disabled||r||e.readOnly||g,h=y=>{y.preventDefault(),!m&&i?.(p,{status:"success"})};return d.jsx(At,{field:e,error:void 0,isRequired:n,className:o,hideLabel:l,children:d.jsx(Zt,{id:ft(e),type:"button",variant:u,size:f,disabled:m,onClick:h,className:H(e.appearance?.className,(!fo(e)||Fr(e.appearance)==="stretch")&&"w-full min-w-0"),children:c})})},A_=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,onAddMore:i})=>{const a=e.properties||{},c=a.variant||"outline",u=a.size||"default",f=a.buttonText||e.label||"Add More",l=a.hideLabel??e.appearance?.hideLabel??!1,p=r||n||e.disabled||e.readOnly;return d.jsx(At,{field:e,error:t,isRequired:o,className:s,hideLabel:l,children:d.jsxs(Zt,{id:ft(e),type:"button",variant:c,size:u,disabled:!!p,onClick:i,className:H("w-fit",e.appearance?.className),children:[d.jsx(Ru,{className:"h-4 w-4 mr-1"}),f]})})},Ig=v.createContext(null);function C_({value:e,children:t}){return d.jsx(Ig.Provider,{value:e,children:t})}function E_(){return v.useContext(Ig)}function Mg(e){const t=e.indexOf("__addmore__");return t>=0?e.slice(0,t):e}function As(e){return e.name||e.key||e.id}function Fc(e){return e.filter(t=>!t.parentId&&t.type==="sectionHeading"&&As(t))}function N_(e){if(e.type!=="sectionHeading")return[];const t=e.properties||{};return Array.isArray(t.linkedFieldNames)?t.linkedFieldNames.filter(r=>typeof r=="string"&&r.trim().length>0):[]}function k_(e){const t=new Map;for(const r of Fc(e)){const n=As(r);for(const o of N_(r))t.set(o,n)}return t}function __(e,t){const r=t.properties||{},n=Array.isArray(r.sectionHeadingNames)?r.sectionHeadingNames.filter(i=>typeof i=="string"&&i.trim()):[],o=Fc(e);if(n.length===0)return o;const s=new Set(n);return o.filter(i=>s.has(As(i)))}function T_(e){const t={};for(const r of Fc(e))t[As(r)]=!0;for(const r of e){if(r.type!=="customizeSections")continue;const n=r.properties||{};for(const o of n.defaultHiddenSectionNames??[])typeof o=="string"&&o.trim()&&(t[o.trim()]=!1)}return t}function Lg(e,t,r,n){if(!e||t==="customizeSections")return!0;const o=Mg(e),s=t==="sectionHeading"?o:n.get(o);return s?r[s]!==!1:!0}const F_=({field:e,error:t,disabled:r,readOnly:n,isRequired:o,className:s,designMode:i=!1})=>{const a=E_(),c=e.properties||{},u=c.variant||"outline",f=c.size||"default",l=c.buttonText||e.label||"Customise sections",p=c.menuTitle||"VISIBLE SECTIONS",g=c.hideLabel??e.appearance?.hideLabel??!1,m=r||n||e.disabled||e.readOnly,h=v.useMemo(()=>a?.allFields?.length?__(a.allFields,e):[],[a?.allFields,e]);return d.jsx(At,{field:e,error:t,isRequired:o,className:s,hideLabel:g,children:d.jsxs(sc,{children:[d.jsx(Wm,{asChild:!0,children:d.jsxs(Zt,{id:ft(e),type:"button",variant:u,size:f,disabled:!!m,className:H("w-fit gap-2",e.appearance?.className),children:[d.jsx(nS,{className:"h-4 w-4"}),l]})}),d.jsxs(ic,{align:"end",className:"w-64 p-0",children:[d.jsx("div",{className:"px-3 py-2 border-b",children:d.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:p})}),d.jsx("div",{className:"max-h-64 overflow-auto p-2 space-y-1",children:h.length===0?d.jsx("p",{className:"text-xs text-muted-foreground px-1 py-2",children:"No section headings on this form."}):h.map(y=>{const S=As(y),w=y.label||S,A=i||!a?!0:a.visibility[S]!==!1;return d.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md px-1 py-1.5 hover:bg-muted/50",children:[d.jsx(Fn,{htmlFor:`ui-section-${e.id}-${S}`,className:"text-xs font-normal truncate",children:w}),d.jsx(Ch,{id:`ui-section-${e.id}-${S}`,checked:A,disabled:i||!a||!!m,onCheckedChange:x=>{!a||i||a.setSectionVisible(S,!!x)}})]},y.id)})})]})]})})},P_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=u?.max||5,l=u?.icon||"star",p=h=>{s||i||e.disabled||e.readOnly||(r(h),n?.())},g=h=>{},m=h=>{const y=t>=h+1,S=H("transition-colors cursor-pointer",y?"fill-yellow-400 text-yellow-400":"text-muted-foreground",(s||i||e.disabled||e.readOnly)&&"cursor-not-allowed opacity-50",!(s||i||e.disabled||e.readOnly)&&"hover:text-yellow-400");return l==="star"?d.jsx(Gu,{className:H(S,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>g()},h):d.jsx(Gu,{className:H(S,"h-6 w-6"),onClick:()=>p(h+1),onMouseEnter:()=>g()},h)};return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:"flex items-center gap-1",role:"radiogroup","aria-label":e.label,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[Array.from({length:f},(h,y)=>m(y)),u?.showValue!==!1&&d.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:t>0?t:""})]})})};var Dg=["PageUp","PageDown"],Bg=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],$g={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Mo="Slider",[Pc,O_,I_]=Cl(Mo),[jg]=vr(Mo,[I_]),[M_,pa]=jg(Mo),zg=b.forwardRef((e,t)=>{const{name:r,min:n=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[n],value:f,onValueChange:l=()=>{},onValueCommit:p=()=>{},inverted:g=!1,form:m,...h}=e,y=b.useRef(new Set),S=b.useRef(0),A=i==="horizontal"?L_:D_,[x=[],F]=ln({prop:f,defaultProp:u,onChange:C=>{[...y.current][S.current]?.focus(),l(C)}}),N=b.useRef(x);function k(C){const I=U_(x,C);E(C,I)}function T(C){E(C,S.current)}function P(){const C=N.current[S.current];x[S.current]!==C&&p(x)}function E(C,I,{commit:W}={commit:!1}){const M=R_(s),z=G_(Math.round((C-n)/s)*s+n,M),V=us(z,[n,o]);F((X=[])=>{const L=j_(X,V,I);if(W_(L,c*s)){S.current=L.indexOf(V);const B=String(L)!==String(X);return B&&W&&p(L),B?L:X}else return X})}return d.jsx(M_,{scope:e.__scopeSlider,name:r,disabled:a,min:n,max:o,valueIndexToChangeRef:S,thumbs:y.current,values:x,orientation:i,form:m,children:d.jsx(Pc.Provider,{scope:e.__scopeSlider,children:d.jsx(Pc.Slot,{scope:e.__scopeSlider,children:d.jsx(A,{"aria-disabled":a,"data-disabled":a?"":void 0,...h,ref:t,onPointerDown:De(h.onPointerDown,()=>{a||(N.current=x)}),min:n,max:o,inverted:g,onSlideStart:a?void 0:k,onSlideMove:a?void 0:T,onSlideEnd:a?void 0:P,onHomeKeyDown:()=>!a&&E(n,0,{commit:!0}),onEndKeyDown:()=>!a&&E(o,x.length-1,{commit:!0}),onStepKeyDown:({event:C,direction:I})=>{if(!a){const z=Dg.includes(C.key)||C.shiftKey&&Bg.includes(C.key)?10:1,V=S.current,X=x[V],L=s*z*I;E(X+L,V,{commit:!0})}}})})})})});zg.displayName=Mo;var[Ug,Vg]=jg(Mo,{startEdge:"left",endEdge:"right",size:"width",direction:1}),L_=b.forwardRef((e,t)=>{const{min:r,max:n,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...f}=e,[l,p]=b.useState(null),g=Qe(t,A=>p(A)),m=b.useRef(void 0),h=bo(o),y=h==="ltr",S=y&&!s||!y&&s;function w(A){const x=m.current||l.getBoundingClientRect(),F=[0,x.width],k=Mc(F,S?[r,n]:[n,r]);return m.current=x,k(A-x.left)}return d.jsx(Ug,{scope:e.__scopeSlider,startEdge:S?"left":"right",endEdge:S?"right":"left",direction:S?1:-1,size:"width",children:d.jsx(Hg,{dir:h,"data-orientation":"horizontal",...f,ref:g,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:A=>{const x=w(A.clientX);i?.(x)},onSlideMove:A=>{const x=w(A.clientX);a?.(x)},onSlideEnd:()=>{m.current=void 0,c?.()},onStepKeyDown:A=>{const F=$g[S?"from-left":"from-right"].includes(A.key);u?.({event:A,direction:F?-1:1})}})})}),D_=b.forwardRef((e,t)=>{const{min:r,max:n,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,f=b.useRef(null),l=Qe(t,f),p=b.useRef(void 0),g=!o;function m(h){const y=p.current||f.current.getBoundingClientRect(),S=[0,y.height],A=Mc(S,g?[n,r]:[r,n]);return p.current=y,A(h-y.top)}return d.jsx(Ug,{scope:e.__scopeSlider,startEdge:g?"bottom":"top",endEdge:g?"top":"bottom",size:"height",direction:g?1:-1,children:d.jsx(Hg,{"data-orientation":"vertical",...u,ref:l,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:h=>{const y=m(h.clientY);s?.(y)},onSlideMove:h=>{const y=m(h.clientY);i?.(y)},onSlideEnd:()=>{p.current=void 0,a?.()},onStepKeyDown:h=>{const S=$g[g?"from-bottom":"from-top"].includes(h.key);c?.({event:h,direction:S?-1:1})}})})}),Hg=b.forwardRef((e,t)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,f=pa(Mo,r);return d.jsx(je.span,{...u,ref:t,onKeyDown:De(e.onKeyDown,l=>{l.key==="Home"?(i(l),l.preventDefault()):l.key==="End"?(a(l),l.preventDefault()):Dg.concat(Bg).includes(l.key)&&(c(l),l.preventDefault())}),onPointerDown:De(e.onPointerDown,l=>{const p=l.target;p.setPointerCapture(l.pointerId),l.preventDefault(),f.thumbs.has(p)?p.focus():n(l)}),onPointerMove:De(e.onPointerMove,l=>{l.target.hasPointerCapture(l.pointerId)&&o(l)}),onPointerUp:De(e.onPointerUp,l=>{const p=l.target;p.hasPointerCapture(l.pointerId)&&(p.releasePointerCapture(l.pointerId),s(l))})})}),Wg="SliderTrack",Rg=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=pa(Wg,r);return d.jsx(je.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...n,ref:t})});Rg.displayName=Wg;var Oc="SliderRange",Gg=b.forwardRef((e,t)=>{const{__scopeSlider:r,...n}=e,o=pa(Oc,r),s=Vg(Oc,r),i=b.useRef(null),a=Qe(t,i),c=o.values.length,u=o.values.map(p=>Yg(p,o.min,o.max)),f=c>1?Math.min(...u):0,l=100-Math.max(...u);return d.jsx(je.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...n,ref:a,style:{...e.style,[s.startEdge]:f+"%",[s.endEdge]:l+"%"}})});Gg.displayName=Oc;var Ic="SliderThumb",Kg=b.forwardRef((e,t)=>{const r=O_(e.__scopeSlider),[n,o]=b.useState(null),s=Qe(t,a=>o(a)),i=b.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return d.jsx(B_,{...e,ref:s,index:i})}),B_=b.forwardRef((e,t)=>{const{__scopeSlider:r,index:n,name:o,...s}=e,i=pa(Ic,r),a=Vg(Ic,r),[c,u]=b.useState(null),f=Qe(t,w=>u(w)),l=c?i.form||!!c.closest("form"):!0,p=ms(c),g=i.values[n],m=g===void 0?0:Yg(g,i.min,i.max),h=z_(n,i.values.length),y=p?.[a.size],S=y?V_(y,m,a.direction):0;return b.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),d.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${m}% + ${S}px)`},children:[d.jsx(Pc.ItemSlot,{scope:e.__scopeSlider,children:d.jsx(je.span,{role:"slider","aria-label":e["aria-label"]||h,"aria-valuemin":i.min,"aria-valuenow":g,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:f,style:g===void 0?{display:"none"}:e.style,onFocus:De(e.onFocus,()=>{i.valueIndexToChangeRef.current=n})})}),l&&d.jsx(qg,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:g},n)]})});Kg.displayName=Ic;var $_="RadioBubbleInput",qg=b.forwardRef(({__scopeSlider:e,value:t,...r},n)=>{const o=b.useRef(null),s=Qe(o,n),i=hs(t);return b.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&f){const l=new Event("input",{bubbles:!0});f.call(a,t),a.dispatchEvent(l)}},[i,t]),d.jsx(je.input,{style:{display:"none"},...r,ref:s,defaultValue:t})});qg.displayName=$_;function j_(e=[],t,r){const n=[...e];return n[r]=t,n.sort((o,s)=>o-s)}function Yg(e,t,r){const s=100/(r-t)*(e-t);return us(s,[0,100])}function z_(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function U_(e,t){if(e.length===1)return 0;const r=e.map(o=>Math.abs(o-t)),n=Math.min(...r);return r.indexOf(n)}function V_(e,t,r){const n=e/2,s=Mc([0,50],[0,n]);return(n-s(t)*r)*r}function H_(e){return e.slice(0,-1).map((t,r)=>e[r+1]-t)}function W_(e,t){if(t>0){const r=H_(e);return Math.min(...r)>=t}return!0}function Mc(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function R_(e){return(String(e).split(".")[1]||"").length}function G_(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}var K_=zg,q_=Rg,Y_=Gg,X_=Kg;function J_({className:e,defaultValue:t,value:r,min:n=0,max:o=100,...s}){const i=b.useMemo(()=>Array.isArray(r)?r:Array.isArray(t)?t:[n,o],[r,t,n,o]);return d.jsxs(K_,{"data-slot":"slider",defaultValue:t,value:r,min:n,max:o,className:H("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...s,children:[d.jsx(q_,{"data-slot":"slider-track",className:H("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:d.jsx(Y_,{"data-slot":"slider-range",className:H("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:i.length},(a,c)=>d.jsx(X_,{"data-slot":"slider-thumb",className:"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},c))]})}const Q_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=e.properties,f=u?.min??0,l=u?.max??100,p=u?.step??1,g=u?.showValue!==!1,m=u?.marks||[],h=S=>{s||i||e.disabled||e.readOnly||(r(S[0]??f),n?.())},y=t??f;return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[g&&d.jsx("span",{className:"text-sm font-medium",children:y}),!g&&d.jsx("span",{className:"text-sm text-muted-foreground",children:f}),!g&&d.jsx("span",{className:"text-sm text-muted-foreground",children:l})]}),d.jsx(J_,{id:ft(e),value:[y],onValueChange:h,min:f,max:l,step:p,disabled:s||e.disabled||i||e.readOnly,className:H("w-full",o&&"border-destructive",e.appearance?.className),"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a}),m.length>0&&d.jsx("div",{className:"flex justify-between text-xs text-muted-foreground",children:m.map((S,w)=>d.jsx("span",{className:"text-center",children:S.label},w))})]})})},Z_=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c})=>{const u=v.useRef(null),[f,l]=v.useState(!1),p=s||e.disabled||i||e.readOnly,g=v.useCallback(S=>{if(p)return;l(!0);const w=u.current;if(!w)return;const A=w.getContext("2d");if(!A)return;const x=w.getBoundingClientRect(),F="touches"in S?S.touches[0].clientX-x.left:S.clientX-x.left,N="touches"in S?S.touches[0].clientY-x.top:S.clientY-x.top;A.beginPath(),A.moveTo(F,N)},[p]),m=v.useCallback(S=>{if(!f||p)return;const w=u.current;if(!w)return;const A=w.getContext("2d");if(!A)return;const x=w.getBoundingClientRect(),F="touches"in S?S.touches[0].clientX-x.left:S.clientX-x.left,N="touches"in S?S.touches[0].clientY-x.top:S.clientY-x.top;A.lineWidth=2,A.lineCap="round",A.strokeStyle="#000",A.lineTo(F,N),A.stroke(),A.beginPath(),A.moveTo(F,N)},[f,p]),h=v.useCallback(()=>{if(!f)return;l(!1);const S=u.current;if(!S)return;const w=S.toDataURL();r(w),n?.()},[f,r,n]),y=v.useCallback(()=>{const S=u.current;if(!S||p)return;const w=S.getContext("2d");w&&(w.clearRect(0,0,S.width,S.height),r(null),n?.())},[p,r,n]);return v.useEffect(()=>{const S=u.current;if(S&&(S.width=S.offsetWidth,S.height=200,t)){const w=new Image;w.onload=()=>{const A=S.getContext("2d");A&&A.drawImage(w,0,0)},w.src=t}},[t]),d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{className:"space-y-2",children:[d.jsx("div",{className:H("border-2 border-dashed rounded-lg overflow-hidden",o&&"border-destructive",p&&"opacity-50 cursor-not-allowed"),children:d.jsx("canvas",{ref:u,id:ft(e),className:"w-full cursor-crosshair touch-none",onMouseDown:g,onMouseMove:m,onMouseUp:h,onMouseLeave:h,onTouchStart:g,onTouchMove:m,onTouchEnd:h,"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,style:{height:"200px"}})}),!p&&d.jsx("div",{className:"flex justify-end",children:d.jsxs(Zt,{type:"button",variant:"outline",size:"sm",onClick:y,className:"text-xs",children:[d.jsx(rs,{className:"h-3 w-3 mr-1"}),"Clear"]})})]})})},eT=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,hideRowControls:u=!1,formValues:f,submissionContext:l})=>{const p=e.properties,g=p?.columns||[],m=p?.minRows||1,h=p?.maxRows||10,y=!u&&p?.allowAddRow!==!1,S=!u&&p?.allowDeleteRow!==!1,w=s===!1&&i===!1?!1:s||e.disabled||i||e.readOnly,A=t||[],x=y&&A.length<h,F=S&&A.length>m,N=v.useCallback(()=>{if(!x||w)return;const M={};g.forEach(z=>{M[z.name]=z.defaultValue??""}),r([...A,M]),n?.()},[A,g,x,w,r,n]),k=v.useCallback(M=>{if(!F||w)return;const z=A.filter((V,X)=>X!==M);r(z),n?.()},[A,F,w,r,n]),T=v.useCallback((M,z,V)=>{if(w)return;const X=[...A];X[M]||(X[M]={}),X[M][z]=V,r(X),n?.()},[A,w,r,n]);if(v.useEffect(()=>{if(A.length<m){const M=m-A.length,z=[];for(let V=0;V<M;V++){const X={};g.forEach(L=>{X[L.name]=L.defaultValue??""}),z.push(X)}r([...A,...z])}},[m,g,r,A.length]),g.length===0)return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this table field"})});const P=Math.max(1,e.position?.rowSpan??1),E=Math.max(1,e.position?.columnSpan??1),C=Math.max(A.length,1),I=P>=3?"py-4":P>=2?"py-3":"py-2.5",W=E>=3?"px-4":E>=2?"px-3":"px-4";return d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:H("flex h-full min-h-0 w-full min-w-0 flex-1 flex-col border rounded-lg overflow-hidden shadow-sm bg-background",o&&"border-destructive",w&&"opacity-50"),"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[d.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:d.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:p?.minWidth?{minWidth:p.minWidth}:void 0,children:[d.jsx("thead",{children:d.jsxs("tr",{className:"border-b border-border bg-muted/60",children:[g.map(M=>d.jsxs("th",{className:H(W,I,"text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground whitespace-nowrap"),children:[M.label,a&&M.validation?.some(z=>z.type==="required")&&d.jsx("span",{className:"text-destructive ml-1",children:"*"})]},M.id)),S&&d.jsx("th",{className:"w-12"})]})}),d.jsx("tbody",{className:"h-full",children:A.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:g.length+(S?1:0),className:H(W,"py-8 text-center text-sm text-muted-foreground"),children:u?"No rows to display.":'No rows added yet. Click "Add Row" to get started.'})}):A.map((M,z)=>{const V=A[z],X=V&&typeof V=="object"&&!Array.isArray(V)?{...f??{},...V}:f;return d.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/30 transition-colors last:border-b-0",style:{height:`${100/C}%`},children:[g.map(L=>{const B={...L,name:`${e.name}_${z}_${L.name}`,appearance:{...L.appearance,hideLabel:!0}},D=L.name??"",K=M[D]!==void 0?M[D]:D&&Object.keys(M).find(G=>G.toLowerCase()===D.toLowerCase())?M[Object.keys(M).find(G=>G.toLowerCase()===D.toLowerCase())]:void 0,ae=!!L.readOnly,j=G=>{if(G==null)return"";if(Array.isArray(G))return G.map(ie=>typeof ie=="object"&&ie!==null&&"name"in ie?String(ie.name??ie):String(ie)).join(", ");if(typeof G=="object"&&G!==null&&!(G instanceof Date)){const ie=G;return typeof ie.name=="string"&&typeof ie.code=="string"?`${ie.code} ${ie.name}`.trim():typeof ie.name=="string"?ie.name:typeof ie.code=="string"?ie.code:String(ie.name??ie.code??G)}return String(G)},U=G=>typeof G=="object"&&G!==null&&!Array.isArray(G)?j(G):String(G??""),le=L.name?.toLowerCase()==="type"||L.label?.toLowerCase()==="type";if(ae){const G=j(K);return d.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:d.jsx("div",{className:"min-w-[120px] text-sm text-foreground",children:le&&G?d.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 text-primary px-2.5 py-0.5 text-xs font-medium",children:G}):d.jsx("span",{className:"py-1 block",children:G})})},L.id)}const oe=()=>{switch(L.type){case"text":case"password":case"url":return d.jsx(ri,{field:B,value:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"number":return d.jsx(dl,{field:B,value:K??null,onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"email":return d.jsx(Ku,{field:B,value:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"phone":case"aadhaar":return d.jsx(qu,{field:B,value:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"otp":return d.jsx(Wf,{field:B,value:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"textarea":return d.jsx(Rf,{field:B,value:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});case"select":return d.jsx(Tm,{field:B,value:typeof K=="string"?K:U(K),onChange:G=>T(z,L.name,G),disabled:w,className:"w-full",formValues:X,submissionContext:l});case"multiselect":{const G=Array.isArray(K)?K:K!=null&&K!==""?[String(K)]:[];return d.jsx(yh,{field:B,value:G,onChange:ie=>T(z,L.name,ie),disabled:w,className:"w-full",formValues:X,submissionContext:l})}case"asyncsearch":return d.jsx(qm,{field:B,value:K,onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full",formValues:X,submissionContext:l});case"checkbox":return d.jsx(bh,{field:B,value:K||!1,onChange:G=>T(z,L.name,G),disabled:w,className:"w-full"});case"radio":case"checkboxgroup":return d.jsx(Wh,{field:B,value:typeof K=="string"?K:U(K),onChange:G=>T(z,L.name,G),disabled:w,className:"w-full"});case"date":case"time":case"datetime":case"daterange":return d.jsx(Rh,{field:B,value:typeof K=="string"?K:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"});default:return d.jsx(ri,{field:B,value:U(K),onChange:G=>T(z,L.name,G),disabled:w,readOnly:w,className:"w-full"})}};return d.jsx("td",{className:"px-4 py-2.5 align-middle first:pl-6 last:pr-6",children:d.jsx("div",{className:"min-w-[160px] w-full [&_input]:min-w-[10rem] [&_input]:overflow-visible [&_textarea]:min-h-[2.5rem]",children:oe()})},L.id)}),S&&d.jsx("td",{className:"px-2 py-2",children:d.jsx(Zt,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>k(z),disabled:!F||w,children:d.jsx(rs,{className:"h-4 w-4"})})})]},z)})})]})}),x&&d.jsx("div",{className:"shrink-0 p-3 border-t bg-muted/30",children:d.jsxs(Zt,{type:"button",variant:"outline",size:"sm",onClick:N,disabled:w,className:"w-full",children:[d.jsx(Ru,{className:"h-4 w-4 mr-2"}),"Add Row"]})})]})})},tT="h-8 min-h-8 rounded-md border border-input bg-background px-2 text-sm shadow-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30",rT="flex min-h-8 w-full items-center gap-0.5 rounded-md border border-input bg-background px-2 focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30",nT="h-8 min-w-[2ch] max-w-full flex-1 border-0 bg-transparent px-0 shadow-none focus-visible:ring-0",oT="align-top max-w-0 whitespace-normal break-words",Cs="block min-w-0 break-words";function Xg(e,t,r){const n=r?.emptyDisplay??"—";if(e==null||e==="")return n;const o=t?.format??"text",s=typeof e=="number"?e:Number(e);switch(o){case"currency":return Number.isNaN(s)?n:`${r?.currencySymbol??"₹"}${s.toLocaleString("en-IN",{minimumFractionDigits:0,maximumFractionDigits:2})}`;case"percent":return Number.isNaN(s)?n:`${s}%`;case"number":return Number.isNaN(s)?n:String(s);default:return String(e)}}function sT(e){const t=e.replace(/[^\d.-]/g,"");if(t===""||t==="-"||t===".")return null;const r=parseFloat(t);return Number.isNaN(r)?null:r}function iT(e){if(e==null||e==="")return"";const t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?"":String(t)}function Jg(e,t){return Xg(e,{format:"currency"},t)}function Es(e){return e==null||e===""}function Qg(e){return e.mode??"editable"}function aT(e,t){return e.kind==="currency"||e.kind==="input"&&e.inputType==="number"?!0:t?.format==="currency"||t?.format==="number"||t?.format==="percent"}function Zg(e,t,r){if(e!==void 0){if(e==="")return"";if(aT(t,r)){const n=Number(e);return Number.isNaN(n)?e:n}return e}}function Lc(e,t){if(!(!e||!("defaultValue"in e)||e.defaultValue===void 0))return Zg(e.defaultValue,e,t)}function Dc(e,t,r){if(!t||!Es(e))return e;if(t.kind==="currency"&&Qg(t)==="static"&&t.value!==void 0)return Zg(t.value,t,r);const n=Lc(t,r);return n!==void 0?n:e}function lT(e,t,r){const n={...t};for(const[o,s]of Object.entries(e)){const i=r.find(c=>c.key===o);if(!Es(n[o]))continue;const a=Dc(n[o],s,i);(!Es(a)||s&&"defaultValue"in s&&s.defaultValue==="")&&(n[o]=a)}return n}function ma(e,t,r){if(!Es(e))return e;const n=Lc(t,r);return n!==void 0?n:e}const cT=new Set(["all_items_summary","invoice_discount","grand_total"]);function dT(e,t){switch(t){case"dynamic":return e.filter(r=>r.rowKind==="dynamic");case"static":return e.filter(r=>r.rowKind==="static");case"all":return e;case"data":return e.filter(r=>r.rowKind==="dynamic"||r.rowKind==="static"&&!cT.has(r.slotId));default:return e}}function uT(e){if(typeof e=="number"&&!Number.isNaN(e))return e;const t=Number(e);return Number.isNaN(t)?0:t}function fT(e,t,r){const n=e.rowSlots.find(o=>o.kind==="static"?o.row.id===t.slotId:o.kind==="dynamic"&&o.block.id===t.slotId);if(n)return n.kind==="static"?n.row.cells[r]:n.block.cells[r]}function pT(e,t,r,n){const o=f=>Fu(n,t,f,r),s=(f,l)=>Fu(n,t,l,r,{slotId:f,rowKind:"static"}),i=(f,l="all")=>dT(t,l).reduce((p,g)=>p+uT(g.values[f]),0),a={...Xs.functions,cell:o,cellInRow:s,SUM:i},c=Object.keys(a),u=Object.values(a);try{const f=new Function(...c,`return (${e});`)(...u);return f==null||typeof f=="number"&&Number.isNaN(f)?null:f}catch{return null}}function mT(e,t){return e.length!==t.length?!1:e.every((r,n)=>{const o=t[n];return r.slotId===o.slotId&&r.rowInstanceId===o.rowInstanceId&&JSON.stringify(r.values)===JSON.stringify(o.values)})}function hT(e,t){const r=t.rows.map(n=>({...n,values:{...n.values}}));for(const n of r)for(const o of e.columns){const s=fT(e,n,o.key);if(s?.kind==="formula"){const i=pT(s.expression,r,n,e),a=e.columns.find(c=>c.key===o.key);n.values[o.key]=Es(i)?Lc(s,a)??i:i}}return{rows:r}}function Lo(e,t,r=8){let n={rows:t.rows.map(o=>({...o,values:{...o.values}}))};for(let o=0;o<r;o++){const s=hT(e,n);if(mT(s.rows,n.rows))return s;n=s}return n}function gT(e,t,r,n,o,s){const i=t.rows.map(a=>a.rowInstanceId!==r||a.slotId!==n?a:{...a,values:{...a.values,[o]:s}});return Lo(e,{rows:i})}function ey(e,t,r=[]){return t.map((n,o)=>{const s=typeof n=="object"&&n!==null?n:{},i=e.rowIdField&&s[e.rowIdField]!=null?String(s[e.rowIdField]):String(o),a={};for(const[u,f]of Object.entries(e.cells)){const l=r.find(p=>p.key===u);(f.kind==="api"&&f.path||f.kind==="currency"&&f.mode==="api"&&f.path)&&(a[u]=ma(Ge(s,f.path),f,l))}const c=a.service??a.tariff_type;return{slotId:e.id,rowKind:"dynamic",rowInstanceId:i,label:typeof c=="string"?c:void 0,values:a}})}function Bc(e,t,r){const n=[];for(const o of e.rowSlots)if(o.kind==="static"){const s=t.get(o.row.id);s&&n.push(s)}else n.push(...r.get(o.block.id)??[]);return n}function $c(e,t){const r=new Map,n=new Map;for(const o of e.rowSlots)if(o.kind==="static"){const s=t?.rows.find(i=>i.slotId===o.row.id&&i.rowKind==="static");r.set(o.row.id,{slotId:o.row.id,rowKind:"static",rowInstanceId:o.row.id,label:o.row.label,values:lT(o.row.cells,s?.values?{...s.values}:{},e.columns)})}else{const s=t?.rows.filter(i=>i.slotId===o.block.id&&i.rowKind==="dynamic")??[];n.set(o.block.id,s.map(i=>({...i,values:{...i.values}})))}return{rows:Bc(e,r,n)}}function yT(e,t,r,n){const o=$c(e,n),s=e.rowSlots.find(c=>c.kind==="dynamic"&&c.block.id===t);if(!s||s.kind!=="dynamic")return Lo(e,o);const i=new Map,a=new Map;for(const c of e.rowSlots)if(c.kind==="static"){const u=o.rows.find(f=>f.slotId===c.row.id&&f.rowKind==="static");u&&i.set(c.row.id,{...u,values:{...u.values}})}else{const u=c.block.id===t?ey(c.block,r,e.columns):o.rows.filter(f=>f.slotId===c.block.id&&f.rowKind==="dynamic");a.set(c.block.id,u.map(f=>({...f,values:{...f.values}})))}return Lo(e,{rows:Bc(e,i,a)})}function ty(e,t,r){const n=$c(e,r);if(t==null||typeof t!="object"||Array.isArray(t))return Lo(e,n);const o=t,s=new Map,i=new Map;for(const a of e.rowSlots)if(a.kind==="static"){const u={...n.rows.find(l=>l.slotId===a.row.id&&l.rowKind==="static")?.values??{}},f=o[a.row.id]??o;for(const[l,p]of Object.entries(a.row.cells)){const g=e.columns.find(m=>m.key===l);(p.kind==="api"&&p.path||p.kind==="currency"&&p.mode==="api"&&p.path)&&(u[l]=ma(Ge(f,p.path),p,g))}s.set(a.row.id,{slotId:a.row.id,rowKind:"static",rowInstanceId:a.row.id,label:a.row.label,values:u})}else{const c=a.block.apiArrayPath??a.block.id,u=Ge(o,c);i.set(a.block.id,Array.isArray(u)?ey(a.block,u,e.columns):[])}return Lo(e,{rows:Bc(e,s,i)})}function ry(e){if(!e)return"";const t=[];switch(e.fontSize){case"xs":t.push("text-xs");break;case"sm":t.push("text-sm");break;case"base":t.push("text-base");break;case"lg":t.push("text-lg");break;case"xl":t.push("text-xl");break}return e.bold?t.push("font-bold"):e.fontSize&&t.push("font-medium"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),t.join(" ")}function bT(e){const t=e?.color?.trim();return t?{color:t}:{}}function jc(e){return{className:ry(e),style:bT(e)}}function vT(e){return e?!!(e.fontSize||e.bold||e.italic||e.underline||e.color?.trim()):!1}function wT(e,t){if(!e&&!t)return;const r={...e,...t};return vT(r)?r:void 0}function ST(e,t){const r=e?.kind==="label"?wT(t,e.cellStyle):e?.cellStyle;return jc(r)}function zc(e){return e==="center"?"text-center":e==="right"?"text-right":"text-left"}function ny(e,t){return e?.align?e.align:t?.align??"left"}function oy(e){const t=e.properties,r=t?.apiEndpoint?{apiEndpoint:t.apiEndpoint,apiMethod:t.apiMethod,apiKey:t.apiKey,apiRealtime:t.apiRealtime,apiQueryParams:t.apiQueryParams,apiHeaders:t.apiHeaders,apiBodyFields:t.apiBodyFields,apiAuth:t.apiAuth,valueSource:t.valueSource,dependentFields:t.dependentFields,apiResponsePath:t.apiResponsePath}:null,n=e.apidata||null;return r||n}function sy(e){if(e.type!=="billingGrid")return!1;const t=oy(e),r=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||r?.valueSource==="api"))}function xT(e,t,r){let n=e;if(r?.trim()&&(n=Ge(e,r.trim())),n==null)return null;if(Array.isArray(n)){const o=t.rowSlots.find(s=>s.kind==="dynamic");return o?.kind==="dynamic"?{[o.block.apiArrayPath?.trim()||o.block.id]:n}:null}return typeof n=="object"?n:null}function ha(e){return JSON.stringify(e?.rows??[])}function AT({field:e,properties:t,formValues:r={},submissionContext:n,value:o,onChange:s}){const i=sy(e),a=oy(e),[c,u]=v.useState(!1),[f,l]=v.useState(null),p=v.useRef(""),g=v.useRef(o);g.current=o;const m=v.useMemo(()=>{const x=a?.apiEndpoint||"",F=a?.apiQueryParams;return po(x,F)},[a?.apiEndpoint,a?.apiQueryParams]),h=v.useMemo(()=>{const x=new Set;for(const F of a?.dependentFields??[])typeof F=="string"&&F.trim()&&x.add(F.trim());return[...x]},[a?.dependentFields]),y=v.useMemo(()=>{const x=new Set([...m,...h]);if(x.size===0)return null;const F={};return x.forEach(N=>{F[N]=r[N]}),JSON.stringify(F)},[m,h,r]),S=v.useMemo(()=>JSON.stringify(n||{}),[n]),w=v.useMemo(()=>{const x=new Set;e.name?.trim()&&x.add(e.name.trim());const F=e.key;return typeof F=="string"&&F.trim()&&x.add(F.trim()),[...x]},[e.name,e.key]),A=v.useMemo(()=>JSON.stringify({rowSlots:t.rowSlots,columns:t.columns}),[t.rowSlots,t.columns]);return v.useEffect(()=>{const x=a?.apiEndpoint;if(!i||!x)return;let F=!1;const N=T=>{if(F)return;const P=ha(T),E=ha(g.current);P!==E&&p.current!==P&&(p.current=P,s(T))};return(async()=>{u(!0),l(null);try{const T=a?.apiMethod||"GET",P=a?.apiRealtime,E=Qs({apiEndpoint:x,apiMethod:T,apiQueryParams:a?.apiQueryParams||{},formValues:r,submissionContext:n,apiRealtime:P,additionalRequiredFieldNames:h,excludeFormFieldNames:w});if(E.blocked){F||u(!1);return}const C={"Content-Type":"application/json"};a?.apiKey&&(C["X-CSCAPI-KEY"]=a.apiKey);const I=a?.apiAuth??Hi(a?.apiHeaders)??{type:"none"};Object.assign(C,Ri(I,{formValues:r,submissionContext:n,apiRealtime:P})),Object.assign(C,Bn(Vi(a?.apiHeaders),{formValues:r,submissionContext:n,apiRealtime:P}));const W=Bn(a?.apiBodyFields,{formValues:r,submissionContext:n,apiRealtime:P}),M={method:T.toLowerCase(),url:Mr(E.url),headers:C};(E.postBodyBase!=null||Object.keys(W).length>0)&&(M.data={...E.postBodyBase??{},...W});const z=await Ct(M),V=xT(z.data,t,a?.apiResponsePath);if(!V){F||l("API response could not be mapped to billing grid rows.");return}const X=ty(t,V,g.current);N(X)}catch(T){if(F)return;let P="Failed to load billing data";const E=T;if(E.response){const C=E.response.data;if(E.response.status===404)P="API endpoint not found.";else if(E.response.status===401)P="Authentication failed.";else if(typeof C=="string")P=C;else if(C&&typeof C=="object"){const I=C;P=I.error||I.message||I.detail||P}}else E.message&&(P=String(E.message));l(P)}finally{F||u(!1)}})(),()=>{F=!0}},[i,a?.apiEndpoint,a?.apiMethod,a?.apiResponsePath,y,h,w,S,A]),{isLoading:c,error:f}}function CT(e,t,r){return e.rowSlots.find(n=>r==="static"?n.kind==="static"&&n.row.id===t:n.kind==="dynamic"&&n.block.id===t)}function iy(e,t,r,n){const o=e.rowSlots.find(s=>r==="static"?s.kind==="static"&&s.row.id===t:s.kind==="dynamic"&&s.block.id===t);if(o)return o.kind==="static"?o.row.cells[n]:o.block.cells[n]}const ET=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f})=>{const l=e.properties??{},p=l.columns??[],g=l.currencySymbol??"₹",m=l.emptyDisplay??"—",h=s||i,y=sy(e),{isLoading:S}=AT({field:e,properties:l,formValues:u,submissionContext:f,value:t,onChange:r}),w=v.useMemo(()=>{const C=$c(l,t);return Lo(l,C)},[l,t]),A=v.useRef("");v.useEffect(()=>{const C=ha(w),I=ha(t);C===I||C===A.current||(A.current=C,r(w))},[w,t,r]),v.useEffect(()=>{!t?.rows?.length&&w.rows.length&&!y&&r(w)},[t,w,r,y]);const x=v.useCallback((C,I,W,M,z)=>{if(h)return;const V=z==="number"?sT(M):M===""?null:M,X=gT(l,w,C,I,W,V);r(X)},[h,w,r,l]),F=(C,I,W,M,z,V)=>{const X=p.find(U=>U.key===z),L=iy(l,C,I,z),B=zc(ny(L,X)),D=Dc(V,L,X),K=CT(l,C,I),ae=K?.kind==="static"?K.row.labelStyle:K?.kind==="dynamic"?K.block.labelStyle:void 0,j=ST(L,ae);if(L?.kind==="label")return d.jsx("span",{className:H(Cs,j.className||"font-medium",B,!j.style.color&&"text-foreground"),style:j.style,children:M??m});if(L?.kind==="input"&&!h){const U=D==null||D===""?"":String(D);return d.jsx(mn,{type:"text",inputMode:L.inputType==="number"?"decimal":"text",value:U,onChange:le=>x(W,C,z,le.target.value,L.inputType),onBlur:n,className:H(tT,"w-full min-w-0",B,j.className),style:j.style,disabled:h})}if(L?.kind==="currency"){const U=Qg(L);if(U==="static"){const oe=L.value!==void 0&&L.value!==""?Dc(null,{...L,mode:"static"},X):D;return d.jsx("span",{className:H(Cs,"tabular-nums",B,j.className),style:j.style,children:Jg(oe,{currencySymbol:g,emptyDisplay:m})})}if(U==="api"||h)return d.jsx("span",{className:H(Cs,"tabular-nums",B,j.className),style:j.style,children:Jg(D,{currencySymbol:g,emptyDisplay:m})});const le=iT(D);return d.jsxs("div",{className:H(rT,B==="text-center"&&"justify-center",B==="text-right"&&"justify-end",B==="text-left"&&"justify-start",j.className),style:j.style,children:[d.jsx("span",{className:"shrink-0 tabular-nums",children:g}),d.jsx(mn,{type:"text",inputMode:"decimal",value:le,onChange:oe=>x(W,C,z,oe.target.value,"number"),onBlur:n,className:nT,disabled:h})]})}return L?.kind==="static"?d.jsx("span",{className:H(Cs,B,j.className,!j.style.color&&"text-muted-foreground"),style:j.style,children:L.value}):d.jsx("span",{className:H(Cs,B,j.className),style:j.style,children:Xg(D,X,{currencySymbol:g,emptyDisplay:m})})},N=l.gridTitle?.trim()??"",k=Math.max(1,e.position?.rowSpan??1),T=Math.max(1,e.position?.columnSpan??1),P=k>=3?"py-4":k>=2?"py-3":"py-2",E=T>=3?"px-4":T>=2?"px-3":"px-2";return p.length===0?d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsx("div",{className:"p-4 border rounded-md bg-muted/50 text-sm text-muted-foreground",children:"No columns defined for this billing grid"})}):d.jsx(At,{field:e,error:o,isRequired:a,className:c,children:d.jsxs("div",{id:ft(e),className:H("relative flex h-full min-h-0 w-full min-w-0 max-w-full flex-1 flex-col border rounded-lg overflow-hidden shadow-sm bg-background",o&&"border-destructive",h&&"opacity-70"),"aria-describedby":Lt(e,!!o),"aria-invalid":Jt(!!o),"aria-required":a,children:[S&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60",children:d.jsx(mo,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),N?d.jsx("div",{className:H("shrink-0 px-4 py-2 border-b bg-muted/40",ry(l.gridTitleStyle)||"text-muted-foreground"),style:jc(l.gridTitleStyle).style,children:N}):null,d.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:d.jsxs("table",{className:"w-full h-full min-h-full border-collapse text-sm table-fixed",style:l.minWidth?{minWidth:l.minWidth}:void 0,children:[d.jsx("thead",{children:d.jsx("tr",{className:"border-b border-border bg-muted/60",children:p.map(C=>{const I=jc(C.headerStyle);return d.jsx("th",{className:H(E,P,"text-xs uppercase tracking-wider whitespace-nowrap",zc(C.align),I.className||"font-semibold text-muted-foreground"),style:I.style,children:C.label},C.id)})})}),d.jsx("tbody",{className:"h-full",children:w.rows.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:p.length,className:H(E,"py-8 text-center text-sm text-muted-foreground"),children:"No billing rows configured"})}):w.rows.map(C=>d.jsx("tr",{className:"border-b border-border/60",children:p.map(I=>{const W=iy(l,C.slotId,C.rowKind,I.key),M=ny(W,I);return d.jsx("td",{className:H(E,P,oT,zc(M)),children:F(C.slotId,C.rowKind,C.rowInstanceId,C.label,I.key,C.values[I.key])},I.id)})},`${C.slotId}-${C.rowInstanceId}`))})]})})]})})};function Uc(e,t,r){return ty(e,t,r)}const NT=({field:e,value:t,error:r,disabled:n,isRequired:o,className:s,formValues:i={},submissionContext:a,extraSubmitPayload:c,skipApiCall:u=!1,prepopulateResponse:f=null})=>{const l=e.properties||{},p=l.source??"manual",g=Array.isArray(l.statuses)?l.statuses:[],m=(l.dataPath||"data").trim(),h=l.showStatusText===!0,y=(l.statusTextPath||"data.admissionStatus").trim(),S=l.showCurrentIndicator!==!1,[w,A]=v.useState(null),[x,F]=v.useState(!1),[N,k]=v.useState(null),T=Ba.useParams(),P=v.useRef(i),E=v.useRef(a),C=v.useRef(c),I=v.useRef(T);P.current=i,E.current=a,C.current=c,I.current=T;const W=v.useCallback(async()=>{const L=l.apiEndpoint?.trim();if(!L){k("Status API endpoint is not configured");return}F(!0),k(null);try{const B=E.current,D=C.current,K=B!=null&&typeof B=="object"?{...B,...D||{}}:D||{},ae=Mr(Lr(L,P.current,I.current,K,void 0,f??void 0)),j=(l.apiMethod||"GET").toUpperCase(),U=await fetch(ae,{method:j,headers:j==="POST"?{"Content-Type":"application/json"}:void 0});if(!U.ok)throw new Error(`HTTP ${U.status}`);const le=await U.json(),oe=m?Ge(le,m):le;A(oe&&typeof oe=="object"?oe:{})}catch(B){k(B instanceof Error?B.message:"Failed to load status"),A(null)}finally{F(!1)}},[l.apiEndpoint,l.apiMethod,m,f]);v.useEffect(()=>{p==="api"&&!u&&W()},[p,u,W]);const M=p==="api"?w:t&&typeof t=="object"?(m?Ge(t,m):null)??t:null,z=h&&y&&M?String(Ge(M,y)??Ge({data:M},y)??""):"",V=L=>{if(!M||typeof M!="object")return!1;const B=M[L];return B===!0||B==="true"||B===1};let X=!1;return d.jsx(At,{field:e,error:r||N||void 0,isRequired:o,className:H(s,"!space-y-0 h-full min-h-0 flex flex-col"),children:d.jsxs("div",{className:"rounded-lg border bg-card p-4 h-full min-h-0 flex flex-col",children:[x&&d.jsx("div",{className:"text-sm text-muted-foreground py-2",children:"Loading status..."}),h&&z&&!x&&d.jsx("p",{className:"text-sm text-muted-foreground mb-3 shrink-0","data-status-text":!0,children:z}),!x&&d.jsx("ul",{className:"flex-1 min-h-0 flex flex-col gap-y-8 overflow-y-auto pr-1 py-1",children:g.map(L=>{const B=V(L.key),D=S&&B&&!X;return D&&(X=!0),d.jsxs("li",{className:H("flex items-center gap-3 text-sm",B?"text-foreground":"text-muted-foreground"),children:[B?d.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-green-600 text-white","aria-hidden":!0,children:d.jsx(oi,{className:"h-3 w-3"})}):d.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 border-muted-foreground/40 bg-muted/50","aria-hidden":!0,children:d.jsx(Vu,{className:"h-2.5 w-2.5 text-muted-foreground/60"})}),d.jsx("span",{className:"flex-1 min-w-0",children:L.label}),D&&d.jsx("span",{className:"shrink-0 text-xs font-medium text-primary",children:"Current"})]},L.key)})}),!x&&g.length===0&&d.jsx("p",{className:"text-sm text-muted-foreground",children:"No statuses configured."})]})})};function Vc(e,t){if(!t||!e)return;const r=t.split(".");let n=e;for(const o of r){if(n==null||typeof n!="object")return;n=n[o]}return n}function Do(e,t){if(t){const r=Vc(e,t);if(r!=null)return String(r)}return e.email!=null?String(e.email):e.personal_email!=null?String(e.personal_email):e.id!=null?String(e.id):JSON.stringify(e)}function kT(e,t,r,n){if(r?.length){const s=n??" | ",i=r.map(a=>Vc(e,a)).filter(a=>a!=null).map(a=>String(a));if(i.length)return i.join(s)}if(t){const s=Vc(e,t);if(s!=null)return String(s)}if(e.name!=null&&e.email!=null)return`${e.name} <${e.email}>`;if(e.name!=null)return String(e.name);if(e.email!=null)return String(e.email);const o=e.personal_email;return o!=null?String(o):JSON.stringify(e)}const _T=({field:e,value:t,onChange:r,onBlur:n,error:o,disabled:s,isRequired:i,className:a,submissionContext:c})=>{const u=e.properties||{},{dataSourceContextKey:f,labelField:l="name",valueField:p="email",displayFields:g,displayFieldsSeparator:m=" | ",showSelectAll:h=!0,selectAllByDefault:y=!0}=u;console.log("[SelectableList] Step 1: render",{fieldName:e.name,valueIsArray:Array.isArray(t),valueLength:Array.isArray(t)?t.length:0,valueSample:Array.isArray(t)&&t.length>0?t.slice(0,2):t,submissionContextKeys:c?Object.keys(c):[],dataSourceContextKey:f,contextKeyValue:c&&f?c[f]:void 0});const S=v.useMemo(()=>{if(!f||!c)return[];const C=c[f];return Array.isArray(C)?C:[]},[f,c]);console.log("[SelectableList] Step 2: contextList from submissionContext",{fieldName:e.name,contextListLength:S.length,contextListSample:S.length>0?S.slice(0,2):[]});const[w,A]=v.useState(()=>S.length>0?S:Array.isArray(t)?t:[]);v.useEffect(()=>{if(S.length>0){console.log("[SelectableList] Step 3: sync fullList from context",{fieldName:e.name,contextListLength:S.length}),A(S);return}Array.isArray(t)&&t.length>0&&A(C=>{const I=C.length===0||t.length>C.length?t:C;return console.log("[SelectableList] Step 3: sync fullList from value",{fieldName:e.name,valueLength:t.length,prevLength:C.length,nextLength:I.length}),I})},[S,t]);const x=v.useMemo(()=>{const C=Array.isArray(t)?t:[];return new Set(C.map(W=>Do(W,p)))},[t,p]),F=w.length>0&&w.every(C=>x.has(Do(C,p))),N=w.some(C=>x.has(Do(C,p))),k=v.useCallback((C,I)=>{const W=Do(C,p),M=Array.isArray(t)?t:[];I?x.has(W)||r([...M,C]):r(M.filter(z=>Do(z,p)!==W)),n?.()},[t,p,x,r,n]),T=v.useCallback(C=>{r(C===!0?[...w]:[]),n?.()},[w,r,n]),P=w.length>0?w:Array.isArray(t)?t:[],E=s||e.disabled;return console.log("[SelectableList] Data in list",{fieldName:e.name,listLength:P.length,listSource:w.length>0?"fullList":"value",valueLength:Array.isArray(t)?t.length:0,fullListLength:w.length,listData:P.length>0?P:[],listDataFirstThree:P.length>0?P.slice(0,3):[]}),d.jsx("div",{className:H("relative z-10 flex flex-col min-h-0 h-full w-full",P.length>0&&"min-h-[14rem]",a),children:d.jsx(At,{field:e,error:o,isRequired:i,className:H("flex-1 min-h-0 flex flex-col",P.length>0&&"min-h-[14rem]"),children:d.jsx("div",{className:H("flex-1 min-h-0 flex flex-col",P.length>0&&"min-h-[14rem]"),children:d.jsxs("div",{className:H("flex-1 min-h-0 flex flex-col",P.length>0&&"overflow-visible"),children:[d.jsxs("div",{role:"listbox","aria-multiselectable":!0,className:H("border rounded-md divide-y overflow-y-auto overflow-x-hidden bg-muted/30 overscroll-contain touch-pan-y pb-3 pr-3 z-20 relative",P.length>0?"flex-1 min-h-0":"min-h-0"),children:[h&&P.length>0&&d.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 sticky top-0 bg-background border-b z-10 shrink-0",children:[d.jsx(Yi,{id:`${ft(e)}-select-all`,checked:F?!0:N?"indeterminate":!1,onCheckedChange:T,disabled:E,"aria-label":"Select all"}),d.jsxs(Fn,{htmlFor:`${ft(e)}-select-all`,className:"text-sm font-medium cursor-pointer",children:["Select all (",P.length,")"]}),d.jsxs("div",{className:"flex gap-1 ml-auto",children:[d.jsx(Zt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:E||F,onClick:()=>{r([...w]),n?.()},children:"Select all"}),d.jsx(Zt,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:E||!N,onClick:()=>{r([]),n?.()},children:"Unselect all"})]})]}),P.length===0?d.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No items to display."}):d.jsx(d.Fragment,{children:P.map((C,I)=>{const W=Do(C,p),M=x.has(W),z=`${ft(e)}-${I}-${W}`;return d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 min-h-[2.5rem] hover:bg-muted/50 shrink-0",role:"row",children:[d.jsx(Yi,{id:z,checked:M,onCheckedChange:V=>k(C,V===!0),disabled:E,"aria-describedby":Lt(e,!!o)}),d.jsx(Fn,{htmlFor:z,className:"text-sm cursor-pointer flex-1 truncate",children:kT(C,l,g,m)})]},W)})})]}),P.length>0&&x.size===0&&d.jsxs("p",{className:"flex items-center gap-1.5 mt-2 text-sm text-amber-600 dark:text-amber-500 shrink-0",role:"status",children:[d.jsx(eS,{className:"h-4 w-4 shrink-0"}),"Please select at least one item."]})]})})})})},ay=({field:e,children:t,className:r})=>{const n=e.properties,o=n?.collapsible??!1,s=n?.defaultCollapsed??!1,i=n?.columns??1,[a,c]=v.useState(s),u=()=>{o&&c(!a)},f={1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"};return d.jsxs("div",{className:H("border rounded-lg bg-card",r),children:[d.jsxs("div",{className:H("flex items-center gap-2 px-4 py-3 border-b bg-muted/50",o&&"cursor-pointer hover:bg-muted/70 transition-colors"),onClick:u,children:[o&&d.jsx("span",{className:"text-muted-foreground",children:a?d.jsx(Uu,{className:"h-4 w-4"}):d.jsx(ts,{className:"h-4 w-4"})}),d.jsx("h3",{className:"font-medium text-sm",children:e.label}),e.description&&d.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:e.description})]}),!a&&d.jsx("div",{className:H("p-4 grid gap-4",f[i]),children:t})]})};var TT=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],FT=TT.reduce((e,t)=>{const r=cl(`Primitive.${t}`),n=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(c,{...a,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),PT="Separator",ly="horizontal",OT=["horizontal","vertical"],cy=b.forwardRef((e,t)=>{const{decorative:r,orientation:n=ly,...o}=e,s=IT(n)?n:ly,a=r?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return d.jsx(FT.div,{"data-orientation":s,...a,...o,ref:t})});cy.displayName=PT;function IT(e){return OT.includes(e)}var MT=cy;function Hc({className:e,orientation:t="horizontal",decorative:r=!0,...n}){return d.jsx(MT,{"data-slot":"separator",decorative:r,orientation:t,className:H("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...n})}const LT=({field:e,className:t})=>d.jsx("div",{className:H("py-2",t),children:d.jsx(Hc,{})}),DT={h1:"text-3xl font-bold",h2:"text-2xl font-bold",h3:"text-xl font-semibold",h4:"text-lg font-semibold",h5:"text-base font-medium",h6:"text-sm font-medium"},BT=({field:e,className:t})=>{const r=e.properties,n=r?.headingLevel??"h3",o=r?.showHorizontalLine??!0,s=DT[n],i=n;return d.jsxs("div",{className:H("w-full min-w-0 space-y-1",t),children:[d.jsx(i,{className:H("m-0 text-foreground",s),children:e.label||"Header"}),e.description&&d.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}),o&&d.jsx(Hc,{className:"w-full"})]})},$T={"top-left":"justify-start","top-center":"justify-center","top-right":"justify-end","middle-left":"justify-start",center:"justify-center","middle-right":"justify-end","bottom-left":"justify-start","bottom-center":"justify-center","bottom-right":"justify-end"},jT={h1:"text-3xl font-bold",h2:"text-2xl font-bold",h3:"text-xl font-semibold",h4:"text-lg font-semibold",h5:"text-base font-medium",h6:"text-sm font-medium"},zT=({field:e,className:t})=>{const r=e.properties,n=r?.position??"top-left",o=r?.headingLevel??"h3",s=r?.showHorizontalLine??!0,i=$T[n],a=jT[o],c=o;return d.jsxs("div",{className:H("w-full min-w-0 space-y-2",t),children:[d.jsx("div",{className:H("flex w-full",i),children:d.jsx(c,{className:H("m-0 text-foreground",a),children:e.label||"Section Heading"})}),s&&d.jsx(Hc,{className:"w-full"})]})},UT=({field:e,className:t})=>{const r=e.appearance?.size||"md",n={sm:"h-4",md:"h-8",lg:"h-12"};return d.jsx("div",{className:H(n[r],t),"aria-hidden":"true"})};function dy(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function VT(e){if(Array.isArray(e))return e}function HT(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,s,i,a=[],c=!0,u=!1;try{if(s=(r=r.call(e)).next,t!==0)for(;!(c=(n=s.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(f){u=!0,o=f}finally{try{if(!c&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return a}}function WT(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
51
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function RT(e,t){return VT(e)||HT(e,t)||GT(e,t)||WT()}function GT(e,t){if(e){if(typeof e=="string")return dy(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?dy(e,t):void 0}}const uy=Object.entries,fy=Object.setPrototypeOf,KT=Object.isFrozen,qT=Object.getPrototypeOf,YT=Object.getOwnPropertyDescriptor;let dr=Object.freeze,Br=Object.seal,Bo=Object.create,py=typeof Reflect<"u"&&Reflect,Wc=py.apply,Rc=py.construct;dr||(dr=function(t){return t}),Br||(Br=function(t){return t}),Wc||(Wc=function(t,r){for(var n=arguments.length,o=new Array(n>2?n-2:0),s=2;s<n;s++)o[s-2]=arguments[s];return t.apply(r,o)}),Rc||(Rc=function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return new t(...n)});const $o=Vt(Array.prototype.forEach),XT=Vt(Array.prototype.lastIndexOf),my=Vt(Array.prototype.pop),jo=Vt(Array.prototype.push),JT=Vt(Array.prototype.splice),ur=Array.isArray,Ns=Vt(String.prototype.toLowerCase),Gc=Vt(String.prototype.toString),hy=Vt(String.prototype.match),zo=Vt(String.prototype.replace),gy=Vt(String.prototype.indexOf),QT=Vt(String.prototype.trim),ZT=Vt(Number.prototype.toString),eF=Vt(Boolean.prototype.toString),yy=typeof BigInt>"u"?null:Vt(BigInt.prototype.toString),by=typeof Symbol>"u"?null:Vt(Symbol.prototype.toString),Mt=Vt(Object.prototype.hasOwnProperty),ks=Vt(Object.prototype.toString),rr=Vt(RegExp.prototype.test),ga=tF(TypeError);function Vt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return Wc(e,t,n)}}function tF(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return Rc(e,r)}}function rt(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ns;if(fy&&fy(e,null),!ur(t))return e;let n=t.length;for(;n--;){let o=t[n];if(typeof o=="string"){const s=r(o);s!==o&&(KT(t)||(t[n]=s),o=s)}e[o]=!0}return e}function rF(e){for(let t=0;t<e.length;t++)Mt(e,t)||(e[t]=null);return e}function gr(e){const t=Bo(null);for(const n of uy(e)){var r=RT(n,2);const o=r[0],s=r[1];Mt(e,o)&&(ur(s)?t[o]=rF(s):s&&typeof s=="object"&&s.constructor===Object?t[o]=gr(s):t[o]=s)}return t}function nF(e){switch(typeof e){case"string":return e;case"number":return ZT(e);case"boolean":return eF(e);case"bigint":return yy?yy(e):"0";case"symbol":return by?by(e):"Symbol()";case"undefined":return ks(e);case"function":case"object":{if(e===null)return ks(e);const t=e,r=so(t,"toString");if(typeof r=="function"){const n=r(t);return typeof n=="string"?n:ks(n)}return ks(e)}default:return ks(e)}}function so(e,t){for(;e!==null;){const n=YT(e,t);if(n){if(n.get)return Vt(n.get);if(typeof n.value=="function")return Vt(n.value)}e=qT(e)}function r(){return null}return r}function oF(e){try{return rr(e,""),!0}catch{return!1}}const vy=dr(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Kc=dr(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),qc=dr(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),sF=dr(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Yc=dr(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),iF=dr(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wy=dr(["#text"]),Sy=dr(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Xc=dr(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),xy=dr(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),ya=dr(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),aF=Br(/{{[\w\W]*|^[\w\W]*}}/g),lF=Br(/<%[\w\W]*|^[\w\W]*%>/g),cF=Br(/\${[\w\W]*/g),dF=Br(/^data-[\-\w.\u00B7-\uFFFF]+$/),uF=Br(/^aria-[\-\w]+$/),Ay=Br(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),fF=Br(/^(?:\w+script|data):/i),pF=Br(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),mF=Br(/^html$/i),hF=Br(/^[a-z][.\w]*(-[.\w]+)+$/i),Uo={element:1,text:3,progressingInstruction:7,comment:8,document:9},gF=function(){return typeof window>"u"?null:window},yF=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const o="data-tt-policy-suffix";r&&r.hasAttribute(o)&&(n=r.getAttribute(o));const s="dompurify"+(n?"#"+n:"");try{return t.createPolicy(s,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Cy=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ey(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:gF();const t=_e=>Ey(_e);if(t.version="3.4.5",t.removed=[],!e||!e.document||e.document.nodeType!==Uo.document||!e.Element)return t.isSupported=!1,t;let r=e.document;const n=r,o=n.currentScript,s=e.DocumentFragment,i=e.HTMLTemplateElement,a=e.Node,c=e.Element,u=e.NodeFilter,f=e.NamedNodeMap,l=f===void 0?e.NamedNodeMap||e.MozNamedAttrMap:f,p=e.HTMLFormElement,g=e.DOMParser,m=e.trustedTypes,h=c.prototype,y=so(h,"cloneNode"),S=so(h,"remove"),w=so(h,"nextSibling"),A=so(h,"childNodes"),x=so(h,"parentNode"),F=a&&a.prototype?so(a.prototype,"nodeType"):null;if(typeof i=="function"){const _e=r.createElement("template");_e.content&&_e.content.ownerDocument&&(r=_e.content.ownerDocument)}let N,k="";const T=r,P=T.implementation,E=T.createNodeIterator,C=T.createDocumentFragment,I=T.getElementsByTagName,W=n.importNode;let M=Cy();t.isSupported=typeof uy=="function"&&typeof x=="function"&&P&&P.createHTMLDocument!==void 0;const z=aF,V=lF,X=cF,L=dF,B=uF,D=fF,K=pF,ae=hF;let j=Ay,U=null;const le=rt({},[...vy,...Kc,...qc,...Yc,...wy]);let oe=null;const G=rt({},[...Sy,...Xc,...xy,...ya]);let ie=Object.seal(Bo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ce=null,ee=null;const ne=Object.seal(Bo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let he=!0,Ie=!0,Ue=!1,re=!0,ge=!1,Se=!0,pt=!1,Dt=!1,Bt=!1,Pt=!1,Ar=!1,Nt=!1,Cr=!0,Xe=!1;const ve="user-content-";let ce=!0,J=!1,$={},fe=null;const it=rt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Te=null;const Ye=rt({},["audio","video","img","source","image","track"]);let Me=null;const xe=rt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),et="http://www.w3.org/1998/Math/MathML",We="http://www.w3.org/2000/svg",dt="http://www.w3.org/1999/xhtml";let bt=dt,ir=!1,xt=null;const $e=rt({},[et,We,dt],Gc);let gt=rt({},["mi","mo","mn","ms","mtext"]),vt=rt({},["annotation-xml"]);const kt=rt({},["title","style","font","a","script"]);let nr=null;const yr=["application/xhtml+xml","text/html"],Er="text/html";let Ot=null,Nr=null;const ar=r.createElement("form"),Sn=function(O){return O instanceof RegExp||O instanceof Function},un=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Nr&&Nr===O)return;(!O||typeof O!="object")&&(O={}),O=gr(O),nr=yr.indexOf(O.PARSER_MEDIA_TYPE)===-1?Er:O.PARSER_MEDIA_TYPE,Ot=nr==="application/xhtml+xml"?Gc:Ns,U=Mt(O,"ALLOWED_TAGS")&&ur(O.ALLOWED_TAGS)?rt({},O.ALLOWED_TAGS,Ot):le,oe=Mt(O,"ALLOWED_ATTR")&&ur(O.ALLOWED_ATTR)?rt({},O.ALLOWED_ATTR,Ot):G,xt=Mt(O,"ALLOWED_NAMESPACES")&&ur(O.ALLOWED_NAMESPACES)?rt({},O.ALLOWED_NAMESPACES,Gc):$e,Me=Mt(O,"ADD_URI_SAFE_ATTR")&&ur(O.ADD_URI_SAFE_ATTR)?rt(gr(xe),O.ADD_URI_SAFE_ATTR,Ot):xe,Te=Mt(O,"ADD_DATA_URI_TAGS")&&ur(O.ADD_DATA_URI_TAGS)?rt(gr(Ye),O.ADD_DATA_URI_TAGS,Ot):Ye,fe=Mt(O,"FORBID_CONTENTS")&&ur(O.FORBID_CONTENTS)?rt({},O.FORBID_CONTENTS,Ot):it,Ce=Mt(O,"FORBID_TAGS")&&ur(O.FORBID_TAGS)?rt({},O.FORBID_TAGS,Ot):gr({}),ee=Mt(O,"FORBID_ATTR")&&ur(O.FORBID_ATTR)?rt({},O.FORBID_ATTR,Ot):gr({}),$=Mt(O,"USE_PROFILES")?O.USE_PROFILES&&typeof O.USE_PROFILES=="object"?gr(O.USE_PROFILES):O.USE_PROFILES:!1,he=O.ALLOW_ARIA_ATTR!==!1,Ie=O.ALLOW_DATA_ATTR!==!1,Ue=O.ALLOW_UNKNOWN_PROTOCOLS||!1,re=O.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ge=O.SAFE_FOR_TEMPLATES||!1,Se=O.SAFE_FOR_XML!==!1,pt=O.WHOLE_DOCUMENT||!1,Pt=O.RETURN_DOM||!1,Ar=O.RETURN_DOM_FRAGMENT||!1,Nt=O.RETURN_TRUSTED_TYPE||!1,Bt=O.FORCE_BODY||!1,Cr=O.SANITIZE_DOM!==!1,Xe=O.SANITIZE_NAMED_PROPS||!1,ce=O.KEEP_CONTENT!==!1,J=O.IN_PLACE||!1,j=oF(O.ALLOWED_URI_REGEXP)?O.ALLOWED_URI_REGEXP:Ay,bt=typeof O.NAMESPACE=="string"?O.NAMESPACE:dt,gt=Mt(O,"MATHML_TEXT_INTEGRATION_POINTS")&&O.MATHML_TEXT_INTEGRATION_POINTS&&typeof O.MATHML_TEXT_INTEGRATION_POINTS=="object"?gr(O.MATHML_TEXT_INTEGRATION_POINTS):rt({},["mi","mo","mn","ms","mtext"]),vt=Mt(O,"HTML_INTEGRATION_POINTS")&&O.HTML_INTEGRATION_POINTS&&typeof O.HTML_INTEGRATION_POINTS=="object"?gr(O.HTML_INTEGRATION_POINTS):rt({},["annotation-xml"]);const te=Mt(O,"CUSTOM_ELEMENT_HANDLING")&&O.CUSTOM_ELEMENT_HANDLING&&typeof O.CUSTOM_ELEMENT_HANDLING=="object"?gr(O.CUSTOM_ELEMENT_HANDLING):Bo(null);if(ie=Bo(null),Mt(te,"tagNameCheck")&&Sn(te.tagNameCheck)&&(ie.tagNameCheck=te.tagNameCheck),Mt(te,"attributeNameCheck")&&Sn(te.attributeNameCheck)&&(ie.attributeNameCheck=te.attributeNameCheck),Mt(te,"allowCustomizedBuiltInElements")&&typeof te.allowCustomizedBuiltInElements=="boolean"&&(ie.allowCustomizedBuiltInElements=te.allowCustomizedBuiltInElements),ge&&(Ie=!1),Ar&&(Pt=!0),$&&(U=rt({},wy),oe=Bo(null),$.html===!0&&(rt(U,vy),rt(oe,Sy)),$.svg===!0&&(rt(U,Kc),rt(oe,Xc),rt(oe,ya)),$.svgFilters===!0&&(rt(U,qc),rt(oe,Xc),rt(oe,ya)),$.mathMl===!0&&(rt(U,Yc),rt(oe,xy),rt(oe,ya))),ne.tagCheck=null,ne.attributeCheck=null,Mt(O,"ADD_TAGS")&&(typeof O.ADD_TAGS=="function"?ne.tagCheck=O.ADD_TAGS:ur(O.ADD_TAGS)&&(U===le&&(U=gr(U)),rt(U,O.ADD_TAGS,Ot))),Mt(O,"ADD_ATTR")&&(typeof O.ADD_ATTR=="function"?ne.attributeCheck=O.ADD_ATTR:ur(O.ADD_ATTR)&&(oe===G&&(oe=gr(oe)),rt(oe,O.ADD_ATTR,Ot))),Mt(O,"ADD_URI_SAFE_ATTR")&&ur(O.ADD_URI_SAFE_ATTR)&&rt(Me,O.ADD_URI_SAFE_ATTR,Ot),Mt(O,"FORBID_CONTENTS")&&ur(O.FORBID_CONTENTS)&&(fe===it&&(fe=gr(fe)),rt(fe,O.FORBID_CONTENTS,Ot)),Mt(O,"ADD_FORBID_CONTENTS")&&ur(O.ADD_FORBID_CONTENTS)&&(fe===it&&(fe=gr(fe)),rt(fe,O.ADD_FORBID_CONTENTS,Ot)),ce&&(U["#text"]=!0),pt&&rt(U,["html","head","body"]),U.table&&(rt(U,["tbody"]),delete Ce.tbody),O.TRUSTED_TYPES_POLICY){if(typeof O.TRUSTED_TYPES_POLICY.createHTML!="function")throw ga('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof O.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ga('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=O.TRUSTED_TYPES_POLICY,k=N.createHTML("")}else N===void 0&&(N=yF(m,o)),N!==null&&typeof k=="string"&&(k=N.createHTML(""));dr&&dr(O),Nr=O},jr=rt({},[...Kc,...qc,...sF]),zn=rt({},[...Yc,...iF]),$t=function(O){let te=x(O);(!te||!te.tagName)&&(te={namespaceURI:bt,tagName:"template"});const we=Ns(O.tagName),st=Ns(te.tagName);return xt[O.namespaceURI]?O.namespaceURI===We?te.namespaceURI===dt?we==="svg":te.namespaceURI===et?we==="svg"&&(st==="annotation-xml"||gt[st]):!!jr[we]:O.namespaceURI===et?te.namespaceURI===dt?we==="math":te.namespaceURI===We?we==="math"&&vt[st]:!!zn[we]:O.namespaceURI===dt?te.namespaceURI===We&&!vt[st]||te.namespaceURI===et&&!gt[st]?!1:!zn[we]&&(kt[we]||!jr[we]):!!(nr==="application/xhtml+xml"&&xt[O.namespaceURI]):!1},Ht=function(O){jo(t.removed,{element:O});try{x(O).removeChild(O)}catch{S(O)}},br=function(O,te){try{jo(t.removed,{attribute:te.getAttributeNode(O),from:te})}catch{jo(t.removed,{attribute:null,from:te})}if(te.removeAttribute(O),O==="is")if(Pt||Ar)try{Ht(te)}catch{}else try{te.setAttribute(O,"")}catch{}},Jr=function(O){let te=null,we=null;if(Bt)O="<remove></remove>"+O;else{const St=hy(O,/^[\r\n\t ]+/);we=St&&St[0]}nr==="application/xhtml+xml"&&bt===dt&&(O='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+O+"</body></html>");const st=N?N.createHTML(O):O;if(bt===dt)try{te=new g().parseFromString(st,nr)}catch{}if(!te||!te.documentElement){te=P.createDocument(bt,"template",null);try{te.documentElement.innerHTML=ir?k:st}catch{}}const wt=te.body||te.documentElement;return O&&we&&wt.insertBefore(r.createTextNode(we),wt.childNodes[0]||null),bt===dt?I.call(te,pt?"html":"body")[0]:pt?te.documentElement:wt},Yt=function(O){return E.call(O.ownerDocument||O,O,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},lr=function(O){O.normalize();const te=E.call(O.ownerDocument||O,O,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let we=te.nextNode();for(;we;){let st=we.data;$o([z,V,X],wt=>{st=zo(st,wt," ")}),we.data=st,we=te.nextNode()}},Un=function(O){return O instanceof p&&(typeof O.nodeName!="string"||typeof O.textContent!="string"||typeof O.removeChild!="function"||!(O.attributes instanceof l)||typeof O.removeAttribute!="function"||typeof O.setAttribute!="function"||typeof O.namespaceURI!="string"||typeof O.insertBefore!="function"||typeof O.hasChildNodes!="function")},Ls=function(O){if(!F||typeof O!="object"||O===null)return!1;try{return typeof F(O)=="number"}catch{return!1}};function _t(_e,O,te){$o(_e,we=>{we.call(t,O,te,Nr)})}const Ds=function(O){let te=null;if(_t(M.beforeSanitizeElements,O,null),Un(O))return Ht(O),!0;const we=Ot(O.nodeName);if(_t(M.uponSanitizeElement,O,{tagName:we,allowedTags:U}),Se&&O.hasChildNodes()&&!Ls(O.firstElementChild)&&rr(/<[/\w!]/g,O.innerHTML)&&rr(/<[/\w!]/g,O.textContent)||Se&&O.namespaceURI===dt&&we==="style"&&Ls(O.firstElementChild)||O.nodeType===Uo.progressingInstruction||Se&&O.nodeType===Uo.comment&&rr(/<[/\w]/g,O.data))return Ht(O),!0;if(Ce[we]||!(ne.tagCheck instanceof Function&&ne.tagCheck(we))&&!U[we]){if(!Ce[we]&&zr(we)&&(ie.tagNameCheck instanceof RegExp&&rr(ie.tagNameCheck,we)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(we)))return!1;if(ce&&!fe[we]){const st=x(O)||O.parentNode,wt=A(O)||O.childNodes;if(wt&&st){const St=wt.length;for(let Wt=St-1;Wt>=0;--Wt){const Et=y(wt[Wt],!0);st.insertBefore(Et,w(O))}}}return Ht(O),!0}return O instanceof c&&!$t(O)||(we==="noscript"||we==="noembed"||we==="noframes")&&rr(/<\/no(script|embed|frames)/i,O.innerHTML)?(Ht(O),!0):(ge&&O.nodeType===Uo.text&&(te=O.textContent,$o([z,V,X],st=>{te=zo(te,st," ")}),O.textContent!==te&&(jo(t.removed,{element:O.cloneNode()}),O.textContent=te)),_t(M.afterSanitizeElements,O,null),!1)},kr=function(O,te,we){if(ee[te]||Cr&&(te==="id"||te==="name")&&(we in r||we in ar))return!1;const st=oe[te]||ne.attributeCheck instanceof Function&&ne.attributeCheck(te,O);if(!(Ie&&!ee[te]&&rr(L,te))){if(!(he&&rr(B,te))){if(!st||ee[te]){if(!(zr(O)&&(ie.tagNameCheck instanceof RegExp&&rr(ie.tagNameCheck,O)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(O))&&(ie.attributeNameCheck instanceof RegExp&&rr(ie.attributeNameCheck,te)||ie.attributeNameCheck instanceof Function&&ie.attributeNameCheck(te,O))||te==="is"&&ie.allowCustomizedBuiltInElements&&(ie.tagNameCheck instanceof RegExp&&rr(ie.tagNameCheck,we)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(we))))return!1}else if(!Me[te]){if(!rr(j,zo(we,K,""))){if(!((te==="src"||te==="xlink:href"||te==="href")&&O!=="script"&&gy(we,"data:")===0&&Te[O])){if(!(Ue&&!rr(D,zo(we,K,"")))){if(we)return!1}}}}}}return!0},Qr=rt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),zr=function(O){return!Qr[Ns(O)]&&rr(ae,O)},Ur=function(O){_t(M.beforeSanitizeAttributes,O,null);const te=O.attributes;if(!te||Un(O))return;const we={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:oe,forceKeepAttr:void 0};let st=te.length;for(;st--;){const wt=te[st],St=wt.name,Wt=wt.namespaceURI,Et=wt.value,Vr=Ot(St),Ho=Et;let It=St==="value"?Ho:QT(Ho);if(we.attrName=Vr,we.attrValue=It,we.keepAttr=!0,we.forceKeepAttr=void 0,_t(M.uponSanitizeAttribute,O,we),It=we.attrValue,Xe&&(Vr==="id"||Vr==="name")&&gy(It,ve)!==0&&(br(St,O),It=ve+It),Se&&rr(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,It)){br(St,O);continue}if(Vr==="attributename"&&hy(It,"href")){br(St,O);continue}if(we.forceKeepAttr)continue;if(!we.keepAttr){br(St,O);continue}if(!re&&rr(/\/>/i,It)){br(St,O);continue}ge&&$o([z,V,X],xn=>{It=zo(It,xn," ")});const fn=Ot(O.nodeName);if(!kr(fn,Vr,It)){br(St,O);continue}if(N&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Wt)switch(m.getAttributeType(fn,Vr)){case"TrustedHTML":{It=N.createHTML(It);break}case"TrustedScriptURL":{It=N.createScriptURL(It);break}}if(It!==Ho)try{Wt?O.setAttributeNS(Wt,St,It):O.setAttribute(St,It),Un(O)?Ht(O):my(t.removed)}catch{br(St,O)}}_t(M.afterSanitizeAttributes,O,null)},_r=function(O){let te=null;const we=Yt(O);for(_t(M.beforeSanitizeShadowDOM,O,null);te=we.nextNode();)_t(M.uponSanitizeShadowNode,te,null),Ds(te),Ur(te),te.content instanceof s&&_r(te.content);_t(M.afterSanitizeShadowDOM,O,null)},Xt=function(O){if(O.nodeType===Uo.element&&O.shadowRoot instanceof s){const st=O.shadowRoot;Xt(st),_r(st)}const te=O.childNodes;if(!te)return;const we=[];$o(te,st=>{jo(we,st)});for(const st of we)Xt(st)};return t.sanitize=function(_e){let O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},te=null,we=null,st=null,wt=null;if(ir=!_e,ir&&(_e="<!-->"),typeof _e!="string"&&!Ls(_e)&&(_e=nF(_e),typeof _e!="string"))throw ga("dirty is not a string, aborting");if(!t.isSupported)return _e;if(Dt||un(O),t.removed=[],typeof _e=="string"&&(J=!1),J){const Et=_e.nodeName;if(typeof Et=="string"){const Vr=Ot(Et);if(!U[Vr]||Ce[Vr])throw ga("root node is forbidden and cannot be sanitized in-place")}Xt(_e)}else if(Ls(_e))te=Jr("<!---->"),we=te.ownerDocument.importNode(_e,!0),we.nodeType===Uo.element&&we.nodeName==="BODY"||we.nodeName==="HTML"?te=we:te.appendChild(we),Xt(we);else{if(!Pt&&!ge&&!pt&&_e.indexOf("<")===-1)return N&&Nt?N.createHTML(_e):_e;if(te=Jr(_e),!te)return Pt?null:Nt?k:""}te&&Bt&&Ht(te.firstChild);const St=Yt(J?_e:te);for(;st=St.nextNode();)Ds(st),Ur(st),st.content instanceof s&&_r(st.content);if(J)return ge&&lr(_e),_e;if(Pt){if(ge&&lr(te),Ar)for(wt=C.call(te.ownerDocument);te.firstChild;)wt.appendChild(te.firstChild);else wt=te;return(oe.shadowroot||oe.shadowrootmode)&&(wt=W.call(n,wt,!0)),wt}let Wt=pt?te.outerHTML:te.innerHTML;return pt&&U["!doctype"]&&te.ownerDocument&&te.ownerDocument.doctype&&te.ownerDocument.doctype.name&&rr(mF,te.ownerDocument.doctype.name)&&(Wt="<!DOCTYPE "+te.ownerDocument.doctype.name+`>
|
|
52
|
+
`+Wt),ge&&$o([z,V,X],Et=>{Wt=zo(Wt,Et," ")}),N&&Nt?N.createHTML(Wt):Wt},t.setConfig=function(){let _e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};un(_e),Dt=!0},t.clearConfig=function(){Nr=null,Dt=!1},t.isValidAttribute=function(_e,O,te){Nr||un({});const we=Ot(_e),st=Ot(O);return kr(we,st,te)},t.addHook=function(_e,O){typeof O=="function"&&jo(M[_e],O)},t.removeHook=function(_e,O){if(O!==void 0){const te=XT(M[_e],O);return te===-1?void 0:JT(M[_e],te,1)[0]}return my(M[_e])},t.removeHooks=function(_e){M[_e]=[]},t.removeAllHooks=function(){M=Cy()},t}var bF=Ey();const vF=["a","b","br","div","em","h1","h2","h3","h4","h5","h6","i","img","li","ol","p","span","strong","table","tbody","td","th","thead","tr","u","ul"],wF=["href","target","rel","src","alt","title","class","style","colspan","rowspan"];function SF(e){return e?bF.sanitize(e,{ALLOWED_TAGS:[...vF],ALLOWED_ATTR:[...wF],ALLOW_DATA_ATTR:!1}):""}function xF(e,t,r=!1){return e.includes("{labelapi:")?e.replace(/\{labelapi:([^}]+)\}/g,(n,o)=>{const s=o.trim();if(s===""||t==null)return r?"":n;const i=Ge(t,s);return i==null?r?"":n:String(i)}):e}function AF(e){return e&&e.replace(/\{api:[^}]*\}/gi,"").replace(/\{labelapi:[^}]*\}/gi,"").replace(/\{resp:[^}]*\}/gi,"").replace(/\{(?:ctx:|@)\w+\}/gi,"").replace(/\{documentId\}/gi,"").replace(/\{(\w+)\}/g,"")}const Ny={sm:"text-sm",md:"text-base",lg:"text-lg"},ky={h1:"text-4xl font-bold tracking-tight",h2:"text-3xl font-semibold tracking-tight",h3:"text-2xl font-semibold",h4:"text-xl font-semibold",h5:"text-lg font-medium",h6:"text-base font-medium"},_y={normal:"font-normal",medium:"font-medium",bold:"font-bold"},ba={left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"};function io(e){return e.properties??{}}function CF(e){const t=io(e);return t.textContent!==void 0?t.textContent:e.label??""}function EF(e){return io(e).textContent===void 0||e.appearance?.hideLabel?!1:!!e.label?.trim()}function NF(e){return e?.contentLayout==="paragraph"?"paragraph":"single"}function Jc(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:a}=t,c=Lr(e,r,n,o,s,i),u=xF(c,a,!0);return AF(u)}const kF=/\{api:[^}]+\}/,_F=/\{labelapi:[^}]+\}/;function Qc(e){return kF.test(e)}function Zc(e){return _F.test(e)}function TF(e){const t=e.captionTemplate??"",r=e.descriptionTemplate??"",n=Qc(e.bodyTemplate)||Qc(t)||Qc(r),o=Zc(e.bodyTemplate)||Zc(t)||Zc(r);return!!(n&&e.prepopulateLoading||o&&e.labelApiConfigPresent&&(e.labelApiLoading||e.labelApiResponse===void 0&&e.labelApiError==null))}function Ty(e,t){const r=t??io(e),n=r.variant??"body",o=e.appearance?.size??"md",s=Ny[o]??Ny.md,i=r.fontWeight??"medium";return n!=="body"?H("m-0 text-foreground",ky[n]??ky.h3,r.fontWeight&&_y[r.fontWeight],r.italic&&"italic",r.underline&&"underline",r.textAlign&&ba[r.textAlign]):H("m-0 text-foreground",s,_y[i],r.italic&&"italic",r.underline&&"underline",r.textAlign&&ba[r.textAlign])}function FF(e,t){const r=(t??io(e)).variant??"body";return r==="body"?"p":r}function ed(e){const t=[];let r=0,n="";const o=()=>{n&&(t.push({type:"text",value:n}),n="")},s=(i,a,c)=>{if(!e.startsWith(i,r))return!1;const u=e.indexOf(a,r+i.length);if(u===-1)return!1;o();const f=e.slice(r+i.length,u);return t.push({type:c,children:ed(f)}),r=u+a.length,!0};for(;r<e.length;){if(e[r]==="\\"&&r+1<e.length){n+=e[r+1],r+=2;continue}s("**","**","bold")||s("__","__","underline")||s("*","*","italic")||s("_","_","italic")||(n+=e[r],r+=1)}return o(),t}function PF(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Fy(e){return e.map(t=>{if(t.type==="text")return PF(t.value);const r=Fy(t.children);return t.type==="bold"?`<strong class="font-bold">${r}</strong>`:t.type==="italic"?`<em class="italic">${r}</em>`:`<u class="underline">${r}</u>`}).join("")}function OF(e){return e?Fy(ed(e)):""}function IF(e,t){return e?t==="markdown-lite"?OF(e):e:""}function Py(e,t){return e.map((r,n)=>{const o=`${t}-${n}`;if(r.type==="text")return r.value?v.createElement(v.Fragment,{key:o},r.value):null;const s=Py(r.children,o);return r.type==="bold"?v.createElement("strong",{key:o,className:"font-bold"},s):r.type==="italic"?v.createElement("em",{key:o,className:"italic"},s):v.createElement("u",{key:o,className:"underline"},s)})}function Oy(e,t){if(!e)return null;if(t!=="markdown-lite")return e;const r=ed(e);return r.length===1&&r[0]?.type==="text"?r[0].value:Py(r,"tl")}const MF="text-label-html prose prose-sm max-w-none [&_p]:m-0 [&_p+p]:mt-2 [&_ul]:my-1 [&_ol]:my-1";function Iy(e,t){if(!e)return null;const{field:r,asDescription:n=!1}=t,o=t.textProps??io(r),s=t.contentLayout??NF(o),i=o.inlineFormat??"none";if(s==="paragraph"){const c=SF(IF(e,i));if(!c)return null;const u=n?H("m-0 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&ba[o.textAlign]):H(Ty(r,o),MF);return v.createElement("div",{className:u,dangerouslySetInnerHTML:{__html:c}})}if(n)return v.createElement("p",{className:H("mt-0.5 text-sm",o.descriptionMuted!==!1?"text-muted-foreground":"text-foreground",o.textAlign&&ba[o.textAlign])},Oy(e,i));const a=FF(r,o);return v.createElement(a,{className:Ty(r,o)},Oy(e,i))}function LF(e){const t=e.labelApiEndpoint?.trim();return!e.labelApiEnabled||!t?null:{labelApiEndpoint:t,labelApiMethod:e.labelApiMethod??"GET",labelApiQueryParams:e.labelApiQueryParams,labelApiHeaders:e.labelApiHeaders,labelApiBodyFields:e.labelApiBodyFields}}async function DF(e,t={}){const{formValues:r={},urlParams:n={},submissionContext:o}=t,s=l=>Lr(l,r,n,o),i=(e.labelApiMethod??"GET").toUpperCase();let a=Mr(s(e.labelApiEndpoint));const c=e.labelApiQueryParams??[];if(c.length){const l=new URLSearchParams;c.forEach(({key:g,value:m})=>{g.trim()&&l.append(g,s(m))});const p=l.toString();p&&(a=`${a}${a.includes("?")?"&":"?"}${p}`)}const u={"Content-Type":"application/json"};(e.labelApiHeaders??[]).forEach(({key:l,value:p})=>{l.trim()&&(u[l]=s(p))});let f;i==="POST"&&(e.labelApiBodyFields??[]).length&&(f={},e.labelApiBodyFields.forEach(({key:l,value:p})=>{l.trim()&&(f[l]=s(p))}));try{return i==="POST"?(await Qt.post(a,f??{},{headers:Object.keys(u).length?u:void 0})).data:(await Qt.get(a,{headers:Object.keys(u).length?u:void 0})).data}catch(l){const p=l,g=p.response?.status,m=typeof p.response?.data=="string"?p.response.data:p.message??"Request failed";throw new Error(g?`HTTP ${g}: ${m}`:String(m))}}const BF=({field:e,className:t,formValues:r,urlParams:n,submissionContext:o,buttonResponses:s,prepopulateResponse:i,prepopulateLoading:a=!1})=>{const c=io(e),u=v.useMemo(()=>LF(io(e)),[e.properties]),[f,l]=v.useState(void 0),[p,g]=v.useState(!1),[m,h]=v.useState(null),y=v.useMemo(()=>u?JSON.stringify({endpoint:u.labelApiEndpoint,method:u.labelApiMethod,query:u.labelApiQueryParams,headers:u.labelApiHeaders,body:u.labelApiBodyFields}):"",[u]),S=v.useCallback(async()=>{if(!u){l(void 0),h(null),g(!1);return}g(!0),h(null);try{const I=await DF(u,{formValues:r??{},urlParams:n??{},submissionContext:o});l(I)}catch(I){l(void 0),h(I instanceof Error?I.message:"Failed to load label API")}finally{g(!1)}},[u,r,n,o]);v.useEffect(()=>{y&&S()},[y,S]);const w=c.textAlign==="center"?"items-center":c.textAlign==="right"?"items-end":c.textAlign==="justify"?"items-stretch":"items-start",A=CF(e),x=EF(e),F=x&&e.label?e.label:"",N=e.description??"",k=TF({bodyTemplate:A,captionTemplate:F,descriptionTemplate:N,prepopulateLoading:a,labelApiConfigPresent:u!=null,labelApiLoading:p,labelApiResponse:f,labelApiError:m}),T={formValues:r??{},urlParams:n??{},submissionContext:o,buttonResponses:s,prepopulateResponse:i,labelApiResponse:f},P=A?Jc(A,T):"",E=x&&e.label?Jc(e.label,T):"",C=N?Jc(N,T):"";return d.jsx("div",{className:H("w-full min-w-0 h-full min-h-[95px] flex flex-col justify-center py-0.5",w,t),children:k?d.jsx("p",{className:"text-sm text-muted-foreground m-0",children:"Loading…"}):d.jsxs(d.Fragment,{children:[m&&u?d.jsx("p",{className:"text-[10px] text-destructive mb-0.5",title:m,children:"Label API failed"}):null,E?d.jsx("div",{className:"text-sm font-medium text-foreground mb-1 w-full",children:E}):null,P?Iy(P,{field:e,textProps:c}):null,C?Iy(C,{field:e,textProps:c,asDescription:!0}):null]})})},td=({legend:e,children:t,className:r,collapsible:n=!1,defaultCollapsed:o=!1,headerActions:s,onCollapsedChange:i})=>{const[a,c]=v.useState(o),u=v.useId(),f=l=>{l.stopPropagation(),n&&c(p=>{const g=!p;return i?.(g),g})};return d.jsxs("fieldset",{className:H("min-w-0 rounded-lg border bg-card p-4",r),"data-form-renderer":"config-section-border",children:[n?d.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2 border-b border-border pb-2",children:[d.jsxs("button",{type:"button",className:H("flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-medium text-foreground","cursor-pointer rounded-sm hover:bg-muted/70 transition-colors focus:outline-none focus:ring-2 focus:ring-ring"),"aria-expanded":!a,"aria-controls":u,onClick:f,children:[d.jsx("span",{className:"shrink-0 text-muted-foreground","aria-hidden":!0,children:a?d.jsx(Uu,{className:"h-4 w-4"}):d.jsx(ts,{className:"h-4 w-4"})}),d.jsx("span",{className:"truncate",children:e})]}),s!=null?d.jsx("div",{className:"shrink-0",children:s}):null]}):d.jsx("legend",{className:"px-1 text-sm font-medium text-foreground",children:e}),!a&&d.jsxs("div",{id:u,className:"space-y-3",children:[!n&&s!=null?d.jsx("div",{className:"flex justify-end",children:s}):null,t]})]})};function My(e){const t=e.properties,r=t?.apiEndpoint?{apiEndpoint:t.apiEndpoint,apiMethod:t.apiMethod,apiKey:t.apiKey,apiRealtime:t.apiRealtime,apiAutoDetect:t.apiAutoDetect,apiLabelField:t.apiLabelField,apiValueField:t.apiValueField,apiQueryParams:t.apiQueryParams,apiClientFilter:t.apiClientFilter,apiHeaders:t.apiHeaders,apiBodyFields:t.apiBodyFields,apiAuth:t.apiAuth,valueSource:t.valueSource,dependentFields:t.dependentFields}:null,n=e.apidata||null;return r||n}function rd(e){const t=My(e),r=e.properties;return!!(t?.apiEndpoint&&(t?.valueSource==="api"||r?.valueSource==="api"))}function Ly({field:e,formValues:t={},submissionContext:r,value:n,onChange:o,clearWhenBlocked:s=!0}){const i=e.properties,a=My(e),c=rd(e),[u,f]=v.useState(!1),[l,p]=v.useState(null),g=v.useRef(null),m=v.useRef(n);m.current=n;const h=v.useMemo(()=>{const F=a?.apiEndpoint||i?.apiEndpoint||"",N=a?.apiQueryParams||i?.apiQueryParams;return po(F,N)},[a?.apiEndpoint,i?.apiEndpoint,a?.apiQueryParams,i?.apiQueryParams]),y=v.useMemo(()=>{const F=new Set;for(const k of i?.dependentFields??a?.dependentFields??[])typeof k=="string"&&k.trim()&&F.add(k.trim());const N=a?.apiClientFilter?.matchField?.trim()||i?.apiClientFilter?.matchField?.trim();return N&&F.add(N),[...F]},[i?.dependentFields,a?.dependentFields,a?.apiClientFilter?.matchField,i?.apiClientFilter?.matchField]),S=v.useMemo(()=>{const F=new Set([...h,...y]);if(F.size===0)return null;const N={};return F.forEach(k=>{N[k]=t[k]}),JSON.stringify(N)},[h,y,t]),w=v.useMemo(()=>JSON.stringify(r||{}),[r]),A=v.useMemo(()=>{const F=new Set;e.name?.trim()&&F.add(e.name.trim());const N=e.key;return typeof N=="string"&&N.trim()&&F.add(N.trim()),[...F]},[e.name,e.key]),x=e.type==="number"?null:"";return v.useEffect(()=>{const F=a?.apiEndpoint;if(!c||!F)return;let N=!1;const k=P=>{if(N)return;const E=m.current;if(P==null||P.trim()===""){s&&E!==x&&E!==void 0&&(g.current=null,o(x));return}if(e.type==="number"){const C=Number(P),I=Number.isFinite(C)?C:null;E!==I&&g.current!==P&&(g.current=P,o(I));return}String(E??"")!==P&&g.current!==P&&(g.current=P,o(P))};return(async()=>{f(!0),p(null);try{const P=a?.apiMethod||i?.apiMethod||"GET",E=a?.apiRealtime||i?.apiRealtime,C=a?.apiQueryParams||i?.apiQueryParams||{},I=Qs({apiEndpoint:F,apiMethod:P,apiQueryParams:C,formValues:t,submissionContext:r,apiRealtime:E,additionalRequiredFieldNames:y,excludeFormFieldNames:A});if(I.blocked){N||(f(!1),s&&k(null));return}const W={"Content-Type":"application/json"},M=a?.apiKey||i?.apiKey;M&&(W["X-CSCAPI-KEY"]=M);const z=e.apidata,V=a?.apiAuth??i?.apiAuth??z?.apiAuth??Hi(a?.apiHeaders??i?.apiHeaders??z?.apiHeaders)??{type:"none"},X=Ri(V,{formValues:t,submissionContext:r,apiRealtime:E});Object.assign(W,X);const L=a?.apiHeaders??i?.apiHeaders??z?.apiHeaders,B=a?.apiBodyFields??i?.apiBodyFields??z?.apiBodyFields,D=Bn(Vi(L),{formValues:t,submissionContext:r,apiRealtime:E});Object.assign(W,D);const K=Bn(B,{formValues:t,submissionContext:r,apiRealtime:E}),ae={method:P.toLowerCase(),url:Mr(I.url),headers:W};(I.postBodyBase!=null||Object.keys(K).length>0)&&(ae.data={...I.postBodyBase??{},...K});const j=await Ct(ae),U=a?.apiLabelField||i?.apiLabelField,le=a?.apiValueField||i?.apiValueField,oe=a?.apiClientFilter||i?.apiClientFilter;let G=ME(j.data,le,U);if(oe?.filterField&&oe?.matchField&&G!=null){const ie=t[oe.matchField];if(ie==null)G=null;else{const Ce=ys(j.data,U,le),ee=Array.isArray(j.data)?j.data:j.data?.data?.data&&Array.isArray(j.data.data.data)?j.data.data.data:j.data?.data&&Array.isArray(j.data.data)?j.data.data:[],ne=Ce.filter(he=>{const Ie=ee.find(re=>String(Ut(re,le||"code"))===String(he.value));if(!Ie)return!1;const Ue=Ut(Ie,oe.filterField);return String(Ue)===String(ie)});G=ne.length>0?ne[0].value:null}}N||k(G)}catch(P){if(N)return;let E="Failed to load value";const C=P;if(C.response){const I=C.response.data;if(C.response.status===404)E="API endpoint not found.";else if(C.response.status===401)E="Authentication failed.";else if(typeof I=="string")E=I;else if(I&&typeof I=="object"){const W=I;E=W.error||W.message||W.detail||E}}else C.message&&(E=String(C.message));p(E)}finally{N||f(!1)}})(),()=>{N=!0}},[c,a?.apiEndpoint,a?.apiMethod,a?.apiValueField,a?.apiLabelField,i?.apiEndpoint,i?.apiMethod,i?.apiValueField,i?.apiLabelField,S,y,A,w,e.type,s,x]),{isLoading:u,error:l}}const $F=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:s,readOnly:i,...a})=>{const{isLoading:c}=Ly({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return d.jsx(ri,{field:e,value:t||"",onChange:r,disabled:s||c,readOnly:i||c,...a})},jF=({field:e,value:t,onChange:r,formValues:n,submissionContext:o,disabled:s,readOnly:i,...a})=>{const{isLoading:c}=Ly({field:e,formValues:n,submissionContext:o,value:t,onChange:r});return d.jsx(dl,{field:e,value:t??null,onChange:r,disabled:s||c,readOnly:i||c,...a})},wn=({field:e,value:t,error:r,onChange:n,onBlur:o,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u={},submissionContext:f,onSubmit:l,onReset:p,onCancel:g,isSubmitting:m,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:S,buttonResponses:w,onButtonApiResponse:A,onValidateForm:x,getValidationErrors:F,allFields:N,onSubmittingChange:k,onAddMore:T,scopedFormValues:P,scopedFieldNameMap:E,excludedOptionValues:C,prepopulateMappedFieldNames:I,fieldValueKey:W,hideTableRowControls:M=!1,urlParams:z={},prepopulateResponse:V=null,prepopulateLoading:X=!1,formSections:L,submitPayload:B})=>{switch(e.type){case"divider":return d.jsx(LT,{field:e,className:c});case"header":return d.jsx(BT,{field:e,className:c});case"sectionHeading":return d.jsx(zT,{field:e,className:c});case"spacer":return d.jsx(UT,{field:e,className:c});case"textLabel":return d.jsx(BF,{field:e,className:c,formValues:u,urlParams:z,submissionContext:f,buttonResponses:w,prepopulateResponse:V??void 0,prepopulateLoading:X});case"status":return d.jsx(NT,{field:e,value:t??null,error:r,disabled:s,isRequired:a,className:c,formValues:u,submissionContext:f,extraSubmitPayload:S,prepopulateResponse:V})}switch(e.type){case"text":case"password":case"url":return e.type==="text"&&rd(e)?d.jsx($F,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f}):d.jsx(ri,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"number":return rd(e)?d.jsx(jF,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f}):d.jsx(dl,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"email":return d.jsx(Ku,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"phone":case"aadhaar":return d.jsx(qu,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"otp":return d.jsx(Wf,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,urlParams:z,submissionContext:{...typeof f=="object"&&f!==null?f:{},...S??{}},prepopulateResponse:V});case"textarea":case"richtext":return d.jsx(Rf,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"select":{const D=W??e.name??e.key??e.id,K=!!(D&&I?.has(D));return d.jsx(Tm,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,formValues:u,submissionContext:f,excludedOptionValues:C,isPrepopulateTarget:K})}case"multiselect":{const D=Array.isArray(t)?t:t!=null&&t!==""?[String(t)]:[];return d.jsx(yh,{field:e,value:D,onChange:K=>n(K),onBlur:o,error:r,disabled:s,isRequired:a,className:c,formValues:u,submissionContext:f,excludedOptionValues:C})}case"asyncsearch":return d.jsx(qm,{field:e,value:t,onChange:D=>n(D),onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f});case"checkbox":case"terms":return d.jsx(bh,{field:e,value:t||!1,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c});case"toggle":return d.jsx(WN,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c});case"radio":case"checkboxgroup":return d.jsx(Wh,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,excludedOptionValues:C});case"selectablelist":{const D=Array.isArray(t)?t:[];return console.log("[SelectableList] FieldRenderer: passing to SelectableListField",{fieldName:e.name,value:D,valueLength:D.length,submissionContextKeys:f?Object.keys(f):[]}),d.jsx(_T,{field:e,value:D,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,submissionContext:f})}case"date":case"time":case"datetime":case"daterange":return d.jsx(Rh,{field:e,value:t||"",onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"file":return d.jsx(hk,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,buttonResponses:w});case"camera":return d.jsx(Hk,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c});case"photoChoice":return d.jsx(Wk,{field:e,value:t??null,onChange:n,onBlur:o,error:r,disabled:s,isRequired:a,className:c,buttonResponses:w});case"signature":return d.jsx(Z_,{field:e,value:t||null,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"rating":return d.jsx(P_,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"slider":return d.jsx(Q_,{field:e,value:t||0,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c});case"table":return d.jsx(eT,{field:e,value:t||[],onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,hideRowControls:M,formValues:u,submissionContext:f});case"billingGrid":return d.jsx(ET,{field:e,value:t||{rows:[]},onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,formValues:u,submissionContext:f});case"button":return d.jsx(S_,{field:e,value:t,onChange:n,onBlur:o,error:r,disabled:s,readOnly:i,isRequired:a,className:c,onSubmit:l,onReset:p,onCancel:g,isSubmitting:m,formValues:u,submissionContext:f,buttonResponses:w,onButtonApiResponse:A,bffSubmitApi:h,onBffSubmitResult:y,extraSubmitPayload:S,onValidateForm:x,getValidationErrors:F,allFields:N,onSubmittingChange:k,scopedFormValues:P,scopedFieldNameMap:E,prepopulateResponse:V,formSections:L,submitPayload:B});case"editButton":return d.jsx(x_,{field:e,disabled:s,readOnly:i,isRequired:a,className:c,buttonResponses:w,onButtonApiResponse:A});case"addmore":return d.jsx(A_,{field:e,error:r,disabled:s,readOnly:i,isRequired:a,className:c,onAddMore:()=>T?.(e)});case"customizeSections":return d.jsx(F_,{field:e,error:r,disabled:s,readOnly:i,isRequired:a,className:c});default:return d.jsx("div",{className:"p-3 border rounded-md bg-muted/50",children:d.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unsupported field type: ",e.type]})})}};function _s(e){if(!e)return e;const t={...e};return e._id&&!e.id&&(t.id=e._id),delete t._id,t.formDefinitionId&&typeof t.formDefinitionId=="object"&&(t.formDefinitionId=t.formDefinitionId._id||t.formDefinitionId.id||t.formDefinitionId),t}function Dy(e){return Array.isArray(e)?e.map(_s):[]}function zF(e){const t=!!e.standalone_form;if(!e.moduleId&&!t)throw new Error(`Form response missing required field: moduleId. Form ID: ${e._id||e.id}. Please ensure the backend returns moduleId when fetching forms.`);if(!e._id&&!e.id)throw new Error("Form response missing required field: id. Please ensure the backend returns _id or id when fetching forms.");let r;e.moduleId&&(typeof e.moduleId=="object"&&e.moduleId._id?r=_s(e.moduleId):r=e.moduleId);const n=e.isDefault??!1;if(!n&&!e.tenantId&&!t)throw new Error(`Form response missing required field: tenantId. Form ID: ${e._id||e.id}. Please ensure the backend returns tenantId when fetching non-default forms.`);return{id:e._id||e.id,name:e.name,description:e.description||"",version:e.version??1,status:e.status||"draft",category:e.category||"",createdAt:e.createdAt||new Date().toISOString(),updatedAt:e.updatedAt||e.createdAt||new Date().toISOString(),createdBy:e.createdBy||"",isActive:e.isActive??!0,isDefault:n,...r!==void 0&&{moduleId:r},tenantId:e.tenantId||void 0,featureId:e.featureId,config:e.config??void 0,standalone_form:t}}class UF{basePath="/api/form-builder/forms";async getForRendering(t,r){if(!nn())throw new Error("Client ID is required");const o=r!==void 0?`${this.basePath}/${t}/render?version=${r}`:`${this.basePath}/${t}/render`,s=await Qt.get(o),i=s.data?.data||s.data,a=i?.BFF_submit_api||i?.bff_submit_api||s.data?.BFF_submit_api||s.data?.bff_submit_api,c=i.form||i,u=!!(c.standalone_form??i.form?.standalone_form);if(!c.moduleId&&!i.form?.moduleId&&!u)throw new Error(`Form response missing required field: moduleId. Form ID: ${t}. Please ensure the backend returns moduleId in the form response.`);if(!(c.isDefault??i.form?.isDefault??!1)&&!c.tenantId&&!i.form?.tenantId&&!u)throw new Error(`Form response missing required field: tenantId. Form ID: ${t}. Please ensure the backend returns tenantId for non-default forms.`);i.form?.moduleId&&!c.moduleId&&(c.moduleId=i.form.moduleId),i.form?.tenantId&&!c.tenantId&&(c.tenantId=i.form.tenantId),i.form?.isDefault!==void 0&&c.isDefault===void 0&&(c.isDefault=i.form.isDefault);const l=zF(c);i.form?.moduleId&&(typeof i.form.moduleId=="object"&&i.form.moduleId._id?l.moduleId=_s(i.form.moduleId):typeof i.form.moduleId=="string"&&(l.moduleId=i.form.moduleId));const p=Dy(i.fields||[]),g=i.layout?_s(i.layout):null,m=Dy(i.rules||[]),h=i.module?_s(i.module):void 0,y=i.clientMapping||i.clientOverrides;return{form:l,fields:p,layout:g,rules:m,module:h,clientMapping:y,clientOverrides:y,BFF_submit_api:a||void 0}}}const VF=new UF,HF={submitAction:"database",autoSave:!0,autoSaveInterval:30,showProgressBar:!0,allowDraft:!0,validateOnChange:!1,validateOnBlur:!0,showFieldErrors:"inline",layout:"default",submitButtonText:"Submit",resetButtonText:"Reset",showReset:!1,successMessage:"Form submitted successfully!",errorMessage:"An error occurred. Please try again."},WF=300;function RF(){return{...HF}}function GF(e){if(!e||typeof e!="object")return;const t=e,r=t.user_type??t.visibleToUserType??"",n=t.user_role??t.visibleToUserRole??"",o=Array.isArray(t.users)?t.users:Array.isArray(t.visibleToUserIds)?t.visibleToUserIds:[];if(!(r!=null&&r!==""||n!=null&&n!==""||o.length>0))return;const i={};return r!=null&&r!==""&&(i.visibleToUserType=r),n!=null&&n!==""&&(i.visibleToUserRole=n),o.length>0&&(i.visibleToUserIds=o),i}function KF(e){const t=RF();if(!e||typeof e!="object")return t;const r=e;return{...t,submitAction:r.submitAction||t.submitAction,apiEndpoint:r.apiEndpoint,dbTable:r.dbTable,emailTo:r.emailTo,workflowTrigger:r.workflowTrigger,workflowSubmissionConfig:r.workflowSubmissionConfig,prepopulateApi:r.prepopulateApi,prepopulateResponseRules:r.prepopulateResponseRules??void 0,sections:g_(r.sections),submitPayload:h_(r.submitPayload),autoSave:r.autoSave,autoSaveInterval:r.autoSaveInterval,showProgressBar:r.showProgressBar,allowDraft:r.allowDraft,validateOnChange:r.validateOnChange,validateOnBlur:r.validateOnBlur,showFieldErrors:r.showFieldErrors,layout:r.layout,submitButtonText:r.submitButtonText,resetButtonText:r.resetButtonText,showReset:r.showReset,successMessage:r.successMessage,successRedirect:r.successRedirect,errorMessage:r.errorMessage}}function Ts(e,t,r,n){const o=t.map(l=>{let p=[],g={};try{l.options&&(p=JSON.parse(l.options)),l.metadata&&(g=JSON.parse(l.metadata))}catch{}const m=bu(l);m&&Object.assign(g,m),p.length>0&&(g.options=p);const h=[];if(l.validationRequired&&h.push({type:"required",message:"This field is required"}),l.validationMinLength!==null&&l.validationMinLength!==void 0&&h.push({type:"minLength",value:l.validationMinLength,message:`Minimum length is ${l.validationMinLength}`}),l.validationMaxLength!==null&&l.validationMaxLength!==void 0&&h.push({type:"maxLength",value:l.validationMaxLength,message:`Maximum length is ${l.validationMaxLength}`}),l.validationPattern&&h.push({type:"pattern",value:l.validationPattern,message:"Invalid format"}),l.validationRules&&typeof l.validationRules=="object"){const j=l.validationRules;if(j.required===!0&&!h.some(U=>U.type==="required")&&h.push({type:"required",message:"This field is required"}),j.allowLetters!==void 0&&h.push({type:"allowLetters",value:j.allowLetters}),j.allowNumbers!==void 0&&h.push({type:"allowNumbers",value:j.allowNumbers}),j.allowSpecialChars!==void 0&&h.push({type:"allowSpecialChars",value:j.allowSpecialChars}),j.minLetters!==void 0&&typeof j.minLetters=="number"&&h.push({type:"minLetters",value:j.minLetters}),j.maxLetters!==void 0&&typeof j.maxLetters=="number"&&h.push({type:"maxLetters",value:j.maxLetters}),j.minNumbers!==void 0&&typeof j.minNumbers=="number"&&h.push({type:"minNumbers",value:j.minNumbers}),j.maxNumbers!==void 0&&typeof j.maxNumbers=="number"&&h.push({type:"maxNumbers",value:j.maxNumbers}),j.minSpecialChars!==void 0&&typeof j.minSpecialChars=="number"&&h.push({type:"minSpecialChars",value:j.minSpecialChars}),j.maxSpecialChars!==void 0&&typeof j.maxSpecialChars=="number"&&h.push({type:"maxSpecialChars",value:j.maxSpecialChars}),j.fileSize!==void 0&&typeof j.fileSize=="number"){const U=j.fileSize/1048576;h.push({type:"fileSize",value:j.fileSize,message:`File size must be less than ${U.toFixed(2)} MB`})}if(j.fileType!==void 0){const U=Array.isArray(j.fileType)?j.fileType:typeof j.fileType=="string"?j.fileType.split(",").map(le=>le.trim()).filter(Boolean):[];U.length>0&&h.push({type:"fileType",value:U,message:"File type is not allowed"})}}const y=[],S=new Set;n.filter(j=>{const U=typeof j.targetFieldId=="object"?j.targetFieldId.id||j.targetFieldId._id:j.targetFieldId;return!!(U===l.id||U===l._id||U&&l.fieldKey&&U===l.fieldKey)}).forEach(j=>{try{const U=JSON.parse(j.conditionExpression);!U.id&&j.id&&(U.id=j.id);const le=typeof j.targetFieldId=="object"?j.targetFieldId?.id||j.targetFieldId?._id:j.targetFieldId;U.action&&(!U.then||!Array.isArray(U.then)||U.then.length===0)&&(U.then=[{action:U.action,...le&&{target:le}}]),(!U.then||!Array.isArray(U.then)||U.then.length===0)&&j.action&&(U.then=[{action:j.action,...le&&{target:le}}]),U.then&&Array.isArray(U.then)&&le&&(U.then=U.then.map(G=>!G.target&&le?{...G,target:le}:G));const oe=j.conditionExpression||JSON.stringify(U);if(S.has(oe))return;S.add(oe),y.push(U)}catch{}});const A=l.disabled===!0||g?.disabled===!0||!1;let x=l.readOnly===!0||g?.readOnly===!0||!1;const F=l.hidden===!0||g?.hidden===!0||!1;(g?.valueSource==="calculated"||g?.formula)&&(x=!0);const{disabled:N,readOnly:k,hidden:T,...P}=g,E={};P.hideLabel!==void 0&&(E.hideLabel=P.hideLabel),P.labelPosition!==void 0&&(E.labelPlacement=P.labelPosition),P.size!==void 0&&(E.size=P.size),P.customClass!==void 0&&(E.className=P.customClass);const{labelPosition:C,size:I,customClass:W,visibility:M,...z}=P,V=Object.keys(z).length>0?z:void 0,X=Object.keys(E).length>0?E:void 0,L=l.visibility??g?.visibility??M;let B=GF(L);if(L&&!B){const j=L;(j.visibleToUserType!=null||j.visibleToUserRole!=null||Array.isArray(j.visibleToUserTypes)&&j.visibleToUserTypes.length>0||Array.isArray(j.visibleToUserRoles)&&j.visibleToUserRoles.length>0||Array.isArray(j.visibleToUserIds)&&j.visibleToUserIds.length>0||Array.isArray(j.hiddenFromUserIds)&&j.hiddenFromUserIds.length>0)&&(B={visibleToUserType:j.visibleToUserType??(Array.isArray(j.visibleToUserTypes)?j.visibleToUserTypes[0]:void 0),visibleToUserRole:j.visibleToUserRole??(Array.isArray(j.visibleToUserRoles)?j.visibleToUserRoles[0]:void 0),visibleToUserIds:j.visibleToUserIds,hiddenFromUserIds:j.hiddenFromUserIds})}const D=g?.columnName,ae=!!l.parentFieldId&&typeof D=="string"?D:l.fieldKey;return{id:l.id,type:l.fieldType,name:ae,label:l.label,description:l.helpText||void 0,placeholder:l.placeholder||void 0,defaultValue:l.defaultValue||void 0,position:{order:typeof l.positionOrder=="number"?l.positionOrder:l.positionRow??0,column:typeof l.positionColumn=="number"?l.positionColumn:1,columnSpan:typeof l.positionWidth=="number"?l.positionWidth:1},parentId:void 0,appearance:X,validation:h.length>0?h:void 0,conditions:y.length>0?y:void 0,properties:V,visibility:B&&(B.visibleToUserType!=null||B.visibleToUserRole!=null||Array.isArray(B.visibleToUserIds)&&B.visibleToUserIds.length>0||Array.isArray(B.hiddenFromUserIds)&&B.hiddenFromUserIds.length>0)?B:void 0,disabled:A,readOnly:x,hidden:F}});o.forEach((l,p)=>{if(l.visibility){const g=t[p];console.log("[backendToFormSchema] field with visibility",{fieldKey:g?.fieldKey??l.name,name:l.name,type:l.type,parentFieldId:g?.parentFieldId,visibility:l.visibility})}});const s=t;for(let l=0;l<o.length;l++){const p=s[l]?.parentFieldId;if(p){const g=o.find(h=>h.id===p||h.type==="table"&&h.name===p||h.type==="table"&&s[l].fieldKey?.startsWith?.(h.name+"_column_")),m=o[l];if(g&&g.type==="table"&&m){const h=g.properties||{};Array.isArray(h.columns)||(h.columns=[]),h.columns.push(m),g.properties=h}}}const i=o.filter((l,p)=>!s[p]?.parentFieldId);for(const l of i)if(l.type==="table"&&l.properties&&Array.isArray(l.properties.columns)){const p=l.properties.columns;for(const g of p){const m=g.properties?.columnName;typeof m=="string"&&(g.name=m)}p.sort((g,m)=>(g.position?.order??0)-(m.position?.order??0)||(g.position?.column??0)-(m.position?.column??0))}let a;const c=e.config;if(console.log("[Prepopulate] backendToFormSchema config",{formId:e.id,hasRawConfig:c!=null,rawConfigType:typeof c,rawConfigPreview:c!=null?typeof c=="string"?c.slice(0,300):JSON.stringify(c).slice(0,300):null}),c!=null)try{const l=typeof c=="string"?JSON.parse(c):c;l&&typeof l=="object"?a=KF(l):a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"}}catch{a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"}}else a={submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};const u=zs(r);u&&(a={...a,grid:u});const f=typeof e.moduleId=="string"?e.moduleId:e.moduleId?.id;return{id:e.id,name:e.name,description:e.description,version:e.version,status:e.status,config:a,fields:i,createdAt:e.createdAt,updatedAt:e.updatedAt,createdBy:e.createdBy,category:e.category,...f?{moduleId:f}:{},standalone_form:e.standalone_form,tenantId:e.tenantId,featureId:e.featureId,isDefault:e.isDefault}}const qF=new Set(["PENDING_PAYMENT","PAYMENT_PENDING","AWAITING_PAYMENT","PAID","PAYMENT_COMPLETED","PAYMENT_FAILED","REFUNDED","AUTHORIZED","CAPTURED","PARTIALLY_PAID"].map(e=>e.toUpperCase()));function nd(e){return typeof e=="string"&&e.trim()!==""}function od(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;const t=e;if(t.payment_type!=null&&t.payment_type!==""||t.payment_mode!=null&&t.payment_mode!==""||t.transaction_id!=null&&String(t.transaction_id).trim()!==""||t.payment_status!=null&&String(t.payment_status).trim()!==""||typeof t.amount=="number"||nd(t.amount)||typeof t.total_amount=="number"||nd(t.total_amount)||nd(t.currency)||t.gateway!=null&&String(t.gateway).trim()!==""||t.razorpay_order_id!=null&&String(t.razorpay_order_id).trim()!==""||t.stripe_payment_intent!=null&&String(t.stripe_payment_intent).trim()!=="")return!0;const r=t.status;return!!(typeof r=="string"&&qF.has(r.trim().toUpperCase()))}function YF(e){const t=Ge(e,"data.items");if(!Array.isArray(t)||t.length===0)return;const r=t[0];if(r==null||typeof r!="object")return;const n=r;if(!(n.id===void 0||n.id===null||n.id===""))return{item:n,id:n.id}}function XF(e,t){const r=YF(e);if(!r)return;const n=Ge(e,"data"),o=n!=null&&typeof n=="object"&&!Array.isArray(n)?n:void 0;if(t?.treatFirstItemIdAsPaymentId===!0||od(r.item)||o!=null&&od(o))return r.id}function JF(e){const t=e.properties,r=e.metadata;return[t?.uploadApiEndpoint,t?.apiEndpoint,r?.uploadApiEndpoint,r?.apiEndpoint].filter(o=>typeof o=="string"&&o.length>0)}function QF(e){return JF(e).some(t=>t.toLowerCase().includes("payment"))}function ZF(e){const t=e.properties,r=e.metadata;return!!(t?.mergeSuccessDataIdAsPaymentId||r?.mergeSuccessDataIdAsPaymentId)}function eP(e,t){if(t?.type!=="button"||!Qo(e))return;const r=Ge(e,"data.id");if(r==null||String(r).trim()==="")return;const n=Ge(e,"data");if(ZF(t)||n!=null&&typeof n=="object"&&!Array.isArray(n)&&od(n)||QF(t))return r}const tP=new Set(["section","group","columns","divider","header","sectionHeading","spacer","addmore","textLabel","customizeSections"]);function rP(e,t){if(!e.length||!t?.length)return[];const r=new Map(t.map(o=>[o.id,o])),n=[];for(const o of e){const s=r.get(o);if(s?.fieldNames?.length)for(const i of s.fieldNames)i&&!n.includes(i)&&n.push(i)}return n}function nP(e,t){const r=e.properties,n=Array.isArray(r?.linkedFieldNames)?r.linkedFieldNames:[],o=rP(Array.isArray(r?.linkedSectionIds)?r.linkedSectionIds:[],t),s=new Set,i=[];for(const a of[...n,...o])!a||s.has(a)||(s.add(a),i.push(a));return i}function By(e,t){const r=e.properties,n=Array.isArray(r?.linkedSectionIds)?r.linkedSectionIds:[];if(!n.length||!t?.length)return[];const o=new Map(t.map(s=>[s.id,s]));return n.map(s=>o.get(s)).filter(s=>!!s)}function oP(e,t){return By(e,t).find(r=>r.heading?.enabled)}function $y(e,t){const r=e.template??"";return(e.mode??"increment")==="fixed"?r:r.replace(/\{n\}/g,String(t+1))}function jy(e,t,r,n){const o=nP(e,r);if(o.length===0)return[];const s=new Set(o);return t.filter(i=>{const a=n(i);return!a||i.id===e.id||tP.has(i.type)?!1:s.has(a)})}function sP(e,t,r){if(e.type!=="sectionHeading"||!t?.length)return;const n=r(e);if(n)for(const o of t){const s=o.heading;if(s?.enabled&&s.headingFieldName===n)return s}}function sd(e){return[...e].sort((t,r)=>{const n=t.position?.order??0,o=r.position?.order??0;if(n!==o)return n-o;const s=t.position?.column??1,i=r.position?.column??1;return s-i})}function iP(e,t,r){if(!e?.length)return[];const n=e.filter(i=>i.showBorder===!0);if(n.length===0)return[];const o=new Map;for(const i of t){const a=r(i);a&&o.set(a,i)}const s=[];for(const i of n){const a=i.fieldNames.map(u=>o.get(u)).filter(u=>!!u);if(a.length===0)continue;const c=sd(a).map(u=>r(u)).filter(Boolean);s.push({section:i,fieldNames:c})}return s}function Fs(e,t=0){return e.heading?.enabled?$y(e.heading,t):e.name}function zy(e,t,r){if(e.type!=="sectionHeading")return!1;const n=t.heading;return!n?.enabled||!n.headingFieldName?!1:r(e)===n.headingFieldName}function aP(e,t){const r=typeof e.position?.order=="number"?e.position.order:0,n=(e.position?.column??1)-1,o=qo(e),s=Xd(e,t);return{row:r,col:n,rowEnd:r+o-1,colEnd:n+s-1}}function id(e,t){let r=1/0,n=-1/0,o=1/0,s=-1/0;for(const i of e){const{row:a,col:c,rowEnd:u,colEnd:f}=aP(i,t);r=Math.min(r,a),n=Math.max(n,u),o=Math.min(o,c),s=Math.max(s,f)}return Number.isFinite(r)?{minRow:r,maxRow:n,minCol:o,maxCol:s,rowSpan:n-r+1,colSpan:s-o+1}:null}function lP(e,t,r,n){const o=e.map(f=>t.find(l=>n(l)===f)).filter(f=>!!f&&typeof f.position?.order=="number");if(o.length===0)return null;const s=id(o,r);if(!s)return null;const i=o.filter(f=>f.type!=="sectionHeading"),a=i.length>0?i:o,c=Math.min(...a.map(f=>f.position?.order??0)),u=Math.max(1,...a.map(f=>(f.position?.order??c)-c+qo(f)));return{minRow:s.minRow,maxRow:s.maxRow,minCol:s.minCol,maxCol:s.maxCol,blockHeight:u}}function cP(e,t){return e.maxRow+1+t*e.blockHeight}function dP(e,t,r,n){const o=new Map;for(const a of t){const c=r(a);c&&o.set(c,a)}const s=new Map,i=new Set;for(const a of e){const c=a.fieldNames.map(w=>o.get(w)).filter(w=>!!w);if(c.length===0)continue;const u=c.filter(w=>!zy(w,a.section,r)),f=id(c,n);if(!f)continue;const{minRow:l,minCol:p,rowSpan:g,colSpan:m}=f,h=`${l}-${p}`;if(s.has(h))continue;const y=new Set;let S=!1;for(let w=l;w<=l+g-1;w++){for(let A=p;A<=p+m-1;A++){const x=`${w}-${A}`;if(i.has(x)){S=!0;break}y.add(x)}if(S)break}if(!S){for(const w of y)i.add(w);s.set(h,{anchorRow:l,anchorCol:p,rowSpan:g,colSpan:m,run:a,legend:Fs(a.section,0),renderFields:u.length>0?u:c})}}return{anchorsByOrigin:s,coveredCells:i}}function uP(e,t,r,n,o,s,i){const a=new Set(i),c=new Map;for(const u of e){const f=Uy(u.linkedFields.map(p=>s(p)).filter(Boolean),t),l=f?.section;l?.fieldNames?.length?l.fieldNames:u.templateFieldNames,u.blockIds.forEach((p,g)=>{const m=r.filter(k=>k.id.endsWith(`__${p}`));if(m.length===0||!f)return;const h=id(m,o);if(!h)return;const{minRow:y,minCol:S,rowSpan:w,colSpan:A}=h,x=`${y}-${S}`;for(let k=y;k<=y+w-1;k++)for(let T=S;T<=S+A-1;T++)a.add(`${k}-${T}`);const F=f,N=Fs(l,g+1);c.set(x,{anchorRow:y,anchorCol:S,rowSpan:w,colSpan:A,run:F,legend:N,renderFields:sd(m),addMoreMeta:{addMoreFieldName:u.addMoreFieldName,blockId:p,blockIndex:g}})})}return{anchorsByOrigin:c,coveredCells:a}}function fP(e,t,r,n){const o=`${e}-${t}`;return r.has(o)?!n.get(o):!1}function pP(e,t,r){for(const n of r.values())if(e>=n.anchorRow&&e<n.anchorRow+n.rowSpan&&t>=n.anchorCol&&t<n.anchorCol+n.colSpan)return n}function mP(e,t,r,n){return!(!n||r.run.section.collapsible!==!0||e===r.anchorRow&&t===r.anchorCol)}function hP(e,t,r){const n=new Set;for(const o of e.values())if(t(o))for(let s=o.anchorRow+1;s<o.anchorRow+o.rowSpan;s++)r(s,o)||n.add(s);return n}function gP(e,t,r){const n=o=>r.has(o)?"minmax(0, auto)":`minmax(${t}, auto)`;return Array.from({length:e},(o,s)=>n(s)).join(" ")}function yP(e,t){return new Map([...e,...t])}function bP(e,t,r){if(t.length===0)return e.map(i=>({kind:"field",field:i}));const n=new Map;for(const i of t)for(const a of i.fieldNames)n.set(a,i);const o=[];let s=0;for(;s<e.length;){const i=e[s],a=r(i),c=a?n.get(a):void 0;if(!c){o.push({kind:"field",field:i}),s+=1;continue}const u=[],f=new Set(c.fieldNames);for(;s<e.length;){const p=r(e[s]);if(!p||!f.has(p))break;const g=e[s];zy(g,c.section,r)||u.push(g),s+=1}if(u.length===0)continue;const l=o[o.length-1];l?.kind==="border"&&l.run.section.id===c.section.id?l.fields.push(...u):o.push({kind:"border",run:c,fields:u})}return o}function Uy(e,t){if(!t?.length)return;const r=new Set(e);for(const n of t){if(n.showBorder!==!0)continue;const o=n.fieldNames.filter(s=>r.has(s));if(o.length>0)return{section:n,fieldNames:o}}}const vP=({steps:e,currentStep:t,completedSteps:r,onStepClick:n,className:o})=>d.jsx("div",{className:H("mb-8",o),children:d.jsx("nav",{"aria-label":"Progress",children:d.jsx("ol",{className:"flex items-center",children:e.map((s,i)=>{const a=r.has(i),c=t===i,u=n&&(a||i===t+1||i<=t);return d.jsxs("li",{className:H("relative",i!==e.length-1&&"pr-8 sm:pr-20 flex-1"),children:[i!==e.length-1&&d.jsx("div",{className:H("absolute top-4 left-8 -right-8 sm:left-12 sm:-right-12 h-0.5",a?"bg-primary":"bg-border"),"aria-hidden":"true"}),d.jsx("button",{type:"button",onClick:()=>u&&n?.(i),disabled:!u,className:H("relative flex h-8 w-8 items-center justify-center rounded-full text-sm font-medium","transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",a&&"bg-primary text-primary-foreground",c&&!a&&"border-2 border-primary text-primary",!a&&!c&&"border-2 border-border text-muted-foreground",u&&"cursor-pointer hover:bg-primary/10",!u&&"cursor-default"),"aria-current":c?"step":void 0,children:a?d.jsx(oi,{className:"h-4 w-4"}):d.jsx("span",{children:i+1})}),d.jsxs("div",{className:"mt-2",children:[d.jsx("span",{className:H("text-sm font-medium",c&&"text-primary",!c&&!a&&"text-muted-foreground"),children:s.name}),s.description&&d.jsx("p",{className:"text-xs text-muted-foreground hidden sm:block",children:s.description})]})]},s.id)})})})}),wP=2*6e4,Vy=50;class SP{map=new Map;ttlMs;constructor(t){this.ttlMs=t}get(t){const r=this.map.get(t);if(!r)return null;const o=Date.now()-r.storedAtMs>this.ttlMs;return{value:r.value,isStale:o}}set(t,r){this.map.set(t,{value:r,storedAtMs:Date.now()}),this.enforceMax()}delete(t){this.map.delete(t)}clear(){this.map.clear()}enforceMax(){if(this.map.size<=Vy)return;const t=Array.from(this.map.entries());t.sort((n,o)=>n[1].storedAtMs-o[1].storedAtMs),t.slice(0,Math.max(0,this.map.size-Vy)).forEach(([n])=>this.map.delete(n))}}function xP(e){return(e??"").trim()||"default"}function Hy(e){const t=xP(e.scope),r=String(e.formId??"").trim(),n=e.version===void 0||e.version===null?"latest":String(e.version).trim();return`form-render:${t}:${r}:${n}`}const Wy=new SP(wP);function Ry(e){const t=Hy(e),r=Wy.get(t);return r?{value:r.value,isStale:r.isStale}:null}function Gy(e,t){const r=Hy(e);Wy.set(r,t)}function Ky(e){const t={};for(const[n,o]of Object.entries(e)){if(o==null){t[n]=o;continue}if(Array.isArray(o)){t[n]=o;continue}if(typeof o=="object"&&!(o instanceof Date)){const s=o;typeof s.name=="string"&&typeof s.code=="string"?t[n]=`${s.code} ${s.name}`.trim():typeof s.name=="string"?t[n]=s.name:typeof s.code=="string"?t[n]=s.code:typeof s.short_code=="string"?t[n]=s.short_code:t[n]=s.name??s.code??"";continue}t[n]=o}const r=t.time_slot??e.time_slot;return typeof r=="string"&&r.includes(" - ")&&(t.start=r.split(" - ")[0].trim()),t}const Ps=({schema:e,formId:t,initialValues:r,onSubmit:n,onChange:o,onValidationError:s,onClose:i,mode:a="fill",className:c,children:u,gridLayout:f,unstyled:l=!1,submissionContext:p,onWorkflowSubmitResult:g,initialExtraSubmitPayload:m,onExtraSubmitPayloadChange:h,workflowStepId:y,initialStepIndex:S,viewerContext:w,getViewerContext:A,hideTableRowControls:x=!1,themeVars:F,dark:N=!1,omitRootWrapper:k=!1,moduleId:T,workflowModalHandlers:P,getAuthHeaders:E})=>{const C=Qn(_=>_.viewerContext),I=v.useMemo(()=>{if(w!==void 0)return w;const _=A?.();return _!==void 0?_:C},[w,A,C]),[W,M]=v.useState(e||null),[z,V]=v.useState(!!t&&!e),[X,L]=v.useState(null),B=e?.BFF_submit_api??X,[D,K]=v.useState(!1),[ae,j]=v.useState({}),[U,le]=v.useState({}),[oe,G]=v.useState({}),[ie,Ce]=v.useState({}),[ee,ne]=v.useState({}),[he,Ie]=v.useState(null),Ue=Ba.useParams(),re=Or(_=>_.setValues),ge=Or(_=>_.setSubmitting),Se=Or(_=>_.formDisabled),pt=Or(_=>_.visibleFields),Dt=Or(_=>_.requiredFields),Bt=Or(_=>_.updateVisibility),Pt=Or(_=>_.updateRequired),Ar=Or(_=>_.setFieldError),Nt=Zs(),Cr=v.useRef(!1),Xe=v.useRef(void 0),ve=v.useMemo(()=>{if(!e)return null;const _=e;if(_.form&&Array.isArray(_.form.fields))try{return Ts(_.form,_.form.fields,_.form.layout||null,_.form.rules||[])}catch{return e}if(Array.isArray(_.fields)&&_.fields.some(R=>typeof R.metadata=="string"&&R.metadata.startsWith("{")||R.fieldType&&!R.type))try{const R={id:_.id||_._id||"temp",name:_.name||"Form",version:_.version??1,status:_.status||"draft",createdAt:_.createdAt||new Date().toISOString(),updatedAt:_.updatedAt||new Date().toISOString(),createdBy:_.createdBy||"system",category:_.category||"",moduleId:_.moduleId,tenantId:_.tenantId,featureId:_.featureId,isDefault:_.isDefault||!1};return Ts(R,_.fields,_.layout||null,_.rules||[])}catch{return e}return e},[e]);v.useEffect(()=>{if(e){const _=e;_.BFF_submit_api&&L(_.BFF_submit_api)}},[e]);const ce=v.useMemo(()=>{const _=ve||W,q=_?da(_):null;if(!q)return null;const R=q.layout,Z=q.rules,Q=q.clientMapping,de=(Array.isArray(q.fields)?q.fields:[]).map(Be=>{let Ve={...Be};if(Be.validationRules&&typeof Be.validationRules=="object"&&!Be.validation){const pe=Be.validationRules,Oe=[];pe.required===!0&&Oe.push({type:"required",message:"This field is required"}),pe.minLength!==void 0&&typeof pe.minLength=="number"&&Oe.push({type:"minLength",value:pe.minLength,message:`Minimum length is ${pe.minLength}`}),pe.maxLength!==void 0&&typeof pe.maxLength=="number"&&Oe.push({type:"maxLength",value:pe.maxLength,message:`Maximum length is ${pe.maxLength}`}),pe.pattern&&typeof pe.pattern=="string"&&Oe.push({type:"pattern",value:pe.pattern,message:"Invalid format"}),pe.allowLetters!==void 0&&Oe.push({type:"allowLetters",value:pe.allowLetters}),pe.allowNumbers!==void 0&&Oe.push({type:"allowNumbers",value:pe.allowNumbers}),pe.allowSpecialChars!==void 0&&Oe.push({type:"allowSpecialChars",value:pe.allowSpecialChars}),Oe.length>0&&(Ve={...Ve,validation:Oe})}const Ne=Be.required===!0||Be.isRequired===!0,ke=Array.isArray(Ve.validation)&&Ve.validation.some(pe=>pe.type==="required");if(Ne&&!ke){const pe={type:"required",message:"This field is required"},Oe=Array.isArray(Ve.validation)?Ve.validation:[];Ve={...Ve,validation:[...Oe,pe]}}if(Be.apidata&&typeof Be.apidata=="object"){const pe=Be.apidata,Oe=Ve.properties||{},Ae=(Ve.type||Be.fieldType)==="status";if(!Oe.apiEndpoint&&pe.apiEndpoint){const lt={...Oe,apiEndpoint:pe.apiEndpoint,apiMethod:pe.apiMethod,apiKey:pe.apiKey,apiRealtime:pe.apiRealtime,apiAutoDetect:pe.apiAutoDetect,apiLabelField:pe.apiLabelField,apiValueField:pe.apiValueField,apiQueryParams:pe.apiQueryParams,apiClientFilter:pe.apiClientFilter,apiHeaders:pe.apiHeaders,apiBodyFields:pe.apiBodyFields,apiAuth:pe.apiAuth,valueSource:pe.valueSource||(pe.apiEndpoint?"api":void 0),optionsSource:pe.optionsSource||(pe.apiEndpoint?"api":void 0),dependentFields:pe.dependentFields,apiResponsePath:pe.apiResponsePath};Ae&&(lt.source=Oe.source??"api",Oe.statuses!==void 0&&(lt.statuses=Oe.statuses),Oe.dataPath!==void 0&&(lt.dataPath=Oe.dataPath),Oe.showStatusText!==void 0&&(lt.showStatusText=Oe.showStatusText),Oe.statusTextPath!==void 0&&(lt.statusTextPath=Oe.statusTextPath),Oe.showCurrentIndicator!==void 0&&(lt.showCurrentIndicator=Oe.showCurrentIndicator)),Ve={...Ve,properties:lt}}}const ze=["select","multiselect","radio","checkboxgroup"],tt=Ve.type||Be.fieldType;if(ze.includes(tt)){const pe=Be.options,Oe=Ve.properties?.options,Ae=Array.isArray(Oe)&&Oe.length>0;if(Array.isArray(pe)&&pe.length>0&&!Ae){const lt=Ve.properties||{};Ve={...Ve,properties:{...lt,options:pe}}}}return Ve}),ye=q.config?.rules,Ee=Z&&Array.isArray(Z)?Z:ye&&Array.isArray(ye)?ye:[],He=Ee.length>0?de.map(Be=>{if((Be.conditions&&Array.isArray(Be.conditions)?Be.conditions:[]).length>0)return Be;const Ne=Be.id??Be._id,ke=Be.name||Be.key,ze=Ee.filter(Oe=>{const Ae=typeof Oe.targetFieldId=="object"?Oe.targetFieldId?.id??Oe.targetFieldId?._id:Oe.targetFieldId;return Ae?Ae===Ne||Ae===ke||Ae===Be.fieldKey:!1});if(ze.length===0)return Be;const tt=[],pe=new Set;return ze.forEach(Oe=>{try{const Ae=typeof Oe.conditionExpression=="string"?JSON.parse(Oe.conditionExpression):Oe.conditionExpression;if(!Ae||typeof Ae!="object")return;!Ae.id&&Oe.id&&(Ae.id=Oe.id);const lt=typeof Oe.targetFieldId=="object"?Oe.targetFieldId?.id??Oe.targetFieldId?._id:Oe.targetFieldId;Ae.action&&(!Ae.then||!Array.isArray(Ae.then)||Ae.then.length===0)&&(Ae.then=[{action:Ae.action,...lt&&{target:lt}}]),(!Ae.then||!Array.isArray(Ae.then)||Ae.then.length===0)&&Oe.action&&(Ae.then=[{action:Oe.action,...lt&&{target:lt}}]),Ae.then&&Array.isArray(Ae.then)&<&&(Ae.then=Ae.then.map(zt=>!zt.target&<?{...zt,target:lt}:zt));const Gt=Oe.conditionExpression??JSON.stringify(Ae);if(pe.has(Gt))return;pe.add(Gt),tt.push(Ae)}catch{}}),tt.length===0?Be:{...Be,conditions:tt}}):de;let Je=q.config||{submitAction:"database",layout:"default",autoSave:!0,validateOnChange:!0,showFieldErrors:"inline"};return!Je.layout&&R?typeof R=="object"&&R!==null?Je.layout="default":typeof R=="string"&&["default","card","compact"].includes(R)?Je.layout=R:Je.layout="default":Je.layout||(Je.layout="default"),Z&&!Je.rules&&(Je.rules=Z),Q&&!Je.clientMapping&&(Je.clientMapping=Q),{...q,fields:He,config:Je}},[ve,W]);v.useEffect(()=>{ve&&ve!==W&&M(ve)},[ve]),v.useEffect(()=>{if(t&&!e){const _=(nn()??"").trim()||"default",q=Ry({scope:_,formId:t,version:"latest"});q?.value?.schema?(M(q.value.schema),q.value.bffSubmitApi&&L(q.value.bffSubmitApi),V(!1),q.isStale&&J({background:!0})):J({background:!1})}},[t,e]);const J=async({background:_})=>{if(!t)return;const q=t;_||V(!0);try{const R=await VF.getForRendering(t),Z=Ts(R.form,R.fields,R.layout,R.rules);if(q!==t)return;M(Z),R.BFF_submit_api&&L(R.BFF_submit_api);const Q=(nn()??"").trim()||"default";Gy({scope:Q,formId:q,version:"latest"},{schema:Z,bffSubmitApi:R.BFF_submit_api})}catch{}finally{_||V(!1)}};if(z)return d.jsx("div",{className:"flex items-center justify-center py-12",children:d.jsx(vn,{})});if(!ce)return d.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Form not found"});const $=ce,fe=v.useMemo(()=>new Set(Object.keys($.config?.prepopulateApi?.fieldMapping??{})),[$.config?.prepopulateApi?.fieldMapping]),it=v.useCallback(async _=>{const q=$?.fields?.length?Tc(_,$.fields):_,R=Og(q,$.config?.sections,$.config?.submitPayload);if(n){const Z=p?{...R,...p}:R;return n(Z)}return{success:!0}},[n,p,$?.fields,$.config?.sections,$.config?.submitPayload]),{values:Te,errors:Ye,touched:Me,isSubmitting:xe,isValid:et,submitCount:We,totalSteps:dt,currentStepFields:bt,isLastStep:ir,setFieldValue:xt,setFieldTouched:$e,handleSubmit:gt,validateForm:vt,resetForm:kt,nextStep:nr,goToStep:yr,currentStep:Er,completedSteps:Ot,loadDraft:Nr}=xu({schema:$,initialValues:r,onSubmit:it,onChange:o,workflowStepId:y,initialStepIndex:S}),{isFieldEnabled:ar,isFieldRequired:Sn,isFieldVisible:un}=Ow({fields:$.fields,values:Te,buttonResponses:U,prepopulateResponse:he,prepopulateResponseRules:$.config?.prepopulateResponseRules}),jr=un,zn=Or(_=>_.readOnlyFields),$t=Or(_=>_.editableFields),Ht=v.useCallback(_=>zn.has(_),[zn]),br=v.useCallback(_=>$t.has(_),[$t]);v.useEffect(()=>{$.config?.allowDraft&&a==="fill"&&Nr()},[$.id]),v.useEffect(()=>{Xe.current=$.id,Cr.current=!1,j({}),G({}),Ce({}),ne({}),Ie(null)},[$.id]),v.useEffect(()=>{const _=$.config?.prepopulateApi,q=!!(_?.fieldMapping&&Object.keys(_?.fieldMapping??{}).length>0),R=($.config?.prepopulateResponseRules?.length??0)>0;if(!_?.enabled||!_.apiEndpoint?.trim()||!q&&!R||Cr.current)return;Cr.current=!0;const Z=$.id;Xe.current=$.id;let Q=!1;return K(!0),(async()=>{try{const de=Nt.getState().values,ye=typeof p=="object"&&p!==null?{...p,...m||{}}:m||{},Ee=se=>Lr(se,de,Ue,ye);let He=Mr(Ee(_.apiEndpoint));if(_.apiQueryParams?.length){const se=new URLSearchParams;_.apiQueryParams.forEach(({key:Le,value:be})=>se.append(Le,Ee(be))),He=`${He}${He.includes("?")?"&":"?"}${se.toString()}`}const Je={};_.apiHeaders?.forEach(({key:se,value:Le})=>{se.trim()&&(Je[se]=Ee(Le))}),Je["Content-Type"]=Je["Content-Type"]??"application/json";let Rt;if(_.apiMethod==="POST"&&_.apiBodyFields?.length){const se={};_.apiBodyFields.forEach(({key:Le,value:be})=>{Le.trim()&&(se[Le]=Ee(be))}),Rt=JSON.stringify(se)}const Be=await fetch(He,{method:_.apiMethod,headers:Je,body:_.apiMethod==="POST"?Rt:void 0});if(!Be.ok){const se=await Be.text();throw new Error(se||`HTTP ${Be.status}`)}const Ve=await Be.json(),Ne=se=>{try{return se.split("?")[0].split("/").filter(Boolean).pop()||se}catch{return se}},ke=(se,Le)=>{if(se==null)return null;const be=typeof se=="string"?se:se instanceof Date?se.toISOString():null;if(!be)return null;const Ke=typeof se=="object"&&se instanceof Date?se:new Date(be);if(Number.isNaN(Ke.getTime()))return null;const ut=mt=>String(mt).padStart(2,"0");if(Le==="date")return be.length>=10&&be[4]==="-"&&be[7]==="-"?be.slice(0,10):Ke.toISOString().slice(0,10);if(Le==="time")return`${ut(Ke.getHours())}:${ut(Ke.getMinutes())}:${ut(Ke.getSeconds())}`;if(Le==="datetime"){const mt=Ke.getFullYear(),Ze=Ke.getMonth()+1,me=Ke.getDate(),ht=Ke.getHours(),Re=Ke.getMinutes(),Tt=Ke.getSeconds();return`${mt}-${ut(Ze)}-${ut(me)}T${ut(ht)}:${ut(Re)}:${ut(Tt)}`}return null},ze=(se,Le)=>{const be=$.fields.find(me=>me.name===se||me.key===se);if(!be)return Le;if((be.type==="file"||be.type==="camera"||be.type==="photoChoice")&&typeof Le=="string"&&Le.startsWith("http"))return{url:Le,name:Ne(Le)};if(be.type==="date"||be.type==="datetime"||be.type==="time"){const me=ke(Le,be.type);if(me!==null)return me}if(be.type==="multiselect")return Array.isArray(Le)?Le.map(me=>typeof me=="string"?me:String(me)):typeof Le=="string"?Le.trim()===""?[]:Le.includes(",")?Le.split(",").map(me=>me.trim()).filter(Boolean):[Le]:Le!=null&&Le!==""?[String(Le)]:[];if(be.type!=="radio"&&be.type!=="select")return Le;const Ke=be.properties?.options??be.options;if(!Array.isArray(Ke)||Ke.length===0)return Le;const ut=Ke.map(me=>me.value);if(ut.includes(Le))return Le;const mt=String(Le);if(ut.includes(mt))return mt;const Ze=Ke.find(me=>me.value==Le);return Ze?Ze.value:Le},tt=new Set($.fields.filter(se=>se.type==="table").map(se=>se.name||se.key)),pe=new Set($.fields.filter(se=>se.type==="billingGrid").map(se=>se.name||se.key)),Oe=se=>se.name||se.key||se.id,Ae={},lt=[],Gt=[],zt=y_(_?.fieldMapping,$.config?.sections,$.config?.submitPayload);for(const[se,Le]of Object.entries(zt)){if(!Le?.trim()||se.startsWith("__"))continue;const be=Ge(Ve,Le),Ke=se.indexOf(".");if(Ke>0&&pe.has(se.slice(0,Ke))){const mt=se.slice(0,Ke),Ze=se.slice(Ke+1),ht=$.fields.find(Re=>(Re.name||Re.key)===mt)?.properties;if(ht?.rowSlots?.length){const Re=Ze.startsWith("__block__")?Ze.slice(9):Ze,Tt=Ae[mt]??Nt.getState().values[mt];Array.isArray(be)?Ae[mt]=yT(ht,Re,be,Tt):be!=null&&(Ae[mt]=Uc(ht,be,Tt))}continue}if(Ke>0&&tt.has(se.slice(0,Ke))){const mt=se.slice(0,Ke),Ze=se.slice(Ke+1);lt.push({tableName:mt,columnName:Ze,path:Le});continue}if(pe.has(se)&&be!==void 0&&be!==null&&typeof be=="object"){const Ze=$.fields.find(me=>(me.name||me.key)===se)?.properties;if(Ze?.rowSlots?.length){if(Array.isArray(be)){const me=Ze.rowSlots.find(ht=>ht.kind==="dynamic");if(me&&me.kind==="dynamic"){const ht=me.block.apiArrayPath??"items";Ae[se]=Uc(Ze,{[ht]:be})}}else Ae[se]=Uc(Ze,be);continue}}if(tt.has(se)&&Array.isArray(be)&&be.length>0&&typeof be[0]=="object"&&be[0]!==null){const Ze=$.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],me=be.map(Ky),ht=Re=>(Re||"").toLowerCase().replace(/\s+/g,"_").trim();Ae[se]=me.map(Re=>{const Tt={};for(const fr of Ze){const co=fr.name??"";Tt[co]=Re[ht(co)]??Re[co]}return Tt});continue}if(be!=null&&(Ae[se]=ze(se,be)),be==null)continue;let ut=be;if(Array.isArray(be)){const mt=$.fields.find(Ze=>Oe(Ze)===se);if(mt?.type==="addmore"){Gt.push({addMoreFieldName:se,array:be});continue}if(mt?.type==="multiselect"){const Ze=_.multiselectArrayPropertyMap?.[se];Ze&&be.length>0&&be.some(me=>me!=null&&typeof me=="object")&&(ut=be.map(me=>me!=null&&typeof me=="object"&&Ze in me?me[Ze]:void 0).filter(me=>me!=null))}}Ae[se]=ze(se,ut)}const at={},yt={},or={};for(const{addMoreFieldName:se,array:Le}of Gt){const be=$.fields.find(ht=>Oe(ht)===se);if(!be||be.type!=="addmore")continue;const Ke=jy(be,$.fields,$.config?.sections,Oe);if(Ke.length===0)continue;const ut=_.addMoreFieldKeyMap?.[se],mt=Le.length>0&&Le[0]!=null&&typeof Le[0]=="object"?Le[0]:null;if(mt)for(const ht of Ke){const Re=Oe(ht),Tt=ut&&ut[Re]||Re,fr=mt[Tt];fr!=null&&(Ae[Re]=ze(Re,fr))}const Ze=Le.slice(1),me=Ze.map((ht,Re)=>`prepop_${se}_${Re}_${Date.now()}`);me.length>0&&(yt[se]=me);for(let ht=0;ht<Ze.length;ht++){const Re=Ze[ht];if(Re==null||typeof Re!="object")continue;const Tt=Re,fr=Tt.id;fr!=null&&String(fr).trim()!==""&&(or[`${se}__${me[ht]}`]=String(fr));for(const co of Ke){const Da=Oe(co),kI=ut&&ut[Da]||Da,Ed=Tt[kI];if(Ed==null)continue;const _I=`${Da}__addmore__${se}__${me[ht]}`;at[_I]=ze(Da,Ed)}}}Object.keys(yt).length>0&&G(se=>({...se,...yt})),Object.keys(or).length>0&&ne(se=>({...se,...or}));const Hr=se=>(se||"").toLowerCase().replace(/\s+/g,"_").trim(),en=[...new Set(lt.map(se=>se.tableName))];for(const se of en){if(Array.isArray(Ae[se]))continue;const Le=lt.find(me=>me.tableName===se);if(!Le?.path?.includes("."))continue;const be=Le.path.replace(/\.[^.]+$/,""),Ke=Ge(Ve,be);if(!Array.isArray(Ke)||Ke.length===0||typeof Ke[0]!="object"||Ke[0]===null)continue;const mt=$.fields.find(me=>(me.name||me.key)===se)?.properties?.columns||[],Ze=Ke.map(Ky);Ae[se]=Ze.map(me=>{const ht={};for(const Re of mt){const Tt=Re.name??"",fr=Hr(Tt),co=me[fr]??me[Tt];ht[Tt]=co}return ht})}const Wr=(se,Le)=>{const be=Ge(Ve,se);if(Array.isArray(be))return be;if(be!=null)return[be];if(!se.includes("."))return[];const Ke=se.replace(/\.[^.]+$/,""),ut=Ge(Ve,Ke);return!Array.isArray(ut)||ut.length===0||typeof ut[0]!="object"||ut[0]===null?[]:ut.map(mt=>{const Ze=mt[Le];if(Ze!==null&&typeof Ze=="object"&&!Array.isArray(Ze)&&!(Ze instanceof Date)){const me=Ze;return typeof me.name=="string"&&typeof me.code=="string"?`${me.code} ${me.name}`.trim():typeof me.name=="string"?me.name:typeof me.code=="string"?me.code:typeof me.short_code=="string"?me.short_code:me.name??me.code??""}return Ze})};for(const{tableName:se,columnName:Le,path:be}of lt){const Ke=Wr(be,Le),mt=$.fields.find(Re=>(Re.name||Re.key)===se)?.properties?.columns||[],Ze=mt.find(Re=>(Re.name||"").toLowerCase()===Le.toLowerCase())?.name??Le;let me=Array.isArray(Ae[se])?Ae[se]:[];const ht=Math.max(me.length,Ke.length);if(ht>me.length)for(me=[...me];me.length<ht;){const Re={};mt.forEach(Tt=>{Re[Tt.name||""]=""}),me.push(Re)}else me=me.map(Re=>({...Re}));Ke.forEach((Re,Tt)=>{me[Tt]&&(me[Tt][Ze]=Re)}),Ae[se]=me}if(Xe.current===Z){if(Object.keys(Ae).length>0||Object.keys(at).length>0){const Tt={...Nt.getState().values,...Ae,...at};re(Tt)}const Le=Ge(Ve,"data.user_id"),be=Ge(Ve,"data.items"),Ke=Ge(Ve,"data");let ut=Array.isArray(be)&&be.length>0&&be[0]!=null&&typeof be[0]=="object"&&be[0].id?be[0].id:void 0;ut===void 0&&Array.isArray(Ke)&&Ke.length>0&&Ke[0]!=null&&typeof Ke[0]=="object"&&Ke[0].id&&(ut=Ke[0].id),ut===void 0&&(ut=Ge(Ve,"data.0.id"));const mt=XF(Ve,{treatFirstItemIdAsPaymentId:_?.treatFirstItemIdAsPaymentId===!0}),Ze=Ge(Ve,"data.id"),me=Ge(Ve,"data.batch_id"),ht=Ge(Ve,"data.program_id"),Re={};Le!=null&&(Re.context_user_id=Le),ut!=null&&ut!==""&&(Re.documentId=ut),Ze!=null&&String(Ze).trim()!==""&&(p?.id===void 0||p?.id===null)&&(Re.id=Ze),me!=null&&String(me).trim()!==""&&((p?.admission_batch_id===void 0||p?.admission_batch_id===null)&&(Re.admission_batch_id=me),(p?.batch_id===void 0||p?.batch_id===null)&&(Re.batch_id=me)),ht!=null&&String(ht).trim()!==""&&(p?.program_id===void 0||p?.program_id===null)&&(Re.program_id=ht),mt!=null&&String(mt).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&(Re.payment_id=mt),Object.keys(Re).length>0&&j(Tt=>{const fr={...Tt,...Re};return h?.(fr),fr}),Ie(Ve)}}catch(de){Q||ia(de,"Prepopulate request failed.",Gr)}finally{K(!1)}})(),()=>{Q=!0}},[$.id,$.config?.prepopulateApi?.enabled,$.config?.prepopulateApi?.apiEndpoint,$.config?.prepopulateApi?.apiMethod,JSON.stringify($.config?.prepopulateApi?.fieldMapping),$.config?.prepopulateApi?.treatFirstItemIdAsPaymentId,p,m,Ue,re,G]),v.useEffect(()=>{Object.keys(Ye).length>0&&s?.(Ye)},[Ye,s]);const Jr=dt>1,Yt=a==="view",lr=v.useCallback((_,q)=>Yt||!!q&&!br(_)||Ht(_)&&!br(_),[Yt,br,Ht]),Un=$.fields.filter(_=>!_.parentId),_t=[...Jr?bt:Un.length>0?Un:$.fields].filter(_=>!(!_||typeof _!="object"||!_.name&&!_.key)).sort((_,q)=>{const R=typeof _.position?.order=="number"?_.position.order:typeof _.positionOrder=="number"?_.positionOrder:Number.MAX_SAFE_INTEGER,Z=typeof q.position?.order=="number"?q.position.order:typeof q.positionOrder=="number"?q.positionOrder:Number.MAX_SAFE_INTEGER;if(R!==Z)return R-Z;const Q=typeof _.position?.column=="number"?_.position.column:1,de=typeof q.position?.column=="number"?q.position.column:1;return Q-de}),Ds=v.useCallback(_=>{const q=Nt.getState().errors,R=Object.keys(q).find(Z=>_.includes(Z));R&&requestAnimationFrame(()=>{document.querySelector(`[data-field-name="${R}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})})},[]),kr=async _=>{if(_?.preventDefault(),Jr&&!ir){if(!await nr())try{const Z=Nt.getState().errors;ct.toast.error(la(Z,$.fields)||"Please fix the errors before continuing."),Ds(_t.map(Q=>Q.name||Q.key||Q.id).filter(Boolean))}catch{ct.toast.error("Please fix the errors before continuing.")}return}const q=await gt(_);if(q&&q.success===!1&&q.errors?.length)try{const R=Nt.getState().errors;ct.toast.error(la(R,$.fields)||"Submission failed. Please check the form."),Ds(_t.map(Z=>Z.name||Z.key||Z.id).filter(Boolean))}catch{ct.toast.error("Submission failed. Please check the form.")}return q},Qr=v.useCallback(()=>{kt(),i&&i()},[kt,i]),zr=v.useCallback((_,q)=>{const R=$.fields.find(de=>de.type==="button"&&(de.name===_||de.key===_)),Z=R?.properties,Q=eP(q,R);Q!=null&&String(Q).trim()!==""&&(p?.payment_id===void 0||p?.payment_id===null)&&j(de=>{const ye={...de,payment_id:Q};return h?.(ye),ye}),R&&Z?.apiSuccessConfig&&qk(q,Z.apiSuccessConfig,{setFieldValue:(de,ye)=>Nt.getState().setFieldValue(de,ye),onContextUpdate:de=>{j(ye=>{const Ee={...ye,...de};return h?.(Ee),Ee})}}),le(de=>{const ye={...de,[_]:q};return!Qo(q)||!(R?.type==="button"&&R.properties?.action==="submit")||$.fields.filter(Je=>Je.type==="editButton").map(Je=>Je.name).forEach(Je=>delete ye[Je]),ye})},[$.fields,p,h,Nt]),Ur=v.useCallback(async()=>await vt(),[vt]),_r=v.useCallback(()=>Nt.getState().errors,[]),Xt=v.useMemo(()=>({...m||{},...ae}),[m,ae]),_e=v.useMemo(()=>({...typeof p=="object"&&p!==null?p:{},...Xt}),[p,Xt]),O=$.config?.layout??$.layout??"default",te=["default","card","compact"].includes(O)?O:"default",we={default:"",card:"bg-card border rounded-lg shadow-sm p-6",compact:"space-y-2"},st=v.useMemo(()=>{if(k)return;const _=$.config?.theme?.cssVariables;if(!(!_&&!F))return{..._??{},...F??{}}},[k,$.config?.theme?.cssVariables,F]),wt=v.useMemo(()=>Us({config:$.config,layout:$.layout},f),[$.config,$.layout,f]),St=v.useMemo(()=>wt?{...wt,verticalSpacing:wt.verticalSpacing??wt.spacing??"16px",horizontalSpacing:wt.horizontalSpacing??wt.spacing??"16px",rowHeight:wt.rowHeight??Hn}:null,[wt]),Wt=St!==null;St?.rows;const Et=St?.columns??3,Vr=St?.verticalSpacing??St?.spacing??"16px",Ho=St?.horizontalSpacing??St?.spacing??"16px",It=St?.rowHeight??Hn,fn=v.useCallback(_=>{if(!I)return!0;const q=_.visibility;if(!q)return!0;const R=q.visibleToUserType??q.user_type,Z=q.visibleToUserRole??q.user_role,Q=Array.isArray(q.visibleToUserIds)?q.visibleToUserIds:Array.isArray(q.users)?q.users:[],de=Array.isArray(q.hiddenFromUserIds)?q.hiddenFromUserIds:[];if(Array.isArray(de)&&de.length>0&&I.userId!=null&&de.includes(I.userId))return!1;if(Q.length>0&&I.userId!=null&&Q.includes(I.userId))return!0;const ye=R!=null&&R!==""&&I.userType!=null&&I.userType!==R,Ee=Z!=null&&Z!==""&&I.role!=null&&I.role!==Z,He=Q.length>0&&(I.userId==null||!Q.includes(I.userId));return!(ye||Ee||He)},[I]),xn=v.useMemo(()=>k_($.fields),[$.fields]),Sd=v.useMemo(()=>T_($.fields),[$.fields]),[Wo,Pb]=v.useState(Sd);v.useEffect(()=>{Pb(Sd)},[$.id,Sd]);const Ob=v.useCallback((_,q)=>{Pb(R=>R[_]===q?R:{...R,[_]:q})},[]),xI=v.useMemo(()=>({visibility:Wo,setSectionVisible:Ob,fieldToHeading:xn,allFields:$.fields}),[Wo,Ob,xn,$.fields]),nt=v.useCallback(_=>_.name||_.key||_.id,[]),Tr=_=>{if(!fn(_))return!1;const q=_.name||_.key||_.id;if(!Lg(q,_.type,Wo,xn))return!1;const R=_.hidden===!0;return jr(q)||!R&&q},Ib=v.useCallback(_=>{const q=$.fields.find(Z=>nt(Z)===_);if(q)return q.type;const R=Mg(_);return $.fields.find(Z=>nt(Z)===R)?.type},[$.fields,nt]),Ca=v.useCallback(_=>Lg(_,Ib(_),Wo,xn),[Wo,xn,Ib]),An=v.useCallback(_=>Ca(_)?Sn(_):!1,[Ca,Sn]);v.useEffect(()=>{const{visibleFields:_,requiredFields:q,errors:R}=Nt.getState(),Z=new Set(_),Q=new Set(q),de=[];for(const ye of $.fields){const Ee=nt(ye);Ee&&(Ca(Ee)||(Z.delete(Ee),Q.delete(Ee),R[Ee]&&de.push(Ee)))}Bt(Array.from(Z)),Pt(Array.from(Q));for(const ye of de)Ar(ye,void 0)},[Wo,xn,$.fields,$.id,nt,Ca,Bt,Pt,Ar,pt,Dt]);const jt=$.config?.sections,ao=v.useCallback(_=>{const q=nt(_);let R=_;if(_.type==="table"){const Q=_.properties?.columns;if(Array.isArray(Q)&&Q.length>0){const de=Q.filter(ye=>fn(ye));R={..._,properties:{..._.properties,columns:de}}}}const Z=sP(R,jt,nt);return Z&&(R={...R,label:$y(Z,0)}),{...R,disabled:!ar(q),readOnly:lr(q,!!R.readOnly)}},[fn,jt,nt,ar,lr]),Cn=v.useCallback(_=>jy(_,$.fields,jt,nt),[$.fields,jt,nt]),Zr=v.useCallback((_,q,R)=>`${_}__addmore__${q}__${R}`,[]),Ea=v.useCallback((_,q)=>`${_}__${q??"base"}`,[]),Na=v.useCallback((_,q)=>{const R=Ea(_.id,q);return ie[R]??_.defaultCollapsed??!1},[ie,Ea]),xd=v.useCallback((_,q,R)=>{const Z=Ea(_,q);Ce(Q=>Q[Z]===R?Q:{...Q,[Z]:R})},[Ea]),ka=v.useMemo(()=>{const _=[],q=$.fields.filter(R=>R.type==="addmore");for(const R of q){const Z=nt(R),de=Cn(R).find(Je=>{if(Je.type!=="button")return!1;const Rt=Je.properties,Be=Je.metadata;let Ve=Rt?.action;if(!Ve&&Be!=null)try{Ve=(typeof Be=="string"?JSON.parse(Be):Be)?.action}catch{}return Ve==="upload"||Ve==="custom"});if(!de)continue;const ye=nt(de),Ee=oe[Z]||[],He=Ge(U[ye],"data.id")??Ge(U[ye],"data.documentId")??ae.documentId;He!=null&&String(He).trim()!==""&&_.push(String(He));for(const Je of Ee){const Rt=Zr(ye,Z,Je),Be=Ge(U[Rt],"data.id")??Ge(U[Rt],"data.documentId"),Ve=ee[`${Z}__${Je}`],Ne=Be??Ve;Ne!=null&&String(Ne).trim()!==""&&_.push(String(Ne))}}return _},[$.fields,oe,U,ee,ae.documentId,nt,Cn,Zr]);v.useEffect(()=>{j(_=>{const q={..._,document_ids:ka},R=_.document_ids;return Array.isArray(R)&&R.length===ka.length&&ka.every((Z,Q)=>R[Q]===Z)?_:q})},[ka]);const _a=v.useCallback((_,q,R,Z)=>{for(const Q of R){const de=nt(Q),ye=Zr(de,_,q),Ee=Z[ye];if(Ee==null)continue;const He=Q.type;if(He==="file"||He==="camera"||He==="photoChoice"){if(typeof Ee=="object"&&Ee!==null&&("url"in Ee||"name"in Ee)||Array.isArray(Ee)&&Ee.length>0)return!0;continue}if(Array.isArray(Ee)){if(Ee.length>0)return!0;continue}if(typeof Ee=="string"&&Ee.trim()!==""||typeof Ee=="number"&&!Number.isNaN(Ee)||typeof Ee=="boolean"||typeof Ee=="object"&&Ee!==null&&Object.keys(Ee).length>0)return!0}return!1},[nt,Zr]),lo=v.useCallback(_=>{const q=nt(_);if(!q)return;if(Cn(_).length===0){ct.toast.error("No linked fields configured for this Add More button.");return}const Z=`${Date.now()}_${Math.random().toString(36).slice(2,8)}`;G(Q=>({...Q,[q]:[...Q[q]||[],Z]}))},[nt,Cn]),Ta=v.useCallback((_,q)=>{G(R=>{const Z=R[_]||[],Q=Z.filter(de=>de!==q);if(Q.length===Z.length)return R;if(Q.length===0){const de={...R};return delete de[_],de}return{...R,[_]:Q}})},[]),Fa=v.useMemo(()=>_t.filter(_=>!_.parentId),[_t]),Vn=v.useMemo(()=>{const _=[];return _t.filter(R=>R.type==="addmore").sort((R,Z)=>{const Q=R.position?.order??0,de=Z.position?.order??0;return Q-de}).forEach(R=>{const Z=nt(R),Q=R.position?.order??0,de=oe[Z]||[],ye=Cn(R).sort((ke,ze)=>{const tt=ke.position?.order??0,pe=ze.position?.order??0;return tt!==pe?tt-pe:(ke.position?.column??1)-(ze.position?.column??1)});if(ye.length===0)return;const Ee=By(R,jt),He=Ee[0]?.fieldNames?.length?Ee[0].fieldNames:ye.map(ke=>nt(ke)).filter(Boolean),Je=lP(He,Fa,Et,nt),Rt=Math.min(...ye.map(ke=>ke.position?.order??0)),Be=Math.max(1,...ye.map(ke=>(ke.position?.order??Rt)-Rt+qo(ke))),Ve=Je?.blockHeight??Be,Ne=de.length*Ve;_.push({addMoreFieldName:Z,baseOrder:Q,blockHeight:Ve,blockIds:de,linkedFields:ye,insertedRows:Ne,templateFieldNames:He,templateBounds:Je})}),_},[_t,Fa,Et,nt,oe,Cn,jt]),Bs=v.useMemo(()=>({}),[]),Pa=v.useMemo(()=>Vn.length===0?_t:_t.map(_=>{const q=_.position?.order??0,R=Vn.reduce((Z,Q)=>{const de=Q.templateBounds?.maxRow??Q.baseOrder;return q>de?Z+Q.insertedRows:Z},0);return R===0?_:{..._,position:{..._.position,order:q+R}}}),[_t,Vn]),Oa=v.useCallback(_=>{const q={};return Object.entries(U).forEach(([R,Z])=>{const Q=_[R];Q&&(q[Q]=Z)}),q},[U]),Ro=v.useMemo(()=>{const _=[],q={};return Vn.forEach(R=>{const{addMoreFieldName:Z,blockIds:Q,linkedFields:de,blockHeight:ye,templateBounds:Ee}=R,He=Math.min(...de.map(Be=>Be.position?.order??0)),Rt=$.fields.find(Be=>nt(Be)===Z&&Be.type==="addmore")?.properties;Q.forEach((Be,Ve)=>{const Ne={},ke={},ze={},tt=Ee?cP(Ee,Ve):R.baseOrder+1+Ve*ye,pe=ee[`${Z}__${Be}`];de.forEach(Ae=>{const lt=nt(Ae),Gt=Zr(lt,Z,Be),zt=(Ae.position?.order??He)-He;if(Ne[Gt]=lt,ke[Gt]=Te[Gt],!(Rt?.linkedFieldAllowDuplicate?.[lt]??!0)&&(Ae.type==="select"||Ae.type==="radio"||Ae.type==="multiselect")){const yt=[],or=Te[lt];or!=null&&or!==""&&(Array.isArray(or)?yt.push(...or.map(en=>String(en))):yt.push(String(or))),Q.filter(en=>en!==Be).forEach(en=>{const Wr=Zr(lt,Z,en),tn=Te[Wr];tn!=null&&tn!==""&&(Array.isArray(tn)?yt.push(...tn.map(se=>String(se))):yt.push(String(tn)))}),yt.length>0&&(ze[Gt]=[...new Set(yt)])}_.push({...Ae,id:`${Ae.id}__${Be}`,name:Gt,position:{...Ae.position,order:tt+zt}})});const Oe=Oa(Ne);Object.keys(Ne).forEach(Ae=>{q[Ae]={scopedFormValues:ke,scopedFieldNameMap:Ne,scopedButtonResponses:Oe,...pe!=null&&{blockDocumentId:pe},...ze[Ae]&&{excludedOptionValues:ze[Ae]}}})})}),{clonedFields:_,scopeByFieldName:q}},[Vn,ee,nt,Zr,Te,Oa,$.fields]),$s=v.useMemo(()=>[...Pa,...Ro.clonedFields].sort((_,q)=>{const R=_.position?.order??0,Z=q.position?.order??0;if(R!==Z)return R-Z;const Q=_.position?.column??1,de=q.position?.column??1;if(Q!==de)return Q-de;const ye=Oo(_.position)??0,Ee=Oo(q.position)??0;return ye!==Ee?ye-Ee:String(_.id).localeCompare(String(q.id))}),[Pa,Ro.clonedFields]),Go=v.useMemo(()=>Qk($s.filter(_=>!_.parentId),Tr),[$s,Tr]),Ad=v.useCallback((_,q)=>Go.some(R=>Zk(_,q,R,Et)),[Go,Et]);Go.length===0||Math.max(...Go.map(_=>(_[0]?.position?.order??0)+Ss(_,Et).rowSpan));const Ia=v.useMemo(()=>iP(jt,sd(_t.filter(_=>!_.parentId)),nt),[jt,_t,nt]),{anchorsByOrigin:Mb,coveredCells:Lb}=v.useMemo(()=>dP(Ia,Pa,nt,Et),[Ia,Pa,nt,Et]),{anchorsByOrigin:Db,coveredCells:Bb}=v.useMemo(()=>uP(Vn.map(_=>({addMoreFieldName:_.addMoreFieldName,blockIds:_.blockIds,linkedFields:_.linkedFields,templateFieldNames:_.templateFieldNames})),jt,Ro.clonedFields,Fa,Et,nt,Lb),[Vn,jt,Ro.clonedFields,Fa,Et,nt,Lb]),En=v.useMemo(()=>yP(Mb,Db),[Mb,Db]),$b=v.useMemo(()=>Bb,[Bb]),jb=String(It).endsWith("px")?It:Hn,zb=v.useCallback((_,q)=>{for(let R=0;R<Et;R++){if(R>=q.anchorCol&&R<q.anchorCol+q.colSpan)continue;if(Bs[`${_}-${R}`]||En.get(`${_}-${R}`)||bg(_,R,$s,Tr).length>0||Ad(_,R))return!0}return!1},[Et,Bs,En,$s,Tr,Ad]),Ub=v.useMemo(()=>hP(En,_=>{const q=_.run.section;return q.collapsible?Na(q,_.addMoreMeta?.blockId):!1},zb),[En,Na,zb]),Vb=v.useMemo(()=>{const _=[];for(const q of Object.keys(Bs)){const R=Number(q.split("-")[0]);Number.isNaN(R)||_.push(R)}for(const q of En.values())if(q.renderFields.some(R=>Tr(R)))for(let R=q.anchorRow;R<q.anchorRow+q.rowSpan;R++)_.push(R);return e_(Go,Et,_)},[Go,Et,Bs,En,Tr]),{originalToDisplayRow:Ma,displayRowCount:AI,sortedOccupiedRows:CI}=v.useMemo(()=>{const _=t_(Vb);return{originalToDisplayRow:_.originalToDisplay,displayRowCount:_.displayRowCount,sortedOccupiedRows:_.sortedOriginalRows}},[Vb]),Hb=Math.max(AI,1),Cd=v.useCallback((_,q=1)=>r_(_,q,Ma),[Ma]),Wb=v.useMemo(()=>{const _=new Set;for(const q of Ub){const R=Ma.get(q);R!==void 0&&_.add(R)}return _},[Ub,Ma]),EI=v.useMemo(()=>gP(Hb,jb,Wb),[Hb,jb,Wb]),NI=v.useMemo(()=>bP(_t.filter(_=>!_.parentId&&Tr(_)),Ia,nt),[_t,Ia,nt,Tr]),La=v.useCallback(_=>{if(Wt)return null;const q=nt(_),R=oe[q]||[];if(R.length===0)return null;const Z=Cn(_);if(Z.length===0)return null;const Q=oP(_,jt),de=Z.map(He=>nt(He)).filter(Boolean),ye=Uy(de,jt),Ee=(He,Je,Rt,Be,Ve,Ne,ke)=>{const ze=nt(He),tt=Zr(ze,q,Je),pe=He.hidden===!0;if(!(fn(He)&&(jr(ze)||!pe&&ze)))return null;const Ae={...He,id:`${He.id}__${Je}`,name:tt,disabled:!ar(ze),readOnly:lr(ze,!!He.readOnly)},Gt=_.properties?.linkedFieldAllowDuplicate?.[ze]??!0;let zt;if(!Gt&&(He.type==="select"||He.type==="radio"||He.type==="multiselect")){const at=[],yt=Te[ze];yt!=null&&yt!==""&&(Array.isArray(yt)?at.push(...yt.map(Hr=>String(Hr))):at.push(String(yt))),R.filter(Hr=>Hr!==Je).forEach(Hr=>{const en=Zr(ze,q,Hr),Wr=Te[en];Wr!=null&&Wr!==""&&(Array.isArray(Wr)?at.push(...Wr.map(tn=>String(tn))):at.push(String(Wr)))}),at.length>0&&(zt=[...new Set(at)])}return d.jsx("div",{"data-field-name":tt,"data-form-renderer":"field-wrapper",children:d.jsx(wn,{field:Ae,value:Te[tt],error:Me[tt]||We>0?Ye[tt]:void 0,onChange:at=>xt(tt,at),onBlur:()=>$e(tt),disabled:Se||!ar(ze)||Yt,readOnly:lr(ze,!!He.readOnly),isRequired:An(ze),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:tt,buttonResponses:Ne,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:ke,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,scopedFormValues:Ve,scopedFieldNameMap:Be,excludedOptionValues:zt,hideTableRowControls:x})},Ae.id)};return d.jsx("div",{className:"space-y-3 mt-3",children:R.map((He,Je)=>{const Rt={},Be={};Z.forEach(zt=>{const at=nt(zt),yt=Zr(at,q,He);Rt[yt]=at,Be[yt]=Te[yt]});const Ve=Oa(Rt),Ne=_a(q,He,Z,Te),ke=Q?.heading!=null?Fs(Q,Je+1):null,ze=ee[`${q}__${He}`],tt=ze!=null?{...Xt,documentId:ze}:Xt,pe=Z.map(zt=>Ee(zt,He,Je,Rt,Be,Ve,tt)).filter(Boolean),Ae=ye?.section?.collapsible===!0,lt=d.jsx("button",{type:"button",className:"inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",disabled:Ne,title:Ne?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:zt=>{zt.preventDefault(),zt.stopPropagation(),Ta(q,He)},children:d.jsx(rs,{className:"h-5 w-5","aria-hidden":!0})}),Gt=d.jsxs(d.Fragment,{children:[!Ae&&d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ke?d.jsx("p",{className:"text-sm font-medium text-foreground",children:ke}):d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Entry ",Je+1]}),lt]}),pe]});return d.jsx("div",{className:"rounded-md border p-3 space-y-3",children:ye?d.jsx(td,{legend:ye.section.heading?.enabled?Fs(ye.section,Je+1):ye.section.name,collapsible:ye.section.collapsible,defaultCollapsed:ye.section.defaultCollapsed,headerActions:Ae?lt:void 0,onCollapsedChange:zt=>xd(ye.section.id,He,zt),children:Gt}):Gt},`${_.id}-${He}`)})})},[Wt,oe,ee,nt,Cn,Zr,_a,Te,Me,We,Ye,xt,$e,ar,Yt,An,_e,fe,zr,kr,kt,Qr,xe,B,g,Xt,Ur,_r,$.fields,ge,jr,fn,Oa,Ta,x,jt,Ue,he,D]),Rb=d.jsx("div",{className:k?H("relative",c):H($a,N&&"dark",c),style:st,"data-form-renderer":k?void 0:"root",children:d.jsxs("div",{className:"relative",children:[D&&d.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 rounded-md",children:d.jsx(vn,{})}),d.jsx("form",{onSubmit:kr,className:l?H("w-full min-w-0"):H("space-y-6 pb-[100px] w-full min-w-0",we[te]),"data-form-renderer":"form","data-form-renderer-layout":Wt?"grid":"stack",children:d.jsxs(C_,{value:xI,children:[Jr&&$.steps&&d.jsx(vP,{steps:$.steps,currentStep:Er,completedSteps:Ot,onStepClick:yr}),d.jsx(Ya.Provider,{value:{gridStretch:Wt},children:Wt?d.jsx("div",{className:l?"w-full min-w-0":"grid w-full min-w-0",style:{display:"grid",gridTemplateRows:EI,gridTemplateColumns:`repeat(${Et}, 1fr)`,rowGap:Vr,columnGap:Ho},"data-form-renderer":"grid",children:CI.map(_=>Array.from({length:Et},(q,R)=>{const Z=Cd(_);if(!Z)return null;if(Ad(_,R))return d.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:R+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${R}`);if(fP(_,R,$b,En)){const Ne=pP(_,R,En);return Ne&&mP(_,R,Ne,Na(Ne.run.section,Ne.addMoreMeta?.blockId))?null:d.jsx("div",{className:"min-w-0 min-h-0",style:{gridRow:Z,gridColumn:R+1,visibility:"hidden",pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`section-border-cover-${_}-${R}`)}const Q=En.get(`${_}-${R}`);if(Q){const Ne=Q.renderFields.filter(at=>Tr(at));if(Ne.length===0)return null;const ke=Q.addMoreMeta,ze=ke!=null?Vn.find(at=>at.addMoreFieldName===ke.addMoreFieldName)?.linkedFields??[]:[],tt=ke!=null?_a(ke.addMoreFieldName,ke.blockId,ze,Te):!1,pe=Q.run.section,Oe=ke?.blockId,Ae=Na(pe,Oe),lt=pe.collapsible&&Ae?1:Q.rowSpan,Gt=Cd(Q.anchorRow,lt)??Z,zt=ke!=null?d.jsx("button",{type:"button",className:H("inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",l&&"text-red-600 hover:bg-red-500/10"),disabled:tt,title:tt?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:at=>{at.preventDefault(),at.stopPropagation(),Ta(ke.addMoreFieldName,ke.blockId)},children:d.jsx(rs,{className:"h-5 w-5","aria-hidden":!0})}):void 0;return d.jsx("div",{className:H("min-h-0 min-w-0",!(pe.collapsible&&Ae)&&"self-stretch"),style:{gridRow:Gt,gridColumn:`${R+1} / span ${Q.colSpan}`},"data-form-renderer":"grid-cell","data-form-renderer-config-section-border-cell":!0,children:d.jsx(td,{legend:Q.legend,className:pe.collapsible&&Ae?void 0:"h-full",collapsible:pe.collapsible,defaultCollapsed:pe.defaultCollapsed,headerActions:zt,onCollapsedChange:at=>xd(pe.id,Oe,at),children:d.jsx("div",{className:"grid w-full min-w-0",style:{gridTemplateColumns:`repeat(${Et}, 1fr)`,gridTemplateRows:`repeat(${Q.rowSpan}, minmax(${String(It).endsWith("px")?It:Hn}, auto))`,rowGap:Vr,columnGap:Ho},children:Ne.map(at=>{const yt=nt(at),or=Ro.scopeByFieldName[yt],Hr=or?.scopedFieldNameMap?.[yt]||yt,en=(at.position?.order??Q.anchorRow)-Q.anchorRow,Wr=at.position?.column??1,{rowSpan:tn,columnSpan:se}=Ss([at],Et),Le=ke!=null?ee[`${ke.addMoreFieldName}__${ke.blockId}`]:void 0,be=Le!=null?{...Xt,documentId:Le}:Xt;return d.jsx("div",{"data-field-name":yt,"data-form-renderer":"field-wrapper",className:"min-h-0 min-w-0",style:{gridRow:`${en+1} / span ${tn}`,gridColumn:`${Wr} / span ${se}`,...Pn(at)},children:d.jsx(wn,{field:ao(at),value:Te[yt],error:Me[yt]||We>0?Ye[yt]:void 0,onChange:Ke=>xt(yt,Ke),onBlur:()=>$e(yt),disabled:(at.type==="table"||at.type==="billingGrid")&&a==="fill"?!1:Se||!ar(Hr)||Yt,readOnly:(at.type==="table"||at.type==="billingGrid")&&a==="fill"?!1:lr(Hr,!!at.readOnly),isRequired:An(Hr),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:yt,buttonResponses:or?.scopedButtonResponses??U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:be,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,scopedFormValues:or?.scopedFormValues,scopedFieldNameMap:or?.scopedFieldNameMap,excludedOptionValues:or?.excludedOptionValues,hideTableRowControls:x})},at.id)})})})},`section-border-${Q.run.section.id}-${_}-${R}-${ke?.blockId??"base"}`)}const de=bg(_,R,$s,Tr).filter(Ne=>!(nt(Ne)?.includes("__addmore__")&&$b.has(`${_}-${R}`)));if(de.length===0){const Ne=Bs[`${_}-${R}`];if(Ne){const ke=$.fields.find(pe=>pe.type==="addmore"&&nt(pe)===Ne.addMoreFieldName),ze=ke!=null?Cn(ke):[],tt=_a(Ne.addMoreFieldName,Ne.blockId,ze,Te);return d.jsx("div",{className:"min-h-0 min-w-0 flex flex-col items-center justify-center",style:{gridRow:Z,gridColumn:R+1},"data-form-renderer":"grid-cell","data-form-renderer-add-more-remove":!0,children:d.jsx("button",{type:"button",className:H("inline-flex shrink-0 rounded-md p-1.5 text-destructive hover:bg-destructive/10 focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-40",l&&"text-red-600 hover:bg-red-500/10"),disabled:tt,title:tt?"Cannot remove: this entry has data":"Remove entry","aria-label":"Remove entry",onClick:pe=>{pe.preventDefault(),pe.stopPropagation(),Ta(Ne.addMoreFieldName,Ne.blockId)},children:d.jsx(rs,{className:"h-5 w-5","aria-hidden":!0})})},`add-more-remove-${_}-${R}`)}return d.jsx("div",{className:"min-w-0",style:{pointerEvents:"none"},"data-form-renderer":"grid-cell","data-form-renderer-empty":!0},`empty-${_}-${R}`)}const ye=de[0],{rowSpan:Ee,columnSpan:He}=Ss(de,Et),Je=Cd(_,Ee)??Z;if(de.length===1&&ye.type==="section"){const Ne=$.fields.filter(ke=>ke.parentId===ye.id&&ke.position!=null).sort((ke,ze)=>{const tt=typeof ke.position?.order=="number"?ke.position.order:0,pe=typeof ze.position?.order=="number"?ze.position.order:0;return tt-pe});return d.jsx("div",{className:"min-w-0 min-h-0 w-full overflow-hidden flex flex-col h-full",style:{gridRow:Je,gridColumn:`${R+1} / span ${He}`,...Pn(ye)},"data-form-renderer":"grid-cell",children:d.jsx(ay,{field:ye,children:Ne.map(ke=>{const ze=ke.name||ke.key||ke.id,tt=ke.hidden===!0;return fn(ke)&&(jr(ze)||!tt&&ze)?d.jsx("div",{"data-field-name":ze,"data-form-renderer":"field-wrapper",children:d.jsx(wn,{field:ao(ke),value:Te[ze],error:Me[ze]||We>0?Ye[ze]:void 0,onChange:Oe=>xt(ze,Oe),onBlur:()=>$e(ze),disabled:Se||!ar(ze)||Yt,readOnly:lr(ze,!!ke.readOnly),isRequired:An(ze),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:ze,buttonResponses:U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x})},ke.id):null})})},ye.id)}const Rt=gg(de),Be=de.some(Ne=>["file","camera","photoChoice","addmore","table","billingGrid"].includes(Ne.type)),Ve=d.jsx("div",{className:H("flex min-h-0 w-full flex-1 gap-3",Rt==="row"?"flex-row items-stretch":"flex-col items-stretch"),children:de.map(Ne=>{const ke=Ne.name||Ne.key||Ne.id,ze=Ne.type==="sectionHeading",tt=Ro.scopeByFieldName[ke],pe=tt?.scopedFieldNameMap?.[ke]||ke,Oe=tt?.blockDocumentId!=null?{...Xt,documentId:tt.blockDocumentId}:Xt,Ae=Ne.appearance?.hideLabel??Ne.properties?.hideLabel??!1,lt=Ne.type==="table"||Ne.type==="billingGrid"?Ne.properties?.minWidth:void 0;return d.jsx("div",{"data-field-name":ke,"data-form-renderer":"field-wrapper",className:H("flex min-h-0 min-w-0 flex-1 flex-col",Xo(Ne),ze&&"items-center justify-center",Ae&&"items-center"),style:{...lt?{minWidth:lt}:{},...Pn(Ne)},children:d.jsx(wn,{field:ao(Ne),value:Te[ke],error:Me[ke]||We>0?Ye[ke]:void 0,onChange:Gt=>xt(ke,Gt),onBlur:()=>$e(ke),disabled:(Ne.type==="table"||Ne.type==="billingGrid")&&a==="fill"?!1:Se||!ar(pe)||Yt,readOnly:(Ne.type==="table"||Ne.type==="billingGrid")&&a==="fill"?!1:lr(pe,!!Ne.readOnly),isRequired:An(pe),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:ke,buttonResponses:tt?.scopedButtonResponses??U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Oe,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,scopedFormValues:tt?.scopedFormValues,scopedFieldNameMap:tt?.scopedFieldNameMap,excludedOptionValues:tt?.excludedOptionValues,hideTableRowControls:x})},Ne.id)})});return d.jsx("div",{className:H(Qd(de),"self-stretch",Be?"overflow-visible":"overflow-hidden"),style:{gridRow:Je,gridColumn:`${R+1} / span ${He}`,...Pn(de[0])},"data-form-renderer":"grid-cell","data-field-name":de.map(Ne=>Ne.name||Ne.key||Ne.id).join(","),children:Ve},de.map(Ne=>Ne.id).join("-"))}))}):d.jsx("div",{className:l?"":"space-y-4","data-form-renderer":"stack",children:_t.map(_=>{if(!Tr(_))return null;const q=NI.find(Z=>Z.kind==="border"&&Z.fields.some(Q=>Q.id===_.id));if(q)return q.fields[0]?.id!==_.id?null:d.jsx(td,{legend:Fs(q.run.section,0),collapsible:q.run.section.collapsible,defaultCollapsed:q.run.section.defaultCollapsed,onCollapsedChange:Z=>xd(q.run.section.id,void 0,Z),children:q.fields.map(Z=>{const Q=nt(Z);return!Q||!Tr(Z)?null:d.jsxs("div",{"data-field-name":Q,"data-form-renderer":"field-wrapper",style:Pn(Z),children:[d.jsx(wn,{field:ao(Z),value:Te[Q],error:Me[Q]||We>0?Ye[Q]:void 0,onChange:de=>xt(Q,de),onBlur:()=>$e(Q),disabled:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:Se||!ar(Q)||Yt,readOnly:(Z.type==="table"||Z.type==="billingGrid")&&a==="fill"?!1:lr(Q,!!Z.readOnly),isRequired:An(Q),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:Q,buttonResponses:U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),Z.type==="addmore"&&La(Z)]},Z.id)})},`stack-border-${q.run.section.id}-${_.id}`);if(!_.parentId){const Z=_t.filter(de=>!de.parentId&&Tr(de)&&ca(de)===ca(_)),Q=Nc(Z).slice(0,2);if(Q.length>1&&Q[0].id!==_.id)return null;if(Q.length>1){const de=gg(Q);return d.jsx("div",{"data-form-renderer":"shared-cell-stack",className:H("flex w-full min-w-0 gap-3",de==="row"?"flex-row items-stretch":"flex-col"),children:Q.map(ye=>{const Ee=ye.name||ye.key||ye.id;return d.jsxs("div",{"data-field-name":Ee,"data-form-renderer":"field-wrapper",className:H("min-w-0 flex-1 flex flex-col",Xo(ye)),style:Pn(ye),children:[d.jsx(wn,{field:ao(ye),value:Te[Ee],error:Me[Ee]||We>0?Ye[Ee]:void 0,onChange:He=>xt(Ee,He),onBlur:()=>$e(Ee),disabled:(ye.type==="table"||ye.type==="billingGrid")&&a==="fill"?!1:Se||!ar(Ee)||Yt,readOnly:(ye.type==="table"||ye.type==="billingGrid")&&a==="fill"?!1:lr(Ee,!!ye.readOnly),isRequired:An(Ee),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:Ee,buttonResponses:U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),ye.type==="addmore"&&La(ye)]},ye.id)})},Q.map(ye=>ye.id).join("-"))}}if(_.type==="section"){const Z=$.fields.filter(Q=>Q.parentId===_.id&&Q.position!=null).sort((Q,de)=>{const ye=typeof Q.position?.order=="number"?Q.position.order:0,Ee=typeof de.position?.order=="number"?de.position.order:0;return ye-Ee});return d.jsx(ay,{field:_,children:Z.map(Q=>{const de=Q.name||Q.key||Q.id,ye=Q.hidden===!0;return fn(Q)&&(jr(de)||!ye&&de)?d.jsxs("div",{"data-field-name":de,"data-form-renderer":"field-wrapper",style:Pn(Q),children:[d.jsx(wn,{field:ao(Q),value:Te[de],error:Me[de]||We>0?Ye[de]:void 0,onChange:He=>xt(de,He),onBlur:()=>$e(de),disabled:Se||!ar(de)||Yt,readOnly:lr(de,!!Q.readOnly),isRequired:An(de),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:de,buttonResponses:U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),Q.type==="addmore"&&La(Q)]},Q.id):null})},_.id)}const R=_.name||_.key||_.id;return d.jsxs("div",{"data-field-name":R,"data-form-renderer":"field-wrapper",style:Pn(_),children:[d.jsx(wn,{field:ao(_),value:Te[R],error:Me[R]||We>0?Ye[R]:void 0,onChange:Z=>xt(R,Z),onBlur:()=>$e(R),disabled:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:Se||!ar(R)||Yt,readOnly:(_.type==="table"||_.type==="billingGrid")&&a==="fill"?!1:lr(R,!!_.readOnly),isRequired:An(R),formValues:Te,submissionContext:_e,prepopulateMappedFieldNames:fe,urlParams:Ue,prepopulateResponse:he,prepopulateLoading:D,formSections:jt,submitPayload:$.config?.submitPayload,fieldValueKey:R,buttonResponses:U,onButtonApiResponse:zr,onSubmit:kr,onReset:kt,onCancel:Qr,isSubmitting:xe,bffSubmitApi:B,onBffSubmitResult:g,extraSubmitPayload:Xt,onValidateForm:Ur,getValidationErrors:_r,allFields:$.fields,onSubmittingChange:ge,onAddMore:lo,hideTableRowControls:x}),_.type==="addmore"&&La(_)]},_.id)})})}),u]})})]})});return P?d.jsx(kg,{handlers:P,moduleId:T??"",submissionContext:p,getAuthHeaders:E,onParentWorkflowSubmitResult:g,children:Rb}):Rb};var va="Tabs",[AP]=vr(va,[ta]),qy=ta(),[CP,ad]=AP(va),Yy=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:a,activationMode:c="automatic",...u}=e,f=bo(a),[l,p]=ln({prop:n,onChange:o,defaultProp:s??"",caller:va});return d.jsx(CP,{scope:r,baseId:hn(),value:l,onValueChange:p,orientation:i,dir:f,activationMode:c,children:d.jsx(je.div,{dir:f,"data-orientation":i,...u,ref:t})})});Yy.displayName=va;var Xy="TabsList",Jy=b.forwardRef((e,t)=>{const{__scopeTabs:r,loop:n=!0,...o}=e,s=ad(Xy,r),i=qy(r);return d.jsx(Fh,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:n,children:d.jsx(je.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});Jy.displayName=Xy;var Qy="TabsTrigger",Zy=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,disabled:o=!1,...s}=e,i=ad(Qy,r),a=qy(r),c=rb(i.baseId,n),u=nb(i.baseId,n),f=n===i.value;return d.jsx(Ph,{asChild:!0,...a,focusable:!o,active:f,children:d.jsx(je.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":u,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:c,...s,ref:t,onMouseDown:De(e.onMouseDown,l=>{!o&&l.button===0&&l.ctrlKey===!1?i.onValueChange(n):l.preventDefault()}),onKeyDown:De(e.onKeyDown,l=>{[" ","Enter"].includes(l.key)&&i.onValueChange(n)}),onFocus:De(e.onFocus,()=>{const l=i.activationMode!=="manual";!f&&!o&&l&&i.onValueChange(n)})})})});Zy.displayName=Qy;var eb="TabsContent",tb=b.forwardRef((e,t)=>{const{__scopeTabs:r,value:n,forceMount:o,children:s,...i}=e,a=ad(eb,r),c=rb(a.baseId,n),u=nb(a.baseId,n),f=n===a.value,l=b.useRef(f);return b.useEffect(()=>{const p=requestAnimationFrame(()=>l.current=!1);return()=>cancelAnimationFrame(p)},[]),d.jsx(xr,{present:o||f,children:({present:p})=>d.jsx(je.div,{"data-state":f?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!p,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:l.current?"0s":void 0},children:p&&s})})});tb.displayName=eb;function rb(e,t){return`${e}-trigger-${t}`}function nb(e,t){return`${e}-content-${t}`}var EP=Yy,NP=Jy,kP=Zy,_P=tb;function ob({className:e,...t}){return d.jsx(EP,{"data-slot":"tabs",className:H("flex flex-col gap-2",e),...t})}function ld({className:e,...t}){return d.jsx(NP,{"data-slot":"tabs-list",className:H("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}function cd({className:e,...t}){return d.jsx(kP,{"data-slot":"tabs-trigger",className:H("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function sb({className:e,...t}){return d.jsx(_P,{"data-slot":"tabs-content",className:H("flex-1 outline-none",e),...t})}const TP="w-full justify-start border-b rounded-none h-auto p-0 bg-transparent gap-0",FP="rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none",PP=({steps:e,position:t,sidebarWidth:r,sticky:n=!0,stickyOffset:o="1rem",sidebarMaxHeight:s="calc(100vh - 6rem)"})=>{if(t==="top")return d.jsx(ld,{className:TP,"data-form-renderer":"workflow-tabs",children:e.map(c=>d.jsx(cd,{value:c.step_id,className:FP,"data-form-renderer":"workflow-tab",children:c.step_name},c.step_id))});const i=t==="left"||t==="right",a=i?{...r?{width:r,flexShrink:0}:{},...n?{top:o}:{},maxHeight:s}:void 0;return d.jsx(ld,{className:H("bg-transparent p-0 gap-0 rounded-none h-auto",i?H("flex flex-col items-stretch shrink-0 self-start z-10 bg-background overflow-y-auto",n&&"sticky",t==="left"?"border-r pr-2":"border-l pl-2",!r&&"w-56"):H("w-full justify-start",t==="bottom"?"border-t pt-0":"border-b")),style:a,"data-form-renderer":"workflow-tabs","data-form-renderer-nav-position":t,children:e.map(c=>d.jsx(cd,{value:c.step_id,className:H("rounded-none shadow-none data-[state=active]:shadow-none text-sm",i?H("justify-start w-full px-3 py-2.5 border-b-0",t==="left"?"border-l-2 border-transparent data-[state=active]:border-primary":"border-r-2 border-transparent data-[state=active]:border-primary"):H("border-b-2 border-transparent data-[state=active]:border-primary",t==="bottom"&&"border-t-2 border-b-0 data-[state=active]:border-t-primary")),"data-form-renderer":"workflow-tab",children:c.step_name},c.step_id))})},OP=new Set(["top","bottom","left","right"]),Os={position:"top",sticky:!0,stickyOffset:"1rem",sidebarMaxHeight:"calc(100vh - 6rem)"};function ib(e){return typeof e=="string"&&OP.has(e)}function IP(...e){for(const t of e){const r=t?.ui_config?.stepsNavigation;if(r&&typeof r=="object")return r}}function dd(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function ud(e={},...t){const r=IP(...t),n=(e.position&&ib(e.position)?e.position:void 0)??(r?.position&&ib(r.position)?r.position:Os.position),o=dd(e.sidebarWidth,r?.sidebarWidth),s=typeof e.sticky=="boolean"?e.sticky:typeof r?.sticky=="boolean"?r.sticky:Os.sticky,i=dd(e.stickyOffset,r?.stickyOffset)??Os.stickyOffset,a=dd(e.sidebarMaxHeight,r?.sidebarMaxHeight)??Os.sidebarMaxHeight;return{position:n,sidebarWidth:o,sticky:s,stickyOffset:i,sidebarMaxHeight:a}}function MP(e,...t){return ud({position:e},...t).position}function LP(e){return e==="left"||e==="right"}function Ft({className:e="",...t}){return d.jsx("div",{"data-slot":"skeleton","data-form-renderer":"skeleton",className:`animate-pulse rounded-md bg-neutral-200 dark:bg-neutral-700 ${e}`.trim(),...t})}function DP({className:e="",position:t="top"}){if(t==="left"||t==="right")return d.jsxs("div",{className:`flex gap-4 ${t==="right"?"flex-row-reverse":"flex-row"} ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:[d.jsxs("div",{className:`flex w-56 shrink-0 flex-col gap-1 border-neutral-200 dark:border-neutral-700 py-1 ${t==="left"?"border-r pr-2":"border-l pl-2"}`,children:[d.jsx(Ft,{className:"h-10 w-full rounded-none"}),d.jsx(Ft,{className:"h-10 w-full rounded-none"}),d.jsx(Ft,{className:"h-10 w-full rounded-none"})]}),d.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-4 py-4",children:[d.jsx(Ft,{className:"h-4 w-32"}),d.jsx(Ft,{className:"h-10 w-full"}),d.jsx(Ft,{className:"h-4 w-40"}),d.jsx(Ft,{className:"h-10 w-full"}),d.jsx(Ft,{className:"h-24 w-full"})]})]});const n=d.jsxs("div",{className:`flex w-full gap-0 ${t==="bottom"?"border-t border-neutral-200 pt-0 dark:border-neutral-700":"border-b border-neutral-200 dark:border-neutral-700"}`,children:[d.jsx(Ft,{className:"h-10 w-24 rounded-none"}),d.jsx(Ft,{className:"h-10 w-28 rounded-none ml-1"}),d.jsx(Ft,{className:"h-10 w-20 rounded-none ml-1"})]}),o=d.jsxs("div",{className:"flex flex-col gap-4 py-4",children:[d.jsx(Ft,{className:"h-4 w-32"}),d.jsx(Ft,{className:"h-10 w-full"}),d.jsx(Ft,{className:"h-4 w-40"}),d.jsx(Ft,{className:"h-10 w-full"}),d.jsx(Ft,{className:"h-4 w-36"}),d.jsx(Ft,{className:"h-24 w-full"})]});return d.jsx("div",{className:`flex flex-col gap-4 ${e}`.trim(),"data-form-renderer":"workflow-steps-view-skeleton",children:t==="bottom"?d.jsxs(d.Fragment,{children:[o,n]}):d.jsxs(d.Fragment,{children:[n,d.jsx("div",{className:"mt-4",children:o})]})})}function BP(){return d.jsxs("div",{className:"flex flex-col gap-4 py-4","data-form-renderer":"form-loading-skeleton",children:[d.jsx(Ft,{className:"h-4 w-28"}),d.jsx(Ft,{className:"h-10 w-full"}),d.jsx(Ft,{className:"h-4 w-36"}),d.jsx(Ft,{className:"h-10 w-full"}),d.jsx(Ft,{className:"h-4 w-24"}),d.jsx(Ft,{className:"h-20 w-full"})]})}const $P=3e4,jP=10*6e4,zP=9e4,UP=15*6e4;function VP(e){return e!=null&&"on_success"in e&&e.on_success!=null}function HP(e,t){if(!t||typeof t!="object")return e;let r=e;return Object.entries(t).forEach(([n,o])=>{o!=null&&o!==""&&(r=r.replace(new RegExp(`\\{${n}\\}`,"g"),String(o)))}),r}const ab=({getWorkflowState:e,moduleId:t,tenantId:r,submissionContext:n,initialValues:o={},getAuthHeaders:s,onSuccess:i,bootstrapFeatureId:a,subjectUserId:c,viewStepId:u,clientId:f,className:l,onWorkflowSubmitResult:p,viewerContext:g,getViewerContext:m,dark:h=!1,themeVars:y,stepsNavigationPosition:S,stepsNavigationSidebarWidth:w,stepsNavigationSticky:A,stepsNavigationStickyOffset:x,stepsNavigationSidebarMaxHeight:F,workflowModalHandlers:N})=>{const k=Nn.useQueryClient(),T=v.useMemo(()=>[c??"",u??"",f??""],[c,u,f]),P=v.useMemo(()=>({moduleId:t,tenantId:r,subjectUserId:c,viewStepId:u,clientId:f}),[t,r,c,u,f]),[E,C]=v.useState([]),[I,W]=v.useState(null),[M,z]=v.useState(null),[V,X]=v.useState(null),[L,B]=v.useState({}),D=v.useRef(null),K=v.useRef(null),ae=v.useRef(null),j=v.useRef(null),U=v.useMemo(()=>E&&Array.isArray(E)?E.filter(ve=>ve.feature_id):[],[E]),le=Nn.useQuery({queryKey:["workflow-steps",t,a??"",r??"",T[0],T[1],T[2]],queryFn:()=>e({...P,featureId:a}),staleTime:$P,gcTime:jP}),oe=le.isPending,G=le.error?le.error instanceof Error?le.error.message:"Failed to load workflow steps":null;v.useEffect(()=>{const ve=le.data;if(!ve||E.length>0)return;const ce=ve.steps&&Array.isArray(ve.steps)?ve.steps:[];C(ce);const J=ce.filter($=>$.feature_id);if(J.length>0){const $=ve.current_step_id,fe=$&&J.some(it=>it.step_id===$);W(fe?$:J[0].step_id)}},[le.data,E.length,a]);const ie=v.useMemo(()=>{if(!I)return;const ve=E.find(J=>J.step_id===I),ce=D.current===I;return ve?.feature_id??(ce?j.current:void 0)??void 0},[I,E]),Ce=Nn.useQuery({queryKey:["workflow-step",t,ie??"",r??"",T[0],T[1],T[2]],queryFn:()=>e({...P,featureId:ie}),enabled:!!ie,staleTime:zP,gcTime:UP,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),ee=Ce.isPending,ne=Ce.error?Ce.error instanceof Error?Ce.error.message:"Failed to load form":null,he=v.useMemo(()=>ud({position:S,sidebarWidth:w,sticky:A,stickyOffset:x,sidebarMaxHeight:F},M,le.data),[S,w,A,x,F,M,le.data]),Ie=he.position,Ue=LP(Ie);v.useEffect(()=>{!Ce.data||D.current===I||(z(Ce.data),X(null),D.current=null,j.current=null)},[Ce.data,I]),v.useEffect(()=>{X(ne)},[ne]),v.useEffect(()=>{ie===void 0&&D.current!==I&&(z(null),X(null),D.current=null,j.current=null)},[ie,I]);const re=v.useMemo(()=>{const ve=M?.form;if(!ve)return null;const ce=(r??nn()??"").trim()||"default",J=Ry({scope:ce,formId:ve._id,version:ve.version});return J?.value?J.value:Ag(M,n)},[M,n,r]),ge=v.useMemo(()=>{const ve=M?.BFF_submit_api;if(!ve?.url)return;let ce=ve.url;if(ce.startsWith("http://")||ce.startsWith("https://"))try{const fe=new URL(ce);ce=fe.pathname+fe.search}catch{}const J=s?.()??{},$={...ve.headers||{},"Content-Type":"application/json",...J};return{...ve,url:ce,headers:$}},[M?.BFF_submit_api,s]),Se=v.useMemo(()=>re?{...re,status:"published",...ge&&{BFF_submit_api:ge}}:null,[re,ge]);v.useEffect(()=>{if(!re?.id)return;const ve=(r??nn()??"").trim()||"default";Gy({scope:ve,formId:re.id,version:re.version},re)},[re,r]);const pt=v.useMemo(()=>{if(!re)return null;const ve=Us({config:re.config,layout:re.layout},null);if(!ve)return null;const ce=ve.rows,J=ve.columns,$={verticalSpacing:ve.verticalSpacing??ve.spacing??"16px",horizontalSpacing:ve.horizontalSpacing??ve.spacing??"16px",rowHeight:ve.rowHeight??Hn};let fe=1;if(Array.isArray(re.fields))for(const Te of re.fields){const Ye=Te?.position,Me=typeof Ye?.order=="number"?Ye.order:0,xe=typeof Ye?.rowSpan=="number"?Ye.rowSpan:1;fe=Math.max(fe,Me+xe)}return{rows:Math.min(ce,Math.max(1,fe)),columns:J,verticalSpacing:$.verticalSpacing,horizontalSpacing:$.horizontalSpacing,rowHeight:$.rowHeight}},[re]),Dt=v.useMemo(()=>{const ce=Se?.config?.theme?.cssVariables;if(!(!ce&&!y))return{...ce??{},...y??{}}},[Se?.config,y]),Bt=v.useCallback(()=>{k.invalidateQueries({queryKey:["workflow-steps",t]}),k.invalidateQueries({queryKey:["workflow-step",t]})},[k,t]),Pt=v.useCallback(ve=>{if(VP(ve)){const fe=ve.on_success,it=fe?.action;if(it==="redirect"&&fe?.redirect_url){const Te=HP(fe.redirect_url.trim(),n);window.location.href=Te;return}if(it==="move"){const Te=fe?.next_step_id,Ye=fe?.next_step_form;if(Te&&Ye){D.current=null,j.current=null;const Me=Ye.featureId??fe?.next_step_form_id??Ye._id;k.removeQueries({queryKey:["workflow-step",t,Me,r??"",T[0],T[1],T[2]]}),Bt(),C(xe=>xe.some(We=>We.step_id===Te)?xe:[...xe,{step_id:Te,step_name:Ye.name||"Next step",feature_id:Me}]),z(null),W(Te),i?.();return}return}if(it==="stay"){Bt(),i?.();return}}const ce=ve;ce.steps&&Array.isArray(ce.steps)&&C(ce.steps);const J=(ce.steps&&Array.isArray(ce.steps)?ce.steps:E).filter(fe=>fe.feature_id),$=ce.current_step_id;$&&J.some(fe=>fe.step_id===$)?W($):J.length>0&&W(J[0].step_id),z(null),Bt(),i?.(),p?.(ce)},[k,t,r,i,p,E,n,T,Bt]),Ar=v.useCallback(async ve=>M?.BFF_submit_api?(i?.(),{success:!0,message:"Saved successfully"}):{success:!1,message:"Submit not configured"},[M?.BFF_submit_api,i]),Nt=v.useCallback((ve,ce)=>{},[]),Cr=v.useCallback(ve=>{},[]);if(oe)return d.jsx(DP,{className:l,position:S??he.position});if(G)return d.jsx("div",{className:H("rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",l),children:G});if(U.length===0)return d.jsx("div",{className:H("py-12 text-center text-sm text-muted-foreground",l),children:"No workflow steps configured."});const Xe=M?.step_blocked_message;return d.jsx("div",{className:H($a,h&&"dark","flex flex-col gap-4",l),style:Dt,"data-form-renderer":"workflow-steps-view",children:d.jsxs(ob,{value:I??"",onValueChange:ve=>W(ve),className:H(Ie!=="top"&&"gap-4",Ue&&"flex-row items-start",Ie==="right"&&"flex-row-reverse",Ie==="bottom"&&"flex-col-reverse"),orientation:Ue?"vertical":"horizontal",children:[d.jsx(PP,{steps:U,position:Ie,sidebarWidth:he.sidebarWidth,sticky:he.sticky,stickyOffset:he.stickyOffset,sidebarMaxHeight:he.sidebarMaxHeight}),U.map(ve=>d.jsx(sb,{value:ve.step_id,className:H("outline-none",Ue?"mt-0 flex-1 min-w-0":"mt-4"),children:ve.step_id!==I?null:ee?d.jsx(BP,{}):V?d.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:V}):Xe&&!M?.form?d.jsx("div",{className:H("rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200",l),"data-form-renderer":"workflow-step-blocked",children:Xe}):Se?.fields?.length?d.jsxs("div",{className:"py-4 [&_*]:box-border",children:[Xe?d.jsx("div",{className:H("mb-4 rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200"),"data-form-renderer":"workflow-step-blocked",children:Xe}):null,(()=>{const ce=K.current!==I||ae.current!==(Se?.id??null);if(I&&Se&&ce){K.current=I,ae.current=Se.id??null;const J=Kn.getState();J.setSchema(Se,{forceReset:!0});const $=Kn.getState().values;J.setValues({...$,...o})}return null})(),d.jsx(Ps,{schema:Se,gridLayout:pt,omitRootWrapper:!0,moduleId:t,workflowModalHandlers:N,getAuthHeaders:s,submissionContext:n,initialValues:o,workflowStepId:I??void 0,viewerContext:g,getViewerContext:m,onSubmit:Ar,onChange:Nt,onValidationError:Cr,onClose:()=>{},mode:"fill",unstyled:!0,onWorkflowSubmitResult:Pt,initialExtraSubmitPayload:Object.keys(L).length>0?L:void 0,onExtraSubmitPayloadChange:ce=>{if(ce&&typeof ce=="object"){const J={};ce.context_user_id!=null&&(J.context_user_id=ce.context_user_id),ce.id!=null&&(J.id=ce.id),ce.batch_id!=null&&(J.batch_id=ce.batch_id),ce.admission_batch_id!=null&&(J.admission_batch_id=ce.admission_batch_id),ce.program_id!=null&&(J.program_id=ce.program_id),Object.keys(J).length>0&&B($=>({...$,...J}))}}},Se.id)]}):d.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No form schema available for this step."})},ve.step_id))]})})},wa=new Map;function WP(e){if(e){wa.delete(e);return}wa.clear()}async function Sa(e,t,r){const n=wa.get(t);if(n!==void 0)return n;const o=e.replace(/\/$/,""),i=!!(await Qt.get(`${o}/${encodeURIComponent(t)}/meta`,{headers:r})).data?.standalone_workflow;return wa.set(t,i),i}function xa(e){const t={...e.getAuthHeaders?.()??{}};return e.clientId&&(t["x-client-id"]=e.clientId),e.userId&&(t["x-user-id"]=e.userId),t}function fd(e,t){Object.entries(t).forEach(([r,n])=>{n&&e.set(r,n)})}function lb(e){const t=e.bffWorkflowsBasePath.replace(/\/$/,""),r=()=>xa({getAuthHeaders:e.getAuthHeaders,clientId:e.clientId,userId:e.userId}),n=o=>o?.trim()||e.moduleId?.trim()||"";return{async getWorkflowStateById({workflowId:o,moduleId:s,entryStepId:i}){const a=o.trim(),c=r();if(await Sa(t,a,c)){const p=new URLSearchParams;e.clientId&&p.set("client_id",e.clientId),e.userId&&p.set("user_id",e.userId),fd(p,{entry_step_id:i});const g=p.toString();return(await Qt.get(`${t}/${encodeURIComponent(a)}/standalone-state${g?`?${g}`:""}`,{headers:c})).data}const f=new URLSearchParams;return f.set("module_id",n(s)),e.clientId&&f.set("client_id",e.clientId),e.userId&&f.set("user_id",e.userId),fd(f,{entry_step_id:i}),(await Qt.get(`${t}/${encodeURIComponent(a)}/state?${f.toString()}`,{headers:c})).data},async navigateWorkflowStep({workflowId:o,moduleId:s,targetStepId:i}){const a=o.trim(),c=r();if(await Sa(t,a,c))return(await Qt.post(`${t}/${encodeURIComponent(a)}/standalone-navigate-step`,{workflow_id:a,target_step_id:i},{headers:c})).data;const f=n(s);return(await Qt.post(`${t}/modules/${encodeURIComponent(f)}/navigate-step`,{workflow_id:a,target_step_id:i},{headers:c})).data}}}async function cb(e){const t=e.bffWorkflowsBasePath.replace(/\/$/,""),r=xa({getAuthHeaders:e.getAuthHeaders,clientId:e.clientId,userId:e.subjectUserId});if(e.workflowId?.trim()){const i=e.workflowId.trim();if(await Sa(t,i,r)){const c=new URLSearchParams;e.clientId&&c.set("client_id",e.clientId),e.subjectUserId&&c.set("user_id",e.subjectUserId),fd(c,{step_id:e.viewStepId});const u=c.toString();return(await Qt.get(`${t}/${encodeURIComponent(i)}/standalone-state${u?`?${u}`:""}`,{headers:r})).data}}const n=new URLSearchParams;n.set("module_id",e.moduleId),e.featureId&&n.set("feature_id",e.featureId),e.tenantId&&n.set("tenant_id",e.tenantId),e.subjectUserId&&n.set("user_id",e.subjectUserId),e.viewStepId&&n.set("step_id",e.viewStepId),e.clientId&&n.set("client_id",e.clientId);const o=e.workflowId?.trim()?`${t}/${encodeURIComponent(e.workflowId.trim())}/state?${n.toString()}`:`${t}/modules/${encodeURIComponent(e.moduleId)}/state?${n.toString()}`;return(await Qt.get(o,{headers:r})).data}function RP(e){return typeof e=="object"&&e!==null&&"apiEndpoint"in e}function GP({formSchema:e}){const t=v.useMemo(()=>{if(!e)return[];const s=[];(!e.name||e.name.trim()==="")&&s.push({id:"form-name-required",type:"error",message:"Form name is required"});const i=new Set,a=new Set;e.fields.forEach((f,l)=>{const p=`field-${f.id}`;if(a.has(f.id)&&s.push({id:`${p}-duplicate-id`,type:"error",message:`Field "${f.label||f.name||`Field ${l+1}`}" has a duplicate ID`,fieldId:f.id}),a.add(f.id),f.name&&i.has(f.name)&&s.push({id:`${p}-duplicate-name`,type:"error",message:`Field "${f.label||f.name}" has a duplicate name: "${f.name}"`,fieldId:f.id}),f.name&&i.add(f.name),(!f.label||f.label.trim()==="")&&s.push({id:`${p}-missing-label`,type:"warning",message:`Field "${f.name||f.id}" is missing a label`,fieldId:f.id}),(!f.name||f.name.trim()==="")&&s.push({id:`${p}-missing-name`,type:"error",message:`Field "${f.label||f.id}" is missing a field name`,fieldId:f.id}),f.name&&!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(f.name)&&s.push({id:`${p}-invalid-name`,type:"error",message:`Field "${f.label||f.name}" has an invalid name. Use only letters, numbers, and underscores.`,fieldId:f.id}),["select","multiselect","radio","checkboxgroup"].includes(f.type)){const h=f.properties;(!h?.options||h.options.length===0)&&s.push({id:`${p}-no-options`,type:"warning",message:`Field "${f.label||f.name}" has no options defined`,fieldId:f.id})}f.parentId&&(e.fields.some(y=>y.id===f.parentId)||s.push({id:`${p}-orphaned`,type:"error",message:`Field "${f.label||f.name}" references a non-existent parent`,fieldId:f.id}));const m=(h,y)=>{if(y.has(h))return!0;y.add(h);const S=e.fields.find(w=>w.id===h);return S?.parentId?m(S.parentId,y):!1};f.parentId&&m(f.id,new Set)&&s.push({id:`${p}-circular-reference`,type:"error",message:`Field "${f.label||f.name}" has a circular parent reference`,fieldId:f.id})}),e.config.workflowTrigger?.workflowId&&(e.fields.some(l=>l.validation?.some(p=>p.type==="required"))||s.push({id:"workflow-no-required-fields",type:"info",message:"Form linked to workflow but has no required fields"}));const c=e.fields.filter(f=>!f.parentId),u=new Map;return c.forEach(f=>{const l=f.position.order;u.has(l)||u.set(l,[]),u.get(l).push(f)}),u.forEach((f,l)=>{f.length>3&&s.push({id:`row-${l}-too-many-fields`,type:"warning",message:`Row ${l+1} has ${f.length} fields (maximum recommended is 3)`})}),s},[e]),r=v.useMemo(()=>t.filter(s=>s.type==="error"),[t]),n=v.useMemo(()=>t.filter(s=>s.type==="warning"),[t]),o=v.useMemo(()=>r.length===0,[r]);return{issues:t,errors:r,warnings:n,isValid:o}}function KP({field:e,value:t,allValues:r,validateOnChange:n=!1,validateOnBlur:o=!0,debounceMs:s=WF}){const[i,a]=v.useState(),[c,u]=v.useState(!1),f=v.useRef(void 0),l=v.useRef(t),p=v.useCallback(async()=>{if(!e.validation||e.validation.length===0){a(void 0);return}u(!0);let S;for(const w of e.validation){const A=rn(t,w,r);if(typeof A=="string"){S=A;break}}return a(S),u(!1),S},[e.validation,t,r]),g=v.useCallback(()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{p()},s)},[p,s]);v.useEffect(()=>(n&&l.current!==t&&g(),l.current=t,()=>{f.current&&clearTimeout(f.current)}),[t,n,g]);const m=v.useCallback(()=>{o&&p()},[o,p]),h=v.useCallback(()=>{a(void 0)},[]),y=v.useCallback(S=>{a(S)},[]);return{error:i,isValidating:c,validate:p,handleBlur:m,clearError:h,setCustomError:y}}const db="—";function er(){return{kind:"static",value:db}}function qP(){return _u({currencySymbol:"₹",emptyDisplay:db,columns:[{id:"col_tariff",key:"tariff_type",label:"Tariff type",format:"text",align:"left"},{id:"col_service",key:"service",label:"Service",format:"text",align:"left"},{id:"col_unit",key:"unit_price",label:"Unit price",format:"currency",align:"right"},{id:"col_disc_pct",key:"discount_pct",label:"Discount (%)",format:"percent",align:"right"},{id:"col_disc_amt",key:"discount_amount",label:"Discount (₹)",format:"currency",align:"right"},{id:"col_net",key:"net_price",label:"Net price",format:"currency",align:"right"},{id:"col_tax",key:"tax_pct",label:"Tax (%)",format:"percent",align:"right"},{id:"col_total",key:"total",label:"Total",format:"currency",align:"right"}],rowSlots:[{kind:"static",row:{id:"registration_fee",label:"Registration fee",cells:{tariff_type:{kind:"label"},service:er(),unit_price:{kind:"api",path:"unit_price"},discount_pct:{kind:"input",inputType:"number"},discount_amount:{kind:"formula",expression:"cell('unit_price') * cell('discount_pct') / 100"},net_price:{kind:"formula",expression:"cell('unit_price') - cell('discount_amount')"},tax_pct:{kind:"api",path:"tax_pct"},total:{kind:"formula",expression:"cell('net_price') * (1 + cell('tax_pct') / 100)"}}}},{kind:"dynamic",block:{id:"line_items",apiArrayPath:"items",rowIdField:"id",cells:{tariff_type:er(),service:{kind:"api",path:"service"},unit_price:{kind:"api",path:"unit_price"},discount_pct:er(),discount_amount:{kind:"formula",expression:"cell('unit_price') * cell('discount_pct') / 100"},net_price:{kind:"formula",expression:"cell('unit_price') - cell('discount_amount')"},tax_pct:{kind:"api",path:"tax_pct"},total:{kind:"formula",expression:"cell('net_price') * (1 + cell('tax_pct') / 100)"}}}},{kind:"static",row:{id:"all_items_summary",label:"All items summary",cells:{tariff_type:{kind:"label"},service:er(),unit_price:{kind:"formula",expression:"SUM('unit_price', 'data')"},discount_pct:er(),discount_amount:{kind:"formula",expression:"SUM('discount_amount', 'data')"},net_price:{kind:"formula",expression:"SUM('net_price', 'data')"},tax_pct:er(),total:{kind:"formula",expression:"SUM('total', 'data')"}}}},{kind:"static",row:{id:"invoice_discount",label:"Invoice discount",cells:{tariff_type:{kind:"label"},service:er(),unit_price:er(),discount_pct:er(),discount_amount:{kind:"input",inputType:"number"},net_price:er(),tax_pct:er(),total:er()}}},{kind:"static",row:{id:"grand_total",label:"Grand total",cells:{tariff_type:{kind:"label"},service:er(),unit_price:er(),discount_pct:er(),discount_amount:er(),net_price:er(),tax_pct:er(),total:{kind:"formula",expression:"SUM('total', 'data') - cellInRow('invoice_discount', 'discount_amount')"}}}}]})}const YP={text:{type:"text",label:"Text Input",icon:"Type",category:"input",description:"Single line text input",defaultProps:{label:"Text Field",name:"text_field",placeholder:"Enter text..."}},number:{type:"number",label:"Number Input",icon:"Hash",category:"input",description:"Numeric input with optional constraints",defaultProps:{label:"Number Field",name:"number_field",placeholder:"0",properties:{min:0,step:1}}},email:{type:"email",label:"Email",icon:"Mail",category:"input",description:"Email address input with validation",defaultProps:{label:"Email",name:"email_field",placeholder:"example@domain.com",validation:[{type:"email"}]}},phone:{type:"phone",label:"Phone",icon:"Phone",category:"input",description:"Phone number input",defaultProps:{label:"Phone Number",name:"phone_field",placeholder:"+91 12345 67890"}},otp:{type:"otp",label:"OTP",icon:"ShieldCheck",category:"input",description:"One-time password with separate digit boxes",defaultProps:{label:"OTP",name:"otp_field",properties:{otpLength:4,numericOnly:!0},validation:[{type:"required",message:"Please enter the OTP"}]}},password:{type:"password",label:"Password",icon:"Lock",category:"input",description:"Secure password input",defaultProps:{label:"Password",name:"password_field",placeholder:"••••••••"}},url:{type:"url",label:"URL",icon:"Link",category:"input",description:"URL input with validation",defaultProps:{label:"URL",name:"url_field",placeholder:"https://example.com",validation:[{type:"url"}]}},date:{type:"date",label:"Date",icon:"Calendar",category:"datetime",description:"Date picker",defaultProps:{label:"Date",name:"date_field",placeholder:"Select date"}},time:{type:"time",label:"Time",icon:"Clock",category:"datetime",description:"Time picker",defaultProps:{label:"Time",name:"time_field",placeholder:"Select time"}},datetime:{type:"datetime",label:"Date & Time",icon:"CalendarClock",category:"datetime",description:"Combined date and time picker",defaultProps:{label:"Date & Time",name:"datetime_field",placeholder:"Select date and time"}},daterange:{type:"daterange",label:"Date Range",icon:"CalendarRange",category:"datetime",description:"Select a range of dates",defaultProps:{label:"Date Range",name:"daterange_field",placeholder:"Select date range"}},select:{type:"select",label:"Dropdown",icon:"ChevronDown",category:"selection",description:"Single selection dropdown",defaultProps:{label:"Select",name:"select_field",placeholder:"Select an option",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],searchable:!0,clearable:!0}}},multiselect:{type:"multiselect",label:"Multi Select",icon:"ListChecks",category:"selection",description:"Multiple selection dropdown",defaultProps:{label:"Multi Select",name:"multiselect_field",placeholder:"Select options",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],searchable:!0}}},radio:{type:"radio",label:"Radio Group",icon:"CircleDot",category:"selection",description:"Single selection radio buttons",defaultProps:{label:"Radio Group",name:"radio_field",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}]}}},checkbox:{type:"checkbox",label:"Checkbox",icon:"CheckSquare",category:"selection",description:"Single checkbox for boolean values",defaultProps:{label:"I agree to the terms",name:"checkbox_field"}},toggle:{type:"toggle",label:"Toggle",icon:"ToggleLeft",category:"selection",description:"Toggle switch with configurable text values",defaultProps:{label:"Toggle",name:"toggle_field",description:"Toggle to switch between states",properties:{onValue:"On",offValue:"Off"}}},checkboxgroup:{type:"checkboxgroup",label:"Checkbox Group",icon:"CheckSquare",category:"selection",description:"Multiple checkboxes for selecting multiple values",defaultProps:{label:"Checkbox Group",name:"checkboxgroup_field",properties:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}]}}},selectablelist:{type:"selectablelist",label:"Selectable List",icon:"ListChecks",category:"selection",description:"List from response or context; select all or specific items. Value = selected array.",defaultProps:{label:"Recipients",name:"recipients",properties:{dataSourceContextKey:"recipients",labelField:"name",valueField:"email",showSelectAll:!0,selectAllByDefault:!0}}},asyncsearch:{type:"asyncsearch",label:"Async Search",icon:"Search",category:"selection",description:"Typeahead search against an API; submitted value is the selected option value.",defaultProps:{label:"Search",name:"async_search",placeholder:"Type to search…",properties:{apiEndpoint:"/api/form-builder/search",apiMethod:"GET",searchQueryParam:"q",searchSchedule:"debounce",intervalMs:300,minQueryLength:0,clearable:!0}}},terms:{type:"terms",label:"Terms & Conditions",icon:"FileText",category:"special",description:"Terms and conditions confirmation checkbox",defaultProps:{label:"I confirm that the details are true to my knowledge",name:"terms_conditions",validation:[{type:"required"}]}},textarea:{type:"textarea",label:"Text Area",icon:"AlignLeft",category:"rich",description:"Multi-line text input",defaultProps:{label:"Text Area",name:"textarea_field",placeholder:"Enter your text here...",properties:{minLength:0,maxLength:1e3}}},richtext:{type:"richtext",label:"Rich Text",icon:"FileText",category:"rich",description:"Rich text editor with formatting",defaultProps:{label:"Rich Text",name:"richtext_field"}},file:{type:"file",label:"File Upload",icon:"Upload",category:"rich",description:"File upload with drag and drop",defaultProps:{label:"File Upload",name:"file_field",properties:{accept:["image/*","application/pdf"],maxSize:5*1024*1024}}},camera:{type:"camera",label:"Use camera",icon:"Camera",category:"rich",description:"Take a photo with your camera",defaultProps:{label:"Take photo",name:"camera_field",properties:{accept:["image/*"],maxSize:5*1024*1024,multiple:!1}}},photoChoice:{type:"photoChoice",label:"Photo (upload or camera)",icon:"ImagePlus",category:"rich",description:"Upload a file or capture with the camera",defaultProps:{label:"Photo",name:"photo_choice_field",properties:{accept:["image/*"],maxSize:5*1024*1024,maxFiles:1}}},signature:{type:"signature",label:"Signature",icon:"Pencil",category:"rich",description:"Digital signature capture",defaultProps:{label:"Signature",name:"signature_field"}},rating:{type:"rating",label:"Rating",icon:"Star",category:"rich",description:"Star rating input",defaultProps:{label:"Rating",name:"rating_field",properties:{max:5,allowHalf:!1,icon:"star"}}},slider:{type:"slider",label:"Slider",icon:"SlidersHorizontal",category:"rich",description:"Numeric slider input",defaultProps:{label:"Slider",name:"slider_field",properties:{min:0,max:100,step:1,showValue:!0}}},table:{type:"table",label:"Table",icon:"Table",category:"special",description:"Repeatable table rows",defaultProps:{label:"Table",name:"table_field",properties:{columns:[],minRows:1,maxRows:10,allowAddRow:!0,allowDeleteRow:!0}}},billingGrid:{type:"billingGrid",label:"Billing Grid",icon:"Receipt",category:"special",description:"Configurable billing/tariff grid with formulas and API line items",defaultProps:{label:"Billing",name:"billing",properties:qP()}},aadhaar:{type:"aadhaar",label:"Aadhaar",icon:"CreditCard",category:"special",description:"Indian Aadhaar number input",defaultProps:{label:"Aadhaar Number",name:"aadhaar_field",placeholder:"XXXX XXXX XXXX"}},section:{type:"section",label:"Section",icon:"LayoutPanelTop",category:"container",description:"Group fields in a collapsible section",defaultProps:{label:"Section",name:"section",properties:{collapsible:!0,defaultCollapsed:!1,columns:1}}},group:{type:"group",label:"Group",icon:"Group",category:"container",description:"Group fields without visual separator",defaultProps:{label:"Group",name:"group"}},columns:{type:"columns",label:"Columns",icon:"Columns",category:"container",description:"Multi-column layout",defaultProps:{label:"Columns",name:"columns",properties:{columns:2}}},divider:{type:"divider",label:"Divider",icon:"Minus",category:"visual",description:"Horizontal line separator",defaultProps:{label:"",name:"divider"}},header:{type:"header",label:"Header",icon:"Heading",category:"visual",description:"Section header text (full row, configurable size)",defaultProps:{label:"Header",name:"header",properties:{headingLevel:"h3",showHorizontalLine:!0}}},sectionHeading:{type:"sectionHeading",label:"Section Heading",icon:"Heading",category:"visual",description:"Heading inside a grid box with configurable position and size",defaultProps:{label:"Section Heading",name:"section_heading",properties:{position:"top-left",headingLevel:"h3",showHorizontalLine:!0}}},spacer:{type:"spacer",label:"Spacer",icon:"Space",category:"visual",description:"Empty space for padding",defaultProps:{label:"",name:"spacer"}},textLabel:{type:"textLabel",label:"Text Label",icon:"Tag",category:"visual",description:"Standalone label text (no input)",defaultProps:{label:"Label",name:"text_label"}},status:{type:"status",label:"Status",icon:"ListChecks",category:"visual",description:"Populate status from Status API; label + response key; true = completed",defaultProps:{label:"Admission Status",name:"status_field",properties:{source:"api",statuses:[{label:"Registered",key:"registered"},{label:"Form Submitted",key:"formSubmitted"},{label:"Documents Verification",key:"documentsVerification"},{label:"Photos Clicked",key:"photosClicked"},{label:"Fitness Verification",key:"fitnessVerification"},{label:"Payment Completed",key:"paymentCompleted"},{label:"Hostel Allotted",key:"hostelAllotted"},{label:"Admission Completed",key:"admissionCompleted"}],showStatusText:!1,statusTextPath:"admissionStatus",showCurrentIndicator:!0}}},button:{type:"button",label:"Button",icon:"MousePointerClick",category:"special",description:"Clickable button element",defaultProps:{label:"Button",name:"button_field",properties:{variant:"default",size:"default",action:"download"}}},editButton:{type:"editButton",label:"Edit Button",icon:"Pencil",category:"special",description:"Toggle edit mode: enable/disable or show/hide other fields and buttons (no API call)",defaultProps:{label:"Edit",name:"edit_button",properties:{buttonText:"Edit",variant:"outline",size:"default",hideLabel:!1,rules:[]}}},addmore:{type:"addmore",label:"Add More",icon:"Plus",category:"special",description:"Duplicate linked fields as a new runtime block",defaultProps:{label:"Add More",name:"addmore_field",properties:{linkedFieldNames:[],linkedSectionIds:[],variant:"outline",size:"default"}}},customizeSections:{type:"customizeSections",label:"Customise Sections",icon:"ListFilter",category:"special",description:"Show or hide UI sections defined by Section Heading fields",defaultProps:{label:"Customise Sections",name:"customize_sections",properties:{sectionHeadingNames:[],defaultHiddenSectionNames:[],variant:"outline",size:"default",buttonText:"Customise sections",menuTitle:"VISIBLE SECTIONS"}}}},ub={padding:"md",showBorder:!1};function fb(e,t){const r="full";return e?{padding:e.padding??ub.padding,maxWidth:e.maxWidth??r,showBorder:e.showBorder??ub.showBorder}:{padding:"md",maxWidth:r,showBorder:!1}}function XP(e){switch(e??"md"){case"none":return"";case"sm":return"p-3";case"lg":return"p-6 md:p-8";default:return"p-4 md:p-6"}}function JP(e,t){if(t==="full-bleed")return"w-full max-w-none";switch(e??"full"){case"full":return"w-full max-w-none";case"sm":return"mx-auto w-full max-w-screen-sm";case"md":return"mx-auto w-full max-w-screen-md";case"lg":return"mx-auto w-full max-w-screen-lg";case"xl":return"mx-auto w-full max-w-screen-xl";case"2xl":return"mx-auto w-full max-w-2xl";case"4xl":return"mx-auto w-full max-w-4xl";case"5xl":return"mx-auto w-full max-w-5xl";case"6xl":return"mx-auto w-full max-w-6xl";case"7xl":return"mx-auto w-full max-w-7xl";default:return"w-full max-w-none"}}function QP(e){switch(e){case"sidebar-main":return"grid grid-cols-1 gap-6 lg:grid-cols-[240px_1fr]";case"full-bleed":return"w-full";default:return"w-full"}}function ZP(e){const t=fb(e.container,e.layout);return H(QP(e.layout),JP(t.maxWidth,e.layout),XP(t.padding),t.showBorder&&"rounded-lg border border-border")}const Aa=1;function eO(){return{version:Aa,layout:"stack",container:{padding:"md",maxWidth:"full",showBorder:!1},dataBindings:[],widgets:[],filterGroups:[]}}function pb(e){return{...e,config:e.config??{},children:Array.isArray(e.children)?e.children.map(pb):void 0}}function tO(e){return{version:Aa,layout:e.layout??"stack",container:fb(e.container,e.layout),meta:e.meta,dataBindings:Array.isArray(e.dataBindings)?e.dataBindings:[],dataApis:e.dataApis??{},prepopulateApi:e.prepopulateApi,widgets:Array.isArray(e.widgets)?e.widgets.map(pb):[],filterGroups:Array.isArray(e.filterGroups)?e.filterGroups:[],eventHandlers:e.eventHandlers??[],navigation:e.navigation}}function rO(e){const t=e;return!t||typeof t!="object"?eO():(t.version!==Aa&&(t.version=Aa),tO(t))}const mb={};let hb=null;function nO(e){hb=e}function oO(){return(mb?.VITE_API_BASE_URL?.trim()||mb?.VITE_API_URL?.trim()||"").replace(/\/$/,"")}const Is=Ct.create({baseURL:oO()});Is.interceptors.request.use(e=>{const t=nn();t&&(e.params={...e.params,clientId:t}),typeof FormData<"u"&&e.data instanceof FormData&&delete e.headers["Content-Type"];let r=hb?.();if((!r||Object.keys(r).length===0)&&(r=ds()),r){const n=e.headers??{};for(const[o,s]of Object.entries(r))s!==void 0&&s!==""&&(n[o]=s);e.headers=n}return e});async function gb(e){const t=await Is.get("/api/page-builder/pages/resolve",{params:e}),r=t.data?.data??t.data;if(!r?.pageId)throw new Error("Page resolve failed: no pageId returned");return r}async function pd(e,t,r){const n=await Is.get(`/api/page-builder/pages/${e}/render`,{params:{clientId:t,...r!==void 0?{version:r}:{}}}),o=n.data?.data??n.data;if(!o?.schema)throw new Error("Page render failed: no schema returned");return o}async function md(e){const{clientId:t,api:r,context:n,filterState:o}=e,s=await Is.post(`/api/page-builder/clients/${t}/data-sources/execute`,{api:r,context:n,filterState:o});return s.data?.data??s.data}function sO(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t)){if(!o.trim())continue;const s=Ge(e,o);s!==void 0&&(r[n]=s)}return r}const hd=v.createContext(null);function iO(e,t){if(t.parentContext)return"idle";const r=e.prepopulateApi,n=String(t.clientIdProp??t.externalContext.clientId??"");return r?.enabled&&r.api?.path&&n?"loading":"idle"}function yb(e,t){const r={};for(const n of e){let o;switch(n.source){case"route.param":o=n.param?t[n.param]:void 0;break;case"route.query":o=n.param?t[n.param]:void 0;break;case"context.user":o=n.param?t.user?.[n.param]:t.user;break;case"context.client":o=n.param?t.client?.[n.param]:t.client??t.clientId;break;case"context.tenant":o=n.param?t.tenant?.[n.param]:t.tenant??t.tenantId;break;case"static":o=n.value;break;case"widget.state":o=n.sample;break;default:o=void 0}o===void 0&&n.sample!==void 0&&(o=n.sample),o!==void 0&&(r[n.key]=o)}return r}function aO({schema:e,context:t={},clientId:r,nestingDepth:n=0,onAction:o,getWorkflowState:s,workflowModalHandlers:i,getAuthHeaders:a,parentContext:c,children:u}){const[f,l]=v.useState(()=>c?c.filterGroups:{}),p=v.useRef(f);p.current=f;const[g,m]=v.useState({}),[h,y]=v.useState(()=>iO(e,{parentContext:c,clientIdProp:r,externalContext:t})),S=v.useRef(null),w=String(r??t.clientId??c?.clientId??""),A=JSON.stringify(t);v.useEffect(()=>{if(c)return;const E=e.prepopulateApi;if(!E?.enabled||!E.api?.path||!w){m({}),y("idle"),S.current=null;return}const C=JSON.stringify({path:E.api.path,method:E.api.method,queryParams:E.api.queryParams,headers:E.api.headers,bodyFields:E.api.bodyFields,auth:E.api.auth,mapping:E.contextMapping,bindings:e.dataBindings,context:A});if(S.current===C)return;let I=!1;return S.current=C,y("loading"),(async()=>{try{const W=yb(e.dataBindings??[],t),M={...t,...W},z=await md({clientId:w,api:E.api,context:M});if(I)return;const V=sO(z,E.contextMapping);m({...V,prepopulateResponse:z}),y("ready")}catch{I||(m({}),y("error"))}})(),()=>{I=!0,S.current=null}},[c,e.prepopulateApi,e.dataBindings,A,w]);const x=v.useMemo(()=>{if(c)return{...c.context,...t};const E=yb(e.dataBindings??[],t);return{...t,...E,...g}},[c,t,e.dataBindings,g]),F=String(r??x.clientId??c?.clientId??""),N=v.useCallback((E,C,I)=>{l(W=>({...W,[E]:{...W[E]??{},[C]:I}}))},[]),k=v.useCallback(E=>p.current[E]??{},[]),T=v.useCallback((E,C,I,W)=>{(o??c?.onAction)?.({...E,sourceWidgetId:C,event:I,payload:W})},[o,c?.onAction]),P=v.useMemo(()=>({schema:e,context:x,clientId:F,prepopulateStatus:c?.prepopulateStatus??h,nestingDepth:n,onAction:o??c?.onAction,getWorkflowState:s??c?.getWorkflowState,workflowModalHandlers:i??c?.workflowModalHandlers,getAuthHeaders:a??c?.getAuthHeaders,filterGroups:f,setFilterValue:N,getFilterGroup:k,dispatchAction:T}),[e,x,F,h,n,o,c?.onAction,s,c?.getWorkflowState,i,c?.workflowModalHandlers,a,c?.getAuthHeaders,f,N,k,T]);return d.jsx(hd.Provider,{value:P,children:u})}function $r(){const e=v.useContext(hd);if(!e)throw new Error("usePageContext must be used within PageContextProvider");return e}function lO(){return v.useContext(hd)}const cO=5,bb=1;function Vo(e){return Number.isFinite(e)?Math.min(cO,Math.max(bb,Math.round(e))):bb}function dO(e,t){const r=Vo(t),n=Array.from({length:r},()=>[]);return e.forEach((o,s)=>{const i=o.config,a=i.columnIndex!==void 0?Math.min(Math.max(0,i.columnIndex),r-1):s%r;n[a].push(o)}),n}function uO(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.round(e))):0}function fO(e,t){const r=Math.max(1,t),n=Math.min(100,Math.max(0,Math.round(e))),o=Math.floor(n/r),s=n-o*r;return Array.from({length:r},(i,a)=>o+(a<s?1:0))}function vb(e){return fO(100,Vo(e))}function pO(e){const t=e.trim(),r=/^(\d+(?:\.\d+)?)\s*%?$/.exec(t);return r?uO(Number(r[1])):null}function wb(e,t){const r=Vo(t),n=[];for(let s=0;s<r;s++){const i=pO(e?.[s]??"");if(i===null)return vb(r);n.push(i)}return n.reduce((s,i)=>s+i,0)!==100?vb(r):n}function mO(e){return e==="sm"?"gap-2":e==="lg"?"gap-6":"gap-4"}function Sb(e,t){return wb(t,Vo(e)).map(n=>`minmax(0, ${n}fr)`).join(" ")}function hO(e){return e.length?e.map(t=>`minmax(0, ${t}fr)`).join(" "):"minmax(0, 1fr)"}function gO(e,t,r,n){const o=Vo(t),s=dO(e,o),i=wb(r,o);if(!(n?.collapseEmpty!==!1))return{columns:s,gridTemplate:Sb(o,r),sourceIndices:s.map((p,g)=>g)};const c=s.map((p,g)=>({colChildren:p,index:g,percent:i[g]??0})).filter(p=>p.colChildren.length>0);if(c.length===0||c.length===s.length)return{columns:s,gridTemplate:Sb(o,r),sourceIndices:s.map((p,g)=>g)};const u=c.reduce((p,g)=>p+g.percent,0),f=c.map(p=>u>0?Math.round(p.percent/u*100):Math.round(100/c.length)),l=100-f.reduce((p,g)=>p+g,0);return l!==0&&f.length>0&&(f[0]+=l),{columns:c.map(p=>p.colChildren),gridTemplate:hO(f),sourceIndices:c.map(p=>p.index)}}function gd(e,t="solid"){return e?t==="dashed"?"rounded-md border border-dashed border-border":"rounded-md border border-border":""}function yO(e){return H(gd(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-3")}function bO(e){return H(gd(e.showBorder,e.borderStyle??"solid"),e.showBorder&&"p-2")}function vO(e,t){return e.columnBorders?.[t]!==void 0?!!e.columnBorders[t]:!!e.showColumnBorders}function wO(e,t){const r=vO(e,t);return H(gd(r,e.borderStyle??"dashed"),r&&"p-2")}function SO(e){if(e)return{minHeight:`${e}vh`}}function xO({widget:e,renderChildren:t}){const r=e.config,[n,o]=v.useState(r.defaultCollapsed??!1);return d.jsxs("section",{className:H("space-y-4",yO(r)),"data-widget-id":e.id,children:[r.heading&&d.jsx("div",{className:"flex items-center gap-2",children:r.collapsible?d.jsx("button",{type:"button",className:"text-left text-lg font-semibold hover:underline",onClick:()=>o(s=>!s),children:r.heading}):d.jsx("h2",{className:"text-lg font-semibold",children:r.heading})}),r.showDivider&&d.jsx("hr",{className:"border-border"}),!n&&e.children?.length?d.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function AO({widget:e,renderChildren:t}){const r=e.config,n=Vo(r.columns??2),o=r.collapseEmptyColumns!==!1,s=gO(e.children??[],n,r.columnWidths,{collapseEmpty:o});return d.jsx("div",{className:H("grid w-full min-w-0 items-stretch",mO(r.gap),bO(r)),style:{gridTemplateColumns:s.gridTemplate,...SO(r.minHeightPercent)},"data-widget-id":e.id,children:s.columns.map((i,a)=>{const c=s.sourceIndices[a]??a;return d.jsx("div",{className:H("flex min-h-[inherit] min-w-0 flex-col space-y-4 overflow-hidden",wO(r,c)),children:t?.(i)},c)})})}function CO({widget:e,renderChildren:t}){const r=e.config,n=r.variant==="outline"?"border bg-background":r.variant==="elevated"?"border bg-background shadow-md":"border bg-card";return d.jsxs("div",{className:H("rounded-lg p-4",n),"data-widget-id":e.id,children:[(r.title||r.subtitle)&&d.jsxs("div",{className:"mb-4",children:[r.title&&d.jsx("h3",{className:"font-semibold",children:r.title}),r.subtitle&&d.jsx("p",{className:"text-sm text-muted-foreground",children:r.subtitle})]}),e.children?.length?d.jsx("div",{className:"space-y-4",children:t?.(e.children)}):null]})}function xb(e,t){if(e.variable){const r=t[e.variable];return r!=null?String(r):e.fallback??e.text??""}return e.text??""}function EO({widget:e}){const t=e.config,{context:r}=$r(),n=xb(t,r),o=t.level??2,s=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left",i=o===1?"text-3xl":o===2?"text-2xl":o===3?"text-xl":"text-lg";return d.jsx("div",{role:"heading","aria-level":o,className:H("font-semibold tracking-tight",i,s),"data-widget-id":e.id,children:n})}function NO({widget:e}){const t=e.config,{context:r}=$r(),n=xb(t,r),o=t.preset==="caption"?"text-sm text-muted-foreground":t.preset==="small"?"text-xs text-muted-foreground":"text-base",s=t.align==="center"?"text-center":t.align==="right"?"text-right":"text-left";return d.jsx("p",{className:H(o,s),"data-widget-id":e.id,children:n})}function kO(e,t){return!e||typeof e!="string"?e:e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=n.trim(),s=t[o];return s==null?"":String(s)})}function Ab(e,t){const r={...e};for(const[n,o]of Object.entries(r))typeof o=="string"&&(r[n]=kO(o,t));return r}function _O(e,t){return e.replace(/\{\{([^}]+)\}\}/g,(r,n)=>{const o=t[n.trim()];return o!=null?String(o):""})}function Cb(e,t,r,n){if(e.type==="navigate"){const o=_O(e.href,t);if(!o.trim())return;e.openIn==="new"?window.open(o,"_blank","noopener,noreferrer"):window.location.assign(o);return}if(e.type==="navigate_page"&&e.pageId){r({...e,params:e.params?Ab(e.params,t):void 0},n,"click");return}if(e.type==="workflow"&&e.workflowId){r(e,n,"click");return}r(e,n,"click")}function TO({widget:e}){const t=e.config,{context:r,dispatchAction:n}=$r();return d.jsx(Zt,{variant:t.variant??"default",size:t.size??"default","data-widget-id":e.id,onClick:()=>Cb(t.action,r,n,e.id),children:t.label})}const FO={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between"},PO={sm:"gap-2",md:"gap-3",lg:"gap-4"};function OO({widget:e}){const t=e.config,{context:r,dispatchAction:n}=$r(),o=t.buttons??[];return d.jsx("div",{className:H("flex flex-wrap items-center",FO[t.align??"start"],PO[t.gap??"sm"],t.wrap===!1&&"flex-nowrap"),"data-widget-id":e.id,children:o.map(s=>d.jsx(Zt,{variant:s.variant??"outline",size:s.size??"default","data-widget-id":e.id,"data-button-id":s.id,onClick:()=>Cb(s.action,r,n,e.id),children:s.label},s.id))})}function IO(e){const t=e.prepopulateApi;return!!(t?.enabled&&t.api?.path)}function MO(e,t){return e&&(t==="idle"||t==="loading")}function LO(e,t){return!e||t==="ready"||t==="error"}function DO(e,t){const r=Ge(e,t??"");return r===void 0?null:r}function Eb(e,t){if(e.mode==="pageApi"&&e.dataSourceRef)return t[e.dataSourceRef];if(e.mode==="api")return e.api}function Nb({widgetId:e,dataSource:t,enabled:r=!0,page:n,pageSize:o,search:s}){const{schema:i,context:a,clientId:c,getFilterGroup:u,prepopulateStatus:f}=$r(),l=v.useMemo(()=>t.filterGroupKey?u(t.filterGroupKey):{},[t.filterGroupKey,u]),p=t.mode==="context"&&IO(i),g=MO(p,f),m=r&&(t.mode==="static"||(t.mode==="context"?LO(p,f):!!c)),h=v.useMemo(()=>["page-ds",e,t,a,l,n,o,s,f],[e,t,a,l,n,o,s,f]),y=Nn.useQuery({queryKey:h,enabled:m,staleTime:Eb(t,i.dataApis??{})?.staleTimeMs??3e4,queryFn:async()=>{if(t.mode==="static")return t.staticData;if(t.mode==="context")return DO(a,t.contextPath);const S=Eb(t,i.dataApis??{});if(!S)throw new Error(`No API config for data source on widget ${e}`);const w={...a};if(t.requestBindings)for(const F of t.requestBindings){let N;F.source==="binding"?N=a[F.key]:F.source==="filter"&&(N=l[F.key]),N!==void 0&&(w[F.param]=N)}const x={...Ab(w,a),...n!==void 0?{page:n,pageSize:o,search:s}:{}};return md({clientId:c,api:S,context:x,filterState:l})}});return{...y,isLoading:y.isLoading||g,isPending:y.isPending||g,isFetching:y.isFetching||g}}function yd(e,t){if(e==null)return"";if(!t||t.type==="none")return String(e);switch(t.type){case"number":{const r=Number(e);return Number.isNaN(r)?String(e):r.toFixed(t.decimals??0)}case"currency":{const r=Number(e);return Number.isNaN(r)?String(e):new Intl.NumberFormat(void 0,{style:"currency",currency:t.currency??"USD"}).format(r)}case"percent":{const r=Number(e);return Number.isNaN(r)?String(e):`${r.toFixed(t.decimals??0)}%`}case"date":{const r=new Date(String(e));return Number.isNaN(r.getTime())?String(e):r.toLocaleDateString(void 0,{...t.format?{}:{}})}case"template":return t.template.replace(/\{\{value\}\}/g,String(e));default:return String(e)}}function Ms(e,t){const r=Ge(e,t.path);return r==null?t.fallback??r:t.formatter?yd(r,t.formatter):r}function BO(e,t){if(!t)return{};const r={};for(const[n,o]of Object.entries(t))o in e&&(r[n]=e[o]);return r}const $O={default:"border bg-card",success:"border border-green-200 bg-green-50 text-green-900",warning:"border border-amber-200 bg-amber-50 text-amber-900",danger:"border border-red-200 bg-red-50 text-red-900"},jO={rectangle:"rounded-lg",square:"aspect-square rounded-lg",circle:"aspect-square rounded-full"},zO={sm:"p-2 text-xs",md:"p-4 text-sm",lg:"p-6 text-base"},bd={sm:"text-lg",md:"text-2xl",lg:"text-3xl"},UO={sm:"gap-2",md:"gap-3",lg:"gap-4"};function VO({title:e,value:t,trend:r,variant:n="default",shape:o="rectangle",size:s="md",layout:i="vertical",isLoading:a,isError:c}){const u=i==="horizontal";return d.jsxs("div",{className:H($O[n??"default"],jO[o??"rectangle"],zO[s??"md"],u&&"flex items-center justify-between gap-3"),children:[d.jsxs("div",{className:H(u&&"min-w-0"),children:[e&&d.jsx("p",{className:H("font-medium text-muted-foreground",u?"text-sm":""),children:e}),r!=null&&r!==""&&!u&&d.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:String(r)})]}),a?d.jsx(vn,{className:"my-2"}):c?d.jsx("p",{className:H("font-bold text-destructive",bd[s??"md"]),children:"Error"}):d.jsx("p",{className:H("font-bold",u?bd[s??"md"]:`mt-1 ${bd[s??"md"]}`),children:String(t)}),u&&r!==null&&r!==void 0&&r!==""&&d.jsx("p",{className:"text-xs text-muted-foreground",children:String(r)})]})}function kb({stat:e,widgetId:t}){const{data:r,isLoading:n,isError:o}=Nb({widgetId:t,dataSource:e.dataSource}),i=(()=>{if(n)return"";if(r==null)return e.valueMapping.fallback??"—";if(e.dataSource.mode==="context"){const c=r;return e.valueMapping.formatter?yd(c,e.valueMapping.formatter):c}if(e.dataSource.mode==="static"){const c=e.valueMapping.path?.trim()||"value",u=Ms(r,{...e.valueMapping,path:c});if(u!=null)return e.valueMapping.formatter?yd(u,e.valueMapping.formatter):u;if(typeof r=="object"&&r!==null&&!Array.isArray(r)){const f=r;if(f.value!==void 0&&f.value!==null)return f.value}return e.valueMapping.fallback??"—"}return Ms(r,e.valueMapping)})(),a=e.trendMapping&&r!==void 0&&e.dataSource.mode!=="context"?Ms(r,e.trendMapping):e.trendMapping&&e.dataSource.mode==="context"&&e.trendMapping.path?Ms({value:r},e.trendMapping):null;return d.jsx(VO,{title:e.title,value:i,trend:a,variant:e.variant,shape:e.shape,size:e.size,layout:e.layout,isLoading:n,isError:o})}function HO({widget:e}){const t=e.config;return d.jsx("div",{"data-widget-id":e.id,children:d.jsx(kb,{stat:t,widgetId:e.id})})}function WO({stat:e,widgetId:t}){return d.jsx(kb,{stat:e,widgetId:`${t}-${e.id}`})}function RO({widget:e}){const t=e.config,r=t.stats??[],n=t.columns??1,o=t.direction==="horizontal";return d.jsx("div",{"data-widget-id":e.id,className:H(o?"flex flex-wrap":"grid",!o&&n===1&&"grid-cols-1",!o&&n===2&&"grid-cols-2",!o&&n===3&&"grid-cols-3",!o&&n===4&&"grid-cols-4",UO[t.gap??"md"]),children:r.map(s=>d.jsx(WO,{stat:s,widgetId:e.id},s.id))})}function GO({widget:e}){const t=e.config,{setFilterValue:r}=$r(),[n,o]=v.useState("");return v.useEffect(()=>{const s=t.debounceMs??300,i=setTimeout(()=>{r(t.filterGroupKey,"search",n)},s);return()=>clearTimeout(i)},[n,t.debounceMs,t.filterGroupKey,r]),d.jsx("input",{type:"search",className:"flex h-9 w-full max-w-sm rounded-md border border-input bg-background px-3 py-1 text-sm shadow-xs",placeholder:t.placeholder??"Search…",value:n,onChange:s=>o(s.target.value),"data-widget-id":e.id})}function KO(e,t){if(!e)return[];const r=t?Ge(e,t):e;if(Array.isArray(r))return r;if(typeof r=="object"&&r!==null){const n=r;if(Array.isArray(n.items))return n.items;if(Array.isArray(n.data))return n.data}return[]}function qO({widget:e}){const t=e.config,{dispatchAction:r}=$r(),[n,o]=v.useState(1),[s,i]=v.useState(""),a=t.pagination?.pageSize??10,{data:c,isLoading:u,isError:f}=Nb({widgetId:e.id,dataSource:t.dataSource,page:n,pageSize:a,search:t.search?.enabled?s:void 0}),l=t.dataSource.mode==="pageApi"?void 0:t.dataSource.api?.itemsPath,p=KO(c,l??"data.items"),g=(m,h)=>{const y=t.dataSource.responseMapping.find(S=>S.target===h);return y?Ms(m,y):Ge(m,h)??""};return d.jsxs("div",{className:"space-y-3","data-widget-id":e.id,children:[t.search?.enabled&&d.jsx("input",{type:"search",className:"flex h-9 w-full max-w-sm rounded-md border border-input bg-background px-3 py-1 text-sm",placeholder:t.search.placeholder??"Search…",value:s,onChange:m=>{i(m.target.value),o(1)}}),d.jsx("div",{className:"overflow-x-auto rounded-md border",children:d.jsxs("table",{className:"w-full text-sm",children:[d.jsx("thead",{children:d.jsx("tr",{className:"border-b bg-muted/50",children:t.columns.map(m=>d.jsx("th",{className:H("px-3 py-2 text-left font-medium",m.align==="center"&&"text-center",m.align==="right"&&"text-right"),style:m.width?{width:m.width}:void 0,children:m.header},m.id))})}),d.jsx("tbody",{children:u?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center",children:d.jsx(vn,{})})}):f?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-destructive",children:"Failed to load data"})}):p.length===0?d.jsx("tr",{children:d.jsx("td",{colSpan:t.columns.length,className:"px-3 py-8 text-center text-muted-foreground",children:t.emptyMessage??"No data"})}):p.map((m,h)=>d.jsx("tr",{className:"cursor-pointer border-b hover:bg-muted/30",onClick:()=>{r({type:"emit",eventName:"row_click",payload:{row:m}},e.id,"row_click")},children:t.columns.map(y=>d.jsx("td",{className:H("px-3 py-2",y.align==="center"&&"text-center",y.align==="right"&&"text-right"),children:String(g(m,y.field))},y.id))},h))})]})}),t.pagination?.enabled&&d.jsxs("div",{className:"flex items-center justify-between text-sm",children:[d.jsxs("span",{className:"text-muted-foreground",children:["Page ",n]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{type:"button",className:"rounded border px-2 py-1 disabled:opacity-50",disabled:n<=1,onClick:()=>o(m=>Math.max(1,m-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"rounded border px-2 py-1",disabled:p.length<a,onClick:()=>o(m=>m+1),children:"Next"})]})]})]})}const YO=75;function XO(e){return e??YO}function JO(e){return e?"rounded-md border border-border p-3":""}function vd({scrollBehavior:e="page",maxHeightPercent:t,children:r,className:n}){if(e!=="contained")return n?d.jsx("div",{className:n,children:r}):d.jsx(d.Fragment,{children:r});const o=XO(t);return d.jsx("div",{className:H("min-w-0 overflow-y-auto overflow-x-hidden",n),style:{maxHeight:`${o}vh`},"data-form-embed-scroll":"contained",children:r})}function QO(e,t,r){return["embedded-form",e,t,r??"latest"]}async function ZO(e,t){try{const r=await Qt.get(`/api/form-builder/form-layouts/form/${e}`,{params:{clientId:t}});let n=r.data?.data??r.data;for(;n&&typeof n=="object"&&!Array.isArray(n)&&n.data!=null&&typeof n.data=="object"&&!("rows"in n)&&!("columns"in n)&&!("formDefinitionId"in n);)n=n.data;return!n||typeof n!="object"||Array.isArray(n)||!("rows"in n)&&!("columns"in n)&&!("formDefinitionId"in n)?null:n}catch{return null}}async function eI(e,t,r){const n=r!==void 0?`/api/form-builder/forms/${e}/render?version=${r}`:`/api/form-builder/forms/${e}/render`,o=await Qt.get(n,{params:{clientId:t}}),i=o.data?.data??o.data,a=i.form??i,c=i.fields??a.fields??[];let u=i.layout??a.layout??null;(!u||typeof u.columns!="number")&&(u=await ZO(e,t));const f=i.rules??a.rules??[],l=Ts(a,c,u,f),p=Us({config:l.config,layout:l.layout},zs(u))??zs(u);return{schema:l,gridLayout:p}}const tI=300*1e3;function _b({formId:e,mode:t="fill",contextFieldMapping:r,pageContext:n,clientId:o,formVersion:s,scrollBehavior:i,maxHeightPercent:a,showBorder:c}){const u=lO(),{data:f,isLoading:l,isError:p,error:g}=Nn.useQuery({queryKey:QO(e,o,s),queryFn:()=>eI(e,o,s),staleTime:tI}),m=v.useMemo(()=>BO(n,r),[n,r]),h=JO(c);if(l)return d.jsx(vd,{scrollBehavior:i,maxHeightPercent:a,className:h,children:d.jsx(vn,{})});if(p)return d.jsx(vd,{scrollBehavior:i,maxHeightPercent:a,className:h,children:d.jsx("p",{className:"text-sm text-destructive",children:g instanceof Error?g.message:"Failed to load form"})});if(!f?.schema)return null;const y=typeof f.schema.moduleId=="string"?f.schema.moduleId.trim():"",S=u?.context.moduleId!=null?String(u.context.moduleId).trim():"",w=y||S||void 0;return d.jsx(vd,{scrollBehavior:i,maxHeightPercent:a,className:h,children:d.jsx(Ps,{schema:f.schema,mode:t,gridLayout:f.gridLayout,initialValues:m,submissionContext:n,moduleId:w,workflowModalHandlers:u?.workflowModalHandlers,getAuthHeaders:u?.getAuthHeaders})})}function rI({widget:e}){const t=e.config,{context:r,clientId:n}=$r();return t.formId?d.jsx(_b,{formId:t.formId,mode:t.mode??"fill",contextFieldMapping:t.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:t.scrollBehavior,maxHeightPercent:t.maxHeightPercent,showBorder:t.showBorder}):d.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured"})}function nI({widget:e}){const t=e.config,{context:r,getWorkflowState:n,workflowModalHandlers:o,clientId:s}=$r(),i=String(r.moduleId??"");if(!n)return d.jsxs("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground","data-widget-id":e.id,children:["Workflow embed requires ",d.jsx("code",{className:"text-xs",children:"getWorkflowState"})," on PageRenderer. Workflow ID: ",t.workflowId]});if(!i)return d.jsx("p",{className:"text-sm text-destructive","data-widget-id":e.id,children:"moduleId required in page context for workflow embed"});const a={};if(t.contextVariableMapping)for(const[c,u]of Object.entries(t.contextVariableMapping)){const f=r[u];f!=null&&(a[c]=String(f))}return d.jsx(ab,{getWorkflowState:n,workflowModalHandlers:o,moduleId:i,tenantId:r.tenantId?String(r.tenantId):void 0,clientId:s||void 0,submissionContext:a})}function oI({widget:e}){const t=e.config,{schema:r,dispatchAction:n}=$r(),o=t.previousPage??r.navigation?.previousPage,s=t.nextPage??r.navigation?.nextPage,i=t.showPrevious!==!1&&!!o,a=t.showNext!==!1&&!!s,c=t.showBreadcrumbs&&r.navigation?.breadcrumbs?.length,u=t.align==="center"?"justify-center":t.align==="right"?"justify-end":t.align==="space-between"?"justify-between":"justify-start",f=l=>{n({type:"navigate_page",pageId:l.pageId},e.id,"click")};return d.jsxs("nav",{className:"space-y-3","data-widget-id":e.id,children:[c&&d.jsx("ol",{className:"flex flex-wrap items-center gap-1 text-sm text-muted-foreground",children:r.navigation.breadcrumbs.map((l,p)=>d.jsxs("li",{className:"flex items-center gap-1",children:[p>0&&d.jsx("span",{children:"/"}),l.href?d.jsx("a",{href:l.href,className:"hover:underline",children:l.label}):d.jsx("span",{children:l.label})]},p))}),d.jsxs("div",{className:H("flex items-center gap-2",u),children:[i&&o&&d.jsx(Zt,{variant:"outline",size:"sm",onClick:()=>f(o),children:o.label??"Previous"}),a&&s&&d.jsx(Zt,{variant:"default",size:"sm",onClick:()=>f(s),children:s.label??"Next"})]})]})}function sI(e,t){return e?.length?e.filter(r=>r.config.tabId===t):[]}const iI=1;function aI(e){switch(e){case"pills":return"bg-transparent gap-1 p-0 h-auto";case"underline":return"bg-transparent rounded-none border-b p-0 h-auto w-full justify-start gap-4";default:return""}}function lI(e){switch(e){case"pills":return"rounded-full data-[state=active]:bg-primary data-[state=active]:text-primary-foreground";case"underline":return"rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none bg-transparent";default:return""}}function cI(e,t,r){return e?new Set(r?[r]:[]):new Set(t.map(n=>n.id))}function dI({tab:e,shouldRender:t,pageContext:r,clientId:n}){return t?e.formId?d.jsx(_b,{formId:e.formId,mode:e.formMode??"fill",contextFieldMapping:e.contextFieldMapping,pageContext:r,clientId:n,scrollBehavior:e.scrollBehavior,maxHeightPercent:e.maxHeightPercent,showBorder:e.showBorder}):d.jsx("p",{className:"text-sm text-muted-foreground",children:"No form configured for this tab"}):null}function uI({tab:e,shouldLoad:t,shouldRender:r,nestingDepth:n,pageContext:o,clientId:s,onAction:i,getWorkflowState:a}){const c=$r(),{data:u,isLoading:f,isError:l,error:p}=Nn.useQuery({queryKey:["tab-page",e.pageId,e.pageVersion,s],enabled:t&&!!e.pageId,queryFn:async()=>pd(e.pageId,s,e.pageVersion)});return r?n>=iI?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:"Nested page tabs not supported"}):e.pageId?f?d.jsx(vn,{}):l?d.jsx("p",{className:"text-sm text-destructive",children:p instanceof Error?p.message:"Failed to load page"}):u?d.jsx(wd,{page:u,context:o,nestingDepth:n+1,inheritContext:!0,onAction:i,getWorkflowState:a,parentContext:c}):null:d.jsx("p",{className:"text-sm text-muted-foreground",children:"No page configured for this tab"}):null}function fI({tab:e,widgetChildren:t,renderChildren:r}){const n=sI(t,e.id);return n.length===0?d.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No widgets in this tab"}):d.jsx(d.Fragment,{children:r?.(n)})}function pI({widget:e,renderChildren:t}){const r=e.config,{context:n,clientId:o,nestingDepth:s,onAction:i,getWorkflowState:a}=$r(),c=r.tabs??[],u=r.defaultTabId??c[0]?.id??"",f=r.lazyLoad!==!1,[l,p]=v.useState(u),[g,m]=v.useState(()=>cI(f,c,u)),h=S=>{m(w=>new Set(w).add(S)),p(S)},y=v.useMemo(()=>!f,[f]);return c.length===0?d.jsx("p",{className:"text-sm text-muted-foreground","data-widget-id":e.id,children:"No tabs configured"}):d.jsxs(ob,{value:l,onValueChange:h,className:"w-full","data-widget-id":e.id,children:[d.jsx(ld,{className:H("mb-4",aI(r.variant)),children:c.map(S=>d.jsx(cd,{value:S.id,disabled:S.disabled,className:lI(r.variant),children:S.label},S.id))}),c.map(S=>{const w=g.has(S.id),A=y||w,x=y||w;return d.jsxs(sb,{value:S.id,forceMount:y||void 0,className:H("mt-0",y&&"data-[state=inactive]:hidden"),children:[S.contentType==="widgets"&&x&&d.jsx(fI,{tab:S,widgetChildren:e.children??[],renderChildren:t}),S.contentType==="form"&&d.jsx(dI,{tab:S,shouldRender:A,pageContext:n,clientId:o}),S.contentType==="page"&&d.jsx(uI,{tab:S,shouldLoad:A,shouldRender:x,nestingDepth:s,pageContext:n,clientId:o,onAction:i,getWorkflowState:a})]},S.id)})]})}const mI={section:xO,columns:AO,card:CO,tab_group:pI,heading:EO,text:NO,button:TO,button_group:OO,stat_card:HO,stat_grid:RO,data_table:qO,search_filter:GO,form_embed:rI,workflow_embed:nI,page_nav:oI};function hI({widget:e}){return d.jsxs("div",{className:"rounded-md border border-dashed border-muted-foreground/40 bg-muted/20 p-3 text-sm text-muted-foreground","data-widget-id":e.id,"data-widget-type":e.type,children:["Unsupported widget: ",d.jsx("code",{className:"text-xs",children:e.type}),e.label&&d.jsxs("span",{className:"ml-1",children:["(",e.label,")"]})]})}function gI({widget:e,renderChildren:t}){const r=mI[e.type]??hI;return d.jsx(r,{widget:e,renderChildren:t})}function Tb(e,t){return e.map(r=>d.jsx(gI,{widget:r,renderChildren:t},r.id))}const yI="/api/bff/workflows";function bI(e){const t=e.moduleId??e.module_id;return t!=null?String(t).trim():""}function Fb(e){const t=Df(),r=e.userId??e.user_id??t?.userId;return r!=null&&String(r).trim()!==""?String(r):void 0}function vI(e){const t=String(e.clientId??nn()??""),r=Fb(e);return()=>xa({getAuthHeaders:()=>ds()??{},clientId:t||void 0,userId:r})}function wI(e,t){const r=bI(e);if(!r)return null;const n=t?.bffWorkflowsBasePath??yI,o=String(e.clientId??nn()??""),s=Fb(e),i=vI(e),a=t?.workflowModalHandlers??lb({bffWorkflowsBasePath:n,moduleId:r,getAuthHeaders:i,clientId:o||void 0,userId:s});return{getWorkflowState:t?.getWorkflowState??(u=>cb({bffWorkflowsBasePath:n,moduleId:u.moduleId,featureId:u.featureId,tenantId:u.tenantId,subjectUserId:u.subjectUserId,viewStepId:u.viewStepId,clientId:u.clientId??(o||void 0),getAuthHeaders:i})),workflowModalHandlers:a,getAuthHeaders:i,moduleId:r}}function wd({page:e,context:t={},onAction:r,chrome:n="none",className:o,nestingDepth:s=0,getWorkflowState:i,workflowModalHandlers:a,getAuthHeaders:c,inheritContext:u=!1,parentContext:f}){const l=v.useMemo(()=>rO(e.schema),[e.schema]),p=v.useMemo(()=>{const h=wI(t,{getWorkflowState:i,workflowModalHandlers:a});return{getWorkflowState:i??h?.getWorkflowState,workflowModalHandlers:a??h?.workflowModalHandlers,getAuthHeaders:c??h?.getAuthHeaders}},[t,i,a,c]),g=h=>Tb(h,g),m=d.jsxs("div",{className:H("studio-page-content min-h-0 min-w-0",ZP(l),o),"data-page-id":e.id,"data-nesting-depth":s,children:[n==="minimal"&&l.meta?.title&&d.jsxs("header",{className:"mb-6 border-b pb-4",children:[d.jsx("h1",{className:"text-2xl font-semibold",children:l.meta.title}),l.meta.description&&d.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:l.meta.description})]}),d.jsx("div",{className:"space-y-6",children:Tb(l.widgets,g)})]});return u&&f?m:d.jsx(aO,{schema:l,context:t,clientId:String(t.clientId??""),nestingDepth:s,onAction:r,getWorkflowState:p.getWorkflowState,workflowModalHandlers:p.workflowModalHandlers,getAuthHeaders:p.getAuthHeaders,parentContext:f,children:m})}function SI({clientId:e,tenantId:t,moduleId:r,featureId:n,pageId:o,routePath:s,routeParams:i={},isDefault:a,context:c={},version:u,chrome:f="none",onAction:l,getWorkflowState:p,workflowModalHandlers:g,getAuthHeaders:m}){const h=v.useMemo(()=>({...i,...c,clientId:e,tenantId:t,moduleId:r,featureId:n}),[i,c,e,t,r,n]),{data:y,isLoading:S,isError:w,error:A}=Nn.useQuery({queryKey:["page-resolve",e,t,r,n,o,s,a,u],queryFn:()=>gb({clientId:e,tenantId:t,moduleId:r,featureId:n,routePath:s,isDefault:a,version:u}),enabled:!o}),x=o??y?.pageId,F=u??y?.version,{data:N,isLoading:k,isError:T,error:P}=Nn.useQuery({queryKey:["page-render",x,e,F],queryFn:()=>pd(x,e,F),enabled:!!x});return!o&&S?d.jsx("div",{className:"flex items-center justify-center p-12",children:d.jsx(vn,{})}):w?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:A instanceof Error?A.message:"Failed to resolve page"}):x?k?d.jsx("div",{className:"flex items-center justify-center p-12",children:d.jsx(vn,{})}):T||!N?d.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm text-destructive",children:P instanceof Error?P.message:"Failed to load page"}):d.jsx(wd,{page:N,context:h,chrome:f,nestingDepth:0,onAction:l,getWorkflowState:p,workflowModalHandlers:g,getAuthHeaders:m}):d.jsx("div",{className:"rounded-md border p-4 text-sm text-muted-foreground",children:"No page found for the given scope or route."})}ue.FIELD_TYPE_REGISTRY=YP,ue.FORM_RENDERER_GRID_ROW_HEIGHT_DEFAULT=Hn,ue.FORM_RENDERER_ROOT_CLASS=$a,ue.FieldRenderer=wn,ue.FormRenderer=Ps,ue.PageRenderer=wd,ue.RendererFieldLayoutContext=Ya,ue.RendererStoreProvider=il,ue.STEPS_NAV_RUNTIME_DEFAULTS=Os,ue.StudioPageHost=SI,ue.WorkflowFormModal=Cg,ue.WorkflowModalProvider=kg,ue.WorkflowStepsView=ab,ue.appearanceControlClasses=uo,ue.appearanceHasExplicitVerticalIntent=iu,ue.appearanceTextareaClasses=Jd,ue.backendToFormSchema=Ts,ue.buildBffWorkflowAuthHeaders=xa,ue.cellAlignmentClasses=Hv,ue.cellVerticalJustifyClassesForField=Vv,ue.clearWorkflowStandaloneCache=WP,ue.createBffWorkflowModalHandlers=lb,ue.effectiveWidthPercent=Rs,ue.executeDataSource=md,ue.fetchBffWorkflowState=cb,ue.fetchPageRender=pd,ue.fetchWorkflowStandaloneFlag=Sa,ue.fieldBlockBoxStyle=Uv,ue.fieldBlockBoxStyleForField=ou,ue.fieldBlockHorizontalPlacementClass=eu,ue.fieldBlockHorizontalSelfClass=tu,ue.fieldBlockHorizontalSelfClassForField=su,ue.fieldBlockWidthStyle=Ha,ue.fieldBlockWidthStyleForField=nu,ue.fieldGridShellFillsCellVertically=Ks,ue.formBuilderHttp=Qt,ue.formLayoutRecordToGridConfig=zs,ue.getBusinessApiOrigin=Mf,ue.getClientId=nn,ue.getRendererHostAuthHeaders=ds,ue.getRendererHostViewerContext=Df,ue.getRendererStore=ww,ue.gridCellFlexClasses=Zd,ue.gridCellFlexClassesForField=qa,ue.gridCellOuterFlexClasses=Qd,ue.hasExplicitFieldBlockWidth=ru,ue.isAsyncSearchFieldProperties=RP,ue.isIntrinsicWidthButtonField=fo,ue.normalizeWorkflowFormSchema=c_,ue.normalizeWorkflowFormToRendererSchema=da,ue.pageBuilderHttp=Is,ue.parseContentVerticalAlign=Ra,ue.parseMetadataJson=xs,ue.resetRendererHostAuth=D0,ue.resolveBusinessApiUrl=Mr,ue.resolveFormGridLayout=Us,ue.resolvePage=gb,ue.resolveWorkflowStepsNavigationConfig=ud,ue.resolveWorkflowStepsNavigationPosition=MP,ue.resolvedGridCellVerticalJustifyClasses=Xo,ue.resolvedHorizontalAlign=Fr,ue.resolvedVerticalAlign=Yo,ue.resolvedVerticalAlignForField=Ka,ue.setBusinessApiOrigin=P0,ue.setFormBuilderAuthProvider=B0,ue.setPageBuilderAuthProvider=nO,ue.setRendererHostAuthHeaders=L0,ue.setRendererHostViewerContext=M0,ue.useFieldValidation=KP,ue.useFormRenderer=xu,ue.useFormValidation=GP,ue.useRendererFieldLayout=Jo,ue.useRendererHostAuthStore=Qn,ue.useWorkflowModal=Ng,Object.defineProperty(ue,Symbol.toStringTag,{value:"Module"})}));
|