@panphora/clayjs 1.23.0 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +1 -1
- package/dist/blockeditor/themes/light-1.css +431 -0
- package/dist/clay-dom.js +1 -1
- package/dist/clay-events.js +1 -1
- package/dist/clay-internals.js +1 -1
- package/dist/clay-options.js +1 -1
- package/dist/clay-router.js +1 -1
- package/dist/clay-ui.js +1 -1
- package/dist/clay-utils.js +1 -1
- package/dist/clay.js +1 -1
- package/dist/clay.standalone.js +30285 -26613
- package/dist/m/c-277QP5ET.js +1 -0
- package/dist/m/c-2BLVA6IN.js +5 -0
- package/dist/m/c-2OJMOUPC.js +1 -0
- package/dist/m/c-2PVGJFI5.js +1 -0
- package/dist/m/{c-AYVGD6A6.js → c-3UW5EJ77.js} +1 -1
- package/dist/m/{c-T5NK2TVY.js → c-42ZNV7LI.js} +1 -1
- package/dist/m/{c-3TLG3OLG.js → c-46LJAZZJ.js} +1 -1
- package/dist/m/c-47IBJGPQ.js +1 -0
- package/dist/m/c-5FXEKU4Y.js +1 -0
- package/dist/m/c-5KXDKC5G.js +1 -0
- package/dist/m/{c-EUGJVHDD.js → c-5RZNFTWD.js} +1 -1
- package/dist/m/c-65LJU2H2.js +72 -0
- package/dist/m/{c-NQJRVJ56.js → c-6IJEVE6B.js} +1 -1
- package/dist/m/{c-NW54NHKE.js → c-6LEYVQJK.js} +1 -1
- package/dist/m/{c-GSRLXYWL.js → c-6Q6RGFBF.js} +1 -1
- package/dist/m/c-6RGEQNVV.js +1 -0
- package/dist/m/c-7CM4GMTS.js +6 -0
- package/dist/m/c-7NCWENHV.js +1 -0
- package/dist/m/c-7V6MGMX2.js +1 -0
- package/dist/m/{c-LKSL4AUJ.js → c-7WZSUTYP.js} +1 -1
- package/dist/m/c-A4L7APIU.js +1 -0
- package/dist/m/c-APGHGDZM.js +1 -0
- package/dist/m/c-AT7GLQGV.js +34 -0
- package/dist/m/{c-ZRXJD4G6.js → c-B7GOFGQR.js} +1 -1
- package/dist/m/{c-KDXIJEEF.js → c-BGN7RCTJ.js} +1 -1
- package/dist/m/c-BKM46LUJ.js +1 -0
- package/dist/m/c-BOMQIQ3V.js +1 -0
- package/dist/m/{c-62HZW5DH.js → c-C5AKJVRH.js} +1 -1
- package/dist/m/{c-BXYSDKAN.js → c-CJ7QYEWI.js} +1 -1
- package/dist/m/c-CTGRDT6E.js +1 -0
- package/dist/m/c-CV4T65JE.js +6 -0
- package/dist/m/c-CVSWLX3X.js +1 -0
- package/dist/m/c-CZHTXGJS.js +1 -0
- package/dist/m/c-D7NT5S4F.js +1 -0
- package/dist/m/c-DD26VXAP.js +1 -0
- package/dist/m/{c-ANNFZFLN.js → c-DDS23EY6.js} +1 -1
- package/dist/m/{c-ALDVFPWL.js → c-DFKBGSN2.js} +1 -1
- package/dist/m/c-DIKR7H57.js +147 -0
- package/dist/m/c-DXPOFLEJ.js +1 -0
- package/dist/m/c-EDE45NM7.js +1 -0
- package/dist/m/c-EILLN2H2.js +1 -0
- package/dist/m/c-EODTTNVA.js +1 -0
- package/dist/m/{c-G6COVIZB.js → c-ESK4S67I.js} +1 -1
- package/dist/m/c-FDWR3FL7.js +1 -0
- package/dist/m/{c-WQZTI5P2.js → c-FEC6LGFF.js} +1 -1
- package/dist/m/c-FLEIU6CG.js +1 -0
- package/dist/m/c-FQAQRXGK.js +1 -0
- package/dist/m/{c-W4JCVLAB.js → c-FSQXFG5T.js} +1 -1
- package/dist/m/c-FVPNX2GO.js +135 -0
- package/dist/m/c-FYDKYW6E.js +1 -0
- package/dist/m/c-GNI7WHKF.js +32 -0
- package/dist/m/c-GO635CRU.js +3 -0
- package/dist/m/c-H3FNLBHN.js +2 -0
- package/dist/m/c-HDVH3MVC.js +72 -0
- package/dist/m/c-HIX5H5L7.js +1 -0
- package/dist/m/c-HKSLOVU4.js +1 -0
- package/dist/m/{c-SGRIYOAJ.js → c-HL6BLJNA.js} +1 -1
- package/dist/m/c-HTLYXCUH.js +1 -0
- package/dist/m/{c-QIR5CAKM.js → c-IUL7PU4P.js} +1 -1
- package/dist/m/c-IXO7EI2Q.js +1 -0
- package/dist/m/{c-W5E5P2TZ.js → c-JQF2EUCG.js} +1 -1
- package/dist/m/{c-NEL7HQW3.js → c-JWDCQL6J.js} +1 -1
- package/dist/m/c-KQKKIVLW.js +20 -0
- package/dist/m/c-LATNQ6Q5.js +1 -0
- package/dist/m/c-LD6UVV5R.js +1 -0
- package/dist/m/c-LS7IVQVW.js +1 -0
- package/dist/m/{c-JCOQVZYS.js → c-LSVN3OLG.js} +1 -1
- package/dist/m/{c-JDZDF2QM.js → c-LTSPHVAK.js} +1 -1
- package/dist/m/c-MFOSMAVM.js +3 -0
- package/dist/m/c-MJ7GVE46.js +1 -0
- package/dist/m/c-MP6S4AZU.js +6 -0
- package/dist/m/c-MQKSKQHG.js +2 -0
- package/dist/m/{c-UHUNXWKN.js → c-MQYEDF3Q.js} +1 -1
- package/dist/m/{c-IHUWUKIU.js → c-MR75YPRT.js} +1 -1
- package/dist/m/c-ND3Q2G2I.js +1 -0
- package/dist/m/c-NEQRFC4O.js +1 -0
- package/dist/m/{c-5FKRZNJV.js → c-NFQFV7OP.js} +1 -1
- package/dist/m/c-NHXOBD6A.js +1 -0
- package/dist/m/{c-QIKT6SKM.js → c-NICICT4P.js} +1 -1
- package/dist/m/c-NQAPWM7O.js +1 -0
- package/dist/m/{c-QUGCKMWF.js → c-NVU3DORS.js} +1 -1
- package/dist/m/{c-LWIDDWAR.js → c-OCYG4NBQ.js} +22 -22
- package/dist/m/c-OH2FPYSY.js +19 -0
- package/dist/m/c-OYHI67B6.js +1 -0
- package/dist/m/{c-R2XUODVY.js → c-OYW5MFPZ.js} +1 -1
- package/dist/m/{c-5B4YBZXC.js → c-P2HKMJAW.js} +1 -1
- package/dist/m/{c-TSBVMWAH.js → c-PCNJETUA.js} +1 -1
- package/dist/m/c-PDBNCJCT.js +1 -0
- package/dist/m/c-PGSBXHUE.js +1 -0
- package/dist/m/{c-5TIZ2I64.js → c-PYG2NGWU.js} +1 -1
- package/dist/m/c-Q26XHBLQ.js +1 -0
- package/dist/m/c-Q6BG3ZLO.js +1 -0
- package/dist/m/c-QENKN7QI.js +1 -0
- package/dist/m/c-QQFHEODI.js +1 -0
- package/dist/m/c-QTEUO2K6.js +1 -0
- package/dist/m/c-R23UHMXG.js +1 -0
- package/dist/m/c-RETTCOWO.js +10 -0
- package/dist/m/c-SE3SIY7Y.js +7 -0
- package/dist/m/{c-XX75FFNL.js → c-SGGGCIVD.js} +1 -1
- package/dist/m/c-SGH3UTF3.js +1 -0
- package/dist/m/c-SIM7Z3U7.js +1 -0
- package/dist/m/{c-X5LNHET5.js → c-SKMIR5HQ.js} +1 -1
- package/dist/m/{c-R27DWQKX.js → c-STRI73GQ.js} +1 -1
- package/dist/m/c-SUXHUL7U.js +1 -0
- package/dist/m/c-SXGEWPFC.js +10 -0
- package/dist/m/c-SXNSSHPP.js +1 -0
- package/dist/m/c-T3P3AXEW.js +1 -0
- package/dist/m/{c-PXLTUYZC.js → c-TFLRT5JX.js} +1 -1
- package/dist/m/{c-YCLU4UNT.js → c-TGIMBAWE.js} +1 -1
- package/dist/m/c-TGSHHFO6.js +1 -0
- package/dist/m/c-U4NTUVDZ.js +1 -0
- package/dist/m/c-UOOIF2AL.js +1 -0
- package/dist/m/{c-6TYGD5AB.js → c-UOUUI265.js} +1 -1
- package/dist/m/c-V2U3F4QX.js +1 -0
- package/dist/m/c-V2V5FKXX.js +1 -0
- package/dist/m/c-VBXRXTVS.js +26 -0
- package/dist/m/c-VHSMPITY.js +1 -0
- package/dist/m/c-VPXCXBDT.js +1 -0
- package/dist/m/c-WCG6AKA7.js +1 -0
- package/dist/m/c-WNOLMHI2.js +1 -0
- package/dist/m/{c-CRPIDGXC.js → c-X6MOYATI.js} +1 -1
- package/dist/m/{c-FQGHR32O.js → c-X75G43SZ.js} +1 -1
- package/dist/m/c-XB6EAIAR.js +13 -0
- package/dist/m/c-XMIDHEKF.js +1 -0
- package/dist/m/c-XUZMRQ7O.js +4 -0
- package/dist/m/{c-2Z22FCFK.js → c-XW5TIYYB.js} +1 -1
- package/dist/m/c-YDW4VCHP.js +1 -0
- package/dist/m/{c-QGAPG7OM.js → c-YLHTD3KX.js} +1 -1
- package/dist/m/c-YNIEIPBS.js +1 -0
- package/dist/m/c-Z4G2UK6T.js +4 -0
- package/dist/m/c-Z6MROEQ4.js +1 -0
- package/dist/m/c-ZFO5RW6G.js +2 -0
- package/dist/m/c-ZGCO4J3H.js +8 -0
- package/dist/m/c-ZKKAF4UT.js +3 -0
- package/dist/m/c-ZRGEN6QQ.js +4 -0
- package/dist/m/core/{admin-attrs-U7IJNYBG.js → admin-attrs-ONRWVXPK.js} +1 -1
- package/dist/m/core/{autosave-F5YQCKVL.js → autosave-TBKAAAFB.js} +1 -1
- package/dist/m/core/conflict-notice-FOEE6I7E.js +1 -0
- package/dist/m/core/draft-mode-4MCL3LYI.js +1 -0
- package/dist/m/core/{host-permission-6EVJGNPL.js → host-permission-X4BENZEU.js} +1 -1
- package/dist/m/core/{is-edit-mode-GCX6767E.js → is-edit-mode-FFHCQ5DR.js} +1 -1
- package/dist/m/core/{persist-CJXIL7D4.js → persist-6ILUR34S.js} +1 -1
- package/dist/m/core/{recovery-DRFZRJED.js → recovery-APWADU4K.js} +1 -1
- package/dist/m/core/save-6HT2LABE.js +1 -0
- package/dist/m/core/save-core-EVMNZQ4V.js +1 -0
- package/dist/m/core/site-edits-G4BOZMV4.js +1 -0
- package/dist/m/core/{unsaved-warning-HNQVTA2D.js → unsaved-warning-ITZDIZ2I.js} +1 -1
- package/dist/m/internals/{index-NRPNDTSA.js → index-HS3CQDFW.js} +1 -1
- package/dist/m/loader-GLLVDUZA.js +1 -0
- package/dist/m/manifest-50FF1C45.js +1 -0
- package/dist/m/manifest-edit-BE1A621D.js +1 -0
- package/dist/m/manifest.json +2072 -1811
- package/dist/m/page/editor-KAZDJNND.js +307 -0
- package/dist/m/plugins/ai-edit-LABECCSN.js +6 -0
- package/dist/m/plugins/{cms-H7DTMUQX.js → cms-T2HLI7JG.js} +16 -16
- package/dist/m/plugins/{demo-42BSYQ7T.js → demo-T7B4RIKL.js} +1 -1
- package/dist/m/plugins/{derive-QVI3LI3A.js → derive-6LPJOCAV.js} +1 -1
- package/dist/m/plugins/indicator-J4ABFARX.js +1 -0
- package/dist/m/plugins/{live-DCUBKXY4.js → live-PGBIEMGB.js} +1 -1
- package/dist/m/plugins/menu-YZL3X2AJ.js +1 -0
- package/dist/m/plugins/page-WOCNX2IN.js +2 -0
- package/dist/m/plugins/page-view-SJODOOGE.js +1 -0
- package/dist/m/plugins/{people-5XRNRP5U.js → people-C4TCWFOQ.js} +1 -1
- package/dist/m/plugins/{quickcrop-WWF5I422.js → quickcrop-X5MRIBAP.js} +2 -2
- package/dist/m/plugins/richclay-Y2NV44NA.js +549 -0
- package/dist/m/plugins/sortable-XCHQG65Z.js +1 -0
- package/dist/m/plugins/{source-6BKMK4PO.js → source-YK7MO23W.js} +1 -1
- package/dist/m/plugins/{undo-3JEYK5QY.js → undo-VLRBQNPN.js} +1 -1
- package/dist/m/plugins/upgrade-NNTJBSK2.js +1 -0
- package/dist/m/plugins/{upload-TTCQRIM5.js → upload-ZKKJV76X.js} +1 -1
- package/dist/m/plugins/visitor-drafts-RTZNONHT.js +20 -0
- package/dist/m/plugins/{visitor-drafts-owner-Z5B2OQBR.js → visitor-drafts-owner-LHUHFU3L.js} +1 -1
- package/dist/m/plugins/{visitor-menu-4LQMKLPP.js → visitor-menu-FY4KM2SW.js} +1 -1
- package/dist/m/plugins/wire-M2NR354P.js +1 -0
- package/dist/m/{reader-core-POFQCKRV.js → reader-core-T2S3JC4E.js} +2 -2
- package/dist/m/sync/live-sync-Z64YREWQ.js +1 -0
- package/dist/m/ui/index-MGTWOW2C.js +1 -0
- package/dist/m/vendor/{sap-core.vendor-OA5SKL7Q.js → sap-core.vendor-QAEPMETX.js} +1 -1
- package/dist/offline-manifest.json +1250 -1082
- package/dist/server/core.cjs +132 -109
- package/dist/server/page-compaction-worker.cjs +5 -5
- package/dist/server/rooms.mjs +3 -1
- package/docs/guide.md +89 -44
- package/entries/clay-data.js +1 -1
- package/entries/sap.js +1 -1
- package/package.json +5 -3
- package/src/blockeditor/themes/content.css +70 -0
- package/src/blockeditor/themes/light-1.css +431 -0
- package/src/blockeditor/themes/light-1.source.css +270 -0
- package/src/blockeditor/themes/light-2.css +211 -0
- package/src/blockeditor/themes/light-3.css +130 -0
- package/src/blockeditor/themes/light-4.css +299 -0
- package/src/core/conflict-notice.js +28 -0
- package/src/core/draft-mode.js +6 -0
- package/src/core/host-meta.js +6 -6
- package/src/core/is-edit-mode.js +9 -3
- package/src/core/mode-support.js +3 -0
- package/src/core/mode-switch.js +4 -4
- package/src/core/mode-transition.js +3 -1
- package/src/core/page-format-wire.js +1 -1
- package/src/core/page-format.js +8 -8
- package/src/core/save-accepted.js +6 -7
- package/src/core/save-core.js +52 -23
- package/src/core/save-failure-notice.js +37 -0
- package/src/core/save-feedback.js +6 -0
- package/src/core/save-replace.js +1 -1
- package/src/core/save-size.js +2 -2
- package/src/core/save.js +78 -15
- package/src/core/site-edits.js +166 -0
- package/src/core/unsaved-warning.js +2 -2
- package/src/core/upgrade-run.js +4 -4
- package/src/lib/ai-comment.js +23 -0
- package/src/lib/effect.js +8 -0
- package/src/lib/idb-error-code.js +20 -0
- package/src/live/fast-lane.js +10 -10
- package/src/live/local-lane.js +10 -10
- package/src/live/page-compaction.js +8 -8
- package/src/live/server-lane.js +1 -1
- package/src/loader-logic.js +48 -18
- package/src/loader.js +11 -6
- package/src/page/adopt-boot.js +1 -1
- package/src/page/adopt.js +2 -2
- package/src/page/ai-area.js +182 -0
- package/src/page/ai-preview.js +80 -0
- package/src/page/ai-surface.js +257 -0
- package/src/page/ai-tool.js +308 -145
- package/src/page/announce.js +2 -2
- package/src/page/awareness.js +18 -18
- package/src/page/blocks.js +35 -34
- package/src/page/blocksel.js +2 -2
- package/src/page/board-drag.js +11 -11
- package/src/page/board-face.js +1 -1
- package/src/page/board-panel.js +26 -26
- package/src/page/board-style.js +127 -127
- package/src/page/board-view.js +48 -48
- package/src/page/chart.js +29 -29
- package/src/page/checkpoint-proof.js +19 -19
- package/src/page/chrome.js +74 -65
- package/src/page/clipboard-shape.js +1 -1
- package/src/page/csv-import.js +4 -4
- package/src/page/drag.js +5 -5
- package/src/page/editor.js +301 -296
- package/src/page/export-html.js +8 -8
- package/src/page/features/checklist.js +36 -36
- package/src/page/features/export-html.js +19 -19
- package/src/page/features/export-markdown.js +10 -10
- package/src/page/features/import-markdown.js +13 -13
- package/src/page/features/media.js +50 -50
- package/src/page/features/table.js +17 -17
- package/src/page/features/title-cover.js +17 -17
- package/src/page/features/title-icon.js +7 -7
- package/src/page/features/toc.js +1 -1
- package/src/page/features/tool.js +42 -18
- package/src/page/format-command.js +4 -4
- package/src/page/format-gate.js +6 -6
- package/src/page/format-host.js +6 -6
- package/src/page/format-level.js +3 -3
- package/src/page/format-native-commands.js +2 -2
- package/src/page/highlight-slot.js +1 -1
- package/src/page/highlight.js +4 -4
- package/src/page/history-intent.js +2 -2
- package/src/page/image-actions.js +4 -4
- package/src/page/link.js +10 -10
- package/src/page/media.js +3 -3
- package/src/page/mention-picker.js +7 -7
- package/src/page/merge.js +1 -1
- package/src/page/placeholder.js +3 -3
- package/src/page/projection.js +11 -11
- package/src/page/reader-patch.js +2 -2
- package/src/page/recover.js +26 -26
- package/src/page/recovery-ui.js +28 -28
- package/src/page/rich/chart.js +1 -1
- package/src/page/rich/page-tool.js +21 -6
- package/src/page/rich/tool-runtime.js +3 -2
- package/src/page/save-projection.js +2 -2
- package/src/page/save-states.js +9 -9
- package/src/page/schema.js +9 -9
- package/src/page/table-style.js +21 -21
- package/src/page/toc-link.js +1 -1
- package/src/page/tool-capability.js +8 -3
- package/src/page/tool-transport.js +52 -0
- package/src/page/tool-views.js +4 -0
- package/src/page/tools.js +6 -1
- package/src/page/view.js +6 -6
- package/src/page/ybind/binding.js +1 -1
- package/src/page/ybind/conversion.js +1 -1
- package/src/page/ybind/layout.js +4 -4
- package/src/page/ybind/migrate.js +1 -1
- package/src/page/ybind/origins.js +2 -2
- package/src/page/ybind/provider.js +2 -2
- package/src/page/ybind/recovery-proof.js +3 -3
- package/src/page/ybind/recovery-replay.js +2 -2
- package/src/plugins/ai-edit/picker.js +235 -0
- package/src/plugins/ai-edit.js +220 -34
- package/src/plugins/indicator-chip.js +39 -34
- package/src/plugins/indicator.js +13 -4
- package/src/plugins/live.js +21 -13
- package/src/plugins/menu/actions.js +89 -17
- package/src/plugins/menu/seo.js +32 -6
- package/src/plugins/menu/shell-style.js +26 -7
- package/src/plugins/menu/shell.js +12 -7
- package/src/plugins/menu/variants.js +6 -10
- package/src/plugins/menu/visitor.js +44 -34
- package/src/plugins/menu.js +3 -2
- package/src/plugins/page-view.js +2 -2
- package/src/plugins/page.js +257 -98
- package/src/plugins/sortable.js +7 -0
- package/src/plugins/upgrade.js +2 -1
- package/src/plugins/visitor-drafts/commit.js +303 -0
- package/src/plugins/visitor-drafts/idb.js +221 -0
- package/src/plugins/visitor-drafts/intro-style.js +1 -1
- package/src/plugins/visitor-drafts/intro.js +8 -25
- package/src/plugins/visitor-drafts/prompt.js +30 -4
- package/src/plugins/visitor-drafts/session.js +345 -0
- package/src/plugins/visitor-drafts/store.js +351 -32
- package/src/plugins/visitor-drafts.js +158 -27
- package/src/server/checkpoint/index.js +8 -8
- package/src/server/rooms/index.js +2 -2
- package/src/server/rooms/live-data-rooms.js +35 -35
- package/src/server/rooms/live-page-history.js +2 -2
- package/src/server/rooms/page-admission.js +34 -6
- package/src/server/rooms/page-conversion.js +1 -1
- package/src/server/rooms/page-lineage.js +4 -4
- package/src/server/rooms/page-rebase.js +4 -4
- package/src/server/rooms/page-room-conformance.js +14 -14
- package/src/server/rooms/page-state.js +2 -2
- package/src/server/rooms/page-write-admission.js +7 -7
- package/src/server/rooms/page-write-guard.js +3 -3
- package/src/sync/data-guard-notice.js +265 -0
- package/src/sync/live-sync.js +54 -11
- package/src/sync/page-relay.js +4 -4
- package/src/sync/presence-store.js +1 -1
- package/src/sync/presence-target.js +3 -3
- package/src/sync/presence.js +1 -1
- package/src/sync/stream.js +54 -13
- package/src/sync/wire-profile.js +8 -3
- package/src/ui/bevel.js +1 -1
- package/src/ui/index.js +9 -10
- package/src/ui/skins/cms.js +1 -1
- package/src/ui/skins/quickcrop.js +1 -1
- package/src/ui/skins/richclay.js +2 -2
- package/src/ui/toast-lazy.js +12 -3
- package/src/ui/toast.js +9 -3
- package/src/vendor/hyper-html-api-data.vendor.js +1 -1
- package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
- package/src/vendor/hypercms.vendor.js +16 -16
- package/src/vendor/richclay.vendor.js +48 -20
- package/src/vendor/sap-core.vendor.js +1 -1
- package/tool-generation/context.md +44 -0
- package/tool-generation/system.md +23 -0
- package/dist/m/c-24PMUJIV.js +0 -2
- package/dist/m/c-2AYVYEI4.js +0 -1
- package/dist/m/c-2AZDZWCK.js +0 -1
- package/dist/m/c-2L6O5PDS.js +0 -6
- package/dist/m/c-2RYOGUQM.js +0 -2
- package/dist/m/c-2ZVOEU4M.js +0 -1
- package/dist/m/c-37NAONZA.js +0 -1
- package/dist/m/c-3GJ4SDE2.js +0 -1
- package/dist/m/c-3O7OBDCM.js +0 -1
- package/dist/m/c-5OJ7YF2N.js +0 -1
- package/dist/m/c-5WMXEKFH.js +0 -135
- package/dist/m/c-6RDOKLN7.js +0 -1
- package/dist/m/c-A4IP6MBC.js +0 -1
- package/dist/m/c-A6L3FMUS.js +0 -1
- package/dist/m/c-ATKAOH23.js +0 -1
- package/dist/m/c-B6O7AJYG.js +0 -32
- package/dist/m/c-BCGWJYXW.js +0 -1
- package/dist/m/c-BGKAT2FL.js +0 -7
- package/dist/m/c-BYTKL6UX.js +0 -1
- package/dist/m/c-DHBRA6DL.js +0 -1
- package/dist/m/c-DTMZ3ZHI.js +0 -1
- package/dist/m/c-E3ZXARWA.js +0 -1
- package/dist/m/c-EK63G3CG.js +0 -1
- package/dist/m/c-ELYIIYRS.js +0 -1
- package/dist/m/c-EXKHPOVC.js +0 -3
- package/dist/m/c-FCSZ3DC5.js +0 -20
- package/dist/m/c-FTWGYI5E.js +0 -1
- package/dist/m/c-G4PWUDD5.js +0 -1
- package/dist/m/c-GBKB5WDL.js +0 -2
- package/dist/m/c-GBTVCJXC.js +0 -1
- package/dist/m/c-GC2HICFJ.js +0 -1
- package/dist/m/c-GRWMD6O5.js +0 -1
- package/dist/m/c-HCNWJE4A.js +0 -4
- package/dist/m/c-HG2C77BM.js +0 -4
- package/dist/m/c-JGHEACGK.js +0 -1
- package/dist/m/c-JGLX6TBK.js +0 -1
- package/dist/m/c-JNRKHYWO.js +0 -1
- package/dist/m/c-KBS3UV6B.js +0 -1
- package/dist/m/c-KQ7E3PYY.js +0 -1
- package/dist/m/c-L3F5ZLIV.js +0 -1
- package/dist/m/c-L4KMT7FO.js +0 -6
- package/dist/m/c-L5VFATT6.js +0 -1
- package/dist/m/c-LCYPMULG.js +0 -1
- package/dist/m/c-LIGQYZ7M.js +0 -6
- package/dist/m/c-LKIWEPAV.js +0 -1
- package/dist/m/c-MPSKIU2I.js +0 -1
- package/dist/m/c-N7JPUPGC.js +0 -1
- package/dist/m/c-NK33MMYF.js +0 -1
- package/dist/m/c-NQLWOHLH.js +0 -10
- package/dist/m/c-NTHUTABN.js +0 -1
- package/dist/m/c-NWX3MFT4.js +0 -1
- package/dist/m/c-OKXI52N7.js +0 -1
- package/dist/m/c-OPONJ2UK.js +0 -128
- package/dist/m/c-OWQWOGYI.js +0 -1
- package/dist/m/c-P6Q2ZTFQ.js +0 -1
- package/dist/m/c-QEN6HZCA.js +0 -1
- package/dist/m/c-QIXT3Q7C.js +0 -28
- package/dist/m/c-QM5LXRDT.js +0 -9
- package/dist/m/c-QYYUVLVG.js +0 -1
- package/dist/m/c-RQRMPZXD.js +0 -1
- package/dist/m/c-SBCBXKOZ.js +0 -26
- package/dist/m/c-SKF5HL4I.js +0 -4
- package/dist/m/c-SRPC3VBE.js +0 -1
- package/dist/m/c-TANBH7FI.js +0 -1
- package/dist/m/c-THGQQDYY.js +0 -1
- package/dist/m/c-UD5JZTDL.js +0 -1
- package/dist/m/c-UDGEFWNU.js +0 -1
- package/dist/m/c-UGNV5MFB.js +0 -1
- package/dist/m/c-VIRFF5HG.js +0 -8
- package/dist/m/c-VJYEVRYK.js +0 -1
- package/dist/m/c-VQCEOGKH.js +0 -13
- package/dist/m/c-VYJ7O4RI.js +0 -34
- package/dist/m/c-W7IPVCAA.js +0 -1
- package/dist/m/c-WBGWGOM7.js +0 -1
- package/dist/m/c-WJ5DRBHT.js +0 -72
- package/dist/m/c-X5WC4PX5.js +0 -1
- package/dist/m/c-XCFQEWW6.js +0 -3
- package/dist/m/c-XGH4GS2T.js +0 -1
- package/dist/m/c-XLQ3BDMM.js +0 -1
- package/dist/m/c-ZQXNHZZT.js +0 -72
- package/dist/m/core/conflict-notice-42H4ASLA.js +0 -1
- package/dist/m/core/draft-mode-WSQAT67S.js +0 -1
- package/dist/m/core/save-ESPSQPLV.js +0 -1
- package/dist/m/core/save-core-6SQHOR6W.js +0 -1
- package/dist/m/loader-FBDE2UAB.js +0 -1
- package/dist/m/manifest-1D2F5CA5.js +0 -1
- package/dist/m/manifest-edit-F7CC5CFD.js +0 -1
- package/dist/m/page/editor-OSKOW6RS.js +0 -304
- package/dist/m/plugins/ai-edit-VV4QTINH.js +0 -6
- package/dist/m/plugins/indicator-WVPGMOZ7.js +0 -1
- package/dist/m/plugins/menu-Q4MFFQ6E.js +0 -1
- package/dist/m/plugins/page-OAWUJQEL.js +0 -2
- package/dist/m/plugins/page-view-DZ26ZDDQ.js +0 -1
- package/dist/m/plugins/richclay-PGOOJ4OK.js +0 -517
- package/dist/m/plugins/sortable-266HY6TR.js +0 -1
- package/dist/m/plugins/upgrade-BNZVFHMZ.js +0 -1
- package/dist/m/plugins/visitor-drafts-2AUYKAIJ.js +0 -20
- package/dist/m/plugins/wire-W2EV36KZ.js +0 -1
- package/dist/m/sync/live-sync-XGUPHI3I.js +0 -1
- package/dist/m/ui/index-VGYAKAKI.js +0 -1
- package/dist/page/themes/light-1.css +0 -431
- package/src/page/themes/content.css +0 -70
- package/src/page/themes/light-1.css +0 -431
- package/src/page/themes/light-1.source.css +0 -270
- package/src/page/themes/light-2.css +0 -211
- package/src/page/themes/light-3.css +0 -130
- package/src/page/themes/light-4.css +0 -299
- /package/dist/m/{c-FILLTJA7.js → c-QTTJYJMA.js} +0 -0
- /package/dist/m/plugins/{quickcrop-WWF5I422.js.LEGAL.txt → quickcrop-X5MRIBAP.js.LEGAL.txt} +0 -0
- /package/dist/m/plugins/{richclay-PGOOJ4OK.js.LEGAL.txt → richclay-Y2NV44NA.js.LEGAL.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as E,b as S,c as P}from"./c-
|
|
1
|
+
import{a as E,b as S,c as P}from"./c-Q6BG3ZLO.js";import{i as A,j as q}from"./c-CV4T65JE.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-DD26VXAP.js";import"./c-CTGRDT6E.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as T}from"./c-ZRGEN6QQ.js";import{d as x}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{b as k}from"./c-RETTCOWO.js";import"./c-WCG6AKA7.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var R=/^[A-Za-z0-9_-]{8,64}$/,D="@",F=100;function _({view:o=null}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let f=o.dom.ownerDocument,y=()=>globalThis.clay?.people??null,l=null;function d(t){let e=o.state;if(!e.selection.empty)return null;let r=e.selection.head;if(r<=t.from||r-t.from>F+1||r>e.doc.content.size)return null;let n=e.doc.resolve(t.from);return!n.parent.isTextblock||n.parent.type.spec.code||r>n.end()||r<n.start()||n.parentOffset&&!/\s/.test(e.doc.textBetween(t.from-1,t.from,"",`
|
|
2
2
|
`))||e.doc.textBetween(t.from,t.from+1)!==D?null:{head:r,query:e.doc.textBetween(t.from+1,r)}}function $(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function h(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function m(t){t.picker.show(S(E(t.saved,t.allowed),t.query),$(t)),h(t)}function i(){let t=l;if(t){l=null;for(let[e,r,n,s]of t.listen)e.removeEventListener(r,n,s);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function p(){let t=l;if(!t||o.composing)return;let e=d(t);if(!e)return i();t.query=e.query,m(t)}async function g(t){let e=l;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),n=d(e);if(!(r&&n&&n.query===e.query&&R.test(String(r.id??""))&&String(r.name??"").trim()))return i(),{ok:!1,code:r?"stale-target":"no-person"};let c=String(r.name).trim();return i(),A(o,()=>{let u=d(e);if(!u||u.query!==e.query)return{ok:!1,code:"stale-target"};let a=o.state.tr.insertText(c,e.from,u.head);return a.addMark(e.from,e.from+c.length,x.marks.mention.create({id:r.id})),a.insertText(" ",e.from+c.length),a.setSelection(k.TextSelection.create(a.doc,e.from+c.length+1)),o.dispatch(T(a)),o.focus(),{ok:!0,id:r.id,label:c}})}function B(t){let e=l;if(!e||q(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),h(e)):t.key==="Enter"?(r(),g(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),i())}function I(t){let e=y()?.available;e&&Promise.resolve().then(()=>e()).then(r=>{l===t&&(t.allowed=Array.isArray(r)?r:null,m(t))}).catch(()=>{})}function M(t){i();let e=P({document:f,onPick:c=>g(c)}),r={from:t,picker:e,query:"",allowed:null,saved:[],listen:[]};try{r.saved=y()?.list?.()??[]}catch{r.saved=[]}l=r;let n=(c,u,a,b)=>{c.addEventListener(u,a,b),r.listen.push([c,u,a,b])};n(f,"keydown",c=>B(c),!0),n(o.dom,"input",()=>p()),n(o.dom,"keyup",()=>p()),n(o.dom,"compositionend",()=>p()),n(f,"mousedown",c=>{r.picker.el.contains(c.target)||i()},!0),(o.dom.parentElement??f.body).appendChild(e.el);let s=d(r);return s?(r.query=s.query,m(r),I(r),{ok:!0,picker:!0}):(i(),{ok:!1,code:"stale-target"})}return{async run(t={}){let e=Number.isInteger(t?.from)?t.from:null;if(e===null){let r=o.state,n=r.selection.$from;if(!r.selection.empty||!n.parent.isTextblock||n.parent.type.spec.code)return{ok:!1,code:"stale-target"};e=r.selection.from;let s=o.state.tr.insertText(D);s.setSelection(k.TextSelection.create(s.doc,e+1)),o.dispatch(s)}return M(e)},dispose(){i()}}}export{_ as createFeature};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ce,b as Qe,c as ue,e as fe,f as pe,g as nt}from"./c-UOOIF2AL.js";import{a as Ze,b as et,c as de,d as tt}from"./c-LZJPNR2W.js";import{a as A,b as J}from"./c-QTTJYJMA.js";import{b as Ke}from"./c-5VYOWDTI.js";import{b as oe,c as ae,d as x,f as he,g as Ve,h as Xe}from"./c-6Q6RGFBF.js";import{a as q}from"./c-LA2BW7UY.js";import{a as Ge}from"./c-LD6UVV5R.js";import{a as ze,f as We,g as Ye,h as Je}from"./c-PGSBXHUE.js";import{a as se,b as $e,c as P,d as re,e as le,h as je}from"./c-6IJEVE6B.js";import{e as Ue}from"./c-QQFHEODI.js";import{d as Pe}from"./c-IJUK2GPW.js";import{f as $,j as te}from"./c-EDE45NM7.js";import{a as Le}from"./c-BPF2NSPV.js";import{E as Y,F as Ne,H as T,I as Oe,b as D,j as ie,o as W,t as M,z as Be}from"./c-PWJSJEJU.js";import{a as Re,b as qe,c as Me,e as j,g as z,h as ne}from"./c-VG5XIN4T.js";import{m as Ie,n as Te}from"./c-HA6INT6J.js";import{a as He,b as Fe,l as Ce,m as Ae}from"./c-ICMAOOGK.js";function it(s){let e=new WeakMap,t=0,i=r=>e.get(r)||null,n=r=>{let l=e.get(r);return l||(l=`${s}:${++t}`,e.set(r,l)),l};return{idOf:i,ensure:n,adopt:(r,l)=>{r&&typeof l=="string"&&l&&e.set(r,l)},exportMap:(r,l)=>{let o={},a=[],h=[],c=(d,_)=>{let g=l(d);g&&(o[_]=n(g));let E=d.children;a.push(E.length),h.push(d.tagName.toLowerCase());for(let f=0;f<E.length;f++)c(E[f],_===""?String(f):`${_}.${f}`)};return c(r,""),o["~"]=a.join(","),o["^"]=h.join(","),o}}}function st(s,e){let t=new WeakMap;if(!s||!e||typeof e!="object"||Array.isArray(e))return t;let i=e["~"],n=typeof i=="string"?i.split(",").map(Number):null,r=n&&typeof e["^"]=="string"?e["^"].split(","):null,l=d=>Number.isInteger(d)&&d>=0,o=0,a=!1,h=d=>{let _=d;for(;_>0;){let g=n[o++];if(o>n.length||!l(g))return!1;_+=g-1}return!0},c=(d,_)=>{if(a)return;if(n){let f=o++,u=n[f];if(f>=n.length||!l(u)){a=!0;return}let S=!r||r[f]===d.tagName.toLowerCase();if(!S||u!==d.children.length){let w=S&&e[_];typeof w=="string"&&w&&t.set(d,w),h(u)||(a=!0);return}}let g=e[_];typeof g=="string"&&g&&t.set(d,g);let E=d.children;for(let f=0;f<E.length;f++)c(E[f],_===""?String(f):`${_}.${f}`)};return c(s,""),t}function vt(s){return e=>{for(let t of s){let i=t(e);if(typeof i=="string"&&i!=="")return i}return null}}var Bt=vt([s=>s.getAttribute("data-id"),s=>s.getAttribute("id")]);var St=/^blockeditor(\.[0-9]+)?$/,rt=s=>[...s.querySelectorAll('script[merge][clay~="live"]')].filter(e=>St.test(e.getAttribute("merge")));function lt(s,e,t){if(!s.html.includes("data-blockeditor"))return s;let i=u=>W(new DOMParser().parseFromString(u,"text/html")),n=i(s.html),r=n.querySelector("article[data-blockeditor]");if(!r)return s;let l=i(e),o=l.querySelector("article[data-blockeditor]");if(!o)return null;let a=st(n.documentElement,s.identityMap),h=(u,S)=>{let w=n.importNode(S,!0),b=a.get(u);return b&&a.set(w,b),u.replaceWith(w),w},c=h(r,o),d=new Map(rt(n).map(u=>[u.getAttribute("merge"),u]));for(let u of rt(l)){let S=u.getAttribute("merge"),w=d.get(S);w?h(w,u):c.before(n.importNode(u,!0)),d.delete(S)}for(let u of d.values())u.remove();let _=n.querySelector("head > title"),g=l.querySelector("head > title");_&&g?h(_,g):g?n.head.append(n.importNode(g,!0)):_?.remove();let E=n.documentElement,f=t.exportMap(E,u=>{let S=a.get(u);return S?(t.adopt(u,S),u):null});return{...s,html:T(E),identityMap:f}}var Et={"merge-tokens":"tokens","merge-max":"max"};function ot(s,e){if(!e.startsWith("data-")||e==="data-id"||!s?.closest)return null;for(let[t,i]of Object.entries(Et)){let n=s.closest(`[${t}]`);if(n&&n.getAttribute(t).split(/\s+/).includes(e))return i}return null}var m=null,at=null,B=new Map;function V(){return at??=Promise.all([import("./c-PYG2NGWU.js"),import("./c-EJTGYSLN.js")]).then(([s,e])=>{m={...s,beginLineageCapture:e.beginLineageCapture};for(let t of[...B.keys()])B.set(t,s.registerContext(t));return m}),at}var ht=()=>m,I={get size(){return m?m.conflicts.size:0},list(){return m?m.conflicts.list():[]},get(s){return m?m.conflicts.get(s):null},acknowledge(s,e={}){if(m)return m.conflicts.acknowledge(s,e);if(!Array.isArray(s))throw new TypeError("clay.conflicts.acknowledge needs an array of ids");return{removedIds:[],remainingIds:[]}},claim(s,e={}){if(m)return m.conflicts.claim(s,e);if(!e.owner)throw new TypeError("clay.conflicts.claim needs an owner");return{release(){}}},registerContext(s){if(m)return m.conflicts.registerContext(s);if(typeof s!="function")throw new TypeError("clay.conflicts.registerContext needs a resolver function");return B.set(s,null),()=>{let e=B.get(s);B.delete(s),e&&e()}},contextFor(s,e){return m?m.conflicts.contextFor(s,e):null},recoveryOf(s){return m?m.conflicts.recoveryOf(s):null},hasPendingApply(){return m?m.conflicts.hasPendingApply():!1}};var y=null,_e=null;function R(){return _e??=new Promise(s=>setTimeout(s,0)).then(()=>import("./c-PDBNCJCT.js")).then(s=>y=s).catch(s=>{throw _e=null,s}),_e}var ve=null,ge=null;function kt(){return ge??=import("./c-APGHGDZM.js").then(s=>ve=s.presence).catch(s=>{throw ge=null,s}),ge}var ut=te().phase==="entering";$&&!ut&&R().catch(()=>{});$&&V().catch(()=>{});var L=null,ye=null,Q=[];function ft(s){L.presence.update(s),L.editingMarker.update(s)}function xt(){return ye??=Promise.all([import("./c-T3P3AXEW.js"),import("./c-X75G43SZ.js")]).then(([s,e])=>{L={presence:s.presence,editingMarker:e.editingMarker};let t=Q;Q=[];for(let i of t)ft(i);return L}).catch(s=>{throw ye=null,s}),ye}function bt(s){if(L){ft(s);return}Q.push(s),xt().catch(()=>{})}var ct=Object.freeze({bytes:null,etag:null,seq:null}),Dt=()=>({msg:"Not in edit mode",msgType:"skipped",code:null,etag:null}),pt=["[editor-ui]",'[clay~="editor-ui"]',"[save-ignore]","[snapshot-remove]","[no-snapshot]","[no-save]","[save-remove]","[freeze] *","[save-freeze] *",'[clay~="no-save"]','[clay~="no-snapshot"]','[clay~="freeze"] *',Ce,He].join(","),_t='[clay~="freeze"], [freeze], [save-freeze]';function X(s){for(let e of s.querySelectorAll(_t))e.replaceChildren();return z()&&Me(s),s}function dt(s){if(s==null)return s;let e=typeof s=="string"?new DOMParser().parseFromString(s,"text/html"):s;return ie(e),W(e),X(e),e}var It=[Ae,'[clay~="no-watch"]',"[no-watch]","[mutations-ignore]"].join(","),Tt=(s,e,t)=>Ie(s,e,t)||Fe.test(e.toLowerCase()),gt=s=>s.getAttribute("data-id")||s.getAttribute("id")||null;function Lt(s){let e=new Map,t=n=>{if(n.matches(pt))return;let r=gt(n);r&&e.set(r,(e.get(r)||0)+1);let l=n.localName==="template"&&n.content?n.content.children:n.children;for(let o of l)t(o)},i=s.nodeType===9?[s.documentElement]:s.nodeType===11?s.children:[s];for(let n of i)n&&n.nodeType===1&&t(n);return e}var Ht=s=>e=>{let t=gt(e);if(!t)return null;let i=e.getRootNode(),n=s.get(i);return n||s.set(i,n=Lt(i)),n.get(t)===1?t:null},me=s=>!!s&&typeof s=="object"&&!Array.isArray(s);function Ft(s){return typeof s!="string"||s===""?null:new DOMParser().parseFromString(s,"text/html").documentElement?.getAttribute("documentetag")||null}function Ct(s,e){e!=="live"||!s||!y||(y.enableContentEditable(s),y.enableOnClick(s),y.enableAdminInputs(s),y.enableAdminResources(s))}function At(){let{forComparison:s,forDirty:e}=Be({flushUndo:!1});return[s,e]}var Rt=1024*1024;function qt(s,e,t,i,n){let r={sender:t,identityMap:i,...n?{etag:n}:{}};return e.length<Rt?JSON.stringify({[s.snapshotKey]:e,...r}):new Blob([`{${JSON.stringify(s.snapshotKey)}:`,JSON.stringify(e),`,${JSON.stringify(r).slice(1)}`],{type:"application/json"})}var Se=class{constructor(){this.sse=null,this.currentFile=null,this.lastHtml=null,this._diskBase=null,this._diskBaseTicket=0,this._agreeSeq=0,this._saveTicket=0,this._peerBaseTicket=0,this._acceptedSaveTicket=0,this._morphTicket=0,this.clientId=this.generateClientId(),this.resumeId=null,this._savedSnapshot?.abort?.abort(),this._savedSnapshot=null,this._sendInFlight=!1,this._queuedSend=null,this._profile=null,this._profilePromise=null,this._sharedData=!1,this._sharedSync=!1,this._workerFeatures=["live-data"],this._liveData=!1,this._editing=null,this._presenceLease=null,this._presenceQuiesced=!1,this._ready=null,this._startGen=0,this.isPaused=!1,this.isDestroyed=!1,this.debug=!1,this._lane=$?"live":"saved",this._laneChosen=!1,this._snapshotHandler=null,this._hiddenHandler=null,this.lastSeenSeq=0,this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingEtag=null,this._pendingBy=null,this._morphInFlight=!1,this._rafHandle=null,this._represented=ct,this._handoff=null,this._handoffHeld=!1,this._pendingExternal=null,this._lastExternalSeq=0,this._saveEpoch=0,this._saveSavedHandler=null,this._saveConflictHandler=null,this._settledHandler=null,this._lastIdentityMap=null,this._applyGen=0,this._holdRetryPeer=null,this._holdRetryExt=null,this._servedFetchId=0,this._startupRetry=null,this._engineRetry=null,this._heldLive=!1,this._heldExt=!1,this.identity=it(this.clientId),this.onConnect=null,this.onDisconnect=null,this.onUpdate=null,this.onError=null,this.onNotification=null}get unresolvedConflicts(){return I.list().filter(e=>e.kind!=="apply-incomplete")}_log(e,t=null){if(!this.debug)return;let i=`[LiveSync ${new Date().toISOString()}]`;t!==null?console.log(i,e,t):console.log(i,e)}generateClientId(){return Math.random().toString(36).slice(2,11)+Date.now().toString(36)}generateResumeId(){try{let e=new Uint8Array(16);return(globalThis.crypto||window.crypto).getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}catch{return Math.random().toString(36).slice(2)+Date.now().toString(36)}}_seedBases(){if(x())return;let e=M({flushUndo:!1});this._setPeerBase(T(e),this.identity.exportMap(e,D),this._ticket()),this._setDiskBase(Y({emitForSync:!1}).forSave,this._ticket())}get lane(){return this._lane}set lane(e){this._lane=e,this._laneChosen=!0}start(e=null,{lane:t,represented:i}={}){if(this.isDestroyed=!1,(this.sse||this._snapshotHandler)&&this.cleanup(),this.currentFile=e||this.detectCurrentFile(),!this.currentFile){console.warn("[LiveSync] No file detected");return}let n=te().mode==="edit"?"live":"saved",r=this.lane==="live";this._lane=t||(this._laneChosen?this._lane:n),this.lastHtml=null,this._lastIdentityMap=null,this._peerBaseTicket=this._ticket(),this._diskBase=null,this._diskBaseTicket=this._ticket(),this._saveTicket=0,this._savedSnapshot?.abort?.abort(),this._savedSnapshot=null,this._applyGen++,this.lastSeenSeq=0,this._lastExternalSeq=0,this._represented=i?Object.freeze({bytes:i.bytes??null,etag:i.etag??null,seq:i.seq??null}):ct,this._acquireEmptySaved=r&&this.lane==="saved"&&this._represented.bytes===null,this._pendingExternal=null,this.resumeId=this.generateResumeId(),this.lane==="live"&&this._seedBases(),this.lane==="live"&&V().catch(()=>{}),console.log(`[LiveSync] Starting for: ${this.currentFile} (lane=${this.lane})`);let l=++this._startGen;if(this.lane==="live"&&!(y&&y.baselineSettled())){let o=this._applyGen,a=this._morphTicket,h=this._saveEpoch,c=this.lastHtml,d=this._diskBaseTicket,_=this._diskBase!==null;this._settledHandler=()=>{if(this._settledHandler=null,!(this.isDestroyed||this._startGen!==l)&&!Pe()&&!x()&&this._saveTicket===0&&this._morphTicket===a){if(c!==null&&this._applyGen===o&&this._saveEpoch===h&&this.lastHtml===c){let g=M({flushUndo:!1});this._setPeerBase(T(g),this.identity.exportMap(g,D),this._ticket())}_&&this._diskBaseTicket===d&&this._setDiskBase(Y({emitForSync:!1}).forSave,this._ticket())}},document.addEventListener("clay:baseline-settled",this._settledHandler,{once:!0})}this._ready=Promise.all([this.lane==="live"?R():null,this._resolveProfile()]).then(()=>{this.isDestroyed||this._startGen!==l||this.connect()}),this.lane==="live"&&(this.listenForSnapshots(),kt().then(o=>this._startPresence(o,l),()=>{}),this._saveSavedHandler=o=>{this._saveEpoch++;let a=this._saveTicket||this._ticket();this._saveTicket=0,a>this._acceptedSaveTicket&&(this._acceptedSaveTicket=a);let h=y?y.getLastSavedBytes():null;h!=null&&this._setDiskBase(h,a),this._relayCommit(o?.detail?.captureId,h)},document.addEventListener("clay:save-saved",this._saveSavedHandler),this._saveConflictHandler=o=>{let a=o.detail&&o.detail.etag;a&&queueMicrotask(()=>{this.isDestroyed||a===se()&&(y?.conflictResolvedBySync(a),this._saveAfterMerge(x(),!1))})},document.addEventListener("clay:save-conflict",this._saveConflictHandler))}cleanup(){if(this.sse&&(this.sse.close(),this.sse=null),de(),Q=[],L&&(L.presence.clear(),L.editingMarker.clear()),this._editing&&(this._editing.stop(),this._editing=null),this._presenceLease){let e=this._presenceLease;this._presenceLease=null,typeof e.stop=="function"?e.stop():e.detach()}this._lastRoster=null,this._snapshotHandler&&(document.removeEventListener("clay:snapshot-ready",this._snapshotHandler),this._snapshotHandler=null),this._saveSavedHandler&&(document.removeEventListener("clay:save-saved",this._saveSavedHandler),this._saveSavedHandler=null),this._saveConflictHandler&&(document.removeEventListener("clay:save-conflict",this._saveConflictHandler),this._saveConflictHandler=null),this._settledHandler&&(document.removeEventListener("clay:baseline-settled",this._settledHandler),this._settledHandler=null),this._hiddenHandler&&(document.removeEventListener("visibilitychange",this._hiddenHandler),document.removeEventListener("clay:workspace-background",this._hiddenHandler),this._hiddenHandler=null),this._queuedSend=null,this._rafHandle!=null&&(this._cancelFrame(this._rafHandle),this._rafHandle=null),this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingBy=null,this._pendingExternal=null,this._handoff=null,this._handoffHeld=!1,clearTimeout(this._holdRetryPeer),clearTimeout(this._holdRetryExt),this._holdRetryPeer=null,this._holdRetryExt=null,clearTimeout(this._startupRetry),this._startupRetry=null,clearTimeout(this._engineRetry),this._engineRetry=null,this._servedFetchId++}detectCurrentFile(){let e=window.location.pathname;if(e==="/")return"index.html";e=e.replace(/^\//,"");let t=e.match(/^(.*?\.html(?:clay)?)/);return t?t[1]:e}_resolveProfile(){return this._profilePromise||(this._profilePromise=nt().then(e=>(this._sharedData=e.sharedData,this._sharedSync=e.sharedSync,this._liveData=e.liveData,this._workerFeatures=e.workerFeatures,this._profile=e.profile,this._log(`Wire profile: ${e.profile.name}`),e.profile))),this._profilePromise}_setHeld(e,t,i){let n=e==="live"?"_heldLive":"_heldExt";this[n]!==t&&(this[n]=t,!t&&!this._heldLive&&!this._heldExt&&je({fresh:!0,clearIfMissing:!1}),document.dispatchEvent(new CustomEvent(t?"clay:sync-held":"clay:sync-resumed",{detail:{lane:e,el:i||null}})))}_applyEtagFrame(e){return typeof e.etag!="string"||typeof e.html=="string"?!1:(this._log("Dropping a stamp that arrived with no document: nothing proves this tab holds those bytes"),!0)}connect(){if(this.isDestroyed)return;let t=(this._profile||pe.legacy).streamPath(window.location.href,this.lane,this.resumeId,this.clientId);this._hiddenHandler||(this._hiddenHandler=()=>{this._rafHandle==null||!ce()||(this._cancelFrame(this._rafHandle),this._rafHandle=null,this._scheduleNextFrame())},document.addEventListener("visibilitychange",this._hiddenHandler),document.addEventListener("clay:workspace-background",this._hiddenHandler)),this.sse=new Qe(new URL(t,window.location.origin).href,{shared:this._sharedSync,sharedData:this._sharedData,workerFeatures:this._workerFeatures,documentURL:window.location.href,lane:this.lane,clientId:this.clientId,keepAliveWhenHidden:this.lane!=="live"?!1:this._liveData?!0:"shared",startupCheck:!!Le}),this._acquireEmptySaved&&(this._acquireEmptySaved=!1,this._fetchServedDocument(void 0,{repair:!0})),this.sse.onopen=()=>{console.log("[LiveSync] Connected"),this._editing&&this._editing.reconnected(),ve&&ve.reconnect(),this.onConnect&&this.onConnect()},this.sse.addEventListener("open",()=>et({clientId:this.clientId,lane:this.lane})),this.sse.addEventListener("error",()=>de());for(let i of Ze)this.sse.addEventListener(i,n=>{let r;try{r=JSON.parse(n.data)}catch{return}tt(i,r)});this.sse.addEventListener("cursor",i=>{let n;try{n=JSON.parse(i.data)}catch{return}if(!n||n.resync!==!0&&n.startup!==!0)return;let r=n.resync===!0,l=n.startup===!0&&!r;console.log(r?"[LiveSync] Server could not replay everything; refetching the document":"[LiveSync] Checking the served document against the version this tab was served"),this._fetchServedDocument(typeof n.seq=="number"?n.seq:void 0,{repair:r,startup:l})}),this.sse.addEventListener("presence",i=>{let n;try{n=JSON.parse(i.data)}catch{return}bt(n),this._lastRoster=n,this._editing&&this._editing.roster(n)}),this.sse.onmessage=i=>{let n=JSON.parse(i.data),{seq:r}=n;if(typeof r=="number"&&r<=this.lastSeenSeq){this._log(`Dropping stale message: seq=${r}, lastSeen=${this.lastSeenSeq}`);return}if(typeof r=="number"&&(this.lastSeenSeq=r),n.type==="notification"){if(this._maybeAcceptExternalChange(n))return;this.handleNotification(n);return}if(n.error){console.error("[LiveSync] Server error:",n.error),this.onError&&this.onError(new Error(n.error));return}if(this._applyEtagFrame(n))return;let{html:l,sender:o,identityMap:a}=n;if(o===this.clientId){this._log("Ignoring own message (sender matches clientId)");return}if(typeof l!="string"){console.error("[LiveSync] Received invalid html, ignoring");return}let h=typeof n.etag=="string"&&n.etag?n.etag:null;if(this.lane==="live"&&!h&&$e()){this._log(`Dropping an unstamped live frame on a stamping host (seq=${r})`);return}if(this.lane==="saved"&&l===this._represented.bytes){this._represented=Object.freeze({bytes:l,etag:h||null,seq:r??null}),P(h);return}if(h&&l===this.lastHtml){this._log(`Taking the stamp from a peer save of content already applied (seq=${r})`),P(h),y&&y.isSaveConflicted()&&(y.conflictResolvedBySync(h),this._saveAfterMerge(x(),!1));return}this._log(`Received update from: ${o} (my clientId: ${this.clientId}, seq=${r})`),this.applyUpdate(l,r,a,h,n.by),this.onUpdate&&this.onUpdate({html:l,sender:o,seq:r,identityMap:a,etag:h})},this.sse.onerror=()=>{this.sse.readyState===EventSource.CONNECTING?console.log("[LiveSync] Reconnecting..."):this.sse.readyState===EventSource.CLOSED&&(console.log("[LiveSync] Connection closed"),this.onError&&this.onError(new Error("Connection closed"))),this.onDisconnect&&this.onDisconnect()}}listenForSnapshots(){this._snapshotHandler=e=>{if(!e.detail||e.detail.forSave!==!0)return;this._saveTicket=this._ticket();let{documentElement:t}=e.detail;if(!t)return;this._log("snapshot-ready received, preparing to send");let i=this.identity.exportMap(t,D);this._savedSnapshot?.abort?.abort();let n={html:null,steps:null,copy:null,abort:null,identityMap:i,ticket:this._saveTicket,captureId:e.detail.captureId??null};if(e.detail.sliced){n.copy=Oe(t),n.abort=new AbortController;let{signal:r}=n.abort;Promise.all([import("./c-YYMZWQLR.js"),import("./c-ZWBI4HYK.js")]).then(([{serializeForSyncSteps:l},{runSliced:o}])=>{if(r.aborted||typeof n.html=="string")return;let a=(function*(){let h=yield*l(n.copy);n.html=h,n.steps=null})();return n.steps=a,o(a,{signal:r})}).catch(()=>{})}else n.html=T(t);this._savedSnapshot=n},document.addEventListener("clay:snapshot-ready",this._snapshotHandler)}_enqueueSend(e,t,i=null){if(!this._profile){this._queuedSend={html:e,identityMap:t,etag:i},this._resolveProfile().then(()=>this._flushQueuedSend());return}if(this._sendInFlight){this._queuedSend={html:e,identityMap:t,etag:i};return}this._postUpdate(e,t,i)}_flushQueuedSend(){if(this.isDestroyed||this._sendInFlight)return;let e=this._queuedSend;e&&(this._queuedSend=null,this._postUpdate(e.html,e.identityMap,e.etag))}_relayCommit(e=null,t=null){if(this.isDestroyed)return;let i=se(),n=this._savedSnapshot;if(n&&(n.captureId??null)!==(e??null)){this._log("Skipping send - snapshot belongs to a different capture");return}let r=n;if(this._savedSnapshot=null,r?.copy&&typeof r.html!="string")if(r.abort?.abort(),r.steps)for(let c=r.steps.next();!c.done;c=r.steps.next());else r.html=T(r.copy);if(!r||typeof r.html!="string")return;let l=r;if(typeof t=="string"){try{l=lt(r,t,this.identity)}catch(c){this._log(`Skipping send - page relay failed: ${c&&c.message}`);return}if(!l){this._log("Skipping send - accepted capture has no page article");return}}let o=Mt(e)??t,a=typeof o=="string"?We(o):0;l={...l,html:Pt(Ye(l.html,Math.max(Je(),a)),o)};let h=!i&&l.html===this.lastHtml;if(this._setPeerBase(l.html,l.identityMap,l.ticket),h){this._log("Skipping send - HTML unchanged");return}this._enqueueSend(l.html,l.identityMap,i||null)}_postUpdate(e,t,i=null,n=0){this._log(`Sending update (HTML length: ${e.length})`),this._sendInFlight=!0;let r=!1,l=this._profile||pe.legacy;fetch(new URL(l.relayPath,window.location.origin).href,{method:"POST",headers:{"Content-Type":"application/json",[l.documentHeader]:window.location.href,[ze]:String(1)},body:qt(l,e,this.clientId,t,i)}).then(o=>{o.ok||(console.warn("[LiveSync] Save returned status:",o.status),r=o.status>=500||o.status===408||o.status===429)}).catch(o=>{console.error("[LiveSync] Save failed:",o),this.onError&&this.onError(o),r=!0}).finally(()=>{this._sendInFlight=!1;let o=this._queuedSend;if(this._queuedSend=null,o){this._postUpdate(o.html,o.identityMap,o.etag);return}!r||!i||n>=3||this.isDestroyed||(this._sendInFlight=!0,setTimeout(()=>{if(this._sendInFlight=!1,this.isDestroyed)return;let a=this._queuedSend;this._queuedSend=null,a?this._postUpdate(a.html,a.identityMap,a.etag):this._postUpdate(e,t,i,n+1)},500*2**n))})}_startPresence(e,t){return this.isDestroyed||this._startGen!==t||this._presenceLease?null:e.connect({send:i=>this._postPresence(i)}).then(i=>this.isDestroyed||this._startGen!==t?(typeof i?.stop=="function"?i.stop():i?.detach(),null):(this._presenceLease=i||null,Ue("presence-editing")),()=>!1).then(i=>{if(!(!i||this.isDestroyed||this._startGen!==t||this._editing))return R().then(n=>{this.isDestroyed||this._startGen!==t||this._editing||(this._editing=new n.EditingSender({}),this._presenceQuiesced?this._editing.stop():(this._editing.start(),this._editing.roster(this._lastRoster)))})})}_postPresence(e){let t=new URL("/_/presence",window.location.origin);return t.searchParams.set("client-id",this.clientId),fetch(t.href,{method:"POST",headers:{"Content-Type":"application/json","Document-URL":window.location.href},body:JSON.stringify(e)}).then(i=>i.ok,()=>!1)}_maybeAcceptExternalChange(e){if(this.lane!=="live")return!1;let t=e.data;return t&&t.kind==="external-change"?(typeof t.html=="string"?this._enqueueExternal(t.html,e.seq,t.etag,t.by):this._fetchExternalChange(e.seq),!0):typeof e.msg=="string"&&e.msg.endsWith("changed on disk outside this tab")?(this._fetchExternalChange(e.seq),!0):!1}_enqueueExternal(e,t,i,n){if(typeof t=="number"){if(t<=this._lastExternalSeq){this._log(`Dropping replayed external change: seq=${t}`);return}this._lastExternalSeq=t}this._pendingExternal={html:e,seq:t,saveEpoch:this._saveEpoch,etag:typeof i=="string"&&i?i:null,by:n??null},this._scheduleNextFrame()}_fetchExternalChange(e){if(typeof e=="number"){if(e<=this._lastExternalSeq)return;this._lastExternalSeq=e}this._fetchServedDocument(e)}_fetchServedDocument(e,{attempt:t=0,repair:i=!1,startup:n=!1}={}){if(n&&(this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null)){this._retryStartup(t);return}let r=this._saveEpoch,l=this._startGen,o=this.lastSeenSeq,a=this._applyGen,h=++this._servedFetchId;i&&typeof e!="number"&&(e=this._lastExternalSeq),fetch(new URL(window.location.href),{cache:"no-store"}).then(c=>c.ok?c.text():null).then(c=>{if(this.isDestroyed||c==null||this._startGen!==l)return;let d=Ft(c),_=n||i&&!!d;if(_){if(h!==this._servedFetchId){i&&this._retryStartup(t+1,{repair:i,startup:n},typeof e=="number"?Math.max(e,this._lastExternalSeq):e);return}if(r!==this._saveEpoch||o!==this.lastSeenSeq||a!==this._applyGen||this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null){this._retryStartup(t+1,{repair:i,startup:n},e);return}if(d){if(d===re()){(i||n)&&this.lane==="saved"&&(this._represented=Object.freeze({bytes:c,etag:d,seq:e??null}));return}}else if(!i)return}else if(typeof e=="number"&&e<this._lastExternalSeq){i&&t<3&&this._fetchServedDocument(this._lastExternalSeq,{attempt:t+1,repair:i,startup:n});return}else if(this._saveEpoch>r){t<3&&(console.log("[LiveSync] Refetching external change: own save landed mid-fetch"),this._fetchServedDocument(e,{attempt:t+1,repair:i,startup:n}));return}this._pendingExternal={html:c,seq:e,saveEpoch:r,etag:d,by:null,fetchOptions:{repair:i,startup:n,attempt:t,versionCheck:_},startGen:l,seenSeq:o,applyGen:a,fetchId:h},this._scheduleNextFrame()}).catch(c=>{this._log("External-change fetch failed",c),typeof e=="number"&&this._lastExternalSeq===e&&(this._lastExternalSeq=e-1)})}_retryStartup(e=0,t={startup:!0},i){this.isDestroyed||e>3||(clearTimeout(this._startupRetry),this._startupRetry=setTimeout(()=>{if(this._startupRetry=null,!this.isDestroyed){if(this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null){this._retryStartup(e,t,i);return}this._fetchServedDocument(i,{...t,attempt:e})}},16))}applyUpdate(e,t,i,n,r){this.isDestroyed||(this._pendingHtml=e,this._pendingSeq=t,this._pendingIdentityMap=i,this._pendingEtag=n??null,this._pendingBy=r??null,this._scheduleNextFrame())}prepareHandoff(e={}){return this._handoff?Promise.resolve(this._handoff):this.isDestroyed?Promise.reject(new Error("LiveSync: stopped")):(this._handoffHeld=!0,this._rafHandle!=null&&(this._cancelFrame(this._rafHandle),this._rafHandle=null),import("./c-6LEYVQJK.js").then(({engineHandoff:t})=>t(this,e)).then(t=>this._handoff=t))}_scheduleNextFrame(){this.isDestroyed||this._handoffHeld||this._rafHandle==null&&(this._morphInFlight||(this._rafHandle=this._requestFrame(()=>this._runPending())))}async _runPending(){if(this._rafHandle=null,this.isDestroyed)return;if(!A()){this._morphInFlight=!0;try{await J()}catch(r){this._log("Merge engine failed to load",r),this._engineRetry=setTimeout(()=>this._scheduleNextFrame(),2e3);return}finally{this._morphInFlight=!1}if(this.isDestroyed)return}let e=this._pendingExternal,t=e?.fetchOptions||null,i=!!(t?.startup||t?.versionCheck),n=!1;if(e!=null&&(i&&this._pendingHtml!=null?n=!1:this._pendingHtml==null?n=!0:n=!(typeof e.seq=="number"&&typeof this._pendingSeq=="number"&&this._pendingSeq<e.seq)),n)if(this._pendingExternal=null,typeof e.seq=="number"&&e.seq<this._lastExternalSeq)i&&t?.repair?this._retryStartup((t.attempt||0)+1,t,this._lastExternalSeq):this._log("Dropping superseded external change at drain");else if(i&&e.startGen!==this._startGen)this._log("Dropping superseded startup check at drain");else if(i&&e.fetchId!==this._servedFetchId)t?.repair?this._retryStartup((t.attempt||0)+1,t,this._lastExternalSeq):this._log("Dropping superseded startup check at drain");else if(i&&(e.saveEpoch!==this._saveEpoch||e.seenSeq!==this.lastSeenSeq||e.applyGen!==this._applyGen))this._retryStartup((t.attempt||0)+1,t,e.seq);else if(i&&e.etag!=null&&e.etag===re())this._log("Startup check found the same version: nothing to apply");else if(!i&&e.saveEpoch!==this._saveEpoch)console.log("[LiveSync] Refetching external change: own save landed after queue"),this._fetchServedDocument(e.seq,t||{});else{this._morphInFlight=!0;try{await this._doApplyExternal(e.html,e.seq,e.etag,e.by,t)}catch(r){console.error("[LiveSync] applyExternal failed:",r)}finally{this._morphInFlight=!1}}else{let r=this._pendingHtml,l=this._pendingSeq,o=this._pendingIdentityMap,a=this._pendingEtag,h=this._pendingBy;if(this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingEtag=null,this._pendingBy=null,r==null)return;this._morphInFlight=!0;try{await this._doApplyUpdate(r,l,o,a,h)}catch(c){console.error("[LiveSync] applyUpdate failed:",c)}finally{this._morphInFlight=!1}}!this.isDestroyed&&(this._pendingHtml!=null||this._pendingExternal!=null)&&this._scheduleNextFrame()}_ticket(){return++this._agreeSeq}_setDiskBase(e,t){t<=this._diskBaseTicket||(this._diskBase=e,this._diskBaseTicket=t)}_setPeerBase(e,t,i){return i<this._peerBaseTicket?!1:(this._peerBaseTicket=i,this.lastHtml=e,this._lastIdentityMap=t&&typeof t=="object"&&!Array.isArray(t)?t:null,!0)}_requestFrame(e){if(ce()){if(typeof MessageChannel=="function"){let n=new MessageChannel,r=!0;return n.port1.onmessage=()=>{n.port1.close(),r&&e()},n.port2.postMessage(null),{cancel:()=>{r=!1,n.port1.close()}}}let i=setTimeout(e,0);return{cancel:()=>clearTimeout(i)}}if(typeof window<"u"&&typeof window.requestAnimationFrame=="function"){let i=window.requestAnimationFrame(e);return{cancel:()=>window.cancelAnimationFrame?.(i)}}let t=setTimeout(e,16);return{cancel:()=>clearTimeout(t)}}_cancelFrame(e){e?.cancel?.()}async _mergeIncoming(e,t,{base:i,baseIdentityMap:n=null,captureLocal:r,synthetic:l,source:o="peer",seq:a=null,etag:h=null,extra:c={}}){A()||await J();let{beginApply:d,completeApply:_,failApply:g,beginLineageCapture:E}=ht()||await V(),f,u=p=>{f=E(I.list());try{let v=A().HyperMorph.mergeDocument({...p,lineage:f.lineage});return f.returned(),v}catch(v){throw f.invalidate(I.list()),f.finish(I.list()),v}},S=this.identity,w=Te,b=Ht(new WeakMap),N=p=>me(p)?{first:b,map:p,then:b}:b,O=l?p=>b(p)||S.idOf(D(p)||p)||null:b,H=e,we=new Map;if(me(t)){H=new DOMParser().parseFromString(e,"text/html"),ie(H);let p=A().HyperMorph.importMap(H.documentElement,t);for(let v of H.querySelectorAll("[data-id], [id]")){let k=b(v),De=k&&p.get(v);De&&we.set(k,De)}}H=dt(H);let Z={live:document,remote:H,ignore:p=>p.matches(pt),opaque:p=>p.matches(_t)||z()&&qe(p),remoteWins:p=>p.matches(It),ignoreAttribute:(p,v,k)=>Tt(p,v,k)||z()&&Re(k||p,v),attributeMerge:ot,protectFocusedValue:!0,restoreFocus:document.activeElement?.localName!=="clay-editor-ui",keepLiveOnly:o==="peer",scripts:{mergeTags:A().mergeTagRecognizers},hooks:{beforeAttributeUpdated:w},...c},ke=this.lane==="live"&&x(),xe=he(),G,ee=null,C=null;if(i==null)G=u({...Z,base:null,local:{root:X(r()),toLive:D},identity:{local:O,remote:N(t)}});else if(ke){let p=r(),v=p.cloneNode(!0);ee=X(p),C=d({source:o,seq:a,etag:h,root:ee,recoveryRoot:v,domain:o==="disk"?"save":"sync"});try{G=u({...Z,base:dt(i),local:{root:ee,toLive:D},identity:{base:N(n),local:O,remote:N(t)}})}catch(k){throw g(C,k),k}}else{let p=X(r()),v=p.ownerDocument;v.documentElement!==p&&v.replaceChild(p,v.documentElement),G=u({...Z,base:v,local:{root:p,toLive:D},fastPath:!0,identity:{base:O,local:O,remote:N(t)}})}let U=this._ticket();this._morphTicket=U;let F;try{F=await G}catch(p){f.invalidate(I.list());try{C&&g(C,p,{ticket:U})}finally{f.finish(I.list())}throw p}let yt=he().gen!==xe.gen,be;try{f.prepareComplete(F,I.list()),be=C?_(C,F.conflicts,{ticket:U}):[]}finally{f.finish(I.list())}this.lane==="live"&&F.localDiverged?Ve():ke&&!F.localDiverged&&Xe(xe);let mt=new Set(me(t)?Object.values(t):[]);for(let[p,v]of F.identities){let k=mt.has(v)?v:we.get(v);k&&S.adopt(p,k)}return{report:F,ticket:U,typedDuringWait:yt,conflictIds:be}}_saveAfterMerge(e,t){(e||t)&&Ke()&&(y?y.savePageThrottled():Dt())}async _doApplyUpdate(e,t,i,n,r=null){if(ue(e)){await fe();return}this.lane==="live"&&!y&&await R(),this._log("applyUpdate - pausing mutations and morphing"),this.isPaused=!0;let l=window.scrollX,o=window.scrollY;q.pause(),oe();let a=!1,h=!1,c=!1;try{if(this.lane==="live"&&x()&&this.lastHtml===null){console.log("[LiveSync] Holding incoming update: unsaved local edits and no baseline to merge against"),this._setHeld("live",!0,null);let f=this._saveEpoch,u=this.lastSeenSeq;clearTimeout(this._holdRetryPeer),this._holdRetryPeer=setTimeout(()=>{this._holdRetryPeer=null,!(this.isDestroyed||this._pendingHtml!=null)&&this._saveEpoch===f&&this.lastSeenSeq===u&&(this._pendingHtml=e,this._pendingSeq=t,this._pendingIdentityMap=i,this._pendingBy=r,this._scheduleNextFrame())},3e3);return}this._setHeld("live",!1);let{report:d,ticket:_,typedDuringWait:g,conflictIds:E}=await this._mergeIncoming(e,i,{base:this.lastHtml,baseIdentityMap:this._lastIdentityMap,captureLocal:()=>M({flushUndo:!1}),synthetic:!0,source:"peer",seq:t,etag:n});if(a=d.localDiverged,h=g,ne(),window.scrollTo(l,o),this._setPeerBase(e,i,_),this._applyGen++,this._acceptedSaveTicket>_||(typeof n=="string"&&n?(P(n),c=!0):le()),this.lane==="live"&&!a&&!x()){let{forSave:f,forComparison:u,forDirty:S}=Y({emitForSync:!1,flushUndo:!1});y.setLastSavedBaselines(u,S),this._setDiskBase(f,this._ticket())}this.lane==="saved"&&(this._represented=Object.freeze({bytes:e,etag:n||null,seq:t??null})),document.dispatchEvent(new CustomEvent("clay:sync-applied",{detail:{seq:t,source:this.lane==="saved"?"disk":"peer",lane:this.lane,by:r||null,html:e,report:d,unresolved:this.unresolvedConflicts,conflictIds:E}}))}finally{this._log("applyUpdate - morph complete, resuming mutations"),q.resume(),ae(),await new Promise(d=>setTimeout(d,0)),this.isPaused=!1}c&&y?.conflictResolvedBySync(n),this._saveAfterMerge(a,h)}async _doApplyExternal(e,t,i=null,n=null,r=null){if(ue(e)){await fe();return}this.lane==="live"&&!y&&await R();let l=this._diskBase;this._log(`applyExternal - external disk change (seq=${t})`),this.isPaused=!0;let o=window.scrollX,a=window.scrollY;q.pause(),oe();let h=!1,c=!1,d=!1;try{if(this.lane==="live"&&x()&&this._diskBase===null){if(console.log("[LiveSync] Holding external change: unsaved local edits and no baseline to merge against"),this._setHeld("external",!0,null),r?.startup||r?.versionCheck){clearTimeout(this._holdRetryExt),this._holdRetryExt=setTimeout(()=>{if(this._holdRetryExt=null,this.isDestroyed)return;let S=typeof t=="number"?Math.max(t,this._lastExternalSeq):t;this._retryStartup(0,r,S)},3e3);return}let u=this._saveEpoch;clearTimeout(this._holdRetryExt),this._holdRetryExt=setTimeout(()=>{this._holdRetryExt=null,!(this.isDestroyed||this._pendingExternal!=null)&&(this._pendingExternal={html:e,seq:t,saveEpoch:u,etag:i,by:n},this._scheduleNextFrame())},3e3);return}this._setHeld("external",!1);let{report:_,ticket:g,typedDuringWait:E,conflictIds:f}=await this._mergeIncoming(e,null,{base:this._diskBase,captureLocal:()=>Ne().saveClone,synthetic:!1,source:"disk",seq:t,etag:i,extra:{beforeApply:u=>Ct(u.documentElement,this.lane)}});if(h=_.localDiverged,c=E,ne(),this._setDiskBase(e,g),window.scrollTo(o,a),this._acceptedSaveTicket>g||(typeof i=="string"&&i?(P(i),d=!0):le()),this.lane==="live"&&!h&&!x()){y.setLastSavedBaselines(...At()),y.setUnsavedChanges(!1);let u=M({flushUndo:!1});this._setPeerBase(T(u),this.identity.exportMap(u,D),g),this._applyGen++}this.lane==="saved"&&(this._represented=Object.freeze({bytes:e,etag:i||null,seq:t??null})),document.dispatchEvent(new CustomEvent("clay:sync-applied",{detail:{seq:t,source:"disk",etag:typeof i=="string"&&i?i:null,by:n||null,html:e,report:_,conflictIds:f,unresolved:this.unresolvedConflicts}}))}finally{this._log("applyExternal - morph complete, resuming mutations"),q.resume(),ae(),await new Promise(_=>setTimeout(_,0)),this.isPaused=!1}d&&y?.conflictResolvedBySync(i),this._saveAfterMerge(h,c),l!=null&&j(l)===j(e)&&y&&y.schedulePaintHeal(()=>this._diskBase==null?null:j(this._diskBase))}handleNotification({msgType:e,msg:t,action:i,persistent:n,data:r}){this._log(`Notification received: ${e} - ${t}`),e==="data-loss"||(n&&window.toastPersistent?window.toastPersistent(t,e):window.toast?window.toast(t,e):console.log(`[LiveSync] Notification: ${t}`)),document.dispatchEvent(new CustomEvent("clay:notification",{detail:{msgType:e,msg:t,action:i,persistent:n,data:r}})),this.onNotification&&this.onNotification({msgType:e,msg:t,action:i,persistent:n,data:r})}stop(){this.cleanup(),this.isDestroyed=!0,console.log("[LiveSync] Stopped")}editParticipant(){return R().then(e=>e.syncParticipant(this))}},K=null;Ge((s,e)=>{K=typeof s=="string"?{html:s,captureId:e?.captureId??null}:null});var Mt=s=>K&&(K.captureId??null)===(s??null)?K.html:null;function Pt(s,e){if(typeof e!="string"||e===s)return s;let t=i=>new DOMParser().parseFromString(i,"text/html").documentElement;return t(s).isEqualNode(t(e))?e:s}var Ee=new Se;typeof window<"u"&&!ut&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Ee.start()):Ee.start());var yn=(s,e,t)=>J().then(({morph:i})=>i(s,e,t));var mn=Ee;export{I as a,pt as b,It as c,Se as d,Ee as e,yn as f,mn as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=921600;function n(e){return[...String(e??"").matchAll(/(?<![\w\u00C0-\u024F.@\/:-])@([\w.-]*[/.][\w./-]*)/g)].map(t=>t[1].replace(/\.+$/,"")).filter(t=>t!=="page").filter(t=>/[/.]/.test(t))}function u(e){return/(?<![\w\u00C0-\u024F.@\/:-])@page(?![\w\/-]|\.\w)/.test(String(e??""))}export{r as a,n as b,u as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as Y}from"./c-3O7OBDCM.js";var me=500,ye=5e3,O="text";var _e=1024*1024,Se=256,Ae=1024*1024;function Be(){let s=globalThis.crypto?.randomUUID?.();return s||`wr-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}var W="clay-recovery-writer:";function Me(s){let a=globalThis.navigator?.locks;typeof a?.request=="function"&&a.request(W+s,()=>new Promise(()=>{})).catch(()=>{})}async function Te(s){let a=globalThis.navigator?.locks;if(typeof a?.query!="function")return new Set;try{let{held:p=[]}=await a.query();return new Set(p.map(f=>f.name).filter(f=>typeof f=="string"&&f.startsWith(W)).map(f=>f.slice(W.length)).filter(f=>f!==s))}catch{return new Set}}function D(s){return Array.isArray(s)?s.join("\0"):String(s)}function F(s,a){return Array.isArray(s)&&Array.isArray(a)?s.length===a.length&&s.every((p,f)=>p===a[f]):s===a}function Ue(s){return globalThis.crypto?.randomUUID?.()??`rec-${s}-${Math.random().toString(36).slice(2)}`}function C(s){return s instanceof Uint8Array?new Uint8Array(s):s instanceof ArrayBuffer?s.slice(0):s}function V(s,a){if(s===a)return!0;if(!s||!a||typeof s!="object"||typeof a!="object")return!1;if(s instanceof Uint8Array||a instanceof Uint8Array){if(!(s instanceof Uint8Array)||!(a instanceof Uint8Array)||s.length!==a.length)return!1;for(let g=0;g<s.length;g++)if(s[g]!==a[g])return!1;return!0}let p=Object.keys(a),f=Object.keys(s);if(p.length!==f.length)return!1;for(let g=0;g<p.length;g++)if(p[g]!==f[g]||a[p[g]]!==s[f[g]])return!1;return!0}var B=new Set;function xe({captureId:s,html:a}={}){if(B.size)for(let p of B)p.capture(s,a)}function De(s){if(!(!B.size||s==null))for(let a of B)a.pinCapture(s)}function qe(s,a){if(!(!B.size||s==null))for(let p of B)p.coverCapture(s,a)}function ze({captureId:s,ok:a=!1,etag:p=null}={}){if(B.size)for(let f of B)f.settle(s,a===!0,p)}function Ce({mode:s=Y==="draft"?"draft":"edit",writerId:a=Be(),indexedDB:p,maxScopeBytes:f,maxDbBytes:g,now:E}={}){let S=new Map,Q=new Set,q=new Map,z=new Map,R=null,P=null,h=null,A={ok:!0,code:null,durable:!1};Me(a);function _(){return{ok:A.ok,code:A.code,durable:A.durable,usage:h?.status().usage??null,identityMismatch:P?P.check().ok===!1:!1}}function w(e){let n={channel:e.channel,status:_(),count:e.pending.size,revisions:[...e.pending.values()].map(({id:t,revision:o})=>({id:t,revision:o}))};for(let t of e.listeners)try{t(n)}catch{}for(let t of Q)try{t(n)}catch{}}function b(e){if(e&&e.ok){let t=A.ok;if(A={ok:!0,code:null,durable:!0},!t)for(let o of S.values())w(o);return}let n=e?.code||"error";if(A.ok||A.code!==n){A={ok:!1,code:n,durable:!1};for(let t of S.values())w(t);return}A={ok:!1,code:n,durable:!1}}async function G(){let[{createIdentity:e},{createStore:n}]=await Promise.all([import("./c-B3JM5ZXC.js"),import("./c-R7LBFMF5.js")]);P=e({mode:s,writerId:a}),h=n({scope:P.scope,indexedDB:p,maxScopeBytes:f,maxDbBytes:g,now:E});let t=await h.open();return t.ok?A={ok:!0,code:null,durable:!1}:b(t),t}function m(){return R||(R=G().catch(e=>({ok:!1,code:e?.name==="DataCloneError"?"uncloneable":"unavailable"}))),R}function I(e,n){let t;try{t=e.readSaved(n)}catch{return[]}if(!t||typeof t.get!="function")return[];let o=[];for(let r of e.held.values())r.kind===O&&t.has(r.key)&&V(t.get(r.key),r.payload)&&o.push({id:r.id,revision:r.revision});return o}function J(e){let n=[];for(let t of S.values())if(!(typeof t.readSaved!="function"||!t.held.size))for(let o of t.held.values())o.kind===O&&n.push({channel:t.channel,key:o.key,id:o.id,revision:o.revision,payload:o.payload});n.length&&z.set(e,n)}function Z(e,n){let t=z.get(e);if(z.delete(e),!t||typeof n!="string")return;let o=new Map,r=new Map;for(let i of t){if(!o.has(i.channel)){let u=S.get(i.channel),d=null;try{d=typeof u?.readSaved=="function"?u.readSaved(n):null}catch{d=null}o.set(i.channel,d&&typeof d.get=="function"?d:null)}let l=o.get(i.channel);if(!l||!l.has(i.key)||!V(l.get(i.key),i.payload))continue;let c=r.get(i.channel)??[];c.push({id:i.id,revision:i.revision}),r.set(i.channel,c)}r.size&&q.set(e,r)}function ee(e,n){if(e==null||typeof n!="string")return;let t=new Map;for(let o of S.values()){if(typeof o.readSaved!="function"||!o.held.size)continue;let r=I(o,n);r.length&&t.set(o.channel,r)}t.size&&q.set(e,t)}async function ne(e,n,t,o){if((await m()).ok){for(let{id:i,revision:l}of n){let c=await h.acknowledge(i,{revision:l,etag:t,captureId:o});b(c);let u=D(i),d=e.held.get(u);d&&d.revision<=l&&e.held.delete(u)}w(e)}}function te(e,n,t){z.delete(e);let o=q.get(e);if(!o||(q.delete(e),!n))return Promise.resolve();let r=[];for(let[i,l]of o){let c=S.get(i);if(!c)continue;let u=()=>ne(c,l,t,e);c.writing=c.writing.then(u,u),r.push(c.writing)}return Promise.all(r).then(()=>{},()=>{})}function oe(e){let n=E?.()??Date.now();e.burstStart||(e.burstStart=n);let t=Math.max(0,Math.min(me,e.burstStart+ye-n));e.timer&&clearTimeout(e.timer),e.timer=setTimeout(()=>{e.timer=null,e.burstStart=0,$(e).catch(()=>{})},t)}function ie(e,{key:n,kind:t=O,baseEtag:o=null,base:r=null,payload:i=null,lineage:l=null}={}){let c=n==null?"":String(n);if(!c)throw new TypeError("clay.recovery.stage needs a key");let u=E?.()??Date.now(),d=++e.revision,k=t===O?[e.channel,c,a]:globalThis.crypto?.randomUUID?.()??`rec-${d}-${Math.random().toString(36).slice(2)}`,M=D(k),T=e.pending.get(M),y={id:k,kind:t,channel:e.channel,version:e.version,key:c,writerId:a,revision:d,status:"journaled",baseEtag:o,base:C(r),payload:C(i),lineage:l,created:T?.created??u,updated:u};return e.pending.set(M,y),e.held.set(M,{id:k,kind:t,key:c,revision:d,payload:y.payload}),oe(e),w(e),{id:k,revision:d}}async function re(e){let n=[...e.pending.values()];if(!n.length)return{ok:!0,stored:[]};let t=await m();if(!t.ok)return{ok:!1,code:t.code};let o=[],r=null;for(let i of n){let l=await h.put(i);if(l.ok){let c=D(i.id);if(e.pending.get(c)===i&&e.pending.delete(c),l.skipped){let u=e.held.get(c);u&&u.revision===i.revision&&e.held.delete(c)}else o.push({id:i.id,revision:i.revision})}else r=r||l.code||"error"}return b(r?{ok:!1,code:r}:{ok:!0}),w(e),r?{ok:!1,code:r}:{ok:!0,stored:o}}function X(e,n){return[e.channel,n,a]}function se(e,n,t,o,r){return{id:n,kind:"binary",channel:e.channel,version:e.version,writerId:a,revision:0,context:t,payload:{base:r??new Uint8Array(0),dependencies:new Uint8Array(0),owned:new Uint8Array(0)},acknowledged:null,created:o,updated:o}}function H(e,n,t){return e.batchQueue.size>=Se||e.queuedBytes+n.payload.byteLength>Ae?!1:(e.batchQueue.set(D(n.id),{record:n,capsule:t}),e.queuedBytes+=n.payload.byteLength,!0)}async function ce(e){if(!e.batchQueue.size)return{ok:!0};let n=await m();if(!n.ok)return{ok:!1,code:n.code};let t=[],o=null;for(let[r,i]of[...e.batchQueue.entries()]){let l=await h.appendBinary(i.record,i.capsule);if(!l.ok){o=o||l.code||"error";continue}e.batchQueue.delete(r),e.queuedBytes=Math.max(0,e.queuedBytes-i.record.payload.byteLength),!l.skipped&&(e.batches+=1,e.batchBytes+=i.record.payload.byteLength,t.push({id:i.record.id,revision:i.record.revision}))}return b(o?{ok:!1,code:o}:{ok:!0}),w(e),o?{ok:!1,code:o}:{ok:!0,stored:t}}async function ae(e,{key:n,context:t=null,update:o,origin:r="local",base:i=null}={}){let l=n==null?"":String(n);if(!l)throw new TypeError("clay.recovery.append needs a key");if(!(o instanceof Uint8Array)&&!(o instanceof ArrayBuffer))throw new TypeError("clay.recovery.append needs binary bytes");let c=E?.()??Date.now(),u=++e.revision,d=X(e,l),k={id:Ue(u),kind:"binary-batch",channel:e.channel,version:e.version,writerId:a,revision:u,capsuleId:d,origin:r==="dependency"?"dependency":"local",context:t,payload:C(o),updated:c},M=se(e,d,t,c,i==null?null:C(i)),T=await m();if(!T.ok)return H(e,k,M)?{ok:!1,code:T.code}:{ok:!1,code:"over-budget"};let y=await h.appendBinary(k,M);return b(y),w(e),y.ok?(e.batches+=1,e.batchBytes+=k.payload.byteLength,y.skipped?{ok:!0,id:k.id,revision:u,skipped:!0}:{ok:!0,id:k.id,revision:u}):H(e,k,M)?{ok:!1,code:y.code}:{ok:!1,code:y.code}}async function le(e,{records:n=[],authority:t=null,epoch:o=null,sequence:r=null}={}){let i=(n||[]).filter(u=>u&&u.id!==void 0&&typeof u.revision=="number");if(!i.length)return{ok:!0,acknowledged:0};let l=await m();if(!l.ok)return{ok:!1,code:l.code};let c=await h.acknowledgeBinary({channel:e.channel,version:e.version,writerId:a,records:i,authority:t,epoch:o,sequence:r});return b(c),w(e),c.ok?{ok:!0,acknowledged:c.acknowledged}:{ok:!1,code:c.code}}async function ue(e,{records:n=[],proof:t=null}={}){let o=(n||[]).filter(u=>u&&u.id!==void 0&&typeof u.revision=="number");if(!o.length)return{ok:!0,retired:[]};if(typeof e.validateCheckpoint!="function")return{ok:!0,retired:[]};let r;try{r=await e.validateCheckpoint(t,o.map(({id:u,revision:d})=>({id:u,revision:d})))}catch{return{ok:!1,code:"invalid",retired:[]}}if(!Array.isArray(r))return{ok:!1,code:"invalid",retired:[]};let i=o.filter(u=>r.some(d=>d&&d.revision===u.revision&&F(d.id,u.id)));if(!i.length)return{ok:!0,retired:[]};let l=await m();if(!l.ok)return{ok:!1,code:l.code,retired:[]};let c=await h.checkpointBinary({channel:e.channel,version:e.version,writerId:a,records:i});return b(c),w(e),c.ok?{ok:!0,retired:c.retired}:{ok:!1,code:c.code,retired:[]}}function L(e){return e&&typeof e.byteLength=="number"&&e.byteLength>0?e:null}async function K(e,n,t=null){for(let o=0;o<3;o++){let r=t?.capsuleId??null,i=[];for(let{id:v,revision:be}of n){let j=await h.get(v);if(!j.ok||!j.record)continue;let U=j.record;U.revision!==be||U.kind!=="binary-batch"||!U.capsuleId||(r||(r=U.capsuleId),F(r,U.capsuleId)&&i.push(U))}if(!r||!(i.length||t))return{ok:!0,retired:[]};let l=await h.get(r);if(!l.ok||!l.record)return{ok:!1,code:"missing"};let c=l.record,u=[L(c.payload?.owned),...i.filter(v=>v.origin!=="dependency").map(v=>L(v.payload))].filter(Boolean),d=[L(c.payload?.dependencies),...i.filter(v=>v.origin==="dependency").map(v=>L(v.payload))].filter(Boolean),k=u.length?C(await e.merge(u)):new Uint8Array(0),M=d.length?C(await e.merge(d)):new Uint8Array(0),T={base:c.payload?.base??new Uint8Array(0),dependencies:M,owned:k};t&&(T=await t.rebuild(T));let y=Math.max(e.revision,c.revision)+1;e.revision=y;let x=await h.compactBinary({channel:e.channel,version:e.version,capsuleId:r,expectedRevision:c.revision,replacement:{revision:y,updated:E?.()??Date.now(),context:t?.context,payload:T},inputs:i.map(v=>({id:v.id,revision:v.revision}))});if(x.ok)return i.length&&(e.batches=e.batchBytes=0),{ok:!0,retired:x.retired,revision:x.revision};if(x.code!=="stale")return{ok:!1,code:x.code}}return{ok:!1,code:"stale"}}async function de(e,{records:n=[]}={}){if(typeof e.merge!="function")return{ok:!1,code:"invalid",retired:[]};let t=(n||[]).filter(i=>i&&i.id!==void 0&&typeof i.revision=="number");if(!t.length)return{ok:!0,retired:[]};let o=await m();if(!o.ok)return{ok:!1,code:o.code,retired:[]};let r=await K(e,t);return b(r),w(e),r.ok?{ok:!0,retired:r.retired}:{ok:!1,code:r.code,retired:[]}}async function fe(e,{key:n,context:t,rebuild:o}={}){let r=await m(),i=r.ok?await K(e,[],{capsuleId:X(e,String(n)),context:t,rebuild:o}):r;return b(i),i}function $(e){e.timer&&clearTimeout(e.timer),e.timer=null,e.burstStart=0;let n=async()=>{let t=await ce(e);return t.ok?re(e):t};return e.writing=e.writing.then(n,n),e.writing}async function pe(e){let n=await m();if(!n.ok)return{ok:!1,code:n.code,records:[],status:_()};let t=await h.list();if(b(t),!t.ok)return{ok:!1,code:t.code,records:[],status:_()};let o=await Te(a);return{ok:!0,records:t.records.filter(i=>i.channel===e.channel&&!o.has(i.writerId)).map(i=>({...i,supported:i.version===e.version})),status:_()}}async function he(e,n,{revision:t}={}){let o=await m();if(!o.ok)return{ok:!1,code:o.code};e.timer&&clearTimeout(e.timer),e.timer=null,e.burstStart=0,await e.writing;let r=D(n),i=e.pending.get(r);i&&(t===void 0||i.revision===t)&&e.pending.delete(r);let l=e.held.get(r);l&&(t===void 0||l.revision===t)&&e.held.delete(r);let c=await h.remove(n,{revision:t});return b(c),w(e),c.ok?{ok:!0,id:n,revision:t}:{ok:!1,code:c.code}}function ke(e,n){return e.listeners.add(n),()=>e.listeners.delete(n)}function ge(e){e.timer&&clearTimeout(e.timer),e.timer=null,e.burstStart=0;let n=$(e).catch(()=>({ok:!1,code:"aborted"}));return e.listeners.clear(),S.delete(e.channel),S.size||B.delete(N),n}let N={capture:ee,settle:te,pinCapture:J,coverCapture:Z};function ve(e){return{channel:e.channel,version:e.version,stage:n=>ie(e,n),flush:()=>$(e),list:()=>pe(e),dismiss:(n,t)=>he(e,n,t),append:n=>ae(e,n),markAcknowledged:n=>le(e,n),checkpoint:n=>ue(e,n),compact:n=>de(e,n),rebase:n=>fe(e,n),subscribe:n=>ke(e,n),dispose:()=>ge(e)}}function we({channel:e,version:n=1,readSaved:t=null,describe:o=null,validateCheckpoint:r=null,merge:i=null}={}){if(!e||typeof e!="string")throw new TypeError("clay.recovery.register needs a channel name");let l=S.get(e);if(l)throw new Error(`clay.recovery: the "${e}" channel is already registered at version ${l.version}`);let c={channel:e,version:n,readSaved:t,describe:o,validateCheckpoint:r,merge:i,revision:0,pending:new Map,held:new Map,batchQueue:new Map,queuedBytes:0,batches:0,batchBytes:0,compaction:null,timer:null,burstStart:0,writing:Promise.resolve(),listeners:new Set};return S.set(e,c),B.add(N),m(),ve(c)}return{register:we,status:_,subscribe(e){return Q.add(e),()=>Q.delete(e)}}}var Pe=Ce();export{xe as a,De as b,qe as c,ze as d,Ce as e,Pe as f};
|
|
1
|
+
import{g as Y}from"./c-EDE45NM7.js";var me=500,ye=5e3,O="text";var _e=1024*1024,Se=256,Ae=1024*1024;function Be(){let s=globalThis.crypto?.randomUUID?.();return s||`wr-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}var W="clay-recovery-writer:";function Me(s){let a=globalThis.navigator?.locks;typeof a?.request=="function"&&a.request(W+s,()=>new Promise(()=>{})).catch(()=>{})}async function Te(s){let a=globalThis.navigator?.locks;if(typeof a?.query!="function")return new Set;try{let{held:p=[]}=await a.query();return new Set(p.map(f=>f.name).filter(f=>typeof f=="string"&&f.startsWith(W)).map(f=>f.slice(W.length)).filter(f=>f!==s))}catch{return new Set}}function D(s){return Array.isArray(s)?s.join("\0"):String(s)}function F(s,a){return Array.isArray(s)&&Array.isArray(a)?s.length===a.length&&s.every((p,f)=>p===a[f]):s===a}function Ue(s){return globalThis.crypto?.randomUUID?.()??`rec-${s}-${Math.random().toString(36).slice(2)}`}function C(s){return s instanceof Uint8Array?new Uint8Array(s):s instanceof ArrayBuffer?s.slice(0):s}function V(s,a){if(s===a)return!0;if(!s||!a||typeof s!="object"||typeof a!="object")return!1;if(s instanceof Uint8Array||a instanceof Uint8Array){if(!(s instanceof Uint8Array)||!(a instanceof Uint8Array)||s.length!==a.length)return!1;for(let g=0;g<s.length;g++)if(s[g]!==a[g])return!1;return!0}let p=Object.keys(a),f=Object.keys(s);if(p.length!==f.length)return!1;for(let g=0;g<p.length;g++)if(p[g]!==f[g]||a[p[g]]!==s[f[g]])return!1;return!0}var B=new Set;function xe({captureId:s,html:a}={}){if(B.size)for(let p of B)p.capture(s,a)}function De(s){if(!(!B.size||s==null))for(let a of B)a.pinCapture(s)}function qe(s,a){if(!(!B.size||s==null))for(let p of B)p.coverCapture(s,a)}function ze({captureId:s,ok:a=!1,etag:p=null}={}){if(B.size)for(let f of B)f.settle(s,a===!0,p)}function Ce({mode:s=Y==="draft"?"draft":"edit",writerId:a=Be(),indexedDB:p,maxScopeBytes:f,maxDbBytes:g,now:E}={}){let S=new Map,Q=new Set,q=new Map,z=new Map,R=null,P=null,h=null,A={ok:!0,code:null,durable:!1};Me(a);function _(){return{ok:A.ok,code:A.code,durable:A.durable,usage:h?.status().usage??null,identityMismatch:P?P.check().ok===!1:!1}}function w(e){let n={channel:e.channel,status:_(),count:e.pending.size,revisions:[...e.pending.values()].map(({id:t,revision:o})=>({id:t,revision:o}))};for(let t of e.listeners)try{t(n)}catch{}for(let t of Q)try{t(n)}catch{}}function b(e){if(e&&e.ok){let t=A.ok;if(A={ok:!0,code:null,durable:!0},!t)for(let o of S.values())w(o);return}let n=e?.code||"error";if(A.ok||A.code!==n){A={ok:!1,code:n,durable:!1};for(let t of S.values())w(t);return}A={ok:!1,code:n,durable:!1}}async function G(){let[{createIdentity:e},{createStore:n}]=await Promise.all([import("./c-B3JM5ZXC.js"),import("./c-R7LBFMF5.js")]);P=e({mode:s,writerId:a}),h=n({scope:P.scope,indexedDB:p,maxScopeBytes:f,maxDbBytes:g,now:E});let t=await h.open();return t.ok?A={ok:!0,code:null,durable:!1}:b(t),t}function m(){return R||(R=G().catch(e=>({ok:!1,code:e?.name==="DataCloneError"?"uncloneable":"unavailable"}))),R}function I(e,n){let t;try{t=e.readSaved(n)}catch{return[]}if(!t||typeof t.get!="function")return[];let o=[];for(let r of e.held.values())r.kind===O&&t.has(r.key)&&V(t.get(r.key),r.payload)&&o.push({id:r.id,revision:r.revision});return o}function J(e){let n=[];for(let t of S.values())if(!(typeof t.readSaved!="function"||!t.held.size))for(let o of t.held.values())o.kind===O&&n.push({channel:t.channel,key:o.key,id:o.id,revision:o.revision,payload:o.payload});n.length&&z.set(e,n)}function Z(e,n){let t=z.get(e);if(z.delete(e),!t||typeof n!="string")return;let o=new Map,r=new Map;for(let i of t){if(!o.has(i.channel)){let u=S.get(i.channel),d=null;try{d=typeof u?.readSaved=="function"?u.readSaved(n):null}catch{d=null}o.set(i.channel,d&&typeof d.get=="function"?d:null)}let l=o.get(i.channel);if(!l||!l.has(i.key)||!V(l.get(i.key),i.payload))continue;let c=r.get(i.channel)??[];c.push({id:i.id,revision:i.revision}),r.set(i.channel,c)}r.size&&q.set(e,r)}function ee(e,n){if(e==null||typeof n!="string")return;let t=new Map;for(let o of S.values()){if(typeof o.readSaved!="function"||!o.held.size)continue;let r=I(o,n);r.length&&t.set(o.channel,r)}t.size&&q.set(e,t)}async function ne(e,n,t,o){if((await m()).ok){for(let{id:i,revision:l}of n){let c=await h.acknowledge(i,{revision:l,etag:t,captureId:o});b(c);let u=D(i),d=e.held.get(u);d&&d.revision<=l&&e.held.delete(u)}w(e)}}function te(e,n,t){z.delete(e);let o=q.get(e);if(!o||(q.delete(e),!n))return Promise.resolve();let r=[];for(let[i,l]of o){let c=S.get(i);if(!c)continue;let u=()=>ne(c,l,t,e);c.writing=c.writing.then(u,u),r.push(c.writing)}return Promise.all(r).then(()=>{},()=>{})}function oe(e){let n=E?.()??Date.now();e.burstStart||(e.burstStart=n);let t=Math.max(0,Math.min(me,e.burstStart+ye-n));e.timer&&clearTimeout(e.timer),e.timer=setTimeout(()=>{e.timer=null,e.burstStart=0,$(e).catch(()=>{})},t)}function ie(e,{key:n,kind:t=O,baseEtag:o=null,base:r=null,payload:i=null,lineage:l=null}={}){let c=n==null?"":String(n);if(!c)throw new TypeError("clay.recovery.stage needs a key");let u=E?.()??Date.now(),d=++e.revision,k=t===O?[e.channel,c,a]:globalThis.crypto?.randomUUID?.()??`rec-${d}-${Math.random().toString(36).slice(2)}`,M=D(k),T=e.pending.get(M),y={id:k,kind:t,channel:e.channel,version:e.version,key:c,writerId:a,revision:d,status:"journaled",baseEtag:o,base:C(r),payload:C(i),lineage:l,created:T?.created??u,updated:u};return e.pending.set(M,y),e.held.set(M,{id:k,kind:t,key:c,revision:d,payload:y.payload}),oe(e),w(e),{id:k,revision:d}}async function re(e){let n=[...e.pending.values()];if(!n.length)return{ok:!0,stored:[]};let t=await m();if(!t.ok)return{ok:!1,code:t.code};let o=[],r=null;for(let i of n){let l=await h.put(i);if(l.ok){let c=D(i.id);if(e.pending.get(c)===i&&e.pending.delete(c),l.skipped){let u=e.held.get(c);u&&u.revision===i.revision&&e.held.delete(c)}else o.push({id:i.id,revision:i.revision})}else r=r||l.code||"error"}return b(r?{ok:!1,code:r}:{ok:!0}),w(e),r?{ok:!1,code:r}:{ok:!0,stored:o}}function X(e,n){return[e.channel,n,a]}function se(e,n,t,o,r){return{id:n,kind:"binary",channel:e.channel,version:e.version,writerId:a,revision:0,context:t,payload:{base:r??new Uint8Array(0),dependencies:new Uint8Array(0),owned:new Uint8Array(0)},acknowledged:null,created:o,updated:o}}function H(e,n,t){return e.batchQueue.size>=Se||e.queuedBytes+n.payload.byteLength>Ae?!1:(e.batchQueue.set(D(n.id),{record:n,capsule:t}),e.queuedBytes+=n.payload.byteLength,!0)}async function ce(e){if(!e.batchQueue.size)return{ok:!0};let n=await m();if(!n.ok)return{ok:!1,code:n.code};let t=[],o=null;for(let[r,i]of[...e.batchQueue.entries()]){let l=await h.appendBinary(i.record,i.capsule);if(!l.ok){o=o||l.code||"error";continue}e.batchQueue.delete(r),e.queuedBytes=Math.max(0,e.queuedBytes-i.record.payload.byteLength),!l.skipped&&(e.batches+=1,e.batchBytes+=i.record.payload.byteLength,t.push({id:i.record.id,revision:i.record.revision}))}return b(o?{ok:!1,code:o}:{ok:!0}),w(e),o?{ok:!1,code:o}:{ok:!0,stored:t}}async function ae(e,{key:n,context:t=null,update:o,origin:r="local",base:i=null}={}){let l=n==null?"":String(n);if(!l)throw new TypeError("clay.recovery.append needs a key");if(!(o instanceof Uint8Array)&&!(o instanceof ArrayBuffer))throw new TypeError("clay.recovery.append needs binary bytes");let c=E?.()??Date.now(),u=++e.revision,d=X(e,l),k={id:Ue(u),kind:"binary-batch",channel:e.channel,version:e.version,writerId:a,revision:u,capsuleId:d,origin:r==="dependency"?"dependency":"local",context:t,payload:C(o),updated:c},M=se(e,d,t,c,i==null?null:C(i)),T=await m();if(!T.ok)return H(e,k,M)?{ok:!1,code:T.code}:{ok:!1,code:"over-budget"};let y=await h.appendBinary(k,M);return b(y),w(e),y.ok?(e.batches+=1,e.batchBytes+=k.payload.byteLength,y.skipped?{ok:!0,id:k.id,revision:u,skipped:!0}:{ok:!0,id:k.id,revision:u}):H(e,k,M)?{ok:!1,code:y.code}:{ok:!1,code:y.code}}async function le(e,{records:n=[],authority:t=null,epoch:o=null,sequence:r=null}={}){let i=(n||[]).filter(u=>u&&u.id!==void 0&&typeof u.revision=="number");if(!i.length)return{ok:!0,acknowledged:0};let l=await m();if(!l.ok)return{ok:!1,code:l.code};let c=await h.acknowledgeBinary({channel:e.channel,version:e.version,writerId:a,records:i,authority:t,epoch:o,sequence:r});return b(c),w(e),c.ok?{ok:!0,acknowledged:c.acknowledged}:{ok:!1,code:c.code}}async function ue(e,{records:n=[],proof:t=null}={}){let o=(n||[]).filter(u=>u&&u.id!==void 0&&typeof u.revision=="number");if(!o.length)return{ok:!0,retired:[]};if(typeof e.validateCheckpoint!="function")return{ok:!0,retired:[]};let r;try{r=await e.validateCheckpoint(t,o.map(({id:u,revision:d})=>({id:u,revision:d})))}catch{return{ok:!1,code:"invalid",retired:[]}}if(!Array.isArray(r))return{ok:!1,code:"invalid",retired:[]};let i=o.filter(u=>r.some(d=>d&&d.revision===u.revision&&F(d.id,u.id)));if(!i.length)return{ok:!0,retired:[]};let l=await m();if(!l.ok)return{ok:!1,code:l.code,retired:[]};let c=await h.checkpointBinary({channel:e.channel,version:e.version,writerId:a,records:i});return b(c),w(e),c.ok?{ok:!0,retired:c.retired}:{ok:!1,code:c.code,retired:[]}}function L(e){return e&&typeof e.byteLength=="number"&&e.byteLength>0?e:null}async function K(e,n,t=null){for(let o=0;o<3;o++){let r=t?.capsuleId??null,i=[];for(let{id:v,revision:be}of n){let j=await h.get(v);if(!j.ok||!j.record)continue;let U=j.record;U.revision!==be||U.kind!=="binary-batch"||!U.capsuleId||(r||(r=U.capsuleId),F(r,U.capsuleId)&&i.push(U))}if(!r||!(i.length||t))return{ok:!0,retired:[]};let l=await h.get(r);if(!l.ok||!l.record)return{ok:!1,code:"missing"};let c=l.record,u=[L(c.payload?.owned),...i.filter(v=>v.origin!=="dependency").map(v=>L(v.payload))].filter(Boolean),d=[L(c.payload?.dependencies),...i.filter(v=>v.origin==="dependency").map(v=>L(v.payload))].filter(Boolean),k=u.length?C(await e.merge(u)):new Uint8Array(0),M=d.length?C(await e.merge(d)):new Uint8Array(0),T={base:c.payload?.base??new Uint8Array(0),dependencies:M,owned:k};t&&(T=await t.rebuild(T));let y=Math.max(e.revision,c.revision)+1;e.revision=y;let x=await h.compactBinary({channel:e.channel,version:e.version,capsuleId:r,expectedRevision:c.revision,replacement:{revision:y,updated:E?.()??Date.now(),context:t?.context,payload:T},inputs:i.map(v=>({id:v.id,revision:v.revision}))});if(x.ok)return i.length&&(e.batches=e.batchBytes=0),{ok:!0,retired:x.retired,revision:x.revision};if(x.code!=="stale")return{ok:!1,code:x.code}}return{ok:!1,code:"stale"}}async function de(e,{records:n=[]}={}){if(typeof e.merge!="function")return{ok:!1,code:"invalid",retired:[]};let t=(n||[]).filter(i=>i&&i.id!==void 0&&typeof i.revision=="number");if(!t.length)return{ok:!0,retired:[]};let o=await m();if(!o.ok)return{ok:!1,code:o.code,retired:[]};let r=await K(e,t);return b(r),w(e),r.ok?{ok:!0,retired:r.retired}:{ok:!1,code:r.code,retired:[]}}async function fe(e,{key:n,context:t,rebuild:o}={}){let r=await m(),i=r.ok?await K(e,[],{capsuleId:X(e,String(n)),context:t,rebuild:o}):r;return b(i),i}function $(e){e.timer&&clearTimeout(e.timer),e.timer=null,e.burstStart=0;let n=async()=>{let t=await ce(e);return t.ok?re(e):t};return e.writing=e.writing.then(n,n),e.writing}async function pe(e){let n=await m();if(!n.ok)return{ok:!1,code:n.code,records:[],status:_()};let t=await h.list();if(b(t),!t.ok)return{ok:!1,code:t.code,records:[],status:_()};let o=await Te(a);return{ok:!0,records:t.records.filter(i=>i.channel===e.channel&&!o.has(i.writerId)).map(i=>({...i,supported:i.version===e.version})),status:_()}}async function he(e,n,{revision:t}={}){let o=await m();if(!o.ok)return{ok:!1,code:o.code};e.timer&&clearTimeout(e.timer),e.timer=null,e.burstStart=0,await e.writing;let r=D(n),i=e.pending.get(r);i&&(t===void 0||i.revision===t)&&e.pending.delete(r);let l=e.held.get(r);l&&(t===void 0||l.revision===t)&&e.held.delete(r);let c=await h.remove(n,{revision:t});return b(c),w(e),c.ok?{ok:!0,id:n,revision:t}:{ok:!1,code:c.code}}function ke(e,n){return e.listeners.add(n),()=>e.listeners.delete(n)}function ge(e){e.timer&&clearTimeout(e.timer),e.timer=null,e.burstStart=0;let n=$(e).catch(()=>({ok:!1,code:"aborted"}));return e.listeners.clear(),S.delete(e.channel),S.size||B.delete(N),n}let N={capture:ee,settle:te,pinCapture:J,coverCapture:Z};function ve(e){return{channel:e.channel,version:e.version,stage:n=>ie(e,n),flush:()=>$(e),list:()=>pe(e),dismiss:(n,t)=>he(e,n,t),append:n=>ae(e,n),markAcknowledged:n=>le(e,n),checkpoint:n=>ue(e,n),compact:n=>de(e,n),rebase:n=>fe(e,n),subscribe:n=>ke(e,n),dispose:()=>ge(e)}}function we({channel:e,version:n=1,readSaved:t=null,describe:o=null,validateCheckpoint:r=null,merge:i=null}={}){if(!e||typeof e!="string")throw new TypeError("clay.recovery.register needs a channel name");let l=S.get(e);if(l)throw new Error(`clay.recovery: the "${e}" channel is already registered at version ${l.version}`);let c={channel:e,version:n,readSaved:t,describe:o,validateCheckpoint:r,merge:i,revision:0,pending:new Map,held:new Map,batchQueue:new Map,queuedBytes:0,batches:0,batchBytes:0,compaction:null,timer:null,burstStart:0,writing:Promise.resolve(),listeners:new Set};return S.set(e,c),B.add(N),m(),ve(c)}return{register:we,status:_,subscribe(e){return Q.add(e),()=>Q.delete(e)}}}var Pe=Ce();export{xe as a,De as b,qe as c,ze as d,Ce as e,Pe as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h}from"./c-
|
|
1
|
+
import{a,b,c,d,e,f,g,h}from"./c-6IJEVE6B.js";import"./c-QQFHEODI.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{b as conditionalSaves,f as forgetEtag,e as forgetRepresentedEtag,a as lastSeenEtag,g as learnConditionalSaves,c as recordEtag,d as representedEtag,h as seedEtag};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as h}from"./c-Q6BG3ZLO.js";import{i as k,j as y}from"./c-CV4T65JE.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-DD26VXAP.js";import"./c-CTGRDT6E.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as g}from"./c-ZRGEN6QQ.js";import{d}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{b as m}from"./c-RETTCOWO.js";import"./c-WCG6AKA7.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var b=e=>String(e).padStart(2,"0");function A(e){if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let s=new Date(`${e}T12:00:00Z`);return Number.isFinite(s.valueOf())&&s.toISOString().slice(0,10)===e}var $=(e=new Date)=>`${e.getFullYear()}-${b(e.getMonth()+1)}-${b(e.getDate())}`,E=(e,s)=>{let a=new Date(`${e}T12:00:00Z`);return a.setUTCDate(a.getUTCDate()+s),a.toISOString().slice(0,10)},I=e=>{let s=E(e,1);return[{id:"today",name:`Today (${e})`,date:e},{id:"tomorrow",name:`Tomorrow (${s})`,date:s}]};function L({view:e=null}={}){if(!e)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let s=e.dom.ownerDocument,a=null;function l(t){let o=e.state;if(!o.selection.empty||o.selection.from!==t.from||t.from<0||t.from>o.doc.content.size)return null;let r=o.doc.resolve(t.from);return!r.parent.isTextblock||r.parent.type.spec.code||!r.parent.type.allowsMarkType(d.marks.date)?null:t.from}function D(t){try{let o=e.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=e.coordsAtPos(t.from);return{x:Math.max(8,r.left-o.left),y:r.bottom+6-o.top}}catch{return null}}function u(t){let o=t.picker.activeId();o?e.dom.setAttribute("aria-activedescendant",o):e.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&e.dom.removeAttribute("aria-activedescendant")}function c(){let t=a;if(t){a=null;for(let[o,r,n,i]of t.listen)o.removeEventListener(r,n,i);e.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&e.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function x(t,o){let r=String(o),n=e.state.tr.insertText(r,t,t);return n.addMark(t,t+r.length,d.marks.date.create({date:r})),n.insertText(" ",t+r.length),n.setSelection(m.TextSelection.create(n.doc,t+r.length+1)),e.dispatch(g(n)),e.focus(),{ok:!0,date:r}}async function f(t){let o=a;if(!o)return{ok:!1,code:"not-editing"};let r=o.picker.personAt(t),n=l(o);return n===null||!r||!A(r.date)?(c(),r?n===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-date"}:{ok:!1,code:"no-date"}):(c(),k(e,()=>{let i=l(o);return i===null?{ok:!1,code:"stale-target"}:x(i,r.date)}))}function S(t){let o=a;if(!o||y(t,e))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),o.picker.move(t.key==="ArrowDown"?1:-1),u(o)):t.key==="Enter"?(r(),f(o.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),c())}function T(){c();let t={from:e.state.selection.from,days:I($()),picker:null,listen:[]};t.picker=h({document:s,label:"Insert a date",empty:"No date to insert",onPick:r=>f(r)}),a=t;let o=(r,n,i,p)=>{r.addEventListener(n,i,p),t.listen.push([r,n,i,p])};return o(s,"keydown",r=>S(r),!0),o(e.dom,"input",()=>c()),o(s,"mousedown",r=>{t.picker.el.contains(r.target)||c()},!0),(e.dom.parentElement??s.body).appendChild(t.picker.el),l(t)===null?(c(),{ok:!1,code:"stale-target"}):(t.picker.show(t.days,D(t)),u(t),{ok:!0,picker:!0})}return{async run(){return T()},dispose(){c()}}}export{L as createFeature,I as earlyDays,A as isISODate,$ as localISODate};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{b as F,c as M}from"./c-DD26VXAP.js";import{C as N,d as $}from"./c-ZRGEN6QQ.js";import{A,b as X,c as Y,d as w,x as U}from"./c-OH2FPYSY.js";import{b as P}from"./c-QY7F6EN6.js";import"./c-RETTCOWO.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var y=5;function v(n){let u=0;for(let i=0;i<n.childCount;i++){let s=n.child(i);if(s.type===w.nodes.heading&&s.attrs.level===1&&s.attrs.parent==null)return{index:i,at:u,node:s};u+=s.nodeSize}return null}var O=`
|
|
2
|
+
:host{font:inherit !important;color:inherit !important}
|
|
3
|
+
.blockeditor-cover-panel{display:flex;align-items:center;gap:8px;margin:8px 0;padding:6px 10px;border:1px solid var(--blockeditor-pop-line);border-radius:8px;background:var(--blockeditor-pop-bg);color:var(--blockeditor-pop-ink);box-shadow:var(--blockeditor-pop-shadow);font-size:.88em}
|
|
4
|
+
.blockeditor-cover-msg{max-width:34ch}
|
|
5
|
+
.blockeditor-cover-bar{flex:1;height:2px;border-radius:1px;background:var(--blockeditor-rule);overflow:hidden}
|
|
6
|
+
.blockeditor-cover-bar>span{display:block;height:100%;background:var(--blockeditor-progress, var(--blockeditor-ink-soft));transition:width 200ms}
|
|
7
|
+
.blockeditor-cover-btn{border:0;padding:4px 8px;border-radius:6px;background:none;color:inherit;font:inherit;cursor:pointer}
|
|
8
|
+
.blockeditor-cover-btn:hover{background:var(--blockeditor-pop-hover)}
|
|
9
|
+
.blockeditor-cover-panel[data-state="error"] .blockeditor-cover-msg{color:var(--blockeditor-danger, #9E3B2F)}
|
|
10
|
+
`,b=n=>Math.min(100,Math.max(0,Math.round(n)));async function R(n,u){if(typeof n.runFormatCommand!="function")return{ok:!1,code:"blockeditor-format-unsupported"};let i=await n.runFormatCommand(u);return i?.status==="applied"?i.result:{ok:!1,code:i?.code??i?.status??"blockeditor-format-refused",retry:i?.retry===!0}}var _=n=>new Promise((u,i)=>{let s=new FileReader;s.onload=()=>u(s.result),s.onerror=()=>i(s.error),s.readAsDataURL(n)});function W({view:n=null,upload:u=null}={}){if(!n)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let i=n.dom.ownerDocument,s=null;function l(){let e=s;if(e){s=null;for(let[t,o,r,a]of e.listen)t.removeEventListener(o,r,a);e.abort?.abort(),e.input?.remove(),e.ui?.remove(),e.stopPick?.(),e.state==="position"&&z(e)}}let f=(e,t,o,r,a)=>{t.addEventListener(o,r,a),e.listen.push([t,o,r,a])},g=(e,t)=>{let o=i.createElement("button");return o.type="button",o.className="blockeditor-cover-btn",o.dataset.act=e,o.textContent=t,o};function m(e){let t=e.panel??(e.panel=i.createElement("div"));t.className="blockeditor-cover-panel",t.dataset.state=e.state,t.setAttribute("contenteditable","false"),t.setAttribute("role",e.state==="uploading"?"status":"alert"),t.textContent="";let o=i.createElement("span");if(o.className="blockeditor-cover-msg",o.textContent=e.message,t.append(o),e.state==="uploading"){let r=i.createElement("span");r.className="blockeditor-cover-bar",r.setAttribute("role","progressbar"),r.setAttribute("aria-valuemin","0"),r.setAttribute("aria-valuemax","100"),r.setAttribute("aria-valuenow",String(e.percent));let a=i.createElement("span");a.style.width=`${e.percent}%`,r.append(a),t.append(r,g("cancel","Cancel"))}else e.state==="embed-choice"?t.append(g("embed","Keep this image inside the document"),g("cancel","Close")):e.state==="position"?t.append(g("apply","Apply"),g("cancel","Cancel")):t.append(g("cancel","Close"));if(!e.ui){let r=n.dom.parentElement;e.ui=P({name:"blockeditor-cover",content:t,css:[O],parent:r??i.body,before:r?n.dom:null})}}function E(e){f(e,e.panel,"click",t=>{let o=t.target.closest?.("[data-act]");o&&(t.preventDefault(),o.dataset.act==="cancel"?l():o.dataset.act==="apply"?C(e):o.dataset.act==="embed"&&B(e))})}function D(e,t){let o=v(n.state.doc);if((o?o.node.attrs.id:null)!==e)return{ok:!1,code:"stale-target"};let r=n.state.tr;if(o)r.setNodeMarkup(o.at,null,{...o.node.attrs,...t});else{let a=n.state.doc.maybeChild(0);r.insert(0,w.nodes.heading.create({id:A(),pos:U(null,a?.attrs.pos??null),parent:null,level:1,...t}))}return n.dispatch(N(r)),{ok:!0,cover:!0}}async function S(e,t){let o=await R(n,()=>D(e.owner,t));return s===e&&l(),o?.ok&&$(n,"Cover added"),o}function T(e){return new Promise(t=>{let o=i.createElement("input");o.type="file",o.accept="image/*",o.className="blockeditor-cover-input",o.hidden=!0,(n.dom.parentElement??i.body).appendChild(o),e.input=o,e.stopPick=()=>t(null);let r=!1,a=p=>{r||(r=!0,t(p))};f(e,o,"change",()=>a([...o.files??[]][0]??null)),f(e,o,"cancel",()=>a(null)),o.click()})}async function j(e,t){let o=M.get(n),r=o?.upload??u;if(typeof r!="function")return l(),{ok:!1,code:"unavailable"};let a=new AbortController;e.abort=a,o?.aborts.set(e.id,a),e.message=`Uploading ${t.name||"the image"}`,m(e);let p=-5,h=({percent:d})=>{s!==e||d-p<5&&d!==100||(p=d,e.percent=d,m(e))},c;try{c=await r(t,{onProgress:h,signal:a.signal})}catch{c={code:"network",msg:"Upload failed"}}if(o?.aborts.delete(e.id),s!==e||n.isDestroyed)return{ok:!1,code:"not-editing"};if(c?.ok){let d=Y(c.uploads?.[0]?.url);if(d)return S(e,{pageCoverSrc:d,pageCoverAlt:"",pageCoverX:50,pageCoverY:50});c={code:"bad-response",msg:"The upload returned an invalid address"}}if((!c||typeof c!="object")&&(c={code:"bad-response",msg:"The upload returned an invalid response"}),c.code==="aborted")return l(),{ok:!1,code:"cancelled"};if(c.code==="unsupported"){let d=/^image\/(png|jpeg|gif|webp)$/i.test(t.type)&&t.size<=F;return e.state=d?"embed-choice":"error",e.file=d?t:null,e.message=d?"This host doesn't store files. You can keep this image inside the document, which makes the document larger.":"This host doesn't store files, and this image is too large to keep inside the document.",m(e),{ok:!1,code:"unsupported"}}return e.state="error",e.message=c.msg||"Upload failed",m(e),{ok:!1,code:c.code??"error"}}async function B(e){let t=e.file;if(!t)return;let o=await _(t);if(s!==e)return;let r=X(o);if(typeof r!="string"){e.state="error",e.message="That image could not be kept inside the document.",m(e);return}return S(e,{pageCoverSrc:r,pageCoverAlt:"",pageCoverX:50,pageCoverY:50})}function L(){l();let e={id:A("c"),owner:v(n.state.doc)?.node.attrs.id??null,state:"uploading",percent:0,message:"Choosing a cover",listen:[]};return s=e,f(e,i,"keydown",t=>{s!==e||t.key!=="Escape"||(t.preventDefault(),t.stopPropagation(),l())},!0),m(e),E(e),T(e).then(t=>{s===e&&(t?j(e,t):l())}),{ok:!0,picker:!0}}let x=()=>n.dom.querySelector("header[data-blockeditor-heading] img[data-blockeditor-cover]");function k(e){let t=x();t&&t.setAttribute("style",`object-position:${e.x}% ${e.y}%`)}function z(e){let t=v(n.state.doc),o=x();!o||!t||t.node.attrs.id!==e.owner||o.setAttribute("style",`object-position:${t.node.attrs.pageCoverX}% ${t.node.attrs.pageCoverY}%`)}async function C(e){if(s!==e)return{ok:!1,code:"not-editing"};let{x:t,y:o}=e;return l(),R(n,()=>D(e.owner,{pageCoverX:t,pageCoverY:o}))}function I(){l();let e=v(n.state.doc);if(!e||!e.node.attrs.pageCoverSrc)return{ok:!1,code:"no-cover"};let t={owner:e.node.attrs.id,state:"position",listen:[],x:e.node.attrs.pageCoverX,y:e.node.attrs.pageCoverY,message:"Drag the picture or use the arrow keys, then Apply"};s=t,m(t),E(t),f(t,i,"keydown",r=>{let a=()=>{r.preventDefault(),r.stopPropagation()};r.key==="Escape"?(a(),l()):r.key==="Enter"?(a(),C(t)):r.key==="ArrowLeft"?(a(),t.x=b(t.x-y),k(t)):r.key==="ArrowRight"?(a(),t.x=b(t.x+y),k(t)):r.key==="ArrowUp"?(a(),t.y=b(t.y-y),k(t)):r.key==="ArrowDown"&&(a(),t.y=b(t.y+y),k(t))},!0);let o=x();return o&&f(t,o,"pointerdown",r=>{let a=o.getBoundingClientRect();if(!a.width||!a.height)return;r.preventDefault();let p={px:r.clientX,py:r.clientY,x:t.x,y:t.y};f(t,i,"pointermove",h=>{t.x=b(p.x+(h.clientX-p.px)/a.width*100),t.y=b(p.y+(h.clientY-p.py)/a.height*100),k(t)}),f(t,i,"pointerup",()=>C(t))}),{ok:!0,position:!0}}return{run(e){return e?.act==="position"?I():L()},dispose(){l()}}}export{W as createFeature};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as L}from"./c-QY7F6EN6.js";import{f as v,g as E,j as p,l as h,n as m}from"./c-MR75YPRT.js";import{e as i,f as l,g as x}from"./c-5RZNFTWD.js";import{b as w}from"./c-PKCCHJ5X.js";import{b as o}from"./c-NUHP2XDB.js";var b={success:{edge:i.teal,icon:l.toastSuccess},error:{edge:i.ox,icon:l.toastWarning},warning:{edge:i.brass,icon:l.toastWarning},info:{edge:i.brass,icon:l.toastInfo}},$=l.toastClose,A=["opacity:0","transform:translateX(24px)"],T=24,B=10;function M(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches?"none":"opacity .5s ease-in-out, transform .5s ease-in-out"}function O(){let e=document.querySelector('clay-editor-ui[data-clay-ui="toasts"]')?.shadowRoot.querySelector("[data-clay-toasts]");if(e)return e;let t=p("div",["position:fixed","top:18px","right:18px","z-index:9999","display:flex","flex-direction:column","align-items:flex-end","gap:10px","width:min(330px, calc(100vw - 36px))","pointer-events:none"]);return t.setAttribute("data-clay-toasts",""),t.setAttribute("aria-live","polite"),L({name:"toasts",content:t}),t}function S(e,t,{detail:n="",actions:a=[]}={}){let c=b[t],s=h("div",["display:flex","align-items:flex-start",...x.toast,"width:100%",`border-inline-start:3px solid ${c.edge}`,"cursor:pointer","pointer-events:auto",...A,`transition:${M()}`]);s.setAttribute("data-clay-toast",t);let d=p("div",["flex:1 1 auto","min-width:0","display:flex","flex-direction:column","gap:8px"]),f=p("div",["display:flex","align-items:flex-start","gap:8px"]),g=m("span",["display:inline-grid","flex:none","padding-top:1px",`color:${c.edge}`]);g.innerHTML=c.icon,v(g.firstElementChild,16);let C=m("span",["flex:1 1 auto","min-width:120px",...x.toastTitle,"overflow-wrap:anywhere"],e);if(f.append(g,C),d.append(f),n&&d.append(m("span",["display:block",`padding-inline-start:${T}px`,`color:${i.muted}`,"overflow-wrap:anywhere"],n)),a.length){let y=p("div",["display:flex","flex-wrap:wrap","gap:8px",`padding-inline-start:${T-B}px`]);for(let{label:I,onClick:N}of a)y.append(E(I,{small:!0,variant:"quiet",onClick:N,extra:["padding:4px 8px"]}));d.append(y)}return s.append(d),s}function P(e){let t=p("button",["flex:none","display:inline-grid","place-items:center",...x.toastClose,"cursor:pointer"]);t.type="button",t.setAttribute("aria-label","Dismiss"),t.title="Dismiss",t.innerHTML=$,v(t.firstElementChild,14);let n=a=>{o(t,"color",a?i.ink:i.muted),o(t,"background",a?i.sunk:"transparent")};return t.addEventListener("pointerenter",()=>n(!0)),t.addEventListener("pointerleave",()=>n(!1)),t.addEventListener("focus",()=>{n(!0),o(t,"outline",`2px solid ${i.brass}`),o(t,"outline-offset","1px")}),t.addEventListener("blur",()=>{n(!1),o(t,"outline","none")}),t.addEventListener("click",e),t}function k(e){O().append(e),w(e,{background:i.surface}),setTimeout(()=>{o(e,"opacity","1"),o(e,"transform","none")},10)}function u(e,t){o(e,"opacity","0"),o(e,"transform","translateX(24px)"),setTimeout(()=>{e.remove(),t?.()},500)}function D(e,t="success"){let n=S(e,b[t]?t:"success");n.addEventListener("click",()=>u(n)),k(n),setTimeout(()=>u(n),6600)}var r=new Map;function X(e,t="warning",{detail:n="",actions:a=[]}={}){let c=r.get(e);c&&(u(c),r.delete(e));let s=S(e,b[t]?t:"warning",{detail:n,actions:a});o(s,"cursor","default");let d=P(f=>{f.stopPropagation(),u(s,()=>{r.get(e)===s&&r.delete(e)})});s.append(d),r.set(e,s),k(s)}function R(e,{now:t=!1}={}){let n=r.get(e);if(n){if(r.delete(e),t){n.remove();return}u(n)}}var W=D;export{X as a,R as b,W as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as d}from"./c-CZHTXGJS.js";import"./c-WN3MXOLT.js";import{b as f,c as m}from"./c-RVMWGXEJ.js";import{b as n,c as r}from"./c-NUHP2XDB.js";import{e as c}from"./c-QQFHEODI.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=30,g=6,e=null,u=null;function O(){return u??=Promise.all([import("./c-TFLRT5JX.js"),import("./c-46LJAZZJ.js")]).then(([o,t])=>e={pageScheme:o.pageScheme,paintLook:o.paintLook,RUNTIME_ONLY:o.RUNTIME_ONLY,TOKENS:t.TOKENS,SHADOW:t.SHADOW,FONT:`600 11px/1 ${t.FONT_MONO}`,LABEL_FONT:`500 11px/1.4 ${t.FONT_MONO}`}).catch(o=>{throw u=null,o}),u}var N=()=>O().then(()=>!0,()=>!1),a=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],T="#FFFCF6";function l(o){return o.setAttribute("clay",e.RUNTIME_ONLY),o}function E(o){return{people:o.people.map(i=>({id:i.id,name:i.name,you:i.you})),anonymous:o.anonymous}}var h=class{constructor(){this.roster={people:[],anonymous:0},this.root=null,this.stack=null,this.count=null,this.tip=null,this._gate=null}supported(){return this._gate||(this._gate=Promise.all([c("presence"),c("record-awareness-v1"),c("blockeditor-awareness-v1")]).then(([t,i,s])=>(d.setCapabilities({supported:t,recordAwareness:i,pageAwareness:s}),t===!0),()=>!1)),this._gate}async update(t){let i=E(d.receive(t)),s=this.root&&JSON.stringify(i)===JSON.stringify(this.roster);if(this.roster=i,!!await this.supported()){if(s){e.paintLook(this.root);return}await this.render()}}clear(){d.clear(),this.roster={people:[],anonymous:0},this.root&&(this.root.remove(),this.root=null,this.stack=null,this.count=null,this.tip=null)}async render(){let{people:t,anonymous:i}=this.roster;if(t.length+i<=1||window.clay?.menu){this.hide();return}if(await N()&&this.build()){this.hideTip(),this.stack.textContent="";for(let s of t)this.stack.appendChild(this.avatar(s));this.stack.firstElementChild&&n(this.stack.firstElementChild,"margin-left","0"),i>0?(this.count.textContent=`+${i} viewing`,n(this.count,"display","inline-block")):(this.count.textContent="",n(this.count,"display","none")),n(this.root,"display","flex"),e.paintLook(this.root)}}hide(){this.root&&(this.hideTip(),this.stack.textContent="",this.count.textContent="",n(this.root,"display","none"))}build(){return this.root?!0:typeof document>"u"||!document.body?!1:(this.root=l(r("div",[...a,`color-scheme:${e.pageScheme()}`,"position:fixed","top:calc(12px + env(safe-area-inset-top,0px))","right:calc(12px + env(safe-area-inset-right,0px))","z-index:2147483000","display:flex","align-items:center","gap:8px","max-width:calc(100vw - 24px)",`font:${e.LABEL_FONT}`,`color:${e.TOKENS.ink}`,"pointer-events:none"])),this.root.setAttribute("data-clay-presence",""),this.count=l(r("span",[...a,"box-sizing:border-box","flex:none","white-space:nowrap","padding:3px 8px","border-radius:0",`background:${e.TOKENS.surface}`,`color:${e.TOKENS.muted}`,`border:1px solid ${e.TOKENS["line-2"]}`,`font:${e.LABEL_FONT}`,"letter-spacing:.02em",`box-shadow:${e.SHADOW}`,"display:none","pointer-events:none"])),this.count.setAttribute("data-clay-presence-count",""),this.stack=l(r("div",[...a,"display:flex","align-items:center","flex:none","pointer-events:none"])),this.tip=l(r("span",[...a,"position:absolute","top:100%","right:0","margin-top:6px","box-sizing:border-box","white-space:nowrap","pointer-events:none","padding:5px 9px","border-radius:0",`background:${e.TOKENS.ink}`,`color:${e.TOKENS.ground}`,`font:${e.LABEL_FONT}`,"letter-spacing:.02em",`box-shadow:${e.SHADOW}`,"display:none"])),this.tip.setAttribute("data-clay-presence-tip",""),this.root.append(this.stack,this.count,this.tip),document.body.appendChild(this.root),!0)}avatar(t){let i=f(t.id),s=[`background-color:${T}`,`color:${i}`,`border-color:${i}`],p=l(r("div",[...a,"box-sizing:border-box","flex:none",`width:${x}px`,`height:${x}px`,"border-radius:0","display:flex","align-items:center","justify-content:center",`font:${e.FONT}`,"letter-spacing:.02em",`margin-left:-${g}px`,"border-width:2px","border-style:solid","background-image:none",`box-shadow:${e.SHADOW}`,"user-select:none","cursor:default","pointer-events:auto",...s],m(t.name)));p.setAttribute("data-clay-presence-avatar","");let b=t.you?`${t.name} (you)`:t.name;return p.addEventListener("mouseenter",()=>this.showTip(b)),p.addEventListener("mouseleave",()=>this.hideTip()),p}showTip(t){this.tip&&(this.tip.textContent=t,n(this.tip,"display","block"))}hideTip(){this.tip&&(this.tip.textContent="",n(this.tip,"display","none"))}},y=new h;typeof document<"u"&&document.addEventListener("clay:menu-ready",()=>y.render());var v=y;export{h as Presence,v as default,y as presence};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o,q as p}from"./c-
|
|
1
|
+
import{e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o,q as p}from"./c-MR75YPRT.js";import{a}from"./c-4JZDZFF6.js";import"./c-5RZNFTWD.js";import{a as b,b as c}from"./c-PKCCHJ5X.js";import"./c-NUHP2XDB.js";import"./c-VHNSBD2M.js";export{d as RUNTIME_ONLY,i as bevelBox,f as bevelButton,h as bevelCornerClose,g as bevelIconButton,o as bevelInput,k as bevelSurface,m as bevelText,l as bevelWell,a as pageScheme,n as paintInput,c as paintLook,e as protectIcon,j as restyleBox,p as setShown,b as uiLook};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as K}from"./c-L3F5ZLIV.js";import{e as te,f as ne,g as oe}from"./c-JRKY44DK.js";import{d as N,e as L,f as R,h as ie,l as se}from"./c-EXKHPOVC.js";import{b as M}from"./c-L5VFATT6.js";import{a as T,b as re,f as $,g as O,h as G,i as P,r as I,s as B}from"./c-WMRJKQ2V.js";import{c as _}from"./c-57XDY6HC.js";import{a as ee}from"./c-I2SCCUEW.js";function F(e){let t=new Set;for(let[,n]of _(e?.y??{}))try{for(let o of P(I(re(n))).keys())t.add(o)}catch{}return t}function Ae(e,t){let n=F(e),o=F(t);if(!n.size||!o.size||[...o].some(r=>n.has(r)))return!0;let i=new Map(_(e?.y??{}));return _(t?.y??{}).some(([r,s])=>i.get(r)===s)}function ae(e,t){return!e||!t||!e.generation||!t.generation?!1:e.generation===t.generation&&e.baseDigest===t.baseDigest}async function ce(e,t){let n=t instanceof Uint8Array?t:new Uint8Array(0);return{generation:e,baseDigest:await L(n),baseVector:n.length?I(n):new Uint8Array(0)}}function le(e,t){let n=F(e),o=F(t);return!n.size||!o.size?!1:Ae(e,t)}var Se="page.yjs",Ie=1,Ue=64,Ve=1024*1024,Ye=e=>B(e),W=class extends Error{constructor(t,n){super(n),this.name="PageReplayError",this.code=t}},y=(e,t)=>{throw new W(e,t)},m=e=>typeof e=="string"?e:JSON.stringify(e),U=e=>e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null,Oe=(e,t)=>m(e)===m(t);function z(e){let t=e.map(U).filter(n=>n&&n.length);return t.length?t.length===1?t[0].slice():B(t):new Uint8Array(0)}function H({capsule:e,batches:t=[]}={}){(!e||e.kind!=="binary"||!e.payload)&&y("invalid-capsule","Replay needs a binary capsule"),e.version!==void 0&&e.version!==1&&y("unknown-version",`Unknown page recovery capsule version: ${e.version}`);let n=[e.payload.dependencies],o=[e.payload.owned],i=new Set;for(let r of t){if((!r||r.kind!=="binary-batch"||!r.payload)&&y("invalid-batch","Replay reads binary batches only"),r.capsuleId!==void 0&&!Oe(r.capsuleId,e.id)&&y("foreign-batch","A batch belongs to another capsule"),r.id!==void 0){if(i.has(m(r.id)))continue;i.add(m(r.id))}r.origin==="dependency"?n.push(r.payload):o.push(r.payload)}return{id:e.id,context:e.context??null,revision:e.revision??0,acknowledged:e.acknowledged??null,base:z([e.payload.base]),dependencies:z(n),owned:z(o)}}function Pe({capsule:e,batches:t=[]}={}){let n=H({capsule:e,batches:t}),o=new $;try{for(let i of[n.base,n.dependencies,n.owned])i.length&&O(o,i,M);return(o.store.pendingStructs||o.store.pendingDs)&&y("unresolved-update","The capsule's updates are missing a prerequisite"),{v:1,g:0,y:{seed:T(G(o))}}}finally{o.destroy()}}function Ee({capsule:e,batches:t=[]}={}){return K(Pe({capsule:e,batches:t}))}function _e({capsule:e,batches:t=[],current:n}={}){let o=H({capsule:e,batches:t});o.context?.authority||y("missing-identity","A capsule with no authority is never replayed"),n?.context?.authority||y("missing-identity","Replay needs the page's own authority"),oe(o.context.authority,n.context.authority)||y("foreign-authority","This journal belongs to another document or account"),ae(o.context.lineage,n.context.lineage)||y("foreign-generation","This journal belongs to another generation of this page");let i=R(n.state);o.base.length&&!N(i,o.base)&&y("missing-base","The page no longer contains the journal's base"),o.owned.length||y("nothing-owned","This capsule owns no local work");let r=z([o.base,o.dependencies,o.owned]);return le(n.state,{v:1,g:0,y:{seed:T(r)}})||y("foreign-lineage","This journal shares no ancestry with this page"),o}function he(e=[]){let t=new Map,n=new Map;for(let o of e||[]){if(!o||o.supported===!1)continue;if(o.kind==="binary"){t.set(m(o.id),o);continue}if(o.kind!=="binary-batch"||o.capsuleId===void 0)continue;let i=m(o.capsuleId),r=n.get(i)??[];r.push(o),n.set(i,r)}return[...t.entries()].map(([o,i])=>({capsule:i,batches:n.get(o)??[]}))}function Te(e,t){for(let n of[t.base,t.dependencies,t.owned])n&&n.length&&O(e,n,se)}function Be(e,t){try{let{owned:n}=H({capsule:e.capsule,batches:e.batches});return n.length>0&&N(R(t.state),n)}catch{return!1}}function Me({records:e=[],current:t,into:n}={}){let o=[],i=[];for(let r of he(e)){let s;try{s=_e({capsule:r.capsule,batches:r.batches,current:t})}catch(l){if(l?.code==="nothing-owned"||l?.code==="foreign-generation"&&Be(r,t))continue;i.push({capsule:r.capsule,batches:r.batches,code:l?.code??"invalid-capsule",message:l?.message??"This journal cannot be replayed"});continue}Te(n,s),o.push({id:r.capsule.id,revision:s.revision,owned:s.owned.length})}return{replayed:o,review:i}}async function Ne({authority:e,generation:t=null,base:n=null,formatFloor:o=0}={}){let i=U(n)??new Uint8Array(0),r=typeof t=="string"&&t?t:await L(i);return{authority:e,lineage:await ce(r,i),formatFloor:o}}function Le({meta:e=null,location:t=globalThis.location,root:n=globalThis.document?.documentElement}={}){let o=t?.origin??"";if(!o)return null;let i=te(n),r=i?"host":"path",s=i?.identity??ne(t?.pathname??"/").identity;if(!s)return null;let l=e?.document?.people,u=l&&typeof l=="object"?l.me?.id??null:s;return u?{host:o,documentId:s,principalId:u,scope:r}:null}var ue=e=>typeof e=="string"?e:JSON.stringify(e);function Re(e,t){if(!t.length)return!0;let n=P(I(t)),o=P(I(e));for(let[i,r]of n)if((o.get(i)??0)<r)return!1;return!0}function de(e,t){let n=U(t);return!n||!n.length?new Uint8Array(0):N(e,n)?new Uint8Array(0):n}var wt=e=>R(e),fe=new WeakMap;function Fe(e){if(!e)return null;let t=fe.get(e);if(t)return t;let n=e.register({channel:Se,version:Ie,validateCheckpoint:ie,merge:Ye});return fe.set(e,n),n}function ze({channel:e,key:t,context:n,base:o=null,onChange:i=()=>{}}){let r=new Map,s=[],l=[],u=new Set,d=U(o)??new Uint8Array(0),f=null,k=null,b=0,S=0,g=!1,C=!0,E=!1,D=Promise.resolve(null),V=null,x=!1,v={channel:e,key:t,onChange:i,context:()=>ke.then(()=>f),local:a=>Z(a,"local"),dependency:a=>{g&&Z(a,"dependency")},records:()=>[...r.values()],names:J,next:()=>new Promise(a=>{l.push(a)}),covers:(a,c)=>{let p=[...r.values()].map(A=>A.update).filter(A=>A&&A.byteLength),h={kind:"binary",version:1,id:"journal",revision:0,payload:{base:d,dependencies:new Uint8Array(0),owned:p.length?B(p):new Uint8Array(0)}};return we([h],a,c)},pending:()=>u.size+(E?s.length:0)+(k?1:0),get failure(){return k},retire:q,rebase:be,compact:X,acknowledged:()=>x||!f||!r.size||typeof e.markAcknowledged!="function"?Promise.resolve(null):Promise.resolve(e.markAcknowledged({records:J(),authority:f.authority})).catch(()=>null),close:()=>{x=!0,s.length=0,Y(null)}},ke=Promise.resolve().then(()=>typeof n=="function"?n(d):n).catch(()=>null).then(a=>{if(f=a&&a.authority?a:null,!f)return x=!0,k="unavailable",s.length=0,v.onChange(),null;for(let c of s.splice(0))c(f);return f});function Y(a){for(let c of l.splice(0))c(a)}function q(a){for(let c of a||[]){let p=ue(c?.id),h=r.get(p);h&&(r.delete(p),b=Math.max(0,b-1),S=Math.max(0,S-(h.update?.byteLength??0)))}}function be(a){return D=D.then(()=>xe(U(a))).catch(()=>null),D}async function xe(a){if(x||!f||!a||!a.length||!Re(a,d))return null;E=!0;try{for(;u.size&&!x;)await v.next();if(x)return null;let c=typeof n=="function"?await n(a):n;if(!c||!c.authority)return null;if(g){let p=typeof e.rebase=="function"?await e.rebase({key:t,context:c,rebuild:h=>({base:a,dependencies:de(a,h.dependencies),owned:de(a,h.owned)})}):null;if(p?.code==="missing")C=!0;else if(!p?.ok)return null}d=a,f=c;for(let p of r.values())p.context=c;return c}finally{if(E=!1,f)for(let c of s.splice(0))c(f)}}function J(){return[...r.values()].map(({id:a,revision:c})=>({id:a,revision:c}))}function X(){if(V||x||!r.size||typeof e.compact!="function")return V;let a=J();return V=Promise.resolve().then(()=>e.compact({records:a})).then(c=>(c?.ok&&q(c.retired),c)).catch(()=>null).then(c=>(V=null,v.onChange(),c)),V}function ve(a,c,p,h){let A;try{A=e.append({key:t,context:a,update:c,origin:p,base:h?d:null})}catch{k="error",Y(null),v.onChange();return}let j={};u.add(j),Promise.resolve(A).then(w=>{if(u.delete(j),!w||w.ok!==!0){k=w?.code??"error",Y(null),v.onChange();return}k=null,w.skipped||(r.set(ue(w.id),{id:w.id,revision:w.revision,update:c,context:a}),b+=1,S+=c.byteLength),v.onChange(),Y({id:w.id,revision:w.revision}),(b>=Ue||S>=Ve)&&X()},()=>{u.delete(j),k="error",Y(null),v.onChange()})}function Q(a,c,p){let h=C;C=!1,ve(a,c,p,h)}function Z(a,c){x||!a||!a.byteLength||typeof e.append!="function"||(g=!0,f&&!E?Q(f,a,c):s.push(p=>Q(p,a,c)))}return v}function kt({meta:e=null,service:t=null,base:n=null,onChange:o=()=>{},location:i,root:r}={}){let s=Le({meta:e,location:i,root:r});if(!s)return null;let l=Fe(t);if(!l)return null;let u=e?.document?.pageState?.generation??null,d=Array.isArray(e?.extensions)&&e.extensions.includes("page-format-v1")?1:0;return ze({channel:l,key:[s.host,s.documentId].join(":"),context:f=>Ne({authority:s,generation:u,base:f,formatFloor:d}),base:n,onChange:o})}function bt({journal:e,store:t=null,reduce:n=()=>null,onState:o=()=>{},onUnavailable:i=()=>{}}={}){if(!e)return{checkpoint(){},state:()=>null,dispose(){}};let r={acknowledged:!1,checkpointed:!1},s=null,l=()=>{let g=e.failure??null,C=e.records().length;return n({unavailable:!!g,pending:g?0:e.pending(),journaled:r.acknowledged?0:C,acknowledged:r.acknowledged?C:0,checkpointed:r.checkpointed&&!C})},u=()=>{let g=l();return!g||g===s?s:(s=g,g==="unavailable"?i(e.failure):o(g),g)},d=e.onChange;e.onChange=()=>{d?.(),u()};let f=t?.onLocal?.(()=>{r.acknowledged=!1,r.checkpointed=!1,u()}),k=t?.onConfirm?.(()=>{r.acknowledged=!0,u()}),b=()=>!!e.failure,S=ee({id:"page:journal",isPending:()=>!b()&&e.pending()>0,flush:async()=>{if(b())return{ok:!0};for(;!b()&&e.pending()>0&&await e.next(););return await Promise.resolve(e.channel?.flush?.()).catch(()=>null),{ok:b()||e.pending()===0}}});return u(),{checkpoint(){r.checkpointed=!0,u()},state:l,dispose(){e.onChange=d,f?.(),k?.(),S.dispose()}}}async function xt({journal:e,state:t,into:n}={}){if(!e)return{replayed:[],review:[]};let o=await e.context();if(!o)return{replayed:[],review:[]};let i=await e.channel.list();return i?.ok?Me({records:i.records,current:{context:o,state:t},into:n}):{replayed:[],review:[]}}var pe=e=>typeof e?.pos=="string"?e.pos:"",He=e=>Object.keys(e).sort((t,n)=>{let o=pe(e[t]),i=pe(e[n]);return o!==i?o<i?-1:1:t<n?-1:t>n?1:0});function me(e){if(typeof e?.c=="string")return e.c;if(!e?.rows)return"";let t=[];for(let n of Object.values(e.rows))for(let o of Object.values(n?.cells??{})){let i=typeof o=="string"?o:typeof o?.c=="string"?o.c:"";i&&t.push(i)}return t.join(" ")}function De(e=[]){let t=new $;try{for(let n of he(e)){let o;try{o=H(n)}catch{continue}for(let i of[o.base,o.dependencies,o.owned])i.length&&O(t,i,M)}for(let n of e||[]){let o=U(n?.update);o&&o.length&&O(t,o,M)}return K({v:1,g:0,y:{seed:T(G(t))}})}catch{return null}finally{t.destroy()}}function Je({capsule:e,batches:t=[]}={}){let n;try{n=Ee({capsule:e,batches:t})}catch{return""}let o=[];for(let i of He(n)){let r=me(n[i]);r&&o.push(r)}return o.join(`
|
|
1
|
+
import{a as K}from"./c-NEQRFC4O.js";import{e as te,f as ne,g as oe}from"./c-JRKY44DK.js";import{d as N,e as L,f as R,h as ie,l as se}from"./c-GO635CRU.js";import{b as M}from"./c-V2V5FKXX.js";import{a as T,b as re,f as $,g as O,h as G,i as P,r as I,s as B}from"./c-WMRJKQ2V.js";import{c as _}from"./c-57XDY6HC.js";import{a as ee}from"./c-I2SCCUEW.js";function F(e){let t=new Set;for(let[,n]of _(e?.y??{}))try{for(let o of P(I(re(n))).keys())t.add(o)}catch{}return t}function Ae(e,t){let n=F(e),o=F(t);if(!n.size||!o.size||[...o].some(r=>n.has(r)))return!0;let i=new Map(_(e?.y??{}));return _(t?.y??{}).some(([r,s])=>i.get(r)===s)}function ae(e,t){return!e||!t||!e.generation||!t.generation?!1:e.generation===t.generation&&e.baseDigest===t.baseDigest}async function ce(e,t){let n=t instanceof Uint8Array?t:new Uint8Array(0);return{generation:e,baseDigest:await L(n),baseVector:n.length?I(n):new Uint8Array(0)}}function le(e,t){let n=F(e),o=F(t);return!n.size||!o.size?!1:Ae(e,t)}var Se="page.yjs",Ie=1,Ue=64,Ve=1024*1024,Ye=e=>B(e),W=class extends Error{constructor(t,n){super(n),this.name="PageReplayError",this.code=t}},y=(e,t)=>{throw new W(e,t)},m=e=>typeof e=="string"?e:JSON.stringify(e),U=e=>e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null,Oe=(e,t)=>m(e)===m(t);function z(e){let t=e.map(U).filter(n=>n&&n.length);return t.length?t.length===1?t[0].slice():B(t):new Uint8Array(0)}function H({capsule:e,batches:t=[]}={}){(!e||e.kind!=="binary"||!e.payload)&&y("invalid-capsule","Replay needs a binary capsule"),e.version!==void 0&&e.version!==1&&y("unknown-version",`Unknown page recovery capsule version: ${e.version}`);let n=[e.payload.dependencies],o=[e.payload.owned],i=new Set;for(let r of t){if((!r||r.kind!=="binary-batch"||!r.payload)&&y("invalid-batch","Replay reads binary batches only"),r.capsuleId!==void 0&&!Oe(r.capsuleId,e.id)&&y("foreign-batch","A batch belongs to another capsule"),r.id!==void 0){if(i.has(m(r.id)))continue;i.add(m(r.id))}r.origin==="dependency"?n.push(r.payload):o.push(r.payload)}return{id:e.id,context:e.context??null,revision:e.revision??0,acknowledged:e.acknowledged??null,base:z([e.payload.base]),dependencies:z(n),owned:z(o)}}function Pe({capsule:e,batches:t=[]}={}){let n=H({capsule:e,batches:t}),o=new $;try{for(let i of[n.base,n.dependencies,n.owned])i.length&&O(o,i,M);return(o.store.pendingStructs||o.store.pendingDs)&&y("unresolved-update","The capsule's updates are missing a prerequisite"),{v:1,g:0,y:{seed:T(G(o))}}}finally{o.destroy()}}function Ee({capsule:e,batches:t=[]}={}){return K(Pe({capsule:e,batches:t}))}function _e({capsule:e,batches:t=[],current:n}={}){let o=H({capsule:e,batches:t});o.context?.authority||y("missing-identity","A capsule with no authority is never replayed"),n?.context?.authority||y("missing-identity","Replay needs the page's own authority"),oe(o.context.authority,n.context.authority)||y("foreign-authority","This journal belongs to another document or account"),ae(o.context.lineage,n.context.lineage)||y("foreign-generation","This journal belongs to another generation of this page");let i=R(n.state);o.base.length&&!N(i,o.base)&&y("missing-base","The page no longer contains the journal's base"),o.owned.length||y("nothing-owned","This capsule owns no local work");let r=z([o.base,o.dependencies,o.owned]);return le(n.state,{v:1,g:0,y:{seed:T(r)}})||y("foreign-lineage","This journal shares no ancestry with this page"),o}function he(e=[]){let t=new Map,n=new Map;for(let o of e||[]){if(!o||o.supported===!1)continue;if(o.kind==="binary"){t.set(m(o.id),o);continue}if(o.kind!=="binary-batch"||o.capsuleId===void 0)continue;let i=m(o.capsuleId),r=n.get(i)??[];r.push(o),n.set(i,r)}return[...t.entries()].map(([o,i])=>({capsule:i,batches:n.get(o)??[]}))}function Te(e,t){for(let n of[t.base,t.dependencies,t.owned])n&&n.length&&O(e,n,se)}function Be(e,t){try{let{owned:n}=H({capsule:e.capsule,batches:e.batches});return n.length>0&&N(R(t.state),n)}catch{return!1}}function Me({records:e=[],current:t,into:n}={}){let o=[],i=[];for(let r of he(e)){let s;try{s=_e({capsule:r.capsule,batches:r.batches,current:t})}catch(l){if(l?.code==="nothing-owned"||l?.code==="foreign-generation"&&Be(r,t))continue;i.push({capsule:r.capsule,batches:r.batches,code:l?.code??"invalid-capsule",message:l?.message??"This journal cannot be replayed"});continue}Te(n,s),o.push({id:r.capsule.id,revision:s.revision,owned:s.owned.length})}return{replayed:o,review:i}}async function Ne({authority:e,generation:t=null,base:n=null,formatFloor:o=0}={}){let i=U(n)??new Uint8Array(0),r=typeof t=="string"&&t?t:await L(i);return{authority:e,lineage:await ce(r,i),formatFloor:o}}function Le({meta:e=null,location:t=globalThis.location,root:n=globalThis.document?.documentElement}={}){let o=t?.origin??"";if(!o)return null;let i=te(n),r=i?"host":"path",s=i?.identity??ne(t?.pathname??"/").identity;if(!s)return null;let l=e?.document?.people,u=l&&typeof l=="object"?l.me?.id??null:s;return u?{host:o,documentId:s,principalId:u,scope:r}:null}var ue=e=>typeof e=="string"?e:JSON.stringify(e);function Re(e,t){if(!t.length)return!0;let n=P(I(t)),o=P(I(e));for(let[i,r]of n)if((o.get(i)??0)<r)return!1;return!0}function de(e,t){let n=U(t);return!n||!n.length?new Uint8Array(0):N(e,n)?new Uint8Array(0):n}var wt=e=>R(e),fe=new WeakMap;function Fe(e){if(!e)return null;let t=fe.get(e);if(t)return t;let n=e.register({channel:Se,version:Ie,validateCheckpoint:ie,merge:Ye});return fe.set(e,n),n}function ze({channel:e,key:t,context:n,base:o=null,onChange:i=()=>{}}){let r=new Map,s=[],l=[],u=new Set,d=U(o)??new Uint8Array(0),f=null,k=null,b=0,S=0,g=!1,C=!0,E=!1,D=Promise.resolve(null),V=null,x=!1,v={channel:e,key:t,onChange:i,context:()=>ke.then(()=>f),local:a=>Z(a,"local"),dependency:a=>{g&&Z(a,"dependency")},records:()=>[...r.values()],names:J,next:()=>new Promise(a=>{l.push(a)}),covers:(a,c)=>{let p=[...r.values()].map(A=>A.update).filter(A=>A&&A.byteLength),h={kind:"binary",version:1,id:"journal",revision:0,payload:{base:d,dependencies:new Uint8Array(0),owned:p.length?B(p):new Uint8Array(0)}};return we([h],a,c)},pending:()=>u.size+(E?s.length:0)+(k?1:0),get failure(){return k},retire:q,rebase:be,compact:X,acknowledged:()=>x||!f||!r.size||typeof e.markAcknowledged!="function"?Promise.resolve(null):Promise.resolve(e.markAcknowledged({records:J(),authority:f.authority})).catch(()=>null),close:()=>{x=!0,s.length=0,Y(null)}},ke=Promise.resolve().then(()=>typeof n=="function"?n(d):n).catch(()=>null).then(a=>{if(f=a&&a.authority?a:null,!f)return x=!0,k="unavailable",s.length=0,v.onChange(),null;for(let c of s.splice(0))c(f);return f});function Y(a){for(let c of l.splice(0))c(a)}function q(a){for(let c of a||[]){let p=ue(c?.id),h=r.get(p);h&&(r.delete(p),b=Math.max(0,b-1),S=Math.max(0,S-(h.update?.byteLength??0)))}}function be(a){return D=D.then(()=>xe(U(a))).catch(()=>null),D}async function xe(a){if(x||!f||!a||!a.length||!Re(a,d))return null;E=!0;try{for(;u.size&&!x;)await v.next();if(x)return null;let c=typeof n=="function"?await n(a):n;if(!c||!c.authority)return null;if(g){let p=typeof e.rebase=="function"?await e.rebase({key:t,context:c,rebuild:h=>({base:a,dependencies:de(a,h.dependencies),owned:de(a,h.owned)})}):null;if(p?.code==="missing")C=!0;else if(!p?.ok)return null}d=a,f=c;for(let p of r.values())p.context=c;return c}finally{if(E=!1,f)for(let c of s.splice(0))c(f)}}function J(){return[...r.values()].map(({id:a,revision:c})=>({id:a,revision:c}))}function X(){if(V||x||!r.size||typeof e.compact!="function")return V;let a=J();return V=Promise.resolve().then(()=>e.compact({records:a})).then(c=>(c?.ok&&q(c.retired),c)).catch(()=>null).then(c=>(V=null,v.onChange(),c)),V}function ve(a,c,p,h){let A;try{A=e.append({key:t,context:a,update:c,origin:p,base:h?d:null})}catch{k="error",Y(null),v.onChange();return}let j={};u.add(j),Promise.resolve(A).then(w=>{if(u.delete(j),!w||w.ok!==!0){k=w?.code??"error",Y(null),v.onChange();return}k=null,w.skipped||(r.set(ue(w.id),{id:w.id,revision:w.revision,update:c,context:a}),b+=1,S+=c.byteLength),v.onChange(),Y({id:w.id,revision:w.revision}),(b>=Ue||S>=Ve)&&X()},()=>{u.delete(j),k="error",Y(null),v.onChange()})}function Q(a,c,p){let h=C;C=!1,ve(a,c,p,h)}function Z(a,c){x||!a||!a.byteLength||typeof e.append!="function"||(g=!0,f&&!E?Q(f,a,c):s.push(p=>Q(p,a,c)))}return v}function kt({meta:e=null,service:t=null,base:n=null,onChange:o=()=>{},location:i,root:r}={}){let s=Le({meta:e,location:i,root:r});if(!s)return null;let l=Fe(t);if(!l)return null;let u=e?.document?.blockeditorState?.generation??null,d=Array.isArray(e?.extensions)&&e.extensions.includes("blockeditor-format-v1")?1:0;return ze({channel:l,key:[s.host,s.documentId].join(":"),context:f=>Ne({authority:s,generation:u,base:f,formatFloor:d}),base:n,onChange:o})}function bt({journal:e,store:t=null,reduce:n=()=>null,onState:o=()=>{},onUnavailable:i=()=>{}}={}){if(!e)return{checkpoint(){},state:()=>null,dispose(){}};let r={acknowledged:!1,checkpointed:!1},s=null,l=()=>{let g=e.failure??null,C=e.records().length;return n({unavailable:!!g,pending:g?0:e.pending(),journaled:r.acknowledged?0:C,acknowledged:r.acknowledged?C:0,checkpointed:r.checkpointed&&!C})},u=()=>{let g=l();return!g||g===s?s:(s=g,g==="unavailable"?i(e.failure):o(g),g)},d=e.onChange;e.onChange=()=>{d?.(),u()};let f=t?.onLocal?.(()=>{r.acknowledged=!1,r.checkpointed=!1,u()}),k=t?.onConfirm?.(()=>{r.acknowledged=!0,u()}),b=()=>!!e.failure,S=ee({id:"page:journal",isPending:()=>!b()&&e.pending()>0,flush:async()=>{if(b())return{ok:!0};for(;!b()&&e.pending()>0&&await e.next(););return await Promise.resolve(e.channel?.flush?.()).catch(()=>null),{ok:b()||e.pending()===0}}});return u(),{checkpoint(){r.checkpointed=!0,u()},state:l,dispose(){e.onChange=d,f?.(),k?.(),S.dispose()}}}async function xt({journal:e,state:t,into:n}={}){if(!e)return{replayed:[],review:[]};let o=await e.context();if(!o)return{replayed:[],review:[]};let i=await e.channel.list();return i?.ok?Me({records:i.records,current:{context:o,state:t},into:n}):{replayed:[],review:[]}}var pe=e=>typeof e?.pos=="string"?e.pos:"",He=e=>Object.keys(e).sort((t,n)=>{let o=pe(e[t]),i=pe(e[n]);return o!==i?o<i?-1:1:t<n?-1:t>n?1:0});function me(e){if(typeof e?.c=="string")return e.c;if(!e?.rows)return"";let t=[];for(let n of Object.values(e.rows))for(let o of Object.values(n?.cells??{})){let i=typeof o=="string"?o:typeof o?.c=="string"?o.c:"";i&&t.push(i)}return t.join(" ")}function De(e=[]){let t=new $;try{for(let n of he(e)){let o;try{o=H(n)}catch{continue}for(let i of[o.base,o.dependencies,o.owned])i.length&&O(t,i,M)}for(let n of e||[]){let o=U(n?.update);o&&o.length&&O(t,o,M)}return K({v:1,g:0,y:{seed:T(G(t))}})}catch{return null}finally{t.destroy()}}function Je({capsule:e,batches:t=[]}={}){let n;try{n=Ee({capsule:e,batches:t})}catch{return""}let o=[];for(let i of He(n)){let r=me(n[i]);r&&o.push(r)}return o.join(`
|
|
2
2
|
`)}function vt(e=[]){return(e||[]).map(t=>({id:t?.capsule?.id,revision:t?.capsule?.revision??0,code:t?.code??"invalid-capsule",message:t?.message??"This journal cannot be replayed",text:Je({capsule:t?.capsule,batches:t?.batches??[]}),capsule:t?.capsule??null,batches:t?.batches??[]}))}function we(e=[],t=null,n=""){let o=t==null?"":String(t),i=typeof n=="string"?n:"";if(!o||!i)return!1;let r=De(e);return!!(r&&r[o]&&me(r[o])===i)}var je="page.copy",$e=1,ge=new WeakMap;function Ct(e){if(!e)return null;let t=ge.get(e);if(t)return t;let n=e.register({channel:je,version:$e});return ge.set(e,n),n}var Ge=e=>`copy:${e?.key??""}:${m(e?.id)}`;function Ke({records:e=[],source:t=null}={}){if(!t||t.id===void 0)return null;for(let n of e||[]){let o=n?.payload;if(!(!o?.source||!o?.destination)&&o.source.key===t.key&&m(o.source.id)===m(t.id))return{record:n,source:o.source,destination:o.destination}}return null}function We({marker:e=null,records:t=[]}={}){if(!e?.destination)return"open";let n=e.destination.id;return(t||[]).some(i=>i&&m(i.id)===m(n))?"copied":"covered"}async function At({channel:e,copies:t,source:n,insert:o}={}){if(!e||!t||!n||typeof o!="function")return{ok:!1,code:"unavailable"};let i,r;try{[i,r]=await Promise.all([e.list(),t.list()])}catch{return{ok:!1,code:"unavailable"}}let s=Ke({records:r?.ok?r.records:[],source:n});if(s){let d=We({marker:s,records:i?.ok?i.records:[]});if(d==="copied")return{ok:!1,code:"already-copied",marker:s};if(d==="covered")return{ok:!1,code:"covered",marker:s}}let l;try{l=await o()}catch{return{ok:!1,code:"insert-failed"}}if(!l||l.revision===void 0||l.id===void 0)return{ok:!1,code:"insert-failed"};t.stage({key:Ge(n),kind:"text",payload:{source:{key:n.key??"",id:n.id,revision:n.revision??0},destination:{key:l.key??"",id:l.id,revision:l.revision}}});let u=await t.flush();return u?.ok?{ok:!0,destination:l}:{ok:!1,code:u?.code||"error",destination:l}}var qe="page.ime",Xe=1,Qe="composing:",ye=new WeakMap;function St(e){if(!e)return null;let t=ye.get(e);if(t)return t;let n=e.register({channel:qe,version:Xe});return ye.set(e,n),n}function It({channel:e=null,key:t=""}={}){if(!e)return null;async function n(o){let i;try{i=await e.list()}catch{return 0}if(!i?.ok)return 0;let r=0;for(let s of i.records)if(s?.payload?.blockId===o)try{(await e.dismiss(s.id,{revision:s.revision}))?.ok&&(r+=1)}catch{}return r}return{key:t,channel:e,keep({blockId:o=null,text:i=""}={}){let r=o==null?"":String(o),s=typeof i=="string"?i:"";return!r||!s?null:e.stage({key:`${Qe}${r}`,kind:"text",payload:{blockId:r,text:s}})},async clear({blockId:o=null,text:i="",covered:r=null,records:s=[]}={}){let l=o==null?"":String(o);if(!l)return{ok:!1,code:"invalid"};if(!(typeof r=="boolean"?r:we(s,l,i)))return{ok:!1,code:"not-covered"};let d=await n(l);return d?{ok:!0,retired:d}:{ok:!1,code:"not-covered"}},async list(){return e.list()},dispose(){return e.flush()}}}function Ut(e=[]){let t=[];for(let n of e||[]){if(!n||n.supported===!1)continue;let o=n.payload;!o||typeof o.text!="string"||!o.text||typeof o.blockId!="string"||!o.blockId||t.push({id:n.id,revision:n.revision,blockId:o.blockId,text:o.text})}return t}export{Se as a,Ie as b,Ue as c,Ve as d,Ye as e,W as f,H as g,Pe as h,Ee as i,_e as j,he as k,Te as l,Me as m,Ne as n,Le as o,wt as p,Fe as q,ze as r,kt as s,bt as t,xt as u,Je as v,vt as w,we as x,je as y,$e as z,Ct as A,Ke as B,We as C,At as D,qe as E,Xe as F,St as G,It as H,Ut as I};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c}from"./c-SIM7Z3U7.js";import"./c-VHNSBD2M.js";export{a as MAX_PAYLOAD_BYTES,b as contextRefsOf,c as wantsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=/^[A-Za-z0-9._-]{1,100}$/,d="visitor-drafts",p="visitor-drafts",l=!1,u=null,i=!1,s=(t,e)=>(t?.get?.(e)||"").split(",").map(r=>r.trim()).includes(p);function m(t){l=s(t,"plugins")&&!s(t,"exclude")}function x(t=document){let e=t.documentElement.getAttribute(d);return e&&c.test(e)?e:null}var a=!1;function h(t){let e=t.querySelector('script[data-rules-name~="api"]');if(!e)return!1;let r=e.getAttribute("data-rules-version"),n=null;if(r!=="1")n=`the api rules tag says data-rules-version="${r??""}" and this version reads version 1`;else try{JSON.parse(e.textContent)}catch{n="the api rules tag does not hold readable JSON"}return n?(a||(a=!0,console.warn(`visitor-drafts: this page keeps no draft (${n})`)),!1):!0}function g(t=document,e=window.location){return l&&(e.protocol==="https:"||e.protocol==="http:")&&x(t)!==null&&h(t)}function v(t){u=t}function D(){return u}var o=null;function S(t){o=t}function T(){if(!o)return!0;try{return o()!==!1}catch{return!1}}function y(t){i=!!t}function A(){return i}var f=null;function F(t){f=t}function b(){try{return!!f?.()}catch{return!0}}export{d as a,p as b,m as c,x as d,g as e,v as f,D as g,S as h,T as i,y as j,A as k,F as l,b as m};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as m}from"./c-QQFHEODI.js";import{f as l}from"./c-EDE45NM7.js";var _=window.__clayWorkspaceBackground===!0;document.addEventListener("clay:workspace-background",()=>{_=!0});document.addEventListener("clay:workspace-foreground",()=>{_=!1});var c=()=>document.hidden||_,y=class extends EventTarget{constructor(e,{shared:s=!1,sharedData:i=!1,documentURL:n,lane:o,clientId:h,startupCheck:t=!1,keepAliveWhenHidden:a=!1,workerFeatures:d=["live-data"]}={}){super(),this.url=e,this.readyState=0,this.onopen=null,this.onmessage=null,this.onerror=null,this._shared=s&&typeof SharedWorker=="function"&&(!i||o==="live"),this._sharedData=i,this._documentURL=n,this._lane=o,this._clientId=h,this._keepAliveWhenHidden=a,this._workerFeatures=d,this._since=0,this._closed=!1,this._suspended=!1,this._repair=!1,this._startup=t,this._worker=null,this._source=null,this._visibility=()=>{clearTimeout(this._hiddenTimer),c()?(this._worker&&this._postWorker(this._worker,"hidden"),this._keepHidden()||(this._hiddenTimer=setTimeout(()=>this._suspend(),5e3))):this._suspended?this._resume():this._worker&&this._postWorker(this._worker,"visible")},this._pagehide=()=>this._suspend(!0),this._pageshow=()=>{(!c()||this._keepHidden())&&this._resume()},document.addEventListener("visibilitychange",this._visibility),document.addEventListener("clay:workspace-background",this._visibility),document.addEventListener("clay:workspace-foreground",this._visibility),window.addEventListener("pagehide",this._pagehide),window.addEventListener("pageshow",this._pageshow),this._open(),c()&&this._visibility()}_emit(e,s){if(this._closed)return;let i=s===void 0?new Event(e):new MessageEvent(e,{data:s});this.dispatchEvent(i),this[`on${e}`]?.(i)}_postWorker(e,s,i={}){e.port.postMessage({v:this._sharedData?2:1,type:s,...i})}_open(){if(!(this._closed||this._suspended)){if(this.readyState=0,!this._shared)return this._openDirect();try{let e=new SharedWorker(new URL(this._sharedData?"/_/sync/data-worker.js":"/_/sync/worker.js",window.location.origin).href,this._sharedData?"clay-sync-data":"clay-sync");this._worker=e;let s=Date.now(),i=!1;e.onerror=()=>{this._worker===e&&(this._shared=!1,this._repair=!0,this._reopen(),c()&&this._visibility())},this._startTimer=setTimeout(e.onerror,5e3),e.port.onmessage=({data:t})=>{if(!(this._worker!==e||t?.v!==(this._sharedData?2:1))){if(this._sharedData){if(t.type==="unsupported"||t.type==="capacity"){e.onerror();return}if(t.type==="gone"){this.readyState=2,this._emit("error"),this.close();return}if(!i){if(t.type!=="hello")return;if(!Array.isArray(t.features)||!this._workerFeatures.every(a=>t.features.includes(a))){e.onerror();return}i=!0,clearTimeout(this._startTimer),s=Date.now();return}if(t.type==="hello")return}if(s=Date.now(),!this._sharedData&&["status","pong","cursor","frame","gone"].includes(t.type)&&clearTimeout(this._startTimer),t.type==="status")t.state==="open"?(!this._sharedData||this.readyState!==1)&&(this.readyState=1,this._emit("open")):t.state==="connecting"&&(this.readyState=0,this._emit("error"));else if(t.type==="cursor"){clearTimeout(this._startTimer),Number.isSafeInteger(t.seq)&&(this._since=Math.max(this._since,t.seq));let a=t.resync===!0||this._repair,d=this._startup;this._repair=!1,this._startup=!1,this._emit("cursor",JSON.stringify({...t,resync:a,startup:d}))}else if(t.type==="frame"&&typeof t.data=="string")this._remember(t.data),this._emit("message",t.data);else if(this._sharedData&&t.type==="event"&&["data","data-state","data-writer","presence"].includes(t.event)&&t.data!==null&&typeof t.data=="object"&&!Array.isArray(t.data))try{this._emit(t.event,JSON.stringify(t.data))}catch{}else t.type==="gone"&&(this.readyState=2,this._emit("error"),this.close())}},e.port.start(),this._postWorker(e,c()?"hidden":"visible");let n={document:this._documentURL,lane:this._lane,since:this._since};this._sharedData&&this._lane==="live"&&(n.clientId=this._clientId),this._postWorker(e,"subscribe",n);let o=0,h=Date.now();this._pingTimer=setInterval(()=>{if(this._worker!==e)return;let t=Date.now(),a=t-h>15e3*6;if(h=t,s>=o&&(o=0),a||o&&t-o>=15e3*3){this._repair=!0,this._reopen();return}o||(o=t),this._postWorker(e,"ping")},15e3)}catch{this._shared=!1,this._reopen(),c()&&this._visibility()}}}_openDirect(){let e=new EventSource(this.url);this._source=e;let s=!1,i=!1;e.onopen=()=>{if(this._source===e&&(s&&!i&&(this._repair=!0),s=!0,this.readyState=1,this._emit("open"),this._repair||this._startup)){let n=this._repair,o=this._startup;this._repair=!1,this._startup=!1,this._emit("cursor",JSON.stringify({resync:n,startup:o}))}},e.onerror=()=>{this._source===e&&(this.readyState=e.readyState,this._emit("error"))},e.onmessage=n=>{this._source===e&&(this._remember(n.data),this._emit("message",n.data))};for(let n of["cursor","presence","data","data-state","data-writer"])e.addEventListener(n,o=>{this._source===e&&(n==="cursor"&&(i=!0),this._emit(n,o.data))})}_remember(e){try{let{seq:s}=JSON.parse(e);Number.isSafeInteger(s)&&(this._since=Math.max(this._since,s))}catch{}}_disconnect(){if(clearTimeout(this._startTimer),clearInterval(this._pingTimer),this._worker){let e=this._worker;this._worker=null,e.onerror=null,e.port.onmessage=null;try{this._postWorker(e,"unsubscribe")}catch{}e.port.close()}this._source&&(this._source.close(),this._source=null)}_keepHidden(){return this._keepAliveWhenHidden===!0||this._keepAliveWhenHidden==="shared"&&this._shared}_reopen(){let e=(this._sharedData||this._keepAliveWhenHidden===!0)&&this.readyState===1;this.readyState=0,e&&this._emit("error"),this._disconnect(),this._open()}_suspend(e=!1){clearTimeout(this._hiddenTimer),!(this._closed||this._suspended)&&(this._suspended=!0,this._repair=!0,this.readyState=0,e&&this._keepAliveWhenHidden===!0&&this._emit("error"),this._disconnect())}_resume(){clearTimeout(this._hiddenTimer),!(this._closed||!this._suspended)&&(this._suspended=!1,this._open())}close(){this._closed=!0,this.readyState=2,clearTimeout(this._hiddenTimer),this._disconnect(),document.removeEventListener("visibilitychange",this._visibility),document.removeEventListener("clay:workspace-background",this._visibility),document.removeEventListener("clay:workspace-foreground",this._visibility),window.removeEventListener("pagehide",this._pagehide),window.removeEventListener("pageshow",this._pageshow)}};var v="This document was upgraded.",u=!1;function p(r,e){let s=r.querySelector(`meta[name="${e}"]`),i=s?s.getAttribute("content"):null;return i&&i.trim()?i.trim():null}function g(r=document){return p(r,"hyper-version")}function k(r){return typeof r!="string"||!r.includes("hyper-version")?null:p(new DOMParser().parseFromString(r,"text/html"),"hyper-version")}function w(r){let e=g();return!!e&&!!r&&r!==e}function S(r){return u?!0:w(k(r))}function D(r){return u?!0:!r||typeof r.querySelector!="function"?!1:w(p(r,"hyper-version"))}function b(){if(u)return Promise.resolve();u=!0;let r=l?import("./core/save-6HT2LABE.js").then(i=>i.holdAllSaves(v),()=>{}):Promise.resolve(),e=new CustomEvent("clay:document-upgraded",{detail:{message:v}}),s=l?Promise.resolve():import("./c-42ZNV7LI.js").then(i=>i.start(e),()=>{});return document.dispatchEvent(e),Promise.all([r,s]).then(()=>{})}var f={spec:{name:"spec",relayPath:"/_/sync",documentHeader:"Document-URL",snapshotKey:"snapshot",streamPath:(r,e,s,i)=>`/_/sync?document-url=${encodeURIComponent(r)}&lane=${e}&resume-id=${s}&client-id=${encodeURIComponent(i)}`},legacy:{name:"legacy",relayPath:"/_/live-sync/save",documentHeader:"Page-URL",snapshotKey:"html",streamPath:(r,e,s,i)=>`/_/live-sync/stream?page-url=${encodeURIComponent(r)}&lane=${e}&resume-id=${s}&client-id=${encodeURIComponent(i)}`}};function A(){return m().then(r=>{let e=r?.extensions||[],s=e.includes("sync"),i=e.includes("live-data"),n=e.includes("presence"),o=s&&i&&e.includes("sync-worker-data"),h=s&&(o||e.includes("sync-worker")&&!i&&!n);return{profile:s?f.spec:f.legacy,sharedSync:h,sharedData:o,liveData:i,workerFeatures:n?["live-data","presence"]:["live-data"]}}).catch(()=>({profile:f.legacy,sharedSync:!1,sharedData:!1,liveData:!1,workerFeatures:["live-data"]}))}export{c as a,y as b,S as c,D as d,b as e,f,A as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as R}from"./c-QHWJ5ZIJ.js";import{a as Y,c as j}from"./c-
|
|
1
|
+
import{d as R}from"./c-QHWJ5ZIJ.js";import{a as Y,c as j}from"./c-ESK4S67I.js";import{g as P,q as k}from"./c-MR75YPRT.js";import{b as H}from"./c-NUHP2XDB.js";var z=Symbol("clay.surfaceTheme"),L=(()=>{"use strict";let r=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'];class d{constructor({targetModal:e,triggers:t=[],onShow:n=()=>{},onClose:u=()=>{},openTrigger:o="data-micromodal-trigger",closeTrigger:x="data-micromodal-close",openClass:F="is-open",disableScroll:E=!1,disableFocus:M=!1,awaitCloseAnimation:C=!1,awaitOpenAnimation:c=!1,debugMode:p=!1}){this.modal=typeof e=="string"?document.getElementById(e):e,this.config={debugMode:p,disableScroll:E,openTrigger:o,closeTrigger:x,openClass:F,onShow:n,onClose:u,awaitCloseAnimation:C,awaitOpenAnimation:c,disableFocus:M},t.length>0&&this.registerTriggers(...t),this.onClick=this.onClick.bind(this),this.onKeydown=this.onKeydown.bind(this)}registerTriggers(...e){e.filter(Boolean).forEach(t=>{t.addEventListener("click",n=>this.showModal(n))})}showModal(e=null){if(this.activeElement=document.activeElement,this.modal.setAttribute("aria-hidden","false"),this.scrollBehaviour("disable"),this.addEventListeners(),this.config.awaitOpenAnimation){let t=()=>{this.modal.removeEventListener("animationend",t,!1),this.setFocusToFirstNode()};this.modal.addEventListener("animationend",t,!1)}else this.setFocusToFirstNode();this.config.onShow(this.modal,this.activeElement,e)}closeModal(e=null){this.modal.setAttribute("aria-hidden","true"),this.removeEventListeners(),this.scrollBehaviour("enable"),this.config.onClose(this.modal,this.activeElement,e)}scrollBehaviour(e){if(!this.config.disableScroll)return;let t=document.querySelector("body");switch(e){case"enable":Object.assign(t.style,{overflow:""});break;case"disable":Object.assign(t.style,{overflow:"hidden"});break;default:}}addEventListeners(){this.modal.addEventListener("touchstart",this.onClick),this.modal.addEventListener("click",this.onClick),document.addEventListener("keydown",this.onKeydown)}removeEventListeners(){this.modal&&(this.modal.removeEventListener("touchstart",this.onClick),this.modal.removeEventListener("click",this.onClick)),document.removeEventListener("keydown",this.onKeydown)}onClick(e){(e.target.hasAttribute(this.config.closeTrigger)||e.target.parentNode.hasAttribute(this.config.closeTrigger))&&(e.preventDefault(),e.stopPropagation(),this.closeModal(e))}onKeydown(e){e.keyCode===27&&this.closeModal(e),e.keyCode===9&&this.retainFocus(e)}getFocusableNodes(){let e=this.modal.querySelectorAll(r);return Array(...e)}setFocusToFirstNode(){if(this.config.disableFocus)return;let e=this.getFocusableNodes();if(e.length===0)return;let t=e.filter(n=>!n.hasAttribute(this.config.closeTrigger));t.length>0&&t[0].focus(),t.length===0&&e[0].focus()}retainFocus(e){let t=this.getFocusableNodes();if(t.length!==0)if(t=t.filter(n=>n.offsetParent!==null),!this.modal.contains(document.activeElement))t[0].focus();else{let n=t.indexOf(document.activeElement);e.shiftKey&&n===0&&(t[t.length-1].focus(),e.preventDefault()),!e.shiftKey&&t.length>0&&n===t.length-1&&(t[0].focus(),e.preventDefault())}}}let l=null,g=(i,e)=>{let t=[];return i.forEach(n=>{let u=n.attributes[e].value;t[u]===void 0&&(t[u]=[]),t[u].push(n)}),t},f=i=>{if(!document.getElementById(i))return console.warn(`MicroModal: \u2757Seems like you have missed %c'${i}'`,"background-color: #f8f9fa;color: #50596c;font-weight: bold;","ID somewhere in your code. Refer example below to resolve it."),console.warn("%cExample:","background-color: #f8f9fa;color: #50596c;font-weight: bold;",`<div class="modal" id="${i}"></div>`),!1},a=i=>{if(i.length<=0)return console.warn("MicroModal: \u2757Please specify at least one %c'micromodal-trigger'","background-color: #f8f9fa;color: #50596c;font-weight: bold;","data attribute."),console.warn("%cExample:","background-color: #f8f9fa;color: #50596c;font-weight: bold;",'<a href="#" data-micromodal-trigger="my-modal"></a>'),!1},m=(i,e)=>{if(a(i),!e)return!0;for(let t in e)f(t);return!0};return{init:i=>{let e=Object.assign({},{openTrigger:"data-micromodal-trigger"},i),t=[...document.querySelectorAll(`[${e.openTrigger}]`)],n=g(t,e.openTrigger);if(!(e.debugMode===!0&&m(t,n)===!1))for(let u in n){let o=n[u];e.targetModal=u,e.triggers=[...o],l=new d(e)}},show:(i,e)=>{let t=e||{};t.targetModal=i,!(t.debugMode===!0&&f(i)===!1)&&(l&&l.removeEventListeners(),l=new d(t),l.showModal())},close:()=>{l&&(l.closeModal(),l=null)}}})(),G=(()=>{let r="",d="",l="",g="100",f="",a="",m="",b,T=!0,v=!0,i=!1,e=[],t=[],n=[];return{isShowing:!1,open(){let o=e,x=t,F=n;e=[],t=[],n=[];let E=!1,M=()=>{E||(E=!0,x.forEach(s=>s()))};(this.isShowing||document.querySelector("[data-clay-modal]"))&&(this._dismiss?.(),this._cleanupListeners?.(),document.querySelectorAll("[data-clay-modal]").forEach(s=>{Y.get(s)?.(),s.remove()}),this.isShowing=!1,document.body.style.overflow=""),this._dismiss=M;let C=b===void 0?R():b,c=j({zIndex:g,closable:!!f,titled:!!a,...m?{width:m}:{},theme:C}),p=c.root,q=c.overlay,N=c.panel,O=c.body,A=c.footer,$=c.close,D={theme:C,parts:["dialog.button"],labelParts:["dialog.buttonLabel"]},y=P("",D),w=P("",{variant:"primary",...D});w.type="submit",A.append(y,w);let S=(s,h)=>{h instanceof Node?s.append(h):s.innerHTML=h};S(O,r),S(w.firstChild,d),S(y.firstChild,l),a&&S(c.heading,a),a&&N.setAttribute("aria-label",c.heading.textContent.trim()),k(O,!(r===""||r==null),"block"),(r===""||r==null)&&a&&H(A,"border-top","0"),document.body.prepend(p);let B=!1;function I(s){B=q.contains(s.target)&&!N.contains(s.target)}function _(s){(y.contains(s.target)||$?.contains(s.target)||T&&B&&!N.contains(s.target)&&q.contains(s.target))&&L.close(),B=!1}function K(s){if(p.contains(s.target)){s.preventDefault();let h=!0;for(let V of o)try{if(V()===!1){h=!1;break}}catch{h=!1;break}h&&(E=!0,L.close())}}document.addEventListener("mousedown",I),document.addEventListener("click",_),document.addEventListener("submit",K),this._cleanupListeners=()=>{document.removeEventListener("mousedown",I),document.removeEventListener("click",_),document.removeEventListener("submit",K)};function U(){k(A,!!(d||l),"flex"),k(w,!!d,"inline-flex"),k(y,!!l,"inline-flex")}if(U(),L.show(p,{disableScroll:v,disableFocus:!0,onClose:s=>{M(),p.remove(),r="",d="",l="",g="100",f="",a="",m="",b=void 0,T=!0,v=!0,i=!1,this.isShowing=!1,document.removeEventListener("mousedown",I),document.removeEventListener("click",_),document.removeEventListener("submit",K),this._cleanupListeners=null,this._dismiss=null}}),this.isShowing=!0,F.forEach(s=>s()),!i){let s=O.querySelector(":is(input,textarea,button):not([hidden])")||[w,y].find(h=>!h.hidden);s?.focus(),s?.setSelectionRange?.(-1,-1)}},close(){L.close()},get html(){return r},set html(o){r=o},get closeHtml(){return f},set closeHtml(o){f=o},get title(){return a},set title(o){a=o},get width(){return m},set width(o){m=o},get[z](){return b},set[z](o){b=o},get yes(){return d},set yes(o){d=o},get no(){return l},set no(o){l=o},get zIndex(){return g},set zIndex(o){g=o},get disableFocus(){return i},set disableFocus(o){i=o},get disableScroll(){return v},set disableScroll(o){v=o},get onYes(){return o=>{e.push(o)}},set onYes(o){e=[o]},get onNo(){return o=>{t.push(o)}},set onNo(o){t=[o]},get onOpen(){return o=>{n.push(o)}},set onOpen(o){n=[o]}}})(),ee=G;export{z as a,ee as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as y}from"./c-QTEUO2K6.js";import{a as i,e as s,f as h,g as u,h as m,k as v}from"./c-DIKR7H57.js";import{b as r,c,d as p,e as d,f}from"./c-CUMXGHVD.js";import"./c-QY7F6EN6.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";function g(){let t=()=>{let o=d()&&c(d());document.dispatchEvent(new CustomEvent("clay:variant-change",{detail:{active:o,shown:o}}))},e=o=>r().some(n=>c(n)===o)?(document.documentElement.setAttribute("look",o),f(o),window.clay?.save?.soon?.(),t(),{ok:!0}):{ok:!1,code:"unknown-variant"};r().length>=2&&(window.clay.variants={list:()=>r().map(o=>({name:c(o),label:p(o),active:o===d()})),get active(){return d()&&c(d())},get shown(){return d()&&c(d())},preview:e,choose:e,keep:()=>Promise.resolve({ok:!1,code:"not-editing"})},document.addEventListener("clay:drafts-restored",()=>{t()}))}var L='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" aria-hidden="true"><path d="M12 9a3 3 0 1 1 0 6 3 3 0 0 1 0-6M10 3h4l1.5 3 3.5-.5 2 4-2 2.5 2 2.5-2 4-3.5-.5-1.5 3h-4l-1.5-3-3.5.5-2-4 2-2.5-2-2.5 2-4 3.5.5Z"/></svg>',w=()=>window.clay?.blockeditor?.history??window.clay?.undo??null;function S({addItem:t,beforeOpen:e}){let o=null,n=()=>{let a=w();if(!a)return;let l=o??{canUndo:!!a.canUndo,canRedo:!!a.canRedo};t({id:"clay.undo",pair:[{id:"clay.undo.undo",label:"Undo",keys:y("\u2318Z","Ctrl+Z"),disabled:!l.canUndo,run:()=>w()?.undo()},{id:"clay.undo.redo",label:"Redo",keys:y("\u2318\u21E7Z","Ctrl+Shift+Z"),disabled:!l.canRedo,run:()=>w()?.redo()}]})};document.addEventListener("clay:undo-change",a=>{o={canUndo:!!a.detail?.canUndo,canRedo:!!a.detail?.canRedo},n()}),n(),e.push(n)}function R(t=window.location){let e=t.pathname.replace(/\/+$/,"")||"/";return`/_/copy${e==="/"?"":e}`}function N(){if(document.querySelector('clay-editor-ui[data-clay-ui="menu"]'))return;let t=v({sections:[["clay.undo"],null],icon:L,label:"Settings"}),{embedded:e,skin:o,addItem:n,removeItem:a,open:l,close:k,note:b,goo:E,beforeOpen:U}=t;t.mount(e?[i,s,o??u,m]:[i,s,h,u,m]),g(),S({addItem:n,beforeOpen:U}),n({id:"clay.download",label:"Download copy",run:()=>window.clay.visitorDrafts.download()}),n({id:"clay.copy",label:"Make your own copy",href:R()}),window.clay.menu={addItem:n,removeItem:a,open:l,close:k,note:b,embedded:e,button:E},document.dispatchEvent(new CustomEvent("clay:menu-ready"))}export{N as start};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as S}from"./c-WMRJKQ2V.js";import{d as k,g as A,h as j,i as E,j as M,k as w,m as $,v as N}from"./c-OH2FPYSY.js";var G="blockeditor-local",U="blockeditor-net",V="blockeditor-seed",B=N,Q=Symbol("blockeditor-history"),X=Object.freeze(["flow","attrs","gone","boardFields","tableFields","origins"]),Y=new Set(["id","pos"]),F=new WeakMap,Z=t=>{let s=F.get(t);return s||F.set(t,s=Object.freeze([...Object.keys(t.spec.attrs||{}).filter(r=>!Y.has(r)),...t.name==="table"?["rows"]:[]])),s},v=(t,s)=>t.name==="table"&&s==="rows"?{}:t.spec.attrs[s].default,tt=(t,s)=>t===s||JSON.stringify(t)===JSON.stringify(s),et=t=>`${t.client}.${t.clock}`,st=t=>{let s=t.indexOf(".");return{client:+t.slice(0,s),clock:+t.slice(s+1)}},ot=t=>t>=55296&&t<=56319,nt=t=>t>=56320&&t<=57343,_=0,rt=t=>`${t.ydoc.clientID.toString(36)}-${(_++).toString(36)}`,q=0,it=t=>`b${t.ydoc.clientID.toString(36)}${(q++).toString(36)}`;function at(t=new S){return{ydoc:t,flow:t.getText("flow"),attrs:t.getMap("attrs"),gone:t.getMap("gone"),boardFields:t.getMap("boardFields"),tableFields:t.getMap("tableFields"),origins:t.getMap("origins")}}var W=t=>t.split("!")[0].split("~")[0],L=t=>t.includes("!"),dt=t=>{let s={};for(let r of t)s[r.type.name]=r.attrs&&Object.keys(r.attrs).length?{...r.attrs}:!0;return s},ht=t=>{let s={};for(let r of t){if(A(r)){for(let[c,i]of Object.entries(E(r.attrs.entries)))s[c]=JSON.parse(JSON.stringify(i));continue}s[r.type.name]=r.attrs&&Object.keys(r.attrs).length?{...r.attrs}:!0}return s},ut=t=>t.map(s=>s.type.name+(s.attrs&&Object.keys(s.attrs).length?JSON.stringify(s.attrs):"")).sort().join("|");function gt(t,s){if(s==="code_block")return[];let r=new Map,c=new Set;for(let o of Object.keys(t))L(o)&&t[o]&&c.add(o.split("!")[0]);for(let o of Object.keys(t).sort()){let a=t[o];a==null||L(o)||c.has(o)||r.set(W(o),a)}let i=[],l=null;for(let[o,a]of r)k.marks[o]&&(!w.has(o)||$(o,a===!0?{}:a))?i.push(k.marks[o].create(a===!0?null:a)):(l??={})[o]=a;if(l){let o=M(l);o.length&&i.push(j(o))}return i}var h=t=>Number.isSafeInteger(t)&&t>=0,p=t=>{throw new RangeError(t)},T=t=>(t!=="before"&&t!=="after"&&p(`Unknown affinity: ${t}`),t),I=(t,s,r)=>{let c=0,i=t.length;for(;c<i;){let l=c+i>>1;s(t[l])<=r?c=l+1:i=l}return c};function bt(t,s){(!t||typeof t!="object"||!h(t.tokens))&&p("A projection map needs a walk result with a token count"),h(s)||p("A projection map needs a nonnegative physical length");let r=t.holes===void 0?[]:t.holes;Array.isArray(r)||p("A projection map needs the walk holes");let c=[],i=[],l=[0],o=0,a=0,b=-1,m=e=>{c.push({logicalStart:o,logicalLength:e,physicalStart:a,physicalLength:e,kind:"visible"}),o+=e,a+=e},J=e=>{let n=i[i.length-1];n&&n.at===o?(n.length+=e,n.end+=e,c[c.length-1].physicalLength+=e,l[l.length-1]+=e):(i.push({at:o,start:a,end:a+e,length:e}),c.push({logicalStart:o,logicalLength:0,physicalStart:a,physicalLength:e,kind:"hidden"}),l.push(l[l.length-1]+e)),a+=e};for(let e of r)(!e||typeof e!="object"||!h(e.at)||!h(e.len))&&p("Malformed walk hole"),e.at<b&&p("Walk holes are out of order"),e.at>t.tokens&&p("A walk hole sits past the logical length"),b=e.at,e.at>o&&m(e.at-o),e.len&&J(e.len);o<t.tokens&&m(t.tokens-o),a!==s&&p("Walk holes do not account for the physical length");let x=e=>I(i,n=>n.at,e),O=e=>I(i,n=>n.end,e),g=e=>e+l[x(e)],K=e=>{let n=i[x(e)-1];return n&&n.at===e?n:null},P=e=>{let n=i[O(e)];return n&&n.start<=e?n:null},R=(e,n)=>{let f=T(n);(!h(e)||e>t.tokens)&&p(`Logical position ${e} is outside the map`);let d=K(e);return d?f==="before"?d.start:d.end:g(e)},C=(e,n)=>{T(n),(!h(e)||e>s)&&p(`Physical position ${e} is outside the flow`);let f=P(e);return f?f.at:e-l[O(e)]},D=(e,n)=>{(!h(e)||!h(n)||e>t.tokens||n>t.tokens)&&p(`Logical range ${e}..${n} is outside the map`);let f=[];if(n<=e)return f;let d=g(e);for(let u of i)if(!(u.at<=e)){if(u.at>n)break;u.start>d&&f.push([d,u.start]),d=u.end}let y=g(n);return y>d&&f.push([d,y]),f};return{segments:c,logicalLength:t.tokens,physicalLength:s,toPhysical:R,toLogical:C,physicalRanges:D}}export{G as a,U as b,V as c,B as d,Q as e,X as f,Z as g,v as h,tt as i,et as j,st as k,ot as l,nt as m,rt as n,it as o,at as p,W as q,L as r,dt as s,ht as t,ut as u,gt as v,bt as w};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import{b as s}from"./c-Y6F2FORL.js";import{b as h}from"./c-QY7F6EN6.js";import{a as d}from"./c-2YYDMLNZ.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var m=`html:has(> body > .clay-intro) { height: auto !important; overflow-y: auto !important; }
|
|
2
|
+
body:has(> .clay-intro) { height: auto !important; overflow: visible !important; }
|
|
3
|
+
.clay-intro {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: block;
|
|
6
|
+
}
|
|
7
|
+
@media print { .clay-intro { display: none; } }
|
|
8
|
+
`,f=`:host { color: inherit !important; }
|
|
9
|
+
.clay-intro__close {
|
|
10
|
+
position: absolute; top: 10px; right: 10px; z-index: 1;
|
|
11
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
12
|
+
width: 28px; height: 28px; min-height: 0; margin: 0; padding: 0;
|
|
13
|
+
border: 0; border-radius: 4px; background: none; box-shadow: none;
|
|
14
|
+
color: inherit; opacity: .55; cursor: pointer; line-height: 1;
|
|
15
|
+
}
|
|
16
|
+
.clay-intro__close:hover { opacity: 1; background: none; color: inherit; }
|
|
17
|
+
.clay-intro__close:focus-visible { opacity: 1; outline: 2px solid currentColor; outline-offset: 2px; }
|
|
18
|
+
.clay-intro__close svg { display: block; width: 12px; height: 12px; fill: currentColor; stroke: none; }
|
|
19
|
+
@media (pointer: coarse) { .clay-intro__close { width: 44px; height: 44px; top: 4px; right: 4px; } }
|
|
20
|
+
.clay-intro__close[data-manual] {
|
|
21
|
+
width: auto; height: 36px; padding: 0 14px; opacity: 1;
|
|
22
|
+
border-radius: 999px; font-size: 12px; font-weight: 500;
|
|
23
|
+
text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
|
|
24
|
+
}
|
|
25
|
+
@media (pointer: coarse), (max-width: 680px) { .clay-intro__close[data-manual] { height: 44px; } }
|
|
26
|
+
`;var u={close:"Hide this introduction",hide:"Hide intro",label:t=>`About ${t}`},v="a[href], button, input, select, textarea, [tabindex]:not([tabindex='-1'])",C="textarea, select",_=["checkbox","radio","button","submit","reset","file"];function E(t){return t.isContentEditable||t.closest(C)?!0:t.tagName!=="INPUT"?!1:_.indexOf(t.type)<0}function g(){try{return new URLSearchParams(window.location.search).get("intro")==="1"}catch{return!1}}function S(){if(document.getElementById("clay-intro-style"))return;let t=document.createElement("style");t.id="clay-intro-style",t.setAttribute("clay","editor-ui"),t.textContent=m,document.head.appendChild(t)}function b(){let t=[...document.querySelectorAll(v)].find(e=>!e.disabled&&!E(e)&&!e.closest("[clay~='editor-ui']")&&(typeof e.checkVisibility!="function"||e.checkVisibility()));t?t.focus({preventScroll:!0}):document.body.focus({preventScroll:!0})}function y({template:t,appName:e,labelText:r,onClose:i}){S();let o=document.createElement("section");o.className="clay-intro",o.setAttribute("clay","editor-ui"),o.setAttribute("sap-ignore",""),o.setAttribute("aria-label",u.label(e)),o.appendChild(t.content.cloneNode(!0));let n=document.createElement("button");return n.type="button",n.className="clay-intro__close",r?(n.textContent=r,n.setAttribute("data-manual","")):(n.setAttribute("aria-label",u.close),n.innerHTML='<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" aria-hidden="true"><path d="M1.4 0 6 4.6 10.6 0 12 1.4 7.4 6 12 10.6 10.6 12 6 7.4 1.4 12 0 10.6 4.6 6 0 1.4z"/></svg>'),n.addEventListener("click",()=>i()),h({name:"intro-close",content:n,css:[f],parent:o}),o.addEventListener("click",c=>{if(c.target.closest("[visitor-intro-dismiss]")){i();return}c.target.closest("[visitor-intro-start]")&&(c.preventDefault(),window.scrollTo({top:window.scrollY+o.getBoundingClientRect().bottom,behavior:"smooth"}))}),o}function M({memory:t,template:e,appName:r,hadDraft:i}){if(!e||!e.content.textContent.trim()&&!e.content.querySelector("img, svg, video, canvas"))return null;if(e.getAttribute("visitor-intro")==="manual"){let o=window.matchMedia&&window.matchMedia("print").matches,n=g()||!(t.get().intro.done||d.servedHash||o);return T({memory:t,template:e,appName:r,open:n})}return!g()&&(t.get().intro.done||i||d.servedHash||window.matchMedia&&window.matchMedia("print").matches)?null:A({memory:t,template:e,appName:r})}function A({memory:t,template:e,appName:r}){let i=y({template:e,appName:r,onClose:()=>c("closed")}),o=!1,n=0;function c(l){if(o)return;o=!0,removeEventListener("scroll",p),n&&cancelAnimationFrame(n);let a=i.getBoundingClientRect().height,x=window.scrollY;if(t.get().intro.done=l,t.save(),i.remove(),l==="scrolled"){let w=/hidden|clip/.test(getComputedStyle(document.body).overflowY+getComputedStyle(document.documentElement).overflowY);window.scrollTo(0,w?0:Math.max(0,x-a))}s(),l!=="scrolled"&&b()}function p(){n||(n=requestAnimationFrame(()=>{n=0;let l=i.getBoundingClientRect().bottom,a=scrollY>0&&scrollY+innerHeight>=document.documentElement.scrollHeight-1;(l<1||a&&l<innerHeight)&&c("scrolled")}))}return document.body.prepend(i),s(),addEventListener("scroll",p,{passive:!0}),i}function T({memory:t,template:e,appName:r,open:i}){if(!i)return null;let o=y({template:e,appName:r,labelText:u.hide,onClose:n});function n(){t.get().intro.done="closed",t.save(),o.remove(),s(),b()}return document.body.prepend(o),s(),o}export{u as COPY,M as mountIntro};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./c-YDW4VCHP.js";import"./c-MFOSMAVM.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-6IJEVE6B.js";import"./c-QQFHEODI.js";import"./c-IJUK2GPW.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-PWJSJEJU.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{a as replace};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=t=>Array.isArray(t?.document?.helpers)&&t.document.helpers.some(e=>e?.name==="blockeditor-tool"&&(e.state==="ready"||e.state==="unavailable"));export{a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=null,n=()=>s??=import("./c-NVU3DORS.js").catch(t=>{throw s=null,t}),e=t=>(...i)=>{n().then(o=>(t?o[t]:o.default)(...i))},l=e(null),r=e("toastPersistent"),a=()=>{n().catch(()=>{})},c=(...t)=>{(s||typeof window.clay?.toastPersistent=="function")&&e("dismissPersistent")(...t)};export{l as a,r as b,a as c,c as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as X}from"./c-LS7IVQVW.js";import{a as Q}from"./c-NEQRFC4O.js";import{i as G,k as j,u as h}from"./c-GO635CRU.js";import{c as z,g as J,h as _,p as L,t as N}from"./c-V2V5FKXX.js";import{f as M,h as K,u as V}from"./c-WMRJKQ2V.js";import{F as D,S as P,T as S,W as R,Y as T,aa as U,ba as I,ca as C,d as w,fa as u,ga as H,na as W,o as Y,p as F,q}from"./c-OH2FPYSY.js";var O=class extends Error{constructor(t){super(t),this.name="YMigrationError",this.code="invalid-source"}},i=e=>{throw new O(e)},$=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),g=e=>JSON.parse(u(e));function ot(e){(!Array.isArray(e)||!e.length)&&i("Expected at least one hybrid page value");for(let t of e){(!$(t)||!$(t.blocks)||Object.keys(t).some(o=>o!=="blocks"&&o!=="deleted"))&&i("Expected a hybrid page value with blocks and optional deleted ids"),t.deleted!=null&&!$(t.deleted)&&i("Invalid hybrid page tombstones");for(let[o,r]of Object.entries(t.blocks))!t.deleted?.[o]&&(!o||o==="__proto__"||!$(r))&&i(`Invalid hybrid page block: ${o}`),!t.deleted?.[o]&&/^~|~\d+$/.test(o)&&i(`Reserved hybrid page block id: ${o}`)}return C(e)}var rt=(e,t)=>{let o;try{o=F(w,e)}catch{return i(`Invalid mark key on block: ${t}`)}return Y([...o].sort((r,n)=>r.type.rank-n.type.rank))},Z=(e,t)=>{let o=U(e.m,e.c.length);o||i(`Invalid mark runs on block: ${t}`);for(let r=0;r<o.length;r++){let n=o[r];typeof n!="string"&&i(`Invalid mark key on block: ${t}`),n.startsWith("@")&&(n!==S||e.c[r]!==P)&&i(`Unsupported inline atom on block: ${t}`),e.t==="code_block"&&n&&i(`Unsupported formatting in code block: ${t}`),n.startsWith("@")||(o[r]=rt(n,t))}return o};function nt(e,t,o){let r={t:t.t,pos:o};for(let n of Object.keys(t))n==="t"||n==="pos"||n==="c"||n==="m"||(r[n]=g(t[n]));if(t.c!=null&&typeof t.c!="string"&&i(`Invalid text on block: ${e}`),r.c=t.c??"",typeof t.c=="string"&&t.m!=null){let n=Z(t,e);n.some(Boolean)&&(r.m=I(n))}else t.m!=null&&i(`Mark runs require flat text on block: ${e}`);return r}function st(e,t,o){let r=Object.hasOwn(R,t.t);!r&&(typeof t.t!="string"||!t.t||t.t==="opaque_block")&&i(`Unsupported hybrid block type: ${t.t}`);let n=String(o+1).padStart(8,"0");if(!r)return nt(e,t,n);let d=w.nodes[t.t],c=J(d),k=new Set(["t","pos","c","m",...c,...t.t==="table"?["rows"]:[]]),f={t:t.t,pos:n};for(let s of Object.keys(t))k.has(s)||(f[s]=g(t[s]));for(let s of c){let a=t[s]===void 0?_(d,s):t[s];u(a)!==u(_(d,s))&&(f[s]=g(a))}if(t.t==="table"&&(t.rows!==void 0&&!$(t.rows)&&i(`Invalid table rows: ${e}`),f.rows=g(t.rows??{})),!d.isTextblock)return t.c!=null&&t.c!==""&&!(Array.isArray(t.c)&&!t.c.length)&&i(`Unexpected text on block: ${e}`),t.m!=null&&!(Array.isArray(t.m)&&!t.m.length)&&i(`Unexpected marks on block: ${e}`),f;t.c!=null&&typeof t.c!="string"&&!Array.isArray(t.c)&&i(`Invalid text on block: ${e}`),typeof t.c=="string"&&t.m!=null?Z(t,e):t.m!=null&&i(`Mark runs require flat text on block: ${e}`);let y=D(w,e,t);y.check();let{c:B,m:b}=q(y.content);return f.c=B,b.some(Boolean)&&(f.m=I(b)),f}function it(e,t){let o;try{let r=ot(e),n=T(r),d=Object.fromEntries(n.map((s,a)=>[s,st(s,r[s],a)]));o=new M,o.clientID=t;let c=L(o),k=0;o.transact(()=>{for(let s of n){let a=d[s],{pos:at,c:A,m:tt,...E}=a;if(a.t==="board"&&(delete E.columns,delete E.cards),c.attrs.set(s,new V(Object.entries(g(E)))),a.t==="board"){for(let[m,p]of Object.entries(a.columns??{})){c.boardFields.set(h(s,"column",m,"alive"),!0);for(let l of["name","pos"])c.boardFields.set(h(s,"column",m,l),p[l]??"")}for(let[m,p]of Object.entries(a.cards??{})){c.boardFields.set(h(s,"card",m,"alive"),!0);for(let l of["title","owner","due"])p[l]!==void 0&&c.boardFields.set(h(s,"card",m,l),p[l]);c.boardFields.set(h(s,"card",m,"placement"),{columnId:p.col??"",pos:p.pos??""})}}if(c.flow.insertEmbed(c.flow.length,{b:s},{}),!A)continue;let v=0;for(let[m,p]of I(U(tt,A.length)??Array(A.length).fill(""))){if(p===S)for(let l=0;l<m;l++)c.flow.insertEmbed(c.flow.length,{br:1},{});else{let l=Object.fromEntries(Object.entries(N(F(w,p))).map(([et,x])=>[`${et}~${t}-m${(k++).toString(36)}`,x&&typeof x=="object"?g(x):x]));c.flow.insert(c.flow.length,A.slice(v,v+m),l)}v+=m}}},z);let f=G(K(o)),y=Math.ceil(f.length/j),b={v:1,g:0,y:y<=1?{seed:f}:Object.fromEntries(Array.from({length:y},(s,a)=>[`seed.${a}.${y}`,f.slice(a*j,(a+1)*j)]))};return u(Q(b))!==u(d)&&i("Hybrid page data cannot be represented without loss"),b}catch(r){throw r instanceof O?r:new O(`Cannot migrate hybrid page: ${r.message}`)}finally{o?.destroy()}}function ct(e){let t=parseInt(H(`blockeditor-seed:v1:${u(e)}`).slice(0,8),16)>>>0;return t<2?t+2:t}function $t(e){let t=W(e,{seed:e.getAttribute("data-rev")??""}),o={};return t.forEach((r,n)=>{let d=X(r,null);d.pos=String(n+1).padStart(8,"0"),o[r.id]=d}),it([{blocks:o}],ct(o))}export{$t as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as r,c as l,d as o,f as i,g as e,h as a}from"./c-
|
|
1
|
+
import{b as r,c as l,d as o,f as i,g as e,h as a}from"./c-DIKR7H57.js";var v={light:[255,252,246],dark:[26,29,44],mutedLight:[107,89,66],mutedDark:[163,169,194]},n=`.clay-menu-edit { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 28px; margin: 0; padding: 0 8px 0 5px; border: 0; background: none; font: 500 13px/1 var(--bevel-font-sans); color: var(--bevel-ink); cursor: pointer; }
|
|
2
2
|
.clay-menu-edit::before { content: ""; position: absolute; inset: -8px 0; }
|
|
3
3
|
.clay-menu-track { position: relative; display: block; box-sizing: border-box; width: 36px; height: 20px; border: 1px solid var(--bevel-line-2); background: var(--bevel-sunk); transition: background-color .14s, border-color .14s; }
|
|
4
4
|
.clay-menu-thumb { position: absolute; top: 2px; left: 2px; box-sizing: border-box; width: 14px; height: 14px; border: 2px solid; border-color: var(--bevel-knob-hi) var(--bevel-edge-lo) var(--bevel-edge-lo) var(--bevel-knob-hi); background: var(--bevel-knob); transition: translate .15s cubic-bezier(.4, 0, .2, 1); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as _,d as v}from"./c-WN3MXOLT.js";import{b as c}from"./c-RVMWGXEJ.js";import{b as u,c as s}from"./c-NUHP2XDB.js";import{e as b}from"./c-
|
|
1
|
+
import{a as _,d as v}from"./c-WN3MXOLT.js";import{b as c}from"./c-RVMWGXEJ.js";import{b as u,c as s}from"./c-NUHP2XDB.js";import{e as b}from"./c-QQFHEODI.js";import"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var d="#FFFCF6",l=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],y=18,h=3,p=null,f=null;function C(){return f??=Promise.all([import("./c-TFLRT5JX.js"),import("./c-46LJAZZJ.js")]).then(([i,e])=>p={RUNTIME_ONLY:i.RUNTIME_ONLY,CHIP_FONT:`600 11px/16px ${e.FONT_MONO}`}).catch(i=>{throw f=null,i}),f}var $=()=>C().then(()=>!0,()=>!1);function a(i){return i.setAttribute("clay",p.RUNTIME_ONLY),i}function A(i){let e=i&&Array.isArray(i.people)?i.people:[],o=[];for(let t of e){if(!t||t.you===!0||typeof t.id!="string"||!t.id||typeof t.editing!="string"||!_.test(t.editing))continue;let n=typeof t.name=="string"&&t.name.trim()?t.name.trim():"Someone";o.push({id:t.id,name:n,path:t.editing})}return o}var m=class{constructor(){this.editors=[],this.root=null,this._gate=null,this._frame=0,this._following=!1,this._onMove=()=>this.schedule()}supported(){return this._gate||(this._gate=b("presence").then(e=>e===!0,()=>!1)),this._gate}async update(e){this.editors=A(e),await this.supported()&&await this.render()}clear(){this.editors=[],this.follow(!1),this._frame&&cancelAnimationFrame(this._frame),this._frame=0,this.root&&this.root.remove(),this.root=null}schedule(){this._frame||(this._frame=requestAnimationFrame(()=>{this._frame=0,this.render()}))}render(){return p?(this.paint(),Promise.resolve()):$().then(e=>{e&&this.paint()})}paint(){let e=new Map;for(let t of this.editors){let n=v(t.path);n&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}let o=[];for(let[t,n]of e){let r=this.box(t,n);r&&o.push(r)}if(!o.length){this.root&&(this.root.textContent="",u(this.root,"display","none")),this.follow(this.editors.length>0);return}this.build()&&(this.root.textContent="",this.root.append(...o),u(this.root,"display","block"),this.follow(!0))}box(e,o){let t=e.getBoundingClientRect();if(!(t.width||t.height))return null;let n=c(o[0].id),r=a(s("div",[...l,"position:fixed","box-sizing:border-box","pointer-events:none",`top:${Math.round(t.top-h)}px`,`left:${Math.round(t.left-h)}px`,`width:${Math.round(t.width+h*2)}px`,`height:${Math.round(t.height+h*2)}px`,`border:2px solid ${n}`,`box-shadow:0 0 0 1px ${d}, inset 0 0 0 1px ${d}`]));r.setAttribute("data-clay-editing-marker","");let M=t.top-h>=y+2,x=a(s("div",[...l,"position:absolute","left:-2px",M?"bottom:100%":"top:100%","display:flex","gap:2px","pointer-events:none"]));for(let g of o){let w=a(s("span",[...l,"box-sizing:border-box",`height:${y}px`,"padding:1px 6px",`font:${p.CHIP_FONT}`,"letter-spacing:.02em","white-space:nowrap","max-width:180px","overflow:hidden","text-overflow:ellipsis",`background-color:${c(g.id)}`,`color:${d}`,`box-shadow:0 0 0 1px ${d}`],g.name));w.setAttribute("data-clay-editing-chip",""),x.appendChild(w)}return r.appendChild(x),r}build(){return this.root&&this.root.isConnected?!0:typeof document>"u"||!document.body?!1:(this.root=a(s("div",[...l,"position:fixed","top:0","left:0","width:0","height:0","overflow:visible","z-index:2147482999","pointer-events:none","display:none"])),this.root.setAttribute("data-clay-editing",""),document.body.appendChild(this.root),!0)}follow(e){if(typeof window>"u"||!!e===this._following)return;this._following=!!e;let o=e?"addEventListener":"removeEventListener";window[o]("scroll",this._onMove,{capture:!0,passive:!0}),window[o]("resize",this._onMove,{passive:!0}),document[o]("input",this._onMove),document[o]("clay:sync-applied",this._onMove)}},N=new m;var O=N;export{m as EditingMarker,O as default,N as editingMarker};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{E as _,X as A,aa as D,ea as F,f as O,ja as T}from"./c-OH2FPYSY.js";import"./c-RETTCOWO.js";import{a as L,b as I}from"./c-RHMPKZZ7.js";import"./c-VHNSBD2M.js";var P="\uFFFC",R='@{"type":"hard_break"}',q={b:"strong",i:"em",s:"strike",c:"code"},z=new Set(["paragraph","heading","list_item","toggle","quote","callout","code_block"]),B=new Set(["paragraph","heading","list_item","quote","callout","code_block","toggle","divider","toc","image","file","table","chart","board","tool","preserved"]),X=new Set(["\\","`","*","_","[","]","(",")","#","!",">","|","<","&"]),U=new Set(["-","+","=","~"]);function E(n){let s=String(n??""),i="",u="";for(let c of s){let a=X.has(c);!a&&u===""&&U.has(c)&&(a=!0),!a&&c==="."&&u!==""&&/^\d+$/.test(u)&&(a=!0),i+=a?`\\${c}`:c,u=c===`
|
|
2
|
+
`?"":u+c}return i}function W(n){let s=String(n),i=(s.match(/`+/g)??[]).reduce((a,f)=>Math.max(a,f.length),0),u="`".repeat(i+1),c=/^[`\s]|[`\s]$/.test(s)?" ":"";return`${u}${c}${s}${c}${u}`}function Y(n,s=""){let i=String(n??"").replace(/\r\n?/g,`
|
|
3
|
+
`).replace(/\n$/,""),u=(i.match(/`+/g)??[]).reduce((f,k)=>Math.max(f,k.length),0),c="`".repeat(Math.max(3,u+1)),a=String(s??"").trim().split(/\s+/)[0].replace(/`/g,"");return`${c}${a}
|
|
4
|
+
${i}
|
|
5
|
+
${c}`}var N=n=>/[\s()<>]/.test(n)?`<${n.trim().replace(/</g,"%3C").replace(/>/g,"%3E")}>`:n;function G(n){let s={},i=null,u=[];for(let c of O(n)){if(c.name===void 0){c.code==="a"?i=String(c.attrs?.[0]??""):q[c.code]?s[q[c.code]]=!0:u.push(c.code);continue}if(c.name==="mention"){u.push("mention");continue}c.name!=="date"&&u.push(c.name)}return{codes:s,href:i,dropped:u}}function S(n,s){let i=typeof n.c=="string"?n.c:"",u=D(n.m,i.length)??[],c="";for(let a=0;a<i.length;){let f=u[a]??"";if(i[a]===P&&f[0]==="@"){f===R?c+=`\\
|
|
6
|
+
`:s("inline object"),a++;continue}let k=a+1;for(;k<i.length&&(u[k]??"")===f&&!(i[k]===P&&f[0]==="@");)k++;let h=i.slice(a,k),{codes:$,href:g,dropped:C}=G(f);for(let t of C)s(t);let w;if($.code){w=W(h);for(let t of["strong","em","strike"])$[t]&&s(t)}else{let t=E(h),r=t.slice(0,t.length-t.trimStart().length),e=t.slice(t.trimEnd().length),o=t.slice(r.length,t.length-e.length);o&&($.em&&(o=`*${o}*`),$.strong&&(o=`**${o}**`),$.strike&&(o=`~~${o}~~`)),w=r+o+e}g&&(w=`[${w}](${N(g)})`),c+=w,a=k}return c}var J=(n,s=2)=>Math.min(6,Math.max(1,Number.isInteger(n)?n:s));function M(n,s){if(n.t==="toc")return A(n,s);if(n.t==="chart"){let i=T([n,...s.filter(c=>c.t==="table")]),u=i.indexOf(`
|
|
7
|
+
<table`);return u<0?i:i.slice(0,u)}return T([n])}var Q=n=>{let s=[];return n.pageIcon!=null&&n.pageIcon!==""&&s.push("Page icon"),(n.pageCoverSrc!=null||n.pageCoverAlt!=null||n.pageCoverX!=null||n.pageCoverY!=null)&&s.push("Page cover"),s};function V(n,s){let i=[],u=n.indexOf(s),c=new Map(n.map(a=>[a.id,a]));for(let a=u+1;a<n.length;a++){let f=n[a].parent??null,k=!1;for(let h=0;f&&h<64;h++){if(f===s.id){k=!0;break}f=c.get(f)?.parent??null}if(!k)break;i.push(n[a])}return i}function H(n){let s=F(n??{}),i=s.filter(r=>r&&typeof r.t=="string"),u=i.find(r=>r.t==="heading"&&(r.level??2)===1&&(r.parent??null)===null)??null,c=[],a=[],f=(r,e)=>c.push({block:r.id??null,type:r.t,name:e}),k=r=>{let e=new Set;return o=>{e.has(o)||(e.add(o),a.push({block:r.id??null,type:r.t,name:o}))}},h=[],$=!1,g=r=>{h.length&&h[h.length-1]!==""&&h.push(""),h.push(...String(r).split(`
|
|
8
|
+
`)),$=!1},C=r=>{!$&&h.length&&h[h.length-1]!==""&&h.push(""),h.push(r),$=!0},w=new Set;for(let r of s){if(!r||typeof r.t!="string"||w.has(r.id))continue;let e=r,o=k(e),p=e.t;if(p==="opaque_block"||!B.has(p)){o(`opaque record (${String(e.raw?.t??p)})`);let l=z.has(p)?S(e,o):typeof e.c=="string"?E(e.c):"";l.trim()&&g(l);continue}if(p==="paragraph"){g(S(e,o));continue}if(p==="heading"){let l=e.id===u?.id?Q(e):[];if(l.length){for(let d of l)f(e,d);g(M(e,s));continue}e.pageIcon!=null&&e.pageIcon!==""&&o("heading icon"),g(`${"#".repeat(J(e.level))} ${S(e,o)}`.trimEnd());continue}if(p==="toggle"){let l=e.level===1||e.level===2||e.level===3?e.level:null;if(l){o("toggle collapse"),g(`${"#".repeat(l)} ${S(e,o)}`);continue}f(e,"Toggle");let d=V(i,e);for(let b of d)w.add(b.id);g(T([e,...d]));continue}if(p==="list_item"){e.owner!=null&&o("owner"),e.due!=null&&o("due date");let l=Math.max(0,Math.min(8,Number.isInteger(e.indent)?e.indent:0)),d=e.kind==="ordered"?"1.":"-",b=e.kind==="check"?e.checked?" [x]":" [ ]":"";C(`${" ".repeat(l)}${d}${b} ${S(e,o)}`.trimEnd());continue}if(p==="quote"){let l=S(e,o).split(`
|
|
9
|
+
`).map(d=>d?`> ${d}`:">").join(`
|
|
10
|
+
`);g(l);continue}if(p==="code_block"){g(Y(e.c,e.lang));continue}if(p==="divider"){g("---");continue}if(p==="image"){let l=String(e.src??"");if(e.width!=null&&o("image width"),e.align!=null&&o("image alignment"),!l){o("image address");let m=String(e.alt??"");m&&g(E(m));continue}let d=E(e.alt??""),b=e.caption?` "${String(e.caption).replace(/"/g,'\\"')}"`:"";g(`}${b})`);continue}if(p==="file"){e.size!=null&&o("file size"),e.mime!=null&&o("file type");let l=String(e.src??""),d=E(e.name||"file");g(l?`[${d}](${N(l)})`:d);continue}if(p==="table"){let l=Array.isArray(e.cols)?e.cols:[],d=Array.isArray(e.rows)?e.rows:[];for(let x of l)x.kind!=null&&o("column kind"),x.width!=null&&o("column width");if(e.sort!=null&&o("sort"),!l.length){o("empty table");continue}let b=x=>(typeof x=="string"?E(x):x&&typeof x=="object"?S(x,o):"").replace(/\n/g," ").trim(),m=l.map(x=>E(x.name??"")).join(" | "),y=l.map(()=>"---").join(" | "),v=d.map(x=>`| ${l.map(j=>b(x.cells?.[j.id])).join(" | ")} |`);g([`| ${m} |`,`| ${y} |`,...v].join(`
|
|
11
|
+
`));continue}if(p==="toc"){f(e,"Table of contents"),g(A(e,s));continue}if(p==="chart"){f(e,"Chart"),g(M(e,s));continue}if(p==="board"){f(e,"Board"),g(M(e,s));continue}if(p==="tool"){f(e,"Tool"),g(M(e,s));continue}if(p==="preserved"){f(e,"Raw HTML"),g(M(e,s));continue}p==="callout"&&(f(e,"Callout"),g(M(e,s)))}let t=h.join(`
|
|
12
|
+
`).replace(/^\n+/,"").replace(/\n+$/,"");return{text:t?`${t}
|
|
13
|
+
`:"",extensions:c,losses:a,blocks:i.length}}function K(n="page"){return`${String(n??"").replace(/[\\/:*?"<>|\u0000-\u001f]+/g,"-").replace(/^[.\s]+/,"").replace(/[.\s]+$/,"")||"page"}.md`}function se({view:n=null,download:s=I}={}){if(!n)return{run:()=>Promise.resolve({ok:!1,code:"not-editing"}),dispose(){}};let i=n.dom.ownerDocument,u=null,c=!1;function a(){let t=u;if(!t)return!1;u=null;for(let[r,e,o,p]of t.listen)r.removeEventListener(e,o,p);return t.panel.remove(),!0}function f(){return a()?(n.focus?.(),{ok:!0,cancelled:!0}):{ok:!1,code:"cancelled"}}function k(t){let r=[],e=(d,b)=>{let m=i.createElement("div");return m.className=d,m.textContent=b,m};r.push(e("blockeditor-menu-title","Export as Markdown"));let o=[`${t.report.blocks} block${t.report.blocks===1?"":"s"}`];t.report.extensions.length&&o.push(`${t.report.extensions.length} kept as HTML`),t.report.losses.length&&o.push(`${t.report.losses.length} lost`),r.push(e("blockeditor-menu-title blockeditor-export-summary",o.join(" \xB7 ")));let p=(d,b,m)=>{if(!m.length)return;let y=i.createElement("div");y.className=d,y.append(e("blockeditor-menu-title",b));for(let v of m){let x=e("blockeditor-export-row",v.name);x.dataset.block=v.block??"",x.dataset.type=v.type??"",y.append(x)}r.push(y)};if(p("blockeditor-export-extensions","Kept as HTML",t.report.extensions),p("blockeditor-export-losses","Not kept in Markdown",t.report.losses),!t.report.extensions.length&&!t.report.losses.length&&r.push(e("blockeditor-export-row","Everything here is written as Markdown.")),t.notice){let d=i.createElement("p");d.className="blockeditor-export-error",d.setAttribute("role","alert"),d.textContent=t.notice,r.push(d)}let l=(d,b)=>{let m=i.createElement("button");return m.type="button",m.className="blockeditor-menu-item",m.dataset.export=d,m.textContent=b,m.addEventListener("mousedown",y=>y.preventDefault()),m.addEventListener("click",()=>d==="download"?h():f()),m};r.push(l("download",`Download ${t.name}`),l("cancel","Cancel")),t.panel.replaceChildren(...r)}async function h(){let t=u;return t?await s({html:t.report.text,name:t.name,type:"text/markdown"})?(a(),n.focus?.(),{ok:!0,downloaded:!0}):(t.notice="That download could not be made.",k(t),{ok:!1,code:"download-failed"}):{ok:!1,code:"no-export"}}function $(t){!u||t.isComposing||t.keyCode===229||(t.key==="Escape"?(t.preventDefault(),t.stopPropagation(),f()):t.key==="Enter"&&!t.target?.closest?.("[data-export]")&&(t.preventDefault(),t.stopPropagation(),h()))}function g(t,r){let e=i.createElement("div");e.className="blockeditor-menu blockeditor-export-preview",e.setAttribute("role","dialog"),e.setAttribute("aria-label","Export Markdown");let o={report:t,name:r,panel:e,notice:null,listen:[]};u=o;let p=(l,d,b,m)=>{l.addEventListener(d,b,m),o.listen.push([l,d,b,m])};return p(i,"keydown",l=>$(l),!0),p(i,"mousedown",l=>{o.panel.contains(l.target)||f()},!0),(n.dom.parentElement??i.body).appendChild(e),k(o),e.querySelector('[data-export="download"]')?.focus?.(),{ok:!0,preview:!0}}function C(){return n.composing?new Promise(t=>{let r=()=>{n.dom.removeEventListener("compositionend",r),t()};n.dom.addEventListener("compositionend",r)}):Promise.resolve()}async function w(){if(c||n.isDestroyed)return{ok:!1,code:"not-editing"};if(a(),await C(),c||n.isDestroyed)return{ok:!1,code:"not-editing"};let t=_(n.state.doc),r;try{r=H(t)}catch(e){return{ok:!1,code:"export-failed",error:e}}return g(r,K(L()))}return{async run(t){return w(t)},dispose(){c=!0,a()}}}export{se as createFeature};
|