chaipro 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -0
- package/dist/IconPicker-I7VNLYZ4.js +5 -0
- package/dist/actions-DM00SIUk.d.cts +899 -0
- package/dist/actions-DM00SIUk.d.ts +899 -0
- package/dist/actions-registery-SEJTZE5Q.js +1 -0
- package/dist/active-in-another-tab-SONDAONP.js +1 -0
- package/dist/add-new-language-page-TI6DUYYX.js +1 -0
- package/dist/add-new-page-LBHXICXO.js +1 -0
- package/dist/ai-block-floating-prompt-input-ESY5GQLZ.js +1 -0
- package/dist/ai-panel-content-62I6FDQF.css +1 -0
- package/dist/ai-panel-content-UZJZ463W.js +1 -0
- package/dist/ai-panel-default-lang-2ZXZYQRT.js +6 -0
- package/dist/ai-panel-default-lang-ETFOFFEF.css +1 -0
- package/dist/ai-panel-for-image-LADQP6VY.js +1 -0
- package/dist/ai-panel-other-lang-WDLC3M2M.js +1 -0
- package/dist/ai-panel-page-chat-7ZISZWY4.js +4 -0
- package/dist/ai-panel-page-chat-N4YFJGAM.css +1 -0
- package/dist/ai-prompt-input-CPT5ETQ4.js +1 -0
- package/dist/ai-theme-generator-7PS4BX52.js +1 -0
- package/dist/ai-translation-prompt-3VE2ECGR.js +1 -0
- package/dist/blocks-CMvgDlxw.d.ts +72 -0
- package/dist/blocks-CP-Pngaz.d.cts +72 -0
- package/dist/build-config-CCERdThN.d.ts +80 -0
- package/dist/build-config-DrerOPd9.d.cts +80 -0
- package/dist/builder.cjs +243 -0
- package/dist/builder.css +1 -0
- package/dist/builder.d.cts +352 -0
- package/dist/builder.d.ts +352 -0
- package/dist/builder.js +1 -0
- package/dist/chaibuilder-instance-DNz3Q-dY.d.cts +579 -0
- package/dist/chaibuilder-instance-qroszVwI.d.ts +579 -0
- package/dist/change-password-modal-NJL7ZLTY.js +1 -0
- package/dist/chunk-2AFM6557.js +3 -0
- package/dist/chunk-2N4IJZOR.js +1 -0
- package/dist/chunk-2NYUIXUX.js +1 -0
- package/dist/chunk-2PJZUYIZ.js +1 -0
- package/dist/chunk-32HH35VD.js +1 -0
- package/dist/chunk-346H4FEX.js +1 -0
- package/dist/chunk-34HIOUTE.js +1 -0
- package/dist/chunk-374QEK4F.js +1 -0
- package/dist/chunk-3E72DJSP.js +1 -0
- package/dist/chunk-3IT7IIAV.js +1 -0
- package/dist/chunk-3UEPBBE4.js +11 -0
- package/dist/chunk-3XSKJBPH.js +1 -0
- package/dist/chunk-45ELAD2J.js +1 -0
- package/dist/chunk-4JBHWPMO.js +1 -0
- package/dist/chunk-4P25MV5E.js +1 -0
- package/dist/chunk-4PQNBY3V.js +1 -0
- package/dist/chunk-4VNLL2IA.js +1 -0
- package/dist/chunk-55SU3QPU.js +1 -0
- package/dist/chunk-5ZC65NB6.js +1 -0
- package/dist/chunk-6M7V7BOM.js +1 -0
- package/dist/chunk-6TXCHU4K.js +1 -0
- package/dist/chunk-777N6WHB.js +1 -0
- package/dist/chunk-7C4EQOAR.js +12 -0
- package/dist/chunk-7EXZXKW2.js +1 -0
- package/dist/chunk-7QWMLDCG.js +1 -0
- package/dist/chunk-AOJE5WI3.js +1 -0
- package/dist/chunk-ATLMLDBS.js +1 -0
- package/dist/chunk-AVGF3YLU.js +17 -0
- package/dist/chunk-BQSLQHLD.js +1 -0
- package/dist/chunk-BWORNCTE.js +1 -0
- package/dist/chunk-BYGD5CDT.js +1 -0
- package/dist/chunk-CA5PVX24.js +1 -0
- package/dist/chunk-CFNOB42V.js +1 -0
- package/dist/chunk-CJP3BQH2.js +1 -0
- package/dist/chunk-CRJENCPR.js +1 -0
- package/dist/chunk-D5SKCKSB.js +1 -0
- package/dist/chunk-DZ72OHTD.js +1 -0
- package/dist/chunk-EPGOG22Q.js +0 -0
- package/dist/chunk-ERCY63ZW.js +1 -0
- package/dist/chunk-ESCX7KEH.js +1 -0
- package/dist/chunk-F2V4N3LT.js +156 -0
- package/dist/chunk-F7YMHPEA.js +1 -0
- package/dist/chunk-FERH2TPR.js +1 -0
- package/dist/chunk-FLSV2QGU.js +1 -0
- package/dist/chunk-FOKGOT6B.js +1 -0
- package/dist/chunk-GJOOCKUE.js +1 -0
- package/dist/chunk-HA7LF3RV.js +1 -0
- package/dist/chunk-HAKJOMCL.js +1 -0
- package/dist/chunk-HEKCKC7N.js +1 -0
- package/dist/chunk-HELRVKD2.js +3 -0
- package/dist/chunk-I7ODKVVX.js +1 -0
- package/dist/chunk-IAKCX2WB.js +1 -0
- package/dist/chunk-IB2C3TWH.js +1 -0
- package/dist/chunk-IH562KSP.js +1 -0
- package/dist/chunk-IP4JBQOX.js +1 -0
- package/dist/chunk-ITX7QWN6.js +1 -0
- package/dist/chunk-IUACZ3E6.js +6 -0
- package/dist/chunk-J7Q62EP7.js +1 -0
- package/dist/chunk-JBB5IJFA.js +1 -0
- package/dist/chunk-JPJRO4NU.js +1 -0
- package/dist/chunk-JUIS55JT.js +1 -0
- package/dist/chunk-JYBTQ3YX.js +5 -0
- package/dist/chunk-K5YWQY4U.js +1 -0
- package/dist/chunk-K6RHR4HT.js +1 -0
- package/dist/chunk-LNV5MRGV.js +1 -0
- package/dist/chunk-LRJREWRD.js +1 -0
- package/dist/chunk-LWYDGDPW.js +1 -0
- package/dist/chunk-MDMGXS5B.js +1 -0
- package/dist/chunk-MEROMQQX.js +1 -0
- package/dist/chunk-N7Z4RFFI.js +1 -0
- package/dist/chunk-NSQEQYEM.js +1 -0
- package/dist/chunk-OD3K76M6.js +1 -0
- package/dist/chunk-ODSL3KXG.js +1 -0
- package/dist/chunk-OJJDRACB.js +1 -0
- package/dist/chunk-ONSZ462E.js +1 -0
- package/dist/chunk-OQZ4EPOM.js +1 -0
- package/dist/chunk-OR7KKUYT.js +1 -0
- package/dist/chunk-OSGXFZTA.js +1 -0
- package/dist/chunk-PM3JNOZH.js +1 -0
- package/dist/chunk-PQHFT4TE.js +1 -0
- package/dist/chunk-QGVCH2NI.js +1 -0
- package/dist/chunk-QIGSSVEY.js +1 -0
- package/dist/chunk-R5ZTCDFD.js +1 -0
- package/dist/chunk-RBDZDQZR.js +1 -0
- package/dist/chunk-ROQRBSK6.js +1 -0
- package/dist/chunk-SSENH35Y.js +1 -0
- package/dist/chunk-SYPALJAE.js +1 -0
- package/dist/chunk-T2YYNX6Z.js +1 -0
- package/dist/chunk-T32TW3XV.js +1 -0
- package/dist/chunk-T56KQBE2.js +1 -0
- package/dist/chunk-TEL5ACJE.js +1 -0
- package/dist/chunk-TGJQC6VC.js +1 -0
- package/dist/chunk-TQ34DGOT.js +1 -0
- package/dist/chunk-TVF77C53.js +1 -0
- package/dist/chunk-UIDBBTCZ.js +3 -0
- package/dist/chunk-VKSRWZCO.js +1 -0
- package/dist/chunk-VL5WBPVV.js +1 -0
- package/dist/chunk-VUWHFLT7.js +22 -0
- package/dist/chunk-WEVKAJMV.js +1 -0
- package/dist/chunk-WHPIYGCY.js +1 -0
- package/dist/chunk-WNESLH23.js +1 -0
- package/dist/chunk-WOT6VMZA.js +1 -0
- package/dist/chunk-WSQ5SQBD.js +1 -0
- package/dist/chunk-XY4UJKHE.js +1 -0
- package/dist/chunk-Y2BHO7OO.js +1 -0
- package/dist/chunk-YDOQEFOK.js +1 -0
- package/dist/chunk-YEFMD4DS.js +1 -0
- package/dist/chunk-YQ5QQCRD.js +1 -0
- package/dist/chunk-YQPOFRXU.js +1 -0
- package/dist/chunk-YTPQSO7V.js +801 -0
- package/dist/chunk-ZAU65LBG.js +1 -0
- package/dist/chunk-ZRFCEMYU.js +1 -0
- package/dist/chunk-ZU2B5YT6.js +1 -0
- package/dist/chunk-ZXKKBKGV.js +1 -0
- package/dist/code-display-7346IUCO.js +1 -0
- package/dist/code-editor-UBGTTX2L.js +1 -0
- package/dist/components/ui/accordion.cjs +1 -0
- package/dist/components/ui/accordion.d.cts +9 -0
- package/dist/components/ui/accordion.d.ts +9 -0
- package/dist/components/ui/accordion.js +1 -0
- package/dist/components/ui/alert-dialog.cjs +1 -0
- package/dist/components/ui/alert-dialog.d.cts +23 -0
- package/dist/components/ui/alert-dialog.d.ts +23 -0
- package/dist/components/ui/alert-dialog.js +1 -0
- package/dist/components/ui/alert.cjs +1 -0
- package/dist/components/ui/alert.d.cts +11 -0
- package/dist/components/ui/alert.d.ts +11 -0
- package/dist/components/ui/alert.js +1 -0
- package/dist/components/ui/avatar.cjs +1 -0
- package/dist/components/ui/avatar.d.cts +8 -0
- package/dist/components/ui/avatar.d.ts +8 -0
- package/dist/components/ui/avatar.js +1 -0
- package/dist/components/ui/badge.cjs +1 -0
- package/dist/components/ui/badge.d.cts +13 -0
- package/dist/components/ui/badge.d.ts +13 -0
- package/dist/components/ui/badge.js +1 -0
- package/dist/components/ui/button.cjs +1 -0
- package/dist/components/ui/button.d.cts +15 -0
- package/dist/components/ui/button.d.ts +15 -0
- package/dist/components/ui/button.js +1 -0
- package/dist/components/ui/card.cjs +1 -0
- package/dist/components/ui/card.d.cts +10 -0
- package/dist/components/ui/card.d.ts +10 -0
- package/dist/components/ui/card.js +1 -0
- package/dist/components/ui/checkbox.cjs +1 -0
- package/dist/components/ui/checkbox.d.cts +6 -0
- package/dist/components/ui/checkbox.d.ts +6 -0
- package/dist/components/ui/checkbox.js +1 -0
- package/dist/components/ui/command.cjs +1 -0
- package/dist/components/ui/command.d.cts +83 -0
- package/dist/components/ui/command.d.ts +83 -0
- package/dist/components/ui/command.js +1 -0
- package/dist/components/ui/context-menu.cjs +1 -0
- package/dist/components/ui/context-menu.d.cts +30 -0
- package/dist/components/ui/context-menu.d.ts +30 -0
- package/dist/components/ui/context-menu.js +1 -0
- package/dist/components/ui/dialog.cjs +1 -0
- package/dist/components/ui/dialog.d.cts +22 -0
- package/dist/components/ui/dialog.d.ts +22 -0
- package/dist/components/ui/dialog.js +1 -0
- package/dist/components/ui/dropdown-menu.cjs +1 -0
- package/dist/components/ui/dropdown-menu.d.cts +30 -0
- package/dist/components/ui/dropdown-menu.d.ts +30 -0
- package/dist/components/ui/dropdown-menu.js +1 -0
- package/dist/components/ui/hover-card.cjs +1 -0
- package/dist/components/ui/hover-card.d.cts +8 -0
- package/dist/components/ui/hover-card.d.ts +8 -0
- package/dist/components/ui/hover-card.js +1 -0
- package/dist/components/ui/input.cjs +1 -0
- package/dist/components/ui/input.d.cts +5 -0
- package/dist/components/ui/input.d.ts +5 -0
- package/dist/components/ui/input.js +1 -0
- package/dist/components/ui/label.cjs +1 -0
- package/dist/components/ui/label.d.cts +8 -0
- package/dist/components/ui/label.d.ts +8 -0
- package/dist/components/ui/label.js +1 -0
- package/dist/components/ui/loader.cjs +1 -0
- package/dist/components/ui/loader.d.cts +12 -0
- package/dist/components/ui/loader.d.ts +12 -0
- package/dist/components/ui/loader.js +1 -0
- package/dist/components/ui/navigation-menu.cjs +1 -0
- package/dist/components/ui/navigation-menu.d.cts +15 -0
- package/dist/components/ui/navigation-menu.d.ts +15 -0
- package/dist/components/ui/navigation-menu.js +1 -0
- package/dist/components/ui/popover.cjs +1 -0
- package/dist/components/ui/popover.d.cts +9 -0
- package/dist/components/ui/popover.d.ts +9 -0
- package/dist/components/ui/popover.js +1 -0
- package/dist/components/ui/progress.cjs +1 -0
- package/dist/components/ui/progress.d.cts +8 -0
- package/dist/components/ui/progress.d.ts +8 -0
- package/dist/components/ui/progress.js +1 -0
- package/dist/components/ui/scroll-area.cjs +1 -0
- package/dist/components/ui/scroll-area.d.cts +7 -0
- package/dist/components/ui/scroll-area.d.ts +7 -0
- package/dist/components/ui/scroll-area.js +1 -0
- package/dist/components/ui/select.cjs +1 -0
- package/dist/components/ui/select.d.cts +15 -0
- package/dist/components/ui/select.d.ts +15 -0
- package/dist/components/ui/select.js +1 -0
- package/dist/components/ui/separator.cjs +1 -0
- package/dist/components/ui/separator.d.cts +6 -0
- package/dist/components/ui/separator.d.ts +6 -0
- package/dist/components/ui/separator.js +1 -0
- package/dist/components/ui/sheet.cjs +1 -0
- package/dist/components/ui/sheet.d.cts +29 -0
- package/dist/components/ui/sheet.d.ts +29 -0
- package/dist/components/ui/sheet.js +1 -0
- package/dist/components/ui/skeleton.cjs +1 -0
- package/dist/components/ui/skeleton.d.cts +5 -0
- package/dist/components/ui/skeleton.d.ts +5 -0
- package/dist/components/ui/skeleton.js +1 -0
- package/dist/components/ui/slider.cjs +1 -0
- package/dist/components/ui/slider.d.cts +6 -0
- package/dist/components/ui/slider.d.ts +6 -0
- package/dist/components/ui/slider.js +1 -0
- package/dist/components/ui/switch.cjs +1 -0
- package/dist/components/ui/switch.d.cts +9 -0
- package/dist/components/ui/switch.d.ts +9 -0
- package/dist/components/ui/switch.js +1 -0
- package/dist/components/ui/tabs.cjs +1 -0
- package/dist/components/ui/tabs.d.cts +9 -0
- package/dist/components/ui/tabs.d.ts +9 -0
- package/dist/components/ui/tabs.js +1 -0
- package/dist/components/ui/textarea.cjs +1 -0
- package/dist/components/ui/textarea.d.cts +5 -0
- package/dist/components/ui/textarea.d.ts +5 -0
- package/dist/components/ui/textarea.js +1 -0
- package/dist/components/ui/toggle.cjs +1 -0
- package/dist/components/ui/toggle.d.cts +15 -0
- package/dist/components/ui/toggle.d.ts +15 -0
- package/dist/components/ui/toggle.js +1 -0
- package/dist/components/ui/tooltip.cjs +1 -0
- package/dist/components/ui/tooltip.d.cts +9 -0
- package/dist/components/ui/tooltip.d.ts +9 -0
- package/dist/components/ui/tooltip.js +1 -0
- package/dist/config-registry-RSJCAKY5.js +1 -0
- package/dist/continue-editing-in-this-client-QBMOFRLL.js +1 -0
- package/dist/core-BNe4bA6z.d.cts +5455 -0
- package/dist/core-BNe4bA6z.d.ts +5455 -0
- package/dist/css-import-modal-NMFRQGCY.js +13 -0
- package/dist/db/better-sqlite3.cjs +1 -0
- package/dist/db/better-sqlite3.d.cts +16 -0
- package/dist/db/better-sqlite3.d.ts +16 -0
- package/dist/db/better-sqlite3.js +1 -0
- package/dist/db/d1.cjs +1 -0
- package/dist/db/d1.d.cts +17 -0
- package/dist/db/d1.d.ts +17 -0
- package/dist/db/d1.js +1 -0
- package/dist/db/libsql.cjs +1 -0
- package/dist/db/libsql.d.cts +23 -0
- package/dist/db/libsql.d.ts +23 -0
- package/dist/db/libsql.js +1 -0
- package/dist/db/node-pg.cjs +1 -0
- package/dist/db/node-pg.d.cts +21 -0
- package/dist/db/node-pg.d.ts +21 -0
- package/dist/db/node-pg.js +1 -0
- package/dist/db/postgres.cjs +1 -0
- package/dist/db/postgres.d.cts +28 -0
- package/dist/db/postgres.d.ts +28 -0
- package/dist/db/postgres.js +1 -0
- package/dist/delete-page-CGR6VXZC.css +1 -0
- package/dist/delete-page-FQYTEMBN.js +1 -0
- package/dist/digital-asset-manager-PIZMJEMX.js +1 -0
- package/dist/digital-asset-manager-PSTDGMY2.css +1 -0
- package/dist/dispatch-action-3IV56BNY.js +1 -0
- package/dist/duplicate-page-HPPMQRL3.js +1 -0
- package/dist/dynamic-page-selector-LFHJQLYY.js +1 -0
- package/dist/dynamic-page-selector-SXJQAIGL.css +1 -0
- package/dist/edit-url-panel-Q3NJCV55.js +1 -0
- package/dist/get-blocks-styles-SLZ5NDUF.js +1 -0
- package/dist/get-page-styles-Q4FWW5LX.js +1 -0
- package/dist/image-editor-PLXDYVKE.css +1 -0
- package/dist/image-editor-RSEHWRGV.js +1 -0
- package/dist/json-diff-viewer-FQYK2FUX.js +8 -0
- package/dist/lang-panel-57UGEL6B.css +1 -0
- package/dist/lang-panel-HH5LEOF4.js +1 -0
- package/dist/license-overlay-4Q525E53.js +1 -0
- package/dist/log-ai-request-LHPKU2C5.js +1 -0
- package/dist/manage-design-tokens-264H25A2.js +1 -0
- package/dist/manage-design-tokens-modal-OIWIZ53K.js +1 -0
- package/dist/mark-as-template-7TCCEMGC.js +1 -0
- package/dist/nested-path-selector-content-N4XN7QUS.js +1 -0
- package/dist/nextjs/render-client.cjs +1 -0
- package/dist/nextjs/render-client.css +1 -0
- package/dist/nextjs/render-client.d.cts +14 -0
- package/dist/nextjs/render-client.d.ts +14 -0
- package/dist/nextjs/render-client.js +1 -0
- package/dist/nextjs/render.cjs +829 -0
- package/dist/nextjs/render.d.cts +78 -0
- package/dist/nextjs/render.d.ts +78 -0
- package/dist/nextjs/render.js +1 -0
- package/dist/nextjs/server.cjs +807 -0
- package/dist/nextjs/server.d.cts +329 -0
- package/dist/nextjs/server.d.ts +329 -0
- package/dist/nextjs/server.js +1 -0
- package/dist/nextjs.cjs +1 -0
- package/dist/nextjs.d.cts +17 -0
- package/dist/nextjs.d.ts +17 -0
- package/dist/nextjs.js +1 -0
- package/dist/no-language-page-content-NQIROTIL.js +1 -0
- package/dist/no-language-page-dialog-CWG5PI7N.js +1 -0
- package/dist/page-creator-2L6L6EFV.js +1 -0
- package/dist/page-lock-7HMG34UJ.js +1 -0
- package/dist/page-locked-dialog-ACMWVAZX.js +1 -0
- package/dist/page-manager-new-SCZFNGKO.js +1 -0
- package/dist/page-manager-new-VWRASZTI.css +1 -0
- package/dist/page-manager-search-and-filter-7CHPYAPV.js +1 -0
- package/dist/page-manager-sheet-KZZBKQ6M.js +1 -0
- package/dist/page-manager-sheet-U5YEB5CS.css +1 -0
- package/dist/page-revisions-content-DHPEQ4CA.js +1 -0
- package/dist/page-revisions-trigger-XGC4HOTL.js +1 -0
- package/dist/pages-DlMX1Lj2.d.cts +21 -0
- package/dist/pages-Dol4CXrN.d.ts +21 -0
- package/dist/payload/builder.cjs +243 -0
- package/dist/payload/builder.css +1 -0
- package/dist/payload/builder.d.cts +13 -0
- package/dist/payload/builder.d.ts +13 -0
- package/dist/payload/builder.js +1 -0
- package/dist/payload.cjs +807 -0
- package/dist/payload.d.cts +603 -0
- package/dist/payload.d.ts +603 -0
- package/dist/payload.js +1 -0
- package/dist/preview-banner-SDDZGGRW.js +1 -0
- package/dist/publish-pages-content-3AZ45DYH.js +1 -0
- package/dist/registry.cjs +11 -0
- package/dist/registry.d.cts +74 -0
- package/dist/registry.d.ts +74 -0
- package/dist/registry.js +1 -0
- package/dist/relations-DDBTFCMR.js +1 -0
- package/dist/revalidate-G2DEOH4Z.js +1 -0
- package/dist/rte-widget-modal-7RXFEYHK.js +1 -0
- package/dist/save-to-lib-65EGTZE5.js +1 -0
- package/dist/schema-IVNMPI4V.js +1 -0
- package/dist/schema.sqlite-CYBLikNv.d.cts +5852 -0
- package/dist/schema.sqlite-CYBLikNv.d.ts +5852 -0
- package/dist/seo-panel-WQ47FNP4.css +1 -0
- package/dist/seo-panel-Z6OBXHQ4.js +2 -0
- package/dist/server-config-b29G6_aQ.d.cts +116 -0
- package/dist/server-config-oPlt3V1X.d.ts +116 -0
- package/dist/state-RAP56WXS.js +1 -0
- package/dist/take-over-request-EB464ZGU.js +1 -0
- package/dist/translation-warning-modal-EES6I2QV.js +1 -0
- package/dist/types.cjs +1 -0
- package/dist/types.d.cts +38 -0
- package/dist/types.d.ts +38 -0
- package/dist/types.js +1 -0
- package/dist/unmark-as-template-6STMTBP5.js +1 -0
- package/dist/unpublish-page-CE3CJK5C.js +1 -0
- package/dist/unpublished-partials-modal-OZBWBCLN.js +1 -0
- package/dist/utils.cjs +1 -0
- package/dist/utils.d.cts +168 -0
- package/dist/utils.d.ts +168 -0
- package/dist/utils.js +1 -0
- package/dist/web-blocks.cjs +1 -0
- package/dist/web-blocks.d.cts +3 -0
- package/dist/web-blocks.d.ts +3 -0
- package/dist/web-blocks.js +1 -0
- package/dist/web-preview-EIWOXGPY.js +1 -0
- package/package.json +322 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import{b as $c}from"./chunk-R5ZTCDFD.js";import{a as Sc,c as Tc}from"./chunk-5ZC65NB6.js";import{a as nr}from"./chunk-JBB5IJFA.js";import{a as hc,b as Zn,c as ra}from"./chunk-7C4EQOAR.js";import{a as ca}from"./chunk-F7YMHPEA.js";import{a as bc,b as K,c as Rc,d as Gc,e as da,f as fo,g as Kc,h as jc,k as Zc,m as pa,n as Yc,o as zs}from"./chunk-D5SKCKSB.js";import{A as Fs,E as lo,a as io,f as Wn,i as lc,l as cc,m as dc,n as pc,r as Un,t as uc}from"./chunk-LNV5MRGV.js";import{a as la}from"./chunk-FOKGOT6B.js";import{b as Rr,c as zn,d as ic,e as $n}from"./chunk-CJP3BQH2.js";import{f as sc}from"./chunk-PQHFT4TE.js";import{e as Ut}from"./chunk-AOJE5WI3.js";import{$ as Zl,A as _n,B as Pn,C as Vl,E as zl,G as Rn,H as Ve,M as Mn,N as rr,O as Hn,P as $l,Q as Wl,R as $t,S as Ul,V as Gl,W as Kl,X as On,Y as jl,Z as $,_ as Fn,a as _l,aa as Yl,b as Lr,ba as W,c as he,da as Vn,e as Pl,ea as Hs,f as Ll,fa as Os,g as Rl,ga as Xl,h as Ml,ha as so,ia as Ce,ja as ye,ka as ze,ma as ql,na as Jl,oa as Ql,p as L,pa as ec,q as Hl,qa as tc,r as bt,ra as oc,s as Qe,sa as et,t as Ao,ta as rc,u as Io,v as Do,w as er,wa as M,x as Ol,xa as te,z as Fl}from"./chunk-2NYUIXUX.js";import{a as vt}from"./chunk-WHPIYGCY.js";import{d as Nc}from"./chunk-PM3JNOZH.js";import{a as Ae}from"./chunk-WEVKAJMV.js";import{a as ea}from"./chunk-55SU3QPU.js";import{b as nc,c as ac,d as Wt}from"./chunk-ZAU65LBG.js";import{a as Xc}from"./chunk-BQSLQHLD.js";import{a as At}from"./chunk-IH562KSP.js";import{a as co,b as po,c as ke,d as tt}from"./chunk-FERH2TPR.js";import{a as ar}from"./chunk-ODSL3KXG.js";import{a as Tl,b as me,c as fe,d as ge}from"./chunk-TVF77C53.js";import{a as Zo,b as Yo,d as Xo}from"./chunk-777N6WHB.js";import{a as Mr}from"./chunk-N7Z4RFFI.js";import{a as at,c as st,d as it,g as lt,i as ct}from"./chunk-WSQ5SQBD.js";import{a as ta}from"./chunk-4P25MV5E.js";import{a as qc,f as Jc,g as Qc,i as ed}from"./chunk-6TXCHU4K.js";import{a as _o}from"./chunk-J7Q62EP7.js";import{a as El,c as Bl,d as Al,e as Il,h as Dl}from"./chunk-YQ5QQCRD.js";import{a as qo,b as Nl,f as Jo,g as Bn,i as Qo}from"./chunk-RBDZDQZR.js";import{a as ot,b as rt,c as Yn,i as nt,j as Pe,k as yc,m as vc,n as Xn}from"./chunk-4VNLL2IA.js";import{a as Cc,b as kc,c as wc}from"./chunk-FLSV2QGU.js";import{a as oe}from"./chunk-2N4IJZOR.js";import{a as z}from"./chunk-4JBHWPMO.js";import{a as qn,b as Jn,c as xc,d as Qn}from"./chunk-3E72DJSP.js";import{a as na,b as Hc,e as aa,f as sa,g as Oc,h as ia,i as Fc,j as Vc,k as zc}from"./chunk-BWORNCTE.js";import{a as Wc,c as Uc}from"./chunk-SSENH35Y.js";import{b as Hr}from"./chunk-TEL5ACJE.js";import{b as D}from"./chunk-3IT7IIAV.js";import{b as En}from"./chunk-IP4JBQOX.js";import{a as Gt}from"./chunk-NSQEQYEM.js";import{a as mo}from"./chunk-T32TW3XV.js";import{a as Mc}from"./chunk-TGJQC6VC.js";import{a as td}from"./chunk-ESCX7KEH.js";import{a as be}from"./chunk-CRJENCPR.js";import{a as gc,c as uo,d as Ec,e as Bc,g as Ac,i as Ic,k as Dc,l as oa,n as Vs,p as _c,q as Pc,r as Lc}from"./chunk-VUWHFLT7.js";import{a as yt,b as Gn,c as Kn,d as mc,e as jn,f as fc}from"./chunk-OR7KKUYT.js";import{a as sr}from"./chunk-T56KQBE2.js";import{a as Nn}from"./chunk-LWYDGDPW.js";import{a as In,b as Dn,c as zt}from"./chunk-VKSRWZCO.js";import{a as An,c as Ln,f as Be,g as tr,i as Ms,j as ao,q as or}from"./chunk-3UEPBBE4.js";import{parse as Yg,stringify as Xg}from"himalaya";import{kebabCase as $s}from"lodash-es";import{useCallback as qg}from"react";import{useAtom as Zg}from"jotai";var dt=()=>Zg(er);var Jg=["data-block-index","draggable","data-drop","data-style-id","data-block-parent","data-style-prop","data-highlighted"],Qg=["Box","Button","Checkbox","Divider","EmptyBox","Form","FormButton","Heading","Input","Label","LineBreak","Link","List","ListItem","Paragraph","Radio","RichText","Select","Span","Text","TextArea","Video"],od=e=>e.type==="element"&&["script","style","link"].includes(e.tagName||"")||e.type==="comment"?null:e.type==="text"?e:e.type==="element"&&e.attributes&&e.attributes.find(t=>t.key==="id"&&t.value==="add-block-bottom")?null:(e.type==="element"&&e.attributes&&(e.attributes=e.attributes.filter(t=>!Jg.includes(t.key))),e.children&&(e.children=e.children.map(od).filter(t=>t!==null)),e),ua=(e,t,o={})=>{var a,s,i,l,c,d,p,h;if(e.type!=="element"||!e.attributes)return e;if(e.tagName==="span"&&e.attributes.find(m=>m.key==="role"&&m.value==="link")){e.tagName="a",e.attributes=e.attributes.filter(f=>f.key!=="role");let m=(a=e.attributes.find(f=>f.key==="data-block-id"))==null?void 0:a.value,g=t==null?void 0:t.find(f=>(f==null?void 0:f._id)===m);if(g!=null&&g.link&&((i=(s=g==null?void 0:g.link)==null?void 0:s.href)==null?void 0:i.length)>0){let f=(l=g==null?void 0:g.link)==null?void 0:l.href,b=(c=g==null?void 0:g.link)==null?void 0:c.target;e.attributes.push({key:"href",value:f}),typeof b=="string"&&b.length>0&&e.attributes.push({key:"target",value:b})}}let r=e.attributes.find(u=>u.key==="data-block-type"),n=e.attributes.find(u=>u.key==="data-block-id");if(r){let u=r.value;if(Qg.includes(u)||(d=o==null?void 0:o.additionalCoreBlocks)!=null&&d.includes(u))e.attributes=e.attributes.filter(m=>m.key!=="data-block-type"),e.children&&(e.children=e.children.map(m=>ua(m,t,o)));else{let m=`chai-${$s(u)}`;e.tagName=m,e.attributes=[],e.attributes.push({key:"chai-type",value:u});let g=Be(u),f=t.find(b=>b._id===(n==null?void 0:n.value));if(f&&e.attributes.push(...Object.entries(f).filter(([b])=>!["_id","_type","_parent","_index"].includes(b)).map(([b,y])=>({key:b.startsWith("_")?"_"+$s(b.slice(1)):$s(b),value:typeof y=="string"?y:JSON.stringify(y)}))),g&&(g!=null&&g.description)&&e.attributes.push({key:"about-this-component",value:g.description}),g){if(g.canMove){let b=typeof g.canMove=="function"?g.canMove():g.canMove;e.attributes.push({key:"can-move",value:String(b)})}if(g.canDelete){let b=typeof g.canDelete=="function"?g.canDelete():g.canDelete;e.attributes.push({key:"can-delete",value:String(b)})}}if(u==="Icon"){let b=e.attributes.find(v=>v.key==="icon"),y=(p=b==null?void 0:b.value)!=null?p:"",k=y.includes("chai-default-svg");if(e.attributes=e.attributes.filter(v=>v.key!=="icon"),!k){let v=y.match(/\blucide-([\w-]+)\b/g);if(v){let S=v.map(x=>x.replace("lucide-","")),E=(h=S.find(x=>!x.endsWith("-icon")))!=null?h:S[0].replace(/-icon$/,"");e.attributes.push({key:"icon-name",value:E})}}}Gn(u)?e.children&&(e.children=e.children.map(b=>ua(b,t,o))):e.children=[]}}else e.children&&(e.children=e.children.map(u=>ua(u,t,o)));return n&&e.attributes.push({key:"bid",value:n.value}),e.attributes=e.attributes.filter(u=>u.key!=="data-block-type"&&u.key!=="data-block-id"),e},Ws=()=>{let[e]=dt();return qg(t=>{var c,d;if(!e)return"";let o=t!=null&&t.blockId?`[data-block-id="${t.blockId}"]`:"#canvas",r=(d=(c=e.contentDocument)==null?void 0:c.querySelector(o))==null?void 0:d[o==="#canvas"?"innerHTML":"outerHTML"];if(!r)return"";let a=Yg(r).map(od).filter(p=>p!==null),s=Hl(),i=a.map(p=>ua(p,s,t)),l=Xg(i);return l=l.replace(/#styles:,/g,"#styles:"),l.replace(/\s+/g," ").trim()},[e])};var eh=({baseUrl:e="https://chaibuilder-sdk.vercel.app"}={})=>({name:"Chai Library",description:"",getBlocksList:async t=>{try{let o=await fetch(`${e}/library-blocks/blocks-list.json`);return o.ok?(await o.json()).map(n=>{var a;return{...n,preview:(a=n.preview)!=null&&a.startsWith("http")?n.preview:`${e}${n.preview}`}}):(console.error("Failed to fetch blocks list:",o.status,o.statusText),[])}catch(o){return console.error("Error fetching blocks list:",o),[]}},getBlock:async({block:t})=>{try{let o=await fetch(`${e}/${t.id}.html?raw`);return o.ok?await o.text():(console.error(`Failed to fetch block "${t.id}" from "${e}/${t.id}.html?raw": ${o.status} ${o.statusText}`),`<!-- Error loading block "${t.id}": ${o.status} ${o.statusText} -->`)}catch(o){return console.error(`Error fetching block "${t.id}" from "${e}/${t.id}.html?raw":`,o),`<!-- Error loading block "${t.id}" -->`}}});import nd from"i18next";import{initReactI18next as oh}from"react-i18next";var rd={"Add block":"Add Block","Add Block":"Add Block","Add blocks":"Add blocks","Add inside":"Add inside","Add before":"Add before","Add after":"Add after","Add block inside":"Add block inside","Add field":"Add field","Enter or paste TailwindCSS HTML snippet":"Enter or paste TailwindCSS HTML snippet","Click to add block to page":"Click to add block to page",Core:"Core","Custom Blocks":"Custom Blocks","UI Library":"UI Library",Import:"Import","Use HTML snippets from Tailwind CSS component libraries":"Use HTML snippets from Tailwind CSS component libraries","Tailwind HTML snippet":"Tailwind HTML snippet","Enter your code snippet here":"Enter your code snippet here","Import HTML":"Import HTML","Imported HTML Note":"NOTE: Imported html will be added to the currently selected block. If no block is selected, the html will be added to the page.","Dark Mode":"Dark Mode","Pannable Canvas":"Pannable Canvas","Hand tool":"Hand tool","Toggle pannable canvas":"Toggle pannable canvas","Select / Hand tool":"Select / Hand tool","Zoom in":"Zoom in","Zoom out":"Zoom out","Reset zoom":"Reset zoom","This page has no blocks. Add a block by clicking the + button":"This page has no blocks. Add a block by clicking the + button","This page is empty":"This page is empty","Please select a block to edit settings or styles":"Please select a block to edit settings or styles","Please select a block to Ask AI":"Please select a block to ask AI","Please select a styling block":"Please select a styling block","Drop your block here":"Drop your block here","Use setting":"Use setting","Mobile (XS)":"Mobile (XS)","Styles set here are applied to all screen unless edited at higher breakpoint":"Styles set here are applied to all screen unless edited at higher breakpoint","Mobile landscape (SM)":"Mobile landscape (SM)","Styles set here are applied at 640px and up unless edited at higher breakpoint":"Styles set here are applied at 640px and up unless edited at higher breakpoint","Tablet (MD)":"Tablet (MD)","Styles set here are applied at 768px and up":"Styles set here are applied at 768px and up","Tablet Landscape (LG)":"Tablet Landscape (LG)","Styles set here are applied at 1024px and up unless edited at higher breakpoint":"Styles set here are applied at 1024px and up unless edited at higher breakpoint","Desktop (XL)":"Desktop (XL)","Styles set here are applied at 1280px and up unless edited at higher breakpoint":"Styles set here are applied at 1280px and up unless edited at higher breakpoint","Large Desktop (2XL)":"Large Desktop (2XL)","Styles set here are applied at 1536px and up":"Styles set here are applied at 1536px and up",Breakpoints:"Breakpoints",Clear:"Clear","Clear whole canvas?":"Clear whole canvas?","Are you sure you want to clear the whole canvas?":"Are you sure you want to clear the whole canvas?",Cancel:"Cancel",Yes:"Yes",Preview:"Preview",Settings:"Settings",Styling:"Style",SVG_code:"Enter SVG code here","Paste SVG_code":"Choose icon or paste SVG code","Enter Key":"Enter Key","Data Provider":"Data Provider","Remove Provider Confirmation":"Are you sure you want to remove <span class='text-blue-500'>{name}</span> provider?","Your data provider will be removed from this page and all added data binding will be not visible on blocks.":"Your data provider will be removed from this page and all added data binding will be not visible on blocks.",Remove:"Remove","You have no data providers registered. Please add a data provider to your project.":"You have no data providers registered. Please add a data provider to your project.","Learn more":"Learn more","Add data providers:":"Add data providers:","Select a provider":"Select a provider",Choose:"Choose","Page data providers:":"Page data providers:","View Data":"View Data","Mark as Global":"Mark as Global","Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.":"Note: Global blocks are single instances. Editing global blocks will be reflected on all pages using these blocks.","Global blocks are indicated with":"Global blocks are indicated with","Global blocks are available under 'Global' category":"Global blocks are available under 'Global' category","Enter global block name":"Enter global block name","Eg: Header, Footer":"Eg: Header, Footer","{length} blocks selected.":"{length} blocks selected.",Cut:"Cut",Copy:"Copy",Paste:"Paste",Delete:"Delete","Clear Selection":"Clear Selection","This is dev mode. Visit":"This is dev mode. Visit","to see page preview":"to see page preview",classes:"classes",Theme:"Theme",Outline:"Outline","Not supported":"Not supported","Please use Chrome, Firefox or Safari":"Please use Chrome, Firefox or Safari","Download Complete":"Download complete",Copied:"Copied","Enter Classes":"Add classes or design tokens (space-separated)","Ask AI":"Ask AI","Edit with AI":"Edit with AI","Generating... Please wait...":"Generating... Please wait...","Saving... Please wait...":"Saving... Please wait...","Deleting... Please wait...":"Deleting... Please wait...",Stop:"Stop","E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI":"E.g.: This page is about an AI assistant app called Chai Studio. It allows users to create beautiful webpages and edit content with AI.","Ask AI to edit styles":"Ask AI to edit styles","Ask AI to edit content":"Ask AI to edit content","AI Context":"AI Context","Select Block for AI":"Select a block to edit with AI","Select Block to Edit":"Please select a block to edit",Edit:"Edit","Describe this page. E.g.: This page is about...":"Describe this page. E.g.: This page is about...",Tag:"Tag",Value:"Value","Background Image":"Background Image","Enter image URL":"Enter image URL","Enter URL":"Enter URL",URL:"URL","Replace image":"Replace image","Choose image":"Choose image",Images:"Images",Library:"Library",Blocks:"Blocks",Basic:"Basic",Media:"Media",Advanced:"Advanced",Form:"Form","Choose Icon or SVG":"Choose an icon or enter SVG",Groups:"Groups","UI Libraries":"UI Libraries",Accordions:"Accordions",Buttons:"Buttons",Layouts:"Layouts","Choose Library":"Choose library","No Library Found":"No library found.",FAQ:"FAQ",Hero:"Hero",Features:"Features",Footer:"Footer",Navbar:"Navbar",Icons:"Icons",Testimonials:"Testimonials",Blog:"Blog","Remove context":"Remove context","Yes, Delete":"Yes, Delete","AI Context Updated":"AI Context Updated","You can now ask AI to edit your content.":"You can now ask AI to edit your content.",Saved:"Saved",Unsaved:"Unsaved","Saving...":"Saving...","Improve writing":"Improve writing","Replace placeholder content":"Replace placeholder content","Discard current placeholder content and replace with meaningful relevant content.":"Discard current placeholder content and replace with meaningful relevant content.","Fix grammar":"Fix grammar","Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.":"Fix grammar in all text elements. Ensuring the text is grammatically correct and free of errors.","Make longer":"Make longer","Make all text elements longer.":"Make all text elements longer.","Make shorter":"Make shorter","Make all text elements shorter.":"Make all text elements shorter.","Add emojis":"Add emojis","Add emojis to text elements if relevant.":"Add emojis to text elements if relevant.",Randomize:"Randomize","Randomize all text elements.":"Randomize all text elements.","Edit Block":"Edit Block","AI Assistant":"AI Assistant","Generate with AI":"Generate with AI","Theme Config":{"Heading Font":"Heading Font","Body Font":"Body Font","Rounded Corner":"Rounded Corners",Primary:"Primary",Secondary:"Secondary",Background:"Background","Text Color":"Text Color","Background Dark Mode":"Background (Dark Mode)","Text Color Dark Mode":"Text Color (Dark Mode)","Reset styles":"Reset styles"},"Copy classes to clipboard":"Copy classes to clipboard","Classes copied to clipboard":"Classes copied to clipboard",Classes:"Classes",All:"All","Enter classes separated by space":"Add classes (space-separated)","Enter classes separated by space or design tokens":"Add classes or design tokens (space-separated)","Show hidden blocks":"Show hidden blocks","Expand all":"Expand all","Collapse all":"Collapse all","Choose library":"Choose library","Close Preview":"Close Preview",Error:"Error","Failed to copy template":"Failed to copy template","Total tokens used":"Total tokens used","Updated AI Context":"Updated AI Context","You can now Ask AI to edit your content":"You can now Ask AI to edit your content","Tell about this page eg this page is about":"Tell about this page eg this page is about..","Delete Context":"Delete Context","Keyboard shortcuts":"Keyboard shortcuts",Undo:"Undo",Redo:"Redo",Duplicate:"Duplicate","Deselect blocks":"Deselect blocks","Delete block":"Delete block","Save page":"Save page","Scripts will be only executed in preview and live mode.":"Scripts will be only executed in preview and live mode.","HTML Code Editor |":"HTML Code Editor |",Close:"Close","Coming soon":"Coming soon",Selected:"Selected",Select:"Select","Choose Builder Layout":"Choose Builder Layout","Single side panel":"Single side panel","Suitable for smaller screens. Bigger canvas size.":"Suitable for smaller screens. Bigger canvas size.","Dual side panel":"Dual side panel","Suitable for larger screens. Smaller canvas size.":"Suitable for larger screens. Smaller canvas size.","Dual side panel advanced":"Dual side panel advanced","Suitable for heavy styling & block editing. Setting are always visible.":"Suitable for heavy styling & block editing. Setting are always visible.","Block Settings":"Block Settings","Visibility settings":"Visibility settings","Show on canvas":"Show on canvas",Attributes:"Attributes","Apply Presets":"Apply Presets",apply:"apply",presets:"presets","Global presets":"Global presets",Orientation:"Orientation",Color:"Color","Please select an image":"Please select an image","click to upload":"click to upload","SVG, PNG, JPG or GIF (Max. 2mb)":"SVG, PNG, JPG or GIF (Max. 2mb)","Uploading...":"Uploading...",Upload:"Upload","Something went wrong":"Something went wrong","Fetching...":"Fetching...","No images found":"No images found","It looks like you haven't uploaded any images yet. Start by clicking the upload button above.":"It looks like you haven't uploaded any images yet. Start by clicking the upload button above.","Open Code Editor":"Open Code Editor","Open publish menu":"Open publish menu","Publish changes":"Publish changes","Select the pages you want to publish. Click publish when you're done.":"Select the pages you want to publish. Click publish when you're done.",Updated:"Updated",Offline:"Offline","No changes found":"No changes found","Publish Selected":"Publish Selected","is editing this page":"is editing this page",Name:"Name",Type:"Type",Status:"Status",Page:"Page",Pages:"Pages","Clear search":"Clear search","No results found for":"No results found for","Search {{pageTypeName}}":"Search {{pageTypeName}}","Goto Page":"Goto Page","Open URL":"Open URL","Compose Email":"Compose Email","Call Phone":"Call Phone","Scroll to element":"Scroll to element","#ElementID":"#ElementID","Enter details":"Enter details","Open in new tab":"Open in new tab",Apply:"Apply",Back:"Back",Insert:"Insert",Rename:"Rename","Unlink from library":"Unlink from library","Save to Library":"Save to Library","No blocks found in this group":"No blocks found in this group","No blocks found matching":"No blocks found matching","No matching blocks found":"No matching blocks found","Search blocks...":"Search blocks...",Partials:"Partials",Happy:"Happy",Sad:"Sad","Importing...":"Importing...","Failed to load the UI library. Try again":"Failed to load the UI library. Try again",Retry:"Retry","Oops! Something went wrong.":"Oops! Something went wrong.","Please try again.":"Please try again.","No option found.":"No option found.","Clipboard not supported":"Clipboard not supported","Are you sure you want to clear the page?":"Are you sure you want to clear the page?",canvas_empty:"Canvas is empty",Presets:"Presets","Reset style":"Reset style","Reset styles":"Reset styles","Clear styles":"Clear styles","Open code editor":"Open code editor","Style element":"Style element","Repeater Data":"Repeater Data","Toggle Data Binding":"Toggle Data Binding",No:"No",Saving:"Saving","Screen sizes":"Screen sizes","Theme Settings":"Theme Settings","Import CSS Theme":"Import CSS Theme","Import theme":"Import theme","Import Theme":"Import Theme","CSS Variables":"CSS Variables","You don't have permission to edit settings or styles":"You don't have permission to edit settings or styles","Please contact your administrator to get access":"Please contact your administrator to get access","flex.heading":"Flex Child","flex.basis":"Basis","flex.order":"Order","flex.flex":"Flex","flex.grow":"Grow","flex.shrink":"Shrink","grid.heading":"Grid Child","grid.col_span":"Col Span","grid.col_start":"Col Start","grid.col_end":"Col End","grid.row_span":"Row Span","grid.row_start":"Row Start","grid.row_end":"Row End","grid.order":"Order","layout.heading":"Layout","layout.width":"Width","layout.height":"Height","layout.margin":"Margin","layout.margin_all":"All","layout.margin_lr":"Left-Right","layout.margin_tb":"Top-Bottom","layout.margin_top":"Top","layout.margin_right":"Right","layout.margin_bottom":"Bottom","layout.margin_left":"Left","layout.padding":"Padding","layout.padding_all":"All","layout.padding_lr":"Left-Right","layout.padding_tb":"Top-Bottom","layout.padding_top":"Top","layout.padding_right":"Right","layout.padding_bottom":"Bottom","layout.padding_left":"Left","layout.space_bt":"Space Bt.","layout.space_lr":"Left-Right","layout.space_tb":"Top-Bottom","size.heading":"Size","size.min_width_height":"Min width & height","size.min_width":"Min Width","size.min_height":"Min Height","size.max_width_height":"Max width & height","size.max_width":"Max Width","size.max_height":"Max Height","size.object_options_aspect_ratio":"Object options & aspect ratio","size.aspect":"Aspect","size.fit":"Fit","size.position":"Position","display.heading":"Display","display.display":"Display","display.flex_options":"Flex options","display.flex_direction":"Direction","display.flex_wrap":"Wrap","display.justify_content":"Justify","display.align_content":"Content","display.align_items":"Items","display.gap":"Gap","display.gap_all":"All","display.gap_lr":"Left-Right","display.gap_tb":"Top-Bottom","display.grid_options":"Grid options","display.grid_columns":"Columns","display.grid_rows":"Rows","display.grid_auto_flow":"Auto Flow","display.grid_auto_cols":"Auto Cols","display.grid_auto_rows":"Auto Rows","display.visibility_opacity":"Visibility & Opacity","display.visibility":"Visibility","display.opacity":"Opacity","position.heading":"Position","position.position":"Position","position.options":"Position options","position.direction":"Direction","position.top":"Top","position.right":"Right","position.bottom":"Bottom","position.left":"Left","position.inset":"Inset","position.all":"All","position.lr":"Left Right","position.tb":"Top Bottom","position.z_index":"Z-Index","position.float_clear":"Float & Clear","position.float":"Float","position.clear":"Clear","position.overflow_overscroll":"Overflow & Overscroll","position.overflow":"Overflow","position.overscroll":"Overscroll","typography.heading":"Typography","typography.font":"Font","typography.size":"Size","typography.height":"Height","typography.weight":"Weight","typography.color":"Color","typography.alignments":"Alignments","typography.align":"Align","typography.valign":"V. Align","typography.spacing_decoration_more":"Spacing, decoration & more","typography.spacing":"Spacing","typography.decoration":"Decoration","typography.thickness":"Thickness","typography.transform":"Transform","typography.whitespace_breaks":"White space & breaks","typography.whitespace":"Whitespace","typography.wordbreak":"Wordbreak","background.heading":"Background","background.bgcolor":"Bg. Color","background.position_size_more":"Position, Size & more","background.attachment":"Attachment","background.clipping":"Clipping","background.origin":"Origin","background.position":"Position","background.repeat":"Repeat","background.size":"Size","background.gradient":"Gradient","background.gradient_colors":"Gradient colors","background.from_color":"From","background.via_color":"Via","background.to_color":"To","border.heading":"Border & Outline","border.width":"Width","border.all":"All","border.lr":"Left Right","border.tb":"Top bottom","border.top":"Top","border.right":"Right","border.bottom":"Bottom","border.left":"Left","border.corners":"Corners","border.top_left":"Top Left","border.top_right":"Top right","border.bottom_right":"Bottom right","border.bottom_left":"Bottom left","border.color":"Color","border.style":"Style","border.divide_options":"Divide options","border.divide_color":"Color","border.divide_style":"Style","border.outline_styling":"Outline styling","border.outline_width":"Width","border.outline_offset":"Offset","border.outline_style":"Style","border.ring_options":"Ring options","border.ring_width":"Width","border.ring_color":"Color","border.ring_offset_width":"Offset","border.ring_offset_color":"Off. color","effect.heading":"Effect & Animation","effect.shadow":"Shadow","effect.color":"Color","effect.cursor":"Cursor","effect.blend_cursor":"Blend & Cursor","effect.mix_blend":"Mix Blend","effect.bg_blend":"Bg. Blend","effect.transform":"Transform","effect.origin":"Origin","effect.scale":"Scale","effect.all":"All","effect.lr":"Left-Right","effect.tb":"Top-Bottom","effect.skew":"Skew","effect.translate":"Translate","effect.rotate":"Rotate","effect.animation":"Animation","effect.transition":"Transition","effect.easing":"Easing","effect.duration":"Duration","effect.delay":"Delay","classes.heading":"Classes",theme_config:{heading_font:"Heading Font",body_font:"Body Font",rounded_corner:"Rounded Corners",primary:"Primary",secondary:"Secondary",background:"Background",text_color:"Text Color",background_dark_mode:"Background (Dark Mode)",text_color_dark_mode:"Text Color (Dark Mode)"},web_blocks:{box:"box",tag:"Tag",div:"div",level:"Level",header:"header",footer:"footer",section:"section",article:"article",aside:"aside",main:"main",nav:"navigation",figure:"figure",details:"details",summary:"summary",dialog:"dialog",strike:"strike",caption:"caption",legend:"legend",figcaption:"figure caption",mark:"mark",background_image:"Background Image",label:"Label",default:"default",icon_size:"Icon Size",icon_position:"Icon Position",start:"Start",end:"End",button:"Button",custom_html:"Custom HTML",html_code:"HTML Code",default_snippet:"The HTML snippet goes here...",placeholder:"Enter custom HTML code here",custom_script:"Custom Script",dark_mode:"Dark Mode",divider:"Divider",empty_box:"Empty Box",heading:"Heading",image:"Image",alt:"Alt",width:"Width",height:"Height",video:"Video",span:"Span",content:"Content",icon:"Icon",richtext:"Rich Text",list:"List",list_type:"List Type",listitem:"List Item",link:"Link",list_item:"List Item",none:"None",disc:"Disc",number:"Number",paragraph:"Paragraph",lightbox_link:"Lightbox Link",href:"Link",type:"Type",iframe:"iframe",inline:"inline",ajax:"ajax",autoplay:"Video autoplay",max_width:"Max Width",backdrop_color:"Background Color",gallery_name:"Gallery Name",slot:"Slot",empty_slot:"Empty Slot",text:"Text",video_url:"Video URL",controls:"Show Controls",loop:"Loop",muted:"Muted",checkbox:"Checkbox",required:"Required",checked:"Checked",submit_button:"Submit Button",form:"Form",submit_url:"Submit URL",error_message:"Error Message",success_message:"Success Message",input:"Input",value:"Value",show_label:"Show Label",field_name:"Field Name",radio:"Radio",multiple:"Multiple",options:"Options",select:"Select",multiple_choice:"Multiple Choice",textarea:"Textarea",rows:"Rows"},"Export Code":"Export Code","Exporting {{count}} blocks":"Exporting {{count}} blocks","Exporting all blocks":"Exporting all blocks","Export code copied!":"Export code copied!","Failed to copy export code":"Failed to copy export code","Export code downloaded successfully!":"Export code downloaded successfully!","Failed to generate export HTML":"Failed to generate export HTML","Enter value":"Enter value","Attribute keys cannot start with @":"Attribute keys cannot start with @","Enter key":"Enter key",Add:"Add",Save:"Save",Screen:"Screen"};nd.use(oh).init({resources:{en:{translation:rd}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});var ma=nd;import{useAtom as kl}from"jotai";import{each as RN,noop as MN,omit as HN}from"lodash-es";import{useEffect as Bo,useMemo as ON}from"react";import{ErrorBoundary as FN}from"react-error-boundary";import{Toaster as VN}from"sonner";import{useTranslation as rh}from"react-i18next";import{jsx as Us,jsxs as nh}from"react/jsx-runtime";var go=()=>{let{t:e}=rh();return Us("div",{className:"h-full w-full rounded-md bg-red-200 p-4 text-red-500",children:nh("div",{className:"flex h-full w-full flex-col items-center justify-center",children:[Us("p",{className:"font-semibold",children:e("Oops! Something went wrong.")}),Us("p",{children:e("Please try again.")})]})})};import{EyeClosedIcon as lh}from"@radix-ui/react-icons";import ch,{Suspense as dh}from"react";import{useTranslation as ph}from"react-i18next";import{atom as ah,useAtom as sh}from"jotai";var ih=ah(!1),ad=()=>{let[e,t]=sh(ih);return[e,t]};import{jsx as Or,jsxs as sd}from"react/jsx-runtime";var id=()=>{let[e,t]=ad(),{t:o}=ph(),r=M("previewComponent",null);return e?sd("div",{className:zt("bg-surface fixed inset-0 z-[999]",e?"block":"hidden"),children:[sd(D,{size:"sm",className:"absolute right-0 top-0 m-4 space-x-2",onClick:()=>t(!1),children:[Or(lh,{}),Or("span",{children:o("Close Preview")})]}),Or("div",{children:r?Or(dh,{fallback:Or(_o,{className:"h-96 w-full"}),children:ch.createElement(r)}):null})]}):null};import{Cross1Icon as uh,DragHandleDots2Icon as mh,MagnifyingGlassIcon as fh}from"@radix-ui/react-icons";import{useAtom as gh}from"jotai";import{atomWithStorage as hh}from"jotai/utils";import{useEffect as bh,useMemo as yh,useState as Gs}from"react";import{useHotkeys as vh}from"react-hotkeys-hook";import{jsx as $e,jsxs as It}from"react/jsx-runtime";var xh=({featureKey:e,options:t})=>{let o=pc(e),r=dc(e);return It("div",{className:"flex items-center space-x-3 rounded-md p-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800",children:[$e(At,{checked:r,onCheckedChange:o}),It("div",{className:"flex-1",children:[$e("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:t.key}),t.description&&$e("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:t.description})]})]})},Ch=hh("show-feature-flag",null),kh=({close:e,position:t,updatePosition:o})=>{let r=cc(),[n,a]=Gs(""),[s,i]=Gs(!1),[l,c]=Gs({x:0,y:0}),d=yh(()=>{if(!n.trim())return r;let m=n.toLowerCase();return Object.fromEntries(Object.entries(r).filter(([g,f])=>{var b;return(g==null?void 0:g.toLowerCase().includes(m))||((b=f==null?void 0:f.description)==null?void 0:b.toLowerCase().includes(m))}))},[r,n]),p=m=>{i(!0),c({x:m.clientX-t.x,y:m.clientY-t.y})},h=m=>{if(!s)return;let g=m.clientX-l.x,f=m.clientY-l.y,b=m.currentTarget,y=b.offsetWidth,k=b.offsetHeight,v=window.innerWidth-y,S=window.innerHeight-k,E=Math.max(0,Math.min(g,v)),x=Math.max(0,Math.min(f,S));o(E,x)},u=()=>{i(!1)};return bh(()=>{let m=()=>{s&&i(!1)};return window.addEventListener("mouseup",m),()=>window.removeEventListener("mouseup",m)},[s]),!t||t.x<0||t.y<0?null:It("div",{onMouseDown:p,onMouseMove:h,onMouseUp:u,className:"fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",style:{left:t.x,top:t.y,cursor:s?"grabbing":"grab",userSelect:"none"},children:[It("div",{className:"relative sticky top-0 rounded-t-lg bg-white",children:[It("div",{className:"mb-3 flex items-center justify-between",children:[It("div",{children:[It("h3",{className:"flex items-center gap-x-2 text-base font-semibold text-gray-900 dark:text-gray-100",children:[$e(mh,{})," Feature Flags"]}),It("p",{className:"text-xs text-gray-400 dark:text-gray-400",children:["Toggle experimental features (",$e("span",{className:"font-mono",children:"Ctrl+Shift+1"})," to toggle)"]})]}),$e(D,{variant:"ghost",size:"sm",onClick:e,className:"absolute -right-2 -top-2 p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:$e(uh,{className:"h-4 w-4"})})]}),It("div",{className:"relative",children:[$e(fh,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),$e(oe,{type:"search",placeholder:"Search features...",className:"w-full pl-8",value:n,onChange:m=>a(m.target.value),autoFocus:!0})]})]}),$e("div",{className:"max-h-96 overflow-y-auto py-2",children:Object.keys(d).length>0?$e("div",{className:"space-y-1",children:Object.entries(d).map(([m,g])=>$e(xh,{featureKey:m,options:g},m))}):$e("div",{className:"py-8 text-center",children:It("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:['No features found matching "',n,'"']})})})]})},ld=()=>{let[e,t]=gh(Ch);return vh("ctrl+shift+1,meta+shift+1",()=>t(o=>o?{...o,show:!o.show}:{x:0,y:0,show:!0}),{enableOnFormTags:!0}),e!=null&&e.show?$e(kh,{position:e,close:()=>t(o=>o?{...o,show:!1}:null),updatePosition:(o,r)=>t(n=>n?{...n,x:o,y:r,show:n.show}:{x:o,y:r,show:!0})}):null};var wh=!1,cd=e=>{wh=e};import{camelCase as Bh}from"lodash-es";import{lazy as Ah,Suspense as Ih,useCallback as dd,useEffect as Dh,useMemo as _h,useState as Fr}from"react";import{ErrorBoundary as Ph}from"react-error-boundary";import{useTranslation as pd}from"react-i18next";import{toast as ga}from"sonner";var U={OPEN_ADD_BLOCK:"OPEN_ADD_BLOCK",CLOSE_ADD_BLOCK:"CLOSE_ADD_BLOCK",SHOW_BLOCK_SETTINGS:"SHOW_BLOCK_SETTINGS",GOTO_BLOCK_SETTINGS:"GOTO_BLOCK_SETTINGS",OPEN_AI_PANEL:"OPEN_AI_PANEL",CLEAR_CANVAS_SELECTION:"CLEAR_CANVAS_SELECTION",CANVAS_BLOCK_SELECTED:"CANVAS_BLOCK_SELECTED",CANVAS_BLOCK_STYLE_SELECTED:"CANVAS_BLOCK_STYLE_SELECTED",OPEN_EXPORT_CODE:"OPEN_EXPORT_CODE"};import{atom as Sh,useAtom as Th}from"jotai";var Nh=Sh("edit"),fa=()=>{let[e,t]=Th(Nh);return{mode:e,setMode:t}};import{useEffect as Eh}from"react";var Ks=class{constructor(){this.subscribers=new Map}subscribe(t,o){return this.subscribers.has(t)||this.subscribers.set(t,new Set),this.subscribers.get(t).add(o),()=>{let r=this.subscribers.get(t);r&&(r.delete(o),r.size===0&&this.subscribers.delete(t))}}publish(t,o){let r=this.subscribers.get(t);r&&r.forEach(n=>n(o))}},J=new Ks;function Kt(e,t){Eh(()=>{let o=J.subscribe(e,t);return()=>o()},[e,t])}import{jsx as we,jsxs as ha}from"react/jsx-runtime";var Lh=Ah(()=>import("./code-display-7346IUCO.js"));async function Rh(e){try{let t=document.createElement("div");t.innerHTML=e;let o=Array.from(t.children);return{jsx:hc(o.length===1?o[0]:o),html:t.innerHTML}}catch(t){return{html:e,jsx:e}}}var Mh=async({selectedBlock:e,html:t,isTypeScript:o=!1})=>{let r=(e==null?void 0:e._name)||(e==null?void 0:e._type)||"Component";r=Bh(r).replace(/^./,d=>d.toUpperCase());let n=" ",{jsx:a,html:s}=await Rh(t),i=a==null?void 0:a.split(`
|
|
2
|
+
`).join(`
|
|
3
|
+
${n}${n}`);return i=`${o?`import React from 'react';
|
|
4
|
+
|
|
5
|
+
`:""}export const ${r}${o?": React.FC":""} = () => {
|
|
6
|
+
${n}return (
|
|
7
|
+
${n}${n}${i==null?void 0:i.trimEnd()}
|
|
8
|
+
${n})
|
|
9
|
+
}`,{jsx:i,html:Zn(s),componentName:r}},Hh=({tab:e})=>{var f;let{t}=pd(),[o,r]=Fr({html:"",jsx:""}),n=$(),a=Ws(),[s,i]=Fr(""),[l,c]=Fr(!1),d=()=>{switch(e){case"js":return`${s}.jsx`;case"ts":return`${s}.tsx`;case"html":return`${s}.html`;case"tailwind":return"tailwind.config.js"}},p=()=>{switch(e){case"js":case"ts":return"javascript";case"html":return"HTML";case"tailwind":return"JSON"}};Dh(()=>{(async()=>{let y=n!=null?n:{_name:"Body",_type:"Body"};try{c(!1);let k=a(n?{blockId:n._id,additionalCoreBlocks:["Icon"]}:{additionalCoreBlocks:["Icon"]});k=k.replace(/\s*bid=["'][^"']*["']/g,"");let v=e==="ts",{jsx:S,html:E,componentName:x}=await Mh({selectedBlock:y,html:k,isTypeScript:v});r({html:E||"",jsx:S}),i(x),c(!0)}catch(k){let v="<div>Export failed. Close the modal and try again.</div>";r({html:v,jsx:v}),ga.error(t("Failed to generate export HTML"))}})()},[t,e,n,a]);let h=dd(async b=>{try{navigator.clipboard.writeText(b),ga.success(t("Export code copied!"))}catch(y){ga.error(t("Failed to copy export code"))}},[t]),u=b=>{var S;let y=new Blob([b],{type:"text/jsx"}),k=URL.createObjectURL(y),v=document.createElement("a");v.href=k,v.download=(S=d())!=null?S:"",document.body.appendChild(v),v.click(),URL.revokeObjectURL(k),document.body.removeChild(v),ga.success(t("Export code downloaded successfully!"))},m=ha("span",{children:["Download ",we("span",{className:"font-mono text-xs font-light text-foreground",children:d()})]}),g=_h(()=>{let b={extend:gc()},y=JSON.stringify(b,null,2);return`{
|
|
10
|
+
// Your tailwind config ...
|
|
11
|
+
|
|
12
|
+
"theme": ${y==null?void 0:y.split(`
|
|
13
|
+
`).join(`
|
|
14
|
+
`)},
|
|
15
|
+
}`},[]);return((f=o==null?void 0:o.jsx)==null?void 0:f.length)>0&&l?we(Lh,{onCopy:h,code:e==="tailwind"?g:e==="html"?o.html:o.jsx,language:p()||"",downloadText:m,onDownload:u},e):we("div",{className:"flex h-[620px] w-full items-center justify-center p-4",children:"Generating code..."})},ud=()=>{let{t:e}=pd(),[t,o]=Fr(!1),{setMode:r}=fa(),[n,a]=Fr("js"),s=dd(async()=>{a("js"),r("view"),o(!0)},[a,r,o]);return Kt(U.OPEN_EXPORT_CODE,s),we(qo,{open:t,onOpenChange:async()=>{r("edit"),await new Promise(l=>setTimeout(l,300)),o(!1)},children:ha(Jo,{className:"max-w-5xl overflow-hidden border-border",children:[ha(Bn,{className:"flex flex-row items-center justify-between",children:[we(Qo,{className:"text-foreground",children:e("Export Code")}),we(co,{defaultValue:"js",onValueChange:a,children:ha(po,{children:[we(ke,{value:"js",className:"px-2 text-xs",children:"Javascript"}),we(ke,{value:"ts",className:"px-2 text-xs",children:"Typescript"}),we(ke,{value:"html",className:"px-2 text-xs",children:"HTML"}),we(ke,{value:"tailwind",className:"px-2 text-xs",children:"Tailwind config"})]})}),we("div",{})]}),we("div",{className:"flex min-h-[400px] flex-col gap-4",children:t&&we(Ih,{fallback:we("div",{className:"flex h-[400px] items-center justify-center text-muted-foreground",children:"Loading code editor..."}),children:we(Ph,{fallback:we("div",{children:"Something went wrong"}),children:we(Hh,{tab:n})})})})]})})};import Oh from"react";import{jsx as ho,jsxs as ba}from"react/jsx-runtime";var md=()=>{let e=M("smallScreenComponent",null);return ho("section",{className:"fixed inset-0 z-[99999] flex h-screen w-screen items-center justify-center bg-white xl:hidden",children:e?Oh.createElement(e):ho("div",{className:"flex h-full w-full items-center justify-center bg-[linear-gradient(to_right,#f3f4f6_1px,transparent_1px),linear-gradient(to_bottom,#f3f4f6_1px,transparent_1px)] bg-[size:10px_10px] py-12 sm:py-16 lg:py-20",children:ho("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:ba("div",{className:"mx-auto max-w-md space-y-6 text-center",children:[ba("div",{className:"space-y-4",children:[ho("h2",{className:"text-5xl font-bold tracking-tight text-gray-900",children:"Screen too small"}),ba("p",{className:"mx-auto max-w-sm text-sm leading-7 text-gray-600",children:["Please view this page on greater than ",ho("strong",{className:"font-medium",children:"1280px"})," screen width for the best experience."]})]}),ho("div",{className:"pt-4",children:ba("div",{className:"inline-flex items-center rounded-full bg-gray-100 px-4 py-2 text-sm text-gray-700",children:[ho("svg",{className:"mr-2 h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:ho("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),"Minimum width: 1280px"]})})]})})})})};import{useAtomValue as fd}from"jotai";import{first as Fh}from"lodash-es";import{useEffect as gd,useRef as Vh}from"react";var js="bid";function zh(){return new URLSearchParams(window.location.search).get(js)}function hd(e){let t=new URL(window.location.href);e?t.searchParams.set(js,e):t.searchParams.delete(js),window.history.replaceState({},"",t.toString())}var bd=()=>{let[e,t]=W(),o=fd(he),r=fd(Rn),n=Vh(!1);gd(()=>{if(!r||n.current||o.length===0)return;n.current=!0;let a=zh();if(!a)return;o.some(i=>i._id===a)?t([a]):hd(null)},[r,o,t]),gd(()=>{if(!n.current)return;let a=Fh(e)||null;hd(a)},[e])};import{useAtom as vd}from"jotai";import{useAtom as $h}from"jotai";import{useCallback as yd,useMemo as Wh}from"react";var jt=null,Ie=()=>{let[e]=$h(er),t=Wh(()=>{var n;return(e==null?void 0:e.contentDocument)||((n=e==null?void 0:e.contentWindow)==null?void 0:n.document)},[e]),o=yd(n=>{if(t)if(jt&&jt.removeAttribute("data-highlighted"),typeof n!="string")n.setAttribute("data-highlighted","true"),jt=n;else if(typeof n=="string"){let a=t.querySelector(`[data-block-id="${n}"]`);a&&(a.setAttribute("data-highlighted","true"),jt=a)}else jt=null},[t]),r=yd(()=>{jt&&(jt.removeAttribute("data-highlighted"),jt=null)},[]);return{highlightBlock:o,clearHighlight:r,lastHighlighted:jt}};var xd=()=>{let{clear:e}=so(),[,t]=W(),{clearHighlight:o}=Ie(),[,r]=K(),[,n]=vd(Fl),{reset:a}=rr(),{setSaveState:s}=$t(),[,i]=Jl(),[,l]=vd(rc);return()=>{i({}),t([]),r([]),o(),e(),n(!1),a(),s("SAVED"),l(0)}};import{atom as Uh,useAtom as Gh,useAtomValue as Kh}from"jotai";import{find as Cd,first as jh,flatten as Zh,get as Yh,isEmpty as Xh,isString as kd}from"lodash-es";import{useEffect as qh}from"react";var Jh=(e,t)=>{let o=[],r=Cd(e,{_id:t}),n=Yh(r,"_parent","");for(;kd(n)&&!Xh(n);)o.push(r==null?void 0:r._parent),r=Cd(e,{_id:n}),n=r==null?void 0:r._parent;return Zh(o)},Qh=Uh([]),wd=()=>{let[e]=W(),t=Kh(he),[,o]=Gh(Qh);qh(()=>{let r=[],n=jh(e);kd(n)&&(r=[n,...Jh(t,n)]),o(r)},[e,t,o])};import{get as wb,isEmpty as Pd}from"lodash-es";import{useCallback as Sb}from"react";import{useHotkeys as Zt}from"react-hotkeys-hook";var eb=new Set(["text","search","url","tel","email","password","number","date","datetime-local","month","week","time"]),Sd=e=>{let t=e.target;if(!(t instanceof Element))return!1;if(t.tagName==="TEXTAREA")return!0;if(t.tagName==="INPUT"){let o=t.type||"text";return eb.has(o)}return!!(t.isContentEditable||t.closest('[contenteditable="true"]'))},Td=e=>{let t=e.target;return t instanceof Element&&t.tagName==="IFRAME"};import{atom as ab,useAtom as sb,useSetAtom as ib}from"jotai";import{isEmpty as Nd,set as lb}from"lodash-es";import{useCallback as Ed}from"react";import{toast as Xs}from"sonner";import{atom as tb,useAtom as ob,useSetAtom as rb}from"jotai";import{useCallback as nb}from"react";var Zs=tb([]),ya=()=>{let[e,t]=ob(Zs),o=rb(Ys),r=nb(n=>{t(n),o([])},[t,o]);return[e,r]};var Ys=ab([]),Bd=()=>{let[e]=Ce(),[t,o]=sb(Ys),r=ib(Zs),{getPartialBlocks:n}=rr(),a=M("flags.copyPaste",!0),s=Ed(l=>l.some(c=>Lr(e,c,null).some(p=>p._type==="PartialBlock"||p._type==="GlobalBlock")),[e]),i=Ed(async(l,c=!1)=>{try{if(Nd(l))return;o(l),r([]);let d={_chai_copied_blocks:l.flatMap(p=>{let h=Lr(e,p,null);if(!c)return h;let u=[];for(let m of h)if(m._type==="PartialBlock"||m._type==="GlobalBlock"){let g=n(m.partialBlockId);m._parent&&(g==null?void 0:g.length)>0&&(g=g.map(f=>(Nd(f._parent)&&lb(f,"_parent",m._parent),f))),u=[...u,...g]}else u.push(m);return u})};if(!a)return;if(!navigator.clipboard){Xs.error("Clipboard not available.");return}Xs.promise(navigator.clipboard.writeText(JSON.stringify(d)),{success:"Blocks copied successfully",error:"Failed to copy blocks to clipboard"})}catch(d){Xs.error("Failed to copy blocks to clipboard"),console.error("Failed to copy blocks to clipboard:",d)}},[o,r,a,e,n]);return[t,i,s]};import{each as cb,filter as db,get as pb,isString as ub}from"lodash-es";import{useCallback as mb}from"react";var va=()=>{let[e]=Ce(),[,t]=W(),{addBlocks:o}=ye();return mb((r,n=null)=>{let a=[];cb(r,s=>{var h;let i=e.find(u=>u._id===s);n?n==="root"&&(n=null):n=(h=i==null?void 0:i._parent)!=null?h:null;let d=db(e,u=>ub(n)?u._parent===n:!u._parent).indexOf(i)+1,p=Lr(e,s,n);o(p,n!=null?n:void 0,d),a.push(pb(p,"0._id",""))}),t(a)},[o,e,t])};import{useAtomValue as yb}from"jotai";import{find as Id,first as vb,has as Dd,isEmpty as xb}from"lodash-es";import{useCallback as ti}from"react";import{toast as Vr}from"sonner";import{filter as Qs,find as fb,first as Ad,forEach as gb,has as qs}from"lodash-es";import{useCallback as Js}from"react";var hb=100,bb=(e,t,o,r,n)=>{let a=n,s=r||Ad(o),i,l=null;for(;s;){let c=fb(t,{_id:s});if(!c)break;if(yt(c._type,e)&&Kn(c._type,e)){if(i=c._id,l&&n===void 0){let p=Qs(t,{_parent:i}).findIndex(h=>h._id===l);p!==-1&&(a=p+1)}break}else l=s,s=c==null?void 0:c._parent}if(!i&&l&&n===void 0){let d=Qs(t,p=>!p._parent).findIndex(p=>p._id===l);d!==-1&&(a=d+1)}return{parentBlockId:i,insertPosition:a}},Le=()=>{let[e]=Ce(),[t,o]=W(),{addBlocks:r}=ye(),n=Js((i,l,c)=>bb(i,e,t,l,c),[e,t]),a=Js((i,l,c)=>{for(let u=0;u<i.length;u++){let{_id:m}=i[u];i[u]._id=In();let g=Qs(i,{_parent:m});for(let f=0;f<g.length;f++)g[f]._parent=i[u]._id}let d=Ad(i),{parentBlockId:p,insertPosition:h}=n(d._type,l,c);return i[0]._parent=p,gb(i,u=>{u!=null&&u._parent||(u._parent=p)}),r(i,p,h),o([d._id]),d},[r,n,o]);return{addCoreBlock:Js((i,l,c)=>{if(qs(i,"blocks")){let f=i.blocks;return a(f,l!=null?l:void 0,c)}let d=In(),p=tr(i.type),h={_type:i.type,_id:d,...p,...qs(i,"_name")&&{_name:i._name},...qs(i,"partialBlockId")&&{partialBlockId:i.partialBlockId}},{parentBlockId:u,insertPosition:m}=n(h._type,l,c);return h._parent=u,r([h],u,m),setTimeout(()=>o([h._id]),hb),h},[r,a,n,o]),addPredefinedBlock:a}};var ei=()=>navigator.userAgent.toLowerCase().includes("firefox"),Cb=()=>{let[e]=Ce();return(t,o)=>{var a;let r=((a=Id(e,{_id:o}))==null?void 0:a._type)||null,n=vb(t.map(s=>{var i;return(i=Id(e,{_id:s}))==null?void 0:i._type}));return yt(r,n)}},kb=()=>{let e=yb(he),{moveBlocks:t}=ye();return ti((o,r)=>{let n=Array.isArray(r)?r[0]:r;if(r==="root"){let a=e==null?void 0:e.filter(s=>!s._parent);t(o,void 0,(a==null?void 0:a.length)||0)}else{let a=e==null?void 0:e.filter(s=>s._parent===n);t(o,n,(a==null?void 0:a.length)||0)}},[t,e])},_d=()=>{let[e,t]=ya(),o=kb(),{addPredefinedBlock:r}=Le(),n=Cb();return{canPaste:ti(async s=>{if(e.length>0)return n(e,s);if(ei())return!1;try{let i=await navigator.clipboard.readText();if(i){let l=JSON.parse(i);return Dd(l,"_chai_copied_blocks")}}catch(i){return!1}return!1},[n,e]),pasteBlocks:ti(async s=>{let i=Array.isArray(s)?s[0]:s;if(!xb(e)){o(e,s),t([]),ei()||await navigator.clipboard.writeText("");return}if(ei()){Vr.error("Paste is not supported in Firefox");return}if(!(navigator!=null&&navigator.permissions)){Vr.error("Cannot check clipboard permissions.");return}try{if((await navigator.permissions.query({name:"clipboard-read"})).state==="denied"){Vr.error("Clipboard paste permission denied. Please allow clipboard access.");return}}catch(l){Vr.error("Failed to check clipboard permissions. Please allow clipboard access.");return}Vr.promise(async()=>{let l=await navigator.clipboard.readText();if(l){let c=JSON.parse(l);if(Dd(c,"_chai_copied_blocks"))r(c._chai_copied_blocks,i==="root"?null:i);else throw new Error("Nothing to paste")}else throw new Error("Nothing to paste")},{success:()=>"Blocks pasted successfully",error:()=>"Nothing to paste"})},[e,o,t,r])}};var Ld=e=>{var n,a,s;let t=e.target,o=(s=(a=(n=e.view)==null?void 0:n.getSelection)==null?void 0:a.call(n))!=null?s:window.getSelection();return!!o&&!o.isCollapsed?!0:!!(t&&(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable||t.closest('[contenteditable="true"], [data-allow-native-copy="true"]')))},xa=e=>{let[t,o]=W(),r=$(),n=Vn(),a=va(),{undo:s,redo:i}=so(),[,l]=ya(),[,c]=Bd(),{canPaste:d,pasteBlocks:p}=_d(),{savePage:h}=$t(),u=Sb(({checkForEnabled:m,preventDefault:g,ignoreTextEntry:f=!0,enableOnContentEditable:b=!1})=>{let y={enableOnFormTags:!0,enableOnContentEditable:b,ignoreEventWhen:k=>Td(k)||f&&Sd(k)};return e&&(y.document=e),m&&(y.enabled=!Pd(t)),g&&(y.preventDefault=!0),y},[e,t]);Zt("ctrl+z,meta+z",m=>{m.preventDefault(),Os.hasUndo()&&s()},u({checkForEnabled:!1,preventDefault:!0}),[e,s]),Zt("ctrl+y,meta+y,ctrl+shift+z,meta+shift+z",m=>{m.preventDefault(),Os.hasRedo()&&i()},u({checkForEnabled:!1,preventDefault:!0}),[e,i]),Zt("ctrl+x,meta+x",m=>{Ld(m)||(m.preventDefault(),Pd(t)||l(t))},u({checkForEnabled:!0,preventDefault:!1}),[e,l,t]),Zt("ctrl+c,meta+c",m=>{Ld(m)||(m.preventDefault(),c(t))},u({checkForEnabled:!0,preventDefault:!1}),[e,c,t]),Zt("ctrl+v,meta+v",async()=>{await d(t[0])&&p(t)},u({checkForEnabled:!0,preventDefault:!1}),[e,d,t,p]),Zt("esc",()=>{var g;let m=(g=(e!=null?e:document).activeElement)!=null?g:null;if(m&&(m.matches("input, textarea, select")||m.isContentEditable)){m.blur();return}o([])},u({checkForEnabled:!1,preventDefault:!1,ignoreTextEntry:!1,enableOnContentEditable:!0}),[e,o]),Zt("ctrl+d,meta+d",()=>{a(t)},u({checkForEnabled:!0,preventDefault:!0}),[e,t,a]),Zt("del, backspace",()=>{jn(wb(r,"_type",""))&&n(t)},u({checkForEnabled:!1,preventDefault:!0}),[e,t,n]),Zt("mod+s",()=>{h()},u({checkForEnabled:!1,preventDefault:!0,ignoreTextEntry:!1,enableOnContentEditable:!0}),[e,h])};import{Cross1Icon as xl,LightningBoltIcon as AN}from"@radix-ui/react-icons";import{motion as Rs}from"framer-motion";import{find as Dr,first as IN,get as q,reverse as DN}from"lodash-es";import{ChevronLeft as Fg,ChevronRight as Vg}from"lucide-react";import _r,{createElement as zg,Suspense as jo,useCallback as wn,useEffect as $g,useMemo as Sn,useState as Cl}from"react";import{useTranslation as _N}from"react-i18next";import{noop as sk}from"lodash-es";import ik,{Suspense as ju}from"react";import{ErrorBoundary as lk}from"react-error-boundary";import{isEmpty as SC}from"lodash-es";import{useCallback as TC,useEffect as NC,useMemo as EC,useRef as Du,useState as BC}from"react";import{Provider as AC}from"react-wrap-balancer";import{flip as My,limitShift as Hy,size as Oy}from"@floating-ui/dom";import{shift as Fy,useFloating as Vy}from"@floating-ui/react-dom";import{ArrowUpIcon as zy,CopyIcon as $y,DragHandleDots2Icon as Wy,PlusIcon as Uy,TrashIcon as Gy}from"@radix-ui/react-icons";import{useResizeObserver as up}from"@react-hookz/web";import{get as lr,isEmpty as Ky}from"lodash-es";import{useCallback as kt,useEffect as Ia,useMemo as jy,useState as bi}from"react";import{noop as Tb}from"lodash-es";import{jsx as Rd}from"react/jsx-runtime";var Md=({className:e="h-full w-full",onClick:t=Tb})=>Rd("svg",{className:e,viewBox:"0 0 256 256",fill:"currentColor",onClick:t,children:Rd("path",{d:"m198.39 128.986-52.16-19.216-19.216-52.16a16 16 0 0 0-30.028 0L77.77 109.77l-52.16 19.216a16 16 0 0 0 0 30.028l52.16 19.216 19.216 52.16a16 16 0 0 0 30.028 0l19.216-52.16 52.16-19.216a16 16 0 0 0 0-30.028m-57.69 34.23a15.97 15.97 0 0 0-9.483 9.483l-19.22 52.152-19.214-52.15a15.97 15.97 0 0 0-9.482-9.484l-52.152-19.22 52.15-19.214a15.97 15.97 0 0 0 9.484-9.482l19.22-52.152 19.214 52.15a15.97 15.97 0 0 0 9.482 9.484l52.152 19.22ZM144 40a8 8 0 0 1 8-8h16V16a8 8 0 0 1 16 0v16h16a8 8 0 0 1 0 16h-16v16a8 8 0 0 1-16 0V48h-16a8 8 0 0 1-8-8m104 48a8 8 0 0 1-8 8h-8v8a8 8 0 0 1-16 0v-8h-8a8 8 0 0 1 0-16h8v-8a8 8 0 0 1 16 0v8h8a8 8 0 0 1 8 8"})});import{filter as Nb,findIndex as Eb,get as zr}from"lodash-es";import{useTranslation as Bb}from"react-i18next";import{jsx as Ca,jsxs as Hd}from"react/jsx-runtime";var Ab=({block:e,children:t})=>{let{t:o}=Bb(),{hasPermission:r}=Ve(),n=zr(e,"_id"),a=zr(e,"_parent"),s=Gn(zr(e,"_type","")),i=l=>{if(l==="CHILD")J.publish(U.OPEN_ADD_BLOCK,e);else{let c=L.get(he),d=Nb(c,u=>a?zr(u,"_parent")===a:!zr(u,"_parent")),p=Eb(d,{_id:n}),h={_id:a||"",position:d==null?void 0:d.length};l==="BEFORE"?h.position=Math.max(p,0):l==="AFTER"&&(h.position=p+1),J.publish(U.OPEN_ADD_BLOCK,h)}};return r(be["pages:update"])?Hd(ot,{children:[Ca(rt,{children:t}),Hd(nt,{className:"border border-blue-500 bg-primary text-white shadow-2xl",children:[s&&Ca(Pe,{className:"cursor-pointer text-xs",onClick:()=>i("CHILD"),children:o("Add inside")}),Ca(Pe,{className:"cursor-pointer text-xs",onClick:()=>i("BEFORE"),children:o("Add before")}),Ca(Pe,{className:"cursor-pointer text-xs",onClick:()=>i("AFTER"),children:o("Add after")})]})]}):null},Od=Ab;import{useAtom as oy}from"jotai";import{useAtom as ri}from"jotai";import{useCallback as _b}from"react";import{useCallback as Fd,useMemo as Ib}from"react";var re=null,Yt=null;function Db(e,t){let o=e.getAttribute("data-block-name"),r=e.getAttribute("data-block-type"),n=o||r||"Container",a=t.createElement("div");return a.className="chai-drag-parent-label",a.textContent=n,a.className="absolute top-0 -left-0.5 -translate-x-0.5 -translate-y-full -mt-1 bg-green-500/95 text-white px-2 py-1 text-xs font-semibold font-sans leading-tight whitespace-nowrap shadow-lg z-[999999] pointer-events-none select-none",a}function oi(){Yt&&Yt.parentNode&&(Yt.parentNode.removeChild(Yt),Yt=null)}var Po=()=>{let[e]=dt(),t=Ib(()=>{var n;return(e==null?void 0:e.contentDocument)||((n=e==null?void 0:e.contentWindow)==null?void 0:n.document)},[e]),o=Fd(n=>{if(!t)return;let a=null;if(!n){re&&(re.style.outline="",re.style.outlineOffset="",re.style.backgroundColor="",re.style.position="",re=null),oi();return}typeof n!="string"?a=n:a=t.querySelector(`[data-block-id="${n}"]`),!(a===re&&Yt&&Yt.parentNode)&&(re&&re!==a&&(re.style.outline="",re.style.outlineOffset="",re.style.backgroundColor="",re.style.position=""),oi(),a?(a.style.outline="2px dashed rgba(34, 197, 94, 1)",a.style.outlineOffset="2px",a.style.backgroundColor="rgba(34, 197, 94, 0.05)",window.getComputedStyle(a).position==="static"&&(a.style.position="relative"),Yt=Db(a,t),a.appendChild(Yt),re=a):re=null)},[t]),r=Fd(()=>{re&&(re.style.outline="",re.style.outlineOffset="",re.style.backgroundColor="",window.getComputedStyle(re).position==="relative"&&re.style.position==="relative"&&(re.style.position=""),re=null),oi()},[]);return{highlightParent:o,clearParentHighlight:r,lastDragHighlighted:re}};var ni=()=>{let[,e]=ri(bt),[,t]=ri(Qe),[o]=dt(),{clearParentHighlight:r}=Po(),[n,a]=ri(Do),s=o==null?void 0:o.contentDocument;return _b(()=>{e(null),t({isVisible:!1,isValid:!1,position:"inside",placeholderOrientation:"horizontal",isEmpty:!1,top:0,left:0,width:0,height:0}),Pb(s),r(),s&&s.querySelectorAll("[data-dragging]").forEach(l=>{l.removeAttribute("data-dragging")}),Io(!1),a(n+1)},[e,t,s,r,n,a])};function Pb(e){if(!e)return;e.querySelectorAll("[data-drop-target]").forEach(o=>o.removeAttribute("data-drop-target"))}import{useAtom as jd}from"jotai";import{useCallback as pi,useEffect as ui,useRef as $r}from"react";var xt=e=>{var t;return((t=e.ownerDocument.defaultView)!=null?t:window).getComputedStyle(e)};function Ct(e,t=null){let o=xt(e),r=t?xt(t):null,n=o.display,a=r?r.display:null;if(n==="flex"||n==="inline-flex"){let s=o.flexDirection;return s==="column"||s==="column-reverse"?"vertical":"horizontal"}else if(n==="grid"){let s=o.gridAutoFlow,i=o.gridTemplateColumns;return s.includes("column")||i&&i!=="none"&&i!==""&&!i.includes("calc")&&i.split(" ").length<=1?"vertical":"horizontal"}else if(a==="inline-block"||a==="inline")return"horizontal";return"vertical"}var Lb=["Heading","Text","Image","Paragraph","Icon","Input","Radio","Checkbox","Select","CustomHTML","TextArea","Divider","Repeater","Video"];function Rb(e){try{return Lb.includes(e)}catch(t){return!1}}var Dt={MIN_EDGE_ZONE:10,MAX_EDGE_ZONE:30,EDGE_ZONE_PERCENTAGE:.2,GAP_THRESHOLD:8,MIN_SIZE_FOR_EDGE_ZONES:50,PARENT_EDGE_PROXIMITY:20},ai=new WeakMap;function Mb(){ai=new WeakMap}function Y(e){let t=ai.get(e);return t||(t=e.getBoundingClientRect(),ai.set(e,t)),t}function Vd(e){try{if(e<Dt.MIN_SIZE_FOR_EDGE_ZONES)return 0;let t=e*Dt.EDGE_ZONE_PERCENTAGE;return Math.max(Dt.MIN_EDGE_ZONE,Math.min(Dt.MAX_EDGE_ZONE,t))}catch(t){return Dt.MIN_EDGE_ZONE}}function bo(e){try{let t=[],o=e.children;for(let r=0;r<o.length;r++){let n=o[r];n.hasAttribute("data-block-id")&&t.push(n)}return t}catch(t){return[]}}function ka(e){try{return bo(e).length>0}catch(t){return!1}}function Hb(e,t,o,r){try{let n=bo(e);if(n.length<2)return null;let a=Vb(n,t,o,r);if(a){let s=si(n,a,r);s.sort((i,l)=>{let c=Y(i),d=Y(l);return r==="vertical"?c.top-d.top:c.left-d.left});for(let i=0;i<s.length-1;i++){let l=s[i],c=s[i+1],d=Y(l),p=Y(c);if(r==="vertical"){let h=d.bottom,u=p.top,m=u-h,g=o>=h&&o<=u,f=t>=Math.min(d.left,p.left)&&t<=Math.max(d.right,p.right);if(g&&f&&m>=Dt.GAP_THRESHOLD)return{before:l,after:c}}else{let h=d.right,u=p.left,m=u-h,g=t>=h&&t<=u,f=o>=Math.min(d.top,p.top)&&o<=Math.max(d.bottom,p.bottom);if(g&&f&&m>=Dt.GAP_THRESHOLD)return{before:l,after:c}}}}for(let s=0;s<n.length-1;s++){let i=n[s],l=n[s+1],c=Y(i),d=Y(l);if(r==="vertical"){let p=c.bottom,h=d.top,u=h-p,m=o>=p&&o<=h,g=t>=Math.min(c.left,d.left)&&t<=Math.max(c.right,d.right);if(m&&g&&u>=Dt.GAP_THRESHOLD)return{before:i,after:l}}else{let p=c.right,h=d.left,u=h-p,m=t>=p&&t<=h,g=o>=Math.min(c.top,d.top)&&o<=Math.max(c.bottom,d.bottom);if(m&&g&&u>=Dt.GAP_THRESHOLD)return{before:i,after:l}}}return null}catch(n){return null}}function Ob(e,t,o,r){try{let n=Y(e),a=Dt.PARENT_EDGE_PROXIMITY;if(r==="vertical"){if(o<=n.top+a)return"start";if(o>=n.bottom-a)return"end"}else{if(t<=n.left+a)return"start";if(t>=n.right-a)return"end"}return null}catch(n){return null}}function Fb(e,t,o,r,n){let a=Y(e);if(n==="vertical"){let i=(o-a.top)/a.height,l=Vd(a.height),c=l/a.height;return r?l>0&&i<c?{position:"before",confidence:1-i/c}:l>0&&i>1-c?{position:"after",confidence:(i-(1-c))/c}:{position:"inside",confidence:1-Math.abs(i-.5)*2}:i<.5?{position:"before",confidence:1-i*2}:{position:"after",confidence:(i-.5)*2}}else{let i=(t-a.left)/a.width,l=Vd(a.width),c=l/a.width;return r?l>0&&i<c?{position:"before",confidence:1-i/c}:l>0&&i>1-c?{position:"after",confidence:(i-(1-c))/c}:{position:"inside",confidence:1-Math.abs(i-.5)*2}:i<.5?{position:"before",confidence:1-i*2}:{position:"after",confidence:(i-.5)*2}}}function zd(e,t,o,r,n){var k,v,S,E;Mb();let a=e.getAttribute("data-block-id"),s=e.getAttribute("data-block-type")||"Box";if(!a)return null;let i=e.parentElement;for(;i&&!i.hasAttribute("data-block-id");)i=i.parentElement;let l=a==="canvas"?a:i==null?void 0:i.getAttribute("data-block-id"),c=i?Ct(i):"vertical",d=Ct(e),p=Rb(s),h=!p&&yt(s,r),u=((k=n.defaultView)==null?void 0:k.scrollY)||0,m=((v=n.defaultView)==null?void 0:v.scrollX)||0;if(a==="canvas"&&ka(e)){let x=bo(e),B=x[x.length-1];if(B){let I=Y(B),N=Y(e),T=xt(e),C=parseFloat(T.paddingLeft)||0,w=parseFloat(T.paddingRight)||0,A=N.width-C-w,_=N.left+m+C;return{position:"after",placeholderOrientation:"horizontal",rect:{top:I.bottom+u,left:_,width:A,height:4},targetElement:B,targetBlockId:B.getAttribute("data-block-id"),targetParentId:"canvas",isEmpty:!1,confidence:1}}}if(h&&!p&&ka(e)){let x=Hb(e,t,o,d);if(x){let B=Y(x.before),I=Y(x.after),N=Y(e),T=xt(e),C=parseFloat(T.paddingLeft)||0,w=parseFloat(T.paddingRight)||0,A=bo(e),_=si(A,x.before,d),Z=0;if(_.forEach(ae=>{let O=Y(ae);O.height>Z&&(Z=O.height)}),d==="vertical"){let ae=N.width-C-w,O=N.left+m+C;return{position:"after",placeholderOrientation:"horizontal",rect:{top:B.bottom+u,left:O,width:ae,height:4},targetElement:x.before,targetBlockId:x.before.getAttribute("data-block-id"),targetParentId:a,isGapZone:!0,confidence:1}}else{let ae=B.top+u,O=Z>0?Z:Math.max(B.height,I.height);return{position:"after",placeholderOrientation:"vertical",rect:{top:ae,left:B.right+m,width:4,height:O},targetElement:x.before,targetBlockId:x.before.getAttribute("data-block-id"),targetParentId:a,isGapZone:!0,confidence:1}}}}if(i&&l){let x=Ob(i,t,o,c);if(x){let B=Y(i),I=xt(i),N=parseFloat(I.paddingLeft)||0,T=parseFloat(I.paddingRight)||0,C=parseFloat(I.paddingTop)||0,w=parseFloat(I.paddingBottom)||0,A=((S=n.defaultView)==null?void 0:S.scrollY)||0,_=((E=n.defaultView)==null?void 0:E.scrollX)||0,Z=c==="vertical"?"horizontal":"vertical",ae=$d(i);if(x==="start"){let O=bo(i)[0];if(O){let X=Y(O);if(c==="vertical"){let Fe=B.width-N-T,Je=B.left+_+N;return{position:"before",placeholderOrientation:Z,rect:{top:X.top+A-2,left:Je,width:Fe,height:4},targetElement:O,targetBlockId:O.getAttribute("data-block-id"),targetParentId:l,confidence:.9}}else{let Fe=B.top+A+C,Je=ae.maxHeight>0?ae.maxHeight:B.height-C-w;return{position:"before",placeholderOrientation:Z,rect:{top:Fe,left:X.left+_-2,width:4,height:Je},targetElement:O,targetBlockId:O.getAttribute("data-block-id"),targetParentId:l,confidence:.9}}}}else{let O=bo(i),X=O[O.length-1];if(X){let Fe=Y(X);if(c==="vertical"){let Je=B.width-N-T,Vt=B.left+_+N;return{position:"after",placeholderOrientation:Z,rect:{top:Fe.bottom+A-2,left:Vt,width:Je,height:4},targetElement:X,targetBlockId:X.getAttribute("data-block-id"),targetParentId:l,confidence:.9}}else{let Je=B.top+A+C,Vt=ae.maxHeight>0?ae.maxHeight:B.height-C-w;return{position:"after",placeholderOrientation:Z,rect:{top:Je,left:Fe.right+_-2,width:4,height:Vt},targetElement:X,targetBlockId:X.getAttribute("data-block-id"),targetParentId:l,confidence:.9}}}}}}let g=Fb(e,t,o,h,c);if(p&&g.position==="inside"){let x=Y(e);c==="vertical"?g={position:(o-x.top)/x.height<.5?"before":"after",confidence:g.confidence}:g={position:(t-x.left)/x.width<.5?"before":"after",confidence:g.confidence}}let f;g.position==="inside"?f=d==="vertical"?"horizontal":"vertical":f=c==="vertical"?"horizontal":"vertical";let b=zb(e,i,g.position,f,n),y=g.position==="inside"?a:l;return{position:g.position,placeholderOrientation:f,rect:b,targetElement:e,targetBlockId:a,targetParentId:y!=null?y:"",isEmpty:g.position==="inside"&&!ka(e),confidence:g.confidence}}function Vb(e,t,o,r){if(e.length===0)return null;let n=e.filter(i=>{let l=Y(i);return r==="vertical"?o>=l.top&&o<=l.bottom:t>=l.left&&t<=l.right});if(n.length===0){let i=new Map;e.forEach(d=>{let p=Y(d),h=Math.round(r==="vertical"?p.top:p.left);i.has(h)||i.set(h,[]),i.get(h).push(d)});let l=null,c=1/0;i.forEach((d,p)=>{let h=Math.abs(r==="vertical"?o-p:t-p);h<c&&(c=h,l=d)}),l&&n.push(l)}if(n.length===0)return null;let a=n[0],s=1/0;return n.forEach(i=>{let l=Y(i),c=l.left+l.width/2,d=l.top+l.height/2,p=Math.sqrt(Math.pow(t-c,2)+Math.pow(o-d,2));p<s&&(s=p,a=i)}),a}function $d(e){let t=bo(e);if(t.length===0)return{maxWidth:0,maxHeight:0};let o=0,r=0;return t.forEach(n=>{let a=Y(n);a.width>o&&(o=a.width),a.height>r&&(r=a.height)}),{maxWidth:o,maxHeight:r}}function si(e,t,o){let r=Y(t),n=5;return e.filter(a=>{let s=Y(a);return o==="vertical"?Math.abs(s.top-r.top)<=n:Math.abs(s.left-r.left)<=n})}function zb(e,t,o,r,n){var C,w;let a=Y(e),s=xt(e),i=((C=n.defaultView)==null?void 0:C.scrollY)||0,l=((w=n.defaultView)==null?void 0:w.scrollX)||0,c=parseFloat(s.marginTop)||0,d=parseFloat(s.marginBottom)||0,p=parseFloat(s.marginLeft)||0,h=parseFloat(s.marginRight)||0,u=parseFloat(s.paddingTop)||0,m=parseFloat(s.paddingBottom)||0,g=parseFloat(s.paddingLeft)||0,f=parseFloat(s.paddingRight)||0,b=t?Y(t):void 0,y=t&&parseFloat(xt(t).paddingLeft)||0,k=t&&parseFloat(xt(t).paddingRight)||0,v=t&&parseFloat(xt(t).paddingTop)||0,S=t&&parseFloat(xt(t).paddingBottom)||0,E=t?$d(t):{maxWidth:0,maxHeight:0},x=t?Ct(t):"vertical",B=t?bo(t):[],I=si(B,e,x),N=0,T=0;if(I.forEach(A=>{let _=Y(A);_.height>N&&(N=_.height),_.width>T&&(T=_.width)}),o==="before")if(r==="horizontal"){let A=b?b.width-y-k:a.width,_=b?b.left+l+y:a.left+l;return{top:a.top+i-c-2,left:_,width:A,height:4}}else{let A=a.top+i,_=x==="horizontal"&&N>0?N:E.maxHeight>0?E.maxHeight:b?b.height-v-S:a.height;return{top:A,left:a.left+l-p-2,width:4,height:_}}else if(o==="after")if(r==="horizontal"){let A=b?b.width-y-k:a.width,_=b?b.left+l+y:a.left+l;return{top:a.bottom+i+d-2,left:_,width:A,height:4}}else{let A=a.top+i,_=x==="horizontal"&&N>0?N:E.maxHeight>0?E.maxHeight:b?b.height-v-S:a.height;return{top:A,left:a.right+l+h-2,width:4,height:_}}else return ka(e)?Ct(e)==="vertical"?{top:a.bottom+i-m-2,left:a.left+l+g,width:a.width-g-f,height:4}:{top:a.top+i+u,left:a.right+l-f-2,width:4,height:a.height-u-m}:{top:a.top+i+u,left:a.left+l+g,width:a.width-g-f,height:Math.max(a.height-u-m,20)}}import{useAtom as Wd,useSetAtom as $b}from"jotai";import{filter as wa,find as Wb,get as Gd,has as Ub,isFunction as Gb}from"lodash-es";import{useCallback as Kb}from"react";import{toast as jb}from"sonner";var ii=()=>{let[e,t]=Wd(bt),o=$b(Qe),[r]=dt(),{addCoreBlock:n}=Le(),{moveBlocks:a}=ye(),[,s]=W(),[,i]=K(),{clearHighlight:l}=Ie(),{clearParentHighlight:c}=Po(),[d,p]=Wd(Do),h=ze(),u=Hn(),m=r==null?void 0:r.contentDocument;return Kb(g=>{g.preventDefault(),g.stopPropagation();let f=L.get(Qe);if(Io(!1),Yb(m),Ud(m),c(),o({isVisible:!1,isValid:!1,position:"inside",placeholderOrientation:"horizontal",isEmpty:!1,top:0,left:0,width:0,height:0}),setTimeout(()=>{c(),Ud(m),o({isVisible:!1,isValid:!1,position:"inside",placeholderOrientation:"horizontal",isEmpty:!1,top:0,left:0,width:0,height:0})},50),!e)return;if(!f.isValid||!f.targetBlockId){c();return}t(null);let b=f.targetBlockId,y=f.targetParentId;if(!b)return;let k=L.get(he),{parentId:v,index:S,replaceImageUrl:E}=Zb(k,b,y,f.position,e),x=e._id!==void 0;if(E&&li(e)){h([b],{image:Gd(e,"blocks.0.image")}),setTimeout(()=>{p(d+1)},50);return}if(x)a([e._id],v===null?void 0:v,S),l(),i([]),s([e._id]);else{let B=e._type||e.type,I=e!=null&&e.blocks?Gb(e==null?void 0:e.blocks)?ao(e==null?void 0:e.blocks()):e==null?void 0:e.blocks:null;if(B==="PartialBlock"){let N=e.partialBlockId||"",{canAdd:T,reason:C}=u(N);if(!T){jb.error(C||"Cannot add this partial block");return}n({blocks:[{_type:B,_id:"partial-block",partialBlockId:e.partialBlockId}]},v,S)}else n((I==null?void 0:I.length)>0?{blocks:[...I]}:{type:B},v,S)}setTimeout(()=>{p(d+1)},50)},[e,m,n,a,t,o,c,l,s,i,d,p,h,u])},li=e=>{var a,s;let t=Ub(e,"blocks"),o=e==null?void 0:e.blocks,r=(o==null?void 0:o.length)===1&&((a=o==null?void 0:o[0])==null?void 0:a._type)==="Image",n=!((s=o==null?void 0:o[0])!=null&&s._id);return t&&r&&n};function Zb(e,t,o,r,n){var a,s;try{if(t===o&&((a=n==null?void 0:n.blocks)==null?void 0:a.length)===1&&Gd(n,"blocks.0._type")==="Image"&&((s=Wb(e,{_id:t}))==null?void 0:s._type)==="Image")return{parentId:"",index:-1,replaceImageUrl:!0};if(t==="canvas"||r==="inside"&&t==="canvas")return{parentId:null,index:wa(e,u=>!(u!=null&&u._parent)).length};if(r==="inside"){let h=wa(e,{_parent:t});return{parentId:t,index:h.length}}let i=!o||o==="canvas",l=i?void 0:o,c=wa(e,h=>i?!(h!=null&&h._parent):(h==null?void 0:h._parent)===l),d=c.findIndex(h=>h._id===t);if(d===-1)return{parentId:i?null:o,index:c.length};let p=r==="before"?d:d+1;return{parentId:i?null:o,index:p}}catch(i){return{parentId:null,index:wa(e,c=>!(c!=null&&c._parent)).length}}}function Ud(e){if(!e)return;e.querySelectorAll("[data-drop-target]").forEach(o=>o.removeAttribute("data-drop-target"))}function Yb(e){if(!e)return;e.querySelectorAll("[data-dragging]").forEach(o=>{o.removeAttribute("data-dragging")})}function ci(e,t,o){if(!e||!t)return!1;if(e===t)return!0;let r=o.find(a=>a._id===e);if(!r)return!1;let n=r;for(;n._parent;){if(n._parent===t)return!0;let a=o.find(s=>s._id===n._parent);if(!a)break;n=a}return!1}function di(e,t,o){return!e||!t?!0:!ci(t,e,o)}function Kd(e,t,o){if(!e)return!0;let r=o.find(a=>a._id===t);if(!r)return!0;let n=r._parent;return di(e,n,o)}var Xb=["Heading","Text","Image","Paragraph","Icon","Input","Radio","Checkbox","Select","CustomHTML","TextArea","Divider","Repeater","Video"],yo={EDGE_ZONE:50,MAX_SCROLL_SPEED:10,MIN_SCROLL_SPEED:10},mi=()=>{let[e]=jd(bt),[t]=dt(),[,o]=jd(Qe),{clearParentHighlight:r,highlightParent:n}=Po(),a=t==null?void 0:t.contentDocument,s=$r(null),i=$r(0),l=pi(u=>{if(!(a!=null&&a.defaultView))return;let m=a.defaultView,g=m.innerHeight,f=m.scrollY,b=a.documentElement.scrollHeight;i.current=u;let y=u,k=g-u,v=!1,S=null,E=0;if(y<yo.EDGE_ZONE&&f>0?(v=!0,S="up",E=y):k<yo.EDGE_ZONE&&f+g<b&&(v=!0,S="down",E=k),!v&&s.current!==null){cancelAnimationFrame(s.current),s.current=null;return}if(v&&S){let x=1-E/yo.EDGE_ZONE,B=yo.MIN_SCROLL_SPEED+(yo.MAX_SCROLL_SPEED-yo.MIN_SCROLL_SPEED)*x,I=()=>{if(!Ao||!m){s.current=null;return}let N=S==="up"?-B:B;m.scrollBy(0,N);let T=m.scrollY,C=T>0,w=T+g<b,A=i.current,_=g-i.current;S==="up"&&C&&A<yo.EDGE_ZONE||S==="down"&&w&&_<yo.EDGE_ZONE?s.current=requestAnimationFrame(I):s.current=null};s.current===null&&(s.current=requestAnimationFrame(I))}},[a]);ui(()=>()=>{s.current!==null&&(cancelAnimationFrame(s.current),s.current=null)},[]),ui(()=>{!Ao&&s.current!==null&&(cancelAnimationFrame(s.current),s.current=null)},[]);let c=pi(u=>{var C,w,A;if(!Ao||!e)return;r();let m=qb(u.target),{element:g,targetBlockId:f,targetParentId:b}=m;if(!g||!f)return;let y=e._id,k=L.get(he);if(y&&(f===y||ci(f,y,k)))return;let v=e._type||e.type;if(!v)return;let S=u.clientX,E=u.clientY;if(l(E),!a)return;let x=zd(g,S,E,v,a);if(!x)return;let B=g.getAttribute("data-block-type")||"Box",I=!1,N=Xb.includes(B);if(B==="Image"&&v==="Image"&&li(e)){n(f);let _=((C=a.defaultView)==null?void 0:C.scrollY)||0,Z=((w=a.defaultView)==null?void 0:w.scrollX)||0,ae=g.getBoundingClientRect();o({isVisible:!0,isValid:!0,position:x.position,placeholderOrientation:x.placeholderOrientation,isEmpty:!0,top:ae.top+_,left:ae.left+Z,width:ae.width,height:ae.height,targetBlockId:x.targetBlockId,targetParentId:x.targetBlockId});return}if(x.position==="inside"){if(N||y&&!di(y,f,k))return;I=yt(B,v)}else{let _=g.parentElement,Z="Box";for(;_&&!_.hasAttribute("data-block-id");)_=_.parentElement;if(_&&(Z=_.getAttribute("data-block-type")||"Box"),y&&!Kd(y,f,k))return;I=yt(Z,v)}if(!I)return;n(x.targetParentId);let T=x.targetParentId||b||void 0;o({isVisible:!0,isValid:!0,position:x.position,placeholderOrientation:x.placeholderOrientation,isEmpty:(A=x.isEmpty)!=null?A:!1,top:x.rect.top,left:x.rect.left,width:x.rect.width,height:x.rect.height,targetBlockId:x.targetBlockId,targetParentId:T}),Jb(x.targetElement)},[a,e,o,r,n,l]),d=$r(c);d.current=c;let p=$r(null),h=$r(null);return ui(()=>()=>{h.current!==null&&(cancelAnimationFrame(h.current),h.current=null)},[]),pi(u=>{u.preventDefault(),u.stopPropagation(),p.current={target:u.target,clientX:u.clientX,clientY:u.clientY},h.current===null&&(h.current=requestAnimationFrame(()=>{h.current=null;let m=p.current;p.current=null,m&&d.current(m)}))},[])};function qb(e){let t=e;for(;t&&!t.hasAttribute("data-block-id");)t=t.parentElement;if(!t)return{element:null,targetBlockId:null,targetBlockType:null,targetParentId:null,targetParentType:null,orientation:"vertical"};let o=t.getAttribute("data-block-id"),r=t.getAttribute("data-block-type")||"Box",n=t.parentElement;for(;n&&!n.hasAttribute("data-block-id");)n=n.parentElement;let a=(n==null?void 0:n.getAttribute("data-block-id"))||null,s=(n==null?void 0:n.getAttribute("data-block-type"))||"Box",i=Ct(t);return{element:t,targetBlockId:o,targetBlockType:r,targetParentId:a,targetParentType:s,orientation:i}}var Sa=null;function Jb(e){Sa!==e&&(Sa&&Sa.removeAttribute("data-drop-target"),e.setAttribute("data-drop-target","true"),Sa=e)}import{useAtom as Yd}from"jotai";import{pick as Qb}from"lodash-es";import{useCallback as ey,useRef as ty}from"react";function Zd(e){var a;let t=document.createElement("div");t.className="absolute -top-[1000px] -left-[1000px] pl-3 pr-1 py-1 bg-white/60 border border-blue-400/30 rounded shadow-md flex items-center gap-1.5 font-sans pointer-events-none z-[9999] scale-90";let o=e.type||e._type||"Box",r=document.createElement("div");r.className="w-3 h-3 flex items-center justify-center text-blue-600";try{o==="Image"?r.innerHTML='<svg class="w-3 h-3" fill="currentColor" viewBox="0 0 0.72 0.72"><path d="M.57.12H.15a.09.09 0 0 0-.09.09v.3A.09.09 0 0 0 .15.6h.42A.09.09 0 0 0 .66.51v-.3A.09.09 0 0 0 .57.12M.15.54A.03.03 0 0 1 .12.51V.437L.219.338a.03.03 0 0 1 .042 0L.462.54ZM.6.51a.03.03 0 0 1-.03.03H.547L.433.425.459.399a.03.03 0 0 1 .042 0L.6.498Zm0-.097L.544.357a.09.09 0 0 0-.127 0L.391.383.305.297a.09.09 0 0 0-.127 0L.12.353V.21A.03.03 0 0 1 .15.18h.42A.03.03 0 0 1 .6.21Z"/></svg>':r.innerHTML=((a=document.querySelector(`[data-add-core-block-icon="${o}"]`))==null?void 0:a.outerHTML)||'<svg class="w-3 h-3" fill="currentColor" viewBox="0 0 20 20"><path d="M3 4a1 1 0 011-1h12a1 1 0 011 1v12a1 1 0 01-1 1H4a1 1 0 01-1-1V4z"/></svg>'}catch(s){r.textContent=""}let n=document.createElement("span");return n.className="text-[10px] font-medium text-blue-600 whitespace-nowrap",n.textContent=e.label||e.type||e._name||e._type||"Block",t.appendChild(r),t.appendChild(n),document.body.appendChild(t),t}function fi(e){e&&e.parentNode&&e.parentNode.removeChild(e)}var gi=()=>{let[,e]=W(),[,t]=K(),{clearHighlight:o}=Ie(),[,r]=Yd(bt),[,n]=Yd(Qe),a=ty(null);return ey((s,i,l=!0)=>{var d;a.current&&(fi(a.current),a.current=null);let c=l?Qb(i,["type","blocks","partialBlockId"]):i;if(r(c),s.dataTransfer.setData("text/plain",JSON.stringify({block:c})),s.dataTransfer.effectAllowed="move",!l&&i._id){let p=(d=document.getElementById("canvas-iframe"))==null?void 0:d.contentDocument;if(p){let h=p.querySelector(`[data-block-id="${i._id}"]`);h&&setTimeout(()=>{if(h&&h.parentElement){let m=h.getBoundingClientRect().height;(h.parentElement&&Ct(h.parentElement))==="vertical"&&m>200&&(h.style.height="max-content",h.style.maxHeight="max-content",h.style.minHeight="0",h.style.overflow="hidden",h.innerHTML="<div class='flex items-center justify-center w-full h-full outline-[1px] outline-dashed font-medium outline-gray-500 bg-gray-500/10 py-4 text-transparent'>-</div>",h.style.opacity="0.4"),h.style.opacity="0.4",h.setAttribute("data-dragging","true")}},0)}}if(i!=null&&i._type||i!=null&&i.type){let p=Zd(i);a.current=p,s.dataTransfer.setDragImage(p,0,0),setTimeout(()=>{a.current&&(fi(a.current),a.current=null)},50)}e([]),o(),t([]),J.publish(U.CLOSE_ADD_BLOCK),Io(!0),n({isVisible:!0,isValid:!0,position:"inside",placeholderOrientation:"horizontal",isEmpty:!0,top:0,left:0,width:0,height:0,targetBlockId:"canvas",targetParentId:void 0})},[r,e,o,t,n])};var pt=()=>{let e=gi(),t=mi(),o=ii(),r=ni();return{onDragStart:e,onDragOver:t,onDrop:o,onDragEnd:r,isDragging:Ao}},Xd=()=>{let[e]=oy(Qe);return e},Re=()=>{let{dragAndDrop:e}=M("flags",{dragAndDrop:!0});return e};import{PinBottomIcon as ny,PinLeftIcon as ay,PinRightIcon as sy,PinTopIcon as iy}from"@radix-ui/react-icons";import{filter as ly,findIndex as cy,get as Ta}from"lodash-es";import{useCallback as dy}from"react";import qd from"react";var Jd,Qd;typeof document!="undefined"&&(Jd=document);typeof window!="undefined"&&(Qd=window);var hi=qd.createContext({document:Jd,window:Qd}),ie=()=>qd.useContext(hi),{Provider:ep,Consumer:ry}=hi;import{Fragment as gy,jsx as tp}from"react/jsx-runtime";var py=[{ControlIcon:iy,dir:"VERTICAL",key:"UP"},{ControlIcon:ny,dir:"VERTICAL",key:"DOWN"},{ControlIcon:ay,dir:"HORIZONTAL",key:"LEFT"},{ControlIcon:sy,dir:"HORIZONTAL",key:"RIGHT"}],uy=(e,t,o)=>{try{if(!e||!o)return"VERTICAL";let r=`[data-block-id='${e}']`,n=o==null?void 0:o.querySelector(r);if(n){let a=o==null?void 0:o.querySelector(`[data-block-id='${t}']`);return Ct(n,a).toUpperCase()}return"VERTICAL"}catch(r){return"VERTICAL"}},op=(e,t,o)=>!!(e&&(o==="UP"||o==="LEFT")||t&&(o==="DOWN"||o==="RIGHT")),my=(e,t)=>{let[o]=Ce(),{document:r}=ie(),{moveBlocks:n}=ye(),a=Ta(e,"_id"),s=Ta(e,"_parent"),i=ly(o,m=>s?Ta(m,"_parent")===s:!Ta(m,"_parent")),l=(i==null?void 0:i.length)<=1,c=cy(i,{_id:a}),d=c<=0,p=c+1===(i==null?void 0:i.length),h=uy(s,a,r),u=dy(m=>{op(d,p,m)||l||(m==="UP"||m==="LEFT"?n([a],s||void 0,c-1):(m==="DOWN"||m==="RIGHT")&&n([a],s||void 0,c+2),t())},[d,p,l,t,n,a,s,c]);return{isOnlyChild:l,isFirstBlock:d,isLastBlock:p,moveBlock:u,orientation:h}},fy=({block:e,updateFloatingBar:t})=>{let{isOnlyChild:o,isFirstBlock:r,isLastBlock:n,moveBlock:a,orientation:s}=my(e,t);return o?null:tp(gy,{children:py.map(({ControlIcon:i,dir:l,key:c})=>s!==l||op(r,n,c)?null:tp(i,{onClick:()=>a(c),className:"rounded p-px hover:bg-white hover:text-blue-500"},c))})},rp=fy;import{atom as hy,useAtom as by}from"jotai";var yy=hy(""),Na=()=>by(yy);import{atom as ap}from"jotai";import{useAtom as np}from"jotai";var sp=ap("");sp.debugLabel="inlineEditingActiveAtom";var ip=ap(0);ip.debugLabel="inlineEditingItemIndexAtom";var Me=()=>{let[e,t]=np(sp),[o,r]=np(ip);return{editingBlockId:e,editingItemIndex:o,setEditingBlockId:t,setEditingItemIndex:r}};import{Suspense as vy,lazy as xy}from"react";import{jsx as Wr}from"react/jsx-runtime";var Cy=xy(()=>import("./ai-panel-content-UZJZ463W.js")),ky=({isOpen:e,isLoading:t,updateLoadingState:o})=>e?Wr(qn,{className:`absolute top-6 overflow-hidden rounded-b border-2 border-t-0 border-blue-500 ${e?"":"hidden"}`,value:e?"ai":"",type:"single",collapsible:!0,children:Wr(Jn,{value:"ai",className:"border-none",children:Wr(Qn,{id:"canvas-block-floating-ai-prompt-input",className:`z-[1001] w-full rounded-b bg-white ${t?"sr-only h-0 w-0 overflow-hidden opacity-0":"h-auto pb-0"}`,onClick:r=>r.stopPropagation(),onMouseDown:r=>r.stopPropagation(),children:Wr(vy,{fallback:null,children:Wr(Cy,{type:"floating",onSuccess:console.log,onError:console.log,onComplete:console.log,updateLoadingState:o})})})})}):null,lp=ky;import{GearIcon as wy}from"@radix-ui/react-icons";import{jsx as Sy}from"react/jsx-runtime";var cp=({blockId:e,className:t})=>Sy(wy,{className:t,onClick:()=>{e&&J.publish(U.GOTO_BLOCK_SETTINGS,e)}});import{useThrottledCallback as Ty}from"@react-hookz/web";import{some as Ny}from"lodash-es";import{useCallback as Ea}from"react";import{jsx as Ry}from"react/jsx-runtime";function Ba(e){if(e.getAttribute("data-block-id")==="canvas")return null;if(e.getAttribute("data-block-id")||e.getAttribute("data-block-parent"))return e;let t=e.closest("[data-block-id]");return(t==null?void 0:t.getAttribute("data-block-id"))==="canvas"?null:t}var Ey=["Heading","Paragraph","Text","Link","Span","Button"],By=e=>{var t;return(e==null?void 0:e.getAttribute("data-block-type"))==="RichText"||((t=e==null?void 0:e.parentElement)==null?void 0:t.getAttribute("data-block-type"))==="RichText"},Ay=()=>{let{editingBlockId:e}=Me();return Ea(t=>{if(e||t.button!==0)return;let o=Ba(t.target);o&&o!=null&&o.getAttribute("data-block-id")&&(o==null||o.getAttribute("data-block-id"))},[e])},dp=e=>e?Ny(e.children,t=>{let o=t;return o.hasAttribute("data-block-id")||dp(o)}):!1,Iy=(e,t)=>{if(t&&e)return!1;if(By(e))return!0;let o=t||(e==null?void 0:e.getAttribute("data-block-type"));return o?Ey.includes(o):!1},Dy=()=>{let{editingBlockId:e,setEditingBlockId:t,setEditingItemIndex:o}=Me();return Ea(r=>{var i;if(r==null||r.preventDefault(),r==null||r.stopPropagation(),e)return;let n=Ba(r.target);if(!n||!Iy(n)||dp(n))return;let a=n.getAttribute("data-block-id");if(!a)return;let s=n.closest('[data-block-type="Repeater"]');s?(i=s==null?void 0:s.childNodes)==null||i.forEach((l,c)=>{l.contains(n)&&o(c)}):o(-1),t(a)},[e,t,o])},_y=()=>{let{editingBlockId:e}=Me(),{clearHighlight:t}=Ie(),[,o]=K();return Ea(r=>{if(e)return;r.stopPropagation();let n=Ba(r.target);if(!n){t(),o([]),J.publish(U.CANVAS_BLOCK_SELECTED,[]);return}if(!(r.detail>=2)){if(n!=null&&n.getAttribute("data-block-id")&&(n==null?void 0:n.getAttribute("data-block-id"))==="container"){J.publish(U.CLEAR_CANVAS_SELECTION);return}if(n!=null&&n.getAttribute("data-block-parent")){let a=n.getAttribute("data-style-prop"),s=n.getAttribute("data-style-id"),i=n.getAttribute("data-block-parent");J.publish(U.CANVAS_BLOCK_STYLE_SELECTED,{blockId:i,styleId:s,styleProp:a})}else if(n!=null&&n.getAttribute("data-block-id")){let a=n.getAttribute("data-block-id");J.publish(U.CANVAS_BLOCK_SELECTED,a==="canvas"?[]:[a])}t()}},[e,t,o])},Py=()=>{let{editingBlockId:e}=Me(),{highlightBlock:t}=Ie();return Ty(o=>{if(e)return;let r=Ba(o.target);if(r){if(r.getAttribute("data-highlighted")==="true")return;t(r)}},[e,t],150)},Ly=()=>{let{clearHighlight:e}=Ie();return Ea(()=>e(),[e])},pp=({children:e})=>{let t=Dy(),o=Ay(),r=_y(),n=Py(),a=Ly();return Ry("div",{"data-block-id":"canvas",id:"canvas",onMouseDown:o,onClick:r,onDoubleClick:t,onMouseMove:n,onMouseLeave:a,className:"relative h-full max-w-full",children:e})},ir=(e,t)=>e.querySelector(`[data-block-id="${t}"]`);import{Fragment as Jy,jsx as De,jsxs as Aa}from"react/jsx-runtime";var mp="AI_OVERLAY_BLOCK_ID",Zy=(e,t)=>{if(fp(e),!ir(e,t))return;let r=e.createElement("div");r.setAttribute("data-block-id",mp),r.style.position="absolute",r.style.top="0px",r.style.left="0px",r.style.width=e.body.clientWidth+"px",r.style.height=e.body.scrollHeight+"px",r.style.backgroundColor="rgba(0, 0, 0, 0.05)",r.style.zIndex="9999",e.body.appendChild(r)},fp=e=>{let t=ir(e,mp);t&&(t.style.display="none",t.remove())},Yy=()=>{let e=$(),{document:t}=ie(),{onDragStart:o,onDragEnd:r,isDragging:n}=pt(),[a,s]=bi(null),i=Re(),l=jy(()=>{if(!(e!=null&&e._id)||e.type==="Multiple"||!t)return[];let p=ir(t,e._id);return p?[p]:[]},[e,t]);Ia(()=>{var h;let p=l[0];if(p){let{top:u}=p.getBoundingClientRect();u>=0&&u<=window.innerHeight||(h=t==null?void 0:t.defaultView)==null||h.scrollTo({top:p.offsetTop,behavior:"smooth"})}},[l,t]);let c=kt(p=>{s(l==null?void 0:l[0]),o(p,e,!1)},[l,o,e]),d=kt(()=>{s(null),r()},[r]);return{selectedBlock:e,selectedElements:l,dragging:a,isDragging:n,isDragAndDropEnabled:i,handleDragStart:c,handleDragEnd:d}},Xy=({block:e,isDragging:t,selectedBlockElement:o})=>{let r=Vn(),n=va(),[,a]=W(),[,s]=Na(),[,i]=K(),{hasPermission:l}=Ve(),{editingBlockId:c}=Me(),{document:d}=ie(),[p,h]=bi(null),u=Re(),m=M("flags.gotoSettings",!1),g=M("flags.ai",!1),f=p===e._id,[b,y]=bi(!1),{floatingStyles:k,refs:v,update:S}=Vy({placement:"top-start",middleware:[Fy({boundary:d==null?void 0:d.body,limiter:Hy({offset:8,mainAxis:!0,crossAxis:!0})}),My({boundary:d==null?void 0:d.body,fallbackPlacements:["bottom-start","top-end","bottom-end","inside"]}),Oy({boundary:d==null?void 0:d.body,apply({availableWidth:O,availableHeight:X,elements:Fe}){Object.assign(Fe.floating.style,{maxWidth:`${Math.max(200,O)}px`,maxHeight:`${Math.max(100,X)}px`})}})],elements:{reference:o}});up(o,()=>S(),o!==null),up(d==null?void 0:d.body,()=>S(),(d==null?void 0:d.body)!==null);let E=lr(e,"_parent",null),x=Ky(lr(e,"_name",""))?lr(e,"_type",""):lr(e,"_name","");Ia(()=>{h(null)},[o]),Ia(()=>{let O=null,X=null;if(!o){S();return}return O=requestAnimationFrame(()=>{X=requestAnimationFrame(()=>{S()})}),()=>{O!==null&&cancelAnimationFrame(O),X!==null&&cancelAnimationFrame(X)}},[o,h,e._id,S]);let B=kt(O=>{v.setFloating(O)},[v]),I=kt(()=>{E&&(i([]),a([E]))},[E,i,a]),N=kt(O=>{O.stopPropagation(),s("")},[s]),T=kt(O=>{O.stopPropagation(),O.preventDefault()},[]),C=kt(O=>{O.stopPropagation()},[]),w=kt(()=>{n([e==null?void 0:e._id])},[n,e._id]),A=kt(()=>{r([e==null?void 0:e._id])},[r,e._id]),_=kt(()=>{h(O=>{var Je;if(O===e._id)return null;let X=(((Je=o==null?void 0:o.getBoundingClientRect())==null?void 0:Je.top)||0)+220;return X>=0&&X<=window.innerHeight||setTimeout(()=>{let Vt=d==null?void 0:d.getElementById("canvas-block-floating-ai-prompt-input");Vt==null||Vt.scrollIntoView({behavior:"smooth",block:"center"})},200),e._id})},[d,e._id,o]),Z=kt(O=>{y(X=>(X&&!O?h(null):O&&p&&d&&Zy(d,p),O))},[d,p]);return Ia(()=>{!p&&d&&fp(d)},[d,p]),{floatingStyles:k,setFloatingRef:B,label:x,parentId:E,isDragAndDropEnabled:u,gotoSettingsEnabled:m,isAiEnabled:g,isAiPromptOpen:f,hasPermission:l,shouldRender:t||o&&e&&!c,block:e,update:S,isAiLoading:b,handlers:{handleParentSelect:I,handleMouseEnter:N,handleClick:T,handleKeyDown:C,handleDuplicate:w,handleDelete:A,handleOpenAiPanel:_,handleAiLoading:Z}}},qy=({block:e,isDragging:t,selectedBlockElement:o})=>{let{floatingStyles:r,setFloatingRef:n,label:a,parentId:s,isDragAndDropEnabled:i,gotoSettingsEnabled:l,isAiEnabled:c,isAiPromptOpen:d,hasPermission:p,shouldRender:h,update:u,handlers:m,isAiLoading:g}=Xy({block:e,isDragging:t,selectedBlockElement:o});return h?De(Jy,{children:Aa("div",{role:"button",tabIndex:0,ref:n,style:r,onClick:m.handleClick,onMouseEnter:m.handleMouseEnter,onKeyDown:m.handleKeyDown,className:`relative z-[999] text-xs text-white ${t?"opacity-0":""}`,children:[Aa("div",{className:"isolate flex h-6 scale-100 items-center justify-between bg-blue-500 py-2",children:[Aa("div",{className:"flex items-center",children:[i&&De(Wy,{className:"flex-shrink-0 cursor-grab rounded p-0.5 hover:bg-white/20 active:cursor-grabbing"}),s&&De(zy,{className:"flex-shrink-0 rounded p-0.5 hover:bg-white/20",onClick:m.handleParentSelect})]}),De("div",{className:`w-full ${i?"cursor-grab active:cursor-grabbing":""}`,children:De("div",{className:"mr-10 w-full items-center space-x-1 px-1 leading-tight",children:a})}),Aa("div",{className:`flex items-center gap-1 pl-1 pr-1.5 ${g?"pointer-events-none opacity-75":""}`,children:[p(be["pages:update"])&&c&&(g?De(En,{className:"h-4 w-4 animate-spin text-white"}):De(Md,{className:`h-4 w-4 rounded hover:bg-white hover:text-blue-500 ${d?"bg-white text-primary":""}`,onClick:()=>m.handleOpenAiPanel()})),l&&De(cp,{blockId:e==null?void 0:e._id,className:"h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500"}),!i&&De(Od,{block:e,children:De(Uy,{className:"h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500"})}),mc(lr(e,"_type",""))&&p(be["pages:update"])?De($y,{className:"h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500",onClick:m.handleDuplicate}):null,jn(lr(e,"_type",""))&&p(be["pages:update"])?De(Gy,{className:"h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500",onClick:m.handleDelete}):null,p(be["pages:update"])&&De(rp,{block:e,updateFloatingBar:u})]})]}),De(lp,{isOpen:d,isLoading:g,updateLoadingState:m.handleAiLoading})]})}):null},gp=()=>{let{selectedBlock:e,selectedElements:t,dragging:o,isDragging:r,isDragAndDropEnabled:n,handleDragStart:a,handleDragEnd:s}=Yy();return De("div",{onDragEnd:s,draggable:n&&!!e,onDragStart:a,children:e&&De(qy,{block:e,isDragging:r&&!!o,selectedBlockElement:t[0]||(r?o:null)})})};var hp=`<!doctype html>
|
|
16
|
+
<html lang="en" dir="__HTML_DIR__" class="scroll-smooth h-full overflow-y-auto">
|
|
17
|
+
<head>
|
|
18
|
+
<meta charset="UTF-8">
|
|
19
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
20
|
+
<script src="https://cdn.tailwindcss.com/3.4.17?plugins=forms@0.5.9,typography@0.5.15,aspect-ratio@0.4.2"></script>
|
|
21
|
+
<style>
|
|
22
|
+
html { height: 100%; overflow:auto; }
|
|
23
|
+
body { height: 100%; }
|
|
24
|
+
.air-highlight{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}
|
|
25
|
+
.air-highlight-multi{ outline: 1px solid #29e503 !important; outline-offset: -1px;}
|
|
26
|
+
body{ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none;
|
|
27
|
+
-moz-user-select: none;-ms-user-select: none; user-select: none; }
|
|
28
|
+
html{
|
|
29
|
+
-ms-overflow-style: none; /* IE and Edge */
|
|
30
|
+
scrollbar-width: none; /* Firefox */
|
|
31
|
+
}
|
|
32
|
+
/** IMPORTANT: Make fields content editable in SAFARI */
|
|
33
|
+
[contenteditable] {-webkit-user-select: text;user-select: text;}
|
|
34
|
+
|
|
35
|
+
html::-webkit-scrollbar { width: 0 !important }
|
|
36
|
+
.aspect-auto{aspect-ratio: auto;}
|
|
37
|
+
.aspect-square{aspect-ratio: 1/1;}
|
|
38
|
+
.aspect-video{aspect-ratio: 16/9;}
|
|
39
|
+
.dragging [data-dnd="leaf"] { pointer-events: none; } .dragging [data-dnd="leaf"] * { pointer-events: none; }
|
|
40
|
+
.dragging [data-dnd="ignore"], .dragging [data-dnd="ignore"] * { pointer-events: none; }
|
|
41
|
+
a{ pointer-events: none !important; }
|
|
42
|
+
[contenteditable="true"], [contenteditable="true"] * { cursor: text !important; }
|
|
43
|
+
[contenteditable="true"] {
|
|
44
|
+
outline: none;
|
|
45
|
+
box-shadow: 0 0 0px 4px rgba(36, 150, 255, 0.2);
|
|
46
|
+
-webkit-user-select: text;
|
|
47
|
+
-moz-user-select: text;
|
|
48
|
+
user-select: text;
|
|
49
|
+
}
|
|
50
|
+
.frame-root .frame-content { height: 100%; }
|
|
51
|
+
[data-drop="yes"] { outline: 2px dashed orange !important; outline-offset: -2px }
|
|
52
|
+
[data-dnd="yes"] { pointer-events: auto !important}
|
|
53
|
+
[data-dnd="no"],[data-block-type="GlobalBlock"],[data-block-type="PartialBlock"] > * { pointer-events: none !important; }
|
|
54
|
+
[data-block-type="GlobalBlock"],[data-block-type="PartialBlock"] { position: relative !important;display: inherit !important; }
|
|
55
|
+
.partial-overlay { pointer-events: auto !important; }
|
|
56
|
+
[data-dnd-dragged="yes"] { opacity: 0.6; pointer-events: none; }
|
|
57
|
+
[data-dnd-dragged="no"] { opacity: 1; pointer-events: auto !important; }
|
|
58
|
+
[force-show] { display: block !important; }
|
|
59
|
+
[data-cut-block="yes"] { pointer-events: none !important; display: none !important; }
|
|
60
|
+
</style>
|
|
61
|
+
<style id="highlighted-block">
|
|
62
|
+
[data-highlighted]{
|
|
63
|
+
outline: 1px solid #42a1fc !important; outline-offset: -1px;
|
|
64
|
+
}
|
|
65
|
+
</style>
|
|
66
|
+
<style>
|
|
67
|
+
.react-colorful {
|
|
68
|
+
height: 120px !important;
|
|
69
|
+
width: 180px !important;
|
|
70
|
+
}
|
|
71
|
+
.react-colorful > div {
|
|
72
|
+
margin-bottom: 4px;
|
|
73
|
+
}
|
|
74
|
+
.react-colorful__saturation {
|
|
75
|
+
border-radius: 4px !important;
|
|
76
|
+
}
|
|
77
|
+
.react-colorful__hue,
|
|
78
|
+
.react-colorful__alpha {
|
|
79
|
+
height: 12px !important;
|
|
80
|
+
border-radius: 4px !important;
|
|
81
|
+
}
|
|
82
|
+
.react-colorful__pointer {
|
|
83
|
+
width: 16px !important;
|
|
84
|
+
height: 16px !important;
|
|
85
|
+
border: 1.5px solid #fff !important;
|
|
86
|
+
cursor: pointer !important;
|
|
87
|
+
z-index: 10002 !important;
|
|
88
|
+
}
|
|
89
|
+
#active-inline-editing-element{outline: 2px solid #00c951;}
|
|
90
|
+
</style>
|
|
91
|
+
<style type="text/tailwindcss">
|
|
92
|
+
@layer base {
|
|
93
|
+
* {
|
|
94
|
+
@apply border-border;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
@layer utilities {
|
|
98
|
+
.rte {
|
|
99
|
+
h1 {
|
|
100
|
+
@apply text-2xl;
|
|
101
|
+
}
|
|
102
|
+
h2 {
|
|
103
|
+
@apply text-xl;
|
|
104
|
+
}
|
|
105
|
+
h3 {
|
|
106
|
+
@apply text-lg;
|
|
107
|
+
}
|
|
108
|
+
h4 {
|
|
109
|
+
@apply text-base;
|
|
110
|
+
}
|
|
111
|
+
h5 {
|
|
112
|
+
@apply text-sm;
|
|
113
|
+
}
|
|
114
|
+
h6 {
|
|
115
|
+
@apply text-xs;
|
|
116
|
+
}
|
|
117
|
+
p {
|
|
118
|
+
&:empty {
|
|
119
|
+
@apply h-4;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
ul {
|
|
123
|
+
@apply list-disc pl-6 text-base;
|
|
124
|
+
}
|
|
125
|
+
ol {
|
|
126
|
+
@apply list-decimal pl-6 text-base;
|
|
127
|
+
}
|
|
128
|
+
li > p {
|
|
129
|
+
@apply m-0;
|
|
130
|
+
}
|
|
131
|
+
blockquote {
|
|
132
|
+
@apply pl-4 text-base;
|
|
133
|
+
p {
|
|
134
|
+
@apply pl-4 text-base;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
</style>
|
|
140
|
+
</head>
|
|
141
|
+
<body class="font-body antialiased h-full">
|
|
142
|
+
<div class="frame-root h-full"></div>
|
|
143
|
+
</body>
|
|
144
|
+
</html>`;import yp,{Component as tv}from"react";import bp from"react-dom";import{Children as Qy,Component as ev}from"react";var Ur=class extends ev{componentDidMount(){this.props.contentDidMount()}componentDidUpdate(){this.props.contentDidUpdate()}render(){return Qy.only(this.props.children)}};import{jsx as Gr}from"react/jsx-runtime";var Da=class extends tv{constructor(o){super(o);this._isMounted=!1;this.nodeRef=yp.createRef();this.setRef=o=>{this.nodeRef.current=o;let{forwardedRef:r}=this.props;typeof r=="function"?r(o):r&&(r.current=o)};this.handleLoad=()=>{clearInterval(this.loadCheck),this.state.iframeLoaded||this.setState({iframeLoaded:!0})};this.startLoadCheck=()=>{this.loadCheck=setInterval(()=>{this.handleLoad()},500)};this.state={iframeLoaded:!1}}componentDidMount(){var r;this._isMounted=!0,this.getDoc()&&this.nodeRef.current&&((r=this.nodeRef.current.contentWindow)==null||r.addEventListener("DOMContentLoaded",this.handleLoad))}componentWillUnmount(){var o;this._isMounted=!1,(o=this.nodeRef.current)==null||o.removeEventListener("DOMContentLoaded",this.handleLoad),clearInterval(this.loadCheck)}getDoc(){return this.nodeRef.current?this.nodeRef.current.contentDocument:null}getMountTarget(){let o=this.getDoc();return o?this.props.mountTarget?o.querySelector(this.props.mountTarget):o.body.children[0]:null}renderFrameContents(){if(!this._isMounted)return null;let o=this.getDoc();if(!o)return null;let r=this.props.contentDidMount,n=this.props.contentDidUpdate,a=o.defaultView||o.parentView,s=Gr(Ur,{contentDidMount:r,contentDidUpdate:n,children:Gr(ep,{value:{document:o,window:a},children:Gr("div",{className:"frame-content",children:this.props.children})})}),i=this.getMountTarget();return!i||!o.head?null:[bp.createPortal(this.props.head,o.head),bp.createPortal(s,i)]}render(){let{...o}=this.props,r={...o,srcDoc:this.props.initialContent,children:void 0};return delete r.head,delete r.initialContent,delete r.mountTarget,delete r.contentDidMount,delete r.contentDidUpdate,delete r.forwardedRef,Gr("iframe",{...r,ref:this.setRef,onLoad:this.handleLoad,children:this.state.iframeLoaded&&this.renderFrameContents()})}};Da.defaultProps={style:{},head:null,children:void 0,mountTarget:void 0,contentDidMount:()=>{},contentDidUpdate:()=>{},initialContent:'<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'};var yi=yp.forwardRef((e,t)=>Gr(Da,{...e,forwardedRef:t}));var vp=()=>{let{document:e}=ie();return xa(e),null};import{PlusIcon as ov}from"@radix-ui/react-icons";import{useTranslation as rv}from"react-i18next";import{jsx as Lo,jsxs as xp}from"react/jsx-runtime";var Cp=()=>{let{t:e}=rv(),{hasPermission:t}=Ve(),o=t(be["pages:update"]),r=Re();return o?xp("div",{id:"add-block-bottom",className:"group relative w-full cursor-pointer py-2",children:[Lo("br",{}),!r&&Lo("div",{role:"button",onClick:()=>J.publish(U.OPEN_ADD_BLOCK),className:"block h-1 rounded bg-primary opacity-0 duration-200 group-hover:opacity-100",children:xp("div",{className:"absolute left-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-primary px-3 py-1 text-xs leading-tight text-white hover:bg-primary",children:[Lo(ov,{className:"size-2.5 stroke-[3]"})," ",e("Add block")]})}),Lo("br",{}),Lo("br",{}),Lo("br",{}),Lo("br",{})]}):null};import cv from"@tailwindcss/container-queries";import dv from"@tailwindcss/forms";import pv from"@tailwindcss/typography";import{filter as wp,get as Sp,has as Tp,map as Np}from"lodash-es";import{useEffect as Ep,useMemo as Kr}from"react";import uv from"tailwindcss/plugin";import{useMemo as nv}from"react";import{jsx as sv}from"react/jsx-runtime";var av=e=>nv(()=>Bc({theme:e}),[e]),kp=({theme:e})=>{let t=av(e);return sv("style",{id:"chai-theme",dangerouslySetInnerHTML:{__html:t}})};import{useAtom as iv}from"jotai";import{atomWithStorage as lv}from"jotai/utils";var vi=lv("darkMode",!1),_t=()=>{let[e,t]=iv(vi);return[e,t]};import{Fragment as Ap,jsx as vo,jsxs as Ip}from"react/jsx-runtime";var mv=(e,t)=>{Ep(()=>{e?t==null||t.documentElement.classList.add("dark"):t==null||t.documentElement.classList.remove("dark")},[e,t])},fv=(e,t,o)=>{Ep(()=>{let r=o;if(!r||!r.tailwind)return;let n={darkMode:"class",theme:{extend:{container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},...Ec(t)}},plugins:[pv,dv,cv,uv(function({addBase:a,theme:s}){a({"h1,h2,h3,h4,h5,h6":{fontFamily:s("fontFamily.heading")},body:{fontFamily:s("fontFamily.body"),color:s("colors.foreground"),backgroundColor:s("colors.background")}})})]};Object.assign(r.tailwind.config,n)},[e,t,o])},gv=()=>{let[e]=K(),[t]=W();return Kr(()=>`${Np(e,({id:o})=>`[data-style-id="${o}"]`).join(",")}{
|
|
145
|
+
outline: 1px solid ${t.length>0?"#42a1fc":"#de8f09"} !important; outline-offset: -1px;
|
|
146
|
+
}`,[e,t])},hv=()=>{let[e]=W();return Kr(()=>`${Np(e,t=>`[data-block-id="${t}"]`).join(",")}{
|
|
147
|
+
outline: 1px solid #42a1fc !important; outline-offset: -1px;
|
|
148
|
+
}`,[e])},bv=()=>{let[e]=Rr(),t=or(),o=Kr(()=>{let{heading:a,body:s}={heading:Sp(e,"fontFamily.heading"),body:Sp(e,"fontFamily.body")};return t.filter(i=>i.family===a||i.family===s)},[e,t]),r=Kr(()=>Ac(wp(o,a=>Tp(a,"url"))),[o]),n=Kr(()=>Ic(wp(o,a=>Tp(a,"src"))),[o]);return{fonts:r,customFonts:n}},yv=()=>{let e=gv();return vo("style",{id:"selected-styling-blocks",dangerouslySetInnerHTML:{__html:e}})},vv=()=>{let e=hv();return vo("style",{id:"selected-blocks",dangerouslySetInnerHTML:{__html:e}})},xv=()=>{let{fonts:e,customFonts:t}=bv();return Ip(Ap,{children:[e.map((o,r)=>vo("link",{rel:"stylesheet",href:o},`google-font-${r}`)),vo("style",{id:"chai-custom-fonts",dangerouslySetInnerHTML:{__html:t}})]})},Bp=()=>{let[e]=Rr(),t=zn(),[o]=_t(),{document:r,window:n}=ie();return mv(o,r),fv(e,t,n),Ip(Ap,{children:[vo(kp,{theme:e}),vo(xv,{}),vo(vv,{}),vo(yv,{})]})};import{useAtomValue as Iv}from"jotai";import{useEffect as Si}from"react";import{atomWithStorage as Cv}from"jotai/utils";import{useAtom as kv}from"jotai";var Ge=Cv("canvasZoom",100),cr=()=>kv(Ge);import{atom as Zr,useAtom as Yr}from"jotai";import{atomWithStorage as Ev}from"jotai/utils";import{atom as Sv,useAtom as _p,useAtomValue as Tv}from"jotai";import{atomWithStorage as Pp}from"jotai/utils";import{useEffect as Nv}from"react";import{useAtom as wv}from"jotai";var Dp=()=>wv(Zl);var Lp=Pp("canvasWidth",800),_a=Pp("canvasDisplayWidth",800),xi=Sv(e=>{let t=e(Lp);return Dn(t).toLowerCase()}),jr=()=>{let[e,t]=_p(Lp),o=Tv(xi),[r,n]=Dp();return Nv(()=>{r!=="xs"&&n(o)},[o,r,n]),[e,o,t]},xo=()=>{let[e,t]=_p(_a);return[e,t]};var Ci=Ev("pannableCanvas",!1),Co=Zr("select"),ut=Zr({x:0,y:0}),ko=Zr(!1),Xt=Zr({width:0,height:0}),Pa=Zr(800),Bv=25,Av=400,ki=24,Rp=48,qt=e=>Math.min(Av,Math.max(Bv,e)),Ro=(e,t,o)=>{let r=Rp-t,n=o-Rp;return Math.min(Math.max(e,r),n)},La=(e,t)=>Ro((t-e)/2,e,t),Mp=e=>{let t=qt(e)/100;return{width:L.get(_a)*t,height:L.get(Pa)*t}},wo=(e,t)=>{let o=L.get(Xt),r=Mp(L.get(Ge)),n=L.get(ut);L.set(ut,{x:Ro(n.x+e,r.width,o.width),y:Ro(n.y+t,r.height,o.height)})},Ra=(e,t,o)=>{let r=L.get(Ge),n=qt(e);if(r===n)return;let a=L.get(Xt),s=Mp(n),i=L.get(ut),l=n/r;L.set(ut,{x:Ro(t-(t-i.x)*l,s.width,a.width),y:Ro(o-(o-i.y)*l,s.height,a.height)}),L.set(Ge,n)},Hp=(e,t,o)=>{let r=L.get(Ge)/100,n=L.get(ut);Ra(e,n.x+r*t,n.y+r*o)},wi=e=>{let t=L.get(Xt);Ra(e,t.width/2,t.height/2)},Op=()=>{let e=L.get(Xt),t=L.get(_a);L.set(Ge,100),L.set(ut,{x:La(t,e.width),y:ki})},Ma=()=>{L.set(Ci,!L.get(Ci))},dr=e=>{var o;let t=e;return!t||typeof t.tagName!="string"?!1:t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||!!t.isContentEditable||!!((o=t.closest)!=null&&o.call(t,'[contenteditable="true"]'))},So=()=>Yr(Ci),Ha=()=>Yr(Co),Fp=()=>Yr(ut),Vp=()=>Yr(ko);var zp=()=>Yr(Pa);import{jsx as _v}from"react/jsx-runtime";var Dv=3e4,$p=({pannable:e})=>{let{document:t}=ie(),{editingBlockId:o}=Me(),r=Iv(Xt).height;if(Si(()=>{if(!e||!(t!=null&&t.documentElement))return;let a,s=()=>{let l=t.documentElement.scrollHeight;L.set(Pa,Math.min(Math.max(l,100),Dv))},i=new ResizeObserver(()=>{clearTimeout(a),a=setTimeout(s,150)});return i.observe(t.documentElement),s(),()=>{clearTimeout(a),i.disconnect()}},[e,t]),Si(()=>{if(!t)return;let a=s=>{s.ctrlKey||s.metaKey||s.altKey||s.key!=="p"&&s.key!=="P"||o||dr(s.target)||Ma()};return t.addEventListener("keydown",a),()=>t.removeEventListener("keydown",a)},[t,o]),Si(()=>{if(!e||!t)return;let a=m=>{if(m.preventDefault(),m.ctrlKey||m.metaKey){let b=qt(L.get(Ge)*Math.exp(-m.deltaY*.01));Hp(b,m.clientX,m.clientY);return}let g=m.deltaX,f=m.deltaY;m.shiftKey&&g===0&&(g=f,f=0),wo(-g,-f)},s=m=>{if(!(o||dr(m.target))){if(m.code==="Space"){m.repeat||(m.preventDefault(),L.set(ko,!0));return}m.ctrlKey||m.metaKey||m.altKey||((m.key==="v"||m.key==="V"||m.key==="Escape")&&L.set(Co,"select"),(m.key==="h"||m.key==="H")&&L.set(Co,"hand"))}},i=m=>{m.code==="Space"&&L.set(ko,!1)},l=!1,c=0,d=0,p=m=>{m.button===1&&(m.preventDefault(),l=!0,c=m.screenX,d=m.screenY)},h=m=>{l&&(wo(m.screenX-c,m.screenY-d),c=m.screenX,d=m.screenY)},u=()=>{l=!1};return t.addEventListener("wheel",a,{passive:!1}),t.addEventListener("keydown",s),t.addEventListener("keyup",i),t.addEventListener("mousedown",p),t.addEventListener("mousemove",h),t.addEventListener("mouseup",u),t.addEventListener("mouseleave",u),()=>{t.removeEventListener("wheel",a),t.removeEventListener("keydown",s),t.removeEventListener("keyup",i),t.removeEventListener("mousedown",p),t.removeEventListener("mousemove",h),t.removeEventListener("mouseup",u),t.removeEventListener("mouseleave",u)}},[e,t,o]),!e)return null;let n=Math.round(Math.max(r,400));return _v("style",{children:`
|
|
149
|
+
html { height: auto !important; overflow: hidden !important; }
|
|
150
|
+
body { height: auto !important; }
|
|
151
|
+
[class*="min-h-screen"], [class*="min-h-dvh"] { min-height: ${n}px !important; }
|
|
152
|
+
[class*="max-h-screen"], [class*="max-h-dvh"] { max-height: ${n}px !important; }
|
|
153
|
+
[class*="h-screen"]:not([class*="min-h-screen"]):not([class*="max-h-screen"]),
|
|
154
|
+
[class*="h-dvh"]:not([class*="min-h-dvh"]):not([class*="max-h-dvh"]) { height: ${n}px !important; }
|
|
155
|
+
`})};import{useEffect as Pv,useRef as Lv}from"react";import{jsx as Rv}from"react/jsx-runtime";var Wp=()=>{let[e]=Ha(),[t]=Vp(),o=Lv(!1);return Pv(()=>{let r=a=>{o.current&&wo(a.movementX,a.movementY)},n=()=>{o.current=!1};return document.addEventListener("mousemove",r),document.addEventListener("mouseup",n),()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",n)}},[]),e!=="hand"&&!t?null:Rv("div",{className:"absolute inset-0 z-40 cursor-grab active:cursor-grabbing",onMouseDown:r=>{r.preventDefault(),r.stopPropagation(),o.current=!0},onClick:r=>r.stopPropagation()})};import{useDebouncedCallback as Mv,useResizeObserver as Hv}from"@react-hookz/web";import{useCallback as Ov,useEffect as Fv,useRef as Vv}from"react";import{jsx as zv}from"react/jsx-runtime";var Up=({children:e,onMount:t,onResize:o})=>{let[,r]=W(),[,n]=K(),a=Vv(null),s=Mv(()=>{let{clientWidth:l}=a.current;o(l)},[o],100);Hv(a,s),Fv(()=>{let{clientWidth:l}=a.current;t(l)},[]);let i=Ov(()=>{r([]),n([])},[r,n]);return zv("div",{id:"main-content",onClick:i,className:"h-full w-full border-x-[24px] border-transparent bg-black/50 pb-0 [background-image:radial-gradient(#444_1px,transparent_1px)] [background-size:20px_20px] dark:bg-background/80",ref:a,children:e})};import{useAtom as gC,useAtomValue as hC}from"jotai";import{atom as Kx,Provider as jx,useAtom as _i,useAtomValue as Zx}from"jotai";import{splitAtom as Yx}from"jotai/utils";import{get as gu,isArray as yu,isEmpty as Xx,isNull as qx,isString as Jx,noop as Qx}from"lodash-es";import{createContext as $a,createElement as eC,memo as tC,Suspense as oC,useCallback as rC,useContext as mr,useMemo as Ke}from"react";import{ErrorBoundary as nC}from"react-error-boundary";import{toast as aC}from"sonner";import{useSetAtom as $v}from"jotai";import{find as Wv}from"lodash-es";import{useCallback as Ti,useMemo as Uv,useRef as Gv}from"react";var Gp=()=>{let e=$v(On),{onDragStart:t,onDragEnd:o}=pt(),r=Gv(null),n=Ti(i=>{var d;if(i.button!==0||i.detail>=2)return;let c=(d=i.target.closest("[data-block-id]"))==null?void 0:d.getAttribute("data-block-id");!c||c==="canvas"||(e(p=>p.length===1&&p[0]===c?p:[c]),r.current=c)},[e]),a=Ti(i=>{var p,h,u,m,g;i.stopPropagation();let l=(g=(m=r.current)!=null?m:(u=(h=(p=i.target).closest)==null?void 0:h.call(p,"[data-block-id]"))==null?void 0:u.getAttribute("data-block-id"))!=null?g:null;if(!l||l==="canvas")return;let c=L.get(he),d=Wv(c,{_id:l});d&&t(i,d,!1)},[t]),s=Ti(()=>{o(),r.current=null},[o]);return Uv(()=>({onMouseDown:n,onDragStart:a,onDragEnd:s}),[n,a,s])};import{atom as Kp}from"jotai";import{isEmpty as Kv,get as Ni}from"lodash-es";var jv=Kp({}),Zv=5e3,Xr=new Map,Yv=()=>{for(;Xr.size>Zv;){let e=Xr.keys().next().value;if(!e)return;Xr.delete(e)}},Xv=(e,t)=>{let o=Object.keys(e);return o.length!==Object.keys(t).length?!1:o.every(r=>Object.is(e[r],t[r]))},qv=(e,t)=>{let o=null;return Kp(r=>{let n=r(Ll),a=[],s=n.get(e);for(;s;){let l=r(s);a.push(l),s=l._parent?n.get(l._parent):void 0}let i=Object.entries(t).reduce((l,[c,d])=>{let p=a.find(h=>h._type===Ni(d,"block"));return p&&(l[c]=Ni(p,Ni(d,"prop"),null)),l},{});return o&&Xv(o,i)?o:(o=i,i)})},jp=(e,t)=>{if(Kv(t))return jv;let o=Xr.get(e);if(o&&o.runtimeProps===t)return o.atom;let r=qv(e,t);return Xr.set(e,{runtimeProps:t,atom:r}),Yv(),r};import{get as Ei}from"lodash-es";import{useMemo as Jv}from"react";var Zp=({children:e,block:t})=>{let o=Jv(()=>Be(t._type),[t._type]),r=Ei(o,"dataProviderDependencies"),n=Ei(o,"dataProvider"),a=Ei(o,"dataProviderMode","mock"),s=Ql(t,a,r,n);return e(s)};import{jsx as Qv}from"react/jsx-runtime";var Yp=()=>Qv("div",{className:"flex min-h-[100px] items-center justify-center bg-red-50 p-2 text-center text-red-500",children:"Something went wrong."});import{useDebouncedCallback as Mx}from"@react-hookz/web";import{BubbleMenu as Hx,EditorContent as Ox}from"@tiptap/react";import{cloneDeep as Fx,get as Vx,has as zx}from"lodash-es";import{createElement as $x,memo as Ii,startTransition as Wx,useCallback as Va,useEffect as Di,useMemo as Qr,useRef as lu,useState as Ux}from"react";import{CaretDownIcon as ru,EnterFullScreenIcon as bx,FontBoldIcon as yx,FontItalicIcon as vx,Link2Icon as xx,LinkBreak2Icon as Cx,ListBulletIcon as nu,StrikethroughIcon as kx,TextAlignCenterIcon as au,TextAlignLeftIcon as su,TextAlignRightIcon as iu,UnderlineIcon as wx,ValueIcon as Sx}from"@radix-ui/react-icons";import{useRef as Tx}from"react";import{clsx as ex}from"cnfast";import{twMerge as tx}from"cnfast";function pe(...e){return tx(ex(e))}import{CaretDownIcon as ix,Cross1Icon as lx}from"@radix-ui/react-icons";import{useDebouncedState as Qp}from"@react-hookz/web";import{useAtom as cx}from"jotai";import{get as dx,uniq as px}from"lodash-es";import{useEffect as eu,useState as Bi}from"react";import{HexAlphaColorPicker as ux}from"react-colorful";import{useCallback as ox,useEffect as rx,useRef as nx,useState as Xp}from"react";import{createPortal as ax}from"react-dom";import{Fragment as qp,jsx as pr,jsxs as Jp}from"react/jsx-runtime";var sx=({editor:e,trigger:t,content:o,from:r,menuRef:n})=>{let{document:a}=ie(),[s,i]=Xp({left:void 0,right:void 0,top:void 0,bottom:void 0}),[l,c]=Xp(!1),d=nx(null),p=ox(()=>{var y,k;let h=(y=d.current)==null?void 0:y.getBoundingClientRect();if(!h||!a)return;let u=(k=n.current)==null?void 0:k.getBoundingClientRect();if(!u)return;let m=h.left,g=h.bottom+4,f,b;(u==null?void 0:u.left)+(u==null?void 0:u.width)+50>=a.body.offsetWidth&&(m=void 0,f=a.body.offsetWidth-(h==null?void 0:h.right)),g+202>=a.body.clientHeight&&(g=void 0,b=a.body.clientHeight-h.bottom+u.height),i({left:m,top:g,right:f,bottom:b})},[a,n]);if(rx(()=>{l&&requestAnimationFrame(p)},[l,p]),r==="canvas"){let h=()=>{c(!1),e&&(e==null||e.view.focus(),e==null||e.chain().focus().run())};return Jp(qp,{children:[pr("div",{ref:d,onClick:()=>c(u=>!u),className:"cursor-pointer",children:t}),l&&(s.left!==void 0||s.top!==void 0||s.right!==void 0||s.bottom!==void 0)&&ax(pr("div",{id:"chaibuilder-rte-dropdown-menu-content",onClick:h,className:"fixed inset-0 left-0 top-0 z-[10001] h-full w-screen",children:pr("div",{onClick:u=>u.stopPropagation(),className:`absolute rounded-md border border-border bg-background p-1.5 text-xs shadow-2xl ${r==="canvas"?"bg-background text-white":"bg-surface text-foreground"}`,style:Object.assign({},{left:s.left,top:s.top,right:s.right,bottom:s.bottom}),children:typeof o=="function"?o(h):o})}),a.body,"chaibuilder-rte-dropdown-menu")]})}return pr(qp,{children:Jp(ot,{open:l,onOpenChange:c,children:[pr(rt,{className:"relative outline-none",asChild:!0,children:t}),pr(nt,{className:"z-50 rounded-md border border-border bg-popover p-1 text-xs text-popover-foreground shadow-xl",children:l&&(typeof o=="function"?o(()=>c(!1)):o)})]})})},qr=sx;import{Fragment as hx,jsx as Se,jsxs as Jr}from"react/jsx-runtime";var mx=(e,t,o)=>{let r=o==="settings",n=typeof t=="boolean"?t:t.some(a=>e.isActive(a));return{"rounded p-1":!0,"hover:bg-primary/90 hover:text-primary-foreground":!n&&!r,"hover:bg-accent hover:text-accent-foreground":!n&&r,"bg-primary text-primary-foreground":n&&r,"bg-primary-foreground text-primary":n&&!r}},tu=({themeColors:e,onClose:t,color:o,onChange:r,onRemove:n})=>Jr(hx,{children:[Se("div",{className:"flex w-[180px] flex-wrap gap-1 pb-2",children:(e==null?void 0:e.length)>0&&px(e).map(a=>{var s;return Se("button",{className:pe("h-3 w-3 cursor-pointer rounded-full border border-foreground/20 shadow duration-300 hover:scale-110 hover:shadow-xl",{"border-2 border-foreground":a===o}),style:{backgroundColor:a},onClick:()=>{r(a),t()},title:(s=a||"#000000")==null?void 0:s.toUpperCase()},a)})}),Se(ux,{color:o,onChange:r,style:{width:"200px",height:"200px"}}),Jr("div",{className:"mt-1 flex items-center justify-between gap-1",children:[Se(oe,{type:"text",value:o||"#000000f2",onChange:a=>r(a.target.value,!0),placeholder:"#000000",className:"h-6 !w-[90px] text-center"}),Se(D,{onClick:()=>{n(),t()},size:"icon-sm",variant:"ghost",className:"h-5 w-5 bg-transparent",title:"Remove",children:Se(lx,{className:"h-3 w-3"})})]})]}),fx=({textColor:e,highlightColor:t,onChangeTextColor:o,onChangeHighlightColor:r,onRemoveTextColor:n,onRemoveHighlightColor:a,onClose:s})=>{let[i]=_t(),[l]=cx(Vl),c=(l==null?void 0:l.colors)||{},d=Object.values(c).map(u=>dx(u,i?"1":"0")),[p,h]=Bi("TEXT");return Se("div",{id:"rte-widget-color-picker",className:"px-1",children:Jr(co,{value:p,onValueChange:h,className:"w-full",children:[Jr(po,{className:"mb-2",children:[Se(ke,{value:"TEXT",className:"h-5 px-2 text-[10px]",children:"Text Color"}),Se(ke,{value:"HIGHLIGHT",className:"h-5 px-2 text-[10px]",children:"Highlight Color"})]}),Se(tt,{value:"TEXT",className:"mt-0",children:Se(tu,{themeColors:d,onClose:s,onChange:o,color:e,onRemove:n})}),Se(tt,{value:"HIGHLIGHT",className:"mt-0",children:Se(tu,{themeColors:d,onClose:s,onChange:r,color:t,onRemove:a})})]})})},gx=({editor:e,from:t,menuRef:o})=>{var y,k;let r=(y=e==null?void 0:e.getAttributes("textStyle"))==null?void 0:y.color,n=(k=e==null?void 0:e.getAttributes("highlight"))==null?void 0:k.color,[a,s]=Bi(r||"#000000F2"),[i,l]=Bi(n||"#00000057"),[c,d]=Qp(a,150),[p,h]=Qp(i,150),u=(v,S)=>{S?(s(v),d(v)):(e==null||e.chain().setColor(v).run(),s(v))},m=(v,S)=>{S?(l(v),h(v)):(e==null||e.chain().setHighlight({color:v}).run(),l(v))},g=()=>{e==null||e.chain().unsetColor().run(),s("#000000F2")},f=()=>{e==null||e.chain().unsetHighlight().run()};return eu(()=>{p!=null&&p.includes("#")&&(p==null?void 0:p.length)>=3&&(e==null||e.chain().setHighlight({color:p}).run())},[p,e]),eu(()=>{c!=null&&c.includes("#")&&(c==null?void 0:c.length)>=3&&(e==null||e.chain().setColor(c).run())},[c,e]),Se(qr,{editor:e,from:t,menuRef:o,trigger:Jr("div",{className:pe("relative flex items-center",mx(e,!!r,t)),title:"Text Color",children:[Se("div",{className:"h-4 w-4 rounded-full border",style:{backgroundColor:r||(t==="canvas"?"#FFFFFF":"#000000")}}),Se(ix,{className:"h-3 w-3 opacity-50"})]}),content:v=>Se(fx,{textColor:a,highlightColor:i,onChangeTextColor:u,onChangeHighlightColor:m,onRemoveTextColor:g,onRemoveHighlightColor:f,onClose:v})})},ou=gx;import{Fragment as Ai,jsx as G,jsxs as wt}from"react/jsx-runtime";var We=(e,t,o)=>{let r=o==="settings",n=typeof t=="boolean"?t:t.some(a=>e.isActive(a));return{"rounded p-1":!0,"hover:bg-primary/90 hover:text-primary-foreground":!n&&!r,"hover:bg-accent hover:text-accent-foreground":!n&&r,"bg-primary text-primary-foreground":n&&r,"bg-primary-foreground text-primary":n&&!r}},Nx=({editor:e,from:t="settings",onExpand:o})=>{let r=Tx(null);if(!e)return null;let n=()=>{let s=window.prompt("URL");s&&e.chain().focus().extendMarkRange("link").setLink({href:s}).run()},a=()=>{e.chain().focus().unsetLink().run()};return wt("div",{ref:r,id:"chai-rich-text-menu-bar",className:pe("mb-1 flex flex-wrap gap-0.5 rounded-t-md border-b border-border bg-secondary p-1 text-foreground",{"mb-0 rounded-md border-none bg-background bg-primary text-primary-foreground":t==="canvas"}),children:[G("button",{type:"button",onClick:()=>e.chain().focus().toggleBold().run(),className:pe("",We(e,["bold"],t)),title:"Bold",children:G(yx,{className:"h-4 w-4"})}),G("button",{type:"button",onClick:()=>e.chain().focus().toggleItalic().run(),className:pe("",We(e,["italic"],t)),title:"Italic",children:G(vx,{className:"h-4 w-4"})}),G("button",{type:"button",onClick:()=>e.chain().focus().toggleUnderline().run(),className:pe("",We(e,["underline"],t)),title:"Underline",children:G(wx,{className:"h-4 w-4"})}),G("button",{type:"button",onClick:()=>e.chain().focus().toggleStrike().run(),className:pe("",We(e,["strike"],t)),title:"Strike",children:G(kx,{className:"h-4 w-4"})}),G("div",{className:"h-5 w-px border-l bg-transparent"}),G(ou,{editor:e,from:t,menuRef:r}),G("div",{className:"h-5 w-px border-l bg-transparent"}),G(qr,{editor:e,menuRef:r,from:t,trigger:wt("button",{type:"button",className:pe("flex items-center",We(e,["bulletList","orderedList"],t)),title:"Bullet List",children:[G(nu,{className:"h-4 w-4"}),G(ru,{className:"h-3 w-3 opacity-50"})]}),content:s=>wt(Ai,{children:[wt("div",{onClick:()=>{e.chain().focus().toggleBulletList().run(),s()},className:pe("flex cursor-pointer items-center gap-x-1 outline-none hover:outline-none",We(e,["bulletList"],t)),children:[G(nu,{className:"h-4 w-4"})," Unordered List"]}),wt("div",{onClick:()=>{e.chain().focus().toggleOrderedList().run(),s()},className:pe("flex cursor-pointer items-center gap-x-1 outline-none hover:outline-none",We(e,["orderedList"],t)),children:[G(Sx,{className:"h-4 w-4"}),"Ordered List"]})]})}),G(qr,{editor:e,menuRef:r,from:t,trigger:wt("button",{type:"button",className:pe("flex items-center",We(e,e.isActive({textAlign:"center"})||e.isActive({textAlign:"right"}),t)),title:"Text Alignment",children:[e.isActive({textAlign:"center"})?G(au,{className:"h-4 w-4"}):e.isActive({textAlign:"right"})?G(iu,{className:"h-4 w-4"}):G(su,{className:"h-4 w-4"}),G(ru,{className:"h-3 w-3 opacity-50"})]}),content:s=>wt(Ai,{children:[wt("div",{onClick:()=>{e.chain().focus().setTextAlign("left").run(),s()},className:pe("flex cursor-pointer items-center gap-x-1 outline-none hover:outline-none",We(e,e.isActive({textAlign:"left"}),t)),children:[G(su,{className:"h-4 w-4"})," Align Left"]}),wt("div",{onClick:()=>{e.chain().focus().setTextAlign("center").run(),s()},className:pe("flex cursor-pointer items-center gap-x-1 outline-none hover:outline-none",We(e,e.isActive({textAlign:"center"}),t)),children:[G(au,{className:"h-4 w-4"})," Align Center"]}),wt("div",{onClick:()=>{e.chain().focus().setTextAlign("right").run(),s()},className:pe("flex cursor-pointer items-center gap-x-1 outline-none hover:outline-none",We(e,e.isActive({textAlign:"right"}),t)),children:[G(iu,{className:"h-4 w-4"})," Align Right"]})]})}),e.isActive("link")?G("button",{type:"button",onClick:a,className:pe("",We(e,["link"],t)),title:"Remove Link",disabled:!e.isActive("link"),children:G(Cx,{className:"h-3.5 w-3.5"})}):G("button",{type:"button",onClick:n,className:pe("",We(e,["link"],t)),title:"Add Link",children:G(xx,{className:"h-3.5 w-3.5"})}),o&&wt(Ai,{children:[G("div",{className:"h-5 w-px border-l bg-transparent"}),G("button",{type:"button",onClick:o,className:pe("",We(e,!1,t)),title:"Open in full screen mode",children:G(bx,{className:"h-3.5 w-3.5"})})]})]})},Oa=Nx;import Ex from"@tiptap/extension-color";import Bx from"@tiptap/extension-highlight";import Ax from"@tiptap/extension-link";import Ix from"@tiptap/extension-placeholder";import Dx from"@tiptap/extension-text-align";import _x from"@tiptap/extension-text-style";import Px from"@tiptap/extension-underline";import{useEditor as Lx}from"@tiptap/react";import Rx from"@tiptap/starter-kit";var Fa=({blockId:e,value:t="",onUpdate:o=()=>{},onBlur:r=()=>{},placeholder:n="",from:a="settings",style:s={}})=>Lx({extensions:[Rx,_x,Ex.configure({types:["textStyle"]}),Bx.configure({multicolor:!0}),Ax.configure({openOnClick:!1,HTMLAttributes:{class:"underline"}}),Dx.configure({types:["heading","paragraph"],alignments:["left","center","right"],defaultAlignment:"left"}),Px,Ix.configure({placeholder:n||"Enter text here",emptyEditorClass:"cursor-text before:content-[attr(data-placeholder)] before:absolute before:opacity-50 before:pointer-events-none"})],content:t||"",onUpdate:o,onBlur:r,editorProps:{attributes:{...s?{style:s}:{},class:a!=="canvas"?"text-sm p-1 px-2 rte":"rte"}}},[e]);import{Fragment as fu,jsx as ur,jsxs as mu}from"react/jsx-runtime";function Gx(e){let t=e;for(;t;){if(t.style&&t.style.textAlign)return t.style.textAlign;let o=window.getComputedStyle(t).textAlign;if(o&&o!=="start"&&o!=="initial"&&o!=="inherit")return o;t=t.parentElement}return null}var cu=Ii(({blockContent:e,editingElement:t,onClose:o,onChange:r,onEscape:n})=>{let{document:a}=ie(),s=Fa({value:e,blockId:"active-inline-editing-element",placeholder:"Enter text here",onUpdate:({editor:c})=>r((c==null?void 0:c.getHTML())||""),onBlur:({editor:c,event:d})=>{if(!a)return;let p=d==null?void 0:d.relatedTarget,h=a.querySelector(".ProseMirror"),u=a.querySelector(".tippy-box"),m=a.querySelector("#chai-rich-text-menu-bar"),g=h==null?void 0:h.contains(p),f=u==null?void 0:u.contains(p),b=m==null?void 0:m.contains(p),y=window.document.getElementById("rte-widget-color-picker");if(!g&&!f&&!b&&!y){let k=(c==null?void 0:c.getHTML())||"";o(k)}},from:"canvas"});Di(()=>{var d,p;let c=Gx(t);c&&((d=s==null?void 0:s.commands)==null||d.setTextAlign(c)),(p=s==null?void 0:s.commands)==null||p.focus(),s==null||s.emit("focus",{editor:s,event:new FocusEvent("focus"),transaction:[]})},[t,s]);let i=Qr(()=>{var p;let c="max-w-none shadow-none outline outline-[2px] [&_*]:shadow-none";if(!t)return c;let d=((p=t==null?void 0:t.className)==null?void 0:p.replace("sr-only",""))||"";return`${c} ${d}`},[t]),l=c=>{c.key==="Escape"&&n(c)};return s&&mu("div",{onKeyDown:l,onClick:c=>c.stopPropagation(),className:"relative",children:[ur(Hx,{editor:s,shouldShow:()=>s&&(s==null?void 0:s.isFocused),tippyOptions:{duration:100,arrow:!0,hideOnClick:!1},className:"w-max",children:ur(Oa,{editor:s,from:"canvas"})}),ur(Ox,{id:"active-inline-editing-element",onKeyDown:l,value:e,editor:s,className:i})]})});cu.displayName="RichTextEditor";var du=Ii(({editingElement:e,blockContent:t,onClose:o,editorRef:r,onChange:n,onEscape:a})=>{let{document:s,window:i}=ie();Di(()=>{if(!(!s||!i))if(r.current){r.current.innerHTML=t,r.current.focus();let h=s.createRange(),u=i.getSelection();h.selectNodeContents(r.current),h.collapse(!1),u==null||u.removeAllRanges(),u==null||u.addRange(h),r.current.focus()}else o()},[t,s,r,o,i]);let l=Qr(()=>{var u;let h=((u=e==null?void 0:e.tagName)==null?void 0:u.toLowerCase())||"div";return h==="button"?"div":h},[e]),c=Va(h=>{(h.key==="Enter"||h.key==="Escape")&&a(h)},[a]),d=Va(()=>{o()},[o]),p=Qr(()=>{var h;return{id:"active-inline-editing-element",contentEditable:!0,className:`${((h=e==null?void 0:e.className)==null?void 0:h.replace("sr-only",""))||""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,style:Fx(e==null?void 0:e.style)||{},onInput:u=>{let m=u.target;m&&(m.innerText.trim()===""?(m.setAttribute("data-placeholder","Enter text here"),m.children.length>0&&m.children[0].remove()):u.target.removeAttribute("data-placeholder"),n(u.target.innerText))},onClick:u=>{u.stopPropagation(),u.preventDefault()}}},[e==null?void 0:e.className,e==null?void 0:e.style,n]);return ur(fu,{children:$x(l,{ref:r,onBlur:d,onKeyDown:c,...p})})});du.displayName="MemoizedEditor";var pu=Ii(({block:e,children:t})=>{let o="content",{document:r}=ie(),{editingBlockId:n,editingItemIndex:a,setEditingBlockId:s,setEditingItemIndex:i}=Me(),[l,c]=Ux(null),d=lu(null),{clearHighlight:p}=Ie(),h=ze(),{selectedLang:u}=te(),[,m]=W(),g=lu(null),f=n,{blockContent:b,blockType:y}=Qr(()=>{var T;let x=e._type,B=e[o],I=Be(e._type);return u&&((T=I==null?void 0:I.i18nProps)!=null&&T.includes(o))&&zx(e,`${o}-${u}`)&&(B=Vx(e,`${o}-${u}`)),{blockContent:B,blockType:x}},[e,u]),k=Va(x=>{var I;let B=x||((I=d.current)==null?void 0:I.innerText);h([f],{[o]:B}),c(null),s(""),i(-1),m([]),f&&setTimeout(()=>m([f]),100)},[h,f,s,i,m]),v=Mx(x=>{h([f],{[o]:x})},[f,e,h,u],1e3),S=Va(x=>{x.preventDefault(),f&&(g.current=f),k(),setTimeout(()=>{let B=g.current;g.current=null,B&&m([B])},100)},[f,k,m]);Di(()=>{var N;if(!f||!r)return;let x=`[data-block-id="${f}"]`,B=a>=0?`[data-block-index="${a}"]`:"",I=r.querySelector(`${x}${B}`);I&&((N=I==null?void 0:I.classList)==null||N.add("sr-only"),Wx(()=>c(I)))},[f,y,r,a]);let E=Qr(()=>l?(p(),["RichText","Paragraph"].includes(y)?ur(cu,{blockContent:b,editingElement:l,onChange:v,onClose:k,onEscape:S}):ur(du,{editorRef:d,blockContent:b,editingElement:l,onClose:k,onChange:v,onEscape:S})):null,[l,p,y,b,k,v,S]);return mu(fu,{children:[E,t]})},(e,t)=>e.block._id===t.block._id&&e.block.content===t.block.content);pu.displayName="WithBlockTextEditor";var uu=pu;import{Fragment as wu,jsx as Q,jsxs as Su}from"react/jsx-runtime";var vu=$a({index:-1,key:""}),hu=$a(0),xu=$a({inPartialBlock:!1}),sC={inPartialBlock:!0},en=$a(null),iC=[],lC=["Heading","Paragraph","Link"],cC=["Box","Repeater","GlobalBlock","PartialBlock","Heading","Text","RichText","Span","Image","Button","Paragraph","Link","Video","Audio","Icon","List","ListItem","CustomScript","CustomHTML"],dC=({asyncProps:e,block:t,children:o})=>{let{editingBlockId:r,editingItemIndex:n}=Me(),a=Ke(()=>Be(t._type),[t._type]),{selectedLang:s,fallbackLang:i}=te(),l=et(),[c]=_i(Pn),d=gu(a,"component",null),{index:p,key:h}=mr(vu),{mode:u}=fa(),m=Rc(),{inPartialBlock:g}=mr(xu),f=Re(),b=u==="edit",{onMouseDown:y,onDragStart:k,onDragEnd:v}=Gp(),S=Ke(()=>c?oa(Vs(t,s,a),l,{index:p,key:h}):Vs(t,s,a),[t,s,a,l,c,p,h]),E=Ke(()=>_c(t,!0,m),[t,m]),x=Ke(()=>jp(t._id,Pc(t._type)),[t._id,t._type]),[B]=_i(x),I=Ke(()=>{let _={"data-block-id":t._id,"data-block-type":t._type,"data-block-index":p};return b&&f?{..._,draggable:!r,onMouseDown:y,onDragStart:k,onDragEnd:v}:_},[t._id,t._type,p,b,f,y,k,v,r]),N=Ke(()=>({blockProps:I,inBuilder:u==="edit",inPartialBlock:g,lang:s||i,pageData:l,...S,...E,...B,...e}),[I,u,s,g,i,l,S,E,B,e]),T=Ke(()=>!cC.includes(t._type),[t._type]),C=Ke(()=>{let _=gu(t,"_show",!0);return Jx(_)?c?Dc(_,l)!=="false":!0:_},[t,c,l]);if(qx(d)||!C)return null;let w=Q(oC,{children:eC(d,N,o({_id:t._id,_type:t._type,...yu(S.repeaterItems)?{repeaterItems:Lc(S.repeaterItems,t),$repeaterItemsKey:S.$repeaterItemsKey}:{},...t.partialBlockId?{partialBlockId:t.partialBlockId}:"",...t.globalBlock?{partialBlockId:t.globalBlock}:""}))}),A=r===t._id&&(n===p||p<0)?Q(uu,{block:t,children:w}):w;return T?Q(nC,{fallbackRender:Yp,children:A}):A},pC=({children:e,partialBlockId:t})=>{let o=M("gotoPage",Qx),{saveState:r}=$t(),{selectedLang:n,fallbackLang:a}=te(),s=rC(i=>{if(i.stopPropagation(),r!=="SAVED"){aC.error("You have unsaved changes. Please save the page first.");return}o({pageId:t,lang:n||a})},[r,o,t,n,a]);return Su(wu,{children:[e,Q("div",{className:"partial-overlay group absolute inset-0 z-50",children:Q("div",{onDoubleClick:s,className:"flex h-full w-full items-center justify-center bg-background/10 opacity-0 transition-opacity duration-300 ease-in-out group-hover:opacity-100 group-hover:backdrop-opacity-85",children:Q("p",{className:"rounded-md bg-white px-2 py-1 text-xs",children:"Partial block. Double click to edit."})})})]})},uC=()=>Q("div",{className:"flex items-center justify-center rounded-md border border-destructive bg-destructive/10 p-4 text-center text-sm text-destructive",children:Su("p",{children:["Maximum partial nesting depth (",4," levels) exceeded"]})}),mC=({partialBlockId:e})=>{let{getPartialBlocks:t}=rr(),o=mr(hu),r=Ke(()=>t(e),[t,e]),n=Ke(()=>Yx(Kx(r)),[r]),a=Hs(n),s=Ke(()=>({childrenMap:_l(r!=null?r:[]),getBlockAtom:a}),[r,a]);return o>=4?Q(uC,{}):Xx(r)?null:Q(hu.Provider,{value:o+1,children:Q(xu.Provider,{value:sC,children:Q(pC,{partialBlockId:e,children:Q(en.Provider,{value:s,children:Q(za,{type:"PartialBlock"})})})})})},Cu=tC(({id:e,contentSpacing:t})=>{var n;let o=mr(en),r=(n=o==null?void 0:o.getBlockAtom(e))!=null?n:null;return r?Q(fC,{blockAtom:r,contentSpacing:t}):null});Cu.displayName="BlockSubtree";var fC=({blockAtom:e,contentSpacing:t})=>{var s;let o=mr(en),[r]=_i(e),n=Ke(()=>t?Mc(r,t==="trail"):r,[r,t]),a=(s=o==null?void 0:o.childrenMap.has(n._id))!=null?s:!1;return Q(Zp,{block:n,children:i=>Q(dC,{block:n,asyncProps:i,children:({_id:l,_type:c,partialBlockId:d,repeaterItems:p,$repeaterItemsKey:h})=>c==="Repeater"?yu(p)&&p.map((u,m)=>Q(vu.Provider,{value:{index:m,key:h},children:Q(za,{parent:l,type:c})},`${l}-${m}`)):c==="GlobalBlock"||c==="PartialBlock"?Q(jx,{store:L,children:Q(mC,{partialBlockId:d})}):a?Q(za,{parent:l,type:c}):null})})},za=({parent:e=null,type:t=""})=>{var a;let o=mr(en),r=(a=o==null?void 0:o.childrenMap.get(e||null))!=null?a:iC,n=lC.includes(t);return Q(wu,{children:r.map((s,i)=>Q(Cu,{id:s._id,contentSpacing:n?i===r.length-1?"trim":"trail":void 0},s._id))})},ku=()=>{let e=Zx(Rl),t=Hs(Pl),o=Ke(()=>({childrenMap:e,getBlockAtom:t}),[e,t]);return Q(en.Provider,{value:o,children:Q(za,{})})};import{Fragment as bC,jsx as Tu}from"react/jsx-runtime";var Nu=()=>{let e=hC(Ml),[t]=gC(Do);return Tu(bC,{children:e?Tu(ku,{},t):null})};import{useEffect as yC,useMemo as vC}from"react";var Eu=(e,t)=>{var i;let o=(i=t==null?void 0:t.disabled)!=null?i:!1,[r]=xo(),[,n]=cr(),a=M("htmlDir","ltr"),s=vC(()=>{if(o)return{};let{width:l,height:c}=e;if(l>0&&l<r){let d=parseFloat((l/r).toFixed(2).toString()),p={},h=c*d,u=l*d;return c&&(p={height:100+(c-h)/h*100+"%",width:100+(l-u)/u*100+"%"}),{position:"relative",top:0,transform:`scale(${d})`,transformOrigin:a==="rtl"?"top right":"top left",...p,maxWidth:"none"}}return{}},[r,e,a,o]);return yC(()=>{if(o)return;let{width:l}=e;if(l)if(l<r){let c=parseFloat((l/r).toFixed(2).toString());n(c*100)}else n(100)},[r,e,n,o]),s};import{useEffect as fr,useMemo as xC,useRef as CC}from"react";var Bu=({dimension:e,wrapperRef:t})=>{let[o]=So(),[r]=xo(),[n]=cr(),[a]=Fp(),[s]=zp(),i=CC(o);fr(()=>{let c=t.current;c&&L.set(Xt,{width:c.clientWidth,height:c.clientHeight})},[e,t]),fr(()=>{var c,d;if(o&&!i.current){let p=(d=(c=t.current)==null?void 0:c.clientWidth)!=null?d:0,h=qt(L.get(Ge))/100;L.set(ut,{x:La(r*h,p),y:ki})}else!o&&i.current&&(L.set(ut,{x:0,y:0}),L.set(Co,"select"),L.set(ko,!1));i.current=o},[o]),fr(()=>{if(!o)return;let c=L.get(Xt),d=qt(L.get(Ge))/100,p=L.get(ut);L.set(ut,{x:La(r*d,c.width),y:Ro(p.y,s*d,c.height)})},[r]),fr(()=>{o&&wo(0,0)},[o,e,s]),fr(()=>{let c=d=>{d.ctrlKey||d.metaKey||d.altKey||d.key!=="p"&&d.key!=="P"||dr(d.target)||Ma()};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[]),fr(()=>{if(!o)return;let c=t.current;if(!c)return;let d=u=>{if(u.preventDefault(),u.ctrlKey||u.metaKey){let f=c.getBoundingClientRect(),b=qt(L.get(Ge)*Math.exp(-u.deltaY*.01));Ra(b,u.clientX-f.left,u.clientY-f.top);return}let m=u.deltaX,g=u.deltaY;u.shiftKey&&m===0&&(m=g,g=0),wo(-m,-g)},p=u=>{if(!dr(u.target)){if(u.code==="Space"){u.repeat||(u.preventDefault(),L.set(ko,!0));return}u.ctrlKey||u.metaKey||u.altKey||((u.key==="v"||u.key==="V"||u.key==="Escape")&&L.set(Co,"select"),(u.key==="h"||u.key==="H")&&L.set(Co,"hand"))}},h=u=>{u.code==="Space"&&L.set(ko,!1)};return c.addEventListener("wheel",d,{passive:!1}),document.addEventListener("keydown",p),document.addEventListener("keyup",h),()=>{c.removeEventListener("wheel",d),document.removeEventListener("keydown",p),document.removeEventListener("keyup",h)}},[o,t]);let l=xC(()=>{if(!o)return null;let c=qt(n)/100;return{position:"absolute",top:0,left:0,width:`${r}px`,height:`${Math.max(s,100)}px`,maxWidth:"none",margin:0,transform:`translate(${a.x}px, ${a.y}px) scale(${c})`,transformOrigin:"0 0"}},[o,n,a,r,s]);return{enabled:o,style:l}};import{first as kC,isEmpty as Pi}from"lodash-es";import{useEffect as Au}from"react";var wC=(e,t)=>e.length===t.length&&e.every((o,r)=>o===t[r]),Iu=()=>{let[e,t]=W(),[o,r]=K(),{document:n}=ie(),{clearHighlight:a}=Ie();return Au(()=>{if(Pi(e)||!Pi(o))return;let s=requestAnimationFrame(()=>{if(!Pi(o))return;let i=ir(n,kC(e));if(i){let l=i.getAttribute("data-style-prop");if(l){let c=i.getAttribute("data-style-id"),d=i.getAttribute("data-block-parent");r([{id:c,prop:l,blockId:d}])}}});return()=>cancelAnimationFrame(s)},[n,e,r,o]),Au(()=>()=>a(),[a]),Kt(U.CANVAS_BLOCK_SELECTED,s=>{s&&t(i=>wC(i,s)?i:s)}),Kt(U.CANVAS_BLOCK_STYLE_SELECTED,s=>{if(!s)return;let{blockId:i,styleId:l,styleProp:c}=s;i&&(r([{id:l,prop:c,blockId:i}]),t(d=>d.length===1&&d[0]===i?d:[i]))}),Kt(U.CLEAR_CANVAS_SELECTION,()=>{a(),t([]),r([])}),null};import{Fragment as DC,jsx as je,jsxs as Wa}from"react/jsx-runtime";var IC=()=>{let[e]=xo(),[,t]=Na(),o=Du(null),r=Du(null),[n,a]=BC({width:0,height:0}),[s]=So(),i=Eu(n,{disabled:s}),{style:l}=Bu({dimension:n,wrapperRef:r}),[,c]=dt(),d=M("loading",!1),p=M("htmlDir","ltr"),{onDragOver:h,onDrop:u,onDragEnd:m}=pt(),g=Xd(),f=TC(y=>{a(k=>({...k,width:y}))},[a]);NC(()=>{if(!r.current)return;let{clientWidth:y,clientHeight:k}=r.current;a({width:y,height:k})},[r,e]);let b=EC(()=>{let y=hp;return y=y.replace("__HTML_DIR__",p),y},[p]);return je(Up,{onMount:f,onResize:f,children:Wa("div",{onMouseLeave:()=>setTimeout(()=>t(""),300),className:"relative mx-auto h-full w-full overflow-hidden pt-6",onDragOver:h,onDrop:u,onDragEnd:m,ref:r,children:[Wa(yi,{contentDidMount:()=>c(o.current),ref:o,id:"canvas-iframe",style:s?l!=null?l:{}:{...i,...SC(i)?{width:`${e}px`}:{}},className:`relative mx-auto box-content h-full w-full max-w-full ${s?"shadow-lg":"transition-all duration-300 ease-linear"}`,initialContent:b,children:[je(vp,{}),je($p,{pannable:s}),je(gp,{}),je(Bp,{}),Wa(AC,{children:[Wa(pp,{children:[d?je("div",{className:"h-full p-4",children:je(_o,{className:"h-full"})}):je(Nu,{}),je(Cp,{})]}),je(Iu,{})]}),je(DC,{children:g.isVisible&&je("div",{id:"placeholder",className:`pointer-events-none absolute z-[99999] max-w-full ${g.isEmpty?"bg-purple-500/10 outline-dashed outline-2 -outline-offset-4 outline-purple-500":"rounded-full bg-green-500"}`,style:{top:g.top,left:g.left,width:g.width,height:g.height}})})]}),s&&je(Wp,{})]})})},_u=IC;import{DropdownMenuSeparator as JC}from"@radix-ui/react-dropdown-menu";import{EraserIcon as QC,LightningBoltIcon as ek}from"@radix-ui/react-icons";import{useAtom as tk}from"jotai";import{Hand as ok,MoreVertical as rk,SunMoon as nk}from"lucide-react";import{useTranslation as ak}from"react-i18next";import{round as Pu}from"lodash-es";import{Minus as _C,Plus as PC}from"lucide-react";import{useTranslation as LC}from"react-i18next";import{jsx as Ua,jsxs as Li}from"react/jsx-runtime";var Lu=()=>{let[e]=cr(),[t]=So(),{t:o}=LC();return t?Li("div",{className:"flex items-center gap-0.5",children:[Ua(D,{size:"sm",variant:"ghost",className:"size-2 h-6 w-6 rounded-md p-1","aria-label":o("Zoom out"),title:o("Zoom out"),onClick:()=>wi(e/1.2),children:Ua(_C,{className:"h-3 w-3"})}),Li("button",{type:"button",className:"w-10 px-1 text-center text-xs text-foreground/50 hover:text-foreground",title:o("Reset zoom"),onClick:Op,children:[Pu(e,0),"%"]}),Ua(D,{size:"sm",variant:"ghost",className:"size-2 h-6 w-6 rounded-md p-1","aria-label":o("Zoom in"),title:o("Zoom in"),onClick:()=>wi(e*1.2),children:Ua(PC,{className:"h-3 w-3"})})]}):Li("div",{className:"px-2 text-xs text-foreground/50",children:[Pu(e,0),"%"]})};import{Hand as RC,MousePointer2 as MC}from"lucide-react";import{useTranslation as HC}from"react-i18next";import{jsx as Ga,jsxs as OC}from"react/jsx-runtime";var Ru=()=>{let[e,t]=Ha(),{t:o}=HC();return OC("div",{className:"flex items-center gap-0.5 rounded-md border border-border bg-muted/40 p-0.5",children:[Ga(D,{size:"sm","aria-label":o("Select"),variant:e==="select"?"secondary":"ghost",className:`h-6 w-6 rounded-sm p-1 ${e==="select"?"bg-orange text-orange-foreground hover:bg-orange/90":"text-foreground/50"}`,title:`${o("Select")} (V)`,onClick:()=>t("select"),children:Ga(MC,{className:"h-3.5 w-3.5"})}),Ga(D,{size:"sm","aria-label":o("Hand tool"),variant:e==="hand"?"secondary":"ghost",className:`h-6 w-6 rounded-sm p-1 ${e==="hand"?"bg-orange text-orange-foreground hover:bg-orange/90":"text-foreground/50"}`,title:`${o("Hand tool")} (H)`,onClick:()=>t("hand"),children:Ga(RC,{className:"h-3.5 w-3.5"})})]})};import{ChevronDownIcon as $C}from"@radix-ui/react-icons";import{includes as Hu,map as Ri,toUpper as Mi}from"lodash-es";import{Laptop as WC,Monitor as UC,Smartphone as Ou,Tablet as Fu}from"lucide-react";import{useTranslation as $u}from"react-i18next";import{useAtom as FC}from"jotai";import{atomWithStorage as VC}from"jotai/utils";var zC=VC("selectedBreakpoints",["XS","MD","XL"]),Mu=()=>{let[e,t]=FC(zC);return[e,t]};import{jsx as le,jsxs as tn}from"react/jsx-runtime";import{createElement as zu}from"react";var GC=[{title:"Mobile (Base)",content:"Styles set here are applied to all screen unless edited at higher breakpoint",breakpoint:"xs",icon:le(Ou,{}),width:400},{title:"Mobile landscape (SM)",content:"Styles set here are applied at 640px and up unless edited at higher breakpoint",breakpoint:"sm",icon:le(Ou,{className:"rotate-90"}),width:640},{title:"Tablet (MD)",content:"Styles set here are applied at 768px and up",breakpoint:"md",icon:le(Fu,{}),width:800},{title:"Tablet Landscape (LG)",content:"Styles set here are applied at 1024px and up unless edited at higher breakpoint",breakpoint:"lg",icon:le(Fu,{className:"rotate-90"}),width:1024},{title:"Desktop (XL)",content:"Styles set here are applied at 1280px and up unless edited at higher breakpoint",breakpoint:"xl",icon:le(WC,{}),width:1420},{title:"Large Desktop (2XL)",content:"Styles set here are applied at 1536px and up",breakpoint:"2xl",icon:le(UC,{}),width:1920}],Vu=({openDelay:e=400,tooltip:t=!0,title:o,currentBreakpoint:r,breakpoint:n,width:a,icon:s,content:i="",onClick:l})=>{let{t:c}=$u(),d=n===r;return t?tn(Cc,{openDelay:e,children:[le(kc,{asChild:!0,children:le(D,{onClick:()=>l(a),size:"icon-sm",variant:"ghost",className:`border-none text-foreground shadow-none hover:bg-accent ${d?"bg-accent":""}`,children:s})}),le(wc,{side:"bottom",className:"w-auto max-w-52",children:tn("div",{className:"space-y-1",children:[le("h4",{className:"text-xs font-semibold",children:c(o)}),le("p",{className:"text-xs text-muted-foreground",children:c(i)})]})})]}):le(D,{onClick:()=>l(a),size:"icon-sm",variant:d?"outline":"ghost",children:s})},Wu=({openDelay:e=400,canvas:t=!1,tooltip:o=!0,buttonClass:r="",activeButtonClass:n=""})=>{let[a,,s]=jr(),[i,l]=xo(),[c,d]=Mu(),p=c,h=d,{t:u}=$u(),m=M("breakpoints",GC),g=y=>{p.includes(y)?p.length>2&&h(p.filter(k=>k!==y)):h(k=>[...k,y])},f=y=>{t||s(y),l(y)},b=Dn(t?i:a).toLowerCase();return m.length<4?le("div",{className:"flex items-center rounded-md",children:Ri(m,y=>zu(Vu,{canvas:t,...y,onClick:f,key:y.breakpoint,currentBreakpoint:b,activeButtonClass:"bg-gray-700"}))}):tn("div",{className:"flex w-full items-center justify-between",children:[le("div",{className:"flex items-center gap-px",children:Ri(m.filter(y=>Hu(p,Mi(y.breakpoint))),y=>zu(Vu,{canvas:t,openDelay:e,tooltip:o,...y,onClick:f,key:y.breakpoint,currentBreakpoint:b,buttonClass:r,activeButtonClass:n}))}),tn(ot,{children:[le(rt,{asChild:!0,children:le(D,{size:"icon-sm",variant:"ghost",className:"mx-px h-6 w-6 outline-none",children:le($C,{className:"h-3 w-3"})})}),tn(nt,{align:"end",className:"w-48",children:[le(vc,{children:u("Screen sizes")}),le(Xn,{}),Ri(m,y=>le(yc,{disabled:y.breakpoint==="xs",onCheckedChange:()=>g(Mi(y.breakpoint)),checked:Hu(p,Mi(y.breakpoint)),onSelect:k=>k.preventDefault(),children:u(y.title)},y.breakpoint))]})]})]})};import{EraserIcon as KC}from"@radix-ui/react-icons";import{useCallback as jC}from"react";import{useTranslation as ZC}from"react-i18next";import{jsx as Mo,jsxs as Ka}from"react/jsx-runtime";var Uu=({children:e})=>{let{t}=ZC(),{setNewBlocks:o}=ye(),[,r]=W(),[,n]=K(),a=jC(()=>{o([]),r([]),n([])},[o,r,n]);return Ka(na,{children:[Mo(Hc,{asChild:!0,children:e||Mo(D,{size:"sm",variant:"ghost",className:"flex items-center",children:Mo(KC,{})})}),Ka(aa,{className:"border-border",children:[Ka(sa,{children:[Mo(ia,{className:"text-foreground",children:t("Clear whole canvas?")}),Mo(Fc,{children:t("Are you sure you want to clear the page?")})]}),Ka(Oc,{children:[Mo(zc,{className:"text-foreground",children:t("Cancel")}),Mo(Vc,{onClick:a,children:t("Yes")})]})]})]})};import{Redo2 as YC,Undo2 as XC}from"lucide-react";import{jsx as ja,jsxs as qC}from"react/jsx-runtime";var Gu=()=>{let{undo:e,redo:t}=so(),{canUndo:o,canRedo:r}=Xl();return qC("div",{className:"flex items-center gap-px px-px",children:[ja(D,{disabled:!o,size:"icon-sm",onClick:e,variant:"ghost",children:ja(XC,{})}),ja(D,{disabled:!r,onClick:t,size:"icon-sm",variant:"ghost",children:ja(YC,{})})]})};import{jsx as ne,jsxs as Jt}from"react/jsx-runtime";var Ku=()=>{let e=M("flags.darkMode",!1),t=M("flags.dataBinding",!0),[o,r]=tk(Pn),{t:n}=ak(),a=e,s=t,[i,l]=_t(),[c,d]=So();return Jt("div",{className:"flex h-10 items-center justify-between px-2",children:[ne("div",{className:"flex items-center",children:Jt("div",{className:"flex items-center",children:[ne(Wu,{canvas:!0,openDelay:400,activeButtonClass:"bg-gray-200"}),ne("div",{className:"h-4 w-px border-l bg-transparent"}),ne(Lu,{}),ne("div",{className:"h-4 w-px border-l bg-transparent"}),ne(Gu,{})]})}),Jt("div",{className:"flex items-center gap-2",children:[c?ne(Ru,{}):null,Jt(ot,{children:[ne(rt,{asChild:!0,children:ne(D,{size:"sm",variant:"ghost",className:"size-2 h-7 w-7 rounded-md p-1",children:ne(rk,{className:"h-2 w-2"})})}),Jt(nt,{className:"w-44 border-border text-xs",side:"bottom",align:"end",children:[ne(Yn,{className:"px-2 py-1 font-light text-foreground/50",children:n("ACTIONS")}),ne(Pe,{disabled:!1,onClick:p=>p.preventDefault(),className:"flex items-center gap-x-2 text-xs",children:ne(Uu,{children:Jt("div",{className:"flex items-center gap-x-2 text-xs",children:[ne(QC,{})," ",n("Clear canvas")]})})}),ne(JC,{className:"my-1 h-px bg-accent"}),a?Jt(Pe,{onSelect:p=>p.preventDefault(),className:"py-1.5",children:[ne(nk,{}),ne("span",{className:"flex-1",children:n("Dark Mode")}),ne(At,{checked:i,onCheckedChange:()=>l(!i)})]}):null,s?Jt(Pe,{onSelect:p=>p.preventDefault(),className:"py-1.5",children:[ne(ek,{}),ne("span",{className:"flex-1",children:n("Data Binding")}),ne(At,{checked:o,onCheckedChange:()=>r(!o)})]}):null,Jt(Pe,{onSelect:p=>p.preventDefault(),className:"py-1.5",children:[ne(ok,{}),ne("span",{className:"flex-1",children:n("Pannable Canvas")}),ne(At,{checked:c,onCheckedChange:()=>d(!c)})]})]})]})]})]})};import{jsx as Pt,jsxs as pk}from"react/jsx-runtime";var ck=ik.lazy(()=>import("./code-editor-UBGTTX2L.js")),dk=()=>{let[e]=ra(),t=M("onError",sk);return Pt("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:pk("div",{className:"relative flex h-full max-h-full flex-col overflow-hidden",children:[Pt(Ku,{}),Pt(ju,{fallback:Pt(_o,{className:"h-full"}),children:Pt(lk,{fallback:Pt(go,{}),onError:t,children:Pt(_u,{})})}),e?Pt(ju,{fallback:Pt(_o,{className:"h-full"}),children:Pt(ck,{})}):null]})})},Zu=dk;import{Cross2Icon as l0}from"@radix-ui/react-icons";import{useCallback as Sm,useState as Ui}from"react";import{useTranslation as c0}from"react-i18next";import{useAtom as $i}from"jotai";import{atomWithStorage as qk}from"jotai/utils";import{capitalize as Jk,debounce as Qk,filter as Ja,find as e0,map as bm,reject as Vi,sortBy as t0,values as hr}from"lodash-es";import{BookText as o0,BrickWall as r0,LayoutPanelLeft as n0,PanelTop as Wi,TvMinimalPlay as a0,Type as s0}from"lucide-react";import ym,{useCallback as nn,useEffect as Qa,useMemo as rn,useRef as vm,useState as zi}from"react";import{useTranslation as Cm}from"react-i18next";import{BoxIcon as uk}from"@radix-ui/react-icons";import{capitalize as mk,has as fk,isFunction as gk,kebabCase as hk}from"lodash-es";import{createElement as bk}from"react";import{useTranslation as yk}from"react-i18next";import{Fragment as vk,jsx as on,jsxs as Yu}from"react/jsx-runtime";var Xu=({block:e,disabled:t,parentId:o,position:r})=>{let{type:n,icon:a,label:s,disabledReason:i}=e,l=t||e.disabled,{addCoreBlock:c,addPredefinedBlock:d}=Le(),p=()=>{if(fk(e,"blocks")){let f=gk(e.blocks)?e.blocks():e.blocks;d(ao(f),o||null,r)}else c(e,o||null,r);J.publish(U.CLOSE_ADD_BLOCK)},h=Re(),{t:u}=yk(),{onDragStart:m,onDragEnd:g}=pt();return on(vk,{children:Yu(me,{delayDuration:1e3,children:[on(fe,{asChild:!0,children:Yu(D,{variant:"outline",disabled:l,onClick:p,onDragStart:f=>!l&&m(f,{...e,label:s,icon:a}),onDragEnd:g,draggable:h&&!l,className:`group flex h-fit flex-col items-center justify-center gap-1 whitespace-normal py-2 ${hk(`chai-block-${n}`)}`,children:[bk(a||uk,{className:"w-4 h-4 mx-auto group-hover:scale-95 transition-transform","data-add-core-block-icon":n}),on("p",{className:"max-w-full line-clamp-1 truncate hyphens-auto break-words text-center text-xs font-light leading-tight",children:mk(u(s||n))})]})}),on(ge,{children:on("p",{children:l&&i?i:u(s||n)})})]},s)})};import{filter as xk,groupBy as Ck,map as kk,uniq as wk}from"lodash-es";import{jsx as Sk}from"react/jsx-runtime";var qu=({parentId:e,position:t,gridCols:o="grid-cols-2",disableBlockGroupsSidebar:r=!1})=>{let n=Ln(),{data:a}=sc(),s=(a==null?void 0:a.pageType)||"page",i=Ck(n,"category"),l=xk(i.core,d=>fc(d,s)),c=wk(kk(l,"group"));return Sk(Za,{gridCols:o,parentId:e,position:t,groups:c,blocks:l,disableBlockGroupsSidebar:r})};import{CircleIcon as Tk}from"@radix-ui/react-icons";import{useState as Ju}from"react";import{useTranslation as Nk}from"react-i18next";import{Fragment as Bk,jsx as gr,jsxs as Hi}from"react/jsx-runtime";var Ek=({parentId:e,position:t,fromSidebar:o})=>{let{t:r}=Nk(),[n,a]=Ju(""),{addPredefinedBlock:s}=Le(),[i,l]=Ju(!1),c=async()=>{l(!0);let d=await uc(n),p=await uo(d);s([...p],e,t),a(""),l(!1),J.publish(U.CLOSE_ADD_BLOCK)};return Hi("div",{className:`space-y-4 py-4 ${o?"w-full":"max-w-full"}`,children:[gr("p",{className:`text-muted-foreground ${o?"text-xs":"text-sm"}`,children:r("Use HTML snippets from Tailwind CSS component libraries")}),Hi("div",{className:"space-y-2",children:[gr(z,{children:r("Tailwind HTML snippet")}),gr(ar,{onChange:d=>a(d.target.value),rows:12,value:n,placeholder:r("Enter your code snippet here"),className:"resize-none overflow-x-auto whitespace-pre text-xs font-extralight"})]}),gr("div",{className:"flex justify-end",children:gr(D,{disabled:n.trim()===""||i,onClick:()=>c(),size:"sm",className:"w-fit",children:i?Hi(Bk,{children:[gr(Tk,{className:"mr-2 h-4 w-4 animate-spin"})," ",r("Importing...")]}):r("Import HTML")})})]})},Qu=Ek;import{CaretRightIcon as _k,ReloadIcon as pm}from"@radix-ui/react-icons";import{clsx as Pk}from"cnfast";import Lk from"fuse.js";import{useSetAtom as Rk}from"jotai";import{capitalize as rm,filter as nm,first as am,get as Ya,groupBy as Mk,has as Hk,isEmpty as Ho,keys as sm,map as im}from"lodash-es";import{useCallback as Ok,useEffect as Fk,useMemo as Xa,useRef as lm,useState as Fi}from"react";import{useTranslation as Vk}from"react-i18next";import{useAtom as Ak}from"jotai";var em=()=>Ak(_n);import{get as tm,isEmpty as om,omit as Ik}from"lodash-es";import{jsx as Dk}from"react/jsx-runtime";var Oi=({block:e,html:t,blocks:o,children:r,onDragStart:n,onDragEnd:a,draggable:s,className:i="",type:l="Box"})=>{let{onDragStart:c,onDragEnd:d}=pt(),p=Re(),[,h]=W(),{clearHighlight:u}=Ie(),m=s!==void 0?s:p;return Dk("div",{draggable:m,onDragStart:async b=>{try{if(n){n(b);return}let y=null;if(l==="Image"){if(!(e!=null&&e.image))return;y={type:"Image",blocks:[{_type:"Image",styles:"#styles:,w-full h-full object-cover",image:e==null?void 0:e.image,alt:(e==null?void 0:e.alt)||"",_name:(e==null?void 0:e.name)||"Image"}]}}else if(t){let k=typeof t=="function"?await t():t,v=await uo(k);if(om(v))return;y={type:"Box",blocks:v,name:tm(v,"0._type","Block")}}else if(o){let k=typeof o=="function"?await o():o;if(om(k))return;y={type:"Box",blocks:k,name:tm(k,"0._type","Block")}}else if(e){let k=typeof e=="function"?await e():e;y=typeof k=="object"?Ik(k,["component","icon"]):k}if(!y)return;c(b,y,!0),setTimeout(()=>{h([]),u()},200)}catch(y){console.error("Error in ChaiDraggableBlock drag start:",y)}},onDragEnd:b=>{a?a(b):d()},className:`${m?"cursor-grab active:cursor-grabbing":""} ${i}`.trim(),children:r})};import{Fragment as dm,jsx as R,jsxs as He}from"react/jsx-runtime";var cm=({block:e,library:t,parentId:o=void 0,position:r=-1})=>{let[n,a]=Fi(!1),s=Xa(()=>(t==null?void 0:t.getBlock)||(()=>[]),[t]),{addCoreBlock:i,addPredefinedBlock:l}=Le(),c=Ya(e,"name",Ya(e,"label")),d=Ya(e,"description",""),{onDragStart:p,onDragEnd:h}=pt(),u=Re(),m=Rk(bt),g=Ok(async b=>{if(b.stopPropagation(),Hk(e,"component")){i(e,o,r),J.publish(U.CLOSE_ADD_BLOCK);return}a(!0);let y=await s({library:t,block:e});typeof y=="string"&&(y=await uo(y)),Ho(y)||l(ao(y),o,r),J.publish(U.CLOSE_ADD_BLOCK),setTimeout(()=>a(!1),1e3)},[i,l,e,s,t,o,r]);return He(me,{children:[R(fe,{asChild:!0,children:R(Oi,{draggable:u,onDragStart:b=>{u&&(p(b,{type:"Box",name:c},!0),s({library:t,block:e}).then(async y=>{typeof y=="string"&&(y=await uo(y)),m(k=>k&&{...k,blocks:y})}))},onDragEnd:h,children:He("div",{onClick:n?()=>{}:g,className:Pk("relative mt-2 overflow-hidden rounded-md border border-border duration-200 hover:border-blue-500 hover:shadow-xl",u?"":"cursor-pointer"),children:[n&&He("div",{className:"absolute flex h-full w-full items-center justify-center bg-background/70",children:[R(pm,{className:"h-4 w-4 animate-spin text-white"}),R("span",{className:"pl-2 text-sm text-white",children:"Adding..."})]}),e.preview?R(ea,{src:e.preview,className:"min-h-[45px] w-full rounded-md",alt:c}):He("div",{className:"flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center",children:[R("p",{className:"font-medium text-gray-800",children:c}),d&&R("p",{className:"text-sm text-gray-600",children:d})]})]})})}),R(ge,{children:R("div",{className:"max-w-xs",children:R("p",{className:"font-medium",children:c})})})]})},zk=({parentId:e,position:t,fromSidebar:o})=>{let[r,n]=em(),a=Un(),s=a.find(C=>C.id===r)||am(a),{data:i,isLoading:l,isError:c,resetLibrary:d}=$c(s),[p,h]=Fi(""),u=Xa(()=>i&&Array.isArray(i)&&i.length>0?new Lk(i,{keys:["name","label","description","group"],threshold:.4,ignoreLocation:!0}):null,[i]),m=Xa(()=>!p.trim()||!u?[]:u.search(p).map(C=>C.item),[p,u]),g=p.trim()&&!Ho(m)?m:i||[],f=Mk(g,"group"),[b,y]=Fi(null),k=Xa(()=>Ho(sm(f))?null:b&&f[b]?b:am(sm(f))||null,[f,b]),v=Ya(f,k||"",[]),S=lm(null),{t:E}=Vk(),x=lm(null);Fk(()=>{var w;let C=(w=x.current)==null?void 0:w.querySelector("[data-radix-scroll-area-viewport]");C&&C.scrollTo({top:0,behavior:"smooth"})},[s,k]);let B=C=>{S.current&&(clearTimeout(S.current),S.current=null),S.current=setTimeout(()=>{S.current&&y(C)},400)},I=()=>{s!=null&&s.id&&d(s.id)};if(l)return He("div",{className:"flex animate-pulse flex-col space-y-1 py-2",children:[R("div",{className:"h-7 w-full rounded-md bg-accent"}),R("div",{className:"h-7 w-full rounded-md bg-accent"}),R("div",{className:"h-7 w-full rounded-md bg-accent"}),R("div",{className:"h-3"}),R("div",{className:"h-36 w-full rounded-md bg-accent"}),R("div",{className:"h-36 w-full rounded-md bg-accent"}),R("div",{className:"h-36 w-full rounded-md bg-accent"})]});let N=nm(v,(C,w)=>w%2===0),T=nm(v,(C,w)=>w%2===1);return R(dm,{children:R("div",{className:"flex h-full max-h-full flex-col py-2",children:R("div",{className:"bg-surface relative flex h-full max-h-full flex-1 overflow-hidden",children:He("div",{className:`flex h-full flex-1 ${o?"flex-col":""}`,children:[He("div",{className:`flex max-h-full min-w-60 flex-col gap-1 ${o?"pb-2":"w-60 max-w-60 px-1 pr-2"}`,children:[R("div",{className:"space-y-0",children:He(at,{value:s==null?void 0:s.id,onValueChange:n,children:[R(it,{className:"w-full",children:R(st,{placeholder:E("Select library"),children:s==null?void 0:s.name})}),R(lt,{children:a.map(C=>R(ct,{value:C.id,children:C.name},C.id))})]})}),He("div",{className:"flex h-full max-h-full w-full flex-1 flex-col",children:[!o&&R("hr",{className:"mt-1 border-border"}),R("div",{className:`no-scrollbar h-full max-h-full flex-1 overflow-y-auto ${o?"":"pb-20"}`,children:Ho(f)?R("div",{className:"mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center",children:p?R("p",{className:"text-sm",children:E("No matching blocks found")}):c?He(dm,{children:[R("p",{className:"text-sm",children:E("Failed to load the UI library. Try again")}),He(D,{onClick:I,variant:"outline",size:"sm",className:"gap-2",children:[R(pm,{className:"h-4 w-4"}),E("Retry")]})]}):R(z,{children:E("This library is empty")})}):o?He(at,{value:k!=null?k:"",onValueChange:y,children:[R(it,{className:"w-full",children:R(st,{placeholder:E("Select a group")})}),R(lt,{children:im(f,(C,w)=>R(ct,{value:w,children:rm(E(w.toLowerCase()))},w))})]}):im(f,(C,w)=>He("div",{onMouseEnter:()=>B(w),onMouseLeave:()=>S.current&&clearTimeout(S.current),role:"button",onClick:()=>y(w),className:Nn("flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",w===k?"bg-primary text-primary-foreground hover:bg-primary/80":""),children:[R("span",{children:rm(E(w.toLowerCase()))}),R(_k,{className:"ml-2 h-5 w-5"})]},w))})]}),!Ho(f)&&R(la,{value:p,setValue:h})]}),R("div",{className:`flex h-full max-h-full w-full flex-col border-border ${o?"":"border-l"}`,children:He(Mr,{ref:x,onMouseEnter:()=>S.current&&clearTimeout(S.current),className:"z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",children:[Ho(v)&&!Ho(f)?R("div",{className:"flex h-full flex-col items-center justify-center p-6 text-center",children:R("p",{className:"text-sm",children:E("No blocks found in this group")})}):He("div",{className:`grid w-full gap-2 ${o?"grid-cols-1 pb-20":"grid-cols-2 px-2"}`,children:[R("div",{className:"flex flex-col gap-1",children:N.map((C,w)=>R(cm,{parentId:e,position:t,block:C,library:s},`block-${w}`))}),R("div",{className:"flex flex-col gap-1",children:T.map((C,w)=>R(cm,{parentId:e,position:t,block:C,library:s},`block-second-${w}`))})]}),R("br",{}),R("br",{}),R("br",{})]})})]})})})})},$k=({parentId:e,position:t,fromSidebar:o})=>R(zk,{parentId:e,position:t,fromSidebar:o}),um=$k;import{FrameIcon as Wk}from"@radix-ui/react-icons";import{atom as gm,useAtom as mm}from"jotai";import{map as Uk,uniq as Gk}from"lodash-es";import{useEffect as Kk,useMemo as jk}from"react";import{jsx as qa,jsxs as Xk}from"react/jsx-runtime";var Zk=gm({blocks:[],groups:[],isLoading:!0,error:null}),Yk=gm(!1),fm=e=>{if(!e)return"";let t=e.replace(/[-_]/g," ");return t=t.replace(/([a-z])([A-Z])/g,"$1 $2"),t.split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1).toLowerCase()).join(" ")},hm=({parentId:e,position:t,gridCols:o="grid-cols-2",disableBlockGroupsSidebar:r=!1})=>{let{data:n,isLoading:a,refetch:s,error:i}=Mn(),[l,c]=mm(Zk),[d,p]=mm(Yk),h=Hn();Kk(()=>{if(!d||Object.keys(l.blocks).length===0)if(i)c({blocks:[],groups:[],isLoading:!1,error:i}),p(!0);else if(!a&&Object.keys(n||{}).length>0){let g=Object.entries(n).map(([b,y])=>{let k=y,v=k.type||"partial",S=fm(v);return{type:"PartialBlock",label:fm(k.name||b),description:k.description||"",icon:Wk,group:S,category:"partial",partialBlockId:b,_name:k.name}}),f=Gk(Uk(g,"group"));c({blocks:g,groups:f,isLoading:!1,error:null}),p(!0)}else a?c(g=>({...g,isLoading:!0,error:null})):!a&&Object.keys(n||{}).length===0&&(c({blocks:[],groups:[],isLoading:!1,error:"No partial blocks available"}),p(!0))},[a,n,d,p,c,l.blocks,i]);let u=()=>{c(g=>({...g,isLoading:!0,error:null})),p(!1),s()},m=jk(()=>l.blocks.map(g=>{let{canAdd:f,reason:b}=h(g.partialBlockId);return{...g,disabled:!f,disabledReason:b}}),[l.blocks,h]);return l.isLoading?qa("div",{className:"flex items-center justify-center p-8 text-center text-muted-foreground",children:"Loading partial blocks..."}):l.error||l.blocks.length===0?Xk("div",{className:"flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground",children:[qa("p",{children:l.error||"No partial blocks available"}),qa("button",{onClick:u,className:"rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",children:"Refresh"})]}):qa(Za,{gridCols:o,parentId:e,position:t,groups:l.groups,blocks:m,disableBlockGroupsSidebar:r})};import{jsx as V,jsxs as Lt}from"react/jsx-runtime";var xm=[{name:"basic",icon:V(Wi,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-primary text-primary-foreground"},{name:"typography",icon:V(s0,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-success text-success-foreground"},{name:"media",icon:V(a0,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-warning text-warning-foreground"},{name:"layout",icon:V(Wi,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-info text-info-foreground"},{name:"form",icon:V(o0,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-purple text-purple-foreground"},{name:"advanced",icon:V(n0,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-orange text-orange-foreground"},{name:"other",icon:V(r0,{className:"h-4 w-4",strokeWidth:2.5}),bg:"bg-aqua text-aqua-foreground"}],Za=({groups:e,blocks:t,parentId:o,position:r,gridCols:n="grid-cols-4",disableBlockGroupsSidebar:a})=>{var T;let{t:s}=Cm(),[i]=Ce(),[l,c]=zi(""),d=vm(null),[p]=$i(km),h=(T=e0(i,C=>C._id===o))==null?void 0:T._type,[u,m]=zi("all"),[,g]=zi(null),f=vm(null),b=M("flags.dragAndDrop",!0);Qa(()=>{let C=setTimeout(()=>{var w;(w=d.current)==null||w.focus()},0);return()=>clearTimeout(C)},[p]);let y=nn(C=>{c(C),C&&(m("all"),g(null))},[]);Qa(()=>(f.current=Qk(C=>{m(C)},500),()=>{f.current&&f.current.cancel()}),[]);let k=nn(C=>{g(C),f.current&&f.current(C)},[]),v=nn(()=>{g(null),f.current&&f.current.cancel()},[]),S=nn(C=>{f.current&&f.current.cancel(),m(C),g(null)},[]),E=rn(()=>l?hr(t).filter(C=>{var w,A;return(((w=C.label)==null?void 0:w.toLowerCase())+" "+((A=C.type)==null?void 0:A.toLowerCase())).includes(l.toLowerCase())}):t,[t,l]),x=rn(()=>l?e.filter(C=>Vi(Ja(hr(E),{group:C}),{hidden:!0}).length>0):e.filter(C=>Vi(Ja(hr(t),{group:C}),{hidden:!0}).length>0),[t,E,e,l]),B=rn(()=>t0(x,C=>{let w=xm.findIndex(A=>A.name===C);return w===-1?99:w}),[x]),I=rn(()=>u==="all"?E:Ja(hr(E),{group:u}),[E,u]),N=rn(()=>u==="all"?B:[u],[B,u]);return Lt("div",{className:"mx-auto flex h-full w-full flex-col py-2",children:[V(la,{value:l,setValue:y}),Lt("div",{className:"sticky top-10 flex h-[calc(100%-48px)] overflow-hidden pt-2",children:[!a&&B.length>0&&V("div",{className:"w-1/4 min-w-[120px] border-r border-border",children:V(Mr,{className:"h-full",children:Lt("div",{className:"space-y-1 pr-2",children:[V(D,{variant:u==="all"?"secondary":"ghost",size:"sm",onClick:()=>S("all"),onMouseEnter:()=>k("all"),onMouseLeave:v,className:"w-full justify-start font-medium",children:s("All")},"sidebar-all"),B.map(C=>V(D,{variant:u===C?"secondary":"ghost",size:"sm",onClick:()=>S(C),onMouseEnter:()=>k(C),onMouseLeave:v,className:"w-full justify-start font-medium",children:Jk(s(C.toLowerCase()))},`sidebar-${C}`))]})})}),V("div",{className:`h-full flex-1 overflow-hidden ${!a&&B.length>0?"w-3/4":"w-full"}`,children:V(Mr,{id:"add-blocks-scroll-area",className:"no-scrollbar h-full",children:x.length===0&&l?V("div",{className:"flex flex-col items-center justify-center p-8 text-center text-muted-foreground",children:Lt("p",{children:[s("No blocks found matching"),' "',l,'"']})}):V("div",{className:`${a?"p-0":"p-4"} space-y-6 pt-2`,children:N.map((C,w)=>{let A=xm.find(_=>_.name===C);return Lt("div",{className:"space-y-3",children:[Lt("div",{className:"flex items-center gap-2",children:[V("div",{className:`flex h-6 w-6 items-center justify-center rounded-full ${(A==null?void 0:A.bg)||"bg-primary text-primary-foreground"}`,children:(A==null?void 0:A.icon)||V(Wi,{className:"h-4 w-4"})}),V(z,{className:"text-xs uppercase text-primary-foreground",children:s(C.toLowerCase())})]}),V("div",{className:"grid gap-2 "+n,children:Vi(u==="all"?Ja(hr(I),{group:C}):hr(I),{hidden:!0}).map((_,Z)=>V(Xu,{parentId:o,position:r,block:_,disabled:!b&&(!yt(h,_.type)||!Kn(h,_.type))},_.type+"-"+w+"-"+Z))})]},C)})})})})]})]})},km=qk("__add_block_tab","library"),i0=({className:e,showHeading:t=!0,parentId:o=void 0,position:r=-1,fromSidebar:n=!1})=>{let{t:a}=Cm(),[s,i]=$i(km),[,l]=$i(Ol),c=M("flags.importHtml",!0),{data:d}=Mn(),p=Object.keys(d||{}).length>0,{hasPermission:h}=Ve();Qa(()=>{s==="partials"&&!p&&i("library")},[s,p,i]);let u=nn(()=>{J.publish(U.CLOSE_ADD_BLOCK)},[]),m=lc(),g=c&&h(be["pages:update"]),b=Un().length>0;return Qa(()=>{s==="library"&&!b&&i("core")},[s,b,i]),Lt("div",{className:zt("flex h-full w-full flex-col overflow-hidden",e),children:[t?Lt("div",{className:"mb-2 flex flex-col justify-between rounded-md px-2 py-1",children:[V("h1",{className:"flex flex-col items-baseline text-xl font-semibold text-foreground xl:flex-col",children:a("Add block")}),V("span",{className:"text-xs font-light leading-3 text-muted-foreground",children:a(s==="html"?"Enter or paste TailwindCSS HTML snippet":"Click to add block to page")})]}):null,Lt(co,{onValueChange:y=>{l(""),i(y)},value:s,className:"flex h-full max-h-full flex-col overflow-hidden",children:[Lt(po,{className:`flex items-center ${n?"h-max w-max justify-start":"w-full"}`,children:[b&&V(ke,{value:"library",className:n?"h-5 px-2 text-xs":"",children:a("Library")}),V(ke,{value:"core",className:n?"h-5 px-2 text-xs":"",children:a("Blocks")}),p&&V(ke,{value:"partials",className:n?"h-5 px-2 text-xs":"",children:a("Partials")}),g?V(ke,{value:"html",className:n?"h-5 px-2 text-xs":"",children:a("Import")}):null,bm(m,y=>V(ke,{value:y.id,className:n?"h-5 px-2 text-xs":"",children:ym.createElement(y.tab)},`tab-add-block-${y.id}`))]}),V(tt,{value:"core",className:"h-full max-h-full flex-1 pb-20",children:V("div",{className:"h-full max-h-full overflow-hidden",children:V("div",{className:"h-full w-full",children:V(qu,{gridCols:n?"grid-cols-2":"grid-cols-4",parentId:o,position:r,disableBlockGroupsSidebar:n})})})}),b&&V(tt,{value:"library",className:"h-full max-h-full flex-1 pb-8",children:V(um,{fromSidebar:n,parentId:o,position:r})}),p&&V(tt,{value:"partials",className:"h-full max-h-full flex-1 pb-20",children:V("div",{className:"h-full max-h-full overflow-hidden",children:V("div",{className:"h-full w-full",children:V(hm,{gridCols:n?"grid-cols-2":"grid-cols-4",parentId:o,position:r,disableBlockGroupsSidebar:n})})})}),g?V(tt,{value:"html",className:"h-full max-h-full flex-1 pb-20 ",children:V(Qu,{parentId:o,position:r,fromSidebar:n})}):null,bm(m,y=>V(tt,{value:y.id,children:ym.createElement(y.tabContent,{close:u,parentId:o,position:r})},`panel-add-block-${y.id}`))]})]})},wm=i0;import{jsx as br,jsxs as Tm}from"react/jsx-runtime";var d0=()=>{let[e,t]=Ui(null),[o,r]=Ui(-1),[n,a]=Ui(!1),s=Re(),[,i]=nr(),l=Sm(d=>{var p,h;s?i("add-block"):(t((p=d==null?void 0:d._id)!=null?p:null),r((h=d==null?void 0:d.position)!=null?h:-1),a(!0))},[s,i]),c=Sm(()=>{t(null),r(-1),a(!1)},[]);return Kt(U.OPEN_ADD_BLOCK,l),Kt(U.CLOSE_ADD_BLOCK,c),{parentId:e,position:o,open:n,handleClose:c}},Nm=()=>{let{t:e}=c0(),{parentId:t,position:o,open:r,handleClose:n}=d0();return br(na,{open:r,onOpenChange:n,children:Tm(aa,{className:"max-w-5xl overflow-hidden border-border",children:[Tm(sa,{className:"flex flex-row items-center justify-between",children:[br(ia,{className:"text-foreground",children:e("Add blocks")}),br("button",{type:"button",onClick:n,"aria-label":e("Close dialog"),className:"text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:br(l0,{className:"h-6 w-6"})})]}),br("div",{className:"no-scrollbar h-[500px] max-h-full overflow-hidden",children:br(wm,{parentId:t!=null?t:"",position:o,showHeading:!1})})]})})};var Oo=()=>null;import{MixerHorizontalIcon as yg}from"@radix-ui/react-icons";import{isEmpty as J1,noop as xg}from"lodash-es";import{useCallback as Q1}from"react";import{ErrorBoundary as hl}from"react-error-boundary";import{useTranslation as Cg}from"react-i18next";import{toast as eN}from"sonner";import{ChevronDownIcon as lS,ChevronRightIcon as cS}from"@radix-ui/react-icons";import{cloneDeep as dS,debounce as pS,forEach as uS,get as Eo,includes as mS,isEmpty as hs,keys as fS,set as fs,startCase as gS,startsWith as hS}from"lodash-es";import{useCallback as bS,useMemo as pn,useState as wf}from"react";import{PlusIcon as Ow}from"@radix-ui/react-icons";import{useThrottledCallback as Fw}from"@react-hookz/web";import Vw from"@rjsf/core";import zw from"@rjsf/validator-ajv8";import{get as $w,set as Ww,take as Uw}from"lodash-es";import{memo as Gw,useCallback as Kw,useEffect as tl,useMemo as cs,useRef as gf,useState as ol}from"react";import{get as Gi,includes as p0}from"lodash-es";import{useMemo as u0}from"react";import{useTranslation as m0}from"react-i18next";import{jsx as Em,jsxs as Ki}from"react/jsx-runtime";var Bm=({id:e,placeholder:t})=>{let{t:o}=m0(),[,r]=ra(),{selectedLang:n}=te(),a=$(),s=e.replace("root.",""),i=Be(a==null?void 0:a._type),c=p0(Gi(i,"i18nProps",[]),s)&&n?`${s}-${n}`:s,d=Gi(a,c,""),p=u0(()=>Gi(mo,n,n),[n]),h=()=>{let u=a==null?void 0:a._id;r({blockId:u,blockProp:c,placeholder:t,initialCode:d})};return Ki("div",{className:"mt-2 flex flex-col gap-y-1",children:[Ki(z,{htmlFor:e,children:["HTML Code",p&&Ki("small",{className:"text-[9px] text-zinc-400",children:["\xA0",p]})]}),Em(ar,{value:Zn(d),onClick:h,readOnly:!0,className:"w-64 break-before-all",placeholder:t||"Eg: <script>console.log('Hello, world!');</script>"}),Em(D,{onClick:h,size:"sm",variant:"outline",className:"w-fit",children:o("Open code editor")})]})};import{find as f0,get as Am}from"lodash-es";import{jsx as ji,jsxs as g0}from"react/jsx-runtime";var Im=({id:e,value:t,onChange:o,onBlur:r})=>{let n=M("collections",[]),a=$(),s=Am(a,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1").replace("#",""),i=f0(n,{id:s}),c=Am(i,e==="root.filter"?"filters":"sorts",[]);return ji("div",{children:g0("select",{className:"flex h-8 w-full rounded-md border border-input bg-transparent px-3 py-1 text-xs shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",value:t,onChange:d=>o(d.target.value),onBlur:d=>r(e,d.target.value),children:[ji("option",{value:"",children:"Select"}),c.map(d=>ji("option",{value:d.id,children:d.name},d.id))]})})};import{lazy as h0,Suspense as b0,useState as y0}from"react";import{useTranslation as v0}from"react-i18next";import{jsx as Qt,jsxs as Dm}from"react/jsx-runtime";var x0=h0(()=>import("./IconPicker-I7VNLYZ4.js").then(e=>({default:e.IconPicker}))),C0=e=>{try{let t=e.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi,"<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi,"<svg$1$2>");return t=t.replace(/>\s+</g,"><"),t=t.replace(/\n/g,"").replace(/\s{2,}/g," "),t=t.replace(/\s+=/g,"=").replace(/=\s+/g,"="),t=t.replace(/<!--[\s\S]*?-->/g,""),t.trim()}catch(t){return e}},_m=({value:e,onChange:t,id:o})=>{let{t:r}=v0(),[n,a]=y0(e||""),s=i=>{a(i);let l=C0(i);t(l)};return Dm("div",{className:"mt-1 flex flex-col gap-2",id:"icon-picker-field",children:[Dm("div",{className:"flex items-start gap-x-2",children:[Qt("div",{className:"bg-surface/50 flex h-16 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input p-2 text-muted-foreground",children:n?Qt("div",{className:"h-8 w-8 [&>svg]:h-full [&>svg]:w-full",dangerouslySetInnerHTML:{__html:n}}):Qt("span",{className:"text-[10px] text-muted-foreground",children:"SVG"})}),Qt("textarea",{id:o,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",value:n,onChange:i=>s(i.target.value),placeholder:r("Paste SVG code here"),rows:3,className:"no-scrollbar flex-1 resize-none rounded-md border border-input bg-transparent px-3 py-2 text-xs text-foreground shadow-sm transition-colors placeholder:text-muted-foreground/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"})]}),Qt("div",{className:"flex items-center justify-between",children:Qt("div",{className:"flex items-center gap-2",children:Qt(b0,{fallback:Qt("div",{className:"text-xs text-muted-foreground",children:"Loading..."}),children:Qt(x0,{onSelectIcon:s})})})})]})};import{Cross1Icon as T0,Pencil2Icon as N0}from"@radix-ui/react-icons";import{first as E0,get as Zi,has as B0,isArray as A0,isEmpty as Yi,set as xr,startsWith as I0}from"lodash-es";import{useCallback as D0,useMemo as _0}from"react";import{useTranslation as P0}from"react-i18next";import{useState as S0}from"react";import{ExclamationTriangleIcon as k0}from"@radix-ui/react-icons";import{useState as es}from"react";import{useTranslation as w0}from"react-i18next";import{jsx as yr,jsxs as ts}from"react/jsx-runtime";var Pm=({close:e,onSelect:t,mode:o="image"})=>{let[r,n]=es(""),[a,s]=es(!1),[i,l]=es(!1),[c,d]=es(null),p=async u=>{if(!u.trim()){l(!1),d("Please enter a URL");return}try{s(!0),d(null),l(!0),d(null)}catch(m){l(!1),d("Error validating URL")}finally{s(!1)}},{t:h}=w0();return ts("div",{className:"flex w-96 flex-col gap-4 p-4",children:[yr("h2",{className:"text-xl font-semibold text-foreground",children:h(`${o.charAt(0).toUpperCase()+o.slice(1)} Manager`)}),c&&ts(Wc,{variant:"destructive",children:[yr(k0,{className:"h-4 w-4"}),yr(Uc,{children:c})]}),ts("div",{className:"flex flex-col gap-4",children:[yr(oe,{placeholder:h(`Enter ${o} URL`),value:r,onChange:u=>n(u.target.value),onKeyUp:()=>p(r)}),ts("div",{className:"flex justify-end gap-2",children:[yr(D,{variant:"outline",onClick:e,children:h("Cancel")}),yr(D,{onClick:()=>t({id:"dam-id",url:r,width:600,height:400,description:{en:"This is image description"}}),disabled:!i||a,children:h("Insert")})]})]})]})};import{jsx as os,jsxs as Lm}from"react/jsx-runtime";var Rm=({assetId:e,children:t,onSelect:o,mode:r="image",multiple:n=!1,open:a,onOpenChange:s})=>{let[i,l]=S0(!1),c=a!==void 0,d=c?a:i,p=u=>{c||l(u),s==null||s(u)},h=(...u)=>{o.call(void 0,...u),p(!1)};return Lm(qo,{open:d,onOpenChange:u=>p(u),children:[t?os(Nl,{asChild:!0,children:t}):null,Lm(Jo,{className:"flex max-h-[90vh] max-w-7xl border-border md:w-fit",children:[os(Qo,{className:"sr-only",children:"Media Manager"}),os("div",{className:"h-full w-full",children:os(lo,{slotId:io.MEDIA_MANAGER,context:{close:()=>p(!1),onSelect:h,mode:r,assetId:e,multiple:n},multiple:!1,defaultComponent:Pm})})]})]})};Rm.displayName="MediaManagerModal";var vr=Rm;function Mm(e,t,o){if(!e)return e;let{baseClasses:r,classes:n}=sr(e),a=l=>l.split(" ").filter(c=>c&&!(t&&c==="w-full")&&!(o&&c==="h-full")).join(" "),s=a(r),i=a(n);return`${An}${s},${i}`}import{Fragment as R0,jsx as Ue,jsxs as ns}from"react/jsx-runtime";var rs="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==",L0=e=>{var n;if(!e||I0(e,"data"))return"";let t=((n=e.split("/").pop())==null?void 0:n.split("?")[0])||"";return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico",".avif"].some(a=>t.toLowerCase().endsWith(a))?t:""},Hm=({value:e,onChange:t,id:o,onBlur:r,uiSchema:n})=>{let{t:a}=P0(),{selectedLang:s,fallbackLang:i}=te(),l=$(),{updateBlocks:c}=ye(),d=et(),p=!0,h=(n==null?void 0:n["ui:allowEmpty"])===!0,u=o.split(".").pop()||"",m=s?`_${u}Id-${s}`:`_${u}Id`,g=Yi(s)&&(l==null?void 0:l._type)==="Image"&&B0(l,"assetId"),f=Zi(l,m,g?l==null?void 0:l.assetId:""),b=_0(()=>{if(!e||!l||!/\{\{.*?\}\}/.test(e))return e;let x={...l,[u]:e},B=oa(x,d,{index:-1,key:""});return Zi(B,u,e)},[e,l,d,u]),y=!!f||b!==rs&&b!=="",k=E=>{let x=A0(E)?E0(E):E;if(x){t(x==null?void 0:x.url);let B=x==null?void 0:x.width,I=x==null?void 0:x.height,N=m.includes("mobile");if(l!=null&&l._id){let T={};if(typeof x.description=="string")try{let w=JSON.parse(x.description);typeof w=="object"&&w!==null&&!Array.isArray(w)?T=Object.fromEntries(Object.entries(w).filter(([,A])=>typeof A=="string").map(([A,_])=>[A,_])):T={[i]:x.description}}catch(w){T={[i]:x.description}}else T=x.description||{};let C={...B&&{[N?"mobileWidth":"width"]:B},...I&&{[N?"mobileHeight":"height"]:I}};if(Object.keys(T).forEach(w=>{let A=T[w];A&&(w===i?xr(C,"alt",A):xr(C,`alt-${w}`,A))}),xr(C,m,x.id),(B||I)&&(l!=null&&l._type)&&(l!=null&&l.styles)){let w=tr(l._type),A=Zi(w,"styles","");l.styles===A&&(C.styles=Mm(l.styles,B,I))}if(Yi(C))return;c([l._id],C)}}},v=D0(()=>{if(t(h?"":rs),l!=null&&l._id){let x={},B=m.includes("mobile");xr(x,m,""),xr(x,B?"mobileWidth":"width",""),xr(x,B?"mobileHeight":"height",""),c([l._id],x)}},[l,t,c,m,h]),S=L0(b);return ns("div",{className:"mt-1.5 flex items-start gap-x-3",children:[b?ns("div",{className:"group relative",children:[Ue("div",{className:"h-[72px] w-[72px] overflow-hidden",children:Ue(ea,{src:b,className:"h-[72px] w-[72px] overflow-hidden rounded-md border border-border object-cover transition duration-200 "+(f&&f!==""?"cursor-pointer group-hover:scale-105 group-hover:opacity-50":""),alt:""})}),y&&Ue(D,{type:"button",onClick:v,size:"icon-xs",variant:"destructive",className:"absolute -right-2 -top-2 z-20 h-5 w-5 rounded-full p-1",children:Ue(T0,{className:"!h-3 !w-3"})}),f&&f!==""&&Ue(vr,{onSelect:k,assetId:f,children:Ue(D,{size:"icon-xs",variant:"ghost",type:"button",className:"absolute inset-0 left-1/2 top-1/2 z-10 flex -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center opacity-0 transition duration-200 group-hover:opacity-100",children:Ue(N0,{className:"h-4 w-4 text-foreground"})})})]}):Ue(vr,{onSelect:k,mode:"image",assetId:f,children:Ue("div",{className:"h-[72px] w-[72px] cursor-pointer rounded-md border border-border bg-[radial-gradient(hsl(var(--muted-foreground)),transparent_1px)] duration-300 [background-size:10px_10px]"})}),ns("div",{className:"flex w-3/5 flex-col",children:[p&&ns(R0,{children:[Ue("p",{className:"sr-only max-w-[250px] truncate pr-2 text-xs text-muted-foreground",children:S}),Ue(vr,{onSelect:k,assetId:"",children:Ue(D,{variant:"outline",size:"sm",children:!Yi(b)&&b!==rs?a("Replace image"):a("Choose image")})}),Ue("div",{className:"text-center text-[10px] italic text-muted-foreground",children:"OR"})]}),Ue(oe,{id:o,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",type:"url",className:"!h-7 rounded-sm px-2 py-px text-xs",placeholder:a("Enter image URL"),value:e===rs?"":e,onBlur:({target:{value:E}})=>r(o,E),onChange:E=>t(E.target.value)})]})]})};import{ChevronDownIcon as K0,ChevronRightIcon as j0,InfoCircledIcon as Um,ListBulletIcon as Z0}from"@radix-ui/react-icons";import{get as Gm,isEmpty as is}from"lodash-es";import{useMemo as Xi,useState as Y0}from"react";import{useMutation as H0,useQueryClient as O0}from"@tanstack/react-query";import{Wand2Icon as F0}from"lucide-react";import{useTranslation as V0}from"react-i18next";import{toast as Fm}from"sonner";import{startsWith as M0}from"lodash-es";var Om=e=>!!(!e||M0(e,"data:image/svg+xml;base64")||e.includes("placehold.co"));import{jsx as as}from"react/jsx-runtime";var Vm=({sourceProp:e,targetProp:t})=>{let{t:o}=V0(),r=Ut(),n=Wt(),a=ac("AI_GENERATE_IMAGE_DESCRIPTION"),s=$(),{updateBlocks:i}=ye(),{languages:l,fallbackLang:c}=te(),d=O0(),[,p]=nr(),h=s?s[e]:"",u=!h||Om(h),{mutate:m,isPending:g}=H0({mutationFn:async({blockId:f,url:b})=>{let y=[c,...l||[]];return{...await r(n,{action:Ae.AI_GENERATE_IMAGE_DESCRIPTION,data:{url:b,languages:y,model:a}}),blockId:f}},onSuccess:f=>{if(!f.translations)return;let b={};Object.entries(f.translations).forEach(([y,k])=>{y===c?b[t]=k:b[`${t}-${y}`]=k}),i([f.blockId],b),d.invalidateQueries({queryKey:[Sc]})},onError:f=>{f!=null&&f.canBuyCredits?Fm.error(as("p",{className:"font-medium",children:f.message||o("Failed to generate alt text")}),{action:{label:o("Buy Credits"),onClick:()=>p(Tc)},duration:8e3}):Fm.error((f==null?void 0:f.message)||o("Failed to generate alt text"))}});return s?as(D,{disabled:g||u,type:"button",variant:"ghost",size:"icon-xs",className:"h-5 w-5","aria-label":o(u?"Cannot generate for placeholder image":"Generate alt text with AI"),onClick:()=>m({blockId:s._id,url:h}),title:o(u?"Cannot generate for placeholder image":"Generate with AI"),children:g?as(En,{className:"text-orange !h-3 !w-3"}):as(F0,{className:`text-orange !h-3 !w-3 ${u?"opacity-30":""}`})}):null};import{first as z0,get as $m,isEmpty as $0,startsWith as W0}from"lodash-es";import{useCallback as U0,useMemo as Wm}from"react";import{jsx as G0}from"react/jsx-runtime";var ss=({schema:e,onChange:t,id:o})=>{let r=et(),n=M("flags.dataBinding",!0),a=Yl(),s=Wm(()=>{if(a.length===1)return"";let c=a.find(h=>h._type==="Repeater"),p=$m(c,"repeaterItems","").replace(/\{\{(.*)\}\}/g,"$1");return`${"@"}${W0(p,"#")?`${p}/${c==null?void 0:c._id}`:p}`},[a]),i=Wm(()=>z0($m(r,s.replace("@",""),[])),[s,r]),l=U0((c,d)=>{if(c=$0(s)?c:c.replace(`${s}`,"$index"),d==="array"||d==="object"){t(`{{${c}}}`,{},o);return}let p=g=>/[.,!?;:]/.test(g),h=(g,f,b)=>{let y="",k="",v=f>0?g[f-1]:"",S=f<g.length?g[f]:"";return f>0&&(v==="."||!p(v)&&v!==" ")&&(y=" "),f<g.length&&!p(S)&&S!==" "&&(k=" "),{text:y+b+k,prefixLength:y.length,suffixLength:k.length}},u=document.getElementById(o);if(!u)return;let m=document.getElementById(`chai-rte-${o}`)||document.getElementById(`chai-rte-modal-${o}`);if(m&&(m.querySelector(".ProseMirror")||m.__chaiRTE)){let g=m.__chaiRTE;if(g){let f=`{{${c}}}`;g.commands.focus();let{from:b,to:y}=g.state.selection;if(b!==y)g.chain().deleteSelection().insertContent(f).run();else{let{state:v}=g,S=v.selection.from,E=v.doc.textBetween(Math.max(0,S-1),S),x=v.doc.textBetween(S,Math.min(S+1,v.doc.content.size)),B="";S>0&&E!==" "&&!p(E)&&(B=" ");let I="";x&&x!==" "&&!p(x)&&(I=" "),g.chain().insertContent(B+f+I).run()}setTimeout(()=>t(g.getHTML(),{},o),100);return}}else{let g=u,f=g.selectionStart||0,b=g.value||"",y=g.selectionEnd||f;if(y>f){let x=`{{${c}}}`,{text:B}=h(b,f,x),I=b.slice(0,f)+B+b.slice(y);t(I,{},o);return}let v=`{{${c}}}`,{text:S}=h(b,f,v),E=b.slice(0,f)+S+b.slice(f);t(E,{},o)}},[o,t,s]);return n?G0(ca,{data:{...i&&{[s]:i},...r},onSelect:l,dataType:e.binding==="array"?"array":"value"}):null};import{Fragment as q0,jsx as ce,jsxs as mt}from"react/jsx-runtime";var X0=e=>{let{id:t,classNames:o,label:r,children:n,errors:a,help:s,hidden:i,required:l,schema:c,formData:d,onChange:p}=e,{selectedLang:h,fallbackLang:u,languages:m}=te(),g=Xi(()=>is(m)?"":is(h)?u:h,[m,h,u]),f=Xi(()=>Gm(mo,g,g),[g]),b=et(),y=$(),k=Ln(),v=Xi(()=>y!=null&&y._type?Gm(k,[y._type,"i18nProps"],[]):[],[k,y]),[S,E]=Y0(null);if(i)return null;if(c.type==="boolean")return ce("div",{className:o,children:n});let B=v==null?void 0:v.includes(t.replace("root.",""));if(c.type==="array"){let T=S===t;return mt("div",{className:`${o} relative`,children:[c.title&&ce("div",{className:"flex items-center justify-between gap-1",children:mt("label",{htmlFor:t,onClick:()=>E(T?null:t),className:"flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",children:[T?ce(K0,{className:"h-3 w-3"}):ce(j0,{className:"h-3 w-3"}),ce(Z0,{className:"h-3 w-3"}),ce("span",{className:"text-xs font-light leading-tight",children:r}),"\xA0",ce(Hr,{variant:"secondary",className:"h-4 px-1 text-[10px]",children:ce("span",{className:"text-[9px] font-medium text-slate-600",children:d==null?void 0:d.length})}),c.description&&ce(vt,{content:c.description,side:"right",children:ce(Um,{className:"h-3 w-3 text-muted-foreground/70",onClick:C=>C.stopPropagation(),onMouseDown:C=>C.stopPropagation()})})]})}),(d==null?void 0:d.length)===0?ce("div",{className:"h-0 overflow-hidden",children:n}):mt("div",{className:`${T?"pt-0.5":"h-0 overflow-hidden"}`,children:[n,a,s]})]})}let I=t.replace("root.",""),N=v.includes(I)&&!is(h)&&is(d);return mt("div",{className:o,children:[c.title&&mt("div",{className:"flex items-center justify-between",children:[mt("div",{className:"flex items-center gap-2",children:[mt(z,{htmlFor:t,className:c.type==="object"?"pb-2":"",children:[r," ",B&&mt("small",{className:"text-[9px] text-zinc-400",children:[" ",f]}),l&&c.type!=="object"?" *":null]}),c.description&&ce(vt,{content:c.description,side:"right",children:ce(Um,{className:"h-3 w-3 text-muted-foreground/70"})})]}),mt("div",{className:"flex items-center gap-1",children:[I==="alt"&&(y==null?void 0:y._type)==="Image"&&ce(Vm,{sourceProp:"image",targetProp:"alt"}),!c.enum&&!c.oneOf&&b&&mt("span",{className:"flex items-center space-x-1",children:[N?ce(vt,{content:mt(q0,{children:["No translation provided. ",ce("br",{}),"Using default language value."]}),side:"left",children:mt("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-triangle-alert-icon lucide-triangle-alert h-3 w-3 text-orange-400",children:[ce("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),ce("path",{d:"M12 9v4"}),ce("path",{d:"M12 17h.01"})]})}):null,ce(ss,{schema:c,onChange:T=>{p(T,d,t)},id:t,formData:d})]})]})]}),n,a,s]})},Km=X0;import{Cross1Icon as J0}from"@radix-ui/react-icons";import{useDebouncedCallback as Q0}from"@react-hookz/web";import{get as qi,isEmpty as Rt,map as Ym,split as ew,startsWith as tw}from"lodash-es";import{useEffect as jm,useMemo as Zm,useRef as ow,useState as an}from"react";import{useTranslation as Xm}from"react-i18next";import{jsx as Te,jsxs as St}from"react/jsx-runtime";var rw=({href:e,onChange:t})=>{let{t:o}=Xm(),r=M("searchPageTypeItems",(v,S)=>[]),[n,a]=an(!1),[s,i]=an(!1),[l,c]=an(""),[d,p]=an([]),[h,u]=an(-1),m=ow(null);jm(()=>{if(c(""),p([]),u(-1),i(!1),!e||n||!tw(e,"pageType:"))return;let v=ew(e,":");(async()=>{let S=await r("",[qi(v,2,"page")]);S&&Array.isArray(S)&&c(qi(S,[0,"name"],""))})()},[e]);let g=Q0(async v=>{if(Rt(v))p([]);else{let S=await r("",v);p(S)}a(!1),u(-1)},[],300),f=v=>{var E;let S=["pageType",v.pageType||"page",(E=v.primaryPage)!=null?E:v.id];S[1]&&(t(S.join(":")),c(v.name),i(!1),p([]),u(-1))},b=v=>{switch(v.key){case"ArrowDown":v.preventDefault(),u(S=>S<d.length-1?S+1:S);break;case"ArrowUp":v.preventDefault(),u(S=>S>0?S-1:S);break;case"Enter":if(v.preventDefault(),d.length===0)return;h>=0&&f(d[h]);break;case"Escape":v.preventDefault(),y();break}};jm(()=>{if(h>=0&&m.current){let v=m.current.children[h];v==null||v.scrollIntoView({block:"nearest"})}},[h]);let y=()=>{c(""),p([]),u(-1),i(!1),t("")},k=v=>{c(v),i(!Rt(v)),a(!0),g(v)};return St("div",{children:[St("div",{className:"group relative flex items-center",children:[Te(oe,{type:"text",value:l,onChange:v=>k(v.target.value),onKeyDown:b,placeholder:o("Search pages"),className:"pr-8"}),Te("div",{className:"absolute bottom-2 right-2 top-2 flex items-center gap-1.5",children:l&&Te("button",{onClick:y,className:"text-muted-foreground hover:text-foreground",title:o("Clear search"),children:Te(J0,{className:"h-4 w-4"})})})]}),(n||!Rt(d)||s&&Rt(d))&&Te("div",{className:"bg-surface absolute z-40 mt-0.5 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border shadow-lg",children:n?St("div",{className:"space-y-1 p-2",children:[Te("div",{className:"h-6 w-full animate-pulse rounded bg-muted/10"}),Te("div",{className:"h-6 w-full animate-pulse rounded bg-muted/10"})]}):s&&Rt(d)?St("div",{className:"flex items-center justify-center p-4 text-xs text-muted-foreground",children:[o("No results found for"),' "',l,'"']}):Te("ul",{ref:m,children:Ym(d==null?void 0:d.slice(0,20),(v,S)=>St("li",{onClick:()=>f(v),className:`cursor-pointer px-2 py-1 text-xs ${e!=null&&e.includes(v.id)?"bg-primary/20":S===h?"bg-accent":"hover:bg-accent"}`,children:[v.name," ",v.slug&&St("small",{className:"font-light text-muted-foreground",children:["( ",v.slug," )"]}),v.lang&&Te("small",{className:"ml-1 rounded bg-muted px-1 py-0.5 text-[10px] font-medium text-muted-foreground",children:v.lang})]},v.id))})})]})},qm=({schema:e,formData:t,onChange:o,name:r})=>{var g;let{t:n}=Xm(),{type:a="pageType",href:s="",target:i="self"}=t!=null?t:{},l=M("pageTypes",[]),{selectedLang:c,fallbackLang:d,languages:p}=te(),h=Zm(()=>Rt(p)?"":Rt(c)?d:c,[p,c,d]),u=Zm(()=>qi(mo,h,h),[h]),m=a==="pageType"&&Rt(l)?"url":a;return St("div",{children:[St("div",{className:"mb-1.5 flex items-center justify-between gap-x-2",children:[St(z,{children:[(g=e==null?void 0:e.title)!=null?g:"Link",Te("span",{className:"pl-1 text-[9px] text-muted-foreground",children:u})]}),Te(ss,{schema:e,onChange:f=>{o({...t,href:f,...m==="pageType"?{type:"url"}:{}})},id:`root.${r}.href`,formData:t})]}),St("div",{className:"flex flex-col gap-y-2.5",children:[Te("select",{className:"flex h-8 w-full rounded-md border border-input bg-transparent px-3 py-1 text-xs shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",name:"type",value:a,onChange:f=>o({...t,type:f.target.value}),children:Ym([...Rt(l)?[]:[{const:"pageType",title:n("Goto Page")}],{const:"url",title:n("Open URL")},{const:"email",title:n("Compose Email")},{const:"telephone",title:n("Call Phone")},{const:"scroll",title:n("Scroll to element")}],f=>Te("option",{value:f.const,children:f.title},f.const))}),m==="pageType"&&!Rt(l)?Te(rw,{href:s,onChange:f=>o({...t,href:f})}):null,Te(oe,{id:`root.${r}.href`,autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",name:"href",type:"text",className:m==="pageType"?"!hidden":"",value:s,onChange:f=>o({...t,href:f.target.value}),placeholder:n(a==="url"?"Enter URL":a==="scroll"?"#ElementID":"Enter details")}),m==="url"&&St("div",{className:"flex items-center gap-x-2 text-muted-foreground",children:[Te(Gt,{id:`root.${r}.target`,checked:i==="_blank",onCheckedChange:f=>o({...t,target:f?"_blank":"_self"})}),Te(z,{htmlFor:`root.${r}.target`,children:n("Open in new tab")})]})]})]})};import{ArrowDownIcon as nw,ArrowUpIcon as aw,Cross1Icon as sw,Pencil1Icon as iw}from"@radix-ui/react-icons";import{get as lw,truncate as cw}from"lodash-es";import{Check as dw,ChevronDown as pw,ChevronRight as uw,Images as mw}from"lucide-react";import{useCallback as Ji,useMemo as fw,useState as Jm}from"react";import{useTranslation as gw}from"react-i18next";import{Fragment as hw,jsx as se,jsxs as ft}from"react/jsx-runtime";var Qm=({formData:e,onChange:t})=>{let{t:o}=gw(),{selectedLang:r,fallbackLang:n}=te(),[a,s]=Jm(null),[i,l]=Jm(!0),c=r||n,d=fw(()=>Array.isArray(e)?e:[],[e]),p=f=>{let b=Array.isArray(f)?f:[f],y=v=>typeof v=="number"&&Number.isFinite(v)&&v>0,k=b.map(v=>{let S=y(v.height),E=y(v.width);return{id:v.id,url:v.url,height:S?v.height:E?v.width:100,width:E?v.width:S?v.height:100,description:typeof v.description=="string"?{[n]:v.description}:v.description||{}}});t([...d,...k])},h=Ji(f=>{let b=[...d];b.splice(f,1),t(b)},[d,t]),u=Ji(f=>{if(f===0)return;let b=[...d],y=b[f];b[f]=b[f-1],b[f-1]=y,t(b)},[d,t]),m=Ji(f=>{if(f===d.length-1)return;let b=[...d],y=b[f];b[f]=b[f+1],b[f+1]=y,t(b)},[d,t]),g=f=>f!=null&&f.description?typeof f.description=="string"?f.description:lw(f.description,r||n,"")||"":"";return ft("div",{className:"flex flex-col gap-y-2",children:[d.length>0&&ft("div",{className:"rounded border",children:[ft("div",{role:"button",onClick:()=>l(!i),className:"flex min-h-7 cursor-pointer items-center justify-between rounded-t p-1 hover:bg-accent/80",children:[ft("div",{className:"flex items-center gap-x-1",children:[i?se(pw,{className:"h-4 w-4"}):se(uw,{className:"h-4 w-4"}),se("h3",{className:"text-xs font-medium",children:o("Images")})]}),ft("span",{className:"text-xs text-muted-foreground",children:[d.length," ",o("selected")]})]}),i&&se("div",{className:"flex flex-col gap-y-1 p-1",children:d.map((f,b)=>{var y;return ft("div",{className:"bg-surface group relative flex items-center gap-x-2 rounded-md border p-1.5",children:[se("div",{className:"h-12 w-12 rounded bg-background/10",children:se("img",{src:f.url,alt:g(f),width:48,height:48,className:"h-12 min-w-12 max-w-12 rounded object-cover"})}),ft("div",{className:"flex w-full flex-col justify-start py-0",children:[ft("div",{className:"flex items-start justify-start text-[12px] text-muted-foreground",children:[ft(z,{children:[o("Alt text")," ",se("span",{className:"text-[9px] text-muted-foreground/70",children:mo[c]||c})]}),se(D,{variant:"ghost",size:"icon-xs",className:"ml-1 h-4 w-4",onClick:()=>s(b),children:se(iw,{className:"!h-3 !w-3"})})]}),a===b?se("input",{type:"text",autoFocus:!0,className:"!h-6 !w-[104%] !rounded-sm !px-2 !py-0",placeholder:o("Enter alt text"),defaultValue:g(f),onChange:k=>{let v=k.target.value,S=[...d],E=S[b].description;typeof E=="string"?S[b].description={[c]:v}:S[b].description={...E||{},[c]:v},t(S)},onBlur:()=>s(null),onKeyDown:k=>{k.key==="Enter"&&k.currentTarget.blur()}}):se("span",{className:"flex-1 truncate text-xs text-foreground",children:cw(g(f),{length:30})||se("span",{className:"italic text-muted-foreground",children:o("No description")})})]}),se("div",{className:"flex items-center gap-x-1",children:a!==b?ft(hw,{children:[ft("div",{className:"absolute right-0 top-0 flex flex-col items-center justify-center rounded border-b border-l",children:[se(D,{type:"button",onClick:()=>u(b),disabled:b===0,size:"icon-xs",variant:"ghost",className:"flex h-5 w-5 items-center justify-center","aria-label":o("Move image up"),children:se(aw,{className:"h-3 w-3"})}),se(D,{type:"button",size:"icon-xs",variant:"ghost",onClick:()=>m(b),disabled:b===d.length-1,className:"flex h-5 w-5 items-center justify-center","aria-label":o("Move image down"),children:se(nw,{className:"h-3 w-3"})})]}),se(D,{type:"button",size:"icon-xs",variant:"ghost",onClick:()=>h(b),className:"absolute bottom-0 right-0 hidden h-5 w-5 items-center justify-center text-destructive hover:bg-destructive/10 group-hover:flex","aria-label":o("Remove image"),children:se(sw,{className:"h-3 w-3"})})]}):se(D,{type:"button",size:"icon-xs",onClick:()=>h(b),className:"absolute right-1 top-1 hidden rounded-full bg-primary p-1 text-primary-foreground hover:bg-primary/90 group-hover:block","aria-label":o("Remove image"),children:se(dw,{className:"h-3 w-3"})})})]},(y=f.id)!=null?y:b)})})]}),se(vr,{multiple:!0,onSelect:p,mode:"image",children:ft("button",{type:"button",className:"flex w-full items-center justify-center gap-x-2 rounded-md border border-dashed border-border py-1 text-xs text-muted-foreground hover:bg-accent",children:[se(mw,{className:"!h-3.5 !w-3.5"}),o("Choose images")]})})]})};import{Cross1Icon as bw,FileIcon as yw,IdCardIcon as vw}from"@radix-ui/react-icons";import{jsx as Mt,jsxs as sn}from"react/jsx-runtime";var ef=({value:e,onChange:t})=>{var a;if(!e)return sn("div",{className:"mt-1 flex h-8 items-center gap-2 rounded-md border border-input bg-muted/50 px-2 py-1 text-xs text-muted-foreground",children:[Mt(yw,{className:"h-3.5 w-3.5"})," Choose a collection"]});let o=`{{${"#"}`,r=e==null?void 0:e.startsWith(o),n=e;return r&&(n=(a=e==null?void 0:e.replace(o,""))==null?void 0:a.replace("}}","")),Mt("div",{className:"mt-1 flex flex-col gap-1",children:sn("div",{className:"flex items-center justify-between gap-2 rounded-md border border-blue-200 bg-blue-50 px-2 py-1 text-xs text-blue-700",children:[sn("span",{className:"flex max-w-[200px] items-center gap-2",children:[" ",r?Mt(vw,{className:"h-3 min-h-3 w-3 min-w-3"}):null,sn(me,{delayDuration:500,children:[Mt(fe,{asChild:!0,children:Mt("span",{className:"cursor-default truncate",children:n})}),Mt(ge,{side:"left",hidden:n.length<50,children:n})]})]}),sn(me,{children:[Mt(fe,{asChild:!0,children:Mt(D,{variant:"ghost",size:"icon",className:"h-5 w-5 rounded-full bg-gray-200 text-gray-900 hover:bg-gray-300",onClick:()=>t(""),children:Mt(bw,{className:"h-4 w-4"})})}),Mt(ge,{side:"left",children:"Remove binding"})]})]})})};import{PlusIcon as kw}from"@radix-ui/react-icons";import{atom as xw,useAtomValue as Cw}from"jotai";import{find as tf}from"lodash-es";var of=xw(e=>{var s;let t=e(he),o=e(On),r=o.length===1?o[0]:null;if(!r)return null;let n=tf(t,{_id:r});if(!n)return null;let a=n._parent;for(;a;){let i=tf(t,{_id:a});if(!i)return null;if((s=Be(i._type))!=null&&s.wrapper)return i;a=i._parent}return null});of.debugLabel="wrapperBlockAtom";var Cr=()=>Cw(of);import{jsx as rf,jsxs as ww}from"react/jsx-runtime";var nf=()=>{let e=$(),t=Cr(),{addCoreBlock:o}=Le();if(!e&&!t)return null;let r=(e==null?void 0:e._type)==="Row"?e:t;return rf("div",{className:"pt-1",children:ww(D,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>o({type:"Column",styles:"#styles:,"},r==null?void 0:r._id),children:[rf(kw,{className:"mr-1 h-3 w-3"})," Add Column"]})})};import{EditorContent as Sw}from"@tiptap/react";import Tw,{Suspense as Nw,useEffect as sf,useRef as Ew,useState as lf}from"react";import{Fragment as Iw,jsx as To,jsxs as af}from"react/jsx-runtime";var Bw=Tw.lazy(()=>import("./rte-widget-modal-7RXFEYHK.js")),Aw=({blockId:e,id:t,placeholder:o,value:r,onChange:n,onBlur:a})=>{let s=Ew(null),[i,l]=lf(!1),c=Fa({blockId:e,value:r,placeholder:o,onBlur:({editor:h})=>{let u=h==null?void 0:h.getHTML();a(t,u)},onUpdate:({editor:h})=>{let u=h==null?void 0:h.getHTML();n(u)}});sf(()=>{s.current&&c&&(s.current.__chaiRTE=c)},[e,c]);let d=()=>{l(!1)},p=af("div",{id:`chai-rte-${t}`,ref:s,className:"mt-1 rounded-md border border-input",children:[To(Oa,{editor:c,onExpand:()=>l(!0)}),To(Sw,{editor:c,id:t,placeholder:o,className:`-mt-1 overflow-auto placeholder:font-light ${i?"max-h-[500px] min-h-[400px] rounded-b-md bg-background text-foreground":"max-h-[200px] min-h-[100px] rounded-b-md bg-background text-foreground"}`},t)]});return af(Iw,{children:[i&&To(Nw,{fallback:To("div",{children:"Loading..."}),children:To(Bw,{isOpen:i,onClose:d,editor:c,rteElement:p})}),i?To("div",{children:"Open in modal"}):To("div",{className:"relative",children:p})]})},cf=e=>{let{editingBlockId:t}=Me(),[o,r]=lf(null),n=$(),a=n==null?void 0:n._id;return sf(()=>{r(a)},[a]),o&&o!==t?To(Aw,{...e,blockId:o},o):null};import{ChevronLeftIcon as Dw,ChevronRightIcon as _w,PlusCircledIcon as Pw}from"@radix-ui/react-icons";import{filter as Lw,find as df,findIndex as Qi,get as ls}from"lodash-es";import{useEffect as pf}from"react";import{jsx as Oe,jsxs as Tt}from"react/jsx-runtime";var uf=({formData:e,onChange:t})=>{let[o]=Ce(),r=$(),n=Cr(),{addCoreBlock:a}=Le(),[,s]=W(),i=(r==null?void 0:r._type)==="Slider"?r:n,l=df(o,{_parent:i==null?void 0:i._id,_type:"Slides"}),c=Lw(o,{_parent:l==null?void 0:l._id,_type:"Slide"}),d=(e==null?void 0:e.currentSlide)||ls(c,"0._id");if(pf(()=>{(r==null?void 0:r._type)==="Slide"&&(e==null?void 0:e.currentSlide)!==(r==null?void 0:r._id)&&t({...e,currentSlide:r==null?void 0:r._id})},[e,t,r]),pf(()=>{c!=null&&c.length&&!df(c,{_id:e==null?void 0:e.currentSlide})&&t({...e,currentSlide:ls(c,"0._id")})},[e,c,t]),!r&&!n||!l)return null;let p=()=>{let m=Qi(c,{_id:d});if(m>-1){let g=(m+1)%c.length,f=ls(c,[g,"_id"]);if(!f)return;t({...e,currentSlide:f}),s([f])}},h=()=>{let m=Qi(c,{_id:d});if(m>-1){let g=(m-1+c.length)%c.length,f=ls(c,[g,"_id"]);if(!f)return;t({...e,currentSlide:f}),s([f])}},u=()=>{let m=a({styles:"#styles:,h-full w-full min-w-full",type:"Slide"},l==null?void 0:l._id),g=m==null?void 0:m._id;g&&(t({...e,currentSlide:g}),s([g]))};return Tt("div",{className:"space-y-1.5 px-2",children:[Tt("div",{className:"flex items-center gap-x-2 pb-2 text-[12px]",children:[Oe("button",{onClick:h,className:"rounded bg-gray-200 p-1.5 hover:opacity-80",children:Oe(Dw,{className:"h-3 w-3"})}),Oe("div",{className:"whitespace-nowrap text-center text-[10px] text-slate-500",children:d?Tt("span",{className:"",children:[Tt("b",{className:"text-[12px]",children:[" ",Qi(c,{_id:d})+1]}),"/",c.length]}):"-"}),Oe("button",{onClick:p,className:"rounded bg-gray-200 p-1.5 hover:opacity-80",children:Oe(_w,{className:"h-3 w-3"})}),Tt("button",{onClick:u,className:"flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",children:[Oe(Pw,{className:"h-3 w-3"}),"Add Slide"]})]}),Tt("div",{className:"flex items-center gap-x-2 leading-tight",children:[Oe(Gt,{checked:!!(e!=null&&e.showSlideButton),onCheckedChange:m=>t({...e,showSlideButton:!!m}),className:"h-3.5 w-3.5 cursor-pointer",id:"showSlideButton"}),Oe(z,{htmlFor:"showSlideButton",className:"mb-0 mt-0.5 cursor-pointer",children:"Show Slide Buttons"})]}),Tt("div",{className:"flex items-center gap-x-2 leading-tight",children:[Oe(Gt,{checked:!!(e!=null&&e.showSlideNavbar),onCheckedChange:m=>t({...e,showSlideNavbar:!!m}),className:"h-3.5 w-3.5 cursor-pointer",id:"showSlideNavbar"}),Oe(z,{htmlFor:"showSlideNavbar",className:"mb-0 mt-0.5 cursor-pointer",children:"Show Slide Navbar"})]}),Oe("div",{children:Tt("div",{className:"flex flex-col",children:[Tt("div",{className:"flex items-center gap-x-2 leading-tight",children:[Oe(Gt,{checked:!!(e!=null&&e.autoplay),onCheckedChange:m=>t({...e,autoplay:!!m}),className:"h-3.5 w-3.5 cursor-pointer",id:"autoplay"}),Oe(z,{htmlFor:"autoplay",className:"mb-0 mt-0.5 cursor-pointer",children:"Autoplay slides"})]}),(e==null?void 0:e.autoplay)&&Tt("div",{className:"pt-0.5 leading-tight",children:[Tt(z,{htmlFor:"interval",className:"mb-1 block",children:["Autoplay Interval ",Oe("span",{className:"font-light opacity-80",children:"(in seconds)"})]}),Oe(oe,{type:"number",id:"interval",name:"interval",placeholder:"0",value:e==null?void 0:e.autoplayInterval,className:"h-7 text-xs",pattern:"[0-9]*",onChange:m=>{let g=m.target.value;g.length&&(g=g.replace("-","")),t({...e,autoplayInterval:g})}})]})]})})]})};import{Cross1Icon as Rw,PlusIcon as Mw}from"@radix-ui/react-icons";import{get as el,map as mf,reject as Hw}from"lodash-es";import{jsx as Nt,jsxs as ln}from"react/jsx-runtime";var ff=({formData:e,onChange:t})=>{let o=el(e,"srcsets",[])||[],r=(s,i)=>{let l=s.target.name,c=s.target.value;t({srcsets:mf(o,(d,p)=>p===i?{...d,[l]:c}:d)})},n=()=>{t({srcsets:[...o,{}]})},a=s=>{t({srcsets:Hw(o,(i,l)=>parseInt(l)===s)})};return ln("div",{children:[ln("div",{className:"flex items-center justify-between pb-2",children:[Nt(z,{children:"Responsive Video (optional)"}),Nt("button",{type:"button",onClick:n,className:"flex items-center gap-x-1 rounded-md border border-blue-500 bg-blue-100 px-2 py-px text-xs text-blue-600 hover:opacity-80",children:Nt(Mw,{className:"h-3 w-3"})})]}),Nt("div",{className:"space-y-2",children:o.length===0?Nt("div",{className:"rounded border border-dashed border-gray-200 p-2 text-xs italic text-gray-500",children:"Add additional sources to create responsive videos"}):mf(o,(s,i)=>ln("div",{className:"group relative space-y-1.5 rounded border border-gray-200 p-2 pb-1.5",children:[Nt("button",{type:"button",onClick:()=>a(i),className:"absolute -right-2 -top-2 translate-y-0 rounded-full bg-destructive p-1 opacity-0 hover:bg-destructive/90 group-hover:opacity-100",children:Nt(Rw,{className:"h-2.5 w-2.5 text-white"})}),ln("div",{className:"flex items-center gap-x-2",children:[Nt(z,{className:"mb-0 flex h-8 w-1/4 items-center justify-start",children:"Width"}),Nt(oe,{name:"width",placeholder:"Enter width (in px)",type:"number",value:el(s,"width"),onChange:l=>r(l,i),className:"h-8 text-xs"})]}),ln("div",{className:"flex items-center gap-x-2",children:[Nt(z,{className:"mb-0 flex h-8 w-1/4 items-center justify-start",children:"URL"}),Nt(oe,{name:"url",placeholder:"Enter url",className:"h-8 text-xs",value:el(s,"url",""),onChange:l=>r(l,i)})]})]},i))})]})};import{jsx as cn,jsxs as Xw}from"react/jsx-runtime";var jw=()=>{let e=Wn("widget"),t=Wn("field"),o=Wn("template"),r=cs(()=>({richtext:cf,icon:_m,image:Hm,code:Bm,colCount:nf,collectionSelect:Im,repeaterBinding:ef,...e}),[e]),n=cs(()=>({link:qm,slider:uf,sources:ff,images:Qm,...t}),[t]),a=cs(()=>({FieldTemplate:Km,ButtonTemplates:{AddButton:Zw},...o}),[o]);return{widgets:r,fields:n,templates:a}},Zw=e=>cn("button",{...e,className:"duration absolute right-2 top-2 cursor-pointer text-blue-400 hover:text-blue-500",children:Xw("div",{className:"flex items-center gap-x-0.5 text-[11px] leading-tight",children:[cn(Ow,{className:"h-3 w-3"})," ",cn("span",{children:"Add"})]})}),Yw=({formRef:e,blockId:t,formData:o,selectedLang:r,uiSchemaCopy:n,schemaCopy:a,onChange:s})=>{let{widgets:i,fields:l,templates:c}=jw(),d=Kw((p,h)=>{let{formData:u}=p;if(!h||t!==(u==null?void 0:u._id))return;let m=Uw(h.split("."),2).join(".").replace("root.","");$w(u,m)===void 0&&Ww(u,m,""),s({formData:u},m)},[t,s]);return cn(Vw,{ref:e,widgets:i,fields:l,templates:c,idSeparator:".",autoComplete:"off",omitExtraData:!1,liveOmit:!1,liveValidate:!1,validator:zw,uiSchema:n,schema:a,formData:o,onChange:d},`json-form-${t}-${r}`)},ds=Gw(({blockId:e,schema:t,uiSchema:o,formData:r,onChange:n})=>{let{selectedLang:a}=te(),s=gf(r),i=gf(null);s.current=r;let[l,c]=ol(r),[d,p]=ol(!1),[{schema:h,uiSchema:u}]=ol({schema:t,uiSchema:o});tl(()=>{var k,v;let f=(v=(k=i==null?void 0:i.current)==null?void 0:k.formElement)==null?void 0:v.current;if(!f)return;let b=()=>p(!1),y=()=>p(!0);return f.addEventListener("focusout",b),f.addEventListener("focusin",y),()=>{f.removeEventListener("focusout",b),f.removeEventListener("focusin",y)}},[]),tl(()=>{e&&d&&c(s.current)},[e,d]),tl(()=>{e&&!d&&c(r)},[e,d,r]);let m=Fw(async({formData:f},b)=>{n({formData:f},b)},[a],800);return cs(()=>cn(Yw,{blockId:e,formRef:i,formData:l,selectedLang:a,uiSchemaCopy:u,schemaCopy:h,onChange:(f,b)=>{c(f.formData),m(f,b)}}),[e,l,a,u,h,m])});ds.displayName="JSONForm";import{TrashIcon as rS}from"@radix-ui/react-icons";import{has as xf,isString as ms}from"lodash-es";import{Settings as nS}from"lucide-react";import{useEffect as aS,useRef as sS,useState as Cf}from"react";import{useTranslation as iS}from"react-i18next";import{Eta as qw}from"eta/core";import{get as Jw,isArray as hf,isObject as bf}from"lodash-es";import{useEffect as ps,useMemo as Qw,useRef as kr,useState as us}from"react";import{useTranslation as eS}from"react-i18next";import{jsx as Vo,jsxs as zo}from"react/jsx-runtime";var tS=new qw({tags:["{{","}}"],autoEscape:!0,autoTrim:!1,useWith:!0,parse:{interpolate:"",exec:"~",raw:"~"}}),oS=[/\b(?:window|document|globalThis|process|Function|eval|import|fetch|XMLHttpRequest|WebSocket|localStorage|sessionStorage)\b/,/(^|[^=!<>])=([^=]|$)/,/\b(?:while|for|try|catch|class|new)\b/],yf=e=>hf(e)?"array":e===null?"null":bf(e)?"JSON":typeof e,rl=(e,t)=>{let o=t?Jw(e,t):e;return!bf(o)||o===null||hf(o)?[]:Object.entries(o).filter(([r])=>!r.startsWith("#")).map(([r,n])=>({path:t?`${t}.${r}`:r,type:yf(n)}))},dn=e=>{let t=e.trim();if(!t)return null;if(oS.some(r=>r.test(t)))return"Unsafe expression detected";try{return tS.compile(`{{${t}}}`),null}catch(r){return"Invalid expression syntax"}},vf=({currentExpression:e,externalData:t,isOpen:o,onSave:r})=>{let n=kr(null),a=kr(null),s=kr(r),i=kr(e),l=dn(e),c=kr(l),d=kr(o),[p,h]=us(e),[u,m]=us(l),[g,f]=us(0),[b,y]=us(null),{t:k}=eS();ps(()=>{h(e),m(dn(e)),y(null),f(0)},[e]),ps(()=>{s.current=r,i.current=p,c.current=u,d.current=o},[r,p,u,o]),ps(()=>()=>{var B;if(d.current)return;let x=(B=i.current)==null?void 0:B.trim();c.current||s.current(x)},[]);let v=Qw(()=>Object.entries(t!=null?t:{}).filter(([x])=>!x.startsWith("#")).map(([x,B])=>({key:x,type:yf(B)})),[t]),S=(x,B)=>{let N=x.slice(0,B).match(/[A-Za-z_$][\w$.]*\.?$/);if(!N){y(null);return}let T=N[0],C;if(T.endsWith(".")){let w=T.slice(0,-1);C=rl(t,w)}else{let w=T.lastIndexOf(".");if(w===-1)C=rl(t,"").filter(A=>A.path.toLowerCase().startsWith(T.toLowerCase()));else{let A=T.slice(0,w),_=T.slice(w+1).toLowerCase();C=rl(t,A).filter(Z=>Z.path.slice(Z.path.lastIndexOf(".")+1).toLowerCase().startsWith(_))}}if(C=C.slice(0,8),!C.length){y(null),f(0);return}y({start:B-T.length,end:B,options:C}),f(0)},E=(x,B)=>{if(!b)return;let I=B==="JSON"?`${x}.`:x,N=p.slice(0,b.start)+I+p.slice(b.end);h(N),m(dn(N)),y(null),f(0),requestAnimationFrame(()=>{var C,w;let T=b.start+I.length;(C=n.current)==null||C.focus(),(w=n.current)==null||w.setSelectionRange(T,T),S(N,T)})};return ps(()=>{if(!b||!a.current)return;let x=a.current.children[g];x==null||x.scrollIntoView({block:"nearest"})},[g,b]),zo("div",{className:"grid gap-2",children:[zo("div",{children:[Vo("p",{className:"mb-1 text-[10px] font-medium text-muted-foreground",children:k("Available databindings:")}),Vo("div",{className:"flex flex-wrap gap-1",children:v.map(x=>zo("span",{className:"inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-[10px]",children:[Vo("span",{className:"font-medium",children:x.key}),zo("span",{className:"ml-0.5 text-muted-foreground",children:[": ",x.type]})]},x.key))})]}),zo("div",{className:"relative",children:[Vo(oe,{ref:n,id:"expression",value:p,className:`h-8 text-xs ${u?"border-red-500":""}`,onChange:x=>{var T;let B=x.target.value,I=(T=x.target.selectionStart)!=null?T:B.length;h(B);let N=dn(B);m(N),S(B,I)},onKeyDown:x=>{if(b&&b.options.length){if(x.key==="ArrowDown"){x.preventDefault(),f(B=>B>=b.options.length-1?0:B+1);return}if(x.key==="ArrowUp"){x.preventDefault(),f(B=>B<=0?b.options.length-1:B-1);return}if(x.key==="Enter"||x.key==="Tab"){x.preventDefault();let B=b.options[g];B&&E(B.path,B.type);return}if(x.key==="Escape"){x.preventDefault(),y(null),f(0);return}}if(x.key==="Enter"){x.preventDefault();let B=dn(p);m(B),B||r(p.trim())}},placeholder:"name === 'x'",autoComplete:"off"}),b&&Vo("div",{ref:a,className:"absolute z-20 mt-1 max-h-36 w-full overflow-auto rounded border bg-background p-1 shadow",children:b.options.map((x,B)=>zo("button",{type:"button",className:`block w-full rounded px-2 py-1 text-left text-[10px] hover:bg-muted ${B===g?"bg-muted":""}`,onMouseDown:I=>{I.preventDefault(),E(x.path,x.type)},children:[Vo("span",{className:"font-medium",children:x.path.slice(x.path.lastIndexOf(".")+1)}),zo("span",{className:"ml-1 text-muted-foreground",children:[": ",x.type]})]},x.path))})]}),u&&Vo("p",{className:"text-[10px] text-red-500",children:u})]})};import{jsx as Ze,jsxs as No}from"react/jsx-runtime";var kf=()=>{let{t:e}=iS(),t=$(),o=et(),r=ze(),[n,a]=Cf(!1),[s,i]=Cf(!1),l=sS(null);aS(()=>()=>{l.current&&clearTimeout(l.current)},[]);let c=g=>{if(t){if(!g||g.trim()===""){ms(t._show)&&r([t._id],{_show:!0});return}r([t._id],{_show:`{{${g.trim()}}}`})}},d=g=>{a(g)},p=()=>{if(!t)return;let g=xf(t,"_show")?t._show:!0;r([t._id],{_show:!g})},h=()=>{t&&(r([t._id],{_show:!0}),i(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{i(!1)},200),a(!1))};if(!t)return null;let u=ms(t._show),m=u?t._show.startsWith("{{")&&t._show.endsWith("}}")?t._show.slice(2,-2).trim():t._show:"";return No("div",{className:"my-2 mb-4 flex items-center justify-between",children:[No("div",{className:"mr-2 flex min-w-0 flex-1 flex-col items-start space-y-0 leading-none",children:[No("div",{className:"flex items-baseline gap-1 text-xs text-gray-500",children:[e("Visibility"),ms(t._show)&&Ze("span",{className:"text-[9px] italic text-gray-400",children:e("visible when true")})]}),ms(t._show)&&Ze("code",{className:"mt-0.5 block max-w-full break-words rounded bg-primary/10 px-1.5 py-0.5 text-[9px] leading-relaxed text-primary",children:m})]}),No("div",{className:"group relative",children:[No(Zo,{open:n,onOpenChange:d,children:[Ze(Yo,{asChild:!0,children:Ze("button",{type:"button","aria-label":e("Open visibility settings"),className:"absolute -left-2 -top-1.5 z-10 cursor-pointer rounded-full border border-blue-500 bg-background p-0.5 text-blue-500 transition-all hover:scale-125",children:Ze(nS,{className:"h-2.5 w-2.5","aria-hidden":"true"})})}),Ze(Xo,{side:"left",align:"start",className:"max-w-92 p-3",children:No("div",{className:"grid gap-2",children:[No("div",{className:"flex items-center justify-between",children:[No("div",{className:"space-y-1",children:[Ze("h4",{className:"text-xs font-medium leading-none",children:e("Conditional Visibility")}),Ze("p",{className:"text-[10px] text-muted-foreground",children:e("Enter a javascript expression. Block will be visible when expression evaluates to true.")})]}),u&&Ze(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-red-500 hover:text-red-500",onClick:h,children:Ze(rS,{className:"h-3.5 w-3.5"})})]}),Ze("div",{className:"relative",children:Ze(vf,{currentExpression:m,externalData:o,isOpen:n,onSave:g=>{s||(c(g),a(!1))}})})]})})]}),Ze(At,{checked:u?!0:xf(t,"_show")?t._show:!0,onCheckedChange:p,disabled:u})]})]})};import{jsx as wr,jsxs as gs}from"react/jsx-runtime";var Sf=(e,t,o)=>{let r=Eo(o,"i18nProps",[]);if(hs(t)||hs(r))return e;let n=dS(e);return uS(fS(e),a=>{mS(r,a)&&(n[a]=Eo(e,`${a}-${t}`))}),n};function bs(){let{selectedLang:e}=te(),t=$(),o=ql(),r=ze(),n=Be(t==null?void 0:t._type),a=pn(()=>Sf(t,e,n),[t,e,n]),[s,i]=wf(a),[l,c]=wf(!1),d=Cr(),p=Be(d==null?void 0:d._type),h=pn(()=>Sf(d,e,p),[d,e,p]),u=bS(({formData:S},E,x)=>{E&&(s==null?void 0:s._id)===t._id&&r([t._id],{[E]:Eo(S,E)},x)},[s==null?void 0:s._id,t._id,r]),m=pn(()=>pS(({formData:S},E,x)=>{u({formData:S},E,x),i(S)},1500),[u]),g=({formData:S},E)=>{E&&(o([t._id],{[E]:Eo(S,E)}),m({formData:S},E,{[E]:Eo(s,E)}))},f=({formData:S},E)=>{E&&(o([d._id],{[E]:Eo(S,E)}),m({formData:S},E,{[E]:Eo(s,E)}))},{schema:b,uiSchema:y}=pn(()=>{let S=t==null?void 0:t._type;if(!S)return{schema:{},uiSchema:{}};try{let{schema:E,uiSchema:x}=Ms(S);if(S==="Repeater"){let B=Eo(t,"repeaterItems","");hS(B,`{{${"#"}`)?(fs(x,"filter",{"ui:widget":"collectionSelect"}),fs(x,"sort",{"ui:widget":"collectionSelect"})):(fs(x,"filter",{"ui:widget":"hidden"}),fs(x,"sort",{"ui:widget":"hidden"}))}return{schema:E,uiSchema:x}}catch(E){return{schema:{},uiSchema:{}}}},[t]),{wrapperSchema:k,wrapperUiSchema:v}=pn(()=>{if(!d||!(d!=null&&d._type))return{wrapperSchema:{},wrapperUiSchema:{}};let S=d==null?void 0:d._type,{schema:E={},uiSchema:x={}}=Ms(S);return{wrapperSchema:E,wrapperUiSchema:x}},[d]);return gs("div",{className:"no-scrollbar overflow-x-hidden px-px",children:[wr(kf,{}),!hs(d)&&gs("div",{className:"mb-4 rounded border px-1",children:[gs("div",{onClick:()=>c(S=>!S),className:"flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",children:[l?wr(lS,{className:"h-4 w-4 text-slate-400"}):wr(cS,{className:"h-4 w-4 text-slate-400"}),gS(d._type)," settings"," ",d._name&&gs("span",{className:"text-[11px] font-light text-slate-400",children:["(",d._name,")"]})]}),wr("div",{className:l?"h-auto":"invisible h-0",children:wr(ds,{blockId:d==null?void 0:d._id,onChange:f,formData:h,schema:k,uiSchema:v})})]}),hs(b)?null:wr(ds,{blockId:t==null?void 0:t._id,onChange:g,formData:a,schema:b,uiSchema:y})]})}import{useThrottledCallback as p1}from"@react-hookz/web";import{get as sg,isEmpty as u1,startsWith as m1}from"lodash-es";import ig,{useCallback as f1}from"react";import{DotsVerticalIcon as wS}from"@radix-ui/react-icons";import{find as SS,get as TS,isEmpty as Ef,map as NS,startCase as nl}from"lodash-es";import{useState as ES}from"react";import{useTranslation as BS}from"react-i18next";import{pick as yS}from"lodash-es";import{useCallback as ys}from"react";var vs=()=>{let e=$(),t=ze(),o=ys(s=>tr(s)||{},[]),r=ys(s=>Object.keys(s).filter(i=>typeof s[i]=="string"&&s[i].startsWith("#styles:")),[]),n=ys(s=>{var c;if(!e)return;let l=(c=o(e._type)[s])!=null?c:"#styles:,";t([e._id],{[s]:l})},[e,o,t]);return{resetAll:ys(()=>{if(!e)return;let s=r(e);if(s.length===0)return;let i=o(e._type),l=yS(i,s);t([e._id],l)},[e,r,o,t]),reset:n}};import{CheckIcon as vS,ChevronDownIcon as xS}from"@radix-ui/react-icons";import{startCase as Tf}from"lodash-es";import{useState as CS}from"react";import{useTranslation as kS}from"react-i18next";import{jsx as Sr,jsxs as un}from"react/jsx-runtime";var Nf=({value:e,options:t,onValueChange:o})=>{let[r,n]=CS(!1),{t:a}=kS();return un(Zo,{open:r,onOpenChange:n,children:[Sr(Yo,{asChild:!0,children:un(D,{variant:"outline",size:"xs",role:"combobox","aria-expanded":r,className:"w-full justify-between text-xs font-normal",children:[e?Tf(e):a("Select element"),Sr(xS,{className:"ml-2 h-3 w-3 shrink-0 opacity-50"})]})}),Sr(Xo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:un(El,{children:[Sr(Bl,{placeholder:a("Search element..."),className:"h-8"}),un(Al,{children:[Sr(Il,{children:a("No element found.")}),t.map(s=>un(Dl,{value:s,onSelect:i=>{o(i),n(!1)},children:[Sr(vS,{className:Nn("mr-1 h-3 w-3",e===s?"opacity-100":"opacity-0")}),Tf(s)]},s))]})]})})]})};import{Fragment as AS,jsx as gt,jsxs as Tr}from"react/jsx-runtime";var Bf=()=>{var f,b;let e=$(),[t,o]=K(),r=da(),[n]=W(),{t:a}=BS(),{reset:s}=vs(),[i,l]=ES(null);if(!e)return null;let c=Object.keys(e).filter(y=>typeof e[y]=="string"&&e[y].startsWith("#styles:"));if(!(!Ef(c)&&c.length>1))return null;let p=TS(e,(f=t[0])==null?void 0:f.prop,""),{classes:h=""}=sr(p)||{},u=h?h.split(" ").filter(y=>!Ef(y)):[],m=y=>SS(t,k=>k.prop===y),g=((b=t[0])==null?void 0:b.prop)||c[0];return Tr(AS,{children:[Tr("div",{className:"flex items-center justify-between",children:[Tr(Hr,{variant:"inactive",className:"group relative mt-1 rounded-sm border-none bg-transparent px-0 pr-2 text-xs font-medium hover:bg-transparent",children:[a("Style Elements"),":"]}),gt("span",{children:gt(lo,{slotId:io.BLOCK_STYLING_ELEMENTS})})]}),gt("div",{className:"flex flex-wrap gap-1 pb-2 pt-1",children:c.length<=2?NS(c,y=>{let k=m(y);return Tr(Hr,{variant:k?"active":"inactive",className:"group relative rounded-sm py-0 pl-2 pr-0",onClick:()=>{o([{id:`${y}-${e._id}`,blockId:e._id,prop:y}])},children:[nl(y),Tr(ot,{open:i===y,onOpenChange:v=>l(v?y:null),children:[gt(rt,{asChild:!0,children:gt(D,{variant:"ghost",size:"icon-xs",onClick:v=>v.stopPropagation(),className:`h-full w-max rounded rounded-l-none border-l px-0.5 duration-300 ${k?"bg-primary/10 text-primary-foreground hover:bg-primary":"bg-background/20 hover:bg-background"}`,children:gt(wS,{className:"!h-3 !w-3"})})}),Tr(nt,{side:"bottom",align:"end",children:[gt(Yn,{className:"line-clamp-1 max-w-32 px-2 py-1 text-xs text-muted","aria-label":nl(y),children:nl(y)}),gt(Xn,{}),gt(Pe,{className:"text-xs",onClick:()=>{s(y),l(null)},children:a("Reset style")}),gt(Pe,{className:"text-xs",onClick:()=>{r(n,u,!0),l(null)},children:a("Clear styles")})]})]})]},y)}):gt(Nf,{value:g,options:c,onValueChange:y=>{o([{id:`${y}-${e._id}`,blockId:e._id,prop:y}])}})}),gt("div",{className:"mt-2 h-px w-full border-b bg-transparent"})]})};import{flatten as Jf,has as yn,intersection as i1,map as cl,startCase as tg}from"lodash-es";import Qf,{createContext as l1,useCallback as c1,useMemo as og}from"react";import{useTranslation as rg}from"react-i18next";import{CrossCircledIcon as UT,InfoCircledIcon as GT}from"@radix-ui/react-icons";import{findLast as KT,get as Ot}from"lodash-es";import{useCallback as ll,useEffect as jT,useMemo as Yf}from"react";import{useTranslation as ZT}from"react-i18next";import{InfoCircledIcon as OS,RowSpacingIcon as FS,TriangleDownIcon as VS}from"@radix-ui/react-icons";import{useThrottledCallback as If}from"@react-hookz/web";import{first as Pf,get as ht,isEmpty as Cs,isNaN as zS,parseInt as $S}from"lodash-es";import{useCallback as Df,useContext as WS,useEffect as US,useState as Wo}from"react";import IS from"react";var xs=IS.createContext({setDragData:()=>{}});import{isEmpty as DS}from"lodash-es";var al=(e,t)=>{e=e.toLowerCase();let o=e.trim().replace(/ |\+/g,"");if((o==="auto"||o==="none")&&t.includes(o))return{value:"",unit:o};let r=t.length?new RegExp(t.join("|"),"g"):/XXXXXX/g;o=o.replace(r,"");let n=e.match(r),a=n&&n.length>1,s=!DS(o)&&Number.isNaN(Number(o));return a||s?{error:"Invalid value"}:n&&(n[0]==="auto"||n[0]==="none")?{value:n[0],unit:""}:{value:o,unit:n?n[0]:""}};import{first as _S,get as PS,includes as $o,isEmpty as Af,isNumber as LS,map as RS,startsWith as mn}from"lodash-es";var MS=e=>{let t=e.startsWith("-")?"-":"",o=e.split("-").pop();if(["auto","none"].includes(o))return{value:"",unit:o};if(o==="px")return{value:"1",unit:"px"};if(o==="screen")return{value:"100",unit:e.indexOf("w-")!==-1?"vw":"vh"};if(o==="full")return{value:"100",unit:"%"};if($o(e,"skew-"))return{value:`${t}${o}`,unit:"deg"};if($o(e,"rotate-"))return{value:`${t}${o}`,unit:"deg"};if($o(e,"opacity-"))return{value:`${o/100}`,unit:"-"};if($o(e,"duration-")||$o(e,"delay-"))return{value:`${o}`,unit:"ms"};if($o(e,"translate-")&&!o.includes("/"))return{value:`${t}${`${o/4}`}`,unit:"rem"};if($o(e,"scale-"))return{value:`${t}${`${o/100}`}`,unit:"-"};if(mn(e,"border")){let r=e.match(/border-?(x|y|t|r|b|l)?\d+/g);if(r)return{value:r[0].split("-").pop(),unit:"px"};if(e.match(/border-?(x|y|t|r|b|l)?/g))return{value:"1",unit:"px"}}if(mn(e,"max-w-")){if(e==="max-w-screen-sm")return{value:"640",unit:"px"};if(e==="max-w-screen-md")return{value:"768",unit:"px"};if(e==="max-w-screen-lg")return{value:"1024",unit:"px"};if(e==="max-w-screen-xl")return{value:"1280",unit:"px"};if(e==="max-w-screen-2xl")return{value:"1536",unit:"px"};if(o==="xs")return{value:"320",unit:"px"};if(o==="sm")return{value:"384",unit:"px"};if(o==="md")return{value:"448",unit:"px"};if(o==="lg")return{value:"512",unit:"px"};if(o==="xl")return{value:"576",unit:"px"};if(o==="2xl")return{value:"672",unit:"px"};if(o==="3xl")return{value:"768",unit:"px"};if(o==="4xl")return{value:"896",unit:"px"};if(o==="5xl")return{value:"1024",unit:"px"};if(o==="6xl")return{value:"1152",unit:"px"};if(o==="7xl")return{value:"1280",unit:"px"};if(o==="prose")return{value:"65",unit:"ch"}}if(mn(e,"text-")){if(o==="xs")return{value:"12",unit:"px"};if(o==="sm")return{value:"14",unit:"px"};if(o==="base")return{value:"16",unit:"px"};if(o==="lg")return{value:"18",unit:"px"};if(o==="xl")return{value:"20",unit:"px"};if(o==="2xl")return{value:"24",unit:"px"};if(o==="3xl")return{value:"30",unit:"px"};if(o==="4xl")return{value:"36",unit:"px"};if(o==="5xl")return{value:"48",unit:"px"};if(o==="6xl")return{value:"60",unit:"px"};if(o==="7xl")return{value:"72",unit:"px"};if(o==="8xl")return{value:"96",unit:"px"};if(o==="9xl")return{value:"128",unit:"px"}}if(mn(e,"leading-")){if(o==="none")return{value:"1",unit:"-"};if(o==="tight")return{value:"1.25",unit:"-"};if(o==="snug")return{value:"1.375",unit:"-"};if(o==="normal")return{value:"1.5",unit:"-"};if(o==="relaxed")return{value:"1.625",unit:"-"};if(o==="loose")return{value:"2",unit:"-"}}if(mn(e,"tracking-")){if(o==="tighter")return{value:"-0.05",unit:"em"};if(o==="tight")return{value:"-0.025",unit:"em"};if(o==="normal")return{value:"0",unit:"em"};if(o==="wide")return{value:"0.025",unit:"em"};if(o==="wider")return{value:"0.05",unit:"em"};if(o==="widest")return{value:"0.1",unit:"em"}}if(["max","min","fit"].includes(o))return{value:e,unit:"class"};if(o.includes("/")){let[r,n]=RS(o.split("/"),a=>parseInt(a,10));return{value:t+(r/n*100).toFixed(2).replace(".00",""),unit:"%"}}return LS(parseFloat(o))?{value:`${t+parseFloat(o)*4}`,unit:"px"}:{value:o,unit:"class"}};var sl=e=>{if(Af(e))return{value:"",unit:""};let t=e.match(/\[.*\]/g);if(t===null)return HS(e);let o=PS(t,"0","").replace(/\[|\]/g,""),r=e.startsWith("-")?"-":"",n=_S(o.match(/\d+.\d+|\d+/g));return{value:`${r}${n}`,unit:o.replace(n,"")}},HS=e=>Af(e)?{value:"",unit:""}:MS(e);import{Fragment as ZS,jsx as ve,jsxs as Nr}from"react/jsx-runtime";var GS=({unit:e,currentValue:t,onDrag:o,onDragEnd:r,onDragStart:n,negative:a,cssProperty:s})=>{let{setDragData:i}=WS(xs);return ve("button",{type:"button",onMouseDown:l=>{let c={onDrag:o,onDragEnd:r,dragging:!0,dragStartY:l.pageY,dragStartValue:`${t}`,dragUnit:e,negative:a,cssProperty:s};n(c),i(c)},color:void 0,className:"bg-surface/70 relative z-50 ml-1 hidden h-6 cursor-row-resize rounded px-2 group-hover:inline",children:ve(FS,{})})},KS=({onSelect:e,current:t,units:o})=>ve("div",{"data-theme":"light",className:"-m-[7px] -mx-[13px] flex w-9 flex-col",children:o.map(r=>ve(D,{className:"h-max rounded-none px-1 py-1 text-right text-[11px] hover:bg-blue-400",color:t===r?"primary":void 0,size:"sm",onClick:n=>{n.stopPropagation(),e(r)},children:r},r))}),_f=50,jS=(e,t,o)=>{let{value:r,unit:n}=sl(e);return n===""?{value:r,unit:t!=null&&t.toLowerCase().includes("width")?"%":Pf(o)}:{value:n==="class"||Cs(r)?"":r,unit:n}},Lf=e=>{let{currentClass:t,onChange:o,classPrefix:r,cssProperty:n,units:a,negative:s}=e,i=jS(t,n,a),[l,c]=Wo(!1),[d,p]=Wo(i.value),[h,u]=Wo(i.unit),[m,g]=Wo(!1),[f,b]=Wo(""),[y,k]=Wo(!1),[v,S]=Wo(!1);US(()=>{let{value:N,unit:T}=sl(t);queueMicrotask(()=>{if(T===""){let C=n!=null&&n.toLowerCase().includes("width")?"%":Pf(a);p(N),u(C);return}u(T),p(T==="class"||Cs(N)?"":N)})},[t,n,a]);let E=If(N=>o(N),[o],_f),x=If(N=>o(N,!1),[o],_f),B=Df((N=!1)=>{let T=al(`${d}`,a);if(ht(T,"error",!1)){g(!0);return}let C=ht(T,"unit")!==""?ht(T,"unit"):h;if(C==="auto"||C==="none"){E(`${r}${C}`);return}if(ht(T,"value")==="")return;let A=`${ht(T,"value","").startsWith("-")?"-":""}${r}[${ht(T,"value","").replace("-","")}${C==="-"?"":C}]`;N?x(A):E(A)},[E,x,d,h,r,a]),I=Df(N=>{let T=al(`${d}`,a);if(ht(T,"error",!1)){g(!0);return}if(N==="auto"||N==="none"){E(`${r}${N}`);return}if(ht(T,"value")==="")return;let C=ht(T,"unit")!==""?ht(T,"unit"):N,A=`${ht(T,"value","").startsWith("-")?"-":""}${r}[${ht(T,"value","").replace("-","")}${C==="-"?"":C}]`;E(A)},[E,d,r,a]);return ve("div",{className:"flex w-full flex-col",children:ve("div",{className:"flex items-center justify-start",children:h==="class"?Nr(ZS,{children:[ve("input",{className:"bg-surface h-6 w-24 rounded border border-foreground/20 px-2 py-0.5 text-sm focus-visible:outline-0",readOnly:!0,value:t}),Nr(me,{children:[ve(fe,{asChild:!0,children:ve("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:ve(OS,{})})}),ve(ge,{children:"Current value is using a Tailwind preset class."})]})]}):Nr("div",{className:`group relative flex items-center ${y?"z-auto":""}`,children:[Nr("div",{className:"flex items-center rounded-md border border-border",children:[["none","auto"].indexOf(h)!==-1?null:ve("input",{readOnly:h==="class",onKeyPress:N=>{N.key==="Enter"&&B()},onKeyDown:N=>{if(N.keyCode!==38&&N.keyCode!==40)return;N.preventDefault(),S(!0);let T=$S(N.target.value),C=zS(T)?0:T;N.keyCode===38&&(C+=1),N.keyCode===40&&(C-=1);let w=`${C}`,_=`${w.startsWith("-")?"-":""}${r}[${w.replace("-","")}${h==="-"?"":h}]`;x(_)},onKeyUp:N=>{v&&(N.preventDefault(),S(!1))},onBlur:()=>B(),onChange:N=>{g(!1),p(N.target.value)},onClick:N=>{var T;(T=N==null?void 0:N.target)==null||T.select(),c(!1)},value:y?f:d,className:"bg-surface h-6 w-14 rounded rounded-r-none border border-transparent pl-2 text-sm focus-visible:outline-0".concat(" ",m?"border-red-500 text-red-500":"border-foreground/20")}),Nr(me,{open:l,delayDuration:100,children:[ve(fe,{asChild:!0,children:Nr("button",{type:"button",onClick:()=>c(!l),className:"bg-surface flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none p-px px-1 text-[11px] uppercase",children:[ve("span",{className:`inline-block ${a.length===1?"px-2 font-semibold":""}`,children:h}),a.length>1?ve(VS,{}):null]})}),ve(ge,{className:"bg-surface",children:ve(KS,{units:a,current:h,onSelect:N=>{c(!1),u(N),I(N)}})})]})]}),["none","auto"].indexOf(h)!==-1||y?null:ve(GS,{onDragStart:()=>k(!0),onDragEnd:()=>{let N=f;if(b(()=>""),k(!1),Cs(N))return;let T=`${N}`,w=`${T.startsWith("-")?"-":""}${r}[${T.replace("-","")}${h==="-"?"":h}]`;E(w)},onDrag:N=>{if(Cs(N))return;b(N);let T=`${N}`,w=`${T.startsWith("-")?"-":""}${r}[${T.replace("-","")}${h==="-"?"":h}]`;x(w)},currentValue:d,unit:h,negative:s,cssProperty:n})]})})})};import{get as Ss}from"lodash-es";import{useCallback as Mf,useContext as tT,useEffect as oT,useMemo as Hf,useState as rT}from"react";import{InfoCircledIcon as qS}from"@radix-ui/react-icons";import{get as JS}from"lodash-es";import{useContext as QS,useMemo as eT}from"react";import{createContext as YS}from"react";import{jsx as XS}from"react/jsx-runtime";var eo=YS({canReset:!1,canChange:!0}),Rf=({children:e,canReset:t=!1,canChange:o=!0})=>XS(eo.Provider,{value:{canReset:t,canChange:o},children:e});import{jsx as to,jsxs as il}from"react/jsx-runtime";var ks=({label:e,property:t,onChange:o})=>{let{getClasses:r}=fo(),n=r(t),a=oo(t),s=eT(()=>JS(a,"cls",""),[a]),{canChange:i}=QS(eo),l=/\[.*\]/g.test(s);return to("div",{className:e?"w-full rounded":"grow",children:l?il("div",{className:"flex items-center",children:[to(oe,{className:"w-[70%] rounded py-1",readOnly:!0,value:s}),il(me,{delayDuration:100,children:[to(fe,{asChild:!0,children:to("button",{type:"button",className:"invisible ml-3 mt-1 text-blue-600 group-hover:visible",children:to(qS,{})})}),to(ge,{children:"Current value is using a Tailwind arbitrary value."})]})]}):to(ws,{rounded:e,onChange:c=>o(c,t),selected:s,options:n,disabled:!i})})};function ws({selected:e,onChange:t,rounded:o=!1,options:r,disabled:n=!1}){let a=e.replace(/.*:/g,"").trim(),{undo:s,redo:i}=so();return il("select",{disabled:!r.length||n,className:`${o?"rounded-md border border-border":"border-0"} bg-surface h-full w-full truncate rounded px-2 py-1 text-xs outline-none disabled:cursor-not-allowed disabled:bg-gray-500`,onChange:l=>t(l.target.value),onKeyDown:l=>{l.ctrlKey&&(l.key==="z"&&s(),l.key==="y"&&i())},value:a,children:[to("option",{className:"bg-transparent",value:""}),r.map((l,c)=>to("option",{className:"bg-transparent",value:l,children:l},`option-${c}`))]})}import{jsx as Ts,jsxs as aT}from"react/jsx-runtime";var nT={backgroundColor:"bg",textColor:"text",borderColor:"border",boxShadowColor:"shadow",outlineColor:"outline",divideColor:"divide",fromColor:"from",viaColor:"via",toColor:"to",ringColor:"ring",ringOffsetColor:"ring-offset"},Of=({property:e,onChange:t})=>{let o=oo(e),r=Hf(()=>Ss(o,"cls",""),[o]),{canChange:n}=tT(eo),a=r.split("-"),s=Ss(a,"1",""),i=Ss(a,"2",""),[l,c]=rT({color:"",shade:""}),d=Hf(()=>{let m=l.color||s;return["current","inherit","transparent","black","white"].includes(m)?[]:["50","100","200","300","400","500","600","700","800","900"]},[l.color,s]),p=Mf(m=>{["current","inherit","transparent","black","white"].includes(m)?c({color:m}):c(g=>({...g,color:m,shade:g.shade?g.shade:"500"}))},[]),h=Mf(m=>{c({color:s,shade:m})},[s]),{match:u}=fo();return oT(()=>{let g=`${Ss(nT,e,"")}-${l.color}${l.shade?`-${l.shade}`:""}`;u(e,g)&&t(g,e)},[u,l,t,e]),aT("div",{className:"flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs",children:[Ts("div",{className:"grow text-center",children:Ts(ws,{disabled:!n,rounded:!0,selected:s,onChange:p,options:["current","transparent","primary","secondary","black","white","slate","gray","zinc","neutral","stone","red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose"]})}),Ts("button",{type:"button",className:"grow text-center",children:Ts(ws,{rounded:!0,selected:i,disabled:!s||!n,onChange:h,options:d})})]})};import{BoxIcon as CT}from"@radix-ui/react-icons";import{get as Vf,map as kT,startCase as wT,toLower as ST}from"lodash-es";import TT,{useContext as NT,useMemo as ET}from"react";import{AlignCenterHorizontallyIcon as sT,AlignLeftIcon as iT,AlignRightIcon as lT,ArrowBottomLeftIcon as cT,ArrowBottomRightIcon as dT,ArrowDownIcon as fn,ArrowLeftIcon as gn,ArrowRightIcon as hn,ArrowTopLeftIcon as pT,ArrowTopRightIcon as uT,ArrowUpIcon as bn,BorderAllIcon as ro,Cross1Icon as mT,Cross2Icon as fT,EyeClosedIcon as Ff,EyeOpenIcon as gT,FontItalicIcon as hT,HeightIcon as Ye,LetterCaseUppercaseIcon as bT,OverlineIcon as yT,StretchHorizontallyIcon as vT,UnderlineIcon as xT,WidthIcon as Xe}from"@radix-ui/react-icons";import{jsx as _e,jsxs as Er}from"react/jsx-runtime";var Ns={"not-italic":()=>_e("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:_e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z",fill:"white"})}),visible:gT,invisible:Ff,hidden:Ff,gap:ro,gapX:Xe,gapY:Ye,spaceX:Xe,spaceY:Ye,overscroll:ro,overscrollX:Xe,overscrollY:Ye,overflow:ro,overflowX:Xe,overflowY:Ye,top:bn,right:hn,bottom:fn,left:gn,inset:ro,insetX:Xe,insetY:Ye,border:ro,borderX:Xe,borderY:Ye,borderTop:bn,borderRight:hn,borderBottom:fn,borderLeft:gn,borderRadius:ro,borderRadiusX:Xe,borderRadiusY:Ye,borderRadiusTop:bn,borderRadiusRight:hn,borderRadiusBottom:fn,borderRadiusLeft:gn,borderRadiusTopLeft:pT,borderRadiusTopRight:uT,borderRadiusBottomRight:dT,borderRadiusBottomLeft:cT,divideXWidth:Xe,divideYWidth:Ye,scale:ro,scaleX:Xe,scaleY:Ye,skewX:Xe,skewY:Ye,translateX:Xe,translateY:Ye,padding:ro,paddingX:Xe,paddingY:Ye,paddingTop:bn,paddingRight:hn,paddingBottom:fn,paddingLeft:gn,margin:ro,marginX:Xe,marginY:Ye,marginTop:bn,marginRight:hn,marginBottom:fn,marginLeft:gn,textLeft:iT,textCenter:sT,textRight:lT,textJustify:vT,italic:hT,underline:xT,overline:yT,uppercase:bT,block:()=>Er("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_e("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M2 2H14V14H2V2ZM1 1H15V15H1V1Z",fill:"currentColor"}),_e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 4H4V12H7V4ZM9 4H12V12H9V4Z",fill:"currentColor"})]}),"float-right":()=>Er("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_e("path",{d:"M8 4H16V12H8V4Z",fill:"currentColor"}),_e("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M0 4H6V6H0V4ZM0 7H6V9H0V7ZM4 10H0V12H4V10Z",fill:"currentColor"})]}),"float-left":()=>Er("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_e("path",{d:"M0 4H8V12H0V4Z",fill:"currentColor"}),_e("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M10 4H16V6H10V4ZM10 7H16V9H10V7ZM14 10H10V12H14V10Z",fill:"currentColor"})]}),"float-none":fT,fixed:()=>Er("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_e("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M15 2H14V4H13V5H14V6H15V2ZM10 5V4H9V2H1V8H2V5H10ZM7 4V3H5V4H7ZM4 4V3H2V4H4ZM1 13H7V14H1V13Z",fill:"currentColor"}),_e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),absolute:()=>Er("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_e("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M14 2H15V6H14V2ZM9 3V2H1V8H2V3H9ZM7 13H1V14H7V13Z",fill:"currentColor"}),_e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H10V3H11V6H12V3H13V2H11ZM2 9H1V12H2V11H7V10H2V9ZM15 7H8V14H15V7Z",fill:"currentColor"})]}),relative:()=>_e("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:_e("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M11 2H9V3H11V6H12V3H14V2H11ZM2 8H1V13H2V11H7V10H2V8ZM15 7H8V14H15V7Z",fill:"currentColor"})}),sticky:()=>Er("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_e("path",{d:"M12.9998 7C13.6558 7 14.2937 6.78498 14.8158 6.38787C15.338 5.99076 15.7156 5.43345 15.8908 4.80128C16.066 4.16912 16.0292 3.49694 15.7859 2.8877C15.5427 2.27846 15.1065 1.76573 14.5441 1.42804C13.9817 1.09034 13.3241 0.946293 12.672 1.01795C12.02 1.08961 11.4094 1.37303 10.9337 1.8248C10.4581 2.27658 10.1436 2.8718 10.0385 3.51932C9.93341 4.16685 10.0434 4.83097 10.3518 5.41L6.88176 8.88C6.80034 8.96122 6.73572 9.05769 6.69158 9.16388C6.64744 9.27008 6.62465 9.38393 6.62451 9.49894C6.62437 9.61395 6.64689 9.72785 6.69077 9.83416C6.73465 9.94046 6.79904 10.0371 6.88026 10.1185C6.96149 10.1999 7.05795 10.2645 7.16415 10.3087C7.27035 10.3528 7.3842 10.3756 7.4992 10.3758C7.61421 10.3759 7.72812 10.3534 7.83442 10.3095C7.94072 10.2656 8.03734 10.2012 8.11876 10.12L11.5888 6.648C12.0088 6.873 12.4888 7 12.9988 7H12.9998Z",fill:"currentColor"}),_e("path",{opacity:"0.6",fillRule:"evenodd",clipRule:"evenodd",d:"M9.535 2H1V14H15V7.465C14.69 7.645 14.355 7.783 14 7.875V13H2V5H9.126C8.86504 3.98486 9.01223 2.90789 9.536 2H9.535ZM7 3V4H5V3H7ZM4 3V4H2V3H4Z",fill:"currentColor"})]}),static:mT};import{jsx as Es,jsxs as BT}from"react/jsx-runtime";var zf=({property:e,onChange:t})=>{let{getClasses:o}=fo(),r=o(e),{canChange:n}=NT(eo),a=oo(e),s=ET(()=>Vf(a,"cls",""),[a]);return Es("div",{className:"flex grow flex-wrap gap-1",children:kT(r,i=>BT(me,{children:[Es(fe,{asChild:!0,children:Es("button",{type:"button",disabled:!n,onClick:()=>t(i,e),className:`cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${s===i?"bg-primary text-white":"disabled:bg-gray-600 disabled:text-gray-400"}`,children:TT.createElement(Vf(Ns,i,CT))})}),Es(ge,{children:wT(ST(i))})]}))})};import{MinusIcon as AT,PlusIcon as IT}from"@radix-ui/react-icons";import{get as DT,nth as $f}from"lodash-es";import{useContext as _T,useMemo as PT}from"react";import{Fragment as LT,jsx as Ht,jsxs as RT}from"react/jsx-runtime";var Wf=({property:e,onChange:t})=>{let{canReset:o,canChange:r}=_T(eo),n=oo(e),a=PT(()=>DT(n,"cls",""),[n]),{getClasses:s}=fo(),i=s(e,[""]),l=i.indexOf(a)>-1?i.indexOf(a):0,c=/\[.*\]/g.test(a);return Ht("div",{className:"flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs",children:c?Ht("div",{className:"px-2 py-[5px]",children:a}):RT(LT,{children:[Ht("button",{type:"button",className:"hover:bg-bg-gray-700 bg-surface box-border w-2/12 rounded-bl rounded-tl px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!r&&(!o||l-1<0),onClick:()=>t($f(i,l-1),e),children:Ht("span",{className:"flex items-center justify-center",children:Ht(AT,{className:!r&&(!o||l-1<0)?"text-gray-500":"text-background/60 dark:text-white/60"})})}),Ht("div",{className:"w-8/12 text-center",children:Ht(ks,{label:!1,property:e,onChange:t})}),Ht("button",{type:"button",className:"hover:bg-bg-gray-700 bg-surface w-2/12 rounded-br rounded-tr px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",disabled:!r&&(!o||l+1>=i.length),onClick:()=>t($f(i,l+1),e),children:Ht("span",{className:"flex items-center justify-center",children:Ht(IT,{className:!r&&(!o||l+1>=i.length)?"text-gray-500":"text-background/60 dark:text-white/60"})})})]})})};import{atom as jf,useAtomValue as MT}from"jotai";import{filter as Bs,first as HT,get as Gf,isNull as OT,map as FT,startsWith as VT}from"lodash-es";var Uf=e=>{let t=["xs","sm","md","lg","xl","2xl"],o=t.indexOf(e);return o===-1?["xs"]:t.slice(0,o+1)};var zT=jf(e=>{let t=HT(e(bc)),o=e(jl);if(!t||t.blockId!==Gf(o,"_id",null))return[];let r=Gf(o,t.prop,`${An},`),{classes:n}=sr(r);return Bs(FT(n.trim().split(" "),Kc),a=>!OT(a))});var Kf={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5},$T=jf(e=>{let t=e(xi),o=e(Fn),r=e(vi),n=Uf(t),a=Bs(e(zT),{mod:o});return VT(o,"_")||(a=Bs(a,s=>n.includes(s.mq))),a=a.sort((s,i)=>Kf[s.mq]-Kf[i.mq]),r||(a=Bs(a,{dark:!1})),a}),Uo=()=>MT($T);import{useAtom as WT}from"jotai";var Zf=()=>WT(Fn);import{jsx as Ne,jsxs as Go}from"react/jsx-runtime";var oo=e=>{let t=Uo();return KT(t,{property:e})},YT=(e,t)=>{let o={xs:0,sm:1,md:2,lg:3,xl:4,"2xl":5};return o[Ot(e,"mq","xs")]<=o[t]},XT={width:"w-",height:"h-",minWidth:"min-w-",minHeight:"min-h-",maxWidth:"max-w-",maxHeight:"max-h-",zIndex:"z-",gap:"gap-",gapX:"gap-x-",gapY:"gap-y-",margin:"m-",marginX:"mx-",marginY:"my-",marginTop:"mt-",marginBottom:"mb-",marginLeft:"ml-",marginRight:"mr-",padding:"p-",paddingX:"px-",paddingY:"py-",paddingTop:"pt-",paddingBottom:"pb-",paddingLeft:"pl-",paddingRight:"pr-",spaceX:"space-x-",spaceY:"space-y-",border:"border-",borderTop:"border-t-",borderBottom:"border-b-",borderLeft:"border-l-",borderRight:"border-r-",borderX:"border-x-",borderY:"border-y-",borderRadius:"rounded-",borderRadiusTop:"rounded-t-",borderRadiusRight:"rounded-r-",borderRadiusBottom:"rounded-b-",borderRadiusLeft:"rounded-l-",borderRadiusTopLeft:"rounded-tl-",borderRadiusTopRight:"rounded-tr-",borderRadiusBottomRight:"rounded-br-",borderRadiusBottomLeft:"rounded-bl-",fontSize:"text-",lineHeight:"leading-",letterSpacing:"tracking-",textIndent:"indent-",rotate:"rotate-",duration:"duration-",transitionDelay:"delay-",scale:"scale-",scaleX:"scale-x-",scaleY:"scale-y-",translateX:"translate-x-",translateY:"translate-y-",skewX:"skew-x-",skewY:"skew-y-",top:"top-",bottom:"bottom-",left:"left-",right:"right-",inset:"inset-",insetX:"inset-x-",insetY:"inset-y-",opacity:"opacity-",flexBasis:"basis-"},Xf={xs:"",sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"},qT=e=>`${e.toUpperCase()} ${Xf[e]?`(${Xf[e]} & up)`:""}`,Br=e=>{let{t}=ZT(),{type:o="icons",label:r,property:n,onEmitChange:a=()=>{},units:s,negative:i=!1}=e,[l]=_t(),[c]=Zf(),[,d]=jr(),p=oo(n),h=Zc(),u=da(),[m]=W(),g=Yf(()=>Ot(p,"fullCls",""),[p]),f=ll((E,x=!0)=>{let B={dark:l,mq:d,mod:c,cls:E,property:n,fullCls:""};(l||c!=="")&&(B.mq="xs");let I=jc(B);h(m,[I],x)},[m,l,d,c,n,h]),b=ll(()=>{u(m,[g],!0)},[m,g,u]),y=Yf(()=>YT(p,d),[p,d]);jT(()=>{a(y,p)},[y,a,p]);let[,,k]=jr(),v=ll(E=>{k({xs:400,sm:640,md:800,lg:1024,xl:1420,"2xl":1920}[E])},[k]),S=Ot(p,"dark",null)===l&&Ot(p,"mod",null)===c&&Ot(p,"mq",null)===d;return Ne(Rf,{canChange:y,canReset:p&&S,children:Go("div",{className:"group flex flex-row items-center py-2 first:pt-0 last:pb-0",children:[Ne("div",{className:"relative w-[70px] truncate text-xs text-foreground",children:Ne("span",{className:`text-[11px] ${p&&!S?"text-foreground":""}`,children:t(r)})}),Go("div",{className:"flex flex-row items-center",children:[Go("div",{className:"w-[150px]",children:[o==="arbitrary"?Ne(Lf,{currentClass:Ot(p,"cls",""),classPrefix:Ot(XT,n,""),units:s||[],onChange:f,negative:i,cssProperty:n}):null,o==="icons"&&Ne(zf,{property:n,onChange:f}),o==="range"&&Ne(Wf,{property:n,onChange:f}),o==="color"&&Ne(Of,{property:n,onChange:f}),o==="dropdown"&&Ne(ks,{label:r,property:n,onChange:f})]}),Ne("div",{className:`w-[30px] cursor-pointer ${g?"visible":"invisible"}`,children:S?Ne("button",{type:"button",onClick:()=>b(),title:"Reset",className:"flex px-1.5 text-xs",children:Ne(UT,{className:"h-5 w-5 text-blue-500 hover:opacity-80"})}):y&&p?Go(me,{delayDuration:100,children:[Ne(fe,{asChild:!0,children:Ne("button",{type:"button",className:"invisible ml-3 mt-1 rounded-full bg-primary text-white group-hover:visible",children:Ne(GT,{})})}),Ne(ge,{children:Ne("div",{className:"text-right",children:Go("div",{children:["Current style is set at \xA0",Go("span",{className:"font-bold",children:[qT(Ot(p,"mq")),l&&!p.dark?"(Light mode)":""]}),Ne("br",{}),Go("button",{type:"button",onClick:()=>v(Ot(p,"mq")),className:"block w-full cursor-default text-right font-semibold text-blue-500",children:["Switch to ",Ot(p,"mq").toUpperCase()]})]})})})]}):null})]})]})})};import{BoxIcon as JT}from"@radix-ui/react-icons";import{get as QT,map as e1,startCase as t1,toLower as o1}from"lodash-es";import qf,{useCallback as r1,useState as n1}from"react";import{useTranslation as a1}from"react-i18next";import{jsx as Ko,jsxs as As}from"react/jsx-runtime";var s1=["px","%","em","rem","ch","vh","vw"],Is=({label:e,options:t,borderB:o=!1,borderT:r=!1,type:n="arbitrary",units:a=s1,negative:s=!1})=>{let{t:i}=a1(),[l,c]=n1(t[0].key),d=Uo(),p=r1(h=>e1(d,"property").includes(h),[d]);return As("div",{className:`mb-2 border-border py-2 first:pt-0 last:pb-0 ${o?"border-b":""} ${r?"border-t":""}`,children:[As("div",{className:"flex flex-row text-xs",children:[e&&Ko("span",{className:"relative w-[70px] flex-none text-xs text-foreground",children:i(e)}),Ko("div",{className:"mb-3 flex grow flex-row flex-wrap gap-x-px",children:t.map(({label:h,key:u},m)=>Ko("div",{className:"first:rounded-l last:rounded-r",children:As(me,{children:[Ko(fe,{asChild:!0,children:As("button",{type:"button",onClick:()=>c(u),className:`relative cursor-pointer rounded-full p-1 text-[8px] ${u===l?"bg-[#3E57F0] text-white":"text-gray-600 dark:text-gray-300"}`,children:[qf.createElement("div",{className:p(u)?"-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full":""}),qf.createElement(QT(Ns,u,JT),{className:"text-inherit w-3 h-3"})]})}),Ko(ge,{children:t1(o1(h))})]})},`option-${m}`))})]}),Ko("div",{className:"mt-0 flex items-center",children:Ko(Br,{type:n,units:[...a],label:"",property:l,negative:s})})]})};import{jsx as Ee,jsxs as dl}from"react/jsx-runtime";var eg=({heading:e,items:t})=>{let{t:o}=rg(),r=Uo(),n=og(()=>{let a=l=>Jf(l.map(c=>c.styleType==="multiple"?cl(c.options,"key"):c.property)),s=Jf(t.map(l=>l.styleType==="accordion"?a(l.items):l.styleType==="multiple"?cl(l.options,"key"):l.property)),i=cl(r,"property");return i1(s,i).length>0},[r,t]);return dl("details",{children:[Ee("summary",{className:"my-px cursor-default rounded-md bg-gray-50 p-px px-2 text-[11px] text-foreground dark:bg-gray-800",children:dl("div",{className:"inline",children:[tg(o(e.toLowerCase())),n?Ee("span",{className:`ml-1 mr-2 inline-block h-[8px] w-[8px] rounded-full ${n?"bg-primary":"bg-gray-300"}`}):null]})}),Ee("div",{className:"p-2",children:t.map(a=>a.styleType==="multiple"?Ee(Is,{...a},a.label):Ee(Br,{...a},a.label))})]})},d1=l1({}),ng=({section:e,showAccordian:t})=>{let{t:o}=rg(),r=Uo(),n=c1((s=[])=>{let i={};for(let c=0;c<r.length;c++)i[r[c].property]=r[c].cls;let l=!0;for(let c in s)if(!yn(i,c)||i[c]!==s[c]){l=!1;break}return l},[r]),a=og(()=>({}),[]);return Ee(d1.Provider,{value:a,children:t?dl(Jn,{value:e.heading,className:"border-none",children:[Ee(xc,{className:"border-slate-150 border-t py-2 text-xs",children:Ee("div",{className:"flex items-center py-2",children:Ee("div",{className:"flex items-center gap-x-2 text-xs font-medium",children:tg(o(e.heading))})})}),Ee(Qn,{className:"py-2",children:e.items.map((s,i)=>yn(s,"component")?Qf.createElement(s.component,{key:s.label||`component-${i}`}):yn(s,"styleType")?s.styleType==="multiple"?Ee(Is,{...s},s.label+"multiple-choices"+i):s.styleType==="accordion"&&n(s==null?void 0:s.conditions)?Ee(eg,{...s},s.label+"nested-options"+i):null:Ee(Br,{...s},s.label+"block-style"+i))})]}):Ee("div",{className:"py-0",children:e.items.map((s,i)=>yn(s,"component")?Qf.createElement(s.component,{key:s.label||`component-${i}`}):yn(s,"styleType")?s.styleType==="multiple"?Ee(Is,{...s},s.label+"multiple-choices"+i):s.styleType==="accordion"&&n(s==null?void 0:s.conditions)?Ee(eg,{...s},s.label+"nested-options"+i):null:Ee(Br,{...s},s.label+"block-style"+i))})})};var Et=["px","%","em","rem","ch","vh","vw"];var ag=[{heading:"Styles",items:[{component:zs}]}],Y8=[{heading:"layout.heading",items:[{type:"arbitrary",label:"layout.width",units:Et.concat("auto"),property:"width"},{type:"arbitrary",label:"layout.height",units:Et.concat("auto"),property:"height"},{styleType:"multiple",label:"layout.margin",negative:!0,units:[...Et,"auto"],options:[{key:"margin",label:"layout.margin_all"},{key:"marginX",label:"layout.margin_lr"},{key:"marginY",label:"layout.margin_tb"},{key:"marginTop",label:"layout.margin_top"},{key:"marginRight",label:"layout.margin_right"},{key:"marginBottom",label:"layout.margin_bottom"},{key:"marginLeft",label:"layout.margin_left"}]},{styleType:"multiple",label:"layout.padding",options:[{key:"padding",label:"layout.padding_all"},{key:"paddingX",label:"layout.padding_lr"},{key:"paddingY",label:"layout.padding_tb"},{key:"paddingTop",label:"layout.padding_top"},{key:"paddingRight",label:"layout.padding_right"},{key:"paddingBottom",label:"layout.padding_bottom"},{key:"paddingLeft",label:"layout.padding_left"}]},{styleType:"multiple",label:"layout.space_bt",options:[{key:"spaceX",label:"layout.space_lr"},{key:"spaceY",label:"layout.space_tb"}]}]},{heading:"size.heading",items:[{styleType:"accordion",heading:"size.min_width_height",items:[{type:"arbitrary",label:"size.min_width",units:Et.concat("auto"),property:"minWidth"},{type:"arbitrary",label:"size.min_height",units:Et.concat("auto"),property:"minHeight"}]},{styleType:"accordion",heading:"size.max_width_height",items:[{type:"arbitrary",label:"size.max_width",units:Et.concat("auto"),property:"maxWidth"},{type:"arbitrary",label:"size.max_height",units:Et.concat("auto"),property:"maxHeight"}]},{styleType:"accordion",heading:"size.object_options_aspect_ratio",items:[{type:"dropdown",label:"size.aspect",property:"aspectRatio"},{type:"dropdown",label:"size.fit",property:"objectFit"},{type:"dropdown",label:"size.position",property:"objectPosition"}]}]},{heading:"display.heading",items:[{type:"dropdown",label:"display.display",property:"display",units:Et},{styleType:"accordion",heading:"display.flex_options",items:[{type:"dropdown",label:"display.flex_direction",property:"flexDirection"},{type:"dropdown",label:"display.flex_wrap",property:"flexWrap"},{type:"dropdown",label:"display.justify_content",property:"justifyContent"},{type:"dropdown",label:"display.align_content",property:"alignContent"},{type:"dropdown",label:"display.align_items",property:"alignItems"},{styleType:"multiple",label:"display.gap",options:[{key:"gap",label:"display.gap_all"},{key:"gapX",label:"display.gap_lr"},{key:"gapY",label:"display.gap_tb"}]}],conditions:{display:"flex"}},{styleType:"accordion",heading:"display.grid_options",items:[{type:"range",label:"display.grid_columns",property:"gridColumns"},{type:"range",label:"display.grid_rows",property:"gridRows"},{type:"dropdown",label:"display.grid_auto_flow",property:"gridAutoFlow"},{type:"dropdown",label:"display.grid_auto_cols",property:"gridAutoColumns"},{type:"dropdown",label:"display.grid_auto_rows",property:"gridAutoRows"},{type:"dropdown",label:"display.justify_content",property:"justifyContent"},{type:"dropdown",label:"display.align_content",property:"alignContent"},{type:"dropdown",label:"display.align_items",property:"alignItems"},{styleType:"multiple",label:"display.gap",units:["px","rem"],options:[{key:"gap",label:"display.gap_all"},{key:"gapX",label:"display.gap_lr"},{key:"gapY",label:"display.gap_tb"}]}],conditions:{display:"grid"}},{styleType:"accordion",heading:"display.visibility_opacity",items:[{type:"dropdown",label:"display.visibility",property:"visibility",units:Et},{type:"arbitrary",label:"display.opacity",property:"opacity",units:["-"]}]}]},{heading:"position.heading",items:[{type:"icons",label:"position.position",property:"position"},{styleType:"accordion",heading:"position.options",items:[{styleType:"multiple",label:"position.direction",options:[{key:"top",label:"position.top"},{key:"right",label:"position.right"},{key:"bottom",label:"position.bottom"},{key:"left",label:"position.left"}]},{styleType:"multiple",label:"position.inset",options:[{key:"inset",label:"position.all"},{key:"insetX",label:"position.lr"},{key:"insetY",label:"position.tb"}]},{type:"arbitrary",label:"position.z_index",units:["-","auto"],property:"zIndex"}]},{styleType:"accordion",heading:"position.float_clear",items:[{type:"icons",label:"position.float",property:"float"},{type:"dropdown",label:"position.clear",property:"clear"}]},{styleType:"accordion",heading:"position.overflow_overscroll",items:[{styleType:"multiple",type:"dropdown",label:"position.overflow",options:[{key:"overflow",label:"position.all"},{key:"overflowX",label:"position.lr"},{key:"overflowY",label:"position.tb"}]},{styleType:"multiple",type:"dropdown",label:"position.overscroll",options:[{key:"overscroll",label:"position.all"},{key:"overscrollX",label:"position.lr"},{key:"overscrollY",label:"position.tb"}]}]}]},{heading:"typography.heading",items:[{type:"dropdown",property:"fontFamily",label:"typography.font"},{type:"arbitrary",property:"fontSize",label:"typography.size",units:Et},{type:"arbitrary",property:"lineHeight",label:"typography.height",units:Et.concat("-")},{type:"range",property:"fontWeight",label:"typography.weight"},{type:"color",property:"textColor",label:"typography.color"},{styleType:"accordion",heading:"typography.alignments",items:[{type:"dropdown",property:"textAlign",label:"typography.align"},{type:"dropdown",property:"verticalAlign",label:"typography.valign"}]},{styleType:"accordion",heading:"typography.spacing_decoration_more",items:[{type:"dropdown",property:"letterSpacing",label:"typography.spacing"},{type:"dropdown",property:"textDecoration",label:"typography.decoration"},{type:"range",property:"textDecorationThickness",label:"typography.thickness"},{type:"dropdown",property:"textTransform",label:"typography.transform"}]},{styleType:"accordion",heading:"typography.whitespace_breaks",items:[{type:"dropdown",property:"whitespace",label:"typography.whitespace"},{type:"dropdown",property:"wordbreak",label:"typography.wordbreak"}]}]},{heading:"background.heading",items:[{type:"color",label:"background.bgcolor",property:"backgroundColor"},{styleType:"accordion",heading:"background.position_size_more",items:[{type:"dropdown",label:"background.attachment",property:"backgroundAttachment"},{type:"dropdown",label:"background.clipping",property:"backgroundClip"},{type:"dropdown",label:"background.origin",property:"backgroundOrigin"},{type:"dropdown",label:"background.position",property:"backgroundPosition"},{type:"dropdown",label:"background.repeat",property:"backgroundRepeat"},{type:"dropdown",label:"background.size",property:"backgroundSize"}]},{type:"dropdown",label:"background.gradient",property:"backgroundGradient"},{styleType:"accordion",heading:"background.gradient_colors",items:[{type:"color",label:"background.from_color",property:"fromColor"},{type:"color",label:"background.via_color",property:"viaColor"},{type:"color",label:"background.to_color",property:"toColor"}]}]},{heading:"border.heading",items:[{styleType:"multiple",type:"dropdown",label:"border.width",options:[{key:"border",label:"border.all"},{key:"borderX",label:"border.lr"},{key:"borderY",label:"border.tb"},{key:"borderTop",label:"border.top"},{key:"borderRight",label:"border.right"},{key:"borderBottom",label:"border.bottom"},{key:"borderLeft",label:"border.left"}]},{styleType:"multiple",type:"dropdown",label:"border.corners",options:[{key:"borderRadius",label:"border.all"},{key:"borderRadiusTop",label:"border.top"},{key:"borderRadiusRight",label:"border.right"},{key:"borderRadiusBottom",label:"border.bottom"},{key:"borderRadiusLeft",label:"border.left"},{key:"borderRadiusTopLeft",label:"border.top_left"},{key:"borderRadiusTopRight",label:"border.top_right"},{key:"borderRadiusBottomRight",label:"border.bottom_right"},{key:"borderRadiusBottomLeft",label:"border.bottom_left"}]},{type:"color",label:"border.color",property:"borderColor"},{type:"dropdown",label:"border.style",property:"borderStyle"},{styleType:"accordion",heading:"border.divide_options",items:[{styleType:"multiple",type:"range",label:"border.width",options:[{key:"divideXWidth",label:"border.lr"},{key:"divideYWidth",label:"border.tb"}]},{type:"color",label:"border.divide_color",property:"divideColor"},{type:"dropdown",label:"border.divide_style",property:"divideStyle"}]},{styleType:"accordion",heading:"border.outline_styling",items:[{type:"range",label:"border.outline_width",property:"outlineWidth"},{type:"range",label:"border.outline_offset",property:"outlineOffset"},{type:"dropdown",label:"border.outline_style",property:"outlineStyle"}]},{styleType:"accordion",heading:"border.ring_options",items:[{type:"range",label:"border.ring_width",property:"ringWidth"},{type:"color",label:"border.ring_color",property:"ringColor"},{type:"range",label:"border.ring_offset_width",property:"ringOffsetWidth"},{type:"color",label:"border.ring_offset_color",property:"ringOffsetColor"}]}]},{heading:"effect.heading",items:[{type:"range",label:"effect.shadow",property:"boxShadow"},{type:"color",label:"effect.color",property:"boxShadowColor"},{type:"dropdown",label:"effect.cursor",property:"cursor"},{styleType:"accordion",heading:"effect.blend_cursor",items:[{type:"dropdown",label:"effect.mix_blend",property:"mixBlendMode"},{type:"dropdown",label:"effect.bg_blend",property:"bgBlendMode"}]},{styleType:"accordion",heading:"effect.transform",items:[{type:"dropdown",label:"effect.origin",property:"transformOrigin"},{styleType:"multiple",label:"effect.scale",units:["-"],options:[{key:"scale",label:"effect.all"},{key:"scaleX",label:"effect.lr"},{key:"scaleY",label:"effect.tb"}]},{styleType:"multiple",label:"effect.skew",units:["deg"],options:[{key:"skewX",label:"effect.lr"},{key:"skewY",label:"effect.tb"}]},{styleType:"multiple",label:"effect.translate",negative:!0,options:[{key:"translateX",label:"effect.lr"},{key:"translateY",label:"effect.tb"}]},{type:"arbitrary",units:["deg"],negative:!0,label:"effect.rotate",property:"rotate"}]},{styleType:"accordion",heading:"effect.animation",items:[{type:"dropdown",label:"effect.animation",property:"animation"},{type:"dropdown",label:"effect.transition",property:"transition"},{type:"dropdown",label:"effect.easing",property:"transitionEase"},{type:"arbitrary",units:["ms"],label:"effect.duration",property:"duration"},{type:"arbitrary",units:["ms"],label:"effect.delay",property:"delay"}]}]},{heading:"classes.heading",items:[{component:zs}]}];import{jsx as Ds,jsxs as lg}from"react/jsx-runtime";var g1={px:1,"%":1,em:100,rem:100,ch:1,vw:1,vh:1,"-":1,deg:1,ms:.1};function _s(){let[e]=K(),[t,o]=ig.useState(""),[r,n]=ig.useState({onDrag:i=>i,onDragEnd:i=>i,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""}),a=p1(i=>{let l=!sg(r,"negative",!1),c=sg(r,"cssProperty",""),d=parseFloat(r.dragStartValue);d=isNaN(d)?0:d;let p=g1[r.dragUnit];(m1(c,"scale")||c==="opacity")&&(p=10);let u=(r.dragStartY-i.pageY)/p+d;l&&u<0&&(u=0),c==="opacity"&&u>1&&(u=1),r.onDrag(`${u}`),o(`${u}`)},[r],50),s=f1(()=>{setTimeout(()=>r.onDragEnd(`${t}`),100),n({onDrag:i=>i,onDragEnd:i=>i,dragStartY:0,dragging:!1,dragStartValue:0,dragUnit:"",negative:!1,cssProperty:""})},[r,t,n]);return u1(e)?null:lg(xs.Provider,{value:{setDragData:n},children:[r.dragging?Ds("div",{onMouseMove:a,onMouseUp:()=>s(),className:"absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"}):null,lg("div",{className:"flex flex-col",children:[Ds(Bf,{}),Ds(qn,{defaultValue:["Styles"],type:"multiple",className:"w-full",children:ag.map(i=>Ds(ng,{section:i,showAccordian:!1},i.heading))})]})]})}import{forEach as V1,get as xn,isEmpty as hg,map as z1,omit as $1,set as W1}from"lodash-es";import*as Ir from"react";import{useState as U1}from"react";import{Cross1Icon as h1,Pencil2Icon as b1}from"@radix-ui/react-icons";import{isEmpty as y1}from"lodash-es";import{Plus as v1,X as x1}from"lucide-react";import C1,{useCallback as k1,useEffect as w1,useRef as cg,useState as Ar}from"react";import{useTranslation as S1}from"react-i18next";import{Fragment as T1,jsx as ee,jsxs as qe}from"react/jsx-runtime";var dg=C1.memo(function({preloadedAttributes:t=[],onAttributesChange:o}){let[r,n]=Ar([]),[a,s]=Ar(""),[i,l]=Ar(""),[c,d]=Ar(null),[p,h]=Ar(""),u=cg(null),m=cg(null),[g,f]=Ar(!1),b=et(),{t:y}=S1();w1(()=>{n(t)},[t]);let k=()=>{if(a.startsWith("@")){h(y("Attribute keys cannot start with @"));return}if(a){let N=[...r,{key:a,value:i}];o==null||o(N),n(N),s(""),l(""),h(""),f(!1)}},v=N=>{let T=r.filter((C,w)=>w!==N);o==null||o(T),n(T)},S=N=>{d(N),s(r[N].key),l(r[N].value),f(!0)},E=()=>{if(a.startsWith("@")){h(y("Attribute keys cannot start with @"));return}if(c!==null&&a){let N=[...r];N[c]={key:a,value:i},o==null||o(N),n(N),d(null),s(""),l(""),h(""),f(!1)}},x=N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),c!==null?E():k())},B=k1(N=>{let T=A=>/[.,!?;:]/.test(A),C=(A,_,Z)=>{let ae="",O="",X=_>0?A[_-1]:"",Fe=_<A.length?A[_]:"";return _>0&&(X==="."||!T(X)&&X!==" ")&&(ae=" "),_<A.length&&!T(Fe)&&Fe!==" "&&(O=" "),{text:ae+Z+O,prefixLength:ae.length,suffixLength:O.length}},w=m.current;if(w){let A=w.selectionStart||0,_=w.value||"",Z=w.selectionEnd||A;if(Z>A){let Je=`{{${N}}}`,{text:Vt}=C(_,A,Je),jg=_.slice(0,A)+Vt+_.slice(Z);l(jg);return}let O=`{{${N}}}`,{text:X}=C(_,A,O),Fe=_.slice(0,A)+X+_.slice(A);l(Fe)}},[]),I=()=>{s(""),l(""),h(""),d(null),f(!1)};return ee(pa,{value:"attribute-manager",defaultOpen:!1,leftLabel:y("Attributes"),rightLabel:N=>ee(D,{variant:"link",size:"xs",onClick:T=>{N&&(T.stopPropagation(),f(!0))},children:N?qe(T1,{children:[ee(v1,{className:"!h-2.5 !w-2.5"})," ",y("Add Attribute")]}):y("View Attribute")}),children:qe("div",{className:"relative flex max-h-full flex-1 flex-col",children:[ee("div",{className:"flex items-center p-0",children:qe(Zo,{open:g,onOpenChange:N=>N?f(!0):I(),children:[ee(Yo,{asChild:!0,children:ee("div",{})}),ee(Xo,{className:"w-52 p-3",side:"left",align:"start",children:qe("form",{onSubmit:N=>{N.preventDefault(),c!==null?E():k()},className:"space-y-1",children:[qe("div",{className:"flex items-center justify-between",children:[ee("div",{className:"text-xs font-medium",children:y(c!==null?"Edit attribute":"Add attribute")}),qe("div",{className:"flex items-center justify-end gap-2",children:[ee(D,{type:"submit",disabled:!a.length,variant:"default",size:"xs",className:"px-2",children:y(c!==null?"Save":"Add")}),ee(D,{type:"button",variant:"ghost",size:"xs",onClick:I,className:"font-light",children:ee(x1,{})})]})]}),qe("div",{className:"space-y-2",children:[qe("div",{className:"space-y-px",children:[ee(z,{htmlFor:"attrKey",children:y("Key")}),ee(oe,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrKey",ref:u,value:a,onChange:N=>s(N.target.value),placeholder:y("Enter key"),className:"h-7 text-xs",autoFocus:!0})]}),qe("div",{className:"space-y-px",children:[qe("div",{className:"flex items-center justify-between",children:[ee(z,{htmlFor:"attrValue",children:y("Value")}),!y1(b)&&ee(ca,{data:b,onSelect:B})]}),ee(ar,{autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",id:"attrValue",ref:m,value:i,onChange:N=>l(N.target.value),onKeyDown:x,placeholder:y("Enter value"),rows:2,className:"resize-none text-xs"})]})]}),p&&ee("p",{className:"text-[10px] text-destructive",children:p})]})})]})}),r.length>0?ee("div",{className:"max-h-[40vh] space-y-1 overflow-y-auto pb-2",children:r.map((N,T)=>qe("div",{className:"flex items-center justify-between rounded-md border border-border bg-muted/10 px-2 py-1 text-sm",children:[qe("div",{className:"flex flex-col gap-0.5 text-xs leading-tight",children:[ee("span",{className:"truncate text-[10px] font-medium leading-none text-muted-foreground",children:N.key}),ee("span",{className:"max-w-[200px] text-wrap text-xs font-normal leading-none text-foreground",children:N.value.toString()})]}),qe("div",{className:"flex flex-shrink-0 gap-0.5",children:[ee(D,{variant:"ghost",size:"icon-xs",onClick:()=>S(T),className:"hover:bg-surface",children:ee(b1,{className:"!h-3 !w-3"})}),ee(D,{variant:"ghost",size:"icon-xs",className:"hover:bg-destructive/30 hover:text-foreground",onClick:()=>v(T),children:ee(h1,{className:"!h-3 !w-3"})})]})]},T))}):ee(z,{children:y("No attributes added yet")})]})})});import{get as ul,isEmpty as D1}from"lodash-es";import{Play as _1,Plus as P1,Trash as L1}from"lucide-react";import R1,{useCallback as Ps}from"react";import{useTranslation as M1}from"react-i18next";import{startCase as N1,toLower as E1}from"lodash-es";var pg="|",B1={animation:"slide-up",easing:"linear",duration:"300",delay:"100",time:"once"};function ug(e){if(!e||typeof e!="string")return null;let t=e.split(pg);return t.length!==5?null:{animation:t[0],easing:t[1],duration:t[2],delay:t[3],time:t[4]}}function pl(e){return[e.animation,e.easing,e.duration,e.delay,e.time].join(pg)}function mg(){return pl(B1)}function vn(e){return N1(E1(e.replace(/-/g," ")))}var A1=".chai-animate { animation-fill-mode: both; visibility: visible; }",I1={"fade-in":"@keyframes chai-fade-in { from { opacity: 0; } to { opacity: 1; } } .chai-animate-fade-in { animation-name: chai-fade-in; }","slide-up":"@keyframes chai-slide-up { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } } .chai-animate-slide-up { animation-name: chai-slide-up; }","slide-down":"@keyframes chai-slide-down { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: translateY(0); } } .chai-animate-slide-down { animation-name: chai-slide-down; }","slide-left":"@keyframes chai-slide-left { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } } .chai-animate-slide-left { animation-name: chai-slide-left; }","slide-right":"@keyframes chai-slide-right { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: translateX(0); } } .chai-animate-slide-right { animation-name: chai-slide-right; }","zoom-in":"@keyframes chai-zoom-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } } .chai-animate-zoom-in { animation-name: chai-zoom-in; }","zoom-out":"@keyframes chai-zoom-out { from { opacity: 0; transform: scale(1.1); } to { opacity: 1; transform: scale(1); } } .chai-animate-zoom-out { animation-name: chai-zoom-out; }","flip-x":"@keyframes chai-flip-x { from { opacity: 0; transform: perspective(400px) rotateX(90deg); } to { opacity: 1; transform: perspective(400px) rotateX(0deg); } } .chai-animate-flip-x { animation-name: chai-flip-x; backface-visibility: visible !important; }","flip-y":"@keyframes chai-flip-y { from { opacity: 0; transform: perspective(400px) rotateY(90deg); } to { opacity: 1; transform: perspective(400px) rotateY(0deg); } } .chai-animate-flip-y { animation-name: chai-flip-y; backface-visibility: visible !important; }","rotate-in":"@keyframes chai-rotate-in { from { opacity: 0; transform: rotate(-90deg); } to { opacity: 1; transform: rotate(0); } } .chai-animate-rotate-in { animation-name: chai-rotate-in; }"};function fg(e){let t=I1[e]||"";return`${A1}
|
|
156
|
+
${t}`}import{useAtom as H1}from"jotai";import{jsx as j,jsxs as de}from"react/jsx-runtime";var O1=["fade-in","slide-up","slide-down","slide-left","slide-right","zoom-in","zoom-out","flip-x","flip-y","rotate-in"],F1=["linear","ease-in","ease-out","ease-in-out"],gg=["100","200","300","400","500","600","700","800","900","1000"],ml=R1.memo(()=>{let e=M("flags.animation",!1),t=$(),[o]=K(),r=ze(),{t:n}=M1(),a=`${ul(o,"0.prop")}_attrs`,s=ul(t,a,{}),i=s["data-animation"]||"",l=ug(i),[c]=H1(er),d=Ps(g=>{if(!t)return;let f={...s};g?f["data-animation"]=g:delete f["data-animation"],r([ul(t,"_id")],{[a]:D1(f)?void 0:f})},[t,s,r,a]),p=g=>{if(!l)return;let f={...l,...g};d(pl(f))},h=Ps(()=>{d(mg())},[d]),u=Ps(()=>{d(void 0)},[d]),m=Ps(()=>{var y;if(!t||!l||!c)return;let g=(c==null?void 0:c.contentDocument)||((y=c==null?void 0:c.contentWindow)==null?void 0:y.document);if(!g)return;let f=t._id+"-CHAI_ANIMATION_CSS_ELEMENT";if(!g.getElementById(f)){let k=g.createElement("style");k.id=f,k.innerHTML=fg(l.animation),g.head.appendChild(k)}let b=g.querySelector(`[data-block-id="${t._id}"]`);if(b){b.classList.remove("chai-animate",`chai-animate-${l.animation}`),b.offsetWidth,b.style.animationDuration=`${l.duration}ms`,b.style.animationDelay=`${l.delay}ms`,b.style.animationTimingFunction=l.easing,b.style.animationIterationCount="1";let k=()=>{b.classList.remove("chai-animate",`chai-animate-${l.animation}`),b.style.animationDuration="",b.style.animationDelay="",b.style.animationTimingFunction="",b.style.animationIterationCount="";let v=g.getElementById(f);v&&v.remove()};b.addEventListener("animationend",k,{once:!0}),b.classList.add("chai-animate",`chai-animate-${l.animation}`)}},[t,l,c]);return e?j(pa,{value:"animations-manager",defaultOpen:!1,leftLabel:n("Animations"),rightLabel:g=>l?l&&de("span",{className:"text-[10px] font-light text-muted",children:[vn((l==null?void 0:l.animation)||"")," \u2022 ",vn((l==null?void 0:l.easing)||"")]}):de(D,{variant:"link",size:"xs",onClick:f=>{g&&f.stopPropagation(),h()},children:[j(P1,{className:"!h-2.5 !w-2.5"})," ",n("Add Animation")]}),children:j("div",{children:l?de("div",{className:"relative flex flex-col gap-y-1.5 rounded-md border border-border bg-muted/5 px-2 pb-1 pt-0",children:[de("div",{children:[j(z,{className:"text-[10px] uppercase text-muted-foreground",children:n("Animation")}),de(at,{value:l.animation,onValueChange:g=>p({animation:g}),children:[j(it,{className:"h-7 text-xs",children:j(st,{})}),j(lt,{children:O1.map(g=>j(ct,{value:g,className:"text-xs",children:vn(g)},g))})]})]}),de("div",{children:[j(z,{className:"text-[10px] uppercase text-muted-foreground",children:n("Easing")}),de(at,{value:l.easing,onValueChange:g=>p({easing:g}),children:[j(it,{className:"h-7 text-xs",children:j(st,{})}),j(lt,{children:F1.map(g=>j(ct,{value:g,className:"text-xs",children:vn(g)},g))})]})]}),de("div",{className:"grid grid-cols-2 gap-2",children:[de("div",{children:[j(z,{className:"text-[10px] uppercase text-muted-foreground",children:n("Duration (ms)")}),de(at,{value:l.duration,onValueChange:g=>p({duration:g}),children:[j(it,{className:"h-7 text-xs",children:j(st,{})}),j(lt,{children:gg.map(g=>de(ct,{value:g,className:"text-xs",children:[g," ms"]},g))})]})]}),de("div",{children:[j(z,{className:"text-[10px] uppercase text-muted-foreground",children:n("Delay (ms)")}),de(at,{value:l.delay,onValueChange:g=>p({delay:g}),children:[j(it,{className:"h-7 text-xs",children:j(st,{})}),j(lt,{children:gg.map(g=>de(ct,{value:g,className:"text-xs",children:[g," ms"]},g))})]})]})]}),de("div",{className:"flex items-center justify-between pt-1",children:[de("div",{className:"flex items-center gap-2",children:[de("div",{className:"flex items-center gap-1",children:[j(Gt,{id:"once",checked:l.time!=="infinite",onCheckedChange:g=>p({time:g?"once":"infinite"})}),j(z,{htmlFor:"once",className:"text-xs font-normal",children:n("Once")})]}),de("div",{className:"flex items-center gap-1",children:[j(Gt,{id:"infinite",checked:l.time==="infinite",onCheckedChange:g=>p({time:g?"infinite":"once"})}),j(z,{htmlFor:"infinite",className:"text-xs font-normal",children:n("Infinite")})]})]}),de("div",{className:"flex gap-1",children:[j(vt,{side:"top",className:"max-w-44",content:n("Preview animation"),children:de(D,{variant:"outline",size:"xs",onClick:m,children:[j(_1,{className:"!h-3 !w-3"})," ",n("Play")]})}),j(D,{variant:"outline",size:"icon-xs",className:"hover:bg-destructive hover:text-destructive-foreground",onClick:u,children:j(L1,{className:"!h-3 !w-3"})})]})]})]}):j("div",{className:"py-2 text-center text-xs text-muted-foreground",children:n("No animation added to this element")})})}):null});ml.displayName="BlockAnimationsEditor";import{Fragment as G1,jsx as bg,jsxs as K1}from"react/jsx-runtime";var fl=Ir.memo(()=>{let e=$(),[t,o]=U1([]),[r]=K(),n=ze(),a=`${xn(r,"0.prop")}_attrs`;Ir.useEffect(()=>{let i=z1($1(xn(e,a),["data-animation"]),(l,c)=>({key:c,value:l}));hg(i)?o([]):o(i)},[xn(e,a)]);let s=Ir.useCallback((i=[])=>{if(!e)return;let l={},c=xn(e,a,{})["data-animation"];c&&(l["data-animation"]=c),V1(i,d=>{hg(d.key)||W1(l,d.key,d.value)}),n([xn(e,"_id")],{[a]:l})},[e,n,a]);return K1(G1,{children:[bg(dg,{preloadedAttributes:t,onAttributesChange:s}),bg(ml,{})]})});fl.displayName="BlockAttributesEditor";import{Cross2Icon as j1,DotsVerticalIcon as Z1,ResetIcon as Y1}from"@radix-ui/react-icons";import{isEmpty as X1}from"lodash-es";import{useTranslation as q1}from"react-i18next";import{jsx as Cn,jsxs as Ls}from"react/jsx-runtime";var gl=()=>{let{resetAll:e}=vs(),t=$(),[o]=K(),r=Gc(),{t:n}=q1();return!t||X1(o)?null:Ls(ot,{children:[Cn(rt,{asChild:!0,children:Cn("div",{className:"inline-flex rounded-sm p-0.5 hover:bg-gray-300",onClick:a=>a.stopPropagation(),children:Cn(Z1,{className:"h-3 w-3"})})}),Ls(nt,{side:"bottom",className:"border-border text-xs",children:[Ls(Pe,{className:"flex items-center gap-1 text-xs",onClick:()=>{e()},children:[Cn(Y1,{className:"h-3 w-3"}),n("Reset styles")]}),Ls(Pe,{className:"text-xs",onClick:()=>{t&&r(t,!0)},children:[Cn(j1,{className:"h-3 w-3"}),n("Clear styles")]})]})]})};import{Fragment as rN,jsx as F,jsxs as no}from"react/jsx-runtime";function vg(){let[e]=K();return J1(e)?null:F(fl,{})}var tN=({partialBlockId:e})=>{let{t}=Cg(),o=M("gotoPage",xg),{saveState:r}=$t(),{selectedLang:n,fallbackLang:a}=te(),s=Q1(i=>{if(i.stopPropagation(),r!=="SAVED"){eN.error("You have unsaved changes. Please save the page first.");return}o({pageId:e,lang:n||a})},[r,o,e,n,a]);return F(rN,{children:F("div",{className:"hidden",children:F("div",{onDoubleClick:s,className:"h-full w-full items-center justify-center",children:F("p",{className:"rounded-md px-2 py-1 text-xs",children:t("Partial block. Double click to edit.")})})})})},oN=()=>{let e=$(),{t}=Cg(),o=M("onError",xg),{hasPermission:r}=Ve(),n=!r(be["pages:update"]),a=!r(be["pages:update"]),[s,i]=$n();return e&&e._type==="PartialBlock"?F(tN,{partialBlockId:e.partialBlockId}):e?n&&a?F("div",{className:"p-4 text-center",children:no("div",{className:"space-y-4 rounded-xl p-4 text-muted-foreground",children:[F(yg,{className:"mx-auto text-3xl"}),F("h1",{children:t("You don't have permission to edit settings or styles")}),F("p",{children:t("Please contact your administrator to get access")})]})}):a?F(hl,{fallback:F(go,{}),onError:o,children:no("div",{className:"no-scrollbar h-full max-h-min w-full overflow-y-auto",children:[F(bs,{},e==null?void 0:e._id),F("br",{}),F("br",{})]})}):n?F(hl,{fallback:F(go,{}),onError:o,children:no("div",{className:"no-scrollbar h-full max-h-min w-full overflow-y-auto overflow-x-hidden",children:[F("div",{className:"flex w-full items-center justify-end",children:F(gl,{})}),F(_s,{}),F(vg,{}),F("br",{}),F("br",{}),F("br",{})]})}):F(hl,{fallback:F(go,{}),onError:o,children:no(co,{value:s,onValueChange:d=>{(d==="settings"||d==="styles")&&i(d)},className:"flex flex-1 flex-col",children:[F("div",{className:"flex items-center justify-between",children:no(po,{className:"grid h-auto w-full grid-cols-2",children:[F(ke,{value:"settings",className:"text-xs",children:t("Settings")}),F(ke,{value:"styles",className:"text-xs",children:no("div",{className:"flex w-full items-center justify-between",children:[F("span",{className:"w-[90%] text-center",children:t("Styling")}),F("span",{className:"w-[10%]",children:F(gl,{})})]})})]})}),no(tt,{value:"settings",className:"no-scrollbar h-full max-h-min overflow-y-auto",children:[F(bs,{},e==null?void 0:e._id),F("br",{}),F("br",{})]}),no(tt,{value:"styles",className:"no-scrollbar h-full max-h-min max-w-full overflow-y-auto overflow-x-hidden",children:[F(_s,{}),F(vg,{}),F("br",{}),F("br",{}),F("br",{})]})]})}):F("div",{className:"h-full",children:no("div",{className:"flex h-full flex-col items-center justify-center px-4 text-center text-muted-foreground",children:[F(yg,{className:"mx-auto h-5 w-5"}),F("div",{className:"text-sm font-light",children:t("Please select a block to edit settings or styles")})]})})},kg=oN;import{MixerHorizontalIcon as gN,MoonIcon as hN,ResetIcon as bN,SunIcon as yN,TextIcon as vN}from"@radix-ui/react-icons";import{useDebouncedCallback as Ig}from"@react-hookz/web";import{capitalize as xN,get as Dg,set as _g}from"lodash-es";import*as Ft from"react";import{useTranslation as CN}from"react-i18next";import{toast as Pg}from"sonner";import{useThrottledCallback as nN}from"@react-hookz/web";import{useEffect as aN,useState as sN}from"react";import{jsx as lN}from"react/jsx-runtime";var iN=({value:e,onChange:t,disabled:o})=>{let[r,n]=sN(e);aN(()=>{n(e)},[e]);let a=nN(t,[e],200,!0);return lN(Xc,{min:0,step:1,max:50,disabled:o,value:[Number(r.replace("px",""))||0],onValueChange:s=>{n(s[0].toString()+"px"),a(s[0].toString())},className:"flex-1 cursor-pointer"})},bl=iN;import{debounce as cN}from"lodash-es";import{jsx as wg}from"react/jsx-runtime";var dN=({value:e,onChange:t})=>{let o=cN(r=>t(r),200);return wg("div",{className:"relative flex h-5 w-5 cursor-pointer rounded-md border border-border",style:{backgroundColor:e},children:wg("input",{type:"color",value:e.startsWith("#")?e:"#000000",onChange:r=>{let n=r.target.value;/^#[0-9A-F]{6}$/i.test(n)&&o(n)},className:"absolute inset-0 h-full w-full cursor-pointer rounded-lg border-0 opacity-0"})})},yl=dN;import{startCase as pN}from"lodash-es";import{useEffect as uN}from"react";import{useTranslation as mN}from"react-i18next";import{jsx as kn,jsxs as Sg}from"react/jsx-runtime";var fN=({label:e,value:t,onChange:o})=>{let r=or(),{t:n}=mN();return uN(()=>{r.some(a=>a.family===t)||o(r[0].family)},[t,o,r]),Sg("div",{className:"space-y-0.5",children:[kn(z,{className:"mb-1 block text-xs text-muted-foreground",children:n(pN(e))}),Sg(at,{value:t,onValueChange:o,children:[kn(it,{className:"h-8 w-full text-xs text-foreground",children:kn(st,{placeholder:n("Select font")})}),kn(lt,{children:r.map(a=>kn(ct,{value:a.family,children:a.family},a.family))})]})]})},vl=fN;import{SquareRoundCorner as kN}from"lucide-react";import{lazy as Rg,Suspense as Lg}from"react";var Tg={fontFamily:{heading:"Poppins",body:"Poppins"},borderRadius:"6px",colors:{background:["#ffffff","#0a0a0a"],foreground:["#0a0a0a","#fafafa"],primary:["#171717","#e5e5e5"],"primary-foreground":["#fafafa","#171717"],secondary:["#f5f5f5","#262626"],"secondary-foreground":["#171717","#fafafa"],muted:["#f5f5f5","#262626"],"muted-foreground":["#737373","#a1a1a1"],accent:["#f5f5f5","#404040"],"accent-foreground":["#171717","#fafafa"],destructive:["#e7000b","#ff6467"],"destructive-foreground":["#ffffff","#fafafa"],border:["#e5e5e5","#282828"],input:["#e5e5e5","#343434"],ring:["#a1a1a1","#737373"],card:["#ffffff","#171717"],"card-foreground":["#0a0a0a","#fafafa"],popover:["#ffffff","#262626"],"popover-foreground":["#0a0a0a","#fafafa"]}},Ng={fontFamily:{heading:"Poppins",body:"Poppins"},borderRadius:"4px",colors:{background:["#ffffff","#000000"],foreground:["#0f1419","#e7e9ea"],primary:["#1e9df1","#1c9cf0"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#0f1419","#f0f3f4"],"secondary-foreground":["#ffffff","#0f1419"],muted:["#e5e5e6","#181818"],"muted-foreground":["#0f1419","#72767a"],accent:["#e3ecf6","#061622"],"accent-foreground":["#1e9df1","#1c9cf0"],destructive:["#f4212e","#f4212e"],"destructive-foreground":["#ffffff","#ffffff"],border:["#e1eaef","#242628"],input:["#f7f9fa","#22303c"],ring:["#1da1f2","#1da1f2"],card:["#f7f8f8","#17181c"],"card-foreground":["#0f1419","#d9d9d9"],popover:["#ffffff","#000000"],"popover-foreground":["#0f1419","#e7e9ea"]}},Eg={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"4px",colors:{background:["#fdf6e3","#002b36"],foreground:["#073642","#93a1a1"],primary:["#d33682","#d33682"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#2aa198","#2aa198"],"secondary-foreground":["#ffffff","#ffffff"],muted:["#93a1a1","#586e75"],"muted-foreground":["#073642","#93a1a1"],accent:["#cb4b16","#cb4b16"],"accent-foreground":["#ffffff","#ffffff"],destructive:["#dc322f","#dc322f"],"destructive-foreground":["#ffffff","#ffffff"],border:["#839496","#586e75"],input:["#839496","#586e75"],ring:["#d33682","#d33682"],card:["#eee8d5","#073642"],"card-foreground":["#073642","#93a1a1"],popover:["#eee8d5","#073642"],"popover-foreground":["#073642","#93a1a1"]}};var Bg={fontFamily:{heading:"Poppins",body:"Poppins"},borderRadius:"6px",colors:{background:["#faf9f5","#262624"],foreground:["#3d3929","#c3c0b6"],primary:["#c96442","#d97757"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#e9e6dc","#faf9f5"],"secondary-foreground":["#535146","#30302e"],muted:["#ede9de","#1b1b19"],"muted-foreground":["#83827d","#b7b5a9"],accent:["#e9e6dc","#1a1915"],"accent-foreground":["#28261b","#f5f4ee"],destructive:["#141413","#ef4444"],"destructive-foreground":["#ffffff","#ffffff"],border:["#dad9d4","#3e3e38"],input:["#b4b2a7","#52514a"],ring:["#c96442","#d97757"],card:["#faf9f5","#262624"],"card-foreground":["#141413","#faf9f5"],popover:["#ffffff","#30302e"],"popover-foreground":["#28261b","#e5e5e2"]}},Ag={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"6px",colors:{background:["#fff9f5","#2a2024"],foreground:["#3d3436","#f2e9e4"],primary:["#ff7e5f","#ff7e5f"],"primary-foreground":["#ffffff","#ffffff"],secondary:["#ffedea","#463a41"],"secondary-foreground":["#b35340","#f2e9e4"],muted:["#fff0eb","#392f35"],"muted-foreground":["#78716c","#d7c6bc"],accent:["#feb47b","#feb47b"],"accent-foreground":["#3d3436","#2a2024"],destructive:["#e63946","#e63946"],"destructive-foreground":["#ffffff","#ffffff"],border:["#ffe0d6","#463a41"],input:["#ffe0d6","#463a41"],ring:["#ff7e5f","#ff7e5f"],card:["#ffffff","#392f35"],"card-foreground":["#3d3436","#f2e9e4"],popover:["#ffffff","#392f35"],"popover-foreground":["#3d3436","#f2e9e4"]}};import{Fragment as BN,jsx as H,jsxs as ue}from"react/jsx-runtime";var wN=Rg(()=>import("./css-import-modal-NMFRQGCY.js").then(e=>({default:e.CssImportModal}))),SN=Rg(()=>import("./ai-theme-generator-7PS4BX52.js").then(e=>({default:e.AiThemeGenerator}))),Mg="chai-builder-previous-theme",TN=[{shadcn_default:Tg},{twitter_theme:Ng},{solarized_theme:Eg},{claude_theme:Bg},{supabase_theme:Ag}],NN=e=>{if(typeof window!="undefined")try{localStorage.setItem(Mg,JSON.stringify(e))}catch(t){console.warn("Failed to save previous theme to localStorage:",t)}},EN=()=>{if(typeof window!="undefined")try{localStorage.removeItem(Mg)}catch(e){console.warn("Failed to clear previous theme from localStorage:",e)}},Hg=Ft.memo(({className:e=""})=>{let[t,o]=_t(),[r,n]=Ft.useState(""),[a,s]=Ft.useState(!1),i=M("themePresets",{}),{hasPermission:l}=Ve(),{debouncedSaveTheme:c}=Yc(),d=M("flags.importTheme",!0),p=M("flags.darkMode",!1),h=or(),u=M("flags.ai",!1);(!i||i.length===0)&&TN.map(T=>{i.push(T)});let[m,g]=Rr(),f=zn(),{t:b}=CN(),y=Ft.useCallback(T=>{let C={...m};NN(C),g(T),c(),Pg.success("Theme updated",{action:{label:ue("span",{className:"flex items-center gap-2",children:[H(bN,{className:"h-4 w-4"})," Undo"]}),onClick:()=>{g(C),EN(),Pg.dismiss()}},closeButton:!0,duration:15e3})},[m,g,c]),k=()=>{let T=i.find(A=>Object.keys(A)[0]===r);if(!T){console.error("Preset not found:",r);return}let C=Object.values(T)[0];C&&typeof C=="object"&&"fontFamily"in C&&"borderRadius"in C&&"colors"in C?(y(C),n("")):console.error("Invalid preset structure:",C)},v=T=>{y(T),n("")},S=Ft.useCallback(T=>{y(T),n("")},[y]),E=Ig((T,C)=>{g(()=>({...m,fontFamily:{...m.fontFamily,[T.replace(/font-/g,"")]:C}})),c()},[m,c],200),x=Ft.useCallback(T=>{let C=T===""?"0":T,w=parseInt(C);isNaN(w)||w<0||w>50?C="0":C=w.toString(),g(A=>({...A,borderRadius:`${C}px`})),c()},[g,c]),B=Ft.useCallback(T=>{g(C=>({...C,borderRadius:`${T}px`})),c()},[g,c]),I=Ig((T,C)=>{g(()=>{let w=Dg(m,`colors.${T}`);return t?_g(w,1,C):_g(w,0,C),{...m,colors:{...m.colors,[T]:w}}}),c()},[m,c],200),N=T=>H("div",{className:"grid grid-cols-1",children:Object.entries(T.items).map(([C])=>{let w=Dg(m,`colors.${C}.${t?1:0}`);return w?ue("div",{id:`theme-${C}`,className:"flex items-center gap-x-2 py-0.5",children:[H(yl,{value:w,onChange:A=>I(C,A)}),H(z,{className:"text-xs font-light leading-tight text-foreground",children:C.split(/(?=[A-Z])/).join(" ").replace(/-/g," ").split(" ").map(A=>A.charAt(0).toUpperCase()+A.slice(1)).join(" ")+(!C.toLowerCase().includes("foreground")&&!C.toLowerCase().includes("border")&&!C.toLowerCase().includes("input")&&!C.toLowerCase().includes("ring")&&!C.toLowerCase().includes("background")?" Background":"")})]},C):null})});return l(be["theme:edit"])?H("div",{className:"relative w-full",children:ue("div",{className:zt("no-scrollbar h-full w-full overflow-y-auto",e),children:[i.length>0&&ue("div",{className:"space-y-2 py-2",children:[ue("div",{className:"flex w-full items-center justify-between",children:[H(z,{className:"text-xs font-medium text-foreground",children:b("Presets")}),ue("div",{className:"flex items-center gap-1",children:[d&&H(D,{variant:"link",size:"xs",onClick:()=>s(!0),children:b("Import theme")}),u&&H(Lg,{fallback:H("div",{className:"h-6 animate-pulse rounded-md bg-muted/20"}),children:H(SN,{onThemeGenerated:S})})]})]}),ue("div",{className:"flex items-center gap-2",children:[ue(at,{value:r,onValueChange:n,children:[H(it,{className:"h-8 flex-1 text-xs",children:H(st,{placeholder:b("Select preset")})}),H(lt,{children:Array.isArray(i)&&i.map(T=>{let C=Object.keys(T)[0],w=C.replaceAll("_"," ");return H(ct,{value:C,className:"text-xs",children:xN(w)},C)})})]}),H(D,{size:"sm",disabled:!r,onClick:k,children:b("Apply")})]})]}),H(ta,{}),ue("div",{className:zt("space-y-3 py-2",e),children:[h.length>0?ue(BN,{children:[ue("div",{className:"flex items-center gap-2 pt-1",children:[H(vN,{className:"h-3.5 w-3.5 text-muted-foreground"}),H("span",{className:"text-xs font-medium text-foreground",children:b("Typography")})]}),(f==null?void 0:f.fontFamily)&&H("div",{className:"space-y-2",children:Object.entries(f.fontFamily).map(([T,C])=>H(vl,{label:T,value:m.fontFamily[T.replace(/font-/g,"")]||C[Object.keys(C)[0]],onChange:w=>E(T,w)},T))}),H(ta,{})]}):"",(f==null?void 0:f.borderRadius)&&ue("div",{className:"space-y-2",children:[ue("div",{className:"flex items-center justify-between",children:[ue("div",{className:"flex items-center gap-2",children:[H(kN,{className:"h-3.5 w-3.5 text-muted-foreground"}),H("span",{className:"text-xs font-medium text-foreground",children:b("Border Radius")})]}),ue("div",{className:"relative flex items-center",children:[H(oe,{type:"number",min:0,max:50,className:"h-6 w-14 rounded-sm border-input bg-muted/20 pr-5 text-right text-[10px] font-light [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",value:m.borderRadius.replace("px",""),onChange:T=>x(T.target.value)}),H("span",{className:"pointer-events-none absolute right-1 text-[10px] font-light text-foreground",children:"px"})]})]}),H("div",{className:"py-1",children:H(bl,{value:m.borderRadius,onChange:B})})]}),H(ta,{}),(f==null?void 0:f.colors)&&ue("div",{className:"space-y-3",children:[ue("div",{className:"flex items-center justify-between",children:[ue("div",{className:"flex items-center gap-2",children:[H(gN,{className:"h-3.5 w-3.5 text-muted-foreground"}),H("span",{className:"text-xs font-medium text-foreground",children:b("Colors")})]}),p&&ue("div",{className:"flex items-center gap-1.5",children:[H(yN,{className:"h-3.5 w-3.5 text-muted-foreground"}),H(At,{checked:t,onCheckedChange:T=>o(T),"aria-label":b("Toggle dark mode")}),H(hN,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]}),H("div",{className:"space-y-1.5",children:f.colors.map(T=>H("div",{children:N(T)},T.group))})]}),H(Lg,{fallback:H("div",{}),children:a&&d&&H(wN,{open:a,onOpenChange:s,onImport:v})})]}),H("br",{}),H("br",{}),H("br",{}),H("br",{})]})}):H("div",{className:"relative w-full",children:H("div",{className:zt("no-scrollbar flex h-full w-full items-center justify-center overflow-y-auto text-center",e),children:H("div",{className:"space-y-2 px-4 text-muted-foreground",children:H("p",{className:"text-xs font-light leading-relaxed",children:b("You don't have permission to edit the theme. Please contact your administrator to get access.")})})})})});Hg.displayName="ThemeConfigPanel";var Og=Hg;import{Fragment as LN,jsx as P,jsxs as xe}from"react/jsx-runtime";var PN=_r.lazy(()=>import("./manage-design-tokens-264H25A2.js")),Tn=280,Wg=()=>{var C;let[e,t]=nr(),[o,r]=Cl("outline"),[n,a]=Cl(!1),[s,i]=Cl(!1),[l,c]=ic(),[,d]=$n(),p=Fs("top"),h=Fs("bottom"),u=DN([...h!=null?h:[]]),m=wn(w=>{td()||w.preventDefault()},[]),g=Sn(()=>[p].flat(),[p]),{t:f}=_N(),b=Sn(()=>[...p,...h],[p,h]),y=M("htmlDir","ltr"),k=(C=Dr(b,{id:e}))!=null?C:IN(b),v=q(k,"width",Tn);$g(()=>{let w=Dr(b,{id:e}),A=w&&q(w,"view","standard")==="standard";e!==null&&A&&r(e)},[e,b]);let S=Sn(()=>{if(o){let w=Dr(b,{id:o});if(w)return q(w,"width",Tn)}return Tn},[o,b]),E=Sn(()=>{if(e===null||n)return 0;let w=Dr(b,{id:e}),A=q(w,"view","standard")==="standard",_=q(w,"width",Tn);return A?_:S},[e,S,b,n]),x=Sn(()=>s||e==="ai"?0:Tn,[s,e]),B=wn(w=>{if(q(Dr(b,{id:w}),"view","standard")==="standard")if(e===w){a(_=>!_);return}else n&&a(!1);t(e===w?null:w)},[b,e,t,n]),I=wn(()=>{t(o!=null?o:"outline")},[t,o]),N=wn(()=>{t("outline")},[t]);$g(()=>{e!==null&&!Dr(b,{id:e})&&t("outline");let w;return Nc()&&e!=="chai-chat-panel"&&(w=setTimeout(()=>t("chai-chat-panel"),1e3)),()=>{w!==void 0&&clearTimeout(w)}},[e,b,t]);let T=wn(w=>{B(w)},[B]);return P("div",{dir:y,className:"bg-surface h-screen max-h-full w-screen overflow-x-hidden text-foreground",children:xe(Tl,{children:[xe("div",{onContextMenu:m,className:"flex h-full max-h-full flex-col",children:[P("div",{className:"flex h-max w-screen items-center border-b",children:P(jo,{children:P(lo,{slotId:io.TOP_BAR,multiple:!1,defaultComponent:null})})}),xe("main",{className:"relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row",children:[xe("div",{id:"sidebar",className:"flex w-10 flex-col items-center justify-between bg-background py-1.5",children:[P("div",{className:"flex flex-col justify-between gap-y-0.5",children:g.map((w,A)=>P(vt,{content:f(w.label),side:"right",children:P("div",{id:"panel-btn-"+w.id,children:zg(q(w,"button",Oo),{position:"top",panelId:w.id,isActive:e===w.id,show:()=>T(w.id)})})},"button-top-"+A))}),P("div",{className:"flex flex-col space-y-0.5"}),P("div",{className:"flex flex-col",children:u==null?void 0:u.map((w,A)=>P(vt,{content:f(w.label),side:"right",children:P("div",{id:"panel-btn-"+w.id,children:zg(q(w,"button",Oo),{position:"bottom",panelId:w.id,isActive:e===w.id,show:()=>T(w.id)})})},"button-bottom-"+A))})]}),xe(Rs.div,{id:"left-panel",className:`relative h-full max-h-full ${n?"border-l":"border-l dark:border-none"}`,initial:{width:E},animate:{width:E},transition:{duration:.3,ease:"easeInOut"},children:[e!==null&&q(k,"view","standard")==="standard"&&!n&&xe("div",{className:"no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2",children:[q(k,"label","")!==""?P("div",{className:`absolute top-2 flex h-8 items-center space-x-1 text-sm font-medium uppercase ${q(k,"isInternal",!1)?"":"w-64 max-w-64 truncate"}`,children:P("span",{children:f(q(k,"label",""))})}):null,P("div",{className:"no-scrollbar h-full max-h-full overflow-y-auto "+(q(k,"label","")!==""?"pt-10":""),children:P(jo,{fallback:P("div",{className:"h-full w-full animate-pulse rounded-md bg-muted/10"}),children:_r.createElement(q(k,"panel",Oo),{})})})]}),e!==null&&P(vt,{content:f(n?"Expand":"Collapse"),side:"right",children:P(D,{variant:"ghost",size:"icon",className:`absolute -right-4 top-10 z-10 h-7 w-4 rounded-none rounded-r-md border-none p-0 hover:bg-accent ${n?"bg-orange hover:bg-orange/80":"bg-surface"}`,onClick:()=>a(w=>!w),children:n?P(Vg,{className:"h-4 w-4"}):P(Fg,{className:"h-4 w-4"})})})]}),P("div",{id:"canvas-container",className:"flex h-full max-h-full flex-1 flex-col",children:P(jo,{children:P(Zu,{})})}),xe(Rs.div,{id:"right-panel",className:`relative h-full max-h-full ${s?"border-r":""}`,initial:{width:x},animate:{width:x},transition:{duration:.3,ease:"easeInOut"},children:[P(vt,{content:f(s?"Expand":"Collapse"),side:"left",children:P(D,{variant:"ghost",size:"icon",className:`absolute -left-4 top-10 z-10 h-7 w-4 rounded-none rounded-l-md border-none p-0 hover:bg-accent ${s?"bg-orange hover:bg-orange/80":"bg-surface"}`,onClick:()=>i(w=>!w),children:s?P(Fg,{className:"h-4 w-4"}):P(Vg,{className:"h-4 w-4"})})}),P("div",{className:"no-scrollbar overflow h-full max-h-full overflow-hidden",children:xe("div",{className:"flex h-full max-h-full flex-col overflow-hidden p-3",children:[P("h2",{className:"-mt-1 flex items-center space-x-1 text-base font-bold",children:P("div",{className:"flex grow items-center gap-2",children:P("div",{className:"flex w-full items-center justify-between gap-2",children:l==="ai"?P(LN,{children:xe("div",{className:"flex items-center gap-2",children:[P(AN,{className:"rtl:ml-2"})," ",f("AI Assistant")]})}):l==="design-tokens"?xe("div",{className:"flex w-full items-center justify-between gap-2",children:[P("div",{className:"flex h-8 items-center space-x-1 truncate text-sm font-medium uppercase",children:f("Design Tokens")}),P(D,{onClick:()=>{d("styles"),c("block")},variant:"ghost",size:"icon-xs",className:"text-xs",children:P(xl,{className:"h-3 w-3 rtl:ml-2"})})]}):l==="theme"?xe("div",{className:"flex w-full items-center justify-between gap-2",children:[P("div",{className:"flex h-8 items-center space-x-1 truncate text-sm font-medium uppercase",children:f("Theme Settings")}),P(D,{onClick:()=>c("block"),variant:"ghost",size:"icon-xs",className:"text-xs",children:P(xl,{className:"h-3 w-3 rtl:ml-2"})})]}):null})})}),P("div",{className:"flex h-full max-h-full w-full",children:P(jo,{fallback:P("div",{className:"h-full w-full animate-pulse rounded-md bg-muted/10"}),children:l==="design-tokens"?P(_r.Suspense,{fallback:P("div",{className:"h-1/2 w-full animate-pulse"}),children:P(PN,{})}):l==="theme"?P(Og,{}):P(kg,{})})})]})})]})]})]}),P(Nm,{}),e!==null&&q(k,"view")==="drawer"&&P(qc,{open:!0,onOpenChange:()=>I(),children:xe(Jc,{side:"left",className:"flex flex-col gap-0 p-0 sm:max-w-full",style:{width:`${v}px`},children:[P(Qc,{className:"border-b border-border px-2 py-2.5",children:xe(ed,{className:"flex items-center gap-2",children:[P("span",{className:"inline-block",children:q(k,"icon",null)}),P("span",{children:f(q(k,"label",""))})]})}),P("div",{className:"h-full max-h-full overflow-y-auto p-4",children:P(jo,{fallback:P("div",{}),children:_r.createElement(q(k,"panel",Oo),{close:N})})})]})})," ",e!==null&&q(k,"view")==="modal"&&P(qo,{open:!0,onOpenChange:()=>I(),children:xe(Jo,{className:"gap-0 p-0",style:{maxWidth:`${v}px`},children:[P(Bn,{className:"border-b border-border px-2 py-3.5",children:xe(Qo,{className:"flex items-center gap-2",children:[P("span",{className:"inline-block",children:q(k,"icon",null)}),P("span",{children:f(q(k,"label",""))})]})}),P("div",{className:"max-h-[70vh] overflow-y-auto p-4",children:P(jo,{fallback:P("div",{}),children:_r.createElement(q(k,"panel",Oo),{close:N})})})]})}),e!==null&&q(k,"view")==="overlay"&&P(Rs.div,{className:"absolute bottom-0 left-12 right-0 top-0 z-50",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:P("div",{className:"h-full w-full",children:xe(Rs.div,{className:"bg-surface flex h-full w-full flex-col",initial:{y:-20,opacity:0},animate:{y:0,opacity:1},exit:{y:20,opacity:0},transition:{duration:.3,delay:.1},children:[xe("div",{className:"flex h-[50px] items-center justify-between border-b border-border p-4",children:[xe("div",{className:"-ml-2 flex items-center gap-2 text-lg font-bold",children:[P("span",{className:"rtl:ml-2 rtl:inline-block",children:q(k,"icon",null)}),P("span",{children:f(q(k,"label",""))})]}),P(D,{onClick:()=>I(),variant:"ghost",size:"icon",className:"",children:P(xl,{className:"h-5 w-5"})})]}),P("div",{className:"flex-1 overflow-y-auto p-4",children:P(jo,{fallback:P("div",{}),children:_r.createElement(q(k,"panel",Oo),{close:N})})})]})})})]})})};import{Fragment as UN,jsx as Bt,jsxs as Ug}from"react/jsx-runtime";var zN=e=>{let[,t]=Ce(),o=xd(),[r]=kl(Wl);kl(_n),xa(),wd(),bd(),Ul(),$l(),Kl();let{postMessage:n}=Gl(),[,a]=kl(Rn),s=zl();return Bo(()=>{L.set(ec,HN(e,["blocks","translations","pageExternalData","globalStyles"]))},[e]),Bo(()=>{L.set(tc,e.pageExternalData||{})},[e.pageExternalData]),Bo(()=>{L.set(oc,e.designTokens||{})},[e.designTokens]),Bo(()=>{a(!1),setTimeout(()=>{let i=ao(e.blocks||[]);t(i),i&&i.length>0&&n({type:"blocks-updated",blocks:i}),o(),a(!0),s()},400)},[e.blocks]),Bo(()=>{ma.changeLanguage(e.locale||"en")},[e.locale]),Bo(()=>{var i;cd((i=e.debugLogs)!=null?i:!1)},[e.debugLogs]),Bo(()=>{e.translations&&RN(e.translations,(i,l)=>{ma.addResourceBundle(l,"translation",i,!0,!0)})},[e.translations]),Bo(()=>(r!=="SAVED"?window.onbeforeunload=()=>"":window.onbeforeunload=null,()=>{window.onbeforeunload=null}),[r]),null},$N=e=>{let t=ON(()=>e.layout||Wg,[e.layout]),o=M("flags.exportCode",!1);return Ug(UN,{children:[e.children,Bt(t,{}),o&&Bt(ud,{}),Bt(lo,{slotId:io.AFTER_BUILDER})]})},WN=e=>{let t=e.onError||MN;return Bt("div",{className:"h-screen w-screen",children:Ug(FN,{fallback:Bt(go,{}),onError:t,children:[Bt(md,{}),Bt($N,{...e}),Bt(zN,{...e}),Bt(id,{}),Bt(VN,{richColors:!0}),Bt(ld,{})]})})};import{useTranslation as dU}from"react-i18next";import{each as L7,filter as R7,find as M7,pick as H7,startsWith as O7}from"lodash-es";import{useCallback as V7}from"react";import{find as GN}from"lodash-es";import{useCallback as KN}from"react";var Gg=(e,t)=>{let o=e.filter(a=>a._parent===t),r=o.map(a=>a._id),n=o.flatMap(a=>Gg(e,a._id));return[...r,...n]},jN=(e,t,o)=>{let r=GN(e,{_id:t});if(!r)return e;let n=e.findIndex(p=>p._id===t),a=Gg(e,t),s=new Set([t,...a]),i=e.filter(p=>!s.has(p._id)),l=new Set(o.map(p=>p._id)),c=o.map(p=>!p._parent||!l.has(p._parent)?{...p,_parent:r._parent}:p);return[...i.slice(0,n),...c,...i.slice(n)]},ZN=()=>{let[,e]=W(),{setNewBlocks:t}=ye(),{hasPermission:o}=Ve();return KN((r,n)=>{if(!o(be["pages:update"]))return;let a=L.get(he),s=r?jN(a,r,n):n;t(s),n.length>0&&setTimeout(()=>e([n[0]._id]),200)},[e,t,o])};import{useMutation as wl,useQueryClient as Sl}from"@tanstack/react-query";import{toast as Pr}from"sonner";var TU=()=>{let e=Wt(),t=Sl(),o=Ut();return wl({mutationFn:async r=>{let n=r.map(async s=>o(e,{action:Ae.CREATE_ASSET,data:s}));return await Promise.all(n)},onSuccess:r=>{var n;if(r!=null&&r.some(a=>a.error))throw new Error(((n=r==null?void 0:r.find(a=>a.error))==null?void 0:n.error)||"Failed to upload asset");{t.invalidateQueries({queryKey:[Ae.GET_ASSETS]});let a=r==null?void 0:r.length;Pr.success(`${a===1?"Asset":a+" Assets"} uploaded successfully`)}},onError:()=>{Pr.error("Failed to upload asset")}})},NU=()=>{let e=Wt(),t=Sl(),o=Ut(),r=nc("flags",{});return wl({mutationFn:async n=>{let a=Array.isArray(n)?n:[n],s=r!=null&&r.trash?Ae.TRASH_ENTITY:Ae.DELETE_ASSET,i=r!=null&&r.trash?{entityType:"asset",ids:a}:{ids:a};return o(e,{action:s,data:i})},onSuccess:(n,a)=>{if(n!=null&&n.error)throw new Error(n==null?void 0:n.error);{let s=Array.isArray(a)&&a.length>1;t.invalidateQueries({queryKey:[Ae.GET_ASSETS]}),Pr.success((s?"Assets":"Asset")+" "+(r!=null&&r.trash?"moved to trash":"deleted successfully"))}},onError:()=>{Pr.error("Failed to delete asset")}})},EU=()=>{let e=Wt(),t=Sl(),o=Ut();return wl({mutationFn:async r=>o(e,{action:Ae.UPDATE_ASSET,data:r}),onSuccess:r=>{if(r!=null&&r.error)throw new Error(r==null?void 0:r.error);t.invalidateQueries({queryKey:[Ae.GET_ASSETS]}),r!=null&&r.id&&t.invalidateQueries({queryKey:[Ae.GET_ASSET,r.id]}),Pr.success("Asset updated successfully")},onError:()=>{Pr.error("Failed to update asset")}})};import{useQuery as Kg}from"@tanstack/react-query";var LU=(e={})=>{let t=Wt(),o=Ut(),{search:r,page:n=1,limit:a=30}=e;return Kg({queryKey:[Ae.GET_ASSETS,r,n,a],queryFn:async()=>{let s=await o(t,{action:Ae.GET_ASSETS,data:{search:r,page:n,limit:a}});return s.page=n,s.limit=a,s},staleTime:1/0,retry:1})},RU=e=>{let t=Wt(),o=Ut();return Kg({queryKey:[Ae.GET_ASSET,e],queryFn:async()=>e?await o(t,{action:Ae.GET_ASSET,data:{id:e}}):null,staleTime:1/0,retry:1})};export{U as a,Ws as b,J as c,Ie as d,ya as e,Bd as f,va as g,Le as h,_d as i,Re as j,ZN as k,pe as l,Uu as m,Oi as n,wm as o,vr as p,WN as q,eh as r,dU as s,TU as t,NU as u,EU as v,LU as w,RU as x};
|