@opennsw/jsonforms-renderers 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- "use strict";var jr=Object.create;var Ue=Object.defineProperty;var Er=Object.getOwnPropertyDescriptor;var Cr=Object.getOwnPropertyNames;var Rr=Object.getPrototypeOf,Sr=Object.prototype.hasOwnProperty;var Ar=(e,r,t)=>r in e?Ue(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var Fr=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of Cr(r))!Sr.call(e,l)&&l!==t&&Ue(e,l,{get:()=>r[l],enumerable:!(o=Er(r,l))||o.enumerable});return e};var Ae=(e,r,t)=>(t=e!=null?jr(Rr(e)):{},Fr(r||!e||!e.__esModule?Ue(t,"default",{value:e,enumerable:!0}):t,e));var Ye=(e,r,t)=>Ar(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("react"),b=require("@jsonforms/core"),B=require("@jsonforms/react"),s=require("@radix-ui/themes"),re=require("@radix-ui/react-icons"),ht=require("dayjs"),xt=g.createContext(null);function Or({children:e,onUpload:r,getDownloadUrl:t}){const o={onUpload:r,getDownloadUrl:t};return n.jsx(xt.Provider,{value:o,children:e})}function mt(){return g.useContext(xt)}const gt=g.createContext(null);function Ir({children:e,services:r}){const t=g.useMemo(()=>r,[r]);return n.jsx(gt.Provider,{value:t,children:e})}function yt(e){const r=g.useContext(gt);return!r||!e?null:r[e]??null}const je=(e,r,t,o=void 0)=>{g.useEffect(()=>{e===!1&&t(r,o)},[e,r,t,o])},Ge=new WeakMap;function kr(e){if(!e||typeof e!="object")return!1;const r=Ge.get(e);if(r!==void 0)return r;const t=Ie(e,e,new Set);return Ge.set(e,t),t}function Dr(e,r){if(!r.startsWith("#/"))return;const t=r.slice(2).split("/");let o=e;for(const l of t){if(!o||typeof o!="object")return;o=o[l]}return o&&typeof o=="object"?o:void 0}function Ie(e,r,t){if(!e||typeof e!="object"||t.has(e))return!1;t.add(e);const o=e;if(o.if!=null||o.dependentRequired!=null||o.dependencies!=null)return!0;for(const l of["allOf","anyOf","oneOf"]){const i=o[l];if(Array.isArray(i))for(const a of i){if(!a||typeof a!="object")continue;const c=a;if(Array.isArray(c.required)&&c.required.length>0||Ie(c,r,t))return!0}}if(typeof o.$ref=="string"){const l=Dr(r,o.$ref);if(l&&Ie(l,r,t))return!0}for(const l of["then","else","not","contains","additionalProperties","items"]){const i=o[l];if(i&&typeof i=="object"&&!Array.isArray(i)&&Ie(i,r,t))return!0}if(Array.isArray(o.items)){for(const l of o.items)if(Ie(l,r,t))return!0}for(const l of["properties","patternProperties","$defs","definitions"]){const i=o[l];if(!(!i||typeof i!="object")){for(const a of Object.values(i))if(Ie(a,r,t))return!0}}return!1}function Nr(e,r){const t=structuredClone(e??{});if(!r)return t;const o=r.split(".");let l=t;for(let a=0;a<o.length-1;a++){const c=o[a];if(l==null||typeof l!="object")return t;const u=l[c];if(u==null||typeof u!="object")return t;l=u}const i=o[o.length-1];return l!=null&&typeof l=="object"&&delete l[i],t}function Lr(e){const r=e.lastIndexOf(".");return r===-1?"":"/"+e.slice(0,r).split(".").join("/")}function Mr(e){if(!e)return"";const r=e.lastIndexOf(".");return r===-1?e:e.slice(r+1)}function zr(e,r){var t;return e.keyword!=="required"&&e.keyword!=="dependencies"||((t=e.params)==null?void 0:t.missingProperty)!==Mr(r)?!1:(e.instancePath??"")===Lr(r)}function Pr(e,r,t){if(!e||!t)return!1;const o=Nr(r,e);t(o);const l=t.errors;return l!=null&&l.length?l.some(i=>zr(i,e)):!1}function be(e,r=!1,t=!0){var c,u,d;const o=B.useJsonForms(),l=(c=o.core)==null?void 0:c.data,i=(u=o.core)==null?void 0:u.validator,a=(d=o.core)==null?void 0:d.schema;return g.useMemo(()=>t?r?!0:kr(a)?Pr(e,l,i):!1:!1,[t,r,e,l,i,a])}const ve=(e,r)=>{if(!e)return"";const t=r||"This field";return e.split(`
2
- `).map(o=>{const l=o.trim();return l==="is a required property"?`${t} is required`:l.startsWith("must be > ")?`${t} must be greater than ${l.slice(10)}`:l.startsWith("must be >= ")?`${t} must be at least ${l.slice(11)}`:l.startsWith("must be multiple of ")?`${t} must be a multiple of ${l.slice(20)}`:o}).join(`
3
- `)},bt=({data:e,handleChange:r,path:t,label:o,required:l,errors:i,uischema:a,schema:c,enabled:u,visible:d=!0})=>{var x;je(d,t,r);const f=be(t,l,d);if(d===!1)return null;const m=i.length===0;return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[o," ",f&&n.jsx(s.Text,{color:"red",children:"*"})]}),n.jsx(s.TextField.Root,{value:e||"",onChange:p=>r(t,p.target.value),disabled:!u,placeholder:(x=a.options)==null?void 0:x.placeholder,color:m?void 0:"red",id:t}),!m&&n.jsx(s.Text,{color:"red",size:"1",children:ve(i,o)}),c.description&&n.jsx(s.Text,{size:"1",color:"gray",children:c.description})]})})},vt=b.rankWith(1,b.isStringControl),Ur=B.withJsonFormsControlProps(bt),$r=new Set(["-","+","e","E"]),wt=({data:e,handleChange:r,path:t,label:o,required:l,errors:i,uischema:a,schema:c,enabled:u,visible:d=!0})=>{var R;je(d,t,r);const f=be(t,l,d);if(d===!1)return null;const m=i.length===0,x=typeof c.exclusiveMinimum=="number"?c.exclusiveMinimum:void 0,p=typeof c.minimum=="number"?c.minimum:void 0,j=x??p,w=j!==void 0&&j>=0,N=typeof c.multipleOf=="number"?c.multipleOf:c.type==="integer"?1:void 0,I=v=>{if(v===""){r(t,void 0);return}const y=Number(v);isNaN(y)||r(t,y)},O=v=>{w&&$r.has(v.key)&&v.preventDefault()},C=v=>{if(!w)return;const y=v.clipboardData.getData("text");/[-+eE]/.test(y)&&v.preventDefault()};return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[o," ",f&&n.jsx(s.Text,{color:"red",children:"*"})]}),n.jsx(s.TextField.Root,{type:"number",value:e??"",onChange:v=>I(v.target.value),onKeyDown:O,onPaste:C,min:j,step:N,disabled:!u,placeholder:(R=a.options)==null?void 0:R.placeholder,color:m?void 0:"red",id:t}),!m&&n.jsx(s.Text,{color:"red",size:"1",children:ve(i,o)}),c.description&&n.jsx(s.Text,{size:"1",color:"gray",children:c.description})]})})},Tt=b.rankWith(2,b.or(b.isNumberControl,b.isIntegerControl)),Br=B.withJsonFormsControlProps(wt),jt=({data:e,handleChange:r,path:t,label:o,required:l,errors:i,schema:a,enabled:c,visible:u=!0})=>{je(u,t,r);const d=be(t,l,u);if(u===!1)return null;const f=i.length===0;return n.jsxs(s.Box,{mb:"4",children:[n.jsxs(s.Flex,{gap:"2",align:"center",children:[n.jsx(s.Checkbox,{checked:!!e,onCheckedChange:m=>r(t,m===!0),disabled:!c,id:t}),n.jsxs(s.Text,{as:"label",size:"2",htmlFor:t,children:[o," ",d&&"*"]})]}),!f&&n.jsx(s.Text,{color:"red",size:"1",className:"block mt-1",children:ve(i,o)}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",className:"block mt-1",children:a.description})]})},Et=b.rankWith(2,b.isBooleanControl),_r=B.withJsonFormsControlProps(jt),Ct=({data:e,handleChange:r,path:t,label:o,required:l,errors:i,schema:a,enabled:c,visible:u=!0})=>{je(u,t,r);const d=be(t,l,u);if(u===!1)return null;const f=i.length===0;let m=[];a.enum?m=a.enum.map(p=>({value:p,label:String(p)})):a.oneOf&&(m=a.oneOf.map(p=>({value:p.const,label:p.title||String(p.const)})));const x=e;return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"div",size:"2",weight:"bold",children:[o," ",d&&n.jsx(s.Text,{color:"red",children:"*"})]}),n.jsx(s.RadioGroup.Root,{value:x!==void 0?String(x):"",onValueChange:p=>{const j=m.find(w=>String(w.value)===p);j&&r(t,j.value)},disabled:!c,children:n.jsx(s.Flex,{direction:"row",style:{flexWrap:"wrap",columnGap:"clamp(14px, 3vw, 36px)",rowGap:"clamp(8px, 1.6vw, 14px)"},children:m.map(p=>n.jsxs(s.Flex,{align:"center",gap:"2",style:{minWidth:"max-content"},children:[n.jsx(s.RadioGroup.Item,{value:String(p.value)}),n.jsx(s.Text,{size:"2",color:c?void 0:"gray",children:p.label})]},String(p.value)))})}),!f&&n.jsx(s.Text,{color:"red",size:"1",children:ve(i,o)}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",children:a.description})]})})},Rt=(e,r,t)=>{var l;return b.or(b.isEnumControl,b.isOneOfControl)(e,r,t)&&((l=e==null?void 0:e.options)==null?void 0:l.format)==="radio"?3:-1},Wr=B.withJsonFormsControlProps(Ct),St=({data:e,handleChange:r,path:t,label:o,required:l,errors:i,schema:a,uischema:c,enabled:u,visible:d=!0})=>{var Q,de,oe,ee;je(d,t,r);const f=be(t,l,d),m=((Q=c.options)==null?void 0:Q.autocomplete)===!0,[x,p]=g.useState(!1),[j,w]=g.useState(""),[N,I]=g.useState(0),O=g.useRef(null);if(g.useEffect(()=>{if(!m||!x)return;const D=H=>{O.current&&!O.current.contains(H.target)&&p(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[m,x]),d===!1)return null;const C=a.type==="object",R=C?((de=a.properties)==null?void 0:de.value)??{}:a;let v=[];R.enum?v=R.enum.map(D=>({value:String(D),label:String(D),raw:D})):R.oneOf&&(v=R.oneOf.map(D=>{const H=D.const;return{value:String(H),label:D.title||String(H),raw:H}}));const y=C?typeof e=="string"||typeof e=="number"||typeof e=="boolean"?{value:e}:e??void 0:void 0,z=C?y==null?void 0:y.value:e,P=y==null?void 0:y.label,F=z!=null?String(z):"",$=P??((oe=v.find(D=>D.value===F))==null?void 0:oe.label)??"",k=((ee=c.options)==null?void 0:ee.placeholder)||"Select an option",ne=C&&F!==""&&!v.some(D=>D.value===F),K=i?ve(i,o):ne?`"${$||F}" is no longer an available option`:"",L=K==="",U=D=>{r(t,C?{value:D.raw,label:D.label}:D.value)};if(m){const D=x?v.filter(M=>M.label.toLowerCase().includes(j.toLowerCase())):v,H=Math.min(N,D.length-1),S=M=>{U(M),p(!1)},Y=M=>{M.stopPropagation(),r(t,void 0),w("")},fe=M=>{(M.key==="Enter"||M.key===" ")&&Y(M)};return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[o," ",f&&n.jsx(s.Text,{color:"red",children:"*"})]}),n.jsxs("div",{ref:O,style:{position:"relative"},children:[n.jsx(s.TextField.Root,{id:t,value:x?j:$,placeholder:k,disabled:!u,style:L?void 0:{outline:"2px solid var(--red-7)",outlineOffset:"-1px"},onChange:M=>{w(M.target.value),I(0),x||p(!0)},onFocus:()=>{u&&!x&&(w(""),I(0),p(!0))},onKeyDown:M=>{M.key==="Escape"?p(!1):M.key==="ArrowDown"?(M.preventDefault(),x?I(G=>Math.min(G+1,D.length-1)):(w(""),p(!0))):M.key==="ArrowUp"?(M.preventDefault(),x&&I(G=>Math.max(G-1,0))):M.key==="Enter"&&x&&D[H]&&(M.preventDefault(),S(D[H]))},children:n.jsx(s.TextField.Slot,{side:"right",children:n.jsxs(s.Flex,{align:"center",gap:"1",children:[F&&u&&n.jsx("span",{role:"button",tabIndex:0,onMouseDown:M=>M.preventDefault(),onClick:Y,onKeyDown:fe,style:{lineHeight:1,color:"var(--gray-9)",padding:"0 2px",cursor:"pointer"},"aria-label":"Clear selection",children:"×"}),n.jsx(re.ChevronDownIcon,{style:{transform:x?"rotate(180deg)":void 0,transition:"transform 150ms"}})]})})}),x&&n.jsx(s.Box,{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:50,background:"var(--color-panel-solid)",borderRadius:"var(--radius-3)",boxShadow:"var(--shadow-5)",border:"1px solid var(--gray-a6)",overflow:"hidden"},children:n.jsx(s.ScrollArea,{style:{maxHeight:240},children:n.jsxs(s.Box,{p:"1",children:[D.length===0&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Text,{size:"2",color:"gray",children:"No results found."})}),D.map((M,G)=>n.jsx(s.Box,{px:"3",py:"2",onMouseDown:ie=>ie.preventDefault(),onClick:()=>S(M),onMouseEnter:()=>I(G),style:{cursor:"pointer",borderRadius:"var(--radius-2)",backgroundColor:G===H?"var(--accent-4)":M.value===F?"var(--accent-3)":void 0},children:n.jsx(s.Text,{size:"2",children:M.label})},M.value))]})})})]}),!L&&n.jsx(s.Text,{color:"red",size:"1",children:K}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",children:a.description})]})})}return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[o," ",f&&n.jsx(s.Text,{color:"red",children:"*"})]}),n.jsxs(s.Select.Root,{value:F,onValueChange:D=>{const H=v.find(S=>S.value===D);H&&U(H)},disabled:!u,children:[n.jsx(s.Select.Trigger,{placeholder:k,color:L?void 0:"red",id:t,children:C&&P?P:void 0}),n.jsx(s.Select.Content,{children:v.map(D=>n.jsx(s.Select.Item,{value:D.value,children:D.label},D.value))})]}),!L&&n.jsx(s.Text,{color:"red",size:"1",children:K}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",children:a.description})]})})},At=b.rankWith(2,b.or(b.isEnumControl,b.isOneOfControl)),Ft=b.rankWith(3,b.schemaMatches(e=>{var t;if(e.type!=="object"||e["x-search"]!==void 0)return!1;const r=(t=e.properties)==null?void 0:t.value;return Array.isArray(r==null?void 0:r.enum)||Array.isArray(r==null?void 0:r.oneOf)})),Ze=B.withJsonFormsControlProps(St),Ot=/\{([A-Za-z0-9_]+)(?:\(([^(){}]*)\))?\}/g,Vr={today:e=>ht().format(e||"YYYY-MM-DD")},Hr=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="bigint",Qe=(e,r)=>Object.prototype.hasOwnProperty.call(e,r);function ze(e,r,t={}){const o={...Vr,...t};return e.replace(Ot,(l,i,a)=>{let c;if(a===void 0){if(!Qe(r,i))return l;c=r[i]}else{if(!Qe(o,i))return l;try{c=o[i](a)}catch{return l}}return c==null?"":Hr(c)?String(c):l})}function He(e){const r=[];let t=0;for(const o of e.matchAll(Ot))o.index>t&&r.push(e.slice(t,o.index)),r.push(o[2]===void 0?{name:o[1]}:{name:o[1],arg:o[2]}),t=o.index+o[0].length;return t<e.length&&r.push(e.slice(t)),r}function qr(e){if(typeof e=="string"&&e.length>0)return e;if(e&&typeof e=="object"&&typeof e.value=="string"){const r=e.value;return r.length>0?r:void 0}}function Xr(e){if(typeof e=="string")return e.length>0?{parent:e}:void 0;if(!e||typeof e!="object")return;const r=Object.entries(e);if(r.length===0)return;const t={},o=[];for(const[l,i]of r)typeof i=="string"&&i.length>0?t[l]=i:o.push(l);return o.length>0&&console.warn(`x-search.dependsOn: ignoring invalid entries [${o.join(", ")}]`),Object.keys(t).length===0?(console.warn("x-search.dependsOn: map has no valid entries; search will not fetch until fixed"),{}):t}function Jr(e,r,t){const o={};for(const[l,i]of Object.entries(e))o[l]=qr(b.Resolve.data(r,t?`${t}.${i}`:i));return o}function et(e,r){return r?{...e,name:ze(r,e)}:e}const Kr={"small-list":{fetchOnOpen:!0,searchable:!1,paginated:!1},"large-searchable-list":{fetchOnOpen:!0,searchable:!0,paginated:!1},"large-paginated-list":{fetchOnOpen:!1,searchable:!0,paginated:!0}},Yr=({data:e,handleChange:r,path:t,label:o,required:l,errors:i,enabled:a,visible:c=!0,schema:u,uischema:d})=>{var De,ge;const f=(u==null?void 0:u["x-search"])??{service:"",displayTemplate:""},m=f.service??"",x=f.mode??"large-paginated-list",p=Kr[x],j=(p==null?void 0:p.fetchOnOpen)??!1,w=typeof f.displayTemplate=="string"?f.displayTemplate:"",N=B.useJsonForms(),I=t.split(".").slice(0,-1).join("."),{parentValues:O,parentValuesKey:C,missingParent:R}=g.useMemo(()=>{var ye;const T=Xr(f.dependsOn);if(!T)return{parentValues:void 0,parentValuesKey:"",missingParent:!1};const te=Jr(T,(ye=N.core)==null?void 0:ye.data,I),ae=Object.keys(te).length===0||Object.values(te).some(Ee=>!Ee);return{parentValues:te,parentValuesKey:JSON.stringify(te),missingParent:ae}},[f.dependsOn,(De=N.core)==null?void 0:De.data,I]),v=g.useMemo(()=>O?{...f.params,...O}:f.params,[O,C,f.params]),y=yt(m),z=u.type==="object",P=z?typeof e=="string"?{value:e}:e??void 0:void 0,F=z?P==null?void 0:P.value:e,$=P==null?void 0:P.label,k=m?y?p?w?null:"x-search.displayTemplate is required.":`Invalid x-search.mode "${x}". Expected "small-list", "large-searchable-list", or "large-paginated-list".`:`Search service "${m}" is not registered.`:"Search not configured.",ne=a!==!1,K=!i||i.length===0,[L,U]=g.useState(!1),[Q,de]=g.useState(""),[oe,ee]=g.useState([]),[D,H]=g.useState(!1),[S,Y]=g.useState(!1),[fe,M]=g.useState(!1),[G,ie]=g.useState(null),[xe,pe]=g.useState(void 0),h=g.useRef(void 0),E=g.useRef(null),_=g.useRef(null),Z=g.useRef(null),q=g.useRef(void 0),he=g.useRef(void 0);g.useEffect(()=>{if(!O)return;const T=he.current;if(he.current=O,!T||!F)return;Object.keys(O).some(ae=>T[ae]!==void 0&&T[ae]!==O[ae])&&r(t,z?void 0:null)},[C,F,r,t,z]),g.useEffect(()=>{var ye,Ee;if(k){pe(void 0),q.current=void 0;return}if(!F){pe(void 0),q.current=void 0;return}if(((ye=q.current)==null?void 0:ye.value)===F&&((Ee=q.current)==null?void 0:Ee.label)===$)return;if(z&&$){pe({id:F,name:$}),q.current={value:F,label:$};return}if(pe({id:F,name:$??F}),!(y!=null&&y.resolve)){q.current={value:F,label:$};return}let T=!1;const te=F,ae=$;return y.resolve(te,v).then(ke=>{T||(ke&&pe(et(ke,w)),q.current={value:te,label:ae})}).catch(()=>{T||(q.current={value:te,label:ae})}),()=>{T=!0}},[k,F,$,z,y,v,w]);const A=g.useCallback(async(T,te=!1)=>{var ye;if(k)return;if(!y){ie("Search service not configured.");return}(ye=_.current)==null||ye.abort();const ae=new AbortController;_.current=ae,te?M(!0):(Y(!0),M(!1),ie(null));try{const Ee=await y.search({query:T,cursor:te?h.current:void 0,signal:ae.signal,params:v});if(ae.signal.aborted)return;const ke=(Ee.options??[]).map(Pe=>et(Pe,w));ee(te?Pe=>[...Pe,...ke]:ke),h.current=Ee.nextCursor,H(((p==null?void 0:p.paginated)??!1)&&Ee.nextCursor!=null)}catch{if(ae.signal.aborted)return;ie("Failed to load results. Please try again.")}finally{ae.signal.aborted||(te?M(!1):Y(!1))}},[k,y,p==null?void 0:p.paginated,v,w]);g.useEffect(()=>{if(!L)return;const T=te=>{Z.current&&!Z.current.contains(te.target)&&U(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[L]),g.useEffect(()=>{var T;L||((T=_.current)==null||T.abort(),de(""),ee([]),H(!1),ie(null),Y(!1),M(!1),h.current=void 0)},[L]),g.useEffect(()=>{if(!L)return;if(R){ee([]),H(!1),ie(null),h.current=void 0;return}if(!Q&&!j){ee([]),H(!1),ie(null),h.current=void 0;return}E.current&&clearTimeout(E.current);const T=Q?300:0;return E.current=setTimeout(()=>{ee([]),H(!1),h.current=void 0,A(Q)},T),()=>{E.current&&clearTimeout(E.current)}},[Q,L,j,A,R,C]),je(c,t,r);const W=be(t,l,c);if(c===!1)return null;const le=()=>{de(""),ee([]),H(!1),ie(null),h.current=void 0,U(!0)},X=T=>{r(t,z?{value:T.id,label:T.name}:T.id),pe(T),q.current={value:T.id,label:z?T.name:void 0},U(!1)},V=T=>{T.stopPropagation(),r(t,void 0),pe(void 0)},Ce=T=>{(T.key==="Enter"||T.key===" ")&&V(T)},Oe=((ge=d==null?void 0:d.options)==null?void 0:ge.placeholder)??"Select an option";return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[o," ",W&&n.jsx(s.Text,{color:"red",children:"*"})]}),n.jsxs("div",{ref:Z,style:{position:"relative"},children:[n.jsx(s.TextField.Root,{id:t,value:L?Q:(xe==null?void 0:xe.name)??"",placeholder:L&&(p!=null&&p.searchable)?"Search...":Oe,disabled:!ne,readOnly:L&&!(p!=null&&p.searchable),style:K?void 0:{outline:"2px solid var(--red-7)",outlineOffset:"-1px"},onChange:T=>{p!=null&&p.searchable&&(de(T.target.value),L||le())},onFocus:()=>{ne&&!L&&le()},onKeyDown:T=>{T.key==="Escape"&&U(!1)},children:n.jsx(s.TextField.Slot,{side:"right",children:n.jsxs(s.Flex,{align:"center",gap:"1",children:[F&&ne&&n.jsx("span",{role:"button",tabIndex:0,onMouseDown:T=>T.preventDefault(),onClick:V,onKeyDown:Ce,style:{lineHeight:1,color:"var(--gray-9)",padding:"0 2px",cursor:"pointer"},"aria-label":"Clear selection",children:"×"}),n.jsx(re.ChevronDownIcon,{style:{transform:L?"rotate(180deg)":void 0,transition:"transform 150ms"}})]})})}),L&&n.jsx(s.Box,{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:50,background:"var(--color-panel-solid)",borderRadius:"var(--radius-3)",boxShadow:"var(--shadow-5)",border:"1px solid var(--gray-a6)",overflow:"hidden"},children:k?n.jsx(s.Box,{p:"3",children:n.jsx(s.Text,{size:"2",color:"gray",children:k})}):n.jsx(s.ScrollArea,{style:{maxHeight:240},children:n.jsxs(s.Box,{p:"1",children:[S&&n.jsx(s.Flex,{justify:"center",p:"4",children:n.jsx(s.Spinner,{})}),!S&&G&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Text,{size:"2",color:"red",children:G})}),!S&&!G&&oe.length===0&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Text,{size:"2",color:"gray",children:R?"Select the related field first.":Q||j?"No results found.":"Type to search…"})}),oe.map(T=>n.jsx(s.Box,{px:"3",py:"2",onMouseDown:te=>te.preventDefault(),onClick:()=>X(T),style:{cursor:"pointer",borderRadius:"var(--radius-2)",backgroundColor:T.id===F?"var(--accent-3)":void 0},className:"hover:bg-(--gray-3)",children:n.jsx(s.Text,{size:"2",children:T.name})},T.id)),(p==null?void 0:p.paginated)&&D&&!fe&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Button,{variant:"ghost",size:"1",style:{width:"100%"},onMouseDown:T=>T.preventDefault(),onClick:()=>void A(Q,!0),children:"Load more"})}),fe&&n.jsx(s.Flex,{justify:"center",p:"2",children:n.jsx(s.Spinner,{})})]})})})]}),!K&&n.jsx(s.Text,{color:"red",size:"1",children:ve(i,o)}),u.description&&n.jsx(s.Text,{size:"1",color:"gray",children:u.description})]})})},It=B.withJsonFormsControlProps(Yr),kt=b.rankWith(3,b.schemaMatches(e=>{const r=e["x-search"];return(e.type==="string"||e.type==="object")&&typeof(r==null?void 0:r.service)=="string"&&r.service!==""})),Gr=e=>{if(e)return/^\d{2}:\d{2}$/.test(e)?`${e}:00`:e},tt=(e,r)=>{if(!e)return"";const t=e.match(/^(\d{2}:\d{2})(:\d{2})?/);return t?r?`${t[1]}${t[2]??":00"}`:t[1]:e},Zr=(e,r)=>ht(`${e}T${r}`).format(),Qr=({path:e,label:r,required:t,errors:o,description:l,children:i})=>{const a=o.length===0;return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",htmlFor:e,children:[r," ",t&&n.jsx(s.Text,{color:"red",children:"*"})]}),i,!a&&n.jsx(s.Text,{color:"red",size:"1",children:ve(o,r)}),l&&n.jsx(s.Text,{size:"1",color:"gray",children:l})]})})},Dt=({data:e,handleChange:r,path:t,label:o,required:l,errors:i,schema:a,uischema:c,enabled:u,visible:d=!0})=>{var v;g.useEffect(()=>{d===!1&&r(t,void 0)},[d,t,r]);const f=be(t,l,d);if(d===!1)return null;const m=i.length===0,x=typeof e=="string"?e:"",p=((v=c==null?void 0:c.options)==null?void 0:v.showSeconds)===!0,j=p?1:60,w=y=>n.jsx(Qr,{path:t,label:o,required:f,errors:i,description:a.description,children:y});if(a.format==="time")return w(n.jsx(s.TextField.Root,{type:"time",step:j,value:tt(x,p),onChange:y=>r(t,Gr(y.target.value)),disabled:!u,color:m?void 0:"red",id:t}));const N=a.format==="date-time",[I="",O=""]=x.split("T"),C=tt(O,p),R=(y,z)=>{if(!y){r(t,void 0);return}r(t,N?Zr(y,z||"00:00"):y)};return w(n.jsxs(s.Flex,{gap:"2",align:"center",children:[n.jsx(s.TextField.Root,{type:"date",value:I,disabled:!u,color:m?void 0:"red",onChange:y=>R(y.target.value,C),id:t,style:{flex:1}}),N&&n.jsx(s.TextField.Root,{type:"time",step:j,value:C,disabled:!u||!I,color:m?void 0:"red",onChange:y=>R(I,y.target.value),style:{flex:1}})]}))},Nt=b.rankWith(2,b.or(b.isDateControl,b.isDateTimeControl,b.isTimeControl)),en=B.withJsonFormsControlProps(Dt),Lt=({uischema:e,schema:r,path:t,renderers:o,cells:l,enabled:i,visible:a=!0})=>{const u=e.elements;return a===!1?null:n.jsx(s.Flex,{direction:"column",gap:"4",children:u.map((d,f)=>n.jsx(B.JsonFormsDispatch,{uischema:d,schema:r,path:t,renderers:o,cells:l,enabled:i},`${t}-${f}`))})},Mt=b.rankWith(1,b.uiTypeIs("VerticalLayout")),zt=({uischema:e,schema:r,path:t,renderers:o,cells:l,enabled:i,visible:a=!0})=>{const u=e.elements;return a===!1?null:n.jsx(s.Flex,{direction:"row",gap:"4",children:u.map((d,f)=>n.jsx(s.Box,{style:{flex:1},children:n.jsx(B.JsonFormsDispatch,{uischema:d,schema:r,path:t,renderers:o,cells:l,enabled:i})},`${t}-${f}`))})},Pt=b.rankWith(1,b.uiTypeIs("HorizontalLayout")),Ut=({uischema:e,schema:r,path:t,renderers:o,cells:l,enabled:i,visible:a=!0})=>{const c=e,u=c.elements;return a===!1?null:n.jsxs(s.Box,{mb:"6",children:[c.label&&n.jsx(s.Heading,{size:"3",mb:"3",className:"text-gray-500 uppercase tracking-wide font-semibold",children:c.label}),n.jsx(s.Flex,{direction:"column",gap:"4",children:u.map((d,f)=>n.jsx(B.JsonFormsDispatch,{uischema:d,schema:r,path:t,renderers:o,cells:l,enabled:i},`${t}-${f}`))})]})},$t=b.rankWith(1,b.uiTypeIs("Group")),Bt=({uischema:e,schema:r,path:t,renderers:o,cells:l,enabled:i,visible:a=!0})=>{var x;const u=e.elements.filter(p=>p.type==="Category"),[d,f]=g.useState(((x=u[0])==null?void 0:x.label)||"");if(a===!1||!u.length)return null;const m=u.find(p=>p.label===d)?d:u[0].label;return n.jsxs(s.Tabs.Root,{value:m,onValueChange:f,children:[n.jsx(s.Tabs.List,{children:u.map((p,j)=>n.jsx(s.Tabs.Trigger,{value:p.label,children:p.label},`${t}-${j}`))}),n.jsx(s.Box,{pt:"3",children:u.map((p,j)=>n.jsx(s.Tabs.Content,{value:p.label,children:n.jsx(s.Flex,{direction:"column",gap:"4",children:p.elements.map((w,N)=>n.jsx(B.JsonFormsDispatch,{uischema:w,schema:r,path:t,renderers:o,cells:l,enabled:i},`${t}-${j}-${N}`))})},`${t}-${j}`))})]})},_t=b.rankWith(1,b.uiTypeIs("Categorization"));function we(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(0)} MB`:e>=1024?`${(e/1024).toFixed(0)} KB`:`${e} B`}function Te(e){const r=e.split(",").map(i=>i.trim()).filter(Boolean),t=r.filter(i=>i.startsWith(".")),l=(t.length>0?t:r).map(i=>{if(i.endsWith("/*"))return i.split("/")[0].toUpperCase()+"S";if(i.startsWith("."))return i.slice(1).toUpperCase();const a=i.split("/")[1];return a?a.toUpperCase():i});return[...new Set(l)].join(", ")}const tn="image/png,image/jpeg,image/gif,image/webp,application/pdf,text/html,text/plain,.png,.jpg,.jpeg,.gif,.webp,.pdf,.html,.htm,.txt";function Wt(e,r){return r.split(",").map(o=>o.trim()).filter(Boolean).some(o=>o==="*"||o==="*/*"?!0:o.endsWith("/*")?(e.type??"").startsWith(o.slice(0,-1)):o.startsWith(".")?e.name.toLowerCase().endsWith(o.toLowerCase()):e.type===o)}function rn(e){const r=!!e.type,t=Be(e.name)!==void 0;return!r&&!t?!0:Wt(e,tn)}function Be(e){const r=e.split(/[/\\]/).pop()??e,t=r.lastIndexOf(".");if(!(t<=0||t===r.length-1))return r.slice(t)}function nn(e,r,t){Vt(new Blob([e],{type:t}),r)}function Vt(e,r){const t=URL.createObjectURL(e),o=document.createElement("a");o.href=t,o.download=r,o.click(),setTimeout(()=>URL.revokeObjectURL(t),0)}async function on(e,r){const t=await fetch(e);if(!t.ok)throw new Error(`Download failed (${t.status})`);Vt(await t.blob(),r)}function sn(e,r,t){const o=t.name||t.key;if(!e)return o;const l=qe(e,r,o),i=Be(t.name??"")??Be(t.key);return!i||l.toLowerCase().endsWith(i.toLowerCase())?l:`${l}${i}`}const ln=new Set(["/","\\","<",">",":",'"',"|","?","*"]),an=e=>ln.has(e)||e.charCodeAt(0)<32||e.charCodeAt(0)===127;function cn(e,r){const t=Array.from(e,o=>an(o)?"_":o).join("").trim();return t===""||t.startsWith(".")?r:t}function qe(e,r,t){const o=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:{};return cn(ze(e,o),t)}function un(e){return e?Array.isArray(e)?e:[e]:[]}const dn=({data:e,handleChange:r,path:t,label:o,required:l,uischema:i,schema:a,enabled:c,errors:u,visible:d=!0})=>{const f=mt();je(d,t,r);const m=be(t,l,d),x=!u||u.length===0,p=(a==null?void 0:a["x-file"])??{},j=(i==null?void 0:i.options)??{},w=p.maxFiles??j.maxFiles??1,N=p.maxSize??j.maxSize??5*1024*1024,I=p.accept??j.accept??"image/*,application/pdf",O=typeof p.fileName=="string"?p.fileName:void 0,C=w>1,R=c!==!1,[v,y]=g.useState(!1),[z,P]=g.useState(null),[F,$]=g.useState({}),[k,ne]=g.useState({}),K=g.useRef(new Set),L=g.useRef(null),U=un(e),Q=U.length>=w,de=h=>{const E=k[h];return{name:(E==null?void 0:E.name)??h,type:E==null?void 0:E.type}},oe=async h=>{var Z,q;const E=(Z=k[h])==null?void 0:Z.blobUrl;if(E)return E;const _=await((q=f==null?void 0:f.getDownloadUrl)==null?void 0:q.call(f,h));return _==null?void 0:_.url},ee=(h,E)=>{$(_=>({..._,[h]:E}))},D=h=>{$(E=>{if(!E[h])return E;const _={...E};return delete _[h],_})};g.useEffect(()=>()=>{K.current.forEach(h=>URL.revokeObjectURL(h)),K.current.clear()},[]);const H=g.useCallback(async h=>{if(P(null),U.length>=w){P(`Maximum ${w} file${w>1?"s":""} allowed.`);return}if(h.size>N){P(`File exceeds the ${we(N)} limit.`);return}if(!Wt(h,I)){P(`Invalid type. Accepted: ${Te(I)}`);return}if(!(f!=null&&f.onUpload)){P("Upload service not configured.");return}try{const E=await f.onUpload(h),_=URL.createObjectURL(h);K.current.add(_);const Z={key:E.key,name:E.name??h.name,type:h.type||void 0,blobUrl:_};ne(he=>({...he,[E.key]:Z}));const q=[...U,E.key];r(t,C?q:q[0])}catch{P("Upload failed. Please try again."),L.current&&(L.current.value="")}},[U,w,N,I,f,t,r,C]);if(d===!1)return null;const S=h=>{h.preventDefault(),h.stopPropagation(),!(!R||Q)&&y(h.type==="dragenter"||h.type==="dragover")},Y=h=>{var E;h.preventDefault(),h.stopPropagation(),y(!1),!(!R||Q)&&(E=h.dataTransfer.files)!=null&&E[0]&&H(h.dataTransfer.files[0])},fe=h=>{var E;(E=h.target.files)!=null&&E[0]&&(H(h.target.files[0]),h.target.value="")},M=h=>{if(!R)return;ne(_=>{var he;const Z={..._},q=(he=Z[h])==null?void 0:he.blobUrl;return q&&(URL.revokeObjectURL(q),K.current.delete(q)),delete Z[h],Z}),D(h);const E=U.filter(_=>_!==h);r(t,C?E.length>0?E:void 0:E[0])},G=async(h,E)=>{var q,he;h.preventDefault(),D(E);const _=(q=k[E])==null?void 0:q.blobUrl;if(_){(he=window.open(_,"_blank","noopener,noreferrer"))==null||he.focus();return}const Z=window.open("","_blank");if(Z)try{const A=await oe(E);A?Z.location.href=A:(Z.close(),ee(E,"Unable to open file."))}catch{Z.close(),ee(E,"Unable to open file.")}},ie=async(h,E)=>{D(h);try{const _=await oe(h);if(!_){ee(h,"Unable to download file.");return}await on(_,E)}catch{ee(h,"Unable to download file.")}};if(!R&&U.length===0)return null;const xe=w-U.length,pe=R&&!Q;return n.jsxs(s.Box,{mb:"4",children:[n.jsxs(s.Flex,{align:"center",justify:"between",mb:"2",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",children:[o,m&&n.jsx(s.Text,{color:"red",children:" *"})]}),n.jsx(s.Text,{size:"1",color:"gray",children:C?`Up to ${w} files · ${we(N)} each · ${Te(I)}`:`${we(N)} · ${Te(I)}`})]}),U.map((h,E)=>{var X;const _=E+1,Z=(X=k[h])==null?void 0:X.name,q=sn(O,{index:_},{name:Z,key:h}),he=O?q:Z??"Uploaded File",A=!!(O&&Z),W=F[h],le=rn(de(h));return n.jsxs(s.Card,{size:"2",variant:"surface",mb:"2",children:[n.jsxs(s.Flex,{align:"center",gap:"3",children:[n.jsx(s.Box,{style:{background:"var(--blue-3)",padding:8,borderRadius:6,color:"var(--blue-9)",flexShrink:0},children:n.jsx(re.FileTextIcon,{width:"20",height:"20"})}),n.jsxs(s.Box,{style:{flex:1,overflow:"hidden"},children:[n.jsx(s.Text,{size:"2",weight:"bold",style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:he}),A&&n.jsx(s.Text,{size:"1",color:"gray",style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Z})]}),n.jsxs(s.Flex,{align:"center",gap:"2",style:{flexShrink:0},children:[le&&n.jsx(s.Button,{variant:"soft",color:"blue",size:"1",onClick:V=>void G(V,h),children:"View"}),n.jsx(s.Tooltip,{content:"Download",children:n.jsx(s.IconButton,{variant:"ghost",color:"gray","aria-label":"Download",onClick:()=>void ie(h,q),children:n.jsx(re.DownloadIcon,{})})}),n.jsx(re.CheckCircledIcon,{style:{color:"var(--green-9)",width:18,height:18}}),R&&n.jsx(s.IconButton,{variant:"ghost",color:"gray",onClick:()=>M(h),children:n.jsx(re.Cross2Icon,{})})]})]}),W&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:W})]},h)}),pe&&n.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{var h;return(h=L.current)==null?void 0:h.click()},onKeyDown:h=>{var E;(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),(E=L.current)==null||E.click())},onDragEnter:S,onDragLeave:S,onDragOver:S,onDrop:Y,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",v?"border-blue-500 bg-blue-50":z?"border-red-300 bg-red-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"].join(" "),children:[n.jsx("input",{ref:L,type:"file",style:{display:"none"},accept:I,onChange:fe}),n.jsx(s.Flex,{direction:"column",align:"center",gap:"2",children:z?n.jsxs(n.Fragment,{children:[n.jsx(re.ExclamationTriangleIcon,{style:{width:32,height:32,color:"var(--red-9)"}}),n.jsx(s.Text,{size:"2",color:"red",weight:"medium",children:z}),n.jsx(s.Text,{size:"1",color:"gray",children:"Click to try again"})]}):n.jsxs(n.Fragment,{children:[n.jsx(re.UploadIcon,{style:{width:32,height:32,color:"var(--gray-8)"}}),n.jsx(s.Text,{size:"2",weight:"medium",children:U.length>0?`Add another file (${xe} remaining)`:"Click to upload or drag and drop"}),n.jsxs(s.Text,{size:"1",color:"gray",children:[we(N)," max · ",Te(I)]})]})})]}),R&&Q&&C&&n.jsxs(s.Text,{size:"1",color:"gray",mt:"1",style:{display:"block",textAlign:"center"},children:["Maximum ",w," files uploaded. Remove one to replace it."]}),!x&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:ve(u,o)})]})},Ht=B.withJsonFormsControlProps(dn),qt=b.rankWith(10,b.and(b.schemaMatches(e=>{if(e.type==="string"&&e.format==="file")return!0;if(e.type==="array"){const r=e.items;return(r==null?void 0:r.type)==="string"&&(r==null?void 0:r.format)==="file"}return!1})));function Xt(e,r){return e!==!1&&r!==!0}class _e extends Error{}async function fn(e,r){const{read:t,utils:o}=await import("@e965/xlsx"),l=t(e,{type:"array",cellDates:!0});if(l.SheetNames.length===0)throw new _e("This file has no sheets.");const i=r??l.SheetNames[0],a=l.Sheets[i];if(!a)throw new _e(`This file doesn't have a sheet named "${i}".`);const c=o.sheet_to_json(a,{header:1,raw:!0,defval:null});return{sheetName:i,matrix:c,rowCount:c.length,colCount:Math.max(0,...c.map(u=>u.length))}}function pn(e){let r=e+1,t="";for(;r>0;){const o=(r-1)%26;t=String.fromCharCode(65+o)+t,r=Math.floor((r-1)/26)}return t}class ue extends Error{constructor(t,o){super(o??t);Ye(this,"code");this.code=t,this.name="FormulaError"}}const hn=["IFS","IFERROR","AND","OR","NOT","ROUND","ROUNDUP","ROUNDDOWN","INDEX","VLOOKUP","HLOOKUP","SUM","AVERAGE","COUNT","DATE","TODAY"],xn=["MAX","MIN","MAXA","MINA","MEDIAN","LARGE","SMALL","PERMUT","PERMUTATIONA","MATCH","SWITCH","SUBSTITUTE","TEXTJOIN","COUNTA","UPPER"],mn=["YEAR","MONTH","DAY","WEEKDAY"],gn=["IF"],yn=["CONCATENATE","CONCAT","LEN","TRIM","LOWER","LEFT","RIGHT","MID","FIND","SEARCH"],bn=new Set([...hn,...xn,...mn,...yn,...gn]),vn=/"(?:[^"]|"")*"/g,rt=new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(","g");function wn(e){const r=e.replace(vn,o=>" ".repeat(o.length));rt.lastIndex=0;let t;for(;(t=rt.exec(r))!==null;){const o=t[1].toUpperCase();if(!bn.has(o))throw new ue("NAME",`Function ${o} is not allowed.`)}}function Tn(e,r,t){let o=e;if(o==null)throw t.NA;if(typeof o=="object"&&!(o instanceof t)&&(o=r.retrieveRef(o)),o instanceof t)throw o;if(typeof o=="boolean")return o;if(typeof o=="number")return o!==0;throw t.VALUE}function Jt(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function Fe(e){const r=Jt(e);return Array.isArray(r)?r.flat(1/0):[r]}function J(e){const r=Jt(e);return Array.isArray(r)?r.flat(1/0)[0]:r}function Ne(e){return e===void 0?void 0:J(e)}function ce(e){return e==null||e===""?"":typeof e=="boolean"?e?"TRUE":"FALSE":e instanceof Date?e.toLocaleDateString():String(e)}function jn(e,r){return e instanceof r?e:new r(e.message||"#ERROR!")}function se(e){return e.find(r=>r instanceof Error)}function En(e,r){const t=i=>{throw jn(i,r)},o=(i,{checkArgsForErrors:a=!0}={})=>(...c)=>{const u=c.flatMap(Fe);if(a){const f=se(u);f&&t(f)}const d=i(...u);return d instanceof Error?t(d):d},l=(i,{toText:a=!1}={})=>c=>{const u=J(c),d=se([u]);d&&t(d);const f=i(a?ce(u):u);return f instanceof Error?t(f):f};return{IF:(i,a,c,u)=>{const d=Tn(a,i,r);if(c==null)throw r.NA;return d?c:u??!1},MAX:o(e.MAX),MIN:o(e.MIN),MAXA:o(e.MAXA),MINA:o(e.MINA),MEDIAN:o(e.MEDIAN),COUNTA:o(e.COUNTA,{checkArgsForErrors:!1}),LARGE:(i,a)=>{const c=Fe(i),u=J(a),d=se([...c,u]);d&&t(d);const f=e.LARGE(c,u);return f instanceof Error?t(f):f},SMALL:(i,a)=>{const c=Fe(i),u=J(a),d=se([...c,u]);d&&t(d);const f=e.SMALL(c,u);return f instanceof Error?t(f):f},PERMUT:(i,a)=>{const c=[J(i),J(a)],u=se(c);u&&t(u);const d=e.PERMUT(c[0],c[1]);return d instanceof Error?t(d):d},PERMUTATIONA:(i,a)=>{const c=[J(i),J(a)],u=se(c);u&&t(u);const d=e.PERMUTATIONA(c[0],c[1]);return d instanceof Error?t(d):d},MATCH:(i,a)=>{const c=J(i),u=Fe(a),d=se([c,...u]);d&&t(d);const f=e.MATCH(c,u,0);return f instanceof Error?t(f):f},SWITCH:(...i)=>{const a=i.map(J),c=se(a);c&&t(c);const u=e.SWITCH(...a);return u instanceof Error?t(u):u},SUBSTITUTE:(i,a,c,u)=>{const d=[ce(J(i)),ce(J(a)),ce(J(c))];u!==void 0&&d.push(J(u));const f=se(d);f&&t(f);const m=e.SUBSTITUTE(...d);return m instanceof Error?t(m):m},TEXTJOIN:(i,a,...c)=>{const u=ce(J(i)),d=J(a),f=c.flatMap(Fe).map(ce),m=se([u,d]);m&&t(m);const x=e.TEXTJOIN(u,d,f);return x instanceof Error?t(x):x},UPPER:l(e.UPPER),YEAR:l(e.YEAR),MONTH:l(e.MONTH),DAY:l(e.DAY),WEEKDAY:(i,a)=>{const c=J(i),u=J(a),d=se([c]);d&&t(d);const f=e.WEEKDAY(c,u);return f instanceof Error?t(f):f},CONCATENATE:(...i)=>{const a=i.flatMap(Fe),c=se(a);c&&t(c);const u=e.CONCATENATE(...a.map(ce));return u instanceof Error?t(u):u},CONCAT:(...i)=>{const a=i.flatMap(Fe),c=se(a);c&&t(c);const u=e.CONCAT(...a.map(ce));return u instanceof Error?t(u):u},LEN:l(e.LEN,{toText:!0}),TRIM:l(e.TRIM,{toText:!0}),LOWER:l(e.LOWER,{toText:!0}),LEFT:(i,a)=>{const c=J(i),u=Ne(a),d=se([c]);d&&t(d);const f=e.LEFT(ce(c),u);return f instanceof Error?t(f):f},RIGHT:(i,a)=>{const c=J(i),u=Ne(a),d=se([c]);d&&t(d);const f=e.RIGHT(ce(c),u);return f instanceof Error?t(f):f},MID:(i,a,c)=>{const u=J(i),d=J(a),f=J(c),m=se([u,d,f]);m&&t(m);const x=e.MID(ce(u),d,f);return x instanceof Error?t(x):x},FIND:(i,a,c)=>{const u=J(i),d=J(a),f=Ne(c),m=se([u,d]);m&&t(m);const x=e.FIND(ce(u),ce(d),f);return x instanceof Error?t(x):x},SEARCH:(i,a,c)=>{const u=J(i),d=J(a),f=Ne(c),m=se([u,d]);m&&t(m);const x=e.SEARCH(ce(u),ce(d),f);return x instanceof Error?t(x):x}}}const Cn={"#REF!":"REF","#VALUE!":"VALUE","#DIV/0!":"DIV0","#NAME?":"NAME","#N/A":"NA","#NUM!":"NUM","#NULL!":"NULL"};function nt(e){return Cn[e.error]??"ERROR"}function ot(e,r){if(e instanceof ue)return e;if(e instanceof r){const t=e.details;return t instanceof ue?t:t instanceof r?new ue(nt(t),t.message):new ue(nt(e),e.message)}return new ue("ERROR",e instanceof Error?e.message:void 0)}function Rn(e){return Math.max(0,...e.map(r=>(r==null?void 0:r.length)??0))}function Sn(e){return r=>{const t=e[r.row-1];if(r.row<1||r.col<1||t==null||r.col-1>=t.length)throw new ue("REF");const o=t[r.col-1];return o==null||o===""?null:o}}function An(e){return r=>{const t=Math.min(r.from.row,r.to.row),o=Math.min(r.from.col,r.to.col),l=Math.max(r.from.row,r.to.row),i=Math.max(r.from.col,r.to.col),a=Rn(e);if(t>e.length||o>a)throw new ue("REF");const c=Math.min(l,e.length),u=[];for(let d=t;d<=c;d++){const f=e[d-1],m=[];if(f!=null){const x=Math.min(i,f.length);for(let p=o;p<=x;p++){const j=f[p-1];m.push(j==null||j===""?null:j)}}u.push(m)}return u}}function Fn(e){if(e==null||e==="")return null;if(typeof e=="number"||typeof e=="string"||typeof e=="boolean"||e instanceof Date)return e;throw new ue("VALUE")}async function Kt(e,r){if(typeof e!="string")throw new ue("ERROR");const t=e.trim();if(t==="")throw new ue("ERROR");const o=t.startsWith("=")?t.slice(1):t;wn(o);const[l,i]=await Promise.all([import("fast-formula-parser"),import("@formulajs/formulajs")]),a=l.default??l,c=a.FormulaError,u=new a({...r,functions:En(i,c)});let d;try{d=u.parse(o,{row:1,col:1,sheet:"Sheet1"})}catch(f){throw ot(f,c)}if(d instanceof c)throw ot(d,c);return Fn(d)}async function On(e,r){return Kt(r,{onCell:Sn(e),onRange:An(e)})}const st=-1;async function Yt(e,r){const t=Object.keys(e);return Kt(r,{onVariable:o=>{const l=t.indexOf(o);return l===-1?null:{row:st,col:l+1}},onCell:o=>{if(o.row===st)return e[t[o.col-1]]??null;throw new ue("REF")},onRange:()=>{throw new ue("REF")}})}const Gt={REF:"#REF!",VALUE:"#VALUE!",DIV0:"#DIV/0!",NAME:"#NAME?",ERROR:"#ERROR!",NA:"#N/A",NUM:"#NUM!",NULL:"#NULL!"};function Xe(e){const r=e instanceof ue?e.code:"ERROR";return Gt[r]}async function In(e,r){return e.length===0?r.map(t=>({id:typeof(t==null?void 0:t.id)=="string"?t.id:"(unknown)",label:(t==null?void 0:t.label)??"(unknown)",value:null,error:Gt.ERROR})):Promise.all(r.map(async t=>{try{if(!t||typeof t.label!="string"||typeof t.expression!="string"||typeof t.id!="string")throw new ue("ERROR");return{id:t.id,label:t.label,value:await On(e,t.expression)}}catch(o){return{id:typeof(t==null?void 0:t.id)=="string"?t.id:"(unknown)",label:(t==null?void 0:t.label)??"(unknown)",value:null,error:Xe(o)}}}))}function it(e){const r=new Set;for(const{id:t}of e){if(r.has(t))return t;r.add(t)}return null}function Zt(e){const{columnHeader:r,rowHeader:t,columns:o,rows:l}=e;if(o!==void 0&&!Array.isArray(o))return"columns must be an array of { id, label } objects.";if(l!==void 0&&!Array.isArray(l))return"rows must be an array of { id, label } objects.";if(o!==void 0&&o.length===0)return"columns is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";if(l!==void 0&&l.length===0)return"rows is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";const i=f=>!!f&&typeof f.id=="string"&&f.id!==""&&typeof f.label=="string"&&f.label!=="",a=o==null?void 0:o.findIndex(f=>!i(f));if(a!=null&&a!==-1)return`columns[${a}] must be a { id, label } object with non-empty string fields.`;const c=l==null?void 0:l.findIndex(f=>!i(f));if(c!=null&&c!==-1)return`rows[${c}] must be a { id, label } object with non-empty string fields.`;const u=!!o&&o.length>0,d=!!l&&l.length>0;if(u){const f=it(o);if(f)return`duplicate column id "${f}" — every declared column id must be unique.`}if(d){const f=it(l);if(f)return`duplicate row id "${f}" — every declared row id must be unique.`}return r&&t?"columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape.":u&&d?"columns and rows cannot both be declared — pick one orientation for the persisted sheet shape.":r&&!u?"columnHeader is true but columns is missing or empty — declare the column list columnHeader positions map to.":t&&!d?"rowHeader is true but rows is missing or empty — declare the row list rowHeader positions map to.":null}function lt(e,r={}){const t=Zt(r);if(t)throw new Error(`x-spreadsheet: ${t}`);const{columnHeader:o,rowHeader:l,columns:i,rows:a}=r;return i&&i.length>0?kn(e,i,o===!0):a&&a.length>0?Dn(e,a,l===!0):e}function kn(e,r,t){return(t?e.slice(1):e).map(l=>{const i=Object.create(null);return r.forEach((a,c)=>{i[a.id]=l[c]??null}),i})}function Dn(e,r,t){const o=t?1:0,l=Math.max(0,...e.map(a=>a.length)),i=Math.max(0,l-o);return Array.from({length:i},(a,c)=>{const u=o+c,d=Object.create(null);return r.forEach((f,m)=>{var x;d[f.id]=((x=e[m])==null?void 0:x[u])??null}),d})}function Qt(e){return!Array.isArray(e[0])}function Nn(e){const r=Object.create(null);for(const{id:t,label:o,value:l,error:i}of e)r[t]=i===void 0?{label:o,value:l}:{label:o,value:l,error:i};return r}function We(e,r){const t=o=>o instanceof Date?o.toISOString():o??null;return t(e)===t(r)}function Ln(e,r){const t=e??{},o=r??{},l=Object.keys(t);return l.length!==Object.keys(o).length?!1:l.every(i=>{if(!Object.prototype.hasOwnProperty.call(o,i))return!1;const a=t[i],c=o[i];return a.label===c.label&&a.error===c.error&&We(a.value,c.value)})}function Mn(e,r){if(e==null||r==null)return e===r;const t=Array.isArray(e);if(t!==Array.isArray(r))return!1;if(t){const a=e,c=r;return a.length===c.length&&a.every((u,d)=>We(u,c[d]))}const o=e,l=r,i=Object.keys(o);return i.length!==Object.keys(l).length?!1:i.every(a=>Object.prototype.hasOwnProperty.call(l,a)&&We(o[a],l[a]))}function zn(e,r){if(e===r)return!0;if(e==null||r==null)return!1;const t=e,o=r;return t.length!==o.length?!1:t.every((l,i)=>Mn(l,o[i]))}function Pn(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e instanceof Date}function er(e,r){if(e.length===0)return[];const t=[],o=new Set;for(const i of r??[])o.has(i)||(o.add(i),t.push(i));for(const i of e)for(const a of Object.keys(i))o.has(a)||(o.add(a),t.push(a));if(t.length===0)return[];const l=e.map(i=>t.map(a=>{if(!Object.prototype.hasOwnProperty.call(i,a))return null;const c=i[a];return Pn(c)?c:null}));return[t,...l]}function Un(e){const r=Math.max(0,...e.map(t=>t.length));return Array.from({length:r},(t,o)=>e.map(l=>l[o]??null))}const $n=".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv",Bn=10*1024*1024,$e=200,_n=50,Wn=[];function at(e){return e==null||e===""?"":e instanceof Date?e.toLocaleDateString():String(e)}const Vn=({data:e,handleChange:r,path:t,label:o,required:l,schema:i,enabled:a,readonly:c,errors:u,visible:d=!0})=>{je(d,t,r);const f=be(t,l,d),m=!u||u.length===0,x=Xt(a,c),p=(i==null?void 0:i["x-spreadsheet"])??{},j=(i==null?void 0:i["x-evaluate"])??Wn,w=p.accept??$n,N=p.maxSize??Bn,I=p.columnHeader===!0,O=p.rowHeader===!0,C=p.columns,R=p.rows,v=Array.isArray(C)&&C.length>0,y=Array.isArray(R)&&R.length>0,z=Zt({columnHeader:I,rowHeader:O,columns:C,rows:R}),P=p.showSheet!==!1,F=p.sheetName,$=p.persistSheet!==!1,k=e??null,[ne,K]=g.useState(()=>k!=null&&k.sheet||Object.keys((k==null?void 0:k.derivations)??{}).length>0?"ready":"empty"),[L,U]=g.useState(null),[Q,de]=g.useState(!1),[oe,ee]=g.useState(null),[D,H]=g.useState(null),S=g.useRef(null),Y=g.useRef(null),fe=(k==null?void 0:k.sheet)??null,M=g.useCallback(A=>{if(!Qt(A))return A;const W=y?R:v?C:void 0,le=er(A,W==null?void 0:W.map(X=>X.id));return y?Un(le):le},[v,y,C,R]),G=g.useMemo(()=>oe??(fe?M(fe):null),[oe,fe,M]),ie=((D==null?void 0:D.matrix)===G?D.derivations:null)??(k==null?void 0:k.derivations)??{},xe=G!=null||k!=null,pe=g.useMemo(()=>{const A=v?1:0,W=y?1:0,le=G?G.slice(A):[],X=le.slice(0,$e),V=Math.min(_n,Math.max(0,...X.map(ge=>Math.max(0,ge.length-W)))),Ce=Array.from({length:V},(ge,T)=>T+W),Oe="",De=y&&!v;return n.jsx(n.Fragment,{children:G&&P&&n.jsxs(s.Box,{mt:"3",children:[n.jsx(s.Box,{style:{overflow:"auto",maxHeight:420},children:n.jsxs(s.Table.Root,{variant:"surface",size:"1",children:[!De&&n.jsx(s.Table.Header,{children:n.jsxs(s.Table.Row,{children:[n.jsx(s.Table.ColumnHeaderCell,{children:Oe}),Ce.map(ge=>{var T;return n.jsx(s.Table.ColumnHeaderCell,{children:v?((T=C==null?void 0:C[ge])==null?void 0:T.label)??"":pn(ge)},ge)})]})}),n.jsx(s.Table.Body,{children:X.map((ge,T)=>{var ae;const te=A+T;return n.jsxs(s.Table.Row,{children:[n.jsx(s.Table.RowHeaderCell,{style:y?{fontWeight:700,background:"var(--gray-a3)"}:void 0,children:y?((ae=R==null?void 0:R[te])==null?void 0:ae.label)??"":v?"":te+1}),Ce.map(ye=>n.jsx(s.Table.Cell,{children:at(ge[ye])},ye))]},T)})})]})}),le.length>$e&&n.jsxs(s.Text,{size:"1",color:"gray",mt:"1",style:{display:"block"},children:["Showing first ",$e," of ",le.length," rows"]})]})})},[G,P,v,y,C,R]),h=g.useCallback(async A=>{if(U(null),A.size>N){U(`File exceeds the ${we(N)} limit.`);return}if(!w.split(",").map(V=>V.trim()).some(V=>V==="*"||V==="*/*"?!0:V.endsWith("/*")?A.type.startsWith(V.slice(0,-1)):V.startsWith(".")?A.name.toLowerCase().endsWith(V.toLowerCase()):A.type===V)){U(`Invalid type. Accepted: ${Te(w)}`);return}K("parsing");let X;try{const V=await A.arrayBuffer();X=(await fn(V,F)).matrix}catch(V){K("error"),U(V instanceof _e?V.message:"This doesn't look like a valid spreadsheet. Please check the file and try again.");return}if(v||y)try{X=M(lt(X,{columnHeader:I,rowHeader:O,columns:C,rows:R}))}catch(V){K("error"),U(V instanceof Error?V.message:"Failed to process this sheet.");return}Y.current=(e==null?void 0:e.sheet)??null,ee(X),K("ready")},[w,N,F,e,I,O,C,R,v,y,M]);if(g.useEffect(()=>{oe!=null&&fe!=null&&fe!==Y.current&&ee(null)},[oe,fe]),g.useEffect(()=>{if(z||j.length===0&&!$)return;let A=!1;const W=X=>{x&&(Ln(k==null?void 0:k.derivations,X==null?void 0:X.derivations)&&zn(k==null?void 0:k.sheet,X==null?void 0:X.sheet)||(Y.current=(X==null?void 0:X.sheet)??null,r(t,X)))},le=G??[];if(le.length===0){k!=null&&W(void 0);return}return In(le,j).then(X=>{if(A)return;let V;if(oe!=null){if($)try{V=lt(le,{columnHeader:v,rowHeader:y,columns:C,rows:R})}catch(Oe){U(Oe instanceof Error?Oe.message:"Failed to process this sheet.");return}}else V=k==null?void 0:k.sheet;U(null);const Ce=Nn(X);H({matrix:le,derivations:Ce}),W(V===void 0?{derivations:Ce}:{sheet:V,derivations:Ce})}),()=>{A=!0}},[G,oe,j,x,$,v,y,C,R,z]),d===!1)return null;if(z)return n.jsxs(s.Box,{mb:"4",children:[n.jsx(s.Text,{as:"label",size:"2",weight:"bold",children:o}),n.jsxs(s.Text,{size:"2",color:"red",style:{display:"block"},children:["Invalid x-spreadsheet config: ",z]})]});if(!x&&!xe)return null;const E=A=>{A.preventDefault(),A.stopPropagation(),x&&de(A.type==="dragenter"||A.type==="dragover")},_=A=>{var W;A.preventDefault(),A.stopPropagation(),de(!1),x&&(W=A.dataTransfer.files)!=null&&W[0]&&h(A.dataTransfer.files[0])},Z=A=>{var W;(W=A.target.files)!=null&&W[0]&&(h(A.target.files[0]),A.target.value="")},q=()=>{x&&(ee(null),H(null),Y.current=null,U(null),K("empty"),r(t,void 0))},he=P&&G==null&&k!=null;return n.jsxs(s.Box,{mb:"4",children:[n.jsxs(s.Flex,{align:"center",justify:"between",mb:"2",children:[n.jsxs(s.Flex,{align:"center",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",children:[o,f&&n.jsx(s.Text,{color:"red",children:" *"})]}),xe&&x&&n.jsxs(n.Fragment,{children:[n.jsx(s.Tooltip,{content:"Replace spreadsheet",children:n.jsx(s.IconButton,{variant:"ghost",size:"1",onClick:()=>{var A;return(A=S.current)==null?void 0:A.click()},"aria-label":"Replace spreadsheet",children:n.jsx(re.UploadIcon,{})})}),n.jsx(s.Tooltip,{content:"Remove spreadsheet",children:n.jsx(s.IconButton,{variant:"ghost",size:"1",color:"gray",onClick:q,"aria-label":"Remove spreadsheet",children:n.jsx(re.Cross2Icon,{})})})]})]}),n.jsxs(s.Text,{size:"1",color:"gray",children:[we(N)," max · ",Te(w)]})]}),xe&&L&&n.jsx(s.Text,{size:"2",color:"red",mb:"2",style:{display:"block"},children:L}),n.jsx("input",{ref:S,type:"file",style:{display:"none"},accept:w,onChange:Z}),x&&!xe&&n.jsx("div",{role:"button",tabIndex:0,onClick:()=>{var A;return(A=S.current)==null?void 0:A.click()},onKeyDown:A=>{var W;(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),(W=S.current)==null||W.click())},onDragEnter:E,onDragLeave:E,onDragOver:E,onDrop:_,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",Q?"border-blue-500 bg-blue-50":L?"border-red-300 bg-red-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"].join(" "),children:n.jsx(s.Flex,{direction:"column",align:"center",gap:"2",children:ne==="parsing"?n.jsxs(n.Fragment,{children:[n.jsx(s.Spinner,{size:"3"}),n.jsx(s.Text,{size:"2",color:"gray",children:"Parsing spreadsheet…"})]}):L?n.jsxs(n.Fragment,{children:[n.jsx(re.ExclamationTriangleIcon,{style:{width:32,height:32,color:"var(--red-9)"}}),n.jsx(s.Text,{size:"2",color:"red",weight:"medium",children:L}),n.jsx(s.Text,{size:"1",color:"gray",children:"Click to try again"})]}):n.jsxs(n.Fragment,{children:[n.jsx(re.UploadIcon,{style:{width:32,height:32,color:"var(--gray-8)"}}),n.jsx(s.Text,{size:"2",weight:"medium",children:"Click to upload or drag and drop"}),n.jsxs(s.Text,{size:"1",color:"gray",children:[we(N)," max · ",Te(w)]})]})})}),pe,he&&n.jsx(s.Text,{size:"2",color:"gray",mt:"3",style:{display:"block"},children:"Sheet preview not stored for this field — re-upload to view contents."}),Object.keys(ie).length>0&&n.jsxs(s.Box,{mt:"3",children:[n.jsx(s.Text,{size:"2",weight:"bold",as:"div",mb:"1",children:"Computed values"}),n.jsx(s.Flex,{direction:"column",gap:"1",children:Object.entries(ie).map(([A,W])=>n.jsxs(s.Flex,{justify:"between",children:[n.jsx(s.Text,{size:"2",children:W.label}),W.error?n.jsx(s.Text,{size:"2",color:"red",children:W.error}):n.jsx(s.Text,{size:"2",children:at(W.value)})]},A))})]}),!m&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:ve(u,o)})]})},tr=B.withJsonFormsControlProps(Vn),rr=b.rankWith(10,b.schemaMatches(e=>e.type==="object"&&typeof e["x-spreadsheet"]=="object")),Hn="Sheet1",qn="xlsx";function Xn(e){if(e===void 0)return null;if(!Array.isArray(e))return"columns must be an array of { id, label } objects.";if(e.length===0)return"columns is declared but empty — declare at least one field, or omit it entirely.";const r=e.findIndex(t=>!t||typeof t!="object"||typeof t.id!="string"||t.id===""||typeof t.label!="string"||t.label==="");return r!==-1?`columns[${r}] must be a { id, label } object with non-empty string fields.`:null}function Jn(e,r){if(!Qt(e))return e;const t=er(e,r==null?void 0:r.map(a=>a.id));if(!r||t.length===0)return t;const o=new Map(r.map(a=>[a.id,a.label])),[l,...i]=t;return[l.map(a=>o.get(String(a))??a),...i]}const Kn=({data:e,path:r,label:t,schema:o,visible:l=!0})=>{const[i,a]=g.useState(null),c=B.useJsonForms();if(l===!1)return null;const u=(o==null?void 0:o["x-spreadsheet-export"])??{},d=u.columns,f=u.sheetName??Hn,m=u.fileType??qn,x=u.fileName??`export.${m}`,p=Xn(d);if(p)return n.jsxs(s.Box,{mb:"4",children:[n.jsx(s.Text,{as:"label",size:"2",weight:"bold",children:t}),n.jsxs(s.Text,{size:"2",color:"red",style:{display:"block"},children:["Invalid x-spreadsheet-export config: ",p]})]});const j=Array.isArray(e)&&e.length>0,w=async()=>{var N,I;if(j){a(null);try{const O=await import("@e965/xlsx"),C=Jn(e,d),R=O.utils.aoa_to_sheet(C),v=O.utils.book_new();O.utils.book_append_sheet(v,R,f);const y=r.split(".").slice(0,-1).join("."),z=y?b.Resolve.data((N=c.core)==null?void 0:N.data,y):(I=c.core)==null?void 0:I.data;O.writeFile(v,qe(x,z,`export.${m}`),{bookType:m})}catch(O){a(O instanceof Error?O.message:"Failed to build the workbook.")}}};return n.jsxs(s.Box,{mb:"4",children:[n.jsx(s.Text,{as:"label",size:"2",weight:"bold",style:{display:"block",marginBottom:"var(--space-2)"},children:t}),n.jsxs(s.Button,{type:"button",variant:"soft",disabled:!j,onClick:()=>void w(),children:[n.jsx(re.DownloadIcon,{})," Download Spreadsheet"]}),i&&n.jsx(s.Text,{size:"2",color:"red",style:{display:"block",marginTop:"var(--space-2)"},children:i})]})},nr=B.withJsonFormsControlProps(Kn),or=b.rankWith(10,b.and(b.schemaMatches(e=>{const r=e["x-spreadsheet-export"];return e.type==="array"&&typeof r=="object"&&r!==null}),b.not(b.optionIs("editable",!0))));class Re extends Error{}const ct=5e6,Yn=1024,Gn=/^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["']/i,Zn={ignoreAttributes:!1,attributeNamePrefix:"@_",textNodeName:"#text",parseTagValue:!0,parseAttributeValue:!0,numberParseOptions:{hex:!1,leadingZeros:!1,eNotation:!0},trimValues:!0,cdataPropName:!1,commentPropName:!1,processEntities:!0,htmlEntities:!0,ignoreDeclaration:!0,ignorePiTags:!0,alwaysCreateTextNode:!1,preserveOrder:!1,removeNSPrefix:!1,maxNestedTags:100,strictReservedNames:!0};function Qn(e){const r=new Set(e);return r.size===0?()=>!1:(t,o)=>r.has(typeof o=="string"?o:o.toString())||r.has(t)}function eo(e){const r=e instanceof Error?e.message:"";return r.startsWith("[SECURITY] Invalid name:")?"This document uses a reserved JavaScript name (__proto__, constructor or prototype) as an element or attribute name, which cannot be represented safely.":r==="External entities are not supported"||r==="Parameter entities are not supported"?`${r}. Please remove the DOCTYPE entity declarations and try again.`:r.startsWith("Maximum nested tags exceeded")?"This document is nested too deeply to parse.":r.startsWith("Entity count")||r.includes("exceeds maximum allowed")?"This document declares too many or too large entity definitions to expand safely.":"This doesn't look like a valid XML document. Please check the file and try again."}async function to(e,r={}){var d;if(typeof e!="string")throw new Re("This file could not be read as text.");const t=e.charCodeAt(0)===65279?e.slice(1):e;if(t.trim()==="")throw new Re("This file is empty.");if(t.length>ct)throw new Re(`This document is too large to parse (over ${ct/1e6} million characters).`);const o=(d=Gn.exec(t.slice(0,Yn)))==null?void 0:d[1];if(o&&!/^utf-?8$/i.test(o))throw new Re(`This document declares the unsupported encoding "${o}". Only UTF-8 is supported.`);const{XMLParser:l,XMLValidator:i}=await import("fast-xml-parser"),a=i.validate(t,{allowBooleanAttributes:!1});if(a!==!0){const{msg:f,line:m,col:x}=a.err;throw new Re(`Invalid XML at line ${m}, column ${x}: ${f}`)}const c=new l({...Zn,removeNSPrefix:r.removeNamespaces===!0,isArray:Qn(r.arrayPaths??[])});let u;try{u=c.parse(t)}catch(f){throw new Re(eo(f))}if(u==null||typeof u!="object"||Array.isArray(u))throw new Re("This document has no root element.");return u}function sr(e,r,t){const{path:o,default:l}=typeof t=="string"?{path:t,default:void 0}:t,i=b.Resolve.data(e,r?`${r}.${o}`:o);return i??l}function ro(e,r,t){const o={};for(const[l,i]of Object.entries(t)){const a=sr(e,r,i);if(a===void 0)return;o[l]=a}return o}async function no(e,r){try{return{status:"ok",value:await Yt(e,r)}}catch(t){return{status:"error",error:Xe(t)}}}function ir(e,r){return e==null?"":typeof e=="number"?e.toFixed(oo(r)):e instanceof Date?e.toLocaleDateString():String(e)}function oo(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.trunc(e))):0}const Se={found:!1},me=e=>({found:!0,value:e});function ut(e){return e==null||e===""?Se:Array.isArray(e)||e instanceof Date?me(e):typeof e=="object"?Se:typeof e=="string"||typeof e=="number"||typeof e=="boolean"?me(e):Se}const so=new Set(["true","1","yes","y"]),io=new Set(["false","0","no","n"]),lo=/^(\d{4}-\d{2}-\d{2})(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})?)?$/;async function ao(e,r,t){switch(r.as){case void 0:return me(e);case"string":return me(e instanceof Date?e.toISOString():String(e));case"number":{const o=e instanceof Date?e.getTime():Number(e);return Number.isFinite(o)?me(r.decimals===void 0?o:ir(o,r.decimals)):Se}case"boolean":{const o=String(e).trim().toLowerCase();return so.has(o)?me(!0):io.has(o)?me(!1):Se}case"date":{const{default:o}=await import("dayjs"),{default:l}=await Promise.resolve().then(()=>require("./customParseFormat-CLvZwox5.cjs")).then(c=>c.customParseFormat);if(o.extend(l),t==="export"){const c=typeof e=="string"?lo.exec(e):null,u=e instanceof Date?o(e):c?o(c[1],"YYYY-MM-DD",!0):null;return u!=null&&u.isValid()?me(u.format(r.format??"YYYY-MM-DD")):Se}const i=e instanceof Date?e.toISOString():String(e),a=r.format?o(i,r.format,!0):o(i);return a.isValid()?me(a.format("YYYY-MM-DD")):Se}}}async function co(e,r){if(r.formula!==void 0){const t={};for(const[o,l]of Object.entries(r.inputs??{})){const i=ut(b.Resolve.data(e,l));if(!i.found||Array.isArray(i.value))return Se;t[o]=i.value}try{return me(await Yt(t,r.formula))}catch(o){throw new Error(`writeTo "${r.to}": ${Xe(o)}`)}}if(r.from===void 0)throw new Error(`writeTo "${r.to}" needs either "from" or "formula".`);return ut(b.Resolve.data(e,r.from))}const Le="@_",lr="#text",Me=e=>e.split(".").filter(Boolean),ar=e=>e.startsWith(Le)||e===lr;function cr(e,r){if(typeof e.to!="string"||Me(e.to).length===0)return'"to" must be a non-empty path.';if(e.format!==void 0&&e.as!=="date")return'"format" needs "as": "date".';if(e.decimals!==void 0){if(r==="import")return'"decimals" only applies on export — on import it would put text in a number field.';if(e.as!=="number")return'"decimals" needs "as": "number".';const{decimals:t}=e;if(!Number.isInteger(t)||t<0||t>100)return'"decimals" must be a whole number from 0 to 100.'}if(r==="export"){const t=Me(e.to);for(const[o,l]of t.entries()){if(l===Le)return'"@_" needs an attribute name after it, e.g. "@_id".';if(ar(l)&&o<t.length-1)return`"${l}" must be the last segment — it belongs to the element before it.`}}return null}function dt(e,r,t){const o=t?` To give "${r}" both text and attributes, write its text to "${r}.${lr}".`:"";return new Error(`writeTo "${e}": "${r}" is written both as a value and as the parent of other values.${o}`)}function ur(e){const r={},t=new Set([r]);for(const{to:o,value:l}of e){const i=Me(o);if(i.length===0)continue;let a=r;for(const[d,f]of i.slice(0,-1).entries()){const m=a[f];if(m===void 0){const x={};t.add(x),a[f]=x,a=x}else if(t.has(m))a=m;else throw dt(o,i.slice(0,d+1).join("."),i[d+1].startsWith(Le))}const c=i[i.length-1],u=a[c];if(t.has(u)){const d=Object.keys(u).some(f=>f.startsWith(Le));throw dt(o,i.join("."),d)}a[c]=l}return r}const uo=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean";async function Je(e,r,t){const o=[];for(const l of r){const i=cr(l,t);if(i)throw new Error(`writeTo "${l.to}": ${i}`);const a=Me(l.to),c=t==="export"&&ar(a[a.length-1]),u=m=>{if(!(c&&m==null)){if(c&&!uo(m)){const x=m instanceof Date?' Add "as": "date" to write a date.':"";throw new Error(`writeTo "${l.to}": an attribute or #text value must be text, a number or a boolean.${x}`)}o.push({to:l.to,value:m})}};let d=await co(e,l);const f=d.found&&Array.isArray(d.value);if(d.found&&f&&l.writeTo){const m=await Promise.all(d.value.map(async x=>ur(await Je(x,l.writeTo,t))));u(m);continue}if(d.found&&!f&&l.writeTo)throw new Error(`writeTo "${l.to}": "writeTo" is set, but "from" did not resolve to a repeating element.`);if(d.found&&!f&&l.map){const m=d.value instanceof Date?d.value.toISOString():String(d.value);Object.prototype.hasOwnProperty.call(l.map,m)&&(d=me(l.map[m]))}if(d.found&&!f&&(d=await ao(d.value,l,t)),!d.found){if(l.default===void 0)continue;u(l.default);continue}u(d.value)}return o}const fo=".xml,text/xml,application/xml",po=5*1024*1024,ho=({data:e,handleChange:r,path:t,label:o,required:l,schema:i,enabled:a,readonly:c,errors:u,visible:d=!0})=>{je(d,t,r);const f=be(t,l,d),m=!u||u.length===0,x=Xt(a,c),p=(i==null?void 0:i["x-xml"])??{},j=p.accept??fo,w=p.maxSize??po,N=p.arrayPaths,I=p.removeNamespaces===!0,O=p.writeTo,C=p.writeBase??"root",R=p.persistDocument!==!1,v=B.useJsonForms(),y=e??null,[z,P]=g.useState(()=>y?"ready":"empty"),[F,$]=g.useState(null),[k,ne]=g.useState(!1),K=g.useRef(null),L=g.useRef(0),U=y!=null,Q=O!==void 0&&O.length>0,de=g.useCallback(async S=>{var pe;const Y=++L.current;if($(null),S.size>w){$(`File exceeds the ${we(w)} limit.`);return}if(!j.split(",").map(h=>h.trim()).some(h=>h==="*"||h==="*/*"?!0:h.endsWith("/*")?S.type.startsWith(h.slice(0,-1)):h.startsWith(".")?S.name.toLowerCase().endsWith(h.toLowerCase()):S.type===h)){$(`Invalid type. Accepted: ${Te(j)}`);return}P("parsing");let G;try{const h=await S.text();G=await to(h,{arrayPaths:N,removeNamespaces:I})}catch(h){if(Y!==L.current)return;P("error"),$(h instanceof Re?h.message:"This doesn't look like a valid XML document. Please check the file and try again.");return}let ie=[];if(O&&O.length>0)try{ie=await Je(G,O,"import")}catch(h){if(Y!==L.current)return;P("error"),$(h instanceof Error?h.message:"This document could not be mapped onto the form.");return}if(Y!==L.current)return;R&&r(t,G);const xe=C==="parent"?t.split(".").slice(0,-1).join("."):"";for(const h of ie)(pe=v.dispatch)==null||pe.call(v,b.update(xe?`${xe}.${h.to}`:h.to,()=>h.value));P("ready")},[j,w,N,I,O,C,R,t,r,v]);if(d===!1||!x&&!U)return null;const oe=S=>{S.preventDefault(),S.stopPropagation(),x&&ne(S.type==="dragenter"||S.type==="dragover")},ee=S=>{var Y;S.preventDefault(),S.stopPropagation(),ne(!1),x&&(Y=S.dataTransfer.files)!=null&&Y[0]&&de(S.dataTransfer.files[0])},D=S=>{var Y;(Y=S.target.files)!=null&&Y[0]&&(de(S.target.files[0]),S.target.value="")},H=()=>{x&&(++L.current,$(null),P("empty"),r(t,void 0))};return n.jsxs(s.Box,{mb:"4",children:[n.jsxs(s.Flex,{align:"center",justify:"between",mb:"2",children:[n.jsxs(s.Flex,{align:"center",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",children:[o,f&&n.jsx(s.Text,{color:"red",children:" *"})]}),!Q&&U&&x&&n.jsxs(n.Fragment,{children:[n.jsx(s.Tooltip,{content:"Replace document",children:n.jsx(s.IconButton,{variant:"ghost",size:"1",onClick:()=>{var S;return(S=K.current)==null?void 0:S.click()},"aria-label":"Replace document",children:n.jsx(re.UploadIcon,{})})}),n.jsx(s.Tooltip,{content:"Remove document",children:n.jsx(s.IconButton,{variant:"ghost",size:"1",color:"gray",onClick:H,"aria-label":"Remove document",children:n.jsx(re.Cross2Icon,{})})})]})]}),n.jsxs(s.Flex,{align:"center",gap:"2",children:[n.jsxs(s.Text,{size:"1",color:"gray",children:[we(w)," max · ",Te(j)]}),Q&&x&&n.jsxs(s.Button,{size:"1",variant:"soft",onClick:()=>{var S;return(S=K.current)==null?void 0:S.click()},disabled:z==="parsing",children:[z==="parsing"?n.jsx(s.Spinner,{size:"1"}):n.jsx(re.UploadIcon,{}),"Upload"]})]})]}),(Q||U)&&F&&n.jsx(s.Text,{size:"2",color:"red",mb:"2",style:{display:"block"},children:F}),n.jsx("input",{ref:K,type:"file",style:{display:"none"},accept:j,onChange:D}),!Q&&x&&!U&&n.jsx("div",{role:"button",tabIndex:0,onClick:()=>{var S;return(S=K.current)==null?void 0:S.click()},onKeyDown:S=>{var Y;(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),(Y=K.current)==null||Y.click())},onDragEnter:oe,onDragLeave:oe,onDragOver:oe,onDrop:ee,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",k?"border-blue-500 bg-blue-50":F?"border-red-300 bg-red-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"].join(" "),children:n.jsx(s.Flex,{direction:"column",align:"center",gap:"2",children:z==="parsing"?n.jsxs(n.Fragment,{children:[n.jsx(s.Spinner,{size:"3"}),n.jsx(s.Text,{size:"2",color:"gray",children:"Parsing document…"})]}):F?n.jsxs(n.Fragment,{children:[n.jsx(re.ExclamationTriangleIcon,{style:{width:32,height:32,color:"var(--red-9)"}}),n.jsx(s.Text,{size:"2",color:"red",weight:"medium",children:F}),n.jsx(s.Text,{size:"1",color:"gray",children:"Click to try again"})]}):n.jsxs(n.Fragment,{children:[n.jsx(re.UploadIcon,{style:{width:32,height:32,color:"var(--gray-8)"}}),n.jsx(s.Text,{size:"2",weight:"medium",children:"Click to upload or drag and drop"}),n.jsxs(s.Text,{size:"1",color:"gray",children:[we(w)," max · ",Te(j)]})]})})}),!m&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:ve(u,o)})]})},dr=B.withJsonFormsControlProps(ho),fr=b.rankWith(10,b.schemaMatches(e=>{const r=e["x-xml"];return e.type==="object"&&typeof r=="object"&&r!==null})),xo="root",ft="export.xml",mo={format:!0,indentBy:" ",ignoreAttributes:!1,attributeNamePrefix:"@_",textNodeName:"#text",suppressBooleanAttributes:!1,processEntities:!0};function go(e){if(e===null||typeof e!="object"||Array.isArray(e))return'declaration must be an object, e.g. { "standalone": "no" }, or {} for the defaults.';const{version:r,encoding:t,standalone:o,...l}=e,[i]=Object.keys(l);return i?`declaration has an unknown key "${i}" — only version, encoding and standalone.`:r!==void 0&&r!=="1.0"&&r!=="1.1"?'declaration.version must be "1.0" or "1.1".':t!==void 0&&t!=="UTF-8"?'declaration.encoding can only be "UTF-8" — the file is always written as UTF-8.':o!==void 0&&o!=="yes"&&o!=="no"?'declaration.standalone must be "yes" or "no".':null}function pr(e){for(const r of e){if(r===null||typeof r!="object"||Array.isArray(r))return"every writeTo entry must be an object.";const{to:t,writeTo:o}=r,l=cr(r,"export");if(l)return`writeTo "${t}": ${l}`;if(o!==void 0){if(!Array.isArray(o))return`writeTo "${t}": its nested writeTo must be an array.`;const i=pr(o);if(i)return i}}return null}function yo({writeTo:e,declaration:r}){return e===void 0?"writeTo is required — see docs/xml-export-control.md.":Array.isArray(e)?e.length===0?"writeTo is declared but empty — declare at least one entry.":pr(e)??(r===void 0?null:go(r)):"writeTo must be an array of { from | formula, to } entries."}function bo({version:e="1.0",standalone:r}){return{"@_version":e,"@_encoding":"UTF-8",...r&&{"@_standalone":r}}}function vo(e){return e==null?!0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}const wo=({path:e,label:r,schema:t,visible:o=!0})=>{var O,C;const l=(t==null?void 0:t["x-xml-export"])??{},i=l.rootElement??xo,a=l.fileName??ft,c=l.writeTo,u=l.writeBase??"root",d=l.declaration,f=yo(l),m=B.useJsonForms(),x=u==="parent"?e.split(".").slice(0,-1).join("."):"",p=x?b.Resolve.data((O=m.core)==null?void 0:O.data,x):(C=m.core)==null?void 0:C.data,[j,w]=g.useState(null),N=vo(p),I=g.useCallback(async()=>{if(c){w(null);try{const R=ur(await Je(p,c,"export")),{XMLBuilder:v}=await import("fast-xml-parser"),y={...d&&{"?xml":bo(d)},[i]:R},z=new v(mo).build(y);nn(z,qe(a,p,ft),"application/xml")}catch(R){w(R instanceof Error?R.message:"This export could not be built.")}}},[c,p,d,i,a]);return o===!1?null:f?n.jsxs(s.Box,{mb:"4",children:[n.jsx(s.Text,{as:"label",size:"2",weight:"bold",children:r}),n.jsxs(s.Text,{size:"2",color:"red",style:{display:"block"},children:["Invalid x-xml-export config: ",f]})]}):n.jsxs(s.Box,{mb:"4",children:[n.jsx(s.Text,{as:"label",size:"2",weight:"bold",style:{display:"block",marginBottom:"var(--space-2)"},children:r}),n.jsxs(s.Button,{size:"1",variant:"soft",disabled:N,onClick:()=>void I(),children:[n.jsx(re.DownloadIcon,{}),"Download XML"]}),j&&n.jsx(s.Text,{size:"2",color:"red",style:{display:"block",marginTop:"var(--space-2)"},children:j})]})},hr=B.withJsonFormsControlProps(wo),xr=b.rankWith(10,b.schemaMatches(e=>{const r=e["x-xml-export"];return e.type==="object"&&typeof r=="object"&&r!==null})),To="{value}",jo=2,Eo={},Co=({data:e,handleChange:r,path:t,label:o,schema:l,visible:i=!0})=>{var y;je(i,t,r);const a=l==null?void 0:l["x-computed"],c=(a==null?void 0:a.inputs)??Eo,u=(a==null?void 0:a.formula)??"",d=(a==null?void 0:a.format)??To,f=(a==null?void 0:a.decimals)??jo,m=B.useJsonForms(),x=t.split(".").slice(0,-1).join("."),p=ro((y=m.core)==null?void 0:y.data,x,c),j=p?JSON.stringify(p):null,w=m.readonly===!0,[N,I]=g.useState(()=>typeof e=="number"?"ok":"unavailable"),[O,C]=g.useState(()=>typeof e=="number"?e:null),[R,v]=g.useState(null);return g.useEffect(()=>{if(!i)return;let z=!1;const P=F=>{w||F!==e&&r(t,F)};if(p===void 0){I("unavailable"),v(null),C(null),P(void 0);return}return I(F=>F==="ok"?F:"loading"),no(p,u).then(F=>{if(z)return;const $=F.status==="ok"&&typeof F.value=="number"&&Number.isFinite(F.value)?F.value:null;if($===null){I("error"),v(F.status==="error"?F.error??"Unable to compute value.":"Computed value must be a number."),C(null),P(void 0);return}I("ok"),v(null),C($),P($)}),()=>{z=!0}},[j,u,i,w]),i===!1?null:n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsx(s.Text,{as:"label",size:"2",weight:"bold",children:o}),N==="unavailable"?n.jsx(s.Text,{size:"2",color:"gray",children:"Not yet available."}):N==="loading"?n.jsxs(s.Flex,{align:"center",gap:"2",children:[n.jsx(s.Spinner,{size:"1"}),n.jsx(s.Text,{size:"2",color:"gray",children:"Computing…"})]}):N==="error"?n.jsx(s.Text,{size:"2",color:"red",children:R}):n.jsx(s.Text,{size:"2",children:ze(d,{value:ir(O,f)})}),l.description&&n.jsx(s.Text,{size:"1",color:"gray",children:l.description})]})})},mr=B.withJsonFormsControlProps(Co),gr=b.rankWith(5,b.schemaMatches(e=>{const r=e["x-computed"];return e.type==="number"&&typeof r=="object"&&r!==null})),yr="seq",pt=2,Ro=e=>e==null||e==="",br=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,So=e=>{const r=e==null?void 0:e["x-template"];if(typeof r!="object"||r===null)return;const{template:t,inputs:o}=r;if(!(typeof t!="string"||t===""))return{template:t,inputs:o}},Ke=e=>typeof e=="object"&&e.name===yr&&e.arg!==void 0,Ao=e=>e.every((r,t)=>!Ke(r)||typeof e[t-1]!="object"&&typeof e[t+1]!="object"),Fo=e=>{const r=new Set;for(const t of He(e))typeof t=="object"&&t.arg===void 0&&r.add(t.name);return[...r]},Oo=e=>{const r=[];for(const[t,o]of Object.entries((e==null?void 0:e.properties)??{})){const l=So(o);l&&r.push([t,l])}return r},Io=(e,r,t)=>{var l;const o={};for(const i of Fo(t.template)){const a=sr(e,r,((l=t.inputs)==null?void 0:l[i])??i);o[i]=typeof a=="string"||typeof a=="number"||typeof a=="boolean"?String(a):""}return o},ko=e=>r=>{const t=r.trim()===""?pt:Number(r);return`${e}`.padStart(Number.isInteger(t)&&t>=0?t:pt,"0")},Do=e=>{const r=o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");let t="";for(const o of He(e))typeof o=="string"?t+=r(o):t+=Ke(o)?"(\\d+)":".*?";return new RegExp(`^${t}$`)},No=(e,r,t)=>{var i,a;const o=Do(t.template);let l=0;for(const c of e){const u=(i=br(c))==null?void 0:i[r];if(typeof u!="string")continue;const d=Number((a=o.exec(u))==null?void 0:a[1]);Number.isFinite(d)&&d>l&&(l=d)}return l},Lo=(e,r,t,o,l,i)=>{const a=Oo(e);if(a.length===0)return r;const c=br(r);if(!c)return r;const u={...c};for(const[d,f]of a){if(!Ro(u[d]))continue;const m=He(f.template),x={};if(m.some(Ke)){if(!Ao(m)){console.warn(`x-template: {seq(…)} needs literal text between it and other placeholders; not numbering "${f.template}"`);continue}const p=Math.max(i[d]??0,No(t,d,f))+1;i[d]=p,x[yr]=ko(p)}u[d]=ze(f.template,Io(o,l,f),x)}return u},Mo=({path:e,items:r,itemsSchema:t,rootSchema:o,addItem:l,sequences:i})=>{const a=B.useJsonForms(),c=()=>{var d;const u=Lo(t,b.createDefaultValue(t,o),r,(d=a.core)==null?void 0:d.data,e.split(".").slice(0,-1).join("."),i.current);l&&l(e,u)()};return n.jsx(s.Box,{mt:"2",children:n.jsxs(s.Button,{type:"button",variant:"surface",onClick:c,children:[n.jsx(re.PlusIcon,{}),"Add Item"]})})},zo=({data:e,path:r,schema:t,uischema:o,enabled:l,visible:i,addItem:a,removeItems:c,rootSchema:u,arraySchema:d,required:f=!1,errors:m=""})=>{const x=g.useRef({}),p=be(r,f,i),j=d?t:t.items,w=d||t;if(i===!1||!j||typeof j!="object"||Array.isArray(j))return null;const N=j,I=Array.isArray(e)?e:[],O=w.title||"Array Items",C=o.options??{},R=l&&C.addable!==!1,v=l&&C.removable!==!1,y=C.itemLabel||"Item",z=p||typeof w.minItems=="number"&&w.minItems>=1,P=!m,F=P?"":I.length===0&&C.errorMessage||ve(m,O),$=k=>{if(c){const ne=c(r,[k]);ne&&ne()}};return n.jsx(s.Box,{mb:"6",children:n.jsxs(s.Flex,{direction:"column",gap:"4",children:[n.jsxs(s.Text,{as:"div",size:"4",weight:"bold",children:[O," ",z&&n.jsx(s.Text,{color:"red",children:"*"})]}),I.length===0&&n.jsx(s.Box,{py:"4",px:"4",style:{backgroundColor:"var(--gray-3)",borderRadius:"var(--radius-3)"},children:n.jsx(s.Text,{size:"2",color:"gray",children:"No items have been added yet."})}),!P&&n.jsx(s.Text,{color:"red",size:"1",children:F}),I.map((k,ne)=>{var L;const K=`${r}.${ne}`;return n.jsx(s.Card,{size:"3",variant:"surface",children:n.jsxs(s.Flex,{direction:"column",gap:"4",children:[n.jsxs(s.Flex,{justify:"between",align:"center",children:[n.jsxs(s.Text,{size:"3",weight:"bold",children:[y," ",ne+1]}),v&&n.jsxs(s.Button,{type:"button",color:"red",variant:"soft",onClick:()=>$(ne),title:"Remove item",children:[n.jsx(re.TrashIcon,{}),"Remove"]})]}),n.jsx(s.Box,{children:n.jsx(B.JsonFormsDispatch,{schema:N,uischema:((L=o.options)==null?void 0:L.detail)||(N.type==="object"||N.properties?{type:"VerticalLayout",elements:Object.keys(N.properties||{}).map(U=>({type:"Control",scope:`#/properties/${U}`}))}:{type:"Control",scope:"#"}),path:K,enabled:l,renderers:void 0,cells:void 0})})]})},K)}),R&&n.jsx(Mo,{path:r,items:I,itemsSchema:N,rootSchema:u,addItem:a,sequences:x})]})})},Ve=B.withJsonFormsArrayControlProps(zo),vr=b.rankWith(3,b.isObjectArrayControl),wr=({uischema:e,visible:r})=>{const t=e;return r===!1?null:n.jsx(s.Box,{mb:"4",children:n.jsx(s.Heading,{size:"4",children:t.text})})},Tr=b.rankWith(1,b.uiTypeIs("Label")),Po=b.rankWith(3,b.isPrimitiveArrayControl),Uo=[{tester:vt,renderer:Ur},{tester:Tt,renderer:Br},{tester:Et,renderer:_r},{tester:Rt,renderer:Wr},{tester:kt,renderer:It},{tester:At,renderer:Ze},{tester:Ft,renderer:Ze},{tester:Nt,renderer:en},{tester:Mt,renderer:B.withJsonFormsLayoutProps(Lt)},{tester:Pt,renderer:B.withJsonFormsLayoutProps(zt)},{tester:$t,renderer:B.withJsonFormsLayoutProps(Ut)},{tester:_t,renderer:B.withJsonFormsLayoutProps(Bt)},{tester:qt,renderer:Ht},{tester:rr,renderer:tr},{tester:or,renderer:nr},{tester:fr,renderer:dr},{tester:xr,renderer:hr},{tester:gr,renderer:mr},{tester:vr,renderer:Ve},{tester:Po,renderer:Ve},{tester:Tr,renderer:wr}];exports.ArrayControl=Ve;exports.ArrayControlTester=vr;exports.BooleanControl=jt;exports.BooleanControlTester=Et;exports.CategorizationLayoutRenderer=Bt;exports.CategorizationLayoutTester=_t;exports.ComputedControl=mr;exports.ComputedControlTester=gr;exports.DateControl=Dt;exports.DateControlTester=Nt;exports.FileControl=Ht;exports.FileControlTester=qt;exports.GroupLayoutRenderer=Ut;exports.GroupLayoutTester=$t;exports.HorizontalLayoutRenderer=zt;exports.HorizontalLayoutTester=Pt;exports.LabelRenderer=wr;exports.LabelTester=Tr;exports.NumberControl=wt;exports.NumberControlTester=Tt;exports.RadioControl=Ct;exports.RadioControlTester=Rt;exports.SearchSelectControl=It;exports.SearchSelectControlTester=kt;exports.SearchServiceProvider=Ir;exports.SelectControl=St;exports.SelectControlTester=At;exports.SelectObjectControlTester=Ft;exports.SpreadsheetControl=tr;exports.SpreadsheetControlTester=rr;exports.SpreadsheetExportControl=nr;exports.SpreadsheetExportControlTester=or;exports.TextControl=bt;exports.TextControlTester=vt;exports.UploadProvider=Or;exports.VerticalLayoutRenderer=Lt;exports.VerticalLayoutTester=Mt;exports.XmlControl=dr;exports.XmlControlTester=fr;exports.XmlExportControl=hr;exports.XmlExportControlTester=xr;exports.radixRenderers=Uo;exports.useSearchService=yt;exports.useUpload=mt;
1
+ "use strict";var rn=Object.create;var He=Object.defineProperty;var nn=Object.getOwnPropertyDescriptor;var on=Object.getOwnPropertyNames;var sn=Object.getPrototypeOf,ln=Object.prototype.hasOwnProperty;var an=(e,r,t)=>r in e?He(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var cn=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of on(r))!ln.call(e,i)&&i!==t&&He(e,i,{get:()=>r[i],enumerable:!(o=nn(r,i))||o.enumerable});return e};var De=(e,r,t)=>(t=e!=null?rn(sn(e)):{},cn(r||!e||!e.__esModule?He(t,"default",{value:e,enumerable:!0}):t,e));var mt=(e,r,t)=>an(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),m=require("react"),v=require("@jsonforms/core"),X=require("@jsonforms/react"),s=require("@radix-ui/themes"),se=require("@radix-ui/react-icons"),Lt=require("dayjs"),Mt=m.createContext(null);function un({children:e,onUpload:r,getDownloadUrl:t}){const o={onUpload:r,getDownloadUrl:t};return n.jsx(Mt.Provider,{value:o,children:e})}function zt(){return m.useContext(Mt)}const Pt=m.createContext(null);function dn({children:e,services:r}){const t=m.useMemo(()=>r,[r]);return n.jsx(Pt.Provider,{value:t,children:e})}function $t(e){const r=m.useContext(Pt);return!r||!e?null:r[e]??null}const Bt=m.createContext(null);function Ut(){return m.useContext(Bt)}function fn({children:e,...r}){return n.jsx(Bt.Provider,{value:r,children:e})}function _t(e){var t;if(!e||typeof e!="object")return!1;const r=e;return r.type==="Categorization"&&((t=r.options)==null?void 0:t.variant)==="stepper"}function pn(e){return e.elements.filter(r=>r.type==="Category")}function Ue(e,r,t,o,i=""){if(t&&e.rule&&!v.isVisible(e,r,i,t,o))return[];if(e.type==="Control")return[e];const l=e.elements;return Array.isArray(l)?l.flatMap(a=>Ue(a,r,t,o,i)):[]}function et(e,r=""){return v.composePaths(r,v.toDataPath(e.scope))}function hn(e,r){return e===r||e.startsWith(`${r}.`)}function mn(e,r,t=v.toDataPath(e.scope),o=v.defaultTranslator){const i=v.Resolve.schema(r,e.scope,r),l=v.createLabelDescriptionFrom(e,i).text;return o(v.getI18nKey(i,e,t,"label"),l)}function xn(e,r,t,o="",i=v.defaultTranslator){const l=r.map(a=>v.getControlPath(a));return e.map(a=>({control:a,path:et(a,o)})).filter(({path:a})=>l.some(c=>hn(c,a))).map(({control:a,path:c})=>({path:c,label:mn(a,t,c,i)}))}function gn(e,r,t=""){const o=e.map(i=>Vt(r,et(i,t))).find(i=>Array.isArray(i)&&i.length>0);return o?{kind:"items",count:o.length}:{kind:"fields",count:e.length}}function yn(e,r,t=""){return e.some(o=>{const i=Vt(r,et(o,t));return i!=null&&i!==""&&!(Array.isArray(i)&&i.length===0)})}function Vt(e,r){return r.split(".").reduce((t,o)=>{if(!(t==null||typeof t!="object"))return t[o]},e)}const Wt={back:"Back",continue:"Continue",stepOf:"Step {step} of {total}",review:"Review and Submit",navLabel:"Form steps",progressLabel:"Progress through the form",noteDone:"Done",noteToFix:"{count} to fix",noteItem:"{count} item added",noteItems:"{count} items added",noteField:"{count} field",noteFields:"{count} fields",noteReview:"Check and submit",missingFields:"Complete these fields to continue:",incompleteSteps:"Some steps are not complete yet:",reviewHint:"Check your answers below, then submit.",edit:"Edit",editStep:"Edit {step}"};function bn(e,r,t){return(e??v.defaultTranslator)(`stepper.${r}`,Wt[r],t).replace(/\{(\w+)\}/g,(i,l)=>t&&l in t?String(t[l]):i)}const Se=(e,r,t,o=void 0)=>{m.useEffect(()=>{e===!1&&t(r,o)},[e,r,t,o])},xt=new WeakMap;function vn(e){if(!e||typeof e!="object")return!1;const r=xt.get(e);if(r!==void 0)return r;const t=ze(e,e,new Set);return xt.set(e,t),t}function wn(e,r){if(!r.startsWith("#/"))return;const t=r.slice(2).split("/");let o=e;for(const i of t){if(!o||typeof o!="object")return;o=o[i]}return o&&typeof o=="object"?o:void 0}function ze(e,r,t){if(!e||typeof e!="object"||t.has(e))return!1;t.add(e);const o=e;if(o.if!=null||o.dependentRequired!=null||o.dependencies!=null)return!0;for(const i of["allOf","anyOf","oneOf"]){const l=o[i];if(Array.isArray(l))for(const a of l){if(!a||typeof a!="object")continue;const c=a;if(Array.isArray(c.required)&&c.required.length>0||ze(c,r,t))return!0}}if(typeof o.$ref=="string"){const i=wn(r,o.$ref);if(i&&ze(i,r,t))return!0}for(const i of["then","else","not","contains","additionalProperties","items"]){const l=o[i];if(l&&typeof l=="object"&&!Array.isArray(l)&&ze(l,r,t))return!0}if(Array.isArray(o.items)){for(const i of o.items)if(ze(i,r,t))return!0}for(const i of["properties","patternProperties","$defs","definitions"]){const l=o[i];if(!(!l||typeof l!="object")){for(const a of Object.values(l))if(ze(a,r,t))return!0}}return!1}function jn(e,r){const t=structuredClone(e??{});if(!r)return t;const o=r.split(".");let i=t;for(let a=0;a<o.length-1;a++){const c=o[a];if(i==null||typeof i!="object")return t;const u=i[c];if(u==null||typeof u!="object")return t;i=u}const l=o[o.length-1];return i!=null&&typeof i=="object"&&delete i[l],t}function Tn(e){const r=e.lastIndexOf(".");return r===-1?"":"/"+e.slice(0,r).split(".").join("/")}function En(e){if(!e)return"";const r=e.lastIndexOf(".");return r===-1?e:e.slice(r+1)}function Sn(e,r){var t;return e.keyword!=="required"&&e.keyword!=="dependencies"||((t=e.params)==null?void 0:t.missingProperty)!==En(r)?!1:(e.instancePath??"")===Tn(r)}function Cn(e,r,t){if(!e||!t)return!1;const o=jn(r,e);t(o);const i=t.errors;return i!=null&&i.length?i.some(l=>Sn(l,e)):!1}function ve(e,r=!1,t=!0){var c,u,d;const o=X.useJsonForms(),i=(c=o.core)==null?void 0:c.data,l=(u=o.core)==null?void 0:u.validator,a=(d=o.core)==null?void 0:d.schema;return m.useMemo(()=>t?r?!0:vn(a)?Cn(e,i,l):!1:!1,[t,r,e,i,l,a])}const we=(e,r)=>{if(!e)return"";const t=r||"This field";return e.split(`
2
+ `).map(o=>{const i=o.trim();return i==="is a required property"?`${t} is required`:i.startsWith("must be > ")?`${t} must be greater than ${i.slice(10)}`:i.startsWith("must be >= ")?`${t} must be at least ${i.slice(11)}`:i.startsWith("must be multiple of ")?`${t} must be a multiple of ${i.slice(20)}`:o}).join(`
3
+ `)},Ht=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,uischema:a,schema:c,enabled:u,visible:d=!0})=>{var p;Se(d,t,r);const f=ve(t,i,d);if(d===!1)return null;const h=l.length===0;return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[o," ",f&&n.jsx(s.Text,{color:"red",children:"*"})]}),n.jsx(s.TextField.Root,{value:e||"",onChange:x=>r(t,x.target.value===""?void 0:x.target.value),disabled:!u,placeholder:(p=a.options)==null?void 0:p.placeholder,color:h?void 0:"red",id:t}),!h&&n.jsx(s.Text,{color:"red",size:"1",children:we(l,o)}),c.description&&n.jsx(s.Text,{size:"1",color:"gray",children:c.description})]})})},qt=v.rankWith(1,v.isStringControl),Rn=X.withJsonFormsControlProps(Ht),An=new Set(["-","+","e","E"]),Xt=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,uischema:a,schema:c,enabled:u,visible:d=!0})=>{var A;Se(d,t,r);const f=ve(t,i,d);if(d===!1)return null;const h=l.length===0,p=typeof c.exclusiveMinimum=="number"?c.exclusiveMinimum:void 0,x=typeof c.minimum=="number"?c.minimum:void 0,j=p??x,b=j!==void 0&&j>=0,D=typeof c.multipleOf=="number"?c.multipleOf:c.type==="integer"?1:void 0,R=S=>{if(S===""){r(t,void 0);return}const E=Number(S);isNaN(E)||r(t,E)},$=S=>{b&&An.has(S.key)&&S.preventDefault()},C=S=>{if(!b)return;const E=S.clipboardData.getData("text");/[-+eE]/.test(E)&&S.preventDefault()};return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[o," ",f&&n.jsx(s.Text,{color:"red",children:"*"})]}),n.jsx(s.TextField.Root,{type:"number",value:e??"",onChange:S=>R(S.target.value),onKeyDown:$,onPaste:C,min:j,step:D,disabled:!u,placeholder:(A=a.options)==null?void 0:A.placeholder,color:h?void 0:"red",id:t}),!h&&n.jsx(s.Text,{color:"red",size:"1",children:we(l,o)}),c.description&&n.jsx(s.Text,{size:"1",color:"gray",children:c.description})]})})},Jt=v.rankWith(2,v.or(v.isNumberControl,v.isIntegerControl)),Fn=X.withJsonFormsControlProps(Xt),Kt=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,schema:a,enabled:c,visible:u=!0})=>{Se(u,t,r);const d=ve(t,i,u);if(u===!1)return null;const f=l.length===0;return n.jsxs(s.Box,{mb:"4",children:[n.jsxs(s.Flex,{gap:"2",align:"center",children:[n.jsx(s.Checkbox,{checked:!!e,onCheckedChange:h=>r(t,h===!0),disabled:!c,id:t}),n.jsxs(s.Text,{as:"label",size:"2",htmlFor:t,children:[o," ",d&&"*"]})]}),!f&&n.jsx(s.Text,{color:"red",size:"1",className:"block mt-1",children:we(l,o)}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",className:"block mt-1",children:a.description})]})},Yt=v.rankWith(2,v.isBooleanControl),kn=X.withJsonFormsControlProps(Kt),Gt=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,schema:a,enabled:c,visible:u=!0})=>{Se(u,t,r);const d=ve(t,i,u);if(u===!1)return null;const f=l.length===0;let h=[];a.enum?h=a.enum.map(x=>({value:x,label:String(x)})):a.oneOf&&(h=a.oneOf.map(x=>({value:x.const,label:x.title||String(x.const)})));const p=e;return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"div",size:"2",weight:"bold",children:[o," ",d&&n.jsx(s.Text,{color:"red",children:"*"})]}),n.jsx(s.RadioGroup.Root,{value:p!==void 0?String(p):"",onValueChange:x=>{const j=h.find(b=>String(b.value)===x);j&&r(t,j.value)},disabled:!c,children:n.jsx(s.Flex,{direction:"row",style:{flexWrap:"wrap",columnGap:"clamp(14px, 3vw, 36px)",rowGap:"clamp(8px, 1.6vw, 14px)"},children:h.map(x=>n.jsxs(s.Flex,{align:"center",gap:"2",style:{minWidth:"max-content"},children:[n.jsx(s.RadioGroup.Item,{value:String(x.value)}),n.jsx(s.Text,{size:"2",color:c?void 0:"gray",children:x.label})]},String(x.value)))})}),!f&&n.jsx(s.Text,{color:"red",size:"1",children:we(l,o)}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",children:a.description})]})})},Zt=(e,r,t)=>{var i;return v.or(v.isEnumControl,v.isOneOfControl)(e,r,t)&&((i=e==null?void 0:e.options)==null?void 0:i.format)==="radio"?3:-1},In=X.withJsonFormsControlProps(Gt),Qt=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,schema:a,uischema:c,enabled:u,visible:d=!0})=>{var le,xe,re,ae;Se(d,t,r);const f=ve(t,i,d),h=((le=c.options)==null?void 0:le.autocomplete)===!0,[p,x]=m.useState(!1),[j,b]=m.useState(""),[D,R]=m.useState(0),$=m.useRef(null);if(m.useEffect(()=>{if(!h||!p)return;const M=K=>{$.current&&!$.current.contains(K.target)&&x(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[h,p]),d===!1)return null;const C=a.type==="object",A=C?((xe=a.properties)==null?void 0:xe.value)??{}:a;let S=[];A.enum?S=A.enum.map(M=>({value:String(M),label:String(M),raw:M})):A.oneOf&&(S=A.oneOf.map(M=>{const K=M.const;return{value:String(K),label:M.title||String(K),raw:K}}));const E=C?typeof e=="string"||typeof e=="number"||typeof e=="boolean"?{value:e}:e??void 0:void 0,_=C?E==null?void 0:E.value:e,P=E==null?void 0:E.label,L=_!=null?String(_):"",N=P??((re=S.find(M=>M.value===L))==null?void 0:re.label)??"",T=((ae=c.options)==null?void 0:ae.placeholder)||"Select an option",ee=C&&L!==""&&!S.some(M=>M.value===L),V=l?we(l,o):ee?`"${N||L}" is no longer an available option`:"",G=V==="",W=M=>{r(t,C?{value:M.raw,label:M.label}:M.value)};if(h){const M=p?S.filter(B=>B.label.toLowerCase().includes(j.toLowerCase())):S,K=Math.min(D,M.length-1),I=B=>{W(B),x(!1)},te=B=>{B.stopPropagation(),r(t,void 0),b("")},Z=B=>{(B.key==="Enter"||B.key===" ")&&te(B)};return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[o," ",f&&n.jsx(s.Text,{color:"red",children:"*"})]}),n.jsxs("div",{ref:$,style:{position:"relative"},children:[n.jsx(s.TextField.Root,{id:t,value:p?j:N,placeholder:T,disabled:!u,style:G?void 0:{outline:"2px solid var(--red-7)",outlineOffset:"-1px"},onChange:B=>{b(B.target.value),R(0),p||x(!0)},onFocus:()=>{u&&!p&&(b(""),R(0),x(!0))},onKeyDown:B=>{B.key==="Escape"?x(!1):B.key==="ArrowDown"?(B.preventDefault(),p?R(y=>Math.min(y+1,M.length-1)):(b(""),x(!0))):B.key==="ArrowUp"?(B.preventDefault(),p&&R(y=>Math.max(y-1,0))):B.key==="Enter"&&p&&M[K]&&(B.preventDefault(),I(M[K]))},children:n.jsx(s.TextField.Slot,{side:"right",children:n.jsxs(s.Flex,{align:"center",gap:"1",children:[L&&u&&n.jsx("span",{role:"button",tabIndex:0,onMouseDown:B=>B.preventDefault(),onClick:te,onKeyDown:Z,style:{lineHeight:1,color:"var(--gray-9)",padding:"0 2px",cursor:"pointer"},"aria-label":"Clear selection",children:"×"}),n.jsx(se.ChevronDownIcon,{style:{transform:p?"rotate(180deg)":void 0,transition:"transform 150ms"}})]})})}),p&&n.jsx(s.Box,{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:50,background:"var(--color-panel-solid)",borderRadius:"var(--radius-3)",boxShadow:"var(--shadow-5)",border:"1px solid var(--gray-a6)",overflow:"hidden"},children:n.jsx(s.ScrollArea,{style:{maxHeight:240},children:n.jsxs(s.Box,{p:"1",children:[M.length===0&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Text,{size:"2",color:"gray",children:"No results found."})}),M.map((B,y)=>n.jsx(s.Box,{px:"3",py:"2",onMouseDown:F=>F.preventDefault(),onClick:()=>I(B),onMouseEnter:()=>R(y),style:{cursor:"pointer",borderRadius:"var(--radius-2)",backgroundColor:y===K?"var(--accent-4)":B.value===L?"var(--accent-3)":void 0},children:n.jsx(s.Text,{size:"2",children:B.label})},B.value))]})})})]}),!G&&n.jsx(s.Text,{color:"red",size:"1",children:V}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",children:a.description})]})})}return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[o," ",f&&n.jsx(s.Text,{color:"red",children:"*"})]}),n.jsxs(s.Select.Root,{value:L,onValueChange:M=>{const K=S.find(I=>I.value===M);K&&W(K)},disabled:!u,children:[n.jsx(s.Select.Trigger,{placeholder:T,color:G?void 0:"red",id:t,children:C&&P?P:void 0}),n.jsx(s.Select.Content,{children:S.map(M=>n.jsx(s.Select.Item,{value:M.value,children:M.label},M.value))})]}),!G&&n.jsx(s.Text,{color:"red",size:"1",children:V}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",children:a.description})]})})},er=v.rankWith(2,v.or(v.isEnumControl,v.isOneOfControl)),tr=v.rankWith(3,v.schemaMatches(e=>{var t;if(e.type!=="object"||e["x-search"]!==void 0)return!1;const r=(t=e.properties)==null?void 0:t.value;return Array.isArray(r==null?void 0:r.enum)||Array.isArray(r==null?void 0:r.oneOf)})),gt=X.withJsonFormsControlProps(Qt),rr=/\{([A-Za-z0-9_]+)(?:\(([^(){}]*)\))?\}/g,On={today:e=>Lt().format(e||"YYYY-MM-DD")},Dn=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="bigint",yt=(e,r)=>Object.prototype.hasOwnProperty.call(e,r);function We(e,r,t={}){const o={...On,...t};return e.replace(rr,(i,l,a)=>{let c;if(a===void 0){if(!yt(r,l))return i;c=r[l]}else{if(!yt(o,l))return i;try{c=o[l](a)}catch{return i}}return c==null?"":Dn(c)?String(c):i})}function tt(e){const r=[];let t=0;for(const o of e.matchAll(rr))o.index>t&&r.push(e.slice(t,o.index)),r.push(o[2]===void 0?{name:o[1]}:{name:o[1],arg:o[2]}),t=o.index+o[0].length;return t<e.length&&r.push(e.slice(t)),r}function bt(e){if(!e||typeof e!="object")return;const r=e["x-search"];return typeof(r==null?void 0:r.service)=="string"&&r.service!==""?r.service:void 0}function rt(e){if(bt(e))return e;if(e.type==="array"){const r=e.items;if(r&&!Array.isArray(r)&&bt(r))return r}}const nr=v.rankWith(4,v.schemaMatches(e=>{const r=rt(e);if(!r)return!1;const t=r.type;return t==="string"||t==="object"}));function Nn(e){if(typeof e=="string"&&e.length>0)return e;if(e&&typeof e=="object"&&typeof e.value=="string"){const r=e.value;return r.length>0?r:void 0}}function Ln(e){if(typeof e=="string")return e.length>0?{parent:e}:void 0;if(!e||typeof e!="object")return;const r=Object.entries(e);if(r.length===0)return;const t={},o=[];for(const[i,l]of r)typeof l=="string"&&l.length>0?t[i]=l:o.push(i);return o.length>0&&console.warn(`x-search.dependsOn: ignoring invalid entries [${o.join(", ")}]`),Object.keys(t).length===0?(console.warn("x-search.dependsOn: map has no valid entries; search will not fetch until fixed"),{}):t}function Mn(e,r,t){const o={};for(const[i,l]of Object.entries(e))o[i]=Nn(v.Resolve.data(r,t?`${t}.${l}`:l));return o}function vt(e){if(typeof e=="string"&&e.length>0)return{value:e};if(e&&typeof e=="object"&&typeof e.value=="string"){const r=e;return{value:r.value,label:r.label}}}function qe(e,r){return r?{...e,name:We(r,e)}:e}const zn={"small-list":{fetchOnOpen:!0,searchable:!1,paginated:!1},"large-searchable-list":{fetchOnOpen:!0,searchable:!0,paginated:!1},"large-paginated-list":{fetchOnOpen:!1,searchable:!0,paginated:!0}},Pn=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,enabled:a,visible:c=!0,schema:u,uischema:d})=>{var ut,dt,ft,pt;const f=u.type==="array",h=rt(u)??u,p=h["x-search"]??{service:"",displayTemplate:""},x=p.service??"",j=p.mode??"large-paginated-list",b=zn[j],D=(b==null?void 0:b.fetchOnOpen)??!1,R=typeof p.displayTemplate=="string"?p.displayTemplate:"",$=X.useJsonForms(),C=t.split(".").slice(0,-1).join("."),{parentValues:A,parentValuesKey:S,missingParent:E}=m.useMemo(()=>{var ge;const w=Ln(p.dependsOn);if(!w)return{parentValues:void 0,parentValuesKey:"",missingParent:!1};const z=Mn(w,(ge=$.core)==null?void 0:ge.data,C),ne=Object.keys(z).length===0||Object.values(z).some(Ce=>!Ce);return{parentValues:z,parentValuesKey:JSON.stringify(z),missingParent:ne}},[p.dependsOn,(ut=$.core)==null?void 0:ut.data,C]),_=m.useMemo(()=>A?{...p.params,...A}:p.params,[A,S,p.params]),P=$t(x),L=h.type==="object",N=typeof u.maxItems=="number"?u.maxItems:void 0,T=m.useMemo(()=>{if(f)return Array.isArray(e)?e.map(vt).filter(z=>!!z):[];const w=vt(L||typeof e=="string"?e:void 0);return w?[w]:[]},[e,f,L]),ee=f||(dt=T[0])==null?void 0:dt.value,V=f||(ft=T[0])==null?void 0:ft.label,G=m.useMemo(()=>new Set(T.map(w=>w.value)),[T]),W=T.length>0,le=m.useRef({}),[xe,re]=m.useState(0),ae=m.useMemo(()=>{const w={};for(const z of T)w[z.value]=z.label||le.current[z.value]||z.value;return w},[T,xe]),M=f&&N!==void 0&&T.length>=N,K=x?P?b?R?null:"x-search.displayTemplate is required.":`Invalid x-search.mode "${j}". Expected "small-list", "large-searchable-list", or "large-paginated-list".`:`Search service "${x}" is not registered.`:"Search not configured.",I=a!==!1,te=!l||l.length===0,[Z,B]=m.useState(!1),[y,F]=m.useState(""),[U,Y]=m.useState([]),[g,k]=m.useState(!1),[Q,ie]=m.useState(!1),[ce,pe]=m.useState(!1),[O,H]=m.useState(null),[ue,J]=m.useState(void 0),q=m.useRef(void 0),ye=m.useRef(null),Re=m.useRef(null),Pe=m.useRef(null),de=m.useRef(void 0),je=m.useRef(void 0),Le=m.useCallback(w=>{if(f){r(t,w.length>0?w.map(ne=>L?ne:ne.value):void 0);return}const z=w[0];if(!z){r(t,void 0);return}r(t,L?{value:z.value,label:z.label}:z.value)},[r,t,f,L]);m.useEffect(()=>{if(!A)return;const w=je.current;if(je.current=A,!w||!W)return;Object.keys(A).some(ne=>w[ne]!==void 0&&w[ne]!==A[ne])&&r(t,void 0)},[S,W,r,t]),m.useEffect(()=>{var ge,Ce;if(f){if(K||L)return;const Ae=T.filter(Oe=>!Oe.label&&!le.current[Oe.value]);if(Ae.length===0||!(P!=null&&P.resolve))return;let Ie=!1;return Promise.all(Ae.map(async Oe=>{try{const ht=await P.resolve(Oe.value,_);if(Ie||!ht)return;le.current[Oe.value]=qe(ht,R).name}catch{}})).then(()=>{Ie||re(Oe=>Oe+1)}),()=>{Ie=!0}}if(K){J(void 0),de.current=void 0;return}if(!ee){J(void 0),de.current=void 0;return}if(((ge=de.current)==null?void 0:ge.value)===ee&&((Ce=de.current)==null?void 0:Ce.label)===V)return;if(L&&V){J({id:ee,name:V}),de.current={value:ee,label:V};return}if(J({id:ee,name:V??ee}),!(P!=null&&P.resolve)){de.current={value:ee,label:V};return}let w=!1;const z=ee,ne=V;return P.resolve(z,_).then(Ae=>{w||(Ae&&J(qe(Ae,R)),de.current={value:z,label:ne})}).catch(()=>{w||(de.current={value:z,label:ne})}),()=>{w=!0}},[K,ee,V,L,f,T,P,_,R]);const Me=m.useCallback(async(w,z=!1)=>{var ge;if(K)return;if(!P){H("Search service not configured.");return}(ge=Re.current)==null||ge.abort();const ne=new AbortController;Re.current=ne,z?pe(!0):(ie(!0),pe(!1),H(null));try{const Ce=await P.search({query:w,cursor:z?q.current:void 0,signal:ne.signal,params:_});if(ne.signal.aborted)return;const Ae=(Ce.options??[]).map(Ie=>qe(Ie,R));Y(z?Ie=>[...Ie,...Ae]:Ae),q.current=Ce.nextCursor,k(((b==null?void 0:b.paginated)??!1)&&Ce.nextCursor!=null)}catch{if(ne.signal.aborted)return;H("Failed to load results. Please try again.")}finally{ne.signal.aborted||(z?pe(!1):ie(!1))}},[K,P,b==null?void 0:b.paginated,_,R]);m.useEffect(()=>{if(!Z)return;const w=z=>{Pe.current&&!Pe.current.contains(z.target)&&B(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[Z]),m.useEffect(()=>{var w;Z||((w=Re.current)==null||w.abort(),F(""),Y([]),k(!1),H(null),ie(!1),pe(!1),q.current=void 0)},[Z]),m.useEffect(()=>{if(!Z)return;if(E){Y([]),k(!1),H(null),q.current=void 0;return}if(!y&&!D){Y([]),k(!1),H(null),q.current=void 0;return}ye.current&&clearTimeout(ye.current);const w=y?300:0;return ye.current=setTimeout(()=>{Y([]),k(!1),q.current=void 0,Me(y)},w),()=>{ye.current&&clearTimeout(ye.current)}},[y,Z,D,Me,E,S]),Se(c,t,r);const $e=ve(t,i,c);if(c===!1)return null;const lt=()=>{F(""),Y([]),k(!1),H(null),q.current=void 0,B(!0)},Zr=w=>{if(f){const z=G.has(w.id);if(!z&&M)return;const ne=z?T.filter(ge=>ge.value!==w.id):[...T,{value:w.id,label:w.name}];z||(le.current[w.id]=w.name,re(ge=>ge+1)),Le(ne),F("");return}Le([{value:w.id,label:w.name}]),J(w),de.current={value:w.id,label:L?w.name:void 0},B(!1)},at=w=>{w.stopPropagation(),r(t,void 0),J(void 0)},ct=(w,z)=>{w.stopPropagation(),Le(T.filter(ne=>ne.value!==z))},Qr=w=>{(w.key==="Enter"||w.key===" ")&&at(w)},en=((pt=d==null?void 0:d.options)==null?void 0:pt.placeholder)??"Select an option",tn=f?"":(ue==null?void 0:ue.name)??"";return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",htmlFor:t,children:[o," ",$e&&n.jsx(s.Text,{color:"red",children:"*"})]}),f&&T.length>0&&n.jsx(s.Flex,{gap:"1",wrap:"wrap",mb:"1",children:T.map(w=>n.jsxs(s.Flex,{align:"center",gap:"1",px:"2",py:"1",style:{background:"var(--accent-3)",borderRadius:"var(--radius-2)",fontSize:"var(--font-size-1)"},children:[n.jsx(s.Text,{size:"1",children:ae[w.value]??w.value}),I&&n.jsx("span",{role:"button",tabIndex:0,"aria-label":`Remove ${ae[w.value]??w.value}`,onMouseDown:z=>z.preventDefault(),onClick:z=>ct(z,w.value),onKeyDown:z=>{(z.key==="Enter"||z.key===" ")&&ct(z,w.value)},style:{lineHeight:1,color:"var(--gray-11)",cursor:"pointer"},children:"×"})]},w.value))}),n.jsxs("div",{ref:Pe,style:{position:"relative"},children:[n.jsx(s.TextField.Root,{id:t,value:Z?y:tn,placeholder:Z&&(b!=null&&b.searchable)?"Search...":en,disabled:!I,readOnly:Z&&!(b!=null&&b.searchable)||f&&!Z,style:te?void 0:{outline:"2px solid var(--red-7)",outlineOffset:"-1px"},onChange:w=>{b!=null&&b.searchable&&(F(w.target.value),Z||lt())},onFocus:()=>{I&&!Z&&lt()},onKeyDown:w=>{w.key==="Escape"&&B(!1)},children:n.jsx(s.TextField.Slot,{side:"right",children:n.jsxs(s.Flex,{align:"center",gap:"1",children:[W&&I&&n.jsx("span",{role:"button",tabIndex:0,onMouseDown:w=>w.preventDefault(),onClick:at,onKeyDown:Qr,style:{lineHeight:1,color:"var(--gray-9)",padding:"0 2px",cursor:"pointer"},"aria-label":"Clear selection",children:"×"}),n.jsx(se.ChevronDownIcon,{style:{transform:Z?"rotate(180deg)":void 0,transition:"transform 150ms"}})]})})}),Z&&n.jsx(s.Box,{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:50,background:"var(--color-panel-solid)",borderRadius:"var(--radius-3)",boxShadow:"var(--shadow-5)",border:"1px solid var(--gray-a6)",overflow:"hidden"},children:K?n.jsx(s.Box,{p:"3",children:n.jsx(s.Text,{size:"2",color:"gray",children:K})}):n.jsx(s.ScrollArea,{style:{maxHeight:240},children:n.jsxs(s.Box,{p:"1",children:[Q&&n.jsx(s.Flex,{justify:"center",p:"4",children:n.jsx(s.Spinner,{})}),!Q&&O&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Text,{size:"2",color:"red",children:O})}),!Q&&!O&&U.length===0&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Text,{size:"2",color:"gray",children:E?"Select the related field first.":y||D?"No results found.":"Type to search…"})}),U.map(w=>{const z=G.has(w.id),ne=M&&!z;return n.jsx(s.Box,{px:"3",py:"2",onMouseDown:ge=>ge.preventDefault(),onClick:()=>{ne||Zr(w)},"aria-disabled":ne||void 0,style:{cursor:ne?"not-allowed":"pointer",opacity:ne?.5:1,borderRadius:"var(--radius-2)",backgroundColor:z?"var(--accent-3)":void 0},className:ne?void 0:"hover:bg-(--gray-3)",children:n.jsxs(s.Flex,{align:"center",justify:"between",gap:"2",children:[n.jsx(s.Text,{size:"2",children:w.name}),f&&z&&n.jsx(s.Text,{size:"1",color:"gray",children:"✓"})]})},w.id)}),(b==null?void 0:b.paginated)&&g&&!ce&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Button,{variant:"ghost",size:"1",style:{width:"100%"},onMouseDown:w=>w.preventDefault(),onClick:()=>void Me(y,!0),children:"Load more"})}),ce&&n.jsx(s.Flex,{justify:"center",p:"2",children:n.jsx(s.Spinner,{})})]})})})]}),!te&&n.jsx(s.Text,{color:"red",size:"1",children:we(l,o)}),u.description&&n.jsx(s.Text,{size:"1",color:"gray",children:u.description})]})})},or=X.withJsonFormsControlProps(Pn),$n=e=>{if(e)return/^\d{2}:\d{2}$/.test(e)?`${e}:00`:e},wt=(e,r)=>{if(!e)return"";const t=e.match(/^(\d{2}:\d{2})(:\d{2})?/);return t?r?`${t[1]}${t[2]??":00"}`:t[1]:e},Bn=(e,r)=>Lt(`${e}T${r}`).format(),Un=({path:e,label:r,required:t,errors:o,description:i,children:l})=>{const a=o.length===0;return n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",htmlFor:e,children:[r," ",t&&n.jsx(s.Text,{color:"red",children:"*"})]}),l,!a&&n.jsx(s.Text,{color:"red",size:"1",children:we(o,r)}),i&&n.jsx(s.Text,{size:"1",color:"gray",children:i})]})})},sr=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,schema:a,uischema:c,enabled:u,visible:d=!0})=>{var S;m.useEffect(()=>{d===!1&&r(t,void 0)},[d,t,r]);const f=ve(t,i,d);if(d===!1)return null;const h=l.length===0,p=typeof e=="string"?e:"",x=((S=c==null?void 0:c.options)==null?void 0:S.showSeconds)===!0,j=x?1:60,b=E=>n.jsx(Un,{path:t,label:o,required:f,errors:l,description:a.description,children:E});if(a.format==="time")return b(n.jsx(s.TextField.Root,{type:"time",step:j,value:wt(p,x),onChange:E=>r(t,$n(E.target.value)),disabled:!u,color:h?void 0:"red",id:t}));const D=a.format==="date-time",[R="",$=""]=p.split("T"),C=wt($,x),A=(E,_)=>{if(!E){r(t,void 0);return}r(t,D?Bn(E,_||"00:00"):E)};return b(n.jsxs(s.Flex,{gap:"2",align:"center",children:[n.jsx(s.TextField.Root,{type:"date",value:R,disabled:!u,color:h?void 0:"red",onChange:E=>A(E.target.value,C),id:t,style:{flex:1}}),D&&n.jsx(s.TextField.Root,{type:"time",step:j,value:C,disabled:!u||!R,color:h?void 0:"red",onChange:E=>A(R,E.target.value),style:{flex:1}})]}))},ir=v.rankWith(2,v.or(v.isDateControl,v.isDateTimeControl,v.isTimeControl)),_n=X.withJsonFormsControlProps(sr),Xe="var(--form-steps-offset, 16px)",Vn=e=>e.enabled?n.jsx(Wn,{...e}):n.jsx(Xn,{...e}),Wn=({uischema:e,schema:r,path:t,renderers:o,cells:i,enabled:l})=>{var B;const a=X.useJsonForms(),c=a.core,u=Ut(),d=(c==null?void 0:c.schema)??r,f=c==null?void 0:c.data,h=c==null?void 0:c.ajv,p=a.config,x=(B=a.i18n)==null?void 0:B.translate,j=(y,F)=>bn(x,y,F),b=lr(e,t),D=b.length,R=D,$=m.useMemo(()=>[...(c==null?void 0:c.errors)??[],...(c==null?void 0:c.additionalErrors)??[]],[c==null?void 0:c.errors,c==null?void 0:c.additionalErrors]),C=m.useMemo(()=>b.map(y=>xn(Ue(y,f,h,p,t),$,d,t,x)),[e,t,f,h,p,$,d,x]),[A,S]=m.useState(0),[E,_]=m.useState(()=>{const y=(U,Y)=>C[Y].length===0&&yn(Ue(U,f,h,p,t),f,t),F=b.findIndex((U,Y)=>!y(U,Y));return F===-1?R:F}),[P,L]=m.useState(new Set),N=Math.min(A,R),T=N===R,ee=m.useEffectEvent(()=>{var y;return(y=u==null?void 0:u.onStepChange)==null?void 0:y.call(u,{step:N,count:D,last:N===R})});m.useEffect(()=>{ee()},[N,D,R]);const V=m.useRef(null),G=m.useRef(null),W=m.useRef(N);if(m.useEffect(()=>{var U,Y;if(W.current===N)return;W.current=N;const y=V.current,F=y&&parseFloat(getComputedStyle(y).scrollMarginTop)||0;y&&y.getBoundingClientRect().top<F&&((U=y.scrollIntoView)==null||U.call(y,{block:"start",behavior:"smooth"})),(Y=G.current)==null||Y.focus({preventScroll:!0})},[N]),!D)return null;const le=y=>{y>E&&y!==N||S(y)},xe=()=>{var F,U;if((F=C[N])!=null&&F.length){L(Y=>new Set(Y).add(N)),(U=u==null?void 0:u.onInvalidStep)==null||U.call(u);return}const y=Math.min(N+1,R);S(y),_(Y=>Math.max(Y,y))},re=[...b.map(y=>cr(y,x)),j("review")],ae=re.length,M=y=>{var F;return y===N?"current":y<D&&((F=C[y])!=null&&F.length)&&(P.has(y)||y<E)?"error":y<E||y<D&&y<N?"done":"todo"},K=(y,F)=>{var U;return F==="error"||F==="current"&&P.has(y)?((U=C[y])==null?void 0:U.length)??0:0},I=(y,F)=>{if(y===R)return j("noteReview");if(K(y,F)>0)return j("noteToFix",{count:K(y,F)});if(F==="done")return j("noteDone");const U=gn(Ue(b[y],f,h,p,t),f,t),Y=U.count===1;return U.kind==="items"?j(Y?"noteItem":"noteItems",{count:U.count}):j(Y?"noteField":"noteFields",{count:U.count})},te=T?void 0:Jn(b[N],x),Z=C.map((y,F)=>({index:F,p:y})).filter(({p:y})=>y.length).map(({index:y,p:F})=>({key:String(y),label:`${re[y]}: ${F.map(U=>U.label).join(", ")}`,onClick:()=>{L(U=>new Set(U).add(y)),le(y)}}));return n.jsxs(s.Flex,{ref:V,gap:"5",align:"start",style:{scrollMarginTop:Xe},children:[n.jsx(s.Box,{asChild:!0,display:{initial:"none",sm:"block"},p:"4",style:{...Ke,flex:"0 0 248px",position:"sticky",top:Xe,maxHeight:`calc(100vh - 2 * ${Xe})`,overflowY:"auto"},children:n.jsx("nav",{"aria-label":j("navLabel"),children:n.jsx("ol",{style:{listStyle:"none",margin:0,padding:0},children:re.map((y,F)=>{const U=M(F);return n.jsxs("li",{style:{position:"relative"},children:[F<ae-1&&n.jsx("span",{"aria-hidden":!0,style:{position:"absolute",left:21,top:40,bottom:-4,width:2,borderRadius:1,background:U==="done"?"var(--green-9)":"var(--gray-a5)"}}),n.jsx(Hn,{index:F,label:y,note:I(F,U),errorCount:K(F,U),status:U,disabled:F>E,onSelect:()=>le(F)})]},`${t}-step-${F}`)})})})}),n.jsxs(s.Box,{style:{...Ke,flex:1,minWidth:0},children:[n.jsxs(s.Box,{px:{initial:"4",sm:"6"},pt:{initial:"4",sm:"5"},pb:"4",children:[n.jsx(s.Text,{as:"p",size:"1",weight:"bold",color:"gray",style:{letterSpacing:"0.06em",textTransform:"uppercase"},children:j("stepOf",{step:N+1,total:ae})}),n.jsx(s.Heading,{ref:G,tabIndex:-1,size:"5",as:"h2",mt:"1",style:{outline:"none"},children:re[N]}),te&&n.jsx(s.Text,{as:"p",size:"2",color:"gray",mt:"1",children:te}),n.jsx(s.Progress,{value:(N+1)/ae*100,size:"1",mt:"4","aria-label":j("progressLabel")})]}),n.jsxs(s.Box,{px:{initial:"4",sm:"6"},pb:"5","data-form-review":T?"":void 0,children:[T&&(Z.length?n.jsx(jt,{title:j("incompleteSteps"),items:Z}):n.jsx(s.Text,{as:"p",size:"2",color:"gray",mb:"5",children:j("reviewHint")})),b.map((y,F)=>{const U=T||F===N;return n.jsxs(s.Box,{hidden:!U,mb:T?"6":void 0,children:[T&&n.jsxs(s.Flex,{justify:"between",align:"center",mb:"3",pb:"2",style:{borderBottom:"1px solid var(--gray-a4)"},children:[n.jsx(s.Heading,{size:"3",as:"h3",children:re[F]}),n.jsx(s.Button,{type:"button",variant:"ghost",onClick:()=>le(F),"aria-label":j("editStep",{step:re[F]}),children:j("edit")})]}),!T&&P.has(F)&&C[F].length>0&&n.jsx(jt,{title:j("missingFields"),items:C[F].map(Y=>({key:Y.path,label:Y.label,onClick:()=>qn(Y.path)}))}),n.jsx(ar,{category:y,schema:r,path:t,renderers:o,cells:i,enabled:l&&!T})]},`${t}-${F}`)})]}),n.jsxs(s.Flex,{gap:"3",align:"center",wrap:"wrap",px:{initial:"4",sm:"6"},py:"4",style:{position:"sticky",bottom:0,zIndex:1,borderTop:"1px solid var(--gray-a5)",background:"var(--color-panel-solid)",borderRadius:"0 0 var(--radius-5) var(--radius-5)"},children:[N>0&&n.jsxs(s.Button,{type:"button",variant:"ghost",color:"gray",size:"3",onClick:()=>S(N-1),children:[n.jsx(se.ChevronLeftIcon,{}),j("back")]}),n.jsx(s.Box,{flexGrow:"1"}),u==null?void 0:u.actions,N<R&&n.jsxs(s.Button,{type:"button",size:"3",onClick:xe,children:[j("continue"),n.jsx(se.ChevronRightIcon,{})]})]})]})]})},Ke={background:"var(--color-panel-solid)",border:"1px solid var(--gray-a4)",borderRadius:"var(--radius-5)",boxShadow:"var(--shadow-2)"};function Hn({index:e,label:r,note:t,errorCount:o,status:i,disabled:l,onSelect:a}){const c={done:{background:"var(--green-9)",color:"white"},current:{background:"var(--color-panel-solid)",color:"var(--accent-11)",boxShadow:"inset 0 0 0 2px var(--accent-9)"},error:{background:"var(--red-9)",color:"white"},todo:{background:"var(--color-panel-solid)",color:"var(--gray-11)",boxShadow:"inset 0 0 0 2px var(--gray-a6)"}};return n.jsx("button",{type:"button",onClick:a,disabled:l,"aria-current":i==="current"?"step":void 0,className:"w-full rounded-md disabled:cursor-default enabled:hover:bg-[var(--gray-a2)]",style:{border:0,background:"transparent",cursor:"pointer",textAlign:"left",padding:"8px 8px 12px"},children:n.jsxs(s.Flex,{gap:"3",align:"start",children:[n.jsx(s.Flex,{align:"center",justify:"center","aria-hidden":!0,style:{width:28,height:28,flex:"0 0 28px",borderRadius:"50%",fontSize:13,fontWeight:600,...c[i]},children:i==="done"?n.jsx(se.CheckIcon,{width:16,height:16}):e+1}),n.jsxs(s.Box,{style:{minWidth:0,flex:1,paddingTop:2},children:[n.jsxs(s.Flex,{align:"center",gap:"2",justify:"between",children:[n.jsx(s.Text,{size:"2",weight:i==="current"?"bold":"medium",style:{color:i==="current"?"var(--accent-11)":"var(--gray-12)"},children:r}),o>0&&n.jsx(s.Flex,{align:"center",justify:"center","aria-hidden":!0,"data-testid":"step-error-count",style:{minWidth:20,height:20,padding:"0 6px",boxSizing:"border-box",borderRadius:10,background:"var(--red-9)",color:"white",fontSize:12,fontWeight:600,lineHeight:1,flexShrink:0},children:o})]}),n.jsx(s.Text,{as:"p",size:"1",color:o>0?"red":"gray",children:t})]})]})})}function qn(e){var t;const r=document.getElementById(e);(t=r==null?void 0:r.scrollIntoView)==null||t.call(r,{block:"center"}),r==null||r.focus()}function jt({title:e,items:r}){return n.jsxs(s.Callout.Root,{color:"red",mb:"4",role:"alert",children:[n.jsx(s.Callout.Icon,{children:n.jsx(se.ExclamationTriangleIcon,{})}),n.jsx(s.Callout.Text,{children:e}),n.jsx("ul",{style:{margin:0,paddingLeft:20},children:r.map(t=>n.jsx("li",{children:n.jsx(s.Button,{type:"button",variant:"ghost",color:"red",size:"1",onClick:t.onClick,children:t.label})},t.key))})]})}const Xn=({uischema:e,schema:r,path:t,renderers:o,cells:i})=>{var f;const l=(f=X.useJsonForms().i18n)==null?void 0:f.translate,a=Ut(),c=lr(e,t),u=c.length,d=m.useEffectEvent(()=>{var h;return(h=a==null?void 0:a.onStepChange)==null?void 0:h.call(a,{step:u,count:u,last:!0})});return m.useEffect(()=>{d()},[u]),n.jsx(s.Flex,{direction:"column",gap:"6",p:{initial:"4",sm:"6"},style:Ke,"data-form-review":"",children:c.map((h,p)=>n.jsxs(s.Box,{children:[n.jsx(s.Heading,{size:"3",as:"h3",mb:"3",children:cr(h,l)}),n.jsx(ar,{category:h,schema:r,path:t,renderers:o,cells:i,enabled:!1})]},`${t}-${p}`))})};function lr(e,r){var a,c;const t=X.useJsonForms(),o=(a=t.core)==null?void 0:a.ajv,i=(c=t.core)==null?void 0:c.data,l=t.config;return pn(e).filter(u=>!u.rule||!o||v.isVisible(u,i,r,o,l))}function ar({category:e,schema:r,path:t,renderers:o,cells:i,enabled:l}){return n.jsx(s.Flex,{direction:"column",gap:"4",children:e.elements.map((a,c)=>n.jsx(X.JsonFormsDispatch,{uischema:a,schema:r,path:t,renderers:o,cells:i,enabled:l},`${t}-${c}`))})}function cr(e,r){return v.deriveLabelForUISchemaElement(e,r??v.defaultTranslator)??e.label}function Jn(e,r){var i;const t=(i=e==null?void 0:e.options)==null?void 0:i.description;if(!e||!t)return;const o=v.getI18nKeyPrefixBySchema(void 0,e);return(r??v.defaultTranslator)(o?`${o}.description`:t,t)}const ur=({uischema:e,schema:r,path:t,renderers:o,cells:i,enabled:l,visible:a=!0})=>{const u=e.elements;return a===!1?null:n.jsx(s.Flex,{direction:"column",gap:"4",children:u.map((d,f)=>n.jsx(X.JsonFormsDispatch,{uischema:d,schema:r,path:t,renderers:o,cells:i,enabled:l},`${t}-${f}`))})},dr=v.rankWith(1,v.uiTypeIs("VerticalLayout")),fr=({uischema:e,schema:r,path:t,renderers:o,cells:i,enabled:l,visible:a=!0})=>{const u=e.elements;return a===!1?null:n.jsx(s.Flex,{direction:"row",gap:"4",children:u.map((d,f)=>n.jsx(s.Box,{style:{flex:1},children:n.jsx(X.JsonFormsDispatch,{uischema:d,schema:r,path:t,renderers:o,cells:i,enabled:l})},`${t}-${f}`))})},pr=v.rankWith(1,v.uiTypeIs("HorizontalLayout")),hr=({uischema:e,schema:r,path:t,renderers:o,cells:i,enabled:l,visible:a=!0})=>{const c=e,u=c.elements;return a===!1?null:n.jsxs(s.Box,{mb:"6",children:[c.label&&n.jsx(s.Heading,{size:"3",mb:"3",className:"text-gray-500 uppercase tracking-wide font-semibold",children:c.label}),n.jsx(s.Flex,{direction:"column",gap:"4",children:u.map((d,f)=>n.jsx(X.JsonFormsDispatch,{uischema:d,schema:r,path:t,renderers:o,cells:i,enabled:l},`${t}-${f}`))})]})},mr=v.rankWith(1,v.uiTypeIs("Group")),xr=e=>e.visible===!1?null:_t(e.uischema)?n.jsx(Vn,{uischema:e.uischema,schema:e.schema,path:e.path,renderers:e.renderers,cells:e.cells,enabled:e.enabled}):n.jsx(Kn,{...e}),Kn=({uischema:e,schema:r,path:t,renderers:o,cells:i,enabled:l})=>{var h;const c=e.elements.filter(p=>p.type==="Category"),[u,d]=m.useState(((h=c[0])==null?void 0:h.label)||"");if(!c.length)return null;const f=c.find(p=>p.label===u)?u:c[0].label;return n.jsxs(s.Tabs.Root,{value:f,onValueChange:d,children:[n.jsx(s.Tabs.List,{children:c.map((p,x)=>n.jsx(s.Tabs.Trigger,{value:p.label,children:p.label},`${t}-${x}`))}),n.jsx(s.Box,{pt:"3",children:c.map((p,x)=>n.jsx(s.Tabs.Content,{value:p.label,children:n.jsx(s.Flex,{direction:"column",gap:"4",children:p.elements.map((j,b)=>n.jsx(X.JsonFormsDispatch,{uischema:j,schema:r,path:t,renderers:o,cells:i,enabled:l},`${t}-${x}-${b}`))})},`${t}-${x}`))})]})},gr=v.rankWith(1,v.uiTypeIs("Categorization"));function Te(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(0)} MB`:e>=1024?`${(e/1024).toFixed(0)} KB`:`${e} B`}function Ee(e){const r=e.split(",").map(l=>l.trim()).filter(Boolean),t=r.filter(l=>l.startsWith(".")),i=(t.length>0?t:r).map(l=>{if(l.endsWith("/*"))return l.split("/")[0].toUpperCase()+"S";if(l.startsWith("."))return l.slice(1).toUpperCase();const a=l.split("/")[1];return a?a.toUpperCase():l});return[...new Set(i)].join(", ")}const Yn="image/png,image/jpeg,image/gif,image/webp,application/pdf,text/html,text/plain,.png,.jpg,.jpeg,.gif,.webp,.pdf,.html,.htm,.txt";function yr(e,r){return r.split(",").map(o=>o.trim()).filter(Boolean).some(o=>o==="*"||o==="*/*"?!0:o.endsWith("/*")?(e.type??"").startsWith(o.slice(0,-1)):o.startsWith(".")?e.name.toLowerCase().endsWith(o.toLowerCase()):e.type===o)}function Gn(e){const r=!!e.type,t=Ye(e.name)!==void 0;return!r&&!t?!0:yr(e,Yn)}function Ye(e){const r=e.split(/[/\\]/).pop()??e,t=r.lastIndexOf(".");if(!(t<=0||t===r.length-1))return r.slice(t)}function Zn(e,r,t){br(new Blob([e],{type:t}),r)}function br(e,r){const t=URL.createObjectURL(e),o=document.createElement("a");o.href=t,o.download=r,o.click(),setTimeout(()=>URL.revokeObjectURL(t),0)}async function Qn(e,r){const t=await fetch(e);if(!t.ok)throw new Error(`Download failed (${t.status})`);br(await t.blob(),r)}function eo(e,r,t){const o=t.name||t.key;if(!e)return o;const i=nt(e,r,o),l=Ye(t.name??"")??Ye(t.key);return!l||i.toLowerCase().endsWith(l.toLowerCase())?i:`${i}${l}`}const to=new Set(["/","\\","<",">",":",'"',"|","?","*"]),ro=e=>to.has(e)||e.charCodeAt(0)<32||e.charCodeAt(0)===127;function no(e,r){const t=Array.from(e,o=>ro(o)?"_":o).join("").trim();return t===""||t.startsWith(".")?r:t}function nt(e,r,t){const o=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:{};return no(We(e,o),t)}function oo(e){return e?Array.isArray(e)?e:[e]:[]}const so=({data:e,handleChange:r,path:t,label:o,required:i,uischema:l,schema:a,enabled:c,errors:u,visible:d=!0})=>{const f=zt();Se(d,t,r);const h=ve(t,i,d),p=!u||u.length===0,x=(a==null?void 0:a["x-file"])??{},j=(l==null?void 0:l.options)??{},b=x.maxFiles??j.maxFiles??1,D=x.maxSize??j.maxSize??5*1024*1024,R=x.accept??j.accept??"image/*,application/pdf",$=typeof x.fileName=="string"?x.fileName:void 0,C=b>1,A=c!==!1,[S,E]=m.useState(!1),[_,P]=m.useState(null),[L,N]=m.useState({}),[T,ee]=m.useState({}),V=m.useRef(new Set),G=m.useRef(null),W=oo(e),le=W.length>=b,xe=g=>{const k=T[g];return{name:(k==null?void 0:k.name)??g,type:k==null?void 0:k.type}},re=async g=>{var ie,ce;const k=(ie=T[g])==null?void 0:ie.blobUrl;if(k)return k;const Q=await((ce=f==null?void 0:f.getDownloadUrl)==null?void 0:ce.call(f,g));return Q==null?void 0:Q.url},ae=(g,k)=>{N(Q=>({...Q,[g]:k}))},M=g=>{N(k=>{if(!k[g])return k;const Q={...k};return delete Q[g],Q})};m.useEffect(()=>()=>{V.current.forEach(g=>URL.revokeObjectURL(g)),V.current.clear()},[]);const K=m.useCallback(async g=>{if(P(null),W.length>=b){P(`Maximum ${b} file${b>1?"s":""} allowed.`);return}if(g.size>D){P(`File exceeds the ${Te(D)} limit.`);return}if(!yr(g,R)){P(`Invalid type. Accepted: ${Ee(R)}`);return}if(!(f!=null&&f.onUpload)){P("Upload service not configured.");return}try{const k=await f.onUpload(g),Q=URL.createObjectURL(g);V.current.add(Q);const ie={key:k.key,name:k.name??g.name,type:g.type||void 0,blobUrl:Q};ee(pe=>({...pe,[k.key]:ie}));const ce=[...W,k.key];r(t,C?ce:ce[0])}catch{P("Upload failed. Please try again."),G.current&&(G.current.value="")}},[W,b,D,R,f,t,r,C]);if(d===!1)return null;const I=g=>{g.preventDefault(),g.stopPropagation(),!(!A||le)&&E(g.type==="dragenter"||g.type==="dragover")},te=g=>{var k;g.preventDefault(),g.stopPropagation(),E(!1),!(!A||le)&&(k=g.dataTransfer.files)!=null&&k[0]&&K(g.dataTransfer.files[0])},Z=g=>{var k;(k=g.target.files)!=null&&k[0]&&(K(g.target.files[0]),g.target.value="")},B=g=>{if(!A)return;ee(Q=>{var pe;const ie={...Q},ce=(pe=ie[g])==null?void 0:pe.blobUrl;return ce&&(URL.revokeObjectURL(ce),V.current.delete(ce)),delete ie[g],ie}),M(g);const k=W.filter(Q=>Q!==g);r(t,C?k.length>0?k:void 0:k[0])},y=async(g,k)=>{var ce,pe;g.preventDefault(),M(k);const Q=(ce=T[k])==null?void 0:ce.blobUrl;if(Q){(pe=window.open(Q,"_blank","noopener,noreferrer"))==null||pe.focus();return}const ie=window.open("","_blank");if(ie)try{const O=await re(k);O?ie.location.href=O:(ie.close(),ae(k,"Unable to open file."))}catch{ie.close(),ae(k,"Unable to open file.")}},F=async(g,k)=>{M(g);try{const Q=await re(g);if(!Q){ae(g,"Unable to download file.");return}await Qn(Q,k)}catch{ae(g,"Unable to download file.")}};if(!A&&W.length===0)return null;const U=b-W.length,Y=A&&!le;return n.jsxs(s.Box,{mb:"4",children:[n.jsxs(s.Flex,{align:"center",justify:"between",mb:"2",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",children:[o,h&&n.jsx(s.Text,{color:"red",children:" *"})]}),n.jsx(s.Text,{size:"1",color:"gray",children:C?`Up to ${b} files · ${Te(D)} each · ${Ee(R)}`:`${Te(D)} · ${Ee(R)}`})]}),W.map((g,k)=>{var J;const Q=k+1,ie=(J=T[g])==null?void 0:J.name,ce=eo($,{index:Q},{name:ie,key:g}),pe=$?ce:ie??"Uploaded File",O=!!($&&ie),H=L[g],ue=Gn(xe(g));return n.jsxs(s.Card,{size:"2",variant:"surface",mb:"2",children:[n.jsxs(s.Flex,{align:"center",gap:"3",children:[n.jsx(s.Box,{style:{background:"var(--blue-3)",padding:8,borderRadius:6,color:"var(--blue-9)",flexShrink:0},children:n.jsx(se.FileTextIcon,{width:"20",height:"20"})}),n.jsxs(s.Box,{style:{flex:1,overflow:"hidden"},children:[n.jsx(s.Text,{size:"2",weight:"bold",style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:pe}),O&&n.jsx(s.Text,{size:"1",color:"gray",style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ie})]}),n.jsxs(s.Flex,{align:"center",gap:"2",style:{flexShrink:0},children:[ue&&n.jsx(s.Button,{variant:"soft",color:"blue",size:"1",onClick:q=>void y(q,g),children:"View"}),n.jsx(s.Tooltip,{content:"Download",children:n.jsx(s.IconButton,{variant:"ghost",color:"gray","aria-label":"Download",onClick:()=>void F(g,ce),children:n.jsx(se.DownloadIcon,{})})}),n.jsx(se.CheckCircledIcon,{style:{color:"var(--green-9)",width:18,height:18}}),A&&n.jsx(s.IconButton,{variant:"ghost",color:"gray",onClick:()=>B(g),children:n.jsx(se.Cross2Icon,{})})]})]}),H&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:H})]},g)}),Y&&n.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{var g;return(g=G.current)==null?void 0:g.click()},onKeyDown:g=>{var k;(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),(k=G.current)==null||k.click())},onDragEnter:I,onDragLeave:I,onDragOver:I,onDrop:te,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",S?"border-blue-500 bg-blue-50":_?"border-red-300 bg-red-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"].join(" "),children:[n.jsx("input",{ref:G,type:"file",style:{display:"none"},accept:R,onChange:Z}),n.jsx(s.Flex,{direction:"column",align:"center",gap:"2",children:_?n.jsxs(n.Fragment,{children:[n.jsx(se.ExclamationTriangleIcon,{style:{width:32,height:32,color:"var(--red-9)"}}),n.jsx(s.Text,{size:"2",color:"red",weight:"medium",children:_}),n.jsx(s.Text,{size:"1",color:"gray",children:"Click to try again"})]}):n.jsxs(n.Fragment,{children:[n.jsx(se.UploadIcon,{style:{width:32,height:32,color:"var(--gray-8)"}}),n.jsx(s.Text,{size:"2",weight:"medium",children:W.length>0?`Add another file (${U} remaining)`:"Click to upload or drag and drop"}),n.jsxs(s.Text,{size:"1",color:"gray",children:[Te(D)," max · ",Ee(R)]})]})})]}),A&&le&&C&&n.jsxs(s.Text,{size:"1",color:"gray",mt:"1",style:{display:"block",textAlign:"center"},children:["Maximum ",b," files uploaded. Remove one to replace it."]}),!p&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:we(u,o)})]})},vr=X.withJsonFormsControlProps(so),wr=v.rankWith(10,v.and(v.schemaMatches(e=>{if(e.type==="string"&&e.format==="file")return!0;if(e.type==="array"){const r=e.items;return(r==null?void 0:r.type)==="string"&&(r==null?void 0:r.format)==="file"}return!1})));function jr(e,r){return e!==!1&&r!==!0}class Ge extends Error{}async function io(e,r){const{read:t,utils:o}=await import("@e965/xlsx"),i=t(e,{type:"array",cellDates:!0});if(i.SheetNames.length===0)throw new Ge("This file has no sheets.");const l=r??i.SheetNames[0],a=i.Sheets[l];if(!a)throw new Ge(`This file doesn't have a sheet named "${l}".`);const c=o.sheet_to_json(a,{header:1,raw:!0,defval:null});return{sheetName:l,matrix:c,rowCount:c.length,colCount:Math.max(0,...c.map(u=>u.length))}}function lo(e){let r=e+1,t="";for(;r>0;){const o=(r-1)%26;t=String.fromCharCode(65+o)+t,r=Math.floor((r-1)/26)}return t}class me extends Error{constructor(t,o){super(o??t);mt(this,"code");this.code=t,this.name="FormulaError"}}const ao=["IFS","IFERROR","AND","OR","NOT","ROUND","ROUNDUP","ROUNDDOWN","INDEX","VLOOKUP","HLOOKUP","SUM","AVERAGE","COUNT","DATE","TODAY"],co=["MAX","MIN","MAXA","MINA","MEDIAN","LARGE","SMALL","PERMUT","PERMUTATIONA","MATCH","SWITCH","SUBSTITUTE","TEXTJOIN","COUNTA","UPPER"],uo=["YEAR","MONTH","DAY","WEEKDAY"],fo=["IF"],po=["CONCATENATE","CONCAT","LEN","TRIM","LOWER","LEFT","RIGHT","MID","FIND","SEARCH"],ho=new Set([...ao,...co,...uo,...po,...fo]),mo=/"(?:[^"]|"")*"/g,Tt=new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(","g");function xo(e){const r=e.replace(mo,o=>" ".repeat(o.length));Tt.lastIndex=0;let t;for(;(t=Tt.exec(r))!==null;){const o=t[1].toUpperCase();if(!ho.has(o))throw new me("NAME",`Function ${o} is not allowed.`)}}function go(e,r,t){let o=e;if(o==null)throw t.NA;if(typeof o=="object"&&!(o instanceof t)&&(o=r.retrieveRef(o)),o instanceof t)throw o;if(typeof o=="boolean")return o;if(typeof o=="number")return o!==0;throw t.VALUE}function Tr(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function Ne(e){const r=Tr(e);return Array.isArray(r)?r.flat(1/0):[r]}function oe(e){const r=Tr(e);return Array.isArray(r)?r.flat(1/0)[0]:r}function Be(e){return e===void 0?void 0:oe(e)}function he(e){return e==null||e===""?"":typeof e=="boolean"?e?"TRUE":"FALSE":e instanceof Date?e.toLocaleDateString():String(e)}function yo(e,r){return e instanceof r?e:new r(e.message||"#ERROR!")}function fe(e){return e.find(r=>r instanceof Error)}function bo(e,r){const t=l=>{throw yo(l,r)},o=(l,{checkArgsForErrors:a=!0}={})=>(...c)=>{const u=c.flatMap(Ne);if(a){const f=fe(u);f&&t(f)}const d=l(...u);return d instanceof Error?t(d):d},i=(l,{toText:a=!1}={})=>c=>{const u=oe(c),d=fe([u]);d&&t(d);const f=l(a?he(u):u);return f instanceof Error?t(f):f};return{IF:(l,a,c,u)=>{const d=go(a,l,r);if(c==null)throw r.NA;return d?c:u??!1},MAX:o(e.MAX),MIN:o(e.MIN),MAXA:o(e.MAXA),MINA:o(e.MINA),MEDIAN:o(e.MEDIAN),COUNTA:o(e.COUNTA,{checkArgsForErrors:!1}),LARGE:(l,a)=>{const c=Ne(l),u=oe(a),d=fe([...c,u]);d&&t(d);const f=e.LARGE(c,u);return f instanceof Error?t(f):f},SMALL:(l,a)=>{const c=Ne(l),u=oe(a),d=fe([...c,u]);d&&t(d);const f=e.SMALL(c,u);return f instanceof Error?t(f):f},PERMUT:(l,a)=>{const c=[oe(l),oe(a)],u=fe(c);u&&t(u);const d=e.PERMUT(c[0],c[1]);return d instanceof Error?t(d):d},PERMUTATIONA:(l,a)=>{const c=[oe(l),oe(a)],u=fe(c);u&&t(u);const d=e.PERMUTATIONA(c[0],c[1]);return d instanceof Error?t(d):d},MATCH:(l,a)=>{const c=oe(l),u=Ne(a),d=fe([c,...u]);d&&t(d);const f=e.MATCH(c,u,0);return f instanceof Error?t(f):f},SWITCH:(...l)=>{const a=l.map(oe),c=fe(a);c&&t(c);const u=e.SWITCH(...a);return u instanceof Error?t(u):u},SUBSTITUTE:(l,a,c,u)=>{const d=[he(oe(l)),he(oe(a)),he(oe(c))];u!==void 0&&d.push(oe(u));const f=fe(d);f&&t(f);const h=e.SUBSTITUTE(...d);return h instanceof Error?t(h):h},TEXTJOIN:(l,a,...c)=>{const u=he(oe(l)),d=oe(a),f=c.flatMap(Ne).map(he),h=fe([u,d]);h&&t(h);const p=e.TEXTJOIN(u,d,f);return p instanceof Error?t(p):p},UPPER:i(e.UPPER),YEAR:i(e.YEAR),MONTH:i(e.MONTH),DAY:i(e.DAY),WEEKDAY:(l,a)=>{const c=oe(l),u=oe(a),d=fe([c]);d&&t(d);const f=e.WEEKDAY(c,u);return f instanceof Error?t(f):f},CONCATENATE:(...l)=>{const a=l.flatMap(Ne),c=fe(a);c&&t(c);const u=e.CONCATENATE(...a.map(he));return u instanceof Error?t(u):u},CONCAT:(...l)=>{const a=l.flatMap(Ne),c=fe(a);c&&t(c);const u=e.CONCAT(...a.map(he));return u instanceof Error?t(u):u},LEN:i(e.LEN,{toText:!0}),TRIM:i(e.TRIM,{toText:!0}),LOWER:i(e.LOWER,{toText:!0}),LEFT:(l,a)=>{const c=oe(l),u=Be(a),d=fe([c]);d&&t(d);const f=e.LEFT(he(c),u);return f instanceof Error?t(f):f},RIGHT:(l,a)=>{const c=oe(l),u=Be(a),d=fe([c]);d&&t(d);const f=e.RIGHT(he(c),u);return f instanceof Error?t(f):f},MID:(l,a,c)=>{const u=oe(l),d=oe(a),f=oe(c),h=fe([u,d,f]);h&&t(h);const p=e.MID(he(u),d,f);return p instanceof Error?t(p):p},FIND:(l,a,c)=>{const u=oe(l),d=oe(a),f=Be(c),h=fe([u,d]);h&&t(h);const p=e.FIND(he(u),he(d),f);return p instanceof Error?t(p):p},SEARCH:(l,a,c)=>{const u=oe(l),d=oe(a),f=Be(c),h=fe([u,d]);h&&t(h);const p=e.SEARCH(he(u),he(d),f);return p instanceof Error?t(p):p}}}const vo={"#REF!":"REF","#VALUE!":"VALUE","#DIV/0!":"DIV0","#NAME?":"NAME","#N/A":"NA","#NUM!":"NUM","#NULL!":"NULL"};function Et(e){return vo[e.error]??"ERROR"}function St(e,r){if(e instanceof me)return e;if(e instanceof r){const t=e.details;return t instanceof me?t:t instanceof r?new me(Et(t),t.message):new me(Et(e),e.message)}return new me("ERROR",e instanceof Error?e.message:void 0)}function wo(e){return Math.max(0,...e.map(r=>(r==null?void 0:r.length)??0))}function jo(e){return r=>{const t=e[r.row-1];if(r.row<1||r.col<1||t==null||r.col-1>=t.length)throw new me("REF");const o=t[r.col-1];return o==null||o===""?null:o}}function To(e){return r=>{const t=Math.min(r.from.row,r.to.row),o=Math.min(r.from.col,r.to.col),i=Math.max(r.from.row,r.to.row),l=Math.max(r.from.col,r.to.col),a=wo(e);if(t>e.length||o>a)throw new me("REF");const c=Math.min(i,e.length),u=[];for(let d=t;d<=c;d++){const f=e[d-1],h=[];if(f!=null){const p=Math.min(l,f.length);for(let x=o;x<=p;x++){const j=f[x-1];h.push(j==null||j===""?null:j)}}u.push(h)}return u}}function Eo(e){if(e==null||e==="")return null;if(typeof e=="number"||typeof e=="string"||typeof e=="boolean"||e instanceof Date)return e;throw new me("VALUE")}async function Er(e,r){if(typeof e!="string")throw new me("ERROR");const t=e.trim();if(t==="")throw new me("ERROR");const o=t.startsWith("=")?t.slice(1):t;xo(o);const[i,l]=await Promise.all([import("fast-formula-parser"),import("@formulajs/formulajs")]),a=i.default??i,c=a.FormulaError,u=new a({...r,functions:bo(l,c)});let d;try{d=u.parse(o,{row:1,col:1,sheet:"Sheet1"})}catch(f){throw St(f,c)}if(d instanceof c)throw St(d,c);return Eo(d)}async function So(e,r){return Er(r,{onCell:jo(e),onRange:To(e)})}const Ct=-1;async function Sr(e,r){const t=Object.keys(e);return Er(r,{onVariable:o=>{const i=t.indexOf(o);return i===-1?null:{row:Ct,col:i+1}},onCell:o=>{if(o.row===Ct)return e[t[o.col-1]]??null;throw new me("REF")},onRange:()=>{throw new me("REF")}})}const Cr={REF:"#REF!",VALUE:"#VALUE!",DIV0:"#DIV/0!",NAME:"#NAME?",ERROR:"#ERROR!",NA:"#N/A",NUM:"#NUM!",NULL:"#NULL!"};function ot(e){const r=e instanceof me?e.code:"ERROR";return Cr[r]}async function Co(e,r){return e.length===0?r.map(t=>({id:typeof(t==null?void 0:t.id)=="string"?t.id:"(unknown)",label:(t==null?void 0:t.label)??"(unknown)",value:null,error:Cr.ERROR})):Promise.all(r.map(async t=>{try{if(!t||typeof t.label!="string"||typeof t.expression!="string"||typeof t.id!="string")throw new me("ERROR");return{id:t.id,label:t.label,value:await So(e,t.expression)}}catch(o){return{id:typeof(t==null?void 0:t.id)=="string"?t.id:"(unknown)",label:(t==null?void 0:t.label)??"(unknown)",value:null,error:ot(o)}}}))}function Rt(e){const r=new Set;for(const{id:t}of e){if(r.has(t))return t;r.add(t)}return null}function Rr(e){const{columnHeader:r,rowHeader:t,columns:o,rows:i}=e;if(o!==void 0&&!Array.isArray(o))return"columns must be an array of { id, label } objects.";if(i!==void 0&&!Array.isArray(i))return"rows must be an array of { id, label } objects.";if(o!==void 0&&o.length===0)return"columns is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";if(i!==void 0&&i.length===0)return"rows is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";const l=f=>!!f&&typeof f.id=="string"&&f.id!==""&&typeof f.label=="string"&&f.label!=="",a=o==null?void 0:o.findIndex(f=>!l(f));if(a!=null&&a!==-1)return`columns[${a}] must be a { id, label } object with non-empty string fields.`;const c=i==null?void 0:i.findIndex(f=>!l(f));if(c!=null&&c!==-1)return`rows[${c}] must be a { id, label } object with non-empty string fields.`;const u=!!o&&o.length>0,d=!!i&&i.length>0;if(u){const f=Rt(o);if(f)return`duplicate column id "${f}" — every declared column id must be unique.`}if(d){const f=Rt(i);if(f)return`duplicate row id "${f}" — every declared row id must be unique.`}return r&&t?"columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape.":u&&d?"columns and rows cannot both be declared — pick one orientation for the persisted sheet shape.":r&&!u?"columnHeader is true but columns is missing or empty — declare the column list columnHeader positions map to.":t&&!d?"rowHeader is true but rows is missing or empty — declare the row list rowHeader positions map to.":null}function At(e,r={}){const t=Rr(r);if(t)throw new Error(`x-spreadsheet: ${t}`);const{columnHeader:o,rowHeader:i,columns:l,rows:a}=r;return l&&l.length>0?Ro(e,l,o===!0):a&&a.length>0?Ao(e,a,i===!0):e}function Ro(e,r,t){return(t?e.slice(1):e).map(i=>{const l=Object.create(null);return r.forEach((a,c)=>{l[a.id]=i[c]??null}),l})}function Ao(e,r,t){const o=t?1:0,i=Math.max(0,...e.map(a=>a.length)),l=Math.max(0,i-o);return Array.from({length:l},(a,c)=>{const u=o+c,d=Object.create(null);return r.forEach((f,h)=>{var p;d[f.id]=((p=e[h])==null?void 0:p[u])??null}),d})}function Ar(e){return!Array.isArray(e[0])}function Fo(e){const r=Object.create(null);for(const{id:t,label:o,value:i,error:l}of e)r[t]=l===void 0?{label:o,value:i}:{label:o,value:i,error:l};return r}function Ze(e,r){const t=o=>o instanceof Date?o.toISOString():o??null;return t(e)===t(r)}function ko(e,r){const t=e??{},o=r??{},i=Object.keys(t);return i.length!==Object.keys(o).length?!1:i.every(l=>{if(!Object.prototype.hasOwnProperty.call(o,l))return!1;const a=t[l],c=o[l];return a.label===c.label&&a.error===c.error&&Ze(a.value,c.value)})}function Io(e,r){if(e==null||r==null)return e===r;const t=Array.isArray(e);if(t!==Array.isArray(r))return!1;if(t){const a=e,c=r;return a.length===c.length&&a.every((u,d)=>Ze(u,c[d]))}const o=e,i=r,l=Object.keys(o);return l.length!==Object.keys(i).length?!1:l.every(a=>Object.prototype.hasOwnProperty.call(i,a)&&Ze(o[a],i[a]))}function Oo(e,r){if(e===r)return!0;if(e==null||r==null)return!1;const t=e,o=r;return t.length!==o.length?!1:t.every((i,l)=>Io(i,o[l]))}function Do(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e instanceof Date}function Fr(e,r){if(e.length===0)return[];const t=[],o=new Set;for(const l of r??[])o.has(l)||(o.add(l),t.push(l));for(const l of e)for(const a of Object.keys(l))o.has(a)||(o.add(a),t.push(a));if(t.length===0)return[];const i=e.map(l=>t.map(a=>{if(!Object.prototype.hasOwnProperty.call(l,a))return null;const c=l[a];return Do(c)?c:null}));return[t,...i]}function No(e){const r=Math.max(0,...e.map(t=>t.length));return Array.from({length:r},(t,o)=>e.map(i=>i[o]??null))}const Lo=".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv",Mo=10*1024*1024,Je=200,zo=50,Po=[];function Ft(e){return e==null||e===""?"":e instanceof Date?e.toLocaleDateString():String(e)}const $o=({data:e,handleChange:r,path:t,label:o,required:i,schema:l,enabled:a,readonly:c,errors:u,visible:d=!0})=>{Se(d,t,r);const f=ve(t,i,d),h=!u||u.length===0,p=jr(a,c),x=(l==null?void 0:l["x-spreadsheet"])??{},j=(l==null?void 0:l["x-evaluate"])??Po,b=x.accept??Lo,D=x.maxSize??Mo,R=x.columnHeader===!0,$=x.rowHeader===!0,C=x.columns,A=x.rows,S=Array.isArray(C)&&C.length>0,E=Array.isArray(A)&&A.length>0,_=Rr({columnHeader:R,rowHeader:$,columns:C,rows:A}),P=x.showSheet!==!1,L=x.sheetName,N=x.persistSheet!==!1,T=e??null,[ee,V]=m.useState(()=>T!=null&&T.sheet||Object.keys((T==null?void 0:T.derivations)??{}).length>0?"ready":"empty"),[G,W]=m.useState(null),[le,xe]=m.useState(!1),[re,ae]=m.useState(null),[M,K]=m.useState(null),I=m.useRef(null),te=m.useRef(null),Z=(T==null?void 0:T.sheet)??null,B=m.useCallback(O=>{if(!Ar(O))return O;const H=E?A:S?C:void 0,ue=Fr(O,H==null?void 0:H.map(J=>J.id));return E?No(ue):ue},[S,E,C,A]),y=m.useMemo(()=>re??(Z?B(Z):null),[re,Z,B]),F=((M==null?void 0:M.matrix)===y?M.derivations:null)??(T==null?void 0:T.derivations)??{},U=y!=null||T!=null,Y=m.useMemo(()=>{const O=S?1:0,H=E?1:0,ue=y?y.slice(O):[],J=ue.slice(0,Je),q=Math.min(zo,Math.max(0,...J.map(de=>Math.max(0,de.length-H)))),ye=Array.from({length:q},(de,je)=>je+H),Re="",Pe=E&&!S;return n.jsx(n.Fragment,{children:y&&P&&n.jsxs(s.Box,{mt:"3",children:[n.jsx(s.Box,{style:{overflow:"auto",maxHeight:420},children:n.jsxs(s.Table.Root,{variant:"surface",size:"1",children:[!Pe&&n.jsx(s.Table.Header,{children:n.jsxs(s.Table.Row,{children:[n.jsx(s.Table.ColumnHeaderCell,{children:Re}),ye.map(de=>{var je;return n.jsx(s.Table.ColumnHeaderCell,{children:S?((je=C==null?void 0:C[de])==null?void 0:je.label)??"":lo(de)},de)})]})}),n.jsx(s.Table.Body,{children:J.map((de,je)=>{var Me;const Le=O+je;return n.jsxs(s.Table.Row,{children:[n.jsx(s.Table.RowHeaderCell,{style:E?{fontWeight:700,background:"var(--gray-a3)"}:void 0,children:E?((Me=A==null?void 0:A[Le])==null?void 0:Me.label)??"":S?"":Le+1}),ye.map($e=>n.jsx(s.Table.Cell,{children:Ft(de[$e])},$e))]},je)})})]})}),ue.length>Je&&n.jsxs(s.Text,{size:"1",color:"gray",mt:"1",style:{display:"block"},children:["Showing first ",Je," of ",ue.length," rows"]})]})})},[y,P,S,E,C,A]),g=m.useCallback(async O=>{if(W(null),O.size>D){W(`File exceeds the ${Te(D)} limit.`);return}if(!b.split(",").map(q=>q.trim()).some(q=>q==="*"||q==="*/*"?!0:q.endsWith("/*")?O.type.startsWith(q.slice(0,-1)):q.startsWith(".")?O.name.toLowerCase().endsWith(q.toLowerCase()):O.type===q)){W(`Invalid type. Accepted: ${Ee(b)}`);return}V("parsing");let J;try{const q=await O.arrayBuffer();J=(await io(q,L)).matrix}catch(q){V("error"),W(q instanceof Ge?q.message:"This doesn't look like a valid spreadsheet. Please check the file and try again.");return}if(S||E)try{J=B(At(J,{columnHeader:R,rowHeader:$,columns:C,rows:A}))}catch(q){V("error"),W(q instanceof Error?q.message:"Failed to process this sheet.");return}te.current=(e==null?void 0:e.sheet)??null,ae(J),V("ready")},[b,D,L,e,R,$,C,A,S,E,B]);if(m.useEffect(()=>{re!=null&&Z!=null&&Z!==te.current&&ae(null)},[re,Z]),m.useEffect(()=>{if(_||j.length===0&&!N)return;let O=!1;const H=J=>{p&&(ko(T==null?void 0:T.derivations,J==null?void 0:J.derivations)&&Oo(T==null?void 0:T.sheet,J==null?void 0:J.sheet)||(te.current=(J==null?void 0:J.sheet)??null,r(t,J)))},ue=y??[];if(ue.length===0){T!=null&&H(void 0);return}return Co(ue,j).then(J=>{if(O)return;let q;if(re!=null){if(N)try{q=At(ue,{columnHeader:S,rowHeader:E,columns:C,rows:A})}catch(Re){W(Re instanceof Error?Re.message:"Failed to process this sheet.");return}}else q=T==null?void 0:T.sheet;W(null);const ye=Fo(J);K({matrix:ue,derivations:ye}),H(q===void 0?{derivations:ye}:{sheet:q,derivations:ye})}),()=>{O=!0}},[y,re,j,p,N,S,E,C,A,_]),d===!1)return null;if(_)return n.jsxs(s.Box,{mb:"4",children:[n.jsx(s.Text,{as:"label",size:"2",weight:"bold",children:o}),n.jsxs(s.Text,{size:"2",color:"red",style:{display:"block"},children:["Invalid x-spreadsheet config: ",_]})]});if(!p&&!U)return null;const k=O=>{O.preventDefault(),O.stopPropagation(),p&&xe(O.type==="dragenter"||O.type==="dragover")},Q=O=>{var H;O.preventDefault(),O.stopPropagation(),xe(!1),p&&(H=O.dataTransfer.files)!=null&&H[0]&&g(O.dataTransfer.files[0])},ie=O=>{var H;(H=O.target.files)!=null&&H[0]&&(g(O.target.files[0]),O.target.value="")},ce=()=>{p&&(ae(null),K(null),te.current=null,W(null),V("empty"),r(t,void 0))},pe=P&&y==null&&T!=null;return n.jsxs(s.Box,{mb:"4",children:[n.jsxs(s.Flex,{align:"center",justify:"between",mb:"2",children:[n.jsxs(s.Flex,{align:"center",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",children:[o,f&&n.jsx(s.Text,{color:"red",children:" *"})]}),U&&p&&n.jsxs(n.Fragment,{children:[n.jsx(s.Tooltip,{content:"Replace spreadsheet",children:n.jsx(s.IconButton,{variant:"ghost",size:"1",onClick:()=>{var O;return(O=I.current)==null?void 0:O.click()},"aria-label":"Replace spreadsheet",children:n.jsx(se.UploadIcon,{})})}),n.jsx(s.Tooltip,{content:"Remove spreadsheet",children:n.jsx(s.IconButton,{variant:"ghost",size:"1",color:"gray",onClick:ce,"aria-label":"Remove spreadsheet",children:n.jsx(se.Cross2Icon,{})})})]})]}),n.jsxs(s.Text,{size:"1",color:"gray",children:[Te(D)," max · ",Ee(b)]})]}),U&&G&&n.jsx(s.Text,{size:"2",color:"red",mb:"2",style:{display:"block"},children:G}),n.jsx("input",{ref:I,type:"file",style:{display:"none"},accept:b,onChange:ie}),p&&!U&&n.jsx("div",{role:"button",tabIndex:0,onClick:()=>{var O;return(O=I.current)==null?void 0:O.click()},onKeyDown:O=>{var H;(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),(H=I.current)==null||H.click())},onDragEnter:k,onDragLeave:k,onDragOver:k,onDrop:Q,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",le?"border-blue-500 bg-blue-50":G?"border-red-300 bg-red-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"].join(" "),children:n.jsx(s.Flex,{direction:"column",align:"center",gap:"2",children:ee==="parsing"?n.jsxs(n.Fragment,{children:[n.jsx(s.Spinner,{size:"3"}),n.jsx(s.Text,{size:"2",color:"gray",children:"Parsing spreadsheet…"})]}):G?n.jsxs(n.Fragment,{children:[n.jsx(se.ExclamationTriangleIcon,{style:{width:32,height:32,color:"var(--red-9)"}}),n.jsx(s.Text,{size:"2",color:"red",weight:"medium",children:G}),n.jsx(s.Text,{size:"1",color:"gray",children:"Click to try again"})]}):n.jsxs(n.Fragment,{children:[n.jsx(se.UploadIcon,{style:{width:32,height:32,color:"var(--gray-8)"}}),n.jsx(s.Text,{size:"2",weight:"medium",children:"Click to upload or drag and drop"}),n.jsxs(s.Text,{size:"1",color:"gray",children:[Te(D)," max · ",Ee(b)]})]})})}),Y,pe&&n.jsx(s.Text,{size:"2",color:"gray",mt:"3",style:{display:"block"},children:"Sheet preview not stored for this field — re-upload to view contents."}),Object.keys(F).length>0&&n.jsxs(s.Box,{mt:"3",children:[n.jsx(s.Text,{size:"2",weight:"bold",as:"div",mb:"1",children:"Computed values"}),n.jsx(s.Flex,{direction:"column",gap:"1",children:Object.entries(F).map(([O,H])=>n.jsxs(s.Flex,{justify:"between",children:[n.jsx(s.Text,{size:"2",children:H.label}),H.error?n.jsx(s.Text,{size:"2",color:"red",children:H.error}):n.jsx(s.Text,{size:"2",children:Ft(H.value)})]},O))})]}),!h&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:we(u,o)})]})},kr=X.withJsonFormsControlProps($o),Ir=v.rankWith(10,v.schemaMatches(e=>e.type==="object"&&typeof e["x-spreadsheet"]=="object")),Bo="Sheet1",Uo="xlsx";function _o(e){if(e===void 0)return null;if(!Array.isArray(e))return"columns must be an array of { id, label } objects.";if(e.length===0)return"columns is declared but empty — declare at least one field, or omit it entirely.";const r=e.findIndex(t=>!t||typeof t!="object"||typeof t.id!="string"||t.id===""||typeof t.label!="string"||t.label==="");return r!==-1?`columns[${r}] must be a { id, label } object with non-empty string fields.`:null}function Vo(e,r){if(!Ar(e))return e;const t=Fr(e,r==null?void 0:r.map(a=>a.id));if(!r||t.length===0)return t;const o=new Map(r.map(a=>[a.id,a.label])),[i,...l]=t;return[i.map(a=>o.get(String(a))??a),...l]}const Wo=({data:e,path:r,label:t,schema:o,visible:i=!0})=>{const[l,a]=m.useState(null),c=X.useJsonForms();if(i===!1)return null;const u=(o==null?void 0:o["x-spreadsheet-export"])??{},d=u.columns,f=u.sheetName??Bo,h=u.fileType??Uo,p=u.fileName??`export.${h}`,x=_o(d);if(x)return n.jsxs(s.Box,{mb:"4",children:[n.jsx(s.Text,{as:"label",size:"2",weight:"bold",children:t}),n.jsxs(s.Text,{size:"2",color:"red",style:{display:"block"},children:["Invalid x-spreadsheet-export config: ",x]})]});const j=Array.isArray(e)&&e.length>0,b=async()=>{var D,R;if(j){a(null);try{const $=await import("@e965/xlsx"),C=Vo(e,d),A=$.utils.aoa_to_sheet(C),S=$.utils.book_new();$.utils.book_append_sheet(S,A,f);const E=r.split(".").slice(0,-1).join("."),_=E?v.Resolve.data((D=c.core)==null?void 0:D.data,E):(R=c.core)==null?void 0:R.data;$.writeFile(S,nt(p,_,`export.${h}`),{bookType:h})}catch($){a($ instanceof Error?$.message:"Failed to build the workbook.")}}};return n.jsxs(s.Box,{mb:"4",children:[n.jsx(s.Text,{as:"label",size:"2",weight:"bold",style:{display:"block",marginBottom:"var(--space-2)"},children:t}),n.jsxs(s.Button,{type:"button",variant:"soft",disabled:!j,onClick:()=>void b(),children:[n.jsx(se.DownloadIcon,{})," Download Spreadsheet"]}),l&&n.jsx(s.Text,{size:"2",color:"red",style:{display:"block",marginTop:"var(--space-2)"},children:l})]})},Or=X.withJsonFormsControlProps(Wo),Dr=v.rankWith(10,v.and(v.schemaMatches(e=>{const r=e["x-spreadsheet-export"];return e.type==="array"&&typeof r=="object"&&r!==null}),v.not(v.optionIs("editable",!0))));class Fe extends Error{}const kt=5e6,Ho=1024,qo=/^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["']/i,Xo={ignoreAttributes:!1,attributeNamePrefix:"@_",textNodeName:"#text",parseTagValue:!0,parseAttributeValue:!0,numberParseOptions:{hex:!1,leadingZeros:!1,eNotation:!0},trimValues:!0,cdataPropName:!1,commentPropName:!1,processEntities:!0,htmlEntities:!0,ignoreDeclaration:!0,ignorePiTags:!0,alwaysCreateTextNode:!1,preserveOrder:!1,removeNSPrefix:!1,maxNestedTags:100,strictReservedNames:!0};function Jo(e){const r=new Set(e);return r.size===0?()=>!1:(t,o)=>r.has(typeof o=="string"?o:o.toString())||r.has(t)}function Ko(e){const r=e instanceof Error?e.message:"";return r.startsWith("[SECURITY] Invalid name:")?"This document uses a reserved JavaScript name (__proto__, constructor or prototype) as an element or attribute name, which cannot be represented safely.":r==="External entities are not supported"||r==="Parameter entities are not supported"?`${r}. Please remove the DOCTYPE entity declarations and try again.`:r.startsWith("Maximum nested tags exceeded")?"This document is nested too deeply to parse.":r.startsWith("Entity count")||r.includes("exceeds maximum allowed")?"This document declares too many or too large entity definitions to expand safely.":"This doesn't look like a valid XML document. Please check the file and try again."}async function Yo(e,r={}){var d;if(typeof e!="string")throw new Fe("This file could not be read as text.");const t=e.charCodeAt(0)===65279?e.slice(1):e;if(t.trim()==="")throw new Fe("This file is empty.");if(t.length>kt)throw new Fe(`This document is too large to parse (over ${kt/1e6} million characters).`);const o=(d=qo.exec(t.slice(0,Ho)))==null?void 0:d[1];if(o&&!/^utf-?8$/i.test(o))throw new Fe(`This document declares the unsupported encoding "${o}". Only UTF-8 is supported.`);const{XMLParser:i,XMLValidator:l}=await import("fast-xml-parser"),a=l.validate(t,{allowBooleanAttributes:!1});if(a!==!0){const{msg:f,line:h,col:p}=a.err;throw new Fe(`Invalid XML at line ${h}, column ${p}: ${f}`)}const c=new i({...Xo,removeNSPrefix:r.removeNamespaces===!0,isArray:Jo(r.arrayPaths??[])});let u;try{u=c.parse(t)}catch(f){throw new Fe(Ko(f))}if(u==null||typeof u!="object"||Array.isArray(u))throw new Fe("This document has no root element.");return u}function Nr(e,r,t){const{path:o,default:i}=typeof t=="string"?{path:t,default:void 0}:t,l=v.Resolve.data(e,r?`${r}.${o}`:o);return l??i}function Go(e,r,t){const o={};for(const[i,l]of Object.entries(t)){const a=Nr(e,r,l);if(a===void 0)return;o[i]=a}return o}async function Zo(e,r){try{return{status:"ok",value:await Sr(e,r)}}catch(t){return{status:"error",error:ot(t)}}}function Lr(e,r){return e==null?"":typeof e=="number"?e.toFixed(Qo(r)):e instanceof Date?e.toLocaleDateString():String(e)}function Qo(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.trunc(e))):0}const ke={found:!1},be=e=>({found:!0,value:e});function It(e){return e==null||e===""?ke:Array.isArray(e)||e instanceof Date?be(e):typeof e=="object"?ke:typeof e=="string"||typeof e=="number"||typeof e=="boolean"?be(e):ke}const es=new Set(["true","1","yes","y"]),ts=new Set(["false","0","no","n"]),rs=/^(\d{4}-\d{2}-\d{2})(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})?)?$/;async function ns(e,r,t){switch(r.as){case void 0:return be(e);case"string":return be(e instanceof Date?e.toISOString():String(e));case"number":{const o=e instanceof Date?e.getTime():Number(e);return Number.isFinite(o)?be(r.decimals===void 0?o:Lr(o,r.decimals)):ke}case"boolean":{const o=String(e).trim().toLowerCase();return es.has(o)?be(!0):ts.has(o)?be(!1):ke}case"date":{const{default:o}=await import("dayjs"),{default:i}=await Promise.resolve().then(()=>require("./customParseFormat-CLvZwox5.cjs")).then(c=>c.customParseFormat);if(o.extend(i),t==="export"){const c=typeof e=="string"?rs.exec(e):null,u=e instanceof Date?o(e):c?o(c[1],"YYYY-MM-DD",!0):null;return u!=null&&u.isValid()?be(u.format(r.format??"YYYY-MM-DD")):ke}const l=e instanceof Date?e.toISOString():String(e),a=r.format?o(l,r.format,!0):o(l);return a.isValid()?be(a.format("YYYY-MM-DD")):ke}}}async function os(e,r){if(r.formula!==void 0){const t={};for(const[o,i]of Object.entries(r.inputs??{})){const l=It(v.Resolve.data(e,i));if(!l.found||Array.isArray(l.value))return ke;t[o]=l.value}try{return be(await Sr(t,r.formula))}catch(o){throw new Error(`writeTo "${r.to}": ${ot(o)}`)}}if(r.from===void 0)throw new Error(`writeTo "${r.to}" needs either "from" or "formula".`);return It(v.Resolve.data(e,r.from))}const _e="@_",Mr="#text",Ve=e=>e.split(".").filter(Boolean),zr=e=>e.startsWith(_e)||e===Mr;function Pr(e,r){if(typeof e.to!="string"||Ve(e.to).length===0)return'"to" must be a non-empty path.';if(e.format!==void 0&&e.as!=="date")return'"format" needs "as": "date".';if(e.decimals!==void 0){if(r==="import")return'"decimals" only applies on export — on import it would put text in a number field.';if(e.as!=="number")return'"decimals" needs "as": "number".';const{decimals:t}=e;if(!Number.isInteger(t)||t<0||t>100)return'"decimals" must be a whole number from 0 to 100.'}if(r==="export"){const t=Ve(e.to);for(const[o,i]of t.entries()){if(i===_e)return'"@_" needs an attribute name after it, e.g. "@_id".';if(zr(i)&&o<t.length-1)return`"${i}" must be the last segment — it belongs to the element before it.`}}return null}function Ot(e,r,t){const o=t?` To give "${r}" both text and attributes, write its text to "${r}.${Mr}".`:"";return new Error(`writeTo "${e}": "${r}" is written both as a value and as the parent of other values.${o}`)}function $r(e){const r={},t=new Set([r]);for(const{to:o,value:i}of e){const l=Ve(o);if(l.length===0)continue;let a=r;for(const[d,f]of l.slice(0,-1).entries()){const h=a[f];if(h===void 0){const p={};t.add(p),a[f]=p,a=p}else if(t.has(h))a=h;else throw Ot(o,l.slice(0,d+1).join("."),l[d+1].startsWith(_e))}const c=l[l.length-1],u=a[c];if(t.has(u)){const d=Object.keys(u).some(f=>f.startsWith(_e));throw Ot(o,l.join("."),d)}a[c]=i}return r}const ss=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean";async function st(e,r,t){const o=[];for(const i of r){const l=Pr(i,t);if(l)throw new Error(`writeTo "${i.to}": ${l}`);const a=Ve(i.to),c=t==="export"&&zr(a[a.length-1]),u=h=>{if(!(c&&h==null)){if(c&&!ss(h)){const p=h instanceof Date?' Add "as": "date" to write a date.':"";throw new Error(`writeTo "${i.to}": an attribute or #text value must be text, a number or a boolean.${p}`)}o.push({to:i.to,value:h})}};let d=await os(e,i);const f=d.found&&Array.isArray(d.value);if(d.found&&f&&i.writeTo){const h=await Promise.all(d.value.map(async p=>$r(await st(p,i.writeTo,t))));u(h);continue}if(d.found&&!f&&i.writeTo)throw new Error(`writeTo "${i.to}": "writeTo" is set, but "from" did not resolve to a repeating element.`);if(d.found&&!f&&i.map){const h=d.value instanceof Date?d.value.toISOString():String(d.value);Object.prototype.hasOwnProperty.call(i.map,h)&&(d=be(i.map[h]))}if(d.found&&!f&&(d=await ns(d.value,i,t)),!d.found){if(i.default===void 0)continue;u(i.default);continue}u(d.value)}return o}const is=".xml,text/xml,application/xml",ls=5*1024*1024,as=({data:e,handleChange:r,path:t,label:o,required:i,schema:l,enabled:a,readonly:c,errors:u,visible:d=!0})=>{Se(d,t,r);const f=ve(t,i,d),h=!u||u.length===0,p=jr(a,c),x=(l==null?void 0:l["x-xml"])??{},j=x.accept??is,b=x.maxSize??ls,D=x.arrayPaths,R=x.removeNamespaces===!0,$=x.writeTo,C=x.writeBase??"root",A=x.persistDocument!==!1,S=X.useJsonForms(),E=e??null,[_,P]=m.useState(()=>E?"ready":"empty"),[L,N]=m.useState(null),[T,ee]=m.useState(!1),V=m.useRef(null),G=m.useRef(0),W=E!=null,le=$!==void 0&&$.length>0,xe=m.useCallback(async I=>{var Y;const te=++G.current;if(N(null),I.size>b){N(`File exceeds the ${Te(b)} limit.`);return}if(!j.split(",").map(g=>g.trim()).some(g=>g==="*"||g==="*/*"?!0:g.endsWith("/*")?I.type.startsWith(g.slice(0,-1)):g.startsWith(".")?I.name.toLowerCase().endsWith(g.toLowerCase()):I.type===g)){N(`Invalid type. Accepted: ${Ee(j)}`);return}P("parsing");let y;try{const g=await I.text();y=await Yo(g,{arrayPaths:D,removeNamespaces:R})}catch(g){if(te!==G.current)return;P("error"),N(g instanceof Fe?g.message:"This doesn't look like a valid XML document. Please check the file and try again.");return}let F=[];if($&&$.length>0)try{F=await st(y,$,"import")}catch(g){if(te!==G.current)return;P("error"),N(g instanceof Error?g.message:"This document could not be mapped onto the form.");return}if(te!==G.current)return;A&&r(t,y);const U=C==="parent"?t.split(".").slice(0,-1).join("."):"";for(const g of F)(Y=S.dispatch)==null||Y.call(S,v.update(U?`${U}.${g.to}`:g.to,()=>g.value));P("ready")},[j,b,D,R,$,C,A,t,r,S]);if(d===!1||!p&&!W)return null;const re=I=>{I.preventDefault(),I.stopPropagation(),p&&ee(I.type==="dragenter"||I.type==="dragover")},ae=I=>{var te;I.preventDefault(),I.stopPropagation(),ee(!1),p&&(te=I.dataTransfer.files)!=null&&te[0]&&xe(I.dataTransfer.files[0])},M=I=>{var te;(te=I.target.files)!=null&&te[0]&&(xe(I.target.files[0]),I.target.value="")},K=()=>{p&&(++G.current,N(null),P("empty"),r(t,void 0))};return n.jsxs(s.Box,{mb:"4",children:[n.jsxs(s.Flex,{align:"center",justify:"between",mb:"2",children:[n.jsxs(s.Flex,{align:"center",gap:"1",children:[n.jsxs(s.Text,{as:"label",size:"2",weight:"bold",children:[o,f&&n.jsx(s.Text,{color:"red",children:" *"})]}),!le&&W&&p&&n.jsxs(n.Fragment,{children:[n.jsx(s.Tooltip,{content:"Replace document",children:n.jsx(s.IconButton,{variant:"ghost",size:"1",onClick:()=>{var I;return(I=V.current)==null?void 0:I.click()},"aria-label":"Replace document",children:n.jsx(se.UploadIcon,{})})}),n.jsx(s.Tooltip,{content:"Remove document",children:n.jsx(s.IconButton,{variant:"ghost",size:"1",color:"gray",onClick:K,"aria-label":"Remove document",children:n.jsx(se.Cross2Icon,{})})})]})]}),n.jsxs(s.Flex,{align:"center",gap:"2",children:[n.jsxs(s.Text,{size:"1",color:"gray",children:[Te(b)," max · ",Ee(j)]}),le&&p&&n.jsxs(s.Button,{size:"1",variant:"soft",onClick:()=>{var I;return(I=V.current)==null?void 0:I.click()},disabled:_==="parsing",children:[_==="parsing"?n.jsx(s.Spinner,{size:"1"}):n.jsx(se.UploadIcon,{}),"Upload"]})]})]}),(le||W)&&L&&n.jsx(s.Text,{size:"2",color:"red",mb:"2",style:{display:"block"},children:L}),n.jsx("input",{ref:V,type:"file",style:{display:"none"},accept:j,onChange:M}),!le&&p&&!W&&n.jsx("div",{role:"button",tabIndex:0,onClick:()=>{var I;return(I=V.current)==null?void 0:I.click()},onKeyDown:I=>{var te;(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),(te=V.current)==null||te.click())},onDragEnter:re,onDragLeave:re,onDragOver:re,onDrop:ae,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",T?"border-blue-500 bg-blue-50":L?"border-red-300 bg-red-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"].join(" "),children:n.jsx(s.Flex,{direction:"column",align:"center",gap:"2",children:_==="parsing"?n.jsxs(n.Fragment,{children:[n.jsx(s.Spinner,{size:"3"}),n.jsx(s.Text,{size:"2",color:"gray",children:"Parsing document…"})]}):L?n.jsxs(n.Fragment,{children:[n.jsx(se.ExclamationTriangleIcon,{style:{width:32,height:32,color:"var(--red-9)"}}),n.jsx(s.Text,{size:"2",color:"red",weight:"medium",children:L}),n.jsx(s.Text,{size:"1",color:"gray",children:"Click to try again"})]}):n.jsxs(n.Fragment,{children:[n.jsx(se.UploadIcon,{style:{width:32,height:32,color:"var(--gray-8)"}}),n.jsx(s.Text,{size:"2",weight:"medium",children:"Click to upload or drag and drop"}),n.jsxs(s.Text,{size:"1",color:"gray",children:[Te(b)," max · ",Ee(j)]})]})})}),!h&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:we(u,o)})]})},Br=X.withJsonFormsControlProps(as),Ur=v.rankWith(10,v.schemaMatches(e=>{const r=e["x-xml"];return e.type==="object"&&typeof r=="object"&&r!==null})),cs="root",Dt="export.xml",us={format:!0,indentBy:" ",ignoreAttributes:!1,attributeNamePrefix:"@_",textNodeName:"#text",suppressBooleanAttributes:!1,processEntities:!0};function ds(e){if(e===null||typeof e!="object"||Array.isArray(e))return'declaration must be an object, e.g. { "standalone": "no" }, or {} for the defaults.';const{version:r,encoding:t,standalone:o,...i}=e,[l]=Object.keys(i);return l?`declaration has an unknown key "${l}" — only version, encoding and standalone.`:r!==void 0&&r!=="1.0"&&r!=="1.1"?'declaration.version must be "1.0" or "1.1".':t!==void 0&&t!=="UTF-8"?'declaration.encoding can only be "UTF-8" — the file is always written as UTF-8.':o!==void 0&&o!=="yes"&&o!=="no"?'declaration.standalone must be "yes" or "no".':null}function _r(e){for(const r of e){if(r===null||typeof r!="object"||Array.isArray(r))return"every writeTo entry must be an object.";const{to:t,writeTo:o}=r,i=Pr(r,"export");if(i)return`writeTo "${t}": ${i}`;if(o!==void 0){if(!Array.isArray(o))return`writeTo "${t}": its nested writeTo must be an array.`;const l=_r(o);if(l)return l}}return null}function fs({writeTo:e,declaration:r}){return e===void 0?"writeTo is required — see docs/xml-export-control.md.":Array.isArray(e)?e.length===0?"writeTo is declared but empty — declare at least one entry.":_r(e)??(r===void 0?null:ds(r)):"writeTo must be an array of { from | formula, to } entries."}function ps({version:e="1.0",standalone:r}){return{"@_version":e,"@_encoding":"UTF-8",...r&&{"@_standalone":r}}}function hs(e){return e==null?!0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}const ms=({path:e,label:r,schema:t,visible:o=!0})=>{var $,C;const i=(t==null?void 0:t["x-xml-export"])??{},l=i.rootElement??cs,a=i.fileName??Dt,c=i.writeTo,u=i.writeBase??"root",d=i.declaration,f=fs(i),h=X.useJsonForms(),p=u==="parent"?e.split(".").slice(0,-1).join("."):"",x=p?v.Resolve.data(($=h.core)==null?void 0:$.data,p):(C=h.core)==null?void 0:C.data,[j,b]=m.useState(null),D=hs(x),R=m.useCallback(async()=>{if(c){b(null);try{const A=$r(await st(x,c,"export")),{XMLBuilder:S}=await import("fast-xml-parser"),E={...d&&{"?xml":ps(d)},[l]:A},_=new S(us).build(E);Zn(_,nt(a,x,Dt),"application/xml")}catch(A){b(A instanceof Error?A.message:"This export could not be built.")}}},[c,x,d,l,a]);return o===!1?null:f?n.jsxs(s.Box,{mb:"4",children:[n.jsx(s.Text,{as:"label",size:"2",weight:"bold",children:r}),n.jsxs(s.Text,{size:"2",color:"red",style:{display:"block"},children:["Invalid x-xml-export config: ",f]})]}):n.jsxs(s.Box,{mb:"4",children:[n.jsx(s.Text,{as:"label",size:"2",weight:"bold",style:{display:"block",marginBottom:"var(--space-2)"},children:r}),n.jsxs(s.Button,{size:"1",variant:"soft",disabled:D,onClick:()=>void R(),children:[n.jsx(se.DownloadIcon,{}),"Download XML"]}),j&&n.jsx(s.Text,{size:"2",color:"red",style:{display:"block",marginTop:"var(--space-2)"},children:j})]})},Vr=X.withJsonFormsControlProps(ms),Wr=v.rankWith(10,v.schemaMatches(e=>{const r=e["x-xml-export"];return e.type==="object"&&typeof r=="object"&&r!==null})),xs="{value}",gs=2,ys={},bs=({data:e,handleChange:r,path:t,label:o,schema:i,visible:l=!0})=>{var E;Se(l,t,r);const a=i==null?void 0:i["x-computed"],c=(a==null?void 0:a.inputs)??ys,u=(a==null?void 0:a.formula)??"",d=(a==null?void 0:a.format)??xs,f=(a==null?void 0:a.decimals)??gs,h=X.useJsonForms(),p=t.split(".").slice(0,-1).join("."),x=Go((E=h.core)==null?void 0:E.data,p,c),j=x?JSON.stringify(x):null,b=h.readonly===!0,[D,R]=m.useState(()=>typeof e=="number"?"ok":"unavailable"),[$,C]=m.useState(()=>typeof e=="number"?e:null),[A,S]=m.useState(null);return m.useEffect(()=>{if(!l)return;let _=!1;const P=L=>{b||L!==e&&r(t,L)};if(x===void 0){R("unavailable"),S(null),C(null),P(void 0);return}return R(L=>L==="ok"?L:"loading"),Zo(x,u).then(L=>{if(_)return;const N=L.status==="ok"&&typeof L.value=="number"&&Number.isFinite(L.value)?L.value:null;if(N===null){R("error"),S(L.status==="error"?L.error??"Unable to compute value.":"Computed value must be a number."),C(null),P(void 0);return}R("ok"),S(null),C(N),P(N)}),()=>{_=!0}},[j,u,l,b]),l===!1?null:n.jsx(s.Box,{mb:"4",children:n.jsxs(s.Flex,{direction:"column",gap:"1",children:[n.jsx(s.Text,{as:"label",size:"2",weight:"bold",children:o}),D==="unavailable"?n.jsx(s.Text,{size:"2",color:"gray",children:"Not yet available."}):D==="loading"?n.jsxs(s.Flex,{align:"center",gap:"2",children:[n.jsx(s.Spinner,{size:"1"}),n.jsx(s.Text,{size:"2",color:"gray",children:"Computing…"})]}):D==="error"?n.jsx(s.Text,{size:"2",color:"red",children:A}):n.jsx(s.Text,{size:"2",children:We(d,{value:Lr($,f)})}),i.description&&n.jsx(s.Text,{size:"1",color:"gray",children:i.description})]})})},Hr=X.withJsonFormsControlProps(bs),qr=v.rankWith(5,v.schemaMatches(e=>{const r=e["x-computed"];return e.type==="number"&&typeof r=="object"&&r!==null})),Xr="seq",Nt=2,vs=e=>e==null||e==="",Jr=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,ws=e=>{const r=e==null?void 0:e["x-template"];if(typeof r!="object"||r===null)return;const{template:t,inputs:o}=r;if(!(typeof t!="string"||t===""))return{template:t,inputs:o}},it=e=>typeof e=="object"&&e.name===Xr&&e.arg!==void 0,js=e=>e.every((r,t)=>!it(r)||typeof e[t-1]!="object"&&typeof e[t+1]!="object"),Ts=e=>{const r=new Set;for(const t of tt(e))typeof t=="object"&&t.arg===void 0&&r.add(t.name);return[...r]},Es=e=>{const r=[];for(const[t,o]of Object.entries((e==null?void 0:e.properties)??{})){const i=ws(o);i&&r.push([t,i])}return r},Ss=(e,r,t)=>{var i;const o={};for(const l of Ts(t.template)){const a=Nr(e,r,((i=t.inputs)==null?void 0:i[l])??l);o[l]=typeof a=="string"||typeof a=="number"||typeof a=="boolean"?String(a):""}return o},Cs=e=>r=>{const t=r.trim()===""?Nt:Number(r);return`${e}`.padStart(Number.isInteger(t)&&t>=0?t:Nt,"0")},Rs=e=>{const r=o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");let t="";for(const o of tt(e))typeof o=="string"?t+=r(o):t+=it(o)?"(\\d+)":".*?";return new RegExp(`^${t}$`)},As=(e,r,t)=>{var l,a;const o=Rs(t.template);let i=0;for(const c of e){const u=(l=Jr(c))==null?void 0:l[r];if(typeof u!="string")continue;const d=Number((a=o.exec(u))==null?void 0:a[1]);Number.isFinite(d)&&d>i&&(i=d)}return i},Fs=(e,r,t,o,i,l)=>{const a=Es(e);if(a.length===0)return r;const c=Jr(r);if(!c)return r;const u={...c};for(const[d,f]of a){if(!vs(u[d]))continue;const h=tt(f.template),p={};if(h.some(it)){if(!js(h)){console.warn(`x-template: {seq(…)} needs literal text between it and other placeholders; not numbering "${f.template}"`);continue}const x=Math.max(l[d]??0,As(t,d,f))+1;l[d]=x,p[Xr]=Cs(x)}u[d]=We(f.template,Ss(o,i,f),p)}return u},ks=({path:e,items:r,itemsSchema:t,rootSchema:o,addItem:i,sequences:l})=>{const a=X.useJsonForms(),c=()=>{var d;const u=Fs(t,v.createDefaultValue(t,o),r,(d=a.core)==null?void 0:d.data,e.split(".").slice(0,-1).join("."),l.current);i&&i(e,u)()};return n.jsx(s.Box,{mt:"2",children:n.jsxs(s.Button,{type:"button",variant:"surface",onClick:c,children:[n.jsx(se.PlusIcon,{}),"Add Item"]})})},Is=({data:e,path:r,schema:t,uischema:o,enabled:i,visible:l,addItem:a,removeItems:c,rootSchema:u,arraySchema:d,required:f=!1,errors:h=""})=>{const p=m.useRef({}),x=ve(r,f,l),j=d?t:t.items,b=d||t;if(l===!1||!j||typeof j!="object"||Array.isArray(j))return null;const D=j,R=Array.isArray(e)?e:[],$=b.title||"Array Items",C=o.options??{},A=i&&C.addable!==!1,S=i&&C.removable!==!1,E=C.itemLabel||"Item",_=x||typeof b.minItems=="number"&&b.minItems>=1,P=!h,L=P?"":R.length===0&&C.errorMessage||we(h,$),N=T=>{if(c){const ee=c(r,[T]);ee&&ee()}};return n.jsx(s.Box,{mb:"6",children:n.jsxs(s.Flex,{direction:"column",gap:"4",children:[n.jsxs(s.Text,{as:"div",size:"4",weight:"bold",children:[$," ",_&&n.jsx(s.Text,{color:"red",children:"*"})]}),R.length===0&&n.jsx(s.Box,{py:"4",px:"4",style:{backgroundColor:"var(--gray-3)",borderRadius:"var(--radius-3)"},children:n.jsx(s.Text,{size:"2",color:"gray",children:"No items have been added yet."})}),!P&&n.jsx(s.Text,{color:"red",size:"1",children:L}),R.map((T,ee)=>{var G;const V=`${r}.${ee}`;return n.jsx(s.Card,{size:"3",variant:"surface",children:n.jsxs(s.Flex,{direction:"column",gap:"4",children:[n.jsxs(s.Flex,{justify:"between",align:"center",children:[n.jsxs(s.Text,{size:"3",weight:"bold",children:[E," ",ee+1]}),S&&n.jsxs(s.Button,{type:"button",color:"red",variant:"soft",onClick:()=>N(ee),title:"Remove item",children:[n.jsx(se.TrashIcon,{}),"Remove"]})]}),n.jsx(s.Box,{children:n.jsx(X.JsonFormsDispatch,{schema:D,uischema:((G=o.options)==null?void 0:G.detail)||(D.type==="object"||D.properties?{type:"VerticalLayout",elements:Object.keys(D.properties||{}).map(W=>({type:"Control",scope:`#/properties/${W}`}))}:{type:"Control",scope:"#"}),path:V,enabled:i,renderers:void 0,cells:void 0})})]})},V)}),A&&n.jsx(ks,{path:r,items:R,itemsSchema:D,rootSchema:u,addItem:a,sequences:p})]})})},Qe=X.withJsonFormsArrayControlProps(Is),Kr=v.rankWith(3,v.isObjectArrayControl),Yr=({uischema:e,visible:r})=>{const t=e;return r===!1?null:n.jsx(s.Box,{mb:"4",children:n.jsx(s.Heading,{size:"4",children:t.text})})},Gr=v.rankWith(1,v.uiTypeIs("Label")),Os=v.rankWith(3,v.isPrimitiveArrayControl),Ds=[{tester:qt,renderer:Rn},{tester:Jt,renderer:Fn},{tester:Yt,renderer:kn},{tester:Zt,renderer:In},{tester:nr,renderer:or},{tester:er,renderer:gt},{tester:tr,renderer:gt},{tester:ir,renderer:_n},{tester:dr,renderer:X.withJsonFormsLayoutProps(ur)},{tester:pr,renderer:X.withJsonFormsLayoutProps(fr)},{tester:mr,renderer:X.withJsonFormsLayoutProps(hr)},{tester:gr,renderer:X.withJsonFormsLayoutProps(xr)},{tester:wr,renderer:vr},{tester:Ir,renderer:kr},{tester:Dr,renderer:Or},{tester:Ur,renderer:Br},{tester:Wr,renderer:Vr},{tester:qr,renderer:Hr},{tester:Kr,renderer:Qe},{tester:Os,renderer:Qe},{tester:Gr,renderer:Yr}];exports.ArrayControl=Qe;exports.ArrayControlTester=Kr;exports.BooleanControl=Kt;exports.BooleanControlTester=Yt;exports.CategorizationLayoutRenderer=xr;exports.CategorizationLayoutTester=gr;exports.ComputedControl=Hr;exports.ComputedControlTester=qr;exports.DateControl=sr;exports.DateControlTester=ir;exports.FileControl=vr;exports.FileControlTester=wr;exports.FormStepsProvider=fn;exports.GroupLayoutRenderer=hr;exports.GroupLayoutTester=mr;exports.HorizontalLayoutRenderer=fr;exports.HorizontalLayoutTester=pr;exports.LabelRenderer=Yr;exports.LabelTester=Gr;exports.NumberControl=Xt;exports.NumberControlTester=Jt;exports.RadioControl=Gt;exports.RadioControlTester=Zt;exports.STEPPER_MESSAGES=Wt;exports.SearchSelectControl=or;exports.SearchSelectControlTester=nr;exports.SearchServiceProvider=dn;exports.SelectControl=Qt;exports.SelectControlTester=er;exports.SelectObjectControlTester=tr;exports.SpreadsheetControl=kr;exports.SpreadsheetControlTester=Ir;exports.SpreadsheetExportControl=Or;exports.SpreadsheetExportControlTester=Dr;exports.TextControl=Ht;exports.TextControlTester=qt;exports.UploadProvider=un;exports.VerticalLayoutRenderer=ur;exports.VerticalLayoutTester=dr;exports.XmlControl=Br;exports.XmlControlTester=Ur;exports.XmlExportControl=Vr;exports.XmlExportControlTester=Wr;exports.isStepperUiSchema=_t;exports.radixRenderers=Ds;exports.searchSelectTargetSchema=rt;exports.useSearchService=$t;exports.useUpload=zt;