@panphora/clayjs 1.17.0 → 1.18.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/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 +72474 -62090
- package/dist/m/attrs/{save-freeze-MYNVXREN.js → save-freeze-LWGF6XUN.js} +1 -1
- package/dist/m/c-2GRUM77Q.js +30 -0
- package/dist/m/c-2KIEGNC4.js +1 -0
- package/dist/m/{c-AMSNPOCX.js → c-2KL3BD52.js} +1 -1
- package/dist/m/c-2ZZBC45O.js +1 -0
- package/dist/m/c-372N6H3B.js +1 -0
- package/dist/m/{c-4WKFKEKF.js → c-3G2DGZUP.js} +1 -1
- package/dist/m/c-3LDGIBMN.js +1 -0
- package/dist/m/c-3O7OBDCM.js +1 -0
- package/dist/m/c-4ASQPRQL.js +1 -0
- package/dist/m/c-4TXNLX4K.js +6 -0
- package/dist/m/c-4YU3BR4D.js +6 -0
- package/dist/m/c-5734MF2P.js +1 -0
- package/dist/m/c-57XDY6HC.js +1 -0
- package/dist/m/{c-KAU6E43D.js → c-5B4YBZXC.js} +1 -1
- package/dist/m/c-5ONTYIUI.js +1 -0
- package/dist/m/c-5OOVFCJM.js +1 -0
- package/dist/m/{c-3XIRD4NU.js → c-5T6NZHNM.js} +1 -1
- package/dist/m/{c-74MGYWZF.js → c-5ZQV7KC4.js} +1 -1
- package/dist/m/{c-7OLLJPWP.js → c-6DB2OLRJ.js} +1 -1
- package/dist/m/c-6DNRCPNM.js +1 -0
- package/dist/m/c-6UGWFMQC.js +2 -0
- package/dist/m/c-7K4SCQB7.js +1 -0
- package/dist/m/c-7MG5RU63.js +1 -0
- package/dist/m/c-7PRJCA3E.js +1 -0
- package/dist/m/c-A6L3FMUS.js +1 -0
- package/dist/m/c-AMU3BPPR.js +4 -0
- package/dist/m/{c-Y5HBBIQ4.js → c-AMYEFA2E.js} +1 -1
- package/dist/m/c-AQYCG7QW.js +1 -0
- package/dist/m/c-ATKAOH23.js +1 -0
- package/dist/m/c-B5CS55WR.js +1 -0
- package/dist/m/c-B5UJQT7W.js +1 -0
- package/dist/m/c-B7J4K2AE.js +3 -0
- package/dist/m/c-BHZYSHW4.js +1 -0
- package/dist/m/{c-VHM5XQHK.js → c-BIJALSRD.js} +1 -1
- package/dist/m/c-BJ7YQ5QZ.js +1 -0
- package/dist/m/{c-KIPQJX4B.js → c-BRLCTNMC.js} +1 -1
- package/dist/m/{c-VE6ZMYMC.js → c-BUAYFEV5.js} +1 -1
- package/dist/m/c-C6IPRG34.js +1 -0
- package/dist/m/{c-KU3ZFADW.js → c-CAS3NND4.js} +1 -1
- package/dist/m/{c-PS5ARVWR.js → c-CCQ25GFY.js} +1 -1
- package/dist/m/c-CJFDLD43.js +1 -0
- package/dist/m/c-COPTL5WB.js +1 -0
- package/dist/m/c-D3E4WJ4M.js +166 -0
- package/dist/m/c-D5IKEKXW.js +7 -0
- package/dist/m/c-DHBRA6DL.js +1 -0
- package/dist/m/c-DKLS74XB.js +72 -0
- package/dist/m/c-DVYGFTSK.js +3 -0
- package/dist/m/c-E3ZXARWA.js +1 -0
- package/dist/m/c-EK63G3CG.js +1 -0
- package/dist/m/c-ERQSNR6K.js +13 -0
- package/dist/m/c-EVYAISP3.js +1 -0
- package/dist/m/c-EXKHPOVC.js +3 -0
- package/dist/m/{c-QJ4OM3G6.js → c-FWKHM4E7.js} +1 -1
- package/dist/m/{c-4Q2XTQ2N.js → c-GBKB5WDL.js} +1 -1
- package/dist/m/c-GNDL3TKB.js +1 -0
- package/dist/m/c-GRWMD6O5.js +1 -0
- package/dist/m/c-GRXHHFPO.js +1 -0
- package/dist/m/c-HG2C77BM.js +4 -0
- package/dist/m/c-HHGJBU4D.js +1 -0
- package/dist/m/c-HMV6P4RX.js +1 -0
- package/dist/m/c-HMYWIHFG.js +1 -0
- package/dist/m/c-HT2DKBV2.js +1 -0
- package/dist/m/c-I2SCCUEW.js +1 -0
- package/dist/m/{c-TJ6WOJL3.js → c-ICJYHABF.js} +2 -2
- package/dist/m/c-IMZCWYHR.js +7 -0
- package/dist/m/c-IVMD3FEM.js +1 -0
- package/dist/m/{c-WDC5GVKU.js → c-IVTRVENZ.js} +1 -1
- package/dist/m/c-JKZJIUIP.js +1 -0
- package/dist/m/{c-UDUUJPFZ.js → c-JNLX3RJB.js} +1 -1
- package/dist/m/c-K3ADYNLU.js +1 -0
- package/dist/m/c-KGHVFRR3.js +1 -0
- package/dist/m/{c-5QWQ7A5L.js → c-KJJPV77R.js} +1 -1
- package/dist/m/{c-CZUSOB7V.js → c-KNPDOMDY.js} +1 -1
- package/dist/m/{c-EZU56NQV.js → c-KP64LT2A.js} +2 -2
- package/dist/m/c-KQ7E3PYY.js +1 -0
- package/dist/m/c-L3F5ZLIV.js +1 -0
- package/dist/m/{c-3RUU4TPX.js → c-L42OLXWM.js} +3 -2
- package/dist/m/c-L5VFATT6.js +1 -0
- package/dist/m/c-L7JL5TL3.js +3 -0
- package/dist/m/c-LKSL4AUJ.js +1 -0
- package/dist/m/c-M6FNQCTQ.js +1 -0
- package/dist/m/c-MCOOHCSG.js +1 -0
- package/dist/m/c-MHI3GYKF.js +1 -0
- package/dist/m/c-MWXFLW4J.js +1 -0
- package/dist/m/{c-5RJFTLSF.js → c-NEL7HQW3.js} +1 -1
- package/dist/m/{c-DCXOXBF3.js → c-NQJRVJ56.js} +1 -1
- package/dist/m/c-NWX3MFT4.js +1 -0
- package/dist/m/{c-HPURYVZS.js → c-OJYM642Q.js} +1 -1
- package/dist/m/c-OKXI52N7.js +1 -0
- package/dist/m/{c-R3L7ZJGB.js → c-OPLUZR3A.js} +1 -1
- package/dist/m/{c-GSFIGKOP.js → c-OTMKN2OO.js} +1 -1
- package/dist/m/{c-6NC5I2TV.js → c-OYRZ7XG2.js} +1 -1
- package/dist/m/{c-EVCQ3BKA.js → c-P3OFYUMA.js} +1 -1
- package/dist/m/c-PLN76GF3.js +6 -0
- package/dist/m/c-PLP4JKFC.js +1 -0
- package/dist/m/c-Q26MME6N.js +1 -0
- package/dist/m/{c-S7H2DRCB.js → c-Q3XOWZEV.js} +1 -1
- package/dist/m/{c-FRLHSY7E.js → c-QIKT6SKM.js} +1 -1
- package/dist/m/c-QIXT3Q7C.js +28 -0
- package/dist/m/c-QO4HNGCQ.js +1 -0
- package/dist/m/{c-JU3NK25H.js → c-R27DWQKX.js} +1 -1
- package/dist/m/{c-RSMOODDU.js → c-R2XUODVY.js} +1 -1
- package/dist/m/{c-QNKREOL6.js → c-R7LBFMF5.js} +1 -1
- package/dist/m/c-RND3G2S2.js +1 -0
- package/dist/m/{c-Q622NS2Y.js → c-S2U6NJU4.js} +1 -1
- package/dist/m/c-SPZPGD3R.js +1 -0
- package/dist/m/c-SW4YEG2D.js +8 -0
- package/dist/m/c-T637T7SN.js +1 -0
- package/dist/m/c-TJAXGIRV.js +1 -0
- package/dist/m/{c-RYUXUUBX.js → c-TNEM3RNM.js} +1 -1
- package/dist/m/c-TTB5EK4S.js +32 -0
- package/dist/m/c-U7SHNWDH.js +1 -0
- package/dist/m/c-UDHIVLYH.js +20 -0
- package/dist/m/{c-BBVGTQG7.js → c-UGNV5MFB.js} +1 -1
- package/dist/m/{c-QICP2YR5.js → c-UORXLSD3.js} +1 -1
- package/dist/m/c-UPD33ZPE.js +1 -0
- package/dist/m/c-URSMSFCB.js +1 -0
- package/dist/m/c-UY4QX42B.js +1 -0
- package/dist/m/c-V44KWI2L.js +4 -0
- package/dist/m/c-VILENZTD.js +1 -0
- package/dist/m/{c-HDDEEL77.js → c-VJYEVRYK.js} +1 -1
- package/dist/m/{c-SMBZG5X4.js → c-VR2BJ4AN.js} +1 -1
- package/dist/m/c-W4JCVLAB.js +1 -0
- package/dist/m/c-W6DQSHXI.js +135 -0
- package/dist/m/c-WBGWGOM7.js +1 -0
- package/dist/m/{c-4L3BTFRK.js → c-WCXLG3MV.js} +1 -1
- package/dist/m/c-WGW764WX.js +1 -0
- package/dist/m/c-WMRJKQ2V.js +5 -0
- package/dist/m/c-WNTYKCDG.js +1 -0
- package/dist/m/c-WQWIRWO3.js +72 -0
- package/dist/m/c-X5LNHET5.js +1 -0
- package/dist/m/{c-I2ZATQCD.js → c-X5TSXZYJ.js} +2 -2
- package/dist/m/c-XGH4GS2T.js +1 -0
- package/dist/m/c-Y6F2FORL.js +1 -0
- package/dist/m/c-YBKHUAK7.js +10 -0
- package/dist/m/c-YBSS55KU.js +20 -0
- package/dist/m/c-YCLU4UNT.js +2 -0
- package/dist/m/c-YVZ2L7CE.js +1 -0
- package/dist/m/c-ZK4GIZH2.js +1 -0
- package/dist/m/c-ZRXJD4G6.js +1 -0
- package/dist/m/c-ZWBI4HYK.js +1 -0
- package/dist/m/core/{admin-attrs-QHOKPJ7W.js → admin-attrs-YY7T5FGU.js} +1 -1
- package/dist/m/core/autosave-S6OMNDCK.js +1 -0
- package/dist/m/core/conflict-notice-IWHMHH43.js +1 -0
- package/dist/m/core/{host-permission-FNXVEFNE.js → host-permission-6EVJGNPL.js} +1 -1
- package/dist/m/core/is-edit-mode-GCX6767E.js +1 -0
- package/dist/m/core/{persist-JFYRHMRJ.js → persist-UKXV5KLA.js} +1 -1
- package/dist/m/core/recovery-DRFZRJED.js +1 -0
- package/dist/m/core/save-LYY7K6U7.js +1 -0
- package/dist/m/core/save-core-MKRPSEEO.js +1 -0
- package/dist/m/core/snapshot-NU3YM6GR.js +1 -0
- package/dist/m/core/unsaved-warning-7QTKEN7Z.js +1 -0
- package/dist/m/internals/{index-PVXGPUDA.js → index-TGLQINN3.js} +1 -1
- package/dist/m/loader-3BBNZZGM.js +1 -0
- package/dist/m/manifest-26C55578.js +1 -0
- package/dist/m/manifest-edit-4396A009.js +1 -0
- package/dist/m/manifest.json +2111 -1573
- package/dist/m/page/{editor-NNJA4OKD.js → editor-6LRB3GE4.js} +123 -21
- package/dist/m/plugins/ai-edit-UTV7YO2I.js +6 -0
- package/dist/m/plugins/{cms-HP3LSTPN.js → cms-LRAOZHT7.js} +9 -9
- package/dist/m/plugins/{demo-RM5IR6AO.js → demo-OYO5GCAO.js} +1 -1
- package/dist/m/plugins/{derive-UAAA4V4S.js → derive-FRE5JJQE.js} +1 -1
- package/dist/m/plugins/indicator-4VDXWYTD.js +1 -0
- package/dist/m/plugins/live-AD4H6XSL.js +1 -0
- package/dist/m/plugins/menu-M5WW7DBF.js +1 -0
- package/dist/m/plugins/page-MD3T2ZX3.js +2 -0
- package/dist/m/plugins/page-view-PAWVZNFY.js +1 -0
- package/dist/m/plugins/{people-SGPJKANK.js → people-JCHVPF7P.js} +1 -1
- package/dist/m/plugins/quickcrop-BQ5YYFCH.js +26 -0
- package/dist/m/plugins/{richclay-NRQDSWX6.js → richclay-KLGETK77.js} +2 -2
- package/dist/m/plugins/sortable-4S6SQC3D.js +1 -0
- package/dist/m/plugins/source-TJXOIOYY.js +1 -0
- package/dist/m/plugins/undo-NLPGCJQY.js +1 -0
- package/dist/m/plugins/{unsent-HJFLQJ2O.js → unsent-OA4RGBUT.js} +1 -1
- package/dist/m/plugins/upgrade-HSUNDNJD.js +1 -0
- package/dist/m/plugins/{upload-WLYKK6TL.js → upload-NHGJXZK2.js} +1 -1
- package/dist/m/plugins/visitor-drafts-BW43DGY3.js +20 -0
- package/dist/m/plugins/visitor-drafts-owner-7ODQG7JX.js +1 -0
- package/dist/m/plugins/{wire-4N6GYAF6.js → wire-VBWXEXU2.js} +1 -1
- package/dist/m/reader-core-4W2KYEWQ.js +77 -0
- package/dist/m/route/route-62CHXL5B.js +1 -0
- package/dist/m/sync/live-sync-MO5DH33W.js +1 -0
- package/dist/m/ui/index-IVWN2QC4.js +1 -0
- package/dist/m/vendor/sap-core.vendor-RN4ZVY4X.js +6 -0
- package/dist/offline-manifest.json +1367 -930
- package/dist/page/themes/light-1.css +8 -7
- package/dist/server/core.cjs +1440 -288
- package/dist/server/offline-runtime.cjs +63 -63
- package/dist/server/offline-runtime.mjs +63 -63
- package/dist/server/page-compaction-worker.cjs +3710 -0
- package/dist/server/rooms.mjs +5 -0
- package/docs/guide.md +653 -101
- package/entries/sap.js +5 -5
- package/package.json +1 -1
- package/src/core/admin-contenteditable.js +5 -2
- package/src/core/admin-inputs.js +1 -0
- package/src/core/admin-onclick.js +2 -1
- package/src/core/conflict-notice-ui.js +4 -7
- package/src/core/download.js +2 -2
- package/src/core/host-meta.js +38 -0
- package/src/core/is-edit-mode.js +17 -1
- package/src/core/mode-key.js +125 -19
- package/src/core/mode-support.js +5 -0
- package/src/core/mode-transition.js +20 -6
- package/src/core/preserve-authored.js +4 -4
- package/src/core/recovery.js +121 -33
- package/src/core/save-accepted.js +33 -0
- package/src/core/save-core.js +106 -31
- package/src/core/save-job.js +108 -0
- package/src/core/save-prepare.js +53 -0
- package/src/core/save-size-notice.js +3 -1
- package/src/core/save-slices.js +15 -0
- package/src/core/save.js +557 -127
- package/src/core/serialize-steps.js +109 -0
- package/src/core/snapshot.js +170 -39
- package/src/core/source-map.js +83 -38
- package/src/core/stale-host-notice.js +1 -0
- package/src/core/upgrade-run.js +59 -8
- package/src/dom/active-element.js +5 -0
- package/src/lib/assets.js +1 -0
- package/src/lib/slice.js +65 -0
- package/src/lib/uimotion.js +774 -0
- package/src/lib/unsaved-state.js +2 -2
- package/src/live/fast-lane.js +10 -3
- package/src/live/local-lane.js +202 -11
- package/src/live/ops.js +16 -0
- package/src/live/page-compaction.js +162 -0
- package/src/live/server-lane.js +1 -0
- package/src/live/store.js +11 -3
- package/src/loader-logic.js +3 -1
- package/src/loader.js +14 -4
- package/src/page/adopt-boot.js +2 -1
- package/src/page/awareness.js +33 -2
- package/src/page/blocks.js +89 -27
- package/src/page/boot-pack.js +1 -1
- package/src/page/chart-tables.js +21 -3
- package/src/page/chart.js +406 -63
- package/src/page/checklist.js +10 -135
- package/src/page/checkpoint-proof.js +7 -1
- package/src/page/chrome.js +250 -51
- package/src/page/clipboard-shape.js +126 -0
- package/src/page/drag.js +33 -3
- package/src/page/editor.js +136 -25
- package/src/page/export-assets.js +357 -0
- package/src/page/export-html.js +209 -0
- package/src/page/export-markdown.js +361 -0
- package/src/page/features/checklist.js +428 -0
- package/src/page/features/export-html.js +189 -0
- package/src/page/features/export-markdown.js +169 -0
- package/src/page/features/import-markdown.js +349 -0
- package/src/page/features/media.js +61 -5
- package/src/page/features/registry.js +18 -0
- package/src/page/features/table.js +373 -83
- package/src/page/features/title-cover.js +331 -0
- package/src/page/features/title-icon.js +213 -0
- package/src/page/features/toc.js +87 -0
- package/src/page/format-command.js +25 -1
- package/src/page/format-gate.js +68 -18
- package/src/page/format-host.js +17 -0
- package/src/page/format-native-commands.js +21 -5
- package/src/page/image-actions.js +64 -0
- package/src/page/import-markdown.js +262 -0
- package/src/page/items.js +135 -17
- package/src/page/markdown.js +6 -2
- package/src/page/media.js +35 -119
- package/src/page/placeholder.js +14 -1
- package/src/page/projection.js +98 -10
- package/src/page/recover.js +10 -12
- package/src/page/recovery-ui.js +464 -0
- package/src/page/rich/chart.js +63 -7
- package/src/page/save-projection.js +28 -0
- package/src/page/save-states.js +13 -3
- package/src/page/schema.js +19 -3
- package/src/page/table-paste.js +3 -1
- package/src/page/table-style.js +4 -4
- package/src/page/table.js +44 -2
- package/src/page/themes/light-1.css +8 -7
- package/src/page/themes/light-1.source.css +8 -7
- package/src/page/toc-link.js +31 -0
- package/src/page/toc.js +5 -0
- package/src/page/view-hooks.js +38 -12
- package/src/page/view.js +13 -0
- package/src/page/ybind/binding.js +88 -5
- package/src/page/ybind/bridge.js +187 -20
- package/src/page/ybind/containment.js +162 -0
- package/src/page/ybind/doc.js +17 -9
- package/src/page/ybind/file-debt.js +63 -0
- package/src/page/ybind/layout.js +7 -2
- package/src/page/ybind/marks.js +1 -1
- package/src/page/ybind/moves.js +5 -4
- package/src/page/ybind/origins.js +106 -4
- package/src/page/ybind/parts.js +8 -1
- package/src/page/ybind/provider.js +113 -17
- package/src/page/ybind/recovery-proof.js +32 -9
- package/src/page/ybind/recovery-replay.js +558 -15
- package/src/page/ybind/recovery.js +174 -45
- package/src/page/ybind/table.js +67 -11
- package/src/page/ybind/walk-delta.js +258 -0
- package/src/page/ybind/walk.js +54 -29
- package/src/page/ybind/writer.js +1 -1
- package/src/plugins/ai-edit.js +13 -9
- package/src/plugins/indicator-chip.js +91 -0
- package/src/plugins/indicator.js +13 -80
- package/src/plugins/live.js +89 -14
- package/src/plugins/menu/actions.js +196 -0
- package/src/plugins/menu/people.js +279 -0
- package/src/plugins/menu/placement.js +121 -0
- package/src/plugins/menu/preferences.js +9 -0
- package/src/plugins/menu/seo.js +316 -397
- package/src/plugins/menu/style.js +171 -0
- package/src/plugins/menu/variants.js +296 -0
- package/src/plugins/menu.js +186 -183
- package/src/plugins/page-view.js +3 -2
- package/src/plugins/page.js +249 -44
- package/src/plugins/sortable.js +8 -1
- package/src/plugins/source.js +6 -0
- package/src/plugins/upgrade.js +51 -17
- package/src/plugins/upload-ui.js +12 -17
- package/src/plugins/visitor-drafts/bottom-ui.js +12 -4
- package/src/plugins/visitor-drafts/intro-style.js +7 -2
- package/src/plugins/visitor-drafts/intro.js +5 -3
- package/src/plugins/visitor-drafts/owner-chip.js +8 -12
- package/src/plugins/visitor-drafts/prompt.js +11 -9
- package/src/plugins/visitor-drafts/source.js +4 -3
- package/src/plugins/visitor-drafts/store.js +138 -9
- package/src/plugins/visitor-drafts/ui-memory.js +2 -2
- package/src/plugins/visitor-drafts-owner.js +4 -6
- package/src/plugins/visitor-drafts.js +5 -3
- package/src/recovery/store.js +1 -1
- package/src/route/route.js +4 -0
- package/src/server/rooms/index.js +5 -1
- package/src/server/rooms/live-data-rooms.js +302 -50
- package/src/server/rooms/page-compaction-worker.js +12 -0
- package/src/server/rooms/page-compactor.js +92 -0
- package/src/server/rooms/page-room-conformance.js +461 -0
- package/src/source/parse-steps.js +94 -0
- package/src/source/session.js +233 -57
- package/src/sync/editing-sender.js +12 -0
- package/src/sync/live-sync-edit.js +22 -2
- package/src/sync/live-sync.js +150 -23
- package/src/sync/page-relay.js +52 -0
- package/src/sync/presence-store.js +44 -4
- package/src/sync/presence.js +6 -3
- package/src/sync/saved-stream.js +11 -6
- package/src/ui/bevel-controls.js +1 -0
- package/src/ui/bevel-dialog.js +5 -2
- package/src/ui/editor-ui.js +77 -0
- package/src/ui/page-colour.js +281 -0
- package/src/ui/toast.js +16 -7
- package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
- package/src/vendor/hyper-undo.vendor.js +1 -1
- package/src/vendor/hypercms.vendor.js +9 -9
- package/src/vendor/parse5.vendor.js +2 -2
- package/src/vendor/sap-core.vendor.js +5 -5
- package/dist/m/c-2SPVQSHC.js +0 -1
- package/dist/m/c-336SGU5W.js +0 -1
- package/dist/m/c-3H6BZDNJ.js +0 -6
- package/dist/m/c-4DFEJ2PO.js +0 -3
- package/dist/m/c-56QRZTZH.js +0 -1
- package/dist/m/c-5J4E7O4Y.js +0 -4
- package/dist/m/c-5LKDWQTL.js +0 -19
- package/dist/m/c-5V3MOVJT.js +0 -1
- package/dist/m/c-6AZOGAPE.js +0 -1
- package/dist/m/c-6CRUUXOX.js +0 -5
- package/dist/m/c-6HMB24EV.js +0 -1
- package/dist/m/c-6KEVEQ7L.js +0 -1
- package/dist/m/c-A3E3NIMC.js +0 -1
- package/dist/m/c-BQ6LOBEE.js +0 -1
- package/dist/m/c-BTDI4Y23.js +0 -1
- package/dist/m/c-CJ3A7ZKE.js +0 -1
- package/dist/m/c-CQHPGKX2.js +0 -1
- package/dist/m/c-DFS4XZJV.js +0 -2
- package/dist/m/c-DNENWY4O.js +0 -1
- package/dist/m/c-E4LIR5X5.js +0 -1
- package/dist/m/c-FDNHHZY5.js +0 -1
- package/dist/m/c-FROJUZMV.js +0 -1
- package/dist/m/c-G2JPKCTP.js +0 -1
- package/dist/m/c-GB6TU7WV.js +0 -1
- package/dist/m/c-GFJJEBTU.js +0 -1
- package/dist/m/c-GJAEGGXY.js +0 -1
- package/dist/m/c-GOWBDM6J.js +0 -1
- package/dist/m/c-HFKUVACH.js +0 -1
- package/dist/m/c-HHDFCNHV.js +0 -1
- package/dist/m/c-IEM4NTCS.js +0 -1
- package/dist/m/c-JDCX26UP.js +0 -25
- package/dist/m/c-KGVGROZT.js +0 -1
- package/dist/m/c-KQ6TYJAP.js +0 -135
- package/dist/m/c-LFPHCXY3.js +0 -1
- package/dist/m/c-LRPUO2MX.js +0 -1
- package/dist/m/c-LWLBHLVC.js +0 -3
- package/dist/m/c-M2L47S2X.js +0 -7
- package/dist/m/c-MFP2ZWD4.js +0 -1
- package/dist/m/c-MKSQ4Y57.js +0 -1
- package/dist/m/c-NUFFJVVJ.js +0 -1
- package/dist/m/c-NUHSPT5P.js +0 -1
- package/dist/m/c-O72HVYSA.js +0 -1
- package/dist/m/c-OIBUTDXI.js +0 -1
- package/dist/m/c-OW5QIGG3.js +0 -1
- package/dist/m/c-PGRCK73F.js +0 -1
- package/dist/m/c-Q7NQD65V.js +0 -1
- package/dist/m/c-QH63LQOS.js +0 -1
- package/dist/m/c-R7IWVINQ.js +0 -1
- package/dist/m/c-RM7J7BV2.js +0 -1
- package/dist/m/c-S4ZEH46B.js +0 -9
- package/dist/m/c-SDAXDM2D.js +0 -1
- package/dist/m/c-SMGU7RT3.js +0 -235
- package/dist/m/c-SPIORRYS.js +0 -1
- package/dist/m/c-SWLRT66R.js +0 -1
- package/dist/m/c-TCJTVAFN.js +0 -1
- package/dist/m/c-TQEMVJCS.js +0 -1
- package/dist/m/c-TYLXX4NF.js +0 -21
- package/dist/m/c-U62OB4BT.js +0 -1
- package/dist/m/c-U6YWUAR3.js +0 -8
- package/dist/m/c-UDCSU5G5.js +0 -2
- package/dist/m/c-VI5RMSVY.js +0 -1
- package/dist/m/c-VRZN56XY.js +0 -1
- package/dist/m/c-W5MCHEGA.js +0 -1
- package/dist/m/c-WNYBLIOZ.js +0 -1
- package/dist/m/c-WWXIDH4O.js +0 -28
- package/dist/m/c-XCNTK76U.js +0 -1
- package/dist/m/c-XMS6DPBR.js +0 -1
- package/dist/m/c-ZUCOKOHT.js +0 -1
- package/dist/m/c-ZVPVXTJF.js +0 -4
- package/dist/m/c-ZVRKXKM7.js +0 -1
- package/dist/m/core/autosave-HRYGUWV6.js +0 -1
- package/dist/m/core/conflict-notice-6MROJN2L.js +0 -1
- package/dist/m/core/is-edit-mode-KTWA3O5N.js +0 -1
- package/dist/m/core/recovery-FLTCC2OC.js +0 -1
- package/dist/m/core/save-HQZ4S667.js +0 -1
- package/dist/m/core/save-core-KGQWFUNH.js +0 -1
- package/dist/m/core/snapshot-EGQZNT45.js +0 -1
- package/dist/m/core/unsaved-warning-IDJLD66H.js +0 -1
- package/dist/m/loader-S4I7GKXR.js +0 -1
- package/dist/m/manifest-4C419D67.js +0 -1
- package/dist/m/manifest-edit-B077F288.js +0 -1
- package/dist/m/plugins/ai-edit-QN4PMMNL.js +0 -6
- package/dist/m/plugins/indicator-URDBBOQO.js +0 -1
- package/dist/m/plugins/live-HFWD4OIH.js +0 -1
- package/dist/m/plugins/menu-3HIEQSI6.js +0 -138
- package/dist/m/plugins/page-JOKB6XPR.js +0 -2
- package/dist/m/plugins/page-view-NXOJHNW6.js +0 -1
- package/dist/m/plugins/quickcrop-QNY3PKLD.js +0 -26
- package/dist/m/plugins/sortable-GWT4PWDV.js +0 -1
- package/dist/m/plugins/source-4ZRSAIYM.js +0 -1
- package/dist/m/plugins/undo-VDA5P7FH.js +0 -1
- package/dist/m/plugins/upgrade-W7FG5VFG.js +0 -1
- package/dist/m/plugins/visitor-drafts-LIDY7NH6.js +0 -21
- package/dist/m/plugins/visitor-drafts-owner-ZXCKBZE7.js +0 -1
- package/dist/m/reader-core-DXYCURFF.js +0 -68
- package/dist/m/route/route-KOCZSEGN.js +0 -1
- package/dist/m/sync/live-sync-J7VMYTKS.js +0 -1
- package/dist/m/ui/index-3JLVI27O.js +0 -1
- package/dist/m/vendor/sap-core.vendor-A7BMUYZT.js +0 -6
- /package/dist/m/{c-FILLTJA7.js → c-QTTJYJMA.js} +0 -0
- /package/dist/m/plugins/{quickcrop-QNY3PKLD.js.LEGAL.txt → quickcrop-BQ5YYFCH.js.LEGAL.txt} +0 -0
- /package/dist/m/plugins/{richclay-NRQDSWX6.js.LEGAL.txt → richclay-KLGETK77.js.LEGAL.txt} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// GENERATED — do not edit. Vendored from
|
|
2
2
|
// hyper-html-api/src/upgrade.js via hyper-html-api
|
|
3
3
|
// `npm run copy-to-clayjs`. Edit the hyper-html-api source and re-run.
|
|
4
|
-
var ut=Object.defineProperty;var at=(e,t)=>{for(var n in t)ut(e,n,{get:t[n],enumerable:!0})};var G=["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"],Z=new Set(G),fe=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Q=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),Ce=new Set(["checked","selected","disabled","readOnly","paused"]);function ue(e,t){return t==null?Ce.has(e)?!1:"":Ce.has(e)?t==="false"?!1:!!t:t}var ne={};at(ne,{EmptyListInsert:()=>M,MAX_RULE_DEPTH:()=>D,MaxRuleDepthExceeded:()=>k,NoRulesTag:()=>ae,RuleTargetReadOnly:()=>H,RulesParseError:()=>_,ShapeMismatch:()=>v,UnknownRulesVersion:()=>P,WriteNotRoundTripped:()=>te,WriteRefused:()=>ee,WriteRejected:()=>de});var _=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},P=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},D=20,k=class extends Error{constructor(t){super(`rule depth exceeded ${D} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},v=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},M=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},H=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},ee=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function dt(e){return e.reduce((n,o)=>typeof o=="number"?`${n}[${o}]`:n?`${n}.${o}`:String(o),"")||"(root)"}var te=class extends Error{constructor(t){super(`write did not round-trip at "${dt(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},ae=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},de=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}};function b(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let i=e[r];i==="\\"?r++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:i==="@"&&t===0&&(o=r)}return o}function pe(e){let t=b(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function he(e){let t=0,n=null,o=-1,r=!1;for(let i=0;i<e.length;i++){let s=e[i];s==="\\"?i++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:t===0&&s===">"?o=i:t===0&&s===","&&(r=!0)}return r||o===-1||!pt(e,o+1)?null:e.slice(0,o).trim()||null}function pt(e,t){let n=t,o=e.replace(/\s+$/,"").length;for(;n<o&&/\s/.test(e[n]);)n++;let r=0,i=null;for(;n<o;n++){let s=e[n];if(s==="\\")n++;else if(i)s===i&&(i=null);else if(s==='"'||s==="'")i=s;else if(s==="["||s==="(")r++;else if(s==="]"||s===")")r>0&&r--;else if(r===0&&(s==="+"||s==="~"||/\s/.test(s)))return!1}return!0}var ht=/^--[A-Za-z0-9_-]+$/;function I(e){return typeof e=="string"&&ht.test(e)}function Me(e){let t=[],n=[],o=null,r=0;for(let i=0;i<e.length;i++){let s=e[i];if(o){s==="\\"?i++:s===o&&(o=null);continue}if(s==="/"&&e[i+1]==="*"){let c=e.indexOf("*/",i+2);i=c===-1?e.length:c+1;continue}s==='"'||s==="'"?o=s:s==="("?n.push(")"):s==="["?n.push("]"):s==="{"?n.push("}"):(s===")"||s==="]"||s==="}")&&n[n.length-1]===s?n.pop():s===";"&&n.length===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function mt(e){let t="",n=null;for(let o=0;o<e.length;o++){let r=e[o];if(n){t+=r,r==="\\"&&o+1<e.length?t+=e[++o]:r===n&&(n=null);continue}if(r==="/"&&e[o+1]==="*"){let i=e.indexOf("*/",o+2);o=i===-1?e.length:i+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Pe(e){e=mt(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),o=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(o);return r&&(o=o.slice(0,r.index).trim()),{name:n,value:o,important:!!r}}function V(e,t){if(e==null)return null;let n=null;for(let o of Me(String(e))){let r=Pe(o);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function ke(e,t,n){let o=e==null?"":String(e),r=n==null||n==="",i=Me(o),s=i.map(Pe),c=s.some(h=>h&&h.name===t&&h.important),l=[],u=!1;i.forEach((h,m)=>{let T=s[m];if(!T||T.name!==t){l.push(h);return}if(r||u)return;let f=/^\s*/.exec(h)[0];l.push(`${f}${t}: ${n}${c?" !important":""}`),u=!0});let d=l.join(";");if(!r&&!u){let h=d.trimEnd();d=h===""?`${t}: ${n}`:`${h}${h.endsWith(";")?" ":"; "}${t}: ${n}`}return d.trim()===""?null:d}function me(e,t,n,o){let r=e.attr(t,"style");if((V(r,n)??"")===o)return;let i=ke(r,n,o);i==null?e.removeAttr(t,"style"):e.attr(t,"style",i)}function C(e,t,n,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 ye(e,t,n,{depth:0,path:[]},o)}function ye(e,t,n,o,r){if(o.depth>D)throw new k(o.path);if(typeof n=="string")return yt(e,t,n,o,r);if(Array.isArray(n)){let[i,s]=n,c=e.find(t,i,r);return Le(r,o,c),c.map((l,u)=>ye(e,l,s,{depth:o.depth+1,path:[...o.path,u]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[s,c]of Object.entries(n))i[s]=ye(e,t,c,{depth:o.depth+1,path:[...o.path,s]},r);return i}return null}function yt(e,t,n,o,r){if(n.endsWith("[]")){let c=n.slice(0,-2),l=e.find(t,c,r);return Le(r,o,l),l.map(u=>e.text(u))}if(n.startsWith("@"))return Ie(e,t,n.slice(1));let i=b(n);if(i!==-1){let c=n.slice(0,i),l=n.slice(i+1),u=c?e.find(t,c,r):[t];return u.length===0?null:Ie(e,u[0],l)}if(n===".")return e.text(t);let s=e.find(t,n,r);return s.length===0?null:e.text(s[0])}function Le(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function Ie(e,t,n){if(I(n))return V(e.attr(t,"style"),n);if(Z.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o??null}function _e(e,t,n,o){let r=e.length,i=t.length,s=new Array(r).fill(-1);if(o){let a=new Set;for(let y=0;y<r;y++){let w=o[y];!(w>=0&&w<i)||a.has(w)||(s[y]=w,a.add(w))}}if(r===0||i===0)return s;let c=e.map(a=>je(a,n)),l=t.map(a=>je(a,n)),u=new Array(i).fill(!1);for(let a of s)a>=0&&(u[a]=!0);let d=new Map;l.forEach((a,y)=>{u[y]||d.set(a,d.has(a)?-1:y)});let h=new Map;c.forEach((a,y)=>{s[y]>=0||h.set(a,(h.get(a)||0)+1)}),c.forEach((a,y)=>{if(s[y]>=0||h.get(a)!==1)return;let w=d.get(a);w===void 0||w===-1||u[w]||(s[y]=w,u[w]=!0)});let m=[];for(let a=0;a<r;a++)s[a]<0&&m.push(a);let T=[];for(let a=0;a<i;a++)u[a]||T.push(a);if(m.length===0||T.length===0)return s;let f=r*i+1,p=gt(e,t,n),g=(a,y)=>p(a,y)*f+Math.abs(a-y);for(let[a,y]of wt(m,T,g))s[a]=y;return s}var De=e=>typeof e=="object"&&e!==null;function je(e,t){if(!De(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function gt(e,t,n){if(!De(n))return(c,l)=>e[c]===t[l]?0:1;let o=Object.keys(n),r=c=>o.map(l=>JSON.stringify(c?.[l])),i=e.map(r),s=t.map(r);return(c,l)=>{let u=i[c],d=s[l],h=0;for(let m=0;m<o.length;m++)u[m]!==d[m]&&h++;return h}}function wt(e,t,n){return e.length<=t.length?$e(e,t,n,!1):$e(t,e,(o,r)=>n(r,o),!0)}function $e(e,t,n,o){let r=e.length,i=t.length,s=[];for(let h=0;h<=r;h++)s.push(new Float64Array(i+1).fill(1/0));let c=[];for(let h=0;h<=r;h++)c.push(new Uint8Array(i+1));for(let h=0;h<=i;h++)s[r][h]=0;for(let h=r-1;h>=0;h--)for(let m=i-1;m>=0;m--){let T=n(e[h],t[m])+s[h+1][m+1],f=s[h][m+1];T<=f?(s[h][m]=T,c[h][m]=1):s[h][m]=f}let l=[],u=0,d=0;for(;u<r&&d<i;)c[u][d]&&(l.push(o?[t[d],e[u]]:[e[u],t[d]]),u++),d++;return l}function we(e,t,n,o,r,i,s,c={}){let l=e.find(t,n,c);if(r.length===0){l.forEach(A=>e.remove(A)),ge(c,"onRowsApplied",i.path,[]);return}let u=r.length>l.length,d=l[0]||null;if(u&&!d&&(d=Ot(e,t,n,c),!d))throw new M(i.path);let h=l.map(A=>xt(e,A,o,c)),m=null;if(u&&d){m=e.clone(d),c.templateAttr&&e.removeAttr(m,c.templateAttr);let A=e.stripIds(m);A>0&&console.warn(`[hyper-html-api] stripped ${A} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let T=_e(r,h,o,At(e,l,r,i,c)),f=l.length>0?e.parent(l[0]):Rt(e,t,n,d,i,c),p=l.length>0?Ve(e,f,l[0]):0,g=Mt(e,l),a=new Set,y=[],w=r.map((A,S)=>{let O=T[S];if(O>=0)return a.add(O),y.push(!1),l[O];y.push(!0);let x=e.clone(m);return e.stripIds(x),x});l.forEach((A,S)=>{a.has(S)||e.remove(A)}),g?Ct(e,f,p,w,y):Pt(e,w,y,f,p),Tt(e,w,o,r,i,s,c),ge(c,"onRowsApplied",i.path,w)}function ge(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function At(e,t,n,o,r){let i=ge(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let s=new Array(n.length).fill(-1),c=new Set,l=new Map(t.map((u,d)=>[e.identity(u),d]));for(let u=0;u<n.length;u++){if(!i[u])continue;let d=l.get(e.identity(i[u]));d===void 0||c.has(d)||(s[u]=d,c.add(d))}return s}function Tt(e,t,n,o,r,i,s){t.forEach((c,l)=>{if(n===null){let u=o[l],d=u==null?"":String(u);e.text(c)!==d&&e.text(c,d)}else{let u=i(e,c,n,o[l],{depth:r.depth+1,path:[...r.path,l]},s);u&&u!==c&&(t[l]=u)}})}function xt(e,t,n,o){return n===null?e.text(t):C(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Ve(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function Ot(e,t,n,o){if(!o.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),i=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),s=n.replace(/^\s*:scope\s*>\s*/,"").replace(i,""),c=r?Et(s):0,l=he(s),u=t;for(;u;){let d=e.find(u,s,{includeRulesTag:!1,templateAttr:null});for(let h of d)if(e.attr(h,o.templateAttr)!=null&&!(r&&!bt(e,t,h,c))&&!(l&&!e.matches(e.parent(h),l)))return h;u=e.parent(u)}return null}function Et(e){let t=0,n=null,o=1;for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\")r++;else if(n)i===n&&(n=null);else if(i==='"'||i==="'")n=i;else if(i==="["||i==="(")t++;else if(i==="]"||i===")")t>0&&t--;else if(t===0&&i===">")o++;else{if(t===0&&(i==="+"||i==="~"))return null;if(t===0&&/\s/.test(i)){if(!St(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return o}function St(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let o=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return We(o)||We(r)}function We(e){return e===">"||e==="+"||e==="~"}function bt(e,t,n,o){if(o===null)return!0;let r=n;for(let l=0;l<o;l++)if(r=e.parent(r),!r)return!1;let i=e.prop(t,"tagName");if(!i)return!0;let s=e.prop(r,"tagName");if(!s||String(s).toLowerCase()!==String(i).toLowerCase())return!1;let c=new Set(Ue(e,r));return Ue(e,t).every(l=>c.has(l))}function Ue(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Rt(e,t,n,o,r,i){let s=e.parent(o);if(s&&Nt(e,t,s)&&!He(e,s,i))return s;let c=he(n);if(!c)throw new M(r.path,`the list selector "${n}" 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 u=(c===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,c,i)).filter(d=>!He(e,d,i));if(u.length===0)throw new M(r.path,`no container matching "${c}" inside this context to hold the new rows`);if(u.length>1)throw new M(r.path,`"${c}" matches ${u.length} containers inside this context, so the new rows have no single destination`);return u[0]}function Nt(e,t,n){let o=n;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(r=>e.sameNode(r,n))}var ve=["no-data","editor-ui"];function He(e,t,n){let o=t;for(;o;){if(n.templateAttr&&e.attr(o,n.templateAttr)!=null||ve.some(i=>e.attr(o,i)!=null))return!0;let r=e.attr(o,"clay");if(r&&r.split(/\s+/).some(i=>ve.includes(i)))return!0;o=e.parent(o)}return!1}function Ct(e,t,n,o,r){let i=e.children(t),s=i.map(l=>e.identity(l)),c=!1;o.forEach((l,u)=>{let d=e.identity(l),h=n+u;if(s[h]===d)return;if(!r[u]){let T=s.indexOf(d);T!==-1&&(s.splice(T,1),i.splice(T,1))}let m=Math.min(h,i.length);m<i.length?e.insertBefore(i[m],l):i.length?c?e.insertAfter(i[i.length-1],l):(e.insertAt(t,l,h),c=!0):e.insertAt(t,l,0),s.splice(m,0,d),i.splice(m,0,l)})}function Mt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=new Map(e.children(n).map((i,s)=>[e.identity(i),s])),r=[];for(let i of t){let s=o.get(e.identity(i));if(s===void 0)return!1;r.push(s)}return r.sort((i,s)=>i-s),r[r.length-1]-r[0]===r.length-1}function Pt(e,t,n,o,r){let i=null,s=r;for(let c=0;c<t.length;c++){if(!n[c]){i=t[c];continue}let l=i?e.parent(i):o;if(!l)continue;let u=i?Ve(e,l,i)+1:s++;e.insertAt(l,t[c],u),i=t[c]}}function L(e,t,n,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let i=[];if(Ae(n,o,[],i),i.length)throw new v(i);re(e,t,n,o,{depth:0,path:[]},r)}function re(e,t,n,o,r,i={}){if(r.depth>D)throw new k(r.path);if(o===void 0)return t;if(typeof n=="string")return kt(e,t,n,o,r,i);if(Array.isArray(n)){let[s,c]=n;return we(e,t,s,c,o,r,re,i),t}if(typeof n=="object"&&n!==null){for(let[s,c]of Object.entries(n)){let l=re(e,t,c,o==null?o:o[s],{depth:r.depth+1,path:[...r.path,s]},i);l&&l!==t&&(t=l)}return t}return t}function kt(e,t,n,o,r,i){if(n.endsWith("[]")){let l=n.slice(0,-2);return we(e,t,l,null,o,r,re,i),t}if(n.startsWith("@"))return Be(e,t,n.slice(1),o);let s=b(n);if(s!==-1){let l=n.slice(0,s),u=n.slice(s+1),d=l?e.find(t,l,i):[t];return d.length===0||Be(e,d[0],u,o),t}if(n===".")return qe(e,t,o),t;let c=e.find(t,n,i);return c.length===0||qe(e,c[0],o),t}function qe(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function It(e,t,n,o){if(e.styleVar){e.styleVar(t,n,o);return}me(e,t,n,o)}function Be(e,t,n,o){if(I(n))return It(e,t,n,o==null?"":String(o).trim()),t;if(Q.has(n)){let r=e.prop(t,n);if(r===o||r!=null&&o!=null&&String(r)===String(o))return t;throw new H(n)}if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}if(fe.has(n)){let r=ue(n,o);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(o==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(o);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function Ae(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,i)=>{typeof r=="object"&&r!==null&&o.push({path:B([...n,i]),expected:"scalar",got:q(r)})}):o.push({path:B(n),expected:"array",got:q(t)});return}t!==null&&typeof t=="object"&&o.push({path:B(n),expected:"scalar",got:q(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:B(n),expected:"array",got:q(t)});return}let r=e[1];t.forEach((i,s)=>Ae(r,i,[...n,s],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:B(n),expected:"object",got:q(t)});return}for(let[r,i]of Object.entries(e))Ae(i,t[r],[...n,r],o)}}}function q(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function B(e){return e.join(".")}function Te(e){try{return JSON.parse(e)}catch(t){throw new _(`Invalid strict JSON: ${t.message}`,t)}}function j(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 n(r){let i=[],s=0;for(;s<r.length;){let c=r[s];if(/\s/.test(c)){s++;continue}if("{}".includes(c)){i.push({type:c,value:c}),s++;continue}if(c==="["){let h=!1,m=s+1;for(;m<r.length&&/\s/.test(r[m]);)m++;if(m<r.length&&/[a-zA-Z_]/.test(r[m])&&(h=!0),!h){i.push({type:c,value:c}),s++;continue}}if(c==="]"){i.push({type:c,value:c}),s++;continue}if(c===":"){i.push({type:t.COLON,value:c}),s++;continue}if(c===","){i.push({type:t.COMMA,value:c}),s++;continue}if(c==='"'||c==="'"){let h=c,m=s+1;for(;m<r.length&&r[m]!==h;)r[m]==="\\"&&m++,m++;i.push({type:t.STRING,value:r.substring(s+1,m),quoted:!0,sourceQuote:h}),s=m+1;continue}let l=s,u;for(;l<r.length&&!/[{},]/.test(r[l]);)if(r[l]===":"){let h=[":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"],m=!1;for(let T of h){let f=T.substring(1);if(r.substring(l+1,l+1+f.length)===f){m=!0,l+=f.length;break}}if(!m)break}else if(r[l]==="["){for(l++;l<r.length&&r[l]!=="]";){if(r[l]==='"'||r[l]==="'"){let h=r[l];for(l++;l<r.length&&r[l]!==h;)r[l]==="\\"&&l++,l++}l++}l<r.length&&r[l]==="]"&&l++}else l++;u=r.substring(s,l);let d=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?d=t.NUMBER:u==="true"||u==="false"||u==="null"?d=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(d=t.SELECTOR),i.push({type:d,value:u,quoted:!1}),s=l}return i}function o(r){let i="";for(let s=0;s<r.length;s++){let c=r[s];if("{}".includes(c.type)||"[]".includes(c.type)){i+=c.value;continue}if(c.type===t.COLON){i+=c.value;continue}if(c.type===t.COMMA){let l=r[s+1];if(l&&(l.type==="}"||l.type==="]"))continue;i+=c.value;continue}if(c.type===t.STRING&&c.quoted){let l=c.value;c.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(u,d)=>d.length%2===0?d+'\\"':u)),i+=`"${l}"`;continue}if(c.type===t.NUMBER||c.type===t.BOOLEAN){i+=c.value;continue}if(c.type===t.SELECTOR||c.type===t.IDENTIFIER){i+=`"${c.value}"`;continue}i+=`"${c.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new _("Invalid extraction rules syntax: "+r.message,r)}}var xe="1",ze=/^[a-zA-Z0-9_-]+$/;function z(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!ze.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${ze})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let i=r[0],s=e.attr(i,"data-rules-version");if(s!==xe)throw new P(s);return{rules:j(e.text(i)),tagNode:i}}var oe=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"]})}),Lt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Fe=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function F(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Oe(e,t){if(F(e,t))return!0;for(let[n,o]of Object.entries(Lt))if(o.includes(t)&&F(e,n))return!0;return!1}function K(e){let t=oe[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function jt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=oe[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>Oe(n,r))||o.bundles.some(r=>F(n,r)))return n;n=n.parentElement}return null}function Ke(e,t){return!!jt(e,t)}var $t=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",...Fe],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 Ee(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return z(e,o,n)}return null}var Ut=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function vt(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Je(e,t,n,o){if(o)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function Ye(e,t,n,o,r,i){return(i?Ke(e,t):Je(e,n,r,!1))||!!(o&&(i&&e!==r?e.matches(o):Je(e,o,r,i)))}function Ht(e,t){let n=oe[t];return n.tokens.some(o=>Oe(e,o))||n.bundles.some(o=>F(e,o))}var Vt=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Xe(e,t,n,o){if(e.nodeType===1&&o(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,i=t;if(e.nodeType===1){if(Vt.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,i=t.content,n.cloneToLive.set(i,r),n.liveToClone.set(r,i)}}else if(e.nodeType!==11)return;let s=i.firstChild;for(let c=r.firstChild;c&&s;c=c.nextSibling)Xe(c,s,n,o),s=s.nextSibling}function J(e,{capability:t="data",exclude:n=null,inherit:o=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let i=e.nodeType===9?e:e.ownerDocument;if(!i?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=i.implementation.createHTMLDocument(""),c=r||new WeakMap,l=new WeakMap,u=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let d=K(t),h=o?f=>Ht(f,t)||!!(n&&f.matches(n)):f=>Ye(f,t,d,n,u,!1),m=null;if(u.nodeType!==1||!Ye(u,t,d,n,u,o)){m=s.importNode(u,!0);let f={cloneToLive:c,liveToClone:l,dropped:[],controls:[]};Xe(u,m,f,h);for(let p of f.dropped)p.remove();for(let p=0;p<f.controls.length;p+=2)vt(f.controls[p],f.controls[p+1])}e.nodeType===9&&m&&(s.replaceChild(m,s.documentElement),l.set(e,s),c.set(s,e));let T=f=>{if(Ut.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:m,document:s,capability:t,selector:K(t),cloneToLive:c,liveToClone:l,original(f){return c.get(f)||null},cloneOf(f){return l.get(f)||null},query(f,p=m){return T(f),Array.from(p.querySelectorAll(f),g=>c.get(g)||g)},text(f=m){return(f===m?m:l.get(f))?.textContent||""},html(f=m){return(f===m?m:l.get(f))?.innerHTML??""},clone(f=m){let p=f===m?m:l.get(f);return p?s.importNode(p,!0):null}}}function Ze(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function qt(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function Ge(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function Qe(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function et(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let o=n.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var E={semanticExclude:!0,find(e,t,n={}){let o=qt(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(c=>!Ze(c)));let i=[];n.skip&&i.push(n.skip);let s=n.templateAttr===null?null:n.templateAttr||"cms-template";if(s&&i.push("["+s+"]"),i.length){let c=i.join(", ");r=r.filter(l=>!l.closest||!l.closest(c))}return r},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,Qe(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),Ge(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),Ge(e,t,null)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return et(t),t},insertAt(e,t,n){let o=e.children[n]||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 o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function Y(e,t={}){if(t.exclude===null)return E;let n=[K("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return E;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,s=e.nodeType===9?e:e.ownerDocument,c=null,l=()=>c||(c=J(i,{capability:"data",exclude:t.exclude||null})),u=f=>{let p=l();return f===e?p.cloneOf(e):p.cloneOf(f)||f},d=f=>c?.original(f)||f,h=(f,p)=>{l().liveToClone.set(f,p),l().cloneToLive.set(p,f);let g=f.childNodes||[],a=p.childNodes||[];for(let y=0;y<Math.min(g.length,a.length);y++)h(g[y],a[y])},m=(f,p,g,a)=>{let y=Array.from(f.childNodes).filter(x=>c.cloneOf(x)),A=y[0];for(;A&&y.includes(A);)A=A.nextSibling;for(let x of y)x.remove();if(g==="innerHTML"){let x=s.createElement("template");x.innerHTML=a;for(let U of Array.from(x.content.childNodes))f.insertBefore(U,A||null)}else f.insertBefore(s.createTextNode(a),A||null),Qe(f,a);let S=J(f,{capability:"data",exclude:t.exclude||null});p.replaceChildren(...Array.from(S.root?.childNodes||[]));let O=x=>{let U=S.original(x);U&&(c.liveToClone.set(U,x),c.cloneToLive.set(x,U));for(let ft of Array.from(x.childNodes||[]))O(ft)};for(let x of Array.from(p.childNodes))O(x)},T={...E,find(f,p,g={}){let a=u(f);if(!a?.querySelectorAll)return[];let y=l().query(p,a);g.includeRulesTag||(y=y.filter(S=>!Ze(S)));let w=[];g.skip&&w.push(g.skip);let A=g.templateAttr===null?null:g.templateAttr||"cms-template";if(A&&w.push(`[${A}]`),w.length){let S=w.join(", ");y=y.filter(O=>!O.closest?.(S))}return y},parent(f){let p=u(f)?.parentElement;return p?d(p):null},children(f){return Array.from(u(f)?.children||[],d)},text(f,p){if(p===void 0){let y=d(f);return!y?.matches?.(n)&&!y?.querySelector?.(n)?E.text(y):(u(f)?.textContent||"").trim()}let g=d(f);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!c){E.text(g,p);return}let a=l().cloneOf(g);a?m(g,a,"textContent",p):E.text(g,p)},attr(f,p,g){let a=d(f);if(g===void 0)return E.attr(a,p);E.attr(a,p,g);let y=c?.cloneOf(a);y&&(E.attr(y,p,g),J(a,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),c.liveToClone.delete(a),c.cloneToLive.delete(y)))},removeAttr(f,p){let g=d(f);E.removeAttr(g,p);let a=c?.cloneOf(g);a&&E.removeAttr(a,p)},prop(f,p,g){let a=d(f);if(g===void 0)return p==="innerHTML"||p==="outerHTML"||p==="textContent"||p==="innerText"?E.prop(u(a),p):E.prop(a,p);let y=p==="innerHTML"||p==="textContent"||p==="innerText",w=y?l().cloneOf(a):c?.cloneOf(a);w&&y?m(a,w,p,g):(E.prop(a,p,g),w&&E.prop(w,p,g))},clone(f){let p=u(f);if(p===f)return E.clone(f);let g=s.importNode(p,!0);return et(g),g},insertAt(f,p,g){let a=d(f),w=T.children(a)[g]||(()=>{for(let O=a.children.length-1;O>=0;O--){let x=a.children[O];if(l().cloneOf(x))return x.nextElementSibling}return a.firstElementChild})(),A=d(p);a.insertBefore(A,w||null);let S=l().cloneOf(a);if(S){let O=l().cloneOf(A);O||(O=s.importNode(A,!0),h(A,O));let x=Array.from(S.children);S.insertBefore(O,x[g]||null)}},insertBefore(f,p){let g=d(f),a=d(p);g.parentNode.insertBefore(a,g);let y=l().cloneOf(g.parentNode);if(y){let w=l().cloneOf(a);w||(w=s.importNode(a,!0),h(a,w));let A=l().cloneOf(g);A?A.before(w):y.appendChild(w)}},insertAfter(f,p){let g=d(f),a=d(p);g.parentNode.insertBefore(a,g.nextSibling);let y=l().cloneOf(g.parentNode);if(y){let w=l().cloneOf(a);w||(w=s.importNode(a,!0),h(a,w));let A=l().cloneOf(g);A?A.after(w):y.appendChild(w)}},identity(f){return d(f)||null},remove(f){let p=d(f),g=l().cloneOf(p);E.remove(p),g&&E.remove(g)},replaceWith(f,p){let g=d(f),a=l().cloneOf(g),y=E.replaceWith(g,p);if(a){let w=J(y,{capability:"data",exclude:t.exclude||null});if(!w.root)a.remove();else{a.replaceWith(w.root);let A=S=>{let O=w.original(S);O&&(c.liveToClone.set(O,S),c.cloneToLive.set(S,O));for(let x of Array.from(S.childNodes||[]))A(x)};A(w.root)}}return y}};return T}var R=E;var tt={extract:(e,t,n={})=>C(Y(e,n),e,t,n),apply:(e,t,n,o={})=>L(Y(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>z(R,e,t),findRules:(e,t)=>Ee(R,e,t),bind:(e,t,n={})=>{let o=Ee(R,e,t);if(!o){let r=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>C(Y(e,n),e,o.rules,n),set:r=>L(Y(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:Te,parseRelaxed:j,ruleAttrIndex:b,splitRule:pe,errors:ne,DOM_PROPERTIES:G};var Bt="hha:upgrade-check:";function N(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function Se(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function nt(e,t){let n=Se(e),o=Se(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let s=n[i]||0,c=o[i]||0;if(s!==c)return s>c}return!1}function zt(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Ft(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function rt({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:i=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(m=>fetch(m)),r=r??Date.now(),!t)return null;let s=N(t,"hyper-source");if(!s)return null;let c=N(t,"hyper-version"),l;try{l=new URL(s,n?n.href:void 0)}catch{return null}if(n&&l.origin===n.origin&&l.pathname===n.pathname)return null;let u=`${Bt}${l.href}:${c||"none"}`,d,h=e?null:zt(u);if(h&&typeof h.checkedAt=="number"&&r-h.checkedAt<i)d=h.sourceVersion;else{try{let m=await o(l.href);if(!m.ok)throw new Error(`HTTP ${m.status}`);let T=await m.text(),f=new DOMParser().parseFromString(T,"text/html");d=N(f,"hyper-version")}catch{d=null}Ft(u,{checkedAt:r,sourceVersion:d})}return d?{available:nt(d,c||"0.0.0"),currentVersion:c,sourceVersion:d,sourceUrl:l.href}:null}var Kt="script[data-rules-name]";function Jt(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ie(e,t){let n=e.find(t,Kt,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let s=Jt(e.attr(i,"data-rules-name"));if(!s)continue;if(o.has(s)){console.warn(`hyper-html-api: duplicate rules tag name "${s}"; using the first.`);continue}let c=e.attr(i,"data-rules-version");if(c!==xe)throw new P(c);o.add(s),r.push({name:s,rules:j(e.text(i))})}return r}function be(e,t){let n={};for(let{name:o,rules:r}of ie(e,t))n[o]=C(e,t,r);return n}function ot(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:be(R,t),version:N(n,"hyper-version")}}var X=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},se=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},$=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},ce=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var Yt="text/hyper-upgrade";function it(e,t){let n=e.find(t,`script[type="${Yt}"]`);if(n.length===0)return null;if(n.length>1)throw new ce(n.length);return e.text(n[0])||null}var Xt=new Function("url","return import(url)");async function st(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await Xt(n)}catch(r){throw new $(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new $("transform must `export default` a function");return o.default}function le(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=Re(t,e,n);return Ne(t,e,n),{data:o,summary:n}}function Re(e,t,n){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):void 0:t==null||typeof t=="object"?void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,o]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(r=>Re(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,i]of Object.entries(e)){let s=Re(i,t?.[r],n);s!==void 0&&(o[r]=s)}return o}}function Ne(e,t,n){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 r of Object.keys(t))o.has(r)?Ne(e[r],t[r],n):n.discarded+=W(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>Ne(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=W(t))}}function W(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+W(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+W(n),0):1}function ct(e,t,n){let o=ie(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},s=new Set;for(let{name:c,rules:l}of o){if(s.add(c),!Object.prototype.hasOwnProperty.call(n,c)){i[c]={carriedOver:0,discarded:0,listItems:0};continue}let{data:u,summary:d}=le(n[c],l);L(e,t,l,u),i[c]=d,r.carriedOver+=d.carriedOver,r.discarded+=d.discarded,r.listItems+=d.listItems}for(let c of Object.keys(n))s.has(c)||(r.discarded+=W(n[c]));return{totals:r,byName:i,rulesTagCount:o.length}}async function lt({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:i}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),i=i||(a=>fetch(a)),!o)throw new Error("upgrade.run requires a document context");if(e=e||N(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let s=new URL(e,r?r.href:void 0);n=n!==void 0?n:N(o,"hyper-version"),t=t||be(R,o);let c;try{c=await i(s.href)}catch(a){throw new X(s.href,a)}if(!c.ok)throw new X(s.href,new Error(`HTTP ${c.status}`));let l=await c.text(),u=new DOMParser().parseFromString(l,"text/html"),d=N(u,"hyper-version"),h=t,m=!1,T=it(R,u);if(T){let y=await(await st(T))(h,{fromVersion:n,toVersion:d});if(!y||typeof y!="object"||Array.isArray(y))throw new $("transform must return a plain object map of { rulesName: data }");h=y,m=!0}let{totals:f,byName:p,rulesTagCount:g}=ct(R,u,h);if(g===0&&Object.keys(h).length>0)throw new se(s.href);return{html:Gt(u),fromVersion:n,toVersion:d,summary:{transformApplied:m,totals:f,byName:p}}}function Gt(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
5
|
-
`+e.documentElement.outerHTML}var
|
|
4
|
+
var ut=Object.defineProperty;var at=(e,t)=>{for(var n in t)ut(e,n,{get:t[n],enumerable:!0})};var G=["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"],Z=new Set(G),fe=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Q=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),Ce=new Set(["checked","selected","disabled","readOnly","paused"]);function ue(e,t){return t==null?Ce.has(e)?!1:"":Ce.has(e)?t==="false"?!1:!!t:t}var ne={};at(ne,{EmptyListInsert:()=>M,MAX_RULE_DEPTH:()=>D,MaxRuleDepthExceeded:()=>k,NoRulesTag:()=>ae,RuleTargetReadOnly:()=>H,RulesParseError:()=>_,ShapeMismatch:()=>U,UnknownRulesVersion:()=>P,WriteNotRoundTripped:()=>te,WriteRefused:()=>ee,WriteRejected:()=>de});var _=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},P=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},D=20,k=class extends Error{constructor(t){super(`rule depth exceeded ${D} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},U=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},M=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},H=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},ee=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function dt(e){return e.reduce((n,o)=>typeof o=="number"?`${n}[${o}]`:n?`${n}.${o}`:String(o),"")||"(root)"}var te=class extends Error{constructor(t){super(`write did not round-trip at "${dt(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},ae=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},de=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}};function S(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let i=e[r];i==="\\"?r++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:i==="@"&&t===0&&(o=r)}return o}function pe(e){let t=S(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function he(e){let t=0,n=null,o=-1,r=!1;for(let i=0;i<e.length;i++){let s=e[i];s==="\\"?i++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:t===0&&s===">"?o=i:t===0&&s===","&&(r=!0)}return r||o===-1||!pt(e,o+1)?null:e.slice(0,o).trim()||null}function pt(e,t){let n=t,o=e.replace(/\s+$/,"").length;for(;n<o&&/\s/.test(e[n]);)n++;let r=0,i=null;for(;n<o;n++){let s=e[n];if(s==="\\")n++;else if(i)s===i&&(i=null);else if(s==='"'||s==="'")i=s;else if(s==="["||s==="(")r++;else if(s==="]"||s===")")r>0&&r--;else if(r===0&&(s==="+"||s==="~"||/\s/.test(s)))return!1}return!0}var ht=/^--[A-Za-z0-9_-]+$/;function I(e){return typeof e=="string"&&ht.test(e)}function Me(e){let t=[],n=[],o=null,r=0;for(let i=0;i<e.length;i++){let s=e[i];if(o){s==="\\"?i++:s===o&&(o=null);continue}if(s==="/"&&e[i+1]==="*"){let c=e.indexOf("*/",i+2);i=c===-1?e.length:c+1;continue}s==='"'||s==="'"?o=s:s==="("?n.push(")"):s==="["?n.push("]"):s==="{"?n.push("}"):(s===")"||s==="]"||s==="}")&&n[n.length-1]===s?n.pop():s===";"&&n.length===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function mt(e){let t="",n=null;for(let o=0;o<e.length;o++){let r=e[o];if(n){t+=r,r==="\\"&&o+1<e.length?t+=e[++o]:r===n&&(n=null);continue}if(r==="/"&&e[o+1]==="*"){let i=e.indexOf("*/",o+2);o=i===-1?e.length:i+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Pe(e){e=mt(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),o=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(o);return r&&(o=o.slice(0,r.index).trim()),{name:n,value:o,important:!!r}}function q(e,t){if(e==null)return null;let n=null;for(let o of Me(String(e))){let r=Pe(o);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function ke(e,t,n){let o=e==null?"":String(e),r=n==null||n==="",i=Me(o),s=i.map(Pe),c=s.some(h=>h&&h.name===t&&h.important),l=[],u=!1;i.forEach((h,m)=>{let T=s[m];if(!T||T.name!==t){l.push(h);return}if(r||u)return;let f=/^\s*/.exec(h)[0];l.push(`${f}${t}: ${n}${c?" !important":""}`),u=!0});let d=l.join(";");if(!r&&!u){let h=d.trimEnd();d=h===""?`${t}: ${n}`:`${h}${h.endsWith(";")?" ":"; "}${t}: ${n}`}return d.trim()===""?null:d}function me(e,t,n,o){let r=e.attr(t,"style");if((q(r,n)??"")===o)return;let i=ke(r,n,o);i==null?e.removeAttr(t,"style"):e.attr(t,"style",i)}function C(e,t,n,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 ye(e,t,n,{depth:0,path:[]},o)}function ye(e,t,n,o,r){if(o.depth>D)throw new k(o.path);if(typeof n=="string")return yt(e,t,n,o,r);if(Array.isArray(n)){let[i,s]=n,c=e.find(t,i,r);return Le(r,o,c),c.map((l,u)=>ye(e,l,s,{depth:o.depth+1,path:[...o.path,u]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[s,c]of Object.entries(n))i[s]=ye(e,t,c,{depth:o.depth+1,path:[...o.path,s]},r);return i}return null}function yt(e,t,n,o,r){if(n.endsWith("[]")){let c=n.slice(0,-2),l=e.find(t,c,r);return Le(r,o,l),l.map(u=>e.text(u))}if(n.startsWith("@"))return Ie(e,t,n.slice(1));let i=S(n);if(i!==-1){let c=n.slice(0,i),l=n.slice(i+1),u=c?e.find(t,c,r):[t];return u.length===0?null:Ie(e,u[0],l)}if(n===".")return e.text(t);let s=e.find(t,n,r);return s.length===0?null:e.text(s[0])}function Le(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function Ie(e,t,n){if(I(n))return q(e.attr(t,"style"),n);if(Z.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o??null}function _e(e,t,n,o){let r=e.length,i=t.length,s=new Array(r).fill(-1);if(o){let a=new Set;for(let y=0;y<r;y++){let A=o[y];!(A>=0&&A<i)||a.has(A)||(s[y]=A,a.add(A))}}if(r===0||i===0)return s;let c=e.map(a=>je(a,n)),l=t.map(a=>je(a,n)),u=new Array(i).fill(!1);for(let a of s)a>=0&&(u[a]=!0);let d=new Map;l.forEach((a,y)=>{u[y]||d.set(a,d.has(a)?-1:y)});let h=new Map;c.forEach((a,y)=>{s[y]>=0||h.set(a,(h.get(a)||0)+1)}),c.forEach((a,y)=>{if(s[y]>=0||h.get(a)!==1)return;let A=d.get(a);A===void 0||A===-1||u[A]||(s[y]=A,u[A]=!0)});let m=[];for(let a=0;a<r;a++)s[a]<0&&m.push(a);let T=[];for(let a=0;a<i;a++)u[a]||T.push(a);if(m.length===0||T.length===0)return s;let f=r*i+1,p=gt(e,t,n),g=(a,y)=>p(a,y)*f+Math.abs(a-y);for(let[a,y]of At(m,T,g))s[a]=y;return s}var De=e=>typeof e=="object"&&e!==null;function je(e,t){if(!De(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function gt(e,t,n){if(!De(n))return(c,l)=>e[c]===t[l]?0:1;let o=Object.keys(n),r=c=>o.map(l=>JSON.stringify(c?.[l])),i=e.map(r),s=t.map(r);return(c,l)=>{let u=i[c],d=s[l],h=0;for(let m=0;m<o.length;m++)u[m]!==d[m]&&h++;return h}}function At(e,t,n){return e.length<=t.length?$e(e,t,n,!1):$e(t,e,(o,r)=>n(r,o),!0)}function $e(e,t,n,o){let r=e.length,i=t.length,s=[];for(let h=0;h<=r;h++)s.push(new Float64Array(i+1).fill(1/0));let c=[];for(let h=0;h<=r;h++)c.push(new Uint8Array(i+1));for(let h=0;h<=i;h++)s[r][h]=0;for(let h=r-1;h>=0;h--)for(let m=i-1;m>=0;m--){let T=n(e[h],t[m])+s[h+1][m+1],f=s[h][m+1];T<=f?(s[h][m]=T,c[h][m]=1):s[h][m]=f}let l=[],u=0,d=0;for(;u<r&&d<i;)c[u][d]&&(l.push(o?[t[d],e[u]]:[e[u],t[d]]),u++),d++;return l}function Ae(e,t,n,o,r,i,s,c={}){let l=e.find(t,n,c);if(r.length===0){l.forEach(w=>e.remove(w)),ge(c,"onRowsApplied",i.path,[]);return}let u=r.length>l.length,d=l[0]||null;if(u&&!d&&(d=Ot(e,t,n,c),!d))throw new M(i.path);let h=l.map(w=>xt(e,w,o,c)),m=null;if(u&&d){m=e.clone(d),c.templateAttr&&e.removeAttr(m,c.templateAttr);let w=e.stripIds(m);w>0&&console.warn(`[hyper-html-api] stripped ${w} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let T=_e(r,h,o,wt(e,l,r,i,c)),f=l.length>0?e.parent(l[0]):Rt(e,t,n,d,i,c),p=l.length>0?qe(e,f,l[0]):0,g=Mt(e,l),a=new Set,y=[],A=r.map((w,b)=>{let O=T[b];if(O>=0)return a.add(O),y.push(!1),l[O];y.push(!0);let x=e.clone(m);return e.stripIds(x),x});l.forEach((w,b)=>{a.has(b)||e.remove(w)}),g?Ct(e,f,p,A,y):Pt(e,A,y,f,p),Tt(e,A,o,r,i,s,c),ge(c,"onRowsApplied",i.path,A)}function ge(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function wt(e,t,n,o,r){let i=ge(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let s=new Array(n.length).fill(-1),c=new Set,l=new Map(t.map((u,d)=>[e.identity(u),d]));for(let u=0;u<n.length;u++){if(!i[u])continue;let d=l.get(e.identity(i[u]));d===void 0||c.has(d)||(s[u]=d,c.add(d))}return s}function Tt(e,t,n,o,r,i,s){t.forEach((c,l)=>{if(n===null){let u=o[l],d=u==null?"":String(u);e.text(c)!==d&&e.text(c,d)}else{let u=i(e,c,n,o[l],{depth:r.depth+1,path:[...r.path,l]},s);u&&u!==c&&(t[l]=u)}})}function xt(e,t,n,o){return n===null?e.text(t):C(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function qe(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function Ot(e,t,n,o){if(!o.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),i=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),s=n.replace(/^\s*:scope\s*>\s*/,"").replace(i,""),c=r?Et(s):0,l=he(s),u=t;for(;u;){let d=e.find(u,s,{includeRulesTag:!1,templateAttr:null});for(let h of d)if(e.attr(h,o.templateAttr)!=null&&!(r&&!St(e,t,h,c))&&!(l&&!e.matches(e.parent(h),l)))return h;u=e.parent(u)}return null}function Et(e){let t=0,n=null,o=1;for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\")r++;else if(n)i===n&&(n=null);else if(i==='"'||i==="'")n=i;else if(i==="["||i==="(")t++;else if(i==="]"||i===")")t>0&&t--;else if(t===0&&i===">")o++;else{if(t===0&&(i==="+"||i==="~"))return null;if(t===0&&/\s/.test(i)){if(!bt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return o}function bt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let o=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return ve(o)||ve(r)}function ve(e){return e===">"||e==="+"||e==="~"}function St(e,t,n,o){if(o===null)return!0;let r=n;for(let l=0;l<o;l++)if(r=e.parent(r),!r)return!1;let i=e.prop(t,"tagName");if(!i)return!0;let s=e.prop(r,"tagName");if(!s||String(s).toLowerCase()!==String(i).toLowerCase())return!1;let c=new Set(We(e,r));return We(e,t).every(l=>c.has(l))}function We(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Rt(e,t,n,o,r,i){let s=e.parent(o);if(s&&Nt(e,t,s)&&!He(e,s,i))return s;let c=he(n);if(!c)throw new M(r.path,`the list selector "${n}" 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 u=(c===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,c,i)).filter(d=>!He(e,d,i));if(u.length===0)throw new M(r.path,`no container matching "${c}" inside this context to hold the new rows`);if(u.length>1)throw new M(r.path,`"${c}" matches ${u.length} containers inside this context, so the new rows have no single destination`);return u[0]}function Nt(e,t,n){let o=n;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(r=>e.sameNode(r,n))}var Ue=["no-data","editor-ui"];function He(e,t,n){let o=t;for(;o;){if(n.templateAttr&&e.attr(o,n.templateAttr)!=null||Ue.some(i=>e.attr(o,i)!=null))return!0;let r=e.attr(o,"clay");if(r&&r.split(/\s+/).some(i=>Ue.includes(i)))return!0;o=e.parent(o)}return!1}function Ct(e,t,n,o,r){let i=e.children(t),s=i.map(l=>e.identity(l)),c=!1;o.forEach((l,u)=>{let d=e.identity(l),h=n+u;if(s[h]===d)return;if(!r[u]){let T=s.indexOf(d);T!==-1&&(s.splice(T,1),i.splice(T,1))}let m=Math.min(h,i.length);m<i.length?e.insertBefore(i[m],l):i.length?c?e.insertAfter(i[i.length-1],l):(e.insertAt(t,l,h),c=!0):e.insertAt(t,l,0),s.splice(m,0,d),i.splice(m,0,l)})}function Mt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=new Map(e.children(n).map((i,s)=>[e.identity(i),s])),r=[];for(let i of t){let s=o.get(e.identity(i));if(s===void 0)return!1;r.push(s)}return r.sort((i,s)=>i-s),r[r.length-1]-r[0]===r.length-1}function Pt(e,t,n,o,r){let i=null,s=r;for(let c=0;c<t.length;c++){if(!n[c]){i=t[c];continue}let l=i?e.parent(i):o;if(!l)continue;let u=i?qe(e,l,i)+1:s++;e.insertAt(l,t[c],u),i=t[c]}}function L(e,t,n,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let i=[];if(we(n,o,[],i),i.length)throw new U(i);re(e,t,n,o,{depth:0,path:[]},r)}function re(e,t,n,o,r,i={}){if(r.depth>D)throw new k(r.path);if(o===void 0)return t;if(typeof n=="string")return kt(e,t,n,o,r,i);if(Array.isArray(n)){let[s,c]=n;return Ae(e,t,s,c,o,r,re,i),t}if(typeof n=="object"&&n!==null){for(let[s,c]of Object.entries(n)){let l=re(e,t,c,o==null?o:o[s],{depth:r.depth+1,path:[...r.path,s]},i);l&&l!==t&&(t=l)}return t}return t}function kt(e,t,n,o,r,i){if(n.endsWith("[]")){let l=n.slice(0,-2);return Ae(e,t,l,null,o,r,re,i),t}if(n.startsWith("@"))return Be(e,t,n.slice(1),o);let s=S(n);if(s!==-1){let l=n.slice(0,s),u=n.slice(s+1),d=l?e.find(t,l,i):[t];return d.length===0||Be(e,d[0],u,o),t}if(n===".")return Ve(e,t,o),t;let c=e.find(t,n,i);return c.length===0||Ve(e,c[0],o),t}function Ve(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function It(e,t,n,o){if(e.styleVar){e.styleVar(t,n,o);return}me(e,t,n,o)}function Be(e,t,n,o){if(I(n))return It(e,t,n,o==null?"":String(o).trim()),t;if(Q.has(n)){let r=e.prop(t,n);if(r===o||r!=null&&o!=null&&String(r)===String(o))return t;throw new H(n)}if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}if(fe.has(n)){let r=ue(n,o);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(o==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(o);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function we(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,i)=>{typeof r=="object"&&r!==null&&o.push({path:B([...n,i]),expected:"scalar",got:V(r)})}):o.push({path:B(n),expected:"array",got:V(t)});return}t!==null&&typeof t=="object"&&o.push({path:B(n),expected:"scalar",got:V(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:B(n),expected:"array",got:V(t)});return}let r=e[1];t.forEach((i,s)=>we(r,i,[...n,s],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:B(n),expected:"object",got:V(t)});return}for(let[r,i]of Object.entries(e))we(i,t[r],[...n,r],o)}}}function V(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function B(e){return e.join(".")}function Te(e){try{return JSON.parse(e)}catch(t){throw new _(`Invalid strict JSON: ${t.message}`,t)}}function j(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 n(r){let i=[],s=0;for(;s<r.length;){let c=r[s];if(/\s/.test(c)){s++;continue}if("{}".includes(c)){i.push({type:c,value:c}),s++;continue}if(c==="["){let h=!1,m=s+1;for(;m<r.length&&/\s/.test(r[m]);)m++;if(m<r.length&&/[a-zA-Z_]/.test(r[m])&&(h=!0),!h){i.push({type:c,value:c}),s++;continue}}if(c==="]"){i.push({type:c,value:c}),s++;continue}if(c===":"){i.push({type:t.COLON,value:c}),s++;continue}if(c===","){i.push({type:t.COMMA,value:c}),s++;continue}if(c==='"'||c==="'"){let h=c,m=s+1;for(;m<r.length&&r[m]!==h;)r[m]==="\\"&&m++,m++;i.push({type:t.STRING,value:r.substring(s+1,m),quoted:!0,sourceQuote:h}),s=m+1;continue}let l=s,u;for(;l<r.length&&!/[{},]/.test(r[l]);)if(r[l]===":"){let h=[":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"],m=!1;for(let T of h){let f=T.substring(1);if(r.substring(l+1,l+1+f.length)===f){m=!0,l+=f.length;break}}if(!m)break}else if(r[l]==="["){for(l++;l<r.length&&r[l]!=="]";){if(r[l]==='"'||r[l]==="'"){let h=r[l];for(l++;l<r.length&&r[l]!==h;)r[l]==="\\"&&l++,l++}l++}l<r.length&&r[l]==="]"&&l++}else l++;u=r.substring(s,l);let d=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?d=t.NUMBER:u==="true"||u==="false"||u==="null"?d=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(d=t.SELECTOR),i.push({type:d,value:u,quoted:!1}),s=l}return i}function o(r){let i="";for(let s=0;s<r.length;s++){let c=r[s];if("{}".includes(c.type)||"[]".includes(c.type)){i+=c.value;continue}if(c.type===t.COLON){i+=c.value;continue}if(c.type===t.COMMA){let l=r[s+1];if(l&&(l.type==="}"||l.type==="]"))continue;i+=c.value;continue}if(c.type===t.STRING&&c.quoted){let l=c.value;c.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(u,d)=>d.length%2===0?d+'\\"':u)),i+=`"${l}"`;continue}if(c.type===t.NUMBER||c.type===t.BOOLEAN){i+=c.value;continue}if(c.type===t.SELECTOR||c.type===t.IDENTIFIER){i+=`"${c.value}"`;continue}i+=`"${c.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new _("Invalid extraction rules syntax: "+r.message,r)}}var xe="1",ze=/^[a-zA-Z0-9_-]+$/;function z(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!ze.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${ze})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let i=r[0],s=e.attr(i,"data-rules-version");if(s!==xe)throw new P(s);return{rules:j(e.text(i)),tagNode:i}}var oe=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"]})}),Lt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Fe=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function F(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Oe(e,t){if(F(e,t))return!0;for(let[n,o]of Object.entries(Lt))if(o.includes(t)&&F(e,n))return!0;return!1}function K(e){let t=oe[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function jt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=oe[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>Oe(n,r))||o.bundles.some(r=>F(n,r)))return n;n=n.parentElement}return null}function Ke(e,t){return!!jt(e,t)}var $t=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",...Fe],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 Ee(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return z(e,o,n)}return null}var Wt=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Ut(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Je(e,t,n,o){if(o)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function Ye(e,t,n,o,r,i){return(i?Ke(e,t):Je(e,n,r,!1))||!!(o&&(i&&e!==r?e.matches(o):Je(e,o,r,i)))}function Ht(e,t){let n=oe[t];return n.tokens.some(o=>Oe(e,o))||n.bundles.some(o=>F(e,o))}var qt=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Xe(e,t,n,o){if(e.nodeType===1&&o(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,i=t;if(e.nodeType===1){if(qt.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,i=t.content,n.cloneToLive.set(i,r),n.liveToClone.set(r,i)}}else if(e.nodeType!==11)return;let s=i.firstChild;for(let c=r.firstChild;c&&s;c=c.nextSibling)Xe(c,s,n,o),s=s.nextSibling}function J(e,{capability:t="data",exclude:n=null,inherit:o=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let i=e.nodeType===9?e:e.ownerDocument;if(!i?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=i.implementation.createHTMLDocument(""),c=r||new WeakMap,l=new WeakMap,u=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let d=K(t),h=o?f=>Ht(f,t)||!!(n&&f.matches(n)):f=>Ye(f,t,d,n,u,!1),m=null;if(u.nodeType!==1||!Ye(u,t,d,n,u,o)){m=s.importNode(u,!0);let f={cloneToLive:c,liveToClone:l,dropped:[],controls:[]};Xe(u,m,f,h);for(let p of f.dropped)p.remove();for(let p=0;p<f.controls.length;p+=2)Ut(f.controls[p],f.controls[p+1])}e.nodeType===9&&m&&(s.replaceChild(m,s.documentElement),l.set(e,s),c.set(s,e));let T=f=>{if(Wt.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:m,document:s,capability:t,selector:K(t),cloneToLive:c,liveToClone:l,original(f){return c.get(f)||null},cloneOf(f){return l.get(f)||null},query(f,p=m){return T(f),Array.from(p.querySelectorAll(f),g=>c.get(g)||g)},text(f=m){return(f===m?m:l.get(f))?.textContent||""},html(f=m){return(f===m?m:l.get(f))?.innerHTML??""},clone(f=m){let p=f===m?m:l.get(f);return p?s.importNode(p,!0):null}}}function Ze(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Vt(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function Ge(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function Qe(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function et(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let o=n.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var E={semanticExclude:!0,find(e,t,n={}){let o=Vt(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(c=>!Ze(c)));let i=[];n.skip&&i.push(n.skip);let s=n.templateAttr===null?null:n.templateAttr||"cms-template";if(s&&i.push("["+s+"]"),i.length){let c=i.join(", ");r=r.filter(l=>!l.closest||!l.closest(c))}return r},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,Qe(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),Ge(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),Ge(e,t,null)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return et(t),t},insertAt(e,t,n){let o=e.children[n]||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 o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function Y(e,t={}){if(t.exclude===null)return E;let n=[K("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return E;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,s=e.nodeType===9?e:e.ownerDocument,c=null,l=()=>c||(c=J(i,{capability:"data",exclude:t.exclude||null})),u=f=>{let p=l();return f===e?p.cloneOf(e):p.cloneOf(f)||f},d=f=>c?.original(f)||f,h=(f,p)=>{l().liveToClone.set(f,p),l().cloneToLive.set(p,f);let g=f.childNodes||[],a=p.childNodes||[];for(let y=0;y<Math.min(g.length,a.length);y++)h(g[y],a[y])},m=(f,p,g,a)=>{let y=Array.from(f.childNodes).filter(x=>c.cloneOf(x)),w=y[0];for(;w&&y.includes(w);)w=w.nextSibling;for(let x of y)x.remove();if(g==="innerHTML"){let x=s.createElement("template");x.innerHTML=a;for(let W of Array.from(x.content.childNodes))f.insertBefore(W,w||null)}else f.insertBefore(s.createTextNode(a),w||null),Qe(f,a);let b=J(f,{capability:"data",exclude:t.exclude||null});p.replaceChildren(...Array.from(b.root?.childNodes||[]));let O=x=>{let W=b.original(x);W&&(c.liveToClone.set(W,x),c.cloneToLive.set(x,W));for(let ft of Array.from(x.childNodes||[]))O(ft)};for(let x of Array.from(p.childNodes))O(x)},T={...E,find(f,p,g={}){let a=u(f);if(!a?.querySelectorAll)return[];let y=l().query(p,a);g.includeRulesTag||(y=y.filter(b=>!Ze(b)));let A=[];g.skip&&A.push(g.skip);let w=g.templateAttr===null?null:g.templateAttr||"cms-template";if(w&&A.push(`[${w}]`),A.length){let b=A.join(", ");y=y.filter(O=>!O.closest?.(b))}return y},parent(f){let p=u(f)?.parentElement;return p?d(p):null},children(f){return Array.from(u(f)?.children||[],d)},text(f,p){if(p===void 0){let y=d(f);return!y?.matches?.(n)&&!y?.querySelector?.(n)?E.text(y):(u(f)?.textContent||"").trim()}let g=d(f);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!c){E.text(g,p);return}let a=l().cloneOf(g);a?m(g,a,"textContent",p):E.text(g,p)},attr(f,p,g){let a=d(f);if(g===void 0)return E.attr(a,p);E.attr(a,p,g);let y=c?.cloneOf(a);y&&(E.attr(y,p,g),J(a,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),c.liveToClone.delete(a),c.cloneToLive.delete(y)))},removeAttr(f,p){let g=d(f);E.removeAttr(g,p);let a=c?.cloneOf(g);a&&E.removeAttr(a,p)},prop(f,p,g){let a=d(f);if(g===void 0)return p==="innerHTML"||p==="outerHTML"||p==="textContent"||p==="innerText"?E.prop(u(a),p):E.prop(a,p);let y=p==="innerHTML"||p==="textContent"||p==="innerText",A=y?l().cloneOf(a):c?.cloneOf(a);A&&y?m(a,A,p,g):(E.prop(a,p,g),A&&E.prop(A,p,g))},clone(f){let p=u(f);if(p===f)return E.clone(f);let g=s.importNode(p,!0);return et(g),g},insertAt(f,p,g){let a=d(f),A=T.children(a)[g]||(()=>{for(let O=a.children.length-1;O>=0;O--){let x=a.children[O];if(l().cloneOf(x))return x.nextElementSibling}return a.firstElementChild})(),w=d(p);a.insertBefore(w,A||null);let b=l().cloneOf(a);if(b){let O=l().cloneOf(w);O||(O=s.importNode(w,!0),h(w,O));let x=Array.from(b.children);b.insertBefore(O,x[g]||null)}},insertBefore(f,p){let g=d(f),a=d(p);g.parentNode.insertBefore(a,g);let y=l().cloneOf(g.parentNode);if(y){let A=l().cloneOf(a);A||(A=s.importNode(a,!0),h(a,A));let w=l().cloneOf(g);w?w.before(A):y.appendChild(A)}},insertAfter(f,p){let g=d(f),a=d(p);g.parentNode.insertBefore(a,g.nextSibling);let y=l().cloneOf(g.parentNode);if(y){let A=l().cloneOf(a);A||(A=s.importNode(a,!0),h(a,A));let w=l().cloneOf(g);w?w.after(A):y.appendChild(A)}},identity(f){return d(f)||null},remove(f){let p=d(f),g=l().cloneOf(p);E.remove(p),g&&E.remove(g)},replaceWith(f,p){let g=d(f),a=l().cloneOf(g),y=E.replaceWith(g,p);if(a){let A=J(y,{capability:"data",exclude:t.exclude||null});if(!A.root)a.remove();else{a.replaceWith(A.root);let w=b=>{let O=A.original(b);O&&(c.liveToClone.set(O,b),c.cloneToLive.set(b,O));for(let x of Array.from(b.childNodes||[]))w(x)};w(A.root)}}return y}};return T}var R=E;var tt={extract:(e,t,n={})=>C(Y(e,n),e,t,n),apply:(e,t,n,o={})=>L(Y(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>z(R,e,t),findRules:(e,t)=>Ee(R,e,t),bind:(e,t,n={})=>{let o=Ee(R,e,t);if(!o){let r=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>C(Y(e,n),e,o.rules,n),set:r=>L(Y(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:Te,parseRelaxed:j,ruleAttrIndex:S,splitRule:pe,errors:ne,DOM_PROPERTIES:G};var Bt="hha:upgrade-check:";function N(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function be(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function nt(e,t){let n=be(e),o=be(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let s=n[i]||0,c=o[i]||0;if(s!==c)return s>c}return!1}function zt(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Ft(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function rt({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:i=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(m=>fetch(m)),r=r??Date.now(),!t)return null;let s=N(t,"hyper-source");if(!s)return null;let c=N(t,"hyper-version"),l;try{l=new URL(s,n?n.href:void 0)}catch{return null}if(n&&l.origin===n.origin&&l.pathname===n.pathname)return null;let u=`${Bt}${l.href}:${c||"none"}`,d,h=e?null:zt(u);if(h&&typeof h.checkedAt=="number"&&r-h.checkedAt<i)d=h.sourceVersion;else{try{let m=await o(l.href);if(!m.ok)throw new Error(`HTTP ${m.status}`);let T=await m.text(),f=new DOMParser().parseFromString(T,"text/html");d=N(f,"hyper-version")}catch{d=null}Ft(u,{checkedAt:r,sourceVersion:d})}return d?{available:nt(d,c||"0.0.0"),currentVersion:c,sourceVersion:d,sourceUrl:l.href}:null}var Kt="script[data-rules-name]";function Jt(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ie(e,t){let n=e.find(t,Kt,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let s=Jt(e.attr(i,"data-rules-name"));if(!s)continue;if(o.has(s)){console.warn(`hyper-html-api: duplicate rules tag name "${s}"; using the first.`);continue}let c=e.attr(i,"data-rules-version");if(c!==xe)throw new P(c);o.add(s),r.push({name:s,rules:j(e.text(i))})}return r}function Se(e,t){let n={};for(let{name:o,rules:r}of ie(e,t))n[o]=C(e,t,r);return n}function ot(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Se(R,t),version:N(n,"hyper-version")}}var X=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},se=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},$=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},ce=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var Yt="text/hyper-upgrade";function it(e,t){let n=e.find(t,`script[type="${Yt}"]`);if(n.length===0)return null;if(n.length>1)throw new ce(n.length);return e.text(n[0])||null}var Xt=new Function("url","return import(url)");async function st(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await Xt(n)}catch(r){throw new $(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new $("transform must `export default` a function");return o.default}function le(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=Re(t,e,n);return Ne(t,e,n),{data:o,summary:n}}function Re(e,t,n){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):void 0:t==null||typeof t=="object"?void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,o]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(r=>Re(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,i]of Object.entries(e)){let s=Re(i,t?.[r],n);s!==void 0&&(o[r]=s)}return o}}function Ne(e,t,n){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 r of Object.keys(t))o.has(r)?Ne(e[r],t[r],n):n.discarded+=v(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>Ne(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=v(t))}}function v(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+v(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+v(n),0):1}function ct(e,t,n){let o=ie(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},s=new Set;for(let{name:c,rules:l}of o){if(s.add(c),!Object.prototype.hasOwnProperty.call(n,c)){i[c]={carriedOver:0,discarded:0,listItems:0};continue}let{data:u,summary:d}=le(n[c],l);L(e,t,l,u),i[c]=d,r.carriedOver+=d.carriedOver,r.discarded+=d.discarded,r.listItems+=d.listItems}for(let c of Object.keys(n))s.has(c)||(r.discarded+=v(n[c]));return{totals:r,byName:i,rulesTagCount:o.length}}async function lt({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:i}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),i=i||(a=>fetch(a)),!o)throw new Error("upgrade.run requires a document context");if(e=e||N(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let s=new URL(e,r?r.href:void 0);n=n!==void 0?n:N(o,"hyper-version"),t=t||Se(R,o);let c;try{c=await i(s.href)}catch(a){throw new X(s.href,a)}if(!c.ok)throw new X(s.href,new Error(`HTTP ${c.status}`));let l=await c.text(),u=new DOMParser().parseFromString(l,"text/html"),d=N(u,"hyper-version"),h=t,m=!1,T=it(R,u);if(T){let y=await(await st(T))(h,{fromVersion:n,toVersion:d});if(!y||typeof y!="object"||Array.isArray(y))throw new $("transform must return a plain object map of { rulesName: data }");h=y,m=!0}let{totals:f,byName:p,rulesTagCount:g}=ct(R,u,h);if(g===0&&Object.keys(h).length>0)throw new se(s.href);return{html:Zt(u),fromVersion:n,toVersion:d,summary:{transformApplied:m,totals:f,byName:p}}}function Gt(e){for(let t of e.querySelectorAll("input")){let n=(t.getAttribute("type")||"").toLowerCase();n!=="file"&&(n==="checkbox"||n==="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 n=[...t.options];if(!t.multiple){let o=n.findIndex(r=>r.hasAttribute("selected"));if(t.selectedIndex===o||o===-1&&t.selectedIndex<=0)continue}for(let o of n)o.selected!==o.hasAttribute("selected")&&o.toggleAttribute("selected",o.selected)}}function Zt(e){return Gt(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
5
|
+
`+e.documentElement.outerHTML}var Qt={checkForUpdate:rt,run:lt,extractAll:ot,shapeMatch:le};var en={engine:tt,upgrade:Qt},tn=en;export{tn as default,tt as engine,nt as isNewerVersion,be as parseVersion,N as readMeta,Qt as upgrade};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var hyperundo=(()=>{var J=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var mt=Object.prototype.hasOwnProperty;var pt=(e,n)=>{for(var t in n)J(e,t,{get:n[t],enumerable:!0})},gt=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of ft(n))!mt.call(e,i)&&i!==t&&J(e,i,{get:()=>n[i],enumerable:!(r=ct(n,i))||r.enumerable});return e};var ht=e=>gt(J({},"__esModule",{value:!0}),e);var Gt={};pt(Gt,{default:()=>Jt,undo:()=>ne});function yt(e,n=null){let t=[];if(e.type==="attributes"){let r=e.target,i=e.attributeName,a=e.oldValue,l=r.getAttribute(i);return a==null&&l!=null?t.push({kind:"attr-add",target:r,name:i,newValue:l}):a!=null&&l==null?t.push({kind:"attr-remove",target:r,name:i,oldValue:a}):a!==l&&t.push({kind:"attr-set",target:r,name:i,oldValue:a,newValue:l}),t}if(e.type==="characterData")return t.push({kind:"text",target:e.target,oldValue:e.oldValue,newValue:e.target.data}),t;if(e.type==="childList"){let r=e.target,i=e.nextSibling,a=e.nextSibling;for(;a&&n?.(a);)a=a.nextSibling;let l=e.previousSibling;for(;l&&n?.(l);)l=l.previousSibling;let s=n?Array.from(e.addedNodes).filter(g=>!n(g)):Array.from(e.addedNodes),d=n?Array.from(e.removedNodes).filter(g=>!n(g)):Array.from(e.removedNodes);return s.length>0&&t.push({kind:"add",parent:r,nodes:s,before:i,afterAuthored:a,beforeAuthored:l,record:e}),d.length>0&&t.push({kind:"remove",parent:r,nodes:d,before:i,afterAuthored:a,beforeAuthored:l,record:e}),t}return t}function ve(e,n=null){let t=[],r=new Map;for(let i of e){if(i.type==="attributes"){let a=i.target,l=i.attributeName,s=r.get(a);s||(s=new Map,r.set(a,s)),s.has(l)||(s.set(l,{idx:t.length,oldValue:i.oldValue}),t.push(null));continue}for(let a of yt(i,n))t.push(a)}for(let[i,a]of r)for(let[l,s]of a){let d=s.oldValue,g=i.getAttribute(l),p=null;d===g?p=null:d==null?p={kind:"attr-add",target:i,name:l,newValue:g}:g==null?p={kind:"attr-remove",target:i,name:l,oldValue:d}:p={kind:"attr-set",target:i,name:l,oldValue:d,newValue:g},t[s.idx]=p}return t.filter(i=>i!=null)}function Ae(e){let n=[],t=new Map;for(let i of e){let a=we(i);if(a==null){n.push(i);continue}let l=t.get(i.target);l||(l=new Map,t.set(i.target,l));let s=l.get(a);if(s==null){let d=ke(i);if(d.oldValue===d.newValue)continue;l.set(a,n.length),n.push({...i,...d})}else n[s]={...n[s],newValue:ke(i).newValue}}let r=[];for(let i of n){if(we(i)==null){r.push(i);continue}i.oldValue!==i.newValue&&r.push(wt(i))}return r}var bt=new Set(["attr-set","attr-add","attr-remove","text","value"]);function we(e){return bt.has(e.kind)?e.kind==="text"?"#text":e.kind==="value"?`#${e.prop||"value"}`:e.name==null?null:`@${e.name}`:null}function ke(e){return e.kind==="attr-add"?{oldValue:null,newValue:e.newValue}:e.kind==="attr-remove"?{oldValue:e.oldValue,newValue:null}:{oldValue:e.oldValue,newValue:e.newValue}}function wt(e){return e.kind!=="attr-add"&&e.kind!=="attr-remove"?e:e.oldValue==null&&e.newValue!=null?{...e,kind:"attr-add"}:e.oldValue!=null&&e.newValue==null?{...e,kind:"attr-remove"}:{...e,kind:"attr-set"}}var Ee=new WeakMap,kt=0;function V(e){let n=Ee.get(e);return n||(n=`n${++kt}`,Ee.set(e,n)),n}function v(e){return!!e&&typeof e=="object"&&typeof e.nodeType=="number"}function vt(e){return e.kind==="add"||e.kind==="remove"}function Se(e,n){let t=[],r=e.childNodes;if(!r)return t;for(let i of r)n&&n(i)||t.push(V(i));return t}function z(e,n,t=null,r=null){if(!v(e))return null;if(e.nodeType===3)return`#text:${JSON.stringify(e.data)}`;if(e.nodeType===8)return`#comment:${JSON.stringify(e.data)}`;if(e.nodeType!==1)return`#node:${e.nodeType}`;let i=[];if(e.attributes){for(let s of e.attributes)At(s.name,e,n,t)||i.push(`${s.name}=${JSON.stringify(s.value)}`);i.sort()}let a=[];if(e.childNodes)for(let s of e.childNodes)Et(s,r)||a.push(z(s,n,t,r));return`<${String(e.tagName||"").toLowerCase()}${i.length?` ${i.join(" ")}`:""}>${a.join("")}</>`}function G(e,n=[]){if(!v(e))return n;if(e.nodeType===1){let t=e.getAttribute&&e.getAttribute("data-id");t&&n.push(t)}if(e.childNodes)for(let t of e.childNodes)G(t,n);return n}function At(e,n,t,r=null){if(typeof t!="function")return!1;try{return!!t(e,n,r)}catch{return!1}}function Et(e,n){if(typeof n!="function")return!1;try{return!!n(e)}catch{return!1}}function Ve(e,n){if(typeof n!="function")return[];let t=[],r=i=>{if(!v(i))return;let a=!1;try{a=!!n(i)}catch{a=!1}if(a&&t.push(N(i,"protected")),i.childNodes)for(let l of i.childNodes)r(l)};for(let i of e)r(i);return t}function N(e,n,t=null){let r=e;r&&r.nodeType!==1&&(r=r.parentElement);let i=r&&typeof r.closest=="function"?r.closest("[data-id]"):null;return!i&&t&&typeof t.closest=="function"&&(i=t.closest("[data-id]")),{id:(i?i.getAttribute("data-id"):null)||null,kind:n||null}}function Nt(e,n,t=null){return(e||[]).filter(v).map(r=>N(r,n,t))}function q(e){return{replayable:!1,reason:e,steps:[]}}function D(e,n){let t=[[n.afterAuthored,i=>i],[n.beforeAuthored,i=>i+1],[n.before,i=>i]],r=!1;for(let[i,a]of t){if(!v(i))continue;r=!0;let l=e.indexOf(V(i));if(l>=0)return a(l)}return r?null:e.length}function Te(e,n={}){let t=n.isIgnored||null,r=n.ignoreAttribute||null,i=Ae(e),a=[];for(let p of i){if(!vt(p)){if(!v(p.target))return q("non-dom-target");continue}if(!v(p.parent))return q("non-dom-parent");let h=Array.from(p.nodes||[]).filter(v);if(h.length!==0){if(h.length!==Array.from(p.nodes||[]).length)return q("non-dom-node");a.push({primitive:p,nodes:h,parent:p.parent})}}if(St(a))return q("in-record-move");let l=Vt(a,t);if(!l)return q("ambiguous-structure");let s=Tt(a,l),d=new Map(a.map(p=>[p.primitive,p])),g=[];for(let p of i){let h=d.get(p);if(!h){g.push(Pt(p));continue}let w=s.get(h);if(w){w.at===h&&g.push(w.step);continue}g.push(It(h,l.get(h),r,t))}return{replayable:!0,reason:null,steps:g}}function St(e){let n=new Map;for(let t of e){let r=t.primitive.record;if(!r)continue;let i=n.get(r);i||(i=new Map,n.set(r,i));for(let a of t.nodes){let l=i.get(a);l||(l=new Set,i.set(a,l)),l.add(t.primitive.kind)}}for(let t of n.values())for(let r of t.values())if(r.size>1)return!0;return!1}function Vt(e,n){let t=new Map;for(let i of e)t.has(i.parent)||t.set(i.parent,Se(i.parent,n));let r=new Map;for(let i=e.length-1;i>=0;i--){let a=e[i],l=t.get(a.parent);if(!l)return null;let s=l.slice(),d;if(a.primitive.kind==="add"){let g=a.nodes.map(V);if(!g.every(p=>l.includes(p)))return null;d=l.filter(p=>!g.includes(p))}else{let g=D(s,a.primitive);if(g==null)return null;d=s.slice(),d.splice(g,0,...a.nodes.map(V))}r.set(a,{before:d,after:s}),t.set(a.parent,d)}return r}function Tt(e,n){let t=new Map,r=new Map;e.forEach((a,l)=>{for(let s of a.nodes){let d=V(s);a.primitive.kind==="remove"?t.set(d,{item:a,index:l,node:s}):r.set(d,{item:a,index:l,node:s})}});let i=new Map;for(let[a,l]of t){let s=r.get(a);if(!s||s.index<l.index||l.item.nodes.length!==1||s.item.nodes.length!==1)continue;let d={type:"move",node:l.node,sourceParent:l.item.parent,destParent:s.item.parent,source:n.get(l.item),dest:n.get(s.item),sourceSlot:l.item.primitive,destSlot:s.item.primitive,targets:[N(l.node,"move")]};i.set(l.item,{step:d,at:s.item}),i.set(s.item,{step:d,at:s.item})}return i}function It(e,n,t,r){let i=e.primitive.kind;return{type:i==="add"?"add":"restore",parent:e.parent,nodes:e.nodes,seqBefore:n.before,seqAfter:n.after,slot:e.primitive,content:e.nodes.map(a=>z(a,t,e.parent,r)),ids:i==="remove"?e.nodes.flatMap(a=>G(a)):[],targets:Nt(e.nodes,i==="add"?"added":"removed",e.parent)}}function Pt(e){return{type:e.kind,primitive:e,targets:[N(e.target,e.name||e.prop||"text")]}}function Ie(e,n,t={}){if(!e||!e.replayable)return{ok:!1,code:"unsupported",targets:[]};let r={isIgnored:t.isIgnored||null,ignoreAttribute:t.ignoreAttribute||null,isProtected:t.isProtected||null,inScope:t.inScope||(()=>!0),liveNodesWithIds:t.liveNodesWithIds||(()=>[]),sim:new Map,planned:new Map,operations:[]};for(let i=0;i<e.steps.length;i++){let a=e.steps[n==="undo"?e.steps.length-1-i:i],l=Rt(a,n,r);if(l)return{ok:!1,code:l.code,targets:l.targets}}return{ok:!0,operations:r.operations}}function M(e,n){return e.sim.has(n)||e.sim.set(n,Se(n,e.isIgnored)),e.sim.get(n)}function Pe(e,n){for(let t=e;t;t=t.parentNode)if(n.planned.has(t))return n.planned.get(t);return n.inScope(e)}function Ce(e,n){return n.liveNodesWithIds(e).filter(t=>Pe(t,n)).length>0}function b(e,n){return{code:e,targets:n||[]}}function Ct(e){return e.kind==="text"?e.target.data:e.kind==="value"?typeof e.read=="function"?e.read(e.target):e.target[e.prop||"value"]:e.target.getAttribute(e.name)}function Rt(e,n,t){let r=n==="undo";return e.type==="move"?Lt(e,r,t):e.type==="add"?xt(e,r,t):e.type==="restore"?_t(e,r,t):Ot(e,r,t)}function Ot(e,n,t){let r=e.primitive,i=n?r.newValue:r.oldValue,a=n?r.oldValue:r.newValue;return v(r.target)?Pe(r.target,t)?r.kind==="value"&&typeof r.write=="function"&&typeof r.read!="function"?b("unsupported",e.targets):Ct(r)!==i?b("content-changed",e.targets):(r.kind==="value"?t.operations.push({type:"value",target:r.target,prop:r.prop||"value",value:a,read:r.read||null,write:r.write||null}):r.kind==="text"?t.operations.push({type:"text",target:r.target,data:a}):t.operations.push({type:"attr",target:r.target,name:r.name,value:a??null}),null):b("target-detached",e.targets):b("unsupported",e.targets)}function xt(e,n,t){if(!v(e.parent)||!t.inScope(e.parent))return b("target-detached",e.targets);if(n){if(!L(M(t,e.parent),e.seqAfter))return b("structure-changed",e.targets);let s=Ve(e.nodes,t.isProtected);if(s.length>0)return b("protected",s);for(let d=0;d<e.nodes.length;d++)if(z(e.nodes[d],t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[d])return b("content-changed",e.targets);for(let d of e.nodes)t.operations.push({type:"remove",node:d}),t.planned.set(d,!1);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!L(M(t,e.parent),e.seqBefore))return b("structure-changed",e.targets);for(let s of e.nodes)if(s.parentNode)return b("structure-changed",e.targets);let r=e.nodes.flatMap(s=>G(s));if(r.length>0&&Ce(r,t))return b("duplicate-id",e.targets);let i=D(e.seqBefore,e.slot);if(i==null)return b("unsupported",e.targets);let a=e.seqBefore.slice(),l=i;for(let s of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:s,beforeId:a[l]??null}),a=a.slice(0,l).concat(V(s),a.slice(l)),l+=1,t.planned.set(s,!0);return t.sim.set(e.parent,e.seqAfter.slice()),null}function _t(e,n,t){if(!v(e.parent)||!t.inScope(e.parent))return b("target-detached",e.targets);if(n){if(!L(M(t,e.parent),e.seqAfter))return b("structure-changed",e.targets);for(let s=0;s<e.nodes.length;s++){let d=e.nodes[s];if(d.parentNode||z(d,t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[s])return b("content-changed",e.targets)}if(e.ids.length>0&&Ce(e.ids,t))return b("duplicate-id",e.targets);let i=D(e.seqAfter,e.slot);if(i==null)return b("unsupported",e.targets);let a=e.seqAfter.slice(),l=i;for(let s of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:s,beforeId:a[l]??null}),a=a.slice(0,l).concat(V(s),a.slice(l)),l+=1,t.planned.set(s,!0);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!L(M(t,e.parent),e.seqBefore))return b("structure-changed",e.targets);let r=Ve(e.nodes,t.isProtected);if(r.length>0)return b("protected",r);for(let i=0;i<e.nodes.length;i++){let a=e.nodes[i];if(a.parentNode!==e.parent||z(a,t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[i])return b("content-changed",e.targets)}for(let i of e.nodes)t.operations.push({type:"remove",node:i}),t.planned.set(i,!1);return t.sim.set(e.parent,e.seqAfter.slice()),null}function Mt(e,n){let t=e.indexOf(n);return t<0?null:e.slice(0,t).concat(e.slice(t+1))}function Lt(e,n,t){let r=V(e.node),i=n?e.destParent:e.sourceParent,a=n?e.sourceParent:e.destParent,l=M(t,i),s=M(t,a),d=n?e.dest.after:e.source.before,g=n?e.source.after:e.dest.before,p=n?e.sourceSlot:e.destSlot;if(!v(i)||!v(a)||!t.inScope(i)||!t.inScope(a))return b("target-detached",e.targets);if(!L(l,d))return b("structure-changed",e.targets);let h=i===a?Mt(s,r):s;if(!L(h,g))return b("structure-changed",e.targets);let w=D(g,p);return w==null?b("unsupported",e.targets):(t.operations.push({type:"insert",parent:a,node:e.node,beforeId:g[w]??null}),t.planned.set(e.node,!0),n?(t.sim.set(a,e.source.before.slice()),i!==a&&t.sim.set(i,e.dest.before.slice())):(t.sim.set(a,e.dest.after.slice()),i!==a&&t.sim.set(i,e.source.after.slice())),null)}function L(e,n){if(!e||!n||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function qt(e,n){for(let t of e.childNodes||[])if(V(t)===n)return t;return null}function Ne(e,n){typeof e.write=="function"?e.write(e.target,n):e.target[e.prop]=n}function Re(e){let n=[];try{for(let t of e)zt(t,n);return{ok:!0}}catch(t){for(let r=n.length-1;r>=0;r--)try{n[r]()}catch{}return{ok:!1,error:t}}}function zt(e,n){if(e.type==="attr"){let t=e.target.getAttribute(e.name);e.value==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,e.value),n.push(()=>{t==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,t)});return}if(e.type==="text"){let t=e.target.data;e.target.data=e.data,n.push(()=>{e.target.data=t});return}if(e.type==="value"){let t=typeof e.read=="function"?e.read(e.target):e.target[e.prop];Ne(e,e.value),n.push(()=>Ne(e,t));return}if(e.type==="insert"){let t=e.beforeId==null?null:qt(e.parent,e.beforeId);if(e.beforeId!=null&&!t)throw new Error("hyper-undo: replay anchor vanished");let r=e.node.parentNode,i=e.node.nextSibling;e.parent.insertBefore(e.node,t),n.push(()=>{r?r.insertBefore(e.node,i&&i.parentNode===r?i:null):e.node.parentNode===e.parent&&e.parent.removeChild(e.node)});return}if(e.type==="remove"){let t=e.node.parentNode;if(!t)throw new Error("hyper-undo: replay target is no longer attached");let r=e.node.nextSibling;t.removeChild(e.node),n.push(()=>t.insertBefore(e.node,r))}}var Kt=['[src^="chrome-extension://"]','[href^="chrome-extension://"]','[src^="moz-extension://"]','[href^="moz-extension://"]','[src^="safari-web-extension://"]','[href^="safari-web-extension://"]','[id="1p-menu-live-region"]',"com-1password-button","com-1password-menu","com-1password-notification","grammarly-extension","grammarly-desktop-integration","lt-div","lt-card","lt-toolbar","lt-highlighter","[data-lastpass-root]","[data-lastpass-icon-root]","[data-dashlane-shadowhost]","[data-klarna-extension]",'[class*="klarna-extension"]',".skiptranslate","#goog-gt-tt",".goog-te-banner-frame",".goog-te-balloon-frame","style.darkreader","style[data-darkreader-mode]","style[data-darkreader-scheme]","#loom-companion-mv3","loom-container","[ext-id]"],$t=["data-grammarly","data-lt","data-1p","data-com-onepassword","data-lastpass","data-lp","data-kwimpala","data-bitwarden","data-bw","data-dashlane","data-np","data-protonpass","data-proton-pass","data-keeper","data-rf","data-roboform","data-honey","data-rakuten","data-capital-one","data-wikibuy","data-klarna","data-darkreader","data-evernote","data-pocket","data-pin"],Oe=Kt.join(","),xe=new RegExp("^(?:"+$t.join("|")+")(?:-|$)");var nn=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"]})}),Bt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Dt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function U(e,n){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(n)||e.hasAttribute?.(n))}function Y(e,n){if(U(e,n))return!0;for(let[t,r]of Object.entries(Bt))if(r.includes(n)&&U(e,t))return!0;return!1}function _e(e){return e==="clay"||Dt.includes(e)}var Ut=["mutations-ignore","save-remove","save-ignore","save-freeze","no-undo","no-watch"];function jt(){if(typeof window>"u")return null;let e=window.clay?.region||window.hyperclay?.region;return e&&typeof e.resolveRegionPolicy=="function"?e.resolveRegionPolicy:null}function Z(e){let n=jt();if(n)try{if(!n(e).undoable)return!0}catch{}let t=e&&e.nodeType!==1?e.parentElement:e;if(t&&t.closest&&t.closest(Oe))return!0;for(;t&&t.nodeType===1;){if(Y(t,"no-undo")||Y(t,"no-watch"))return!0;for(let r of Ut)if(U(t,r))return!0;t=t.parentElement}return!1}function Wt(e){let n=e.target,t=n.cloneNode(!1),r=t;for(;n.parentElement;){n=n.parentElement;let i=n.cloneNode(!1);i.appendChild(t),t=i}return e.oldValue==null?r.removeAttribute(e.attributeName):r.setAttribute(e.attributeName,e.oldValue),Z(r)}function j(e,n,t){if(t?.type==="attributes"&&_e(t.attributeName)){if(Z(e)&&Wt(t))return!0}else if(Z(e))return!0;if(t&&t.type==="attributes"){if(t.attributeName&&xe.test(t.attributeName.toLowerCase()))return!0;if(n)try{if(n(t.attributeName,t.target))return!0}catch{}}return!1}function Me(){let e=new Map;function n(i,a){let l=e.get(i);return l||(l=new Set,e.set(i,l)),l.add(a),()=>t(i,a)}function t(i,a){let l=e.get(i);l&&l.delete(a)}function r(i,a){let l=e.get(i);if(l)for(let s of Array.from(l))try{s(a)}catch(d){console.error("[hyper-undo] listener threw",d)}}return{on:n,off:t,emit:r}}var Ft={maxHistory:100,idleWindowMs:500,idleLabel:"Edit",recording:"automatic",ignoreAttribute:null,isProtected:null,ignoreNode:null,debug:!1};function Q(e){let n={...Ft,...e};if(!n.scope)throw new Error("hyper-undo: scope is required");let t=Me(),r=[],i=[],a=`u${Math.random().toString(36).slice(2,8)}`,l=0,s=null,d=[],g=null,p=null,h=0,w=!1,P=n.recording==="commands"?"commands":"automatic",A=null,C=!1;function k(...o){n.debug&&console.log("[hyper-undo]",...o)}function $e(){w||(w=!0,p=Be(R),p.observe(n.scope,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),k("started"))}function Be(o){let u=typeof document<"u"&&n.scope===document.body,c=typeof window<"u"&&(window.clay?.Mutation||window.hyperclay?.Mutation)||null;return u&&c&&typeof c.createObserver=="function"?(k("sourcing records from the platform Mutation hub (shared observer)"),c.createObserver(o)):new MutationObserver(o)}function re(){w&&(w=!1,p&&(p.disconnect(),p=null),O(),r.length=0,i.length=0,d=[],s=null,A=null,C=!1,h=0,k("stopped"))}function De(){let o=n.scope;return!!(o&&o.nodeType===1&&o.isConnected===!1)}function R(o){oe(o,!1)}function oe(o,u){if(A){for(let m of o)A.records.push(m);return}if(P==="commands"||h>0)return;let c=W(Ue(o),u);if(c.length>0){for(let m of c)d.push(m);ie()}}function Ue(o){return typeof n.ignoreNode!="function"?o:o.filter(u=>{if(u.type!=="childList")return!0;let c=[...u.addedNodes,...u.removedNodes];return c.length===0?!0:!c.every(m=>je(m))})}function je(o){try{return!!n.ignoreNode(o)}catch{return!1}}function W(o,u=!1){let c=o.filter(m=>(ut(m.target)||u&&ye(m.target))&&!j(m.target,n.ignoreAttribute,m));return ve(c,m=>j(m,n.ignoreAttribute))}function ie(){O(),g=setTimeout(ae,n.idleWindowMs)}function O(){g!=null&&(clearTimeout(g),g=null)}function ae(){if(g=null,d.length===0)return;let o=d;d=[],K(n.idleLabel,o)}function K(o,u){let c=Te(u,{isIgnored:F,ignoreAttribute:ue});if(c.steps.length===0)return k("commit",o,"with nothing to record"),t.emit("commit"),null;let m={id:`${a}-${++l}`,label:o,timestamp:Date.now(),primitives:u,certificate:c};for(r.push(m),i.length=0,s=null;r.length>n.maxHistory;)r.shift();return k("commit",o,"primitives:",u.length),t.emit("commit"),m}function F(o){return j(o,n.ignoreAttribute)}function ue(o,u,c=null){if(typeof n.ignoreAttribute!="function")return!1;try{return!!n.ignoreAttribute(o,u,c)}catch{return!1}}function We(o){if(typeof n.isProtected!="function")return!1;try{return!!n.isProtected(o)}catch{return!1}}function Fe(o,u){if(!w)throw new Error("hyper-undo: scope not started");if(P==="commands")return de(o,u,{honorPause:!0,receipt:!1});R(p.takeRecords()),x();let c=h===0?se():null,m=u();if(m&&typeof m.then=="function")throw new Error("hyper-undo: commit() fn must be synchronous; returned a Promise");if(oe(p.takeRecords(),!0),c!=null&&le(c),d.length===0){t.emit("commit");return}O();let y=d;d=[],K(o,y)}function Xe(o){if(!w)throw new Error("hyper-undo: scope not started");if(!p)return;if(h>1){p.takeRecords();return}x();let u=W(p.takeRecords(),!0);u.length!==0&&(O(),K(o,u))}function He(){p&&p.takeRecords()}function X(){let o=n.scope;return o&&o.ownerDocument||(typeof document<"u"?document:null)}function $(){let o=X();return!o||!o.head||typeof o.head.querySelector!="function"?null:o.head.querySelector("title")}function se(){let o=$();return o?o.textContent:null}function le(o){let u=$();if(!u||o==null)return;let c=u.textContent;c!==o&&fe({kind:"value",target:u,prop:"textContent",oldValue:o,newValue:c})}function Je(o){if(!o)return null;let u=X();if(!u||o.target!==u||o.prop!=="title")return o;let c=$();return c?{kind:"value",target:c,prop:"textContent",oldValue:o.oldValue,newValue:o.newValue}:null}function Ge(){if(typeof window>"u")return!1;let o=window.clay?.effect||window.hyperclay?.effect;return!!(o&&o.running)}function Ye(){p&&R(p.takeRecords()),x(),A={records:[],primitives:[]}}function Ze(){let o=A;if(A=null,!o)return[];let u=W(o.records,!0);for(let c of o.primitives)u.push(c);return u}function de(o,u,{honorPause:c,receipt:m}){if(typeof u!="function")throw new Error("hyper-undo: command() needs a synchronous function");if(A)throw new Error("hyper-undo: command() cannot nest inside another command");if(C)throw new Error("hyper-undo: command() cannot run during undo or redo");if(Ge())throw new Error("hyper-undo: command() cannot run inside a derived-effect context");if(u.constructor&&u.constructor.name==="AsyncFunction")throw new Error("hyper-undo: command() fn must be synchronous; it was declared async");let y=c&&h>0,E=y?null:se();Ye();let S=[],T=null,_;try{try{_=u()}catch(be){T=be}if(p&&R(p.takeRecords()),_&&typeof _.then=="function"){try{_.then(void 0,()=>{})}catch{}T||(T=new Error("hyper-undo: command() fn must be synchronous; returned a Promise"))}y||le(E)}finally{S=Ze()}let B=y||S.length===0?null:K(o,S);if(T)throw T;return m?B?{id:B.id,label:B.label}:null:B}function Qe(o,u){if(!w)throw new Error("hyper-undo: scope not started");return de(o,u,{honorPause:!1,receipt:!0})}function et(o){if(o!=="automatic"&&o!=="commands")throw new Error("hyper-undo: setRecording() takes 'automatic' or 'commands'");if(A)throw new Error("hyper-undo: setRecording() cannot change while a command is running");return P===o||(x(),P=o,k("recording",o)),P}function ce(o){if(!w||!o||!A&&(h>0||P==="commands"))return;let u=Je(o);u&&fe(u)}function fe(o){if(A){A.primitives.push(o);return}d.push(o),ie()}function tt(o,{prop:u="value",oldValue:c,newValue:m,read:y,write:E}={}){!o||c===m||ce({kind:"value",target:o,prop:u,oldValue:c,newValue:m,read:y,write:E})}function x(){h===0&&p&&R(p.takeRecords()),d.length!==0&&(O(),ae())}function me(){h===0&&p&&R(p.takeRecords()),h++,k("paused",h)}function pe(){h!==0&&(h--,h===0&&p&&p.takeRecords(),k("resumed",h))}function ge(o,u){if(De())return re(),{ok:!1,code:"disconnected"};x();let c=o==="undo"?r:i,m=o==="undo"?i:r,y=c.at(-1);if(!y)return{ok:!1,code:"empty"};if(u&&u!==y.id){let _=he(u)||y;return H(_,o,"stale-entry")}let E;C=!0;try{E=Ie(y.certificate,o,{isIgnored:F,ignoreAttribute:ue,isProtected:We,inScope:st,liveNodesWithIds:lt})}finally{C=!1}if(!E.ok)return H(y,o,E.code,E.targets);me();let S;C=!0;try{S=Re(E.operations)}finally{C=!1,pe()}if(!S.ok)return k(`${o} failed and was rolled back`,S.error),H(y,o,"replay-error");c.pop(),m.push(y),s=null;let T={ok:!0,entryId:y.id,label:y.label,direction:o};return k(o,y.label),t.emit(o,T),T}function nt(o){return ge("undo",o&&o.entryId)}function rt(o){return ge("redo",o&&o.entryId)}function he(o){return r.find(u=>u.id===o)||i.find(u=>u.id===o)||null}function H(o,u,c,m=[]){return s={entryId:o.id,direction:u,code:c,targets:m},k("refused",u,c),t.emit("refused",{entryId:o.id,label:o.label,direction:u,code:c,targets:m}),{ok:!1,code:c,entryId:o.id,label:o.label,direction:u}}function ot(o){if(!s||s.entryId!==o)return{ok:!1,code:"not-refused",entryId:o};let u=s.direction,c=u==="undo"?r:i,m=c.at(-1);return!m||m.id!==o?{ok:!1,code:"stale-entry",entryId:o}:(c.pop(),s=null,k("discarded",m.label),t.emit("discard",{entryId:o,label:m.label,direction:u}),{ok:!0,entryId:o,direction:u})}function it(o){let u=he(o);if(!u||!u.certificate||!u.certificate.replayable)return null;let c=s&&s.entryId===u.id?{direction:s.direction,code:s.code,targets:(s.targets||[]).map(m=>({id:m.id??null,kind:m.kind??null}))}:null;return{id:u.id,label:u.label,timestamp:u.timestamp,refused:c,steps:u.certificate.steps.map(at)}}function at(o){if(o.type==="move")return{kind:"move",node:{id:N(o.node).id},from:{id:N(o.sourceParent).id},to:{id:N(o.destParent).id}};if(o.type==="add"||o.type==="restore")return{kind:o.type==="add"?"add":"remove",parent:{id:N(o.parent).id},nodes:o.nodes.map((E,S)=>({id:N(E).id,html:o.content[S]??null}))};let u=o.primitive,c={id:N(u.target).id},m=u.oldValue??null,y=u.newValue??null;return o.type==="value"?{kind:"value",target:c,prop:u.prop??"value",before:m,after:y}:o.type==="text"?{kind:"text",target:c,before:m,after:y}:o.type==="attr-set"||o.type==="attr-add"||o.type==="attr-remove"?{kind:"attribute",target:c,name:u.name??null,before:m,after:y}:{kind:o.type,target:c,before:m,after:y}}function ut(o){let u=n.scope;return!u||!o?!1:o===u||typeof u.contains=="function"&&u.contains(o)}function ye(o){let u=X(),c=u&&u.head;if(!c||!o)return!1;let m=o.nodeType===1?o:o.parentElement;for(;m&&m!==c;m=m.parentElement)if(m.localName==="title")return!1;return m===c}function st(o){let u=n.scope;return!o||!u?!1:o===u||$()===o||ye(o)?!0:typeof u.contains=="function"?u.contains(o):!1}function lt(o){let u=n.scope;if(!o||o.length===0||typeof u?.querySelectorAll!="function")return[];let c=new Set(o),m=[];for(let y of u.querySelectorAll("[data-id]"))c.has(y.getAttribute("data-id"))&&(F(y)||m.push(y));return m}function dt(){p&&p.takeRecords(),r.length=0,i.length=0,d=[],s=null,O(),k("cleared"),t.emit("clear")}return{_config:n,start:$e,stop:re,commit:Fe,commitCaptured:Xe,discardCaptured:He,flush:x,command:Qe,setRecording:et,record:ce,recordValue:tt,undo:nt,redo:rt,clear:dt,discard:ot,describe:it,pause:me,resume:pe,on:t.on,off:t.off,get canUndo(){return r.length>0},get canRedo(){return i.length>0},get isPaused(){return h>0},get history(){return r.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return s&&s.entryId===o.id&&(u.refused={direction:s.direction,code:s.code,targets:s.targets}),u})},get future(){return i.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return s&&s.entryId===o.id&&(u.refused={direction:s.direction,code:s.code,targets:s.targets}),u}).reverse()},get scope(){return n.scope}}}function Xt(e){let n=typeof e.composedPath=="function"?e.composedPath():[],t=n.length>0?n:Ht(e.target);for(let r of t){if(!r||r.nodeType!==1)continue;let i=String(r.tagName||"").toUpperCase();if(i==="INPUT"||i==="TEXTAREA"||i==="SELECT"||r.isContentEditable===!0)return!0;let a=r.getAttribute&&r.getAttribute("contenteditable");if(a!=null&&String(a).toLowerCase()!=="false")return!0}return!1}function Ht(e){let n=[];for(let t=e;t;t=t.parentNode||(t.host??null))n.push(t);return n}function Le(e,n){let t=r=>{let i=e.scope;if(i&&i.nodeType===1&&i.isConnected===!1){n&&n();return}if(r.defaultPrevented||r.isComposing||r.keyCode===229||Xt(r))return;let a=r.target,l=e._config.shadowKeydownIn;if(a&&a.closest&&Array.isArray(l))for(let g of l)try{if(a.closest(g))return}catch{}if(!(r.metaKey||r.ctrlKey))return;let d=(r.key||"").toLowerCase();if(d==="z"&&!r.shiftKey){r.preventDefault(),r.stopPropagation(),e.undo();return}if(d==="z"&&r.shiftKey){r.preventDefault(),r.stopPropagation(),e.redo();return}if(d==="y"&&!r.shiftKey){r.preventDefault(),r.stopPropagation(),e.redo();return}};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)}var ee=[".CodeMirror",".cm-editor",".monaco-editor",".ace_editor",".ql-editor",".tiptap",".ProseMirror",".overtype-input","[data-richclay-active]"],f=null,te=null,qe=null,I=null;function ze(e,n){if(I){if(I.inst===e)return I.cleanup;throw new Error("hyper-undo: another scope already owns the global Cmd+Z binding (bindKeys: true). Stop it first, or use bindKeys: false for additional scopes.")}let t=Le(e,n);return I={inst:e,cleanup:t},t}function Ke(e){I&&I.inst===e&&(I.cleanup(),I=null)}var ne={defaults:{shadowKeydownIn:ee},start(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");if(f){if(te===n)return console.warn("[hyper-undo] start() called again on existing singleton; ignoring new options"),f;throw new Error("hyper-undo: start() called with a different scope while the singleton is already started. Use undo.create({ scope }) for additional scopes, or call undo.stop() first.")}let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||ee};return f=Q(t),f.start(),te=n,e.bindKeys!==!1&&(qe=ze(f,()=>ne.stop())),f},stop(){f&&(Ke(f),qe=null,f.stop(),f=null,te=null)},create(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||ee},r=Q(t),i=null,a={_config:r._config,commit:r.commit,command:r.command,setRecording:r.setRecording,commitCaptured:r.commitCaptured,discardCaptured:r.discardCaptured,flush:r.flush,record:r.record,recordValue:r.recordValue,undo:r.undo,redo:r.redo,clear:r.clear,discard:r.discard,describe:r.describe,pause:r.pause,resume:r.resume,on:r.on,off:r.off,get canUndo(){return r.canUndo},get canRedo(){return r.canRedo},get isPaused(){return r.isPaused},get history(){return r.history},get future(){return r.future},get scope(){return r.scope},start(){e.bindKeys&&(i=ze(r,()=>a.stop())),r.start()},stop(){Ke(r),i=null,r.stop()}};return a},commit(e,n){return f?f.commit(e,n):void 0},command(e,n){return f?f.command(e,n):void 0},setRecording(e){return f?f.setRecording(e):void 0},commitCaptured(e){return f?f.commitCaptured(e):void 0},discardCaptured(){return f?f.discardCaptured():void 0},record(e){return f?f.record(e):void 0},recordValue(e,n){return f?f.recordValue(e,n):void 0},undo(e){return f?f.undo(e):void 0},redo(e){return f?f.redo(e):void 0},clear(){return f?f.clear():void 0},discard(e){return f?f.discard(e):void 0},describe(e){return f?f.describe(e):void 0},pause(){return f?f.pause():void 0},resume(){return f?f.resume():void 0},flush(){return f?f.flush():void 0},on(e,n){return f?f.on(e,n):void 0},off(e,n){return f?f.off(e,n):void 0},get canUndo(){return f?f.canUndo:!1},get canRedo(){return f?f.canRedo:!1},get history(){return f?f.history:[]},get future(){return f?f.future:[]},get isPaused(){return f?f.isPaused:!1}};var Jt=ne;return ht(Gt);})();
|
|
1
|
+
var hyperundo=(()=>{var Y=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var pt=Object.getOwnPropertyNames;var gt=Object.prototype.hasOwnProperty;var ht=(e,n)=>{for(var t in n)Y(e,t,{get:n[t],enumerable:!0})},yt=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of pt(n))!gt.call(e,i)&&i!==t&&Y(e,i,{get:()=>n[i],enumerable:!(r=mt(n,i))||r.enumerable});return e};var bt=e=>yt(Y({},"__esModule",{value:!0}),e);var Qt={};ht(Qt,{default:()=>Zt,undo:()=>oe});function wt(e,n=null){let t=[];if(e.type==="attributes"){let r=e.target,i=e.attributeName,a=e.oldValue,s=r.getAttribute(i);return a==null&&s!=null?t.push({kind:"attr-add",target:r,name:i,newValue:s}):a!=null&&s==null?t.push({kind:"attr-remove",target:r,name:i,oldValue:a}):a!==s&&t.push({kind:"attr-set",target:r,name:i,oldValue:a,newValue:s}),t}if(e.type==="characterData")return t.push({kind:"text",target:e.target,oldValue:e.oldValue,newValue:e.target.data}),t;if(e.type==="childList"){let r=e.target,i=e.nextSibling,a=e.nextSibling;for(;a&&n?.(a);)a=a.nextSibling;let s=e.previousSibling;for(;s&&n?.(s);)s=s.previousSibling;let l=n?Array.from(e.addedNodes).filter(h=>!n(h)):Array.from(e.addedNodes),c=n?Array.from(e.removedNodes).filter(h=>!n(h)):Array.from(e.removedNodes);return l.length>0&&t.push({kind:"add",parent:r,nodes:l,before:i,afterAuthored:a,beforeAuthored:s,record:e}),c.length>0&&t.push({kind:"remove",parent:r,nodes:c,before:i,afterAuthored:a,beforeAuthored:s,record:e}),t}return t}function Ee(e,n=null){let t=[],r=new Map;for(let i of e){if(i.type==="attributes"){let a=i.target,s=i.attributeName,l=r.get(a);l||(l=new Map,r.set(a,l)),l.has(s)||(l.set(s,{idx:t.length,oldValue:i.oldValue}),t.push(null));continue}for(let a of wt(i,n))t.push(a)}for(let[i,a]of r)for(let[s,l]of a){let c=l.oldValue,h=i.getAttribute(s),p=null;c===h?p=null:c==null?p={kind:"attr-add",target:i,name:s,newValue:h}:h==null?p={kind:"attr-remove",target:i,name:s,oldValue:c}:p={kind:"attr-set",target:i,name:s,oldValue:c,newValue:h},t[l.idx]=p}return t.filter(i=>i!=null)}function Se(e){let n=[],t=new Map;for(let i of e){let a=Ae(i);if(a==null){n.push(i);continue}let s=t.get(i.target);s||(s=new Map,t.set(i.target,s));let l=s.get(a);if(l==null){let c=Ne(i);if(c.oldValue===c.newValue)continue;s.set(a,n.length),n.push({...i,...c})}else n[l]={...n[l],newValue:Ne(i).newValue}}let r=[];for(let i of n){if(Ae(i)==null){r.push(i);continue}i.oldValue!==i.newValue&&r.push(vt(i))}return r}var kt=new Set(["attr-set","attr-add","attr-remove","text","value"]);function Ae(e){return kt.has(e.kind)?e.kind==="text"?"#text":e.kind==="value"?`#${e.prop||"value"}`:e.name==null?null:`@${e.name}`:null}function Ne(e){return e.kind==="attr-add"?{oldValue:null,newValue:e.newValue}:e.kind==="attr-remove"?{oldValue:e.oldValue,newValue:null}:{oldValue:e.oldValue,newValue:e.newValue}}function vt(e){return e.kind!=="attr-add"&&e.kind!=="attr-remove"?e:e.oldValue==null&&e.newValue!=null?{...e,kind:"attr-add"}:e.oldValue!=null&&e.newValue==null?{...e,kind:"attr-remove"}:{...e,kind:"attr-set"}}var Te=new WeakMap,At=0;function T(e){let n=Te.get(e);return n||(n=`n${++At}`,Te.set(e,n)),n}function v(e){return!!e&&typeof e=="object"&&typeof e.nodeType=="number"}function Nt(e){return e.kind==="add"||e.kind==="remove"}function Ie(e,n){let t=[],r=e.childNodes;if(!r)return t;for(let i of r)n&&n(i)||t.push(T(i));return t}function K(e,n,t=null,r=null){if(!v(e))return null;if(e.nodeType===3)return`#text:${JSON.stringify(e.data)}`;if(e.nodeType===8)return`#comment:${JSON.stringify(e.data)}`;if(e.nodeType!==1)return`#node:${e.nodeType}`;let i=[];if(e.attributes){for(let l of e.attributes)Et(l.name,e,n,t)||i.push(`${l.name}=${JSON.stringify(l.value)}`);i.sort()}let a=[];if(e.childNodes)for(let l of e.childNodes)St(l,r)||a.push(K(l,n,t,r));return`<${String(e.tagName||"").toLowerCase()}${i.length?` ${i.join(" ")}`:""}>${a.join("")}</>`}function Z(e,n=[]){if(!v(e))return n;if(e.nodeType===1){let t=e.getAttribute&&e.getAttribute("data-id");t&&n.push(t)}if(e.childNodes)for(let t of e.childNodes)Z(t,n);return n}function Et(e,n,t,r=null){if(typeof t!="function")return!1;try{return!!t(e,n,r)}catch{return!1}}function St(e,n){if(typeof n!="function")return!1;try{return!!n(e)}catch{return!1}}function Pe(e,n){if(typeof n!="function")return[];let t=[],r=i=>{if(!v(i))return;let a=!1;try{a=!!n(i)}catch{a=!1}if(a&&t.push(E(i,"protected")),i.childNodes)for(let s of i.childNodes)r(s)};for(let i of e)r(i);return t}function E(e,n,t=null){let r=e;r&&r.nodeType!==1&&(r=r.parentElement);let i=r&&typeof r.closest=="function"?r.closest("[data-id]"):null;return!i&&t&&typeof t.closest=="function"&&(i=t.closest("[data-id]")),{id:(i?i.getAttribute("data-id"):null)||null,kind:n||null}}function Tt(e,n,t=null){return(e||[]).filter(v).map(r=>E(r,n,t))}function z(e){return{replayable:!1,reason:e,steps:[]}}function U(e,n){let t=[[n.afterAuthored,i=>i],[n.beforeAuthored,i=>i+1],[n.before,i=>i]],r=!1;for(let[i,a]of t){if(!v(i))continue;r=!0;let s=e.indexOf(T(i));if(s>=0)return a(s)}return r?null:e.length}function Ce(e,n={}){let t=n.isIgnored||null,r=n.ignoreAttribute||null,i=Se(e),a=[];for(let p of i){if(!Nt(p)){if(!v(p.target))return z("non-dom-target");continue}if(!v(p.parent))return z("non-dom-parent");let y=Array.from(p.nodes||[]).filter(v);if(y.length!==0){if(y.length!==Array.from(p.nodes||[]).length)return z("non-dom-node");a.push({primitive:p,nodes:y,parent:p.parent})}}if(Vt(a))return z("in-record-move");let s=It(a,t);if(!s)return z("ambiguous-structure");let l=Pt(a,s),c=new Map(a.map(p=>[p.primitive,p])),h=[];for(let p of i){let y=c.get(p);if(!y){h.push(Rt(p));continue}let w=l.get(y);if(w){w.at===y&&h.push(w.step);continue}h.push(Ct(y,s.get(y),r,t))}return{replayable:!0,reason:null,steps:h}}function Vt(e){let n=new Map;for(let t of e){let r=t.primitive.record;if(!r)continue;let i=n.get(r);i||(i=new Map,n.set(r,i));for(let a of t.nodes){let s=i.get(a);s||(s=new Set,i.set(a,s)),s.add(t.primitive.kind)}}for(let t of n.values())for(let r of t.values())if(r.size>1)return!0;return!1}function It(e,n){let t=new Map;for(let i of e)t.has(i.parent)||t.set(i.parent,Ie(i.parent,n));let r=new Map;for(let i=e.length-1;i>=0;i--){let a=e[i],s=t.get(a.parent);if(!s)return null;let l=s.slice(),c;if(a.primitive.kind==="add"){let h=a.nodes.map(T);if(!h.every(p=>s.includes(p)))return null;c=s.filter(p=>!h.includes(p))}else{let h=U(l,a.primitive);if(h==null)return null;c=l.slice(),c.splice(h,0,...a.nodes.map(T))}r.set(a,{before:c,after:l}),t.set(a.parent,c)}return r}function Pt(e,n){let t=new Map,r=new Map;e.forEach((a,s)=>{for(let l of a.nodes){let c=T(l);a.primitive.kind==="remove"?t.set(c,{item:a,index:s,node:l}):r.set(c,{item:a,index:s,node:l})}});let i=new Map;for(let[a,s]of t){let l=r.get(a);if(!l||l.index<s.index||s.item.nodes.length!==1||l.item.nodes.length!==1)continue;let c={type:"move",node:s.node,sourceParent:s.item.parent,destParent:l.item.parent,source:n.get(s.item),dest:n.get(l.item),sourceSlot:s.item.primitive,destSlot:l.item.primitive,targets:[E(s.node,"move")]};i.set(s.item,{step:c,at:l.item}),i.set(l.item,{step:c,at:l.item})}return i}function Ct(e,n,t,r){let i=e.primitive.kind;return{type:i==="add"?"add":"restore",parent:e.parent,nodes:e.nodes,seqBefore:n.before,seqAfter:n.after,slot:e.primitive,content:e.nodes.map(a=>K(a,t,e.parent,r)),ids:i==="remove"?e.nodes.flatMap(a=>Z(a)):[],targets:Tt(e.nodes,i==="add"?"added":"removed",e.parent)}}function Rt(e){return{type:e.kind,primitive:e,targets:[E(e.target,e.name||e.prop||"text")]}}function Re(e,n,t={}){if(!e||!e.replayable)return{ok:!1,code:"unsupported",targets:[]};let r={isIgnored:t.isIgnored||null,ignoreAttribute:t.ignoreAttribute||null,isProtected:t.isProtected||null,inScope:t.inScope||(()=>!0),liveNodesWithIds:t.liveNodesWithIds||(()=>[]),sim:new Map,planned:new Map,operations:[]};for(let i=0;i<e.steps.length;i++){let a=e.steps[n==="undo"?e.steps.length-1-i:i],s=xt(a,n,r);if(s)return{ok:!1,code:s.code,targets:s.targets}}return{ok:!0,operations:r.operations}}function M(e,n){return e.sim.has(n)||e.sim.set(n,Ie(n,e.isIgnored)),e.sim.get(n)}function L(e,n){for(let t=e;t;t=t.parentNode)if(n.planned.has(t))return n.planned.get(t);return n.inScope(e)}function Oe(e,n){return n.liveNodesWithIds(e).filter(t=>L(t,n)).length>0}function b(e,n){return{code:e,targets:n||[]}}function Ot(e){return e.kind==="text"?e.target.data:e.kind==="value"?typeof e.read=="function"?e.read(e.target):e.target[e.prop||"value"]:e.target.getAttribute(e.name)}function xt(e,n,t){let r=n==="undo";return e.type==="move"?zt(e,r,t):e.type==="add"?Mt(e,r,t):e.type==="restore"?Lt(e,r,t):_t(e,r,t)}function _t(e,n,t){let r=e.primitive,i=n?r.newValue:r.oldValue,a=n?r.oldValue:r.newValue;return v(r.target)?L(r.target,t)?r.kind==="value"&&typeof r.write=="function"&&typeof r.read!="function"?b("unsupported",e.targets):Ot(r)!==i?b("content-changed",e.targets):(r.kind==="value"?t.operations.push({type:"value",target:r.target,prop:r.prop||"value",value:a,read:r.read||null,write:r.write||null}):r.kind==="text"?t.operations.push({type:"text",target:r.target,data:a}):t.operations.push({type:"attr",target:r.target,name:r.name,value:a??null}),null):b("target-detached",e.targets):b("unsupported",e.targets)}function Mt(e,n,t){if(!v(e.parent)||!L(e.parent,t))return b("target-detached",e.targets);if(n){if(!q(M(t,e.parent),e.seqAfter))return b("structure-changed",e.targets);let l=Pe(e.nodes,t.isProtected);if(l.length>0)return b("protected",l);for(let c=0;c<e.nodes.length;c++)if(K(e.nodes[c],t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[c])return b("content-changed",e.targets);for(let c of e.nodes)t.operations.push({type:"remove",node:c}),t.planned.set(c,!1);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!q(M(t,e.parent),e.seqBefore))return b("structure-changed",e.targets);for(let l of e.nodes)if(l.parentNode)return b("structure-changed",e.targets);let r=e.nodes.flatMap(l=>Z(l));if(r.length>0&&Oe(r,t))return b("duplicate-id",e.targets);let i=U(e.seqBefore,e.slot);if(i==null)return b("unsupported",e.targets);let a=e.seqBefore.slice(),s=i;for(let l of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:l,beforeId:a[s]??null}),a=a.slice(0,s).concat(T(l),a.slice(s)),s+=1,t.planned.set(l,!0);return t.sim.set(e.parent,e.seqAfter.slice()),null}function Lt(e,n,t){if(!v(e.parent)||!L(e.parent,t))return b("target-detached",e.targets);if(n){if(!q(M(t,e.parent),e.seqAfter))return b("structure-changed",e.targets);for(let c=0;c<e.nodes.length;c++){let h=e.nodes[c];if(h.parentNode||K(h,t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[c])return b("content-changed",e.targets)}if(e.ids.length>0&&Oe(e.ids,t))return b("duplicate-id",e.targets);let a=U(e.seqAfter,e.slot);if(a==null)return b("unsupported",e.targets);let s=e.seqAfter.slice(),l=a;for(let c of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:c,beforeId:s[l]??null}),s=s.slice(0,l).concat(T(c),s.slice(l)),l+=1,t.planned.set(c,!0);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!q(M(t,e.parent),e.seqBefore))return b("structure-changed",e.targets);let r=Pe(e.nodes,t.isProtected);if(r.length>0)return b("protected",r);let i=a=>t.planned.get(a)===!0||typeof t.isIgnored=="function"&&t.isIgnored(a);for(let a=0;a<e.nodes.length;a++){let s=e.nodes[a];if(s.parentNode!==e.parent||K(s,t.ignoreAttribute,e.parent,i)!==e.content[a])return b("content-changed",e.targets)}for(let a of e.nodes)t.operations.push({type:"remove",node:a}),t.planned.set(a,!1);return t.sim.set(e.parent,e.seqAfter.slice()),null}function qt(e,n){let t=e.indexOf(n);return t<0?null:e.slice(0,t).concat(e.slice(t+1))}function zt(e,n,t){let r=T(e.node),i=n?e.destParent:e.sourceParent,a=n?e.sourceParent:e.destParent,s=M(t,i),l=M(t,a),c=n?e.dest.after:e.source.before,h=n?e.source.after:e.dest.before,p=n?e.sourceSlot:e.destSlot;if(!v(i)||!v(a)||!L(i,t)||!L(a,t))return b("target-detached",e.targets);if(!q(s,c))return b("structure-changed",e.targets);let y=i===a?qt(l,r):l;if(!q(y,h))return b("structure-changed",e.targets);let w=U(h,p);return w==null?b("unsupported",e.targets):(t.operations.push({type:"insert",parent:a,node:e.node,beforeId:h[w]??null}),t.planned.set(e.node,!0),n?(t.sim.set(a,e.source.before.slice()),i!==a&&t.sim.set(i,e.dest.before.slice())):(t.sim.set(a,e.dest.after.slice()),i!==a&&t.sim.set(i,e.source.after.slice())),null)}function q(e,n){if(!e||!n||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function Kt(e,n){for(let t of e.childNodes||[])if(T(t)===n)return t;return null}function Ve(e,n){typeof e.write=="function"?e.write(e.target,n):e.target[e.prop]=n}function xe(e){let n=[];try{for(let t of e)$t(t,n);return{ok:!0}}catch(t){for(let r=n.length-1;r>=0;r--)try{n[r]()}catch{}return{ok:!1,error:t}}}function $t(e,n){if(e.type==="attr"){let t=e.target.getAttribute(e.name);e.value==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,e.value),n.push(()=>{t==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,t)});return}if(e.type==="text"){let t=e.target.data;e.target.data=e.data,n.push(()=>{e.target.data=t});return}if(e.type==="value"){let t=typeof e.read=="function"?e.read(e.target):e.target[e.prop];Ve(e,e.value),n.push(()=>Ve(e,t));return}if(e.type==="insert"){let t=e.beforeId==null?null:Kt(e.parent,e.beforeId);if(e.beforeId!=null&&!t)throw new Error("hyper-undo: replay anchor vanished");let r=e.node.parentNode,i=e.node.nextSibling;e.parent.insertBefore(e.node,t),n.push(()=>{r?r.insertBefore(e.node,i&&i.parentNode===r?i:null):e.node.parentNode===e.parent&&e.parent.removeChild(e.node)});return}if(e.type==="remove"){let t=e.node.parentNode;if(!t)throw new Error("hyper-undo: replay target is no longer attached");let r=e.node.nextSibling;t.removeChild(e.node),n.push(()=>t.insertBefore(e.node,r))}}var Bt=['[src^="chrome-extension://"]','[href^="chrome-extension://"]','[src^="moz-extension://"]','[href^="moz-extension://"]','[src^="safari-web-extension://"]','[href^="safari-web-extension://"]','[id="1p-menu-live-region"]',"com-1password-button","com-1password-menu","com-1password-notification","grammarly-extension","grammarly-desktop-integration","lt-div","lt-card","lt-toolbar","lt-highlighter","[data-lastpass-root]","[data-lastpass-icon-root]","[data-dashlane-shadowhost]","[data-klarna-extension]",'[class*="klarna-extension"]',".skiptranslate","#goog-gt-tt",".goog-te-banner-frame",".goog-te-balloon-frame","style.darkreader","style[data-darkreader-mode]","style[data-darkreader-scheme]","#loom-companion-mv3","loom-container","[ext-id]"],Dt=["data-grammarly","data-lt","data-1p","data-com-onepassword","data-lastpass","data-lp","data-kwimpala","data-bitwarden","data-bw","data-dashlane","data-np","data-protonpass","data-proton-pass","data-keeper","data-rf","data-roboform","data-honey","data-rakuten","data-capital-one","data-wikibuy","data-klarna","data-darkreader","data-evernote","data-pocket","data-pin"],_e=Bt.join(","),Me=new RegExp("^(?:"+Dt.join("|")+")(?:-|$)");var an=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"]})}),Ut=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"]);function j(e,n){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(n)||e.hasAttribute?.(n))}function Q(e,n){if(j(e,n))return!0;for(let[t,r]of Object.entries(Ut))if(r.includes(n)&&j(e,t))return!0;return!1}function Le(e){return e==="clay"||jt.includes(e)}var Ft=["mutations-ignore","save-remove","save-ignore","save-freeze","no-undo","no-watch"];function Wt(){if(typeof window>"u")return null;let e=window.clay?.region||window.hyperclay?.region;return e&&typeof e.resolveRegionPolicy=="function"?e.resolveRegionPolicy:null}function ee(e){let n=Wt();if(n)try{if(!n(e).undoable)return!0}catch{}let t=e&&e.nodeType!==1?e.parentElement:e;if(t&&t.closest&&t.closest(_e))return!0;for(;t&&t.nodeType===1;){if(Q(t,"no-undo")||Q(t,"no-watch"))return!0;for(let r of Ft)if(j(t,r))return!0;t=t.parentElement}return!1}function Xt(e){let n=e.target,t=n.cloneNode(!1),r=t;for(;n.parentElement;){n=n.parentElement;let i=n.cloneNode(!1);i.appendChild(t),t=i}return e.oldValue==null?r.removeAttribute(e.attributeName):r.setAttribute(e.attributeName,e.oldValue),ee(r)}function F(e,n,t){if(t?.type==="attributes"&&Le(t.attributeName)){if(ee(e)&&Xt(t))return!0}else if(ee(e))return!0;if(t&&t.type==="attributes"){if(t.attributeName&&Me.test(t.attributeName.toLowerCase()))return!0;if(n)try{if(n(t.attributeName,t.target))return!0}catch{}}return!1}function qe(){let e=new Map;function n(i,a){let s=e.get(i);return s||(s=new Set,e.set(i,s)),s.add(a),()=>t(i,a)}function t(i,a){let s=e.get(i);s&&s.delete(a)}function r(i,a){let s=e.get(i);if(s)for(let l of Array.from(s))try{l(a)}catch(c){console.error("[hyper-undo] listener threw",c)}}return{on:n,off:t,emit:r}}var Ht={maxHistory:100,idleWindowMs:500,idleLabel:"Edit",recording:"automatic",ignoreAttribute:null,isProtected:null,ignoreNode:null,debug:!1};function te(e){let n={...Ht,...e};if(!n.scope)throw new Error("hyper-undo: scope is required");let t=qe(),r=[],i=[],a=`u${Math.random().toString(36).slice(2,8)}`,s=0,l=null,c=[],h=null,p=null,y=0,w=!1,P=n.recording==="commands"?"commands":"automatic",A=null,C=!1;function k(...o){n.debug&&console.log("[hyper-undo]",...o)}function De(){w||(w=!0,p=Ue(R),p.observe(n.scope,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),k("started"))}function Ue(o){let u=typeof document<"u"&&n.scope===document.body,d=typeof window<"u"&&(window.clay?.Mutation||window.hyperclay?.Mutation)||null;return u&&d&&typeof d.createObserver=="function"?(k("sourcing records from the platform Mutation hub (shared observer)"),d.createObserver(o)):new MutationObserver(o)}function ie(){w&&(w=!1,p&&(p.disconnect(),p=null),O(),r.length=0,i.length=0,c=[],l=null,A=null,C=!1,y=0,k("stopped"))}function je(){let o=n.scope;return!!(o&&o.nodeType===1&&o.isConnected===!1)}function R(o){ae(o,!1)}function ae(o,u){if(A){for(let f of o)A.records.push(f);return}if(P==="commands"||y>0)return;let d=W(Fe(o),u);if(d.length>0){for(let f of d)c.push(f);ue()}}function Fe(o){return typeof n.ignoreNode!="function"?o:o.filter(u=>{if(u.type!=="childList")return!0;let d=[...u.addedNodes,...u.removedNodes];return d.length===0?!0:!d.every(f=>We(f))})}function We(o){try{return!!n.ignoreNode(o)}catch{return!1}}function W(o,u=!1){let d=lt(o),f=o.filter(g=>(G(g.target)||d(g.target)||u&&ke(g.target))&&!F(g.target,n.ignoreAttribute,g));return Ee(f,g=>F(g,n.ignoreAttribute))}function ue(){O(),h=setTimeout(se,n.idleWindowMs)}function O(){h!=null&&(clearTimeout(h),h=null)}function se(){if(h=null,c.length===0)return;let o=c;c=[],$(n.idleLabel,o)}function $(o,u){let d=Ce(u,{isIgnored:X,ignoreAttribute:le});if(d.steps.length===0)return k("commit",o,"with nothing to record"),t.emit("commit"),null;let f={id:`${a}-${++s}`,label:o,timestamp:Date.now(),primitives:u,certificate:d};for(r.push(f),i.length=0,l=null;r.length>n.maxHistory;)r.shift();return k("commit",o,"primitives:",u.length),t.emit("commit"),f}function X(o){return F(o,n.ignoreAttribute)}function le(o,u,d=null){if(typeof n.ignoreAttribute!="function")return!1;try{return!!n.ignoreAttribute(o,u,d)}catch{return!1}}function Xe(o){if(typeof n.isProtected!="function")return!1;try{return!!n.isProtected(o)}catch{return!1}}function He(o,u){if(!w)throw new Error("hyper-undo: scope not started");if(P==="commands")return fe(o,u,{honorPause:!0,receipt:!1});R(p.takeRecords()),x();let d=y===0?de():null,f=u();if(f&&typeof f.then=="function")throw new Error("hyper-undo: commit() fn must be synchronous; returned a Promise");if(ae(p.takeRecords(),!0),d!=null&&ce(d),c.length===0){t.emit("commit");return}O();let g=c;c=[],$(o,g)}function Je(o){if(!w)throw new Error("hyper-undo: scope not started");if(!p)return;if(y>1){p.takeRecords();return}x();let u=W(p.takeRecords(),!0);u.length!==0&&(O(),$(o,u))}function Ge(){p&&p.takeRecords()}function H(){let o=n.scope;return o&&o.ownerDocument||(typeof document<"u"?document:null)}function B(){let o=H();return!o||!o.head||typeof o.head.querySelector!="function"?null:o.head.querySelector("title")}function de(){let o=B();return o?o.textContent:null}function ce(o){let u=B();if(!u||o==null)return;let d=u.textContent;d!==o&&pe({kind:"value",target:u,prop:"textContent",oldValue:o,newValue:d})}function Ye(o){if(!o)return null;let u=H();if(!u||o.target!==u||o.prop!=="title")return o;let d=B();return d?{kind:"value",target:d,prop:"textContent",oldValue:o.oldValue,newValue:o.newValue}:null}function Ze(){if(typeof window>"u")return!1;let o=window.clay?.effect||window.hyperclay?.effect;return!!(o&&o.running)}function Qe(){p&&R(p.takeRecords()),x(),A={records:[],primitives:[]}}function et(){let o=A;if(A=null,!o)return[];let u=W(o.records,!0);for(let d of o.primitives)u.push(d);return u}function fe(o,u,{honorPause:d,receipt:f}){if(typeof u!="function")throw new Error("hyper-undo: command() needs a synchronous function");if(A)throw new Error("hyper-undo: command() cannot nest inside another command");if(C)throw new Error("hyper-undo: command() cannot run during undo or redo");if(Ze())throw new Error("hyper-undo: command() cannot run inside a derived-effect context");if(u.constructor&&u.constructor.name==="AsyncFunction")throw new Error("hyper-undo: command() fn must be synchronous; it was declared async");let g=d&&y>0,N=g?null:de();Qe();let S=[],V=null,_;try{try{_=u()}catch(ve){V=ve}if(p&&R(p.takeRecords()),_&&typeof _.then=="function"){try{_.then(void 0,()=>{})}catch{}V||(V=new Error("hyper-undo: command() fn must be synchronous; returned a Promise"))}g||ce(N)}finally{S=et()}let D=g||S.length===0?null:$(o,S);if(V)throw V;return f?D?{id:D.id,label:D.label}:null:D}function tt(o,u){if(!w)throw new Error("hyper-undo: scope not started");return fe(o,u,{honorPause:!1,receipt:!0})}function nt(o){if(o!=="automatic"&&o!=="commands")throw new Error("hyper-undo: setRecording() takes 'automatic' or 'commands'");if(A)throw new Error("hyper-undo: setRecording() cannot change while a command is running");return P===o||(x(),P=o,k("recording",o)),P}function me(o){if(!w||!o||!A&&(y>0||P==="commands"))return;let u=Ye(o);u&&pe(u)}function pe(o){if(A){A.primitives.push(o);return}c.push(o),ue()}function rt(o,{prop:u="value",oldValue:d,newValue:f,read:g,write:N}={}){!o||d===f||me({kind:"value",target:o,prop:u,oldValue:d,newValue:f,read:g,write:N})}function x(){y===0&&p&&R(p.takeRecords()),c.length!==0&&(O(),se())}function ge(){y===0&&p&&R(p.takeRecords()),y++,k("paused",y)}function he(){y!==0&&(y--,y===0&&p&&p.takeRecords(),k("resumed",y))}function ye(o,u){if(je())return ie(),{ok:!1,code:"disconnected"};x();let d=o==="undo"?r:i,f=o==="undo"?i:r,g=d.at(-1);if(!g)return{ok:!1,code:"empty"};if(u&&u!==g.id){let _=be(u)||g;return J(_,o,"stale-entry")}let N;C=!0;try{N=Re(g.certificate,o,{isIgnored:X,ignoreAttribute:le,isProtected:Xe,inScope:dt,liveNodesWithIds:ct})}finally{C=!1}if(!N.ok)return J(g,o,N.code,N.targets);ge();let S;C=!0;try{S=xe(N.operations)}finally{C=!1,he()}if(!S.ok)return k(`${o} failed and was rolled back`,S.error),J(g,o,"replay-error");d.pop(),f.push(g),l=null;let V={ok:!0,entryId:g.id,label:g.label,direction:o};return k(o,g.label),t.emit(o,V),V}function ot(o){return ye("undo",o&&o.entryId)}function it(o){return ye("redo",o&&o.entryId)}function be(o){return r.find(u=>u.id===o)||i.find(u=>u.id===o)||null}function J(o,u,d,f=[]){return l={entryId:o.id,direction:u,code:d,targets:f},k("refused",u,d),t.emit("refused",{entryId:o.id,label:o.label,direction:u,code:d,targets:f}),{ok:!1,code:d,entryId:o.id,label:o.label,direction:u}}function at(o){if(!l||l.entryId!==o)return{ok:!1,code:"not-refused",entryId:o};let u=l.direction,d=u==="undo"?r:i,f=d.at(-1);return!f||f.id!==o?{ok:!1,code:"stale-entry",entryId:o}:(d.pop(),l=null,k("discarded",f.label),t.emit("discard",{entryId:o,label:f.label,direction:u}),{ok:!0,entryId:o,direction:u})}function ut(o){let u=be(o);if(!u||!u.certificate||!u.certificate.replayable)return null;let d=l&&l.entryId===u.id?{direction:l.direction,code:l.code,targets:(l.targets||[]).map(f=>({id:f.id??null,kind:f.kind??null}))}:null;return{id:u.id,label:u.label,timestamp:u.timestamp,refused:d,steps:u.certificate.steps.map(st)}}function st(o){if(o.type==="move")return{kind:"move",node:{id:E(o.node).id},from:{id:E(o.sourceParent).id},to:{id:E(o.destParent).id}};if(o.type==="add"||o.type==="restore")return{kind:o.type==="add"?"add":"remove",parent:{id:E(o.parent).id},nodes:o.nodes.map((N,S)=>({id:E(N).id,html:o.content[S]??null}))};let u=o.primitive,d={id:E(u.target).id},f=u.oldValue??null,g=u.newValue??null;return o.type==="value"?{kind:"value",target:d,prop:u.prop??"value",before:f,after:g}:o.type==="text"?{kind:"text",target:d,before:f,after:g}:o.type==="attr-set"||o.type==="attr-add"||o.type==="attr-remove"?{kind:"attribute",target:d,name:u.name??null,before:f,after:g}:{kind:o.type,target:d,before:f,after:g}}function lt(o){let u=new Set,d=!0;for(;d;){d=!1;for(let f of o)if(!(f.type!=="childList"||!f.removedNodes?.length)&&!(!G(f.target)&&!we(f.target,u)))for(let g of f.removedNodes)u.has(g)||(u.add(g),d=!0)}return f=>!G(f)&&we(f,u)}function we(o,u){for(let d=o;d;d=d.parentNode)if(u.has(d))return!0;return!1}function G(o){let u=n.scope;return!u||!o?!1:o===u||typeof u.contains=="function"&&u.contains(o)}function ke(o){let u=H(),d=u&&u.head;if(!d||!o)return!1;let f=o.nodeType===1?o:o.parentElement;for(;f&&f!==d;f=f.parentElement)if(f.localName==="title")return!1;return f===d}function dt(o){let u=n.scope;return!o||!u?!1:o===u||B()===o||ke(o)?!0:typeof u.contains=="function"?u.contains(o):!1}function ct(o){let u=n.scope;if(!o||o.length===0||typeof u?.querySelectorAll!="function")return[];let d=new Set(o),f=[];for(let g of u.querySelectorAll("[data-id]"))d.has(g.getAttribute("data-id"))&&(X(g)||f.push(g));return f}function ft(){p&&p.takeRecords(),r.length=0,i.length=0,c=[],l=null,O(),k("cleared"),t.emit("clear")}return{_config:n,start:De,stop:ie,commit:He,commitCaptured:Je,discardCaptured:Ge,flush:x,command:tt,setRecording:nt,record:me,recordValue:rt,undo:ot,redo:it,clear:ft,discard:at,describe:ut,pause:ge,resume:he,on:t.on,off:t.off,get canUndo(){return r.length>0},get canRedo(){return i.length>0},get isPaused(){return y>0},get history(){return r.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return l&&l.entryId===o.id&&(u.refused={direction:l.direction,code:l.code,targets:l.targets}),u})},get future(){return i.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return l&&l.entryId===o.id&&(u.refused={direction:l.direction,code:l.code,targets:l.targets}),u}).reverse()},get scope(){return n.scope}}}var Jt=new Set(["checkbox","radio","button","submit","reset","image","file","range","color"]);function Gt(e){let n=typeof e.composedPath=="function"?e.composedPath():[],t=n.length>0?n:Yt(e.target);for(let r of t){if(!r||r.nodeType!==1)continue;let i=String(r.tagName||"").toUpperCase();if(i==="TEXTAREA"||i==="SELECT"||i==="INPUT"&&!Jt.has(String(r.type||r.getAttribute?.("type")||"text").toLowerCase())||r.isContentEditable===!0)return!0;let a=r.getAttribute&&r.getAttribute("contenteditable");if(a!=null&&String(a).toLowerCase()!=="false")return!0}return!1}function Yt(e){let n=[];for(let t=e;t;t=t.parentNode||(t.host??null))n.push(t);return n}function ze(e,n){let t=r=>{let i=e.scope;if(i&&i.nodeType===1&&i.isConnected===!1){n&&n();return}if(r.defaultPrevented||r.isComposing||r.keyCode===229||Gt(r))return;let a=r.target,s=e._config.shadowKeydownIn;if(a&&a.closest&&Array.isArray(s))for(let h of s)try{if(a.closest(h))return}catch{}if(!(r.metaKey||r.ctrlKey))return;let c=(r.key||"").toLowerCase();if(c==="z"&&!r.shiftKey){r.preventDefault(),r.stopPropagation(),e.undo();return}if(c==="z"&&r.shiftKey){r.preventDefault(),r.stopPropagation(),e.redo();return}if(c==="y"&&!r.shiftKey){r.preventDefault(),r.stopPropagation(),e.redo();return}};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)}var ne=[".CodeMirror",".cm-editor",".monaco-editor",".ace_editor",".ql-editor",".tiptap",".ProseMirror",".overtype-input","[data-richclay-active]"],m=null,re=null,Ke=null,I=null;function $e(e,n){if(I){if(I.inst===e)return I.cleanup;throw new Error("hyper-undo: another scope already owns the global Cmd+Z binding (bindKeys: true). Stop it first, or use bindKeys: false for additional scopes.")}let t=ze(e,n);return I={inst:e,cleanup:t},t}function Be(e){I&&I.inst===e&&(I.cleanup(),I=null)}var oe={defaults:{shadowKeydownIn:ne},start(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");if(m){if(re===n)return console.warn("[hyper-undo] start() called again on existing singleton; ignoring new options"),m;throw new Error("hyper-undo: start() called with a different scope while the singleton is already started. Use undo.create({ scope }) for additional scopes, or call undo.stop() first.")}let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||ne};return m=te(t),m.start(),re=n,e.bindKeys!==!1&&(Ke=$e(m,()=>oe.stop())),m},stop(){m&&(Be(m),Ke=null,m.stop(),m=null,re=null)},create(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||ne},r=te(t),i=null,a={_config:r._config,commit:r.commit,command:r.command,setRecording:r.setRecording,commitCaptured:r.commitCaptured,discardCaptured:r.discardCaptured,flush:r.flush,record:r.record,recordValue:r.recordValue,undo:r.undo,redo:r.redo,clear:r.clear,discard:r.discard,describe:r.describe,pause:r.pause,resume:r.resume,on:r.on,off:r.off,get canUndo(){return r.canUndo},get canRedo(){return r.canRedo},get isPaused(){return r.isPaused},get history(){return r.history},get future(){return r.future},get scope(){return r.scope},start(){e.bindKeys&&(i=$e(r,()=>a.stop())),r.start()},stop(){Be(r),i=null,r.stop()}};return a},commit(e,n){return m?m.commit(e,n):void 0},command(e,n){return m?m.command(e,n):void 0},setRecording(e){return m?m.setRecording(e):void 0},commitCaptured(e){return m?m.commitCaptured(e):void 0},discardCaptured(){return m?m.discardCaptured():void 0},record(e){return m?m.record(e):void 0},recordValue(e,n){return m?m.recordValue(e,n):void 0},undo(e){return m?m.undo(e):void 0},redo(e){return m?m.redo(e):void 0},clear(){return m?m.clear():void 0},discard(e){return m?m.discard(e):void 0},describe(e){return m?m.describe(e):void 0},pause(){return m?m.pause():void 0},resume(){return m?m.resume():void 0},flush(){return m?m.flush():void 0},on(e,n){return m?m.on(e,n):void 0},off(e,n){return m?m.off(e,n):void 0},get canUndo(){return m?m.canUndo:!1},get canRedo(){return m?m.canRedo:!1},get history(){return m?m.history:[]},get future(){return m?m.future:[]},get isPaused(){return m?m.isPaused:!1}};var Zt=oe;return bt(Qt);})();
|
|
2
2
|
|
|
3
3
|
// Auto-export to window unless suppressed by loader.
|
|
4
4
|
if (!window.__hyperclayNoAutoExport) {
|