@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A,B,C,D,E,F,G,H,I,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./c-TGIMBAWE.js";import"./c-WNOLMHI2.js";import"./c-LS7IVQVW.js";import"./c-NEQRFC4O.js";import"./c-JRKY44DK.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-OH2FPYSY.js";import"./c-RETTCOWO.js";import"./c-57XDY6HC.js";import"./c-I2SCCUEW.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{c as COMPACT_BATCHES,d as COMPACT_BYTES,y as COPY_CHANNEL,z as COPY_VERSION,E as IME_CHANNEL,F as IME_VERSION,a as PAGE_CHANNEL,b as PAGE_CHANNEL_VERSION,f as PageReplayError,g as accumulateCapsule,j as admitCapsule,l as applyCapsule,k as capsulesOf,C as copyState,x as coversText,r as createPageJournal,w as describeReview,I as imeEntries,p as journalBase,B as markerFor,e as mergePageUpdates,H as openImeShadow,s as openPageJournal,o as pageAuthority,q as pageChannel,A as pageCopyChannel,G as pageImeChannel,n as pageJournalContext,i as reconstructPage,v as reconstructText,D as recoverAsCopy,u as replayInto,m as replayJournals,h as replayPageValue,t as watchJournal};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{b as pe}from"./c-A7LS5UZW.js";import{a as I,b as Le,c as U,d as ve}from"./c-7K4SCQB7.js";import{a as Z,b as L,f as ye,g as ge,h as Ye,s as qe}from"./c-WMRJKQ2V.js";import{a as he}from"./c-TCCA5BZN.js";import{a as C,b as V,c as Te,d as Ce,f as Ne,g as Pe,k as $,m as H,p as _e}from"./c-3LDGIBMN.js";import{a as X,b as $e,c as Y}from"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";function Ue(a,y){return!y||!Number.isInteger(y.seq)?null:y.seq>=(a.last??0)?[]:y.seq<(a.floor??0)?null:a.log.filter(d=>d.seq>y.seq).map(d=>({seq:d.seq,ops:d.ops}))}var k=Object.freeze({version:1,loose:32,soft:16,activeBytes:3840*1024,deleteReserve:64*1024,newPerFrame:4,tailFloor:64*1024,leaseMs:60*1e3,retired:8192}),Ke=Object.freeze({"checkpoint-required":503,"blockeditor-full":409,"compaction-failed":409,"blockeditor-immutable":409,"blockeditor-batch":409,"blockeditor-update-invalid":422,"blockeditor-upgrade":404}),me=/^[ur][0-9a-z]+(-[0-9a-z]+){2}$/,je=/^[ctf][0-9a-z]{8}-[0-9a-z]+(-[0-9a-z]+)?$/,ht=/^(seed|c[0-9a-z]{8}-[0-9a-z]+)$/,be=a=>ht.test(a);function ee(a,y=k){let d=0,f=0,u=0,c=0;for(let p of Object.keys(a)){if(X.test(p)){u++;continue}be(p)?d++:f++,!me.test(p)&&!je.test(p)&&p!=="seed"&&c++}return{checkpoints:d,loose:f,parts:u,legacy:c,normal:u===0&&d<=1&&f<=y.loose}}function ze(a,{overflow:y=!1}={},d=k){let f=ee(a,d),u=Y(a),c=u.filter(([b])=>be(b)),p=u.filter(([b])=>!be(b)),w=p.reduce((b,[,m])=>b+m.length,0),g=c.reduce((b,[,m])=>b+m.length,0);return!f.normal||y||w>Math.max(d.tailFloor,g/4)?{kind:"full",sources:u}:p.length<2||f.loose<d.soft?null:{kind:"tail",sources:p}}function De({kind:a,sources:y,encode:d=Ye}){let f=y.map(([,c])=>L(c));if(a==="tail"){let c=qe(f),p=I(c);for(let w of f)if(!U(p,I(w)))return{failure:"not-covered"};return{update:Z(c)}}let u=new ye({gc:!0});try{for(let g of f)ge(u,g);if(u.store.pendingStructs||u.store.pendingDs){let g=qe(f),v=I(g);for(let b of f)if(!U(v,I(b)))return{failure:"not-covered"};return{update:Z(g),pending:!0}}let c=ve(u);for(let g of f)if(!U(c,I(g)))return{failure:"not-covered"};let p=Z(d(u)),w=new ye({gc:!0});try{ge(w,L(p));let g=ve(w);if(!g.complete)return{failure:"not-covered"};for(let v of f)if(!U(g,I(v)))return{failure:"not-covered"}}finally{w.destroy()}return{update:p}}catch(c){return{failure:"invalid-update",message:c?.message||String(c)}}finally{u.destroy()}}function we(a){if(typeof a!="string"||!$e(a))return null;try{let{items:y,deletes:d}=I(L(a)),f=0;for(let u of d.values())for(let[c,p]of u)f+=p-c;return{deleted:f,inserts:y.size>0}}catch{return null}}function Ve({y:a,ops:y,state:d,limits:f}){if(d.compaction!==f.version)return{error:"blockeditor-upgrade"};let u=0,c=0,p=!1;for(let g of y){let v=g.path?.[1];if(g.op!=="set"||typeof v!="string"||!me.test(v))return{error:"blockeditor-immutable"};if(Object.hasOwn(a,v)){if(a[v]!==g.value)return{error:"blockeditor-immutable"};continue}if(d.retired.has(v))return{error:"blockeditor-immutable"};let b=we(g.value);if(!b)return{error:"blockeditor-update-invalid"};u+=1,c+=b.deleted,p||=b.inserts}if(u>f.newPerFrame)return{error:"blockeditor-batch"};if(d.failed)return{added:u,deleted:c,inserts:p,limit:f.activeBytes+(p?0:f.deleteReserve),shape:null,failed:!0};let w=ee(a,f);return!w.normal||w.loose+u>f.loose?{error:"checkpoint-required",retryAfter:0}:{added:u,deleted:c,inserts:p,limit:f.activeBytes+(p?0:f.deleteReserve),shape:w}}var yt=a=>me.test(a)||je.test(a);function He(a=256){let y=new Map;return(d,f)=>{let u=y.get(d);if(u&&u.value===f)return u.ranges;let c=I(L(f));return y.delete(d),y.set(d,{value:f,ranges:c}),y.size>a&&y.delete(y.keys().next().value),c}}function Je({y:a,fileY:y,retired:d,rangesFor:f,keyFor:u=(c,p)=>p}){let c=Y(a),p=new Map(c),w=null,g=[];for(let[v,b]of Y(y??{})){if(p.get(v)===b||d.has(v)&&yt(v))continue;let m;try{m=I(L(b))}catch{continue}w??=Le(c.map(([r,O])=>f(r,O))),U(w,m)||g.push([v,b])}return g.map(([v,b],m)=>[u(m,v),b])}var Ge=5,gt=2e3,qt=500,vt=1024,bt=256*1024;function te(a,y){let d=[],f=()=>{for(let u=d.length-1;u>=0;u--)Pe(d[u])};try{for(let u of y){let c=Ne(a,u);c&&(d.push(c),a=c.root)}}catch(u){throw f(),u}return{value:a,undo:f}}var Qe=new TextEncoder,Xe="blockeditor-format:1",Ze="blockeditor-rooms:2";function Tt(a=0,y=window.location.pathname){let d="clay-live:"+y;return`${a>=1?`${d}:${Xe}`:d}:${Ze}`}function mt(a){typeof requestIdleCallback=="function"?requestIdleCallback(a,{timeout:1e3}):setTimeout(a,0)}var J=a=>!!a&&typeof a=="object"&&typeof a.y=="object"&&a.y!==null&&!Array.isArray(a.y);function Ct(){return typeof BroadcastChannel=="function"&&typeof navigator<"u"&&typeof navigator.locks?.request=="function"}function We(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Math.random().toString(36).slice(2)+Date.now().toString(36)}function Nt({seed:a,key:y="clay-live:"+window.location.pathname,channel:d=null,floor:f=0,rooms:u=!1}){let c=We(),p=f>=1?1:0,w=e=>`${y}${e>=1?`:${Xe}`:""}${u?`:${Ze}`:""}`,g=w(p),v=null,b=null,m=null,r=null,O=!1,oe=null,K=!1,R=null,et=0,j=0,N=new Map,G=new Map,Q=new Set,P=new Map,s={epoch:null,seq:0,sequencer:null,closedBy:null,stale:!1,seen:new Map,stores:new Map};function A(e){v?.post({...e,version:Ge})}function ne(e,t){for(t.bytes=Qe.encode(JSON.stringify(t.ops)).length,e.log.push(t),e.logBytes+=t.bytes;e.log.length>vt||e.logBytes>bt;){let n=e.log.shift();e.logBytes-=n.bytes,e.floor=n.seq}}function re(e){let t=s.stores.get(e.name);t&&(t.value=te(t.value,e.ops).value,t.last=e.seq,t.ephemeral||ne(t,{seq:e.seq,ops:e.ops})),s.seq=e.seq;let n=e.name+`
|
|
2
|
+
`+e.from;(s.seen.get(n)??0)<e.n&&s.seen.set(n,e.n)}function tt(e){let t={};for(let[n,l]of s.seen){let o=n.indexOf(`
|
|
3
|
+
`);n.slice(0,o)===e&&(t[n.slice(o+1)]=l)}return t}let ke=e=>e.behind||e.landed===null?-1:e.landed;function z(e){let t={},n={};for(let[o,i]of s.stores)t[o]={value:C(i.value),ephemeral:i.ephemeral,seen:tt(o),last:i.last,landed:ke(i)},o==="blockeditor"&&J(i.value)&&(t[o].compaction={v:k.version,loose:k.loose,activeBytes:k.activeBytes}),n[o]={log:i.log,last:i.last,landed:i.landed,floor:i.floor,behind:i.behind,file:i.file,inFile:i.inFile};let l={epoch:r.epoch,seq:r.seq,writer:c,stores:t,mirror:{seen:[...s.seen],stores:n}};if(e!==void 0){let o=e&&e.epoch===s.epoch&&Number.isInteger(e.seq)?e.seq:0,i={};for(let[q,h]of s.stores)i[q]=Ue(h,{seq:o});l.moves=i}return l}function Oe(e,t){return e?.file?t.seq!=null&&e.file.seq!=null?t.seq<=e.file.seq:e.file.hash===H($(he(t.text))):!1}function ot(){for(let[e,t]of P)try{Oe(s.stores.get(e),t)&&P.delete(e)}catch{P.delete(e)}}function se(e){if(r||!e||typeof e.epoch!="string"||!Number.isInteger(e.seq)||!e.mirror||Q.has(e.epoch)||e.epoch===s.epoch&&e.seq<s.seq)return!1;s.epoch!==null&&e.epoch!==s.epoch&&Q.add(s.epoch);let t=new Map;for(let[n,l]of Object.entries(e.stores||{})){let o=e.mirror.stores?.[n]||{},i=Array.isArray(o.log)?o.log:[];t.set(n,{value:C(l.value),ephemeral:l.ephemeral===!0,log:i,logBytes:i.reduce((q,h)=>q+(h.bytes||0),0),last:Number.isInteger(o.last)?o.last:0,landed:Number.isInteger(o.landed)?o.landed:null,floor:Number.isInteger(o.floor)?o.floor:0,behind:o.behind===!0,file:o.file||null,inFile:Array.isArray(o.inFile)?[...o.inFile]:[]})}return s={epoch:e.epoch,seq:e.seq,sequencer:e.writer??null,closedBy:null,stale:!1,seen:new Map(e.mirror.seen||[]),stores:t},ot(),j+=1,!0}function le(){let e=z();A({type:"data-state",state:e}),m.state(e)}function ie(){s.epoch!==null&&Q.add(s.epoch),s.epoch=We(),s.seq=0;for(let e of s.stores.values())e.log=[],e.logBytes=0,e.last=0,e.landed=null,e.floor=0,e.behind=!0,e.file=null,e.inFile=[]}function nt({fresh:e}){let t=s.epoch===null;t&&ie();for(let[l,o]of a())s.stores.has(l)||s.stores.set(l,{value:C(o.value),ephemeral:o.ephemeral,log:[],logBytes:0,last:0,landed:0,floor:0,behind:!1,file:null,inFile:[]});s.stale=!1,s.sequencer=c,s.closedBy=null;let n=new Map;for(let[l,o]of s.seen)n.set(l,{n:o,seq:0});r={epoch:s.epoch,seq:s.seq,lastN:n,host:st()};for(let[l,o]of P){let i=s.stores.get(l);if(!(!i||i.ephemeral)){try{if(Oe(i,o))continue}catch{continue}Ae(l,o)}}P.clear(),e&&!t&&(ie(),r.epoch=s.epoch,r.seq=0),j+=1,le()}function Se(){ie(),r.epoch=s.epoch,r.seq=0,j+=1,le()}function ce(){r&&(A({type:"closed",from:c,state:z()}),r=null,oe?.(),oe=null)}function rt(e){return s.closedBy!==null&&(e===null||s.closedBy===e)?Promise.resolve(!0):new Promise(t=>{let n=setTimeout(()=>{R=null,t(!1)},qt);R={sequencer:e,resolve(l){clearTimeout(n),R=null,t(l)}}})}function ae(){K||O||(K=!0,navigator.locks.request(g,async()=>{if(O)return;let e=await rt(s.sequencer);if(!O)return nt({fresh:s.epoch===null||!e}),new Promise(t=>{oe=t})}).catch(()=>{}).finally(()=>{K=!1}))}let st=()=>({retired:new Set,lastFull:null,deletesSince:0,failed:null,ranges:He(),task:null,overflow:!1}),lt=()=>{let e=s.stores.get("blockeditor");return e&&!e.ephemeral&&J(e.value)?e:null},ue=e=>Qe.encode($(e)).length,fe=(e,t=0)=>({status:Ke[e]??409,body:{code:e},retryAfter:t});function _(e=!1){if(!r)return;let t=r.host;if(t.overflow||=e,t.task)return;let n=r;t.task=mt(()=>{t.task=null;let l=t.overflow;t.overflow=!1,!(O||r!==n||t.failed)&&it(t,{overflow:l})})}function it(e,{overflow:t}){let n=lt();if(!n)return;let l=ze(n.value.y,{overflow:t},k);if(!l)return;let o=De({kind:l.kind,sources:l.sources});if(typeof o.update!="string"){e.failed={reason:o.failure};return}ct(e,n,l,o.update)}function ct(e,t,n,l){let o=t.value.y,i=new Map(n.sources),q=Object.keys(o).filter(F=>{let D=X.exec(F);return i.has(D?D[1]:F)||D&&n.kind==="full"}),h=new Map(Y(Object.fromEntries(q.map(F=>[F,o[F]]))));for(let[F,D]of i)if(h.get(F)!==D)return;if(!we(l))return;let x=`${n.kind==="full"?"c":"t"}${H(r.epoch).slice(0,8)}-${(r.seq+1).toString(36)}`;if(Object.hasOwn(o,x))return;let B=[...q.map(F=>V({op:"del",path:["y",F]})),V({op:"set",path:["y",x],value:l})],M=ue(t.value),E;try{E=te(t.value,B)}catch{return}let S=ue(E.value);if(E.undo(),S>k.activeBytes&&S>M){n.kind==="full"&&q.length===Object.keys(o).length&&(e.lastFull={bytes:M,seq:r.seq},e.deletesSince=0);return}let T=!t.behind&&t.landed===t.last;for(let[F]of n.sources)e.retired.add(F),e.retired.size>k.retired&&e.retired.delete(e.retired.values().next().value);r.seq+=1,n.kind==="full"&&(e.lastFull={bytes:S,seq:r.seq},e.deletesSince=0);let de={epoch:r.epoch,seq:r.seq,name:"blockeditor",ops:B,from:"compactor",n:0,kind:n.kind};re(de),T&&(t.landed=r.seq),A({type:"data",data:de}),m.frame(C(de)),T&&(W(["blockeditor"]),A({type:"landed",name:"blockeditor",at:{epoch:r.epoch,seq:r.seq}}));let Re=ee(t.value.y,k);(Re.loose>=k.soft||!Re.normal)&&_()}function xe(e,t){if(!t||typeof t.name!="string"||!Number.isInteger(t.n)||t.n<1||!Array.isArray(t.ops)||!t.ops.length)return{status:400,body:{error:"bad-frame"},retryAfter:0};let n=s.stores.get(t.name);if(!n)return{status:404,body:{error:"unknown-store"},retryAfter:0};let l=t.name+`
|
|
4
|
+
`+e,o=r.lastN.get(l);if(o&&t.n<=o.n)return{status:200,body:{duplicate:!0,seq:o.seq,epoch:r.epoch},retryAfter:0};let i;try{i=t.ops.map(V)}catch(E){return{status:422,body:{error:E.message},retryAfter:0}}let q=r.host,h=t.name==="blockeditor"&&J(n.value)?Ve({y:n.value.y,ops:i,state:{...q,compaction:t.compaction},limits:k}):null;if(h?.error)return h.error==="checkpoint-required"&&_(),fe(h.error,h.retryAfter);let x;try{x=te(n.value,i)}catch(E){return{status:422,body:{error:E.message},retryAfter:0}}let B=h?ue(x.value):0;if(x.undo(),h&&B>h.limit)return h.failed||q.lastFull&&q.deletesSince===0?fe("blockeditor-full"):(_(!0),fe("checkpoint-required"));r.seq+=1,r.lastN.set(l,{n:t.n,seq:r.seq});let M={epoch:r.epoch,seq:r.seq,name:t.name,ops:i,from:e,n:t.n};return re(M),A({type:"data",data:M}),m.frame(C(M)),h&&(q.deletesSince+=h.deleted,!h.failed&&B>k.activeBytes?_(!0):!h.failed&&h.shape.loose+h.added>=k.soft&&_()),{status:200,body:{seq:r.seq,epoch:r.epoch},retryAfter:0}}function W(e){if(!r||!e.length)return;let t={};for(let n of e){let l=s.stores.get(n);l&&(t[n]=ke(l))}m.writer({epoch:r.epoch,writer:c,landed:t})}function Fe(e,t){let n=s.stores.get(e);return!n||n.ephemeral||!t||t.epoch!==s.epoch||!Number.isInteger(t.seq)||!n.behind&&n.landed!==null&&t.seq<=n.landed?!1:(n.landed=t.seq,n.behind=!1,!0)}function Ae(e,{text:t,at:n,seq:l}){let o=s.stores.get(e);if(!o||o.ephemeral)return null;let i;try{i=C(he(t))}catch{return null}if(i===null||typeof i!="object"||Array.isArray(i)!==Array.isArray(o.value))return null;let q={seq:l??null,hash:H($(i))};if(e==="blockeditor"&&J(o.value)&&J(i))return at(o,i,q);let h=!!n&&n.epoch===s.epoch&&n.seq<=r.seq,x=h&&n.hash===q.hash,B=h?n.seq:o.behind?null:o.landed;if(B===null||B<o.floor){let S=!o.behind;return o.behind=!0,o.file=q,{changed:!1,moved:S}}let M=o.log.filter(S=>S.seq>B&&(x||!o.inFile.includes(S.seq)));x&&(o.inFile=[]);for(let S of M)for(let T of S.ops)try{Te(i,T),i=Ce(i,T)}catch{}let E=!1;if($(i)!==$(o.value)){let S=_e(o.value,i);o.value=i,r.seq+=1,s.seq=r.seq,o.last=r.seq,ne(o,{seq:r.seq,ops:S}),o.inFile=[...o.inFile.filter(T=>T>o.floor),r.seq],E=!0}return o.landed=M.length?B:o.last,o.behind=!1,o.file=q,{changed:E,moved:!0}}function at(e,t,n){if(t.g!==e.value.g)return null;let l=r.host,o=Je({y:e.value.y,fileY:t.y,retired:l.retired,rangesFor:l.ranges,keyFor:h=>`f${H(r.epoch).slice(0,8)}-${(r.seq+1).toString(36)}-${h.toString(36)}`});e.file=n;let i=new Set,q=[];for(let[h,x]of o)Object.hasOwn(e.value.y,h)||i.has(h)||(i.add(h),q.push(V({op:"set",path:["y",h],value:x})));return q.length?(e.value=te(e.value,q).value,r.seq+=1,s.seq=r.seq,e.last=r.seq,ne(e,{seq:r.seq,ops:q}),e.inFile=[...e.inFile.filter(h=>h>e.floor),r.seq],l.lastFull=null,_(),{changed:!0,moved:!0}):{changed:!1,moved:!1}}function ut(e){let t=!1,n=[];for(let[l,o]of e){let i=s.stores.get(l);if(!i||i.ephemeral)continue;if(!r){P.set(l,o);continue}let q=Ae(l,o);q&&(q.changed?t=!0:q.moved&&n.push(l))}t?le():W(n)}function Be(e){return new Promise(t=>{let n=++et,l=setTimeout(()=>{N.delete(n),G.delete(n),t(null)},gt);e.type==="post"&&G.set(n,s.sequencer),N.set(n,o=>{clearTimeout(l),N.delete(n),G.delete(n),t(o)}),A({...e,from:c,rid:n})})}function ft(e){if(!(!e||typeof e.name!="string"||typeof e.epoch!="string"||!Number.isInteger(e.seq))&&!(r||Q.has(e.epoch))){if(e.epoch!==s.epoch)s.stale=!0;else if(!s.stale&&e.seq===s.seq+1)try{re(e)}catch{s.stale=!0}else e.seq>s.seq&&(s.stale=!0);m.frame(e)}}function dt(e,t){if(!(typeof e!="string"||!t)){se(t)&&(s.closedBy=e,m.state(t));for(let[n,l]of G)l===e&&N.get(n)?.(null);R&&(R.sequencer===null||R.sequencer===e)&&R.resolve(s.closedBy===e)}}function Ee({data:e}){if(!(O||!e||e.version!==Ge)){if(r&&(e.type==="data"&&e.data?.epoch===r.epoch||(e.type==="data-state"||e.type==="closed")&&e.state?.epoch===r.epoch&&e.state.writer!==c)){Se();return}if(!r&&e.type==="data-state"&&e.state?.epoch===s.epoch&&e.state.writer!==s.sequencer&&Number.isInteger(e.state.seq)&&e.state.seq<s.seq){A({type:"forked",epoch:s.epoch,to:e.state.writer});return}if(e.type==="forked"){r&&e.epoch===r.epoch&&e.to===c&&Se();return}e.type==="data"?ft(e.data):e.type==="data-state"?se(e.state)&&m.state(e.state):e.type==="closed"?dt(e.from,e.state):e.type==="landed"?typeof e.name=="string"&&Fe(e.name,e.at)&&W([e.name]):e.type==="answer"?e.to===c&&N.get(e.rid)?.(e.result):r&&e.type==="post"?e.epoch===r.epoch&&A({type:"answer",to:e.from,rid:e.rid,result:xe(e.from,e.frame)}):r&&e.type==="state-request"&&A({type:"answer",to:e.from,rid:e.rid,result:z(e.since)})}}function Ie(){ce()}function Me(e){!e.persisted||O||r||K||(s.sequencer=null,s.closedBy=null,ae(),m.close(),m.open({clientId:c,lane:"live"}))}function pt(e,{covered:t=!1}={}){let n=e>=1?1:0,l={floor:p,scope:g};return n<=p?{status:"already",...l}:O||!v?{status:"refused",code:"lane-stopped",...l}:d?{status:"refused",code:"shared-channel",...l}:t?(ce(),b?.(),g=w(n),p=n,v=pe(g),b=v.subscribe("durable",o=>Ee({data:o})),s.sequencer=s.closedBy=null,K=!1,ae(),m.close(),m.open({clientId:c,lane:"live"}),{status:"switched",floor:p,scope:g}):{status:"refused",code:"uncovered",...l}}return{clientId:c,get scope(){return g},get floor(){return p},switchScope:pt,start(e){return m=e,v=d??pe(g),b=v.subscribe("durable",t=>Ee({data:t})),window.addEventListener("pagehide",Ie),window.addEventListener("pageshow",Me),ae(),m.open({clientId:c,lane:"live"}),()=>{ce(),O=!0,R?.resolve(!1),window.removeEventListener("pagehide",Ie),window.removeEventListener("pageshow",Me);for(let t of N.values())t(null);b?.(),b=null,v=null}},async send(e,t){return r?xe(c,t):await Be({type:"post",frame:t,epoch:s.epoch})||{status:0,body:null,retryAfter:0}},async fetchState(e,t=null){if(r)return z(t);let n=j,l=await Be({type:"state-request",since:t});return r?z(t):n!==j||!se(l)?null:l},fileFrame(e){O||ut(e)},landed(e,t){O||!t||(Fe(e,t)&&W([e]),A({type:"landed",name:e,at:{epoch:t.epoch,seq:t.seq}}))},get isSequencer(){return r!==null}}}export{qt as CLOSE_WAIT_MS,Xe as FORMAT_SCOPE,bt as LOG_BYTES,vt as LOG_ENTRIES,gt as REQUEST_MS,Ze as ROOM_SCOPE,Tt as localLaneKey,Ct as localLaneSupported,Nt as localTransport};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as u,b as m,c as b,d as k}from"./c-Y6F2FORL.js";import{b as y}from"./c-QY7F6EN6.js";import{d as v}from"./c-PKCCHJ5X.js";import{b as g}from"./c-
|
|
1
|
+
import{a as u,b as m,c as b,d as k}from"./c-Y6F2FORL.js";import{b as y}from"./c-QY7F6EN6.js";import{d as v}from"./c-PKCCHJ5X.js";import{b as g}from"./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 A=.8,c={draft:"You're seeing a private draft, like a visitor.",draftAction:"Edit the original",edit:"You're editing the original. Visitors get these changes.",editAction:"Back to my draft",close:"Hide this note"},L=`.clay-owner {
|
|
2
2
|
--hcp-surface: light-dark(#FFFCF6, #11131E);
|
|
3
3
|
--hcp-ground: var(--bevel-surface, var(--hcp-surface));
|
|
4
4
|
--hcp-ink: light-dark(#2B241B, #ECEAF2);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as g,s as k}from"./c-MFOSMAVM.js";import{a as u,b as r,c as d,h as p}from"./c-6IJEVE6B.js";var v=3e4;function a(){return{ok:!1,code:"failed"}}async function x(n,{etag:o}={}){if(typeof n!="string"||n==="")return a();let m=o!==void 0,y=typeof o=="string"&&o?o:null;if(r()||await p(),!r())return{ok:!1,code:"unsupported"};let s=m?y:u();if(!s)return{ok:!1,code:"conflict"};let i=new AbortController,S=setTimeout(()=>i.abort(),v);try{let{url:c,options:b}=k(n,!0,i.signal,g(),s,!1,null,!1),t=await fetch(c,b),f=await t.text(),e={};if(f)try{e=JSON.parse(f)}catch{e={}}if(!t.ok)return t.status===412?{ok:!1,code:"conflict"}:t.status===401||t.status===403?{ok:!1,code:"forbidden"}:a();let l=typeof e.etag=="string"&&e.etag?e.etag:null;return d(l),{ok:!0,etag:l}}catch{return a()}finally{clearTimeout(S)}}export{x as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as j,c as re}from"./c-6DNRCPNM.js";import{a as Re}from"./c-Q3XOWZEV.js";import{a as Le}from"./c-4ASQPRQL.js";import{
|
|
1
|
+
import{a as j,c as re}from"./c-6DNRCPNM.js";import{a as Re}from"./c-Q3XOWZEV.js";import{a as Le}from"./c-4ASQPRQL.js";import{j as Me}from"./c-MFOSMAVM.js";import{a as Ce}from"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import{a as Ae}from"./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{b as Y,c as Oe,d as Ie,l as ce,u as fe}from"./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";var Et=16384;function Ot(e){let t=new Map,n=e?.onParseError;return{parser:new Re({...e,onParseError:s=>{t.set(s.code,(t.get(s.code)||0)+1),n?.(s)}}),errors:t}}function It(e,t,n,r){let s=Math.min(n+r,t.length);return e.tokenizer.write(t.slice(n,s),s>=t.length),s}function*de(e,t,{chunk:n=Et}={}){let{parser:r,errors:s}=Ot(t),o=0;do o=It(r,e,o,n),o<e.length&&(yield);while(o<e.length);return{document:r.document,errors:s}}var ge=new Set(["script","style","xmp","iframe","noembed","noframes","plaintext","noscript"]),Je=new Set(["textarea","title"]),be=e=>ge.has(e)?"raw":Je.has(e)?"rcdata":"normal",pe=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),$e="http://www.w3.org/1999/xhtml",K=1500,Ct=e=>e.replace(/&/g,"&").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">"),Fe=e=>e.replace(/&/g,"&").replace(/ /g," ").replace(/"/g,""");function Qe(e){return j(ie(e))}function*ie(e){let{document:t,errors:n}=yield*de(e,{sourceCodeLocationInfo:!0});return We(e,t,n)}function We(e,t,n){let r=t.childNodes.find(l=>l.nodeName==="html"),s=t.childNodes.filter(l=>l!==r).map(l=>l.nodeName==="#documentType"?{kind:"doctype",name:l.name||"",publicId:l.publicId||"",systemId:l.systemId||""}:{kind:l.nodeName==="#comment"?"comment":l.nodeName,value:l.data}),o=r?ze(r,null,e):null;return o&&Ve(o,e),{src:e,doc:t,outside:s,root:o,parseErrors:n,relocated:o?me(o):null,movedIn:o?me(o,"movedIn"):null,tailOwner:o?He(o):null}}function ze(e,t,n){let r=e.sourceCodeLocation||null,s=e.nodeName==="#text"?"text":e.nodeName==="#comment"?"comment":"element",o={node:e,parent:t,live:null,kind:s,children:[],from:r?r.startOffset:-1,to:r?r.endOffset:-1};if(s==="text")return o.value=e.value,o;if(s==="comment")return o.value=e.data,o;o.tag=e.tagName,o.located=!!(r&&r.startTag),o.openFrom=o.located?r.startTag.startOffset:-1,o.openTo=o.located?r.startTag.endOffset:-1,o.closeFrom=r&&r.endTag?r.endTag.startOffset:o.located?o.to:-1,o.closeTo=r&&r.endTag?r.endTag.endOffset:o.located?o.to:-1,o.endTagged=!!(r&&r.endTag),o.located&&(o.to<o.openTo&&(o.to=o.openTo),o.closeFrom<o.openTo&&(o.closeFrom=o.closeTo=o.openTo)),o.attrs=[];let l=o.located&&r.startTag.attrs||r&&r.attrs||{};for(let a of e.attrs){let g=a.prefix?a.prefix+":"+a.name:a.name,c=l[g.toLowerCase()];o.attrs.push({name:g,key:g.toLowerCase(),value:a.value,from:c?c.startOffset:-1,to:c?c.endOffset:-1})}let d=e.nodeName==="template"&&e.content?e.content.childNodes:e.childNodes;for(let a of d)a.nodeName!=="#documentType"&&o.children.push(ze(a,o,n));if(!o.located){let a=o.children.filter(p=>p.from>=0),g=a.length?Math.min(...a.map(p=>p.from)):-1,c=a.length?Math.max(...a.map(p=>p.to)):-1;o.openFrom=o.openTo=g,o.closeFrom=o.closeTo=c,o.from=g,o.to=c}return o}function Ve(e,t,n=1/0){if(e.kind!=="element")return;for(let o of e.children){if(o.from>=n&&!(o.kind==="text"&&!/\S/.test(o.value))&&(e.movedIn=!0),o.from>=0&&e.located){let l=Math.max(e.openTo,Math.min(o.to,e.closeFrom)),d=Math.min(Math.max(o.from,e.openTo),l);if(d!==o.from||l!==o.to){if(o.kind==="text"&&!ge.has(e.tag)&&!Je.has(e.tag)){let a=t.slice(l,o.to).replace(/<!--[\s\S]*?-->|<[^>]*>/g,"").replace(/\r\n?/g,`
|
|
2
2
|
`);a&&!/\S/.test(a)&&o.value.endsWith(a)&&(o.outsideTail=a)}o.clamped=!0,o.from=d,o.to=l}}o.kind==="element"&&o.located&&!o.endTagged&&o.closeFrom>o.to&&(o.closeFrom=o.closeTo=o.to)}let r=e.located?e.openTo:-1;for(let o of e.children)if(!(o.from<0)){if(o.from<r){e.outOfOrder=!0;break}r=o.to}let s=e.located&&e.endTagged?Math.min(n,e.closeTo):n;for(let o of e.children)Ve(o,t,s)}function me(e,t="outOfOrder"){if(e[t])return e.tag;for(let n of e.children){if(n.kind!=="element")continue;let r=me(n,t);if(r)return r}return null}function He(e){if(e.outsideTail)return e;for(let t of e.children||[]){let n=He(t);if(n)return n}return null}function Z(e,t){if(!e.root)return"source has no <html> element";if(e.root.openFrom<0)return"source has no content inside <html>";if(e.relocated)return"the parser moved content out of <"+e.relocated+">, so source order and tree order disagree";if(e.movedIn)return"the parser moved content written after the end of <"+e.movedIn+"> back inside it, so source order and tree order disagree";let n=Rt(t),r=e.outside.map(At);if(n.length!==r.length)return"outside <html>: "+JSON.stringify(r)+" vs live "+JSON.stringify(n);for(let s=0;s<n.length;s++)if(n[s]!==r[s])return"outside <html>: "+r[s]+" vs live "+n[s];return null}function At(e){return e.kind==="doctype"?"doctype:"+e.name+"|"+e.publicId+"|"+e.systemId:e.kind+":"+e.value}function Rt(e){let t=[];for(let n of e.childNodes)n.nodeType===10?t.push("doctype:"+n.name+"|"+n.publicId+"|"+n.systemId):n.nodeType===8?t.push("comment:"+n.data):n.nodeType!==1&&t.push("#"+n.nodeType+":"+(n.data||""));return t}var ae="\0",Ge={align:0,hashKey:0};function Pe(e,t){for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function J(e){Ge.hashKey++;let t=2166136261,n=5381;for(let r of e)t=Pe(t,r),n=(Math.imul(n,33)^Pe(t^2654435769,r))>>>0;return t.toString(36)+"."+n.toString(36)}function q(e){let t=e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r of t)(r.nodeType===1||r.nodeType===3||r.nodeType===8)&&n.push(r);return n}var ye=e=>Array.from(e.attributes,t=>t.name.toLowerCase()+"="+t.value).sort().join(ae),Xe=e=>e.attrs.map(t=>t.key+"="+t.value).sort().join(ae);function Ye(e,t){let n;if(e.nodeType===3)n={tag:"#text",shallow:"t:"+e.data,content:"t:"+e.data,deep:"t:"+e.data};else if(e.nodeType===8)n={tag:"#comment",shallow:"c:"+e.data,content:"c:"+e.data,deep:"c:"+e.data};else{let r=q(e).map(o=>Ye(o,t)),s="e:"+e.localName+"|"+ye(e);n={tag:e.localName,shallow:s,content:"e:"+e.localName+"|"+J(r.map(o=>o.content)),deep:s+"|"+J(r.map(o=>o.deep))}}return t.set(e,n),n}function*Ke(e,t,n){++n.n%K===0&&(yield);let r;if(e.nodeType===3)r={tag:"#text",shallow:"t:"+e.data,content:"t:"+e.data,deep:"t:"+e.data};else if(e.nodeType===8)r={tag:"#comment",shallow:"c:"+e.data,content:"c:"+e.data,deep:"c:"+e.data};else{let s=[];for(let l of q(e))s.push(yield*Ke(l,t,n));let o="e:"+e.localName+"|"+ye(e);r={tag:e.localName,shallow:o,content:"e:"+e.localName+"|"+J(s.map(l=>l.content)),deep:o+"|"+J(s.map(l=>l.deep))}}return t.set(e,r),r}function*Ze(e,t){if(++t.n%K===0&&(yield),e.kind==="text")return e.keys={tag:"#text",shallow:"t:"+e.value,content:"t:"+e.value,deep:"t:"+e.value};if(e.kind==="comment")return e.keys={tag:"#comment",shallow:"c:"+e.value,content:"c:"+e.value,deep:"c:"+e.value};let n=[];for(let s of e.children)n.push(yield*Ze(s,t));let r="e:"+e.tag+"|"+Xe(e);return e.keys={tag:e.tag,shallow:r,content:"e:"+e.tag+"|"+J(n.map(s=>s.content)),deep:r+"|"+J(n.map(s=>s.deep))}}var De=["deep","content","shallow","tag"],Mt=4096;function Lt(e,t){Ge.align++;let n=[],r=e.map((p,y)=>y),s=t.map((p,y)=>y);g(r,s,0);let o=new Set(n.map(p=>p[0])),l=new Set(n.map(p=>p[1])),d=r.filter(p=>!o.has(p)),a=s.filter(p=>!l.has(p));return d.length&&a.length&&g(d,a,0),n.sort((p,y)=>p[0]-y[0]),n;function g(p,y,S){let w=0,h=p.length,v=0,N=y.length;if(w>=h||v>=N)return;if(S>=De.length)return c(p,y);let b=De[S];for(;w<h&&v<N&&e[p[w]][b]===t[y[v]][b];)n.push([p[w],y[v]]),w++,v++;for(;w<h&&v<N&&e[p[h-1]][b]===t[y[N-1]][b];)h--,N--,n.push([p[h],y[N]]);if(w>=h||v>=N)return;let P=new Map,Q=new Map;for(let I=w;I<h;I++){let A=e[p[I]][b];P.set(A,P.has(A)?-1:I)}for(let I=v;I<N;I++){let A=t[y[I]][b];Q.set(A,Q.has(A)?-1:I)}let ne=[];for(let I=w;I<h;I++){let A=e[p[I]][b];if(P.get(A)===I){let D=Q.get(A);D!==void 0&&D>=0&&ne.push([I,D])}}let W=bt(ne);if(!W.length){if((h-w)*(N-v)<=Mt){let I=Ft(e,t,p,y,w,h,v,N,b);if(I.length){let A=w,D=v;for(let[H,G]of I)n.push([p[H],y[G]]),g(p.slice(A,H),y.slice(D,G),S+1),A=H+1,D=G+1;g(p.slice(A,h),y.slice(D,N),S+1);return}}return g(p.slice(w,h),y.slice(v,N),S+1)}let z=w,V=v;for(let[I,A]of W)n.push([p[I],y[A]]),g(p.slice(z,I),y.slice(V,A),S),z=I+1,V=A+1;g(p.slice(z,h),y.slice(V,N),S)}function c(p,y){let S=new Map,w=new Map;for(let h of p){let v=e[h].tag;S.has(v)||S.set(v,[]),S.get(v).push(h)}for(let h of y){let v=t[h].tag;w.has(v)||w.set(v,[]),w.get(v).push(h)}for(let[h,v]of S){let N=w.get(h);N&&N.length===v.length&&h!=="#text"&&h!=="#comment"&&v.forEach((b,P)=>n.push([b,N[P]]))}}}function bt(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let l=0;l<e.length;l++){let d=e[l][1],a=0,g=t.length;for(;a<g;){let c=a+g>>1;t[c]<d?a=c+1:g=c}t[a]=d,n[a]=l,r[l]=a>0?n[a-1]:-1}let s=[],o=n.length?n[n.length-1]:-1;for(;o>=0;)s.push(e[o]),o=r[o];return s.reverse()}function Ft(e,t,n,r,s,o,l,d,a){let g=o-s,c=d-l,p=(v,N)=>e[n[s+v]][a]===t[r[l+N]][a],y=Array.from({length:g+1},()=>new Uint16Array(c+1));for(let v=g-1;v>=0;v--)for(let N=c-1;N>=0;N--)y[v][N]=p(v,N)?y[v+1][N+1]+1:Math.max(y[v+1][N],y[v][N+1]);let S=[],w=0,h=0;for(;w<g&&h<c;)p(w,h)?(S.push([s+w,l+h]),w++,h++):y[w+1][h]>=y[w][h+1]?w++:h++;return S}function Be(e){return e.nodeType===3?"#text "+JSON.stringify(e.data.slice(0,40)):e.nodeType===8?"#comment":"<"+e.localName+Array.from(e.attributes,t=>" "+t.name+'="'+t.value.slice(0,30)+'"').join("")+">"}function je(e){return e.kind==="text"?"#text "+JSON.stringify(e.value.slice(0,40)):e.kind==="comment"?"#comment":"<"+e.tag+e.attrs.map(t=>" "+t.name+'="'+t.value.slice(0,30)+'"').join("")+">"}function et(e,t,n=r=>r){return j(we(e,t,n))}function*we(e,t,n=r=>r){let r=new WeakMap,s=new Map,o={n:0};yield*Ke(e,s,o),yield*Ze(t.root,o);let l={paired:0,unmatchedLive:[],unmatchedSource:[],attrDiffs:[],textDiffs:0,unresolved:0},d={};return t.gen=d,yield*tt(e,t.root,r,s,l,"html",n,d,o),{map:r,stats:l}}function*tt(e,t,n,r,s,o,l,d,a){++a.n%K===0&&(yield);let g=l(e);if(g?(n.set(g,t),t.gen=d,s.paired++):s.unresolved++,t.kind!=="element"){e.data!==t.value&&s.textDiffs++;return}ye(e)!==Xe(t)&&s.attrDiffs.push({path:o,live:Be(e),source:je(t)});let c=q(e),p=t.children,y=Lt(c.map(h=>r.get(h)),p.map(h=>h.keys)),S=new Set,w=new Set;for(let[h,v]of y)S.add(h),w.add(v),yield*tt(c[h],p[v],n,r,s,o+">"+(c[h].nodeType===1?c[h].localName:"#")+"["+h+"]",l,d,a);for(let h=0;h<c.length;h++)S.has(h)||s.unmatchedLive.push({path:o,node:Be(c[h])});for(let h=0;h<p.length;h++)w.has(h)||s.unmatchedSource.push({path:o,node:je(p[h])})}function*nt(e,t,n=r=>r){if(!t.root)return null;let r=[],s=yield*rt(e,t.root,n,r,{n:0});if(s<0)return null;let o=new WeakMap,l={};t.gen=l;let d=0;for(let[a,g]of r)a&&(o.set(a,g),g.gen=l,d++);return{map:o,stats:{paired:d,unmatchedLive:[],unmatchedSource:[],attrDiffs:[],textDiffs:0,unresolved:s}}}function*rt(e,t,n,r,s){if(++s.n%K===0&&(yield),t.kind==="text"){if(e.nodeType!==3||e.data!==t.value)return-1}else if(t.kind==="comment"){if(e.nodeType!==8||e.data!==t.value)return-1}else if(e.nodeType!==1||e.localName!==t.tag||e.namespaceURI!==t.node.namespaceURI||Pt(e)!==Dt(t.node))return-1;let o=n(e);r.push([o,t]);let l=o?0:1;if(t.kind!=="element")return l;let d=Bt(e),a=t.children;if(d.length!==a.length)return-1;for(let g=0;g<d.length;g++){let c=yield*rt(d[g],a[g],n,r,s);if(c<0)return-1;l+=c}return l}var ot=e=>JSON.stringify(e),Pt=e=>Array.from(e.attributes,t=>ot([t.namespaceURI||"",t.name,t.value])).sort().join(ae),Dt=e=>e.attrs.map(t=>ot([t.namespace||"",t.prefix?t.prefix+":"+t.name:t.name,t.value])).sort().join(ae);function Bt(e){let t=e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r of t)(r.nodeType===1||r.nodeType===3||r.nodeType===8)&&n.push(r);return n}function st(e,t,n){let r=t.get(e);if(!r||r.gen!==n.gen||r.from<0||r.to<0||r.kind==="element"&&r.located&&n.src.slice(r.openFrom,r.openFrom+r.tag.length+1).toLowerCase()!=="<"+r.tag.toLowerCase())return null;let s=jt(n),o=Ut(s,r.from);return{from:r.from,to:r.to,line:o+1,column:r.from-s[o]+1}}function jt(e){if(!e.lineStarts){let t=[0];for(let n=0;n<e.src.length;n++)e.src.charCodeAt(n)===10&&t.push(n+1);e.lineStarts=t}return e.lineStarts}function Ut(e,t){let n=0,r=e.length-1;for(;n<r;){let s=n+r+1>>1;e[s]<=t?n=s:r=s-1}return n}function it(e,t,n,r,s={}){let o=()=>typeof performance<"u"?performance.now():Date.now(),l=o(),d=n.src,a=[],g=0,c=(u,m)=>{if(!(u>=0&&m>u))return;let f=a.length>g?a[a.length-1]:null;f&&f.text===void 0&&f.to===u?f.to=m:a.push({from:u,to:m})},p=u=>{u&&a.push({text:u})},y=0,S=u=>{if(y)return null;let m=r(u),f=m?t.get(m):null;return f&&f.gen===n.gen?f:null},w=null,h=-1,v=!1,N=n.root;if(c(0,N.openFrom),I(e,N),c(N.closeTo,d.length),n.tailOwner&&h>=0&&!v){for(let u=h;u<a.length;u++)a[u]={text:Q(P(a[u]))};w&&w.tail&&a.splice(w.at,0,{text:w.tail})}return{text:a.map(P).join(""),ms:o()-l};function P(u){return u.text!==void 0?u.text:d.slice(u.from,u.to)}function Q(u){return u.split(/(<!--[\s\S]*?-->|<[^>]*>)/).map((m,f)=>f%2?m:m.replace(/[\t\n\f\r ]+/g,"")).join("")}function ne(){h=a.length,g=a.length,v=!!w&&w.whole&&/^(?:<\/[^>]*>)*$/.test(a.slice(w.at).map(P).join(""))}function W(u,m){if(u.nodeType===3)return V(u,m);if(u.nodeType===8)return z(u);if(u.nodeType===1){if(s.print&&s.print.has(u)){y++;try{I(u,null)}finally{y--}}else I(u,S(u));u.localName==="body"&&u.parentNode===e&&ne()}}function z(u){let m=S(u);m&&m.kind==="comment"&&m.value===u.data&&m.from>=0&&!s.breakText?c(m.from,m.to):p("<!--"+u.data+"-->")}function V(u,m){let f=S(u),x=u.data;s.corrupt==="drop-first-text"&&!s.corrupted&&x.trim()&&(s.corrupted=!0,x=x.slice(1));let T=f&&f.parent&&be(f.parent.tag)===be(m);if(f&&f.kind==="text"&&f.value===x&&f.from>=0&&!s.breakText&&T){c(f.from,f.to),s.doubleCopied!==void 0&&x===s.doubleCopied&&c(f.from,f.to),f.outsideTail&&(w={at:a.length,tail:f.outsideTail,whole:!0},g=a.length);return}let M=null;if(f&&f.kind==="text"&&f.outsideTail){let R=x.endsWith(f.outsideTail);R&&(x=x.slice(0,x.length-f.outsideTail.length)),M={tail:R?f.outsideTail:"",whole:R}}p(ge.has(m)?x:Ct(x)),M&&(w={at:a.length,...M},g=a.length)}function I(u,m){let f=u.localName,x=pe.has(f)&&u.namespaceURI===$e,T=m&&m.kind==="element"&&!s.breakTags?m:null;if(T&&!T.located){if(u.attributes.length===0){if(T.openFrom>=0){X(u,T,f);return}q(u).length&&X(u,null,f);return}if(p(A(u)),x)return;X(u,T.openFrom>=0?T:null,f),p("</"+f+">");return}if(!T){if(p(A(u)),x)return;X(u,null,f),p("</"+f+">");return}H(u,T),!x&&(X(u,T,f),c(T.closeFrom,T.closeTo))}function A(u){let m="<"+u.localName;for(let f of u.attributes)m+=" "+f.name+(f.value===""?"":'="'+Fe(f.value)+'"');return m+">"}function D(u,m){let f=u.attributes;if(f.length!==m.attrs.length)return!1;for(let x=0;x<f.length;x++){let T=m.attrs[x];if(T.from<0||f[x].value!==T.value||f[x].name.toLowerCase()!==T.key)return!1}return!0}function H(u,m){if(D(u,m)){c(m.openFrom,m.openTo);return}let f=new Map;for(let O of u.attributes)f.set(O.name.toLowerCase(),O);let x=new Set,T=m.openFrom;for(let O of m.attrs){if(O.from<0){let _=f.get(O.key);_&&_.value===O.value&&x.add(O.key);continue}let L=f.get(O.key);if(x.add(O.key),!L){c(T,G(T,O.from)),T=O.to;continue}if(L.value===O.value){c(T,O.to),T=O.to;continue}c(T,O.from),p(xt(d.slice(O.from,O.to),L.value)),T=O.to}let M=m.openTo-1,R=m.attrs.reduce((O,L)=>L.to>O?L.to:O,m.openFrom);d[M-1]==="/"&&M-1>=R&&M--,c(T,M);for(let O of u.attributes)x.has(O.name.toLowerCase())||p(" "+O.name+(O.value===""?"":'="'+Fe(O.value)+'"'));c(M,m.openTo)}function G(u,m){let f=m;for(;f>u&&/[ \t\n\r\f]/.test(d[f-1]);)f--;return f}function xt(u,m){let f=u.indexOf("="),x=(f<0?u:u.slice(0,f)).trimEnd(),T=f<0?"":u.slice(f+1).trim(),M=T[0]==="'"?"'":T[0]==='"'?'"':"",R=m.replace(/&/g,"&").replace(/ /g," ");return M==="'"&&!m.includes("'")?x+"='"+R+"'":M===""&&T!==""&&m!==""&&!/[\s"'=<>`]/.test(m)?x+"="+R:x+'="'+R.replace(/"/g,""")+'"'}function St(u){if(u.nodeType!==1||y||s.print&&s.print.has(u))return null;let m=S(u);return m&&m.kind==="element"&&m.located&&!m.endTagged&&!pe.has(m.tag)&&!s.breakTags?m:null}function ue(u){let m=St(u);if(!m)return null;let f=q(u);return((f.length?ue(f[f.length-1]):null)||[]).concat(m.tag)}function X(u,m,f){let x=q(u),T=null,M=(C,k)=>{T&&!(k>=0&&T.j>=0&&k===T.j+1)&&p(T.tags.map(E=>"</"+E+">").join("")),T=null};if(!m){for(let C of x){M(-1,-1),W(C,f);let k=ue(C);k&&(T={tags:k,j:-1})}return}let R=m.children,O=new Map(R.map((C,k)=>[C,k])),L=x.map(C=>{let k=S(C);return k&&k.parent===m&&k.from>=0?O.get(k):-1}),_=new Set;if(!s.breakText&&!s.breakTags){let C=new Set(L),k=new Map;R.forEach((E,F)=>{C.has(F)||E.from<0||!E.keys||(k.has(E.keys.deep)||k.set(E.keys.deep,[]),k.get(E.keys.deep).push(F))}),k.size&&x.forEach((E,F)=>{if(L[F]>=0||S(E))return;let B=k.get(Ye(E,new Map).deep);B&&B.length&&(L[F]=B.shift(),_.add(F))})}let Se=(C,k)=>{if(!_.has(k))return W(C,f);let E=R[L[k]];c(E.from,E.to),E.outsideTail&&(w={at:a.length,tail:E.outsideTail,whole:!0},g=a.length)},kt=(C,k)=>{if(!_.has(k))return ue(C);let E=R[L[k]];return E.kind==="element"&&E.located&&!E.endTagged&&!pe.has(E.tag)?[E.tag]:null},Nt=new Set(_t(L)),U=m.openTo,ke=-1,Ne=C=>{for(let k=ke+1;k<C;k++){let E=R[k];E.from<0||(c(U,E.from),U=Math.max(U,E.to))}};for(let C=0;C<x.length;C++){let k=x[C],E=kt(k,C);if(Nt.has(C)){let B=L[C],Ee=R[B];M(C,B),Ne(B),c(U,Ee.from),Se(k,C),U=Math.max(U,Ee.to),ke=B,T=E?{tags:E,j:B}:null;continue}let F=S(k);M(C,F&&F.parent===m?O.get(F):-1),Se(k,C),T=E?{tags:E,j:-1}:null}Ne(R.length),c(U,m.closeFrom)}}function _t(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let l=0;l<e.length;l++){let d=e[l];if(d<0)continue;let a=0,g=t.length;for(;a<g;){let c=a+g>>1;t[c]<d?a=c+1:g=c}t[a]=d,n[a]=l,r[l]=a>0?n[a-1]:-1}let s=[],o=n.length?n[n.length-1]:-1;for(;o>=0;)s.push(o),o=r[o];return s.reverse()}function*at(e,t,n,r=null,s=null){return yield*ve(e,t,n,r,s,!0)}function*ve(e,t,n,r,s,o){let l=new DOMParser,d=l.parseFromString(e,"text/html"),a=qe(d),g=qe(n);if(a.join(`
|
|
3
3
|
`)!==g.join(`
|
|
4
4
|
`))return{ok:!1,diff:"document: outside <html> "+JSON.stringify(a)+" vs live "+JSON.stringify(g)};let c=null,p=null;if(r&&(c=[],p=yield*se(d.documentElement,r,"html",c),!p)){let h=yield*Ue(e,s,o);return h.diff?{ok:!1,diff:h.diff}:o?_e({ok:!0,diff:null,oracle:"clone"},h,e,n):{ok:!0,diff:null,oracle:"clone"}}let y=l.parseFromString(t,"text/html"),S=yield*se(d.documentElement,y.documentElement,"html"),w=S?null:yield*Ue(e,s,o);return S?r?{ok:!1,diff:S,at:c}:{ok:!1,diff:S}:w.diff?{ok:!1,diff:w.diff}:o?_e({ok:!0,diff:null,oracle:"today"},w,e,n):{ok:!0,diff:null,oracle:"today"}}function lt(e,t){let n=e;for(let r of t){let s=he(n);if(r>=s.length)return null;n=s[r]}return n}function*Ue(e,t,n){if(!t)return{diff:null};let{document:r,errors:s}=yield*de(e,n?{sourceCodeLocationInfo:!0}:{});for(let[o,l]of s){let d=t.get(o)||0;if(l>d)return{diff:`the render introduced parse errors the source does not have: ${o} ${d} -> ${l}`}}return n?{diff:null,doc:r,parseErrors:s}:{diff:null}}function _e(e,t,n,r){if(!t.doc)return e;let s=We(n,t.doc,t.parseErrors);return Z(s,r)||(e.model=s),e}function qe(e){let t=[];for(let n of e.childNodes)n.nodeType===10?t.push("doctype "+n.name+"|"+n.publicId+"|"+n.systemId):n.nodeType===8?t.push("comment "+n.data):n.nodeType!==1&&t.push("node"+n.nodeType+" "+(n.data||""));return t}function*qt(e,t,n,r){let s=new DOMParser,o=l=>{let d=Array.from(l.childNodes);return d.length&&d.every(a=>a.nodeType===3)?d.map(a=>a.data).join(""):l.innerHTML};return yield*se(s.parseFromString(e.innerHTML,"text/html").body,s.parseFromString(o(t),"text/html").body,n+">#noscript",[],r)}function he(e){let t=e.localName==="template"&&e.content?e.content.childNodes:e.childNodes,n=[];for(let r=0;r<t.length;r++){let s=t[r];(s.nodeType===1||s.nodeType===3||s.nodeType===8)&&n.push(s)}return n}var oe=e=>Array.from(e.attributes,t=>(t.namespaceURI||"")+" "+t.name+"="+JSON.stringify(t.value)).sort().join("; ");function Jt(e,t){let n=e.attributes,r=t.attributes;if(n.length!==r.length)return!1;for(let s=0;s<n.length;s++){let o=n[s],l=r[s];if(o.name!==l.name||o.value!==l.value||o.namespaceURI!==l.namespaceURI)return!1}return!0}function*se(e,t,n,r=[],s={n:0}){if(++s.n%K===0&&(yield),e.nodeType!==t.nodeType)return n+": node type "+e.nodeType+" vs "+t.nodeType;if(e.nodeType===3||e.nodeType===8)return e.data===t.data?null:n+": text "+JSON.stringify(e.data.slice(0,60))+" vs "+JSON.stringify(t.data.slice(0,60));if(e.localName!==t.localName||e.namespaceURI!==t.namespaceURI)return n+": tag "+e.localName+" vs "+t.localName;if(!Jt(e,t)&&oe(e)!==oe(t))return n+": attrs "+oe(e)+" vs "+oe(t);if(e.localName==="noscript"&&e.namespaceURI===$e)return yield*qt(e,t,n,s);let o=he(e),l=he(t);if(o.length!==l.length)return n+": "+o.length+" vs "+l.length+" children";for(let d=0;d<o.length;d++){r.push(d);let a=yield*se(o[d],l[d],n+">"+(o[d].localName||"#")+"["+d+"]",r,s);if(a)return a;r.pop()}return null}var i={installed:!1,refused:null,session:0,model:null,map:null,stats:null,saves:0,reprints:0,lastReprint:null,partialReprints:0,lastPartialReprint:null,lastOutcome:null,lastRenderMs:null,lastBytes:null,timing:{fetch:null,model:null,pair:null,refresh:null},refreshes:0,repairs:0,refreshQueued:!1,pendingBytes:null,refetch:!1,adoptions:0},$t=2,$=()=>typeof performance<"u"?performance.now():Date.now(),dt=4,le=Object.freeze({superseded:!0});function pt(e){return document.hidden||Me()?!1:e>=307200}var mt='<script type="application/json" id="clay-runtime-map"',ht=e=>e.includes(mt)||e.includes("/_/clayjs/");async function gt(e){let t=await fetch(e,{cache:"no-store",redirect:"manual",credentials:"same-origin",headers:{"Clay-Source":"1"}});if(!t.ok)throw new Error(`source fetch: status ${t.status}`);if(t.redirected||t.type==="opaqueredirect")throw new Error("source fetch: redirected");let n=(t.headers.get("content-type")||"").toLowerCase();if(!n.startsWith("text/html"))throw new Error(`source fetch: content-type ${n||"missing"}`);let r=await t.text();if(r.includes(mt))throw new Error("source fetch: projected response");return r}function yt(e){let t=fe({flushUndo:!1,authored:!1});return et(t,e,Y)}function*Qt(e){let t=fe({flushUndo:!1,authored:!1});return yield*we(t,e,Y)}function Wt(e){let t=e.doc&&e.doc.childNodes.find(r=>r.nodeName==="html"),n=t&&Array.isArray(t.attrs)?t.attrs.find(r=>r.name==="documentetag"):null;return n&&n.value?n.value:null}function zt(e){let t=e&&e.represented&&e.represented.etag;if(t)return t;let n=Ae();return n||e===null&&document.documentElement.getAttribute("documentetag")||null}function Vt(e,t){let n=Wt(e),r=zt(t);return!n||!r||n===r?null:`source refused: the fetch answered version ${n} while this page holds ${r}`}async function wt(e,t=null,n=0,r=!0,s=null){let o=i.session,l=$(),d=i.adoptions;i.refused=null;let a=s?s():null,g=a&&typeof a.bytes=="string"&&!ht(a.bytes)?a.bytes:null;try{let c=g!==null?g:await gt(e);if(o!==i.session)return null;let p=$(),y=await Ht({src:c,context:t,render:r,session:o,generation:d,t0:l,t1:p});if(y!==le)return y;if(n<$t)return wt(e,t,n+1,r,s);throw new Error("source refused: a save replaced the file while the fetch was in flight")}catch(c){return o!==i.session||(i.refused=String(c&&c.message?c.message:c),console.info(`clayjs: source map off (${i.refused}); saves use the full serialization`)),null}}function*ut(e){let t=yield*ie(e.src),n=Z(t,document);if(n)throw new Error(`source refused: ${n}`);let r=Vt(t,e.context);if(r)throw new Error(r);if(i.adoptions!==e.generation)return le;let s=$();if(yield,i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let{map:o,stats:l}=yield*Qt(t);if(i.session!==e.session)return null;if(i.adoptions!==e.generation)return le;let d=$();return i.model=t,i.map=o,i.stats=l,i.timing={fetch:e.t1-e.t0,model:s-e.t1,pair:d-s,refresh:null},i.installed=!0,e.render&&ce(Gt,{steps:vt}),Tt()}async function Ht(e){if(!pt(e.src.length))return j(ut(e));let t={get aborted(){return i.session!==e.session}},n=await re(ut(e),{budgetMs:dt,signal:t});return n&&n.aborted===!0?null:n}function Gt(e,t,n={}){return j(vt(e,t,n))}function*vt(e,t,n={}){if(!i.installed)return t;yield*xe();let r=i.session,s=i.repairs,o=Oe(),l=!!o&&!o.authoredHandlers,d=new Set,a=null;for(let g=0;g<=Yt;g++){let c;try{c=it(e,i.map,i.model,Y,{...n,print:d})}catch(y){return ee("render threw: "+(y&&y.message?y.message:y),t)}let p=l?yield*at(c.text,t,document,e,i.model.parseErrors):yield*ve(c.text,t,document,e,i.model.parseErrors,!1);if(p.ok){let y=ct(r,s);if(y)return ee(y,t);let S=d.size?{text:c.text,scope:"partial",reason:a,printed:d.size}:{text:c.text,scope:null},w=p.model?yield*nt(e,p.model,Y):null,h=ct(r,s);return h?ee(h,t):(i.lastRenderMs=c.ms,i.lastBytes=c.text.length,i.lastOutcome=S,p.model&&Xt(p.model,c.text,o,w),c.text)}if(a===null&&(a=p.diff),!p.at||!Kt(e,lt(e,p.at),d))return ee(a,t)}return ee(a,t)}function ct(e,t){return i.session!==e?"render refused: the session ended while this render ran":i.installed?i.repairs!==t?"render refused: the map was re-paired while this render ran":null:"render refused: the source map was uninstalled while this render ran"}function Xt(e,t,n,r){r&&Ie({captureId:n.captureId,html:t,source:{model:e,map:r.map,stats:r.stats,repairGeneration:i.repairs,outcome:i.lastOutcome}})}var Yt=8;function Kt(e,t,n){let r=t&&t.nodeType===1?t:t&&t.parentNode;for(let s=r;s&&s!==e;s=s.parentNode)if(n.has(s)){n.delete(s),r=s.parentNode;break}return!r||r.nodeType!==1||r===e?!1:(n.add(r),!0)}function ee(e,t){return i.lastOutcome={text:t,scope:"full",reason:e},t}function Zt(e){i.reprints++,i.lastReprint=e,console.warn("clayjs: source map did not verify, saving the full serialization instead:",e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"full"}}))}function en(e,t){i.partialReprints++,i.lastPartialReprint=e,console.info(`clayjs: source map printed ${t} element(s) in full to match the page:`,e),document.dispatchEvent(new CustomEvent("clay:save-reprinted",{detail:{reason:e,scope:"partial",printed:t}}))}function tn(e,t){i.adoptions++,i.installed&&(rn(e,t&&t.artifact?t.artifact.source.outcome:null),!nn(e,t)&&(i.pendingBytes=e,Te()))}function nn(e,t){let n=t&&t.artifact;return!n||!n.source||n.html!==e||t.captureId===null||t.captureId===void 0||n.captureId!==t.captureId||n.source.repairGeneration!==i.repairs||i.refreshQueued||i.pendingBytes!==null?!1:(i.model=n.source.model,i.map=n.source.map,i.stats=n.source.stats,!0)}function rn(e,t=null){let n=i.lastOutcome&&i.lastOutcome.text===e?i.lastOutcome:t;!n||n.text!==e||(i.lastOutcome===n&&(i.lastOutcome=null),i.saves++,n.scope==="full"?Zt(n.reason):n.scope==="partial"&&en(n.reason,n.printed))}function on(e){let t=e&&e.detail;t&&t.source==="disk"&&typeof t.html=="string"&&i.adoptions++,i.installed&&(t&&t.source==="disk"&&typeof t.html=="string"&&(ht(t.html)?i.refetch=!0:i.pendingBytes=t.html),Te())}function Te(){i.refreshQueued||(i.refreshQueued=!0,typeof requestIdleCallback=="function"?requestIdleCallback(ft,{timeout:2e3}):setTimeout(ft,0))}function ft(){if(!pt(sn())){te();return}an()}function sn(){return typeof i.pendingBytes=="string"?i.pendingBytes.length:i.model?i.model.src.length:0}async function an(){let e=i.session,t={get aborted(){return i.session!==e}};try{await re(xe(),{budgetMs:dt,signal:t})}catch(n){console.warn("clayjs: source map could not run the queued repair:",n)}!i.refreshQueued||!i.installed||i.session!==e||(i.refreshQueued=!1,Te())}function te(){j(xe())}function*xe(){if(!i.refreshQueued)return;if(!i.installed){i.refreshQueued=!1;return}let e=i.session,t=i.repairs,n=i.adoptions,r=i.pendingBytes,s=i.refetch&&r===null,o=$(),l=i.model;if(r!==null)try{let a=yield*ie(r),g=Z(a,document);if(g)throw new Error(g);l=a}catch(a){console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",a)}if(yield,!ln(e,t,n))return;let d=null;try{d=yt(l)}catch(a){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",a)}i.refreshQueued=!1,i.pendingBytes=null,s&&(i.refetch=!1),i.repairs++,d&&(i.model=l,i.map=d.map,i.stats=d.stats,i.refreshes++,i.timing.refresh=$()-o),s&&un()}function ln(e,t,n){return i.session===e&&i.installed&&i.repairs===t&&i.adoptions===n}function un(){let e=i.repairs,t=i.adoptions;gt(window.location.href).then(n=>{let r=Qe(n),s=Z(r,document);if(s)throw new Error(s);return r}).then(n=>{if(!(i.repairs!==e||i.adoptions!==t))try{i.repairs++,i.adoptions++;let{map:r,stats:s}=yt(n);i.model=n,i.map=r,i.stats=s,i.refreshes++}catch(r){console.warn("clayjs: source map could not re-pair, continuing on the previous map:",r)}}).catch(n=>{console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:",n)})}function Tt(){let e=i.stats;return{installed:i.installed,refused:i.refused,sourceBytes:i.model?i.model.src.length:null,paired:e?e.paired:0,unresolved:e?e.unresolved:0,unmatchedLive:e?e.unmatchedLive.length:0,unmatchedSource:e?e.unmatchedSource.length:0,attrDiffs:e?e.attrDiffs.length:0,saves:i.saves,reprints:i.reprints,lastReprint:i.lastReprint,partialReprints:i.partialReprints,lastPartialReprint:i.lastPartialReprint,lastRenderMs:i.lastRenderMs,lastBytes:i.lastBytes,refreshes:i.refreshes,timing:i.timing}}function kn(){return te(),i.model?i.model.src:null}function Nn(e){return te(),i.installed&&e?st(e,i.map,i.model):null}function En(){return te(),i.stats?{live:i.stats.unmatchedLive.slice(0,50),source:i.stats.unmatchedSource.slice(0,50)}:null}function On(){return te(),Tt()}var In=()=>i.installed,Cn=()=>i.repairs;function An(){cn()}function cn(){i.session++,i.installed=!1,i.refreshQueued=!1,i.pendingBytes=null,i.refetch=!1,ce(null)}function Rn({context:e=null,latest:t=null}={}){return wt(window.location.href,e,0,!0,t)}Ce(tn);document.addEventListener("clay:sync-applied",on);export{tn as adoptAccepted,In as installed,Nn as locateLive,xe as refreshNowSteps,An as release,Gt as renderSave,vt as renderSaveSteps,Cn as repairGeneration,Rn as start,On as stats,kn as text,En as unpaired};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./c-OYW5MFPZ.js";import"./c-OH2FPYSY.js";import"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";export{a as tablesFromDoc,b as toolContext};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as ee}from"./c-YDW4VCHP.js";import{b as Q}from"./c-3G2DGZUP.js";import{p as K,q as Z}from"./c-MFOSMAVM.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import{a as B,h as X}from"./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";var We=Object.defineProperty,Ve=(e,t)=>{for(var r in t)We(e,r,{get:t[r],enumerable:!0})},Fe=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],ze=new Set(Fe),_e=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),he=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),te=new Set(["checked","selected","disabled","readOnly","paused"]);function Je(e,t){return t==null?te.has(e)?!1:"":te.has(e)?t==="false"?!1:!!t:t}var Ye={};Ve(Ye,{CodecRefused:()=>et,EmptyListInsert:()=>R,MAX_RULE_DEPTH:()=>L,MaxRuleDepthExceeded:()=>G,NoRulesTag:()=>Ze,RuleTargetReadOnly:()=>ge,RulesParseError:()=>$,ShapeMismatch:()=>ye,UnknownCodec:()=>we,UnknownRulesVersion:()=>me,WriteNotRoundTripped:()=>Ke,WriteRefused:()=>Ge,WriteRejected:()=>Qe});var $=class extends Error{constructor(e,t){super(e),this.name="RulesParseError",this.cause=t}},me=class extends Error{constructor(e){super(`unknown rules version: ${e}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=e}},L=20,G=class extends Error{constructor(e){super(`rule depth exceeded ${L} at path: ${e.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=e}},ye=class extends Error{constructor(e){super(`shape mismatch: ${e.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=e}},R=class extends Error{constructor(e,t){super(t?`cannot add items to empty list at "${e.join(".")}" \u2014 ${t}`:`cannot add items to empty list at "${e.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=e}},ge=class extends Error{constructor(e){super(`cannot write to read-only DOM property "${e}"`),this.name="RuleTargetReadOnly",this.target=e}},Ge=class extends Error{constructor(e){super(`write refused: ${e.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=e}};function Xe(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:String(r),"")||"(root)"}var Ke=class extends Error{constructor(e){super(`write did not round-trip at "${Xe(e)}"`),this.name="WriteNotRoundTripped",this.path=e}},Ze=class extends Error{constructor(e){super(`no <script data-rules-name~="${e}"> rules tag in this document`),this.name="NoRulesTag",this.token=e}},Qe=class extends Error{constructor(e,t){super(`write rejected: ${e.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=e,this.unmatched=t}},we=class extends Error{constructor(e){super(`unknown codec "${e}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=e}},et=class extends Error{constructor(e,t){super(t),this.name="CodecRefused",this.code=e}};function M(e){let t=0,r=null,o=-1;for(let n=0;n<e.length;n++){let l=e[n];l==="\\"?n++:r?l===r&&(r=null):l==='"'||l==="'"?r=l:l==="["||l==="("?t++:l==="]"||l===")"?t>0&&t--:l==="@"&&t===0&&(o=n)}return o}var re="[*]";function j(e){let t=M(e),r=t===-1?e:e.slice(0,t),o=r.endsWith(re),n={selector:o?r.slice(0,-re.length):r,prop:t===-1?null:e.slice(t+1)||null};return o&&(n.all=!0),n}function ve(e){let t=0,r=null,o=-1,n=!1;for(let l=0;l<e.length;l++){let i=e[l];i==="\\"?l++:r?i===r&&(r=null):i==='"'||i==="'"?r=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:t===0&&i===">"?o=l:t===0&&i===","&&(n=!0)}return n||o===-1||!tt(e,o+1)?null:e.slice(0,o).trim()||null}function tt(e,t){let r=t,o=e.replace(/\s+$/,"").length;for(;r<o&&/\s/.test(e[r]);)r++;let n=0,l=null;for(;r<o;r++){let i=e[r];if(i==="\\")r++;else if(l)i===l&&(l=null);else if(i==='"'||i==="'")l=i;else if(i==="["||i==="(")n++;else if(i==="]"||i===")")n>0&&n--;else if(n===0&&(i==="+"||i==="~"||/\s/.test(i)))return!1}return!0}var rt=/^codec\(([a-z][a-z0-9-]*)\)$/;function P(e){if(typeof e!="string")return null;let t=M(e);if(t===-1)return null;let r=rt.exec(e.slice(t+1));if(!r)return null;let{selector:o,all:n}=j(e);if(n)throw new $("A @codec(name) rule cannot use [*].");return{selector:o,name:r[1]}}var nt=/^--[A-Za-z0-9_-]+$/;function be(e){return typeof e=="string"&&nt.test(e)}function xe(e){let t=[],r=[],o=null,n=0;for(let l=0;l<e.length;l++){let i=e[l];if(o){i==="\\"?l++:i===o&&(o=null);continue}if(i==="/"&&e[l+1]==="*"){let a=e.indexOf("*/",l+2);l=a===-1?e.length:a+1;continue}i==='"'||i==="'"?o=i:i==="("?r.push(")"):i==="["?r.push("]"):i==="{"?r.push("}"):(i===")"||i==="]"||i==="}")&&r[r.length-1]===i?r.pop():i===";"&&r.length===0&&(t.push(e.slice(n,l)),n=l+1)}return t.push(e.slice(n)),t}function ot(e){let t="",r=null;for(let o=0;o<e.length;o++){let n=e[o];if(r){t+=n,n==="\\"&&o+1<e.length?t+=e[++o]:n===r&&(r=null);continue}if(n==="/"&&e[o+1]==="*"){let l=e.indexOf("*/",o+2);o=l===-1?e.length:l+1,t+=" ";continue}(n==='"'||n==="'")&&(r=n),t+=n}return t}function Ae(e){e=ot(e);let t=e.indexOf(":");if(t===-1)return null;let r=e.slice(0,t).trim(),o=e.slice(t+1).trim(),n=/!\s*important\s*$/i.exec(o);return n&&(o=o.slice(0,n.index).trim()),{name:r,value:o,important:!!n}}function Te(e,t){if(e==null)return null;let r=null;for(let o of xe(String(e))){let n=Ae(o);!n||n.name!==t||(!r||n.important||!r.important)&&(r=n)}return r?r.value:null}function lt(e,t,r){let o=e==null?"":String(e),n=r==null||r==="",l=xe(o),i=l.map(Ae),a=i.some(u=>u&&u.name===t&&u.important),s=[],c=!1;l.forEach((u,d)=>{let m=i[d];if(!m||m.name!==t){s.push(u);return}if(n||c)return;let p=/^\s*/.exec(u)[0];s.push(`${p}${t}: ${r}${a?" !important":""}`),c=!0});let f=s.join(";");if(!n&&!c){let u=f.trimEnd();f=u===""?`${t}: ${r}`:`${u}${u.endsWith(";")?" ":"; "}${t}: ${r}`}return f.trim()===""?null:f}function it(e,t,r,o){let n=e.attr(t,"style");if((Te(n,r)??"")===o)return;let l=lt(n,r,o);l==null?e.removeAttr(t,"style"):e.attr(t,"style",l)}var at='The @codec(name) rule form needs a rules tag with data-rules-version="2".',st="A @codec(name) rule must be the value of a top level key.";function Oe(e,t){let r=P(e);return r?{...r,codec:t.codecs[r.name]}:null}function Ee(e,t={}){let r=t.version??"1",o=t.codecs??{};n(e,0);function n(l,i){if(!(i>L)){if(typeof l=="string"){let a=P(l);if(!a)return;if(r!=="2")throw new $(at);if(i!==1)throw new $(st);if(!Object.prototype.hasOwnProperty.call(o,a.name))throw new we(a.name);return}if(Array.isArray(l)){n(l[1],i+1);return}if(l&&typeof l=="object")for(let a of Object.values(l))n(a,i+1)}}}function ke(e,t,r,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return Ee(r,o),V(e,t,r,{depth:0,path:[]},o)}function V(e,t,r,o,n){if(o.depth>L)throw new G(o.path);if(typeof r=="string")return ut(e,t,r,o,n);if(Array.isArray(r)){let[l,i]=r,a=e.find(t,l,n);return Ne(n,o,a),a.map((s,c)=>V(e,s,i,{depth:o.depth+1,path:[...o.path,c]},n))}if(typeof r=="object"&&r!==null){let l={};for(let[i,a]of Object.entries(r))l[i]=V(e,t,a,{depth:o.depth+1,path:[...o.path,i]},n);return l}return null}function ut(e,t,r,o,n){if(r.endsWith("[]")){let f=r.slice(0,-2),u=e.find(t,f,n);return Ne(n,o,u),u.map(d=>e.text(d))}let l=Oe(r,n);if(l)return ct(e,t,l,n);if(r.startsWith("@"))return W(e,t,r.slice(1));let i=M(r);if(i!==-1){let{selector:f,all:u}=j(r),d=r.slice(i+1),m=f?e.find(t,f,n):[t];return u&&n.allMatches?m.map(p=>W(e,p,d)):m.length===0?null:W(e,m[0],d)}if(r===".")return e.text(t);let{selector:a,all:s}=j(r),c=e.find(t,a,n);return s&&n.allMatches?c.map(f=>e.text(f)):c.length===0?null:e.text(c[0])}function ct(e,t,{selector:r,codec:o},n){let l=r?e.find(t,r,n):[t];return l.length===0?null:o.read(e,l[0],{query:n.query,view:n.view,region:n.region})}function Ne(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function W(e,t,r){if(be(r))return Te(e.attr(t,"style"),r);if(ze.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}return e.attr(t,r)??null}function ft(e,t,r,o){let n=e.length,l=t.length,i=new Array(n).fill(-1);if(o){let h=new Set;for(let y=0;y<n;y++){let g=o[y];!(g>=0&&g<l)||h.has(g)||(i[y]=g,h.add(g))}}if(n===0||l===0)return i;let a=e.map(h=>ne(h,r)),s=t.map(h=>ne(h,r)),c=new Array(l).fill(!1);for(let h of i)h>=0&&(c[h]=!0);let f=new Map;s.forEach((h,y)=>{c[y]||f.set(h,f.has(h)?-1:y)});let u=new Map;a.forEach((h,y)=>{i[y]>=0||u.set(h,(u.get(h)||0)+1)}),a.forEach((h,y)=>{if(i[y]>=0||u.get(h)!==1)return;let g=f.get(h);g===void 0||g===-1||c[g]||(i[y]=g,c[g]=!0)});let d=[];for(let h=0;h<n;h++)i[h]<0&&d.push(h);let m=[];for(let h=0;h<l;h++)c[h]||m.push(h);if(d.length===0||m.length===0)return i;let p=n*l+1,w=dt(e,t,r),v=(h,y)=>w(h,y)*p+Math.abs(h-y);for(let[h,y]of pt(d,m,v))i[h]=y;return i}var Se=e=>typeof e=="object"&&e!==null;function ne(e,t){if(!Se(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(o=>{let n=JSON.stringify(e?.[o]);return n===void 0?" undef":n}))}function dt(e,t,r){if(!Se(r))return(a,s)=>e[a]===t[s]?0:1;let o=Object.keys(r),n=a=>o.map(s=>JSON.stringify(a?.[s])),l=e.map(n),i=t.map(n);return(a,s)=>{let c=l[a],f=i[s],u=0;for(let d=0;d<o.length;d++)c[d]!==f[d]&&u++;return u}}function pt(e,t,r){return e.length<=t.length?oe(e,t,r,!1):oe(t,e,(o,n)=>r(n,o),!0)}function oe(e,t,r,o){let n=e.length,l=t.length,i=[];for(let u=0;u<=n;u++)i.push(new Float64Array(l+1).fill(1/0));let a=[];for(let u=0;u<=n;u++)a.push(new Uint8Array(l+1));for(let u=0;u<=l;u++)i[n][u]=0;for(let u=n-1;u>=0;u--)for(let d=l-1;d>=0;d--){let m=r(e[u],t[d])+i[u+1][d+1],p=i[u][d+1];m<=p?(i[u][d]=m,a[u][d]=1):i[u][d]=p}let s=[],c=0,f=0;for(;c<n&&f<l;)a[c][f]&&(s.push(o?[t[f],e[c]]:[e[c],t[f]]),c++),f++;return s}function Re(e,t,r,o,n,l,i,a={}){let s=e.find(t,r,a);if(n.length===0){s.forEach(b=>e.remove(b)),F(a,"onRowsApplied",l.path,[]);return}let c=n.length>s.length,f=s[0]||null;if(c&&!f&&(f=gt(e,t,r,a),!f))throw new R(l.path);let u=s.map(b=>yt(e,b,o,a)),d=null;if(c&&f){d=e.clone(f),a.templateAttr&&e.removeAttr(d,a.templateAttr);let b=e.stripIds(d);b>0&&console.warn(`[hyper-html-api] stripped ${b} id attribute(s) from cloned template at "${l.path.join(".")||"(root)"}"`)}let m=ft(n,u,o,ht(e,s,n,l,a)),p=s.length>0?e.parent(s[0]):xt(e,t,r,f,l,a),w=s.length>0?$e(e,p,s[0]):0,v=Ot(e,s),h=new Set,y=[],g=n.map((b,E)=>{let k=m[E];if(k>=0)return h.add(k),y.push(!1),s[k];y.push(!0);let T=e.clone(d);return e.stripIds(T),T});s.forEach((b,E)=>{h.has(E)||e.remove(b)}),v?Tt(e,p,w,g,y):Et(e,g,y,p,w),mt(e,g,o,n,l,i,a),F(a,"onRowsApplied",l.path,g)}function F(e,t,r,o){if(typeof e[t]=="function")try{return e[t](r.slice(),o)}catch(n){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,n);return}}function ht(e,t,r,o,n){let l=F(n,"identifyRows",o.path,r);if(!Array.isArray(l))return null;let i=new Array(r.length).fill(-1),a=new Set,s=new Map(t.map((c,f)=>[e.identity(c),f]));for(let c=0;c<r.length;c++){if(!l[c])continue;let f=s.get(e.identity(l[c]));f===void 0||a.has(f)||(i[c]=f,a.add(f))}return i}function mt(e,t,r,o,n,l,i){t.forEach((a,s)=>{if(r===null){let c=o[s],f=c==null?"":String(c);e.text(a)!==f&&e.text(a,f)}else{let c=l(e,a,r,o[s],{depth:n.depth+1,path:[...n.path,s]},i);c&&c!==a&&(t[s]=c)}})}function yt(e,t,r,o){return r===null?e.text(t):ke(e,t,r,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function $e(e,t,r){let o=e.children(t);for(let n=0;n<o.length;n++)if(e.sameNode(o[n],r))return n;return-1}function gt(e,t,r,o){if(!o.templateAttr)return null;let n=/^\s*:scope\s*>\s*/.test(r),l=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),i=r.replace(/^\s*:scope\s*>\s*/,"").replace(l,""),a=n?wt(i):0,s=ve(i),c=t;for(;c;){let f=e.find(c,i,{includeRulesTag:!1,templateAttr:null});for(let u of f)if(e.attr(u,o.templateAttr)!=null&&!(n&&!bt(e,t,u,a))&&!(s&&!e.matches(e.parent(u),s)))return u;c=e.parent(c)}return null}function wt(e){let t=0,r=null,o=1;for(let n=0;n<e.length;n++){let l=e[n];if(l==="\\")n++;else if(r)l===r&&(r=null);else if(l==='"'||l==="'")r=l;else if(l==="["||l==="(")t++;else if(l==="]"||l===")")t>0&&t--;else if(t===0&&l===">")o++;else{if(t===0&&(l==="+"||l==="~"))return null;if(t===0&&/\s/.test(l)){if(!vt(e,n))return null;for(;n+1<e.length&&/\s/.test(e[n+1]);)n++}}}return o}function vt(e,t){let r=t;for(;r<e.length&&/\s/.test(e[r]);)r++;let o=t>0?e[t-1]:"",n=r<e.length?e[r]:"";return le(o)||le(n)}function le(e){return e===">"||e==="+"||e==="~"}function bt(e,t,r,o){if(o===null)return!0;let n=r;for(let s=0;s<o;s++)if(n=e.parent(n),!n)return!1;let l=e.prop(t,"tagName");if(!l)return!0;let i=e.prop(n,"tagName");if(!i||String(i).toLowerCase()!==String(l).toLowerCase())return!1;let a=new Set(ie(e,n));return ie(e,t).every(s=>a.has(s))}function ie(e,t){let r=e.attr(t,"class");return r?String(r).split(/\s+/).filter(Boolean):[]}function xt(e,t,r,o,n,l){let i=e.parent(o);if(i&&At(e,t,i)&&!se(e,i,l))return i;let a=ve(r);if(!a)throw new R(n.path,`the list selector "${r}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let s=(a===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,a,l)).filter(c=>!se(e,c,l));if(s.length===0)throw new R(n.path,`no container matching "${a}" inside this context to hold the new rows`);if(s.length>1)throw new R(n.path,`"${a}" matches ${s.length} containers inside this context, so the new rows have no single destination`);return s[0]}function At(e,t,r){let o=r;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(n=>e.sameNode(n,r))}var ae=["no-data","editor-ui"];function se(e,t,r){let o=t;for(;o;){if(r.templateAttr&&e.attr(o,r.templateAttr)!=null||ae.some(l=>e.attr(o,l)!=null))return!0;let n=e.attr(o,"clay");if(n&&n.split(/\s+/).some(l=>ae.includes(l)))return!0;o=e.parent(o)}return!1}function Tt(e,t,r,o,n){let l=e.children(t),i=l.map(s=>e.identity(s)),a=!1;o.forEach((s,c)=>{let f=e.identity(s),u=r+c;if(i[u]===f)return;if(!n[c]){let m=i.indexOf(f);m!==-1&&(i.splice(m,1),l.splice(m,1))}let d=Math.min(u,l.length);d<l.length?e.insertBefore(l[d],s):l.length?a?e.insertAfter(l[l.length-1],s):(e.insertAt(t,s,u),a=!0):e.insertAt(t,s,0),i.splice(d,0,f),l.splice(d,0,s)})}function Ot(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let o=new Map(e.children(r).map((l,i)=>[e.identity(l),i])),n=[];for(let l of t){let i=o.get(e.identity(l));if(i===void 0)return!1;n.push(i)}return n.sort((l,i)=>l-i),n[n.length-1]-n[0]===n.length-1}function Et(e,t,r,o,n){let l=null,i=n;for(let a=0;a<t.length;a++){if(!r[a]){l=t[a];continue}let s=l?e.parent(l):o;if(!s)continue;let c=l?$e(e,s,l)+1:i++;e.insertAt(s,t[a],c),l=t[a]}}function kt(e,t,r,o,n={}){if(Object.prototype.hasOwnProperty.call(n,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");Ee(r,n);let l=[];if(z(r,o,[],l),l.length)throw new ye(l);I(e,t,r,o,{depth:0,path:[]},n)}function I(e,t,r,o,n,l={}){if(n.depth>L)throw new G(n.path);if(o===void 0)return t;if(typeof r=="string")return Nt(e,t,r,o,n,l);if(Array.isArray(r)){let[i,a]=r;return Re(e,t,i,a,o,n,I,l),t}if(typeof r=="object"&&r!==null){for(let[i,a]of Object.entries(r)){let s=I(e,t,a,o==null?o:o[i],{depth:n.depth+1,path:[...n.path,i]},l);s&&s!==t&&(t=s)}return t}return t}function Nt(e,t,r,o,n,l){if(r.endsWith("[]")){let u=r.slice(0,-2);return Re(e,t,u,null,o,n,I,l),t}let i=Oe(r,l);if(i){let u=i.selector?e.find(t,i.selector,l):[t];return u.length&&i.codec.write(e,u[0],o,{query:l.query}),t}if(r.startsWith("@"))return ce(e,t,r.slice(1),o);let a=M(r);if(a!==-1){let{selector:u,all:d}=j(r),m=r.slice(a+1),p=u?e.find(t,u,l):[t];for(let w of d?p:p.slice(0,1))ce(e,w,m,o);return t}if(r===".")return ue(e,t,o),t;let{selector:s,all:c}=j(r),f=e.find(t,s,l);for(let u of c?f:f.slice(0,1))ue(e,u,o);return t}function ue(e,t,r){let o=r==null?"":String(r);e.text(t)!==o&&e.text(t,o)}function St(e,t,r,o){if(e.styleVar){e.styleVar(t,r,o);return}it(e,t,r,o)}function ce(e,t,r,o){if(be(r))return St(e,t,r,o==null?"":String(o).trim()),t;if(he.has(r)){let n=e.prop(t,r);if(n===o||n!=null&&o!=null&&String(n)===String(o))return t;throw new ge(r)}if(r==="outerHTML"){let n=o==null?"":String(o);return e.replaceWith(t,n)}if(_e.has(r)){let n=Je(r,o);return e.prop(t,r)!==n&&e.prop(t,r,n),t}if(o==null)e.attr(t,r)!=null&&e.removeAttr(t,r);else{let n=String(o);e.attr(t,r)!==n&&e.attr(t,r,n)}return t}function z(e,t,r,o){if(t!==void 0){if(typeof e=="string"){if(P(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,l)=>{typeof n=="object"&&n!==null&&o.push({path:S([...r,l]),expected:"scalar",got:N(n)})}):o.push({path:S(r),expected:"array",got:N(t)});return}t!==null&&typeof t=="object"&&o.push({path:S(r),expected:"scalar",got:N(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:S(r),expected:"array",got:N(t)});return}let n=e[1];t.forEach((l,i)=>z(n,l,[...r,i],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:S(r),expected:"object",got:N(t)});return}for(let[n,l]of Object.entries(e))z(l,t[n],[...r,n],o)}}}function N(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function S(e){return e.join(".")}function Rt(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(n){let l=[],i=0;for(;i<n.length;){let a=n[i];if(/\s/.test(a)){i++;continue}if("{}".includes(a)){l.push({type:a,value:a}),i++;continue}if(a==="["){let u=!1,d=i+1;for(;d<n.length&&/\s/.test(n[d]);)d++;if(d<n.length&&/[a-zA-Z_]/.test(n[d])&&(u=!0),!u){l.push({type:a,value:a}),i++;continue}}if(a==="]"){l.push({type:a,value:a}),i++;continue}if(a===":"){l.push({type:t.COLON,value:a}),i++;continue}if(a===","){l.push({type:t.COMMA,value:a}),i++;continue}if(a==='"'||a==="'"){let u=a,d=i+1;for(;d<n.length&&n[d]!==u;)n[d]==="\\"&&d++,d++;l.push({type:t.STRING,value:n.substring(i+1,d),quoted:!0,sourceQuote:u}),i=d+1;continue}let s=i,c;for(;s<n.length&&!/[{},]/.test(n[s]);)if(n[s]===":"){let u=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],d=!1;for(let m of u){let p=m.substring(1);if(n.substring(s+1,s+1+p.length)===p){d=!0,s+=p.length;break}}if(!d)break}else if(n[s]==="["){for(s++;s<n.length&&n[s]!=="]";){if(n[s]==='"'||n[s]==="'"){let u=n[s];for(s++;s<n.length&&n[s]!==u;)n[s]==="\\"&&s++,s++}s++}s<n.length&&n[s]==="]"&&s++}else s++;c=n.substring(i,s);let f=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?f=t.NUMBER:c==="true"||c==="false"||c==="null"?f=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(f=t.SELECTOR),l.push({type:f,value:c,quoted:!1}),i=s}return l}function o(n){let l="";for(let i=0;i<n.length;i++){let a=n[i];if("{}".includes(a.type)||"[]".includes(a.type)){l+=a.value;continue}if(a.type===t.COLON){l+=a.value;continue}if(a.type===t.COMMA){let s=n[i+1];if(s&&(s.type==="}"||s.type==="]"))continue;l+=a.value;continue}if(a.type===t.STRING&&a.quoted){let s=a.value;a.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(c,f)=>f.length%2===0?f+'\\"':c)),l+=`"${s}"`;continue}if(a.type===t.NUMBER||a.type===t.BOOLEAN){l+=a.value;continue}if(a.type===t.SELECTOR||a.type===t.IDENTIFIER){l+=`"${a.value}"`;continue}l+=`"${a.value}"`}return l}try{let n=r(e),l=o(n);return JSON.parse(l)}catch(n){throw new $("Invalid extraction rules syntax: "+n.message,n)}}var $t=["1","2"];var Ar=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Tr=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),jt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);var Or=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...jt],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})});function Ct(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Lt(e){return e?(e.nodeType===9||e.nodeType,e):null}function fe(e,t,r){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=r===null?"":r:t==="checked"&&e.tagName==="INPUT"?e.checked=r!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=r!==null))}function Mt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Ut(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let r of t)if(r.tagName==="TEXTAREA")r.value=r.defaultValue;else if(r.tagName==="INPUT"){let o=r.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(r.value=r.defaultValue),r.checked=r.defaultChecked}else r.tagName==="OPTION"&&(r.selected=r.defaultSelected)}var It={semanticExclude:!0,find(e,t,r={}){let o=Lt(e);if(!o||!o.querySelectorAll)return[];let n=Array.from(o.querySelectorAll(t));r.includeRulesTag||(n=n.filter(a=>!Ct(a)));let l=[];r.skip&&l.push(r.skip);let i=r.templateAttr===null?null:r.templateAttr||"cms-template";if(i&&l.push("["+i+"]"),l.length){let a=l.join(", ");n=n.filter(s=>!s.closest||!s.closest(a))}return n},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Mt(e,t)},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r),fe(e,t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),fe(e,t,null)},prop(e,t,r){if(r===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=r},clone(e){let t=e.cloneNode(!0);return Ut(t),t},insertAt(e,t,r){let o=e.children[r]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let o=r.content.firstElementChild;if(!o)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(o,e),o},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};var U=It;var Pt="hha:upgrade-check:";function x(e,t){let r=e.querySelector(`meta[name="${t}"]`),o=r?r.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function de(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Dt(e,t){let r=de(e),o=de(t);if(!r||!o)return!1;let n=Math.max(r.length,o.length);for(let l=0;l<n;l++){let i=r[l]||0,a=o[l]||0;if(i!==a)return i>a}return!1}function qt(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Ht(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function Bt({force:e=!1,doc:t,loc:r,fetchFn:o,now:n,ttlMs:l=864e5}={}){if(t=t||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),o=o||(d=>fetch(d)),n=n??Date.now(),!t)return null;let i=x(t,"hyper-source");if(!i)return null;let a=x(t,"hyper-version"),s;try{s=new URL(i,r?r.href:void 0)}catch{return null}if(r&&s.origin===r.origin&&s.pathname===r.pathname)return null;let c=`${Pt}${s.href}:${a||"none"}`,f,u=e?null:qt(c);if(u&&typeof u.checkedAt=="number"&&n-u.checkedAt<l)f=u.sourceVersion;else{try{let d=await o(s.href);if(!d.ok)throw new Error(`HTTP ${d.status}`);let m=await d.text(),p=new DOMParser().parseFromString(m,"text/html");f=x(p,"hyper-version")}catch{f=null}Ht(c,{checkedAt:n,sourceVersion:f})}return f?{available:Dt(f,a||"0.0.0"),currentVersion:a,sourceVersion:f,sourceUrl:s.href}:null}var Wt="script[data-rules-name]";function Vt(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function je(e,t){let r=e.find(t,Wt,{includeRulesTag:!0}),o=new Set,n=[];for(let l of r){let i=Vt(e.attr(l,"data-rules-name"));if(!i)continue;if(o.has(i)){console.warn(`hyper-html-api: duplicate rules tag name "${i}"; using the first.`);continue}let a=e.attr(l,"data-rules-version");if(!$t.includes(a))throw new me(a);o.add(i),n.push({name:i,rules:Rt(e.text(l)),version:a})}return n}function Ce(e,t){if(t!=="2"||!e||typeof e!="object"||Array.isArray(e))return{rules:e,carried:[]};let r={},o=[];for(let[n,l]of Object.entries(e)){let i=P(l);i?o.push({key:n,selector:i.selector}):r[n]=l}return{rules:r,carried:o}}function Le(e,t,r){return e.find(t,r)[0]||null}function Me(e,t){let r={};for(let{name:o,rules:n,version:l}of je(e,t)){let{rules:i,carried:a}=Ce(n,l),s=ke(e,t,i,{version:l});for(let{key:c,selector:f}of a){let u=Le(e,t,f);s[c]=u?e.prop(u,"innerHTML"):null}r[o]=s}return r}function Ft(e){let t=e||document,r=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Me(U,t),version:x(r,"hyper-version")}}var pe=class extends Error{constructor(e,t){super(`could not fetch upgrade source: ${e}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=e,this.cause=t}},zt=class extends Error{constructor(e){super(`upgrade source has no rules tags; refusing to drop all existing data: ${e}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=e}},_=class extends Error{constructor(e,t){super(e),this.name="UpgradeTransformInvalid",this.cause=t}},_t=class extends Error{constructor(e){super(`found ${e} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=e}},Jt="text/hyper-upgrade";function Yt(e,t){let r=e.find(t,`script[type="${Jt}"]`);if(r.length===0)return null;if(r.length>1)throw new _t(r.length);return e.text(r[0])||null}var Gt=new Function("url","return import(url)");async function Xt(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t),o;try{o=await Gt(r)}catch(n){throw new _(`transform failed to load: ${n&&n.message?n.message:n}`,n)}finally{URL.revokeObjectURL(r)}if(typeof o.default!="function")throw new _("transform must `export default` a function");return o.default}function Ue(e,t){let r={carriedOver:0,discarded:0,listItems:0},o=J(t,e,r);return Y(t,e,r),{data:o,summary:r}}function J(e,t,r,o=!1){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(r.listItems+=t.length,r.carriedOver+=t.length,t):o?[]:void 0:t==null||typeof t=="object"?o&&!Kt(e)?null:void 0:(r.carriedOver++,t);if(Array.isArray(e)){let[,n]=e;return Array.isArray(t)?(r.listItems+=t.length,t.map(l=>J(n,l,r,!0))):o?[]:void 0}if(typeof e=="object"&&e!==null){let n={};for(let[l,i]of Object.entries(e)){let a=J(i,t?.[l],r,o);a!==void 0&&(n[l]=a)}return n}}function Kt(e){let t=M(e);return t!==-1&&he.has(e.slice(t+1))}function Y(e,t,r){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let o=new Set(Object.keys(e));for(let n of Object.keys(t))o.has(n)?Y(e[n],t[n],r):r.discarded+=C(t[n]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(n=>Y(o,n,r));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(r.discarded+=C(t))}}function C(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+C(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+C(r),0):1}function Zt(e,t,r){let o=je(e,t),n={carriedOver:0,discarded:0,listItems:0},l={},i=new Set;for(let{name:a,rules:s,version:c}of o){if(i.add(a),!Object.prototype.hasOwnProperty.call(r,a)){l[a]={carriedOver:0,discarded:0,listItems:0};continue}let{rules:f,carried:u}=Ce(s,c),d=r[a],{data:m,summary:p}=Ue(Qt(d,u),f);kt(e,t,f,m,{templateAttr:"cms-template"});for(let{key:w,selector:v}of u){let h=Ie(d)?d[w]:void 0;if(h==null)continue;let y=Le(e,t,v);typeof h=="string"&&y?(e.prop(y,"innerHTML",h),p.carriedOver+=1):p.discarded+=1}l[a]=p,n.carriedOver+=p.carriedOver,n.discarded+=p.discarded,n.listItems+=p.listItems}for(let a of Object.keys(r))i.has(a)||(n.discarded+=C(r[a]));return{totals:n,byName:l,rulesTagCount:o.length}}function Ie(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Qt(e,t){if(!t.length||!Ie(e))return e;let r={...e};for(let{key:o}of t)delete r[o];return r}async function er({sourceUrl:e,dataByName:t,fromVersion:r,doc:o,loc:n,fetchFn:l}={}){if(o=o||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),l=l||(h=>fetch(h)),!o)throw new Error("upgrade.run requires a document context");if(e=e||x(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let i=new URL(e,n?n.href:void 0);r=r!==void 0?r:x(o,"hyper-version"),t=t||Me(U,o);let a;try{a=await l(i.href)}catch(h){throw new pe(i.href,h)}if(!a.ok)throw new pe(i.href,new Error(`HTTP ${a.status}`));let s=await a.text(),c=new DOMParser().parseFromString(s,"text/html"),f=x(c,"hyper-version"),u=t,d=!1,m=Yt(U,c);if(m){let h=await(await Xt(m))(u,{fromVersion:r,toVersion:f});if(!h||typeof h!="object"||Array.isArray(h))throw new _("transform must return a plain object map of { rulesName: data }");u=h,d=!0}let{totals:p,byName:w,rulesTagCount:v}=Zt(U,c,u);if(v===0&&Object.keys(u).length>0)throw new zt(i.href);return{html:rr(c),fromVersion:r,toVersion:f,summary:{transformApplied:d,totals:p,byName:w}}}function tr(e){for(let t of e.querySelectorAll("input")){let r=(t.getAttribute("type")||"").toLowerCase();r!=="file"&&(r==="checkbox"||r==="radio"?t.checked!==t.hasAttribute("checked")&&t.toggleAttribute("checked",t.checked):t.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",t.value))}for(let t of e.querySelectorAll("textarea"))t.value!==t.textContent&&(t.textContent=t.value);for(let t of e.querySelectorAll("select")){let r=[...t.options];if(!t.multiple){let o=r.findIndex(n=>n.hasAttribute("selected"));if(t.selectedIndex===o||o===-1&&t.selectedIndex<=0)continue}for(let o of r)o.selected!==o.hasAttribute("selected")&&o.toggleAttribute("selected",o.selected)}}function rr(e){return tr(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
2
|
+
`+e.documentElement.outerHTML}var D={checkForUpdate:Bt,run:er,extractAll:Ft,shapeMatch:Ue};var A="The new version could not be downloaded. Nothing was changed.",q="The upgrade could not be saved. Nothing was changed.",qe="This document changed somewhere else. Reload and try again.",nr="Something else is changing this document. Nothing was changed.",or="This document does not say which parts are its data, so it cannot be upgraded safely. Nothing was changed.",lr="The new version has no place for this page's content. Nothing was changed.";async function ir(e){let t=globalThis.crypto&&globalThis.crypto.subtle;if(!t)return null;let r=await t.digest("SHA-256",e);return[...new Uint8Array(r)].map(o=>o.toString(16).padStart(2,"0")).join("")}async function Pe(e,t){try{let r=await e(t,{credentials:"omit"});return!r||!r.ok?null:r}catch{return null}}function ar(e,t,r){if(e&&typeof e.latestUrl=="string"&&e.latestUrl)return e.latestUrl;let o=x(t,"hyper-source");if(!o)return null;try{let n=new URL(o,r?r.href:void 0);return n.pathname=n.pathname.replace(/\.html$/,".json"),n.href}catch{return null}}function sr(e){let t=x(e,"clay-template");if(!t)return null;let[r,o]=t.split(/\s+/);return r&&o?{id:r,variant:o}:null}function H(e,t="",r=[]){if(Array.isArray(e)){for(let o of e)H(o,`${t}[]`,r);return r}if(e&&typeof e=="object"){for(let[o,n]of Object.entries(e))H(n,t?`${t}.${o}`:o,r);return r}return e!=null&&r.push({path:t,value:e}),r}function ur(e,t){let r=[e];for(let o of String(t).split(".")){let n=o.endsWith("[]"),l=n?o.slice(0,-2):o,i=[];for(let a of r){let s=l?a?.[l]:a;n?Array.isArray(s)&&i.push(...s):i.push(s)}r=i}return r}function cr(e,t,r={}){let o=new Map;for(let{path:l,value:i}of H(t)){let a=`${l}\0${String(i)}`;o.set(a,(o.get(a)||0)+1)}let n=[];for(let{path:l,value:i}of H(e)){let a=`${l}\0${String(i)}`;if(o.get(a)>0){o.set(a,o.get(a)-1);continue}let s=r[l];typeof s=="string"&&ur(t,s).some(c=>c===i)||n.push({path:l,value:i})}return n}async function fr(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t);try{return await new Function("url","return import(url)")(r)}finally{URL.revokeObjectURL(r)}}async function dr(e){let r=new DOMParser().parseFromString(e,"text/html").querySelector('script[type="text/hyper-upgrade"]');if(!r)return{};let o=await fr(r.textContent||"");return o&&o.renames&&typeof o.renames=="object"?o.renames:{}}var De='script[clay~="live"][merge]';function pr(e,t,r){let o=t.querySelector("article[data-blockeditor]");if(!o)return null;o.replaceWith(t.importNode(r,!0));for(let l of e.querySelectorAll(De)){let i=l.getAttribute("merge");if(i!=="blockeditor"&&!i.startsWith("blockeditor."))continue;let a=t.importNode(l,!0),s=[...t.querySelectorAll(De)].find(c=>c.getAttribute("merge")===i);s?s.replaceWith(a):t.querySelector("article[data-blockeditor]").after(a)}return(t.doctype?`<!DOCTYPE ${t.doctype.name}>
|
|
3
|
+
`:"")+t.documentElement.outerHTML}async function He(e,{doc:t=document,loc:r=location,fetchFn:o=(n,l)=>fetch(n,l)}={}){if((typeof window<"u"&&window.clay||{}).isDraftMode)return{ok:!1,code:"draft"};if(!e||typeof e.version!="string")return{ok:!1,code:"unavailable",message:A};let l=ar(e,t,r);if(!l)return{ok:!1,code:"unavailable",message:A};let i=await Pe(o,l);if(!i)return{ok:!1,code:"unavailable",message:A};let a;try{a=await i.json()}catch{return{ok:!1,code:"unavailable",message:A}}if(!a||typeof a!="object")return{ok:!1,code:"unavailable",message:A};let s=sr(t);if(!s||a.id!==s.id||a.variant!==s.variant)return{ok:!1,code:"template",message:"This upgrade is for a different document."};let c=x(t,"hyper-version");if(!c||typeof a.version!="string"||!Q(a.version,c))return{ok:!1,code:"not-newer",message:"There is no newer version to install."};if(typeof a.html!="string"||!a.html)return{ok:!1,code:"unavailable",message:A};let f;try{f=new URL(a.html,l).href}catch{return{ok:!1,code:"unavailable",message:A}}if(!/^https:\/\/hyperclay\.com\/templates\//.test(f))return{ok:!1,code:"source",message:"This upgrade is not from the template host."};let u=await Pe(o,f);if(!u)return{ok:!1,code:"unavailable",message:A};let d;try{d=await u.text()}catch{return{ok:!1,code:"unavailable",message:A}}let m=await ir(new TextEncoder().encode(d));if(!m||m!==String(a.sha256||"").toLowerCase())return{ok:!1,code:"unavailable",message:A};let p,w;try{w=await dr(d),p=await D.run({sourceUrl:f,doc:t,loc:r,fromVersion:c,fetchFn:async()=>({ok:!0,status:200,text:async()=>d})})}catch(T){return{ok:!1,code:"transform",message:T&&T.message?T.message:A}}let v=new DOMParser().parseFromString(p.html,"text/html"),h=D.extractAll(t).dataByName,y=t.querySelector("article[data-blockeditor]");if(!y&&!Object.keys(h||{}).length)return{ok:!1,code:"undeclared",message:or};let g=p.html;if(y){let T=pr(t,v,y);if(!T)return{ok:!1,code:"lost",lost:[],discarded:0,message:lr};g=T}let b=D.extractAll(v).dataByName,E=cr(h,b,w),k=p.summary&&p.summary.totals&&p.summary.totals.discarded||0;return E.length||k>0?{ok:!1,code:"lost",lost:E,discarded:k,message:hr(E,k)}:{ok:!0,html:g,version:p.toVersion||a.version}}function hr(e,t){let r=e.slice(0,5).map(({path:n})=>n),o=e.length>r.length?` and ${e.length-r.length} more`:"";return r.length?`This upgrade would lose data: ${r.join(", ")}${o}. Nothing was changed.`:`This upgrade would lose ${t} value${t===1?"":"s"}. Nothing was changed.`}function mr(e){let t=e&&e.state;if(t==="conflict")return{ok:!1,code:"conflict",message:qe};let r=e&&e.message?e.message:"The document could not be saved.";return{ok:!1,code:"flush",state:t||"failed",message:r}}async function Be(e,{doc:t=document,loc:r=location,fetchFn:o=(s,c)=>fetch(s,c),clay:n=typeof window<"u"?window.clay:null,reload:l=()=>window.location.reload(),replace:i=null,etag:a}={}){if((n||{}).isDraftMode)return{ok:!1,code:"draft"};let c=K("upgrade");if(!c)return{ok:!1,code:"busy",message:nr};try{return await yr(e,{doc:t,loc:r,fetchFn:o,clay:n,reload:l,replace:i,etag:a})}finally{Z(c)}}async function yr(e,{doc:t,loc:r,fetchFn:o,clay:n,reload:l,replace:i,etag:a}){let s=n||{};if(s.isEditMode&&s.save&&typeof s.save.flush=="function"){let p;try{p=await s.save.flush()}catch(w){return mr(w)}if(p&&typeof p.state=="string"&&p.state!=="saved"&&p.state!=="clean"&&p.state!=="view")return{ok:!1,code:"flush",state:p.state,message:"This document has changes that could not be saved. Nothing was changed."}}if(a===void 0&&!B())try{await X()}catch{}let c=a!==void 0?a:B(),f=t;if(s.isEditMode&&typeof s.getHTML=="function")try{f=new DOMParser().parseFromString(await s.getHTML(),"text/html")}catch{return{ok:!1,code:"failed",message:q}}else f=new DOMParser().parseFromString(`<!DOCTYPE html>
|
|
4
|
+
`+t.documentElement.outerHTML,"text/html");let u=await He(e,{doc:f,loc:r,fetchFn:o});if(!u.ok)return u;let d=typeof i=="function"?i:s.save&&typeof s.save.replace=="function"?s.save.replace:ee,m;try{m=await d(u.html,{etag:c})}catch{return{ok:!1,code:"failed",message:q}}if(!m||!m.ok){let p=m&&m.code?m.code:"failed";return p==="conflict"?{ok:!1,code:p,message:qe}:p==="forbidden"?{ok:!1,code:p,message:"You are not allowed to save this document."}:p==="unsupported"?{ok:!1,code:p,message:"This host cannot save the upgrade."}:{ok:!1,code:p,message:q}}return l(),{ok:!0,html:u.html,version:u.version,etag:m.etag}}function O(e,t,r={}){let o=e.createElement(t);o.setAttribute("clay","editor-ui");for(let[n,l]of Object.entries(r))n==="style"?o.setAttribute("style",l):n==="text"?o.textContent=l:o.setAttribute(n,l);return o}function gr(e){let r=(e&&e.pathname?e.pathname:"/").split("/").filter(Boolean).pop()||"page.html";try{r=decodeURIComponent(r)}catch{}return/\.html?$/i.test(r)?r:`${r}.html`}async function wr(e,{loc:t=location,fetchFn:r=(o,n)=>fetch(o,n)}={}){if(typeof e.getHTML=="function")return e.getHTML();let o=await r(t.href,{cache:"no-store",credentials:"same-origin"});if(!o.ok)throw new Error(`copy fetch ${o.status}`);return o.text()}async function vr({clay:e,doc:t=document,loc:r=location,fetchFn:o}={}){if(typeof URL>"u"||typeof URL.createObjectURL!="function")return!1;try{let n=await wr(e,{loc:r,fetchFn:o});if(typeof n=="string"&&/clay|data-paid-only/i.test(n)){let{stripCopyContent:a}=await import("./c-C4IIQZGJ.js");n=a(n)}let l=URL.createObjectURL(new Blob([n],{type:"text/html"})),i=t.createElement("a");return i.setAttribute("clay","editor-ui"),i.href=l,i.download=gr(r),i.style.setProperty("display","none","important"),t.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(l),4e4),!0}catch{return!1}}async function br(e){let t=e&&e.host;if(!t||!t.versions)return!1;try{return await t.versions===!0}catch{return!1}}async function xr(e,t={}){let r=t.doc||document,o=t.clay||(typeof window<"u"?window.clay:null)||{};if(o.isDraftMode||!e||typeof e.version!="string")return null;let n=await br(o),l=O(r,"div",{role:"dialog","aria-modal":"true","data-clay-upgrade":"",style:"position:fixed;inset:0;z-index:2147483000;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(15,17,21,.42);font-family:system-ui,-apple-system,'Segoe UI',sans-serif;"}),i=O(r,"div",{style:"width:min(460px,100%);padding:20px;border-radius:14px;background:var(--clay-ui-bg,#fff);color:var(--clay-ui-fg,#1f2328);box-shadow:0 18px 48px -16px rgba(0,0,0,.55);font-size:14px;line-height:1.5;"}),a=O(r,"h2",{text:`Upgrade to version ${e.version}`,style:"margin:0 0 8px;font-size:16px;"}),s=O(r,"p",{text:`Your data moves into version ${e.version}. The page's layout and code are replaced; your current version stays in this document's history.`,style:"margin:0 0 16px;"}),c=O(r,"p",{role:"status",style:"margin:0 0 12px;min-height:1.5em;"}),f=O(r,"div",{style:"display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end;"}),u="padding:7px 12px;border-radius:8px;border:1px solid rgba(23,28,36,.2);background:transparent;color:inherit;font:inherit;cursor:pointer;",d=O(r,"button",{type:"button",text:"Cancel",style:u}),m=n?null:O(r,"button",{type:"button",text:"Download a copy first",style:u}),p=O(r,"button",{type:"button",text:"Upgrade",style:`${u}border-color:transparent;background:#2f6fed;color:#fff;font-weight:600;`});n||(p.disabled=!0),m&&f.append(m),f.append(d,p),i.append(a,s,c,f),l.append(i),r.body.appendChild(l);let w=!1,v=()=>{w||(w=!0,l.remove())};m&&m.addEventListener("click",async()=>{await vr({clay:o,doc:r,loc:t.loc,fetchFn:t.fetchFn})?(p.disabled=!1,c.textContent="Your copy was downloaded."):c.textContent="The copy could not be downloaded. Nothing was changed."}),d.addEventListener("click",v);let h,y=new Promise(g=>{h=g});return p.addEventListener("click",async()=>{p.disabled=!0,m&&(m.disabled=!0),c.textContent=`Upgrading to version ${e.version}\u2026`;let g=await Be(e,t);if(g.ok){v(),h(g);return}c.textContent=g.message||q,p.disabled=!1,m&&(m.disabled=!1),h(g)}),{root:l,title:a,body:s,status:c,cancel:d,download:m,upgrade:p,close:v,done:y}}export{Be as apply,He as prepare,xr as start};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as l,d as i}from"./c-RETTCOWO.js";var{Plugin:p,PluginKey:f}=l,u="blockeditor-ai-preview",a=new f("blockeditor-ai-preview");function g(e,t,r){let c=new Set(t),n=[],o=-1;return e.forEach((s,d)=>{c.has(s.attrs?.id)&&(o<0&&(o=d),n.push(i.Decoration.node(d,d+s.nodeSize,{class:"blockeditor-ai-hidden"})))}),o<0?null:(n.push(i.Decoration.widget(o,r,{side:-1,ignoreSelection:!0,stopEvent:()=>!0})),i.DecorationSet.create(e,n))}function h(e,t,r){return typeof t!="number"||t<0||t>e.content.size?null:i.DecorationSet.create(e,[i.Decoration.widget(t,r,{side:1,ignoreSelection:!0,stopEvent:()=>!0})])}function y(){return new p({key:a,state:{init:()=>null,apply(e,t,r,c){let n=e.getMeta(u);if(n===void 0){if(!t)return null;let s=t.decorations.map(e.mapping,e.doc);return s?{decorations:s}:null}if(!n)return null;let o=n.ids?g(c.doc,n.ids,n.dom):h(c.doc,n.at,n.dom);return o?{decorations:o}:null}},props:{decorations:e=>a.getState(e)?.decorations??null,editable:e=>a.getState(e)?!1:void 0}})}function m(e,{ids:t,dom:r}){!e||e.isDestroyed||!t?.length||!r||e.dispatch(e.state.tr.setMeta(u,{ids:[...t],dom:r}))}function D(e,{at:t,dom:r}){!e||e.isDestroyed||typeof t!="number"||!r||e.dispatch(e.state.tr.setMeta(u,{at:t,dom:r}))}function P(e){!e||e.isDestroyed||!S(e.state)||e.dispatch(e.state.tr.setMeta(u,null))}var S=e=>!!a.getState(e);export{y as a,m as b,D as c,P as d,S as e};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{w as T}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{d as g}from"./c-ZRGEN6QQ.js";import{d as f,l as M,n as b}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{e as x}from"./c-RETTCOWO.js";import{a as k}from"./c-WCG6AKA7.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var $="blockeditor-step",l=t=>x.closeHistory(t).setMeta($,!0),y=(t,e)=>!!t&&Object.keys(t.type.attrs).every(r=>t.attrs[r]===e[r]);function C(t,e,r){let o=t.state,{from:n,to:a,empty:u,$from:s}=o.selection,c=o.tr;if(u)y(e.isInSet(o.storedMarks||s.marks()),r)?c.removeStoredMark(e):c.addStoredMark(e.create(r));else{let i=!0;o.doc.nodesBetween(n,a,h=>{i&&h.isText&&!y(e.isInSet(h.marks),r)&&(i=!1)}),i?c.removeMark(n,a,e):c.addMark(n,a,e.create(r))}return t.dispatch(l(c)),!0}function F(t,e){let r=t.state,o=r.tr;return r.selection.empty?o.removeStoredMark(e):o.removeMark(r.selection.from,r.selection.to,e),t.dispatch(l(o)),!0}function p(t,e){let r=t.runFormatCommand;return typeof r!="function"?Promise.resolve({status:"unsupported-host",code:"blockeditor-format-unsupported",retry:!1}):r(e)}function A(t,e,r={},{reset:o=!1}={}){let n=f.marks[e];return n?t.editable?b(t.state,n)?p(t,()=>o?F(t,n):C(t,n,r)):Promise.resolve({status:"refused",code:"mark-not-allowed"}):Promise.resolve({status:"refused",code:"not-editable"}):Promise.resolve({status:"refused",code:"unsupported-format"})}function B(t,e,r,o){let n=t.state.doc,a=()=>{if(t.isDestroyed)return!1;let s=t.state;return s.selection.from!==r||s.selection.to!==o?!1:(t.dispatch(s.tr.replaceSelection(e).scrollIntoView()),!0)},u=()=>{let s=e.content.textBetween(0,e.content.size,`
|
|
2
|
+
`," ");return!t.isDestroyed&&s&&t.state.doc===n&&t.dispatch(t.state.tr.insertText(s,r,o)),!1};p(t,a).then(s=>{s?.status!=="applied"&&(m(t,s?.message??"That format isn\u2019t available here."),u())},u)}function H(t,e,{at:r,from:o,to:n},a){let u=()=>{if(e.isDestroyed)return!1;let s=e.state,c=s.doc.nodeAt(r);if(!c||c.type!==f.nodes.paragraph||c.textContent!=='"')return a();let i=s.tr.delete(r+1,r+2).setNodeMarkup(r,f.nodes.quote,c.attrs);return e.dispatch(l(i.setMeta(t,{transform:i,from:o,to:n,text:" "}))),!0};e.runFormatCommand(u).then(s=>{s?.status!=="applied"&&(s&&m(e,S(s)),a())},a)}var N="This text can\u2019t take that format.",S=t=>t.status==="upgrade-required"?t.message:t.code==="mark-not-allowed"?N:"That format isn\u2019t available here.",m=(t,e)=>{t.isDestroyed||(g(t,e),k(e,"error"))},P=(t,e)=>{e?.status!=="applied"&&m(t,S(e??{}))},d=(t,e,r={},o=void 0)=>{A(t,e,r,o).then(n=>P(t,n))},O=(t,e)=>{p(t,e).then(r=>P(t,r))};function j(t,e,r){if(e==="underline")return d(t,e);let o=e==="text_color"?"Text":"Highlight",n=e==="text_color"?"Automatic":"No highlight";return T(t,r,[...M.map(a=>({key:`${e}_${a}`,label:`${o}: ${a[0].toUpperCase()}${a.slice(1)}`,icon:"\u25CF",run:u=>d(u,e,{color:a})})),{key:`${e}_none`,label:n,icon:"\xD7",run:a=>d(a,e,{},{reset:!0})}])}export{A as formatMark,O as gateTurn,j as nativeMenu,B as pasteFormats,H as quoteFromSpace,m as refuse,p as runFormat,d as runNative};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{e as X,f as G,h as J,i as Q,j as P,k as U}from"./c-NICICT4P.js";import{a as C,f as L}from"./c-CZHTXGJS.js";import"./c-WN3MXOLT.js";import"./c-V2V5FKXX.js";import{a as O,b as N,k as z,l as K,m as j,n as V,v as T}from"./c-WMRJKQ2V.js";import{p as w}from"./c-ZRGEN6QQ.js";import"./c-OH2FPYSY.js";import{b as y,d as H}from"./c-RETTCOWO.js";import{b as W}from"./c-RS77ODLY.js";import"./c-7SWMYKAI.js";import"./c-UGHH4MB3.js";import"./c-LA2BW7UY.js";import{d as q}from"./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-VG5XIN4T.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var ce=128,D=r=>r.depth?r.node(1).attrs.id:null,Z=r=>!!r.depth&&r.node(1).type.name==="table",ae=(r,t,o,e,n)=>O(K(z(r.flow,J(t,o.holes,e,o.visible),n)));function te({pd:r,w:t,doc:o},e){if(!r||!t||!o||!e)return null;if(e instanceof y.TextSelection){let n=e.$anchor,s=e.$head;if(Z(n)||Z(s)){let a=P(o,n.pos),u=P(o,s.pos);return!a||!u||a.table!==u.table||a.row!==u.row||a.col!==u.col?null:{kind:"cell",block:a.table,row:a.row,col:a.col}}let i=Math.min(e.from,e.to),l=a=>{let u=D(a);return u===null?null:{block:u,rel:ae(r,o,t,a.pos,e.empty||a.pos===i?0:-1)}},c=l(n),m=l(s);return c&&m?{kind:"text",anchor:c,head:m}:null}if(e instanceof w||e instanceof y.NodeSelection){let n=[];if(e instanceof w){let{lo:s,hi:i}=e.span();o.forEach((l,c,m)=>{m>=s&&m<=i&&n.push(l.attrs.id)})}else{let s=o.nodeAt(e.from);s&&n.push(s.attrs.id)}if(!n.length)return null;if(n.length>ce){let s=D(e.$from);return s?{kind:"blocks",ids:[s]}:null}return{kind:"blocks",ids:n}}return null}var ue=(r,t)=>{if(!t||typeof t!="object"||typeof t.block!="string"||!t.block||typeof t.rel!="string"||!t.rel)return null;let o;try{o=j(N(t.rel))}catch{return null}let e;try{e=V(o,r.ydoc)}catch{return null}return!e||e.type!==r.flow?null:e.index},fe=(r,t)=>{let o=0;for(let e=r.flow._start;e;e=e.right){let n=o+e.length;if(t<n)return!e.deleted;o=n}return!1},de=(r,t)=>{for(let o=r.flow._start;o;o=o.right)if(!o.deleted&&o.content instanceof T&&o.content.embed?.b===t)return!0;return!1},me=(r,t)=>{let o=0,e=null,n=0;for(let s=r.flow._start;s;s=s.right)if(s.content instanceof T&&s.content.embed?.b!==void 0&&(e=s.content.embed.b,n=o+s.length),o+=s.length,o>t&&e!==null)return{id:e,offset:t-n};return e===null?null:{id:e,offset:t-n}},pe=(r,t,o)=>{let e=null;return r.forEach((n,s)=>{e===null&&n.attrs.id===t&&n.isTextblock&&(e=s+1+Math.min(Math.max(o,0),n.content.size))}),e},ee=({pd:r,w:t,doc:o},e)=>{let n=ue(r,e);if(n===null)return null;let s=Q(o,t.holes,t.tokens,n,t.visible);if(D(o.resolve(s))===e.block)return s;let i=me(r,n);if(i&&i.id===e.block){let l=pe(o,e.block,i.offset);if(l!==null)return l}return de(r,e.block)||!fe(r,n)||t.holes.some(l=>n>=G(t.holes,l.at)&&n<X(t.holes,l.at))?null:o.resolve(s).parent.inlineContent?s:null};function oe({pd:r,w:t,doc:o},e){if(!r||!t||!o||!e||typeof e!="object")return null;if(e.kind==="text"){let n=ee({pd:r,w:t,doc:o},e.anchor),s=ee({pd:r,w:t,doc:o},e.head);return n===null||s===null?null:{kind:"text",from:Math.min(n,s),to:Math.max(n,s)}}if(e.kind==="cell"){let n=U(o,{table:e.block,row:e.row,col:e.col,offset:0});return n?{kind:"cell",from:n.from,to:n.to,block:n.block,row:n.row,col:n.col}:null}if(e.kind==="blocks"){let n=[],s=[];for(let i of Array.isArray(e.ids)?e.ids:[])o.forEach((l,c)=>{l.attrs.id!==i||n.includes(i)||(n.push(i),s.push({from:c,to:c+l.nodeSize}))});return s.length?{kind:"blocks",ids:n,ranges:s}:null}return null}var{Plugin:be,PluginKey:ge}=y,{Decoration:h,DecorationSet:x}=H,k=new ge("blockeditor-awareness"),ne="blockeditor-awareness-style",he=`
|
|
2
|
+
.blockeditor-remote-selection { background-color: color-mix(in srgb, var(--blockeditor-remote-color, currentColor) 22%, transparent); }
|
|
3
|
+
.blockeditor-remote-caret { position: relative; display: inline-block; width: 0; height: 1.1em; vertical-align: text-bottom; }
|
|
4
|
+
.blockeditor-remote-caret::before { content: ""; position: absolute; inset-inline-start: -1px; top: 0; bottom: 0; width: 2px; background: var(--blockeditor-remote-color, currentColor); }
|
|
5
|
+
.blockeditor-remote-name { position: absolute; inset-inline-start: -1px; bottom: 100%; padding: 1px 4px; border-radius: 4px; background: var(--blockeditor-remote-color, currentColor); color: #fff; font-size: 10px; line-height: 1.4; white-space: nowrap; pointer-events: none; }
|
|
6
|
+
.blockeditor-remote-cell { outline: 2px solid var(--blockeditor-remote-color, currentColor); outline-offset: -2px; }
|
|
7
|
+
.blockeditor-remote-block { box-shadow: inset 2px 0 0 var(--blockeditor-remote-color, currentColor); }
|
|
8
|
+
`,re=["#2F5E9E","#8A3B6E","#3E6A28","#8A5A1E","#5E4596","#1F5A8A"],ke=r=>{let t=typeof r=="string"?r:"",o=0;for(let e=0;e<t.length;e++)o=o*31+t.charCodeAt(e)>>>0;return re[o%re.length]},_=(r,t,o)=>{let e=r.createElement("span");e.className="blockeditor-remote-caret",e.setAttribute("aria-hidden","true"),e.style.setProperty("--blockeditor-remote-color",o);let n=r.createElement("span");return n.className="blockeditor-remote-name",n.textContent=t,e.appendChild(n),e},ye=r=>typeof r.name=="string"&&r.name.trim()?r.name.trim():"Someone",F=!1;typeof document<"u"&&(document.addEventListener("clay:presence-quiesce",()=>{F=!0}),document.addEventListener("clay:presence-resume",()=>{F=!1}));function se({binding:r,doc:t,snapshot:o,epoch:e}){let n=r.awareness.generation(),s={...r.awareness.map(),doc:t},i=[];for(let l of o.people??[]){if(l.you)continue;let c=ke(l.id),m=ye(l);for(let a of l.sessions??[]){if(a.you)continue;let u=a.editing;if(!u||u.kind!=="blockeditor"||u.v!==C||u.epoch!==e||u.generation!==n)continue;let f=oe(s,u.selection);if(f){if(f.kind==="text")f.to>f.from&&i.push(h.inline(f.from,f.to,{class:"blockeditor-remote-selection",style:`--blockeditor-remote-color:${c}`})),i.push(h.widget(f.to,g=>_(g.dom.ownerDocument,m,c),{side:1,key:`caret:${l.id}:${a.id}`}));else if(f.kind==="cell")i.push(h.node(f.from,f.to,{class:"blockeditor-remote-cell",style:`--blockeditor-remote-color:${c}`})),i.push(h.widget(f.from+1,g=>_(g.dom.ownerDocument,m,c),{side:-1,key:`cell:${l.id}:${a.id}`}));else if(f.kind==="blocks"){let[g]=f.ranges;for(let p of f.ranges)i.push(h.node(p.from,p.to,{class:"blockeditor-remote-block",style:`--blockeditor-remote-color:${c}`}));i.push(h.widget(g.from+1,p=>_(p.dom.ownerDocument,m,c),{side:-1,key:`blocks:${l.id}:${a.id}`}))}}}}return i.length?x.create(t,i):x.empty}function Ee({binding:r,view:t,store:o=L,epoch:e,composing:n=null,frame:s=l=>requestAnimationFrame(l),cancel:i=l=>cancelAnimationFrame(l)}){if(!r?.awareness||!t||typeof e!="string"||!e)return null;W(ne,he,ne,["editor-ui"]);let l=t.dom.ownerDocument,c=!1,m=F,a=typeof t.hasFocus=="function"?t.hasFocus()===!0:t.dom.contains(l.activeElement),u=null,f=()=>n?n()===!0:t.composing===!0,g=()=>o.getSnapshot().pageAwareness!==!1,p=(d=t.state)=>{if(c||m)return;if(!g()||!a||f()){o.setTarget(null);return}let b=te({...r.awareness.map(),doc:d.doc},d.selection);if(!b){o.setTarget(null);return}o.setTarget({kind:"blockeditor",v:C,epoch:e,generation:r.awareness.generation(),selection:b})},le=d=>f()?k.getState(t.state):se({binding:r,doc:d.doc,snapshot:o.getSnapshot(),epoch:e}),A=new be({key:k,state:{init:(d,b)=>se({binding:r,doc:b.doc,snapshot:o.getSnapshot(),epoch:e}),apply:(d,b,xe,R)=>((d.docChanged||d.selectionSet)&&p(R),d.docChanged||d.getMeta(k)?le(R):b)},props:{decorations(d){return k.getState(d)??x.empty}}}),M=()=>{c||t.isDestroyed||t.dispatch(t.state.tr.setMeta(k,!0))},E=()=>{c||u!==null||t.isDestroyed||(u=s(()=>{u=null,M()}))},ie=o.subscribe(d=>{d.pageAwareness===!1&&o.setTarget(null),E()}),S=()=>{c||(m=!0,o.setTarget(null))},v=()=>{c||(m=!1,p())},Y=()=>{a=!0,p(),E()},$=()=>{a=!1,o.setTarget(null)},B=()=>{o.setTarget(null)},I=()=>{p(),E()};return t.dom.addEventListener("focus",Y),t.dom.addEventListener("blur",$),t.dom.addEventListener("compositionend",I),l.addEventListener("pagehide",B),l.addEventListener("clay:presence-quiesce",S),l.addEventListener("clay:presence-resume",v),t.updateState(t.state.reconfigure({plugins:[...t.state.plugins,A]})),p(),E(),{epoch:e,refresh:M,plugin:A,quiesce:S,resume:v,get decorations(){return k.getState(t.state)??x.empty},get target(){return o.target??null},dispose(){if(!c&&(c=!0,u!==null&&(i(u),u=null),ie(),t.dom.removeEventListener("focus",Y),t.dom.removeEventListener("blur",$),t.dom.removeEventListener("compositionend",I),l.removeEventListener("pagehide",B),l.removeEventListener("clay:presence-quiesce",S),l.removeEventListener("clay:presence-resume",v),o.setTarget(null),o.releaseTarget(),!t.isDestroyed)){let d=t.state.plugins.filter(b=>b!==A);t.updateState(t.state.reconfigure({plugins:d}))}}}}async function $e({binding:r,view:t,store:o=L,meta:e=null}={}){if(!r?.awareness||!t)return null;let n=e??await q(),s=Array.isArray(n?.extensions)?n.extensions:[];if(o.setCapabilities({supported:s.includes("presence"),recordAwareness:s.includes("record-awareness-v1"),pageAwareness:s.includes("blockeditor-awareness-v1")}),!s.includes("blockeditor-awareness-v1"))return null;let i=n.document?.awareness?.scope;return typeof i!="string"||!i?null:Ee({binding:r,view:t,store:o,epoch:i})}export{k as awarenessKey,ke as colorOf,Ee as createPageAwareness,se as decorationsFor,$e as installPageAwareness};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as me,b as pe,c as he}from"./c-SIM7Z3U7.js";import{a as de,b as fe}from"./c-OYW5MFPZ.js";import{a as F,b as U,c as ue}from"./c-H3FNLBHN.js";import{C as X,E as le,h as z,l as ce,m as Y}from"./c-ZRGEN6QQ.js";import{A as se,d as N,x as oe}from"./c-OH2FPYSY.js";import"./c-VPXCXBDT.js";import{b as $,c as ae,d as R}from"./c-Z6MROEQ4.js";import{b as ie}from"./c-Q26XHBLQ.js";import{a as H,b as V}from"./c-RETTCOWO.js";import{a as re}from"./c-3LDGIBMN.js";import"./c-VHNSBD2M.js";var ge=16384,we=i=>new TextEncoder().encode(JSON.stringify(i)).length,G=class extends Error{constructor(n,t=n){super(t),this.name="ToolRequestError",this.code=n}};function Oe(i){let n=re(i);for(Array.isArray(n.tables)||(n.tables=[]),Array.isArray(n.outline)||(n.outline=[]);we(n)>ge;){let t=[...n.tables].reverse().find(r=>Array.isArray(r.rows)&&r.rows.length);if(t)t.rows.pop();else if(n.outline.length)n.outline.pop();else break}if(we(n)>ge)throw new G("context-too-large");return n}var Me=()=>globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;function ve({transport:i,newId:n=Me}){let t=null,r=s=>{!s||s.discarded||s.done||(s.discarded=!0,t===s&&(t=null),i.cancel(s.requestId),s.resolve({requestId:s.requestId,code:"discarded",message:"Candidate discarded"}))};return{request(s,a,v=null,h=null){let o=Oe(a);t&&r(t);let m=n(),l={requestId:m,discarded:!1,done:!1};l.promise=new Promise(u=>{l.resolve=u}),t=l;let e={protocol:"blockeditor-tool/1",requestId:m,prompt:s,context:o,target:v,current:h};l.request=e;let f=u=>{if(!(l.discarded||l.done||u?.requestId!==m))if(l.done=!0,t===l&&(t=null),u?.artifact!==void 0){let g=F(u.artifact),d=U(u.state),p=g.ok?d.ok?null:d:g;l.resolve(p?{requestId:m,code:p.code,message:p.code}:u)}else l.resolve(typeof u?.code=="string"?u:{requestId:m,code:"invalid-result",message:"invalid-result"})};try{let u=g=>f({requestId:m,code:typeof g?.code=="string"?g.code:"transport-error",message:String(g?.message??g)});Promise.resolve(i.request(e)).then(f,u)}catch(u){f({requestId:m,code:typeof u?.code=="string"?u.code:"transport-error",message:String(u?.message??u)})}return l},discard:r,async wait(s,{signal:a}={}){if(a?.aborted)throw new DOMException("Aborted","AbortError");let v,h=await(a?Promise.race([s.promise,new Promise((o,m)=>{v=()=>m(new DOMException("Aborted","AbortError")),a.addEventListener("abort",v,{once:!0})})]).finally(()=>a.removeEventListener("abort",v)):s.promise);if(h?.code)throw new G(h.code,h.message);return h}}}var J=class extends Error{constructor(n){super(n),this.name="ToolTransportError",this.code=n}};function ye({getWire:i=()=>globalThis.window?.clay?.wire??null}={}){let n=new Map;return{request(t,{onStatus:r=null}={}){let s=i();if(!s||typeof s.send!="function")return Promise.reject(new J("no-wire"));let a=t?.requestId,v;try{v=s.send(t,{helper:"blockeditor-tool",document:"none",id:a,onStatus:r})}catch{return Promise.reject(new J("no-wire"))}return n.set(a,v),Promise.resolve(v.done).then(h=>{if(n.get(a)===v&&n.delete(a),h?.state==="done"){let o=h.result??{};return{requestId:typeof o.requestId=="string"?o.requestId:a,artifact:o.artifact,state:o.state,model:o.model}}return{requestId:a,code:h?.errorCode||(h?.state==="cancelled"?"cancelled":"transport-error"),message:h?.error||"the helper reported an error"}},()=>({requestId:a,code:"transport-error",message:"the helper reported an error"}))},cancel(t){let r=n.get(t);n.delete(t),r?.cancel?.()}}}var{Selection:Be}=V,W="This page is not open for editing any more.",Ie="AI tool making isn't available on this page right now.",Te="This document can't save tool data.",K="The place for this tool moved. Close this and run /ai where you want the tool.",be="This tool changed while you were revising, so nothing was replaced. Ask again.",Q="AI did not make a usable tool. Try again.",Ne="The tool data from AI is too large or not usable. Try again.",xe="This tool's data changed while AI was working, so it was not replaced. Ask again to include the latest data.",Ae="The tool could not be saved, so it was not added. Try again.",Re="Your tool is in the document, but saving failed. It will be saved with your next edit.";function _(i,n){let t=null;return i.forEach((r,s,a)=>{r.attrs.id===n&&(t={node:r,at:s,index:a})}),t}function Pe(i,n){let t=i.selection.$head,r=Math.min(Math.max(t.index(0),0),i.doc.childCount-1);return{hostId:i.doc.child(r)?.attrs.id??null,slashText:n?i.doc.textBetween(n.from,n.to):null,slashOffset:n&&t.depth?n.from-t.before(1)-1:null}}function Z(i,n){let t=n?.hostId?_(i.doc,n.hostId):null;if(!t)return null;let r=i.doc.maybeChild(t.index+1),s=t.node.isTextblock&&(t.node.content.size===0||t.node.textContent===n.slashText);return{...t,replace:s,pos:s?t.node.attrs.pos:oe(t.node.attrs.pos,r?.attrs.pos??null),insertAt:s?t.at:t.at+t.node.nodeSize}}function _e(i,n,t){let r=i.state,s=Z(r,t);if(!s)return!1;let{node:a,at:v,insertAt:h,replace:o}=s,m=N.nodes.tool.create({id:n.id,pos:s.pos,parent:a.attrs.parent??null,artifact:n.artifact,rev:n.rev,state:n.state}),l=r.tr;if(!o&&t?.hostId===a.attrs.id&&t.slashText&&t.slashOffset>=0){let f=v+1+t.slashOffset,u=f+t.slashText.length;u<=v+a.nodeSize-1&&r.doc.textBetween(f,u)===t.slashText&&l.delete(f,u)}let e=l.mapping.map(h);return l.replaceWith(e,o?l.mapping.map(v+a.nodeSize):e,m),l.setSelection(Be.near(l.doc.resolve(Math.min(e+m.nodeSize,l.doc.content.size)))),i.dispatch(X(l).scrollIntoView()),!0}var Se=()=>({x:0,y:0,left:0,top:0,right:0,bottom:0,width:0,height:0});function Ee({getView:i,store:n=()=>null,acceptState:t=()=>globalThis.clay?.save?.flush?.(),newId:r=se,transport:s=ye()}={}){let a=()=>{let e=i();return e&&!e.isDestroyed?e:null},v=()=>typeof n=="function"?n():n,h=(e,f)=>{let u=v()?.data?.[e]?.[f];return u===void 0?{}:u},o=new Map,m=e=>Array.isArray(e)?`[${e.map(m).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(u=>`${JSON.stringify(u)}:${m(e[u])}`).join(",")}}`:JSON.stringify(e)??"null";function l(e=null,f=null){let u=a(),g=e||!u?null:Pe(u.state,f),d=null,p=ve({transport:{request:c=>s.request(c,{onStatus:T=>d?.(T)}),cancel:c=>s.cancel(c)}}),b=null,w=null,y=null,M=!1,k=null,O=null,C=()=>{y?.host?.dispose(),y=null},L=()=>{let c=a();return c&&e?ie.get(c)?.get(e)??null:null},j=()=>L()?.suspend(),B=()=>L()?.resume(),q=c=>{M=!1;let T=a();return C(),T&&R(T),B(),{status:"failed",message:c}},ne={aiTarget:!0,label:e?"This tool":"New tool",ref:e?[e]:[],placeholder:e?"What should change?":"Describe the tool",get isConnected(){let c=a();return c?e?!!_(c.state.doc,e):!0:!1},getBoundingClientRect(){let c=a();if(!c)return Se();if(y)return y.dom.getBoundingClientRect();let T=e??g?.hostId,A=T?_(c.state.doc,T):null,E=A?c.nodeDOM(A.at):null;return E&&typeof E.getBoundingClientRect=="function"?E.getBoundingClientRect():Se()},async start(c){w=null,M=!1;let T=a();if(!T)return{status:"refused",code:"gone",message:W};if(!globalThis.window?.clay?.wire)return{status:"refused",code:"no-wire",message:Ie};let A=null,E=null;if(e){let x=_(T.state.doc,e);if(x?.node.type!==N.nodes.tool)return{status:"refused",code:"gone",message:W};k=x.node.attrs.rev,A={toolId:e,rev:k},j(),E={artifact:x.node.attrs.artifact,state:h(e,k)},O=m(E.state)}return b=p.request(c,fe(T.state.doc,T.dom.ownerDocument.title),A,E),{status:"ok",id:b.requestId,send:(x={})=>(d=typeof x.onStatus=="function"?x.onStatus:null,{done:p.wait(b).then(S=>(w={id:e,rev:null,artifact:S.artifact,state:S.state},{state:"done",result:S}),S=>(B(),{state:"error",error:S?.message||S?.code||"the helper reported an error",code:S?.code??null})),cancel:()=>{B(),p.discard(b)}})}},async propose(c){let T=a();if(!T||!c)return{status:"refused",message:W};if(!F(c.artifact).ok)return{status:"refused",message:Q};if(!U(c.state).ok)return{status:"refused",message:Ne};w={id:e,rev:null,artifact:c.artifact,state:c.state};let x=De(T);return x.status!=="ready"&&(w=null),x},async keep(){if(!w||M)return q(be);let c=a();if(!c)return q(W);let T=v();if(!T)return q(Te);let A=()=>e&&O!==null&&m(h(e,k))!==O;if(A())return q(xe);M=!0;let E=w.id??r("b"),x=r("rev"),I={...w,id:E,rev:x};try{await T.set([E,x],I.state)}catch(D){return q(D?.message??Te)}let S=null;try{S=await t()}catch{return q(Ae)}if(S?.ok!==!0&&!["saved","clean"].includes(S?.state))return q(S?.msg??S?.message??Ae);if(e){let D=_(c.state.doc,e);if(D?.node.type!==N.nodes.tool||D.node.attrs.rev!==k)return q(be)}else if(!Z(c.state,g))return q(K);if(A())return q(xe);if(C(),R(c),e){let D=_(c.state.doc,e);c.dispatch(X(c.state.tr.setNodeMarkup(D.at,null,{...D.node.attrs,artifact:I.artifact,rev:I.rev})))}else if(!_e(c,I,g))return q(K);let P=!1;for(let D=0;D<2&&!P;D++)try{P=(await t())?.ok!==!1}catch{P=!1}return P?(o.delete(e??"new"),{status:"kept"}):{status:"failed",message:Re}},discard(){C();let c=a();c&&R(c),p.discard(b),B(),o.delete(e??"new")}};function De(c){C();let T=ue({mode:"view",tables:()=>de(c.state.doc).map(({id:I,cols:S,rows:P})=>({id:I,cols:S,rows:P}))}),A=c.dom.ownerDocument.createElement("div");A.className="blockeditor-ai-preview";let E=null;try{E=T.mount(A,{id:"preview",rev:"preview",artifact:w.artifact,seed:w.state})}catch{return T.dispose(),{status:"refused",message:Q}}if(E.failed)return T.dispose(),{status:"refused",message:Q};if(y={host:T,dom:A},e)return $(c,{ids:[e],dom:A}),{status:"ready"};let x=Z(c.state,g);return x?(x.replace?$(c,{ids:[x.node.attrs.id],dom:A}):ae(c,{at:x.insertAt,dom:A}),{status:"ready"}):(C(),{status:"refused",message:K})}return e&&o.set(e,ne),ne}return{newTool(e=null){return l(null,e)},reviseTool(e){let f=o.get(e);return f?.isConnected?f:(o.delete(e),l(e))}}}var{TextSelection:$e}=V,ze="ai-edit",Le="page area",je="This section is too large for AI editing. Select a smaller part.",Ce="Someone changed this area while AI was working, so nothing was changed.",Ve="This page is not open for editing any more.",Fe="AI editing isn't available on this page right now.",Ue=0;function te(i,n){let t=null;return i.forEach((r,s)=>{r.attrs?.id===n&&(t={node:r,at:s})}),t}var qe=(i,n)=>te(i,n)?.node?.type===N.nodes.tool,ee=(i,n,t)=>i.slice(n,t+1).map(r=>r.node.attrs.id).filter(Boolean),Ge=()=>globalThis.crypto?.randomUUID?.()??`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,ke=()=>({x:0,y:0,left:0,top:0,right:0,bottom:0,width:0,height:0});function Je(i){if(!i.length)return ke();let n=Math.min(...i.map(a=>a.left)),t=Math.min(...i.map(a=>a.top)),r=Math.max(...i.map(a=>a.right)),s=Math.max(...i.map(a=>a.bottom));return{x:n,y:t,left:n,top:t,right:r,bottom:s,width:r-n,height:s-t}}function We(i,n,t){let r=i.selection;if(!(r instanceof $e)||r.empty)return null;let[s,a]=ce(i.doc,r,n);if(s!==a||t.lo!==s||t.hi!==s)return null;let v=n[s];if(r.from<v.at||r.to>v.end)return null;let h=i.doc.textBetween(r.from,r.to," ");if(!h.trim())return null;let o=i.doc.textBetween(v.at+1,r.from," ").length;return{text:h,start:o,end:o+h.length}}function Tt({getView:i,store:n=()=>null,acceptState:t}={}){let r=()=>{let o=i();return o&&!o.isDestroyed?o:null},s=new Map,a=Ee({getView:r,store:n,acceptState:t}),v=o=>a.reviseTool(o);function h(o,{quote:m=null,label:l=null}={}){for(let[d,p]of s)p.isConnected||s.delete(d);let e=s.get(o.join(","));if(e)return e.quote=m??void 0,e;let f=null,u=null,g={aiTarget:!0,label:l??(o.length===1?"This block":`${o.length} blocks`),ref:[...o],get isConnected(){let d=r();return!!d&&o.some(p=>te(d.state.doc,p))},getBoundingClientRect(){let d=r();if(!d)return ke();let p=d.dom.querySelector(".blockeditor-ai-preview");if(p)return p.getBoundingClientRect();let w=[g.ref[0],g.ref[g.ref.length-1]].map(y=>te(d.state.doc,y)).map(y=>y?d.nodeDOM(y.at):null).filter(y=>y&&typeof y.getBoundingClientRect=="function").map(y=>y.getBoundingClientRect());return Je(w)},async start(d,p){let b=r();if(!b)return{status:"refused",code:"gone",message:Ve};let w=window.clay?.wire;if(!w)return{status:"refused",code:"no-wire",message:Fe};let{captureArea:y,AREA_GUIDE:M}=await import("./c-47IBJGPQ.js"),k=y(b.state.doc,g.ref);if(f=null,u=null,k.status!=="ok")return{status:"refused",code:k.code,message:k.message};let O=p??g.quote,C={id:"req-"+Date.now().toString(36)+"-"+ ++Ue,editId:Le,tag:"div",elementHTML:k.capture.html,comment:d+`
|
|
2
|
+
|
|
3
|
+
`+M,contextRefs:pe(d)};return O&&(C.quote=O.text,Number.isInteger(O.start)&&(C.selection={start:O.start,end:O.end})),he(d)&&(C.page=!0),new Blob([JSON.stringify(C)]).size>921600?{status:"refused",code:"too-large",message:je}:(f=k.capture,{status:"ok",id:C.id,send:(L={})=>{let j=!0,B=null;return{done:(async()=>(C.page&&await window.clay?.save?.(),j?(B=w.send(C,{helper:ze,onStatus:L.onStatus}),B.done):{state:"cancelled"}))(),cancel(){j=!1,B?.cancel()}}}})},async propose(d){let p=r();if(!p||!f)return{status:"refused",message:"This area is no longer open for AI editing."};let{proposeArea:b}=await import("./c-47IBJGPQ.js"),w=b(p.state,f,d?.html??"",{seed:Ge()});if(w.status!=="ready")return{status:"refused",message:w.message};u=w;let y=p.dom.ownerDocument.createElement("div");y.className="blockeditor-ai-preview";let M=H.DOMSerializer.fromSchema(N);return y.appendChild(M.serializeFragment(H.Fragment.from(w.nodes),{document:p.dom.ownerDocument})),$(p,{ids:f.ids,dom:y}),{status:"ready"}},async keep(){let d=r();if(!d||!f||!u)return{status:"failed",message:Ce};let{keepAreaTransaction:p}=await import("./c-47IBJGPQ.js"),b=p(d.state,f,u);if(R(d),b.status!=="ok")return{status:"failed",message:Ce};d.dispatch(b.tr),d.dom.isConnected&&d.focus();try{await window.clay?.save?.flush?.()}catch{return{status:"failed",message:"Your change is in the document, but saving failed. It will be saved with your next edit."}}return{status:"kept"}},discard(){let d=r();d&&(R(d),d.dom.isConnected&&d.focus())}};return g.quote=m??void 0,s.set(o.join(","),g),g}return{active:()=>!!r(),targetFromSelection(){let o=r();if(!o)return null;let m=z(o.state.doc);if(!m.length)return null;let l=le(o.state,m),e=ee(m,l.lo,l.hi);return e.length?e.length===1&&qe(o.state.doc,e[0])?v(e[0]):h(e,{quote:We(o.state,m,l)}):null},targetAt(o,m){let l=r();if(!l)return null;let e=l.posAtCoords({left:o,top:m});if(!e)return null;let f=z(l.state.doc);if(!f.length)return null;let u=e.inside>=0?e.inside:e.pos,g=f.findIndex(y=>y.node.type===N.nodes.tool&&y.end===u),d=g>=0?g:Math.min(Math.max(l.state.doc.resolve(u).index(0),0),f.length-1),{lo:p,hi:b}=Y(f,d,d),w=ee(f,p,b);return w.length?w.length===1&&qe(l.state.doc,w[0])?v(w[0]):h(w):null},between(o,m){let l=r();if(!l)return null;let e=z(l.state.doc),f=[...o?.ref??[],...m?.ref??[]].map(p=>e.findIndex(b=>b.node.attrs.id===p)).filter(p=>p>=0);if(!f.length)return null;let{lo:u,hi:g}=Y(e,Math.min(...f),Math.max(...f)),d=ee(e,u,g);return d.length?h(d):null},wholePage(){let o=r(),m=o?z(o.state.doc).map(l=>l.node.attrs.id).filter(Boolean):[];return h(m,{label:"This page"})},newTool(o){return a.newTool(o??null)},reviseTool(o){return a.reviseTool(o)}}}export{Tt as createPageAi};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{$ as Xt,A as V,U as Ut,V as ut,W as Ft,Z as Wt,_ as Gt,a as L,b as et,d as T,da as ft,e as nt,h as Rt,k as qt,ka as Qt,m as ct,q as _t,r as Kt,s as Ht,t as jt,v as ot,y as lt,z as dt}from"./c-OH2FPYSY.js";import{a as O,b as D,d as $,e as Z,f as Vt,g as tt}from"./c-RETTCOWO.js";var be=e=>e==="left"||e==="right"?e:null,{Plugin:wt,PluginKey:ke,TextSelection:I,NodeSelection:Yt,Selection:st}=D,M=T.nodes,S=e=>e.type===M.list_item,A=e=>e.type===M.toggle,k=e=>e.attrs.parent??null,Et="blockeditor-step",q="blockeditor-move",Mt=e=>e&&(n=>e(Z.closeHistory(n).setMeta(Et,!0)));function y(e,n=null){let t=[],o=new Map,r=[];e.forEach((s,i)=>{let a=t.length,l=t[a-1],c=k(s),d=c!==null&&o.has(c)?o.get(c):-1,f=d;if(S(s)){for(l&&S(l.node)&&k(l.node)===c||(r=[]);r.length&&t[r[r.length-1]].node.attrs.indent>=s.attrs.indent;)r.pop();r.length&&(f=r[r.length-1]),r.push(a)}else r=[];let p=A(s)&&(s.attrs.open||!!n?.has(s.attrs.id)),u=d>=0&&(t[d].hidden||!t[d].open);t.push({node:s,at:i,end:i+s.nodeSize,i:a,up:f,depth:d>=0?t[d].depth+1:0,hidden:u,open:p,subEnd:a}),A(s)&&s.attrs.id&&o.set(s.attrs.id,a)});for(let s=t.length-1;s>=0;s--){let i=t[s].up;i>=0&&t[s].subEnd>t[i].subEnd&&(t[i].subEnd=t[s].subEnd)}return t}var Jn=(e,n)=>({from:e[n].at,to:e[e[n].subEnd].end});function xe(e,n=null){let t=new Map;n?.forEach(c=>{c.attrs.id&&t.set(c.attrs.id,k(c))}),e.forEach(c=>{c.attrs.id&&t.set(c.attrs.id,k(c))});let o=[];e.forEach((c,d)=>o.push({node:c,at:d}));let r=new Array(o.length).fill(null);for(let c=o.length-2;c>=0;c--){let d=k(o[c+1].node);r[c]=d!==k(o[c].node)?d:r[c+1]}let s=[],i=[null],a=null,l=[];return o.forEach(({node:c,at:d},f)=>{let p=k(c),u=new Set;for(;p!==null&&!i.includes(p)&&!u.has(p);)u.add(p),p=t.has(p)?t.get(p):null;i.includes(p)||(p=null);let h=r[f];i.indexOf(h)>i.indexOf(p)&&(p=h);let m=i.slice(0,i.indexOf(p)+1),g=c.attrs.indent;if(S(c)){let E=Number.isInteger(g)&&g>0?g:0,b=a&&S(a.node)&&a.parent===p;for(b||(l=[]);l.length&&l[l.length-1].orig>E;)l.pop();let N=0;if(l.length){let C=l[l.length-1];N=C.shift,C.orig===E&&l.pop()}g=Math.max(0,Math.min(E-N,b?a.indent+1:0)),l.push({orig:E,shift:E-g})}else l=[];(p!==k(c)||S(c)&&g!==c.attrs.indent)&&s.push({at:d,attrs:{...c.attrs,parent:p,...S(c)?{indent:g}:{}}}),a={node:c,parent:p,indent:g},i=A(c)&&c.attrs.id?[...m,c.attrs.id]:m}),s}function Zn(){let e=new WeakSet;return new wt({appendTransaction(n,t,o){if(!n.some(i=>i.docChanged&&!i.getMeta(ot)))return null;if(e.has(t.doc)&&je(t.doc,o.doc))return e.add(o.doc),null;let r=xe(o.doc,t.doc);if(!r.length)return e.add(o.doc),null;let s=o.tr;for(let i of r)s.setNodeMarkup(i.at,null,i.attrs);return s}})}function it(e,n,t){let o=e.resolve(n.from).index(0),r=Math.min(e.resolve(n.to).index(0),t.length-1);return r>o&&n.to<=t[r].at&&r--,[Math.min(o,t.length-1),r]}var ne=it;function z(e,n,t){let o=n;for(;e[o].up>=0&&t>e[e[o].up].subEnd;)o=e[o].up;let r=e[o].up,s=e[o].subEnd;for(;s<t;)s=e[s+1].subEnd;return{lo:o,hi:s,up:r}}var ye=(e,n,t)=>{let o=e.resolve(Math.max(0,Math.min(n,e.content.size)));return o.depth===0?o.pos:t<0?o.before(1):o.after(1)},Jt=e=>({id:e.node.attrs.id,at:e.at,node:e.node}),bt=(e,n)=>n.id?e.node.attrs.id===n.id:e.at===n.at&&e.node.type===n.node.type&&e.node.content.eq(n.node.content);function Ae(e,n,t){let o=[];for(let r=n;r<=t;r=e[r].subEnd+1)o.push(Jt(e[r]));return{roots:o,members:e.slice(n,t+1).map(Jt)}}function Se(e,n){let t=n.roots.map(i=>e.findIndex(a=>bt(a,i))).filter(i=>i>=0);if(!t.length||t.some(i=>e[i].hidden))return null;let o=t[0],r=e[o].up,s=e[o].subEnd;for(let i of t.slice(1)){if(i!==s+1||e[i].up!==r)return null;s=e[i].subEnd}return e.slice(o,s+1).some(i=>!n.members.some(a=>bt(i,a)))?null:{lo:o,hi:s}}var we=(e,n)=>{let t=o=>({...o,at:n.map(o.at,1)});return{roots:e.roots.map(t),members:e.members.map(t)}},x=class e extends st{map(n,t){return this.getBookmark().map(t).resolve(n)}eq(n){return n instanceof e&&n.anchor===this.anchor&&n.head===this.head}toJSON(){return{type:"blockeditor-block",anchor:this.anchor,head:this.head}}static fromJSON(n,t){return new e(n.resolve(t.anchor),n.resolve(t.head))}getBookmark(){let{lo:n,hi:t}=this.span();return new kt(this.anchor,this.head,Ae(y(this.$from.doc),n,t))}span(n=this.$from.doc){return{lo:n.resolve(this.from).index(0),hi:n.resolve(this.to).index(0)-1}}};x.prototype.visible=!1;st.jsonID("blockeditor-block",x);var kt=class e{constructor(n,t,o){this.anchor=n,this.head=t,this.span=o}map(n){let t=this.anchor<=this.head;return new e(n.map(this.anchor,t?1:-1),n.map(this.head,t?-1:1),we(this.span,n))}resolve(n){let t=y(n),o=Se(t,this.span);if(!o){let i=t.find(a=>bt(a,this.span.roots[0]));return st.near(n.resolve(i?.at??ye(n,Math.min(this.anchor,this.head),-1)))}let r=t[o.lo].at,s=t[o.hi].end;return this.anchor<=this.head?new x(n.resolve(r),n.resolve(s)):new x(n.resolve(s),n.resolve(r))}},oe=(e,n)=>{for(let t=n-1;t>=0;t--)if(e[t].up===e[n].up)return t;return-1};function G(e,n,t,o,r=()=>null){let s=r(e[n])||{},i="parent"in s?s.parent:k(e[n].node),a=null;for(let d=0;d<e.length&&e[d].end<=o;d++)d>=n&&d<=t||k(e[d].node)===i&&(a=e[d].node.attrs.id);let l=[],c={};for(let d=n;d<=t;d++){let f=e[d].node,p=r(e[d]);l.push(f.attrs.id),p&&"indent"in p&&p.indent!==f.attrs.indent&&(c[f.attrs.id]={indent:p.indent})}return{ids:l,afterId:a,parent:i,attrs:c}}function re(e,n,t,o,r,s=()=>null,i=e.selection){let a=n[t].at,l=n[o].end,c=l-a,d=[];for(let h=t;h<=o;h++){let m=n[h].node;d.push(m.type.create({...m.attrs,...s(n[h])||{},pos:null},m.content,m.marks))}let f=e.tr.delete(a,l),p=r>a?r-c:r;f.insert(p,d);let u=p-a;return i instanceof x?f.setSelection(new x(f.doc.resolve(i.anchor+u),f.doc.resolve(i.head+u))):i instanceof Yt?f.setSelection(Yt.create(f.doc,i.from+u)):f.setSelection(I.create(f.doc,i.anchor+u,i.head+u)),f.setMeta(q,G(n,t,o,r,s))}function xt(e,n,t){let o=e[t].node;if(A(o)){let s=o.attrs.id,i=k(o);return a=>k(a.node)===s?{parent:i}:null}let r=o.attrs.indent-e[n].node.attrs.indent;return s=>S(s.node)?{indent:s.node.attrs.indent+r}:null}var Zt=e=>(n,t)=>{t=Mt(t);let o=y(n.doc);if(!o.length)return!1;let[r,s]=it(n.doc,n.selection,o),{lo:i,hi:a,up:l}=z(o,r,s),c,d=()=>null;if(e<0){let f=oe(o,i);if(f>=0)c=o[f].at;else if(l>=0)c=o[l].at,d=xt(o,i,l);else return!0}else{let f=a+1;if(f<o.length&&o[f].up===l)c=o[o[f].subEnd].end;else if(l>=0)c=o[o[l].subEnd].end,d=xt(o,i,l);else return!0}return t&&t(re(n,o,i,a,c,d).scrollIntoView()),!0},Ee=8,rt=(e,n)=>S(e.node)&&S(n.node)&&k(e.node)===k(n.node);function Me(e,n){n=Mt(n);let t=y(e.doc);if(!t.length)return!1;let[o,r]=it(e.doc,e.selection,t),s=t[o];if(S(s.node)&&o>0&&rt(t[o-1],s)){if(s.node.attrs.indent>t[o-1].node.attrs.indent)return!0;for(let a=o;a<=Math.max(r,s.subEnd);a++)if(t[a].node.attrs.indent>=Ee)return!0;if(n){let a=e.tr,l=r;for(let d=o;d<=l;d++)l=Math.max(l,t[d].subEnd);let c=o-1;for(let d=o;d<=l&&rt(t[d],s);d++)a.setNodeMarkup(t[d].at,null,{...t[d].node.attrs,indent:t[d].node.attrs.indent+1}),c=d;a.setMeta(q,G(t,o,c,t[o].at,d=>d.i>=o&&d.i<=c?{indent:d.node.attrs.indent+1}:null)),n(a)}return!0}let i=oe(t,o);if(i<0||!A(t[i].node)||t[i].subEnd!==o-1)return!0;if(n){let{hi:a}=z(t,o,r),l=e.tr,c=k(s.node),d=t[i].node.attrs.id,f=[];for(let u=o;u<=a;u++)k(t[u].node)===c&&(l.setNodeMarkup(t[u].at,null,{...t[u].node.attrs,parent:d}),f.push(t[u].node.attrs.id));t[i].node.attrs.open||l.setNodeMarkup(t[i].at,null,{...t[i].node.attrs,open:!0});let p=G(t,o,a,t[o].at,u=>u.i>=o&&u.i<=a&&k(u.node)===c?{parent:d}:null);l.setMeta(q,{...p,ids:f,attrs:t[i].node.attrs.open?p.attrs:{...p.attrs,[d]:{open:!0}}}),n(l)}return!0}function vt(e,n){n=Mt(n);let t=y(e.doc);if(!t.length)return!1;let[o,r]=it(e.doc,e.selection,t),s=t[o];if(S(s.node)&&s.node.attrs.indent>0){if(n){let{lo:d,hi:f}=z(t,o,r),p=e.tr,u=new Set;for(let h=o;h<=r;){let m=t[h];if(S(m.node)&&m.node.attrs.indent>0)for(let g=h;g<=m.subEnd;g++)S(t[g].node)&&(p.setNodeMarkup(t[g].at,null,{...t[g].node.attrs,indent:t[g].node.attrs.indent-1}),u.add(g));h=m.subEnd+1}p.setMeta(q,G(t,d,f,t[d].at,h=>u.has(h.i)?{indent:h.node.attrs.indent-1}:null)),n(p)}return!0}if(k(s.node)===null)return!0;let{lo:a,hi:l}=z(t,o,r),c=t[a].up;for(;c>=0&&!A(t[c].node);)c=t[c].up;if(c<0)return!0;if(n){let d=xt(t,a,c),f=t[c].subEnd;if(l===f){let p=e.tr;for(let u=a;u<=l;u++){let h=d(t[u]);h&&p.setNodeMarkup(t[u].at,null,{...t[u].node.attrs,...h})}p.setMeta(q,G(t,a,l,t[a].at,d)),n(p)}else n(re(e,t,a,l,t[f].end,d).scrollIntoView())}return!0}function se(e){let n=e.tr;return e.selection.empty||n.deleteSelection(),n}function ve(e,n){let{$from:t,$to:o,empty:r}=e.selection;if(t.depth!==1||!S(t.parent)||!t.sameParent(o))return!1;if(r&&t.parent.content.size===0){let h=t.parent;return h.attrs.indent>0?vt(e,n):(n&&n(e.tr.setNodeMarkup(t.before(),M.paragraph,{id:h.attrs.id,pos:h.attrs.pos,parent:h.attrs.parent})),!0)}let s=se(e),i=s.selection.$from,a=i.parent,l=y(s.doc),c=i.index(0),d=i.parentOffset===0,f=i.parentOffset===a.content.size,p=l[c+1],u=f&&p&&rt(p,l[c])&&p.node.attrs.indent>a.attrs.indent;return d?(s.split(i.pos,1,[{type:M.list_item,attrs:a.attrs}]),s.setNodeMarkup(l[c].at,null,{...a.attrs,checked:!1})):s.split(i.pos,1,[{type:M.list_item,attrs:{...a.attrs,checked:!1,indent:a.attrs.indent+(u?1:0)}}]),n&&n(s.scrollIntoView()),!0}function Te(e,n){let{$from:t,$to:o}=e.selection;if(t.depth!==1||!A(t.parent)||!t.sameParent(o))return!1;let r=se(e),s=r.selection.$from,i=s.parent,a=y(r.doc),l=s.index(0),c=a[l],d=c.subEnd>l;if(i.content.size===0&&!d)return r.setNodeMarkup(c.at,M.paragraph,{id:i.attrs.id,pos:i.attrs.pos,parent:i.attrs.parent}),n&&n(r),!0;if(s.parentOffset===0&&i.content.size>0)return r.insert(c.at,M.paragraph.create({parent:k(i)})),n&&n(r.scrollIntoView()),!0;let f=i.content.cut(s.parentOffset);if(i.attrs.open)r.split(s.pos,1,[{type:M.paragraph,attrs:{parent:i.attrs.id}}]);else{let p=a[c.subEnd].end,u=r.steps.length;r.delete(s.pos,c.end-1);let h=r.mapping.slice(u).map(p);r.insert(h,M.toggle.create({parent:k(i),open:!1},f)),r.setSelection(I.create(r.doc,h+1))}return n&&n(r.scrollIntoView()),!0}function Ne(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||t.parent.type!==M.paragraph||t.parent.content.size)return!1;let r=k(t.parent);if(r===null)return!1;let s=y(e.doc),i=t.index(0),a=s.findIndex(l=>l.node.attrs.id===r);if(a<0||s[a].subEnd!==i)return!1;if(n){let l=s[i].node.attrs.id,c=k(s[a].node),d=i>0?s[i-1].node:null,f=e.tr.setNodeMarkup(s[i].at,null,{...t.parent.attrs,parent:c});f.setMeta(q,{ids:[l],afterId:d?d.attrs.id:null,parent:k(d??s[i].node),attrs:{[l]:{parent:c}}}),n(f)}return!0}function Ie(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!t.parent.isTextblock||t.parent.type.spec.code)return!1;let r=t.parent;if(S(r)||A(r)||k(r)===null||t.parentOffset!==r.content.size)return!1;if(n){let s=e.tr.split(t.pos,1,[{type:M.paragraph,attrs:{parent:k(r)}}]);n(s.scrollIntoView())}return!0}function Ce(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!S(t.parent)||t.parentOffset!==0)return!1;if(t.parent.attrs.indent>0)return vt(e,n);let r=t.parent;return n&&n(e.tr.setNodeMarkup(t.before(),M.paragraph,{id:r.attrs.id,pos:r.attrs.pos,parent:r.attrs.parent})),!0}function Oe(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!A(t.parent)||t.parentOffset!==0)return!1;let r=t.parent;return n&&n(e.tr.setNodeMarkup(t.before(),M.paragraph,{id:r.attrs.id,pos:r.attrs.pos,parent:r.attrs.parent})),!0}function Tt(e,n){if(n<=0||!e[n-1].hidden)return-1;let t=n-1;for(;t>=0&&e[t].hidden;)t--;return t>=0&&A(e[t].node)&&e[t].subEnd>=n-1?t:-1}function Nt(e,n,t,o){let r=e.tr,s=n[o],i=n[t].end-1;return r.delete(s.at,s.end),s.node.content.size&&r.insert(i,s.node.content),r.setSelection(I.create(r.doc,i))}function De(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||t.parentOffset!==0||!t.parent.isTextblock)return!1;let r=y(e.doc),s=t.index(0),i=Tt(r,s);return i<0?!1:(n&&n(Nt(e,r,i,s).scrollIntoView()),!0)}function $e(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!A(t.parent)||t.parent.attrs.open||t.parentOffset!==t.parent.content.size)return!1;let r=y(e.doc),s=t.index(0),i=r[s].subEnd+1;return i===s+1?!1:(i>=r.length||!r[i].node.isTextblock||n&&n(Nt(e,r,s,i).scrollIntoView()),!0)}function Le(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1)return!1;let r=t.parent,s=t.index(0);if(!r.isTextblock||r.type.spec.code||A(r)||!r.content.size||t.parentOffset!==r.content.size||s+1>=e.doc.childCount||!A(e.doc.child(s+1)))return!1;if(n&&r.type!==M.paragraph)n(e.tr.setSelection(I.create(e.doc,t.after()+1)).scrollIntoView());else if(n){let i=t.before(),a=e.tr.insert(t.after()+1,r.content).delete(i,t.after());n(a.setSelection(I.create(a.doc,i+1+r.content.size)).scrollIntoView())}return!0}var ie=e=>(n,t)=>{let{$from:o,empty:r}=n.selection;if(!r||o.depth!==1||!o.parent.isTextblock)return!1;let s=o.parent,i=o.index(0);if(o.parentOffset!==(e<0?0:s.content.size))return!1;let a=y(n.doc),l=e<0?Tt(a,i):-1,c=l>=0?l:i+e;if(c<0||c>=a.length)return!1;let d=a[c].node;if(!d.isTextblock||!s.type.spec.code&&!d.type.spec.code)return!1;if(!t)return!0;let f=n.tr,p=a[i],u=a[c],h=e<0?u.end-1:u.at+1;return!s.content.size&&!s.type.spec.code?f.delete(p.at,p.end).setSelection(I.create(f.doc,f.mapping.map(h))):!d.content.size&&!d.type.spec.code?f.delete(u.at,u.end):f.setSelection(I.create(f.doc,h)),t(f.scrollIntoView()),!0},Be=ie(-1),Pe=ie(1);function ze(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||t.parentOffset!==0||!t.parent.isTextblock)return!1;let r=t.parent;if(S(r)||A(r)||k(r)===null)return!1;let s=t.index(0);return e.doc.child(s-1).attrs.id!==k(r)?!1:(n&&n(Nt(e,y(e.doc),s-1,s).scrollIntoView()),!0)}var It="blockeditor-reveal";function to(e,n){return n.length?e.setMeta(It,{add:n}):e}function ae(e,n,t,o=y(e.doc)){let r=o[n];return e.tr.setNodeMarkup(r.at,null,{...r.node.attrs,open:t}).setMeta("addToHistory",!1).setMeta(It,{clear:[r.node.attrs.id]})}function Ve(e,n){let{$from:t}=e.selection;return t.depth!==1||!A(t.parent)?!1:(n&&n(ae(e,t.index(0),!t.parent.attrs.open)),!0)}function Re(e){let n=[];for(let t of e)!A(t.node)||t.hidden||t.open||t.subEnd===t.i||n.push({line:t.at+1,sumEnd:t.end-1,from:t.end,to:e[t.subEnd].end});return n}var yt=(e,n)=>n>e.from&&n<e.to;function At(e,n,t,o){if(o>0){let r=t.to;for(;;){let s=st.findFrom(e.resolve(r),1,!0);if(!s)break;let i=n.find(a=>yt(a,s.head));if(!i)return s.head;r=i.to}}return t.sumEnd}function te(e,n,t,o=-1,r=!1){if(!t.length)return null;let{anchor:s,head:i}=n;if(!(n instanceof I)){let c=t.find(d=>n.from>=d.from&&n.from<d.to);return c?I.create(e,c.sumEnd):null}let a=t.find(c=>yt(c,i));a&&(i=At(e,t,a,o));let l=t.find(c=>yt(c,s));if(l&&(s=l.sumEnd),!r&&s!==i){let c=Math.min(s,i),d=Math.max(s,i),f=t.find(p=>(c>p.line||c===p.sumEnd)&&c<p.from&&d>=p.to);if(f){let p=c===f.sumEnd?At(e,t,f,1):f.line;s<i?s=p:i=p}}return s===n.anchor&&i===n.head?null:I.create(e,s,i)}var qe=e=>{let n="";for(;e>0;)e--,n=String.fromCharCode(97+e%26)+n,e=Math.floor(e/26);return n},_e=e=>[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]].reduce((n,[t,o])=>{for(;e>=t;)n+=o,e-=t;return n},"");function Ke(e){let n=new Map,t=[];return e.forEach((o,r)=>{if(!S(o.node)){t=[];return}r>0&&!rt(e[r-1],o)&&(t=[]);let s=o.node.attrs.indent;if(t.length=s+1,o.node.attrs.kind!=="ordered"){t[s]=0;return}t[s]=(t[s]||0)+1;let i=t[s];n.set(r,`${s%3===0?i:s%3===1?qe(i):_e(i)}.`)}),n}var F=new ke("blockeditor-collapse"),He=["id","parent","indent","kind","open"];function je(e,n){if(e.childCount!==n.childCount)return!1;for(let t=0;t<e.childCount;t++){let o=e.child(t),r=n.child(t);if(o!==r){if(o.type!==r.type)return!1;for(let s of He)if(o.attrs[s]!==r.attrs[s])return!1}}return!0}var Ue=new Set;function pt(e,n=Ue){let t=y(e,n);return{decos:Ge(e,t),ranges:Re(t),reveal:n}}var Fe=null,We=()=>Fe??=class extends $.DecorationSet{forChild(e,n){if(n.isLeaf)return $.DecorationSet.empty;let t=this.children,o=0,r=t.length/3;for(;o<r;){let s=o+r>>1;t[s*3]<e?o=s+1:r=s}return o*3<t.length&&t[o*3]===e?t[o*3+2]:$.DecorationSet.empty}};function Ge(e,n=y(e)){let{Decoration:t,DecorationSet:o}=$,r=Ke(n),s=[],i=[];for(let a of n){let l={};if(a.hidden&&(l.class="blockeditor-hidden",l["aria-hidden"]="true"),a.depth&&(l.style=`--blockeditor-depth:${a.depth}`),r.has(a.i)&&(l["data-marker"]=r.get(a.i)),A(a.node)&&(l["data-expanded"]=a.open?"true":"false"),Object.keys(l).length&&s.push(t.node(a.at,a.end,l)),A(a.node)&&!a.hidden){let c=t.widget(0,()=>Xe(a.node,a.open),{side:-1,ignoreSelection:!0,key:`t:${a.node.attrs.id}:${a.open}`});i.push(a.at,a.end,new o([c],[]))}}return!s.length&&!i.length?o.empty:new(We())(s,i)}function Xe(e,n=e.attrs.open){let t=document.createElement("button");return t.type="button",t.className="blockeditor-toggle-button",t.contentEditable="false",t.setAttribute("aria-label",n?"Collapse":"Expand"),t.setAttribute("aria-expanded",n?"true":"false"),t.setAttribute("data-toggle",e.attrs.id||""),t}function eo(){let e=!1;return new wt({key:F,state:{init:(n,t)=>pt(t.doc),apply(n,t,o,r){let s=n.getMeta(It);if(s){let i=new Set(t.reveal);for(let a of s.add??[])i.add(a);for(let a of s.clear??[])i.delete(a);return pt(r.doc,i)}return n.docChanged?pt(r.doc,t.reveal):t}},appendTransaction(n,t,o){if(!n.some(a=>a.docChanged||a.selectionSet))return null;let s=n.some(a=>a.selectionSet)&&o.selection.head>=t.selection.head?1:-1,i=te(o.doc,o.selection,F.getState(o).ranges,s,e);return i?o.tr.setSelection(i):null},props:{decorations:n=>F.getState(n).decos,handleDOMEvents:{mousedown:(n,t)=>{let o=t.target.closest?.(".blockeditor-toggle-button");if(o){t.preventDefault();let i=y(n.state.doc),a=i.findIndex(l=>l.node.attrs.id===o.dataset.toggle);return a>=0&&n.dispatch(ae(n.state,a,!i[a].node.attrs.open,i)),!0}e=!0;let r=n.dom.ownerDocument.defaultView,s=()=>{e=!1,r.removeEventListener("mouseup",s,!0);let i=te(n.state.doc,n.state.selection,F.getState(n.state).ranges,1,!1);i&&n.dispatch(n.state.tr.setSelection(i))};return r.addEventListener("mouseup",s,!0),!1}},handleKeyDown(n,t){let o={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1}[t.key];if(!o||t.altKey||t.metaKey||t.ctrlKey)return!1;let{head:r}=n.state.selection,i=t.key==="ArrowDown"||t.key==="ArrowUp"?o>0?"down":"up":o>0?"forward":"backward";if(!n.endOfTextblock(i))return!1;let a=y(n.state.doc),{ranges:l}=F.getState(n.state),d=n.state.doc.resolve(r).index(0),f=null;if(o>0){let u=l.find(h=>h.from===a[d].end);u&&(f=At(n.state.doc,l,u,1))}else{let u=Tt(a,d);u>=0&&(f=t.shiftKey?a[u].at+1:a[u].end-1)}if(f===null||f===r)return!1;let p=t.shiftKey?n.state.selection.anchor:f;return n.dispatch(n.state.tr.setSelection(I.create(n.state.doc,p,f)).scrollIntoView()),!0}}})}var ee=/^([ \t]*)(?:([-*+•])|(\d+)[.)])[ \t]+(?:\[([ xX])\][ \t]+)?(.*)$/;function Qe(e){let n=e.replace(/\r\n?/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`);if(!n.some(r=>ee.test(r)))return null;let t=[],o=[];for(let r of n){if(!r.trim())continue;let s=ee.exec(r);if(!s){t.length=0,o.push(M.paragraph.create(null,r.trim()?T.text(r.trim()):null));continue}let i=s[1].replace(/\t/g," ").length;for(;t.length&&t[t.length-1]>i;)t.pop();(!t.length||t[t.length-1]<i)&&t.push(i);let a=Math.min(t.length-1,o.length&&S(o[o.length-1])?o[o.length-1].attrs.indent+1:0),l=s[4]!==void 0?"check":s[3]!==void 0?"ordered":"bullet";o.push(M.list_item.create({kind:l,indent:a,checked:s[4]==="x"||s[4]==="X"},s[5]?T.text(s[5]):null))}return new O.Slice(O.Fragment.from(o),0,0)}var ht=new Set(["UL","OL"]),mt=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE","BLOCKQUOTE","UL","OL","LI","DETAILS","SUMMARY","TABLE","HR","FIGURE"]);function Ye(e){let n=e.querySelector(":scope > input[type=checkbox], :scope > p > input[type=checkbox], :scope > label > input[type=checkbox]");if(n)return{check:!0,checked:n.checked||n.hasAttribute("checked")};if(e.getAttribute("role")==="checkbox"||e.hasAttribute("aria-checked"))return{check:!0,checked:e.getAttribute("aria-checked")==="true"};if(e.hasAttribute("data-checked"))return{check:!0,checked:e.getAttribute("data-checked")==="true"};let o=e.className||"";return/\b(checked|task-list-item|to-do)\b/.test(o)||e.closest?.("ul.to-do-list, ul.contains-task-list")?{check:!0,checked:/\bchecked\b/.test(o)||!!e.querySelector(".checkbox-on")}:{check:!1,checked:!1}}function Je(e){let n=(e.getAttribute("style")||"")+";"+(e.parentElement?.getAttribute("style")||""),t=/list-style-type\s*:\s*([a-z-]+)/i.exec(e.getAttribute("style")||"")?.[1];return t?/decimal|alpha|roman|latin|greek/.test(t)?"ordered":"bullet":e.parentElement?.tagName==="OL"?"ordered":"bullet"}function Ze(e,n=globalThis.document){let t=n.createElement("div");t.innerHTML=e;for(let u of t.querySelectorAll('b[style*="font-weight:normal"], b[style*="font-weight: normal"]'))u.replaceWith(...u.childNodes);let o=0,r=n.createElement("div"),s=u=>{let h=parseInt(u.getAttribute("aria-level"),10);if(h>0)return h-1;let m=-1;for(let g=u.parentElement;g&&g!==t;g=g.parentElement)ht.has(g.tagName)&&m++;return Math.max(0,m)},i=[];function a(u,h,m){let g=n.createElement("div"),{check:E,checked:b}=Ye(u);g.setAttribute("data-blockeditor-li",""),g.setAttribute("data-kind",E?"check":Je(u)),g.setAttribute("data-checked",b?"true":"false"),g.dataset.depth=String(s(u)),h&&g.setAttribute("data-blockeditor-parent",h);let N=!0,C=[];for(let w of[...u.childNodes]){if(w.nodeType===1&&ht.has(w.tagName)){C.push(w);continue}if(!(w.nodeType===1&&w.tagName==="INPUT")){if(w.nodeType===1&&mt.has(w.tagName)){N||g.appendChild(n.createElement("br"));for(let P of[...w.childNodes])P.nodeType===1&&P.tagName==="INPUT"||g.appendChild(P);N=!1;continue}g.appendChild(w),(w.nodeType!==3||w.textContent.trim())&&(N=!1)}}m.appendChild(g),i.push(g);for(let w of C)l(w,h,m)}function l(u,h,m){let g=null,E=b=>{g||(g=n.createElement("p"),h&&g.setAttribute("data-blockeditor-parent",h),m.appendChild(g)),g.appendChild(b)};for(let b of[...u.childNodes])if(!(b.nodeType===1&&(b.tagName==="META"||b.tagName==="STYLE"))){if(b.nodeType===1&&b.tagName==="BR"){g=null;continue}if(b.nodeType!==1){b.nodeType===3&&(g||b.textContent.trim())&&E(b);continue}if(!mt.has(b.tagName)&&b.tagName!=="ASIDE"){E(b);continue}if(g=null,ht.has(b.tagName)){l(b,h,m);continue}if(b.tagName==="LI"){a(b,h,m);continue}if(b.tagName==="DETAILS"){let N=`paste-${++o}`,C=b.querySelector(":scope > summary"),w=n.createElement("div");w.setAttribute("data-blockeditor-toggle",N),b.hasAttribute("open")&&w.setAttribute("data-open","true"),h&&w.setAttribute("data-blockeditor-parent",h);let P=C?.querySelector(":scope > h1, :scope > h2, :scope > h3");P?(w.setAttribute("data-level",P.tagName[1]),w.append(...P.childNodes)):C&&w.append(...C.childNodes),m.appendChild(w);for(let Pt of[...b.childNodes])if(Pt!==C){let zt=n.createElement("div");zt.appendChild(Pt),l(zt,N,m)}continue}if(b.tagName==="DIV"&&!b.hasAttribute("data-blockeditor-li")&&[...b.children].some(N=>mt.has(N.tagName))){l(b,h,m);continue}h&&b.setAttribute("data-blockeditor-parent",h),m.appendChild(b)}}l(t,null,r);let c=i.length?Math.min(...i.map(u=>+u.dataset.depth)):0,d=null;for(let u of i){let h=+u.dataset.depth-c,m=d&&u.previousElementSibling===d?+d.getAttribute("data-indent")+1:0;u.setAttribute("data-indent",String(Math.min(h,m))),u.removeAttribute("data-depth"),d=u}let f=u=>{if(u.nodeType!==1||u.tagName==="IMG")return[u.cloneNode(!0)];let h=[],m=u.cloneNode(!1);for(let g of u.childNodes)for(let E of f(g))E.nodeType===1&&E.tagName==="IMG"?(m.hasChildNodes()&&h.push(m),h.push(E),m=u.cloneNode(!1)):m.appendChild(E);return(m.hasChildNodes()||!h.length)&&h.push(m),h};for(let u of[...r.children]){if(!u.matches("p, h1, h2, h3, h4, h5, h6, aside, div[data-blockeditor-li], div.blockeditor-li")||!u.querySelector("img"))continue;let h=f(u),m=u.getAttribute("data-blockeditor-parent");if(m)for(let g of h)g.setAttribute("data-blockeditor-parent",m);u.replaceWith(...h)}let p=t.querySelector("[data-pm-slice]");return p&&r.firstElementChild?.setAttribute("data-pm-slice",p.dataset.pmSlice),r.innerHTML}var gt=(e,n=0)=>e!==null&&e!==""&&Number.isInteger(+e)&&+e>=n?+e:null,v=e=>e.getAttribute("data-blockeditor-parent")||null,tn=Rt([]).type,en=Object.create(T,{marks:{value:{...T.marks,[nt]:tn}}}),ce=e=>{let n;try{n=Qt(e)}catch{return null}return!n||typeof n.t!="string"||n.t==="opaque_block"||Object.hasOwn(Ft,n.t)?null:n},nn=e=>{let n=ce(e);return n?{raw:n,parent:v(e)}:!1},on=e=>{let n=ce(e);if(!n||typeof n.c!="string"||!n.c)return O.Fragment.empty;let t=Ht(n.m,n.c.length);return O.Fragment.from(jt(T,n.c,t,T.nodes.opaque_block))},rn=e=>{try{return{entries:Wt(e.getAttribute(ut))}}catch{return!1}},X=null,sn=()=>import("./c-SE3SIY7Y.js").then(e=>{X=e},()=>{}),an=new O.DOMParser(en,[{tag:"table",node:"table",getAttrs:e=>X?.table(e)??!1,getContent:e=>X.rows(e)},{tag:`div[${Ut}]`,node:"opaque_block",getAttrs:nn,getContent:on},{tag:`span[${ut}]`,mark:nt,getAttrs:rn},{tag:"div[data-blockeditor-li]",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div.blockeditor-li",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div[data-blockeditor-toggle]",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-blockeditor-toggle"),open:e.getAttribute("data-open")==="true",parent:v(e),level:ft(Number(e.getAttribute("data-level")))})},{tag:"div.blockeditor-toggle",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-id"),open:e.getAttribute("data-open")==="true",parent:null,level:ft(Number(e.getAttribute("data-level")))})},{tag:"h1",node:"heading",getAttrs:e=>({level:1,parent:v(e)})},{tag:"h2",node:"heading",getAttrs:e=>({level:2,parent:v(e)})},{tag:"h3",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"h4",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"pre",node:"code_block",preserveWhitespace:"full",getAttrs:e=>({lang:e.getAttribute("data-lang")||"",parent:v(e)})},{tag:"hr",node:"divider",getAttrs:e=>({parent:v(e)})},{tag:"aside.blockeditor-callout",node:"callout",getAttrs:e=>({parent:v(e)})},{tag:'figure:not([data-type]), figure[data-type="image"]',node:"image",getAttrs:e=>{let n=e.querySelector("img"),t=et(n?.getAttribute("src"));return t?{src:t,alt:n.getAttribute("alt")||"",caption:e.querySelector("figcaption")?.textContent||"",width:gt(e.getAttribute("data-width")??n.getAttribute("width"),1),align:be(e.getAttribute("data-align")),parent:v(e)}:!1}},{tag:"img[src]",node:"image",getAttrs:e=>{let n=et(e.getAttribute("src"));return n?{src:n,alt:e.getAttribute("alt")||"",width:gt(e.getAttribute("width"),1),parent:v(e)}:!1}},{tag:'div.blockeditor-file, div[data-type="file"]',node:"file",getAttrs:e=>{let n=L(e.getAttribute("data-src"));return n?{src:n,name:e.getAttribute("data-name")||"file",size:gt(e.getAttribute("data-size")),mime:e.getAttribute("data-mime")||null,parent:v(e)}:!1}},{tag:"p",node:"paragraph",getAttrs:e=>({parent:v(e)})},{tag:"br",node:"hard_break"},{tag:"strong",mark:"strong"},{tag:"b",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(normal|[1-5]00)\b/.test(e.getAttribute("style")||"")?!1:null},{tag:"span",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(bold|[6-9]00)\b/.test(e.getAttribute("style")||"")?null:!1},{tag:"em",mark:"em"},{tag:"i",mark:"em"},{tag:"span",mark:"em",getAttrs:e=>/font-style\s*:\s*italic/.test(e.getAttribute("style")||"")?null:!1},{tag:"s",mark:"strike"},{tag:"del",mark:"strike"},{tag:"code",mark:"code"},{tag:"a[href]",mark:"link",getAttrs:e=>{let n=L(e.getAttribute("href"));return n?{href:n}:!1}},{tag:"blockquote",node:"quote",getAttrs:e=>({parent:v(e)})},{tag:"u",mark:"underline"},{tag:"mark",mark:"highlight",getAttrs:e=>ct("highlight",{color:e.getAttribute("data-color")})??!1},{tag:"span[data-color]",mark:"text_color",getAttrs:e=>ct("text_color",{color:e.getAttribute("data-color")})??!1}]);function cn(e,n){let t=n.selection.$from,o=n.selection instanceof x,r=o?n.doc.child(n.selection.span().lo):t.depth>=1?t.node(1):null,s=r?k(r):null,i=r&&S(r)?r.attrs.indent:0,a=new Map;e.content.forEach(m=>{A(m)&&m.attrs.id&&a.set(m.attrs.id,V())});let l=[];e.content.forEach(m=>{if(!m.type.spec.group?.includes("block")){l.push(m);return}let g=k(m),E={...m.attrs,pos:null,id:A(m)?a.get(m.attrs.id)??null:null,parent:g!==null&&a.has(g)?a.get(g):s};S(m)&&(E.indent=m.attrs.indent+i),l.push(m.type.create(E,m.content,m.marks))});let c=!r||!(S(r)||A(r)),d=m=>m&&(S(m)||A(m)),f=c&&d(l[0])?0:e.openStart,p=l[l.length-1],u=new Set(a.values()),h=c&&(d(p)||p&&u.has(k(p)))?0:e.openEnd;return new O.Slice(O.Fragment.from(l),o?0:f,o?0:h)}var St=class extends O.DOMSerializer{serializeFragment(n,t,o){let r=super.serializeFragment(n,t,o);if(!n.firstChild?.isBlock)return r;let s=[...r.childNodes];return n.forEach((i,a,l)=>{let c=s[l];!c||c.nodeType!==1||(k(i)!==null&&c.setAttribute("data-blockeditor-parent",k(i)),A(i)&&i.attrs.id&&c.setAttribute("data-blockeditor-toggle",i.attrs.id),i.type===M.image&&i.attrs.width&&c.setAttribute("data-width",String(i.attrs.width)))}),X?.copy(n,s),r}},le=O.DOMSerializer.fromSchema(T),ln=e=>{let{t:n,...t}=e.attrs.raw??{},{c:o,m:r}=_t(e.content);return o?{t:n,...t,c:o,...r.some(Boolean)?{m:Kt(r)}:{}}:{t:n,...t}},dn=e=>["div",{"data-type":"newer-format",...Gt(ln(e))},0],un=e=>["span",Xt(e.attrs.entries),0],fn={...le.nodes,opaque_block:dn},pn={...le.marks,[nt]:un},hn=new St(fn,pn);function mn(e,n,t){let{$from:o}=e.state.selection,r=o.depth>=1?o.node(1):null;if(!r||!A(r)||r.attrs.open||t.content.childCount<2)return!1;let s=e.state.tr.setNodeMarkup(o.before(1),null,{...r.attrs,open:!0}).replaceSelection(t);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gn(e){let n=!1;return e?.content?.descendants(t=>n?!1:((t.type===M.quote||t.isText&&t.marks.some(o=>qt.has(o.type.name)))&&(n=!0),!n)),n}function bn(e,n,t){let o=e.state.selection.from,r=e.state.selection.to,s=e.state.doc,i=()=>{let a=t.content.textBetween(0,t.content.size,`
|
|
4
|
+
`," ");return!e.isDestroyed&&a&&e.state.doc===s&&e.dispatch(e.state.tr.insertText(a,o,r)),!1};return import("./c-ZFO5RW6G.js").then(({pasteFormats:a})=>a(e,t,o,r),i),!0}function no(){return new wt({view(){return sn(),{}},props:{handlePaste(e,n,t){return gn(t)?bn(e,n,t):mn(e,n,t)},clipboardSerializer:hn,clipboardTextSerializer:e=>X?.text(e),transformPastedHTML:e=>Ze(e),clipboardParser:an,clipboardTextParser:(e,n,t)=>t?null:Qe(e),transformPasted:(e,n)=>cn(e,n.state)}})}var W=tt.chainCommands(Ce,Oe,Be,ze,De),R=tt.chainCommands($e,Le,Pe),oo={Enter:tt.chainCommands(ve,Te,Ne,Ie),Backspace:W,"Shift-Backspace":W,"Mod-Backspace":W,"Alt-Backspace":W,"Ctrl-h":W,Delete:R,"Shift-Delete":R,"Mod-Delete":R,"Alt-Delete":R,"Ctrl-d":R,"Ctrl-Alt-Backspace":R,Tab:Me,"Shift-Tab":vt,"Mod-Shift-ArrowUp":Zt(-1),"Mod-Shift-ArrowDown":Zt(1),"Mod-Enter":Ve};function ao(){return new D.Plugin({view(e){let n=e.dom.ownerDocument.createElement("div");return n.className="blockeditor-live",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),e.dom.parentElement.appendChild(n),{destroy:()=>n.remove()}}})}function Ct(e,n){let t=e.dom.parentElement?.querySelector(".blockeditor-live");t&&(t.textContent="",t.textContent=n)}var de=new D.PluginKey("tableRect");var{Selection:kn,TextSelection:K,NodeSelection:xn,Plugin:yn,PluginKey:An}=D,Q=T.nodes,H=e=>Z.closeHistory(e).setMeta(Et,!0);function Y(e,n,t=n,o=y(e)){let{lo:r,hi:s}=z(o,Math.min(n,t),Math.max(n,t)),i=o[r].at,a=o[s].end;return n<=t?new x(e.resolve(i),e.resolve(a)):new x(e.resolve(a),e.resolve(i))}function Sn(e,n=y(e.doc)){let[t,o]=ne(e.doc,e.selection,n);return z(n,t,o)}var _=(e,n,t)=>{for(let o=n;o>=0&&o<e.length;o+=t)if(!e[o].hidden)return o;return-1};function wn(e,n){if(e.selection instanceof x)return!1;let t=Math.min(e.selection.$head.index(0),e.doc.childCount-1);return n&&n(e.tr.setSelection(Y(e.doc,t))),!0}var ue=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:i}=o.span(n.doc),a=e<0?_(r,s-1,-1):_(r,i+1,1);return a<0||t&&t(n.tr.setSelection(Y(n.doc,a)).scrollIntoView()),!0};function Dt(e,n,t,o){if(o<0)return n;let r=n;for(;e[r].subEnd<t;)r=e[r].subEnd+1;return r}function En(e,n){for(let t=n-1;t>=0;t--)if(e[t].up===e[n].up)return t;return n}var fe=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:i}=o.span(n.doc),a=o.anchor<=o.head,l=a?s:Dt(r,s,i,1),c=a?Dt(r,s,i,1):s;return e>0?a||s===i||c===l?c=_(r,(a?i:c)+1,1):c=_(r,r[c].subEnd+1,1):!a||c===l?c=_(r,(a?c:s)-1,-1):c=En(r,c),c<0||t&&t(n.tr.setSelection(Y(n.doc,l,c,r)).scrollIntoView()),!0};function at(e,n){let t=e.selection;if(!(t instanceof x))return!1;if(n){let o=e.tr.delete(t.from,t.to);o.doc.content.size===0&&o.insert(0,Q.paragraph.create()),o.setSelection(kn.near(o.doc.resolve(Math.min(t.from,o.doc.content.size)),-1)),n(H(o).scrollIntoView())}return!0}function Mn({columns:e={},cards:n={}}){let t=dt(e),o=new Map(t.map(i=>[i,V("c")])),r=lt(null,null,t.length),s={};for(let i of new Set([...t,...Object.values(n).map(a=>a.col)])){let a=dt(Object.fromEntries(Object.entries(n).filter(([,c])=>c.col===i))),l=lt(null,null,a.length);a.forEach((c,d)=>{s[V("k")]={...n[c],col:o.get(i)??i,pos:l[d]}})}return{columns:Object.fromEntries(t.map((i,a)=>[o.get(i),{...e[i],pos:r[a]}])),cards:s}}function vn(e,n){let t=y(e.doc);if(!t.length)return!1;let{lo:o,hi:r}=Sn(e,t);if(n){let s=new Map;for(let f=o;f<=r;f++)t[f].node.type===Q.toggle&&t[f].node.attrs.id&&s.set(t[f].node.attrs.id,V());let i=[];for(let f=o;f<=r;f++){let p=t[f].node,u=p.attrs.parent??null;i.push(p.type.create({...p.attrs,...p.type===Q.board?Mn(p.attrs):{},id:s.get(p.attrs.id)??null,pos:null,parent:s.get(u)??u},p.content,p.marks))}let a=t[r].end,l=a-t[o].at,c=e.tr.insert(a,i),d=e.selection;c.setSelection(d instanceof x?new x(c.doc.resolve(a),c.doc.resolve(a+l)):K.create(c.doc,d.anchor+l,d.head+l)),n(H(c).scrollIntoView())}return!0}var he=(e,n,t,o)=>{for(let r=t;r<=o;r++)if(n[r].node.isTextblock)return n[r].end-1;return-1};function pe(e,n){let t=e.selection;if(!(t instanceof x))return!1;let o=y(e.doc),{lo:r,hi:s}=t.span(e.doc);if(n){let i=he(e.doc,o,r,s);n(e.tr.setSelection(i>=0?K.create(e.doc,i):xn.create(e.doc,o[r].at)))}return!0}var Tn=({$from:e,$to:n})=>{if(e.depth<2||n.depth<2)return null;let t=e.node(1);return t.type.name==="table"&&n.node(1)===t?{from:e.before(1),to:e.after(1)}:null};function Nn(e,n){let t=e.selection,{$from:o,$to:r}=t,s=o.parent.isTextblock&&o.sameParent(r)&&!de.getState(e),i=s&&o.parentOffset===0&&r.parentOffset===r.parent.content.size;if(s&&!i&&o.parent.content.size)return n&&n(e.tr.setSelection(K.create(e.doc,o.start(),o.end()))),!0;let a=Tn(t);return a&&!(t instanceof x&&t.from===a.from&&t.to===a.to)?(n&&n(e.tr.setSelection(new x(e.doc.resolve(a.from),e.doc.resolve(a.to)))),!0):(n&&n(e.tr.setSelection(new x(e.doc.resolve(0),e.doc.resolve(e.doc.content.size)))),!0)}var In=(e,n)=>{let t=e.state,o=t.selection;if(!(o instanceof x))return!1;let r=y(t.doc),{lo:s,hi:i}=o.span(t.doc),a=he(t.doc,r,s,i),l=t.tr;if(a<0){let c=r[i].end;l.insert(c,Q.paragraph.create({parent:r[s].node.attrs.parent??null})),l.setSelection(K.create(l.doc,c+1)),H(l)}else l.setSelection(K.create(l.doc,a));return l.insertText(n),e.dispatch(l.scrollIntoView()),!0},Cn=(e,n,t)=>{let o=e.selection;if(!(o instanceof K)||!t?.endOfTextblock("down"))return!1;let{$anchor:r,$head:s}=o;if(r.depth!==1||r.parent.type!==Q.toggle||r.parent.attrs.open||r.index(0)!==s.index(0))return!1;let i=y(e.doc),a=r.index(0),l=_(i,i[a].subEnd+1,1);return l<0?!1:(n&&n(e.tr.setSelection(Y(e.doc,a,l,i)).scrollIntoView()),!0)},On=e=>(n,t,o)=>n.selection instanceof x&&e(n,t,o),Dn={Escape:(e,n)=>pe(e,n)||wn(e,n),Enter:On(pe),ArrowUp:ue(-1),ArrowDown:ue(1),"Shift-ArrowUp":fe(-1),"Shift-ArrowDown":(e,n,t)=>fe(1)(e,n)||Cn(e,n,t),Backspace:at,"Alt-Backspace":at,"Ctrl-h":at,Delete:at,"Mod-d":vn,"Mod-a":Nn},Ot=new An("blockeditor-blocksel"),$n=e=>{let n=e.selection,{lo:t,hi:o}=n.span(e.doc);return y(e.doc).filter(r=>r.i>=t&&r.i<=o&&!r.hidden).length};function ko(){let e=Vt.keymap(Dn);return new yn({key:Ot,state:{init:()=>0,apply:(n,t,o,r)=>n.getMeta(ot)&&o.selection instanceof x&&!(r.selection instanceof x)?t+1:t},props:{handleKeyDown:(n,t)=>e.props.handleKeyDown(n,t),handleTextInput:(n,t,o,r)=>In(n,r),decorations(n){let t=n.selection;if(!(t instanceof x))return null;let o=[];return n.doc.nodesBetween(t.from,t.to,(r,s)=>(o.push($.Decoration.node(s,s+r.nodeSize,{class:"blockeditor-block-selected"})),!1)),$.DecorationSet.create(n.doc,o)},createSelectionBetween(n,t,o){let r=n.state.selection;return r instanceof x&&t.pos===r.anchor&&o.pos===r.head?r:null},handleDOMEvents:{mousedown(n,t){let o=n.state.selection;if(!t.shiftKey||!(o instanceof x)||t.button!==0)return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});if(!r)return!1;let s=y(n.state.doc),i=Math.min(n.state.doc.resolve(r.inside>=0?r.inside:r.pos).index(0),s.length-1),{lo:a,hi:l}=o.span(n.state.doc),c=o.anchor<=o.head?a:Dt(s,a,l,1);return t.preventDefault(),n.dispatch(n.state.tr.setSelection(Y(n.state.doc,c,i,s))),!0}}},view:()=>({update(n,t){let o=n.state.selection,r=t.selection;if(o instanceof x&&!o.eq(r)){let s=$n(n.state);Ct(n,`${s} ${s===1?"block":"blocks"} selected`)}else r instanceof x&&!(o instanceof x)&&Ct(n,Ot.getState(n.state)!==Ot.getState(t)?"Block selection cleared because the document changed":"Selection cleared")}})})}var{Plugin:Ln,PluginKey:Bn,TextSelection:J}=D,{Decoration:Pn,DecorationSet:zn}=$,U=T.marks.link,Vn=e=>/^(https?:\/\/|mailto:|tel:|www\.)\S+$/i.test(e.trim())&&L(e)!==null;function $t(e,n){let t=e.resolve(n);if(!t.parent.inlineContent)return null;let o=U.isInSet((t.nodeAfter??t.nodeBefore)?.marks??[]);if(!o)return null;let r=[];t.parent.forEach((c,d)=>r.push({n:c,off:d}));let s=r.findIndex(({n:c,off:d})=>d<=t.parentOffset&&t.parentOffset<=d+c.nodeSize&&o.isInSet(c.marks));if(s<0)return null;let i=s,a=s;for(;i>0&&o.isInSet(r[i-1].n.marks);)i--;for(;a<r.length-1&&o.isInSet(r[a+1].n.marks);)a++;let l=t.start();return{from:l+r[i].off,to:l+r[a].off+r[a].n.nodeSize,href:o.attrs.href}}function me(e,n,t,o){let r=e.tr.removeMark(n,t,U);return o&&r.addMark(n,t,U.create({href:o})),H(r)}var B=new Bn("blockeditor-link"),Lt=new WeakMap,ge=e=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`,Rn=ge('<path d="M9 3h4v4M13 3 7.5 8.5M11 9.5V13H3V5h3.5"/>'),qn=ge('<path d="M4 4l8 8M12 4l-8 8"/>');function j(e,n,t,o={}){let r=e.createElement(n);t&&(r.className=t);for(let[s,i]of Object.entries(o))r.setAttribute(s,i);return r}function _n(e,n,t){let o=null;return e.doc.nodesBetween(n,t,r=>{let s=U.isInSet(r.marks);s&&(o=s.attrs.href)}),o}var Bt=class{constructor(n){this.view=n,this.shell=n.dom.parentElement,this.doc=n.dom.ownerDocument,this.mode=null,this.range=null;let t=this.doc;this.dom=j(t,"div","blockeditor-link",{role:"dialog","aria-label":"Link",hidden:""}),this.input=j(t,"input","blockeditor-link-input",{type:"url","aria-label":"Link address",placeholder:"Paste or type a link",autocomplete:"off",spellcheck:"false"}),this.url=j(t,"a","blockeditor-link-url",{target:"_blank",rel:"noopener noreferrer"}),this.open=j(t,"a","blockeditor-link-btn",{"data-act":"open",target:"_blank",rel:"noopener noreferrer","aria-label":"Open link in a new tab",title:"Open in a new tab"}),this.open.innerHTML=Rn,this.edit=j(t,"button","blockeditor-link-btn",{type:"button","data-act":"edit"}),this.edit.textContent="Edit",this.remove=j(t,"button","blockeditor-link-btn",{type:"button","data-act":"remove","aria-label":"Remove link",title:"Remove link"}),this.remove.innerHTML=qn,this.dom.append(this.input,this.url,this.open,this.edit,this.remove),this.shell.append(this.dom),Lt.set(n,this),this.dom.addEventListener("mousedown",o=>{o.target!==this.input&&o.preventDefault()}),this.edit.addEventListener("click",()=>this.openEdit()),this.remove.addEventListener("click",()=>this.apply("")),this.input.addEventListener("keydown",o=>{o.isComposing||o.keyCode===229||(o.key==="Enter"?(o.preventDefault(),this.apply(this.input.value)):o.key==="Escape"&&(o.preventDefault(),this.close()))}),this.onDocDown=o=>{this.mode==="edit"&&!this.dom.contains(o.target)&&this.close(!1)},this.doc.addEventListener("mousedown",this.onDocDown,!0)}openEdit(){let n=this.view.state,t=n.selection;if(!(t instanceof J)||!t.$from.sameParent(t.$to)||!t.$from.parent.inlineContent||t.$from.parent.type.spec.code)return!1;let o=t.empty?$t(n.doc,t.head):null;return this.range=o??{from:t.from,to:t.to,href:t.empty?null:_n(n,t.from,t.to)},this.mode="edit",this.view.dispatch(n.tr.setMeta(B,{from:this.range.from,to:this.range.to})),this.render(),this.input.value=this.range.href??"",this.input.removeAttribute("aria-invalid"),this.input.focus(),this.input.select(),!0}apply(n){let t=String(n).trim(),o=t?L(t):null;if(t&&!o){this.input.setAttribute("aria-invalid","true");return}let r=this.view.state,s=B.getState(r)??(this.mode==="view"?this.range:null);if(!s)return this.close();let i;if(s.from===s.to){if(!o)return this.close();i=r.tr.insert(s.from,T.text(t,[U.create({href:o})])),i.setSelection(J.create(i.doc,s.from+t.length))}else i=me(r,s.from,s.to,o),i.setSelection(J.create(i.doc,s.to));this.view.dispatch(H(i).setMeta(B,null)),this.close()}close(n=!0){this.mode=null,this.range=null,B.getState(this.view.state)&&this.view.dispatch(this.view.state.tr.setMeta(B,null)),this.dom.hidden=!0,this.dom.dataset.mode="",n&&this.view.focus(),this.update(this.view)}render(){let n=this.mode==="edit",t=L(this.range?.href);this.dom.dataset.mode=this.mode??"",this.input.hidden=!n,this.url.hidden=n,this.edit.hidden=n,this.open.hidden=!t,this.remove.hidden=!this.range?.href,t?(this.open.href=t,this.url.href=t,this.url.textContent=t.replace(/^https?:\/\//,"")):(this.open.removeAttribute("href"),this.url.removeAttribute("href"),this.url.textContent=""),this.dom.hidden=!1,this.place()}place(){let n=this.range;if(!n)return;let t=this.shell.getBoundingClientRect(),o=this.view.coordsAtPos(n.from),r=this.view.coordsAtPos(n.to,-1);this.dom.style.setProperty("--blockeditor-pop-x",`${Math.min(o.left,r.left)-t.left}px`),this.dom.style.setProperty("--blockeditor-pop-y",`${Math.max(o.bottom,r.bottom)-t.top+6}px`)}update(n){if(this.view=n,this.mode==="edit"){let r=B.getState(n.state);if(r)return this.range={...this.range,...r},this.place();this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}let t=n.state.selection,o=t instanceof J&&t.empty&&n.hasFocus()?$t(n.state.doc,t.head):null;if(!o||t.head===o.from||t.head===o.to){this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}this.mode="view",this.range=o,this.render()}destroy(){this.doc.removeEventListener("mousedown",this.onDocDown,!0),this.dom.remove(),Lt.delete(this.view)}},Kn=e=>Lt.get(e)?.openEdit()??!1;function Hn(e,n){if(n.clipboardData?.files?.length)return!1;let t=n.clipboardData?.getData("text/plain")??"";if(!Vn(t))return!1;let o=e.state.selection;if(!(o instanceof J)||!o.$from.sameParent(o.$to)||o.$from.parent.type.spec.code)return!1;let r=L(t),s=o.empty?e.state.tr.replaceSelectionWith(T.text(t.trim(),[U.create({href:r})]),!1):me(e.state,o.from,o.to,r);return e.dispatch(s.scrollIntoView().setMeta("uiEvent","paste")),!0}function Eo(){return new Ln({key:B,state:{init:()=>null,apply(e,n){let t=e.getMeta(B);if(t!==void 0)return t;if(!n||!e.docChanged)return n;let o=e.mapping.mapResult(n.from,1),r=e.mapping.mapResult(n.to,n.from===n.to?1:-1);return o.deletedAcross||r.deletedAcross||n.from!==n.to&&o.pos>=r.pos?null:{from:o.pos,to:r.pos}}},view:e=>new Bt(e),props:{decorations(e){let n=B.getState(e);return n&&n.from<n.to?zn.create(e.doc,[Pn.inline(n.from,n.to,{class:"blockeditor-link-pending"})]):null},handleKeyDown(e,n){return(n.metaKey||n.ctrlKey)&&!n.altKey&&!n.shiftKey&&n.key.toLowerCase()==="k"?(n.preventDefault(),Kn(e)||!0):!1},handlePaste:Hn,handleClick(e,n,t){if(!(t.metaKey||t.ctrlKey))return!1;let o=$t(e.state.doc,n),r=L(o?.href);return r?(e.dom.ownerDocument.defaultView.open(r,"_blank","noopener,noreferrer"),!0):!1}}})}export{Kn as a,Eo as b,ao as c,Ct as d,de as e,Et as f,q as g,y as h,Jn as i,xe as j,Zn as k,ne as l,z as m,Ae as n,Se as o,x as p,G as q,re as r,Zt as s,Ee as t,Me as u,vt as v,to as w,eo as x,an as y,hn as z,no as A,oo as B,H as C,Y as D,Sn as E,at as F,vn as G,In as H,ko as I};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as b,b as C,c as O,d as L,e as R,f as A,g as S,h as T,i as I}from"../c-
|
|
1
|
+
import{a as b,b as C,c as O,d as L,e as R,f as A,g as S,h as T,i as I}from"../c-CJ7QYEWI.js";import{a as l,b as u,c,d as f}from"../c-MQYEDF3Q.js";import{a as d,b as E,c as m,d as p}from"../c-JQF2EUCG.js";import"../c-TWCXBWS3.js";import"../c-VKEDWYDF.js";import{a}from"../c-LA2BW7UY.js";import"../c-IJUK2GPW.js";import{f as s}from"../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";var N=[d,R,A,b,l].join(", "),x=[E,S,C,u],o=null,n=null,i=!1,D=t=>{let e=t.parentNode||t;for(let q of x)q(e)};function r(){i=!0,!n&&(n=a.onAddElement({selectorFilter:N,require:"observed",pausable:!1,debounce:0},t=>{i&&t.forEach(({element:e})=>D(e))}))}function k(){i=!1,n&&(n(),n=null)}function h(){return o||(p(),I(),L(),f(),o={selector:N},s&&r(),o)}h();function w(t=document){return{enable(){for(let e of x)e(t);r()},quiesce(){i=!1},resume(){i=!0},dispose(){k(),m(),T(),O(),c()}}}function y(){return{id:"clay:controls",order:110,prepare(t={}){let e=w();return t.initial!==!0?e:{enable:()=>r(),quiesce:()=>e.quiesce(),resume:()=>e.resume(),dispose:()=>e.dispose()}}}}var F=h;export{w as controlsLease,F as default,h as init,h as install,y as modeParticipant};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{R as e,h as i}from"../c-HTLYXCUH.js";import"../c-4ASQPRQL.js";import"../c-GQ6F6IDK.js";import"../c-I2SCCUEW.js";import{a as p}from"../c-5VYOWDTI.js";import"../c-6Q6RGFBF.js";import"../c-SKMIR5HQ.js";import{a as f,b as m}from"../c-WYFDLITL.js";import"../c-UGHH4MB3.js";import{a as d}from"../c-LA2BW7UY.js";import"../c-MFOSMAVM.js";import"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-6IJEVE6B.js";import"../c-QQFHEODI.js";import{c}from"../c-IJUK2GPW.js";import{f as a}from"../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{s as n,v as o}from"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";function y(){d.onAnyChange({debounce:0,omitChangeDetails:!0,require:"autosave"},()=>{i()&&e.noteActivity()})}function A(){document.addEventListener("input",t=>{t.target.closest(f)&&(t.isTrusted&&!o(n(t.target),"dirty")&&c(),i()&&e.noteActivity())},!0)}function g(){let t=v=>{if(!e.pending())return;let r=v.target;if(!r||typeof r.closest!="function")return;let s=r.closest("input, textarea, select, [contenteditable]");s&&(o(n(s),"dirty")||i()&&e.noteActivity())};document.addEventListener("input",t,!0),document.addEventListener("compositionupdate",t,!0)}var l=!1;function u(){l||document.documentElement.matches(m)&&a&&(l=!0,p(!0),y(),A(),g())}u();var C=u;function L(){return{id:"clay:autosave",order:20,prepare(t={}){return t.initial===!0?{enable(){},quiesce(){},resume(){},dispose(){}}:{enable:u,quiesce(){},resume(){},dispose(){}}}}}export{C as default,u as init,L as modeParticipant};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as m}from"../c-VKEDWYDF.js";import{r as h}from"../c-HTLYXCUH.js";import"../c-4ASQPRQL.js";import"../c-GQ6F6IDK.js";import"../c-I2SCCUEW.js";import"../c-5VYOWDTI.js";import"../c-6Q6RGFBF.js";import"../c-SKMIR5HQ.js";import"../c-WYFDLITL.js";import"../c-UGHH4MB3.js";import"../c-LA2BW7UY.js";import"../c-MFOSMAVM.js";import"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-6IJEVE6B.js";import{d as g}from"../c-QQFHEODI.js";import"../c-IJUK2GPW.js";import{f as p}from"../c-EDE45NM7.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import{b as f}from"../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";var s=()=>window.clay?.conflicts||null,o=!1,r=null,l=null;function e(t){o||(o=!0,v(),import("../c-42ZNV7LI.js").then(n=>{r=n,n.start(t)},n=>{console.error("clayjs: the conflict notice could not be downloaded; it will try again on the next conflict",n),o=!1,u()}))}function u(){l||=new AbortController;let{signal:t}=l;document.addEventListener("clay:sync-conflicts-changed",w,{signal:t}),document.addEventListener("clay:save-conflict",b,{signal:t}),document.addEventListener("clay:document-upgraded",k,{signal:t}),document.addEventListener("clay:undo-kept",x,{signal:t})}function v(){l?.abort(),l=null}function w(t){s()?.size&&e(t)}function b(t){e(t)}function k(t){e(t)}function x(t){t?.detail?.ok===!0&&e(t)}var C="conflicts",L="undo",y=t=>f.local.get(t)?.count>0;function D(){y(L)&&e(null),y(C)&&import("../c-OIDRZKAF.js").then(t=>{!o&&t.pendingConflicts()>0&&e(null)},()=>{})}function N(){let t=(s()?.list?.()??[]).filter(n=>!n.claimedBy).map(n=>n.id);return t.length?t:h()?["save"]:[]}var a=null,i=0;function E(){let t=++i;g().then(n=>{let c=n.extensions.includes("data-guard-v1")?n.document?.dataGuard?.href:null;return t!==i||typeof c!="string"||!c?null:import("../c-CVSWLX3X.js").then(d=>{t===i&&(a=d,d.start({href:c}))})}).catch(n=>{console.error("clayjs: the data-loss notice could not start; it will try again on the next open",n)})}function j(){i++,a?.stop(),a=null}function A(){return{id:"clay:conflict-notice",order:960,prepare(t={}){return{enable(){t.initial!==!0&&(!r&&!o&&u(),E())},quiesce(){let n=N();if(n.length)throw Object.assign(new Error("clay.conflict-notice: a conflict here is still unresolved"),{code:"conflict",pending:n})},resume(){},dispose(){v(),o=!1,r?.stop?.(),r=null,j()}}}}}m(()=>{p&&(s()?.size?e(null):(u(),D()),E())});export{A as conflictNoticeParticipant,A as modeParticipant};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"../c-U4NTUVDZ.js";import"../c-VHNSBD2M.js";export{a as DRAFT_ATTR,b as DRAFT_PLUGIN,e as draftEligible,d as draftSlot,k as draftStoreFailed,g as draftTransport,m as draftUnconfirmed,i as flushDraft,c as noteBootParams,h as setDraftFlush,j as setDraftStoreFailed,f as setDraftTransport,l as setDraftUnconfirmed};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,b as n,c as m,d as r}from"../c-
|
|
1
|
+
import{a as s,b as n,c as m,d as r}from"../c-QQFHEODI.js";import{d as l}from"../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";var e=null,u=0;async function p({fresh:f=!1}={}){let o=location.pathname,t=await r({fresh:f});if(location.pathname!==o||n(t)!==o&&(t=await r({fresh:!0}),location.pathname!==o||n(t)!==o))return e;let a=s(t);if(a==="failed"||a==="ok"&&!t.document)return e;let i=a==="ok"?t.document.writable:void 0,c=m(t);return c<u||(u=c,e=typeof i=="boolean"?i:null,l(e)),e}export{p as checkHostPermission};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,c as b,d as c,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}from"../c-
|
|
1
|
+
import{b as a,c as b,d as c,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}from"../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 canEdit,h as commitModeFacts,a as isDraftMode,e as isEditMode,g as isOwner,d as learnedHostWritable,f as mode,i as modeState,c as noteHostWritable,k as noteParticipantForget,l as peekModeParticipants,n as registerModeParticipant,o as siteVisibility,j as startsAtImport,m as takeModeParticipants};
|