@opennsw/jsonforms-renderers 0.16.0 → 0.17.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 hn=Object.create;var Je=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var gn=Object.getOwnPropertyNames;var yn=Object.getPrototypeOf,bn=Object.prototype.hasOwnProperty;var vn=(e,r,t)=>r in e?Je(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var jn=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of gn(r))!bn.call(e,i)&&i!==t&&Je(e,i,{get:()=>r[i],enumerable:!(o=xn(r,i))||o.enumerable});return e};var Pe=(e,r,t)=>(t=e!=null?hn(yn(e)):{},jn(r||!e||!e.__esModule?Je(t,"default",{value:e,enumerable:!0}):t,e));var gt=(e,r,t)=>vn(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),x=require("react"),b=require("@jsonforms/core"),Y=require("@jsonforms/react"),s=require("@radix-ui/themes"),ne=require("@radix-ui/react-icons"),Bt=require("dayjs"),Ut=x.createContext(null);function wn({children:e,onUpload:r,getDownloadUrl:t}){const o={onUpload:r,getDownloadUrl:t};return n.jsx(Ut.Provider,{value:o,children:e})}function _t(){return x.useContext(Ut)}const Wt=x.createContext(null);function Tn({children:e,services:r}){const t=x.useMemo(()=>r,[r]);return n.jsx(Wt.Provider,{value:t,children:e})}function Vt(e){const r=x.useContext(Wt);return!r||!e?null:r[e]??null}const Ht=x.createContext(null);function qt(){return x.useContext(Ht)}function Sn({children:e,...r}){return n.jsx(Ht.Provider,{value:r,children:e})}function Jt(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 En(e){return e.elements.filter(r=>r.type==="Category")}function We(e,r,t,o,i=""){if(t&&e.rule&&!b.isVisible(e,r,i,t,o))return[];if(e.type==="Control")return[e];const l=e.elements;return Array.isArray(l)?l.flatMap(a=>We(a,r,t,o,i)):[]}function rt(e,r=""){return b.composePaths(r,b.toDataPath(e.scope))}function Cn(e,r){return e===r||e.startsWith(`${r}.`)}function Rn(e,r,t=b.toDataPath(e.scope),o=b.defaultTranslator){const i=b.Resolve.schema(r,e.scope,r),l=b.createLabelDescriptionFrom(e,i).text;return o(b.getI18nKey(i,e,t,"label"),l)}function An(e,r,t,o="",i=b.defaultTranslator){const l=r.map(a=>b.getControlPath(a));return e.map(a=>({control:a,path:rt(a,o)})).filter(({path:a})=>l.some(c=>Cn(c,a))).map(({control:a,path:c})=>({path:c,label:Rn(a,t,c,i)}))}function Fn(e,r,t=""){const o=e.map(i=>Xt(r,rt(i,t))).find(i=>Array.isArray(i)&&i.length>0);return o?{kind:"items",count:o.length}:{kind:"fields",count:e.length}}function In(e,r,t=""){return e.some(o=>{const i=Xt(r,rt(o,t));return i!=null&&i!==""&&!(Array.isArray(i)&&i.length===0)})}function Xt(e,r){return r.split(".").reduce((t,o)=>{if(!(t==null||typeof t!="object"))return t[o]},e)}function nt(e,r,t,o){return(e??b.defaultTranslator)(r,t,o).replace(/\{(\w+)\}/g,(l,a)=>o&&a in o?String(o[a]):l)}const Kt={addItem:"Add Item",remove:"Remove",removeItem:"Remove {item}",openItem:"Open {item}",confirmTitle:"Remove {item}?",confirmDescription:"Its answers are removed too. This can't be undone.",keepItem:"Keep item",removeConfirmed:"Remove item",removed:"{item} removed.",removedTotals:"{item} removed. Now {totals}.",empty:"No items have been added yet.",countOne:"{count} item",countOther:"{count} items",needsAttention:"Needs attention",done:"Done",add:"Add",cancel:"Cancel",close:"Close"},Yt={moreActions:"More actions for {file}",remove:"Remove",confirmTitle:"Remove {file}?",confirmDescription:"The file is removed from this form.",keepFile:"Keep file",removeConfirmed:"Remove file",removed:"{file} removed.",uploaded:"Uploaded"},kn=(e,r,t)=>nt(e,`list.${r}`,Kt[r],t),Oe=(e,r,t)=>nt(e,`upload.${r}`,Yt[r],t),Gt={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 On(e,r,t){return nt(e,`stepper.${r}`,Gt[r],t)}const Re=(e,r,t,o=void 0)=>{x.useEffect(()=>{e===!1&&t(r,o)},[e,r,t,o])},yt=new WeakMap;function Dn(e){if(!e||typeof e!="object")return!1;const r=yt.get(e);if(r!==void 0)return r;const t=Be(e,e,new Set);return yt.set(e,t),t}function Nn(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 Be(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||Be(c,r,t))return!0}}if(typeof o.$ref=="string"){const i=Nn(r,o.$ref);if(i&&Be(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)&&Be(l,r,t))return!0}if(Array.isArray(o.items)){for(const i of o.items)if(Be(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(Be(a,r,t))return!0}}return!1}function Mn(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 Ln(e){const r=e.lastIndexOf(".");return r===-1?"":"/"+e.slice(0,r).split(".").join("/")}function zn(e){if(!e)return"";const r=e.lastIndexOf(".");return r===-1?e:e.slice(r+1)}function Pn(e,r){var t;return e.keyword!=="required"&&e.keyword!=="dependencies"||((t=e.params)==null?void 0:t.missingProperty)!==zn(r)?!1:(e.instancePath??"")===Ln(r)}function $n(e,r,t){if(!e||!t)return!1;const o=Mn(r,e);t(o);const i=t.errors;return i!=null&&i.length?i.some(l=>Pn(l,e)):!1}function Te(e,r=!1,t=!0){var c,u,d;const o=Y.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 x.useMemo(()=>t?r?!0:Dn(a)?$n(e,i,l):!1:!1,[t,r,e,i,l,a])}const Se=(e,r)=>{if(!e)return"";const t=r||"This field";return e.split(`
1
+ "use strict";var Tn=Object.create;var lt=Object.defineProperty;var Sn=Object.getOwnPropertyDescriptor;var En=Object.getOwnPropertyNames;var Cn=Object.getPrototypeOf,Rn=Object.prototype.hasOwnProperty;var An=(e,r,t)=>r in e?lt(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var Fn=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of En(r))!Rn.call(e,i)&&i!==t&&lt(e,i,{get:()=>r[i],enumerable:!(o=Sn(r,i))||o.enumerable});return e};var We=(e,r,t)=>(t=e!=null?Tn(Cn(e)):{},Fn(r||!e||!e.__esModule?lt(t,"default",{value:e,enumerable:!0}):t,e));var Rt=(e,r,t)=>An(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("react"),v=require("@jsonforms/core"),K=require("@jsonforms/react"),s=require("@radix-ui/themes"),re=require("@radix-ui/react-icons"),Gt=require("dayjs"),Zt=g.createContext(null);function In({children:e,onUpload:r,getDownloadUrl:t}){const o={onUpload:r,getDownloadUrl:t};return n.jsx(Zt.Provider,{value:o,children:e})}function Qt(){return g.useContext(Zt)}const er=g.createContext(null);function kn({children:e,services:r}){const t=g.useMemo(()=>r,[r]);return n.jsx(er.Provider,{value:t,children:e})}function tr(e){const r=g.useContext(er);return!r||!e?null:r[e]??null}const rr=g.createContext(null);function nr(){return g.useContext(rr)}function On({children:e,...r}){return n.jsx(rr.Provider,{value:r,children:e})}function or(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 Dn(e){return e.elements.filter(r=>r.type==="Category")}function Ye(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=>Ye(a,r,t,o,i)):[]}function ht(e,r=""){return v.composePaths(r,v.toDataPath(e.scope))}function at(e,r){return e===r||e.startsWith(`${r}.`)}function Nn(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 Ln(e,r,t,o="",i=v.defaultTranslator){const l=e.map(f=>f.map(m=>({control:m,path:ht(m,o)}))),a=e.map(()=>new Set),c=Mn(r,t),u=[];for(const{path:f}of c)l.forEach((m,p)=>m.forEach(({control:h,path:w})=>{at(f,w)&&(a[p].add(h),u.push(f))}));const d=c.filter(({path:f,missing:m})=>m&&!u.some(p=>at(p,f))).sort((f,m)=>m.path.split(".").length-f.path.split(".").length);for(const{path:f}of d){if(u.some(h=>at(h,f)))continue;const m=({path:h})=>h.startsWith(`${f}.`),p=l.findIndex(h=>h.some(m));p!==-1&&(a[p].add(l[p].find(m).control),u.push(f))}return l.map((f,m)=>f.filter(({control:p})=>a[m].has(p)).map(({control:p,path:h})=>({path:h,label:Nn(p,t,h,i)})))}function Mn(e,r){const t=new Map,o=(i,l)=>{if(t.get(i)===!0||(t.set(i,!0),l>16))return;const a=zn(r,i);for(const c of(a==null?void 0:a.required)??[])o(v.composePaths(i,c),l+1)};for(const i of e){const l=v.getControlPath(i);i.keyword==="required"&&l!==""?o(l,0):t.has(l)||t.set(l,!1)}return[...t].map(([i,l])=>({path:i,missing:l}))}function zn(e,r){const t=r.split(".").map(o=>/^\d+$/.test(o)?"items":`properties/${v.encode(o)}`).join("/");return v.Resolve.schema(e,`#/${t}`,e)}function $n(e,r,t=""){const o=e.map(i=>sr(r,ht(i,t))).find(i=>Array.isArray(i)&&i.length>0);return o?{kind:"items",count:o.length}:{kind:"fields",count:e.length}}function Pn(e,r,t=""){return e.some(o=>{const i=sr(r,ht(o,t));return i!=null&&i!==""&&!(Array.isArray(i)&&i.length===0)})}function sr(e,r){return r.split(".").reduce((t,o)=>{if(!(t==null||typeof t!="object"))return t[o]},e)}function ir(e,r){return e.replace(/\{(\w+)\}/g,(t,o)=>r&&o in r?String(r[o]):t)}function tt(e,r,t,o){const i=(e??v.defaultTranslator)(r,t,o);return ir(i,o)}const lr={addItem:"Add Item",remove:"Remove",removeItem:"Remove {item}",openItem:"Open {item}",confirmTitle:"Remove {item}?",confirmDescription:"Its answers are removed too. This can't be undone.",keepItem:"Keep item",removeConfirmed:"Remove item",removed:"{item} removed.",removedTotals:"{item} removed. Now {totals}.",empty:"No items have been added yet.",countOne:"{count} item",countOther:"{count} items",needsAttention:"Needs attention",done:"Done",add:"Add",cancel:"Cancel",close:"Close"},ar={moreActions:"More actions for {file}",remove:"Remove",confirmTitle:"Remove {file}?",confirmDescription:"The file is removed from this form.",keepFile:"Keep file",removeConfirmed:"Remove file",removed:"{file} removed.",uploaded:"Uploaded"},Bn=(e,r,t,o)=>{if(e&&o){const i=`${o}.list.${r}`,l=e(i,void 0,t);if(l&&l!==i)return ir(l,t)}return tt(e,`list.${r}`,lr[r],t)},Le=(e,r,t)=>tt(e,`upload.${r}`,ar[r],t),cr={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}",contentsLabel:"Sections",jumpTo:"Jump to section"};function ur(e,r,t){return tt(e,`stepper.${r}`,cr[r],t)}const Ie=(e,r,t,o=void 0)=>{g.useEffect(()=>{e===!1&&t(r,o)},[e,r,t,o])},At=new WeakMap;function Un(e){if(!e||typeof e!="object")return!1;const r=At.get(e);if(r!==void 0)return r;const t=He(e,e,new Set);return At.set(e,t),t}function _n(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 He(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||He(c,r,t))return!0}}if(typeof o.$ref=="string"){const i=_n(r,o.$ref);if(i&&He(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)&&He(l,r,t))return!0}if(Array.isArray(o.items)){for(const i of o.items)if(He(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(He(a,r,t))return!0}}return!1}function Wn(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 Vn(e){const r=e.lastIndexOf(".");return r===-1?"":"/"+e.slice(0,r).split(".").join("/")}function Hn(e){if(!e)return"";const r=e.lastIndexOf(".");return r===-1?e:e.slice(r+1)}function qn(e,r){var t;return e.keyword!=="required"&&e.keyword!=="dependencies"||((t=e.params)==null?void 0:t.missingProperty)!==Hn(r)?!1:(e.instancePath??"")===Vn(r)}function Jn(e,r,t){if(!e||!t)return!1;const o=Wn(r,e);t(o);const i=t.errors;return i!=null&&i.length?i.some(l=>qn(l,e)):!1}function Ee(e,r=!1,t=!0){var c,u,d;const o=K.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 g.useMemo(()=>t?r?!0:Un(a)?Jn(e,i,l):!1:!1,[t,r,e,i,l,a])}const Ce=(e,r)=>{if(!e)return"";const t=r||"This field";return e.split(`
2
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
- `)},Zt=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,uischema:a,schema:c,enabled:u,visible:d=!0})=>{var p;Re(d,t,r);const f=Te(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:y=>r(t,y.target.value===""?void 0:y.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:Se(l,o)}),c.description&&n.jsx(s.Text,{size:"1",color:"gray",children:c.description})]})})},Qt=b.rankWith(1,b.isStringControl),Bn=Y.withJsonFormsControlProps(Zt),Un=new Set(["-","+","e","E"]),er=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,uischema:a,schema:c,enabled:u,visible:d=!0})=>{var E;Re(d,t,r);const f=Te(t,i,d);if(d===!1)return null;const h=l.length===0,p=typeof c.exclusiveMinimum=="number"?c.exclusiveMinimum:void 0,y=typeof c.minimum=="number"?c.minimum:void 0,S=p??y,w=S!==void 0&&S>=0,H=typeof c.multipleOf=="number"?c.multipleOf:c.type==="integer"?1:void 0,R=T=>{if(T===""){r(t,void 0);return}const C=Number(T);isNaN(C)||r(t,C)},z=T=>{w&&Un.has(T.key)&&T.preventDefault()},k=T=>{if(!w)return;const C=T.clipboardData.getData("text");/[-+eE]/.test(C)&&T.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:T=>R(T.target.value),onKeyDown:z,onPaste:k,min:S,step:H,disabled:!u,placeholder:(E=a.options)==null?void 0:E.placeholder,color:h?void 0:"red",id:t}),!h&&n.jsx(s.Text,{color:"red",size:"1",children:Se(l,o)}),c.description&&n.jsx(s.Text,{size:"1",color:"gray",children:c.description})]})})},tr=b.rankWith(2,b.or(b.isNumberControl,b.isIntegerControl)),_n=Y.withJsonFormsControlProps(er),rr=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,schema:a,enabled:c,visible:u=!0})=>{Re(u,t,r);const d=Te(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:Se(l,o)}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",className:"block mt-1",children:a.description})]})},nr=b.rankWith(2,b.isBooleanControl),Wn=Y.withJsonFormsControlProps(rr),or=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,schema:a,enabled:c,visible:u=!0})=>{Re(u,t,r);const d=Te(t,i,u);if(u===!1)return null;const f=l.length===0;let h=[];a.enum?h=a.enum.map(y=>({value:y,label:String(y)})):a.oneOf&&(h=a.oneOf.map(y=>({value:y.const,label:y.title||String(y.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:y=>{const S=h.find(w=>String(w.value)===y);S&&r(t,S.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(y=>n.jsxs(s.Flex,{align:"center",gap:"2",style:{minWidth:"max-content"},children:[n.jsx(s.RadioGroup.Item,{value:String(y.value)}),n.jsx(s.Text,{size:"2",color:c?void 0:"gray",children:y.label})]},String(y.value)))})}),!f&&n.jsx(s.Text,{color:"red",size:"1",children:Se(l,o)}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",children:a.description})]})})},sr=(e,r,t)=>{var i;return b.or(b.isEnumControl,b.isOneOfControl)(e,r,t)&&((i=e==null?void 0:e.options)==null?void 0:i.format)==="radio"?3:-1},Vn=Y.withJsonFormsControlProps(or),ir=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,schema:a,uischema:c,enabled:u,visible:d=!0})=>{var ce,se,G,ue;Re(d,t,r);const f=Te(t,i,d),h=((ce=c.options)==null?void 0:ce.autocomplete)===!0,[p,y]=x.useState(!1),[S,w]=x.useState(""),[H,R]=x.useState(0),z=x.useRef(null);if(x.useEffect(()=>{if(!h||!p)return;const D=K=>{z.current&&!z.current.contains(K.target)&&y(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[h,p]),d===!1)return null;const k=a.type==="object",E=k?((se=a.properties)==null?void 0:se.value)??{}:a;let T=[];E.enum?T=E.enum.map(D=>({value:String(D),label:String(D),raw:D})):E.oneOf&&(T=E.oneOf.map(D=>{const K=D.const;return{value:String(K),label:D.title||String(K),raw:K}}));const C=k?typeof e=="string"||typeof e=="number"||typeof e=="boolean"?{value:e}:e??void 0:void 0,X=k?C==null?void 0:C.value:e,U=C==null?void 0:C.label,M=X!=null?String(X):"",P=U??((G=T.find(D=>D.value===M))==null?void 0:G.label)??"",I=((ue=c.options)==null?void 0:ue.placeholder)||"Select an option",oe=k&&M!==""&&!T.some(D=>D.value===M),q=l?Se(l,o):oe?`"${P||M}" is no longer an available option`:"",te=q==="",J=D=>{r(t,k?{value:D.raw,label:D.label}:D.value)};if(h){const D=p?T.filter(B=>B.label.toLowerCase().includes(S.toLowerCase())):T,K=Math.min(H,D.length-1),L=B=>{J(B),y(!1)},ee=B=>{B.stopPropagation(),r(t,void 0),w("")},Q=B=>{(B.key==="Enter"||B.key===" ")&&ee(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:z,style:{position:"relative"},children:[n.jsx(s.TextField.Root,{id:t,value:p?S:P,placeholder:I,disabled:!u,style:te?void 0:{outline:"2px solid var(--red-7)",outlineOffset:"-1px"},onChange:B=>{w(B.target.value),R(0),p||y(!0)},onFocus:()=>{u&&!p&&(w(""),R(0),y(!0))},onKeyDown:B=>{B.key==="Escape"?y(!1):B.key==="ArrowDown"?(B.preventDefault(),p?R(g=>Math.min(g+1,D.length-1)):(w(""),y(!0))):B.key==="ArrowUp"?(B.preventDefault(),p&&R(g=>Math.max(g-1,0))):B.key==="Enter"&&p&&D[K]&&(B.preventDefault(),L(D[K]))},children:n.jsx(s.TextField.Slot,{side:"right",children:n.jsxs(s.Flex,{align:"center",gap:"1",children:[M&&u&&n.jsx("span",{role:"button",tabIndex:0,onMouseDown:B=>B.preventDefault(),onClick:ee,onKeyDown:Q,style:{lineHeight:1,color:"var(--gray-9)",padding:"0 2px",cursor:"pointer"},"aria-label":"Clear selection",children:"×"}),n.jsx(ne.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:[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((B,g)=>n.jsx(s.Box,{px:"3",py:"2",onMouseDown:F=>F.preventDefault(),onClick:()=>L(B),onMouseEnter:()=>R(g),style:{cursor:"pointer",borderRadius:"var(--radius-2)",backgroundColor:g===K?"var(--accent-4)":B.value===M?"var(--accent-3)":void 0},children:n.jsx(s.Text,{size:"2",children:B.label})},B.value))]})})})]}),!te&&n.jsx(s.Text,{color:"red",size:"1",children:q}),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:M,onValueChange:D=>{const K=T.find(L=>L.value===D);K&&J(K)},disabled:!u,children:[n.jsx(s.Select.Trigger,{placeholder:I,color:te?void 0:"red",id:t,children:k&&U?U:void 0}),n.jsx(s.Select.Content,{children:T.map(D=>n.jsx(s.Select.Item,{value:D.value,children:D.label},D.value))})]}),!te&&n.jsx(s.Text,{color:"red",size:"1",children:q}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",children:a.description})]})})},lr=b.rankWith(2,b.or(b.isEnumControl,b.isOneOfControl)),ar=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)})),bt=Y.withJsonFormsControlProps(ir),cr=/\{([A-Za-z0-9_]+)(?:\(([^(){}]*)\))?\}/g,Hn={today:e=>Bt().format(e||"YYYY-MM-DD")},qn=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="bigint",vt=(e,r)=>Object.prototype.hasOwnProperty.call(e,r);function qe(e,r,t={}){const o={...Hn,...t};return e.replace(cr,(i,l,a)=>{let c;if(a===void 0){if(!vt(r,l))return i;c=r[l]}else{if(!vt(o,l))return i;try{c=o[l](a)}catch{return i}}return c==null?"":qn(c)?String(c):i})}function ot(e){const r=[];let t=0;for(const o of e.matchAll(cr))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 jt(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 st(e){if(jt(e))return e;if(e.type==="array"){const r=e.items;if(r&&!Array.isArray(r)&&jt(r))return r}}const ur=b.rankWith(4,b.schemaMatches(e=>{const r=st(e);if(!r)return!1;const t=r.type;return t==="string"||t==="object"}));function Jn(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 Xn(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 Kn(e,r,t){const o={};for(const[i,l]of Object.entries(e))o[i]=Jn(b.Resolve.data(r,t?`${t}.${l}`:l));return o}function wt(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 Xe(e,r){return r?{...e,name:qe(r,e)}:e}const Yn={"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}},Gn=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,enabled:a,visible:c=!0,schema:u,uischema:d})=>{var ft,pt,mt,ht;const f=u.type==="array",h=st(u)??u,p=h["x-search"]??{service:"",displayTemplate:""},y=p.service??"",S=p.mode??"large-paginated-list",w=Yn[S],H=(w==null?void 0:w.fetchOnOpen)??!1,R=typeof p.displayTemplate=="string"?p.displayTemplate:"",z=Y.useJsonForms(),k=t.split(".").slice(0,-1).join("."),{parentValues:E,parentValuesKey:T,missingParent:C}=x.useMemo(()=>{var ge;const j=Xn(p.dependsOn);if(!j)return{parentValues:void 0,parentValuesKey:"",missingParent:!1};const _=Kn(j,(ge=z.core)==null?void 0:ge.data,k),le=Object.keys(_).length===0||Object.values(_).some(Fe=>!Fe);return{parentValues:_,parentValuesKey:JSON.stringify(_),missingParent:le}},[p.dependsOn,(ft=z.core)==null?void 0:ft.data,k]),X=x.useMemo(()=>E?{...p.params,...E}:p.params,[E,T,p.params]),U=Vt(y),M=h.type==="object",P=typeof u.maxItems=="number"?u.maxItems:void 0,I=x.useMemo(()=>{if(f)return Array.isArray(e)?e.map(wt).filter(_=>!!_):[];const j=wt(M||typeof e=="string"?e:void 0);return j?[j]:[]},[e,f,M]),oe=f||(pt=I[0])==null?void 0:pt.value,q=f||(mt=I[0])==null?void 0:mt.label,te=x.useMemo(()=>new Set(I.map(j=>j.value)),[I]),J=I.length>0,ce=x.useRef({}),[se,G]=x.useState(0),ue=x.useMemo(()=>{const j={};for(const _ of I)j[_.value]=_.label||ce.current[_.value]||_.value;return j},[I,se]),D=f&&P!==void 0&&I.length>=P,K=y?U?w?R?null:"x-search.displayTemplate is required.":`Invalid x-search.mode "${S}". Expected "small-list", "large-searchable-list", or "large-paginated-list".`:`Search service "${y}" is not registered.`:"Search not configured.",L=a!==!1,ee=!l||l.length===0,[Q,B]=x.useState(!1),[g,F]=x.useState(""),[W,Z]=x.useState([]),[re,me]=x.useState(!1),[ve,Ae]=x.useState(!1),[Ie,ye]=x.useState(!1),[m,v]=x.useState(null),[V,A]=x.useState(void 0),N=x.useRef(void 0),ie=x.useRef(null),pe=x.useRef(null),O=x.useRef(null),$=x.useRef(void 0),de=x.useRef(void 0),je=x.useCallback(j=>{if(f){r(t,j.length>0?j.map(le=>M?le:le.value):void 0);return}const _=j[0];if(!_){r(t,void 0);return}r(t,M?{value:_.value,label:_.label}:_.value)},[r,t,f,M]);x.useEffect(()=>{if(!E)return;const j=de.current;if(de.current=E,!j||!J)return;Object.keys(E).some(le=>j[le]!==void 0&&j[le]!==E[le])&&r(t,void 0)},[T,J,r,t]),x.useEffect(()=>{var ge,Fe;if(f){if(K||M)return;const ke=I.filter(ze=>!ze.label&&!ce.current[ze.value]);if(ke.length===0||!(U!=null&&U.resolve))return;let Le=!1;return Promise.all(ke.map(async ze=>{try{const xt=await U.resolve(ze.value,X);if(Le||!xt)return;ce.current[ze.value]=Xe(xt,R).name}catch{}})).then(()=>{Le||G(ze=>ze+1)}),()=>{Le=!0}}if(K){A(void 0),$.current=void 0;return}if(!oe){A(void 0),$.current=void 0;return}if(((ge=$.current)==null?void 0:ge.value)===oe&&((Fe=$.current)==null?void 0:Fe.label)===q)return;if(M&&q){A({id:oe,name:q}),$.current={value:oe,label:q};return}if(A({id:oe,name:q??oe}),!(U!=null&&U.resolve)){$.current={value:oe,label:q};return}let j=!1;const _=oe,le=q;return U.resolve(_,X).then(ke=>{j||(ke&&A(Xe(ke,R)),$.current={value:_,label:le})}).catch(()=>{j||($.current={value:_,label:le})}),()=>{j=!0}},[K,oe,q,M,f,I,U,X,R]);const we=x.useCallback(async(j,_=!1)=>{var ge;if(K)return;if(!U){v("Search service not configured.");return}(ge=pe.current)==null||ge.abort();const le=new AbortController;pe.current=le,_?ye(!0):(Ae(!0),ye(!1),v(null));try{const Fe=await U.search({query:j,cursor:_?N.current:void 0,signal:le.signal,params:X});if(le.signal.aborted)return;const ke=(Fe.options??[]).map(Le=>Xe(Le,R));Z(_?Le=>[...Le,...ke]:ke),N.current=Fe.nextCursor,me(((w==null?void 0:w.paginated)??!1)&&Fe.nextCursor!=null)}catch{if(le.signal.aborted)return;v("Failed to load results. Please try again.")}finally{le.signal.aborted||(_?ye(!1):Ae(!1))}},[K,U,w==null?void 0:w.paginated,X,R]);x.useEffect(()=>{if(!Q)return;const j=_=>{O.current&&!O.current.contains(_.target)&&B(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[Q]),x.useEffect(()=>{var j;Q||((j=pe.current)==null||j.abort(),F(""),Z([]),me(!1),v(null),Ae(!1),ye(!1),N.current=void 0)},[Q]),x.useEffect(()=>{if(!Q)return;if(C){Z([]),me(!1),v(null),N.current=void 0;return}if(!g&&!H){Z([]),me(!1),v(null),N.current=void 0;return}ie.current&&clearTimeout(ie.current);const j=g?300:0;return ie.current=setTimeout(()=>{Z([]),me(!1),N.current=void 0,we(g)},j),()=>{ie.current&&clearTimeout(ie.current)}},[g,Q,H,we,C,T]),Re(c,t,r);const Me=Te(t,i,c);if(c===!1)return null;const Ue=()=>{F(""),Z([]),me(!1),v(null),N.current=void 0,B(!0)},dn=j=>{if(f){const _=te.has(j.id);if(!_&&D)return;const le=_?I.filter(ge=>ge.value!==j.id):[...I,{value:j.id,label:j.name}];_||(ce.current[j.id]=j.name,G(ge=>ge+1)),je(le),F("");return}je([{value:j.id,label:j.name}]),A(j),$.current={value:j.id,label:M?j.name:void 0},B(!1)},ut=j=>{j.stopPropagation(),r(t,void 0),A(void 0)},dt=(j,_)=>{j.stopPropagation(),je(I.filter(le=>le.value!==_))},fn=j=>{(j.key==="Enter"||j.key===" ")&&ut(j)},pn=((ht=d==null?void 0:d.options)==null?void 0:ht.placeholder)??"Select an option",mn=f?"":(V==null?void 0:V.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," ",Me&&n.jsx(s.Text,{color:"red",children:"*"})]}),f&&I.length>0&&n.jsx(s.Flex,{gap:"1",wrap:"wrap",mb:"1",children:I.map(j=>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:ue[j.value]??j.value}),L&&n.jsx("span",{role:"button",tabIndex:0,"aria-label":`Remove ${ue[j.value]??j.value}`,onMouseDown:_=>_.preventDefault(),onClick:_=>dt(_,j.value),onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&dt(_,j.value)},style:{lineHeight:1,color:"var(--gray-11)",cursor:"pointer"},children:"×"})]},j.value))}),n.jsxs("div",{ref:O,style:{position:"relative"},children:[n.jsx(s.TextField.Root,{id:t,value:Q?g:mn,placeholder:Q&&(w!=null&&w.searchable)?"Search...":pn,disabled:!L,readOnly:Q&&!(w!=null&&w.searchable)||f&&!Q,style:ee?void 0:{outline:"2px solid var(--red-7)",outlineOffset:"-1px"},onChange:j=>{w!=null&&w.searchable&&(F(j.target.value),Q||Ue())},onFocus:()=>{L&&!Q&&Ue()},onKeyDown:j=>{j.key==="Escape"&&B(!1)},children:n.jsx(s.TextField.Slot,{side:"right",children:n.jsxs(s.Flex,{align:"center",gap:"1",children:[J&&L&&n.jsx("span",{role:"button",tabIndex:0,onMouseDown:j=>j.preventDefault(),onClick:ut,onKeyDown:fn,style:{lineHeight:1,color:"var(--gray-9)",padding:"0 2px",cursor:"pointer"},"aria-label":"Clear selection",children:"×"}),n.jsx(ne.ChevronDownIcon,{style:{transform:Q?"rotate(180deg)":void 0,transition:"transform 150ms"}})]})})}),Q&&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:[ve&&n.jsx(s.Flex,{justify:"center",p:"4",children:n.jsx(s.Spinner,{})}),!ve&&m&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Text,{size:"2",color:"red",children:m})}),!ve&&!m&&W.length===0&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Text,{size:"2",color:"gray",children:C?"Select the related field first.":g||H?"No results found.":"Type to search…"})}),W.map(j=>{const _=te.has(j.id),le=D&&!_;return n.jsx(s.Box,{px:"3",py:"2",onMouseDown:ge=>ge.preventDefault(),onClick:()=>{le||dn(j)},"aria-disabled":le||void 0,style:{cursor:le?"not-allowed":"pointer",opacity:le?.5:1,borderRadius:"var(--radius-2)",backgroundColor:_?"var(--accent-3)":void 0},className:le?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:j.name}),f&&_&&n.jsx(s.Text,{size:"1",color:"gray",children:"✓"})]})},j.id)}),(w==null?void 0:w.paginated)&&re&&!Ie&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Button,{variant:"ghost",size:"1",style:{width:"100%"},onMouseDown:j=>j.preventDefault(),onClick:()=>void we(g,!0),children:"Load more"})}),Ie&&n.jsx(s.Flex,{justify:"center",p:"2",children:n.jsx(s.Spinner,{})})]})})})]}),!ee&&n.jsx(s.Text,{color:"red",size:"1",children:Se(l,o)}),u.description&&n.jsx(s.Text,{size:"1",color:"gray",children:u.description})]})})},dr=Y.withJsonFormsControlProps(Gn),Zn=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},Qn=(e,r)=>Bt(`${e}T${r}`).format(),eo=({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:Se(o,r)}),i&&n.jsx(s.Text,{size:"1",color:"gray",children:i})]})})},fr=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,schema:a,uischema:c,enabled:u,visible:d=!0})=>{var T;x.useEffect(()=>{d===!1&&r(t,void 0)},[d,t,r]);const f=Te(t,i,d);if(d===!1)return null;const h=l.length===0,p=typeof e=="string"?e:"",y=((T=c==null?void 0:c.options)==null?void 0:T.showSeconds)===!0,S=y?1:60,w=C=>n.jsx(eo,{path:t,label:o,required:f,errors:l,description:a.description,children:C});if(a.format==="time")return w(n.jsx(s.TextField.Root,{type:"time",step:S,value:Tt(p,y),onChange:C=>r(t,Zn(C.target.value)),disabled:!u,color:h?void 0:"red",id:t}));const H=a.format==="date-time",[R="",z=""]=p.split("T"),k=Tt(z,y),E=(C,X)=>{if(!C){r(t,void 0);return}r(t,H?Qn(C,X||"00:00"):C)};return w(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:C=>E(C.target.value,k),id:t,style:{flex:1}}),H&&n.jsx(s.TextField.Root,{type:"time",step:S,value:k,disabled:!u||!R,color:h?void 0:"red",onChange:C=>E(R,C.target.value),style:{flex:1}})]}))},pr=b.rankWith(2,b.or(b.isDateControl,b.isDateTimeControl,b.isTimeControl)),to=Y.withJsonFormsControlProps(fr),Ke="var(--form-steps-offset, 16px)",ro=e=>e.enabled?n.jsx(no,{...e}):n.jsx(io,{...e}),no=({uischema:e,schema:r,path:t,renderers:o,cells:i,enabled:l})=>{var B;const a=Y.useJsonForms(),c=a.core,u=qt(),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,y=(B=a.i18n)==null?void 0:B.translate,S=(g,F)=>On(y,g,F),w=mr(e,t),H=w.length,R=H,z=x.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]),k=x.useMemo(()=>w.map(g=>An(We(g,f,h,p,t),z,d,t,y)),[e,t,f,h,p,z,d,y]),[E,T]=x.useState(0),[C,X]=x.useState(()=>{const g=(W,Z)=>k[Z].length===0&&In(We(W,f,h,p,t),f,t),F=w.findIndex((W,Z)=>!g(W,Z));return F===-1?R:F}),[U,M]=x.useState(new Set),P=Math.min(E,R),I=P===R,oe=x.useEffectEvent(()=>{var g;return(g=u==null?void 0:u.onStepChange)==null?void 0:g.call(u,{step:P,count:H,last:P===R})});x.useEffect(()=>{oe()},[P,H,R]);const q=x.useRef(null),te=x.useRef(null),J=x.useRef(P);if(x.useEffect(()=>{var W,Z;if(J.current===P)return;J.current=P;const g=q.current,F=g&&parseFloat(getComputedStyle(g).scrollMarginTop)||0;g&&g.getBoundingClientRect().top<F&&((W=g.scrollIntoView)==null||W.call(g,{block:"start",behavior:"smooth"})),(Z=te.current)==null||Z.focus({preventScroll:!0})},[P]),!H)return null;const ce=g=>{g>C&&g!==P||T(g)},se=()=>{var F,W;if((F=k[P])!=null&&F.length){M(Z=>new Set(Z).add(P)),(W=u==null?void 0:u.onInvalidStep)==null||W.call(u);return}const g=Math.min(P+1,R);T(g),X(Z=>Math.max(Z,g))},G=[...w.map(g=>xr(g,y)),S("review")],ue=G.length,D=g=>{var F;return g===P?"current":g<H&&((F=k[g])!=null&&F.length)&&(U.has(g)||g<C)?"error":g<C||g<H&&g<P?"done":"todo"},K=(g,F)=>{var W;return F==="error"||F==="current"&&U.has(g)?((W=k[g])==null?void 0:W.length)??0:0},L=(g,F)=>{if(g===R)return S("noteReview");if(K(g,F)>0)return S("noteToFix",{count:K(g,F)});if(F==="done")return S("noteDone");const W=Fn(We(w[g],f,h,p,t),f,t),Z=W.count===1;return W.kind==="items"?S(Z?"noteItem":"noteItems",{count:W.count}):S(Z?"noteField":"noteFields",{count:W.count})},ee=I?void 0:lo(w[P],y),Q=k.map((g,F)=>({index:F,p:g})).filter(({p:g})=>g.length).map(({index:g,p:F})=>({key:String(g),label:`${G[g]}: ${F.map(W=>W.label).join(", ")}`,onClick:()=>{M(W=>new Set(W).add(g)),ce(g)}}));return n.jsxs(s.Flex,{ref:q,gap:"5",align:"start",style:{scrollMarginTop:Ke},children:[n.jsx(s.Box,{asChild:!0,display:{initial:"none",sm:"block"},p:"4",style:{...Ge,flex:"0 0 248px",position:"sticky",top:Ke,maxHeight:`calc(100vh - 2 * ${Ke})`,overflowY:"auto"},children:n.jsx("nav",{"aria-label":S("navLabel"),children:n.jsx("ol",{style:{listStyle:"none",margin:0,padding:0},children:G.map((g,F)=>{const W=D(F);return n.jsxs("li",{style:{position:"relative"},children:[F<ue-1&&n.jsx("span",{"aria-hidden":!0,style:{position:"absolute",left:21,top:40,bottom:-4,width:2,borderRadius:1,background:W==="done"?"var(--green-9)":"var(--gray-a5)"}}),n.jsx(oo,{index:F,label:g,note:L(F,W),errorCount:K(F,W),status:W,disabled:F>C,onSelect:()=>ce(F)})]},`${t}-step-${F}`)})})})}),n.jsxs(s.Box,{style:{...Ge,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:S("stepOf",{step:P+1,total:ue})}),n.jsx(s.Heading,{ref:te,tabIndex:-1,size:"5",as:"h2",mt:"1",style:{outline:"none"},children:G[P]}),ee&&n.jsx(s.Text,{as:"p",size:"2",color:"gray",mt:"1",children:ee}),n.jsx(s.Progress,{value:(P+1)/ue*100,size:"1",mt:"4","aria-label":S("progressLabel")})]}),n.jsxs(s.Box,{px:{initial:"4",sm:"6"},pb:"5","data-form-review":I?"":void 0,children:[I&&(Q.length?n.jsx(St,{title:S("incompleteSteps"),items:Q}):n.jsx(s.Text,{as:"p",size:"2",color:"gray",mb:"5",children:S("reviewHint")})),w.map((g,F)=>{const W=I||F===P;return n.jsxs(s.Box,{hidden:!W,mb:I?"6":void 0,children:[I&&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:G[F]}),n.jsx(s.Button,{type:"button",variant:"ghost",onClick:()=>ce(F),"aria-label":S("editStep",{step:G[F]}),children:S("edit")})]}),!I&&U.has(F)&&k[F].length>0&&n.jsx(St,{title:S("missingFields"),items:k[F].map(Z=>({key:Z.path,label:Z.label,onClick:()=>so(Z.path)}))}),n.jsx(hr,{category:g,schema:r,path:t,renderers:o,cells:i,enabled:l&&!I})]},`${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:[P>0&&n.jsxs(s.Button,{type:"button",variant:"ghost",color:"gray",size:"3",onClick:()=>T(P-1),children:[n.jsx(ne.ChevronLeftIcon,{}),S("back")]}),n.jsx(s.Box,{flexGrow:"1"}),u==null?void 0:u.actions,P<R&&n.jsxs(s.Button,{type:"button",size:"3",onClick:se,children:[S("continue"),n.jsx(ne.ChevronRightIcon,{})]})]})]})]})},Ge={background:"var(--color-panel-solid)",border:"1px solid var(--gray-a4)",borderRadius:"var(--radius-5)",boxShadow:"var(--shadow-2)"};function oo({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(ne.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 so(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 St({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(ne.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 io=({uischema:e,schema:r,path:t,renderers:o,cells:i})=>{var f;const l=(f=Y.useJsonForms().i18n)==null?void 0:f.translate,a=qt(),c=mr(e,t),u=c.length,d=x.useEffectEvent(()=>{var h;return(h=a==null?void 0:a.onStepChange)==null?void 0:h.call(a,{step:u,count:u,last:!0})});return x.useEffect(()=>{d()},[u]),n.jsx(s.Flex,{direction:"column",gap:"6",p:{initial:"4",sm:"6"},style:Ge,"data-form-review":"",children:c.map((h,p)=>n.jsxs(s.Box,{children:[n.jsx(s.Heading,{size:"3",as:"h3",mb:"3",children:xr(h,l)}),n.jsx(hr,{category:h,schema:r,path:t,renderers:o,cells:i,enabled:!1})]},`${t}-${p}`))})};function mr(e,r){var a,c;const t=Y.useJsonForms(),o=(a=t.core)==null?void 0:a.ajv,i=(c=t.core)==null?void 0:c.data,l=t.config;return En(e).filter(u=>!u.rule||!o||b.isVisible(u,i,r,o,l))}function hr({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(Y.JsonFormsDispatch,{uischema:a,schema:r,path:t,renderers:o,cells:i,enabled:l},`${t}-${c}`))})}function xr(e,r){return b.deriveLabelForUISchemaElement(e,r??b.defaultTranslator)??e.label}function lo(e,r){var i;const t=(i=e==null?void 0:e.options)==null?void 0:i.description;if(!e||!t)return;const o=b.getI18nKeyPrefixBySchema(void 0,e);return(r??b.defaultTranslator)(o?`${o}.description`:t,t)}const gr=({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(Y.JsonFormsDispatch,{uischema:d,schema:r,path:t,renderers:o,cells:i,enabled:l},`${t}-${f}`))})},yr=b.rankWith(1,b.uiTypeIs("VerticalLayout")),br=({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(Y.JsonFormsDispatch,{uischema:d,schema:r,path:t,renderers:o,cells:i,enabled:l})},`${t}-${f}`))})},vr=b.rankWith(1,b.uiTypeIs("HorizontalLayout")),jr=({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(Y.JsonFormsDispatch,{uischema:d,schema:r,path:t,renderers:o,cells:i,enabled:l},`${t}-${f}`))})]})},wr=b.rankWith(1,b.uiTypeIs("Group")),Tr=e=>e.visible===!1?null:Jt(e.uischema)?n.jsx(ro,{uischema:e.uischema,schema:e.schema,path:e.path,renderers:e.renderers,cells:e.cells,enabled:e.enabled}):n.jsx(ao,{...e}),ao=({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]=x.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,y)=>n.jsx(s.Tabs.Trigger,{value:p.label,children:p.label},`${t}-${y}`))}),n.jsx(s.Box,{pt:"3",children:c.map((p,y)=>n.jsx(s.Tabs.Content,{value:p.label,children:n.jsx(s.Flex,{direction:"column",gap:"4",children:p.elements.map((S,w)=>n.jsx(Y.JsonFormsDispatch,{uischema:S,schema:r,path:t,renderers:o,cells:i,enabled:l},`${t}-${y}-${w}`))})},`${t}-${y}`))})]})},Sr=b.rankWith(1,b.uiTypeIs("Categorization"));function Ee(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(0)} MB`:e>=1024?`${(e/1024).toFixed(0)} KB`:`${e} B`}function Ce(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 co="image/png,image/jpeg,image/gif,image/webp,application/pdf,text/html,text/plain,.png,.jpg,.jpeg,.gif,.webp,.pdf,.html,.htm,.txt";function Er(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 Et(e){const r=e.name??(e.extension?`file${e.extension}`:""),t=!!e.type,o=Cr(r)!==void 0;return!t&&!o?!0:Er({name:r,type:e.type},co)}function Cr(e){const r=e.split(/[/\\]/).pop()??e,t=r.lastIndexOf(".");if(!(t<=0||t===r.length-1))return r.slice(t)}function uo(e,r,t){Rr(new Blob([e],{type:t}),r)}function Rr(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 fo(e,r){const t=await fetch(e);if(!t.ok)throw new Error(`Download failed (${t.status})`);Rr(await t.blob(),r)}const Ze="Uploaded File";function po(e,r,t){if(!e&&t.name)return t.name;const o=e?it(e,r,Ar(t.name??"",Ze)):Ze,i=mo(Cr(t.name??"")??t.extension);return!i||o.toLowerCase().endsWith(i.toLowerCase())?o:`${o}${i}`}function mo(e){return e&&/^\.[A-Za-z0-9]+$/.test(e)?e:void 0}const ho=new Set(["/","\\","<",">",":",'"',"|","?","*"]),xo=e=>ho.has(e)||e.charCodeAt(0)<32||e.charCodeAt(0)===127;function Ar(e,r){const t=Array.from(e,o=>xo(o)?"_":o).join("").trim();return t===""||t.startsWith(".")?r:t}function it(e,r,t){const o=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:{};return Ar(qe(e,o),t)}function Fr({open:e,onOpenChange:r,title:t,description:o,keepLabel:i,removeLabel:l,onConfirm:a}){return n.jsx(s.AlertDialog.Root,{open:e,onOpenChange:r,children:n.jsxs(s.AlertDialog.Content,{maxWidth:"460px",children:[n.jsx(s.AlertDialog.Title,{children:t}),n.jsx(s.AlertDialog.Description,{size:"2",children:o}),n.jsxs(s.Flex,{gap:"3",mt:"4",justify:"end",children:[n.jsx(s.AlertDialog.Cancel,{children:n.jsx(s.Button,{type:"button",variant:"soft",color:"gray",children:i})}),n.jsx(s.AlertDialog.Action,{children:n.jsx(s.Button,{type:"button",color:"red",onClick:a,children:l})})]})]})})}function go(e){return e?Array.isArray(e)?e:[e]:[]}const yo=({data:e,handleChange:r,path:t,label:o,required:i,uischema:l,schema:a,enabled:c,errors:u,visible:d=!0})=>{var ye;const f=_t(),h=(ye=Y.useJsonForms().i18n)==null?void 0:ye.translate,[p,y]=x.useState(null),[S,w]=x.useState("");Re(d,t,r);const H=Te(t,i,d),R=!u||u.length===0,z=(a==null?void 0:a["x-file"])??{},k=(l==null?void 0:l.options)??{},E=z.maxFiles??k.maxFiles??1,T=z.maxSize??k.maxSize??5*1024*1024,C=z.accept??k.accept??"image/*,application/pdf",X=typeof z.fileName=="string"?z.fileName:void 0,U=E>1,M=c!==!1,[P,I]=x.useState(!1),[oe,q]=x.useState(null),[te,J]=x.useState({}),[ce,se]=x.useState({}),G=x.useRef(new Set),ue=x.useRef(null),D=go(e),K=D.length>=E,L=async m=>{var N;const v=(N=ce[m])==null?void 0:N.blobUrl;if(v)return{url:v};const V=f==null?void 0:f.getDownloadUrl;if(!V)return{};const A=await V(m);return{url:A==null?void 0:A.url,extension:A==null?void 0:A.extension,type:A==null?void 0:A.mimeType}},ee=(m,v,V)=>{var A;return po(X,{index:v},{name:(A=ce[m])==null?void 0:A.name,extension:V.extension})},Q=(m,v)=>{J(V=>({...V,[m]:v}))},B=m=>{J(v=>{if(!v[m])return v;const V={...v};return delete V[m],V})};x.useEffect(()=>()=>{G.current.forEach(m=>URL.revokeObjectURL(m)),G.current.clear()},[]);const g=x.useCallback(async m=>{if(q(null),D.length>=E){q(`Maximum ${E} file${E>1?"s":""} allowed.`);return}if(m.size>T){q(`File exceeds the ${Ee(T)} limit.`);return}if(!Er(m,C)){q(`Invalid type. Accepted: ${Ce(C)}`);return}if(!(f!=null&&f.onUpload)){q("Upload service not configured.");return}try{const v=await f.onUpload(m),V=URL.createObjectURL(m);G.current.add(V);const A={key:v.key,name:v.name??m.name,type:m.type||void 0,blobUrl:V};se(ie=>({...ie,[v.key]:A}));const N=[...D,v.key];r(t,U?N:N[0])}catch{q("Upload failed. Please try again."),ue.current&&(ue.current.value="")}},[D,E,T,C,f,t,r,U]);if(d===!1)return null;const F=m=>{m.preventDefault(),m.stopPropagation(),!(!M||K)&&I(m.type==="dragenter"||m.type==="dragover")},W=m=>{var v;m.preventDefault(),m.stopPropagation(),I(!1),!(!M||K)&&(v=m.dataTransfer.files)!=null&&v[0]&&g(m.dataTransfer.files[0])},Z=m=>{var v;(v=m.target.files)!=null&&v[0]&&(g(m.target.files[0]),m.target.value="")},re=m=>{if(!M)return;se(V=>{var ie;const A={...V},N=(ie=A[m])==null?void 0:ie.blobUrl;return N&&(URL.revokeObjectURL(N),G.current.delete(N)),delete A[m],A}),B(m);const v=D.filter(V=>V!==m);r(t,U?v.length>0?v:void 0:v[0])},me=async(m,v,V)=>{var ie,pe;m.preventDefault(),B(v);const A=(ie=ce[v])==null?void 0:ie.blobUrl;if(A){(pe=window.open(A,"_blank","noopener,noreferrer"))==null||pe.focus();return}const N=window.open("","_blank");if(N)try{const O=await L(v);if(!O.url){N.close(),Q(v,"Unable to open file.");return}if(Et(O)){N.location.href=O.url;return}N.close(),await ve(v,V,O)}catch{N.close(),Q(v,"Unable to open file.")}},ve=async(m,v,V)=>{B(m);try{const A=V??await L(m);if(!A.url){Q(m,"Unable to download file.");return}await fo(A.url,ee(m,v,A))}catch{Q(m,"Unable to download file.")}};if(!M&&D.length===0)return null;const Ae=E-D.length,Ie=M&&!K;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:U?`Up to ${E} files · ${Ee(T)} each · ${Ce(C)}`:`${Ee(T)} · ${Ce(C)}`})]}),n.jsx(s.Text,{as:"p",size:"2",role:"status",mb:"2",style:S?void 0:{display:"none"},children:S}),n.jsx(Fr,{open:p!==null,onOpenChange:m=>!m&&y(null),title:p?Oe(h,"confirmTitle",{file:p.name}):"",description:Oe(h,"confirmDescription"),keepLabel:Oe(h,"keepFile"),removeLabel:Oe(h,"removeConfirmed"),onConfirm:()=>{p&&(re(p.key),w(Oe(h,"removed",{file:p.name})),y(null))}}),D.map((m,v)=>{const V=v+1,A=ce[m],N=A==null?void 0:A.name,ie=X?ee(m,V,{}):N??Ze,pe=!!(X&&N),O=te[m],$=Et({name:N,type:A==null?void 0:A.type});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(ne.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:ie}),pe&&n.jsx(s.Text,{size:"1",color:"gray",style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N})]}),n.jsxs(s.Flex,{align:"center",gap:"2",style:{flexShrink:0},children:[$&&n.jsx(s.Button,{variant:"soft",color:"blue",size:"1",onClick:de=>void me(de,m,V),children:"View"}),n.jsx(s.Tooltip,{content:"Download",children:n.jsx(s.IconButton,{variant:"ghost",color:"gray","aria-label":"Download",onClick:()=>void ve(m,V),children:n.jsx(ne.DownloadIcon,{})})}),n.jsx("span",{role:"img","aria-label":Oe(h,"uploaded"),style:{display:"inline-flex"},children:n.jsx(ne.CheckCircledIcon,{"aria-hidden":!0,style:{color:"var(--green-9)",width:18,height:18}})}),M&&n.jsxs(s.DropdownMenu.Root,{children:[n.jsx(s.DropdownMenu.Trigger,{children:n.jsx(s.IconButton,{type:"button",variant:"ghost",color:"gray","aria-label":Oe(h,"moreActions",{file:ie}),children:n.jsx(ne.DotsHorizontalIcon,{})})}),n.jsx(s.DropdownMenu.Content,{align:"end",children:n.jsx(s.DropdownMenu.Item,{color:"red",onSelect:()=>y({key:m,name:ie}),children:Oe(h,"remove")})})]})]})]}),O&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:O})]},m)}),Ie&&n.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{var m;return(m=ue.current)==null?void 0:m.click()},onKeyDown:m=>{var v;(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),(v=ue.current)==null||v.click())},onDragEnter:F,onDragLeave:F,onDragOver:F,onDrop:W,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",P?"border-blue-500 bg-blue-50":oe?"border-red-300 bg-red-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"].join(" "),children:[n.jsx("input",{ref:ue,type:"file",style:{display:"none"},accept:C,onChange:Z}),n.jsx(s.Flex,{direction:"column",align:"center",gap:"2",children:oe?n.jsxs(n.Fragment,{children:[n.jsx(ne.ExclamationTriangleIcon,{style:{width:32,height:32,color:"var(--red-9)"}}),n.jsx(s.Text,{size:"2",color:"red",weight:"medium",children:oe}),n.jsx(s.Text,{size:"1",color:"gray",children:"Click to try again"})]}):n.jsxs(n.Fragment,{children:[n.jsx(ne.UploadIcon,{style:{width:32,height:32,color:"var(--gray-8)"}}),n.jsx(s.Text,{size:"2",weight:"medium",children:D.length>0?`Add another file (${Ae} remaining)`:"Click to upload or drag and drop"}),n.jsxs(s.Text,{size:"1",color:"gray",children:[Ee(T)," max · ",Ce(C)]})]})})]}),M&&K&&U&&n.jsxs(s.Text,{size:"1",color:"gray",mt:"1",style:{display:"block",textAlign:"center"},children:["Maximum ",E," files uploaded. Remove one to replace it."]}),!R&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:Se(u,o)})]})},Ir=Y.withJsonFormsControlProps(yo),kr=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 Or(e,r){return e!==!1&&r!==!0}class Qe extends Error{}async function bo(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 Qe("This file has no sheets.");const l=r??i.SheetNames[0],a=i.Sheets[l];if(!a)throw new Qe(`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 vo(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 xe extends Error{constructor(t,o){super(o??t);gt(this,"code");this.code=t,this.name="FormulaError"}}const jo=["IFS","IFERROR","AND","OR","NOT","ROUND","ROUNDUP","ROUNDDOWN","INDEX","VLOOKUP","HLOOKUP","SUM","AVERAGE","COUNT","DATE","TODAY"],wo=["MAX","MIN","MAXA","MINA","MEDIAN","LARGE","SMALL","PERMUT","PERMUTATIONA","MATCH","SWITCH","SUBSTITUTE","TEXTJOIN","COUNTA","UPPER"],To=["YEAR","MONTH","DAY","WEEKDAY"],So=["IF"],Eo=["CONCATENATE","CONCAT","LEN","TRIM","LOWER","LEFT","RIGHT","MID","FIND","SEARCH"],Co=new Set([...jo,...wo,...To,...Eo,...So]),Ro=/"(?:[^"]|"")*"/g,Ct=new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(","g");function Ao(e){const r=e.replace(Ro,o=>" ".repeat(o.length));Ct.lastIndex=0;let t;for(;(t=Ct.exec(r))!==null;){const o=t[1].toUpperCase();if(!Co.has(o))throw new xe("NAME",`Function ${o} is not allowed.`)}}function Fo(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 Dr(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function $e(e){const r=Dr(e);return Array.isArray(r)?r.flat(1/0):[r]}function ae(e){const r=Dr(e);return Array.isArray(r)?r.flat(1/0)[0]:r}function _e(e){return e===void 0?void 0:ae(e)}function he(e){return e==null||e===""?"":typeof e=="boolean"?e?"TRUE":"FALSE":e instanceof Date?e.toLocaleDateString():String(e)}function Io(e,r){return e instanceof r?e:new r(e.message||"#ERROR!")}function fe(e){return e.find(r=>r instanceof Error)}function ko(e,r){const t=l=>{throw Io(l,r)},o=(l,{checkArgsForErrors:a=!0}={})=>(...c)=>{const u=c.flatMap($e);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=ae(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=Fo(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=$e(l),u=ae(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=$e(l),u=ae(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=[ae(l),ae(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=[ae(l),ae(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=ae(l),u=$e(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(ae),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(ae(l)),he(ae(a)),he(ae(c))];u!==void 0&&d.push(ae(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(ae(l)),d=ae(a),f=c.flatMap($e).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=ae(l),u=ae(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($e),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($e),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=ae(l),u=_e(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=ae(l),u=_e(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=ae(l),d=ae(a),f=ae(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=ae(l),d=ae(a),f=_e(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=ae(l),d=ae(a),f=_e(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 Oo={"#REF!":"REF","#VALUE!":"VALUE","#DIV/0!":"DIV0","#NAME?":"NAME","#N/A":"NA","#NUM!":"NUM","#NULL!":"NULL"};function Rt(e){return Oo[e.error]??"ERROR"}function At(e,r){if(e instanceof xe)return e;if(e instanceof r){const t=e.details;return t instanceof xe?t:t instanceof r?new xe(Rt(t),t.message):new xe(Rt(e),e.message)}return new xe("ERROR",e instanceof Error?e.message:void 0)}function Do(e){return Math.max(0,...e.map(r=>(r==null?void 0:r.length)??0))}function No(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 xe("REF");const o=t[r.col-1];return o==null||o===""?null:o}}function Mo(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=Do(e);if(t>e.length||o>a)throw new xe("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 y=o;y<=p;y++){const S=f[y-1];h.push(S==null||S===""?null:S)}}u.push(h)}return u}}function Lo(e){if(e==null||e==="")return null;if(typeof e=="number"||typeof e=="string"||typeof e=="boolean"||e instanceof Date)return e;throw new xe("VALUE")}async function Nr(e,r){if(typeof e!="string")throw new xe("ERROR");const t=e.trim();if(t==="")throw new xe("ERROR");const o=t.startsWith("=")?t.slice(1):t;Ao(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:ko(l,c)});let d;try{d=u.parse(o,{row:1,col:1,sheet:"Sheet1"})}catch(f){throw At(f,c)}if(d instanceof c)throw At(d,c);return Lo(d)}async function zo(e,r){return Nr(r,{onCell:No(e),onRange:Mo(e)})}const Ft=-1;async function Mr(e,r){const t=Object.keys(e);return Nr(r,{onVariable:o=>{const i=t.indexOf(o);return i===-1?null:{row:Ft,col:i+1}},onCell:o=>{if(o.row===Ft)return e[t[o.col-1]]??null;throw new xe("REF")},onRange:()=>{throw new xe("REF")}})}const Lr={REF:"#REF!",VALUE:"#VALUE!",DIV0:"#DIV/0!",NAME:"#NAME?",ERROR:"#ERROR!",NA:"#N/A",NUM:"#NUM!",NULL:"#NULL!"};function lt(e){const r=e instanceof xe?e.code:"ERROR";return Lr[r]}async function Po(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:Lr.ERROR})):Promise.all(r.map(async t=>{try{if(!t||typeof t.label!="string"||typeof t.expression!="string"||typeof t.id!="string")throw new xe("ERROR");return{id:t.id,label:t.label,value:await zo(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:lt(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 zr(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=It(o);if(f)return`duplicate column id "${f}" — every declared column id must be unique.`}if(d){const f=It(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 kt(e,r={}){const t=zr(r);if(t)throw new Error(`x-spreadsheet: ${t}`);const{columnHeader:o,rowHeader:i,columns:l,rows:a}=r;return l&&l.length>0?$o(e,l,o===!0):a&&a.length>0?Bo(e,a,i===!0):e}function $o(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 Bo(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 Pr(e){return!Array.isArray(e[0])}function Uo(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 et(e,r){const t=o=>o instanceof Date?o.toISOString():o??null;return t(e)===t(r)}function _o(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&&et(a.value,c.value)})}function Wo(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)=>et(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)&&et(o[a],i[a]))}function Vo(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)=>Wo(i,o[l]))}function Ho(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e instanceof Date}function $r(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 Ho(c)?c:null}));return[t,...i]}function qo(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 Jo=".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv",Xo=10*1024*1024,Ye=200,Ko=50,Yo=[];function Ot(e){return e==null||e===""?"":e instanceof Date?e.toLocaleDateString():String(e)}const Go=({data:e,handleChange:r,path:t,label:o,required:i,schema:l,enabled:a,readonly:c,errors:u,visible:d=!0})=>{Re(d,t,r);const f=Te(t,i,d),h=!u||u.length===0,p=Or(a,c),y=(l==null?void 0:l["x-spreadsheet"])??{},S=(l==null?void 0:l["x-evaluate"])??Yo,w=y.accept??Jo,H=y.maxSize??Xo,R=y.columnHeader===!0,z=y.rowHeader===!0,k=y.columns,E=y.rows,T=Array.isArray(k)&&k.length>0,C=Array.isArray(E)&&E.length>0,X=zr({columnHeader:R,rowHeader:z,columns:k,rows:E}),U=y.showSheet!==!1,M=y.sheetName,P=y.persistSheet!==!1,I=e??null,[oe,q]=x.useState(()=>I!=null&&I.sheet||Object.keys((I==null?void 0:I.derivations)??{}).length>0?"ready":"empty"),[te,J]=x.useState(null),[ce,se]=x.useState(!1),[G,ue]=x.useState(null),[D,K]=x.useState(null),L=x.useRef(null),ee=x.useRef(null),Q=(I==null?void 0:I.sheet)??null,B=x.useCallback(m=>{if(!Pr(m))return m;const v=C?E:T?k:void 0,V=$r(m,v==null?void 0:v.map(A=>A.id));return C?qo(V):V},[T,C,k,E]),g=x.useMemo(()=>G??(Q?B(Q):null),[G,Q,B]),F=((D==null?void 0:D.matrix)===g?D.derivations:null)??(I==null?void 0:I.derivations)??{},W=g!=null||I!=null,Z=x.useMemo(()=>{const m=T?1:0,v=C?1:0,V=g?g.slice(m):[],A=V.slice(0,Ye),N=Math.min(Ko,Math.max(0,...A.map($=>Math.max(0,$.length-v)))),ie=Array.from({length:N},($,de)=>de+v),pe="",O=C&&!T;return n.jsx(n.Fragment,{children:g&&U&&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:[!O&&n.jsx(s.Table.Header,{children:n.jsxs(s.Table.Row,{children:[n.jsx(s.Table.ColumnHeaderCell,{children:pe}),ie.map($=>{var de;return n.jsx(s.Table.ColumnHeaderCell,{children:T?((de=k==null?void 0:k[$])==null?void 0:de.label)??"":vo($)},$)})]})}),n.jsx(s.Table.Body,{children:A.map(($,de)=>{var we;const je=m+de;return n.jsxs(s.Table.Row,{children:[n.jsx(s.Table.RowHeaderCell,{style:C?{fontWeight:700,background:"var(--gray-a3)"}:void 0,children:C?((we=E==null?void 0:E[je])==null?void 0:we.label)??"":T?"":je+1}),ie.map(Me=>n.jsx(s.Table.Cell,{children:Ot($[Me])},Me))]},de)})})]})}),V.length>Ye&&n.jsxs(s.Text,{size:"1",color:"gray",mt:"1",style:{display:"block"},children:["Showing first ",Ye," of ",V.length," rows"]})]})})},[g,U,T,C,k,E]),re=x.useCallback(async m=>{if(J(null),m.size>H){J(`File exceeds the ${Ee(H)} limit.`);return}if(!w.split(",").map(N=>N.trim()).some(N=>N==="*"||N==="*/*"?!0:N.endsWith("/*")?m.type.startsWith(N.slice(0,-1)):N.startsWith(".")?m.name.toLowerCase().endsWith(N.toLowerCase()):m.type===N)){J(`Invalid type. Accepted: ${Ce(w)}`);return}q("parsing");let A;try{const N=await m.arrayBuffer();A=(await bo(N,M)).matrix}catch(N){q("error"),J(N instanceof Qe?N.message:"This doesn't look like a valid spreadsheet. Please check the file and try again.");return}if(T||C)try{A=B(kt(A,{columnHeader:R,rowHeader:z,columns:k,rows:E}))}catch(N){q("error"),J(N instanceof Error?N.message:"Failed to process this sheet.");return}ee.current=(e==null?void 0:e.sheet)??null,ue(A),q("ready")},[w,H,M,e,R,z,k,E,T,C,B]);if(x.useEffect(()=>{G!=null&&Q!=null&&Q!==ee.current&&ue(null)},[G,Q]),x.useEffect(()=>{if(X||S.length===0&&!P)return;let m=!1;const v=A=>{p&&(_o(I==null?void 0:I.derivations,A==null?void 0:A.derivations)&&Vo(I==null?void 0:I.sheet,A==null?void 0:A.sheet)||(ee.current=(A==null?void 0:A.sheet)??null,r(t,A)))},V=g??[];if(V.length===0){I!=null&&v(void 0);return}return Po(V,S).then(A=>{if(m)return;let N;if(G!=null){if(P)try{N=kt(V,{columnHeader:T,rowHeader:C,columns:k,rows:E})}catch(pe){J(pe instanceof Error?pe.message:"Failed to process this sheet.");return}}else N=I==null?void 0:I.sheet;J(null);const ie=Uo(A);K({matrix:V,derivations:ie}),v(N===void 0?{derivations:ie}:{sheet:N,derivations:ie})}),()=>{m=!0}},[g,G,S,p,P,T,C,k,E,X]),d===!1)return null;if(X)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: ",X]})]});if(!p&&!W)return null;const me=m=>{m.preventDefault(),m.stopPropagation(),p&&se(m.type==="dragenter"||m.type==="dragover")},ve=m=>{var v;m.preventDefault(),m.stopPropagation(),se(!1),p&&(v=m.dataTransfer.files)!=null&&v[0]&&re(m.dataTransfer.files[0])},Ae=m=>{var v;(v=m.target.files)!=null&&v[0]&&(re(m.target.files[0]),m.target.value="")},Ie=()=>{p&&(ue(null),K(null),ee.current=null,J(null),q("empty"),r(t,void 0))},ye=U&&g==null&&I!=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:" *"})]}),W&&p&&n.jsxs(n.Fragment,{children:[n.jsx(s.Tooltip,{content:"Replace spreadsheet",children:n.jsx(s.IconButton,{variant:"ghost",size:"1",onClick:()=>{var m;return(m=L.current)==null?void 0:m.click()},"aria-label":"Replace spreadsheet",children:n.jsx(ne.UploadIcon,{})})}),n.jsx(s.Tooltip,{content:"Remove spreadsheet",children:n.jsx(s.IconButton,{variant:"ghost",size:"1",color:"gray",onClick:Ie,"aria-label":"Remove spreadsheet",children:n.jsx(ne.Cross2Icon,{})})})]})]}),n.jsxs(s.Text,{size:"1",color:"gray",children:[Ee(H)," max · ",Ce(w)]})]}),W&&te&&n.jsx(s.Text,{size:"2",color:"red",mb:"2",style:{display:"block"},children:te}),n.jsx("input",{ref:L,type:"file",style:{display:"none"},accept:w,onChange:Ae}),p&&!W&&n.jsx("div",{role:"button",tabIndex:0,onClick:()=>{var m;return(m=L.current)==null?void 0:m.click()},onKeyDown:m=>{var v;(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),(v=L.current)==null||v.click())},onDragEnter:me,onDragLeave:me,onDragOver:me,onDrop:ve,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",ce?"border-blue-500 bg-blue-50":te?"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:oe==="parsing"?n.jsxs(n.Fragment,{children:[n.jsx(s.Spinner,{size:"3"}),n.jsx(s.Text,{size:"2",color:"gray",children:"Parsing spreadsheet…"})]}):te?n.jsxs(n.Fragment,{children:[n.jsx(ne.ExclamationTriangleIcon,{style:{width:32,height:32,color:"var(--red-9)"}}),n.jsx(s.Text,{size:"2",color:"red",weight:"medium",children:te}),n.jsx(s.Text,{size:"1",color:"gray",children:"Click to try again"})]}):n.jsxs(n.Fragment,{children:[n.jsx(ne.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:[Ee(H)," max · ",Ce(w)]})]})})}),Z,ye&&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(([m,v])=>n.jsxs(s.Flex,{justify:"between",children:[n.jsx(s.Text,{size:"2",children:v.label}),v.error?n.jsx(s.Text,{size:"2",color:"red",children:v.error}):n.jsx(s.Text,{size:"2",children:Ot(v.value)})]},m))})]}),!h&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:Se(u,o)})]})},Br=Y.withJsonFormsControlProps(Go),Ur=b.rankWith(10,b.schemaMatches(e=>e.type==="object"&&typeof e["x-spreadsheet"]=="object")),Zo="Sheet1",Qo="xlsx";function es(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 ts(e,r){if(!Pr(e))return e;const t=$r(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 rs=({data:e,path:r,label:t,schema:o,visible:i=!0})=>{const[l,a]=x.useState(null),c=Y.useJsonForms();if(i===!1)return null;const u=(o==null?void 0:o["x-spreadsheet-export"])??{},d=u.columns,f=u.sheetName??Zo,h=u.fileType??Qo,p=u.fileName??`export.${h}`,y=es(d);if(y)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: ",y]})]});const S=Array.isArray(e)&&e.length>0,w=async()=>{var H,R;if(S){a(null);try{const z=await import("@e965/xlsx"),k=ts(e,d),E=z.utils.aoa_to_sheet(k),T=z.utils.book_new();z.utils.book_append_sheet(T,E,f);const C=r.split(".").slice(0,-1).join("."),X=C?b.Resolve.data((H=c.core)==null?void 0:H.data,C):(R=c.core)==null?void 0:R.data;z.writeFile(T,it(p,X,`export.${h}`),{bookType:h})}catch(z){a(z instanceof Error?z.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:!S,onClick:()=>void w(),children:[n.jsx(ne.DownloadIcon,{})," Download Spreadsheet"]}),l&&n.jsx(s.Text,{size:"2",color:"red",style:{display:"block",marginTop:"var(--space-2)"},children:l})]})},_r=Y.withJsonFormsControlProps(rs),Wr=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 De extends Error{}const Dt=5e6,ns=1024,os=/^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["']/i,ss={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 is(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 ls(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 as(e,r={}){var d;if(typeof e!="string")throw new De("This file could not be read as text.");const t=e.charCodeAt(0)===65279?e.slice(1):e;if(t.trim()==="")throw new De("This file is empty.");if(t.length>Dt)throw new De(`This document is too large to parse (over ${Dt/1e6} million characters).`);const o=(d=os.exec(t.slice(0,ns)))==null?void 0:d[1];if(o&&!/^utf-?8$/i.test(o))throw new De(`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 De(`Invalid XML at line ${h}, column ${p}: ${f}`)}const c=new i({...ss,removeNSPrefix:r.removeNamespaces===!0,isArray:is(r.arrayPaths??[])});let u;try{u=c.parse(t)}catch(f){throw new De(ls(f))}if(u==null||typeof u!="object"||Array.isArray(u))throw new De("This document has no root element.");return u}function Vr(e,r,t){const{path:o,default:i}=typeof t=="string"?{path:t,default:void 0}:t,l=b.Resolve.data(e,r?`${r}.${o}`:o);return l??i}function cs(e,r,t){const o={};for(const[i,l]of Object.entries(t)){const a=Vr(e,r,l);if(a===void 0)return;o[i]=a}return o}async function us(e,r){try{return{status:"ok",value:await Mr(e,r)}}catch(t){return{status:"error",error:lt(t)}}}function Hr(e,r){return e==null?"":typeof e=="number"?e.toFixed(ds(r)):e instanceof Date?e.toLocaleDateString():String(e)}function ds(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.trunc(e))):0}const Ne={found:!1},be=e=>({found:!0,value:e});function Nt(e){return e==null||e===""?Ne:Array.isArray(e)||e instanceof Date?be(e):typeof e=="object"?Ne:typeof e=="string"||typeof e=="number"||typeof e=="boolean"?be(e):Ne}const fs=new Set(["true","1","yes","y"]),ps=new Set(["false","0","no","n"]),ms=/^(\d{4}-\d{2}-\d{2})(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})?)?$/;async function hs(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:Hr(o,r.decimals)):Ne}case"boolean":{const o=String(e).trim().toLowerCase();return fs.has(o)?be(!0):ps.has(o)?be(!1):Ne}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"?ms.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")):Ne}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")):Ne}}}async function xs(e,r){if(r.formula!==void 0){const t={};for(const[o,i]of Object.entries(r.inputs??{})){const l=Nt(b.Resolve.data(e,i));if(!l.found||Array.isArray(l.value))return Ne;t[o]=l.value}try{return be(await Mr(t,r.formula))}catch(o){throw new Error(`writeTo "${r.to}": ${lt(o)}`)}}if(r.from===void 0)throw new Error(`writeTo "${r.to}" needs either "from" or "formula".`);return Nt(b.Resolve.data(e,r.from))}const Ve="@_",qr="#text",He=e=>e.split(".").filter(Boolean),Jr=e=>e.startsWith(Ve)||e===qr;function Xr(e,r){if(typeof e.to!="string"||He(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=He(e.to);for(const[o,i]of t.entries()){if(i===Ve)return'"@_" needs an attribute name after it, e.g. "@_id".';if(Jr(i)&&o<t.length-1)return`"${i}" must be the last segment — it belongs to the element before it.`}}return null}function Mt(e,r,t){const o=t?` To give "${r}" both text and attributes, write its text to "${r}.${qr}".`:"";return new Error(`writeTo "${e}": "${r}" is written both as a value and as the parent of other values.${o}`)}function Kr(e){const r={},t=new Set([r]);for(const{to:o,value:i}of e){const l=He(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 Mt(o,l.slice(0,d+1).join("."),l[d+1].startsWith(Ve))}const c=l[l.length-1],u=a[c];if(t.has(u)){const d=Object.keys(u).some(f=>f.startsWith(Ve));throw Mt(o,l.join("."),d)}a[c]=i}return r}const gs=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean";async function at(e,r,t){const o=[];for(const i of r){const l=Xr(i,t);if(l)throw new Error(`writeTo "${i.to}": ${l}`);const a=He(i.to),c=t==="export"&&Jr(a[a.length-1]),u=h=>{if(!(c&&h==null)){if(c&&!gs(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 xs(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=>Kr(await at(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 hs(d.value,i,t)),!d.found){if(i.default===void 0)continue;u(i.default);continue}u(d.value)}return o}const ys=".xml,text/xml,application/xml",bs=5*1024*1024,vs=({data:e,handleChange:r,path:t,label:o,required:i,schema:l,enabled:a,readonly:c,errors:u,visible:d=!0})=>{Re(d,t,r);const f=Te(t,i,d),h=!u||u.length===0,p=Or(a,c),y=(l==null?void 0:l["x-xml"])??{},S=y.accept??ys,w=y.maxSize??bs,H=y.arrayPaths,R=y.removeNamespaces===!0,z=y.writeTo,k=y.writeBase??"root",E=y.persistDocument!==!1,T=Y.useJsonForms(),C=e??null,[X,U]=x.useState(()=>C?"ready":"empty"),[M,P]=x.useState(null),[I,oe]=x.useState(!1),q=x.useRef(null),te=x.useRef(0),J=C!=null,ce=z!==void 0&&z.length>0,se=x.useCallback(async L=>{var Z;const ee=++te.current;if(P(null),L.size>w){P(`File exceeds the ${Ee(w)} limit.`);return}if(!S.split(",").map(re=>re.trim()).some(re=>re==="*"||re==="*/*"?!0:re.endsWith("/*")?L.type.startsWith(re.slice(0,-1)):re.startsWith(".")?L.name.toLowerCase().endsWith(re.toLowerCase()):L.type===re)){P(`Invalid type. Accepted: ${Ce(S)}`);return}U("parsing");let g;try{const re=await L.text();g=await as(re,{arrayPaths:H,removeNamespaces:R})}catch(re){if(ee!==te.current)return;U("error"),P(re instanceof De?re.message:"This doesn't look like a valid XML document. Please check the file and try again.");return}let F=[];if(z&&z.length>0)try{F=await at(g,z,"import")}catch(re){if(ee!==te.current)return;U("error"),P(re instanceof Error?re.message:"This document could not be mapped onto the form.");return}if(ee!==te.current)return;E&&r(t,g);const W=k==="parent"?t.split(".").slice(0,-1).join("."):"";for(const re of F)(Z=T.dispatch)==null||Z.call(T,b.update(W?`${W}.${re.to}`:re.to,()=>re.value));U("ready")},[S,w,H,R,z,k,E,t,r,T]);if(d===!1||!p&&!J)return null;const G=L=>{L.preventDefault(),L.stopPropagation(),p&&oe(L.type==="dragenter"||L.type==="dragover")},ue=L=>{var ee;L.preventDefault(),L.stopPropagation(),oe(!1),p&&(ee=L.dataTransfer.files)!=null&&ee[0]&&se(L.dataTransfer.files[0])},D=L=>{var ee;(ee=L.target.files)!=null&&ee[0]&&(se(L.target.files[0]),L.target.value="")},K=()=>{p&&(++te.current,P(null),U("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:" *"})]}),!ce&&J&&p&&n.jsxs(n.Fragment,{children:[n.jsx(s.Tooltip,{content:"Replace document",children:n.jsx(s.IconButton,{variant:"ghost",size:"1",onClick:()=>{var L;return(L=q.current)==null?void 0:L.click()},"aria-label":"Replace document",children:n.jsx(ne.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(ne.Cross2Icon,{})})})]})]}),n.jsxs(s.Flex,{align:"center",gap:"2",children:[n.jsxs(s.Text,{size:"1",color:"gray",children:[Ee(w)," max · ",Ce(S)]}),ce&&p&&n.jsxs(s.Button,{size:"1",variant:"soft",onClick:()=>{var L;return(L=q.current)==null?void 0:L.click()},disabled:X==="parsing",children:[X==="parsing"?n.jsx(s.Spinner,{size:"1"}):n.jsx(ne.UploadIcon,{}),"Upload"]})]})]}),(ce||J)&&M&&n.jsx(s.Text,{size:"2",color:"red",mb:"2",style:{display:"block"},children:M}),n.jsx("input",{ref:q,type:"file",style:{display:"none"},accept:S,onChange:D}),!ce&&p&&!J&&n.jsx("div",{role:"button",tabIndex:0,onClick:()=>{var L;return(L=q.current)==null?void 0:L.click()},onKeyDown:L=>{var ee;(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),(ee=q.current)==null||ee.click())},onDragEnter:G,onDragLeave:G,onDragOver:G,onDrop:ue,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",I?"border-blue-500 bg-blue-50":M?"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:X==="parsing"?n.jsxs(n.Fragment,{children:[n.jsx(s.Spinner,{size:"3"}),n.jsx(s.Text,{size:"2",color:"gray",children:"Parsing document…"})]}):M?n.jsxs(n.Fragment,{children:[n.jsx(ne.ExclamationTriangleIcon,{style:{width:32,height:32,color:"var(--red-9)"}}),n.jsx(s.Text,{size:"2",color:"red",weight:"medium",children:M}),n.jsx(s.Text,{size:"1",color:"gray",children:"Click to try again"})]}):n.jsxs(n.Fragment,{children:[n.jsx(ne.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:[Ee(w)," max · ",Ce(S)]})]})})}),!h&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:Se(u,o)})]})},Yr=Y.withJsonFormsControlProps(vs),Gr=b.rankWith(10,b.schemaMatches(e=>{const r=e["x-xml"];return e.type==="object"&&typeof r=="object"&&r!==null})),js="root",Lt="export.xml",ws={format:!0,indentBy:" ",ignoreAttributes:!1,attributeNamePrefix:"@_",textNodeName:"#text",suppressBooleanAttributes:!1,processEntities:!0};function Ts(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 Zr(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=Xr(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=Zr(o);if(l)return l}}return null}function Ss({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.":Zr(e)??(r===void 0?null:Ts(r)):"writeTo must be an array of { from | formula, to } entries."}function Es({version:e="1.0",standalone:r}){return{"@_version":e,"@_encoding":"UTF-8",...r&&{"@_standalone":r}}}function Cs(e){return e==null?!0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}const Rs=({path:e,label:r,schema:t,visible:o=!0})=>{var z,k;const i=(t==null?void 0:t["x-xml-export"])??{},l=i.rootElement??js,a=i.fileName??Lt,c=i.writeTo,u=i.writeBase??"root",d=i.declaration,f=Ss(i),h=Y.useJsonForms(),p=u==="parent"?e.split(".").slice(0,-1).join("."):"",y=p?b.Resolve.data((z=h.core)==null?void 0:z.data,p):(k=h.core)==null?void 0:k.data,[S,w]=x.useState(null),H=Cs(y),R=x.useCallback(async()=>{if(c){w(null);try{const E=Kr(await at(y,c,"export")),{XMLBuilder:T}=await import("fast-xml-parser"),C={...d&&{"?xml":Es(d)},[l]:E},X=new T(ws).build(C);uo(X,it(a,y,Lt),"application/xml")}catch(E){w(E instanceof Error?E.message:"This export could not be built.")}}},[c,y,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:H,onClick:()=>void R(),children:[n.jsx(ne.DownloadIcon,{}),"Download XML"]}),S&&n.jsx(s.Text,{size:"2",color:"red",style:{display:"block",marginTop:"var(--space-2)"},children:S})]})},Qr=Y.withJsonFormsControlProps(Rs),en=b.rankWith(10,b.schemaMatches(e=>{const r=e["x-xml-export"];return e.type==="object"&&typeof r=="object"&&r!==null})),As="{value}",Fs=2,Is={},ks=({data:e,handleChange:r,path:t,label:o,schema:i,visible:l=!0})=>{var C;Re(l,t,r);const a=i==null?void 0:i["x-computed"],c=(a==null?void 0:a.inputs)??Is,u=(a==null?void 0:a.formula)??"",d=(a==null?void 0:a.format)??As,f=(a==null?void 0:a.decimals)??Fs,h=Y.useJsonForms(),p=t.split(".").slice(0,-1).join("."),y=cs((C=h.core)==null?void 0:C.data,p,c),S=y?JSON.stringify(y):null,w=h.readonly===!0,[H,R]=x.useState(()=>typeof e=="number"?"ok":"unavailable"),[z,k]=x.useState(()=>typeof e=="number"?e:null),[E,T]=x.useState(null);return x.useEffect(()=>{if(!l)return;let X=!1;const U=M=>{w||M!==e&&r(t,M)};if(y===void 0){R("unavailable"),T(null),k(null),U(void 0);return}return R(M=>M==="ok"?M:"loading"),us(y,u).then(M=>{if(X)return;const P=M.status==="ok"&&typeof M.value=="number"&&Number.isFinite(M.value)?M.value:null;if(P===null){R("error"),T(M.status==="error"?M.error??"Unable to compute value.":"Computed value must be a number."),k(null),U(void 0);return}R("ok"),T(null),k(P),U(P)}),()=>{X=!0}},[S,u,l,w]),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}),H==="unavailable"?n.jsx(s.Text,{size:"2",color:"gray",children:"Not yet available."}):H==="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…"})]}):H==="error"?n.jsx(s.Text,{size:"2",color:"red",children:E}):n.jsx(s.Text,{size:"2",children:qe(d,{value:Hr(z,f)})}),i.description&&n.jsx(s.Text,{size:"1",color:"gray",children:i.description})]})})},tn=Y.withJsonFormsControlProps(ks),rn=b.rankWith(5,b.schemaMatches(e=>{const r=e["x-computed"];return e.type==="number"&&typeof r=="object"&&r!==null})),nn="seq",zt=2,Os=e=>e==null||e==="",on=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,Ds=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}},ct=e=>typeof e=="object"&&e.name===nn&&e.arg!==void 0,Ns=e=>e.every((r,t)=>!ct(r)||typeof e[t-1]!="object"&&typeof e[t+1]!="object"),Ms=e=>{const r=new Set;for(const t of ot(e))typeof t=="object"&&t.arg===void 0&&r.add(t.name);return[...r]},Ls=e=>{const r=[];for(const[t,o]of Object.entries((e==null?void 0:e.properties)??{})){const i=Ds(o);i&&r.push([t,i])}return r},zs=(e,r,t)=>{var i;const o={};for(const l of Ms(t.template)){const a=Vr(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},Ps=e=>r=>{const t=r.trim()===""?zt:Number(r);return`${e}`.padStart(Number.isInteger(t)&&t>=0?t:zt,"0")},$s=e=>{const r=o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");let t="";for(const o of ot(e))typeof o=="string"?t+=r(o):t+=ct(o)?"(\\d+)":".*?";return new RegExp(`^${t}$`)},Bs=(e,r,t)=>{var l,a;const o=$s(t.template);let i=0;for(const c of e){const u=(l=on(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},Us=(e,r,t,o,i,l)=>{const a=Ls(e);if(a.length===0)return r;const c=on(r);if(!c)return r;const u={...c};for(const[d,f]of a){if(!Os(u[d]))continue;const h=ot(f.template),p={};if(h.some(ct)){if(!Ns(h)){console.warn(`x-template: {seq(…)} needs literal text between it and other placeholders; not numbering "${f.template}"`);continue}const y=Math.max(l[d]??0,Bs(t,d,f))+1;l[d]=y,p[nn]=Ps(y)}u[d]=qe(f.template,zs(o,i,f),p)}return u},Pt=" · ",_s=/\{([A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*)\}/g;function sn(e,r){return r.split(".").reduce((t,o)=>{if(!(t===null||typeof t!="object"))return t[o]},e)}function Ws(e,r){return r.split(".").reduce((t,o)=>{var i;return(i=t==null?void 0:t.properties)==null?void 0:i[o]},e)}function Vs(e,r){var o;const t=(e==null?void 0:e.oneOf)??(e==null?void 0:e.anyOf);return Array.isArray(t)?(o=t.find(i=>i.const===r))==null?void 0:o.title:void 0}function ln(e,r,t){var i;if(e==null||e==="")return"";if(typeof e=="object"&&!Array.isArray(e)){const l=e;return typeof l.label=="string"?l.label:"value"in l?ln(l.value,(i=r==null?void 0:r.properties)==null?void 0:i.value,t):""}const o=Vs(r,e);return o||(typeof e=="number"?new Intl.NumberFormat(t).format(e):typeof e=="string"?e:"")}function $t(e,r,t,o){return e.split(Pt).map(i=>{let l=0,a=0;const c=i.replace(_s,(u,d)=>{l++;const f=ln(sn(r,d),Ws(t,d),o);return f&&a++,f});return l>0&&a===0?"":c.trim()}).filter(Boolean).join(Pt)}function Hs(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e)))return Number(e)}function qs(e,r,t){const o=new Intl.NumberFormat(t);return r.flatMap(i=>{const l=e.map(a=>Hs(sn(a,i.field))).filter(a=>a!==void 0);return l.length?[i.label.replace("{sum}",o.format(l.reduce((a,c)=>a+c,0)))]:[]})}const Js=({path:e,items:r,itemsSchema:t,rootSchema:o,addItem:i,sequences:l,label:a,buttonRef:c,onAdded:u})=>{const d=Y.useJsonForms(),f=()=>{var p;const h=Us(t,b.createDefaultValue(t,o),r,(p=d.core)==null?void 0:p.data,e.split(".").slice(0,-1).join("."),l.current);i&&i(e,h)(),u(r.length)};return n.jsx(s.Box,{mt:"2",children:n.jsxs(s.Button,{ref:c,type:"button",variant:"surface",onClick:f,children:[n.jsx(ne.PlusIcon,{}),a]})})};function Xs(e,r){var o;const t=(o=e.options)==null?void 0:o.detail;return t||(r.type==="object"||r.properties?{type:"VerticalLayout",elements:Object.keys(r.properties||{}).map(i=>({type:"Control",scope:`#/properties/${i}`}))}:{type:"Control",scope:"#"})}const Ks=({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=""})=>{var m,v,V,A,N,ie,pe;const p=x.useRef({}),y=Te(r,f,l),S=Y.useJsonForms(),w=(m=S.i18n)==null?void 0:m.translate,H=(v=S.i18n)==null?void 0:v.locale,R=(O,$)=>kn(w,O,$),[z,k]=x.useState(null),[E,T]=x.useState(null),[C,X]=x.useState(""),U=x.useRef(null),M=x.useRef([]),P=x.useRef(null),I=Array.isArray(e)?e.length:0;x.useEffect(()=>{if(U.current===null)return;const O=M.current[Math.min(U.current,I-1)]??P.current;U.current=null,O==null||O.focus()},[I]);const oe=d?t:t.items,q=d||t;if(l===!1||!oe||typeof oe!="object"||Array.isArray(oe))return null;const te=oe,J=Array.isArray(e)?e:[],ce=q.title||"Array Items",se=o.options??{},G=se.display==="cards",ue=i&&se.addable!==!1,D=i&&se.removable!==!1,K=se.itemLabel||"Item",L=y||typeof q.minItems=="number"&&q.minItems>=1,ee=!h,Q=ee?"":J.length===0&&se.errorMessage||Se(h,ce),B=O=>se.summary?$t(se.summary,O,te,H):"",g=O=>`${K} ${O+1}`,F=O=>{const $=B(J[O]);return $?`${g(O)} (${$})`:g(O)},W=O=>[R(O.length===1?"countOne":"countOther",{count:O.length}),...qs(O,se.totals??[],H)].join(" · "),Z=J.length>0&&(G||(((V=se.totals)==null?void 0:V.length)??0)>0),re=((A=S.core)==null?void 0:A.validationMode)!=="ValidateAndHide"&&((N=S.core)==null?void 0:N.validationMode)!=="NoValidation",me=new Set;if(G&&re){const O=`${r}.`;for(const $ of[...((ie=S.core)==null?void 0:ie.errors)??[],...((pe=S.core)==null?void 0:pe.additionalErrors)??[]]){const de=b.getControlPath($);de.startsWith(O)&&me.add(Number(de.slice(O.length).split(".")[0]))}}const ve=O=>{if(!c)return;const $=c(r,[O]);$&&$()},Ae=()=>{if(z===null)return;const O=z,$=F(O),de=J.filter((je,we)=>we!==O);ve(O),X(de.length&&Z?R("removedTotals",{item:$,totals:W(de)}):R("removed",{item:$})),U.current=O,k(null)},Ie=O=>{X(""),G&&T({index:O,isNew:!0})},ye=(O,$)=>n.jsx(Y.JsonFormsDispatch,{schema:te,uischema:Xs(o,te),path:`${r}.${O}`,enabled:$,renderers:void 0,cells:void 0});return n.jsxs(s.Box,{mb:"6",id:r,tabIndex:-1,style:{outline:"none"},children:[n.jsxs(s.Flex,{direction:"column",gap:"4",children:[n.jsxs(s.Text,{as:"div",size:"4",weight:"bold",children:[ce," ",L&&n.jsx(s.Text,{color:"red",children:"*"})]}),Z&&n.jsx(s.Text,{as:"p",size:"2",weight:"medium",children:W(J)}),n.jsx(s.Text,{as:"p",size:"2",role:"status",style:C?void 0:{display:"none"},children:C}),J.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:R("empty")})}),!ee&&n.jsx(s.Text,{color:"red",size:"1",children:Q}),J.map((O,$)=>{const de=`${r}.${$}`;if(G){const je=B(O),we=se.summaryDetail?$t(se.summaryDetail,O,te,H):"",Me=me.has($);return n.jsx(s.Card,{size:"1",variant:"surface",style:Me?{boxShadow:"inset 0 0 0 1px var(--red-8)"}:void 0,children:n.jsxs(s.Flex,{align:"center",gap:"3",children:[n.jsxs("button",{ref:Ue=>{M.current[$]=Ue},type:"button",onClick:()=>T({index:$,isNew:!1}),"aria-label":R("openItem",{item:F($)}),className:"enabled:hover:bg-[var(--gray-a2)]",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:12,padding:8,border:0,borderRadius:"var(--radius-3)",background:"transparent",cursor:"pointer",textAlign:"left"},children:[n.jsx(s.Box,{"aria-hidden":!0,style:{background:"var(--accent-3)",color:"var(--accent-11)",padding:8,borderRadius:"var(--radius-2)",flexShrink:0,display:"flex"},children:n.jsx(ne.FileTextIcon,{width:"18",height:"18"})}),n.jsxs(s.Box,{style:{flex:1,minWidth:0},children:[n.jsx(s.Text,{as:"p",size:"2",weight:"bold",children:je||g($)}),we&&n.jsx(s.Text,{as:"p",size:"1",color:"gray",children:we}),Me&&n.jsx(s.Text,{as:"p",size:"1",color:"red",children:R("needsAttention")})]}),n.jsx(ne.ChevronRightIcon,{"aria-hidden":!0})]}),D&&n.jsxs(n.Fragment,{children:[n.jsx(s.Separator,{orientation:"vertical",size:"2"}),n.jsx(s.IconButton,{type:"button",variant:"ghost",color:"gray",onClick:()=>k($),"aria-label":R("removeItem",{item:F($)}),children:n.jsx(ne.Cross2Icon,{})})]})]})},de)}return n.jsx(s.Card,{size:"3",variant:"surface",ref:je=>{M.current[$]=je},tabIndex:-1,style:{outline:"none"},children:n.jsxs(s.Flex,{direction:"column",gap:"4",children:[n.jsxs(s.Flex,{justify:"between",align:"center",children:[n.jsx(s.Text,{size:"3",weight:"bold",children:g($)}),D&&n.jsxs(s.Button,{type:"button",color:"red",variant:"soft",onClick:()=>k($),"aria-label":R("removeItem",{item:F($)}),children:[n.jsx(ne.TrashIcon,{}),R("remove")]})]}),n.jsx(s.Box,{children:ye($,i)})]})},de)}),ue&&n.jsx(Js,{path:r,items:J,itemsSchema:te,rootSchema:u,addItem:a,sequences:p,label:R("addItem"),buttonRef:P,onAdded:Ie})]}),G&&E&&E.index<J.length&&n.jsx(s.Dialog.Root,{open:!0,onOpenChange:O=>!O&&T(null),children:n.jsxs(s.Dialog.Content,{maxWidth:"640px",children:[n.jsx(s.Dialog.Title,{children:g(E.index)}),n.jsx(s.Dialog.Description,{size:"2",color:"gray",mb:"4",children:B(J[E.index])}),ye(E.index,i),n.jsxs(s.Flex,{gap:"3",mt:"4",justify:"between",children:[!E.isNew&&D?n.jsxs(s.Button,{type:"button",color:"red",variant:"soft",onClick:()=>{const O=E.index;T(null),k(O)},children:[n.jsx(ne.TrashIcon,{}),R("remove")]}):n.jsx("span",{}),n.jsxs(s.Flex,{gap:"3",children:[E.isNew&&n.jsx(s.Button,{type:"button",variant:"soft",color:"gray",onClick:()=>{var O;ve(E.index),T(null),(O=P.current)==null||O.focus()},children:R("cancel")}),n.jsx(s.Dialog.Close,{children:n.jsx(s.Button,{type:"button",children:E.isNew?R("add"):R(i?"done":"close")})})]})]})]})}),n.jsx(Fr,{open:z!==null,onOpenChange:O=>!O&&k(null),title:z===null?"":R("confirmTitle",{item:F(z)}),description:R("confirmDescription"),keepLabel:R("keepItem"),removeLabel:R("removeConfirmed"),onConfirm:Ae})]})},tt=Y.withJsonFormsArrayControlProps(Ks),an=b.rankWith(3,b.isObjectArrayControl),cn=({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})})},un=b.rankWith(1,b.uiTypeIs("Label")),Ys=b.rankWith(3,b.isPrimitiveArrayControl),Gs=[{tester:Qt,renderer:Bn},{tester:tr,renderer:_n},{tester:nr,renderer:Wn},{tester:sr,renderer:Vn},{tester:ur,renderer:dr},{tester:lr,renderer:bt},{tester:ar,renderer:bt},{tester:pr,renderer:to},{tester:yr,renderer:Y.withJsonFormsLayoutProps(gr)},{tester:vr,renderer:Y.withJsonFormsLayoutProps(br)},{tester:wr,renderer:Y.withJsonFormsLayoutProps(jr)},{tester:Sr,renderer:Y.withJsonFormsLayoutProps(Tr)},{tester:kr,renderer:Ir},{tester:Ur,renderer:Br},{tester:Wr,renderer:_r},{tester:Gr,renderer:Yr},{tester:en,renderer:Qr},{tester:rn,renderer:tn},{tester:an,renderer:tt},{tester:Ys,renderer:tt},{tester:un,renderer:cn}];exports.ArrayControl=tt;exports.ArrayControlTester=an;exports.BooleanControl=rr;exports.BooleanControlTester=nr;exports.CategorizationLayoutRenderer=Tr;exports.CategorizationLayoutTester=Sr;exports.ComputedControl=tn;exports.ComputedControlTester=rn;exports.DateControl=fr;exports.DateControlTester=pr;exports.FileControl=Ir;exports.FileControlTester=kr;exports.FormStepsProvider=Sn;exports.GroupLayoutRenderer=jr;exports.GroupLayoutTester=wr;exports.HorizontalLayoutRenderer=br;exports.HorizontalLayoutTester=vr;exports.LIST_MESSAGES=Kt;exports.LabelRenderer=cn;exports.LabelTester=un;exports.NumberControl=er;exports.NumberControlTester=tr;exports.RadioControl=or;exports.RadioControlTester=sr;exports.STEPPER_MESSAGES=Gt;exports.SearchSelectControl=dr;exports.SearchSelectControlTester=ur;exports.SearchServiceProvider=Tn;exports.SelectControl=ir;exports.SelectControlTester=lr;exports.SelectObjectControlTester=ar;exports.SpreadsheetControl=Br;exports.SpreadsheetControlTester=Ur;exports.SpreadsheetExportControl=_r;exports.SpreadsheetExportControlTester=Wr;exports.TextControl=Zt;exports.TextControlTester=Qt;exports.UPLOAD_MESSAGES=Yt;exports.UploadProvider=wn;exports.VerticalLayoutRenderer=gr;exports.VerticalLayoutTester=yr;exports.XmlControl=Yr;exports.XmlControlTester=Gr;exports.XmlExportControl=Qr;exports.XmlExportControlTester=en;exports.isStepperUiSchema=Jt;exports.radixRenderers=Gs;exports.searchSelectTargetSchema=st;exports.useSearchService=Vt;exports.useUpload=_t;
3
+ `)},rt=g.createContext(!1);function nt(e){const r=K.useJsonForms().readonly===!0,t=g.useContext(rt);return e===!1&&!r&&!t}const Xn="Not provided";function ot(e){var o;const r=K.useJsonForms(),t=g.useContext(rt);return r.readonly!==!0&&!t?{placeholder:e}:{placeholder:tt((o=r.i18n)==null?void 0:o.translate,"form.notProvided",Xn),"data-empty-answer":""}}function Ge(){return n.jsx(s.TextField.Slot,{side:"right",children:n.jsx(re.LockClosedIcon,{"aria-hidden":!0,"data-testid":"read-only-lock",style:{color:"var(--gray-10)"}})})}const dr=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,uischema:a,schema:c,enabled:u,visible:d=!0})=>{var w;Ie(d,t,r);const f=Ee(t,i,d),m=nt(u),p=ot((w=a.options)==null?void 0:w.placeholder);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:E=>r(t,E.target.value===""?void 0:E.target.value),disabled:!u,...p,color:h?void 0:"red",id:t,children:m&&n.jsx(Ge,{})}),!h&&n.jsx(s.Text,{color:"red",size:"1",children:Ce(l,o)}),c.description&&n.jsx(s.Text,{size:"1",color:"gray",children:c.description})]})})},fr=v.rankWith(1,v.isStringControl),Kn=K.withJsonFormsControlProps(dr),Yn=new Set(["-","+","e","E"]),pr=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,uischema:a,schema:c,enabled:u,visible:d=!0})=>{var k;Ie(d,t,r);const f=Ee(t,i,d),m=nt(u),p=ot((k=a.options)==null?void 0:k.placeholder);if(d===!1)return null;const h=l.length===0,w=typeof c.exclusiveMinimum=="number"?c.exclusiveMinimum:void 0,E=typeof c.minimum=="number"?c.minimum:void 0,L=w??E,B=L!==void 0&&L>=0,M=typeof c.multipleOf=="number"?c.multipleOf:c.type==="integer"?1:void 0,$=R=>{if(R===""){r(t,void 0);return}const y=Number(R);isNaN(y)||r(t,y)},j=R=>{B&&Yn.has(R.key)&&R.preventDefault()},N=R=>{if(!B)return;const y=R.clipboardData.getData("text");/[-+eE]/.test(y)&&R.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:R=>$(R.target.value),onKeyDown:j,onPaste:N,min:L,step:M,disabled:!u,...p,color:h?void 0:"red",id:t,children:m&&n.jsx(Ge,{})}),!h&&n.jsx(s.Text,{color:"red",size:"1",children:Ce(l,o)}),c.description&&n.jsx(s.Text,{size:"1",color:"gray",children:c.description})]})})},mr=v.rankWith(2,v.or(v.isNumberControl,v.isIntegerControl)),Gn=K.withJsonFormsControlProps(pr),hr=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,schema:a,enabled:c,visible:u=!0})=>{Ie(u,t,r);const d=Ee(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: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:Ce(l,o)}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",className:"block mt-1",children:a.description})]})},xr=v.rankWith(2,v.isBooleanControl),Zn=K.withJsonFormsControlProps(hr),gr=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,schema:a,enabled:c,visible:u=!0})=>{Ie(u,t,r);const d=Ee(t,i,u);if(u===!1)return null;const f=l.length===0;let m=[];a.enum?m=a.enum.map(h=>({value:h,label:String(h)})):a.oneOf&&(m=a.oneOf.map(h=>({value:h.const,label:h.title||String(h.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:h=>{const w=m.find(E=>String(E.value)===h);w&&r(t,w.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(h=>n.jsxs(s.Flex,{align:"center",gap:"2",style:{minWidth:"max-content"},children:[n.jsx(s.RadioGroup.Item,{value:String(h.value)}),n.jsx(s.Text,{size:"2",color:c?void 0:"gray",children:h.label})]},String(h.value)))})}),!f&&n.jsx(s.Text,{color:"red",size:"1",children:Ce(l,o)}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",children:a.description})]})})},yr=(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},Qn=K.withJsonFormsControlProps(gr),br=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,schema:a,uischema:c,enabled:u,visible:d=!0})=>{var oe,de,q,ce;Ie(d,t,r);const f=Ee(t,i,d),m=ot(((oe=c.options)==null?void 0:oe.placeholder)||"Select an option"),p=((de=c.options)==null?void 0:de.autocomplete)===!0,[h,w]=g.useState(!1),[E,L]=g.useState(""),[B,M]=g.useState(0),$=g.useRef(null);if(g.useEffect(()=>{if(!p||!h)return;const A=J=>{$.current&&!$.current.contains(J.target)&&w(!1)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[p,h]),d===!1)return null;const j=a.type==="object",N=j?((q=a.properties)==null?void 0:q.value)??{}:a;let k=[];N.enum?k=N.enum.map(A=>({value:String(A),label:String(A),raw:A})):N.oneOf&&(k=N.oneOf.map(A=>{const J=A.const;return{value:String(J),label:A.title||String(J),raw:J}}));const R=j?typeof e=="string"||typeof e=="number"||typeof e=="boolean"?{value:e}:e??void 0:void 0,y=j?R==null?void 0:R.value:e,T=R==null?void 0:R.label,O=y!=null?String(y):"",F=T??((ce=k.find(A=>A.value===O))==null?void 0:ce.label)??"",le=j&&O!==""&&!k.some(A=>A.value===O),X=l?Ce(l,o):le?`"${F||O}" is no longer an available option`:"",ne=X==="",Q=A=>{r(t,j?{value:A.raw,label:A.label}:A.value)};if(p){const A=h?k.filter(_=>_.label.toLowerCase().includes(E.toLowerCase())):k,J=Math.min(B,A.length-1),P=_=>{Q(_),w(!1)},Z=_=>{_.stopPropagation(),r(t,void 0),L("")},Y=_=>{(_.key==="Enter"||_.key===" ")&&Z(_)};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:h?E:F,...m,disabled:!u,style:ne?void 0:{outline:"2px solid var(--red-7)",outlineOffset:"-1px"},onChange:_=>{L(_.target.value),M(0),h||w(!0)},onFocus:()=>{u&&!h&&(L(""),M(0),w(!0))},onKeyDown:_=>{_.key==="Escape"?w(!1):_.key==="ArrowDown"?(_.preventDefault(),h?M(b=>Math.min(b+1,A.length-1)):(L(""),w(!0))):_.key==="ArrowUp"?(_.preventDefault(),h&&M(b=>Math.max(b-1,0))):_.key==="Enter"&&h&&A[J]&&(_.preventDefault(),P(A[J]))},children:n.jsx(s.TextField.Slot,{side:"right",children:n.jsxs(s.Flex,{align:"center",gap:"1",children:[O&&u&&n.jsx("span",{role:"button",tabIndex:0,onMouseDown:_=>_.preventDefault(),onClick:Z,onKeyDown:Y,style:{lineHeight:1,color:"var(--gray-9)",padding:"0 2px",cursor:"pointer"},"aria-label":"Clear selection",children:"×"}),n.jsx(re.ChevronDownIcon,{style:{transform:h?"rotate(180deg)":void 0,transition:"transform 150ms"}})]})})}),h&&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:[A.length===0&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Text,{size:"2",color:"gray",children:"No results found."})}),A.map((_,b)=>n.jsx(s.Box,{px:"3",py:"2",onMouseDown:D=>D.preventDefault(),onClick:()=>P(_),onMouseEnter:()=>M(b),style:{cursor:"pointer",borderRadius:"var(--radius-2)",backgroundColor:b===J?"var(--accent-4)":_.value===O?"var(--accent-3)":void 0},children:n.jsx(s.Text,{size:"2",children:_.label})},_.value))]})})})]}),!ne&&n.jsx(s.Text,{color:"red",size:"1",children:X}),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:O,onValueChange:A=>{const J=k.find(P=>P.value===A);J&&Q(J)},disabled:!u,children:[n.jsx(s.Select.Trigger,{...m,color:ne?void 0:"red",id:t,children:j&&T?T:void 0}),n.jsx(s.Select.Content,{children:k.map(A=>n.jsx(s.Select.Item,{value:A.value,children:A.label},A.value))})]}),!ne&&n.jsx(s.Text,{color:"red",size:"1",children:X}),a.description&&n.jsx(s.Text,{size:"1",color:"gray",children:a.description})]})})},vr=v.rankWith(2,v.or(v.isEnumControl,v.isOneOfControl)),jr=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)})),Ft=K.withJsonFormsControlProps(br),wr=/\{([A-Za-z0-9_]+)(?:\(([^(){}]*)\))?\}/g,eo={today:e=>Gt().format(e||"YYYY-MM-DD")},to=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="bigint",It=(e,r)=>Object.prototype.hasOwnProperty.call(e,r);function st(e,r,t={}){const o={...eo,...t};return e.replace(wr,(i,l,a)=>{let c;if(a===void 0){if(!It(r,l))return i;c=r[l]}else{if(!It(o,l))return i;try{c=o[l](a)}catch{return i}}return c==null?"":to(c)?String(c):i})}function xt(e){const r=[];let t=0;for(const o of e.matchAll(wr))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 kt(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 gt(e){if(kt(e))return e;if(e.type==="array"){const r=e.items;if(r&&!Array.isArray(r)&&kt(r))return r}}const Tr=v.rankWith(4,v.schemaMatches(e=>{const r=gt(e);if(!r)return!1;const t=r.type;return t==="string"||t==="object"}));function ro(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 no(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 oo(e,r,t){const o={};for(const[i,l]of Object.entries(e))o[i]=ro(v.Resolve.data(r,t?`${t}.${l}`:l));return o}function Ot(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 ct(e,r){return r?{...e,name:st(r,e)}:e}const so={"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}},io=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,enabled:a,visible:c=!0,schema:u,uischema:d})=>{var wt,Tt,St,Et;const f=u.type==="array",m=gt(u)??u,p=m["x-search"]??{service:"",displayTemplate:""},h=p.service??"",w=p.mode??"large-paginated-list",E=so[w],L=(E==null?void 0:E.fetchOnOpen)??!1,B=typeof p.displayTemplate=="string"?p.displayTemplate:"",M=K.useJsonForms(),$=t.split(".").slice(0,-1).join("."),{parentValues:j,parentValuesKey:N,missingParent:k}=g.useMemo(()=>{var be;const C=no(p.dependsOn);if(!C)return{parentValues:void 0,parentValuesKey:"",missingParent:!1};const W=oo(C,(be=M.core)==null?void 0:be.data,$),se=Object.keys(W).length===0||Object.values(W).some(De=>!De);return{parentValues:W,parentValuesKey:JSON.stringify(W),missingParent:se}},[p.dependsOn,(wt=M.core)==null?void 0:wt.data,$]),R=g.useMemo(()=>j?{...p.params,...j}:p.params,[j,N,p.params]),y=tr(h),T=m.type==="object",O=typeof u.maxItems=="number"?u.maxItems:void 0,F=g.useMemo(()=>{if(f)return Array.isArray(e)?e.map(Ot).filter(W=>!!W):[];const C=Ot(T||typeof e=="string"?e:void 0);return C?[C]:[]},[e,f,T]),le=f||(Tt=F[0])==null?void 0:Tt.value,X=f||(St=F[0])==null?void 0:St.label,ne=g.useMemo(()=>new Set(F.map(C=>C.value)),[F]),Q=F.length>0,oe=g.useRef({}),[de,q]=g.useState(0),ce=g.useMemo(()=>{const C={};for(const W of F)C[W.value]=W.label||oe.current[W.value]||W.value;return C},[F,de]),A=f&&O!==void 0&&F.length>=O,J=h?y?E?B?null:"x-search.displayTemplate is required.":`Invalid x-search.mode "${w}". Expected "small-list", "large-searchable-list", or "large-paginated-list".`:`Search service "${h}" is not registered.`:"Search not configured.",P=a!==!1,Z=!l||l.length===0,[Y,_]=g.useState(!1),[b,D]=g.useState(""),[H,G]=g.useState([]),[ee,ye]=g.useState(!1),[je,ve]=g.useState(!1),[we,Te]=g.useState(!1),[x,S]=g.useState(null),[V,I]=g.useState(void 0),z=g.useRef(void 0),ae=g.useRef(null),pe=g.useRef(null),me=g.useRef(null),ue=g.useRef(void 0),he=g.useRef(void 0),ke=g.useCallback(C=>{if(f){r(t,C.length>0?C.map(se=>T?se:se.value):void 0);return}const W=C[0];if(!W){r(t,void 0);return}r(t,T?{value:W.value,label:W.label}:W.value)},[r,t,f,T]);g.useEffect(()=>{if(!j)return;const C=he.current;if(he.current=j,!C||!Q)return;Object.keys(j).some(se=>C[se]!==void 0&&C[se]!==j[se])&&r(t,void 0)},[N,Q,r,t]),g.useEffect(()=>{var be,De;if(f){if(J||T)return;const Ne=F.filter(_e=>!_e.label&&!oe.current[_e.value]);if(Ne.length===0||!(y!=null&&y.resolve))return;let Ue=!1;return Promise.all(Ne.map(async _e=>{try{const Ct=await y.resolve(_e.value,R);if(Ue||!Ct)return;oe.current[_e.value]=ct(Ct,B).name}catch{}})).then(()=>{Ue||q(_e=>_e+1)}),()=>{Ue=!0}}if(J){I(void 0),ue.current=void 0;return}if(!le){I(void 0),ue.current=void 0;return}if(((be=ue.current)==null?void 0:be.value)===le&&((De=ue.current)==null?void 0:De.label)===X)return;if(T&&X){I({id:le,name:X}),ue.current={value:le,label:X};return}if(I({id:le,name:X??le}),!(y!=null&&y.resolve)){ue.current={value:le,label:X};return}let C=!1;const W=le,se=X;return y.resolve(W,R).then(Ne=>{C||(Ne&&I(ct(Ne,B)),ue.current={value:W,label:se})}).catch(()=>{C||(ue.current={value:W,label:se})}),()=>{C=!0}},[J,le,X,T,f,F,y,R,B]);const Oe=g.useCallback(async(C,W=!1)=>{var be;if(J)return;if(!y){S("Search service not configured.");return}(be=pe.current)==null||be.abort();const se=new AbortController;pe.current=se,W?Te(!0):(ve(!0),Te(!1),S(null));try{const De=await y.search({query:C,cursor:W?z.current:void 0,signal:se.signal,params:R});if(se.signal.aborted)return;const Ne=(De.options??[]).map(Ue=>ct(Ue,B));G(W?Ue=>[...Ue,...Ne]:Ne),z.current=De.nextCursor,ye(((E==null?void 0:E.paginated)??!1)&&De.nextCursor!=null)}catch{if(se.signal.aborted)return;S("Failed to load results. Please try again.")}finally{se.signal.aborted||(W?Te(!1):ve(!1))}},[J,y,E==null?void 0:E.paginated,R,B]);g.useEffect(()=>{if(!Y)return;const C=W=>{me.current&&!me.current.contains(W.target)&&_(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[Y]),g.useEffect(()=>{var C;Y||((C=pe.current)==null||C.abort(),D(""),G([]),ye(!1),S(null),ve(!1),Te(!1),z.current=void 0)},[Y]),g.useEffect(()=>{if(!Y)return;if(k){G([]),ye(!1),S(null),z.current=void 0;return}if(!b&&!L){G([]),ye(!1),S(null),z.current=void 0;return}ae.current&&clearTimeout(ae.current);const C=b?300:0;return ae.current=setTimeout(()=>{G([]),ye(!1),z.current=void 0,Oe(b)},C),()=>{ae.current&&clearTimeout(ae.current)}},[b,Y,L,Oe,k,N]),Ie(c,t,r);const $e=Ee(t,i,c),Je=nt(a),U=ot(((Et=d==null?void 0:d.options)==null?void 0:Et.placeholder)??"Select an option");if(c===!1)return null;const te=()=>{D(""),G([]),ye(!1),S(null),z.current=void 0,_(!0)},Re=C=>{if(f){const W=ne.has(C.id);if(!W&&A)return;const se=W?F.filter(be=>be.value!==C.id):[...F,{value:C.id,label:C.name}];W||(oe.current[C.id]=C.name,q(be=>be+1)),ke(se),D("");return}ke([{value:C.id,label:C.name}]),I(C),ue.current={value:C.id,label:T?C.name:void 0},_(!1)},Pe=C=>{C.stopPropagation(),r(t,void 0),I(void 0)},Be=(C,W)=>{C.stopPropagation(),ke(F.filter(se=>se.value!==W))},Xe=C=>{(C.key==="Enter"||C.key===" ")&&Pe(C)},it=f?"":(V==null?void 0:V.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&&F.length>0&&n.jsx(s.Flex,{gap:"1",wrap:"wrap",mb:"1",children:F.map(C=>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:ce[C.value]??C.value}),P&&n.jsx("span",{role:"button",tabIndex:0,"aria-label":`Remove ${ce[C.value]??C.value}`,onMouseDown:W=>W.preventDefault(),onClick:W=>Be(W,C.value),onKeyDown:W=>{(W.key==="Enter"||W.key===" ")&&Be(W,C.value)},style:{lineHeight:1,color:"var(--gray-11)",cursor:"pointer"},children:"×"})]},C.value))}),n.jsxs("div",{ref:me,style:{position:"relative"},children:[n.jsx(s.TextField.Root,{id:t,value:Y?b:it,placeholder:Y&&(E!=null&&E.searchable)?"Search...":U.placeholder,"data-empty-answer":U["data-empty-answer"],disabled:!P,readOnly:Y&&!(E!=null&&E.searchable)||f&&!Y,style:Z?void 0:{outline:"2px solid var(--red-7)",outlineOffset:"-1px"},onChange:C=>{E!=null&&E.searchable&&(D(C.target.value),Y||te())},onFocus:()=>{P&&!Y&&te()},onKeyDown:C=>{C.key==="Escape"&&_(!1)},children:n.jsx(s.TextField.Slot,{side:"right",children:n.jsxs(s.Flex,{align:"center",gap:"1",children:[Q&&P&&n.jsx("span",{role:"button",tabIndex:0,onMouseDown:C=>C.preventDefault(),onClick:Pe,onKeyDown:Xe,style:{lineHeight:1,color:"var(--gray-9)",padding:"0 2px",cursor:"pointer"},"aria-label":"Clear selection",children:"×"}),Je?n.jsx(re.LockClosedIcon,{"aria-hidden":!0,"data-testid":"read-only-lock",style:{color:"var(--gray-10)"}}):n.jsx(re.ChevronDownIcon,{style:{transform:Y?"rotate(180deg)":void 0,transition:"transform 150ms"}})]})})}),Y&&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:J?n.jsx(s.Box,{p:"3",children:n.jsx(s.Text,{size:"2",color:"gray",children:J})}):n.jsx(s.ScrollArea,{style:{maxHeight:240},children:n.jsxs(s.Box,{p:"1",children:[je&&n.jsx(s.Flex,{justify:"center",p:"4",children:n.jsx(s.Spinner,{})}),!je&&x&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Text,{size:"2",color:"red",children:x})}),!je&&!x&&H.length===0&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Text,{size:"2",color:"gray",children:k?"Select the related field first.":b||L?"No results found.":"Type to search…"})}),H.map(C=>{const W=ne.has(C.id),se=A&&!W;return n.jsx(s.Box,{px:"3",py:"2",onMouseDown:be=>be.preventDefault(),onClick:()=>{se||Re(C)},"aria-disabled":se||void 0,style:{cursor:se?"not-allowed":"pointer",opacity:se?.5:1,borderRadius:"var(--radius-2)",backgroundColor:W?"var(--accent-3)":void 0},className:se?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:C.name}),f&&W&&n.jsx(s.Text,{size:"1",color:"gray",children:"✓"})]})},C.id)}),(E==null?void 0:E.paginated)&&ee&&!we&&n.jsx(s.Box,{px:"3",py:"2",children:n.jsx(s.Button,{variant:"ghost",size:"1",style:{width:"100%"},onMouseDown:C=>C.preventDefault(),onClick:()=>void Oe(b,!0),children:"Load more"})}),we&&n.jsx(s.Flex,{justify:"center",p:"2",children:n.jsx(s.Spinner,{})})]})})})]}),!Z&&n.jsx(s.Text,{color:"red",size:"1",children:Ce(l,o)}),u.description&&n.jsx(s.Text,{size:"1",color:"gray",children:u.description})]})})},Sr=K.withJsonFormsControlProps(io),lo=e=>{if(e)return/^\d{2}:\d{2}$/.test(e)?`${e}:00`:e},Dt=(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},ao=(e,r)=>Gt(`${e}T${r}`).format(),co=({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:Ce(o,r)}),i&&n.jsx(s.Text,{size:"1",color:"gray",children:i})]})})},Er=({data:e,handleChange:r,path:t,label:o,required:i,errors:l,schema:a,uischema:c,enabled:u,visible:d=!0})=>{var k;g.useEffect(()=>{d===!1&&r(t,void 0)},[d,t,r]);const f=Ee(t,i,d),m=nt(u);if(d===!1)return null;const p=l.length===0,h=typeof e=="string"?e:"",w=((k=c==null?void 0:c.options)==null?void 0:k.showSeconds)===!0,E=w?1:60,L=R=>n.jsx(co,{path:t,label:o,required:f,errors:l,description:a.description,children:R});if(a.format==="time")return L(n.jsx(s.TextField.Root,{type:"time",step:E,value:Dt(h,w),onChange:R=>r(t,lo(R.target.value)),disabled:!u,color:p?void 0:"red",id:t,children:m&&n.jsx(Ge,{})}));const B=a.format==="date-time",[M="",$=""]=h.split("T"),j=Dt($,w),N=(R,y)=>{if(!R){r(t,void 0);return}r(t,B?ao(R,y||"00:00"):R)};return L(n.jsxs(s.Flex,{gap:"2",align:"center",children:[n.jsx(s.TextField.Root,{type:"date",value:M,disabled:!u,color:p?void 0:"red",onChange:R=>N(R.target.value,j),id:t,style:{flex:1},children:m&&n.jsx(Ge,{})}),B&&n.jsx(s.TextField.Root,{type:"time",step:E,value:j,disabled:!u||!M,color:p?void 0:"red",onChange:R=>N(M,R.target.value),style:{flex:1}})]}))},Cr=v.rankWith(2,v.or(v.isDateControl,v.isDateTimeControl,v.isTimeControl)),uo=K.withJsonFormsControlProps(Er),qe="var(--form-steps-offset, 16px)",fo=e=>e.enabled?n.jsx(po,{...e}):n.jsx(ho,{...e}),po=({uischema:e,schema:r,path:t,renderers:o,cells:i,enabled:l})=>{var _;const a=K.useJsonForms(),c=a.core,u=nr(),d=(c==null?void 0:c.schema)??r,f=c==null?void 0:c.data,m=c==null?void 0:c.ajv,p=a.config,h=(_=a.i18n)==null?void 0:_.translate,w=(b,D)=>ur(h,b,D),E=Ar(e,t),L=E.length,B=L,M=g.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]),$=g.useMemo(()=>Ln(E.map(b=>Ye(b,f,m,p,t)),M,d,t,h),[e,t,f,m,p,M,d,h]),[j,N]=g.useState(0),[k,R]=g.useState(()=>{const b=(H,G)=>$[G].length===0&&Pn(Ye(H,f,m,p,t),f,t),D=E.findIndex((H,G)=>!b(H,G));return D===-1?B:D}),[y,T]=g.useState(new Set),O=Math.min(j,B),F=O===B,le=g.useEffectEvent(()=>{var b;return(b=u==null?void 0:u.onStepChange)==null?void 0:b.call(u,{step:O,count:L,last:O===B})});g.useEffect(()=>{le()},[O,L,B]);const X=g.useRef(null),ne=g.useRef(null),Q=g.useRef(O);if(g.useEffect(()=>{var H,G;if(Q.current===O)return;Q.current=O;const b=X.current,D=b&&parseFloat(getComputedStyle(b).scrollMarginTop)||0;b&&b.getBoundingClientRect().top<D&&((H=b.scrollIntoView)==null||H.call(b,{block:"start",behavior:"smooth"})),(G=ne.current)==null||G.focus({preventScroll:!0})},[O]),!L)return null;const oe=b=>{b>k&&b!==O||N(b)},de=()=>{var D,H;if((D=$[O])!=null&&D.length){T(G=>new Set(G).add(O)),(H=u==null?void 0:u.onInvalidStep)==null||H.call(u);return}const b=Math.min(O+1,B);N(b),R(G=>Math.max(G,b))},q=[...E.map(b=>Ir(b,h)),w("review")],ce=q.length,A=b=>{var D;return b===O?"current":b<L&&((D=$[b])!=null&&D.length)&&(y.has(b)||b<k)?"error":b<k||b<L&&b<O?"done":"todo"},J=(b,D)=>{var H;return D==="error"||D==="current"&&y.has(b)?((H=$[b])==null?void 0:H.length)??0:0},P=(b,D)=>{if(b===B)return w("noteReview");if(J(b,D)>0)return w("noteToFix",{count:J(b,D)});if(D==="done")return w("noteDone");const H=$n(Ye(E[b],f,m,p,t),f,t),G=H.count===1;return H.kind==="items"?w(G?"noteItem":"noteItems",{count:H.count}):w(G?"noteField":"noteFields",{count:H.count})},Z=F?void 0:yo(E[O],h),Y=$.map((b,D)=>({index:D,p:b})).filter(({p:b})=>b.length).map(({index:b,p:D})=>({key:String(b),label:`${q[b]}: ${D.map(H=>H.label).join(", ")}`,onClick:()=>{T(H=>new Set(H).add(b)),oe(b)}}));return n.jsxs(s.Flex,{ref:X,gap:"5",align:"start",style:{scrollMarginTop:qe},children:[n.jsx(s.Box,{asChild:!0,display:{initial:"none",sm:"block"},p:"4",style:{...Ze,flex:"0 0 248px",position:"sticky",top:qe,maxHeight:`calc(100vh - 2 * ${qe})`,overflowY:"auto"},children:n.jsx("nav",{"aria-label":w("navLabel"),children:n.jsx("ol",{style:{listStyle:"none",margin:0,padding:0},children:q.map((b,D)=>{const H=A(D);return n.jsxs("li",{style:{position:"relative"},children:[D<ce-1&&n.jsx("span",{"aria-hidden":!0,style:{position:"absolute",left:21,top:40,bottom:-4,width:2,borderRadius:1,background:H==="done"?"var(--green-9)":"var(--gray-a5)"}}),n.jsx(Rr,{index:D,label:b,note:P(D,H),errorCount:J(D,H),status:H,disabled:D>k,onSelect:()=>oe(D)})]},`${t}-step-${D}`)})})})}),n.jsxs(s.Box,{style:{...Ze,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:w("stepOf",{step:O+1,total:ce})}),n.jsx(s.Heading,{ref:ne,tabIndex:-1,size:"5",as:"h2",mt:"1",style:{outline:"none"},children:q[O]}),Z&&n.jsx(s.Text,{as:"p",size:"2",color:"gray",mt:"1",children:Z}),n.jsx(s.Progress,{value:(O+1)/ce*100,size:"1",mt:"4","aria-label":w("progressLabel")})]}),n.jsx(s.Box,{px:{initial:"4",sm:"6"},pb:"5","data-form-review":F?"":void 0,children:n.jsxs(rt.Provider,{value:F,children:[F&&(Y.length?n.jsx(Nt,{title:w("incompleteSteps"),items:Y}):n.jsx(s.Text,{as:"p",size:"2",color:"gray",mb:"5",children:w("reviewHint")})),E.map((b,D)=>{const H=F||D===O;return n.jsxs(s.Box,{hidden:!H,mb:F?"6":void 0,children:[F&&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:q[D]}),n.jsx(s.Button,{type:"button",variant:"ghost",onClick:()=>oe(D),"aria-label":w("editStep",{step:q[D]}),children:w("edit")})]}),!F&&y.has(D)&&$[D].length>0&&n.jsx(Nt,{title:w("missingFields"),items:$[D].map(G=>({key:G.path,label:G.label,onClick:()=>mo(G.path)}))}),n.jsx(Fr,{category:b,schema:r,path:t,renderers:o,cells:i,enabled:l&&!F})]},`${t}-${D}`)})]})}),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:[O>0&&n.jsxs(s.Button,{type:"button",variant:"ghost",color:"gray",size:"3",onClick:()=>N(O-1),children:[n.jsx(re.ChevronLeftIcon,{}),w("back")]}),n.jsx(s.Box,{flexGrow:"1"}),u==null?void 0:u.actions,O<B&&n.jsxs(s.Button,{type:"button",size:"3",onClick:de,children:[w("continue"),n.jsx(re.ChevronRightIcon,{})]})]})]})]})},Ze={background:"var(--color-panel-solid)",border:"1px solid var(--gray-a4)",borderRadius:"var(--radius-5)",boxShadow:"var(--shadow-2)"};function Rr({index:e,label:r,note:t,errorCount:o,status:i,disabled:l=!1,current:a="step",onSelect:c}){const u={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:c,disabled:l,"aria-current":i==="current"?a: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,...u[i]},children:i==="done"?n.jsx(re.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!=null&&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})]}),t&&n.jsx(s.Text,{as:"p",size:"1",color:o?"red":"gray",children:t})]})]})})}function mo(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 Nt({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(re.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 ho=({uischema:e,schema:r,path:t,renderers:o,cells:i})=>{var R;const l=(R=K.useJsonForms().i18n)==null?void 0:R.translate,a=(y,T)=>ur(l,y,T),c=nr(),u=Ar(e,t),d=u.length,f=(c==null?void 0:c.contentsLinks)??[],m=d+f.length>1,p=g.useEffectEvent(()=>{var y;return(y=c==null?void 0:c.onStepChange)==null?void 0:y.call(c,{step:d,count:d,last:!0})});g.useEffect(()=>{p()},[d]);const h=g.useRef([]),w=g.useRef(null),E=xo(h,w,d,m),L=g.useId(),B=y=>`${L}-section-${y}`,M=y=>{var F;(F=y==null?void 0:y.scrollIntoView)==null||F.call(y,{block:"start",behavior:"smooth"});const T="h1, h2, h3, h4, h5, h6",O=y!=null&&y.matches(T)?y:y==null?void 0:y.querySelector(T);O&&!O.hasAttribute("tabindex")&&O.setAttribute("tabindex","-1"),O==null||O.focus({preventScroll:!0})},$=g.useRef(null),j=u.map(y=>Ir(y,l)),N=[...j.map((y,T)=>({label:y,go:()=>M(h.current[T])})),...f.map(y=>({label:y.label,go:()=>M(document.getElementById(y.targetId))}))],k=n.jsx(rt.Provider,{value:!0,children:n.jsxs(s.Flex,{direction:"column",gap:"6",p:{initial:"4",sm:"6"},style:Ze,"data-form-review":"",children:[u.map((y,T)=>n.jsxs("section",{ref:O=>{h.current[T]=O},"aria-labelledby":B(T),style:{scrollMarginTop:qe},children:[n.jsx(s.Heading,{id:B(T),tabIndex:-1,size:"3",as:"h3",mb:"3",style:{outline:"none"},children:j[T]}),n.jsx(Fr,{category:y,schema:r,path:t,renderers:o,cells:i,enabled:!1})]},`${t}-${T}`)),n.jsx("div",{ref:w})]})});return m?n.jsxs(s.Flex,{gap:"5",align:"start",children:[n.jsx(s.Box,{asChild:!0,display:{initial:"none",sm:"block"},p:"4",style:{...Ze,flex:"0 0 248px",position:"sticky",top:qe,maxHeight:`calc(100vh - 2 * ${qe})`,overflowY:"auto"},children:n.jsx("nav",{"aria-label":a("contentsLabel"),children:n.jsx("ol",{style:{listStyle:"none",margin:0,padding:0},children:N.map((y,T)=>n.jsxs("li",{style:{position:"relative"},children:[T<N.length-1&&n.jsx("span",{"aria-hidden":!0,style:{position:"absolute",left:21,top:40,bottom:-4,width:2,borderRadius:1,background:"var(--gray-a5)"}}),n.jsx(Rr,{index:T,label:y.label,status:T===E?"current":"todo",current:"location",onSelect:y.go})]},`${t}-contents-${T}`))})})}),n.jsxs(s.Box,{style:{flex:1,minWidth:0},children:[n.jsx(s.Box,{display:{initial:"block",sm:"none"},mb:"3",children:n.jsxs(s.Select.Root,{value:"",onValueChange:y=>{var T;$.current=((T=N[Number(y)])==null?void 0:T.go)??null},children:[n.jsx(s.Select.Trigger,{placeholder:a("jumpTo"),"aria-label":a("jumpTo"),style:{width:"100%"}}),n.jsx(s.Select.Content,{position:"popper",onCloseAutoFocus:y=>{const T=$.current;T&&($.current=null,y.preventDefault(),T())},children:N.map((y,T)=>n.jsx(s.Select.Item,{value:String(T),children:y.label},`${t}-jump-${T}`))})]})}),k]})]}):k};function xo(e,r,t,o){const[i,l]=g.useState(0);return g.useEffect(()=>{if(!o)return;let a=0,c=!1;const u=()=>{a=0;let m=0;e.current.slice(0,t).forEach((L,B)=>{if(!L)return;const M=parseFloat(getComputedStyle(L).scrollMarginTop)||0;L.getBoundingClientRect().top<=M+1&&(m=B)});const p=r.current,h=e.current[0],w=e.current[t-1];if((c&&h?h.getBoundingClientRect().top<=(parseFloat(getComputedStyle(h).scrollMarginTop)||0)+1:!1)&&p&&w&&m<t-1){const L=go(p);p.getBoundingClientRect().top<=L&&w.getBoundingClientRect().top<L&&(m=t-1)}l(m)},d=()=>{a||(a=requestAnimationFrame(u))},f=()=>{c=!0,d()};return u(),document.addEventListener("scroll",f,{capture:!0,passive:!0}),window.addEventListener("resize",d),()=>{a&&cancelAnimationFrame(a),document.removeEventListener("scroll",f,{capture:!0}),window.removeEventListener("resize",d)}},[e,r,t,o]),i}function go(e){let r=window.innerHeight;for(let t=e.parentElement;t;t=t.parentElement){const o=getComputedStyle(t).overflowY;(o==="auto"||o==="scroll")&&(r=Math.min(r,t.getBoundingClientRect().bottom))}return r}function Ar(e,r){var a,c;const t=K.useJsonForms(),o=(a=t.core)==null?void 0:a.ajv,i=(c=t.core)==null?void 0:c.data,l=t.config;return Dn(e).filter(u=>!u.rule||!o||v.isVisible(u,i,r,o,l))}function Fr({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(K.JsonFormsDispatch,{uischema:a,schema:r,path:t,renderers:o,cells:i,enabled:l},`${t}-${c}`))})}function Ir(e,r){return v.deriveLabelForUISchemaElement(e,r??v.defaultTranslator)??e.label}function yo(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 kr=({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(K.JsonFormsDispatch,{uischema:d,schema:r,path:t,renderers:o,cells:i,enabled:l},`${t}-${f}`))})},Or=v.rankWith(1,v.uiTypeIs("VerticalLayout")),Dr=({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(K.JsonFormsDispatch,{uischema:d,schema:r,path:t,renderers:o,cells:i,enabled:l})},`${t}-${f}`))})},Nr=v.rankWith(1,v.uiTypeIs("HorizontalLayout")),Lr=({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(K.JsonFormsDispatch,{uischema:d,schema:r,path:t,renderers:o,cells:i,enabled:l},`${t}-${f}`))})]})},Mr=v.rankWith(1,v.uiTypeIs("Group")),zr=e=>e.visible===!1?null:or(e.uischema)?n.jsx(fo,{uischema:e.uischema,schema:e.schema,path:e.path,renderers:e.renderers,cells:e.cells,enabled:e.enabled}):n.jsx(bo,{...e}),bo=({uischema:e,schema:r,path:t,renderers:o,cells:i,enabled:l})=>{var m;const c=e.elements.filter(p=>p.type==="Category"),[u,d]=g.useState(((m=c[0])==null?void 0:m.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,h)=>n.jsx(s.Tabs.Trigger,{value:p.label,children:p.label},`${t}-${h}`))}),n.jsx(s.Box,{pt:"3",children:c.map((p,h)=>n.jsx(s.Tabs.Content,{value:p.label,children:n.jsx(s.Flex,{direction:"column",gap:"4",children:p.elements.map((w,E)=>n.jsx(K.JsonFormsDispatch,{uischema:w,schema:r,path:t,renderers:o,cells:i,enabled:l},`${t}-${h}-${E}`))})},`${t}-${h}`))})]})},$r=v.rankWith(1,v.uiTypeIs("Categorization"));function Ae(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(0)} MB`:e>=1024?`${(e/1024).toFixed(0)} KB`:`${e} B`}function Fe(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 vo=new Set(["image/png","image/jpeg","image/gif","image/webp","application/pdf","text/plain"]);function jo(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 wo(e){return vo.has((e.type??"").toLowerCase())}function To(e){const r=e.split(/[/\\]/).pop()??e,t=r.lastIndexOf(".");if(!(t<=0||t===r.length-1))return r.slice(t)}function So(e,r,t){Pr(new Blob([e],{type:t}),r)}function Pr(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 Eo(e,r){const t=await fetch(e);if(!t.ok)throw new Error(`Download failed (${t.status})`);Pr(await t.blob(),r)}const dt="Uploaded File";function Co(e,r,t){if(!e&&t.name)return t.name;const o=e?yt(e,r,Br(t.name??"",dt)):dt,i=Ro(To(t.name??"")??t.extension);return!i||o.toLowerCase().endsWith(i.toLowerCase())?o:`${o}${i}`}function Ro(e){return e&&/^\.[A-Za-z0-9]+$/.test(e)?e:void 0}const Ao=new Set(["/","\\","<",">",":",'"',"|","?","*"]),Fo=e=>Ao.has(e)||e.charCodeAt(0)<32||e.charCodeAt(0)===127;function Br(e,r){const t=Array.from(e,o=>Fo(o)?"_":o).join("").trim();return t===""||t.startsWith(".")?r:t}function yt(e,r,t){const o=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:{};return Br(st(e,o),t)}function Ur({open:e,onOpenChange:r,title:t,description:o,keepLabel:i,removeLabel:l,onConfirm:a}){return n.jsx(s.AlertDialog.Root,{open:e,onOpenChange:r,children:n.jsxs(s.AlertDialog.Content,{maxWidth:"460px",children:[n.jsx(s.AlertDialog.Title,{children:t}),n.jsx(s.AlertDialog.Description,{size:"2",children:o}),n.jsxs(s.Flex,{gap:"3",mt:"4",justify:"end",children:[n.jsx(s.AlertDialog.Cancel,{children:n.jsx(s.Button,{type:"button",variant:"soft",color:"gray",children:i})}),n.jsx(s.AlertDialog.Action,{children:n.jsx(s.Button,{type:"button",color:"red",onClick:a,children:l})})]})]})})}function Io(e){return e?Array.isArray(e)?e:[e]:[]}const ko=({data:e,handleChange:r,path:t,label:o,required:i,uischema:l,schema:a,enabled:c,errors:u,visible:d=!0})=>{var Te;const f=Qt(),m=(Te=K.useJsonForms().i18n)==null?void 0:Te.translate,[p,h]=g.useState(null),[w,E]=g.useState("");Ie(d,t,r);const L=Ee(t,i,d),B=!u||u.length===0,M=(a==null?void 0:a["x-file"])??{},$=(l==null?void 0:l.options)??{},j=M.maxFiles??$.maxFiles??1,N=M.maxSize??$.maxSize??5*1024*1024,k=M.accept??$.accept??"image/*,application/pdf",R=typeof M.fileName=="string"?M.fileName:void 0,y=j>1,T=c!==!1,[O,F]=g.useState(!1),[le,X]=g.useState(null),[ne,Q]=g.useState({}),[oe,de]=g.useState({}),q=g.useRef(new Set),ce=g.useRef(null),A=Io(e),J=A.length>=j,P=async x=>{var z;const S=(z=oe[x])==null?void 0:z.blobUrl;if(S)return{url:S};const V=f==null?void 0:f.getDownloadUrl;if(!V)return{};const I=await V(x);return{url:I==null?void 0:I.url,extension:I==null?void 0:I.extension,disposition:I==null?void 0:I.disposition}},Z=(x,S,V)=>{var I;return Co(R,{index:S},{name:(I=oe[x])==null?void 0:I.name,extension:V.extension})},Y=(x,S)=>{Q(V=>({...V,[x]:S}))},_=x=>{Q(S=>{if(!S[x])return S;const V={...S};return delete V[x],V})};g.useEffect(()=>()=>{q.current.forEach(x=>URL.revokeObjectURL(x)),q.current.clear()},[]);const b=g.useCallback(async x=>{if(X(null),A.length>=j){X(`Maximum ${j} file${j>1?"s":""} allowed.`);return}if(x.size>N){X(`File exceeds the ${Ae(N)} limit.`);return}if(!jo(x,k)){X(`Invalid type. Accepted: ${Fe(k)}`);return}if(!(f!=null&&f.onUpload)){X("Upload service not configured.");return}try{const S=await f.onUpload(x),V=URL.createObjectURL(x);q.current.add(V);const I={key:S.key,name:S.name??x.name,type:x.type||void 0,blobUrl:V};de(ae=>({...ae,[S.key]:I}));const z=[...A,S.key];r(t,y?z:z[0])}catch{X("Upload failed. Please try again."),ce.current&&(ce.current.value="")}},[A,j,N,k,f,t,r,y]);if(d===!1)return null;const D=x=>{x.preventDefault(),x.stopPropagation(),!(!T||J)&&F(x.type==="dragenter"||x.type==="dragover")},H=x=>{var S;x.preventDefault(),x.stopPropagation(),F(!1),!(!T||J)&&(S=x.dataTransfer.files)!=null&&S[0]&&b(x.dataTransfer.files[0])},G=x=>{var S;(S=x.target.files)!=null&&S[0]&&(b(x.target.files[0]),x.target.value="")},ee=x=>{if(!T)return;de(V=>{var ae;const I={...V},z=(ae=I[x])==null?void 0:ae.blobUrl;return z&&(URL.revokeObjectURL(z),q.current.delete(z)),delete I[x],I}),_(x);const S=A.filter(V=>V!==x);r(t,y?S.length>0?S:void 0:S[0])},ye=async(x,S,V)=>{var ae,pe;x.preventDefault(),_(S);const I=(ae=oe[S])==null?void 0:ae.blobUrl;if(I){(pe=window.open(I,"_blank","noopener,noreferrer"))==null||pe.focus();return}const z=window.open("","_blank");if(z){z.opener=null;try{const me=await P(S);if(!me.url){z.close(),Y(S,"Unable to open file.");return}if(me.disposition==="inline"){z.location.href=me.url;return}z.close(),await je(S,V,me)}catch{z.close(),Y(S,"Unable to open file.")}}},je=async(x,S,V)=>{_(x);try{const I=V??await P(x);if(!I.url){Y(x,"Unable to download file.");return}await Eo(I.url,Z(x,S,I))}catch{Y(x,"Unable to download file.")}};if(!T&&A.length===0)return null;const ve=j-A.length,we=T&&!J;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,L&&n.jsx(s.Text,{color:"red",children:" *"})]}),n.jsx(s.Text,{size:"1",color:"gray",children:y?`Up to ${j} files · ${Ae(N)} each · ${Fe(k)}`:`${Ae(N)} · ${Fe(k)}`})]}),n.jsx(s.Text,{as:"p",size:"2",role:"status",mb:"2",style:w?void 0:{display:"none"},children:w}),n.jsx(Ur,{open:p!==null,onOpenChange:x=>!x&&h(null),title:p?Le(m,"confirmTitle",{file:p.name}):"",description:Le(m,"confirmDescription"),keepLabel:Le(m,"keepFile"),removeLabel:Le(m,"removeConfirmed"),onConfirm:()=>{p&&(ee(p.key),E(Le(m,"removed",{file:p.name})),h(null))}}),A.map((x,S)=>{const V=S+1,I=oe[x],z=I==null?void 0:I.name,ae=R?Z(x,V,{}):z??dt,pe=!!(R&&z),me=ne[x],ue=!I||wo({type:I.type});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:ae}),pe&&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:[ue&&n.jsx(s.Button,{variant:"soft",color:"blue",size:"1",onClick:he=>void ye(he,x,V),children:"View"}),n.jsx(s.Tooltip,{content:"Download",children:n.jsx(s.IconButton,{variant:"ghost",color:"gray","aria-label":"Download",onClick:()=>void je(x,V),children:n.jsx(re.DownloadIcon,{})})}),n.jsx("span",{role:"img","aria-label":Le(m,"uploaded"),style:{display:"inline-flex"},children:n.jsx(re.CheckCircledIcon,{"aria-hidden":!0,style:{color:"var(--green-9)",width:18,height:18}})}),T&&n.jsxs(s.DropdownMenu.Root,{children:[n.jsx(s.DropdownMenu.Trigger,{children:n.jsx(s.IconButton,{type:"button",variant:"ghost",color:"gray","aria-label":Le(m,"moreActions",{file:ae}),children:n.jsx(re.DotsHorizontalIcon,{})})}),n.jsx(s.DropdownMenu.Content,{align:"end",children:n.jsx(s.DropdownMenu.Item,{color:"red",onSelect:()=>h({key:x,name:ae}),children:Le(m,"remove")})})]})]})]}),me&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:me})]},x)}),we&&n.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{var x;return(x=ce.current)==null?void 0:x.click()},onKeyDown:x=>{var S;(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),(S=ce.current)==null||S.click())},onDragEnter:D,onDragLeave:D,onDragOver:D,onDrop:H,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",O?"border-blue-500 bg-blue-50":le?"border-red-300 bg-red-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"].join(" "),children:[n.jsx("input",{ref:ce,type:"file",style:{display:"none"},accept:k,onChange:G}),n.jsx(s.Flex,{direction:"column",align:"center",gap:"2",children:le?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:le}),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:A.length>0?`Add another file (${ve} remaining)`:"Click to upload or drag and drop"}),n.jsxs(s.Text,{size:"1",color:"gray",children:[Ae(N)," max · ",Fe(k)]})]})})]}),T&&J&&y&&n.jsxs(s.Text,{size:"1",color:"gray",mt:"1",style:{display:"block",textAlign:"center"},children:["Maximum ",j," files uploaded. Remove one to replace it."]}),!B&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:Ce(u,o)})]})},_r=K.withJsonFormsControlProps(ko),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 Vr(e,r){return e!==!1&&r!==!0}class ft extends Error{}async function Oo(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 ft("This file has no sheets.");const l=r??i.SheetNames[0],a=i.Sheets[l];if(!a)throw new ft(`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 Do(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 ge extends Error{constructor(t,o){super(o??t);Rt(this,"code");this.code=t,this.name="FormulaError"}}const No=["IFS","IFERROR","AND","OR","NOT","ROUND","ROUNDUP","ROUNDDOWN","INDEX","VLOOKUP","HLOOKUP","SUM","AVERAGE","COUNT","DATE","TODAY"],Lo=["MAX","MIN","MAXA","MINA","MEDIAN","LARGE","SMALL","PERMUT","PERMUTATIONA","MATCH","SWITCH","SUBSTITUTE","TEXTJOIN","COUNTA","UPPER"],Mo=["YEAR","MONTH","DAY","WEEKDAY"],zo=["IF"],$o=["CONCATENATE","CONCAT","LEN","TRIM","LOWER","LEFT","RIGHT","MID","FIND","SEARCH"],Po=new Set([...No,...Lo,...Mo,...$o,...zo]),Bo=/"(?:[^"]|"")*"/g,Lt=new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(","g");function Uo(e){const r=e.replace(Bo,o=>" ".repeat(o.length));Lt.lastIndex=0;let t;for(;(t=Lt.exec(r))!==null;){const o=t[1].toUpperCase();if(!Po.has(o))throw new ge("NAME",`Function ${o} is not allowed.`)}}function _o(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 Hr(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function Ve(e){const r=Hr(e);return Array.isArray(r)?r.flat(1/0):[r]}function ie(e){const r=Hr(e);return Array.isArray(r)?r.flat(1/0)[0]:r}function Ke(e){return e===void 0?void 0:ie(e)}function xe(e){return e==null||e===""?"":typeof e=="boolean"?e?"TRUE":"FALSE":e instanceof Date?e.toLocaleDateString():String(e)}function Wo(e,r){return e instanceof r?e:new r(e.message||"#ERROR!")}function fe(e){return e.find(r=>r instanceof Error)}function Vo(e,r){const t=l=>{throw Wo(l,r)},o=(l,{checkArgsForErrors:a=!0}={})=>(...c)=>{const u=c.flatMap(Ve);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=ie(c),d=fe([u]);d&&t(d);const f=l(a?xe(u):u);return f instanceof Error?t(f):f};return{IF:(l,a,c,u)=>{const d=_o(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=Ve(l),u=ie(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=Ve(l),u=ie(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=[ie(l),ie(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=[ie(l),ie(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=ie(l),u=Ve(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(ie),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=[xe(ie(l)),xe(ie(a)),xe(ie(c))];u!==void 0&&d.push(ie(u));const f=fe(d);f&&t(f);const m=e.SUBSTITUTE(...d);return m instanceof Error?t(m):m},TEXTJOIN:(l,a,...c)=>{const u=xe(ie(l)),d=ie(a),f=c.flatMap(Ve).map(xe),m=fe([u,d]);m&&t(m);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=ie(l),u=ie(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(Ve),c=fe(a);c&&t(c);const u=e.CONCATENATE(...a.map(xe));return u instanceof Error?t(u):u},CONCAT:(...l)=>{const a=l.flatMap(Ve),c=fe(a);c&&t(c);const u=e.CONCAT(...a.map(xe));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=ie(l),u=Ke(a),d=fe([c]);d&&t(d);const f=e.LEFT(xe(c),u);return f instanceof Error?t(f):f},RIGHT:(l,a)=>{const c=ie(l),u=Ke(a),d=fe([c]);d&&t(d);const f=e.RIGHT(xe(c),u);return f instanceof Error?t(f):f},MID:(l,a,c)=>{const u=ie(l),d=ie(a),f=ie(c),m=fe([u,d,f]);m&&t(m);const p=e.MID(xe(u),d,f);return p instanceof Error?t(p):p},FIND:(l,a,c)=>{const u=ie(l),d=ie(a),f=Ke(c),m=fe([u,d]);m&&t(m);const p=e.FIND(xe(u),xe(d),f);return p instanceof Error?t(p):p},SEARCH:(l,a,c)=>{const u=ie(l),d=ie(a),f=Ke(c),m=fe([u,d]);m&&t(m);const p=e.SEARCH(xe(u),xe(d),f);return p instanceof Error?t(p):p}}}const Ho={"#REF!":"REF","#VALUE!":"VALUE","#DIV/0!":"DIV0","#NAME?":"NAME","#N/A":"NA","#NUM!":"NUM","#NULL!":"NULL"};function Mt(e){return Ho[e.error]??"ERROR"}function zt(e,r){if(e instanceof ge)return e;if(e instanceof r){const t=e.details;return t instanceof ge?t:t instanceof r?new ge(Mt(t),t.message):new ge(Mt(e),e.message)}return new ge("ERROR",e instanceof Error?e.message:void 0)}function qo(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 ge("REF");const o=t[r.col-1];return o==null||o===""?null:o}}function Xo(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=qo(e);if(t>e.length||o>a)throw new ge("REF");const c=Math.min(i,e.length),u=[];for(let d=t;d<=c;d++){const f=e[d-1],m=[];if(f!=null){const p=Math.min(l,f.length);for(let h=o;h<=p;h++){const w=f[h-1];m.push(w==null||w===""?null:w)}}u.push(m)}return u}}function Ko(e){if(e==null||e==="")return null;if(typeof e=="number"||typeof e=="string"||typeof e=="boolean"||e instanceof Date)return e;throw new ge("VALUE")}async function qr(e,r){if(typeof e!="string")throw new ge("ERROR");const t=e.trim();if(t==="")throw new ge("ERROR");const o=t.startsWith("=")?t.slice(1):t;Uo(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:Vo(l,c)});let d;try{d=u.parse(o,{row:1,col:1,sheet:"Sheet1"})}catch(f){throw zt(f,c)}if(d instanceof c)throw zt(d,c);return Ko(d)}async function Yo(e,r){return qr(r,{onCell:Jo(e),onRange:Xo(e)})}const $t=-1;async function Jr(e,r){const t=Object.keys(e);return qr(r,{onVariable:o=>{const i=t.indexOf(o);return i===-1?null:{row:$t,col:i+1}},onCell:o=>{if(o.row===$t)return e[t[o.col-1]]??null;throw new ge("REF")},onRange:()=>{throw new ge("REF")}})}const Xr={REF:"#REF!",VALUE:"#VALUE!",DIV0:"#DIV/0!",NAME:"#NAME?",ERROR:"#ERROR!",NA:"#N/A",NUM:"#NUM!",NULL:"#NULL!"};function bt(e){const r=e instanceof ge?e.code:"ERROR";return Xr[r]}async function Go(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:Xr.ERROR})):Promise.all(r.map(async t=>{try{if(!t||typeof t.label!="string"||typeof t.expression!="string"||typeof t.id!="string")throw new ge("ERROR");return{id:t.id,label:t.label,value:await Yo(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:bt(o)}}}))}function Pt(e){const r=new Set;for(const{id:t}of e){if(r.has(t))return t;r.add(t)}return null}function Kr(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=Pt(o);if(f)return`duplicate column id "${f}" — every declared column id must be unique.`}if(d){const f=Pt(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 Bt(e,r={}){const t=Kr(r);if(t)throw new Error(`x-spreadsheet: ${t}`);const{columnHeader:o,rowHeader:i,columns:l,rows:a}=r;return l&&l.length>0?Zo(e,l,o===!0):a&&a.length>0?Qo(e,a,i===!0):e}function Zo(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 Qo(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,m)=>{var p;d[f.id]=((p=e[m])==null?void 0:p[u])??null}),d})}function Yr(e){return!Array.isArray(e[0])}function es(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 pt(e,r){const t=o=>o instanceof Date?o.toISOString():o??null;return t(e)===t(r)}function ts(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&&pt(a.value,c.value)})}function rs(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)=>pt(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)&&pt(o[a],i[a]))}function ns(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)=>rs(i,o[l]))}function os(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e instanceof Date}function Gr(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 os(c)?c:null}));return[t,...i]}function ss(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 is=".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv",ls=10*1024*1024,ut=200,as=50,cs=[];function Ut(e){return e==null||e===""?"":e instanceof Date?e.toLocaleDateString():String(e)}const us=({data:e,handleChange:r,path:t,label:o,required:i,schema:l,enabled:a,readonly:c,errors:u,visible:d=!0})=>{Ie(d,t,r);const f=Ee(t,i,d),m=!u||u.length===0,p=Vr(a,c),h=(l==null?void 0:l["x-spreadsheet"])??{},w=(l==null?void 0:l["x-evaluate"])??cs,E=h.accept??is,L=h.maxSize??ls,B=h.columnHeader===!0,M=h.rowHeader===!0,$=h.columns,j=h.rows,N=Array.isArray($)&&$.length>0,k=Array.isArray(j)&&j.length>0,R=Kr({columnHeader:B,rowHeader:M,columns:$,rows:j}),y=h.showSheet!==!1,T=h.sheetName,O=h.persistSheet!==!1,F=e??null,[le,X]=g.useState(()=>F!=null&&F.sheet||Object.keys((F==null?void 0:F.derivations)??{}).length>0?"ready":"empty"),[ne,Q]=g.useState(null),[oe,de]=g.useState(!1),[q,ce]=g.useState(null),[A,J]=g.useState(null),P=g.useRef(null),Z=g.useRef(null),Y=(F==null?void 0:F.sheet)??null,_=g.useCallback(x=>{if(!Yr(x))return x;const S=k?j:N?$:void 0,V=Gr(x,S==null?void 0:S.map(I=>I.id));return k?ss(V):V},[N,k,$,j]),b=g.useMemo(()=>q??(Y?_(Y):null),[q,Y,_]),D=((A==null?void 0:A.matrix)===b?A.derivations:null)??(F==null?void 0:F.derivations)??{},H=b!=null||F!=null,G=g.useMemo(()=>{const x=N?1:0,S=k?1:0,V=b?b.slice(x):[],I=V.slice(0,ut),z=Math.min(as,Math.max(0,...I.map(ue=>Math.max(0,ue.length-S)))),ae=Array.from({length:z},(ue,he)=>he+S),pe="",me=k&&!N;return n.jsx(n.Fragment,{children:b&&y&&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:[!me&&n.jsx(s.Table.Header,{children:n.jsxs(s.Table.Row,{children:[n.jsx(s.Table.ColumnHeaderCell,{children:pe}),ae.map(ue=>{var he;return n.jsx(s.Table.ColumnHeaderCell,{children:N?((he=$==null?void 0:$[ue])==null?void 0:he.label)??"":Do(ue)},ue)})]})}),n.jsx(s.Table.Body,{children:I.map((ue,he)=>{var Oe;const ke=x+he;return n.jsxs(s.Table.Row,{children:[n.jsx(s.Table.RowHeaderCell,{style:k?{fontWeight:700,background:"var(--gray-a3)"}:void 0,children:k?((Oe=j==null?void 0:j[ke])==null?void 0:Oe.label)??"":N?"":ke+1}),ae.map($e=>n.jsx(s.Table.Cell,{children:Ut(ue[$e])},$e))]},he)})})]})}),V.length>ut&&n.jsxs(s.Text,{size:"1",color:"gray",mt:"1",style:{display:"block"},children:["Showing first ",ut," of ",V.length," rows"]})]})})},[b,y,N,k,$,j]),ee=g.useCallback(async x=>{if(Q(null),x.size>L){Q(`File exceeds the ${Ae(L)} limit.`);return}if(!E.split(",").map(z=>z.trim()).some(z=>z==="*"||z==="*/*"?!0:z.endsWith("/*")?x.type.startsWith(z.slice(0,-1)):z.startsWith(".")?x.name.toLowerCase().endsWith(z.toLowerCase()):x.type===z)){Q(`Invalid type. Accepted: ${Fe(E)}`);return}X("parsing");let I;try{const z=await x.arrayBuffer();I=(await Oo(z,T)).matrix}catch(z){X("error"),Q(z instanceof ft?z.message:"This doesn't look like a valid spreadsheet. Please check the file and try again.");return}if(N||k)try{I=_(Bt(I,{columnHeader:B,rowHeader:M,columns:$,rows:j}))}catch(z){X("error"),Q(z instanceof Error?z.message:"Failed to process this sheet.");return}Z.current=(e==null?void 0:e.sheet)??null,ce(I),X("ready")},[E,L,T,e,B,M,$,j,N,k,_]);if(g.useEffect(()=>{q!=null&&Y!=null&&Y!==Z.current&&ce(null)},[q,Y]),g.useEffect(()=>{if(R||w.length===0&&!O)return;let x=!1;const S=I=>{p&&(ts(F==null?void 0:F.derivations,I==null?void 0:I.derivations)&&ns(F==null?void 0:F.sheet,I==null?void 0:I.sheet)||(Z.current=(I==null?void 0:I.sheet)??null,r(t,I)))},V=b??[];if(V.length===0){F!=null&&S(void 0);return}return Go(V,w).then(I=>{if(x)return;let z;if(q!=null){if(O)try{z=Bt(V,{columnHeader:N,rowHeader:k,columns:$,rows:j})}catch(pe){Q(pe instanceof Error?pe.message:"Failed to process this sheet.");return}}else z=F==null?void 0:F.sheet;Q(null);const ae=es(I);J({matrix:V,derivations:ae}),S(z===void 0?{derivations:ae}:{sheet:z,derivations:ae})}),()=>{x=!0}},[b,q,w,p,O,N,k,$,j,R]),d===!1)return null;if(R)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: ",R]})]});if(!p&&!H)return null;const ye=x=>{x.preventDefault(),x.stopPropagation(),p&&de(x.type==="dragenter"||x.type==="dragover")},je=x=>{var S;x.preventDefault(),x.stopPropagation(),de(!1),p&&(S=x.dataTransfer.files)!=null&&S[0]&&ee(x.dataTransfer.files[0])},ve=x=>{var S;(S=x.target.files)!=null&&S[0]&&(ee(x.target.files[0]),x.target.value="")},we=()=>{p&&(ce(null),J(null),Z.current=null,Q(null),X("empty"),r(t,void 0))},Te=y&&b==null&&F!=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:" *"})]}),H&&p&&n.jsxs(n.Fragment,{children:[n.jsx(s.Tooltip,{content:"Replace spreadsheet",children:n.jsx(s.IconButton,{variant:"ghost",size:"1",onClick:()=>{var x;return(x=P.current)==null?void 0:x.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:we,"aria-label":"Remove spreadsheet",children:n.jsx(re.Cross2Icon,{})})})]})]}),n.jsxs(s.Text,{size:"1",color:"gray",children:[Ae(L)," max · ",Fe(E)]})]}),H&&ne&&n.jsx(s.Text,{size:"2",color:"red",mb:"2",style:{display:"block"},children:ne}),n.jsx("input",{ref:P,type:"file",style:{display:"none"},accept:E,onChange:ve}),p&&!H&&n.jsx("div",{role:"button",tabIndex:0,onClick:()=>{var x;return(x=P.current)==null?void 0:x.click()},onKeyDown:x=>{var S;(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),(S=P.current)==null||S.click())},onDragEnter:ye,onDragLeave:ye,onDragOver:ye,onDrop:je,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",oe?"border-blue-500 bg-blue-50":ne?"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:le==="parsing"?n.jsxs(n.Fragment,{children:[n.jsx(s.Spinner,{size:"3"}),n.jsx(s.Text,{size:"2",color:"gray",children:"Parsing spreadsheet…"})]}):ne?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:ne}),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:[Ae(L)," max · ",Fe(E)]})]})})}),G,Te&&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(D).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(D).map(([x,S])=>n.jsxs(s.Flex,{justify:"between",children:[n.jsx(s.Text,{size:"2",children:S.label}),S.error?n.jsx(s.Text,{size:"2",color:"red",children:S.error}):n.jsx(s.Text,{size:"2",children:Ut(S.value)})]},x))})]}),!m&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:Ce(u,o)})]})},Zr=K.withJsonFormsControlProps(us),Qr=v.rankWith(10,v.schemaMatches(e=>e.type==="object"&&typeof e["x-spreadsheet"]=="object")),ds="Sheet1",fs="xlsx";function ps(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 ms(e,r){if(!Yr(e))return e;const t=Gr(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 hs=({data:e,path:r,label:t,schema:o,visible:i=!0})=>{const[l,a]=g.useState(null),c=K.useJsonForms();if(i===!1)return null;const u=(o==null?void 0:o["x-spreadsheet-export"])??{},d=u.columns,f=u.sheetName??ds,m=u.fileType??fs,p=u.fileName??`export.${m}`,h=ps(d);if(h)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: ",h]})]});const w=Array.isArray(e)&&e.length>0,E=async()=>{var L,B;if(w){a(null);try{const M=await import("@e965/xlsx"),$=ms(e,d),j=M.utils.aoa_to_sheet($),N=M.utils.book_new();M.utils.book_append_sheet(N,j,f);const k=r.split(".").slice(0,-1).join("."),R=k?v.Resolve.data((L=c.core)==null?void 0:L.data,k):(B=c.core)==null?void 0:B.data;M.writeFile(N,yt(p,R,`export.${m}`),{bookType:m})}catch(M){a(M instanceof Error?M.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:!w,onClick:()=>void E(),children:[n.jsx(re.DownloadIcon,{})," Download Spreadsheet"]}),l&&n.jsx(s.Text,{size:"2",color:"red",style:{display:"block",marginTop:"var(--space-2)"},children:l})]})},en=K.withJsonFormsControlProps(hs),tn=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 Me extends Error{}const _t=5e6,xs=1024,gs=/^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["']/i,ys={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 bs(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 vs(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 js(e,r={}){var d;if(typeof e!="string")throw new Me("This file could not be read as text.");const t=e.charCodeAt(0)===65279?e.slice(1):e;if(t.trim()==="")throw new Me("This file is empty.");if(t.length>_t)throw new Me(`This document is too large to parse (over ${_t/1e6} million characters).`);const o=(d=gs.exec(t.slice(0,xs)))==null?void 0:d[1];if(o&&!/^utf-?8$/i.test(o))throw new Me(`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:m,col:p}=a.err;throw new Me(`Invalid XML at line ${m}, column ${p}: ${f}`)}const c=new i({...ys,removeNSPrefix:r.removeNamespaces===!0,isArray:bs(r.arrayPaths??[])});let u;try{u=c.parse(t)}catch(f){throw new Me(vs(f))}if(u==null||typeof u!="object"||Array.isArray(u))throw new Me("This document has no root element.");return u}function rn(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 ws(e,r,t){const o={};for(const[i,l]of Object.entries(t)){const a=rn(e,r,l);if(a===void 0)return;o[i]=a}return o}async function Ts(e,r){try{return{status:"ok",value:await Jr(e,r)}}catch(t){return{status:"error",error:bt(t)}}}function nn(e,r){return e==null?"":typeof e=="number"?e.toFixed(Ss(r)):e instanceof Date?e.toLocaleDateString():String(e)}function Ss(e){return Number.isFinite(e)?Math.min(100,Math.max(0,Math.trunc(e))):0}const ze={found:!1},Se=e=>({found:!0,value:e});function Wt(e){return e==null||e===""?ze:Array.isArray(e)||e instanceof Date?Se(e):typeof e=="object"?ze:typeof e=="string"||typeof e=="number"||typeof e=="boolean"?Se(e):ze}const Es=new Set(["true","1","yes","y"]),Cs=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 As(e,r,t){switch(r.as){case void 0:return Se(e);case"string":return Se(e instanceof Date?e.toISOString():String(e));case"number":{const o=e instanceof Date?e.getTime():Number(e);return Number.isFinite(o)?Se(r.decimals===void 0?o:nn(o,r.decimals)):ze}case"boolean":{const o=String(e).trim().toLowerCase();return Es.has(o)?Se(!0):Cs.has(o)?Se(!1):ze}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()?Se(u.format(r.format??"YYYY-MM-DD")):ze}const l=e instanceof Date?e.toISOString():String(e),a=r.format?o(l,r.format,!0):o(l);return a.isValid()?Se(a.format("YYYY-MM-DD")):ze}}}async function Fs(e,r){if(r.formula!==void 0){const t={};for(const[o,i]of Object.entries(r.inputs??{})){const l=Wt(v.Resolve.data(e,i));if(!l.found||Array.isArray(l.value))return ze;t[o]=l.value}try{return Se(await Jr(t,r.formula))}catch(o){throw new Error(`writeTo "${r.to}": ${bt(o)}`)}}if(r.from===void 0)throw new Error(`writeTo "${r.to}" needs either "from" or "formula".`);return Wt(v.Resolve.data(e,r.from))}const Qe="@_",on="#text",et=e=>e.split(".").filter(Boolean),sn=e=>e.startsWith(Qe)||e===on;function ln(e,r){if(typeof e.to!="string"||et(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=et(e.to);for(const[o,i]of t.entries()){if(i===Qe)return'"@_" needs an attribute name after it, e.g. "@_id".';if(sn(i)&&o<t.length-1)return`"${i}" must be the last segment — it belongs to the element before it.`}}return null}function Vt(e,r,t){const o=t?` To give "${r}" both text and attributes, write its text to "${r}.${on}".`:"";return new Error(`writeTo "${e}": "${r}" is written both as a value and as the parent of other values.${o}`)}function an(e){const r={},t=new Set([r]);for(const{to:o,value:i}of e){const l=et(o);if(l.length===0)continue;let a=r;for(const[d,f]of l.slice(0,-1).entries()){const m=a[f];if(m===void 0){const p={};t.add(p),a[f]=p,a=p}else if(t.has(m))a=m;else throw Vt(o,l.slice(0,d+1).join("."),l[d+1].startsWith(Qe))}const c=l[l.length-1],u=a[c];if(t.has(u)){const d=Object.keys(u).some(f=>f.startsWith(Qe));throw Vt(o,l.join("."),d)}a[c]=i}return r}const Is=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean";async function vt(e,r,t){const o=[];for(const i of r){const l=ln(i,t);if(l)throw new Error(`writeTo "${i.to}": ${l}`);const a=et(i.to),c=t==="export"&&sn(a[a.length-1]),u=m=>{if(!(c&&m==null)){if(c&&!Is(m)){const p=m 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:m})}};let d=await Fs(e,i);const f=d.found&&Array.isArray(d.value);if(d.found&&f&&i.writeTo){const m=await Promise.all(d.value.map(async p=>an(await vt(p,i.writeTo,t))));u(m);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 m=d.value instanceof Date?d.value.toISOString():String(d.value);Object.prototype.hasOwnProperty.call(i.map,m)&&(d=Se(i.map[m]))}if(d.found&&!f&&(d=await As(d.value,i,t)),!d.found){if(i.default===void 0)continue;u(i.default);continue}u(d.value)}return o}const ks=".xml,text/xml,application/xml",Os=5*1024*1024,Ds=({data:e,handleChange:r,path:t,label:o,required:i,schema:l,enabled:a,readonly:c,errors:u,visible:d=!0})=>{Ie(d,t,r);const f=Ee(t,i,d),m=!u||u.length===0,p=Vr(a,c),h=(l==null?void 0:l["x-xml"])??{},w=h.accept??ks,E=h.maxSize??Os,L=h.arrayPaths,B=h.removeNamespaces===!0,M=h.writeTo,$=h.writeBase??"root",j=h.persistDocument!==!1,N=K.useJsonForms(),k=e??null,[R,y]=g.useState(()=>k?"ready":"empty"),[T,O]=g.useState(null),[F,le]=g.useState(!1),X=g.useRef(null),ne=g.useRef(0),Q=k!=null,oe=M!==void 0&&M.length>0,de=g.useCallback(async P=>{var G;const Z=++ne.current;if(O(null),P.size>E){O(`File exceeds the ${Ae(E)} limit.`);return}if(!w.split(",").map(ee=>ee.trim()).some(ee=>ee==="*"||ee==="*/*"?!0:ee.endsWith("/*")?P.type.startsWith(ee.slice(0,-1)):ee.startsWith(".")?P.name.toLowerCase().endsWith(ee.toLowerCase()):P.type===ee)){O(`Invalid type. Accepted: ${Fe(w)}`);return}y("parsing");let b;try{const ee=await P.text();b=await js(ee,{arrayPaths:L,removeNamespaces:B})}catch(ee){if(Z!==ne.current)return;y("error"),O(ee instanceof Me?ee.message:"This doesn't look like a valid XML document. Please check the file and try again.");return}let D=[];if(M&&M.length>0)try{D=await vt(b,M,"import")}catch(ee){if(Z!==ne.current)return;y("error"),O(ee instanceof Error?ee.message:"This document could not be mapped onto the form.");return}if(Z!==ne.current)return;j&&r(t,b);const H=$==="parent"?t.split(".").slice(0,-1).join("."):"";for(const ee of D)(G=N.dispatch)==null||G.call(N,v.update(H?`${H}.${ee.to}`:ee.to,()=>ee.value));y("ready")},[w,E,L,B,M,$,j,t,r,N]);if(d===!1||!p&&!Q)return null;const q=P=>{P.preventDefault(),P.stopPropagation(),p&&le(P.type==="dragenter"||P.type==="dragover")},ce=P=>{var Z;P.preventDefault(),P.stopPropagation(),le(!1),p&&(Z=P.dataTransfer.files)!=null&&Z[0]&&de(P.dataTransfer.files[0])},A=P=>{var Z;(Z=P.target.files)!=null&&Z[0]&&(de(P.target.files[0]),P.target.value="")},J=()=>{p&&(++ne.current,O(null),y("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:" *"})]}),!oe&&Q&&p&&n.jsxs(n.Fragment,{children:[n.jsx(s.Tooltip,{content:"Replace document",children:n.jsx(s.IconButton,{variant:"ghost",size:"1",onClick:()=>{var P;return(P=X.current)==null?void 0:P.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:J,"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:[Ae(E)," max · ",Fe(w)]}),oe&&p&&n.jsxs(s.Button,{size:"1",variant:"soft",onClick:()=>{var P;return(P=X.current)==null?void 0:P.click()},disabled:R==="parsing",children:[R==="parsing"?n.jsx(s.Spinner,{size:"1"}):n.jsx(re.UploadIcon,{}),"Upload"]})]})]}),(oe||Q)&&T&&n.jsx(s.Text,{size:"2",color:"red",mb:"2",style:{display:"block"},children:T}),n.jsx("input",{ref:X,type:"file",style:{display:"none"},accept:w,onChange:A}),!oe&&p&&!Q&&n.jsx("div",{role:"button",tabIndex:0,onClick:()=>{var P;return(P=X.current)==null?void 0:P.click()},onKeyDown:P=>{var Z;(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),(Z=X.current)==null||Z.click())},onDragEnter:q,onDragLeave:q,onDragOver:q,onDrop:ce,style:{cursor:"pointer"},className:["border-2 border-dashed rounded-lg p-6 text-center","transition-all duration-200 ease-in-out",F?"border-blue-500 bg-blue-50":T?"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:R==="parsing"?n.jsxs(n.Fragment,{children:[n.jsx(s.Spinner,{size:"3"}),n.jsx(s.Text,{size:"2",color:"gray",children:"Parsing document…"})]}):T?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:T}),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:[Ae(E)," max · ",Fe(w)]})]})})}),!m&&n.jsx(s.Text,{color:"red",size:"1",mt:"2",style:{display:"block"},children:Ce(u,o)})]})},cn=K.withJsonFormsControlProps(Ds),un=v.rankWith(10,v.schemaMatches(e=>{const r=e["x-xml"];return e.type==="object"&&typeof r=="object"&&r!==null})),Ns="root",Ht="export.xml",Ls={format:!0,indentBy:" ",ignoreAttributes:!1,attributeNamePrefix:"@_",textNodeName:"#text",suppressBooleanAttributes:!1,processEntities:!0};function Ms(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 dn(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=ln(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=dn(o);if(l)return l}}return null}function zs({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.":dn(e)??(r===void 0?null:Ms(r)):"writeTo must be an array of { from | formula, to } entries."}function $s({version:e="1.0",standalone:r}){return{"@_version":e,"@_encoding":"UTF-8",...r&&{"@_standalone":r}}}function Ps(e){return e==null?!0:Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}const Bs=({path:e,label:r,schema:t,visible:o=!0})=>{var M,$;const i=(t==null?void 0:t["x-xml-export"])??{},l=i.rootElement??Ns,a=i.fileName??Ht,c=i.writeTo,u=i.writeBase??"root",d=i.declaration,f=zs(i),m=K.useJsonForms(),p=u==="parent"?e.split(".").slice(0,-1).join("."):"",h=p?v.Resolve.data((M=m.core)==null?void 0:M.data,p):($=m.core)==null?void 0:$.data,[w,E]=g.useState(null),L=Ps(h),B=g.useCallback(async()=>{if(c){E(null);try{const j=an(await vt(h,c,"export")),{XMLBuilder:N}=await import("fast-xml-parser"),k={...d&&{"?xml":$s(d)},[l]:j},R=new N(Ls).build(k);So(R,yt(a,h,Ht),"application/xml")}catch(j){E(j instanceof Error?j.message:"This export could not be built.")}}},[c,h,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:L,onClick:()=>void B(),children:[n.jsx(re.DownloadIcon,{}),"Download XML"]}),w&&n.jsx(s.Text,{size:"2",color:"red",style:{display:"block",marginTop:"var(--space-2)"},children:w})]})},fn=K.withJsonFormsControlProps(Bs),pn=v.rankWith(10,v.schemaMatches(e=>{const r=e["x-xml-export"];return e.type==="object"&&typeof r=="object"&&r!==null})),Us="{value}",_s=2,Ws={},Vs=({data:e,handleChange:r,path:t,label:o,schema:i,visible:l=!0})=>{var k;Ie(l,t,r);const a=i==null?void 0:i["x-computed"],c=(a==null?void 0:a.inputs)??Ws,u=(a==null?void 0:a.formula)??"",d=(a==null?void 0:a.format)??Us,f=(a==null?void 0:a.decimals)??_s,m=K.useJsonForms(),p=t.split(".").slice(0,-1).join("."),h=ws((k=m.core)==null?void 0:k.data,p,c),w=h?JSON.stringify(h):null,E=m.readonly===!0,[L,B]=g.useState(()=>typeof e=="number"?"ok":"unavailable"),[M,$]=g.useState(()=>typeof e=="number"?e:null),[j,N]=g.useState(null);return g.useEffect(()=>{if(!l)return;let R=!1;const y=T=>{E||T!==e&&r(t,T)};if(h===void 0){B("unavailable"),N(null),$(null),y(void 0);return}return B(T=>T==="ok"?T:"loading"),Ts(h,u).then(T=>{if(R)return;const O=T.status==="ok"&&typeof T.value=="number"&&Number.isFinite(T.value)?T.value:null;if(O===null){B("error"),N(T.status==="error"?T.error??"Unable to compute value.":"Computed value must be a number."),$(null),y(void 0);return}B("ok"),N(null),$(O),y(O)}),()=>{R=!0}},[w,u,l,E]),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}),L==="unavailable"?n.jsx(s.Text,{size:"2",color:"gray",children:"Not yet available."}):L==="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…"})]}):L==="error"?n.jsx(s.Text,{size:"2",color:"red",children:j}):n.jsx(s.Text,{size:"2",children:st(d,{value:nn(M,f)})}),i.description&&n.jsx(s.Text,{size:"1",color:"gray",children:i.description})]})})},mn=K.withJsonFormsControlProps(Vs),hn=v.rankWith(5,v.schemaMatches(e=>{const r=e["x-computed"];return e.type==="number"&&typeof r=="object"&&r!==null})),xn="seq",qt=2,Hs=e=>e==null||e==="",gn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0,qs=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}},jt=e=>typeof e=="object"&&e.name===xn&&e.arg!==void 0,Js=e=>e.every((r,t)=>!jt(r)||typeof e[t-1]!="object"&&typeof e[t+1]!="object"),Xs=e=>{const r=new Set;for(const t of xt(e))typeof t=="object"&&t.arg===void 0&&r.add(t.name);return[...r]},Ks=e=>{const r=[];for(const[t,o]of Object.entries((e==null?void 0:e.properties)??{})){const i=qs(o);i&&r.push([t,i])}return r},Ys=(e,r,t)=>{var i;const o={};for(const l of Xs(t.template)){const a=rn(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},Gs=e=>r=>{const t=r.trim()===""?qt:Number(r);return`${e}`.padStart(Number.isInteger(t)&&t>=0?t:qt,"0")},Zs=e=>{const r=o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");let t="";for(const o of xt(e))typeof o=="string"?t+=r(o):t+=jt(o)?"(\\d+)":".*?";return new RegExp(`^${t}$`)},Qs=(e,r,t)=>{var l,a;const o=Zs(t.template);let i=0;for(const c of e){const u=(l=gn(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},ei=(e,r,t,o,i,l)=>{const a=Ks(e);if(a.length===0)return r;const c=gn(r);if(!c)return r;const u={...c};for(const[d,f]of a){if(!Hs(u[d]))continue;const m=xt(f.template),p={};if(m.some(jt)){if(!Js(m)){console.warn(`x-template: {seq(…)} needs literal text between it and other placeholders; not numbering "${f.template}"`);continue}const h=Math.max(l[d]??0,Qs(t,d,f))+1;l[d]=h,p[xn]=Gs(h)}u[d]=st(f.template,Ys(o,i,f),p)}return u},Jt=["","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],Xt=["","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"];function ti(e){if(!Number.isInteger(e)||e<1||e>=100)return String(e);if(e<20)return Jt[e];const r=Math.floor(e/10),t=e%10;return t===0?Xt[r]:`${Xt[r]}-${Jt[t]}`}const Kt=" · ",ri=/\{([A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*)\}/g;function yn(e,r){return r.split(".").reduce((t,o)=>{if(!(t===null||typeof t!="object"))return t[o]},e)}function ni(e,r){return r.split(".").reduce((t,o)=>{var i;return(i=t==null?void 0:t.properties)==null?void 0:i[o]},e)}function oi(e,r){var o;const t=(e==null?void 0:e.oneOf)??(e==null?void 0:e.anyOf);return Array.isArray(t)?(o=t.find(i=>i.const===r))==null?void 0:o.title:void 0}function bn(e,r,t){var i;if(e==null||e==="")return"";if(typeof e=="object"&&!Array.isArray(e)){const l=e;return typeof l.label=="string"?l.label:"value"in l?bn(l.value,(i=r==null?void 0:r.properties)==null?void 0:i.value,t):""}const o=oi(r,e);return o||(typeof e=="number"?new Intl.NumberFormat(t).format(e):typeof e=="string"?e:"")}function Yt(e,r,t,o){return e.split(Kt).map(i=>{let l=0,a=0;const c=i.replace(ri,(u,d)=>{l++;const f=bn(yn(r,d),ni(t,d),o);return f&&a++,f});return l>0&&a===0?"":c.trim()}).filter(Boolean).join(Kt)}function si(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e)))return Number(e)}function ii(e,r,t){const o=new Intl.NumberFormat(t);return r.flatMap(i=>{const l=e.map(a=>si(yn(a,i.field))).filter(a=>a!==void 0);return l.length?[i.label.replace("{sum}",o.format(l.reduce((a,c)=>a+c,0)))]:[]})}const li=({path:e,items:r,itemsSchema:t,rootSchema:o,addItem:i,sequences:l,label:a,buttonRef:c,onAdded:u})=>{const d=K.useJsonForms(),f=()=>{var p;const m=ei(t,v.createDefaultValue(t,o),r,(p=d.core)==null?void 0:p.data,e.split(".").slice(0,-1).join("."),l.current);i&&i(e,m)(),u(r.length)};return n.jsx(s.Box,{mt:"2",children:n.jsxs(s.Button,{ref:c,type:"button",variant:"surface",onClick:f,children:[n.jsx(re.PlusIcon,{}),a]})})};function ai(e,r){var o;const t=(o=e.options)==null?void 0:o.detail;return t||(r.type==="object"||r.properties?{type:"VerticalLayout",elements:Object.keys(r.properties||{}).map(i=>({type:"Control",scope:`#/properties/${i}`}))}:{type:"Control",scope:"#"})}const ci=({data:e,path:r,schema:t,uischema:o,enabled:i,visible:l,addItem:a,removeItems:c,rootSchema:u,arraySchema:d,label:f,i18nKeyPrefix:m,required:p=!1,errors:h=""})=>{var me,ue,he,ke,Oe,$e,Je;const w=g.useRef({}),E=Ee(r,p,l),L=K.useJsonForms(),B=(me=L.i18n)==null?void 0:me.translate,M=(ue=L.i18n)==null?void 0:ue.locale,$=m??v.getI18nKeyPrefix(d??t,o,r),j=(U,te)=>Bn(B,U,te,$),[N,k]=g.useState(null),[R,y]=g.useState(null),[T,O]=g.useState(""),F=g.useRef(null),le=g.useRef([]),X=g.useRef(null),ne=Array.isArray(e)?e.length:0;g.useEffect(()=>{if(F.current===null)return;const U=le.current[Math.min(F.current,ne-1)]??X.current;F.current=null,U==null||U.focus()},[ne]);const Q=d?t:t.items,oe=d||t;if(l===!1||!Q||typeof Q!="object"||Array.isArray(Q))return null;const de=Q,q=Array.isArray(e)?e:[],ce=oe.title||"Array Items",A=o.options??{},J=A.display==="cards",P=i&&A.addable!==!1,Z=i&&A.removable!==!1,Y=A.itemLabel||"Item",_=A.addLabel||j("addItem"),b=A.emptyLabel||j("empty"),D=o.label===!1?"":f!==void 0?f:ce,H=D||ce,G=E||typeof oe.minItems=="number"&&oe.minItems>=1,ee=!h,ye=ee?"":q.length===0&&A.errorMessage||Ce(h,H),je=U=>A.summary?Yt(A.summary,U,de,M):"",ve=U=>`${Y} ${A.itemNumber==="word"?ti(U+1):U+1}`,we=U=>{const te=je(q[U]);return te?`${ve(U)} (${te})`:ve(U)},Te=U=>[j(U.length===1?"countOne":"countOther",{count:U.length}),...ii(U,A.totals??[],M)].join(" · "),x=q.length>0&&(J||(((he=A.totals)==null?void 0:he.length)??0)>0),S=((ke=L.core)==null?void 0:ke.validationMode)!=="ValidateAndHide"&&((Oe=L.core)==null?void 0:Oe.validationMode)!=="NoValidation",V=new Set;if(J&&S){const U=`${r}.`;for(const te of[...(($e=L.core)==null?void 0:$e.errors)??[],...((Je=L.core)==null?void 0:Je.additionalErrors)??[]]){const Re=v.getControlPath(te);Re.startsWith(U)&&V.add(Number(Re.slice(U.length).split(".")[0]))}}const I=U=>{if(!c)return;const te=c(r,[U]);te&&te()},z=()=>{if(N===null)return;const U=N,te=we(U),Re=q.filter((Pe,Be)=>Be!==U);I(U),O(Re.length&&x?j("removedTotals",{item:te,totals:Te(Re)}):j("removed",{item:te})),F.current=U,k(null)},ae=U=>{O(""),J&&y({index:U,isNew:!0})},pe=(U,te)=>n.jsx(K.JsonFormsDispatch,{schema:de,uischema:ai(o,de),path:`${r}.${U}`,enabled:te,renderers:void 0,cells:void 0});return n.jsxs(s.Box,{mb:"6",id:r,tabIndex:-1,style:{outline:"none"},children:[n.jsxs(s.Flex,{direction:"column",gap:"4",children:[D&&n.jsxs(s.Text,{as:"div",size:"4",weight:"bold",children:[D," ",G&&n.jsx(s.Text,{color:"red",children:"*"})]}),x&&n.jsx(s.Text,{as:"p",size:"2",weight:"medium",children:Te(q)}),n.jsx(s.Text,{as:"p",size:"2",role:"status",style:T?void 0:{display:"none"},children:T}),q.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:b})}),!ee&&n.jsx(s.Text,{color:"red",size:"1",children:ye}),q.map((U,te)=>{const Re=`${r}.${te}`;if(J){const Pe=je(U),Be=A.summaryDetail?Yt(A.summaryDetail,U,de,M):"",Xe=V.has(te);return n.jsx(s.Card,{size:"1",variant:"surface",style:Xe?{boxShadow:"inset 0 0 0 1px var(--red-8)"}:void 0,children:n.jsxs(s.Flex,{align:"center",gap:"3",children:[n.jsxs("button",{ref:it=>{le.current[te]=it},type:"button",onClick:()=>y({index:te,isNew:!1}),"aria-label":j("openItem",{item:we(te)}),className:"enabled:hover:bg-[var(--gray-a2)]",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:12,padding:8,border:0,borderRadius:"var(--radius-3)",background:"transparent",cursor:"pointer",textAlign:"left"},children:[n.jsx(s.Box,{"aria-hidden":!0,style:{background:"var(--accent-3)",color:"var(--accent-11)",padding:8,borderRadius:"var(--radius-2)",flexShrink:0,display:"flex"},children:n.jsx(re.FileTextIcon,{width:"18",height:"18"})}),n.jsxs(s.Box,{style:{flex:1,minWidth:0},children:[n.jsx(s.Text,{as:"p",size:"2",weight:"bold",children:Pe||ve(te)}),Be&&n.jsx(s.Text,{as:"p",size:"1",color:"gray",children:Be}),Xe&&n.jsx(s.Text,{as:"p",size:"1",color:"red",children:j("needsAttention")})]}),n.jsx(re.ChevronRightIcon,{"aria-hidden":!0})]}),Z&&n.jsxs(n.Fragment,{children:[n.jsx(s.Separator,{orientation:"vertical",size:"2"}),n.jsx(s.IconButton,{type:"button",variant:"ghost",color:"gray",onClick:()=>k(te),"aria-label":j("removeItem",{item:we(te)}),children:n.jsx(re.Cross2Icon,{})})]})]})},Re)}return n.jsx(s.Card,{size:"3",variant:"surface",ref:Pe=>{le.current[te]=Pe},tabIndex:-1,style:{outline:"none"},children:n.jsxs(s.Flex,{direction:"column",gap:"4",children:[n.jsxs(s.Flex,{justify:"between",align:"center",children:[n.jsx(s.Text,{size:"3",weight:"bold",children:ve(te)}),Z&&n.jsxs(s.Button,{type:"button",color:"red",variant:"soft",onClick:()=>k(te),"aria-label":j("removeItem",{item:we(te)}),children:[n.jsx(re.TrashIcon,{}),j("remove")]})]}),n.jsx(s.Box,{children:pe(te,i)})]})},Re)}),P&&n.jsx(li,{path:r,items:q,itemsSchema:de,rootSchema:u,addItem:a,sequences:w,label:_,buttonRef:X,onAdded:ae})]}),J&&R&&R.index<q.length&&n.jsx(s.Dialog.Root,{open:!0,onOpenChange:U=>!U&&y(null),children:n.jsxs(s.Dialog.Content,{maxWidth:"640px",children:[n.jsx(s.Dialog.Title,{children:ve(R.index)}),n.jsx(s.Dialog.Description,{size:"2",color:"gray",mb:"4",children:je(q[R.index])}),pe(R.index,i),n.jsxs(s.Flex,{gap:"3",mt:"4",justify:"between",children:[!R.isNew&&Z?n.jsxs(s.Button,{type:"button",color:"red",variant:"soft",onClick:()=>{const U=R.index;y(null),k(U)},children:[n.jsx(re.TrashIcon,{}),j("remove")]}):n.jsx("span",{}),n.jsxs(s.Flex,{gap:"3",children:[R.isNew&&n.jsx(s.Button,{type:"button",variant:"soft",color:"gray",onClick:()=>{var U;I(R.index),y(null),(U=X.current)==null||U.focus()},children:j("cancel")}),n.jsx(s.Dialog.Close,{children:n.jsx(s.Button,{type:"button",children:R.isNew?j("add"):j(i?"done":"close")})})]})]})]})}),n.jsx(Ur,{open:N!==null,onOpenChange:U=>!U&&k(null),title:N===null?"":j("confirmTitle",{item:we(N)}),description:j("confirmDescription"),keepLabel:j("keepItem"),removeLabel:j("removeConfirmed"),onConfirm:z})]})},mt=K.withJsonFormsArrayControlProps(ci),vn=v.rankWith(3,v.isObjectArrayControl),jn=({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})})},wn=v.rankWith(1,v.uiTypeIs("Label")),ui=v.rankWith(3,v.isPrimitiveArrayControl),di=[{tester:fr,renderer:Kn},{tester:mr,renderer:Gn},{tester:xr,renderer:Zn},{tester:yr,renderer:Qn},{tester:Tr,renderer:Sr},{tester:vr,renderer:Ft},{tester:jr,renderer:Ft},{tester:Cr,renderer:uo},{tester:Or,renderer:K.withJsonFormsLayoutProps(kr)},{tester:Nr,renderer:K.withJsonFormsLayoutProps(Dr)},{tester:Mr,renderer:K.withJsonFormsLayoutProps(Lr)},{tester:$r,renderer:K.withJsonFormsLayoutProps(zr)},{tester:Wr,renderer:_r},{tester:Qr,renderer:Zr},{tester:tn,renderer:en},{tester:un,renderer:cn},{tester:pn,renderer:fn},{tester:hn,renderer:mn},{tester:vn,renderer:mt},{tester:ui,renderer:mt},{tester:wn,renderer:jn}];exports.ArrayControl=mt;exports.ArrayControlTester=vn;exports.BooleanControl=hr;exports.BooleanControlTester=xr;exports.CategorizationLayoutRenderer=zr;exports.CategorizationLayoutTester=$r;exports.ComputedControl=mn;exports.ComputedControlTester=hn;exports.DateControl=Er;exports.DateControlTester=Cr;exports.FileControl=_r;exports.FileControlTester=Wr;exports.FormStepsProvider=On;exports.GroupLayoutRenderer=Lr;exports.GroupLayoutTester=Mr;exports.HorizontalLayoutRenderer=Dr;exports.HorizontalLayoutTester=Nr;exports.LIST_MESSAGES=lr;exports.LabelRenderer=jn;exports.LabelTester=wn;exports.NumberControl=pr;exports.NumberControlTester=mr;exports.RadioControl=gr;exports.RadioControlTester=yr;exports.STEPPER_MESSAGES=cr;exports.SearchSelectControl=Sr;exports.SearchSelectControlTester=Tr;exports.SearchServiceProvider=kn;exports.SelectControl=br;exports.SelectControlTester=vr;exports.SelectObjectControlTester=jr;exports.SpreadsheetControl=Zr;exports.SpreadsheetControlTester=Qr;exports.SpreadsheetExportControl=en;exports.SpreadsheetExportControlTester=tn;exports.TextControl=dr;exports.TextControlTester=fr;exports.UPLOAD_MESSAGES=ar;exports.UploadProvider=In;exports.VerticalLayoutRenderer=kr;exports.VerticalLayoutTester=Or;exports.XmlControl=cn;exports.XmlControlTester=un;exports.XmlExportControl=fn;exports.XmlExportControlTester=pn;exports.isStepperUiSchema=or;exports.radixRenderers=di;exports.searchSelectTargetSchema=gt;exports.useSearchService=tr;exports.useUpload=Qt;