@app-studio/components 0.12.0 → 0.12.2
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/README.md +1 -1
- package/dist/alert.cjs.js +1 -1
- package/dist/alert.esm.mjs +1 -1
- package/dist/avatar.cjs.js +1 -1
- package/dist/avatar.esm.mjs +1 -1
- package/dist/button.cjs.js +1 -1
- package/dist/button.esm.mjs +1 -1
- package/dist/card.cjs.js +1 -1
- package/dist/card.esm.mjs +1 -1
- package/dist/checkbox.cjs.js +1 -1
- package/dist/checkbox.esm.mjs +1 -1
- package/dist/chunks/{Alert-Q1HlVX8f.mjs → Alert-B5vkpWXy.mjs} +55 -42
- package/dist/chunks/Alert-B5vkpWXy.mjs.map +1 -0
- package/dist/chunks/Alert-BHlgJZAo.cjs +2 -0
- package/dist/chunks/Alert-BHlgJZAo.cjs.map +1 -0
- package/dist/chunks/{AttachmentPreview-8d8gZ5kk.mjs → AttachmentPreview-B2-kP0Bn.mjs} +1745 -2997
- package/dist/chunks/AttachmentPreview-B2-kP0Bn.mjs.map +1 -0
- package/dist/chunks/AttachmentPreview-BZV6xSa4.cjs +2 -0
- package/dist/chunks/AttachmentPreview-BZV6xSa4.cjs.map +1 -0
- package/dist/chunks/{Avatar-D-GkyL2c.mjs → Avatar-CC1SDq6h.mjs} +34 -32
- package/dist/chunks/Avatar-CC1SDq6h.mjs.map +1 -0
- package/dist/chunks/Avatar-DtfD7QQ6.cjs +2 -0
- package/dist/chunks/Avatar-DtfD7QQ6.cjs.map +1 -0
- package/dist/chunks/Button.core-BB25t8wB.cjs +7 -0
- package/dist/chunks/Button.core-BB25t8wB.cjs.map +1 -0
- package/dist/chunks/{Button.core-Bc5cSn_z.mjs → Button.core-oxCH_VTn.mjs} +236 -222
- package/dist/chunks/Button.core-oxCH_VTn.mjs.map +1 -0
- package/dist/chunks/Button.pilot-BJK10U1-.mjs +6 -0
- package/dist/chunks/{Button.pilot-C4BIb08S.mjs.map → Button.pilot-BJK10U1-.mjs.map} +1 -1
- package/dist/chunks/Button.pilot-eWGY9Jm5.cjs +2 -0
- package/dist/chunks/{Button.pilot-JmR2DCSE.cjs.map → Button.pilot-eWGY9Jm5.cjs.map} +1 -1
- package/dist/chunks/Card-CK_D7gzP.cjs +2 -0
- package/dist/chunks/Card-CK_D7gzP.cjs.map +1 -0
- package/dist/chunks/Card-ymI5Thma.mjs +208 -0
- package/dist/chunks/Card-ymI5Thma.mjs.map +1 -0
- package/dist/chunks/Checkbox-BXbEChdd.cjs +2 -0
- package/dist/chunks/Checkbox-BXbEChdd.cjs.map +1 -0
- package/dist/chunks/Checkbox-DnwrApdj.mjs +21 -0
- package/dist/chunks/Checkbox-DnwrApdj.mjs.map +1 -0
- package/dist/chunks/Checkbox.view-B7K8ycvs.cjs +2 -0
- package/dist/chunks/Checkbox.view-B7K8ycvs.cjs.map +1 -0
- package/dist/chunks/{Checkbox.view-dhc-rfEX.mjs → Checkbox.view-CCGfVtqr.mjs} +140 -119
- package/dist/chunks/Checkbox.view-CCGfVtqr.mjs.map +1 -0
- package/dist/chunks/{Formik.Uploader-DRIyxMI0.mjs → Formik.Uploader-CIYySBWB.mjs} +18 -18
- package/dist/chunks/{Formik.Uploader-DRIyxMI0.mjs.map → Formik.Uploader-CIYySBWB.mjs.map} +1 -1
- package/dist/chunks/{Formik.Uploader-D0nzjyau.cjs → Formik.Uploader-DePTdd7A.cjs} +4 -4
- package/dist/chunks/{Formik.Uploader-D0nzjyau.cjs.map → Formik.Uploader-DePTdd7A.cjs.map} +1 -1
- package/dist/chunks/{Icon-DrAZswNH.mjs → Icon-Cy5kEVYz.mjs} +60 -60
- package/dist/chunks/{Icon-DrAZswNH.mjs.map → Icon-Cy5kEVYz.mjs.map} +1 -1
- package/dist/chunks/Modal-BzlrQQu5.cjs +2 -0
- package/dist/chunks/Modal-BzlrQQu5.cjs.map +1 -0
- package/dist/chunks/{Modal-DkckCT8-.mjs → Modal-CqbUQXoc.mjs} +92 -75
- package/dist/chunks/Modal-CqbUQXoc.mjs.map +1 -0
- package/dist/chunks/Select-CrOxhfvQ.mjs +28 -0
- package/dist/chunks/Select-CrOxhfvQ.mjs.map +1 -0
- package/dist/chunks/Select-DRMUC3NX.cjs +2 -0
- package/dist/chunks/Select-DRMUC3NX.cjs.map +1 -0
- package/dist/chunks/{Select.view-CPMqT8pn.mjs → Select.view-BHMiRNIc.mjs} +126 -124
- package/dist/chunks/Select.view-BHMiRNIc.mjs.map +1 -0
- package/dist/chunks/Select.view-BV01zWHM.cjs +2 -0
- package/dist/chunks/Select.view-BV01zWHM.cjs.map +1 -0
- package/dist/chunks/{Switch-DWx1g3jT.mjs → Switch-04GGHGrV.mjs} +2 -2
- package/dist/chunks/{Switch-DWx1g3jT.mjs.map → Switch-04GGHGrV.mjs.map} +1 -1
- package/dist/chunks/{Switch-D80yPNFV.cjs → Switch-DqgmPp8M.cjs} +2 -2
- package/dist/chunks/{Switch-D80yPNFV.cjs.map → Switch-DqgmPp8M.cjs.map} +1 -1
- package/dist/chunks/Switch.view-6ncV6Ifz.cjs +2 -0
- package/dist/chunks/Switch.view-6ncV6Ifz.cjs.map +1 -0
- package/dist/chunks/{Switch.view-QLZ7O5Z7.mjs → Switch.view-DUvFLhyy.mjs} +34 -39
- package/dist/chunks/Switch.view-DUvFLhyy.mjs.map +1 -0
- package/dist/chunks/Tabs-BdoE88Ee.mjs +567 -0
- package/dist/chunks/Tabs-BdoE88Ee.mjs.map +1 -0
- package/dist/chunks/Tabs-DneEt-le.cjs +2 -0
- package/dist/chunks/Tabs-DneEt-le.cjs.map +1 -0
- package/dist/chunks/{TextField-DOU2CL5J.mjs → TextField-Bwc_F2Rq.mjs} +97 -86
- package/dist/chunks/TextField-Bwc_F2Rq.mjs.map +1 -0
- package/dist/chunks/TextField-CwaxvcqN.cjs +2 -0
- package/dist/chunks/TextField-CwaxvcqN.cjs.map +1 -0
- package/dist/chunks/{default-nRKhMTzF.mjs → default-1F10zins.mjs} +2 -2
- package/dist/chunks/{default-nRKhMTzF.mjs.map → default-1F10zins.mjs.map} +1 -1
- package/dist/chunks/default-W-NMTEJ3.cjs +2 -0
- package/dist/chunks/default-W-NMTEJ3.cjs.map +1 -0
- package/dist/chunks/designSystem.page-BgmjSYsz.cjs +11 -0
- package/dist/chunks/designSystem.page-BgmjSYsz.cjs.map +1 -0
- package/dist/chunks/{designSystem.page-K0ajTvy7.mjs → designSystem.page-CM_h09Ui.mjs} +18 -16
- package/dist/chunks/designSystem.page-CM_h09Ui.mjs.map +1 -0
- package/dist/chunks/{FieldWrapper-Bb0j8Iog.mjs → useFieldDesignSystemProps-BZj7d9gK.mjs} +118 -87
- package/dist/chunks/useFieldDesignSystemProps-BZj7d9gK.mjs.map +1 -0
- package/dist/chunks/useFieldDesignSystemProps-CgVU3R10.cjs +2 -0
- package/dist/chunks/useFieldDesignSystemProps-CgVU3R10.cjs.map +1 -0
- package/dist/design-system-preview.cjs.js +1 -1
- package/dist/design-system-preview.esm.mjs +14 -14
- package/dist/formik.cjs.js +1 -1
- package/dist/formik.esm.mjs +2 -2
- package/dist/link.esm.mjs +1 -1
- package/dist/modal.cjs.js +1 -1
- package/dist/modal.esm.mjs +1 -1
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.native.js +13 -5
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.native.js.map +1 -1
- package/dist/native/components/Alert/Alert/Alert.view.d.ts +3 -1
- package/dist/native/components/Alert/Alert/Alert.view.js +16 -6
- package/dist/native/components/Alert/Alert/Alert.view.js.map +1 -1
- package/dist/native/components/Alert/Alert/Alert.view.native.d.ts +3 -1
- package/dist/native/components/Alert/Alert/Alert.view.native.js +15 -4
- package/dist/native/components/Alert/Alert/Alert.view.native.js.map +1 -1
- package/dist/native/components/Alert/Alert.js +3 -3
- package/dist/native/components/Alert/Alert.js.map +1 -1
- package/dist/native/components/Avatar/Avatar/Avatar.props.d.ts +1 -1
- package/dist/native/components/Avatar/Avatar/Avatar.state.d.ts +2 -2
- package/dist/native/components/Avatar/Avatar/Avatar.state.js +6 -5
- package/dist/native/components/Avatar/Avatar/Avatar.state.js.map +1 -1
- package/dist/native/components/Avatar/Avatar/Avatar.view.d.ts +1 -1
- package/dist/native/components/Avatar/Avatar/Avatar.view.js +2 -2
- package/dist/native/components/Avatar/Avatar/Avatar.view.js.map +1 -1
- package/dist/native/components/Avatar/Avatar.js +2 -2
- package/dist/native/components/Avatar/Avatar.js.map +1 -1
- package/dist/native/components/Button/Button/Button.style.js +11 -6
- package/dist/native/components/Button/Button/Button.style.js.map +1 -1
- package/dist/native/components/Button/Button/Button.view.d.ts +2 -0
- package/dist/native/components/Button/Button/Button.view.js +9 -3
- package/dist/native/components/Button/Button/Button.view.js.map +1 -1
- package/dist/native/components/Button/Button/Button.view.native.d.ts +1 -0
- package/dist/native/components/Button/Button/Button.view.native.js +19 -4
- package/dist/native/components/Button/Button/Button.view.native.js.map +1 -1
- package/dist/native/components/Button/Button.core.js +3 -3
- package/dist/native/components/Button/Button.core.js.map +1 -1
- package/dist/native/components/Card/Card/Card.view.d.ts +3 -1
- package/dist/native/components/Card/Card/Card.view.js +32 -24
- package/dist/native/components/Card/Card/Card.view.js.map +1 -1
- package/dist/native/components/Card/Card.js +3 -3
- package/dist/native/components/Card/Card.js.map +1 -1
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.props.d.ts +1 -0
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.state.d.ts +5 -1
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.state.js +13 -0
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.state.js.map +1 -1
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.style.d.ts +3 -12
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.style.js +3 -12
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.style.js.map +1 -1
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.view.js +19 -16
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.view.js.map +1 -1
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.view.native.js +36 -30
- package/dist/native/components/Form/Checkbox/Checkbox/Checkbox.view.native.js.map +1 -1
- package/dist/native/components/Form/Checkbox/Checkbox.js +3 -3
- package/dist/native/components/Form/Checkbox/Checkbox.js.map +1 -1
- package/dist/native/components/Form/DatePicker/DatePicker/DatePicker.state.js +8 -2
- package/dist/native/components/Form/DatePicker/DatePicker/DatePicker.state.js.map +1 -1
- package/dist/native/components/Form/Select/Select/Select.props.d.ts +1 -0
- package/dist/native/components/Form/Select/Select/Select.view.js +2 -2
- package/dist/native/components/Form/Select/Select/Select.view.js.map +1 -1
- package/dist/native/components/Form/Select/Select/Select.view.native.js +17 -4
- package/dist/native/components/Form/Select/Select/Select.view.native.js.map +1 -1
- package/dist/native/components/Form/Select/Select.js +3 -3
- package/dist/native/components/Form/Select/Select.js.map +1 -1
- package/dist/native/components/Form/Switch/Switch/Switch.style.d.ts +3 -8
- package/dist/native/components/Form/Switch/Switch/Switch.style.js +3 -8
- package/dist/native/components/Form/Switch/Switch/Switch.style.js.map +1 -1
- package/dist/native/components/Form/Switch/Switch/Switch.view.js +1 -5
- package/dist/native/components/Form/Switch/Switch/Switch.view.js.map +1 -1
- package/dist/native/components/Form/Switch/Switch/Switch.view.native.js +7 -4
- package/dist/native/components/Form/Switch/Switch/Switch.view.native.js.map +1 -1
- package/dist/native/components/Form/TextField/TextField/TextField.props.d.ts +1 -0
- package/dist/native/components/Form/TextField/TextField/TextField.view.js +2 -2
- package/dist/native/components/Form/TextField/TextField/TextField.view.js.map +1 -1
- package/dist/native/components/Form/TextField/TextField/TextField.view.native.js +9 -4
- package/dist/native/components/Form/TextField/TextField/TextField.view.native.js.map +1 -1
- package/dist/native/components/Form/TextField/TextField.js +3 -3
- package/dist/native/components/Form/TextField/TextField.js.map +1 -1
- package/dist/native/components/Input/FieldContent/FieldContent/FieldContent.props.d.ts +1 -0
- package/dist/native/components/Input/FieldContent/FieldContent.js +16 -3
- package/dist/native/components/Input/FieldContent/FieldContent.js.map +1 -1
- package/dist/native/components/Input/useFieldDesignSystemProps.d.ts +9 -0
- package/dist/native/components/Input/useFieldDesignSystemProps.js +15 -0
- package/dist/native/components/Input/useFieldDesignSystemProps.js.map +1 -0
- package/dist/native/components/Modal/Modal/Modal.props.d.ts +2 -0
- package/dist/native/components/Modal/Modal/Modal.view.js +6 -4
- package/dist/native/components/Modal/Modal/Modal.view.js.map +1 -1
- package/dist/native/components/Modal/Modal/Modal.view.native.js +5 -4
- package/dist/native/components/Modal/Modal/Modal.view.native.js.map +1 -1
- package/dist/native/components/Tabs/Tabs/TabHeader.d.ts +2 -0
- package/dist/native/components/Tabs/Tabs/TabHeader.js +7 -6
- package/dist/native/components/Tabs/Tabs/TabHeader.js.map +1 -1
- package/dist/native/components/Tabs/Tabs/Tabs.props.d.ts +10 -0
- package/dist/native/components/Tabs/Tabs/Tabs.state.d.ts +1 -0
- package/dist/native/components/Tabs/Tabs/Tabs.state.js +20 -43
- package/dist/native/components/Tabs/Tabs/Tabs.state.js.map +1 -1
- package/dist/native/components/Tabs/Tabs/Tabs.styles.d.ts +11 -0
- package/dist/native/components/Tabs/Tabs/Tabs.styles.js +7 -0
- package/dist/native/components/Tabs/Tabs/Tabs.styles.js.map +1 -0
- package/dist/native/components/Tabs/Tabs/Tabs.type.d.ts +4 -0
- package/dist/native/components/Tabs/Tabs/Tabs.view.js +146 -58
- package/dist/native/components/Tabs/Tabs/Tabs.view.js.map +1 -1
- package/dist/native/components/Tabs/Tabs/Tabs.view.native.js +83 -19
- package/dist/native/components/Tabs/Tabs/Tabs.view.native.js.map +1 -1
- package/dist/native/components/Tabs/Tabs.js +8 -8
- package/dist/native/components/Tabs/Tabs.js.map +1 -1
- package/dist/native/components/index.js +1 -1
- package/dist/native/components/index.js.map +1 -1
- package/dist/native/components/pilot/blocks/SettingsPanel.js +3 -1
- package/dist/native/components/pilot/blocks/SettingsPanel.js.map +1 -1
- package/dist/native/components/pilot/blocks/SignIn.js +3 -1
- package/dist/native/components/pilot/blocks/SignIn.js.map +1 -1
- package/dist/native/design-system/DesignSystemProvider.d.ts +1 -1
- package/dist/native/design-system/DesignSystemProvider.js +2 -2
- package/dist/native/design-system/DesignSystemProvider.js.map +1 -1
- package/dist/native/design-system/configs/default.json +1 -1
- package/dist/native/design-system/theme.d.ts +10 -1
- package/dist/native/design-system/theme.js +41 -12
- package/dist/native/design-system/theme.js.map +1 -1
- package/dist/native/design-system/types.d.ts +3 -9
- package/dist/native/design-system/utils.d.ts +5 -2
- package/dist/native/design-system/utils.js +42 -10
- package/dist/native/design-system/utils.js.map +1 -1
- package/dist/presets.cjs.js +1 -1
- package/dist/presets.esm.mjs +1 -1
- package/dist/registry/alert.json +13 -12
- package/dist/registry/avatar.json +15 -15
- package/dist/registry/button.json +14 -12
- package/dist/registry/card.json +13 -13
- package/dist/registry/checkbox.json +14 -11
- package/dist/registry/modal.json +8 -4
- package/dist/registry/registry.json +178 -78
- package/dist/registry/select.json +20 -12
- package/dist/registry/settings-panel.json +6 -2
- package/dist/registry/sign-in.json +6 -2
- package/dist/registry/switch.json +15 -15
- package/dist/registry/tabs.json +23 -18
- package/dist/registry/text-field.json +19 -11
- package/dist/registry/theme.json +71 -0
- package/dist/select.cjs.js +1 -1
- package/dist/select.esm.mjs +1 -1
- package/dist/settings-panel.cjs.js +1 -1
- package/dist/settings-panel.cjs.js.map +1 -1
- package/dist/settings-panel.esm.mjs +9 -9
- package/dist/settings-panel.esm.mjs.map +1 -1
- package/dist/sign-in.cjs.js +1 -1
- package/dist/sign-in.cjs.js.map +1 -1
- package/dist/sign-in.esm.mjs +15 -15
- package/dist/sign-in.esm.mjs.map +1 -1
- package/dist/switch.cjs.js +1 -1
- package/dist/switch.esm.mjs +1 -1
- package/dist/tabs.cjs.js +1 -1
- package/dist/tabs.esm.mjs +1 -1
- package/dist/text-field.cjs.js +1 -1
- package/dist/text-field.esm.mjs +1 -1
- package/dist/theme.cjs.js +1 -1
- package/dist/theme.cjs.js.map +1 -1
- package/dist/theme.esm.mjs +125 -72
- package/dist/theme.esm.mjs.map +1 -1
- package/dist/types/components/Alert/Alert/Alert.view.d.ts +3 -1
- package/dist/types/components/Avatar/Avatar/Avatar.props.d.ts +1 -1
- package/dist/types/components/Avatar/Avatar/Avatar.state.d.ts +2 -2
- package/dist/types/components/Avatar/Avatar/Avatar.view.d.ts +1 -1
- package/dist/types/components/Button/Button/Button.view.d.ts +2 -0
- package/dist/types/components/Card/Card/Card.view.d.ts +3 -1
- package/dist/types/components/Form/Checkbox/Checkbox/Checkbox.props.d.ts +1 -0
- package/dist/types/components/Form/Checkbox/Checkbox/Checkbox.state.d.ts +5 -1
- package/dist/types/components/Form/Checkbox/Checkbox/Checkbox.style.d.ts +3 -12
- package/dist/types/components/Form/Select/Select/Select.props.d.ts +1 -0
- package/dist/types/components/Form/Switch/Switch/Switch.style.d.ts +3 -8
- package/dist/types/components/Form/TextField/TextField/TextField.props.d.ts +1 -0
- package/dist/types/components/IconPicker/IconPicker/IconPicker.state.d.ts +2 -2
- package/dist/types/components/Input/FieldContent/FieldContent/FieldContent.props.d.ts +1 -0
- package/dist/types/components/Input/useFieldDesignSystemProps.d.ts +9 -0
- package/dist/types/components/Modal/Modal/Modal.props.d.ts +2 -0
- package/dist/types/components/Tabs/Tabs/TabHeader.d.ts +2 -0
- package/dist/types/components/Tabs/Tabs/Tabs.props.d.ts +10 -0
- package/dist/types/components/Tabs/Tabs/Tabs.state.d.ts +1 -0
- package/dist/types/components/Tabs/Tabs/Tabs.styles.d.ts +11 -0
- package/dist/types/components/Tabs/Tabs/Tabs.type.d.ts +4 -0
- package/dist/types/design-system/DesignSystemProvider.d.ts +1 -1
- package/dist/types/design-system/configs/default.json.d.ts +1 -1
- package/dist/types/design-system/theme.d.ts +10 -1
- package/dist/types/design-system/types.d.ts +3 -9
- package/dist/types/design-system/utils.d.ts +5 -2
- package/dist/web.cjs.js +16 -16
- package/dist/web.esm.mjs +44 -41
- package/dist/web.umd.js +38 -38
- package/dist/web.umd.js.map +1 -1
- package/docs/getting-started/react-native.md +17 -3
- package/docs/guides/performance.mdx +5 -0
- package/docs/guides/react-native.mdx +10 -0
- package/docs/guides/registry-guide.mdx +72 -8
- package/package.json +6 -4
- package/dist/chunks/Alert-Bjl40k3x.cjs +0 -2
- package/dist/chunks/Alert-Bjl40k3x.cjs.map +0 -1
- package/dist/chunks/Alert-Q1HlVX8f.mjs.map +0 -1
- package/dist/chunks/AttachmentPreview-8d8gZ5kk.mjs.map +0 -1
- package/dist/chunks/AttachmentPreview-Bwrz5TJh.cjs +0 -2
- package/dist/chunks/AttachmentPreview-Bwrz5TJh.cjs.map +0 -1
- package/dist/chunks/Avatar-BB0DeN9j.cjs +0 -2
- package/dist/chunks/Avatar-BB0DeN9j.cjs.map +0 -1
- package/dist/chunks/Avatar-D-GkyL2c.mjs.map +0 -1
- package/dist/chunks/Button.core-Bc5cSn_z.mjs.map +0 -1
- package/dist/chunks/Button.core-BhtOm8ak.cjs +0 -7
- package/dist/chunks/Button.core-BhtOm8ak.cjs.map +0 -1
- package/dist/chunks/Button.pilot-C4BIb08S.mjs +0 -6
- package/dist/chunks/Button.pilot-JmR2DCSE.cjs +0 -2
- package/dist/chunks/Card-CNSl9fD5.cjs +0 -2
- package/dist/chunks/Card-CNSl9fD5.cjs.map +0 -1
- package/dist/chunks/Card-DMhV_NTt.mjs +0 -200
- package/dist/chunks/Card-DMhV_NTt.mjs.map +0 -1
- package/dist/chunks/Checkbox-Bo7IRVRE.mjs +0 -11
- package/dist/chunks/Checkbox-Bo7IRVRE.mjs.map +0 -1
- package/dist/chunks/Checkbox-CAI6RtuO.cjs +0 -2
- package/dist/chunks/Checkbox-CAI6RtuO.cjs.map +0 -1
- package/dist/chunks/Checkbox.view-DGdNPlF9.cjs +0 -2
- package/dist/chunks/Checkbox.view-DGdNPlF9.cjs.map +0 -1
- package/dist/chunks/Checkbox.view-dhc-rfEX.mjs.map +0 -1
- package/dist/chunks/FieldWrapper-Bb0j8Iog.mjs.map +0 -1
- package/dist/chunks/FieldWrapper-DRCn7BLi.cjs +0 -2
- package/dist/chunks/FieldWrapper-DRCn7BLi.cjs.map +0 -1
- package/dist/chunks/Modal-DkckCT8-.mjs.map +0 -1
- package/dist/chunks/Modal-zok954As.cjs +0 -2
- package/dist/chunks/Modal-zok954As.cjs.map +0 -1
- package/dist/chunks/Select-C6R0Tei-.cjs +0 -2
- package/dist/chunks/Select-C6R0Tei-.cjs.map +0 -1
- package/dist/chunks/Select-C7IBNyjR.mjs +0 -24
- package/dist/chunks/Select-C7IBNyjR.mjs.map +0 -1
- package/dist/chunks/Select.view-CPMqT8pn.mjs.map +0 -1
- package/dist/chunks/Select.view-Pq1yAcMm.cjs +0 -2
- package/dist/chunks/Select.view-Pq1yAcMm.cjs.map +0 -1
- package/dist/chunks/Switch.view-CQZO_Js7.cjs +0 -2
- package/dist/chunks/Switch.view-CQZO_Js7.cjs.map +0 -1
- package/dist/chunks/Switch.view-QLZ7O5Z7.mjs.map +0 -1
- package/dist/chunks/Tabs-D5chMrkE.mjs +0 -403
- package/dist/chunks/Tabs-D5chMrkE.mjs.map +0 -1
- package/dist/chunks/Tabs-DQeBJwkz.cjs +0 -2
- package/dist/chunks/Tabs-DQeBJwkz.cjs.map +0 -1
- package/dist/chunks/TextField-DOU2CL5J.mjs.map +0 -1
- package/dist/chunks/TextField-Da4JCcAU.cjs +0 -2
- package/dist/chunks/TextField-Da4JCcAU.cjs.map +0 -1
- package/dist/chunks/default-D7ePSMKP.cjs +0 -2
- package/dist/chunks/default-D7ePSMKP.cjs.map +0 -1
- package/dist/chunks/designSystem.page-B74Vm2Dt.cjs +0 -11
- package/dist/chunks/designSystem.page-B74Vm2Dt.cjs.map +0 -1
- package/dist/chunks/designSystem.page-K0ajTvy7.mjs.map +0 -1
package/dist/web.cjs.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./chunks/designSystem.page-B74Vm2Dt.cjs"),n=require("react/jsx-runtime"),C=require("react"),h=require("app-studio"),ht=require("./chunks/Select.view-Pq1yAcMm.cjs"),E=require("./chunks/Icon-C37alecH.cjs"),Nt=require("./chunks/Alert-Bjl40k3x.cjs"),ce=require("./chunks/Formik.Uploader-D0nzjyau.cjs"),Ut=require("./chunks/Avatar-BB0DeN9j.cjs"),_t=require("./chunks/Card-CNSl9fD5.cjs"),$e=require("./chunks/Loader-4V81BN95.cjs"),qt=require("./chunks/Select-C6R0Tei-.cjs"),Xt=require("./chunks/Switch-D80yPNFV.cjs"),K=require("./chunks/AttachmentPreview-Bwrz5TJh.cjs"),Me=require("./chunks/TextField-Da4JCcAU.cjs"),Yt=require("./chunks/Checkbox-CAI6RtuO.cjs"),Ye=require("./link.cjs.js"),vt=require("./chunks/Tabs-DQeBJwkz.cjs"),ye=require("./theme.cjs.js"),Qe=require("./presets.cjs.js"),we=require("./chunks/Modal-zok954As.cjs"),Je=require("./chunks/Router-DjmVh9pK.cjs"),et=require("./chunks/Router.store-Bxe2uZWk.cjs"),Kt=({isOpen:e,defaultOpen:t=!1,value:r,defaultValue:g,isMulti:o=!1,onOpenChange:a,onClose:c})=>{const b=typeof e=="boolean",i=r!==void 0,s=g??(o?[]:""),[l,f]=C.useState(t),[x,y]=C.useState(s),u=b?!!e:l,j=i?r:x,S=C.useCallback(m=>{b||f(m),a==null||a(m),m||c==null||c()},[b,c,a]),D=C.useCallback(()=>{S(!1)},[S]),d=C.useCallback(m=>{i||y(m)},[i]);return{isSheetOpen:u,selectedValue:j,setSelectedValue:d,closeSheet:D}},Gt={sm:{minHeight:44,paddingVertical:10,paddingHorizontal:16},md:{minHeight:52,paddingVertical:12,paddingHorizontal:18},lg:{minHeight:60,paddingVertical:14,paddingHorizontal:20}},je={sm:{label:14,description:12},md:{label:16,description:13},lg:{label:18,description:14}},at=(e,t)=>e.id??e.value??`action-sheet-item-${t}`,gt=e=>e.value??e.id,ct=e=>e.disabled||e.isDisabled||e.divider,Zt=(e,t)=>{if(typeof e.selected=="boolean")return e.selected;const r=gt(e);return r?Array.isArray(t)?t.includes(r):t===r:!1},Qt=({isSheetOpen:e,closeSheet:t,selectedValue:r,setSelectedValue:g,isClosePrevented:o=!1,dismissOnBackdropPress:a=!0,title:c,description:b,header:i,children:s,items:l=[],isMulti:f=!1,closeOnSelect:x,onSelect:y,onChange:u,showCancel:j=!1,cancelLabel:S="Cancel",onCancel:D,showHandle:d=!0,size:m="md",maxHeight:I="88vh",views:k,animationType:M,...p})=>{if(!e)return null;const w=()=>{o||t()},R=()=>{a&&w()},B=()=>{D==null||D(),w()},W=A=>{var _;if(ct(A))return;const V=gt(A);let O=r;if(V){if(f){const Z=Array.isArray(r)?r:r?[r]:[];O=Z.includes(V)?Z.filter(Y=>Y!==V):[...Z,V]}else O=V;g(O),y==null||y(V,A),u==null||u(O,A)}(_=A.onPress)==null||_.call(A,A),(A.closeOnSelect??x??!f)&&w()};return n.jsx(ht.Portal,{children:n.jsx(h.View,{position:"fixed",top:0,right:0,bottom:0,left:0,zIndex:9999,backgroundColor:"color-dark-50-360",display:"flex",justifyContent:"flex-end",onClick:R,...k==null?void 0:k.overlay,children:n.jsxs(h.Vertical,{width:"100%",maxWidth:520,maxHeight:I,marginHorizontal:"auto",backgroundColor:"color-white",borderTopLeftRadius:24,borderTopRightRadius:24,paddingTop:8,paddingBottom:12,overflow:"hidden",boxShadow:"0 -18px 48px rgba(15, 23, 42, 0.18)",onClick:A=>A.stopPropagation(),...k==null?void 0:k.container,...k==null?void 0:k.sheet,...p,children:[d&&n.jsx(h.View,{width:36,height:4,borderRadius:999,backgroundColor:"color-gray-300",alignSelf:"center",marginTop:4,marginBottom:8,...k==null?void 0:k.handle}),(c||b)&&n.jsxs(h.Vertical,{paddingHorizontal:20,paddingTop:6,paddingBottom:12,gap:4,...k==null?void 0:k.header,children:[c&&n.jsx(h.Text,{fontSize:18,lineHeight:24,fontWeight:"600",color:"color-gray-900",...k==null?void 0:k.title,children:c}),b&&n.jsx(h.Text,{fontSize:13,lineHeight:18,color:"color-gray-500",...k==null?void 0:k.description,children:b})]}),i,n.jsxs(h.Vertical,{overflowY:"auto",paddingBottom:4,...k==null?void 0:k.content,children:[l.map((A,V)=>{if(A.divider)return n.jsx(h.View,{height:1,backgroundColor:"color-gray-200",marginVertical:6,...k==null?void 0:k.divider},at(A,V));const O=Zt(A,r),N=ct(A),_=N?"color-gray-400":A.destructive?"color-red-600":O?"theme-primary":"color-gray-900";return n.jsxs(h.Horizontal,{alignItems:"center",gap:12,opacity:N?.5:1,cursor:N?"not-allowed":"pointer",onClick:()=>W(A),...Gt[m],...k==null?void 0:k.item,children:[A.icon&&n.jsx(h.View,{flexShrink:0,...k==null?void 0:k.itemIcon,children:A.icon}),n.jsxs(h.Vertical,{flex:1,gap:2,children:[typeof A.label=="string"?n.jsx(h.Text,{fontSize:je[m].label,lineHeight:je[m].label+6,fontWeight:O?"600":"400",color:_,...k==null?void 0:k.itemLabel,children:A.label}):A.label,A.description&&n.jsx(h.Text,{fontSize:je[m].description,lineHeight:je[m].description+5,color:"color-gray-500",...k==null?void 0:k.itemDescription,children:A.description})]}),O&&n.jsx(E.TickIcon,{widthHeight:18,color:"theme-primary",...k==null?void 0:k.itemIndicator})]},at(A,V))}),s]}),j&&n.jsx(h.View,{marginTop:8,paddingHorizontal:12,paddingTop:8,borderTopWidth:1,borderTopColor:"color-gray-200",children:n.jsx(h.Horizontal,{minHeight:52,alignItems:"center",justifyContent:"center",borderRadius:14,backgroundColor:"color-gray-100",cursor:"pointer",onClick:B,...k==null?void 0:k.cancelButton,children:n.jsx(h.Text,{fontSize:je[m].label,lineHeight:je[m].label+6,fontWeight:"600",color:"color-gray-900",...k==null?void 0:k.cancelLabel,children:S})})})]})})})},Jt=e=>{const t=Kt(e);return n.jsx(Qt,{...e,...t})},en=Jt,Ie=P.DEFAULT_CHART_COLORS,tn={width:"100%",height:"100%",position:"relative",display:"flex",flexDirection:"column"},nn={fontSize:"18px",fontWeight:"700",marginBottom:"24px",textAlign:"center",color:"color-gray-900"},rn={display:"flex",flexWrap:"wrap",justifyContent:"flex-start",marginTop:"16px",gap:"12px"},on={display:"flex",alignItems:"center",padding:"4px 8px",borderRadius:"6px",cursor:"pointer",transition:"background-color 0.2s ease",_hover:{backgroundColor:"color-gray-50"}},an={width:"10px",height:"10px",borderRadius:"50%",marginRight:"8px"},cn={fontSize:"13px",fontWeight:"500",color:"color-gray-600"},Pe={position:"absolute",backgroundColor:"color-white",padding:"12px 16px",borderRadius:"8px",boxShadow:"0px 12px 24px rgba(15, 23, 42, 0.18)",border:"1px solid color-gray-200",fontSize:"14px",display:"flex",flexDirection:"column",pointerEvents:"none",zIndex:100},pt={stroke:"color-gray-100",strokeWidth:"1px",strokeDasharray:"4 4"},ze={stroke:"color-gray-200",strokeWidth:"1px"},Ne={fontSize:"12px",fill:"color-gray-500",fontWeight:"500"},ln={rx:"4px",ry:"4px",cursor:"pointer",transition:"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",_hover:{filter:"brightness(1.1)"}},sn={strokeWidth:"3px",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",transition:"stroke-width 0.2s ease"},dn={r:"5px",strokeWidth:"2.5px",stroke:"color-white",cursor:"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",_hover:{r:"7px"}},Fe={strokeWidth:"2px",stroke:"color-white",cursor:"pointer",transition:"all 0.3s ease",_hover:{transform:"scale(1.02)"}},tt={position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"color-white-800",borderRadius:"4px",zIndex:10,padding:"24px",textAlign:"center"},un={...tt},hn={...tt,backgroundColor:"rgba(254, 242, 242, 0.8)",color:"color-red-600"},gn={...tt,backgroundColor:"rgba(249, 250, 251, 0.8)",color:"color-gray-500"},pn=({data:e,dataPoints:t,animated:r=!0,animationDuration:g=500,showTooltips:o=!0})=>{const[a,c]=C.useState(r?0:1),[b,i]=C.useState({visible:!1,x:0,y:0,content:null}),s=C.useRef(null),l=C.useRef(null);C.useEffect(()=>{if(!r){c(1);return}const d=Date.now(),m=()=>{const I=Date.now()-d,k=Math.min(I/g,1);c(k),k<1&&(s.current=requestAnimationFrame(m))};return s.current=requestAnimationFrame(m),()=>{s.current&&cancelAnimationFrame(s.current)}},[r,g]);const[f,x]=C.useState(new Set),y=C.useCallback(d=>{x(m=>{const I=new Set(m);return I.has(d)?I.delete(d):I.add(d),I})},[]),u=C.useCallback(()=>e?{...e,series:e.series.map((d,m)=>({...d,color:d.color||Ie[m%Ie.length],hidden:f.has(d.name)}))}:t?t.map((d,m)=>({...d,color:d.color||Ie[m%Ie.length],hidden:f.has(d.label)})):null,[e,t,f]),j=C.useCallback((d,m,I)=>{o&&i({visible:!0,x:d,y:m,content:I})},[o]),S=C.useCallback(()=>{i(d=>({...d,visible:!1}))},[]),D=C.useCallback(()=>{if(!l.current)return{width:0,height:0};const{width:d,height:m}=l.current.getBoundingClientRect();return{width:d,height:m}},[]);return{animationProgress:a,tooltip:b,containerRef:l,processedData:u,showTooltip:j,hideTooltip:S,getChartDimensions:D,toggleSeries:y}},fn=({data:e,width:t,height:r,animationProgress:g,showGrid:o=!0,onBarClick:a,showTooltip:c,hideTooltip:b,views:i})=>{const{getColor:s}=h.useTheme(),l={top:20,right:20,bottom:40,left:50},f=t-l.left-l.right,x=r-l.top-l.bottom,y=C.useMemo(()=>{let k=0;return e.series.forEach(M=>{M.data.forEach(p=>{k=Math.max(k,p)})}),k},[e]),u=e.labels.length,j=e.series.length,S=f/u,D=S*.8/j,d=S*.2/(j+1),m=y||10,I=C.useMemo(()=>{const M=[];for(let p=0;p<=5;p++){const w=m/5*p;M.push(w)}return M},[y]);return n.jsxs("svg",{width:t,height:r,children:[n.jsx("defs",{children:e.series.map((k,M)=>{const p=k.color?s(k.color):"black";return n.jsxs("linearGradient",{id:`bar-gradient-${M}`,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[n.jsx("stop",{offset:"0%",stopColor:p,stopOpacity:1}),n.jsx("stop",{offset:"100%",stopColor:p,stopOpacity:.7})]},`bar-gradient-${M}`)})}),n.jsx("line",{x1:l.left,y1:r-l.bottom,x2:t-l.right,y2:r-l.bottom,...ze,...i==null?void 0:i.axis}),n.jsx("line",{x1:l.left,y1:l.top,x2:l.left,y2:r-l.bottom,...ze,...i==null?void 0:i.axis}),e.labels.map((k,M)=>{const p=l.left+(M+.5)*S,w=r-l.bottom+20;return n.jsx("text",{x:p,y:w,textAnchor:"middle",...Ne,...i==null?void 0:i.axisLabel,children:k},`x-label-${M}`)}),I.map((k,M)=>{const p=r-l.bottom-k/m*x;return n.jsxs(C.Fragment,{children:[n.jsx("text",{x:l.left-10,y:p,textAnchor:"end",dominantBaseline:"middle",...Ne,...i==null?void 0:i.axisLabel,children:k.toFixed(0)}),o&&n.jsx("line",{x1:l.left,y1:p,x2:t-l.right,y2:p,...pt,...i==null?void 0:i.grid})]},`y-tick-${M}`)}),e.series.map((k,M)=>k.hidden?null:n.jsx(C.Fragment,{children:k.data.map((p,w)=>{const R=p/m*x*g,B=l.left+w*S+d*(M+1)+D*M,W=r-l.bottom-R,A=e.labels[w],V=e.series.reduce((Y,q)=>{const H=q.data[w];return Y+(typeof H=="number"?H:0)},0),O=V>0?(p/V*100).toFixed(1):null,N=k.color?s(k.color):"black",_=Y=>{const q=n.jsxs(h.View,{display:"flex",flexDirection:"column",minWidth:"180px",children:[n.jsxs(h.View,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[n.jsx(h.Text,{fontWeight:"semibold",children:k.name}),n.jsx(h.View,{width:"12px",height:"12px",borderRadius:"2px",backgroundColor:N})]}),n.jsx(h.Text,{marginTop:"4px",color:"color-gray-500",fontSize:"12px",children:A}),n.jsxs(h.View,{marginTop:"8px",display:"flex",flexDirection:"column",children:[n.jsxs(h.View,{display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Value"}),n.jsx(h.Text,{fontWeight:"medium",children:p.toLocaleString()})]}),O!==null&&n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Share"}),n.jsx(h.Text,{fontWeight:"medium",children:`${O}%`})]}),n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Category total"}),n.jsx(h.Text,{fontWeight:"medium",children:V.toLocaleString()})]})]})]}),H=Y.currentTarget.getBoundingClientRect(),ee=H.left+H.width/2,re=H.top;c(ee,re,q)},Z=()=>{a&&a(k.name,w)};return n.jsx("rect",{x:B,y:W,width:D,height:R,fill:`url(#bar-gradient-${M})`,onMouseEnter:_,onMouseMove:_,onMouseLeave:b,onClick:Z,...ln,...i==null?void 0:i.bar},`bar-${M}-${w}`)})},`series-${M}`))]})},mn=({data:e,width:t,height:r,animationProgress:g,showGrid:o=!0,onPointClick:a,showTooltip:c,hideTooltip:b,views:i})=>{const{getColor:s}=h.useTheme(),l={top:20,right:20,bottom:40,left:40},f=t-l.left-l.right,x=r-l.top-l.bottom,y=C.useMemo(()=>{let d=0;return e.series.forEach(m=>{m.data.forEach(I=>{d=Math.max(d,I)})}),d},[e]),u=y||10,j=C.useMemo(()=>{const m=[];for(let I=0;I<=5;I++){const k=u/5*I;m.push(k)}return m},[y]),S=d=>{if(d.length<2)return"";const m=d.map((k,M)=>({x:l.left+M/(e.labels.length-1)*f,y:r-l.bottom-k/u*x*g}));let I=`M ${m[0].x},${m[0].y}`;for(let k=0;k<m.length-1;k++){const M=m[k===0?k:k-1],p=m[k],w=m[k+1],R=m[k+2===m.length?k+1:k+2],B=p.x+(w.x-M.x)/6,W=p.y+(w.y-M.y)/6,A=w.x-(R.x-p.x)/6,V=w.y-(R.y-p.y)/6;I+=` C ${B},${W} ${A},${V} ${w.x},${w.y}`}return I},D=d=>{if(d.length<2)return"";const m=S(d),I=l.left,k=l.left+f,M=r-l.bottom;return`${m} L ${k},${M} L ${I},${M} Z`};return n.jsxs("svg",{width:t,height:r,children:[n.jsx("defs",{children:e.series.map((d,m)=>{const I=d.color?s(d.color):"black";return n.jsxs("linearGradient",{id:`gradient-${m}`,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[n.jsx("stop",{offset:"0%",stopColor:I,stopOpacity:.3}),n.jsx("stop",{offset:"100%",stopColor:I,stopOpacity:0})]},`gradient-${m}`)})}),n.jsx("line",{x1:l.left,y1:r-l.bottom,x2:t-l.right,y2:r-l.bottom,...ze,...i==null?void 0:i.axis}),n.jsx("line",{x1:l.left,y1:l.top,x2:l.left,y2:r-l.bottom,...ze,...i==null?void 0:i.axis}),e.labels.map((d,m)=>{const I=l.left+m/(e.labels.length-1)*f,k=r-l.bottom+20;return n.jsx("text",{x:I,y:k,textAnchor:"middle",...Ne,...i==null?void 0:i.axisLabel,children:d},`x-label-${m}`)}),j.map((d,m)=>{const I=r-l.bottom-d/u*x;return n.jsxs(C.Fragment,{children:[n.jsx("text",{x:l.left-10,y:I,textAnchor:"end",dominantBaseline:"middle",...Ne,...i==null?void 0:i.axisLabel,children:d.toFixed(0)}),o&&n.jsx("line",{x1:l.left,y1:I,x2:t-l.right,y2:I,...pt,...i==null?void 0:i.grid})]},`y-tick-${m}`)}),e.series.map((d,m)=>{if(d.hidden)return null;const I=d.color?s(d.color):"black";return n.jsxs(C.Fragment,{children:[n.jsx("path",{d:D(d.data),fill:`url(#gradient-${m})`,...i==null?void 0:i.area}),n.jsx("path",{d:S(d.data),stroke:I,...sn,...i==null?void 0:i.line}),d.data.map((k,M)=>{const p=l.left+M/(e.labels.length-1)*f,w=r-l.bottom-k/u*x*g,R=e.labels[M],B=e.series.reduce((Z,Y)=>{const q=Y.data[M];return Z+(typeof q=="number"?q:0)},0),W=B>0?(k/B*100).toFixed(1):null,A=M>0&&typeof d.data[M-1]=="number"?d.data[M-1]:null,V=typeof A=="number"?k-A:null,O=typeof V=="number"?`${V>=0?"+":""}${V.toLocaleString()}`:null,N=Z=>{const Y=n.jsxs(h.View,{display:"flex",flexDirection:"column",minWidth:"200px",children:[n.jsxs(h.View,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[n.jsx(h.Text,{fontWeight:"semibold",children:d.name}),n.jsx(h.View,{width:"12px",height:"12px",borderRadius:"2px",backgroundColor:I})]}),n.jsx(h.Text,{marginTop:"4px",color:"color-gray-500",fontSize:"12px",children:R}),n.jsxs(h.View,{marginTop:"8px",display:"flex",flexDirection:"column",children:[n.jsxs(h.View,{display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Value"}),n.jsx(h.Text,{fontWeight:"medium",children:k.toLocaleString()})]}),O!==null&&n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Change"}),n.jsx(h.Text,{fontWeight:"medium",children:O})]}),W!==null&&n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Share"}),n.jsx(h.Text,{fontWeight:"medium",children:`${W}%`})]}),n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Category total"}),n.jsx(h.Text,{fontWeight:"medium",children:B.toLocaleString()})]})]})]}),q=Z.currentTarget.getBoundingClientRect(),H=q.left+q.width/2,ee=q.top+q.height/2;c(H,ee,Y)},_=()=>{a&&a(d.name,M)};return n.jsx("circle",{cx:p,cy:w,fill:I,onMouseEnter:N,onMouseMove:N,onMouseLeave:b,onClick:_,...dn,...i==null?void 0:i.point},`point-${m}-${M}`)})]},`series-${m}`)})]})},xn=({dataPoints:e,width:t,height:r,animationProgress:g,isDonut:o=!1,onSliceClick:a,showTooltip:c,hideTooltip:b,views:i})=>{const{getColor:s}=h.useTheme(),{ref:l,relation:f}=h.useElementPosition({trackChanges:!0,trackOnHover:!0,trackOnScroll:!0,trackOnResize:!0}),x=C.useRef(null);C.useEffect(()=>{x.current&&l&&(l.current=x.current)},[x,l]);const u=Math.min(t,r)/2*.8,j=t/2,S=r/2,D=o?u*.6:0,d=C.useMemo(()=>e.filter(k=>!k.hidden),[e]),m=C.useMemo(()=>d.reduce((k,M)=>k+M.value,0),[d]),I=C.useMemo(()=>{if(m===0)return[{path:o?[`M ${j} ${S-u}`,`A ${u} ${u} 0 1 1 ${j} ${S+u}`,`A ${u} ${u} 0 1 1 ${j} ${S-u}`,`M ${j} ${S-D}`,`A ${D} ${D} 0 1 0 ${j} ${S+D}`,`A ${D} ${D} 0 1 0 ${j} ${S-D}`,"Z"].join(" "):[`M ${j} ${S}`,`M ${j} ${S-u}`,`A ${u} ${u} 0 1 1 ${j} ${S+u}`,`A ${u} ${u} 0 1 1 ${j} ${S-u}`,"Z"].join(" "),color:"#E2E8F0",label:"Total",value:0,percentage:"0%",labelX:j,labelY:S,startAngle:0,endAngle:Math.PI*2,index:-1}];const k=[];let M=-Math.PI/2;for(let p=0;p<d.length;p++){const R=d[p].value/m,B=R*2*Math.PI*g,A=Math.max(0,B-.02),V=M+A,O=j+Math.cos(M)*u,N=S+Math.sin(M)*u,_=j+Math.cos(V)*u,Z=S+Math.sin(V)*u,Y=j+Math.cos(M)*D,q=S+Math.sin(M)*D,H=j+Math.cos(V)*D,ee=S+Math.sin(V)*D,re=A>Math.PI?1:0;let ie;o?ie=[`M ${O} ${N}`,`A ${u} ${u} 0 ${re} 1 ${_} ${Z}`,`L ${H} ${ee}`,`A ${D} ${D} 0 ${re} 0 ${Y} ${q}`,"Z"].join(" "):ie=[`M ${j} ${S}`,`L ${O} ${N}`,`A ${u} ${u} 0 ${re} 1 ${_} ${Z}`,"Z"].join(" ");const se=M+A/2,$=o?(u+D)/2:u*.7,F=j+Math.cos(se)*$,X=S+Math.sin(se)*$,G=`${(R*100).toFixed(1)}%`,U=d[p].color||Ie[p%Ie.length],Q=s(U);k.push({path:ie,color:Q,label:d[p].label,value:d[p].value,percentage:G,labelX:F,labelY:X,startAngle:M,endAngle:V,index:p,originalIndex:e.findIndex(oe=>oe.label===d[p].label)}),M=V}return k},[d,m,u,j,S,D,g,o,e]);return n.jsxs("svg",{ref:x,width:t,height:r,style:{overflow:"visible"},children:[o&&n.jsxs("g",{pointerEvents:"none",children:[n.jsx("circle",{cx:j,cy:S,r:D,fill:"white"}),n.jsx("text",{x:j,y:S-8,textAnchor:"middle",dominantBaseline:"middle",fontSize:"14px",fontWeight:"500",fill:"color-gray-500",children:"Total"}),n.jsx("text",{x:j,y:S+12,textAnchor:"middle",dominantBaseline:"middle",fontSize:"20px",fontWeight:"800",fill:"color-gray-900",children:m.toLocaleString()})]}),I.map((k,M)=>{const p=B=>{const W=m>0?k.value/m*100:0,A=m>0?Math.max(0,100-W):null,V=n.jsxs(h.View,{display:"flex",flexDirection:"column",minWidth:"200px",children:[n.jsxs(h.View,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[n.jsx(h.Text,{fontWeight:"semibold",children:k.label}),n.jsx(h.View,{width:"12px",height:"12px",borderRadius:"2px",backgroundColor:k.color})]}),n.jsxs(h.Text,{marginTop:"4px",color:"color-gray-500",fontSize:"12px",children:["Slice ",k.index+1," of ",d.length]}),n.jsxs(h.View,{marginTop:"8px",display:"flex",flexDirection:"column",children:[n.jsxs(h.View,{display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Value"}),n.jsx(h.Text,{fontWeight:"medium",children:k.value.toLocaleString()})]}),n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Share"}),n.jsx(h.Text,{fontWeight:"medium",children:k.percentage})]}),n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Total"}),n.jsx(h.Text,{fontWeight:"medium",children:m.toLocaleString()})]}),A!==null&&n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Remaining"}),n.jsx(h.Text,{fontWeight:"medium",children:`${A.toFixed(1)}%`})]})]})]});let O=B.clientX,N=B.clientY;if(x.current){const _=x.current.getBoundingClientRect();O=_.left+k.labelX,N=_.top+k.labelY}c(O,N,V)},w=()=>{k.index!==-1&&a&&a(e[k.index],k.index)},R=k.index===-1;return n.jsxs("g",{children:[n.jsx("path",{d:k.path,fill:k.color,onMouseEnter:R?void 0:p,onMouseMove:R?void 0:p,onMouseLeave:R?void 0:b,onClick:w,...Fe,style:{...Fe==null?void 0:Fe.style,cursor:R?"default":"pointer"},...i==null?void 0:i.pie}),!R&&k.endAngle-k.startAngle>.25&&n.jsx("text",{x:k.labelX,y:k.labelY,textAnchor:"middle",dominantBaseline:"middle",fill:"white",fontSize:"11px",fontWeight:"800",pointerEvents:"none",paintOrder:"stroke",stroke:"rgba(0,0,0,0.2)",strokeWidth:"2px",children:k.percentage})]},`slice-${M}`)})]})},bn=({visible:e,x:t,y:r,content:g,maxDistance:o=100,views:a})=>{const c=C.useRef(null),[b,i]=C.useState({left:0,top:0});return C.useEffect(()=>{if(!e||!c.current||typeof window>"u"||typeof c.current.getBoundingClientRect!="function")return;const l=c.current.getBoundingClientRect(),f=l.width||200,x=l.height||100,y=20,u=16;let j=t-f/2,S=r-x-y;S<u&&(S=r+y),j+f>window.innerWidth-u?j=window.innerWidth-f-u:j<u&&(j=u),S=Math.max(u,Math.min(S,window.innerHeight-x-u)),i({left:j,top:S})},[e,t,r]),e?n.jsx(h.View,{ref:c,position:"fixed",left:`${b.left}px`,top:`${b.top}px`,...Pe,...a==null?void 0:a.tooltip,style:{...Pe==null?void 0:Pe.style,pointerEvents:"none",transition:"all 0.1s ease-out"},children:g}):null},kn=({type:e,data:t,dataPoints:r,title:g,showLegend:o=!0,legendPosition:a="bottom",showGrid:c=!0,showTooltips:b=!0,animated:i=!0,animationDuration:s=500,responsive:l=!0,aspectRatio:f=16/9,width:x=200,height:y=200,views:u,onDataPointClick:j,onSeriesClick:S,isLoading:D=!1,error:d,noData:m,loadingIndicator:I,errorIndicator:k,noDataIndicator:M,"aria-label":p,themeMode:w,...R})=>{const{animationProgress:B,tooltip:W,containerRef:A,processedData:V,showTooltip:O,hideTooltip:N,getChartDimensions:_,toggleSeries:Z}=pn({data:t,dataPoints:r,animated:i,animationDuration:s,showTooltips:b}),Y=V(),{width:q,height:H}=_(),ee=x||q,re=y||(l?q/f:H),ie=()=>{if(!o||!Y)return null;let Q=[];return e==="pie"||e==="donut"?Array.isArray(Y)&&(Q=Y):Y&&Y.series&&(Q=Y.series),!Q||Q.length===0?null:n.jsx(h.Horizontal,{flexWrap:"wrap",justifyContent:"flex-start",marginTop:a==="bottom"?"16px":0,marginBottom:a==="top"?"16px":0,...rn,...u==null?void 0:u.legend,children:Q.map((oe,ue)=>{const ae=oe.hidden,he=oe.name||oe.label;return n.jsxs(h.View,{...on,onClick:()=>Z(he),opacity:ae?.4:1,...u==null?void 0:u.legendItem,children:[n.jsx(h.View,{backgroundColor:oe.color,...an,opacity:ae?.3:1}),n.jsx(h.Text,{...cn,textDecoration:ae?"line-through":"none",children:he})]},`legend-${ue}`)})})},se=()=>{if(!Y)return null;switch(e){case"bar":return n.jsx(fn,{data:Y,width:ee,height:re,animationProgress:B,showGrid:c,onBarClick:S,showTooltip:O,hideTooltip:N,views:u});case"line":case"area":return n.jsx(mn,{data:Y,width:ee,height:re,animationProgress:B,showGrid:c,onPointClick:S,showTooltip:O,hideTooltip:N,views:u});case"pie":case"donut":return n.jsx(xn,{dataPoints:Y,width:ee,height:re,animationProgress:B,isDonut:e==="donut",onSliceClick:j,showTooltip:O,hideTooltip:N,views:u});default:return null}},$=()=>D?n.jsx(h.View,{...un,...u==null?void 0:u.loadingOverlay,children:I||n.jsx(h.Center,{children:n.jsx($e.Loader,{size:"lg"})})}):null,F=()=>d?n.jsx(h.View,{...hn,...u==null?void 0:u.errorOverlay,children:k||n.jsx(h.Text,{fontWeight:"medium",children:typeof d=="string"?d:"An error occurred"})}):null,X=()=>m?n.jsx(h.View,{...gn,...u==null?void 0:u.noDataOverlay,children:M||n.jsx(h.Text,{children:typeof m=="string"?m:"No data available"})}):null,G=p??(typeof g=="string"?g:"Chart"),U=!d&&!D&&!m;return n.jsxs(h.View,{ref:A,role:"region","aria-label":G,"aria-busy":D,...tn,...u==null?void 0:u.container,...R,children:[g&&n.jsx(h.Text,{...nn,children:g}),U&&a==="top"&&ie(),n.jsxs(h.View,{flex:1,width:"100%",position:"relative",...u==null?void 0:u.chart,children:[U&&se(),$(),F(),X(),n.jsx(bn,{visible:b&&W.visible,x:W.x,y:W.y,content:W.content,maxDistance:100,views:u})]}),U&&a==="bottom"&&ie()]})},yn=e=>n.jsx(kn,{...e}),Cn=yn,Sn=(e=365)=>{const[t,r]=C.useState(!1),[g,o]=C.useState(null),a="app-studio-cookie-consent";C.useEffect(()=>{if(typeof localStorage>"u")return;const s=localStorage.getItem(a);o(s!==null?s==="true":!1)},[]);const c=s=>{if(typeof localStorage<"u"){localStorage.setItem(a,String(s));const l=new Date;l.setDate(l.getDate()+e),localStorage.setItem(`${a}-expires`,l.toISOString())}o(s)};return{isHovered:t,setIsHovered:r,hasConsent:g,acceptCookies:()=>{c(!0)},resetConsent:()=>{typeof localStorage<"u"&&(localStorage.removeItem(a),localStorage.removeItem(`${a}-expires`)),o(!1)}}},jn=e=>({default:{container:{backgroundColor:"color-white",borderColor:"color-gray-200",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},content:{color:"color-gray-800"},acceptButton:{backgroundColor:"color-blue-500",color:"color-white",hoverBackgroundColor:"color-blue-600"},customizeButton:{backgroundColor:"transparent",color:"color-gray-600",borderColor:"color-gray-300",hoverBackgroundColor:"color-gray-100"}},info:{container:{backgroundColor:"color-blue-50",borderColor:"color-blue-200",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},content:{color:"color-blue-800"},acceptButton:{backgroundColor:"color-blue-500",color:"color-white",hoverBackgroundColor:"color-blue-600"},customizeButton:{backgroundColor:"transparent",color:"color-blue-800",borderColor:"color-blue-300",hoverBackgroundColor:"color-blue-100"}},primary:{container:{backgroundColor:"color-blue-50",borderColor:"color-blue-200",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},content:{color:"color-blue-700"},acceptButton:{backgroundColor:"color-blue-500",color:"color-white",hoverBackgroundColor:"color-blue-600"},customizeButton:{backgroundColor:"transparent",color:"color-blue-700",borderColor:"color-blue-300",hoverBackgroundColor:"color-blue-100"}}}),In=({title:e="Nous utilisons des cookies",description:t="Ce site utilise des cookies pour améliorer votre expérience. En continuant à naviguer sur ce site, vous acceptez notre utilisation des cookies conformément à notre politique de confidentialité.",acceptButtonText:r="Accepter",customizeButtonText:g="Personnaliser",position:o="bottom",variant:a="default",onAccept:c,onCustomize:b,views:i,showCustomizeButton:s=!0,cookieExpiration:l=365,themeMode:f,...x})=>{const{themeMode:y}=h.useTheme(),{hasConsent:u,acceptCookies:j}=Sn(l),D=jn()[a];if(u)return null;const d=()=>{j(),c&&c()},m=()=>{b&&b()};return n.jsx(h.View,{style:{position:"fixed",left:16,right:16,zIndex:1e3,...o==="bottom"?{bottom:16}:{top:16}},padding:16,borderWidth:"1px",borderStyle:"solid",borderRadius:8,maxWidth:"800px",marginLeft:"auto",marginRight:"auto",transition:"opacity 0.3s ease, transform 0.3s ease",...D.container,...i==null?void 0:i.container,...x,children:n.jsxs(h.Vertical,{gap:12,maxWidth:1200,marginLeft:"auto",marginRight:"auto",children:[e&&n.jsx(h.Text,{fontWeight:"bold",fontSize:18,color:"color-black",...i==null?void 0:i.title,children:e}),t&&n.jsx(h.Text,{fontSize:14,color:"color-black",...i==null?void 0:i.description,children:t}),n.jsxs(h.Horizontal,{gap:12,justifyContent:"flex-end",marginTop:8,...i==null?void 0:i.buttonGroup,children:[s&&n.jsx(P.Button,{variant:"outline",onClick:m,size:"sm",...i==null?void 0:i.customizeButton,children:g}),n.jsx(P.Button,{variant:"filled",onClick:d,size:"sm",...i==null?void 0:i.acceptButton,children:r})]})]})})},wn=e=>n.jsx(In,{...e}),Tn=wn,En=({src:e,color:t,views:r,themeMode:g,...o})=>{const{getColor:a,themeMode:c}=h.useTheme(),b=t?{fill:a(t,{themeMode:c}),stroke:a(t,{themeMode:c})}:{};return n.jsx(h.View,{display:"flex",alignItems:"center",justifyContent:"center",...o,...r==null?void 0:r.container,children:n.jsx(h.Image,{...b,content:'url("'+e+'")',width:"100%",height:"100%",...r==null?void 0:r.image})})},Dn=({path:e,...t})=>n.jsx(h.Image,{src:e,...t}),Rn=e=>{const t={...e,options:e.options||[]},r=K.useSelectorState(t);return n.jsx(K.SelectorView,{...r,...t,onClick:g=>{g.stopPropagation(),e.onClick&&e.onClick(g)}})},Mn=Rn,An=({value:e,defaultValue:t="",onChange:r})=>{const[g,o]=C.useState(e!==void 0?e:t);return C.useEffect(()=>{e!==void 0&&o(e)},[e]),{selectedValue:g,setSelectedValue:c=>{e===void 0&&o(c),r&&r(c)}}},Ln=({children:e,name:t,label:r,helperText:g,error:o,selectedValue:a,setSelectedValue:c,direction:b="vertical",spacing:i=8,isDisabled:s=!1,isReadOnly:l=!1,views:f={container:{},label:{},helperText:{}},onChange:x,value:y,defaultValue:u,...j})=>{const S=b==="vertical"?h.Vertical:h.Horizontal,D=C.Children.map(e,M=>{if(C.isValidElement(M)){const p={name:t,isChecked:M.props.value===a,isDisabled:s||M.props.isDisabled,isReadOnly:l||M.props.isReadOnly,onChange:w=>{c(w),M.props.onChange&&M.props.onChange(w)}};return C.cloneElement(M,p)}return M}),d=C.useId(),m=`${d}-label`,I=`${d}-helper`,k=!!(g||o);return n.jsxs(h.Vertical,{gap:i,width:"100%",role:"radiogroup","aria-labelledby":r?m:void 0,"aria-describedby":k?I:void 0,"aria-invalid":o?!0:void 0,...f.container,...j,children:[r&&n.jsx(h.Text,{id:m,fontWeight:"600",fontSize:"14px",color:o?"theme-error":"inherit",marginBottom:4,...f.label,children:r}),n.jsx(S,{gap:i,children:D}),k&&n.jsx(h.Text,{id:I,fontWeight:o?"500":"400",fontSize:"14px",lineHeight:"20px",color:o?"theme-error":"color-gray-500",marginTop:4,transition:"color 0.2s ease, opacity 0.2s ease",...f.helperText,children:o||g})]})},$n=e=>{const t=An(e);return n.jsx(Ln,{...t,...e})},Bn=$n,Vn=e=>{const t=K.useColorInputState(e);return n.jsx(K.ColorInputView,{...t,...e})},Pn=Vn,Fn=e=>{const t=K.useCountryPickerState(e);return n.jsx(K.CountryPickerView,{...t,...e})},Wn=Fn,lt={xs:14,sm:16,md:16,lg:18,xl:20},On=({visibleIcon:e,hiddenIcon:t,...r})=>{const{isVisible:g,setIsVisible:o,...a}=K.usePasswordState(r),c=lt[r.size??"md"]??lt.md,b=c-2;return n.jsx(Me.TextFieldView,{...a,type:g?"text":"password",isClearable:!1,right:n.jsx(h.View,{display:"flex",alignItems:"center",justifyContent:"center",width:`${c}px`,height:`${c}px`,minWidth:`${c}px`,color:"color-gray-500",cursor:r.isDisabled?"not-allowed":"pointer",transition:"color 0.2s ease",onClick:()=>{r.isDisabled||o(!g)},children:g?e??n.jsx(E.OpenEyeIcon,{widthHeight:b}):t??n.jsx(E.CloseEyeIcon,{widthHeight:b})})})},Hn=On,zn=({id:e,name:t,items:r,placeholder:g,searchPlaceholder:o,...a})=>{const c=K.useComboBoxState(r,g,o);return n.jsx(K.ComboBoxView,{id:e,name:t,items:r,searchPlaceholder:o,...c,...a})},Nn=zn,Un=e=>{const t=K.useTagInputState(e),{tags:r,...g}=e,{setTags:o,...a}=t;return n.jsx(K.TagInputView,{...a,...g})},_n=Un,qn=({url:e,type:t,name:r,onOpen:g})=>{const o=t.toLowerCase(),a=o.startsWith("image"),c=o.startsWith("video"),b=o.startsWith("audio"),i=()=>{g&&g()};return n.jsxs(h.View,{width:"60px",height:"60px",flexShrink:0,borderRadius:"4px",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"color-gray-200",cursor:"pointer",onClick:i,children:[a&&n.jsx(h.Image,{src:e,alt:r,width:"100%",height:"100%",objectFit:"cover"}),c&&n.jsx(h.View,{as:"video",src:e,controls:!0,width:"100%",height:"100%",style:{objectFit:"cover"},onClick:s=>s.stopPropagation()}),b&&n.jsx(h.View,{as:"audio",controls:!0,src:e,width:"100%",onClick:s=>s.stopPropagation()}),!a&&!c&&!b&&n.jsx(E.FileIcon,{widthHeight:24,color:"color-gray-600"})]})},ft=({behavior:e,keyboardVerticalOffset:t,dismissOnTap:r,enabled:g,children:o,...a})=>n.jsx(h.View,{flex:1,width:"100%",...a,children:o}),Xn=({header:e,footer:t,children:r,isLoading:g=!1,safe:o=!0,scrollable:a=!0,dismissKeyboardOnTap:c=!0,keyboardVerticalOffset:b=0,views:i={},backgroundColor:s="color-white",...l})=>{const f=o?h.SafeArea:h.View,x=h.isBrowser()?{}:{keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!1,contentContainerStyle:{flexGrow:1}},y=g?n.jsx(h.Center,{flex:1,width:"100%",...i.content,children:n.jsx($e.Loader,{})}):a?n.jsx(h.Scroll,{flex:1,width:"100%",...x,...i.content,children:r}):n.jsx(h.View,{flex:1,width:"100%",...i.content,children:r});return n.jsxs(f,{flex:1,height:"100%",width:"100%",flexDirection:"column",backgroundColor:s,...l,...i.container,children:[e!=null&&n.jsx(h.View,{width:"100%",flexShrink:0,...i.header,children:e}),n.jsxs(ft,{flexDirection:"column",dismissOnTap:c,keyboardVerticalOffset:b,children:[y,t!=null&&n.jsx(h.View,{width:"100%",flexShrink:0,...i.footer,children:t})]})]})},Yn={justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:12},vn={margin:0,fontSize:22,fontWeight:"700",color:"theme-text"},Kn={margin:0,color:"color-gray-600"},Gn=({title:e,description:t,action:r,views:g={},...o})=>n.jsxs(h.Horizontal,{...Yn,...g.container,...o,children:[n.jsxs(h.Vertical,{gap:4,flexShrink:1,children:[n.jsx(h.Text,{as:"h1",...vn,...g.title,children:e}),t?n.jsx(h.Text,{as:"p",...Kn,...g.description,children:t}):null]}),r?n.jsx(h.View,{flexShrink:0,...g.action,children:r}):null]}),Zn=e=>{const t=ye.useMergedDesignSystemComponentProps("pageHeader",e);return n.jsx(Gn,{...t})},Qn={alignItems:"center",gap:8,paddingVertical:48,paddingHorizontal:16,borderRadius:12,borderWidth:1,borderStyle:"dashed",borderColor:"color-gray-200",backgroundColor:"color-white"},Jn={margin:0,fontSize:16,fontWeight:"600",textAlign:"center",color:"theme-text"},er={margin:0,textAlign:"center",color:"color-gray-600"},tr=({state:e,title:t,description:r,action:g,views:o={},...a})=>n.jsxs(h.Vertical,{...e==="error"?{role:"alert"}:{},"data-testid":`state-${e}`,"data-state":e,...Qn,...o.container,...a,children:[n.jsx(h.Text,{as:"h2",...Jn,...o.title,children:t}),r?n.jsx(h.Text,{as:"p",...er,...o.description,children:r}):null,g?n.jsx(h.View,{...o.action,children:g}):null]}),De=e=>{const t=ye.useMergedDesignSystemComponentProps("statePanel",e);return n.jsx(tr,{...t})},mt={loading:"Loading…",emptyTitle:"Nothing here yet",errorTitle:"Something went wrong",networkError:"The server could not be reached. Check your connection and retry.",retry:"Retry",forbiddenTitle:"You don't have access to this",signInRequired:"Sign in to continue.",askAccess:"Ask an administrator for access.",goneTitle:"This no longer exists",goneDescription:"It may have been deleted."},xt=e=>{const t=e!==null&&typeof e=="object"&&"status"in e&&typeof e.status=="number"?e.status:void 0;return t===void 0?{kind:"network"}:t===401||t===403?{kind:"forbidden",status:t}:t===404?{kind:"gone"}:{kind:"error"}},nr=({label:e,...t})=>n.jsxs(h.Vertical,{role:"status","aria-live":"polite","data-testid":"state-loading","data-state":"loading",alignItems:"center",gap:8,padding:48,...t,children:[n.jsx($e.Loader,{}),n.jsx(h.Text,{color:"color-gray-600",children:e})]}),rr=e=>n.jsx(h.Vertical,{"data-testid":"state-populated","data-state":"populated",gap:12,...e}),or=({query:e,isEmpty:t,empty:r,children:g,labels:o,views:a={}})=>{const c={...mt,...o};if(e.status==="loading")return n.jsx(nr,{label:c.loading,...a.loading});if(e.status==="error"){const b=xt(e.error);return b.kind==="forbidden"?n.jsx(De,{state:"forbidden",title:c.forbiddenTitle,description:b.status===401?c.signInRequired:c.askAccess}):b.kind==="gone"?n.jsx(De,{state:"gone",title:c.goneTitle,description:c.goneDescription}):n.jsx(De,{state:"error",title:c.errorTitle,description:b.kind==="network"?c.networkError:void 0,action:n.jsx(P.Button,{onClick:e.reload,children:c.retry})})}return t!=null&&t(e.data)?n.jsx(De,{state:"empty",title:(r==null?void 0:r.title)??c.emptyTitle,description:r==null?void 0:r.description,action:r==null?void 0:r.action}):n.jsx(rr,{...a.content,children:g(e.data)})},ir=({items:e,onChange:t})=>{const[r,g]=C.useState(e),[o,a]=C.useState(null),[c,b]=C.useState(null),i=C.useRef({x:0,y:0}),s=C.useRef([]),l=C.useCallback((y,u)=>{y.preventDefault(),document.body.style.cursor="grabbing";const j="touches"in y?y.touches[0].clientX:y.clientX,S="touches"in y?y.touches[0].clientY:y.clientY;i.current={x:j,y:S},b(u),a(r[u])},[r]),f=C.useCallback(y=>{if(c===null)return;const u="touches"in y?y.touches[0].clientX:y.clientX,j="touches"in y?y.touches[0].clientY:y.clientY,S=s.current[c];if(!S)return;const D=u-i.current.x,d=j-i.current.y;S.style.transform=`translate(${D}px, ${d}px)`,S.style.zIndex="1000";const m=s.current.findIndex((I,k)=>{if(!I||k===c)return!1;const M=I.getBoundingClientRect();return j>=M.top&&j<=M.bottom});if(m!==-1&&m!==c){const I=[...r],[k]=I.splice(c,1);I.splice(m,0,k),g(I),b(m),t==null||t(I),i.current={x:u,y:j}}},[c,r,t]),x=C.useCallback(()=>{document.body.style.cursor="",s.current.forEach(y=>{y&&(y.style.transform="",y.style.zIndex="")}),b(null),a(null)},[c]);return C.useEffect(()=>{if(!(typeof window>"u"))return c!==null&&(window.addEventListener("mousemove",f),window.addEventListener("touchmove",f),window.addEventListener("mouseup",x),window.addEventListener("touchend",x)),()=>{window.removeEventListener("mousemove",f),window.removeEventListener("touchmove",f),window.removeEventListener("mouseup",x),window.removeEventListener("touchend",x)}},[c,f,x]),{items:r,draggedItem:o,draggedIndex:c,itemRefs:s,handleDragStart:l}},ar=({items:e,renderItem:t,containerProps:r,itemProps:g,draggedIndex:o,itemRefs:a,handleDragStart:c,views:b,themeMode:i})=>n.jsx(h.View,{overflow:"hidden",position:"relative",...r,...b==null?void 0:b.container,children:e.map((s,l)=>n.jsx(h.View,{ref:f=>{a.current[l]=f},onMouseDown:f=>c(f,l),onTouchStart:f=>c(f,l),position:"relative",cursor:"grab",transition:"transform 0.2s",...g,...b==null?void 0:b.item,children:t?t(s,l):s},l))}),bt=e=>{const{items:t,draggedIndex:r,itemRefs:g,handleDragStart:o}=ir(e);return n.jsx(ar,{...e,items:t,draggedIndex:r,itemRefs:g,handleDragStart:o})},cr=bt,lr=({onFileSelect:e,onMultipleFileSelect:t,validateFile:r,accept:g,multiple:o,disabled:a,previewUrl:c})=>{const[b,i]=C.useState(!1),[s,l]=C.useState(null),f=C.useRef(null),x=c!==void 0?c:s;C.useEffect(()=>()=>{s&&URL.revokeObjectURL(s)},[s]);const y=C.useCallback(I=>{I.preventDefault(),I.stopPropagation(),!a&&i(!0)},[a]),u=C.useCallback(I=>{I.preventDefault(),I.stopPropagation(),!a&&i(!1)},[a]),j=C.useCallback(I=>{I.preventDefault(),I.stopPropagation(),!a&&i(!0)},[a]),S=C.useCallback(I=>{if(!I||I.length===0)return;const k=Array.from(I);if(!o&&k.length>0){const M=k[0];if(M.type.startsWith("image/")){const p=URL.createObjectURL(M);l(w=>(w&&URL.revokeObjectURL(w),p))}else l(null)}o?t&&t(k):k.length>0&&e&&e(k[0])},[o,t,e]),D=C.useCallback(I=>{I.preventDefault(),I.stopPropagation(),i(!1),!a&&I.dataTransfer.files&&I.dataTransfer.files.length>0&&(S(I.dataTransfer.files),I.dataTransfer.clearData())},[a,S]),d=C.useCallback(()=>{var I;a||(I=f.current)==null||I.click()},[a]),m=C.useCallback(I=>{S(I.target.files),I.target.value&&(I.target.value="")},[S]);return{isDragActive:b,handleDragEnter:y,handleDragLeave:u,handleDragOver:j,handleDrop:D,handleClick:d,handleFileChange:m,inputRef:f,preview:x}},sr={position:"absolute",top:"-4px",right:"-4px",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:"rgba(0, 0, 0, 0.5)",color:"white",border:"none",padding:0,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"12px",zIndex:10,_hover:{backgroundColor:"rgba(0, 0, 0, 0.7)"}},kt=({files:e,sandboxId:t,onRemove:r,layout:g="inline",maxHeight:o="120px",showPreviews:a=!1,views:c={}})=>{if(e.length===0)return null;const b=C.useCallback(s=>s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`,[]),i=C.useCallback(s=>s.type.startsWith("image/")?{backgroundColor:"#DBEAFE",color:"#2563EB"}:s.type.startsWith("video/")?{backgroundColor:"#EDE9FE",color:"#7C3AED"}:s.type.startsWith("audio/")?{backgroundColor:"#DCFCE7",color:"#16A34A"}:{backgroundColor:"#E2E8F0",color:"#475569"},[]);return n.jsx(h.View,{display:"flex",flexWrap:"wrap",gap:"8px",padding:"8px 0",maxHeight:o,overflowY:"auto",...c==null?void 0:c.container,children:e.map((s,l)=>{const f=typeof URL<"u"&&typeof URL.createObjectURL=="function"&&typeof Blob<"u"&&s instanceof Blob,x=(s==null?void 0:s.path)||(s==null?void 0:s.url)||(a&&f?URL.createObjectURL(s):""),y=s.type.startsWith("image/"),u=s.type.startsWith("video/"),j=s.type.startsWith("audio/"),S=i(s);return a?n.jsx(h.Vertical,{alignItems:"center",gap:"6px",padding:"6px 10px",borderRadius:"8px",border:"1px solid #E2E8F0",backgroundColor:"color-white",animate:{from:{opacity:0,scale:.9},to:{opacity:1,scale:1}},animationDuration:.2,...c==null?void 0:c.item,children:a&&n.jsxs(ce.HoverCard,{children:[n.jsxs(ce.HoverCard.Trigger,{children:[y&&n.jsx(h.Image,{src:x,alt:s.name,width:"60px",height:"60px",borderRadius:"8px",objectFit:"cover"}),u&&n.jsx(h.View,{as:"video",src:x,alt:s.name,controls:!1,muted:!0,width:"60px",height:"60px",borderRadius:"8px",objectFit:"cover"}),j&&n.jsx(h.Center,{width:"60px",height:"60px",borderRadius:"8px",backgroundColor:"color-gray-100",children:n.jsx(E.AudioIcon,{widthHeight:24,color:"color-black"})}),!y&&!u&&!j&&n.jsx(h.Center,{width:"60px",height:"60px",borderRadius:"8px",backgroundColor:"color-gray-100",children:n.jsx(E.FileIcon,{widthHeight:24,color:"color-black"})}),r&&n.jsx(h.Button,{...sr,onClick:D=>{D.stopPropagation(),r(l)},"aria-label":`Remove ${s.name}`,children:"×"})]}),n.jsxs(ce.HoverCard.Content,{children:[y&&n.jsx(h.Image,{src:x,alt:s.name,maxWidth:"100%"}),u&&n.jsx(h.View,{as:"video",src:x,controls:!0,maxWidth:"100%"}),j&&n.jsx(h.View,{as:"audio",src:x,controls:!0,width:"100%"}),n.jsxs(h.Text,{marginTop:"4px",maxLines:1,width:"100%",...c==null?void 0:c.name,children:[s.name," (",b(s.size),")"]})]})]})},l):n.jsxs(h.Horizontal,{alignItems:"center",gap:"8px",padding:"6px 10px 6px 8px",borderRadius:"9999px",border:"1px solid #E2E8F0",backgroundColor:"color-white",maxWidth:"100%",animate:{from:{opacity:0,scale:.96},to:{opacity:1,scale:1}},animationDuration:.2,...c==null?void 0:c.item,children:[n.jsx(h.Center,{width:"22px",height:"22px",minWidth:"22px",borderRadius:"9999px",backgroundColor:S.backgroundColor,color:S.color,children:j?n.jsx(E.AudioIcon,{widthHeight:12,color:"currentColor"}):n.jsx(E.FileIcon,{widthHeight:12,color:"currentColor"})}),n.jsxs(h.Text,{fontSize:"12px",lineHeight:"16px",color:"color-gray-600",maxLines:1,maxWidth:"220px",...c==null?void 0:c.name,children:[s.name," · ",b(s.size)]}),r&&n.jsx(h.View,{as:"button",type:"button",onClick:()=>r(l),"aria-label":`Remove ${s.name}`,display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",minWidth:"16px",border:"none",backgroundColor:"transparent",color:"color-gray-400",padding:0,cursor:"pointer",transition:"color 0.2s ease, opacity 0.2s ease",_hover:{color:"color-gray-600"},children:"×"})]},l)})})},dr=({children:e,text:t="Drop files here or click to upload",textProps:r,containerProps:g,disabled:o,accept:a,multiple:c,isDragActive:b,handleDragEnter:i,handleDragLeave:s,handleDragOver:l,handleDrop:f,handleClick:x,handleFileChange:y,inputRef:u,preview:j,imageProps:S,selectedFiles:D,onRemove:d})=>n.jsxs(h.Center,{width:"100%",minHeight:"200px",height:D&&D.length>0?"auto":"200px",borderWidth:2,borderStyle:"dashed",borderColor:b?"theme-primary":"color-gray-300",borderRadius:12,backgroundColor:b?"#EFF6FF":"color-gray-50",flexDirection:"column",cursor:o?"not-allowed":"pointer",opacity:o?.6:1,onClick:x,onDragEnter:i,onDragLeave:s,onDragOver:l,onDrop:f,transition:"background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease",overflow:"hidden",position:"relative",padding:16,...g,children:[n.jsx("input",{type:"file",ref:u,onChange:y,accept:a,multiple:c,style:{display:"none"},disabled:o}),j&&!c?n.jsxs(h.View,{width:"100%",height:"200px",position:"relative",children:[n.jsx(h.Image,{src:j,alt:"Preview",width:"100%",height:"100%",objectFit:"contain",...S}),n.jsx(h.Center,{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.3)",opacity:0,_hover:{opacity:1},transition:"opacity 0.2s",children:n.jsx(h.Text,{color:"white",fontWeight:600,children:"Click to replace"})})]}):n.jsxs(h.View,{flexDirection:"column",alignItems:"center",width:"100%",children:[e||n.jsxs(h.View,{flexDirection:"column",alignItems:"center",width:"100%",children:[n.jsx(E.UploadIcon,{widthHeight:40,color:b?"theme-primary":"color-gray-500"}),n.jsx(h.Text,{marginTop:16,color:b?"theme-primary":"color-gray-600",fontWeight:500,textAlign:"center",...r,children:t})]}),c&&D&&D.length>0&&n.jsx(h.View,{marginTop:16,width:"100%",children:n.jsx(kt,{files:D,onRemove:d||(()=>{}),showPreviews:!0,layout:"inline",maxHeight:"160px"})})]})]}),ur=e=>{const t=lr(e);return n.jsx(dr,{...e,...t})},hr=e=>{const t=K.useEmojiPickerState(e);return n.jsx(K.EmojiPickerView,{...t,...e})},yt=hr,gr=["paragraph","h1","h2","h3","bullet","number","quote","codeBlock","table"];function Se(e){const t=e.trim();return!!t&&!/[\u0000-\u0020\u007f\\]/.test(t)&&(!/^[a-z][a-z\d+.-]*:/i.test(t)||/^(https?:|mailto:|tel:)/i.test(t))}function pr(e){const t=/^(!?)\[((?:\\.|[^\]\\\n])*)\]\(/.exec(e);if(!t)return null;let r=t[0].length;const g=r;let o=0;for(;r<e.length;r++){if(e[r]==="\\"){r++;continue}if(e[r]==="(")o++;else if(e[r]===")"){if(!o)break;o--}else if(/\s/.test(e[r]))break}const a=e.slice(g,r).replace(/\\([()\\])/g,"$1"),c=/^(?:[ \t]+(?:"([^"\n]*)"|'([^'\n]*)'))?\)/.exec(e.slice(r));return c?{image:!!t[1],label:t[2],url:a,title:c[1]??c[2],labelStart:t[1].length+1,length:r+c[0].length}:null}function Ue(e){return Se(e)&&!/^(?:mailto|tel):/i.test(e.trim())}function fr(e){return/^[a-z][a-z\d+.-]*:\/\/[^\s\\]+$/i.test(e)&&!/^(?:javascript|vbscript|data|file|blob):/i.test(e)}function fe(e,t=0,r=0,g=!1){var b;if(r>20)return[{kind:"text",text:e,start:t,end:t+e.length}];const o=[];let a=0;const c=(i,s,l)=>o.push({kind:"text",text:i,start:t+s,end:t+l});for(;a<e.length;){const i=g&&/^(?: {2,}|\\)\r?\n/.exec(e.slice(a));if(i){o.push({kind:"break",start:t+a,end:t+a+i[0].length}),a+=i[0].length;continue}if(e[a]==="\\"&&/[\\`*{}\[\]()#+.!_>~|]/.test(e[a+1]||"")){c(e[a+1],a+1,a+2),a+=2;continue}const s=/^<br\s*\/?\s*>/i.exec(e.slice(a));if(s){o.push({kind:"break",start:t+a,end:t+a+s[0].length}),a+=s[0].length;continue}const l=/^`+/.exec(e.slice(a));if(l){const j=e.indexOf(l[0],a+l[0].length);if(j>=0){o.push({kind:"code",text:e.slice(a+l[0].length,j),start:t+a,end:t+j+l[0].length,contentStart:t+a+l[0].length}),a=j+l[0].length;continue}}const f=g&&pr(e.slice(a));if(f){o.push({kind:f.image?"image":"link",start:t+a,end:t+a+f.length,url:f.url,title:f.title,text:f.image?f.label.replace(/\\([\\`*{}\[\]()#+.!_>~|])/g,"$1"):void 0,children:f.image?void 0:fe(f.label,t+a+f.labelStart,r+1,g)}),a+=f.length;continue}const x=!g&&/^\[([^\]\n]+)\]\(([^\s()]*)\)/.exec(e.slice(a));if(x){o.push({kind:"link",start:t+a,end:t+a+x[0].length,url:x[2],children:fe(x[1],t+a+1,r+1)}),a+=x[0].length;continue}const y=[["***","***","bold"],["**","**","bold"],["__","__","bold"],["~~","~~","strikethrough"],["<u>","</u>","underline"],["`","`","code"],["*","*","italic"],["_","_","italic"]];let u=!1;for(const[j,S,D]of y){if(!e.startsWith(j,a))continue;let d=e.indexOf(S,a+j.length);for(;d>=0&&e[d-1]==="\\";)d=e.indexOf(S,d+S.length);if((j==="*"||j==="_")&&e.startsWith(j+j,d)){const k=e.indexOf(j+j,d+2);k>=0&&(d=e.indexOf(j,k+2))}if((j==="**"||j==="__")&&e[d+2]===j[0]&&(((b=e.slice(a+2,d).match(new RegExp(`\\${j[0]}(?!\\${j[0]})`,"g")))==null?void 0:b.length)||0)%2===1&&d++,d<=a+j.length||j==="_"&&/\w/.test(e[a-1]||"")&&/\w/.test(e[d+1]||""))continue;const m=e.slice(a+j.length,d);let I=D==="code"?void 0:fe(m,t+a+j.length,r+1,g);j==="***"&&(I=[{kind:"italic",start:t+a+2,end:t+d+1,children:I}]),o.push({kind:D,start:t+a,end:t+d+S.length,text:D==="code"?m:void 0,children:I}),u=!0,a=d+S.length;break}u||(c(e[a],a,a+1),a++)}return o.reduce((i,s)=>{const l=i[i.length-1];return(l==null?void 0:l.kind)==="text"&&s.kind==="text"&&l.end===s.start?(l.text+=s.text,l.end=s.end):i.push(s),i},[])}function _e(e,t=[],r,{display:g=!1}={}){var j,S,D;const o=e.replace(g?/^ {0,3}(`{3,}|~{3,})[^\n]*\n[\s\S]*?(?:^ {0,3}\1[ \t]*$|(?![\s\S]))/gm:/^ {0,3}(`{3,}|~{3,})[^\n]*\n[\s\S]*?^ {0,3}\1\s*$/gm,"").replace(/`[^`\n]*`/g,""),a=g?/^(?:import |export |\s*:::|\s*\[.+\]:|\s*={3,}\s*$)|\[\^[^\]]+\]|\$\$|\{[^}\n]*\}|<(?!(?:\/?u>|br\s*\/?>))\/?[A-Za-z!]|&(?:#\w+|\w+);/m.test(o)||/^(?:---|\+\+\+)[ \t]*\r?\n[ \t]*[\w-]+:/.test(e)||/^(?:>[ \t]*>| {1,3}#{1,6}\s|#{1,6}\t|[ \t]{2,}(?:>|#{1,6}\s|\|))|^[ \t]{2,}(?:`{3,}|~{3,})/m.test(o):/^(?:import |export |-{3,}\s*$|\+\+\+\s*$|\s*:::|\s*\[.+\]:|\s*#{4,}\s|\s*(?:\*\s*){3,}$|\s*(?:-\s*){3,}$|\s*(?:_\s*){3,}$|\s*={3,}\s*$)|!\[|\[\^[^\]]+\]|\$\$|\{[^}\n]*\}|<(?!(?:\/?u>|br\s*\/?>))\/?[A-Za-z!]|&(?:#\w+|\w+);/m.test(o)||/^[ \t]{2,}(?:`{3,}|~{3,})/m.test(e)||/^(?:>[ \t]*>| {1,3}#{1,6}\s|#{1,6}\t|[ \t]{2,}(?:>|#{1,6}\s|\|)|[ \t]*(?:[-*+] |\d+[.)] )\[[ xX]\])|(?: {2,}|\\)\r?$/m.test(o)||Array.from(o.matchAll(/\[[^\]\n]+\]\(([^)\n]*)\)/g)).some(d=>/[\s(]/.test(d[1])||!Se(d[1]))||o.split(/\r?\n/).some(d=>fe(d.trim(),0,0,!0).some(m=>m.kind==="link"&&m.title==="video")),c=[],b=/[^\r\n]+|\r\n|\n|\r/g;let i=0;for(const d of e.matchAll(b))/^[\r\n]/.test(d[0])&&(c.push({text:e.slice(i,d.index),start:i,end:d.index}),i=d.index+d[0].length);(i<e.length||!c.length)&&c.push({text:e.slice(i),start:i,end:e.length});const s=[],l=new Set;let f=a;const x=/^\s*(?:[-*+] |\d+[.)] )/,y=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,u=/^ {0,3}(?:(?:\*[ \t]*){3,}|(?:-[ \t]*){3,}|(?:_[ \t]*){3,})$/;for(let d=0;d<c.length;){if(!c[d].text.trim()){const Z=d;for(;d<c.length&&!c[d].text.trim();)d++;const Y=d-Z,q=!s.length,H=q?Math.floor(Y/2)+(d===c.length?1:0):d===c.length?Math.ceil(Y/2):Math.floor(Y/2);for(let ee=0;ee<H;ee++){const re=((j=c[Z+ee*2+(q?0:1)])==null?void 0:j.start)??e.length,ie=((S=t.find(se=>!se.raw&&!l.has(se.id)))==null?void 0:S.id)||P.generateId("block");l.add(ie),s.push({id:ie,kind:"paragraph",raw:"",body:"",start:re,end:re,bodyStart:re})}continue}const m=c[d];let I=d,k="paragraph",M=0,p;const w=(g?/^(#{1,6}) (.*)$/:/^(#{1,3}) (.*)$/).exec(m.text),R=/^ {0,3}(`{3,}|~{3,})([\w+-]*)\s*$/.exec(m.text);let B=!1;if(g&&u.test(m.text))k="hr";else if(w)k=`h${w[1].length}`,M=w[1].length+1;else if(R){for(k="codeBlock",p=R[2],I++;I<c.length&&!new RegExp(`^ {0,3}${R[1][0]}{${R[1].length},}\\s*$`).test(c[I].text);)I++;I>=c.length&&(g||(f=!0),B=!0,I=c.length-1),M=m.end-m.start+(e.slice(m.end,m.end+2)===`\r
|
|
2
|
-
`?2:1)}else if(d+1<c.length&&m.text.includes("|")&&y.test(c[d+1].text))for(k="table",I=d+1;I+1<c.length&&c[I+1].text.trim()&&c[I+1].text.includes("|");)I++;else if(x.test(m.text)){for(k=/^\s*\d/.test(m.text)?"number":"bullet";I+1<c.length&&c[I+1].text.trim()&&(x.test(c[I+1].text)||/^\s{2,}\S/.test(c[I+1].text));)I++;M=m.text.match(x)[0].length}else if(/^> ?/.test(m.text))for(k="quote",M=m.text.match(/^> ?/)[0].length;I+1<c.length&&/^> ?/.test(c[I+1].text);)I++;else{for(;I+1<c.length&&c[I+1].text.trim()&&!/^(?:#{1,6} |>|`{3}|~{3})/.test(c[I+1].text)&&!(g&&u.test(c[I+1].text))&&!x.test(c[I+1].text);)I++;/^ {4}\S/.test(m.text)&&(f=!0)}const W=e.slice(m.start,c[I].end),A=t.find(Z=>Z.id===r&&Z.start===m.start&&!l.has(Z.id)),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./chunks/designSystem.page-BgmjSYsz.cjs"),n=require("react/jsx-runtime"),C=require("react"),h=require("app-studio"),ht=require("./chunks/Select.view-BV01zWHM.cjs"),E=require("./chunks/Icon-C37alecH.cjs"),Nt=require("./chunks/Alert-BHlgJZAo.cjs"),ce=require("./chunks/Formik.Uploader-DePTdd7A.cjs"),Ut=require("./chunks/Avatar-DtfD7QQ6.cjs"),_t=require("./chunks/Card-CK_D7gzP.cjs"),$e=require("./chunks/Loader-4V81BN95.cjs"),qt=require("./chunks/Select-DRMUC3NX.cjs"),Xt=require("./chunks/Switch-DqgmPp8M.cjs"),K=require("./chunks/AttachmentPreview-BZV6xSa4.cjs"),Me=require("./chunks/TextField-CwaxvcqN.cjs"),Yt=require("./chunks/Checkbox-BXbEChdd.cjs"),Ye=require("./link.cjs.js"),vt=require("./chunks/Tabs-DneEt-le.cjs"),ge=require("./theme.cjs.js"),Qe=require("./presets.cjs.js"),we=require("./chunks/Modal-BzlrQQu5.cjs"),Je=require("./chunks/Router-DjmVh9pK.cjs"),et=require("./chunks/Router.store-Bxe2uZWk.cjs"),Kt=({isOpen:e,defaultOpen:t=!1,value:r,defaultValue:g,isMulti:o=!1,onOpenChange:a,onClose:c})=>{const b=typeof e=="boolean",i=r!==void 0,s=g??(o?[]:""),[l,f]=C.useState(t),[x,y]=C.useState(s),u=b?!!e:l,j=i?r:x,S=C.useCallback(m=>{b||f(m),a==null||a(m),m||c==null||c()},[b,c,a]),D=C.useCallback(()=>{S(!1)},[S]),d=C.useCallback(m=>{i||y(m)},[i]);return{isSheetOpen:u,selectedValue:j,setSelectedValue:d,closeSheet:D}},Gt={sm:{minHeight:44,paddingVertical:10,paddingHorizontal:16},md:{minHeight:52,paddingVertical:12,paddingHorizontal:18},lg:{minHeight:60,paddingVertical:14,paddingHorizontal:20}},je={sm:{label:14,description:12},md:{label:16,description:13},lg:{label:18,description:14}},at=(e,t)=>e.id??e.value??`action-sheet-item-${t}`,gt=e=>e.value??e.id,ct=e=>e.disabled||e.isDisabled||e.divider,Zt=(e,t)=>{if(typeof e.selected=="boolean")return e.selected;const r=gt(e);return r?Array.isArray(t)?t.includes(r):t===r:!1},Qt=({isSheetOpen:e,closeSheet:t,selectedValue:r,setSelectedValue:g,isClosePrevented:o=!1,dismissOnBackdropPress:a=!0,title:c,description:b,header:i,children:s,items:l=[],isMulti:f=!1,closeOnSelect:x,onSelect:y,onChange:u,showCancel:j=!1,cancelLabel:S="Cancel",onCancel:D,showHandle:d=!0,size:m="md",maxHeight:I="88vh",views:k,animationType:M,...p})=>{if(!e)return null;const w=()=>{o||t()},R=()=>{a&&w()},V=()=>{D==null||D(),w()},W=A=>{var _;if(ct(A))return;const B=gt(A);let O=r;if(B){if(f){const Z=Array.isArray(r)?r:r?[r]:[];O=Z.includes(B)?Z.filter(Y=>Y!==B):[...Z,B]}else O=B;g(O),y==null||y(B,A),u==null||u(O,A)}(_=A.onPress)==null||_.call(A,A),(A.closeOnSelect??x??!f)&&w()};return n.jsx(ht.Portal,{children:n.jsx(h.View,{position:"fixed",top:0,right:0,bottom:0,left:0,zIndex:9999,backgroundColor:"color-dark-50-360",display:"flex",justifyContent:"flex-end",onClick:R,...k==null?void 0:k.overlay,children:n.jsxs(h.Vertical,{width:"100%",maxWidth:520,maxHeight:I,marginHorizontal:"auto",backgroundColor:"color-white",borderTopLeftRadius:24,borderTopRightRadius:24,paddingTop:8,paddingBottom:12,overflow:"hidden",boxShadow:"0 -18px 48px rgba(15, 23, 42, 0.18)",onClick:A=>A.stopPropagation(),...k==null?void 0:k.container,...k==null?void 0:k.sheet,...p,children:[d&&n.jsx(h.View,{width:36,height:4,borderRadius:999,backgroundColor:"color-gray-300",alignSelf:"center",marginTop:4,marginBottom:8,...k==null?void 0:k.handle}),(c||b)&&n.jsxs(h.Vertical,{paddingHorizontal:20,paddingTop:6,paddingBottom:12,gap:4,...k==null?void 0:k.header,children:[c&&n.jsx(h.Text,{fontSize:18,lineHeight:24,fontWeight:"600",color:"color-gray-900",...k==null?void 0:k.title,children:c}),b&&n.jsx(h.Text,{fontSize:13,lineHeight:18,color:"color-gray-500",...k==null?void 0:k.description,children:b})]}),i,n.jsxs(h.Vertical,{overflowY:"auto",paddingBottom:4,...k==null?void 0:k.content,children:[l.map((A,B)=>{if(A.divider)return n.jsx(h.View,{height:1,backgroundColor:"color-gray-200",marginVertical:6,...k==null?void 0:k.divider},at(A,B));const O=Zt(A,r),N=ct(A),_=N?"color-gray-400":A.destructive?"color-red-600":O?"theme-primary":"color-gray-900";return n.jsxs(h.Horizontal,{alignItems:"center",gap:12,opacity:N?.5:1,cursor:N?"not-allowed":"pointer",onClick:()=>W(A),...Gt[m],...k==null?void 0:k.item,children:[A.icon&&n.jsx(h.View,{flexShrink:0,...k==null?void 0:k.itemIcon,children:A.icon}),n.jsxs(h.Vertical,{flex:1,gap:2,children:[typeof A.label=="string"?n.jsx(h.Text,{fontSize:je[m].label,lineHeight:je[m].label+6,fontWeight:O?"600":"400",color:_,...k==null?void 0:k.itemLabel,children:A.label}):A.label,A.description&&n.jsx(h.Text,{fontSize:je[m].description,lineHeight:je[m].description+5,color:"color-gray-500",...k==null?void 0:k.itemDescription,children:A.description})]}),O&&n.jsx(E.TickIcon,{widthHeight:18,color:"theme-primary",...k==null?void 0:k.itemIndicator})]},at(A,B))}),s]}),j&&n.jsx(h.View,{marginTop:8,paddingHorizontal:12,paddingTop:8,borderTopWidth:1,borderTopColor:"color-gray-200",children:n.jsx(h.Horizontal,{minHeight:52,alignItems:"center",justifyContent:"center",borderRadius:14,backgroundColor:"color-gray-100",cursor:"pointer",onClick:V,...k==null?void 0:k.cancelButton,children:n.jsx(h.Text,{fontSize:je[m].label,lineHeight:je[m].label+6,fontWeight:"600",color:"color-gray-900",...k==null?void 0:k.cancelLabel,children:S})})})]})})})},Jt=e=>{const t=Kt(e);return n.jsx(Qt,{...e,...t})},en=Jt,Ie=P.DEFAULT_CHART_COLORS,tn={width:"100%",height:"100%",position:"relative",display:"flex",flexDirection:"column"},nn={fontSize:"18px",fontWeight:"700",marginBottom:"24px",textAlign:"center",color:"color-gray-900"},rn={display:"flex",flexWrap:"wrap",justifyContent:"flex-start",marginTop:"16px",gap:"12px"},on={display:"flex",alignItems:"center",padding:"4px 8px",borderRadius:"6px",cursor:"pointer",transition:"background-color 0.2s ease",_hover:{backgroundColor:"color-gray-50"}},an={width:"10px",height:"10px",borderRadius:"50%",marginRight:"8px"},cn={fontSize:"13px",fontWeight:"500",color:"color-gray-600"},Pe={position:"absolute",backgroundColor:"color-white",padding:"12px 16px",borderRadius:"8px",boxShadow:"0px 12px 24px rgba(15, 23, 42, 0.18)",border:"1px solid color-gray-200",fontSize:"14px",display:"flex",flexDirection:"column",pointerEvents:"none",zIndex:100},pt={stroke:"color-gray-100",strokeWidth:"1px",strokeDasharray:"4 4"},ze={stroke:"color-gray-200",strokeWidth:"1px"},Ne={fontSize:"12px",fill:"color-gray-500",fontWeight:"500"},ln={rx:"4px",ry:"4px",cursor:"pointer",transition:"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",_hover:{filter:"brightness(1.1)"}},sn={strokeWidth:"3px",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",transition:"stroke-width 0.2s ease"},dn={r:"5px",strokeWidth:"2.5px",stroke:"color-white",cursor:"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",_hover:{r:"7px"}},Fe={strokeWidth:"2px",stroke:"color-white",cursor:"pointer",transition:"all 0.3s ease",_hover:{transform:"scale(1.02)"}},tt={position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"color-white-800",borderRadius:"4px",zIndex:10,padding:"24px",textAlign:"center"},un={...tt},hn={...tt,backgroundColor:"rgba(254, 242, 242, 0.8)",color:"color-red-600"},gn={...tt,backgroundColor:"rgba(249, 250, 251, 0.8)",color:"color-gray-500"},pn=({data:e,dataPoints:t,animated:r=!0,animationDuration:g=500,showTooltips:o=!0})=>{const[a,c]=C.useState(r?0:1),[b,i]=C.useState({visible:!1,x:0,y:0,content:null}),s=C.useRef(null),l=C.useRef(null);C.useEffect(()=>{if(!r){c(1);return}const d=Date.now(),m=()=>{const I=Date.now()-d,k=Math.min(I/g,1);c(k),k<1&&(s.current=requestAnimationFrame(m))};return s.current=requestAnimationFrame(m),()=>{s.current&&cancelAnimationFrame(s.current)}},[r,g]);const[f,x]=C.useState(new Set),y=C.useCallback(d=>{x(m=>{const I=new Set(m);return I.has(d)?I.delete(d):I.add(d),I})},[]),u=C.useCallback(()=>e?{...e,series:e.series.map((d,m)=>({...d,color:d.color||Ie[m%Ie.length],hidden:f.has(d.name)}))}:t?t.map((d,m)=>({...d,color:d.color||Ie[m%Ie.length],hidden:f.has(d.label)})):null,[e,t,f]),j=C.useCallback((d,m,I)=>{o&&i({visible:!0,x:d,y:m,content:I})},[o]),S=C.useCallback(()=>{i(d=>({...d,visible:!1}))},[]),D=C.useCallback(()=>{if(!l.current)return{width:0,height:0};const{width:d,height:m}=l.current.getBoundingClientRect();return{width:d,height:m}},[]);return{animationProgress:a,tooltip:b,containerRef:l,processedData:u,showTooltip:j,hideTooltip:S,getChartDimensions:D,toggleSeries:y}},fn=({data:e,width:t,height:r,animationProgress:g,showGrid:o=!0,onBarClick:a,showTooltip:c,hideTooltip:b,views:i})=>{const{getColor:s}=h.useTheme(),l={top:20,right:20,bottom:40,left:50},f=t-l.left-l.right,x=r-l.top-l.bottom,y=C.useMemo(()=>{let k=0;return e.series.forEach(M=>{M.data.forEach(p=>{k=Math.max(k,p)})}),k},[e]),u=e.labels.length,j=e.series.length,S=f/u,D=S*.8/j,d=S*.2/(j+1),m=y||10,I=C.useMemo(()=>{const M=[];for(let p=0;p<=5;p++){const w=m/5*p;M.push(w)}return M},[y]);return n.jsxs("svg",{width:t,height:r,children:[n.jsx("defs",{children:e.series.map((k,M)=>{const p=k.color?s(k.color):"black";return n.jsxs("linearGradient",{id:`bar-gradient-${M}`,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[n.jsx("stop",{offset:"0%",stopColor:p,stopOpacity:1}),n.jsx("stop",{offset:"100%",stopColor:p,stopOpacity:.7})]},`bar-gradient-${M}`)})}),n.jsx("line",{x1:l.left,y1:r-l.bottom,x2:t-l.right,y2:r-l.bottom,...ze,...i==null?void 0:i.axis}),n.jsx("line",{x1:l.left,y1:l.top,x2:l.left,y2:r-l.bottom,...ze,...i==null?void 0:i.axis}),e.labels.map((k,M)=>{const p=l.left+(M+.5)*S,w=r-l.bottom+20;return n.jsx("text",{x:p,y:w,textAnchor:"middle",...Ne,...i==null?void 0:i.axisLabel,children:k},`x-label-${M}`)}),I.map((k,M)=>{const p=r-l.bottom-k/m*x;return n.jsxs(C.Fragment,{children:[n.jsx("text",{x:l.left-10,y:p,textAnchor:"end",dominantBaseline:"middle",...Ne,...i==null?void 0:i.axisLabel,children:k.toFixed(0)}),o&&n.jsx("line",{x1:l.left,y1:p,x2:t-l.right,y2:p,...pt,...i==null?void 0:i.grid})]},`y-tick-${M}`)}),e.series.map((k,M)=>k.hidden?null:n.jsx(C.Fragment,{children:k.data.map((p,w)=>{const R=p/m*x*g,V=l.left+w*S+d*(M+1)+D*M,W=r-l.bottom-R,A=e.labels[w],B=e.series.reduce((Y,q)=>{const H=q.data[w];return Y+(typeof H=="number"?H:0)},0),O=B>0?(p/B*100).toFixed(1):null,N=k.color?s(k.color):"black",_=Y=>{const q=n.jsxs(h.View,{display:"flex",flexDirection:"column",minWidth:"180px",children:[n.jsxs(h.View,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[n.jsx(h.Text,{fontWeight:"semibold",children:k.name}),n.jsx(h.View,{width:"12px",height:"12px",borderRadius:"2px",backgroundColor:N})]}),n.jsx(h.Text,{marginTop:"4px",color:"color-gray-500",fontSize:"12px",children:A}),n.jsxs(h.View,{marginTop:"8px",display:"flex",flexDirection:"column",children:[n.jsxs(h.View,{display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Value"}),n.jsx(h.Text,{fontWeight:"medium",children:p.toLocaleString()})]}),O!==null&&n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Share"}),n.jsx(h.Text,{fontWeight:"medium",children:`${O}%`})]}),n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Category total"}),n.jsx(h.Text,{fontWeight:"medium",children:B.toLocaleString()})]})]})]}),H=Y.currentTarget.getBoundingClientRect(),ee=H.left+H.width/2,re=H.top;c(ee,re,q)},Z=()=>{a&&a(k.name,w)};return n.jsx("rect",{x:V,y:W,width:D,height:R,fill:`url(#bar-gradient-${M})`,onMouseEnter:_,onMouseMove:_,onMouseLeave:b,onClick:Z,...ln,...i==null?void 0:i.bar},`bar-${M}-${w}`)})},`series-${M}`))]})},mn=({data:e,width:t,height:r,animationProgress:g,showGrid:o=!0,onPointClick:a,showTooltip:c,hideTooltip:b,views:i})=>{const{getColor:s}=h.useTheme(),l={top:20,right:20,bottom:40,left:40},f=t-l.left-l.right,x=r-l.top-l.bottom,y=C.useMemo(()=>{let d=0;return e.series.forEach(m=>{m.data.forEach(I=>{d=Math.max(d,I)})}),d},[e]),u=y||10,j=C.useMemo(()=>{const m=[];for(let I=0;I<=5;I++){const k=u/5*I;m.push(k)}return m},[y]),S=d=>{if(d.length<2)return"";const m=d.map((k,M)=>({x:l.left+M/(e.labels.length-1)*f,y:r-l.bottom-k/u*x*g}));let I=`M ${m[0].x},${m[0].y}`;for(let k=0;k<m.length-1;k++){const M=m[k===0?k:k-1],p=m[k],w=m[k+1],R=m[k+2===m.length?k+1:k+2],V=p.x+(w.x-M.x)/6,W=p.y+(w.y-M.y)/6,A=w.x-(R.x-p.x)/6,B=w.y-(R.y-p.y)/6;I+=` C ${V},${W} ${A},${B} ${w.x},${w.y}`}return I},D=d=>{if(d.length<2)return"";const m=S(d),I=l.left,k=l.left+f,M=r-l.bottom;return`${m} L ${k},${M} L ${I},${M} Z`};return n.jsxs("svg",{width:t,height:r,children:[n.jsx("defs",{children:e.series.map((d,m)=>{const I=d.color?s(d.color):"black";return n.jsxs("linearGradient",{id:`gradient-${m}`,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[n.jsx("stop",{offset:"0%",stopColor:I,stopOpacity:.3}),n.jsx("stop",{offset:"100%",stopColor:I,stopOpacity:0})]},`gradient-${m}`)})}),n.jsx("line",{x1:l.left,y1:r-l.bottom,x2:t-l.right,y2:r-l.bottom,...ze,...i==null?void 0:i.axis}),n.jsx("line",{x1:l.left,y1:l.top,x2:l.left,y2:r-l.bottom,...ze,...i==null?void 0:i.axis}),e.labels.map((d,m)=>{const I=l.left+m/(e.labels.length-1)*f,k=r-l.bottom+20;return n.jsx("text",{x:I,y:k,textAnchor:"middle",...Ne,...i==null?void 0:i.axisLabel,children:d},`x-label-${m}`)}),j.map((d,m)=>{const I=r-l.bottom-d/u*x;return n.jsxs(C.Fragment,{children:[n.jsx("text",{x:l.left-10,y:I,textAnchor:"end",dominantBaseline:"middle",...Ne,...i==null?void 0:i.axisLabel,children:d.toFixed(0)}),o&&n.jsx("line",{x1:l.left,y1:I,x2:t-l.right,y2:I,...pt,...i==null?void 0:i.grid})]},`y-tick-${m}`)}),e.series.map((d,m)=>{if(d.hidden)return null;const I=d.color?s(d.color):"black";return n.jsxs(C.Fragment,{children:[n.jsx("path",{d:D(d.data),fill:`url(#gradient-${m})`,...i==null?void 0:i.area}),n.jsx("path",{d:S(d.data),stroke:I,...sn,...i==null?void 0:i.line}),d.data.map((k,M)=>{const p=l.left+M/(e.labels.length-1)*f,w=r-l.bottom-k/u*x*g,R=e.labels[M],V=e.series.reduce((Z,Y)=>{const q=Y.data[M];return Z+(typeof q=="number"?q:0)},0),W=V>0?(k/V*100).toFixed(1):null,A=M>0&&typeof d.data[M-1]=="number"?d.data[M-1]:null,B=typeof A=="number"?k-A:null,O=typeof B=="number"?`${B>=0?"+":""}${B.toLocaleString()}`:null,N=Z=>{const Y=n.jsxs(h.View,{display:"flex",flexDirection:"column",minWidth:"200px",children:[n.jsxs(h.View,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[n.jsx(h.Text,{fontWeight:"semibold",children:d.name}),n.jsx(h.View,{width:"12px",height:"12px",borderRadius:"2px",backgroundColor:I})]}),n.jsx(h.Text,{marginTop:"4px",color:"color-gray-500",fontSize:"12px",children:R}),n.jsxs(h.View,{marginTop:"8px",display:"flex",flexDirection:"column",children:[n.jsxs(h.View,{display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Value"}),n.jsx(h.Text,{fontWeight:"medium",children:k.toLocaleString()})]}),O!==null&&n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Change"}),n.jsx(h.Text,{fontWeight:"medium",children:O})]}),W!==null&&n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Share"}),n.jsx(h.Text,{fontWeight:"medium",children:`${W}%`})]}),n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Category total"}),n.jsx(h.Text,{fontWeight:"medium",children:V.toLocaleString()})]})]})]}),q=Z.currentTarget.getBoundingClientRect(),H=q.left+q.width/2,ee=q.top+q.height/2;c(H,ee,Y)},_=()=>{a&&a(d.name,M)};return n.jsx("circle",{cx:p,cy:w,fill:I,onMouseEnter:N,onMouseMove:N,onMouseLeave:b,onClick:_,...dn,...i==null?void 0:i.point},`point-${m}-${M}`)})]},`series-${m}`)})]})},xn=({dataPoints:e,width:t,height:r,animationProgress:g,isDonut:o=!1,onSliceClick:a,showTooltip:c,hideTooltip:b,views:i})=>{const{getColor:s}=h.useTheme(),{ref:l,relation:f}=h.useElementPosition({trackChanges:!0,trackOnHover:!0,trackOnScroll:!0,trackOnResize:!0}),x=C.useRef(null);C.useEffect(()=>{x.current&&l&&(l.current=x.current)},[x,l]);const u=Math.min(t,r)/2*.8,j=t/2,S=r/2,D=o?u*.6:0,d=C.useMemo(()=>e.filter(k=>!k.hidden),[e]),m=C.useMemo(()=>d.reduce((k,M)=>k+M.value,0),[d]),I=C.useMemo(()=>{if(m===0)return[{path:o?[`M ${j} ${S-u}`,`A ${u} ${u} 0 1 1 ${j} ${S+u}`,`A ${u} ${u} 0 1 1 ${j} ${S-u}`,`M ${j} ${S-D}`,`A ${D} ${D} 0 1 0 ${j} ${S+D}`,`A ${D} ${D} 0 1 0 ${j} ${S-D}`,"Z"].join(" "):[`M ${j} ${S}`,`M ${j} ${S-u}`,`A ${u} ${u} 0 1 1 ${j} ${S+u}`,`A ${u} ${u} 0 1 1 ${j} ${S-u}`,"Z"].join(" "),color:"#E2E8F0",label:"Total",value:0,percentage:"0%",labelX:j,labelY:S,startAngle:0,endAngle:Math.PI*2,index:-1}];const k=[];let M=-Math.PI/2;for(let p=0;p<d.length;p++){const R=d[p].value/m,V=R*2*Math.PI*g,A=Math.max(0,V-.02),B=M+A,O=j+Math.cos(M)*u,N=S+Math.sin(M)*u,_=j+Math.cos(B)*u,Z=S+Math.sin(B)*u,Y=j+Math.cos(M)*D,q=S+Math.sin(M)*D,H=j+Math.cos(B)*D,ee=S+Math.sin(B)*D,re=A>Math.PI?1:0;let ie;o?ie=[`M ${O} ${N}`,`A ${u} ${u} 0 ${re} 1 ${_} ${Z}`,`L ${H} ${ee}`,`A ${D} ${D} 0 ${re} 0 ${Y} ${q}`,"Z"].join(" "):ie=[`M ${j} ${S}`,`L ${O} ${N}`,`A ${u} ${u} 0 ${re} 1 ${_} ${Z}`,"Z"].join(" ");const se=M+A/2,$=o?(u+D)/2:u*.7,F=j+Math.cos(se)*$,X=S+Math.sin(se)*$,G=`${(R*100).toFixed(1)}%`,U=d[p].color||Ie[p%Ie.length],Q=s(U);k.push({path:ie,color:Q,label:d[p].label,value:d[p].value,percentage:G,labelX:F,labelY:X,startAngle:M,endAngle:B,index:p,originalIndex:e.findIndex(oe=>oe.label===d[p].label)}),M=B}return k},[d,m,u,j,S,D,g,o,e]);return n.jsxs("svg",{ref:x,width:t,height:r,style:{overflow:"visible"},children:[o&&n.jsxs("g",{pointerEvents:"none",children:[n.jsx("circle",{cx:j,cy:S,r:D,fill:"white"}),n.jsx("text",{x:j,y:S-8,textAnchor:"middle",dominantBaseline:"middle",fontSize:"14px",fontWeight:"500",fill:"color-gray-500",children:"Total"}),n.jsx("text",{x:j,y:S+12,textAnchor:"middle",dominantBaseline:"middle",fontSize:"20px",fontWeight:"800",fill:"color-gray-900",children:m.toLocaleString()})]}),I.map((k,M)=>{const p=V=>{const W=m>0?k.value/m*100:0,A=m>0?Math.max(0,100-W):null,B=n.jsxs(h.View,{display:"flex",flexDirection:"column",minWidth:"200px",children:[n.jsxs(h.View,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[n.jsx(h.Text,{fontWeight:"semibold",children:k.label}),n.jsx(h.View,{width:"12px",height:"12px",borderRadius:"2px",backgroundColor:k.color})]}),n.jsxs(h.Text,{marginTop:"4px",color:"color-gray-500",fontSize:"12px",children:["Slice ",k.index+1," of ",d.length]}),n.jsxs(h.View,{marginTop:"8px",display:"flex",flexDirection:"column",children:[n.jsxs(h.View,{display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Value"}),n.jsx(h.Text,{fontWeight:"medium",children:k.value.toLocaleString()})]}),n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Share"}),n.jsx(h.Text,{fontWeight:"medium",children:k.percentage})]}),n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Total"}),n.jsx(h.Text,{fontWeight:"medium",children:m.toLocaleString()})]}),A!==null&&n.jsxs(h.View,{marginTop:"4px",display:"flex",justifyContent:"space-between",children:[n.jsx(h.Text,{color:"color-gray-500",children:"Remaining"}),n.jsx(h.Text,{fontWeight:"medium",children:`${A.toFixed(1)}%`})]})]})]});let O=V.clientX,N=V.clientY;if(x.current){const _=x.current.getBoundingClientRect();O=_.left+k.labelX,N=_.top+k.labelY}c(O,N,B)},w=()=>{k.index!==-1&&a&&a(e[k.index],k.index)},R=k.index===-1;return n.jsxs("g",{children:[n.jsx("path",{d:k.path,fill:k.color,onMouseEnter:R?void 0:p,onMouseMove:R?void 0:p,onMouseLeave:R?void 0:b,onClick:w,...Fe,style:{...Fe==null?void 0:Fe.style,cursor:R?"default":"pointer"},...i==null?void 0:i.pie}),!R&&k.endAngle-k.startAngle>.25&&n.jsx("text",{x:k.labelX,y:k.labelY,textAnchor:"middle",dominantBaseline:"middle",fill:"white",fontSize:"11px",fontWeight:"800",pointerEvents:"none",paintOrder:"stroke",stroke:"rgba(0,0,0,0.2)",strokeWidth:"2px",children:k.percentage})]},`slice-${M}`)})]})},bn=({visible:e,x:t,y:r,content:g,maxDistance:o=100,views:a})=>{const c=C.useRef(null),[b,i]=C.useState({left:0,top:0});return C.useEffect(()=>{if(!e||!c.current||typeof window>"u"||typeof c.current.getBoundingClientRect!="function")return;const l=c.current.getBoundingClientRect(),f=l.width||200,x=l.height||100,y=20,u=16;let j=t-f/2,S=r-x-y;S<u&&(S=r+y),j+f>window.innerWidth-u?j=window.innerWidth-f-u:j<u&&(j=u),S=Math.max(u,Math.min(S,window.innerHeight-x-u)),i({left:j,top:S})},[e,t,r]),e?n.jsx(h.View,{ref:c,position:"fixed",left:`${b.left}px`,top:`${b.top}px`,...Pe,...a==null?void 0:a.tooltip,style:{...Pe==null?void 0:Pe.style,pointerEvents:"none",transition:"all 0.1s ease-out"},children:g}):null},kn=({type:e,data:t,dataPoints:r,title:g,showLegend:o=!0,legendPosition:a="bottom",showGrid:c=!0,showTooltips:b=!0,animated:i=!0,animationDuration:s=500,responsive:l=!0,aspectRatio:f=16/9,width:x=200,height:y=200,views:u,onDataPointClick:j,onSeriesClick:S,isLoading:D=!1,error:d,noData:m,loadingIndicator:I,errorIndicator:k,noDataIndicator:M,"aria-label":p,themeMode:w,...R})=>{const{animationProgress:V,tooltip:W,containerRef:A,processedData:B,showTooltip:O,hideTooltip:N,getChartDimensions:_,toggleSeries:Z}=pn({data:t,dataPoints:r,animated:i,animationDuration:s,showTooltips:b}),Y=B(),{width:q,height:H}=_(),ee=x||q,re=y||(l?q/f:H),ie=()=>{if(!o||!Y)return null;let Q=[];return e==="pie"||e==="donut"?Array.isArray(Y)&&(Q=Y):Y&&Y.series&&(Q=Y.series),!Q||Q.length===0?null:n.jsx(h.Horizontal,{flexWrap:"wrap",justifyContent:"flex-start",marginTop:a==="bottom"?"16px":0,marginBottom:a==="top"?"16px":0,...rn,...u==null?void 0:u.legend,children:Q.map((oe,ue)=>{const ae=oe.hidden,he=oe.name||oe.label;return n.jsxs(h.View,{...on,onClick:()=>Z(he),opacity:ae?.4:1,...u==null?void 0:u.legendItem,children:[n.jsx(h.View,{backgroundColor:oe.color,...an,opacity:ae?.3:1}),n.jsx(h.Text,{...cn,textDecoration:ae?"line-through":"none",children:he})]},`legend-${ue}`)})})},se=()=>{if(!Y)return null;switch(e){case"bar":return n.jsx(fn,{data:Y,width:ee,height:re,animationProgress:V,showGrid:c,onBarClick:S,showTooltip:O,hideTooltip:N,views:u});case"line":case"area":return n.jsx(mn,{data:Y,width:ee,height:re,animationProgress:V,showGrid:c,onPointClick:S,showTooltip:O,hideTooltip:N,views:u});case"pie":case"donut":return n.jsx(xn,{dataPoints:Y,width:ee,height:re,animationProgress:V,isDonut:e==="donut",onSliceClick:j,showTooltip:O,hideTooltip:N,views:u});default:return null}},$=()=>D?n.jsx(h.View,{...un,...u==null?void 0:u.loadingOverlay,children:I||n.jsx(h.Center,{children:n.jsx($e.Loader,{size:"lg"})})}):null,F=()=>d?n.jsx(h.View,{...hn,...u==null?void 0:u.errorOverlay,children:k||n.jsx(h.Text,{fontWeight:"medium",children:typeof d=="string"?d:"An error occurred"})}):null,X=()=>m?n.jsx(h.View,{...gn,...u==null?void 0:u.noDataOverlay,children:M||n.jsx(h.Text,{children:typeof m=="string"?m:"No data available"})}):null,G=p??(typeof g=="string"?g:"Chart"),U=!d&&!D&&!m;return n.jsxs(h.View,{ref:A,role:"region","aria-label":G,"aria-busy":D,...tn,...u==null?void 0:u.container,...R,children:[g&&n.jsx(h.Text,{...nn,children:g}),U&&a==="top"&&ie(),n.jsxs(h.View,{flex:1,width:"100%",position:"relative",...u==null?void 0:u.chart,children:[U&&se(),$(),F(),X(),n.jsx(bn,{visible:b&&W.visible,x:W.x,y:W.y,content:W.content,maxDistance:100,views:u})]}),U&&a==="bottom"&&ie()]})},yn=e=>n.jsx(kn,{...e}),Cn=yn,Sn=(e=365)=>{const[t,r]=C.useState(!1),[g,o]=C.useState(null),a="app-studio-cookie-consent";C.useEffect(()=>{if(typeof localStorage>"u")return;const s=localStorage.getItem(a);o(s!==null?s==="true":!1)},[]);const c=s=>{if(typeof localStorage<"u"){localStorage.setItem(a,String(s));const l=new Date;l.setDate(l.getDate()+e),localStorage.setItem(`${a}-expires`,l.toISOString())}o(s)};return{isHovered:t,setIsHovered:r,hasConsent:g,acceptCookies:()=>{c(!0)},resetConsent:()=>{typeof localStorage<"u"&&(localStorage.removeItem(a),localStorage.removeItem(`${a}-expires`)),o(!1)}}},jn=e=>({default:{container:{backgroundColor:"color-white",borderColor:"color-gray-200",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},content:{color:"color-gray-800"},acceptButton:{backgroundColor:"color-blue-500",color:"color-white",hoverBackgroundColor:"color-blue-600"},customizeButton:{backgroundColor:"transparent",color:"color-gray-600",borderColor:"color-gray-300",hoverBackgroundColor:"color-gray-100"}},info:{container:{backgroundColor:"color-blue-50",borderColor:"color-blue-200",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},content:{color:"color-blue-800"},acceptButton:{backgroundColor:"color-blue-500",color:"color-white",hoverBackgroundColor:"color-blue-600"},customizeButton:{backgroundColor:"transparent",color:"color-blue-800",borderColor:"color-blue-300",hoverBackgroundColor:"color-blue-100"}},primary:{container:{backgroundColor:"color-blue-50",borderColor:"color-blue-200",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},content:{color:"color-blue-700"},acceptButton:{backgroundColor:"color-blue-500",color:"color-white",hoverBackgroundColor:"color-blue-600"},customizeButton:{backgroundColor:"transparent",color:"color-blue-700",borderColor:"color-blue-300",hoverBackgroundColor:"color-blue-100"}}}),In=({title:e="Nous utilisons des cookies",description:t="Ce site utilise des cookies pour améliorer votre expérience. En continuant à naviguer sur ce site, vous acceptez notre utilisation des cookies conformément à notre politique de confidentialité.",acceptButtonText:r="Accepter",customizeButtonText:g="Personnaliser",position:o="bottom",variant:a="default",onAccept:c,onCustomize:b,views:i,showCustomizeButton:s=!0,cookieExpiration:l=365,themeMode:f,...x})=>{const{themeMode:y}=h.useTheme(),{hasConsent:u,acceptCookies:j}=Sn(l),D=jn()[a];if(u)return null;const d=()=>{j(),c&&c()},m=()=>{b&&b()};return n.jsx(h.View,{style:{position:"fixed",left:16,right:16,zIndex:1e3,...o==="bottom"?{bottom:16}:{top:16}},padding:16,borderWidth:"1px",borderStyle:"solid",borderRadius:8,maxWidth:"800px",marginLeft:"auto",marginRight:"auto",transition:"opacity 0.3s ease, transform 0.3s ease",...D.container,...i==null?void 0:i.container,...x,children:n.jsxs(h.Vertical,{gap:12,maxWidth:1200,marginLeft:"auto",marginRight:"auto",children:[e&&n.jsx(h.Text,{fontWeight:"bold",fontSize:18,color:"color-black",...i==null?void 0:i.title,children:e}),t&&n.jsx(h.Text,{fontSize:14,color:"color-black",...i==null?void 0:i.description,children:t}),n.jsxs(h.Horizontal,{gap:12,justifyContent:"flex-end",marginTop:8,...i==null?void 0:i.buttonGroup,children:[s&&n.jsx(P.Button,{variant:"outline",onClick:m,size:"sm",...i==null?void 0:i.customizeButton,children:g}),n.jsx(P.Button,{variant:"filled",onClick:d,size:"sm",...i==null?void 0:i.acceptButton,children:r})]})]})})},wn=e=>n.jsx(In,{...e}),Tn=wn,En=({src:e,color:t,views:r,themeMode:g,...o})=>{const{getColor:a,themeMode:c}=h.useTheme(),b=t?{fill:a(t,{themeMode:c}),stroke:a(t,{themeMode:c})}:{};return n.jsx(h.View,{display:"flex",alignItems:"center",justifyContent:"center",...o,...r==null?void 0:r.container,children:n.jsx(h.Image,{...b,content:'url("'+e+'")',width:"100%",height:"100%",...r==null?void 0:r.image})})},Dn=({path:e,...t})=>n.jsx(h.Image,{src:e,...t}),Rn=e=>{const t={...e,options:e.options||[]},r=K.useSelectorState(t);return n.jsx(K.SelectorView,{...r,...t,onClick:g=>{g.stopPropagation(),e.onClick&&e.onClick(g)}})},Mn=Rn,An=({value:e,defaultValue:t="",onChange:r})=>{const[g,o]=C.useState(e!==void 0?e:t);return C.useEffect(()=>{e!==void 0&&o(e)},[e]),{selectedValue:g,setSelectedValue:c=>{e===void 0&&o(c),r&&r(c)}}},Ln=({children:e,name:t,label:r,helperText:g,error:o,selectedValue:a,setSelectedValue:c,direction:b="vertical",spacing:i=8,isDisabled:s=!1,isReadOnly:l=!1,views:f={container:{},label:{},helperText:{}},onChange:x,value:y,defaultValue:u,...j})=>{const S=b==="vertical"?h.Vertical:h.Horizontal,D=C.Children.map(e,M=>{if(C.isValidElement(M)){const p={name:t,isChecked:M.props.value===a,isDisabled:s||M.props.isDisabled,isReadOnly:l||M.props.isReadOnly,onChange:w=>{c(w),M.props.onChange&&M.props.onChange(w)}};return C.cloneElement(M,p)}return M}),d=C.useId(),m=`${d}-label`,I=`${d}-helper`,k=!!(g||o);return n.jsxs(h.Vertical,{gap:i,width:"100%",role:"radiogroup","aria-labelledby":r?m:void 0,"aria-describedby":k?I:void 0,"aria-invalid":o?!0:void 0,...f.container,...j,children:[r&&n.jsx(h.Text,{id:m,fontWeight:"600",fontSize:"14px",color:o?"theme-error":"inherit",marginBottom:4,...f.label,children:r}),n.jsx(S,{gap:i,children:D}),k&&n.jsx(h.Text,{id:I,fontWeight:o?"500":"400",fontSize:"14px",lineHeight:"20px",color:o?"theme-error":"color-gray-500",marginTop:4,transition:"color 0.2s ease, opacity 0.2s ease",...f.helperText,children:o||g})]})},$n=e=>{const t=An(e);return n.jsx(Ln,{...t,...e})},Vn=$n,Bn=e=>{const t=K.useColorInputState(e);return n.jsx(K.ColorInputView,{...t,...e})},Pn=Bn,Fn=e=>{const t=K.useCountryPickerState(e);return n.jsx(K.CountryPickerView,{...t,...e})},Wn=Fn,lt={xs:14,sm:16,md:16,lg:18,xl:20},On=({visibleIcon:e,hiddenIcon:t,...r})=>{const{isVisible:g,setIsVisible:o,...a}=K.usePasswordState(r),c=lt[r.size??"md"]??lt.md,b=c-2;return n.jsx(Me.TextFieldView,{...a,type:g?"text":"password",isClearable:!1,right:n.jsx(h.View,{display:"flex",alignItems:"center",justifyContent:"center",width:`${c}px`,height:`${c}px`,minWidth:`${c}px`,color:"color-gray-500",cursor:r.isDisabled?"not-allowed":"pointer",transition:"color 0.2s ease",onClick:()=>{r.isDisabled||o(!g)},children:g?e??n.jsx(E.OpenEyeIcon,{widthHeight:b}):t??n.jsx(E.CloseEyeIcon,{widthHeight:b})})})},Hn=On,zn=({id:e,name:t,items:r,placeholder:g,searchPlaceholder:o,...a})=>{const c=K.useComboBoxState(r,g,o);return n.jsx(K.ComboBoxView,{id:e,name:t,items:r,searchPlaceholder:o,...c,...a})},Nn=zn,Un=e=>{const t=K.useTagInputState(e),{tags:r,...g}=e,{setTags:o,...a}=t;return n.jsx(K.TagInputView,{...a,...g})},_n=Un,qn=({url:e,type:t,name:r,onOpen:g})=>{const o=t.toLowerCase(),a=o.startsWith("image"),c=o.startsWith("video"),b=o.startsWith("audio"),i=()=>{g&&g()};return n.jsxs(h.View,{width:"60px",height:"60px",flexShrink:0,borderRadius:"4px",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"color-gray-200",cursor:"pointer",onClick:i,children:[a&&n.jsx(h.Image,{src:e,alt:r,width:"100%",height:"100%",objectFit:"cover"}),c&&n.jsx(h.View,{as:"video",src:e,controls:!0,width:"100%",height:"100%",style:{objectFit:"cover"},onClick:s=>s.stopPropagation()}),b&&n.jsx(h.View,{as:"audio",controls:!0,src:e,width:"100%",onClick:s=>s.stopPropagation()}),!a&&!c&&!b&&n.jsx(E.FileIcon,{widthHeight:24,color:"color-gray-600"})]})},ft=({behavior:e,keyboardVerticalOffset:t,dismissOnTap:r,enabled:g,children:o,...a})=>n.jsx(h.View,{flex:1,width:"100%",...a,children:o}),Xn=({header:e,footer:t,children:r,isLoading:g=!1,safe:o=!0,scrollable:a=!0,dismissKeyboardOnTap:c=!0,keyboardVerticalOffset:b=0,views:i={},backgroundColor:s="color-white",...l})=>{const f=o?h.SafeArea:h.View,x=h.isBrowser()?{}:{keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!1,contentContainerStyle:{flexGrow:1}},y=g?n.jsx(h.Center,{flex:1,width:"100%",...i.content,children:n.jsx($e.Loader,{})}):a?n.jsx(h.Scroll,{flex:1,width:"100%",...x,...i.content,children:r}):n.jsx(h.View,{flex:1,width:"100%",...i.content,children:r});return n.jsxs(f,{flex:1,height:"100%",width:"100%",flexDirection:"column",backgroundColor:s,...l,...i.container,children:[e!=null&&n.jsx(h.View,{width:"100%",flexShrink:0,...i.header,children:e}),n.jsxs(ft,{flexDirection:"column",dismissOnTap:c,keyboardVerticalOffset:b,children:[y,t!=null&&n.jsx(h.View,{width:"100%",flexShrink:0,...i.footer,children:t})]})]})},Yn={justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:12},vn={margin:0,fontSize:22,fontWeight:"700",color:"theme-text"},Kn={margin:0,color:"color-gray-600"},Gn=({title:e,description:t,action:r,views:g={},...o})=>n.jsxs(h.Horizontal,{...Yn,...g.container,...o,children:[n.jsxs(h.Vertical,{gap:4,flexShrink:1,children:[n.jsx(h.Text,{as:"h1",...vn,...g.title,children:e}),t?n.jsx(h.Text,{as:"p",...Kn,...g.description,children:t}):null]}),r?n.jsx(h.View,{flexShrink:0,...g.action,children:r}):null]}),Zn=e=>{const t=ge.useMergedDesignSystemComponentProps("pageHeader",e);return n.jsx(Gn,{...t})},Qn={alignItems:"center",gap:8,paddingVertical:48,paddingHorizontal:16,borderRadius:12,borderWidth:1,borderStyle:"dashed",borderColor:"color-gray-200",backgroundColor:"color-white"},Jn={margin:0,fontSize:16,fontWeight:"600",textAlign:"center",color:"theme-text"},er={margin:0,textAlign:"center",color:"color-gray-600"},tr=({state:e,title:t,description:r,action:g,views:o={},...a})=>n.jsxs(h.Vertical,{...e==="error"?{role:"alert"}:{},"data-testid":`state-${e}`,"data-state":e,...Qn,...o.container,...a,children:[n.jsx(h.Text,{as:"h2",...Jn,...o.title,children:t}),r?n.jsx(h.Text,{as:"p",...er,...o.description,children:r}):null,g?n.jsx(h.View,{...o.action,children:g}):null]}),De=e=>{const t=ge.useMergedDesignSystemComponentProps("statePanel",e);return n.jsx(tr,{...t})},mt={loading:"Loading…",emptyTitle:"Nothing here yet",errorTitle:"Something went wrong",networkError:"The server could not be reached. Check your connection and retry.",retry:"Retry",forbiddenTitle:"You don't have access to this",signInRequired:"Sign in to continue.",askAccess:"Ask an administrator for access.",goneTitle:"This no longer exists",goneDescription:"It may have been deleted."},xt=e=>{const t=e!==null&&typeof e=="object"&&"status"in e&&typeof e.status=="number"?e.status:void 0;return t===void 0?{kind:"network"}:t===401||t===403?{kind:"forbidden",status:t}:t===404?{kind:"gone"}:{kind:"error"}},nr=({label:e,...t})=>n.jsxs(h.Vertical,{role:"status","aria-live":"polite","data-testid":"state-loading","data-state":"loading",alignItems:"center",gap:8,padding:48,...t,children:[n.jsx($e.Loader,{}),n.jsx(h.Text,{color:"color-gray-600",children:e})]}),rr=e=>n.jsx(h.Vertical,{"data-testid":"state-populated","data-state":"populated",gap:12,...e}),or=({query:e,isEmpty:t,empty:r,children:g,labels:o,views:a={}})=>{const c={...mt,...o};if(e.status==="loading")return n.jsx(nr,{label:c.loading,...a.loading});if(e.status==="error"){const b=xt(e.error);return b.kind==="forbidden"?n.jsx(De,{state:"forbidden",title:c.forbiddenTitle,description:b.status===401?c.signInRequired:c.askAccess}):b.kind==="gone"?n.jsx(De,{state:"gone",title:c.goneTitle,description:c.goneDescription}):n.jsx(De,{state:"error",title:c.errorTitle,description:b.kind==="network"?c.networkError:void 0,action:n.jsx(P.Button,{onClick:e.reload,children:c.retry})})}return t!=null&&t(e.data)?n.jsx(De,{state:"empty",title:(r==null?void 0:r.title)??c.emptyTitle,description:r==null?void 0:r.description,action:r==null?void 0:r.action}):n.jsx(rr,{...a.content,children:g(e.data)})},ir=({items:e,onChange:t})=>{const[r,g]=C.useState(e),[o,a]=C.useState(null),[c,b]=C.useState(null),i=C.useRef({x:0,y:0}),s=C.useRef([]),l=C.useCallback((y,u)=>{y.preventDefault(),document.body.style.cursor="grabbing";const j="touches"in y?y.touches[0].clientX:y.clientX,S="touches"in y?y.touches[0].clientY:y.clientY;i.current={x:j,y:S},b(u),a(r[u])},[r]),f=C.useCallback(y=>{if(c===null)return;const u="touches"in y?y.touches[0].clientX:y.clientX,j="touches"in y?y.touches[0].clientY:y.clientY,S=s.current[c];if(!S)return;const D=u-i.current.x,d=j-i.current.y;S.style.transform=`translate(${D}px, ${d}px)`,S.style.zIndex="1000";const m=s.current.findIndex((I,k)=>{if(!I||k===c)return!1;const M=I.getBoundingClientRect();return j>=M.top&&j<=M.bottom});if(m!==-1&&m!==c){const I=[...r],[k]=I.splice(c,1);I.splice(m,0,k),g(I),b(m),t==null||t(I),i.current={x:u,y:j}}},[c,r,t]),x=C.useCallback(()=>{document.body.style.cursor="",s.current.forEach(y=>{y&&(y.style.transform="",y.style.zIndex="")}),b(null),a(null)},[c]);return C.useEffect(()=>{if(!(typeof window>"u"))return c!==null&&(window.addEventListener("mousemove",f),window.addEventListener("touchmove",f),window.addEventListener("mouseup",x),window.addEventListener("touchend",x)),()=>{window.removeEventListener("mousemove",f),window.removeEventListener("touchmove",f),window.removeEventListener("mouseup",x),window.removeEventListener("touchend",x)}},[c,f,x]),{items:r,draggedItem:o,draggedIndex:c,itemRefs:s,handleDragStart:l}},ar=({items:e,renderItem:t,containerProps:r,itemProps:g,draggedIndex:o,itemRefs:a,handleDragStart:c,views:b,themeMode:i})=>n.jsx(h.View,{overflow:"hidden",position:"relative",...r,...b==null?void 0:b.container,children:e.map((s,l)=>n.jsx(h.View,{ref:f=>{a.current[l]=f},onMouseDown:f=>c(f,l),onTouchStart:f=>c(f,l),position:"relative",cursor:"grab",transition:"transform 0.2s",...g,...b==null?void 0:b.item,children:t?t(s,l):s},l))}),bt=e=>{const{items:t,draggedIndex:r,itemRefs:g,handleDragStart:o}=ir(e);return n.jsx(ar,{...e,items:t,draggedIndex:r,itemRefs:g,handleDragStart:o})},cr=bt,lr=({onFileSelect:e,onMultipleFileSelect:t,validateFile:r,accept:g,multiple:o,disabled:a,previewUrl:c})=>{const[b,i]=C.useState(!1),[s,l]=C.useState(null),f=C.useRef(null),x=c!==void 0?c:s;C.useEffect(()=>()=>{s&&URL.revokeObjectURL(s)},[s]);const y=C.useCallback(I=>{I.preventDefault(),I.stopPropagation(),!a&&i(!0)},[a]),u=C.useCallback(I=>{I.preventDefault(),I.stopPropagation(),!a&&i(!1)},[a]),j=C.useCallback(I=>{I.preventDefault(),I.stopPropagation(),!a&&i(!0)},[a]),S=C.useCallback(I=>{if(!I||I.length===0)return;const k=Array.from(I);if(!o&&k.length>0){const M=k[0];if(M.type.startsWith("image/")){const p=URL.createObjectURL(M);l(w=>(w&&URL.revokeObjectURL(w),p))}else l(null)}o?t&&t(k):k.length>0&&e&&e(k[0])},[o,t,e]),D=C.useCallback(I=>{I.preventDefault(),I.stopPropagation(),i(!1),!a&&I.dataTransfer.files&&I.dataTransfer.files.length>0&&(S(I.dataTransfer.files),I.dataTransfer.clearData())},[a,S]),d=C.useCallback(()=>{var I;a||(I=f.current)==null||I.click()},[a]),m=C.useCallback(I=>{S(I.target.files),I.target.value&&(I.target.value="")},[S]);return{isDragActive:b,handleDragEnter:y,handleDragLeave:u,handleDragOver:j,handleDrop:D,handleClick:d,handleFileChange:m,inputRef:f,preview:x}},sr={position:"absolute",top:"-4px",right:"-4px",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:"rgba(0, 0, 0, 0.5)",color:"white",border:"none",padding:0,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"12px",zIndex:10,_hover:{backgroundColor:"rgba(0, 0, 0, 0.7)"}},kt=({files:e,sandboxId:t,onRemove:r,layout:g="inline",maxHeight:o="120px",showPreviews:a=!1,views:c={}})=>{if(e.length===0)return null;const b=C.useCallback(s=>s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`,[]),i=C.useCallback(s=>s.type.startsWith("image/")?{backgroundColor:"#DBEAFE",color:"#2563EB"}:s.type.startsWith("video/")?{backgroundColor:"#EDE9FE",color:"#7C3AED"}:s.type.startsWith("audio/")?{backgroundColor:"#DCFCE7",color:"#16A34A"}:{backgroundColor:"#E2E8F0",color:"#475569"},[]);return n.jsx(h.View,{display:"flex",flexWrap:"wrap",gap:"8px",padding:"8px 0",maxHeight:o,overflowY:"auto",...c==null?void 0:c.container,children:e.map((s,l)=>{const f=typeof URL<"u"&&typeof URL.createObjectURL=="function"&&typeof Blob<"u"&&s instanceof Blob,x=(s==null?void 0:s.path)||(s==null?void 0:s.url)||(a&&f?URL.createObjectURL(s):""),y=s.type.startsWith("image/"),u=s.type.startsWith("video/"),j=s.type.startsWith("audio/"),S=i(s);return a?n.jsx(h.Vertical,{alignItems:"center",gap:"6px",padding:"6px 10px",borderRadius:"8px",border:"1px solid #E2E8F0",backgroundColor:"color-white",animate:{from:{opacity:0,scale:.9},to:{opacity:1,scale:1}},animationDuration:.2,...c==null?void 0:c.item,children:a&&n.jsxs(ce.HoverCard,{children:[n.jsxs(ce.HoverCard.Trigger,{children:[y&&n.jsx(h.Image,{src:x,alt:s.name,width:"60px",height:"60px",borderRadius:"8px",objectFit:"cover"}),u&&n.jsx(h.View,{as:"video",src:x,alt:s.name,controls:!1,muted:!0,width:"60px",height:"60px",borderRadius:"8px",objectFit:"cover"}),j&&n.jsx(h.Center,{width:"60px",height:"60px",borderRadius:"8px",backgroundColor:"color-gray-100",children:n.jsx(E.AudioIcon,{widthHeight:24,color:"color-black"})}),!y&&!u&&!j&&n.jsx(h.Center,{width:"60px",height:"60px",borderRadius:"8px",backgroundColor:"color-gray-100",children:n.jsx(E.FileIcon,{widthHeight:24,color:"color-black"})}),r&&n.jsx(h.Button,{...sr,onClick:D=>{D.stopPropagation(),r(l)},"aria-label":`Remove ${s.name}`,children:"×"})]}),n.jsxs(ce.HoverCard.Content,{children:[y&&n.jsx(h.Image,{src:x,alt:s.name,maxWidth:"100%"}),u&&n.jsx(h.View,{as:"video",src:x,controls:!0,maxWidth:"100%"}),j&&n.jsx(h.View,{as:"audio",src:x,controls:!0,width:"100%"}),n.jsxs(h.Text,{marginTop:"4px",maxLines:1,width:"100%",...c==null?void 0:c.name,children:[s.name," (",b(s.size),")"]})]})]})},l):n.jsxs(h.Horizontal,{alignItems:"center",gap:"8px",padding:"6px 10px 6px 8px",borderRadius:"9999px",border:"1px solid #E2E8F0",backgroundColor:"color-white",maxWidth:"100%",animate:{from:{opacity:0,scale:.96},to:{opacity:1,scale:1}},animationDuration:.2,...c==null?void 0:c.item,children:[n.jsx(h.Center,{width:"22px",height:"22px",minWidth:"22px",borderRadius:"9999px",backgroundColor:S.backgroundColor,color:S.color,children:j?n.jsx(E.AudioIcon,{widthHeight:12,color:"currentColor"}):n.jsx(E.FileIcon,{widthHeight:12,color:"currentColor"})}),n.jsxs(h.Text,{fontSize:"12px",lineHeight:"16px",color:"color-gray-600",maxLines:1,maxWidth:"220px",...c==null?void 0:c.name,children:[s.name," · ",b(s.size)]}),r&&n.jsx(h.View,{as:"button",type:"button",onClick:()=>r(l),"aria-label":`Remove ${s.name}`,display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",minWidth:"16px",border:"none",backgroundColor:"transparent",color:"color-gray-400",padding:0,cursor:"pointer",transition:"color 0.2s ease, opacity 0.2s ease",_hover:{color:"color-gray-600"},children:"×"})]},l)})})},dr=({children:e,text:t="Drop files here or click to upload",textProps:r,containerProps:g,disabled:o,accept:a,multiple:c,isDragActive:b,handleDragEnter:i,handleDragLeave:s,handleDragOver:l,handleDrop:f,handleClick:x,handleFileChange:y,inputRef:u,preview:j,imageProps:S,selectedFiles:D,onRemove:d})=>n.jsxs(h.Center,{width:"100%",minHeight:"200px",height:D&&D.length>0?"auto":"200px",borderWidth:2,borderStyle:"dashed",borderColor:b?"theme-primary":"color-gray-300",borderRadius:12,backgroundColor:b?"#EFF6FF":"color-gray-50",flexDirection:"column",cursor:o?"not-allowed":"pointer",opacity:o?.6:1,onClick:x,onDragEnter:i,onDragLeave:s,onDragOver:l,onDrop:f,transition:"background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease",overflow:"hidden",position:"relative",padding:16,...g,children:[n.jsx("input",{type:"file",ref:u,onChange:y,accept:a,multiple:c,style:{display:"none"},disabled:o}),j&&!c?n.jsxs(h.View,{width:"100%",height:"200px",position:"relative",children:[n.jsx(h.Image,{src:j,alt:"Preview",width:"100%",height:"100%",objectFit:"contain",...S}),n.jsx(h.Center,{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.3)",opacity:0,_hover:{opacity:1},transition:"opacity 0.2s",children:n.jsx(h.Text,{color:"white",fontWeight:600,children:"Click to replace"})})]}):n.jsxs(h.View,{flexDirection:"column",alignItems:"center",width:"100%",children:[e||n.jsxs(h.View,{flexDirection:"column",alignItems:"center",width:"100%",children:[n.jsx(E.UploadIcon,{widthHeight:40,color:b?"theme-primary":"color-gray-500"}),n.jsx(h.Text,{marginTop:16,color:b?"theme-primary":"color-gray-600",fontWeight:500,textAlign:"center",...r,children:t})]}),c&&D&&D.length>0&&n.jsx(h.View,{marginTop:16,width:"100%",children:n.jsx(kt,{files:D,onRemove:d||(()=>{}),showPreviews:!0,layout:"inline",maxHeight:"160px"})})]})]}),ur=e=>{const t=lr(e);return n.jsx(dr,{...e,...t})},hr=e=>{const t=K.useEmojiPickerState(e);return n.jsx(K.EmojiPickerView,{...t,...e})},yt=hr,gr=["paragraph","h1","h2","h3","bullet","number","quote","codeBlock","table"];function Se(e){const t=e.trim();return!!t&&!/[\u0000-\u0020\u007f\\]/.test(t)&&(!/^[a-z][a-z\d+.-]*:/i.test(t)||/^(https?:|mailto:|tel:)/i.test(t))}function pr(e){const t=/^(!?)\[((?:\\.|[^\]\\\n])*)\]\(/.exec(e);if(!t)return null;let r=t[0].length;const g=r;let o=0;for(;r<e.length;r++){if(e[r]==="\\"){r++;continue}if(e[r]==="(")o++;else if(e[r]===")"){if(!o)break;o--}else if(/\s/.test(e[r]))break}const a=e.slice(g,r).replace(/\\([()\\])/g,"$1"),c=/^(?:[ \t]+(?:"([^"\n]*)"|'([^'\n]*)'))?\)/.exec(e.slice(r));return c?{image:!!t[1],label:t[2],url:a,title:c[1]??c[2],labelStart:t[1].length+1,length:r+c[0].length}:null}function Ue(e){return Se(e)&&!/^(?:mailto|tel):/i.test(e.trim())}function fr(e){return/^[a-z][a-z\d+.-]*:\/\/[^\s\\]+$/i.test(e)&&!/^(?:javascript|vbscript|data|file|blob):/i.test(e)}function me(e,t=0,r=0,g=!1){var b;if(r>20)return[{kind:"text",text:e,start:t,end:t+e.length}];const o=[];let a=0;const c=(i,s,l)=>o.push({kind:"text",text:i,start:t+s,end:t+l});for(;a<e.length;){const i=g&&/^(?: {2,}|\\)\r?\n/.exec(e.slice(a));if(i){o.push({kind:"break",start:t+a,end:t+a+i[0].length}),a+=i[0].length;continue}if(e[a]==="\\"&&/[\\`*{}\[\]()#+.!_>~|]/.test(e[a+1]||"")){c(e[a+1],a+1,a+2),a+=2;continue}const s=/^<br\s*\/?\s*>/i.exec(e.slice(a));if(s){o.push({kind:"break",start:t+a,end:t+a+s[0].length}),a+=s[0].length;continue}const l=/^`+/.exec(e.slice(a));if(l){const j=e.indexOf(l[0],a+l[0].length);if(j>=0){o.push({kind:"code",text:e.slice(a+l[0].length,j),start:t+a,end:t+j+l[0].length,contentStart:t+a+l[0].length}),a=j+l[0].length;continue}}const f=g&&pr(e.slice(a));if(f){o.push({kind:f.image?"image":"link",start:t+a,end:t+a+f.length,url:f.url,title:f.title,text:f.image?f.label.replace(/\\([\\`*{}\[\]()#+.!_>~|])/g,"$1"):void 0,children:f.image?void 0:me(f.label,t+a+f.labelStart,r+1,g)}),a+=f.length;continue}const x=!g&&/^\[([^\]\n]+)\]\(([^\s()]*)\)/.exec(e.slice(a));if(x){o.push({kind:"link",start:t+a,end:t+a+x[0].length,url:x[2],children:me(x[1],t+a+1,r+1)}),a+=x[0].length;continue}const y=[["***","***","bold"],["**","**","bold"],["__","__","bold"],["~~","~~","strikethrough"],["<u>","</u>","underline"],["`","`","code"],["*","*","italic"],["_","_","italic"]];let u=!1;for(const[j,S,D]of y){if(!e.startsWith(j,a))continue;let d=e.indexOf(S,a+j.length);for(;d>=0&&e[d-1]==="\\";)d=e.indexOf(S,d+S.length);if((j==="*"||j==="_")&&e.startsWith(j+j,d)){const k=e.indexOf(j+j,d+2);k>=0&&(d=e.indexOf(j,k+2))}if((j==="**"||j==="__")&&e[d+2]===j[0]&&(((b=e.slice(a+2,d).match(new RegExp(`\\${j[0]}(?!\\${j[0]})`,"g")))==null?void 0:b.length)||0)%2===1&&d++,d<=a+j.length||j==="_"&&/\w/.test(e[a-1]||"")&&/\w/.test(e[d+1]||""))continue;const m=e.slice(a+j.length,d);let I=D==="code"?void 0:me(m,t+a+j.length,r+1,g);j==="***"&&(I=[{kind:"italic",start:t+a+2,end:t+d+1,children:I}]),o.push({kind:D,start:t+a,end:t+d+S.length,text:D==="code"?m:void 0,children:I}),u=!0,a=d+S.length;break}u||(c(e[a],a,a+1),a++)}return o.reduce((i,s)=>{const l=i[i.length-1];return(l==null?void 0:l.kind)==="text"&&s.kind==="text"&&l.end===s.start?(l.text+=s.text,l.end=s.end):i.push(s),i},[])}function _e(e,t=[],r,{display:g=!1}={}){var j,S,D;const o=e.replace(g?/^ {0,3}(`{3,}|~{3,})[^\n]*\n[\s\S]*?(?:^ {0,3}\1[ \t]*$|(?![\s\S]))/gm:/^ {0,3}(`{3,}|~{3,})[^\n]*\n[\s\S]*?^ {0,3}\1\s*$/gm,"").replace(/`[^`\n]*`/g,""),a=g?/^(?:import |export |\s*:::|\s*\[.+\]:|\s*={3,}\s*$)|\[\^[^\]]+\]|\$\$|\{[^}\n]*\}|<(?!(?:\/?u>|br\s*\/?>))\/?[A-Za-z!]|&(?:#\w+|\w+);/m.test(o)||/^(?:---|\+\+\+)[ \t]*\r?\n[ \t]*[\w-]+:/.test(e)||/^(?:>[ \t]*>| {1,3}#{1,6}\s|#{1,6}\t|[ \t]{2,}(?:>|#{1,6}\s|\|))|^[ \t]{2,}(?:`{3,}|~{3,})/m.test(o):/^(?:import |export |-{3,}\s*$|\+\+\+\s*$|\s*:::|\s*\[.+\]:|\s*#{4,}\s|\s*(?:\*\s*){3,}$|\s*(?:-\s*){3,}$|\s*(?:_\s*){3,}$|\s*={3,}\s*$)|!\[|\[\^[^\]]+\]|\$\$|\{[^}\n]*\}|<(?!(?:\/?u>|br\s*\/?>))\/?[A-Za-z!]|&(?:#\w+|\w+);/m.test(o)||/^[ \t]{2,}(?:`{3,}|~{3,})/m.test(e)||/^(?:>[ \t]*>| {1,3}#{1,6}\s|#{1,6}\t|[ \t]{2,}(?:>|#{1,6}\s|\|)|[ \t]*(?:[-*+] |\d+[.)] )\[[ xX]\])|(?: {2,}|\\)\r?$/m.test(o)||Array.from(o.matchAll(/\[[^\]\n]+\]\(([^)\n]*)\)/g)).some(d=>/[\s(]/.test(d[1])||!Se(d[1]))||o.split(/\r?\n/).some(d=>me(d.trim(),0,0,!0).some(m=>m.kind==="link"&&m.title==="video")),c=[],b=/[^\r\n]+|\r\n|\n|\r/g;let i=0;for(const d of e.matchAll(b))/^[\r\n]/.test(d[0])&&(c.push({text:e.slice(i,d.index),start:i,end:d.index}),i=d.index+d[0].length);(i<e.length||!c.length)&&c.push({text:e.slice(i),start:i,end:e.length});const s=[],l=new Set;let f=a;const x=/^\s*(?:[-*+] |\d+[.)] )/,y=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/,u=/^ {0,3}(?:(?:\*[ \t]*){3,}|(?:-[ \t]*){3,}|(?:_[ \t]*){3,})$/;for(let d=0;d<c.length;){if(!c[d].text.trim()){const Z=d;for(;d<c.length&&!c[d].text.trim();)d++;const Y=d-Z,q=!s.length,H=q?Math.floor(Y/2)+(d===c.length?1:0):d===c.length?Math.ceil(Y/2):Math.floor(Y/2);for(let ee=0;ee<H;ee++){const re=((j=c[Z+ee*2+(q?0:1)])==null?void 0:j.start)??e.length,ie=((S=t.find(se=>!se.raw&&!l.has(se.id)))==null?void 0:S.id)||P.generateId("block");l.add(ie),s.push({id:ie,kind:"paragraph",raw:"",body:"",start:re,end:re,bodyStart:re})}continue}const m=c[d];let I=d,k="paragraph",M=0,p;const w=(g?/^(#{1,6}) (.*)$/:/^(#{1,3}) (.*)$/).exec(m.text),R=/^ {0,3}(`{3,}|~{3,})([\w+-]*)\s*$/.exec(m.text);let V=!1;if(g&&u.test(m.text))k="hr";else if(w)k=`h${w[1].length}`,M=w[1].length+1;else if(R){for(k="codeBlock",p=R[2],I++;I<c.length&&!new RegExp(`^ {0,3}${R[1][0]}{${R[1].length},}\\s*$`).test(c[I].text);)I++;I>=c.length&&(g||(f=!0),V=!0,I=c.length-1),M=m.end-m.start+(e.slice(m.end,m.end+2)===`\r
|
|
2
|
+
`?2:1)}else if(d+1<c.length&&m.text.includes("|")&&y.test(c[d+1].text))for(k="table",I=d+1;I+1<c.length&&c[I+1].text.trim()&&c[I+1].text.includes("|");)I++;else if(x.test(m.text)){for(k=/^\s*\d/.test(m.text)?"number":"bullet";I+1<c.length&&c[I+1].text.trim()&&(x.test(c[I+1].text)||/^\s{2,}\S/.test(c[I+1].text));)I++;M=m.text.match(x)[0].length}else if(/^> ?/.test(m.text))for(k="quote",M=m.text.match(/^> ?/)[0].length;I+1<c.length&&/^> ?/.test(c[I+1].text);)I++;else{for(;I+1<c.length&&c[I+1].text.trim()&&!/^(?:#{1,6} |>|`{3}|~{3})/.test(c[I+1].text)&&!(g&&u.test(c[I+1].text))&&!x.test(c[I+1].text);)I++;/^ {4}\S/.test(m.text)&&(f=!0)}const W=e.slice(m.start,c[I].end),A=t.find(Z=>Z.id===r&&Z.start===m.start&&!l.has(Z.id)),B=t[s.length],O=A||t.find(Z=>Z.raw===W&&!l.has(Z.id))||(B&&!l.has(B.id)&&e.indexOf(B.raw,c[I].end)<0?B:void 0),N=(O==null?void 0:O.id)||P.generateId("block");l.add(N);let _=W.slice(M);k==="codeBlock"&&(_=e.slice(m.start+M,V?c[I].end:c[I].start).replace(/\r?\n$/,"")),s.push({id:N,kind:k,raw:W,start:m.start,end:c[I].end,body:_,bodyStart:m.start+M,language:p}),d=I+1}return s.length||s.push({id:((D=t[0])==null?void 0:D.id)||P.generateId("block"),kind:"paragraph",raw:"",body:"",start:e.length,end:e.length,bodyStart:e.length}),{blocks:s,sourceMode:f}}function ye(e,t,r){const g=Math.max(0,Math.min(t.start,e.length)),o=Math.max(g,Math.min(t.end,e.length));return e.slice(0,g)+r+e.slice(o)}function mr(e,t){const r=e.kind==="codeBlock"?e.body:e.raw.replace(/^(?:#{1,3} |\s*[-*+] |\s*\d+[.)] |> ?)/gm,"");if(t==="codeBlock"){const o="`".repeat(Math.max(3,...Array.from(r.matchAll(/`+/g),a=>a[0].length+1)));return`${o}
|
|
3
3
|
${r}
|
|
4
4
|
${o}`}if(t==="table")return`| Column 1 | Column 2 | Column 3 |
|
|
5
5
|
| --- | --- | --- |
|
|
6
6
|
| `+r.replace(/\|/g,"\\|").replace(/\r?\n/g," ")+" | | |";const g={paragraph:"",h1:"# ",h2:"## ",h3:"### ",bullet:"- ",number:"1. ",quote:"> "}[t];return r.split(/\r?\n/).map((o,a)=>t==="number"?`${a+1}. ${o}`:g+o).join(`
|
|
7
|
-
`)}function st(e,t){const r={...t},g=o=>{var s,l,f,x;(s=o.children)==null||s.forEach(g);const a=(l=o.children)==null?void 0:l[0],c=(f=o.children)==null?void 0:f[o.children.length-1],b=o.kind==="code"?o.contentStart:a==null?void 0:a.start,i=o.kind==="code"?o.contentStart+(((x=o.text)==null?void 0:x.length)||0):c==null?void 0:c.end;b!==void 0&&i!==void 0&&r.start<=b&&r.end>=i&&(r.start=Math.min(r.start,o.start),r.end=Math.max(r.end,o.end))};return e.filter(o=>o.kind!=="codeBlock"&&t.start<o.end&&t.end>o.start).forEach(o=>
|
|
8
|
-
`)?2:1);const u=(S,D)=>{const d={start:Math.max(r.start,S),end:Math.min(r.end,D)};d.end>d.start&&a.push(d)};if(s.kind==="table"){if(x===1)return;let S=f.startsWith("|")?1:0;for(let D=S;D<=f.length;D++)if(D===f.length||f[D]==="|"&&f[D-1]!=="\\"){const d=f.slice(S,D),m=d.trim(),I=y+S+d.indexOf(m);u(I,I+m.length),S=D+1}}else{const S=((j=f.match(/^(?:#{1,3} |\s*(?:[-*+] |\d+[.)] )|> ?)/))==null?void 0:j[0].length)||0;u(y+S,y+f.length)}})}let c=e;const b={...r},i=a.length>0&&a.every(s=>ve(e,s,g,o).removed);for(const s of a.reverse()){const l=ve(c,s,g,o);!i&&l.removed||(b.end=s.end===r.end?l.selection.end:b.end+l.value.length-c.length,s.start===r.start&&(b.start=l.selection.start),c=l.value)}return{value:c,selection:b}}function ve(e,t,r,g){const o={bold:["**","**"],italic:["*","*"],underline:["<u>","</u>"],strikethrough:["~~","~~"],code:["`","`"]};let[a,c]=r==="link"?["[",`](${g})`]:o[r]||["",""];const b=e.slice(t.start,t.end)||r==="link"&&g||"",i=
|
|
7
|
+
`)}function st(e,t){const r={...t},g=o=>{var s,l,f,x;(s=o.children)==null||s.forEach(g);const a=(l=o.children)==null?void 0:l[0],c=(f=o.children)==null?void 0:f[o.children.length-1],b=o.kind==="code"?o.contentStart:a==null?void 0:a.start,i=o.kind==="code"?o.contentStart+(((x=o.text)==null?void 0:x.length)||0):c==null?void 0:c.end;b!==void 0&&i!==void 0&&r.start<=b&&r.end>=i&&(r.start=Math.min(r.start,o.start),r.end=Math.max(r.end,o.end))};return e.filter(o=>o.kind!=="codeBlock"&&t.start<o.end&&t.end>o.start).forEach(o=>me(o.raw,o.start).forEach(g)),r}function xr(e,t,r,g,o){const a=[];for(const s of t){if(s.kind==="codeBlock"||s.end<=r.start||s.start>=r.end)continue;let l=s.start;s.raw.split(/\r?\n/).forEach((f,x)=>{var j;const y=l;l+=f.length+(s.raw.includes(`\r
|
|
8
|
+
`)?2:1);const u=(S,D)=>{const d={start:Math.max(r.start,S),end:Math.min(r.end,D)};d.end>d.start&&a.push(d)};if(s.kind==="table"){if(x===1)return;let S=f.startsWith("|")?1:0;for(let D=S;D<=f.length;D++)if(D===f.length||f[D]==="|"&&f[D-1]!=="\\"){const d=f.slice(S,D),m=d.trim(),I=y+S+d.indexOf(m);u(I,I+m.length),S=D+1}}else{const S=((j=f.match(/^(?:#{1,3} |\s*(?:[-*+] |\d+[.)] )|> ?)/))==null?void 0:j[0].length)||0;u(y+S,y+f.length)}})}let c=e;const b={...r},i=a.length>0&&a.every(s=>ve(e,s,g,o).removed);for(const s of a.reverse()){const l=ve(c,s,g,o);!i&&l.removed||(b.end=s.end===r.end?l.selection.end:b.end+l.value.length-c.length,s.start===r.start&&(b.start=l.selection.start),c=l.value)}return{value:c,selection:b}}function ve(e,t,r,g){const o={bold:["**","**"],italic:["*","*"],underline:["<u>","</u>"],strikethrough:["~~","~~"],code:["`","`"]};let[a,c]=r==="link"?["[",`](${g})`]:o[r]||["",""];const b=e.slice(t.start,t.end)||r==="link"&&g||"",i=me(b);if(r!=="link"&&i.length===1&&i[0].kind===r&&i[0].end===b.length){const x=r==="code"?i[0].contentStart:a.length,y=r==="code"?x:c.length,u=b.slice(x,b.length-y);return{removed:!0,value:ye(e,t,u),selection:{start:t.start,end:t.start+u.length}}}if(r==="code"&&(a=c="`".repeat(Math.max(1,...Array.from(b.matchAll(/`+/g),x=>x[0].length+1)))),e.slice(t.start-a.length,t.start)===a&&e.slice(t.end,t.end+c.length)===c)return{removed:!0,value:ye(e,{start:t.start-a.length,end:t.end+c.length},b),selection:{start:t.start-a.length,end:t.end-a.length}};const s=[],l=x=>{var u;if((u=x.children)==null||u.forEach(l),x.kind!==r)return;const y=r==="code"?x.contentStart-x.start:a.length;s.push({start:x.start,end:x.start+y},{start:r==="link"?x.children[x.children.length-1].end:x.end-(r==="code"?y:c.length),end:x.end})};i.forEach(l);let f=b;return s.sort((x,y)=>y.start-x.start).forEach(x=>{f=f.slice(0,x.start)+f.slice(x.end)}),{value:ye(e,t,a+f+c),selection:{start:t.start+a.length,end:t.start+a.length+f.length}}}const Ke=/^(\s*)([-*+] |\d+[.)] )/;function Re(e,t){var r,g,o,a;for(const c of me(e)){const b=((g=(r=c.children)==null?void 0:r[0])==null?void 0:g.start)??c.contentStart,i=((a=(o=c.children)==null?void 0:o[c.children.length-1])==null?void 0:a.end)??(b===void 0?void 0:c.end-(b-c.start));if(b!==void 0&&i!==void 0&&t>=b&&t<=i){const[s,l]=Re(e.slice(b,i),t-b),f=x=>x?e.slice(c.start,b)+x+e.slice(i,c.end):"";return[e.slice(0,c.start)+f(s),f(l)+e.slice(c.end)]}c.kind==="text"&&t===c.start&&e[t-1]==="\\"&&t--}return[e.slice(0,t),e.slice(t)]}function ke(e,t,r,g){return{value:ye(e,t,r),selection:{start:g,end:g}}}function Ct(e,t,r,g=!1){var x,y,u;const o=t.find(j=>r.start>=j.start&&r.end<=j.end);if(!o)return null;const a=o.raw.includes(`\r
|
|
9
9
|
`)||e.includes(`\r
|
|
10
10
|
`)?`\r
|
|
11
11
|
`:`
|
|
12
|
-
`;if(o.kind==="codeBlock"||o.kind==="table"||g){if(o.kind==="table"&&/[|\r\n]/.test(e.slice(r.start,r.end)))return null;const j=o.kind==="codeBlock"?a:"<br>";return
|
|
12
|
+
`;if(o.kind==="codeBlock"||o.kind==="table"||g){if(o.kind==="table"&&/[|\r\n]/.test(e.slice(r.start,r.end)))return null;const j=o.kind==="codeBlock"?a:"<br>";return ke(e,r,j,r.start+j.length)}const c=r.start-o.start,b=r.end-o.start;let i,s;if(o.kind==="bullet"||o.kind==="number"){const j=o.raw.lastIndexOf(`
|
|
13
13
|
`,Math.max(0,c-1))+1,S=o.raw.indexOf(`
|
|
14
14
|
`,b),D=S<0?o.raw.length:S,d=o.raw.slice(j,o.raw.indexOf(`
|
|
15
15
|
`,c)<0?o.raw.length:o.raw.indexOf(`
|
|
16
16
|
`,c)).replace(/\r$/,""),m=((x=d.match(Ke))==null?void 0:x[0])||"",I=o.raw.lastIndexOf(`
|
|
17
|
-
`,Math.max(0,b-1))+1,k=o.raw.slice(I,D).replace(/\r$/,""),M=((y=k.match(Ke))==null?void 0:y[0])||"";i=Re(d.slice(m.length),Math.max(0,c-j-m.length))[0],s=Re(k.slice(M.length),Math.max(0,b-I-M.length))[1];const p=o.raw.slice(0,j).replace(/\r?\n$/,"");let w=o.raw.slice(D).replace(/^\r?\n/,"");if(!i&&!s){if(/^\s/.test(m)){const A=m.replace(/^(?: {1,2}|\t)/,""),
|
|
18
|
-
`,g-a.start-1)+1,x=(s=a.raw.slice(f).match(Ke))==null?void 0:s[0];if(!f||!x)return null;const y=f-(a.raw[f-2]==="\r"?2:1);let u=a.raw.slice(f+x.length);if(/\d+[.)] $/.test(x)){const j=((l=x.match(/^\s*/))==null?void 0:l[0])||"";u=u.replace(/(\r?\n)([ \t]*)(\d+)([.)] )/g,(S,D,d,m,I)=>d===j?D+d+Math.max(1,Number(m)-1)+I:S)}return
|
|
19
|
-
`:u.text||"").join("");b=a.kind==="codeBlock"?a.body:f(
|
|
17
|
+
`,Math.max(0,b-1))+1,k=o.raw.slice(I,D).replace(/\r$/,""),M=((y=k.match(Ke))==null?void 0:y[0])||"";i=Re(d.slice(m.length),Math.max(0,c-j-m.length))[0],s=Re(k.slice(M.length),Math.max(0,b-I-M.length))[1];const p=o.raw.slice(0,j).replace(/\r?\n$/,"");let w=o.raw.slice(D).replace(/^\r?\n/,"");if(!i&&!s){if(/^\s/.test(m)){const A=m.replace(/^(?: {1,2}|\t)/,""),B=[p,A,w].filter((O,N)=>O||N===1).join(a);return ke(e,o,B,o.start+(p?p.length+a.length:0)+A.length)}const W=[p,"",w].filter((A,B)=>A||B===1).join(a+a);return ke(e,o,W,o.start+(p?p.length+a.length*2:0))}const R=m.replace(/(\d+)([.)] )$/,(W,A,B)=>`${Number(A)+1}${B}`);if(/\d+[.)] $/.test(m)){const W=((u=m.match(/^\s*/))==null?void 0:u[0])||"";w=w.split(a).map(A=>A.replace(/^(\s*)(\d+)([.)] )/,(B,O,N,_)=>O===W?O+(Number(N)+1)+_:B)).join(a)}const V=[p,m+i,R+s,w].filter((W,A)=>W||A===1||A===2).join(a);return ke(e,o,V,o.start+(p?p.length+a.length:0)+m.length+i.length+a.length+R.length)}const l=o.raw.slice(0,o.bodyStart-o.start);i=Re(o.body,Math.max(0,c-l.length))[0],s=Re(o.body,Math.max(0,b-l.length))[1],!i&&s?s=l+s:(i=l+i,o.kind==="quote"&&s&&(s="> "+s));const f=i+a+a+s;return ke(e,o,f,o.start+i.length+a.length*2+(!i&&s?l.length:o.kind==="quote"&&s?2:0))}function br(e){return e.kind==="codeBlock"?e.body.split(/\r?\n/).map(t=>{if(!t)return"";const r="`".repeat(Math.max(1,...Array.from(t.matchAll(/`+/g),g=>g[0].length+1)));return r+t+r}).join("<br>"):(e.kind==="quote"?e.raw.replace(/^> ?/gm,""):e.kind==="bullet"||e.kind==="number"?e.raw.replace(/^(\s*)([-*+] |\d+[.)] )/gm,""):e.body).replace(/\r?\n/g,"<br>")}function St(e,t,r,g){var s,l;const o=t.findIndex(f=>f.id===r),a=t[o],c=t[o-1];if(a&&g!==void 0&&(a.kind==="bullet"||a.kind==="number")){const f=a.raw.lastIndexOf(`
|
|
18
|
+
`,g-a.start-1)+1,x=(s=a.raw.slice(f).match(Ke))==null?void 0:s[0];if(!f||!x)return null;const y=f-(a.raw[f-2]==="\r"?2:1);let u=a.raw.slice(f+x.length);if(/\d+[.)] $/.test(x)){const j=((l=x.match(/^\s*/))==null?void 0:l[0])||"";u=u.replace(/(\r?\n)([ \t]*)(\d+)([.)] )/g,(S,D,d,m,I)=>d===j?D+d+Math.max(1,Number(m)-1)+I:S)}return ke(e,a,a.raw.slice(0,y)+u,a.start+y)}if(!a||!c||a.kind==="table"||c.kind==="table")return null;if(!c.raw)return ke(e,{start:c.start,end:a.end},a.raw,c.start+a.bodyStart-a.start);let b=br(a);const i=c.kind==="codeBlock"?c.bodyStart+c.body.length:c.end;if(c.kind==="codeBlock"){const f=y=>y.map(u=>u.children?f(u.children):u.kind==="break"?`
|
|
19
|
+
`:u.text||"").join("");b=a.kind==="codeBlock"?a.body:f(me(b));const x=ye(c.raw,{start:i-c.start,end:i-c.start},b);return ke(e,{start:c.start,end:a.end},x,i)}return ke(e,{start:c.end,end:a.end},b,i)}const jt={document:"Document",paragraph:"Paragraph",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",bullet:"Bulleted list",number:"Numbered list",quote:"Quote",codeBlock:"Code block",table:"Table",blocks:"Blocks /",below:"Insert below",duplicate:"Duplicate",delete:"Delete",up:"Move up",down:"Move down",drag:"Drag block",bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",code:"Inline code",link:"Link",linkUrl:"Link address",invalidLink:"Enter an http, https, mailto, tel or relative link.",media:"Insert image or video",image:"Image",video:"Video",mediaUrl:"Media address",mediaDescription:"Description / alternative text",mediaSource:"Inserting media switches this document to Markdown source editing.",invalidMedia:"Choose an image or video and a safe http, https or relative address.",upload:"Upload a file",uploading:"Uploading…",pickingMedia:"Choose a file…",uploadError:"Upload failed. Your document is unchanged.",cancelUpload:"Cancel upload",mediaStale:"The document has changed. Close this panel and choose the insertion point again.",undo:"Undo",redo:"Redo",source:"Markdown source",visual:"Visual editor",emoji:"Insert emoji",sourceFallback:"This Markdown contains syntax that visual editing cannot preserve. Edit its source instead.",selectionToolbar:"Selection actions",askSelection:"Edit selection with AI",askSection:"Edit document with AI",aiPanel:"AI proposal",instruction:"Describe the change",generating:"Preparing proposal…",aiError:"Generation failed. Your text is unchanged.",proposal:"Proposal",apply:"Apply",discard:"Discard",cancel:"Close",retry:"Retry",generate:"Generate",stale:"The document has changed. Select the text again before generating a proposal.",selectionRequired:"Select text inside this editor first.",save:"Save",empty:"Write something…"};function kr(e){const t=e.value??e.defaultValue??"",r=C.useId(),[g,o]=C.useState(t),[a,c]=C.useState(()=>{const T=_e(t);return T.blocks.forEach((L,z)=>{L.id=`${r}-block-${z}`}),T}),[b,i]=C.useState({start:0,end:0}),[s,l]=C.useState(0),[f,x]=C.useState(!1),[y,u]=C.useState(null),[j,S]=C.useState(null),[D,d]=C.useState(!1),[m,I]=C.useState(""),[k,M]=C.useState(""),[p,w]=C.useState(null),[R,V]=C.useState(null),W=C.useRef(null),A=C.useRef(0),B=C.useRef(null),O=T=>{W.current=T,V(T)},N=()=>{var T;A.current++,(T=B.current)==null||T.abort(),B.current=null},[_,Z]=C.useState(0),Y={...jt,...e.labels},q=!!(e.isDisabled||e.isReadOnly),H=C.useRef({value:t,selection:b}),ee=C.useRef(a),re=C.useRef({undo:[],redo:[],lastInput:0}),ie=C.useRef(0),se=C.useRef(!1),$=C.useRef(!1),F=C.useRef(null),X=C.useRef(0),G=C.useRef(e);G.current=e;const U=C.useRef(p);U.current=p;const Q=C.useRef(!0);C.useEffect(()=>(Q.current=!0,()=>{Q.current=!1,X.current++,N()}),[]);const oe=T=>{const L={start:Math.max(0,Math.min(T.start,H.current.value.length)),end:Math.max(0,Math.min(T.end,H.current.value.length)),...T.backward?{backward:!0}:{}};L.end<L.start&&([L.start,L.end]=[L.end,L.start]),!(L.start===H.current.selection.start&&L.end===H.current.selection.end&&!!L.backward==!!H.current.selection.backward)&&(re.current.lastInput=0,H.current.selection=L,i(L))},ue=(T=H.current.selection)=>{oe(T),se.current=!0,l(L=>L+1)},ae=(T,L=!0,z)=>{W.current&&(N(),O({...W.current,phase:"stale",error:void 0}));const v=_e(T.value,ee.current.blocks,z);ee.current=v,H.current=T,ie.current++,c(v),o(T.value),i(T.selection),L&&(se.current=!0,l(J=>J+1))};C.useEffect(()=>{e.value===void 0||e.value===H.current.value||(ae({value:e.value,selection:{start:0,end:0}},!1),$.current=!1,se.current=!1,l(T=>T+1),re.current={undo:[],redo:[],lastInput:0},X.current++,w(null),S(null),d(!1),F.current=null,O(null),u(null),Z(T=>T+1))},[e.value]),C.useEffect(()=>{q&&($.current=!1,F.current=null,X.current++,w(null),S(null),d(!1),N(),O(null))},[q]);const he=(T,L=H.current.selection,z=!1,v=!0,J)=>{var le,ne;if(q||T===H.current.value)return;const de=Date.now(),te=re.current;(!z||de-te.lastInput>750||!te.undo.length)&&(te.undo.push({value:H.current.value,selection:{...H.current.selection}}),te.undo.length>100&&te.undo.shift()),te.lastInput=z?de:0,te.redo=[],ae({value:T,selection:L},v,J),Z(fe=>fe+1),(ne=(le=G.current).onChange)==null||ne.call(le,T)},xe=(T,L=H.current.selection,z=!1)=>{const v=ye(H.current.value,L,T);he(v,{start:L.start+T.length,end:L.start+T.length},z)},qe=(T,L,z,v=!0,J=!1)=>{he(ye(H.current.value,{start:T.start,end:T.end},L),{start:T.start+z.start,end:T.start+z.end},v,J,T.id)},Xe=(T=!1)=>{if(q||f||ee.current.sourceMode)return!1;const L=Ct(H.current.value,ee.current.blocks,H.current.selection,T);return L?(he(L.value,L.selection),!0):!1},pe=T=>{if(q||f||ee.current.sourceMode)return!1;const L=St(H.current.value,ee.current.blocks,T);return L?(he(L.value,L.selection),!0):!1},Ve=(T=!1)=>{var de,te;if(q)return;const L=re.current,z=T?L.redo:L.undo,v=T?L.undo:L.redo,J=z.pop();if(!J){ue();return}v.push({value:H.current.value,selection:{...H.current.selection}}),L.lastInput=0,ae(J),Z(le=>le+1),(te=(de=G.current).onChange)==null||te.call(de,J.value)},be=(T,L)=>{if(q)return;const z=ee.current.blocks,v=z.findIndex(ne=>ne.id===T);if(v<0||L<0||L>=z.length||v===L)return;const J=[...z],[de]=J.splice(v,1);J.splice(L,0,de);let te=H.current.value.slice(0,z[0].start),le=0;J.forEach((ne,fe)=>{ne.id===T&&(le=te.length+de.bodyStart-de.start),te+=ne.raw+(fe+1<z.length?H.current.value.slice(z[fe].end,z[fe+1].start):H.current.value.slice(z[fe].end))}),ee.current={...ee.current,blocks:J},he(te,{start:le,end:le})},Te=(T,L)=>{var te,le;if(q)return;const z=ee.current.blocks,v=z.findIndex(ne=>ne.id===T),J=z[v];if(!J)return;if(L==="up"||L==="down"){be(T,v+(L==="up"?-1:1));return}if(L==="delete"){const ne={start:v===z.length-1&&v>0?z[v-1].end:J.start,end:((te=z[v+1])==null?void 0:te.start)??J.end};xe("",ne);return}const de=`
|
|
20
20
|
|
|
21
|
-
`+(L==="duplicate"?J.raw:"");
|
|
21
|
+
`+(L==="duplicate"?J.raw:"");xe(de,{start:J.end,end:J.end}),L==="below"&&S(((le=ee.current.blocks.find(ne=>!ne.raw&&ne.start>=J.end))==null?void 0:le.id)||null)},Dt=(T,L)=>{const z=ee.current.blocks.find(J=>J.id===T);if(!z)return;const v=mr(z,L);he(ye(H.current.value,{start:z.start,end:z.end},v),{start:z.start+v.length,end:z.start+v.length}),S(null)},Rt=()=>{q||(W.current&&Be(!1),F.current={value:H.current.value,selection:{...H.current.selection}},$.current=!0,I(""),M(""),d(!0))},Ee=(T=!0)=>{const L=F.current;F.current=null,$.current=!1,d(!1),M(""),T&&(L==null?void 0:L.value)===H.current.value&&ue(L.selection)},Be=(T=!0)=>{var z;const L=(z=W.current)==null?void 0:z.target;N(),O(null),$.current=!1,T&&(L==null?void 0:L.value)===H.current.value&&ue(L.selection)},Mt=()=>{q||W.current||(Ee(!1),X.current++,w(null),$.current=!0,O({target:{value:H.current.value,selection:{...H.current.selection}},revision:ie.current,type:"image",url:"",description:"",phase:"idle"}))},At=T=>{const L=W.current;q||!L||["loading","picking","stale"].includes(L.phase)||O({...L,...T,phase:"idle",error:void 0,file:void 0})},Ce=T=>Q.current&&!G.current.isDisabled&&!G.current.isReadOnly&&T.revision===ie.current&&T.target.value===H.current.value&&W.current===T,nt=(T,L=W.current)=>{var it;if(!L||!Ce(L)||L.phase==="stale"||!T&&["loading","picking"].includes(L.phase))return;const z=((T==null?void 0:T.url)??L.url).trim(),v=(T==null?void 0:T.type)??L.type;if(!Ue(z)||!["image","video"].includes(v)){O({...L,phase:"error",error:Y.invalidMedia});return}const J=(L.description||((it=L.file)==null?void 0:it.name)||v).replace(/[\r\n]+/g," ").replace(/[\\`*{}\[\]()#+.!_>~|]/g,"\\$&"),de=z.replace(/[()"'<>]/g,zt=>`%${zt.charCodeAt(0).toString(16).toUpperCase()}`),te=v==="image"?``:`[${J}](${de} "video")`,le=L.target.selection,ne=L.target.value.slice(0,le.start),fe=L.target.value.slice(le.end),Ht=v==="video"?`${ne&&!ne.endsWith(`
|
|
22
22
|
|
|
23
23
|
`)?ne.endsWith(`
|
|
24
24
|
`)?`
|
|
25
25
|
`:`
|
|
26
26
|
|
|
27
|
-
`:""}${te}${
|
|
27
|
+
`:""}${te}${fe&&!fe.startsWith(`
|
|
28
28
|
|
|
29
|
-
`)?
|
|
29
|
+
`)?fe.startsWith(`
|
|
30
30
|
`)?`
|
|
31
31
|
`:`
|
|
32
32
|
|
|
33
|
-
`:""}`:te;
|
|
34
|
-
`:i.children?i.children.map(b):i.text},s)}if(i.kind==="text")return n.jsx("span",{"data-source-start":i.start,"data-source-end":i.end,children:i.text},s);if(i.kind==="break")return n.jsx("br",{"data-source-start":i.start,"data-source-end":i.end},s);if(i.kind==="code")return n.jsx("code",{children:n.jsx("span",{"data-source-start":i.contentStart??i.start+1,"data-source-end":(i.contentStart??i.start+1)+(((x=i.text)==null?void 0:x.length)||0),children:i.text})},s);if(i.kind==="link")return g&&Se(i.url||"")?n.jsx(Ye.Link,{href:i.url,display:"inline",color:"theme-primary",underline:"underline",_focusVisible:{outline:"2px solid currentColor",outlineOffset:2},onClick:o?S=>{S.preventDefault(),o(i.url)}:void 0,children:(y=i.children)==null?void 0:y.map(b)},s):n.jsx("a",{href:Se(i.url||"")?i.url:void 0,onClick:S=>S.preventDefault(),children:(u=i.children)==null?void 0:u.map(b)},s);const l={bold:"strong",italic:"em",underline:"u",strikethrough:"s"}[i.kind];return C.createElement(l,{key:s},(j=i.children)==null?void 0:j.map(b))};return n.jsx(n.Fragment,{children:e.map(b)})}function It({block:e,native:t=!1,codeFontFamily:r="monospace",isDisplay:g=!1,onLinkPress:o,renderLink:a,allowImages:c,allowVideos:b=!0,renderVideo:i}){var f,x;if(g&&e.kind==="paragraph"){const y=
|
|
33
|
+
`:""}`:te;Be(!1),xe(Ht,le)},rt=async(T,L)=>{var le;let z=W.current;const v=G.current.uploadMedia;if(!z||!v||!Ce(z)||L===void 0&&["loading","picking"].includes(z.phase)||L!==void 0&&L!==A.current)return;const J=(le=/^(image|video)\//.exec(T.type))==null?void 0:le[1];if(!J){O({...z,phase:"error",error:Y.invalidMedia});return}const de=++A.current,te=new AbortController;B.current=te,z={...z,file:T,type:J,phase:"loading",error:void 0},O(z);try{const ne=await v(T,{signal:te.signal});if(te.signal.aborted||de!==A.current||!Ce(z))return;if(!ne||ne.type!==J||typeof ne.url!="string"||!Ue(ne.url)){O({...z,phase:"error",error:Y.invalidMedia});return}nt(ne,z)}catch{!te.signal.aborted&&de===A.current&&Ce(z)&&O({...z,phase:"error",error:Y.uploadError})}finally{B.current===te&&(B.current=null)}},Lt=async()=>{const T=W.current,L=G.current.pickMedia;if(!L||!G.current.uploadMedia||!T||!Ce(T)||["loading","picking"].includes(T.phase))return;const z=++A.current,v={...T,phase:"picking",error:void 0};O(v);try{const J=await L();if(z!==A.current||!Ce(v))return;J?await rt(J,z):O({...v,phase:"idle"})}catch{z===A.current&&Ce(v)&&O({...v,phase:"error",error:Y.uploadError})}},$t=()=>{const T=W.current;T&&(N(),O({...T,phase:"idle",error:void 0}))},Vt=(T,L)=>{if(q||T!=="link"&&H.current.selection.start===H.current.selection.end)return;if(T==="link"&&F.current){if(F.current.value!==H.current.value){Ee(!1);return}oe(F.current.selection)}if(T==="link"&&!Se(L||"")){M(Y.invalidLink);return}const z=f||ee.current.sourceMode||H.current.selection.start===H.current.selection.end?ve(H.current.value,H.current.selection,T,L):xr(H.current.value,ee.current.blocks,H.current.selection,T,L);he(z.value,z.selection),T==="link"&&Ee(!1),M("")},Bt=T=>{if(q||!G.current.generate)return;W.current&&Be(!1);const L=T==="section"?{start:0,end:H.current.value.length}:H.current.selection;if(T==="selection"&&L.start===L.end){M(Y.selectionRequired);return}Ee(!1),$.current=!0,X.current++,w({scope:T,target:{value:H.current.value,selection:{...L}},origin:{...H.current.selection},revision:ie.current,fragment:H.current.value.slice(L.start,L.end),prompt:"",state:"prompt"})},ot=(T=!0)=>{const L=U.current;X.current++,U.current=null,w(null),$.current=!1,T&&(L==null?void 0:L.target.value)===H.current.value&&L.revision===ie.current&&ue(L.origin)},Pt=async()=>{const T=U.current;if(q||!(T!=null&&T.prompt.trim())||T.state==="loading"||T.revision!==ie.current||!G.current.generate)return;const L=++X.current;U.current={...T,state:"loading"},w(U.current);try{const z=await G.current.generate(T.prompt.trim(),T.fragment,T.scope);if(!Q.current||L!==X.current)return;if(!z.trim())throw new Error("empty-proposal");w({...T,result:z,state:"proposal"})}catch{Q.current&&L===X.current&&w({...T,state:"error"})}},Ft=()=>{const T=U.current;q||!(T!=null&&T.result)||T.revision!==ie.current||T.target.value!==H.current.value||(xe(T.result,T.target.selection),ot(!1))},Wt=()=>{x(T=>!T),se.current=!0,l(T=>T+1)},Ot=()=>{S(null),se.current=!0,l(T=>T+1)};return{value:g,document:a,selection:b,restoreVersion:s,restoreRequested:se,manualSource:f,toggleSource:Wt,source:f||a.sourceMode,activeId:y,setActiveId:u,commandId:j,setCommandId:S,closeCommand:Ot,linkOpen:D,openLink:Rt,closeLink:Ee,media:R,openMedia:Mt,closeMedia:Be,changeMedia:At,insertMedia:nt,uploadFile:rt,chooseMedia:Lt,cancelMediaUpload:$t,link:m,setLink:I,message:k,setMessage:M,labels:Y,locked:q,capture:oe,restoreSelection:ue,holdSelection:$,current:H,commit:he,replace:xe,editBlock:qe,breakBlock:Xe,mergeBackward:pe,undo:Ve,move:be,action:Te,transform:Dt,format:Vt,ai:p,setAi:w,openAi:Bt,closeAi:ot,runAi:Pt,applyAi:Ft,stale:!!p&&p.revision!==ie.current,canUndo:!!re.current.undo.length,canRedo:!!re.current.redo.length,historyVersion:_}}function yr({url:e,caption:t,native:r,allowVideos:g,renderVideo:o,onLinkPress:a}){const[c,b]=C.useState(!1);if(!g||c||!Ue(e))return n.jsx(h.Text,{children:t||e});const i=o==null?void 0:o(e,t);return i!==void 0?n.jsx(n.Fragment,{children:i}):r?n.jsx(h.Text,{accessibilityRole:"link",color:"theme-primary",textDecorationLine:"underline",onPress:()=>a==null?void 0:a(e),children:t||e}):n.jsxs("figure",{style:{margin:0},children:[n.jsx("video",{src:e,controls:!0,preload:"none",playsInline:!0,"aria-label":t||e,style:{display:"block",maxWidth:"100%",width:"100%",height:"auto"},onError:()=>b(!0)}),t&&n.jsx("figcaption",{children:t})]})}function Cr({node:e,native:t,allowImages:r}){const[g,o]=C.useState(!1),a=e.text||e.url||"";return!r||g||!Ue(e.url||"")?n.jsx(h.Text,{children:a}):t?n.jsx(h.Image,{src:e.url,alt:a,width:240,height:160,resizeMode:"contain",onError:()=>o(!0)}):n.jsx("img",{src:e.url,alt:e.text||"",title:e.title,loading:"lazy",decoding:"async",style:{maxWidth:"100%",height:"auto"},onError:()=>o(!0)})}function Sr({nodes:e,native:t=!1,codeFontFamily:r="monospace",isDisplay:g=!1,onLinkPress:o,renderLink:a,allowImages:c=!0}){const b=(i,s)=>{var f,x,y,u,j;if(i.kind==="image")return n.jsx(Cr,{node:i,native:t,allowImages:c},`${s}:${i.url}`);if(i.kind==="link"&&g){const S=i.url||"",D=(f=i.children)==null?void 0:f.map(b),d=Se(S),m=d||fr(S)?a==null?void 0:a(S,D):void 0;return m!==void 0?n.jsx(C.Fragment,{children:m},s):d?t?n.jsx(h.Text,{color:"theme-primary",textDecorationLine:"underline",accessibilityRole:"link",onPress:()=>o==null?void 0:o(S),children:D},s):n.jsx(Ye.Link,{href:S,title:i.title,display:"inline",color:"theme-primary",underline:"underline",_focusVisible:{outline:"2px solid currentColor",outlineOffset:2},onClick:o?I=>{I.preventDefault(),o(S)}:void 0,children:D},s):n.jsx(C.Fragment,{children:D},s)}if(t){const S={bold:{fontWeight:"700"},italic:{fontStyle:"italic"},underline:{textDecorationLine:"underline"},strikethrough:{textDecorationLine:"line-through"},code:{fontFamily:r,backgroundColor:"color-gray-100"},link:{color:"theme-primary",textDecorationLine:"underline"},text:{},break:{}};return n.jsx(h.Text,{...S[i.kind],...g&&i.kind==="link"&&Se(i.url||"")?{accessibilityRole:"link",onPress:()=>o==null?void 0:o(i.url)}:{},children:i.kind==="break"?`
|
|
34
|
+
`:i.children?i.children.map(b):i.text},s)}if(i.kind==="text")return n.jsx("span",{"data-source-start":i.start,"data-source-end":i.end,children:i.text},s);if(i.kind==="break")return n.jsx("br",{"data-source-start":i.start,"data-source-end":i.end},s);if(i.kind==="code")return n.jsx("code",{children:n.jsx("span",{"data-source-start":i.contentStart??i.start+1,"data-source-end":(i.contentStart??i.start+1)+(((x=i.text)==null?void 0:x.length)||0),children:i.text})},s);if(i.kind==="link")return g&&Se(i.url||"")?n.jsx(Ye.Link,{href:i.url,display:"inline",color:"theme-primary",underline:"underline",_focusVisible:{outline:"2px solid currentColor",outlineOffset:2},onClick:o?S=>{S.preventDefault(),o(i.url)}:void 0,children:(y=i.children)==null?void 0:y.map(b)},s):n.jsx("a",{href:Se(i.url||"")?i.url:void 0,onClick:S=>S.preventDefault(),children:(u=i.children)==null?void 0:u.map(b)},s);const l={bold:"strong",italic:"em",underline:"u",strikethrough:"s"}[i.kind];return C.createElement(l,{key:s},(j=i.children)==null?void 0:j.map(b))};return n.jsx(n.Fragment,{children:e.map(b)})}function It({block:e,native:t=!1,codeFontFamily:r="monospace",isDisplay:g=!1,onLinkPress:o,renderLink:a,allowImages:c,allowVideos:b=!0,renderVideo:i}){var f,x;if(g&&e.kind==="paragraph"){const y=me(e.body.trim(),0,0,!0),u=y.length===1&&y[0].kind==="link"&&y[0].title==="video"?y[0]:null;if(u){const j=S=>S.children?S.children.map(j).join(""):S.text||"";return n.jsx(yr,{url:u.url||"",caption:j(u),native:t,allowVideos:b,renderVideo:i,onLinkPress:o},u.url)}}const s=(y,u)=>!y&&!t&&!g?n.jsx("span",{"data-source-start":u,"data-source-end":u,children:n.jsx("br",{})}):n.jsx(Sr,{nodes:me(y,u,0,g),native:t,codeFontFamily:r,isDisplay:g,onLinkPress:o,renderLink:a,allowImages:c});if(e.kind==="hr")return t?n.jsx(h.View,{borderBottomWidth:1,borderColor:"color-gray-300",marginVertical:8}):n.jsx("hr",{style:{border:0,borderTop:"1px solid #d1d5db",margin:"8px 0"}});if(e.kind==="codeBlock")return t?n.jsx(h.Text,{fontFamily:r,style:t?void 0:{whiteSpace:"pre-wrap"},children:e.body}):n.jsx(h.Element,{as:"pre",margin:0,padding:12,borderRadius:8,backgroundColor:"color-gray-100",fontFamily:r,style:{whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:g?n.jsx("code",{children:e.body}):n.jsx("span",{"data-source-start":e.bodyStart,"data-source-end":e.bodyStart+e.body.length,children:e.body||n.jsx("br",{})})});if(e.kind==="table"){const y=e.raw.split(/\r?\n/)[1],u=y.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(d=>/:\s*$/.test(d)?/^\s*:/.test(d)?"center":"right":"left");let j=e.start;const S=e.raw.split(/\r?\n/).map(d=>{const m=j;j+=d.length+(e.raw.includes(`\r
|
|
35
35
|
`)?2:1);const I=[];let k=d.startsWith("|")?1:0;for(let M=k;M<=d.length;M++)if(M===d.length||d[M]==="|"&&d[M-1]!=="\\"){const p=d.slice(k,M),w=p.trim();(M!==d.length||w||d[d.length-1]!=="|")&&I.push({text:w,start:m+k+p.indexOf(w)}),k=M+1}return I}).filter((d,m)=>m!==1),D=n.jsx(P.Table,{children:n.jsxs(P.Table.Container,{"data-table-separator":t?void 0:y,minWidth:g?Math.max((((f=S[0])==null?void 0:f.length)||0)*140,320):void 0,children:[n.jsx(P.Table.Head,{children:n.jsx(P.Table.Row,{children:(x=S[0])==null?void 0:x.map((d,m)=>n.jsx(P.Table.HeadCell,{textAlign:u[m],children:s(d.text,d.start)},m))})}),n.jsx(P.Table.Body,{children:S.slice(1).map((d,m)=>n.jsx(P.Table.Row,{children:d.map((I,k)=>n.jsx(P.Table.Cell,{textAlign:u[k],children:s(I.text,I.start)},k))},m))})]})});return g?n.jsx(P.TableScroll,{children:D}):D}if(e.kind==="bullet"||e.kind==="number"){let y=e.start;const u=e.raw.split(/\r?\n/).map((j,S)=>{var k;const D=y;y+=j.length+(e.raw.includes(`\r
|
|
36
36
|
`)?2:1);const d=/^(\s*)([-*+] |\d+[.)] )?(.*)$/.exec(j),m=g&&/^\[([ xX])\][ \t]+(.*)$/.exec(d[3]),I=s(m?m[2]:d[3],D+d[1].length+(((k=d[2])==null?void 0:k.length)||0)+(m?d[3].length-m[2].length:0));return t?n.jsx(h.View,{paddingLeft:d[1].length*8,children:n.jsxs(h.Text,{children:[m?n.jsx(h.Text,{accessibilityRole:"checkbox",accessibilityState:{checked:m[1].toLowerCase()==="x",disabled:!0},children:m[1].toLowerCase()==="x"?"☑ ":"☐ "}):d[2]?/\d/.test(d[2])?d[2]:"• ":"",I]})},S):n.jsxs("li",{"data-list-indent":d[1],"data-list-marker":d[2]||"",style:{marginLeft:d[1].length*8,listStyleType:"none"},children:[m?n.jsx("input",{type:"checkbox",checked:m[1].toLowerCase()==="x",readOnly:!0,disabled:!0,"aria-label":m[2]}):d[2]&&n.jsx("span",{contentEditable:!1,"aria-hidden":"true",style:{display:"inline-block",marginLeft:-20,width:20},children:/\d/.test(d[2])?d[2]:"• "}),I]},S)});return t?n.jsx(h.View,{children:u}):e.kind==="number"?n.jsx("ol",{style:{margin:0,paddingLeft:24},children:u}):n.jsx("ul",{style:{margin:0,paddingLeft:24},children:u})}if(e.kind==="quote"){let y=e.start;const u=e.raw.split(/\r?\n/).map((j,S)=>{var m;const D=y;y+=j.length+(e.raw.includes(`\r
|
|
37
37
|
`)?2:1);const d=((m=j.match(/^> ?/))==null?void 0:m[0].length)||0;return n.jsxs(C.Fragment,{children:[S>0&&(t?`
|
|
@@ -50,9 +50,9 @@ ${o}`}if(t==="table")return`| Column 1 | Column 2 | Column 3 |
|
|
|
50
50
|
`)&&c(`
|
|
51
51
|
`);const d=((D=x.parentElement)==null?void 0:D.tagName)==="OL",m=x.parentElement?Array.from(x.parentElement.children).indexOf(x)+1:1;c((x.dataset.listIndent??s)+(x.dataset.listMarker??(d?`${m}. `:"- ")))}if(y==="table"){Array.from(x.querySelectorAll("tr")).forEach((m,I)=>{I&&c(`
|
|
52
52
|
`),c("| "),Array.from(m.children).forEach(k=>{b(k,s),c(" | ")}),I===0&&c(`
|
|
53
|
-
`+(x.dataset.tableSeparator||"| "+Array.from(m.children).map(()=>"---").join(" | ")+" |"))});return}!l&&u[y]&&x.textContent&&c(u[y][0]);const S=Array.from(i.childNodes);S.forEach((d,m)=>{a(i,m),b(d,y==="li"?s+" ":s,l||y==="code",f||y==="blockquote")}),a(i,S.length),!l&&u[y]&&x.textContent&&c(u[y][1])};return b(e,"",e.hasAttribute("data-code-block")),{text:r,selection:{start:Math.min(g??r.length,o??r.length),end:Math.max(g??r.length,o??r.length)}}}let dt;function We(e){var o,a,c;dt??(dt=new Intl.Segmenter(void 0,{granularity:"grapheme"}));const t=[],r=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT);let g;for(;g=r.nextNode();){if((o=g.parentElement)!=null&&o.closest('[contenteditable="false"]'))continue;if(g.nodeType===1){if(g.tagName!=="BR")continue;const s=g.parentNode,l=Array.from(s.childNodes).indexOf(g),f=s;if(f.dataset.sourceStart!==void 0&&f.dataset.sourceStart===f.dataset.sourceEnd&&!f.textContent){t.push({node:s,offset:0,source:Number(f.dataset.sourceStart)});continue}const x=g.dataset.sourceEnd!==void 0?Number(g.dataset.sourceEnd):Ae(e,s,l+1);if(!t.length){const y=Ae(e,s,l);y!==null&&t.push({node:s,offset:l,source:y})}x!==null&&Number.isFinite(x)&&((a=t[t.length-1])==null?void 0:a.source)!==x&&t.push({node:s,offset:l+1,source:x});continue}const b=g.textContent||"",i=[0,...Array.from(dt.segment(b),s=>s.index+s.segment.length)];for(const s of i){const l=Ae(e,g,s);l!==null&&((c=t[t.length-1])==null?void 0:c.source)!==l&&t.push({node:g,offset:s,source:l})}}if(!t.length){const b=e.querySelector("[data-source-start]");b&&t.push({node:b,offset:0,source:Number(b.dataset.sourceStart)})}return t}function Oe(e){var g,o;const t=e.node.ownerDocument.createRange();t.setStart(e.node,e.offset),t.collapse(!0);const r=(g=t.getBoundingClientRect)==null?void 0:g.call(t);return r!=null&&r.height?r:(o=e.node.nodeType===1?e.node:e.node.parentElement)==null?void 0:o.getBoundingClientRect()}function ut(e,t){var g,o,a;const r="p,h1,h2,h3,li,td,th,pre,blockquote,div";return e.node!==t.node&&e.offset===((g=e.node.textContent)==null?void 0:g.length)&&t.offset===0&&((o=e.node.parentElement)==null?void 0:o.closest(r))===((a=t.node.parentElement)==null?void 0:a.closest(r))}function Tr(e,t,r,g){var m,I,k,M,p;if(typeof Intl.Segmenter!="function")return null;const o=e.ownerDocument.getSelection(),a=Le(e,!0);if(!a||!(o!=null&&o.focusNode)||!o.anchorNode)return null;const c=Array.from(e.querySelectorAll("[data-block-id]")),b=t==="ArrowLeft"||t==="ArrowUp",i=t==="ArrowUp"||t==="ArrowDown",s=o.focusNode.nodeType===1?o.focusNode:o.focusNode.parentElement;let l=c.indexOf(s==null?void 0:s.closest("[data-block-id]"));if(l<0)return null;let f=We(c[l]);if(!f.length)return null;const x=a.backward?a.start:a.end;let y=f.findIndex(w=>w.node===o.focusNode&&w.offset===o.focusOffset);y<0&&(y=f.reduce((w,R,
|
|
53
|
+
`+(x.dataset.tableSeparator||"| "+Array.from(m.children).map(()=>"---").join(" | ")+" |"))});return}!l&&u[y]&&x.textContent&&c(u[y][0]);const S=Array.from(i.childNodes);S.forEach((d,m)=>{a(i,m),b(d,y==="li"?s+" ":s,l||y==="code",f||y==="blockquote")}),a(i,S.length),!l&&u[y]&&x.textContent&&c(u[y][1])};return b(e,"",e.hasAttribute("data-code-block")),{text:r,selection:{start:Math.min(g??r.length,o??r.length),end:Math.max(g??r.length,o??r.length)}}}let dt;function We(e){var o,a,c;dt??(dt=new Intl.Segmenter(void 0,{granularity:"grapheme"}));const t=[],r=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT);let g;for(;g=r.nextNode();){if((o=g.parentElement)!=null&&o.closest('[contenteditable="false"]'))continue;if(g.nodeType===1){if(g.tagName!=="BR")continue;const s=g.parentNode,l=Array.from(s.childNodes).indexOf(g),f=s;if(f.dataset.sourceStart!==void 0&&f.dataset.sourceStart===f.dataset.sourceEnd&&!f.textContent){t.push({node:s,offset:0,source:Number(f.dataset.sourceStart)});continue}const x=g.dataset.sourceEnd!==void 0?Number(g.dataset.sourceEnd):Ae(e,s,l+1);if(!t.length){const y=Ae(e,s,l);y!==null&&t.push({node:s,offset:l,source:y})}x!==null&&Number.isFinite(x)&&((a=t[t.length-1])==null?void 0:a.source)!==x&&t.push({node:s,offset:l+1,source:x});continue}const b=g.textContent||"",i=[0,...Array.from(dt.segment(b),s=>s.index+s.segment.length)];for(const s of i){const l=Ae(e,g,s);l!==null&&((c=t[t.length-1])==null?void 0:c.source)!==l&&t.push({node:g,offset:s,source:l})}}if(!t.length){const b=e.querySelector("[data-source-start]");b&&t.push({node:b,offset:0,source:Number(b.dataset.sourceStart)})}return t}function Oe(e){var g,o;const t=e.node.ownerDocument.createRange();t.setStart(e.node,e.offset),t.collapse(!0);const r=(g=t.getBoundingClientRect)==null?void 0:g.call(t);return r!=null&&r.height?r:(o=e.node.nodeType===1?e.node:e.node.parentElement)==null?void 0:o.getBoundingClientRect()}function ut(e,t){var g,o,a;const r="p,h1,h2,h3,li,td,th,pre,blockquote,div";return e.node!==t.node&&e.offset===((g=e.node.textContent)==null?void 0:g.length)&&t.offset===0&&((o=e.node.parentElement)==null?void 0:o.closest(r))===((a=t.node.parentElement)==null?void 0:a.closest(r))}function Tr(e,t,r,g){var m,I,k,M,p;if(typeof Intl.Segmenter!="function")return null;const o=e.ownerDocument.getSelection(),a=Le(e,!0);if(!a||!(o!=null&&o.focusNode)||!o.anchorNode)return null;const c=Array.from(e.querySelectorAll("[data-block-id]")),b=t==="ArrowLeft"||t==="ArrowUp",i=t==="ArrowUp"||t==="ArrowDown",s=o.focusNode.nodeType===1?o.focusNode:o.focusNode.parentElement;let l=c.indexOf(s==null?void 0:s.closest("[data-block-id]"));if(l<0)return null;let f=We(c[l]);if(!f.length)return null;const x=a.backward?a.start:a.end;let y=f.findIndex(w=>w.node===o.focusNode&&w.offset===o.focusOffset);y<0&&(y=f.reduce((w,R,V)=>Math.abs(R.source-x)<Math.abs(f[w].source-x)?V:w,0));let u=f[y],j=i?g??((m=Oe(u))==null?void 0:m.left)??0:null;if(!r&&a.start!==a.end&&!i){const w=b?a.start:a.end,R=c.find(W=>{const A=W.querySelectorAll("[data-source-start]");return A.length&&w>=Number(A[0].dataset.sourceStart)&&w<=Number(A[A.length-1].dataset.sourceEnd)});u=(R?We(R):f).reduce((W,A)=>Math.abs(A.source-w)<Math.abs(W.source-w)?A:W)}else if(i){const w=Oe(u),R=(W,A)=>{const B=W.map(_=>({point:_,rect:Oe(_)})).filter(_=>_.rect&&(!A||!w||(b?_.rect.bottom<w.bottom-w.height/2:_.rect.top>w.top+w.height/2)));if(!B.length)return null;const O=b?Math.max(...B.map(_=>_.rect.top)):Math.min(...B.map(_=>_.rect.top));return B.filter(_=>Math.abs(_.rect.top-O)<Math.max(1,_.rect.height/2)).reduce((_,Z)=>Math.abs(Z.rect.left-j)<Math.abs(_.rect.left-j)?Z:_).point},V=R(f,!0);V?u=V:(l+=b?-1:1,c[l]&&(u=R(We(c[l]),!1)??u))}else{const w=b?-1:1;let R=y+w;R>=0&&R<f.length&&(b?ut(f[R],f[y]):ut(f[y],f[R]))&&(R+=w),R>=0&&R<f.length?u=f[R]:(f=c[l+w]?We(c[l+w]):[],f.length&&(u=f[b?f.length-1:0]))}const S=r?{node:o.anchorNode,offset:o.anchorOffset,source:a.backward?a.end:a.start}:u,D=(I=u.node.nodeType===1?u.node:u.node.parentElement)==null?void 0:I.closest("[data-editor-input]");D==null||D.focus({preventScroll:!0}),o.setBaseAndExtent(S.node,S.offset,u.node,u.offset);const d=Oe(u);return d&&(d.top<0||d.bottom>(((k=e.ownerDocument.defaultView)==null?void 0:k.innerHeight)??1/0))&&((p=(M=u.node.parentElement)==null?void 0:M.scrollIntoView)==null||p.call(M,{block:"nearest"})),{selection:{start:Math.min(S.source,u.source),end:Math.max(S.source,u.source),...u.source<S.source?{backward:!0}:{}},x:j}}function Er(e,t,r,g,o=!1){const a=C.useRef(!1),c=C.useRef(null),[b,i]=C.useState(!1),s=C.useRef(null),l=C.useRef(null),f=C.useRef(null),x=()=>{a.current=!1,i(!1)};C.useEffect(()=>{const p=e.current.current.selection;!e.source&&!e.locked&&p.start===0&&p.end===e.value.length&&e.value.length>0&&(a.current=!0,i(!0)),(e.source||e.locked||e.current.current.selection.start===e.current.current.selection.end)&&x(),c.current=null,s.current=null,l.current=null,f.current=null},[e.value,e.source,e.locked]);const y=p=>{var R;const w=p instanceof Element?p.closest("[data-editor-input]"):null;return w&&((R=t.current)!=null&&R.contains(w))?w:null},u=p=>{if(a.current)return{start:0,end:e.current.current.value.length,...e.current.current.selection.backward?{backward:!0}:{}};if((p==null?void 0:p.tagName)==="TEXTAREA"){const w=p,R=Number(w.dataset.editorOffset||0);return{start:R+w.selectionStart,end:R+w.selectionEnd}}return t.current?Le(t.current,!0):null},j=p=>a.current||e.document.blocks.filter(w=>p.start<w.end&&p.end>w.start).length>1,S=(p,w,R)=>{if(e.source||p.tagName==="TEXTAREA")return null;if(w==="insertParagraph"||w==="insertLineBreak")return Ct(e.current.current.value,e.document.blocks,R,w==="insertLineBreak");const V=p.querySelector("[data-source-start]");if(w==="deleteContentBackward"&&R.start===R.end){const W=Array.from(p.querySelectorAll("li")).find(A=>{var B;return Number((B=A.querySelector("[data-source-start]"))==null?void 0:B.dataset.sourceStart)===R.start});if(R.start===Number(V==null?void 0:V.dataset.sourceStart)||W)return St(e.current.current.value,e.document.blocks,p.dataset.blockId||"",W&&R.start!==Number(V==null?void 0:V.dataset.sourceStart)?R.start:void 0)??{value:e.current.current.value,selection:R}}return null},D=()=>{var V,W,A;const p=(V=t.current)==null?void 0:V.ownerDocument.activeElement;if((p==null?void 0:p.tagName)==="INPUT"||(p==null?void 0:p.tagName)==="TEXTAREA"){const B=y(p);if(B){const O=u(B);O&&e.capture(O)}return null}const w=(W=t.current)==null?void 0:W.ownerDocument.getSelection();if(!(w!=null&&w.anchorNode)||!w.focusNode||!((A=t.current)!=null&&A.contains(w.anchorNode))||!t.current.contains(w.focusNode))return a.current&&x(),null;const R=u();return R&&e.capture(R),R},d=(p,w=!1)=>{const R=y(p.target);if(!R||R.tagName==="TEXTAREA")return;const V=u(R);!V||V.start===V.end||(p.clipboardData.setData("text/plain",e.current.current.value.slice(V.start,V.end)),p.preventDefault(),w&&!e.locked&&(e.capture(V),e.replace("",st(e.document.blocks,V)),x()))},m=p=>{if(p.defaultPrevented||p.nativeEvent.isComposing)return;const w=y(p.target);if(!w)return;const R=u(w);R&&e.capture(R);const V=p.key.toLowerCase();V==="tab"&&x();const W=(p.ctrlKey||p.metaKey)&&!p.altKey;if(W&&V==="a"&&!p.shiftKey&&w.tagName!=="TEXTAREA"){p.preventDefault();const A=w.ownerDocument.createRange();A.selectNodeContents(r.current);const B=w.ownerDocument.getSelection();B==null||B.removeAllRanges(),B==null||B.addRange(A),a.current=!0,i(!0),e.capture({start:0,end:e.current.current.value.length});return}if(a.current&&["arrowleft","arrowright","arrowup","arrowdown","home","end","escape"].includes(V)){if(p.shiftKey&&t.current&&wt(t.current,{start:0,end:e.current.current.value.length,...e.current.current.selection.backward?{backward:!0}:{}}),x(),!p.shiftKey){p.preventDefault();const A=e.document.blocks[0],B=e.document.blocks[e.document.blocks.length-1],O=["arrowleft","arrowup","home"].includes(V)?A.bodyStart:B.kind==="codeBlock"?B.bodyStart+B.body.length:B.end;e.restoreSelection({start:O,end:O})}if(!p.shiftKey)return}if(!e.source&&!e.locked&&!W&&!p.altKey&&w.tagName!=="TEXTAREA"&&["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(p.key)&&t.current){const A=Tr(t.current,p.key,p.shiftKey,c.current);if(A){p.preventDefault(),c.current=A.x,e.capture(A.selection);return}}else c.current=null;if(!e.locked){if(W){V==="z"||V==="y"?(p.preventDefault(),x(),e.undo(V==="y"||p.shiftKey)):V==="s"&&g?(p.preventDefault(),g()):V==="a"&&p.shiftKey&&o?(p.preventDefault(),e.openAi("selection")):["b","i","u"].includes(V)?(p.preventDefault(),e.format({b:"bold",i:"italic",u:"underline"}[V])):V==="k"&&(p.preventDefault(),e.openLink());return}if(!p.altKey&&R&&["enter","backspace"].includes(V)){const A=S(w,V==="enter"?p.shiftKey?"insertLineBreak":"insertParagraph":"deleteContentBackward",R);if(A){p.preventDefault(),e.commit(A.value,A.selection),x();return}}if(w.tagName!=="TEXTAREA"&&R&&R.start!==R.end&&["backspace","delete"].includes(V)){p.preventDefault(),e.replace("",st(e.document.blocks,R)),x();return}if(R&&j(R)){const A=V==="backspace"||V==="delete"?"":V==="enter"?`
|
|
54
54
|
|
|
55
|
-
`:p.key.length===1&&!p.altKey?p.key:null;if(A!==null){p.preventDefault(),e.replace(A,R,p.key.length===1),x();return}}}},I=p=>{var W;const w=y(p.target);if(!w||e.locked||p.isComposing||s.current)return;if(p.inputType==="historyUndo"||p.inputType==="historyRedo"){p.cancelable&&(p.preventDefault(),e.undo(p.inputType==="historyRedo"));return}const R=u(w);if(R){const A=S(w,p.inputType,R);if(A){e.capture(R),p.cancelable?(p.preventDefault(),e.commit(A.value,A.selection),x()):f.current=A;return}}if(!R||!j(R))return;const
|
|
55
|
+
`:p.key.length===1&&!p.altKey?p.key:null;if(A!==null){p.preventDefault(),e.replace(A,R,p.key.length===1),x();return}}}},I=p=>{var W;const w=y(p.target);if(!w||e.locked||p.isComposing||s.current)return;if(p.inputType==="historyUndo"||p.inputType==="historyRedo"){p.cancelable&&(p.preventDefault(),e.undo(p.inputType==="historyRedo"));return}const R=u(w);if(R){const A=S(w,p.inputType,R);if(A){e.capture(R),p.cancelable?(p.preventDefault(),e.commit(A.value,A.selection),x()):f.current=A;return}}if(!R||!j(R))return;const V=(W=p.inputType)!=null&&W.startsWith("delete")?"":["insertParagraph","insertLineBreak"].includes(p.inputType)?`
|
|
56
56
|
|
|
57
|
-
`:p.data;B!=null&&(p.cancelable?(p.preventDefault(),e.replace(B,R),x()):l.current={target:R,text:B})},k=C.useRef(I);return k.current=I,C.useEffect(()=>{const p=t.current,w=R=>k.current(R);return p==null||p.addEventListener("beforeinput",w,!0),()=>p==null?void 0:p.removeEventListener("beforeinput",w,!0)},[t]),{capture:D,selectedDocument:b,onKeyDown:m,onInputCapture:p=>{var W,A;const w=y(p.target),R=p.nativeEvent;if(!w||e.locked||R.isComposing||s.current)return;const B=f.current??S(w,R.inputType,e.current.current.selection);if(B){p.stopPropagation(),f.current=null,B.value===e.current.current.value?e.restoreSelection(B.selection):e.commit(B.value,B.selection),x();return}if(R.inputType==="historyUndo"||R.inputType==="historyRedo")p.stopPropagation(),e.undo(R.inputType==="historyRedo");else if(l.current||w.tagName!=="TEXTAREA"&&j(e.current.current.selection)&&(R.data!=null||(W=R.inputType)!=null&&W.startsWith("delete"))){p.stopPropagation();const{target:V,text:O}=l.current??{target:e.current.current.selection,text:(A=R.inputType)!=null&&A.startsWith("delete")?"":R.data};l.current=null,e.replace(O,V),x()}},onCopy:p=>d(p),onCut:p=>d(p,!0),onPaste:p=>{const w=y(p.target);if(!w||w.tagName==="TEXTAREA"||e.locked)return;const R=u(w);if(!R)return;p.preventDefault();const B=p.clipboardData.getData("text/plain");!B&&!Array.from(p.clipboardData.types||[]).includes("text/plain")||(e.capture(R),e.replace(B,R),x())},onPointerDownCapture:p=>{c.current=null,y(p.target)&&x()},onCompositionStartCapture:p=>{const w=y(p.target),R=w&&u(w);R&&j(R)&&!e.locked&&(s.current=R)},onCompositionEndCapture:p=>{const w=s.current;w&&(p.stopPropagation(),s.current=null,p.data?e.replace(p.data,w):e.restoreSelection(w),x())}}}function Dr({rect:e,state:t,props:r,preserve:g}){var i,s,l,f;const o=C.useRef(null),{themeMode:a}=h.useTheme(),[c,b]=C.useState({top:8,left:8});return C.useLayoutEffect(()=>{const x=()=>{var j;const u=(j=o.current)==null?void 0:j.getBoundingClientRect();u&&b({left:Math.max(8,Math.min(e.left,window.innerWidth-u.width-8)),top:Math.max(8,Math.min(e.top-u.height-8>=8?e.top-u.height-8:e.bottom+8,window.innerHeight-u.height-8))})};x();const y=typeof ResizeObserver>"u"?null:new ResizeObserver(x);return o.current&&(y==null||y.observe(o.current)),()=>y==null?void 0:y.disconnect()},[e,t.linkOpen,!!t.media,(i=t.media)==null?void 0:i.phase,(s=t.ai)==null?void 0:s.state,(l=t.ai)==null?void 0:l.result,(f=t.ai)==null?void 0:f.prompt,t.stale,t.message]),C.useEffect(()=>{if(!t.linkOpen&&!t.media&&!t.ai)return;const x=y=>{var u;y.target instanceof Node&&!((u=o.current)!=null&&u.contains(y.target))&&(t.media?t.closeMedia(!1):t.ai?t.closeAi(!1):t.closeLink(!1))};return document.addEventListener("pointerdown",x,!0),()=>document.removeEventListener("pointerdown",x,!0)},[t.linkOpen,!!t.media,!!t.ai]),n.jsx(h.View,{ref:o,"data-editor-selection-toolbar":"true","data-editor-link-popover":t.linkOpen?"true":void 0,"data-editor-ai-popover":t.ai?"true":void 0,role:t.linkOpen||t.media||t.ai?"dialog":void 0,"aria-label":t.media?t.labels.media:t.ai?t.labels.aiPanel:t.linkOpen?t.labels.link:void 0,onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),t.media?t.closeMedia():t.ai?t.closeAi():t.linkOpen&&t.closeLink())},position:"fixed",top:c.top,left:c.left,maxWidth:"calc(100vw - 16px)",maxHeight:"calc(100vh - 16px)",overflow:"auto",backgroundColor:a==="dark"?"color-gray-900":"color-white",borderWidth:1,borderStyle:"solid",borderColor:a==="dark"?"color-gray-600":"color-gray-300",boxShadow:"0 6px 20px rgba(0, 0, 0, 0.18)",borderRadius:10,padding:6,zIndex:1e3,children:t.linkOpen||t.media||t.ai?n.jsx(Ir,{state:t,views:r.views,uploadEnabled:!!r.uploadMedia,floating:!0}):n.jsx(Ge,{state:t,props:r,formatting:!0,preserve:g})})}function Rr({block:e,state:t,label:r,views:g}){const o=C.useRef(null),a=C.useRef(!1),c=C.useMemo(()=>n.jsx(It,{block:e}),[e.id,e.start,t.restoreVersion]),b=()=>{if(!o.current||a.current||t.locked)return;const i=wr(o.current);if(e.kind==="codeBlock"){const l=e.bodyStart-e.start;t.editBlock(e,ke(e.raw,{start:l,end:l+e.body.length},i.text),{start:l+i.selection.start,end:l+i.selection.end},!0,!1);return}const s=_e(i.text);t.editBlock(e,i.text,i.selection,!0,s.blocks.length!==1||s.blocks[0].kind!==e.kind)};return n.jsx(h.View,{ref:o,"data-block-id":e.id,"data-block-start":e.kind==="codeBlock"?e.bodyStart:e.start,"data-code-block":e.kind==="codeBlock"?e.id:void 0,"data-editor-input":"true",contentEditable:!t.locked,suppressContentEditableWarning:!0,role:"textbox","aria-label":r,"aria-multiline":"true","aria-readonly":t.locked,minHeight:24,flex:1,outline:"none",...g==null?void 0:g.content,onFocus:()=>t.setActiveId(e.id),onBeforeInput:i=>{if(i.defaultPrevented)return;const s=o.current&&Le(o.current,!0);s&&t.capture(s)},onInput:i=>{b()},onCompositionStart:()=>{a.current=!0},onCompositionEnd:()=>{a.current=!1,b()},onKeyDown:i=>{if(i.nativeEvent.isComposing||t.locked)return;const s=o.current&&Le(o.current,!0);s&&t.capture(s),i.key==="/"&&!i.metaKey&&!i.ctrlKey&&!e.body.trim()&&(i.preventDefault(),t.setCommandId(e.id))},children:c},t.restoreVersion)}function Mr({state:e,...t}){const{value:r,defaultValue:g,onChange:o,generate:a,uploadMedia:c,pickMedia:b,onSave:i,label:s=e.labels.document,isDisabled:l,isReadOnly:f,labels:x,views:y={},status:u,...j}=t,S=C.useRef(null),{themeMode:D}=h.useTheme(),[d,m]=C.useState(null),[I,k]=C.useState(null),M=C.useRef(null),p=C.useRef(null),w=Er(e,S,M,i,!!t.generate);C.useLayoutEffect(()=>{if(!e.linkOpen&&!e.media&&!e.ai||!S.current){k(null);return}const $=S.current.ownerDocument.getSelection(),F=$!=null&&$.rangeCount&&$.anchorNode&&S.current.contains($.anchorNode)?$.getRangeAt(0).cloneRange():null,X=p.current??S.current.querySelector(`[data-block-id="${e.activeId}"]`)??M.current??S.current,G=()=>{const U=F==null?void 0:F.getBoundingClientRect(),Q=U!=null&&U.height?U:X.getBoundingClientRect();k({top:Q.top,bottom:Q.bottom,left:Q.left})};return G(),window.addEventListener("scroll",G,!0),window.addEventListener("resize",G),()=>{window.removeEventListener("scroll",G,!0),window.removeEventListener("resize",G)}},[e.linkOpen,!!e.media,!!e.ai]);const R=C.useRef(null),B=C.useRef(null),W=C.useRef(null),A=C.useRef(null),V=C.useRef([]),O=C.useRef(null),[N,_]=C.useState(null),Z=$=>{$.preventDefault()},Y=()=>{var $;return Array.from((($=M.current)==null?void 0:$.querySelectorAll("[data-editor-row]"))||[])},q=()=>{var $;W.current!==null&&window.cancelAnimationFrame(W.current),W.current=null,R.current=null,($=B.current)==null||$.remove(),B.current=null,O.current=null,_(null)},H=($,F)=>$>F.from&&$<=F.to?-F.extent:$>=F.to&&$<F.from?F.extent:0,ee=($,F)=>{const X=Y()[$];return X?X.offsetTop+($>F.from?X.offsetHeight-F.height:0):F.top},re=$=>{const F=O.current;if(!F||F.to===$)return;const X={...F,to:$,top:ee($,F)};O.current=X,_(X)},ie=$=>{const F=O.current;if(!F||!M.current)return null;const X=$-M.current.getBoundingClientRect().top;if(X>=F.top&&X<=F.top+F.height)return F.to;const G=Y();let U=0;return G.forEach((Q,oe)=>{oe!==F.from&&X>=Q.offsetTop+H(oe,F)+Q.offsetHeight/2&&U++}),U};C.useEffect(()=>{q()},[e.value,e.locked,e.source]),C.useEffect(()=>{if(N!=null&&N.id)return window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[N==null?void 0:N.id]),C.useEffect(()=>()=>{var $;W.current!==null&&window.cancelAnimationFrame(W.current),($=B.current)==null||$.remove(),V.current.forEach(F=>F.cancel())},[]),C.useLayoutEffect(()=>{var F;const $=A.current;$&&(A.current=null,V.current.forEach(X=>X.cancel()),V.current=[],!((F=window.matchMedia)!=null&&F.call(window,"(prefers-reduced-motion: reduce)").matches)&&Y().forEach(X=>{const G=$.get(X.dataset.editorRow),U=G===void 0?0:G-X.getBoundingClientRect().top;Math.abs(U)<1||!X.animate||V.current.push(X.animate([{transform:`translateY(${U}px)`},{transform:"translateY(0)"}],{duration:180,easing:"cubic-bezier(0.2, 0, 0, 1)"}))}))}),C.useEffect(()=>{const $=()=>{var ue;const F=S.current;if(!F||e.holdSelection.current||e.linkOpen)return;if(R.current){m(null);return}const X=F.ownerDocument.activeElement,G=w.capture()??Le(F),U=F.ownerDocument.getSelection(),Q=X==null?void 0:X.matches("input[data-editor-input],textarea[data-editor-input]");if(G&&G.start!==G.end&&(U!=null&&U.rangeCount)&&!Q&&!e.locked){const ae=U.getRangeAt(0).getBoundingClientRect();if(ae.bottom>0&&ae.top<window.innerHeight){m({top:ae.top,bottom:ae.bottom,left:ae.left});return}}m(null);const oe=F.ownerDocument.getSelection();if(oe&&!oe.isCollapsed&&oe.anchorNode&&!F.contains(oe.anchorNode)&&!((ue=oe.anchorNode.parentElement)!=null&&ue.closest("[data-editor-block-list]"))){const ae=e.current.current.selection.end;e.capture({start:ae,end:ae})}};return document.addEventListener("selectionchange",$),window.addEventListener("scroll",$,!0),window.addEventListener("resize",$),()=>{document.removeEventListener("selectionchange",$),window.removeEventListener("scroll",$,!0),window.removeEventListener("resize",$)}},[e.locked,e.source,e.linkOpen]),C.useLayoutEffect(()=>{!e.restoreVersion||!S.current||!e.restoreRequested.current||(e.restoreRequested.current=!1,e.source&&p.current?(p.current.focus({preventScroll:!0}),p.current.setSelectionRange(e.selection.start,e.selection.end,e.selection.backward?"backward":"forward")):wt(S.current,e.selection))},[e.restoreVersion,e.source]);const se=()=>{p.current&&e.capture({start:p.current.selectionStart,end:p.current.selectionEnd,...p.current.selectionDirection==="backward"?{backward:!0}:{}})};return n.jsxs(h.Vertical,{ref:S,gap:12,minWidth:0,"aria-label":s,"aria-disabled":l,...j,...y.container,onCopy:w.onCopy,onCut:w.onCut,onPaste:w.onPaste,onPointerDownCapture:w.onPointerDownCapture,onInputCapture:w.onInputCapture,onCompositionStartCapture:w.onCompositionStartCapture,onCompositionEndCapture:w.onCompositionEndCapture,onDragOver:$=>{if(!R.current||e.locked)return;$.preventDefault(),$.dataTransfer.dropEffect="move";const F=ie($.clientY);F!==null&&re(F)},onDragLeave:$=>{const F=$.currentTarget.getBoundingClientRect();($.clientX<F.left||$.clientX>F.right||$.clientY<F.top||$.clientY>F.bottom)&&O.current&&re(O.current.from)},onDrop:$=>{var X;if(!R.current||e.locked)return;$.preventDefault();const F=ie($.clientY);if(F!==null&&((X=e.document.blocks[F])==null?void 0:X.id)!==R.current){A.current=new Map(Y().map(U=>[U.dataset.editorRow,U.getBoundingClientRect().top]));const G=O.current;G&&M.current&&A.current.set(G.id,M.current.getBoundingClientRect().top+ee(F,G)),e.move(R.current,F)}q()},onKeyDown:$=>{$.nativeEvent.isComposing||($.key==="Escape"&&(q(),e.setCommandId(null),e.linkOpen&&e.closeLink(),e.ai&&e.closeAi(),e.media&&e.closeMedia(),m(null)),w.onKeyDown($))},children:[!f&&n.jsxs(h.Vertical,{position:"sticky",top:0,zIndex:10,backgroundColor:D==="dark"?"color-gray-900":"color-white",borderWidth:1,borderColor:"color-gray-200",borderStyle:"solid",borderRadius:8,padding:8,gap:4,children:[n.jsx(Ge,{state:e,props:t,preserve:Z}),e.source&&n.jsx(Ge,{state:e,props:t,formatting:!0,preserve:Z})]}),e.document.sourceMode&&n.jsx(h.Text,{role:"status",...y.notice,children:e.labels.sourceFallback}),e.message&&!e.linkOpen&&n.jsx(h.Text,{role:"status",...y.notice,children:e.message}),e.source?n.jsx(P.TextArea,{value:e.value,"data-editor-input":"true","data-editor-offset":0,label:s,isDisabled:l,isReadOnly:f,inputRef:$=>{p.current=$},onSelect:se,onFocus:se,onChange:$=>e.commit($,p.current?{start:p.current.selectionStart,end:p.current.selectionEnd}:e.selection,!0,!1),views:{textarea:{minHeight:240,fontFamily:"monospace",...y.source}}}):n.jsxs(h.Vertical,{ref:M,position:"relative",gap:12,"data-editor-block-list":"true",children:[N&&n.jsx(h.View,{"data-editor-drop-placeholder":N.to,"aria-hidden":"true",position:"absolute",left:0,right:0,top:0,height:N.height,borderWidth:1,borderStyle:"dashed",boxSizing:"border-box",borderColor:"theme-primary",borderRadius:8,backgroundColor:"theme-primary",opacity:.14,pointerEvents:"none",style:{transform:`translateY(${N.top}px)`,transition:N.reducedMotion?"none":"transform 180ms cubic-bezier(0.2, 0, 0, 1)"}}),e.document.blocks.map(($,F)=>{var X,G;return n.jsxs(h.Horizontal,{gap:8,alignItems:"flex-start",position:"relative",borderRadius:6,backgroundColor:w.selectedDocument?"theme-primary-100":e.activeId===$.id?"color-gray-50":void 0,_hover:{backgroundColor:"color-gray-50"},"data-editor-row":$.id,...y.block,opacity:(N==null?void 0:N.id)===$.id?0:((X=y.block)==null?void 0:X.opacity)??1,style:{...(G=y.block)==null?void 0:G.style,...N?{transform:`translateY(${H(F,N)}px)`,transition:N.reducedMotion?"none":"transform 180ms cubic-bezier(0.2, 0, 0, 1)"}:{}},children:[!f&&n.jsx(P.DropdownMenu,{views:{menu:{borderWidth:1,borderStyle:"solid",borderColor:"color-gray-300",backgroundColor:D==="dark"?"color-gray-900":"color-white",boxShadow:"0 6px 20px rgba(0, 0, 0, 0.18)"},item:{as:"button",type:"button",width:"100%",textAlign:"left",borderWidth:0,_focusVisible:{outline:"2px solid",outlineColor:"theme-primary"}}},trigger:n.jsx(P.Button,{type:"button",size:"sm",variant:"ghost",isIcon:!0,minWidth:36,width:36,minHeight:36,padding:4,title:`${e.labels.drag} · ${e.labels.blocks}`,style:{userSelect:"none"},draggable:!e.locked,isDisabled:e.locked,cursor:N?"grabbing":"grab","aria-label":e.labels.drag,onDragStart:U=>{var oe;if(e.locked){U.preventDefault();return}R.current=$.id,V.current.forEach(ue=>ue.cancel()),V.current=[];const Q=U.currentTarget.closest("[data-editor-row]");if(Q){const ue=Q.getBoundingClientRect(),ae=Y(),he=ae[F+1],me=ae[F-1],qe=he?he.offsetTop-Q.offsetTop-Q.offsetHeight:me?Q.offsetTop-me.offsetTop-me.offsetHeight:0,Xe={id:$.id,from:F,to:F,height:Q.offsetHeight,extent:Q.offsetHeight+Math.max(0,qe),top:Q.offsetTop,reducedMotion:!!((oe=window.matchMedia)!=null&&oe.call(window,"(prefers-reduced-motion: reduce)").matches)};O.current=Xe,W.current=window.requestAnimationFrame(()=>{W.current=null,O.current&&_(O.current)});const ge=Q.cloneNode(!0);let Be="Canvas";for(let xe=Q;xe;xe=xe.parentElement){const Te=window.getComputedStyle(xe).backgroundColor;if(Te!=="transparent"&&Te!=="rgba(0, 0, 0, 0)"){Be=Te;break}}Object.assign(ge.style,{position:"fixed",left:"-10000px",top:"0",width:`${ue.width}px`,padding:"8px",boxSizing:"border-box",borderRadius:"8px",backgroundColor:Be,boxShadow:"0 8px 24px rgba(0,0,0,0.18)",opacity:"1"}),ge.dataset.editorDragPreview="true",ge.setAttribute("aria-hidden","true"),ge.inert=!0,ge.querySelectorAll("[contenteditable]").forEach(xe=>{xe.style.outline="none"}),Q.ownerDocument.body.appendChild(ge),B.current=ge,U.dataTransfer.setDragImage(ge,U.clientX-ue.left+8,U.clientY-ue.top+8)}U.dataTransfer.setData("application/x-app-studio-block",$.id),U.dataTransfer.effectAllowed="move"},onDragEnd:q,children:n.jsx(E.DragHandleIcon,{widthHeight:18,strokeWidth:2})}),items:[{id:"transform",label:e.labels.blocks,disabled:e.locked,onClick:()=>e.setCommandId($.id)},...["below","duplicate","up","down","delete"].map(U=>({id:U,label:e.labels[U],disabled:e.locked||U==="up"&&F===0||U==="down"&&F===e.document.blocks.length-1,onClick:()=>e.action($.id,U)}))]},`${e.restoreVersion}-${e.commandId??""}`),n.jsx(Rr,{block:$,state:e,label:$.kind==="codeBlock"?e.labels.codeBlock:s,views:y})]},$.id)})]}),(e.linkOpen||e.media||e.ai?I:!e.source&&d)&&!e.locked&&n.jsx(ht.Portal,{children:n.jsx(Dr,{rect:e.linkOpen||e.media||e.ai?I:d,state:e,props:t,preserve:Z})}),n.jsx(P.Command,{open:!!e.commandId&&!e.locked,onOpenChange:$=>{$||e.closeCommand()},placeholder:e.labels.blocks,commands:gr.map($=>({id:$,name:e.labels[$],onSelect:()=>{e.commandId&&e.transform(e.commandId,$)}}))}),u]})}const Ar=e=>{const t=kr(e);return n.jsx(Mr,{...e,state:t})};function Lr(){const[e,t]=C.useState(()=>{var r;return typeof window<"u"&&!!((r=window.matchMedia)!=null&&r.call(window,"(prefers-reduced-motion: reduce)").matches)});return C.useEffect(()=>{var o,a;const r=(o=window.matchMedia)==null?void 0:o.call(window,"(prefers-reduced-motion: reduce)");if(!r)return;const g=()=>t(r.matches);return g(),(a=r.addEventListener)==null||a.call(r,"change",g),()=>{var c;return(c=r.removeEventListener)==null?void 0:c.call(r,"change",g)}},[]),e}const He=typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"grapheme"}):void 0;function Tt(e,{typing:t=!1,isStreaming:r=!1,onTypingComplete:g}={}){const o=Lr(),a=!!t&&!o&&!!He,c=typeof t=="object"?t:void 0,b=Math.max(1,Math.floor(Number.isFinite(c==null?void 0:c.charsPerTick)?c.charsPerTick:3)),i=Math.max(1,Number.isFinite(c==null?void 0:c.intervalMs)?c.intervalMs:16),[s,l]=C.useState(()=>({value:e,length:a?0:e.length})),f=C.useRef(e),x=C.useRef(null),y=C.useRef(g);y.current=g;const u=C.useMemo(()=>[0,...Array.from((He==null?void 0:He.segment(e))??[],p=>p.index+p.segment.length)],[e]),j=Math.max(0,u.length-(r?2:1)),S=u[j],D=e.startsWith(s.value)?Math.min(s.length,S):0;let d=0;for(;d+1<u.length&&u[d+1]<=D;)d++;const m=a?u[d]:e.length,I=e.slice(0,m),k=C.useRef({value:e,ends:u,index:d,targetIndex:j});k.current={value:e,ends:u,index:d,targetIndex:j};const M=a&&m<S;return C.useEffect(()=>{e.startsWith(f.current)||(x.current=null),f.current=e},[e]),C.useEffect(()=>{r&&(x.current=null)},[r]),C.useEffect(()=>{a||l(p=>p.value===e&&p.length===e.length?p:{value:e,length:e.length})},[a,e]),C.useEffect(()=>{if(!M)return;const p=setInterval(()=>{const w=k.current;l({value:w.value,length:w.ends[Math.min(w.index+b,w.targetIndex)]})},i);return()=>clearInterval(p)},[M,b,i]),C.useEffect(()=>{var p;t&&e&&!r&&m===e.length&&x.current!==e&&(x.current=e,(p=y.current)==null||p.call(y))},[e,t,r,m]),{displayedText:I,isTyping:a&&(m<e.length||r)}}function $r({value:e,label:t,onLinkPress:r,renderLink:g,allowImages:o=!0,allowVideos:a=!0,renderVideo:c,typing:b,isStreaming:i,onTypingComplete:s,labels:l,views:f={},native:x=!1,codeFontFamily:y="monospace",...u}){const{displayedText:j,isTyping:S}=Tt(e,{typing:b,isStreaming:i,onTypingComplete:s}),D=C.useRef([]),d=C.useMemo(()=>{const m=_e(j,D.current,void 0,{display:!0});return D.current=m.blocks,m},[j]);return n.jsxs(h.Vertical,{gap:12,minWidth:0,...x?{accessibilityLabel:t}:{role:t?"region":void 0,"aria-label":t},...u,...f.container,children:[d.sourceMode?n.jsxs(n.Fragment,{children:[n.jsx(h.Text,{...f.notice,children:(l==null?void 0:l.sourceFallback)??"This Markdown contains unsupported syntax. Its source is shown as plain text."}),n.jsx(h.Text,{fontFamily:y,...x?{selectable:!0}:{style:{whiteSpace:"pre-wrap",overflowWrap:"anywhere"}},...f.source,children:j})]}):d.blocks.filter(m=>m.raw).map(m=>n.jsx(h.View,{minWidth:0,...f.block,children:n.jsx(It,{block:m,native:x,codeFontFamily:y,isDisplay:!0,onLinkPress:r,renderLink:g,allowImages:o,allowVideos:a,renderVideo:c})},m.id)),S&&n.jsx(h.View,{as:"span",width:2,height:16,backgroundColor:"color-gray-700",...x?{accessibilityElementsHidden:!0}:{"aria-hidden":!0},animate:h.Animation.flash({duration:"0.8s",iterationCount:"infinite"})})]})}const Br=e=>n.jsx($r,{...e}),Vr=e=>{const t=K.useIconPickerState(e);return n.jsx(K.IconPickerView,{...t,...e})},Pr=Vr;function Fr({onSelect:e,onCancel:t,active:r}){const[g,o]=C.useState(null);C.useRef(null);const a=C.useCallback(i=>{var y;if(!r)return;const s=document.elementFromPoint(i.clientX,i.clientY);if(!s||s===document.body||s.closest('[data-chatwidget-ignore="true"]')||s.closest("#chatwidget-overlay")){o(null);return}const l=s.getBoundingClientRect();let f=s.tagName.toLowerCase();if(s.id)f+=`#${s.id}`;else if(s.className&&typeof s.className=="string"){const u=s.className.split(" ")[0];u&&(f+=`.${u}`)}const x=(y=s.innerText)==null?void 0:y.slice(0,20);x&&(f+=` ("${x}...")`),o({id:s.id||`el-${Date.now()}`,name:f,tagName:s.tagName.toLowerCase(),rect:l})},[r]),c=C.useCallback(i=>{!r||i.target.closest('[data-chatwidget-ignore="true"]')||(i.preventDefault(),i.stopPropagation(),g&&e(g))},[r,g,e]),b=C.useCallback(i=>{r&&i.key==="Escape"&&t()},[r,t]);return C.useEffect(()=>{if(!(typeof document>"u"))return r?(document.addEventListener("mousemove",a),document.addEventListener("click",c,!0),document.addEventListener("keydown",b),document.body.style.cursor="crosshair"):(o(null),document.removeEventListener("mousemove",a),document.removeEventListener("click",c,!0),document.removeEventListener("keydown",b),document.body.style.cursor=""),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("click",c,!0),document.removeEventListener("keydown",b),document.body.style.cursor=""}},[r,a,c,b]),{highlightedElement:g}}function Wr({element:e}){return e?n.jsx("div",{id:"chatwidget-overlay",style:{position:"fixed",top:e.rect.top,left:e.rect.left,width:e.rect.width,height:e.rect.height,border:"2px solid #1D4ED8",backgroundColor:"rgba(29, 78, 216, 0.08)",pointerEvents:"none",zIndex:99999,transition:"top 0.1s ease-out, left 0.1s ease-out, width 0.1s ease-out, height 0.1s ease-out",borderRadius:"8px"},children:n.jsx("div",{style:{position:"absolute",top:"-24px",left:"0",backgroundColor:"#1D4ED8",color:"white",padding:"2px 8px",borderRadius:"9999px",fontSize:"12px",fontWeight:"bold",whiteSpace:"nowrap"},children:e.name})}):null}const Or=({initialMessages:e=[],onSendMessage:t,bubbleSize:r="md"})=>{const[g,o]=C.useState(!1),[a,c]=C.useState(!1),[b,i]=C.useState(e),[s,l]=C.useState([]),{highlightedElement:f}=Fr({active:a,onSelect:S=>{l(D=>[...D,S]),c(!1),o(!0)},onCancel:()=>{c(!1),o(!0)}}),x=()=>o(!g),y=()=>{c(!0),o(!1)},u=S=>{l(D=>D.filter(d=>d.id!==S))},j=S=>{const D={id:Date.now().toString(),role:"user",content:S,timestamp:new Date,contextElements:[...s]};i(d=>[...d,D]),t==null||t(S,s),l([]),setTimeout(()=>{var k;const d=Math.random()>.7,m=Math.random()>.4,I={id:(Date.now()+1).toString(),role:"assistant",timestamp:new Date,content:d?"I will highlight the selected element.":`I received your message regarding: ${((k=D.contextElements)==null?void 0:k.map(M=>M.name).join(", "))||"general context"}. How can I assist you further?`,messageType:d?"tool":"text",reasoning:m?"Analyzing the user input and context... The user seems to be asking about specific elements. I should tailor my response to the selected context.":void 0};i(M=>[...M,I]),d&&setTimeout(()=>{i(M=>[...M,{id:(Date.now()+2).toString(),role:"assistant",messageType:"system",content:'Tool "highlightElement" executed successfully.',timestamp:new Date}])},800)},1e3)};return n.jsxs(h.View,{position:"fixed",bottom:24,right:24,zIndex:9999,children:[n.jsx(Wr,{element:f}),a&&n.jsx(h.View,{position:"fixed",top:24,left:"50%",transform:"translateX(-50%)",backgroundColor:"rgba(0,0,0,0.8)",color:"white",padding:"8px 16px",borderRadius:"24px",zIndex:1e4,boxShadow:"0 4px 6px rgba(0,0,0,0.1)",children:n.jsx(h.Text,{fontWeight:"600",fontSize:"14px",children:"Click an element to select it. Press ESC to cancel."})}),g&&n.jsxs(h.View,{position:"absolute",bottom:60,right:0,width:"400px",height:"600px",marginBottom:"16px",backgroundColor:"rgba(255, 255, 255, 0.8)",backdropFilter:"blur(20px)",borderRadius:"24px",border:"1px solid rgba(255, 255, 255, 0.4)",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",overflow:"hidden",animation:"slideUp 0.3s ease-out",style:{animation:"fadeIn 0.2s ease-out",transformOrigin:"bottom right"},children:[n.jsxs(h.View,{padding:"16px",borderBottom:"1px solid rgba(0,0,0,0.05)",display:"flex",justifyContent:"space-between",alignItems:"center",children:[n.jsx(h.Text,{fontWeight:"bold",color:"color-gray-800",children:"ChatWidget Assistant"}),n.jsx(h.View,{as:"button",onClick:()=>o(!1),cursor:"pointer",padding:"4px",borderRadius:"50%",border:"none",backgroundColor:"transparent",_hover:{backgroundColor:"rgba(0,0,0,0.05)"},children:n.jsx(E.CloseIcon,{widthHeight:16,color:"color-gray-500"})})]}),n.jsx(P.ChatWidget,{messages:b,onSubmit:j,size:r,variant:"minimal",enableContextPicker:!0,selectedContextElements:s,onContextPickerClick:y,onRemoveContextElement:u,styles:{container:{height:"calc(100% - 60px)",backgroundColor:"transparent"},inputContainer:{backgroundColor:"white",margin:"0 16px 16px 16px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"}}})]}),!a&&n.jsx(h.View,{as:"button",onClick:x,width:"56px",height:"56px",borderRadius:"50%",backgroundColor:"theme-primary",border:"none",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"transform 0.2s ease",_hover:{transform:"scale(1.05)"},_active:{transform:"scale(0.95)"},"data-chatwidget-ignore":"true",children:g?n.jsx(E.CloseIcon,{widthHeight:24,color:"white"}):n.jsx(E.PanelIcon,{widthHeight:24,color:"white"})})]})},Hr={info:{container:{backgroundColor:"color-white",border:"rgba(191, 219, 254, 0.95)"},icon:{color:"theme-primary",name:"InformationIcon"},content:{color:"color-gray-900"},close:{color:"color-gray-500",name:"CloseIcon"}},success:{container:{backgroundColor:"#F0FDF4",border:"#BBF7D0"},icon:{color:"#16A34A",name:"SuccessIcon"},content:{color:"#14532D"},close:{color:"#15803D",name:"CloseIcon"}},error:{container:{backgroundColor:"#FEF2F2",border:"#FECACA"},icon:{color:"#DC2626",name:"ErrorIcon"},content:{color:"#7F1D1D"},close:{color:"#B91C1C",name:"CloseIcon"}},warning:{container:{backgroundColor:"#FFF7ED",border:"#FED7AA"},icon:{color:"#EA580C",name:"WarningIcon"},content:{color:"#9A3412"},close:{color:"#C2410C",name:"CloseIcon"}}},Et=({variant:e,hide:t,title:r,subtitle:g,theme:o,action:a,actionText:c,showIcon:b=!1,isClosable:i=!1,timeout:s=3e3,views:l})=>{var D,d;C.useEffect(()=>{if(s&&!i){const m=setTimeout(()=>{t()},s);return()=>{clearTimeout(m)}}},[]);const f=o??Hr,x=!!(a&&c),y={borderWidth:1,borderStyle:"solid",borderRadius:12,borderColor:`${f[e].container.border}`,boxShadow:"0 8px 24px rgba(15, 23, 42, 0.06)"},u={info:"#3b82f6",success:"#4ade80",warning:"#f97316",error:"#ef4444"}[e],j={info:n.jsx(E.InfoIcon,{widthHeight:24,color:u,...l==null?void 0:l.icon}),success:n.jsx(E.SuccessIcon,{widthHeight:24,color:u,...l==null?void 0:l.icon}),warning:n.jsx(E.WarningIcon,{widthHeight:24,color:u,...l==null?void 0:l.icon}),error:n.jsx(E.ErrorIcon,{widthHeight:24,color:u,...l==null?void 0:l.icon})}[e],S=b&&j;return n.jsxs(h.Horizontal,{role:"messageContent",gap:12,width:"100%",maxWidth:520,flexWrap:"nowrap",position:"relative",alignItems:"flex-start",padding:"12px 14px",color:`${f[e].content.color}`,backgroundColor:`${f[e].container.backgroundColor}`,onClick:i?()=>{}:()=>{t()},...y,transition:"background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease",...l==null?void 0:l.container,children:[S&&j,n.jsxs(h.Vertical,{gap:4,width:"100%",children:[n.jsx(h.Text,{size:"md",weight:"semiBold",...l==null?void 0:l.title,children:r}),g&&n.jsx(h.Text,{size:"sm",lineHeight:"20px",color:f[e].content.color,...l==null?void 0:l.subtitle,children:g})]}),x&&n.jsx(h.View,{as:"button",type:"button",onClick:a,backgroundColor:"color-white",borderWidth:"1px",borderStyle:"solid",borderColor:f[e].container.border,borderRadius:"9999px",padding:"6px 12px",cursor:"pointer",transition:"background-color 0.2s ease, border-color 0.2s ease",...l==null?void 0:l.actionText,children:n.jsx(h.Text,{whiteSpace:"nowrap",size:"sm",weight:"semiBold",color:f[e].content.color,children:c})}),i&&n.jsx(h.View,{position:"absolute",zIndex:1e4,right:8,top:8,onClick:()=>{t()},cursor:"pointer",padding:"4px",borderRadius:"9999px",transition:"background-color 0.2s ease",...(D=l==null?void 0:l.closingIcon)==null?void 0:D.container,children:n.jsx(E.CloseIcon,{widthHeight:16,color:f[e].close.color,...(d=l==null?void 0:l.closingIcon)==null?void 0:d.icon})})]})},zr=({container:e,theme:t,position:r="topRight"})=>{const{visible:g,title:o,variant:a,subtitle:c,isClosable:b,views:i,action:s,actionText:l,showIcon:f,timeout:x}=ce.useMessageStore(),y={topLeft:{top:6,left:8},topRight:{top:6,right:8},bottomLeft:{bottom:8,left:6},bottomRight:{bottom:8,right:6}}[r],u=()=>n.jsx(Et,{variant:a,subtitle:c,show:g,title:o,theme:t,isClosable:b,views:i,action:s,actionText:l,showIcon:f,timeout:x,hide:()=>ce.hideMessage()}),j=e?C.cloneElement(e,{},u()):n.jsx(h.View,{position:"absolute",zIndex:1e4,...y,children:u()});return g?j:null};function Nr(e){const t=Math.floor(e/60),r=e%60;return`${t}:${r.toString().padStart(2,"0")}`}function Ur({onAudio:e,recording:t,paused:r,audioBlob:g,analyserNode:o,duration:a,error:c,startRecording:b,stopRecording:i,pauseRecording:s,resumeRecording:l,resetRecording:f,handleFileChange:x,...y}){const[u,j]=C.useState(null);C.useEffect(()=>{if(g){const d=URL.createObjectURL(g);return j({url:d,label:`recording-${Date.now()}.webm`}),()=>{URL.revokeObjectURL(d)}}return()=>{}},[g]);const S=()=>{u!=null&&u.url&&URL.revokeObjectURL(u.url),j(null),f()},D=d=>{e(d),u!=null&&u.url&&URL.revokeObjectURL(u.url),j({url:URL.createObjectURL(d),label:d.name})};return n.jsxs(h.Vertical,{gap:"10px",width:"100%",...y,children:[n.jsxs(h.Horizontal,{gap:12,alignItems:"center",padding:"12px 14px",border:"1px solid color-gray-200",borderRadius:"12px",backgroundColor:"color-white",children:[n.jsx(ce.Uploader,{accept:"audio/*",icon:n.jsx(E.AttachmentIcon,{widthHeight:16}),maxSize:100*1024*1024,onFileSelect:D,fileType:"file",multiple:!1,renderError:({errorMessage:d})=>null,views:{container:{width:"36px",height:"36px",cursor:"pointer",border:"1px solid color-gray-200",borderRadius:"10px",backgroundColor:"color-white",transition:"background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease",_hover:{backgroundColor:"color-gray-50",borderColor:"color-gray-300"}}},containerProps:{display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"10px",width:"36px",height:"36px"},validateFile:d=>d.size>100*1024*1024?"File size exceeds 100MB limit":d.type.startsWith("audio/")?null:"Only audio files are allowed"}),n.jsx(h.View,{as:"button",type:"button",onClick:t?i:b,width:"36px",height:"36px",minWidth:"36px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"theme-primary",color:"color-white",borderRadius:"999px",border:"0",cursor:"pointer",transition:"background-color 0.2s ease, opacity 0.2s ease",_hover:{opacity:.92},children:t?n.jsx(E.StopIcon,{widthHeight:14,color:"color-white",filled:!1}):n.jsx(E.MicrophoneIcon,{widthHeight:18,color:"color-white",filled:!1})}),n.jsx(h.View,{flex:1,minWidth:120,children:n.jsx(ce.AudioWaveform,{analyserNode:t?o:null,isPaused:!t||r})}),n.jsx(h.Text,{fontSize:"12px",lineHeight:"16px",color:"color-gray-500",whiteSpace:"nowrap",children:Nr(a)})]}),u&&!t&&n.jsxs(h.Vertical,{gap:"8px",padding:"12px 14px",border:"1px solid color-gray-200",borderRadius:"12px",backgroundColor:"color-white",children:[n.jsxs(h.Horizontal,{alignItems:"center",justifyContent:"space-between",gap:8,children:[n.jsx(h.Text,{fontSize:"12px",lineHeight:"16px",color:"color-gray-500",children:u.label}),n.jsx(h.View,{as:"button",type:"button",onClick:S,width:"24px",height:"24px",display:"flex",alignItems:"center",justifyContent:"center",border:"0",backgroundColor:"transparent",color:"color-gray-500",cursor:"pointer",children:n.jsx(E.CloseIcon,{widthHeight:14,color:"currentColor"})})]}),n.jsx(h.View,{as:"audio",controls:!0,src:u.url,width:"100%"})]}),c&&n.jsx(h.Text,{fontSize:"11px",lineHeight:"16px",color:"theme-error",children:c})]})}function _r(e){const{onAudio:t}=e,{recording:r,paused:g,audioBlob:o,analyserNode:a,duration:c,error:b,startRecording:i,stopRecording:s,pauseRecording:l,resumeRecording:f,resetRecording:x}=ce.useAudioRecording();return C.useEffect(()=>{if(o&&t){const u=new File([o],"recording.webm",{type:o.type||"audio/webm;codecs=opus"});t(u)}},[o,t]),{recording:r,paused:g,audioBlob:o,analyserNode:a,duration:c,error:b,startRecording:i,stopRecording:s,pauseRecording:l,resumeRecording:f,resetRecording:x,handleFileChange:u=>{var S;const j=(S=u.target.files)==null?void 0:S[0];j&&t&&t(j)}}}function qr(e){const t=_r(e);return n.jsx(Ur,{...e,...t})}const Xr=e=>{const t=K.useDatePickerState(e);return n.jsx(K.DatePickerView,{...t,...e})},Yr=Xr,vr=({logo:e,logoSrc:t,loader:r,showLoader:g=!0,duration:o=600,isLoaded:a,onHidden:c,backgroundColor:b="color-white",children:i,...s})=>{const l=P.useSplashStore(m=>m.loaded),f=a!==void 0?a:l,[x,y]=C.useState(!0),[u,j]=C.useState(!1);if(C.useEffect(()=>{if(!f||u)return;j(!0);const m=setTimeout(()=>{y(!1),c==null||c()},o);return()=>clearTimeout(m)},[f,u,o,c]),!x)return null;const S=h.isBrowser()?"fixed":"absolute",D=u?h.Animation.fadeOut({duration:`${o}ms`}):void 0,d=e??(t?n.jsx(h.Image,{src:t,width:120,height:120,alt:"logo"}):null);return n.jsxs(h.Center,{position:S,top:0,left:0,right:0,bottom:0,zIndex:9999,backgroundColor:b,animate:D,...s,children:[n.jsxs(h.Vertical,{alignItems:"center",gap:24,children:[d,g&&(r??n.jsx($e.Loader,{}))]}),i]})};exports.Accordion=P.Accordion;exports.AspectRatio=P.AspectRatio;exports.Background=P.Background;exports.Badge=P.Badge;exports.Button=P.Button;exports.CHART_COLORS=P.CHART_COLORS;exports.Carousel=P.Carousel;exports.ChatInput=P.ChatInput;exports.ChatWidget=P.ChatWidget;exports.ChatWidgetComponent=P.ChatWidgetComponent;exports.ColorPicker=P.ColorPicker;exports.Command=P.Command;exports.ContextMenu=P.ContextMenu;exports.DEFAULT_CHART_COLORS=P.DEFAULT_CHART_COLORS;exports.DesignSystem=P.DesignSystem;exports.DesignSystemProvider=P.DesignSystemProvider;exports.Divider=P.Divider;exports.Drawer=P.Drawer;exports.DropdownMenu=P.DropdownMenu;exports.Gradient=P.Gradient;exports.Menubar=P.Menubar;exports.NavigationMenu=P.NavigationMenu;exports.OTPInput=P.OTPInput;exports.Pagination=P.Pagination;exports.ProgressBar=P.ProgressBar;exports.Radio=P.Radio;exports.Resizable=P.Resizable;exports.Separator=P.Separator;exports.ShareButton=P.ShareButton;exports.Sidebar=P.Sidebar;exports.Slider=P.Slider;exports.StatusIndicator=P.StatusIndicator;exports.Table=P.Table;exports.TextArea=P.TextArea;exports.Title=P.Title;exports.Toast=P.Toast;exports.ToggleGroup=P.ToggleGroup;exports.Tooltip=P.Tooltip;exports.hideDrawer=P.hideDrawer;exports.setSplashLoaded=P.setSplashLoaded;exports.setSplashStarted=P.setSplashStarted;exports.showDrawer=P.showDrawer;exports.showToast=P.showToast;exports.useDrawerStore=P.useDrawerStore;exports.useSplashStore=P.useSplashStore;exports.useToast=P.useToast;exports.ArrowIcon=E.ArrowIcon;exports.AttachmentIcon=E.AttachmentIcon;exports.AudioIcon=E.AudioIcon;exports.BackIcon=E.BackIcon;exports.BatteryIcon=E.BatteryIcon;exports.BluetoothIcon=E.BluetoothIcon;exports.BoldArrowIcon=E.BoldArrowIcon;exports.BookmarkIcon=E.BookmarkIcon;exports.CalendarIcon=E.CalendarIcon;exports.CameraIcon=E.CameraIcon;exports.ChartIcon=E.ChartIcon;exports.CheckIcon=E.CheckIcon;exports.ChevronIcon=E.ChevronIcon;exports.ClockIcon=E.ClockIcon;exports.CloseEyeIcon=E.CloseEyeIcon;exports.CloseIcon=E.CloseIcon;exports.CloudIcon=E.CloudIcon;exports.CopyIcon=E.CopyIcon;exports.CreditCardIcon=E.CreditCardIcon;exports.CropIcon=E.CropIcon;exports.DeleteIcon=E.DeleteIcon;exports.DocumentIcon=E.DocumentIcon;exports.DownloadIcon=E.DownloadIcon;exports.DragHandleIcon=E.DragHandleIcon;exports.DragHandleLinesIcon=E.DragHandleLinesIcon;exports.DustBinIcon=E.DustBinIcon;exports.EditIcon=E.EditIcon;exports.ErrorIcon=E.ErrorIcon;exports.ExternalLinkIcon=E.ExternalLinkIcon;exports.FacebookIcon=E.FacebookIcon;exports.FileIcon=E.FileIcon;exports.FilterIcon=E.FilterIcon;exports.FolderIcon=E.FolderIcon;exports.GiftIcon=E.GiftIcon;exports.HeartIcon=E.HeartIcon;exports.HelpIcon=E.HelpIcon;exports.HomeIcon=E.HomeIcon;exports.Icon=E.Icon;exports.ImageIcon=E.ImageIcon;exports.InfoIcon=E.InfoIcon;exports.InstagramIcon=E.InstagramIcon;exports.LayoutIcon=E.LayoutIcon;exports.LikeIcon=E.LikeIcon;exports.LinkIcon=E.LinkIcon;exports.LinkedinIcon=E.LinkedinIcon;exports.LoadingSpinnerIcon=E.LoadingSpinnerIcon;exports.LockIcon=E.LockIcon;exports.LogoutIcon=E.LogoutIcon;exports.MagicWandIcon=E.MagicWandIcon;exports.MapPinIcon=E.MapPinIcon;exports.MenuIcon=E.MenuIcon;exports.MicrophoneIcon=E.MicrophoneIcon;exports.MinusIcon=E.MinusIcon;exports.MoonIcon=E.MoonIcon;exports.MoreIcon=E.MoreIcon;exports.MousePointerIcon=E.MousePointerIcon;exports.NotificationIcon=E.NotificationIcon;exports.OpenEyeIcon=E.OpenEyeIcon;exports.PanelIcon=E.PanelIcon;exports.PauseIcon=E.PauseIcon;exports.PlayIcon=E.PlayIcon;exports.PlusIcon=E.PlusIcon;exports.PowerOffIcon=E.PowerOffIcon;exports.PrintIcon=E.PrintIcon;exports.ProfileIcon=E.ProfileIcon;exports.RefreshIcon=E.RefreshIcon;exports.RotateIcon=E.RotateIcon;exports.SaveIcon=E.SaveIcon;exports.SearchIcon=E.SearchIcon;exports.SendIcon=E.SendIcon;exports.SettingsIcon=E.SettingsIcon;exports.ShapeIcon=E.ShapeIcon;exports.ShareIcon=E.ShareIcon;exports.ShieldIcon=E.ShieldIcon;exports.SliderIcon=E.SliderIcon;exports.SpinnerIcon=E.SpinnerIcon;exports.StarIcon=E.StarIcon;exports.StopIcon=E.StopIcon;exports.SuccessIcon=E.SuccessIcon;exports.TextIcon=E.TextIcon;exports.ThreadsIcon=E.ThreadsIcon;exports.TickIcon=E.TickIcon;exports.TrashIcon=E.TrashIcon;exports.TwitchIcon=E.TwitchIcon;exports.TwitterIcon=E.TwitterIcon;exports.UnLikeIcon=E.UnLikeIcon;exports.UnlockIcon=E.UnlockIcon;exports.UploadIcon=E.UploadIcon;exports.UserIcon=E.UserIcon;exports.VideoIcon=E.VideoIcon;exports.WarningIcon=E.WarningIcon;exports.WifiIcon=E.WifiIcon;exports.XIcon=E.XIcon;exports.YoutubeIcon=E.YoutubeIcon;exports.ZapIcon=E.ZapIcon;exports.ZoomInIcon=E.ZoomInIcon;exports.ZoomOutIcon=E.ZoomOutIcon;exports.Alert=Nt.Alert;exports.AudioWaveform=ce.AudioWaveform;exports.DefaultEmojiData=ce.DefaultEmojiData;exports.FormikForm=ce.FormikForm;exports.FormikUploader=ce.FormikUploader;exports.HoverCard=ce.HoverCard;exports.QuickReactionEmojis=ce.QuickReactionEmojis;exports.Toggle=ce.Toggle;exports.Uploader=ce.Uploader;exports.hideMessage=ce.hideMessage;exports.showMessage=ce.showMessage;exports.useMessageStore=ce.useMessageStore;exports.Avatar=Ut.Avatar;exports.Card=_t.Card;exports.Loader=$e.Loader;exports.Select=qt.Select;exports.Switch=Xt.Switch;exports.AttachmentPreview=K.AttachmentPreview;exports.FormikChatInput=K.FormikChatInput;exports.FormikCheckbox=K.FormikCheckbox;exports.FormikColorInput=K.FormikColorInput;exports.FormikComboBox=K.FormikComboBox;exports.FormikCountryPicker=K.FormikCountryPicker;exports.FormikDatePicker=K.FormikDatePicker;exports.FormikEmojiPicker=K.FormikEmojiPicker;exports.FormikIconPicker=K.FormikIconPicker;exports.FormikOTPInput=K.FormikOTPInput;exports.FormikPassword=K.FormikPassword;exports.FormikRadio=K.FormikRadio;exports.FormikSelect=K.FormikSelect;exports.FormikSelector=K.FormikSelector;exports.FormikSlider=K.FormikSlider;exports.FormikSwitch=K.FormikSwitch;exports.FormikTagInput=K.FormikTagInput;exports.FormikTextArea=K.FormikTextArea;exports.FormikTextField=K.FormikTextField;exports.FormikToggle=K.FormikToggle;exports.FormikToggleGroup=K.FormikToggleGroup;exports.defaultEmojiPickerLabels=K.defaultEmojiPickerLabels;exports.TextField=Me.TextField;exports.Checkbox=Yt.Checkbox;exports.Link=Ye.Link;exports.Tabs=vt.Tabs;exports.deepMerge=ye.deepMerge;exports.getDesignSystemComponentProps=ye.getDesignSystemComponentProps;exports.mergeDesignSystemComponentProps=ye.mergeDesignSystemComponentProps;exports.normalizeDesignSystemComponentProps=ye.normalizeDesignSystemComponentProps;exports.useDesignSystem=ye.useDesignSystem;exports.useDesignSystemComponentProps=ye.useDesignSystemComponentProps;exports.useMergedDesignSystemComponentProps=ye.useMergedDesignSystemComponentProps;exports.defaultDesignSystemConfig=Qe.defaultDesignSystemConfig;exports.designSystemConfigList=Qe.designSystemConfigList;exports.designSystemConfigs=Qe.designSystemConfigs;exports.Modal=we.Modal;exports.ModalLayout=we.ModalLayout;exports.ModalRouter=we.ModalLayout;exports.hideModal=we.hideModal;exports.showModal=we.showModal;exports.useModalStore=we.useModalStore;exports.Router=Je.Router;exports.matchPath=Je.matchPath;exports.useHistory=Je.useHistory;exports.goBack=et.goBack;exports.navigate=et.navigate;exports.useRouterStore=et.useRouterStore;exports.ActionSheet=en;exports.AttachmentGroup=kt;exports.AudioInput=qr;exports.BlockEditor=Ar;exports.Chart=Cn;exports.ChatWidgetWidget=Or;exports.ColorInput=Pn;exports.ComboBox=Nn;exports.CookieConsent=Tn;exports.CountryPicker=Wn;exports.DataState=or;exports.DataStateDefaultLabels=mt;exports.DatePicker=Yr;exports.DragAndDrop=cr;exports.DragAndDropComponent=bt;exports.DropZone=ur;exports.EmojiPicker=yt;exports.FileImage=Dn;exports.FileSVG=En;exports.IconPicker=Pr;exports.KeyboardAvoidingView=ft;exports.Markdown=Br;exports.MediaPreview=qn;exports.MessageLayout=zr;exports.MessageView=Et;exports.PageHeader=Zn;exports.PageLayout=Xn;exports.Password=Hn;exports.RadioGroup=Bn;exports.Selector=Mn;exports.SplashScreen=vr;exports.StatePanel=De;exports.TagInput=_n;exports.classifyDataStateError=xt;exports.defaultBlockEditorLabels=jt;exports.useMarkdownTyping=Tt;
|
|
57
|
+
`:p.data;V!=null&&(p.cancelable?(p.preventDefault(),e.replace(V,R),x()):l.current={target:R,text:V})},k=C.useRef(I);return k.current=I,C.useEffect(()=>{const p=t.current,w=R=>k.current(R);return p==null||p.addEventListener("beforeinput",w,!0),()=>p==null?void 0:p.removeEventListener("beforeinput",w,!0)},[t]),{capture:D,selectedDocument:b,onKeyDown:m,onInputCapture:p=>{var W,A;const w=y(p.target),R=p.nativeEvent;if(!w||e.locked||R.isComposing||s.current)return;const V=f.current??S(w,R.inputType,e.current.current.selection);if(V){p.stopPropagation(),f.current=null,V.value===e.current.current.value?e.restoreSelection(V.selection):e.commit(V.value,V.selection),x();return}if(R.inputType==="historyUndo"||R.inputType==="historyRedo")p.stopPropagation(),e.undo(R.inputType==="historyRedo");else if(l.current||w.tagName!=="TEXTAREA"&&j(e.current.current.selection)&&(R.data!=null||(W=R.inputType)!=null&&W.startsWith("delete"))){p.stopPropagation();const{target:B,text:O}=l.current??{target:e.current.current.selection,text:(A=R.inputType)!=null&&A.startsWith("delete")?"":R.data};l.current=null,e.replace(O,B),x()}},onCopy:p=>d(p),onCut:p=>d(p,!0),onPaste:p=>{const w=y(p.target);if(!w||w.tagName==="TEXTAREA"||e.locked)return;const R=u(w);if(!R)return;p.preventDefault();const V=p.clipboardData.getData("text/plain");!V&&!Array.from(p.clipboardData.types||[]).includes("text/plain")||(e.capture(R),e.replace(V,R),x())},onPointerDownCapture:p=>{c.current=null,y(p.target)&&x()},onCompositionStartCapture:p=>{const w=y(p.target),R=w&&u(w);R&&j(R)&&!e.locked&&(s.current=R)},onCompositionEndCapture:p=>{const w=s.current;w&&(p.stopPropagation(),s.current=null,p.data?e.replace(p.data,w):e.restoreSelection(w),x())}}}function Dr({rect:e,state:t,props:r,preserve:g}){var i,s,l,f;const o=C.useRef(null),{themeMode:a}=h.useTheme(),[c,b]=C.useState({top:8,left:8});return C.useLayoutEffect(()=>{const x=()=>{var j;const u=(j=o.current)==null?void 0:j.getBoundingClientRect();u&&b({left:Math.max(8,Math.min(e.left,window.innerWidth-u.width-8)),top:Math.max(8,Math.min(e.top-u.height-8>=8?e.top-u.height-8:e.bottom+8,window.innerHeight-u.height-8))})};x();const y=typeof ResizeObserver>"u"?null:new ResizeObserver(x);return o.current&&(y==null||y.observe(o.current)),()=>y==null?void 0:y.disconnect()},[e,t.linkOpen,!!t.media,(i=t.media)==null?void 0:i.phase,(s=t.ai)==null?void 0:s.state,(l=t.ai)==null?void 0:l.result,(f=t.ai)==null?void 0:f.prompt,t.stale,t.message]),C.useEffect(()=>{if(!t.linkOpen&&!t.media&&!t.ai)return;const x=y=>{var u;y.target instanceof Node&&!((u=o.current)!=null&&u.contains(y.target))&&(t.media?t.closeMedia(!1):t.ai?t.closeAi(!1):t.closeLink(!1))};return document.addEventListener("pointerdown",x,!0),()=>document.removeEventListener("pointerdown",x,!0)},[t.linkOpen,!!t.media,!!t.ai]),n.jsx(h.View,{ref:o,"data-editor-selection-toolbar":"true","data-editor-link-popover":t.linkOpen?"true":void 0,"data-editor-ai-popover":t.ai?"true":void 0,role:t.linkOpen||t.media||t.ai?"dialog":void 0,"aria-label":t.media?t.labels.media:t.ai?t.labels.aiPanel:t.linkOpen?t.labels.link:void 0,onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),t.media?t.closeMedia():t.ai?t.closeAi():t.linkOpen&&t.closeLink())},position:"fixed",top:c.top,left:c.left,maxWidth:"calc(100vw - 16px)",maxHeight:"calc(100vh - 16px)",overflow:"auto",backgroundColor:a==="dark"?"color-gray-900":"color-white",borderWidth:1,borderStyle:"solid",borderColor:a==="dark"?"color-gray-600":"color-gray-300",boxShadow:"0 6px 20px rgba(0, 0, 0, 0.18)",borderRadius:10,padding:6,zIndex:1e3,children:t.linkOpen||t.media||t.ai?n.jsx(Ir,{state:t,views:r.views,uploadEnabled:!!r.uploadMedia,floating:!0}):n.jsx(Ge,{state:t,props:r,formatting:!0,preserve:g})})}function Rr({block:e,state:t,label:r,views:g}){const o=C.useRef(null),a=C.useRef(!1),c=C.useMemo(()=>n.jsx(It,{block:e}),[e.id,e.start,t.restoreVersion]),b=()=>{if(!o.current||a.current||t.locked)return;const i=wr(o.current);if(e.kind==="codeBlock"){const l=e.bodyStart-e.start;t.editBlock(e,ye(e.raw,{start:l,end:l+e.body.length},i.text),{start:l+i.selection.start,end:l+i.selection.end},!0,!1);return}const s=_e(i.text);t.editBlock(e,i.text,i.selection,!0,s.blocks.length!==1||s.blocks[0].kind!==e.kind)};return n.jsx(h.View,{ref:o,"data-block-id":e.id,"data-block-start":e.kind==="codeBlock"?e.bodyStart:e.start,"data-code-block":e.kind==="codeBlock"?e.id:void 0,"data-editor-input":"true",contentEditable:!t.locked,suppressContentEditableWarning:!0,role:"textbox","aria-label":r,"aria-multiline":"true","aria-readonly":t.locked,minHeight:24,flex:1,outline:"none",...g==null?void 0:g.content,onFocus:()=>t.setActiveId(e.id),onBeforeInput:i=>{if(i.defaultPrevented)return;const s=o.current&&Le(o.current,!0);s&&t.capture(s)},onInput:i=>{b()},onCompositionStart:()=>{a.current=!0},onCompositionEnd:()=>{a.current=!1,b()},onKeyDown:i=>{if(i.nativeEvent.isComposing||t.locked)return;const s=o.current&&Le(o.current,!0);s&&t.capture(s),i.key==="/"&&!i.metaKey&&!i.ctrlKey&&!e.body.trim()&&(i.preventDefault(),t.setCommandId(e.id))},children:c},t.restoreVersion)}function Mr({state:e,...t}){const{value:r,defaultValue:g,onChange:o,generate:a,uploadMedia:c,pickMedia:b,onSave:i,label:s=e.labels.document,isDisabled:l,isReadOnly:f,labels:x,views:y={},status:u,...j}=t,S=C.useRef(null),{themeMode:D}=h.useTheme(),[d,m]=C.useState(null),[I,k]=C.useState(null),M=C.useRef(null),p=C.useRef(null),w=Er(e,S,M,i,!!t.generate);C.useLayoutEffect(()=>{if(!e.linkOpen&&!e.media&&!e.ai||!S.current){k(null);return}const $=S.current.ownerDocument.getSelection(),F=$!=null&&$.rangeCount&&$.anchorNode&&S.current.contains($.anchorNode)?$.getRangeAt(0).cloneRange():null,X=p.current??S.current.querySelector(`[data-block-id="${e.activeId}"]`)??M.current??S.current,G=()=>{const U=F==null?void 0:F.getBoundingClientRect(),Q=U!=null&&U.height?U:X.getBoundingClientRect();k({top:Q.top,bottom:Q.bottom,left:Q.left})};return G(),window.addEventListener("scroll",G,!0),window.addEventListener("resize",G),()=>{window.removeEventListener("scroll",G,!0),window.removeEventListener("resize",G)}},[e.linkOpen,!!e.media,!!e.ai]);const R=C.useRef(null),V=C.useRef(null),W=C.useRef(null),A=C.useRef(null),B=C.useRef([]),O=C.useRef(null),[N,_]=C.useState(null),Z=$=>{$.preventDefault()},Y=()=>{var $;return Array.from((($=M.current)==null?void 0:$.querySelectorAll("[data-editor-row]"))||[])},q=()=>{var $;W.current!==null&&window.cancelAnimationFrame(W.current),W.current=null,R.current=null,($=V.current)==null||$.remove(),V.current=null,O.current=null,_(null)},H=($,F)=>$>F.from&&$<=F.to?-F.extent:$>=F.to&&$<F.from?F.extent:0,ee=($,F)=>{const X=Y()[$];return X?X.offsetTop+($>F.from?X.offsetHeight-F.height:0):F.top},re=$=>{const F=O.current;if(!F||F.to===$)return;const X={...F,to:$,top:ee($,F)};O.current=X,_(X)},ie=$=>{const F=O.current;if(!F||!M.current)return null;const X=$-M.current.getBoundingClientRect().top;if(X>=F.top&&X<=F.top+F.height)return F.to;const G=Y();let U=0;return G.forEach((Q,oe)=>{oe!==F.from&&X>=Q.offsetTop+H(oe,F)+Q.offsetHeight/2&&U++}),U};C.useEffect(()=>{q()},[e.value,e.locked,e.source]),C.useEffect(()=>{if(N!=null&&N.id)return window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[N==null?void 0:N.id]),C.useEffect(()=>()=>{var $;W.current!==null&&window.cancelAnimationFrame(W.current),($=V.current)==null||$.remove(),B.current.forEach(F=>F.cancel())},[]),C.useLayoutEffect(()=>{var F;const $=A.current;$&&(A.current=null,B.current.forEach(X=>X.cancel()),B.current=[],!((F=window.matchMedia)!=null&&F.call(window,"(prefers-reduced-motion: reduce)").matches)&&Y().forEach(X=>{const G=$.get(X.dataset.editorRow),U=G===void 0?0:G-X.getBoundingClientRect().top;Math.abs(U)<1||!X.animate||B.current.push(X.animate([{transform:`translateY(${U}px)`},{transform:"translateY(0)"}],{duration:180,easing:"cubic-bezier(0.2, 0, 0, 1)"}))}))}),C.useEffect(()=>{const $=()=>{var ue;const F=S.current;if(!F||e.holdSelection.current||e.linkOpen)return;if(R.current){m(null);return}const X=F.ownerDocument.activeElement,G=w.capture()??Le(F),U=F.ownerDocument.getSelection(),Q=X==null?void 0:X.matches("input[data-editor-input],textarea[data-editor-input]");if(G&&G.start!==G.end&&(U!=null&&U.rangeCount)&&!Q&&!e.locked){const ae=U.getRangeAt(0).getBoundingClientRect();if(ae.bottom>0&&ae.top<window.innerHeight){m({top:ae.top,bottom:ae.bottom,left:ae.left});return}}m(null);const oe=F.ownerDocument.getSelection();if(oe&&!oe.isCollapsed&&oe.anchorNode&&!F.contains(oe.anchorNode)&&!((ue=oe.anchorNode.parentElement)!=null&&ue.closest("[data-editor-block-list]"))){const ae=e.current.current.selection.end;e.capture({start:ae,end:ae})}};return document.addEventListener("selectionchange",$),window.addEventListener("scroll",$,!0),window.addEventListener("resize",$),()=>{document.removeEventListener("selectionchange",$),window.removeEventListener("scroll",$,!0),window.removeEventListener("resize",$)}},[e.locked,e.source,e.linkOpen]),C.useLayoutEffect(()=>{!e.restoreVersion||!S.current||!e.restoreRequested.current||(e.restoreRequested.current=!1,e.source&&p.current?(p.current.focus({preventScroll:!0}),p.current.setSelectionRange(e.selection.start,e.selection.end,e.selection.backward?"backward":"forward")):wt(S.current,e.selection))},[e.restoreVersion,e.source]);const se=()=>{p.current&&e.capture({start:p.current.selectionStart,end:p.current.selectionEnd,...p.current.selectionDirection==="backward"?{backward:!0}:{}})};return n.jsxs(h.Vertical,{ref:S,gap:12,minWidth:0,"aria-label":s,"aria-disabled":l,...j,...y.container,onCopy:w.onCopy,onCut:w.onCut,onPaste:w.onPaste,onPointerDownCapture:w.onPointerDownCapture,onInputCapture:w.onInputCapture,onCompositionStartCapture:w.onCompositionStartCapture,onCompositionEndCapture:w.onCompositionEndCapture,onDragOver:$=>{if(!R.current||e.locked)return;$.preventDefault(),$.dataTransfer.dropEffect="move";const F=ie($.clientY);F!==null&&re(F)},onDragLeave:$=>{const F=$.currentTarget.getBoundingClientRect();($.clientX<F.left||$.clientX>F.right||$.clientY<F.top||$.clientY>F.bottom)&&O.current&&re(O.current.from)},onDrop:$=>{var X;if(!R.current||e.locked)return;$.preventDefault();const F=ie($.clientY);if(F!==null&&((X=e.document.blocks[F])==null?void 0:X.id)!==R.current){A.current=new Map(Y().map(U=>[U.dataset.editorRow,U.getBoundingClientRect().top]));const G=O.current;G&&M.current&&A.current.set(G.id,M.current.getBoundingClientRect().top+ee(F,G)),e.move(R.current,F)}q()},onKeyDown:$=>{$.nativeEvent.isComposing||($.key==="Escape"&&(q(),e.setCommandId(null),e.linkOpen&&e.closeLink(),e.ai&&e.closeAi(),e.media&&e.closeMedia(),m(null)),w.onKeyDown($))},children:[!f&&n.jsxs(h.Vertical,{position:"sticky",top:0,zIndex:10,backgroundColor:D==="dark"?"color-gray-900":"color-white",borderWidth:1,borderColor:"color-gray-200",borderStyle:"solid",borderRadius:8,padding:8,gap:4,children:[n.jsx(Ge,{state:e,props:t,preserve:Z}),e.source&&n.jsx(Ge,{state:e,props:t,formatting:!0,preserve:Z})]}),e.document.sourceMode&&n.jsx(h.Text,{role:"status",...y.notice,children:e.labels.sourceFallback}),e.message&&!e.linkOpen&&n.jsx(h.Text,{role:"status",...y.notice,children:e.message}),e.source?n.jsx(P.TextArea,{value:e.value,"data-editor-input":"true","data-editor-offset":0,label:s,isDisabled:l,isReadOnly:f,inputRef:$=>{p.current=$},onSelect:se,onFocus:se,onChange:$=>e.commit($,p.current?{start:p.current.selectionStart,end:p.current.selectionEnd}:e.selection,!0,!1),views:{textarea:{minHeight:240,fontFamily:"monospace",...y.source}}}):n.jsxs(h.Vertical,{ref:M,position:"relative",gap:12,"data-editor-block-list":"true",children:[N&&n.jsx(h.View,{"data-editor-drop-placeholder":N.to,"aria-hidden":"true",position:"absolute",left:0,right:0,top:0,height:N.height,borderWidth:1,borderStyle:"dashed",boxSizing:"border-box",borderColor:"theme-primary",borderRadius:8,backgroundColor:"theme-primary",opacity:.14,pointerEvents:"none",style:{transform:`translateY(${N.top}px)`,transition:N.reducedMotion?"none":"transform 180ms cubic-bezier(0.2, 0, 0, 1)"}}),e.document.blocks.map(($,F)=>{var X,G;return n.jsxs(h.Horizontal,{gap:8,alignItems:"flex-start",position:"relative",borderRadius:6,backgroundColor:w.selectedDocument?"theme-primary-100":e.activeId===$.id?"color-gray-50":void 0,_hover:{backgroundColor:"color-gray-50"},"data-editor-row":$.id,...y.block,opacity:(N==null?void 0:N.id)===$.id?0:((X=y.block)==null?void 0:X.opacity)??1,style:{...(G=y.block)==null?void 0:G.style,...N?{transform:`translateY(${H(F,N)}px)`,transition:N.reducedMotion?"none":"transform 180ms cubic-bezier(0.2, 0, 0, 1)"}:{}},children:[!f&&n.jsx(P.DropdownMenu,{views:{menu:{borderWidth:1,borderStyle:"solid",borderColor:"color-gray-300",backgroundColor:D==="dark"?"color-gray-900":"color-white",boxShadow:"0 6px 20px rgba(0, 0, 0, 0.18)"},item:{as:"button",type:"button",width:"100%",textAlign:"left",borderWidth:0,_focusVisible:{outline:"2px solid",outlineColor:"theme-primary"}}},trigger:n.jsx(P.Button,{type:"button",size:"sm",variant:"ghost",isIcon:!0,minWidth:36,width:36,minHeight:36,padding:4,title:`${e.labels.drag} · ${e.labels.blocks}`,style:{userSelect:"none"},draggable:!e.locked,isDisabled:e.locked,cursor:N?"grabbing":"grab","aria-label":e.labels.drag,onDragStart:U=>{var oe;if(e.locked){U.preventDefault();return}R.current=$.id,B.current.forEach(ue=>ue.cancel()),B.current=[];const Q=U.currentTarget.closest("[data-editor-row]");if(Q){const ue=Q.getBoundingClientRect(),ae=Y(),he=ae[F+1],xe=ae[F-1],qe=he?he.offsetTop-Q.offsetTop-Q.offsetHeight:xe?Q.offsetTop-xe.offsetTop-xe.offsetHeight:0,Xe={id:$.id,from:F,to:F,height:Q.offsetHeight,extent:Q.offsetHeight+Math.max(0,qe),top:Q.offsetTop,reducedMotion:!!((oe=window.matchMedia)!=null&&oe.call(window,"(prefers-reduced-motion: reduce)").matches)};O.current=Xe,W.current=window.requestAnimationFrame(()=>{W.current=null,O.current&&_(O.current)});const pe=Q.cloneNode(!0);let Ve="Canvas";for(let be=Q;be;be=be.parentElement){const Te=window.getComputedStyle(be).backgroundColor;if(Te!=="transparent"&&Te!=="rgba(0, 0, 0, 0)"){Ve=Te;break}}Object.assign(pe.style,{position:"fixed",left:"-10000px",top:"0",width:`${ue.width}px`,padding:"8px",boxSizing:"border-box",borderRadius:"8px",backgroundColor:Ve,boxShadow:"0 8px 24px rgba(0,0,0,0.18)",opacity:"1"}),pe.dataset.editorDragPreview="true",pe.setAttribute("aria-hidden","true"),pe.inert=!0,pe.querySelectorAll("[contenteditable]").forEach(be=>{be.style.outline="none"}),Q.ownerDocument.body.appendChild(pe),V.current=pe,U.dataTransfer.setDragImage(pe,U.clientX-ue.left+8,U.clientY-ue.top+8)}U.dataTransfer.setData("application/x-app-studio-block",$.id),U.dataTransfer.effectAllowed="move"},onDragEnd:q,children:n.jsx(E.DragHandleIcon,{widthHeight:18,strokeWidth:2})}),items:[{id:"transform",label:e.labels.blocks,disabled:e.locked,onClick:()=>e.setCommandId($.id)},...["below","duplicate","up","down","delete"].map(U=>({id:U,label:e.labels[U],disabled:e.locked||U==="up"&&F===0||U==="down"&&F===e.document.blocks.length-1,onClick:()=>e.action($.id,U)}))]},`${e.restoreVersion}-${e.commandId??""}`),n.jsx(Rr,{block:$,state:e,label:$.kind==="codeBlock"?e.labels.codeBlock:s,views:y})]},$.id)})]}),(e.linkOpen||e.media||e.ai?I:!e.source&&d)&&!e.locked&&n.jsx(ht.Portal,{children:n.jsx(Dr,{rect:e.linkOpen||e.media||e.ai?I:d,state:e,props:t,preserve:Z})}),n.jsx(P.Command,{open:!!e.commandId&&!e.locked,onOpenChange:$=>{$||e.closeCommand()},placeholder:e.labels.blocks,commands:gr.map($=>({id:$,name:e.labels[$],onSelect:()=>{e.commandId&&e.transform(e.commandId,$)}}))}),u]})}const Ar=e=>{const t=kr(e);return n.jsx(Mr,{...e,state:t})};function Lr(){const[e,t]=C.useState(()=>{var r;return typeof window<"u"&&!!((r=window.matchMedia)!=null&&r.call(window,"(prefers-reduced-motion: reduce)").matches)});return C.useEffect(()=>{var o,a;const r=(o=window.matchMedia)==null?void 0:o.call(window,"(prefers-reduced-motion: reduce)");if(!r)return;const g=()=>t(r.matches);return g(),(a=r.addEventListener)==null||a.call(r,"change",g),()=>{var c;return(c=r.removeEventListener)==null?void 0:c.call(r,"change",g)}},[]),e}const He=typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"grapheme"}):void 0;function Tt(e,{typing:t=!1,isStreaming:r=!1,onTypingComplete:g}={}){const o=Lr(),a=!!t&&!o&&!!He,c=typeof t=="object"?t:void 0,b=Math.max(1,Math.floor(Number.isFinite(c==null?void 0:c.charsPerTick)?c.charsPerTick:3)),i=Math.max(1,Number.isFinite(c==null?void 0:c.intervalMs)?c.intervalMs:16),[s,l]=C.useState(()=>({value:e,length:a?0:e.length})),f=C.useRef(e),x=C.useRef(null),y=C.useRef(g);y.current=g;const u=C.useMemo(()=>[0,...Array.from((He==null?void 0:He.segment(e))??[],p=>p.index+p.segment.length)],[e]),j=Math.max(0,u.length-(r?2:1)),S=u[j],D=e.startsWith(s.value)?Math.min(s.length,S):0;let d=0;for(;d+1<u.length&&u[d+1]<=D;)d++;const m=a?u[d]:e.length,I=e.slice(0,m),k=C.useRef({value:e,ends:u,index:d,targetIndex:j});k.current={value:e,ends:u,index:d,targetIndex:j};const M=a&&m<S;return C.useEffect(()=>{e.startsWith(f.current)||(x.current=null),f.current=e},[e]),C.useEffect(()=>{r&&(x.current=null)},[r]),C.useEffect(()=>{a||l(p=>p.value===e&&p.length===e.length?p:{value:e,length:e.length})},[a,e]),C.useEffect(()=>{if(!M)return;const p=setInterval(()=>{const w=k.current;l({value:w.value,length:w.ends[Math.min(w.index+b,w.targetIndex)]})},i);return()=>clearInterval(p)},[M,b,i]),C.useEffect(()=>{var p;t&&e&&!r&&m===e.length&&x.current!==e&&(x.current=e,(p=y.current)==null||p.call(y))},[e,t,r,m]),{displayedText:I,isTyping:a&&(m<e.length||r)}}function $r({value:e,label:t,onLinkPress:r,renderLink:g,allowImages:o=!0,allowVideos:a=!0,renderVideo:c,typing:b,isStreaming:i,onTypingComplete:s,labels:l,views:f={},native:x=!1,codeFontFamily:y="monospace",...u}){const{displayedText:j,isTyping:S}=Tt(e,{typing:b,isStreaming:i,onTypingComplete:s}),D=C.useRef([]),d=C.useMemo(()=>{const m=_e(j,D.current,void 0,{display:!0});return D.current=m.blocks,m},[j]);return n.jsxs(h.Vertical,{gap:12,minWidth:0,...x?{accessibilityLabel:t}:{role:t?"region":void 0,"aria-label":t},...u,...f.container,children:[d.sourceMode?n.jsxs(n.Fragment,{children:[n.jsx(h.Text,{...f.notice,children:(l==null?void 0:l.sourceFallback)??"This Markdown contains unsupported syntax. Its source is shown as plain text."}),n.jsx(h.Text,{fontFamily:y,...x?{selectable:!0}:{style:{whiteSpace:"pre-wrap",overflowWrap:"anywhere"}},...f.source,children:j})]}):d.blocks.filter(m=>m.raw).map(m=>n.jsx(h.View,{minWidth:0,...f.block,children:n.jsx(It,{block:m,native:x,codeFontFamily:y,isDisplay:!0,onLinkPress:r,renderLink:g,allowImages:o,allowVideos:a,renderVideo:c})},m.id)),S&&n.jsx(h.View,{as:"span",width:2,height:16,backgroundColor:"color-gray-700",...x?{accessibilityElementsHidden:!0}:{"aria-hidden":!0},animate:h.Animation.flash({duration:"0.8s",iterationCount:"infinite"})})]})}const Vr=e=>n.jsx($r,{...e}),Br=e=>{const t=K.useIconPickerState(e);return n.jsx(K.IconPickerView,{...t,...e})},Pr=Br;function Fr({onSelect:e,onCancel:t,active:r}){const[g,o]=C.useState(null);C.useRef(null);const a=C.useCallback(i=>{var y;if(!r)return;const s=document.elementFromPoint(i.clientX,i.clientY);if(!s||s===document.body||s.closest('[data-chatwidget-ignore="true"]')||s.closest("#chatwidget-overlay")){o(null);return}const l=s.getBoundingClientRect();let f=s.tagName.toLowerCase();if(s.id)f+=`#${s.id}`;else if(s.className&&typeof s.className=="string"){const u=s.className.split(" ")[0];u&&(f+=`.${u}`)}const x=(y=s.innerText)==null?void 0:y.slice(0,20);x&&(f+=` ("${x}...")`),o({id:s.id||`el-${Date.now()}`,name:f,tagName:s.tagName.toLowerCase(),rect:l})},[r]),c=C.useCallback(i=>{!r||i.target.closest('[data-chatwidget-ignore="true"]')||(i.preventDefault(),i.stopPropagation(),g&&e(g))},[r,g,e]),b=C.useCallback(i=>{r&&i.key==="Escape"&&t()},[r,t]);return C.useEffect(()=>{if(!(typeof document>"u"))return r?(document.addEventListener("mousemove",a),document.addEventListener("click",c,!0),document.addEventListener("keydown",b),document.body.style.cursor="crosshair"):(o(null),document.removeEventListener("mousemove",a),document.removeEventListener("click",c,!0),document.removeEventListener("keydown",b),document.body.style.cursor=""),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("click",c,!0),document.removeEventListener("keydown",b),document.body.style.cursor=""}},[r,a,c,b]),{highlightedElement:g}}function Wr({element:e}){return e?n.jsx("div",{id:"chatwidget-overlay",style:{position:"fixed",top:e.rect.top,left:e.rect.left,width:e.rect.width,height:e.rect.height,border:"2px solid #1D4ED8",backgroundColor:"rgba(29, 78, 216, 0.08)",pointerEvents:"none",zIndex:99999,transition:"top 0.1s ease-out, left 0.1s ease-out, width 0.1s ease-out, height 0.1s ease-out",borderRadius:"8px"},children:n.jsx("div",{style:{position:"absolute",top:"-24px",left:"0",backgroundColor:"#1D4ED8",color:"white",padding:"2px 8px",borderRadius:"9999px",fontSize:"12px",fontWeight:"bold",whiteSpace:"nowrap"},children:e.name})}):null}const Or=({initialMessages:e=[],onSendMessage:t,bubbleSize:r="md"})=>{const[g,o]=C.useState(!1),[a,c]=C.useState(!1),[b,i]=C.useState(e),[s,l]=C.useState([]),{highlightedElement:f}=Fr({active:a,onSelect:S=>{l(D=>[...D,S]),c(!1),o(!0)},onCancel:()=>{c(!1),o(!0)}}),x=()=>o(!g),y=()=>{c(!0),o(!1)},u=S=>{l(D=>D.filter(d=>d.id!==S))},j=S=>{const D={id:Date.now().toString(),role:"user",content:S,timestamp:new Date,contextElements:[...s]};i(d=>[...d,D]),t==null||t(S,s),l([]),setTimeout(()=>{var k;const d=Math.random()>.7,m=Math.random()>.4,I={id:(Date.now()+1).toString(),role:"assistant",timestamp:new Date,content:d?"I will highlight the selected element.":`I received your message regarding: ${((k=D.contextElements)==null?void 0:k.map(M=>M.name).join(", "))||"general context"}. How can I assist you further?`,messageType:d?"tool":"text",reasoning:m?"Analyzing the user input and context... The user seems to be asking about specific elements. I should tailor my response to the selected context.":void 0};i(M=>[...M,I]),d&&setTimeout(()=>{i(M=>[...M,{id:(Date.now()+2).toString(),role:"assistant",messageType:"system",content:'Tool "highlightElement" executed successfully.',timestamp:new Date}])},800)},1e3)};return n.jsxs(h.View,{position:"fixed",bottom:24,right:24,zIndex:9999,children:[n.jsx(Wr,{element:f}),a&&n.jsx(h.View,{position:"fixed",top:24,left:"50%",transform:"translateX(-50%)",backgroundColor:"rgba(0,0,0,0.8)",color:"white",padding:"8px 16px",borderRadius:"24px",zIndex:1e4,boxShadow:"0 4px 6px rgba(0,0,0,0.1)",children:n.jsx(h.Text,{fontWeight:"600",fontSize:"14px",children:"Click an element to select it. Press ESC to cancel."})}),g&&n.jsxs(h.View,{position:"absolute",bottom:60,right:0,width:"400px",height:"600px",marginBottom:"16px",backgroundColor:"rgba(255, 255, 255, 0.8)",backdropFilter:"blur(20px)",borderRadius:"24px",border:"1px solid rgba(255, 255, 255, 0.4)",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",overflow:"hidden",animation:"slideUp 0.3s ease-out",style:{animation:"fadeIn 0.2s ease-out",transformOrigin:"bottom right"},children:[n.jsxs(h.View,{padding:"16px",borderBottom:"1px solid rgba(0,0,0,0.05)",display:"flex",justifyContent:"space-between",alignItems:"center",children:[n.jsx(h.Text,{fontWeight:"bold",color:"color-gray-800",children:"ChatWidget Assistant"}),n.jsx(h.View,{as:"button",onClick:()=>o(!1),cursor:"pointer",padding:"4px",borderRadius:"50%",border:"none",backgroundColor:"transparent",_hover:{backgroundColor:"rgba(0,0,0,0.05)"},children:n.jsx(E.CloseIcon,{widthHeight:16,color:"color-gray-500"})})]}),n.jsx(P.ChatWidget,{messages:b,onSubmit:j,size:r,variant:"minimal",enableContextPicker:!0,selectedContextElements:s,onContextPickerClick:y,onRemoveContextElement:u,styles:{container:{height:"calc(100% - 60px)",backgroundColor:"transparent"},inputContainer:{backgroundColor:"white",margin:"0 16px 16px 16px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"}}})]}),!a&&n.jsx(h.View,{as:"button",onClick:x,width:"56px",height:"56px",borderRadius:"50%",backgroundColor:"theme-primary",border:"none",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"transform 0.2s ease",_hover:{transform:"scale(1.05)"},_active:{transform:"scale(0.95)"},"data-chatwidget-ignore":"true",children:g?n.jsx(E.CloseIcon,{widthHeight:24,color:"white"}):n.jsx(E.PanelIcon,{widthHeight:24,color:"white"})})]})},Hr={info:{container:{backgroundColor:"color-white",border:"rgba(191, 219, 254, 0.95)"},icon:{color:"theme-primary",name:"InformationIcon"},content:{color:"color-gray-900"},close:{color:"color-gray-500",name:"CloseIcon"}},success:{container:{backgroundColor:"#F0FDF4",border:"#BBF7D0"},icon:{color:"#16A34A",name:"SuccessIcon"},content:{color:"#14532D"},close:{color:"#15803D",name:"CloseIcon"}},error:{container:{backgroundColor:"#FEF2F2",border:"#FECACA"},icon:{color:"#DC2626",name:"ErrorIcon"},content:{color:"#7F1D1D"},close:{color:"#B91C1C",name:"CloseIcon"}},warning:{container:{backgroundColor:"#FFF7ED",border:"#FED7AA"},icon:{color:"#EA580C",name:"WarningIcon"},content:{color:"#9A3412"},close:{color:"#C2410C",name:"CloseIcon"}}},Et=({variant:e,hide:t,title:r,subtitle:g,theme:o,action:a,actionText:c,showIcon:b=!1,isClosable:i=!1,timeout:s=3e3,views:l})=>{var D,d;C.useEffect(()=>{if(s&&!i){const m=setTimeout(()=>{t()},s);return()=>{clearTimeout(m)}}},[]);const f=o??Hr,x=!!(a&&c),y={borderWidth:1,borderStyle:"solid",borderRadius:12,borderColor:`${f[e].container.border}`,boxShadow:"0 8px 24px rgba(15, 23, 42, 0.06)"},u={info:"#3b82f6",success:"#4ade80",warning:"#f97316",error:"#ef4444"}[e],j={info:n.jsx(E.InfoIcon,{widthHeight:24,color:u,...l==null?void 0:l.icon}),success:n.jsx(E.SuccessIcon,{widthHeight:24,color:u,...l==null?void 0:l.icon}),warning:n.jsx(E.WarningIcon,{widthHeight:24,color:u,...l==null?void 0:l.icon}),error:n.jsx(E.ErrorIcon,{widthHeight:24,color:u,...l==null?void 0:l.icon})}[e],S=b&&j;return n.jsxs(h.Horizontal,{role:"messageContent",gap:12,width:"100%",maxWidth:520,flexWrap:"nowrap",position:"relative",alignItems:"flex-start",padding:"12px 14px",color:`${f[e].content.color}`,backgroundColor:`${f[e].container.backgroundColor}`,onClick:i?()=>{}:()=>{t()},...y,transition:"background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease",...l==null?void 0:l.container,children:[S&&j,n.jsxs(h.Vertical,{gap:4,width:"100%",children:[n.jsx(h.Text,{size:"md",weight:"semiBold",...l==null?void 0:l.title,children:r}),g&&n.jsx(h.Text,{size:"sm",lineHeight:"20px",color:f[e].content.color,...l==null?void 0:l.subtitle,children:g})]}),x&&n.jsx(h.View,{as:"button",type:"button",onClick:a,backgroundColor:"color-white",borderWidth:"1px",borderStyle:"solid",borderColor:f[e].container.border,borderRadius:"9999px",padding:"6px 12px",cursor:"pointer",transition:"background-color 0.2s ease, border-color 0.2s ease",...l==null?void 0:l.actionText,children:n.jsx(h.Text,{whiteSpace:"nowrap",size:"sm",weight:"semiBold",color:f[e].content.color,children:c})}),i&&n.jsx(h.View,{position:"absolute",zIndex:1e4,right:8,top:8,onClick:()=>{t()},cursor:"pointer",padding:"4px",borderRadius:"9999px",transition:"background-color 0.2s ease",...(D=l==null?void 0:l.closingIcon)==null?void 0:D.container,children:n.jsx(E.CloseIcon,{widthHeight:16,color:f[e].close.color,...(d=l==null?void 0:l.closingIcon)==null?void 0:d.icon})})]})},zr=({container:e,theme:t,position:r="topRight"})=>{const{visible:g,title:o,variant:a,subtitle:c,isClosable:b,views:i,action:s,actionText:l,showIcon:f,timeout:x}=ce.useMessageStore(),y={topLeft:{top:6,left:8},topRight:{top:6,right:8},bottomLeft:{bottom:8,left:6},bottomRight:{bottom:8,right:6}}[r],u=()=>n.jsx(Et,{variant:a,subtitle:c,show:g,title:o,theme:t,isClosable:b,views:i,action:s,actionText:l,showIcon:f,timeout:x,hide:()=>ce.hideMessage()}),j=e?C.cloneElement(e,{},u()):n.jsx(h.View,{position:"absolute",zIndex:1e4,...y,children:u()});return g?j:null};function Nr(e){const t=Math.floor(e/60),r=e%60;return`${t}:${r.toString().padStart(2,"0")}`}function Ur({onAudio:e,recording:t,paused:r,audioBlob:g,analyserNode:o,duration:a,error:c,startRecording:b,stopRecording:i,pauseRecording:s,resumeRecording:l,resetRecording:f,handleFileChange:x,...y}){const[u,j]=C.useState(null);C.useEffect(()=>{if(g){const d=URL.createObjectURL(g);return j({url:d,label:`recording-${Date.now()}.webm`}),()=>{URL.revokeObjectURL(d)}}return()=>{}},[g]);const S=()=>{u!=null&&u.url&&URL.revokeObjectURL(u.url),j(null),f()},D=d=>{e(d),u!=null&&u.url&&URL.revokeObjectURL(u.url),j({url:URL.createObjectURL(d),label:d.name})};return n.jsxs(h.Vertical,{gap:"10px",width:"100%",...y,children:[n.jsxs(h.Horizontal,{gap:12,alignItems:"center",padding:"12px 14px",border:"1px solid color-gray-200",borderRadius:"12px",backgroundColor:"color-white",children:[n.jsx(ce.Uploader,{accept:"audio/*",icon:n.jsx(E.AttachmentIcon,{widthHeight:16}),maxSize:100*1024*1024,onFileSelect:D,fileType:"file",multiple:!1,renderError:({errorMessage:d})=>null,views:{container:{width:"36px",height:"36px",cursor:"pointer",border:"1px solid color-gray-200",borderRadius:"10px",backgroundColor:"color-white",transition:"background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease",_hover:{backgroundColor:"color-gray-50",borderColor:"color-gray-300"}}},containerProps:{display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"10px",width:"36px",height:"36px"},validateFile:d=>d.size>100*1024*1024?"File size exceeds 100MB limit":d.type.startsWith("audio/")?null:"Only audio files are allowed"}),n.jsx(h.View,{as:"button",type:"button",onClick:t?i:b,width:"36px",height:"36px",minWidth:"36px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"theme-primary",color:"color-white",borderRadius:"999px",border:"0",cursor:"pointer",transition:"background-color 0.2s ease, opacity 0.2s ease",_hover:{opacity:.92},children:t?n.jsx(E.StopIcon,{widthHeight:14,color:"color-white",filled:!1}):n.jsx(E.MicrophoneIcon,{widthHeight:18,color:"color-white",filled:!1})}),n.jsx(h.View,{flex:1,minWidth:120,children:n.jsx(ce.AudioWaveform,{analyserNode:t?o:null,isPaused:!t||r})}),n.jsx(h.Text,{fontSize:"12px",lineHeight:"16px",color:"color-gray-500",whiteSpace:"nowrap",children:Nr(a)})]}),u&&!t&&n.jsxs(h.Vertical,{gap:"8px",padding:"12px 14px",border:"1px solid color-gray-200",borderRadius:"12px",backgroundColor:"color-white",children:[n.jsxs(h.Horizontal,{alignItems:"center",justifyContent:"space-between",gap:8,children:[n.jsx(h.Text,{fontSize:"12px",lineHeight:"16px",color:"color-gray-500",children:u.label}),n.jsx(h.View,{as:"button",type:"button",onClick:S,width:"24px",height:"24px",display:"flex",alignItems:"center",justifyContent:"center",border:"0",backgroundColor:"transparent",color:"color-gray-500",cursor:"pointer",children:n.jsx(E.CloseIcon,{widthHeight:14,color:"currentColor"})})]}),n.jsx(h.View,{as:"audio",controls:!0,src:u.url,width:"100%"})]}),c&&n.jsx(h.Text,{fontSize:"11px",lineHeight:"16px",color:"theme-error",children:c})]})}function _r(e){const{onAudio:t}=e,{recording:r,paused:g,audioBlob:o,analyserNode:a,duration:c,error:b,startRecording:i,stopRecording:s,pauseRecording:l,resumeRecording:f,resetRecording:x}=ce.useAudioRecording();return C.useEffect(()=>{if(o&&t){const u=new File([o],"recording.webm",{type:o.type||"audio/webm;codecs=opus"});t(u)}},[o,t]),{recording:r,paused:g,audioBlob:o,analyserNode:a,duration:c,error:b,startRecording:i,stopRecording:s,pauseRecording:l,resumeRecording:f,resetRecording:x,handleFileChange:u=>{var S;const j=(S=u.target.files)==null?void 0:S[0];j&&t&&t(j)}}}function qr(e){const t=_r(e);return n.jsx(Ur,{...e,...t})}const Xr=e=>{const t=K.useDatePickerState(e);return n.jsx(K.DatePickerView,{...t,...e})},Yr=Xr,vr=({logo:e,logoSrc:t,loader:r,showLoader:g=!0,duration:o=600,isLoaded:a,onHidden:c,backgroundColor:b="color-white",children:i,...s})=>{const l=P.useSplashStore(m=>m.loaded),f=a!==void 0?a:l,[x,y]=C.useState(!0),[u,j]=C.useState(!1);if(C.useEffect(()=>{if(!f||u)return;j(!0);const m=setTimeout(()=>{y(!1),c==null||c()},o);return()=>clearTimeout(m)},[f,u,o,c]),!x)return null;const S=h.isBrowser()?"fixed":"absolute",D=u?h.Animation.fadeOut({duration:`${o}ms`}):void 0,d=e??(t?n.jsx(h.Image,{src:t,width:120,height:120,alt:"logo"}):null);return n.jsxs(h.Center,{position:S,top:0,left:0,right:0,bottom:0,zIndex:9999,backgroundColor:b,animate:D,...s,children:[n.jsxs(h.Vertical,{alignItems:"center",gap:24,children:[d,g&&(r??n.jsx($e.Loader,{}))]}),i]})};exports.Accordion=P.Accordion;exports.AspectRatio=P.AspectRatio;exports.Background=P.Background;exports.Badge=P.Badge;exports.Button=P.Button;exports.CHART_COLORS=P.CHART_COLORS;exports.Carousel=P.Carousel;exports.ChatInput=P.ChatInput;exports.ChatWidget=P.ChatWidget;exports.ChatWidgetComponent=P.ChatWidgetComponent;exports.ColorPicker=P.ColorPicker;exports.Command=P.Command;exports.ContextMenu=P.ContextMenu;exports.DEFAULT_CHART_COLORS=P.DEFAULT_CHART_COLORS;exports.DesignSystem=P.DesignSystem;exports.DesignSystemProvider=P.DesignSystemProvider;exports.Divider=P.Divider;exports.Drawer=P.Drawer;exports.DropdownMenu=P.DropdownMenu;exports.Gradient=P.Gradient;exports.Menubar=P.Menubar;exports.NavigationMenu=P.NavigationMenu;exports.OTPInput=P.OTPInput;exports.Pagination=P.Pagination;exports.ProgressBar=P.ProgressBar;exports.Radio=P.Radio;exports.Resizable=P.Resizable;exports.Separator=P.Separator;exports.ShareButton=P.ShareButton;exports.Sidebar=P.Sidebar;exports.Slider=P.Slider;exports.StatusIndicator=P.StatusIndicator;exports.Table=P.Table;exports.TextArea=P.TextArea;exports.Title=P.Title;exports.Toast=P.Toast;exports.ToggleGroup=P.ToggleGroup;exports.Tooltip=P.Tooltip;exports.hideDrawer=P.hideDrawer;exports.setSplashLoaded=P.setSplashLoaded;exports.setSplashStarted=P.setSplashStarted;exports.showDrawer=P.showDrawer;exports.showToast=P.showToast;exports.useDrawerStore=P.useDrawerStore;exports.useSplashStore=P.useSplashStore;exports.useToast=P.useToast;exports.ArrowIcon=E.ArrowIcon;exports.AttachmentIcon=E.AttachmentIcon;exports.AudioIcon=E.AudioIcon;exports.BackIcon=E.BackIcon;exports.BatteryIcon=E.BatteryIcon;exports.BluetoothIcon=E.BluetoothIcon;exports.BoldArrowIcon=E.BoldArrowIcon;exports.BookmarkIcon=E.BookmarkIcon;exports.CalendarIcon=E.CalendarIcon;exports.CameraIcon=E.CameraIcon;exports.ChartIcon=E.ChartIcon;exports.CheckIcon=E.CheckIcon;exports.ChevronIcon=E.ChevronIcon;exports.ClockIcon=E.ClockIcon;exports.CloseEyeIcon=E.CloseEyeIcon;exports.CloseIcon=E.CloseIcon;exports.CloudIcon=E.CloudIcon;exports.CopyIcon=E.CopyIcon;exports.CreditCardIcon=E.CreditCardIcon;exports.CropIcon=E.CropIcon;exports.DeleteIcon=E.DeleteIcon;exports.DocumentIcon=E.DocumentIcon;exports.DownloadIcon=E.DownloadIcon;exports.DragHandleIcon=E.DragHandleIcon;exports.DragHandleLinesIcon=E.DragHandleLinesIcon;exports.DustBinIcon=E.DustBinIcon;exports.EditIcon=E.EditIcon;exports.ErrorIcon=E.ErrorIcon;exports.ExternalLinkIcon=E.ExternalLinkIcon;exports.FacebookIcon=E.FacebookIcon;exports.FileIcon=E.FileIcon;exports.FilterIcon=E.FilterIcon;exports.FolderIcon=E.FolderIcon;exports.GiftIcon=E.GiftIcon;exports.HeartIcon=E.HeartIcon;exports.HelpIcon=E.HelpIcon;exports.HomeIcon=E.HomeIcon;exports.Icon=E.Icon;exports.ImageIcon=E.ImageIcon;exports.InfoIcon=E.InfoIcon;exports.InstagramIcon=E.InstagramIcon;exports.LayoutIcon=E.LayoutIcon;exports.LikeIcon=E.LikeIcon;exports.LinkIcon=E.LinkIcon;exports.LinkedinIcon=E.LinkedinIcon;exports.LoadingSpinnerIcon=E.LoadingSpinnerIcon;exports.LockIcon=E.LockIcon;exports.LogoutIcon=E.LogoutIcon;exports.MagicWandIcon=E.MagicWandIcon;exports.MapPinIcon=E.MapPinIcon;exports.MenuIcon=E.MenuIcon;exports.MicrophoneIcon=E.MicrophoneIcon;exports.MinusIcon=E.MinusIcon;exports.MoonIcon=E.MoonIcon;exports.MoreIcon=E.MoreIcon;exports.MousePointerIcon=E.MousePointerIcon;exports.NotificationIcon=E.NotificationIcon;exports.OpenEyeIcon=E.OpenEyeIcon;exports.PanelIcon=E.PanelIcon;exports.PauseIcon=E.PauseIcon;exports.PlayIcon=E.PlayIcon;exports.PlusIcon=E.PlusIcon;exports.PowerOffIcon=E.PowerOffIcon;exports.PrintIcon=E.PrintIcon;exports.ProfileIcon=E.ProfileIcon;exports.RefreshIcon=E.RefreshIcon;exports.RotateIcon=E.RotateIcon;exports.SaveIcon=E.SaveIcon;exports.SearchIcon=E.SearchIcon;exports.SendIcon=E.SendIcon;exports.SettingsIcon=E.SettingsIcon;exports.ShapeIcon=E.ShapeIcon;exports.ShareIcon=E.ShareIcon;exports.ShieldIcon=E.ShieldIcon;exports.SliderIcon=E.SliderIcon;exports.SpinnerIcon=E.SpinnerIcon;exports.StarIcon=E.StarIcon;exports.StopIcon=E.StopIcon;exports.SuccessIcon=E.SuccessIcon;exports.TextIcon=E.TextIcon;exports.ThreadsIcon=E.ThreadsIcon;exports.TickIcon=E.TickIcon;exports.TrashIcon=E.TrashIcon;exports.TwitchIcon=E.TwitchIcon;exports.TwitterIcon=E.TwitterIcon;exports.UnLikeIcon=E.UnLikeIcon;exports.UnlockIcon=E.UnlockIcon;exports.UploadIcon=E.UploadIcon;exports.UserIcon=E.UserIcon;exports.VideoIcon=E.VideoIcon;exports.WarningIcon=E.WarningIcon;exports.WifiIcon=E.WifiIcon;exports.XIcon=E.XIcon;exports.YoutubeIcon=E.YoutubeIcon;exports.ZapIcon=E.ZapIcon;exports.ZoomInIcon=E.ZoomInIcon;exports.ZoomOutIcon=E.ZoomOutIcon;exports.Alert=Nt.Alert;exports.AudioWaveform=ce.AudioWaveform;exports.DefaultEmojiData=ce.DefaultEmojiData;exports.FormikForm=ce.FormikForm;exports.FormikUploader=ce.FormikUploader;exports.HoverCard=ce.HoverCard;exports.QuickReactionEmojis=ce.QuickReactionEmojis;exports.Toggle=ce.Toggle;exports.Uploader=ce.Uploader;exports.hideMessage=ce.hideMessage;exports.showMessage=ce.showMessage;exports.useMessageStore=ce.useMessageStore;exports.Avatar=Ut.Avatar;exports.Card=_t.Card;exports.Loader=$e.Loader;exports.Select=qt.Select;exports.Switch=Xt.Switch;exports.AttachmentPreview=K.AttachmentPreview;exports.FormikChatInput=K.FormikChatInput;exports.FormikCheckbox=K.FormikCheckbox;exports.FormikColorInput=K.FormikColorInput;exports.FormikComboBox=K.FormikComboBox;exports.FormikCountryPicker=K.FormikCountryPicker;exports.FormikDatePicker=K.FormikDatePicker;exports.FormikEmojiPicker=K.FormikEmojiPicker;exports.FormikIconPicker=K.FormikIconPicker;exports.FormikOTPInput=K.FormikOTPInput;exports.FormikPassword=K.FormikPassword;exports.FormikRadio=K.FormikRadio;exports.FormikSelect=K.FormikSelect;exports.FormikSelector=K.FormikSelector;exports.FormikSlider=K.FormikSlider;exports.FormikSwitch=K.FormikSwitch;exports.FormikTagInput=K.FormikTagInput;exports.FormikTextArea=K.FormikTextArea;exports.FormikTextField=K.FormikTextField;exports.FormikToggle=K.FormikToggle;exports.FormikToggleGroup=K.FormikToggleGroup;exports.defaultEmojiPickerLabels=K.defaultEmojiPickerLabels;exports.TextField=Me.TextField;exports.Checkbox=Yt.Checkbox;exports.Link=Ye.Link;exports.Tabs=vt.Tabs;exports.deepMerge=ge.deepMerge;exports.getDesignSystemComponentProps=ge.getDesignSystemComponentProps;exports.mergeComponentDefaults=ge.mergeComponentDefaults;exports.mergeDesignSystemComponentProps=ge.mergeDesignSystemComponentProps;exports.mergeDesignSystemViews=ge.mergeDesignSystemViews;exports.normalizeDesignSystemComponentProps=ge.normalizeDesignSystemComponentProps;exports.useDesignSystem=ge.useDesignSystem;exports.useDesignSystemComponentLayers=ge.useDesignSystemComponentLayers;exports.useDesignSystemComponentProps=ge.useDesignSystemComponentProps;exports.useMergedDesignSystemComponentProps=ge.useMergedDesignSystemComponentProps;exports.defaultDesignSystemConfig=Qe.defaultDesignSystemConfig;exports.designSystemConfigList=Qe.designSystemConfigList;exports.designSystemConfigs=Qe.designSystemConfigs;exports.Modal=we.Modal;exports.ModalLayout=we.ModalLayout;exports.ModalRouter=we.ModalLayout;exports.hideModal=we.hideModal;exports.showModal=we.showModal;exports.useModalStore=we.useModalStore;exports.Router=Je.Router;exports.matchPath=Je.matchPath;exports.useHistory=Je.useHistory;exports.goBack=et.goBack;exports.navigate=et.navigate;exports.useRouterStore=et.useRouterStore;exports.ActionSheet=en;exports.AttachmentGroup=kt;exports.AudioInput=qr;exports.BlockEditor=Ar;exports.Chart=Cn;exports.ChatWidgetWidget=Or;exports.ColorInput=Pn;exports.ComboBox=Nn;exports.CookieConsent=Tn;exports.CountryPicker=Wn;exports.DataState=or;exports.DataStateDefaultLabels=mt;exports.DatePicker=Yr;exports.DragAndDrop=cr;exports.DragAndDropComponent=bt;exports.DropZone=ur;exports.EmojiPicker=yt;exports.FileImage=Dn;exports.FileSVG=En;exports.IconPicker=Pr;exports.KeyboardAvoidingView=ft;exports.Markdown=Vr;exports.MediaPreview=qn;exports.MessageLayout=zr;exports.MessageView=Et;exports.PageHeader=Zn;exports.PageLayout=Xn;exports.Password=Hn;exports.RadioGroup=Vn;exports.Selector=Mn;exports.SplashScreen=vr;exports.StatePanel=De;exports.TagInput=_n;exports.classifyDataStateError=xt;exports.defaultBlockEditorLabels=jt;exports.useMarkdownTyping=Tt;
|
|
58
58
|
//# sourceMappingURL=web.cjs.js.map
|