@overmap-ai/forms 1.0.39 → 1.0.40-file-component-improvements.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.
- package/dist/forms.js +278 -262
- package/dist/forms.umd.cjs +14 -14
- package/package.json +1 -1
package/dist/forms.umd.cjs
CHANGED
|
@@ -53,22 +53,27 @@
|
|
|
53
53
|
*
|
|
54
54
|
* This source code is licensed under the ISC license.
|
|
55
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const El=R("circle-
|
|
56
|
+
*/const El=R("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
|
|
57
57
|
* @license lucide-react v0.542.0 - ISC
|
|
58
58
|
*
|
|
59
59
|
* This source code is licensed under the ISC license.
|
|
60
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const Il=R("circle-
|
|
61
|
+
*/const Il=R("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
|
62
62
|
* @license lucide-react v0.542.0 - ISC
|
|
63
63
|
*
|
|
64
64
|
* This source code is licensed under the ISC license.
|
|
65
65
|
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const Ol=R("circle-
|
|
66
|
+
*/const Ol=R("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
|
|
67
67
|
* @license lucide-react v0.542.0 - ISC
|
|
68
68
|
*
|
|
69
69
|
* This source code is licensed under the ISC license.
|
|
70
70
|
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const bl=R("circle-
|
|
71
|
+
*/const bl=R("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
72
|
+
* @license lucide-react v0.542.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const Nl=R("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
72
77
|
* @license lucide-react v0.542.0 - ISC
|
|
73
78
|
*
|
|
74
79
|
* This source code is licensed under the ISC license.
|
|
@@ -83,7 +88,7 @@
|
|
|
83
88
|
*
|
|
84
89
|
* This source code is licensed under the ISC license.
|
|
85
90
|
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const
|
|
91
|
+
*/const Tl=R("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/**
|
|
87
92
|
* @license lucide-react v0.542.0 - ISC
|
|
88
93
|
*
|
|
89
94
|
* This source code is licensed under the ISC license.
|
|
@@ -93,7 +98,7 @@
|
|
|
93
98
|
*
|
|
94
99
|
* This source code is licensed under the ISC license.
|
|
95
100
|
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/const
|
|
101
|
+
*/const Ml=R("copy-check",[["path",{d:"m12 15 2 2 4-4",key:"2c609p"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
|
97
102
|
* @license lucide-react v0.542.0 - ISC
|
|
98
103
|
*
|
|
99
104
|
* This source code is licensed under the ISC license.
|
|
@@ -113,12 +118,7 @@
|
|
|
113
118
|
*
|
|
114
119
|
* This source code is licensed under the ISC license.
|
|
115
120
|
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
-
*/const
|
|
117
|
-
* @license lucide-react v0.542.0 - ISC
|
|
118
|
-
*
|
|
119
|
-
* This source code is licensed under the ISC license.
|
|
120
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/const Dl=R("file-question-mark",[["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]]);/**
|
|
121
|
+
*/const Dl=R("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
|
|
122
122
|
* @license lucide-react v0.542.0 - ISC
|
|
123
123
|
*
|
|
124
124
|
* This source code is licensed under the ISC license.
|
|
@@ -253,7 +253,7 @@
|
|
|
253
253
|
*
|
|
254
254
|
* This source code is licensed under the ISC license.
|
|
255
255
|
* See the LICENSE file in the root directory of this source tree.
|
|
256
|
-
*/const at=R("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Cn=y.memo(r=>{const{ref:e,file:t,className:n,error:i,rightSlot:a,size:o,...s}=r;return d.jsxs(v.Card,{className:$e.cx(n,"flex w-full items-center gap-2"),ref:e,size:"xs",...s,children:[i?d.jsx(v.LuIcon,{icon:Dl,color:"var(--base-a11)"}):d.jsx(v.LuIcon,{icon:Fl,color:"var(--base-a11)"}),i?d.jsx(v.Text,{accentColor:"danger",className:"truncate",size:o,children:i}):t?d.jsx(v.Text,{className:"truncate",size:o,children:t.name}):d.jsx("div",{className:"flex w-full justify-center",children:d.jsx(v.Spinner,{})}),a]})});Cn.displayName="FileCard";function Jt(r){return Array.isArray(r)?r.every(e=>typeof e=="string"):!1}class er{constructor(){M(this,"observers",new Set)}notify(e){for(const t of this.observers)t(e)}observe(e){return this.observers.add(e),()=>{this.observers.delete(e)}}}class mn extends er{constructor(t){const{identifier:n}=t;super();M(this,"identifier");this.identifier=n}getOptions(){return{identifier:this.identifier}}setOptions(t){this.identifier=t.identifier??this.identifier,this.notify(this)}serialize(){return{type:this.type,identifier:this.identifier}}}class Ve extends mn{constructor(t){const{label:n,description:i=null,required:a,image:o,...s}=t;super(s);M(this,"label");M(this,"description");M(this,"required");M(this,"image");this.label=n,this.description=i,this.required=a,this.image=o}getError(t){if(!(!this.required&&this.isValueBlank(t))){if(this.required&&this.isValueBlank(t))return"This field is required.";for(const n of this.getFieldValidators()){const i=n(t);if(i)return i}}}serialize(){return{...super.serialize(),label:this.label,description:this.description,required:this.required,image:this.image}}getOptions(){return{...super.getOptions(),label:this.label,description:this.description,required:this.required,image:this.image}}setOptions(t){const{label:n,description:i=null,required:a,image:o,...s}=t;this.label=n??this.label,this.description=i??this.description,this.required=a??this.required,this.image=o??this.image,super.setOptions(s)}isValueBlank(t){return this.areValuesEqual(t,this.blankValue())}cleanValue(t){return t}isValueClean(t){return this.areValuesEqual(t,this.cleanValue(t))}cleanSerializedValue(t){return t}isSerializedValueClean(t){return this.areSerializedValuesEqual(t,this.cleanSerializedValue(t))}isSerializedValueBlank(t){return this.areSerializedValuesEqual(t,this.blankSerializedValue())}getFieldValidators(){return[]}}const ce=y.createContext({}),wn=r=>{const[e,t]=y.useState(null);return y.useEffect(()=>{const n=URL.createObjectURL(r);return t(n),()=>{URL.revokeObjectURL(n)}},[r]),e},Bt=y.memo(r=>{const{file:e,...t}=r,n=wn(e);return n?d.jsx("img",{src:n,alt:e.name,...t}):null});Bt.displayName="ImageFile";const ya=y.createContext(()=>{throw new Error("No ImageViewerProvider found")}),Pr=()=>y.useContext(ya),_n=y.memo(r=>{const{file:e,onClose:t}=r,n=y.useCallback(()=>{ta.saveAs(e,e.name)},[e]);return d.jsx(v.Overlay.Root,{open:!0,onOpenChange:t,children:d.jsxs(v.Overlay.Content,{onOpenAutoFocus:v.preventDefault,children:[d.jsxs(v.ButtonGroup,{className:"absolute right-0 top-0 flex items-center gap-2 p-2",accentColor:"base",variant:"ghost",children:[d.jsxs(v.Tooltip.Root,{children:[d.jsx(v.Tooltip.Trigger,{asChild:!0,children:d.jsx(v.IconButton,{onClick:n,"aria-label":"download",children:d.jsx(v.LuIcon,{icon:ca})})}),d.jsx(v.Tooltip.Content,{size:"sm",children:"Download"})]}),d.jsx(v.Separator,{orientation:"vertical",size:"sm"}),d.jsx(v.Overlay.Close,{asChild:!0,children:d.jsx(v.IconButton,{onClick:t,"aria-label":"close",children:d.jsx(v.LuIcon,{icon:at})})})]}),d.jsx("figure",{className:"flex size-full items-center justify-center overflow-hidden p-4",children:d.jsx(Bt,{className:"max-h-full max-w-full",file:e})})]})})});_n.displayName="ImageViewer";const Ca=y.memo(r=>{const{children:e}=r,[t,n]=y.useState(null),i=y.useCallback(()=>{n(null)},[]),a=y.useCallback(s=>{n(s(i))},[i]),o=y.useCallback(()=>{t&&(t.onClose&&t.onClose(),i())},[i,t]);return d.jsxs(ya.Provider,{value:a,children:[e,t&&d.jsx(_n,{file:t.file,onClose:o})]})});Ca.displayName="FileViewerProvider";const de=y.memo(r=>{const{label:e,error:t,description:n,required:i,children:a,inputId:o,image:s,size:l}=r,[u,c]=y.useState(void 0),f=Pr();y.useEffect(()=>{s instanceof Promise?s.then(c).catch(console.error):c(s)},[s]);const h=y.useCallback(()=>{u&&f(()=>({file:u}))},[f,u]),p=i?`${e} *`:e;return d.jsxs("div",{className:"flex flex-col gap-1",children:[u&&d.jsx(Bt,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:u,onClick:h}),(!!e||!!n)&&d.jsxs("div",{className:"flex flex-col",children:[d.jsx("label",{className:"w-max max-w-full",htmlFor:o,children:d.jsx(v.Text,{size:l,className:"text-wrap",children:p})}),!!n&&d.jsx(v.Text,{accentColor:"base",size:l,children:n})]}),a,!!t&&d.jsx(v.Text,{accentColor:"danger",size:l,children:t})]})});de.displayName="InputWithLabel";const ma=r=>r.map(e=>d.jsx(y.Fragment,{children:e.render()},e.identifier)),Br=r=>r.map(e=>d.jsx(y.Fragment,{children:e.render()},e.identifier)),me=r=>{const{field:e}=r,{field:{value:t,name:n,onChange:i,onBlur:a,disabled:o},fieldState:{isTouched:s,error:l}}=Ye.useController({name:e.identifier});return{value:t,name:n,disabled:o,isTouched:s,error:(l==null?void 0:l.message)??"",onChange:i,onBlur:a}},An=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),[u,c]=y.useState(""),[f,h]=y.useState(""),p=y.useCallback(S=>{o(S),a()},[o,a]),g=y.useCallback(S=>{n&&n.findIndex(O=>O===S.target.value.trim())>=0?h("All options must be unique"):S.target.value?h(""):h("Option cannot be empty"),c(S.target.value)},[c,n]),x=y.useCallback(()=>{if(f)return;if(!u.trim()){h("Option cannot be empty");return}const S=u.trim();p([...n,S]),c("")},[u,f,p,n]),m=y.useCallback(S=>{S.key==="Enter"&&(S.preventDefault(),x())},[x]),w=y.useCallback(S=>{const O=Array.from(n);O.splice(S,1),p(O)},[n,p]),A=y.useCallback(S=>{if(!S.destination)return;const O=S.source.index,N=S.destination.index,T=Array.from(n),[V]=T.splice(O,1);T.splice(N,0,V),p(T)},[p,n]),E=y.useCallback(()=>{a()},[a]);return d.jsx(gn.DragDropContext,{onDragEnd:A,children:d.jsxs(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:f||s,image:e.image,children:[(!l||n.length===0)&&d.jsxs("div",{className:"flex gap-2",children:[d.jsx(v.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:t,children:d.jsx(v.Input.Field,{value:u,onChange:g,onKeyDown:m,id:e.identifier,placeholder:e.placeholder,onBlur:E,name:i,disabled:l})}),d.jsx(v.IconButton,{size:t,accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!f||l,onClick:x,children:d.jsx(v.LuIcon,{icon:Ze})})]}),n.length!==0&&d.jsx(gn.Droppable,{droppableId:`${e.identifier}-droppable`,children:S=>d.jsxs("div",{className:"flex flex-col gap-1",...S.droppableProps,ref:S.innerRef,children:[n.map((O,N)=>d.jsx(gn.Draggable,{draggableId:`${O}-draggable`,index:N,isDragDisabled:l,children:({draggableProps:T,dragHandleProps:V,innerRef:L})=>d.jsxs(v.Badge,{...V,...T,ref:L,className:"flex items-center justify-between gap-2",accentColor:"base",size:t,variant:"soft",children:[d.jsx(v.Text,{className:"truncate",highContrast:!0,children:typeof O=="object"&&"label"in O?O.label:O}),d.jsx(v.IconButton,{className:"bg-transparent!",size:t,variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:l,onClick:()=>{w(N)},children:d.jsx(v.LuIcon,{icon:at})})]})},`${e.identifier}-${O}-${N}`)),S.placeholder]})})]})})});An.displayName="MultiStringFieldInput";class xt extends Ve{constructor(t){const{minimum_length:n,maximum_length:i,placeholder:a,...o}=t;super(o);M(this,"type","multi-string");M(this,"minLength");M(this,"maxLength");M(this,"placeholder");this.minLength=n??0,this.maxLength=i??1/0,this.placeholder=a??"Press enter to add a new option"}render(){return d.jsx(An,{field:this})}serialize(){return{...super.serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}duplicate(t){return new xt({...this.getOptions(),identifier:t})}setOptions(t){const{minimum_length:n,maximum_length:i,placeholder:a,...o}=t;this.minLength=n??this.minLength,this.maxLength=i??this.maxLength,this.placeholder=a??this.placeholder,super.setOptions(o)}serializeValue(t){return t}deserializeValue(t){return t}getFieldValidators(){const t=super.getFieldValidators();return t.push(n=>{if(n.length<this.minLength)return`Must have at least ${this.minLength} options.`}),t.push(n=>{if(n.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),t}static deserialize(t){return new xt(t)}isSerializedValue(t){return Jt(t)}isValue(t){return Jt(t)}blankValue(){return[]}areValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}}class tr extends Ve{constructor(t){const{options:n,...i}=t;super(i);M(this,"options");this.options=n.map(a=>(typeof a=="string"&&(a={label:a,value:a}),a))}serialize(){return{...super.serialize(),options:this.options}}getOptions(){return{...super.getOptions(),options:this.options}}setOptions(t){const{options:n,...i}=t;this.options=(n==null?void 0:n.map(a=>(typeof a=="string"&&(a={label:a,value:a}),a)))??this.options,super.setOptions(i)}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new xt({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${n}options`,minimum_length:2}),showDirectly:!0}]}}const Sn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{o(!!f),a()},[a,o]),c=y.useCallback(()=>{a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,error:s,image:e.image,required:e.required,children:d.jsx(v.Checkbox.Root,{id:e.identifier,name:i,checked:n??!1,onCheckedChange:u,onBlur:c,size:t,accentColor:"base",variant:"surface",disabled:l,children:d.jsx(v.Checkbox.Indicator,{children:d.jsx(v.LuIcon,{icon:ke})})})})});Sn.displayName="BooleanFieldInput";class yt extends Ve{constructor(t){super(t);M(this,"type","boolean")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}setOptions(t){super.setOptions(t)}duplicate(t){return new yt({...this.getOptions(),identifier:t})}static deserialize(t){return new yt(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Sn,{field:this})}isSerializedValue(t){return typeof t=="boolean"}isValue(t){return typeof t=="boolean"}blankValue(){return!1}blankSerializedValue(){return!1}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return t===n}}const En=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{const p=h.target.valueAsNumber,g=isNaN(p)?null:p;o(g)},[o]),c=y.useCallback(()=>{a()},[a]),f=y.useCallback(h=>{h.key==="Enter"&&h.preventDefault()},[]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(v.Input.Root,{accentColor:"base",variant:"surface",size:t,children:d.jsx(v.Input.Field,{id:e.identifier,name:i,onChange:u,onBlur:c,value:n??"",type:"number",min:e.minimum,max:e.maximum,step:e.integers?1:"any",placeholder:e.placeholder??"Enter a number",disabled:l,onKeyDown:f})})})});En.displayName="NumberFieldInput";class Pe extends Ve{constructor(t){const{minimum:n=Number.MIN_SAFE_INTEGER,maximum:i=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:o,...s}=t;super(s);M(this,"type","number");M(this,"minimum");M(this,"maximum");M(this,"integers");M(this,"placeholder");this.minimum=n,this.maximum=i,this.integers=a,this.placeholder=o}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${n}minimum`}),showDirectly:!1},{field:new Pe({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${n}maximum`}),showDirectly:!1},{field:new yt({label:"Integers",description:"Whole numbers only",required:!1,identifier:`${n}integers`}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.minimum,i=this.maximum;return typeof n=="number"&&t.push(a=>{if(typeof a=="number"&&a<n)return`Must be at least ${this.minimum}.`}),typeof i=="number"&&t.push(a=>{if(typeof a=="number"&&a>i)return`Must be at most ${this.maximum}.`}),this.integers&&t.push(a=>{if(typeof a=="number"&&!Number.isInteger(a))return"Must be a whole number."}),t}serialize(){return{...super.serialize(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}duplicate(t){return new Pe({...this.getOptions(),identifier:t})}setOptions(t){const{minimum:n,maximum:i,integers:a,placeholder:o,...s}=t;this.minimum=n??this.minimum,this.maximum=i??this.maximum,this.integers=a??this.integers,this.placeholder=o??this.placeholder,super.setOptions(s)}static deserialize(t){return new Pe(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(En,{field:this})}isSerializedValue(t){return this.isValue(t)}isValue(t){return typeof t=="number"&&!isNaN(t)||t===null}areValuesEqual(t,n){return t===n}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const rr=1e4;class In extends Ve{constructor(t){const{minLength:n,maxLength:i,placeholder:a="",...o}=t;super(o);M(this,"minLength");M(this,"maxLength");M(this,"placeholder");this.minLength=n?Math.max(n,0):void 0,this.maxLength=i?Math.max(i,0):rr,this.placeholder=a}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${n}minimum_length`,minimum:0,maximum:100,integers:!0}),showDirectly:!1},{field:new Pe({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${n}maximum_length`,minimum:1,maximum:rr,integers:!0}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators();return this.minLength&&t.push(n=>{if(this.minLength&&(!n||n.length<this.minLength))return!this.required&&!n?void 0:`Minimum ${this.minLength} character(s).`}),this.maxLength&&t.push(n=>{if(typeof n=="string"&&this.maxLength&&n.length>this.maxLength)return`Maximum ${this.maxLength} character(s).`}),t}serialize(){return{...super.serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minLength:this.minLength,maxLength:this.maxLength,placeholder:this.placeholder}}setOptions(t){const{minLength:n,maxLength:i,placeholder:a,...o}=t;this.minLength=n,this.maxLength=i??this.maxLength,this.placeholder=a,super.setOptions(o)}serializeValue(t){return t}deserializeValue(t){return t}isSerializedValue(t){return typeof t=="string"}isValue(t){return typeof t=="string"}blankValue(){return""}blankSerializedValue(){return""}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return t===n}}const On=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{o(f),a()},[a,o]),c=y.useCallback(()=>{a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(v.CheckboxGroup.Root,{id:e.identifier,name:i,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,values:n,onValuesChange:u,disabled:l,children:e.options.map((f,h)=>d.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(v.CheckboxGroup.Item,{value:f.value,onBlur:c,children:d.jsx(v.CheckboxGroup.ItemIndicator,{children:d.jsx(v.LuIcon,{icon:ke})})}),d.jsx(v.Text,{size:t,accentColor:"base",className:"truncate",children:f.label})]},`${e.identifier}-${f.value}-${h}`))})})});On.displayName="CheckboxListFieldInput";class Ct extends tr{constructor(t){super(t);M(this,"type","checkbox-list")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new Ct({...this.getOptions(),identifier:t})}static deserialize(t){return new Ct(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(On,{field:this})}isSerializedValue(t){if(!Jt(t))return!1;const n=new Set(this.options.map(({value:i})=>i));return t.every(i=>n.has(i))}isValue(t){return this.isSerializedValue(t)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}areValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}}const bn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),[u,c]=y.useState(!1),f=y.useCallback(p=>{o(p??null),a(),c(!1)},[o,a]),h=y.useCallback(p=>{c(p),p||a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.Popover.Root,{open:u,onOpenChange:h,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:d.jsxs(v.Button,{id:e.identifier,name:i,type:"button",className:"!justify-between",accentColor:"base",variant:"surface",size:t,disabled:l,children:[d.jsx(v.Text,{className:"truncate",highContrast:!!n,children:n?n.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd"}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Popover.Content,{align:"start",size:t,children:d.jsx(v.DayPicker,{size:t,required:!1,mode:"single",variant:"solid",selected:n??void 0,onSelect:f})})]})})});bn.displayName="DateFieldInput";class Lt extends Ve{constructor(t){super(t);M(this,"type","date")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new Lt({...this.getOptions(),identifier:t})}static deserialize(t){return new Lt(t)}setOptions(t){super.setOptions(t)}serializeValue(t){return t?t.toISOString():null}deserializeValue(t){return t?new Date(t):null}render(){return d.jsx(bn,{field:this})}isSerializedValue(t){return typeof t!="string"&&t!==null?!1:this.isValue(this.deserializeValue(t))}isValue(t){return!(!(t instanceof Date)&&t!==null||t instanceof Date&&isNaN(t.getTime()))}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return!t&&!n?!0:!t||!n?!1:t.getTime()===n.getTime()}}var W=(r=>(r.Text="text",r.Selection="selection",r.Numeric="numeric",r.Temporal="temporal",r.Capture="capture",r.Assessment="assessment",r.Verification="verification",r))(W||{});const Nn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{o(f),a()},[a,o]),c=y.useCallback(f=>{f||a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.Menu.Root,{onOpenChange:c,align:"start",children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsxs(v.Button,{id:e.identifier,name:i,className:"!justify-between",variant:"surface",type:"button",size:t,accentColor:"base",disabled:l,children:[d.jsx(v.Text,{className:"truncate",highContrast:n&&n.length>0,children:n&&n.length>0?n.join(", "):e.placeholder??"Select one or more..."}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Menu.Content,{size:t,children:d.jsx(v.Menu.Scroll,{children:d.jsxs(v.Menu.MultiSelectGroup,{values:n,onValuesChange:u,children:[d.jsxs(v.Menu.SelectAllItem,{children:[d.jsx(v.Menu.CheckboxItemIndicator,{children:f=>f?d.jsx(v.LuIcon,{icon:Vr}):d.jsx(v.LuIcon,{icon:ke})}),"Select all"]}),e.options.map((f,h)=>d.jsxs(v.Menu.MultiSelectItem,{value:f.value,children:[d.jsx(v.Menu.SelectedIndicator,{children:d.jsx(v.LuIcon,{icon:ke})}),f.label]},`${e.identifier}-${f.value}-${h}`))]})})})]})})});Nn.displayName="MultiSelectFieldInput";class it extends tr{constructor(t){const{placeholder:n,...i}=t;super(i);M(this,"type","multi-select");M(this,"placeholder");this.placeholder=n}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(t){return new it({...this.getOptions(),identifier:t})}setOptions(t){const{placeholder:n}=t;this.placeholder=n,super.setOptions(t)}static deserialize(t){return new it(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Nn,{field:this})}isSerializedValue(t){if(!Jt(t))return!1;const n=new Set(this.options.map(({value:i})=>i));return t.every(i=>n.has(i))}isValue(t){return this.isSerializedValue(t)}blankValue(){return[]}areValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}}const Tn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h??null),a()},[a,o]),c=y.useCallback(h=>{h||a()},[a]),f=y.useMemo(()=>e.options.find(h=>h.value===n),[e.options,n]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.Menu.Root,{onOpenChange:c,align:"start",children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsxs(v.Button,{id:e.identifier,name:i,className:"!justify-between",accentColor:"base",variant:"surface",type:"button",size:t,disabled:l,children:[d.jsx(v.Text,{className:"truncate",highContrast:!!f,children:f?f.label:e.placeholder??"Select one..."}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Menu.Content,{size:t,children:d.jsx(v.Menu.Scroll,{children:d.jsx(v.Menu.SelectGroup,{required:!1,value:n??void 0,onValueChange:u,children:e.options.map((h,p)=>d.jsxs(v.Menu.SelectItem,{value:h.value,children:[d.jsx(v.Menu.SelectedIndicator,{children:d.jsx(v.LuIcon,{icon:ke})}),h.label]},`${e.identifier}-${h.value}-${p}`))})})})]})})});Tn.displayName="SelectFieldInput";class ot extends tr{constructor(t){const{placeholder:n,...i}=t;super(i);M(this,"type","select");M(this,"placeholder");this.placeholder=n}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(t){return new ot({...this.getOptions(),identifier:t})}setOptions(t){const{placeholder:n}=t;this.placeholder=n,super.setOptions(t)}static deserialize(t){return new ot(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Tn,{field:this})}isSerializedValue(t){return typeof t!="string"&&t!==null?!1:new Set([null,...this.options.map(({value:i})=>i)]).has(t)}isValue(t){return this.isSerializedValue(t)}blankValue(){return null}areValuesEqual(t,n){return t===n}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const Mn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h)},[o]),c=y.useCallback(()=>{a()},[a]),f=y.useMemo(()=>Array.from({length:e.length},()=>U.v4()),[e.length]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.OneTimePasswordField.Root,{id:e.identifier,name:i,value:n,onValueChange:u,validationType:e.validationType,disabled:l,orientation:"horizontal",dir:"ltr",type:"text",autoComplete:"off",autoFocus:!1,autoSubmit:!1,className:"p-0.25 flex h-max w-full gap-1 overflow-x-auto",accentColor:"base",variant:"surface",size:t,onBlur:c,children:[f.map(h=>d.jsx(v.OneTimePasswordField.Input,{id:h},h)),d.jsx(v.OneTimePasswordField.HiddenInput,{})]})})});Mn.displayName="OTPFieldInput";class mt extends Ve{constructor(t){const{length:n,validationType:i,...a}=t;super(a);M(this,"type","otp");M(this,"length");M(this,"validationType");this.length=n,this.validationType=i}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Length",integers:!0,required:!1,minimum:1,maximum:16,identifier:`${n}length`}),showDirectly:!1},{field:new ot({label:"Type",required:!1,identifier:`${n}validationType`,options:[{value:"none",label:"Any"},{value:"numeric",label:"Numeric"},{value:"alpha",label:"Alpha"},{value:"alphanumeric",label:"Alphanumeric"}]}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.length;return t.push(i=>{if(i.length!=n)return`Must be ${n} characters.`}),t}serialize(){return{...super.serialize(),length:this.length,validationType:this.validationType}}getOptions(){return{...super.getOptions(),length:this.length,validationType:this.validationType}}duplicate(t){return new mt({...this.getOptions(),identifier:t})}setOptions(t){const{length:n,validationType:i,...a}=t;this.length=n??this.length,this.validationType=i??this.validationType,super.setOptions(a)}static deserialize(t){return new mt(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Mn,{field:this})}isSerializedValue(t){return typeof t=="string"}isValue(t){return typeof t=="string"}blankValue(){return""}areValuesEqual(t,n){return t===n}blankSerializedValue(){return""}areSerializedValuesEqual(t,n){return t===n}}const wt={pass:{label:"Pass",icon:El},fail:{label:"Fail",icon:bl},na:{label:"N/A",icon:Ol}},zt=Object.keys(wt);class st extends File{constructor(t,...n){super(...n);M(this,"uuid");this.uuid=t}static from(t,n){return new st(t,[n],n.name,{lastModified:n.lastModified,type:n.type})}}class kt extends Promise{constructor(t,n){super(t);M(this,"_uuid");this._uuid=n}get uuid(){return this._uuid}set uuid(t){this._uuid=t}static from(t,n){return new kt((i,a)=>{Promise.resolve(t).then(i).catch(a)},n)}then(t,n){const i=super.then(t,n);return i.uuid=this.uuid,i}catch(t){const n=super.catch(t);return n.uuid=this.uuid,n}finally(t){const n=super.finally(t);return n.uuid=this.uuid,n}}function wa(r){return Array.isArray(r)?r.every(e=>e instanceof kt||e instanceof st):!1}function Lr(r,e){const t=new Set(r.map(({uuid:i})=>i)),n=new Set(e.map(({uuid:i})=>i));return t.size===n.size&&t.isSubsetOf(n)}const Dn=y.memo(r=>{const{ref:e,file:t,error:n,rightSlot:i,className:a,size:o,...s}=r;return d.jsxs(v.Card,{className:$e.cx(a,"p-0! relative flex h-48 w-full flex-col items-center"),ref:e,size:"xs",...s,children:[!t&&!n&&d.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:d.jsx(v.Spinner,{})}),!!t&&!n&&d.jsx("div",{className:"flex w-full grow items-center justify-center overflow-hidden bg-clip-padding p-3",children:d.jsx(Bt,{className:"size-full max-w-full object-cover",file:t})}),d.jsx(v.Separator,{size:"full"}),(!!t||!!n)&&d.jsxs("div",{className:$e.cx("flex w-full items-center gap-2 self-end p-3",{"bg-transparent":!t}),children:[n?d.jsx(v.LuIcon,{color:"var(--base-11)",icon:fa}):t&&d.jsx(v.LuIcon,{color:"var(--base-11)",icon:ha}),d.jsx(v.Text,{className:"truncate",size:o,children:n??(t==null?void 0:t.name)}),i]})]})});Dn.displayName="ImageCard";const Fn=y.memo(r=>{const{file:e,...t}=r,n=wn(e);return n?d.jsx("video",{src:n,...t}):null});Fn.displayName="VideoFile";const Vn=y.memo(r=>{const{ref:e,file:t,className:n,error:i,rightSlot:a,size:o,...s}=r;return d.jsxs(v.Card,{className:$e.cx(n,"p-0! relative flex h-48 w-full flex-col items-center"),ref:e,size:"xs",...s,children:[!t&&!i&&d.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:d.jsx(v.Spinner,{})}),!!t&&!i&&d.jsx("div",{className:"flex w-full grow items-center justify-center overflow-hidden bg-clip-padding p-3",children:d.jsx(Fn,{className:"size-full max-w-full object-cover",file:t,controls:!0})}),d.jsx(v.Separator,{size:"full"}),(!!t||!!i)&&d.jsxs("div",{className:$e.cx("flex w-full items-center gap-2 self-end p-3",{"bg-transparent":!t}),children:[i?d.jsx(v.LuIcon,{color:"var(--base-11)",icon:fa}):t&&d.jsx(v.LuIcon,{color:"var(--base-11)",icon:jl}),d.jsx(v.Text,{className:"truncate",size:o,children:i??(t==null?void 0:t.name)}),a]})]})});Vn.displayName="VideoCard";const Pn=y.memo(r=>{const{fileOrPromise:e,onRemove:t,disabled:n,size:i}=r,[a,o]=y.useState(null),[s,l]=y.useState(null),u=Pr();y.useEffect(()=>{e instanceof kt?e.then(w=>{o(w)}).catch(w=>{l(w instanceof Error?w.message:"Unknown error")}):o(e)},[e]);const c=y.useCallback(()=>{if(!a)return;const w=new Blob([a]);ta.saveAs(w,a.name)},[a]),f=y.useCallback(()=>{t(e)},[t,e]),h=y.useCallback(()=>{if(!a)return;const w=URL.createObjectURL(a);window.open(w,"_blank"),URL.revokeObjectURL(w)},[a]),p=y.useCallback(()=>{a&&u(w=>({file:a,onDelete:n?void 0:()=>{f(),w()}}))},[n,f,u,a]),g=y.useMemo(()=>d.jsx("div",{className:"flex grow justify-end",children:d.jsxs(v.Menu.Root,{modal:!0,children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.IconButton,{onClick:v.stopPropagation,type:"button",variant:"ghost",accentColor:"base",size:i,children:d.jsx(v.LuIcon,{icon:da})})}),d.jsxs(v.Menu.Content,{size:i,children:[d.jsxs(v.Menu.Item,{onSelect:c,disabled:!a,children:[d.jsx(v.LuIcon,{icon:ca})," Download"]}),n?null:d.jsxs(d.Fragment,{children:[d.jsx(v.Menu.Separator,{}),d.jsxs(v.Menu.Item,{onSelect:f,children:[d.jsx(v.LuIcon,{icon:gt})," Delete"]})]})]})]})}),[n,f,c,a,i]),x=!!(a!=null&&a.type.startsWith("image/")),m=!!(a!=null&&a.type.startsWith("video/"));return x?d.jsx(Dn,{className:"cursor-pointer",onClick:p,file:a,error:s??void 0,rightSlot:g,size:i}):m?d.jsx(Vn,{className:"cursor-pointer",onClick:p,file:a,error:s??void 0,rightSlot:g,size:i}):d.jsx(Cn,{className:"cursor-pointer",file:a,error:s??void 0,onClick:h,rightSlot:g,size:i})});Pn.displayName="DisplayFile";const Bn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useRef(null),c=y.useCallback(S=>{const O=e.cleanValue({...n,status:S});o(O),a()},[e,a,o,n]),f=y.useCallback(S=>{const O=S.target.value,N={...n,notes:O};o(N)},[n,o]),h=y.useCallback(()=>{a()},[a]),p=y.useCallback(S=>{const O=n.files.filter(({uuid:N})=>N!==S.uuid);o({...n,files:O}),a()},[o,a,n]),g=y.useCallback(()=>{var S;(S=u.current)==null||S.click()},[]),x=y.useCallback(S=>{const O=Array.from(S.target.files??[]).map(T=>st.from(U.v4(),T)),N={...n,files:[...n.files,...O]};o(N),a()},[a,o,n]);y.useEffect(()=>{if(!u.current)return;const S=new AbortController;return u.current.addEventListener("cancel",()=>{a()},{signal:S.signal}),()=>{S.abort()}},[a,n]);const m=n.status&&e.showNotesAndFilesOn.includes(n.status),w=`${e.identifier}-status`,A=`${e.identifier}-notes`,E=`${e.identifier}-files`;return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(v.RadioGroup.Root,{id:w,className:"flex gap-2",name:i,value:n.status,disabled:l,accentColor:"base",variant:"surface",size:t,onValueChange:c,children:zt.map(S=>{const{label:O}=wt[S];return d.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(v.RadioGroup.Item,{value:S,children:d.jsx(v.RadioGroup.Indicator,{children:d.jsx(v.LuIcon,{icon:sa,className:"fill-current"})})}),d.jsx(v.Text,{size:t,accentColor:"base",className:"truncate",children:O})]},`${e.identifier}-${S}`)})}),m&&d.jsxs(d.Fragment,{children:[d.jsx("div",{children:d.jsx(v.TextArea,{id:A,value:n.notes??"",name:i,onChange:f,onBlur:h,className:"field-sizing-content min-h-12 w-full",placeholder:"Notes",resize:"vertical",accentColor:"base",variant:"surface",size:t,disabled:l})}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs(v.Button,{className:"w-max",size:t,variant:"soft",accentColor:"base",onClick:g,type:"button",disabled:l,children:[d.jsx(v.LuIcon,{icon:yn}),"Select files"]}),d.jsx("input",{id:E,name:i,type:"file",ref:u,multiple:!0,className:"hidden",onChange:x,value:""}),n.files.length>0&&d.jsx("div",{className:"flex h-max flex-wrap gap-2",children:n.files.map(S=>d.jsx(Pn,{size:t,fileOrPromise:S,onRemove:p,disabled:l},S.uuid))})]})]})]})})});Bn.displayName="PassFailFieldInput";const Ln=r=>typeof r=="string"&&zt.includes(r),_a=r=>!(r===null||typeof r!="object"||!("status"in r)||!Ln(r.status)||!("notes"in r)||typeof r.notes!="string"||!("files"in r)||!(Array.isArray(r.files)&&r.files.length===0)),Aa=r=>!(r===null||typeof r!="object"||!("status"in r)||!Ln(r.status)||!("notes"in r)||typeof r.notes!="string"||!("files"in r)||!wa(r.files)),Sa=r=>({status:r.status,notes:r.notes,files:[]}),Ea=r=>({status:r.status,notes:r.notes,files:[]}),Ia=(r,e)=>!(r.status!==e.status||r.notes!==e.notes||!Lr(r.files,e.files)),Oa=(r,e)=>!(r.status!==e.status||r.notes!==e.notes||r.files.length!==e.files.length);class _t extends Ve{constructor(t){const{showNotesAndFilesOn:n,...i}=t;super(i);M(this,"type","pass-fail");M(this,"showNotesAndFilesOn");this.showNotesAndFilesOn=n}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new it({identifier:`${n}showNotesAndFilesOn`,label:"Show notes and files on",description:"Show the notes and files on desired statuses.",options:zt.map(i=>{const{label:a}=wt[i];return{value:i,label:a}}),required:!1}),showDirectly:!1}]}serialize(){return{...super.serialize(),showNotesAndFilesOn:this.showNotesAndFilesOn}}getOptions(){return{...super.getOptions(),showNotesAndFilesOn:this.showNotesAndFilesOn}}duplicate(t){return new _t({...this.getOptions(),identifier:t})}setOptions(t){const{showNotesAndFilesOn:n,...i}=t;this.showNotesAndFilesOn=n??this.showNotesAndFilesOn,super.setOptions(i)}getFieldValidators(){const t=super.getFieldValidators(),n=this.showNotesAndFilesOn,i=this.blankValue();return n.length>0&&(t.push(a=>{if(!(!a.status||!n.includes(a.status))&&i.notes===a.notes)return"Notes is required."}),t.push(a=>{if(!(!a.status||!n.includes(a.status))&&Lr(i.files,a.files))return"Files is required."})),t}static deserialize(t){return new _t({...t,showNotesAndFilesOn:t.showNotesAndFilesOn??!1})}serializeValue(t){return Sa(t)}deserializeValue(t){return Ea(t)}render(){return d.jsx(Bn,{field:this})}isSerializedValue(t){return _a(t)}isValue(t){return Aa(t)}areValuesEqual(t,n){return Ia(t,n)}blankValue(){return{status:null,notes:"",files:[]}}cleanValue(t){return t.status&&this.showNotesAndFilesOn.includes(t.status)?t:{status:t.status,notes:"",files:[]}}cleanSerializedValue(t){return super.cleanSerializedValue(t)}blankSerializedValue(){return{status:null,notes:"",files:[]}}areSerializedValuesEqual(t,n){return Oa(t,n)}}const zn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h),a()},[a,o]),c=y.useCallback(()=>{a()},[a]),f=y.useCallback(()=>{o(null),a()},[a,o]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.RadioGroup.Root,{id:e.identifier,name:i,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,value:n??"",onValueChange:u,disabled:l,children:[e.options.map((h,p)=>d.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(v.RadioGroup.Item,{value:h.value,onBlur:c,children:d.jsx(v.RadioGroup.Indicator,{children:d.jsx(v.LuIcon,{icon:sa,className:"fill-current"})})}),d.jsx(v.Text,{size:t,accentColor:"base",className:"truncate",children:h.label})]},`${e.identifier}-${h.value}-${p}`)),!!n&&d.jsxs(v.Button,{onClick:f,className:"-mx-2 w-max",type:"button",variant:"ghost",accentColor:"base",size:t,children:[d.jsx(v.LuIcon,{icon:at}),"Clear"]})]})})});zn.displayName="RadioFieldInput";class At extends tr{constructor(t){super(t);M(this,"type","radio")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new At({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){return new At(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(zn,{field:this})}isSerializedValue(t){return typeof t!="string"&&t!==null?!1:new Set([null,...this.options.map(({value:i})=>i)]).has(t)}isValue(t){return this.isSerializedValue(t)}blankValue(){return null}areValuesEqual(t,n){return t===n}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const Yl=$e.cva(["group flex cursor-pointer items-center justify-center text-yellow-500 transition-colors disabled:pointer-events-none disabled:opacity-50"],{variants:{size:{xs:["size-5"],sm:["size-6"],md:["size-7"],lg:["size-8"],xl:["size-9"]}}}),kn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h),a()},[a,o]),c=y.useCallback(()=>{o(null),a()},[a,o]),f=Array.from({length:e.maxRating},(h,p)=>p+1);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs("div",{className:"flex flex-row items-center gap-1",children:[d.jsx(v.Rating.Root,{id:e.identifier,name:i,className:"flex items-center gap-0.5",value:n,onValueChange:u,disabled:l,children:f.map(h=>d.jsx(v.Rating.Item,{value:h,className:Yl({size:t}),children:d.jsx(v.LuIcon,{icon:xa,className:"size-full group-data-[active=true]:fill-current"})},`${e.identifier}-${h}`))}),!l&&n!==null&&d.jsx(v.IconButton,{onClick:c,type:"button",variant:"ghost",accentColor:"base",size:t,children:d.jsx(v.LuIcon,{icon:at})})]})})});kn.displayName="RatingFieldInput";class St extends Ve{constructor(t){const{maxRating:n,...i}=t;super(i);M(this,"type","rating");M(this,"maxRating");this.maxRating=n}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Max Rating",description:"Maximum rating value",integers:!0,required:!1,minimum:1,maximum:10,identifier:`${n}maxRating`}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.maxRating;return t.push(i=>{if(typeof i=="number"&&(i<1||i>n))return`Rating must be between 1 and ${n}.`}),t}serialize(){return{...super.serialize(),maxRating:this.maxRating}}getOptions(){return{...super.getOptions(),maxRating:this.maxRating}}duplicate(t){return new St({...this.getOptions(),identifier:t})}setOptions(t){const{maxRating:n,...i}=t;this.maxRating=n??this.maxRating,super.setOptions(i)}static deserialize(t){return new St(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(kn,{field:this})}isSerializedValue(t){return this.isValue(t)}isValue(t){return typeof t=="number"&&!isNaN(t)||t===null}areValuesEqual(t,n){return t===n}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const ba=y.createContext(()=>{throw new Error("No ScannerProvider found")}),Zl=()=>y.use(ba);function Kl(r,e){var t=Object.setPrototypeOf;t?t(r,e):r.__proto__=e}function Ql(r,e){e===void 0&&(e=r.constructor);var t=Error.captureStackTrace;t&&t(r,e)}var Jl=function(){var r=function(t,n){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,a){i.__proto__=a}||function(i,a){for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(i[o]=a[o])},r(t,n)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),eu=function(r){Jl(e,r);function e(t,n){var i=this.constructor,a=r.call(this,t,n)||this;return Object.defineProperty(a,"name",{value:i.name,enumerable:!1,configurable:!0}),Kl(a,i.prototype),Ql(a),a}return e}(Error),tu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Ue=function(r){tu(e,r);function e(t){t===void 0&&(t=void 0);var n=r.call(this,t)||this;return n.message=t,n}return e.prototype.getKind=function(){var t=this.constructor;return t.kind},e.kind="Exception",e}(eu),ru=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Ke=function(r){ru(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="ArgumentException",e}(Ue),nu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),k=function(r){nu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="IllegalArgumentException",e}(Ue),iu=function(){function r(e){if(this.binarizer=e,e===null)throw new k("Binarizer must be non-null.")}return r.prototype.getWidth=function(){return this.binarizer.getWidth()},r.prototype.getHeight=function(){return this.binarizer.getHeight()},r.prototype.getBlackRow=function(e,t){return this.binarizer.getBlackRow(e,t)},r.prototype.getBlackMatrix=function(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix},r.prototype.isCropSupported=function(){return this.binarizer.getLuminanceSource().isCropSupported()},r.prototype.crop=function(e,t,n,i){var a=this.binarizer.getLuminanceSource().crop(e,t,n,i);return new r(this.binarizer.createBinarizer(a))},r.prototype.isRotateSupported=function(){return this.binarizer.getLuminanceSource().isRotateSupported()},r.prototype.rotateCounterClockwise=function(){var e=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new r(this.binarizer.createBinarizer(e))},r.prototype.rotateCounterClockwise45=function(){var e=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new r(this.binarizer.createBinarizer(e))},r.prototype.toString=function(){try{return this.getBlackMatrix().toString()}catch{return""}},r}(),au=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),we=function(r){au(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.getChecksumInstance=function(){return new e},e.kind="ChecksumException",e}(Ue),ou=function(){function r(e){this.source=e}return r.prototype.getLuminanceSource=function(){return this.source},r.prototype.getWidth=function(){return this.source.getWidth()},r.prototype.getHeight=function(){return this.source.getHeight()},r}(),ie=function(){function r(){}return r.arraycopy=function(e,t,n,i,a){for(;a--;)n[i++]=e[t++]},r.currentTimeMillis=function(){return Date.now()},r}(),su=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Un=function(r){su(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="IndexOutOfBoundsException",e}(Ue),lu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Na=function(r){lu(e,r);function e(t,n){t===void 0&&(t=void 0),n===void 0&&(n=void 0);var i=r.call(this,n)||this;return i.index=t,i.message=n,i}return e.kind="ArrayIndexOutOfBoundsException",e}(Un),uu=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},fe=function(){function r(){}return r.fill=function(e,t){for(var n=0,i=e.length;n<i;n++)e[n]=t},r.fillWithin=function(e,t,n,i){r.rangeCheck(e.length,t,n);for(var a=t;a<n;a++)e[a]=i},r.rangeCheck=function(e,t,n){if(t>n)throw new k("fromIndex("+t+") > toIndex("+n+")");if(t<0)throw new Na(t);if(n>e)throw new Na(n)},r.asList=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e},r.create=function(e,t,n){var i=Array.from({length:e});return i.map(function(a){return Array.from({length:t}).fill(n)})},r.createInt32Array=function(e,t,n){var i=Array.from({length:e});return i.map(function(a){return Int32Array.from({length:t}).fill(n)})},r.equals=function(e,t){if(!e||!t||!e.length||!t.length||e.length!==t.length)return!1;for(var n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0},r.hashCode=function(e){var t,n;if(e===null)return 0;var i=1;try{for(var a=uu(e),o=a.next();!o.done;o=a.next()){var s=o.value;i=31*i+s}}catch(l){t={error:l}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return i},r.fillUint8Array=function(e,t){for(var n=0;n!==e.length;n++)e[n]=t},r.copyOf=function(e,t){return e.slice(0,t)},r.copyOfUint8Array=function(e,t){if(e.length<=t){var n=new Uint8Array(t);return n.set(e),n}return e.slice(0,t)},r.copyOfRange=function(e,t,n){var i=n-t,a=new Int32Array(i);return ie.arraycopy(e,t,a,0,i),a},r.binarySearch=function(e,t,n){n===void 0&&(n=r.numberComparator);for(var i=0,a=e.length-1;i<=a;){var o=a+i>>1,s=n(t,e[o]);if(s>0)i=o+1;else if(s<0)a=o-1;else return o}return-i-1},r.numberComparator=function(e,t){return e-t},r}(),$=function(){function r(){}return r.numberOfTrailingZeros=function(e){var t;if(e===0)return 32;var n=31;return t=e<<16,t!==0&&(n-=16,e=t),t=e<<8,t!==0&&(n-=8,e=t),t=e<<4,t!==0&&(n-=4,e=t),t=e<<2,t!==0&&(n-=2,e=t),n-(e<<1>>>31)},r.numberOfLeadingZeros=function(e){if(e===0)return 32;var t=1;return e>>>16||(t+=16,e<<=16),e>>>24||(t+=8,e<<=8),e>>>28||(t+=4,e<<=4),e>>>30||(t+=2,e<<=2),t-=e>>>31,t},r.toHexString=function(e){return e.toString(16)},r.toBinaryString=function(e){return String(parseInt(String(e),2))},r.bitCount=function(e){return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),e=e+(e>>>4)&252645135,e=e+(e>>>8),e=e+(e>>>16),e&63},r.truncDivision=function(e,t){return Math.trunc(e/t)},r.parseInt=function(e,t){return t===void 0&&(t=void 0),parseInt(e,t)},r.MIN_VALUE_32_BITS=-2147483648,r.MAX_VALUE=Number.MAX_SAFE_INTEGER,r}(),_e=function(){function r(e,t){e===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=e,t==null?this.bits=r.makeArray(e):this.bits=t)}return r.prototype.getSize=function(){return this.size},r.prototype.getSizeInBytes=function(){return Math.floor((this.size+7)/8)},r.prototype.ensureCapacity=function(e){if(e>this.bits.length*32){var t=r.makeArray(e);ie.arraycopy(this.bits,0,t,0,this.bits.length),this.bits=t}},r.prototype.get=function(e){return(this.bits[Math.floor(e/32)]&1<<(e&31))!==0},r.prototype.set=function(e){this.bits[Math.floor(e/32)]|=1<<(e&31)},r.prototype.flip=function(e){this.bits[Math.floor(e/32)]^=1<<(e&31)},r.prototype.getNextSet=function(e){var t=this.size;if(e>=t)return t;var n=this.bits,i=Math.floor(e/32),a=n[i];a&=~((1<<(e&31))-1);for(var o=n.length;a===0;){if(++i===o)return t;a=n[i]}var s=i*32+$.numberOfTrailingZeros(a);return s>t?t:s},r.prototype.getNextUnset=function(e){var t=this.size;if(e>=t)return t;var n=this.bits,i=Math.floor(e/32),a=~n[i];a&=~((1<<(e&31))-1);for(var o=n.length;a===0;){if(++i===o)return t;a=~n[i]}var s=i*32+$.numberOfTrailingZeros(a);return s>t?t:s},r.prototype.setBulk=function(e,t){this.bits[Math.floor(e/32)]=t},r.prototype.setRange=function(e,t){if(t<e||e<0||t>this.size)throw new k;if(t!==e){t--;for(var n=Math.floor(e/32),i=Math.floor(t/32),a=this.bits,o=n;o<=i;o++){var s=o>n?0:e&31,l=o<i?31:t&31,u=(2<<l)-(1<<s);a[o]|=u}}},r.prototype.clear=function(){for(var e=this.bits.length,t=this.bits,n=0;n<e;n++)t[n]=0},r.prototype.isRange=function(e,t,n){if(t<e||e<0||t>this.size)throw new k;if(t===e)return!0;t--;for(var i=Math.floor(e/32),a=Math.floor(t/32),o=this.bits,s=i;s<=a;s++){var l=s>i?0:e&31,u=s<a?31:t&31,c=(2<<u)-(1<<l)&4294967295;if((o[s]&c)!==(n?c:0))return!1}return!0},r.prototype.appendBit=function(e){this.ensureCapacity(this.size+1),e&&(this.bits[Math.floor(this.size/32)]|=1<<(this.size&31)),this.size++},r.prototype.appendBits=function(e,t){if(t<0||t>32)throw new k("Num bits must be between 0 and 32");this.ensureCapacity(this.size+t);for(var n=t;n>0;n--)this.appendBit((e>>n-1&1)===1)},r.prototype.appendBitArray=function(e){var t=e.size;this.ensureCapacity(this.size+t);for(var n=0;n<t;n++)this.appendBit(e.get(n))},r.prototype.xor=function(e){if(this.size!==e.size)throw new k("Sizes don't match");for(var t=this.bits,n=0,i=t.length;n<i;n++)t[n]^=e.bits[n]},r.prototype.toBytes=function(e,t,n,i){for(var a=0;a<i;a++){for(var o=0,s=0;s<8;s++)this.get(e)&&(o|=1<<7-s),e++;t[n+a]=o}},r.prototype.getBitArray=function(){return this.bits},r.prototype.reverse=function(){for(var e=new Int32Array(this.bits.length),t=Math.floor((this.size-1)/32),n=t+1,i=this.bits,a=0;a<n;a++){var o=i[a];o=o>>1&1431655765|(o&1431655765)<<1,o=o>>2&858993459|(o&858993459)<<2,o=o>>4&252645135|(o&252645135)<<4,o=o>>8&16711935|(o&16711935)<<8,o=o>>16&65535|(o&65535)<<16,e[t-a]=o}if(this.size!==n*32){for(var s=n*32-this.size,l=e[0]>>>s,a=1;a<n;a++){var u=e[a];l|=u<<32-s,e[a-1]=l,l=u>>>s}e[n-1]=l}this.bits=e},r.makeArray=function(e){return new Int32Array(Math.floor((e+31)/32))},r.prototype.equals=function(e){if(!(e instanceof r))return!1;var t=e;return this.size===t.size&&fe.equals(this.bits,t.bits)},r.prototype.hashCode=function(){return 31*this.size+fe.hashCode(this.bits)},r.prototype.toString=function(){for(var e="",t=0,n=this.size;t<n;t++)(t&7)===0&&(e+=" "),e+=this.get(t)?"X":".";return e},r.prototype.clone=function(){return new r(this.size,this.bits.slice())},r.prototype.toArray=function(){for(var e=[],t=0,n=this.size;t<n;t++)e.push(this.get(t));return e},r}(),Rn;(function(r){r[r.OTHER=0]="OTHER",r[r.PURE_BARCODE=1]="PURE_BARCODE",r[r.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",r[r.TRY_HARDER=3]="TRY_HARDER",r[r.CHARACTER_SET=4]="CHARACTER_SET",r[r.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",r[r.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",r[r.ASSUME_GS1=7]="ASSUME_GS1",r[r.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",r[r.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",r[r.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"})(Rn||(Rn={}));const se=Rn;var cu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),D=function(r){cu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.getFormatInstance=function(){return new e},e.kind="FormatException",e}(Ue),du=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},te;(function(r){r[r.Cp437=0]="Cp437",r[r.ISO8859_1=1]="ISO8859_1",r[r.ISO8859_2=2]="ISO8859_2",r[r.ISO8859_3=3]="ISO8859_3",r[r.ISO8859_4=4]="ISO8859_4",r[r.ISO8859_5=5]="ISO8859_5",r[r.ISO8859_6=6]="ISO8859_6",r[r.ISO8859_7=7]="ISO8859_7",r[r.ISO8859_8=8]="ISO8859_8",r[r.ISO8859_9=9]="ISO8859_9",r[r.ISO8859_10=10]="ISO8859_10",r[r.ISO8859_11=11]="ISO8859_11",r[r.ISO8859_13=12]="ISO8859_13",r[r.ISO8859_14=13]="ISO8859_14",r[r.ISO8859_15=14]="ISO8859_15",r[r.ISO8859_16=15]="ISO8859_16",r[r.SJIS=16]="SJIS",r[r.Cp1250=17]="Cp1250",r[r.Cp1251=18]="Cp1251",r[r.Cp1252=19]="Cp1252",r[r.Cp1256=20]="Cp1256",r[r.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",r[r.UTF8=22]="UTF8",r[r.ASCII=23]="ASCII",r[r.Big5=24]="Big5",r[r.GB18030=25]="GB18030",r[r.EUC_KR=26]="EUC_KR"})(te||(te={}));var he=function(){function r(e,t,n){for(var i,a,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];this.valueIdentifier=e,this.name=n,typeof t=="number"?this.values=Int32Array.from([t]):this.values=t,this.otherEncodingNames=o,r.VALUE_IDENTIFIER_TO_ECI.set(e,this),r.NAME_TO_ECI.set(n,this);for(var l=this.values,u=0,c=l.length;u!==c;u++){var f=l[u];r.VALUES_TO_ECI.set(f,this)}try{for(var h=du(o),p=h.next();!p.done;p=h.next()){var g=p.value;r.NAME_TO_ECI.set(g,this)}}catch(x){i={error:x}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}}return r.prototype.getValueIdentifier=function(){return this.valueIdentifier},r.prototype.getName=function(){return this.name},r.prototype.getValue=function(){return this.values[0]},r.getCharacterSetECIByValue=function(e){if(e<0||e>=900)throw new D("incorect value");var t=r.VALUES_TO_ECI.get(e);if(t===void 0)throw new D("incorect value");return t},r.getCharacterSetECIByName=function(e){var t=r.NAME_TO_ECI.get(e);if(t===void 0)throw new D("incorect value");return t},r.prototype.equals=function(e){if(!(e instanceof r))return!1;var t=e;return this.getName()===t.getName()},r.VALUE_IDENTIFIER_TO_ECI=new Map,r.VALUES_TO_ECI=new Map,r.NAME_TO_ECI=new Map,r.Cp437=new r(te.Cp437,Int32Array.from([0,2]),"Cp437"),r.ISO8859_1=new r(te.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),r.ISO8859_2=new r(te.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),r.ISO8859_3=new r(te.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),r.ISO8859_4=new r(te.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),r.ISO8859_5=new r(te.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),r.ISO8859_6=new r(te.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),r.ISO8859_7=new r(te.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),r.ISO8859_8=new r(te.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),r.ISO8859_9=new r(te.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),r.ISO8859_10=new r(te.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),r.ISO8859_11=new r(te.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),r.ISO8859_13=new r(te.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),r.ISO8859_14=new r(te.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),r.ISO8859_15=new r(te.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),r.ISO8859_16=new r(te.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),r.SJIS=new r(te.SJIS,20,"SJIS","Shift_JIS"),r.Cp1250=new r(te.Cp1250,21,"Cp1250","windows-1250"),r.Cp1251=new r(te.Cp1251,22,"Cp1251","windows-1251"),r.Cp1252=new r(te.Cp1252,23,"Cp1252","windows-1252"),r.Cp1256=new r(te.Cp1256,24,"Cp1256","windows-1256"),r.UnicodeBigUnmarked=new r(te.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),r.UTF8=new r(te.UTF8,26,"UTF8","UTF-8"),r.ASCII=new r(te.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),r.Big5=new r(te.Big5,28,"Big5"),r.GB18030=new r(te.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),r.EUC_KR=new r(te.EUC_KR,30,"EUC_KR","EUC-KR"),r}(),fu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),zr=function(r){fu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="UnsupportedOperationException",e}(Ue),Xe=function(){function r(){}return r.decode=function(e,t){var n=this.encodingName(t);return this.customDecoder?this.customDecoder(e,n):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(n)?this.decodeFallback(e,n):new TextDecoder(n).decode(e)},r.shouldDecodeOnFallback=function(e){return!r.isBrowser()&&e==="ISO-8859-1"},r.encode=function(e,t){var n=this.encodingName(t);return this.customEncoder?this.customEncoder(e,n):typeof TextEncoder>"u"?this.encodeFallback(e):new TextEncoder().encode(e)},r.isBrowser=function(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"},r.encodingName=function(e){return typeof e=="string"?e:e.getName()},r.encodingCharacterSet=function(e){return e instanceof he?e:he.getCharacterSetECIByName(e)},r.decodeFallback=function(e,t){var n=this.encodingCharacterSet(t);if(r.isDecodeFallbackSupported(n)){for(var i="",a=0,o=e.length;a<o;a++){var s=e[a].toString(16);s.length<2&&(s="0"+s),i+="%"+s}return decodeURIComponent(i)}if(n.equals(he.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(e.buffer));throw new zr("Encoding "+this.encodingName(t)+" not supported by fallback.")},r.isDecodeFallbackSupported=function(e){return e.equals(he.UTF8)||e.equals(he.ISO8859_1)||e.equals(he.ASCII)},r.encodeFallback=function(e){for(var t=btoa(unescape(encodeURIComponent(e))),n=t.split(""),i=[],a=0;a<n.length;a++)i.push(n[a].charCodeAt(0));return new Uint8Array(i)},r}(),X=function(){function r(){}return r.castAsNonUtf8Char=function(e,t){t===void 0&&(t=null);var n=t?t.getName():this.ISO88591;return Xe.decode(new Uint8Array([e]),n)},r.guessEncoding=function(e,t){if(t!=null&&t.get(se.CHARACTER_SET)!==void 0)return t.get(se.CHARACTER_SET).toString();for(var n=e.length,i=!0,a=!0,o=!0,s=0,l=0,u=0,c=0,f=0,h=0,p=0,g=0,x=0,m=0,w=0,A=e.length>3&&e[0]===239&&e[1]===187&&e[2]===191,E=0;E<n&&(i||a||o);E++){var S=e[E]&255;o&&(s>0?(S&128)===0?o=!1:s--:(S&128)!==0&&((S&64)===0?o=!1:(s++,(S&32)===0?l++:(s++,(S&16)===0?u++:(s++,(S&8)===0?c++:o=!1))))),i&&(S>127&&S<160?i=!1:S>159&&(S<192||S===215||S===247)&&w++),a&&(f>0?S<64||S===127||S>252?a=!1:f--:S===128||S===160||S>239?a=!1:S>160&&S<224?(h++,g=0,p++,p>x&&(x=p)):S>127?(f++,p=0,g++,g>m&&(m=g)):(p=0,g=0))}return o&&s>0&&(o=!1),a&&f>0&&(a=!1),o&&(A||l+u+c>0)?r.UTF8:a&&(r.ASSUME_SHIFT_JIS||x>=3||m>=3)?r.SHIFT_JIS:i&&a?x===2&&h===2||w*10>=n?r.SHIFT_JIS:r.ISO88591:i?r.ISO88591:a?r.SHIFT_JIS:o?r.UTF8:r.PLATFORM_DEFAULT_ENCODING},r.format=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=-1;function a(s,l,u,c,f,h){if(s==="%%")return"%";if(t[++i]!==void 0){s=c?parseInt(c.substr(1)):void 0;var p=f?parseInt(f.substr(1)):void 0,g;switch(h){case"s":g=t[i];break;case"c":g=t[i][0];break;case"f":g=parseFloat(t[i]).toFixed(s);break;case"p":g=parseFloat(t[i]).toPrecision(s);break;case"e":g=parseFloat(t[i]).toExponential(s);break;case"x":g=parseInt(t[i]).toString(p||16);break;case"d":g=parseFloat(parseInt(t[i],p||10).toPrecision(s)).toFixed(0);break}g=typeof g=="object"?JSON.stringify(g):(+g).toString(p);for(var x=parseInt(u),m=u&&u[0]+""=="0"?"0":" ";g.length<x;)g=l!==void 0?g+m:m+g;return g}}var o=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(o,a)},r.getBytes=function(e,t){return Xe.encode(e,t)},r.getCharCode=function(e,t){return t===void 0&&(t=0),e.charCodeAt(t)},r.getCharAt=function(e){return String.fromCharCode(e)},r.SHIFT_JIS=he.SJIS.getName(),r.GB2312="GB2312",r.ISO88591=he.ISO8859_1.getName(),r.EUC_JP="EUC_JP",r.UTF8=he.UTF8.getName(),r.PLATFORM_DEFAULT_ENCODING=r.UTF8,r.ASSUME_SHIFT_JIS=!1,r}(),q=function(){function r(e){e===void 0&&(e=""),this.value=e}return r.prototype.enableDecoding=function(e){return this.encoding=e,this},r.prototype.append=function(e){return typeof e=="string"?this.value+=e.toString():this.encoding?this.value+=X.castAsNonUtf8Char(e,this.encoding):this.value+=String.fromCharCode(e),this},r.prototype.appendChars=function(e,t,n){for(var i=t;t<t+n;i++)this.append(e[i]);return this},r.prototype.length=function(){return this.value.length},r.prototype.charAt=function(e){return this.value.charAt(e)},r.prototype.deleteCharAt=function(e){this.value=this.value.substr(0,e)+this.value.substring(e+1)},r.prototype.setCharAt=function(e,t){this.value=this.value.substr(0,e)+t+this.value.substr(e+1)},r.prototype.substring=function(e,t){return this.value.substring(e,t)},r.prototype.setLengthToZero=function(){this.value=""},r.prototype.toString=function(){return this.value},r.prototype.insert=function(e,t){this.value=this.value.substring(0,e)+t+this.value.substring(e)},r}(),tt=function(){function r(e,t,n,i){if(this.width=e,this.height=t,this.rowSize=n,this.bits=i,t==null&&(t=e),this.height=t,e<1||t<1)throw new k("Both dimensions must be greater than 0");n==null&&(n=Math.floor((e+31)/32)),this.rowSize=n,i==null&&(this.bits=new Int32Array(this.rowSize*this.height))}return r.parseFromBooleanArray=function(e){for(var t=e.length,n=e[0].length,i=new r(n,t),a=0;a<t;a++)for(var o=e[a],s=0;s<n;s++)o[s]&&i.set(s,a);return i},r.parseFromString=function(e,t,n){if(e===null)throw new k("stringRepresentation cannot be null");for(var i=new Array(e.length),a=0,o=0,s=-1,l=0,u=0;u<e.length;)if(e.charAt(u)===`
|
|
256
|
+
*/const at=R("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Cn=y.memo(r=>{const{ref:e,file:t,className:n,error:i,rightSlot:a,size:o,...s}=r,l=()=>i?d.jsxs(d.Fragment,{children:[d.jsx(v.LuIcon,{icon:El,color:"var(--base-a11)"}),d.jsx(v.Text,{accentColor:"base",className:"truncate",size:o,children:i})]}):t?d.jsxs(d.Fragment,{children:[d.jsx(v.LuIcon,{icon:Fl,color:"var(--base-a11)"}),d.jsx(v.Text,{className:"truncate",size:o,children:t.name})]}):d.jsx(d.Fragment,{children:d.jsx("div",{className:"flex w-full justify-center",children:d.jsx(v.Spinner,{size:o})})});return d.jsxs(v.Card,{className:$e.cx(n,"flex w-full items-center gap-2"),ref:e,size:"xs",...s,children:[l(),a]})});Cn.displayName="FileCard";function Jt(r){return Array.isArray(r)?r.every(e=>typeof e=="string"):!1}class er{constructor(){M(this,"observers",new Set)}notify(e){for(const t of this.observers)t(e)}observe(e){return this.observers.add(e),()=>{this.observers.delete(e)}}}class mn extends er{constructor(t){const{identifier:n}=t;super();M(this,"identifier");this.identifier=n}getOptions(){return{identifier:this.identifier}}setOptions(t){this.identifier=t.identifier??this.identifier,this.notify(this)}serialize(){return{type:this.type,identifier:this.identifier}}}class Ve extends mn{constructor(t){const{label:n,description:i=null,required:a,image:o,...s}=t;super(s);M(this,"label");M(this,"description");M(this,"required");M(this,"image");this.label=n,this.description=i,this.required=a,this.image=o}getError(t){if(!(!this.required&&this.isValueBlank(t))){if(this.required&&this.isValueBlank(t))return"This field is required.";for(const n of this.getFieldValidators()){const i=n(t);if(i)return i}}}serialize(){return{...super.serialize(),label:this.label,description:this.description,required:this.required,image:this.image}}getOptions(){return{...super.getOptions(),label:this.label,description:this.description,required:this.required,image:this.image}}setOptions(t){const{label:n,description:i=null,required:a,image:o,...s}=t;this.label=n??this.label,this.description=i??this.description,this.required=a??this.required,this.image=o??this.image,super.setOptions(s)}isValueBlank(t){return this.areValuesEqual(t,this.blankValue())}cleanValue(t){return t}isValueClean(t){return this.areValuesEqual(t,this.cleanValue(t))}cleanSerializedValue(t){return t}isSerializedValueClean(t){return this.areSerializedValuesEqual(t,this.cleanSerializedValue(t))}isSerializedValueBlank(t){return this.areSerializedValuesEqual(t,this.blankSerializedValue())}getFieldValidators(){return[]}}const ce=y.createContext({}),wn=r=>{const[e,t]=y.useState(null);return y.useEffect(()=>{const n=URL.createObjectURL(r);return t(n),()=>{URL.revokeObjectURL(n)}},[r]),e},Bt=y.memo(r=>{const{file:e,...t}=r,n=wn(e);return n?d.jsx("img",{src:n,alt:e.name,...t}):null});Bt.displayName="ImageFile";const ya=y.createContext(()=>{throw new Error("No ImageViewerProvider found")}),Pr=()=>y.useContext(ya),_n=y.memo(r=>{const{file:e,onClose:t}=r,n=y.useCallback(()=>{ta.saveAs(e,e.name)},[e]);return d.jsx(v.Overlay.Root,{open:!0,onOpenChange:t,children:d.jsxs(v.Overlay.Content,{onOpenAutoFocus:v.preventDefault,children:[d.jsxs(v.ButtonGroup,{className:"absolute right-0 top-0 flex items-center gap-2 p-2",accentColor:"base",variant:"ghost",children:[d.jsxs(v.Tooltip.Root,{children:[d.jsx(v.Tooltip.Trigger,{asChild:!0,children:d.jsx(v.IconButton,{onClick:n,"aria-label":"download",children:d.jsx(v.LuIcon,{icon:ca})})}),d.jsx(v.Tooltip.Content,{size:"sm",children:"Download"})]}),d.jsx(v.Separator,{orientation:"vertical",size:"sm"}),d.jsx(v.Overlay.Close,{asChild:!0,children:d.jsx(v.IconButton,{onClick:t,"aria-label":"close",children:d.jsx(v.LuIcon,{icon:at})})})]}),d.jsx("figure",{className:"flex size-full items-center justify-center overflow-hidden p-4",children:d.jsx(Bt,{className:"max-h-full max-w-full",file:e})})]})})});_n.displayName="ImageViewer";const Ca=y.memo(r=>{const{children:e}=r,[t,n]=y.useState(null),i=y.useCallback(()=>{n(null)},[]),a=y.useCallback(s=>{n(s(i))},[i]),o=y.useCallback(()=>{t&&(t.onClose&&t.onClose(),i())},[i,t]);return d.jsxs(ya.Provider,{value:a,children:[e,t&&d.jsx(_n,{file:t.file,onClose:o})]})});Ca.displayName="FileViewerProvider";const de=y.memo(r=>{const{label:e,error:t,description:n,required:i,children:a,inputId:o,image:s,size:l}=r,[u,c]=y.useState(void 0),f=Pr();y.useEffect(()=>{s instanceof Promise?s.then(c).catch(console.error):c(s)},[s]);const h=y.useCallback(()=>{u&&f(()=>({file:u}))},[f,u]),p=i?`${e} *`:e;return d.jsxs("div",{className:"flex flex-col gap-1",children:[u&&d.jsx(Bt,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:u,onClick:h}),(!!e||!!n)&&d.jsxs("div",{className:"flex flex-col",children:[d.jsx("label",{className:"w-max max-w-full",htmlFor:o,children:d.jsx(v.Text,{size:l,className:"text-wrap",children:p})}),!!n&&d.jsx(v.Text,{accentColor:"base",size:l,children:n})]}),a,!!t&&d.jsx(v.Text,{accentColor:"danger",size:l,children:t})]})});de.displayName="InputWithLabel";const ma=r=>r.map(e=>d.jsx(y.Fragment,{children:e.render()},e.identifier)),Br=r=>r.map(e=>d.jsx(y.Fragment,{children:e.render()},e.identifier)),me=r=>{const{field:e}=r,{field:{value:t,name:n,onChange:i,onBlur:a,disabled:o},fieldState:{isTouched:s,error:l}}=Ye.useController({name:e.identifier});return{value:t,name:n,disabled:o,isTouched:s,error:(l==null?void 0:l.message)??"",onChange:i,onBlur:a}},An=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),[u,c]=y.useState(""),[f,h]=y.useState(""),p=y.useCallback(S=>{o(S),a()},[o,a]),g=y.useCallback(S=>{n&&n.findIndex(O=>O===S.target.value.trim())>=0?h("All options must be unique"):S.target.value?h(""):h("Option cannot be empty"),c(S.target.value)},[c,n]),x=y.useCallback(()=>{if(f)return;if(!u.trim()){h("Option cannot be empty");return}const S=u.trim();p([...n,S]),c("")},[u,f,p,n]),m=y.useCallback(S=>{S.key==="Enter"&&(S.preventDefault(),x())},[x]),w=y.useCallback(S=>{const O=Array.from(n);O.splice(S,1),p(O)},[n,p]),A=y.useCallback(S=>{if(!S.destination)return;const O=S.source.index,N=S.destination.index,T=Array.from(n),[V]=T.splice(O,1);T.splice(N,0,V),p(T)},[p,n]),E=y.useCallback(()=>{a()},[a]);return d.jsx(gn.DragDropContext,{onDragEnd:A,children:d.jsxs(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:f||s,image:e.image,children:[(!l||n.length===0)&&d.jsxs("div",{className:"flex gap-2",children:[d.jsx(v.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:t,children:d.jsx(v.Input.Field,{value:u,onChange:g,onKeyDown:m,id:e.identifier,placeholder:e.placeholder,onBlur:E,name:i,disabled:l})}),d.jsx(v.IconButton,{size:t,accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!f||l,onClick:x,children:d.jsx(v.LuIcon,{icon:Ze})})]}),n.length!==0&&d.jsx(gn.Droppable,{droppableId:`${e.identifier}-droppable`,children:S=>d.jsxs("div",{className:"flex flex-col gap-1",...S.droppableProps,ref:S.innerRef,children:[n.map((O,N)=>d.jsx(gn.Draggable,{draggableId:`${O}-draggable`,index:N,isDragDisabled:l,children:({draggableProps:T,dragHandleProps:V,innerRef:L})=>d.jsxs(v.Badge,{...V,...T,ref:L,className:"flex items-center justify-between gap-2",accentColor:"base",size:t,variant:"soft",children:[d.jsx(v.Text,{className:"truncate",highContrast:!0,children:typeof O=="object"&&"label"in O?O.label:O}),d.jsx(v.IconButton,{className:"bg-transparent!",size:t,variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:l,onClick:()=>{w(N)},children:d.jsx(v.LuIcon,{icon:at})})]})},`${e.identifier}-${O}-${N}`)),S.placeholder]})})]})})});An.displayName="MultiStringFieldInput";class xt extends Ve{constructor(t){const{minimum_length:n,maximum_length:i,placeholder:a,...o}=t;super(o);M(this,"type","multi-string");M(this,"minLength");M(this,"maxLength");M(this,"placeholder");this.minLength=n??0,this.maxLength=i??1/0,this.placeholder=a??"Press enter to add a new option"}render(){return d.jsx(An,{field:this})}serialize(){return{...super.serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}duplicate(t){return new xt({...this.getOptions(),identifier:t})}setOptions(t){const{minimum_length:n,maximum_length:i,placeholder:a,...o}=t;this.minLength=n??this.minLength,this.maxLength=i??this.maxLength,this.placeholder=a??this.placeholder,super.setOptions(o)}serializeValue(t){return t}deserializeValue(t){return t}getFieldValidators(){const t=super.getFieldValidators();return t.push(n=>{if(n.length<this.minLength)return`Must have at least ${this.minLength} options.`}),t.push(n=>{if(n.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),t}static deserialize(t){return new xt(t)}isSerializedValue(t){return Jt(t)}isValue(t){return Jt(t)}blankValue(){return[]}areValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}}class tr extends Ve{constructor(t){const{options:n,...i}=t;super(i);M(this,"options");this.options=n.map(a=>(typeof a=="string"&&(a={label:a,value:a}),a))}serialize(){return{...super.serialize(),options:this.options}}getOptions(){return{...super.getOptions(),options:this.options}}setOptions(t){const{options:n,...i}=t;this.options=(n==null?void 0:n.map(a=>(typeof a=="string"&&(a={label:a,value:a}),a)))??this.options,super.setOptions(i)}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new xt({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${n}options`,minimum_length:2}),showDirectly:!0}]}}const Sn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{o(!!f),a()},[a,o]),c=y.useCallback(()=>{a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,error:s,image:e.image,required:e.required,children:d.jsx(v.Checkbox.Root,{id:e.identifier,name:i,checked:n??!1,onCheckedChange:u,onBlur:c,size:t,accentColor:"base",variant:"surface",disabled:l,children:d.jsx(v.Checkbox.Indicator,{children:d.jsx(v.LuIcon,{icon:ke})})})})});Sn.displayName="BooleanFieldInput";class yt extends Ve{constructor(t){super(t);M(this,"type","boolean")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}setOptions(t){super.setOptions(t)}duplicate(t){return new yt({...this.getOptions(),identifier:t})}static deserialize(t){return new yt(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Sn,{field:this})}isSerializedValue(t){return typeof t=="boolean"}isValue(t){return typeof t=="boolean"}blankValue(){return!1}blankSerializedValue(){return!1}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return t===n}}const En=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{const p=h.target.valueAsNumber,g=isNaN(p)?null:p;o(g)},[o]),c=y.useCallback(()=>{a()},[a]),f=y.useCallback(h=>{h.key==="Enter"&&h.preventDefault()},[]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(v.Input.Root,{accentColor:"base",variant:"surface",size:t,children:d.jsx(v.Input.Field,{id:e.identifier,name:i,onChange:u,onBlur:c,value:n??"",type:"number",min:e.minimum,max:e.maximum,step:e.integers?1:"any",placeholder:e.placeholder??"Enter a number",disabled:l,onKeyDown:f})})})});En.displayName="NumberFieldInput";class Pe extends Ve{constructor(t){const{minimum:n=Number.MIN_SAFE_INTEGER,maximum:i=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:o,...s}=t;super(s);M(this,"type","number");M(this,"minimum");M(this,"maximum");M(this,"integers");M(this,"placeholder");this.minimum=n,this.maximum=i,this.integers=a,this.placeholder=o}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${n}minimum`}),showDirectly:!1},{field:new Pe({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${n}maximum`}),showDirectly:!1},{field:new yt({label:"Integers",description:"Whole numbers only",required:!1,identifier:`${n}integers`}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.minimum,i=this.maximum;return typeof n=="number"&&t.push(a=>{if(typeof a=="number"&&a<n)return`Must be at least ${this.minimum}.`}),typeof i=="number"&&t.push(a=>{if(typeof a=="number"&&a>i)return`Must be at most ${this.maximum}.`}),this.integers&&t.push(a=>{if(typeof a=="number"&&!Number.isInteger(a))return"Must be a whole number."}),t}serialize(){return{...super.serialize(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}duplicate(t){return new Pe({...this.getOptions(),identifier:t})}setOptions(t){const{minimum:n,maximum:i,integers:a,placeholder:o,...s}=t;this.minimum=n??this.minimum,this.maximum=i??this.maximum,this.integers=a??this.integers,this.placeholder=o??this.placeholder,super.setOptions(s)}static deserialize(t){return new Pe(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(En,{field:this})}isSerializedValue(t){return this.isValue(t)}isValue(t){return typeof t=="number"&&!isNaN(t)||t===null}areValuesEqual(t,n){return t===n}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const rr=1e4;class In extends Ve{constructor(t){const{minLength:n,maxLength:i,placeholder:a="",...o}=t;super(o);M(this,"minLength");M(this,"maxLength");M(this,"placeholder");this.minLength=n?Math.max(n,0):void 0,this.maxLength=i?Math.max(i,0):rr,this.placeholder=a}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${n}minimum_length`,minimum:0,maximum:100,integers:!0}),showDirectly:!1},{field:new Pe({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${n}maximum_length`,minimum:1,maximum:rr,integers:!0}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators();return this.minLength&&t.push(n=>{if(this.minLength&&(!n||n.length<this.minLength))return!this.required&&!n?void 0:`Minimum ${this.minLength} character(s).`}),this.maxLength&&t.push(n=>{if(typeof n=="string"&&this.maxLength&&n.length>this.maxLength)return`Maximum ${this.maxLength} character(s).`}),t}serialize(){return{...super.serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minLength:this.minLength,maxLength:this.maxLength,placeholder:this.placeholder}}setOptions(t){const{minLength:n,maxLength:i,placeholder:a,...o}=t;this.minLength=n,this.maxLength=i??this.maxLength,this.placeholder=a,super.setOptions(o)}serializeValue(t){return t}deserializeValue(t){return t}isSerializedValue(t){return typeof t=="string"}isValue(t){return typeof t=="string"}blankValue(){return""}blankSerializedValue(){return""}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return t===n}}const On=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{o(f),a()},[a,o]),c=y.useCallback(()=>{a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(v.CheckboxGroup.Root,{id:e.identifier,name:i,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,values:n,onValuesChange:u,disabled:l,children:e.options.map((f,h)=>d.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(v.CheckboxGroup.Item,{value:f.value,onBlur:c,children:d.jsx(v.CheckboxGroup.ItemIndicator,{children:d.jsx(v.LuIcon,{icon:ke})})}),d.jsx(v.Text,{size:t,accentColor:"base",className:"truncate",children:f.label})]},`${e.identifier}-${f.value}-${h}`))})})});On.displayName="CheckboxListFieldInput";class Ct extends tr{constructor(t){super(t);M(this,"type","checkbox-list")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new Ct({...this.getOptions(),identifier:t})}static deserialize(t){return new Ct(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(On,{field:this})}isSerializedValue(t){if(!Jt(t))return!1;const n=new Set(this.options.map(({value:i})=>i));return t.every(i=>n.has(i))}isValue(t){return this.isSerializedValue(t)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}areValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}}const bn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),[u,c]=y.useState(!1),f=y.useCallback(p=>{o(p??null),a(),c(!1)},[o,a]),h=y.useCallback(p=>{c(p),p||a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.Popover.Root,{open:u,onOpenChange:h,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:d.jsxs(v.Button,{id:e.identifier,name:i,type:"button",className:"!justify-between",accentColor:"base",variant:"surface",size:t,disabled:l,children:[d.jsx(v.Text,{className:"truncate",highContrast:!!n,children:n?n.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd"}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Popover.Content,{align:"start",size:t,children:d.jsx(v.DayPicker,{size:t,required:!1,mode:"single",variant:"solid",selected:n??void 0,onSelect:f})})]})})});bn.displayName="DateFieldInput";class Lt extends Ve{constructor(t){super(t);M(this,"type","date")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new Lt({...this.getOptions(),identifier:t})}static deserialize(t){return new Lt(t)}setOptions(t){super.setOptions(t)}serializeValue(t){return t?t.toISOString():null}deserializeValue(t){return t?new Date(t):null}render(){return d.jsx(bn,{field:this})}isSerializedValue(t){return typeof t!="string"&&t!==null?!1:this.isValue(this.deserializeValue(t))}isValue(t){return!(!(t instanceof Date)&&t!==null||t instanceof Date&&isNaN(t.getTime()))}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return!t&&!n?!0:!t||!n?!1:t.getTime()===n.getTime()}}var W=(r=>(r.Text="text",r.Selection="selection",r.Numeric="numeric",r.Temporal="temporal",r.Capture="capture",r.Assessment="assessment",r.Verification="verification",r))(W||{});const Nn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{o(f),a()},[a,o]),c=y.useCallback(f=>{f||a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.Menu.Root,{onOpenChange:c,align:"start",children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsxs(v.Button,{id:e.identifier,name:i,className:"!justify-between",variant:"surface",type:"button",size:t,accentColor:"base",disabled:l,children:[d.jsx(v.Text,{className:"truncate",highContrast:n&&n.length>0,children:n&&n.length>0?n.join(", "):e.placeholder??"Select one or more..."}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Menu.Content,{size:t,children:d.jsx(v.Menu.Scroll,{children:d.jsxs(v.Menu.MultiSelectGroup,{values:n,onValuesChange:u,children:[d.jsxs(v.Menu.SelectAllItem,{children:[d.jsx(v.Menu.CheckboxItemIndicator,{children:f=>f?d.jsx(v.LuIcon,{icon:Vr}):d.jsx(v.LuIcon,{icon:ke})}),"Select all"]}),e.options.map((f,h)=>d.jsxs(v.Menu.MultiSelectItem,{value:f.value,children:[d.jsx(v.Menu.SelectedIndicator,{children:d.jsx(v.LuIcon,{icon:ke})}),f.label]},`${e.identifier}-${f.value}-${h}`))]})})})]})})});Nn.displayName="MultiSelectFieldInput";class it extends tr{constructor(t){const{placeholder:n,...i}=t;super(i);M(this,"type","multi-select");M(this,"placeholder");this.placeholder=n}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(t){return new it({...this.getOptions(),identifier:t})}setOptions(t){const{placeholder:n}=t;this.placeholder=n,super.setOptions(t)}static deserialize(t){return new it(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Nn,{field:this})}isSerializedValue(t){if(!Jt(t))return!1;const n=new Set(this.options.map(({value:i})=>i));return t.every(i=>n.has(i))}isValue(t){return this.isSerializedValue(t)}blankValue(){return[]}areValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){const i=new Set(t),a=new Set(n);return i.size===a.size&&i.isSubsetOf(a)}}const Tn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h??null),a()},[a,o]),c=y.useCallback(h=>{h||a()},[a]),f=y.useMemo(()=>e.options.find(h=>h.value===n),[e.options,n]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.Menu.Root,{onOpenChange:c,align:"start",children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsxs(v.Button,{id:e.identifier,name:i,className:"!justify-between",accentColor:"base",variant:"surface",type:"button",size:t,disabled:l,children:[d.jsx(v.Text,{className:"truncate",highContrast:!!f,children:f?f.label:e.placeholder??"Select one..."}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Menu.Content,{size:t,children:d.jsx(v.Menu.Scroll,{children:d.jsx(v.Menu.SelectGroup,{required:!1,value:n??void 0,onValueChange:u,children:e.options.map((h,p)=>d.jsxs(v.Menu.SelectItem,{value:h.value,children:[d.jsx(v.Menu.SelectedIndicator,{children:d.jsx(v.LuIcon,{icon:ke})}),h.label]},`${e.identifier}-${h.value}-${p}`))})})})]})})});Tn.displayName="SelectFieldInput";class ot extends tr{constructor(t){const{placeholder:n,...i}=t;super(i);M(this,"type","select");M(this,"placeholder");this.placeholder=n}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(t){return new ot({...this.getOptions(),identifier:t})}setOptions(t){const{placeholder:n}=t;this.placeholder=n,super.setOptions(t)}static deserialize(t){return new ot(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Tn,{field:this})}isSerializedValue(t){return typeof t!="string"&&t!==null?!1:new Set([null,...this.options.map(({value:i})=>i)]).has(t)}isValue(t){return this.isSerializedValue(t)}blankValue(){return null}areValuesEqual(t,n){return t===n}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const Mn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h)},[o]),c=y.useCallback(()=>{a()},[a]),f=y.useMemo(()=>Array.from({length:e.length},()=>U.v4()),[e.length]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.OneTimePasswordField.Root,{id:e.identifier,name:i,value:n,onValueChange:u,validationType:e.validationType,disabled:l,orientation:"horizontal",dir:"ltr",type:"text",autoComplete:"off",autoFocus:!1,autoSubmit:!1,className:"p-0.25 flex h-max w-full gap-1 overflow-x-auto",accentColor:"base",variant:"surface",size:t,onBlur:c,children:[f.map(h=>d.jsx(v.OneTimePasswordField.Input,{id:h},h)),d.jsx(v.OneTimePasswordField.HiddenInput,{})]})})});Mn.displayName="OTPFieldInput";class mt extends Ve{constructor(t){const{length:n,validationType:i,...a}=t;super(a);M(this,"type","otp");M(this,"length");M(this,"validationType");this.length=n,this.validationType=i}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Length",integers:!0,required:!1,minimum:1,maximum:16,identifier:`${n}length`}),showDirectly:!1},{field:new ot({label:"Type",required:!1,identifier:`${n}validationType`,options:[{value:"none",label:"Any"},{value:"numeric",label:"Numeric"},{value:"alpha",label:"Alpha"},{value:"alphanumeric",label:"Alphanumeric"}]}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.length;return t.push(i=>{if(i.length!=n)return`Must be ${n} characters.`}),t}serialize(){return{...super.serialize(),length:this.length,validationType:this.validationType}}getOptions(){return{...super.getOptions(),length:this.length,validationType:this.validationType}}duplicate(t){return new mt({...this.getOptions(),identifier:t})}setOptions(t){const{length:n,validationType:i,...a}=t;this.length=n??this.length,this.validationType=i??this.validationType,super.setOptions(a)}static deserialize(t){return new mt(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Mn,{field:this})}isSerializedValue(t){return typeof t=="string"}isValue(t){return typeof t=="string"}blankValue(){return""}areValuesEqual(t,n){return t===n}blankSerializedValue(){return""}areSerializedValuesEqual(t,n){return t===n}}const wt={pass:{label:"Pass",icon:Il},fail:{label:"Fail",icon:Nl},na:{label:"N/A",icon:bl}},zt=Object.keys(wt);class st extends File{constructor(t,...n){super(...n);M(this,"uuid");this.uuid=t}static from(t,n){return new st(t,[n],n.name,{lastModified:n.lastModified,type:n.type})}}class kt extends Promise{constructor(t,n){super(t);M(this,"_uuid");this._uuid=n}get uuid(){return this._uuid}set uuid(t){this._uuid=t}static from(t,n){return new kt((i,a)=>{Promise.resolve(t).then(i).catch(a)},n)}then(t,n){const i=super.then(t,n);return i.uuid=this.uuid,i}catch(t){const n=super.catch(t);return n.uuid=this.uuid,n}finally(t){const n=super.finally(t);return n.uuid=this.uuid,n}}function wa(r){return Array.isArray(r)?r.every(e=>e instanceof kt||e instanceof st):!1}function Lr(r,e){const t=new Set(r.map(({uuid:i})=>i)),n=new Set(e.map(({uuid:i})=>i));return t.size===n.size&&t.isSubsetOf(n)}const Dn=y.memo(r=>{const{ref:e,file:t,error:n,rightSlot:i,className:a,size:o,...s}=r;return d.jsxs(v.Card,{className:$e.cx(a,"p-0! relative flex h-48 w-full flex-col items-center"),ref:e,size:"xs",...s,children:[!t&&!n&&d.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:d.jsx(v.Spinner,{})}),!!t&&!n&&d.jsx("div",{className:"flex w-full grow items-center justify-center overflow-hidden bg-clip-padding p-3",children:d.jsx(Bt,{className:"size-full max-w-full object-cover",file:t})}),d.jsx(v.Separator,{size:"full"}),(!!t||!!n)&&d.jsxs("div",{className:$e.cx("flex w-full items-center gap-2 self-end p-3",{"bg-transparent":!t}),children:[n?d.jsx(v.LuIcon,{color:"var(--base-11)",icon:fa}):t&&d.jsx(v.LuIcon,{color:"var(--base-11)",icon:ha}),d.jsx(v.Text,{className:"truncate",size:o,children:n??(t==null?void 0:t.name)}),i]})]})});Dn.displayName="ImageCard";const Fn=y.memo(r=>{const{file:e,...t}=r,n=wn(e);return n?d.jsx("video",{src:n,...t}):null});Fn.displayName="VideoFile";const Vn=y.memo(r=>{const{ref:e,file:t,className:n,error:i,rightSlot:a,size:o,...s}=r;return d.jsxs(v.Card,{className:$e.cx(n,"p-0! relative flex h-48 w-full flex-col items-center"),ref:e,size:"xs",...s,children:[!t&&!i&&d.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:d.jsx(v.Spinner,{})}),!!t&&!i&&d.jsx("div",{className:"flex w-full grow items-center justify-center overflow-hidden bg-clip-padding p-3",children:d.jsx(Fn,{className:"size-full max-w-full object-cover",file:t,controls:!0})}),d.jsx(v.Separator,{size:"full"}),(!!t||!!i)&&d.jsxs("div",{className:$e.cx("flex w-full items-center gap-2 self-end p-3",{"bg-transparent":!t}),children:[i?d.jsx(v.LuIcon,{color:"var(--base-11)",icon:fa}):t&&d.jsx(v.LuIcon,{color:"var(--base-11)",icon:jl}),d.jsx(v.Text,{className:"truncate",size:o,children:i??(t==null?void 0:t.name)}),a]})]})});Vn.displayName="VideoCard";const Pn=y.memo(r=>{const{fileOrPromise:e,onRemove:t,disabled:n,size:i}=r,[a,o]=y.useState(null),[s,l]=y.useState(null),u=Pr();y.useEffect(()=>{let w=!0;return o(null),l(null),(async()=>{if(e instanceof kt)try{const E=await e;if(!w)return;o(E)}catch(E){if(!w)return;l(E instanceof Error?E.message:"Unknown error")}else o(e)})(),()=>{w=!1}},[e]);const c=y.useCallback(()=>{if(!a)return;const w=new Blob([a]);ta.saveAs(w,a.name)},[a]),f=y.useCallback(()=>{t(e)},[t,e]),h=y.useCallback(()=>{if(!a)return;const w=URL.createObjectURL(a);window.open(w,"_blank"),URL.revokeObjectURL(w)},[a]),p=y.useCallback(()=>{a&&u(w=>({file:a,onDelete:n?void 0:()=>{f(),w()}}))},[n,f,u,a]),g=y.useMemo(()=>d.jsx("div",{className:"flex grow justify-end",children:d.jsxs(v.Menu.Root,{modal:!0,children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.IconButton,{onClick:v.stopPropagation,type:"button",variant:"ghost",accentColor:"base",size:i,children:d.jsx(v.LuIcon,{icon:da})})}),d.jsxs(v.Menu.Content,{size:i,children:[d.jsxs(v.Menu.Item,{onSelect:c,disabled:!a,children:[d.jsx(v.LuIcon,{icon:ca})," Download"]}),n?null:d.jsxs(d.Fragment,{children:[d.jsx(v.Menu.Separator,{}),d.jsxs(v.Menu.Item,{onSelect:f,children:[d.jsx(v.LuIcon,{icon:gt})," Delete"]})]})]})]})}),[n,f,c,a,i]),x=!!(a!=null&&a.type.startsWith("image/")),m=!!(a!=null&&a.type.startsWith("video/"));return x?d.jsx(Dn,{className:"cursor-pointer",onClick:p,file:a,error:s??void 0,rightSlot:g,size:i}):m?d.jsx(Vn,{className:"cursor-pointer",onClick:p,file:a,error:s??void 0,rightSlot:g,size:i}):d.jsx(Cn,{className:"cursor-pointer",file:a,error:s??void 0,onClick:h,rightSlot:g,size:i})});Pn.displayName="DisplayFile";const Bn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useRef(null),c=y.useCallback(S=>{const O=e.cleanValue({...n,status:S});o(O),a()},[e,a,o,n]),f=y.useCallback(S=>{const O=S.target.value,N={...n,notes:O};o(N)},[n,o]),h=y.useCallback(()=>{a()},[a]),p=y.useCallback(S=>{const O=n.files.filter(({uuid:N})=>N!==S.uuid);o({...n,files:O}),a()},[o,a,n]),g=y.useCallback(()=>{var S;(S=u.current)==null||S.click()},[]),x=y.useCallback(S=>{const O=Array.from(S.target.files??[]).map(T=>st.from(U.v4(),T)),N={...n,files:[...n.files,...O]};o(N),a()},[a,o,n]);y.useEffect(()=>{if(!u.current)return;const S=new AbortController;return u.current.addEventListener("cancel",()=>{a()},{signal:S.signal}),()=>{S.abort()}},[a,n]);const m=n.status&&e.showNotesAndFilesOn.includes(n.status),w=`${e.identifier}-status`,A=`${e.identifier}-notes`,E=`${e.identifier}-files`;return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(v.RadioGroup.Root,{id:w,className:"flex gap-2",name:i,value:n.status,disabled:l,accentColor:"base",variant:"surface",size:t,onValueChange:c,children:zt.map(S=>{const{label:O}=wt[S];return d.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(v.RadioGroup.Item,{value:S,children:d.jsx(v.RadioGroup.Indicator,{children:d.jsx(v.LuIcon,{icon:sa,className:"fill-current"})})}),d.jsx(v.Text,{size:t,accentColor:"base",className:"truncate",children:O})]},`${e.identifier}-${S}`)})}),m&&d.jsxs(d.Fragment,{children:[d.jsx("div",{children:d.jsx(v.TextArea,{id:A,value:n.notes??"",name:i,onChange:f,onBlur:h,className:"field-sizing-content min-h-12 w-full",placeholder:"Notes",resize:"vertical",accentColor:"base",variant:"surface",size:t,disabled:l})}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs(v.Button,{className:"w-max",size:t,variant:"soft",accentColor:"base",onClick:g,type:"button",disabled:l,children:[d.jsx(v.LuIcon,{icon:yn}),"Select files"]}),d.jsx("input",{id:E,name:i,type:"file",ref:u,multiple:!0,className:"hidden",onChange:x,value:""}),n.files.length>0&&d.jsx("div",{className:"flex h-max flex-wrap gap-2",children:n.files.map(S=>d.jsx(Pn,{size:t,fileOrPromise:S,onRemove:p,disabled:l},S.uuid))})]})]})]})})});Bn.displayName="PassFailFieldInput";const Ln=r=>typeof r=="string"&&zt.includes(r),_a=r=>!(r===null||typeof r!="object"||!("status"in r)||!Ln(r.status)||!("notes"in r)||typeof r.notes!="string"||!("files"in r)||!(Array.isArray(r.files)&&r.files.length===0)),Aa=r=>!(r===null||typeof r!="object"||!("status"in r)||!Ln(r.status)||!("notes"in r)||typeof r.notes!="string"||!("files"in r)||!wa(r.files)),Sa=r=>({status:r.status,notes:r.notes,files:[]}),Ea=r=>({status:r.status,notes:r.notes,files:[]}),Ia=(r,e)=>!(r.status!==e.status||r.notes!==e.notes||!Lr(r.files,e.files)),Oa=(r,e)=>!(r.status!==e.status||r.notes!==e.notes||r.files.length!==e.files.length);class _t extends Ve{constructor(t){const{showNotesAndFilesOn:n,...i}=t;super(i);M(this,"type","pass-fail");M(this,"showNotesAndFilesOn");this.showNotesAndFilesOn=n}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new it({identifier:`${n}showNotesAndFilesOn`,label:"Show notes and files on",description:"Show the notes and files on desired statuses.",options:zt.map(i=>{const{label:a}=wt[i];return{value:i,label:a}}),required:!1}),showDirectly:!1}]}serialize(){return{...super.serialize(),showNotesAndFilesOn:this.showNotesAndFilesOn}}getOptions(){return{...super.getOptions(),showNotesAndFilesOn:this.showNotesAndFilesOn}}duplicate(t){return new _t({...this.getOptions(),identifier:t})}setOptions(t){const{showNotesAndFilesOn:n,...i}=t;this.showNotesAndFilesOn=n??this.showNotesAndFilesOn,super.setOptions(i)}getFieldValidators(){const t=super.getFieldValidators(),n=this.showNotesAndFilesOn,i=this.blankValue();return n.length>0&&(t.push(a=>{if(!(!a.status||!n.includes(a.status))&&i.notes===a.notes)return"Notes is required."}),t.push(a=>{if(!(!a.status||!n.includes(a.status))&&Lr(i.files,a.files))return"Files is required."})),t}static deserialize(t){return new _t({...t,showNotesAndFilesOn:t.showNotesAndFilesOn??!1})}serializeValue(t){return Sa(t)}deserializeValue(t){return Ea(t)}render(){return d.jsx(Bn,{field:this})}isSerializedValue(t){return _a(t)}isValue(t){return Aa(t)}areValuesEqual(t,n){return Ia(t,n)}blankValue(){return{status:null,notes:"",files:[]}}cleanValue(t){return t.status&&this.showNotesAndFilesOn.includes(t.status)?t:{status:t.status,notes:"",files:[]}}cleanSerializedValue(t){return super.cleanSerializedValue(t)}blankSerializedValue(){return{status:null,notes:"",files:[]}}areSerializedValuesEqual(t,n){return Oa(t,n)}}const zn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h),a()},[a,o]),c=y.useCallback(()=>{a()},[a]),f=y.useCallback(()=>{o(null),a()},[a,o]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs(v.RadioGroup.Root,{id:e.identifier,name:i,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,value:n??"",onValueChange:u,disabled:l,children:[e.options.map((h,p)=>d.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[d.jsx(v.RadioGroup.Item,{value:h.value,onBlur:c,children:d.jsx(v.RadioGroup.Indicator,{children:d.jsx(v.LuIcon,{icon:sa,className:"fill-current"})})}),d.jsx(v.Text,{size:t,accentColor:"base",className:"truncate",children:h.label})]},`${e.identifier}-${h.value}-${p}`)),!!n&&d.jsxs(v.Button,{onClick:f,className:"-mx-2 w-max",type:"button",variant:"ghost",accentColor:"base",size:t,children:[d.jsx(v.LuIcon,{icon:at}),"Clear"]})]})})});zn.displayName="RadioFieldInput";class At extends tr{constructor(t){super(t);M(this,"type","radio")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new At({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){return new At(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(zn,{field:this})}isSerializedValue(t){return typeof t!="string"&&t!==null?!1:new Set([null,...this.options.map(({value:i})=>i)]).has(t)}isValue(t){return this.isSerializedValue(t)}blankValue(){return null}areValuesEqual(t,n){return t===n}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const Yl=$e.cva(["group flex cursor-pointer items-center justify-center text-yellow-500 transition-colors disabled:pointer-events-none disabled:opacity-50"],{variants:{size:{xs:["size-5"],sm:["size-6"],md:["size-7"],lg:["size-8"],xl:["size-9"]}}}),kn=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{o(h),a()},[a,o]),c=y.useCallback(()=>{o(null),a()},[a,o]),f=Array.from({length:e.maxRating},(h,p)=>p+1);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs("div",{className:"flex flex-row items-center gap-1",children:[d.jsx(v.Rating.Root,{id:e.identifier,name:i,className:"flex items-center gap-0.5",value:n,onValueChange:u,disabled:l,children:f.map(h=>d.jsx(v.Rating.Item,{value:h,className:Yl({size:t}),children:d.jsx(v.LuIcon,{icon:xa,className:"size-full group-data-[active=true]:fill-current"})},`${e.identifier}-${h}`))}),!l&&n!==null&&d.jsx(v.IconButton,{onClick:c,type:"button",variant:"ghost",accentColor:"base",size:t,children:d.jsx(v.LuIcon,{icon:at})})]})})});kn.displayName="RatingFieldInput";class St extends Ve{constructor(t){const{maxRating:n,...i}=t;super(i);M(this,"type","rating");M(this,"maxRating");this.maxRating=n}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"Max Rating",description:"Maximum rating value",integers:!0,required:!1,minimum:1,maximum:10,identifier:`${n}maxRating`}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.maxRating;return t.push(i=>{if(typeof i=="number"&&(i<1||i>n))return`Rating must be between 1 and ${n}.`}),t}serialize(){return{...super.serialize(),maxRating:this.maxRating}}getOptions(){return{...super.getOptions(),maxRating:this.maxRating}}duplicate(t){return new St({...this.getOptions(),identifier:t})}setOptions(t){const{maxRating:n,...i}=t;this.maxRating=n??this.maxRating,super.setOptions(i)}static deserialize(t){return new St(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(kn,{field:this})}isSerializedValue(t){return this.isValue(t)}isValue(t){return typeof t=="number"&&!isNaN(t)||t===null}areValuesEqual(t,n){return t===n}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}}const ba=y.createContext(()=>{throw new Error("No ScannerProvider found")}),Zl=()=>y.use(ba);function Kl(r,e){var t=Object.setPrototypeOf;t?t(r,e):r.__proto__=e}function Ql(r,e){e===void 0&&(e=r.constructor);var t=Error.captureStackTrace;t&&t(r,e)}var Jl=function(){var r=function(t,n){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,a){i.__proto__=a}||function(i,a){for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(i[o]=a[o])},r(t,n)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),eu=function(r){Jl(e,r);function e(t,n){var i=this.constructor,a=r.call(this,t,n)||this;return Object.defineProperty(a,"name",{value:i.name,enumerable:!1,configurable:!0}),Kl(a,i.prototype),Ql(a),a}return e}(Error),tu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Ue=function(r){tu(e,r);function e(t){t===void 0&&(t=void 0);var n=r.call(this,t)||this;return n.message=t,n}return e.prototype.getKind=function(){var t=this.constructor;return t.kind},e.kind="Exception",e}(eu),ru=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Ke=function(r){ru(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="ArgumentException",e}(Ue),nu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),k=function(r){nu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="IllegalArgumentException",e}(Ue),iu=function(){function r(e){if(this.binarizer=e,e===null)throw new k("Binarizer must be non-null.")}return r.prototype.getWidth=function(){return this.binarizer.getWidth()},r.prototype.getHeight=function(){return this.binarizer.getHeight()},r.prototype.getBlackRow=function(e,t){return this.binarizer.getBlackRow(e,t)},r.prototype.getBlackMatrix=function(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix},r.prototype.isCropSupported=function(){return this.binarizer.getLuminanceSource().isCropSupported()},r.prototype.crop=function(e,t,n,i){var a=this.binarizer.getLuminanceSource().crop(e,t,n,i);return new r(this.binarizer.createBinarizer(a))},r.prototype.isRotateSupported=function(){return this.binarizer.getLuminanceSource().isRotateSupported()},r.prototype.rotateCounterClockwise=function(){var e=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new r(this.binarizer.createBinarizer(e))},r.prototype.rotateCounterClockwise45=function(){var e=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new r(this.binarizer.createBinarizer(e))},r.prototype.toString=function(){try{return this.getBlackMatrix().toString()}catch{return""}},r}(),au=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),we=function(r){au(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.getChecksumInstance=function(){return new e},e.kind="ChecksumException",e}(Ue),ou=function(){function r(e){this.source=e}return r.prototype.getLuminanceSource=function(){return this.source},r.prototype.getWidth=function(){return this.source.getWidth()},r.prototype.getHeight=function(){return this.source.getHeight()},r}(),ie=function(){function r(){}return r.arraycopy=function(e,t,n,i,a){for(;a--;)n[i++]=e[t++]},r.currentTimeMillis=function(){return Date.now()},r}(),su=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Un=function(r){su(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="IndexOutOfBoundsException",e}(Ue),lu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Na=function(r){lu(e,r);function e(t,n){t===void 0&&(t=void 0),n===void 0&&(n=void 0);var i=r.call(this,n)||this;return i.index=t,i.message=n,i}return e.kind="ArrayIndexOutOfBoundsException",e}(Un),uu=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},fe=function(){function r(){}return r.fill=function(e,t){for(var n=0,i=e.length;n<i;n++)e[n]=t},r.fillWithin=function(e,t,n,i){r.rangeCheck(e.length,t,n);for(var a=t;a<n;a++)e[a]=i},r.rangeCheck=function(e,t,n){if(t>n)throw new k("fromIndex("+t+") > toIndex("+n+")");if(t<0)throw new Na(t);if(n>e)throw new Na(n)},r.asList=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e},r.create=function(e,t,n){var i=Array.from({length:e});return i.map(function(a){return Array.from({length:t}).fill(n)})},r.createInt32Array=function(e,t,n){var i=Array.from({length:e});return i.map(function(a){return Int32Array.from({length:t}).fill(n)})},r.equals=function(e,t){if(!e||!t||!e.length||!t.length||e.length!==t.length)return!1;for(var n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0},r.hashCode=function(e){var t,n;if(e===null)return 0;var i=1;try{for(var a=uu(e),o=a.next();!o.done;o=a.next()){var s=o.value;i=31*i+s}}catch(l){t={error:l}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return i},r.fillUint8Array=function(e,t){for(var n=0;n!==e.length;n++)e[n]=t},r.copyOf=function(e,t){return e.slice(0,t)},r.copyOfUint8Array=function(e,t){if(e.length<=t){var n=new Uint8Array(t);return n.set(e),n}return e.slice(0,t)},r.copyOfRange=function(e,t,n){var i=n-t,a=new Int32Array(i);return ie.arraycopy(e,t,a,0,i),a},r.binarySearch=function(e,t,n){n===void 0&&(n=r.numberComparator);for(var i=0,a=e.length-1;i<=a;){var o=a+i>>1,s=n(t,e[o]);if(s>0)i=o+1;else if(s<0)a=o-1;else return o}return-i-1},r.numberComparator=function(e,t){return e-t},r}(),$=function(){function r(){}return r.numberOfTrailingZeros=function(e){var t;if(e===0)return 32;var n=31;return t=e<<16,t!==0&&(n-=16,e=t),t=e<<8,t!==0&&(n-=8,e=t),t=e<<4,t!==0&&(n-=4,e=t),t=e<<2,t!==0&&(n-=2,e=t),n-(e<<1>>>31)},r.numberOfLeadingZeros=function(e){if(e===0)return 32;var t=1;return e>>>16||(t+=16,e<<=16),e>>>24||(t+=8,e<<=8),e>>>28||(t+=4,e<<=4),e>>>30||(t+=2,e<<=2),t-=e>>>31,t},r.toHexString=function(e){return e.toString(16)},r.toBinaryString=function(e){return String(parseInt(String(e),2))},r.bitCount=function(e){return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),e=e+(e>>>4)&252645135,e=e+(e>>>8),e=e+(e>>>16),e&63},r.truncDivision=function(e,t){return Math.trunc(e/t)},r.parseInt=function(e,t){return t===void 0&&(t=void 0),parseInt(e,t)},r.MIN_VALUE_32_BITS=-2147483648,r.MAX_VALUE=Number.MAX_SAFE_INTEGER,r}(),_e=function(){function r(e,t){e===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=e,t==null?this.bits=r.makeArray(e):this.bits=t)}return r.prototype.getSize=function(){return this.size},r.prototype.getSizeInBytes=function(){return Math.floor((this.size+7)/8)},r.prototype.ensureCapacity=function(e){if(e>this.bits.length*32){var t=r.makeArray(e);ie.arraycopy(this.bits,0,t,0,this.bits.length),this.bits=t}},r.prototype.get=function(e){return(this.bits[Math.floor(e/32)]&1<<(e&31))!==0},r.prototype.set=function(e){this.bits[Math.floor(e/32)]|=1<<(e&31)},r.prototype.flip=function(e){this.bits[Math.floor(e/32)]^=1<<(e&31)},r.prototype.getNextSet=function(e){var t=this.size;if(e>=t)return t;var n=this.bits,i=Math.floor(e/32),a=n[i];a&=~((1<<(e&31))-1);for(var o=n.length;a===0;){if(++i===o)return t;a=n[i]}var s=i*32+$.numberOfTrailingZeros(a);return s>t?t:s},r.prototype.getNextUnset=function(e){var t=this.size;if(e>=t)return t;var n=this.bits,i=Math.floor(e/32),a=~n[i];a&=~((1<<(e&31))-1);for(var o=n.length;a===0;){if(++i===o)return t;a=~n[i]}var s=i*32+$.numberOfTrailingZeros(a);return s>t?t:s},r.prototype.setBulk=function(e,t){this.bits[Math.floor(e/32)]=t},r.prototype.setRange=function(e,t){if(t<e||e<0||t>this.size)throw new k;if(t!==e){t--;for(var n=Math.floor(e/32),i=Math.floor(t/32),a=this.bits,o=n;o<=i;o++){var s=o>n?0:e&31,l=o<i?31:t&31,u=(2<<l)-(1<<s);a[o]|=u}}},r.prototype.clear=function(){for(var e=this.bits.length,t=this.bits,n=0;n<e;n++)t[n]=0},r.prototype.isRange=function(e,t,n){if(t<e||e<0||t>this.size)throw new k;if(t===e)return!0;t--;for(var i=Math.floor(e/32),a=Math.floor(t/32),o=this.bits,s=i;s<=a;s++){var l=s>i?0:e&31,u=s<a?31:t&31,c=(2<<u)-(1<<l)&4294967295;if((o[s]&c)!==(n?c:0))return!1}return!0},r.prototype.appendBit=function(e){this.ensureCapacity(this.size+1),e&&(this.bits[Math.floor(this.size/32)]|=1<<(this.size&31)),this.size++},r.prototype.appendBits=function(e,t){if(t<0||t>32)throw new k("Num bits must be between 0 and 32");this.ensureCapacity(this.size+t);for(var n=t;n>0;n--)this.appendBit((e>>n-1&1)===1)},r.prototype.appendBitArray=function(e){var t=e.size;this.ensureCapacity(this.size+t);for(var n=0;n<t;n++)this.appendBit(e.get(n))},r.prototype.xor=function(e){if(this.size!==e.size)throw new k("Sizes don't match");for(var t=this.bits,n=0,i=t.length;n<i;n++)t[n]^=e.bits[n]},r.prototype.toBytes=function(e,t,n,i){for(var a=0;a<i;a++){for(var o=0,s=0;s<8;s++)this.get(e)&&(o|=1<<7-s),e++;t[n+a]=o}},r.prototype.getBitArray=function(){return this.bits},r.prototype.reverse=function(){for(var e=new Int32Array(this.bits.length),t=Math.floor((this.size-1)/32),n=t+1,i=this.bits,a=0;a<n;a++){var o=i[a];o=o>>1&1431655765|(o&1431655765)<<1,o=o>>2&858993459|(o&858993459)<<2,o=o>>4&252645135|(o&252645135)<<4,o=o>>8&16711935|(o&16711935)<<8,o=o>>16&65535|(o&65535)<<16,e[t-a]=o}if(this.size!==n*32){for(var s=n*32-this.size,l=e[0]>>>s,a=1;a<n;a++){var u=e[a];l|=u<<32-s,e[a-1]=l,l=u>>>s}e[n-1]=l}this.bits=e},r.makeArray=function(e){return new Int32Array(Math.floor((e+31)/32))},r.prototype.equals=function(e){if(!(e instanceof r))return!1;var t=e;return this.size===t.size&&fe.equals(this.bits,t.bits)},r.prototype.hashCode=function(){return 31*this.size+fe.hashCode(this.bits)},r.prototype.toString=function(){for(var e="",t=0,n=this.size;t<n;t++)(t&7)===0&&(e+=" "),e+=this.get(t)?"X":".";return e},r.prototype.clone=function(){return new r(this.size,this.bits.slice())},r.prototype.toArray=function(){for(var e=[],t=0,n=this.size;t<n;t++)e.push(this.get(t));return e},r}(),Rn;(function(r){r[r.OTHER=0]="OTHER",r[r.PURE_BARCODE=1]="PURE_BARCODE",r[r.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",r[r.TRY_HARDER=3]="TRY_HARDER",r[r.CHARACTER_SET=4]="CHARACTER_SET",r[r.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",r[r.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",r[r.ASSUME_GS1=7]="ASSUME_GS1",r[r.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",r[r.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",r[r.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"})(Rn||(Rn={}));const se=Rn;var cu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),D=function(r){cu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.getFormatInstance=function(){return new e},e.kind="FormatException",e}(Ue),du=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},te;(function(r){r[r.Cp437=0]="Cp437",r[r.ISO8859_1=1]="ISO8859_1",r[r.ISO8859_2=2]="ISO8859_2",r[r.ISO8859_3=3]="ISO8859_3",r[r.ISO8859_4=4]="ISO8859_4",r[r.ISO8859_5=5]="ISO8859_5",r[r.ISO8859_6=6]="ISO8859_6",r[r.ISO8859_7=7]="ISO8859_7",r[r.ISO8859_8=8]="ISO8859_8",r[r.ISO8859_9=9]="ISO8859_9",r[r.ISO8859_10=10]="ISO8859_10",r[r.ISO8859_11=11]="ISO8859_11",r[r.ISO8859_13=12]="ISO8859_13",r[r.ISO8859_14=13]="ISO8859_14",r[r.ISO8859_15=14]="ISO8859_15",r[r.ISO8859_16=15]="ISO8859_16",r[r.SJIS=16]="SJIS",r[r.Cp1250=17]="Cp1250",r[r.Cp1251=18]="Cp1251",r[r.Cp1252=19]="Cp1252",r[r.Cp1256=20]="Cp1256",r[r.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",r[r.UTF8=22]="UTF8",r[r.ASCII=23]="ASCII",r[r.Big5=24]="Big5",r[r.GB18030=25]="GB18030",r[r.EUC_KR=26]="EUC_KR"})(te||(te={}));var he=function(){function r(e,t,n){for(var i,a,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];this.valueIdentifier=e,this.name=n,typeof t=="number"?this.values=Int32Array.from([t]):this.values=t,this.otherEncodingNames=o,r.VALUE_IDENTIFIER_TO_ECI.set(e,this),r.NAME_TO_ECI.set(n,this);for(var l=this.values,u=0,c=l.length;u!==c;u++){var f=l[u];r.VALUES_TO_ECI.set(f,this)}try{for(var h=du(o),p=h.next();!p.done;p=h.next()){var g=p.value;r.NAME_TO_ECI.set(g,this)}}catch(x){i={error:x}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}}return r.prototype.getValueIdentifier=function(){return this.valueIdentifier},r.prototype.getName=function(){return this.name},r.prototype.getValue=function(){return this.values[0]},r.getCharacterSetECIByValue=function(e){if(e<0||e>=900)throw new D("incorect value");var t=r.VALUES_TO_ECI.get(e);if(t===void 0)throw new D("incorect value");return t},r.getCharacterSetECIByName=function(e){var t=r.NAME_TO_ECI.get(e);if(t===void 0)throw new D("incorect value");return t},r.prototype.equals=function(e){if(!(e instanceof r))return!1;var t=e;return this.getName()===t.getName()},r.VALUE_IDENTIFIER_TO_ECI=new Map,r.VALUES_TO_ECI=new Map,r.NAME_TO_ECI=new Map,r.Cp437=new r(te.Cp437,Int32Array.from([0,2]),"Cp437"),r.ISO8859_1=new r(te.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),r.ISO8859_2=new r(te.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),r.ISO8859_3=new r(te.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),r.ISO8859_4=new r(te.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),r.ISO8859_5=new r(te.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),r.ISO8859_6=new r(te.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),r.ISO8859_7=new r(te.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),r.ISO8859_8=new r(te.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),r.ISO8859_9=new r(te.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),r.ISO8859_10=new r(te.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),r.ISO8859_11=new r(te.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),r.ISO8859_13=new r(te.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),r.ISO8859_14=new r(te.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),r.ISO8859_15=new r(te.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),r.ISO8859_16=new r(te.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),r.SJIS=new r(te.SJIS,20,"SJIS","Shift_JIS"),r.Cp1250=new r(te.Cp1250,21,"Cp1250","windows-1250"),r.Cp1251=new r(te.Cp1251,22,"Cp1251","windows-1251"),r.Cp1252=new r(te.Cp1252,23,"Cp1252","windows-1252"),r.Cp1256=new r(te.Cp1256,24,"Cp1256","windows-1256"),r.UnicodeBigUnmarked=new r(te.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),r.UTF8=new r(te.UTF8,26,"UTF8","UTF-8"),r.ASCII=new r(te.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),r.Big5=new r(te.Big5,28,"Big5"),r.GB18030=new r(te.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),r.EUC_KR=new r(te.EUC_KR,30,"EUC_KR","EUC-KR"),r}(),fu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),zr=function(r){fu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="UnsupportedOperationException",e}(Ue),Xe=function(){function r(){}return r.decode=function(e,t){var n=this.encodingName(t);return this.customDecoder?this.customDecoder(e,n):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(n)?this.decodeFallback(e,n):new TextDecoder(n).decode(e)},r.shouldDecodeOnFallback=function(e){return!r.isBrowser()&&e==="ISO-8859-1"},r.encode=function(e,t){var n=this.encodingName(t);return this.customEncoder?this.customEncoder(e,n):typeof TextEncoder>"u"?this.encodeFallback(e):new TextEncoder().encode(e)},r.isBrowser=function(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"},r.encodingName=function(e){return typeof e=="string"?e:e.getName()},r.encodingCharacterSet=function(e){return e instanceof he?e:he.getCharacterSetECIByName(e)},r.decodeFallback=function(e,t){var n=this.encodingCharacterSet(t);if(r.isDecodeFallbackSupported(n)){for(var i="",a=0,o=e.length;a<o;a++){var s=e[a].toString(16);s.length<2&&(s="0"+s),i+="%"+s}return decodeURIComponent(i)}if(n.equals(he.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(e.buffer));throw new zr("Encoding "+this.encodingName(t)+" not supported by fallback.")},r.isDecodeFallbackSupported=function(e){return e.equals(he.UTF8)||e.equals(he.ISO8859_1)||e.equals(he.ASCII)},r.encodeFallback=function(e){for(var t=btoa(unescape(encodeURIComponent(e))),n=t.split(""),i=[],a=0;a<n.length;a++)i.push(n[a].charCodeAt(0));return new Uint8Array(i)},r}(),X=function(){function r(){}return r.castAsNonUtf8Char=function(e,t){t===void 0&&(t=null);var n=t?t.getName():this.ISO88591;return Xe.decode(new Uint8Array([e]),n)},r.guessEncoding=function(e,t){if(t!=null&&t.get(se.CHARACTER_SET)!==void 0)return t.get(se.CHARACTER_SET).toString();for(var n=e.length,i=!0,a=!0,o=!0,s=0,l=0,u=0,c=0,f=0,h=0,p=0,g=0,x=0,m=0,w=0,A=e.length>3&&e[0]===239&&e[1]===187&&e[2]===191,E=0;E<n&&(i||a||o);E++){var S=e[E]&255;o&&(s>0?(S&128)===0?o=!1:s--:(S&128)!==0&&((S&64)===0?o=!1:(s++,(S&32)===0?l++:(s++,(S&16)===0?u++:(s++,(S&8)===0?c++:o=!1))))),i&&(S>127&&S<160?i=!1:S>159&&(S<192||S===215||S===247)&&w++),a&&(f>0?S<64||S===127||S>252?a=!1:f--:S===128||S===160||S>239?a=!1:S>160&&S<224?(h++,g=0,p++,p>x&&(x=p)):S>127?(f++,p=0,g++,g>m&&(m=g)):(p=0,g=0))}return o&&s>0&&(o=!1),a&&f>0&&(a=!1),o&&(A||l+u+c>0)?r.UTF8:a&&(r.ASSUME_SHIFT_JIS||x>=3||m>=3)?r.SHIFT_JIS:i&&a?x===2&&h===2||w*10>=n?r.SHIFT_JIS:r.ISO88591:i?r.ISO88591:a?r.SHIFT_JIS:o?r.UTF8:r.PLATFORM_DEFAULT_ENCODING},r.format=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=-1;function a(s,l,u,c,f,h){if(s==="%%")return"%";if(t[++i]!==void 0){s=c?parseInt(c.substr(1)):void 0;var p=f?parseInt(f.substr(1)):void 0,g;switch(h){case"s":g=t[i];break;case"c":g=t[i][0];break;case"f":g=parseFloat(t[i]).toFixed(s);break;case"p":g=parseFloat(t[i]).toPrecision(s);break;case"e":g=parseFloat(t[i]).toExponential(s);break;case"x":g=parseInt(t[i]).toString(p||16);break;case"d":g=parseFloat(parseInt(t[i],p||10).toPrecision(s)).toFixed(0);break}g=typeof g=="object"?JSON.stringify(g):(+g).toString(p);for(var x=parseInt(u),m=u&&u[0]+""=="0"?"0":" ";g.length<x;)g=l!==void 0?g+m:m+g;return g}}var o=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(o,a)},r.getBytes=function(e,t){return Xe.encode(e,t)},r.getCharCode=function(e,t){return t===void 0&&(t=0),e.charCodeAt(t)},r.getCharAt=function(e){return String.fromCharCode(e)},r.SHIFT_JIS=he.SJIS.getName(),r.GB2312="GB2312",r.ISO88591=he.ISO8859_1.getName(),r.EUC_JP="EUC_JP",r.UTF8=he.UTF8.getName(),r.PLATFORM_DEFAULT_ENCODING=r.UTF8,r.ASSUME_SHIFT_JIS=!1,r}(),q=function(){function r(e){e===void 0&&(e=""),this.value=e}return r.prototype.enableDecoding=function(e){return this.encoding=e,this},r.prototype.append=function(e){return typeof e=="string"?this.value+=e.toString():this.encoding?this.value+=X.castAsNonUtf8Char(e,this.encoding):this.value+=String.fromCharCode(e),this},r.prototype.appendChars=function(e,t,n){for(var i=t;t<t+n;i++)this.append(e[i]);return this},r.prototype.length=function(){return this.value.length},r.prototype.charAt=function(e){return this.value.charAt(e)},r.prototype.deleteCharAt=function(e){this.value=this.value.substr(0,e)+this.value.substring(e+1)},r.prototype.setCharAt=function(e,t){this.value=this.value.substr(0,e)+t+this.value.substr(e+1)},r.prototype.substring=function(e,t){return this.value.substring(e,t)},r.prototype.setLengthToZero=function(){this.value=""},r.prototype.toString=function(){return this.value},r.prototype.insert=function(e,t){this.value=this.value.substring(0,e)+t+this.value.substring(e)},r}(),tt=function(){function r(e,t,n,i){if(this.width=e,this.height=t,this.rowSize=n,this.bits=i,t==null&&(t=e),this.height=t,e<1||t<1)throw new k("Both dimensions must be greater than 0");n==null&&(n=Math.floor((e+31)/32)),this.rowSize=n,i==null&&(this.bits=new Int32Array(this.rowSize*this.height))}return r.parseFromBooleanArray=function(e){for(var t=e.length,n=e[0].length,i=new r(n,t),a=0;a<t;a++)for(var o=e[a],s=0;s<n;s++)o[s]&&i.set(s,a);return i},r.parseFromString=function(e,t,n){if(e===null)throw new k("stringRepresentation cannot be null");for(var i=new Array(e.length),a=0,o=0,s=-1,l=0,u=0;u<e.length;)if(e.charAt(u)===`
|
|
257
257
|
`||e.charAt(u)==="\r"){if(a>o){if(s===-1)s=a-o;else if(a-o!==s)throw new k("row lengths do not match");o=a,l++}u++}else if(e.substring(u,u+t.length)===t)u+=t.length,i[a]=!0,a++;else if(e.substring(u,u+n.length)===n)u+=n.length,i[a]=!1,a++;else throw new k("illegal character encountered: "+e.substring(u));if(a>o){if(s===-1)s=a-o;else if(a-o!==s)throw new k("row lengths do not match");l++}for(var c=new r(s,l),f=0;f<a;f++)i[f]&&c.set(Math.floor(f%s),Math.floor(f/s));return c},r.prototype.get=function(e,t){var n=t*this.rowSize+Math.floor(e/32);return(this.bits[n]>>>(e&31)&1)!==0},r.prototype.set=function(e,t){var n=t*this.rowSize+Math.floor(e/32);this.bits[n]|=1<<(e&31)&4294967295},r.prototype.unset=function(e,t){var n=t*this.rowSize+Math.floor(e/32);this.bits[n]&=~(1<<(e&31)&4294967295)},r.prototype.flip=function(e,t){var n=t*this.rowSize+Math.floor(e/32);this.bits[n]^=1<<(e&31)&4294967295},r.prototype.xor=function(e){if(this.width!==e.getWidth()||this.height!==e.getHeight()||this.rowSize!==e.getRowSize())throw new k("input matrix dimensions do not match");for(var t=new _e(Math.floor(this.width/32)+1),n=this.rowSize,i=this.bits,a=0,o=this.height;a<o;a++)for(var s=a*n,l=e.getRow(a,t).getBitArray(),u=0;u<n;u++)i[s+u]^=l[u]},r.prototype.clear=function(){for(var e=this.bits,t=e.length,n=0;n<t;n++)e[n]=0},r.prototype.setRegion=function(e,t,n,i){if(t<0||e<0)throw new k("Left and top must be nonnegative");if(i<1||n<1)throw new k("Height and width must be at least 1");var a=e+n,o=t+i;if(o>this.height||a>this.width)throw new k("The region must fit inside the matrix");for(var s=this.rowSize,l=this.bits,u=t;u<o;u++)for(var c=u*s,f=e;f<a;f++)l[c+Math.floor(f/32)]|=1<<(f&31)&4294967295},r.prototype.getRow=function(e,t){t==null||t.getSize()<this.width?t=new _e(this.width):t.clear();for(var n=this.rowSize,i=this.bits,a=e*n,o=0;o<n;o++)t.setBulk(o*32,i[a+o]);return t},r.prototype.setRow=function(e,t){ie.arraycopy(t.getBitArray(),0,this.bits,e*this.rowSize,this.rowSize)},r.prototype.rotate180=function(){for(var e=this.getWidth(),t=this.getHeight(),n=new _e(e),i=new _e(e),a=0,o=Math.floor((t+1)/2);a<o;a++)n=this.getRow(a,n),i=this.getRow(t-1-a,i),n.reverse(),i.reverse(),this.setRow(a,i),this.setRow(t-1-a,n)},r.prototype.getEnclosingRectangle=function(){for(var e=this.width,t=this.height,n=this.rowSize,i=this.bits,a=e,o=t,s=-1,l=-1,u=0;u<t;u++)for(var c=0;c<n;c++){var f=i[u*n+c];if(f!==0){if(u<o&&(o=u),u>l&&(l=u),c*32<a){for(var h=0;(f<<31-h&4294967295)===0;)h++;c*32+h<a&&(a=c*32+h)}if(c*32+31>s){for(var h=31;!(f>>>h);)h--;c*32+h>s&&(s=c*32+h)}}}return s<a||l<o?null:Int32Array.from([a,o,s-a+1,l-o+1])},r.prototype.getTopLeftOnBit=function(){for(var e=this.rowSize,t=this.bits,n=0;n<t.length&&t[n]===0;)n++;if(n===t.length)return null;for(var i=n/e,a=n%e*32,o=t[n],s=0;(o<<31-s&4294967295)===0;)s++;return a+=s,Int32Array.from([a,i])},r.prototype.getBottomRightOnBit=function(){for(var e=this.rowSize,t=this.bits,n=t.length-1;n>=0&&t[n]===0;)n--;if(n<0)return null;for(var i=Math.floor(n/e),a=Math.floor(n%e)*32,o=t[n],s=31;!(o>>>s);)s--;return a+=s,Int32Array.from([a,i])},r.prototype.getWidth=function(){return this.width},r.prototype.getHeight=function(){return this.height},r.prototype.getRowSize=function(){return this.rowSize},r.prototype.equals=function(e){if(!(e instanceof r))return!1;var t=e;return this.width===t.width&&this.height===t.height&&this.rowSize===t.rowSize&&fe.equals(this.bits,t.bits)},r.prototype.hashCode=function(){var e=this.width;return e=31*e+this.width,e=31*e+this.height,e=31*e+this.rowSize,e=31*e+fe.hashCode(this.bits),e},r.prototype.toString=function(e,t,n){return e===void 0&&(e="X "),t===void 0&&(t=" "),n===void 0&&(n=`
|
|
258
258
|
`),this.buildToString(e,t,n)},r.prototype.buildToString=function(e,t,n){for(var i=new q,a=0,o=this.height;a<o;a++){for(var s=0,l=this.width;s<l;s++)i.append(this.get(s,a)?e:t);i.append(n)}return i.toString()},r.prototype.clone=function(){return new r(this.width,this.height,this.rowSize,this.bits.slice())},r}(),hu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),b=function(r){hu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.getNotFoundInstance=function(){return new e},e.kind="NotFoundException",e}(Ue),pu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),vu=function(r){pu(e,r);function e(t){var n=r.call(this,t)||this;return n.luminances=e.EMPTY,n.buckets=new Int32Array(e.LUMINANCE_BUCKETS),n}return e.prototype.getBlackRow=function(t,n){var i=this.getLuminanceSource(),a=i.getWidth();n==null||n.getSize()<a?n=new _e(a):n.clear(),this.initArrays(a);for(var o=i.getRow(t,this.luminances),s=this.buckets,l=0;l<a;l++)s[(o[l]&255)>>e.LUMINANCE_SHIFT]++;var u=e.estimateBlackPoint(s);if(a<3)for(var l=0;l<a;l++)(o[l]&255)<u&&n.set(l);else for(var c=o[0]&255,f=o[1]&255,l=1;l<a-1;l++){var h=o[l+1]&255;(f*4-c-h)/2<u&&n.set(l),c=f,f=h}return n},e.prototype.getBlackMatrix=function(){var t=this.getLuminanceSource(),n=t.getWidth(),i=t.getHeight(),a=new tt(n,i);this.initArrays(n);for(var o=this.buckets,s=1;s<5;s++)for(var l=Math.floor(i*s/5),u=t.getRow(l,this.luminances),c=Math.floor(n*4/5),f=Math.floor(n/5);f<c;f++){var h=u[f]&255;o[h>>e.LUMINANCE_SHIFT]++}for(var p=e.estimateBlackPoint(o),g=t.getMatrix(),s=0;s<i;s++)for(var x=s*n,f=0;f<n;f++){var h=g[x+f]&255;h<p&&a.set(f,s)}return a},e.prototype.createBinarizer=function(t){return new e(t)},e.prototype.initArrays=function(t){this.luminances.length<t&&(this.luminances=new Uint8ClampedArray(t));for(var n=this.buckets,i=0;i<e.LUMINANCE_BUCKETS;i++)n[i]=0},e.estimateBlackPoint=function(t){for(var n=t.length,i=0,a=0,o=0,s=0;s<n;s++)t[s]>o&&(a=s,o=t[s]),t[s]>i&&(i=t[s]);for(var l=0,u=0,s=0;s<n;s++){var c=s-a,f=t[s]*c*c;f>u&&(l=s,u=f)}if(a>l){var h=a;a=l,l=h}if(l-a<=n/16)throw new b;for(var p=l-1,g=-1,s=l-1;s>a;s--){var x=s-a,f=x*x*(l-s)*(i-t[s]);f>g&&(p=s,g=f)}return p<<e.LUMINANCE_SHIFT},e.LUMINANCE_BITS=5,e.LUMINANCE_SHIFT=8-e.LUMINANCE_BITS,e.LUMINANCE_BUCKETS=1<<e.LUMINANCE_BITS,e.EMPTY=Uint8ClampedArray.from([0]),e}(ou),gu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),xu=function(r){gu(e,r);function e(t){var n=r.call(this,t)||this;return n.matrix=null,n}return e.prototype.getBlackMatrix=function(){if(this.matrix!==null)return this.matrix;var t=this.getLuminanceSource(),n=t.getWidth(),i=t.getHeight();if(n>=e.MINIMUM_DIMENSION&&i>=e.MINIMUM_DIMENSION){var a=t.getMatrix(),o=n>>e.BLOCK_SIZE_POWER;(n&e.BLOCK_SIZE_MASK)!==0&&o++;var s=i>>e.BLOCK_SIZE_POWER;(i&e.BLOCK_SIZE_MASK)!==0&&s++;var l=e.calculateBlackPoints(a,o,s,n,i),u=new tt(n,i);e.calculateThresholdForBlock(a,o,s,n,i,l,u),this.matrix=u}else this.matrix=r.prototype.getBlackMatrix.call(this);return this.matrix},e.prototype.createBinarizer=function(t){return new e(t)},e.calculateThresholdForBlock=function(t,n,i,a,o,s,l){for(var u=o-e.BLOCK_SIZE,c=a-e.BLOCK_SIZE,f=0;f<i;f++){var h=f<<e.BLOCK_SIZE_POWER;h>u&&(h=u);for(var p=e.cap(f,2,i-3),g=0;g<n;g++){var x=g<<e.BLOCK_SIZE_POWER;x>c&&(x=c);for(var m=e.cap(g,2,n-3),w=0,A=-2;A<=2;A++){var E=s[p+A];w+=E[m-2]+E[m-1]+E[m]+E[m+1]+E[m+2]}var S=w/25;e.thresholdBlock(t,x,h,S,a,l)}}},e.cap=function(t,n,i){return t<n?n:t>i?i:t},e.thresholdBlock=function(t,n,i,a,o,s){for(var l=0,u=i*o+n;l<e.BLOCK_SIZE;l++,u+=o)for(var c=0;c<e.BLOCK_SIZE;c++)(t[u+c]&255)<=a&&s.set(n+c,i+l)},e.calculateBlackPoints=function(t,n,i,a,o){for(var s=o-e.BLOCK_SIZE,l=a-e.BLOCK_SIZE,u=new Array(i),c=0;c<i;c++){u[c]=new Int32Array(n);var f=c<<e.BLOCK_SIZE_POWER;f>s&&(f=s);for(var h=0;h<n;h++){var p=h<<e.BLOCK_SIZE_POWER;p>l&&(p=l);for(var g=0,x=255,m=0,w=0,A=f*a+p;w<e.BLOCK_SIZE;w++,A+=a){for(var E=0;E<e.BLOCK_SIZE;E++){var S=t[A+E]&255;g+=S,S<x&&(x=S),S>m&&(m=S)}if(m-x>e.MIN_DYNAMIC_RANGE)for(w++,A+=a;w<e.BLOCK_SIZE;w++,A+=a)for(var E=0;E<e.BLOCK_SIZE;E++)g+=t[A+E]&255}var O=g>>e.BLOCK_SIZE_POWER*2;if(m-x<=e.MIN_DYNAMIC_RANGE&&(O=x/2,c>0&&h>0)){var N=(u[c-1][h]+2*u[c][h-1]+u[c-1][h-1])/4;x<N&&(O=N)}u[c][h]=O}}return u},e.BLOCK_SIZE_POWER=3,e.BLOCK_SIZE=1<<e.BLOCK_SIZE_POWER,e.BLOCK_SIZE_MASK=e.BLOCK_SIZE-1,e.MINIMUM_DIMENSION=e.BLOCK_SIZE*5,e.MIN_DYNAMIC_RANGE=24,e}(vu),kr=function(){function r(e,t){this.width=e,this.height=t}return r.prototype.getWidth=function(){return this.width},r.prototype.getHeight=function(){return this.height},r.prototype.isCropSupported=function(){return!1},r.prototype.crop=function(e,t,n,i){throw new zr("This luminance source does not support cropping.")},r.prototype.isRotateSupported=function(){return!1},r.prototype.rotateCounterClockwise=function(){throw new zr("This luminance source does not support rotation by 90 degrees.")},r.prototype.rotateCounterClockwise45=function(){throw new zr("This luminance source does not support rotation by 45 degrees.")},r.prototype.toString=function(){for(var e=new Uint8ClampedArray(this.width),t=new q,n=0;n<this.height;n++){for(var i=this.getRow(n,e),a=0;a<this.width;a++){var o=i[a]&255,s=void 0;o<64?s="#":o<128?s="+":o<192?s=".":s=" ",t.append(s)}t.append(`
|
|
259
259
|
`)}return t.toString()},r}(),yu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Gn=function(r){yu(e,r);function e(t){var n=r.call(this,t.getWidth(),t.getHeight())||this;return n.delegate=t,n}return e.prototype.getRow=function(t,n){for(var i=this.delegate.getRow(t,n),a=this.getWidth(),o=0;o<a;o++)i[o]=255-(i[o]&255);return i},e.prototype.getMatrix=function(){for(var t=this.delegate.getMatrix(),n=this.getWidth()*this.getHeight(),i=new Uint8ClampedArray(n),a=0;a<n;a++)i[a]=255-(t[a]&255);return i},e.prototype.isCropSupported=function(){return this.delegate.isCropSupported()},e.prototype.crop=function(t,n,i,a){return new e(this.delegate.crop(t,n,i,a))},e.prototype.isRotateSupported=function(){return this.delegate.isRotateSupported()},e.prototype.invert=function(){return this.delegate},e.prototype.rotateCounterClockwise=function(){return new e(this.delegate.rotateCounterClockwise())},e.prototype.rotateCounterClockwise45=function(){return new e(this.delegate.rotateCounterClockwise45())},e}(kr),Cu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),mu=function(r){Cu(e,r);function e(t){var n=r.call(this,t.width,t.height)||this;return n.canvas=t,n.tempCanvasElement=null,n.buffer=e.makeBufferFromCanvasImageData(t),n}return e.makeBufferFromCanvasImageData=function(t){var n=t.getContext("2d").getImageData(0,0,t.width,t.height);return e.toGrayscaleBuffer(n.data,t.width,t.height)},e.toGrayscaleBuffer=function(t,n,i){var a=new Uint8ClampedArray(n*i);if(e.FRAME_INDEX=!e.FRAME_INDEX,e.FRAME_INDEX)for(var o=0,s=0,l=t.length;o<l;o+=4,s++){var u=void 0,c=t[o+3];if(c===0)u=255;else{var f=t[o],h=t[o+1],p=t[o+2];u=306*f+601*h+117*p+512>>10}a[s]=u}else for(var o=0,s=0,g=t.length;o<g;o+=4,s++){var u=void 0,c=t[o+3];if(c===0)u=255;else{var f=t[o],h=t[o+1],p=t[o+2];u=306*f+601*h+117*p+512>>10}a[s]=255-u}return a},e.prototype.getRow=function(t,n){if(t<0||t>=this.getHeight())throw new k("Requested row is outside the image: "+t);var i=this.getWidth(),a=t*i;return n===null?n=this.buffer.slice(a,a+i):(n.length<i&&(n=new Uint8ClampedArray(i)),n.set(this.buffer.slice(a,a+i))),n},e.prototype.getMatrix=function(){return this.buffer},e.prototype.isCropSupported=function(){return!0},e.prototype.crop=function(t,n,i,a){return r.prototype.crop.call(this,t,n,i,a),this},e.prototype.isRotateSupported=function(){return!0},e.prototype.rotateCounterClockwise=function(){return this.rotate(-90),this},e.prototype.rotateCounterClockwise45=function(){return this.rotate(-45),this},e.prototype.getTempCanvasElement=function(){if(this.tempCanvasElement===null){var t=this.canvas.ownerDocument.createElement("canvas");t.width=this.canvas.width,t.height=this.canvas.height,this.tempCanvasElement=t}return this.tempCanvasElement},e.prototype.rotate=function(t){var n=this.getTempCanvasElement(),i=n.getContext("2d"),a=t*e.DEGREE_TO_RADIANS,o=this.canvas.width,s=this.canvas.height,l=Math.ceil(Math.abs(Math.cos(a))*o+Math.abs(Math.sin(a))*s),u=Math.ceil(Math.abs(Math.sin(a))*o+Math.abs(Math.cos(a))*s);return n.width=l,n.height=u,i.translate(l/2,u/2),i.rotate(a),i.drawImage(this.canvas,o/-2,s/-2),this.buffer=e.makeBufferFromCanvasImageData(n),this},e.prototype.invert=function(){return new Gn(this)},e.DEGREE_TO_RADIANS=Math.PI/180,e.FRAME_INDEX=!0,e}(kr),wu=function(){function r(e,t,n){this.deviceId=e,this.label=t,this.kind="videoinput",this.groupId=n||void 0}return r.prototype.toJSON=function(){return{kind:this.kind,groupId:this.groupId,deviceId:this.deviceId,label:this.label}},r}(),Be=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(c){try{u(n.next(c))}catch(f){o(f)}}function l(c){try{u(n.throw(c))}catch(f){o(f)}}function u(c){c.done?a(c.value):i(c.value).then(s,l)}u((n=n.apply(r,e||[])).next())})},Le=function(r,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(u){return function(c){return l([u,c])}}function l(u){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(a=u[0]&2?i.return:u[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,u[1])).done)return a;switch(i=0,a&&(u=[u[0]&2,a.value]),u[0]){case 0:case 1:a=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,i=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){t.label=u[1];break}if(u[0]===6&&t.label<a[1]){t.label=a[1],a=u;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(u);break}a[2]&&t.ops.pop(),t.trys.pop();continue}u=e.call(r,t)}catch(c){u=[6,c],i=0}finally{n=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},_u=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Ut=function(){function r(e,t,n){t===void 0&&(t=500),this.reader=e,this.timeBetweenScansMillis=t,this._hints=n,this._stopContinuousDecode=!1,this._stopAsyncDecode=!1,this._timeBetweenDecodingAttempts=0}return Object.defineProperty(r.prototype,"hasNavigator",{get:function(){return typeof navigator<"u"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isMediaDevicesSuported",{get:function(){return this.hasNavigator&&!!navigator.mediaDevices},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"canEnumerateDevices",{get:function(){return!!(this.isMediaDevicesSuported&&navigator.mediaDevices.enumerateDevices)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"timeBetweenDecodingAttempts",{get:function(){return this._timeBetweenDecodingAttempts},set:function(e){this._timeBetweenDecodingAttempts=e<0?0:e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hints",{get:function(){return this._hints},set:function(e){this._hints=e||null},enumerable:!1,configurable:!0}),r.prototype.listVideoInputDevices=function(){return Be(this,void 0,void 0,function(){var e,t,n,i,a,o,s,l,u,c,f,h;return Le(this,function(p){switch(p.label){case 0:if(!this.hasNavigator)throw new Error("Can't enumerate devices, navigator is not present.");if(!this.canEnumerateDevices)throw new Error("Can't enumerate devices, method not supported.");return[4,navigator.mediaDevices.enumerateDevices()];case 1:e=p.sent(),t=[];try{for(n=_u(e),i=n.next();!i.done;i=n.next())a=i.value,o=a.kind==="video"?"videoinput":a.kind,o==="videoinput"&&(s=a.deviceId||a.id,l=a.label||"Video device "+(t.length+1),u=a.groupId,c={deviceId:s,label:l,kind:o,groupId:u},t.push(c))}catch(g){f={error:g}}finally{try{i&&!i.done&&(h=n.return)&&h.call(n)}finally{if(f)throw f.error}}return[2,t]}})})},r.prototype.getVideoInputDevices=function(){return Be(this,void 0,void 0,function(){var e;return Le(this,function(t){switch(t.label){case 0:return[4,this.listVideoInputDevices()];case 1:return e=t.sent(),[2,e.map(function(n){return new wu(n.deviceId,n.label)})]}})})},r.prototype.findDeviceById=function(e){return Be(this,void 0,void 0,function(){var t;return Le(this,function(n){switch(n.label){case 0:return[4,this.listVideoInputDevices()];case 1:return t=n.sent(),t?[2,t.find(function(i){return i.deviceId===e})]:[2,null]}})})},r.prototype.decodeFromInputVideoDevice=function(e,t){return Be(this,void 0,void 0,function(){return Le(this,function(n){switch(n.label){case 0:return[4,this.decodeOnceFromVideoDevice(e,t)];case 1:return[2,n.sent()]}})})},r.prototype.decodeOnceFromVideoDevice=function(e,t){return Be(this,void 0,void 0,function(){var n,i;return Le(this,function(a){switch(a.label){case 0:return this.reset(),e?n={deviceId:{exact:e}}:n={facingMode:"environment"},i={video:n},[4,this.decodeOnceFromConstraints(i,t)];case 1:return[2,a.sent()]}})})},r.prototype.decodeOnceFromConstraints=function(e,t){return Be(this,void 0,void 0,function(){var n;return Le(this,function(i){switch(i.label){case 0:return[4,navigator.mediaDevices.getUserMedia(e)];case 1:return n=i.sent(),[4,this.decodeOnceFromStream(n,t)];case 2:return[2,i.sent()]}})})},r.prototype.decodeOnceFromStream=function(e,t){return Be(this,void 0,void 0,function(){var n,i;return Le(this,function(a){switch(a.label){case 0:return this.reset(),[4,this.attachStreamToVideo(e,t)];case 1:return n=a.sent(),[4,this.decodeOnce(n)];case 2:return i=a.sent(),[2,i]}})})},r.prototype.decodeFromInputVideoDeviceContinuously=function(e,t,n){return Be(this,void 0,void 0,function(){return Le(this,function(i){switch(i.label){case 0:return[4,this.decodeFromVideoDevice(e,t,n)];case 1:return[2,i.sent()]}})})},r.prototype.decodeFromVideoDevice=function(e,t,n){return Be(this,void 0,void 0,function(){var i,a;return Le(this,function(o){switch(o.label){case 0:return e?i={deviceId:{exact:e}}:i={facingMode:"environment"},a={video:i},[4,this.decodeFromConstraints(a,t,n)];case 1:return[2,o.sent()]}})})},r.prototype.decodeFromConstraints=function(e,t,n){return Be(this,void 0,void 0,function(){var i;return Le(this,function(a){switch(a.label){case 0:return[4,navigator.mediaDevices.getUserMedia(e)];case 1:return i=a.sent(),[4,this.decodeFromStream(i,t,n)];case 2:return[2,a.sent()]}})})},r.prototype.decodeFromStream=function(e,t,n){return Be(this,void 0,void 0,function(){var i;return Le(this,function(a){switch(a.label){case 0:return this.reset(),[4,this.attachStreamToVideo(e,t)];case 1:return i=a.sent(),[4,this.decodeContinuously(i,n)];case 2:return[2,a.sent()]}})})},r.prototype.stopAsyncDecode=function(){this._stopAsyncDecode=!0},r.prototype.stopContinuousDecode=function(){this._stopContinuousDecode=!0},r.prototype.attachStreamToVideo=function(e,t){return Be(this,void 0,void 0,function(){var n;return Le(this,function(i){switch(i.label){case 0:return n=this.prepareVideoElement(t),this.addVideoSource(n,e),this.videoElement=n,this.stream=e,[4,this.playVideoOnLoadAsync(n)];case 1:return i.sent(),[2,n]}})})},r.prototype.playVideoOnLoadAsync=function(e){var t=this;return new Promise(function(n,i){return t.playVideoOnLoad(e,function(){return n()})})},r.prototype.playVideoOnLoad=function(e,t){var n=this;this.videoEndedListener=function(){return n.stopStreams()},this.videoCanPlayListener=function(){return n.tryPlayVideo(e)},e.addEventListener("ended",this.videoEndedListener),e.addEventListener("canplay",this.videoCanPlayListener),e.addEventListener("playing",t),this.tryPlayVideo(e)},r.prototype.isVideoPlaying=function(e){return e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2},r.prototype.tryPlayVideo=function(e){return Be(this,void 0,void 0,function(){return Le(this,function(t){switch(t.label){case 0:if(this.isVideoPlaying(e))return console.warn("Trying to play video that is already playing."),[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,e.play()];case 2:return t.sent(),[3,4];case 3:return t.sent(),console.warn("It was not possible to play the video."),[3,4];case 4:return[2]}})})},r.prototype.getMediaElement=function(e,t){var n=document.getElementById(e);if(!n)throw new Ke("element with id '"+e+"' not found");if(n.nodeName.toLowerCase()!==t.toLowerCase())throw new Ke("element with id '"+e+"' must be an "+t+" element");return n},r.prototype.decodeFromImage=function(e,t){if(!e&&!t)throw new Ke("either imageElement with a src set or an url must be provided");return t&&!e?this.decodeFromImageUrl(t):this.decodeFromImageElement(e)},r.prototype.decodeFromVideo=function(e,t){if(!e&&!t)throw new Ke("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrl(t):this.decodeFromVideoElement(e)},r.prototype.decodeFromVideoContinuously=function(e,t,n){if(e===void 0&&t===void 0)throw new Ke("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrlContinuously(t,n):this.decodeFromVideoElementContinuously(e,n)},r.prototype.decodeFromImageElement=function(e){if(!e)throw new Ke("An image element must be provided.");this.reset();var t=this.prepareImageElement(e);this.imageElement=t;var n;return this.isImageLoaded(t)?n=this.decodeOnce(t,!1,!0):n=this._decodeOnLoadImage(t),n},r.prototype.decodeFromVideoElement=function(e){var t=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideo(t)},r.prototype.decodeFromVideoElementContinuously=function(e,t){var n=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideoContinuously(n,t)},r.prototype._decodeFromVideoElementSetup=function(e){if(!e)throw new Ke("A video element must be provided.");this.reset();var t=this.prepareVideoElement(e);return this.videoElement=t,t},r.prototype.decodeFromImageUrl=function(e){if(!e)throw new Ke("An URL must be provided.");this.reset();var t=this.prepareImageElement();this.imageElement=t;var n=this._decodeOnLoadImage(t);return t.src=e,n},r.prototype.decodeFromVideoUrl=function(e){if(!e)throw new Ke("An URL must be provided.");this.reset();var t=this.prepareVideoElement(),n=this.decodeFromVideoElement(t);return t.src=e,n},r.prototype.decodeFromVideoUrlContinuously=function(e,t){if(!e)throw new Ke("An URL must be provided.");this.reset();var n=this.prepareVideoElement(),i=this.decodeFromVideoElementContinuously(n,t);return n.src=e,i},r.prototype._decodeOnLoadImage=function(e){var t=this;return new Promise(function(n,i){t.imageLoadedListener=function(){return t.decodeOnce(e,!1,!0).then(n,i)},e.addEventListener("load",t.imageLoadedListener)})},r.prototype._decodeOnLoadVideo=function(e){return Be(this,void 0,void 0,function(){return Le(this,function(t){switch(t.label){case 0:return[4,this.playVideoOnLoadAsync(e)];case 1:return t.sent(),[4,this.decodeOnce(e)];case 2:return[2,t.sent()]}})})},r.prototype._decodeOnLoadVideoContinuously=function(e,t){return Be(this,void 0,void 0,function(){return Le(this,function(n){switch(n.label){case 0:return[4,this.playVideoOnLoadAsync(e)];case 1:return n.sent(),this.decodeContinuously(e,t),[2]}})})},r.prototype.isImageLoaded=function(e){return!(!e.complete||e.naturalWidth===0)},r.prototype.prepareImageElement=function(e){var t;return typeof e>"u"&&(t=document.createElement("img"),t.width=200,t.height=200),typeof e=="string"&&(t=this.getMediaElement(e,"img")),e instanceof HTMLImageElement&&(t=e),t},r.prototype.prepareVideoElement=function(e){var t;return!e&&typeof document<"u"&&(t=document.createElement("video"),t.width=200,t.height=200),typeof e=="string"&&(t=this.getMediaElement(e,"video")),e instanceof HTMLVideoElement&&(t=e),t.setAttribute("autoplay","true"),t.setAttribute("muted","true"),t.setAttribute("playsinline","true"),t},r.prototype.decodeOnce=function(e,t,n){var i=this;t===void 0&&(t=!0),n===void 0&&(n=!0),this._stopAsyncDecode=!1;var a=function(o,s){if(i._stopAsyncDecode){s(new b("Video stream has ended before any code could be detected.")),i._stopAsyncDecode=void 0;return}try{var l=i.decode(e);o(l)}catch(h){var u=t&&h instanceof b,c=h instanceof we||h instanceof D,f=c&&n;if(u||f)return setTimeout(a,i._timeBetweenDecodingAttempts,o,s);s(h)}};return new Promise(function(o,s){return a(o,s)})},r.prototype.decodeContinuously=function(e,t){var n=this;this._stopContinuousDecode=!1;var i=function(){if(n._stopContinuousDecode){n._stopContinuousDecode=void 0;return}try{var a=n.decode(e);t(a,null),setTimeout(i,n.timeBetweenScansMillis)}catch(l){t(null,l);var o=l instanceof we||l instanceof D,s=l instanceof b;(o||s)&&setTimeout(i,n._timeBetweenDecodingAttempts)}};i()},r.prototype.decode=function(e){var t=this.createBinaryBitmap(e);return this.decodeBitmap(t)},r.prototype.createBinaryBitmap=function(e){this.getCaptureCanvasContext(e),e instanceof HTMLVideoElement?this.drawFrameOnCanvas(e):this.drawImageOnCanvas(e);var t=this.getCaptureCanvas(e),n=new mu(t),i=new xu(n);return new iu(i)},r.prototype.getCaptureCanvasContext=function(e){if(!this.captureCanvasContext){var t=this.getCaptureCanvas(e),n=void 0;try{n=t.getContext("2d",{willReadFrequently:!0})}catch{n=t.getContext("2d")}this.captureCanvasContext=n}return this.captureCanvasContext},r.prototype.getCaptureCanvas=function(e){if(!this.captureCanvas){var t=this.createCaptureCanvas(e);this.captureCanvas=t}return this.captureCanvas},r.prototype.drawFrameOnCanvas=function(e,t,n){t===void 0&&(t={sx:0,sy:0,sWidth:e.videoWidth,sHeight:e.videoHeight,dx:0,dy:0,dWidth:e.videoWidth,dHeight:e.videoHeight}),n===void 0&&(n=this.captureCanvasContext),n.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)},r.prototype.drawImageOnCanvas=function(e,t,n){t===void 0&&(t={sx:0,sy:0,sWidth:e.naturalWidth,sHeight:e.naturalHeight,dx:0,dy:0,dWidth:e.naturalWidth,dHeight:e.naturalHeight}),n===void 0&&(n=this.captureCanvasContext),n.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)},r.prototype.decodeBitmap=function(e){return this.reader.decode(e,this._hints)},r.prototype.createCaptureCanvas=function(e){if(typeof document>"u")return this._destroyCaptureCanvas(),null;var t=document.createElement("canvas"),n,i;return typeof e<"u"&&(e instanceof HTMLVideoElement?(n=e.videoWidth,i=e.videoHeight):e instanceof HTMLImageElement&&(n=e.naturalWidth||e.width,i=e.naturalHeight||e.height)),t.style.width=n+"px",t.style.height=i+"px",t.width=n,t.height=i,t},r.prototype.stopStreams=function(){this.stream&&(this.stream.getVideoTracks().forEach(function(e){return e.stop()}),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()},r.prototype.reset=function(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()},r.prototype._destroyVideoElement=function(){this.videoElement&&(typeof this.videoEndedListener<"u"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener<"u"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener<"u"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)},r.prototype._destroyImageElement=function(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)},r.prototype._destroyCaptureCanvas=function(){this.captureCanvasContext=void 0,this.captureCanvas=void 0},r.prototype.addVideoSource=function(e,t){try{e.srcObject=t}catch{e.src=URL.createObjectURL(t)}},r.prototype.cleanVideoSource=function(e){try{e.srcObject=null}catch{e.src=""}this.videoElement.removeAttribute("src")},r}(),De=function(){function r(e,t,n,i,a,o){n===void 0&&(n=t==null?0:8*t.length),o===void 0&&(o=ie.currentTimeMillis()),this.text=e,this.rawBytes=t,this.numBits=n,this.resultPoints=i,this.format=a,this.timestamp=o,this.text=e,this.rawBytes=t,n==null?this.numBits=t==null?0:8*t.length:this.numBits=n,this.resultPoints=i,this.format=a,this.resultMetadata=null,o==null?this.timestamp=ie.currentTimeMillis():this.timestamp=o}return r.prototype.getText=function(){return this.text},r.prototype.getRawBytes=function(){return this.rawBytes},r.prototype.getNumBits=function(){return this.numBits},r.prototype.getResultPoints=function(){return this.resultPoints},r.prototype.getBarcodeFormat=function(){return this.format},r.prototype.getResultMetadata=function(){return this.resultMetadata},r.prototype.putMetadata=function(e,t){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(e,t)},r.prototype.putAllMetadata=function(e){e!==null&&(this.resultMetadata===null?this.resultMetadata=e:this.resultMetadata=new Map(e))},r.prototype.addResultPoints=function(e){var t=this.resultPoints;if(t===null)this.resultPoints=e;else if(e!==null&&e.length>0){var n=new Array(t.length+e.length);ie.arraycopy(t,0,n,0,t.length),ie.arraycopy(e,0,n,t.length,e.length),this.resultPoints=n}},r.prototype.getTimestamp=function(){return this.timestamp},r.prototype.toString=function(){return this.text},r}(),Hn;(function(r){r[r.AZTEC=0]="AZTEC",r[r.CODABAR=1]="CODABAR",r[r.CODE_39=2]="CODE_39",r[r.CODE_93=3]="CODE_93",r[r.CODE_128=4]="CODE_128",r[r.DATA_MATRIX=5]="DATA_MATRIX",r[r.EAN_8=6]="EAN_8",r[r.EAN_13=7]="EAN_13",r[r.ITF=8]="ITF",r[r.MAXICODE=9]="MAXICODE",r[r.PDF_417=10]="PDF_417",r[r.QR_CODE=11]="QR_CODE",r[r.RSS_14=12]="RSS_14",r[r.RSS_EXPANDED=13]="RSS_EXPANDED",r[r.UPC_A=14]="UPC_A",r[r.UPC_E=15]="UPC_E",r[r.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(Hn||(Hn={}));const P=Hn;var qn;(function(r){r[r.OTHER=0]="OTHER",r[r.ORIENTATION=1]="ORIENTATION",r[r.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",r[r.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",r[r.ISSUE_NUMBER=4]="ISSUE_NUMBER",r[r.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",r[r.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",r[r.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",r[r.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",r[r.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",r[r.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(qn||(qn={}));const Oe=qn;var Ur=function(){function r(e,t,n,i,a,o){a===void 0&&(a=-1),o===void 0&&(o=-1),this.rawBytes=e,this.text=t,this.byteSegments=n,this.ecLevel=i,this.structuredAppendSequenceNumber=a,this.structuredAppendParity=o,this.numBits=e==null?0:8*e.length}return r.prototype.getRawBytes=function(){return this.rawBytes},r.prototype.getNumBits=function(){return this.numBits},r.prototype.setNumBits=function(e){this.numBits=e},r.prototype.getText=function(){return this.text},r.prototype.getByteSegments=function(){return this.byteSegments},r.prototype.getECLevel=function(){return this.ecLevel},r.prototype.getErrorsCorrected=function(){return this.errorsCorrected},r.prototype.setErrorsCorrected=function(e){this.errorsCorrected=e},r.prototype.getErasures=function(){return this.erasures},r.prototype.setErasures=function(e){this.erasures=e},r.prototype.getOther=function(){return this.other},r.prototype.setOther=function(e){this.other=e},r.prototype.hasStructuredAppend=function(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0},r.prototype.getStructuredAppendParity=function(){return this.structuredAppendParity},r.prototype.getStructuredAppendSequenceNumber=function(){return this.structuredAppendSequenceNumber},r}(),nr=function(){function r(){}return r.prototype.exp=function(e){return this.expTable[e]},r.prototype.log=function(e){if(e===0)throw new k;return this.logTable[e]},r.addOrSubtract=function(e,t){return e^t},r}(),lt=function(){function r(e,t){if(t.length===0)throw new k;this.field=e;var n=t.length;if(n>1&&t[0]===0){for(var i=1;i<n&&t[i]===0;)i++;i===n?this.coefficients=Int32Array.from([0]):(this.coefficients=new Int32Array(n-i),ie.arraycopy(t,i,this.coefficients,0,this.coefficients.length))}else this.coefficients=t}return r.prototype.getCoefficients=function(){return this.coefficients},r.prototype.getDegree=function(){return this.coefficients.length-1},r.prototype.isZero=function(){return this.coefficients[0]===0},r.prototype.getCoefficient=function(e){return this.coefficients[this.coefficients.length-1-e]},r.prototype.evaluateAt=function(e){if(e===0)return this.getCoefficient(0);var t=this.coefficients,n;if(e===1){n=0;for(var i=0,a=t.length;i!==a;i++){var o=t[i];n=nr.addOrSubtract(n,o)}return n}n=t[0];for(var s=t.length,l=this.field,i=1;i<s;i++)n=nr.addOrSubtract(l.multiply(e,n),t[i]);return n},r.prototype.addOrSubtract=function(e){if(!this.field.equals(e.field))throw new k("GenericGFPolys do not have same GenericGF field");if(this.isZero())return e;if(e.isZero())return this;var t=this.coefficients,n=e.coefficients;if(t.length>n.length){var i=t;t=n,n=i}var a=new Int32Array(n.length),o=n.length-t.length;ie.arraycopy(n,0,a,0,o);for(var s=o;s<n.length;s++)a[s]=nr.addOrSubtract(t[s-o],n[s]);return new r(this.field,a)},r.prototype.multiply=function(e){if(!this.field.equals(e.field))throw new k("GenericGFPolys do not have same GenericGF field");if(this.isZero()||e.isZero())return this.field.getZero();for(var t=this.coefficients,n=t.length,i=e.coefficients,a=i.length,o=new Int32Array(n+a-1),s=this.field,l=0;l<n;l++)for(var u=t[l],c=0;c<a;c++)o[l+c]=nr.addOrSubtract(o[l+c],s.multiply(u,i[c]));return new r(s,o)},r.prototype.multiplyScalar=function(e){if(e===0)return this.field.getZero();if(e===1)return this;for(var t=this.coefficients.length,n=this.field,i=new Int32Array(t),a=this.coefficients,o=0;o<t;o++)i[o]=n.multiply(a[o],e);return new r(n,i)},r.prototype.multiplyByMonomial=function(e,t){if(e<0)throw new k;if(t===0)return this.field.getZero();for(var n=this.coefficients,i=n.length,a=new Int32Array(i+e),o=this.field,s=0;s<i;s++)a[s]=o.multiply(n[s],t);return new r(o,a)},r.prototype.divide=function(e){if(!this.field.equals(e.field))throw new k("GenericGFPolys do not have same GenericGF field");if(e.isZero())throw new k("Divide by 0");for(var t=this.field,n=t.getZero(),i=this,a=e.getCoefficient(e.getDegree()),o=t.inverse(a);i.getDegree()>=e.getDegree()&&!i.isZero();){var s=i.getDegree()-e.getDegree(),l=t.multiply(i.getCoefficient(i.getDegree()),o),u=e.multiplyByMonomial(s,l),c=t.buildMonomial(s,l);n=n.addOrSubtract(c),i=i.addOrSubtract(u)}return[n,i]},r.prototype.toString=function(){for(var e="",t=this.getDegree();t>=0;t--){var n=this.getCoefficient(t);if(n!==0){if(n<0?(e+=" - ",n=-n):e.length>0&&(e+=" + "),t===0||n!==1){var i=this.field.log(n);i===0?e+="1":i===1?e+="a":(e+="a^",e+=i)}t!==0&&(t===1?e+="x":(e+="x^",e+=t))}}return e},r}(),Au=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Ta=function(r){Au(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="ArithmeticException",e}(Ue),Su=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Re=function(r){Su(e,r);function e(t,n,i){var a=r.call(this)||this;a.primitive=t,a.size=n,a.generatorBase=i;for(var o=new Int32Array(n),s=1,l=0;l<n;l++)o[l]=s,s*=2,s>=n&&(s^=t,s&=n-1);a.expTable=o;for(var u=new Int32Array(n),l=0;l<n-1;l++)u[o[l]]=l;return a.logTable=u,a.zero=new lt(a,Int32Array.from([0])),a.one=new lt(a,Int32Array.from([1])),a}return e.prototype.getZero=function(){return this.zero},e.prototype.getOne=function(){return this.one},e.prototype.buildMonomial=function(t,n){if(t<0)throw new k;if(n===0)return this.zero;var i=new Int32Array(t+1);return i[0]=n,new lt(this,i)},e.prototype.inverse=function(t){if(t===0)throw new Ta;return this.expTable[this.size-this.logTable[t]-1]},e.prototype.multiply=function(t,n){return t===0||n===0?0:this.expTable[(this.logTable[t]+this.logTable[n])%(this.size-1)]},e.prototype.getSize=function(){return this.size},e.prototype.getGeneratorBase=function(){return this.generatorBase},e.prototype.toString=function(){return"GF(0x"+$.toHexString(this.primitive)+","+this.size+")"},e.prototype.equals=function(t){return t===this},e.AZTEC_DATA_12=new e(4201,4096,1),e.AZTEC_DATA_10=new e(1033,1024,1),e.AZTEC_DATA_6=new e(67,64,1),e.AZTEC_PARAM=new e(19,16,1),e.QR_CODE_FIELD_256=new e(285,256,0),e.DATA_MATRIX_FIELD_256=new e(301,256,1),e.AZTEC_DATA_8=e.DATA_MATRIX_FIELD_256,e.MAXICODE_FIELD_64=e.AZTEC_DATA_6,e}(nr),Eu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Rr=function(r){Eu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="ReedSolomonException",e}(Ue),Iu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),ir=function(r){Iu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="IllegalStateException",e}(Ue),Gr=function(){function r(e){this.field=e}return r.prototype.decode=function(e,t){for(var n=this.field,i=new lt(n,e),a=new Int32Array(t),o=!0,s=0;s<t;s++){var l=i.evaluateAt(n.exp(s+n.getGeneratorBase()));a[a.length-1-s]=l,l!==0&&(o=!1)}if(!o)for(var u=new lt(n,a),c=this.runEuclideanAlgorithm(n.buildMonomial(t,1),u,t),f=c[0],h=c[1],p=this.findErrorLocations(f),g=this.findErrorMagnitudes(h,p),s=0;s<p.length;s++){var x=e.length-1-n.log(p[s]);if(x<0)throw new Rr("Bad error location");e[x]=Re.addOrSubtract(e[x],g[s])}},r.prototype.runEuclideanAlgorithm=function(e,t,n){if(e.getDegree()<t.getDegree()){var i=e;e=t,t=i}for(var a=this.field,o=e,s=t,l=a.getZero(),u=a.getOne();s.getDegree()>=(n/2|0);){var c=o,f=l;if(o=s,l=u,o.isZero())throw new Rr("r_{i-1} was zero");s=c;for(var h=a.getZero(),p=o.getCoefficient(o.getDegree()),g=a.inverse(p);s.getDegree()>=o.getDegree()&&!s.isZero();){var x=s.getDegree()-o.getDegree(),m=a.multiply(s.getCoefficient(s.getDegree()),g);h=h.addOrSubtract(a.buildMonomial(x,m)),s=s.addOrSubtract(o.multiplyByMonomial(x,m))}if(u=h.multiply(l).addOrSubtract(f),s.getDegree()>=o.getDegree())throw new ir("Division algorithm failed to reduce polynomial?")}var w=u.getCoefficient(0);if(w===0)throw new Rr("sigmaTilde(0) was zero");var A=a.inverse(w),E=u.multiplyScalar(A),S=s.multiplyScalar(A);return[E,S]},r.prototype.findErrorLocations=function(e){var t=e.getDegree();if(t===1)return Int32Array.from([e.getCoefficient(1)]);for(var n=new Int32Array(t),i=0,a=this.field,o=1;o<a.getSize()&&i<t;o++)e.evaluateAt(o)===0&&(n[i]=a.inverse(o),i++);if(i!==t)throw new Rr("Error locator degree does not match number of roots");return n},r.prototype.findErrorMagnitudes=function(e,t){for(var n=t.length,i=new Int32Array(n),a=this.field,o=0;o<n;o++){for(var s=a.inverse(t[o]),l=1,u=0;u<n;u++)if(o!==u){var c=a.multiply(t[u],s),f=(c&1)===0?c|1:c&-2;l=a.multiply(l,f)}i[o]=a.multiply(e.evaluateAt(s),a.inverse(l)),a.getGeneratorBase()!==0&&(i[o]=a.multiply(i[o],s))}return i},r}(),be;(function(r){r[r.UPPER=0]="UPPER",r[r.LOWER=1]="LOWER",r[r.MIXED=2]="MIXED",r[r.DIGIT=3]="DIGIT",r[r.PUNCT=4]="PUNCT",r[r.BINARY=5]="BINARY"})(be||(be={}));var Ma=function(){function r(){}return r.prototype.decode=function(e){this.ddata=e;var t=e.getBits(),n=this.extractBits(t),i=this.correctBits(n),a=r.convertBoolArrayToByteArray(i),o=r.getEncodedData(i),s=new Ur(a,o,null,null);return s.setNumBits(i.length),s},r.highLevelDecode=function(e){return this.getEncodedData(e)},r.getEncodedData=function(e){for(var t=e.length,n=be.UPPER,i=be.UPPER,a="",o=0;o<t;)if(i===be.BINARY){if(t-o<5)break;var s=r.readCode(e,o,5);if(o+=5,s===0){if(t-o<11)break;s=r.readCode(e,o,11)+31,o+=11}for(var l=0;l<s;l++){if(t-o<8){o=t;break}var u=r.readCode(e,o,8);a+=X.castAsNonUtf8Char(u),o+=8}i=n}else{var c=i===be.DIGIT?4:5;if(t-o<c)break;var u=r.readCode(e,o,c);o+=c;var f=r.getCharacter(i,u);f.startsWith("CTRL_")?(n=i,i=r.getTable(f.charAt(5)),f.charAt(6)==="L"&&(n=i)):(a+=f,i=n)}return a},r.getTable=function(e){switch(e){case"L":return be.LOWER;case"P":return be.PUNCT;case"M":return be.MIXED;case"D":return be.DIGIT;case"B":return be.BINARY;case"U":default:return be.UPPER}},r.getCharacter=function(e,t){switch(e){case be.UPPER:return r.UPPER_TABLE[t];case be.LOWER:return r.LOWER_TABLE[t];case be.MIXED:return r.MIXED_TABLE[t];case be.PUNCT:return r.PUNCT_TABLE[t];case be.DIGIT:return r.DIGIT_TABLE[t];default:throw new ir("Bad table")}},r.prototype.correctBits=function(e){var t,n;this.ddata.getNbLayers()<=2?(n=6,t=Re.AZTEC_DATA_6):this.ddata.getNbLayers()<=8?(n=8,t=Re.AZTEC_DATA_8):this.ddata.getNbLayers()<=22?(n=10,t=Re.AZTEC_DATA_10):(n=12,t=Re.AZTEC_DATA_12);var i=this.ddata.getNbDatablocks(),a=e.length/n;if(a<i)throw new D;for(var o=e.length%n,s=new Int32Array(a),l=0;l<a;l++,o+=n)s[l]=r.readCode(e,o,n);try{var u=new Gr(t);u.decode(s,a-i)}catch(m){throw new D(m)}for(var c=(1<<n)-1,f=0,l=0;l<i;l++){var h=s[l];if(h===0||h===c)throw new D;(h===1||h===c-1)&&f++}for(var p=new Array(i*n-f),g=0,l=0;l<i;l++){var h=s[l];if(h===1||h===c-1)p.fill(h>1,g,g+n-1),g+=n-1;else for(var x=n-1;x>=0;--x)p[g++]=(h&1<<x)!==0}return p},r.prototype.extractBits=function(e){var t=this.ddata.isCompact(),n=this.ddata.getNbLayers(),i=(t?11:14)+n*4,a=new Int32Array(i),o=new Array(this.totalBitsInLayer(n,t));if(t)for(var s=0;s<a.length;s++)a[s]=s;else for(var l=i+1+2*$.truncDivision($.truncDivision(i,2)-1,15),u=i/2,c=$.truncDivision(l,2),s=0;s<u;s++){var f=s+$.truncDivision(s,15);a[u-s-1]=c-f-1,a[u+s]=c+f+1}for(var s=0,h=0;s<n;s++){for(var p=(n-s)*4+(t?9:12),g=s*2,x=i-1-g,m=0;m<p;m++)for(var w=m*2,A=0;A<2;A++)o[h+w+A]=e.get(a[g+A],a[g+m]),o[h+2*p+w+A]=e.get(a[g+m],a[x-A]),o[h+4*p+w+A]=e.get(a[x-A],a[x-m]),o[h+6*p+w+A]=e.get(a[x-m],a[g+A]);h+=p*8}return o},r.readCode=function(e,t,n){for(var i=0,a=t;a<t+n;a++)i<<=1,e[a]&&(i|=1);return i},r.readByte=function(e,t){var n=e.length-t;return n>=8?r.readCode(e,t,8):r.readCode(e,t,n)<<8-n},r.convertBoolArrayToByteArray=function(e){for(var t=new Uint8Array((e.length+7)/8),n=0;n<t.length;n++)t[n]=r.readByte(e,8*n);return t},r.prototype.totalBitsInLayer=function(e,t){return((t?88:112)+16*e)*e},r.UPPER_TABLE=["CTRL_PS"," ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","CTRL_LL","CTRL_ML","CTRL_DL","CTRL_BS"],r.LOWER_TABLE=["CTRL_PS"," ","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","CTRL_US","CTRL_ML","CTRL_DL","CTRL_BS"],r.MIXED_TABLE=["CTRL_PS"," ","\\1","\\2","\\3","\\4","\\5","\\6","\\7","\b"," ",`
|
|
@@ -272,4 +272,4 @@
|
|
|
272
272
|
`),e.append(`>>
|
|
273
273
|
`),e.toString()},r.prototype.setMode=function(e){this.mode=e},r.prototype.setECLevel=function(e){this.ecLevel=e},r.prototype.setVersion=function(e){this.version=e},r.prototype.setMaskPattern=function(e){this.maskPattern=e},r.prototype.setMatrix=function(e){this.matrix=e},r.isValidMaskPattern=function(e){return e>=0&&e<r.NUM_MASK_PATTERNS},r.NUM_MASK_PATTERNS=8,r}(),Rd=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),oe=function(r){Rd(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.kind="WriterException",e}(Ue),co=function(){function r(){}return r.clearMatrix=function(e){e.clear(255)},r.buildMatrix=function(e,t,n,i,a){r.clearMatrix(a),r.embedBasicPatterns(n,a),r.embedTypeInfo(t,i,a),r.maybeEmbedVersionInfo(n,a),r.embedDataBits(e,i,a)},r.embedBasicPatterns=function(e,t){r.embedPositionDetectionPatternsAndSeparators(t),r.embedDarkDotAtLeftBottomCorner(t),r.maybeEmbedPositionAdjustmentPatterns(e,t),r.embedTimingPatterns(t)},r.embedTypeInfo=function(e,t,n){var i=new _e;r.makeTypeInfoBits(e,t,i);for(var a=0,o=i.getSize();a<o;++a){var s=i.get(i.getSize()-1-a),l=r.TYPE_INFO_COORDINATES[a],u=l[0],c=l[1];if(n.setBoolean(u,c,s),a<8){var f=n.getWidth()-a-1,h=8;n.setBoolean(f,h,s)}else{var f=8,h=n.getHeight()-7+(a-8);n.setBoolean(f,h,s)}}},r.maybeEmbedVersionInfo=function(e,t){if(!(e.getVersionNumber()<7)){var n=new _e;r.makeVersionInfoBits(e,n);for(var i=17,a=0;a<6;++a)for(var o=0;o<3;++o){var s=n.get(i);i--,t.setBoolean(a,t.getHeight()-11+o,s),t.setBoolean(t.getHeight()-11+o,a,s)}}},r.embedDataBits=function(e,t,n){for(var i=0,a=-1,o=n.getWidth()-1,s=n.getHeight()-1;o>0;){for(o===6&&(o-=1);s>=0&&s<n.getHeight();){for(var l=0;l<2;++l){var u=o-l;if(r.isEmpty(n.get(u,s))){var c=void 0;i<e.getSize()?(c=e.get(i),++i):c=!1,t!==255&&ur.getDataMaskBit(t,u,s)&&(c=!c),n.setBoolean(u,s,c)}}s+=a}a=-a,s+=a,o-=2}if(i!==e.getSize())throw new oe("Not all bits consumed: "+i+"/"+e.getSize())},r.findMSBSet=function(e){return 32-$.numberOfLeadingZeros(e)},r.calculateBCHCode=function(e,t){if(t===0)throw new k("0 polynomial");var n=r.findMSBSet(t);for(e<<=n-1;r.findMSBSet(e)>=n;)e^=t<<r.findMSBSet(e)-n;return e},r.makeTypeInfoBits=function(e,t,n){if(!ui.isValidMaskPattern(t))throw new oe("Invalid mask pattern");var i=e.getBits()<<3|t;n.appendBits(i,5);var a=r.calculateBCHCode(i,r.TYPE_INFO_POLY);n.appendBits(a,10);var o=new _e;if(o.appendBits(r.TYPE_INFO_MASK_PATTERN,15),n.xor(o),n.getSize()!==15)throw new oe("should not happen but we got: "+n.getSize())},r.makeVersionInfoBits=function(e,t){t.appendBits(e.getVersionNumber(),6);var n=r.calculateBCHCode(e.getVersionNumber(),r.VERSION_INFO_POLY);if(t.appendBits(n,12),t.getSize()!==18)throw new oe("should not happen but we got: "+t.getSize())},r.isEmpty=function(e){return e===255},r.embedTimingPatterns=function(e){for(var t=8;t<e.getWidth()-8;++t){var n=(t+1)%2;r.isEmpty(e.get(t,6))&&e.setNumber(t,6,n),r.isEmpty(e.get(6,t))&&e.setNumber(6,t,n)}},r.embedDarkDotAtLeftBottomCorner=function(e){if(e.get(8,e.getHeight()-8)===0)throw new oe;e.setNumber(8,e.getHeight()-8,1)},r.embedHorizontalSeparationPattern=function(e,t,n){for(var i=0;i<8;++i){if(!r.isEmpty(n.get(e+i,t)))throw new oe;n.setNumber(e+i,t,0)}},r.embedVerticalSeparationPattern=function(e,t,n){for(var i=0;i<7;++i){if(!r.isEmpty(n.get(e,t+i)))throw new oe;n.setNumber(e,t+i,0)}},r.embedPositionAdjustmentPattern=function(e,t,n){for(var i=0;i<5;++i)for(var a=r.POSITION_ADJUSTMENT_PATTERN[i],o=0;o<5;++o)n.setNumber(e+o,t+i,a[o])},r.embedPositionDetectionPattern=function(e,t,n){for(var i=0;i<7;++i)for(var a=r.POSITION_DETECTION_PATTERN[i],o=0;o<7;++o)n.setNumber(e+o,t+i,a[o])},r.embedPositionDetectionPatternsAndSeparators=function(e){var t=r.POSITION_DETECTION_PATTERN[0].length;r.embedPositionDetectionPattern(0,0,e),r.embedPositionDetectionPattern(e.getWidth()-t,0,e),r.embedPositionDetectionPattern(0,e.getWidth()-t,e);var n=8;r.embedHorizontalSeparationPattern(0,n-1,e),r.embedHorizontalSeparationPattern(e.getWidth()-n,n-1,e),r.embedHorizontalSeparationPattern(0,e.getWidth()-n,e);var i=7;r.embedVerticalSeparationPattern(i,0,e),r.embedVerticalSeparationPattern(e.getHeight()-i-1,0,e),r.embedVerticalSeparationPattern(i,e.getHeight()-i,e)},r.maybeEmbedPositionAdjustmentPatterns=function(e,t){if(!(e.getVersionNumber()<2))for(var n=e.getVersionNumber()-1,i=r.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[n],a=0,o=i.length;a!==o;a++){var s=i[a];if(s>=0)for(var l=0;l!==o;l++){var u=i[l];u>=0&&r.isEmpty(t.get(u,s))&&r.embedPositionAdjustmentPattern(u-2,s-2,t)}}},r.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),r.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),r.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),r.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),r.VERSION_INFO_POLY=7973,r.TYPE_INFO_POLY=1335,r.TYPE_INFO_MASK_PATTERN=21522,r}(),Gd=function(){function r(e,t){this.dataBytes=e,this.errorCorrectionBytes=t}return r.prototype.getDataBytes=function(){return this.dataBytes},r.prototype.getErrorCorrectionBytes=function(){return this.errorCorrectionBytes},r}(),fo=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};(function(){function r(){}return r.calculateMaskPenalty=function(e){return ur.applyMaskPenaltyRule1(e)+ur.applyMaskPenaltyRule2(e)+ur.applyMaskPenaltyRule3(e)+ur.applyMaskPenaltyRule4(e)},r.encode=function(e,t,n){n===void 0&&(n=null);var i=r.DEFAULT_BYTE_MODE_ENCODING,a=n!==null&&n.get(jr.CHARACTER_SET)!==void 0;a&&(i=n.get(jr.CHARACTER_SET).toString());var o=this.chooseMode(e,i),s=new _e;if(o===ae.BYTE&&(a||r.DEFAULT_BYTE_MODE_ENCODING!==i)){var l=he.getCharacterSetECIByName(i);l!==void 0&&this.appendECI(l,s)}this.appendModeInfo(o,s);var u=new _e;this.appendBytes(e,o,u,i);var c;if(n!==null&&n.get(jr.QR_VERSION)!==void 0){var f=Number.parseInt(n.get(jr.QR_VERSION).toString(),10);c=bt.getVersionForNumber(f);var h=this.calculateBitsNeeded(o,s,u,c);if(!this.willFit(h,c,t))throw new oe("Data too big for requested version")}else c=this.recommendVersion(t,o,s,u);var p=new _e;p.appendBitArray(s);var g=o===ae.BYTE?u.getSizeInBytes():e.length;this.appendLengthInfo(g,c,o,p),p.appendBitArray(u);var x=c.getECBlocksForLevel(t),m=c.getTotalCodewords()-x.getTotalECCodewords();this.terminateBits(m,p);var w=this.interleaveWithECBytes(p,c.getTotalCodewords(),m,x.getNumBlocks()),A=new ui;A.setECLevel(t),A.setMode(o),A.setVersion(c);var E=c.getDimensionForVersion(),S=new Ud(E,E),O=this.chooseMaskPattern(w,t,c,S);return A.setMaskPattern(O),co.buildMatrix(w,t,c,O,S),A.setMatrix(S),A},r.recommendVersion=function(e,t,n,i){var a=this.calculateBitsNeeded(t,n,i,bt.getVersionForNumber(1)),o=this.chooseVersion(a,e),s=this.calculateBitsNeeded(t,n,i,o);return this.chooseVersion(s,e)},r.calculateBitsNeeded=function(e,t,n,i){return t.getSize()+e.getCharacterCountBits(i)+n.getSize()},r.getAlphanumericCode=function(e){return e<r.ALPHANUMERIC_TABLE.length?r.ALPHANUMERIC_TABLE[e]:-1},r.chooseMode=function(e,t){if(t===void 0&&(t=null),he.SJIS.getName()===t&&this.isOnlyDoubleByteKanji(e))return ae.KANJI;for(var n=!1,i=!1,a=0,o=e.length;a<o;++a){var s=e.charAt(a);if(r.isDigit(s))n=!0;else if(this.getAlphanumericCode(s.charCodeAt(0))!==-1)i=!0;else return ae.BYTE}return i?ae.ALPHANUMERIC:n?ae.NUMERIC:ae.BYTE},r.isOnlyDoubleByteKanji=function(e){var t;try{t=Xe.encode(e,he.SJIS)}catch{return!1}var n=t.length;if(n%2!==0)return!1;for(var i=0;i<n;i+=2){var a=t[i]&255;if((a<129||a>159)&&(a<224||a>235))return!1}return!0},r.chooseMaskPattern=function(e,t,n,i){for(var a=Number.MAX_SAFE_INTEGER,o=-1,s=0;s<ui.NUM_MASK_PATTERNS;s++){co.buildMatrix(e,t,n,s,i);var l=this.calculateMaskPenalty(i);l<a&&(a=l,o=s)}return o},r.chooseVersion=function(e,t){for(var n=1;n<=40;n++){var i=bt.getVersionForNumber(n);if(r.willFit(e,i,t))return i}throw new oe("Data too big")},r.willFit=function(e,t,n){var i=t.getTotalCodewords(),a=t.getECBlocksForLevel(n),o=a.getTotalECCodewords(),s=i-o,l=(e+7)/8;return s>=l},r.terminateBits=function(e,t){var n=e*8;if(t.getSize()>n)throw new oe("data bits cannot fit in the QR Code"+t.getSize()+" > "+n);for(var i=0;i<4&&t.getSize()<n;++i)t.appendBit(!1);var a=t.getSize()&7;if(a>0)for(var i=a;i<8;i++)t.appendBit(!1);for(var o=e-t.getSizeInBytes(),i=0;i<o;++i)t.appendBits((i&1)===0?236:17,8);if(t.getSize()!==n)throw new oe("Bits size does not equal capacity")},r.getNumDataBytesAndNumECBytesForBlockID=function(e,t,n,i,a,o){if(i>=n)throw new oe("Block ID too large");var s=e%n,l=n-s,u=Math.floor(e/n),c=u+1,f=Math.floor(t/n),h=f+1,p=u-f,g=c-h;if(p!==g)throw new oe("EC bytes mismatch");if(n!==l+s)throw new oe("RS blocks mismatch");if(e!==(f+p)*l+(h+g)*s)throw new oe("Total bytes mismatch");i<l?(a[0]=f,o[0]=p):(a[0]=h,o[0]=g)},r.interleaveWithECBytes=function(e,t,n,i){var a,o,s,l;if(e.getSizeInBytes()!==n)throw new oe("Number of bits and data bytes does not match");for(var u=0,c=0,f=0,h=new Array,p=0;p<i;++p){var g=new Int32Array(1),x=new Int32Array(1);r.getNumDataBytesAndNumECBytesForBlockID(t,n,i,p,g,x);var m=g[0],w=new Uint8Array(m);e.toBytes(8*u,w,0,m);var A=r.generateECBytes(w,x[0]);h.push(new Gd(w,A)),c=Math.max(c,m),f=Math.max(f,A.length),u+=g[0]}if(n!==u)throw new oe("Data bytes does not match offset");for(var E=new _e,p=0;p<c;++p)try{for(var S=(a=void 0,fo(h)),O=S.next();!O.done;O=S.next()){var N=O.value,w=N.getDataBytes();p<w.length&&E.appendBits(w[p],8)}}catch(z){a={error:z}}finally{try{O&&!O.done&&(o=S.return)&&o.call(S)}finally{if(a)throw a.error}}for(var p=0;p<f;++p)try{for(var T=(s=void 0,fo(h)),V=T.next();!V.done;V=T.next()){var N=V.value,A=N.getErrorCorrectionBytes();p<A.length&&E.appendBits(A[p],8)}}catch(z){s={error:z}}finally{try{V&&!V.done&&(l=T.return)&&l.call(T)}finally{if(s)throw s.error}}if(t!==E.getSizeInBytes())throw new oe("Interleaving error: "+t+" and "+E.getSizeInBytes()+" differ.");return E},r.generateECBytes=function(e,t){for(var n=e.length,i=new Int32Array(n+t),a=0;a<n;a++)i[a]=e[a]&255;new uo(Re.QR_CODE_FIELD_256).encode(i,t);for(var o=new Uint8Array(t),a=0;a<t;a++)o[a]=i[n+a];return o},r.appendModeInfo=function(e,t){t.appendBits(e.getBits(),4)},r.appendLengthInfo=function(e,t,n,i){var a=n.getCharacterCountBits(t);if(e>=1<<a)throw new oe(e+" is bigger than "+((1<<a)-1));i.appendBits(e,a)},r.appendBytes=function(e,t,n,i){switch(t){case ae.NUMERIC:r.appendNumericBytes(e,n);break;case ae.ALPHANUMERIC:r.appendAlphanumericBytes(e,n);break;case ae.BYTE:r.append8BitBytes(e,n,i);break;case ae.KANJI:r.appendKanjiBytes(e,n);break;default:throw new oe("Invalid mode: "+t)}},r.getDigit=function(e){return e.charCodeAt(0)-48},r.isDigit=function(e){var t=r.getDigit(e);return t>=0&&t<=9},r.appendNumericBytes=function(e,t){for(var n=e.length,i=0;i<n;){var a=r.getDigit(e.charAt(i));if(i+2<n){var o=r.getDigit(e.charAt(i+1)),s=r.getDigit(e.charAt(i+2));t.appendBits(a*100+o*10+s,10),i+=3}else if(i+1<n){var o=r.getDigit(e.charAt(i+1));t.appendBits(a*10+o,7),i+=2}else t.appendBits(a,4),i++}},r.appendAlphanumericBytes=function(e,t){for(var n=e.length,i=0;i<n;){var a=r.getAlphanumericCode(e.charCodeAt(i));if(a===-1)throw new oe;if(i+1<n){var o=r.getAlphanumericCode(e.charCodeAt(i+1));if(o===-1)throw new oe;t.appendBits(a*45+o,11),i+=2}else t.appendBits(a,6),i++}},r.append8BitBytes=function(e,t,n){var i;try{i=Xe.encode(e,n)}catch(l){throw new oe(l)}for(var a=0,o=i.length;a!==o;a++){var s=i[a];t.appendBits(s,8)}},r.appendKanjiBytes=function(e,t){var n;try{n=Xe.encode(e,he.SJIS)}catch(f){throw new oe(f)}for(var i=n.length,a=0;a<i;a+=2){var o=n[a]&255,s=n[a+1]&255,l=o<<8&4294967295|s,u=-1;if(l>=33088&&l<=40956?u=l-33088:l>=57408&&l<=60351&&(u=l-49472),u===-1)throw new oe("Invalid byte sequence");var c=(u>>8)*192+(u&255);t.appendBits(c,13)}},r.appendECI=function(e,t){t.appendBits(ae.ECI.getBits(),4),t.appendBits(e.getValue(),8)},r.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),r.DEFAULT_BYTE_MODE_ENCODING=he.UTF8.getName(),r})();var Hd=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}();(function(r){Hd(e,r);function e(t,n,i,a,o,s,l,u){var c=r.call(this,s,l)||this;if(c.yuvData=t,c.dataWidth=n,c.dataHeight=i,c.left=a,c.top=o,a+s>n||o+l>i)throw new k("Crop rectangle does not fit within image data.");return u&&c.reverseHorizontal(s,l),c}return e.prototype.getRow=function(t,n){if(t<0||t>=this.getHeight())throw new k("Requested row is outside the image: "+t);var i=this.getWidth();(n==null||n.length<i)&&(n=new Uint8ClampedArray(i));var a=(t+this.top)*this.dataWidth+this.left;return ie.arraycopy(this.yuvData,a,n,0,i),n},e.prototype.getMatrix=function(){var t=this.getWidth(),n=this.getHeight();if(t===this.dataWidth&&n===this.dataHeight)return this.yuvData;var i=t*n,a=new Uint8ClampedArray(i),o=this.top*this.dataWidth+this.left;if(t===this.dataWidth)return ie.arraycopy(this.yuvData,o,a,0,i),a;for(var s=0;s<n;s++){var l=s*t;ie.arraycopy(this.yuvData,o,a,l,t),o+=this.dataWidth}return a},e.prototype.isCropSupported=function(){return!0},e.prototype.crop=function(t,n,i,a){return new e(this.yuvData,this.dataWidth,this.dataHeight,this.left+t,this.top+n,i,a,!1)},e.prototype.renderThumbnail=function(){for(var t=this.getWidth()/e.THUMBNAIL_SCALE_FACTOR,n=this.getHeight()/e.THUMBNAIL_SCALE_FACTOR,i=new Int32Array(t*n),a=this.yuvData,o=this.top*this.dataWidth+this.left,s=0;s<n;s++){for(var l=s*t,u=0;u<t;u++){var c=a[o+u*e.THUMBNAIL_SCALE_FACTOR]&255;i[l+u]=4278190080|c*65793}o+=this.dataWidth*e.THUMBNAIL_SCALE_FACTOR}return i},e.prototype.getThumbnailWidth=function(){return this.getWidth()/e.THUMBNAIL_SCALE_FACTOR},e.prototype.getThumbnailHeight=function(){return this.getHeight()/e.THUMBNAIL_SCALE_FACTOR},e.prototype.reverseHorizontal=function(t,n){for(var i=this.yuvData,a=0,o=this.top*this.dataWidth+this.left;a<n;a++,o+=this.dataWidth)for(var s=o+t/2,l=o,u=o+t-1;l<s;l++,u--){var c=i[l];i[l]=i[u],i[u]=c}},e.prototype.invert=function(){return new Gn(this)},e.THUMBNAIL_SCALE_FACTOR=2,e})(kr);var qd=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}();(function(r){qd(e,r);function e(t,n,i,a,o,s,l){var u=r.call(this,n,i)||this;if(u.dataWidth=a,u.dataHeight=o,u.left=s,u.top=l,t.BYTES_PER_ELEMENT===4){for(var c=n*i,f=new Uint8ClampedArray(c),h=0;h<c;h++){var p=t[h],g=p>>16&255,x=p>>7&510,m=p&255;f[h]=(g+x+m)/4&255}u.luminances=f}else u.luminances=t;if(a===void 0&&(u.dataWidth=n),o===void 0&&(u.dataHeight=i),s===void 0&&(u.left=0),l===void 0&&(u.top=0),u.left+n>u.dataWidth||u.top+i>u.dataHeight)throw new k("Crop rectangle does not fit within image data.");return u}return e.prototype.getRow=function(t,n){if(t<0||t>=this.getHeight())throw new k("Requested row is outside the image: "+t);var i=this.getWidth();(n==null||n.length<i)&&(n=new Uint8ClampedArray(i));var a=(t+this.top)*this.dataWidth+this.left;return ie.arraycopy(this.luminances,a,n,0,i),n},e.prototype.getMatrix=function(){var t=this.getWidth(),n=this.getHeight();if(t===this.dataWidth&&n===this.dataHeight)return this.luminances;var i=t*n,a=new Uint8ClampedArray(i),o=this.top*this.dataWidth+this.left;if(t===this.dataWidth)return ie.arraycopy(this.luminances,o,a,0,i),a;for(var s=0;s<n;s++){var l=s*t;ie.arraycopy(this.luminances,o,a,l,t),o+=this.dataWidth}return a},e.prototype.isCropSupported=function(){return!0},e.prototype.crop=function(t,n,i,a){return new e(this.luminances,i,a,this.dataWidth,this.dataHeight,this.left+t,this.top+n)},e.prototype.invert=function(){return new Gn(this)},e})(kr);var $d=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Xd=function(r){$d(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.forName=function(t){return this.getCharacterSetECIByName(t)},e}(he),Wd=function(){function r(){}return r.ISO_8859_1=he.ISO8859_1,r}(),ci,jd=301,Yd=function(r,e){for(var t=1,n=0;n<255;n++)e[n]=t,r[t]=n,t*=2,t>=256&&(t^=jd);return{LOG:r,ALOG:e}};ci=Yd([],[]),ci.LOG,ci.ALOG;var ho;(function(r){r[r.FORCE_NONE=0]="FORCE_NONE",r[r.FORCE_SQUARE=1]="FORCE_SQUARE",r[r.FORCE_RECTANGLE=2]="FORCE_RECTANGLE"})(ho||(ho={}));var po=129,vo=230,Zd=231,Kd=235,Qd=236,Jd=237,ef=238,tf=239,rf=240,di=254,nf=254,go="[)>05",xo="[)>06",yo="",re=0,Ne=1,ze=2,xe=3,Se=4,Fe=5,af=function(){function r(){}return r.prototype.getEncodingMode=function(){return re},r.prototype.encode=function(e){var t=et.determineConsecutiveDigitCount(e.getMessage(),e.pos);if(t>=2)e.writeCodeword(this.encodeASCIIDigits(e.getMessage().charCodeAt(e.pos),e.getMessage().charCodeAt(e.pos+1))),e.pos+=2;else{var n=e.getCurrentChar(),i=et.lookAheadTest(e.getMessage(),e.pos,this.getEncodingMode());if(i!==this.getEncodingMode())switch(i){case Fe:e.writeCodeword(Zd),e.signalEncoderChange(Fe);return;case Ne:e.writeCodeword(vo),e.signalEncoderChange(Ne);return;case xe:e.writeCodeword(ef),e.signalEncoderChange(xe);break;case ze:e.writeCodeword(tf),e.signalEncoderChange(ze);break;case Se:e.writeCodeword(rf),e.signalEncoderChange(Se);break;default:throw new Error("Illegal mode: "+i)}else et.isExtendedASCII(n)?(e.writeCodeword(Kd),e.writeCodeword(n-128+1),e.pos++):(e.writeCodeword(n+1),e.pos++)}},r.prototype.encodeASCIIDigits=function(e,t){if(et.isDigit(e)&&et.isDigit(t)){var n=(e-48)*10+(t-48);return n+130}throw new Error("not digits: "+e+t)},r}(),of=function(){function r(){}return r.prototype.getEncodingMode=function(){return Fe},r.prototype.encode=function(e){var t=new q;for(t.append(0);e.hasMoreCharacters();){var n=e.getCurrentChar();t.append(n),e.pos++;var i=et.lookAheadTest(e.getMessage(),e.pos,this.getEncodingMode());if(i!==this.getEncodingMode()){e.signalEncoderChange(re);break}}var a=t.length()-1,o=1,s=e.getCodewordCount()+a+o;e.updateSymbolInfo(s);var l=e.getSymbolInfo().getDataCapacity()-s>0;if(e.hasMoreCharacters()||l)if(a<=249)t.setCharAt(0,X.getCharAt(a));else if(a<=1555)t.setCharAt(0,X.getCharAt(Math.floor(a/250)+249)),t.insert(1,X.getCharAt(a%250));else throw new Error("Message length not in valid ranges: "+a);for(var u=0,n=t.length();u<n;u++)e.writeCodeword(this.randomize255State(t.charAt(u).charCodeAt(0),e.getCodewordCount()+1))},r.prototype.randomize255State=function(e,t){var n=149*t%255+1,i=e+n;return i<=255?i:i-256},r}(),fi=function(){function r(){}return r.prototype.getEncodingMode=function(){return Ne},r.prototype.encodeMaximal=function(e){for(var t=new q,n=0,i=e.pos,a=0;e.hasMoreCharacters();){var o=e.getCurrentChar();e.pos++,n=this.encodeChar(o,t),t.length()%3===0&&(i=e.pos,a=t.length())}if(a!==t.length()){var s=Math.floor(t.length()/3*2),l=Math.floor(e.getCodewordCount()+s+1);e.updateSymbolInfo(l);var u=e.getSymbolInfo().getDataCapacity()-l,c=Math.floor(t.length()%3);(c===2&&u!==2||c===1&&(n>3||u!==1))&&(e.pos=i)}t.length()>0&&e.writeCodeword(vo),this.handleEOD(e,t)},r.prototype.encode=function(e){for(var t=new q;e.hasMoreCharacters();){var n=e.getCurrentChar();e.pos++;var i=this.encodeChar(n,t),a=Math.floor(t.length()/3)*2,o=e.getCodewordCount()+a;e.updateSymbolInfo(o);var s=e.getSymbolInfo().getDataCapacity()-o;if(!e.hasMoreCharacters()){var l=new q;for(t.length()%3===2&&s!==2&&(i=this.backtrackOneCharacter(e,t,l,i));t.length()%3===1&&(i>3||s!==1);)i=this.backtrackOneCharacter(e,t,l,i);break}var u=t.length();if(u%3===0){var c=et.lookAheadTest(e.getMessage(),e.pos,this.getEncodingMode());if(c!==this.getEncodingMode()){e.signalEncoderChange(re);break}}}this.handleEOD(e,t)},r.prototype.backtrackOneCharacter=function(e,t,n,i){var a=t.length(),o=t.toString().substring(0,a-i);t.setLengthToZero(),t.append(o),e.pos--;var s=e.getCurrentChar();return i=this.encodeChar(s,n),e.resetSymbolInfo(),i},r.prototype.writeNextTriplet=function(e,t){e.writeCodewords(this.encodeToCodewords(t.toString()));var n=t.toString().substring(3);t.setLengthToZero(),t.append(n)},r.prototype.handleEOD=function(e,t){var n=Math.floor(t.length()/3*2),i=t.length()%3,a=e.getCodewordCount()+n;e.updateSymbolInfo(a);var o=e.getSymbolInfo().getDataCapacity()-a;if(i===2){for(t.append("\0");t.length()>=3;)this.writeNextTriplet(e,t);e.hasMoreCharacters()&&e.writeCodeword(di)}else if(o===1&&i===1){for(;t.length()>=3;)this.writeNextTriplet(e,t);e.hasMoreCharacters()&&e.writeCodeword(di),e.pos--}else if(i===0){for(;t.length()>=3;)this.writeNextTriplet(e,t);(o>0||e.hasMoreCharacters())&&e.writeCodeword(di)}else throw new Error("Unexpected case. Please report!");e.signalEncoderChange(re)},r.prototype.encodeChar=function(e,t){if(e===32)return t.append(3),1;if(e>=48&&e<=57)return t.append(e-48+4),1;if(e>=65&&e<=90)return t.append(e-65+14),1;if(e<32)return t.append(0),t.append(e),2;if(e<=47)return t.append(1),t.append(e-33),2;if(e<=64)return t.append(1),t.append(e-58+15),2;if(e<=95)return t.append(1),t.append(e-91+22),2;if(e<=127)return t.append(2),t.append(e-96),2;t.append("1");var n=2;return n+=this.encodeChar(e-128,t),n},r.prototype.encodeToCodewords=function(e){var t=1600*e.charCodeAt(0)+40*e.charCodeAt(1)+e.charCodeAt(2)+1,n=t/256,i=t%256,a=new q;return a.append(n),a.append(i),a.toString()},r}(),sf=function(){function r(){}return r.prototype.getEncodingMode=function(){return Se},r.prototype.encode=function(e){for(var t=new q;e.hasMoreCharacters();){var n=e.getCurrentChar();this.encodeChar(n,t),e.pos++;var i=t.length();if(i>=4){e.writeCodewords(this.encodeToCodewords(t.toString()));var a=t.toString().substring(4);t.setLengthToZero(),t.append(a);var o=et.lookAheadTest(e.getMessage(),e.pos,this.getEncodingMode());if(o!==this.getEncodingMode()){e.signalEncoderChange(re);break}}}t.append(X.getCharAt(31)),this.handleEOD(e,t)},r.prototype.handleEOD=function(e,t){try{var n=t.length();if(n===0)return;if(n===1){e.updateSymbolInfo();var i=e.getSymbolInfo().getDataCapacity()-e.getCodewordCount(),a=e.getRemainingCharacters();if(a>i&&(e.updateSymbolInfo(e.getCodewordCount()+1),i=e.getSymbolInfo().getDataCapacity()-e.getCodewordCount()),a<=i&&i<=2)return}if(n>4)throw new Error("Count must not exceed 4");var o=n-1,s=this.encodeToCodewords(t.toString()),l=!e.hasMoreCharacters(),u=l&&o<=2;if(o<=2){e.updateSymbolInfo(e.getCodewordCount()+o);var i=e.getSymbolInfo().getDataCapacity()-e.getCodewordCount();i>=3&&(u=!1,e.updateSymbolInfo(e.getCodewordCount()+s.length))}u?(e.resetSymbolInfo(),e.pos-=o):e.writeCodewords(s)}finally{e.signalEncoderChange(re)}},r.prototype.encodeChar=function(e,t){e>=32&&e<=63?t.append(e):e>=64&&e<=94?t.append(X.getCharAt(e-64)):et.illegalCharacter(X.getCharAt(e))},r.prototype.encodeToCodewords=function(e){var t=e.length;if(t===0)throw new Error("StringBuilder must not be empty");var n=e.charAt(0).charCodeAt(0),i=t>=2?e.charAt(1).charCodeAt(0):0,a=t>=3?e.charAt(2).charCodeAt(0):0,o=t>=4?e.charAt(3).charCodeAt(0):0,s=(n<<18)+(i<<12)+(a<<6)+o,l=s>>16&255,u=s>>8&255,c=s&255,f=new q;return f.append(l),t>=2&&f.append(u),t>=3&&f.append(c),f.toString()},r}(),lf=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),uf=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},J=function(){function r(e,t,n,i,a,o,s,l){s===void 0&&(s=0),l===void 0&&(l=0),this.rectangular=e,this.dataCapacity=t,this.errorCodewords=n,this.matrixWidth=i,this.matrixHeight=a,this.dataRegions=o,this.rsBlockData=s,this.rsBlockError=l}return r.lookup=function(e,t,n,i,a){var o,s;t===void 0&&(t=0),n===void 0&&(n=null),i===void 0&&(i=null),a===void 0&&(a=!0);try{for(var l=uf(df),u=l.next();!u.done;u=l.next()){var c=u.value;if(!(t===1&&c.rectangular)&&!(t===2&&!c.rectangular)&&!(n!=null&&(c.getSymbolWidth()<n.getWidth()||c.getSymbolHeight()<n.getHeight()))&&!(i!=null&&(c.getSymbolWidth()>i.getWidth()||c.getSymbolHeight()>i.getHeight()))&&e<=c.dataCapacity)return c}}catch(f){o={error:f}}finally{try{u&&!u.done&&(s=l.return)&&s.call(l)}finally{if(o)throw o.error}}if(a)throw new Error("Can't find a symbol arrangement that matches the message. Data codewords: "+e);return null},r.prototype.getHorizontalDataRegions=function(){switch(this.dataRegions){case 1:return 1;case 2:case 4:return 2;case 16:return 4;case 36:return 6;default:throw new Error("Cannot handle this number of data regions")}},r.prototype.getVerticalDataRegions=function(){switch(this.dataRegions){case 1:case 2:return 1;case 4:return 2;case 16:return 4;case 36:return 6;default:throw new Error("Cannot handle this number of data regions")}},r.prototype.getSymbolDataWidth=function(){return this.getHorizontalDataRegions()*this.matrixWidth},r.prototype.getSymbolDataHeight=function(){return this.getVerticalDataRegions()*this.matrixHeight},r.prototype.getSymbolWidth=function(){return this.getSymbolDataWidth()+this.getHorizontalDataRegions()*2},r.prototype.getSymbolHeight=function(){return this.getSymbolDataHeight()+this.getVerticalDataRegions()*2},r.prototype.getCodewordCount=function(){return this.dataCapacity+this.errorCodewords},r.prototype.getInterleavedBlockCount=function(){return this.rsBlockData?this.dataCapacity/this.rsBlockData:1},r.prototype.getDataCapacity=function(){return this.dataCapacity},r.prototype.getErrorCodewords=function(){return this.errorCodewords},r.prototype.getDataLengthForInterleavedBlock=function(e){return this.rsBlockData},r.prototype.getErrorLengthForInterleavedBlock=function(e){return this.rsBlockError},r}(),cf=function(r){lf(e,r);function e(){return r.call(this,!1,1558,620,22,22,36,-1,62)||this}return e.prototype.getInterleavedBlockCount=function(){return 10},e.prototype.getDataLengthForInterleavedBlock=function(t){return t<=8?156:155},e}(J),df=[new J(!1,3,5,8,8,1),new J(!1,5,7,10,10,1),new J(!0,5,7,16,6,1),new J(!1,8,10,12,12,1),new J(!0,10,11,14,6,2),new J(!1,12,12,14,14,1),new J(!0,16,14,24,10,1),new J(!1,18,14,16,16,1),new J(!1,22,18,18,18,1),new J(!0,22,18,16,10,2),new J(!1,30,20,20,20,1),new J(!0,32,24,16,14,2),new J(!1,36,24,22,22,1),new J(!1,44,28,24,24,1),new J(!0,49,28,22,14,2),new J(!1,62,36,14,14,4),new J(!1,86,42,16,16,4),new J(!1,114,48,18,18,4),new J(!1,144,56,20,20,4),new J(!1,174,68,22,22,4),new J(!1,204,84,24,24,4,102,42),new J(!1,280,112,14,14,16,140,56),new J(!1,368,144,16,16,16,92,36),new J(!1,456,192,18,18,16,114,48),new J(!1,576,224,20,20,16,144,56),new J(!1,696,272,22,22,16,174,68),new J(!1,816,336,24,24,16,136,56),new J(!1,1050,408,18,18,36,175,68),new J(!1,1304,496,20,20,36,163,62),new cf],ff=function(){function r(e){this.msg=e,this.pos=0,this.skipAtEnd=0;for(var t=e.split("").map(function(s){return s.charCodeAt(0)}),n=new q,i=0,a=t.length;i<a;i++){var o=String.fromCharCode(t[i]&255);if(o==="?"&&e.charAt(i)!=="?")throw new Error("Message contains characters outside ISO-8859-1 encoding.");n.append(o)}this.msg=n.toString(),this.shape=0,this.codewords=new q,this.newEncoding=-1}return r.prototype.setSymbolShape=function(e){this.shape=e},r.prototype.setSizeConstraints=function(e,t){this.minSize=e,this.maxSize=t},r.prototype.getMessage=function(){return this.msg},r.prototype.setSkipAtEnd=function(e){this.skipAtEnd=e},r.prototype.getCurrentChar=function(){return this.msg.charCodeAt(this.pos)},r.prototype.getCurrent=function(){return this.msg.charCodeAt(this.pos)},r.prototype.getCodewords=function(){return this.codewords},r.prototype.writeCodewords=function(e){this.codewords.append(e)},r.prototype.writeCodeword=function(e){this.codewords.append(e)},r.prototype.getCodewordCount=function(){return this.codewords.length()},r.prototype.getNewEncoding=function(){return this.newEncoding},r.prototype.signalEncoderChange=function(e){this.newEncoding=e},r.prototype.resetEncoderSignal=function(){this.newEncoding=-1},r.prototype.hasMoreCharacters=function(){return this.pos<this.getTotalMessageCharCount()},r.prototype.getTotalMessageCharCount=function(){return this.msg.length-this.skipAtEnd},r.prototype.getRemainingCharacters=function(){return this.getTotalMessageCharCount()-this.pos},r.prototype.getSymbolInfo=function(){return this.symbolInfo},r.prototype.updateSymbolInfo=function(e){e===void 0&&(e=this.getCodewordCount()),(this.symbolInfo==null||e>this.symbolInfo.getDataCapacity())&&(this.symbolInfo=J.lookup(e,this.shape,this.minSize,this.maxSize,!0))},r.prototype.resetSymbolInfo=function(){this.symbolInfo=null},r}(),hf=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),pf=function(r){hf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.getEncodingMode=function(){return xe},e.prototype.encode=function(t){for(var n=new q;t.hasMoreCharacters();){var i=t.getCurrentChar();t.pos++,this.encodeChar(i,n);var a=n.length();if(a%3===0){this.writeNextTriplet(t,n);var o=et.lookAheadTest(t.getMessage(),t.pos,this.getEncodingMode());if(o!==this.getEncodingMode()){t.signalEncoderChange(re);break}}}this.handleEOD(t,n)},e.prototype.encodeChar=function(t,n){switch(t){case 13:n.append(0);break;case 42:n.append(1);break;case 62:n.append(2);break;case 32:n.append(3);break;default:t>=48&&t<=57?n.append(t-48+4):t>=65&&t<=90?n.append(t-65+14):et.illegalCharacter(X.getCharAt(t));break}return 1},e.prototype.handleEOD=function(t,n){t.updateSymbolInfo();var i=t.getSymbolInfo().getDataCapacity()-t.getCodewordCount(),a=n.length();t.pos-=a,(t.getRemainingCharacters()>1||i>1||t.getRemainingCharacters()!==i)&&t.writeCodeword(nf),t.getNewEncoding()<0&&t.signalEncoderChange(re)},e}(fi),vf=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),gf=function(r){vf(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.getEncodingMode=function(){return ze},e.prototype.encodeChar=function(t,n){if(t===32)return n.append(3),1;if(t>=48&&t<=57)return n.append(t-48+4),1;if(t>=97&&t<=122)return n.append(t-97+14),1;if(t<32)return n.append(0),n.append(t),2;if(t<=47)return n.append(1),n.append(t-33),2;if(t<=64)return n.append(1),n.append(t-58+15),2;if(t>=91&&t<=95)return n.append(1),n.append(t-91+22),2;if(t===96)return n.append(2),n.append(0),2;if(t<=90)return n.append(2),n.append(t-65+1),2;if(t<=127)return n.append(2),n.append(t-123+27),2;n.append("1");var i=2;return i+=this.encodeChar(t-128,n),i},e}(fi),et=function(){function r(){}return r.randomize253State=function(e){var t=149*e%253+1,n=po+t;return n<=254?n:n-254},r.encodeHighLevel=function(e,t,n,i,a){t===void 0&&(t=0),n===void 0&&(n=null),i===void 0&&(i=null),a===void 0&&(a=!1);var o=new fi,s=[new af,o,new gf,new pf,new sf,new of],l=new ff(e);l.setSymbolShape(t),l.setSizeConstraints(n,i),e.startsWith(go)&&e.endsWith(yo)?(l.writeCodeword(Qd),l.setSkipAtEnd(2),l.pos+=go.length):e.startsWith(xo)&&e.endsWith(yo)&&(l.writeCodeword(Jd),l.setSkipAtEnd(2),l.pos+=xo.length);var u=re;for(a&&(o.encodeMaximal(l),u=l.getNewEncoding(),l.resetEncoderSignal());l.hasMoreCharacters();)s[u].encode(l),l.getNewEncoding()>=0&&(u=l.getNewEncoding(),l.resetEncoderSignal());var c=l.getCodewordCount();l.updateSymbolInfo();var f=l.getSymbolInfo().getDataCapacity();c<f&&u!==re&&u!==Fe&&u!==Se&&l.writeCodeword("þ");var h=l.getCodewords();for(h.length()<f&&h.append(po);h.length()<f;)h.append(this.randomize253State(h.length()+1));return l.getCodewords().toString()},r.lookAheadTest=function(e,t,n){var i=this.lookAheadTestIntern(e,t,n);if(n===xe&&i===xe){for(var a=Math.min(t+3,e.length),o=t;o<a;o++)if(!this.isNativeX12(e.charCodeAt(o)))return re}else if(n===Se&&i===Se){for(var a=Math.min(t+4,e.length),o=t;o<a;o++)if(!this.isNativeEDIFACT(e.charCodeAt(o)))return re}return i},r.lookAheadTestIntern=function(e,t,n){if(t>=e.length)return n;var i;n===re?i=[0,1,1,1,1,1.25]:(i=[1,2,2,2,2,2.25],i[n]=0);for(var a=0,o=new Uint8Array(6),s=[];;){if(t+a===e.length){fe.fill(o,0),fe.fill(s,0);var l=this.findMinimums(i,s,$.MAX_VALUE,o),u=this.getMinimumCount(o);if(s[re]===l)return re;if(u===1){if(o[Fe]>0)return Fe;if(o[Se]>0)return Se;if(o[ze]>0)return ze;if(o[xe]>0)return xe}return Ne}var c=e.charCodeAt(t+a);if(a++,this.isDigit(c)?i[re]+=.5:this.isExtendedASCII(c)?(i[re]=Math.ceil(i[re]),i[re]+=2):(i[re]=Math.ceil(i[re]),i[re]++),this.isNativeC40(c)?i[Ne]+=2/3:this.isExtendedASCII(c)?i[Ne]+=8/3:i[Ne]+=4/3,this.isNativeText(c)?i[ze]+=2/3:this.isExtendedASCII(c)?i[ze]+=8/3:i[ze]+=4/3,this.isNativeX12(c)?i[xe]+=2/3:this.isExtendedASCII(c)?i[xe]+=13/3:i[xe]+=10/3,this.isNativeEDIFACT(c)?i[Se]+=3/4:this.isExtendedASCII(c)?i[Se]+=17/4:i[Se]+=13/4,this.isSpecialB256(c)?i[Fe]+=4:i[Fe]++,a>=4){if(fe.fill(o,0),fe.fill(s,0),this.findMinimums(i,s,$.MAX_VALUE,o),s[re]<this.min(s[Fe],s[Ne],s[ze],s[xe],s[Se]))return re;if(s[Fe]<s[re]||s[Fe]+1<this.min(s[Ne],s[ze],s[xe],s[Se]))return Fe;if(s[Se]+1<this.min(s[Fe],s[Ne],s[ze],s[xe],s[re]))return Se;if(s[ze]+1<this.min(s[Fe],s[Ne],s[Se],s[xe],s[re]))return ze;if(s[xe]+1<this.min(s[Fe],s[Ne],s[Se],s[ze],s[re]))return xe;if(s[Ne]+1<this.min(s[re],s[Fe],s[Se],s[ze])){if(s[Ne]<s[xe])return Ne;if(s[Ne]===s[xe]){for(var f=t+a+1;f<e.length;){var h=e.charCodeAt(f);if(this.isX12TermSep(h))return xe;if(!this.isNativeX12(h))break;f++}return Ne}}}}},r.min=function(e,t,n,i,a){var o=Math.min(e,Math.min(t,Math.min(n,i)));return a===void 0?o:Math.min(o,a)},r.findMinimums=function(e,t,n,i){for(var a=0;a<6;a++){var o=t[a]=Math.ceil(e[a]);n>o&&(n=o,fe.fill(i,0)),n===o&&(i[a]=i[a]+1)}return n},r.getMinimumCount=function(e){for(var t=0,n=0;n<6;n++)t+=e[n];return t||0},r.isDigit=function(e){return e>=48&&e<=57},r.isExtendedASCII=function(e){return e>=128&&e<=255},r.isNativeC40=function(e){return e===32||e>=48&&e<=57||e>=65&&e<=90},r.isNativeText=function(e){return e===32||e>=48&&e<=57||e>=97&&e<=122},r.isNativeX12=function(e){return this.isX12TermSep(e)||e===32||e>=48&&e<=57||e>=65&&e<=90},r.isX12TermSep=function(e){return e===13||e===42||e===62},r.isNativeEDIFACT=function(e){return e>=32&&e<=94},r.isSpecialB256=function(e){return!1},r.determineConsecutiveDigitCount=function(e,t){t===void 0&&(t=0);for(var n=e.length,i=t;i<n&&this.isDigit(e.charCodeAt(i));)i++;return i-t},r.illegalCharacter=function(e){var t=$.toHexString(e.charCodeAt(0));throw t="0000".substring(0,4-t.length)+t,new Error("Illegal character: "+e+" (0x"+t+")")},r}(),hi=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Co=function(){function r(e){this.charset=e,this.name=e.name}return r.prototype.canEncode=function(e){try{return Xe.encode(e,this.charset)!=null}catch{return!1}},r}(),xf=function(){function r(e,t,n){var i,a,o,s,l,u;this.ENCODERS=["IBM437","ISO-8859-2","ISO-8859-3","ISO-8859-4","ISO-8859-5","ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-9","ISO-8859-10","ISO-8859-11","ISO-8859-13","ISO-8859-14","ISO-8859-15","ISO-8859-16","windows-1250","windows-1251","windows-1252","windows-1256","Shift_JIS"].map(function(L){return new Co(Xd.forName(L))}),this.encoders=[];var c=[];c.push(new Co(Wd.ISO_8859_1));for(var f=t!=null&&t.name.startsWith("UTF"),h=0;h<e.length;h++){var p=!1;try{for(var g=(i=void 0,hi(c)),x=g.next();!x.done;x=g.next()){var m=x.value,w=e.charAt(h),A=w.charCodeAt(0);if(A===n||m.canEncode(w)){p=!0;break}}}catch(L){i={error:L}}finally{try{x&&!x.done&&(a=g.return)&&a.call(g)}finally{if(i)throw i.error}}if(!p)try{for(var E=(o=void 0,hi(this.ENCODERS)),S=E.next();!S.done;S=E.next()){var m=S.value;if(m.canEncode(e.charAt(h))){c.push(m),p=!0;break}}}catch(L){o={error:L}}finally{try{S&&!S.done&&(s=E.return)&&s.call(E)}finally{if(o)throw o.error}}p||(f=!0)}if(c.length===1&&!f)this.encoders=[c[0]];else{this.encoders=[];var O=0;try{for(var N=hi(c),T=N.next();!T.done;T=N.next()){var m=T.value;this.encoders[O++]=m}}catch(L){l={error:L}}finally{try{T&&!T.done&&(u=N.return)&&u.call(N)}finally{if(l)throw l.error}}}var V=-1;if(t!=null){for(var h=0;h<this.encoders.length;h++)if(this.encoders[h]!=null&&t.name===this.encoders[h].name){V=h;break}}this.priorityEncoderIndex=V}return r.prototype.length=function(){return this.encoders.length},r.prototype.getCharsetName=function(e){if(!(e<this.length()))throw new Error("index must be less than length");return this.encoders[e].name},r.prototype.getCharset=function(e){if(!(e<this.length()))throw new Error("index must be less than length");return this.encoders[e].charset},r.prototype.getECIValue=function(e){return this.encoders[e].charset.getValueIdentifier()},r.prototype.getPriorityEncoderIndex=function(){return this.priorityEncoderIndex},r.prototype.canEncode=function(e,t){if(!(t<this.length()))throw new Error("index must be less than length");return!0},r.prototype.encode=function(e,t){if(!(t<this.length()))throw new Error("index must be less than length");return Xe.encode(X.getCharAt(e),this.encoders[t].name)},r}(),yf=3,Cf=function(){function r(e,t,n){this.fnc1=n;var i=new xf(e,t,n);if(i.length()===1)for(var a=0;a<this.bytes.length;a++){var o=e.charAt(a).charCodeAt(0);this.bytes[a]=o===n?1e3:o}else this.bytes=this.encodeMinimally(e,i,n)}return r.prototype.getFNC1Character=function(){return this.fnc1},r.prototype.length=function(){return this.bytes.length},r.prototype.haveNCharacters=function(e,t){if(e+t-1>=this.bytes.length)return!1;for(var n=0;n<t;n++)if(this.isECI(e+n))return!1;return!0},r.prototype.charAt=function(e){if(e<0||e>=this.length())throw new Error(""+e);if(this.isECI(e))throw new Error("value at "+e+" is not a character but an ECI");return this.isFNC1(e)?this.fnc1:this.bytes[e]},r.prototype.subSequence=function(e,t){if(e<0||e>t||t>this.length())throw new Error(""+e);for(var n=new q,i=e;i<t;i++){if(this.isECI(i))throw new Error("value at "+i+" is not a character but an ECI");n.append(this.charAt(i))}return n.toString()},r.prototype.isECI=function(e){if(e<0||e>=this.length())throw new Error(""+e);return this.bytes[e]>255&&this.bytes[e]<=999},r.prototype.isFNC1=function(e){if(e<0||e>=this.length())throw new Error(""+e);return this.bytes[e]===1e3},r.prototype.getECIValue=function(e){if(e<0||e>=this.length())throw new Error(""+e);if(!this.isECI(e))throw new Error("value at "+e+" is not an ECI but a character");return this.bytes[e]-256},r.prototype.addEdge=function(e,t,n){(e[t][n.encoderIndex]==null||e[t][n.encoderIndex].cachedTotalSize>n.cachedTotalSize)&&(e[t][n.encoderIndex]=n)},r.prototype.addEdges=function(e,t,n,i,a,o){var s=e.charAt(i).charCodeAt(0),l=0,u=t.length();t.getPriorityEncoderIndex()>=0&&(s===o||t.canEncode(s,t.getPriorityEncoderIndex()))&&(l=t.getPriorityEncoderIndex(),u=l+1);for(var c=l;c<u;c++)(s===o||t.canEncode(s,c))&&this.addEdge(n,i+1,new mo(s,t,c,a,o))},r.prototype.encodeMinimally=function(e,t,n){var i=e.length,a=new mo[i+1][t.length()];this.addEdges(e,t,a,0,null,n);for(var o=1;o<=i;o++){for(var s=0;s<t.length();s++)a[o][s]!=null&&o<i&&this.addEdges(e,t,a,o,a[o][s],n);for(var s=0;s<t.length();s++)a[o-1][s]=null}for(var l=-1,u=$.MAX_VALUE,s=0;s<t.length();s++)if(a[i][s]!=null){var c=a[i][s];c.cachedTotalSize<u&&(u=c.cachedTotalSize,l=s)}if(l<0)throw new Error('Failed to encode "'+e+'"');for(var f=[],h=a[i][l];h!=null;){if(h.isFNC1())f.unshift(1e3);else for(var p=t.encode(h.c,h.encoderIndex),o=p.length-1;o>=0;o--)f.unshift(p[o]&255);var g=h.previous===null?0:h.previous.encoderIndex;g!==h.encoderIndex&&f.unshift(256+t.getECIValue(h.encoderIndex)),h=h.previous}for(var x=[],o=0;o<x.length;o++)x[o]=f[o];return x},r}(),mo=function(){function r(e,t,n,i,a){this.c=e,this.encoderSet=t,this.encoderIndex=n,this.previous=i,this.fnc1=a,this.c=e===a?1e3:e;var o=this.isFNC1()?1:t.encode(e,n).length,s=i===null?0:i.encoderIndex;s!==n&&(o+=yf),i!=null&&(o+=i.cachedTotalSize),this.cachedTotalSize=o}return r.prototype.isFNC1=function(){return this.c===1e3},r}(),mf=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),wf=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(s){o={error:s}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a},wo;(function(r){r[r.ASCII=0]="ASCII",r[r.C40=1]="C40",r[r.TEXT=2]="TEXT",r[r.X12=3]="X12",r[r.EDF=4]="EDF",r[r.B256=5]="B256"})(wo||(wo={})),function(r){mf(e,r);function e(t,n,i,a,o){var s=r.call(this,t,n,i)||this;return s.shape=a,s.macroId=o,s}return e.prototype.getMacroId=function(){return this.macroId},e.prototype.getShapeHint=function(){return this.shape},e}(Cf);var _f=function(){function r(){}return r.prototype.isCompact=function(){return this.compact},r.prototype.setCompact=function(e){this.compact=e},r.prototype.getSize=function(){return this.size},r.prototype.setSize=function(e){this.size=e},r.prototype.getLayers=function(){return this.layers},r.prototype.setLayers=function(e){this.layers=e},r.prototype.getCodeWords=function(){return this.codeWords},r.prototype.setCodeWords=function(e){this.codeWords=e},r.prototype.getMatrix=function(){return this.matrix},r.prototype.setMatrix=function(e){this.matrix=e},r}(),_o=function(){function r(){}return r.singletonList=function(e){return[e]},r.min=function(e,t){return e.sort(t)[0]},r}(),Af=function(){function r(e){this.previous=e}return r.prototype.getPrevious=function(){return this.previous},r}(),Sf=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),pi=function(r){Sf(e,r);function e(t,n,i){var a=r.call(this,t)||this;return a.value=n,a.bitCount=i,a}return e.prototype.appendTo=function(t,n){t.appendBits(this.value,this.bitCount)},e.prototype.add=function(t,n){return new e(this,t,n)},e.prototype.addBinaryShift=function(t,n){return console.warn("addBinaryShift on SimpleToken, this simply returns a copy of this token"),new e(this,t,n)},e.prototype.toString=function(){var t=this.value&(1<<this.bitCount)-1;return t|=1<<this.bitCount,"<"+$.toBinaryString(t|1<<this.bitCount).substring(1)+">"},e}(Af),Ef=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a])},r(e,t)};return function(e,t){r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),If=function(r){Ef(e,r);function e(t,n,i){var a=r.call(this,t,0,0)||this;return a.binaryShiftStart=n,a.binaryShiftByteCount=i,a}return e.prototype.appendTo=function(t,n){for(var i=0;i<this.binaryShiftByteCount;i++)(i===0||i===31&&this.binaryShiftByteCount<=62)&&(t.appendBits(31,5),this.binaryShiftByteCount>62?t.appendBits(this.binaryShiftByteCount-31,16):i===0?t.appendBits(Math.min(this.binaryShiftByteCount,31),5):t.appendBits(this.binaryShiftByteCount-31,5)),t.appendBits(n[this.binaryShiftStart+i],8)},e.prototype.addBinaryShift=function(t,n){return new e(this,t,n)},e.prototype.toString=function(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"},e}(pi);function Of(r,e,t){return new If(r,e,t)}function cr(r,e,t){return new pi(r,e,t)}var bf=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],ft=0,Yr=1,je=2,Ao=3,rt=4,Nf=new pi(null,0,0),vi=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])],Tf=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function Mf(r){var e,t;try{for(var n=Tf(r),i=n.next();!i.done;i=n.next()){var a=i.value;fe.fill(a,-1)}}catch(o){e={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r[ft][rt]=0,r[Yr][rt]=0,r[Yr][ft]=28,r[Ao][rt]=0,r[je][rt]=0,r[je][ft]=15,r}var So=Mf(fe.createInt32Array(6,6)),Df=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Ff=function(){function r(e,t,n,i){this.token=e,this.mode=t,this.binaryShiftByteCount=n,this.bitCount=i}return r.prototype.getMode=function(){return this.mode},r.prototype.getToken=function(){return this.token},r.prototype.getBinaryShiftByteCount=function(){return this.binaryShiftByteCount},r.prototype.getBitCount=function(){return this.bitCount},r.prototype.latchAndAppend=function(e,t){var n=this.bitCount,i=this.token;if(e!==this.mode){var a=vi[this.mode][e];i=cr(i,a&65535,a>>16),n+=a>>16}var o=e===je?4:5;return i=cr(i,t,o),new r(i,e,0,n+o)},r.prototype.shiftAndAppend=function(e,t){var n=this.token,i=this.mode===je?4:5;return n=cr(n,So[this.mode][e],i),n=cr(n,t,5),new r(n,this.mode,0,this.bitCount+i+5)},r.prototype.addBinaryShiftChar=function(e){var t=this.token,n=this.mode,i=this.bitCount;if(this.mode===rt||this.mode===je){var a=vi[n][ft];t=cr(t,a&65535,a>>16),i+=a>>16,n=ft}var o=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,s=new r(t,n,this.binaryShiftByteCount+1,i+o);return s.binaryShiftByteCount===2078&&(s=s.endBinaryShift(e+1)),s},r.prototype.endBinaryShift=function(e){if(this.binaryShiftByteCount===0)return this;var t=this.token;return t=Of(t,e-this.binaryShiftByteCount,this.binaryShiftByteCount),new r(t,this.mode,0,this.bitCount)},r.prototype.isBetterThanOrEqualTo=function(e){var t=this.bitCount+(vi[this.mode][e.mode]>>16);return this.binaryShiftByteCount<e.binaryShiftByteCount?t+=r.calculateBinaryShiftCost(e)-r.calculateBinaryShiftCost(this):this.binaryShiftByteCount>e.binaryShiftByteCount&&e.binaryShiftByteCount>0&&(t+=10),t<=e.bitCount},r.prototype.toBitArray=function(e){for(var t,n,i=[],a=this.endBinaryShift(e.length).token;a!==null;a=a.getPrevious())i.unshift(a);var o=new _e;try{for(var s=Df(i),l=s.next();!l.done;l=s.next()){var u=l.value;u.appendTo(o,e)}}catch(c){t={error:c}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},r.prototype.toString=function(){return X.format("%s bits=%d bytes=%d",bf[this.mode],this.bitCount,this.binaryShiftByteCount)},r.calculateBinaryShiftCost=function(e){return e.binaryShiftByteCount>62?21:e.binaryShiftByteCount>31?20:e.binaryShiftByteCount>0?10:0},r.INITIAL_STATE=new r(Nf,ft,0,0),r}();function Vf(r){var e=X.getCharCode(" "),t=X.getCharCode("."),n=X.getCharCode(",");r[ft][e]=1;for(var i=X.getCharCode("Z"),a=X.getCharCode("A"),o=a;o<=i;o++)r[ft][o]=o-a+2;r[Yr][e]=1;for(var s=X.getCharCode("z"),l=X.getCharCode("a"),o=l;o<=s;o++)r[Yr][o]=o-l+2;r[je][e]=1;for(var u=X.getCharCode("9"),c=X.getCharCode("0"),o=c;o<=u;o++)r[je][o]=o-c+2;r[je][n]=12,r[je][t]=13;for(var f=["\0"," ","","","","","","","\x07","\b"," ",`
|
|
274
274
|
`,"\v","\f","\r","\x1B","","","","","@","\\","^","_","`","|","~",""],h=0;h<f.length;h++)r[Ao][X.getCharCode(f[h])]=h;for(var p=["\0","\r","\0","\0","\0","\0","!","'","#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}"],h=0;h<p.length;h++)X.getCharCode(p[h])>0&&(r[rt][X.getCharCode(p[h])]=h);return r}var gi=Vf(fe.createInt32Array(5,256)),Zr=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Pf=function(){function r(e){this.text=e}return r.prototype.encode=function(){for(var e=X.getCharCode(" "),t=X.getCharCode(`
|
|
275
|
-
`),n=_o.singletonList(Ff.INITIAL_STATE),i=0;i<this.text.length;i++){var a=void 0,o=i+1<this.text.length?this.text[i+1]:0;switch(this.text[i]){case X.getCharCode("\r"):a=o===t?2:0;break;case X.getCharCode("."):a=o===e?3:0;break;case X.getCharCode(","):a=o===e?4:0;break;case X.getCharCode(":"):a=o===e?5:0;break;default:a=0}a>0?(n=r.updateStateListForPair(n,i,a),i++):n=this.updateStateListForChar(n,i)}var s=_o.min(n,function(l,u){return l.getBitCount()-u.getBitCount()});return s.toBitArray(this.text)},r.prototype.updateStateListForChar=function(e,t){var n,i,a=[];try{for(var o=Zr(e),s=o.next();!s.done;s=o.next()){var l=s.value;this.updateStateForChar(l,t,a)}}catch(u){n={error:u}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return r.simplifyStates(a)},r.prototype.updateStateForChar=function(e,t,n){for(var i=this.text[t]&255,a=gi[e.getMode()][i]>0,o=null,s=0;s<=rt;s++){var l=gi[s][i];if(l>0){if(o==null&&(o=e.endBinaryShift(t)),!a||s===e.getMode()||s===je){var u=o.latchAndAppend(s,l);n.push(u)}if(!a&&So[e.getMode()][s]>=0){var c=o.shiftAndAppend(s,l);n.push(c)}}}if(e.getBinaryShiftByteCount()>0||gi[e.getMode()][i]===0){var f=e.addBinaryShiftChar(t);n.push(f)}},r.updateStateListForPair=function(e,t,n){var i,a,o=[];try{for(var s=Zr(e),l=s.next();!l.done;l=s.next()){var u=l.value;this.updateStateForPair(u,t,n,o)}}catch(c){i={error:c}}finally{try{l&&!l.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}return this.simplifyStates(o)},r.updateStateForPair=function(e,t,n,i){var a=e.endBinaryShift(t);if(i.push(a.latchAndAppend(rt,n)),e.getMode()!==rt&&i.push(a.shiftAndAppend(rt,n)),n===3||n===4){var o=a.latchAndAppend(je,16-n).latchAndAppend(je,1);i.push(o)}if(e.getBinaryShiftByteCount()>0){var s=e.addBinaryShiftChar(t).addBinaryShiftChar(t+1);i.push(s)}},r.simplifyStates=function(e){var t,n,i,a,o=[];try{for(var s=Zr(e),l=s.next();!l.done;l=s.next()){var u=l.value,c=!0,f=function(m){if(m.isBetterThanOrEqualTo(u))return c=!1,"break";u.isBetterThanOrEqualTo(m)&&(o=o.filter(function(w){return w!==m}))};try{for(var h=(i=void 0,Zr(o)),p=h.next();!p.done;p=h.next()){var g=p.value,x=f(g);if(x==="break")break}}catch(m){i={error:m}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}c&&o.push(u)}}catch(m){t={error:m}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},r}(),Bf=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};(function(){function r(){}return r.encodeBytes=function(e){return r.encode(e,r.DEFAULT_EC_PERCENT,r.DEFAULT_AZTEC_LAYERS)},r.encode=function(e,t,n){var i=new Pf(e).encode(),a=$.truncDivision(i.getSize()*t,100)+11,o=i.getSize()+a,s,l,u,c,f;if(n!==r.DEFAULT_AZTEC_LAYERS){if(s=n<0,l=Math.abs(n),l>(s?r.MAX_NB_BITS_COMPACT:r.MAX_NB_BITS))throw new k(X.format("Illegal value %s for layers",n));u=r.totalBitsInLayer(l,s),c=r.WORD_SIZE[l];var h=u-u%c;if(f=r.stuffBits(i,c),f.getSize()+a>h)throw new k("Data to large for user specified layer");if(s&&f.getSize()>c*64)throw new k("Data to large for user specified layer")}else{c=0,f=null;for(var p=0;;p++){if(p>r.MAX_NB_BITS)throw new k("Data too large for an Aztec code");if(s=p<=3,l=s?p+1:p,u=r.totalBitsInLayer(l,s),!(o>u)){(f==null||c!==r.WORD_SIZE[l])&&(c=r.WORD_SIZE[l],f=r.stuffBits(i,c));var h=u-u%c;if(!(s&&f.getSize()>c*64)&&f.getSize()+a<=h)break}}}var g=r.generateCheckWords(f,u,c),x=f.getSize()/c,m=r.generateModeMessage(s,l,x),w=(s?11:14)+l*4,A=new Int32Array(w),E;if(s){E=w;for(var p=0;p<A.length;p++)A[p]=p}else{E=w+1+2*$.truncDivision($.truncDivision(w,2)-1,15);for(var S=$.truncDivision(w,2),O=$.truncDivision(E,2),p=0;p<S;p++){var N=p+$.truncDivision(p,15);A[S-p-1]=O-N-1,A[S+p]=O+N+1}}for(var T=new tt(E),p=0,V=0;p<l;p++){for(var L=(l-p)*4+(s?9:12),z=0;z<L;z++)for(var K=z*2,G=0;G<2;G++)g.get(V+K+G)&&T.set(A[p*2+G],A[p*2+z]),g.get(V+L*2+K+G)&&T.set(A[p*2+z],A[w-1-p*2-G]),g.get(V+L*4+K+G)&&T.set(A[w-1-p*2-G],A[w-1-p*2-z]),g.get(V+L*6+K+G)&&T.set(A[w-1-p*2-z],A[p*2+G]);V+=L*8}if(r.drawModeMessage(T,s,E,m),s)r.drawBullsEye(T,$.truncDivision(E,2),5);else{r.drawBullsEye(T,$.truncDivision(E,2),7);for(var p=0,z=0;p<$.truncDivision(w,2)-1;p+=15,z+=16)for(var G=$.truncDivision(E,2)&1;G<E;G+=2)T.set($.truncDivision(E,2)-z,G),T.set($.truncDivision(E,2)+z,G),T.set(G,$.truncDivision(E,2)-z),T.set(G,$.truncDivision(E,2)+z)}var Y=new _f;return Y.setCompact(s),Y.setSize(E),Y.setLayers(l),Y.setCodeWords(x),Y.setMatrix(T),Y},r.drawBullsEye=function(e,t,n){for(var i=0;i<n;i+=2)for(var a=t-i;a<=t+i;a++)e.set(a,t-i),e.set(a,t+i),e.set(t-i,a),e.set(t+i,a);e.set(t-n,t-n),e.set(t-n+1,t-n),e.set(t-n,t-n+1),e.set(t+n,t-n),e.set(t+n,t-n+1),e.set(t+n,t+n-1)},r.generateModeMessage=function(e,t,n){var i=new _e;return e?(i.appendBits(t-1,2),i.appendBits(n-1,6),i=r.generateCheckWords(i,28,4)):(i.appendBits(t-1,5),i.appendBits(n-1,11),i=r.generateCheckWords(i,40,4)),i},r.drawModeMessage=function(e,t,n,i){var a=$.truncDivision(n,2);if(t)for(var o=0;o<7;o++){var s=a-3+o;i.get(o)&&e.set(s,a-5),i.get(o+7)&&e.set(a+5,s),i.get(20-o)&&e.set(s,a+5),i.get(27-o)&&e.set(a-5,s)}else for(var o=0;o<10;o++){var s=a-5+o+$.truncDivision(o,5);i.get(o)&&e.set(s,a-7),i.get(o+10)&&e.set(a+7,s),i.get(29-o)&&e.set(s,a+7),i.get(39-o)&&e.set(a-7,s)}},r.generateCheckWords=function(e,t,n){var i,a,o=e.getSize()/n,s=new uo(r.getGF(n)),l=$.truncDivision(t,n),u=r.bitsToWords(e,n,l);s.encode(u,l-o);var c=t%n,f=new _e;f.appendBits(0,c);try{for(var h=Bf(Array.from(u)),p=h.next();!p.done;p=h.next()){var g=p.value;f.appendBits(g,n)}}catch(x){i={error:x}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}return f},r.bitsToWords=function(e,t,n){var i=new Int32Array(n),a,o;for(a=0,o=e.getSize()/t;a<o;a++){for(var s=0,l=0;l<t;l++)s|=e.get(a*t+l)?1<<t-l-1:0;i[a]=s}return i},r.getGF=function(e){switch(e){case 4:return Re.AZTEC_PARAM;case 6:return Re.AZTEC_DATA_6;case 8:return Re.AZTEC_DATA_8;case 10:return Re.AZTEC_DATA_10;case 12:return Re.AZTEC_DATA_12;default:throw new k("Unsupported word size "+e)}},r.stuffBits=function(e,t){for(var n=new _e,i=e.getSize(),a=(1<<t)-2,o=0;o<i;o+=t){for(var s=0,l=0;l<t;l++)(o+l>=i||e.get(o+l))&&(s|=1<<t-1-l);(s&a)===a?(n.appendBits(s&a,t),o--):(s&a)===0?(n.appendBits(s|1,t),o--):n.appendBits(s,t)}return n},r.totalBitsInLayer=function(e,t){return((t?88:112)+16*e)*e},r.DEFAULT_EC_PERCENT=33,r.DEFAULT_AZTEC_LAYERS=0,r.MAX_NB_BITS=32,r.MAX_NB_BITS_COMPACT=4,r.WORD_SIZE=Int32Array.from([4,6,6,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12]),r})();const Lf=new Map([[ra.DecodeHintType.POSSIBLE_FORMATS,[P.AZTEC,P.CODABAR,P.CODE_39,P.CODE_93,P.CODE_128,P.DATA_MATRIX,P.EAN_8,P.EAN_13,P.ITF,P.MAXICODE,P.PDF_417,P.QR_CODE,P.RSS_14,P.RSS_EXPANDED,P.UPC_A,P.UPC_E,P.UPC_EAN_EXTENSION]]]),Kr=y.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,...o}=r;return d.jsxs(v.Overlay.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[!!e&&d.jsx(v.Overlay.Trigger,{asChild:!0,children:e}),d.jsxs(v.Overlay.Content,{children:[d.jsx(v.Overlay.Title,{className:"sr-only",children:"Scanner"}),d.jsx(v.Overlay.Description,{className:"sr-only",children:"Scan a barcode or a qr code."}),d.jsx(Eo,{...o})]})]})});Kr.displayName="Scanner";const Eo=y.memo(r=>{const{paused:e,timeBetweenDecodingAttempts:t,onDecodeResult:n,onDecodeError:i,onError:a}=r,{ref:o}=ra.useZxing({paused:e,timeBetweenDecodingAttempts:t,onDecodeResult:n,onDecodeError:i,onError:a,hints:Lf});return d.jsxs("div",{className:"bg-(--color-background) flex size-full flex-col justify-center overflow-hidden",children:[d.jsx("div",{className:"flex w-full justify-end p-4",children:d.jsx(v.Overlay.Close,{asChild:!0,children:d.jsx(v.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",children:d.jsx(v.LuIcon,{icon:at})})})}),d.jsx("div",{className:"max-h-full w-full grow overflow-hidden p-4",children:d.jsx("video",{className:"size-full",ref:o})})]})});Eo.displayName="ScannerInternal";const Io=y.memo(r=>{const{children:e}=r,[t,n]=y.useState(null),i=y.useCallback(()=>{n(null)},[]),a=y.useCallback(s=>{n(s(i))},[i]),o=y.useCallback(()=>{t&&(t.onClose&&t.onClose(),i())},[i,t]);return d.jsxs(ba.Provider,{value:a,children:[e,t&&d.jsx(Kr,{open:!0,onOpenChange:o,...t})]})});Io.displayName="FileViewerProvider";const xi=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),[u,c]=y.useState(!1),f=y.useCallback(m=>{const w=m.target.value;o(w)},[o]),h=y.useCallback(()=>{a()},[a]),p=y.useCallback(m=>{o(m.getText()),a(),c(!1)},[o,a]),g=y.useCallback(()=>{c(!0)},[]),x=y.useCallback(()=>{c(!1),a()},[a]);return d.jsxs(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:[d.jsx(v.TextArea,{className:"field-sizing-content w-full",accentColor:"base",variant:"surface",size:t,id:e.identifier,name:i,value:n??"",placeholder:"Enter a qr or barcode",onChange:f,onBlur:h,disabled:l}),d.jsxs(v.Button,{onClick:g,className:"w-max",type:"button",variant:"soft",size:t,accentColor:"base",disabled:l,children:[d.jsx(v.LuIcon,{icon:Ul}),"Scan"]}),d.jsx(Kr,{open:u,onDecodeResult:p,onOpenChange:x})]})});xi.displayName="ScanFieldInput";class $t extends Ve{constructor(t){super(t);M(this,"type","qr")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new $t({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){return new $t(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(xi,{field:this})}isSerializedValue(t){return typeof t=="string"}isValue(t){return typeof t=="string"}blankValue(){return""}areValuesEqual(t,n){return t===n}blankSerializedValue(){return""}areSerializedValuesEqual(t,n){return t===n}}const yi=500,Ci=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{const p=h.target.value;o(p)},[o]),c=y.useCallback(()=>{a()},[a]),f=y.useCallback(h=>{h.key==="Enter"&&h.preventDefault()},[]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(v.Input.Root,{accentColor:"base",variant:"surface",size:t,children:d.jsx(v.Input.Field,{id:e.identifier,className:"truncate",name:i,value:n??"",type:"text",placeholder:e.placeholder,onChange:u,onBlur:c,disabled:l,onKeyDown:f})})})});Ci.displayName="StringFieldInput";class Tt extends In{constructor(t){const{...n}=t,i=t.maxLength?Math.min(yi,t.maxLength):yi,a=t.minLength?Math.min(t.minLength,i):void 0;super({...n,maxLength:i,minLength:a});M(this,"type","string")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new Tt({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){const{maximum_length:n,minimum_length:i,...a}=t;return new Tt({...a,maxLength:n,minLength:i,placeholder:"Enter a short description"})}render(){return d.jsx(Ci,{field:this})}}const mi=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{const h=f.target.value;o(h)},[o]),c=y.useCallback(()=>{a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(v.TextArea,{id:e.identifier,value:n??"",name:i,onChange:u,onBlur:c,className:"field-sizing-content min-h-12",placeholder:e.placeholder,resize:"vertical",accentColor:"base",variant:"surface",size:t,disabled:l})})});mi.displayName="TextFieldInput";class Mt extends In{constructor(t){const n=t.maxLength?Math.min(rr,t.maxLength):rr,i=t.minLength?Math.min(t.minLength,n):void 0;super({...t,maxLength:n,minLength:i});M(this,"type","text")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new Mt({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){const{maximum_length:n,minimum_length:i,...a}=t;return new Mt({...a,maxLength:n,minLength:i,placeholder:"Enter a description"})}render(){return d.jsx(mi,{field:this})}}const wi=zf(),Oo=new Set(wi);function zf(r=!0){const e=new Set;for(let t=-12;t<=14;t++){const n=t>=0?"+":"-",i=Math.abs(t).toString().padStart(2,"0");e.add(`${n}${i}:00`)}if(r){const t=[-12.5,-9.5,-3.5,3.5,4.5,5.5,6.5,9.5,10.5,12.5];for(const n of t){const i=n>=0?"+":"-",a=Math.floor(Math.abs(n)).toString().padStart(2,"0");e.add(`${i}${a}:30`)}}return Array.from(e).sort((t,n)=>bo(t)-bo(n))}function bo(r){const e=r[0]==="+"?1:-1,t=Number(r.slice(1,3)),n=Number(r.slice(4,6));return e*(t*60+n)}const kf="+00:00",Uf=/^T([01]\d|2[0-3]):([0-5]\d):00([+-]\d{2}:\d{2})$/,Qr=r=>typeof r=="string"&&Oo.has(r),No=()=>{const r=-new Date().getTimezoneOffset(),e=r>=0?"+":"-",t=Math.abs(r),n=Math.floor(t/60),i=t%60,a=`${e}${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`;return Qr(a)?a:kf};function To(r){const e=/^([+-])(\d{2}):(\d{2})$/.exec(r);if(!e)throw new Error(`Invalid UTC offset: ${r}`);return(e[1]==="+"?1:-1)*(Number(e[2])*60+Number(e[3]))}const dr=r=>{const e=Uf.exec(r);if(!e)return null;const t=e[3];return Qr(t)?{hours:Number(e[1]),minutes:Number(e[2]),utcOffset:t}:null},ye=r=>typeof r=="string"&&dr(r)!==null,_i=(r,e,t=No())=>{if(!Number.isInteger(r)||r<0||r>23)throw new Error(`Invalid hour: ${r}`);if(!Number.isInteger(e)||e<0||e>59)throw new Error(`Invalid minute: ${e}`);if(!Qr(t))throw new Error("Unsupported UTC offset");const n=r.toString().padStart(2,"0"),i=e.toString().padStart(2,"0");return`T${n}:${i}:00${t}`},Jr=r=>`UTC${r}`,ht=r=>{const e=dr(r);if(!e)throw new Error(`Invalid time value: ${r}`);return(e.hours*60+e.minutes-To(e.utcOffset)+1440)%1440},en=(r,e=!0)=>{const t=dr(r);if(!t)throw new Error(`Invalid time value: ${r}`);const n=(t.hours%12||12).toString().padStart(2,"0"),i=t.minutes.toString().padStart(2,"0"),a=t.hours>=12?"PM":"AM",o=`${n}:${i} ${a}`;return e?`${o} ${Jr(t.utcOffset)}`:o},fr=r=>typeof r=="object"&&(ye(r.from)||ye(r.to)),Ai=(r,e)=>{const t=ht(r),n=e.from?ht(e.from):null,i=e.to?ht(e.to):null;return n===null&&i===null?!0:n===null?t<=i:i===null?t>=n:n<=i?t>=n&&t<=i:t>=n||t<=i},tn=y.memo(r=>{const{value:e,onChange:t,onBlur:n,disabled:i,size:a="md",id:o,name:s,compact:l=!1}=r,u=e?dr(e):null,c=u?`${u.hours.toString().padStart(2,"0")}:${u.minutes.toString().padStart(2,"0")}`:"",f=y.useCallback(g=>{const x=g.target.value;if(!x){t(null);return}const[m,w]=x.split(":").map(Number);t(_i(m,w,u==null?void 0:u.utcOffset))},[t,u==null?void 0:u.utcOffset]),h=y.useCallback(g=>{u&&(t(_i(u.hours,u.minutes,g)),n==null||n())},[n,t,u]),p=y.useCallback(g=>{g||n==null||n()},[n]);return d.jsxs("div",{className:"flex min-w-0 gap-2",children:[d.jsx(v.Input.Root,{className:"min-w-0 grow",accentColor:"base",variant:"surface",size:a,children:d.jsx(v.Input.Field,{id:o,name:s,className:$e.cx("[&::-webkit-calendar-picker-indicator]:invert-40 dark:[&::-webkit-calendar-picker-indicator]:invert-60",{"[&::-webkit-datetime-edit]:opacity-60":!e}),type:"time",step:60,value:c,onChange:f,onBlur:n,disabled:i})}),d.jsxs(v.Menu.Root,{align:"end",onOpenChange:p,children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsxs(v.Button,{type:"button",className:l?"!justify-between":"min-w-32 !justify-between",accentColor:"base",variant:"surface",size:a,disabled:i||!u,children:[d.jsx(v.Text,{className:"truncate",highContrast:!!u,children:u?Jr(u.utcOffset):"UTC offset"}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Menu.Content,{size:a,children:d.jsx(v.Menu.Scroll,{children:d.jsx(v.Menu.SelectGroup,{required:!0,value:u==null?void 0:u.utcOffset,onValueChange:h,children:wi.map(g=>d.jsxs(v.Menu.SelectItem,{value:g,children:[d.jsx(v.Menu.SelectedIndicator,{children:d.jsx(v.LuIcon,{icon:ke})}),Jr(g)]},g))})})})]})]})});tn.displayName="TimeFieldControl";const Si=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e});return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(tn,{id:e.identifier,name:i,size:t,value:n,onChange:o,onBlur:a,disabled:l})})});Si.displayName="TimeFieldInput";class Xt extends Ve{constructor(t){super(t);M(this,"type","time")}static deserialize(t){return new Xt(t)}getOptions(){return super.getOptions()}duplicate(t){return new Xt({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Si,{field:this})}isSerializedValue(t){return t===null||ye(t)}isValue(t){return t===null||ye(t)}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return t===n}}const Ei=y.memo(r=>{var m;const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useRef(null),c=y.useCallback(()=>{var w;(w=u.current)==null||w.click()},[]),f=y.useCallback(()=>{if(!u.current)return;const w=u.current.files;if(!w){a();return}const A=Array.from(w).map(S=>st.from(U.v4(),S)),E=[...n,...A];o(E),a()},[a,o,n]),h=y.useCallback(w=>{const A=n.filter(({uuid:E})=>E!==w.uuid);o(A),a()},[n,o,a]);y.useEffect(()=>{if(!u.current)return;const w=new AbortController;return u.current.addEventListener("cancel",()=>{a()},{signal:w.signal}),()=>{w.abort()}},[a,n]);const x=e.maxFiles>1?"Select files":"Select a file";return d.jsxs(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:[d.jsxs(v.Button,{className:"w-max",size:t,variant:"soft",accentColor:"base",onClick:c,type:"button",disabled:l,children:[d.jsx(v.LuIcon,{icon:yn}),x]}),d.jsx("input",{id:e.identifier,name:i,type:"file",ref:u,accept:(m=e.extensions)==null?void 0:m.join(","),multiple:e.maxFiles>1,className:"hidden",onChange:f,value:""}),n.length>0&&d.jsx("div",{className:"flex h-max flex-col gap-2",children:n.map(w=>d.jsx(Pn,{size:t,fileOrPromise:w,onRemove:h,disabled:l},w.uuid))})]})});Ei.displayName="UploadFieldInput";class Dt extends Ve{constructor(t){const{extensions:n,maximum_files:i,maximum_size:a,...o}=t;super(o);M(this,"type","upload");M(this,"extensions");M(this,"maxFileSize");M(this,"maxFiles");this.maxFileSize=typeof a=="number"?a:void 0,this.maxFiles=Math.max(typeof i=="number"?i:1,1),this.extensions=n}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:1,maximum:10,identifier:`${n}maximum_files`,integers:!0}),showDirectly:!1},{field:new Pe({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${jt}MB).`,required:!1,identifier:`${n}maximum_size`,minimum:1,maximum:jt,integers:!0}),showDirectly:!1},{field:new it({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,identifier:`${n}extensions`,options:[{value:"image/*",label:"Images"},{value:"audio/*",label:"Audio files"},{value:"video/*",label:"Videos"},{value:"text/*",label:"Text files"},{value:"application/*",label:"Application files (includes PDFs and Word documents)"}]}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.maxFileSize??jt,i=n*1e3*1e3,a=this.maxFiles||1;return t.push(o=>{if(o.some(s=>s instanceof st&&s.size>i))return`Files must be at most ${n}MB.`}),t.push(o=>{if(o.length>a)return`You can only upload ${a} files.`}),t}serialize(){return{...super.serialize(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}getOptions(){return{...super.getOptions(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}duplicate(t){return new Dt({...this.getOptions(),identifier:t})}setOptions(t){const{extensions:n,maximum_files:i,maximum_size:a,...o}=t;this.maxFileSize=typeof a=="number"?a:this.maxFileSize,this.maxFiles=typeof i=="number"?i:this.maxFiles,this.extensions=n,super.setOptions(o)}static deserialize(t){return new Dt(t)}serializeValue(t){return[]}deserializeValue(t){return[]}render(){return d.jsx(Ei,{field:this})}isSerializedValue(t){return Array.isArray(t)&&t.length===0}isValue(t){return Array.isArray(t)?t.every(n=>n instanceof kt||n instanceof st):!1}areValuesEqual(t,n){return Lr(t,n)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){return t.length===n.length}}const Ii=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(p=>{const g=p.target.value;g!==""&&!URL.canParse(g)||o(g!==""?new URL(g):null)},[o]),c=y.useCallback(()=>{a()},[a]),f=y.useCallback(p=>{p.key==="Enter"&&p.preventDefault()},[]),h=y.useCallback(()=>{n!==null&&window.open(n,"_blank","noopener,noreferrer")},[n]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs("div",{className:"flex w-full gap-2",children:[d.jsx(v.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:t,children:d.jsx(v.Input.Field,{id:e.identifier,className:"truncate",name:i,value:n?n.toString():"",type:"url",inputMode:"url",placeholder:e.placeholder,onChange:u,onBlur:c,disabled:l,onKeyDown:f})}),d.jsx(v.IconButton,{size:t,variant:"soft",accentColor:"base",type:"button",disabled:n===null,onClick:h,children:d.jsx(v.LuIcon,{icon:Ml})})]})})});Ii.displayName="URLFieldInput";class Wt extends Ve{constructor(t){const{placeholder:n="https://example.com",...i}=t;super(i);M(this,"type","url");M(this,"placeholder");this.placeholder=n}serialize(){return{...super.serialize(),placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(t){return new Wt({...this.getOptions(),identifier:t})}setOptions(t){const{placeholder:n,...i}=t;this.placeholder=n??this.placeholder,super.setOptions(i)}static deserialize(t){return new Wt(t)}serializeValue(t){return(t==null?void 0:t.toString())??null}deserializeValue(t){return t===null?null:new URL(t)}isSerializedValue(t){return t===null?!0:typeof t!="string"?!1:URL.canParse(t)}isValue(t){return t===null||t instanceof URL}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return(t==null?void 0:t.toString())===(n==null?void 0:n.toString())}render(){return d.jsx(Ii,{field:this})}}const Oi={date:Lt,time:Xt,number:Pe,boolean:yt,select:ot,string:Tt,url:Wt,text:Mt,upload:Dt,qr:$t,"multi-string":xt,"multi-select":it,radio:At,"checkbox-list":Ct,"pass-fail":_t,otp:mt,rating:St},Mo=Object.keys(Oi),ue={"checkbox-list":{description:"Allows the user to select a multiple options from a list.",group:W.Selection,icon:Tl,name:"Checkbox list"},"multi-select":{description:"Allows the user to select a multiple options from a list of options.",group:W.Selection,icon:Ll,name:"Multi-select"},"multi-string":{description:"Allows the user to provide multiple unique strings.",group:W.Text,icon:kl,name:"Multi-string"},"pass-fail":{description:"Track pass, fail, or N/A outcome.",group:W.Assessment,icon:Nl,name:"Pass - Fail"},boolean:{description:"Perfect for both optional and required yes/no questions.",group:W.Selection,icon:ql,name:"Checkbox"},date:{description:"Allows specifying a date.",group:W.Temporal,icon:Sl,name:"Date"},time:{description:"Allows specifying a time and UTC offset.",group:W.Temporal,icon:Wl,name:"Time"},number:{description:"Allows specifying a number within a given range.",group:W.Numeric,icon:Pl,name:"Number"},otp:{description:"Allows specifying a number within a given range.",group:W.Verification,icon:Rl,name:"OTP"},qr:{description:"Used for scanning/reading QR and barcodes.",group:W.Capture,icon:Gl,name:"Scan"},radio:{description:"Allows the user to select a single option from a list of options.",group:W.Selection,icon:Il,name:"Option list"},rating:{description:"Allows users to select a rating value.",group:W.Assessment,icon:xa,name:"Rating"},select:{description:"Allows the user to select a single option from a list of options.",group:W.Selection,icon:zl,name:"Dropdown"},string:{description:"Short text fields can hold up to 500 characters on a single line.",group:W.Text,icon:Xl,name:"Short Text"},text:{description:"Paragraph fields can hold up to 10000 characters and can have multiple lines.",group:W.Text,icon:wl,name:"Paragraph"},upload:{description:"Allows a file to be uploaded.",group:W.Capture,icon:yn,name:"Upload"},url:{description:"Allows users to enter a URL.",group:W.Text,icon:Bl,name:"URL"}},Do={[W.Assessment]:{name:"Assessment"},[W.Capture]:{name:"Capture"},[W.Numeric]:{name:"Numeric"},[W.Selection]:{name:"Selection"},[W.Temporal]:{name:"Temporal"},[W.Text]:{name:"Text"},[W.Verification]:{name:"Verification"}},jt=50,Fo=jt*1e3,Vo=Fo*1e3,Ce="Unlabelled",bi="Unlabelled";class H{constructor(e){M(this,"id");M(this,"label");M(this,"getApplyFn");M(this,"serialize");M(this,"deserialize");const{id:t,getApplyFn:n,label:i,serialize:a,deserialize:o}=e;this.id=t,this.getApplyFn=n,this.label=i,this.serialize=a,this.deserialize=o}static create(e){return new H(e)}}const Po=H.create({id:"nullable-boolean-equals",label:"is",getApplyFn:r=>e=>e===r,serialize:r=>r,deserialize:r=>r}),Bo=H.create({id:"nullable-boolean-not-equals",label:"is not",getApplyFn:r=>e=>e!==r,serialize:r=>r,deserialize:r=>r}),Lo=H.create({id:"date-equals",getApplyFn:r=>e=>e.getTime()===r.getTime(),label:"is",serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),zo=H.create({id:"date-not-equals",getApplyFn:r=>e=>e.getTime()!==r.getTime(),label:"is not",serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),ko=H.create({id:"date-before",getApplyFn:r=>e=>e.getTime()<r.getTime(),label:"before",serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),Uo=H.create({id:"date-after",label:"after",getApplyFn:r=>e=>e.getTime()>r.getTime(),serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),Ro=H.create({id:"date-range-in",label:"in between",getApplyFn:r=>e=>!(r!=null&&r.from&&r.from.getTime()>e.getTime()||r!=null&&r.to&&r.to.getTime()<e.getTime()),serialize:r=>{var e,t;return{from:((e=r.from)==null?void 0:e.toISOString())??null,to:((t=r.to)==null?void 0:t.toISOString())??null}},deserialize:r=>({from:r.from?new Date(r.from):void 0,to:r.to?new Date(r.to):void 0})}),Go=H.create({id:"date-range-not-in",label:"not in between",getApplyFn:r=>e=>!!(r!=null&&r.from&&r.from.getTime()>e.getTime()||r!=null&&r.to&&r.to.getTime()<e.getTime()),serialize:r=>{var e,t;return{from:((e=r.from)==null?void 0:e.toISOString())??null,to:((t=r.to)==null?void 0:t.toISOString())??null}},deserialize:r=>({from:r.from?new Date(r.from):void 0,to:r.to?new Date(r.to):void 0})}),Ho=H.create({id:"has-files",label:"is",getApplyFn:r=>e=>e.length>0,serialize:r=>r,deserialize:r=>r}),qo=H.create({id:"does-not-have-files",label:"is not",getApplyFn:r=>e=>e.length===0,serialize:r=>r,deserialize:r=>r}),Ni=H.create({id:"number-equals",getApplyFn:r=>e=>e===r,label:"is",serialize:r=>r,deserialize:r=>r}),Ti=H.create({id:"number-not-equals",getApplyFn:r=>e=>e!==r,label:"is not",serialize:r=>r,deserialize:r=>r}),Mi=H.create({id:"number-less-than",getApplyFn:r=>e=>e<r,label:"is less than",serialize:r=>r,deserialize:r=>r}),Di=H.create({id:"number-less-than-or-equals",getApplyFn:r=>e=>e<=r,label:"is less than or equal to",serialize:r=>r,deserialize:r=>r}),Fi=H.create({id:"number-greater-than",getApplyFn:r=>e=>e>r,label:"is greater than",serialize:r=>r,deserialize:r=>r}),Vi=H.create({id:"number-greater-than-or-equals",getApplyFn:r=>e=>e>=r,label:"is greater than or equal to",serialize:r=>r,deserialize:r=>r}),Pi=H.create({id:"number-range-in",getApplyFn:r=>e=>!(r.to&&e>r.to||r.from&&e<r.from),label:"is between",serialize:r=>r,deserialize:r=>r}),Bi=H.create({id:"number-range-not-in",getApplyFn:r=>e=>!!(r.to&&e>r.to||r.from&&e<r.from),label:"is not between",serialize:r=>r,deserialize:r=>r}),$o=H.create({id:"pass-fail-equals",getApplyFn:r=>e=>e===r,label:"is",serialize:r=>r,deserialize:r=>r}),Xo=H.create({id:"pass-fail-not-equals",getApplyFn:r=>e=>e!==r,label:"is not",serialize:r=>r,deserialize:r=>r}),Wo=H.create({id:"pass-fail-array-includes",getApplyFn:r=>{const e=new Set(r);return t=>e.has(t)},label:"is any of",serialize:r=>r,deserialize:r=>r}),jo=H.create({id:"pass-fail-array-excludes",getApplyFn:r=>{const e=new Set(r);return t=>!e.has(t)},label:"is none of",serialize:r=>r,deserialize:r=>r}),pt=H.create({id:"nullable-string-equals",getApplyFn:r=>e=>e===r,label:"is",serialize:r=>r,deserialize:r=>r}),vt=H.create({id:"nullable-string-not-equals",getApplyFn:r=>e=>e!==r,label:"is not",serialize:r=>r,deserialize:r=>r}),Yt=H.create({id:"string-includes",getApplyFn:r=>e=>e.includes(r),label:"includes",serialize:r=>r,deserialize:r=>r}),Zt=H.create({id:"string-excludes",getApplyFn:r=>e=>!e.includes(r),label:"does not include",serialize:r=>r,deserialize:r=>r}),Li=H.create({id:"string-array-includes",getApplyFn:r=>{const e=new Set(r);return t=>e.has(t)},label:"is any of",serialize:r=>r,deserialize:r=>r}),zi=H.create({id:"string-array-excludes",getApplyFn:r=>{const e=new Set(r);return t=>!e.has(t)},label:"is none of",serialize:r=>r,deserialize:r=>r}),rn=H.create({id:"string-array-every",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.isSubsetOf(n)}},label:"has all of",serialize:r=>r,deserialize:r=>r}),nn=H.create({id:"string-array-some",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return!e.isDisjointFrom(n)}},label:"has any of",serialize:r=>r,deserialize:r=>r}),an=H.create({id:"string-array-none",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.isDisjointFrom(n)}},label:"has none of",serialize:r=>r,deserialize:r=>r}),on=H.create({id:"string-array-equals",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.size===n.size&&n.isSubsetOf(e)}},label:"is",serialize:r=>r,deserialize:r=>r}),sn=H.create({id:"string-array-not-equals",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.size!==n.size||!n.isSubsetOf(e)}},label:"is not",serialize:r=>r,deserialize:r=>r}),Yo=H.create({id:"time-equals",label:"is",getApplyFn:r=>e=>e===r,serialize:r=>r,deserialize:r=>r}),Zo=H.create({id:"time-not-equals",label:"is not",getApplyFn:r=>e=>e!==r,serialize:r=>r,deserialize:r=>r}),Ko=H.create({id:"time-before",label:"before",getApplyFn:r=>e=>ht(e)<ht(r),serialize:r=>r,deserialize:r=>r}),Qo=H.create({id:"time-after",label:"after",getApplyFn:r=>e=>ht(e)>ht(r),serialize:r=>r,deserialize:r=>r}),Jo=H.create({id:"time-range-in",label:"in between",getApplyFn:r=>e=>Ai(e,r),serialize:r=>r,deserialize:r=>r}),es=H.create({id:"time-range-not-in",label:"not in between",getApplyFn:r=>e=>!Ai(e,r),serialize:r=>r,deserialize:r=>r}),F=r=>r;class Ee extends er{constructor(t){const{id:n,field:i,conditionValue:a,conditionModifier:o}=t;super();M(this,"id");M(this,"conditionValue");M(this,"conditionModifier");M(this,"field");M(this,"getConditionValue",()=>this.conditionValue);M(this,"setConditionValue",t=>{const n=this.modifiers[this.conditionModifier];t!==void 0&&!n.isConditionValueValid(t)||(this.conditionValue=t,this.notify(this))});M(this,"getConditionModifier",()=>this.conditionModifier);M(this,"setConditionModifier",t=>{const n=this.modifiers[t],i=this.getConditionValue();i&&!n.isConditionValueValid(i)&&(this.conditionValue=void 0),this.conditionModifier=t,this.notify(this)});M(this,"getConditionModifiers",()=>Object.entries(this.modifiers));M(this,"accessorFn",t=>t[this.field.identifier]);M(this,"getApplyFn",()=>{const t=this.modifiers[this.conditionModifier],n=this.getConditionValue(),i=n!==void 0&&t.isConditionValueValid(n),a=i?t.modifier.getApplyFn(n):null;return o=>{if(!i)return!0;const s=this.transformValue(o);return t.isValueValid(s)?a(s):!1}});this.id=n,this.field=i,this.conditionValue=a,this.conditionModifier=o}serialize(){return{id:this.id,type:this.field.type,fieldId:this.field.identifier,conditionValue:this.conditionValue!==void 0?this.modifiers[this.conditionModifier].modifier.serialize(this.conditionValue):void 0,conditionModifier:this.conditionModifier}}transformValue(t){return t}}const ts=y.memo,Ft=ts(function(r){const{ref:e,children:t,...n}=r,i=y.useCallback(a=>typeof t=="function"?d.jsxs(d.Fragment,{children:[t(a),d.jsx(v.Menu.SelectedIndicator,{className:"ml-[auto]",children:d.jsx(v.LuIcon,{icon:ke})})]}):d.jsxs(d.Fragment,{children:[t,d.jsx(v.Menu.SelectedIndicator,{className:"ml-[auto]",children:d.jsx(v.LuIcon,{icon:ke})})]}),[t]);return d.jsx(v.Menu.SelectItem,{ref:e,...n,children:i})}),rs=ts(function(r){const{ref:e,children:t,...n}=r,i=y.useCallback(a=>typeof t=="function"?d.jsxs(d.Fragment,{children:[t(a),d.jsx(v.Menu.SelectedIndicator,{className:"ml-auto",children:d.jsx(v.LuIcon,{icon:ke})})]}):d.jsxs(d.Fragment,{children:[t,d.jsx(v.Menu.SelectedIndicator,{className:"ml-auto",children:d.jsx(v.LuIcon,{icon:ke})})]}),[t]);return d.jsx(v.Menu.MultiSelectItem,{ref:e,...n,children:i})}),ki=y.memo(r=>{const{ref:e,children:t,...n}=r,i=y.useCallback(a=>typeof t=="function"?d.jsxs(d.Fragment,{children:[t(a),d.jsx(v.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:o=>o?d.jsx(v.LuIcon,{icon:Vr}):d.jsx(v.LuIcon,{icon:ke})})]}):d.jsxs(d.Fragment,{children:[t,d.jsx(v.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:o=>o?d.jsx(v.LuIcon,{icon:Vr}):d.jsx(v.LuIcon,{icon:ke})})]}),[t]);return d.jsx(v.Menu.SelectAllItem,{ref:e,...n,children:i})});ki.displayName="SelectAllItemTemplate";const Te=r=>{const{children:e,condition:t,size:n="sm",variant:i,accentColor:a,radius:o}=r,s=y.useCallback(l=>{t.setConditionModifier(l)},[t]);return d.jsxs(v.Menu.Root,{align:"start",children:[d.jsx(v.Menu.ClickTrigger,{children:e}),d.jsx(v.Menu.Content,{size:n,variant:i,radius:o,accentColor:a,children:d.jsx(v.Menu.SelectGroup,{required:!0,value:t.getConditionModifier(),onValueChange:s,children:t.getConditionModifiers().map(([l,u])=>d.jsx(Ft,{value:l,children:u.modifier.label},l))})})]})},ln=y.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,align:s,accentColor:l="base",...u}=r;return d.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:e}),d.jsx(v.Popover.Content,{size:o,align:s,children:d.jsx(v.DayPicker,{size:o,accentColor:l,...u})})]})});ln.displayName="DayPickerPopover";const ns=y.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,accentColor:s="base",values:l,onValuesChange:u,placeholder:c="Enter text",...f}=r,[h,p]=y.useState(""),g=y.useCallback(A=>{p(A.target.value)},[]),x=y.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),A.stopPropagation(),u([...l,h]),p(""))},[h,u,l]),m=y.useCallback(()=>{u([...l,h]),p("")},[h,u,l]),w=y.useCallback(A=>{const E=[...l];E.splice(A,1),u(E)},[u,l]);return d.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:e}),d.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,accentColor:s,...f,children:d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex gap-2",children:[d.jsx(v.Input.Root,{className:"grow",accentColor:"base",variant:"outline",size:"sm",children:d.jsx(v.Input.Field,{value:h,onChange:g,onKeyDown:x,placeholder:c,...f})}),d.jsx(v.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button",onClick:m,children:d.jsx(v.LuIcon,{icon:Ze})})]}),l.length>0&&d.jsx("div",{className:"flex flex-col gap-1",children:l.map((A,E)=>d.jsxs(v.Badge,{className:"flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[d.jsx("span",{className:"truncate",children:A}),d.jsx(v.IconButton,{size:"xs",variant:"ghost",type:"button",accentColor:"base",onClick:()=>{w(E)},children:d.jsx(v.LuIcon,{icon:at})})]},`${A}-${E}`))})]})})]})});ns.displayName="NumberInputPopover";const Vt=y.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,accentColor:s="base",value:l,onValueChange:u,placeholder:c="Enter a number",...f}=r,[h,p]=y.useState(null);y.useEffect(()=>{l!==void 0&&p(l)},[l]);const g=y.useCallback(m=>{const w=m.target.valueAsNumber;p(isNaN(w)?null:w)},[]),x=y.useCallback(m=>{const w=m.target.valueAsNumber;u==null||u(isNaN(w)?null:w)},[u]);return d.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:e}),d.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,...f,children:d.jsx(v.Input.Root,{size:o,accentColor:s,children:d.jsx(v.Input.Field,{placeholder:c,type:"number",value:h??"",onChange:g,onBlur:x})})})]})});Vt.displayName="NumberInputPopover";const Ie=r=>{const{condition:e,onClick:t,...n}=r,i=y.useCallback(()=>{t(e)},[e,t]);return d.jsx(v.IconButton,{onClick:i,...n,children:d.jsx(v.LuIcon,{icon:at})})};Ie.displayName="RemoveConditionButton";const hr=y.memo(r=>{const{ref:e,selectFieldOptions:t,...n}=r,i=y.useMemo(()=>t.map(a=>typeof a=="string"?{value:a,label:a}:a),[t]);return d.jsxs(v.Menu.MultiSelectGroup,{ref:e,...n,children:[d.jsx(ki,{children:"Select all"}),i.map(a=>d.jsx(rs,{value:a.value,children:d.jsx("span",{className:"truncate",children:a.label})},a.value))]})});hr.displayName="SelectFieldOptionMultiSelectGroup";const Ui=y.memo(r=>{const{ref:e,selectFieldOptions:t,...n}=r,i=y.useMemo(()=>t.map(a=>typeof a=="string"?{value:a,label:a}:a),[t]);return d.jsx(v.Menu.SelectGroup,{ref:e,...n,children:i.map(a=>d.jsx(Ft,{value:a.value,children:d.jsx("span",{className:"truncate",children:a.label})},a.value))})});Ui.displayName="SelectFieldOptionSelectGroup";const Kt=y.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,accentColor:s="base",value:l,onValueChange:u,placeholder:c="Enter text",...f}=r,[h,p]=y.useState(""),g=y.useCallback(m=>{p(m.target.value)},[]),x=y.useCallback(m=>{const w=m.target.value;u==null||u(w)},[u]);return y.useEffect(()=>{l&&p(l)},[l]),d.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:e}),d.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,...f,children:d.jsx(v.Input.Root,{size:o,accentColor:s,children:d.jsx(v.Input.Field,{placeholder:c,type:"text",value:h,onChange:g,onBlur:x})})})]})});Kt.displayName="TextInputPopover";const un=y.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o="sm",accentColor:s="base",value:l,onValueChange:u,...c}=r;return d.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:e}),d.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,accentColor:s,...c,children:d.jsx(tn,{compact:!0,size:o,value:l,onChange:u})})]})});un.displayName="TimeInputPopover";const is=r=>{const{condition:e,onRemove:t}=r,n=e.getConditionValue(),i=e.getConditionModifier(),a=()=>{switch(n){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[e.field.type].icon}),d.jsx("span",{className:"truncate",children:e.field.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[i].modifier.label})}),d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:a()})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsxs(v.Menu.SelectGroup,{required:!0,value:n,onValueChange:e.setConditionValue,children:[d.jsx(Ft,{value:!0,children:"true"}),d.jsx(Ft,{value:!1,children:"false"})]})})]}),d.jsx(Ie,{condition:e,onClick:t})]})},as={equals:F({modifier:Po,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:Bo,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class pr extends Ee{constructor(t){super(t);M(this,"modifiers",as)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=as[a];let l;return i!==void 0&&(l=s.modifier.deserialize(i)),new pr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(is,{condition:this,...t},this.id)}}const Qt=[],os=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=y.useCallback(l=>{l.length>0?e.setConditionValue(l):e.setConditionValue(void 0)},[e]),s=()=>{if(i===void 0)return"...";if(i===null)return"empty";switch(i.length){case 0:return"...";default:return`${i.length} options`}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"soft",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"soft",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"truncate",children:s()})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(hr,{values:i??Qt,selectFieldOptions:e.field.options,onValuesChange:o})})]}),d.jsx(Ie,{condition:e,onClick:t})]})},ss={equals:F({modifier:on,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:sn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),every:F({modifier:rn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),some:F({modifier:nn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),none:F({modifier:an,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class vr extends Ee{constructor(t){super(t);M(this,"modifiers",ss)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ss[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new vr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(os,{condition:this,...t},this.id)}}class cn extends er{constructor(t){super();M(this,"conditions");M(this,"conditionObserver",()=>{this.conditions=[...this.conditions],this.notify(this)});M(this,"initConditions",t=>{for(const n of t)n.observe(this.conditionObserver);return t});this.conditions=this.initConditions(t)}getConditions(){return this.conditions}addCondition(t){this.conditions=this.initConditions([...this.conditions,t]),this.notify(this)}addConditions(t){this.conditions=this.initConditions([...this.conditions,...t]),this.notify(this)}removeCondition(t){this.conditions=this.initConditions(this.conditions.filter(n=>n.id!==t.id)),this.notify(this)}removeConditions(t){const n=new Set(t.map(i=>i.id));this.conditions=this.initConditions(this.conditions.filter(i=>!n.has(i.id))),this.notify(this)}applyConditions(t){return this.conditions.length===0?!0:this.conditions.map(i=>[i.getApplyFn(),i.accessorFn]).every(([i,a])=>i(a(t)))}}const Rf=(r,e)=>y.useMemo(()=>{const t=new cn(r);return t.observe(n=>e(n.getConditions())),t},[r,e]),ls=r=>{const{condition:e,onRemove:t}=r,n=e.getConditionValue(),i=e.getConditionModifier(),a=()=>{var o,s;switch(i){case"equals":case"notEquals":{const l=e.modifiers.equals,u=n!==void 0&&l.isConditionValueValid(n)?n:void 0;return d.jsx(ln,{required:!1,size:"sm",mode:"single",selected:u??void 0,onSelect:c=>e.setConditionValue(c),children:d.jsx(v.Button,{type:"button",className:"truncate",children:u!==void 0?(u==null?void 0:u.toLocaleDateString())??"empty":"..."})})}case"before":case"after":{const l=e.modifiers.after,u=n!==void 0&&l.isConditionValueValid(n)?n:void 0;return d.jsx(ln,{required:!0,size:"sm",mode:"single",selected:u,onSelect:e.setConditionValue,children:d.jsx(v.Button,{type:"button",className:"truncate",children:u?u.toLocaleDateString():"..."})})}case"in":case"notIn":{const l=e.modifiers.in,u=n!==void 0&&l.isConditionValueValid(n)?n:void 0;return d.jsx(ln,{required:!0,mode:"range",size:"sm",selected:u,onSelect:e.setConditionValue,children:d.jsx(v.Button,{className:"truncate",children:u?`${(o=u.from)==null?void 0:o.toLocaleDateString()} - ${(s=u.to)==null?void 0:s.toLocaleDateString()}`:"..."})})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[e.field.type].icon}),d.jsx("span",{className:"truncate",children:e.field.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[i].modifier.label})}),a(),d.jsx(Ie,{condition:e,onClick:t})]})},us={equals:F({modifier:Lo,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),notEquals:F({modifier:zo,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),before:F({modifier:ko,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),after:F({modifier:Uo,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),in:F({modifier:Ro,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>"to"in(r??{})&&"from"in(r??{}),isSerializedValueValid:r=>typeof r=="object"&&"to"in r&&"from"in r}),notIn:F({modifier:Go,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>"to"in(r??{})&&"from"in(r??{}),isSerializedValueValid:r=>typeof r=="object"&&"to"in r&&"from"in r})};class gr extends Ee{constructor(t){super(t);M(this,"modifiers",us)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=us[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new gr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(ls,{condition:this,...t},this.id)}}const cs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=y.useCallback(l=>{l.length>0?e.setConditionValue(l):e.setConditionValue(void 0)},[e]),s=()=>{if(i===void 0)return"...";if(i===null)return"empty";switch(i.length){case 0:return"...";default:return`${i.length} options`}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"truncate",children:s()})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(hr,{values:i??Qt,selectFieldOptions:n.options,onValuesChange:o})})]}),d.jsx(Ie,{condition:e,onClick:t})]})},ds={equals:F({modifier:on,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:sn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),every:F({modifier:rn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),some:F({modifier:nn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),none:F({modifier:an,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class xr extends Ee{constructor(t){super(t);M(this,"modifiers",ds)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ds[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new xr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(cs,{condition:this,...t},this.id)}}const fs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=y.useCallback(l=>{e.setConditionValue(l.length>0?l:void 0)},[e]),s=()=>{if(i===void 0)return"...";if(i===null)return"empty";switch(i.length){case 0:return"...";case 1:return i[0].toString();default:return`${i.length} values`}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),d.jsx(ns,{values:i??Qt,onValuesChange:o,children:d.jsx(v.Button,{type:"button",className:"truncate",children:s()})}),d.jsx(Ie,{condition:e,onClick:t})]})},hs={equals:F({modifier:on,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:sn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),every:F({modifier:rn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),some:F({modifier:nn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),none:F({modifier:an,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class yr extends Ee{constructor(t){super(t);M(this,"modifiers",hs)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=hs[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new yr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(fs,{condition:this,...t},this.id)}}const ps=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=y.useCallback(l=>{e.setConditionValue(l??void 0)},[e]),s=()=>{switch(a){case"equals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const l=e.modifiers.greaterThan,u=i!==void 0&&l.isConditionValueValid(i)?i:void 0;return d.jsx(Vt,{value:u??null,onValueChange:o,size:"sm",children:d.jsx(v.Button,{type:"button",className:"truncate",children:u!==void 0?u??"empty":"..."})})}case"inRange":case"notInRange":{const l=e.modifiers.inRange,u=i!==void 0&&l.isConditionValueValid(i)?i:void 0;return d.jsxs(d.Fragment,{children:[d.jsx(Vt,{value:(u==null?void 0:u.from)??null,onValueChange:c=>{e.setConditionValue({from:c,to:(u==null?void 0:u.to)??null})},size:"sm",children:d.jsx(v.Button,{className:"truncate",children:(u==null?void 0:u.from)??"..."})}),d.jsx(Vt,{value:(u==null?void 0:u.to)??null,onValueChange:c=>{e.setConditionValue({from:(u==null?void 0:u.from)??null,to:c})},size:"sm",children:d.jsx(v.Button,{className:"truncate",children:(u==null?void 0:u.to)??"..."})})]})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),s(),d.jsx(Ie,{condition:e,onClick:t})]})},vs={equals:F({modifier:Ni,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),notEquals:F({modifier:Ti,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThan:F({modifier:Mi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThanOrEquals:F({modifier:Di,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThan:F({modifier:Fi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThanOrEquals:F({modifier:Vi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),inRange:F({modifier:Pi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"}),notInRange:F({modifier:Bi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"})};class Cr extends Ee{constructor(t){super(t);M(this,"modifiers",vs)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=vs[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Cr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(ps,{condition:this,...t},this.id)}}const gs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return d.jsx(Kt,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:i||"..."})})})}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},xs={equals:F({modifier:pt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:vt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:F({modifier:Yt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:F({modifier:Zt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class mr extends Ee{constructor(t){super(t);M(this,"modifiers",xs)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=xs[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new mr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(gs,{condition:this,...t},this.id)}}const ys=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":{const s=e.modifiers.equals,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:l!==void 0?l?wt[l].label:"empty":"..."})})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(v.Menu.SelectGroup,{required:!1,value:l,onValueChange:e.setConditionValue,children:zt.map(u=>{const{label:c}=wt[u];return d.jsx(Ft,{value:u,children:d.jsx("span",{className:"truncate",children:c})},u)})})})]})}case"includes":case"excludes":{const s=e.modifiers.includes,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",children:l?`${l.length} statuses`:"..."})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsxs(v.Menu.MultiSelectGroup,{values:l??Qt,onValuesChange:e.setConditionValue,children:[d.jsx(ki,{children:"Select all"}),zt.map(u=>{const{label:c,icon:f}=wt[u];return d.jsxs(rs,{value:u,children:[d.jsx(v.LuIcon,{icon:f}),d.jsx("span",{className:"truncate",children:c})]},u)})]})})]})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},Cs={equals:F({modifier:$o,isValueValid:r=>r!==null,isConditionValueValid:r=>typeof r=="string",isSerializedValueValid:r=>typeof r=="string"}),notEquals:F({modifier:Xo,isValueValid:r=>r!==null,isConditionValueValid:r=>typeof r=="string",isSerializedValueValid:r=>typeof r=="string"}),includes:F({modifier:Wo,isValueValid:r=>r!==null,isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)}),excludes:F({modifier:jo,isValueValid:r=>r!==null,isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)})};class wr extends Ee{constructor(t){super(t);M(this,"modifiers",Cs)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Cs[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new wr({field:n,conditionModifier:a,conditionValue:l,...o})}transformValue(t){return t.status}render(t){return d.jsx(ys,{condition:this,...t},this.id)}}const ms=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=y.useMemo(()=>n.options.map(u=>typeof u=="string"?{value:u,label:u}:u),[n.options]),s=y.useMemo(()=>{const u={};for(const c of o)u[c.value]=c.label;return u},[o]),l=()=>{switch(a){case"equals":case"notEquals":{const u=e.modifiers.equals,c=i!==void 0&&u.isConditionValueValid(i)?i:void 0;return d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:c!==void 0?c?s[c]:"empty":"..."})})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(Ui,{required:!0,selectFieldOptions:n.options,value:c??void 0,onValueChange:e.setConditionValue})})]})}case"includes":case"excludes":{const u=e.modifiers.includes,c=i!==void 0&&u.isConditionValueValid(i)?i:void 0;return d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",children:c?`${c.length} options`:"..."})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(hr,{selectFieldOptions:n.options,values:c??Qt,onValuesChange:e.setConditionValue})})]})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),l(),d.jsx(Ie,{condition:e,onClick:t})]})},ws={equals:F({modifier:pt,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),notEquals:F({modifier:vt,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),includes:F({modifier:Li,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)}),excludes:F({modifier:zi,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)})};class _r extends Ee{constructor(t){super(t);M(this,"modifiers",ws)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ws[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new _r({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(ms,{condition:this,...t},this.id)}}const _s=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const s=e.modifiers[a],l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return d.jsx(Vt,{value:l??null,onValueChange:u=>e.setConditionValue(u??void 0),size:"sm",children:d.jsx(v.Button,{type:"button",className:"truncate",children:l!==void 0?l:"..."})})}case"inRange":case"notInRange":{const s=e.modifiers.inRange,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return d.jsxs(d.Fragment,{children:[d.jsx(Vt,{value:(l==null?void 0:l.from)??null,onValueChange:u=>{e.setConditionValue({from:u,to:(l==null?void 0:l.to)??null})},size:"sm",children:d.jsx(v.Button,{className:"truncate",children:(l==null?void 0:l.from)??"..."})}),d.jsx(Vt,{value:(l==null?void 0:l.to)??null,onValueChange:u=>{e.setConditionValue({from:(l==null?void 0:l.from)??null,to:u})},size:"sm",children:d.jsx(v.Button,{className:"truncate",children:(l==null?void 0:l.to)??"..."})})]})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},As={equals:F({modifier:Ni,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),notEquals:F({modifier:Ti,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThan:F({modifier:Mi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThanOrEquals:F({modifier:Di,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThan:F({modifier:Fi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThanOrEquals:F({modifier:Vi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),inRange:F({modifier:Pi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"}),notInRange:F({modifier:Bi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"})};class Ar extends Ee{constructor(t){super(t);M(this,"modifiers",As)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=As[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Ar({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(_s,{condition:this,...t},this.id)}}const Ss=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return d.jsx(Kt,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:i||"..."})})})}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},Es={equals:F({modifier:pt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:vt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:F({modifier:Yt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:F({modifier:Zt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Sr extends Ee{constructor(t){super(t);M(this,"modifiers",Es)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Es[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Sr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(Ss,{condition:this,...t},this.id)}}const Is=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=y.useMemo(()=>n.options.map(c=>typeof c=="string"?{value:c,label:c}:c),[n.options]),s=y.useMemo(()=>{const c={};for(const f of o)c[f.value]=f.label;return c},[o]),l=y.useCallback(c=>{c.length>0?e.setConditionValue(c):e.setConditionValue([])},[e]),u=()=>{switch(a){case"equals":case"notEquals":{const c=e.modifiers.equals,f=i!==void 0&&c.isConditionValueValid(i)?i:void 0;return d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:f!==void 0?f?s[f]:"empty":"..."})})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(Ui,{required:!1,selectFieldOptions:n.options,value:f??void 0,onValueChange:e.setConditionValue})})]})}case"includes":case"excludes":{const c=e.modifiers.includes,f=i!==void 0&&c.isConditionValueValid(i)?i:void 0;return d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",children:f?`${f.length} options`:"..."})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(hr,{selectFieldOptions:n.options,values:f??Qt,onValuesChange:l})})]})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),u(),d.jsx(Ie,{condition:e,onClick:t})]})},Os={equals:F({modifier:pt,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),notEquals:F({modifier:vt,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),includes:F({modifier:Li,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)}),excludes:F({modifier:zi,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)})};class Er extends Ee{constructor(t){super(t);M(this,"modifiers",Os)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Os[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Er({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(Is,{condition:this,...t},this.id)}}const bs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return d.jsx(Kt,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:i||"..."})})})}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},Ns={equals:F({modifier:pt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:vt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:F({modifier:Yt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:F({modifier:Zt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Ir extends Ee{constructor(t){super(t);M(this,"modifiers",Ns)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Ns[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Ir({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(bs,{condition:this,...t},this.id)}}const Ts=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return d.jsx(Kt,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:i||"..."})})})}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},Ms={equals:F({modifier:pt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:vt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:F({modifier:Yt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:F({modifier:Zt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Or extends Ee{constructor(t){super(t);M(this,"modifiers",Ms)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Ms[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Or({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(Ts,{condition:this,...t},this.id)}}const Ds=r=>{const{condition:e,onRemove:t}=r,n=e.getConditionValue(),i=e.getConditionModifier(),a=()=>{switch(i){case"equals":case"notEquals":case"before":case"after":{const o=typeof n=="string"?n:void 0;return d.jsx(un,{value:o,onValueChange:s=>e.setConditionValue(s??void 0),size:"sm",children:d.jsx(v.Button,{type:"button",className:"truncate",children:o?en(o):"..."})})}case"in":case"notIn":{const o=n&&typeof n=="object"?n:void 0,s=l=>{e.setConditionValue(l.from||l.to?l:void 0)};return d.jsxs(d.Fragment,{children:[d.jsx(un,{value:o==null?void 0:o.from,onValueChange:l=>s({from:l,to:(o==null?void 0:o.to)??null}),size:"sm",children:d.jsx(v.Button,{type:"button",className:"truncate",children:o!=null&&o.from?en(o.from):"..."})}),d.jsx(un,{value:o==null?void 0:o.to,onValueChange:l=>s({from:(o==null?void 0:o.from)??null,to:l}),size:"sm",children:d.jsx(v.Button,{type:"button",className:"truncate",children:o!=null&&o.to?en(o.to):"..."})})]})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[e.field.type].icon}),d.jsx("span",{className:"truncate",children:e.field.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[i].modifier.label})}),a(),d.jsx(Ie,{condition:e,onClick:t})]})},Fs={equals:F({modifier:Yo,isValueValid:r=>ye(r),isConditionValueValid:r=>ye(r),isSerializedValueValid:r=>ye(r)}),notEquals:F({modifier:Zo,isValueValid:r=>ye(r),isConditionValueValid:r=>ye(r),isSerializedValueValid:r=>ye(r)}),before:F({modifier:Ko,isValueValid:r=>ye(r),isConditionValueValid:r=>ye(r),isSerializedValueValid:r=>ye(r)}),after:F({modifier:Qo,isValueValid:r=>ye(r),isConditionValueValid:r=>ye(r),isSerializedValueValid:r=>ye(r)}),in:F({modifier:Jo,isValueValid:r=>ye(r),isConditionValueValid:r=>fr(r),isSerializedValueValid:r=>fr(r)}),notIn:F({modifier:es,isValueValid:r=>ye(r),isConditionValueValid:r=>fr(r),isSerializedValueValid:r=>fr(r)})};class br extends Ee{constructor(t){super(t);M(this,"modifiers",Fs)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Fs[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new br({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(Ds,{condition:this,...t},this.id)}}const Vs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(i){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:o()})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsxs(v.Menu.SelectGroup,{required:!0,value:i,onValueChange:e.setConditionValue,children:[d.jsx(Ft,{value:!0,children:"empty"}),d.jsx(Ft,{value:!1,children:"not empty"})]})})]}),d.jsx(Ie,{condition:e,onClick:t})]})},Ps={equals:F({modifier:Ho,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:qo,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Nr extends Ee{constructor(t){super(t);M(this,"modifiers",Ps)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Ps[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Nr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(Vs,{condition:this,...t},this.id)}}const Bs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return d.jsx(Kt,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:i||"..."})})})}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},Ls={equals:F({modifier:pt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:vt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:F({modifier:Yt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:F({modifier:Zt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Tr extends Ee{constructor(t){super(t);M(this,"modifiers",Ls)}transformValue(t){return(t==null?void 0:t.toString())??""}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Ls[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Tr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(Bs,{condition:this,...t},this.id)}}const Gf={date:gr,time:br,number:Cr,boolean:pr,select:Er,string:Ir,url:Tr,text:Or,upload:Nr,qr:Sr,"multi-string":yr,"multi-select":xr,radio:_r,"checkbox-list":vr,"pass-fail":wr,otp:mr,rating:Ar},zs=(r,e)=>{if(r.type!==e.type)throw new Error(`field and condition type mismatch ${r.type} !== ${e.type}`);return Gf[e.type].deserialize(e,r)},Ri=(r,e)=>{const t=Gi(r,e),n={};for(const i of r)n[i.identifier]=i;return t.map(i=>zs(n[i.fieldId],i))},ks=(r,e)=>Hi(r,e).map(n=>n.serialize()),Gi=(r,e)=>{const t=new Set(r.map(n=>n.identifier));return e.filter(n=>t.has(n.fieldId))},Hi=(r,e)=>{const t=new Set(r.map(n=>n.identifier));return e.filter(n=>t.has(n.field.identifier))},dn=r=>Oi[r.type].deserialize(r);function Hf(r){return r.map(Us)}const Us=r=>r.type==="section"?qe.deserialize(r):dn(r);function qf(r){return r.map(dn)}function $f(r){const e=[];for(const t of r)if(t instanceof qe)for(const n of t.getFields())e.push(n);else e.push(t);return e}function Xf(r){const e={};for(const t of r)e[t.identifier]=t;return e}function Rs(r,e,t=!0){const n=t?fn(r,e):e,i={};for(const a of r){if(!(a.identifier in n))continue;const o=n[a.identifier];i[a.identifier]=a.serializeValue(o)}return i}function Gs(r,e,t=!0){const n=t?qi(r,e):e,i={};for(const a of r){if(!(a.identifier in n))continue;const o=n[a.identifier];i[a.identifier]=a.deserializeValue(o)}return i}function fn(r,e){const t={};for(const n of r){if(!(n.identifier in e))continue;const i=e[n.identifier];n.isValue(i)&&(t[n.identifier]=n.cleanValue(i))}return t}function qi(r,e){const t={};for(const n of r){if(!(n.identifier in e))continue;const i=e[n.identifier];n.isSerializedValue(i)&&(t[n.identifier]=n.cleanSerializedValue(i))}return t}function Hs(r,e){const t=fn(r,e),n={},i={};for(const a of r){if(!(a.identifier in t))continue;const o=t[a.identifier];switch(a.type){case"upload":if(!a.isValue(o))break;i[a.identifier]=o,n[a.identifier]=[];break;case"pass-fail":if(!a.isValue(o))break;i[a.identifier]=o.files,n[a.identifier]={...o,files:[]};break;default:n[a.identifier]=e[a.identifier]}}return[n,i]}function qs(r,e,t){const n={};for(const i of r){if(!(i.identifier in e))continue;const a=e[i.identifier];switch(i.type){case"upload":if(!i.isValue(a))break;n[i.identifier]=t[i.identifier]??[];break;case"pass-fail":if(!i.isValue(a))break;n[i.identifier]={...a,files:t[i.identifier]??[]};break;default:if(!i.isValue(a))break;n[i.identifier]=a}}return n}const $s=(r,e)=>{const t={};for(const n of r){const i=e[n.identifier];t[n.identifier]=i!==void 0?i:n.blankValue()}return t},Xs=(r,e,t)=>{const n={};for(const i of r){const a=e[i.identifier],o=t[i.identifier];i.areValuesEqual(a,o)||(n[i.identifier]=o)}return n},Ws=(r,e,t)=>{const n={};for(const i of r){const a=e[i.identifier],o=t[i.identifier];i.areValuesEqual(a,o)&&(n[i.identifier]=o)}return n},$i=(r,e,t)=>r.every(n=>{const i=e[n.identifier],a=t[n.identifier];return n.areValuesEqual(i,a)}),Xi=r=>{const e={};for(const t of r)e[t.identifier]=t.blankValue();return e},js=(r,e)=>$i(r,e,Xi(r)),Wf=$e.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),hn=$e.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),Wi=y.memo(r=>{const{fieldSection:e}=r,{label:t,description:n}=e,i=Ye.useWatch(),{fieldSchema:a,size:o}=y.use(ce),s=y.useMemo(()=>a.getFieldSections(),[a]),l=y.useMemo(()=>s.findIndex(({identifier:h})=>h===e.identifier),[s,e.identifier]),u=y.useMemo(()=>s.filter(h=>e.identifier in h.conditions),[s,e.identifier]),c=y.useMemo(()=>u.length===0?!0:u.some(h=>{const p=h.getConditions(e.identifier);return new cn(p).applyConditions(i)}),[u,e,i]),f=Br(e.fields);return c?d.jsxs(d.Fragment,{children:[l!==0?d.jsx(v.Separator,{size:"full"}):null,d.jsxs("div",{className:"flex flex-col gap-4",children:[(t||n)&&d.jsx(d.Fragment,{children:d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx(v.Heading,{size:o,children:t}),n&&d.jsx(v.Text,{accentColor:"base",size:o,children:n})]})}),d.jsx("div",{className:hn({size:o}),children:f})]})]}):null});Wi.displayName="FieldSectionLayout";const Mr=class Mr extends mn{constructor(t){const{label:n=null,description:i=null,fields:a,conditions:o={},...s}=t;super(s);M(this,"type","section");M(this,"label");M(this,"description");M(this,"conditions");M(this,"fields",[]);M(this,"fieldObserver",()=>{this.notify(this)});M(this,"initFields",t=>{for(const n of t)n.observe(this.fieldObserver);return t});M(this,"conditionObserver",()=>{this.notify(this)});M(this,"initConditions",t=>{for(const n of Object.values(t).flat())n.observe(this.conditionObserver);return t});this.label=n,this.description=i,this.fields=this.initFields(a),this.conditions=this.initConditions(o)}serialize(){const t={};for(const[n,i]of Object.entries(this.conditions))t[n]=i.map(a=>a.serialize());return{...super.serialize(),label:this.label,description:this.description,conditions:t,fields:this.fields.map(n=>n.serialize())}}getOptions(){return{...super.getOptions(),label:this.label,description:this.description,fields:this.fields,conditions:this.conditions}}duplicate(t){return new Mr({...this.getOptions(),identifier:t,fields:this.fields.map(n=>n.duplicate(U.v4()))})}setOptions(t){const{label:n,description:i,fields:a,conditions:o,...s}=t;this.label=n??this.label,this.description=i??this.description,this.fields=a||this.fields,this.conditions=o||this.conditions,super.setOptions(s)}getErrors(t){const n={};for(const i of this.fields){const a=i.getError(t[i.identifier]);a&&(n[i.identifier]=a)}return n}getFields(){return this.fields}addField(t,n){const i=[...this.fields];i.splice(n??this.fields.length,0,t),this.fields=this.initFields(i),this.notify(this)}moveField(t,n){const i=[...this.fields],[a]=i.splice(t,1);i.splice(n,0,a),this.fields=i,this.notify(this)}removeField(t){this.fields=this.initFields(this.fields.filter(({identifier:i})=>i!==t.identifier));const n={};for(const[i,a]of Object.entries(this.conditions))n[i]=a.filter(o=>o.field.identifier!==t.identifier);this.conditions=n,this.notify(this)}getConditions(t){return this.conditions[t]}addCondition(t,n){this.conditions=this.initConditions({...this.conditions,[t]:[...this.conditions[t]??[],n]}),this.notify(this)}addConditions(t,n){this.conditions=this.initConditions({...this.conditions,[t]:[...this.conditions[t]??[],...n]}),this.notify(this)}removeCondition(t,n){this.conditions=this.initConditions({...this.conditions,[t]:(this.conditions[t]??[]).filter(i=>i.id!==n.id)}),this.notify(this)}removeConditions(t,n){const i=new Set(n.map(a=>a.id));this.conditions=this.initConditions({...this.conditions,[t]:(this.conditions[t]??[]).filter(a=>!i.has(a.id))}),this.notify(this)}getConditionals(){return new Set(Object.keys(this.conditions))}addConditional(t){this.conditions=this.initConditions({...this.conditions,[t]:[]}),this.notify(this)}removeConditional(t){const n={...this.conditions};delete n[t],this.conditions=this.initConditions(n),this.notify(this)}render(){return d.jsx(Wi,{fieldSection:this})}};M(Mr,"deserialize",t=>{const n=t.fields.map(dn),i={};for(const[a,o]of Object.entries(t.conditions))i[a]=Ri(n,o);return new Mr({...t,fields:n,conditions:i})});let qe=Mr;const nt=y.createContext({}),pn=y.memo(r=>{const{children:e,variant:t,size:n,accentColor:i,onSelectFieldType:a,...o}=r,s=y.useMemo(()=>{const l={[W.Assessment]:[],[W.Capture]:[],[W.Numeric]:[],[W.Selection]:[],[W.Temporal]:[],[W.Text]:[],[W.Verification]:[]};for(const u of Mo){const{group:c}=ue[u];l[c].push(u)}return l},[]);return d.jsxs(v.Menu.Root,{...o,children:[d.jsx(v.Menu.ClickTrigger,{children:e}),d.jsx(v.Menu.Content,{variant:t,size:n,accentColor:i,children:d.jsx(v.Menu.Scroll,{children:Object.entries(s).map(([l,u])=>{const{name:c}=Do[l];return u.length===0?null:d.jsxs(v.Menu.Group,{children:[d.jsx(v.Menu.Label,{children:c}),u.map(f=>d.jsx(Ys,{fieldType:f,onSelectFieldType:a},f))]},l)})})})]})});pn.displayName="CreateFieldDropdownMenu";const Ys=y.memo(r=>{const{fieldType:e,onSelectFieldType:t}=r,n=y.useCallback(()=>{t(e)},[e,t]),{icon:i,name:a}=ue[e];return d.jsxs(v.Menu.Item,{onSelect:n,children:[d.jsx(v.LuIcon,{icon:i}),d.jsx(v.Text,{className:"truncate",children:a})]})});Ys.displayName="CreateFieldDropdownMenuItem";const vn=r=>{switch(r){case"text":return new Mt({label:"",required:!1,identifier:U.v4()});case"boolean":return new yt({label:"",required:!1,identifier:U.v4()});case"number":return new Pe({label:"",required:!1,identifier:U.v4()});case"date":return new Lt({label:"",required:!1,identifier:U.v4()});case"time":return new Xt({label:"",required:!1,identifier:U.v4()});case"string":return new Tt({label:"",required:!1,identifier:U.v4()});case"url":return new Wt({label:"",required:!1,identifier:U.v4()});case"select":return new ot({label:"",options:[],required:!1,identifier:U.v4()});case"multi-string":return new xt({label:"",required:!1,identifier:U.v4()});case"multi-select":return new it({label:"",options:[],required:!1,identifier:U.v4()});case"upload":return new Dt({label:"",required:!1,identifier:U.v4(),maximum_files:6,maximum_size:jt});case"qr":return new $t({label:"",required:!1,identifier:U.v4()});case"radio":return new At({label:"",options:[],required:!1,identifier:U.v4()});case"checkbox-list":return new Ct({label:"",options:[],required:!1,identifier:U.v4()});case"pass-fail":return new _t({label:"",required:!1,identifier:U.v4(),showNotesAndFilesOn:["fail"]});case"otp":return new mt({label:"",validationType:"none",required:!1,identifier:U.v4(),length:6});case"rating":return new St({label:"",required:!1,identifier:U.v4(),maxRating:5})}},ji=r=>{switch(r.type){case"text":return new Or({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"boolean":return new pr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"number":return new Cr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"date":return new gr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"time":return new br({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"string":return new Ir({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"url":return new Tr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"select":return new Er({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"multi-string":return new yr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"multi-select":return new xr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"upload":return new Nr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"qr":return new Sr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"radio":return new _r({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"checkbox-list":return new vr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"pass-fail":return new wr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"otp":return new mr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"rating":return new Ar({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r})}},Zs=(r,e)=>{switch(r){case"checkbox-list":return Ct.getFieldCreationSchema(e);case"multi-select":return it.getFieldCreationSchema(e);case"number":return Pe.getFieldCreationSchema(e);case"radio":return At.getFieldCreationSchema(e);case"select":return ot.getFieldCreationSchema(e);case"string":return Tt.getFieldCreationSchema(e);case"text":return Mt.getFieldCreationSchema(e);case"upload":return Dt.getFieldCreationSchema(e);case"pass-fail":return _t.getFieldCreationSchema(e);case"otp":return mt.getFieldCreationSchema(e);case"rating":return St.getFieldCreationSchema(e);default:return}},Ks=y.memo(r=>{const{popoverInputs:e,...t}=r;return d.jsxs(v.Popover.Root,{children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:d.jsxs(v.Button,{variant:"soft",type:"button",size:"sm",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:Hl}),"Settings"]})}),d.jsx(v.Popover.Content,{size:"sm",...t,children:d.jsx("div",{className:$e.cx("flex w-full max-w-[350px] flex-col",hn({size:"sm"})),children:e})})]})});Ks.displayName="FieldSettingsPopover";const Qs=y.memo(r=>{const{parentPath:e,fieldIndex:t,field:n}=r,i=Pr(),{disableRequiredFields:a}=y.use(nt),[o,s]=y.useState(void 0);y.useEffect(()=>{n.image instanceof Promise?n.image.then(s).catch(console.error):s(n.image)},[n]);const l=y.useCallback(()=>{n.setOptions({image:void 0})},[n]),[u,c]=y.useMemo(()=>{const S=[],O=[],N=Zs(n.type,`${e}.${t}`)??[];for(const T of N)T.showDirectly?S.push(T.field):O.push(T.field);return[S,O]},[n,e,t]),f=Br(u),h=Br(c),p=c.length>0,g=y.useCallback(()=>{o&&i(()=>({file:o}))},[i,o]),x=y.useCallback(S=>{n.setOptions({required:!!S})},[n]),m=y.useCallback(S=>{n.setOptions({label:S.target.value})},[n]),w=y.useCallback(S=>{n.setOptions({description:S.target.value})},[n]),{icon:A,name:E}=ue[n.type];return d.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[d.jsxs("div",{className:"flex w-full justify-between gap-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(v.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[d.jsx(v.LuIcon,{icon:A}),E]}),!a&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(v.Checkbox.Root,{checked:n.required,onCheckedChange:x,size:"sm",children:d.jsx(v.Checkbox.Indicator,{children:d.jsx(v.LuIcon,{icon:ke})})}),d.jsx(v.Text,{size:"sm",accentColor:"base",children:"Required"})]})]}),p&&d.jsx(Ks,{popoverInputs:h,align:"end"})]}),o&&d.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[d.jsx(Bt,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:o,onClick:g}),d.jsx(v.IconButton,{type:"button",className:"group-hover:not-disabled:flex absolute right-2 top-2 hidden",variant:"solid",accentColor:"base","aria-label":"delete",onClick:l,size:"sm",children:d.jsx(v.LuIcon,{icon:gt})})]}),d.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[d.jsx(v.Input.Root,{variant:"outline",size:"md",children:d.jsx(v.Input.Field,{placeholder:"Enter your question",value:n.label??"",onChange:m,maxLength:200})}),d.jsx(v.TextArea,{className:"field-sizing-content",placeholder:"Enter a field description (optional)",value:n.description??"",onChange:w,maxLength:1e3,resize:"vertical",size:"md"})]}),u.length>0&&d.jsx("div",{className:$e.cx("w-full",hn({size:"sm"})),children:f})]})});Qs.displayName="FieldBuilder";const Yi=y.memo(r=>{const{field:e,fieldSection:t,fieldIndex:n,sectionIndex:i}=r,a=y.useRef(null),o=`fields.${i}.fields`,s=y.useCallback(x=>{t.addField(vn(x),n+1)},[n,t]),l=y.useCallback(()=>{t.addField(e.duplicate(U.v4()))},[e,t]),u=y.useCallback(x=>{const m=x==="up"?i-1:i+1;t.moveField(n,m)},[t,n,i]),c=y.useCallback(x=>{const{files:m}=x.target;if(!m||m.length!==1)return;const w=m.item(0);if(w){if(w.size>Vo){v.toast.error({title:"File upload error",description:`The file ${w.name} exceeded the maximum file size`});return}e.setOptions({image:w})}},[e]),f=y.useCallback(()=>{u("up")},[u]),h=y.useCallback(()=>{u("down")},[u]),p=y.useCallback(()=>{var x;(x=a.current)==null||x.click()},[]),g=y.useCallback(()=>{t.removeField(e)},[e,t]);return d.jsxs(v.Card,{className:"flex w-full items-center justify-between gap-4",size:"sm",children:[d.jsx(Qs,{fieldIndex:n,field:e,parentPath:o}),d.jsxs(v.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[d.jsx(pn,{onSelectFieldType:s,size:"sm",children:d.jsx(v.IconButton,{type:"button",children:d.jsx(v.LuIcon,{icon:Ze})})}),d.jsx(v.IconButton,{type:"button",onClick:f,children:d.jsx(v.LuIcon,{icon:ga})}),d.jsx(v.IconButton,{type:"button",onClick:h,children:d.jsx(v.LuIcon,{icon:va})}),d.jsx(v.IconButton,{type:"button",onClick:l,children:d.jsx(v.LuIcon,{icon:xn})}),d.jsx(v.IconButton,{type:"button",onClick:p,children:d.jsx(v.LuIcon,{icon:ha})}),d.jsx(v.IconButton,{type:"button",onClick:g,children:d.jsx(v.LuIcon,{icon:gt})})]}),d.jsx("input",{className:"hidden",ref:a,type:"file",accept:"image/*",onChange:c})]})});Yi.displayName="FieldBuilderWithActions";const Zi=y.memo(r=>{const{children:e,variant:t,size:n,accentColor:i,fields:a,onSelectField:o,...s}=r;return d.jsxs(v.Menu.Root,{...s,children:[d.jsx(v.Menu.ClickTrigger,{children:e}),d.jsx(v.Menu.Content,{variant:t,size:n,accentColor:i,children:d.jsx(v.Menu.Scroll,{children:a.map(l=>d.jsx(Js,{field:l,onSelectField:o},l.identifier))})})]})});Zi.displayName="FieldDropdownMenu";const Js=y.memo(r=>{const{field:e,onSelectField:t}=r,n=y.useCallback(()=>{t(e)},[e,t]);return d.jsxs(v.Menu.Item,{onSelect:n,children:[d.jsx(v.LuIcon,{icon:ue[e.type].icon}),e.label||Ce]})});Js.displayName="FieldDropdownMenuItem";const el=y.memo(r=>{const{children:e,variant:t,size:n,accentColor:i,fieldSections:a,onSelectFieldSection:o,...s}=r;return d.jsxs(v.Menu.Root,{...s,children:[d.jsx(v.Menu.ClickTrigger,{children:e}),d.jsx(v.Menu.Content,{variant:t,size:n,accentColor:i,children:a.map(l=>d.jsx(tl,{fieldSection:l,onSelectFieldSection:o},l.identifier))})]})});el.displayName="FieldSectionDropdownMenu";const tl=y.memo(r=>{const{fieldSection:e,onSelectFieldSection:t}=r,n=y.useCallback(()=>{t(e)},[e,t]);return d.jsxs(v.Menu.Item,{onSelect:n,children:[d.jsx(v.LuIcon,{icon:pa}),e.label||bi]})});tl.displayName="FieldSectionDropdownMenuItem";const rl=y.memo(r=>{const{id:e,sourceX:t,sourceY:n,targetX:i,targetY:a,style:o,markerEnd:s,data:l}=r,{targetSection:u,sourceSection:c,layoutDirection:f}=l,h=y.useMemo(()=>c.getConditions(u.identifier),[c,u.identifier]),p=y.useCallback(()=>{c.removeConditional(u.identifier)},[c,u.identifier]),g=y.useCallback(E=>{c.addCondition(u.identifier,ji(E))},[c,u.identifier]),x=y.useCallback(E=>{c.removeCondition(u.identifier,E)},[c,u.identifier]),[m,w,A]=le.getBezierPath({sourceX:t,sourceY:n,sourcePosition:f==="LR"?le.Position.Right:le.Position.Bottom,targetX:i,targetY:a,targetPosition:f==="LR"?le.Position.Left:le.Position.Top});return d.jsxs(d.Fragment,{children:[d.jsx(le.BaseEdge,{id:e,path:m,style:o,markerEnd:s,labelX:w,labelY:A}),d.jsx(le.EdgeLabelRenderer,{children:d.jsxs(v.Card,{size:"xs",variant:"surface",className:"nodrag nopan bg-(--base-2) pointer-events-auto absolute inline-flex flex-col gap-2",onMouseDown:v.stopPropagation,onClick:v.stopPropagation,"data-floating-content":"",style:{transform:`translate(-50%, -50%) translate(${w}px, ${A}px)`},children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(v.Text,{size:"xs",className:"max-w-[280px] truncate",children:c.label||"Untitled section"}),d.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[d.jsx(Zi,{fields:c.fields,onSelectField:g,children:d.jsx(v.IconButton,{"aria-label":"Add condition",type:"button",variant:"surface",size:"xs",accentColor:"base",children:d.jsx(v.LuIcon,{icon:Ze})})}),d.jsxs(v.Tooltip.Root,{children:[d.jsx(v.Tooltip.Trigger,{asChild:!0,children:d.jsx(v.IconButton,{"aria-label":"Remove conditional logic",type:"button",variant:"surface",size:"xs",accentColor:"base",color:"danger",onClick:p,children:d.jsx(v.LuIcon,{icon:gt})})}),d.jsx(v.Tooltip.Content,{size:"sm",children:"Remove conditional logic"})]})]})]}),h.length>0&&d.jsx("div",{className:"flex h-max w-full flex-col flex-wrap gap-1",children:h.map(E=>d.jsx(y.Fragment,{children:E.render({onRemove:x})},E.id))})]})})]})});rl.displayName="FieldSectionConditionEdgeComponent";const nl=y.memo(r=>{const{data:e,selected:t}=r,{fieldSection:n,index:i,layoutDirection:a}=e,{fieldSchema:o}=y.use(nt),s=y.useCallback(()=>{o.removeFieldSection(n)},[o,n]),l=y.useCallback(p=>{n.addField(vn(p))},[n]),u=y.useCallback(()=>{const p=new qe({identifier:U.v4(),fields:[]});o.addFieldSection(p),n.addConditional(p.identifier)},[o,n]),c=y.useCallback(()=>{o.addFieldSection(n.duplicate(U.v4()))},[o,n]),f=y.useCallback(p=>{n.setOptions({label:p.target.value})},[n]),h=y.useCallback(p=>{n.setOptions({description:p.target.value})},[n]);return d.jsxs(v.Card,{variant:"surface",className:"bg-(--base-2) relative cursor-pointer",size:"sm","data-selected":t?"true":void 0,children:[d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[d.jsx(v.Input.Root,{variant:"outline",size:"md",accentColor:"base",children:d.jsx(v.Input.Field,{placeholder:"Enter a section label (optional)",value:n.label??"",onChange:f,maxLength:200})}),d.jsx(v.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:n.description??"",onChange:h,maxLength:1e3,resize:"vertical",size:"md"})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(v.Text,{weight:"bold",children:"Fields"}),d.jsx(pn,{onSelectFieldType:l,size:"sm",children:d.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:Ze})," Add field"]})})]}),d.jsx("div",{className:"flex flex-col gap-3",children:n.fields.map((p,g)=>d.jsx(Yi,{field:p,fieldSection:n,fieldIndex:g,sectionIndex:i},p.identifier))})]}),d.jsx(le.NodeToolbar,{isVisible:!0,position:le.Position.Right,align:"start",offset:8,onMouseDown:v.stopPropagation,children:d.jsx(v.Card,{variant:"surface",className:"bg-(--base-2) flex flex-col items-center gap-1 p-1",size:"xs",onClick:v.stopPropagation,children:d.jsxs(v.ButtonGroup,{className:"flex flex-col gap-2",variant:"surface",size:"xs",accentColor:"base",children:[d.jsx(v.IconButton,{type:"button",onClick:u,children:d.jsx(v.LuIcon,{icon:Vl})}),d.jsx(v.IconButton,{type:"button",onClick:c,children:d.jsx(v.LuIcon,{icon:xn})}),d.jsx(v.IconButton,{type:"button",onClick:s,children:d.jsx(v.LuIcon,{icon:gt})})]})})}),d.jsx(le.Handle,{type:"target",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:a==="LR"?le.Position.Left:le.Position.Top}),d.jsx(le.Handle,{type:"source",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:a==="LR"?le.Position.Right:le.Position.Bottom})]})});nl.displayName="CustomNode";const jf={fieldSection:nl},Yf={fieldSectionCondition:rl},Zf=(r,e,t)=>{const n=new na.graphlib.Graph().setDefaultEdgeLabel(()=>({}));return n.setGraph({rankdir:t,nodesep:200,edgesep:500,ranksep:500}),e.forEach(i=>n.setEdge(i.source,i.target,{width:500,height:200,labelpos:"c"})),r.forEach(i=>{var a,o;return n.setNode(i.id,{...i,width:((a=i.measured)==null?void 0:a.width)??0,height:((o=i.measured)==null?void 0:o.height)??0})}),na.layout(n),[r.map(i=>{var l,u;const a=n.node(i.id),o=a.x-(((l=i.measured)==null?void 0:l.width)??0)/2,s=a.y-(((u=i.measured)==null?void 0:u.height)??0)/2;return{...i,position:{x:o,y:s}}}),e]},Kf={hideAttribution:!0},il=y.memo(()=>{var z;const{errors:r}=Ye.useFormState(),{handleSubmit:e}=Ye.useFormContext(),{onSave:t,onCancel:n}=y.use(nt),{fieldSchema:i}=y.use(nt),a=y.useRef(null),[o,s]=y.useState(),[l,u]=y.useState("TB");y.useLayoutEffect(()=>{a.current&&a.current.classList.remove("light")},[]);const c=y.useMemo(()=>i.fieldSections.map((K,G)=>({id:K.identifier,position:{x:0,y:0},data:{index:G,fieldSection:K,layoutDirection:l},draggable:!0,type:"fieldSection"})),[i.fieldSections,l]),f=y.useMemo(()=>{const K=[],G={};for(const Y of i.fieldSections)G[Y.identifier]=Y;for(const Y of i.fieldSections){const Me=Y.conditions;for(const[He,Dr]of Object.entries(Me))K.push({id:`${Y.identifier}-${He}`,source:Y.identifier,target:He,data:{targetSection:G[He],sourceSection:Y,layoutDirection:l},animated:Dr.length>0,markerEnd:le.MarkerType.Arrow,style:{strokeWidth:2,stroke:"var(--base-a8)"},type:"fieldSectionCondition"})}return K},[i.fieldSections,l]),[h,p,g]=le.useNodesState(c),[x,m,w]=le.useEdgesState(f);y.useEffect(()=>{p(c)},[c,p]),y.useEffect(()=>{m(f)},[f,m]);const[A,E]=y.useMemo(()=>Zf(h,x,l),[x,l,h]),S=y.useCallback(()=>{i.addFieldSection(new qe({identifier:U.v4(),fields:[]}))},[i]),O=y.useCallback(K=>{const{source:G,target:Y}=K,Me=i.fieldSections.find(({identifier:He})=>He===G);Me.setOptions({conditions:{...Me.conditions,[Y]:[]}})},[i.fieldSections]),N=y.useCallback(K=>{const G=i.getSectionDependencyGraph();return!ea.willCreateCycle(G,K.source,K.target)},[i]),T=y.useCallback(()=>{o==null||o.zoomOut()},[o]),V=y.useCallback(()=>{o==null||o.zoomIn()},[o]),L=y.useCallback(()=>{o==null||o.fitView()},[o]);return d.jsxs("form",{className:"flex size-full flex-col gap-4",onSubmit:e(t),children:[d.jsxs(v.Card,{className:"relative size-full",variant:"outline",children:[d.jsx(le.ReactFlow,{ref:a,onInit:s,nodes:A,onNodesChange:g,edges:E,onEdgesChange:w,nodeTypes:jf,edgeTypes:Yf,onConnect:O,attributionPosition:"bottom-left",fitView:!0,minZoom:0,isValidConnection:N,proOptions:Kf}),d.jsx(le.Panel,{position:"top-left",children:d.jsx(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:d.jsxs(v.Button,{type:"button",variant:"surface",onClick:S,children:[d.jsx(v.LuIcon,{icon:Ze})," Add section"]})})}),d.jsxs(le.Panel,{position:"top-right",className:"flex flex-col items-center gap-2",children:[d.jsxs(v.ToggleGroup.Root,{className:"flex flex-col",type:"single",accentColor:"base",size:"sm",value:l,onValueChange:u,children:[d.jsx(v.ToggleGroup.IconItem,{className:"rounded-b-none",value:"LR",type:"button",children:d.jsx(v.LuIcon,{icon:Al})}),d.jsx(v.ToggleGroup.IconItem,{className:"rounded-t-none",value:"TB",type:"button",children:d.jsx(v.LuIcon,{icon:_l})})]}),d.jsx(v.Separator,{size:"sm"}),d.jsxs(v.ButtonGroup,{className:"flex flex-col",size:"sm",accentColor:"base",variant:"soft",children:[d.jsx(v.IconButton,{className:"rounded-b-none",onClick:V,type:"button",children:d.jsx(v.LuIcon,{icon:Ze})}),d.jsx(v.IconButton,{onClick:T,radius:"none",type:"button",children:d.jsx(v.LuIcon,{icon:Vr})}),d.jsx(v.IconButton,{className:"rounded-t-none",onClick:L,type:"button",children:d.jsx(v.LuIcon,{icon:$l})})]})]}),d.jsx(le.Panel,{position:"bottom-right",children:d.jsxs(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[n&&d.jsx(v.Button,{type:"button",variant:"soft",accentColor:"base",onClick:n,children:"Cancel"}),d.jsx(v.Button,{type:"submit",variant:"surface",children:"Save"})]})})]}),!!((z=r.fields)!=null&&z.message)&&d.jsx(v.Text,{size:"xs",accentColor:"danger",children:r.fields.message})]})});il.displayName="FormBuilderFlowBuilder";const Qf=(r,e,t={})=>{const{conditions:n=!1}=t,i=r.get(e.identifier);if(!i)throw new Error(`Attempting to reseed serialized section with identifier ${e.identifier} which is not present in the reseeded identifier map`);const a=new Map,o=e.fields.map(l=>{const u=U.v4(),{image:c,...f}=l;return a.set(l.identifier,u),{...f,identifier:u}}),s={};if(n)for(const[l,u]of Object.entries(e.conditions??{})){const c=r.get(l);if(!c)continue;const f=u.map(h=>{const p=a.get(h.fieldId);if(!p)throw new Error(`Serialized condition referencing undefined field with identifier: ${h.fieldId}`);return{...h,fieldId:p}});s[c]=f}return{...e,identifier:i,conditions:s,fields:o}},Jf=(r,e={})=>{const t=new Map(r.map(n=>[n.identifier,U.v4()]));return r.map(n=>Qf(t,n,e))},Ki=(r,e)=>{const t={},n=r.filter(i=>i instanceof qe);for(const i of r)if(i instanceof qe){const a=n.filter(s=>i.identifier in s.conditions);if(a.length>0&&!a.some(s=>{const l=s.getConditions(i.identifier);return new cn(l).applyConditions(e)}))continue;const o=i.getErrors(e);Object.assign(t,o)}else{if(!(i instanceof Ve))throw new Error("Invalid field type");const a=i.identifier,o=i.getError(ia(e,a));o&&vl(t,a,o)}return t},e1=async r=>{const e={},t=[];for(const n of r){const{fields:i}=n,a=[];for(const o of i){if(o.image){if(o.image instanceof Promise)try{e[o.identifier]=await o.image}catch(s){console.error("Failed to get image from promise",s)}else e[o.identifier]=o.image;delete o.image}a.push(o)}t.push({...n,fields:a})}return{fields:t,images:e}};async function t1(r){const e={};for(const[t,n]of Object.entries(r))e[t]=await Promise.all(n);return e}class Pt extends er{constructor(t){super();M(this,"fieldSections");M(this,"fieldObserver",()=>{this.notify(this)});M(this,"initFields",t=>{for(const n of t)n.observe(this.fieldObserver);return t});this.fieldSections=this.initFields(t)}serialize(){return this.fieldSections.map(t=>t.serialize())}static deserialize(t){return new Pt(t.map(qe.deserialize))}static reseedFieldSections(t,n){return Jf(t,n)}getFields(){return this.fieldSections.flatMap(t=>t.getFields())}getFieldSections(){return this.fieldSections}addFieldSection(t,n){const i=[...this.fieldSections];i.splice(n??this.fieldSections.length,0,t),this.fieldSections=this.initFields(i),this.notify(this)}removeFieldSection(t){const n=this.fieldSections.filter(i=>i.identifier!==t.identifier);for(const i of n)i.removeConditional(i.identifier);this.fieldSections=this.initFields(n),this.notify(this)}moveFieldSection(t,n){const i=[...this.fieldSections],[a]=i.splice(t,1);i.splice(n,0,a),this.fieldSections=this.initFields(i),this.notify(this)}getSectionDependencyGraph(){const t=new hl.DirectedGraph({type:"directed"});for(const n of this.fieldSections)for(const i of Object.keys(n.conditions))t.mergeEdge(n.identifier,i);return t}getDependenciesOfSection(t){const n=this.getSectionDependencyGraph(),i=new Map(this.fieldSections.map(o=>[o.identifier,o])),a=[];return pl.bfsFromNode(n,t,(o,s,l)=>{a.push(i.get(o))},{mode:"in"}),a}cleanValues(t){return fn(this.getFields(),t)}cleanSerializedValues(t){return qi(this.getFields(),t)}deserializeValues(t,n){return Gs(this.getFields(),t,n)}serializeValues(t,n){return Rs(this.getFields(),t,n)}initializeValues(t){return $s(this.getFields(),t)}validateValues(t){return Ki(this.getFieldSections(),t)}areValuesValid(t){return Object.keys(this.validateValues(t)).length===0}deserializeConditions(t){return Ri(this.getFields(),t)}cleanConditions(t){return Hi(this.getFields(),t)}serializeConditions(t){return ks(this.getFields(),t)}cleanSerializedConditions(t){return Gi(this.getFields(),t)}changedFieldValues(t,n){return Xs(this.getFields(),t,n)}unchangedFieldValues(t,n){return Ws(this.getFields(),t,n)}areValuesEqual(t,n){return $i(this.getFields(),t,n)}areValuesBlank(t){return js(this.getFields(),t)}blankValues(){return Xi(this.getFields())}extractFilesAndPromisesFromFieldValues(t){return Hs(this.getFields(),t)}insertFilesAndPromisesToFieldValues(t,n){return qs(this.getFields(),t,n)}}const al=y.memo(r=>{const{sourceFieldSection:e,targetFieldSection:t}=r,n=y.useMemo(()=>e.getConditions(t.identifier),[e,t.identifier]),i=y.useCallback(()=>{e.removeConditional(t.identifier)},[e,t.identifier]),a=y.useCallback(s=>{e.addCondition(t.identifier,ji(s))},[e,t.identifier]),o=y.useCallback(s=>{e.removeCondition(t.identifier,s)},[e,t.identifier]);return d.jsxs(v.Card,{className:"flex flex-col gap-2",size:"sm",children:[d.jsxs(v.ButtonGroup,{className:"flex justify-between gap-2",size:"sm",accentColor:"base",variant:"soft",children:[d.jsxs(v.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[d.jsx(v.LuIcon,{icon:pa}),e.label??bi]}),d.jsx(v.IconButton,{type:"button",onClick:i,variant:"ghost",children:d.jsx(v.LuIcon,{icon:gt})})]}),d.jsxs("div",{className:"flex h-max w-full flex-wrap gap-2",children:[n.map(s=>s.render({onRemove:o})),d.jsx(Zi,{fields:e.fields,onSelectField:a,align:"start",children:d.jsx(v.IconButton,{type:"button",size:"sm",variant:"soft",accentColor:"base",children:d.jsx(v.LuIcon,{icon:Ze})})})]})]})});al.displayName="FieldSectionConditionalItem";const ol=y.memo(r=>{const{fieldSection:e}=r,{fieldSchema:t}=y.use(nt),n=y.useMemo(()=>t.fieldSections.filter(l=>e.identifier in l.conditions),[t.fieldSections,e.identifier]),i=y.useCallback(l=>{l.addConditional(e.identifier)},[e.identifier]),a=y.useCallback(l=>{e.setOptions({label:l.target.value})},[e]),o=y.useCallback(l=>{e.setOptions({description:l.target.value})},[e]),s=y.useMemo(()=>{const l=t.getSectionDependencyGraph();return t.fieldSections.filter(u=>!ea.willCreateCycle(l,u.identifier,e.identifier))},[e.identifier,t]);return d.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[d.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[d.jsx(v.Input.Root,{variant:"outline",size:"md",children:d.jsx(v.Input.Field,{placeholder:"Enter a section label (optional)",value:e.label??"",onChange:a,maxLength:200})}),d.jsx(v.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:e.description??"",onChange:o,maxLength:1e3,resize:"vertical",size:"md"})]}),d.jsx(v.Separator,{size:"full"}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex justify-between gap-2",children:[d.jsx(v.Text,{accentColor:"base",children:"Conditions"}),d.jsx(el,{fieldSections:s,onSelectFieldSection:i,children:d.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",className:"w-max",children:[d.jsx(v.LuIcon,{icon:Ze}),"Add condition"]})})]}),n.map(l=>d.jsx(al,{sourceFieldSection:l,targetFieldSection:e},l.identifier))]}),d.jsx(v.Separator,{size:"full"})]})});ol.displayName="FieldSectionBuilder";const sl=y.memo(r=>{const{fieldSection:e,sectionIndex:t}=r,{fieldSchema:n}=y.use(nt),i=v.useAlertDialog(),a=y.useCallback(()=>{n.removeFieldSection(e)},[n,e]),o=y.useCallback(x=>{const m=x==="up"?t-1:t+1;n.moveFieldSection(t,m)},[n,t]),s=y.useCallback(()=>{n.addFieldSection(e.duplicate(U.v4()))},[n,e]),l=y.useCallback(x=>{e.addField(vn(x))},[e]),u=y.useCallback(()=>{o("up")},[o]),c=y.useCallback(()=>{o("down")},[o]),f=y.useCallback(async()=>{const x=[e.serialize()],m=Pt.reseedFieldSections(x,{conditions:!1}),w=JSON.stringify(m);await navigator.clipboard.writeText(w),v.toast.success({title:"Section copied"})},[e]),h=y.useCallback(async()=>{const m=n.getDependenciesOfSection(e.identifier).map(E=>E.serialize()),w=Pt.reseedFieldSections(m,{conditions:!0}),A=JSON.stringify(w);await navigator.clipboard.writeText(A),v.toast.success({title:"Section copied"})},[e,n]),p=y.useCallback(async()=>{const x=n.getDependenciesOfSection(e.identifier),m=x.length>1,w=x.length-1;m?i({title:"Copy section dependencies?",description:`This section has ${w} dependent section${w>1?"s":""} that will also be copied to maintain the conditions. Do you want to include these dependencies?`,action:"Include",onAction:h,cancel:"Dont include",onCancel:f}):f()},[e,n,i,h,f]),g=y.useCallback(async()=>{let x="";try{x=await navigator.clipboard.readText()}catch{v.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const m=x.trim();if(!m){v.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let w;try{w=JSON.parse(m)}catch{v.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const A=Array.isArray(w)?w:[w],E=[];for(const S of A){if(!S||typeof S!="object")continue;const O=S;if(O.type!=="section"||!Array.isArray(O.fields))continue;const N={type:"section",identifier:typeof O.identifier=="string"?O.identifier:U.v4(),label:typeof O.label=="string"||O.label===null?O.label:null,description:typeof O.description=="string"||O.description===null?O.description:null,conditions:O.conditions&&typeof O.conditions=="object"?O.conditions:{},fields:O.fields};try{E.push(qe.deserialize(N))}catch{}}if(E.length===0){v.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}E.forEach((S,O)=>{n.addFieldSection(S,t+1+O)}),v.toast.success({title:"Section pasted",description:"Serialized JSON imported successfully."})},[n,t]);return d.jsxs(v.Card,{variant:"outline",className:"flex w-full items-center justify-between gap-4",size:"sm",children:[d.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[d.jsx(ol,{fieldSection:e}),d.jsxs("div",{className:"flex w-full flex-col gap-2",children:[d.jsxs("div",{className:"flex justify-between gap-2",children:[d.jsx(v.Text,{accentColor:"base",size:"md",children:"Fields"}),d.jsx(pn,{onSelectFieldType:l,size:"sm",children:d.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",children:[d.jsx(v.LuIcon,{icon:Ze})," Add field"]})})]}),e.fields.map((x,m)=>d.jsx(Yi,{field:x,fieldSection:e,fieldIndex:m,sectionIndex:t},x.identifier))]})]}),d.jsxs(v.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[d.jsx(v.IconButton,{type:"button",onClick:u,children:d.jsx(v.LuIcon,{icon:ga})}),d.jsx(v.IconButton,{type:"button",onClick:c,children:d.jsx(v.LuIcon,{icon:va})}),d.jsxs(v.Menu.Root,{align:"end",children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.IconButton,{type:"button",children:d.jsx(v.LuIcon,{icon:da})})}),d.jsxs(v.Menu.Content,{size:"sm",children:[d.jsxs(v.Menu.Item,{onSelect:s,children:[d.jsx(v.LuIcon,{icon:xn}),"Duplicate section"]}),d.jsxs(v.Menu.Item,{onSelect:p,children:[d.jsx(v.LuIcon,{icon:la}),"Copy JSON"]}),d.jsxs(v.Menu.Item,{onSelect:g,children:[d.jsx(v.LuIcon,{icon:ua}),"Paste JSON"]}),d.jsxs(v.Menu.Item,{onSelect:a,children:[d.jsx(v.LuIcon,{icon:gt}),"Delete section"]})]})]})]})]})});sl.displayName="FieldSectionWithActions";const ll=y.memo(()=>{var l;const{handleSubmit:r}=Ye.useFormContext(),{errors:e}=Ye.useFormState(),{onSave:t,onCancel:n}=y.use(nt),{fieldSchema:i}=y.use(nt),a=y.useCallback(()=>{i.addFieldSection(new qe({identifier:U.v4(),fields:[]}))},[i]),o=y.useCallback(async()=>{try{const u=i.serialize(),c=Pt.reseedFieldSections(u),f=JSON.stringify(c);await navigator.clipboard.writeText(f),v.toast.success({title:"Sections copied",description:"All sections JSON copied to clipboard."})}catch{v.toast.error({title:"Copy failed",description:"Unable to copy the sections JSON."})}},[i]),s=y.useCallback(async()=>{let u="";try{u=await navigator.clipboard.readText()}catch{v.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const c=u.trim();if(!c){v.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let f;try{f=JSON.parse(c)}catch{v.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const h=Array.isArray(f)?f:[f],p=[];for(const x of h){if(!x||typeof x!="object")continue;const m=x;if(m.type!=="section"||!Array.isArray(m.fields))continue;const w={type:"section",identifier:typeof m.identifier=="string"?m.identifier:U.v4(),label:typeof m.label=="string"||m.label===null?m.label:null,description:typeof m.description=="string"||m.description===null?m.description:null,conditions:m.conditions&&typeof m.conditions=="object"?m.conditions:{},fields:m.fields};try{p.push(qe.deserialize(w))}catch{}}if(p.length===0){v.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}const g=i.fieldSections.length;p.forEach((x,m)=>{i.addFieldSection(x,g+m)}),v.toast.success({title:"Sections pasted",description:"Serialized JSON imported successfully."})},[i]);return d.jsxs("form",{className:"flex flex-col gap-4",onSubmit:r(t),children:[d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{className:"flex items-center justify-end gap-2",children:[d.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",onClick:o,children:[d.jsx(v.LuIcon,{icon:la})," Copy JSON"]}),d.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",onClick:s,children:[d.jsx(v.LuIcon,{icon:ua})," Paste JSON"]})]}),i.fieldSections.map((u,c)=>d.jsx(sl,{fieldSection:u,sectionIndex:c},u.identifier)),d.jsxs(v.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:a,children:[d.jsx(v.LuIcon,{icon:Ze})," Add section"]})]}),!!((l=e.fields)!=null&&l.message)&&d.jsx(v.Text,{size:"xs",accentColor:"danger",children:e.fields.message}),d.jsxs(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[n&&d.jsx(v.Button,{type:"button",variant:"soft",accentColor:"base",onClick:n,children:"Cancel"}),d.jsx(v.Button,{type:"submit",variant:"surface",children:"Save"})]})]})});ll.displayName="FormBuilderListBuilder";function ul(r){const e=t=>{const n={};for(const[i,a]of Object.entries(t))typeof a=="string"?n[i]={type:"validate",message:a}:n[i]=e(a);return n};return e(r)}const cl=y.memo(y.forwardRef((r,e)=>{const{disabled:t=!1,fieldSchema:n,values:i={},onValuesChange:a,onSubmit:o,submitText:s="Submit",hideSubmit:l=!1,cancelText:u,onCancel:c,hideCancel:f=!1,className:h,buttonProps:p,size:g="md"}=r,x=y.useMemo(()=>n.initializeValues(i),[n,i]),m=y.useCallback(T=>{o==null||o(T)},[o]),w=Ye.useForm({values:x,mode:"onBlur",criteriaMode:"all",disabled:t,resolver:T=>{const V=n.validateValues(T),L=ul(V);return Object.keys(V).length>0?{values:{},errors:L}:{values:T,errors:{}}}}),A=y.useCallback(T=>{a==null||a(T)},[a]);y.useEffect(()=>{const{unsubscribe:T}=w.watch((V,{type:L})=>{L==="change"&&A(V)});return()=>{T()}},[w,A]);const E=ma(n.getFieldSections()),S=y.useMemo(()=>({fieldSchema:n,size:g}),[n,g]),O=!f&&!!c,N=!l;return d.jsx(Ye.FormProvider,{...w,children:d.jsx(ce,{value:S,children:d.jsxs("form",{ref:e,className:$e.cx(h,"flex flex-col gap-4"),onSubmit:w.handleSubmit(m),children:[d.jsx("div",{className:Wf({size:g}),children:E}),!t&&(O||N)?d.jsxs(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:g,children:[O?d.jsxs(v.Button,{...p,accentColor:"base",type:"button",variant:"soft",onClick:c,children:[d.jsx(v.LuIcon,{icon:at}),u]}):null,N?d.jsxs(v.Button,{...p,type:"submit",accentColor:"primary",variant:"surface",children:[d.jsx(v.LuIcon,{icon:ke}),s]}):null]}):null]})})})})),dl=y.memo(()=>{const{fieldSchema:r}=y.use(nt);return d.jsx(cl,{fieldSchema:r,disabled:!1})});dl.displayName="FormBuilderPreview";const fl=y.memo(r=>{const{children:e,initialFields:t,onSave:n,onCancel:i,disableRequiredFields:a=!1}=r,o=y.useCallback(g=>{var E;const x={};(!g.fields||g.fields.length===0)&&(x.fields="At least one field is required.");const m=[];for(const[S,O]of g.fields.entries())for(const[N,T]of O.fields.entries()){const V=((E=Zs(T.type,`fields.${S}.fields.${N}`))==null?void 0:E.map(({field:L})=>L))??[];m.push(...V)}const w={};for(const S of m)w[S.identifier]=ia(g,S.identifier);const A=Ki(m,w);return Object.keys(A).length>0&&(x.fields=A.fields),Object.keys(x).length>0&&v.toast.error({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),x},[]),s=y.useMemo(()=>({fields:t??[]}),[t]),l=Ye.useForm({values:s,mode:"onSubmit",criteriaMode:"all",reValidateMode:"onSubmit",resolver:g=>{const x=o(g),m=ul(x);return Object.keys(x).length>0?{values:{},errors:m}:{values:g,errors:{}}}}),u=y.useCallback(g=>{l.setValue("fields",g.serialize())},[l]),c=Ye.useWatch({control:l.control,compute:g=>g.fields}),f=y.useMemo(()=>{const g=Pt.deserialize(c);return g.observe(u),g},[c,u]),h=y.useMemo(()=>({fieldSchema:f,disableRequiredFields:a,onSave:n,onCancel:i}),[a,n,i,f]),p=y.useMemo(()=>({fieldSchema:f,size:"sm"}),[f]);return d.jsx(nt,{value:h,children:d.jsx(ce,{value:p,children:d.jsx(Ye.FormProvider,{...l,children:e})})})});fl.displayName="FormBuilderRoot";const r1={Root:fl,FlowBuilder:il,ListBuilder:ll,Preview:dl};_.BaseCondition=Ee,_.BaseField=Ve,_.BaseFormElement=mn,_.BaseOptionsField=tr,_.BaseStringField=In,_.BooleanEqualsConditionModifier=Po,_.BooleanField=yt,_.BooleanFieldCondition=pr,_.BooleanFieldConditionCell=is,_.BooleanFieldInput=Sn,_.BooleanNotEqualsConditionModifier=Bo,_.CheckboxListField=Ct,_.CheckboxListFieldCondition=vr,_.CheckboxListFieldConditionCell=os,_.CheckboxListFieldInput=On,_.ConditionManager=cn,_.DateAfterConditionModifier=Uo,_.DateBeforeConditionModifier=ko,_.DateEqualsConditionModifier=Lo,_.DateField=Lt,_.DateFieldCondition=gr,_.DateFieldConditionCell=ls,_.DateFieldInput=bn,_.DateNotEqualsConditionModifier=zo,_.DateRangeInConditionModifier=Ro,_.DateRangeNotInConditionModifier=Go,_.DoesNotHaveFilesConditionModifier=qo,_.FIELD_TYPES=Mo,_.FieldSchema=Pt,_.FieldSection=qe,_.FieldSectionLayout=Wi,_.FieldTypeGroup=W,_.FieldTypeToClsMapping=Oi,_.FieldsRenderer=cl,_.FileCard=Cn,_.FormBuilder=r1,_.HasFilesConditionModifier=Ho,_.ImageCard=Dn,_.ImageFile=Bt,_.ImageViewer=_n,_.ImageViewerProvider=Ca,_.InputWithLabel=de,_.LONG_TEXT_FIELD_MAX_LENGTH=rr,_.MultiSelectField=it,_.MultiSelectFieldCondition=xr,_.MultiSelectFieldConditionCell=cs,_.MultiSelectFieldInput=Nn,_.MultiStringField=xt,_.MultiStringFieldCondition=yr,_.MultiStringFieldConditionCell=fs,_.MultiStringFieldInput=An,_.NumberEqualsConditionModifier=Ni,_.NumberField=Pe,_.NumberFieldCondition=Cr,_.NumberFieldConditionCell=ps,_.NumberFieldInput=En,_.NumberGreaterThanConditionModifier=Fi,_.NumberGreaterThanOrEqualsConditionModifier=Vi,_.NumberLessThanConditionModifier=Mi,_.NumberLessThanOrEqualsConditionModifier=Di,_.NumberNotEqualsConditionModifier=Ti,_.NumberRangeInConditionModifier=Pi,_.NumberRangeNotInConditionModifier=Bi,_.OTPField=mt,_.OTPFieldCondition=mr,_.OTPFieldConditionCell=gs,_.OTPFieldInput=Mn,_.Observable=er,_.PassFailArrayExcludesConditionModifier=jo,_.PassFailArrayIncludesConditionModifier=Wo,_.PassFailEqualsConditionModifier=$o,_.PassFailField=_t,_.PassFailFieldCondition=wr,_.PassFailFieldConditionCell=ys,_.PassFailFieldInput=Bn,_.PassFailNotEqualsConditionModifier=Xo,_.RadioField=At,_.RadioFieldCondition=_r,_.RadioFieldConditionCell=ms,_.RadioFieldInput=zn,_.RatingField=St,_.RatingFieldCondition=Ar,_.RatingFieldConditionCell=_s,_.RatingFieldInput=kn,_.SHORT_TEXT_FIELD_MAX_LENGTH=yi,_.ScanField=$t,_.ScanFieldCondition=Sr,_.ScanFieldConditionCell=Ss,_.ScanFieldInput=xi,_.Scanner=Kr,_.ScannerProvider=Io,_.SelectField=ot,_.SelectFieldCondition=Er,_.SelectFieldConditionCell=Is,_.SelectFieldInput=Tn,_.StringArrayEqualsConditionModifier=on,_.StringArrayEveryConditionModifier=rn,_.StringArrayExcludesConditionModifier=zi,_.StringArrayIncludesConditionModifier=Li,_.StringArrayNoneConditionModifier=an,_.StringArrayNotEqualsConditionModifier=sn,_.StringArraySomeConditionModifier=nn,_.StringEqualsConditionModifier=pt,_.StringExcludesConditionModifier=Zt,_.StringField=Tt,_.StringFieldCondition=Ir,_.StringFieldConditionCell=bs,_.StringFieldInput=Ci,_.StringIncludesConditionModifier=Yt,_.StringNotEqualsConditionModifier=vt,_.TextField=Mt,_.TextFieldCondition=Or,_.TextFieldConditionCell=Ts,_.TextFieldInput=mi,_.TimeAfterConditionModifier=Qo,_.TimeBeforeConditionModifier=Ko,_.TimeEqualsConditionModifier=Yo,_.TimeField=Xt,_.TimeFieldCondition=br,_.TimeFieldConditionCell=Ds,_.TimeFieldControl=tn,_.TimeFieldInput=Si,_.TimeNotEqualsConditionModifier=Zo,_.TimeRangeInConditionModifier=Jo,_.TimeRangeNotInConditionModifier=es,_.UNLABELLED_FIELD_LABEL=Ce,_.UNLABELLED_SECTION_LABEL=bi,_.URLField=Wt,_.URLFieldCondition=Tr,_.URLFieldConditionCell=Bs,_.URLFieldInput=Ii,_.UTC_OFFSETS=wi,_.UTC_OFFSETS_SET=Oo,_.UUIDFile=st,_.UUIDPromise=kt,_.UploadField=Dt,_.UploadFieldCondition=Nr,_.UploadFieldConditionCell=Vs,_.UploadFieldInput=Ei,_.VideoCard=Vn,_.VideoFile=Fn,_.areFieldValuesBlank=js,_.areFieldValuesEqual=$i,_.areFileAndPromiseArraysEqual=Lr,_.arePassFieldValuesEqual=Ia,_.areSerializedPassFailFieldValuesEqual=Oa,_.awaitFilesAndPromises=t1,_.blankFieldValues=Xi,_.changedFieldValues=Xs,_.cleanConditions=Hi,_.cleanFieldValues=fn,_.cleanSerializedConditions=Gi,_.cleanSerializedFieldValues=qi,_.createCondition=ji,_.createConditionModifierConfig=F,_.createField=vn,_.createTime=_i,_.deserialize=Us,_.deserializeCondition=zs,_.deserializeConditions=Ri,_.deserializeField=dn,_.deserializeFieldValues=Gs,_.deserializeFields=Hf,_.deserializeOnlyFields=qf,_.deserializePassFailFieldValue=Ea,_.extractFilesAndPromisesFromFieldValues=Hs,_.fieldDataMapping=ue,_.fieldSpacingCva=hn,_.fieldTypeGroupDataMapping=Do,_.flattenFields=$f,_.formatTime=en,_.formatUTCOffset=Jr,_.getCurrentUTCOffset=No,_.getFieldsMapping=Xf,_.getUTCMinuteOfDay=ht,_.getUTCOffsetMinutes=To,_.initializeFieldValues=$s,_.insertFilesAndPromisesToFieldValues=qs,_.isFileAndPromiseArray=wa,_.isPassFailFieldStatus=Ln,_.isPassFailFieldValue=Aa,_.isSerializedPassFailFieldValue=_a,_.isStringArray=Jt,_.isTime=ye,_.isTimeInRange=Ai,_.isTimeRange=fr,_.isUTCOffset=Qr,_.maxFileSizeB=Vo,_.maxFileSizeKB=Fo,_.maxFileSizeMB=jt,_.parseTime=dr,_.passFailFieldStatusMapping=wt,_.passFailFieldStatuses=zt,_.separateImagesFromFields=e1,_.serializeConditions=ks,_.serializeFieldValues=Rs,_.serializePassFailFieldValue=Sa,_.unchangedFieldValues=Ws,_.useConditionManager=Rf,_.useFieldInput=me,_.useFieldInputs=Br,_.useFieldSectionInputs=ma,_.useImageViewer=Pr,_.useObjectUrl=wn,_.useScanner=Zl,_.validateFieldValues=Ki,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
|
275
|
+
`),n=_o.singletonList(Ff.INITIAL_STATE),i=0;i<this.text.length;i++){var a=void 0,o=i+1<this.text.length?this.text[i+1]:0;switch(this.text[i]){case X.getCharCode("\r"):a=o===t?2:0;break;case X.getCharCode("."):a=o===e?3:0;break;case X.getCharCode(","):a=o===e?4:0;break;case X.getCharCode(":"):a=o===e?5:0;break;default:a=0}a>0?(n=r.updateStateListForPair(n,i,a),i++):n=this.updateStateListForChar(n,i)}var s=_o.min(n,function(l,u){return l.getBitCount()-u.getBitCount()});return s.toBitArray(this.text)},r.prototype.updateStateListForChar=function(e,t){var n,i,a=[];try{for(var o=Zr(e),s=o.next();!s.done;s=o.next()){var l=s.value;this.updateStateForChar(l,t,a)}}catch(u){n={error:u}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return r.simplifyStates(a)},r.prototype.updateStateForChar=function(e,t,n){for(var i=this.text[t]&255,a=gi[e.getMode()][i]>0,o=null,s=0;s<=rt;s++){var l=gi[s][i];if(l>0){if(o==null&&(o=e.endBinaryShift(t)),!a||s===e.getMode()||s===je){var u=o.latchAndAppend(s,l);n.push(u)}if(!a&&So[e.getMode()][s]>=0){var c=o.shiftAndAppend(s,l);n.push(c)}}}if(e.getBinaryShiftByteCount()>0||gi[e.getMode()][i]===0){var f=e.addBinaryShiftChar(t);n.push(f)}},r.updateStateListForPair=function(e,t,n){var i,a,o=[];try{for(var s=Zr(e),l=s.next();!l.done;l=s.next()){var u=l.value;this.updateStateForPair(u,t,n,o)}}catch(c){i={error:c}}finally{try{l&&!l.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}return this.simplifyStates(o)},r.updateStateForPair=function(e,t,n,i){var a=e.endBinaryShift(t);if(i.push(a.latchAndAppend(rt,n)),e.getMode()!==rt&&i.push(a.shiftAndAppend(rt,n)),n===3||n===4){var o=a.latchAndAppend(je,16-n).latchAndAppend(je,1);i.push(o)}if(e.getBinaryShiftByteCount()>0){var s=e.addBinaryShiftChar(t).addBinaryShiftChar(t+1);i.push(s)}},r.simplifyStates=function(e){var t,n,i,a,o=[];try{for(var s=Zr(e),l=s.next();!l.done;l=s.next()){var u=l.value,c=!0,f=function(m){if(m.isBetterThanOrEqualTo(u))return c=!1,"break";u.isBetterThanOrEqualTo(m)&&(o=o.filter(function(w){return w!==m}))};try{for(var h=(i=void 0,Zr(o)),p=h.next();!p.done;p=h.next()){var g=p.value,x=f(g);if(x==="break")break}}catch(m){i={error:m}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}c&&o.push(u)}}catch(m){t={error:m}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},r}(),Bf=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};(function(){function r(){}return r.encodeBytes=function(e){return r.encode(e,r.DEFAULT_EC_PERCENT,r.DEFAULT_AZTEC_LAYERS)},r.encode=function(e,t,n){var i=new Pf(e).encode(),a=$.truncDivision(i.getSize()*t,100)+11,o=i.getSize()+a,s,l,u,c,f;if(n!==r.DEFAULT_AZTEC_LAYERS){if(s=n<0,l=Math.abs(n),l>(s?r.MAX_NB_BITS_COMPACT:r.MAX_NB_BITS))throw new k(X.format("Illegal value %s for layers",n));u=r.totalBitsInLayer(l,s),c=r.WORD_SIZE[l];var h=u-u%c;if(f=r.stuffBits(i,c),f.getSize()+a>h)throw new k("Data to large for user specified layer");if(s&&f.getSize()>c*64)throw new k("Data to large for user specified layer")}else{c=0,f=null;for(var p=0;;p++){if(p>r.MAX_NB_BITS)throw new k("Data too large for an Aztec code");if(s=p<=3,l=s?p+1:p,u=r.totalBitsInLayer(l,s),!(o>u)){(f==null||c!==r.WORD_SIZE[l])&&(c=r.WORD_SIZE[l],f=r.stuffBits(i,c));var h=u-u%c;if(!(s&&f.getSize()>c*64)&&f.getSize()+a<=h)break}}}var g=r.generateCheckWords(f,u,c),x=f.getSize()/c,m=r.generateModeMessage(s,l,x),w=(s?11:14)+l*4,A=new Int32Array(w),E;if(s){E=w;for(var p=0;p<A.length;p++)A[p]=p}else{E=w+1+2*$.truncDivision($.truncDivision(w,2)-1,15);for(var S=$.truncDivision(w,2),O=$.truncDivision(E,2),p=0;p<S;p++){var N=p+$.truncDivision(p,15);A[S-p-1]=O-N-1,A[S+p]=O+N+1}}for(var T=new tt(E),p=0,V=0;p<l;p++){for(var L=(l-p)*4+(s?9:12),z=0;z<L;z++)for(var K=z*2,G=0;G<2;G++)g.get(V+K+G)&&T.set(A[p*2+G],A[p*2+z]),g.get(V+L*2+K+G)&&T.set(A[p*2+z],A[w-1-p*2-G]),g.get(V+L*4+K+G)&&T.set(A[w-1-p*2-G],A[w-1-p*2-z]),g.get(V+L*6+K+G)&&T.set(A[w-1-p*2-z],A[p*2+G]);V+=L*8}if(r.drawModeMessage(T,s,E,m),s)r.drawBullsEye(T,$.truncDivision(E,2),5);else{r.drawBullsEye(T,$.truncDivision(E,2),7);for(var p=0,z=0;p<$.truncDivision(w,2)-1;p+=15,z+=16)for(var G=$.truncDivision(E,2)&1;G<E;G+=2)T.set($.truncDivision(E,2)-z,G),T.set($.truncDivision(E,2)+z,G),T.set(G,$.truncDivision(E,2)-z),T.set(G,$.truncDivision(E,2)+z)}var Y=new _f;return Y.setCompact(s),Y.setSize(E),Y.setLayers(l),Y.setCodeWords(x),Y.setMatrix(T),Y},r.drawBullsEye=function(e,t,n){for(var i=0;i<n;i+=2)for(var a=t-i;a<=t+i;a++)e.set(a,t-i),e.set(a,t+i),e.set(t-i,a),e.set(t+i,a);e.set(t-n,t-n),e.set(t-n+1,t-n),e.set(t-n,t-n+1),e.set(t+n,t-n),e.set(t+n,t-n+1),e.set(t+n,t+n-1)},r.generateModeMessage=function(e,t,n){var i=new _e;return e?(i.appendBits(t-1,2),i.appendBits(n-1,6),i=r.generateCheckWords(i,28,4)):(i.appendBits(t-1,5),i.appendBits(n-1,11),i=r.generateCheckWords(i,40,4)),i},r.drawModeMessage=function(e,t,n,i){var a=$.truncDivision(n,2);if(t)for(var o=0;o<7;o++){var s=a-3+o;i.get(o)&&e.set(s,a-5),i.get(o+7)&&e.set(a+5,s),i.get(20-o)&&e.set(s,a+5),i.get(27-o)&&e.set(a-5,s)}else for(var o=0;o<10;o++){var s=a-5+o+$.truncDivision(o,5);i.get(o)&&e.set(s,a-7),i.get(o+10)&&e.set(a+7,s),i.get(29-o)&&e.set(s,a+7),i.get(39-o)&&e.set(a-7,s)}},r.generateCheckWords=function(e,t,n){var i,a,o=e.getSize()/n,s=new uo(r.getGF(n)),l=$.truncDivision(t,n),u=r.bitsToWords(e,n,l);s.encode(u,l-o);var c=t%n,f=new _e;f.appendBits(0,c);try{for(var h=Bf(Array.from(u)),p=h.next();!p.done;p=h.next()){var g=p.value;f.appendBits(g,n)}}catch(x){i={error:x}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(i)throw i.error}}return f},r.bitsToWords=function(e,t,n){var i=new Int32Array(n),a,o;for(a=0,o=e.getSize()/t;a<o;a++){for(var s=0,l=0;l<t;l++)s|=e.get(a*t+l)?1<<t-l-1:0;i[a]=s}return i},r.getGF=function(e){switch(e){case 4:return Re.AZTEC_PARAM;case 6:return Re.AZTEC_DATA_6;case 8:return Re.AZTEC_DATA_8;case 10:return Re.AZTEC_DATA_10;case 12:return Re.AZTEC_DATA_12;default:throw new k("Unsupported word size "+e)}},r.stuffBits=function(e,t){for(var n=new _e,i=e.getSize(),a=(1<<t)-2,o=0;o<i;o+=t){for(var s=0,l=0;l<t;l++)(o+l>=i||e.get(o+l))&&(s|=1<<t-1-l);(s&a)===a?(n.appendBits(s&a,t),o--):(s&a)===0?(n.appendBits(s|1,t),o--):n.appendBits(s,t)}return n},r.totalBitsInLayer=function(e,t){return((t?88:112)+16*e)*e},r.DEFAULT_EC_PERCENT=33,r.DEFAULT_AZTEC_LAYERS=0,r.MAX_NB_BITS=32,r.MAX_NB_BITS_COMPACT=4,r.WORD_SIZE=Int32Array.from([4,6,6,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12]),r})();const Lf=new Map([[ra.DecodeHintType.POSSIBLE_FORMATS,[P.AZTEC,P.CODABAR,P.CODE_39,P.CODE_93,P.CODE_128,P.DATA_MATRIX,P.EAN_8,P.EAN_13,P.ITF,P.MAXICODE,P.PDF_417,P.QR_CODE,P.RSS_14,P.RSS_EXPANDED,P.UPC_A,P.UPC_E,P.UPC_EAN_EXTENSION]]]),Kr=y.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,...o}=r;return d.jsxs(v.Overlay.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[!!e&&d.jsx(v.Overlay.Trigger,{asChild:!0,children:e}),d.jsxs(v.Overlay.Content,{children:[d.jsx(v.Overlay.Title,{className:"sr-only",children:"Scanner"}),d.jsx(v.Overlay.Description,{className:"sr-only",children:"Scan a barcode or a qr code."}),d.jsx(Eo,{...o})]})]})});Kr.displayName="Scanner";const Eo=y.memo(r=>{const{paused:e,timeBetweenDecodingAttempts:t,onDecodeResult:n,onDecodeError:i,onError:a}=r,{ref:o}=ra.useZxing({paused:e,timeBetweenDecodingAttempts:t,onDecodeResult:n,onDecodeError:i,onError:a,hints:Lf});return d.jsxs("div",{className:"bg-(--color-background) flex size-full flex-col justify-center overflow-hidden",children:[d.jsx("div",{className:"flex w-full justify-end p-4",children:d.jsx(v.Overlay.Close,{asChild:!0,children:d.jsx(v.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",children:d.jsx(v.LuIcon,{icon:at})})})}),d.jsx("div",{className:"max-h-full w-full grow overflow-hidden p-4",children:d.jsx("video",{className:"size-full",ref:o})})]})});Eo.displayName="ScannerInternal";const Io=y.memo(r=>{const{children:e}=r,[t,n]=y.useState(null),i=y.useCallback(()=>{n(null)},[]),a=y.useCallback(s=>{n(s(i))},[i]),o=y.useCallback(()=>{t&&(t.onClose&&t.onClose(),i())},[i,t]);return d.jsxs(ba.Provider,{value:a,children:[e,t&&d.jsx(Kr,{open:!0,onOpenChange:o,...t})]})});Io.displayName="FileViewerProvider";const xi=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),[u,c]=y.useState(!1),f=y.useCallback(m=>{const w=m.target.value;o(w)},[o]),h=y.useCallback(()=>{a()},[a]),p=y.useCallback(m=>{o(m.getText()),a(),c(!1)},[o,a]),g=y.useCallback(()=>{c(!0)},[]),x=y.useCallback(()=>{c(!1),a()},[a]);return d.jsxs(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:[d.jsx(v.TextArea,{className:"field-sizing-content w-full",accentColor:"base",variant:"surface",size:t,id:e.identifier,name:i,value:n??"",placeholder:"Enter a qr or barcode",onChange:f,onBlur:h,disabled:l}),d.jsxs(v.Button,{onClick:g,className:"w-max",type:"button",variant:"soft",size:t,accentColor:"base",disabled:l,children:[d.jsx(v.LuIcon,{icon:Ul}),"Scan"]}),d.jsx(Kr,{open:u,onDecodeResult:p,onOpenChange:x})]})});xi.displayName="ScanFieldInput";class $t extends Ve{constructor(t){super(t);M(this,"type","qr")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new $t({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){return new $t(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(xi,{field:this})}isSerializedValue(t){return typeof t=="string"}isValue(t){return typeof t=="string"}blankValue(){return""}areValuesEqual(t,n){return t===n}blankSerializedValue(){return""}areSerializedValuesEqual(t,n){return t===n}}const yi=500,Ci=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(h=>{const p=h.target.value;o(p)},[o]),c=y.useCallback(()=>{a()},[a]),f=y.useCallback(h=>{h.key==="Enter"&&h.preventDefault()},[]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(v.Input.Root,{accentColor:"base",variant:"surface",size:t,children:d.jsx(v.Input.Field,{id:e.identifier,className:"truncate",name:i,value:n??"",type:"text",placeholder:e.placeholder,onChange:u,onBlur:c,disabled:l,onKeyDown:f})})})});Ci.displayName="StringFieldInput";class Tt extends In{constructor(t){const{...n}=t,i=t.maxLength?Math.min(yi,t.maxLength):yi,a=t.minLength?Math.min(t.minLength,i):void 0;super({...n,maxLength:i,minLength:a});M(this,"type","string")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new Tt({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){const{maximum_length:n,minimum_length:i,...a}=t;return new Tt({...a,maxLength:n,minLength:i,placeholder:"Enter a short description"})}render(){return d.jsx(Ci,{field:this})}}const mi=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(f=>{const h=f.target.value;o(h)},[o]),c=y.useCallback(()=>{a()},[a]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(v.TextArea,{id:e.identifier,value:n??"",name:i,onChange:u,onBlur:c,className:"field-sizing-content min-h-12",placeholder:e.placeholder,resize:"vertical",accentColor:"base",variant:"surface",size:t,disabled:l})})});mi.displayName="TextFieldInput";class Mt extends In{constructor(t){const n=t.maxLength?Math.min(rr,t.maxLength):rr,i=t.minLength?Math.min(t.minLength,n):void 0;super({...t,maxLength:n,minLength:i});M(this,"type","text")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(t){return new Mt({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}static deserialize(t){const{maximum_length:n,minimum_length:i,...a}=t;return new Mt({...a,maxLength:n,minLength:i,placeholder:"Enter a description"})}render(){return d.jsx(mi,{field:this})}}const wi=zf(),Oo=new Set(wi);function zf(r=!0){const e=new Set;for(let t=-12;t<=14;t++){const n=t>=0?"+":"-",i=Math.abs(t).toString().padStart(2,"0");e.add(`${n}${i}:00`)}if(r){const t=[-12.5,-9.5,-3.5,3.5,4.5,5.5,6.5,9.5,10.5,12.5];for(const n of t){const i=n>=0?"+":"-",a=Math.floor(Math.abs(n)).toString().padStart(2,"0");e.add(`${i}${a}:30`)}}return Array.from(e).sort((t,n)=>bo(t)-bo(n))}function bo(r){const e=r[0]==="+"?1:-1,t=Number(r.slice(1,3)),n=Number(r.slice(4,6));return e*(t*60+n)}const kf="+00:00",Uf=/^T([01]\d|2[0-3]):([0-5]\d):00([+-]\d{2}:\d{2})$/,Qr=r=>typeof r=="string"&&Oo.has(r),No=()=>{const r=-new Date().getTimezoneOffset(),e=r>=0?"+":"-",t=Math.abs(r),n=Math.floor(t/60),i=t%60,a=`${e}${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`;return Qr(a)?a:kf};function To(r){const e=/^([+-])(\d{2}):(\d{2})$/.exec(r);if(!e)throw new Error(`Invalid UTC offset: ${r}`);return(e[1]==="+"?1:-1)*(Number(e[2])*60+Number(e[3]))}const dr=r=>{const e=Uf.exec(r);if(!e)return null;const t=e[3];return Qr(t)?{hours:Number(e[1]),minutes:Number(e[2]),utcOffset:t}:null},ye=r=>typeof r=="string"&&dr(r)!==null,_i=(r,e,t=No())=>{if(!Number.isInteger(r)||r<0||r>23)throw new Error(`Invalid hour: ${r}`);if(!Number.isInteger(e)||e<0||e>59)throw new Error(`Invalid minute: ${e}`);if(!Qr(t))throw new Error("Unsupported UTC offset");const n=r.toString().padStart(2,"0"),i=e.toString().padStart(2,"0");return`T${n}:${i}:00${t}`},Jr=r=>`UTC${r}`,ht=r=>{const e=dr(r);if(!e)throw new Error(`Invalid time value: ${r}`);return(e.hours*60+e.minutes-To(e.utcOffset)+1440)%1440},en=(r,e=!0)=>{const t=dr(r);if(!t)throw new Error(`Invalid time value: ${r}`);const n=(t.hours%12||12).toString().padStart(2,"0"),i=t.minutes.toString().padStart(2,"0"),a=t.hours>=12?"PM":"AM",o=`${n}:${i} ${a}`;return e?`${o} ${Jr(t.utcOffset)}`:o},fr=r=>typeof r=="object"&&(ye(r.from)||ye(r.to)),Ai=(r,e)=>{const t=ht(r),n=e.from?ht(e.from):null,i=e.to?ht(e.to):null;return n===null&&i===null?!0:n===null?t<=i:i===null?t>=n:n<=i?t>=n&&t<=i:t>=n||t<=i},tn=y.memo(r=>{const{value:e,onChange:t,onBlur:n,disabled:i,size:a="md",id:o,name:s,compact:l=!1}=r,u=e?dr(e):null,c=u?`${u.hours.toString().padStart(2,"0")}:${u.minutes.toString().padStart(2,"0")}`:"",f=y.useCallback(g=>{const x=g.target.value;if(!x){t(null);return}const[m,w]=x.split(":").map(Number);t(_i(m,w,u==null?void 0:u.utcOffset))},[t,u==null?void 0:u.utcOffset]),h=y.useCallback(g=>{u&&(t(_i(u.hours,u.minutes,g)),n==null||n())},[n,t,u]),p=y.useCallback(g=>{g||n==null||n()},[n]);return d.jsxs("div",{className:"flex min-w-0 gap-2",children:[d.jsx(v.Input.Root,{className:"min-w-0 grow",accentColor:"base",variant:"surface",size:a,children:d.jsx(v.Input.Field,{id:o,name:s,className:$e.cx("[&::-webkit-calendar-picker-indicator]:invert-40 dark:[&::-webkit-calendar-picker-indicator]:invert-60",{"[&::-webkit-datetime-edit]:opacity-60":!e}),type:"time",step:60,value:c,onChange:f,onBlur:n,disabled:i})}),d.jsxs(v.Menu.Root,{align:"end",onOpenChange:p,children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsxs(v.Button,{type:"button",className:l?"!justify-between":"min-w-32 !justify-between",accentColor:"base",variant:"surface",size:a,disabled:i||!u,children:[d.jsx(v.Text,{className:"truncate",highContrast:!!u,children:u?Jr(u.utcOffset):"UTC offset"}),d.jsx(v.LuIcon,{icon:Fr})]})}),d.jsx(v.Menu.Content,{size:a,children:d.jsx(v.Menu.Scroll,{children:d.jsx(v.Menu.SelectGroup,{required:!0,value:u==null?void 0:u.utcOffset,onValueChange:h,children:wi.map(g=>d.jsxs(v.Menu.SelectItem,{value:g,children:[d.jsx(v.Menu.SelectedIndicator,{children:d.jsx(v.LuIcon,{icon:ke})}),Jr(g)]},g))})})})]})]})});tn.displayName="TimeFieldControl";const Si=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e});return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsx(tn,{id:e.identifier,name:i,size:t,value:n,onChange:o,onBlur:a,disabled:l})})});Si.displayName="TimeFieldInput";class Xt extends Ve{constructor(t){super(t);M(this,"type","time")}static deserialize(t){return new Xt(t)}getOptions(){return super.getOptions()}duplicate(t){return new Xt({...this.getOptions(),identifier:t})}setOptions(t){super.setOptions(t)}serializeValue(t){return t}deserializeValue(t){return t}render(){return d.jsx(Si,{field:this})}isSerializedValue(t){return t===null||ye(t)}isValue(t){return t===null||ye(t)}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return t===n}}const Ei=y.memo(r=>{var m;const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useRef(null),c=y.useCallback(()=>{var w;(w=u.current)==null||w.click()},[]),f=y.useCallback(()=>{if(!u.current)return;const w=u.current.files;if(!w){a();return}const A=Array.from(w).map(S=>st.from(U.v4(),S)),E=[...n,...A];o(E),a()},[a,o,n]),h=y.useCallback(w=>{const A=n.filter(({uuid:E})=>E!==w.uuid);o(A),a()},[n,o,a]);y.useEffect(()=>{if(!u.current)return;const w=new AbortController;return u.current.addEventListener("cancel",()=>{a()},{signal:w.signal}),()=>{w.abort()}},[a,n]);const x=e.maxFiles>1?"Select files":"Select a file";return d.jsxs(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:[d.jsxs(v.Button,{className:"w-max",size:t,variant:"soft",accentColor:"base",onClick:c,type:"button",disabled:l,children:[d.jsx(v.LuIcon,{icon:yn}),x]}),d.jsx("input",{id:e.identifier,name:i,type:"file",ref:u,accept:(m=e.extensions)==null?void 0:m.join(","),multiple:e.maxFiles>1,className:"hidden",onChange:f,value:""}),n.length>0&&d.jsx("div",{className:"flex h-max flex-col gap-2",children:n.map(w=>d.jsx(Pn,{size:t,fileOrPromise:w,onRemove:h,disabled:l},w.uuid))})]})});Ei.displayName="UploadFieldInput";class Dt extends Ve{constructor(t){const{extensions:n,maximum_files:i,maximum_size:a,...o}=t;super(o);M(this,"type","upload");M(this,"extensions");M(this,"maxFileSize");M(this,"maxFiles");this.maxFileSize=typeof a=="number"?a:void 0,this.maxFiles=Math.max(typeof i=="number"?i:1,1),this.extensions=n}static getFieldCreationSchema(t=""){const n=t&&`${t}.`;return[{field:new Pe({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:1,maximum:10,identifier:`${n}maximum_files`,integers:!0}),showDirectly:!1},{field:new Pe({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${jt}MB).`,required:!1,identifier:`${n}maximum_size`,minimum:1,maximum:jt,integers:!0}),showDirectly:!1},{field:new it({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,identifier:`${n}extensions`,options:[{value:"image/*",label:"Images"},{value:"audio/*",label:"Audio files"},{value:"video/*",label:"Videos"},{value:"text/*",label:"Text files"},{value:"application/*",label:"Application files (includes PDFs and Word documents)"}]}),showDirectly:!1}]}getFieldValidators(){const t=super.getFieldValidators(),n=this.maxFileSize??jt,i=n*1e3*1e3,a=this.maxFiles||1;return t.push(o=>{if(o.some(s=>s instanceof st&&s.size>i))return`Files must be at most ${n}MB.`}),t.push(o=>{if(o.length>a)return`You can only upload ${a} files.`}),t}serialize(){return{...super.serialize(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}getOptions(){return{...super.getOptions(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}duplicate(t){return new Dt({...this.getOptions(),identifier:t})}setOptions(t){const{extensions:n,maximum_files:i,maximum_size:a,...o}=t;this.maxFileSize=typeof a=="number"?a:this.maxFileSize,this.maxFiles=typeof i=="number"?i:this.maxFiles,this.extensions=n,super.setOptions(o)}static deserialize(t){return new Dt(t)}serializeValue(t){return[]}deserializeValue(t){return[]}render(){return d.jsx(Ei,{field:this})}isSerializedValue(t){return Array.isArray(t)&&t.length===0}isValue(t){return Array.isArray(t)?t.every(n=>n instanceof kt||n instanceof st):!1}areValuesEqual(t,n){return Lr(t,n)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(t,n){return t.length===n.length}}const Ii=y.memo(r=>{const{field:e}=r,{size:t}=y.use(ce),{value:n,name:i,onBlur:a,onChange:o,error:s,disabled:l}=me({field:e}),u=y.useCallback(p=>{const g=p.target.value;g!==""&&!URL.canParse(g)||o(g!==""?new URL(g):null)},[o]),c=y.useCallback(()=>{a()},[a]),f=y.useCallback(p=>{p.key==="Enter"&&p.preventDefault()},[]),h=y.useCallback(()=>{n!==null&&window.open(n,"_blank","noopener,noreferrer")},[n]);return d.jsx(de,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:s,image:e.image,children:d.jsxs("div",{className:"flex w-full gap-2",children:[d.jsx(v.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:t,children:d.jsx(v.Input.Field,{id:e.identifier,className:"truncate",name:i,value:n?n.toString():"",type:"url",inputMode:"url",placeholder:e.placeholder,onChange:u,onBlur:c,disabled:l,onKeyDown:f})}),d.jsx(v.IconButton,{size:t,variant:"soft",accentColor:"base",type:"button",disabled:n===null,onClick:h,children:d.jsx(v.LuIcon,{icon:Dl})})]})})});Ii.displayName="URLFieldInput";class Wt extends Ve{constructor(t){const{placeholder:n="https://example.com",...i}=t;super(i);M(this,"type","url");M(this,"placeholder");this.placeholder=n}serialize(){return{...super.serialize(),placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(t){return new Wt({...this.getOptions(),identifier:t})}setOptions(t){const{placeholder:n,...i}=t;this.placeholder=n??this.placeholder,super.setOptions(i)}static deserialize(t){return new Wt(t)}serializeValue(t){return(t==null?void 0:t.toString())??null}deserializeValue(t){return t===null?null:new URL(t)}isSerializedValue(t){return t===null?!0:typeof t!="string"?!1:URL.canParse(t)}isValue(t){return t===null||t instanceof URL}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(t,n){return t===n}areValuesEqual(t,n){return(t==null?void 0:t.toString())===(n==null?void 0:n.toString())}render(){return d.jsx(Ii,{field:this})}}const Oi={date:Lt,time:Xt,number:Pe,boolean:yt,select:ot,string:Tt,url:Wt,text:Mt,upload:Dt,qr:$t,"multi-string":xt,"multi-select":it,radio:At,"checkbox-list":Ct,"pass-fail":_t,otp:mt,rating:St},Mo=Object.keys(Oi),ue={"checkbox-list":{description:"Allows the user to select a multiple options from a list.",group:W.Selection,icon:Ml,name:"Checkbox list"},"multi-select":{description:"Allows the user to select a multiple options from a list of options.",group:W.Selection,icon:Ll,name:"Multi-select"},"multi-string":{description:"Allows the user to provide multiple unique strings.",group:W.Text,icon:kl,name:"Multi-string"},"pass-fail":{description:"Track pass, fail, or N/A outcome.",group:W.Assessment,icon:Tl,name:"Pass - Fail"},boolean:{description:"Perfect for both optional and required yes/no questions.",group:W.Selection,icon:ql,name:"Checkbox"},date:{description:"Allows specifying a date.",group:W.Temporal,icon:Sl,name:"Date"},time:{description:"Allows specifying a time and UTC offset.",group:W.Temporal,icon:Wl,name:"Time"},number:{description:"Allows specifying a number within a given range.",group:W.Numeric,icon:Pl,name:"Number"},otp:{description:"Allows specifying a number within a given range.",group:W.Verification,icon:Rl,name:"OTP"},qr:{description:"Used for scanning/reading QR and barcodes.",group:W.Capture,icon:Gl,name:"Scan"},radio:{description:"Allows the user to select a single option from a list of options.",group:W.Selection,icon:Ol,name:"Option list"},rating:{description:"Allows users to select a rating value.",group:W.Assessment,icon:xa,name:"Rating"},select:{description:"Allows the user to select a single option from a list of options.",group:W.Selection,icon:zl,name:"Dropdown"},string:{description:"Short text fields can hold up to 500 characters on a single line.",group:W.Text,icon:Xl,name:"Short Text"},text:{description:"Paragraph fields can hold up to 10000 characters and can have multiple lines.",group:W.Text,icon:wl,name:"Paragraph"},upload:{description:"Allows a file to be uploaded.",group:W.Capture,icon:yn,name:"Upload"},url:{description:"Allows users to enter a URL.",group:W.Text,icon:Bl,name:"URL"}},Do={[W.Assessment]:{name:"Assessment"},[W.Capture]:{name:"Capture"},[W.Numeric]:{name:"Numeric"},[W.Selection]:{name:"Selection"},[W.Temporal]:{name:"Temporal"},[W.Text]:{name:"Text"},[W.Verification]:{name:"Verification"}},jt=50,Fo=jt*1e3,Vo=Fo*1e3,Ce="Unlabelled",bi="Unlabelled";class H{constructor(e){M(this,"id");M(this,"label");M(this,"getApplyFn");M(this,"serialize");M(this,"deserialize");const{id:t,getApplyFn:n,label:i,serialize:a,deserialize:o}=e;this.id=t,this.getApplyFn=n,this.label=i,this.serialize=a,this.deserialize=o}static create(e){return new H(e)}}const Po=H.create({id:"nullable-boolean-equals",label:"is",getApplyFn:r=>e=>e===r,serialize:r=>r,deserialize:r=>r}),Bo=H.create({id:"nullable-boolean-not-equals",label:"is not",getApplyFn:r=>e=>e!==r,serialize:r=>r,deserialize:r=>r}),Lo=H.create({id:"date-equals",getApplyFn:r=>e=>e.getTime()===r.getTime(),label:"is",serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),zo=H.create({id:"date-not-equals",getApplyFn:r=>e=>e.getTime()!==r.getTime(),label:"is not",serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),ko=H.create({id:"date-before",getApplyFn:r=>e=>e.getTime()<r.getTime(),label:"before",serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),Uo=H.create({id:"date-after",label:"after",getApplyFn:r=>e=>e.getTime()>r.getTime(),serialize:r=>r.toISOString(),deserialize:r=>new Date(r)}),Ro=H.create({id:"date-range-in",label:"in between",getApplyFn:r=>e=>!(r!=null&&r.from&&r.from.getTime()>e.getTime()||r!=null&&r.to&&r.to.getTime()<e.getTime()),serialize:r=>{var e,t;return{from:((e=r.from)==null?void 0:e.toISOString())??null,to:((t=r.to)==null?void 0:t.toISOString())??null}},deserialize:r=>({from:r.from?new Date(r.from):void 0,to:r.to?new Date(r.to):void 0})}),Go=H.create({id:"date-range-not-in",label:"not in between",getApplyFn:r=>e=>!!(r!=null&&r.from&&r.from.getTime()>e.getTime()||r!=null&&r.to&&r.to.getTime()<e.getTime()),serialize:r=>{var e,t;return{from:((e=r.from)==null?void 0:e.toISOString())??null,to:((t=r.to)==null?void 0:t.toISOString())??null}},deserialize:r=>({from:r.from?new Date(r.from):void 0,to:r.to?new Date(r.to):void 0})}),Ho=H.create({id:"has-files",label:"is",getApplyFn:r=>e=>e.length>0,serialize:r=>r,deserialize:r=>r}),qo=H.create({id:"does-not-have-files",label:"is not",getApplyFn:r=>e=>e.length===0,serialize:r=>r,deserialize:r=>r}),Ni=H.create({id:"number-equals",getApplyFn:r=>e=>e===r,label:"is",serialize:r=>r,deserialize:r=>r}),Ti=H.create({id:"number-not-equals",getApplyFn:r=>e=>e!==r,label:"is not",serialize:r=>r,deserialize:r=>r}),Mi=H.create({id:"number-less-than",getApplyFn:r=>e=>e<r,label:"is less than",serialize:r=>r,deserialize:r=>r}),Di=H.create({id:"number-less-than-or-equals",getApplyFn:r=>e=>e<=r,label:"is less than or equal to",serialize:r=>r,deserialize:r=>r}),Fi=H.create({id:"number-greater-than",getApplyFn:r=>e=>e>r,label:"is greater than",serialize:r=>r,deserialize:r=>r}),Vi=H.create({id:"number-greater-than-or-equals",getApplyFn:r=>e=>e>=r,label:"is greater than or equal to",serialize:r=>r,deserialize:r=>r}),Pi=H.create({id:"number-range-in",getApplyFn:r=>e=>!(r.to&&e>r.to||r.from&&e<r.from),label:"is between",serialize:r=>r,deserialize:r=>r}),Bi=H.create({id:"number-range-not-in",getApplyFn:r=>e=>!!(r.to&&e>r.to||r.from&&e<r.from),label:"is not between",serialize:r=>r,deserialize:r=>r}),$o=H.create({id:"pass-fail-equals",getApplyFn:r=>e=>e===r,label:"is",serialize:r=>r,deserialize:r=>r}),Xo=H.create({id:"pass-fail-not-equals",getApplyFn:r=>e=>e!==r,label:"is not",serialize:r=>r,deserialize:r=>r}),Wo=H.create({id:"pass-fail-array-includes",getApplyFn:r=>{const e=new Set(r);return t=>e.has(t)},label:"is any of",serialize:r=>r,deserialize:r=>r}),jo=H.create({id:"pass-fail-array-excludes",getApplyFn:r=>{const e=new Set(r);return t=>!e.has(t)},label:"is none of",serialize:r=>r,deserialize:r=>r}),pt=H.create({id:"nullable-string-equals",getApplyFn:r=>e=>e===r,label:"is",serialize:r=>r,deserialize:r=>r}),vt=H.create({id:"nullable-string-not-equals",getApplyFn:r=>e=>e!==r,label:"is not",serialize:r=>r,deserialize:r=>r}),Yt=H.create({id:"string-includes",getApplyFn:r=>e=>e.includes(r),label:"includes",serialize:r=>r,deserialize:r=>r}),Zt=H.create({id:"string-excludes",getApplyFn:r=>e=>!e.includes(r),label:"does not include",serialize:r=>r,deserialize:r=>r}),Li=H.create({id:"string-array-includes",getApplyFn:r=>{const e=new Set(r);return t=>e.has(t)},label:"is any of",serialize:r=>r,deserialize:r=>r}),zi=H.create({id:"string-array-excludes",getApplyFn:r=>{const e=new Set(r);return t=>!e.has(t)},label:"is none of",serialize:r=>r,deserialize:r=>r}),rn=H.create({id:"string-array-every",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.isSubsetOf(n)}},label:"has all of",serialize:r=>r,deserialize:r=>r}),nn=H.create({id:"string-array-some",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return!e.isDisjointFrom(n)}},label:"has any of",serialize:r=>r,deserialize:r=>r}),an=H.create({id:"string-array-none",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.isDisjointFrom(n)}},label:"has none of",serialize:r=>r,deserialize:r=>r}),on=H.create({id:"string-array-equals",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.size===n.size&&n.isSubsetOf(e)}},label:"is",serialize:r=>r,deserialize:r=>r}),sn=H.create({id:"string-array-not-equals",getApplyFn:r=>{const e=new Set(r);return t=>{const n=new Set(t);return e.size!==n.size||!n.isSubsetOf(e)}},label:"is not",serialize:r=>r,deserialize:r=>r}),Yo=H.create({id:"time-equals",label:"is",getApplyFn:r=>e=>e===r,serialize:r=>r,deserialize:r=>r}),Zo=H.create({id:"time-not-equals",label:"is not",getApplyFn:r=>e=>e!==r,serialize:r=>r,deserialize:r=>r}),Ko=H.create({id:"time-before",label:"before",getApplyFn:r=>e=>ht(e)<ht(r),serialize:r=>r,deserialize:r=>r}),Qo=H.create({id:"time-after",label:"after",getApplyFn:r=>e=>ht(e)>ht(r),serialize:r=>r,deserialize:r=>r}),Jo=H.create({id:"time-range-in",label:"in between",getApplyFn:r=>e=>Ai(e,r),serialize:r=>r,deserialize:r=>r}),es=H.create({id:"time-range-not-in",label:"not in between",getApplyFn:r=>e=>!Ai(e,r),serialize:r=>r,deserialize:r=>r}),F=r=>r;class Ee extends er{constructor(t){const{id:n,field:i,conditionValue:a,conditionModifier:o}=t;super();M(this,"id");M(this,"conditionValue");M(this,"conditionModifier");M(this,"field");M(this,"getConditionValue",()=>this.conditionValue);M(this,"setConditionValue",t=>{const n=this.modifiers[this.conditionModifier];t!==void 0&&!n.isConditionValueValid(t)||(this.conditionValue=t,this.notify(this))});M(this,"getConditionModifier",()=>this.conditionModifier);M(this,"setConditionModifier",t=>{const n=this.modifiers[t],i=this.getConditionValue();i&&!n.isConditionValueValid(i)&&(this.conditionValue=void 0),this.conditionModifier=t,this.notify(this)});M(this,"getConditionModifiers",()=>Object.entries(this.modifiers));M(this,"accessorFn",t=>t[this.field.identifier]);M(this,"getApplyFn",()=>{const t=this.modifiers[this.conditionModifier],n=this.getConditionValue(),i=n!==void 0&&t.isConditionValueValid(n),a=i?t.modifier.getApplyFn(n):null;return o=>{if(!i)return!0;const s=this.transformValue(o);return t.isValueValid(s)?a(s):!1}});this.id=n,this.field=i,this.conditionValue=a,this.conditionModifier=o}serialize(){return{id:this.id,type:this.field.type,fieldId:this.field.identifier,conditionValue:this.conditionValue!==void 0?this.modifiers[this.conditionModifier].modifier.serialize(this.conditionValue):void 0,conditionModifier:this.conditionModifier}}transformValue(t){return t}}const ts=y.memo,Ft=ts(function(r){const{ref:e,children:t,...n}=r,i=y.useCallback(a=>typeof t=="function"?d.jsxs(d.Fragment,{children:[t(a),d.jsx(v.Menu.SelectedIndicator,{className:"ml-[auto]",children:d.jsx(v.LuIcon,{icon:ke})})]}):d.jsxs(d.Fragment,{children:[t,d.jsx(v.Menu.SelectedIndicator,{className:"ml-[auto]",children:d.jsx(v.LuIcon,{icon:ke})})]}),[t]);return d.jsx(v.Menu.SelectItem,{ref:e,...n,children:i})}),rs=ts(function(r){const{ref:e,children:t,...n}=r,i=y.useCallback(a=>typeof t=="function"?d.jsxs(d.Fragment,{children:[t(a),d.jsx(v.Menu.SelectedIndicator,{className:"ml-auto",children:d.jsx(v.LuIcon,{icon:ke})})]}):d.jsxs(d.Fragment,{children:[t,d.jsx(v.Menu.SelectedIndicator,{className:"ml-auto",children:d.jsx(v.LuIcon,{icon:ke})})]}),[t]);return d.jsx(v.Menu.MultiSelectItem,{ref:e,...n,children:i})}),ki=y.memo(r=>{const{ref:e,children:t,...n}=r,i=y.useCallback(a=>typeof t=="function"?d.jsxs(d.Fragment,{children:[t(a),d.jsx(v.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:o=>o?d.jsx(v.LuIcon,{icon:Vr}):d.jsx(v.LuIcon,{icon:ke})})]}):d.jsxs(d.Fragment,{children:[t,d.jsx(v.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:o=>o?d.jsx(v.LuIcon,{icon:Vr}):d.jsx(v.LuIcon,{icon:ke})})]}),[t]);return d.jsx(v.Menu.SelectAllItem,{ref:e,...n,children:i})});ki.displayName="SelectAllItemTemplate";const Te=r=>{const{children:e,condition:t,size:n="sm",variant:i,accentColor:a,radius:o}=r,s=y.useCallback(l=>{t.setConditionModifier(l)},[t]);return d.jsxs(v.Menu.Root,{align:"start",children:[d.jsx(v.Menu.ClickTrigger,{children:e}),d.jsx(v.Menu.Content,{size:n,variant:i,radius:o,accentColor:a,children:d.jsx(v.Menu.SelectGroup,{required:!0,value:t.getConditionModifier(),onValueChange:s,children:t.getConditionModifiers().map(([l,u])=>d.jsx(Ft,{value:l,children:u.modifier.label},l))})})]})},ln=y.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,align:s,accentColor:l="base",...u}=r;return d.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:e}),d.jsx(v.Popover.Content,{size:o,align:s,children:d.jsx(v.DayPicker,{size:o,accentColor:l,...u})})]})});ln.displayName="DayPickerPopover";const ns=y.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,accentColor:s="base",values:l,onValuesChange:u,placeholder:c="Enter text",...f}=r,[h,p]=y.useState(""),g=y.useCallback(A=>{p(A.target.value)},[]),x=y.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),A.stopPropagation(),u([...l,h]),p(""))},[h,u,l]),m=y.useCallback(()=>{u([...l,h]),p("")},[h,u,l]),w=y.useCallback(A=>{const E=[...l];E.splice(A,1),u(E)},[u,l]);return d.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:e}),d.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,accentColor:s,...f,children:d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex gap-2",children:[d.jsx(v.Input.Root,{className:"grow",accentColor:"base",variant:"outline",size:"sm",children:d.jsx(v.Input.Field,{value:h,onChange:g,onKeyDown:x,placeholder:c,...f})}),d.jsx(v.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button",onClick:m,children:d.jsx(v.LuIcon,{icon:Ze})})]}),l.length>0&&d.jsx("div",{className:"flex flex-col gap-1",children:l.map((A,E)=>d.jsxs(v.Badge,{className:"flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[d.jsx("span",{className:"truncate",children:A}),d.jsx(v.IconButton,{size:"xs",variant:"ghost",type:"button",accentColor:"base",onClick:()=>{w(E)},children:d.jsx(v.LuIcon,{icon:at})})]},`${A}-${E}`))})]})})]})});ns.displayName="NumberInputPopover";const Vt=y.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,accentColor:s="base",value:l,onValueChange:u,placeholder:c="Enter a number",...f}=r,[h,p]=y.useState(null);y.useEffect(()=>{l!==void 0&&p(l)},[l]);const g=y.useCallback(m=>{const w=m.target.valueAsNumber;p(isNaN(w)?null:w)},[]),x=y.useCallback(m=>{const w=m.target.valueAsNumber;u==null||u(isNaN(w)?null:w)},[u]);return d.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:e}),d.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,...f,children:d.jsx(v.Input.Root,{size:o,accentColor:s,children:d.jsx(v.Input.Field,{placeholder:c,type:"number",value:h??"",onChange:g,onBlur:x})})})]})});Vt.displayName="NumberInputPopover";const Ie=r=>{const{condition:e,onClick:t,...n}=r,i=y.useCallback(()=>{t(e)},[e,t]);return d.jsx(v.IconButton,{onClick:i,...n,children:d.jsx(v.LuIcon,{icon:at})})};Ie.displayName="RemoveConditionButton";const hr=y.memo(r=>{const{ref:e,selectFieldOptions:t,...n}=r,i=y.useMemo(()=>t.map(a=>typeof a=="string"?{value:a,label:a}:a),[t]);return d.jsxs(v.Menu.MultiSelectGroup,{ref:e,...n,children:[d.jsx(ki,{children:"Select all"}),i.map(a=>d.jsx(rs,{value:a.value,children:d.jsx("span",{className:"truncate",children:a.label})},a.value))]})});hr.displayName="SelectFieldOptionMultiSelectGroup";const Ui=y.memo(r=>{const{ref:e,selectFieldOptions:t,...n}=r,i=y.useMemo(()=>t.map(a=>typeof a=="string"?{value:a,label:a}:a),[t]);return d.jsx(v.Menu.SelectGroup,{ref:e,...n,children:i.map(a=>d.jsx(Ft,{value:a.value,children:d.jsx("span",{className:"truncate",children:a.label})},a.value))})});Ui.displayName="SelectFieldOptionSelectGroup";const Kt=y.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o,accentColor:s="base",value:l,onValueChange:u,placeholder:c="Enter text",...f}=r,[h,p]=y.useState(""),g=y.useCallback(m=>{p(m.target.value)},[]),x=y.useCallback(m=>{const w=m.target.value;u==null||u(w)},[u]);return y.useEffect(()=>{l&&p(l)},[l]),d.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:e}),d.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,...f,children:d.jsx(v.Input.Root,{size:o,accentColor:s,children:d.jsx(v.Input.Field,{placeholder:c,type:"text",value:h,onChange:g,onBlur:x})})})]})});Kt.displayName="TextInputPopover";const un=y.memo(r=>{const{children:e,open:t,onOpenChange:n,defaultOpen:i,modal:a,size:o="sm",accentColor:s="base",value:l,onValueChange:u,...c}=r;return d.jsxs(v.Popover.Root,{open:t,onOpenChange:n,defaultOpen:i,modal:a,children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:e}),d.jsx(v.Popover.Content,{size:o,onClick:v.stopPropagation,accentColor:s,...c,children:d.jsx(tn,{compact:!0,size:o,value:l,onChange:u})})]})});un.displayName="TimeInputPopover";const is=r=>{const{condition:e,onRemove:t}=r,n=e.getConditionValue(),i=e.getConditionModifier(),a=()=>{switch(n){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[e.field.type].icon}),d.jsx("span",{className:"truncate",children:e.field.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[i].modifier.label})}),d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:a()})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsxs(v.Menu.SelectGroup,{required:!0,value:n,onValueChange:e.setConditionValue,children:[d.jsx(Ft,{value:!0,children:"true"}),d.jsx(Ft,{value:!1,children:"false"})]})})]}),d.jsx(Ie,{condition:e,onClick:t})]})},as={equals:F({modifier:Po,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:Bo,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class pr extends Ee{constructor(t){super(t);M(this,"modifiers",as)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=as[a];let l;return i!==void 0&&(l=s.modifier.deserialize(i)),new pr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(is,{condition:this,...t},this.id)}}const Qt=[],os=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=y.useCallback(l=>{l.length>0?e.setConditionValue(l):e.setConditionValue(void 0)},[e]),s=()=>{if(i===void 0)return"...";if(i===null)return"empty";switch(i.length){case 0:return"...";default:return`${i.length} options`}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"soft",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"soft",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"truncate",children:s()})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(hr,{values:i??Qt,selectFieldOptions:e.field.options,onValuesChange:o})})]}),d.jsx(Ie,{condition:e,onClick:t})]})},ss={equals:F({modifier:on,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:sn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),every:F({modifier:rn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),some:F({modifier:nn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),none:F({modifier:an,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class vr extends Ee{constructor(t){super(t);M(this,"modifiers",ss)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ss[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new vr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(os,{condition:this,...t},this.id)}}class cn extends er{constructor(t){super();M(this,"conditions");M(this,"conditionObserver",()=>{this.conditions=[...this.conditions],this.notify(this)});M(this,"initConditions",t=>{for(const n of t)n.observe(this.conditionObserver);return t});this.conditions=this.initConditions(t)}getConditions(){return this.conditions}addCondition(t){this.conditions=this.initConditions([...this.conditions,t]),this.notify(this)}addConditions(t){this.conditions=this.initConditions([...this.conditions,...t]),this.notify(this)}removeCondition(t){this.conditions=this.initConditions(this.conditions.filter(n=>n.id!==t.id)),this.notify(this)}removeConditions(t){const n=new Set(t.map(i=>i.id));this.conditions=this.initConditions(this.conditions.filter(i=>!n.has(i.id))),this.notify(this)}applyConditions(t){return this.conditions.length===0?!0:this.conditions.map(i=>[i.getApplyFn(),i.accessorFn]).every(([i,a])=>i(a(t)))}}const Rf=(r,e)=>y.useMemo(()=>{const t=new cn(r);return t.observe(n=>e(n.getConditions())),t},[r,e]),ls=r=>{const{condition:e,onRemove:t}=r,n=e.getConditionValue(),i=e.getConditionModifier(),a=()=>{var o,s;switch(i){case"equals":case"notEquals":{const l=e.modifiers.equals,u=n!==void 0&&l.isConditionValueValid(n)?n:void 0;return d.jsx(ln,{required:!1,size:"sm",mode:"single",selected:u??void 0,onSelect:c=>e.setConditionValue(c),children:d.jsx(v.Button,{type:"button",className:"truncate",children:u!==void 0?(u==null?void 0:u.toLocaleDateString())??"empty":"..."})})}case"before":case"after":{const l=e.modifiers.after,u=n!==void 0&&l.isConditionValueValid(n)?n:void 0;return d.jsx(ln,{required:!0,size:"sm",mode:"single",selected:u,onSelect:e.setConditionValue,children:d.jsx(v.Button,{type:"button",className:"truncate",children:u?u.toLocaleDateString():"..."})})}case"in":case"notIn":{const l=e.modifiers.in,u=n!==void 0&&l.isConditionValueValid(n)?n:void 0;return d.jsx(ln,{required:!0,mode:"range",size:"sm",selected:u,onSelect:e.setConditionValue,children:d.jsx(v.Button,{className:"truncate",children:u?`${(o=u.from)==null?void 0:o.toLocaleDateString()} - ${(s=u.to)==null?void 0:s.toLocaleDateString()}`:"..."})})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[e.field.type].icon}),d.jsx("span",{className:"truncate",children:e.field.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[i].modifier.label})}),a(),d.jsx(Ie,{condition:e,onClick:t})]})},us={equals:F({modifier:Lo,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),notEquals:F({modifier:zo,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),before:F({modifier:ko,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),after:F({modifier:Uo,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>r instanceof Date,isSerializedValueValid:r=>typeof r=="string"}),in:F({modifier:Ro,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>"to"in(r??{})&&"from"in(r??{}),isSerializedValueValid:r=>typeof r=="object"&&"to"in r&&"from"in r}),notIn:F({modifier:Go,isValueValid:r=>r instanceof Date,isConditionValueValid:r=>"to"in(r??{})&&"from"in(r??{}),isSerializedValueValid:r=>typeof r=="object"&&"to"in r&&"from"in r})};class gr extends Ee{constructor(t){super(t);M(this,"modifiers",us)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=us[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new gr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(ls,{condition:this,...t},this.id)}}const cs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=y.useCallback(l=>{l.length>0?e.setConditionValue(l):e.setConditionValue(void 0)},[e]),s=()=>{if(i===void 0)return"...";if(i===null)return"empty";switch(i.length){case 0:return"...";default:return`${i.length} options`}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"truncate",children:s()})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(hr,{values:i??Qt,selectFieldOptions:n.options,onValuesChange:o})})]}),d.jsx(Ie,{condition:e,onClick:t})]})},ds={equals:F({modifier:on,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:sn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),every:F({modifier:rn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),some:F({modifier:nn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),none:F({modifier:an,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class xr extends Ee{constructor(t){super(t);M(this,"modifiers",ds)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ds[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new xr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(cs,{condition:this,...t},this.id)}}const fs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=y.useCallback(l=>{e.setConditionValue(l.length>0?l:void 0)},[e]),s=()=>{if(i===void 0)return"...";if(i===null)return"empty";switch(i.length){case 0:return"...";case 1:return i[0].toString();default:return`${i.length} values`}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),d.jsx(ns,{values:i??Qt,onValuesChange:o,children:d.jsx(v.Button,{type:"button",className:"truncate",children:s()})}),d.jsx(Ie,{condition:e,onClick:t})]})},hs={equals:F({modifier:on,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:sn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),every:F({modifier:rn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),some:F({modifier:nn,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),none:F({modifier:an,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class yr extends Ee{constructor(t){super(t);M(this,"modifiers",hs)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=hs[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new yr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(fs,{condition:this,...t},this.id)}}const ps=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=y.useCallback(l=>{e.setConditionValue(l??void 0)},[e]),s=()=>{switch(a){case"equals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const l=e.modifiers.greaterThan,u=i!==void 0&&l.isConditionValueValid(i)?i:void 0;return d.jsx(Vt,{value:u??null,onValueChange:o,size:"sm",children:d.jsx(v.Button,{type:"button",className:"truncate",children:u!==void 0?u??"empty":"..."})})}case"inRange":case"notInRange":{const l=e.modifiers.inRange,u=i!==void 0&&l.isConditionValueValid(i)?i:void 0;return d.jsxs(d.Fragment,{children:[d.jsx(Vt,{value:(u==null?void 0:u.from)??null,onValueChange:c=>{e.setConditionValue({from:c,to:(u==null?void 0:u.to)??null})},size:"sm",children:d.jsx(v.Button,{className:"truncate",children:(u==null?void 0:u.from)??"..."})}),d.jsx(Vt,{value:(u==null?void 0:u.to)??null,onValueChange:c=>{e.setConditionValue({from:(u==null?void 0:u.from)??null,to:c})},size:"sm",children:d.jsx(v.Button,{className:"truncate",children:(u==null?void 0:u.to)??"..."})})]})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),s(),d.jsx(Ie,{condition:e,onClick:t})]})},vs={equals:F({modifier:Ni,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),notEquals:F({modifier:Ti,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThan:F({modifier:Mi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThanOrEquals:F({modifier:Di,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThan:F({modifier:Fi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThanOrEquals:F({modifier:Vi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),inRange:F({modifier:Pi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"}),notInRange:F({modifier:Bi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"})};class Cr extends Ee{constructor(t){super(t);M(this,"modifiers",vs)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=vs[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Cr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(ps,{condition:this,...t},this.id)}}const gs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return d.jsx(Kt,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:i||"..."})})})}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},xs={equals:F({modifier:pt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:vt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:F({modifier:Yt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:F({modifier:Zt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class mr extends Ee{constructor(t){super(t);M(this,"modifiers",xs)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=xs[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new mr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(gs,{condition:this,...t},this.id)}}const ys=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":{const s=e.modifiers.equals,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:l!==void 0?l?wt[l].label:"empty":"..."})})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(v.Menu.SelectGroup,{required:!1,value:l,onValueChange:e.setConditionValue,children:zt.map(u=>{const{label:c}=wt[u];return d.jsx(Ft,{value:u,children:d.jsx("span",{className:"truncate",children:c})},u)})})})]})}case"includes":case"excludes":{const s=e.modifiers.includes,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",children:l?`${l.length} statuses`:"..."})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsxs(v.Menu.MultiSelectGroup,{values:l??Qt,onValuesChange:e.setConditionValue,children:[d.jsx(ki,{children:"Select all"}),zt.map(u=>{const{label:c,icon:f}=wt[u];return d.jsxs(rs,{value:u,children:[d.jsx(v.LuIcon,{icon:f}),d.jsx("span",{className:"truncate",children:c})]},u)})]})})]})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},Cs={equals:F({modifier:$o,isValueValid:r=>r!==null,isConditionValueValid:r=>typeof r=="string",isSerializedValueValid:r=>typeof r=="string"}),notEquals:F({modifier:Xo,isValueValid:r=>r!==null,isConditionValueValid:r=>typeof r=="string",isSerializedValueValid:r=>typeof r=="string"}),includes:F({modifier:Wo,isValueValid:r=>r!==null,isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)}),excludes:F({modifier:jo,isValueValid:r=>r!==null,isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)})};class wr extends Ee{constructor(t){super(t);M(this,"modifiers",Cs)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Cs[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new wr({field:n,conditionModifier:a,conditionValue:l,...o})}transformValue(t){return t.status}render(t){return d.jsx(ys,{condition:this,...t},this.id)}}const ms=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=y.useMemo(()=>n.options.map(u=>typeof u=="string"?{value:u,label:u}:u),[n.options]),s=y.useMemo(()=>{const u={};for(const c of o)u[c.value]=c.label;return u},[o]),l=()=>{switch(a){case"equals":case"notEquals":{const u=e.modifiers.equals,c=i!==void 0&&u.isConditionValueValid(i)?i:void 0;return d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:c!==void 0?c?s[c]:"empty":"..."})})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(Ui,{required:!0,selectFieldOptions:n.options,value:c??void 0,onValueChange:e.setConditionValue})})]})}case"includes":case"excludes":{const u=e.modifiers.includes,c=i!==void 0&&u.isConditionValueValid(i)?i:void 0;return d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",children:c?`${c.length} options`:"..."})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(hr,{selectFieldOptions:n.options,values:c??Qt,onValuesChange:e.setConditionValue})})]})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),l(),d.jsx(Ie,{condition:e,onClick:t})]})},ws={equals:F({modifier:pt,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),notEquals:F({modifier:vt,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),includes:F({modifier:Li,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)}),excludes:F({modifier:zi,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)})};class _r extends Ee{constructor(t){super(t);M(this,"modifiers",ws)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=ws[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new _r({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(ms,{condition:this,...t},this.id)}}const _s=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const s=e.modifiers[a],l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return d.jsx(Vt,{value:l??null,onValueChange:u=>e.setConditionValue(u??void 0),size:"sm",children:d.jsx(v.Button,{type:"button",className:"truncate",children:l!==void 0?l:"..."})})}case"inRange":case"notInRange":{const s=e.modifiers.inRange,l=i!==void 0&&s.isConditionValueValid(i)?i:void 0;return d.jsxs(d.Fragment,{children:[d.jsx(Vt,{value:(l==null?void 0:l.from)??null,onValueChange:u=>{e.setConditionValue({from:u,to:(l==null?void 0:l.to)??null})},size:"sm",children:d.jsx(v.Button,{className:"truncate",children:(l==null?void 0:l.from)??"..."})}),d.jsx(Vt,{value:(l==null?void 0:l.to)??null,onValueChange:u=>{e.setConditionValue({from:(l==null?void 0:l.from)??null,to:u})},size:"sm",children:d.jsx(v.Button,{className:"truncate",children:(l==null?void 0:l.to)??"..."})})]})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},As={equals:F({modifier:Ni,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),notEquals:F({modifier:Ti,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThan:F({modifier:Mi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),lessThanOrEquals:F({modifier:Di,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThan:F({modifier:Fi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),greaterThanOrEquals:F({modifier:Vi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="number",isSerializedValueValid:r=>typeof r=="number"}),inRange:F({modifier:Pi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"}),notInRange:F({modifier:Bi,isValueValid:r=>typeof r=="number",isConditionValueValid:r=>typeof r=="object",isSerializedValueValid:r=>typeof r=="object"})};class Ar extends Ee{constructor(t){super(t);M(this,"modifiers",As)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=As[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Ar({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(_s,{condition:this,...t},this.id)}}const Ss=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return d.jsx(Kt,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:i||"..."})})})}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},Es={equals:F({modifier:pt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:vt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:F({modifier:Yt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:F({modifier:Zt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Sr extends Ee{constructor(t){super(t);M(this,"modifiers",Es)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Es[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Sr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(Ss,{condition:this,...t},this.id)}}const Is=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=y.useMemo(()=>n.options.map(c=>typeof c=="string"?{value:c,label:c}:c),[n.options]),s=y.useMemo(()=>{const c={};for(const f of o)c[f.value]=f.label;return c},[o]),l=y.useCallback(c=>{c.length>0?e.setConditionValue(c):e.setConditionValue([])},[e]),u=()=>{switch(a){case"equals":case"notEquals":{const c=e.modifiers.equals,f=i!==void 0&&c.isConditionValueValid(i)?i:void 0;return d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:f!==void 0?f?s[f]:"empty":"..."})})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(Ui,{required:!1,selectFieldOptions:n.options,value:f??void 0,onValueChange:e.setConditionValue})})]})}case"includes":case"excludes":{const c=e.modifiers.includes,f=i!==void 0&&c.isConditionValueValid(i)?i:void 0;return d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",children:f?`${f.length} options`:"..."})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsx(hr,{selectFieldOptions:n.options,values:f??Qt,onValuesChange:l})})]})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),u(),d.jsx(Ie,{condition:e,onClick:t})]})},Os={equals:F({modifier:pt,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),notEquals:F({modifier:vt,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>!Array.isArray(r),isSerializedValueValid:r=>!Array.isArray(r)}),includes:F({modifier:Li,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)}),excludes:F({modifier:zi,isValueValid:r=>typeof r=="string",isConditionValueValid:r=>Array.isArray(r),isSerializedValueValid:r=>Array.isArray(r)})};class Er extends Ee{constructor(t){super(t);M(this,"modifiers",Os)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Os[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Er({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(Is,{condition:this,...t},this.id)}}const bs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return d.jsx(Kt,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:i||"..."})})})}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},Ns={equals:F({modifier:pt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:vt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:F({modifier:Yt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:F({modifier:Zt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Ir extends Ee{constructor(t){super(t);M(this,"modifiers",Ns)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Ns[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Ir({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(bs,{condition:this,...t},this.id)}}const Ts=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return d.jsx(Kt,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:i||"..."})})})}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},Ms={equals:F({modifier:pt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:vt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:F({modifier:Yt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:F({modifier:Zt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Or extends Ee{constructor(t){super(t);M(this,"modifiers",Ms)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Ms[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Or({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(Ts,{condition:this,...t},this.id)}}const Ds=r=>{const{condition:e,onRemove:t}=r,n=e.getConditionValue(),i=e.getConditionModifier(),a=()=>{switch(i){case"equals":case"notEquals":case"before":case"after":{const o=typeof n=="string"?n:void 0;return d.jsx(un,{value:o,onValueChange:s=>e.setConditionValue(s??void 0),size:"sm",children:d.jsx(v.Button,{type:"button",className:"truncate",children:o?en(o):"..."})})}case"in":case"notIn":{const o=n&&typeof n=="object"?n:void 0,s=l=>{e.setConditionValue(l.from||l.to?l:void 0)};return d.jsxs(d.Fragment,{children:[d.jsx(un,{value:o==null?void 0:o.from,onValueChange:l=>s({from:l,to:(o==null?void 0:o.to)??null}),size:"sm",children:d.jsx(v.Button,{type:"button",className:"truncate",children:o!=null&&o.from?en(o.from):"..."})}),d.jsx(un,{value:o==null?void 0:o.to,onValueChange:l=>s({from:(o==null?void 0:o.from)??null,to:l}),size:"sm",children:d.jsx(v.Button,{type:"button",className:"truncate",children:o!=null&&o.to?en(o.to):"..."})})]})}}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[e.field.type].icon}),d.jsx("span",{className:"truncate",children:e.field.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[i].modifier.label})}),a(),d.jsx(Ie,{condition:e,onClick:t})]})},Fs={equals:F({modifier:Yo,isValueValid:r=>ye(r),isConditionValueValid:r=>ye(r),isSerializedValueValid:r=>ye(r)}),notEquals:F({modifier:Zo,isValueValid:r=>ye(r),isConditionValueValid:r=>ye(r),isSerializedValueValid:r=>ye(r)}),before:F({modifier:Ko,isValueValid:r=>ye(r),isConditionValueValid:r=>ye(r),isSerializedValueValid:r=>ye(r)}),after:F({modifier:Qo,isValueValid:r=>ye(r),isConditionValueValid:r=>ye(r),isSerializedValueValid:r=>ye(r)}),in:F({modifier:Jo,isValueValid:r=>ye(r),isConditionValueValid:r=>fr(r),isSerializedValueValid:r=>fr(r)}),notIn:F({modifier:es,isValueValid:r=>ye(r),isConditionValueValid:r=>fr(r),isSerializedValueValid:r=>fr(r)})};class br extends Ee{constructor(t){super(t);M(this,"modifiers",Fs)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Fs[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new br({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(Ds,{condition:this,...t},this.id)}}const Vs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(i){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),d.jsxs(v.Menu.Root,{children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:o()})}),d.jsx(v.Menu.Content,{size:"sm",children:d.jsxs(v.Menu.SelectGroup,{required:!0,value:i,onValueChange:e.setConditionValue,children:[d.jsx(Ft,{value:!0,children:"empty"}),d.jsx(Ft,{value:!1,children:"not empty"})]})})]}),d.jsx(Ie,{condition:e,onClick:t})]})},Ps={equals:F({modifier:Ho,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:qo,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Nr extends Ee{constructor(t){super(t);M(this,"modifiers",Ps)}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Ps[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Nr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(Vs,{condition:this,...t},this.id)}}const Bs=r=>{const{condition:e,onRemove:t}=r,n=e.field,i=e.getConditionValue(),a=e.getConditionModifier(),o=()=>{switch(a){case"equals":case"notEquals":case"includes":case"excludes":return d.jsx(Kt,{value:i??"",onValueChange:e.setConditionValue,size:"sm",children:d.jsx(v.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:d.jsx("span",{className:"truncate",children:i||"..."})})})}};return d.jsxs(v.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[d.jsxs(v.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:ue[n.type].icon}),d.jsx("span",{className:"truncate",children:n.label||Ce})]}),d.jsx(Te,{condition:e,children:d.jsx(v.Button,{type:"button",children:e.modifiers[a].modifier.label})}),o(),d.jsx(Ie,{condition:e,onClick:t})]})},Ls={equals:F({modifier:pt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),notEquals:F({modifier:vt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),includes:F({modifier:Yt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0}),excludes:F({modifier:Zt,isValueValid:r=>!0,isConditionValueValid:r=>!0,isSerializedValueValid:r=>!0})};class Tr extends Ee{constructor(t){super(t);M(this,"modifiers",Ls)}transformValue(t){return(t==null?void 0:t.toString())??""}static deserialize(t,n){const{conditionValue:i,conditionModifier:a,...o}=t,s=Ls[a],l=i!==void 0&&s.isSerializedValueValid(i)?s.modifier.deserialize(i):void 0;return new Tr({field:n,conditionModifier:a,conditionValue:l,...o})}render(t){return d.jsx(Bs,{condition:this,...t},this.id)}}const Gf={date:gr,time:br,number:Cr,boolean:pr,select:Er,string:Ir,url:Tr,text:Or,upload:Nr,qr:Sr,"multi-string":yr,"multi-select":xr,radio:_r,"checkbox-list":vr,"pass-fail":wr,otp:mr,rating:Ar},zs=(r,e)=>{if(r.type!==e.type)throw new Error(`field and condition type mismatch ${r.type} !== ${e.type}`);return Gf[e.type].deserialize(e,r)},Ri=(r,e)=>{const t=Gi(r,e),n={};for(const i of r)n[i.identifier]=i;return t.map(i=>zs(n[i.fieldId],i))},ks=(r,e)=>Hi(r,e).map(n=>n.serialize()),Gi=(r,e)=>{const t=new Set(r.map(n=>n.identifier));return e.filter(n=>t.has(n.fieldId))},Hi=(r,e)=>{const t=new Set(r.map(n=>n.identifier));return e.filter(n=>t.has(n.field.identifier))},dn=r=>Oi[r.type].deserialize(r);function Hf(r){return r.map(Us)}const Us=r=>r.type==="section"?qe.deserialize(r):dn(r);function qf(r){return r.map(dn)}function $f(r){const e=[];for(const t of r)if(t instanceof qe)for(const n of t.getFields())e.push(n);else e.push(t);return e}function Xf(r){const e={};for(const t of r)e[t.identifier]=t;return e}function Rs(r,e,t=!0){const n=t?fn(r,e):e,i={};for(const a of r){if(!(a.identifier in n))continue;const o=n[a.identifier];i[a.identifier]=a.serializeValue(o)}return i}function Gs(r,e,t=!0){const n=t?qi(r,e):e,i={};for(const a of r){if(!(a.identifier in n))continue;const o=n[a.identifier];i[a.identifier]=a.deserializeValue(o)}return i}function fn(r,e){const t={};for(const n of r){if(!(n.identifier in e))continue;const i=e[n.identifier];n.isValue(i)&&(t[n.identifier]=n.cleanValue(i))}return t}function qi(r,e){const t={};for(const n of r){if(!(n.identifier in e))continue;const i=e[n.identifier];n.isSerializedValue(i)&&(t[n.identifier]=n.cleanSerializedValue(i))}return t}function Hs(r,e){const t=fn(r,e),n={},i={};for(const a of r){if(!(a.identifier in t))continue;const o=t[a.identifier];switch(a.type){case"upload":if(!a.isValue(o))break;i[a.identifier]=o,n[a.identifier]=[];break;case"pass-fail":if(!a.isValue(o))break;i[a.identifier]=o.files,n[a.identifier]={...o,files:[]};break;default:n[a.identifier]=e[a.identifier]}}return[n,i]}function qs(r,e,t){const n={};for(const i of r){if(!(i.identifier in e))continue;const a=e[i.identifier];switch(i.type){case"upload":if(!i.isValue(a))break;n[i.identifier]=t[i.identifier]??[];break;case"pass-fail":if(!i.isValue(a))break;n[i.identifier]={...a,files:t[i.identifier]??[]};break;default:if(!i.isValue(a))break;n[i.identifier]=a}}return n}const $s=(r,e)=>{const t={};for(const n of r){const i=e[n.identifier];t[n.identifier]=i!==void 0?i:n.blankValue()}return t},Xs=(r,e,t)=>{const n={};for(const i of r){const a=e[i.identifier],o=t[i.identifier];i.areValuesEqual(a,o)||(n[i.identifier]=o)}return n},Ws=(r,e,t)=>{const n={};for(const i of r){const a=e[i.identifier],o=t[i.identifier];i.areValuesEqual(a,o)&&(n[i.identifier]=o)}return n},$i=(r,e,t)=>r.every(n=>{const i=e[n.identifier],a=t[n.identifier];return n.areValuesEqual(i,a)}),Xi=r=>{const e={};for(const t of r)e[t.identifier]=t.blankValue();return e},js=(r,e)=>$i(r,e,Xi(r)),Wf=$e.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),hn=$e.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),Wi=y.memo(r=>{const{fieldSection:e}=r,{label:t,description:n}=e,i=Ye.useWatch(),{fieldSchema:a,size:o}=y.use(ce),s=y.useMemo(()=>a.getFieldSections(),[a]),l=y.useMemo(()=>s.findIndex(({identifier:h})=>h===e.identifier),[s,e.identifier]),u=y.useMemo(()=>s.filter(h=>e.identifier in h.conditions),[s,e.identifier]),c=y.useMemo(()=>u.length===0?!0:u.some(h=>{const p=h.getConditions(e.identifier);return new cn(p).applyConditions(i)}),[u,e,i]),f=Br(e.fields);return c?d.jsxs(d.Fragment,{children:[l!==0?d.jsx(v.Separator,{size:"full"}):null,d.jsxs("div",{className:"flex flex-col gap-4",children:[(t||n)&&d.jsx(d.Fragment,{children:d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx(v.Heading,{size:o,children:t}),n&&d.jsx(v.Text,{accentColor:"base",size:o,children:n})]})}),d.jsx("div",{className:hn({size:o}),children:f})]})]}):null});Wi.displayName="FieldSectionLayout";const Mr=class Mr extends mn{constructor(t){const{label:n=null,description:i=null,fields:a,conditions:o={},...s}=t;super(s);M(this,"type","section");M(this,"label");M(this,"description");M(this,"conditions");M(this,"fields",[]);M(this,"fieldObserver",()=>{this.notify(this)});M(this,"initFields",t=>{for(const n of t)n.observe(this.fieldObserver);return t});M(this,"conditionObserver",()=>{this.notify(this)});M(this,"initConditions",t=>{for(const n of Object.values(t).flat())n.observe(this.conditionObserver);return t});this.label=n,this.description=i,this.fields=this.initFields(a),this.conditions=this.initConditions(o)}serialize(){const t={};for(const[n,i]of Object.entries(this.conditions))t[n]=i.map(a=>a.serialize());return{...super.serialize(),label:this.label,description:this.description,conditions:t,fields:this.fields.map(n=>n.serialize())}}getOptions(){return{...super.getOptions(),label:this.label,description:this.description,fields:this.fields,conditions:this.conditions}}duplicate(t){return new Mr({...this.getOptions(),identifier:t,fields:this.fields.map(n=>n.duplicate(U.v4()))})}setOptions(t){const{label:n,description:i,fields:a,conditions:o,...s}=t;this.label=n??this.label,this.description=i??this.description,this.fields=a||this.fields,this.conditions=o||this.conditions,super.setOptions(s)}getErrors(t){const n={};for(const i of this.fields){const a=i.getError(t[i.identifier]);a&&(n[i.identifier]=a)}return n}getFields(){return this.fields}addField(t,n){const i=[...this.fields];i.splice(n??this.fields.length,0,t),this.fields=this.initFields(i),this.notify(this)}moveField(t,n){const i=[...this.fields],[a]=i.splice(t,1);i.splice(n,0,a),this.fields=i,this.notify(this)}removeField(t){this.fields=this.initFields(this.fields.filter(({identifier:i})=>i!==t.identifier));const n={};for(const[i,a]of Object.entries(this.conditions))n[i]=a.filter(o=>o.field.identifier!==t.identifier);this.conditions=n,this.notify(this)}getConditions(t){return this.conditions[t]}addCondition(t,n){this.conditions=this.initConditions({...this.conditions,[t]:[...this.conditions[t]??[],n]}),this.notify(this)}addConditions(t,n){this.conditions=this.initConditions({...this.conditions,[t]:[...this.conditions[t]??[],...n]}),this.notify(this)}removeCondition(t,n){this.conditions=this.initConditions({...this.conditions,[t]:(this.conditions[t]??[]).filter(i=>i.id!==n.id)}),this.notify(this)}removeConditions(t,n){const i=new Set(n.map(a=>a.id));this.conditions=this.initConditions({...this.conditions,[t]:(this.conditions[t]??[]).filter(a=>!i.has(a.id))}),this.notify(this)}getConditionals(){return new Set(Object.keys(this.conditions))}addConditional(t){this.conditions=this.initConditions({...this.conditions,[t]:[]}),this.notify(this)}removeConditional(t){const n={...this.conditions};delete n[t],this.conditions=this.initConditions(n),this.notify(this)}render(){return d.jsx(Wi,{fieldSection:this})}};M(Mr,"deserialize",t=>{const n=t.fields.map(dn),i={};for(const[a,o]of Object.entries(t.conditions))i[a]=Ri(n,o);return new Mr({...t,fields:n,conditions:i})});let qe=Mr;const nt=y.createContext({}),pn=y.memo(r=>{const{children:e,variant:t,size:n,accentColor:i,onSelectFieldType:a,...o}=r,s=y.useMemo(()=>{const l={[W.Assessment]:[],[W.Capture]:[],[W.Numeric]:[],[W.Selection]:[],[W.Temporal]:[],[W.Text]:[],[W.Verification]:[]};for(const u of Mo){const{group:c}=ue[u];l[c].push(u)}return l},[]);return d.jsxs(v.Menu.Root,{...o,children:[d.jsx(v.Menu.ClickTrigger,{children:e}),d.jsx(v.Menu.Content,{variant:t,size:n,accentColor:i,children:d.jsx(v.Menu.Scroll,{children:Object.entries(s).map(([l,u])=>{const{name:c}=Do[l];return u.length===0?null:d.jsxs(v.Menu.Group,{children:[d.jsx(v.Menu.Label,{children:c}),u.map(f=>d.jsx(Ys,{fieldType:f,onSelectFieldType:a},f))]},l)})})})]})});pn.displayName="CreateFieldDropdownMenu";const Ys=y.memo(r=>{const{fieldType:e,onSelectFieldType:t}=r,n=y.useCallback(()=>{t(e)},[e,t]),{icon:i,name:a}=ue[e];return d.jsxs(v.Menu.Item,{onSelect:n,children:[d.jsx(v.LuIcon,{icon:i}),d.jsx(v.Text,{className:"truncate",children:a})]})});Ys.displayName="CreateFieldDropdownMenuItem";const vn=r=>{switch(r){case"text":return new Mt({label:"",required:!1,identifier:U.v4()});case"boolean":return new yt({label:"",required:!1,identifier:U.v4()});case"number":return new Pe({label:"",required:!1,identifier:U.v4()});case"date":return new Lt({label:"",required:!1,identifier:U.v4()});case"time":return new Xt({label:"",required:!1,identifier:U.v4()});case"string":return new Tt({label:"",required:!1,identifier:U.v4()});case"url":return new Wt({label:"",required:!1,identifier:U.v4()});case"select":return new ot({label:"",options:[],required:!1,identifier:U.v4()});case"multi-string":return new xt({label:"",required:!1,identifier:U.v4()});case"multi-select":return new it({label:"",options:[],required:!1,identifier:U.v4()});case"upload":return new Dt({label:"",required:!1,identifier:U.v4(),maximum_files:6,maximum_size:jt});case"qr":return new $t({label:"",required:!1,identifier:U.v4()});case"radio":return new At({label:"",options:[],required:!1,identifier:U.v4()});case"checkbox-list":return new Ct({label:"",options:[],required:!1,identifier:U.v4()});case"pass-fail":return new _t({label:"",required:!1,identifier:U.v4(),showNotesAndFilesOn:["fail"]});case"otp":return new mt({label:"",validationType:"none",required:!1,identifier:U.v4(),length:6});case"rating":return new St({label:"",required:!1,identifier:U.v4(),maxRating:5})}},ji=r=>{switch(r.type){case"text":return new Or({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"boolean":return new pr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"number":return new Cr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"date":return new gr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"time":return new br({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"string":return new Ir({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"url":return new Tr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"select":return new Er({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"multi-string":return new yr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"multi-select":return new xr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"upload":return new Nr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"qr":return new Sr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"radio":return new _r({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"checkbox-list":return new vr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"pass-fail":return new wr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"otp":return new mr({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r});case"rating":return new Ar({id:U.v4(),conditionValue:void 0,conditionModifier:"equals",field:r})}},Zs=(r,e)=>{switch(r){case"checkbox-list":return Ct.getFieldCreationSchema(e);case"multi-select":return it.getFieldCreationSchema(e);case"number":return Pe.getFieldCreationSchema(e);case"radio":return At.getFieldCreationSchema(e);case"select":return ot.getFieldCreationSchema(e);case"string":return Tt.getFieldCreationSchema(e);case"text":return Mt.getFieldCreationSchema(e);case"upload":return Dt.getFieldCreationSchema(e);case"pass-fail":return _t.getFieldCreationSchema(e);case"otp":return mt.getFieldCreationSchema(e);case"rating":return St.getFieldCreationSchema(e);default:return}},Ks=y.memo(r=>{const{popoverInputs:e,...t}=r;return d.jsxs(v.Popover.Root,{children:[d.jsx(v.Popover.Trigger,{asChild:!0,children:d.jsxs(v.Button,{variant:"soft",type:"button",size:"sm",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:Hl}),"Settings"]})}),d.jsx(v.Popover.Content,{size:"sm",...t,children:d.jsx("div",{className:$e.cx("flex w-full max-w-[350px] flex-col",hn({size:"sm"})),children:e})})]})});Ks.displayName="FieldSettingsPopover";const Qs=y.memo(r=>{const{parentPath:e,fieldIndex:t,field:n}=r,i=Pr(),{disableRequiredFields:a}=y.use(nt),[o,s]=y.useState(void 0);y.useEffect(()=>{n.image instanceof Promise?n.image.then(s).catch(console.error):s(n.image)},[n]);const l=y.useCallback(()=>{n.setOptions({image:void 0})},[n]),[u,c]=y.useMemo(()=>{const S=[],O=[],N=Zs(n.type,`${e}.${t}`)??[];for(const T of N)T.showDirectly?S.push(T.field):O.push(T.field);return[S,O]},[n,e,t]),f=Br(u),h=Br(c),p=c.length>0,g=y.useCallback(()=>{o&&i(()=>({file:o}))},[i,o]),x=y.useCallback(S=>{n.setOptions({required:!!S})},[n]),m=y.useCallback(S=>{n.setOptions({label:S.target.value})},[n]),w=y.useCallback(S=>{n.setOptions({description:S.target.value})},[n]),{icon:A,name:E}=ue[n.type];return d.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[d.jsxs("div",{className:"flex w-full justify-between gap-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(v.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[d.jsx(v.LuIcon,{icon:A}),E]}),!a&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(v.Checkbox.Root,{checked:n.required,onCheckedChange:x,size:"sm",children:d.jsx(v.Checkbox.Indicator,{children:d.jsx(v.LuIcon,{icon:ke})})}),d.jsx(v.Text,{size:"sm",accentColor:"base",children:"Required"})]})]}),p&&d.jsx(Ks,{popoverInputs:h,align:"end"})]}),o&&d.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[d.jsx(Bt,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:o,onClick:g}),d.jsx(v.IconButton,{type:"button",className:"group-hover:not-disabled:flex absolute right-2 top-2 hidden",variant:"solid",accentColor:"base","aria-label":"delete",onClick:l,size:"sm",children:d.jsx(v.LuIcon,{icon:gt})})]}),d.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[d.jsx(v.Input.Root,{variant:"outline",size:"md",children:d.jsx(v.Input.Field,{placeholder:"Enter your question",value:n.label??"",onChange:m,maxLength:200})}),d.jsx(v.TextArea,{className:"field-sizing-content",placeholder:"Enter a field description (optional)",value:n.description??"",onChange:w,maxLength:1e3,resize:"vertical",size:"md"})]}),u.length>0&&d.jsx("div",{className:$e.cx("w-full",hn({size:"sm"})),children:f})]})});Qs.displayName="FieldBuilder";const Yi=y.memo(r=>{const{field:e,fieldSection:t,fieldIndex:n,sectionIndex:i}=r,a=y.useRef(null),o=`fields.${i}.fields`,s=y.useCallback(x=>{t.addField(vn(x),n+1)},[n,t]),l=y.useCallback(()=>{t.addField(e.duplicate(U.v4()))},[e,t]),u=y.useCallback(x=>{const m=x==="up"?i-1:i+1;t.moveField(n,m)},[t,n,i]),c=y.useCallback(x=>{const{files:m}=x.target;if(!m||m.length!==1)return;const w=m.item(0);if(w){if(w.size>Vo){v.toast.error({title:"File upload error",description:`The file ${w.name} exceeded the maximum file size`});return}e.setOptions({image:w})}},[e]),f=y.useCallback(()=>{u("up")},[u]),h=y.useCallback(()=>{u("down")},[u]),p=y.useCallback(()=>{var x;(x=a.current)==null||x.click()},[]),g=y.useCallback(()=>{t.removeField(e)},[e,t]);return d.jsxs(v.Card,{className:"flex w-full items-center justify-between gap-4",size:"sm",children:[d.jsx(Qs,{fieldIndex:n,field:e,parentPath:o}),d.jsxs(v.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[d.jsx(pn,{onSelectFieldType:s,size:"sm",children:d.jsx(v.IconButton,{type:"button",children:d.jsx(v.LuIcon,{icon:Ze})})}),d.jsx(v.IconButton,{type:"button",onClick:f,children:d.jsx(v.LuIcon,{icon:ga})}),d.jsx(v.IconButton,{type:"button",onClick:h,children:d.jsx(v.LuIcon,{icon:va})}),d.jsx(v.IconButton,{type:"button",onClick:l,children:d.jsx(v.LuIcon,{icon:xn})}),d.jsx(v.IconButton,{type:"button",onClick:p,children:d.jsx(v.LuIcon,{icon:ha})}),d.jsx(v.IconButton,{type:"button",onClick:g,children:d.jsx(v.LuIcon,{icon:gt})})]}),d.jsx("input",{className:"hidden",ref:a,type:"file",accept:"image/*",onChange:c})]})});Yi.displayName="FieldBuilderWithActions";const Zi=y.memo(r=>{const{children:e,variant:t,size:n,accentColor:i,fields:a,onSelectField:o,...s}=r;return d.jsxs(v.Menu.Root,{...s,children:[d.jsx(v.Menu.ClickTrigger,{children:e}),d.jsx(v.Menu.Content,{variant:t,size:n,accentColor:i,children:d.jsx(v.Menu.Scroll,{children:a.map(l=>d.jsx(Js,{field:l,onSelectField:o},l.identifier))})})]})});Zi.displayName="FieldDropdownMenu";const Js=y.memo(r=>{const{field:e,onSelectField:t}=r,n=y.useCallback(()=>{t(e)},[e,t]);return d.jsxs(v.Menu.Item,{onSelect:n,children:[d.jsx(v.LuIcon,{icon:ue[e.type].icon}),e.label||Ce]})});Js.displayName="FieldDropdownMenuItem";const el=y.memo(r=>{const{children:e,variant:t,size:n,accentColor:i,fieldSections:a,onSelectFieldSection:o,...s}=r;return d.jsxs(v.Menu.Root,{...s,children:[d.jsx(v.Menu.ClickTrigger,{children:e}),d.jsx(v.Menu.Content,{variant:t,size:n,accentColor:i,children:a.map(l=>d.jsx(tl,{fieldSection:l,onSelectFieldSection:o},l.identifier))})]})});el.displayName="FieldSectionDropdownMenu";const tl=y.memo(r=>{const{fieldSection:e,onSelectFieldSection:t}=r,n=y.useCallback(()=>{t(e)},[e,t]);return d.jsxs(v.Menu.Item,{onSelect:n,children:[d.jsx(v.LuIcon,{icon:pa}),e.label||bi]})});tl.displayName="FieldSectionDropdownMenuItem";const rl=y.memo(r=>{const{id:e,sourceX:t,sourceY:n,targetX:i,targetY:a,style:o,markerEnd:s,data:l}=r,{targetSection:u,sourceSection:c,layoutDirection:f}=l,h=y.useMemo(()=>c.getConditions(u.identifier),[c,u.identifier]),p=y.useCallback(()=>{c.removeConditional(u.identifier)},[c,u.identifier]),g=y.useCallback(E=>{c.addCondition(u.identifier,ji(E))},[c,u.identifier]),x=y.useCallback(E=>{c.removeCondition(u.identifier,E)},[c,u.identifier]),[m,w,A]=le.getBezierPath({sourceX:t,sourceY:n,sourcePosition:f==="LR"?le.Position.Right:le.Position.Bottom,targetX:i,targetY:a,targetPosition:f==="LR"?le.Position.Left:le.Position.Top});return d.jsxs(d.Fragment,{children:[d.jsx(le.BaseEdge,{id:e,path:m,style:o,markerEnd:s,labelX:w,labelY:A}),d.jsx(le.EdgeLabelRenderer,{children:d.jsxs(v.Card,{size:"xs",variant:"surface",className:"nodrag nopan bg-(--base-2) pointer-events-auto absolute inline-flex flex-col gap-2",onMouseDown:v.stopPropagation,onClick:v.stopPropagation,"data-floating-content":"",style:{transform:`translate(-50%, -50%) translate(${w}px, ${A}px)`},children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(v.Text,{size:"xs",className:"max-w-[280px] truncate",children:c.label||"Untitled section"}),d.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[d.jsx(Zi,{fields:c.fields,onSelectField:g,children:d.jsx(v.IconButton,{"aria-label":"Add condition",type:"button",variant:"surface",size:"xs",accentColor:"base",children:d.jsx(v.LuIcon,{icon:Ze})})}),d.jsxs(v.Tooltip.Root,{children:[d.jsx(v.Tooltip.Trigger,{asChild:!0,children:d.jsx(v.IconButton,{"aria-label":"Remove conditional logic",type:"button",variant:"surface",size:"xs",accentColor:"base",color:"danger",onClick:p,children:d.jsx(v.LuIcon,{icon:gt})})}),d.jsx(v.Tooltip.Content,{size:"sm",children:"Remove conditional logic"})]})]})]}),h.length>0&&d.jsx("div",{className:"flex h-max w-full flex-col flex-wrap gap-1",children:h.map(E=>d.jsx(y.Fragment,{children:E.render({onRemove:x})},E.id))})]})})]})});rl.displayName="FieldSectionConditionEdgeComponent";const nl=y.memo(r=>{const{data:e,selected:t}=r,{fieldSection:n,index:i,layoutDirection:a}=e,{fieldSchema:o}=y.use(nt),s=y.useCallback(()=>{o.removeFieldSection(n)},[o,n]),l=y.useCallback(p=>{n.addField(vn(p))},[n]),u=y.useCallback(()=>{const p=new qe({identifier:U.v4(),fields:[]});o.addFieldSection(p),n.addConditional(p.identifier)},[o,n]),c=y.useCallback(()=>{o.addFieldSection(n.duplicate(U.v4()))},[o,n]),f=y.useCallback(p=>{n.setOptions({label:p.target.value})},[n]),h=y.useCallback(p=>{n.setOptions({description:p.target.value})},[n]);return d.jsxs(v.Card,{variant:"surface",className:"bg-(--base-2) relative cursor-pointer",size:"sm","data-selected":t?"true":void 0,children:[d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[d.jsx(v.Input.Root,{variant:"outline",size:"md",accentColor:"base",children:d.jsx(v.Input.Field,{placeholder:"Enter a section label (optional)",value:n.label??"",onChange:f,maxLength:200})}),d.jsx(v.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:n.description??"",onChange:h,maxLength:1e3,resize:"vertical",size:"md"})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(v.Text,{weight:"bold",children:"Fields"}),d.jsx(pn,{onSelectFieldType:l,size:"sm",children:d.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",accentColor:"base",children:[d.jsx(v.LuIcon,{icon:Ze})," Add field"]})})]}),d.jsx("div",{className:"flex flex-col gap-3",children:n.fields.map((p,g)=>d.jsx(Yi,{field:p,fieldSection:n,fieldIndex:g,sectionIndex:i},p.identifier))})]}),d.jsx(le.NodeToolbar,{isVisible:!0,position:le.Position.Right,align:"start",offset:8,onMouseDown:v.stopPropagation,children:d.jsx(v.Card,{variant:"surface",className:"bg-(--base-2) flex flex-col items-center gap-1 p-1",size:"xs",onClick:v.stopPropagation,children:d.jsxs(v.ButtonGroup,{className:"flex flex-col gap-2",variant:"surface",size:"xs",accentColor:"base",children:[d.jsx(v.IconButton,{type:"button",onClick:u,children:d.jsx(v.LuIcon,{icon:Vl})}),d.jsx(v.IconButton,{type:"button",onClick:c,children:d.jsx(v.LuIcon,{icon:xn})}),d.jsx(v.IconButton,{type:"button",onClick:s,children:d.jsx(v.LuIcon,{icon:gt})})]})})}),d.jsx(le.Handle,{type:"target",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:a==="LR"?le.Position.Left:le.Position.Top}),d.jsx(le.Handle,{type:"source",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:a==="LR"?le.Position.Right:le.Position.Bottom})]})});nl.displayName="CustomNode";const jf={fieldSection:nl},Yf={fieldSectionCondition:rl},Zf=(r,e,t)=>{const n=new na.graphlib.Graph().setDefaultEdgeLabel(()=>({}));return n.setGraph({rankdir:t,nodesep:200,edgesep:500,ranksep:500}),e.forEach(i=>n.setEdge(i.source,i.target,{width:500,height:200,labelpos:"c"})),r.forEach(i=>{var a,o;return n.setNode(i.id,{...i,width:((a=i.measured)==null?void 0:a.width)??0,height:((o=i.measured)==null?void 0:o.height)??0})}),na.layout(n),[r.map(i=>{var l,u;const a=n.node(i.id),o=a.x-(((l=i.measured)==null?void 0:l.width)??0)/2,s=a.y-(((u=i.measured)==null?void 0:u.height)??0)/2;return{...i,position:{x:o,y:s}}}),e]},Kf={hideAttribution:!0},il=y.memo(()=>{var z;const{errors:r}=Ye.useFormState(),{handleSubmit:e}=Ye.useFormContext(),{onSave:t,onCancel:n}=y.use(nt),{fieldSchema:i}=y.use(nt),a=y.useRef(null),[o,s]=y.useState(),[l,u]=y.useState("TB");y.useLayoutEffect(()=>{a.current&&a.current.classList.remove("light")},[]);const c=y.useMemo(()=>i.fieldSections.map((K,G)=>({id:K.identifier,position:{x:0,y:0},data:{index:G,fieldSection:K,layoutDirection:l},draggable:!0,type:"fieldSection"})),[i.fieldSections,l]),f=y.useMemo(()=>{const K=[],G={};for(const Y of i.fieldSections)G[Y.identifier]=Y;for(const Y of i.fieldSections){const Me=Y.conditions;for(const[He,Dr]of Object.entries(Me))K.push({id:`${Y.identifier}-${He}`,source:Y.identifier,target:He,data:{targetSection:G[He],sourceSection:Y,layoutDirection:l},animated:Dr.length>0,markerEnd:le.MarkerType.Arrow,style:{strokeWidth:2,stroke:"var(--base-a8)"},type:"fieldSectionCondition"})}return K},[i.fieldSections,l]),[h,p,g]=le.useNodesState(c),[x,m,w]=le.useEdgesState(f);y.useEffect(()=>{p(c)},[c,p]),y.useEffect(()=>{m(f)},[f,m]);const[A,E]=y.useMemo(()=>Zf(h,x,l),[x,l,h]),S=y.useCallback(()=>{i.addFieldSection(new qe({identifier:U.v4(),fields:[]}))},[i]),O=y.useCallback(K=>{const{source:G,target:Y}=K,Me=i.fieldSections.find(({identifier:He})=>He===G);Me.setOptions({conditions:{...Me.conditions,[Y]:[]}})},[i.fieldSections]),N=y.useCallback(K=>{const G=i.getSectionDependencyGraph();return!ea.willCreateCycle(G,K.source,K.target)},[i]),T=y.useCallback(()=>{o==null||o.zoomOut()},[o]),V=y.useCallback(()=>{o==null||o.zoomIn()},[o]),L=y.useCallback(()=>{o==null||o.fitView()},[o]);return d.jsxs("form",{className:"flex size-full flex-col gap-4",onSubmit:e(t),children:[d.jsxs(v.Card,{className:"relative size-full",variant:"outline",children:[d.jsx(le.ReactFlow,{ref:a,onInit:s,nodes:A,onNodesChange:g,edges:E,onEdgesChange:w,nodeTypes:jf,edgeTypes:Yf,onConnect:O,attributionPosition:"bottom-left",fitView:!0,minZoom:0,isValidConnection:N,proOptions:Kf}),d.jsx(le.Panel,{position:"top-left",children:d.jsx(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:d.jsxs(v.Button,{type:"button",variant:"surface",onClick:S,children:[d.jsx(v.LuIcon,{icon:Ze})," Add section"]})})}),d.jsxs(le.Panel,{position:"top-right",className:"flex flex-col items-center gap-2",children:[d.jsxs(v.ToggleGroup.Root,{className:"flex flex-col",type:"single",accentColor:"base",size:"sm",value:l,onValueChange:u,children:[d.jsx(v.ToggleGroup.IconItem,{className:"rounded-b-none",value:"LR",type:"button",children:d.jsx(v.LuIcon,{icon:Al})}),d.jsx(v.ToggleGroup.IconItem,{className:"rounded-t-none",value:"TB",type:"button",children:d.jsx(v.LuIcon,{icon:_l})})]}),d.jsx(v.Separator,{size:"sm"}),d.jsxs(v.ButtonGroup,{className:"flex flex-col",size:"sm",accentColor:"base",variant:"soft",children:[d.jsx(v.IconButton,{className:"rounded-b-none",onClick:V,type:"button",children:d.jsx(v.LuIcon,{icon:Ze})}),d.jsx(v.IconButton,{onClick:T,radius:"none",type:"button",children:d.jsx(v.LuIcon,{icon:Vr})}),d.jsx(v.IconButton,{className:"rounded-t-none",onClick:L,type:"button",children:d.jsx(v.LuIcon,{icon:$l})})]})]}),d.jsx(le.Panel,{position:"bottom-right",children:d.jsxs(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[n&&d.jsx(v.Button,{type:"button",variant:"soft",accentColor:"base",onClick:n,children:"Cancel"}),d.jsx(v.Button,{type:"submit",variant:"surface",children:"Save"})]})})]}),!!((z=r.fields)!=null&&z.message)&&d.jsx(v.Text,{size:"xs",accentColor:"danger",children:r.fields.message})]})});il.displayName="FormBuilderFlowBuilder";const Qf=(r,e,t={})=>{const{conditions:n=!1}=t,i=r.get(e.identifier);if(!i)throw new Error(`Attempting to reseed serialized section with identifier ${e.identifier} which is not present in the reseeded identifier map`);const a=new Map,o=e.fields.map(l=>{const u=U.v4(),{image:c,...f}=l;return a.set(l.identifier,u),{...f,identifier:u}}),s={};if(n)for(const[l,u]of Object.entries(e.conditions??{})){const c=r.get(l);if(!c)continue;const f=u.map(h=>{const p=a.get(h.fieldId);if(!p)throw new Error(`Serialized condition referencing undefined field with identifier: ${h.fieldId}`);return{...h,fieldId:p}});s[c]=f}return{...e,identifier:i,conditions:s,fields:o}},Jf=(r,e={})=>{const t=new Map(r.map(n=>[n.identifier,U.v4()]));return r.map(n=>Qf(t,n,e))},Ki=(r,e)=>{const t={},n=r.filter(i=>i instanceof qe);for(const i of r)if(i instanceof qe){const a=n.filter(s=>i.identifier in s.conditions);if(a.length>0&&!a.some(s=>{const l=s.getConditions(i.identifier);return new cn(l).applyConditions(e)}))continue;const o=i.getErrors(e);Object.assign(t,o)}else{if(!(i instanceof Ve))throw new Error("Invalid field type");const a=i.identifier,o=i.getError(ia(e,a));o&&vl(t,a,o)}return t},e1=async r=>{const e={},t=[];for(const n of r){const{fields:i}=n,a=[];for(const o of i){if(o.image){if(o.image instanceof Promise)try{e[o.identifier]=await o.image}catch(s){console.error("Failed to get image from promise",s)}else e[o.identifier]=o.image;delete o.image}a.push(o)}t.push({...n,fields:a})}return{fields:t,images:e}};async function t1(r){const e={};for(const[t,n]of Object.entries(r))e[t]=await Promise.all(n);return e}class Pt extends er{constructor(t){super();M(this,"fieldSections");M(this,"fieldObserver",()=>{this.notify(this)});M(this,"initFields",t=>{for(const n of t)n.observe(this.fieldObserver);return t});this.fieldSections=this.initFields(t)}serialize(){return this.fieldSections.map(t=>t.serialize())}static deserialize(t){return new Pt(t.map(qe.deserialize))}static reseedFieldSections(t,n){return Jf(t,n)}getFields(){return this.fieldSections.flatMap(t=>t.getFields())}getFieldSections(){return this.fieldSections}addFieldSection(t,n){const i=[...this.fieldSections];i.splice(n??this.fieldSections.length,0,t),this.fieldSections=this.initFields(i),this.notify(this)}removeFieldSection(t){const n=this.fieldSections.filter(i=>i.identifier!==t.identifier);for(const i of n)i.removeConditional(i.identifier);this.fieldSections=this.initFields(n),this.notify(this)}moveFieldSection(t,n){const i=[...this.fieldSections],[a]=i.splice(t,1);i.splice(n,0,a),this.fieldSections=this.initFields(i),this.notify(this)}getSectionDependencyGraph(){const t=new hl.DirectedGraph({type:"directed"});for(const n of this.fieldSections)for(const i of Object.keys(n.conditions))t.mergeEdge(n.identifier,i);return t}getDependenciesOfSection(t){const n=this.getSectionDependencyGraph(),i=new Map(this.fieldSections.map(o=>[o.identifier,o])),a=[];return pl.bfsFromNode(n,t,(o,s,l)=>{a.push(i.get(o))},{mode:"in"}),a}cleanValues(t){return fn(this.getFields(),t)}cleanSerializedValues(t){return qi(this.getFields(),t)}deserializeValues(t,n){return Gs(this.getFields(),t,n)}serializeValues(t,n){return Rs(this.getFields(),t,n)}initializeValues(t){return $s(this.getFields(),t)}validateValues(t){return Ki(this.getFieldSections(),t)}areValuesValid(t){return Object.keys(this.validateValues(t)).length===0}deserializeConditions(t){return Ri(this.getFields(),t)}cleanConditions(t){return Hi(this.getFields(),t)}serializeConditions(t){return ks(this.getFields(),t)}cleanSerializedConditions(t){return Gi(this.getFields(),t)}changedFieldValues(t,n){return Xs(this.getFields(),t,n)}unchangedFieldValues(t,n){return Ws(this.getFields(),t,n)}areValuesEqual(t,n){return $i(this.getFields(),t,n)}areValuesBlank(t){return js(this.getFields(),t)}blankValues(){return Xi(this.getFields())}extractFilesAndPromisesFromFieldValues(t){return Hs(this.getFields(),t)}insertFilesAndPromisesToFieldValues(t,n){return qs(this.getFields(),t,n)}}const al=y.memo(r=>{const{sourceFieldSection:e,targetFieldSection:t}=r,n=y.useMemo(()=>e.getConditions(t.identifier),[e,t.identifier]),i=y.useCallback(()=>{e.removeConditional(t.identifier)},[e,t.identifier]),a=y.useCallback(s=>{e.addCondition(t.identifier,ji(s))},[e,t.identifier]),o=y.useCallback(s=>{e.removeCondition(t.identifier,s)},[e,t.identifier]);return d.jsxs(v.Card,{className:"flex flex-col gap-2",size:"sm",children:[d.jsxs(v.ButtonGroup,{className:"flex justify-between gap-2",size:"sm",accentColor:"base",variant:"soft",children:[d.jsxs(v.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[d.jsx(v.LuIcon,{icon:pa}),e.label??bi]}),d.jsx(v.IconButton,{type:"button",onClick:i,variant:"ghost",children:d.jsx(v.LuIcon,{icon:gt})})]}),d.jsxs("div",{className:"flex h-max w-full flex-wrap gap-2",children:[n.map(s=>s.render({onRemove:o})),d.jsx(Zi,{fields:e.fields,onSelectField:a,align:"start",children:d.jsx(v.IconButton,{type:"button",size:"sm",variant:"soft",accentColor:"base",children:d.jsx(v.LuIcon,{icon:Ze})})})]})]})});al.displayName="FieldSectionConditionalItem";const ol=y.memo(r=>{const{fieldSection:e}=r,{fieldSchema:t}=y.use(nt),n=y.useMemo(()=>t.fieldSections.filter(l=>e.identifier in l.conditions),[t.fieldSections,e.identifier]),i=y.useCallback(l=>{l.addConditional(e.identifier)},[e.identifier]),a=y.useCallback(l=>{e.setOptions({label:l.target.value})},[e]),o=y.useCallback(l=>{e.setOptions({description:l.target.value})},[e]),s=y.useMemo(()=>{const l=t.getSectionDependencyGraph();return t.fieldSections.filter(u=>!ea.willCreateCycle(l,u.identifier,e.identifier))},[e.identifier,t]);return d.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[d.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[d.jsx(v.Input.Root,{variant:"outline",size:"md",children:d.jsx(v.Input.Field,{placeholder:"Enter a section label (optional)",value:e.label??"",onChange:a,maxLength:200})}),d.jsx(v.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:e.description??"",onChange:o,maxLength:1e3,resize:"vertical",size:"md"})]}),d.jsx(v.Separator,{size:"full"}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex justify-between gap-2",children:[d.jsx(v.Text,{accentColor:"base",children:"Conditions"}),d.jsx(el,{fieldSections:s,onSelectFieldSection:i,children:d.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",className:"w-max",children:[d.jsx(v.LuIcon,{icon:Ze}),"Add condition"]})})]}),n.map(l=>d.jsx(al,{sourceFieldSection:l,targetFieldSection:e},l.identifier))]}),d.jsx(v.Separator,{size:"full"})]})});ol.displayName="FieldSectionBuilder";const sl=y.memo(r=>{const{fieldSection:e,sectionIndex:t}=r,{fieldSchema:n}=y.use(nt),i=v.useAlertDialog(),a=y.useCallback(()=>{n.removeFieldSection(e)},[n,e]),o=y.useCallback(x=>{const m=x==="up"?t-1:t+1;n.moveFieldSection(t,m)},[n,t]),s=y.useCallback(()=>{n.addFieldSection(e.duplicate(U.v4()))},[n,e]),l=y.useCallback(x=>{e.addField(vn(x))},[e]),u=y.useCallback(()=>{o("up")},[o]),c=y.useCallback(()=>{o("down")},[o]),f=y.useCallback(async()=>{const x=[e.serialize()],m=Pt.reseedFieldSections(x,{conditions:!1}),w=JSON.stringify(m);await navigator.clipboard.writeText(w),v.toast.success({title:"Section copied"})},[e]),h=y.useCallback(async()=>{const m=n.getDependenciesOfSection(e.identifier).map(E=>E.serialize()),w=Pt.reseedFieldSections(m,{conditions:!0}),A=JSON.stringify(w);await navigator.clipboard.writeText(A),v.toast.success({title:"Section copied"})},[e,n]),p=y.useCallback(async()=>{const x=n.getDependenciesOfSection(e.identifier),m=x.length>1,w=x.length-1;m?i({title:"Copy section dependencies?",description:`This section has ${w} dependent section${w>1?"s":""} that will also be copied to maintain the conditions. Do you want to include these dependencies?`,action:"Include",onAction:h,cancel:"Dont include",onCancel:f}):f()},[e,n,i,h,f]),g=y.useCallback(async()=>{let x="";try{x=await navigator.clipboard.readText()}catch{v.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const m=x.trim();if(!m){v.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let w;try{w=JSON.parse(m)}catch{v.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const A=Array.isArray(w)?w:[w],E=[];for(const S of A){if(!S||typeof S!="object")continue;const O=S;if(O.type!=="section"||!Array.isArray(O.fields))continue;const N={type:"section",identifier:typeof O.identifier=="string"?O.identifier:U.v4(),label:typeof O.label=="string"||O.label===null?O.label:null,description:typeof O.description=="string"||O.description===null?O.description:null,conditions:O.conditions&&typeof O.conditions=="object"?O.conditions:{},fields:O.fields};try{E.push(qe.deserialize(N))}catch{}}if(E.length===0){v.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}E.forEach((S,O)=>{n.addFieldSection(S,t+1+O)}),v.toast.success({title:"Section pasted",description:"Serialized JSON imported successfully."})},[n,t]);return d.jsxs(v.Card,{variant:"outline",className:"flex w-full items-center justify-between gap-4",size:"sm",children:[d.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[d.jsx(ol,{fieldSection:e}),d.jsxs("div",{className:"flex w-full flex-col gap-2",children:[d.jsxs("div",{className:"flex justify-between gap-2",children:[d.jsx(v.Text,{accentColor:"base",size:"md",children:"Fields"}),d.jsx(pn,{onSelectFieldType:l,size:"sm",children:d.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",children:[d.jsx(v.LuIcon,{icon:Ze})," Add field"]})})]}),e.fields.map((x,m)=>d.jsx(Yi,{field:x,fieldSection:e,fieldIndex:m,sectionIndex:t},x.identifier))]})]}),d.jsxs(v.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[d.jsx(v.IconButton,{type:"button",onClick:u,children:d.jsx(v.LuIcon,{icon:ga})}),d.jsx(v.IconButton,{type:"button",onClick:c,children:d.jsx(v.LuIcon,{icon:va})}),d.jsxs(v.Menu.Root,{align:"end",children:[d.jsx(v.Menu.ClickTrigger,{children:d.jsx(v.IconButton,{type:"button",children:d.jsx(v.LuIcon,{icon:da})})}),d.jsxs(v.Menu.Content,{size:"sm",children:[d.jsxs(v.Menu.Item,{onSelect:s,children:[d.jsx(v.LuIcon,{icon:xn}),"Duplicate section"]}),d.jsxs(v.Menu.Item,{onSelect:p,children:[d.jsx(v.LuIcon,{icon:la}),"Copy JSON"]}),d.jsxs(v.Menu.Item,{onSelect:g,children:[d.jsx(v.LuIcon,{icon:ua}),"Paste JSON"]}),d.jsxs(v.Menu.Item,{onSelect:a,children:[d.jsx(v.LuIcon,{icon:gt}),"Delete section"]})]})]})]})]})});sl.displayName="FieldSectionWithActions";const ll=y.memo(()=>{var l;const{handleSubmit:r}=Ye.useFormContext(),{errors:e}=Ye.useFormState(),{onSave:t,onCancel:n}=y.use(nt),{fieldSchema:i}=y.use(nt),a=y.useCallback(()=>{i.addFieldSection(new qe({identifier:U.v4(),fields:[]}))},[i]),o=y.useCallback(async()=>{try{const u=i.serialize(),c=Pt.reseedFieldSections(u),f=JSON.stringify(c);await navigator.clipboard.writeText(f),v.toast.success({title:"Sections copied",description:"All sections JSON copied to clipboard."})}catch{v.toast.error({title:"Copy failed",description:"Unable to copy the sections JSON."})}},[i]),s=y.useCallback(async()=>{let u="";try{u=await navigator.clipboard.readText()}catch{v.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const c=u.trim();if(!c){v.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let f;try{f=JSON.parse(c)}catch{v.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const h=Array.isArray(f)?f:[f],p=[];for(const x of h){if(!x||typeof x!="object")continue;const m=x;if(m.type!=="section"||!Array.isArray(m.fields))continue;const w={type:"section",identifier:typeof m.identifier=="string"?m.identifier:U.v4(),label:typeof m.label=="string"||m.label===null?m.label:null,description:typeof m.description=="string"||m.description===null?m.description:null,conditions:m.conditions&&typeof m.conditions=="object"?m.conditions:{},fields:m.fields};try{p.push(qe.deserialize(w))}catch{}}if(p.length===0){v.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}const g=i.fieldSections.length;p.forEach((x,m)=>{i.addFieldSection(x,g+m)}),v.toast.success({title:"Sections pasted",description:"Serialized JSON imported successfully."})},[i]);return d.jsxs("form",{className:"flex flex-col gap-4",onSubmit:r(t),children:[d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{className:"flex items-center justify-end gap-2",children:[d.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",onClick:o,children:[d.jsx(v.LuIcon,{icon:la})," Copy JSON"]}),d.jsxs(v.Button,{type:"button",variant:"soft",size:"sm",onClick:s,children:[d.jsx(v.LuIcon,{icon:ua})," Paste JSON"]})]}),i.fieldSections.map((u,c)=>d.jsx(sl,{fieldSection:u,sectionIndex:c},u.identifier)),d.jsxs(v.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:a,children:[d.jsx(v.LuIcon,{icon:Ze})," Add section"]})]}),!!((l=e.fields)!=null&&l.message)&&d.jsx(v.Text,{size:"xs",accentColor:"danger",children:e.fields.message}),d.jsxs(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[n&&d.jsx(v.Button,{type:"button",variant:"soft",accentColor:"base",onClick:n,children:"Cancel"}),d.jsx(v.Button,{type:"submit",variant:"surface",children:"Save"})]})]})});ll.displayName="FormBuilderListBuilder";function ul(r){const e=t=>{const n={};for(const[i,a]of Object.entries(t))typeof a=="string"?n[i]={type:"validate",message:a}:n[i]=e(a);return n};return e(r)}const cl=y.memo(y.forwardRef((r,e)=>{const{disabled:t=!1,fieldSchema:n,values:i={},onValuesChange:a,onSubmit:o,submitText:s="Submit",hideSubmit:l=!1,cancelText:u,onCancel:c,hideCancel:f=!1,className:h,buttonProps:p,size:g="md"}=r,x=y.useMemo(()=>n.initializeValues(i),[n,i]),m=y.useCallback(T=>{o==null||o(T)},[o]),w=Ye.useForm({values:x,mode:"onBlur",criteriaMode:"all",disabled:t,resolver:T=>{const V=n.validateValues(T),L=ul(V);return Object.keys(V).length>0?{values:{},errors:L}:{values:T,errors:{}}}}),A=y.useCallback(T=>{a==null||a(T)},[a]);y.useEffect(()=>{const{unsubscribe:T}=w.watch((V,{type:L})=>{L==="change"&&A(V)});return()=>{T()}},[w,A]);const E=ma(n.getFieldSections()),S=y.useMemo(()=>({fieldSchema:n,size:g}),[n,g]),O=!f&&!!c,N=!l;return d.jsx(Ye.FormProvider,{...w,children:d.jsx(ce,{value:S,children:d.jsxs("form",{ref:e,className:$e.cx(h,"flex flex-col gap-4"),onSubmit:w.handleSubmit(m),children:[d.jsx("div",{className:Wf({size:g}),children:E}),!t&&(O||N)?d.jsxs(v.ButtonGroup,{className:"flex items-center justify-end gap-2",size:g,children:[O?d.jsxs(v.Button,{...p,accentColor:"base",type:"button",variant:"soft",onClick:c,children:[d.jsx(v.LuIcon,{icon:at}),u]}):null,N?d.jsxs(v.Button,{...p,type:"submit",accentColor:"primary",variant:"surface",children:[d.jsx(v.LuIcon,{icon:ke}),s]}):null]}):null]})})})})),dl=y.memo(()=>{const{fieldSchema:r}=y.use(nt);return d.jsx(cl,{fieldSchema:r,disabled:!1})});dl.displayName="FormBuilderPreview";const fl=y.memo(r=>{const{children:e,initialFields:t,onSave:n,onCancel:i,disableRequiredFields:a=!1}=r,o=y.useCallback(g=>{var E;const x={};(!g.fields||g.fields.length===0)&&(x.fields="At least one field is required.");const m=[];for(const[S,O]of g.fields.entries())for(const[N,T]of O.fields.entries()){const V=((E=Zs(T.type,`fields.${S}.fields.${N}`))==null?void 0:E.map(({field:L})=>L))??[];m.push(...V)}const w={};for(const S of m)w[S.identifier]=ia(g,S.identifier);const A=Ki(m,w);return Object.keys(A).length>0&&(x.fields=A.fields),Object.keys(x).length>0&&v.toast.error({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),x},[]),s=y.useMemo(()=>({fields:t??[]}),[t]),l=Ye.useForm({values:s,mode:"onSubmit",criteriaMode:"all",reValidateMode:"onSubmit",resolver:g=>{const x=o(g),m=ul(x);return Object.keys(x).length>0?{values:{},errors:m}:{values:g,errors:{}}}}),u=y.useCallback(g=>{l.setValue("fields",g.serialize())},[l]),c=Ye.useWatch({control:l.control,compute:g=>g.fields}),f=y.useMemo(()=>{const g=Pt.deserialize(c);return g.observe(u),g},[c,u]),h=y.useMemo(()=>({fieldSchema:f,disableRequiredFields:a,onSave:n,onCancel:i}),[a,n,i,f]),p=y.useMemo(()=>({fieldSchema:f,size:"sm"}),[f]);return d.jsx(nt,{value:h,children:d.jsx(ce,{value:p,children:d.jsx(Ye.FormProvider,{...l,children:e})})})});fl.displayName="FormBuilderRoot";const r1={Root:fl,FlowBuilder:il,ListBuilder:ll,Preview:dl};_.BaseCondition=Ee,_.BaseField=Ve,_.BaseFormElement=mn,_.BaseOptionsField=tr,_.BaseStringField=In,_.BooleanEqualsConditionModifier=Po,_.BooleanField=yt,_.BooleanFieldCondition=pr,_.BooleanFieldConditionCell=is,_.BooleanFieldInput=Sn,_.BooleanNotEqualsConditionModifier=Bo,_.CheckboxListField=Ct,_.CheckboxListFieldCondition=vr,_.CheckboxListFieldConditionCell=os,_.CheckboxListFieldInput=On,_.ConditionManager=cn,_.DateAfterConditionModifier=Uo,_.DateBeforeConditionModifier=ko,_.DateEqualsConditionModifier=Lo,_.DateField=Lt,_.DateFieldCondition=gr,_.DateFieldConditionCell=ls,_.DateFieldInput=bn,_.DateNotEqualsConditionModifier=zo,_.DateRangeInConditionModifier=Ro,_.DateRangeNotInConditionModifier=Go,_.DoesNotHaveFilesConditionModifier=qo,_.FIELD_TYPES=Mo,_.FieldSchema=Pt,_.FieldSection=qe,_.FieldSectionLayout=Wi,_.FieldTypeGroup=W,_.FieldTypeToClsMapping=Oi,_.FieldsRenderer=cl,_.FileCard=Cn,_.FormBuilder=r1,_.HasFilesConditionModifier=Ho,_.ImageCard=Dn,_.ImageFile=Bt,_.ImageViewer=_n,_.ImageViewerProvider=Ca,_.InputWithLabel=de,_.LONG_TEXT_FIELD_MAX_LENGTH=rr,_.MultiSelectField=it,_.MultiSelectFieldCondition=xr,_.MultiSelectFieldConditionCell=cs,_.MultiSelectFieldInput=Nn,_.MultiStringField=xt,_.MultiStringFieldCondition=yr,_.MultiStringFieldConditionCell=fs,_.MultiStringFieldInput=An,_.NumberEqualsConditionModifier=Ni,_.NumberField=Pe,_.NumberFieldCondition=Cr,_.NumberFieldConditionCell=ps,_.NumberFieldInput=En,_.NumberGreaterThanConditionModifier=Fi,_.NumberGreaterThanOrEqualsConditionModifier=Vi,_.NumberLessThanConditionModifier=Mi,_.NumberLessThanOrEqualsConditionModifier=Di,_.NumberNotEqualsConditionModifier=Ti,_.NumberRangeInConditionModifier=Pi,_.NumberRangeNotInConditionModifier=Bi,_.OTPField=mt,_.OTPFieldCondition=mr,_.OTPFieldConditionCell=gs,_.OTPFieldInput=Mn,_.Observable=er,_.PassFailArrayExcludesConditionModifier=jo,_.PassFailArrayIncludesConditionModifier=Wo,_.PassFailEqualsConditionModifier=$o,_.PassFailField=_t,_.PassFailFieldCondition=wr,_.PassFailFieldConditionCell=ys,_.PassFailFieldInput=Bn,_.PassFailNotEqualsConditionModifier=Xo,_.RadioField=At,_.RadioFieldCondition=_r,_.RadioFieldConditionCell=ms,_.RadioFieldInput=zn,_.RatingField=St,_.RatingFieldCondition=Ar,_.RatingFieldConditionCell=_s,_.RatingFieldInput=kn,_.SHORT_TEXT_FIELD_MAX_LENGTH=yi,_.ScanField=$t,_.ScanFieldCondition=Sr,_.ScanFieldConditionCell=Ss,_.ScanFieldInput=xi,_.Scanner=Kr,_.ScannerProvider=Io,_.SelectField=ot,_.SelectFieldCondition=Er,_.SelectFieldConditionCell=Is,_.SelectFieldInput=Tn,_.StringArrayEqualsConditionModifier=on,_.StringArrayEveryConditionModifier=rn,_.StringArrayExcludesConditionModifier=zi,_.StringArrayIncludesConditionModifier=Li,_.StringArrayNoneConditionModifier=an,_.StringArrayNotEqualsConditionModifier=sn,_.StringArraySomeConditionModifier=nn,_.StringEqualsConditionModifier=pt,_.StringExcludesConditionModifier=Zt,_.StringField=Tt,_.StringFieldCondition=Ir,_.StringFieldConditionCell=bs,_.StringFieldInput=Ci,_.StringIncludesConditionModifier=Yt,_.StringNotEqualsConditionModifier=vt,_.TextField=Mt,_.TextFieldCondition=Or,_.TextFieldConditionCell=Ts,_.TextFieldInput=mi,_.TimeAfterConditionModifier=Qo,_.TimeBeforeConditionModifier=Ko,_.TimeEqualsConditionModifier=Yo,_.TimeField=Xt,_.TimeFieldCondition=br,_.TimeFieldConditionCell=Ds,_.TimeFieldControl=tn,_.TimeFieldInput=Si,_.TimeNotEqualsConditionModifier=Zo,_.TimeRangeInConditionModifier=Jo,_.TimeRangeNotInConditionModifier=es,_.UNLABELLED_FIELD_LABEL=Ce,_.UNLABELLED_SECTION_LABEL=bi,_.URLField=Wt,_.URLFieldCondition=Tr,_.URLFieldConditionCell=Bs,_.URLFieldInput=Ii,_.UTC_OFFSETS=wi,_.UTC_OFFSETS_SET=Oo,_.UUIDFile=st,_.UUIDPromise=kt,_.UploadField=Dt,_.UploadFieldCondition=Nr,_.UploadFieldConditionCell=Vs,_.UploadFieldInput=Ei,_.VideoCard=Vn,_.VideoFile=Fn,_.areFieldValuesBlank=js,_.areFieldValuesEqual=$i,_.areFileAndPromiseArraysEqual=Lr,_.arePassFieldValuesEqual=Ia,_.areSerializedPassFailFieldValuesEqual=Oa,_.awaitFilesAndPromises=t1,_.blankFieldValues=Xi,_.changedFieldValues=Xs,_.cleanConditions=Hi,_.cleanFieldValues=fn,_.cleanSerializedConditions=Gi,_.cleanSerializedFieldValues=qi,_.createCondition=ji,_.createConditionModifierConfig=F,_.createField=vn,_.createTime=_i,_.deserialize=Us,_.deserializeCondition=zs,_.deserializeConditions=Ri,_.deserializeField=dn,_.deserializeFieldValues=Gs,_.deserializeFields=Hf,_.deserializeOnlyFields=qf,_.deserializePassFailFieldValue=Ea,_.extractFilesAndPromisesFromFieldValues=Hs,_.fieldDataMapping=ue,_.fieldSpacingCva=hn,_.fieldTypeGroupDataMapping=Do,_.flattenFields=$f,_.formatTime=en,_.formatUTCOffset=Jr,_.getCurrentUTCOffset=No,_.getFieldsMapping=Xf,_.getUTCMinuteOfDay=ht,_.getUTCOffsetMinutes=To,_.initializeFieldValues=$s,_.insertFilesAndPromisesToFieldValues=qs,_.isFileAndPromiseArray=wa,_.isPassFailFieldStatus=Ln,_.isPassFailFieldValue=Aa,_.isSerializedPassFailFieldValue=_a,_.isStringArray=Jt,_.isTime=ye,_.isTimeInRange=Ai,_.isTimeRange=fr,_.isUTCOffset=Qr,_.maxFileSizeB=Vo,_.maxFileSizeKB=Fo,_.maxFileSizeMB=jt,_.parseTime=dr,_.passFailFieldStatusMapping=wt,_.passFailFieldStatuses=zt,_.separateImagesFromFields=e1,_.serializeConditions=ks,_.serializeFieldValues=Rs,_.serializePassFailFieldValue=Sa,_.unchangedFieldValues=Ws,_.useConditionManager=Rf,_.useFieldInput=me,_.useFieldInputs=Br,_.useFieldSectionInputs=ma,_.useImageViewer=Pr,_.useObjectUrl=wn,_.useScanner=Zl,_.validateFieldValues=Ki,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|