@overmap-ai/forms 1.1.4 → 1.1.5-conditions-v2.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/Root.d.ts +2 -2
- package/dist/form/builder/components/CreateFieldDropdownMenu.d.ts +1 -1
- package/dist/form/builder/components/FieldDropdownMenu.d.ts +1 -0
- package/dist/form/builder/list/sectionSerialization.d.ts +3 -3
- package/dist/form/builder/typings.d.ts +3 -3
- package/dist/form/builder/utils.d.ts +3 -3
- package/dist/form/conditions/BaseCondition/BaseCondition.d.ts +13 -27
- package/dist/form/conditions/BaseCondition/typings.d.ts +11 -15
- 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 -4
- 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 -4
- 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 -4
- 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 -4
- 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 -4
- 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 -4
- 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 -4
- 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 -4
- 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 -4
- 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 -4
- 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 -4
- 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 -4
- 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 -4
- 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 -4
- 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 -4
- 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 -4
- 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 +3 -1
- package/dist/form/conditions/UploadFieldCondition/mappings.d.ts +16 -0
- package/dist/form/conditions/UploadFieldCondition/typings.d.ts +4 -4
- 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/SelectFieldOptionMultiSelectGroup.d.ts +1 -1
- package/dist/form/conditions/components/SelectFieldOptionSelectGroup.d.ts +1 -1
- package/dist/form/conditions/components/TimeInputPopover.d.ts +1 -1
- 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 -27
- package/dist/form/conditions/utils.d.ts +6 -5
- package/dist/form/fields/BaseField/BaseField.d.ts +13 -9
- package/dist/form/fields/BaseField/typings.d.ts +9 -9
- package/dist/form/fields/BaseFormElement/BaseFormElement.d.ts +11 -7
- package/dist/form/fields/BaseFormElement/typings.d.ts +5 -5
- package/dist/form/fields/BaseOptionsField/BaseOptionsField.d.ts +7 -6
- package/dist/form/fields/BaseOptionsField/index.d.ts +1 -0
- package/dist/form/fields/BaseOptionsField/typings.d.ts +6 -7
- package/dist/form/fields/BaseOptionsField/utils.d.ts +3 -0
- package/dist/form/fields/BaseStringField/BaseStringField.d.ts +8 -9
- package/dist/form/fields/BaseStringField/typings.d.ts +9 -4
- package/dist/form/fields/BooleanField/BooleanField.d.ts +10 -6
- package/dist/form/fields/BooleanField/typings.d.ts +3 -2
- package/dist/form/fields/CheckboxListField/CheckboxListField.d.ts +10 -7
- package/dist/form/fields/CheckboxListField/index.d.ts +0 -1
- package/dist/form/fields/CheckboxListField/typings.d.ts +4 -2
- package/dist/form/fields/DateField/DateField.d.ts +10 -7
- package/dist/form/fields/DateField/typings.d.ts +4 -2
- package/dist/form/fields/FieldSection/FieldSection.d.ts +20 -20
- package/dist/form/fields/FieldSection/index.d.ts +0 -1
- package/dist/form/fields/FieldSection/typings.d.ts +15 -9
- package/dist/form/fields/MultiSelectField/MultiSelectField.d.ts +10 -8
- package/dist/form/fields/MultiSelectField/index.d.ts +0 -1
- package/dist/form/fields/MultiSelectField/typings.d.ts +5 -2
- package/dist/form/fields/MultiStringField/MultiStringField.d.ts +13 -13
- package/dist/form/fields/MultiStringField/index.d.ts +0 -1
- package/dist/form/fields/MultiStringField/typings.d.ts +9 -4
- package/dist/form/fields/NumberField/NumberField.d.ts +13 -14
- package/dist/form/fields/NumberField/index.d.ts +0 -1
- package/dist/form/fields/NumberField/typings.d.ts +11 -5
- package/dist/form/fields/OTPField/OTPField.d.ts +12 -16
- package/dist/form/fields/OTPField/index.d.ts +0 -1
- package/dist/form/fields/OTPField/typings.d.ts +5 -6
- package/dist/form/fields/PassFailField/PassFailField.d.ts +17 -15
- package/dist/form/fields/PassFailField/constants.d.ts +1 -1
- package/dist/form/fields/PassFailField/index.d.ts +0 -1
- package/dist/form/fields/PassFailField/typings.d.ts +5 -7
- package/dist/form/fields/PassFailField/utils.d.ts +6 -5
- package/dist/form/fields/RadioField/RadioField.d.ts +10 -7
- package/dist/form/fields/RadioField/index.d.ts +0 -1
- package/dist/form/fields/RadioField/typings.d.ts +4 -2
- package/dist/form/fields/RatingField/RatingField.d.ts +10 -8
- package/dist/form/fields/RatingField/index.d.ts +0 -1
- package/dist/form/fields/RatingField/typings.d.ts +5 -2
- package/dist/form/fields/ScanField/ScanField.d.ts +10 -7
- package/dist/form/fields/ScanField/index.d.ts +0 -1
- package/dist/form/fields/ScanField/typings.d.ts +4 -2
- package/dist/form/fields/SelectField/SelectField.d.ts +10 -8
- package/dist/form/fields/SelectField/index.d.ts +0 -1
- package/dist/form/fields/SelectField/typings.d.ts +5 -2
- package/dist/form/fields/StringField/StringField.d.ts +10 -7
- package/dist/form/fields/StringField/index.d.ts +0 -2
- package/dist/form/fields/StringField/typings.d.ts +4 -2
- package/dist/form/fields/TextField/TextField.d.ts +10 -6
- package/dist/form/fields/TextField/index.d.ts +0 -2
- package/dist/form/fields/TextField/typings.d.ts +3 -2
- package/dist/form/fields/TimeField/TimeField.d.ts +9 -5
- package/dist/form/fields/TimeField/TimeFieldControl.d.ts +1 -1
- package/dist/form/fields/TimeField/index.d.ts +1 -1
- package/dist/form/fields/TimeField/typings.d.ts +3 -10
- package/dist/form/fields/TimeField/utils.d.ts +1 -1
- package/dist/form/fields/URLField/URLField.d.ts +11 -9
- package/dist/form/fields/URLField/index.d.ts +0 -1
- package/dist/form/fields/URLField/typings.d.ts +5 -2
- package/dist/form/fields/UploadField/UploadField.d.ts +12 -12
- package/dist/form/fields/UploadField/index.d.ts +1 -2
- package/dist/form/fields/UploadField/typings.d.ts +9 -9
- package/dist/form/fields/components/InputWithLabel.d.ts +4 -4
- package/dist/form/fields/constants.d.ts +39 -7
- package/dist/form/fields/hooks.d.ts +1 -1
- package/dist/form/fields/typings.d.ts +27 -22
- package/dist/form/fields/utils.d.ts +23 -12
- package/dist/form/index.d.ts +0 -1
- package/dist/form/schema/FieldSchema.d.ts +20 -14
- package/dist/form/schema/index.d.ts +1 -0
- package/dist/form/schema/typings.d.ts +3 -0
- package/dist/form/typings.d.ts +5 -6
- package/dist/form/utils.d.ts +3 -5
- package/dist/forms.js +5651 -4408
- package/dist/forms.umd.cjs +1 -1
- package/package.json +7 -5
- package/dist/form/conditions/BooleanFieldCondition/BooleanFieldCondition.d.ts +0 -15
- package/dist/form/conditions/CheckboxListFieldCondition/CheckboxListFieldCondition.d.ts +0 -18
- package/dist/form/conditions/DateFieldCondition/DateFieldCondition.d.ts +0 -20
- package/dist/form/conditions/MultiSelectFieldCondition/MultiSelectFieldCondition.d.ts +0 -18
- package/dist/form/conditions/MultiStringFieldCondition/MultiStringFieldCondition.d.ts +0 -18
- package/dist/form/conditions/NumberFieldCondition/NumberFieldCondition.d.ts +0 -21
- package/dist/form/conditions/OTPFieldCondition/OTPFieldCondition.d.ts +0 -17
- package/dist/form/conditions/PassFailFieldCondition/PassFailFieldCondition.d.ts +0 -18
- package/dist/form/conditions/RadioFieldCondition/RadioFieldCondition.d.ts +0 -17
- package/dist/form/conditions/RatingFieldCondition/RatingFieldCondition.d.ts +0 -21
- package/dist/form/conditions/ScanFieldCondition/ScanFieldCondition.d.ts +0 -17
- package/dist/form/conditions/SelectFieldCondition/SelectFieldCondition.d.ts +0 -17
- package/dist/form/conditions/StringFieldCondition/StringFieldCondition.d.ts +0 -17
- package/dist/form/conditions/TextFieldCondition/TextFieldCondition.d.ts +0 -18
- package/dist/form/conditions/TimeFieldCondition/TimeFieldCondition.d.ts +0 -19
- package/dist/form/conditions/URLFieldCondition/URLFieldCondition.d.ts +0 -18
- package/dist/form/conditions/UploadFieldCondition/UploadFieldCondition.d.ts +0 -17
- package/dist/form/conditions/constants.d.ts +0 -36
- package/dist/form/fields/StringField/constants.d.ts +0 -1
- package/dist/form/fields/TextField/constants.d.ts +0 -1
- 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("graphology"),require("graphology-traversal"),require("lodash.get"),require("lodash.set")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@overmap-ai/blocks","class-variance-authority","react","@xyflow/react/dist/style.css","@xyflow/react","graphology-dag","react-hook-form","uuid","@hello-pangea/dnd","file-saver","@overmap-ai/hooks","react-zxing","@dagrejs/dagre","graphology","graphology-traversal","lodash.get","lodash.set"],n):(c=typeof globalThis<"u"?globalThis:c||self,n(c.forms={},c.jsxRuntime,c.blocks,c.classVarianceAuthority,c.React,null,c.react,c.graphologyDag,c.reactHookForm,c.uuid,c.dnd,c.fileSaver,c.hooks,c.reactZxing,c.Dagre,c.graphology,c.graphologyTraversal,c.get,c.set))})(this,(function(c,n,o,Q,d,aa,O,Dn,Y,b,Oi,Pn,eo,io,jn,no,to,Un,ro){"use strict";const oo=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ao=i=>i.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase()),Gn=i=>{const e=ao(i);return e.charAt(0).toUpperCase()+e.slice(1)},kn=(...i)=>i.filter((e,t,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===t).join(" ").trim(),lo=i=>{for(const e in i)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var so={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const co=d.forwardRef(({color:i="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:r,className:a="",children:l,iconNode:s,...h},u)=>d.createElement("svg",{ref:u,...so,width:e,height:e,stroke:i,strokeWidth:r?Number(t)*24/Number(e):t,className:kn("lucide",a),...!l&&!lo(h)&&{"aria-hidden":"true"},...h},[...s.map(([f,p])=>d.createElement(f,p)),...Array.isArray(l)?l:[l]]));const N=(i,e)=>{const t=d.forwardRef(({className:r,...a},l)=>d.createElement(co,{ref:l,iconNode:e,className:kn(`lucide-${oo(Gn(i))}`,`lucide-${i}`,r),...a}));return t.displayName=Gn(i),t};const uo=N("align-justify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);const ho=N("arrow-down-up",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);const fo=N("arrow-left-right",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);const po=N("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const J=N("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const si=N("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const _i=N("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const go=N("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const mo=N("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);const Co=N("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Vo=N("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const Hn=N("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Jn=N("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);const yo=N("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);const Wn=N("clipboard-paste",[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]);const vo=N("copy-check",[["path",{d:"m12 15 2 2 4-4",key:"2c609p"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Ti=N("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Xn=N("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Kn=N("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);const So=N("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const zo=N("file",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);const Fo=N("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);const wo=N("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);const Yn=N("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const Zn=N("layout-panel-top",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);const bo=N("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const No=N("list-checks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);const Mo=N("list-todo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);const xo=N("list",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);const Io=N("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);const di=N("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Qn=N("move-down",[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);const Rn=N("move-up",[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);const Z=N("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const qo=N("rectangle-ellipsis",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);const Oo=N("scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);const _o=N("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const To=N("square-check",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const Lo=N("square-dashed",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]]);const et=N("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);const Bo=N("text-cursor-input",[["path",{d:"M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6",key:"1528k5"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1",key:"1mj8rg"}],["path",{d:"M9 6v12",key:"velyjx"}]]);const Ao=N("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);const se=N("trash",[["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const Li=N("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const Eo=N("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);const ne=N("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Bi=d.memo(i=>{const{ref:e,file:t,className:r,error:a,rightSlot:l,size:s,...h}=i,u=()=>a?n.jsxs(n.Fragment,{children:[n.jsx(o.LuIcon,{icon:_i,color:"var(--base-a11)"}),n.jsx(o.Text,{accentColor:"base",className:"truncate",size:s,children:a})]}):t?n.jsxs(n.Fragment,{children:[n.jsx(o.LuIcon,{icon:zo,color:"var(--base-a11)"}),n.jsx(o.Text,{className:"truncate",size:s,children:t.name})]}):n.jsx(n.Fragment,{children:n.jsx("div",{className:"flex w-full justify-center",children:n.jsx(o.Spinner,{size:s})})});return n.jsxs(o.Card,{className:Q.cx(r,"flex w-full items-center gap-2"),ref:e,size:"xs",...h,children:[u(),l]})});Bi.displayName="FileCard";function Ae(i){return Array.isArray(i)?i.every(e=>typeof e=="string"):!1}class Ee{observers=new Set;notify(e){for(const t of this.observers)t(e)}observe(e){return this.observers.add(e),()=>{this.observers.delete(e)}}}class Ai extends Ee{identifier;constructor(e){const{identifier:t}=e;super(),this.identifier=t}getOptions(){return{identifier:this.identifier}}setOptions(e){this.identifier=e.identifier??this.identifier,this.notify(this)}serialize(){return{type:this.type,identifier:this.identifier}}}class k extends Ai{label;description;required;image;constructor(e){const{label:t,description:r=null,required:a,image:l,...s}=e;super(s),this.label=t,this.description=r,this.required=a,this.image=l}getError(e){if(!(!this.required&&this.isValueBlank(e))){if(this.required&&this.isValueBlank(e))return"This field is required.";for(const t of this.getFieldValidators()){const r=t(e);if(r)return r}}}serialize(){return{...super.serialize(),label:this.label,description:this.description,required:this.required,image:this.image}}getOptions(){return{...super.getOptions(),label:this.label,description:this.description,required:this.required,image:this.image}}setOptions(e){const{label:t,description:r=null,required:a,image:l,...s}=e;this.label=t??this.label,this.description=r??this.description,this.required=a??this.required,this.image=l??this.image,super.setOptions(s)}isValueBlank(e){return this.areValuesEqual(e,this.blankValue())}cleanValue(e){return e}isValueClean(e){return this.areValuesEqual(e,this.cleanValue(e))}cleanSerializedValue(e){return e}isSerializedValueClean(e){return this.areSerializedValuesEqual(e,this.cleanSerializedValue(e))}isSerializedValueBlank(e){return this.areSerializedValuesEqual(e,this.blankSerializedValue())}getFieldValidators(){return[]}}const L=d.createContext({}),Ei=i=>{const[e,t]=d.useState(null);return d.useLayoutEffect(()=>{const r=URL.createObjectURL(i);return t(r),()=>{URL.revokeObjectURL(r)}},[i]),e},we=d.memo(i=>{const{file:e,...t}=i,r=Ei(e);return n.jsx("img",{src:r??void 0,alt:e.name,...t})});we.displayName="ImageFile";const it=d.createContext(()=>{throw new Error("No ImageViewerProvider found")}),ci=()=>d.useContext(it),$i=d.memo(i=>{const{file:e,onClose:t}=i,r=d.useCallback(()=>{Pn.saveAs(e,e.name)},[e]);return n.jsx(o.Overlay.Root,{open:!0,onOpenChange:t,children:n.jsxs(o.Overlay.Content,{onOpenAutoFocus:o.preventDefault,children:[n.jsxs(o.ButtonGroup,{className:"absolute right-0 top-0 flex items-center gap-2 p-2",accentColor:"base",variant:"ghost",children:[n.jsxs(o.Tooltip.Root,{children:[n.jsx(o.Tooltip.Trigger,{asChild:!0,children:n.jsx(o.IconButton,{onClick:r,"aria-label":"download",children:n.jsx(o.LuIcon,{icon:Xn})})}),n.jsx(o.Tooltip.Content,{size:"sm",children:"Download"})]}),n.jsx(o.Separator,{orientation:"vertical",size:"sm"}),n.jsx(o.Overlay.Close,{asChild:!0,children:n.jsx(o.IconButton,{onClick:t,"aria-label":"close",children:n.jsx(o.LuIcon,{icon:ne})})})]}),n.jsx("figure",{className:"flex size-full items-center justify-center overflow-hidden p-4",children:n.jsx(we,{className:"max-h-full max-w-full",file:e})})]})})});$i.displayName="ImageViewer";const nt=d.memo(i=>{const{children:e}=i,[t,r]=d.useState(null),a=d.useCallback(()=>{r(null)},[]),l=d.useCallback(h=>{r(h(a))},[a]),s=d.useCallback(()=>{t&&(t.onClose&&t.onClose(),a())},[a,t]);return n.jsxs(it.Provider,{value:l,children:[e,t&&n.jsx($i,{file:t.file,onClose:s})]})});nt.displayName="FileViewerProvider";const B=d.memo(i=>{const{label:e,error:t,description:r,required:a,children:l,inputId:s,image:h,size:u}=i,[f,p]=d.useState(void 0),g=ci();d.useEffect(()=>{h instanceof Promise?h.then(p).catch(console.error):p(h)},[h]);const m=d.useCallback(()=>{f&&g(()=>({file:f}))},[g,f]),C=a?`${e} *`:e;return n.jsxs("div",{className:"flex flex-col gap-1",children:[f&&n.jsx(we,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:f,onClick:m}),(!!e||!!r)&&n.jsxs("div",{className:"flex flex-col",children:[n.jsx("label",{className:"w-max max-w-full",htmlFor:s,children:n.jsx(o.Text,{size:u,className:"text-wrap",children:C})}),!!r&&n.jsx(o.Text,{accentColor:"base",size:u,children:r})]}),l,!!t&&n.jsx(o.Text,{accentColor:"danger",size:u,children:t})]})});B.displayName="InputWithLabel";const tt=i=>i.map(e=>n.jsx(d.Fragment,{children:e.render()},e.identifier)),ui=i=>i.map(e=>n.jsx(d.Fragment,{children:e.render()},e.identifier)),D=i=>{const{field:e}=i,{field:{value:t,name:r,onChange:a,onBlur:l,disabled:s},fieldState:{isTouched:h,error:u}}=Y.useController({name:e.identifier});return{value:t,name:r,disabled:s,isTouched:h,error:u?.message??"",onChange:a,onBlur:l}},Di=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),[f,p]=d.useState(""),[g,m]=d.useState(""),C=d.useCallback(F=>{s(F),l()},[s,l]),v=d.useCallback(F=>{r&&r.findIndex(w=>w===F.target.value.trim())>=0?m("All options must be unique"):F.target.value?m(""):m("Option cannot be empty"),p(F.target.value)},[p,r]),y=d.useCallback(()=>{if(g)return;if(!f.trim()){m("Option cannot be empty");return}const F=f.trim();C([...r,F]),p("")},[f,g,C,r]),S=d.useCallback(F=>{F.key==="Enter"&&(F.preventDefault(),y())},[y]),z=d.useCallback(F=>{const w=Array.from(r);w.splice(F,1),C(w)},[r,C]),x=d.useCallback(F=>{if(!F.destination)return;const w=F.source.index,T=F.destination.index,G=Array.from(r),[ee]=G.splice(w,1);G.splice(T,0,ee),C(G)},[C,r]),I=d.useCallback(()=>{l()},[l]);return n.jsx(Oi.DragDropContext,{onDragEnd:x,children:n.jsxs(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:g||h,image:e.image,children:[(!u||r.length===0)&&n.jsxs("div",{className:"flex gap-2",children:[n.jsx(o.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:t,children:n.jsx(o.Input.Field,{value:f,onChange:v,onKeyDown:S,id:e.identifier,placeholder:e.placeholder,onBlur:I,name:a,disabled:u})}),n.jsx(o.IconButton,{size:t,accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!g||u,onClick:y,children:n.jsx(o.LuIcon,{icon:Z})})]}),r.length!==0&&n.jsx(Oi.Droppable,{droppableId:`${e.identifier}-droppable`,children:F=>n.jsxs("div",{className:"flex flex-col gap-1",...F.droppableProps,ref:F.innerRef,children:[r.map((w,T)=>n.jsx(Oi.Draggable,{draggableId:`${w}-draggable`,index:T,isDragDisabled:u,children:({draggableProps:G,dragHandleProps:ee,innerRef:Be})=>n.jsxs(o.Badge,{...ee,...G,ref:Be,className:"flex items-center justify-between gap-2",accentColor:"base",size:t,variant:"soft",children:[n.jsx(o.Text,{className:"truncate",highContrast:!0,children:typeof w=="object"&&"label"in w?w.label:w}),n.jsx(o.IconButton,{className:"bg-transparent!",size:t,variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:u,onClick:()=>{z(T)},children:n.jsx(o.LuIcon,{icon:ne})})]})},`${e.identifier}-${w}-${T}`)),F.placeholder]})})]})})});Di.displayName="MultiStringFieldInput";class de extends k{type="multi-string";minLength;maxLength;placeholder;constructor(e){const{minimum_length:t,maximum_length:r,placeholder:a,...l}=e;super(l),this.minLength=t??0,this.maxLength=r??1/0,this.placeholder=a??"Press enter to add a new option"}render(){return n.jsx(Di,{field:this})}serialize(){return{...super.serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}duplicate(e){return new de({...this.getOptions(),identifier:e})}setOptions(e){const{minimum_length:t,maximum_length:r,placeholder:a,...l}=e;this.minLength=t??this.minLength,this.maxLength=r??this.maxLength,this.placeholder=a??this.placeholder,super.setOptions(l)}serializeValue(e){return e}deserializeValue(e){return e}getFieldValidators(){const e=super.getFieldValidators();return e.push(t=>{if(t.length<this.minLength)return`Must have at least ${this.minLength} options.`}),e.push(t=>{if(t.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),e}static deserialize(e){return new de(e)}isSerializedValue(e){return Ae(e)}isValue(e){return Ae(e)}blankValue(){return[]}areValuesEqual(e,t){const r=new Set(e),a=new Set(t);return r.size===a.size&&r.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(e,t){const r=new Set(e),a=new Set(t);return r.size===a.size&&r.isSubsetOf(a)}}class $e extends k{options;constructor(e){const{options:t,...r}=e;super(r),this.options=t.map(a=>(typeof a=="string"&&(a={label:a,value:a}),a))}serialize(){return{...super.serialize(),options:this.options}}getOptions(){return{...super.getOptions(),options:this.options}}setOptions(e){const{options:t,...r}=e;this.options=t?.map(a=>(typeof a=="string"&&(a={label:a,value:a}),a))??this.options,super.setOptions(r)}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new de({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${t}options`,minimum_length:2}),showDirectly:!0}]}}const Pi=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(g=>{s(!!g),l()},[l,s]),p=d.useCallback(()=>{l()},[l]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,error:h,image:e.image,required:e.required,children:n.jsx(o.Checkbox.Root,{id:e.identifier,name:a,checked:r??!1,onCheckedChange:f,onBlur:p,size:t,accentColor:"base",variant:"surface",disabled:u,children:n.jsx(o.Checkbox.Indicator,{children:n.jsx(o.LuIcon,{icon:J})})})})});Pi.displayName="BooleanFieldInput";class ce extends k{type="boolean";constructor(e){super(e)}serialize(){return super.serialize()}getOptions(){return super.getOptions()}setOptions(e){super.setOptions(e)}duplicate(e){return new ce({...this.getOptions(),identifier:e})}static deserialize(e){return new ce(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Pi,{field:this})}isSerializedValue(e){return typeof e=="boolean"}isValue(e){return typeof e=="boolean"}blankValue(){return!1}blankSerializedValue(){return!1}areSerializedValuesEqual(e,t){return e===t}areValuesEqual(e,t){return e===t}}const ji=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(m=>{const C=m.target.valueAsNumber,v=isNaN(C)?null:C;s(v)},[s]),p=d.useCallback(()=>{l()},[l]),g=d.useCallback(m=>{m.key==="Enter"&&m.preventDefault()},[]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsx(o.Input.Root,{accentColor:"base",variant:"surface",size:t,children:n.jsx(o.Input.Field,{id:e.identifier,name:a,onChange:f,onBlur:p,value:r??"",type:"number",min:e.minimum,max:e.maximum,step:e.integers?1:"any",placeholder:e.placeholder??"Enter a number",disabled:u,onKeyDown:g})})})});ji.displayName="NumberFieldInput";class H extends k{type="number";minimum;maximum;integers;placeholder;constructor(e){const{minimum:t=Number.MIN_SAFE_INTEGER,maximum:r=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:l,...s}=e;super(s),this.minimum=t,this.maximum=r,this.integers=a,this.placeholder=l}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new H({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${t}minimum`}),showDirectly:!1},{field:new H({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${t}maximum`}),showDirectly:!1},{field:new ce({label:"Integers",description:"Whole numbers only",required:!1,identifier:`${t}integers`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),t=this.minimum,r=this.maximum;return typeof t=="number"&&e.push(a=>{if(typeof a=="number"&&a<t)return`Must be at least ${this.minimum}.`}),typeof r=="number"&&e.push(a=>{if(typeof a=="number"&&a>r)return`Must be at most ${this.maximum}.`}),this.integers&&e.push(a=>{if(typeof a=="number"&&!Number.isInteger(a))return"Must be a whole number."}),e}serialize(){return{...super.serialize(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}duplicate(e){return new H({...this.getOptions(),identifier:e})}setOptions(e){const{minimum:t,maximum:r,integers:a,placeholder:l,...s}=e;this.minimum=t??this.minimum,this.maximum=r??this.maximum,this.integers=a??this.integers,this.placeholder=l??this.placeholder,super.setOptions(s)}static deserialize(e){return new H(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(ji,{field:this})}isSerializedValue(e){return this.isValue(e)}isValue(e){return typeof e=="number"&&!isNaN(e)||e===null}areValuesEqual(e,t){return e===t}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}}const De=1e4;class Ui extends k{minLength;maxLength;placeholder;constructor(e){const{minLength:t,maxLength:r,placeholder:a="",...l}=e;super(l),this.minLength=t?Math.max(t,0):void 0,this.maxLength=r?Math.max(r,0):De,this.placeholder=a}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new H({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${t}minimum_length`,minimum:0,maximum:100,integers:!0}),showDirectly:!1},{field:new H({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${t}maximum_length`,minimum:1,maximum:De,integers:!0}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators();return this.minLength&&e.push(t=>{if(this.minLength&&(!t||t.length<this.minLength))return!this.required&&!t?void 0:`Minimum ${this.minLength} character(s).`}),this.maxLength&&e.push(t=>{if(typeof t=="string"&&this.maxLength&&t.length>this.maxLength)return`Maximum ${this.maxLength} character(s).`}),e}serialize(){return{...super.serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),minLength:this.minLength,maxLength:this.maxLength,placeholder:this.placeholder}}setOptions(e){const{minLength:t,maxLength:r,placeholder:a,...l}=e;this.minLength=t,this.maxLength=r??this.maxLength,this.placeholder=a,super.setOptions(l)}serializeValue(e){return e}deserializeValue(e){return e}isSerializedValue(e){return typeof e=="string"}isValue(e){return typeof e=="string"}blankValue(){return""}blankSerializedValue(){return""}areSerializedValuesEqual(e,t){return e===t}areValuesEqual(e,t){return e===t}}const Gi=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(g=>{s(g),l()},[l,s]),p=d.useCallback(()=>{l()},[l]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsx(o.CheckboxGroup.Root,{id:e.identifier,name:a,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,values:r,onValuesChange:f,disabled:u,children:e.options.map((g,m)=>n.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(o.CheckboxGroup.Item,{value:g.value,onBlur:p,children:n.jsx(o.CheckboxGroup.ItemIndicator,{children:n.jsx(o.LuIcon,{icon:J})})}),n.jsx(o.Text,{size:t,accentColor:"base",className:"truncate",children:g.label})]},`${e.identifier}-${g.value}-${m}`))})})});Gi.displayName="CheckboxListFieldInput";class ue extends $e{type="checkbox-list";constructor(e){super(e)}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new ue({...this.getOptions(),identifier:e})}static deserialize(e){return new ue(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Gi,{field:this})}isSerializedValue(e){if(!Ae(e))return!1;const t=new Set(this.options.map(({value:r})=>r));return e.every(r=>t.has(r))}isValue(e){return this.isSerializedValue(e)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(e,t){const r=new Set(e),a=new Set(t);return r.size===a.size&&r.isSubsetOf(a)}areValuesEqual(e,t){const r=new Set(e),a=new Set(t);return r.size===a.size&&r.isSubsetOf(a)}}const ki=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),[f,p]=d.useState(!1),g=d.useCallback(C=>{s(C??null),l(),p(!1)},[s,l]),m=d.useCallback(C=>{p(C),C||l()},[l]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs(o.Popover.Root,{open:f,onOpenChange:m,children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:n.jsxs(o.Button,{id:e.identifier,name:a,type:"button",className:"!justify-between",accentColor:"base",variant:"surface",size:t,disabled:u,children:[n.jsx(o.Text,{className:"truncate",highContrast:!!r,children:r?r.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd"}),n.jsx(o.LuIcon,{icon:si})]})}),n.jsx(o.Popover.Content,{align:"start",size:t,children:n.jsx(o.DayPicker,{size:t,required:!1,mode:"single",variant:"solid",selected:r??void 0,onSelect:g})})]})})});ki.displayName="DateFieldInput";class be extends k{type="date";constructor(e){super(e)}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new be({...this.getOptions(),identifier:e})}static deserialize(e){return new be(e)}setOptions(e){super.setOptions(e)}serializeValue(e){return e?e.toISOString():null}deserializeValue(e){return e?new Date(e):null}render(){return n.jsx(ki,{field:this})}isSerializedValue(e){return typeof e!="string"&&e!==null?!1:this.isValue(this.deserializeValue(e))}isValue(e){return!(!(e instanceof Date)&&e!==null||e instanceof Date&&isNaN(e.getTime()))}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}areValuesEqual(e,t){return!e&&!t?!0:!e||!t?!1:e.getTime()===t.getTime()}}var q=(i=>(i.Text="text",i.Selection="selection",i.Numeric="numeric",i.Temporal="temporal",i.Capture="capture",i.Assessment="assessment",i.Verification="verification",i))(q||{});const Hi=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(g=>{s(g),l()},[l,s]),p=d.useCallback(g=>{g||l()},[l]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs(o.Menu.Root,{onOpenChange:p,align:"start",children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsxs(o.Button,{id:e.identifier,name:a,className:"!justify-between",variant:"surface",type:"button",size:t,accentColor:"base",disabled:u,children:[n.jsx(o.Text,{className:"truncate",highContrast:r&&r.length>0,children:r&&r.length>0?r.join(", "):e.placeholder??"Select one or more..."}),n.jsx(o.LuIcon,{icon:si})]})}),n.jsx(o.Menu.Content,{size:t,children:n.jsx(o.Menu.Scroll,{children:n.jsxs(o.Menu.MultiSelectGroup,{values:r,onValuesChange:f,children:[n.jsxs(o.Menu.SelectAllItem,{children:[n.jsx(o.Menu.CheckboxItemIndicator,{children:g=>g?n.jsx(o.LuIcon,{icon:di}):n.jsx(o.LuIcon,{icon:J})}),"Select all"]}),e.options.map((g,m)=>n.jsxs(o.Menu.MultiSelectItem,{value:g.value,children:[n.jsx(o.Menu.SelectedIndicator,{children:n.jsx(o.LuIcon,{icon:J})}),g.label]},`${e.identifier}-${g.value}-${m}`))]})})})]})})});Hi.displayName="MultiSelectFieldInput";class ie extends $e{type="multi-select";placeholder;constructor(e){const{placeholder:t,...r}=e;super(r),this.placeholder=t}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new ie({...this.getOptions(),identifier:e})}setOptions(e){const{placeholder:t}=e;this.placeholder=t,super.setOptions(e)}static deserialize(e){return new ie(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Hi,{field:this})}isSerializedValue(e){if(!Ae(e))return!1;const t=new Set(this.options.map(({value:r})=>r));return e.every(r=>t.has(r))}isValue(e){return this.isSerializedValue(e)}blankValue(){return[]}areValuesEqual(e,t){const r=new Set(e),a=new Set(t);return r.size===a.size&&r.isSubsetOf(a)}blankSerializedValue(){return[]}areSerializedValuesEqual(e,t){const r=new Set(e),a=new Set(t);return r.size===a.size&&r.isSubsetOf(a)}}const Ji=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(m=>{s(m??null),l()},[l,s]),p=d.useCallback(m=>{m||l()},[l]),g=d.useMemo(()=>e.options.find(m=>m.value===r),[e.options,r]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs(o.Menu.Root,{onOpenChange:p,align:"start",children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsxs(o.Button,{id:e.identifier,name:a,className:"!justify-between",accentColor:"base",variant:"surface",type:"button",size:t,disabled:u,children:[n.jsx(o.Text,{className:"truncate",highContrast:!!g,children:g?g.label:e.placeholder??"Select one..."}),n.jsx(o.LuIcon,{icon:si})]})}),n.jsx(o.Menu.Content,{size:t,children:n.jsx(o.Menu.Scroll,{children:n.jsx(o.Menu.SelectGroup,{required:!1,value:r??void 0,onValueChange:f,children:e.options.map((m,C)=>n.jsxs(o.Menu.SelectItem,{value:m.value,children:[n.jsx(o.Menu.SelectedIndicator,{children:n.jsx(o.LuIcon,{icon:J})}),m.label]},`${e.identifier}-${m.value}-${C}`))})})})]})})});Ji.displayName="SelectFieldInput";class te extends $e{type="select";placeholder;constructor(e){const{placeholder:t,...r}=e;super(r),this.placeholder=t}serialize(){return super.serialize()}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new te({...this.getOptions(),identifier:e})}setOptions(e){const{placeholder:t}=e;this.placeholder=t,super.setOptions(e)}static deserialize(e){return new te(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Ji,{field:this})}isSerializedValue(e){return typeof e!="string"&&e!==null?!1:new Set([null,...this.options.map(({value:r})=>r)]).has(e)}isValue(e){return this.isSerializedValue(e)}blankValue(){return null}areValuesEqual(e,t){return e===t}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}}const Wi=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(m=>{s(m)},[s]),p=d.useCallback(()=>{l()},[l]),g=d.useMemo(()=>Array.from({length:e.length},()=>b.v4()),[e.length]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs(o.OneTimePasswordField.Root,{id:e.identifier,name:a,value:r,onValueChange:f,validationType:e.validationType,disabled:u,orientation:"horizontal",dir:"ltr",type:"text",autoComplete:"off",autoFocus:!1,autoSubmit:!1,className:"p-0.25 flex h-max w-full gap-1 overflow-x-auto",accentColor:"base",variant:"surface",size:t,onBlur:p,children:[g.map(m=>n.jsx(o.OneTimePasswordField.Input,{id:m},m)),n.jsx(o.OneTimePasswordField.HiddenInput,{})]})})});Wi.displayName="OTPFieldInput";class he extends k{type="otp";length;validationType;constructor(e){const{length:t,validationType:r,...a}=e;super(a),this.length=t,this.validationType=r}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new H({label:"Length",integers:!0,required:!1,minimum:1,maximum:16,identifier:`${t}length`}),showDirectly:!1},{field:new te({label:"Type",required:!1,identifier:`${t}validationType`,options:[{value:"none",label:"Any"},{value:"numeric",label:"Numeric"},{value:"alpha",label:"Alpha"},{value:"alphanumeric",label:"Alphanumeric"}]}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),t=this.length;return e.push(r=>{if(r.length!=t)return`Must be ${t} characters.`}),e}serialize(){return{...super.serialize(),length:this.length,validationType:this.validationType}}getOptions(){return{...super.getOptions(),length:this.length,validationType:this.validationType}}duplicate(e){return new he({...this.getOptions(),identifier:e})}setOptions(e){const{length:t,validationType:r,...a}=e;this.length=t??this.length,this.validationType=r??this.validationType,super.setOptions(a)}static deserialize(e){return new he(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(Wi,{field:this})}isSerializedValue(e){return typeof e=="string"}isValue(e){return typeof e=="string"}blankValue(){return""}areValuesEqual(e,t){return e===t}blankSerializedValue(){return""}areSerializedValuesEqual(e,t){return e===t}}const fe={pass:{label:"Pass",icon:go},fail:{label:"Fail",icon:Vo},na:{label:"N/A",icon:Co}},Ne=Object.keys(fe);class re extends File{uuid;constructor(e,...t){super(...t),this.uuid=e}static from(e,t){return new re(e,[t],t.name,{lastModified:t.lastModified,type:t.type})}}class pe extends Promise{_uuid;constructor(e,t){super(e),this._uuid=t}get uuid(){return this._uuid}set uuid(e){this._uuid=e}static from(e,t){return new pe((r,a)=>{Promise.resolve(e).then(r).catch(a)},t)}then(e,t){const r=super.then(e,t);return r.uuid=this.uuid,r}catch(e){const t=super.catch(e);return t.uuid=this.uuid,t}finally(e){const t=super.finally(e);return t.uuid=this.uuid,t}}function rt(i){return Array.isArray(i)?i.every(e=>e instanceof pe||e instanceof re):!1}function hi(i,e){const t=new Set(i.map(({uuid:a})=>a)),r=new Set(e.map(({uuid:a})=>a));return t.size===r.size&&t.isSubsetOf(r)}const Xi=d.memo(i=>{const{ref:e,file:t,error:r,rightSlot:a,className:l,size:s,...h}=i;return n.jsxs(o.Card,{className:Q.cx(l,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:e,size:"xs",...h,children:[!t&&!r&&n.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:n.jsx(o.Spinner,{size:s})}),!!t&&!r&&n.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3",children:n.jsx(we,{className:"block size-full max-w-full object-cover",file:t})}),!!r&&n.jsx("div",{className:"grow"}),(!!t||!!r)&&n.jsxs(n.Fragment,{children:[n.jsx(o.Separator,{size:"full"}),n.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[r?n.jsx(o.LuIcon,{color:"var(--base-11)",icon:_i}):t&&n.jsx(o.LuIcon,{color:"var(--base-11)",icon:Yn}),n.jsx(o.Text,{className:"truncate",size:s,children:r??t?.name}),a]})]})]})});Xi.displayName="ImageCard";const Ki=d.memo(i=>{const{file:e,...t}=i,r=Ei(e);return n.jsx("video",{src:r??void 0,...t})});Ki.displayName="VideoFile";const Yi=d.memo(i=>{const{ref:e,file:t,className:r,error:a,rightSlot:l,size:s,...h}=i;return n.jsxs(o.Card,{className:Q.cx(r,"p-0! relative flex h-48 w-full flex-col overflow-hidden"),ref:e,size:"xs",...h,children:[!t&&!a&&n.jsx("div",{className:"absolute inset-0 flex grow items-center justify-center",children:n.jsx(o.Spinner,{size:s})}),!!t&&!a&&n.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-hidden p-3",children:n.jsx(Ki,{className:"block size-full max-w-full object-cover",file:t,controls:!0})}),!!a&&n.jsx("div",{className:"grow"}),(!!t||!!a)&&n.jsxs(n.Fragment,{children:[n.jsx(o.Separator,{size:"full"}),n.jsxs("div",{className:"flex w-full shrink-0 items-center gap-2 self-end p-3",children:[a?n.jsx(o.LuIcon,{color:"var(--danger-11)",icon:_i}):t&&n.jsx(o.LuIcon,{color:"var(--base-11)",icon:Eo}),n.jsx(o.Text,{className:"truncate",size:s,children:a??t?.name}),l]})]})]})});Yi.displayName="VideoCard";const Zi=d.memo(i=>{const{fileOrPromise:e,onRemove:t,disabled:r,size:a}=i,[l,s]=d.useState(e instanceof pe?null:e),[h,u]=d.useState(null),f=ci();eo.useActiveEffect(z=>{if(u(null),!(e instanceof pe)){s(e);return}s(null),e.then(x=>{z()&&s(x)}).catch(x=>{z()&&u(x instanceof Error?x.message:"Unknown error")})},[e]);const p=d.useCallback(()=>{if(!l)return;const z=new Blob([l]);Pn.saveAs(z,l.name)},[l]),g=d.useCallback(()=>{t(e)},[t,e]),m=d.useCallback(()=>{if(!l)return;const z=URL.createObjectURL(l);window.open(z,"_blank"),URL.revokeObjectURL(z)},[l]),C=d.useCallback(()=>{l&&f(z=>({file:l,onDelete:r?void 0:()=>{g(),z()}}))},[r,g,f,l]),v=d.useMemo(()=>n.jsx("div",{className:"flex grow justify-end",children:n.jsxs(o.Menu.Root,{modal:!0,children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.IconButton,{onClick:o.stopPropagation,type:"button",variant:"ghost",accentColor:"base",size:a,children:n.jsx(o.LuIcon,{icon:Kn})})}),n.jsxs(o.Menu.Content,{size:a,children:[n.jsxs(o.Menu.Item,{onSelect:p,disabled:!l,children:[n.jsx(o.LuIcon,{icon:Xn})," Download"]}),r?null:n.jsxs(n.Fragment,{children:[n.jsx(o.Menu.Separator,{}),n.jsxs(o.Menu.Item,{onSelect:g,children:[n.jsx(o.LuIcon,{icon:se})," Delete"]})]})]})]})}),[r,g,p,l,a]),y=!!l?.type.startsWith("image/"),S=!!l?.type.startsWith("video/");return y?n.jsx(Xi,{className:"cursor-pointer",onClick:C,file:l,error:h??void 0,rightSlot:v,size:a}):S?n.jsx(Yi,{className:"cursor-pointer",onClick:C,file:l,error:h??void 0,rightSlot:v,size:a}):n.jsx(Bi,{className:"cursor-pointer",file:l,error:h??void 0,onClick:m,rightSlot:v,size:a})});Zi.displayName="DisplayFile";const Qi=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useRef(null),p=d.useCallback(F=>{const w=e.cleanValue({...r,status:F});s(w),l()},[e,l,s,r]),g=d.useCallback(F=>{const w=F.target.value,T={...r,notes:w};s(T)},[r,s]),m=d.useCallback(()=>{l()},[l]),C=d.useCallback(F=>{const w=r.files.filter(({uuid:T})=>T!==F.uuid);s({...r,files:w}),l()},[s,l,r]),v=d.useCallback(()=>{f.current?.click()},[]),y=d.useCallback(F=>{const w=Array.from(F.target.files??[]).map(G=>re.from(b.v4(),G)),T={...r,files:[...r.files,...w]};s(T),l()},[l,s,r]);d.useEffect(()=>{if(!f.current)return;const F=new AbortController;return f.current.addEventListener("cancel",()=>{l()},{signal:F.signal}),()=>{F.abort()}},[l,r]);const S=r.status&&e.showNotesAndFilesOn.includes(r.status),z=`${e.identifier}-status`,x=`${e.identifier}-notes`,I=`${e.identifier}-files`;return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(o.RadioGroup.Root,{id:z,className:"flex gap-2",name:a,value:r.status,disabled:u,accentColor:"base",variant:"surface",size:t,onValueChange:p,children:Ne.map(F=>{const{label:w}=fe[F];return n.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(o.RadioGroup.Item,{value:F,children:n.jsx(o.RadioGroup.Indicator,{children:n.jsx(o.LuIcon,{icon:Hn,className:"fill-current"})})}),n.jsx(o.Text,{size:t,accentColor:"base",className:"truncate",children:w})]},`${e.identifier}-${F}`)})}),S&&n.jsxs(n.Fragment,{children:[n.jsx("div",{children:n.jsx(o.TextArea,{id:x,value:r.notes??"",name:a,onChange:g,onBlur:m,className:"field-sizing-content min-h-12 w-full",placeholder:"Notes",resize:"vertical",accentColor:"base",variant:"surface",size:t,disabled:u})}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs(o.Button,{className:"w-max",size:t,variant:"surface",accentColor:"base",onClick:v,type:"button",disabled:u,children:[n.jsx(o.LuIcon,{icon:Li}),"Select files"]}),n.jsx("input",{id:I,name:a,type:"file",ref:f,multiple:!0,className:"hidden",onChange:y,value:""}),r.files.length>0&&n.jsx("div",{className:"flex h-max flex-wrap gap-2",children:r.files.map(F=>n.jsx(Zi,{size:t,fileOrPromise:F,onRemove:C,disabled:u},F.uuid))})]})]})]})})});Qi.displayName="PassFailFieldInput";const Ri=i=>typeof i=="string"&&Ne.includes(i),ot=i=>!(i===null||typeof i!="object"||!("status"in i)||!Ri(i.status)||!("notes"in i)||typeof i.notes!="string"||!("files"in i)||!(Array.isArray(i.files)&&i.files.length===0)),at=i=>!(i===null||typeof i!="object"||!("status"in i)||!Ri(i.status)||!("notes"in i)||typeof i.notes!="string"||!("files"in i)||!rt(i.files)),lt=i=>({status:i.status,notes:i.notes,files:[]}),st=i=>({status:i.status,notes:i.notes,files:[]}),dt=(i,e)=>!(i.status!==e.status||i.notes!==e.notes||!hi(i.files,e.files)),ct=(i,e)=>!(i.status!==e.status||i.notes!==e.notes||i.files.length!==e.files.length);class ge extends k{type="pass-fail";showNotesAndFilesOn;constructor(e){const{showNotesAndFilesOn:t,...r}=e;super(r),this.showNotesAndFilesOn=t}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new ie({identifier:`${t}showNotesAndFilesOn`,label:"Show notes and files on",description:"Show the notes and files on desired statuses.",options:Ne.map(r=>{const{label:a}=fe[r];return{value:r,label:a}}),required:!1}),showDirectly:!1}]}serialize(){return{...super.serialize(),showNotesAndFilesOn:this.showNotesAndFilesOn}}getOptions(){return{...super.getOptions(),showNotesAndFilesOn:this.showNotesAndFilesOn}}duplicate(e){return new ge({...this.getOptions(),identifier:e})}setOptions(e){const{showNotesAndFilesOn:t,...r}=e;this.showNotesAndFilesOn=t??this.showNotesAndFilesOn,super.setOptions(r)}getFieldValidators(){const e=super.getFieldValidators(),t=this.showNotesAndFilesOn,r=this.blankValue();return t.length>0&&(e.push(a=>{if(!(!a.status||!t.includes(a.status))&&r.notes===a.notes)return"Notes is required."}),e.push(a=>{if(!(!a.status||!t.includes(a.status))&&hi(r.files,a.files))return"Files is required."})),e}static deserialize(e){return new ge({...e,showNotesAndFilesOn:e.showNotesAndFilesOn??!1})}serializeValue(e){return lt(e)}deserializeValue(e){return st(e)}render(){return n.jsx(Qi,{field:this})}isSerializedValue(e){return ot(e)}isValue(e){return at(e)}areValuesEqual(e,t){return dt(e,t)}blankValue(){return{status:null,notes:"",files:[]}}cleanValue(e){return e.status&&this.showNotesAndFilesOn.includes(e.status)?e:{status:e.status,notes:"",files:[]}}cleanSerializedValue(e){return super.cleanSerializedValue(e)}blankSerializedValue(){return{status:null,notes:"",files:[]}}areSerializedValuesEqual(e,t){return ct(e,t)}}const en=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(m=>{s(m),l()},[l,s]),p=d.useCallback(()=>{l()},[l]),g=d.useCallback(()=>{s(null),l()},[l,s]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs(o.RadioGroup.Root,{id:e.identifier,name:a,className:"flex flex-col gap-1",accentColor:"base",variant:"surface",size:t,value:r??"",onValueChange:f,disabled:u,children:[e.options.map((m,C)=>n.jsxs("label",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(o.RadioGroup.Item,{value:m.value,onBlur:p,children:n.jsx(o.RadioGroup.Indicator,{children:n.jsx(o.LuIcon,{icon:Hn,className:"fill-current"})})}),n.jsx(o.Text,{size:t,accentColor:"base",className:"truncate",children:m.label})]},`${e.identifier}-${m.value}-${C}`)),!!r&&n.jsxs(o.Button,{onClick:g,className:"-mx-2 w-max",type:"button",variant:"ghost",accentColor:"base",size:t,children:[n.jsx(o.LuIcon,{icon:ne}),"Clear"]})]})})});en.displayName="RadioFieldInput";class me extends $e{type="radio";constructor(e){super(e)}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new me({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){return new me(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(en,{field:this})}isSerializedValue(e){return typeof e!="string"&&e!==null?!1:new Set([null,...this.options.map(({value:r})=>r)]).has(e)}isValue(e){return this.isSerializedValue(e)}blankValue(){return null}areValuesEqual(e,t){return e===t}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}}const $o=Q.cva(["group flex cursor-pointer items-center justify-center text-yellow-500 transition-colors disabled:pointer-events-none disabled:opacity-50"],{variants:{size:{xs:["size-5"],sm:["size-6"],md:["size-7"],lg:["size-8"],xl:["size-9"]}}}),nn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(m=>{s(m),l()},[l,s]),p=d.useCallback(()=>{s(null),l()},[l,s]),g=Array.from({length:e.maxRating},(m,C)=>C+1);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs("div",{className:"flex flex-row items-center gap-1",children:[n.jsx(o.Rating.Root,{id:e.identifier,name:a,className:"flex items-center gap-0.5",value:r,onValueChange:f,disabled:u,children:g.map(m=>n.jsx(o.Rating.Item,{value:m,className:$o({size:t}),children:n.jsx(o.LuIcon,{icon:et,className:"size-full group-data-[active=true]:fill-current"})},`${e.identifier}-${m}`))}),!u&&r!==null&&n.jsx(o.IconButton,{onClick:p,type:"button",variant:"ghost",accentColor:"base",size:t,children:n.jsx(o.LuIcon,{icon:ne})})]})})});nn.displayName="RatingFieldInput";class Ce extends k{type="rating";maxRating;constructor(e){const{maxRating:t,...r}=e;super(r),this.maxRating=t}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new H({label:"Max Rating",description:"Maximum rating value",integers:!0,required:!1,minimum:1,maximum:10,identifier:`${t}maxRating`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),t=this.maxRating;return e.push(r=>{if(typeof r=="number"&&(r<1||r>t))return`Rating must be between 1 and ${t}.`}),e}serialize(){return{...super.serialize(),maxRating:this.maxRating}}getOptions(){return{...super.getOptions(),maxRating:this.maxRating}}duplicate(e){return new Ce({...this.getOptions(),identifier:e})}setOptions(e){const{maxRating:t,...r}=e;this.maxRating=t??this.maxRating,super.setOptions(r)}static deserialize(e){return new Ce(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(nn,{field:this})}isSerializedValue(e){return this.isValue(e)}isValue(e){return typeof e=="number"&&!isNaN(e)||e===null}areValuesEqual(e,t){return e===t}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}}const tn=d.createContext(null),ut=()=>{const i=d.use(tn);if(!i)throw new Error("useScannerContext must be used within a component tree wrapped by ScannerProvider.");return i},Do=()=>{const i=d.use(tn);if(!i)throw new Error("useScanner must be used within a component tree wrapped by ScannerProvider.");return i.openScanner},fi=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:a,modal:l,...s}=i;return n.jsxs(o.Overlay.Root,{open:t,onOpenChange:r,defaultOpen:a,modal:l,children:[!!e&&n.jsx(o.Overlay.Trigger,{asChild:!0,children:e}),n.jsxs(o.Overlay.Content,{children:[n.jsx(o.Overlay.Title,{className:"sr-only",children:"Scanner"}),n.jsx(o.Overlay.Description,{className:"sr-only",children:"Scan a barcode or a qr code."}),n.jsx(ht,{...s})]})]})});fi.displayName="Scanner";const ht=d.memo(i=>{const{paused:e,formats:t,timeBetweenDecodingAttempts:r,trySkew:a,onDecodeResult:l,onDecodeError:s,onError:h}=i,{wasmUrl:u}=ut(),{ref:f}=io.useZxing({wasmUrl:u,paused:e,formats:t,timeBetweenDecodingAttempts:r,trySkew:a,onDecodeResult:l,onDecodeError:s,onError:h,constraints:{video:{width:{ideal:1920,min:1280},height:{ideal:1080,min:720},aspectRatio:{ideal:16/9},facingMode:"environment"}}});return n.jsxs("div",{className:"bg-(--color-background) flex size-full flex-col justify-center overflow-hidden",children:[n.jsx("div",{className:"flex w-full justify-end p-4",children:n.jsx(o.Overlay.Close,{asChild:!0,children:n.jsx(o.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",children:n.jsx(o.LuIcon,{icon:ne})})})}),n.jsx("div",{className:"max-h-full w-full grow overflow-hidden p-4",children:n.jsx("video",{className:"size-full",ref:f,muted:!0,playsInline:!0})})]})});ht.displayName="ScannerInternal";const ft=d.memo(i=>{const{children:e,wasmUrl:t}=i,[r,a]=d.useState(null),l=d.useCallback(()=>{a(null)},[]),s=d.useCallback(f=>{a(f(l))},[l]),h=d.useCallback(()=>{r&&(r.onClose&&r.onClose(),l())},[l,r]),u=d.useMemo(()=>({wasmUrl:t,openScanner:s}),[t,s]);return n.jsxs(tn,{value:u,children:[e,r&&n.jsx(fi,{open:!0,onOpenChange:h,...r})]})});ft.displayName="ScannerProvider";const rn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),[f,p]=d.useState(!1),g=d.useCallback(S=>{const z=S.target.value;s(z)},[s]),m=d.useCallback(()=>{l()},[l]),C=d.useCallback(S=>{s(S.rawValue.trim()),l(),p(!1)},[s,l]),v=d.useCallback(()=>{p(!0)},[]),y=d.useCallback(()=>{p(!1),l()},[l]);return n.jsxs(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:[n.jsx(o.TextArea,{className:"field-sizing-content w-full",accentColor:"base",variant:"surface",size:t,id:e.identifier,name:a,value:r??"",placeholder:"Enter a qr or barcode",onChange:g,onBlur:m,disabled:u}),n.jsxs(o.Button,{onClick:v,className:"w-max",type:"button",variant:"soft",size:t,accentColor:"base",disabled:u,children:[n.jsx(o.LuIcon,{icon:Io}),"Scan"]}),n.jsx(fi,{open:f,onDecodeResult:C,onOpenChange:y})]})});rn.displayName="ScanFieldInput";class Me extends k{type="qr";constructor(e){super(e)}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new Me({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){return new Me(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(rn,{field:this})}isSerializedValue(e){return typeof e=="string"}isValue(e){return typeof e=="string"}blankValue(){return""}areValuesEqual(e,t){return e===t}blankSerializedValue(){return""}areSerializedValuesEqual(e,t){return e===t}}const on=500,an=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(m=>{const C=m.target.value;s(C)},[s]),p=d.useCallback(()=>{l()},[l]),g=d.useCallback(m=>{m.key==="Enter"&&m.preventDefault()},[]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsx(o.Input.Root,{accentColor:"base",variant:"surface",size:t,children:n.jsx(o.Input.Field,{id:e.identifier,className:"truncate",name:a,value:r??"",type:"text",placeholder:e.placeholder,onChange:f,onBlur:p,disabled:u,onKeyDown:g})})})});an.displayName="StringFieldInput";class Ve extends Ui{type="string";constructor(e){const{...t}=e,r=e.maxLength?Math.min(on,e.maxLength):on,a=e.minLength?Math.min(e.minLength,r):void 0;super({...t,maxLength:r,minLength:a})}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new Ve({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){const{maximum_length:t,minimum_length:r,...a}=e;return new Ve({...a,maxLength:t,minLength:r,placeholder:"Enter a short description"})}render(){return n.jsx(an,{field:this})}}const ln=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(g=>{const m=g.target.value;s(m)},[s]),p=d.useCallback(()=>{l()},[l]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsx(o.TextArea,{id:e.identifier,value:r??"",name:a,onChange:f,onBlur:p,className:"field-sizing-content min-h-12",placeholder:e.placeholder,resize:"vertical",accentColor:"base",variant:"surface",size:t,disabled:u})})});ln.displayName="TextFieldInput";class ye extends Ui{type="text";constructor(e){const t=e.maxLength?Math.min(De,e.maxLength):De,r=e.minLength?Math.min(e.minLength,t):void 0;super({...e,maxLength:t,minLength:r})}serialize(){return super.serialize()}getOptions(){return super.getOptions()}duplicate(e){return new ye({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}static deserialize(e){const{maximum_length:t,minimum_length:r,...a}=e;return new ye({...a,maxLength:t,minLength:r,placeholder:"Enter a description"})}render(){return n.jsx(ln,{field:this})}}const sn=Po(),pt=new Set(sn);function Po(i=!0){const e=new Set;for(let t=-12;t<=14;t++){const r=t>=0?"+":"-",a=Math.abs(t).toString().padStart(2,"0");e.add(`${r}${a}:00`)}if(i){const t=[-12.5,-9.5,-3.5,3.5,4.5,5.5,6.5,9.5,10.5,12.5];for(const r of t){const a=r>=0?"+":"-",l=Math.floor(Math.abs(r)).toString().padStart(2,"0");e.add(`${a}${l}:30`)}}return Array.from(e).sort((t,r)=>gt(t)-gt(r))}function gt(i){const e=i[0]==="+"?1:-1,t=Number(i.slice(1,3)),r=Number(i.slice(4,6));return e*(t*60+r)}const jo="+00:00",Uo=/^T([01]\d|2[0-3]):([0-5]\d):00([+-]\d{2}:\d{2})$/,pi=i=>typeof i=="string"&&pt.has(i),mt=()=>{const i=-new Date().getTimezoneOffset(),e=i>=0?"+":"-",t=Math.abs(i),r=Math.floor(t/60),a=t%60,l=`${e}${r.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`;return pi(l)?l:jo};function Ct(i){const e=/^([+-])(\d{2}):(\d{2})$/.exec(i);if(!e)throw new Error(`Invalid UTC offset: ${i}`);return(e[1]==="+"?1:-1)*(Number(e[2])*60+Number(e[3]))}const Pe=i=>{const e=Uo.exec(i);if(!e)return null;const t=e[3];return pi(t)?{hours:Number(e[1]),minutes:Number(e[2]),utcOffset:t}:null},A=i=>typeof i=="string"&&Pe(i)!==null,dn=(i,e,t=mt())=>{if(!Number.isInteger(i)||i<0||i>23)throw new Error(`Invalid hour: ${i}`);if(!Number.isInteger(e)||e<0||e>59)throw new Error(`Invalid minute: ${e}`);if(!pi(t))throw new Error("Unsupported UTC offset");const r=i.toString().padStart(2,"0"),a=e.toString().padStart(2,"0");return`T${r}:${a}:00${t}`},gi=i=>`UTC${i}`,oe=i=>{const e=Pe(i);if(!e)throw new Error(`Invalid time value: ${i}`);return(e.hours*60+e.minutes-Ct(e.utcOffset)+1440)%1440},mi=(i,e=!0)=>{const t=Pe(i);if(!t)throw new Error(`Invalid time value: ${i}`);const r=(t.hours%12||12).toString().padStart(2,"0"),a=t.minutes.toString().padStart(2,"0"),l=t.hours>=12?"PM":"AM",s=`${r}:${a} ${l}`;return e?`${s} ${gi(t.utcOffset)}`:s},je=i=>typeof i=="object"&&(A(i.from)||A(i.to)),cn=(i,e)=>{const t=oe(i),r=e.from?oe(e.from):null,a=e.to?oe(e.to):null;return r===null&&a===null?!0:r===null?t<=a:a===null?t>=r:r<=a?t>=r&&t<=a:t>=r||t<=a},Ci=d.memo(i=>{const{value:e,onChange:t,onBlur:r,disabled:a,size:l="md",id:s,name:h,compact:u=!1}=i,f=e?Pe(e):null,p=f?`${f.hours.toString().padStart(2,"0")}:${f.minutes.toString().padStart(2,"0")}`:"",g=d.useCallback(v=>{const y=v.target.value;if(!y){t(null);return}const[S,z]=y.split(":").map(Number);t(dn(S,z,f?.utcOffset))},[t,f?.utcOffset]),m=d.useCallback(v=>{f&&(t(dn(f.hours,f.minutes,v)),r?.())},[r,t,f]),C=d.useCallback(v=>{v||r?.()},[r]);return n.jsxs("div",{className:"flex min-w-0 gap-2",children:[n.jsx(o.Input.Root,{className:"min-w-0 grow",accentColor:"base",variant:"surface",size:l,children:n.jsx(o.Input.Field,{id:s,name:h,className:Q.cx("[&::-webkit-calendar-picker-indicator]:invert-40 dark:[&::-webkit-calendar-picker-indicator]:invert-60",{"[&::-webkit-datetime-edit]:opacity-60":!e}),type:"time",step:60,value:p,onChange:g,onBlur:r,disabled:a})}),n.jsxs(o.Menu.Root,{align:"end",onOpenChange:C,children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsxs(o.Button,{type:"button",className:u?"!justify-between":"min-w-32 !justify-between",accentColor:"base",variant:"surface",size:l,disabled:a||!f,children:[n.jsx(o.Text,{className:"truncate",highContrast:!!f,children:f?gi(f.utcOffset):"UTC offset"}),n.jsx(o.LuIcon,{icon:si})]})}),n.jsx(o.Menu.Content,{size:l,children:n.jsx(o.Menu.Scroll,{children:n.jsx(o.Menu.SelectGroup,{required:!0,value:f?.utcOffset,onValueChange:m,children:sn.map(v=>n.jsxs(o.Menu.SelectItem,{value:v,children:[n.jsx(o.Menu.SelectedIndicator,{children:n.jsx(o.LuIcon,{icon:J})}),gi(v)]},v))})})})]})]})});Ci.displayName="TimeFieldControl";const un=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e});return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsx(Ci,{id:e.identifier,name:a,size:t,value:r,onChange:s,onBlur:l,disabled:u})})});un.displayName="TimeFieldInput";class xe extends k{type="time";constructor(e){super(e)}static deserialize(e){return new xe(e)}getOptions(){return super.getOptions()}duplicate(e){return new xe({...this.getOptions(),identifier:e})}setOptions(e){super.setOptions(e)}serializeValue(e){return e}deserializeValue(e){return e}render(){return n.jsx(un,{field:this})}isSerializedValue(e){return e===null||A(e)}isValue(e){return e===null||A(e)}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}areValuesEqual(e,t){return e===t}}const hn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useRef(null),p=d.useCallback(()=>{f.current?.click()},[]),g=d.useCallback(()=>{if(!f.current)return;const S=f.current.files;if(!S){l();return}const z=Array.from(S).map(I=>re.from(b.v4(),I)),x=[...r,...z];s(x),l()},[l,s,r]),m=d.useCallback(S=>{const z=r.filter(({uuid:x})=>x!==S.uuid);s(z),l()},[r,s,l]);d.useEffect(()=>{if(!f.current)return;const S=new AbortController;return f.current.addEventListener("cancel",()=>{l()},{signal:S.signal}),()=>{S.abort()}},[l,r]);const y=e.maxFiles>1?"Select files":"Select a file";return n.jsxs(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:[n.jsxs(o.Button,{className:"w-max",size:t,variant:"surface",accentColor:"base",onClick:p,type:"button",disabled:u,children:[n.jsx(o.LuIcon,{icon:Li}),y]}),n.jsx("input",{id:e.identifier,name:a,type:"file",ref:f,accept:e.extensions?.join(","),multiple:e.maxFiles>1,className:"hidden",onChange:g,value:""}),r.length>0&&n.jsx("div",{className:"mt-1 flex h-max flex-col gap-2",children:r.map(S=>n.jsx(Zi,{size:t,fileOrPromise:S,onRemove:m,disabled:u},S.uuid))})]})});hn.displayName="UploadFieldInput";class ve extends k{type="upload";extensions;maxFileSize;maxFiles;constructor(e){const{extensions:t,maximum_files:r,maximum_size:a,...l}=e;super(l),this.maxFileSize=typeof a=="number"?a:void 0,this.maxFiles=Math.max(typeof r=="number"?r:1,1),this.extensions=t}static getFieldCreationSchema(e=""){const t=e&&`${e}.`;return[{field:new H({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:1,maximum:10,identifier:`${t}maximum_files`,integers:!0}),showDirectly:!1},{field:new H({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${qe}MB).`,required:!1,identifier:`${t}maximum_size`,minimum:1,maximum:qe,integers:!0}),showDirectly:!1},{field:new ie({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,identifier:`${t}extensions`,options:[{value:"image/*",label:"Images"},{value:"audio/*",label:"Audio files"},{value:"video/*",label:"Videos"},{value:"text/*",label:"Text files"},{value:"application/*",label:"Application files (includes PDFs and Word documents)"}]}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),t=this.maxFileSize??qe,r=t*1e3*1e3,a=this.maxFiles||1;return e.push(l=>{if(l.some(s=>s instanceof re&&s.size>r))return`Files must be at most ${t}MB.`}),e.push(l=>{if(l.length>a)return`You can only upload ${a} files.`}),e}serialize(){return{...super.serialize(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}getOptions(){return{...super.getOptions(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}duplicate(e){return new ve({...this.getOptions(),identifier:e})}setOptions(e){const{extensions:t,maximum_files:r,maximum_size:a,...l}=e;this.maxFileSize=typeof a=="number"?a:this.maxFileSize,this.maxFiles=typeof r=="number"?r:this.maxFiles,this.extensions=t,super.setOptions(l)}static deserialize(e){return new ve(e)}serializeValue(e){return[]}deserializeValue(e){return[]}render(){return n.jsx(hn,{field:this})}isSerializedValue(e){return Array.isArray(e)&&e.length===0}isValue(e){return Array.isArray(e)?e.every(t=>t instanceof pe||t instanceof re):!1}areValuesEqual(e,t){return hi(e,t)}blankValue(){return[]}blankSerializedValue(){return[]}areSerializedValuesEqual(e,t){return e.length===t.length}}const fn=d.memo(i=>{const{field:e}=i,{size:t}=d.use(L),{value:r,name:a,onBlur:l,onChange:s,error:h,disabled:u}=D({field:e}),f=d.useCallback(C=>{const v=C.target.value;v!==""&&!URL.canParse(v)||s(v!==""?new URL(v):null)},[s]),p=d.useCallback(()=>{l()},[l]),g=d.useCallback(C=>{C.key==="Enter"&&C.preventDefault()},[]),m=d.useCallback(()=>{r!==null&&window.open(r,"_blank","noopener,noreferrer")},[r]);return n.jsx(B,{size:t,inputId:e.identifier,label:e.label,description:e.description,required:e.required,error:h,image:e.image,children:n.jsxs("div",{className:"flex w-full gap-2",children:[n.jsx(o.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:t,children:n.jsx(o.Input.Field,{id:e.identifier,className:"truncate",name:a,value:r?r.toString():"",type:"url",inputMode:"url",placeholder:e.placeholder,onChange:f,onBlur:p,disabled:u,onKeyDown:g})}),n.jsx(o.IconButton,{size:t,variant:"soft",accentColor:"base",type:"button",disabled:r===null,onClick:m,children:n.jsx(o.LuIcon,{icon:So})})]})})});fn.displayName="URLFieldInput";class Ie extends k{type="url";placeholder;constructor(e){const{placeholder:t="https://example.com",...r}=e;super(r),this.placeholder=t}serialize(){return{...super.serialize(),placeholder:this.placeholder}}getOptions(){return{...super.getOptions(),placeholder:this.placeholder}}duplicate(e){return new Ie({...this.getOptions(),identifier:e})}setOptions(e){const{placeholder:t,...r}=e;this.placeholder=t??this.placeholder,super.setOptions(r)}static deserialize(e){return new Ie(e)}serializeValue(e){return e?.toString()??null}deserializeValue(e){return e===null?null:new URL(e)}isSerializedValue(e){return e===null?!0:typeof e!="string"?!1:URL.canParse(e)}isValue(e){return e===null||e instanceof URL}blankValue(){return null}blankSerializedValue(){return null}areSerializedValuesEqual(e,t){return e===t}areValuesEqual(e,t){return e?.toString()===t?.toString()}render(){return n.jsx(fn,{field:this})}}const pn={date:be,time:xe,number:H,boolean:ce,select:te,string:Ve,url:Ie,text:ye,upload:ve,qr:Me,"multi-string":de,"multi-select":ie,radio:me,"checkbox-list":ue,"pass-fail":ge,otp:he,rating:Ce},Vt=Object.keys(pn),_={"checkbox-list":{description:"Allows the user to select a multiple options from a list.",group:q.Selection,icon:vo,name:"Checkbox list"},"multi-select":{description:"Allows the user to select a multiple options from a list of options.",group:q.Selection,icon:No,name:"Multi-select"},"multi-string":{description:"Allows the user to provide multiple unique strings.",group:q.Text,icon:xo,name:"Multi-string"},"pass-fail":{description:"Track pass, fail, or N/A outcome.",group:q.Assessment,icon:yo,name:"Pass - Fail"},boolean:{description:"Perfect for both optional and required yes/no questions.",group:q.Selection,icon:To,name:"Checkbox"},date:{description:"Allows specifying a date.",group:q.Temporal,icon:po,name:"Date"},time:{description:"Allows specifying a time and UTC offset.",group:q.Temporal,icon:Ao,name:"Time"},number:{description:"Allows specifying a number within a given range.",group:q.Numeric,icon:wo,name:"Number"},otp:{description:"Allows specifying a number within a given range.",group:q.Verification,icon:qo,name:"OTP"},qr:{description:"Used for scanning/reading QR and barcodes.",group:q.Capture,icon:Oo,name:"Scan"},radio:{description:"Allows the user to select a single option from a list of options.",group:q.Selection,icon:mo,name:"Option list"},rating:{description:"Allows users to select a rating value.",group:q.Assessment,icon:et,name:"Rating"},select:{description:"Allows the user to select a single option from a list of options.",group:q.Selection,icon:Mo,name:"Dropdown"},string:{description:"Short text fields can hold up to 500 characters on a single line.",group:q.Text,icon:Bo,name:"Short Text"},text:{description:"Paragraph fields can hold up to 10000 characters and can have multiple lines.",group:q.Text,icon:uo,name:"Paragraph"},upload:{description:"Allows a file to be uploaded.",group:q.Capture,icon:Li,name:"Upload"},url:{description:"Allows users to enter a URL.",group:q.Text,icon:bo,name:"URL"}},yt={[q.Assessment]:{name:"Assessment"},[q.Capture]:{name:"Capture"},[q.Numeric]:{name:"Numeric"},[q.Selection]:{name:"Selection"},[q.Temporal]:{name:"Temporal"},[q.Text]:{name:"Text"},[q.Verification]:{name:"Verification"}},qe=50,vt=qe*1e3,St=vt*1e3,E="Unlabelled",gn="Unlabelled";class M{id;label;getApplyFn;serialize;deserialize;constructor(e){const{id:t,getApplyFn:r,label:a,serialize:l,deserialize:s}=e;this.id=t,this.getApplyFn=r,this.label=a,this.serialize=l,this.deserialize=s}static create(e){return new M(e)}}const zt=M.create({id:"nullable-boolean-equals",label:"is",getApplyFn:i=>e=>e===i,serialize:i=>i,deserialize:i=>i}),Ft=M.create({id:"nullable-boolean-not-equals",label:"is not",getApplyFn:i=>e=>e!==i,serialize:i=>i,deserialize:i=>i}),wt=M.create({id:"date-equals",getApplyFn:i=>e=>e.getTime()===i.getTime(),label:"is",serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),bt=M.create({id:"date-not-equals",getApplyFn:i=>e=>e.getTime()!==i.getTime(),label:"is not",serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),Nt=M.create({id:"date-before",getApplyFn:i=>e=>e.getTime()<i.getTime(),label:"before",serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),Mt=M.create({id:"date-after",label:"after",getApplyFn:i=>e=>e.getTime()>i.getTime(),serialize:i=>i.toISOString(),deserialize:i=>new Date(i)}),xt=M.create({id:"date-range-in",label:"in between",getApplyFn:i=>e=>!(i?.from&&i.from.getTime()>e.getTime()||i?.to&&i.to.getTime()<e.getTime()),serialize:i=>({from:i.from?.toISOString()??null,to:i.to?.toISOString()??null}),deserialize:i=>({from:i.from?new Date(i.from):void 0,to:i.to?new Date(i.to):void 0})}),It=M.create({id:"date-range-not-in",label:"not in between",getApplyFn:i=>e=>!!(i?.from&&i.from.getTime()>e.getTime()||i?.to&&i.to.getTime()<e.getTime()),serialize:i=>({from:i.from?.toISOString()??null,to:i.to?.toISOString()??null}),deserialize:i=>({from:i.from?new Date(i.from):void 0,to:i.to?new Date(i.to):void 0})}),qt=M.create({id:"has-files",label:"is",getApplyFn:i=>e=>e.length>0,serialize:i=>i,deserialize:i=>i}),Ot=M.create({id:"does-not-have-files",label:"is not",getApplyFn:i=>e=>e.length===0,serialize:i=>i,deserialize:i=>i}),mn=M.create({id:"number-equals",getApplyFn:i=>e=>e===i,label:"is",serialize:i=>i,deserialize:i=>i}),Cn=M.create({id:"number-not-equals",getApplyFn:i=>e=>e!==i,label:"is not",serialize:i=>i,deserialize:i=>i}),Vn=M.create({id:"number-less-than",getApplyFn:i=>e=>e<i,label:"is less than",serialize:i=>i,deserialize:i=>i}),yn=M.create({id:"number-less-than-or-equals",getApplyFn:i=>e=>e<=i,label:"is less than or equal to",serialize:i=>i,deserialize:i=>i}),vn=M.create({id:"number-greater-than",getApplyFn:i=>e=>e>i,label:"is greater than",serialize:i=>i,deserialize:i=>i}),Sn=M.create({id:"number-greater-than-or-equals",getApplyFn:i=>e=>e>=i,label:"is greater than or equal to",serialize:i=>i,deserialize:i=>i}),zn=M.create({id:"number-range-in",getApplyFn:i=>e=>!(i.to&&e>i.to||i.from&&e<i.from),label:"is between",serialize:i=>i,deserialize:i=>i}),Fn=M.create({id:"number-range-not-in",getApplyFn:i=>e=>!!(i.to&&e>i.to||i.from&&e<i.from),label:"is not between",serialize:i=>i,deserialize:i=>i}),_t=M.create({id:"pass-fail-equals",getApplyFn:i=>e=>e===i,label:"is",serialize:i=>i,deserialize:i=>i}),Tt=M.create({id:"pass-fail-not-equals",getApplyFn:i=>e=>e!==i,label:"is not",serialize:i=>i,deserialize:i=>i}),Lt=M.create({id:"pass-fail-array-includes",getApplyFn:i=>{const e=new Set(i);return t=>e.has(t)},label:"is any of",serialize:i=>i,deserialize:i=>i}),Bt=M.create({id:"pass-fail-array-excludes",getApplyFn:i=>{const e=new Set(i);return t=>!e.has(t)},label:"is none of",serialize:i=>i,deserialize:i=>i}),ae=M.create({id:"nullable-string-equals",getApplyFn:i=>e=>e===i,label:"is",serialize:i=>i,deserialize:i=>i}),le=M.create({id:"nullable-string-not-equals",getApplyFn:i=>e=>e!==i,label:"is not",serialize:i=>i,deserialize:i=>i}),Oe=M.create({id:"string-includes",getApplyFn:i=>e=>e.includes(i),label:"includes",serialize:i=>i,deserialize:i=>i}),_e=M.create({id:"string-excludes",getApplyFn:i=>e=>!e.includes(i),label:"does not include",serialize:i=>i,deserialize:i=>i}),wn=M.create({id:"string-array-includes",getApplyFn:i=>{const e=new Set(i);return t=>e.has(t)},label:"is any of",serialize:i=>i,deserialize:i=>i}),bn=M.create({id:"string-array-excludes",getApplyFn:i=>{const e=new Set(i);return t=>!e.has(t)},label:"is none of",serialize:i=>i,deserialize:i=>i}),Vi=M.create({id:"string-array-every",getApplyFn:i=>{const e=new Set(i);return t=>{const r=new Set(t);return e.isSubsetOf(r)}},label:"has all of",serialize:i=>i,deserialize:i=>i}),yi=M.create({id:"string-array-some",getApplyFn:i=>{const e=new Set(i);return t=>{const r=new Set(t);return!e.isDisjointFrom(r)}},label:"has any of",serialize:i=>i,deserialize:i=>i}),vi=M.create({id:"string-array-none",getApplyFn:i=>{const e=new Set(i);return t=>{const r=new Set(t);return e.isDisjointFrom(r)}},label:"has none of",serialize:i=>i,deserialize:i=>i}),Si=M.create({id:"string-array-equals",getApplyFn:i=>{const e=new Set(i);return t=>{const r=new Set(t);return e.size===r.size&&r.isSubsetOf(e)}},label:"is",serialize:i=>i,deserialize:i=>i}),zi=M.create({id:"string-array-not-equals",getApplyFn:i=>{const e=new Set(i);return t=>{const r=new Set(t);return e.size!==r.size||!r.isSubsetOf(e)}},label:"is not",serialize:i=>i,deserialize:i=>i}),At=M.create({id:"time-equals",label:"is",getApplyFn:i=>e=>e===i,serialize:i=>i,deserialize:i=>i}),Et=M.create({id:"time-not-equals",label:"is not",getApplyFn:i=>e=>e!==i,serialize:i=>i,deserialize:i=>i}),$t=M.create({id:"time-before",label:"before",getApplyFn:i=>e=>oe(e)<oe(i),serialize:i=>i,deserialize:i=>i}),Dt=M.create({id:"time-after",label:"after",getApplyFn:i=>e=>oe(e)>oe(i),serialize:i=>i,deserialize:i=>i}),Pt=M.create({id:"time-range-in",label:"in between",getApplyFn:i=>e=>cn(e,i),serialize:i=>i,deserialize:i=>i}),jt=M.create({id:"time-range-not-in",label:"not in between",getApplyFn:i=>e=>!cn(e,i),serialize:i=>i,deserialize:i=>i}),V=i=>i;class P extends Ee{id;conditionValue;conditionModifier;field;constructor(e){const{id:t,field:r,conditionValue:a,conditionModifier:l}=e;super(),this.id=t,this.field=r,this.conditionValue=a,this.conditionModifier=l}serialize(){return{id:this.id,type:this.field.type,fieldId:this.field.identifier,conditionValue:this.conditionValue!==void 0?this.modifiers[this.conditionModifier].modifier.serialize(this.conditionValue):void 0,conditionModifier:this.conditionModifier}}getConditionValue=()=>this.conditionValue;transformValue(e){return e}setConditionValue=e=>{const t=this.modifiers[this.conditionModifier];e!==void 0&&!t.isConditionValueValid(e)||(this.conditionValue=e,this.notify(this))};getConditionModifier=()=>this.conditionModifier;setConditionModifier=e=>{const t=this.modifiers[e],r=this.getConditionValue();r&&!t.isConditionValueValid(r)&&(this.conditionValue=void 0),this.conditionModifier=e,this.notify(this)};getConditionModifiers=()=>Object.entries(this.modifiers);accessorFn=e=>e[this.field.identifier];getApplyFn=()=>{const e=this.modifiers[this.conditionModifier],t=this.getConditionValue(),r=t!==void 0&&e.isConditionValueValid(t),a=r?e.modifier.getApplyFn(t):null;return l=>{if(!r)return!0;const s=this.transformValue(l);return e.isValueValid(s)?a(s):!1}}}const Ut=d.memo,Se=Ut(function(i){const{ref:e,children:t,...r}=i,a=d.useCallback(l=>typeof t=="function"?n.jsxs(n.Fragment,{children:[t(l),n.jsx(o.Menu.SelectedIndicator,{className:"ml-[auto]",children:n.jsx(o.LuIcon,{icon:J})})]}):n.jsxs(n.Fragment,{children:[t,n.jsx(o.Menu.SelectedIndicator,{className:"ml-[auto]",children:n.jsx(o.LuIcon,{icon:J})})]}),[t]);return n.jsx(o.Menu.SelectItem,{ref:e,...r,children:a})}),Gt=Ut(function(i){const{ref:e,children:t,...r}=i,a=d.useCallback(l=>typeof t=="function"?n.jsxs(n.Fragment,{children:[t(l),n.jsx(o.Menu.SelectedIndicator,{className:"ml-auto",children:n.jsx(o.LuIcon,{icon:J})})]}):n.jsxs(n.Fragment,{children:[t,n.jsx(o.Menu.SelectedIndicator,{className:"ml-auto",children:n.jsx(o.LuIcon,{icon:J})})]}),[t]);return n.jsx(o.Menu.MultiSelectItem,{ref:e,...r,children:a})}),Nn=d.memo(i=>{const{ref:e,children:t,...r}=i,a=d.useCallback(l=>typeof t=="function"?n.jsxs(n.Fragment,{children:[t(l),n.jsx(o.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:s=>s?n.jsx(o.LuIcon,{icon:di}):n.jsx(o.LuIcon,{icon:J})})]}):n.jsxs(n.Fragment,{children:[t,n.jsx(o.Menu.CheckboxItemIndicator,{className:"ml-[auto]",children:s=>s?n.jsx(o.LuIcon,{icon:di}):n.jsx(o.LuIcon,{icon:J})})]}),[t]);return n.jsx(o.Menu.SelectAllItem,{ref:e,...r,children:a})});Nn.displayName="SelectAllItemTemplate";const U=i=>{const{children:e,condition:t,size:r="sm",variant:a,accentColor:l,radius:s}=i,h=d.useCallback(u=>{t.setConditionModifier(u)},[t]);return n.jsxs(o.Menu.Root,{align:"start",children:[n.jsx(o.Menu.ClickTrigger,{children:e}),n.jsx(o.Menu.Content,{size:r,variant:a,radius:s,accentColor:l,children:n.jsx(o.Menu.SelectGroup,{required:!0,value:t.getConditionModifier(),onValueChange:h,children:t.getConditionModifiers().map(([u,f])=>n.jsx(Se,{value:u,children:f.modifier.label},u))})})]})},Fi=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:a,modal:l,size:s,align:h,accentColor:u="base",...f}=i;return n.jsxs(o.Popover.Root,{open:t,onOpenChange:r,defaultOpen:a,modal:l,children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:e}),n.jsx(o.Popover.Content,{size:s,align:h,children:n.jsx(o.DayPicker,{size:s,accentColor:u,...f})})]})});Fi.displayName="DayPickerPopover";const kt=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:a,modal:l,size:s,accentColor:h="base",values:u,onValuesChange:f,placeholder:p="Enter text",...g}=i,[m,C]=d.useState(""),v=d.useCallback(x=>{C(x.target.value)},[]),y=d.useCallback(x=>{x.key==="Enter"&&(x.preventDefault(),x.stopPropagation(),f([...u,m]),C(""))},[m,f,u]),S=d.useCallback(()=>{f([...u,m]),C("")},[m,f,u]),z=d.useCallback(x=>{const I=[...u];I.splice(x,1),f(I)},[f,u]);return n.jsxs(o.Popover.Root,{open:t,onOpenChange:r,defaultOpen:a,modal:l,children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:e}),n.jsx(o.Popover.Content,{size:s,onClick:o.stopPropagation,accentColor:h,...g,children:n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{className:"flex gap-2",children:[n.jsx(o.Input.Root,{className:"grow",accentColor:"base",variant:"outline",size:"sm",children:n.jsx(o.Input.Field,{value:m,onChange:v,onKeyDown:y,placeholder:p,...g})}),n.jsx(o.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button",onClick:S,children:n.jsx(o.LuIcon,{icon:Z})})]}),u.length>0&&n.jsx("div",{className:"flex flex-col gap-1",children:u.map((x,I)=>n.jsxs(o.Badge,{className:"flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[n.jsx("span",{className:"truncate",children:x}),n.jsx(o.IconButton,{size:"xs",variant:"ghost",type:"button",accentColor:"base",onClick:()=>{z(I)},children:n.jsx(o.LuIcon,{icon:ne})})]},`${x}-${I}`))})]})})]})});kt.displayName="NumberInputPopover";const ze=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:a,modal:l,size:s,accentColor:h="base",value:u,onValueChange:f,placeholder:p="Enter a number",...g}=i,[m,C]=d.useState(null);d.useEffect(()=>{u!==void 0&&C(u)},[u]);const v=d.useCallback(S=>{const z=S.target.valueAsNumber;C(isNaN(z)?null:z)},[]),y=d.useCallback(S=>{const z=S.target.valueAsNumber;f?.(isNaN(z)?null:z)},[f]);return n.jsxs(o.Popover.Root,{open:t,onOpenChange:r,defaultOpen:a,modal:l,children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:e}),n.jsx(o.Popover.Content,{size:s,onClick:o.stopPropagation,...g,children:n.jsx(o.Input.Root,{size:s,accentColor:h,children:n.jsx(o.Input.Field,{placeholder:p,type:"number",value:m??"",onChange:v,onBlur:y})})})]})});ze.displayName="NumberInputPopover";const j=i=>{const{condition:e,onClick:t,...r}=i,a=d.useCallback(()=>{t(e)},[e,t]);return n.jsx(o.IconButton,{onClick:a,...r,children:n.jsx(o.LuIcon,{icon:ne})})};j.displayName="RemoveConditionButton";const Ue=d.memo(i=>{const{ref:e,selectFieldOptions:t,...r}=i,a=d.useMemo(()=>t.map(l=>typeof l=="string"?{value:l,label:l}:l),[t]);return n.jsxs(o.Menu.MultiSelectGroup,{ref:e,...r,children:[n.jsx(Nn,{children:"Select all"}),a.map(l=>n.jsx(Gt,{value:l.value,children:n.jsx("span",{className:"truncate",children:l.label})},l.value))]})});Ue.displayName="SelectFieldOptionMultiSelectGroup";const Mn=d.memo(i=>{const{ref:e,selectFieldOptions:t,...r}=i,a=d.useMemo(()=>t.map(l=>typeof l=="string"?{value:l,label:l}:l),[t]);return n.jsx(o.Menu.SelectGroup,{ref:e,...r,children:a.map(l=>n.jsx(Se,{value:l.value,children:n.jsx("span",{className:"truncate",children:l.label})},l.value))})});Mn.displayName="SelectFieldOptionSelectGroup";const Te=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:a,modal:l,size:s,accentColor:h="base",value:u,onValueChange:f,placeholder:p="Enter text",...g}=i,[m,C]=d.useState(""),v=d.useCallback(S=>{C(S.target.value)},[]),y=d.useCallback(S=>{const z=S.target.value;f?.(z)},[f]);return d.useEffect(()=>{u&&C(u)},[u]),n.jsxs(o.Popover.Root,{open:t,onOpenChange:r,defaultOpen:a,modal:l,children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:e}),n.jsx(o.Popover.Content,{size:s,onClick:o.stopPropagation,...g,children:n.jsx(o.Input.Root,{size:s,accentColor:h,children:n.jsx(o.Input.Field,{placeholder:p,type:"text",value:m,onChange:v,onBlur:y})})})]})});Te.displayName="TextInputPopover";const wi=d.memo(i=>{const{children:e,open:t,onOpenChange:r,defaultOpen:a,modal:l,size:s="sm",accentColor:h="base",value:u,onValueChange:f,...p}=i;return n.jsxs(o.Popover.Root,{open:t,onOpenChange:r,defaultOpen:a,modal:l,children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:e}),n.jsx(o.Popover.Content,{size:s,onClick:o.stopPropagation,accentColor:h,...p,children:n.jsx(Ci,{compact:!0,size:s,value:u,onChange:f})})]})});wi.displayName="TimeInputPopover";const Ht=i=>{const{condition:e,onRemove:t}=i,r=e.getConditionValue(),a=e.getConditionModifier(),l=()=>{switch(r){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[e.field.type].icon}),n.jsx("span",{className:"truncate",children:e.field.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[a].modifier.label})}),n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:l()})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsxs(o.Menu.SelectGroup,{required:!0,value:r,onValueChange:e.setConditionValue,children:[n.jsx(Se,{value:!0,children:"true"}),n.jsx(Se,{value:!1,children:"false"})]})})]}),n.jsx(j,{condition:e,onClick:t})]})},Jt={equals:V({modifier:zt,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:Ft,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Ge extends P{modifiers=Jt;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=Jt[a];let h;return r!==void 0&&(h=s.modifier.deserialize(r)),new Ge({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Ht,{condition:this,...e},this.id)}}const Le=[],Wt=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=d.useCallback(u=>{u.length>0?e.setConditionValue(u):e.setConditionValue(void 0)},[e]),h=()=>a===void 0?"...":a===null?"empty":a.length===0?"...":`${a.length} options`;return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"soft",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"soft",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"truncate",children:h()})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(Ue,{values:a??Le,selectFieldOptions:e.field.options,onValuesChange:s})})]}),n.jsx(j,{condition:e,onClick:t})]})},Xt={equals:V({modifier:Si,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:zi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),every:V({modifier:Vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),some:V({modifier:yi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),none:V({modifier:vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ke extends P{modifiers=Xt;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=Xt[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ke({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Wt,{condition:this,...e},this.id)}}class bi extends Ee{conditions;constructor(e){super(),this.conditions=this.initConditions(e)}conditionObserver=()=>{this.conditions=[...this.conditions],this.notify(this)};initConditions=e=>{for(const t of e)t.observe(this.conditionObserver);return e};getConditions(){return this.conditions}addCondition(e){this.conditions=this.initConditions([...this.conditions,e]),this.notify(this)}addConditions(e){this.conditions=this.initConditions([...this.conditions,...e]),this.notify(this)}removeCondition(e){this.conditions=this.initConditions(this.conditions.filter(t=>t.id!==e.id)),this.notify(this)}removeConditions(e){const t=new Set(e.map(r=>r.id));this.conditions=this.initConditions(this.conditions.filter(r=>!t.has(r.id))),this.notify(this)}applyConditions(e){return this.conditions.length===0?!0:this.conditions.map(r=>[r.getApplyFn(),r.accessorFn]).every(([r,a])=>r(a(e)))}}const Go=(i,e)=>d.useMemo(()=>{const t=new bi(i);return t.observe(r=>e(r.getConditions())),t},[i,e]),Kt=i=>{const{condition:e,onRemove:t}=i,r=e.getConditionValue(),a=e.getConditionModifier(),l=()=>{switch(a){case"equals":case"notEquals":{const s=e.modifiers.equals,h=r!==void 0&&s.isConditionValueValid(r)?r:void 0;return n.jsx(Fi,{required:!1,size:"sm",mode:"single",selected:h??void 0,onSelect:u=>e.setConditionValue(u),children:n.jsx(o.Button,{type:"button",className:"truncate",children:h!==void 0?h?.toLocaleDateString()??"empty":"..."})})}case"before":case"after":{const s=e.modifiers.after,h=r!==void 0&&s.isConditionValueValid(r)?r:void 0;return n.jsx(Fi,{required:!0,size:"sm",mode:"single",selected:h,onSelect:e.setConditionValue,children:n.jsx(o.Button,{type:"button",className:"truncate",children:h?h.toLocaleDateString():"..."})})}case"in":case"notIn":{const s=e.modifiers.in,h=r!==void 0&&s.isConditionValueValid(r)?r:void 0;return n.jsx(Fi,{required:!0,mode:"range",size:"sm",selected:h,onSelect:e.setConditionValue,children:n.jsx(o.Button,{className:"truncate",children:h?`${h.from?.toLocaleDateString()} - ${h.to?.toLocaleDateString()}`:"..."})})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[e.field.type].icon}),n.jsx("span",{className:"truncate",children:e.field.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[a].modifier.label})}),l(),n.jsx(j,{condition:e,onClick:t})]})},Yt={equals:V({modifier:wt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),notEquals:V({modifier:bt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),before:V({modifier:Nt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),after:V({modifier:Mt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>i instanceof Date,isSerializedValueValid:i=>typeof i=="string"}),in:V({modifier:xt,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>"to"in(i??{})&&"from"in(i??{}),isSerializedValueValid:i=>typeof i=="object"&&"to"in i&&"from"in i}),notIn:V({modifier:It,isValueValid:i=>i instanceof Date,isConditionValueValid:i=>"to"in(i??{})&&"from"in(i??{}),isSerializedValueValid:i=>typeof i=="object"&&"to"in i&&"from"in i})};class He extends P{modifiers=Yt;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=Yt[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new He({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Kt,{condition:this,...e},this.id)}}const Zt=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=d.useCallback(u=>{u.length>0?e.setConditionValue(u):e.setConditionValue(void 0)},[e]),h=()=>a===void 0?"...":a===null?"empty":a.length===0?"...":`${a.length} options`;return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"truncate",children:h()})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(Ue,{values:a??Le,selectFieldOptions:r.options,onValuesChange:s})})]}),n.jsx(j,{condition:e,onClick:t})]})},Qt={equals:V({modifier:Si,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:zi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),every:V({modifier:Vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),some:V({modifier:yi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),none:V({modifier:vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Je extends P{modifiers=Qt;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=Qt[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Je({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Zt,{condition:this,...e},this.id)}}const Rt=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=d.useCallback(u=>{e.setConditionValue(u.length>0?u:void 0)},[e]),h=()=>{if(a===void 0)return"...";if(a===null)return"empty";switch(a.length){case 0:return"...";case 1:return a[0].toString();default:return`${a.length} values`}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),n.jsx(kt,{values:a??Le,onValuesChange:s,children:n.jsx(o.Button,{type:"button",className:"truncate",children:h()})}),n.jsx(j,{condition:e,onClick:t})]})},er={equals:V({modifier:Si,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:zi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),every:V({modifier:Vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),some:V({modifier:yi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),none:V({modifier:vi,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class We extends P{modifiers=er;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=er[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new We({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Rt,{condition:this,...e},this.id)}}const ir=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=d.useCallback(u=>{e.setConditionValue(u??void 0)},[e]),h=()=>{switch(l){case"equals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const u=e.modifiers.greaterThan,f=a!==void 0&&u.isConditionValueValid(a)?a:void 0;return n.jsx(ze,{value:f??null,onValueChange:s,size:"sm",children:n.jsx(o.Button,{type:"button",className:"truncate",children:f!==void 0?f??"empty":"..."})})}case"inRange":case"notInRange":{const u=e.modifiers.inRange,f=a!==void 0&&u.isConditionValueValid(a)?a:void 0;return n.jsxs(n.Fragment,{children:[n.jsx(ze,{value:f?.from??null,onValueChange:p=>{e.setConditionValue({from:p,to:f?.to??null})},size:"sm",children:n.jsx(o.Button,{className:"truncate",children:f?.from??"..."})}),n.jsx(ze,{value:f?.to??null,onValueChange:p=>{e.setConditionValue({from:f?.from??null,to:p})},size:"sm",children:n.jsx(o.Button,{className:"truncate",children:f?.to??"..."})})]})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),h(),n.jsx(j,{condition:e,onClick:t})]})},nr={equals:V({modifier:mn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),notEquals:V({modifier:Cn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThan:V({modifier:Vn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThanOrEquals:V({modifier:yn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThan:V({modifier:vn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThanOrEquals:V({modifier:Sn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),inRange:V({modifier:zn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"}),notInRange:V({modifier:Fn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"})};class Xe extends P{modifiers=nr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=nr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Xe({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(ir,{condition:this,...e},this.id)}}const tr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Te,{value:a??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:a||"..."})})})}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},rr={equals:V({modifier:ae,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Oe,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:_e,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Ke extends P{modifiers=rr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=rr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Ke({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(tr,{condition:this,...e},this.id)}}const or=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":{const h=e.modifiers.equals,u=a!==void 0&&h.isConditionValueValid(a)?a:void 0;return n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:u!==void 0?u?fe[u].label:"empty":"..."})})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(o.Menu.SelectGroup,{required:!1,value:u,onValueChange:e.setConditionValue,children:Ne.map(f=>{const{label:p}=fe[f];return n.jsx(Se,{value:f,children:n.jsx("span",{className:"truncate",children:p})},f)})})})]})}case"includes":case"excludes":{const h=e.modifiers.includes,u=a!==void 0&&h.isConditionValueValid(a)?a:void 0;return n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",children:u?`${u.length} statuses`:"..."})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsxs(o.Menu.MultiSelectGroup,{values:u??Le,onValuesChange:e.setConditionValue,children:[n.jsx(Nn,{children:"Select all"}),Ne.map(f=>{const{label:p,icon:g}=fe[f];return n.jsxs(Gt,{value:f,children:[n.jsx(o.LuIcon,{icon:g}),n.jsx("span",{className:"truncate",children:p})]},f)})]})})]})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},ar={equals:V({modifier:_t,isValueValid:i=>i!==null,isConditionValueValid:i=>typeof i=="string",isSerializedValueValid:i=>typeof i=="string"}),notEquals:V({modifier:Tt,isValueValid:i=>i!==null,isConditionValueValid:i=>typeof i=="string",isSerializedValueValid:i=>typeof i=="string"}),includes:V({modifier:Lt,isValueValid:i=>i!==null,isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)}),excludes:V({modifier:Bt,isValueValid:i=>i!==null,isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)})};class Ye extends P{modifiers=ar;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=ar[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Ye({field:t,conditionModifier:a,conditionValue:h,...l})}transformValue(e){return e.status}render(e){return n.jsx(or,{condition:this,...e},this.id)}}const lr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=d.useMemo(()=>r.options.map(f=>typeof f=="string"?{value:f,label:f}:f),[r.options]),h=d.useMemo(()=>{const f={};for(const p of s)f[p.value]=p.label;return f},[s]),u=()=>{switch(l){case"equals":case"notEquals":{const f=e.modifiers.equals,p=a!==void 0&&f.isConditionValueValid(a)?a:void 0;return n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:p!==void 0?p?h[p]:"empty":"..."})})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(Mn,{required:!0,selectFieldOptions:r.options,value:p??void 0,onValueChange:e.setConditionValue})})]})}case"includes":case"excludes":{const f=e.modifiers.includes,p=a!==void 0&&f.isConditionValueValid(a)?a:void 0;return n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",children:p?`${p.length} options`:"..."})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(Ue,{selectFieldOptions:r.options,values:p??Le,onValuesChange:e.setConditionValue})})]})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),u(),n.jsx(j,{condition:e,onClick:t})]})},sr={equals:V({modifier:ae,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),notEquals:V({modifier:le,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),includes:V({modifier:wn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)}),excludes:V({modifier:bn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)})};class Ze extends P{modifiers=sr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=sr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Ze({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(lr,{condition:this,...e},this.id)}}const dr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"greaterThanOrEquals":case"lessThanOrEquals":case"greaterThan":case"lessThan":{const h=e.modifiers[l],u=a!==void 0&&h.isConditionValueValid(a)?a:void 0;return n.jsx(ze,{value:u??null,onValueChange:f=>e.setConditionValue(f??void 0),size:"sm",children:n.jsx(o.Button,{type:"button",className:"truncate",children:u!==void 0?u:"..."})})}case"inRange":case"notInRange":{const h=e.modifiers.inRange,u=a!==void 0&&h.isConditionValueValid(a)?a:void 0;return n.jsxs(n.Fragment,{children:[n.jsx(ze,{value:u?.from??null,onValueChange:f=>{e.setConditionValue({from:f,to:u?.to??null})},size:"sm",children:n.jsx(o.Button,{className:"truncate",children:u?.from??"..."})}),n.jsx(ze,{value:u?.to??null,onValueChange:f=>{e.setConditionValue({from:u?.from??null,to:f})},size:"sm",children:n.jsx(o.Button,{className:"truncate",children:u?.to??"..."})})]})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},cr={equals:V({modifier:mn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),notEquals:V({modifier:Cn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThan:V({modifier:Vn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),lessThanOrEquals:V({modifier:yn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThan:V({modifier:vn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),greaterThanOrEquals:V({modifier:Sn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="number",isSerializedValueValid:i=>typeof i=="number"}),inRange:V({modifier:zn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"}),notInRange:V({modifier:Fn,isValueValid:i=>typeof i=="number",isConditionValueValid:i=>typeof i=="object",isSerializedValueValid:i=>typeof i=="object"})};class Qe extends P{modifiers=cr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=cr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Qe({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(dr,{condition:this,...e},this.id)}}const ur=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Te,{value:a??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:a||"..."})})})}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},hr={equals:V({modifier:ae,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Oe,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:_e,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class Re extends P{modifiers=hr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=hr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new Re({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(ur,{condition:this,...e},this.id)}}const fr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=d.useMemo(()=>r.options.map(p=>typeof p=="string"?{value:p,label:p}:p),[r.options]),h=d.useMemo(()=>{const p={};for(const g of s)p[g.value]=g.label;return p},[s]),u=d.useCallback(p=>{p.length>0?e.setConditionValue(p):e.setConditionValue([])},[e]),f=()=>{switch(l){case"equals":case"notEquals":{const p=e.modifiers.equals,g=a!==void 0&&p.isConditionValueValid(a)?a:void 0;return n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:g!==void 0?g?h[g]:"empty":"..."})})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(Mn,{required:!1,selectFieldOptions:r.options,value:g??void 0,onValueChange:e.setConditionValue})})]})}case"includes":case"excludes":{const p=e.modifiers.includes,g=a!==void 0&&p.isConditionValueValid(a)?a:void 0;return n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",children:g?`${g.length} options`:"..."})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsx(Ue,{selectFieldOptions:r.options,values:g??Le,onValuesChange:u})})]})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),f(),n.jsx(j,{condition:e,onClick:t})]})},pr={equals:V({modifier:ae,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),notEquals:V({modifier:le,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>!Array.isArray(i),isSerializedValueValid:i=>!Array.isArray(i)}),includes:V({modifier:wn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)}),excludes:V({modifier:bn,isValueValid:i=>typeof i=="string",isConditionValueValid:i=>Array.isArray(i),isSerializedValueValid:i=>Array.isArray(i)})};class ei extends P{modifiers=pr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=pr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ei({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(fr,{condition:this,...e},this.id)}}const gr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Te,{value:a??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:a||"..."})})})}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},mr={equals:V({modifier:ae,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Oe,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:_e,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ii extends P{modifiers=mr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=mr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ii({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(gr,{condition:this,...e},this.id)}}const Cr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Te,{value:a??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:a||"..."})})})}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},Vr={equals:V({modifier:ae,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Oe,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:_e,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ni extends P{modifiers=Vr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=Vr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ni({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Cr,{condition:this,...e},this.id)}}const yr=i=>{const{condition:e,onRemove:t}=i,r=e.getConditionValue(),a=e.getConditionModifier(),l=()=>{switch(a){case"equals":case"notEquals":case"before":case"after":{const s=typeof r=="string"?r:void 0;return n.jsx(wi,{value:s,onValueChange:h=>e.setConditionValue(h??void 0),size:"sm",children:n.jsx(o.Button,{type:"button",className:"truncate",children:s?mi(s):"..."})})}case"in":case"notIn":{const s=r&&typeof r=="object"?r:void 0,h=u=>{e.setConditionValue(u.from||u.to?u:void 0)};return n.jsxs(n.Fragment,{children:[n.jsx(wi,{value:s?.from,onValueChange:u=>h({from:u,to:s?.to??null}),size:"sm",children:n.jsx(o.Button,{type:"button",className:"truncate",children:s?.from?mi(s.from):"..."})}),n.jsx(wi,{value:s?.to,onValueChange:u=>h({from:s?.from??null,to:u}),size:"sm",children:n.jsx(o.Button,{type:"button",className:"truncate",children:s?.to?mi(s.to):"..."})})]})}}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[e.field.type].icon}),n.jsx("span",{className:"truncate",children:e.field.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[a].modifier.label})}),l(),n.jsx(j,{condition:e,onClick:t})]})},vr={equals:V({modifier:At,isValueValid:i=>A(i),isConditionValueValid:i=>A(i),isSerializedValueValid:i=>A(i)}),notEquals:V({modifier:Et,isValueValid:i=>A(i),isConditionValueValid:i=>A(i),isSerializedValueValid:i=>A(i)}),before:V({modifier:$t,isValueValid:i=>A(i),isConditionValueValid:i=>A(i),isSerializedValueValid:i=>A(i)}),after:V({modifier:Dt,isValueValid:i=>A(i),isConditionValueValid:i=>A(i),isSerializedValueValid:i=>A(i)}),in:V({modifier:Pt,isValueValid:i=>A(i),isConditionValueValid:i=>je(i),isSerializedValueValid:i=>je(i)}),notIn:V({modifier:jt,isValueValid:i=>A(i),isConditionValueValid:i=>je(i),isSerializedValueValid:i=>je(i)})};class ti extends P{modifiers=vr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=vr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ti({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(yr,{condition:this,...e},this.id)}}const Sr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(a){case void 0:return"...";case!0:return"true";case!1:return"false";case null:return"empty"}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),n.jsxs(o.Menu.Root,{children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:s()})}),n.jsx(o.Menu.Content,{size:"sm",children:n.jsxs(o.Menu.SelectGroup,{required:!0,value:a,onValueChange:e.setConditionValue,children:[n.jsx(Se,{value:!0,children:"empty"}),n.jsx(Se,{value:!1,children:"not empty"})]})})]}),n.jsx(j,{condition:e,onClick:t})]})},zr={equals:V({modifier:qt,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:Ot,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class ri extends P{modifiers=zr;constructor(e){super(e)}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=zr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new ri({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Sr,{condition:this,...e},this.id)}}const Fr=i=>{const{condition:e,onRemove:t}=i,r=e.field,a=e.getConditionValue(),l=e.getConditionModifier(),s=()=>{switch(l){case"equals":case"notEquals":case"includes":case"excludes":return n.jsx(Te,{value:a??"",onValueChange:e.setConditionValue,size:"sm",children:n.jsx(o.Button,{type:"button",className:"shrink-1 min-w-0 grow",children:n.jsx("span",{className:"truncate",children:a||"..."})})})}};return n.jsxs(o.ButtonGroup,{className:"flex w-max min-w-0 max-w-full gap-0.5",size:"sm",variant:"fill",accentColor:"base",children:[n.jsxs(o.Badge,{className:"shrink-1 min-w-0",size:"sm",variant:"fill",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_[r.type].icon}),n.jsx("span",{className:"truncate",children:r.label||E})]}),n.jsx(U,{condition:e,children:n.jsx(o.Button,{type:"button",children:e.modifiers[l].modifier.label})}),s(),n.jsx(j,{condition:e,onClick:t})]})},wr={equals:V({modifier:ae,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),notEquals:V({modifier:le,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),includes:V({modifier:Oe,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0}),excludes:V({modifier:_e,isValueValid:i=>!0,isConditionValueValid:i=>!0,isSerializedValueValid:i=>!0})};class oi extends P{modifiers=wr;constructor(e){super(e)}transformValue(e){return e?.toString()??""}static deserialize(e,t){const{conditionValue:r,conditionModifier:a,...l}=e,s=wr[a],h=r!==void 0&&s.isSerializedValueValid(r)?s.modifier.deserialize(r):void 0;return new oi({field:t,conditionModifier:a,conditionValue:h,...l})}render(e){return n.jsx(Fr,{condition:this,...e},this.id)}}const ko={date:He,time:ti,number:Xe,boolean:Ge,select:ei,string:ii,url:oi,text:ni,upload:ri,qr:Re,"multi-string":We,"multi-select":Je,radio:Ze,"checkbox-list":ke,"pass-fail":Ye,otp:Ke,rating:Qe},br=(i,e)=>{if(i.type!==e.type)throw new Error(`field and condition type mismatch ${i.type} !== ${e.type}`);return ko[e.type].deserialize(e,i)},xn=(i,e)=>{const t=In(i,e),r={};for(const a of i)r[a.identifier]=a;return t.map(a=>br(r[a.fieldId],a))},Nr=(i,e)=>qn(i,e).map(r=>r.serialize()),In=(i,e)=>{const t=new Set(i.map(r=>r.identifier));return e.filter(r=>t.has(r.fieldId))},qn=(i,e)=>{const t=new Set(i.map(r=>r.identifier));return e.filter(r=>t.has(r.field.identifier))},Ni=i=>pn[i.type].deserialize(i);function Ho(i){return i.map(Mr)}const Mr=i=>i.type==="section"?W.deserialize(i):Ni(i);function Jo(i){return i.map(Ni)}function Wo(i){const e=[];for(const t of i)if(t instanceof W)for(const r of t.getFields())e.push(r);else e.push(t);return e}function Xo(i){const e={};for(const t of i)e[t.identifier]=t;return e}function xr(i,e,t=!0){const r=t?Mi(i,e):e,a={};for(const l of i){if(!(l.identifier in r))continue;const s=r[l.identifier];a[l.identifier]=l.serializeValue(s)}return a}function Ir(i,e,t=!0){const r=t?On(i,e):e,a={};for(const l of i){if(!(l.identifier in r))continue;const s=r[l.identifier];a[l.identifier]=l.deserializeValue(s)}return a}function Mi(i,e){const t={};for(const r of i){if(!(r.identifier in e))continue;const a=e[r.identifier];r.isValue(a)&&(t[r.identifier]=r.cleanValue(a))}return t}function On(i,e){const t={};for(const r of i){if(!(r.identifier in e))continue;const a=e[r.identifier];r.isSerializedValue(a)&&(t[r.identifier]=r.cleanSerializedValue(a))}return t}function qr(i,e){const t=Mi(i,e),r={},a={};for(const l of i){if(!(l.identifier in t))continue;const s=t[l.identifier];switch(l.type){case"upload":if(!l.isValue(s))break;a[l.identifier]=s,r[l.identifier]=[];break;case"pass-fail":if(!l.isValue(s))break;a[l.identifier]=s.files,r[l.identifier]={...s,files:[]};break;default:r[l.identifier]=e[l.identifier]}}return[r,a]}function Or(i,e,t){const r={};for(const a of i){if(!(a.identifier in e))continue;const l=e[a.identifier];switch(a.type){case"upload":if(!a.isValue(l))break;r[a.identifier]=t[a.identifier]??[];break;case"pass-fail":if(!a.isValue(l))break;r[a.identifier]={...l,files:t[a.identifier]??[]};break;default:if(!a.isValue(l))break;r[a.identifier]=l}}return r}const _r=(i,e)=>{const t={};for(const r of i){const a=e[r.identifier];t[r.identifier]=a!==void 0?a:r.blankValue()}return t},Tr=(i,e,t)=>{const r={};for(const a of i){const l=e[a.identifier],s=t[a.identifier];a.areValuesEqual(l,s)||(r[a.identifier]=s)}return r},Lr=(i,e,t)=>{const r={};for(const a of i){const l=e[a.identifier],s=t[a.identifier];a.areValuesEqual(l,s)&&(r[a.identifier]=s)}return r},_n=(i,e,t)=>i.every(r=>{const a=e[r.identifier],l=t[r.identifier];return r.areValuesEqual(a,l)}),Tn=i=>{const e={};for(const t of i)e[t.identifier]=t.blankValue();return e},Br=(i,e)=>_n(i,e,Tn(i)),Ko=Q.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),xi=Q.cva(["flex","flex-col"],{variants:{size:{xs:["gap-2"],sm:["gap-4"],md:["gap-6"],lg:["gap-8"],xl:["gap-10"]}}}),Ln=d.memo(i=>{const{fieldSection:e}=i,{label:t,description:r}=e,a=Y.useWatch(),{fieldSchema:l,size:s}=d.use(L),h=d.useMemo(()=>l.getFieldSections(),[l]),u=d.useMemo(()=>h.findIndex(({identifier:m})=>m===e.identifier),[h,e.identifier]),f=d.useMemo(()=>h.filter(m=>e.identifier in m.conditions),[h,e.identifier]),p=d.useMemo(()=>f.length===0?!0:f.some(m=>{const C=m.getConditions(e.identifier);return new bi(C).applyConditions(a)}),[f,e,a]),g=ui(e.fields);return p?n.jsxs(n.Fragment,{children:[u!==0?n.jsx(o.Separator,{size:"full"}):null,n.jsxs("div",{className:"flex flex-col gap-4",children:[(t||r)&&n.jsx(n.Fragment,{children:n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx(o.Heading,{size:s,children:t}),r&&n.jsx(o.Text,{accentColor:"base",size:s,children:r})]})}),n.jsx("div",{className:xi({size:s}),children:g})]})]}):null});Ln.displayName="FieldSectionLayout";class W extends Ai{type="section";label;description;conditions;fields=[];constructor(e){const{label:t=null,description:r=null,fields:a,conditions:l={},...s}=e;super(s),this.label=t,this.description=r,this.fields=this.initFields(a),this.conditions=this.initConditions(l)}serialize(){const e={};for(const[t,r]of Object.entries(this.conditions))e[t]=r.map(a=>a.serialize());return{...super.serialize(),label:this.label,description:this.description,conditions:e,fields:this.fields.map(t=>t.serialize())}}static deserialize=e=>{const t=e.fields.map(Ni),r={};for(const[a,l]of Object.entries(e.conditions))r[a]=xn(t,l);return new W({...e,fields:t,conditions:r})};getOptions(){return{...super.getOptions(),label:this.label,description:this.description,fields:this.fields,conditions:this.conditions}}duplicate(e){return new W({...this.getOptions(),identifier:e,fields:this.fields.map(t=>t.duplicate(b.v4()))})}setOptions(e){const{label:t,description:r,fields:a,conditions:l,...s}=e;this.label=t??this.label,this.description=r??this.description,this.fields=a||this.fields,this.conditions=l||this.conditions,super.setOptions(s)}getErrors(e){const t={};for(const r of this.fields){const a=r.getError(e[r.identifier]);a&&(t[r.identifier]=a)}return t}fieldObserver=()=>{this.notify(this)};initFields=e=>{for(const t of e)t.observe(this.fieldObserver);return e};getFields(){return this.fields}addField(e,t){const r=[...this.fields];r.splice(t??this.fields.length,0,e),this.fields=this.initFields(r),this.notify(this)}moveField(e,t){const r=[...this.fields],[a]=r.splice(e,1);r.splice(t,0,a),this.fields=r,this.notify(this)}removeField(e){this.fields=this.initFields(this.fields.filter(({identifier:r})=>r!==e.identifier));const t={};for(const[r,a]of Object.entries(this.conditions))t[r]=a.filter(l=>l.field.identifier!==e.identifier);this.conditions=t,this.notify(this)}conditionObserver=()=>{this.notify(this)};initConditions=e=>{for(const t of Object.values(e).flat())t.observe(this.conditionObserver);return e};getConditions(e){return this.conditions[e]}addCondition(e,t){this.conditions=this.initConditions({...this.conditions,[e]:[...this.conditions[e]??[],t]}),this.notify(this)}addConditions(e,t){this.conditions=this.initConditions({...this.conditions,[e]:[...this.conditions[e]??[],...t]}),this.notify(this)}removeCondition(e,t){this.conditions=this.initConditions({...this.conditions,[e]:(this.conditions[e]??[]).filter(r=>r.id!==t.id)}),this.notify(this)}removeConditions(e,t){const r=new Set(t.map(a=>a.id));this.conditions=this.initConditions({...this.conditions,[e]:(this.conditions[e]??[]).filter(a=>!r.has(a.id))}),this.notify(this)}getConditionals(){return new Set(Object.keys(this.conditions))}addConditional(e){this.conditions=this.initConditions({...this.conditions,[e]:[]}),this.notify(this)}removeConditional(e){const t={...this.conditions};delete t[e],this.conditions=this.initConditions(t),this.notify(this)}render(){return n.jsx(Ln,{fieldSection:this})}}const R=d.createContext({}),Ii=d.memo(i=>{const{children:e,variant:t,size:r,accentColor:a,onSelectFieldType:l,...s}=i,h=d.useMemo(()=>{const u={[q.Assessment]:[],[q.Capture]:[],[q.Numeric]:[],[q.Selection]:[],[q.Temporal]:[],[q.Text]:[],[q.Verification]:[]};for(const f of Vt){const{group:p}=_[f];u[p].push(f)}return u},[]);return n.jsxs(o.Menu.Root,{...s,children:[n.jsx(o.Menu.ClickTrigger,{children:e}),n.jsx(o.Menu.Content,{variant:t,size:r,accentColor:a,children:n.jsx(o.Menu.Scroll,{children:Object.entries(h).map(([u,f])=>{const{name:p}=yt[u];return f.length===0?null:n.jsxs(o.Menu.Group,{children:[n.jsx(o.Menu.Label,{children:p}),f.map(g=>n.jsx(Ar,{fieldType:g,onSelectFieldType:l},g))]},u)})})})]})});Ii.displayName="CreateFieldDropdownMenu";const Ar=d.memo(i=>{const{fieldType:e,onSelectFieldType:t}=i,r=d.useCallback(()=>{t(e)},[e,t]),{icon:a,name:l}=_[e];return n.jsxs(o.Menu.Item,{onSelect:r,children:[n.jsx(o.LuIcon,{icon:a}),n.jsx(o.Text,{className:"truncate",children:l})]})});Ar.displayName="CreateFieldDropdownMenuItem";const qi=i=>{switch(i){case"text":return new ye({label:"",required:!1,identifier:b.v4()});case"boolean":return new ce({label:"",required:!1,identifier:b.v4()});case"number":return new H({label:"",required:!1,identifier:b.v4()});case"date":return new be({label:"",required:!1,identifier:b.v4()});case"time":return new xe({label:"",required:!1,identifier:b.v4()});case"string":return new Ve({label:"",required:!1,identifier:b.v4()});case"url":return new Ie({label:"",required:!1,identifier:b.v4()});case"select":return new te({label:"",options:[],required:!1,identifier:b.v4()});case"multi-string":return new de({label:"",required:!1,identifier:b.v4()});case"multi-select":return new ie({label:"",options:[],required:!1,identifier:b.v4()});case"upload":return new ve({label:"",required:!1,identifier:b.v4(),maximum_files:6,maximum_size:qe});case"qr":return new Me({label:"",required:!1,identifier:b.v4()});case"radio":return new me({label:"",options:[],required:!1,identifier:b.v4()});case"checkbox-list":return new ue({label:"",options:[],required:!1,identifier:b.v4()});case"pass-fail":return new ge({label:"",required:!1,identifier:b.v4(),showNotesAndFilesOn:["fail"]});case"otp":return new he({label:"",validationType:"none",required:!1,identifier:b.v4(),length:6});case"rating":return new Ce({label:"",required:!1,identifier:b.v4(),maxRating:5})}},Bn=i=>{switch(i.type){case"text":return new ni({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"boolean":return new Ge({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"number":return new Xe({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"date":return new He({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"time":return new ti({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"string":return new ii({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"url":return new oi({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"select":return new ei({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"multi-string":return new We({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"multi-select":return new Je({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"upload":return new ri({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"qr":return new Re({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"radio":return new Ze({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"checkbox-list":return new ke({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"pass-fail":return new Ye({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"otp":return new Ke({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i});case"rating":return new Qe({id:b.v4(),conditionValue:void 0,conditionModifier:"equals",field:i})}},Er=(i,e)=>{switch(i){case"checkbox-list":return ue.getFieldCreationSchema(e);case"multi-select":return ie.getFieldCreationSchema(e);case"number":return H.getFieldCreationSchema(e);case"radio":return me.getFieldCreationSchema(e);case"select":return te.getFieldCreationSchema(e);case"string":return Ve.getFieldCreationSchema(e);case"text":return ye.getFieldCreationSchema(e);case"upload":return ve.getFieldCreationSchema(e);case"pass-fail":return ge.getFieldCreationSchema(e);case"otp":return he.getFieldCreationSchema(e);case"rating":return Ce.getFieldCreationSchema(e);default:return}},$r=d.memo(i=>{const{popoverInputs:e,...t}=i;return n.jsxs(o.Popover.Root,{children:[n.jsx(o.Popover.Trigger,{asChild:!0,children:n.jsxs(o.Button,{variant:"soft",type:"button",size:"sm",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:_o}),"Settings"]})}),n.jsx(o.Popover.Content,{size:"sm",...t,children:n.jsx("div",{className:Q.cx("flex w-full max-w-[350px] flex-col",xi({size:"sm"})),children:e})})]})});$r.displayName="FieldSettingsPopover";const Dr=d.memo(i=>{const{parentPath:e,fieldIndex:t,field:r}=i,a=ci(),{disableRequiredFields:l}=d.use(R),[s,h]=d.useState(void 0);d.useEffect(()=>{r.image instanceof Promise?r.image.then(h).catch(console.error):h(r.image)},[r]);const u=d.useCallback(()=>{r.setOptions({image:void 0})},[r]),[f,p]=d.useMemo(()=>{const F=[],w=[],T=Er(r.type,`${e}.${t}`)??[];for(const G of T)G.showDirectly?F.push(G.field):w.push(G.field);return[F,w]},[r,e,t]),g=ui(f),m=ui(p),C=p.length>0,v=d.useCallback(()=>{s&&a(()=>({file:s}))},[a,s]),y=d.useCallback(F=>{r.setOptions({required:!!F})},[r]),S=d.useCallback(F=>{r.setOptions({label:F.target.value})},[r]),z=d.useCallback(F=>{r.setOptions({description:F.target.value})},[r]),{icon:x,name:I}=_[r.type];return n.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[n.jsxs("div",{className:"flex w-full justify-between gap-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(o.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[n.jsx(o.LuIcon,{icon:x}),I]}),!l&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(o.Checkbox.Root,{checked:r.required,onCheckedChange:y,size:"sm",children:n.jsx(o.Checkbox.Indicator,{children:n.jsx(o.LuIcon,{icon:J})})}),n.jsx(o.Text,{size:"sm",accentColor:"base",children:"Required"})]})]}),C&&n.jsx($r,{popoverInputs:m,align:"end"})]}),s&&n.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[n.jsx(we,{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",file:s,onClick:v}),n.jsx(o.IconButton,{type:"button",className:"group-hover:not-disabled:flex absolute right-2 top-2 hidden",variant:"solid",accentColor:"base","aria-label":"delete",onClick:u,size:"sm",children:n.jsx(o.LuIcon,{icon:se})})]}),n.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[n.jsx(o.Input.Root,{variant:"outline",size:"md",children:n.jsx(o.Input.Field,{placeholder:"Enter your question",value:r.label??"",onChange:S,maxLength:200})}),n.jsx(o.TextArea,{className:"field-sizing-content",placeholder:"Enter a field description (optional)",value:r.description??"",onChange:z,maxLength:1e3,resize:"vertical",size:"md"})]}),f.length>0&&n.jsx("div",{className:Q.cx("w-full",xi({size:"sm"})),children:g})]})});Dr.displayName="FieldBuilder";const An=d.memo(i=>{const{field:e,fieldSection:t,fieldIndex:r,sectionIndex:a}=i,l=d.useRef(null),s=`fields.${a}.fields`,h=d.useCallback(y=>{t.addField(qi(y),r+1)},[r,t]),u=d.useCallback(()=>{t.addField(e.duplicate(b.v4()))},[e,t]),f=d.useCallback(y=>{const S=y==="up"?a-1:a+1;t.moveField(r,S)},[t,r,a]),p=d.useCallback(y=>{const{files:S}=y.target;if(!S||S.length!==1)return;const z=S.item(0);if(z){if(z.size>St){o.toast.error({title:"File upload error",description:`The file ${z.name} exceeded the maximum file size`});return}e.setOptions({image:z})}},[e]),g=d.useCallback(()=>{f("up")},[f]),m=d.useCallback(()=>{f("down")},[f]),C=d.useCallback(()=>{l.current?.click()},[]),v=d.useCallback(()=>{t.removeField(e)},[e,t]);return n.jsxs(o.Card,{className:"flex w-full items-center justify-between gap-4",size:"sm",children:[n.jsx(Dr,{fieldIndex:r,field:e,parentPath:s}),n.jsxs(o.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[n.jsx(Ii,{onSelectFieldType:h,size:"sm",children:n.jsx(o.IconButton,{type:"button",children:n.jsx(o.LuIcon,{icon:Z})})}),n.jsx(o.IconButton,{type:"button",onClick:g,children:n.jsx(o.LuIcon,{icon:Rn})}),n.jsx(o.IconButton,{type:"button",onClick:m,children:n.jsx(o.LuIcon,{icon:Qn})}),n.jsx(o.IconButton,{type:"button",onClick:u,children:n.jsx(o.LuIcon,{icon:Ti})}),n.jsx(o.IconButton,{type:"button",onClick:C,children:n.jsx(o.LuIcon,{icon:Yn})}),n.jsx(o.IconButton,{type:"button",onClick:v,children:n.jsx(o.LuIcon,{icon:se})})]}),n.jsx("input",{className:"hidden",ref:l,type:"file",accept:"image/*",onChange:p})]})});An.displayName="FieldBuilderWithActions";const En=d.memo(i=>{const{children:e,variant:t,size:r,accentColor:a,fields:l,onSelectField:s,...h}=i;return n.jsxs(o.Menu.Root,{...h,children:[n.jsx(o.Menu.ClickTrigger,{children:e}),n.jsx(o.Menu.Content,{variant:t,size:r,accentColor:a,children:n.jsx(o.Menu.Scroll,{children:l.map(u=>n.jsx(Pr,{field:u,onSelectField:s},u.identifier))})})]})});En.displayName="FieldDropdownMenu";const Pr=d.memo(i=>{const{field:e,onSelectField:t}=i,r=d.useCallback(()=>{t(e)},[e,t]);return n.jsxs(o.Menu.Item,{onSelect:r,children:[n.jsx(o.LuIcon,{icon:_[e.type].icon}),e.label||E]})});Pr.displayName="FieldDropdownMenuItem";const jr=d.memo(i=>{const{children:e,variant:t,size:r,accentColor:a,fieldSections:l,onSelectFieldSection:s,...h}=i;return n.jsxs(o.Menu.Root,{...h,children:[n.jsx(o.Menu.ClickTrigger,{children:e}),n.jsx(o.Menu.Content,{variant:t,size:r,accentColor:a,children:l.map(u=>n.jsx(Ur,{fieldSection:u,onSelectFieldSection:s},u.identifier))})]})});jr.displayName="FieldSectionDropdownMenu";const Ur=d.memo(i=>{const{fieldSection:e,onSelectFieldSection:t}=i,r=d.useCallback(()=>{t(e)},[e,t]);return n.jsxs(o.Menu.Item,{onSelect:r,children:[n.jsx(o.LuIcon,{icon:Zn}),e.label||gn]})});Ur.displayName="FieldSectionDropdownMenuItem";const Gr=d.memo(i=>{const{id:e,sourceX:t,sourceY:r,targetX:a,targetY:l,style:s,markerEnd:h,data:u}=i,{targetSection:f,sourceSection:p,layoutDirection:g}=u,m=d.useMemo(()=>p.getConditions(f.identifier),[p,f.identifier]),C=d.useCallback(()=>{p.removeConditional(f.identifier)},[p,f.identifier]),v=d.useCallback(I=>{p.addCondition(f.identifier,Bn(I))},[p,f.identifier]),y=d.useCallback(I=>{p.removeCondition(f.identifier,I)},[p,f.identifier]),[S,z,x]=O.getBezierPath({sourceX:t,sourceY:r,sourcePosition:g==="LR"?O.Position.Right:O.Position.Bottom,targetX:a,targetY:l,targetPosition:g==="LR"?O.Position.Left:O.Position.Top});return n.jsxs(n.Fragment,{children:[n.jsx(O.BaseEdge,{id:e,path:S,style:s,markerEnd:h,labelX:z,labelY:x}),n.jsx(O.EdgeLabelRenderer,{children:n.jsxs(o.Card,{size:"xs",variant:"surface",className:"nodrag nopan bg-(--base-2) pointer-events-auto absolute inline-flex flex-col gap-2",onMouseDown:o.stopPropagation,onClick:o.stopPropagation,"data-floating-content":"",style:{transform:`translate(-50%, -50%) translate(${z}px, ${x}px)`},children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(o.Text,{size:"xs",className:"max-w-[280px] truncate",children:p.label||"Untitled section"}),n.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[n.jsx(En,{fields:p.fields,onSelectField:v,children:n.jsx(o.IconButton,{"aria-label":"Add condition",type:"button",variant:"surface",size:"xs",accentColor:"base",children:n.jsx(o.LuIcon,{icon:Z})})}),n.jsxs(o.Tooltip.Root,{children:[n.jsx(o.Tooltip.Trigger,{asChild:!0,children:n.jsx(o.IconButton,{"aria-label":"Remove conditional logic",type:"button",variant:"surface",size:"xs",accentColor:"base",color:"danger",onClick:C,children:n.jsx(o.LuIcon,{icon:se})})}),n.jsx(o.Tooltip.Content,{size:"sm",children:"Remove conditional logic"})]})]})]}),m.length>0&&n.jsx("div",{className:"flex h-max w-full flex-col flex-wrap gap-1",children:m.map(I=>n.jsx(d.Fragment,{children:I.render({onRemove:y})},I.id))})]})})]})});Gr.displayName="FieldSectionConditionEdgeComponent";const kr=d.memo(i=>{const{data:e,selected:t}=i,{fieldSection:r,index:a,layoutDirection:l}=e,{fieldSchema:s}=d.use(R),h=d.useCallback(()=>{s.removeFieldSection(r)},[s,r]),u=d.useCallback(C=>{r.addField(qi(C))},[r]),f=d.useCallback(()=>{const C=new W({identifier:b.v4(),fields:[]});s.addFieldSection(C),r.addConditional(C.identifier)},[s,r]),p=d.useCallback(()=>{s.addFieldSection(r.duplicate(b.v4()))},[s,r]),g=d.useCallback(C=>{r.setOptions({label:C.target.value})},[r]),m=d.useCallback(C=>{r.setOptions({description:C.target.value})},[r]);return n.jsxs(o.Card,{variant:"surface",className:"bg-(--base-2) relative cursor-pointer",size:"sm","data-selected":t?"true":void 0,children:[n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[n.jsx(o.Input.Root,{variant:"outline",size:"md",accentColor:"base",children:n.jsx(o.Input.Field,{placeholder:"Enter a section label (optional)",value:r.label??"",onChange:g,maxLength:200})}),n.jsx(o.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:r.description??"",onChange:m,maxLength:1e3,resize:"vertical",size:"md"})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(o.Text,{weight:"bold",children:"Fields"}),n.jsx(Ii,{onSelectFieldType:u,size:"sm",children:n.jsxs(o.Button,{type:"button",variant:"soft",size:"sm",accentColor:"base",children:[n.jsx(o.LuIcon,{icon:Z})," Add field"]})})]}),n.jsx("div",{className:"flex flex-col gap-3",children:r.fields.map((C,v)=>n.jsx(An,{field:C,fieldSection:r,fieldIndex:v,sectionIndex:a},C.identifier))})]}),n.jsx(O.NodeToolbar,{isVisible:!0,position:O.Position.Right,align:"start",offset:8,onMouseDown:o.stopPropagation,children:n.jsx(o.Card,{variant:"surface",className:"bg-(--base-2) flex flex-col items-center gap-1 p-1",size:"xs",onClick:o.stopPropagation,children:n.jsxs(o.ButtonGroup,{className:"flex flex-col gap-2",variant:"surface",size:"xs",accentColor:"base",children:[n.jsx(o.IconButton,{type:"button",onClick:f,children:n.jsx(o.LuIcon,{icon:Fo})}),n.jsx(o.IconButton,{type:"button",onClick:p,children:n.jsx(o.LuIcon,{icon:Ti})}),n.jsx(o.IconButton,{type:"button",onClick:h,children:n.jsx(o.LuIcon,{icon:se})})]})})}),n.jsx(O.Handle,{type:"target",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:l==="LR"?O.Position.Left:O.Position.Top}),n.jsx(O.Handle,{type:"source",className:"size-4! bg-(--base-3)! border-(--base-7)!",position:l==="LR"?O.Position.Right:O.Position.Bottom})]})});kr.displayName="CustomNode";const Yo={fieldSection:kr},Zo={fieldSectionCondition:Gr},Qo=(i,e,t)=>{const r=new jn.graphlib.Graph().setDefaultEdgeLabel(()=>({}));return r.setGraph({rankdir:t,nodesep:200,edgesep:500,ranksep:500}),e.forEach(a=>r.setEdge(a.source,a.target,{width:500,height:200,labelpos:"c"})),i.forEach(a=>r.setNode(a.id,{...a,width:a.measured?.width??0,height:a.measured?.height??0})),jn.layout(r),[i.map(a=>{const l=r.node(a.id),s=l.x-(a.measured?.width??0)/2,h=l.y-(a.measured?.height??0)/2;return{...a,position:{x:s,y:h}}}),e]},Ro={hideAttribution:!0},Hr=d.memo(()=>{const{errors:i}=Y.useFormState(),{handleSubmit:e}=Y.useFormContext(),{onSave:t,onCancel:r}=d.use(R),{fieldSchema:a}=d.use(R),l=d.useRef(null),[s,h]=d.useState(),[u,f]=d.useState("TB");d.useLayoutEffect(()=>{l.current&&l.current.classList.remove("light")},[]);const p=d.useMemo(()=>a.fieldSections.map(($,X)=>({id:$.identifier,position:{x:0,y:0},data:{index:X,fieldSection:$,layoutDirection:u},draggable:!0,type:"fieldSection"})),[a.fieldSections,u]),g=d.useMemo(()=>{const $=[],X={};for(const K of a.fieldSections)X[K.identifier]=K;for(const K of a.fieldSections){const ai=K.conditions;for(const[li,oa]of Object.entries(ai))$.push({id:`${K.identifier}-${li}`,source:K.identifier,target:li,data:{targetSection:X[li],sourceSection:K,layoutDirection:u},animated:oa.length>0,markerEnd:O.MarkerType.Arrow,style:{strokeWidth:2,stroke:"var(--base-a8)"},type:"fieldSectionCondition"})}return $},[a.fieldSections,u]),[m,C,v]=O.useNodesState(p),[y,S,z]=O.useEdgesState(g);d.useEffect(()=>{C(p)},[p,C]),d.useEffect(()=>{S(g)},[g,S]);const[x,I]=d.useMemo(()=>Qo(m,y,u),[y,u,m]),F=d.useCallback(()=>{a.addFieldSection(new W({identifier:b.v4(),fields:[]}))},[a]),w=d.useCallback($=>{const{source:X,target:K}=$,ai=a.fieldSections.find(({identifier:li})=>li===X);ai.setOptions({conditions:{...ai.conditions,[K]:[]}})},[a.fieldSections]),T=d.useCallback($=>{const X=a.getSectionDependencyGraph();return!Dn.willCreateCycle(X,$.source,$.target)},[a]),G=d.useCallback(()=>{s?.zoomOut()},[s]),ee=d.useCallback(()=>{s?.zoomIn()},[s]),Be=d.useCallback(()=>{s?.fitView()},[s]);return n.jsxs("form",{className:"flex size-full flex-col gap-4",onSubmit:e(t),children:[n.jsxs(o.Card,{className:"relative size-full",variant:"outline",children:[n.jsx(O.ReactFlow,{ref:l,onInit:h,nodes:x,onNodesChange:v,edges:I,onEdgesChange:z,nodeTypes:Yo,edgeTypes:Zo,onConnect:w,attributionPosition:"bottom-left",fitView:!0,minZoom:0,isValidConnection:T,proOptions:Ro}),n.jsx(O.Panel,{position:"top-left",children:n.jsx(o.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:n.jsxs(o.Button,{type:"button",variant:"surface",onClick:F,children:[n.jsx(o.LuIcon,{icon:Z})," Add section"]})})}),n.jsxs(O.Panel,{position:"top-right",className:"flex flex-col items-center gap-2",children:[n.jsxs(o.ToggleGroup.Root,{className:"flex flex-col",type:"single",accentColor:"base",size:"sm",value:u,onValueChange:f,children:[n.jsx(o.ToggleGroup.IconItem,{className:"rounded-b-none",value:"LR",type:"button",children:n.jsx(o.LuIcon,{icon:fo})}),n.jsx(o.ToggleGroup.IconItem,{className:"rounded-t-none",value:"TB",type:"button",children:n.jsx(o.LuIcon,{icon:ho})})]}),n.jsx(o.Separator,{size:"sm"}),n.jsxs(o.ButtonGroup,{className:"flex flex-col",size:"sm",accentColor:"base",variant:"soft",children:[n.jsx(o.IconButton,{className:"rounded-b-none",onClick:ee,type:"button",children:n.jsx(o.LuIcon,{icon:Z})}),n.jsx(o.IconButton,{onClick:G,radius:"none",type:"button",children:n.jsx(o.LuIcon,{icon:di})}),n.jsx(o.IconButton,{className:"rounded-t-none",onClick:Be,type:"button",children:n.jsx(o.LuIcon,{icon:Lo})})]})]}),n.jsx(O.Panel,{position:"bottom-right",children:n.jsxs(o.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[r&&n.jsx(o.Button,{type:"button",variant:"soft",accentColor:"base",onClick:r,children:"Cancel"}),n.jsx(o.Button,{type:"submit",variant:"surface",children:"Save"})]})})]}),!!i.fields?.message&&n.jsx(o.Text,{size:"xs",accentColor:"danger",children:i.fields.message})]})});Hr.displayName="FormBuilderFlowBuilder";const ea=(i,e,t={})=>{const{conditions:r=!1}=t,a=i.get(e.identifier);if(!a)throw new Error(`Attempting to reseed serialized section with identifier ${e.identifier} which is not present in the reseeded identifier map`);const l=new Map,s=e.fields.map(u=>{const f=b.v4(),{image:p,...g}=u;return l.set(u.identifier,f),{...g,identifier:f}}),h={};if(r)for(const[u,f]of Object.entries(e.conditions??{})){const p=i.get(u);if(!p)continue;const g=f.map(m=>{const C=l.get(m.fieldId);if(!C)throw new Error(`Serialized condition referencing undefined field with identifier: ${m.fieldId}`);return{...m,fieldId:C}});h[p]=g}return{...e,identifier:a,conditions:h,fields:s}},ia=(i,e={})=>{const t=new Map(i.map(r=>[r.identifier,b.v4()]));return i.map(r=>ea(t,r,e))},$n=(i,e)=>{const t={},r=i.filter(a=>a instanceof W);for(const a of i)if(a instanceof W){const l=r.filter(h=>a.identifier in h.conditions);if(l.length>0&&!l.some(h=>{const u=h.getConditions(a.identifier);return new bi(u).applyConditions(e)}))continue;const s=a.getErrors(e);Object.assign(t,s)}else{if(!(a instanceof k))throw new Error("Invalid field type");const l=a.identifier,s=a.getError(Un(e,l));s&&ro(t,l,s)}return t},na=async i=>{const e={},t=[];for(const r of i){const{fields:a}=r,l=[];for(const s of a){if(s.image){if(s.image instanceof Promise)try{e[s.identifier]=await s.image}catch(h){console.error("Failed to get image from promise",h)}else e[s.identifier]=s.image;delete s.image}l.push(s)}t.push({...r,fields:l})}return{fields:t,images:e}};async function ta(i){const e={};for(const[t,r]of Object.entries(i))e[t]=await Promise.all(r);return e}class Fe extends Ee{fieldSections;constructor(e){super(),this.fieldSections=this.initFields(e)}serialize(){return this.fieldSections.map(e=>e.serialize())}static deserialize(e){return new Fe(e.map(W.deserialize))}static reseedFieldSections(e,t){return ia(e,t)}fieldObserver=()=>{this.notify(this)};initFields=e=>{for(const t of e)t.observe(this.fieldObserver);return e};getFields(){return this.fieldSections.flatMap(e=>e.getFields())}getFieldSections(){return this.fieldSections}addFieldSection(e,t){const r=[...this.fieldSections];r.splice(t??this.fieldSections.length,0,e),this.fieldSections=this.initFields(r),this.notify(this)}removeFieldSection(e){const t=this.fieldSections.filter(r=>r.identifier!==e.identifier);for(const r of t)r.removeConditional(r.identifier);this.fieldSections=this.initFields(t),this.notify(this)}moveFieldSection(e,t){const r=[...this.fieldSections],[a]=r.splice(e,1);r.splice(t,0,a),this.fieldSections=this.initFields(r),this.notify(this)}getSectionDependencyGraph(){const e=new no.DirectedGraph({type:"directed"});for(const t of this.fieldSections)for(const r of Object.keys(t.conditions))e.mergeEdge(t.identifier,r);return e}getDependenciesOfSection(e){const t=this.getSectionDependencyGraph(),r=new Map(this.fieldSections.map(l=>[l.identifier,l])),a=[];return to.bfsFromNode(t,e,(l,s,h)=>{a.push(r.get(l))},{mode:"in"}),a}cleanValues(e){return Mi(this.getFields(),e)}cleanSerializedValues(e){return On(this.getFields(),e)}deserializeValues(e,t){return Ir(this.getFields(),e,t)}serializeValues(e,t){return xr(this.getFields(),e,t)}initializeValues(e){return _r(this.getFields(),e)}validateValues(e){return $n(this.getFieldSections(),e)}areValuesValid(e){return Object.keys(this.validateValues(e)).length===0}deserializeConditions(e){return xn(this.getFields(),e)}cleanConditions(e){return qn(this.getFields(),e)}serializeConditions(e){return Nr(this.getFields(),e)}cleanSerializedConditions(e){return In(this.getFields(),e)}changedFieldValues(e,t){return Tr(this.getFields(),e,t)}unchangedFieldValues(e,t){return Lr(this.getFields(),e,t)}areValuesEqual(e,t){return _n(this.getFields(),e,t)}areValuesBlank(e){return Br(this.getFields(),e)}blankValues(){return Tn(this.getFields())}extractFilesAndPromisesFromFieldValues(e){return qr(this.getFields(),e)}insertFilesAndPromisesToFieldValues(e,t){return Or(this.getFields(),e,t)}}const Jr=d.memo(i=>{const{sourceFieldSection:e,targetFieldSection:t}=i,r=d.useMemo(()=>e.getConditions(t.identifier),[e,t.identifier]),a=d.useCallback(()=>{e.removeConditional(t.identifier)},[e,t.identifier]),l=d.useCallback(h=>{e.addCondition(t.identifier,Bn(h))},[e,t.identifier]),s=d.useCallback(h=>{e.removeCondition(t.identifier,h)},[e,t.identifier]);return n.jsxs(o.Card,{className:"flex flex-col gap-2",size:"sm",children:[n.jsxs(o.ButtonGroup,{className:"flex justify-between gap-2",size:"sm",accentColor:"base",variant:"soft",children:[n.jsxs(o.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[n.jsx(o.LuIcon,{icon:Zn}),e.label??gn]}),n.jsx(o.IconButton,{type:"button",onClick:a,variant:"ghost",children:n.jsx(o.LuIcon,{icon:se})})]}),n.jsxs("div",{className:"flex h-max w-full flex-wrap gap-2",children:[r.map(h=>h.render({onRemove:s})),n.jsx(En,{fields:e.fields,onSelectField:l,align:"start",children:n.jsx(o.IconButton,{type:"button",size:"sm",variant:"soft",accentColor:"base",children:n.jsx(o.LuIcon,{icon:Z})})})]})]})});Jr.displayName="FieldSectionConditionalItem";const Wr=d.memo(i=>{const{fieldSection:e}=i,{fieldSchema:t}=d.use(R),r=d.useMemo(()=>t.fieldSections.filter(u=>e.identifier in u.conditions),[t.fieldSections,e.identifier]),a=d.useCallback(u=>{u.addConditional(e.identifier)},[e.identifier]),l=d.useCallback(u=>{e.setOptions({label:u.target.value})},[e]),s=d.useCallback(u=>{e.setOptions({description:u.target.value})},[e]),h=d.useMemo(()=>{const u=t.getSectionDependencyGraph();return t.fieldSections.filter(f=>!Dn.willCreateCycle(u,f.identifier,e.identifier))},[e.identifier,t]);return n.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[n.jsxs("div",{className:"flex w-full flex-col gap-2 overflow-hidden",children:[n.jsx(o.Input.Root,{variant:"outline",size:"md",children:n.jsx(o.Input.Field,{placeholder:"Enter a section label (optional)",value:e.label??"",onChange:l,maxLength:200})}),n.jsx(o.TextArea,{className:"field-sizing-content",placeholder:"Enter a section description (optional)",value:e.description??"",onChange:s,maxLength:1e3,resize:"vertical",size:"md"})]}),n.jsx(o.Separator,{size:"full"}),n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx(o.Text,{accentColor:"base",children:"Conditions"}),n.jsx(jr,{fieldSections:h,onSelectFieldSection:a,children:n.jsxs(o.Button,{type:"button",variant:"soft",size:"sm",className:"w-max",children:[n.jsx(o.LuIcon,{icon:Z}),"Add condition"]})})]}),r.map(u=>n.jsx(Jr,{sourceFieldSection:u,targetFieldSection:e},u.identifier))]}),n.jsx(o.Separator,{size:"full"})]})});Wr.displayName="FieldSectionBuilder";const Xr=d.memo(i=>{const{fieldSection:e,sectionIndex:t}=i,{fieldSchema:r}=d.use(R),a=o.useAlertDialog(),l=d.useCallback(()=>{r.removeFieldSection(e)},[r,e]),s=d.useCallback(y=>{const S=y==="up"?t-1:t+1;r.moveFieldSection(t,S)},[r,t]),h=d.useCallback(()=>{r.addFieldSection(e.duplicate(b.v4()))},[r,e]),u=d.useCallback(y=>{e.addField(qi(y))},[e]),f=d.useCallback(()=>{s("up")},[s]),p=d.useCallback(()=>{s("down")},[s]),g=d.useCallback(async()=>{const y=[e.serialize()],S=Fe.reseedFieldSections(y,{conditions:!1}),z=JSON.stringify(S);await navigator.clipboard.writeText(z),o.toast.success({title:"Section copied"})},[e]),m=d.useCallback(async()=>{const S=r.getDependenciesOfSection(e.identifier).map(I=>I.serialize()),z=Fe.reseedFieldSections(S,{conditions:!0}),x=JSON.stringify(z);await navigator.clipboard.writeText(x),o.toast.success({title:"Section copied"})},[e,r]),C=d.useCallback(async()=>{const y=r.getDependenciesOfSection(e.identifier),S=y.length>1,z=y.length-1;S?a({title:"Copy section dependencies?",description:`This section has ${z} dependent section${z>1?"s":""} that will also be copied to maintain the conditions. Do you want to include these dependencies?`,action:"Include",onAction:m,cancel:"Dont include",onCancel:g}):g()},[e,r,a,m,g]),v=d.useCallback(async()=>{let y="";try{y=await navigator.clipboard.readText()}catch{o.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const S=y.trim();if(!S){o.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let z;try{z=JSON.parse(S)}catch{o.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const x=Array.isArray(z)?z:[z],I=[];for(const F of x){if(!F||typeof F!="object")continue;const w=F;if(w.type!=="section"||!Array.isArray(w.fields))continue;const T={type:"section",identifier:typeof w.identifier=="string"?w.identifier:b.v4(),label:typeof w.label=="string"||w.label===null?w.label:null,description:typeof w.description=="string"||w.description===null?w.description:null,conditions:w.conditions&&typeof w.conditions=="object"?w.conditions:{},fields:w.fields};try{I.push(W.deserialize(T))}catch{}}if(I.length===0){o.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}I.forEach((F,w)=>{r.addFieldSection(F,t+1+w)}),o.toast.success({title:"Section pasted",description:"Serialized JSON imported successfully."})},[r,t]);return n.jsxs(o.Card,{variant:"outline",className:"flex w-full items-center justify-between gap-4",size:"sm",children:[n.jsxs("div",{className:"flex w-full grow flex-col gap-4",children:[n.jsx(Wr,{fieldSection:e}),n.jsxs("div",{className:"flex w-full flex-col gap-2",children:[n.jsxs("div",{className:"flex justify-between gap-2",children:[n.jsx(o.Text,{accentColor:"base",size:"md",children:"Fields"}),n.jsx(Ii,{onSelectFieldType:u,size:"sm",children:n.jsxs(o.Button,{type:"button",variant:"soft",size:"sm",children:[n.jsx(o.LuIcon,{icon:Z})," Add field"]})})]}),e.fields.map((y,S)=>n.jsx(An,{field:y,fieldSection:e,fieldIndex:S,sectionIndex:t},y.identifier))]})]}),n.jsxs(o.ButtonGroup,{className:"flex flex-col gap-0.5",variant:"ghost",accentColor:"base",size:"sm",children:[n.jsx(o.IconButton,{type:"button",onClick:f,children:n.jsx(o.LuIcon,{icon:Rn})}),n.jsx(o.IconButton,{type:"button",onClick:p,children:n.jsx(o.LuIcon,{icon:Qn})}),n.jsxs(o.Menu.Root,{align:"end",children:[n.jsx(o.Menu.ClickTrigger,{children:n.jsx(o.IconButton,{type:"button",children:n.jsx(o.LuIcon,{icon:Kn})})}),n.jsxs(o.Menu.Content,{size:"sm",children:[n.jsxs(o.Menu.Item,{onSelect:h,children:[n.jsx(o.LuIcon,{icon:Ti}),"Duplicate section"]}),n.jsxs(o.Menu.Item,{onSelect:C,children:[n.jsx(o.LuIcon,{icon:Jn}),"Copy JSON"]}),n.jsxs(o.Menu.Item,{onSelect:v,children:[n.jsx(o.LuIcon,{icon:Wn}),"Paste JSON"]}),n.jsxs(o.Menu.Item,{onSelect:l,children:[n.jsx(o.LuIcon,{icon:se}),"Delete section"]})]})]})]})]})});Xr.displayName="FieldSectionWithActions";const Kr=d.memo(()=>{const{handleSubmit:i}=Y.useFormContext(),{errors:e}=Y.useFormState(),{onSave:t,onCancel:r}=d.use(R),{fieldSchema:a}=d.use(R),l=d.useCallback(()=>{a.addFieldSection(new W({identifier:b.v4(),fields:[]}))},[a]),s=d.useCallback(async()=>{try{const u=a.serialize(),f=Fe.reseedFieldSections(u),p=JSON.stringify(f);await navigator.clipboard.writeText(p),o.toast.success({title:"Sections copied",description:"All sections JSON copied to clipboard."})}catch{o.toast.error({title:"Copy failed",description:"Unable to copy the sections JSON."})}},[a]),h=d.useCallback(async()=>{let u="";try{u=await navigator.clipboard.readText()}catch{o.toast.error({title:"Paste failed",description:"Unable to read clipboard contents."});return}const f=u.trim();if(!f){o.toast.error({title:"Paste failed",description:"Clipboard is empty."});return}let p;try{p=JSON.parse(f)}catch{o.toast.error({title:"Invalid JSON",description:"Check the JSON and try again."});return}const g=Array.isArray(p)?p:[p],m=[];for(const v of g){if(!v||typeof v!="object")continue;const y=v;if(y.type!=="section"||!Array.isArray(y.fields))continue;const S={type:"section",identifier:typeof y.identifier=="string"?y.identifier:b.v4(),label:typeof y.label=="string"||y.label===null?y.label:null,description:typeof y.description=="string"||y.description===null?y.description:null,conditions:y.conditions&&typeof y.conditions=="object"?y.conditions:{},fields:y.fields};try{m.push(W.deserialize(S))}catch{}}if(m.length===0){o.toast.error({title:"Paste failed",description:"No valid sections found in the JSON."});return}const C=a.fieldSections.length;m.forEach((v,y)=>{a.addFieldSection(v,C+y)}),o.toast.success({title:"Sections pasted",description:"Serialized JSON imported successfully."})},[a]);return n.jsxs("form",{className:"flex flex-col gap-4",onSubmit:i(t),children:[n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center justify-end gap-2",children:[n.jsxs(o.Button,{type:"button",variant:"soft",size:"sm",onClick:s,children:[n.jsx(o.LuIcon,{icon:Jn})," Copy JSON"]}),n.jsxs(o.Button,{type:"button",variant:"soft",size:"sm",onClick:h,children:[n.jsx(o.LuIcon,{icon:Wn})," Paste JSON"]})]}),a.fieldSections.map((u,f)=>n.jsx(Xr,{fieldSection:u,sectionIndex:f},u.identifier)),n.jsxs(o.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:l,children:[n.jsx(o.LuIcon,{icon:Z})," Add section"]})]}),!!e.fields?.message&&n.jsx(o.Text,{size:"xs",accentColor:"danger",children:e.fields.message}),n.jsxs(o.ButtonGroup,{className:"flex items-center justify-end gap-2",size:"sm",children:[r&&n.jsx(o.Button,{type:"button",variant:"soft",accentColor:"base",onClick:r,children:"Cancel"}),n.jsx(o.Button,{type:"submit",variant:"surface",children:"Save"})]})]})});Kr.displayName="FormBuilderListBuilder";function Yr(i){const e=t=>{const r={};for(const[a,l]of Object.entries(t))typeof l=="string"?r[a]={type:"validate",message:l}:r[a]=e(l);return r};return e(i)}const Zr=d.memo(d.forwardRef((i,e)=>{const{disabled:t=!1,fieldSchema:r,values:a={},onValuesChange:l,onSubmit:s,submitText:h="Submit",hideSubmit:u=!1,cancelText:f,onCancel:p,hideCancel:g=!1,className:m,submitButtonProps:C,cancelButtonProps:v,cancelIcon:y,submitIcon:S,size:z="md"}=i,x=d.useMemo(()=>r.initializeValues(a),[r,a]),I=d.useCallback($=>{s?.($)},[s]),F=Y.useForm({values:x,mode:"onBlur",criteriaMode:"all",disabled:t,resolver:$=>{const X=r.validateValues($),K=Yr(X);return Object.keys(X).length>0?{values:{},errors:K}:{values:$,errors:{}}}}),w=d.useCallback($=>{l?.($)},[l]);d.useEffect(()=>{const{unsubscribe:$}=F.watch((X,{type:K})=>{K==="change"&&w(X)});return()=>{$()}},[F,w]);const T=tt(r.getFieldSections()),G=d.useMemo(()=>({fieldSchema:r,size:z}),[r,z]),ee=!g&&!!p,Be=!u;return n.jsx(Y.FormProvider,{...F,children:n.jsx(L,{value:G,children:n.jsxs("form",{ref:e,className:Q.cx(m,"flex flex-col gap-4"),onSubmit:F.handleSubmit(I),children:[n.jsx("div",{className:Ko({size:z}),children:T}),!t&&(ee||Be)?n.jsxs(o.ButtonGroup,{className:"flex items-center justify-end gap-2",size:z,children:[ee?n.jsxs(o.Button,{accentColor:"base",type:"button",variant:"soft",onClick:p,...v,children:[n.jsx(o.LuIcon,{icon:y??ne}),f]}):null,Be?n.jsxs(o.Button,{type:"submit",accentColor:"primary",variant:"surface",...C,children:[n.jsx(o.LuIcon,{icon:S??J}),h]}):null]}):null]})})})})),Qr=d.memo(()=>{const{fieldSchema:i}=d.use(R);return n.jsx(Zr,{fieldSchema:i,disabled:!1})});Qr.displayName="FormBuilderPreview";const Rr=d.memo(i=>{const{children:e,initialFields:t,onSave:r,onCancel:a,disableRequiredFields:l=!1}=i,s=d.useCallback(v=>{const y={};(!v.fields||v.fields.length===0)&&(y.fields="At least one field is required.");const S=[];for(const[I,F]of v.fields.entries())for(const[w,T]of F.fields.entries()){const G=Er(T.type,`fields.${I}.fields.${w}`)?.map(({field:ee})=>ee)??[];S.push(...G)}const z={};for(const I of S)z[I.identifier]=Un(v,I.identifier);const x=$n(S,z);return Object.keys(x).length>0&&(y.fields=x.fields),Object.keys(y).length>0&&o.toast.error({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),y},[]),h=d.useMemo(()=>({fields:t??[]}),[t]),u=Y.useForm({values:h,mode:"onSubmit",criteriaMode:"all",reValidateMode:"onSubmit",resolver:v=>{const y=s(v),S=Yr(y);return Object.keys(y).length>0?{values:{},errors:S}:{values:v,errors:{}}}}),f=d.useCallback(v=>{u.setValue("fields",v.serialize())},[u]),p=Y.useWatch({control:u.control,compute:v=>v.fields}),g=d.useMemo(()=>{const v=Fe.deserialize(p);return v.observe(f),v},[p,f]),m=d.useMemo(()=>({fieldSchema:g,disableRequiredFields:l,onSave:r,onCancel:a}),[l,r,a,g]),C=d.useMemo(()=>({fieldSchema:g,size:"sm"}),[g]);return n.jsx(R,{value:m,children:n.jsx(L,{value:C,children:n.jsx(Y.FormProvider,{...u,children:e})})})});Rr.displayName="FormBuilderRoot";const ra={Root:Rr,FlowBuilder:Hr,ListBuilder:Kr,Preview:Qr};c.BaseCondition=P,c.BaseField=k,c.BaseFormElement=Ai,c.BaseOptionsField=$e,c.BaseStringField=Ui,c.BooleanEqualsConditionModifier=zt,c.BooleanField=ce,c.BooleanFieldCondition=Ge,c.BooleanFieldConditionCell=Ht,c.BooleanFieldInput=Pi,c.BooleanNotEqualsConditionModifier=Ft,c.CheckboxListField=ue,c.CheckboxListFieldCondition=ke,c.CheckboxListFieldConditionCell=Wt,c.CheckboxListFieldInput=Gi,c.ConditionManager=bi,c.DateAfterConditionModifier=Mt,c.DateBeforeConditionModifier=Nt,c.DateEqualsConditionModifier=wt,c.DateField=be,c.DateFieldCondition=He,c.DateFieldConditionCell=Kt,c.DateFieldInput=ki,c.DateNotEqualsConditionModifier=bt,c.DateRangeInConditionModifier=xt,c.DateRangeNotInConditionModifier=It,c.DoesNotHaveFilesConditionModifier=Ot,c.FIELD_TYPES=Vt,c.FieldSchema=Fe,c.FieldSection=W,c.FieldSectionLayout=Ln,c.FieldTypeGroup=q,c.FieldTypeToClsMapping=pn,c.FieldsRenderer=Zr,c.FileCard=Bi,c.FormBuilder=ra,c.HasFilesConditionModifier=qt,c.ImageCard=Xi,c.ImageFile=we,c.ImageViewer=$i,c.ImageViewerProvider=nt,c.InputWithLabel=B,c.LONG_TEXT_FIELD_MAX_LENGTH=De,c.MultiSelectField=ie,c.MultiSelectFieldCondition=Je,c.MultiSelectFieldConditionCell=Zt,c.MultiSelectFieldInput=Hi,c.MultiStringField=de,c.MultiStringFieldCondition=We,c.MultiStringFieldConditionCell=Rt,c.MultiStringFieldInput=Di,c.NumberEqualsConditionModifier=mn,c.NumberField=H,c.NumberFieldCondition=Xe,c.NumberFieldConditionCell=ir,c.NumberFieldInput=ji,c.NumberGreaterThanConditionModifier=vn,c.NumberGreaterThanOrEqualsConditionModifier=Sn,c.NumberLessThanConditionModifier=Vn,c.NumberLessThanOrEqualsConditionModifier=yn,c.NumberNotEqualsConditionModifier=Cn,c.NumberRangeInConditionModifier=zn,c.NumberRangeNotInConditionModifier=Fn,c.OTPField=he,c.OTPFieldCondition=Ke,c.OTPFieldConditionCell=tr,c.OTPFieldInput=Wi,c.Observable=Ee,c.PassFailArrayExcludesConditionModifier=Bt,c.PassFailArrayIncludesConditionModifier=Lt,c.PassFailEqualsConditionModifier=_t,c.PassFailField=ge,c.PassFailFieldCondition=Ye,c.PassFailFieldConditionCell=or,c.PassFailFieldInput=Qi,c.PassFailNotEqualsConditionModifier=Tt,c.RadioField=me,c.RadioFieldCondition=Ze,c.RadioFieldConditionCell=lr,c.RadioFieldInput=en,c.RatingField=Ce,c.RatingFieldCondition=Qe,c.RatingFieldConditionCell=dr,c.RatingFieldInput=nn,c.SHORT_TEXT_FIELD_MAX_LENGTH=on,c.ScanField=Me,c.ScanFieldCondition=Re,c.ScanFieldConditionCell=ur,c.ScanFieldInput=rn,c.Scanner=fi,c.ScannerProvider=ft,c.SelectField=te,c.SelectFieldCondition=ei,c.SelectFieldConditionCell=fr,c.SelectFieldInput=Ji,c.StringArrayEqualsConditionModifier=Si,c.StringArrayEveryConditionModifier=Vi,c.StringArrayExcludesConditionModifier=bn,c.StringArrayIncludesConditionModifier=wn,c.StringArrayNoneConditionModifier=vi,c.StringArrayNotEqualsConditionModifier=zi,c.StringArraySomeConditionModifier=yi,c.StringEqualsConditionModifier=ae,c.StringExcludesConditionModifier=_e,c.StringField=Ve,c.StringFieldCondition=ii,c.StringFieldConditionCell=gr,c.StringFieldInput=an,c.StringIncludesConditionModifier=Oe,c.StringNotEqualsConditionModifier=le,c.TextField=ye,c.TextFieldCondition=ni,c.TextFieldConditionCell=Cr,c.TextFieldInput=ln,c.TimeAfterConditionModifier=Dt,c.TimeBeforeConditionModifier=$t,c.TimeEqualsConditionModifier=At,c.TimeField=xe,c.TimeFieldCondition=ti,c.TimeFieldConditionCell=yr,c.TimeFieldControl=Ci,c.TimeFieldInput=un,c.TimeNotEqualsConditionModifier=Et,c.TimeRangeInConditionModifier=Pt,c.TimeRangeNotInConditionModifier=jt,c.UNLABELLED_FIELD_LABEL=E,c.UNLABELLED_SECTION_LABEL=gn,c.URLField=Ie,c.URLFieldCondition=oi,c.URLFieldConditionCell=Fr,c.URLFieldInput=fn,c.UTC_OFFSETS=sn,c.UTC_OFFSETS_SET=pt,c.UUIDFile=re,c.UUIDPromise=pe,c.UploadField=ve,c.UploadFieldCondition=ri,c.UploadFieldConditionCell=Sr,c.UploadFieldInput=hn,c.VideoCard=Yi,c.VideoFile=Ki,c.areFieldValuesBlank=Br,c.areFieldValuesEqual=_n,c.areFileAndPromiseArraysEqual=hi,c.arePassFieldValuesEqual=dt,c.areSerializedPassFailFieldValuesEqual=ct,c.awaitFilesAndPromises=ta,c.blankFieldValues=Tn,c.changedFieldValues=Tr,c.cleanConditions=qn,c.cleanFieldValues=Mi,c.cleanSerializedConditions=In,c.cleanSerializedFieldValues=On,c.createCondition=Bn,c.createConditionModifierConfig=V,c.createField=qi,c.createTime=dn,c.deserialize=Mr,c.deserializeCondition=br,c.deserializeConditions=xn,c.deserializeField=Ni,c.deserializeFieldValues=Ir,c.deserializeFields=Ho,c.deserializeOnlyFields=Jo,c.deserializePassFailFieldValue=st,c.extractFilesAndPromisesFromFieldValues=qr,c.fieldDataMapping=_,c.fieldSpacingCva=xi,c.fieldTypeGroupDataMapping=yt,c.flattenFields=Wo,c.formatTime=mi,c.formatUTCOffset=gi,c.getCurrentUTCOffset=mt,c.getFieldsMapping=Xo,c.getUTCMinuteOfDay=oe,c.getUTCOffsetMinutes=Ct,c.initializeFieldValues=_r,c.insertFilesAndPromisesToFieldValues=Or,c.isFileAndPromiseArray=rt,c.isPassFailFieldStatus=Ri,c.isPassFailFieldValue=at,c.isSerializedPassFailFieldValue=ot,c.isStringArray=Ae,c.isTime=A,c.isTimeInRange=cn,c.isTimeRange=je,c.isUTCOffset=pi,c.maxFileSizeB=St,c.maxFileSizeKB=vt,c.maxFileSizeMB=qe,c.parseTime=Pe,c.passFailFieldStatusMapping=fe,c.passFailFieldStatuses=Ne,c.separateImagesFromFields=na,c.serializeConditions=Nr,c.serializeFieldValues=xr,c.serializePassFailFieldValue=lt,c.unchangedFieldValues=Lr,c.useConditionManager=Go,c.useFieldInput=D,c.useFieldInputs=ui,c.useFieldSectionInputs=tt,c.useImageViewer=ci,c.useObjectUrl=Ei,c.useScanner=Do,c.useScannerContext=ut,c.validateFieldValues=$n,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|
|
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"})}));
|