@overmap-ai/forms 1.1.5-fields-json-types.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/form/builder/components/CreateFieldDropdownMenu.d.ts +1 -1
- package/dist/form/builder/list/sectionSerialization.d.ts +1 -1
- package/dist/form/builder/utils.d.ts +3 -3
- package/dist/form/conditions/BaseCondition/BaseCondition.d.ts +12 -21
- package/dist/form/conditions/BaseCondition/typings.d.ts +11 -13
- package/dist/form/conditions/BaseFieldCondition/BaseFieldCondition.d.ts +12 -0
- package/dist/form/conditions/BaseFieldCondition/index.d.ts +2 -0
- package/dist/form/conditions/BaseFieldCondition/typings.d.ts +24 -0
- package/dist/form/conditions/BooleanFieldCondition/BooleanFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/BooleanFieldCondition/BooleanFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/BooleanFieldCondition/BooleanFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/BooleanFieldCondition/index.d.ts +3 -1
- package/dist/form/conditions/BooleanFieldCondition/mappings.d.ts +16 -0
- package/dist/form/conditions/BooleanFieldCondition/typings.d.ts +4 -5
- package/dist/form/conditions/CheckboxListFieldCondition/CheckboxListFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/CheckboxListFieldCondition/CheckboxListFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/CheckboxListFieldCondition/CheckboxListFieldEveryCondition.d.ts +10 -0
- package/dist/form/conditions/CheckboxListFieldCondition/CheckboxListFieldNoneCondition.d.ts +10 -0
- package/dist/form/conditions/CheckboxListFieldCondition/CheckboxListFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/CheckboxListFieldCondition/CheckboxListFieldSomeCondition.d.ts +10 -0
- package/dist/form/conditions/CheckboxListFieldCondition/index.d.ts +7 -2
- package/dist/form/conditions/CheckboxListFieldCondition/mappings.d.ts +37 -0
- package/dist/form/conditions/CheckboxListFieldCondition/typings.d.ts +7 -5
- package/dist/form/conditions/ConditionManager/ConditionManager.d.ts +1 -0
- package/dist/form/conditions/DateFieldCondition/DateFieldAfterCondition.d.ts +10 -0
- package/dist/form/conditions/DateFieldCondition/DateFieldBeforeCondition.d.ts +10 -0
- package/dist/form/conditions/DateFieldCondition/DateFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/DateFieldCondition/DateFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/DateFieldCondition/DateFieldInCondition.d.ts +11 -0
- package/dist/form/conditions/DateFieldCondition/DateFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/DateFieldCondition/DateFieldNotInCondition.d.ts +11 -0
- package/dist/form/conditions/DateFieldCondition/index.d.ts +8 -2
- package/dist/form/conditions/DateFieldCondition/mappings.d.ts +51 -0
- package/dist/form/conditions/DateFieldCondition/typings.d.ts +8 -6
- package/dist/form/conditions/FieldConditionCell.d.ts +6 -0
- package/dist/form/conditions/MultiSelectFieldCondition/MultiSelectFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/MultiSelectFieldCondition/MultiSelectFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/MultiSelectFieldCondition/MultiSelectFieldEveryCondition.d.ts +10 -0
- package/dist/form/conditions/MultiSelectFieldCondition/MultiSelectFieldNoneCondition.d.ts +10 -0
- package/dist/form/conditions/MultiSelectFieldCondition/MultiSelectFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/MultiSelectFieldCondition/MultiSelectFieldSomeCondition.d.ts +10 -0
- package/dist/form/conditions/MultiSelectFieldCondition/index.d.ts +7 -2
- package/dist/form/conditions/MultiSelectFieldCondition/mappings.d.ts +37 -0
- package/dist/form/conditions/MultiSelectFieldCondition/typings.d.ts +7 -5
- package/dist/form/conditions/MultiStringFieldCondition/MultiStringFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/MultiStringFieldCondition/MultiStringFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/MultiStringFieldCondition/MultiStringFieldEveryCondition.d.ts +10 -0
- package/dist/form/conditions/MultiStringFieldCondition/MultiStringFieldNoneCondition.d.ts +10 -0
- package/dist/form/conditions/MultiStringFieldCondition/MultiStringFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/MultiStringFieldCondition/MultiStringFieldSomeCondition.d.ts +10 -0
- package/dist/form/conditions/MultiStringFieldCondition/index.d.ts +7 -2
- package/dist/form/conditions/MultiStringFieldCondition/mappings.d.ts +37 -0
- package/dist/form/conditions/MultiStringFieldCondition/typings.d.ts +7 -5
- package/dist/form/conditions/NumberFieldCondition/NumberFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/NumberFieldCondition/NumberFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/NumberFieldCondition/NumberFieldGreaterThanCondition.d.ts +10 -0
- package/dist/form/conditions/NumberFieldCondition/NumberFieldGreaterThanOrEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/NumberFieldCondition/NumberFieldInRangeCondition.d.ts +10 -0
- package/dist/form/conditions/NumberFieldCondition/NumberFieldLessThanCondition.d.ts +10 -0
- package/dist/form/conditions/NumberFieldCondition/NumberFieldLessThanOrEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/NumberFieldCondition/NumberFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/NumberFieldCondition/NumberFieldNotInRangeCondition.d.ts +10 -0
- package/dist/form/conditions/NumberFieldCondition/index.d.ts +10 -2
- package/dist/form/conditions/NumberFieldCondition/mappings.d.ts +65 -0
- package/dist/form/conditions/NumberFieldCondition/typings.d.ts +10 -5
- package/dist/form/conditions/OTPFieldCondition/OTPFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/OTPFieldCondition/OTPFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/OTPFieldCondition/OTPFieldExcludesCondition.d.ts +10 -0
- package/dist/form/conditions/OTPFieldCondition/OTPFieldIncludesCondition.d.ts +10 -0
- package/dist/form/conditions/OTPFieldCondition/OTPFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/OTPFieldCondition/index.d.ts +6 -2
- package/dist/form/conditions/OTPFieldCondition/mappings.d.ts +30 -0
- package/dist/form/conditions/OTPFieldCondition/typings.d.ts +6 -5
- package/dist/form/conditions/PassFailFieldCondition/PassFailFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/PassFailFieldCondition/PassFailFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/PassFailFieldCondition/PassFailFieldExcludesCondition.d.ts +10 -0
- package/dist/form/conditions/PassFailFieldCondition/PassFailFieldIncludesCondition.d.ts +10 -0
- package/dist/form/conditions/PassFailFieldCondition/PassFailFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/PassFailFieldCondition/index.d.ts +6 -2
- package/dist/form/conditions/PassFailFieldCondition/mappings.d.ts +31 -0
- package/dist/form/conditions/PassFailFieldCondition/typings.d.ts +6 -5
- package/dist/form/conditions/RadioFieldCondition/RadioFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/RadioFieldCondition/RadioFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/RadioFieldCondition/RadioFieldExcludesCondition.d.ts +10 -0
- package/dist/form/conditions/RadioFieldCondition/RadioFieldIncludesCondition.d.ts +10 -0
- package/dist/form/conditions/RadioFieldCondition/RadioFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/RadioFieldCondition/index.d.ts +6 -2
- package/dist/form/conditions/RadioFieldCondition/mappings.d.ts +30 -0
- package/dist/form/conditions/RadioFieldCondition/typings.d.ts +6 -5
- package/dist/form/conditions/RatingFieldCondition/RatingFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/RatingFieldCondition/RatingFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/RatingFieldCondition/RatingFieldGreaterThanCondition.d.ts +10 -0
- package/dist/form/conditions/RatingFieldCondition/RatingFieldGreaterThanOrEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/RatingFieldCondition/RatingFieldInRangeCondition.d.ts +10 -0
- package/dist/form/conditions/RatingFieldCondition/RatingFieldLessThanCondition.d.ts +10 -0
- package/dist/form/conditions/RatingFieldCondition/RatingFieldLessThanOrEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/RatingFieldCondition/RatingFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/RatingFieldCondition/RatingFieldNotInRangeCondition.d.ts +10 -0
- package/dist/form/conditions/RatingFieldCondition/index.d.ts +10 -2
- package/dist/form/conditions/RatingFieldCondition/mappings.d.ts +65 -0
- package/dist/form/conditions/RatingFieldCondition/typings.d.ts +10 -5
- package/dist/form/conditions/ScanFieldCondition/ScanFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/ScanFieldCondition/ScanFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/ScanFieldCondition/ScanFieldExcludesCondition.d.ts +10 -0
- package/dist/form/conditions/ScanFieldCondition/ScanFieldIncludesCondition.d.ts +10 -0
- package/dist/form/conditions/ScanFieldCondition/ScanFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/ScanFieldCondition/index.d.ts +6 -2
- package/dist/form/conditions/ScanFieldCondition/mappings.d.ts +30 -0
- package/dist/form/conditions/ScanFieldCondition/typings.d.ts +6 -5
- package/dist/form/conditions/SelectFieldCondition/SelectFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/SelectFieldCondition/SelectFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/SelectFieldCondition/SelectFieldExcludesCondition.d.ts +10 -0
- package/dist/form/conditions/SelectFieldCondition/SelectFieldIncludesCondition.d.ts +10 -0
- package/dist/form/conditions/SelectFieldCondition/SelectFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/SelectFieldCondition/index.d.ts +6 -2
- package/dist/form/conditions/SelectFieldCondition/mappings.d.ts +30 -0
- package/dist/form/conditions/SelectFieldCondition/typings.d.ts +6 -5
- package/dist/form/conditions/StringFieldCondition/StringFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/StringFieldCondition/StringFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/StringFieldCondition/StringFieldExcludesCondition.d.ts +10 -0
- package/dist/form/conditions/StringFieldCondition/StringFieldIncludesCondition.d.ts +10 -0
- package/dist/form/conditions/StringFieldCondition/StringFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/StringFieldCondition/index.d.ts +6 -2
- package/dist/form/conditions/StringFieldCondition/mappings.d.ts +30 -0
- package/dist/form/conditions/StringFieldCondition/typings.d.ts +6 -5
- package/dist/form/conditions/TextFieldCondition/TextFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/TextFieldCondition/TextFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/TextFieldCondition/TextFieldExcludesCondition.d.ts +10 -0
- package/dist/form/conditions/TextFieldCondition/TextFieldIncludesCondition.d.ts +10 -0
- package/dist/form/conditions/TextFieldCondition/TextFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/TextFieldCondition/index.d.ts +6 -2
- package/dist/form/conditions/TextFieldCondition/mappings.d.ts +30 -0
- package/dist/form/conditions/TextFieldCondition/typings.d.ts +6 -6
- package/dist/form/conditions/TimeFieldCondition/TimeFieldAfterCondition.d.ts +10 -0
- package/dist/form/conditions/TimeFieldCondition/TimeFieldBeforeCondition.d.ts +10 -0
- package/dist/form/conditions/TimeFieldCondition/TimeFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/TimeFieldCondition/TimeFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/TimeFieldCondition/TimeFieldInCondition.d.ts +10 -0
- package/dist/form/conditions/TimeFieldCondition/TimeFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/TimeFieldCondition/TimeFieldNotInCondition.d.ts +10 -0
- package/dist/form/conditions/TimeFieldCondition/index.d.ts +8 -2
- package/dist/form/conditions/TimeFieldCondition/mappings.d.ts +51 -0
- package/dist/form/conditions/TimeFieldCondition/typings.d.ts +8 -5
- package/dist/form/conditions/URLFieldCondition/URLFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/URLFieldCondition/URLFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/URLFieldCondition/URLFieldExcludesCondition.d.ts +10 -0
- package/dist/form/conditions/URLFieldCondition/URLFieldIncludesCondition.d.ts +10 -0
- package/dist/form/conditions/URLFieldCondition/URLFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/URLFieldCondition/index.d.ts +6 -2
- package/dist/form/conditions/URLFieldCondition/mappings.d.ts +30 -0
- package/dist/form/conditions/URLFieldCondition/typings.d.ts +6 -5
- package/dist/form/conditions/UploadFieldCondition/UploadFieldConditionCell.d.ts +3 -3
- package/dist/form/conditions/UploadFieldCondition/UploadFieldEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/UploadFieldCondition/UploadFieldNotEqualsCondition.d.ts +10 -0
- package/dist/form/conditions/UploadFieldCondition/index.d.ts +4 -2
- package/dist/form/conditions/UploadFieldCondition/mappings.d.ts +16 -0
- package/dist/form/conditions/UploadFieldCondition/typings.d.ts +4 -5
- package/dist/form/conditions/components/ConditionModifierDropdown.d.ts +6 -5
- package/dist/form/conditions/components/RemoveConditionButton.d.ts +2 -3
- package/dist/form/conditions/components/index.d.ts +0 -1
- package/dist/form/conditions/hooks.d.ts +3 -0
- package/dist/form/conditions/index.d.ts +2 -0
- package/dist/form/conditions/mappings.d.ts +132 -0
- package/dist/form/conditions/typings.d.ts +26 -26
- package/dist/form/fields/BaseField/BaseField.d.ts +4 -4
- package/dist/form/fields/BaseField/typings.d.ts +6 -6
- package/dist/form/fields/BaseFormElement/BaseFormElement.d.ts +2 -2
- package/dist/form/fields/BaseFormElement/typings.d.ts +2 -2
- package/dist/form/fields/BooleanField/BooleanField.d.ts +1 -1
- package/dist/form/fields/CheckboxListField/CheckboxListField.d.ts +1 -1
- package/dist/form/fields/DateField/DateField.d.ts +1 -1
- package/dist/form/fields/FieldSection/FieldSection.d.ts +11 -10
- package/dist/form/fields/FieldSection/typings.d.ts +4 -4
- package/dist/form/fields/MultiSelectField/MultiSelectField.d.ts +1 -1
- package/dist/form/fields/MultiStringField/MultiStringField.d.ts +3 -3
- package/dist/form/fields/MultiStringField/typings.d.ts +4 -4
- package/dist/form/fields/NumberField/NumberField.d.ts +1 -1
- package/dist/form/fields/OTPField/OTPField.d.ts +4 -9
- package/dist/form/fields/OTPField/typings.d.ts +0 -3
- package/dist/form/fields/PassFailField/PassFailField.d.ts +1 -1
- package/dist/form/fields/RadioField/RadioField.d.ts +1 -1
- package/dist/form/fields/RatingField/RatingField.d.ts +1 -1
- package/dist/form/fields/ScanField/ScanField.d.ts +1 -1
- package/dist/form/fields/SelectField/SelectField.d.ts +1 -1
- package/dist/form/fields/StringField/StringField.d.ts +1 -1
- package/dist/form/fields/TextField/TextField.d.ts +1 -1
- package/dist/form/fields/TimeField/TimeField.d.ts +1 -1
- package/dist/form/fields/URLField/URLField.d.ts +1 -1
- package/dist/form/fields/UploadField/UploadField.d.ts +3 -3
- package/dist/form/fields/UploadField/typings.d.ts +4 -4
- package/dist/form/fields/components/InputWithLabel.d.ts +4 -4
- package/dist/form/fields/constants.d.ts +39 -4
- package/dist/form/fields/hooks.d.ts +1 -1
- package/dist/form/fields/utils.d.ts +1 -1
- package/dist/form/index.d.ts +0 -1
- package/dist/form/schema/FieldSchema.d.ts +1 -1
- package/dist/form/typings.d.ts +4 -4
- package/dist/forms.js +5736 -4908
- package/dist/forms.umd.cjs +1 -1
- package/package.json +3 -3
- package/dist/form/conditions/BooleanFieldCondition/BooleanFieldCondition.d.ts +0 -14
- package/dist/form/conditions/CheckboxListFieldCondition/CheckboxListFieldCondition.d.ts +0 -17
- package/dist/form/conditions/DateFieldCondition/DateFieldCondition.d.ts +0 -19
- package/dist/form/conditions/MultiSelectFieldCondition/MultiSelectFieldCondition.d.ts +0 -17
- package/dist/form/conditions/MultiStringFieldCondition/MultiStringFieldCondition.d.ts +0 -17
- package/dist/form/conditions/NumberFieldCondition/NumberFieldCondition.d.ts +0 -20
- package/dist/form/conditions/OTPFieldCondition/OTPFieldCondition.d.ts +0 -16
- package/dist/form/conditions/PassFailFieldCondition/PassFailFieldCondition.d.ts +0 -17
- package/dist/form/conditions/RadioFieldCondition/RadioFieldCondition.d.ts +0 -16
- package/dist/form/conditions/RatingFieldCondition/RatingFieldCondition.d.ts +0 -20
- package/dist/form/conditions/ScanFieldCondition/ScanFieldCondition.d.ts +0 -16
- package/dist/form/conditions/SelectFieldCondition/SelectFieldCondition.d.ts +0 -16
- package/dist/form/conditions/StringFieldCondition/StringFieldCondition.d.ts +0 -16
- package/dist/form/conditions/TextFieldCondition/TextFieldCondition.d.ts +0 -16
- package/dist/form/conditions/TimeFieldCondition/TimeFieldCondition.d.ts +0 -18
- package/dist/form/conditions/URLFieldCondition/URLFieldCondition.d.ts +0 -17
- package/dist/form/conditions/UploadFieldCondition/UploadFieldCondition.d.ts +0 -16
- package/dist/form/conditions/constants.d.ts +0 -36
- package/dist/form/modifiers/boolean.d.ts +0 -3
- package/dist/form/modifiers/conditionModifier.d.ts +0 -17
- package/dist/form/modifiers/date.d.ts +0 -9
- package/dist/form/modifiers/file.d.ts +0 -4
- package/dist/form/modifiers/index.d.ts +0 -9
- package/dist/form/modifiers/number.d.ts +0 -10
- package/dist/form/modifiers/passFailStatus.d.ts +0 -6
- package/dist/form/modifiers/string.d.ts +0 -12
- package/dist/form/modifiers/time.d.ts +0 -8
- package/dist/form/modifiers/typings.d.ts +0 -13
- package/dist/form/modifiers/utils.d.ts +0 -2
- /package/dist/form/{conditions/TimeFieldCondition/TimeFieldCondition.test.d.ts → fields/FieldSection/FieldSection.test.d.ts} +0 -0
package/dist/forms.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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("@adrekic/zod-fieldsjson"),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","@adrekic/zod-fieldsjson","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.zodFieldsjson,c.graphology,c.graphologyTraversal,c.get,c.set))})(this,(function(c,n,a,R,d,ma,_,Mn,Y,F,Ai,xn,In,ho,qn,On,po,mo,_n,go){"use strict";const Co=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Vo=i=>i.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase()),Tn=i=>{const e=Vo(i);return e.charAt(0).toUpperCase()+e.slice(1)},En=(...i)=>i.filter((e,t,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===t).join(" ").trim(),yo=i=>{for(const e in i)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var vo={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 zo=d.forwardRef(({color:i="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:r,className:o="",children:l,iconNode:s,...f},u)=>d.createElement("svg",{ref:u,...vo,width:e,height:e,stroke:i,strokeWidth:r?Number(t)*24/Number(e):t,className:En("lucide",o),...!l&&!yo(f)&&{"aria-hidden":"true"},...f},[...s.map(([h,p])=>d.createElement(h,p)),...Array.isArray(l)?l:[l]]));const b=(i,e)=>{const t=d.forwardRef(({className:r,...o},l)=>d.createElement(zo,{ref:l,iconNode:e,className:En(`lucide-${Co(Tn(i))}`,`lucide-${i}`,r),...o}));return t.displayName=Tn(i),t};const So=b("align-justify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);const wo=b("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=b("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 bo=b("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 H=b("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const ui=b("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $i=b("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 No=b("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const Mo=b("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);const xo=b("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 Io=b("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 Ln=b("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Bn=b("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 qo=b("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 An=b("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 Oo=b("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 Di=b("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 $n=b("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 Dn=b("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 _o=b("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 To=b("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 Eo=b("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 Lo=b("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 Pn=b("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 jn=b("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=b("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 Ao=b("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 $o=b("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 Do=b("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 Po=b("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 fi=b("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Un=b("move-down",[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);const kn=b("move-up",[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);const Z=b("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const jo=b("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 Uo=b("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 ko=b("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 Go=b("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 Jo=b("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 Gn=b("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 Ho=b("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 Wo=b("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 ve=b("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 Pi=b("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 Ko=b("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 oe=b("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),ji=d.memo(i=>{const{ref:e,file:t,className:r,error:o,rightSlot:l,size:s,...f}=i,u=()=>o?n.jsxs(n.Fragment,{children:[n.jsx(a.LuIcon,{icon:$i,color:"var(--base-a11)"}),n.jsx(a.Text,{accentColor:"base",className:"truncate",size:s,children:o})]}):t?n.jsxs(n.Fragment,{children:[n.jsx(a.LuIcon,{icon:To,color:"var(--base-a11)"}),n.jsx(a.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(a.Spinner,{size:s})})});return n.jsxs(a.Card,{className:R.cx(r,"flex w-full items-center gap-2"),ref:e,size:"xs",...f,children:[u(),l]})});ji.displayName="FileCard";function Pe(i){return Array.isArray(i)?i.every(e=>typeof e=="string"):!1}class je{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 ze extends je{identifier;constructor(e){const{identifier:t}=e;super(),this.identifier=t}getOptions(){return{identifier:this.identifier}}setOptions(e){"identifier"in e&&e.identifier!==void 0&&(this.identifier=e.identifier),this.notify(this)}serialize(){return{type:this.type,identifier:this.identifier}}config(){return{type:this.type,identifier:this.identifier}}static _deserializeConfig(e){const{identifier:t,type:r}=e;return{identifier:t,type:r}}static _serializeConfig(e){const{identifier:t,type:r}=e;return{identifier:t,type:r}}}class N extends ze{label;description;required;image;constructor(e){const{label:t,description:r=null,required:o,image:l,...s}=e;super(s),this.label=t,this.description=r,this.required=o,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}}config(){return{...super.config(),label:this.label,description:this.description,required:this.required,image:this.image}}static _deserializeConfig(e){const{label:t,description:r,required:o,...l}=e;return{...ze._deserializeConfig(l),label:t,description:r,required:o}}static _serializeConfig(e){const{label:t,description:r,required:o,...l}=e;return{...ze._serializeConfig(l),label:t,description:r,required:o}}getOptions(){return{...super.getOptions(),label:this.label,description:this.description,required:this.required,image:this.image}}setOptions(e){"label"in e&&e.label!==void 0&&(this.label=e.label),"description"in e&&(this.description=e.description??null),"required"in e&&e.required!==void 0&&(this.required=e.required),"image"in e&&(this.image=e.image),super.setOptions(e)}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({}),Ui=i=>{const[e,t]=d.useState(null);return d.useLayoutEffect(()=>{const r=URL.createObjectURL(i);return t(r),()=>{URL.revokeObjectURL(r)}},[i]),e},Oe=d.memo(i=>{const{file:e,...t}=i,r=Ui(e);return n.jsx("img",{src:r??void 0,alt:e.name,...t})});Oe.displayName="ImageFile";const Jn=d.createContext(()=>{throw new Error("No ImageViewerProvider found")}),hi=()=>d.useContext(Jn),ki=d.memo(i=>{const{file:e,onClose:t}=i,r=d.useCallback(()=>{xn.saveAs(e,e.name)},[e]);return n.jsx(a.Overlay.Root,{open:!0,onOpenChange:t,children:n.jsxs(a.Overlay.Content,{onOpenAutoFocus:a.preventDefault,children:[n.jsxs(a.ButtonGroup,{className:"absolute right-0 top-0 flex items-center gap-2 p-2",accentColor:"base",variant:"ghost",children:[n.jsxs(a.Tooltip.Root,{children:[n.jsx(a.Tooltip.Trigger,{asChild:!0,children:n.jsx(a.IconButton,{onClick:r,"aria-label":"download",children:n.jsx(a.LuIcon,{icon:$n})})}),n.jsx(a.Tooltip.Content,{size:"sm",children:"Download"})]}),n.jsx(a.Separator,{orientation:"vertical",size:"sm"}),n.jsx(a.Overlay.Close,{asChild:!0,children:n.jsx(a.IconButton,{onClick:t,"aria-label":"close",children:n.jsx(a.LuIcon,{icon:oe})})})]}),n.jsx("figure",{className:"flex size-full items-center justify-center overflow-hidden p-4",children:n.jsx(Oe,{className:"max-h-full max-w-full",file:e})})]})})});ki.displayName="ImageViewer";const Hn=d.memo(i=>{const{children:e}=i,[t,r]=d.useState(null),o=d.useCallback(()=>{r(null)},[]),l=d.useCallback(f=>{r(f(o))},[o]),s=d.useCallback(()=>{t&&(t.onClose&&t.onClose(),o())},[o,t]);return n.jsxs(Jn.Provider,{value:l,children:[e,t&&n.jsx(ki,{file:t.file,onClose:s})]})});Hn.displayName="FileViewerProvider";const B=d.memo(i=>{const{label:e,error:t,description:r,required:o,children:l,inputId:s,image:f,size:u}=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]),C=o?`${e} *`:e;return n.jsxs("div",{className:"flex flex-col gap-1",children:[h&&n.jsx(Oe,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:h,onClick:g}),(!!e||!!r)&&n.jsxs("div",{className:"flex flex-col",children:[n.jsx("label",{className:"w-max max-w-full",htmlFor:s,children:n.jsx(a.Text,{size:u,className:"text-wrap",children:C})}),!!r&&n.jsx(a.Text,{accentColor:"base",size:u,children:r})]}),l,!!t&&n.jsx(a.Text,{accentColor:"danger",size:u,children:t})]})});B.displayName="InputWithLabel";const Wn=i=>i.map(e=>n.jsx(d.Fragment,{children:e.render()},e.identifier)),pi=i=>i.map(e=>n.jsx(d.Fragment,{children:e.render()},e.identifier)),P=i=>{const{field:e}=i,{field:{value:t,name:r,onChange:o,onBlur:l,disabled:s},fieldState:{isTouched:f,error:u}}=Y.useController({name:e.identifier});return{value:t,name:r,disabled:s,isTouched:f,error:u?.message??"",onChange:o,onBlur:l}},Kn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),[h,p]=d.useState(""),[m,g]=d.useState(""),C=d.useCallback(y=>{s(y),l()},[s,l]),z=d.useCallback(y=>{r&&r.findIndex(I=>I===y.target.value.trim())>=0?g("All options must be unique"):y.target.value?g(""):g("Option cannot be empty"),p(y.target.value)},[p,r]),S=d.useCallback(()=>{if(m)return;if(!h.trim()){g("Option cannot be empty");return}const y=h.trim();C([...r,y]),p("")},[h,m,C,r]),w=d.useCallback(y=>{y.key==="Enter"&&(y.preventDefault(),S())},[S]),v=d.useCallback(y=>{const I=Array.from(r);I.splice(y,1),C(I)},[r,C]),x=d.useCallback(y=>{if(!y.destination)return;const I=y.source.index,E=y.destination.index,G=Array.from(r),[te]=G.splice(I,1);G.splice(E,0,te),C(G)},[C,r]),O=d.useCallback(()=>{l()},[l]);return n.jsx(Ai.DragDropContext,{onDragEnd:x,children:n.jsxs(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:m||f,image:e.image,children:[(!u||r.length===0)&&n.jsxs("div",{className:"flex gap-2",children:[n.jsx(a.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:t,children:n.jsx(a.Input.Field,{value:h,onChange:z,onKeyDown:w,id:e.identifier,placeholder:e.placeholder??"Press enter to add a new option",onBlur:O,name:o,disabled:u})}),n.jsx(a.IconButton,{size:t,accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!m||u,onClick:S,children:n.jsx(a.LuIcon,{icon:Z})})]}),r.length!==0&&n.jsx(Ai.Droppable,{droppableId:`${e.identifier}-droppable`,children:y=>n.jsxs("div",{className:"flex flex-col gap-1",...y.droppableProps,ref:y.innerRef,children:[r.map((I,E)=>n.jsx(Ai.Draggable,{draggableId:`${I}-draggable`,index:E,isDragDisabled:u,children:({draggableProps:G,dragHandleProps:te,innerRef:De})=>n.jsxs(a.Badge,{...te,...G,ref:De,className:"flex items-center justify-between gap-2",accentColor:"base",size:t,variant:"soft",children:[n.jsx(a.Text,{className:"truncate",highContrast:!0,children:Gi(I).label}),n.jsx(a.IconButton,{className:"bg-transparent!",size:t,variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:u,onClick:()=>{v(E)},children:n.jsx(a.LuIcon,{icon:oe})})]})},`${e.identifier}-${I}-${E}`)),y.placeholder]})})]})})});Kn.displayName="MultiStringFieldInput";class ae extends N{type="multi-string";minimumLength;maximumLength;placeholder;constructor(e){const{minimumLength:t,maximumLength:r,placeholder:o,...l}=e;super(l),this.minimumLength=t,this.maximumLength=r,this.placeholder=o}render(){return n.jsx(Kn,{field:this})}serialize(){return{...super.serialize(),minimum_length:this.minimumLength,maximum_length:this.maximumLength,placeholder:this.placeholder}}config(){return{...super.config(),minimumLength:this.minimumLength,maximumLength:this.maximumLength,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minimumLength:this.minimumLength,maximumLength:this.maximumLength,placeholder:this.placeholder}}duplicate(e){return new ae({...this.getOptions(),identifier:e})}setOptions(e){"minimumLength"in e&&(this.minimumLength=e.minimumLength),"maximumLength"in e&&(this.maximumLength=e.maximumLength),"placeholder"in e&&(this.placeholder=e.placeholder),super.setOptions(e)}serializeValue(e){return e}deserializeValue(e){return e}getFieldValidators(){const e=super.getFieldValidators();return e.push(t=>{if(this.minimumLength!==void 0&&t.length<this.minimumLength)return`Must have at least ${this.minimumLength} options.`}),e.push(t=>{if(this.maximumLength!==void 0&&t.length>this.maximumLength)return`Must have at most ${this.maximumLength} options.`}),e}static deserialize(e){return new ae(e)}static fromConfig(e){return new ae(e)}static deserializeConfig(e){const{minimum_length:t,maximum_length:r,placeholder:o,...l}=e;return{...N._deserializeConfig(l),minimumLength:t,maximumLength:r,placeholder:o}}static serializeConfig(e){const{minimumLength:t,maximumLength:r,placeholder:o,...l}=e;return{...N._serializeConfig(l),minimum_length:t,maximum_length:r,placeholder:o}}isSerializedValue(e){return Pe(e)}isValue(e){return Pe(e)}blankValue(){return[]}areValuesEqual(e,t){const r=new Set(e),o=new Set(t);return r.size===o.size&&r.isSubsetOf(o)}blankSerializedValue(){return[]}areSerializedValuesEqual(e,t){const r=new Set(e),o=new Set(t);return r.size===o.size&&r.isSubsetOf(o)}}function Gi(i){return typeof i=="string"&&(i={label:i,value:i}),i}function _e(i){return i.map(Gi)}class Q extends N{options;constructor(e){const{options:t,...r}=e;super(r),this.options=_e(t)}serialize(){return{...super.serialize(),options:this.options}}config(){return{...super.config(),options:this.options}}static _deserializeConfig(e){const{options:t,...r}=e;return{...N._deserializeConfig(r),options:t}}static _serializeConfig(e){const{options:t,...r}=e;return{...N._serializeConfig(r),options:_e(t)}}getOptions(){return{...super.getOptions(),options:this.options}}setOptions(e){"options"in e&&e.options!==void 0&&(this.options=_e(e.options)),super.setOptions(e)}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new ae({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${t}options`,minimumLength:2}),showDirectly:!0}]}}const Ji=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),h=d.useCallback(m=>{s(!!m),l()},[l,s]),p=d.useCallback(()=>{l()},[l]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,error:f,image:e.image,required:e.required,children:n.jsx(a.Checkbox.Root,{id:e.identifier,name:o,checked:r??!1,onCheckedChange:h,onBlur:p,size:t,accentColor:"base",variant:"surface",disabled:u,children:n.jsx(a.Checkbox.Indicator,{children:n.jsx(a.LuIcon,{icon:H})})})})});Ji.displayName="BooleanFieldInput";class le extends N{type="boolean";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}setOptions(e){super.setOptions(e)}duplicate(e){return new le({...this.getOptions(),identifier:e})}static deserialize(e){return new le(e)}static fromConfig(e){return new le(e)}static deserializeConfig(e){return N._deserializeConfig(e)}static serializeConfig(e){return N._serializeConfig(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Ji,{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 Xn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),h=d.useCallback(g=>{const C=g.target.valueAsNumber,z=isNaN(C)?null:C;s(z)},[s]),p=d.useCallback(()=>{l()},[l]),m=d.useCallback(g=>{g.key==="Enter"&&g.preventDefault()},[]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:n.jsx(a.Input.Root,{accentColor:"base",variant:"surface",size:t,children:n.jsx(a.Input.Field,{id:e.identifier,name:o,onChange:h,onBlur:p,value:r??"",type:"number",min:e.minimum??Number.MIN_SAFE_INTEGER,max:e.maximum??Number.MAX_SAFE_INTEGER,step:e.integers?1:"any",placeholder:e.placeholder??"Enter a number",disabled:u,onKeyDown:m})})})});Xn.displayName="NumberFieldInput";class J extends N{type="number";minimum;maximum;integers;placeholder;constructor(e){const{minimum:t,maximum:r,integers:o,placeholder:l,...s}=e;super(s),this.minimum=t,this.maximum=r,this.integers=o,this.placeholder=l}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new J({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${t}minimum`}),showDirectly:!1},{field:new J({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${t}maximum`}),showDirectly:!1},{field:new le({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(o=>{if(typeof o=="number"&&o<t)return`Must be at least ${this.minimum}.`}),e.push(o=>{if(typeof o=="number"&&o<Number.MIN_SAFE_INTEGER)return"Cant be less than MIN_SAFE_INTEGER."}),typeof r=="number"&&e.push(o=>{if(typeof o=="number"&&o>r)return`Must be at most ${r}.`}),e.push(o=>{if(typeof o=="number"&&o>Number.MAX_SAFE_INTEGER)return"Cant be greater than MAX_SAFE_INTEGER."}),this.integers&&e.push(o=>{if(typeof o=="number"&&!Number.isInteger(o))return"Must be a whole number."}),e}serialize(){return{...super.serialize(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}config(){return{...super.config(),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 J({...this.getOptions(),identifier:e})}setOptions(e){"minimum"in e&&(this.minimum=e.minimum),"maximum"in e&&(this.maximum=e.maximum),"integers"in e&&(this.integers=e.integers),"placeholder"in e&&(this.placeholder=e.placeholder),super.setOptions(e)}static deserialize(e){return new J(e)}static fromConfig(e){return new J(e)}static deserializeConfig(e){const{minimum:t,maximum:r,integers:o,placeholder:l,...s}=e;return{...N._deserializeConfig(s),minimum:t,maximum:r,integers:o,placeholder:l}}static serializeConfig(e){const{minimum:t,maximum:r,integers:o=!1,placeholder:l,...s}=e;return{...N._serializeConfig(s),minimum:t,maximum:r,integers:o,placeholder:l}}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Xn,{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}}class Se extends N{minLength;maxLength;placeholder;constructor(e){const{minLength:t,maxLength:r,placeholder:o,...l}=e;super(l),this.minLength=t,this.maxLength=r,this.placeholder=o}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new J({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${t}minimum_length`,minimum:0,integers:!0}),showDirectly:!1},{field:new J({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${t}maximum_length`,minimum:1,integers:!0}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),t=this.minLength,r=this.maxLength;return typeof t=="number"&&e.push(o=>{if(o.length<t)return`Minimum ${t} character(s).`}),typeof r=="number"&&e.push(o=>{if(o.length>r)return`Maximum ${r} character(s).`}),e}serialize(){return{...super.serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}config(){return{...super.config(),minLength:this.minLength,maxLength:this.maxLength,placeholder:this.placeholder}}static _deserializeConfig(e){const{maximum_length:t,minimum_length:r,placeholder:o,...l}=e;return{...N._deserializeConfig(l),minLength:r,maxLength:t,placeholder:o}}static _serializeConfig(e){const{minLength:t,maxLength:r,placeholder:o,...l}=e;return{...N._serializeConfig(l),minimum_length:t,maximum_length:r,placeholder:o}}getOptions(){return{...super.getOptions(),minLength:this.minLength,maxLength:this.maxLength,placeholder:this.placeholder}}setOptions(e){"minLength"in e&&(this.minLength=e.minLength),"maxLength"in e&&(this.maxLength=e.maxLength),"placeholder"in e&&(this.placeholder=e.placeholder),super.setOptions(e)}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 Yn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),h=d.useCallback(m=>{s(m),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:f,image:e.image,children:n.jsx(a.CheckboxGroup.Root,{id:e.identifier,name:o,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,values:r,onValuesChange:h,disabled:u,children:e.options.map((m,g)=>n.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(a.CheckboxGroup.Item,{value:m.value,onBlur:p,children:n.jsx(a.CheckboxGroup.ItemIndicator,{children:n.jsx(a.LuIcon,{icon:H})})}),n.jsx(a.Text,{size:t,accentColor:"base",className:"truncate",children:m.label})]},`${e.identifier}-${m.value}-${g}`))})})});Yn.displayName="CheckboxListFieldInput";class ee extends Q{type="checkbox-list";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new ee({...this.getOptions(),identifier:e})}static deserialize(e){return new ee(e)}static fromConfig(e){return new ee(e)}static deserializeConfig(e){return ee._deserializeConfig(e)}static serializeConfig(e){return ee._serializeConfig(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Yn,{field:this})}isSerializedValue(e){if(!Pe(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),o=new Set(t);return r.size===o.size&&r.isSubsetOf(o)}areValuesEqual(e,t){const r=new Set(e),o=new Set(t);return r.size===o.size&&r.isSubsetOf(o)}}const Hi=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),[h,p]=d.useState(!1),m=d.useCallback(C=>{s(C??null),l(),p(!1)},[s,l]),g=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:f,image:e.image,children:n.jsxs(a.Popover.Root,{open:h,onOpenChange:g,children:[n.jsx(a.Popover.Trigger,{asChild:!0,children:n.jsxs(a.Button,{id:e.identifier,name:o,type:"button",className:"!justify-between",accentColor:"base",variant:"surface",size:t,disabled:u,children:[n.jsx(a.Text,{className:"truncate",highContrast:!!r,children:r?r.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd"}),n.jsx(a.LuIcon,{icon:ui})]})}),n.jsx(a.Popover.Content,{align:"start",size:t,children:n.jsx(a.DayPicker,{size:t,required:!1,mode:"single",variant:"solid",selected:r??void 0,onSelect:m})})]})})});Hi.displayName="DateFieldInput";class we extends N{type="date";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new we({...this.getOptions(),identifier:e})}static deserialize(e){return new we(e)}static fromConfig(e){return new we(e)}static deserializeConfig(e){return N._deserializeConfig(e)}static serializeConfig(e){return N._serializeConfig(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(Hi,{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 Zn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),h=d.useCallback(m=>{s(m),l()},[l,s]),p=d.useCallback(m=>{m||l()},[l]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:n.jsxs(a.Menu.Root,{onOpenChange:p,align:"start",children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsxs(a.Button,{id:e.identifier,name:o,className:"!justify-between",variant:"surface",type:"button",size:t,accentColor:"base",disabled:u,children:[n.jsx(a.Text,{className:"truncate",highContrast:r&&r.length>0,children:r&&r.length>0?r.join(", "):e.placeholder??"Select one or more..."}),n.jsx(a.LuIcon,{icon:ui})]})}),n.jsx(a.Menu.Content,{size:t,children:n.jsx(a.Menu.Scroll,{children:n.jsxs(a.Menu.MultiSelectGroup,{values:r,onValuesChange:h,children:[n.jsxs(a.Menu.SelectAllItem,{children:[n.jsx(a.Menu.CheckboxItemIndicator,{children:m=>m?n.jsx(a.LuIcon,{icon:fi}):n.jsx(a.LuIcon,{icon:H})}),"Select all"]}),e.options.map((m,g)=>n.jsxs(a.Menu.MultiSelectItem,{value:m.value,children:[n.jsx(a.Menu.SelectedIndicator,{children:n.jsx(a.LuIcon,{icon:H})}),m.label]},`${e.identifier}-${m.value}-${g}`))]})})})]})})});Zn.displayName="MultiSelectFieldInput";class ie extends Q{type="multi-select";placeholder;constructor(e){const{placeholder:t,...r}=e;super(r),this.placeholder=t}serialize(){return{...super.serialize(),placeholder:this.placeholder}}config(){return{...super.config(),placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new ie({...this.getOptions(),identifier:e})}setOptions(e){"placeholder"in e&&(this.placeholder=e.placeholder),super.setOptions(e)}static deserialize(e){return new ie(e)}static fromConfig(e){return new ie(e)}static deserializeConfig(e){const{placeholder:t,...r}=e;return{...Q._deserializeConfig(r),placeholder:t}}static serializeConfig(e){const{placeholder:t,...r}=e;return{...Q._serializeConfig(r),placeholder:t}}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Zn,{field:this})}isSerializedValue(e){if(!Pe(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),o=new Set(t);return r.size===o.size&&r.isSubsetOf(o)}blankSerializedValue(){return[]}areSerializedValuesEqual(e,t){const r=new Set(e),o=new Set(t);return r.size===o.size&&r.isSubsetOf(o)}}const Qn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),h=d.useCallback(g=>{s(g??null),l()},[l,s]),p=d.useCallback(g=>{g||l()},[l]),m=d.useMemo(()=>e.options.find(g=>g.value===r),[e.options,r]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:n.jsxs(a.Menu.Root,{onOpenChange:p,align:"start",children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsxs(a.Button,{id:e.identifier,name:o,className:"!justify-between",accentColor:"base",variant:"surface",type:"button",size:t,disabled:u,children:[n.jsx(a.Text,{className:"truncate",highContrast:!!m,children:m?m.label:e.placeholder??"Select one..."}),n.jsx(a.LuIcon,{icon:ui})]})}),n.jsx(a.Menu.Content,{size:t,children:n.jsx(a.Menu.Scroll,{children:n.jsx(a.Menu.SelectGroup,{required:!1,value:r??void 0,onValueChange:h,children:e.options.map((g,C)=>n.jsxs(a.Menu.SelectItem,{value:g.value,children:[n.jsx(a.Menu.SelectedIndicator,{children:n.jsx(a.LuIcon,{icon:H})}),g.label]},`${e.identifier}-${g.value}-${C}`))})})})]})})});Qn.displayName="SelectFieldInput";class re extends Q{type="select";placeholder;constructor(e){const{placeholder:t,...r}=e;super(r),this.placeholder=t}serialize(){return{...super.serialize(),placeholder:this.placeholder}}config(){return{...super.config(),placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new re({...this.getOptions(),identifier:e})}setOptions(e){"placeholder"in e&&(this.placeholder=e.placeholder),super.setOptions(e)}static deserialize(e){return new re(e)}static fromConfig(e){return new re(e)}static deserializeConfig(e){const{placeholder:t,...r}=e;return{...Q._deserializeConfig(r),placeholder:t}}static serializeConfig(e){const{placeholder:t,...r}=e;return{...Q._serializeConfig(r),placeholder:t}}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Qn,{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 Rn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),h=d.useCallback(g=>{s(g)},[s]),p=d.useCallback(()=>{l()},[l]),m=d.useMemo(()=>Array.from({length:e.length},()=>F.v4()),[e.length]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:n.jsxs(a.OneTimePasswordField.Root,{id:e.identifier,name:o,value:r,onValueChange:h,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:[m.map(g=>n.jsx(a.OneTimePasswordField.Input,{id:g},g)),n.jsx(a.OneTimePasswordField.HiddenInput,{})]})})});Rn.displayName="OTPFieldInput";class se extends N{type="otp";length;validationType;constructor(e){const{length:t,validationType:r,...o}=e;super(o),this.length=t,this.validationType=r}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new J({label:"Length",integers:!0,required:!1,minimum:1,maximum:16,identifier:`${t}length`}),showDirectly:!1},{field:new re({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}}config(){return{...super.config(),length:this.length,validationType:this.validationType}}getOptions(){return{...super.getOptions(),length:this.length,validationType:this.validationType}}duplicate(e){return new se({...this.getOptions(),identifier:e})}setOptions(e){"length"in e&&e.length!==void 0&&(this.length=e.length),"validationType"in e&&e.validationType!==void 0&&(this.validationType=e.validationType),super.setOptions(e)}static deserialize(e){return new se(e)}static fromConfig(e){return new se(e)}static deserializeConfig(e){const{length:t,validationType:r,...o}=e;return{...N._deserializeConfig(o),length:t,validationType:r}}static serializeConfig(e){const{length:t,validationType:r,...o}=e;return{...N._serializeConfig(o),length:t,validationType:r}}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 Fe={pass:{label:"Pass",icon:No},fail:{label:"Fail",icon:Io},na:{label:"N/A",icon:xo}},Te=Object.keys(Fe);class de extends File{uuid;constructor(e,...t){super(...t),this.uuid=e}static from(e,t){return new de(e,[t],t.name,{lastModified:t.lastModified,type:t.type})}}class be 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 be((r,o)=>{Promise.resolve(e).then(r).catch(o)},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 et(i){return Array.isArray(i)?i.every(e=>e instanceof be||e instanceof de):!1}function mi(i,e){const t=new Set(i.map(({uuid:o})=>o)),r=new Set(e.map(({uuid:o})=>o));return t.size===r.size&&t.isSubsetOf(r)}const Wi=d.memo(i=>{const{ref:e,file:t,error:r,rightSlot:o,className:l,size:s,...f}=i;return n.jsxs(a.Card,{className:R.cx(l,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:e,size:"xs",...f,children:[!t&&!r&&n.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:n.jsx(a.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(Oe,{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(a.Separator,{size:"full"}),n.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[r?n.jsx(a.LuIcon,{color:"var(--base-11)",icon:$i}):t&&n.jsx(a.LuIcon,{color:"var(--base-11)",icon:Pn}),n.jsx(a.Text,{className:"truncate",size:s,children:r??t?.name}),o]})]})]})});Wi.displayName="ImageCard";const Ki=d.memo(i=>{const{file:e,...t}=i,r=Ui(e);return n.jsx("video",{src:r??void 0,...t})});Ki.displayName="VideoFile";const Xi=d.memo(i=>{const{ref:e,file:t,className:r,error:o,rightSlot:l,size:s,...f}=i;return n.jsxs(a.Card,{className:R.cx(r,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:e,size:"xs",...f,children:[!t&&!o&&n.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:n.jsx(a.Spinner,{size:s})}),!!t&&!o&&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})}),!!o&&n.jsx("div",{className:"grow"}),(!!t||!!o)&&n.jsxs(n.Fragment,{children:[n.jsx(a.Separator,{size:"full"}),n.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[o?n.jsx(a.LuIcon,{color:"var(--danger-11)",icon:$i}):t&&n.jsx(a.LuIcon,{color:"var(--base-11)",icon:Ko}),n.jsx(a.Text,{className:"truncate",size:s,children:o??t?.name}),l]})]})]})});Xi.displayName="VideoCard";const Yi=d.memo(i=>{const{fileOrPromise:e,onRemove:t,disabled:r,size:o}=i,[l,s]=d.useState(e instanceof be?null:e),[f,u]=d.useState(null),h=hi();In.useActiveEffect(v=>{if(u(null),!(e instanceof be)){s(e);return}s(null),e.then(x=>{v()&&s(x)}).catch(x=>{v()&&u(x instanceof Error?x.message:"Unknown error")})},[e]);const p=d.useCallback(()=>{if(!l)return;const v=new Blob([l]);xn.saveAs(v,l.name)},[l]),m=d.useCallback(()=>{t(e)},[t,e]),g=d.useCallback(()=>{if(!l)return;const v=URL.createObjectURL(l);window.open(v,"_blank"),URL.revokeObjectURL(v)},[l]),C=d.useCallback(()=>{l&&h(v=>({file:l,onDelete:r?void 0:()=>{m(),v()}}))},[r,m,h,l]),z=d.useMemo(()=>n.jsx("div",{className:"flex grow justify-end",children:n.jsxs(a.Menu.Root,{modal:!0,children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsx(a.IconButton,{onClick:a.stopPropagation,type:"button",variant:"ghost",accentColor:"base",size:o,children:n.jsx(a.LuIcon,{icon:Dn})})}),n.jsxs(a.Menu.Content,{size:o,children:[n.jsxs(a.Menu.Item,{onSelect:p,disabled:!l,children:[n.jsx(a.LuIcon,{icon:$n})," Download"]}),r?null:n.jsxs(n.Fragment,{children:[n.jsx(a.Menu.Separator,{}),n.jsxs(a.Menu.Item,{onSelect:m,children:[n.jsx(a.LuIcon,{icon:ve})," Delete"]})]})]})]})}),[r,m,p,l,o]),S=!!l?.type.startsWith("image/"),w=!!l?.type.startsWith("video/");return S?n.jsx(Wi,{className:"cursor-pointer",onClick:C,file:l,error:f??void 0,rightSlot:z,size:o}):w?n.jsx(Xi,{className:"cursor-pointer",onClick:C,file:l,error:f??void 0,rightSlot:z,size:o}):n.jsx(ji,{className:"cursor-pointer",file:l,error:f??void 0,onClick:g,rightSlot:z,size:o})});Yi.displayName="DisplayFile";const it=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),h=d.useRef(null),p=d.useCallback(y=>{const I=e.cleanValue({...r,status:y});s(I),l()},[e,l,s,r]),m=d.useCallback(y=>{const I=y.target.value,E={...r,notes:I};s(E)},[r,s]),g=d.useCallback(()=>{l()},[l]),C=d.useCallback(y=>{const I=r.files.filter(({uuid:E})=>E!==y.uuid);s({...r,files:I}),l()},[s,l,r]),z=d.useCallback(()=>{h.current?.click()},[]),S=d.useCallback(y=>{const I=Array.from(y.target.files??[]).map(G=>de.from(F.v4(),G)),E={...r,files:[...r.files,...I]};s(E),l()},[l,s,r]);d.useEffect(()=>{if(!h.current)return;const y=new AbortController;return h.current.addEventListener("cancel",()=>{l()},{signal:y.signal}),()=>{y.abort()}},[l,r]);const w=r.status&&e.showNotesAndFilesOn.includes(r.status),v=`${e.identifier}-status`,x=`${e.identifier}-notes`,O=`${e.identifier}-files`;return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(a.RadioGroup.Root,{id:v,className:"flex gap-2",name:o,value:r.status,disabled:u,accentColor:"base",variant:"surface",size:t,onValueChange:p,children:Te.map(y=>{const{label:I}=Fe[y];return n.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(a.RadioGroup.Item,{value:y,children:n.jsx(a.RadioGroup.Indicator,{children:n.jsx(a.LuIcon,{icon:Ln,className:"fill-current"})})}),n.jsx(a.Text,{size:t,accentColor:"base",className:"truncate",children:I})]},`${e.identifier}-${y}`)})}),w&&n.jsxs(n.Fragment,{children:[n.jsx("div",{children:n.jsx(a.TextArea,{id:x,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:t,disabled:u})}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs(a.Button,{className:"w-max",size:t,variant:"surface",accentColor:"base",onClick:z,type:"button",disabled:u,children:[n.jsx(a.LuIcon,{icon:Pi}),"Select files"]}),n.jsx("input",{id:O,name:o,type:"file",ref:h,multiple:!0,className:"hidden",onChange:S,value:""}),r.files.length>0&&n.jsx("div",{className:"flex h-max flex-wrap gap-2",children:r.files.map(y=>n.jsx(Yi,{size:t,fileOrPromise:y,onRemove:C,disabled:u},y.uuid))})]})]})]})})});it.displayName="PassFailFieldInput";const Zi=i=>typeof i=="string"&&Te.includes(i),nt=i=>!(i===null||typeof i!="object"||!("status"in i)||!Zi(i.status)||!("notes"in i)||typeof i.notes!="string"||!("files"in i)||!(Array.isArray(i.files)&&i.files.length===0)),tt=i=>!(i===null||typeof i!="object"||!("status"in i)||!Zi(i.status)||!("notes"in i)||typeof i.notes!="string"||!("files"in i)||!et(i.files)),rt=i=>({status:i.status,notes:i.notes,files:[]}),ot=i=>({status:i.status,notes:i.notes,files:[]}),at=(i,e)=>!(i.status!==e.status||i.notes!==e.notes||!mi(i.files,e.files)),lt=(i,e)=>!(i.status!==e.status||i.notes!==e.notes||i.files.length!==e.files.length);class ce extends N{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:Te.map(r=>{const{label:o}=Fe[r];return{value:r,label:o}}),required:!1}),showDirectly:!1}]}serialize(){return{...super.serialize(),showNotesAndFilesOn:this.showNotesAndFilesOn}}config(){return{...super.config(),showNotesAndFilesOn:this.showNotesAndFilesOn}}getOptions(){return{...super.getOptions(),showNotesAndFilesOn:this.showNotesAndFilesOn}}duplicate(e){return new ce({...this.getOptions(),identifier:e})}setOptions(e){"showNotesAndFilesOn"in e&&e.showNotesAndFilesOn!==void 0&&(this.showNotesAndFilesOn=e.showNotesAndFilesOn),super.setOptions(e)}getFieldValidators(){const e=super.getFieldValidators(),t=this.showNotesAndFilesOn,r=this.blankValue();return t.length>0&&(e.push(o=>{if(!(!o.status||!t.includes(o.status))&&r.notes===o.notes)return"Notes is required."}),e.push(o=>{if(!(!o.status||!t.includes(o.status))&&mi(r.files,o.files))return"Files is required."})),e}static deserialize(e){const{showNotesAndFilesOn:t,...r}=e;return new ce({...r,showNotesAndFilesOn:t})}static fromConfig(e){return new ce(e)}static deserializeConfig(e){const{showNotesAndFilesOn:t,...r}=e;return{...N._deserializeConfig(r),showNotesAndFilesOn:t}}static serializeConfig(e){const{showNotesAndFilesOn:t,...r}=e;return{...N._serializeConfig(r),showNotesAndFilesOn:t}}serializeValue(e){return rt(e)}deserializeValue(e){return ot(e)}render(){return n.jsx(it,{field:this})}isSerializedValue(e){return nt(e)}isValue(e){return tt(e)}areValuesEqual(e,t){return at(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 lt(e,t)}}const st=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),h=d.useCallback(g=>{s(g),l()},[l,s]),p=d.useCallback(()=>{l()},[l]),m=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:f,image:e.image,children:n.jsxs(a.RadioGroup.Root,{id:e.identifier,name:o,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,value:r??"",onValueChange:h,disabled:u,children:[e.options.map((g,C)=>n.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(a.RadioGroup.Item,{value:g.value,onBlur:p,children:n.jsx(a.RadioGroup.Indicator,{children:n.jsx(a.LuIcon,{icon:Ln,className:"fill-current"})})}),n.jsx(a.Text,{size:t,accentColor:"base",className:"truncate",children:g.label})]},`${e.identifier}-${g.value}-${C}`)),!!r&&n.jsxs(a.Button,{onClick:m,className:"-mx-2 w-max",type:"button",variant:"ghost",accentColor:"base",size:t,children:[n.jsx(a.LuIcon,{icon:oe}),"Clear"]})]})})});st.displayName="RadioFieldInput";class ue extends Q{type="radio";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new ue({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){return new ue(e)}static fromConfig(e){return new ue(e)}static deserializeConfig(e){return Q._deserializeConfig(e)}static serializeConfig(e){return Q._serializeConfig(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(st,{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 Xo=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"]}}}),dt=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),h=d.useCallback(g=>{s(g),l()},[l,s]),p=d.useCallback(()=>{s(null),l()},[l,s]),m=Array.from({length:e.maxRating},(g,C)=>C+1);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:n.jsxs("div",{className:"flex flex-row items-center gap-1",children:[n.jsx(a.Rating.Root,{id:e.identifier,name:o,className:"flex items-center gap-0.5",value:r,onValueChange:h,disabled:u,children:m.map(g=>n.jsx(a.Rating.Item,{value:g,className:Xo({size:t}),children:n.jsx(a.LuIcon,{icon:Gn,className:"size-full group-data-[active=true]:fill-current"})},`${e.identifier}-${g}`))}),!u&&r!==null&&n.jsx(a.IconButton,{onClick:p,type:"button",variant:"ghost",accentColor:"base",size:t,children:n.jsx(a.LuIcon,{icon:oe})})]})})});dt.displayName="RatingFieldInput";class fe extends N{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 J({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}}config(){return{...super.config(),maxRating:this.maxRating}}getOptions(){return{...super.getOptions(),maxRating:this.maxRating}}duplicate(e){return new fe({...this.getOptions(),identifier:e})}setOptions(e){"maxRating"in e&&e.maxRating!==void 0&&(this.maxRating=e.maxRating),super.setOptions(e)}static deserialize(e){return new fe(e)}static fromConfig(e){return new fe(e)}static deserializeConfig(e){const{maxRating:t,...r}=e;return{...N._deserializeConfig(r),maxRating:t}}static serializeConfig(e){const{maxRating:t,...r}=e;return{...N._serializeConfig(r),maxRating:t}}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(dt,{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 Qi=d.createContext(null),ct=()=>{const i=d.use(Qi);if(!i)throw new Error("useScannerContext must be used within a component tree wrapped by ScannerProvider.");return i},Yo=()=>{const i=d.use(Qi);if(!i)throw new Error("useScanner must be used within a component tree wrapped by ScannerProvider.");return i.openScanner},gi=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:o,modal:l,...s}=i;return n.jsxs(a.Overlay.Root,{open:t,onOpenChange:r,defaultOpen:o,modal:l,children:[!!e&&n.jsx(a.Overlay.Trigger,{asChild:!0,children:e}),n.jsxs(a.Overlay.Content,{children:[n.jsx(a.Overlay.Title,{className:"sr-only",children:"Scanner"}),n.jsx(a.Overlay.Description,{className:"sr-only",children:"Scan a barcode or a qr code."}),n.jsx(ut,{...s})]})]})});gi.displayName="Scanner";const ut=d.memo(i=>{const{paused:e,formats:t,timeBetweenDecodingAttempts:r,trySkew:o,onDecodeResult:l,onDecodeError:s,onError:f}=i,{wasmUrl:u}=ct(),{ref:h}=ho.useZxing({wasmUrl:u,paused:e,formats:t,timeBetweenDecodingAttempts:r,trySkew:o,onDecodeResult:l,onDecodeError:s,onError:f,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(a.Overlay.Close,{asChild:!0,children:n.jsx(a.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",children:n.jsx(a.LuIcon,{icon:oe})})})}),n.jsx("div",{className:"max-h-full w-full grow overflow-hidden p-4",children:n.jsx("video",{className:"size-full",ref:h,muted:!0,playsInline:!0})})]})});ut.displayName="ScannerInternal";const ft=d.memo(i=>{const{children:e,wasmUrl:t}=i,[r,o]=d.useState(null),l=d.useCallback(()=>{o(null)},[]),s=d.useCallback(h=>{o(h(l))},[l]),f=d.useCallback(()=>{r&&(r.onClose&&r.onClose(),l())},[l,r]),u=d.useMemo(()=>({wasmUrl:t,openScanner:s}),[t,s]);return n.jsxs(Qi,{value:u,children:[e,r&&n.jsx(gi,{open:!0,onOpenChange:f,...r})]})});ft.displayName="ScannerProvider";const ht=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),[h,p]=d.useState(!1),m=d.useCallback(w=>{const v=w.target.value;s(v)},[s]),g=d.useCallback(()=>{l()},[l]),C=d.useCallback(w=>{s(w.rawValue.trim()),l(),p(!1)},[s,l]),z=d.useCallback(()=>{p(!0)},[]),S=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:f,image:e.image,children:[n.jsx(a.TextArea,{className:"field-sizing-content w-full",accentColor:"base",variant:"surface",size:t,id:e.identifier,name:o,value:r??"",placeholder:"Enter a qr or barcode",onChange:m,onBlur:g,disabled:u}),n.jsxs(a.Button,{onClick:z,className:"w-max",type:"button",variant:"soft",size:t,accentColor:"base",disabled:u,children:[n.jsx(a.LuIcon,{icon:Po}),"Scan"]}),n.jsx(gi,{open:h,onDecodeResult:C,onOpenChange:S})]})});ht.displayName="ScanFieldInput";class Ne extends N{type="qr";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new Ne({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){return new Ne(e)}static fromConfig(e){return new Ne(e)}static deserializeConfig(e){return N._deserializeConfig(e)}static serializeConfig(e){return N._serializeConfig(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(ht,{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 pt=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),h=d.useCallback(g=>{const C=g.target.value;s(C)},[s]),p=d.useCallback(()=>{l()},[l]),m=d.useCallback(g=>{g.key==="Enter"&&g.preventDefault()},[]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:n.jsx(a.Input.Root,{accentColor:"base",variant:"surface",size:t,children:n.jsx(a.Input.Field,{id:e.identifier,className:"truncate",name:o,value:r??"",type:"text",placeholder:e.placeholder??"Enter a short description",onChange:h,onBlur:p,disabled:u,onKeyDown:m})})})});pt.displayName="StringFieldInput";class he extends Se{type="string";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new he({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){const{maximum_length:t,minimum_length:r,...o}=e;return new he({...o,maxLength:t,minLength:r})}static fromConfig(e){return new he(e)}static deserializeConfig(e){return Se._deserializeConfig(e)}static serializeConfig(e){return Se._serializeConfig(e)}render(){return n.jsx(pt,{field:this})}}const mt=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),h=d.useCallback(m=>{const g=m.target.value;s(g)},[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:f,image:e.image,children:n.jsx(a.TextArea,{id:e.identifier,value:r??"",name:o,onChange:h,onBlur:p,className:"field-sizing-content min-h-12",placeholder:e.placeholder??"Enter a description",resize:"vertical",accentColor:"base",variant:"surface",size:t,disabled:u})})});mt.displayName="TextFieldInput";class pe extends Se{type="text";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new pe({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){const{maximum_length:t,minimum_length:r,...o}=e;return new pe({...o,maxLength:t,minLength:r})}static fromConfig(e){return new pe(e)}static deserializeConfig(e){return Se._deserializeConfig(e)}static serializeConfig(e){return Se._serializeConfig(e)}render(){return n.jsx(mt,{field:this})}}const Ri=Zo(),gt=new Set(Ri);function Zo(i=!0){const e=new Set;for(let t=-12;t<=14;t++){const r=t>=0?"+":"-",o=Math.abs(t).toString().padStart(2,"0");e.add(`${r}${o}: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 o=r>=0?"+":"-",l=Math.floor(Math.abs(r)).toString().padStart(2,"0");e.add(`${o}${l}:30`)}}return Array.from(e).sort((t,r)=>Ct(t)-Ct(r))}function Ct(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 Qo="+00:00",Ro=/^T([01]\d|2[0-3]):([0-5]\d):00([+-]\d{2}:\d{2})$/,Ci=i=>typeof i=="string"&>.has(i),Vt=()=>{const i=-new Date().getTimezoneOffset(),e=i>=0?"+":"-",t=Math.abs(i),r=Math.floor(t/60),o=t%60,l=`${e}${r.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`;return Ci(l)?l:Qo};function yt(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 Ue=i=>{const e=Ro.exec(i);if(!e)return null;const t=e[3];return Ci(t)?{hours:Number(e[1]),minutes:Number(e[2]),utcOffset:t}:null},A=i=>typeof i=="string"&&Ue(i)!==null,en=(i,e,t=Vt())=>{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(!Ci(t))throw new Error("Unsupported UTC offset");const r=i.toString().padStart(2,"0"),o=e.toString().padStart(2,"0");return`T${r}:${o}:00${t}`},Vi=i=>`UTC${i}`,me=i=>{const e=Ue(i);if(!e)throw new Error(`Invalid time value: ${i}`);return(e.hours*60+e.minutes-yt(e.utcOffset)+1440)%1440},yi=(i,e=!0)=>{const t=Ue(i);if(!t)throw new Error(`Invalid time value: ${i}`);const r=(t.hours%12||12).toString().padStart(2,"0"),o=t.minutes.toString().padStart(2,"0"),l=t.hours>=12?"PM":"AM",s=`${r}:${o} ${l}`;return e?`${s} ${Vi(t.utcOffset)}`:s},ke=i=>typeof i=="object"&&(A(i.from)||A(i.to)),nn=(i,e)=>{const t=me(i),r=e.from?me(e.from):null,o=e.to?me(e.to):null;return r===null&&o===null?!0:r===null?t<=o:o===null?t>=r:r<=o?t>=r&&t<=o:t>=r||t<=o},vi=d.memo(i=>{const{value:e,onChange:t,onBlur:r,disabled:o,size:l="md",id:s,name:f,compact:u=!1}=i,h=e?Ue(e):null,p=h?`${h.hours.toString().padStart(2,"0")}:${h.minutes.toString().padStart(2,"0")}`:"",m=d.useCallback(z=>{const S=z.target.value;if(!S){t(null);return}const[w,v]=S.split(":").map(Number);t(en(w,v,h?.utcOffset))},[t,h?.utcOffset]),g=d.useCallback(z=>{h&&(t(en(h.hours,h.minutes,z)),r?.())},[r,t,h]),C=d.useCallback(z=>{z||r?.()},[r]);return n.jsxs("div",{className:"flex min-w-0 gap-2",children:[n.jsx(a.Input.Root,{className:"min-w-0 grow",accentColor:"base",variant:"surface",size:l,children:n.jsx(a.Input.Field,{id:s,name:f,className:R.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:m,onBlur:r,disabled:o})}),n.jsxs(a.Menu.Root,{align:"end",onOpenChange:C,children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsxs(a.Button,{type:"button",className:u?"!justify-between":"min-w-32 !justify-between",accentColor:"base",variant:"surface",size:l,disabled:o||!h,children:[n.jsx(a.Text,{className:"truncate",highContrast:!!h,children:h?Vi(h.utcOffset):"UTC offset"}),n.jsx(a.LuIcon,{icon:ui})]})}),n.jsx(a.Menu.Content,{size:l,children:n.jsx(a.Menu.Scroll,{children:n.jsx(a.Menu.SelectGroup,{required:!0,value:h?.utcOffset,onValueChange:g,children:Ri.map(z=>n.jsxs(a.Menu.SelectItem,{value:z,children:[n.jsx(a.Menu.SelectedIndicator,{children:n.jsx(a.LuIcon,{icon:H})}),Vi(z)]},z))})})})]})]})});vi.displayName="TimeFieldControl";const tn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e});return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:n.jsx(vi,{id:e.identifier,name:o,size:t,value:r,onChange:s,onBlur:l,disabled:u})})});tn.displayName="TimeFieldInput";class Me extends N{type="time";constructor(e){super(e)}static deserialize(e){return new Me(e)}static fromConfig(e){return new Me(e)}static deserializeConfig(e){return N._deserializeConfig(e)}static serializeConfig(e){return N._serializeConfig(e)}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new Me({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(tn,{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 vt=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),h=d.useRef(null),p=d.useCallback(()=>{h.current?.click()},[]),m=d.useCallback(()=>{if(!h.current)return;const v=h.current.files;if(!v){l();return}const x=Array.from(v).map(y=>de.from(F.v4(),y)),O=[...r,...x];s(O),l()},[l,s,r]),g=d.useCallback(v=>{const x=r.filter(({uuid:O})=>O!==v.uuid);s(x),l()},[r,s,l]);d.useEffect(()=>{if(!h.current)return;const v=new AbortController;return h.current.addEventListener("cancel",()=>{l()},{signal:v.signal}),()=>{v.abort()}},[l,r]);const C=e.maximumFiles!==1,w=C?"Select files":"Select a file";return n.jsxs(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:[n.jsxs(a.Button,{className:"w-max",size:t,variant:"surface",accentColor:"base",onClick:p,type:"button",disabled:u,children:[n.jsx(a.LuIcon,{icon:Pi}),w]}),n.jsx("input",{id:e.identifier,name:o,type:"file",ref:h,accept:e.extensions?.join(","),multiple:C,className:"hidden",onChange:m,value:""}),r.length>0&&n.jsx("div",{className:"mt-1 flex h-max flex-col gap-2",children:r.map(v=>n.jsx(Yi,{size:t,fileOrPromise:v,onRemove:g,disabled:u},v.uuid))})]})});vt.displayName="UploadFieldInput";class ge extends N{type="upload";extensions;maximumSize;maximumFiles;constructor(e){const{extensions:t,maximumFiles:r,maximumSize:o,...l}=e;super(l),this.maximumSize=o,this.maximumFiles=r,this.extensions=t}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new J({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:0,identifier:`${t}maximumFiles`,integers:!0}),showDirectly:!1},{field:new J({label:"What is the maximum size of each file?",description:"Maximum file size in MB.",required:!1,identifier:`${t}maximumSize`,minimum:0,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.maximumSize,r=t&&t*1e3*1e3,o=this.maximumFiles;return typeof t=="number"&&typeof r=="number"&&e.push(l=>{if(l.some(s=>s instanceof de&&s.size>r))return`Files must be at most ${t}MB.`}),typeof o=="number"&&e.push(l=>{if(l.length>o)return`You can only upload ${o} files.`}),e}serialize(){return{...super.serialize(),extensions:this.extensions,maximum_size:this.maximumSize,maximum_files:this.maximumFiles}}config(){return{...super.config(),extensions:this.extensions,maximumSize:this.maximumSize,maximumFiles:this.maximumFiles}}getOptions(){return{...super.getOptions(),extensions:this.extensions,maximumSize:this.maximumSize,maximumFiles:this.maximumFiles}}duplicate(e){return new ge({...this.getOptions(),identifier:e})}setOptions(e){"maximumSize"in e&&(this.maximumSize=e.maximumSize),"maximumFiles"in e&&(this.maximumFiles=e.maximumFiles),"extensions"in e&&(this.extensions=e.extensions),super.setOptions(e)}static deserialize(e){const{maximum_size:t,maximum_files:r,...o}=e;return new ge({...o,maximumSize:t,maximumFiles:r})}static fromConfig(e){return new ge(e)}static deserializeConfig(e){const{extensions:t,maximum_size:r,maximum_files:o,...l}=e;return{...N._deserializeConfig(l),extensions:t,maximumSize:r,maximumFiles:o}}static serializeConfig(e){const{extensions:t,maximumSize:r,maximumFiles:o,...l}=e;return{...N._serializeConfig(l),extensions:t,maximum_size:r,maximum_files:o}}serializeValue(e){return[]}deserializeValue(e){return[]}render(){return n.jsx(vt,{field:this})}isSerializedValue(e){return Array.isArray(e)&&e.length===0}isValue(e){return Array.isArray(e)?e.every(t=>t instanceof be||t instanceof de):!1}areValuesEqual(e,t){return mi(e,t)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(e,t){return e.length===t.length}}const zt=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:o,onBlur:l,onChange:s,error:f,disabled:u}=P({field:e}),h=d.useCallback(C=>{const z=C.target.value;z!==""&&!URL.canParse(z)||s(z!==""?new URL(z):null)},[s]),p=d.useCallback(()=>{l()},[l]),m=d.useCallback(C=>{C.key==="Enter"&&C.preventDefault()},[]),g=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:f,image:e.image,children:n.jsxs("div",{className:"flex w-full gap-2",children:[n.jsx(a.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:t,children:n.jsx(a.Input.Field,{id:e.identifier,className:"truncate",name:o,value:r?r.toString():"",type:"url",inputMode:"url",placeholder:e.placeholder??"https://example.com",onChange:h,onBlur:p,disabled:u,onKeyDown:m})}),n.jsx(a.IconButton,{size:t,variant:"soft",accentColor:"base",type:"button",disabled:r===null,onClick:g,children:n.jsx(a.LuIcon,{icon:_o})})]})})});zt.displayName="URLFieldInput";class xe extends N{type="url";placeholder;constructor(e){const{placeholder:t,...r}=e;super(r),this.placeholder=t}serialize(){return{...super.serialize(),placeholder:this.placeholder}}config(){return{...super.config(),placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new xe({...this.getOptions(),identifier:e})}setOptions(e){"placeholder"in e&&(this.placeholder=e.placeholder),super.setOptions(e)}static deserialize(e){return new xe(e)}static fromConfig(e){return new xe(e)}static deserializeConfig(e){const{placeholder:t,...r}=e;return{...N._deserializeConfig(r),placeholder:t}}static serializeConfig(e){const{placeholder:t,...r}=e;return{...N._serializeConfig(r),placeholder:t}}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(zt,{field:this})}}const Ee={date:we,time:Me,number:J,boolean:le,select:re,string:he,url:xe,text:pe,upload:ge,qr:Ne,"multi-string":ae,"multi-select":ie,radio:ue,"checkbox-list":ee,"pass-fail":ce,otp:se,rating:fe},St=Object.keys(Ee),T={"checkbox-list":{description:"Allows the user to select a multiple options from a list.",group:q.Selection,icon:Oo,name:"Checkbox list"},"multi-select":{description:"Allows the user to select a multiple options from a list of options.",group:q.Selection,icon:Ao,name:"Multi-select"},"multi-string":{description:"Allows the user to provide multiple unique strings.",group:q.Text,icon:Do,name:"Multi-string"},"pass-fail":{description:"Track pass, fail, or N/A outcome.",group:q.Assessment,icon:qo,name:"Pass - Fail"},boolean:{description:"Perfect for both optional and required yes/no questions.",group:q.Selection,icon:Go,name:"Checkbox"},date:{description:"Allows specifying a date.",group:q.Temporal,icon:bo,name:"Date"},time:{description:"Allows specifying a time and UTC offset.",group:q.Temporal,icon:Wo,name:"Time"},number:{description:"Allows specifying a number within a given range.",group:q.Numeric,icon:Lo,name:"Number"},otp:{description:"Allows specifying a number within a given range.",group:q.Verification,icon:jo,name:"OTP"},qr:{description:"Used for scanning/reading QR and barcodes.",group:q.Capture,icon:Uo,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:Gn,name:"Rating"},select:{description:"Allows the user to select a single option from a list of options.",group:q.Selection,icon:$o,name:"Dropdown"},string:{description:"Short text fields can hold up to 500 characters on a single line.",group:q.Text,icon:Ho,name:"Short Text"},text:{description:"Paragraph fields can hold up to 10000 characters and can have multiple lines.",group:q.Text,icon:So,name:"Paragraph"},upload:{description:"Allows a file to be uploaded.",group:q.Capture,icon:Pi,name:"Upload"},url:{description:"Allows users to enter a URL.",group:q.Text,icon:Bo,name:"URL"}},wt={[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"}},$="Unlabelled",zi="Unlabelled";class M{id;label;getApplyFn;serialize;deserialize;constructor(e){const{id:t,getApplyFn:r,label:o,serialize:l,deserialize:s}=e;this.id=t,this.getApplyFn=r,this.label=o,this.serialize=l,this.deserialize=s}static create(e){return new M(e)}}const Ft=M.create({id:"nullable-boolean-equals",label:"is",getApplyFn:i=>e=>e===i,serialize:i=>i,deserialize:i=>i}),bt=M.create({id:"nullable-boolean-not-equals",label:"is not",getApplyFn:i=>e=>e!==i,serialize:i=>i,deserialize:i=>i}),Nt=M.create({id:"date-equals",getApplyFn:i=>e=>e.getTime()===i.getTime(),label:"is",serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),Mt=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)}),xt=M.create({id:"date-before",getApplyFn:i=>e=>e.getTime()<i.getTime(),label:"before",serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),It=M.create({id:"date-after",label:"after",getApplyFn:i=>e=>e.getTime()>i.getTime(),serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),qt=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})}),Ot=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})}),_t=M.create({id:"has-files",label:"is",getApplyFn:i=>e=>e.length>0,serialize:i=>i,deserialize:i=>i}),Tt=M.create({id:"does-not-have-files",label:"is not",getApplyFn:i=>e=>e.length===0,serialize:i=>i,deserialize:i=>i}),rn=M.create({id:"number-equals",getApplyFn:i=>e=>e===i,label:"is",serialize:i=>i,deserialize:i=>i}),on=M.create({id:"number-not-equals",getApplyFn:i=>e=>e!==i,label:"is not",serialize:i=>i,deserialize:i=>i}),an=M.create({id:"number-less-than",getApplyFn:i=>e=>e<i,label:"is less than",serialize:i=>i,deserialize:i=>i}),ln=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}),sn=M.create({id:"number-greater-than",getApplyFn:i=>e=>e>i,label:"is greater than",serialize:i=>i,deserialize:i=>i}),dn=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}),cn=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}),un=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}),Et=M.create({id:"pass-fail-equals",getApplyFn:i=>e=>e===i,label:"is",serialize:i=>i,deserialize:i=>i}),Lt=M.create({id:"pass-fail-not-equals",getApplyFn:i=>e=>e!==i,label:"is not",serialize:i=>i,deserialize:i=>i}),Bt=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}),At=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}),Ce=M.create({id:"nullable-string-equals",getApplyFn:i=>e=>e===i,label:"is",serialize:i=>i,deserialize:i=>i}),Ve=M.create({id:"nullable-string-not-equals",getApplyFn:i=>e=>e!==i,label:"is not",serialize:i=>i,deserialize:i=>i}),Le=M.create({id:"string-includes",getApplyFn:i=>e=>e.includes(i),label:"includes",serialize:i=>i,deserialize:i=>i}),Be=M.create({id:"string-excludes",getApplyFn:i=>e=>!e.includes(i),label:"does not include",serialize:i=>i,deserialize:i=>i}),fn=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}),hn=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}),Si=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}),wi=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}),Fi=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}),bi=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}),Ni=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}),$t=M.create({id:"time-equals",label:"is",getApplyFn:i=>e=>e===i,serialize:i=>i,deserialize:i=>i}),Dt=M.create({id:"time-not-equals",label:"is not",getApplyFn:i=>e=>e!==i,serialize:i=>i,deserialize:i=>i}),Pt=M.create({id:"time-before",label:"before",getApplyFn:i=>e=>me(e)<me(i),serialize:i=>i,deserialize:i=>i}),jt=M.create({id:"time-after",label:"after",getApplyFn:i=>e=>me(e)>me(i),serialize:i=>i,deserialize:i=>i}),Ut=M.create({id:"time-range-in",label:"in between",getApplyFn:i=>e=>nn(e,i),serialize:i=>i,deserialize:i=>i}),kt=M.create({id:"time-range-not-in",label:"not in between",getApplyFn:i=>e=>!nn(e,i),serialize:i=>i,deserialize:i=>i}),V=i=>i;class j extends je{id;conditionValue;conditionModifier;field;constructor(e){const{id:t,field:r,conditionValue:o,conditionModifier:l}=e;super(),this.id=t,this.field=r,this.conditionValue=o,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),o=r?e.modifier.getApplyFn(t):null;return l=>{if(!r)return!0;const s=this.transformValue(l);return e.isValueValid(s)?o(s):!1}}}const Gt=d.memo,Ie=Gt(function(i){const{ref:e,children:t,...r}=i,o=d.useCallback(l=>typeof t=="function"?n.jsxs(n.Fragment,{children:[t(l),n.jsx(a.Menu.SelectedIndicator,{className:"ml-[auto]",children:n.jsx(a.LuIcon,{icon:H})})]}):n.jsxs(n.Fragment,{children:[t,n.jsx(a.Menu.SelectedIndicator,{className:"ml-[auto]",children:n.jsx(a.LuIcon,{icon:H})})]}),[t]);return n.jsx(a.Menu.SelectItem,{ref:e,...r,children:o})}),Jt=Gt(function(i){const{ref:e,children:t,...r}=i,o=d.useCallback(l=>typeof t=="function"?n.jsxs(n.Fragment,{children:[t(l),n.jsx(a.Menu.SelectedIndicator,{className:"ml-auto",children:n.jsx(a.LuIcon,{icon:H})})]}):n.jsxs(n.Fragment,{children:[t,n.jsx(a.Menu.SelectedIndicator,{className:"ml-auto",children:n.jsx(a.LuIcon,{icon:H})})]}),[t]);return n.jsx(a.Menu.MultiSelectItem,{ref:e,...r,children:o})}),pn=d.memo(i=>{const{ref:e,children:t,...r}=i,o=d.useCallback(l=>typeof t=="function"?n.jsxs(n.Fragment,{children:[t(l),n.jsx(a.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:s=>s?n.jsx(a.LuIcon,{icon:fi}):n.jsx(a.LuIcon,{icon:H})})]}):n.jsxs(n.Fragment,{children:[t,n.jsx(a.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:s=>s?n.jsx(a.LuIcon,{icon:fi}):n.jsx(a.LuIcon,{icon:H})})]}),[t]);return n.jsx(a.Menu.SelectAllItem,{ref:e,...r,children:o})});pn.displayName="SelectAllItemTemplate";const k=i=>{const{children:e,condition:t,size:r="sm",variant:o,accentColor:l,radius:s}=i,f=d.useCallback(u=>{t.setConditionModifier(u)},[t]);return n.jsxs(a.Menu.Root,{align:"start",children:[n.jsx(a.Menu.ClickTrigger,{children:e}),n.jsx(a.Menu.Content,{size:r,variant:o,radius:s,accentColor:l,children:n.jsx(a.Menu.SelectGroup,{required:!0,value:t.getConditionModifier(),onValueChange:f,children:t.getConditionModifiers().map(([u,h])=>n.jsx(Ie,{value:u,children:h.modifier.label},u))})})]})},Mi=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:o,modal:l,size:s,align:f,accentColor:u="base",...h}=i;return n.jsxs(a.Popover.Root,{open:t,onOpenChange:r,defaultOpen:o,modal:l,children:[n.jsx(a.Popover.Trigger,{asChild:!0,children:e}),n.jsx(a.Popover.Content,{size:s,align:f,children:n.jsx(a.DayPicker,{size:s,accentColor:u,...h})})]})});Mi.displayName="DayPickerPopover";const Ht=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:o,modal:l,size:s,accentColor:f="base",values:u,onValuesChange:h,placeholder:p="Enter text",...m}=i,[g,C]=d.useState(""),z=d.useCallback(x=>{C(x.target.value)},[]),S=d.useCallback(x=>{x.key==="Enter"&&(x.preventDefault(),x.stopPropagation(),h([...u,g]),C(""))},[g,h,u]),w=d.useCallback(()=>{h([...u,g]),C("")},[g,h,u]),v=d.useCallback(x=>{const O=[...u];O.splice(x,1),h(O)},[h,u]);return n.jsxs(a.Popover.Root,{open:t,onOpenChange:r,defaultOpen:o,modal:l,children:[n.jsx(a.Popover.Trigger,{asChild:!0,children:e}),n.jsx(a.Popover.Content,{size:s,onClick:a.stopPropagation,accentColor:f,...m,children:n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{className:"flex gap-2",children:[n.jsx(a.Input.Root,{className:"grow",accentColor:"base",variant:"outline",size:"sm",children:n.jsx(a.Input.Field,{value:g,onChange:z,onKeyDown:S,placeholder:p,...m})}),n.jsx(a.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button",onClick:w,children:n.jsx(a.LuIcon,{icon:Z})})]}),u.length>0&&n.jsx("div",{className:"flex flex-col gap-1",children:u.map((x,O)=>n.jsxs(a.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(a.IconButton,{size:"xs",variant:"ghost",type:"button",accentColor:"base",onClick:()=>{v(O)},children:n.jsx(a.LuIcon,{icon:oe})})]},`${x}-${O}`))})]})})]})});Ht.displayName="NumberInputPopover";const qe=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:o,modal:l,size:s,accentColor:f="base",value:u,onValueChange:h,placeholder:p="Enter a number",...m}=i,[g,C]=d.useState(null);d.useEffect(()=>{u!==void 0&&C(u)},[u]);const z=d.useCallback(w=>{const v=w.target.valueAsNumber;C(isNaN(v)?null:v)},[]),S=d.useCallback(w=>{const v=w.target.valueAsNumber;h?.(isNaN(v)?null:v)},[h]);return n.jsxs(a.Popover.Root,{open:t,onOpenChange:r,defaultOpen:o,modal:l,children:[n.jsx(a.Popover.Trigger,{asChild:!0,children:e}),n.jsx(a.Popover.Content,{size:s,onClick:a.stopPropagation,...m,children:n.jsx(a.Input.Root,{size:s,accentColor:f,children:n.jsx(a.Input.Field,{placeholder:p,type:"number",value:g??"",onChange:z,onBlur:S})})})]})});qe.displayName="NumberInputPopover";const U=i=>{const{condition:e,onClick:t,...r}=i,o=d.useCallback(()=>{t(e)},[e,t]);return n.jsx(a.IconButton,{onClick:o,...r,children:n.jsx(a.LuIcon,{icon:oe})})};U.displayName="RemoveConditionButton";const Ge=d.memo(i=>{const{ref:e,selectFieldOptions:t,...r}=i,o=d.useMemo(()=>_e(t),[t]);return n.jsxs(a.Menu.MultiSelectGroup,{ref:e,...r,children:[n.jsx(pn,{children:"Select all"}),o.map(l=>n.jsx(Jt,{value:l.value,children:n.jsx("span",{className:"truncate",children:l.label})},l.value))]})});Ge.displayName="SelectFieldOptionMultiSelectGroup";const mn=d.memo(i=>{const{ref:e,selectFieldOptions:t,...r}=i,o=d.useMemo(()=>_e(t),[t]);return n.jsx(a.Menu.SelectGroup,{ref:e,...r,children:o.map(l=>n.jsx(Ie,{value:l.value,children:n.jsx("span",{className:"truncate",children:l.label})},l.value))})});mn.displayName="SelectFieldOptionSelectGroup";const Ae=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:o,modal:l,size:s,accentColor:f="base",value:u,onValueChange:h,placeholder:p="Enter text",...m}=i,[g,C]=d.useState(""),z=d.useCallback(w=>{C(w.target.value)},[]),S=d.useCallback(w=>{const v=w.target.value;h?.(v)},[h]);return d.useEffect(()=>{u&&C(u)},[u]),n.jsxs(a.Popover.Root,{open:t,onOpenChange:r,defaultOpen:o,modal:l,children:[n.jsx(a.Popover.Trigger,{asChild:!0,children:e}),n.jsx(a.Popover.Content,{size:s,onClick:a.stopPropagation,...m,children:n.jsx(a.Input.Root,{size:s,accentColor:f,children:n.jsx(a.Input.Field,{placeholder:p,type:"text",value:g,onChange:z,onBlur:S})})})]})});Ae.displayName="TextInputPopover";const xi=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:o,modal:l,size:s="sm",accentColor:f="base",value:u,onValueChange:h,...p}=i;return n.jsxs(a.Popover.Root,{open:t,onOpenChange:r,defaultOpen:o,modal:l,children:[n.jsx(a.Popover.Trigger,{asChild:!0,children:e}),n.jsx(a.Popover.Content,{size:s,onClick:a.stopPropagation,accentColor:f,...p,children:n.jsx(vi,{compact:!0,size:s,value:u,onChange:h})})]})});xi.displayName="TimeInputPopover";const Wt=i=>{const{condition:e,onRemove:t}=i,r=e.getConditionValue(),o=e.getConditionModifier(),l=()=>{switch(r){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[e.field.type].icon}),n.jsx("span",{className:"truncate",children:e.field.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[o].modifier.label})}),n.jsxs(a.Menu.Root,{children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:l()})}),n.jsx(a.Menu.Content,{size:"sm",children:n.jsxs(a.Menu.SelectGroup,{required:!0,value:r,onValueChange:e.setConditionValue,children:[n.jsx(Ie,{value:!0,children:"true"}),n.jsx(Ie,{value:!1,children:"false"})]})})]}),n.jsx(U,{condition:e,onClick:t})]})},Kt={equals:V({modifier:Ft,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:bt,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Je extends j{modifiers=Kt;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=Kt[o];let f;return r!==void 0&&(f=s.modifier.deserialize(r)),new Je({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(Wt,{condition:this,...e},this.id)}}const $e=[],Xt=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=d.useCallback(u=>{u.length>0?e.setConditionValue(u):e.setConditionValue(void 0)},[e]),f=()=>o===void 0?"...":o===null?"empty":o.length===0?"...":`${o.length} options`;return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"soft",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"soft",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),n.jsxs(a.Menu.Root,{children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsx(a.Button,{type:"button",className:"truncate",children:f()})}),n.jsx(a.Menu.Content,{size:"sm",children:n.jsx(Ge,{values:o??$e,selectFieldOptions:e.field.options,onValuesChange:s})})]}),n.jsx(U,{condition:e,onClick:t})]})},Yt={equals:V({modifier:bi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:Ni,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),every:V({modifier:Si,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),some:V({modifier:wi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),none:V({modifier:Fi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class He extends j{modifiers=Yt;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=Yt[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new He({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(Xt,{condition:this,...e},this.id)}}class Ii extends je{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,o])=>r(o(e)))}}const ea=(i,e)=>d.useMemo(()=>{const t=new Ii(i);return t.observe(r=>e(r.getConditions())),t},[i,e]),Zt=i=>{const{condition:e,onRemove:t}=i,r=e.getConditionValue(),o=e.getConditionModifier(),l=()=>{switch(o){case"equals":case"notEquals":{const s=e.modifiers.equals,f=r!==void 0&&s.isConditionValueValid(r)?r:void 0;return n.jsx(Mi,{required:!1,size:"sm",mode:"single",selected:f??void 0,onSelect:u=>e.setConditionValue(u),children:n.jsx(a.Button,{type:"button",className:"truncate",children:f!==void 0?f?.toLocaleDateString()??"empty":"..."})})}case"before":case"after":{const s=e.modifiers.after,f=r!==void 0&&s.isConditionValueValid(r)?r:void 0;return n.jsx(Mi,{required:!0,size:"sm",mode:"single",selected:f,onSelect:e.setConditionValue,children:n.jsx(a.Button,{type:"button",className:"truncate",children:f?f.toLocaleDateString():"..."})})}case"in":case"notIn":{const s=e.modifiers.in,f=r!==void 0&&s.isConditionValueValid(r)?r:void 0;return n.jsx(Mi,{required:!0,mode:"range",size:"sm",selected:f,onSelect:e.setConditionValue,children:n.jsx(a.Button,{className:"truncate",children:f?`${f.from?.toLocaleDateString()} - ${f.to?.toLocaleDateString()}`:"..."})})}}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[e.field.type].icon}),n.jsx("span",{className:"truncate",children:e.field.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[o].modifier.label})}),l(),n.jsx(U,{condition:e,onClick:t})]})},Qt={equals:V({modifier:Nt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),notEquals:V({modifier:Mt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),before:V({modifier:xt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),after:V({modifier:It,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),in:V({modifier:qt,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: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})};class We extends j{modifiers=Qt;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=Qt[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new We({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(Zt,{condition:this,...e},this.id)}}const Rt=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=d.useCallback(u=>{u.length>0?e.setConditionValue(u):e.setConditionValue(void 0)},[e]),f=()=>o===void 0?"...":o===null?"empty":o.length===0?"...":`${o.length} options`;return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),n.jsxs(a.Menu.Root,{children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsx(a.Button,{type:"button",className:"truncate",children:f()})}),n.jsx(a.Menu.Content,{size:"sm",children:n.jsx(Ge,{values:o??$e,selectFieldOptions:r.options,onValuesChange:s})})]}),n.jsx(U,{condition:e,onClick:t})]})},er={equals:V({modifier:bi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:Ni,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),every:V({modifier:Si,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),some:V({modifier:wi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),none:V({modifier:Fi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Ke extends j{modifiers=er;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=er[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Ke({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(Rt,{condition:this,...e},this.id)}}const ir=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=d.useCallback(u=>{e.setConditionValue(u.length>0?u:void 0)},[e]),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 n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),n.jsx(Ht,{values:o??$e,onValuesChange:s,children:n.jsx(a.Button,{type:"button",className:"truncate",children:f()})}),n.jsx(U,{condition:e,onClick:t})]})},nr={equals:V({modifier:bi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:Ni,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),every:V({modifier:Si,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),some:V({modifier:wi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),none:V({modifier:Fi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Xe extends j{modifiers=nr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=nr[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Xe({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(ir,{condition:this,...e},this.id)}}const tr=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=d.useCallback(u=>{e.setConditionValue(u??void 0)},[e]),f=()=>{switch(l){case"equals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const u=e.modifiers.greaterThan,h=o!==void 0&&u.isConditionValueValid(o)?o:void 0;return n.jsx(qe,{value:h??null,onValueChange:s,size:"sm",children:n.jsx(a.Button,{type:"button",className:"truncate",children:h!==void 0?h??"empty":"..."})})}case"inRange":case"notInRange":{const u=e.modifiers.inRange,h=o!==void 0&&u.isConditionValueValid(o)?o:void 0;return n.jsxs(n.Fragment,{children:[n.jsx(qe,{value:h?.from??null,onValueChange:p=>{e.setConditionValue({from:p,to:h?.to??null})},size:"sm",children:n.jsx(a.Button,{className:"truncate",children:h?.from??"..."})}),n.jsx(qe,{value:h?.to??null,onValueChange:p=>{e.setConditionValue({from:h?.from??null,to:p})},size:"sm",children:n.jsx(a.Button,{className:"truncate",children:h?.to??"..."})})]})}}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),f(),n.jsx(U,{condition:e,onClick:t})]})},rr={equals:V({modifier:rn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),notEquals:V({modifier:on,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThan:V({modifier:an,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThanOrEquals:V({modifier:ln,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThan:V({modifier:sn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThanOrEquals:V({modifier:dn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),inRange:V({modifier:cn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"}),notInRange:V({modifier:un,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"})};class Ye extends j{modifiers=rr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=rr[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Ye({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(tr,{condition:this,...e},this.id)}}const or=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Ae,{value:o??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:o||"..."})})})}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(U,{condition:e,onClick:t})]})},ar={equals:V({modifier:Ce,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:Ve,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:Be,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Ze extends j{modifiers=ar;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=ar[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Ze({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(or,{condition:this,...e},this.id)}}const lr=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":{const f=e.modifiers.equals,u=o!==void 0&&f.isConditionValueValid(o)?o:void 0;return n.jsxs(a.Menu.Root,{children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsx(a.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(a.Menu.Content,{size:"sm",children:n.jsx(a.Menu.SelectGroup,{required:!1,value:u,onValueChange:e.setConditionValue,children:Te.map(h=>{const{label:p}=Fe[h];return n.jsx(Ie,{value:h,children:n.jsx("span",{className:"truncate",children:p})},h)})})})]})}case"includes":case"excludes":{const f=e.modifiers.includes,u=o!==void 0&&f.isConditionValueValid(o)?o:void 0;return n.jsxs(a.Menu.Root,{children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsx(a.Button,{type:"button",children:u?`${u.length} statuses`:"..."})}),n.jsx(a.Menu.Content,{size:"sm",children:n.jsxs(a.Menu.MultiSelectGroup,{values:u??$e,onValuesChange:e.setConditionValue,children:[n.jsx(pn,{children:"Select all"}),Te.map(h=>{const{label:p,icon:m}=Fe[h];return n.jsxs(Jt,{value:h,children:[n.jsx(a.LuIcon,{icon:m}),n.jsx("span",{className:"truncate",children:p})]},h)})]})})]})}}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(U,{condition:e,onClick:t})]})},sr={equals:V({modifier:Et,isValueValid:i=>i!==null,isConditionValueValid:i=>typeof i=="string",isSerializedValueValid:i=>typeof i=="string"}),notEquals:V({modifier:Lt,isValueValid:i=>i!==null,isConditionValueValid:i=>typeof i=="string",isSerializedValueValid:i=>typeof i=="string"}),includes:V({modifier:Bt,isValueValid:i=>i!==null,isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)}),excludes:V({modifier:At,isValueValid:i=>i!==null,isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)})};class Qe extends j{modifiers=sr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=sr[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Qe({field:t,conditionModifier:o,conditionValue:f,...l})}transformValue(e){return e.status}render(e){return n.jsx(lr,{condition:this,...e},this.id)}}const dr=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=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 s)h[p.value]=p.label;return h},[s]),u=()=>{switch(l){case"equals":case"notEquals":{const h=e.modifiers.equals,p=o!==void 0&&h.isConditionValueValid(o)?o:void 0;return n.jsxs(a.Menu.Root,{children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:p!==void 0?p?f[p]:"empty":"..."})})}),n.jsx(a.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 h=e.modifiers.includes,p=o!==void 0&&h.isConditionValueValid(o)?o:void 0;return n.jsxs(a.Menu.Root,{children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsx(a.Button,{type:"button",children:p?`${p.length} options`:"..."})}),n.jsx(a.Menu.Content,{size:"sm",children:n.jsx(Ge,{selectFieldOptions:r.options,values:p??$e,onValuesChange:e.setConditionValue})})]})}}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),u(),n.jsx(U,{condition:e,onClick:t})]})},cr={equals:V({modifier:Ce,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),notEquals:V({modifier:Ve,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),includes:V({modifier:fn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)}),excludes:V({modifier:hn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)})};class Re extends j{modifiers=cr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=cr[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Re({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(dr,{condition:this,...e},this.id)}}const ur=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const f=e.modifiers[l],u=o!==void 0&&f.isConditionValueValid(o)?o:void 0;return n.jsx(qe,{value:u??null,onValueChange:h=>e.setConditionValue(h??void 0),size:"sm",children:n.jsx(a.Button,{type:"button",className:"truncate",children:u!==void 0?u:"..."})})}case"inRange":case"notInRange":{const f=e.modifiers.inRange,u=o!==void 0&&f.isConditionValueValid(o)?o:void 0;return n.jsxs(n.Fragment,{children:[n.jsx(qe,{value:u?.from??null,onValueChange:h=>{e.setConditionValue({from:h,to:u?.to??null})},size:"sm",children:n.jsx(a.Button,{className:"truncate",children:u?.from??"..."})}),n.jsx(qe,{value:u?.to??null,onValueChange:h=>{e.setConditionValue({from:u?.from??null,to:h})},size:"sm",children:n.jsx(a.Button,{className:"truncate",children:u?.to??"..."})})]})}}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(U,{condition:e,onClick:t})]})},fr={equals:V({modifier:rn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),notEquals:V({modifier:on,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThan:V({modifier:an,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThanOrEquals:V({modifier:ln,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThan:V({modifier:sn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThanOrEquals:V({modifier:dn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),inRange:V({modifier:cn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"}),notInRange:V({modifier:un,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"})};class ei extends j{modifiers=fr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=fr[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ei({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(ur,{condition:this,...e},this.id)}}const hr=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Ae,{value:o??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:o||"..."})})})}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(U,{condition:e,onClick:t})]})},pr={equals:V({modifier:Ce,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:Ve,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:Be,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ii extends j{modifiers=pr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=pr[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ii({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(hr,{condition:this,...e},this.id)}}const mr=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=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 s)p[m.value]=m.label;return p},[s]),u=d.useCallback(p=>{p.length>0?e.setConditionValue(p):e.setConditionValue([])},[e]),h=()=>{switch(l){case"equals":case"notEquals":{const p=e.modifiers.equals,m=o!==void 0&&p.isConditionValueValid(o)?o:void 0;return n.jsxs(a.Menu.Root,{children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:m!==void 0?m?f[m]:"empty":"..."})})}),n.jsx(a.Menu.Content,{size:"sm",children:n.jsx(mn,{required:!1,selectFieldOptions:r.options,value:m??void 0,onValueChange:e.setConditionValue})})]})}case"includes":case"excludes":{const p=e.modifiers.includes,m=o!==void 0&&p.isConditionValueValid(o)?o:void 0;return n.jsxs(a.Menu.Root,{children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsx(a.Button,{type:"button",children:m?`${m.length} options`:"..."})}),n.jsx(a.Menu.Content,{size:"sm",children:n.jsx(Ge,{selectFieldOptions:r.options,values:m??$e,onValuesChange:u})})]})}}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),h(),n.jsx(U,{condition:e,onClick:t})]})},gr={equals:V({modifier:Ce,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),notEquals:V({modifier:Ve,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),includes:V({modifier:fn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)}),excludes:V({modifier:hn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)})};class ni extends j{modifiers=gr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=gr[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ni({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(mr,{condition:this,...e},this.id)}}const Cr=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Ae,{value:o??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:o||"..."})})})}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(U,{condition:e,onClick:t})]})},Vr={equals:V({modifier:Ce,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:Ve,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:Be,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ti extends j{modifiers=Vr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=Vr[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ti({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(Cr,{condition:this,...e},this.id)}}const yr=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Ae,{value:o??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:o||"..."})})})}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(U,{condition:e,onClick:t})]})},vr={equals:V({modifier:Ce,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:Ve,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:Be,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ri extends j{modifiers=vr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=vr[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ri({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(yr,{condition:this,...e},this.id)}}const zr=i=>{const{condition:e,onRemove:t}=i,r=e.getConditionValue(),o=e.getConditionModifier(),l=()=>{switch(o){case"equals":case"notEquals":case"before":case"after":{const s=typeof r=="string"?r:void 0;return n.jsx(xi,{value:s,onValueChange:f=>e.setConditionValue(f??void 0),size:"sm",children:n.jsx(a.Button,{type:"button",className:"truncate",children:s?yi(s):"..."})})}case"in":case"notIn":{const s=r&&typeof r=="object"?r:void 0,f=u=>{e.setConditionValue(u.from||u.to?u:void 0)};return n.jsxs(n.Fragment,{children:[n.jsx(xi,{value:s?.from,onValueChange:u=>f({from:u,to:s?.to??null}),size:"sm",children:n.jsx(a.Button,{type:"button",className:"truncate",children:s?.from?yi(s.from):"..."})}),n.jsx(xi,{value:s?.to,onValueChange:u=>f({from:s?.from??null,to:u}),size:"sm",children:n.jsx(a.Button,{type:"button",className:"truncate",children:s?.to?yi(s.to):"..."})})]})}}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[e.field.type].icon}),n.jsx("span",{className:"truncate",children:e.field.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[o].modifier.label})}),l(),n.jsx(U,{condition:e,onClick:t})]})},Sr={equals:V({modifier:$t,isValueValid:i=>A(i),isConditionValueValid:i=>A(i),isSerializedValueValid:i=>A(i)}),notEquals:V({modifier:Dt,isValueValid:i=>A(i),isConditionValueValid:i=>A(i),isSerializedValueValid:i=>A(i)}),before:V({modifier:Pt,isValueValid:i=>A(i),isConditionValueValid:i=>A(i),isSerializedValueValid:i=>A(i)}),after:V({modifier:jt,isValueValid:i=>A(i),isConditionValueValid:i=>A(i),isSerializedValueValid:i=>A(i)}),in:V({modifier:Ut,isValueValid:i=>A(i),isConditionValueValid:i=>ke(i),isSerializedValueValid:i=>ke(i)}),notIn:V({modifier:kt,isValueValid:i=>A(i),isConditionValueValid:i=>ke(i),isSerializedValueValid:i=>ke(i)})};class oi extends j{modifiers=Sr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=Sr[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new oi({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(zr,{condition:this,...e},this.id)}}const wr=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(o){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),n.jsxs(a.Menu.Root,{children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:s()})}),n.jsx(a.Menu.Content,{size:"sm",children:n.jsxs(a.Menu.SelectGroup,{required:!0,value:o,onValueChange:e.setConditionValue,children:[n.jsx(Ie,{value:!0,children:"empty"}),n.jsx(Ie,{value:!1,children:"not empty"})]})})]}),n.jsx(U,{condition:e,onClick:t})]})},Fr={equals:V({modifier:_t,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:Tt,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ai extends j{modifiers=Fr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=Fr[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ai({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(wr,{condition:this,...e},this.id)}}const br=i=>{const{condition:e,onRemove:t}=i,r=e.field,o=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Ae,{value:o??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(a.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:o||"..."})})})}};return n.jsxs(a.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(a.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:T[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||$})]}),n.jsx(k,{condition:e,children:n.jsx(a.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(U,{condition:e,onClick:t})]})},Nr={equals:V({modifier:Ce,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:Ve,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:Be,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class li extends j{modifiers=Nr;constructor(e){super(e)}transformValue(e){return e?.toString()??""}static deserialize(e,t){const{conditionValue:r,conditionModifier:o,...l}=e,s=Nr[o],f=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new li({field:t,conditionModifier:o,conditionValue:f,...l})}render(e){return n.jsx(br,{condition:this,...e},this.id)}}const ia={date:We,time:oi,number:Ye,boolean:Je,select:ni,string:ti,url:li,text:ri,upload:ai,qr:ii,"multi-string":Xe,"multi-select":Ke,radio:Re,"checkbox-list":He,"pass-fail":Qe,otp:Ze,rating:ei},Mr=(i,e)=>{if(i.type!==e.type)throw new Error(`field and condition type mismatch ${i.type} !== ${e.type}`);return ia[e.type].deserialize(e,i)},qi=(i,e)=>{const t=gn(i,e),r={};for(const o of i)r[o.identifier]=o;return t.map(o=>Mr(r[o.fieldId],o))},xr=(i,e)=>Cn(i,e).map(r=>r.serialize()),gn=(i,e)=>{const t=new Set(i.map(r=>r.identifier));return e.filter(r=>t.has(r.fieldId))},Cn=(i,e)=>{const t=new Set(i.map(r=>r.identifier));return e.filter(r=>t.has(r.field.identifier))},Oi=i=>Ee[i.type].deserialize(i);function na(i){return i.map(Oi)}function Ir(i){return i.type==="section"?W.deserialize(i):Oi(i)}const _i=i=>i.map(Ir),Vn=i=>Ee[i.type].fromConfig(i),qr=i=>i.map(e=>Vn(e)),Or=i=>i.type==="section"?W.fromConfig(i):Vn(i),_r=i=>i.map(Or),yn=i=>Ee[i.type].deserializeConfig(i),Tr=i=>i.map(yn),Er=i=>i.type==="section"?W.deserializeConfig(i):yn(i),Lr=i=>i.map(Er),vn=i=>Ee[i.type].serializeConfig(i),Br=i=>i.map(vn),Ar=i=>i.type==="section"?W.serializeConfig(i):vn(i),$r=i=>i.map(Ar);function ta(i){const e={};for(const t of i)e[t.identifier]=t;return e}function Dr(i,e,t=!0){const r=t?Ti(i,e):e,o={};for(const l of i){if(!(l.identifier in r))continue;const s=r[l.identifier];o[l.identifier]=l.serializeValue(s)}return o}function Pr(i,e,t=!0){const r=t?zn(i,e):e,o={};for(const l of i){if(!(l.identifier in r))continue;const s=r[l.identifier];o[l.identifier]=l.deserializeValue(s)}return o}function Ti(i,e){const t={};for(const r of i){if(!(r.identifier in e))continue;const o=e[r.identifier];r.isValue(o)&&(t[r.identifier]=r.cleanValue(o))}return t}function zn(i,e){const t={};for(const r of i){if(!(r.identifier in e))continue;const o=e[r.identifier];r.isSerializedValue(o)&&(t[r.identifier]=r.cleanSerializedValue(o))}return t}function jr(i,e){const t=Ti(i,e),r={},o={};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;o[l.identifier]=s,r[l.identifier]=[];break;case"pass-fail":if(!l.isValue(s))break;o[l.identifier]=s.files,r[l.identifier]={...s,files:[]};break;default:r[l.identifier]=e[l.identifier]}}return[r,o]}function Ur(i,e,t){const r={};for(const o of i){if(!(o.identifier in e))continue;const l=e[o.identifier];switch(o.type){case"upload":if(!o.isValue(l))break;r[o.identifier]=t[o.identifier]??[];break;case"pass-fail":if(!o.isValue(l))break;r[o.identifier]={...l,files:t[o.identifier]??[]};break;default:if(!o.isValue(l))break;r[o.identifier]=l}}return r}const kr=(i,e)=>{const t={};for(const r of i){const o=e[r.identifier];t[r.identifier]=o!==void 0?o:r.blankValue()}return t},Gr=(i,e,t)=>{const r={};for(const o of i){const l=e[o.identifier],s=t[o.identifier];o.areValuesEqual(l,s)||(r[o.identifier]=s)}return r},Jr=(i,e,t)=>{const r={};for(const o of i){const l=e[o.identifier],s=t[o.identifier];o.areValuesEqual(l,s)&&(r[o.identifier]=s)}return r},Sn=(i,e,t)=>i.every(r=>{const o=e[r.identifier],l=t[r.identifier];return r.areValuesEqual(o,l)}),wn=i=>{const e={};for(const t of i)e[t.identifier]=t.blankValue();return e},Hr=(i,e)=>Sn(i,e,wn(i)),ra=R.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),Ei=R.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),Wr=d.memo(i=>{const{fieldSection:e}=i,{label:t,description:r}=e,o=Y.useWatch(),{fieldSchema:l,size:s}=d.use(L),f=d.useMemo(()=>l.getFieldSections(),[l]),u=d.useMemo(()=>f.findIndex(({identifier:g})=>g===e.identifier),[f,e.identifier]),h=d.useMemo(()=>f.filter(g=>e.identifier in g.conditions),[f,e.identifier]),p=d.useMemo(()=>h.length===0?!0:h.some(g=>{const C=g.getConditions(e.identifier);return new Ii(C).applyConditions(o)}),[h,e,o]),m=pi(e.fields);return p?n.jsxs(n.Fragment,{children:[u!==0?n.jsx(a.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(a.Heading,{size:s,children:t}),r&&n.jsx(a.Text,{accentColor:"base",size:s,children:r})]})}),n.jsx("div",{className:Ei({size:s}),children:m})]})]}):null});Wr.displayName="FieldSectionLayout";class W extends ze{type="section";label;description;conditions;fields=[];constructor(e){const{label:t=null,description:r=null,fields:o,conditions:l={},...s}=e;super(s),this.label=t,this.description=r,this.fields=this.initFields(o),this.conditions=this.initConditions(l)}serialize(){return{...super.serialize(),label:this.label,description:this.description,fields:this.fields.map(e=>e.serialize()),conditions:Object.fromEntries(Object.entries(this.conditions).map(([e,t])=>[e,t.map(r=>r.serialize())]))}}static deserialize=e=>{const t=e.fields.map(Oi),r={};for(const[o,l]of Object.entries(e.conditions))r[o]=qi(t,l);return new W({...e,fields:t,conditions:r})};static fromConfig=e=>{const t=qr(e.fields),r={};for(const[o,l]of Object.entries(e.conditions??{}))r[o]=qi(t,l);return new W({...e,fields:t,conditions:r})};static deserializeConfig(e){const{label:t,description:r,fields:o,conditions:l,...s}=e;return{...ze._deserializeConfig(s),label:t,description:r,fields:Tr(o),conditions:l}}static serializeConfig(e){const{label:t,description:r,fields:o,conditions:l,...s}=e;return{...ze._serializeConfig(s),label:t??null,description:r,fields:Br(o),conditions:l??{}}}config(){return{...super.config(),label:this.label,description:this.description,fields:this.fields.map(e=>e.config()),conditions:Object.fromEntries(Object.entries(this.conditions).map(([e,t])=>[e,t.map(r=>r.serialize())]))}}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(F.v4()))})}setOptions(e){"label"in e&&(this.label=e.label??null),"description"in e&&(this.description=e.description??null),"fields"in e&&e.fields!==void 0&&(this.fields=e.fields),"conditions"in e&&(this.conditions=e.conditions??{}),super.setOptions(e)}getErrors(e){const t={};for(const r of this.fields){const o=r.getError(e[r.identifier]);o&&(t[r.identifier]=o)}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],[o]=r.splice(e,1);r.splice(t,0,o),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,o]of Object.entries(this.conditions))t[r]=o.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(o=>o.id));this.conditions=this.initConditions({...this.conditions,[e]:(this.conditions[e]??[]).filter(o=>!r.has(o.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(Wr,{fieldSection:this})}}const ne=d.createContext({}),Li=d.memo(i=>{const{children:e,variant:t,size:r,accentColor:o,onSelectFieldType:l,...s}=i,f=d.useMemo(()=>{const u={[q.Assessment]:[],[q.Capture]:[],[q.Numeric]:[],[q.Selection]:[],[q.Temporal]:[],[q.Text]:[],[q.Verification]:[]};for(const h of St){const{group:p}=T[h];u[p].push(h)}return u},[]);return n.jsxs(a.Menu.Root,{...s,children:[n.jsx(a.Menu.ClickTrigger,{children:e}),n.jsx(a.Menu.Content,{variant:t,size:r,accentColor:o,children:n.jsx(a.Menu.Scroll,{children:Object.entries(f).map(([u,h])=>{const{name:p}=wt[u];return h.length===0?null:n.jsxs(a.Menu.Group,{children:[n.jsx(a.Menu.Label,{children:p}),h.map(m=>n.jsx(Kr,{fieldType:m,onSelectFieldType:l},m))]},u)})})})]})});Li.displayName="CreateFieldDropdownMenu";const Kr=d.memo(i=>{const{fieldType:e,onSelectFieldType:t}=i,r=d.useCallback(()=>{t(e)},[e,t]),{icon:o,name:l}=T[e];return n.jsxs(a.Menu.Item,{onSelect:r,children:[n.jsx(a.LuIcon,{icon:o}),n.jsx(a.Text,{className:"truncate",children:l})]})});Kr.displayName="CreateFieldDropdownMenuItem";const Bi=i=>{switch(i){case"text":return new pe({label:"",required:!1,identifier:F.v4()});case"boolean":return new le({label:"",required:!1,identifier:F.v4()});case"number":return new J({label:"",required:!1,identifier:F.v4()});case"date":return new we({label:"",required:!1,identifier:F.v4()});case"time":return new Me({label:"",required:!1,identifier:F.v4()});case"string":return new he({label:"",required:!1,identifier:F.v4()});case"url":return new xe({label:"",required:!1,identifier:F.v4()});case"select":return new re({label:"",options:[],required:!1,identifier:F.v4()});case"multi-string":return new ae({label:"",required:!1,identifier:F.v4()});case"multi-select":return new ie({label:"",options:[],required:!1,identifier:F.v4()});case"upload":return new ge({label:"",required:!1,identifier:F.v4()});case"qr":return new Ne({label:"",required:!1,identifier:F.v4()});case"radio":return new ue({label:"",options:[],required:!1,identifier:F.v4()});case"checkbox-list":return new ee({label:"",options:[],required:!1,identifier:F.v4()});case"pass-fail":return new ce({label:"",required:!1,identifier:F.v4(),showNotesAndFilesOn:["fail"]});case"otp":return new se({label:"",validationType:"none",required:!1,identifier:F.v4(),length:6});case"rating":return new fe({label:"",required:!1,identifier:F.v4(),maxRating:5})}},si=i=>{switch(i.type){case"text":return new ri({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"boolean":return new Je({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"number":return new Ye({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"date":return new We({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"time":return new oi({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"string":return new ti({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"url":return new li({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"select":return new ni({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"multi-string":return new Xe({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"multi-select":return new Ke({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"upload":return new ai({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"qr":return new ii({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"radio":return new Re({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"checkbox-list":return new He({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"pass-fail":return new Qe({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"otp":return new Ze({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"rating":return new ei({id:F.v4(),conditionValue:void 0,conditionModifier:"equals",field:i})}},Xr=(i,e)=>{switch(i){case"checkbox-list":return ee.getFieldCreationSchema(e);case"multi-select":return ie.getFieldCreationSchema(e);case"number":return J.getFieldCreationSchema(e);case"radio":return ue.getFieldCreationSchema(e);case"select":return re.getFieldCreationSchema(e);case"string":return he.getFieldCreationSchema(e);case"text":return pe.getFieldCreationSchema(e);case"upload":return ge.getFieldCreationSchema(e);case"pass-fail":return ce.getFieldCreationSchema(e);case"otp":return se.getFieldCreationSchema(e);case"rating":return fe.getFieldCreationSchema(e);default:return}},Yr=d.memo(i=>{const{popoverInputs:e,...t}=i;return n.jsxs(a.Popover.Root,{children:[n.jsx(a.Popover.Trigger,{asChild:!0,children:n.jsxs(a.Button,{variant:"soft",type:"button",size:"sm",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:ko}),"Settings"]})}),n.jsx(a.Popover.Content,{size:"sm",...t,children:n.jsx("div",{className:R.cx("flex w-full max-w-[350px] flex-col",Ei({size:"sm"})),children:e})})]})});Yr.displayName="FieldSettingsPopover";const Zr=d.memo(i=>{const{parentPath:e,fieldIndex:t,field:r}=i,o=hi(),{disableRequiredFields:l}=d.use(ne),[s,f]=d.useState(void 0);In.useActiveEffect(y=>{const I=r.image;if(I){if(!(I instanceof Promise)){f(I);return}f(void 0),I.then(E=>{y()&&f(E)})}},[r.image]);const u=d.useCallback(()=>{r.setOptions({image:void 0})},[r]),[h,p]=d.useMemo(()=>{const y=[],I=[],E=Xr(r.type,`${e}.${t}`)??[];for(const G of E)G.showDirectly?y.push(G.field):I.push(G.field);return[y,I]},[r,e,t]),m=pi(h),g=pi(p),C=p.length>0,z=d.useCallback(()=>{s&&o(()=>({file:s}))},[o,s]),S=d.useCallback(y=>{r.setOptions({required:!!y})},[r]),w=d.useCallback(y=>{r.setOptions({label:y.target.value})},[r]),v=d.useCallback(y=>{r.setOptions({description:y.target.value})},[r]),{icon:x,name:O}=T[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(a.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[n.jsx(a.LuIcon,{icon:x}),O]}),!l&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(a.Checkbox.Root,{checked:r.required,onCheckedChange:S,size:"sm",children:n.jsx(a.Checkbox.Indicator,{children:n.jsx(a.LuIcon,{icon:H})})}),n.jsx(a.Text,{size:"sm",accentColor:"base",children:"Required"})]})]}),C&&n.jsx(Yr,{popoverInputs:g,align:"end"})]}),s&&n.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[n.jsx(Oe,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:s,onClick:z}),n.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:u,size:"sm",children:n.jsx(a.LuIcon,{icon:ve})})]}),n.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[n.jsx(a.Input.Root,{variant:"outline",size:"md",children:n.jsx(a.Input.Field,{placeholder:"Enter your question",value:r.label??"",onChange:w,maxLength:200})}),n.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&&n.jsx("div",{className:R.cx("w-full",Ei({size:"sm"})),children:m})]})});Zr.displayName="FieldBuilder";const Fn=d.memo(i=>{const{field:e,fieldSection:t,fieldIndex:r,sectionIndex:o}=i,l=d.useRef(null),s=`fields.${o}.fields`,f=d.useCallback(S=>{t.addField(Bi(S),r+1)},[r,t]),u=d.useCallback(()=>{t.addField(e.duplicate(F.v4()))},[e,t]),h=d.useCallback(S=>{const w=S==="up"?o-1:o+1;t.moveField(r,w)},[t,r,o]),p=d.useCallback(S=>{const{files:w}=S.target;if(!w||w.length!==1)return;const v=w.item(0);v&&e.setOptions({image:v})},[e]),m=d.useCallback(()=>{h("up")},[h]),g=d.useCallback(()=>{h("down")},[h]),C=d.useCallback(()=>{l.current?.click()},[]),z=d.useCallback(()=>{t.removeField(e)},[e,t]);return n.jsxs(a.Card,{className:"flex w-full items-center justify-between gap-4",size:"sm",children:[n.jsx(Zr,{fieldIndex:r,field:e,parentPath:s}),n.jsxs(a.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[n.jsx(Li,{onSelectFieldType:f,size:"sm",children:n.jsx(a.IconButton,{type:"button",children:n.jsx(a.LuIcon,{icon:Z})})}),n.jsx(a.IconButton,{type:"button",onClick:m,children:n.jsx(a.LuIcon,{icon:kn})}),n.jsx(a.IconButton,{type:"button",onClick:g,children:n.jsx(a.LuIcon,{icon:Un})}),n.jsx(a.IconButton,{type:"button",onClick:u,children:n.jsx(a.LuIcon,{icon:Di})}),n.jsx(a.IconButton,{type:"button",onClick:C,children:n.jsx(a.LuIcon,{icon:Pn})}),n.jsx(a.IconButton,{type:"button",onClick:z,children:n.jsx(a.LuIcon,{icon:ve})})]}),n.jsx("input",{className:"hidden",ref:l,type:"file",accept:"image/*",onChange:p})]})});Fn.displayName="FieldBuilderWithActions";const bn=d.memo(i=>{const{children:e,variant:t,size:r,accentColor:o,fields:l,onSelectField:s,onSelectAllFields:f,...u}=i,h=d.useCallback(()=>{f?.(l)},[f,l]);return n.jsxs(a.Menu.Root,{...u,children:[n.jsx(a.Menu.ClickTrigger,{children:e}),n.jsx(a.Menu.Content,{variant:t,size:r,accentColor:o,children:n.jsxs(a.Menu.Scroll,{children:[f?n.jsx(a.Menu.Item,{onSelect:h,children:"Select all"}):null,l.map(p=>n.jsx(Qr,{field:p,onSelectField:s},p.identifier))]})})]})});bn.displayName="FieldDropdownMenu";const Qr=d.memo(i=>{const{field:e,onSelectField:t}=i,r=d.useCallback(()=>{t(e)},[e,t]);return n.jsxs(a.Menu.Item,{onSelect:r,children:[n.jsx(a.LuIcon,{icon:T[e.type].icon}),e.label||$]})});Qr.displayName="FieldDropdownMenuItem";const Rr=d.memo(i=>{const{children:e,variant:t,size:r,accentColor:o,fieldSections:l,onSelectFieldSection:s,...f}=i;return n.jsxs(a.Menu.Root,{...f,children:[n.jsx(a.Menu.ClickTrigger,{children:e}),n.jsx(a.Menu.Content,{variant:t,size:r,accentColor:o,children:l.map(u=>n.jsx(eo,{fieldSection:u,onSelectFieldSection:s},u.identifier))})]})});Rr.displayName="FieldSectionDropdownMenu";const eo=d.memo(i=>{const{fieldSection:e,onSelectFieldSection:t}=i,r=d.useCallback(()=>{t(e)},[e,t]);return n.jsxs(a.Menu.Item,{onSelect:r,children:[n.jsx(a.LuIcon,{icon:jn}),e.label||zi]})});eo.displayName="FieldSectionDropdownMenuItem";const io=d.memo(i=>{const{id:e,sourceX:t,sourceY:r,targetX:o,targetY:l,style:s,markerEnd:f,data:u}=i,{targetSection:h,sourceSection:p,layoutDirection:m}=u,g=d.useMemo(()=>p.getConditions(h.identifier),[p,h.identifier]),C=d.useCallback(()=>{p.removeConditional(h.identifier)},[p,h.identifier]),z=d.useCallback(y=>{p.addCondition(h.identifier,si(y))},[p,h.identifier]),S=d.useCallback(y=>{p.addConditions(h.identifier,y.map(si))},[p,h.identifier]),w=d.useCallback(y=>{p.removeCondition(h.identifier,y)},[p,h.identifier]),[v,x,O]=_.getBezierPath({sourceX:t,sourceY:r,sourcePosition:m==="LR"?_.Position.Right:_.Position.Bottom,targetX:o,targetY:l,targetPosition:m==="LR"?_.Position.Left:_.Position.Top});return n.jsxs(n.Fragment,{children:[n.jsx(_.BaseEdge,{id:e,path:v,style:s,markerEnd:f,labelX:x,labelY:O}),n.jsx(_.EdgeLabelRenderer,{children:n.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(${x}px, ${O}px)`},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(a.Text,{size:"xs",className:"max-w-[280px] truncate",children:p.label||zi}),n.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[n.jsx(bn,{size:"sm",fields:p.fields,onSelectField:z,onSelectAllFields:S,children:n.jsx(a.IconButton,{"aria-label":"Add condition",type:"button",variant:"surface",size:"xs",accentColor:"base",children:n.jsx(a.LuIcon,{icon:Z})})}),n.jsxs(a.Tooltip.Root,{children:[n.jsx(a.Tooltip.Trigger,{asChild:!0,children:n.jsx(a.IconButton,{"aria-label":"Remove conditional logic",type:"button",variant:"surface",size:"xs",accentColor:"base",color:"danger",onClick:C,children:n.jsx(a.LuIcon,{icon:ve})})}),n.jsx(a.Tooltip.Content,{size:"sm",children:"Remove conditional logic"})]})]})]}),g.length>0&&n.jsx("div",{className:"flex h-max w-full flex-col flex-wrap gap-1",children:g.map(y=>n.jsx(d.Fragment,{children:y.render({onRemove:w})},y.id))})]})})]})});io.displayName="FieldSectionConditionEdgeComponent";const no=d.memo(i=>{const{data:e,selected:t}=i,{fieldSection:r,index:o,layoutDirection:l}=e,{fieldSchema:s}=d.use(ne),f=d.useCallback(()=>{s.removeFieldSection(r)},[s,r]),u=d.useCallback(C=>{r.addField(Bi(C))},[r]),h=d.useCallback(()=>{const C=new W({identifier:F.v4(),fields:[]});s.addFieldSection(C),r.addConditional(C.identifier)},[s,r]),p=d.useCallback(()=>{s.addFieldSection(r.duplicate(F.v4()))},[s,r]),m=d.useCallback(C=>{r.setOptions({label:C.target.value})},[r]),g=d.useCallback(C=>{r.setOptions({description:C.target.value})},[r]);return n.jsxs(a.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(a.Input.Root,{variant:"outline",size:"md",accentColor:"base",children:n.jsx(a.Input.Field,{placeholder:"Enter a section label (optional)",value:r.label??"",onChange:m,maxLength:200})}),n.jsx(a.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:r.description??"",onChange:g,maxLength:1e3,resize:"vertical",size:"md"})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(a.Text,{weight:"bold",children:"Fields"}),n.jsx(Li,{onSelectFieldType:u,size:"sm",children:n.jsxs(a.Button,{type:"button",variant:"soft",size:"sm",accentColor:"base",children:[n.jsx(a.LuIcon,{icon:Z})," Add field"]})})]}),n.jsx("div",{className:"flex flex-col gap-3",children:r.fields.map((C,z)=>n.jsx(Fn,{field:C,fieldSection:r,fieldIndex:z,sectionIndex:o},C.identifier))})]}),n.jsx(_.NodeToolbar,{isVisible:!0,position:_.Position.Right,align:"start",offset:8,onMouseDown:a.stopPropagation,children:n.jsx(a.Card,{variant:"surface",className:"bg-(--base-2) flex flex-col items-center gap-1 p-1",size:"xs",onClick:a.stopPropagation,children:n.jsxs(a.ButtonGroup,{className:"flex flex-col gap-2",variant:"surface",size:"xs",accentColor:"base",children:[n.jsx(a.IconButton,{type:"button",onClick:h,children:n.jsx(a.LuIcon,{icon:Eo})}),n.jsx(a.IconButton,{type:"button",onClick:p,children:n.jsx(a.LuIcon,{icon:Di})}),n.jsx(a.IconButton,{type:"button",onClick:f,children:n.jsx(a.LuIcon,{icon:ve})})]})})}),n.jsx(_.Handle,{type:"target",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:l==="LR"?_.Position.Left:_.Position.Top}),n.jsx(_.Handle,{type:"source",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:l==="LR"?_.Position.Right:_.Position.Bottom})]})});no.displayName="CustomNode";const oa={fieldSection:no},aa={fieldSectionCondition:io},la=(i,e,t)=>{const r=new qn.graphlib.Graph().setDefaultEdgeLabel(()=>({}));return r.setGraph({rankdir:t,nodesep:200,edgesep:500,ranksep:500}),e.forEach(o=>r.setEdge(o.source,o.target,{width:500,height:200,labelpos:"c"})),i.forEach(o=>r.setNode(o.id,{...o,width:o.measured?.width??0,height:o.measured?.height??0})),qn.layout(r),[i.map(o=>{const l=r.node(o.id),s=l.x-(o.measured?.width??0)/2,f=l.y-(o.measured?.height??0)/2;return{...o,position:{x:s,y:f}}}),e]},sa={hideAttribution:!0},to=d.memo(()=>{const{errors:i}=Y.useFormState(),{handleSubmit:e}=Y.useFormContext(),{onSave:t,onCancel:r}=d.use(ne),{fieldSchema:o}=d.use(ne),l=d.useRef(null),[s,f]=d.useState(),[u,h]=d.useState("TB");d.useLayoutEffect(()=>{l.current&&l.current.classList.remove("light")},[]);const p=d.useMemo(()=>o.fieldSections.map((D,K)=>({id:D.identifier,position:{x:0,y:0},data:{index:K,fieldSection:D,layoutDirection:u},draggable:!0,type:"fieldSection"})),[o.fieldSections,u]),m=d.useMemo(()=>{const D=[],K={};for(const X of o.fieldSections)K[X.identifier]=X;for(const X of o.fieldSections){const di=X.conditions;for(const[ci,pa]of Object.entries(di))D.push({id:`${X.identifier}-${ci}`,source:X.identifier,target:ci,data:{targetSection:K[ci],sourceSection:X,layoutDirection:u},animated:pa.length>0,markerEnd:_.MarkerType.Arrow,style:{strokeWidth:2,stroke:"var(--base-a8)"},type:"fieldSectionCondition"})}return D},[o.fieldSections,u]),[g,C,z]=_.useNodesState(p),[S,w,v]=_.useEdgesState(m);d.useEffect(()=>{C(p)},[p,C]),d.useEffect(()=>{w(m)},[m,w]);const[x,O]=d.useMemo(()=>la(g,S,u),[S,u,g]),y=d.useCallback(()=>{o.addFieldSection(new W({identifier:F.v4(),fields:[]}))},[o]),I=d.useCallback(D=>{const{source:K,target:X}=D,di=o.fieldSections.find(({identifier:ci})=>ci===K);di.setOptions({conditions:{...di.conditions,[X]:[]}})},[o.fieldSections]),E=d.useCallback(D=>{const K=o.getSectionDependencyGraph();return!Mn.willCreateCycle(K,D.source,D.target)},[o]),G=d.useCallback(()=>{s?.zoomOut()},[s]),te=d.useCallback(()=>{s?.zoomIn()},[s]),De=d.useCallback(()=>{s?.fitView()},[s]);return n.jsxs("form",{className:"flex size-full flex-col gap-4",onSubmit:e(t),children:[n.jsxs(a.Card,{className:"relative size-full",variant:"outline",children:[n.jsx(_.ReactFlow,{ref:l,onInit:f,nodes:x,onNodesChange:z,edges:O,onEdgesChange:v,nodeTypes:oa,edgeTypes:aa,onConnect:I,attributionPosition:"bottom-left",fitView:!0,minZoom:0,isValidConnection:E,proOptions:sa}),n.jsx(_.Panel,{position:"top-left",children:n.jsx(a.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:n.jsxs(a.Button,{type:"button",variant:"surface",onClick:y,children:[n.jsx(a.LuIcon,{icon:Z})," Add section"]})})}),n.jsxs(_.Panel,{position:"top-right",className:"flex flex-col items-center gap-2",children:[n.jsxs(a.ToggleGroup.Root,{className:"flex flex-col",type:"single",accentColor:"base",size:"sm",value:u,onValueChange:h,children:[n.jsx(a.ToggleGroup.IconItem,{className:"rounded-b-none",value:"LR",type:"button",children:n.jsx(a.LuIcon,{icon:Fo})}),n.jsx(a.ToggleGroup.IconItem,{className:"rounded-t-none",value:"TB",type:"button",children:n.jsx(a.LuIcon,{icon:wo})})]}),n.jsx(a.Separator,{size:"sm"}),n.jsxs(a.ButtonGroup,{className:"flex flex-col",size:"sm",accentColor:"base",variant:"soft",children:[n.jsx(a.IconButton,{className:"rounded-b-none",onClick:te,type:"button",children:n.jsx(a.LuIcon,{icon:Z})}),n.jsx(a.IconButton,{onClick:G,radius:"none",type:"button",children:n.jsx(a.LuIcon,{icon:fi})}),n.jsx(a.IconButton,{className:"rounded-t-none",onClick:De,type:"button",children:n.jsx(a.LuIcon,{icon:Jo})})]})]}),n.jsx(_.Panel,{position:"bottom-right",children:n.jsxs(a.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[r&&n.jsx(a.Button,{type:"button",variant:"soft",accentColor:"base",onClick:r,children:"Cancel"}),n.jsx(a.Button,{type:"submit",variant:"surface",children:"Save"})]})})]}),!!i.fields?.message&&n.jsx(a.Text,{size:"xs",accentColor:"danger",children:i.fields.message})]})});to.displayName="FormBuilderFlowBuilder";const da=(i,e,t={})=>{const{conditions:r=!1}=t,o=i.get(e.identifier);if(!o)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 h=F.v4();return l.set(u.identifier,h),{...u,identifier:h}}),f={};if(r)for(const[u,h]of Object.entries(e.conditions??{})){const p=i.get(u);if(!p)continue;const m=h.map(g=>{const C=l.get(g.fieldId);if(!C)throw new Error(`Serialized condition referencing undefined field with identifier: ${g.fieldId}`);return{...g,fieldId:C}});f[p]=m}return{...e,identifier:o,conditions:f,fields:s}},ca=(i,e={})=>{const t=new Map(i.map(r=>[r.identifier,F.v4()]));return i.map(r=>da(t,r,e))},Nn=(i,e)=>{const t={},r=i.filter(o=>o instanceof W);for(const o of i)if(o instanceof W){const l=r.filter(f=>o.identifier in f.conditions);if(l.length>0&&!l.some(f=>{const u=f.getConditions(o.identifier);return new Ii(u).applyConditions(e)}))continue;const s=o.getErrors(e);Object.assign(t,s)}else{if(!(o instanceof N))throw new Error("Invalid field type");const l=o.identifier,s=o.getError(_n(e,l));s&&go(t,l,s)}return t},ua=async i=>{const e={};for(const t of i){const{fields:r}=t;for(const o of r)if(o.image)if(o.image instanceof Promise)try{e[o.identifier]=await o.image}catch(l){console.error("Failed to get image from promise",l)}else e[o.identifier]=o.image}return e};async function fa(i){const e={};for(const[t,r]of Object.entries(i))e[t]=await Promise.all(r);return e}class ye extends je{fieldSections;constructor(e){super(),this.fieldSections=this.initFields(e)}serialize(){return this.fieldSections.map(e=>e.serialize())}config(){return this.fieldSections.map(e=>e.config())}static deserialize(e){return new ye(_i(e))}static fromConfig(e){return new ye(_r(e))}static serializeConfig(e){return $r(e)}static deserializeConfig(e){return Lr(e)}static reseedFieldSections(e,t){return ca(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],[o]=r.splice(e,1);r.splice(t,0,o),this.fieldSections=this.initFields(r),this.notify(this)}getSectionDependencyGraph(){const e=new po.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])),o=[];return mo.bfsFromNode(t,e,(l,s,f)=>{o.push(r.get(l))},{mode:"in"}),o}cleanValues(e){return Ti(this.getFields(),e)}cleanSerializedValues(e){return zn(this.getFields(),e)}deserializeValues(e,t){return Pr(this.getFields(),e,t)}serializeValues(e,t){return Dr(this.getFields(),e,t)}initializeValues(e){return kr(this.getFields(),e)}validateValues(e){return Nn(this.getFieldSections(),e)}areValuesValid(e){return Object.keys(this.validateValues(e)).length===0}deserializeConditions(e){return qi(this.getFields(),e)}cleanConditions(e){return Cn(this.getFields(),e)}serializeConditions(e){return xr(this.getFields(),e)}cleanSerializedConditions(e){return gn(this.getFields(),e)}changedFieldValues(e,t){return Gr(this.getFields(),e,t)}unchangedFieldValues(e,t){return Jr(this.getFields(),e,t)}areValuesEqual(e,t){return Sn(this.getFields(),e,t)}areValuesBlank(e){return Hr(this.getFields(),e)}blankValues(){return wn(this.getFields())}extractFilesAndPromisesFromFieldValues(e){return jr(this.getFields(),e)}insertFilesAndPromisesToFieldValues(e,t){return Ur(this.getFields(),e,t)}}const ro=d.memo(i=>{const{sourceFieldSection:e,targetFieldSection:t}=i,r=d.useMemo(()=>e.getConditions(t.identifier),[e,t.identifier]),o=d.useCallback(()=>{e.removeConditional(t.identifier)},[e,t.identifier]),l=d.useCallback(u=>{e.addCondition(t.identifier,si(u))},[e,t.identifier]),s=d.useCallback(u=>{e.addConditions(t.identifier,u.map(si))},[e,t.identifier]),f=d.useCallback(u=>{e.removeCondition(t.identifier,u)},[e,t.identifier]);return n.jsxs(a.Card,{className:"flex flex-col gap-2",size:"sm",children:[n.jsxs(a.ButtonGroup,{className:"flex justify-between gap-2",size:"sm",accentColor:"base",variant:"soft",children:[n.jsxs(a.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[n.jsx(a.LuIcon,{icon:jn}),e.label??zi]}),n.jsx(a.IconButton,{type:"button",onClick:o,variant:"ghost",children:n.jsx(a.LuIcon,{icon:ve})})]}),n.jsxs("div",{className:"flex h-max w-full flex-wrap gap-2",children:[r.map(u=>u.render({onRemove:f})),n.jsx(bn,{fields:e.fields,onSelectField:l,onSelectAllFields:s,align:"start",size:"sm",children:n.jsx(a.IconButton,{type:"button",size:"sm",variant:"soft",accentColor:"base",children:n.jsx(a.LuIcon,{icon:Z})})})]})]})});ro.displayName="FieldSectionConditionalItem";const oo=d.memo(i=>{const{fieldSection:e}=i,{fieldSchema:t}=d.use(ne),r=d.useMemo(()=>t.fieldSections.filter(u=>e.identifier in u.conditions),[t.fieldSections,e.identifier]),o=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]),f=d.useMemo(()=>{const u=t.getSectionDependencyGraph();return t.fieldSections.filter(h=>!Mn.willCreateCycle(u,h.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(a.Input.Root,{variant:"outline",size:"md",children:n.jsx(a.Input.Field,{placeholder:"Enter a section label (optional)",value:e.label??"",onChange:l,maxLength:200})}),n.jsx(a.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:e.description??"",onChange:s,maxLength:1e3,resize:"vertical",size:"md"})]}),n.jsx(a.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(a.Text,{accentColor:"base",children:"Conditions"}),n.jsx(Rr,{fieldSections:f,onSelectFieldSection:o,children:n.jsxs(a.Button,{type:"button",variant:"soft",size:"sm",className:"w-max",children:[n.jsx(a.LuIcon,{icon:Z}),"Add condition"]})})]}),r.map(u=>n.jsx(ro,{sourceFieldSection:u,targetFieldSection:e},u.identifier))]}),n.jsx(a.Separator,{size:"full"})]})});oo.displayName="FieldSectionBuilder";const ao=d.memo(i=>{const{fieldSection:e,sectionIndex:t}=i,{fieldSchema:r}=d.use(ne),o=a.useAlertDialog(),l=d.useCallback(()=>{r.removeFieldSection(e)},[r,e]),s=d.useCallback(S=>{const w=S==="up"?t-1:t+1;r.moveFieldSection(t,w)},[r,t]),f=d.useCallback(()=>{r.addFieldSection(e.duplicate(F.v4()))},[r,e]),u=d.useCallback(S=>{e.addField(Bi(S))},[e]),h=d.useCallback(()=>{s("up")},[s]),p=d.useCallback(()=>{s("down")},[s]),m=d.useCallback(async()=>{const S=[e.serialize()],w=ye.reseedFieldSections(S,{conditions:!1}),v=JSON.stringify(w);await navigator.clipboard.writeText(v),a.toast.success({title:"Section copied"})},[e]),g=d.useCallback(async()=>{const w=r.getDependenciesOfSection(e.identifier).map(O=>O.serialize()),v=ye.reseedFieldSections(w,{conditions:!0}),x=JSON.stringify(v);await navigator.clipboard.writeText(x),a.toast.success({title:"Section copied"})},[e,r]),C=d.useCallback(async()=>{const S=r.getDependenciesOfSection(e.identifier),w=S.length>1,v=S.length-1;w?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()},[e,r,o,g,m]),z=d.useCallback(async()=>{let S="";try{S=await navigator.clipboard.readText()}catch{a.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const w=S.trim();if(!w){a.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}try{const v=JSON.parse(w),x=On.JSONFieldSectionSchema.array().parse(v),O=_i(x);if(O.length===0){a.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}for(const[y,I]of O.entries())r.addFieldSection(I,t+1+y);a.toast.success({title:"Sections pasted",description:"Serialized JSON imported successfully."})}catch(v){console.error(v),a.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."})}},[r,t]);return n.jsxs(a.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(oo,{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(a.Text,{accentColor:"base",size:"md",children:"Fields"}),n.jsx(Li,{onSelectFieldType:u,size:"sm",children:n.jsxs(a.Button,{type:"button",variant:"soft",size:"sm",children:[n.jsx(a.LuIcon,{icon:Z})," Add field"]})})]}),e.fields.map((S,w)=>n.jsx(Fn,{field:S,fieldSection:e,fieldIndex:w,sectionIndex:t},S.identifier))]})]}),n.jsxs(a.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[n.jsx(a.IconButton,{type:"button",onClick:h,children:n.jsx(a.LuIcon,{icon:kn})}),n.jsx(a.IconButton,{type:"button",onClick:p,children:n.jsx(a.LuIcon,{icon:Un})}),n.jsxs(a.Menu.Root,{align:"end",children:[n.jsx(a.Menu.ClickTrigger,{children:n.jsx(a.IconButton,{type:"button",children:n.jsx(a.LuIcon,{icon:Dn})})}),n.jsxs(a.Menu.Content,{size:"sm",children:[n.jsxs(a.Menu.Item,{onSelect:f,children:[n.jsx(a.LuIcon,{icon:Di}),"Duplicate section"]}),n.jsxs(a.Menu.Item,{onSelect:C,children:[n.jsx(a.LuIcon,{icon:Bn}),"Copy JSON"]}),n.jsxs(a.Menu.Item,{onSelect:z,children:[n.jsx(a.LuIcon,{icon:An}),"Paste JSON"]}),n.jsxs(a.Menu.Item,{onSelect:l,children:[n.jsx(a.LuIcon,{icon:ve}),"Delete section"]})]})]})]})]})});ao.displayName="FieldSectionWithActions";const lo=d.memo(()=>{const{handleSubmit:i}=Y.useFormContext(),{errors:e}=Y.useFormState(),{onSave:t,onCancel:r}=d.use(ne),{fieldSchema:o}=d.use(ne),l=d.useCallback(()=>{o.addFieldSection(new W({identifier:F.v4(),fields:[]}))},[o]),s=d.useCallback(async()=>{try{const u=o.serialize(),h=ye.reseedFieldSections(u,{conditions:!0}),p=JSON.stringify(h);await navigator.clipboard.writeText(p),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 u="";try{u=await navigator.clipboard.readText()}catch{a.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const h=u.trim();if(!h){a.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}try{const p=JSON.parse(h),m=On.JSONFieldSectionSchema.array().parse(p),g=_i(m);if(g.length===0){a.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}for(const[C,z]of g.entries())o.addFieldSection(z,o.fieldSections.length+C);a.toast.success({title:"Sections pasted",description:"Serialized JSON imported successfully."})}catch(p){console.error(p),a.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."})}},[o]);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(a.Button,{type:"button",variant:"soft",size:"sm",onClick:s,children:[n.jsx(a.LuIcon,{icon:Bn})," Copy JSON"]}),n.jsxs(a.Button,{type:"button",variant:"soft",size:"sm",onClick:f,children:[n.jsx(a.LuIcon,{icon:An})," Paste JSON"]})]}),o.fieldSections.map((u,h)=>n.jsx(ao,{fieldSection:u,sectionIndex:h},u.identifier)),n.jsxs(a.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:l,children:[n.jsx(a.LuIcon,{icon:Z})," Add section"]})]}),!!e.fields?.message&&n.jsx(a.Text,{size:"xs",accentColor:"danger",children:e.fields.message}),n.jsxs(a.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[r&&n.jsx(a.Button,{type:"button",variant:"soft",accentColor:"base",onClick:r,children:"Cancel"}),n.jsx(a.Button,{type:"submit",variant:"surface",children:"Save"})]})]})});lo.displayName="FormBuilderListBuilder";function so(i){const e=t=>{const r={};for(const[o,l]of Object.entries(t))typeof l=="string"?r[o]={type:"validate",message:l}:r[o]=e(l);return r};return e(i)}const co=d.memo(d.forwardRef((i,e)=>{const{disabled:t=!1,fieldSchema:r,values:o={},onValuesChange:l,onSubmit:s,submitText:f="Submit",hideSubmit:u=!1,cancelText:h,onCancel:p,hideCancel:m=!1,className:g,submitButtonProps:C,cancelButtonProps:z,cancelIcon:S,submitIcon:w,size:v="md"}=i,x=d.useMemo(()=>r.initializeValues(o),[r,o]),O=d.useCallback(D=>{s?.(D)},[s]),y=Y.useForm({values:x,mode:"onBlur",criteriaMode:"all",disabled:t,resolver:D=>{const K=r.validateValues(D),X=so(K);return Object.keys(K).length>0?{values:{},errors:X}:{values:D,errors:{}}}}),I=d.useCallback(D=>{l?.(D)},[l]);d.useEffect(()=>{const{unsubscribe:D}=y.watch((K,{type:X})=>{X==="change"&&I(K)});return()=>{D()}},[y,I]);const E=Wn(r.getFieldSections()),G=d.useMemo(()=>({fieldSchema:r,size:v}),[r,v]),te=!m&&!!p,De=!u;return n.jsx(Y.FormProvider,{...y,children:n.jsx(L,{value:G,children:n.jsxs("form",{ref:e,className:R.cx(g,"flex flex-col gap-4"),onSubmit:y.handleSubmit(O),children:[n.jsx("div",{className:ra({size:v}),children:E}),!t&&(te||De)?n.jsxs(a.ButtonGroup,{className:"flex items-center justify-end gap-2",size:v,children:[te?n.jsxs(a.Button,{accentColor:"base",type:"button",variant:"soft",onClick:p,...z,children:[n.jsx(a.LuIcon,{icon:S??oe}),h]}):null,De?n.jsxs(a.Button,{type:"submit",accentColor:"primary",variant:"surface",...C,children:[n.jsx(a.LuIcon,{icon:w??H}),f]}):null]}):null]})})})})),uo=d.memo(()=>{const{fieldSchema:i}=d.use(ne);return n.jsx(co,{fieldSchema:i,disabled:!1})});uo.displayName="FormBuilderPreview";const fo=d.memo(i=>{const{children:e,initialFields:t,onSave:r,onCancel:o,disableRequiredFields:l=!1}=i,s=d.useCallback(z=>{const S={};(!z.fields||z.fields.length===0)&&(S.fields="At least one field is required.");const w=[];for(const[O,y]of z.fields.entries())for(const[I,E]of y.fields.entries()){const G=Xr(E.type,`fields.${O}.fields.${I}`)?.map(({field:te})=>te)??[];w.push(...G)}const v={};for(const O of w)v[O.identifier]=_n(z,O.identifier);const x=Nn(w,v);return Object.keys(x).length>0&&(S.fields=x.fields),Object.keys(S).length>0&&a.toast.error({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),S},[]),f=d.useMemo(()=>({fields:t??[]}),[t]),u=Y.useForm({values:f,mode:"onSubmit",criteriaMode:"all",reValidateMode:"onSubmit",resolver:z=>{const S=s(z),w=so(S);return Object.keys(S).length>0?{values:{},errors:w}:{values:z,errors:{}}}}),h=d.useCallback(z=>{u.setValue("fields",z.config())},[u]),p=Y.useWatch({control:u.control,compute:z=>z.fields}),m=d.useMemo(()=>{const z=ye.fromConfig(p);return z.observe(h),z},[p,h]),g=d.useMemo(()=>({fieldSchema:m,disableRequiredFields:l,onSave:r,onCancel:o}),[l,r,o,m]),C=d.useMemo(()=>({fieldSchema:m,size:"sm"}),[m]);return n.jsx(ne,{value:g,children:n.jsx(L,{value:C,children:n.jsx(Y.FormProvider,{...u,children:e})})})});fo.displayName="FormBuilderRoot";const ha={Root:fo,FlowBuilder:to,ListBuilder:lo,Preview:uo};c.BaseCondition=j,c.BaseField=N,c.BaseFormElement=ze,c.BaseOptionsField=Q,c.BaseStringField=Se,c.BooleanEqualsConditionModifier=Ft,c.BooleanField=le,c.BooleanFieldCondition=Je,c.BooleanFieldConditionCell=Wt,c.BooleanFieldInput=Ji,c.BooleanNotEqualsConditionModifier=bt,c.CheckboxListField=ee,c.CheckboxListFieldCondition=He,c.CheckboxListFieldConditionCell=Xt,c.ConditionManager=Ii,c.DateAfterConditionModifier=It,c.DateBeforeConditionModifier=xt,c.DateEqualsConditionModifier=Nt,c.DateField=we,c.DateFieldCondition=We,c.DateFieldConditionCell=Zt,c.DateFieldInput=Hi,c.DateNotEqualsConditionModifier=Mt,c.DateRangeInConditionModifier=qt,c.DateRangeNotInConditionModifier=Ot,c.DoesNotHaveFilesConditionModifier=Tt,c.FIELD_TYPES=St,c.FieldSchema=ye,c.FieldSection=W,c.FieldTypeGroup=q,c.FieldTypeToClsMapping=Ee,c.FieldsRenderer=co,c.FileCard=ji,c.FormBuilder=ha,c.HasFilesConditionModifier=_t,c.ImageCard=Wi,c.ImageFile=Oe,c.ImageViewer=ki,c.ImageViewerProvider=Hn,c.InputWithLabel=B,c.MultiSelectField=ie,c.MultiSelectFieldCondition=Ke,c.MultiSelectFieldConditionCell=Rt,c.MultiStringField=ae,c.MultiStringFieldCondition=Xe,c.MultiStringFieldConditionCell=ir,c.NumberEqualsConditionModifier=rn,c.NumberField=J,c.NumberFieldCondition=Ye,c.NumberFieldConditionCell=tr,c.NumberGreaterThanConditionModifier=sn,c.NumberGreaterThanOrEqualsConditionModifier=dn,c.NumberLessThanConditionModifier=an,c.NumberLessThanOrEqualsConditionModifier=ln,c.NumberNotEqualsConditionModifier=on,c.NumberRangeInConditionModifier=cn,c.NumberRangeNotInConditionModifier=un,c.OTPField=se,c.OTPFieldCondition=Ze,c.OTPFieldConditionCell=or,c.Observable=je,c.PassFailArrayExcludesConditionModifier=At,c.PassFailArrayIncludesConditionModifier=Bt,c.PassFailEqualsConditionModifier=Et,c.PassFailField=ce,c.PassFailFieldCondition=Qe,c.PassFailFieldConditionCell=lr,c.PassFailNotEqualsConditionModifier=Lt,c.RadioField=ue,c.RadioFieldCondition=Re,c.RadioFieldConditionCell=dr,c.RatingField=fe,c.RatingFieldCondition=ei,c.RatingFieldConditionCell=ur,c.ScanField=Ne,c.ScanFieldCondition=ii,c.ScanFieldConditionCell=hr,c.Scanner=gi,c.ScannerProvider=ft,c.SelectField=re,c.SelectFieldCondition=ni,c.SelectFieldConditionCell=mr,c.StringArrayEqualsConditionModifier=bi,c.StringArrayEveryConditionModifier=Si,c.StringArrayExcludesConditionModifier=hn,c.StringArrayIncludesConditionModifier=fn,c.StringArrayNoneConditionModifier=Fi,c.StringArrayNotEqualsConditionModifier=Ni,c.StringArraySomeConditionModifier=wi,c.StringEqualsConditionModifier=Ce,c.StringExcludesConditionModifier=Be,c.StringField=he,c.StringFieldCondition=ti,c.StringFieldConditionCell=Cr,c.StringIncludesConditionModifier=Le,c.StringNotEqualsConditionModifier=Ve,c.TextField=pe,c.TextFieldCondition=ri,c.TextFieldConditionCell=yr,c.TimeAfterConditionModifier=jt,c.TimeBeforeConditionModifier=Pt,c.TimeEqualsConditionModifier=$t,c.TimeField=Me,c.TimeFieldCondition=oi,c.TimeFieldConditionCell=zr,c.TimeFieldControl=vi,c.TimeFieldInput=tn,c.TimeNotEqualsConditionModifier=Dt,c.TimeRangeInConditionModifier=Ut,c.TimeRangeNotInConditionModifier=kt,c.UNLABELLED_FIELD_LABEL=$,c.UNLABELLED_SECTION_LABEL=zi,c.URLField=xe,c.URLFieldCondition=li,c.URLFieldConditionCell=br,c.UTC_OFFSETS=Ri,c.UTC_OFFSETS_SET=gt,c.UUIDFile=de,c.UUIDPromise=be,c.UploadField=ge,c.UploadFieldCondition=ai,c.UploadFieldConditionCell=wr,c.VideoCard=Xi,c.VideoFile=Ki,c.areFieldValuesBlank=Hr,c.areFieldValuesEqual=Sn,c.areFileAndPromiseArraysEqual=mi,c.areJSONPassFailFieldValuesEqual=lt,c.arePassFieldValuesEqual=at,c.awaitFilesAndPromises=fa,c.blankFieldValues=wn,c.changedFieldValues=Gr,c.cleanConditions=Cn,c.cleanFieldValues=Ti,c.cleanSerializedConditions=gn,c.cleanSerializedFieldValues=zn,c.createCondition=si,c.createConditionModifierConfig=V,c.createField=Bi,c.createTime=en,c.deserializeCondition=Mr,c.deserializeConditions=qi,c.deserializeField=Oi,c.deserializeFieldConfig=yn,c.deserializeFieldConfigs=Tr,c.deserializeFieldElement=Ir,c.deserializeFieldElementConfig=Er,c.deserializeFieldElementConfigs=Lr,c.deserializeFieldElements=_i,c.deserializeFieldValues=Pr,c.deserializeFields=na,c.deserializePassFailFieldValue=ot,c.extractFilesAndPromisesFromFieldValues=jr,c.fieldDataMapping=T,c.fieldElementFromConfig=Or,c.fieldElementsFromConfigs=_r,c.fieldFromConfig=Vn,c.fieldSpacingCva=Ei,c.fieldTypeGroupDataMapping=wt,c.fieldsFromConfigs=qr,c.formatTime=yi,c.formatUTCOffset=Vi,c.getCurrentUTCOffset=Vt,c.getFieldsMapping=ta,c.getImagesFromFields=ua,c.getUTCMinuteOfDay=me,c.getUTCOffsetMinutes=yt,c.initializeFieldValues=kr,c.insertFilesAndPromisesToFieldValues=Ur,c.isFileAndPromiseArray=et,c.isJSONPassFailFieldValue=nt,c.isPassFailFieldStatus=Zi,c.isPassFailFieldValue=tt,c.isStringArray=Pe,c.isTime=A,c.isTimeInRange=nn,c.isTimeRange=ke,c.isUTCOffset=Ci,c.normalizeFieldOption=Gi,c.normalizeFieldOptions=_e,c.parseTime=Ue,c.passFailFieldStatusMapping=Fe,c.passFailFieldStatuses=Te,c.serializeConditions=xr,c.serializeFieldConfig=vn,c.serializeFieldConfigs=Br,c.serializeFieldElementConfig=Ar,c.serializeFieldElementConfigs=$r,c.serializeFieldValues=Dr,c.serializePassFailFieldValue=rt,c.unchangedFieldValues=Jr,c.useConditionManager=ea,c.useFieldInput=P,c.useFieldInputs=pi,c.useFieldSectionInputs=Wn,c.useImageViewer=hi,c.useObjectUrl=Ui,c.useScanner=Yo,c.useScannerContext=ct,c.validateFieldValues=Nn,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(d,i){typeof exports=="object"&&typeof module<"u"?i(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("@adrekic/zod-fieldsjson"),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","@adrekic/zod-fieldsjson","graphology","graphology-traversal","lodash.get","lodash.set"],i):(d=typeof globalThis<"u"?globalThis:d||self,i(d.forms={},d.jsxRuntime,d.blocks,d.classVarianceAuthority,d.react,null,d.react$1,d.graphologyDag,d.reactHookForm,d.uuid,d.dnd,d.fileSaver,d.hooks,d.reactZxing,d.Dagre,d.zodFieldsjson,d.graphology,d.graphologyTraversal,d.get,d.set))})(this,(function(d,i,s,Q,o,Da,O,Tt,K,V,Yi,Ot,Et,Ls,Lt,Bt,Bs,As,At,Ds){"use strict";const _s=l=>l.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),$s=l=>l.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,t)=>t?t.toUpperCase():n.toLowerCase()),Dt=l=>{const e=$s(l);return e.charAt(0).toUpperCase()+e.slice(1)},_t=(...l)=>l.filter((e,n,t)=>!!e&&e.trim()!==""&&t.indexOf(e)===n).join(" ").trim(),ks=l=>{for(const e in l)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Ps={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 js=o.forwardRef(({color:l="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:t,className:a="",children:r,iconNode:c,...f},h)=>o.createElement("svg",{ref:h,...Ps,width:e,height:e,stroke:l,strokeWidth:t?Number(n)*24/Number(e):n,className:_t("lucide",a),...!r&&!ks(f)&&{"aria-hidden":"true"},...f},[...c.map(([u,p])=>o.createElement(u,p)),...Array.isArray(r)?r:[r]]));const N=(l,e)=>{const n=o.forwardRef(({className:t,...a},r)=>o.createElement(js,{ref:r,iconNode:e,className:_t(`lucide-${_s(Dt(l))}`,`lucide-${l}`,t),...a}));return n.displayName=Dt(l),n};const Us=N("align-justify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);const Gs=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 Js=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 Hs=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 G=N("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const pi=N("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Qi=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 Ws=N("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const Ks=N("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);const Xs=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 Zs=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 $t=N("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const kt=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 Ys=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 Pt=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 Qs=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 Ri=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 jt=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 Ut=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 Rs=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 ea=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 na=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 ia=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 Gt=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 Jt=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 ta=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 la=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 sa=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 aa=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 ra=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 gi=N("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Ht=N("move-down",[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);const Wt=N("move-up",[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);const X=N("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const oa=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 da=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 ca=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 ua=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 ha=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 Kt=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 fa=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 pa=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 Fe=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 et=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 ga=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 te=N("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),nt=o.memo(l=>{const{ref:e,file:n,className:t,error:a,rightSlot:r,size:c,...f}=l,h=()=>a?i.jsxs(i.Fragment,{children:[i.jsx(s.LuIcon,{icon:Qi,color:"var(--base-a11)"}),i.jsx(s.Text,{accentColor:"base",className:"truncate",size:c,children:a})]}):n?i.jsxs(i.Fragment,{children:[i.jsx(s.LuIcon,{icon:ea,color:"var(--base-a11)"}),i.jsx(s.Text,{className:"truncate",size:c,children:n.name})]}):i.jsx(i.Fragment,{children:i.jsx("div",{className:"flex w-full justify-center",children:i.jsx(s.Spinner,{size:c})})});return i.jsxs(s.Card,{className:Q.cx(t,"flex w-full items-center gap-2"),ref:e,size:"xs",...f,children:[h(),r]})});nt.displayName="FileCard";function Qe(l){return Array.isArray(l)?l.every(e=>typeof e=="string"):!1}class Re{observers=new Set;notify(e){for(const n of this.observers)n(e)}observe(e){return this.observers.add(e),()=>{this.observers.delete(e)}}}class ze extends Re{id;constructor(e){const{id:n}=e;super(),this.id=n}getOptions(){return{id:this.id}}setOptions(e){"id"in e&&e.id!==void 0&&(this.id=e.id),this.notify(this)}serialize(){return{type:this.type,id:this.id}}config(){return{type:this.type,id:this.id}}static _deserializeConfig(e){const{id:n,type:t}=e;return{id:n,type:t}}static _serializeConfig(e){const{id:n,type:t}=e;return{id:n,type:t}}}class x extends ze{label;description;required;image;constructor(e){const{label:n,description:t,required:a,image:r,...c}=e;super(c),this.label=n,this.description=t,this.required=a,this.image=r}getError(e){if(!(!this.required&&this.isValueBlank(e))){if(this.required&&this.isValueBlank(e))return"This field is required.";for(const n of this.getFieldValidators()){const t=n(e);if(t)return t}}}serialize(){return{...super.serialize(),label:this.label,description:this.description,required:this.required}}config(){return{...super.config(),label:this.label,description:this.description,required:this.required,image:this.image}}static _deserializeConfig(e){const{label:n,description:t,required:a,...r}=e;return{...ze._deserializeConfig(r),label:n,description:t??void 0,required:a}}static _serializeConfig(e){const{label:n,description:t,required:a,...r}=e;return{...ze._serializeConfig(r),label:n,description:t,required:a}}getOptions(){return{...super.getOptions(),label:this.label,description:this.description,required:this.required,image:this.image}}setOptions(e){"label"in e&&e.label!==void 0&&(this.label=e.label),"description"in e&&(this.description=e.description),"required"in e&&e.required!==void 0&&(this.required=e.required),"image"in e&&(this.image=e.image),super.setOptions(e)}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=o.createContext({}),it=l=>{const[e,n]=o.useState(null);return o.useLayoutEffect(()=>{const t=URL.createObjectURL(l);return n(t),()=>{URL.revokeObjectURL(t)}},[l]),e},qe=o.memo(l=>{const{file:e,...n}=l,t=it(e);return i.jsx("img",{src:t??void 0,alt:e.name,...n})});qe.displayName="ImageFile";const Xt=o.createContext(()=>{throw new Error("No ImageViewerProvider found")}),mi=()=>o.useContext(Xt),tt=o.memo(l=>{const{file:e,onClose:n}=l,t=o.useCallback(()=>{Ot.saveAs(e,e.name)},[e]);return i.jsx(s.Overlay.Root,{open:!0,onOpenChange:n,children:i.jsxs(s.Overlay.Content,{onOpenAutoFocus:s.preventDefault,children:[i.jsxs(s.ButtonGroup,{className:"absolute right-0 top-0 flex items-center gap-2 p-2",accentColor:"base",variant:"ghost",children:[i.jsxs(s.Tooltip.Root,{children:[i.jsx(s.Tooltip.Trigger,{asChild:!0,children:i.jsx(s.IconButton,{onClick:t,"aria-label":"download",children:i.jsx(s.LuIcon,{icon:jt})})}),i.jsx(s.Tooltip.Content,{size:"sm",children:"Download"})]}),i.jsx(s.Separator,{orientation:"vertical",size:"sm"}),i.jsx(s.Overlay.Close,{asChild:!0,children:i.jsx(s.IconButton,{onClick:n,"aria-label":"close",children:i.jsx(s.LuIcon,{icon:te})})})]}),i.jsx("figure",{className:"flex size-full items-center justify-center overflow-hidden p-4",children:i.jsx(qe,{className:"max-h-full max-w-full",file:e})})]})})});tt.displayName="ImageViewer";const Zt=o.memo(l=>{const{children:e}=l,[n,t]=o.useState(null),a=o.useCallback(()=>{t(null)},[]),r=o.useCallback(f=>{t(f(a))},[a]),c=o.useCallback(()=>{n&&(n.onClose&&n.onClose(),a())},[a,n]);return i.jsxs(Xt.Provider,{value:r,children:[e,n&&i.jsx(tt,{file:n.file,onClose:c})]})});Zt.displayName="FileViewerProvider";const B=o.memo(l=>{const{label:e,error:n,description:t,required:a,children:r,inputId:c,image:f,size:h}=l,[u,p]=o.useState(void 0),m=mi();o.useEffect(()=>{f instanceof Promise?f.then(p).catch(console.error):p(f)},[f]);const g=o.useCallback(()=>{u&&m(()=>({file:u}))},[m,u]),C=a?`${e??"Unlabelled"} *`:e??"Unlabelled";return i.jsxs("div",{className:"flex flex-col gap-1",children:[u&&i.jsx(qe,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:u,onClick:g}),(!!e||!!t)&&i.jsxs("div",{className:"flex flex-col",children:[i.jsx("label",{className:"w-max max-w-full",htmlFor:c,children:i.jsx(s.Text,{size:h,className:"text-wrap",children:C})}),!!t&&i.jsx(s.Text,{accentColor:"base",size:h,children:t})]}),r,!!n&&i.jsx(s.Text,{accentColor:"danger",size:h,children:n})]})});B.displayName="InputWithLabel";const Yt=l=>l.map(e=>i.jsx(o.Fragment,{children:e.render()},e.id)),Ci=l=>l.map(e=>i.jsx(o.Fragment,{children:e.render()},e.id)),_=l=>{const{field:e}=l,{field:{value:n,name:t,onChange:a,onBlur:r,disabled:c},fieldState:{isTouched:f,error:h}}=K.useController({name:e.id});return{value:n,name:t,disabled:c,isTouched:f,error:h?.message??"",onChange:a,onBlur:r}},Qt=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),[u,p]=o.useState(""),[m,g]=o.useState(""),C=o.useCallback(z=>{c(z),r()},[c,r]),F=o.useCallback(z=>{t&&t.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,t]),w=o.useCallback(()=>{if(m)return;if(!u.trim()){g("Option cannot be empty");return}const z=u.trim();C([...t,z]),p("")},[u,m,C,t]),S=o.useCallback(z=>{z.key==="Enter"&&(z.preventDefault(),w())},[w]),v=o.useCallback(z=>{const b=Array.from(t);b.splice(z,1),C(b)},[t,C]),I=o.useCallback(z=>{if(!z.destination)return;const b=z.source.index,T=z.destination.index,j=Array.from(t),[ie]=j.splice(b,1);j.splice(T,0,ie),C(j)},[C,t]),q=o.useCallback(()=>{r()},[r]);return i.jsx(Yi.DragDropContext,{onDragEnd:I,children:i.jsxs(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:m||f,image:e.image,children:[(!h||t.length===0)&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx(s.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:n,children:i.jsx(s.Input.Field,{value:u,onChange:F,onKeyDown:S,id:e.id,placeholder:e.placeholder??"Press enter to add a new option",onBlur:q,name:a,disabled:h})}),i.jsx(s.IconButton,{size:n,accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!m||h,onClick:w,children:i.jsx(s.LuIcon,{icon:X})})]}),t.length!==0&&i.jsx(Yi.Droppable,{droppableId:`${e.id}-droppable`,children:z=>i.jsxs("div",{className:"flex flex-col gap-1",...z.droppableProps,ref:z.innerRef,children:[t.map((b,T)=>i.jsx(Yi.Draggable,{draggableId:`${b}-draggable`,index:T,isDragDisabled:h,children:({draggableProps:j,dragHandleProps:ie,innerRef:Ye})=>i.jsxs(s.Badge,{...ie,...j,ref:Ye,className:"flex items-center justify-between gap-2",accentColor:"base",size:n,variant:"soft",children:[i.jsx(s.Text,{className:"truncate",highContrast:!0,children:lt(b).label}),i.jsx(s.IconButton,{className:"bg-transparent!",size:n,variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:h,onClick:()=>{v(T)},children:i.jsx(s.LuIcon,{icon:te})})]})},`${e.id}-${b}-${T}`)),z.placeholder]})})]})})});Qt.displayName="MultiStringFieldInput";class le extends x{type="multi-string";minLength;maxLength;placeholder;constructor(e){const{minLength:n,maxLength:t,placeholder:a,...r}=e;super(r),this.minLength=n,this.maxLength=t,this.placeholder=a}render(){return i.jsx(Qt,{field:this})}serialize(){return{...super.serialize(),minLength:this.minLength,maxLength:this.maxLength,placeholder:this.placeholder}}config(){return{...super.config(),minLength:this.minLength,maxLength:this.maxLength,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minLength:this.minLength,maxLength:this.maxLength,placeholder:this.placeholder}}duplicate(e){return new le({...this.getOptions(),id:e})}setOptions(e){"minLength"in e&&(this.minLength=e.minLength),"maxLength"in e&&(this.maxLength=e.maxLength),"placeholder"in e&&(this.placeholder=e.placeholder),super.setOptions(e)}serializeValue(e){return e}deserializeValue(e){return e}getFieldValidators(){const e=super.getFieldValidators();return e.push(n=>{if(this.minLength!==void 0&&n.length<this.minLength)return`Must have at least ${this.minLength} options.`}),e.push(n=>{if(this.maxLength!==void 0&&n.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),e}static deserialize(e){return new le(e)}static fromConfig(e){return new le(e)}static deserializeConfig(e){const{minLength:n,maxLength:t,placeholder:a,...r}=e;return{...x._deserializeConfig(r),minLength:n,maxLength:t,placeholder:a}}static serializeConfig(e){const{minLength:n,maxLength:t,placeholder:a,...r}=e;return{...x._serializeConfig(r),minLength:n,maxLength:t,placeholder:a}}isSerializedValue(e){return Qe(e)}isValue(e){return Qe(e)}blankValue(){return[]}areValuesEqual(e,n){const t=new Set(e),a=new Set(n);return t.size===a.size&&t.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(e,n){const t=new Set(e),a=new Set(n);return t.size===a.size&&t.isSubsetOf(a)}}function lt(l){return typeof l=="string"&&(l={label:l,value:l}),l}function se(l){return l.map(lt)}class Z extends x{options;constructor(e){const{options:n,...t}=e;super(t),this.options=se(n)}serialize(){return{...super.serialize(),options:this.options}}config(){return{...super.config(),options:this.options}}static _deserializeConfig(e){const{options:n,...t}=e;return{...x._deserializeConfig(t),options:n}}static _serializeConfig(e){const{options:n,...t}=e;return{...x._serializeConfig(t),options:se(n)}}getOptions(){return{...super.getOptions(),options:this.options}}setOptions(e){"options"in e&&e.options!==void 0&&(this.options=se(e.options)),super.setOptions(e)}static getFieldCreationSchema(e=""){const n=e&&`${e}.`;return[{field:new le({label:"Options",description:"List possible options for the user to select from.",required:!0,id:`${n}options`,minLength:2}),showDirectly:!0}]}}const st=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),u=o.useCallback(m=>{c(!!m),r()},[r,c]),p=o.useCallback(()=>{r()},[r]);return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,error:f,image:e.image,required:e.required,children:i.jsx(s.Checkbox.Root,{id:e.id,name:a,checked:t??!1,onCheckedChange:u,onBlur:p,size:n,accentColor:"base",variant:"surface",disabled:h,children:i.jsx(s.Checkbox.Indicator,{children:i.jsx(s.LuIcon,{icon:G})})})})});st.displayName="BooleanFieldInput";class ae extends x{type="boolean";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}setOptions(e){super.setOptions(e)}duplicate(e){return new ae({...this.getOptions(),id:e})}static deserialize(e){return new ae(e)}static fromConfig(e){return new ae(e)}static deserializeConfig(e){return x._deserializeConfig(e)}static serializeConfig(e){return x._serializeConfig(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return i.jsx(st,{field:this})}isSerializedValue(e){return typeof e=="boolean"}isValue(e){return typeof e=="boolean"}blankValue(){return!1}blankSerializedValue(){return!1}areSerializedValuesEqual(e,n){return e===n}areValuesEqual(e,n){return e===n}}const Rt=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),u=o.useCallback(g=>{const C=g.target.valueAsNumber,F=isNaN(C)?null:C;c(F)},[c]),p=o.useCallback(()=>{r()},[r]),m=o.useCallback(g=>{g.key==="Enter"&&g.preventDefault()},[]);return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:i.jsx(s.Input.Root,{accentColor:"base",variant:"surface",size:n,children:i.jsx(s.Input.Field,{id:e.id,name:a,onChange:u,onBlur:p,value:t??"",type:"number",min:e.minimum??Number.MIN_SAFE_INTEGER,max:e.maximum??Number.MAX_SAFE_INTEGER,step:e.integers?1:"any",placeholder:e.placeholder??"Enter a number",disabled:h,onKeyDown:m})})})});Rt.displayName="NumberFieldInput";class U extends x{type="number";minimum;maximum;integers;placeholder;constructor(e){const{minimum:n,maximum:t,integers:a,placeholder:r,...c}=e;super(c),this.minimum=n,this.maximum=t,this.integers=a,this.placeholder=r}static getFieldCreationSchema(e=""){const n=e&&`${e}.`;return[{field:new U({label:"Minimum",description:"Minimum value",integers:!0,required:!1,id:`${n}minimum`}),showDirectly:!1},{field:new U({label:"Maximum",description:"Maximum value",integers:!0,required:!1,id:`${n}maximum`}),showDirectly:!1},{field:new ae({label:"Integers",description:"Whole numbers only",required:!1,id:`${n}integers`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),n=this.minimum,t=this.maximum;return typeof n=="number"&&e.push(a=>{if(typeof a=="number"&&a<n)return`Must be at least ${this.minimum}.`}),e.push(a=>{if(typeof a=="number"&&a<Number.MIN_SAFE_INTEGER)return"Cant be less than MIN_SAFE_INTEGER."}),typeof t=="number"&&e.push(a=>{if(typeof a=="number"&&a>t)return`Must be at most ${t}.`}),e.push(a=>{if(typeof a=="number"&&a>Number.MAX_SAFE_INTEGER)return"Cant be greater than MAX_SAFE_INTEGER."}),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}}config(){return{...super.config(),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 U({...this.getOptions(),id:e})}setOptions(e){"minimum"in e&&(this.minimum=e.minimum),"maximum"in e&&(this.maximum=e.maximum),"integers"in e&&(this.integers=e.integers),"placeholder"in e&&(this.placeholder=e.placeholder),super.setOptions(e)}static deserialize(e){return new U(e)}static fromConfig(e){return new U(e)}static deserializeConfig(e){const{minimum:n,maximum:t,integers:a,placeholder:r,...c}=e;return{...x._deserializeConfig(c),minimum:n,maximum:t,integers:a,placeholder:r}}static serializeConfig(e){const{minimum:n,maximum:t,integers:a,placeholder:r,...c}=e;return{...x._serializeConfig(c),minimum:n,maximum:t,integers:a,placeholder:r}}serializeValue(e){return e}deserializeValue(e){return e}render(){return i.jsx(Rt,{field:this})}isSerializedValue(e){return this.isValue(e)}isValue(e){return typeof e=="number"&&!isNaN(e)||e===null}areValuesEqual(e,n){return e===n}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,n){return e===n}}class we extends x{minLength;maxLength;placeholder;constructor(e){const{minLength:n,maxLength:t,placeholder:a,...r}=e;super(r),this.minLength=n,this.maxLength=t,this.placeholder=a}static getFieldCreationSchema(e=""){const n=e&&`${e}.`;return[{field:new U({label:"Minimum length",description:"Minimum number of characters",required:!1,id:`${n}minLength`,minimum:0,integers:!0}),showDirectly:!1},{field:new U({label:"Maximum length",description:"Maximum number of characters",required:!1,id:`${n}maxLength`,minimum:1,integers:!0}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),n=this.minLength,t=this.maxLength;return typeof n=="number"&&e.push(a=>{if(a.length<n)return`Minimum ${n} character(s).`}),typeof t=="number"&&e.push(a=>{if(a.length>t)return`Maximum ${t} character(s).`}),e}serialize(){return{...super.serialize(),minLength:this.minLength,maxLength:this.maxLength,placeholder:this.placeholder}}config(){return{...super.config(),minLength:this.minLength,maxLength:this.maxLength,placeholder:this.placeholder}}static _deserializeConfig(e){const{maxLength:n,minLength:t,placeholder:a,...r}=e;return{...x._deserializeConfig(r),minLength:t,maxLength:n,placeholder:a}}static _serializeConfig(e){const{minLength:n,maxLength:t,placeholder:a,...r}=e;return{...x._serializeConfig(r),minLength:n,maxLength:t,placeholder:a}}getOptions(){return{...super.getOptions(),minLength:this.minLength,maxLength:this.maxLength,placeholder:this.placeholder}}setOptions(e){"minLength"in e&&(this.minLength=e.minLength),"maxLength"in e&&(this.maxLength=e.maxLength),"placeholder"in e&&(this.placeholder=e.placeholder),super.setOptions(e)}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,n){return e===n}areValuesEqual(e,n){return e===n}}const el=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),u=o.useCallback(m=>{c(m),r()},[r,c]),p=o.useCallback(()=>{r()},[r]);return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:i.jsx(s.CheckboxGroup.Root,{id:e.id,name:a,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:n,values:t,onValuesChange:u,disabled:h,children:e.options.map((m,g)=>i.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(s.CheckboxGroup.Item,{value:m.value,onBlur:p,children:i.jsx(s.CheckboxGroup.ItemIndicator,{children:i.jsx(s.LuIcon,{icon:G})})}),i.jsx(s.Text,{size:n,accentColor:"base",className:"truncate",children:m.label})]},`${e.id}-${m.value}-${g}`))})})});el.displayName="CheckboxListFieldInput";class R extends Z{type="checkbox-list";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new R({...this.getOptions(),id:e})}static deserialize(e){return new R(e)}static fromConfig(e){return new R(e)}static deserializeConfig(e){return R._deserializeConfig(e)}static serializeConfig(e){return R._serializeConfig(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return i.jsx(el,{field:this})}isSerializedValue(e){if(!Qe(e))return!1;const n=new Set(this.options.map(({value:t})=>t));return e.every(t=>n.has(t))}isValue(e){return this.isSerializedValue(e)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(e,n){const t=new Set(e),a=new Set(n);return t.size===a.size&&t.isSubsetOf(a)}areValuesEqual(e,n){const t=new Set(e),a=new Set(n);return t.size===a.size&&t.isSubsetOf(a)}}const at=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),[u,p]=o.useState(!1),m=o.useCallback(C=>{c(C??null),r(),p(!1)},[c,r]),g=o.useCallback(C=>{p(C),C||r()},[r]);return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:i.jsxs(s.Popover.Root,{open:u,onOpenChange:g,children:[i.jsx(s.Popover.Trigger,{asChild:!0,children:i.jsxs(s.Button,{id:e.id,name:a,type:"button",className:"!justify-between",accentColor:"base",variant:"surface",size:n,disabled:h,children:[i.jsx(s.Text,{className:"truncate",highContrast:!!t,children:t?t.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd"}),i.jsx(s.LuIcon,{icon:pi})]})}),i.jsx(s.Popover.Content,{align:"start",size:n,children:i.jsx(s.DayPicker,{size:n,required:!1,mode:"single",variant:"solid",selected:t??void 0,onSelect:m})})]})})});at.displayName="DateFieldInput";class Se extends x{type="date";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new Se({...this.getOptions(),id:e})}static deserialize(e){return new Se(e)}static fromConfig(e){return new Se(e)}static deserializeConfig(e){return x._deserializeConfig(e)}static serializeConfig(e){return x._serializeConfig(e)}setOptions(e){super.setOptions(e)}serializeValue(e){return e?e.toISOString():null}deserializeValue(e){return e?new Date(e):null}render(){return i.jsx(at,{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,n){return e===n}areValuesEqual(e,n){return!e&&!n?!0:!e||!n?!1:e.getTime()===n.getTime()}}var M=(l=>(l.Text="text",l.Selection="selection",l.Numeric="numeric",l.Temporal="temporal",l.Capture="capture",l.Assessment="assessment",l.Verification="verification",l))(M||{});const nl=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),u=o.useCallback(m=>{c(m),r()},[r,c]),p=o.useCallback(m=>{m||r()},[r]);return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:i.jsxs(s.Menu.Root,{onOpenChange:p,align:"start",children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsxs(s.Button,{id:e.id,name:a,className:"!justify-between",variant:"surface",type:"button",size:n,accentColor:"base",disabled:h,children:[i.jsx(s.Text,{className:"truncate",highContrast:t&&t.length>0,children:t&&t.length>0?t.join(", "):e.placeholder??"Select one or more..."}),i.jsx(s.LuIcon,{icon:pi})]})}),i.jsx(s.Menu.Content,{size:n,children:i.jsx(s.Menu.Scroll,{children:i.jsxs(s.Menu.MultiSelectGroup,{values:t,onValuesChange:u,children:[i.jsxs(s.Menu.SelectAllItem,{children:[i.jsx(s.Menu.CheckboxItemIndicator,{children:m=>m?i.jsx(s.LuIcon,{icon:gi}):i.jsx(s.LuIcon,{icon:G})}),"Select all"]}),e.options.map((m,g)=>i.jsxs(s.Menu.MultiSelectItem,{value:m.value,children:[i.jsx(s.Menu.SelectedIndicator,{children:i.jsx(s.LuIcon,{icon:G})}),m.label]},`${e.id}-${m.value}-${g}`))]})})})]})})});nl.displayName="MultiSelectFieldInput";class ee extends Z{type="multi-select";placeholder;constructor(e){const{placeholder:n,...t}=e;super(t),this.placeholder=n}serialize(){return{...super.serialize(),placeholder:this.placeholder}}config(){return{...super.config(),placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new ee({...this.getOptions(),id:e})}setOptions(e){"placeholder"in e&&(this.placeholder=e.placeholder),super.setOptions(e)}static deserialize(e){return new ee(e)}static fromConfig(e){return new ee(e)}static deserializeConfig(e){const{placeholder:n,...t}=e;return{...Z._deserializeConfig(t),placeholder:n}}static serializeConfig(e){const{placeholder:n,...t}=e;return{...Z._serializeConfig(t),placeholder:n}}serializeValue(e){return e}deserializeValue(e){return e}render(){return i.jsx(nl,{field:this})}isSerializedValue(e){if(!Qe(e))return!1;const n=new Set(this.options.map(({value:t})=>t));return e.every(t=>n.has(t))}isValue(e){return this.isSerializedValue(e)}blankValue(){return[]}areValuesEqual(e,n){const t=new Set(e),a=new Set(n);return t.size===a.size&&t.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(e,n){const t=new Set(e),a=new Set(n);return t.size===a.size&&t.isSubsetOf(a)}}const il=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),u=o.useCallback(g=>{c(g)},[c]),p=o.useCallback(()=>{r()},[r]),m=o.useMemo(()=>Array.from({length:e.length},()=>V.v4()),[e.length]);return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:i.jsxs(s.OneTimePasswordField.Root,{id:e.id,name:a,value:t,onValueChange:u,validationType:"none",disabled:h,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:n,onBlur:p,children:[m.map(g=>i.jsx(s.OneTimePasswordField.Input,{id:g},g)),i.jsx(s.OneTimePasswordField.HiddenInput,{})]})})});il.displayName="OTPFieldInput";class re extends x{type="otp";length;constructor(e){const{length:n,...t}=e;super(t),this.length=n}static getFieldCreationSchema(e=""){const n=e&&`${e}.`;return[{field:new U({label:"Length",integers:!0,required:!1,minimum:1,maximum:16,id:`${n}length`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),n=this.length;return e.push(t=>{if(t.length!=n)return`Must be ${n} characters.`}),e}serialize(){return{...super.serialize(),length:this.length}}config(){return{...super.config(),length:this.length}}getOptions(){return{...super.getOptions(),length:this.length}}duplicate(e){return new re({...this.getOptions(),id:e})}setOptions(e){"length"in e&&e.length!==void 0&&(this.length=e.length),super.setOptions(e)}static deserialize(e){return new re(e)}static fromConfig(e){return new re(e)}static deserializeConfig(e){const{length:n,...t}=e;return{...x._deserializeConfig(t),length:n}}static serializeConfig(e){const{length:n,...t}=e;return{...x._serializeConfig(t),length:n}}serializeValue(e){return e}deserializeValue(e){return e}render(){return i.jsx(il,{field:this})}isSerializedValue(e){return typeof e=="string"}isValue(e){return typeof e=="string"}blankValue(){return""}areValuesEqual(e,n){return e===n}blankSerializedValue(){return""}areSerializedValuesEqual(e,n){return e===n}}const oe={pass:{label:"Pass",icon:Ws},fail:{label:"Fail",icon:Zs},na:{label:"N/A",icon:Xs}},Te=Object.keys(oe);class de extends File{uuid;constructor(e,...n){super(...n),this.uuid=e}static from(e,n){return new de(e,[n],n.name,{lastModified:n.lastModified,type:n.type})}}class be extends Promise{_uuid;constructor(e,n){super(e),this._uuid=n}get uuid(){return this._uuid}set uuid(e){this._uuid=e}static from(e,n){return new be((t,a)=>{Promise.resolve(e).then(t).catch(a)},n)}then(e,n){const t=super.then(e,n);return t.uuid=this.uuid,t}catch(e){const n=super.catch(e);return n.uuid=this.uuid,n}finally(e){const n=super.finally(e);return n.uuid=this.uuid,n}}function tl(l){return Array.isArray(l)?l.every(e=>e instanceof be||e instanceof de):!1}function yi(l,e){const n=new Set(l.map(({uuid:a})=>a)),t=new Set(e.map(({uuid:a})=>a));return n.size===t.size&&n.isSubsetOf(t)}const rt=o.memo(l=>{const{ref:e,file:n,error:t,rightSlot:a,className:r,size:c,...f}=l;return i.jsxs(s.Card,{className:Q.cx(r,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:e,size:"xs",...f,children:[!n&&!t&&i.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:i.jsx(s.Spinner,{size:c})}),!!n&&!t&&i.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3",children:i.jsx(qe,{className:"block size-full max-w-full object-cover",file:n})}),!!t&&i.jsx("div",{className:"grow"}),(!!n||!!t)&&i.jsxs(i.Fragment,{children:[i.jsx(s.Separator,{size:"full"}),i.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[t?i.jsx(s.LuIcon,{color:"var(--base-11)",icon:Qi}):n&&i.jsx(s.LuIcon,{color:"var(--base-11)",icon:Gt}),i.jsx(s.Text,{className:"truncate",size:c,children:t??n?.name}),a]})]})]})});rt.displayName="ImageCard";const ot=o.memo(l=>{const{file:e,...n}=l,t=it(e);return i.jsx("video",{src:t??void 0,...n})});ot.displayName="VideoFile";const dt=o.memo(l=>{const{ref:e,file:n,className:t,error:a,rightSlot:r,size:c,...f}=l;return i.jsxs(s.Card,{className:Q.cx(t,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:e,size:"xs",...f,children:[!n&&!a&&i.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:i.jsx(s.Spinner,{size:c})}),!!n&&!a&&i.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3",children:i.jsx(ot,{className:"block size-full max-w-full object-cover",file:n,controls:!0})}),!!a&&i.jsx("div",{className:"grow"}),(!!n||!!a)&&i.jsxs(i.Fragment,{children:[i.jsx(s.Separator,{size:"full"}),i.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[a?i.jsx(s.LuIcon,{color:"var(--danger-11)",icon:Qi}):n&&i.jsx(s.LuIcon,{color:"var(--base-11)",icon:ga}),i.jsx(s.Text,{className:"truncate",size:c,children:a??n?.name}),r]})]})]})});dt.displayName="VideoCard";const ct=o.memo(l=>{const{fileOrPromise:e,onRemove:n,disabled:t,size:a}=l,[r,c]=o.useState(e instanceof be?null:e),[f,h]=o.useState(null),u=mi();Et.useActiveEffect(v=>{if(h(null),!(e instanceof be)){c(e);return}c(null),e.then(I=>{v()&&c(I)}).catch(I=>{v()&&h(I instanceof Error?I.message:"Unknown error")})},[e]);const p=o.useCallback(()=>{if(!r)return;const v=new Blob([r]);Ot.saveAs(v,r.name)},[r]),m=o.useCallback(()=>{n(e)},[n,e]),g=o.useCallback(()=>{if(!r)return;const v=URL.createObjectURL(r);window.open(v,"_blank"),URL.revokeObjectURL(v)},[r]),C=o.useCallback(()=>{r&&u(v=>({file:r,onDelete:t?void 0:()=>{m(),v()}}))},[t,m,u,r]),F=o.useMemo(()=>i.jsx("div",{className:"flex grow justify-end",children:i.jsxs(s.Menu.Root,{modal:!0,children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsx(s.IconButton,{onClick:s.stopPropagation,type:"button",variant:"ghost",accentColor:"base",size:a,children:i.jsx(s.LuIcon,{icon:Ut})})}),i.jsxs(s.Menu.Content,{size:a,children:[i.jsxs(s.Menu.Item,{onSelect:p,disabled:!r,children:[i.jsx(s.LuIcon,{icon:jt})," Download"]}),t?null:i.jsxs(i.Fragment,{children:[i.jsx(s.Menu.Separator,{}),i.jsxs(s.Menu.Item,{onSelect:m,children:[i.jsx(s.LuIcon,{icon:Fe})," Delete"]})]})]})]})}),[t,m,p,r,a]),w=!!r?.type.startsWith("image/"),S=!!r?.type.startsWith("video/");return w?i.jsx(rt,{className:"cursor-pointer",onClick:C,file:r,error:f??void 0,rightSlot:F,size:a}):S?i.jsx(dt,{className:"cursor-pointer",onClick:C,file:r,error:f??void 0,rightSlot:F,size:a}):i.jsx(nt,{className:"cursor-pointer",file:r,error:f??void 0,onClick:g,rightSlot:F,size:a})});ct.displayName="DisplayFile";const ll=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),u=o.useRef(null),p=o.useCallback(z=>{const b=e.cleanValue({...t,status:z});c(b),r()},[e,r,c,t]),m=o.useCallback(z=>{const b=z.target.value,T={...t,notes:b};c(T)},[t,c]),g=o.useCallback(()=>{r()},[r]),C=o.useCallback(z=>{const b=t.files.filter(({uuid:T})=>T!==z.uuid);c({...t,files:b}),r()},[c,r,t]),F=o.useCallback(()=>{u.current?.click()},[]),w=o.useCallback(z=>{const b=Array.from(z.target.files??[]).map(j=>de.from(V.v4(),j)),T={...t,files:[...t.files,...b]};c(T),r()},[r,c,t]);o.useEffect(()=>{if(!u.current)return;const z=new AbortController;return u.current.addEventListener("cancel",()=>{r()},{signal:z.signal}),()=>{z.abort()}},[r,t]);const S=t.status&&e.showNotesAndFilesOn.includes(t.status),v=`${e.id}-status`,I=`${e.id}-notes`,q=`${e.id}-files`;return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(s.RadioGroup.Root,{id:v,className:"flex gap-2",name:a,value:t.status,disabled:h,accentColor:"base",variant:"surface",size:n,onValueChange:p,children:Te.map(z=>{const{label:b}=oe[z];return i.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(s.RadioGroup.Item,{value:z,children:i.jsx(s.RadioGroup.Indicator,{children:i.jsx(s.LuIcon,{icon:$t,className:"fill-current"})})}),i.jsx(s.Text,{size:n,accentColor:"base",className:"truncate",children:b})]},`${e.id}-${z}`)})}),S&&i.jsxs(i.Fragment,{children:[i.jsx("div",{children:i.jsx(s.TextArea,{id:I,value:t.notes??"",name:a,onChange:m,onBlur:g,className:"field-sizing-content min-h-12 w-full",placeholder:"Notes",resize:"vertical",accentColor:"base",variant:"surface",size:n,disabled:h})}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsxs(s.Button,{className:"w-max",size:n,variant:"surface",accentColor:"base",onClick:F,type:"button",disabled:h,children:[i.jsx(s.LuIcon,{icon:et}),"Select files"]}),i.jsx("input",{id:q,name:a,type:"file",ref:u,multiple:!0,className:"hidden",onChange:w,value:""}),t.files.length>0&&i.jsx("div",{className:"flex h-max flex-wrap gap-2",children:t.files.map(z=>i.jsx(ct,{size:n,fileOrPromise:z,onRemove:C,disabled:h},z.uuid))})]})]})]})})});ll.displayName="PassFailFieldInput";const ut=l=>typeof l=="string"&&Te.includes(l),sl=l=>!(l===null||typeof l!="object"||!("status"in l)||!ut(l.status)||!("notes"in l)||typeof l.notes!="string"||!("files"in l)||!(Array.isArray(l.files)&&l.files.length===0)),al=l=>!(l===null||typeof l!="object"||!("status"in l)||!ut(l.status)||!("notes"in l)||typeof l.notes!="string"||!("files"in l)||!tl(l.files)),rl=l=>({status:l.status,notes:l.notes,files:[]}),ol=l=>({status:l.status,notes:l.notes,files:[]}),dl=(l,e)=>!(l.status!==e.status||l.notes!==e.notes||!yi(l.files,e.files)),cl=(l,e)=>!(l.status!==e.status||l.notes!==e.notes||l.files.length!==e.files.length);class ce extends x{type="pass-fail";showNotesAndFilesOn;constructor(e){const{showNotesAndFilesOn:n,...t}=e;super(t),this.showNotesAndFilesOn=n}static getFieldCreationSchema(e=""){const n=e&&`${e}.`;return[{field:new ee({id:`${n}showNotesAndFilesOn`,label:"Show notes and files on",description:"Show the notes and files on desired statuses.",options:Te.map(t=>{const{label:a}=oe[t];return{value:t,label:a}}),required:!1}),showDirectly:!1}]}serialize(){return{...super.serialize(),showNotesAndFilesOn:this.showNotesAndFilesOn}}config(){return{...super.config(),showNotesAndFilesOn:this.showNotesAndFilesOn}}getOptions(){return{...super.getOptions(),showNotesAndFilesOn:this.showNotesAndFilesOn}}duplicate(e){return new ce({...this.getOptions(),id:e})}setOptions(e){"showNotesAndFilesOn"in e&&e.showNotesAndFilesOn!==void 0&&(this.showNotesAndFilesOn=e.showNotesAndFilesOn),super.setOptions(e)}getFieldValidators(){const e=super.getFieldValidators(),n=this.showNotesAndFilesOn,t=this.blankValue();return n.length>0&&(e.push(a=>{if(!(!a.status||!n.includes(a.status))&&t.notes===a.notes)return"Notes is required."}),e.push(a=>{if(!(!a.status||!n.includes(a.status))&&yi(t.files,a.files))return"Files is required."})),e}static deserialize(e){const{showNotesAndFilesOn:n,...t}=e;return new ce({...t,showNotesAndFilesOn:n})}static fromConfig(e){return new ce(e)}static deserializeConfig(e){const{showNotesAndFilesOn:n,...t}=e;return{...x._deserializeConfig(t),showNotesAndFilesOn:n}}static serializeConfig(e){const{showNotesAndFilesOn:n,...t}=e;return{...x._serializeConfig(t),showNotesAndFilesOn:n}}serializeValue(e){return rl(e)}deserializeValue(e){return ol(e)}render(){return i.jsx(ll,{field:this})}isSerializedValue(e){return sl(e)}isValue(e){return al(e)}areValuesEqual(e,n){return dl(e,n)}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,n){return cl(e,n)}}const ul=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),u=o.useCallback(g=>{c(g),r()},[r,c]),p=o.useCallback(()=>{r()},[r]),m=o.useCallback(()=>{c(null),r()},[r,c]);return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:i.jsxs(s.RadioGroup.Root,{id:e.id,name:a,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:n,value:t??"",onValueChange:u,disabled:h,children:[e.options.map((g,C)=>i.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[i.jsx(s.RadioGroup.Item,{value:g.value,onBlur:p,children:i.jsx(s.RadioGroup.Indicator,{children:i.jsx(s.LuIcon,{icon:$t,className:"fill-current"})})}),i.jsx(s.Text,{size:n,accentColor:"base",className:"truncate",children:g.label})]},`${e.id}-${g.value}-${C}`)),!!t&&i.jsxs(s.Button,{onClick:m,className:"-mx-2 w-max",type:"button",variant:"ghost",accentColor:"base",size:n,children:[i.jsx(s.LuIcon,{icon:te}),"Clear"]})]})})});ul.displayName="RadioFieldInput";class ue extends Z{type="radio";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new ue({...this.getOptions(),id:e})}setOptions(e){super.setOptions(e)}static deserialize(e){return new ue(e)}static fromConfig(e){return new ue(e)}static deserializeConfig(e){return Z._deserializeConfig(e)}static serializeConfig(e){return Z._serializeConfig(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return i.jsx(ul,{field:this})}isSerializedValue(e){return typeof e!="string"&&e!==null?!1:new Set([null,...this.options.map(({value:t})=>t)]).has(e)}isValue(e){return this.isSerializedValue(e)}blankValue(){return null}areValuesEqual(e,n){return e===n}blankSerializedValue(){return null}areSerializedValuesEqual(e,n){return e===n}}const ma=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"]}}}),hl=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),u=o.useCallback(g=>{c(g),r()},[r,c]),p=o.useCallback(()=>{c(null),r()},[r,c]),m=Array.from({length:e.maxRating},(g,C)=>C+1);return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:i.jsxs("div",{className:"flex flex-row items-center gap-1",children:[i.jsx(s.Rating.Root,{id:e.id,name:a,className:"flex items-center gap-0.5",value:t,onValueChange:u,disabled:h,children:m.map(g=>i.jsx(s.Rating.Item,{value:g,className:ma({size:n}),children:i.jsx(s.LuIcon,{icon:Kt,className:"size-full group-data-[active=true]:fill-current"})},`${e.id}-${g}`))}),!h&&t!==null&&i.jsx(s.IconButton,{onClick:p,type:"button",variant:"ghost",accentColor:"base",size:n,children:i.jsx(s.LuIcon,{icon:te})})]})})});hl.displayName="RatingFieldInput";class he extends x{type="rating";maxRating;constructor(e){const{maxRating:n,...t}=e;super(t),this.maxRating=n}static getFieldCreationSchema(e=""){const n=e&&`${e}.`;return[{field:new U({label:"Max Rating",description:"Maximum rating value",integers:!0,required:!1,minimum:1,maximum:10,id:`${n}maxRating`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),n=this.maxRating;return e.push(t=>{if(typeof t=="number"&&(t<1||t>n))return`Rating must be between 1 and ${n}.`}),e}serialize(){return{...super.serialize(),maxRating:this.maxRating}}config(){return{...super.config(),maxRating:this.maxRating}}getOptions(){return{...super.getOptions(),maxRating:this.maxRating}}duplicate(e){return new he({...this.getOptions(),id:e})}setOptions(e){"maxRating"in e&&e.maxRating!==void 0&&(this.maxRating=e.maxRating),super.setOptions(e)}static deserialize(e){return new he(e)}static fromConfig(e){return new he(e)}static deserializeConfig(e){const{maxRating:n,...t}=e;return{...x._deserializeConfig(t),maxRating:n}}static serializeConfig(e){const{maxRating:n,...t}=e;return{...x._serializeConfig(t),maxRating:n}}serializeValue(e){return e}deserializeValue(e){return e}render(){return i.jsx(hl,{field:this})}isSerializedValue(e){return this.isValue(e)}isValue(e){return typeof e=="number"&&!isNaN(e)||e===null}areValuesEqual(e,n){return e===n}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,n){return e===n}}const ht=o.createContext(null),fl=()=>{const l=o.use(ht);if(!l)throw new Error("useScannerContext must be used within a component tree wrapped by ScannerProvider.");return l},Ca=()=>{const l=o.use(ht);if(!l)throw new Error("useScanner must be used within a component tree wrapped by ScannerProvider.");return l.openScanner},vi=o.memo(l=>{const{children:e,open:n,onOpenChange:t,defaultOpen:a,modal:r,...c}=l;return i.jsxs(s.Overlay.Root,{open:n,onOpenChange:t,defaultOpen:a,modal:r,children:[!!e&&i.jsx(s.Overlay.Trigger,{asChild:!0,children:e}),i.jsxs(s.Overlay.Content,{children:[i.jsx(s.Overlay.Title,{className:"sr-only",children:"Scanner"}),i.jsx(s.Overlay.Description,{className:"sr-only",children:"Scan a barcode or a qr code."}),i.jsx(pl,{...c})]})]})});vi.displayName="Scanner";const pl=o.memo(l=>{const{paused:e,formats:n,timeBetweenDecodingAttempts:t,trySkew:a,onDecodeResult:r,onDecodeError:c,onError:f}=l,{wasmUrl:h}=fl(),{ref:u}=Ls.useZxing({wasmUrl:h,paused:e,formats:n,timeBetweenDecodingAttempts:t,trySkew:a,onDecodeResult:r,onDecodeError:c,onError:f,constraints:{video:{width:{ideal:1920,min:1280},height:{ideal:1080,min:720},aspectRatio:{ideal:16/9},facingMode:"environment"}}});return i.jsxs("div",{className:"bg-(--color-background) flex size-full flex-col justify-center overflow-hidden",children:[i.jsx("div",{className:"flex w-full justify-end p-4",children:i.jsx(s.Overlay.Close,{asChild:!0,children:i.jsx(s.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",children:i.jsx(s.LuIcon,{icon:te})})})}),i.jsx("div",{className:"max-h-full w-full grow overflow-hidden p-4",children:i.jsx("video",{className:"size-full",ref:u,muted:!0,playsInline:!0})})]})});pl.displayName="ScannerInternal";const gl=o.memo(l=>{const{children:e,wasmUrl:n}=l,[t,a]=o.useState(null),r=o.useCallback(()=>{a(null)},[]),c=o.useCallback(u=>{a(u(r))},[r]),f=o.useCallback(()=>{t&&(t.onClose&&t.onClose(),r())},[r,t]),h=o.useMemo(()=>({wasmUrl:n,openScanner:c}),[n,c]);return i.jsxs(ht,{value:h,children:[e,t&&i.jsx(vi,{open:!0,onOpenChange:f,...t})]})});gl.displayName="ScannerProvider";const ml=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),[u,p]=o.useState(!1),m=o.useCallback(S=>{const v=S.target.value;c(v)},[c]),g=o.useCallback(()=>{r()},[r]),C=o.useCallback(S=>{c(S.rawValue.trim()),r(),p(!1)},[c,r]),F=o.useCallback(()=>{p(!0)},[]),w=o.useCallback(()=>{p(!1),r()},[r]);return i.jsxs(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:[i.jsx(s.TextArea,{className:"field-sizing-content w-full",accentColor:"base",variant:"surface",size:n,id:e.id,name:a,value:t??"",placeholder:"Enter a qr or barcode",onChange:m,onBlur:g,disabled:h}),i.jsxs(s.Button,{onClick:F,className:"w-max",type:"button",variant:"soft",size:n,accentColor:"base",disabled:h,children:[i.jsx(s.LuIcon,{icon:ra}),"Scan"]}),i.jsx(vi,{open:u,onDecodeResult:C,onOpenChange:w})]})});ml.displayName="ScanFieldInput";class Ve extends x{type="qr";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new Ve({...this.getOptions(),id:e})}setOptions(e){super.setOptions(e)}static deserialize(e){return new Ve(e)}static fromConfig(e){return new Ve(e)}static deserializeConfig(e){return x._deserializeConfig(e)}static serializeConfig(e){return x._serializeConfig(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return i.jsx(ml,{field:this})}isSerializedValue(e){return typeof e=="string"}isValue(e){return typeof e=="string"}blankValue(){return""}areValuesEqual(e,n){return e===n}blankSerializedValue(){return""}areSerializedValuesEqual(e,n){return e===n}}const Cl=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),u=o.useCallback(g=>{c(g??null),r()},[r,c]),p=o.useCallback(g=>{g||r()},[r]),m=o.useMemo(()=>e.options.find(g=>g.value===t),[e.options,t]);return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:i.jsxs(s.Menu.Root,{onOpenChange:p,align:"start",children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsxs(s.Button,{id:e.id,name:a,className:"!justify-between",accentColor:"base",variant:"surface",type:"button",size:n,disabled:h,children:[i.jsx(s.Text,{className:"truncate",highContrast:!!m,children:m?m.label:e.placeholder??"Select one..."}),i.jsx(s.LuIcon,{icon:pi})]})}),i.jsx(s.Menu.Content,{size:n,children:i.jsx(s.Menu.Scroll,{children:i.jsx(s.Menu.SelectGroup,{required:!1,value:t??void 0,onValueChange:u,children:e.options.map((g,C)=>i.jsxs(s.Menu.SelectItem,{value:g.value,children:[i.jsx(s.Menu.SelectedIndicator,{children:i.jsx(s.LuIcon,{icon:G})}),g.label]},`${e.id}-${g.value}-${C}`))})})})]})})});Cl.displayName="SelectFieldInput";class fe extends Z{type="select";placeholder;constructor(e){const{placeholder:n,...t}=e;super(t),this.placeholder=n}serialize(){return{...super.serialize(),placeholder:this.placeholder}}config(){return{...super.config(),placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new fe({...this.getOptions(),id:e})}setOptions(e){"placeholder"in e&&(this.placeholder=e.placeholder),super.setOptions(e)}static deserialize(e){return new fe(e)}static fromConfig(e){return new fe(e)}static deserializeConfig(e){const{placeholder:n,...t}=e;return{...Z._deserializeConfig(t),placeholder:n}}static serializeConfig(e){const{placeholder:n,...t}=e;return{...Z._serializeConfig(t),placeholder:n}}serializeValue(e){return e}deserializeValue(e){return e}render(){return i.jsx(Cl,{field:this})}isSerializedValue(e){return typeof e!="string"&&e!==null?!1:new Set([null,...this.options.map(({value:t})=>t)]).has(e)}isValue(e){return this.isSerializedValue(e)}blankValue(){return null}areValuesEqual(e,n){return e===n}blankSerializedValue(){return null}areSerializedValuesEqual(e,n){return e===n}}const yl=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),u=o.useCallback(g=>{const C=g.target.value;c(C)},[c]),p=o.useCallback(()=>{r()},[r]),m=o.useCallback(g=>{g.key==="Enter"&&g.preventDefault()},[]);return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:i.jsx(s.Input.Root,{accentColor:"base",variant:"surface",size:n,children:i.jsx(s.Input.Field,{id:e.id,className:"truncate",name:a,value:t??"",type:"text",placeholder:e.placeholder??"Enter a short description",onChange:u,onBlur:p,disabled:h,onKeyDown:m})})})});yl.displayName="StringFieldInput";class pe extends we{type="string";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new pe({...this.getOptions(),id:e})}setOptions(e){super.setOptions(e)}static deserialize(e){return new pe(e)}static fromConfig(e){return new pe(e)}static deserializeConfig(e){return we._deserializeConfig(e)}static serializeConfig(e){return we._serializeConfig(e)}render(){return i.jsx(yl,{field:this})}}const vl=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),u=o.useCallback(m=>{const g=m.target.value;c(g)},[c]),p=o.useCallback(()=>{r()},[r]);return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:i.jsx(s.TextArea,{id:e.id,value:t??"",name:a,onChange:u,onBlur:p,className:"field-sizing-content min-h-12",placeholder:e.placeholder??"Enter a description",resize:"vertical",accentColor:"base",variant:"surface",size:n,disabled:h})})});vl.displayName="TextFieldInput";class ge extends we{type="text";constructor(e){super(e)}serialize(){return super.serialize()}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new ge({...this.getOptions(),id:e})}setOptions(e){super.setOptions(e)}static deserialize(e){return new ge(e)}static fromConfig(e){return new ge(e)}static deserializeConfig(e){return we._deserializeConfig(e)}static serializeConfig(e){return we._serializeConfig(e)}render(){return i.jsx(vl,{field:this})}}const ft=ya(),Fl=new Set(ft);function ya(l=!0){const e=new Set;for(let n=-12;n<=14;n++){const t=n>=0?"+":"-",a=Math.abs(n).toString().padStart(2,"0");e.add(`${t}${a}:00`)}if(l){const n=[-12.5,-9.5,-3.5,3.5,4.5,5.5,6.5,9.5,10.5,12.5];for(const t of n){const a=t>=0?"+":"-",r=Math.floor(Math.abs(t)).toString().padStart(2,"0");e.add(`${a}${r}:30`)}}return Array.from(e).sort((n,t)=>zl(n)-zl(t))}function zl(l){const e=l[0]==="+"?1:-1,n=Number(l.slice(1,3)),t=Number(l.slice(4,6));return e*(n*60+t)}const va="+00:00",Fa=/^T([01]\d|2[0-3]):([0-5]\d):00([+-]\d{2}:\d{2})$/,Fi=l=>typeof l=="string"&&Fl.has(l),wl=()=>{const l=-new Date().getTimezoneOffset(),e=l>=0?"+":"-",n=Math.abs(l),t=Math.floor(n/60),a=n%60,r=`${e}${t.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`;return Fi(r)?r:va};function Sl(l){const e=/^([+-])(\d{2}):(\d{2})$/.exec(l);if(!e)throw new Error(`Invalid UTC offset: ${l}`);return(e[1]==="+"?1:-1)*(Number(e[2])*60+Number(e[3]))}const en=l=>{const e=Fa.exec(l);if(!e)return null;const n=e[3];return Fi(n)?{hours:Number(e[1]),minutes:Number(e[2]),utcOffset:n}:null},Y=l=>typeof l=="string"&&en(l)!==null,me=(l,e,n=wl())=>{if(!Number.isInteger(l)||l<0||l>23)throw new Error(`Invalid hour: ${l}`);if(!Number.isInteger(e)||e<0||e>59)throw new Error(`Invalid minute: ${e}`);if(!Fi(n))throw new Error("Unsupported UTC offset");const t=l.toString().padStart(2,"0"),a=e.toString().padStart(2,"0");return`T${t}:${a}:00${n}`},zi=l=>`UTC${l}`,Ce=l=>{const e=en(l);if(!e)throw new Error(`Invalid time value: ${l}`);return(e.hours*60+e.minutes-Sl(e.utcOffset)+1440)%1440},wi=(l,e=!0)=>{const n=en(l);if(!n)throw new Error(`Invalid time value: ${l}`);const t=(n.hours%12||12).toString().padStart(2,"0"),a=n.minutes.toString().padStart(2,"0"),r=n.hours>=12?"PM":"AM",c=`${t}:${a} ${r}`;return e?`${c} ${zi(n.utcOffset)}`:c},za=l=>typeof l=="object"&&(Y(l.from)||Y(l.to)),pt=(l,e)=>{const n=Ce(l),t=e.from?Ce(e.from):null,a=e.to?Ce(e.to):null;return t===null&&a===null?!0:t===null?n<=a:a===null?n>=t:t<=a?n>=t&&n<=a:n>=t||n<=a},Si=o.memo(l=>{const{value:e,onChange:n,onBlur:t,disabled:a,size:r="md",id:c,name:f,compact:h=!1}=l,u=e?en(e):null,p=u?`${u.hours.toString().padStart(2,"0")}:${u.minutes.toString().padStart(2,"0")}`:"",m=o.useCallback(F=>{const w=F.target.value;if(!w){n(null);return}const[S,v]=w.split(":").map(Number);n(me(S,v,u?.utcOffset))},[n,u?.utcOffset]),g=o.useCallback(F=>{u&&(n(me(u.hours,u.minutes,F)),t?.())},[t,n,u]),C=o.useCallback(F=>{F||t?.()},[t]);return i.jsxs("div",{className:"flex min-w-0 gap-2",children:[i.jsx(s.Input.Root,{className:"min-w-0 grow",accentColor:"base",variant:"surface",size:r,children:i.jsx(s.Input.Field,{id:c,name:f,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:m,onBlur:t,disabled:a})}),i.jsxs(s.Menu.Root,{align:"end",onOpenChange:C,children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsxs(s.Button,{type:"button",className:h?"!justify-between":"min-w-32 !justify-between",accentColor:"base",variant:"surface",size:r,disabled:a||!u,children:[i.jsx(s.Text,{className:"truncate",highContrast:!!u,children:u?zi(u.utcOffset):"UTC offset"}),i.jsx(s.LuIcon,{icon:pi})]})}),i.jsx(s.Menu.Content,{size:r,children:i.jsx(s.Menu.Scroll,{children:i.jsx(s.Menu.SelectGroup,{required:!0,value:u?.utcOffset,onValueChange:g,children:ft.map(F=>i.jsxs(s.Menu.SelectItem,{value:F,children:[i.jsx(s.Menu.SelectedIndicator,{children:i.jsx(s.LuIcon,{icon:G})}),zi(F)]},F))})})})]})]})});Si.displayName="TimeFieldControl";const gt=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e});return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:i.jsx(Si,{id:e.id,name:a,size:n,value:t,onChange:c,onBlur:r,disabled:h})})});gt.displayName="TimeFieldInput";class Ne extends x{type="time";constructor(e){super(e)}static deserialize(e){return new Ne(e)}static fromConfig(e){return new Ne(e)}static deserializeConfig(e){return x._deserializeConfig(e)}static serializeConfig(e){return x._serializeConfig(e)}config(){return super.config()}getOptions(){return super.getOptions()}duplicate(e){return new Ne({...this.getOptions(),id:e})}setOptions(e){super.setOptions(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return i.jsx(gt,{field:this})}isSerializedValue(e){return e===null||Y(e)}isValue(e){return e===null||Y(e)}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,n){return e===n}areValuesEqual(e,n){return e===n}}const bl=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),u=o.useRef(null),p=o.useCallback(()=>{u.current?.click()},[]),m=o.useCallback(()=>{if(!u.current)return;const v=u.current.files;if(!v){r();return}const I=Array.from(v).map(z=>de.from(V.v4(),z)),q=[...t,...I];c(q),r()},[r,c,t]),g=o.useCallback(v=>{const I=t.filter(({uuid:q})=>q!==v.uuid);c(I),r()},[t,c,r]);o.useEffect(()=>{if(!u.current)return;const v=new AbortController;return u.current.addEventListener("cancel",()=>{r()},{signal:v.signal}),()=>{v.abort()}},[r,t]);const C=e.maxFiles!==1,S=C?"Select files":"Select a file";return i.jsxs(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:[i.jsxs(s.Button,{className:"w-max",size:n,variant:"surface",accentColor:"base",onClick:p,type:"button",disabled:h,children:[i.jsx(s.LuIcon,{icon:et}),S]}),i.jsx("input",{id:e.id,name:a,type:"file",ref:u,accept:e.extensions?.join(","),multiple:C,className:"hidden",onChange:m,value:""}),t.length>0&&i.jsx("div",{className:"mt-1 flex h-max flex-col gap-2",children:t.map(v=>i.jsx(ct,{size:n,fileOrPromise:v,onRemove:g,disabled:h},v.uuid))})]})});bl.displayName="UploadFieldInput";class ye extends x{type="upload";extensions;maxSize;maxFiles;constructor(e){const{extensions:n,maxFiles:t,maxSize:a,...r}=e;super(r),this.maxSize=a,this.maxFiles=t,this.extensions=n}static getFieldCreationSchema(e=""){const n=e&&`${e}.`;return[{field:new U({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:0,id:`${n}maxFiles`,integers:!0}),showDirectly:!1},{field:new U({label:"What is the maximum size of each file?",description:"Maximum file size in MB.",required:!1,id:`${n}maxSize`,minimum:0,integers:!0}),showDirectly:!1},{field:new ee({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,id:`${n}extensions`,options:[{value:"image/*",label:"Images"},{value:"audio/*",label:"Audio files"},{value:"video/*",label:"Videos"},{value:"text/*",label:"Text files"},{value:"application/*",label:"Application files (includes PDFs and Word documents)"}]}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),n=this.maxSize,t=n&&n*1e3*1e3,a=this.maxFiles;return typeof n=="number"&&typeof t=="number"&&e.push(r=>{if(r.some(c=>c instanceof de&&c.size>t))return`Files must be at most ${n}MB.`}),typeof a=="number"&&e.push(r=>{if(r.length>a)return`You can only upload ${a} files.`}),e}serialize(){return{...super.serialize(),extensions:this.extensions,maxSize:this.maxSize,maxFiles:this.maxFiles}}config(){return{...super.config(),extensions:this.extensions,maxSize:this.maxSize,maxFiles:this.maxFiles}}getOptions(){return{...super.getOptions(),extensions:this.extensions,maxSize:this.maxSize,maxFiles:this.maxFiles}}duplicate(e){return new ye({...this.getOptions(),id:e})}setOptions(e){"maxSize"in e&&(this.maxSize=e.maxSize),"maxFiles"in e&&(this.maxFiles=e.maxFiles),"extensions"in e&&(this.extensions=e.extensions),super.setOptions(e)}static deserialize(e){return new ye(e)}static fromConfig(e){return new ye(e)}static deserializeConfig(e){const{extensions:n,maxSize:t,maxFiles:a,...r}=e;return{...x._deserializeConfig(r),extensions:n,maxSize:t,maxFiles:a}}static serializeConfig(e){const{extensions:n,maxSize:t,maxFiles:a,...r}=e;return{...x._serializeConfig(r),extensions:n,maxSize:t,maxFiles:a}}serializeValue(e){return[]}deserializeValue(e){return[]}render(){return i.jsx(bl,{field:this})}isSerializedValue(e){return Array.isArray(e)&&e.length===0}isValue(e){return Array.isArray(e)?e.every(n=>n instanceof be||n instanceof de):!1}areValuesEqual(e,n){return yi(e,n)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(e,n){return e.length===n.length}}const Vl=o.memo(l=>{const{field:e}=l,{size:n}=o.use(L),{value:t,name:a,onBlur:r,onChange:c,error:f,disabled:h}=_({field:e}),u=o.useCallback(C=>{const F=C.target.value;F!==""&&!URL.canParse(F)||c(F!==""?new URL(F):null)},[c]),p=o.useCallback(()=>{r()},[r]),m=o.useCallback(C=>{C.key==="Enter"&&C.preventDefault()},[]),g=o.useCallback(()=>{t!==null&&window.open(t,"_blank","noopener,noreferrer")},[t]);return i.jsx(B,{size:n,inputId:e.id,label:e.label,description:e.description,required:e.required,error:f,image:e.image,children:i.jsxs("div",{className:"flex w-full gap-2",children:[i.jsx(s.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:n,children:i.jsx(s.Input.Field,{id:e.id,className:"truncate",name:a,value:t?t.toString():"",type:"url",inputMode:"url",placeholder:e.placeholder??"https://example.com",onChange:u,onBlur:p,disabled:h,onKeyDown:m})}),i.jsx(s.IconButton,{size:n,variant:"soft",accentColor:"base",type:"button",disabled:t===null,onClick:g,children:i.jsx(s.LuIcon,{icon:Rs})})]})})});Vl.displayName="URLFieldInput";class xe extends x{type="url";placeholder;constructor(e){const{placeholder:n,...t}=e;super(t),this.placeholder=n}serialize(){return{...super.serialize(),placeholder:this.placeholder}}config(){return{...super.config(),placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new xe({...this.getOptions(),id:e})}setOptions(e){"placeholder"in e&&(this.placeholder=e.placeholder),super.setOptions(e)}static deserialize(e){return new xe(e)}static fromConfig(e){return new xe(e)}static deserializeConfig(e){const{placeholder:n,...t}=e;return{...x._deserializeConfig(t),placeholder:n}}static serializeConfig(e){const{placeholder:n,...t}=e;return{...x._serializeConfig(t),placeholder:n}}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,n){return e===n}areValuesEqual(e,n){return e?.toString()===n?.toString()}render(){return i.jsx(Vl,{field:this})}}const Oe={date:Se,time:Ne,number:U,boolean:ae,select:fe,string:pe,url:xe,text:ge,upload:ye,qr:Ve,"multi-string":le,"multi-select":ee,radio:ue,"checkbox-list":R,"pass-fail":ce,otp:re,rating:he},Nl=Object.keys(Oe),E={"checkbox-list":{description:"Allows the user to select a multiple options from a list.",group:M.Selection,icon:Qs,name:"Checkbox list"},"multi-select":{description:"Allows the user to select a multiple options from a list of options.",group:M.Selection,icon:la,name:"Multi-select"},"multi-string":{description:"Allows the user to provide multiple unique strings.",group:M.Text,icon:aa,name:"Multi-string"},"pass-fail":{description:"Track pass, fail, or N/A outcome.",group:M.Assessment,icon:Ys,name:"Pass - Fail"},boolean:{description:"Perfect for both optional and required yes/no questions.",group:M.Selection,icon:ua,name:"Checkbox"},date:{description:"Allows specifying a date.",group:M.Temporal,icon:Hs,name:"Date"},time:{description:"Allows specifying a time and UTC offset.",group:M.Temporal,icon:pa,name:"Time"},number:{description:"Allows specifying a number within a given range.",group:M.Numeric,icon:ia,name:"Number"},otp:{description:"Allows specifying a number within a given range.",group:M.Verification,icon:oa,name:"OTP"},qr:{description:"Used for scanning/reading QR and barcodes.",group:M.Capture,icon:da,name:"Scan"},radio:{description:"Allows the user to select a single option from a list of options.",group:M.Selection,icon:Ks,name:"Option list"},rating:{description:"Allows users to select a rating value.",group:M.Assessment,icon:Kt,name:"Rating"},select:{description:"Allows the user to select a single option from a list of options.",group:M.Selection,icon:sa,name:"Dropdown"},string:{description:"Short text fields can hold up to 500 characters on a single line.",group:M.Text,icon:fa,name:"Short Text"},text:{description:"Paragraph fields can hold up to 10000 characters and can have multiple lines.",group:M.Text,icon:Us,name:"Paragraph"},upload:{description:"Allows a file to be uploaded.",group:M.Capture,icon:et,name:"Upload"},url:{description:"Allows users to enter a URL.",group:M.Text,icon:ta,name:"URL"}},xl={[M.Assessment]:{name:"Assessment"},[M.Capture]:{name:"Capture"},[M.Numeric]:{name:"Numeric"},[M.Selection]:{name:"Selection"},[M.Temporal]:{name:"Temporal"},[M.Text]:{name:"Text"},[M.Verification]:{name:"Verification"}},A="Unlabelled",bi="Unlabelled";class Il extends Re{id;value;constructor(e){const{id:n,value:t}=e;super(),this.id=n,this.value=t}serialize(){return{id:this.id,type:this.type,value:this.serializeValue(),modifier:this.modifier}}getValue=()=>this.value;setValue=e=>{this.value=e,this.notify(this)}}class y extends Il{field;constructor(e){const{field:n,...t}=e;super(t),this.field=n}serialize(){return{...super.serialize(),field:this.field.id}}isApplicable=e=>this.field.isValue(e);accessorFn=e=>e[this.field.id]}const Ml=o.memo,Ie=Ml(function(l){const{ref:e,children:n,...t}=l,a=o.useCallback(r=>typeof n=="function"?i.jsxs(i.Fragment,{children:[n(r),i.jsx(s.Menu.SelectedIndicator,{className:"ml-[auto]",children:i.jsx(s.LuIcon,{icon:G})})]}):i.jsxs(i.Fragment,{children:[n,i.jsx(s.Menu.SelectedIndicator,{className:"ml-[auto]",children:i.jsx(s.LuIcon,{icon:G})})]}),[n]);return i.jsx(s.Menu.SelectItem,{ref:e,...t,children:a})}),ql=Ml(function(l){const{ref:e,children:n,...t}=l,a=o.useCallback(r=>typeof n=="function"?i.jsxs(i.Fragment,{children:[n(r),i.jsx(s.Menu.SelectedIndicator,{className:"ml-auto",children:i.jsx(s.LuIcon,{icon:G})})]}):i.jsxs(i.Fragment,{children:[n,i.jsx(s.Menu.SelectedIndicator,{className:"ml-auto",children:i.jsx(s.LuIcon,{icon:G})})]}),[n]);return i.jsx(s.Menu.MultiSelectItem,{ref:e,...t,children:a})}),mt=o.memo(l=>{const{ref:e,children:n,...t}=l,a=o.useCallback(r=>typeof n=="function"?i.jsxs(i.Fragment,{children:[n(r),i.jsx(s.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:c=>c==="indeterminate"?i.jsx(s.LuIcon,{icon:gi}):i.jsx(s.LuIcon,{icon:G})})]}):i.jsxs(i.Fragment,{children:[n,i.jsx(s.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:c=>c==="indeterminate"?i.jsx(s.LuIcon,{icon:gi}):i.jsx(s.LuIcon,{icon:G})})]}),[n]);return i.jsx(s.Menu.SelectAllItem,{ref:e,...t,children:a})});mt.displayName="SelectAllItemTemplate";const Ct=o.memo(l=>{const{children:e,open:n,onOpenChange:t,defaultOpen:a,modal:r,size:c,align:f,accentColor:h="base",...u}=l;return i.jsxs(s.Popover.Root,{open:n,onOpenChange:t,defaultOpen:a,modal:r,children:[i.jsx(s.Popover.Trigger,{asChild:!0,children:e}),i.jsx(s.Popover.Content,{size:c,align:f,children:i.jsx(s.DayPicker,{size:c,accentColor:h,...u})})]})});Ct.displayName="DayPickerPopover";const Tl=o.memo(l=>{const{children:e,open:n,onOpenChange:t,defaultOpen:a,modal:r,size:c,accentColor:f="base",values:h,onValuesChange:u,placeholder:p="Enter text",...m}=l,[g,C]=o.useState(""),F=o.useCallback(I=>{C(I.target.value)},[]),w=o.useCallback(I=>{I.key==="Enter"&&(I.preventDefault(),I.stopPropagation(),u([...h,g]),C(""))},[g,u,h]),S=o.useCallback(()=>{u([...h,g]),C("")},[g,u,h]),v=o.useCallback(I=>{const q=[...h];q.splice(I,1),u(q)},[u,h]);return i.jsxs(s.Popover.Root,{open:n,onOpenChange:t,defaultOpen:a,modal:r,children:[i.jsx(s.Popover.Trigger,{asChild:!0,children:e}),i.jsx(s.Popover.Content,{size:c,onClick:s.stopPropagation,accentColor:f,...m,children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx(s.Input.Root,{className:"grow",accentColor:"base",variant:"outline",size:"sm",children:i.jsx(s.Input.Field,{value:g,onChange:F,onKeyDown:w,placeholder:p,...m})}),i.jsx(s.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button",onClick:S,children:i.jsx(s.LuIcon,{icon:X})})]}),h.length>0&&i.jsx("div",{className:"flex flex-col gap-1",children:h.map((I,q)=>i.jsxs(s.Badge,{className:"flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[i.jsx("span",{className:"truncate",children:I}),i.jsx(s.IconButton,{size:"xs",variant:"ghost",type:"button",accentColor:"base",onClick:()=>{v(q)},children:i.jsx(s.LuIcon,{icon:te})})]},`${I}-${q}`))})]})})]})});Tl.displayName="NumberInputPopover";const Me=o.memo(l=>{const{children:e,open:n,onOpenChange:t,defaultOpen:a,modal:r,size:c,accentColor:f="base",value:h,onValueChange:u,placeholder:p="Enter a number",...m}=l,[g,C]=o.useState(null);o.useEffect(()=>{h!==void 0&&C(h)},[h]);const F=o.useCallback(S=>{const v=S.target.valueAsNumber;C(isNaN(v)?null:v)},[]),w=o.useCallback(S=>{const v=S.target.valueAsNumber;u?.(isNaN(v)?null:v)},[u]);return i.jsxs(s.Popover.Root,{open:n,onOpenChange:t,defaultOpen:a,modal:r,children:[i.jsx(s.Popover.Trigger,{asChild:!0,children:e}),i.jsx(s.Popover.Content,{size:c,onClick:s.stopPropagation,...m,children:i.jsx(s.Input.Root,{size:c,accentColor:f,children:i.jsx(s.Input.Field,{placeholder:p,type:"number",value:g??"",onChange:F,onBlur:w})})})]})});Me.displayName="NumberInputPopover";const $=l=>{const{condition:e,onClick:n,...t}=l,a=o.useCallback(()=>{n(e)},[e,n]);return i.jsx(s.IconButton,{onClick:a,...t,children:i.jsx(s.LuIcon,{icon:te})})};$.displayName="RemoveConditionButton";const nn=o.memo(l=>{const{ref:e,selectFieldOptions:n,...t}=l,a=o.useMemo(()=>se(n),[n]);return i.jsxs(s.Menu.MultiSelectGroup,{ref:e,...t,children:[i.jsx(mt,{children:"Select all"}),a.map(r=>i.jsx(ql,{value:r.value,children:i.jsx("span",{className:"truncate",children:r.label})},r.value))]})});nn.displayName="SelectFieldOptionMultiSelectGroup";const yt=o.memo(l=>{const{ref:e,selectFieldOptions:n,...t}=l,a=o.useMemo(()=>se(n),[n]);return i.jsx(s.Menu.SelectGroup,{ref:e,...t,children:a.map(r=>i.jsx(Ie,{value:r.value,children:i.jsx("span",{className:"truncate",children:r.label})},r.value))})});yt.displayName="SelectFieldOptionSelectGroup";const Ee=o.memo(l=>{const{children:e,open:n,onOpenChange:t,defaultOpen:a,modal:r,size:c,accentColor:f="base",value:h,onValueChange:u,placeholder:p="Enter text",...m}=l,[g,C]=o.useState(""),F=o.useCallback(S=>{C(S.target.value)},[]),w=o.useCallback(S=>{const v=S.target.value;u?.(v)},[u]);return o.useEffect(()=>{h&&C(h)},[h]),i.jsxs(s.Popover.Root,{open:n,onOpenChange:t,defaultOpen:a,modal:r,children:[i.jsx(s.Popover.Trigger,{asChild:!0,children:e}),i.jsx(s.Popover.Content,{size:c,onClick:s.stopPropagation,...m,children:i.jsx(s.Input.Root,{size:c,accentColor:f,children:i.jsx(s.Input.Field,{placeholder:p,type:"text",value:g,onChange:F,onBlur:w})})})]})});Ee.displayName="TextInputPopover";const Vi=o.memo(l=>{const{children:e,open:n,onOpenChange:t,defaultOpen:a,modal:r,size:c="sm",accentColor:f="base",value:h,onValueChange:u,...p}=l;return i.jsxs(s.Popover.Root,{open:n,onOpenChange:t,defaultOpen:a,modal:r,children:[i.jsx(s.Popover.Trigger,{asChild:!0,children:e}),i.jsx(s.Popover.Content,{size:c,onClick:s.stopPropagation,accentColor:f,...p,children:i.jsx(Si,{compact:!0,size:c,value:h,onChange:u})})]})});Vi.displayName="TimeInputPopover";const k=l=>{const{children:e,required:n,value:t,defaultValue:a,onValueChange:r,modifierConfig:c,size:f="sm",variant:h,accentColor:u,radius:p}=l;return i.jsxs(s.Menu.Root,{align:"start",children:[i.jsx(s.Menu.ClickTrigger,{children:e}),i.jsx(s.Menu.Content,{size:f,variant:h,radius:p,accentColor:u,children:i.jsx(s.Menu.SelectGroup,{required:n,defaultValue:a,value:t,onValueChange:r,children:Object.keys(c).map(m=>{const{label:g}=c[m];return i.jsx(Ie,{value:m,children:g},m)})})})]})},P=(l,e,n)=>o.useCallback(t=>{const{klass:a,isTransferable:r,defaultValue:c}=e[t],f=l.getValue(),h=new a({id:l.id,value:r(f)?f:c(),field:l.field});n(l,h)},[l,e,n]);class Le extends y{type="boolean";modifier="equals";static deserialize(e,n){return new Le({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===this.value}}class tn extends y{type="boolean";modifier="notEquals";static deserialize(e,n){return new tn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e!==this.value}}const Ni={equals:{klass:Le,label:"is",isTransferable:l=>!0,defaultValue:()=>!0},notEquals:{klass:tn,label:"is not",isTransferable:l=>!0,defaultValue:()=>!0}},Ol=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=e.getValue(),r=e.modifier,c=()=>{switch(a){case!0:return"true";case!1:return"false"}},f=P(e,Ni,n);return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:r,onValueChange:f,modifierConfig:Ni,children:i.jsx(s.Button,{type:"button",children:Ni[r].label})}),i.jsxs(s.Menu.Root,{children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsx(s.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:c()})}),i.jsx(s.Menu.Content,{size:"sm",children:i.jsxs(s.Menu.SelectGroup,{required:!0,value:a,onValueChange:e.setValue,children:[i.jsx(Ie,{value:!0,children:"true"}),i.jsx(Ie,{value:!1,children:"false"})]})})]}),i.jsx($,{condition:e,onClick:t})]})};class Be extends y{type="checkbox-list";modifier="equals";static deserialize(e,n){return new Be({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return n.size===t.size&&t.isSubsetOf(n)}}}class ln extends y{type="checkbox-list";modifier="notEquals";static deserialize(e,n){return new ln({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return n.size!==t.size||!t.isSubsetOf(n)}}}class sn extends y{type="checkbox-list";modifier="every";static deserialize(e,n){return new sn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return n.isSubsetOf(t)}}}class an extends y{type="checkbox-list";modifier="some";static deserialize(e,n){return new an({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return!n.isDisjointFrom(t)}}}class rn extends y{type="checkbox-list";modifier="none";static deserialize(e,n){return new rn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return n.isDisjointFrom(t)}}}const xi={equals:{klass:Be,label:"is",isTransferable:l=>!0,defaultValue:()=>[]},notEquals:{klass:ln,label:"is not",isTransferable:l=>!0,defaultValue:()=>[]},every:{klass:sn,label:"has all of",isTransferable:l=>!0,defaultValue:()=>[]},some:{klass:an,label:"has any of",isTransferable:l=>!0,defaultValue:()=>[]},none:{klass:rn,label:"has none of",isTransferable:l=>!0,defaultValue:()=>[]}},El=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,xi,n),r=()=>i.jsxs(s.Menu.Root,{children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsxs(s.Button,{type:"button",children:[e.getValue().length," options"]})}),i.jsx(s.Menu.Content,{size:"sm",children:i.jsx(nn,{selectFieldOptions:e.field.options,values:e.getValue(),onValuesChange:e.setValue})})]});return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:xi,children:i.jsx(s.Button,{type:"button",children:xi[e.modifier].label})}),r(),i.jsx($,{condition:e,onClick:t})]})};class Ii extends Re{conditions;constructor(e){super(),this.conditions=this.initConditions(e)}conditionObserver=()=>{this.conditions=[...this.conditions],this.notify(this)};initConditions=e=>{for(const n of e)n.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)}replaceCondition(e,n){this.conditions=this.initConditions(this.conditions.map(t=>t.id===e.id?n:t)),this.notify(this)}removeCondition(e){this.conditions=this.initConditions(this.conditions.filter(n=>n.id!==e.id)),this.notify(this)}removeConditions(e){const n=new Set(e.map(t=>t.id));this.conditions=this.initConditions(this.conditions.filter(t=>!n.has(t.id))),this.notify(this)}applyConditions(e){return this.conditions.length===0?!0:this.conditions.map(t=>[t.getApplyFn(),t.isApplicable,t.accessorFn]).every(([t,a,r])=>{const c=r(e);return a(c)?t(c):!1})}}const wa=(l,e)=>o.useMemo(()=>{const n=new Ii(l);return n.observe(t=>e(t.getConditions())),n},[l,e]);class Ae extends y{type="date";modifier="equals";static deserialize(e,n){return new Ae({...e,value:new Date(e.value),field:n})}serializeValue(){return this.value.toISOString()}getApplyFn(){return e=>e===null?!1:e.getTime()===this.value.getTime()}}class on extends y{type="date";modifier="notEquals";static deserialize(e,n){return new on({...e,value:new Date(e.value),field:n})}serializeValue(){return this.value.toISOString()}getApplyFn(){return e=>e===null?!1:e.getTime()!==this.value.getTime()}}class dn extends y{type="date";modifier="before";static deserialize(e,n){return new dn({...e,value:new Date(e.value),field:n})}serializeValue(){return this.value.toISOString()}getApplyFn(){return e=>e===null?!1:e.getTime()<this.value.getTime()}}class cn extends y{type="date";modifier="after";static deserialize(e,n){return new cn({...e,value:new Date(e.value),field:n})}serializeValue(){return this.value.toISOString()}getApplyFn(){return e=>e===null?!1:e.getTime()>this.value.getTime()}}class un extends y{type="date";modifier="in";static deserialize(e,n){return new un({...e,value:{from:e.value.from?new Date(e.value.from):void 0,to:e.value.to?new Date(e.value.to):void 0},field:n})}serializeValue(){return{from:this.value.from?.toISOString()??null,to:this.value.to?.toISOString()??null}}getApplyFn(){return e=>!(e===null||this.value.from&&this.value.from.getTime()>e.getTime()||this.value.to&&this.value.to.getTime()<e.getTime())}}class hn extends y{type="date";modifier="notIn";static deserialize(e,n){return new hn({...e,value:{from:e.value.from?new Date(e.value.from):void 0,to:e.value.to?new Date(e.value.to):void 0},field:n})}serializeValue(){return{from:this.value.from?.toISOString()??null,to:this.value.to?.toISOString()??null}}getApplyFn(){return e=>e===null?!1:!!(this.value.from&&this.value.from.getTime()>e.getTime()||this.value.to&&this.value.to.getTime()<e.getTime())}}const Mi={equals:{klass:Ae,label:"is",isTransferable:l=>l instanceof Date,defaultValue:()=>new Date(new Date().setHours(0,0,0,0))},notEquals:{klass:on,label:"is not",isTransferable:l=>l instanceof Date,defaultValue:()=>new Date(new Date().setHours(0,0,0,0))},before:{klass:dn,label:"before",isTransferable:l=>l instanceof Date,defaultValue:()=>new Date(new Date().setHours(0,0,0,0))},after:{klass:cn,label:"after",isTransferable:l=>l instanceof Date,defaultValue:()=>new Date(new Date().setHours(0,0,0,0))},in:{klass:un,label:"in between",isTransferable:l=>!(l instanceof Date),defaultValue:()=>({from:void 0,to:void 0})},notIn:{klass:hn,label:"not in between",isTransferable:l=>!(l instanceof Date),defaultValue:()=>({from:void 0,to:void 0})}},Ll=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,Mi,n),r=()=>{switch(e.modifier){case"in":case"notIn":{const c=e.getValue();return i.jsx(Ct,{required:!0,mode:"range",size:"sm",selected:c,onSelect:e.setValue,children:i.jsxs(s.Button,{type:"button",className:"truncate",children:[c.from?.toLocaleDateString()??"..."," - ",c.to?.toLocaleDateString()??"..."]})})}default:return i.jsx(Ct,{required:!0,mode:"single",size:"sm",selected:e.getValue(),onSelect:e.setValue,children:i.jsx(s.Button,{type:"button",className:"truncate",children:e.getValue().toLocaleDateString()})})}};return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:Mi,children:i.jsx(s.Button,{type:"button",children:Mi[e.modifier].label})}),r(),i.jsx($,{condition:e,onClick:t})]})};class De extends y{type="multi-select";modifier="equals";static deserialize(e,n){return new De({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return n.size===t.size&&t.isSubsetOf(n)}}}class fn extends y{type="multi-select";modifier="notEquals";static deserialize(e,n){return new fn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return n.size!==t.size||!t.isSubsetOf(n)}}}class pn extends y{type="multi-select";modifier="every";static deserialize(e,n){return new pn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return n.isSubsetOf(t)}}}class gn extends y{type="multi-select";modifier="some";static deserialize(e,n){return new gn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return!n.isDisjointFrom(t)}}}class mn extends y{type="multi-select";modifier="none";static deserialize(e,n){return new mn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return n.isDisjointFrom(t)}}}const qi={equals:{klass:De,label:"is",isTransferable:l=>!0,defaultValue:()=>[]},notEquals:{klass:fn,label:"is not",isTransferable:l=>!0,defaultValue:()=>[]},every:{klass:pn,label:"has all of",isTransferable:l=>!0,defaultValue:()=>[]},some:{klass:gn,label:"has any of",isTransferable:l=>!0,defaultValue:()=>[]},none:{klass:mn,label:"has none of",isTransferable:l=>!0,defaultValue:()=>[]}},Bl=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,qi,n),r=()=>i.jsxs(s.Menu.Root,{children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsxs(s.Button,{type:"button",children:[e.getValue().length," options"]})}),i.jsx(s.Menu.Content,{size:"sm",children:i.jsx(nn,{selectFieldOptions:e.field.options,values:e.getValue(),onValuesChange:e.setValue})})]});return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:qi,children:i.jsx(s.Button,{type:"button",children:qi[e.modifier].label})}),r(),i.jsx($,{condition:e,onClick:t})]})};class _e extends y{type="multi-string";modifier="equals";static deserialize(e,n){return new _e({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return n.size===t.size&&t.isSubsetOf(n)}}}class Cn extends y{type="multi-string";modifier="notEquals";static deserialize(e,n){return new Cn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return n.size!==t.size||!t.isSubsetOf(n)}}}class yn extends y{type="multi-string";modifier="every";static deserialize(e,n){return new yn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return n.isSubsetOf(t)}}}class vn extends y{type="multi-string";modifier="some";static deserialize(e,n){return new vn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return!n.isDisjointFrom(t)}}}class Fn extends y{type="multi-string";modifier="none";static deserialize(e,n){return new Fn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>{const n=new Set(this.value),t=new Set(e);return n.isDisjointFrom(t)}}}const Ti={equals:{klass:_e,label:"is",isTransferable:l=>!0,defaultValue:()=>[]},notEquals:{klass:Cn,label:"is not",isTransferable:l=>!0,defaultValue:()=>[]},every:{klass:yn,label:"has all of",isTransferable:l=>!0,defaultValue:()=>[]},some:{klass:vn,label:"has any of",isTransferable:l=>!0,defaultValue:()=>[]},none:{klass:Fn,label:"has none of",isTransferable:l=>!0,defaultValue:()=>[]}},Al=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,Ti,n),r=()=>{const c=e.getValue();return i.jsx(Tl,{values:c,onValuesChange:e.setValue,size:"sm",children:i.jsx(s.Button,{type:"button",className:"truncate",children:c.length===1?c[0]:`${c.length} values`})})};return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:Ti,children:i.jsx(s.Button,{type:"button",children:Ti[e.modifier].label})}),r(),i.jsx($,{condition:e,onClick:t})]})};class $e extends y{type="number";modifier="equals";static deserialize(e,n){return new $e({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e===this.value}}class zn extends y{type="number";modifier="notEquals";static deserialize(e,n){return new zn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e!==this.value}}class wn extends y{type="number";modifier="lessThan";static deserialize(e,n){return new wn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e<this.value}}class Sn extends y{type="number";modifier="lessThanOrEquals";static deserialize(e,n){return new Sn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e<=this.value}}class bn extends y{type="number";modifier="greaterThan";static deserialize(e,n){return new bn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e>this.value}}class Vn extends y{type="number";modifier="greaterThanOrEquals";static deserialize(e,n){return new Vn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e>=this.value}}class Nn extends y{type="number";modifier="inRange";static deserialize(e,n){return new Nn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>!(e===null||this.value.to!==null&&e>this.value.to||this.value.from!==null&&e<this.value.from)}}class xn extends y{type="number";modifier="notInRange";static deserialize(e,n){return new xn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:this.value.to!==null&&e>this.value.to||this.value.from!==null&&e<this.value.from}}const Oi={equals:{klass:$e,label:"is",isTransferable:l=>typeof l=="number",defaultValue:()=>0},notEquals:{klass:zn,label:"is not",isTransferable:l=>typeof l=="number",defaultValue:()=>0},lessThan:{klass:wn,label:"is less than",isTransferable:l=>typeof l=="number",defaultValue:()=>0},lessThanOrEquals:{klass:Sn,label:"is less than or equal to",isTransferable:l=>typeof l=="number",defaultValue:()=>0},greaterThan:{klass:bn,label:"is greater than",isTransferable:l=>typeof l=="number",defaultValue:()=>0},greaterThanOrEquals:{klass:Vn,label:"is greater than or equal to",isTransferable:l=>typeof l=="number",defaultValue:()=>0},inRange:{klass:Nn,label:"is between",isTransferable:l=>typeof l=="object",defaultValue:()=>({from:null,to:null})},notInRange:{klass:xn,label:"is not between",isTransferable:l=>typeof l=="object",defaultValue:()=>({from:null,to:null})}},Dl=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,Oi,n),r=o.useCallback(u=>{u===null||e.modifier==="inRange"||e.modifier==="notInRange"||e.setValue(u)},[e]),c=o.useCallback(u=>{e.modifier!=="inRange"&&e.modifier!=="notInRange"||e.setValue({...e.getValue(),from:u})},[e]),f=o.useCallback(u=>{e.modifier!=="inRange"&&e.modifier!=="notInRange"||e.setValue({...e.getValue(),to:u})},[e]),h=()=>{switch(e.modifier){case"inRange":case"notInRange":{const u=e.getValue();return i.jsxs(i.Fragment,{children:[i.jsx(Me,{value:u.from,onValueChange:c,size:"sm",children:i.jsx(s.Button,{type:"button",className:"truncate",children:u.from??"..."})}),i.jsx(Me,{value:u.to,onValueChange:f,size:"sm",children:i.jsx(s.Button,{type:"button",className:"truncate",children:u.to??"..."})})]})}default:return i.jsx(Me,{value:e.getValue(),onValueChange:r,size:"sm",children:i.jsx(s.Button,{type:"button",className:"truncate",children:e.getValue()})})}};return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:Oi,children:i.jsx(s.Button,{type:"button",children:Oi[e.modifier].label})}),h(),i.jsx($,{condition:e,onClick:t})]})};class ke extends y{type="otp";modifier="equals";static deserialize(e,n){return new ke({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===this.value}}class In extends y{type="otp";modifier="notEquals";static deserialize(e,n){return new In({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e!==this.value}}class Mn extends y{type="otp";modifier="includes";static deserialize(e,n){return new Mn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e.includes(this.value)}}class qn extends y{type="otp";modifier="excludes";static deserialize(e,n){return new qn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>!e.includes(this.value)}}const Ei={equals:{klass:ke,label:"is",isTransferable:l=>!0,defaultValue:()=>""},notEquals:{klass:In,label:"is not",isTransferable:l=>!0,defaultValue:()=>""},includes:{klass:Mn,label:"includes",isTransferable:l=>!0,defaultValue:()=>""},excludes:{klass:qn,label:"does not include",isTransferable:l=>!0,defaultValue:()=>""}},_l=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,Ei,n),r=()=>i.jsx(Ee,{value:e.getValue(),onValueChange:e.setValue,size:"sm",children:i.jsx(s.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:i.jsx("span",{className:"truncate",children:e.getValue()||"..."})})});return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:Ei,children:i.jsx(s.Button,{type:"button",children:Ei[e.modifier].label})}),r(),i.jsx($,{condition:e,onClick:t})]})};class Pe extends y{type="pass-fail";modifier="equals";static deserialize(e,n){return new Pe({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e.status===null?!1:e.status===this.value}}class Tn extends y{type="pass-fail";modifier="notEquals";static deserialize(e,n){return new Tn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e.status===null?!1:e.status!==this.value}}class On extends y{type="pass-fail";modifier="includes";static deserialize(e,n){return new On({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e.status===null?!1:this.value.includes(e.status)}}class En extends y{type="pass-fail";modifier="excludes";static deserialize(e,n){return new En({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e.status===null?!1:!this.value.includes(e.status)}}const Li={equals:{klass:Pe,label:"is",isTransferable:l=>typeof l=="string",defaultValue:()=>"pass"},notEquals:{klass:Tn,label:"is not",isTransferable:l=>typeof l=="string",defaultValue:()=>"pass"},includes:{klass:On,label:"is any of",isTransferable:l=>Array.isArray(l),defaultValue:()=>[]},excludes:{klass:En,label:"is none of",isTransferable:l=>Array.isArray(l),defaultValue:()=>[]}},$l=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,Li,n),r=()=>{switch(e.modifier){case"equals":case"notEquals":return i.jsxs(s.Menu.Root,{children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsx(s.Button,{type:"button",children:oe[e.getValue()].label})}),i.jsx(s.Menu.Content,{size:"sm",children:i.jsx(s.Menu.SelectGroup,{required:!0,value:e.getValue(),onValueChange:e.setValue,children:Te.map(c=>i.jsx(Ie,{value:c,children:oe[c].label},c))})})]});case"includes":case"excludes":return i.jsxs(s.Menu.Root,{children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsxs(s.Button,{type:"button",children:[e.getValue().length," statuses"]})}),i.jsx(s.Menu.Content,{size:"sm",children:i.jsxs(s.Menu.MultiSelectGroup,{values:e.getValue(),onValuesChange:e.setValue,children:[i.jsx(mt,{children:"Select all"}),Te.map(c=>i.jsxs(ql,{value:c,children:[i.jsx(s.LuIcon,{icon:oe[c].icon}),oe[c].label]},c))]})})]})}};return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:Li,children:i.jsx(s.Button,{type:"button",children:Li[e.modifier].label})}),r(),i.jsx($,{condition:e,onClick:t})]})};class je extends y{type="radio";modifier="equals";static deserialize(e,n){return new je({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e===this.value}}class Ln extends y{type="radio";modifier="notEquals";static deserialize(e,n){return new Ln({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e!==this.value}}class Bn extends y{type="radio";modifier="includes";static deserialize(e,n){return new Bn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:this.value.includes(e)}}class An extends y{type="radio";modifier="excludes";static deserialize(e,n){return new An({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:!this.value.includes(e)}}const Bi={equals:{klass:je,label:"is",isTransferable:l=>typeof l=="string",defaultValue:()=>""},notEquals:{klass:Ln,label:"is not",isTransferable:l=>typeof l=="string",defaultValue:()=>""},includes:{klass:Bn,label:"is any of",isTransferable:l=>Array.isArray(l),defaultValue:()=>[]},excludes:{klass:An,label:"is none of",isTransferable:l=>Array.isArray(l),defaultValue:()=>[]}},kl=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,Bi,n),r=()=>{switch(e.modifier){case"equals":case"notEquals":{const c=e.getValue(),f=se(e.field.options).find(h=>h.value===c)?.label;return i.jsxs(s.Menu.Root,{children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsx(s.Button,{type:"button",className:"truncate",children:f??(c||"...")})}),i.jsx(s.Menu.Content,{size:"sm",children:i.jsx(yt,{required:!0,selectFieldOptions:e.field.options,value:c,onValueChange:e.setValue})})]})}case"includes":case"excludes":return i.jsxs(s.Menu.Root,{children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsxs(s.Button,{type:"button",children:[e.getValue().length," options"]})}),i.jsx(s.Menu.Content,{size:"sm",children:i.jsx(nn,{selectFieldOptions:e.field.options,values:e.getValue(),onValuesChange:e.setValue})})]})}};return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:Bi,children:i.jsx(s.Button,{type:"button",children:Bi[e.modifier].label})}),r(),i.jsx($,{condition:e,onClick:t})]})};class Ue extends y{type="rating";modifier="equals";static deserialize(e,n){return new Ue({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e===this.value}}class Dn extends y{type="rating";modifier="notEquals";static deserialize(e,n){return new Dn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e!==this.value}}class _n extends y{type="rating";modifier="lessThan";static deserialize(e,n){return new _n({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e<this.value}}class $n extends y{type="rating";modifier="lessThanOrEquals";static deserialize(e,n){return new $n({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e<=this.value}}class kn extends y{type="rating";modifier="greaterThan";static deserialize(e,n){return new kn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e>this.value}}class Pn extends y{type="rating";modifier="greaterThanOrEquals";static deserialize(e,n){return new Pn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e>=this.value}}class jn extends y{type="rating";modifier="inRange";static deserialize(e,n){return new jn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>!(e===null||this.value.to!==null&&e>this.value.to||this.value.from!==null&&e<this.value.from)}}class Un extends y{type="rating";modifier="notInRange";static deserialize(e,n){return new Un({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:this.value.to!==null&&e>this.value.to||this.value.from!==null&&e<this.value.from}}const Ai={equals:{klass:Ue,label:"is",isTransferable:l=>typeof l=="number",defaultValue:()=>0},notEquals:{klass:Dn,label:"is not",isTransferable:l=>typeof l=="number",defaultValue:()=>0},lessThan:{klass:_n,label:"is less than",isTransferable:l=>typeof l=="number",defaultValue:()=>0},lessThanOrEquals:{klass:$n,label:"is less than or equal to",isTransferable:l=>typeof l=="number",defaultValue:()=>0},greaterThan:{klass:kn,label:"is greater than",isTransferable:l=>typeof l=="number",defaultValue:()=>0},greaterThanOrEquals:{klass:Pn,label:"is greater than or equal to",isTransferable:l=>typeof l=="number",defaultValue:()=>0},inRange:{klass:jn,label:"is between",isTransferable:l=>typeof l=="object",defaultValue:()=>({from:null,to:null})},notInRange:{klass:Un,label:"is not between",isTransferable:l=>typeof l=="object",defaultValue:()=>({from:null,to:null})}},Pl=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,Ai,n),r=o.useCallback(u=>{u===null||e.modifier==="inRange"||e.modifier==="notInRange"||e.setValue(u)},[e]),c=o.useCallback(u=>{e.modifier!=="inRange"&&e.modifier!=="notInRange"||e.setValue({...e.getValue(),from:u})},[e]),f=o.useCallback(u=>{e.modifier!=="inRange"&&e.modifier!=="notInRange"||e.setValue({...e.getValue(),to:u})},[e]),h=()=>{switch(e.modifier){case"inRange":case"notInRange":{const u=e.getValue();return i.jsxs(i.Fragment,{children:[i.jsx(Me,{value:u.from,onValueChange:c,size:"sm",children:i.jsx(s.Button,{type:"button",className:"truncate",children:u.from??"..."})}),i.jsx(Me,{value:u.to,onValueChange:f,size:"sm",children:i.jsx(s.Button,{type:"button",className:"truncate",children:u.to??"..."})})]})}default:return i.jsx(Me,{value:e.getValue(),onValueChange:r,size:"sm",children:i.jsx(s.Button,{type:"button",className:"truncate",children:e.getValue()})})}};return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:Ai,children:i.jsx(s.Button,{type:"button",children:Ai[e.modifier].label})}),h(),i.jsx($,{condition:e,onClick:t})]})};class Ge extends y{type="qr";modifier="equals";static deserialize(e,n){return new Ge({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===this.value}}class Gn extends y{type="qr";modifier="notEquals";static deserialize(e,n){return new Gn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e!==this.value}}class Jn extends y{type="qr";modifier="includes";static deserialize(e,n){return new Jn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e.includes(this.value)}}class Hn extends y{type="qr";modifier="excludes";static deserialize(e,n){return new Hn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>!e.includes(this.value)}}const Di={equals:{klass:Ge,label:"is",isTransferable:l=>!0,defaultValue:()=>""},notEquals:{klass:Gn,label:"is not",isTransferable:l=>!0,defaultValue:()=>""},includes:{klass:Jn,label:"includes",isTransferable:l=>!0,defaultValue:()=>""},excludes:{klass:Hn,label:"does not include",isTransferable:l=>!0,defaultValue:()=>""}},jl=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,Di,n),r=()=>i.jsx(Ee,{value:e.getValue(),onValueChange:e.setValue,size:"sm",children:i.jsx(s.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:i.jsx("span",{className:"truncate",children:e.getValue()||"..."})})});return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:Di,children:i.jsx(s.Button,{type:"button",children:Di[e.modifier].label})}),r(),i.jsx($,{condition:e,onClick:t})]})};class Je extends y{type="select";modifier="equals";static deserialize(e,n){return new Je({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e===this.value}}class Wn extends y{type="select";modifier="notEquals";static deserialize(e,n){return new Wn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:e!==this.value}}class Kn extends y{type="select";modifier="includes";static deserialize(e,n){return new Kn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:this.value.includes(e)}}class Xn extends y{type="select";modifier="excludes";static deserialize(e,n){return new Xn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===null?!1:!this.value.includes(e)}}const _i={equals:{klass:Je,label:"is",isTransferable:l=>typeof l=="string",defaultValue:()=>""},notEquals:{klass:Wn,label:"is not",isTransferable:l=>typeof l=="string",defaultValue:()=>""},includes:{klass:Kn,label:"is any of",isTransferable:l=>Array.isArray(l),defaultValue:()=>[]},excludes:{klass:Xn,label:"is none of",isTransferable:l=>Array.isArray(l),defaultValue:()=>[]}},Ul=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,_i,n),r=()=>{switch(e.modifier){case"equals":case"notEquals":{const c=e.getValue(),f=se(e.field.options).find(h=>h.value===c)?.label;return i.jsxs(s.Menu.Root,{children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsx(s.Button,{type:"button",className:"truncate",children:f??(c||"...")})}),i.jsx(s.Menu.Content,{size:"sm",children:i.jsx(yt,{required:!0,selectFieldOptions:e.field.options,value:c,onValueChange:e.setValue})})]})}case"includes":case"excludes":return i.jsxs(s.Menu.Root,{children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsxs(s.Button,{type:"button",children:[e.getValue().length," options"]})}),i.jsx(s.Menu.Content,{size:"sm",children:i.jsx(nn,{selectFieldOptions:e.field.options,values:e.getValue(),onValuesChange:e.setValue})})]})}};return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:_i,children:i.jsx(s.Button,{type:"button",children:_i[e.modifier].label})}),r(),i.jsx($,{condition:e,onClick:t})]})};class He extends y{type="string";modifier="equals";static deserialize(e,n){return new He({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===this.value}}class Zn extends y{type="string";modifier="notEquals";static deserialize(e,n){return new Zn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e!==this.value}}class Yn extends y{type="string";modifier="includes";static deserialize(e,n){return new Yn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e.includes(this.value)}}class Qn extends y{type="string";modifier="excludes";static deserialize(e,n){return new Qn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>!e.includes(this.value)}}const $i={equals:{klass:He,label:"is",isTransferable:l=>!0,defaultValue:()=>""},notEquals:{klass:Zn,label:"is not",isTransferable:l=>!0,defaultValue:()=>""},includes:{klass:Yn,label:"includes",isTransferable:l=>!0,defaultValue:()=>""},excludes:{klass:Qn,label:"does not include",isTransferable:l=>!0,defaultValue:()=>""}},Gl=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,$i,n),r=()=>i.jsx(Ee,{value:e.getValue(),onValueChange:e.setValue,size:"sm",children:i.jsx(s.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:i.jsx("span",{className:"truncate",children:e.getValue()||"..."})})});return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:$i,children:i.jsx(s.Button,{type:"button",children:$i[e.modifier].label})}),r(),i.jsx($,{condition:e,onClick:t})]})};class We extends y{type="text";modifier="equals";static deserialize(e,n){return new We({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e===this.value}}class Rn extends y{type="text";modifier="notEquals";static deserialize(e,n){return new Rn({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e!==this.value}}class ei extends y{type="text";modifier="includes";static deserialize(e,n){return new ei({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e.includes(this.value)}}class ni extends y{type="text";modifier="excludes";static deserialize(e,n){return new ni({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>!e.includes(this.value)}}const ki={equals:{klass:We,label:"is",isTransferable:l=>!0,defaultValue:()=>""},notEquals:{klass:Rn,label:"is not",isTransferable:l=>!0,defaultValue:()=>""},includes:{klass:ei,label:"includes",isTransferable:l=>!0,defaultValue:()=>""},excludes:{klass:ni,label:"does not include",isTransferable:l=>!0,defaultValue:()=>""}},Jl=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,ki,n),r=()=>i.jsx(Ee,{value:e.getValue(),onValueChange:e.setValue,size:"sm",children:i.jsx(s.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:i.jsx("span",{className:"truncate",children:e.getValue()||"..."})})});return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:ki,children:i.jsx(s.Button,{type:"button",children:ki[e.modifier].label})}),r(),i.jsx($,{condition:e,onClick:t})]})};class Ke extends y{type="time";modifier="equals";static deserialize(e,n){return new Ke({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>Y(e)?e===this.value:!1}}class ii extends y{type="time";modifier="notEquals";static deserialize(e,n){return new ii({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>Y(e)?e!==this.value:!1}}class ti extends y{type="time";modifier="before";static deserialize(e,n){return new ti({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>Y(e)?Ce(e)<Ce(this.value):!1}}class li extends y{type="time";modifier="after";static deserialize(e,n){return new li({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>Y(e)?Ce(e)>Ce(this.value):!1}}class si extends y{type="time";modifier="in";static deserialize(e,n){return new si({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>Y(e)?pt(e,this.value):!1}}class ai extends y{type="time";modifier="notIn";static deserialize(e,n){return new ai({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>Y(e)?!pt(e,this.value):!1}}const Pi={equals:{klass:Ke,label:"is",isTransferable:l=>typeof l=="string",defaultValue:()=>me(0,0)},notEquals:{klass:ii,label:"is not",isTransferable:l=>typeof l=="string",defaultValue:()=>me(0,0)},before:{klass:ti,label:"before",isTransferable:l=>typeof l=="string",defaultValue:()=>me(0,0)},after:{klass:li,label:"after",isTransferable:l=>typeof l=="string",defaultValue:()=>me(0,0)},in:{klass:si,label:"in between",isTransferable:l=>typeof l=="object",defaultValue:()=>({from:null,to:null})},notIn:{klass:ai,label:"not in between",isTransferable:l=>typeof l=="object",defaultValue:()=>({from:null,to:null})}},Hl=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,Pi,n),r=o.useCallback(u=>{u===null||e.modifier==="in"||e.modifier==="notIn"||e.setValue(u)},[e]),c=o.useCallback(u=>{e.modifier!=="in"&&e.modifier!=="notIn"||e.setValue({...e.getValue(),from:u})},[e]),f=o.useCallback(u=>{e.modifier!=="in"&&e.modifier!=="notIn"||e.setValue({...e.getValue(),to:u})},[e]),h=()=>{switch(e.modifier){case"in":case"notIn":{const u=e.getValue();return i.jsxs(i.Fragment,{children:[i.jsx(Vi,{value:u.from,onValueChange:c,size:"sm",children:i.jsx(s.Button,{type:"button",className:"truncate",children:u.from?wi(u.from):"..."})}),i.jsx(Vi,{value:u.to,onValueChange:f,size:"sm",children:i.jsx(s.Button,{type:"button",className:"truncate",children:u.to?wi(u.to):"..."})})]})}default:return i.jsx(Vi,{value:e.getValue(),onValueChange:r,size:"sm",children:i.jsx(s.Button,{type:"button",className:"truncate",children:wi(e.getValue())})})}};return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:Pi,children:i.jsx(s.Button,{type:"button",children:Pi[e.modifier].label})}),h(),i.jsx($,{condition:e,onClick:t})]})};class Xe extends y{type="upload";modifier="equals";static deserialize(e,n){return new Xe({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e.length>0}}class ri extends y{type="upload";modifier="notEquals";static deserialize(e,n){return new ri({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>e.length===0}}const ji={equals:{klass:Xe,label:"is",isTransferable:l=>!0,defaultValue:()=>!0},notEquals:{klass:ri,label:"is not",isTransferable:l=>!0,defaultValue:()=>!0}},Wl=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,ji,n),r=()=>i.jsxs(s.Menu.Root,{children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsx(s.Button,{type:"button",children:e.getValue()?"empty":"not empty"})}),i.jsx(s.Menu.Content,{size:"sm",children:i.jsxs(s.Menu.SelectGroup,{required:!0,value:e.getValue(),onValueChange:e.setValue,children:[i.jsx(Ie,{value:!0,children:"empty"}),i.jsx(Ie,{value:!1,children:"not empty"})]})})]});return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:ji,children:i.jsx(s.Button,{type:"button",children:ji[e.modifier].label})}),r(),i.jsx($,{condition:e,onClick:t})]})};class Ze extends y{type="url";modifier="equals";static deserialize(e,n){return new Ze({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>(e?.toString()??"")===this.value}}class oi extends y{type="url";modifier="notEquals";static deserialize(e,n){return new oi({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>(e?.toString()??"")!==this.value}}class di extends y{type="url";modifier="includes";static deserialize(e,n){return new di({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>(e?.toString()??"").includes(this.value)}}class ci extends y{type="url";modifier="excludes";static deserialize(e,n){return new ci({...e,field:n})}serializeValue(){return this.value}getApplyFn(){return e=>!(e?.toString()??"").includes(this.value)}}const Ui={equals:{klass:Ze,label:"is",isTransferable:l=>!0,defaultValue:()=>""},notEquals:{klass:oi,label:"is not",isTransferable:l=>!0,defaultValue:()=>""},includes:{klass:di,label:"includes",isTransferable:l=>!0,defaultValue:()=>""},excludes:{klass:ci,label:"does not include",isTransferable:l=>!0,defaultValue:()=>""}},Kl=l=>{const{condition:e,onReplace:n,onRemove:t}=l,a=P(e,Ui,n),r=()=>i.jsx(Ee,{value:e.getValue(),onValueChange:e.setValue,size:"sm",children:i.jsx(s.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:i.jsx("span",{className:"truncate",children:e.getValue()||"..."})})});return i.jsxs(s.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[i.jsxs(s.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:E[e.field.type].icon}),i.jsx("span",{className:"truncate",children:e.field.label||A})]}),i.jsx(k,{required:!0,value:e.modifier,onValueChange:a,modifierConfig:Ui,children:i.jsx(s.Button,{type:"button",children:Ui[e.modifier].label})}),r(),i.jsx($,{condition:e,onClick:t})]})},Sa={date:{equals:Ae,notEquals:on,before:dn,after:cn,in:un,notIn:hn},boolean:{equals:Le,notEquals:tn},"checkbox-list":{equals:Be,notEquals:ln,every:sn,none:rn,some:an},"multi-select":{equals:De,notEquals:fn,every:pn,none:mn,some:gn},"multi-string":{equals:_e,notEquals:Cn,every:yn,none:Fn,some:vn},number:{equals:$e,notEquals:zn,greaterThan:bn,greaterThanOrEquals:Vn,inRange:Nn,lessThan:wn,lessThanOrEquals:Sn,notInRange:xn},otp:{equals:ke,notEquals:In,excludes:qn,includes:Mn},"pass-fail":{equals:Pe,notEquals:Tn,excludes:En,includes:On},radio:{equals:je,notEquals:Ln,excludes:An,includes:Bn},rating:{equals:Ue,notEquals:Dn,greaterThan:kn,greaterThanOrEquals:Pn,inRange:jn,lessThan:_n,lessThanOrEquals:$n,notInRange:Un},qr:{equals:Ge,notEquals:Gn,excludes:Hn,includes:Jn},select:{equals:Je,notEquals:Wn,excludes:Xn,includes:Kn},string:{equals:He,notEquals:Zn,excludes:Qn,includes:Yn},text:{equals:We,notEquals:Rn,excludes:ni,includes:ei},time:{equals:Ke,notEquals:ii,after:li,before:ti,in:si,notIn:ai},url:{equals:Ze,notEquals:oi,excludes:ci,includes:di},upload:{equals:Xe,notEquals:ri}},Xl=(l,e)=>{if(l.type!==e.type)throw new Error(`field and condition type mismatch ${l.type} !== ${e.type}`);return Sa[e.type][e.modifier].deserialize(e,l)},Gi=(l,e)=>{const n=vt(l,e),t={};for(const a of l)t[a.id]=a;return n.map(a=>Xl(t[a.field],a))},Zl=(l,e)=>Ft(l,e).map(t=>t.serialize()),vt=(l,e)=>{const n=new Set(l.map(t=>t.id));return e.filter(t=>n.has(t.field))},Ft=(l,e)=>{const n=new Set(l.map(t=>t.id));return e.filter(t=>n.has(t.field.id))},zt=l=>{const{condition:e,...n}=l;switch(e.type){case"string":return i.jsx(Gl,{condition:e,...n});case"text":return i.jsx(Jl,{condition:e,...n});case"otp":return i.jsx(_l,{condition:e,...n});case"qr":return i.jsx(jl,{condition:e,...n});case"url":return i.jsx(Kl,{condition:e,...n});case"select":return i.jsx(Ul,{condition:e,...n});case"radio":return i.jsx(kl,{condition:e,...n});case"checkbox-list":return i.jsx(El,{condition:e,...n});case"multi-select":return i.jsx(Bl,{condition:e,...n});case"multi-string":return i.jsx(Al,{condition:e,...n});case"number":return i.jsx(Dl,{condition:e,...n});case"rating":return i.jsx(Pl,{condition:e,...n});case"date":return i.jsx(Ll,{condition:e,...n});case"time":return i.jsx(Hl,{condition:e,...n});case"pass-fail":return i.jsx($l,{condition:e,...n});case"upload":return i.jsx(Wl,{condition:e,...n});case"boolean":return i.jsx(Ol,{condition:e,...n})}},Ji=l=>Oe[l.type].deserialize(l);function ba(l){return l.map(Ji)}function Yl(l){return l.type==="section"?J.deserialize(l):Ji(l)}const Hi=l=>l.map(Yl),wt=l=>Oe[l.type].fromConfig(l),Ql=l=>l.map(e=>wt(e)),Rl=l=>l.type==="section"?J.fromConfig(l):wt(l),es=l=>l.map(Rl),St=l=>Oe[l.type].deserializeConfig(l),ns=l=>l.map(St),is=l=>l.type==="section"?J.deserializeConfig(l):St(l),ts=l=>l.map(is),bt=l=>Oe[l.type].serializeConfig(l),ls=l=>l.map(bt),ss=l=>l.type==="section"?J.serializeConfig(l):bt(l),as=l=>l.map(ss);function Va(l){const e={};for(const n of l)e[n.id]=n;return e}function rs(l,e,n=!0){const t=n?Wi(l,e):e,a={};for(const r of l){if(!(r.id in t))continue;const c=t[r.id];a[r.id]=r.serializeValue(c)}return a}function os(l,e,n=!0){const t=n?Vt(l,e):e,a={};for(const r of l){if(!(r.id in t))continue;const c=t[r.id];a[r.id]=r.deserializeValue(c)}return a}function Wi(l,e){const n={};for(const t of l){if(!(t.id in e))continue;const a=e[t.id];t.isValue(a)&&(n[t.id]=t.cleanValue(a))}return n}function Vt(l,e){const n={};for(const t of l){if(!(t.id in e))continue;const a=e[t.id];t.isSerializedValue(a)&&(n[t.id]=t.cleanSerializedValue(a))}return n}function ds(l,e){const n=Wi(l,e),t={},a={};for(const r of l){if(!(r.id in n))continue;const c=n[r.id];switch(r.type){case"upload":if(!r.isValue(c))break;a[r.id]=c,t[r.id]=[];break;case"pass-fail":if(!r.isValue(c))break;a[r.id]=c.files,t[r.id]={...c,files:[]};break;default:t[r.id]=e[r.id]}}return[t,a]}function cs(l,e,n){const t={};for(const a of l){if(!(a.id in e))continue;const r=e[a.id];switch(a.type){case"upload":if(!a.isValue(r))break;t[a.id]=n[a.id]??[];break;case"pass-fail":if(!a.isValue(r))break;t[a.id]={...r,files:n[a.id]??[]};break;default:if(!a.isValue(r))break;t[a.id]=r}}return t}const us=(l,e)=>{const n={};for(const t of l){const a=e[t.id];n[t.id]=a!==void 0?a:t.blankValue()}return n},hs=(l,e,n)=>{const t={};for(const a of l){const r=e[a.id],c=n[a.id];a.areValuesEqual(r,c)||(t[a.id]=c)}return t},fs=(l,e,n)=>{const t={};for(const a of l){const r=e[a.id],c=n[a.id];a.areValuesEqual(r,c)&&(t[a.id]=c)}return t},Nt=(l,e,n)=>l.every(t=>{const a=e[t.id],r=n[t.id];return t.areValuesEqual(a,r)}),xt=l=>{const e={};for(const n of l)e[n.id]=n.blankValue();return e},ps=(l,e)=>Nt(l,e,xt(l)),Na=Q.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),Ki=Q.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),gs=o.memo(l=>{const{fieldSection:e}=l,{label:n,description:t}=e,a=K.useWatch(),{fieldSchema:r,size:c}=o.use(L),f=o.useMemo(()=>r.getFieldSections(),[r]),h=o.useMemo(()=>f.findIndex(({id:g})=>g===e.id),[f,e.id]),u=o.useMemo(()=>f.filter(g=>e.id in g.conditions),[f,e.id]),p=o.useMemo(()=>u.length===0?!0:u.some(g=>{const C=g.getConditions(e.id);return new Ii(C).applyConditions(a)}),[u,e,a]),m=Ci(e.fields);return p?i.jsxs(i.Fragment,{children:[h!==0?i.jsx(s.Separator,{size:"full"}):null,i.jsxs("div",{className:"flex flex-col gap-4",children:[(n||t)&&i.jsx(i.Fragment,{children:i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx(s.Heading,{size:c,children:n}),t&&i.jsx(s.Text,{accentColor:"base",size:c,children:t})]})}),i.jsx("div",{className:Ki({size:c}),children:m})]})]}):null});gs.displayName="FieldSectionLayout";class J extends ze{type="section";label;description;conditions;fields=[];constructor(e){const{label:n,description:t,fields:a,conditions:r={},...c}=e;super(c),this.label=n,this.description=t,this.fields=this.initFields(a),this.conditions=this.initConditions(r)}serialize(){return{...super.serialize(),label:this.label,description:this.description,fields:this.fields.map(e=>e.serialize()),conditions:Object.fromEntries(Object.entries(this.conditions).map(([e,n])=>[e,n.map(t=>t.serialize())]))}}static deserialize=e=>{const n=e.fields.map(Ji),t={};for(const[a,r]of Object.entries(e.conditions??{}))t[a]=Gi(n,r);return new J({...e,fields:n,conditions:t})};static fromConfig=e=>{const n=Ql(e.fields),t={};for(const[a,r]of Object.entries(e.conditions??{}))t[a]=Gi(n,r);return new J({...e,fields:n,conditions:t})};static deserializeConfig(e){const{label:n,description:t,fields:a,conditions:r,...c}=e;return{...ze._deserializeConfig(c),label:n,description:t,fields:ns(a),conditions:r}}static serializeConfig(e){const{label:n,description:t,fields:a,conditions:r,...c}=e;return{...ze._serializeConfig(c),label:n,description:t,fields:ls(a),conditions:r}}config(){return{...super.config(),label:this.label,description:this.description,fields:this.fields.map(e=>e.config()),conditions:Object.fromEntries(Object.entries(this.conditions).map(([e,n])=>[e,n.map(t=>t.serialize())]))}}getOptions(){return{...super.getOptions(),label:this.label,description:this.description,fields:this.fields,conditions:this.conditions}}duplicate(e){return new J({...this.getOptions(),id:e,fields:this.fields.map(n=>n.duplicate(V.v4()))})}setOptions(e){"label"in e&&(this.label=e.label),"description"in e&&(this.description=e.description),"fields"in e&&e.fields!==void 0&&(this.fields=this.initFields(e.fields)),"conditions"in e&&(this.conditions=this.initConditions(e.conditions??{})),super.setOptions(e)}getErrors(e){const n={};for(const t of this.fields){const a=t.getError(e[t.id]);a&&(n[t.id]=a)}return n}fieldObserver=()=>{this.notify(this)};initFields=e=>{for(const n of e)n.observe(this.fieldObserver);return e};getFields(){return this.fields}addField(e,n){const t=[...this.fields];t.splice(n??this.fields.length,0,e),this.fields=this.initFields(t),this.notify(this)}moveField(e,n){const t=[...this.fields],[a]=t.splice(e,1);t.splice(n,0,a),this.fields=t,this.notify(this)}removeField(e){this.fields=this.initFields(this.fields.filter(({id:t})=>t!==e.id));const n={};for(const[t,a]of Object.entries(this.conditions))n[t]=a.filter(r=>r.field.id!==e.id);this.conditions=n,this.notify(this)}conditionObserver=()=>{this.notify(this)};initConditions=e=>{for(const n of Object.values(e).flat())n.observe(this.conditionObserver);return e};getConditions(e){return this.conditions[e]}addCondition(e,n){this.conditions=this.initConditions({...this.conditions,[e]:[...this.conditions[e]??[],n]}),this.notify(this)}addConditions(e,n){this.conditions=this.initConditions({...this.conditions,[e]:[...this.conditions[e]??[],...n]}),this.notify(this)}replaceCondition(e,n,t){this.conditions=this.initConditions({...this.conditions,[e]:(this.conditions[e]??[]).map(a=>a.id===n.id?t:a)}),this.notify(this)}removeCondition(e,n){this.conditions=this.initConditions({...this.conditions,[e]:(this.conditions[e]??[]).filter(t=>t.id!==n.id)}),this.notify(this)}removeConditions(e,n){const t=new Set(n.map(a=>a.id));this.conditions=this.initConditions({...this.conditions,[e]:(this.conditions[e]??[]).filter(a=>!t.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 n={...this.conditions};delete n[e],this.conditions=this.initConditions(n),this.notify(this)}render(){return i.jsx(gs,{fieldSection:this})}}const ne=o.createContext({}),Xi=o.memo(l=>{const{children:e,variant:n,size:t,accentColor:a,onSelectFieldType:r,...c}=l,f=o.useMemo(()=>{const h={[M.Assessment]:[],[M.Capture]:[],[M.Numeric]:[],[M.Selection]:[],[M.Temporal]:[],[M.Text]:[],[M.Verification]:[]};for(const u of Nl){const{group:p}=E[u];h[p].push(u)}return h},[]);return i.jsxs(s.Menu.Root,{...c,children:[i.jsx(s.Menu.ClickTrigger,{children:e}),i.jsx(s.Menu.Content,{variant:n,size:t,accentColor:a,children:i.jsx(s.Menu.Scroll,{children:Object.entries(f).map(([h,u])=>{const{name:p}=xl[h];return u.length===0?null:i.jsxs(s.Menu.Group,{children:[i.jsx(s.Menu.Label,{children:p}),u.map(m=>i.jsx(ms,{fieldType:m,onSelectFieldType:r},m))]},h)})})})]})});Xi.displayName="CreateFieldDropdownMenu";const ms=o.memo(l=>{const{fieldType:e,onSelectFieldType:n}=l,t=o.useCallback(()=>{n(e)},[e,n]),{icon:a,name:r}=E[e];return i.jsxs(s.Menu.Item,{onSelect:t,children:[i.jsx(s.LuIcon,{icon:a}),i.jsx(s.Text,{className:"truncate",children:r})]})});ms.displayName="CreateFieldDropdownMenuItem";const Zi=l=>{switch(l){case"text":return new ge({label:"",required:!1,id:V.v4()});case"boolean":return new ae({label:"",required:!1,id:V.v4()});case"number":return new U({label:"",required:!1,id:V.v4()});case"date":return new Se({label:"",required:!1,id:V.v4()});case"time":return new Ne({label:"",required:!1,id:V.v4()});case"string":return new pe({label:"",required:!1,id:V.v4()});case"url":return new xe({label:"",required:!1,id:V.v4()});case"select":return new fe({label:"",options:[],required:!1,id:V.v4()});case"multi-string":return new le({label:"",required:!1,id:V.v4()});case"multi-select":return new ee({label:"",options:[],required:!1,id:V.v4()});case"upload":return new ye({label:"",required:!1,id:V.v4()});case"qr":return new Ve({label:"",required:!1,id:V.v4()});case"radio":return new ue({label:"",options:[],required:!1,id:V.v4()});case"checkbox-list":return new R({label:"",options:[],required:!1,id:V.v4()});case"pass-fail":return new ce({label:"",required:!1,id:V.v4(),showNotesAndFilesOn:["fail"]});case"otp":return new re({label:"",required:!1,id:V.v4(),length:6});case"rating":return new he({label:"",required:!1,id:V.v4(),maxRating:5})}},ui=l=>{switch(l.type){case"text":return new We({id:V.v4(),value:"",field:l});case"boolean":return new Le({id:V.v4(),value:!0,field:l});case"number":return new $e({id:V.v4(),value:0,field:l});case"date":return new Ae({id:V.v4(),value:new Date,field:l});case"time":return new Ke({id:V.v4(),value:me(0,0),field:l});case"string":return new He({id:V.v4(),value:"",field:l});case"url":return new Ze({id:V.v4(),value:"",field:l});case"select":return new Je({id:V.v4(),value:"",field:l});case"multi-string":return new _e({id:V.v4(),value:[],field:l});case"multi-select":return new De({id:V.v4(),value:[],field:l});case"upload":return new Xe({id:V.v4(),value:!0,field:l});case"qr":return new Ge({id:V.v4(),value:"",field:l});case"radio":return new je({id:V.v4(),value:"",field:l});case"checkbox-list":return new Be({id:V.v4(),value:[],field:l});case"pass-fail":return new Pe({id:V.v4(),value:"pass",field:l});case"otp":return new ke({id:V.v4(),value:"",field:l});case"rating":return new Ue({id:V.v4(),value:0,field:l})}},Cs=(l,e)=>{switch(l){case"checkbox-list":return R.getFieldCreationSchema(e);case"multi-select":return ee.getFieldCreationSchema(e);case"number":return U.getFieldCreationSchema(e);case"radio":return ue.getFieldCreationSchema(e);case"select":return fe.getFieldCreationSchema(e);case"string":return pe.getFieldCreationSchema(e);case"text":return ge.getFieldCreationSchema(e);case"upload":return ye.getFieldCreationSchema(e);case"pass-fail":return ce.getFieldCreationSchema(e);case"otp":return re.getFieldCreationSchema(e);case"rating":return he.getFieldCreationSchema(e);default:return}},ys=o.memo(l=>{const{popoverInputs:e,...n}=l;return i.jsxs(s.Popover.Root,{children:[i.jsx(s.Popover.Trigger,{asChild:!0,children:i.jsxs(s.Button,{variant:"soft",type:"button",size:"sm",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:ca}),"Settings"]})}),i.jsx(s.Popover.Content,{size:"sm",...n,children:i.jsx("div",{className:Q.cx("flex w-full max-w-[350px] flex-col",Ki({size:"sm"})),children:e})})]})});ys.displayName="FieldSettingsPopover";const vs=o.memo(l=>{const{parentPath:e,fieldIndex:n,field:t}=l,a=mi(),{disableRequiredFields:r}=o.use(ne),[c,f]=o.useState(void 0);Et.useActiveEffect(z=>{f(void 0);const b=t.image;if(b){if(!(b instanceof Promise)){f(b);return}b.then(T=>{z()&&f(T)})}},[t.image]);const h=o.useCallback(()=>{t.setOptions({image:void 0})},[t]),[u,p]=o.useMemo(()=>{const z=[],b=[],T=Cs(t.type,`${e}.${n}`)??[];for(const j of T)j.showDirectly?z.push(j.field):b.push(j.field);return[z,b]},[t,e,n]),m=Ci(u),g=Ci(p),C=p.length>0,F=o.useCallback(()=>{c&&a(()=>({file:c}))},[a,c]),w=o.useCallback(z=>{t.setOptions({required:!!z})},[t]),S=o.useCallback(z=>{t.setOptions({label:z.target.value})},[t]),v=o.useCallback(z=>{t.setOptions({description:z.target.value})},[t]),{icon:I,name:q}=E[t.type];return i.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[i.jsxs("div",{className:"flex w-full justify-between gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs(s.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[i.jsx(s.LuIcon,{icon:I}),q]}),!r&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(s.Checkbox.Root,{checked:t.required,onCheckedChange:w,size:"sm",children:i.jsx(s.Checkbox.Indicator,{children:i.jsx(s.LuIcon,{icon:G})})}),i.jsx(s.Text,{size:"sm",accentColor:"base",children:"Required"})]})]}),C&&i.jsx(ys,{popoverInputs:g,align:"end"})]}),c&&i.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[i.jsx(qe,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:c,onClick:F}),i.jsx(s.IconButton,{type:"button",className:"group-hover:not-disabled:flex absolute right-2 top-2 hidden",variant:"solid",accentColor:"base","aria-label":"delete",onClick:h,size:"sm",children:i.jsx(s.LuIcon,{icon:Fe})})]}),i.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[i.jsx(s.Input.Root,{variant:"outline",size:"md",children:i.jsx(s.Input.Field,{placeholder:"Enter your question",value:t.label??"",onChange:S,maxLength:200})}),i.jsx(s.TextArea,{className:"field-sizing-content",placeholder:"Enter a field description (optional)",value:t.description??"",onChange:v,maxLength:1e3,resize:"vertical",size:"md"})]}),u.length>0&&i.jsx("div",{className:Q.cx("w-full",Ki({size:"sm"})),children:m})]})});vs.displayName="FieldBuilder";const It=o.memo(l=>{const{field:e,fieldSection:n,fieldIndex:t,sectionIndex:a}=l,r=o.useRef(null),c=`fields.${a}.fields`,f=o.useCallback(w=>{n.addField(Zi(w),t+1)},[t,n]),h=o.useCallback(()=>{n.addField(e.duplicate(V.v4()))},[e,n]),u=o.useCallback(w=>{const S=w==="up"?a-1:a+1;n.moveField(t,S)},[n,t,a]),p=o.useCallback(w=>{const{files:S}=w.target;if(!S||S.length!==1)return;const v=S.item(0);v&&e.setOptions({image:v})},[e]),m=o.useCallback(()=>{u("up")},[u]),g=o.useCallback(()=>{u("down")},[u]),C=o.useCallback(()=>{r.current?.click()},[]),F=o.useCallback(()=>{n.removeField(e)},[e,n]);return i.jsxs(s.Card,{className:"flex w-full items-center justify-between gap-4",size:"sm",children:[i.jsx(vs,{fieldIndex:t,field:e,parentPath:c}),i.jsxs(s.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[i.jsx(Xi,{onSelectFieldType:f,size:"sm",children:i.jsx(s.IconButton,{type:"button",children:i.jsx(s.LuIcon,{icon:X})})}),i.jsx(s.IconButton,{type:"button",onClick:m,children:i.jsx(s.LuIcon,{icon:Wt})}),i.jsx(s.IconButton,{type:"button",onClick:g,children:i.jsx(s.LuIcon,{icon:Ht})}),i.jsx(s.IconButton,{type:"button",onClick:h,children:i.jsx(s.LuIcon,{icon:Ri})}),i.jsx(s.IconButton,{type:"button",onClick:C,children:i.jsx(s.LuIcon,{icon:Gt})}),i.jsx(s.IconButton,{type:"button",onClick:F,children:i.jsx(s.LuIcon,{icon:Fe})})]}),i.jsx("input",{className:"hidden",ref:r,type:"file",accept:"image/*",onChange:p})]})});It.displayName="FieldBuilderWithActions";const Mt=o.memo(l=>{const{children:e,variant:n,size:t,accentColor:a,fields:r,onSelectField:c,onSelectAllFields:f,...h}=l,u=o.useCallback(()=>{f?.(r)},[f,r]);return i.jsxs(s.Menu.Root,{...h,children:[i.jsx(s.Menu.ClickTrigger,{children:e}),i.jsx(s.Menu.Content,{variant:n,size:t,accentColor:a,children:i.jsxs(s.Menu.Scroll,{children:[f?i.jsx(s.Menu.Item,{onSelect:u,children:"Select all"}):null,r.map(p=>i.jsx(Fs,{field:p,onSelectField:c},p.id))]})})]})});Mt.displayName="FieldDropdownMenu";const Fs=o.memo(l=>{const{field:e,onSelectField:n}=l,t=o.useCallback(()=>{n(e)},[e,n]);return i.jsxs(s.Menu.Item,{onSelect:t,children:[i.jsx(s.LuIcon,{icon:E[e.type].icon}),e.label||A]})});Fs.displayName="FieldDropdownMenuItem";const zs=o.memo(l=>{const{children:e,variant:n,size:t,accentColor:a,fieldSections:r,onSelectFieldSection:c,...f}=l;return i.jsxs(s.Menu.Root,{...f,children:[i.jsx(s.Menu.ClickTrigger,{children:e}),i.jsx(s.Menu.Content,{variant:n,size:t,accentColor:a,children:r.map(h=>i.jsx(ws,{fieldSection:h,onSelectFieldSection:c},h.id))})]})});zs.displayName="FieldSectionDropdownMenu";const ws=o.memo(l=>{const{fieldSection:e,onSelectFieldSection:n}=l,t=o.useCallback(()=>{n(e)},[e,n]);return i.jsxs(s.Menu.Item,{onSelect:t,children:[i.jsx(s.LuIcon,{icon:Jt}),e.label||bi]})});ws.displayName="FieldSectionDropdownMenuItem";const Ss=o.memo(l=>{const{id:e,sourceX:n,sourceY:t,targetX:a,targetY:r,style:c,markerEnd:f,data:h}=l,{targetSection:u,sourceSection:p,layoutDirection:m}=h,g=o.useMemo(()=>p.getConditions(u.id),[p,u.id]),C=o.useCallback(()=>{p.removeConditional(u.id)},[p,u.id]),F=o.useCallback(b=>{p.addCondition(u.id,ui(b))},[p,u.id]),w=o.useCallback(b=>{p.addConditions(u.id,b.map(ui))},[p,u.id]),S=o.useCallback((b,T)=>{p.replaceCondition(u.id,b,T)},[p,u.id]),v=o.useCallback(b=>{p.removeCondition(u.id,b)},[p,u.id]),[I,q,z]=O.getBezierPath({sourceX:n,sourceY:t,sourcePosition:m==="LR"?O.Position.Right:O.Position.Bottom,targetX:a,targetY:r,targetPosition:m==="LR"?O.Position.Left:O.Position.Top});return i.jsxs(i.Fragment,{children:[i.jsx(O.BaseEdge,{id:e,path:I,style:c,markerEnd:f,labelX:q,labelY:z}),i.jsx(O.EdgeLabelRenderer,{children:i.jsxs(s.Card,{size:"xs",variant:"surface",className:"nodrag nopan bg-(--base-2)! pointer-events-auto absolute inline-flex flex-col gap-2",onMouseDown:s.stopPropagation,onClick:s.stopPropagation,"data-floating-content":"",style:{transform:`translate(-50%, -50%) translate(${q}px, ${z}px)`},children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(s.Text,{size:"xs",className:"max-w-[280px] truncate",children:p.label||bi}),i.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[i.jsx(Mt,{size:"sm",fields:p.fields,onSelectField:F,onSelectAllFields:w,children:i.jsx(s.IconButton,{"aria-label":"Add condition",type:"button",variant:"surface",size:"xs",accentColor:"base",children:i.jsx(s.LuIcon,{icon:X})})}),i.jsxs(s.Tooltip.Root,{children:[i.jsx(s.Tooltip.Trigger,{asChild:!0,children:i.jsx(s.IconButton,{"aria-label":"Remove conditional logic",type:"button",variant:"surface",size:"xs",accentColor:"base",color:"danger",onClick:C,children:i.jsx(s.LuIcon,{icon:Fe})})}),i.jsx(s.Tooltip.Content,{size:"sm",children:"Remove conditional logic"})]})]})]}),g.length>0&&i.jsx("div",{className:"flex h-max w-full flex-col flex-wrap gap-1",children:g.map(b=>i.jsx(zt,{condition:b,onRemove:v,onReplace:S},b.id))})]})})]})});Ss.displayName="FieldSectionConditionEdgeComponent";const bs=o.memo(l=>{const{data:e,selected:n}=l,{fieldSection:t,index:a,layoutDirection:r}=e,{fieldSchema:c}=o.use(ne),f=o.useCallback(()=>{c.removeFieldSection(t)},[c,t]),h=o.useCallback(C=>{t.addField(Zi(C))},[t]),u=o.useCallback(()=>{const C=new J({id:V.v4(),fields:[]});c.addFieldSection(C),t.addConditional(C.id)},[c,t]),p=o.useCallback(()=>{c.addFieldSection(t.duplicate(V.v4()))},[c,t]),m=o.useCallback(C=>{t.setOptions({label:C.target.value})},[t]),g=o.useCallback(C=>{t.setOptions({description:C.target.value})},[t]);return i.jsxs(s.Card,{variant:"surface",className:"bg-(--base-2) relative cursor-pointer",size:"sm","data-selected":n?"true":void 0,children:[i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[i.jsx(s.Input.Root,{variant:"outline",size:"md",accentColor:"base",children:i.jsx(s.Input.Field,{placeholder:"Enter a section label (optional)",value:t.label??"",onChange:m,maxLength:200})}),i.jsx(s.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:t.description??"",onChange:g,maxLength:1e3,resize:"vertical",size:"md"})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(s.Text,{weight:"bold",children:"Fields"}),i.jsx(Xi,{onSelectFieldType:h,size:"sm",children:i.jsxs(s.Button,{type:"button",variant:"soft",size:"sm",accentColor:"base",children:[i.jsx(s.LuIcon,{icon:X})," Add field"]})})]}),i.jsx("div",{className:"flex flex-col gap-3",children:t.fields.map((C,F)=>i.jsx(It,{field:C,fieldSection:t,fieldIndex:F,sectionIndex:a},C.id))})]}),i.jsx(O.NodeToolbar,{isVisible:!0,position:O.Position.Right,align:"start",offset:8,onMouseDown:s.stopPropagation,children:i.jsx(s.Card,{variant:"surface",className:"bg-(--base-2) flex flex-col items-center gap-1 p-1",size:"xs",onClick:s.stopPropagation,children:i.jsxs(s.ButtonGroup,{className:"flex flex-col gap-2",variant:"surface",size:"xs",accentColor:"base",children:[i.jsx(s.IconButton,{type:"button",onClick:u,children:i.jsx(s.LuIcon,{icon:na})}),i.jsx(s.IconButton,{type:"button",onClick:p,children:i.jsx(s.LuIcon,{icon:Ri})}),i.jsx(s.IconButton,{type:"button",onClick:f,children:i.jsx(s.LuIcon,{icon:Fe})})]})})}),i.jsx(O.Handle,{type:"target",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:r==="LR"?O.Position.Left:O.Position.Top}),i.jsx(O.Handle,{type:"source",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:r==="LR"?O.Position.Right:O.Position.Bottom})]})});bs.displayName="CustomNode";const xa={fieldSection:bs},Ia={fieldSectionCondition:Ss},Ma=(l,e,n)=>{const t=new Lt.graphlib.Graph().setDefaultEdgeLabel(()=>({}));return t.setGraph({rankdir:n,nodesep:200,edgesep:500,ranksep:500}),e.forEach(a=>t.setEdge(a.source,a.target,{width:500,height:200,labelpos:"c"})),l.forEach(a=>t.setNode(a.id,{...a,width:a.measured?.width??0,height:a.measured?.height??0})),Lt.layout(t),[l.map(a=>{const r=t.node(a.id),c=r.x-(a.measured?.width??0)/2,f=r.y-(a.measured?.height??0)/2;return{...a,position:{x:c,y:f}}}),e]},qa={hideAttribution:!0},Vs=o.memo(()=>{const{errors:l}=K.useFormState(),{handleSubmit:e}=K.useFormContext(),{onSave:n,onCancel:t}=o.use(ne),{fieldSchema:a}=o.use(ne),r=o.useRef(null),[c,f]=o.useState(),[h,u]=o.useState("TB");o.useLayoutEffect(()=>{r.current&&r.current.classList.remove("light")},[]);const p=o.useMemo(()=>a.fieldSections.map((D,H)=>({id:D.id,position:{x:0,y:0},data:{index:H,fieldSection:D,layoutDirection:h},draggable:!0,type:"fieldSection"})),[a.fieldSections,h]),m=o.useMemo(()=>{const D=[],H={};for(const W of a.fieldSections)H[W.id]=W;for(const W of a.fieldSections){const hi=W.conditions;for(const[fi,Aa]of Object.entries(hi))D.push({id:`${W.id}-${fi}`,source:W.id,target:fi,data:{targetSection:H[fi],sourceSection:W,layoutDirection:h},animated:Aa.length>0,markerEnd:O.MarkerType.Arrow,style:{strokeWidth:2,stroke:"var(--base-a8)"},type:"fieldSectionCondition"})}return D},[a.fieldSections,h]),[g,C,F]=O.useNodesState(p),[w,S,v]=O.useEdgesState(m);o.useEffect(()=>{C(p)},[p,C]),o.useEffect(()=>{S(m)},[m,S]);const[I,q]=o.useMemo(()=>Ma(g,w,h),[w,h,g]),z=o.useCallback(()=>{a.addFieldSection(new J({id:V.v4(),fields:[]}))},[a]),b=o.useCallback(D=>{const{source:H,target:W}=D,hi=a.fieldSections.find(({id:fi})=>fi===H);hi.setOptions({conditions:{...hi.conditions,[W]:[]}})},[a.fieldSections]),T=o.useCallback(D=>{const H=a.getSectionDependencyGraph();return!Tt.willCreateCycle(H,D.source,D.target)},[a]),j=o.useCallback(()=>{c?.zoomOut()},[c]),ie=o.useCallback(()=>{c?.zoomIn()},[c]),Ye=o.useCallback(()=>{c?.fitView()},[c]);return i.jsxs("form",{className:"flex size-full flex-col gap-4",onSubmit:e(n),children:[i.jsxs(s.Card,{className:"relative size-full",variant:"outline",children:[i.jsx(O.ReactFlow,{ref:r,onInit:f,nodes:I,onNodesChange:F,edges:q,onEdgesChange:v,nodeTypes:xa,edgeTypes:Ia,onConnect:b,attributionPosition:"bottom-left",fitView:!0,minZoom:0,isValidConnection:T,proOptions:qa}),i.jsx(O.Panel,{position:"top-left",children:i.jsx(s.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:i.jsxs(s.Button,{type:"button",variant:"surface",onClick:z,children:[i.jsx(s.LuIcon,{icon:X})," Add section"]})})}),i.jsxs(O.Panel,{position:"top-right",className:"flex flex-col items-center gap-2",children:[i.jsxs(s.ToggleGroup.Root,{className:"flex flex-col",type:"single",accentColor:"base",size:"sm",value:h,onValueChange:u,children:[i.jsx(s.ToggleGroup.IconItem,{className:"rounded-b-none",value:"LR",type:"button",children:i.jsx(s.LuIcon,{icon:Js})}),i.jsx(s.ToggleGroup.IconItem,{className:"rounded-t-none",value:"TB",type:"button",children:i.jsx(s.LuIcon,{icon:Gs})})]}),i.jsx(s.Separator,{size:"sm"}),i.jsxs(s.ButtonGroup,{className:"flex flex-col",size:"sm",accentColor:"base",variant:"soft",children:[i.jsx(s.IconButton,{className:"rounded-b-none",onClick:ie,type:"button",children:i.jsx(s.LuIcon,{icon:X})}),i.jsx(s.IconButton,{onClick:j,radius:"none",type:"button",children:i.jsx(s.LuIcon,{icon:gi})}),i.jsx(s.IconButton,{className:"rounded-t-none",onClick:Ye,type:"button",children:i.jsx(s.LuIcon,{icon:ha})})]})]}),i.jsx(O.Panel,{position:"bottom-right",children:i.jsxs(s.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[t&&i.jsx(s.Button,{type:"button",variant:"soft",accentColor:"base",onClick:t,children:"Cancel"}),i.jsx(s.Button,{type:"submit",variant:"surface",children:"Save"})]})})]}),!!l.fields?.message&&i.jsx(s.Text,{size:"xs",accentColor:"danger",children:l.fields.message})]})});Vs.displayName="FormBuilderFlowBuilder";const Ta=(l,e,n={})=>{const{conditions:t=!1}=n,a=l.get(e.id);if(!a)throw new Error(`Attempting to reseed serialized section with id ${e.id} which is not present in the reseeded id map`);const r=new Map,c=e.fields.map(h=>{const u=V.v4();return r.set(h.id,u),{...h,id:u}}),f={};if(t)for(const[h,u]of Object.entries(e.conditions??{})){const p=l.get(h);if(!p)continue;const m=u.map(g=>{const C=r.get(g.field);if(!C)throw new Error(`Serialized condition referencing undefined field with id: ${g.field}`);return{...g,field:C}});f[p]=m}return{...e,id:a,conditions:f,fields:c}},Oa=(l,e={})=>{const n=new Map(l.map(t=>[t.id,V.v4()]));return l.map(t=>Ta(n,t,e))},qt=(l,e)=>{const n={},t=l.filter(a=>a instanceof J);for(const a of l)if(a instanceof J){const r=t.filter(f=>a.id in f.conditions);if(r.length>0&&!r.some(f=>{const h=f.getConditions(a.id);return new Ii(h).applyConditions(e)}))continue;const c=a.getErrors(e);Object.assign(n,c)}else{if(!(a instanceof x))throw new Error("Invalid field type");const r=a.id,c=a.getError(At(e,r));c&&Ds(n,r,c)}return n},Ea=async l=>{const e={};for(const n of l){const{fields:t}=n;for(const a of t)if(a.image)if(a.image instanceof Promise)try{e[a.id]=await a.image}catch(r){console.error("Failed to get image from promise",r)}else e[a.id]=a.image}return e};async function La(l){const e={};for(const[n,t]of Object.entries(l))e[n]=await Promise.all(t);return e}class ve extends Re{fieldSections;constructor(e){super(),this.fieldSections=this.initFields(e)}serialize(){return this.fieldSections.map(e=>e.serialize())}config(){return this.fieldSections.map(e=>e.config())}static deserialize(e){return new ve(Hi(e))}static fromConfig(e){return new ve(es(e))}static serializeConfig(e){return as(e)}static deserializeConfig(e){return ts(e)}static reseedFieldSections(e,n){return Oa(e,n)}fieldObserver=()=>{this.notify(this)};initFields=e=>{for(const n of e)n.observe(this.fieldObserver);return e};getFields(){return this.fieldSections.flatMap(e=>e.getFields())}getFieldSections(){return this.fieldSections}addFieldSection(e,n){const t=[...this.fieldSections];t.splice(n??this.fieldSections.length,0,e),this.fieldSections=this.initFields(t),this.notify(this)}removeFieldSection(e){const n=this.fieldSections.filter(t=>t.id!==e.id);for(const t of n)t.removeConditional(e.id);this.fieldSections=this.initFields(n),this.notify(this)}moveFieldSection(e,n){const t=[...this.fieldSections],[a]=t.splice(e,1);t.splice(n,0,a),this.fieldSections=this.initFields(t),this.notify(this)}getSectionDependencyGraph(){const e=new Bs.DirectedGraph({type:"directed"});for(const n of this.fieldSections)for(const t of Object.keys(n.conditions))e.mergeEdge(n.id,t);return e}getDependenciesOfSection(e){const n=this.getSectionDependencyGraph(),t=new Map(this.fieldSections.map(r=>[r.id,r])),a=[];return As.bfsFromNode(n,e,(r,c,f)=>{a.push(t.get(r))},{mode:"in"}),a}cleanValues(e){return Wi(this.getFields(),e)}cleanSerializedValues(e){return Vt(this.getFields(),e)}deserializeValues(e,n){return os(this.getFields(),e,n)}serializeValues(e,n){return rs(this.getFields(),e,n)}initializeValues(e){return us(this.getFields(),e)}validateValues(e){return qt(this.getFieldSections(),e)}areValuesValid(e){return Object.keys(this.validateValues(e)).length===0}deserializeConditions(e){return Gi(this.getFields(),e)}cleanConditions(e){return Ft(this.getFields(),e)}serializeConditions(e){return Zl(this.getFields(),e)}cleanSerializedConditions(e){return vt(this.getFields(),e)}changedFieldValues(e,n){return hs(this.getFields(),e,n)}unchangedFieldValues(e,n){return fs(this.getFields(),e,n)}areValuesEqual(e,n){return Nt(this.getFields(),e,n)}areValuesBlank(e){return ps(this.getFields(),e)}blankValues(){return xt(this.getFields())}extractFilesAndPromisesFromFieldValues(e){return ds(this.getFields(),e)}insertFilesAndPromisesToFieldValues(e,n){return cs(this.getFields(),e,n)}}const Ns=o.memo(l=>{const{sourceFieldSection:e,targetFieldSection:n}=l,t=o.useMemo(()=>e.getConditions(n.id),[e,n.id]),a=o.useCallback(()=>{e.removeConditional(n.id)},[e,n.id]),r=o.useCallback(u=>{e.addCondition(n.id,ui(u))},[e,n.id]),c=o.useCallback(u=>{e.addConditions(n.id,u.map(ui))},[e,n.id]),f=o.useCallback((u,p)=>{e.replaceCondition(n.id,u,p)},[e,n.id]),h=o.useCallback(u=>{e.removeCondition(n.id,u)},[e,n.id]);return i.jsxs(s.Card,{className:"flex flex-col gap-2",size:"sm",children:[i.jsxs(s.ButtonGroup,{className:"flex justify-between gap-2",size:"sm",accentColor:"base",variant:"soft",children:[i.jsxs(s.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[i.jsx(s.LuIcon,{icon:Jt}),e.label??bi]}),i.jsx(s.IconButton,{type:"button",onClick:a,variant:"ghost",children:i.jsx(s.LuIcon,{icon:Fe})})]}),i.jsxs("div",{className:"flex h-max w-full flex-wrap gap-2",children:[t.map(u=>i.jsx(zt,{condition:u,onRemove:h,onReplace:f},u.id)),i.jsx(Mt,{fields:e.fields,onSelectField:r,onSelectAllFields:c,align:"start",size:"sm",children:i.jsx(s.IconButton,{type:"button",size:"sm",variant:"soft",accentColor:"base",children:i.jsx(s.LuIcon,{icon:X})})})]})]})});Ns.displayName="FieldSectionConditionalItem";const xs=o.memo(l=>{const{fieldSection:e}=l,{fieldSchema:n}=o.use(ne),t=o.useMemo(()=>n.fieldSections.filter(h=>e.id in h.conditions),[n.fieldSections,e.id]),a=o.useCallback(h=>{h.addConditional(e.id)},[e.id]),r=o.useCallback(h=>{e.setOptions({label:h.target.value})},[e]),c=o.useCallback(h=>{e.setOptions({description:h.target.value})},[e]),f=o.useMemo(()=>{const h=n.getSectionDependencyGraph();return n.fieldSections.filter(u=>!Tt.willCreateCycle(h,u.id,e.id))},[e.id,n]);return i.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[i.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[i.jsx(s.Input.Root,{variant:"outline",size:"md",children:i.jsx(s.Input.Field,{placeholder:"Enter a section label (optional)",value:e.label??"",onChange:r,maxLength:200})}),i.jsx(s.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:e.description??"",onChange:c,maxLength:1e3,resize:"vertical",size:"md"})]}),i.jsx(s.Separator,{size:"full"}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsxs("div",{className:"flex justify-between gap-2",children:[i.jsx(s.Text,{accentColor:"base",children:"Conditions"}),i.jsx(zs,{fieldSections:f,onSelectFieldSection:a,size:"sm",children:i.jsxs(s.Button,{type:"button",variant:"soft",size:"sm",className:"w-max",children:[i.jsx(s.LuIcon,{icon:X}),"Add condition"]})})]}),t.map(h=>i.jsx(Ns,{sourceFieldSection:h,targetFieldSection:e},h.id))]}),i.jsx(s.Separator,{size:"full"})]})});xs.displayName="FieldSectionBuilder";const Is=o.memo(l=>{const{fieldSection:e,sectionIndex:n}=l,{fieldSchema:t}=o.use(ne),a=s.useAlertDialog(),r=o.useCallback(()=>{t.removeFieldSection(e)},[t,e]),c=o.useCallback(w=>{const S=w==="up"?n-1:n+1;t.moveFieldSection(n,S)},[t,n]),f=o.useCallback(()=>{t.addFieldSection(e.duplicate(V.v4()))},[t,e]),h=o.useCallback(w=>{e.addField(Zi(w))},[e]),u=o.useCallback(()=>{c("up")},[c]),p=o.useCallback(()=>{c("down")},[c]),m=o.useCallback(async()=>{const w=[e.serialize()],S=ve.reseedFieldSections(w,{conditions:!1}),v=JSON.stringify(S);await navigator.clipboard.writeText(v),s.toast.success({title:"Section copied"})},[e]),g=o.useCallback(async()=>{const S=t.getDependenciesOfSection(e.id).map(q=>q.serialize()),v=ve.reseedFieldSections(S,{conditions:!0}),I=JSON.stringify(v);await navigator.clipboard.writeText(I),s.toast.success({title:"Section copied"})},[e,t]),C=o.useCallback(async()=>{const w=t.getDependenciesOfSection(e.id),S=w.length>1,v=w.length-1;S?a({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()},[e,t,a,g,m]),F=o.useCallback(async()=>{let w="";try{w=await navigator.clipboard.readText()}catch{s.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const S=w.trim();if(!S){s.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}try{const v=JSON.parse(S),I=Bt.JSONFieldSectionSchema.array().parse(v),q=Hi(I);if(q.length===0){s.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}for(const[z,b]of q.entries())t.addFieldSection(b,n+1+z);s.toast.success({title:"Sections pasted",description:"Serialized JSON imported successfully."})}catch(v){console.error(v),s.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."})}},[t,n]);return i.jsxs(s.Card,{variant:"outline",className:"flex w-full items-center justify-between gap-4",size:"sm",children:[i.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[i.jsx(xs,{fieldSection:e}),i.jsxs("div",{className:"flex w-full flex-col gap-2",children:[i.jsxs("div",{className:"flex justify-between gap-2",children:[i.jsx(s.Text,{accentColor:"base",size:"md",children:"Fields"}),i.jsx(Xi,{onSelectFieldType:h,size:"sm",children:i.jsxs(s.Button,{type:"button",variant:"soft",size:"sm",children:[i.jsx(s.LuIcon,{icon:X})," Add field"]})})]}),e.fields.map((w,S)=>i.jsx(It,{field:w,fieldSection:e,fieldIndex:S,sectionIndex:n},w.id))]})]}),i.jsxs(s.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[i.jsx(s.IconButton,{type:"button",onClick:u,children:i.jsx(s.LuIcon,{icon:Wt})}),i.jsx(s.IconButton,{type:"button",onClick:p,children:i.jsx(s.LuIcon,{icon:Ht})}),i.jsxs(s.Menu.Root,{align:"end",children:[i.jsx(s.Menu.ClickTrigger,{children:i.jsx(s.IconButton,{type:"button",children:i.jsx(s.LuIcon,{icon:Ut})})}),i.jsxs(s.Menu.Content,{size:"sm",children:[i.jsxs(s.Menu.Item,{onSelect:f,children:[i.jsx(s.LuIcon,{icon:Ri}),"Duplicate section"]}),i.jsxs(s.Menu.Item,{onSelect:C,children:[i.jsx(s.LuIcon,{icon:kt}),"Copy JSON"]}),i.jsxs(s.Menu.Item,{onSelect:F,children:[i.jsx(s.LuIcon,{icon:Pt}),"Paste JSON"]}),i.jsxs(s.Menu.Item,{onSelect:r,children:[i.jsx(s.LuIcon,{icon:Fe}),"Delete section"]})]})]})]})]})});Is.displayName="FieldSectionWithActions";const Ms=o.memo(()=>{const{handleSubmit:l}=K.useFormContext(),{errors:e}=K.useFormState(),{onSave:n,onCancel:t}=o.use(ne),{fieldSchema:a}=o.use(ne),r=o.useCallback(()=>{a.addFieldSection(new J({id:V.v4(),fields:[]}))},[a]),c=o.useCallback(async()=>{try{const h=a.serialize(),u=ve.reseedFieldSections(h,{conditions:!0}),p=JSON.stringify(u);await navigator.clipboard.writeText(p),s.toast.success({title:"Sections copied",description:"All sections JSON copied to clipboard."})}catch{s.toast.error({title:"Copy failed",description:"Unable to copy the sections JSON."})}},[a]),f=o.useCallback(async()=>{let h="";try{h=await navigator.clipboard.readText()}catch{s.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const u=h.trim();if(!u){s.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}try{const p=JSON.parse(u),m=Bt.JSONFieldSectionSchema.array().parse(p),g=Hi(m);if(g.length===0){s.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}for(const[C,F]of g.entries())a.addFieldSection(F,a.fieldSections.length+C);s.toast.success({title:"Sections pasted",description:"Serialized JSON imported successfully."})}catch(p){console.error(p),s.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."})}},[a]);return i.jsxs("form",{className:"flex flex-col gap-4",onSubmit:l(n),children:[i.jsxs("div",{className:"flex flex-col gap-4",children:[i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsxs(s.Button,{type:"button",variant:"soft",size:"sm",onClick:c,children:[i.jsx(s.LuIcon,{icon:kt})," Copy JSON"]}),i.jsxs(s.Button,{type:"button",variant:"soft",size:"sm",onClick:f,children:[i.jsx(s.LuIcon,{icon:Pt})," Paste JSON"]})]}),a.fieldSections.map((h,u)=>i.jsx(Is,{fieldSection:h,sectionIndex:u},h.id)),i.jsxs(s.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:r,children:[i.jsx(s.LuIcon,{icon:X})," Add section"]})]}),!!e.fields?.message&&i.jsx(s.Text,{size:"xs",accentColor:"danger",children:e.fields.message}),i.jsxs(s.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[t&&i.jsx(s.Button,{type:"button",variant:"soft",accentColor:"base",onClick:t,children:"Cancel"}),i.jsx(s.Button,{type:"submit",variant:"surface",children:"Save"})]})]})});Ms.displayName="FormBuilderListBuilder";function qs(l){const e=n=>{const t={};for(const[a,r]of Object.entries(n))typeof r=="string"?t[a]={type:"validate",message:r}:t[a]=e(r);return t};return e(l)}const Ts=o.memo(o.forwardRef((l,e)=>{const{disabled:n=!1,fieldSchema:t,values:a={},onValuesChange:r,onSubmit:c,submitText:f="Submit",hideSubmit:h=!1,cancelText:u,onCancel:p,hideCancel:m=!1,className:g,submitButtonProps:C,cancelButtonProps:F,cancelIcon:w,submitIcon:S,size:v="md"}=l,I=o.useMemo(()=>t.initializeValues(a),[t,a]),q=o.useCallback(D=>{c?.(D)},[c]),z=K.useForm({values:I,mode:"onBlur",criteriaMode:"all",disabled:n,resolver:D=>{const H=t.validateValues(D),W=qs(H);return Object.keys(H).length>0?{values:{},errors:W}:{values:D,errors:{}}}}),b=o.useCallback(D=>{r?.(D)},[r]);o.useEffect(()=>{const{unsubscribe:D}=z.watch((H,{type:W})=>{W==="change"&&b(H)});return()=>{D()}},[z,b]);const T=Yt(t.getFieldSections()),j=o.useMemo(()=>({fieldSchema:t,size:v}),[t,v]),ie=!m&&!!p,Ye=!h;return i.jsx(K.FormProvider,{...z,children:i.jsx(L,{value:j,children:i.jsxs("form",{ref:e,className:Q.cx(g,"flex flex-col gap-4"),onSubmit:z.handleSubmit(q),children:[i.jsx("div",{className:Na({size:v}),children:T}),!n&&(ie||Ye)?i.jsxs(s.ButtonGroup,{className:"flex items-center justify-end gap-2",size:v,children:[ie?i.jsxs(s.Button,{accentColor:"base",type:"button",variant:"soft",onClick:p,...F,children:[i.jsx(s.LuIcon,{icon:w??te}),u]}):null,Ye?i.jsxs(s.Button,{type:"submit",accentColor:"primary",variant:"surface",...C,children:[i.jsx(s.LuIcon,{icon:S??G}),f]}):null]}):null]})})})})),Os=o.memo(()=>{const{fieldSchema:l}=o.use(ne);return i.jsx(Ts,{fieldSchema:l,disabled:!1})});Os.displayName="FormBuilderPreview";const Es=o.memo(l=>{const{children:e,initialFields:n,onSave:t,onCancel:a,disableRequiredFields:r=!1}=l,c=o.useCallback(F=>{const w={};(!F.fields||F.fields.length===0)&&(w.fields="At least one field is required.");const S=[];for(const[q,z]of F.fields.entries())for(const[b,T]of z.fields.entries()){const j=Cs(T.type,`fields.${q}.fields.${b}`)?.map(({field:ie})=>ie)??[];S.push(...j)}const v={};for(const q of S)v[q.id]=At(F,q.id);const I=qt(S,v);return Object.keys(I).length>0&&(w.fields=I.fields),Object.keys(w).length>0&&s.toast.error({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),w},[]),f=o.useMemo(()=>({fields:n??[]}),[n]),h=K.useForm({values:f,mode:"onSubmit",criteriaMode:"all",reValidateMode:"onSubmit",resolver:F=>{const w=c(F),S=qs(w);return Object.keys(w).length>0?{values:{},errors:S}:{values:F,errors:{}}}}),u=o.useCallback(F=>{h.setValue("fields",F.config())},[h]),p=K.useWatch({control:h.control,compute:F=>F.fields}),m=o.useMemo(()=>{const F=ve.fromConfig(p);return F.observe(u),F},[p,u]),g=o.useMemo(()=>({fieldSchema:m,disableRequiredFields:r,onSave:t,onCancel:a}),[r,t,a,m]),C=o.useMemo(()=>({fieldSchema:m,size:"sm"}),[m]);return i.jsx(ne,{value:g,children:i.jsx(L,{value:C,children:i.jsx(K.FormProvider,{...h,children:e})})})});Es.displayName="FormBuilderRoot";const Ba={Root:Es,FlowBuilder:Vs,ListBuilder:Ms,Preview:Os};d.BaseCondition=Il,d.BaseField=x,d.BaseFieldCondition=y,d.BaseFormElement=ze,d.BaseOptionsField=Z,d.BaseStringField=we,d.BooleanField=ae,d.BooleanFieldConditionCell=Ol,d.BooleanFieldEqualsCondition=Le,d.BooleanFieldInput=st,d.BooleanFieldNotEqualsCondition=tn,d.CheckboxListField=R,d.CheckboxListFieldConditionCell=El,d.CheckboxListFieldEqualsCondition=Be,d.CheckboxListFieldEveryCondition=sn,d.CheckboxListFieldNoneCondition=rn,d.CheckboxListFieldNotEqualsCondition=ln,d.CheckboxListFieldSomeCondition=an,d.ConditionManager=Ii,d.DateField=Se,d.DateFieldAfterCondition=cn,d.DateFieldBeforeCondition=dn,d.DateFieldConditionCell=Ll,d.DateFieldEqualsCondition=Ae,d.DateFieldInCondition=un,d.DateFieldInput=at,d.DateFieldNotEqualsCondition=on,d.DateFieldNotInCondition=hn,d.FIELD_TYPES=Nl,d.FieldConditionCell=zt,d.FieldSchema=ve,d.FieldSection=J,d.FieldTypeGroup=M,d.FieldTypeToClsMapping=Oe,d.FieldsRenderer=Ts,d.FileCard=nt,d.FormBuilder=Ba,d.ImageCard=rt,d.ImageFile=qe,d.ImageViewer=tt,d.ImageViewerProvider=Zt,d.InputWithLabel=B,d.MultiSelectField=ee,d.MultiSelectFieldConditionCell=Bl,d.MultiSelectFieldEqualsCondition=De,d.MultiSelectFieldEveryCondition=pn,d.MultiSelectFieldNoneCondition=mn,d.MultiSelectFieldNotEqualsCondition=fn,d.MultiSelectFieldSomeCondition=gn,d.MultiStringField=le,d.MultiStringFieldConditionCell=Al,d.MultiStringFieldEqualsCondition=_e,d.MultiStringFieldEveryCondition=yn,d.MultiStringFieldNoneCondition=Fn,d.MultiStringFieldNotEqualsCondition=Cn,d.MultiStringFieldSomeCondition=vn,d.NumberField=U,d.NumberFieldConditionCell=Dl,d.NumberFieldEqualsCondition=$e,d.NumberFieldGreaterThanCondition=bn,d.NumberFieldGreaterThanOrEqualsCondition=Vn,d.NumberFieldInRangeCondition=Nn,d.NumberFieldLessThanCondition=wn,d.NumberFieldLessThanOrEqualsCondition=Sn,d.NumberFieldNotEqualsCondition=zn,d.NumberFieldNotInRangeCondition=xn,d.OTPField=re,d.OTPFieldConditionCell=_l,d.OTPFieldEqualsCondition=ke,d.OTPFieldExcludesCondition=qn,d.OTPFieldIncludesCondition=Mn,d.OTPFieldNotEqualsCondition=In,d.Observable=Re,d.PassFailField=ce,d.PassFailFieldConditionCell=$l,d.PassFailFieldEqualsCondition=Pe,d.PassFailFieldExcludesCondition=En,d.PassFailFieldIncludesCondition=On,d.PassFailFieldNotEqualsCondition=Tn,d.RadioField=ue,d.RadioFieldConditionCell=kl,d.RadioFieldEqualsCondition=je,d.RadioFieldExcludesCondition=An,d.RadioFieldIncludesCondition=Bn,d.RadioFieldNotEqualsCondition=Ln,d.RatingField=he,d.RatingFieldConditionCell=Pl,d.RatingFieldEqualsCondition=Ue,d.RatingFieldGreaterThanCondition=kn,d.RatingFieldGreaterThanOrEqualsCondition=Pn,d.RatingFieldInRangeCondition=jn,d.RatingFieldLessThanCondition=_n,d.RatingFieldLessThanOrEqualsCondition=$n,d.RatingFieldNotEqualsCondition=Dn,d.RatingFieldNotInRangeCondition=Un,d.ScanField=Ve,d.ScanFieldConditionCell=jl,d.ScanFieldEqualsCondition=Ge,d.ScanFieldExcludesCondition=Hn,d.ScanFieldIncludesCondition=Jn,d.ScanFieldNotEqualsCondition=Gn,d.Scanner=vi,d.ScannerProvider=gl,d.SelectField=fe,d.SelectFieldConditionCell=Ul,d.SelectFieldEqualsCondition=Je,d.SelectFieldExcludesCondition=Xn,d.SelectFieldIncludesCondition=Kn,d.SelectFieldNotEqualsCondition=Wn,d.StringField=pe,d.StringFieldConditionCell=Gl,d.StringFieldEqualsCondition=He,d.StringFieldExcludesCondition=Qn,d.StringFieldIncludesCondition=Yn,d.StringFieldNotEqualsCondition=Zn,d.TextField=ge,d.TextFieldConditionCell=Jl,d.TextFieldEqualsCondition=We,d.TextFieldExcludesCondition=ni,d.TextFieldIncludesCondition=ei,d.TextFieldNotEqualsCondition=Rn,d.TimeField=Ne,d.TimeFieldAfterCondition=li,d.TimeFieldBeforeCondition=ti,d.TimeFieldConditionCell=Hl,d.TimeFieldControl=Si,d.TimeFieldEqualsCondition=Ke,d.TimeFieldInCondition=si,d.TimeFieldInput=gt,d.TimeFieldNotEqualsCondition=ii,d.TimeFieldNotInCondition=ai,d.UNLABELLED_FIELD_LABEL=A,d.UNLABELLED_SECTION_LABEL=bi,d.URLField=xe,d.URLFieldConditionCell=Kl,d.URLFieldEqualsCondition=Ze,d.URLFieldExcludesCondition=ci,d.URLFieldIncludesCondition=di,d.URLFieldNotEqualsCondition=oi,d.UTC_OFFSETS=ft,d.UTC_OFFSETS_SET=Fl,d.UUIDFile=de,d.UUIDPromise=be,d.UploadField=ye,d.UploadFieldConditionCell=Wl,d.UploadFieldEqualsCondition=Xe,d.UploadFieldNotEqualsCondition=ri,d.VideoCard=dt,d.VideoFile=ot,d.areFieldValuesBlank=ps,d.areFieldValuesEqual=Nt,d.areFileAndPromiseArraysEqual=yi,d.areJSONPassFailFieldValuesEqual=cl,d.arePassFieldValuesEqual=dl,d.awaitFilesAndPromises=La,d.blankFieldValues=xt,d.booleanFieldConditionModifierConfig=Ni,d.changedFieldValues=hs,d.checkboxListFieldConditionModifierConfig=xi,d.cleanConditions=Ft,d.cleanFieldValues=Wi,d.cleanSerializedConditions=vt,d.cleanSerializedFieldValues=Vt,d.createCondition=ui,d.createField=Zi,d.createTime=me,d.dateFieldConditionModifierConfig=Mi,d.deserializeCondition=Xl,d.deserializeConditions=Gi,d.deserializeField=Ji,d.deserializeFieldConfig=St,d.deserializeFieldConfigs=ns,d.deserializeFieldElement=Yl,d.deserializeFieldElementConfig=is,d.deserializeFieldElementConfigs=ts,d.deserializeFieldElements=Hi,d.deserializeFieldValues=os,d.deserializeFields=ba,d.deserializePassFailFieldValue=ol,d.extractFilesAndPromisesFromFieldValues=ds,d.fieldDataMapping=E,d.fieldElementFromConfig=Rl,d.fieldElementsFromConfigs=es,d.fieldFromConfig=wt,d.fieldSpacingCva=Ki,d.fieldTypeGroupDataMapping=xl,d.fieldsFromConfigs=Ql,d.formatTime=wi,d.formatUTCOffset=zi,d.getCurrentUTCOffset=wl,d.getFieldsMapping=Va,d.getImagesFromFields=Ea,d.getUTCMinuteOfDay=Ce,d.getUTCOffsetMinutes=Sl,d.initializeFieldValues=us,d.insertFilesAndPromisesToFieldValues=cs,d.isFileAndPromiseArray=tl,d.isJSONPassFailFieldValue=sl,d.isPassFailFieldStatus=ut,d.isPassFailFieldValue=al,d.isStringArray=Qe,d.isTime=Y,d.isTimeInRange=pt,d.isTimeRange=za,d.isUTCOffset=Fi,d.multiSelectFieldConditionModifierConfig=qi,d.multiStringFieldConditionModifierConfig=Ti,d.normalizeFieldOption=lt,d.normalizeFieldOptions=se,d.numberFieldConditionModifierConfig=Oi,d.otpFieldConditionModifierConfig=Ei,d.parseTime=en,d.passFailFieldConditionModifierConfig=Li,d.passFailFieldStatusMapping=oe,d.passFailFieldStatuses=Te,d.radioFieldConditionModifierConfig=Bi,d.ratingFieldConditionModifierConfig=Ai,d.scanFieldConditionModifierConfig=Di,d.selectFieldConditionModifierConfig=_i,d.serializeConditions=Zl,d.serializeFieldConfig=bt,d.serializeFieldConfigs=ls,d.serializeFieldElementConfig=ss,d.serializeFieldElementConfigs=as,d.serializeFieldValues=rs,d.serializePassFailFieldValue=rl,d.stringFieldConditionModifierConfig=$i,d.textFieldConditionModifierConfig=ki,d.timeFieldConditionModifierConfig=Pi,d.unchangedFieldValues=fs,d.uploadFieldConditionModifierConfig=ji,d.urlFieldConditionModifierConfig=Ui,d.useConditionManager=wa,d.useFieldInput=_,d.useFieldInputs=Ci,d.useFieldSectionInputs=Yt,d.useImageViewer=mi,d.useObjectUrl=it,d.useScanner=Ca,d.useScannerContext=fl,d.validateFieldValues=qt,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
|