@overmap-ai/forms 1.1.3 → 1.1.4
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 +3467 -3820
- package/dist/forms.umd.cjs +1 -251
- package/package.json +3 -5
package/dist/forms.umd.cjs
CHANGED
|
@@ -1,251 +1 @@
|
|
|
1
|
-
(function(u,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react/jsx-runtime"),require("@overmap-ai/blocks"),require("class-variance-authority"),require("react"),require("@xyflow/react/dist/style.css"),require("@xyflow/react"),require("graphology-dag"),require("react-hook-form"),require("uuid"),require("@hello-pangea/dnd"),require("file-saver"),require("@overmap-ai/hooks"),require("react-zxing"),require("@dagrejs/dagre"),require("graphology"),require("graphology-traversal"),require("lodash.get"),require("lodash.set")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@overmap-ai/blocks","class-variance-authority","react","@xyflow/react/dist/style.css","@xyflow/react","graphology-dag","react-hook-form","uuid","@hello-pangea/dnd","file-saver","@overmap-ai/hooks","react-zxing","@dagrejs/dagre","graphology","graphology-traversal","lodash.get","lodash.set"],t):(u=typeof globalThis<"u"?globalThis:u||self,t(u.forms={},u.jsxRuntime,u.blocks,u.classVarianceAuthority,u.React,null,u.react,u.graphologyDag,u.reactHookForm,u.uuid,u.dnd,u.fileSaver,u.hooks,u.reactZxing,u.Dagre,u.graphology,u.graphologyTraversal,u.get,u.set))})(this,function(u,t,a,R,d,ua,_,Un,Y,N,Li,Gn,to,ro,kn,oo,ao,Hn,so){"use strict";var da=Object.defineProperty;var ca=(u,t,a)=>t in u?da(u,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):u[t]=a;var C=(u,t,a)=>ca(u,typeof t!="symbol"?t+"":t,a);/**
|
|
2
|
-
* @license lucide-react v0.542.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const lo=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),co=i=>i.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,e,r)=>r?r.toUpperCase():e.toLowerCase()),Jn=i=>{const n=co(i);return n.charAt(0).toUpperCase()+n.slice(1)},Wn=(...i)=>i.filter((n,e,r)=>!!n&&n.trim()!==""&&r.indexOf(n)===e).join(" ").trim(),uo=i=>{for(const n in i)if(n.startsWith("aria-")||n==="role"||n==="title")return!0};/**
|
|
7
|
-
* @license lucide-react v0.542.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/var ho={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
12
|
-
* @license lucide-react v0.542.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const fo=d.forwardRef(({color:i="currentColor",size:n=24,strokeWidth:e=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:l,...f},c)=>d.createElement("svg",{ref:c,...ho,width:n,height:n,stroke:i,strokeWidth:r?Number(e)*24/Number(n):e,className:Wn("lucide",o),...!s&&!uo(f)&&{"aria-hidden":"true"},...f},[...l.map(([h,p])=>d.createElement(h,p)),...Array.isArray(s)?s:[s]]));/**
|
|
17
|
-
* @license lucide-react v0.542.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const M=(i,n)=>{const e=d.forwardRef(({className:r,...o},s)=>d.createElement(fo,{ref:s,iconNode:n,className:Wn(`lucide-${lo(Jn(i))}`,`lucide-${i}`,r),...o}));return e.displayName=Jn(i),e};/**
|
|
22
|
-
* @license lucide-react v0.542.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const po=M("align-justify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);/**
|
|
27
|
-
* @license lucide-react v0.542.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const mo=M("arrow-down-up",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);/**
|
|
32
|
-
* @license lucide-react v0.542.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const go=M("arrow-left-right",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/**
|
|
37
|
-
* @license lucide-react v0.542.0 - ISC
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the ISC license.
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const Co=M("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/**
|
|
42
|
-
* @license lucide-react v0.542.0 - ISC
|
|
43
|
-
*
|
|
44
|
-
* This source code is licensed under the ISC license.
|
|
45
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const W=M("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
|
47
|
-
* @license lucide-react v0.542.0 - ISC
|
|
48
|
-
*
|
|
49
|
-
* This source code is licensed under the ISC license.
|
|
50
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const ci=M("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
|
52
|
-
* @license lucide-react v0.542.0 - ISC
|
|
53
|
-
*
|
|
54
|
-
* This source code is licensed under the ISC license.
|
|
55
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const Bi=M("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
|
-
* @license lucide-react v0.542.0 - ISC
|
|
58
|
-
*
|
|
59
|
-
* This source code is licensed under the ISC license.
|
|
60
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const Vo=M("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
|
62
|
-
* @license lucide-react v0.542.0 - ISC
|
|
63
|
-
*
|
|
64
|
-
* This source code is licensed under the ISC license.
|
|
65
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const yo=M("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
|
|
67
|
-
* @license lucide-react v0.542.0 - ISC
|
|
68
|
-
*
|
|
69
|
-
* This source code is licensed under the ISC license.
|
|
70
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const vo=M("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 So=M("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"}]]);/**
|
|
77
|
-
* @license lucide-react v0.542.0 - ISC
|
|
78
|
-
*
|
|
79
|
-
* This source code is licensed under the ISC license.
|
|
80
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const Xn=M("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
|
|
82
|
-
* @license lucide-react v0.542.0 - ISC
|
|
83
|
-
*
|
|
84
|
-
* This source code is licensed under the ISC license.
|
|
85
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const Kn=M("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);/**
|
|
87
|
-
* @license lucide-react v0.542.0 - ISC
|
|
88
|
-
*
|
|
89
|
-
* This source code is licensed under the ISC license.
|
|
90
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const zo=M("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"}]]);/**
|
|
92
|
-
* @license lucide-react v0.542.0 - ISC
|
|
93
|
-
*
|
|
94
|
-
* This source code is licensed under the ISC license.
|
|
95
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/const Yn=M("clipboard-paste",[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]);/**
|
|
97
|
-
* @license lucide-react v0.542.0 - ISC
|
|
98
|
-
*
|
|
99
|
-
* This source code is licensed under the ISC license.
|
|
100
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const wo=M("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"}]]);/**
|
|
102
|
-
* @license lucide-react v0.542.0 - ISC
|
|
103
|
-
*
|
|
104
|
-
* This source code is licensed under the ISC license.
|
|
105
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const Ai=M("copy",[["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"}]]);/**
|
|
107
|
-
* @license lucide-react v0.542.0 - ISC
|
|
108
|
-
*
|
|
109
|
-
* This source code is licensed under the ISC license.
|
|
110
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
-
*/const Zn=M("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);/**
|
|
112
|
-
* @license lucide-react v0.542.0 - ISC
|
|
113
|
-
*
|
|
114
|
-
* This source code is licensed under the ISC license.
|
|
115
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
-
*/const Qn=M("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
|
|
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 Fo=M("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
|
-
* @license lucide-react v0.542.0 - ISC
|
|
123
|
-
*
|
|
124
|
-
* This source code is licensed under the ISC license.
|
|
125
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
-
*/const bo=M("file",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
|
|
127
|
-
* @license lucide-react v0.542.0 - ISC
|
|
128
|
-
*
|
|
129
|
-
* This source code is licensed under the ISC license.
|
|
130
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
-
*/const No=M("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
|
|
132
|
-
* @license lucide-react v0.542.0 - ISC
|
|
133
|
-
*
|
|
134
|
-
* This source code is licensed under the ISC license.
|
|
135
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
-
*/const Mo=M("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/**
|
|
137
|
-
* @license lucide-react v0.542.0 - ISC
|
|
138
|
-
*
|
|
139
|
-
* This source code is licensed under the ISC license.
|
|
140
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
-
*/const Rn=M("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
|
|
142
|
-
* @license lucide-react v0.542.0 - ISC
|
|
143
|
-
*
|
|
144
|
-
* This source code is licensed under the ISC license.
|
|
145
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
-
*/const et=M("layout-panel-top",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);/**
|
|
147
|
-
* @license lucide-react v0.542.0 - ISC
|
|
148
|
-
*
|
|
149
|
-
* This source code is licensed under the ISC license.
|
|
150
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
-
*/const xo=M("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
|
|
152
|
-
* @license lucide-react v0.542.0 - ISC
|
|
153
|
-
*
|
|
154
|
-
* This source code is licensed under the ISC license.
|
|
155
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
-
*/const Io=M("list-checks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
|
|
157
|
-
* @license lucide-react v0.542.0 - ISC
|
|
158
|
-
*
|
|
159
|
-
* This source code is licensed under the ISC license.
|
|
160
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
-
*/const qo=M("list-todo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
|
|
162
|
-
* @license lucide-react v0.542.0 - ISC
|
|
163
|
-
*
|
|
164
|
-
* This source code is licensed under the ISC license.
|
|
165
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
-
*/const Oo=M("list",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/**
|
|
167
|
-
* @license lucide-react v0.542.0 - ISC
|
|
168
|
-
*
|
|
169
|
-
* This source code is licensed under the ISC license.
|
|
170
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
-
*/const _o=M("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/**
|
|
172
|
-
* @license lucide-react v0.542.0 - ISC
|
|
173
|
-
*
|
|
174
|
-
* This source code is licensed under the ISC license.
|
|
175
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
176
|
-
*/const ui=M("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
|
|
177
|
-
* @license lucide-react v0.542.0 - ISC
|
|
178
|
-
*
|
|
179
|
-
* This source code is licensed under the ISC license.
|
|
180
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
181
|
-
*/const it=M("move-down",[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/**
|
|
182
|
-
* @license lucide-react v0.542.0 - ISC
|
|
183
|
-
*
|
|
184
|
-
* This source code is licensed under the ISC license.
|
|
185
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
186
|
-
*/const nt=M("move-up",[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/**
|
|
187
|
-
* @license lucide-react v0.542.0 - ISC
|
|
188
|
-
*
|
|
189
|
-
* This source code is licensed under the ISC license.
|
|
190
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
191
|
-
*/const Z=M("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
192
|
-
* @license lucide-react v0.542.0 - ISC
|
|
193
|
-
*
|
|
194
|
-
* This source code is licensed under the ISC license.
|
|
195
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
196
|
-
*/const To=M("rectangle-ellipsis",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/**
|
|
197
|
-
* @license lucide-react v0.542.0 - ISC
|
|
198
|
-
*
|
|
199
|
-
* This source code is licensed under the ISC license.
|
|
200
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
201
|
-
*/const Lo=M("scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/**
|
|
202
|
-
* @license lucide-react v0.542.0 - ISC
|
|
203
|
-
*
|
|
204
|
-
* This source code is licensed under the ISC license.
|
|
205
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
206
|
-
*/const Bo=M("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
207
|
-
* @license lucide-react v0.542.0 - ISC
|
|
208
|
-
*
|
|
209
|
-
* This source code is licensed under the ISC license.
|
|
210
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
211
|
-
*/const Ao=M("square-check",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
|
212
|
-
* @license lucide-react v0.542.0 - ISC
|
|
213
|
-
*
|
|
214
|
-
* This source code is licensed under the ISC license.
|
|
215
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
216
|
-
*/const Eo=M("square-dashed",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]]);/**
|
|
217
|
-
* @license lucide-react v0.542.0 - ISC
|
|
218
|
-
*
|
|
219
|
-
* This source code is licensed under the ISC license.
|
|
220
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
221
|
-
*/const tt=M("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/**
|
|
222
|
-
* @license lucide-react v0.542.0 - ISC
|
|
223
|
-
*
|
|
224
|
-
* This source code is licensed under the ISC license.
|
|
225
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
226
|
-
*/const $o=M("text-cursor-input",[["path",{d:"M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6",key:"1528k5"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1",key:"1mj8rg"}],["path",{d:"M9 6v12",key:"velyjx"}]]);/**
|
|
227
|
-
* @license lucide-react v0.542.0 - ISC
|
|
228
|
-
*
|
|
229
|
-
* This source code is licensed under the ISC license.
|
|
230
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
231
|
-
*/const Do=M("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/**
|
|
232
|
-
* @license lucide-react v0.542.0 - ISC
|
|
233
|
-
*
|
|
234
|
-
* This source code is licensed under the ISC license.
|
|
235
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
236
|
-
*/const ue=M("trash",[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);/**
|
|
237
|
-
* @license lucide-react v0.542.0 - ISC
|
|
238
|
-
*
|
|
239
|
-
* This source code is licensed under the ISC license.
|
|
240
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
241
|
-
*/const Ei=M("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);/**
|
|
242
|
-
* @license lucide-react v0.542.0 - ISC
|
|
243
|
-
*
|
|
244
|
-
* This source code is licensed under the ISC license.
|
|
245
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
246
|
-
*/const Po=M("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/**
|
|
247
|
-
* @license lucide-react v0.542.0 - ISC
|
|
248
|
-
*
|
|
249
|
-
* This source code is licensed under the ISC license.
|
|
250
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
251
|
-
*/const re=M("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),$i=d.memo(i=>{const{ref:n,file:e,className:r,error:o,rightSlot:s,size:l,...f}=i,c=()=>o?t.jsxs(t.Fragment,{children:[t.jsx(a.LuIcon,{icon:Bi,color:"var(--base-a11)"}),t.jsx(a.Text,{accentColor:"base",className:"truncate",size:l,children:o})]}):e?t.jsxs(t.Fragment,{children:[t.jsx(a.LuIcon,{icon:bo,color:"var(--base-a11)"}),t.jsx(a.Text,{className:"truncate",size:l,children:e.name})]}):t.jsx(t.Fragment,{children:t.jsx("div",{className:"flex w-full justify-center",children:t.jsx(a.Spinner,{size:l})})});return t.jsxs(a.Card,{className:R.cx(r,"flex w-full items-center gap-2"),ref:n,size:"xs",...f,children:[c(),s]})});$i.displayName="FileCard";function $e(i){return Array.isArray(i)?i.every(n=>typeof n=="string"):!1}class De{constructor(){C(this,"observers",new Set)}notify(n){for(const e of this.observers)e(n)}observe(n){return this.observers.add(n),()=>{this.observers.delete(n)}}}class Di extends De{constructor(e){const{identifier:r}=e;super();C(this,"identifier");this.identifier=r}getOptions(){return{identifier:this.identifier}}setOptions(e){this.identifier=e.identifier??this.identifier,this.notify(this)}serialize(){return{type:this.type,identifier:this.identifier}}}class k extends Di{constructor(e){const{label:r,description:o=null,required:s,image:l,...f}=e;super(f);C(this,"label");C(this,"description");C(this,"required");C(this,"image");this.label=r,this.description=o,this.required=s,this.image=l}getError(e){if(!(!this.required&&this.isValueBlank(e))){if(this.required&&this.isValueBlank(e))return"This field is required.";for(const r of this.getFieldValidators()){const o=r(e);if(o)return o}}}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(e){const{label:r,description:o=null,required:s,image:l,...f}=e;this.label=r??this.label,this.description=o??this.description,this.required=s??this.required,this.image=l??this.image,super.setOptions(f)}isValueBlank(e){return this.areValuesEqual(e,this.blankValue())}cleanValue(e){return e}isValueClean(e){return this.areValuesEqual(e,this.cleanValue(e))}cleanSerializedValue(e){return e}isSerializedValueClean(e){return this.areSerializedValuesEqual(e,this.cleanSerializedValue(e))}isSerializedValueBlank(e){return this.areSerializedValuesEqual(e,this.blankSerializedValue())}getFieldValidators(){return[]}}const B=d.createContext({}),Pi=i=>{const[n,e]=d.useState(null);return d.useLayoutEffect(()=>{const r=URL.createObjectURL(i);return e(r),()=>{URL.revokeObjectURL(r)}},[i]),n},Me=d.memo(i=>{const{file:n,...e}=i,r=Pi(n);return t.jsx("img",{src:r??void 0,alt:n.name,...e})});Me.displayName="ImageFile";const rt=d.createContext(()=>{throw new Error("No ImageViewerProvider found")}),hi=()=>d.useContext(rt),ji=d.memo(i=>{const{file:n,onClose:e}=i,r=d.useCallback(()=>{Gn.saveAs(n,n.name)},[n]);return t.jsx(a.Overlay.Root,{open:!0,onOpenChange:e,children:t.jsxs(a.Overlay.Content,{onOpenAutoFocus:a.preventDefault,children:[t.jsxs(a.ButtonGroup,{className:"absolute right-0 top-0 flex items-center gap-2 p-2",accentColor:"base",variant:"ghost",children:[t.jsxs(a.Tooltip.Root,{children:[t.jsx(a.Tooltip.Trigger,{asChild:!0,children:t.jsx(a.IconButton,{onClick:r,"aria-label":"download",children:t.jsx(a.LuIcon,{icon:Zn})})}),t.jsx(a.Tooltip.Content,{size:"sm",children:"Download"})]}),t.jsx(a.Separator,{orientation:"vertical",size:"sm"}),t.jsx(a.Overlay.Close,{asChild:!0,children:t.jsx(a.IconButton,{onClick:e,"aria-label":"close",children:t.jsx(a.LuIcon,{icon:re})})})]}),t.jsx("figure",{className:"flex size-full items-center justify-center overflow-hidden p-4",children:t.jsx(Me,{className:"max-h-full max-w-full",file:n})})]})})});ji.displayName="ImageViewer";const ot=d.memo(i=>{const{children:n}=i,[e,r]=d.useState(null),o=d.useCallback(()=>{r(null)},[]),s=d.useCallback(f=>{r(f(o))},[o]),l=d.useCallback(()=>{e&&(e.onClose&&e.onClose(),o())},[o,e]);return t.jsxs(rt.Provider,{value:s,children:[n,e&&t.jsx(ji,{file:e.file,onClose:l})]})});ot.displayName="FileViewerProvider";const A=d.memo(i=>{const{label:n,error:e,description:r,required:o,children:s,inputId:l,image:f,size:c}=i,[h,p]=d.useState(void 0),m=hi();d.useEffect(()=>{f instanceof Promise?f.then(p).catch(console.error):p(f)},[f]);const g=d.useCallback(()=>{h&&m(()=>({file:h}))},[m,h]),V=o?`${n} *`:n;return t.jsxs("div",{className:"flex flex-col gap-1",children:[h&&t.jsx(Me,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:h,onClick:g}),(!!n||!!r)&&t.jsxs("div",{className:"flex flex-col",children:[t.jsx("label",{className:"w-max max-w-full",htmlFor:l,children:t.jsx(a.Text,{size:c,className:"text-wrap",children:V})}),!!r&&t.jsx(a.Text,{accentColor:"base",size:c,children:r})]}),s,!!e&&t.jsx(a.Text,{accentColor:"danger",size:c,children:e})]})});A.displayName="InputWithLabel";const at=i=>i.map(n=>t.jsx(d.Fragment,{children:n.render()},n.identifier)),fi=i=>i.map(n=>t.jsx(d.Fragment,{children:n.render()},n.identifier)),D=i=>{const{field:n}=i,{field:{value:e,name:r,onChange:o,onBlur:s,disabled:l},fieldState:{isTouched:f,error:c}}=Y.useController({name:n.identifier});return{value:e,name:r,disabled:l,isTouched:f,error:(c==null?void 0:c.message)??"",onChange:o,onBlur:s}},Ui=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),[h,p]=d.useState(""),[m,g]=d.useState(""),V=d.useCallback(z=>{l(z),s()},[l,s]),F=d.useCallback(z=>{r&&r.findIndex(b=>b===z.target.value.trim())>=0?g("All options must be unique"):z.target.value?g(""):g("Option cannot be empty"),p(z.target.value)},[p,r]),w=d.useCallback(()=>{if(m)return;if(!h.trim()){g("Option cannot be empty");return}const z=h.trim();V([...r,z]),p("")},[h,m,V,r]),S=d.useCallback(z=>{z.key==="Enter"&&(z.preventDefault(),w())},[w]),v=d.useCallback(z=>{const b=Array.from(r);b.splice(z,1),V(b)},[r,V]),I=d.useCallback(z=>{if(!z.destination)return;const b=z.source.index,L=z.destination.index,G=Array.from(r),[ie]=G.splice(b,1);G.splice(L,0,ie),V(G)},[V,r]),q=d.useCallback(()=>{s()},[s]);return t.jsx(Li.DragDropContext,{onDragEnd:I,children:t.jsxs(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:m||f,image:n.image,children:[(!c||r.length===0)&&t.jsxs("div",{className:"flex gap-2",children:[t.jsx(a.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:e,children:t.jsx(a.Input.Field,{value:h,onChange:F,onKeyDown:S,id:n.identifier,placeholder:n.placeholder,onBlur:q,name:o,disabled:c})}),t.jsx(a.IconButton,{size:e,accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!m||c,onClick:w,children:t.jsx(a.LuIcon,{icon:Z})})]}),r.length!==0&&t.jsx(Li.Droppable,{droppableId:`${n.identifier}-droppable`,children:z=>t.jsxs("div",{className:"flex flex-col gap-1",...z.droppableProps,ref:z.innerRef,children:[r.map((b,L)=>t.jsx(Li.Draggable,{draggableId:`${b}-draggable`,index:L,isDragDisabled:c,children:({draggableProps:G,dragHandleProps:ie,innerRef:ce})=>t.jsxs(a.Badge,{...ie,...G,ref:ce,className:"flex items-center justify-between gap-2",accentColor:"base",size:e,variant:"soft",children:[t.jsx(a.Text,{className:"truncate",highContrast:!0,children:typeof b=="object"&&"label"in b?b.label:b}),t.jsx(a.IconButton,{className:"bg-transparent!",size:e,variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:c,onClick:()=>{v(L)},children:t.jsx(a.LuIcon,{icon:re})})]})},`${n.identifier}-${b}-${L}`)),z.placeholder]})})]})})});Ui.displayName="MultiStringFieldInput";class he extends k{constructor(e){const{minimum_length:r,maximum_length:o,placeholder:s,...l}=e;super(l);C(this,"type","multi-string");C(this,"minLength");C(this,"maxLength");C(this,"placeholder");this.minLength=r??0,this.maxLength=o??1/0,this.placeholder=s??"Press enter to add a new option"}render(){return t.jsx(Ui,{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(e){return new he({...this.getOptions(),identifier:e})}setOptions(e){const{minimum_length:r,maximum_length:o,placeholder:s,...l}=e;this.minLength=r??this.minLength,this.maxLength=o??this.maxLength,this.placeholder=s??this.placeholder,super.setOptions(l)}serializeValue(e){return e}deserializeValue(e){return e}getFieldValidators(){const e=super.getFieldValidators();return e.push(r=>{if(r.length<this.minLength)return`Must have at least ${this.minLength} options.`}),e.push(r=>{if(r.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),e}static deserialize(e){return new he(e)}isSerializedValue(e){return $e(e)}isValue(e){return $e(e)}blankValue(){return[]}areValuesEqual(e,r){const o=new Set(e),s=new Set(r);return o.size===s.size&&o.isSubsetOf(s)}blankSerializedValue(){return[]}areSerializedValuesEqual(e,r){const o=new Set(e),s=new Set(r);return o.size===s.size&&o.isSubsetOf(s)}}class Pe extends k{constructor(e){const{options:r,...o}=e;super(o);C(this,"options");this.options=r.map(s=>(typeof s=="string"&&(s={label:s,value:s}),s))}serialize(){return{...super.serialize(),options:this.options}}getOptions(){return{...super.getOptions(),options:this.options}}setOptions(e){const{options:r,...o}=e;this.options=(r==null?void 0:r.map(s=>(typeof s=="string"&&(s={label:s,value:s}),s)))??this.options,super.setOptions(o)}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new he({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${r}options`,minimum_length:2}),showDirectly:!0}]}}const Gi=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),h=d.useCallback(m=>{l(!!m),s()},[s,l]),p=d.useCallback(()=>{s()},[s]);return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,error:f,image:n.image,required:n.required,children:t.jsx(a.Checkbox.Root,{id:n.identifier,name:o,checked:r??!1,onCheckedChange:h,onBlur:p,size:e,accentColor:"base",variant:"surface",disabled:c,children:t.jsx(a.Checkbox.Indicator,{children:t.jsx(a.LuIcon,{icon:W})})})})});Gi.displayName="BooleanFieldInput";class fe extends k{constructor(e){super(e);C(this,"type","boolean")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}setOptions(e){super.setOptions(e)}duplicate(e){return new fe({...this.getOptions(),identifier:e})}static deserialize(e){return new fe(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return t.jsx(Gi,{field:this})}isSerializedValue(e){return typeof e=="boolean"}isValue(e){return typeof e=="boolean"}blankValue(){return!1}blankSerializedValue(){return!1}areSerializedValuesEqual(e,r){return e===r}areValuesEqual(e,r){return e===r}}const ki=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),h=d.useCallback(g=>{const V=g.target.valueAsNumber,F=isNaN(V)?null:V;l(F)},[l]),p=d.useCallback(()=>{s()},[s]),m=d.useCallback(g=>{g.key==="Enter"&&g.preventDefault()},[]);return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:t.jsx(a.Input.Root,{accentColor:"base",variant:"surface",size:e,children:t.jsx(a.Input.Field,{id:n.identifier,name:o,onChange:h,onBlur:p,value:r??"",type:"number",min:n.minimum,max:n.maximum,step:n.integers?1:"any",placeholder:n.placeholder??"Enter a number",disabled:c,onKeyDown:m})})})});ki.displayName="NumberFieldInput";class H extends k{constructor(e){const{minimum:r=Number.MIN_SAFE_INTEGER,maximum:o=Number.MAX_SAFE_INTEGER,integers:s=!1,placeholder:l,...f}=e;super(f);C(this,"type","number");C(this,"minimum");C(this,"maximum");C(this,"integers");C(this,"placeholder");this.minimum=r,this.maximum=o,this.integers=s,this.placeholder=l}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new H({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${r}minimum`}),showDirectly:!1},{field:new H({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${r}maximum`}),showDirectly:!1},{field:new fe({label:"Integers",description:"Whole numbers only",required:!1,identifier:`${r}integers`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.minimum,o=this.maximum;return typeof r=="number"&&e.push(s=>{if(typeof s=="number"&&s<r)return`Must be at least ${this.minimum}.`}),typeof o=="number"&&e.push(s=>{if(typeof s=="number"&&s>o)return`Must be at most ${this.maximum}.`}),this.integers&&e.push(s=>{if(typeof s=="number"&&!Number.isInteger(s))return"Must be a whole number."}),e}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(e){return new H({...this.getOptions(),identifier:e})}setOptions(e){const{minimum:r,maximum:o,integers:s,placeholder:l,...f}=e;this.minimum=r??this.minimum,this.maximum=o??this.maximum,this.integers=s??this.integers,this.placeholder=l??this.placeholder,super.setOptions(f)}static deserialize(e){return new H(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return t.jsx(ki,{field:this})}isSerializedValue(e){return this.isValue(e)}isValue(e){return typeof e=="number"&&!isNaN(e)||e===null}areValuesEqual(e,r){return e===r}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,r){return e===r}}const je=1e4;class Hi extends k{constructor(e){const{minLength:r,maxLength:o,placeholder:s="",...l}=e;super(l);C(this,"minLength");C(this,"maxLength");C(this,"placeholder");this.minLength=r?Math.max(r,0):void 0,this.maxLength=o?Math.max(o,0):je,this.placeholder=s}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new H({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${r}minimum_length`,minimum:0,maximum:100,integers:!0}),showDirectly:!1},{field:new H({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${r}maximum_length`,minimum:1,maximum:je,integers:!0}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators();return this.minLength&&e.push(r=>{if(this.minLength&&(!r||r.length<this.minLength))return!this.required&&!r?void 0:`Minimum ${this.minLength} character(s).`}),this.maxLength&&e.push(r=>{if(typeof r=="string"&&this.maxLength&&r.length>this.maxLength)return`Maximum ${this.maxLength} character(s).`}),e}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(e){const{minLength:r,maxLength:o,placeholder:s,...l}=e;this.minLength=r,this.maxLength=o??this.maxLength,this.placeholder=s,super.setOptions(l)}serializeValue(e){return e}deserializeValue(e){return e}isSerializedValue(e){return typeof e=="string"}isValue(e){return typeof e=="string"}blankValue(){return""}blankSerializedValue(){return""}areSerializedValuesEqual(e,r){return e===r}areValuesEqual(e,r){return e===r}}const Ji=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),h=d.useCallback(m=>{l(m),s()},[s,l]),p=d.useCallback(()=>{s()},[s]);return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:t.jsx(a.CheckboxGroup.Root,{id:n.identifier,name:o,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:e,values:r,onValuesChange:h,disabled:c,children:n.options.map((m,g)=>t.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(a.CheckboxGroup.Item,{value:m.value,onBlur:p,children:t.jsx(a.CheckboxGroup.ItemIndicator,{children:t.jsx(a.LuIcon,{icon:W})})}),t.jsx(a.Text,{size:e,accentColor:"base",className:"truncate",children:m.label})]},`${n.identifier}-${m.value}-${g}`))})})});Ji.displayName="CheckboxListFieldInput";class pe extends Pe{constructor(e){super(e);C(this,"type","checkbox-list")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new pe({...this.getOptions(),identifier:e})}static deserialize(e){return new pe(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return t.jsx(Ji,{field:this})}isSerializedValue(e){if(!$e(e))return!1;const r=new Set(this.options.map(({value:o})=>o));return e.every(o=>r.has(o))}isValue(e){return this.isSerializedValue(e)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(e,r){const o=new Set(e),s=new Set(r);return o.size===s.size&&o.isSubsetOf(s)}areValuesEqual(e,r){const o=new Set(e),s=new Set(r);return o.size===s.size&&o.isSubsetOf(s)}}const Wi=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),[h,p]=d.useState(!1),m=d.useCallback(V=>{l(V??null),s(),p(!1)},[l,s]),g=d.useCallback(V=>{p(V),V||s()},[s]);return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:t.jsxs(a.Popover.Root,{open:h,onOpenChange:g,children:[t.jsx(a.Popover.Trigger,{asChild:!0,children:t.jsxs(a.Button,{id:n.identifier,name:o,type:"button",className:"!justify-between",accentColor:"base",variant:"surface",size:e,disabled:c,children:[t.jsx(a.Text,{className:"truncate",highContrast:!!r,children:r?r.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd"}),t.jsx(a.LuIcon,{icon:ci})]})}),t.jsx(a.Popover.Content,{align:"start",size:e,children:t.jsx(a.DayPicker,{size:e,required:!1,mode:"single",variant:"solid",selected:r??void 0,onSelect:m})})]})})});Wi.displayName="DateFieldInput";class xe extends k{constructor(e){super(e);C(this,"type","date")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new xe({...this.getOptions(),identifier:e})}static deserialize(e){return new xe(e)}setOptions(e){super.setOptions(e)}serializeValue(e){return e?e.toISOString():null}deserializeValue(e){return e?new Date(e):null}render(){return t.jsx(Wi,{field:this})}isSerializedValue(e){return typeof e!="string"&&e!==null?!1:this.isValue(this.deserializeValue(e))}isValue(e){return!(!(e instanceof Date)&&e!==null||e instanceof Date&&isNaN(e.getTime()))}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,r){return e===r}areValuesEqual(e,r){return!e&&!r?!0:!e||!r?!1:e.getTime()===r.getTime()}}var O=(i=>(i.Text="text",i.Selection="selection",i.Numeric="numeric",i.Temporal="temporal",i.Capture="capture",i.Assessment="assessment",i.Verification="verification",i))(O||{});const Xi=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),h=d.useCallback(m=>{l(m),s()},[s,l]),p=d.useCallback(m=>{m||s()},[s]);return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:t.jsxs(a.Menu.Root,{onOpenChange:p,align:"start",children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsxs(a.Button,{id:n.identifier,name:o,className:"!justify-between",variant:"surface",type:"button",size:e,accentColor:"base",disabled:c,children:[t.jsx(a.Text,{className:"truncate",highContrast:r&&r.length>0,children:r&&r.length>0?r.join(", "):n.placeholder??"Select one or more..."}),t.jsx(a.LuIcon,{icon:ci})]})}),t.jsx(a.Menu.Content,{size:e,children:t.jsx(a.Menu.Scroll,{children:t.jsxs(a.Menu.MultiSelectGroup,{values:r,onValuesChange:h,children:[t.jsxs(a.Menu.SelectAllItem,{children:[t.jsx(a.Menu.CheckboxItemIndicator,{children:m=>m?t.jsx(a.LuIcon,{icon:ui}):t.jsx(a.LuIcon,{icon:W})}),"Select all"]}),n.options.map((m,g)=>t.jsxs(a.Menu.MultiSelectItem,{value:m.value,children:[t.jsx(a.Menu.SelectedIndicator,{children:t.jsx(a.LuIcon,{icon:W})}),m.label]},`${n.identifier}-${m.value}-${g}`))]})})})]})})});Xi.displayName="MultiSelectFieldInput";class te extends Pe{constructor(e){const{placeholder:r,...o}=e;super(o);C(this,"type","multi-select");C(this,"placeholder");this.placeholder=r}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new te({...this.getOptions(),identifier:e})}setOptions(e){const{placeholder:r}=e;this.placeholder=r,super.setOptions(e)}static deserialize(e){return new te(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return t.jsx(Xi,{field:this})}isSerializedValue(e){if(!$e(e))return!1;const r=new Set(this.options.map(({value:o})=>o));return e.every(o=>r.has(o))}isValue(e){return this.isSerializedValue(e)}blankValue(){return[]}areValuesEqual(e,r){const o=new Set(e),s=new Set(r);return o.size===s.size&&o.isSubsetOf(s)}blankSerializedValue(){return[]}areSerializedValuesEqual(e,r){const o=new Set(e),s=new Set(r);return o.size===s.size&&o.isSubsetOf(s)}}const Ki=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),h=d.useCallback(g=>{l(g??null),s()},[s,l]),p=d.useCallback(g=>{g||s()},[s]),m=d.useMemo(()=>n.options.find(g=>g.value===r),[n.options,r]);return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:t.jsxs(a.Menu.Root,{onOpenChange:p,align:"start",children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsxs(a.Button,{id:n.identifier,name:o,className:"!justify-between",accentColor:"base",variant:"surface",type:"button",size:e,disabled:c,children:[t.jsx(a.Text,{className:"truncate",highContrast:!!m,children:m?m.label:n.placeholder??"Select one..."}),t.jsx(a.LuIcon,{icon:ci})]})}),t.jsx(a.Menu.Content,{size:e,children:t.jsx(a.Menu.Scroll,{children:t.jsx(a.Menu.SelectGroup,{required:!1,value:r??void 0,onValueChange:h,children:n.options.map((g,V)=>t.jsxs(a.Menu.SelectItem,{value:g.value,children:[t.jsx(a.Menu.SelectedIndicator,{children:t.jsx(a.LuIcon,{icon:W})}),g.label]},`${n.identifier}-${g.value}-${V}`))})})})]})})});Ki.displayName="SelectFieldInput";class oe extends Pe{constructor(e){const{placeholder:r,...o}=e;super(o);C(this,"type","select");C(this,"placeholder");this.placeholder=r}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new oe({...this.getOptions(),identifier:e})}setOptions(e){const{placeholder:r}=e;this.placeholder=r,super.setOptions(e)}static deserialize(e){return new oe(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return t.jsx(Ki,{field:this})}isSerializedValue(e){return typeof e!="string"&&e!==null?!1:new Set([null,...this.options.map(({value:o})=>o)]).has(e)}isValue(e){return this.isSerializedValue(e)}blankValue(){return null}areValuesEqual(e,r){return e===r}blankSerializedValue(){return null}areSerializedValuesEqual(e,r){return e===r}}const Yi=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),h=d.useCallback(g=>{l(g)},[l]),p=d.useCallback(()=>{s()},[s]),m=d.useMemo(()=>Array.from({length:n.length},()=>N.v4()),[n.length]);return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:t.jsxs(a.OneTimePasswordField.Root,{id:n.identifier,name:o,value:r,onValueChange:h,validationType:n.validationType,disabled:c,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:e,onBlur:p,children:[m.map(g=>t.jsx(a.OneTimePasswordField.Input,{id:g},g)),t.jsx(a.OneTimePasswordField.HiddenInput,{})]})})});Yi.displayName="OTPFieldInput";class me extends k{constructor(e){const{length:r,validationType:o,...s}=e;super(s);C(this,"type","otp");C(this,"length");C(this,"validationType");this.length=r,this.validationType=o}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new H({label:"Length",integers:!0,required:!1,minimum:1,maximum:16,identifier:`${r}length`}),showDirectly:!1},{field:new oe({label:"Type",required:!1,identifier:`${r}validationType`,options:[{value:"none",label:"Any"},{value:"numeric",label:"Numeric"},{value:"alpha",label:"Alpha"},{value:"alphanumeric",label:"Alphanumeric"}]}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.length;return e.push(o=>{if(o.length!=r)return`Must be ${r} characters.`}),e}serialize(){return{...super.serialize(),length:this.length,validationType:this.validationType}}getOptions(){return{...super.getOptions(),length:this.length,validationType:this.validationType}}duplicate(e){return new me({...this.getOptions(),identifier:e})}setOptions(e){const{length:r,validationType:o,...s}=e;this.length=r??this.length,this.validationType=o??this.validationType,super.setOptions(s)}static deserialize(e){return new me(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return t.jsx(Yi,{field:this})}isSerializedValue(e){return typeof e=="string"}isValue(e){return typeof e=="string"}blankValue(){return""}areValuesEqual(e,r){return e===r}blankSerializedValue(){return""}areSerializedValuesEqual(e,r){return e===r}}const ge={pass:{label:"Pass",icon:Vo},fail:{label:"Fail",icon:So},na:{label:"N/A",icon:vo}},Ie=Object.keys(ge);class ae extends File{constructor(e,...r){super(...r);C(this,"uuid");this.uuid=e}static from(e,r){return new ae(e,[r],r.name,{lastModified:r.lastModified,type:r.type})}}class Ce extends Promise{constructor(e,r){super(e);C(this,"_uuid");this._uuid=r}get uuid(){return this._uuid}set uuid(e){this._uuid=e}static from(e,r){return new Ce((o,s)=>{Promise.resolve(e).then(o).catch(s)},r)}then(e,r){const o=super.then(e,r);return o.uuid=this.uuid,o}catch(e){const r=super.catch(e);return r.uuid=this.uuid,r}finally(e){const r=super.finally(e);return r.uuid=this.uuid,r}}function st(i){return Array.isArray(i)?i.every(n=>n instanceof Ce||n instanceof ae):!1}function pi(i,n){const e=new Set(i.map(({uuid:o})=>o)),r=new Set(n.map(({uuid:o})=>o));return e.size===r.size&&e.isSubsetOf(r)}const Zi=d.memo(i=>{const{ref:n,file:e,error:r,rightSlot:o,className:s,size:l,...f}=i;return t.jsxs(a.Card,{className:R.cx(s,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:n,size:"xs",...f,children:[!e&&!r&&t.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:t.jsx(a.Spinner,{size:l})}),!!e&&!r&&t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3",children:t.jsx(Me,{className:"block size-full max-w-full object-cover",file:e})}),!!r&&t.jsx("div",{className:"grow"}),(!!e||!!r)&&t.jsxs(t.Fragment,{children:[t.jsx(a.Separator,{size:"full"}),t.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[r?t.jsx(a.LuIcon,{color:"var(--base-11)",icon:Bi}):e&&t.jsx(a.LuIcon,{color:"var(--base-11)",icon:Rn}),t.jsx(a.Text,{className:"truncate",size:l,children:r??(e==null?void 0:e.name)}),o]})]})]})});Zi.displayName="ImageCard";const Qi=d.memo(i=>{const{file:n,...e}=i,r=Pi(n);return t.jsx("video",{src:r??void 0,...e})});Qi.displayName="VideoFile";const Ri=d.memo(i=>{const{ref:n,file:e,className:r,error:o,rightSlot:s,size:l,...f}=i;return t.jsxs(a.Card,{className:R.cx(r,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:n,size:"xs",...f,children:[!e&&!o&&t.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:t.jsx(a.Spinner,{size:l})}),!!e&&!o&&t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3",children:t.jsx(Qi,{className:"block size-full max-w-full object-cover",file:e,controls:!0})}),!!o&&t.jsx("div",{className:"grow"}),(!!e||!!o)&&t.jsxs(t.Fragment,{children:[t.jsx(a.Separator,{size:"full"}),t.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[o?t.jsx(a.LuIcon,{color:"var(--danger-11)",icon:Bi}):e&&t.jsx(a.LuIcon,{color:"var(--base-11)",icon:Po}),t.jsx(a.Text,{className:"truncate",size:l,children:o??(e==null?void 0:e.name)}),s]})]})]})});Ri.displayName="VideoCard";const en=d.memo(i=>{const{fileOrPromise:n,onRemove:e,disabled:r,size:o}=i,[s,l]=d.useState(n instanceof Ce?null:n),[f,c]=d.useState(null),h=hi();to.useActiveEffect(v=>{if(c(null),!(n instanceof Ce)){l(n);return}l(null),n.then(I=>{v()&&l(I)}).catch(I=>{v()&&c(I instanceof Error?I.message:"Unknown error")})},[n]);const p=d.useCallback(()=>{if(!s)return;const v=new Blob([s]);Gn.saveAs(v,s.name)},[s]),m=d.useCallback(()=>{e(n)},[e,n]),g=d.useCallback(()=>{if(!s)return;const v=URL.createObjectURL(s);window.open(v,"_blank"),URL.revokeObjectURL(v)},[s]),V=d.useCallback(()=>{s&&h(v=>({file:s,onDelete:r?void 0:()=>{m(),v()}}))},[r,m,h,s]),F=d.useMemo(()=>t.jsx("div",{className:"flex grow justify-end",children:t.jsxs(a.Menu.Root,{modal:!0,children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsx(a.IconButton,{onClick:a.stopPropagation,type:"button",variant:"ghost",accentColor:"base",size:o,children:t.jsx(a.LuIcon,{icon:Qn})})}),t.jsxs(a.Menu.Content,{size:o,children:[t.jsxs(a.Menu.Item,{onSelect:p,disabled:!s,children:[t.jsx(a.LuIcon,{icon:Zn})," Download"]}),r?null:t.jsxs(t.Fragment,{children:[t.jsx(a.Menu.Separator,{}),t.jsxs(a.Menu.Item,{onSelect:m,children:[t.jsx(a.LuIcon,{icon:ue})," Delete"]})]})]})]})}),[r,m,p,s,o]),w=!!(s!=null&&s.type.startsWith("image/")),S=!!(s!=null&&s.type.startsWith("video/"));return w?t.jsx(Zi,{className:"cursor-pointer",onClick:V,file:s,error:f??void 0,rightSlot:F,size:o}):S?t.jsx(Ri,{className:"cursor-pointer",onClick:V,file:s,error:f??void 0,rightSlot:F,size:o}):t.jsx($i,{className:"cursor-pointer",file:s,error:f??void 0,onClick:g,rightSlot:F,size:o})});en.displayName="DisplayFile";const nn=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),h=d.useRef(null),p=d.useCallback(z=>{const b=n.cleanValue({...r,status:z});l(b),s()},[n,s,l,r]),m=d.useCallback(z=>{const b=z.target.value,L={...r,notes:b};l(L)},[r,l]),g=d.useCallback(()=>{s()},[s]),V=d.useCallback(z=>{const b=r.files.filter(({uuid:L})=>L!==z.uuid);l({...r,files:b}),s()},[l,s,r]),F=d.useCallback(()=>{var z;(z=h.current)==null||z.click()},[]),w=d.useCallback(z=>{const b=Array.from(z.target.files??[]).map(G=>ae.from(N.v4(),G)),L={...r,files:[...r.files,...b]};l(L),s()},[s,l,r]);d.useEffect(()=>{if(!h.current)return;const z=new AbortController;return h.current.addEventListener("cancel",()=>{s()},{signal:z.signal}),()=>{z.abort()}},[s,r]);const S=r.status&&n.showNotesAndFilesOn.includes(r.status),v=`${n.identifier}-status`,I=`${n.identifier}-notes`,q=`${n.identifier}-files`;return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(a.RadioGroup.Root,{id:v,className:"flex gap-2",name:o,value:r.status,disabled:c,accentColor:"base",variant:"surface",size:e,onValueChange:p,children:Ie.map(z=>{const{label:b}=ge[z];return t.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(a.RadioGroup.Item,{value:z,children:t.jsx(a.RadioGroup.Indicator,{children:t.jsx(a.LuIcon,{icon:Xn,className:"fill-current"})})}),t.jsx(a.Text,{size:e,accentColor:"base",className:"truncate",children:b})]},`${n.identifier}-${z}`)})}),S&&t.jsxs(t.Fragment,{children:[t.jsx("div",{children:t.jsx(a.TextArea,{id:I,value:r.notes??"",name:o,onChange:m,onBlur:g,className:"field-sizing-content min-h-12 w-full",placeholder:"Notes",resize:"vertical",accentColor:"base",variant:"surface",size:e,disabled:c})}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs(a.Button,{className:"w-max",size:e,variant:"surface",accentColor:"base",onClick:F,type:"button",disabled:c,children:[t.jsx(a.LuIcon,{icon:Ei}),"Select files"]}),t.jsx("input",{id:q,name:o,type:"file",ref:h,multiple:!0,className:"hidden",onChange:w,value:""}),r.files.length>0&&t.jsx("div",{className:"flex h-max flex-wrap gap-2",children:r.files.map(z=>t.jsx(en,{size:e,fileOrPromise:z,onRemove:V,disabled:c},z.uuid))})]})]})]})})});nn.displayName="PassFailFieldInput";const tn=i=>typeof i=="string"&&Ie.includes(i),lt=i=>!(i===null||typeof i!="object"||!("status"in i)||!tn(i.status)||!("notes"in i)||typeof i.notes!="string"||!("files"in i)||!(Array.isArray(i.files)&&i.files.length===0)),dt=i=>!(i===null||typeof i!="object"||!("status"in i)||!tn(i.status)||!("notes"in i)||typeof i.notes!="string"||!("files"in i)||!st(i.files)),ct=i=>({status:i.status,notes:i.notes,files:[]}),ut=i=>({status:i.status,notes:i.notes,files:[]}),ht=(i,n)=>!(i.status!==n.status||i.notes!==n.notes||!pi(i.files,n.files)),ft=(i,n)=>!(i.status!==n.status||i.notes!==n.notes||i.files.length!==n.files.length);class Ve extends k{constructor(e){const{showNotesAndFilesOn:r,...o}=e;super(o);C(this,"type","pass-fail");C(this,"showNotesAndFilesOn");this.showNotesAndFilesOn=r}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new te({identifier:`${r}showNotesAndFilesOn`,label:"Show notes and files on",description:"Show the notes and files on desired statuses.",options:Ie.map(o=>{const{label:s}=ge[o];return{value:o,label:s}}),required:!1}),showDirectly:!1}]}serialize(){return{...super.serialize(),showNotesAndFilesOn:this.showNotesAndFilesOn}}getOptions(){return{...super.getOptions(),showNotesAndFilesOn:this.showNotesAndFilesOn}}duplicate(e){return new Ve({...this.getOptions(),identifier:e})}setOptions(e){const{showNotesAndFilesOn:r,...o}=e;this.showNotesAndFilesOn=r??this.showNotesAndFilesOn,super.setOptions(o)}getFieldValidators(){const e=super.getFieldValidators(),r=this.showNotesAndFilesOn,o=this.blankValue();return r.length>0&&(e.push(s=>{if(!(!s.status||!r.includes(s.status))&&o.notes===s.notes)return"Notes is required."}),e.push(s=>{if(!(!s.status||!r.includes(s.status))&&pi(o.files,s.files))return"Files is required."})),e}static deserialize(e){return new Ve({...e,showNotesAndFilesOn:e.showNotesAndFilesOn??!1})}serializeValue(e){return ct(e)}deserializeValue(e){return ut(e)}render(){return t.jsx(nn,{field:this})}isSerializedValue(e){return lt(e)}isValue(e){return dt(e)}areValuesEqual(e,r){return ht(e,r)}blankValue(){return{status:null,notes:"",files:[]}}cleanValue(e){return e.status&&this.showNotesAndFilesOn.includes(e.status)?e:{status:e.status,notes:"",files:[]}}cleanSerializedValue(e){return super.cleanSerializedValue(e)}blankSerializedValue(){return{status:null,notes:"",files:[]}}areSerializedValuesEqual(e,r){return ft(e,r)}}const rn=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),h=d.useCallback(g=>{l(g),s()},[s,l]),p=d.useCallback(()=>{s()},[s]),m=d.useCallback(()=>{l(null),s()},[s,l]);return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:t.jsxs(a.RadioGroup.Root,{id:n.identifier,name:o,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:e,value:r??"",onValueChange:h,disabled:c,children:[n.options.map((g,V)=>t.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(a.RadioGroup.Item,{value:g.value,onBlur:p,children:t.jsx(a.RadioGroup.Indicator,{children:t.jsx(a.LuIcon,{icon:Xn,className:"fill-current"})})}),t.jsx(a.Text,{size:e,accentColor:"base",className:"truncate",children:g.label})]},`${n.identifier}-${g.value}-${V}`)),!!r&&t.jsxs(a.Button,{onClick:m,className:"-mx-2 w-max",type:"button",variant:"ghost",accentColor:"base",size:e,children:[t.jsx(a.LuIcon,{icon:re}),"Clear"]})]})})});rn.displayName="RadioFieldInput";class ye extends Pe{constructor(e){super(e);C(this,"type","radio")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new ye({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){return new ye(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return t.jsx(rn,{field:this})}isSerializedValue(e){return typeof e!="string"&&e!==null?!1:new Set([null,...this.options.map(({value:o})=>o)]).has(e)}isValue(e){return this.isSerializedValue(e)}blankValue(){return null}areValuesEqual(e,r){return e===r}blankSerializedValue(){return null}areSerializedValuesEqual(e,r){return e===r}}const jo=R.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"]}}}),on=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),h=d.useCallback(g=>{l(g),s()},[s,l]),p=d.useCallback(()=>{l(null),s()},[s,l]),m=Array.from({length:n.maxRating},(g,V)=>V+1);return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:t.jsxs("div",{className:"flex flex-row items-center gap-1",children:[t.jsx(a.Rating.Root,{id:n.identifier,name:o,className:"flex items-center gap-0.5",value:r,onValueChange:h,disabled:c,children:m.map(g=>t.jsx(a.Rating.Item,{value:g,className:jo({size:e}),children:t.jsx(a.LuIcon,{icon:tt,className:"size-full group-data-[active=true]:fill-current"})},`${n.identifier}-${g}`))}),!c&&r!==null&&t.jsx(a.IconButton,{onClick:p,type:"button",variant:"ghost",accentColor:"base",size:e,children:t.jsx(a.LuIcon,{icon:re})})]})})});on.displayName="RatingFieldInput";class ve extends k{constructor(e){const{maxRating:r,...o}=e;super(o);C(this,"type","rating");C(this,"maxRating");this.maxRating=r}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new H({label:"Max Rating",description:"Maximum rating value",integers:!0,required:!1,minimum:1,maximum:10,identifier:`${r}maxRating`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.maxRating;return e.push(o=>{if(typeof o=="number"&&(o<1||o>r))return`Rating must be between 1 and ${r}.`}),e}serialize(){return{...super.serialize(),maxRating:this.maxRating}}getOptions(){return{...super.getOptions(),maxRating:this.maxRating}}duplicate(e){return new ve({...this.getOptions(),identifier:e})}setOptions(e){const{maxRating:r,...o}=e;this.maxRating=r??this.maxRating,super.setOptions(o)}static deserialize(e){return new ve(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return t.jsx(on,{field:this})}isSerializedValue(e){return this.isValue(e)}isValue(e){return typeof e=="number"&&!isNaN(e)||e===null}areValuesEqual(e,r){return e===r}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,r){return e===r}}const an=d.createContext(null),pt=()=>{const i=d.use(an);if(!i)throw new Error("useScannerContext must be used within a component tree wrapped by ScannerProvider.");return i},Uo=()=>{const i=d.use(an);if(!i)throw new Error("useScanner must be used within a component tree wrapped by ScannerProvider.");return i.openScanner},mi=d.memo(i=>{const{children:n,open:e,onOpenChange:r,defaultOpen:o,modal:s,...l}=i;return t.jsxs(a.Overlay.Root,{open:e,onOpenChange:r,defaultOpen:o,modal:s,children:[!!n&&t.jsx(a.Overlay.Trigger,{asChild:!0,children:n}),t.jsxs(a.Overlay.Content,{children:[t.jsx(a.Overlay.Title,{className:"sr-only",children:"Scanner"}),t.jsx(a.Overlay.Description,{className:"sr-only",children:"Scan a barcode or a qr code."}),t.jsx(mt,{...l})]})]})});mi.displayName="Scanner";const mt=d.memo(i=>{const{paused:n,formats:e,timeBetweenDecodingAttempts:r,trySkew:o,onDecodeResult:s,onDecodeError:l,onError:f}=i,{wasmUrl:c}=pt(),{ref:h}=ro.useZxing({wasmUrl:c,paused:n,formats:e,timeBetweenDecodingAttempts:r,trySkew:o,onDecodeResult:s,onDecodeError:l,onError:f});return t.jsxs("div",{className:"bg-(--color-background) flex size-full flex-col justify-center overflow-hidden",children:[t.jsx("div",{className:"flex w-full justify-end p-4",children:t.jsx(a.Overlay.Close,{asChild:!0,children:t.jsx(a.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",children:t.jsx(a.LuIcon,{icon:re})})})}),t.jsx("div",{className:"max-h-full w-full grow overflow-hidden p-4",children:t.jsx("video",{className:"size-full",ref:h,muted:!0,playsInline:!0})})]})});mt.displayName="ScannerInternal";const gt=d.memo(i=>{const{children:n,wasmUrl:e}=i,[r,o]=d.useState(null),s=d.useCallback(()=>{o(null)},[]),l=d.useCallback(h=>{o(h(s))},[s]),f=d.useCallback(()=>{r&&(r.onClose&&r.onClose(),s())},[s,r]),c=d.useMemo(()=>({wasmUrl:e,openScanner:l}),[e,l]);return t.jsxs(an,{value:c,children:[n,r&&t.jsx(mi,{open:!0,onOpenChange:f,...r})]})});gt.displayName="ScannerProvider";const sn=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),[h,p]=d.useState(!1),m=d.useCallback(S=>{const v=S.target.value;l(v)},[l]),g=d.useCallback(()=>{s()},[s]),V=d.useCallback(S=>{l(S.rawValue.trim()),s(),p(!1)},[l,s]),F=d.useCallback(()=>{p(!0)},[]),w=d.useCallback(()=>{p(!1),s()},[s]);return t.jsxs(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:[t.jsx(a.TextArea,{className:"field-sizing-content w-full",accentColor:"base",variant:"surface",size:e,id:n.identifier,name:o,value:r??"",placeholder:"Enter a qr or barcode",onChange:m,onBlur:g,disabled:c}),t.jsxs(a.Button,{onClick:F,className:"w-max",type:"button",variant:"soft",size:e,accentColor:"base",disabled:c,children:[t.jsx(a.LuIcon,{icon:_o}),"Scan"]}),t.jsx(mi,{open:h,onDecodeResult:V,onOpenChange:w})]})});sn.displayName="ScanFieldInput";class qe extends k{constructor(e){super(e);C(this,"type","qr")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new qe({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){return new qe(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return t.jsx(sn,{field:this})}isSerializedValue(e){return typeof e=="string"}isValue(e){return typeof e=="string"}blankValue(){return""}areValuesEqual(e,r){return e===r}blankSerializedValue(){return""}areSerializedValuesEqual(e,r){return e===r}}const ln=500,dn=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),h=d.useCallback(g=>{const V=g.target.value;l(V)},[l]),p=d.useCallback(()=>{s()},[s]),m=d.useCallback(g=>{g.key==="Enter"&&g.preventDefault()},[]);return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:t.jsx(a.Input.Root,{accentColor:"base",variant:"surface",size:e,children:t.jsx(a.Input.Field,{id:n.identifier,className:"truncate",name:o,value:r??"",type:"text",placeholder:n.placeholder,onChange:h,onBlur:p,disabled:c,onKeyDown:m})})})});dn.displayName="StringFieldInput";class Se extends Hi{constructor(e){const{...r}=e,o=e.maxLength?Math.min(ln,e.maxLength):ln,s=e.minLength?Math.min(e.minLength,o):void 0;super({...r,maxLength:o,minLength:s});C(this,"type","string")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new Se({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){const{maximum_length:r,minimum_length:o,...s}=e;return new Se({...s,maxLength:r,minLength:o,placeholder:"Enter a short description"})}render(){return t.jsx(dn,{field:this})}}const cn=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),h=d.useCallback(m=>{const g=m.target.value;l(g)},[l]),p=d.useCallback(()=>{s()},[s]);return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:t.jsx(a.TextArea,{id:n.identifier,value:r??"",name:o,onChange:h,onBlur:p,className:"field-sizing-content min-h-12",placeholder:n.placeholder,resize:"vertical",accentColor:"base",variant:"surface",size:e,disabled:c})})});cn.displayName="TextFieldInput";class ze extends Hi{constructor(e){const r=e.maxLength?Math.min(je,e.maxLength):je,o=e.minLength?Math.min(e.minLength,r):void 0;super({...e,maxLength:r,minLength:o});C(this,"type","text")}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new ze({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){const{maximum_length:r,minimum_length:o,...s}=e;return new ze({...s,maxLength:r,minLength:o,placeholder:"Enter a description"})}render(){return t.jsx(cn,{field:this})}}const un=Go(),Ct=new Set(un);function Go(i=!0){const n=new Set;for(let e=-12;e<=14;e++){const r=e>=0?"+":"-",o=Math.abs(e).toString().padStart(2,"0");n.add(`${r}${o}:00`)}if(i){const e=[-12.5,-9.5,-3.5,3.5,4.5,5.5,6.5,9.5,10.5,12.5];for(const r of e){const o=r>=0?"+":"-",s=Math.floor(Math.abs(r)).toString().padStart(2,"0");n.add(`${o}${s}:30`)}}return Array.from(n).sort((e,r)=>Vt(e)-Vt(r))}function Vt(i){const n=i[0]==="+"?1:-1,e=Number(i.slice(1,3)),r=Number(i.slice(4,6));return n*(e*60+r)}const ko="+00:00",Ho=/^T([01]\d|2[0-3]):([0-5]\d):00([+-]\d{2}:\d{2})$/,gi=i=>typeof i=="string"&&Ct.has(i),yt=()=>{const i=-new Date().getTimezoneOffset(),n=i>=0?"+":"-",e=Math.abs(i),r=Math.floor(e/60),o=e%60,s=`${n}${r.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`;return gi(s)?s:ko};function vt(i){const n=/^([+-])(\d{2}):(\d{2})$/.exec(i);if(!n)throw new Error(`Invalid UTC offset: ${i}`);return(n[1]==="+"?1:-1)*(Number(n[2])*60+Number(n[3]))}const Ue=i=>{const n=Ho.exec(i);if(!n)return null;const e=n[3];return gi(e)?{hours:Number(n[1]),minutes:Number(n[2]),utcOffset:e}:null},E=i=>typeof i=="string"&&Ue(i)!==null,hn=(i,n,e=yt())=>{if(!Number.isInteger(i)||i<0||i>23)throw new Error(`Invalid hour: ${i}`);if(!Number.isInteger(n)||n<0||n>59)throw new Error(`Invalid minute: ${n}`);if(!gi(e))throw new Error("Unsupported UTC offset");const r=i.toString().padStart(2,"0"),o=n.toString().padStart(2,"0");return`T${r}:${o}:00${e}`},Ci=i=>`UTC${i}`,se=i=>{const n=Ue(i);if(!n)throw new Error(`Invalid time value: ${i}`);return(n.hours*60+n.minutes-vt(n.utcOffset)+1440)%1440},Vi=(i,n=!0)=>{const e=Ue(i);if(!e)throw new Error(`Invalid time value: ${i}`);const r=(e.hours%12||12).toString().padStart(2,"0"),o=e.minutes.toString().padStart(2,"0"),s=e.hours>=12?"PM":"AM",l=`${r}:${o} ${s}`;return n?`${l} ${Ci(e.utcOffset)}`:l},Ge=i=>typeof i=="object"&&(E(i.from)||E(i.to)),fn=(i,n)=>{const e=se(i),r=n.from?se(n.from):null,o=n.to?se(n.to):null;return r===null&&o===null?!0:r===null?e<=o:o===null?e>=r:r<=o?e>=r&&e<=o:e>=r||e<=o},yi=d.memo(i=>{const{value:n,onChange:e,onBlur:r,disabled:o,size:s="md",id:l,name:f,compact:c=!1}=i,h=n?Ue(n):null,p=h?`${h.hours.toString().padStart(2,"0")}:${h.minutes.toString().padStart(2,"0")}`:"",m=d.useCallback(F=>{const w=F.target.value;if(!w){e(null);return}const[S,v]=w.split(":").map(Number);e(hn(S,v,h==null?void 0:h.utcOffset))},[e,h==null?void 0:h.utcOffset]),g=d.useCallback(F=>{h&&(e(hn(h.hours,h.minutes,F)),r==null||r())},[r,e,h]),V=d.useCallback(F=>{F||r==null||r()},[r]);return t.jsxs("div",{className:"flex min-w-0 gap-2",children:[t.jsx(a.Input.Root,{className:"min-w-0 grow",accentColor:"base",variant:"surface",size:s,children:t.jsx(a.Input.Field,{id:l,name:f,className:R.cx("[&::-webkit-calendar-picker-indicator]:invert-40 dark:[&::-webkit-calendar-picker-indicator]:invert-60",{"[&::-webkit-datetime-edit]:opacity-60":!n}),type:"time",step:60,value:p,onChange:m,onBlur:r,disabled:o})}),t.jsxs(a.Menu.Root,{align:"end",onOpenChange:V,children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsxs(a.Button,{type:"button",className:c?"!justify-between":"min-w-32 !justify-between",accentColor:"base",variant:"surface",size:s,disabled:o||!h,children:[t.jsx(a.Text,{className:"truncate",highContrast:!!h,children:h?Ci(h.utcOffset):"UTC offset"}),t.jsx(a.LuIcon,{icon:ci})]})}),t.jsx(a.Menu.Content,{size:s,children:t.jsx(a.Menu.Scroll,{children:t.jsx(a.Menu.SelectGroup,{required:!0,value:h==null?void 0:h.utcOffset,onValueChange:g,children:un.map(F=>t.jsxs(a.Menu.SelectItem,{value:F,children:[t.jsx(a.Menu.SelectedIndicator,{children:t.jsx(a.LuIcon,{icon:W})}),Ci(F)]},F))})})})]})]})});yi.displayName="TimeFieldControl";const pn=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n});return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:t.jsx(yi,{id:n.identifier,name:o,size:e,value:r,onChange:l,onBlur:s,disabled:c})})});pn.displayName="TimeFieldInput";class Oe extends k{constructor(e){super(e);C(this,"type","time")}static deserialize(e){return new Oe(e)}getOptions(){return super.getOptions()}duplicate(e){return new Oe({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return t.jsx(pn,{field:this})}isSerializedValue(e){return e===null||E(e)}isValue(e){return e===null||E(e)}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,r){return e===r}areValuesEqual(e,r){return e===r}}const mn=d.memo(i=>{var S;const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),h=d.useRef(null),p=d.useCallback(()=>{var v;(v=h.current)==null||v.click()},[]),m=d.useCallback(()=>{if(!h.current)return;const v=h.current.files;if(!v){s();return}const I=Array.from(v).map(z=>ae.from(N.v4(),z)),q=[...r,...I];l(q),s()},[s,l,r]),g=d.useCallback(v=>{const I=r.filter(({uuid:q})=>q!==v.uuid);l(I),s()},[r,l,s]);d.useEffect(()=>{if(!h.current)return;const v=new AbortController;return h.current.addEventListener("cancel",()=>{s()},{signal:v.signal}),()=>{v.abort()}},[s,r]);const w=n.maxFiles>1?"Select files":"Select a file";return t.jsxs(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:[t.jsxs(a.Button,{className:"w-max",size:e,variant:"surface",accentColor:"base",onClick:p,type:"button",disabled:c,children:[t.jsx(a.LuIcon,{icon:Ei}),w]}),t.jsx("input",{id:n.identifier,name:o,type:"file",ref:h,accept:(S=n.extensions)==null?void 0:S.join(","),multiple:n.maxFiles>1,className:"hidden",onChange:m,value:""}),r.length>0&&t.jsx("div",{className:"mt-1 flex h-max flex-col gap-2",children:r.map(v=>t.jsx(en,{size:e,fileOrPromise:v,onRemove:g,disabled:c},v.uuid))})]})});mn.displayName="UploadFieldInput";class we extends k{constructor(e){const{extensions:r,maximum_files:o,maximum_size:s,...l}=e;super(l);C(this,"type","upload");C(this,"extensions");C(this,"maxFileSize");C(this,"maxFiles");this.maxFileSize=typeof s=="number"?s:void 0,this.maxFiles=Math.max(typeof o=="number"?o:1,1),this.extensions=r}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new H({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:1,maximum:10,identifier:`${r}maximum_files`,integers:!0}),showDirectly:!1},{field:new H({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${Te}MB).`,required:!1,identifier:`${r}maximum_size`,minimum:1,maximum:Te,integers:!0}),showDirectly:!1},{field:new te({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,identifier:`${r}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 e=super.getFieldValidators(),r=this.maxFileSize??Te,o=r*1e3*1e3,s=this.maxFiles||1;return e.push(l=>{if(l.some(f=>f instanceof ae&&f.size>o))return`Files must be at most ${r}MB.`}),e.push(l=>{if(l.length>s)return`You can only upload ${s} files.`}),e}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(e){return new we({...this.getOptions(),identifier:e})}setOptions(e){const{extensions:r,maximum_files:o,maximum_size:s,...l}=e;this.maxFileSize=typeof s=="number"?s:this.maxFileSize,this.maxFiles=typeof o=="number"?o:this.maxFiles,this.extensions=r,super.setOptions(l)}static deserialize(e){return new we(e)}serializeValue(e){return[]}deserializeValue(e){return[]}render(){return t.jsx(mn,{field:this})}isSerializedValue(e){return Array.isArray(e)&&e.length===0}isValue(e){return Array.isArray(e)?e.every(r=>r instanceof Ce||r instanceof ae):!1}areValuesEqual(e,r){return pi(e,r)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(e,r){return e.length===r.length}}const gn=d.memo(i=>{const{field:n}=i,{size:e}=d.use(B),{value:r,name:o,onBlur:s,onChange:l,error:f,disabled:c}=D({field:n}),h=d.useCallback(V=>{const F=V.target.value;F!==""&&!URL.canParse(F)||l(F!==""?new URL(F):null)},[l]),p=d.useCallback(()=>{s()},[s]),m=d.useCallback(V=>{V.key==="Enter"&&V.preventDefault()},[]),g=d.useCallback(()=>{r!==null&&window.open(r,"_blank","noopener,noreferrer")},[r]);return t.jsx(A,{size:e,inputId:n.identifier,label:n.label,description:n.description,required:n.required,error:f,image:n.image,children:t.jsxs("div",{className:"flex w-full gap-2",children:[t.jsx(a.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:e,children:t.jsx(a.Input.Field,{id:n.identifier,className:"truncate",name:o,value:r?r.toString():"",type:"url",inputMode:"url",placeholder:n.placeholder,onChange:h,onBlur:p,disabled:c,onKeyDown:m})}),t.jsx(a.IconButton,{size:e,variant:"soft",accentColor:"base",type:"button",disabled:r===null,onClick:g,children:t.jsx(a.LuIcon,{icon:Fo})})]})})});gn.displayName="URLFieldInput";class _e extends k{constructor(e){const{placeholder:r="https://example.com",...o}=e;super(o);C(this,"type","url");C(this,"placeholder");this.placeholder=r}serialize(){return{...super.serialize(),placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new _e({...this.getOptions(),identifier:e})}setOptions(e){const{placeholder:r,...o}=e;this.placeholder=r??this.placeholder,super.setOptions(o)}static deserialize(e){return new _e(e)}serializeValue(e){return(e==null?void 0:e.toString())??null}deserializeValue(e){return e===null?null:new URL(e)}isSerializedValue(e){return e===null?!0:typeof e!="string"?!1:URL.canParse(e)}isValue(e){return e===null||e instanceof URL}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,r){return e===r}areValuesEqual(e,r){return(e==null?void 0:e.toString())===(r==null?void 0:r.toString())}render(){return t.jsx(gn,{field:this})}}const Cn={date:xe,time:Oe,number:H,boolean:fe,select:oe,string:Se,url:_e,text:ze,upload:we,qr:qe,"multi-string":he,"multi-select":te,radio:ye,"checkbox-list":pe,"pass-fail":Ve,otp:me,rating:ve},St=Object.keys(Cn),T={"checkbox-list":{description:"Allows the user to select a multiple options from a list.",group:O.Selection,icon:wo,name:"Checkbox list"},"multi-select":{description:"Allows the user to select a multiple options from a list of options.",group:O.Selection,icon:Io,name:"Multi-select"},"multi-string":{description:"Allows the user to provide multiple unique strings.",group:O.Text,icon:Oo,name:"Multi-string"},"pass-fail":{description:"Track pass, fail, or N/A outcome.",group:O.Assessment,icon:zo,name:"Pass - Fail"},boolean:{description:"Perfect for both optional and required yes/no questions.",group:O.Selection,icon:Ao,name:"Checkbox"},date:{description:"Allows specifying a date.",group:O.Temporal,icon:Co,name:"Date"},time:{description:"Allows specifying a time and UTC offset.",group:O.Temporal,icon:Do,name:"Time"},number:{description:"Allows specifying a number within a given range.",group:O.Numeric,icon:Mo,name:"Number"},otp:{description:"Allows specifying a number within a given range.",group:O.Verification,icon:To,name:"OTP"},qr:{description:"Used for scanning/reading QR and barcodes.",group:O.Capture,icon:Lo,name:"Scan"},radio:{description:"Allows the user to select a single option from a list of options.",group:O.Selection,icon:yo,name:"Option list"},rating:{description:"Allows users to select a rating value.",group:O.Assessment,icon:tt,name:"Rating"},select:{description:"Allows the user to select a single option from a list of options.",group:O.Selection,icon:qo,name:"Dropdown"},string:{description:"Short text fields can hold up to 500 characters on a single line.",group:O.Text,icon:$o,name:"Short Text"},text:{description:"Paragraph fields can hold up to 10000 characters and can have multiple lines.",group:O.Text,icon:po,name:"Paragraph"},upload:{description:"Allows a file to be uploaded.",group:O.Capture,icon:Ei,name:"Upload"},url:{description:"Allows users to enter a URL.",group:O.Text,icon:xo,name:"URL"}},zt={[O.Assessment]:{name:"Assessment"},[O.Capture]:{name:"Capture"},[O.Numeric]:{name:"Numeric"},[O.Selection]:{name:"Selection"},[O.Temporal]:{name:"Temporal"},[O.Text]:{name:"Text"},[O.Verification]:{name:"Verification"}},Te=50,wt=Te*1e3,Ft=wt*1e3,$="Unlabelled",Vn="Unlabelled";class x{constructor(n){C(this,"id");C(this,"label");C(this,"getApplyFn");C(this,"serialize");C(this,"deserialize");const{id:e,getApplyFn:r,label:o,serialize:s,deserialize:l}=n;this.id=e,this.getApplyFn=r,this.label=o,this.serialize=s,this.deserialize=l}static create(n){return new x(n)}}const bt=x.create({id:"nullable-boolean-equals",label:"is",getApplyFn:i=>n=>n===i,serialize:i=>i,deserialize:i=>i}),Nt=x.create({id:"nullable-boolean-not-equals",label:"is not",getApplyFn:i=>n=>n!==i,serialize:i=>i,deserialize:i=>i}),Mt=x.create({id:"date-equals",getApplyFn:i=>n=>n.getTime()===i.getTime(),label:"is",serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),xt=x.create({id:"date-not-equals",getApplyFn:i=>n=>n.getTime()!==i.getTime(),label:"is not",serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),It=x.create({id:"date-before",getApplyFn:i=>n=>n.getTime()<i.getTime(),label:"before",serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),qt=x.create({id:"date-after",label:"after",getApplyFn:i=>n=>n.getTime()>i.getTime(),serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),Ot=x.create({id:"date-range-in",label:"in between",getApplyFn:i=>n=>!(i!=null&&i.from&&i.from.getTime()>n.getTime()||i!=null&&i.to&&i.to.getTime()<n.getTime()),serialize:i=>{var n,e;return{from:((n=i.from)==null?void 0:n.toISOString())??null,to:((e=i.to)==null?void 0:e.toISOString())??null}},deserialize:i=>({from:i.from?new Date(i.from):void 0,to:i.to?new Date(i.to):void 0})}),_t=x.create({id:"date-range-not-in",label:"not in between",getApplyFn:i=>n=>!!(i!=null&&i.from&&i.from.getTime()>n.getTime()||i!=null&&i.to&&i.to.getTime()<n.getTime()),serialize:i=>{var n,e;return{from:((n=i.from)==null?void 0:n.toISOString())??null,to:((e=i.to)==null?void 0:e.toISOString())??null}},deserialize:i=>({from:i.from?new Date(i.from):void 0,to:i.to?new Date(i.to):void 0})}),Tt=x.create({id:"has-files",label:"is",getApplyFn:i=>n=>n.length>0,serialize:i=>i,deserialize:i=>i}),Lt=x.create({id:"does-not-have-files",label:"is not",getApplyFn:i=>n=>n.length===0,serialize:i=>i,deserialize:i=>i}),yn=x.create({id:"number-equals",getApplyFn:i=>n=>n===i,label:"is",serialize:i=>i,deserialize:i=>i}),vn=x.create({id:"number-not-equals",getApplyFn:i=>n=>n!==i,label:"is not",serialize:i=>i,deserialize:i=>i}),Sn=x.create({id:"number-less-than",getApplyFn:i=>n=>n<i,label:"is less than",serialize:i=>i,deserialize:i=>i}),zn=x.create({id:"number-less-than-or-equals",getApplyFn:i=>n=>n<=i,label:"is less than or equal to",serialize:i=>i,deserialize:i=>i}),wn=x.create({id:"number-greater-than",getApplyFn:i=>n=>n>i,label:"is greater than",serialize:i=>i,deserialize:i=>i}),Fn=x.create({id:"number-greater-than-or-equals",getApplyFn:i=>n=>n>=i,label:"is greater than or equal to",serialize:i=>i,deserialize:i=>i}),bn=x.create({id:"number-range-in",getApplyFn:i=>n=>!(i.to&&n>i.to||i.from&&n<i.from),label:"is between",serialize:i=>i,deserialize:i=>i}),Nn=x.create({id:"number-range-not-in",getApplyFn:i=>n=>!!(i.to&&n>i.to||i.from&&n<i.from),label:"is not between",serialize:i=>i,deserialize:i=>i}),Bt=x.create({id:"pass-fail-equals",getApplyFn:i=>n=>n===i,label:"is",serialize:i=>i,deserialize:i=>i}),At=x.create({id:"pass-fail-not-equals",getApplyFn:i=>n=>n!==i,label:"is not",serialize:i=>i,deserialize:i=>i}),Et=x.create({id:"pass-fail-array-includes",getApplyFn:i=>{const n=new Set(i);return e=>n.has(e)},label:"is any of",serialize:i=>i,deserialize:i=>i}),$t=x.create({id:"pass-fail-array-excludes",getApplyFn:i=>{const n=new Set(i);return e=>!n.has(e)},label:"is none of",serialize:i=>i,deserialize:i=>i}),le=x.create({id:"nullable-string-equals",getApplyFn:i=>n=>n===i,label:"is",serialize:i=>i,deserialize:i=>i}),de=x.create({id:"nullable-string-not-equals",getApplyFn:i=>n=>n!==i,label:"is not",serialize:i=>i,deserialize:i=>i}),Le=x.create({id:"string-includes",getApplyFn:i=>n=>n.includes(i),label:"includes",serialize:i=>i,deserialize:i=>i}),Be=x.create({id:"string-excludes",getApplyFn:i=>n=>!n.includes(i),label:"does not include",serialize:i=>i,deserialize:i=>i}),Mn=x.create({id:"string-array-includes",getApplyFn:i=>{const n=new Set(i);return e=>n.has(e)},label:"is any of",serialize:i=>i,deserialize:i=>i}),xn=x.create({id:"string-array-excludes",getApplyFn:i=>{const n=new Set(i);return e=>!n.has(e)},label:"is none of",serialize:i=>i,deserialize:i=>i}),vi=x.create({id:"string-array-every",getApplyFn:i=>{const n=new Set(i);return e=>{const r=new Set(e);return n.isSubsetOf(r)}},label:"has all of",serialize:i=>i,deserialize:i=>i}),Si=x.create({id:"string-array-some",getApplyFn:i=>{const n=new Set(i);return e=>{const r=new Set(e);return!n.isDisjointFrom(r)}},label:"has any of",serialize:i=>i,deserialize:i=>i}),zi=x.create({id:"string-array-none",getApplyFn:i=>{const n=new Set(i);return e=>{const r=new Set(e);return n.isDisjointFrom(r)}},label:"has none of",serialize:i=>i,deserialize:i=>i}),wi=x.create({id:"string-array-equals",getApplyFn:i=>{const n=new Set(i);return e=>{const r=new Set(e);return n.size===r.size&&r.isSubsetOf(n)}},label:"is",serialize:i=>i,deserialize:i=>i}),Fi=x.create({id:"string-array-not-equals",getApplyFn:i=>{const n=new Set(i);return e=>{const r=new Set(e);return n.size!==r.size||!r.isSubsetOf(n)}},label:"is not",serialize:i=>i,deserialize:i=>i}),Dt=x.create({id:"time-equals",label:"is",getApplyFn:i=>n=>n===i,serialize:i=>i,deserialize:i=>i}),Pt=x.create({id:"time-not-equals",label:"is not",getApplyFn:i=>n=>n!==i,serialize:i=>i,deserialize:i=>i}),jt=x.create({id:"time-before",label:"before",getApplyFn:i=>n=>se(n)<se(i),serialize:i=>i,deserialize:i=>i}),Ut=x.create({id:"time-after",label:"after",getApplyFn:i=>n=>se(n)>se(i),serialize:i=>i,deserialize:i=>i}),Gt=x.create({id:"time-range-in",label:"in between",getApplyFn:i=>n=>fn(n,i),serialize:i=>i,deserialize:i=>i}),kt=x.create({id:"time-range-not-in",label:"not in between",getApplyFn:i=>n=>!fn(n,i),serialize:i=>i,deserialize:i=>i}),y=i=>i;class P extends De{constructor(e){const{id:r,field:o,conditionValue:s,conditionModifier:l}=e;super();C(this,"id");C(this,"conditionValue");C(this,"conditionModifier");C(this,"field");C(this,"getConditionValue",()=>this.conditionValue);C(this,"setConditionValue",e=>{const r=this.modifiers[this.conditionModifier];e!==void 0&&!r.isConditionValueValid(e)||(this.conditionValue=e,this.notify(this))});C(this,"getConditionModifier",()=>this.conditionModifier);C(this,"setConditionModifier",e=>{const r=this.modifiers[e],o=this.getConditionValue();o&&!r.isConditionValueValid(o)&&(this.conditionValue=void 0),this.conditionModifier=e,this.notify(this)});C(this,"getConditionModifiers",()=>Object.entries(this.modifiers));C(this,"accessorFn",e=>e[this.field.identifier]);C(this,"getApplyFn",()=>{const e=this.modifiers[this.conditionModifier],r=this.getConditionValue(),o=r!==void 0&&e.isConditionValueValid(r),s=o?e.modifier.getApplyFn(r):null;return l=>{if(!o)return!0;const f=this.transformValue(l);return e.isValueValid(f)?s(f):!1}});this.id=r,this.field=o,this.conditionValue=s,this.conditionModifier=l}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(e){return e}}const Ht=d.memo,Fe=Ht(function(i){const{ref:n,children:e,...r}=i,o=d.useCallback(s=>typeof e=="function"?t.jsxs(t.Fragment,{children:[e(s),t.jsx(a.Menu.SelectedIndicator,{className:"ml-[auto]",children:t.jsx(a.LuIcon,{icon:W})})]}):t.jsxs(t.Fragment,{children:[e,t.jsx(a.Menu.SelectedIndicator,{className:"ml-[auto]",children:t.jsx(a.LuIcon,{icon:W})})]}),[e]);return t.jsx(a.Menu.SelectItem,{ref:n,...r,children:o})}),Jt=Ht(function(i){const{ref:n,children:e,...r}=i,o=d.useCallback(s=>typeof e=="function"?t.jsxs(t.Fragment,{children:[e(s),t.jsx(a.Menu.SelectedIndicator,{className:"ml-auto",children:t.jsx(a.LuIcon,{icon:W})})]}):t.jsxs(t.Fragment,{children:[e,t.jsx(a.Menu.SelectedIndicator,{className:"ml-auto",children:t.jsx(a.LuIcon,{icon:W})})]}),[e]);return t.jsx(a.Menu.MultiSelectItem,{ref:n,...r,children:o})}),In=d.memo(i=>{const{ref:n,children:e,...r}=i,o=d.useCallback(s=>typeof e=="function"?t.jsxs(t.Fragment,{children:[e(s),t.jsx(a.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:l=>l?t.jsx(a.LuIcon,{icon:ui}):t.jsx(a.LuIcon,{icon:W})})]}):t.jsxs(t.Fragment,{children:[e,t.jsx(a.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:l=>l?t.jsx(a.LuIcon,{icon:ui}):t.jsx(a.LuIcon,{icon:W})})]}),[e]);return t.jsx(a.Menu.SelectAllItem,{ref:n,...r,children:o})});In.displayName="SelectAllItemTemplate";const U=i=>{const{children:n,condition:e,size:r="sm",variant:o,accentColor:s,radius:l}=i,f=d.useCallback(c=>{e.setConditionModifier(c)},[e]);return t.jsxs(a.Menu.Root,{align:"start",children:[t.jsx(a.Menu.ClickTrigger,{children:n}),t.jsx(a.Menu.Content,{size:r,variant:o,radius:l,accentColor:s,children:t.jsx(a.Menu.SelectGroup,{required:!0,value:e.getConditionModifier(),onValueChange:f,children:e.getConditionModifiers().map(([c,h])=>t.jsx(Fe,{value:c,children:h.modifier.label},c))})})]})},bi=d.memo(i=>{const{children:n,open:e,onOpenChange:r,defaultOpen:o,modal:s,size:l,align:f,accentColor:c="base",...h}=i;return t.jsxs(a.Popover.Root,{open:e,onOpenChange:r,defaultOpen:o,modal:s,children:[t.jsx(a.Popover.Trigger,{asChild:!0,children:n}),t.jsx(a.Popover.Content,{size:l,align:f,children:t.jsx(a.DayPicker,{size:l,accentColor:c,...h})})]})});bi.displayName="DayPickerPopover";const Wt=d.memo(i=>{const{children:n,open:e,onOpenChange:r,defaultOpen:o,modal:s,size:l,accentColor:f="base",values:c,onValuesChange:h,placeholder:p="Enter text",...m}=i,[g,V]=d.useState(""),F=d.useCallback(I=>{V(I.target.value)},[]),w=d.useCallback(I=>{I.key==="Enter"&&(I.preventDefault(),I.stopPropagation(),h([...c,g]),V(""))},[g,h,c]),S=d.useCallback(()=>{h([...c,g]),V("")},[g,h,c]),v=d.useCallback(I=>{const q=[...c];q.splice(I,1),h(q)},[h,c]);return t.jsxs(a.Popover.Root,{open:e,onOpenChange:r,defaultOpen:o,modal:s,children:[t.jsx(a.Popover.Trigger,{asChild:!0,children:n}),t.jsx(a.Popover.Content,{size:l,onClick:a.stopPropagation,accentColor:f,...m,children:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(a.Input.Root,{className:"grow",accentColor:"base",variant:"outline",size:"sm",children:t.jsx(a.Input.Field,{value:g,onChange:F,onKeyDown:w,placeholder:p,...m})}),t.jsx(a.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button",onClick:S,children:t.jsx(a.LuIcon,{icon:Z})})]}),c.length>0&&t.jsx("div",{className:"flex flex-col gap-1",children:c.map((I,q)=>t.jsxs(a.Badge,{className:"flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[t.jsx("span",{className:"truncate",children:I}),t.jsx(a.IconButton,{size:"xs",variant:"ghost",type:"button",accentColor:"base",onClick:()=>{v(q)},children:t.jsx(a.LuIcon,{icon:re})})]},`${I}-${q}`))})]})})]})});Wt.displayName="NumberInputPopover";const be=d.memo(i=>{const{children:n,open:e,onOpenChange:r,defaultOpen:o,modal:s,size:l,accentColor:f="base",value:c,onValueChange:h,placeholder:p="Enter a number",...m}=i,[g,V]=d.useState(null);d.useEffect(()=>{c!==void 0&&V(c)},[c]);const F=d.useCallback(S=>{const v=S.target.valueAsNumber;V(isNaN(v)?null:v)},[]),w=d.useCallback(S=>{const v=S.target.valueAsNumber;h==null||h(isNaN(v)?null:v)},[h]);return t.jsxs(a.Popover.Root,{open:e,onOpenChange:r,defaultOpen:o,modal:s,children:[t.jsx(a.Popover.Trigger,{asChild:!0,children:n}),t.jsx(a.Popover.Content,{size:l,onClick:a.stopPropagation,...m,children:t.jsx(a.Input.Root,{size:l,accentColor:f,children:t.jsx(a.Input.Field,{placeholder:p,type:"number",value:g??"",onChange:F,onBlur:w})})})]})});be.displayName="NumberInputPopover";const j=i=>{const{condition:n,onClick:e,...r}=i,o=d.useCallback(()=>{e(n)},[n,e]);return t.jsx(a.IconButton,{onClick:o,...r,children:t.jsx(a.LuIcon,{icon:re})})};j.displayName="RemoveConditionButton";const ke=d.memo(i=>{const{ref:n,selectFieldOptions:e,...r}=i,o=d.useMemo(()=>e.map(s=>typeof s=="string"?{value:s,label:s}:s),[e]);return t.jsxs(a.Menu.MultiSelectGroup,{ref:n,...r,children:[t.jsx(In,{children:"Select all"}),o.map(s=>t.jsx(Jt,{value:s.value,children:t.jsx("span",{className:"truncate",children:s.label})},s.value))]})});ke.displayName="SelectFieldOptionMultiSelectGroup";const qn=d.memo(i=>{const{ref:n,selectFieldOptions:e,...r}=i,o=d.useMemo(()=>e.map(s=>typeof s=="string"?{value:s,label:s}:s),[e]);return t.jsx(a.Menu.SelectGroup,{ref:n,...r,children:o.map(s=>t.jsx(Fe,{value:s.value,children:t.jsx("span",{className:"truncate",children:s.label})},s.value))})});qn.displayName="SelectFieldOptionSelectGroup";const Ae=d.memo(i=>{const{children:n,open:e,onOpenChange:r,defaultOpen:o,modal:s,size:l,accentColor:f="base",value:c,onValueChange:h,placeholder:p="Enter text",...m}=i,[g,V]=d.useState(""),F=d.useCallback(S=>{V(S.target.value)},[]),w=d.useCallback(S=>{const v=S.target.value;h==null||h(v)},[h]);return d.useEffect(()=>{c&&V(c)},[c]),t.jsxs(a.Popover.Root,{open:e,onOpenChange:r,defaultOpen:o,modal:s,children:[t.jsx(a.Popover.Trigger,{asChild:!0,children:n}),t.jsx(a.Popover.Content,{size:l,onClick:a.stopPropagation,...m,children:t.jsx(a.Input.Root,{size:l,accentColor:f,children:t.jsx(a.Input.Field,{placeholder:p,type:"text",value:g,onChange:F,onBlur:w})})})]})});Ae.displayName="TextInputPopover";const Ni=d.memo(i=>{const{children:n,open:e,onOpenChange:r,defaultOpen:o,modal:s,size:l="sm",accentColor:f="base",value:c,onValueChange:h,...p}=i;return t.jsxs(a.Popover.Root,{open:e,onOpenChange:r,defaultOpen:o,modal:s,children:[t.jsx(a.Popover.Trigger,{asChild:!0,children:n}),t.jsx(a.Popover.Content,{size:l,onClick:a.stopPropagation,accentColor:f,...p,children:t.jsx(yi,{compact:!0,size:l,value:c,onChange:h})})]})});Ni.displayName="TimeInputPopover";const Xt=i=>{const{condition:n,onRemove:e}=i,r=n.getConditionValue(),o=n.getConditionModifier(),s=()=>{switch(r){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[n.field.type].icon}),t.jsx("span",{className:"truncate",children:n.field.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[o].modifier.label})}),t.jsxs(a.Menu.Root,{children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:s()})}),t.jsx(a.Menu.Content,{size:"sm",children:t.jsxs(a.Menu.SelectGroup,{required:!0,value:r,onValueChange:n.setConditionValue,children:[t.jsx(Fe,{value:!0,children:"true"}),t.jsx(Fe,{value:!1,children:"false"})]})})]}),t.jsx(j,{condition:n,onClick:e})]})},Kt={equals:y({modifier:bt,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:y({modifier:Nt,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class He extends P{constructor(e){super(e);C(this,"modifiers",Kt)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=Kt[s];let c;return o!==void 0&&(c=f.modifier.deserialize(o)),new He({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(Xt,{condition:this,...e},this.id)}}const Ee=[],Yt=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=d.useCallback(c=>{c.length>0?n.setConditionValue(c):n.setConditionValue(void 0)},[n]),f=()=>{if(o===void 0)return"...";if(o===null)return"empty";switch(o.length){case 0:return"...";default:return`${o.length} options`}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"soft",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"soft",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),t.jsxs(a.Menu.Root,{children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsx(a.Button,{type:"button",className:"truncate",children:f()})}),t.jsx(a.Menu.Content,{size:"sm",children:t.jsx(ke,{values:o??Ee,selectFieldOptions:n.field.options,onValuesChange:l})})]}),t.jsx(j,{condition:n,onClick:e})]})},Zt={equals:y({modifier:wi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:y({modifier:Fi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),every:y({modifier:vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),some:y({modifier:Si,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),none:y({modifier:zi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Je extends P{constructor(e){super(e);C(this,"modifiers",Zt)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=Zt[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new Je({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(Yt,{condition:this,...e},this.id)}}class Mi extends De{constructor(e){super();C(this,"conditions");C(this,"conditionObserver",()=>{this.conditions=[...this.conditions],this.notify(this)});C(this,"initConditions",e=>{for(const r of e)r.observe(this.conditionObserver);return e});this.conditions=this.initConditions(e)}getConditions(){return this.conditions}addCondition(e){this.conditions=this.initConditions([...this.conditions,e]),this.notify(this)}addConditions(e){this.conditions=this.initConditions([...this.conditions,...e]),this.notify(this)}removeCondition(e){this.conditions=this.initConditions(this.conditions.filter(r=>r.id!==e.id)),this.notify(this)}removeConditions(e){const r=new Set(e.map(o=>o.id));this.conditions=this.initConditions(this.conditions.filter(o=>!r.has(o.id))),this.notify(this)}applyConditions(e){return this.conditions.length===0?!0:this.conditions.map(o=>[o.getApplyFn(),o.accessorFn]).every(([o,s])=>o(s(e)))}}const Jo=(i,n)=>d.useMemo(()=>{const e=new Mi(i);return e.observe(r=>n(r.getConditions())),e},[i,n]),Qt=i=>{const{condition:n,onRemove:e}=i,r=n.getConditionValue(),o=n.getConditionModifier(),s=()=>{var l,f;switch(o){case"equals":case"notEquals":{const c=n.modifiers.equals,h=r!==void 0&&c.isConditionValueValid(r)?r:void 0;return t.jsx(bi,{required:!1,size:"sm",mode:"single",selected:h??void 0,onSelect:p=>n.setConditionValue(p),children:t.jsx(a.Button,{type:"button",className:"truncate",children:h!==void 0?(h==null?void 0:h.toLocaleDateString())??"empty":"..."})})}case"before":case"after":{const c=n.modifiers.after,h=r!==void 0&&c.isConditionValueValid(r)?r:void 0;return t.jsx(bi,{required:!0,size:"sm",mode:"single",selected:h,onSelect:n.setConditionValue,children:t.jsx(a.Button,{type:"button",className:"truncate",children:h?h.toLocaleDateString():"..."})})}case"in":case"notIn":{const c=n.modifiers.in,h=r!==void 0&&c.isConditionValueValid(r)?r:void 0;return t.jsx(bi,{required:!0,mode:"range",size:"sm",selected:h,onSelect:n.setConditionValue,children:t.jsx(a.Button,{className:"truncate",children:h?`${(l=h.from)==null?void 0:l.toLocaleDateString()} - ${(f=h.to)==null?void 0:f.toLocaleDateString()}`:"..."})})}}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[n.field.type].icon}),t.jsx("span",{className:"truncate",children:n.field.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[o].modifier.label})}),s(),t.jsx(j,{condition:n,onClick:e})]})},Rt={equals:y({modifier:Mt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),notEquals:y({modifier:xt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),before:y({modifier:It,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),after:y({modifier:qt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),in:y({modifier:Ot,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>"to"in(i??{})&&"from"in(i??{}),isSerializedValueValid:i=>typeof i=="object"&&"to"in i&&"from"in i}),notIn:y({modifier:_t,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>"to"in(i??{})&&"from"in(i??{}),isSerializedValueValid:i=>typeof i=="object"&&"to"in i&&"from"in i})};class We extends P{constructor(e){super(e);C(this,"modifiers",Rt)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=Rt[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new We({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(Qt,{condition:this,...e},this.id)}}const er=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=d.useCallback(c=>{c.length>0?n.setConditionValue(c):n.setConditionValue(void 0)},[n]),f=()=>{if(o===void 0)return"...";if(o===null)return"empty";switch(o.length){case 0:return"...";default:return`${o.length} options`}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),t.jsxs(a.Menu.Root,{children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsx(a.Button,{type:"button",className:"truncate",children:f()})}),t.jsx(a.Menu.Content,{size:"sm",children:t.jsx(ke,{values:o??Ee,selectFieldOptions:r.options,onValuesChange:l})})]}),t.jsx(j,{condition:n,onClick:e})]})},ir={equals:y({modifier:wi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:y({modifier:Fi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),every:y({modifier:vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),some:y({modifier:Si,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),none:y({modifier:zi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Xe extends P{constructor(e){super(e);C(this,"modifiers",ir)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=ir[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new Xe({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(er,{condition:this,...e},this.id)}}const nr=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=d.useCallback(c=>{n.setConditionValue(c.length>0?c:void 0)},[n]),f=()=>{if(o===void 0)return"...";if(o===null)return"empty";switch(o.length){case 0:return"...";case 1:return o[0].toString();default:return`${o.length} values`}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),t.jsx(Wt,{values:o??Ee,onValuesChange:l,children:t.jsx(a.Button,{type:"button",className:"truncate",children:f()})}),t.jsx(j,{condition:n,onClick:e})]})},tr={equals:y({modifier:wi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:y({modifier:Fi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),every:y({modifier:vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),some:y({modifier:Si,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),none:y({modifier:zi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Ke extends P{constructor(e){super(e);C(this,"modifiers",tr)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=tr[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new Ke({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(nr,{condition:this,...e},this.id)}}const rr=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=d.useCallback(c=>{n.setConditionValue(c??void 0)},[n]),f=()=>{switch(s){case"equals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const c=n.modifiers.greaterThan,h=o!==void 0&&c.isConditionValueValid(o)?o:void 0;return t.jsx(be,{value:h??null,onValueChange:l,size:"sm",children:t.jsx(a.Button,{type:"button",className:"truncate",children:h!==void 0?h??"empty":"..."})})}case"inRange":case"notInRange":{const c=n.modifiers.inRange,h=o!==void 0&&c.isConditionValueValid(o)?o:void 0;return t.jsxs(t.Fragment,{children:[t.jsx(be,{value:(h==null?void 0:h.from)??null,onValueChange:p=>{n.setConditionValue({from:p,to:(h==null?void 0:h.to)??null})},size:"sm",children:t.jsx(a.Button,{className:"truncate",children:(h==null?void 0:h.from)??"..."})}),t.jsx(be,{value:(h==null?void 0:h.to)??null,onValueChange:p=>{n.setConditionValue({from:(h==null?void 0:h.from)??null,to:p})},size:"sm",children:t.jsx(a.Button,{className:"truncate",children:(h==null?void 0:h.to)??"..."})})]})}}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),f(),t.jsx(j,{condition:n,onClick:e})]})},or={equals:y({modifier:yn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),notEquals:y({modifier:vn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThan:y({modifier:Sn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThanOrEquals:y({modifier:zn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThan:y({modifier:wn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThanOrEquals:y({modifier:Fn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),inRange:y({modifier:bn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"}),notInRange:y({modifier:Nn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"})};class Ye extends P{constructor(e){super(e);C(this,"modifiers",or)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=or[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new Ye({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(rr,{condition:this,...e},this.id)}}const ar=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=()=>{switch(s){case"equals":case"notEquals":case"includes":case"excludes":return t.jsx(Ae,{value:o??"",onValueChange:n.setConditionValue,size:"sm",children:t.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:t.jsx("span",{className:"truncate",children:o||"..."})})})}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),l(),t.jsx(j,{condition:n,onClick:e})]})},sr={equals:y({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:y({modifier:de,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:y({modifier:Le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:y({modifier:Be,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Ze extends P{constructor(e){super(e);C(this,"modifiers",sr)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=sr[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new Ze({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(ar,{condition:this,...e},this.id)}}const lr=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=()=>{switch(s){case"equals":case"notEquals":{const f=n.modifiers.equals,c=o!==void 0&&f.isConditionValueValid(o)?o:void 0;return t.jsxs(a.Menu.Root,{children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:t.jsx("span",{className:"truncate",children:c!==void 0?c?ge[c].label:"empty":"..."})})}),t.jsx(a.Menu.Content,{size:"sm",children:t.jsx(a.Menu.SelectGroup,{required:!1,value:c,onValueChange:n.setConditionValue,children:Ie.map(h=>{const{label:p}=ge[h];return t.jsx(Fe,{value:h,children:t.jsx("span",{className:"truncate",children:p})},h)})})})]})}case"includes":case"excludes":{const f=n.modifiers.includes,c=o!==void 0&&f.isConditionValueValid(o)?o:void 0;return t.jsxs(a.Menu.Root,{children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsx(a.Button,{type:"button",children:c?`${c.length} statuses`:"..."})}),t.jsx(a.Menu.Content,{size:"sm",children:t.jsxs(a.Menu.MultiSelectGroup,{values:c??Ee,onValuesChange:n.setConditionValue,children:[t.jsx(In,{children:"Select all"}),Ie.map(h=>{const{label:p,icon:m}=ge[h];return t.jsxs(Jt,{value:h,children:[t.jsx(a.LuIcon,{icon:m}),t.jsx("span",{className:"truncate",children:p})]},h)})]})})]})}}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),l(),t.jsx(j,{condition:n,onClick:e})]})},dr={equals:y({modifier:Bt,isValueValid:i=>i!==null,isConditionValueValid:i=>typeof i=="string",isSerializedValueValid:i=>typeof i=="string"}),notEquals:y({modifier:At,isValueValid:i=>i!==null,isConditionValueValid:i=>typeof i=="string",isSerializedValueValid:i=>typeof i=="string"}),includes:y({modifier:Et,isValueValid:i=>i!==null,isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)}),excludes:y({modifier:$t,isValueValid:i=>i!==null,isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)})};class Qe extends P{constructor(e){super(e);C(this,"modifiers",dr)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=dr[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new Qe({field:r,conditionModifier:s,conditionValue:c,...l})}transformValue(e){return e.status}render(e){return t.jsx(lr,{condition:this,...e},this.id)}}const cr=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=d.useMemo(()=>r.options.map(h=>typeof h=="string"?{value:h,label:h}:h),[r.options]),f=d.useMemo(()=>{const h={};for(const p of l)h[p.value]=p.label;return h},[l]),c=()=>{switch(s){case"equals":case"notEquals":{const h=n.modifiers.equals,p=o!==void 0&&h.isConditionValueValid(o)?o:void 0;return t.jsxs(a.Menu.Root,{children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:t.jsx("span",{className:"truncate",children:p!==void 0?p?f[p]:"empty":"..."})})}),t.jsx(a.Menu.Content,{size:"sm",children:t.jsx(qn,{required:!0,selectFieldOptions:r.options,value:p??void 0,onValueChange:n.setConditionValue})})]})}case"includes":case"excludes":{const h=n.modifiers.includes,p=o!==void 0&&h.isConditionValueValid(o)?o:void 0;return t.jsxs(a.Menu.Root,{children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsx(a.Button,{type:"button",children:p?`${p.length} options`:"..."})}),t.jsx(a.Menu.Content,{size:"sm",children:t.jsx(ke,{selectFieldOptions:r.options,values:p??Ee,onValuesChange:n.setConditionValue})})]})}}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),c(),t.jsx(j,{condition:n,onClick:e})]})},ur={equals:y({modifier:le,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),notEquals:y({modifier:de,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),includes:y({modifier:Mn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)}),excludes:y({modifier:xn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)})};class Re extends P{constructor(e){super(e);C(this,"modifiers",ur)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=ur[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new Re({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(cr,{condition:this,...e},this.id)}}const hr=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=()=>{switch(s){case"equals":case"notEquals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const f=n.modifiers[s],c=o!==void 0&&f.isConditionValueValid(o)?o:void 0;return t.jsx(be,{value:c??null,onValueChange:h=>n.setConditionValue(h??void 0),size:"sm",children:t.jsx(a.Button,{type:"button",className:"truncate",children:c!==void 0?c:"..."})})}case"inRange":case"notInRange":{const f=n.modifiers.inRange,c=o!==void 0&&f.isConditionValueValid(o)?o:void 0;return t.jsxs(t.Fragment,{children:[t.jsx(be,{value:(c==null?void 0:c.from)??null,onValueChange:h=>{n.setConditionValue({from:h,to:(c==null?void 0:c.to)??null})},size:"sm",children:t.jsx(a.Button,{className:"truncate",children:(c==null?void 0:c.from)??"..."})}),t.jsx(be,{value:(c==null?void 0:c.to)??null,onValueChange:h=>{n.setConditionValue({from:(c==null?void 0:c.from)??null,to:h})},size:"sm",children:t.jsx(a.Button,{className:"truncate",children:(c==null?void 0:c.to)??"..."})})]})}}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),l(),t.jsx(j,{condition:n,onClick:e})]})},fr={equals:y({modifier:yn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),notEquals:y({modifier:vn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThan:y({modifier:Sn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThanOrEquals:y({modifier:zn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThan:y({modifier:wn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThanOrEquals:y({modifier:Fn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),inRange:y({modifier:bn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"}),notInRange:y({modifier:Nn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"})};class ei extends P{constructor(e){super(e);C(this,"modifiers",fr)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=fr[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new ei({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(hr,{condition:this,...e},this.id)}}const pr=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=()=>{switch(s){case"equals":case"notEquals":case"includes":case"excludes":return t.jsx(Ae,{value:o??"",onValueChange:n.setConditionValue,size:"sm",children:t.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:t.jsx("span",{className:"truncate",children:o||"..."})})})}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),l(),t.jsx(j,{condition:n,onClick:e})]})},mr={equals:y({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:y({modifier:de,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:y({modifier:Le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:y({modifier:Be,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ii extends P{constructor(e){super(e);C(this,"modifiers",mr)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=mr[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new ii({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(pr,{condition:this,...e},this.id)}}const gr=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=d.useMemo(()=>r.options.map(p=>typeof p=="string"?{value:p,label:p}:p),[r.options]),f=d.useMemo(()=>{const p={};for(const m of l)p[m.value]=m.label;return p},[l]),c=d.useCallback(p=>{p.length>0?n.setConditionValue(p):n.setConditionValue([])},[n]),h=()=>{switch(s){case"equals":case"notEquals":{const p=n.modifiers.equals,m=o!==void 0&&p.isConditionValueValid(o)?o:void 0;return t.jsxs(a.Menu.Root,{children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:t.jsx("span",{className:"truncate",children:m!==void 0?m?f[m]:"empty":"..."})})}),t.jsx(a.Menu.Content,{size:"sm",children:t.jsx(qn,{required:!1,selectFieldOptions:r.options,value:m??void 0,onValueChange:n.setConditionValue})})]})}case"includes":case"excludes":{const p=n.modifiers.includes,m=o!==void 0&&p.isConditionValueValid(o)?o:void 0;return t.jsxs(a.Menu.Root,{children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsx(a.Button,{type:"button",children:m?`${m.length} options`:"..."})}),t.jsx(a.Menu.Content,{size:"sm",children:t.jsx(ke,{selectFieldOptions:r.options,values:m??Ee,onValuesChange:c})})]})}}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),h(),t.jsx(j,{condition:n,onClick:e})]})},Cr={equals:y({modifier:le,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),notEquals:y({modifier:de,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),includes:y({modifier:Mn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)}),excludes:y({modifier:xn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)})};class ni extends P{constructor(e){super(e);C(this,"modifiers",Cr)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=Cr[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new ni({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(gr,{condition:this,...e},this.id)}}const Vr=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=()=>{switch(s){case"equals":case"notEquals":case"includes":case"excludes":return t.jsx(Ae,{value:o??"",onValueChange:n.setConditionValue,size:"sm",children:t.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:t.jsx("span",{className:"truncate",children:o||"..."})})})}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),l(),t.jsx(j,{condition:n,onClick:e})]})},yr={equals:y({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:y({modifier:de,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:y({modifier:Le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:y({modifier:Be,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ti extends P{constructor(e){super(e);C(this,"modifiers",yr)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=yr[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new ti({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(Vr,{condition:this,...e},this.id)}}const vr=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=()=>{switch(s){case"equals":case"notEquals":case"includes":case"excludes":return t.jsx(Ae,{value:o??"",onValueChange:n.setConditionValue,size:"sm",children:t.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:t.jsx("span",{className:"truncate",children:o||"..."})})})}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),l(),t.jsx(j,{condition:n,onClick:e})]})},Sr={equals:y({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:y({modifier:de,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:y({modifier:Le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:y({modifier:Be,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ri extends P{constructor(e){super(e);C(this,"modifiers",Sr)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=Sr[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new ri({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(vr,{condition:this,...e},this.id)}}const zr=i=>{const{condition:n,onRemove:e}=i,r=n.getConditionValue(),o=n.getConditionModifier(),s=()=>{switch(o){case"equals":case"notEquals":case"before":case"after":{const l=typeof r=="string"?r:void 0;return t.jsx(Ni,{value:l,onValueChange:f=>n.setConditionValue(f??void 0),size:"sm",children:t.jsx(a.Button,{type:"button",className:"truncate",children:l?Vi(l):"..."})})}case"in":case"notIn":{const l=r&&typeof r=="object"?r:void 0,f=c=>{n.setConditionValue(c.from||c.to?c:void 0)};return t.jsxs(t.Fragment,{children:[t.jsx(Ni,{value:l==null?void 0:l.from,onValueChange:c=>f({from:c,to:(l==null?void 0:l.to)??null}),size:"sm",children:t.jsx(a.Button,{type:"button",className:"truncate",children:l!=null&&l.from?Vi(l.from):"..."})}),t.jsx(Ni,{value:l==null?void 0:l.to,onValueChange:c=>f({from:(l==null?void 0:l.from)??null,to:c}),size:"sm",children:t.jsx(a.Button,{type:"button",className:"truncate",children:l!=null&&l.to?Vi(l.to):"..."})})]})}}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[n.field.type].icon}),t.jsx("span",{className:"truncate",children:n.field.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[o].modifier.label})}),s(),t.jsx(j,{condition:n,onClick:e})]})},wr={equals:y({modifier:Dt,isValueValid:i=>E(i),isConditionValueValid:i=>E(i),isSerializedValueValid:i=>E(i)}),notEquals:y({modifier:Pt,isValueValid:i=>E(i),isConditionValueValid:i=>E(i),isSerializedValueValid:i=>E(i)}),before:y({modifier:jt,isValueValid:i=>E(i),isConditionValueValid:i=>E(i),isSerializedValueValid:i=>E(i)}),after:y({modifier:Ut,isValueValid:i=>E(i),isConditionValueValid:i=>E(i),isSerializedValueValid:i=>E(i)}),in:y({modifier:Gt,isValueValid:i=>E(i),isConditionValueValid:i=>Ge(i),isSerializedValueValid:i=>Ge(i)}),notIn:y({modifier:kt,isValueValid:i=>E(i),isConditionValueValid:i=>Ge(i),isSerializedValueValid:i=>Ge(i)})};class oi extends P{constructor(e){super(e);C(this,"modifiers",wr)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=wr[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new oi({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(zr,{condition:this,...e},this.id)}}const Fr=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=()=>{switch(o){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),t.jsxs(a.Menu.Root,{children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:l()})}),t.jsx(a.Menu.Content,{size:"sm",children:t.jsxs(a.Menu.SelectGroup,{required:!0,value:o,onValueChange:n.setConditionValue,children:[t.jsx(Fe,{value:!0,children:"empty"}),t.jsx(Fe,{value:!1,children:"not empty"})]})})]}),t.jsx(j,{condition:n,onClick:e})]})},br={equals:y({modifier:Tt,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:y({modifier:Lt,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ai extends P{constructor(e){super(e);C(this,"modifiers",br)}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=br[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new ai({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(Fr,{condition:this,...e},this.id)}}const Nr=i=>{const{condition:n,onRemove:e}=i,r=n.field,o=n.getConditionValue(),s=n.getConditionModifier(),l=()=>{switch(s){case"equals":case"notEquals":case"includes":case"excludes":return t.jsx(Ae,{value:o??"",onValueChange:n.setConditionValue,size:"sm",children:t.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:t.jsx("span",{className:"truncate",children:o||"..."})})})}};return t.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[t.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:T[r.type].icon}),t.jsx("span",{className:"truncate",children:r.label||$})]}),t.jsx(U,{condition:n,children:t.jsx(a.Button,{type:"button",children:n.modifiers[s].modifier.label})}),l(),t.jsx(j,{condition:n,onClick:e})]})},Mr={equals:y({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:y({modifier:de,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:y({modifier:Le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:y({modifier:Be,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class si extends P{constructor(e){super(e);C(this,"modifiers",Mr)}transformValue(e){return(e==null?void 0:e.toString())??""}static deserialize(e,r){const{conditionValue:o,conditionModifier:s,...l}=e,f=Mr[s],c=o!==void 0&&f.isSerializedValueValid(o)?f.modifier.deserialize(o):void 0;return new si({field:r,conditionModifier:s,conditionValue:c,...l})}render(e){return t.jsx(Nr,{condition:this,...e},this.id)}}const Wo={date:We,time:oi,number:Ye,boolean:He,select:ni,string:ti,url:si,text:ri,upload:ai,qr:ii,"multi-string":Ke,"multi-select":Xe,radio:Re,"checkbox-list":Je,"pass-fail":Qe,otp:Ze,rating:ei},xr=(i,n)=>{if(i.type!==n.type)throw new Error(`field and condition type mismatch ${i.type} !== ${n.type}`);return Wo[n.type].deserialize(n,i)},On=(i,n)=>{const e=_n(i,n),r={};for(const o of i)r[o.identifier]=o;return e.map(o=>xr(r[o.fieldId],o))},Ir=(i,n)=>Tn(i,n).map(r=>r.serialize()),_n=(i,n)=>{const e=new Set(i.map(r=>r.identifier));return n.filter(r=>e.has(r.fieldId))},Tn=(i,n)=>{const e=new Set(i.map(r=>r.identifier));return n.filter(r=>e.has(r.field.identifier))},xi=i=>Cn[i.type].deserialize(i);function Xo(i){return i.map(qr)}const qr=i=>i.type==="section"?X.deserialize(i):xi(i);function Ko(i){return i.map(xi)}function Yo(i){const n=[];for(const e of i)if(e instanceof X)for(const r of e.getFields())n.push(r);else n.push(e);return n}function Zo(i){const n={};for(const e of i)n[e.identifier]=e;return n}function Or(i,n,e=!0){const r=e?Ii(i,n):n,o={};for(const s of i){if(!(s.identifier in r))continue;const l=r[s.identifier];o[s.identifier]=s.serializeValue(l)}return o}function _r(i,n,e=!0){const r=e?Ln(i,n):n,o={};for(const s of i){if(!(s.identifier in r))continue;const l=r[s.identifier];o[s.identifier]=s.deserializeValue(l)}return o}function Ii(i,n){const e={};for(const r of i){if(!(r.identifier in n))continue;const o=n[r.identifier];r.isValue(o)&&(e[r.identifier]=r.cleanValue(o))}return e}function Ln(i,n){const e={};for(const r of i){if(!(r.identifier in n))continue;const o=n[r.identifier];r.isSerializedValue(o)&&(e[r.identifier]=r.cleanSerializedValue(o))}return e}function Tr(i,n){const e=Ii(i,n),r={},o={};for(const s of i){if(!(s.identifier in e))continue;const l=e[s.identifier];switch(s.type){case"upload":if(!s.isValue(l))break;o[s.identifier]=l,r[s.identifier]=[];break;case"pass-fail":if(!s.isValue(l))break;o[s.identifier]=l.files,r[s.identifier]={...l,files:[]};break;default:r[s.identifier]=n[s.identifier]}}return[r,o]}function Lr(i,n,e){const r={};for(const o of i){if(!(o.identifier in n))continue;const s=n[o.identifier];switch(o.type){case"upload":if(!o.isValue(s))break;r[o.identifier]=e[o.identifier]??[];break;case"pass-fail":if(!o.isValue(s))break;r[o.identifier]={...s,files:e[o.identifier]??[]};break;default:if(!o.isValue(s))break;r[o.identifier]=s}}return r}const Br=(i,n)=>{const e={};for(const r of i){const o=n[r.identifier];e[r.identifier]=o!==void 0?o:r.blankValue()}return e},Ar=(i,n,e)=>{const r={};for(const o of i){const s=n[o.identifier],l=e[o.identifier];o.areValuesEqual(s,l)||(r[o.identifier]=l)}return r},Er=(i,n,e)=>{const r={};for(const o of i){const s=n[o.identifier],l=e[o.identifier];o.areValuesEqual(s,l)&&(r[o.identifier]=l)}return r},Bn=(i,n,e)=>i.every(r=>{const o=n[r.identifier],s=e[r.identifier];return r.areValuesEqual(o,s)}),An=i=>{const n={};for(const e of i)n[e.identifier]=e.blankValue();return n},$r=(i,n)=>Bn(i,n,An(i)),Qo=R.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),qi=R.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),En=d.memo(i=>{const{fieldSection:n}=i,{label:e,description:r}=n,o=Y.useWatch(),{fieldSchema:s,size:l}=d.use(B),f=d.useMemo(()=>s.getFieldSections(),[s]),c=d.useMemo(()=>f.findIndex(({identifier:g})=>g===n.identifier),[f,n.identifier]),h=d.useMemo(()=>f.filter(g=>n.identifier in g.conditions),[f,n.identifier]),p=d.useMemo(()=>h.length===0?!0:h.some(g=>{const V=g.getConditions(n.identifier);return new Mi(V).applyConditions(o)}),[h,n,o]),m=fi(n.fields);return p?t.jsxs(t.Fragment,{children:[c!==0?t.jsx(a.Separator,{size:"full"}):null,t.jsxs("div",{className:"flex flex-col gap-4",children:[(e||r)&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx(a.Heading,{size:l,children:e}),r&&t.jsx(a.Text,{accentColor:"base",size:l,children:r})]})}),t.jsx("div",{className:qi({size:l}),children:m})]})]}):null});En.displayName="FieldSectionLayout";const li=class li extends Di{constructor(e){const{label:r=null,description:o=null,fields:s,conditions:l={},...f}=e;super(f);C(this,"type","section");C(this,"label");C(this,"description");C(this,"conditions");C(this,"fields",[]);C(this,"fieldObserver",()=>{this.notify(this)});C(this,"initFields",e=>{for(const r of e)r.observe(this.fieldObserver);return e});C(this,"conditionObserver",()=>{this.notify(this)});C(this,"initConditions",e=>{for(const r of Object.values(e).flat())r.observe(this.conditionObserver);return e});this.label=r,this.description=o,this.fields=this.initFields(s),this.conditions=this.initConditions(l)}serialize(){const e={};for(const[r,o]of Object.entries(this.conditions))e[r]=o.map(s=>s.serialize());return{...super.serialize(),label:this.label,description:this.description,conditions:e,fields:this.fields.map(r=>r.serialize())}}getOptions(){return{...super.getOptions(),label:this.label,description:this.description,fields:this.fields,conditions:this.conditions}}duplicate(e){return new li({...this.getOptions(),identifier:e,fields:this.fields.map(r=>r.duplicate(N.v4()))})}setOptions(e){const{label:r,description:o,fields:s,conditions:l,...f}=e;this.label=r??this.label,this.description=o??this.description,this.fields=s||this.fields,this.conditions=l||this.conditions,super.setOptions(f)}getErrors(e){const r={};for(const o of this.fields){const s=o.getError(e[o.identifier]);s&&(r[o.identifier]=s)}return r}getFields(){return this.fields}addField(e,r){const o=[...this.fields];o.splice(r??this.fields.length,0,e),this.fields=this.initFields(o),this.notify(this)}moveField(e,r){const o=[...this.fields],[s]=o.splice(e,1);o.splice(r,0,s),this.fields=o,this.notify(this)}removeField(e){this.fields=this.initFields(this.fields.filter(({identifier:o})=>o!==e.identifier));const r={};for(const[o,s]of Object.entries(this.conditions))r[o]=s.filter(l=>l.field.identifier!==e.identifier);this.conditions=r,this.notify(this)}getConditions(e){return this.conditions[e]}addCondition(e,r){this.conditions=this.initConditions({...this.conditions,[e]:[...this.conditions[e]??[],r]}),this.notify(this)}addConditions(e,r){this.conditions=this.initConditions({...this.conditions,[e]:[...this.conditions[e]??[],...r]}),this.notify(this)}removeCondition(e,r){this.conditions=this.initConditions({...this.conditions,[e]:(this.conditions[e]??[]).filter(o=>o.id!==r.id)}),this.notify(this)}removeConditions(e,r){const o=new Set(r.map(s=>s.id));this.conditions=this.initConditions({...this.conditions,[e]:(this.conditions[e]??[]).filter(s=>!o.has(s.id))}),this.notify(this)}getConditionals(){return new Set(Object.keys(this.conditions))}addConditional(e){this.conditions=this.initConditions({...this.conditions,[e]:[]}),this.notify(this)}removeConditional(e){const r={...this.conditions};delete r[e],this.conditions=this.initConditions(r),this.notify(this)}render(){return t.jsx(En,{fieldSection:this})}};C(li,"deserialize",e=>{const r=e.fields.map(xi),o={};for(const[s,l]of Object.entries(e.conditions))o[s]=On(r,l);return new li({...e,fields:r,conditions:o})});let X=li;const ee=d.createContext({}),Oi=d.memo(i=>{const{children:n,variant:e,size:r,accentColor:o,onSelectFieldType:s,...l}=i,f=d.useMemo(()=>{const c={[O.Assessment]:[],[O.Capture]:[],[O.Numeric]:[],[O.Selection]:[],[O.Temporal]:[],[O.Text]:[],[O.Verification]:[]};for(const h of St){const{group:p}=T[h];c[p].push(h)}return c},[]);return t.jsxs(a.Menu.Root,{...l,children:[t.jsx(a.Menu.ClickTrigger,{children:n}),t.jsx(a.Menu.Content,{variant:e,size:r,accentColor:o,children:t.jsx(a.Menu.Scroll,{children:Object.entries(f).map(([c,h])=>{const{name:p}=zt[c];return h.length===0?null:t.jsxs(a.Menu.Group,{children:[t.jsx(a.Menu.Label,{children:p}),h.map(m=>t.jsx(Dr,{fieldType:m,onSelectFieldType:s},m))]},c)})})})]})});Oi.displayName="CreateFieldDropdownMenu";const Dr=d.memo(i=>{const{fieldType:n,onSelectFieldType:e}=i,r=d.useCallback(()=>{e(n)},[n,e]),{icon:o,name:s}=T[n];return t.jsxs(a.Menu.Item,{onSelect:r,children:[t.jsx(a.LuIcon,{icon:o}),t.jsx(a.Text,{className:"truncate",children:s})]})});Dr.displayName="CreateFieldDropdownMenuItem";const _i=i=>{switch(i){case"text":return new ze({label:"",required:!1,identifier:N.v4()});case"boolean":return new fe({label:"",required:!1,identifier:N.v4()});case"number":return new H({label:"",required:!1,identifier:N.v4()});case"date":return new xe({label:"",required:!1,identifier:N.v4()});case"time":return new Oe({label:"",required:!1,identifier:N.v4()});case"string":return new Se({label:"",required:!1,identifier:N.v4()});case"url":return new _e({label:"",required:!1,identifier:N.v4()});case"select":return new oe({label:"",options:[],required:!1,identifier:N.v4()});case"multi-string":return new he({label:"",required:!1,identifier:N.v4()});case"multi-select":return new te({label:"",options:[],required:!1,identifier:N.v4()});case"upload":return new we({label:"",required:!1,identifier:N.v4(),maximum_files:6,maximum_size:Te});case"qr":return new qe({label:"",required:!1,identifier:N.v4()});case"radio":return new ye({label:"",options:[],required:!1,identifier:N.v4()});case"checkbox-list":return new pe({label:"",options:[],required:!1,identifier:N.v4()});case"pass-fail":return new Ve({label:"",required:!1,identifier:N.v4(),showNotesAndFilesOn:["fail"]});case"otp":return new me({label:"",validationType:"none",required:!1,identifier:N.v4(),length:6});case"rating":return new ve({label:"",required:!1,identifier:N.v4(),maxRating:5})}},$n=i=>{switch(i.type){case"text":return new ri({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"boolean":return new He({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"number":return new Ye({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"date":return new We({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"time":return new oi({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"string":return new ti({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"url":return new si({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"select":return new ni({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"multi-string":return new Ke({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"multi-select":return new Xe({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"upload":return new ai({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"qr":return new ii({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"radio":return new Re({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"checkbox-list":return new Je({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"pass-fail":return new Qe({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"otp":return new Ze({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"rating":return new ei({id:N.v4(),conditionValue:void 0,conditionModifier:"equals",field:i})}},Pr=(i,n)=>{switch(i){case"checkbox-list":return pe.getFieldCreationSchema(n);case"multi-select":return te.getFieldCreationSchema(n);case"number":return H.getFieldCreationSchema(n);case"radio":return ye.getFieldCreationSchema(n);case"select":return oe.getFieldCreationSchema(n);case"string":return Se.getFieldCreationSchema(n);case"text":return ze.getFieldCreationSchema(n);case"upload":return we.getFieldCreationSchema(n);case"pass-fail":return Ve.getFieldCreationSchema(n);case"otp":return me.getFieldCreationSchema(n);case"rating":return ve.getFieldCreationSchema(n);default:return}},jr=d.memo(i=>{const{popoverInputs:n,...e}=i;return t.jsxs(a.Popover.Root,{children:[t.jsx(a.Popover.Trigger,{asChild:!0,children:t.jsxs(a.Button,{variant:"soft",type:"button",size:"sm",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:Bo}),"Settings"]})}),t.jsx(a.Popover.Content,{size:"sm",...e,children:t.jsx("div",{className:R.cx("flex w-full max-w-[350px] flex-col",qi({size:"sm"})),children:n})})]})});jr.displayName="FieldSettingsPopover";const Ur=d.memo(i=>{const{parentPath:n,fieldIndex:e,field:r}=i,o=hi(),{disableRequiredFields:s}=d.use(ee),[l,f]=d.useState(void 0);d.useEffect(()=>{r.image instanceof Promise?r.image.then(f).catch(console.error):f(r.image)},[r]);const c=d.useCallback(()=>{r.setOptions({image:void 0})},[r]),[h,p]=d.useMemo(()=>{const z=[],b=[],L=Pr(r.type,`${n}.${e}`)??[];for(const G of L)G.showDirectly?z.push(G.field):b.push(G.field);return[z,b]},[r,n,e]),m=fi(h),g=fi(p),V=p.length>0,F=d.useCallback(()=>{l&&o(()=>({file:l}))},[o,l]),w=d.useCallback(z=>{r.setOptions({required:!!z})},[r]),S=d.useCallback(z=>{r.setOptions({label:z.target.value})},[r]),v=d.useCallback(z=>{r.setOptions({description:z.target.value})},[r]),{icon:I,name:q}=T[r.type];return t.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[t.jsxs("div",{className:"flex w-full justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(a.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[t.jsx(a.LuIcon,{icon:I}),q]}),!s&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(a.Checkbox.Root,{checked:r.required,onCheckedChange:w,size:"sm",children:t.jsx(a.Checkbox.Indicator,{children:t.jsx(a.LuIcon,{icon:W})})}),t.jsx(a.Text,{size:"sm",accentColor:"base",children:"Required"})]})]}),V&&t.jsx(jr,{popoverInputs:g,align:"end"})]}),l&&t.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[t.jsx(Me,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:l,onClick:F}),t.jsx(a.IconButton,{type:"button",className:"group-hover:not-disabled:flex absolute right-2 top-2 hidden",variant:"solid",accentColor:"base","aria-label":"delete",onClick:c,size:"sm",children:t.jsx(a.LuIcon,{icon:ue})})]}),t.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[t.jsx(a.Input.Root,{variant:"outline",size:"md",children:t.jsx(a.Input.Field,{placeholder:"Enter your question",value:r.label??"",onChange:S,maxLength:200})}),t.jsx(a.TextArea,{className:"field-sizing-content",placeholder:"Enter a field description (optional)",value:r.description??"",onChange:v,maxLength:1e3,resize:"vertical",size:"md"})]}),h.length>0&&t.jsx("div",{className:R.cx("w-full",qi({size:"sm"})),children:m})]})});Ur.displayName="FieldBuilder";const Dn=d.memo(i=>{const{field:n,fieldSection:e,fieldIndex:r,sectionIndex:o}=i,s=d.useRef(null),l=`fields.${o}.fields`,f=d.useCallback(w=>{e.addField(_i(w),r+1)},[r,e]),c=d.useCallback(()=>{e.addField(n.duplicate(N.v4()))},[n,e]),h=d.useCallback(w=>{const S=w==="up"?o-1:o+1;e.moveField(r,S)},[e,r,o]),p=d.useCallback(w=>{const{files:S}=w.target;if(!S||S.length!==1)return;const v=S.item(0);if(v){if(v.size>Ft){a.toast.error({title:"File upload error",description:`The file ${v.name} exceeded the maximum file size`});return}n.setOptions({image:v})}},[n]),m=d.useCallback(()=>{h("up")},[h]),g=d.useCallback(()=>{h("down")},[h]),V=d.useCallback(()=>{var w;(w=s.current)==null||w.click()},[]),F=d.useCallback(()=>{e.removeField(n)},[n,e]);return t.jsxs(a.Card,{className:"flex w-full items-center justify-between gap-4",size:"sm",children:[t.jsx(Ur,{fieldIndex:r,field:n,parentPath:l}),t.jsxs(a.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[t.jsx(Oi,{onSelectFieldType:f,size:"sm",children:t.jsx(a.IconButton,{type:"button",children:t.jsx(a.LuIcon,{icon:Z})})}),t.jsx(a.IconButton,{type:"button",onClick:m,children:t.jsx(a.LuIcon,{icon:nt})}),t.jsx(a.IconButton,{type:"button",onClick:g,children:t.jsx(a.LuIcon,{icon:it})}),t.jsx(a.IconButton,{type:"button",onClick:c,children:t.jsx(a.LuIcon,{icon:Ai})}),t.jsx(a.IconButton,{type:"button",onClick:V,children:t.jsx(a.LuIcon,{icon:Rn})}),t.jsx(a.IconButton,{type:"button",onClick:F,children:t.jsx(a.LuIcon,{icon:ue})})]}),t.jsx("input",{className:"hidden",ref:s,type:"file",accept:"image/*",onChange:p})]})});Dn.displayName="FieldBuilderWithActions";const Pn=d.memo(i=>{const{children:n,variant:e,size:r,accentColor:o,fields:s,onSelectField:l,...f}=i;return t.jsxs(a.Menu.Root,{...f,children:[t.jsx(a.Menu.ClickTrigger,{children:n}),t.jsx(a.Menu.Content,{variant:e,size:r,accentColor:o,children:t.jsx(a.Menu.Scroll,{children:s.map(c=>t.jsx(Gr,{field:c,onSelectField:l},c.identifier))})})]})});Pn.displayName="FieldDropdownMenu";const Gr=d.memo(i=>{const{field:n,onSelectField:e}=i,r=d.useCallback(()=>{e(n)},[n,e]);return t.jsxs(a.Menu.Item,{onSelect:r,children:[t.jsx(a.LuIcon,{icon:T[n.type].icon}),n.label||$]})});Gr.displayName="FieldDropdownMenuItem";const kr=d.memo(i=>{const{children:n,variant:e,size:r,accentColor:o,fieldSections:s,onSelectFieldSection:l,...f}=i;return t.jsxs(a.Menu.Root,{...f,children:[t.jsx(a.Menu.ClickTrigger,{children:n}),t.jsx(a.Menu.Content,{variant:e,size:r,accentColor:o,children:s.map(c=>t.jsx(Hr,{fieldSection:c,onSelectFieldSection:l},c.identifier))})]})});kr.displayName="FieldSectionDropdownMenu";const Hr=d.memo(i=>{const{fieldSection:n,onSelectFieldSection:e}=i,r=d.useCallback(()=>{e(n)},[n,e]);return t.jsxs(a.Menu.Item,{onSelect:r,children:[t.jsx(a.LuIcon,{icon:et}),n.label||Vn]})});Hr.displayName="FieldSectionDropdownMenuItem";const Jr=d.memo(i=>{const{id:n,sourceX:e,sourceY:r,targetX:o,targetY:s,style:l,markerEnd:f,data:c}=i,{targetSection:h,sourceSection:p,layoutDirection:m}=c,g=d.useMemo(()=>p.getConditions(h.identifier),[p,h.identifier]),V=d.useCallback(()=>{p.removeConditional(h.identifier)},[p,h.identifier]),F=d.useCallback(q=>{p.addCondition(h.identifier,$n(q))},[p,h.identifier]),w=d.useCallback(q=>{p.removeCondition(h.identifier,q)},[p,h.identifier]),[S,v,I]=_.getBezierPath({sourceX:e,sourceY:r,sourcePosition:m==="LR"?_.Position.Right:_.Position.Bottom,targetX:o,targetY:s,targetPosition:m==="LR"?_.Position.Left:_.Position.Top});return t.jsxs(t.Fragment,{children:[t.jsx(_.BaseEdge,{id:n,path:S,style:l,markerEnd:f,labelX:v,labelY:I}),t.jsx(_.EdgeLabelRenderer,{children:t.jsxs(a.Card,{size:"xs",variant:"surface",className:"nodrag nopan bg-(--base-2) pointer-events-auto absolute inline-flex flex-col gap-2",onMouseDown:a.stopPropagation,onClick:a.stopPropagation,"data-floating-content":"",style:{transform:`translate(-50%, -50%) translate(${v}px, ${I}px)`},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(a.Text,{size:"xs",className:"max-w-[280px] truncate",children:p.label||"Untitled section"}),t.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[t.jsx(Pn,{fields:p.fields,onSelectField:F,children:t.jsx(a.IconButton,{"aria-label":"Add condition",type:"button",variant:"surface",size:"xs",accentColor:"base",children:t.jsx(a.LuIcon,{icon:Z})})}),t.jsxs(a.Tooltip.Root,{children:[t.jsx(a.Tooltip.Trigger,{asChild:!0,children:t.jsx(a.IconButton,{"aria-label":"Remove conditional logic",type:"button",variant:"surface",size:"xs",accentColor:"base",color:"danger",onClick:V,children:t.jsx(a.LuIcon,{icon:ue})})}),t.jsx(a.Tooltip.Content,{size:"sm",children:"Remove conditional logic"})]})]})]}),g.length>0&&t.jsx("div",{className:"flex h-max w-full flex-col flex-wrap gap-1",children:g.map(q=>t.jsx(d.Fragment,{children:q.render({onRemove:w})},q.id))})]})})]})});Jr.displayName="FieldSectionConditionEdgeComponent";const Wr=d.memo(i=>{const{data:n,selected:e}=i,{fieldSection:r,index:o,layoutDirection:s}=n,{fieldSchema:l}=d.use(ee),f=d.useCallback(()=>{l.removeFieldSection(r)},[l,r]),c=d.useCallback(V=>{r.addField(_i(V))},[r]),h=d.useCallback(()=>{const V=new X({identifier:N.v4(),fields:[]});l.addFieldSection(V),r.addConditional(V.identifier)},[l,r]),p=d.useCallback(()=>{l.addFieldSection(r.duplicate(N.v4()))},[l,r]),m=d.useCallback(V=>{r.setOptions({label:V.target.value})},[r]),g=d.useCallback(V=>{r.setOptions({description:V.target.value})},[r]);return t.jsxs(a.Card,{variant:"surface",className:"bg-(--base-2) relative cursor-pointer",size:"sm","data-selected":e?"true":void 0,children:[t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[t.jsx(a.Input.Root,{variant:"outline",size:"md",accentColor:"base",children:t.jsx(a.Input.Field,{placeholder:"Enter a section label (optional)",value:r.label??"",onChange:m,maxLength:200})}),t.jsx(a.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:r.description??"",onChange:g,maxLength:1e3,resize:"vertical",size:"md"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(a.Text,{weight:"bold",children:"Fields"}),t.jsx(Oi,{onSelectFieldType:c,size:"sm",children:t.jsxs(a.Button,{type:"button",variant:"soft",size:"sm",accentColor:"base",children:[t.jsx(a.LuIcon,{icon:Z})," Add field"]})})]}),t.jsx("div",{className:"flex flex-col gap-3",children:r.fields.map((V,F)=>t.jsx(Dn,{field:V,fieldSection:r,fieldIndex:F,sectionIndex:o},V.identifier))})]}),t.jsx(_.NodeToolbar,{isVisible:!0,position:_.Position.Right,align:"start",offset:8,onMouseDown:a.stopPropagation,children:t.jsx(a.Card,{variant:"surface",className:"bg-(--base-2) flex flex-col items-center gap-1 p-1",size:"xs",onClick:a.stopPropagation,children:t.jsxs(a.ButtonGroup,{className:"flex flex-col gap-2",variant:"surface",size:"xs",accentColor:"base",children:[t.jsx(a.IconButton,{type:"button",onClick:h,children:t.jsx(a.LuIcon,{icon:No})}),t.jsx(a.IconButton,{type:"button",onClick:p,children:t.jsx(a.LuIcon,{icon:Ai})}),t.jsx(a.IconButton,{type:"button",onClick:f,children:t.jsx(a.LuIcon,{icon:ue})})]})})}),t.jsx(_.Handle,{type:"target",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:s==="LR"?_.Position.Left:_.Position.Top}),t.jsx(_.Handle,{type:"source",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:s==="LR"?_.Position.Right:_.Position.Bottom})]})});Wr.displayName="CustomNode";const Ro={fieldSection:Wr},ea={fieldSectionCondition:Jr},ia=(i,n,e)=>{const r=new kn.graphlib.Graph().setDefaultEdgeLabel(()=>({}));return r.setGraph({rankdir:e,nodesep:200,edgesep:500,ranksep:500}),n.forEach(o=>r.setEdge(o.source,o.target,{width:500,height:200,labelpos:"c"})),i.forEach(o=>{var s,l;return r.setNode(o.id,{...o,width:((s=o.measured)==null?void 0:s.width)??0,height:((l=o.measured)==null?void 0:l.height)??0})}),kn.layout(r),[i.map(o=>{var c,h;const s=r.node(o.id),l=s.x-(((c=o.measured)==null?void 0:c.width)??0)/2,f=s.y-(((h=o.measured)==null?void 0:h.height)??0)/2;return{...o,position:{x:l,y:f}}}),n]},na={hideAttribution:!0},Xr=d.memo(()=>{var Q;const{errors:i}=Y.useFormState(),{handleSubmit:n}=Y.useFormContext(),{onSave:e,onCancel:r}=d.use(ee),{fieldSchema:o}=d.use(ee),s=d.useRef(null),[l,f]=d.useState(),[c,h]=d.useState("TB");d.useLayoutEffect(()=>{s.current&&s.current.classList.remove("light")},[]);const p=d.useMemo(()=>o.fieldSections.map((J,K)=>({id:J.identifier,position:{x:0,y:0},data:{index:K,fieldSection:J,layoutDirection:c},draggable:!0,type:"fieldSection"})),[o.fieldSections,c]),m=d.useMemo(()=>{const J=[],K={};for(const ne of o.fieldSections)K[ne.identifier]=ne;for(const ne of o.fieldSections){const Ti=ne.conditions;for(const[di,la]of Object.entries(Ti))J.push({id:`${ne.identifier}-${di}`,source:ne.identifier,target:di,data:{targetSection:K[di],sourceSection:ne,layoutDirection:c},animated:la.length>0,markerEnd:_.MarkerType.Arrow,style:{strokeWidth:2,stroke:"var(--base-a8)"},type:"fieldSectionCondition"})}return J},[o.fieldSections,c]),[g,V,F]=_.useNodesState(p),[w,S,v]=_.useEdgesState(m);d.useEffect(()=>{V(p)},[p,V]),d.useEffect(()=>{S(m)},[m,S]);const[I,q]=d.useMemo(()=>ia(g,w,c),[w,c,g]),z=d.useCallback(()=>{o.addFieldSection(new X({identifier:N.v4(),fields:[]}))},[o]),b=d.useCallback(J=>{const{source:K,target:ne}=J,Ti=o.fieldSections.find(({identifier:di})=>di===K);Ti.setOptions({conditions:{...Ti.conditions,[ne]:[]}})},[o.fieldSections]),L=d.useCallback(J=>{const K=o.getSectionDependencyGraph();return!Un.willCreateCycle(K,J.source,J.target)},[o]),G=d.useCallback(()=>{l==null||l.zoomOut()},[l]),ie=d.useCallback(()=>{l==null||l.zoomIn()},[l]),ce=d.useCallback(()=>{l==null||l.fitView()},[l]);return t.jsxs("form",{className:"flex size-full flex-col gap-4",onSubmit:n(e),children:[t.jsxs(a.Card,{className:"relative size-full",variant:"outline",children:[t.jsx(_.ReactFlow,{ref:s,onInit:f,nodes:I,onNodesChange:F,edges:q,onEdgesChange:v,nodeTypes:Ro,edgeTypes:ea,onConnect:b,attributionPosition:"bottom-left",fitView:!0,minZoom:0,isValidConnection:L,proOptions:na}),t.jsx(_.Panel,{position:"top-left",children:t.jsx(a.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:t.jsxs(a.Button,{type:"button",variant:"surface",onClick:z,children:[t.jsx(a.LuIcon,{icon:Z})," Add section"]})})}),t.jsxs(_.Panel,{position:"top-right",className:"flex flex-col items-center gap-2",children:[t.jsxs(a.ToggleGroup.Root,{className:"flex flex-col",type:"single",accentColor:"base",size:"sm",value:c,onValueChange:h,children:[t.jsx(a.ToggleGroup.IconItem,{className:"rounded-b-none",value:"LR",type:"button",children:t.jsx(a.LuIcon,{icon:go})}),t.jsx(a.ToggleGroup.IconItem,{className:"rounded-t-none",value:"TB",type:"button",children:t.jsx(a.LuIcon,{icon:mo})})]}),t.jsx(a.Separator,{size:"sm"}),t.jsxs(a.ButtonGroup,{className:"flex flex-col",size:"sm",accentColor:"base",variant:"soft",children:[t.jsx(a.IconButton,{className:"rounded-b-none",onClick:ie,type:"button",children:t.jsx(a.LuIcon,{icon:Z})}),t.jsx(a.IconButton,{onClick:G,radius:"none",type:"button",children:t.jsx(a.LuIcon,{icon:ui})}),t.jsx(a.IconButton,{className:"rounded-t-none",onClick:ce,type:"button",children:t.jsx(a.LuIcon,{icon:Eo})})]})]}),t.jsx(_.Panel,{position:"bottom-right",children:t.jsxs(a.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[r&&t.jsx(a.Button,{type:"button",variant:"soft",accentColor:"base",onClick:r,children:"Cancel"}),t.jsx(a.Button,{type:"submit",variant:"surface",children:"Save"})]})})]}),!!((Q=i.fields)!=null&&Q.message)&&t.jsx(a.Text,{size:"xs",accentColor:"danger",children:i.fields.message})]})});Xr.displayName="FormBuilderFlowBuilder";const ta=(i,n,e={})=>{const{conditions:r=!1}=e,o=i.get(n.identifier);if(!o)throw new Error(`Attempting to reseed serialized section with identifier ${n.identifier} which is not present in the reseeded identifier map`);const s=new Map,l=n.fields.map(c=>{const h=N.v4(),{image:p,...m}=c;return s.set(c.identifier,h),{...m,identifier:h}}),f={};if(r)for(const[c,h]of Object.entries(n.conditions??{})){const p=i.get(c);if(!p)continue;const m=h.map(g=>{const V=s.get(g.fieldId);if(!V)throw new Error(`Serialized condition referencing undefined field with identifier: ${g.fieldId}`);return{...g,fieldId:V}});f[p]=m}return{...n,identifier:o,conditions:f,fields:l}},ra=(i,n={})=>{const e=new Map(i.map(r=>[r.identifier,N.v4()]));return i.map(r=>ta(e,r,n))},jn=(i,n)=>{const e={},r=i.filter(o=>o instanceof X);for(const o of i)if(o instanceof X){const s=r.filter(f=>o.identifier in f.conditions);if(s.length>0&&!s.some(f=>{const c=f.getConditions(o.identifier);return new Mi(c).applyConditions(n)}))continue;const l=o.getErrors(n);Object.assign(e,l)}else{if(!(o instanceof k))throw new Error("Invalid field type");const s=o.identifier,l=o.getError(Hn(n,s));l&&so(e,s,l)}return e},oa=async i=>{const n={},e=[];for(const r of i){const{fields:o}=r,s=[];for(const l of o){if(l.image){if(l.image instanceof Promise)try{n[l.identifier]=await l.image}catch(f){console.error("Failed to get image from promise",f)}else n[l.identifier]=l.image;delete l.image}s.push(l)}e.push({...r,fields:s})}return{fields:e,images:n}};async function aa(i){const n={};for(const[e,r]of Object.entries(i))n[e]=await Promise.all(r);return n}class Ne extends De{constructor(e){super();C(this,"fieldSections");C(this,"fieldObserver",()=>{this.notify(this)});C(this,"initFields",e=>{for(const r of e)r.observe(this.fieldObserver);return e});this.fieldSections=this.initFields(e)}serialize(){return this.fieldSections.map(e=>e.serialize())}static deserialize(e){return new Ne(e.map(X.deserialize))}static reseedFieldSections(e,r){return ra(e,r)}getFields(){return this.fieldSections.flatMap(e=>e.getFields())}getFieldSections(){return this.fieldSections}addFieldSection(e,r){const o=[...this.fieldSections];o.splice(r??this.fieldSections.length,0,e),this.fieldSections=this.initFields(o),this.notify(this)}removeFieldSection(e){const r=this.fieldSections.filter(o=>o.identifier!==e.identifier);for(const o of r)o.removeConditional(o.identifier);this.fieldSections=this.initFields(r),this.notify(this)}moveFieldSection(e,r){const o=[...this.fieldSections],[s]=o.splice(e,1);o.splice(r,0,s),this.fieldSections=this.initFields(o),this.notify(this)}getSectionDependencyGraph(){const e=new oo.DirectedGraph({type:"directed"});for(const r of this.fieldSections)for(const o of Object.keys(r.conditions))e.mergeEdge(r.identifier,o);return e}getDependenciesOfSection(e){const r=this.getSectionDependencyGraph(),o=new Map(this.fieldSections.map(l=>[l.identifier,l])),s=[];return ao.bfsFromNode(r,e,(l,f,c)=>{s.push(o.get(l))},{mode:"in"}),s}cleanValues(e){return Ii(this.getFields(),e)}cleanSerializedValues(e){return Ln(this.getFields(),e)}deserializeValues(e,r){return _r(this.getFields(),e,r)}serializeValues(e,r){return Or(this.getFields(),e,r)}initializeValues(e){return Br(this.getFields(),e)}validateValues(e){return jn(this.getFieldSections(),e)}areValuesValid(e){return Object.keys(this.validateValues(e)).length===0}deserializeConditions(e){return On(this.getFields(),e)}cleanConditions(e){return Tn(this.getFields(),e)}serializeConditions(e){return Ir(this.getFields(),e)}cleanSerializedConditions(e){return _n(this.getFields(),e)}changedFieldValues(e,r){return Ar(this.getFields(),e,r)}unchangedFieldValues(e,r){return Er(this.getFields(),e,r)}areValuesEqual(e,r){return Bn(this.getFields(),e,r)}areValuesBlank(e){return $r(this.getFields(),e)}blankValues(){return An(this.getFields())}extractFilesAndPromisesFromFieldValues(e){return Tr(this.getFields(),e)}insertFilesAndPromisesToFieldValues(e,r){return Lr(this.getFields(),e,r)}}const Kr=d.memo(i=>{const{sourceFieldSection:n,targetFieldSection:e}=i,r=d.useMemo(()=>n.getConditions(e.identifier),[n,e.identifier]),o=d.useCallback(()=>{n.removeConditional(e.identifier)},[n,e.identifier]),s=d.useCallback(f=>{n.addCondition(e.identifier,$n(f))},[n,e.identifier]),l=d.useCallback(f=>{n.removeCondition(e.identifier,f)},[n,e.identifier]);return t.jsxs(a.Card,{className:"flex flex-col gap-2",size:"sm",children:[t.jsxs(a.ButtonGroup,{className:"flex justify-between gap-2",size:"sm",accentColor:"base",variant:"soft",children:[t.jsxs(a.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[t.jsx(a.LuIcon,{icon:et}),n.label??Vn]}),t.jsx(a.IconButton,{type:"button",onClick:o,variant:"ghost",children:t.jsx(a.LuIcon,{icon:ue})})]}),t.jsxs("div",{className:"flex h-max w-full flex-wrap gap-2",children:[r.map(f=>f.render({onRemove:l})),t.jsx(Pn,{fields:n.fields,onSelectField:s,align:"start",children:t.jsx(a.IconButton,{type:"button",size:"sm",variant:"soft",accentColor:"base",children:t.jsx(a.LuIcon,{icon:Z})})})]})]})});Kr.displayName="FieldSectionConditionalItem";const Yr=d.memo(i=>{const{fieldSection:n}=i,{fieldSchema:e}=d.use(ee),r=d.useMemo(()=>e.fieldSections.filter(c=>n.identifier in c.conditions),[e.fieldSections,n.identifier]),o=d.useCallback(c=>{c.addConditional(n.identifier)},[n.identifier]),s=d.useCallback(c=>{n.setOptions({label:c.target.value})},[n]),l=d.useCallback(c=>{n.setOptions({description:c.target.value})},[n]),f=d.useMemo(()=>{const c=e.getSectionDependencyGraph();return e.fieldSections.filter(h=>!Un.willCreateCycle(c,h.identifier,n.identifier))},[n.identifier,e]);return t.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[t.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[t.jsx(a.Input.Root,{variant:"outline",size:"md",children:t.jsx(a.Input.Field,{placeholder:"Enter a section label (optional)",value:n.label??"",onChange:s,maxLength:200})}),t.jsx(a.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:n.description??"",onChange:l,maxLength:1e3,resize:"vertical",size:"md"})]}),t.jsx(a.Separator,{size:"full"}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("div",{className:"flex justify-between gap-2",children:[t.jsx(a.Text,{accentColor:"base",children:"Conditions"}),t.jsx(kr,{fieldSections:f,onSelectFieldSection:o,children:t.jsxs(a.Button,{type:"button",variant:"soft",size:"sm",className:"w-max",children:[t.jsx(a.LuIcon,{icon:Z}),"Add condition"]})})]}),r.map(c=>t.jsx(Kr,{sourceFieldSection:c,targetFieldSection:n},c.identifier))]}),t.jsx(a.Separator,{size:"full"})]})});Yr.displayName="FieldSectionBuilder";const Zr=d.memo(i=>{const{fieldSection:n,sectionIndex:e}=i,{fieldSchema:r}=d.use(ee),o=a.useAlertDialog(),s=d.useCallback(()=>{r.removeFieldSection(n)},[r,n]),l=d.useCallback(w=>{const S=w==="up"?e-1:e+1;r.moveFieldSection(e,S)},[r,e]),f=d.useCallback(()=>{r.addFieldSection(n.duplicate(N.v4()))},[r,n]),c=d.useCallback(w=>{n.addField(_i(w))},[n]),h=d.useCallback(()=>{l("up")},[l]),p=d.useCallback(()=>{l("down")},[l]),m=d.useCallback(async()=>{const w=[n.serialize()],S=Ne.reseedFieldSections(w,{conditions:!1}),v=JSON.stringify(S);await navigator.clipboard.writeText(v),a.toast.success({title:"Section copied"})},[n]),g=d.useCallback(async()=>{const S=r.getDependenciesOfSection(n.identifier).map(q=>q.serialize()),v=Ne.reseedFieldSections(S,{conditions:!0}),I=JSON.stringify(v);await navigator.clipboard.writeText(I),a.toast.success({title:"Section copied"})},[n,r]),V=d.useCallback(async()=>{const w=r.getDependenciesOfSection(n.identifier),S=w.length>1,v=w.length-1;S?o({title:"Copy section dependencies?",description:`This section has ${v} dependent section${v>1?"s":""} that will also be copied to maintain the conditions. Do you want to include these dependencies?`,action:"Include",onAction:g,cancel:"Dont include",onCancel:m}):m()},[n,r,o,g,m]),F=d.useCallback(async()=>{let w="";try{w=await navigator.clipboard.readText()}catch{a.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const S=w.trim();if(!S){a.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let v;try{v=JSON.parse(S)}catch{a.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const I=Array.isArray(v)?v:[v],q=[];for(const z of I){if(!z||typeof z!="object")continue;const b=z;if(b.type!=="section"||!Array.isArray(b.fields))continue;const L={type:"section",identifier:typeof b.identifier=="string"?b.identifier:N.v4(),label:typeof b.label=="string"||b.label===null?b.label:null,description:typeof b.description=="string"||b.description===null?b.description:null,conditions:b.conditions&&typeof b.conditions=="object"?b.conditions:{},fields:b.fields};try{q.push(X.deserialize(L))}catch{}}if(q.length===0){a.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}q.forEach((z,b)=>{r.addFieldSection(z,e+1+b)}),a.toast.success({title:"Section pasted",description:"Serialized JSON imported successfully."})},[r,e]);return t.jsxs(a.Card,{variant:"outline",className:"flex w-full items-center justify-between gap-4",size:"sm",children:[t.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[t.jsx(Yr,{fieldSection:n}),t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs("div",{className:"flex justify-between gap-2",children:[t.jsx(a.Text,{accentColor:"base",size:"md",children:"Fields"}),t.jsx(Oi,{onSelectFieldType:c,size:"sm",children:t.jsxs(a.Button,{type:"button",variant:"soft",size:"sm",children:[t.jsx(a.LuIcon,{icon:Z})," Add field"]})})]}),n.fields.map((w,S)=>t.jsx(Dn,{field:w,fieldSection:n,fieldIndex:S,sectionIndex:e},w.identifier))]})]}),t.jsxs(a.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[t.jsx(a.IconButton,{type:"button",onClick:h,children:t.jsx(a.LuIcon,{icon:nt})}),t.jsx(a.IconButton,{type:"button",onClick:p,children:t.jsx(a.LuIcon,{icon:it})}),t.jsxs(a.Menu.Root,{align:"end",children:[t.jsx(a.Menu.ClickTrigger,{children:t.jsx(a.IconButton,{type:"button",children:t.jsx(a.LuIcon,{icon:Qn})})}),t.jsxs(a.Menu.Content,{size:"sm",children:[t.jsxs(a.Menu.Item,{onSelect:f,children:[t.jsx(a.LuIcon,{icon:Ai}),"Duplicate section"]}),t.jsxs(a.Menu.Item,{onSelect:V,children:[t.jsx(a.LuIcon,{icon:Kn}),"Copy JSON"]}),t.jsxs(a.Menu.Item,{onSelect:F,children:[t.jsx(a.LuIcon,{icon:Yn}),"Paste JSON"]}),t.jsxs(a.Menu.Item,{onSelect:s,children:[t.jsx(a.LuIcon,{icon:ue}),"Delete section"]})]})]})]})]})});Zr.displayName="FieldSectionWithActions";const Qr=d.memo(()=>{var c;const{handleSubmit:i}=Y.useFormContext(),{errors:n}=Y.useFormState(),{onSave:e,onCancel:r}=d.use(ee),{fieldSchema:o}=d.use(ee),s=d.useCallback(()=>{o.addFieldSection(new X({identifier:N.v4(),fields:[]}))},[o]),l=d.useCallback(async()=>{try{const h=o.serialize(),p=Ne.reseedFieldSections(h),m=JSON.stringify(p);await navigator.clipboard.writeText(m),a.toast.success({title:"Sections copied",description:"All sections JSON copied to clipboard."})}catch{a.toast.error({title:"Copy failed",description:"Unable to copy the sections JSON."})}},[o]),f=d.useCallback(async()=>{let h="";try{h=await navigator.clipboard.readText()}catch{a.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const p=h.trim();if(!p){a.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let m;try{m=JSON.parse(p)}catch{a.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const g=Array.isArray(m)?m:[m],V=[];for(const w of g){if(!w||typeof w!="object")continue;const S=w;if(S.type!=="section"||!Array.isArray(S.fields))continue;const v={type:"section",identifier:typeof S.identifier=="string"?S.identifier:N.v4(),label:typeof S.label=="string"||S.label===null?S.label:null,description:typeof S.description=="string"||S.description===null?S.description:null,conditions:S.conditions&&typeof S.conditions=="object"?S.conditions:{},fields:S.fields};try{V.push(X.deserialize(v))}catch{}}if(V.length===0){a.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}const F=o.fieldSections.length;V.forEach((w,S)=>{o.addFieldSection(w,F+S)}),a.toast.success({title:"Sections pasted",description:"Serialized JSON imported successfully."})},[o]);return t.jsxs("form",{className:"flex flex-col gap-4",onSubmit:i(e),children:[t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.jsxs(a.Button,{type:"button",variant:"soft",size:"sm",onClick:l,children:[t.jsx(a.LuIcon,{icon:Kn})," Copy JSON"]}),t.jsxs(a.Button,{type:"button",variant:"soft",size:"sm",onClick:f,children:[t.jsx(a.LuIcon,{icon:Yn})," Paste JSON"]})]}),o.fieldSections.map((h,p)=>t.jsx(Zr,{fieldSection:h,sectionIndex:p},h.identifier)),t.jsxs(a.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:s,children:[t.jsx(a.LuIcon,{icon:Z})," Add section"]})]}),!!((c=n.fields)!=null&&c.message)&&t.jsx(a.Text,{size:"xs",accentColor:"danger",children:n.fields.message}),t.jsxs(a.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[r&&t.jsx(a.Button,{type:"button",variant:"soft",accentColor:"base",onClick:r,children:"Cancel"}),t.jsx(a.Button,{type:"submit",variant:"surface",children:"Save"})]})]})});Qr.displayName="FormBuilderListBuilder";function Rr(i){const n=e=>{const r={};for(const[o,s]of Object.entries(e))typeof s=="string"?r[o]={type:"validate",message:s}:r[o]=n(s);return r};return n(i)}const eo=d.memo(d.forwardRef((i,n)=>{const{disabled:e=!1,fieldSchema:r,values:o={},onValuesChange:s,onSubmit:l,submitText:f="Submit",hideSubmit:c=!1,cancelText:h,onCancel:p,hideCancel:m=!1,className:g,submitButtonProps:V,cancelButtonProps:F,cancelIcon:w,submitIcon:S,size:v="md"}=i,I=d.useMemo(()=>r.initializeValues(o),[r,o]),q=d.useCallback(Q=>{l==null||l(Q)},[l]),z=Y.useForm({values:I,mode:"onBlur",criteriaMode:"all",disabled:e,resolver:Q=>{const J=r.validateValues(Q),K=Rr(J);return Object.keys(J).length>0?{values:{},errors:K}:{values:Q,errors:{}}}}),b=d.useCallback(Q=>{s==null||s(Q)},[s]);d.useEffect(()=>{const{unsubscribe:Q}=z.watch((J,{type:K})=>{K==="change"&&b(J)});return()=>{Q()}},[z,b]);const L=at(r.getFieldSections()),G=d.useMemo(()=>({fieldSchema:r,size:v}),[r,v]),ie=!m&&!!p,ce=!c;return t.jsx(Y.FormProvider,{...z,children:t.jsx(B,{value:G,children:t.jsxs("form",{ref:n,className:R.cx(g,"flex flex-col gap-4"),onSubmit:z.handleSubmit(q),children:[t.jsx("div",{className:Qo({size:v}),children:L}),!e&&(ie||ce)?t.jsxs(a.ButtonGroup,{className:"flex items-center justify-end gap-2",size:v,children:[ie?t.jsxs(a.Button,{accentColor:"base",type:"button",variant:"soft",onClick:p,...F,children:[t.jsx(a.LuIcon,{icon:w??re}),h]}):null,ce?t.jsxs(a.Button,{type:"submit",accentColor:"primary",variant:"surface",...V,children:[t.jsx(a.LuIcon,{icon:S??W}),f]}):null]}):null]})})})})),io=d.memo(()=>{const{fieldSchema:i}=d.use(ee);return t.jsx(eo,{fieldSchema:i,disabled:!1})});io.displayName="FormBuilderPreview";const no=d.memo(i=>{const{children:n,initialFields:e,onSave:r,onCancel:o,disableRequiredFields:s=!1}=i,l=d.useCallback(F=>{var q;const w={};(!F.fields||F.fields.length===0)&&(w.fields="At least one field is required.");const S=[];for(const[z,b]of F.fields.entries())for(const[L,G]of b.fields.entries()){const ie=((q=Pr(G.type,`fields.${z}.fields.${L}`))==null?void 0:q.map(({field:ce})=>ce))??[];S.push(...ie)}const v={};for(const z of S)v[z.identifier]=Hn(F,z.identifier);const I=jn(S,v);return Object.keys(I).length>0&&(w.fields=I.fields),Object.keys(w).length>0&&a.toast.error({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),w},[]),f=d.useMemo(()=>({fields:e??[]}),[e]),c=Y.useForm({values:f,mode:"onSubmit",criteriaMode:"all",reValidateMode:"onSubmit",resolver:F=>{const w=l(F),S=Rr(w);return Object.keys(w).length>0?{values:{},errors:S}:{values:F,errors:{}}}}),h=d.useCallback(F=>{c.setValue("fields",F.serialize())},[c]),p=Y.useWatch({control:c.control,compute:F=>F.fields}),m=d.useMemo(()=>{const F=Ne.deserialize(p);return F.observe(h),F},[p,h]),g=d.useMemo(()=>({fieldSchema:m,disableRequiredFields:s,onSave:r,onCancel:o}),[s,r,o,m]),V=d.useMemo(()=>({fieldSchema:m,size:"sm"}),[m]);return t.jsx(ee,{value:g,children:t.jsx(B,{value:V,children:t.jsx(Y.FormProvider,{...c,children:n})})})});no.displayName="FormBuilderRoot";const sa={Root:no,FlowBuilder:Xr,ListBuilder:Qr,Preview:io};u.BaseCondition=P,u.BaseField=k,u.BaseFormElement=Di,u.BaseOptionsField=Pe,u.BaseStringField=Hi,u.BooleanEqualsConditionModifier=bt,u.BooleanField=fe,u.BooleanFieldCondition=He,u.BooleanFieldConditionCell=Xt,u.BooleanFieldInput=Gi,u.BooleanNotEqualsConditionModifier=Nt,u.CheckboxListField=pe,u.CheckboxListFieldCondition=Je,u.CheckboxListFieldConditionCell=Yt,u.CheckboxListFieldInput=Ji,u.ConditionManager=Mi,u.DateAfterConditionModifier=qt,u.DateBeforeConditionModifier=It,u.DateEqualsConditionModifier=Mt,u.DateField=xe,u.DateFieldCondition=We,u.DateFieldConditionCell=Qt,u.DateFieldInput=Wi,u.DateNotEqualsConditionModifier=xt,u.DateRangeInConditionModifier=Ot,u.DateRangeNotInConditionModifier=_t,u.DoesNotHaveFilesConditionModifier=Lt,u.FIELD_TYPES=St,u.FieldSchema=Ne,u.FieldSection=X,u.FieldSectionLayout=En,u.FieldTypeGroup=O,u.FieldTypeToClsMapping=Cn,u.FieldsRenderer=eo,u.FileCard=$i,u.FormBuilder=sa,u.HasFilesConditionModifier=Tt,u.ImageCard=Zi,u.ImageFile=Me,u.ImageViewer=ji,u.ImageViewerProvider=ot,u.InputWithLabel=A,u.LONG_TEXT_FIELD_MAX_LENGTH=je,u.MultiSelectField=te,u.MultiSelectFieldCondition=Xe,u.MultiSelectFieldConditionCell=er,u.MultiSelectFieldInput=Xi,u.MultiStringField=he,u.MultiStringFieldCondition=Ke,u.MultiStringFieldConditionCell=nr,u.MultiStringFieldInput=Ui,u.NumberEqualsConditionModifier=yn,u.NumberField=H,u.NumberFieldCondition=Ye,u.NumberFieldConditionCell=rr,u.NumberFieldInput=ki,u.NumberGreaterThanConditionModifier=wn,u.NumberGreaterThanOrEqualsConditionModifier=Fn,u.NumberLessThanConditionModifier=Sn,u.NumberLessThanOrEqualsConditionModifier=zn,u.NumberNotEqualsConditionModifier=vn,u.NumberRangeInConditionModifier=bn,u.NumberRangeNotInConditionModifier=Nn,u.OTPField=me,u.OTPFieldCondition=Ze,u.OTPFieldConditionCell=ar,u.OTPFieldInput=Yi,u.Observable=De,u.PassFailArrayExcludesConditionModifier=$t,u.PassFailArrayIncludesConditionModifier=Et,u.PassFailEqualsConditionModifier=Bt,u.PassFailField=Ve,u.PassFailFieldCondition=Qe,u.PassFailFieldConditionCell=lr,u.PassFailFieldInput=nn,u.PassFailNotEqualsConditionModifier=At,u.RadioField=ye,u.RadioFieldCondition=Re,u.RadioFieldConditionCell=cr,u.RadioFieldInput=rn,u.RatingField=ve,u.RatingFieldCondition=ei,u.RatingFieldConditionCell=hr,u.RatingFieldInput=on,u.SHORT_TEXT_FIELD_MAX_LENGTH=ln,u.ScanField=qe,u.ScanFieldCondition=ii,u.ScanFieldConditionCell=pr,u.ScanFieldInput=sn,u.Scanner=mi,u.ScannerProvider=gt,u.SelectField=oe,u.SelectFieldCondition=ni,u.SelectFieldConditionCell=gr,u.SelectFieldInput=Ki,u.StringArrayEqualsConditionModifier=wi,u.StringArrayEveryConditionModifier=vi,u.StringArrayExcludesConditionModifier=xn,u.StringArrayIncludesConditionModifier=Mn,u.StringArrayNoneConditionModifier=zi,u.StringArrayNotEqualsConditionModifier=Fi,u.StringArraySomeConditionModifier=Si,u.StringEqualsConditionModifier=le,u.StringExcludesConditionModifier=Be,u.StringField=Se,u.StringFieldCondition=ti,u.StringFieldConditionCell=Vr,u.StringFieldInput=dn,u.StringIncludesConditionModifier=Le,u.StringNotEqualsConditionModifier=de,u.TextField=ze,u.TextFieldCondition=ri,u.TextFieldConditionCell=vr,u.TextFieldInput=cn,u.TimeAfterConditionModifier=Ut,u.TimeBeforeConditionModifier=jt,u.TimeEqualsConditionModifier=Dt,u.TimeField=Oe,u.TimeFieldCondition=oi,u.TimeFieldConditionCell=zr,u.TimeFieldControl=yi,u.TimeFieldInput=pn,u.TimeNotEqualsConditionModifier=Pt,u.TimeRangeInConditionModifier=Gt,u.TimeRangeNotInConditionModifier=kt,u.UNLABELLED_FIELD_LABEL=$,u.UNLABELLED_SECTION_LABEL=Vn,u.URLField=_e,u.URLFieldCondition=si,u.URLFieldConditionCell=Nr,u.URLFieldInput=gn,u.UTC_OFFSETS=un,u.UTC_OFFSETS_SET=Ct,u.UUIDFile=ae,u.UUIDPromise=Ce,u.UploadField=we,u.UploadFieldCondition=ai,u.UploadFieldConditionCell=Fr,u.UploadFieldInput=mn,u.VideoCard=Ri,u.VideoFile=Qi,u.areFieldValuesBlank=$r,u.areFieldValuesEqual=Bn,u.areFileAndPromiseArraysEqual=pi,u.arePassFieldValuesEqual=ht,u.areSerializedPassFailFieldValuesEqual=ft,u.awaitFilesAndPromises=aa,u.blankFieldValues=An,u.changedFieldValues=Ar,u.cleanConditions=Tn,u.cleanFieldValues=Ii,u.cleanSerializedConditions=_n,u.cleanSerializedFieldValues=Ln,u.createCondition=$n,u.createConditionModifierConfig=y,u.createField=_i,u.createTime=hn,u.deserialize=qr,u.deserializeCondition=xr,u.deserializeConditions=On,u.deserializeField=xi,u.deserializeFieldValues=_r,u.deserializeFields=Xo,u.deserializeOnlyFields=Ko,u.deserializePassFailFieldValue=ut,u.extractFilesAndPromisesFromFieldValues=Tr,u.fieldDataMapping=T,u.fieldSpacingCva=qi,u.fieldTypeGroupDataMapping=zt,u.flattenFields=Yo,u.formatTime=Vi,u.formatUTCOffset=Ci,u.getCurrentUTCOffset=yt,u.getFieldsMapping=Zo,u.getUTCMinuteOfDay=se,u.getUTCOffsetMinutes=vt,u.initializeFieldValues=Br,u.insertFilesAndPromisesToFieldValues=Lr,u.isFileAndPromiseArray=st,u.isPassFailFieldStatus=tn,u.isPassFailFieldValue=dt,u.isSerializedPassFailFieldValue=lt,u.isStringArray=$e,u.isTime=E,u.isTimeInRange=fn,u.isTimeRange=Ge,u.isUTCOffset=gi,u.maxFileSizeB=Ft,u.maxFileSizeKB=wt,u.maxFileSizeMB=Te,u.parseTime=Ue,u.passFailFieldStatusMapping=ge,u.passFailFieldStatuses=Ie,u.separateImagesFromFields=oa,u.serializeConditions=Ir,u.serializeFieldValues=Or,u.serializePassFailFieldValue=ct,u.unchangedFieldValues=Er,u.useConditionManager=Jo,u.useFieldInput=D,u.useFieldInputs=fi,u.useFieldSectionInputs=at,u.useImageViewer=hi,u.useObjectUrl=Pi,u.useScanner=Uo,u.useScannerContext=pt,u.validateFieldValues=jn,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("@overmap-ai/blocks"),require("class-variance-authority"),require("react"),require("@xyflow/react/dist/style.css"),require("@xyflow/react"),require("graphology-dag"),require("react-hook-form"),require("uuid"),require("@hello-pangea/dnd"),require("file-saver"),require("@overmap-ai/hooks"),require("react-zxing"),require("@dagrejs/dagre"),require("graphology"),require("graphology-traversal"),require("lodash.get"),require("lodash.set")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@overmap-ai/blocks","class-variance-authority","react","@xyflow/react/dist/style.css","@xyflow/react","graphology-dag","react-hook-form","uuid","@hello-pangea/dnd","file-saver","@overmap-ai/hooks","react-zxing","@dagrejs/dagre","graphology","graphology-traversal","lodash.get","lodash.set"],n):(c=typeof globalThis<"u"?globalThis:c||self,n(c.forms={},c.jsxRuntime,c.blocks,c.classVarianceAuthority,c.React,null,c.react,c.graphologyDag,c.reactHookForm,c.uuid,c.dnd,c.fileSaver,c.hooks,c.reactZxing,c.Dagre,c.graphology,c.graphologyTraversal,c.get,c.set))})(this,(function(c,n,o,Q,d,aa,O,Dn,Y,b,Oi,Pn,eo,io,jn,no,to,Un,ro){"use strict";const oo=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ao=i=>i.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase()),Gn=i=>{const e=ao(i);return e.charAt(0).toUpperCase()+e.slice(1)},kn=(...i)=>i.filter((e,t,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===t).join(" ").trim(),lo=i=>{for(const e in i)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var so={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const co=d.forwardRef(({color:i="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:r,className:a="",children:l,iconNode:s,...h},u)=>d.createElement("svg",{ref:u,...so,width:e,height:e,stroke:i,strokeWidth:r?Number(t)*24/Number(e):t,className:kn("lucide",a),...!l&&!lo(h)&&{"aria-hidden":"true"},...h},[...s.map(([f,p])=>d.createElement(f,p)),...Array.isArray(l)?l:[l]]));const N=(i,e)=>{const t=d.forwardRef(({className:r,...a},l)=>d.createElement(co,{ref:l,iconNode:e,className:kn(`lucide-${oo(Gn(i))}`,`lucide-${i}`,r),...a}));return t.displayName=Gn(i),t};const uo=N("align-justify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);const ho=N("arrow-down-up",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);const fo=N("arrow-left-right",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);const po=N("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const J=N("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const si=N("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const _i=N("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const go=N("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const mo=N("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);const Co=N("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"}]]);const Vo=N("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"}]]);const Hn=N("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Jn=N("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);const yo=N("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"}]]);const Wn=N("clipboard-paste",[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]);const vo=N("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"}]]);const Ti=N("copy",[["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"}]]);const Xn=N("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Kn=N("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);const So=N("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const zo=N("file",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);const Fo=N("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);const wo=N("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);const Yn=N("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const Zn=N("layout-panel-top",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);const bo=N("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const No=N("list-checks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);const Mo=N("list-todo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);const xo=N("list",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);const Io=N("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);const di=N("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Qn=N("move-down",[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);const Rn=N("move-up",[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);const Z=N("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const qo=N("rectangle-ellipsis",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);const Oo=N("scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);const _o=N("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const To=N("square-check",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const Lo=N("square-dashed",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]]);const et=N("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);const Bo=N("text-cursor-input",[["path",{d:"M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6",key:"1528k5"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1",key:"1mj8rg"}],["path",{d:"M9 6v12",key:"velyjx"}]]);const Ao=N("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);const se=N("trash",[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const Li=N("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const Eo=N("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);const ne=N("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Bi=d.memo(i=>{const{ref:e,file:t,className:r,error:a,rightSlot:l,size:s,...h}=i,u=()=>a?n.jsxs(n.Fragment,{children:[n.jsx(o.LuIcon,{icon:_i,color:"var(--base-a11)"}),n.jsx(o.Text,{accentColor:"base",className:"truncate",size:s,children:a})]}):t?n.jsxs(n.Fragment,{children:[n.jsx(o.LuIcon,{icon:zo,color:"var(--base-a11)"}),n.jsx(o.Text,{className:"truncate",size:s,children:t.name})]}):n.jsx(n.Fragment,{children:n.jsx("div",{className:"flex w-full justify-center",children:n.jsx(o.Spinner,{size:s})})});return n.jsxs(o.Card,{className:Q.cx(r,"flex w-full items-center gap-2"),ref:e,size:"xs",...h,children:[u(),l]})});Bi.displayName="FileCard";function Ae(i){return Array.isArray(i)?i.every(e=>typeof e=="string"):!1}class Ee{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 Ai extends Ee{identifier;constructor(e){const{identifier:t}=e;super(),this.identifier=t}getOptions(){return{identifier:this.identifier}}setOptions(e){this.identifier=e.identifier??this.identifier,this.notify(this)}serialize(){return{type:this.type,identifier:this.identifier}}}class k extends Ai{label;description;required;image;constructor(e){const{label:t,description:r=null,required:a,image:l,...s}=e;super(s),this.label=t,this.description=r,this.required=a,this.image=l}getError(e){if(!(!this.required&&this.isValueBlank(e))){if(this.required&&this.isValueBlank(e))return"This field is required.";for(const t of this.getFieldValidators()){const r=t(e);if(r)return r}}}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(e){const{label:t,description:r=null,required:a,image:l,...s}=e;this.label=t??this.label,this.description=r??this.description,this.required=a??this.required,this.image=l??this.image,super.setOptions(s)}isValueBlank(e){return this.areValuesEqual(e,this.blankValue())}cleanValue(e){return e}isValueClean(e){return this.areValuesEqual(e,this.cleanValue(e))}cleanSerializedValue(e){return e}isSerializedValueClean(e){return this.areSerializedValuesEqual(e,this.cleanSerializedValue(e))}isSerializedValueBlank(e){return this.areSerializedValuesEqual(e,this.blankSerializedValue())}getFieldValidators(){return[]}}const L=d.createContext({}),Ei=i=>{const[e,t]=d.useState(null);return d.useLayoutEffect(()=>{const r=URL.createObjectURL(i);return t(r),()=>{URL.revokeObjectURL(r)}},[i]),e},we=d.memo(i=>{const{file:e,...t}=i,r=Ei(e);return n.jsx("img",{src:r??void 0,alt:e.name,...t})});we.displayName="ImageFile";const it=d.createContext(()=>{throw new Error("No ImageViewerProvider found")}),ci=()=>d.useContext(it),$i=d.memo(i=>{const{file:e,onClose:t}=i,r=d.useCallback(()=>{Pn.saveAs(e,e.name)},[e]);return n.jsx(o.Overlay.Root,{open:!0,onOpenChange:t,children:n.jsxs(o.Overlay.Content,{onOpenAutoFocus:o.preventDefault,children:[n.jsxs(o.ButtonGroup,{className:"absolute right-0 top-0 flex items-center gap-2 p-2",accentColor:"base",variant:"ghost",children:[n.jsxs(o.Tooltip.Root,{children:[n.jsx(o.Tooltip.Trigger,{asChild:!0,children:n.jsx(o.IconButton,{onClick:r,"aria-label":"download",children:n.jsx(o.LuIcon,{icon:Xn})})}),n.jsx(o.Tooltip.Content,{size:"sm",children:"Download"})]}),n.jsx(o.Separator,{orientation:"vertical",size:"sm"}),n.jsx(o.Overlay.Close,{asChild:!0,children:n.jsx(o.IconButton,{onClick:t,"aria-label":"close",children:n.jsx(o.LuIcon,{icon:ne})})})]}),n.jsx("figure",{className:"flex size-full items-center justify-center overflow-hidden p-4",children:n.jsx(we,{className:"max-h-full max-w-full",file:e})})]})})});$i.displayName="ImageViewer";const nt=d.memo(i=>{const{children:e}=i,[t,r]=d.useState(null),a=d.useCallback(()=>{r(null)},[]),l=d.useCallback(h=>{r(h(a))},[a]),s=d.useCallback(()=>{t&&(t.onClose&&t.onClose(),a())},[a,t]);return n.jsxs(it.Provider,{value:l,children:[e,t&&n.jsx($i,{file:t.file,onClose:s})]})});nt.displayName="FileViewerProvider";const B=d.memo(i=>{const{label:e,error:t,description:r,required:a,children:l,inputId:s,image:h,size:u}=i,[f,p]=d.useState(void 0),g=ci();d.useEffect(()=>{h instanceof Promise?h.then(p).catch(console.error):p(h)},[h]);const m=d.useCallback(()=>{f&&g(()=>({file:f}))},[g,f]),C=a?`${e} *`:e;return n.jsxs("div",{className:"flex flex-col gap-1",children:[f&&n.jsx(we,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:f,onClick:m}),(!!e||!!r)&&n.jsxs("div",{className:"flex flex-col",children:[n.jsx("label",{className:"w-max max-w-full",htmlFor:s,children:n.jsx(o.Text,{size:u,className:"text-wrap",children:C})}),!!r&&n.jsx(o.Text,{accentColor:"base",size:u,children:r})]}),l,!!t&&n.jsx(o.Text,{accentColor:"danger",size:u,children:t})]})});B.displayName="InputWithLabel";const tt=i=>i.map(e=>n.jsx(d.Fragment,{children:e.render()},e.identifier)),ui=i=>i.map(e=>n.jsx(d.Fragment,{children:e.render()},e.identifier)),D=i=>{const{field:e}=i,{field:{value:t,name:r,onChange:a,onBlur:l,disabled:s},fieldState:{isTouched:h,error:u}}=Y.useController({name:e.identifier});return{value:t,name:r,disabled:s,isTouched:h,error:u?.message??"",onChange:a,onBlur:l}},Di=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),[f,p]=d.useState(""),[g,m]=d.useState(""),C=d.useCallback(F=>{s(F),l()},[s,l]),v=d.useCallback(F=>{r&&r.findIndex(w=>w===F.target.value.trim())>=0?m("All options must be unique"):F.target.value?m(""):m("Option cannot be empty"),p(F.target.value)},[p,r]),y=d.useCallback(()=>{if(g)return;if(!f.trim()){m("Option cannot be empty");return}const F=f.trim();C([...r,F]),p("")},[f,g,C,r]),S=d.useCallback(F=>{F.key==="Enter"&&(F.preventDefault(),y())},[y]),z=d.useCallback(F=>{const w=Array.from(r);w.splice(F,1),C(w)},[r,C]),x=d.useCallback(F=>{if(!F.destination)return;const w=F.source.index,T=F.destination.index,G=Array.from(r),[ee]=G.splice(w,1);G.splice(T,0,ee),C(G)},[C,r]),I=d.useCallback(()=>{l()},[l]);return n.jsx(Oi.DragDropContext,{onDragEnd:x,children:n.jsxs(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:g||h,image:e.image,children:[(!u||r.length===0)&&n.jsxs("div",{className:"flex gap-2",children:[n.jsx(o.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:t,children:n.jsx(o.Input.Field,{value:f,onChange:v,onKeyDown:S,id:e.identifier,placeholder:e.placeholder,onBlur:I,name:a,disabled:u})}),n.jsx(o.IconButton,{size:t,accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!g||u,onClick:y,children:n.jsx(o.LuIcon,{icon:Z})})]}),r.length!==0&&n.jsx(Oi.Droppable,{droppableId:`${e.identifier}-droppable`,children:F=>n.jsxs("div",{className:"flex flex-col gap-1",...F.droppableProps,ref:F.innerRef,children:[r.map((w,T)=>n.jsx(Oi.Draggable,{draggableId:`${w}-draggable`,index:T,isDragDisabled:u,children:({draggableProps:G,dragHandleProps:ee,innerRef:Be})=>n.jsxs(o.Badge,{...ee,...G,ref:Be,className:"flex items-center justify-between gap-2",accentColor:"base",size:t,variant:"soft",children:[n.jsx(o.Text,{className:"truncate",highContrast:!0,children:typeof w=="object"&&"label"in w?w.label:w}),n.jsx(o.IconButton,{className:"bg-transparent!",size:t,variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:u,onClick:()=>{z(T)},children:n.jsx(o.LuIcon,{icon:ne})})]})},`${e.identifier}-${w}-${T}`)),F.placeholder]})})]})})});Di.displayName="MultiStringFieldInput";class de extends k{type="multi-string";minLength;maxLength;placeholder;constructor(e){const{minimum_length:t,maximum_length:r,placeholder:a,...l}=e;super(l),this.minLength=t??0,this.maxLength=r??1/0,this.placeholder=a??"Press enter to add a new option"}render(){return n.jsx(Di,{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(e){return new de({...this.getOptions(),identifier:e})}setOptions(e){const{minimum_length:t,maximum_length:r,placeholder:a,...l}=e;this.minLength=t??this.minLength,this.maxLength=r??this.maxLength,this.placeholder=a??this.placeholder,super.setOptions(l)}serializeValue(e){return e}deserializeValue(e){return e}getFieldValidators(){const e=super.getFieldValidators();return e.push(t=>{if(t.length<this.minLength)return`Must have at least ${this.minLength} options.`}),e.push(t=>{if(t.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),e}static deserialize(e){return new de(e)}isSerializedValue(e){return Ae(e)}isValue(e){return Ae(e)}blankValue(){return[]}areValuesEqual(e,t){const r=new Set(e),a=new Set(t);return r.size===a.size&&r.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(e,t){const r=new Set(e),a=new Set(t);return r.size===a.size&&r.isSubsetOf(a)}}class $e extends k{options;constructor(e){const{options:t,...r}=e;super(r),this.options=t.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(e){const{options:t,...r}=e;this.options=t?.map(a=>(typeof a=="string"&&(a={label:a,value:a}),a))??this.options,super.setOptions(r)}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new de({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${t}options`,minimum_length:2}),showDirectly:!0}]}}const Pi=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(g=>{s(!!g),l()},[l,s]),p=d.useCallback(()=>{l()},[l]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,error:h,image:e.image,required:e.required,children:n.jsx(o.Checkbox.Root,{id:e.identifier,name:a,checked:r??!1,onCheckedChange:f,onBlur:p,size:t,accentColor:"base",variant:"surface",disabled:u,children:n.jsx(o.Checkbox.Indicator,{children:n.jsx(o.LuIcon,{icon:J})})})})});Pi.displayName="BooleanFieldInput";class ce extends k{type="boolean";constructor(e){super(e)}serialize(){return super.serialize()}getOptions(){return super.getOptions()}setOptions(e){super.setOptions(e)}duplicate(e){return new ce({...this.getOptions(),identifier:e})}static deserialize(e){return new ce(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Pi,{field:this})}isSerializedValue(e){return typeof e=="boolean"}isValue(e){return typeof e=="boolean"}blankValue(){return!1}blankSerializedValue(){return!1}areSerializedValuesEqual(e,t){return e===t}areValuesEqual(e,t){return e===t}}const ji=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(m=>{const C=m.target.valueAsNumber,v=isNaN(C)?null:C;s(v)},[s]),p=d.useCallback(()=>{l()},[l]),g=d.useCallback(m=>{m.key==="Enter"&&m.preventDefault()},[]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsx(o.Input.Root,{accentColor:"base",variant:"surface",size:t,children:n.jsx(o.Input.Field,{id:e.identifier,name:a,onChange:f,onBlur:p,value:r??"",type:"number",min:e.minimum,max:e.maximum,step:e.integers?1:"any",placeholder:e.placeholder??"Enter a number",disabled:u,onKeyDown:g})})})});ji.displayName="NumberFieldInput";class H extends k{type="number";minimum;maximum;integers;placeholder;constructor(e){const{minimum:t=Number.MIN_SAFE_INTEGER,maximum:r=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:l,...s}=e;super(s),this.minimum=t,this.maximum=r,this.integers=a,this.placeholder=l}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new H({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${t}minimum`}),showDirectly:!1},{field:new H({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${t}maximum`}),showDirectly:!1},{field:new ce({label:"Integers",description:"Whole numbers only",required:!1,identifier:`${t}integers`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),t=this.minimum,r=this.maximum;return typeof t=="number"&&e.push(a=>{if(typeof a=="number"&&a<t)return`Must be at least ${this.minimum}.`}),typeof r=="number"&&e.push(a=>{if(typeof a=="number"&&a>r)return`Must be at most ${this.maximum}.`}),this.integers&&e.push(a=>{if(typeof a=="number"&&!Number.isInteger(a))return"Must be a whole number."}),e}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(e){return new H({...this.getOptions(),identifier:e})}setOptions(e){const{minimum:t,maximum:r,integers:a,placeholder:l,...s}=e;this.minimum=t??this.minimum,this.maximum=r??this.maximum,this.integers=a??this.integers,this.placeholder=l??this.placeholder,super.setOptions(s)}static deserialize(e){return new H(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(ji,{field:this})}isSerializedValue(e){return this.isValue(e)}isValue(e){return typeof e=="number"&&!isNaN(e)||e===null}areValuesEqual(e,t){return e===t}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}}const De=1e4;class Ui extends k{minLength;maxLength;placeholder;constructor(e){const{minLength:t,maxLength:r,placeholder:a="",...l}=e;super(l),this.minLength=t?Math.max(t,0):void 0,this.maxLength=r?Math.max(r,0):De,this.placeholder=a}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new H({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${t}minimum_length`,minimum:0,maximum:100,integers:!0}),showDirectly:!1},{field:new H({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${t}maximum_length`,minimum:1,maximum:De,integers:!0}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators();return this.minLength&&e.push(t=>{if(this.minLength&&(!t||t.length<this.minLength))return!this.required&&!t?void 0:`Minimum ${this.minLength} character(s).`}),this.maxLength&&e.push(t=>{if(typeof t=="string"&&this.maxLength&&t.length>this.maxLength)return`Maximum ${this.maxLength} character(s).`}),e}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(e){const{minLength:t,maxLength:r,placeholder:a,...l}=e;this.minLength=t,this.maxLength=r??this.maxLength,this.placeholder=a,super.setOptions(l)}serializeValue(e){return e}deserializeValue(e){return e}isSerializedValue(e){return typeof e=="string"}isValue(e){return typeof e=="string"}blankValue(){return""}blankSerializedValue(){return""}areSerializedValuesEqual(e,t){return e===t}areValuesEqual(e,t){return e===t}}const Gi=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(g=>{s(g),l()},[l,s]),p=d.useCallback(()=>{l()},[l]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsx(o.CheckboxGroup.Root,{id:e.identifier,name:a,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,values:r,onValuesChange:f,disabled:u,children:e.options.map((g,m)=>n.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(o.CheckboxGroup.Item,{value:g.value,onBlur:p,children:n.jsx(o.CheckboxGroup.ItemIndicator,{children:n.jsx(o.LuIcon,{icon:J})})}),n.jsx(o.Text,{size:t,accentColor:"base",className:"truncate",children:g.label})]},`${e.identifier}-${g.value}-${m}`))})})});Gi.displayName="CheckboxListFieldInput";class ue extends $e{type="checkbox-list";constructor(e){super(e)}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new ue({...this.getOptions(),identifier:e})}static deserialize(e){return new ue(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Gi,{field:this})}isSerializedValue(e){if(!Ae(e))return!1;const t=new Set(this.options.map(({value:r})=>r));return e.every(r=>t.has(r))}isValue(e){return this.isSerializedValue(e)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(e,t){const r=new Set(e),a=new Set(t);return r.size===a.size&&r.isSubsetOf(a)}areValuesEqual(e,t){const r=new Set(e),a=new Set(t);return r.size===a.size&&r.isSubsetOf(a)}}const ki=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),[f,p]=d.useState(!1),g=d.useCallback(C=>{s(C??null),l(),p(!1)},[s,l]),m=d.useCallback(C=>{p(C),C||l()},[l]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs(o.Popover.Root,{open:f,onOpenChange:m,children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:n.jsxs(o.Button,{id:e.identifier,name:a,type:"button",className:"!justify-between",accentColor:"base",variant:"surface",size:t,disabled:u,children:[n.jsx(o.Text,{className:"truncate",highContrast:!!r,children:r?r.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd"}),n.jsx(o.LuIcon,{icon:si})]})}),n.jsx(o.Popover.Content,{align:"start",size:t,children:n.jsx(o.DayPicker,{size:t,required:!1,mode:"single",variant:"solid",selected:r??void 0,onSelect:g})})]})})});ki.displayName="DateFieldInput";class be extends k{type="date";constructor(e){super(e)}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new be({...this.getOptions(),identifier:e})}static deserialize(e){return new be(e)}setOptions(e){super.setOptions(e)}serializeValue(e){return e?e.toISOString():null}deserializeValue(e){return e?new Date(e):null}render(){return n.jsx(ki,{field:this})}isSerializedValue(e){return typeof e!="string"&&e!==null?!1:this.isValue(this.deserializeValue(e))}isValue(e){return!(!(e instanceof Date)&&e!==null||e instanceof Date&&isNaN(e.getTime()))}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}areValuesEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.getTime()===t.getTime()}}var q=(i=>(i.Text="text",i.Selection="selection",i.Numeric="numeric",i.Temporal="temporal",i.Capture="capture",i.Assessment="assessment",i.Verification="verification",i))(q||{});const Hi=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(g=>{s(g),l()},[l,s]),p=d.useCallback(g=>{g||l()},[l]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs(o.Menu.Root,{onOpenChange:p,align:"start",children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsxs(o.Button,{id:e.identifier,name:a,className:"!justify-between",variant:"surface",type:"button",size:t,accentColor:"base",disabled:u,children:[n.jsx(o.Text,{className:"truncate",highContrast:r&&r.length>0,children:r&&r.length>0?r.join(", "):e.placeholder??"Select one or more..."}),n.jsx(o.LuIcon,{icon:si})]})}),n.jsx(o.Menu.Content,{size:t,children:n.jsx(o.Menu.Scroll,{children:n.jsxs(o.Menu.MultiSelectGroup,{values:r,onValuesChange:f,children:[n.jsxs(o.Menu.SelectAllItem,{children:[n.jsx(o.Menu.CheckboxItemIndicator,{children:g=>g?n.jsx(o.LuIcon,{icon:di}):n.jsx(o.LuIcon,{icon:J})}),"Select all"]}),e.options.map((g,m)=>n.jsxs(o.Menu.MultiSelectItem,{value:g.value,children:[n.jsx(o.Menu.SelectedIndicator,{children:n.jsx(o.LuIcon,{icon:J})}),g.label]},`${e.identifier}-${g.value}-${m}`))]})})})]})})});Hi.displayName="MultiSelectFieldInput";class ie extends $e{type="multi-select";placeholder;constructor(e){const{placeholder:t,...r}=e;super(r),this.placeholder=t}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new ie({...this.getOptions(),identifier:e})}setOptions(e){const{placeholder:t}=e;this.placeholder=t,super.setOptions(e)}static deserialize(e){return new ie(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Hi,{field:this})}isSerializedValue(e){if(!Ae(e))return!1;const t=new Set(this.options.map(({value:r})=>r));return e.every(r=>t.has(r))}isValue(e){return this.isSerializedValue(e)}blankValue(){return[]}areValuesEqual(e,t){const r=new Set(e),a=new Set(t);return r.size===a.size&&r.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(e,t){const r=new Set(e),a=new Set(t);return r.size===a.size&&r.isSubsetOf(a)}}const Ji=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(m=>{s(m??null),l()},[l,s]),p=d.useCallback(m=>{m||l()},[l]),g=d.useMemo(()=>e.options.find(m=>m.value===r),[e.options,r]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs(o.Menu.Root,{onOpenChange:p,align:"start",children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsxs(o.Button,{id:e.identifier,name:a,className:"!justify-between",accentColor:"base",variant:"surface",type:"button",size:t,disabled:u,children:[n.jsx(o.Text,{className:"truncate",highContrast:!!g,children:g?g.label:e.placeholder??"Select one..."}),n.jsx(o.LuIcon,{icon:si})]})}),n.jsx(o.Menu.Content,{size:t,children:n.jsx(o.Menu.Scroll,{children:n.jsx(o.Menu.SelectGroup,{required:!1,value:r??void 0,onValueChange:f,children:e.options.map((m,C)=>n.jsxs(o.Menu.SelectItem,{value:m.value,children:[n.jsx(o.Menu.SelectedIndicator,{children:n.jsx(o.LuIcon,{icon:J})}),m.label]},`${e.identifier}-${m.value}-${C}`))})})})]})})});Ji.displayName="SelectFieldInput";class te extends $e{type="select";placeholder;constructor(e){const{placeholder:t,...r}=e;super(r),this.placeholder=t}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new te({...this.getOptions(),identifier:e})}setOptions(e){const{placeholder:t}=e;this.placeholder=t,super.setOptions(e)}static deserialize(e){return new te(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Ji,{field:this})}isSerializedValue(e){return typeof e!="string"&&e!==null?!1:new Set([null,...this.options.map(({value:r})=>r)]).has(e)}isValue(e){return this.isSerializedValue(e)}blankValue(){return null}areValuesEqual(e,t){return e===t}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}}const Wi=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(m=>{s(m)},[s]),p=d.useCallback(()=>{l()},[l]),g=d.useMemo(()=>Array.from({length:e.length},()=>b.v4()),[e.length]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs(o.OneTimePasswordField.Root,{id:e.identifier,name:a,value:r,onValueChange:f,validationType:e.validationType,disabled:u,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:p,children:[g.map(m=>n.jsx(o.OneTimePasswordField.Input,{id:m},m)),n.jsx(o.OneTimePasswordField.HiddenInput,{})]})})});Wi.displayName="OTPFieldInput";class he extends k{type="otp";length;validationType;constructor(e){const{length:t,validationType:r,...a}=e;super(a),this.length=t,this.validationType=r}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new H({label:"Length",integers:!0,required:!1,minimum:1,maximum:16,identifier:`${t}length`}),showDirectly:!1},{field:new te({label:"Type",required:!1,identifier:`${t}validationType`,options:[{value:"none",label:"Any"},{value:"numeric",label:"Numeric"},{value:"alpha",label:"Alpha"},{value:"alphanumeric",label:"Alphanumeric"}]}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),t=this.length;return e.push(r=>{if(r.length!=t)return`Must be ${t} characters.`}),e}serialize(){return{...super.serialize(),length:this.length,validationType:this.validationType}}getOptions(){return{...super.getOptions(),length:this.length,validationType:this.validationType}}duplicate(e){return new he({...this.getOptions(),identifier:e})}setOptions(e){const{length:t,validationType:r,...a}=e;this.length=t??this.length,this.validationType=r??this.validationType,super.setOptions(a)}static deserialize(e){return new he(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Wi,{field:this})}isSerializedValue(e){return typeof e=="string"}isValue(e){return typeof e=="string"}blankValue(){return""}areValuesEqual(e,t){return e===t}blankSerializedValue(){return""}areSerializedValuesEqual(e,t){return e===t}}const fe={pass:{label:"Pass",icon:go},fail:{label:"Fail",icon:Vo},na:{label:"N/A",icon:Co}},Ne=Object.keys(fe);class re extends File{uuid;constructor(e,...t){super(...t),this.uuid=e}static from(e,t){return new re(e,[t],t.name,{lastModified:t.lastModified,type:t.type})}}class pe extends Promise{_uuid;constructor(e,t){super(e),this._uuid=t}get uuid(){return this._uuid}set uuid(e){this._uuid=e}static from(e,t){return new pe((r,a)=>{Promise.resolve(e).then(r).catch(a)},t)}then(e,t){const r=super.then(e,t);return r.uuid=this.uuid,r}catch(e){const t=super.catch(e);return t.uuid=this.uuid,t}finally(e){const t=super.finally(e);return t.uuid=this.uuid,t}}function rt(i){return Array.isArray(i)?i.every(e=>e instanceof pe||e instanceof re):!1}function hi(i,e){const t=new Set(i.map(({uuid:a})=>a)),r=new Set(e.map(({uuid:a})=>a));return t.size===r.size&&t.isSubsetOf(r)}const Xi=d.memo(i=>{const{ref:e,file:t,error:r,rightSlot:a,className:l,size:s,...h}=i;return n.jsxs(o.Card,{className:Q.cx(l,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:e,size:"xs",...h,children:[!t&&!r&&n.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:n.jsx(o.Spinner,{size:s})}),!!t&&!r&&n.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3",children:n.jsx(we,{className:"block size-full max-w-full object-cover",file:t})}),!!r&&n.jsx("div",{className:"grow"}),(!!t||!!r)&&n.jsxs(n.Fragment,{children:[n.jsx(o.Separator,{size:"full"}),n.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[r?n.jsx(o.LuIcon,{color:"var(--base-11)",icon:_i}):t&&n.jsx(o.LuIcon,{color:"var(--base-11)",icon:Yn}),n.jsx(o.Text,{className:"truncate",size:s,children:r??t?.name}),a]})]})]})});Xi.displayName="ImageCard";const Ki=d.memo(i=>{const{file:e,...t}=i,r=Ei(e);return n.jsx("video",{src:r??void 0,...t})});Ki.displayName="VideoFile";const Yi=d.memo(i=>{const{ref:e,file:t,className:r,error:a,rightSlot:l,size:s,...h}=i;return n.jsxs(o.Card,{className:Q.cx(r,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:e,size:"xs",...h,children:[!t&&!a&&n.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:n.jsx(o.Spinner,{size:s})}),!!t&&!a&&n.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3",children:n.jsx(Ki,{className:"block size-full max-w-full object-cover",file:t,controls:!0})}),!!a&&n.jsx("div",{className:"grow"}),(!!t||!!a)&&n.jsxs(n.Fragment,{children:[n.jsx(o.Separator,{size:"full"}),n.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[a?n.jsx(o.LuIcon,{color:"var(--danger-11)",icon:_i}):t&&n.jsx(o.LuIcon,{color:"var(--base-11)",icon:Eo}),n.jsx(o.Text,{className:"truncate",size:s,children:a??t?.name}),l]})]})]})});Yi.displayName="VideoCard";const Zi=d.memo(i=>{const{fileOrPromise:e,onRemove:t,disabled:r,size:a}=i,[l,s]=d.useState(e instanceof pe?null:e),[h,u]=d.useState(null),f=ci();eo.useActiveEffect(z=>{if(u(null),!(e instanceof pe)){s(e);return}s(null),e.then(x=>{z()&&s(x)}).catch(x=>{z()&&u(x instanceof Error?x.message:"Unknown error")})},[e]);const p=d.useCallback(()=>{if(!l)return;const z=new Blob([l]);Pn.saveAs(z,l.name)},[l]),g=d.useCallback(()=>{t(e)},[t,e]),m=d.useCallback(()=>{if(!l)return;const z=URL.createObjectURL(l);window.open(z,"_blank"),URL.revokeObjectURL(z)},[l]),C=d.useCallback(()=>{l&&f(z=>({file:l,onDelete:r?void 0:()=>{g(),z()}}))},[r,g,f,l]),v=d.useMemo(()=>n.jsx("div",{className:"flex grow justify-end",children:n.jsxs(o.Menu.Root,{modal:!0,children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.IconButton,{onClick:o.stopPropagation,type:"button",variant:"ghost",accentColor:"base",size:a,children:n.jsx(o.LuIcon,{icon:Kn})})}),n.jsxs(o.Menu.Content,{size:a,children:[n.jsxs(o.Menu.Item,{onSelect:p,disabled:!l,children:[n.jsx(o.LuIcon,{icon:Xn})," Download"]}),r?null:n.jsxs(n.Fragment,{children:[n.jsx(o.Menu.Separator,{}),n.jsxs(o.Menu.Item,{onSelect:g,children:[n.jsx(o.LuIcon,{icon:se})," Delete"]})]})]})]})}),[r,g,p,l,a]),y=!!l?.type.startsWith("image/"),S=!!l?.type.startsWith("video/");return y?n.jsx(Xi,{className:"cursor-pointer",onClick:C,file:l,error:h??void 0,rightSlot:v,size:a}):S?n.jsx(Yi,{className:"cursor-pointer",onClick:C,file:l,error:h??void 0,rightSlot:v,size:a}):n.jsx(Bi,{className:"cursor-pointer",file:l,error:h??void 0,onClick:m,rightSlot:v,size:a})});Zi.displayName="DisplayFile";const Qi=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useRef(null),p=d.useCallback(F=>{const w=e.cleanValue({...r,status:F});s(w),l()},[e,l,s,r]),g=d.useCallback(F=>{const w=F.target.value,T={...r,notes:w};s(T)},[r,s]),m=d.useCallback(()=>{l()},[l]),C=d.useCallback(F=>{const w=r.files.filter(({uuid:T})=>T!==F.uuid);s({...r,files:w}),l()},[s,l,r]),v=d.useCallback(()=>{f.current?.click()},[]),y=d.useCallback(F=>{const w=Array.from(F.target.files??[]).map(G=>re.from(b.v4(),G)),T={...r,files:[...r.files,...w]};s(T),l()},[l,s,r]);d.useEffect(()=>{if(!f.current)return;const F=new AbortController;return f.current.addEventListener("cancel",()=>{l()},{signal:F.signal}),()=>{F.abort()}},[l,r]);const S=r.status&&e.showNotesAndFilesOn.includes(r.status),z=`${e.identifier}-status`,x=`${e.identifier}-notes`,I=`${e.identifier}-files`;return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(o.RadioGroup.Root,{id:z,className:"flex gap-2",name:a,value:r.status,disabled:u,accentColor:"base",variant:"surface",size:t,onValueChange:p,children:Ne.map(F=>{const{label:w}=fe[F];return n.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(o.RadioGroup.Item,{value:F,children:n.jsx(o.RadioGroup.Indicator,{children:n.jsx(o.LuIcon,{icon:Hn,className:"fill-current"})})}),n.jsx(o.Text,{size:t,accentColor:"base",className:"truncate",children:w})]},`${e.identifier}-${F}`)})}),S&&n.jsxs(n.Fragment,{children:[n.jsx("div",{children:n.jsx(o.TextArea,{id:x,value:r.notes??"",name:a,onChange:g,onBlur:m,className:"field-sizing-content min-h-12 w-full",placeholder:"Notes",resize:"vertical",accentColor:"base",variant:"surface",size:t,disabled:u})}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs(o.Button,{className:"w-max",size:t,variant:"surface",accentColor:"base",onClick:v,type:"button",disabled:u,children:[n.jsx(o.LuIcon,{icon:Li}),"Select files"]}),n.jsx("input",{id:I,name:a,type:"file",ref:f,multiple:!0,className:"hidden",onChange:y,value:""}),r.files.length>0&&n.jsx("div",{className:"flex h-max flex-wrap gap-2",children:r.files.map(F=>n.jsx(Zi,{size:t,fileOrPromise:F,onRemove:C,disabled:u},F.uuid))})]})]})]})})});Qi.displayName="PassFailFieldInput";const Ri=i=>typeof i=="string"&&Ne.includes(i),ot=i=>!(i===null||typeof i!="object"||!("status"in i)||!Ri(i.status)||!("notes"in i)||typeof i.notes!="string"||!("files"in i)||!(Array.isArray(i.files)&&i.files.length===0)),at=i=>!(i===null||typeof i!="object"||!("status"in i)||!Ri(i.status)||!("notes"in i)||typeof i.notes!="string"||!("files"in i)||!rt(i.files)),lt=i=>({status:i.status,notes:i.notes,files:[]}),st=i=>({status:i.status,notes:i.notes,files:[]}),dt=(i,e)=>!(i.status!==e.status||i.notes!==e.notes||!hi(i.files,e.files)),ct=(i,e)=>!(i.status!==e.status||i.notes!==e.notes||i.files.length!==e.files.length);class ge extends k{type="pass-fail";showNotesAndFilesOn;constructor(e){const{showNotesAndFilesOn:t,...r}=e;super(r),this.showNotesAndFilesOn=t}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new ie({identifier:`${t}showNotesAndFilesOn`,label:"Show notes and files on",description:"Show the notes and files on desired statuses.",options:Ne.map(r=>{const{label:a}=fe[r];return{value:r,label:a}}),required:!1}),showDirectly:!1}]}serialize(){return{...super.serialize(),showNotesAndFilesOn:this.showNotesAndFilesOn}}getOptions(){return{...super.getOptions(),showNotesAndFilesOn:this.showNotesAndFilesOn}}duplicate(e){return new ge({...this.getOptions(),identifier:e})}setOptions(e){const{showNotesAndFilesOn:t,...r}=e;this.showNotesAndFilesOn=t??this.showNotesAndFilesOn,super.setOptions(r)}getFieldValidators(){const e=super.getFieldValidators(),t=this.showNotesAndFilesOn,r=this.blankValue();return t.length>0&&(e.push(a=>{if(!(!a.status||!t.includes(a.status))&&r.notes===a.notes)return"Notes is required."}),e.push(a=>{if(!(!a.status||!t.includes(a.status))&&hi(r.files,a.files))return"Files is required."})),e}static deserialize(e){return new ge({...e,showNotesAndFilesOn:e.showNotesAndFilesOn??!1})}serializeValue(e){return lt(e)}deserializeValue(e){return st(e)}render(){return n.jsx(Qi,{field:this})}isSerializedValue(e){return ot(e)}isValue(e){return at(e)}areValuesEqual(e,t){return dt(e,t)}blankValue(){return{status:null,notes:"",files:[]}}cleanValue(e){return e.status&&this.showNotesAndFilesOn.includes(e.status)?e:{status:e.status,notes:"",files:[]}}cleanSerializedValue(e){return super.cleanSerializedValue(e)}blankSerializedValue(){return{status:null,notes:"",files:[]}}areSerializedValuesEqual(e,t){return ct(e,t)}}const en=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(m=>{s(m),l()},[l,s]),p=d.useCallback(()=>{l()},[l]),g=d.useCallback(()=>{s(null),l()},[l,s]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs(o.RadioGroup.Root,{id:e.identifier,name:a,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,value:r??"",onValueChange:f,disabled:u,children:[e.options.map((m,C)=>n.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(o.RadioGroup.Item,{value:m.value,onBlur:p,children:n.jsx(o.RadioGroup.Indicator,{children:n.jsx(o.LuIcon,{icon:Hn,className:"fill-current"})})}),n.jsx(o.Text,{size:t,accentColor:"base",className:"truncate",children:m.label})]},`${e.identifier}-${m.value}-${C}`)),!!r&&n.jsxs(o.Button,{onClick:g,className:"-mx-2 w-max",type:"button",variant:"ghost",accentColor:"base",size:t,children:[n.jsx(o.LuIcon,{icon:ne}),"Clear"]})]})})});en.displayName="RadioFieldInput";class me extends $e{type="radio";constructor(e){super(e)}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new me({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){return new me(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(en,{field:this})}isSerializedValue(e){return typeof e!="string"&&e!==null?!1:new Set([null,...this.options.map(({value:r})=>r)]).has(e)}isValue(e){return this.isSerializedValue(e)}blankValue(){return null}areValuesEqual(e,t){return e===t}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}}const $o=Q.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"]}}}),nn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(m=>{s(m),l()},[l,s]),p=d.useCallback(()=>{s(null),l()},[l,s]),g=Array.from({length:e.maxRating},(m,C)=>C+1);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs("div",{className:"flex flex-row items-center gap-1",children:[n.jsx(o.Rating.Root,{id:e.identifier,name:a,className:"flex items-center gap-0.5",value:r,onValueChange:f,disabled:u,children:g.map(m=>n.jsx(o.Rating.Item,{value:m,className:$o({size:t}),children:n.jsx(o.LuIcon,{icon:et,className:"size-full group-data-[active=true]:fill-current"})},`${e.identifier}-${m}`))}),!u&&r!==null&&n.jsx(o.IconButton,{onClick:p,type:"button",variant:"ghost",accentColor:"base",size:t,children:n.jsx(o.LuIcon,{icon:ne})})]})})});nn.displayName="RatingFieldInput";class Ce extends k{type="rating";maxRating;constructor(e){const{maxRating:t,...r}=e;super(r),this.maxRating=t}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new H({label:"Max Rating",description:"Maximum rating value",integers:!0,required:!1,minimum:1,maximum:10,identifier:`${t}maxRating`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),t=this.maxRating;return e.push(r=>{if(typeof r=="number"&&(r<1||r>t))return`Rating must be between 1 and ${t}.`}),e}serialize(){return{...super.serialize(),maxRating:this.maxRating}}getOptions(){return{...super.getOptions(),maxRating:this.maxRating}}duplicate(e){return new Ce({...this.getOptions(),identifier:e})}setOptions(e){const{maxRating:t,...r}=e;this.maxRating=t??this.maxRating,super.setOptions(r)}static deserialize(e){return new Ce(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(nn,{field:this})}isSerializedValue(e){return this.isValue(e)}isValue(e){return typeof e=="number"&&!isNaN(e)||e===null}areValuesEqual(e,t){return e===t}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}}const tn=d.createContext(null),ut=()=>{const i=d.use(tn);if(!i)throw new Error("useScannerContext must be used within a component tree wrapped by ScannerProvider.");return i},Do=()=>{const i=d.use(tn);if(!i)throw new Error("useScanner must be used within a component tree wrapped by ScannerProvider.");return i.openScanner},fi=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:a,modal:l,...s}=i;return n.jsxs(o.Overlay.Root,{open:t,onOpenChange:r,defaultOpen:a,modal:l,children:[!!e&&n.jsx(o.Overlay.Trigger,{asChild:!0,children:e}),n.jsxs(o.Overlay.Content,{children:[n.jsx(o.Overlay.Title,{className:"sr-only",children:"Scanner"}),n.jsx(o.Overlay.Description,{className:"sr-only",children:"Scan a barcode or a qr code."}),n.jsx(ht,{...s})]})]})});fi.displayName="Scanner";const ht=d.memo(i=>{const{paused:e,formats:t,timeBetweenDecodingAttempts:r,trySkew:a,onDecodeResult:l,onDecodeError:s,onError:h}=i,{wasmUrl:u}=ut(),{ref:f}=io.useZxing({wasmUrl:u,paused:e,formats:t,timeBetweenDecodingAttempts:r,trySkew:a,onDecodeResult:l,onDecodeError:s,onError:h,constraints:{video:{width:{ideal:1920,min:1280},height:{ideal:1080,min:720},aspectRatio:{ideal:16/9},facingMode:"environment"}}});return n.jsxs("div",{className:"bg-(--color-background) flex size-full flex-col justify-center overflow-hidden",children:[n.jsx("div",{className:"flex w-full justify-end p-4",children:n.jsx(o.Overlay.Close,{asChild:!0,children:n.jsx(o.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",children:n.jsx(o.LuIcon,{icon:ne})})})}),n.jsx("div",{className:"max-h-full w-full grow overflow-hidden p-4",children:n.jsx("video",{className:"size-full",ref:f,muted:!0,playsInline:!0})})]})});ht.displayName="ScannerInternal";const ft=d.memo(i=>{const{children:e,wasmUrl:t}=i,[r,a]=d.useState(null),l=d.useCallback(()=>{a(null)},[]),s=d.useCallback(f=>{a(f(l))},[l]),h=d.useCallback(()=>{r&&(r.onClose&&r.onClose(),l())},[l,r]),u=d.useMemo(()=>({wasmUrl:t,openScanner:s}),[t,s]);return n.jsxs(tn,{value:u,children:[e,r&&n.jsx(fi,{open:!0,onOpenChange:h,...r})]})});ft.displayName="ScannerProvider";const rn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),[f,p]=d.useState(!1),g=d.useCallback(S=>{const z=S.target.value;s(z)},[s]),m=d.useCallback(()=>{l()},[l]),C=d.useCallback(S=>{s(S.rawValue.trim()),l(),p(!1)},[s,l]),v=d.useCallback(()=>{p(!0)},[]),y=d.useCallback(()=>{p(!1),l()},[l]);return n.jsxs(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:[n.jsx(o.TextArea,{className:"field-sizing-content w-full",accentColor:"base",variant:"surface",size:t,id:e.identifier,name:a,value:r??"",placeholder:"Enter a qr or barcode",onChange:g,onBlur:m,disabled:u}),n.jsxs(o.Button,{onClick:v,className:"w-max",type:"button",variant:"soft",size:t,accentColor:"base",disabled:u,children:[n.jsx(o.LuIcon,{icon:Io}),"Scan"]}),n.jsx(fi,{open:f,onDecodeResult:C,onOpenChange:y})]})});rn.displayName="ScanFieldInput";class Me extends k{type="qr";constructor(e){super(e)}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new Me({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){return new Me(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(rn,{field:this})}isSerializedValue(e){return typeof e=="string"}isValue(e){return typeof e=="string"}blankValue(){return""}areValuesEqual(e,t){return e===t}blankSerializedValue(){return""}areSerializedValuesEqual(e,t){return e===t}}const on=500,an=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(m=>{const C=m.target.value;s(C)},[s]),p=d.useCallback(()=>{l()},[l]),g=d.useCallback(m=>{m.key==="Enter"&&m.preventDefault()},[]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsx(o.Input.Root,{accentColor:"base",variant:"surface",size:t,children:n.jsx(o.Input.Field,{id:e.identifier,className:"truncate",name:a,value:r??"",type:"text",placeholder:e.placeholder,onChange:f,onBlur:p,disabled:u,onKeyDown:g})})})});an.displayName="StringFieldInput";class Ve extends Ui{type="string";constructor(e){const{...t}=e,r=e.maxLength?Math.min(on,e.maxLength):on,a=e.minLength?Math.min(e.minLength,r):void 0;super({...t,maxLength:r,minLength:a})}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new Ve({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){const{maximum_length:t,minimum_length:r,...a}=e;return new Ve({...a,maxLength:t,minLength:r,placeholder:"Enter a short description"})}render(){return n.jsx(an,{field:this})}}const ln=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(g=>{const m=g.target.value;s(m)},[s]),p=d.useCallback(()=>{l()},[l]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsx(o.TextArea,{id:e.identifier,value:r??"",name:a,onChange:f,onBlur:p,className:"field-sizing-content min-h-12",placeholder:e.placeholder,resize:"vertical",accentColor:"base",variant:"surface",size:t,disabled:u})})});ln.displayName="TextFieldInput";class ye extends Ui{type="text";constructor(e){const t=e.maxLength?Math.min(De,e.maxLength):De,r=e.minLength?Math.min(e.minLength,t):void 0;super({...e,maxLength:t,minLength:r})}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new ye({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){const{maximum_length:t,minimum_length:r,...a}=e;return new ye({...a,maxLength:t,minLength:r,placeholder:"Enter a description"})}render(){return n.jsx(ln,{field:this})}}const sn=Po(),pt=new Set(sn);function Po(i=!0){const e=new Set;for(let t=-12;t<=14;t++){const r=t>=0?"+":"-",a=Math.abs(t).toString().padStart(2,"0");e.add(`${r}${a}:00`)}if(i){const t=[-12.5,-9.5,-3.5,3.5,4.5,5.5,6.5,9.5,10.5,12.5];for(const r of t){const a=r>=0?"+":"-",l=Math.floor(Math.abs(r)).toString().padStart(2,"0");e.add(`${a}${l}:30`)}}return Array.from(e).sort((t,r)=>gt(t)-gt(r))}function gt(i){const e=i[0]==="+"?1:-1,t=Number(i.slice(1,3)),r=Number(i.slice(4,6));return e*(t*60+r)}const jo="+00:00",Uo=/^T([01]\d|2[0-3]):([0-5]\d):00([+-]\d{2}:\d{2})$/,pi=i=>typeof i=="string"&&pt.has(i),mt=()=>{const i=-new Date().getTimezoneOffset(),e=i>=0?"+":"-",t=Math.abs(i),r=Math.floor(t/60),a=t%60,l=`${e}${r.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`;return pi(l)?l:jo};function Ct(i){const e=/^([+-])(\d{2}):(\d{2})$/.exec(i);if(!e)throw new Error(`Invalid UTC offset: ${i}`);return(e[1]==="+"?1:-1)*(Number(e[2])*60+Number(e[3]))}const Pe=i=>{const e=Uo.exec(i);if(!e)return null;const t=e[3];return pi(t)?{hours:Number(e[1]),minutes:Number(e[2]),utcOffset:t}:null},A=i=>typeof i=="string"&&Pe(i)!==null,dn=(i,e,t=mt())=>{if(!Number.isInteger(i)||i<0||i>23)throw new Error(`Invalid hour: ${i}`);if(!Number.isInteger(e)||e<0||e>59)throw new Error(`Invalid minute: ${e}`);if(!pi(t))throw new Error("Unsupported UTC offset");const r=i.toString().padStart(2,"0"),a=e.toString().padStart(2,"0");return`T${r}:${a}:00${t}`},gi=i=>`UTC${i}`,oe=i=>{const e=Pe(i);if(!e)throw new Error(`Invalid time value: ${i}`);return(e.hours*60+e.minutes-Ct(e.utcOffset)+1440)%1440},mi=(i,e=!0)=>{const t=Pe(i);if(!t)throw new Error(`Invalid time value: ${i}`);const r=(t.hours%12||12).toString().padStart(2,"0"),a=t.minutes.toString().padStart(2,"0"),l=t.hours>=12?"PM":"AM",s=`${r}:${a} ${l}`;return e?`${s} ${gi(t.utcOffset)}`:s},je=i=>typeof i=="object"&&(A(i.from)||A(i.to)),cn=(i,e)=>{const t=oe(i),r=e.from?oe(e.from):null,a=e.to?oe(e.to):null;return r===null&&a===null?!0:r===null?t<=a:a===null?t>=r:r<=a?t>=r&&t<=a:t>=r||t<=a},Ci=d.memo(i=>{const{value:e,onChange:t,onBlur:r,disabled:a,size:l="md",id:s,name:h,compact:u=!1}=i,f=e?Pe(e):null,p=f?`${f.hours.toString().padStart(2,"0")}:${f.minutes.toString().padStart(2,"0")}`:"",g=d.useCallback(v=>{const y=v.target.value;if(!y){t(null);return}const[S,z]=y.split(":").map(Number);t(dn(S,z,f?.utcOffset))},[t,f?.utcOffset]),m=d.useCallback(v=>{f&&(t(dn(f.hours,f.minutes,v)),r?.())},[r,t,f]),C=d.useCallback(v=>{v||r?.()},[r]);return n.jsxs("div",{className:"flex min-w-0 gap-2",children:[n.jsx(o.Input.Root,{className:"min-w-0 grow",accentColor:"base",variant:"surface",size:l,children:n.jsx(o.Input.Field,{id:s,name:h,className:Q.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:p,onChange:g,onBlur:r,disabled:a})}),n.jsxs(o.Menu.Root,{align:"end",onOpenChange:C,children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsxs(o.Button,{type:"button",className:u?"!justify-between":"min-w-32 !justify-between",accentColor:"base",variant:"surface",size:l,disabled:a||!f,children:[n.jsx(o.Text,{className:"truncate",highContrast:!!f,children:f?gi(f.utcOffset):"UTC offset"}),n.jsx(o.LuIcon,{icon:si})]})}),n.jsx(o.Menu.Content,{size:l,children:n.jsx(o.Menu.Scroll,{children:n.jsx(o.Menu.SelectGroup,{required:!0,value:f?.utcOffset,onValueChange:m,children:sn.map(v=>n.jsxs(o.Menu.SelectItem,{value:v,children:[n.jsx(o.Menu.SelectedIndicator,{children:n.jsx(o.LuIcon,{icon:J})}),gi(v)]},v))})})})]})]})});Ci.displayName="TimeFieldControl";const un=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e});return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsx(Ci,{id:e.identifier,name:a,size:t,value:r,onChange:s,onBlur:l,disabled:u})})});un.displayName="TimeFieldInput";class xe extends k{type="time";constructor(e){super(e)}static deserialize(e){return new xe(e)}getOptions(){return super.getOptions()}duplicate(e){return new xe({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(un,{field:this})}isSerializedValue(e){return e===null||A(e)}isValue(e){return e===null||A(e)}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}areValuesEqual(e,t){return e===t}}const hn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useRef(null),p=d.useCallback(()=>{f.current?.click()},[]),g=d.useCallback(()=>{if(!f.current)return;const S=f.current.files;if(!S){l();return}const z=Array.from(S).map(I=>re.from(b.v4(),I)),x=[...r,...z];s(x),l()},[l,s,r]),m=d.useCallback(S=>{const z=r.filter(({uuid:x})=>x!==S.uuid);s(z),l()},[r,s,l]);d.useEffect(()=>{if(!f.current)return;const S=new AbortController;return f.current.addEventListener("cancel",()=>{l()},{signal:S.signal}),()=>{S.abort()}},[l,r]);const y=e.maxFiles>1?"Select files":"Select a file";return n.jsxs(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:[n.jsxs(o.Button,{className:"w-max",size:t,variant:"surface",accentColor:"base",onClick:p,type:"button",disabled:u,children:[n.jsx(o.LuIcon,{icon:Li}),y]}),n.jsx("input",{id:e.identifier,name:a,type:"file",ref:f,accept:e.extensions?.join(","),multiple:e.maxFiles>1,className:"hidden",onChange:g,value:""}),r.length>0&&n.jsx("div",{className:"mt-1 flex h-max flex-col gap-2",children:r.map(S=>n.jsx(Zi,{size:t,fileOrPromise:S,onRemove:m,disabled:u},S.uuid))})]})});hn.displayName="UploadFieldInput";class ve extends k{type="upload";extensions;maxFileSize;maxFiles;constructor(e){const{extensions:t,maximum_files:r,maximum_size:a,...l}=e;super(l),this.maxFileSize=typeof a=="number"?a:void 0,this.maxFiles=Math.max(typeof r=="number"?r:1,1),this.extensions=t}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new H({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:1,maximum:10,identifier:`${t}maximum_files`,integers:!0}),showDirectly:!1},{field:new H({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${qe}MB).`,required:!1,identifier:`${t}maximum_size`,minimum:1,maximum:qe,integers:!0}),showDirectly:!1},{field:new ie({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,identifier:`${t}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 e=super.getFieldValidators(),t=this.maxFileSize??qe,r=t*1e3*1e3,a=this.maxFiles||1;return e.push(l=>{if(l.some(s=>s instanceof re&&s.size>r))return`Files must be at most ${t}MB.`}),e.push(l=>{if(l.length>a)return`You can only upload ${a} files.`}),e}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(e){return new ve({...this.getOptions(),identifier:e})}setOptions(e){const{extensions:t,maximum_files:r,maximum_size:a,...l}=e;this.maxFileSize=typeof a=="number"?a:this.maxFileSize,this.maxFiles=typeof r=="number"?r:this.maxFiles,this.extensions=t,super.setOptions(l)}static deserialize(e){return new ve(e)}serializeValue(e){return[]}deserializeValue(e){return[]}render(){return n.jsx(hn,{field:this})}isSerializedValue(e){return Array.isArray(e)&&e.length===0}isValue(e){return Array.isArray(e)?e.every(t=>t instanceof pe||t instanceof re):!1}areValuesEqual(e,t){return hi(e,t)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(e,t){return e.length===t.length}}const fn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(C=>{const v=C.target.value;v!==""&&!URL.canParse(v)||s(v!==""?new URL(v):null)},[s]),p=d.useCallback(()=>{l()},[l]),g=d.useCallback(C=>{C.key==="Enter"&&C.preventDefault()},[]),m=d.useCallback(()=>{r!==null&&window.open(r,"_blank","noopener,noreferrer")},[r]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs("div",{className:"flex w-full gap-2",children:[n.jsx(o.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:t,children:n.jsx(o.Input.Field,{id:e.identifier,className:"truncate",name:a,value:r?r.toString():"",type:"url",inputMode:"url",placeholder:e.placeholder,onChange:f,onBlur:p,disabled:u,onKeyDown:g})}),n.jsx(o.IconButton,{size:t,variant:"soft",accentColor:"base",type:"button",disabled:r===null,onClick:m,children:n.jsx(o.LuIcon,{icon:So})})]})})});fn.displayName="URLFieldInput";class Ie extends k{type="url";placeholder;constructor(e){const{placeholder:t="https://example.com",...r}=e;super(r),this.placeholder=t}serialize(){return{...super.serialize(),placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new Ie({...this.getOptions(),identifier:e})}setOptions(e){const{placeholder:t,...r}=e;this.placeholder=t??this.placeholder,super.setOptions(r)}static deserialize(e){return new Ie(e)}serializeValue(e){return e?.toString()??null}deserializeValue(e){return e===null?null:new URL(e)}isSerializedValue(e){return e===null?!0:typeof e!="string"?!1:URL.canParse(e)}isValue(e){return e===null||e instanceof URL}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}areValuesEqual(e,t){return e?.toString()===t?.toString()}render(){return n.jsx(fn,{field:this})}}const pn={date:be,time:xe,number:H,boolean:ce,select:te,string:Ve,url:Ie,text:ye,upload:ve,qr:Me,"multi-string":de,"multi-select":ie,radio:me,"checkbox-list":ue,"pass-fail":ge,otp:he,rating:Ce},Vt=Object.keys(pn),_={"checkbox-list":{description:"Allows the user to select a multiple options from a list.",group:q.Selection,icon:vo,name:"Checkbox list"},"multi-select":{description:"Allows the user to select a multiple options from a list of options.",group:q.Selection,icon:No,name:"Multi-select"},"multi-string":{description:"Allows the user to provide multiple unique strings.",group:q.Text,icon:xo,name:"Multi-string"},"pass-fail":{description:"Track pass, fail, or N/A outcome.",group:q.Assessment,icon:yo,name:"Pass - Fail"},boolean:{description:"Perfect for both optional and required yes/no questions.",group:q.Selection,icon:To,name:"Checkbox"},date:{description:"Allows specifying a date.",group:q.Temporal,icon:po,name:"Date"},time:{description:"Allows specifying a time and UTC offset.",group:q.Temporal,icon:Ao,name:"Time"},number:{description:"Allows specifying a number within a given range.",group:q.Numeric,icon:wo,name:"Number"},otp:{description:"Allows specifying a number within a given range.",group:q.Verification,icon:qo,name:"OTP"},qr:{description:"Used for scanning/reading QR and barcodes.",group:q.Capture,icon:Oo,name:"Scan"},radio:{description:"Allows the user to select a single option from a list of options.",group:q.Selection,icon:mo,name:"Option list"},rating:{description:"Allows users to select a rating value.",group:q.Assessment,icon:et,name:"Rating"},select:{description:"Allows the user to select a single option from a list of options.",group:q.Selection,icon:Mo,name:"Dropdown"},string:{description:"Short text fields can hold up to 500 characters on a single line.",group:q.Text,icon:Bo,name:"Short Text"},text:{description:"Paragraph fields can hold up to 10000 characters and can have multiple lines.",group:q.Text,icon:uo,name:"Paragraph"},upload:{description:"Allows a file to be uploaded.",group:q.Capture,icon:Li,name:"Upload"},url:{description:"Allows users to enter a URL.",group:q.Text,icon:bo,name:"URL"}},yt={[q.Assessment]:{name:"Assessment"},[q.Capture]:{name:"Capture"},[q.Numeric]:{name:"Numeric"},[q.Selection]:{name:"Selection"},[q.Temporal]:{name:"Temporal"},[q.Text]:{name:"Text"},[q.Verification]:{name:"Verification"}},qe=50,vt=qe*1e3,St=vt*1e3,E="Unlabelled",gn="Unlabelled";class M{id;label;getApplyFn;serialize;deserialize;constructor(e){const{id:t,getApplyFn:r,label:a,serialize:l,deserialize:s}=e;this.id=t,this.getApplyFn=r,this.label=a,this.serialize=l,this.deserialize=s}static create(e){return new M(e)}}const zt=M.create({id:"nullable-boolean-equals",label:"is",getApplyFn:i=>e=>e===i,serialize:i=>i,deserialize:i=>i}),Ft=M.create({id:"nullable-boolean-not-equals",label:"is not",getApplyFn:i=>e=>e!==i,serialize:i=>i,deserialize:i=>i}),wt=M.create({id:"date-equals",getApplyFn:i=>e=>e.getTime()===i.getTime(),label:"is",serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),bt=M.create({id:"date-not-equals",getApplyFn:i=>e=>e.getTime()!==i.getTime(),label:"is not",serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),Nt=M.create({id:"date-before",getApplyFn:i=>e=>e.getTime()<i.getTime(),label:"before",serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),Mt=M.create({id:"date-after",label:"after",getApplyFn:i=>e=>e.getTime()>i.getTime(),serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),xt=M.create({id:"date-range-in",label:"in between",getApplyFn:i=>e=>!(i?.from&&i.from.getTime()>e.getTime()||i?.to&&i.to.getTime()<e.getTime()),serialize:i=>({from:i.from?.toISOString()??null,to:i.to?.toISOString()??null}),deserialize:i=>({from:i.from?new Date(i.from):void 0,to:i.to?new Date(i.to):void 0})}),It=M.create({id:"date-range-not-in",label:"not in between",getApplyFn:i=>e=>!!(i?.from&&i.from.getTime()>e.getTime()||i?.to&&i.to.getTime()<e.getTime()),serialize:i=>({from:i.from?.toISOString()??null,to:i.to?.toISOString()??null}),deserialize:i=>({from:i.from?new Date(i.from):void 0,to:i.to?new Date(i.to):void 0})}),qt=M.create({id:"has-files",label:"is",getApplyFn:i=>e=>e.length>0,serialize:i=>i,deserialize:i=>i}),Ot=M.create({id:"does-not-have-files",label:"is not",getApplyFn:i=>e=>e.length===0,serialize:i=>i,deserialize:i=>i}),mn=M.create({id:"number-equals",getApplyFn:i=>e=>e===i,label:"is",serialize:i=>i,deserialize:i=>i}),Cn=M.create({id:"number-not-equals",getApplyFn:i=>e=>e!==i,label:"is not",serialize:i=>i,deserialize:i=>i}),Vn=M.create({id:"number-less-than",getApplyFn:i=>e=>e<i,label:"is less than",serialize:i=>i,deserialize:i=>i}),yn=M.create({id:"number-less-than-or-equals",getApplyFn:i=>e=>e<=i,label:"is less than or equal to",serialize:i=>i,deserialize:i=>i}),vn=M.create({id:"number-greater-than",getApplyFn:i=>e=>e>i,label:"is greater than",serialize:i=>i,deserialize:i=>i}),Sn=M.create({id:"number-greater-than-or-equals",getApplyFn:i=>e=>e>=i,label:"is greater than or equal to",serialize:i=>i,deserialize:i=>i}),zn=M.create({id:"number-range-in",getApplyFn:i=>e=>!(i.to&&e>i.to||i.from&&e<i.from),label:"is between",serialize:i=>i,deserialize:i=>i}),Fn=M.create({id:"number-range-not-in",getApplyFn:i=>e=>!!(i.to&&e>i.to||i.from&&e<i.from),label:"is not between",serialize:i=>i,deserialize:i=>i}),_t=M.create({id:"pass-fail-equals",getApplyFn:i=>e=>e===i,label:"is",serialize:i=>i,deserialize:i=>i}),Tt=M.create({id:"pass-fail-not-equals",getApplyFn:i=>e=>e!==i,label:"is not",serialize:i=>i,deserialize:i=>i}),Lt=M.create({id:"pass-fail-array-includes",getApplyFn:i=>{const e=new Set(i);return t=>e.has(t)},label:"is any of",serialize:i=>i,deserialize:i=>i}),Bt=M.create({id:"pass-fail-array-excludes",getApplyFn:i=>{const e=new Set(i);return t=>!e.has(t)},label:"is none of",serialize:i=>i,deserialize:i=>i}),ae=M.create({id:"nullable-string-equals",getApplyFn:i=>e=>e===i,label:"is",serialize:i=>i,deserialize:i=>i}),le=M.create({id:"nullable-string-not-equals",getApplyFn:i=>e=>e!==i,label:"is not",serialize:i=>i,deserialize:i=>i}),Oe=M.create({id:"string-includes",getApplyFn:i=>e=>e.includes(i),label:"includes",serialize:i=>i,deserialize:i=>i}),_e=M.create({id:"string-excludes",getApplyFn:i=>e=>!e.includes(i),label:"does not include",serialize:i=>i,deserialize:i=>i}),wn=M.create({id:"string-array-includes",getApplyFn:i=>{const e=new Set(i);return t=>e.has(t)},label:"is any of",serialize:i=>i,deserialize:i=>i}),bn=M.create({id:"string-array-excludes",getApplyFn:i=>{const e=new Set(i);return t=>!e.has(t)},label:"is none of",serialize:i=>i,deserialize:i=>i}),Vi=M.create({id:"string-array-every",getApplyFn:i=>{const e=new Set(i);return t=>{const r=new Set(t);return e.isSubsetOf(r)}},label:"has all of",serialize:i=>i,deserialize:i=>i}),yi=M.create({id:"string-array-some",getApplyFn:i=>{const e=new Set(i);return t=>{const r=new Set(t);return!e.isDisjointFrom(r)}},label:"has any of",serialize:i=>i,deserialize:i=>i}),vi=M.create({id:"string-array-none",getApplyFn:i=>{const e=new Set(i);return t=>{const r=new Set(t);return e.isDisjointFrom(r)}},label:"has none of",serialize:i=>i,deserialize:i=>i}),Si=M.create({id:"string-array-equals",getApplyFn:i=>{const e=new Set(i);return t=>{const r=new Set(t);return e.size===r.size&&r.isSubsetOf(e)}},label:"is",serialize:i=>i,deserialize:i=>i}),zi=M.create({id:"string-array-not-equals",getApplyFn:i=>{const e=new Set(i);return t=>{const r=new Set(t);return e.size!==r.size||!r.isSubsetOf(e)}},label:"is not",serialize:i=>i,deserialize:i=>i}),At=M.create({id:"time-equals",label:"is",getApplyFn:i=>e=>e===i,serialize:i=>i,deserialize:i=>i}),Et=M.create({id:"time-not-equals",label:"is not",getApplyFn:i=>e=>e!==i,serialize:i=>i,deserialize:i=>i}),$t=M.create({id:"time-before",label:"before",getApplyFn:i=>e=>oe(e)<oe(i),serialize:i=>i,deserialize:i=>i}),Dt=M.create({id:"time-after",label:"after",getApplyFn:i=>e=>oe(e)>oe(i),serialize:i=>i,deserialize:i=>i}),Pt=M.create({id:"time-range-in",label:"in between",getApplyFn:i=>e=>cn(e,i),serialize:i=>i,deserialize:i=>i}),jt=M.create({id:"time-range-not-in",label:"not in between",getApplyFn:i=>e=>!cn(e,i),serialize:i=>i,deserialize:i=>i}),V=i=>i;class P extends Ee{id;conditionValue;conditionModifier;field;constructor(e){const{id:t,field:r,conditionValue:a,conditionModifier:l}=e;super(),this.id=t,this.field=r,this.conditionValue=a,this.conditionModifier=l}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}}getConditionValue=()=>this.conditionValue;transformValue(e){return e}setConditionValue=e=>{const t=this.modifiers[this.conditionModifier];e!==void 0&&!t.isConditionValueValid(e)||(this.conditionValue=e,this.notify(this))};getConditionModifier=()=>this.conditionModifier;setConditionModifier=e=>{const t=this.modifiers[e],r=this.getConditionValue();r&&!t.isConditionValueValid(r)&&(this.conditionValue=void 0),this.conditionModifier=e,this.notify(this)};getConditionModifiers=()=>Object.entries(this.modifiers);accessorFn=e=>e[this.field.identifier];getApplyFn=()=>{const e=this.modifiers[this.conditionModifier],t=this.getConditionValue(),r=t!==void 0&&e.isConditionValueValid(t),a=r?e.modifier.getApplyFn(t):null;return l=>{if(!r)return!0;const s=this.transformValue(l);return e.isValueValid(s)?a(s):!1}}}const Ut=d.memo,Se=Ut(function(i){const{ref:e,children:t,...r}=i,a=d.useCallback(l=>typeof t=="function"?n.jsxs(n.Fragment,{children:[t(l),n.jsx(o.Menu.SelectedIndicator,{className:"ml-[auto]",children:n.jsx(o.LuIcon,{icon:J})})]}):n.jsxs(n.Fragment,{children:[t,n.jsx(o.Menu.SelectedIndicator,{className:"ml-[auto]",children:n.jsx(o.LuIcon,{icon:J})})]}),[t]);return n.jsx(o.Menu.SelectItem,{ref:e,...r,children:a})}),Gt=Ut(function(i){const{ref:e,children:t,...r}=i,a=d.useCallback(l=>typeof t=="function"?n.jsxs(n.Fragment,{children:[t(l),n.jsx(o.Menu.SelectedIndicator,{className:"ml-auto",children:n.jsx(o.LuIcon,{icon:J})})]}):n.jsxs(n.Fragment,{children:[t,n.jsx(o.Menu.SelectedIndicator,{className:"ml-auto",children:n.jsx(o.LuIcon,{icon:J})})]}),[t]);return n.jsx(o.Menu.MultiSelectItem,{ref:e,...r,children:a})}),Nn=d.memo(i=>{const{ref:e,children:t,...r}=i,a=d.useCallback(l=>typeof t=="function"?n.jsxs(n.Fragment,{children:[t(l),n.jsx(o.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:s=>s?n.jsx(o.LuIcon,{icon:di}):n.jsx(o.LuIcon,{icon:J})})]}):n.jsxs(n.Fragment,{children:[t,n.jsx(o.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:s=>s?n.jsx(o.LuIcon,{icon:di}):n.jsx(o.LuIcon,{icon:J})})]}),[t]);return n.jsx(o.Menu.SelectAllItem,{ref:e,...r,children:a})});Nn.displayName="SelectAllItemTemplate";const U=i=>{const{children:e,condition:t,size:r="sm",variant:a,accentColor:l,radius:s}=i,h=d.useCallback(u=>{t.setConditionModifier(u)},[t]);return n.jsxs(o.Menu.Root,{align:"start",children:[n.jsx(o.Menu.ClickTrigger,{children:e}),n.jsx(o.Menu.Content,{size:r,variant:a,radius:s,accentColor:l,children:n.jsx(o.Menu.SelectGroup,{required:!0,value:t.getConditionModifier(),onValueChange:h,children:t.getConditionModifiers().map(([u,f])=>n.jsx(Se,{value:u,children:f.modifier.label},u))})})]})},Fi=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:a,modal:l,size:s,align:h,accentColor:u="base",...f}=i;return n.jsxs(o.Popover.Root,{open:t,onOpenChange:r,defaultOpen:a,modal:l,children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:e}),n.jsx(o.Popover.Content,{size:s,align:h,children:n.jsx(o.DayPicker,{size:s,accentColor:u,...f})})]})});Fi.displayName="DayPickerPopover";const kt=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:a,modal:l,size:s,accentColor:h="base",values:u,onValuesChange:f,placeholder:p="Enter text",...g}=i,[m,C]=d.useState(""),v=d.useCallback(x=>{C(x.target.value)},[]),y=d.useCallback(x=>{x.key==="Enter"&&(x.preventDefault(),x.stopPropagation(),f([...u,m]),C(""))},[m,f,u]),S=d.useCallback(()=>{f([...u,m]),C("")},[m,f,u]),z=d.useCallback(x=>{const I=[...u];I.splice(x,1),f(I)},[f,u]);return n.jsxs(o.Popover.Root,{open:t,onOpenChange:r,defaultOpen:a,modal:l,children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:e}),n.jsx(o.Popover.Content,{size:s,onClick:o.stopPropagation,accentColor:h,...g,children:n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{className:"flex gap-2",children:[n.jsx(o.Input.Root,{className:"grow",accentColor:"base",variant:"outline",size:"sm",children:n.jsx(o.Input.Field,{value:m,onChange:v,onKeyDown:y,placeholder:p,...g})}),n.jsx(o.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button",onClick:S,children:n.jsx(o.LuIcon,{icon:Z})})]}),u.length>0&&n.jsx("div",{className:"flex flex-col gap-1",children:u.map((x,I)=>n.jsxs(o.Badge,{className:"flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[n.jsx("span",{className:"truncate",children:x}),n.jsx(o.IconButton,{size:"xs",variant:"ghost",type:"button",accentColor:"base",onClick:()=>{z(I)},children:n.jsx(o.LuIcon,{icon:ne})})]},`${x}-${I}`))})]})})]})});kt.displayName="NumberInputPopover";const ze=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:a,modal:l,size:s,accentColor:h="base",value:u,onValueChange:f,placeholder:p="Enter a number",...g}=i,[m,C]=d.useState(null);d.useEffect(()=>{u!==void 0&&C(u)},[u]);const v=d.useCallback(S=>{const z=S.target.valueAsNumber;C(isNaN(z)?null:z)},[]),y=d.useCallback(S=>{const z=S.target.valueAsNumber;f?.(isNaN(z)?null:z)},[f]);return n.jsxs(o.Popover.Root,{open:t,onOpenChange:r,defaultOpen:a,modal:l,children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:e}),n.jsx(o.Popover.Content,{size:s,onClick:o.stopPropagation,...g,children:n.jsx(o.Input.Root,{size:s,accentColor:h,children:n.jsx(o.Input.Field,{placeholder:p,type:"number",value:m??"",onChange:v,onBlur:y})})})]})});ze.displayName="NumberInputPopover";const j=i=>{const{condition:e,onClick:t,...r}=i,a=d.useCallback(()=>{t(e)},[e,t]);return n.jsx(o.IconButton,{onClick:a,...r,children:n.jsx(o.LuIcon,{icon:ne})})};j.displayName="RemoveConditionButton";const Ue=d.memo(i=>{const{ref:e,selectFieldOptions:t,...r}=i,a=d.useMemo(()=>t.map(l=>typeof l=="string"?{value:l,label:l}:l),[t]);return n.jsxs(o.Menu.MultiSelectGroup,{ref:e,...r,children:[n.jsx(Nn,{children:"Select all"}),a.map(l=>n.jsx(Gt,{value:l.value,children:n.jsx("span",{className:"truncate",children:l.label})},l.value))]})});Ue.displayName="SelectFieldOptionMultiSelectGroup";const Mn=d.memo(i=>{const{ref:e,selectFieldOptions:t,...r}=i,a=d.useMemo(()=>t.map(l=>typeof l=="string"?{value:l,label:l}:l),[t]);return n.jsx(o.Menu.SelectGroup,{ref:e,...r,children:a.map(l=>n.jsx(Se,{value:l.value,children:n.jsx("span",{className:"truncate",children:l.label})},l.value))})});Mn.displayName="SelectFieldOptionSelectGroup";const Te=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:a,modal:l,size:s,accentColor:h="base",value:u,onValueChange:f,placeholder:p="Enter text",...g}=i,[m,C]=d.useState(""),v=d.useCallback(S=>{C(S.target.value)},[]),y=d.useCallback(S=>{const z=S.target.value;f?.(z)},[f]);return d.useEffect(()=>{u&&C(u)},[u]),n.jsxs(o.Popover.Root,{open:t,onOpenChange:r,defaultOpen:a,modal:l,children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:e}),n.jsx(o.Popover.Content,{size:s,onClick:o.stopPropagation,...g,children:n.jsx(o.Input.Root,{size:s,accentColor:h,children:n.jsx(o.Input.Field,{placeholder:p,type:"text",value:m,onChange:v,onBlur:y})})})]})});Te.displayName="TextInputPopover";const wi=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:a,modal:l,size:s="sm",accentColor:h="base",value:u,onValueChange:f,...p}=i;return n.jsxs(o.Popover.Root,{open:t,onOpenChange:r,defaultOpen:a,modal:l,children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:e}),n.jsx(o.Popover.Content,{size:s,onClick:o.stopPropagation,accentColor:h,...p,children:n.jsx(Ci,{compact:!0,size:s,value:u,onChange:f})})]})});wi.displayName="TimeInputPopover";const Ht=i=>{const{condition:e,onRemove:t}=i,r=e.getConditionValue(),a=e.getConditionModifier(),l=()=>{switch(r){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[e.field.type].icon}),n.jsx("span",{className:"truncate",children:e.field.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[a].modifier.label})}),n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:l()})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsxs(o.Menu.SelectGroup,{required:!0,value:r,onValueChange:e.setConditionValue,children:[n.jsx(Se,{value:!0,children:"true"}),n.jsx(Se,{value:!1,children:"false"})]})})]}),n.jsx(j,{condition:e,onClick:t})]})},Jt={equals:V({modifier:zt,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:Ft,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Ge extends P{modifiers=Jt;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=Jt[a];let h;return r!==void 0&&(h=s.modifier.deserialize(r)),new Ge({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Ht,{condition:this,...e},this.id)}}const Le=[],Wt=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=d.useCallback(u=>{u.length>0?e.setConditionValue(u):e.setConditionValue(void 0)},[e]),h=()=>a===void 0?"...":a===null?"empty":a.length===0?"...":`${a.length} options`;return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"soft",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"soft",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"truncate",children:h()})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(Ue,{values:a??Le,selectFieldOptions:e.field.options,onValuesChange:s})})]}),n.jsx(j,{condition:e,onClick:t})]})},Xt={equals:V({modifier:Si,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:zi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),every:V({modifier:Vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),some:V({modifier:yi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),none:V({modifier:vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ke extends P{modifiers=Xt;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=Xt[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ke({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Wt,{condition:this,...e},this.id)}}class bi extends Ee{conditions;constructor(e){super(),this.conditions=this.initConditions(e)}conditionObserver=()=>{this.conditions=[...this.conditions],this.notify(this)};initConditions=e=>{for(const t of e)t.observe(this.conditionObserver);return e};getConditions(){return this.conditions}addCondition(e){this.conditions=this.initConditions([...this.conditions,e]),this.notify(this)}addConditions(e){this.conditions=this.initConditions([...this.conditions,...e]),this.notify(this)}removeCondition(e){this.conditions=this.initConditions(this.conditions.filter(t=>t.id!==e.id)),this.notify(this)}removeConditions(e){const t=new Set(e.map(r=>r.id));this.conditions=this.initConditions(this.conditions.filter(r=>!t.has(r.id))),this.notify(this)}applyConditions(e){return this.conditions.length===0?!0:this.conditions.map(r=>[r.getApplyFn(),r.accessorFn]).every(([r,a])=>r(a(e)))}}const Go=(i,e)=>d.useMemo(()=>{const t=new bi(i);return t.observe(r=>e(r.getConditions())),t},[i,e]),Kt=i=>{const{condition:e,onRemove:t}=i,r=e.getConditionValue(),a=e.getConditionModifier(),l=()=>{switch(a){case"equals":case"notEquals":{const s=e.modifiers.equals,h=r!==void 0&&s.isConditionValueValid(r)?r:void 0;return n.jsx(Fi,{required:!1,size:"sm",mode:"single",selected:h??void 0,onSelect:u=>e.setConditionValue(u),children:n.jsx(o.Button,{type:"button",className:"truncate",children:h!==void 0?h?.toLocaleDateString()??"empty":"..."})})}case"before":case"after":{const s=e.modifiers.after,h=r!==void 0&&s.isConditionValueValid(r)?r:void 0;return n.jsx(Fi,{required:!0,size:"sm",mode:"single",selected:h,onSelect:e.setConditionValue,children:n.jsx(o.Button,{type:"button",className:"truncate",children:h?h.toLocaleDateString():"..."})})}case"in":case"notIn":{const s=e.modifiers.in,h=r!==void 0&&s.isConditionValueValid(r)?r:void 0;return n.jsx(Fi,{required:!0,mode:"range",size:"sm",selected:h,onSelect:e.setConditionValue,children:n.jsx(o.Button,{className:"truncate",children:h?`${h.from?.toLocaleDateString()} - ${h.to?.toLocaleDateString()}`:"..."})})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[e.field.type].icon}),n.jsx("span",{className:"truncate",children:e.field.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[a].modifier.label})}),l(),n.jsx(j,{condition:e,onClick:t})]})},Yt={equals:V({modifier:wt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),notEquals:V({modifier:bt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),before:V({modifier:Nt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),after:V({modifier:Mt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),in:V({modifier:xt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>"to"in(i??{})&&"from"in(i??{}),isSerializedValueValid:i=>typeof i=="object"&&"to"in i&&"from"in i}),notIn:V({modifier:It,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>"to"in(i??{})&&"from"in(i??{}),isSerializedValueValid:i=>typeof i=="object"&&"to"in i&&"from"in i})};class He extends P{modifiers=Yt;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=Yt[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new He({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Kt,{condition:this,...e},this.id)}}const Zt=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=d.useCallback(u=>{u.length>0?e.setConditionValue(u):e.setConditionValue(void 0)},[e]),h=()=>a===void 0?"...":a===null?"empty":a.length===0?"...":`${a.length} options`;return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"truncate",children:h()})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(Ue,{values:a??Le,selectFieldOptions:r.options,onValuesChange:s})})]}),n.jsx(j,{condition:e,onClick:t})]})},Qt={equals:V({modifier:Si,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:zi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),every:V({modifier:Vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),some:V({modifier:yi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),none:V({modifier:vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Je extends P{modifiers=Qt;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=Qt[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Je({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Zt,{condition:this,...e},this.id)}}const Rt=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=d.useCallback(u=>{e.setConditionValue(u.length>0?u:void 0)},[e]),h=()=>{if(a===void 0)return"...";if(a===null)return"empty";switch(a.length){case 0:return"...";case 1:return a[0].toString();default:return`${a.length} values`}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),n.jsx(kt,{values:a??Le,onValuesChange:s,children:n.jsx(o.Button,{type:"button",className:"truncate",children:h()})}),n.jsx(j,{condition:e,onClick:t})]})},er={equals:V({modifier:Si,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:zi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),every:V({modifier:Vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),some:V({modifier:yi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),none:V({modifier:vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class We extends P{modifiers=er;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=er[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new We({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Rt,{condition:this,...e},this.id)}}const ir=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=d.useCallback(u=>{e.setConditionValue(u??void 0)},[e]),h=()=>{switch(l){case"equals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const u=e.modifiers.greaterThan,f=a!==void 0&&u.isConditionValueValid(a)?a:void 0;return n.jsx(ze,{value:f??null,onValueChange:s,size:"sm",children:n.jsx(o.Button,{type:"button",className:"truncate",children:f!==void 0?f??"empty":"..."})})}case"inRange":case"notInRange":{const u=e.modifiers.inRange,f=a!==void 0&&u.isConditionValueValid(a)?a:void 0;return n.jsxs(n.Fragment,{children:[n.jsx(ze,{value:f?.from??null,onValueChange:p=>{e.setConditionValue({from:p,to:f?.to??null})},size:"sm",children:n.jsx(o.Button,{className:"truncate",children:f?.from??"..."})}),n.jsx(ze,{value:f?.to??null,onValueChange:p=>{e.setConditionValue({from:f?.from??null,to:p})},size:"sm",children:n.jsx(o.Button,{className:"truncate",children:f?.to??"..."})})]})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),h(),n.jsx(j,{condition:e,onClick:t})]})},nr={equals:V({modifier:mn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),notEquals:V({modifier:Cn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThan:V({modifier:Vn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThanOrEquals:V({modifier:yn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThan:V({modifier:vn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThanOrEquals:V({modifier:Sn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),inRange:V({modifier:zn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"}),notInRange:V({modifier:Fn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"})};class Xe extends P{modifiers=nr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=nr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Xe({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(ir,{condition:this,...e},this.id)}}const tr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Te,{value:a??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:a||"..."})})})}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},rr={equals:V({modifier:ae,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Oe,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:_e,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Ke extends P{modifiers=rr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=rr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Ke({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(tr,{condition:this,...e},this.id)}}const or=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":{const h=e.modifiers.equals,u=a!==void 0&&h.isConditionValueValid(a)?a:void 0;return n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:u!==void 0?u?fe[u].label:"empty":"..."})})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(o.Menu.SelectGroup,{required:!1,value:u,onValueChange:e.setConditionValue,children:Ne.map(f=>{const{label:p}=fe[f];return n.jsx(Se,{value:f,children:n.jsx("span",{className:"truncate",children:p})},f)})})})]})}case"includes":case"excludes":{const h=e.modifiers.includes,u=a!==void 0&&h.isConditionValueValid(a)?a:void 0;return n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",children:u?`${u.length} statuses`:"..."})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsxs(o.Menu.MultiSelectGroup,{values:u??Le,onValuesChange:e.setConditionValue,children:[n.jsx(Nn,{children:"Select all"}),Ne.map(f=>{const{label:p,icon:g}=fe[f];return n.jsxs(Gt,{value:f,children:[n.jsx(o.LuIcon,{icon:g}),n.jsx("span",{className:"truncate",children:p})]},f)})]})})]})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},ar={equals:V({modifier:_t,isValueValid:i=>i!==null,isConditionValueValid:i=>typeof i=="string",isSerializedValueValid:i=>typeof i=="string"}),notEquals:V({modifier:Tt,isValueValid:i=>i!==null,isConditionValueValid:i=>typeof i=="string",isSerializedValueValid:i=>typeof i=="string"}),includes:V({modifier:Lt,isValueValid:i=>i!==null,isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)}),excludes:V({modifier:Bt,isValueValid:i=>i!==null,isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)})};class Ye extends P{modifiers=ar;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=ar[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Ye({field:t,conditionModifier:a,conditionValue:h,...l})}transformValue(e){return e.status}render(e){return n.jsx(or,{condition:this,...e},this.id)}}const lr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=d.useMemo(()=>r.options.map(f=>typeof f=="string"?{value:f,label:f}:f),[r.options]),h=d.useMemo(()=>{const f={};for(const p of s)f[p.value]=p.label;return f},[s]),u=()=>{switch(l){case"equals":case"notEquals":{const f=e.modifiers.equals,p=a!==void 0&&f.isConditionValueValid(a)?a:void 0;return n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:p!==void 0?p?h[p]:"empty":"..."})})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(Mn,{required:!0,selectFieldOptions:r.options,value:p??void 0,onValueChange:e.setConditionValue})})]})}case"includes":case"excludes":{const f=e.modifiers.includes,p=a!==void 0&&f.isConditionValueValid(a)?a:void 0;return n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",children:p?`${p.length} options`:"..."})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(Ue,{selectFieldOptions:r.options,values:p??Le,onValuesChange:e.setConditionValue})})]})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),u(),n.jsx(j,{condition:e,onClick:t})]})},sr={equals:V({modifier:ae,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),notEquals:V({modifier:le,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),includes:V({modifier:wn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)}),excludes:V({modifier:bn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)})};class Ze extends P{modifiers=sr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=sr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Ze({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(lr,{condition:this,...e},this.id)}}const dr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const h=e.modifiers[l],u=a!==void 0&&h.isConditionValueValid(a)?a:void 0;return n.jsx(ze,{value:u??null,onValueChange:f=>e.setConditionValue(f??void 0),size:"sm",children:n.jsx(o.Button,{type:"button",className:"truncate",children:u!==void 0?u:"..."})})}case"inRange":case"notInRange":{const h=e.modifiers.inRange,u=a!==void 0&&h.isConditionValueValid(a)?a:void 0;return n.jsxs(n.Fragment,{children:[n.jsx(ze,{value:u?.from??null,onValueChange:f=>{e.setConditionValue({from:f,to:u?.to??null})},size:"sm",children:n.jsx(o.Button,{className:"truncate",children:u?.from??"..."})}),n.jsx(ze,{value:u?.to??null,onValueChange:f=>{e.setConditionValue({from:u?.from??null,to:f})},size:"sm",children:n.jsx(o.Button,{className:"truncate",children:u?.to??"..."})})]})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},cr={equals:V({modifier:mn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),notEquals:V({modifier:Cn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThan:V({modifier:Vn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThanOrEquals:V({modifier:yn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThan:V({modifier:vn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThanOrEquals:V({modifier:Sn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),inRange:V({modifier:zn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"}),notInRange:V({modifier:Fn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"})};class Qe extends P{modifiers=cr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=cr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Qe({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(dr,{condition:this,...e},this.id)}}const ur=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Te,{value:a??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:a||"..."})})})}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},hr={equals:V({modifier:ae,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Oe,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:_e,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Re extends P{modifiers=hr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=hr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Re({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(ur,{condition:this,...e},this.id)}}const fr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=d.useMemo(()=>r.options.map(p=>typeof p=="string"?{value:p,label:p}:p),[r.options]),h=d.useMemo(()=>{const p={};for(const g of s)p[g.value]=g.label;return p},[s]),u=d.useCallback(p=>{p.length>0?e.setConditionValue(p):e.setConditionValue([])},[e]),f=()=>{switch(l){case"equals":case"notEquals":{const p=e.modifiers.equals,g=a!==void 0&&p.isConditionValueValid(a)?a:void 0;return n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:g!==void 0?g?h[g]:"empty":"..."})})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(Mn,{required:!1,selectFieldOptions:r.options,value:g??void 0,onValueChange:e.setConditionValue})})]})}case"includes":case"excludes":{const p=e.modifiers.includes,g=a!==void 0&&p.isConditionValueValid(a)?a:void 0;return n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",children:g?`${g.length} options`:"..."})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(Ue,{selectFieldOptions:r.options,values:g??Le,onValuesChange:u})})]})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),f(),n.jsx(j,{condition:e,onClick:t})]})},pr={equals:V({modifier:ae,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),notEquals:V({modifier:le,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),includes:V({modifier:wn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)}),excludes:V({modifier:bn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)})};class ei extends P{modifiers=pr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=pr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ei({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(fr,{condition:this,...e},this.id)}}const gr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Te,{value:a??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:a||"..."})})})}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},mr={equals:V({modifier:ae,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Oe,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:_e,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ii extends P{modifiers=mr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=mr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ii({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(gr,{condition:this,...e},this.id)}}const Cr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Te,{value:a??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:a||"..."})})})}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},Vr={equals:V({modifier:ae,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Oe,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:_e,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ni extends P{modifiers=Vr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=Vr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ni({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Cr,{condition:this,...e},this.id)}}const yr=i=>{const{condition:e,onRemove:t}=i,r=e.getConditionValue(),a=e.getConditionModifier(),l=()=>{switch(a){case"equals":case"notEquals":case"before":case"after":{const s=typeof r=="string"?r:void 0;return n.jsx(wi,{value:s,onValueChange:h=>e.setConditionValue(h??void 0),size:"sm",children:n.jsx(o.Button,{type:"button",className:"truncate",children:s?mi(s):"..."})})}case"in":case"notIn":{const s=r&&typeof r=="object"?r:void 0,h=u=>{e.setConditionValue(u.from||u.to?u:void 0)};return n.jsxs(n.Fragment,{children:[n.jsx(wi,{value:s?.from,onValueChange:u=>h({from:u,to:s?.to??null}),size:"sm",children:n.jsx(o.Button,{type:"button",className:"truncate",children:s?.from?mi(s.from):"..."})}),n.jsx(wi,{value:s?.to,onValueChange:u=>h({from:s?.from??null,to:u}),size:"sm",children:n.jsx(o.Button,{type:"button",className:"truncate",children:s?.to?mi(s.to):"..."})})]})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[e.field.type].icon}),n.jsx("span",{className:"truncate",children:e.field.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[a].modifier.label})}),l(),n.jsx(j,{condition:e,onClick:t})]})},vr={equals:V({modifier:At,isValueValid:i=>A(i),isConditionValueValid:i=>A(i),isSerializedValueValid:i=>A(i)}),notEquals:V({modifier:Et,isValueValid:i=>A(i),isConditionValueValid:i=>A(i),isSerializedValueValid:i=>A(i)}),before:V({modifier:$t,isValueValid:i=>A(i),isConditionValueValid:i=>A(i),isSerializedValueValid:i=>A(i)}),after:V({modifier:Dt,isValueValid:i=>A(i),isConditionValueValid:i=>A(i),isSerializedValueValid:i=>A(i)}),in:V({modifier:Pt,isValueValid:i=>A(i),isConditionValueValid:i=>je(i),isSerializedValueValid:i=>je(i)}),notIn:V({modifier:jt,isValueValid:i=>A(i),isConditionValueValid:i=>je(i),isSerializedValueValid:i=>je(i)})};class ti extends P{modifiers=vr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=vr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ti({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(yr,{condition:this,...e},this.id)}}const Sr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(a){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:s()})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsxs(o.Menu.SelectGroup,{required:!0,value:a,onValueChange:e.setConditionValue,children:[n.jsx(Se,{value:!0,children:"empty"}),n.jsx(Se,{value:!1,children:"not empty"})]})})]}),n.jsx(j,{condition:e,onClick:t})]})},zr={equals:V({modifier:qt,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:Ot,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ri extends P{modifiers=zr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=zr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ri({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Sr,{condition:this,...e},this.id)}}const Fr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Te,{value:a??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:a||"..."})})})}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},wr={equals:V({modifier:ae,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Oe,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:_e,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class oi extends P{modifiers=wr;constructor(e){super(e)}transformValue(e){return e?.toString()??""}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=wr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new oi({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Fr,{condition:this,...e},this.id)}}const ko={date:He,time:ti,number:Xe,boolean:Ge,select:ei,string:ii,url:oi,text:ni,upload:ri,qr:Re,"multi-string":We,"multi-select":Je,radio:Ze,"checkbox-list":ke,"pass-fail":Ye,otp:Ke,rating:Qe},br=(i,e)=>{if(i.type!==e.type)throw new Error(`field and condition type mismatch ${i.type} !== ${e.type}`);return ko[e.type].deserialize(e,i)},xn=(i,e)=>{const t=In(i,e),r={};for(const a of i)r[a.identifier]=a;return t.map(a=>br(r[a.fieldId],a))},Nr=(i,e)=>qn(i,e).map(r=>r.serialize()),In=(i,e)=>{const t=new Set(i.map(r=>r.identifier));return e.filter(r=>t.has(r.fieldId))},qn=(i,e)=>{const t=new Set(i.map(r=>r.identifier));return e.filter(r=>t.has(r.field.identifier))},Ni=i=>pn[i.type].deserialize(i);function Ho(i){return i.map(Mr)}const Mr=i=>i.type==="section"?W.deserialize(i):Ni(i);function Jo(i){return i.map(Ni)}function Wo(i){const e=[];for(const t of i)if(t instanceof W)for(const r of t.getFields())e.push(r);else e.push(t);return e}function Xo(i){const e={};for(const t of i)e[t.identifier]=t;return e}function xr(i,e,t=!0){const r=t?Mi(i,e):e,a={};for(const l of i){if(!(l.identifier in r))continue;const s=r[l.identifier];a[l.identifier]=l.serializeValue(s)}return a}function Ir(i,e,t=!0){const r=t?On(i,e):e,a={};for(const l of i){if(!(l.identifier in r))continue;const s=r[l.identifier];a[l.identifier]=l.deserializeValue(s)}return a}function Mi(i,e){const t={};for(const r of i){if(!(r.identifier in e))continue;const a=e[r.identifier];r.isValue(a)&&(t[r.identifier]=r.cleanValue(a))}return t}function On(i,e){const t={};for(const r of i){if(!(r.identifier in e))continue;const a=e[r.identifier];r.isSerializedValue(a)&&(t[r.identifier]=r.cleanSerializedValue(a))}return t}function qr(i,e){const t=Mi(i,e),r={},a={};for(const l of i){if(!(l.identifier in t))continue;const s=t[l.identifier];switch(l.type){case"upload":if(!l.isValue(s))break;a[l.identifier]=s,r[l.identifier]=[];break;case"pass-fail":if(!l.isValue(s))break;a[l.identifier]=s.files,r[l.identifier]={...s,files:[]};break;default:r[l.identifier]=e[l.identifier]}}return[r,a]}function Or(i,e,t){const r={};for(const a of i){if(!(a.identifier in e))continue;const l=e[a.identifier];switch(a.type){case"upload":if(!a.isValue(l))break;r[a.identifier]=t[a.identifier]??[];break;case"pass-fail":if(!a.isValue(l))break;r[a.identifier]={...l,files:t[a.identifier]??[]};break;default:if(!a.isValue(l))break;r[a.identifier]=l}}return r}const _r=(i,e)=>{const t={};for(const r of i){const a=e[r.identifier];t[r.identifier]=a!==void 0?a:r.blankValue()}return t},Tr=(i,e,t)=>{const r={};for(const a of i){const l=e[a.identifier],s=t[a.identifier];a.areValuesEqual(l,s)||(r[a.identifier]=s)}return r},Lr=(i,e,t)=>{const r={};for(const a of i){const l=e[a.identifier],s=t[a.identifier];a.areValuesEqual(l,s)&&(r[a.identifier]=s)}return r},_n=(i,e,t)=>i.every(r=>{const a=e[r.identifier],l=t[r.identifier];return r.areValuesEqual(a,l)}),Tn=i=>{const e={};for(const t of i)e[t.identifier]=t.blankValue();return e},Br=(i,e)=>_n(i,e,Tn(i)),Ko=Q.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),xi=Q.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),Ln=d.memo(i=>{const{fieldSection:e}=i,{label:t,description:r}=e,a=Y.useWatch(),{fieldSchema:l,size:s}=d.use(L),h=d.useMemo(()=>l.getFieldSections(),[l]),u=d.useMemo(()=>h.findIndex(({identifier:m})=>m===e.identifier),[h,e.identifier]),f=d.useMemo(()=>h.filter(m=>e.identifier in m.conditions),[h,e.identifier]),p=d.useMemo(()=>f.length===0?!0:f.some(m=>{const C=m.getConditions(e.identifier);return new bi(C).applyConditions(a)}),[f,e,a]),g=ui(e.fields);return p?n.jsxs(n.Fragment,{children:[u!==0?n.jsx(o.Separator,{size:"full"}):null,n.jsxs("div",{className:"flex flex-col gap-4",children:[(t||r)&&n.jsx(n.Fragment,{children:n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx(o.Heading,{size:s,children:t}),r&&n.jsx(o.Text,{accentColor:"base",size:s,children:r})]})}),n.jsx("div",{className:xi({size:s}),children:g})]})]}):null});Ln.displayName="FieldSectionLayout";class W extends Ai{type="section";label;description;conditions;fields=[];constructor(e){const{label:t=null,description:r=null,fields:a,conditions:l={},...s}=e;super(s),this.label=t,this.description=r,this.fields=this.initFields(a),this.conditions=this.initConditions(l)}serialize(){const e={};for(const[t,r]of Object.entries(this.conditions))e[t]=r.map(a=>a.serialize());return{...super.serialize(),label:this.label,description:this.description,conditions:e,fields:this.fields.map(t=>t.serialize())}}static deserialize=e=>{const t=e.fields.map(Ni),r={};for(const[a,l]of Object.entries(e.conditions))r[a]=xn(t,l);return new W({...e,fields:t,conditions:r})};getOptions(){return{...super.getOptions(),label:this.label,description:this.description,fields:this.fields,conditions:this.conditions}}duplicate(e){return new W({...this.getOptions(),identifier:e,fields:this.fields.map(t=>t.duplicate(b.v4()))})}setOptions(e){const{label:t,description:r,fields:a,conditions:l,...s}=e;this.label=t??this.label,this.description=r??this.description,this.fields=a||this.fields,this.conditions=l||this.conditions,super.setOptions(s)}getErrors(e){const t={};for(const r of this.fields){const a=r.getError(e[r.identifier]);a&&(t[r.identifier]=a)}return t}fieldObserver=()=>{this.notify(this)};initFields=e=>{for(const t of e)t.observe(this.fieldObserver);return e};getFields(){return this.fields}addField(e,t){const r=[...this.fields];r.splice(t??this.fields.length,0,e),this.fields=this.initFields(r),this.notify(this)}moveField(e,t){const r=[...this.fields],[a]=r.splice(e,1);r.splice(t,0,a),this.fields=r,this.notify(this)}removeField(e){this.fields=this.initFields(this.fields.filter(({identifier:r})=>r!==e.identifier));const t={};for(const[r,a]of Object.entries(this.conditions))t[r]=a.filter(l=>l.field.identifier!==e.identifier);this.conditions=t,this.notify(this)}conditionObserver=()=>{this.notify(this)};initConditions=e=>{for(const t of Object.values(e).flat())t.observe(this.conditionObserver);return e};getConditions(e){return this.conditions[e]}addCondition(e,t){this.conditions=this.initConditions({...this.conditions,[e]:[...this.conditions[e]??[],t]}),this.notify(this)}addConditions(e,t){this.conditions=this.initConditions({...this.conditions,[e]:[...this.conditions[e]??[],...t]}),this.notify(this)}removeCondition(e,t){this.conditions=this.initConditions({...this.conditions,[e]:(this.conditions[e]??[]).filter(r=>r.id!==t.id)}),this.notify(this)}removeConditions(e,t){const r=new Set(t.map(a=>a.id));this.conditions=this.initConditions({...this.conditions,[e]:(this.conditions[e]??[]).filter(a=>!r.has(a.id))}),this.notify(this)}getConditionals(){return new Set(Object.keys(this.conditions))}addConditional(e){this.conditions=this.initConditions({...this.conditions,[e]:[]}),this.notify(this)}removeConditional(e){const t={...this.conditions};delete t[e],this.conditions=this.initConditions(t),this.notify(this)}render(){return n.jsx(Ln,{fieldSection:this})}}const R=d.createContext({}),Ii=d.memo(i=>{const{children:e,variant:t,size:r,accentColor:a,onSelectFieldType:l,...s}=i,h=d.useMemo(()=>{const u={[q.Assessment]:[],[q.Capture]:[],[q.Numeric]:[],[q.Selection]:[],[q.Temporal]:[],[q.Text]:[],[q.Verification]:[]};for(const f of Vt){const{group:p}=_[f];u[p].push(f)}return u},[]);return n.jsxs(o.Menu.Root,{...s,children:[n.jsx(o.Menu.ClickTrigger,{children:e}),n.jsx(o.Menu.Content,{variant:t,size:r,accentColor:a,children:n.jsx(o.Menu.Scroll,{children:Object.entries(h).map(([u,f])=>{const{name:p}=yt[u];return f.length===0?null:n.jsxs(o.Menu.Group,{children:[n.jsx(o.Menu.Label,{children:p}),f.map(g=>n.jsx(Ar,{fieldType:g,onSelectFieldType:l},g))]},u)})})})]})});Ii.displayName="CreateFieldDropdownMenu";const Ar=d.memo(i=>{const{fieldType:e,onSelectFieldType:t}=i,r=d.useCallback(()=>{t(e)},[e,t]),{icon:a,name:l}=_[e];return n.jsxs(o.Menu.Item,{onSelect:r,children:[n.jsx(o.LuIcon,{icon:a}),n.jsx(o.Text,{className:"truncate",children:l})]})});Ar.displayName="CreateFieldDropdownMenuItem";const qi=i=>{switch(i){case"text":return new ye({label:"",required:!1,identifier:b.v4()});case"boolean":return new ce({label:"",required:!1,identifier:b.v4()});case"number":return new H({label:"",required:!1,identifier:b.v4()});case"date":return new be({label:"",required:!1,identifier:b.v4()});case"time":return new xe({label:"",required:!1,identifier:b.v4()});case"string":return new Ve({label:"",required:!1,identifier:b.v4()});case"url":return new Ie({label:"",required:!1,identifier:b.v4()});case"select":return new te({label:"",options:[],required:!1,identifier:b.v4()});case"multi-string":return new de({label:"",required:!1,identifier:b.v4()});case"multi-select":return new ie({label:"",options:[],required:!1,identifier:b.v4()});case"upload":return new ve({label:"",required:!1,identifier:b.v4(),maximum_files:6,maximum_size:qe});case"qr":return new Me({label:"",required:!1,identifier:b.v4()});case"radio":return new me({label:"",options:[],required:!1,identifier:b.v4()});case"checkbox-list":return new ue({label:"",options:[],required:!1,identifier:b.v4()});case"pass-fail":return new ge({label:"",required:!1,identifier:b.v4(),showNotesAndFilesOn:["fail"]});case"otp":return new he({label:"",validationType:"none",required:!1,identifier:b.v4(),length:6});case"rating":return new Ce({label:"",required:!1,identifier:b.v4(),maxRating:5})}},Bn=i=>{switch(i.type){case"text":return new ni({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"boolean":return new Ge({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"number":return new Xe({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"date":return new He({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"time":return new ti({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"string":return new ii({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"url":return new oi({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"select":return new ei({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"multi-string":return new We({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"multi-select":return new Je({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"upload":return new ri({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"qr":return new Re({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"radio":return new Ze({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"checkbox-list":return new ke({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"pass-fail":return new Ye({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"otp":return new Ke({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"rating":return new Qe({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i})}},Er=(i,e)=>{switch(i){case"checkbox-list":return ue.getFieldCreationSchema(e);case"multi-select":return ie.getFieldCreationSchema(e);case"number":return H.getFieldCreationSchema(e);case"radio":return me.getFieldCreationSchema(e);case"select":return te.getFieldCreationSchema(e);case"string":return Ve.getFieldCreationSchema(e);case"text":return ye.getFieldCreationSchema(e);case"upload":return ve.getFieldCreationSchema(e);case"pass-fail":return ge.getFieldCreationSchema(e);case"otp":return he.getFieldCreationSchema(e);case"rating":return Ce.getFieldCreationSchema(e);default:return}},$r=d.memo(i=>{const{popoverInputs:e,...t}=i;return n.jsxs(o.Popover.Root,{children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:n.jsxs(o.Button,{variant:"soft",type:"button",size:"sm",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_o}),"Settings"]})}),n.jsx(o.Popover.Content,{size:"sm",...t,children:n.jsx("div",{className:Q.cx("flex w-full max-w-[350px] flex-col",xi({size:"sm"})),children:e})})]})});$r.displayName="FieldSettingsPopover";const Dr=d.memo(i=>{const{parentPath:e,fieldIndex:t,field:r}=i,a=ci(),{disableRequiredFields:l}=d.use(R),[s,h]=d.useState(void 0);d.useEffect(()=>{r.image instanceof Promise?r.image.then(h).catch(console.error):h(r.image)},[r]);const u=d.useCallback(()=>{r.setOptions({image:void 0})},[r]),[f,p]=d.useMemo(()=>{const F=[],w=[],T=Er(r.type,`${e}.${t}`)??[];for(const G of T)G.showDirectly?F.push(G.field):w.push(G.field);return[F,w]},[r,e,t]),g=ui(f),m=ui(p),C=p.length>0,v=d.useCallback(()=>{s&&a(()=>({file:s}))},[a,s]),y=d.useCallback(F=>{r.setOptions({required:!!F})},[r]),S=d.useCallback(F=>{r.setOptions({label:F.target.value})},[r]),z=d.useCallback(F=>{r.setOptions({description:F.target.value})},[r]),{icon:x,name:I}=_[r.type];return n.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[n.jsxs("div",{className:"flex w-full justify-between gap-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(o.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[n.jsx(o.LuIcon,{icon:x}),I]}),!l&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(o.Checkbox.Root,{checked:r.required,onCheckedChange:y,size:"sm",children:n.jsx(o.Checkbox.Indicator,{children:n.jsx(o.LuIcon,{icon:J})})}),n.jsx(o.Text,{size:"sm",accentColor:"base",children:"Required"})]})]}),C&&n.jsx($r,{popoverInputs:m,align:"end"})]}),s&&n.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[n.jsx(we,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:s,onClick:v}),n.jsx(o.IconButton,{type:"button",className:"group-hover:not-disabled:flex absolute right-2 top-2 hidden",variant:"solid",accentColor:"base","aria-label":"delete",onClick:u,size:"sm",children:n.jsx(o.LuIcon,{icon:se})})]}),n.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[n.jsx(o.Input.Root,{variant:"outline",size:"md",children:n.jsx(o.Input.Field,{placeholder:"Enter your question",value:r.label??"",onChange:S,maxLength:200})}),n.jsx(o.TextArea,{className:"field-sizing-content",placeholder:"Enter a field description (optional)",value:r.description??"",onChange:z,maxLength:1e3,resize:"vertical",size:"md"})]}),f.length>0&&n.jsx("div",{className:Q.cx("w-full",xi({size:"sm"})),children:g})]})});Dr.displayName="FieldBuilder";const An=d.memo(i=>{const{field:e,fieldSection:t,fieldIndex:r,sectionIndex:a}=i,l=d.useRef(null),s=`fields.${a}.fields`,h=d.useCallback(y=>{t.addField(qi(y),r+1)},[r,t]),u=d.useCallback(()=>{t.addField(e.duplicate(b.v4()))},[e,t]),f=d.useCallback(y=>{const S=y==="up"?a-1:a+1;t.moveField(r,S)},[t,r,a]),p=d.useCallback(y=>{const{files:S}=y.target;if(!S||S.length!==1)return;const z=S.item(0);if(z){if(z.size>St){o.toast.error({title:"File upload error",description:`The file ${z.name} exceeded the maximum file size`});return}e.setOptions({image:z})}},[e]),g=d.useCallback(()=>{f("up")},[f]),m=d.useCallback(()=>{f("down")},[f]),C=d.useCallback(()=>{l.current?.click()},[]),v=d.useCallback(()=>{t.removeField(e)},[e,t]);return n.jsxs(o.Card,{className:"flex w-full items-center justify-between gap-4",size:"sm",children:[n.jsx(Dr,{fieldIndex:r,field:e,parentPath:s}),n.jsxs(o.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[n.jsx(Ii,{onSelectFieldType:h,size:"sm",children:n.jsx(o.IconButton,{type:"button",children:n.jsx(o.LuIcon,{icon:Z})})}),n.jsx(o.IconButton,{type:"button",onClick:g,children:n.jsx(o.LuIcon,{icon:Rn})}),n.jsx(o.IconButton,{type:"button",onClick:m,children:n.jsx(o.LuIcon,{icon:Qn})}),n.jsx(o.IconButton,{type:"button",onClick:u,children:n.jsx(o.LuIcon,{icon:Ti})}),n.jsx(o.IconButton,{type:"button",onClick:C,children:n.jsx(o.LuIcon,{icon:Yn})}),n.jsx(o.IconButton,{type:"button",onClick:v,children:n.jsx(o.LuIcon,{icon:se})})]}),n.jsx("input",{className:"hidden",ref:l,type:"file",accept:"image/*",onChange:p})]})});An.displayName="FieldBuilderWithActions";const En=d.memo(i=>{const{children:e,variant:t,size:r,accentColor:a,fields:l,onSelectField:s,...h}=i;return n.jsxs(o.Menu.Root,{...h,children:[n.jsx(o.Menu.ClickTrigger,{children:e}),n.jsx(o.Menu.Content,{variant:t,size:r,accentColor:a,children:n.jsx(o.Menu.Scroll,{children:l.map(u=>n.jsx(Pr,{field:u,onSelectField:s},u.identifier))})})]})});En.displayName="FieldDropdownMenu";const Pr=d.memo(i=>{const{field:e,onSelectField:t}=i,r=d.useCallback(()=>{t(e)},[e,t]);return n.jsxs(o.Menu.Item,{onSelect:r,children:[n.jsx(o.LuIcon,{icon:_[e.type].icon}),e.label||E]})});Pr.displayName="FieldDropdownMenuItem";const jr=d.memo(i=>{const{children:e,variant:t,size:r,accentColor:a,fieldSections:l,onSelectFieldSection:s,...h}=i;return n.jsxs(o.Menu.Root,{...h,children:[n.jsx(o.Menu.ClickTrigger,{children:e}),n.jsx(o.Menu.Content,{variant:t,size:r,accentColor:a,children:l.map(u=>n.jsx(Ur,{fieldSection:u,onSelectFieldSection:s},u.identifier))})]})});jr.displayName="FieldSectionDropdownMenu";const Ur=d.memo(i=>{const{fieldSection:e,onSelectFieldSection:t}=i,r=d.useCallback(()=>{t(e)},[e,t]);return n.jsxs(o.Menu.Item,{onSelect:r,children:[n.jsx(o.LuIcon,{icon:Zn}),e.label||gn]})});Ur.displayName="FieldSectionDropdownMenuItem";const Gr=d.memo(i=>{const{id:e,sourceX:t,sourceY:r,targetX:a,targetY:l,style:s,markerEnd:h,data:u}=i,{targetSection:f,sourceSection:p,layoutDirection:g}=u,m=d.useMemo(()=>p.getConditions(f.identifier),[p,f.identifier]),C=d.useCallback(()=>{p.removeConditional(f.identifier)},[p,f.identifier]),v=d.useCallback(I=>{p.addCondition(f.identifier,Bn(I))},[p,f.identifier]),y=d.useCallback(I=>{p.removeCondition(f.identifier,I)},[p,f.identifier]),[S,z,x]=O.getBezierPath({sourceX:t,sourceY:r,sourcePosition:g==="LR"?O.Position.Right:O.Position.Bottom,targetX:a,targetY:l,targetPosition:g==="LR"?O.Position.Left:O.Position.Top});return n.jsxs(n.Fragment,{children:[n.jsx(O.BaseEdge,{id:e,path:S,style:s,markerEnd:h,labelX:z,labelY:x}),n.jsx(O.EdgeLabelRenderer,{children:n.jsxs(o.Card,{size:"xs",variant:"surface",className:"nodrag nopan bg-(--base-2) pointer-events-auto absolute inline-flex flex-col gap-2",onMouseDown:o.stopPropagation,onClick:o.stopPropagation,"data-floating-content":"",style:{transform:`translate(-50%, -50%) translate(${z}px, ${x}px)`},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(o.Text,{size:"xs",className:"max-w-[280px] truncate",children:p.label||"Untitled section"}),n.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[n.jsx(En,{fields:p.fields,onSelectField:v,children:n.jsx(o.IconButton,{"aria-label":"Add condition",type:"button",variant:"surface",size:"xs",accentColor:"base",children:n.jsx(o.LuIcon,{icon:Z})})}),n.jsxs(o.Tooltip.Root,{children:[n.jsx(o.Tooltip.Trigger,{asChild:!0,children:n.jsx(o.IconButton,{"aria-label":"Remove conditional logic",type:"button",variant:"surface",size:"xs",accentColor:"base",color:"danger",onClick:C,children:n.jsx(o.LuIcon,{icon:se})})}),n.jsx(o.Tooltip.Content,{size:"sm",children:"Remove conditional logic"})]})]})]}),m.length>0&&n.jsx("div",{className:"flex h-max w-full flex-col flex-wrap gap-1",children:m.map(I=>n.jsx(d.Fragment,{children:I.render({onRemove:y})},I.id))})]})})]})});Gr.displayName="FieldSectionConditionEdgeComponent";const kr=d.memo(i=>{const{data:e,selected:t}=i,{fieldSection:r,index:a,layoutDirection:l}=e,{fieldSchema:s}=d.use(R),h=d.useCallback(()=>{s.removeFieldSection(r)},[s,r]),u=d.useCallback(C=>{r.addField(qi(C))},[r]),f=d.useCallback(()=>{const C=new W({identifier:b.v4(),fields:[]});s.addFieldSection(C),r.addConditional(C.identifier)},[s,r]),p=d.useCallback(()=>{s.addFieldSection(r.duplicate(b.v4()))},[s,r]),g=d.useCallback(C=>{r.setOptions({label:C.target.value})},[r]),m=d.useCallback(C=>{r.setOptions({description:C.target.value})},[r]);return n.jsxs(o.Card,{variant:"surface",className:"bg-(--base-2) relative cursor-pointer",size:"sm","data-selected":t?"true":void 0,children:[n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[n.jsx(o.Input.Root,{variant:"outline",size:"md",accentColor:"base",children:n.jsx(o.Input.Field,{placeholder:"Enter a section label (optional)",value:r.label??"",onChange:g,maxLength:200})}),n.jsx(o.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:r.description??"",onChange:m,maxLength:1e3,resize:"vertical",size:"md"})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(o.Text,{weight:"bold",children:"Fields"}),n.jsx(Ii,{onSelectFieldType:u,size:"sm",children:n.jsxs(o.Button,{type:"button",variant:"soft",size:"sm",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:Z})," Add field"]})})]}),n.jsx("div",{className:"flex flex-col gap-3",children:r.fields.map((C,v)=>n.jsx(An,{field:C,fieldSection:r,fieldIndex:v,sectionIndex:a},C.identifier))})]}),n.jsx(O.NodeToolbar,{isVisible:!0,position:O.Position.Right,align:"start",offset:8,onMouseDown:o.stopPropagation,children:n.jsx(o.Card,{variant:"surface",className:"bg-(--base-2) flex flex-col items-center gap-1 p-1",size:"xs",onClick:o.stopPropagation,children:n.jsxs(o.ButtonGroup,{className:"flex flex-col gap-2",variant:"surface",size:"xs",accentColor:"base",children:[n.jsx(o.IconButton,{type:"button",onClick:f,children:n.jsx(o.LuIcon,{icon:Fo})}),n.jsx(o.IconButton,{type:"button",onClick:p,children:n.jsx(o.LuIcon,{icon:Ti})}),n.jsx(o.IconButton,{type:"button",onClick:h,children:n.jsx(o.LuIcon,{icon:se})})]})})}),n.jsx(O.Handle,{type:"target",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:l==="LR"?O.Position.Left:O.Position.Top}),n.jsx(O.Handle,{type:"source",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:l==="LR"?O.Position.Right:O.Position.Bottom})]})});kr.displayName="CustomNode";const Yo={fieldSection:kr},Zo={fieldSectionCondition:Gr},Qo=(i,e,t)=>{const r=new jn.graphlib.Graph().setDefaultEdgeLabel(()=>({}));return r.setGraph({rankdir:t,nodesep:200,edgesep:500,ranksep:500}),e.forEach(a=>r.setEdge(a.source,a.target,{width:500,height:200,labelpos:"c"})),i.forEach(a=>r.setNode(a.id,{...a,width:a.measured?.width??0,height:a.measured?.height??0})),jn.layout(r),[i.map(a=>{const l=r.node(a.id),s=l.x-(a.measured?.width??0)/2,h=l.y-(a.measured?.height??0)/2;return{...a,position:{x:s,y:h}}}),e]},Ro={hideAttribution:!0},Hr=d.memo(()=>{const{errors:i}=Y.useFormState(),{handleSubmit:e}=Y.useFormContext(),{onSave:t,onCancel:r}=d.use(R),{fieldSchema:a}=d.use(R),l=d.useRef(null),[s,h]=d.useState(),[u,f]=d.useState("TB");d.useLayoutEffect(()=>{l.current&&l.current.classList.remove("light")},[]);const p=d.useMemo(()=>a.fieldSections.map(($,X)=>({id:$.identifier,position:{x:0,y:0},data:{index:X,fieldSection:$,layoutDirection:u},draggable:!0,type:"fieldSection"})),[a.fieldSections,u]),g=d.useMemo(()=>{const $=[],X={};for(const K of a.fieldSections)X[K.identifier]=K;for(const K of a.fieldSections){const ai=K.conditions;for(const[li,oa]of Object.entries(ai))$.push({id:`${K.identifier}-${li}`,source:K.identifier,target:li,data:{targetSection:X[li],sourceSection:K,layoutDirection:u},animated:oa.length>0,markerEnd:O.MarkerType.Arrow,style:{strokeWidth:2,stroke:"var(--base-a8)"},type:"fieldSectionCondition"})}return $},[a.fieldSections,u]),[m,C,v]=O.useNodesState(p),[y,S,z]=O.useEdgesState(g);d.useEffect(()=>{C(p)},[p,C]),d.useEffect(()=>{S(g)},[g,S]);const[x,I]=d.useMemo(()=>Qo(m,y,u),[y,u,m]),F=d.useCallback(()=>{a.addFieldSection(new W({identifier:b.v4(),fields:[]}))},[a]),w=d.useCallback($=>{const{source:X,target:K}=$,ai=a.fieldSections.find(({identifier:li})=>li===X);ai.setOptions({conditions:{...ai.conditions,[K]:[]}})},[a.fieldSections]),T=d.useCallback($=>{const X=a.getSectionDependencyGraph();return!Dn.willCreateCycle(X,$.source,$.target)},[a]),G=d.useCallback(()=>{s?.zoomOut()},[s]),ee=d.useCallback(()=>{s?.zoomIn()},[s]),Be=d.useCallback(()=>{s?.fitView()},[s]);return n.jsxs("form",{className:"flex size-full flex-col gap-4",onSubmit:e(t),children:[n.jsxs(o.Card,{className:"relative size-full",variant:"outline",children:[n.jsx(O.ReactFlow,{ref:l,onInit:h,nodes:x,onNodesChange:v,edges:I,onEdgesChange:z,nodeTypes:Yo,edgeTypes:Zo,onConnect:w,attributionPosition:"bottom-left",fitView:!0,minZoom:0,isValidConnection:T,proOptions:Ro}),n.jsx(O.Panel,{position:"top-left",children:n.jsx(o.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:n.jsxs(o.Button,{type:"button",variant:"surface",onClick:F,children:[n.jsx(o.LuIcon,{icon:Z})," Add section"]})})}),n.jsxs(O.Panel,{position:"top-right",className:"flex flex-col items-center gap-2",children:[n.jsxs(o.ToggleGroup.Root,{className:"flex flex-col",type:"single",accentColor:"base",size:"sm",value:u,onValueChange:f,children:[n.jsx(o.ToggleGroup.IconItem,{className:"rounded-b-none",value:"LR",type:"button",children:n.jsx(o.LuIcon,{icon:fo})}),n.jsx(o.ToggleGroup.IconItem,{className:"rounded-t-none",value:"TB",type:"button",children:n.jsx(o.LuIcon,{icon:ho})})]}),n.jsx(o.Separator,{size:"sm"}),n.jsxs(o.ButtonGroup,{className:"flex flex-col",size:"sm",accentColor:"base",variant:"soft",children:[n.jsx(o.IconButton,{className:"rounded-b-none",onClick:ee,type:"button",children:n.jsx(o.LuIcon,{icon:Z})}),n.jsx(o.IconButton,{onClick:G,radius:"none",type:"button",children:n.jsx(o.LuIcon,{icon:di})}),n.jsx(o.IconButton,{className:"rounded-t-none",onClick:Be,type:"button",children:n.jsx(o.LuIcon,{icon:Lo})})]})]}),n.jsx(O.Panel,{position:"bottom-right",children:n.jsxs(o.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[r&&n.jsx(o.Button,{type:"button",variant:"soft",accentColor:"base",onClick:r,children:"Cancel"}),n.jsx(o.Button,{type:"submit",variant:"surface",children:"Save"})]})})]}),!!i.fields?.message&&n.jsx(o.Text,{size:"xs",accentColor:"danger",children:i.fields.message})]})});Hr.displayName="FormBuilderFlowBuilder";const ea=(i,e,t={})=>{const{conditions:r=!1}=t,a=i.get(e.identifier);if(!a)throw new Error(`Attempting to reseed serialized section with identifier ${e.identifier} which is not present in the reseeded identifier map`);const l=new Map,s=e.fields.map(u=>{const f=b.v4(),{image:p,...g}=u;return l.set(u.identifier,f),{...g,identifier:f}}),h={};if(r)for(const[u,f]of Object.entries(e.conditions??{})){const p=i.get(u);if(!p)continue;const g=f.map(m=>{const C=l.get(m.fieldId);if(!C)throw new Error(`Serialized condition referencing undefined field with identifier: ${m.fieldId}`);return{...m,fieldId:C}});h[p]=g}return{...e,identifier:a,conditions:h,fields:s}},ia=(i,e={})=>{const t=new Map(i.map(r=>[r.identifier,b.v4()]));return i.map(r=>ea(t,r,e))},$n=(i,e)=>{const t={},r=i.filter(a=>a instanceof W);for(const a of i)if(a instanceof W){const l=r.filter(h=>a.identifier in h.conditions);if(l.length>0&&!l.some(h=>{const u=h.getConditions(a.identifier);return new bi(u).applyConditions(e)}))continue;const s=a.getErrors(e);Object.assign(t,s)}else{if(!(a instanceof k))throw new Error("Invalid field type");const l=a.identifier,s=a.getError(Un(e,l));s&&ro(t,l,s)}return t},na=async i=>{const e={},t=[];for(const r of i){const{fields:a}=r,l=[];for(const s of a){if(s.image){if(s.image instanceof Promise)try{e[s.identifier]=await s.image}catch(h){console.error("Failed to get image from promise",h)}else e[s.identifier]=s.image;delete s.image}l.push(s)}t.push({...r,fields:l})}return{fields:t,images:e}};async function ta(i){const e={};for(const[t,r]of Object.entries(i))e[t]=await Promise.all(r);return e}class Fe extends Ee{fieldSections;constructor(e){super(),this.fieldSections=this.initFields(e)}serialize(){return this.fieldSections.map(e=>e.serialize())}static deserialize(e){return new Fe(e.map(W.deserialize))}static reseedFieldSections(e,t){return ia(e,t)}fieldObserver=()=>{this.notify(this)};initFields=e=>{for(const t of e)t.observe(this.fieldObserver);return e};getFields(){return this.fieldSections.flatMap(e=>e.getFields())}getFieldSections(){return this.fieldSections}addFieldSection(e,t){const r=[...this.fieldSections];r.splice(t??this.fieldSections.length,0,e),this.fieldSections=this.initFields(r),this.notify(this)}removeFieldSection(e){const t=this.fieldSections.filter(r=>r.identifier!==e.identifier);for(const r of t)r.removeConditional(r.identifier);this.fieldSections=this.initFields(t),this.notify(this)}moveFieldSection(e,t){const r=[...this.fieldSections],[a]=r.splice(e,1);r.splice(t,0,a),this.fieldSections=this.initFields(r),this.notify(this)}getSectionDependencyGraph(){const e=new no.DirectedGraph({type:"directed"});for(const t of this.fieldSections)for(const r of Object.keys(t.conditions))e.mergeEdge(t.identifier,r);return e}getDependenciesOfSection(e){const t=this.getSectionDependencyGraph(),r=new Map(this.fieldSections.map(l=>[l.identifier,l])),a=[];return to.bfsFromNode(t,e,(l,s,h)=>{a.push(r.get(l))},{mode:"in"}),a}cleanValues(e){return Mi(this.getFields(),e)}cleanSerializedValues(e){return On(this.getFields(),e)}deserializeValues(e,t){return Ir(this.getFields(),e,t)}serializeValues(e,t){return xr(this.getFields(),e,t)}initializeValues(e){return _r(this.getFields(),e)}validateValues(e){return $n(this.getFieldSections(),e)}areValuesValid(e){return Object.keys(this.validateValues(e)).length===0}deserializeConditions(e){return xn(this.getFields(),e)}cleanConditions(e){return qn(this.getFields(),e)}serializeConditions(e){return Nr(this.getFields(),e)}cleanSerializedConditions(e){return In(this.getFields(),e)}changedFieldValues(e,t){return Tr(this.getFields(),e,t)}unchangedFieldValues(e,t){return Lr(this.getFields(),e,t)}areValuesEqual(e,t){return _n(this.getFields(),e,t)}areValuesBlank(e){return Br(this.getFields(),e)}blankValues(){return Tn(this.getFields())}extractFilesAndPromisesFromFieldValues(e){return qr(this.getFields(),e)}insertFilesAndPromisesToFieldValues(e,t){return Or(this.getFields(),e,t)}}const Jr=d.memo(i=>{const{sourceFieldSection:e,targetFieldSection:t}=i,r=d.useMemo(()=>e.getConditions(t.identifier),[e,t.identifier]),a=d.useCallback(()=>{e.removeConditional(t.identifier)},[e,t.identifier]),l=d.useCallback(h=>{e.addCondition(t.identifier,Bn(h))},[e,t.identifier]),s=d.useCallback(h=>{e.removeCondition(t.identifier,h)},[e,t.identifier]);return n.jsxs(o.Card,{className:"flex flex-col gap-2",size:"sm",children:[n.jsxs(o.ButtonGroup,{className:"flex justify-between gap-2",size:"sm",accentColor:"base",variant:"soft",children:[n.jsxs(o.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[n.jsx(o.LuIcon,{icon:Zn}),e.label??gn]}),n.jsx(o.IconButton,{type:"button",onClick:a,variant:"ghost",children:n.jsx(o.LuIcon,{icon:se})})]}),n.jsxs("div",{className:"flex h-max w-full flex-wrap gap-2",children:[r.map(h=>h.render({onRemove:s})),n.jsx(En,{fields:e.fields,onSelectField:l,align:"start",children:n.jsx(o.IconButton,{type:"button",size:"sm",variant:"soft",accentColor:"base",children:n.jsx(o.LuIcon,{icon:Z})})})]})]})});Jr.displayName="FieldSectionConditionalItem";const Wr=d.memo(i=>{const{fieldSection:e}=i,{fieldSchema:t}=d.use(R),r=d.useMemo(()=>t.fieldSections.filter(u=>e.identifier in u.conditions),[t.fieldSections,e.identifier]),a=d.useCallback(u=>{u.addConditional(e.identifier)},[e.identifier]),l=d.useCallback(u=>{e.setOptions({label:u.target.value})},[e]),s=d.useCallback(u=>{e.setOptions({description:u.target.value})},[e]),h=d.useMemo(()=>{const u=t.getSectionDependencyGraph();return t.fieldSections.filter(f=>!Dn.willCreateCycle(u,f.identifier,e.identifier))},[e.identifier,t]);return n.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[n.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[n.jsx(o.Input.Root,{variant:"outline",size:"md",children:n.jsx(o.Input.Field,{placeholder:"Enter a section label (optional)",value:e.label??"",onChange:l,maxLength:200})}),n.jsx(o.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:e.description??"",onChange:s,maxLength:1e3,resize:"vertical",size:"md"})]}),n.jsx(o.Separator,{size:"full"}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx(o.Text,{accentColor:"base",children:"Conditions"}),n.jsx(jr,{fieldSections:h,onSelectFieldSection:a,children:n.jsxs(o.Button,{type:"button",variant:"soft",size:"sm",className:"w-max",children:[n.jsx(o.LuIcon,{icon:Z}),"Add condition"]})})]}),r.map(u=>n.jsx(Jr,{sourceFieldSection:u,targetFieldSection:e},u.identifier))]}),n.jsx(o.Separator,{size:"full"})]})});Wr.displayName="FieldSectionBuilder";const Xr=d.memo(i=>{const{fieldSection:e,sectionIndex:t}=i,{fieldSchema:r}=d.use(R),a=o.useAlertDialog(),l=d.useCallback(()=>{r.removeFieldSection(e)},[r,e]),s=d.useCallback(y=>{const S=y==="up"?t-1:t+1;r.moveFieldSection(t,S)},[r,t]),h=d.useCallback(()=>{r.addFieldSection(e.duplicate(b.v4()))},[r,e]),u=d.useCallback(y=>{e.addField(qi(y))},[e]),f=d.useCallback(()=>{s("up")},[s]),p=d.useCallback(()=>{s("down")},[s]),g=d.useCallback(async()=>{const y=[e.serialize()],S=Fe.reseedFieldSections(y,{conditions:!1}),z=JSON.stringify(S);await navigator.clipboard.writeText(z),o.toast.success({title:"Section copied"})},[e]),m=d.useCallback(async()=>{const S=r.getDependenciesOfSection(e.identifier).map(I=>I.serialize()),z=Fe.reseedFieldSections(S,{conditions:!0}),x=JSON.stringify(z);await navigator.clipboard.writeText(x),o.toast.success({title:"Section copied"})},[e,r]),C=d.useCallback(async()=>{const y=r.getDependenciesOfSection(e.identifier),S=y.length>1,z=y.length-1;S?a({title:"Copy section dependencies?",description:`This section has ${z} dependent section${z>1?"s":""} that will also be copied to maintain the conditions. Do you want to include these dependencies?`,action:"Include",onAction:m,cancel:"Dont include",onCancel:g}):g()},[e,r,a,m,g]),v=d.useCallback(async()=>{let y="";try{y=await navigator.clipboard.readText()}catch{o.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const S=y.trim();if(!S){o.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let z;try{z=JSON.parse(S)}catch{o.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const x=Array.isArray(z)?z:[z],I=[];for(const F of x){if(!F||typeof F!="object")continue;const w=F;if(w.type!=="section"||!Array.isArray(w.fields))continue;const T={type:"section",identifier:typeof w.identifier=="string"?w.identifier:b.v4(),label:typeof w.label=="string"||w.label===null?w.label:null,description:typeof w.description=="string"||w.description===null?w.description:null,conditions:w.conditions&&typeof w.conditions=="object"?w.conditions:{},fields:w.fields};try{I.push(W.deserialize(T))}catch{}}if(I.length===0){o.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}I.forEach((F,w)=>{r.addFieldSection(F,t+1+w)}),o.toast.success({title:"Section pasted",description:"Serialized JSON imported successfully."})},[r,t]);return n.jsxs(o.Card,{variant:"outline",className:"flex w-full items-center justify-between gap-4",size:"sm",children:[n.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[n.jsx(Wr,{fieldSection:e}),n.jsxs("div",{className:"flex w-full flex-col gap-2",children:[n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx(o.Text,{accentColor:"base",size:"md",children:"Fields"}),n.jsx(Ii,{onSelectFieldType:u,size:"sm",children:n.jsxs(o.Button,{type:"button",variant:"soft",size:"sm",children:[n.jsx(o.LuIcon,{icon:Z})," Add field"]})})]}),e.fields.map((y,S)=>n.jsx(An,{field:y,fieldSection:e,fieldIndex:S,sectionIndex:t},y.identifier))]})]}),n.jsxs(o.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[n.jsx(o.IconButton,{type:"button",onClick:f,children:n.jsx(o.LuIcon,{icon:Rn})}),n.jsx(o.IconButton,{type:"button",onClick:p,children:n.jsx(o.LuIcon,{icon:Qn})}),n.jsxs(o.Menu.Root,{align:"end",children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.IconButton,{type:"button",children:n.jsx(o.LuIcon,{icon:Kn})})}),n.jsxs(o.Menu.Content,{size:"sm",children:[n.jsxs(o.Menu.Item,{onSelect:h,children:[n.jsx(o.LuIcon,{icon:Ti}),"Duplicate section"]}),n.jsxs(o.Menu.Item,{onSelect:C,children:[n.jsx(o.LuIcon,{icon:Jn}),"Copy JSON"]}),n.jsxs(o.Menu.Item,{onSelect:v,children:[n.jsx(o.LuIcon,{icon:Wn}),"Paste JSON"]}),n.jsxs(o.Menu.Item,{onSelect:l,children:[n.jsx(o.LuIcon,{icon:se}),"Delete section"]})]})]})]})]})});Xr.displayName="FieldSectionWithActions";const Kr=d.memo(()=>{const{handleSubmit:i}=Y.useFormContext(),{errors:e}=Y.useFormState(),{onSave:t,onCancel:r}=d.use(R),{fieldSchema:a}=d.use(R),l=d.useCallback(()=>{a.addFieldSection(new W({identifier:b.v4(),fields:[]}))},[a]),s=d.useCallback(async()=>{try{const u=a.serialize(),f=Fe.reseedFieldSections(u),p=JSON.stringify(f);await navigator.clipboard.writeText(p),o.toast.success({title:"Sections copied",description:"All sections JSON copied to clipboard."})}catch{o.toast.error({title:"Copy failed",description:"Unable to copy the sections JSON."})}},[a]),h=d.useCallback(async()=>{let u="";try{u=await navigator.clipboard.readText()}catch{o.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const f=u.trim();if(!f){o.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let p;try{p=JSON.parse(f)}catch{o.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const g=Array.isArray(p)?p:[p],m=[];for(const v of g){if(!v||typeof v!="object")continue;const y=v;if(y.type!=="section"||!Array.isArray(y.fields))continue;const S={type:"section",identifier:typeof y.identifier=="string"?y.identifier:b.v4(),label:typeof y.label=="string"||y.label===null?y.label:null,description:typeof y.description=="string"||y.description===null?y.description:null,conditions:y.conditions&&typeof y.conditions=="object"?y.conditions:{},fields:y.fields};try{m.push(W.deserialize(S))}catch{}}if(m.length===0){o.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}const C=a.fieldSections.length;m.forEach((v,y)=>{a.addFieldSection(v,C+y)}),o.toast.success({title:"Sections pasted",description:"Serialized JSON imported successfully."})},[a]);return n.jsxs("form",{className:"flex flex-col gap-4",onSubmit:i(t),children:[n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center justify-end gap-2",children:[n.jsxs(o.Button,{type:"button",variant:"soft",size:"sm",onClick:s,children:[n.jsx(o.LuIcon,{icon:Jn})," Copy JSON"]}),n.jsxs(o.Button,{type:"button",variant:"soft",size:"sm",onClick:h,children:[n.jsx(o.LuIcon,{icon:Wn})," Paste JSON"]})]}),a.fieldSections.map((u,f)=>n.jsx(Xr,{fieldSection:u,sectionIndex:f},u.identifier)),n.jsxs(o.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:l,children:[n.jsx(o.LuIcon,{icon:Z})," Add section"]})]}),!!e.fields?.message&&n.jsx(o.Text,{size:"xs",accentColor:"danger",children:e.fields.message}),n.jsxs(o.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[r&&n.jsx(o.Button,{type:"button",variant:"soft",accentColor:"base",onClick:r,children:"Cancel"}),n.jsx(o.Button,{type:"submit",variant:"surface",children:"Save"})]})]})});Kr.displayName="FormBuilderListBuilder";function Yr(i){const e=t=>{const r={};for(const[a,l]of Object.entries(t))typeof l=="string"?r[a]={type:"validate",message:l}:r[a]=e(l);return r};return e(i)}const Zr=d.memo(d.forwardRef((i,e)=>{const{disabled:t=!1,fieldSchema:r,values:a={},onValuesChange:l,onSubmit:s,submitText:h="Submit",hideSubmit:u=!1,cancelText:f,onCancel:p,hideCancel:g=!1,className:m,submitButtonProps:C,cancelButtonProps:v,cancelIcon:y,submitIcon:S,size:z="md"}=i,x=d.useMemo(()=>r.initializeValues(a),[r,a]),I=d.useCallback($=>{s?.($)},[s]),F=Y.useForm({values:x,mode:"onBlur",criteriaMode:"all",disabled:t,resolver:$=>{const X=r.validateValues($),K=Yr(X);return Object.keys(X).length>0?{values:{},errors:K}:{values:$,errors:{}}}}),w=d.useCallback($=>{l?.($)},[l]);d.useEffect(()=>{const{unsubscribe:$}=F.watch((X,{type:K})=>{K==="change"&&w(X)});return()=>{$()}},[F,w]);const T=tt(r.getFieldSections()),G=d.useMemo(()=>({fieldSchema:r,size:z}),[r,z]),ee=!g&&!!p,Be=!u;return n.jsx(Y.FormProvider,{...F,children:n.jsx(L,{value:G,children:n.jsxs("form",{ref:e,className:Q.cx(m,"flex flex-col gap-4"),onSubmit:F.handleSubmit(I),children:[n.jsx("div",{className:Ko({size:z}),children:T}),!t&&(ee||Be)?n.jsxs(o.ButtonGroup,{className:"flex items-center justify-end gap-2",size:z,children:[ee?n.jsxs(o.Button,{accentColor:"base",type:"button",variant:"soft",onClick:p,...v,children:[n.jsx(o.LuIcon,{icon:y??ne}),f]}):null,Be?n.jsxs(o.Button,{type:"submit",accentColor:"primary",variant:"surface",...C,children:[n.jsx(o.LuIcon,{icon:S??J}),h]}):null]}):null]})})})})),Qr=d.memo(()=>{const{fieldSchema:i}=d.use(R);return n.jsx(Zr,{fieldSchema:i,disabled:!1})});Qr.displayName="FormBuilderPreview";const Rr=d.memo(i=>{const{children:e,initialFields:t,onSave:r,onCancel:a,disableRequiredFields:l=!1}=i,s=d.useCallback(v=>{const y={};(!v.fields||v.fields.length===0)&&(y.fields="At least one field is required.");const S=[];for(const[I,F]of v.fields.entries())for(const[w,T]of F.fields.entries()){const G=Er(T.type,`fields.${I}.fields.${w}`)?.map(({field:ee})=>ee)??[];S.push(...G)}const z={};for(const I of S)z[I.identifier]=Un(v,I.identifier);const x=$n(S,z);return Object.keys(x).length>0&&(y.fields=x.fields),Object.keys(y).length>0&&o.toast.error({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),y},[]),h=d.useMemo(()=>({fields:t??[]}),[t]),u=Y.useForm({values:h,mode:"onSubmit",criteriaMode:"all",reValidateMode:"onSubmit",resolver:v=>{const y=s(v),S=Yr(y);return Object.keys(y).length>0?{values:{},errors:S}:{values:v,errors:{}}}}),f=d.useCallback(v=>{u.setValue("fields",v.serialize())},[u]),p=Y.useWatch({control:u.control,compute:v=>v.fields}),g=d.useMemo(()=>{const v=Fe.deserialize(p);return v.observe(f),v},[p,f]),m=d.useMemo(()=>({fieldSchema:g,disableRequiredFields:l,onSave:r,onCancel:a}),[l,r,a,g]),C=d.useMemo(()=>({fieldSchema:g,size:"sm"}),[g]);return n.jsx(R,{value:m,children:n.jsx(L,{value:C,children:n.jsx(Y.FormProvider,{...u,children:e})})})});Rr.displayName="FormBuilderRoot";const ra={Root:Rr,FlowBuilder:Hr,ListBuilder:Kr,Preview:Qr};c.BaseCondition=P,c.BaseField=k,c.BaseFormElement=Ai,c.BaseOptionsField=$e,c.BaseStringField=Ui,c.BooleanEqualsConditionModifier=zt,c.BooleanField=ce,c.BooleanFieldCondition=Ge,c.BooleanFieldConditionCell=Ht,c.BooleanFieldInput=Pi,c.BooleanNotEqualsConditionModifier=Ft,c.CheckboxListField=ue,c.CheckboxListFieldCondition=ke,c.CheckboxListFieldConditionCell=Wt,c.CheckboxListFieldInput=Gi,c.ConditionManager=bi,c.DateAfterConditionModifier=Mt,c.DateBeforeConditionModifier=Nt,c.DateEqualsConditionModifier=wt,c.DateField=be,c.DateFieldCondition=He,c.DateFieldConditionCell=Kt,c.DateFieldInput=ki,c.DateNotEqualsConditionModifier=bt,c.DateRangeInConditionModifier=xt,c.DateRangeNotInConditionModifier=It,c.DoesNotHaveFilesConditionModifier=Ot,c.FIELD_TYPES=Vt,c.FieldSchema=Fe,c.FieldSection=W,c.FieldSectionLayout=Ln,c.FieldTypeGroup=q,c.FieldTypeToClsMapping=pn,c.FieldsRenderer=Zr,c.FileCard=Bi,c.FormBuilder=ra,c.HasFilesConditionModifier=qt,c.ImageCard=Xi,c.ImageFile=we,c.ImageViewer=$i,c.ImageViewerProvider=nt,c.InputWithLabel=B,c.LONG_TEXT_FIELD_MAX_LENGTH=De,c.MultiSelectField=ie,c.MultiSelectFieldCondition=Je,c.MultiSelectFieldConditionCell=Zt,c.MultiSelectFieldInput=Hi,c.MultiStringField=de,c.MultiStringFieldCondition=We,c.MultiStringFieldConditionCell=Rt,c.MultiStringFieldInput=Di,c.NumberEqualsConditionModifier=mn,c.NumberField=H,c.NumberFieldCondition=Xe,c.NumberFieldConditionCell=ir,c.NumberFieldInput=ji,c.NumberGreaterThanConditionModifier=vn,c.NumberGreaterThanOrEqualsConditionModifier=Sn,c.NumberLessThanConditionModifier=Vn,c.NumberLessThanOrEqualsConditionModifier=yn,c.NumberNotEqualsConditionModifier=Cn,c.NumberRangeInConditionModifier=zn,c.NumberRangeNotInConditionModifier=Fn,c.OTPField=he,c.OTPFieldCondition=Ke,c.OTPFieldConditionCell=tr,c.OTPFieldInput=Wi,c.Observable=Ee,c.PassFailArrayExcludesConditionModifier=Bt,c.PassFailArrayIncludesConditionModifier=Lt,c.PassFailEqualsConditionModifier=_t,c.PassFailField=ge,c.PassFailFieldCondition=Ye,c.PassFailFieldConditionCell=or,c.PassFailFieldInput=Qi,c.PassFailNotEqualsConditionModifier=Tt,c.RadioField=me,c.RadioFieldCondition=Ze,c.RadioFieldConditionCell=lr,c.RadioFieldInput=en,c.RatingField=Ce,c.RatingFieldCondition=Qe,c.RatingFieldConditionCell=dr,c.RatingFieldInput=nn,c.SHORT_TEXT_FIELD_MAX_LENGTH=on,c.ScanField=Me,c.ScanFieldCondition=Re,c.ScanFieldConditionCell=ur,c.ScanFieldInput=rn,c.Scanner=fi,c.ScannerProvider=ft,c.SelectField=te,c.SelectFieldCondition=ei,c.SelectFieldConditionCell=fr,c.SelectFieldInput=Ji,c.StringArrayEqualsConditionModifier=Si,c.StringArrayEveryConditionModifier=Vi,c.StringArrayExcludesConditionModifier=bn,c.StringArrayIncludesConditionModifier=wn,c.StringArrayNoneConditionModifier=vi,c.StringArrayNotEqualsConditionModifier=zi,c.StringArraySomeConditionModifier=yi,c.StringEqualsConditionModifier=ae,c.StringExcludesConditionModifier=_e,c.StringField=Ve,c.StringFieldCondition=ii,c.StringFieldConditionCell=gr,c.StringFieldInput=an,c.StringIncludesConditionModifier=Oe,c.StringNotEqualsConditionModifier=le,c.TextField=ye,c.TextFieldCondition=ni,c.TextFieldConditionCell=Cr,c.TextFieldInput=ln,c.TimeAfterConditionModifier=Dt,c.TimeBeforeConditionModifier=$t,c.TimeEqualsConditionModifier=At,c.TimeField=xe,c.TimeFieldCondition=ti,c.TimeFieldConditionCell=yr,c.TimeFieldControl=Ci,c.TimeFieldInput=un,c.TimeNotEqualsConditionModifier=Et,c.TimeRangeInConditionModifier=Pt,c.TimeRangeNotInConditionModifier=jt,c.UNLABELLED_FIELD_LABEL=E,c.UNLABELLED_SECTION_LABEL=gn,c.URLField=Ie,c.URLFieldCondition=oi,c.URLFieldConditionCell=Fr,c.URLFieldInput=fn,c.UTC_OFFSETS=sn,c.UTC_OFFSETS_SET=pt,c.UUIDFile=re,c.UUIDPromise=pe,c.UploadField=ve,c.UploadFieldCondition=ri,c.UploadFieldConditionCell=Sr,c.UploadFieldInput=hn,c.VideoCard=Yi,c.VideoFile=Ki,c.areFieldValuesBlank=Br,c.areFieldValuesEqual=_n,c.areFileAndPromiseArraysEqual=hi,c.arePassFieldValuesEqual=dt,c.areSerializedPassFailFieldValuesEqual=ct,c.awaitFilesAndPromises=ta,c.blankFieldValues=Tn,c.changedFieldValues=Tr,c.cleanConditions=qn,c.cleanFieldValues=Mi,c.cleanSerializedConditions=In,c.cleanSerializedFieldValues=On,c.createCondition=Bn,c.createConditionModifierConfig=V,c.createField=qi,c.createTime=dn,c.deserialize=Mr,c.deserializeCondition=br,c.deserializeConditions=xn,c.deserializeField=Ni,c.deserializeFieldValues=Ir,c.deserializeFields=Ho,c.deserializeOnlyFields=Jo,c.deserializePassFailFieldValue=st,c.extractFilesAndPromisesFromFieldValues=qr,c.fieldDataMapping=_,c.fieldSpacingCva=xi,c.fieldTypeGroupDataMapping=yt,c.flattenFields=Wo,c.formatTime=mi,c.formatUTCOffset=gi,c.getCurrentUTCOffset=mt,c.getFieldsMapping=Xo,c.getUTCMinuteOfDay=oe,c.getUTCOffsetMinutes=Ct,c.initializeFieldValues=_r,c.insertFilesAndPromisesToFieldValues=Or,c.isFileAndPromiseArray=rt,c.isPassFailFieldStatus=Ri,c.isPassFailFieldValue=at,c.isSerializedPassFailFieldValue=ot,c.isStringArray=Ae,c.isTime=A,c.isTimeInRange=cn,c.isTimeRange=je,c.isUTCOffset=pi,c.maxFileSizeB=St,c.maxFileSizeKB=vt,c.maxFileSizeMB=qe,c.parseTime=Pe,c.passFailFieldStatusMapping=fe,c.passFailFieldStatuses=Ne,c.separateImagesFromFields=na,c.serializeConditions=Nr,c.serializeFieldValues=xr,c.serializePassFailFieldValue=lt,c.unchangedFieldValues=Lr,c.useConditionManager=Go,c.useFieldInput=D,c.useFieldInputs=ui,c.useFieldSectionInputs=tt,c.useImageViewer=ci,c.useObjectUrl=Ei,c.useScanner=Do,c.useScannerContext=ut,c.validateFieldValues=$n,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|