@panphora/clayjs 1.25.0 → 1.25.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 +4432 -3831
- package/dist/m/attrs/{save-freeze-MH3AOD56.js → save-freeze-PUYX32AK.js} +1 -1
- package/dist/m/{c-XHZIKRCV.js → c-2A2ATCIH.js} +1 -1
- package/dist/m/{c-BOMQIQ3V.js → c-2EFMJYGJ.js} +1 -1
- package/dist/m/{c-JD2VFAYG.js → c-2GB34XL4.js} +2 -2
- package/dist/m/{c-CITLTVQ4.js → c-2TJCFPX4.js} +1 -1
- package/dist/m/c-33SS5A4Y.js +1 -0
- package/dist/m/{c-V2FPBRO6.js → c-34J5HC7N.js} +1 -1
- package/dist/m/{c-ZEA3DCG3.js → c-3AAQJAKJ.js} +1 -1
- package/dist/m/c-3F3AADKG.js +1 -0
- package/dist/m/{c-GDNZEOOZ.js → c-3WX5FABT.js} +1 -1
- package/dist/m/{c-QWB53KRW.js → c-3XNTQQEJ.js} +1 -1
- package/dist/m/{c-AI3H6ETU.js → c-3Y234AUB.js} +2 -2
- package/dist/m/{c-GEAG5XAK.js → c-42RLKGEY.js} +1 -1
- package/dist/m/{c-XQTERKQA.js → c-44WITKWQ.js} +1 -1
- package/dist/m/c-47M4QHCK.js +1 -0
- package/dist/m/{c-UOUUI265.js → c-4M2T676V.js} +1 -1
- package/dist/m/{c-3E2IK5HU.js → c-4NAYDOWH.js} +1 -1
- package/dist/m/{c-TLQINES7.js → c-4OZZ7ENT.js} +2 -2
- package/dist/m/{c-QDVG4NAZ.js → c-5IIEOPIV.js} +1 -1
- package/dist/m/{c-4Q6QIODW.js → c-755ZOHOM.js} +1 -1
- package/dist/m/c-7Q4XYDF4.js +1 -0
- package/dist/m/c-7RHOMAMR.js +1 -0
- package/dist/m/{c-BCWYEG6P.js → c-7Z2625LX.js} +1 -1
- package/dist/m/{c-C6YZNU6E.js → c-A3OKSYRI.js} +1 -1
- package/dist/m/{c-RGAALCDU.js → c-A5IYL7JI.js} +1 -1
- package/dist/m/c-A5LASUEZ.js +1 -0
- package/dist/m/c-AQVQKFKB.js +1 -0
- package/dist/m/{c-IESDKFO6.js → c-ASGHHLFX.js} +1 -1
- package/dist/m/c-ASMLERFA.js +7 -0
- package/dist/m/{c-ORLPQFNU.js → c-AZM34SPO.js} +1 -1
- package/dist/m/{c-TCFVG3I4.js → c-BHLYQGTA.js} +1 -1
- package/dist/m/{c-ZORVIXUR.js → c-C27EVUQ6.js} +1 -1
- package/dist/m/{c-SUAC5RSG.js → c-C5UGNOC2.js} +1 -1
- package/dist/m/c-C6DXZIXD.js +1 -0
- package/dist/m/{c-WSTUCBHV.js → c-CPRGR2II.js} +1 -1
- package/dist/m/{c-NFQFV7OP.js → c-D2OPWOWO.js} +1 -1
- package/dist/m/{c-PRZNJUYZ.js → c-D4N4UJCQ.js} +2 -2
- package/dist/m/{c-D62HRSZK.js → c-DAUQ6JZ3.js} +1 -1
- package/dist/m/{c-5PZYDWTW.js → c-DDCYVLGG.js} +1 -1
- package/dist/m/{c-FBOO2UY3.js → c-DVMDYRAE.js} +1 -1
- package/dist/m/{c-WGQVSKKC.js → c-DYTBSJBI.js} +1 -1
- package/dist/m/{c-O2QZDVZ2.js → c-EEWPNUM2.js} +1 -1
- package/dist/m/{c-MFB74XVN.js → c-EHAR4RJJ.js} +2 -2
- package/dist/m/c-EIDZHQHZ.js +1 -0
- package/dist/m/c-ELXMSEN5.js +1 -0
- package/dist/m/c-FC5RUFPR.js +1 -0
- package/dist/m/{c-V4B3RUWB.js → c-GFASNR55.js} +1 -1
- package/dist/m/{c-4AE2A2LK.js → c-GNFDX6SU.js} +1 -1
- package/dist/m/{c-UD4VDBGJ.js → c-H3M6UDNV.js} +1 -1
- package/dist/m/{c-MUM53J5J.js → c-H4M2T4A6.js} +1 -1
- package/dist/m/{c-U7F66I64.js → c-HYNM5U6B.js} +1 -1
- package/dist/m/c-J2YYLEVM.js +1 -0
- package/dist/m/c-J2ZW4HMR.js +1 -0
- package/dist/m/{c-WCG6AKA7.js → c-JC4RZW4E.js} +1 -1
- package/dist/m/c-K2ZHQMPF.js +1 -0
- package/dist/m/{c-Z2OZFX3N.js → c-L6KVXPBO.js} +1 -1
- package/dist/m/{c-JWW6BHWD.js → c-LUBZU4AZ.js} +4 -4
- package/dist/m/{c-SEVOS4UE.js → c-LYNLY3MR.js} +1 -1
- package/dist/m/{c-NADLYVAH.js → c-MHTO3QAD.js} +1 -1
- package/dist/m/{c-SFYTKRU7.js → c-MKAUC6DB.js} +1 -1
- package/dist/m/c-MLMJUNRV.js +1 -0
- package/dist/m/{c-WDFQ7PBU.js → c-MMEVDN6D.js} +1 -1
- package/dist/m/{c-KYTVZT4D.js → c-NW4ZFKCY.js} +1 -1
- package/dist/m/{c-YFO6ZJLQ.js → c-O3DPFZCE.js} +1 -1
- package/dist/m/c-O4YIDULY.js +1 -0
- package/dist/m/c-OZOACVUD.js +1 -0
- package/dist/m/{c-MV7TEUTD.js → c-OZVK3TFI.js} +1 -1
- package/dist/m/c-PP3CUF3U.js +1 -0
- package/dist/m/{c-GY4BREDT.js → c-QL4NYM2L.js} +1 -1
- package/dist/m/c-RES2S5Q3.js +1 -0
- package/dist/m/c-RFGELYEU.js +2 -0
- package/dist/m/c-RGFPLQGV.js +1 -0
- package/dist/m/{c-FKTALXNV.js → c-STAPQ2X6.js} +1 -1
- package/dist/m/c-SYVF6ZMF.js +1 -0
- package/dist/m/{c-X3V4RWMA.js → c-T5IWJOMW.js} +1 -1
- package/dist/m/{c-DT7E76Z2.js → c-T7LOTEWO.js} +1 -1
- package/dist/m/{c-SFZRY6RT.js → c-TWB5ZQU4.js} +1 -1
- package/dist/m/c-U35T5NAY.js +1 -0
- package/dist/m/c-UW6MMZ4V.js +1 -0
- package/dist/m/c-VGG3UR7I.js +1 -0
- package/dist/m/c-VU4WEWPH.js +4 -0
- package/dist/m/{c-5Q5XBN56.js → c-W7LWCJHD.js} +1 -1
- package/dist/m/c-WOJ2RTV4.js +1 -0
- package/dist/m/{c-ZJG6C2WL.js → c-WOWGGNCJ.js} +1 -1
- package/dist/m/{c-SXZYVXD6.js → c-XCOQNISP.js} +1 -1
- package/dist/m/{c-IL5IVTOG.js → c-XS7G6U3Z.js} +1 -1
- package/dist/m/{c-HGG7M2S3.js → c-Y3J5LDKB.js} +1 -1
- package/dist/m/{c-JB5YU57S.js → c-Y3MPVURA.js} +1 -1
- package/dist/m/c-Y6HH7LTM.js +1 -0
- package/dist/m/{c-52OC3OH3.js → c-YRDKVEGR.js} +1 -1
- package/dist/m/{c-WVCT3ITX.js → c-YZGWSCMT.js} +1 -1
- package/dist/m/{c-YX2MC7YL.js → c-ZJ7726FO.js} +1 -1
- package/dist/m/core/{admin-attrs-ZI6K6UGM.js → admin-attrs-43JBA6JB.js} +1 -1
- package/dist/m/core/{autosave-BSM2ABJL.js → autosave-HD7Y7UNV.js} +1 -1
- package/dist/m/core/{conflict-notice-7EQLDYPA.js → conflict-notice-Y2NTMDGJ.js} +1 -1
- package/dist/m/core/{persist-2SZO3PCE.js → persist-MX3VYVBN.js} +1 -1
- package/dist/m/core/{save-K6Q47J2X.js → save-JZ7R4ET2.js} +1 -1
- package/dist/m/core/{save-core-U3Z44XBO.js → save-core-I4N6S4ED.js} +1 -1
- package/dist/m/core/{site-edits-CFMF6GHD.js → site-edits-TIJDPG6H.js} +1 -1
- package/dist/m/core/{snapshot-PWCHYFL6.js → snapshot-N5MKDGNI.js} +1 -1
- package/dist/m/core/{unsaved-warning-2WRZLJH5.js → unsaved-warning-BP6ZY3PG.js} +1 -1
- package/dist/m/internals/{index-FSLC4M7J.js → index-3LAVREAU.js} +1 -1
- package/dist/m/{loader-RC54UV7H.js → loader-7ORQVRCK.js} +1 -1
- package/dist/m/manifest-A27A4278.js +1 -0
- package/dist/m/manifest-edit-E8A61EB4.js +1 -0
- package/dist/m/manifest.json +1099 -1039
- package/dist/m/page/{editor-PKSPJ2XJ.js → editor-HS2CAV3W.js} +5 -5
- package/dist/m/plugins/{ai-edit-3LG6MGS3.js → ai-edit-WDV2GLDU.js} +2 -2
- package/dist/m/plugins/{cms-T2HLI7JG.js → cms-4KET6RZT.js} +9 -9
- package/dist/m/plugins/{derive-7DR5TUDH.js → derive-R4USHZ7P.js} +1 -1
- package/dist/m/plugins/{indicator-CTKX4EY7.js → indicator-OLPZ4WFI.js} +1 -1
- package/dist/m/plugins/{live-IFLL6YN5.js → live-CO4VJS46.js} +1 -1
- package/dist/m/plugins/{menu-YJZ3JWBC.js → menu-ESEFQARM.js} +1 -1
- package/dist/m/plugins/{page-GTDPYGE4.js → page-L3VKIQU2.js} +2 -2
- package/dist/m/plugins/{page-view-NMCCU6MF.js → page-view-6KNTXABH.js} +1 -1
- package/dist/m/plugins/{people-6WIWCZEG.js → people-EBWE337I.js} +1 -1
- package/dist/m/plugins/quickcrop-VNRXGRPC.js +26 -0
- package/dist/m/plugins/{richclay-L3BZMX4I.js → richclay-V6WKJTUF.js} +17 -17
- package/dist/m/plugins/sortable-BAG3MSWS.js +1 -0
- package/dist/m/plugins/{source-7LSGOV46.js → source-OYHDXKTB.js} +1 -1
- package/dist/m/plugins/undo-WUK2NLBA.js +1 -0
- package/dist/m/plugins/{upgrade-MMPZUCDM.js → upgrade-SZQJYEQQ.js} +1 -1
- package/dist/m/plugins/{visitor-drafts-V5YB7XDH.js → visitor-drafts-ZE6PCAFP.js} +2 -2
- package/dist/m/plugins/{visitor-menu-QDV2MYJN.js → visitor-menu-5XY57JQA.js} +1 -1
- package/dist/m/plugins/{wire-3YGUO3GE.js → wire-S5ATC4QI.js} +1 -1
- package/dist/m/reader-core-AHOAP5DH.js +77 -0
- package/dist/m/sync/{live-sync-XMXXZS3G.js → live-sync-DX4K5GDB.js} +1 -1
- package/dist/m/ui/index-G7ZJXNMG.js +1 -0
- package/dist/m/vendor/{sap-core.vendor-JANUQULT.js → sap-core.vendor-5TWOJYVM.js} +4 -4
- package/dist/offline-manifest.json +707 -677
- package/dist/server/core.cjs +4245 -2614
- package/dist/server/markdown.cjs +1 -0
- package/dist/server/markdown.mjs +7 -0
- package/docs/guide.md +26 -37
- package/entries/clay-data.js +1 -1
- package/entries/sap.js +5 -5
- package/package.json +6 -2
- package/packed-contract.json +3 -0
- package/src/attrs/save-freeze.js +1 -1
- package/src/core/admin-contenteditable.js +1 -1
- package/src/core/admin-inputs.js +1 -1
- package/src/core/admin-onclick.js +1 -1
- package/src/core/admin-resources.js +5 -2
- package/src/core/conflict-notice-ui.js +59 -34
- package/src/core/save.js +9 -9
- package/src/core/snapshot.js +56 -43
- package/src/core/stale-host-notice.js +20 -7
- package/src/page/editor.js +10 -4
- package/src/page/import-markdown.js +22 -8
- package/src/page/save-projection.js +1 -1
- package/src/plugins/quickcrop.js +128 -69
- package/src/plugins/sortable.js +25 -9
- package/src/server/markdown/index.js +23 -0
- package/src/sync/conflicts.js +3 -1
- package/src/sync/data-guard-notice.js +137 -18
- package/src/ui/bevel-controls.js +4 -1
- package/src/ui/dialogs.js +11 -7
- package/src/ui/modal.js +9 -7
- package/src/ui/toast.js +67 -32
- package/src/vendor/hyper-html-api-data.vendor.js +1 -1
- package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
- package/src/vendor/hyper-undo.vendor.js +1 -1
- package/src/vendor/hypercms.vendor.js +7 -7
- package/src/vendor/richclay.vendor.js +16 -16
- package/src/vendor/sap-core.vendor.js +4 -4
- package/tool-generation/context.md +69 -0
- package/tool-generation/system.md +1 -1
- package/dist/m/c-277QP5ET.js +0 -1
- package/dist/m/c-5SZ6KFR5.js +0 -1
- package/dist/m/c-CU33V6RW.js +0 -4
- package/dist/m/c-CVSWLX3X.js +0 -1
- package/dist/m/c-DXPOFLEJ.js +0 -1
- package/dist/m/c-EODTTNVA.js +0 -1
- package/dist/m/c-ESK4S67I.js +0 -1
- package/dist/m/c-FDWR3FL7.js +0 -1
- package/dist/m/c-FJDTDGDA.js +0 -1
- package/dist/m/c-FYDKYW6E.js +0 -1
- package/dist/m/c-HKSLOVU4.js +0 -1
- package/dist/m/c-IJHF4IO6.js +0 -1
- package/dist/m/c-IUL7PU4P.js +0 -1
- package/dist/m/c-K4M76VPM.js +0 -7
- package/dist/m/c-M7ITYKMF.js +0 -1
- package/dist/m/c-MR75YPRT.js +0 -1
- package/dist/m/c-NHXOBD6A.js +0 -1
- package/dist/m/c-NVU3DORS.js +0 -1
- package/dist/m/c-PNZIJFG7.js +0 -1
- package/dist/m/c-RHPHMTF2.js +0 -2
- package/dist/m/c-RWJ3OSCP.js +0 -1
- package/dist/m/c-SGG6MUXW.js +0 -1
- package/dist/m/c-SXNSSHPP.js +0 -1
- package/dist/m/c-TFLRT5JX.js +0 -1
- package/dist/m/c-U65PREMC.js +0 -1
- package/dist/m/c-VMXCX52Q.js +0 -1
- package/dist/m/c-YYGUHSZR.js +0 -1
- package/dist/m/manifest-3B84C829.js +0 -1
- package/dist/m/manifest-edit-1CB79AD4.js +0 -1
- package/dist/m/plugins/quickcrop-X5MRIBAP.js +0 -26
- package/dist/m/plugins/sortable-365SRRL3.js +0 -1
- package/dist/m/plugins/undo-UES4KS7B.js +0 -1
- package/dist/m/reader-core-VR7EL4WV.js +0 -77
- package/dist/m/ui/index-MGTWOW2C.js +0 -1
- /package/dist/m/{c-QTTJYJMA.js → c-FILLTJA7.js} +0 -0
- /package/dist/m/plugins/{quickcrop-X5MRIBAP.js.LEGAL.txt → quickcrop-VNRXGRPC.js.LEGAL.txt} +0 -0
- /package/dist/m/plugins/{richclay-L3BZMX4I.js.LEGAL.txt → richclay-V6WKJTUF.js.LEGAL.txt} +0 -0
package/src/ui/bevel-controls.js
CHANGED
|
@@ -186,10 +186,13 @@ export function bevelButton(label, { variant = 'default', small = false, onClick
|
|
|
186
186
|
return b;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
export function bevelIconButton(svg, { label, onClick = null }) {
|
|
189
|
+
export function bevelIconButton(svg, { label, onClick = null, theme = null, parts = [], labelParts = [] }) {
|
|
190
190
|
const b = bevelButton('', {
|
|
191
191
|
small: true,
|
|
192
192
|
onClick,
|
|
193
|
+
theme,
|
|
194
|
+
parts,
|
|
195
|
+
labelParts,
|
|
193
196
|
extra: ['width:26px', 'height:26px', 'padding:0', 'display:inline-grid', 'place-items:center'],
|
|
194
197
|
labelExtra: ['display:inline-grid', 'width:12px', 'height:12px'],
|
|
195
198
|
});
|
package/src/ui/dialogs.js
CHANGED
|
@@ -6,9 +6,10 @@ import { bevelBox, bevelButton, bevelInput, bevelText } from "./bevel-controls.j
|
|
|
6
6
|
import { TOKENS, FONT_SANS, FONT_MONO } from "./bevel.js";
|
|
7
7
|
import { resolveTheme } from "./theme.js";
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// it is ClayJS's to style. The prompt is the dialog's title, as in the
|
|
9
|
+
// Prompts, titles, paragraphs and labels are text (or a node placed as it is), so a
|
|
10
|
+
// record or a visitor cannot run markup. extraContent is markup (or a node). Only the
|
|
11
|
+
// frame around it is ClayJS's to style. The prompt is the dialog's title, as in the
|
|
12
|
+
// dashboard.
|
|
12
13
|
function createModal(promptText, yesCallback, extraContent = "", includeInput = false, defaultValue = "", yesLabel = "OK") {
|
|
13
14
|
const theme = resolveTheme();
|
|
14
15
|
const content = bevelBox("div", ["display:flex", "flex-direction:column", "gap:14px", `font:14.5px/1.55 ${FONT_SANS}`, `color:${TOKENS["ink-2"]}`], { theme, parts: ["dialog.content"], role: "text" });
|
|
@@ -19,7 +20,8 @@ function createModal(promptText, yesCallback, extraContent = "", includeInput =
|
|
|
19
20
|
input.required = true;
|
|
20
21
|
content.append(input);
|
|
21
22
|
}
|
|
22
|
-
content.
|
|
23
|
+
if (extraContent instanceof Node) content.append(extraContent);
|
|
24
|
+
else if (extraContent) content.insertAdjacentHTML("beforeend", extraContent);
|
|
23
25
|
|
|
24
26
|
themodal.title = promptText;
|
|
25
27
|
themodal.html = includeInput || extraContent ? content : "";
|
|
@@ -102,7 +104,8 @@ export function tell(promptText, ...content) {
|
|
|
102
104
|
const box = bevelBox("div", ["display:flex", "flex-direction:column", "gap:12px"], { theme, parts: ["dialog.content"] });
|
|
103
105
|
for (const c of content) {
|
|
104
106
|
const paragraph = bevelText("div", [`font:14.5px/1.55 ${FONT_SANS}`, `color:${TOKENS["ink-2"]}`, "overflow-wrap:anywhere"], undefined, { theme });
|
|
105
|
-
paragraph.
|
|
107
|
+
if (c instanceof Node) paragraph.append(c);
|
|
108
|
+
else paragraph.textContent = c;
|
|
106
109
|
box.append(paragraph);
|
|
107
110
|
}
|
|
108
111
|
|
|
@@ -148,7 +151,7 @@ export function snippet(title, content, extraContent = '') {
|
|
|
148
151
|
`background:${TOKENS.sunk}`, `border:1px solid ${TOKENS["line-2"]}`,
|
|
149
152
|
], { theme, parts: ["dialog.well"], role: "well" });
|
|
150
153
|
const pre = bevelText("pre", ["display:block", "margin:0", "white-space:nowrap", `font:13px/1.6 ${FONT_MONO}`], undefined, { theme, parts: ["dialog.code"], role: "code" });
|
|
151
|
-
pre.
|
|
154
|
+
pre.textContent = content;
|
|
152
155
|
well.append(pre);
|
|
153
156
|
const copy = bevelButton("Copy", {
|
|
154
157
|
small: true,
|
|
@@ -160,7 +163,8 @@ export function snippet(title, content, extraContent = '') {
|
|
|
160
163
|
},
|
|
161
164
|
});
|
|
162
165
|
box.append(well, copy);
|
|
163
|
-
|
|
166
|
+
if (extraContent instanceof Node) box.append(extraContent);
|
|
167
|
+
else if (extraContent) box.insertAdjacentHTML("beforeend", extraContent);
|
|
164
168
|
|
|
165
169
|
themodal.title = title;
|
|
166
170
|
themodal.html = box;
|
package/src/ui/modal.js
CHANGED
|
@@ -18,12 +18,12 @@ export const SURFACE_THEME = Symbol("clay.surfaceTheme");
|
|
|
18
18
|
- user confirms
|
|
19
19
|
- everything about the modal resets
|
|
20
20
|
|
|
21
|
-
themodal.html = content; //
|
|
22
|
-
themodal.yes = content;
|
|
21
|
+
themodal.html = content; // the body: markup, or a node placed as it is
|
|
22
|
+
themodal.yes = content; // text, or a node placed as it is
|
|
23
23
|
themodal.no = content;
|
|
24
24
|
|
|
25
25
|
themodal.closeHtml = "x"; // any non-empty value shows the corner close
|
|
26
|
-
themodal.title = content; //
|
|
26
|
+
themodal.title = content; // text or a node: a header with the title (optional)
|
|
27
27
|
themodal.width = "440px"; // the panel's width (default 600px)
|
|
28
28
|
|
|
29
29
|
themodal.disableFocus = true;
|
|
@@ -367,12 +367,14 @@ const themodal = (() => {
|
|
|
367
367
|
modalYesElem.type = 'submit';
|
|
368
368
|
modalButtonsElem.append(modalNoElem, modalYesElem);
|
|
369
369
|
|
|
370
|
-
//
|
|
371
|
-
|
|
370
|
+
// A node is placed as it is. A string is text, except in the body, which is
|
|
371
|
+
// the one slot that takes markup.
|
|
372
|
+
const place = (target, value, markup = false) => {
|
|
372
373
|
if (value instanceof Node) target.append(value);
|
|
373
|
-
else target.innerHTML = value;
|
|
374
|
+
else if (markup) target.innerHTML = value;
|
|
375
|
+
else target.textContent = value;
|
|
374
376
|
};
|
|
375
|
-
place(modalContentElem, html);
|
|
377
|
+
place(modalContentElem, html, true);
|
|
376
378
|
place(modalYesElem.firstChild, yes);
|
|
377
379
|
place(modalNoElem.firstChild, no);
|
|
378
380
|
if (title) place(shell.heading, title);
|
package/src/ui/toast.js
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
//
|
|
4
4
|
// The Hyperclay dashboard's toast (Bevel's React toast with the dashboard's overrides),
|
|
5
5
|
// drawn inline: a 3px tone edge, a 16px Bevel glyph, 13.5px semibold text, a quiet close.
|
|
6
|
-
import { set } from "../lib/hostile-css.js";
|
|
7
|
-
import { bevelBox, bevelSurface, bevelText, bevelButton, protectIcon, paintLook } from "./bevel-controls.js";
|
|
6
|
+
import { set, style } from "../lib/hostile-css.js";
|
|
7
|
+
import { bevelBox, bevelSurface, bevelText, bevelButton, protectIcon, paintLook, restyleBox } from "./bevel-controls.js";
|
|
8
8
|
import { TOKENS, RULES, GLYPHS } from "./bevel.js";
|
|
9
|
+
import { resolveTheme } from "./theme.js";
|
|
10
|
+
import { themed, tokenRulesFor, partRules, markParts } from "./theme-parts.js";
|
|
9
11
|
import { mountEditorUI } from "./editor-ui.js";
|
|
10
12
|
|
|
11
13
|
const TONES = {
|
|
@@ -34,48 +36,49 @@ function motion() {
|
|
|
34
36
|
// body, and a detached stack would swallow every toast after it. The stack sits in its own
|
|
35
37
|
// shadow root: the inline !important rules already beat the page's stylesheets, and the
|
|
36
38
|
// root also keeps out what they cannot, such as a page's ::before content.
|
|
37
|
-
function stack() {
|
|
39
|
+
function stack(theme) {
|
|
38
40
|
const existing = document.querySelector('clay-editor-ui[data-clay-ui="toasts"]')?.shadowRoot.querySelector("[data-clay-toasts]");
|
|
39
41
|
if (existing) return existing;
|
|
40
42
|
const box = bevelBox("div", [
|
|
41
43
|
"position:fixed", "top:18px", "right:18px", "z-index:9999",
|
|
42
44
|
"display:flex", "flex-direction:column", "align-items:flex-end", "gap:10px",
|
|
43
45
|
"width:min(330px, calc(100vw - 36px))", "pointer-events:none",
|
|
44
|
-
]);
|
|
46
|
+
], { theme, parts: ["toast.stack"] });
|
|
45
47
|
box.setAttribute("data-clay-toasts", "");
|
|
46
48
|
box.setAttribute("aria-live", "polite");
|
|
47
49
|
mountEditorUI({ name: "toasts", content: box });
|
|
48
50
|
return box;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
function build(message, type, { detail = "", actions = [] } = {}) {
|
|
53
|
+
function build(message, type, { detail = "", actions = [] } = {}, theme) {
|
|
52
54
|
const tone = TONES[type];
|
|
53
55
|
const el = bevelSurface("div", [
|
|
54
56
|
"display:flex", "align-items:flex-start", ...RULES.toast, "width:100%",
|
|
55
57
|
`border-inline-start:3px solid ${tone.edge}`,
|
|
56
58
|
"cursor:pointer", "pointer-events:auto",
|
|
57
59
|
...HIDDEN, `transition:${motion()}`,
|
|
58
|
-
]);
|
|
60
|
+
], { theme, parts: ["toast.panel"] });
|
|
61
|
+
if (themed(theme)) style(el, [`border-inline-start-color:${tone.edge}`, ...partRules(theme, ["toast.panel"], {})]);
|
|
59
62
|
el.setAttribute("data-clay-toast", type);
|
|
60
|
-
const body = bevelBox("div", ["flex:1 1 auto", "min-width:0", "display:flex", "flex-direction:column", "gap:8px"]);
|
|
61
|
-
const head = bevelBox("div", ["display:flex", "align-items:flex-start", "gap:8px"]);
|
|
62
|
-
const glyph = bevelText("span", ["display:inline-grid", "flex:none", "padding-top:1px", `color:${tone.edge}`]);
|
|
63
|
+
const body = bevelBox("div", ["flex:1 1 auto", "min-width:0", "display:flex", "flex-direction:column", "gap:8px"], { theme });
|
|
64
|
+
const head = bevelBox("div", ["display:flex", "align-items:flex-start", "gap:8px"], { theme });
|
|
65
|
+
const glyph = bevelText("span", ["display:inline-grid", "flex:none", "padding-top:1px", `color:${tone.edge}`], undefined, { theme, parts: ["toast.icon"], role: null });
|
|
63
66
|
glyph.innerHTML = tone.icon;
|
|
64
67
|
protectIcon(glyph.firstElementChild, 16);
|
|
65
68
|
// A message can carry a filename, and a filename is whatever whoever wrote the
|
|
66
69
|
// file chose. It goes in as text so markup in a name can never become markup here.
|
|
67
|
-
const text = bevelText("span", ["flex:1 1 auto", "min-width:120px", ...RULES.toastTitle, "overflow-wrap:anywhere"], message);
|
|
70
|
+
const text = bevelText("span", ["flex:1 1 auto", "min-width:120px", ...RULES.toastTitle, "overflow-wrap:anywhere"], message, { theme, parts: ["toast.text"] });
|
|
68
71
|
head.append(glyph, text);
|
|
69
72
|
body.append(head);
|
|
70
73
|
// Detail and actions are the same untrusted text as the title: textContent for
|
|
71
74
|
// both, so a reason string can never become markup in the toast either.
|
|
72
75
|
if (detail) {
|
|
73
|
-
body.append(bevelText("span", ["display:block", `padding-inline-start:${TEXT_INSET}px`, `color:${TOKENS.muted}`, "overflow-wrap:anywhere"], detail));
|
|
76
|
+
body.append(bevelText("span", ["display:block", `padding-inline-start:${TEXT_INSET}px`, `color:${TOKENS.muted}`, "overflow-wrap:anywhere"], detail, { theme, parts: ["toast.text"], role: "mutedText" }));
|
|
74
77
|
}
|
|
75
78
|
if (actions.length) {
|
|
76
|
-
const row = bevelBox("div", ["display:flex", "flex-wrap:wrap", "gap:8px", `padding-inline-start:${TEXT_INSET - BUTTON_LABEL_INSET}px`]);
|
|
79
|
+
const row = bevelBox("div", ["display:flex", "flex-wrap:wrap", "gap:8px", `padding-inline-start:${TEXT_INSET - BUTTON_LABEL_INSET}px`], { theme });
|
|
77
80
|
for (const { label, onClick } of actions) {
|
|
78
|
-
row.append(bevelButton(label, { small: true, variant: "quiet", onClick, extra: ["padding:4px 8px"] }));
|
|
81
|
+
row.append(bevelButton(label, { small: true, variant: "quiet", onClick, extra: ["padding:4px 8px"], theme }));
|
|
79
82
|
}
|
|
80
83
|
body.append(row);
|
|
81
84
|
}
|
|
@@ -84,31 +87,61 @@ function build(message, type, { detail = "", actions = [] } = {}) {
|
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
// The dashboard's toast close: a bare 24px square in the muted ink, the sunk ground on hover.
|
|
87
|
-
function closeButton(onClick) {
|
|
88
|
-
const
|
|
90
|
+
function closeButton(onClick, theme) {
|
|
91
|
+
const base = [
|
|
89
92
|
"flex:none", "display:inline-grid", "place-items:center", ...RULES.toastClose,
|
|
90
93
|
"cursor:pointer",
|
|
91
|
-
]
|
|
94
|
+
];
|
|
95
|
+
const b = bevelBox("button", base);
|
|
92
96
|
b.type = "button";
|
|
93
97
|
b.setAttribute("aria-label", "Dismiss");
|
|
94
98
|
b.title = "Dismiss";
|
|
95
99
|
b.innerHTML = CLOSE_ICON;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
if (!themed(theme)) {
|
|
101
|
+
protectIcon(b.firstElementChild, 14);
|
|
102
|
+
const paint = (lit) => {
|
|
103
|
+
set(b, "color", lit ? TOKENS.ink : TOKENS.muted);
|
|
104
|
+
set(b, "background", lit ? TOKENS.sunk : "transparent");
|
|
105
|
+
};
|
|
106
|
+
b.addEventListener("pointerenter", () => paint(true));
|
|
107
|
+
b.addEventListener("pointerleave", () => paint(false));
|
|
108
|
+
b.addEventListener("focus", () => { paint(true); set(b, "outline", `2px solid ${TOKENS.brass}`); set(b, "outline-offset", "1px"); });
|
|
109
|
+
b.addEventListener("blur", () => { paint(false); set(b, "outline", "none"); });
|
|
110
|
+
b.addEventListener("click", onClick);
|
|
111
|
+
return b;
|
|
112
|
+
}
|
|
113
|
+
const names = ["close", "toast.close"];
|
|
114
|
+
const icon = ["icon", "toast.closeIcon"];
|
|
115
|
+
markParts(b, theme, names);
|
|
116
|
+
markParts(b.firstElementChild, theme, icon);
|
|
117
|
+
const flags = { hover: false, focus: false, pressed: false };
|
|
118
|
+
const paint = () => {
|
|
119
|
+
const act = { hover: flags.hover, active: flags.pressed, focus: flags.focus };
|
|
120
|
+
const svg = b.firstElementChild;
|
|
121
|
+
svg.style.cssText = "";
|
|
122
|
+
protectIcon(svg, 14);
|
|
123
|
+
style(svg, partRules(theme, icon, act));
|
|
124
|
+
restyleBox(b, [...base, ...tokenRulesFor(theme, "close", act), ...partRules(theme, names, act)]);
|
|
100
125
|
};
|
|
101
|
-
b.addEventListener("pointerenter", () => paint(
|
|
102
|
-
b.addEventListener("pointerleave", () => paint(
|
|
103
|
-
b.addEventListener("
|
|
104
|
-
|
|
126
|
+
b.addEventListener("pointerenter", () => { flags.hover = true; paint(); });
|
|
127
|
+
b.addEventListener("pointerleave", () => { flags.hover = false; flags.pressed = false; paint(); });
|
|
128
|
+
b.addEventListener("pointerdown", (e) => {
|
|
129
|
+
if (e.button !== undefined && e.button !== 0) return;
|
|
130
|
+
flags.pressed = true;
|
|
131
|
+
paint();
|
|
132
|
+
});
|
|
133
|
+
b.addEventListener("pointerup", () => { flags.pressed = false; paint(); });
|
|
134
|
+
b.addEventListener("focus", () => { flags.focus = true; paint(); });
|
|
135
|
+
b.addEventListener("blur", () => { flags.focus = false; flags.pressed = false; paint(); });
|
|
105
136
|
b.addEventListener("click", onClick);
|
|
137
|
+
paint();
|
|
106
138
|
return b;
|
|
107
139
|
}
|
|
108
140
|
|
|
109
|
-
function reveal(el) {
|
|
110
|
-
stack().append(el);
|
|
111
|
-
|
|
141
|
+
function reveal(el, theme) {
|
|
142
|
+
stack(theme).append(el);
|
|
143
|
+
if (themed(theme)) set(el, "color-scheme", theme.scheme === "light dark" ? "light" : theme.scheme);
|
|
144
|
+
else paintLook(el, { background: TOKENS.surface });
|
|
112
145
|
setTimeout(() => {
|
|
113
146
|
set(el, "opacity", "1");
|
|
114
147
|
set(el, "transform", "none");
|
|
@@ -125,9 +158,10 @@ function dismiss(el, after) {
|
|
|
125
158
|
}
|
|
126
159
|
|
|
127
160
|
function toast(message, messageType = "success") {
|
|
128
|
-
const
|
|
161
|
+
const theme = resolveTheme();
|
|
162
|
+
const el = build(message, TONES[messageType] ? messageType : "success", {}, theme);
|
|
129
163
|
el.addEventListener("click", () => dismiss(el));
|
|
130
|
-
reveal(el);
|
|
164
|
+
reveal(el, theme);
|
|
131
165
|
setTimeout(() => dismiss(el), 6600);
|
|
132
166
|
}
|
|
133
167
|
|
|
@@ -142,17 +176,18 @@ function toastPersistent(message, messageType = "warning", { detail = "", action
|
|
|
142
176
|
activePersistentToasts.delete(message);
|
|
143
177
|
}
|
|
144
178
|
|
|
145
|
-
const
|
|
179
|
+
const theme = resolveTheme();
|
|
180
|
+
const el = build(message, TONES[messageType] ? messageType : "warning", { detail, actions }, theme);
|
|
146
181
|
set(el, "cursor", "default");
|
|
147
182
|
const close = closeButton((e) => {
|
|
148
183
|
e.stopPropagation();
|
|
149
184
|
// A newer toast with the same message may have taken this entry since.
|
|
150
185
|
dismiss(el, () => { if (activePersistentToasts.get(message) === el) activePersistentToasts.delete(message); });
|
|
151
|
-
});
|
|
186
|
+
}, theme);
|
|
152
187
|
el.append(close);
|
|
153
188
|
|
|
154
189
|
activePersistentToasts.set(message, el);
|
|
155
|
-
reveal(el);
|
|
190
|
+
reveal(el, theme);
|
|
156
191
|
}
|
|
157
192
|
|
|
158
193
|
// Takes down the persistent toast showing this message, if one is up. `now` takes the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// GENERATED — do not edit. Vendored from
|
|
2
2
|
// hyper-html-api/dist/hyper-html-api.engine.esm.js via hyper-html-api
|
|
3
3
|
// `npm run copy-to-clayjs`. Edit the hyper-html-api source and re-run.
|
|
4
|
-
var At=Object.defineProperty;var Et=(e,t)=>{for(var n in t)At(e,n,{get:t[n],enumerable:!0})};var re=["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"],ie=new Set(re),he=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),B=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),$e=new Set(["checked","selected","disabled","readOnly","paused"]);function pe(e,t){return t==null?$e.has(e)?!1:"":$e.has(e)?t==="false"?!1:!!t:t}var R={};Et(R,{CodecRefused:()=>ge,EmptyListInsert:()=>P,MAX_RULE_DEPTH:()=>M,MaxRuleDepthExceeded:()=>_,NoRulesTag:()=>me,RuleTargetReadOnly:()=>z,RulesParseError:()=>C,ShapeMismatch:()=>U,UnknownCodec:()=>K,UnknownRulesVersion:()=>H,WriteNotRoundTripped:()=>oe,WriteRefused:()=>F,WriteRejected:()=>ye});var C=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},H=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=t}},M=20,_=class extends Error{constructor(t){super(`rule depth exceeded ${M} 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}},P=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}},z=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},F=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function Tt(e){return e.reduce((n,i)=>typeof i=="number"?`${n}[${i}]`:n?`${n}.${i}`:String(i),"")||"(root)"}var oe=class extends Error{constructor(t){super(`write did not round-trip at "${Tt(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},me=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},ye=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}},K=class extends Error{constructor(t){super(`unknown codec "${t}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=t}},ge=class extends Error{constructor(t,n){super(n),this.name="CodecRefused",this.code=t}};function N(e){let t=0,n=null,i=-1;for(let r=0;r<e.length;r++){let o=e[r];o==="\\"?r++:n?o===n&&(n=null):o==='"'||o==="'"?n=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(i=r)}return i}var je="[*]";function b(e){let t=N(e),n=t===-1?e:e.slice(0,t),i=n.endsWith(je),r={selector:i?n.slice(0,-je.length):n,prop:t===-1?null:e.slice(t+1)||null};return i&&(r.all=!0),r}function we(e){let t=0,n=null,i=-1,r=!1;for(let o=0;o<e.length;o++){let c=e[o];c==="\\"?o++:n?c===n&&(n=null):c==='"'||c==="'"?n=c:c==="["||c==="("?t++:c==="]"||c===")"?t>0&&t--:t===0&&c===">"?i=o:t===0&&c===","&&(r=!0)}return r||i===-1||!Ot(e,i+1)?null:e.slice(0,i).trim()||null}function Ot(e,t){let n=t,i=e.replace(/\s+$/,"").length;for(;n<i&&/\s/.test(e[n]);)n++;let r=0,o=null;for(;n<i;n++){let c=e[n];if(c==="\\")n++;else if(o)c===o&&(o=null);else if(c==='"'||c==="'")o=c;else if(c==="["||c==="(")r++;else if(c==="]"||c===")")r>0&&r--;else if(r===0&&(c==="+"||c==="~"||/\s/.test(c)))return!1}return!0}var St=/^codec\(([a-z][a-z0-9-]*)\)$/;function $(e){if(typeof e!="string")return null;let t=N(e);if(t===-1)return null;let n=St.exec(e.slice(t+1));if(!n)return null;let{selector:i,all:r}=b(e);if(r)throw new C("A @codec(name) rule cannot use [*].");return{selector:i,name:n[1]}}var xt=/^--[A-Za-z0-9_-]+$/;function k(e){return typeof e=="string"&&xt.test(e)}function De(e){let t=[],n=[],i=null,r=0;for(let o=0;o<e.length;o++){let c=e[o];if(i){c==="\\"?o++:c===i&&(i=null);continue}if(c==="/"&&e[o+1]==="*"){let l=e.indexOf("*/",o+2);o=l===-1?e.length:l+1;continue}c==='"'||c==="'"?i=c:c==="("?n.push(")"):c==="["?n.push("]"):c==="{"?n.push("}"):(c===")"||c==="]"||c==="}")&&n[n.length-1]===c?n.pop():c===";"&&n.length===0&&(t.push(e.slice(r,o)),r=o+1)}return t.push(e.slice(r)),t}function bt(e){let t="",n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){t+=r,r==="\\"&&i+1<e.length?t+=e[++i]:r===n&&(n=null);continue}if(r==="/"&&e[i+1]==="*"){let o=e.indexOf("*/",i+2);i=o===-1?e.length:o+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function ve(e){e=bt(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),i=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(i);return r&&(i=i.slice(0,r.index).trim()),{name:n,value:i,important:!!r}}function v(e,t){if(e==null)return null;let n=null;for(let i of De(String(e))){let r=ve(i);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function We(e,t,n){let i=e==null?"":String(e),r=n==null||n==="",o=De(i),c=o.map(ve),l=c.some(d=>d&&d.name===t&&d.important),s=[],f=!1;o.forEach((d,h)=>{let A=c[h];if(!A||A.name!==t){s.push(d);return}if(r||f)return;let a=/^\s*/.exec(d)[0];s.push(`${a}${t}: ${n}${l?" !important":""}`),f=!0});let u=s.join(";");if(!r&&!f){let d=u.trimEnd();u=d===""?`${t}: ${n}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${n}`}return u.trim()===""?null:u}function se(e,t,n,i){let r=e.attr(t,"style");if((v(r,n)??"")===i)return;let o=We(r,n,i);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}var qe=/^[a-z][a-z0-9-]*$/,Ae=new Map;function Ee(e,t){if(typeof e!="string"||!qe.test(e))throw new Error(`hyper-html-api: invalid codec name ${JSON.stringify(e)} (must match ${qe})`);if(!t||typeof t.read!="function"||typeof t.write!="function"||typeof t.same!="function")throw new Error(`hyper-html-api: codec "${e}" needs read, write and same functions`);Ae.set(e,t)}function Te(e){return Ae.get(e)??null}function Oe(){return Object.fromEntries(Ae)}var Rt='The @codec(name) rule form needs a rules tag with data-rules-version="2".',Ct="A @codec(name) rule must be the value of a top level key.";function ce(e,t){let n=$(e);return n?{...n,codec:t.codecs[n.name]}:null}function j(e,t={}){let n=t.version??"1",i=t.codecs??{};r(e,0);function r(o,c){if(!(c>M)){if(typeof o=="string"){let l=$(o);if(!l)return;if(n!=="2")throw new C(Rt);if(c!==1)throw new C(Ct);if(!Object.prototype.hasOwnProperty.call(i,l.name))throw new K(l.name);return}if(Array.isArray(o)){r(o[1],c+1);return}if(o&&typeof o=="object")for(let l of Object.values(o))r(l,c+1)}}}function L(e,t,n,i={}){if(Object.prototype.hasOwnProperty.call(i,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return j(n,i),xe(e,t,n,{depth:0,path:[]},i)}function xe(e,t,n,i,r){if(i.depth>M)throw new _(i.path);if(typeof n=="string")return Nt(e,t,n,i,r);if(Array.isArray(n)){let[o,c]=n,l=e.find(t,o,r);return Ve(r,i,l),l.map((s,f)=>xe(e,s,c,{depth:i.depth+1,path:[...i.path,f]},r))}if(typeof n=="object"&&n!==null){let o={};for(let[c,l]of Object.entries(n))o[c]=xe(e,t,l,{depth:i.depth+1,path:[...i.path,c]},r);return o}return null}function Nt(e,t,n,i,r){if(n.endsWith("[]")){let u=n.slice(0,-2),d=e.find(t,u,r);return Ve(r,i,d),d.map(h=>e.text(h))}let o=ce(n,r);if(o)return Pt(e,t,o,r);if(n.startsWith("@"))return Se(e,t,n.slice(1));let c=N(n);if(c!==-1){let{selector:u,all:d}=b(n),h=n.slice(c+1),A=u?e.find(t,u,r):[t];return d&&r.allMatches?A.map(a=>Se(e,a,h)):A.length===0?null:Se(e,A[0],h)}if(n===".")return e.text(t);let{selector:l,all:s}=b(n),f=e.find(t,l,r);return s&&r.allMatches?f.map(u=>e.text(u)):f.length===0?null:e.text(f[0])}function Pt(e,t,{selector:n,codec:i},r){let o=n?e.find(t,n,r):[t];return o.length===0?null:i.read(e,o[0],{query:r.query,view:r.view,region:r.region})}function Ve(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(i){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,i)}}function Se(e,t,n){if(k(n))return v(e.attr(t,"style"),n);if(ie.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let i=e.attr(t,n);return i??null}function Ue(e,t,n,i){let r=e.length,o=t.length,c=new Array(r).fill(-1);if(i){let p=new Set;for(let y=0;y<r;y++){let w=i[y];!(w>=0&&w<o)||p.has(w)||(c[y]=w,p.add(w))}}if(r===0||o===0)return c;let l=e.map(p=>Be(p,n)),s=t.map(p=>Be(p,n)),f=new Array(o).fill(!1);for(let p of c)p>=0&&(f[p]=!0);let u=new Map;s.forEach((p,y)=>{f[y]||u.set(p,u.has(p)?-1:y)});let d=new Map;l.forEach((p,y)=>{c[y]>=0||d.set(p,(d.get(p)||0)+1)}),l.forEach((p,y)=>{if(c[y]>=0||d.get(p)!==1)return;let w=u.get(p);w===void 0||w===-1||f[w]||(c[y]=w,f[w]=!0)});let h=[];for(let p=0;p<r;p++)c[p]<0&&h.push(p);let A=[];for(let p=0;p<o;p++)f[p]||A.push(p);if(h.length===0||A.length===0)return c;let a=r*o+1,m=Mt(e,t,n),g=(p,y)=>m(p,y)*a+Math.abs(p-y);for(let[p,y]of kt(h,A,g))c[p]=y;return c}var ze=e=>typeof e=="object"&&e!==null;function Be(e,t){if(!ze(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(i=>{let r=JSON.stringify(e?.[i]);return r===void 0?" undef":r}))}function Mt(e,t,n){if(!ze(n))return(l,s)=>e[l]===t[s]?0:1;let i=Object.keys(n),r=l=>i.map(s=>JSON.stringify(l?.[s])),o=e.map(r),c=t.map(r);return(l,s)=>{let f=o[l],u=c[s],d=0;for(let h=0;h<i.length;h++)f[h]!==u[h]&&d++;return d}}function kt(e,t,n){return e.length<=t.length?He(e,t,n,!1):He(t,e,(i,r)=>n(r,i),!0)}function He(e,t,n,i){let r=e.length,o=t.length,c=[];for(let d=0;d<=r;d++)c.push(new Float64Array(o+1).fill(1/0));let l=[];for(let d=0;d<=r;d++)l.push(new Uint8Array(o+1));for(let d=0;d<=o;d++)c[r][d]=0;for(let d=r-1;d>=0;d--)for(let h=o-1;h>=0;h--){let A=n(e[d],t[h])+c[d+1][h+1],a=c[d][h+1];A<=a?(c[d][h]=A,l[d][h]=1):c[d][h]=a}let s=[],f=0,u=0;for(;f<r&&u<o;)l[f][u]&&(s.push(i?[t[u],e[f]]:[e[f],t[u]]),f++),u++;return s}function Re(e,t,n,i,r,o,c,l={}){let s=e.find(t,n,l);if(r.length===0){s.forEach(E=>e.remove(E)),be(l,"onRowsApplied",o.path,[]);return}let f=r.length>s.length,u=s[0]||null;if(f&&!u&&(u=$t(e,t,n,l),!u))throw new P(o.path);let d=s.map(E=>_t(e,E,i,l)),h=null;if(f&&u){h=e.clone(u),l.templateAttr&&e.removeAttr(h,l.templateAttr);let E=e.stripIds(h);E>0&&console.warn(`[hyper-html-api] stripped ${E} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let A=Ue(r,d,i,Lt(e,s,r,o,l)),a=s.length>0?e.parent(s[0]):Wt(e,t,n,u,o,l),m=s.length>0?Ye(e,a,s[0]):0,g=Bt(e,s),p=new Set,y=[],w=r.map((E,x)=>{let O=A[x];if(O>=0)return p.add(O),y.push(!1),s[O];y.push(!0);let T=e.clone(h);return e.stripIds(T),T});s.forEach((E,x)=>{p.has(x)||e.remove(E)}),g?Vt(e,a,m,w,y):Ht(e,w,y,a,m),It(e,w,i,r,o,c,l),be(l,"onRowsApplied",o.path,w)}function be(e,t,n,i){if(typeof e[t]=="function")try{return e[t](n.slice(),i)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function Lt(e,t,n,i,r){let o=be(r,"identifyRows",i.path,n);if(!Array.isArray(o))return null;let c=new Array(n.length).fill(-1),l=new Set,s=new Map(t.map((f,u)=>[e.identity(f),u]));for(let f=0;f<n.length;f++){if(!o[f])continue;let u=s.get(e.identity(o[f]));u===void 0||l.has(u)||(c[f]=u,l.add(u))}return c}function It(e,t,n,i,r,o,c){t.forEach((l,s)=>{if(n===null){let f=i[s],u=f==null?"":String(f);e.text(l)!==u&&e.text(l,u)}else{let f=o(e,l,n,i[s],{depth:r.depth+1,path:[...r.path,s]},c);f&&f!==l&&(t[s]=f)}})}function _t(e,t,n,i){return n===null?e.text(t):L(e,t,n,i.onRowsRead?{...i,onRowsRead:void 0}:i)}function Ye(e,t,n){let i=e.children(t);for(let r=0;r<i.length;r++)if(e.sameNode(i[r],n))return r;return-1}function $t(e,t,n,i){if(!i.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),o=new RegExp(":not\\(\\["+i.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),c=n.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),l=r?jt(c):0,s=we(c),f=t;for(;f;){let u=e.find(f,c,{includeRulesTag:!1,templateAttr:null});for(let d of u)if(e.attr(d,i.templateAttr)!=null&&!(r&&!vt(e,t,d,l))&&!(s&&!e.matches(e.parent(d),s)))return d;f=e.parent(f)}return null}function jt(e){let t=0,n=null,i=1;for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\")r++;else if(n)o===n&&(n=null);else if(o==='"'||o==="'")n=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")i++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!Dt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return i}function Dt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let i=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return Fe(i)||Fe(r)}function Fe(e){return e===">"||e==="+"||e==="~"}function vt(e,t,n,i){if(i===null)return!0;let r=n;for(let s=0;s<i;s++)if(r=e.parent(r),!r)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let c=e.prop(r,"tagName");if(!c||String(c).toLowerCase()!==String(o).toLowerCase())return!1;let l=new Set(Ke(e,r));return Ke(e,t).every(s=>l.has(s))}function Ke(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Wt(e,t,n,i,r,o){let c=e.parent(i);if(c&&qt(e,t,c)&&!Xe(e,c,o))return c;let l=we(n);if(!l)throw new P(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 f=(l===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,l,o)).filter(u=>!Xe(e,u,o));if(f.length===0)throw new P(r.path,`no container matching "${l}" inside this context to hold the new rows`);if(f.length>1)throw new P(r.path,`"${l}" matches ${f.length} containers inside this context, so the new rows have no single destination`);return f[0]}function qt(e,t,n){let i=n;for(;i;){if(e.sameNode(i,t))return!0;i=e.parent(i)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var Je=["no-data","editor-ui"];function Xe(e,t,n){let i=t;for(;i;){if(n.templateAttr&&e.attr(i,n.templateAttr)!=null||Je.some(o=>e.attr(i,o)!=null))return!0;let r=e.attr(i,"clay");if(r&&r.split(/\s+/).some(o=>Je.includes(o)))return!0;i=e.parent(i)}return!1}function Vt(e,t,n,i,r){let o=e.children(t),c=o.map(s=>e.identity(s)),l=!1;i.forEach((s,f)=>{let u=e.identity(s),d=n+f;if(c[d]===u)return;if(!r[f]){let A=c.indexOf(u);A!==-1&&(c.splice(A,1),o.splice(A,1))}let h=Math.min(d,o.length);h<o.length?e.insertBefore(o[h],s):o.length?l?e.insertAfter(o[o.length-1],s):(e.insertAt(t,s,d),l=!0):e.insertAt(t,s,0),c.splice(h,0,u),o.splice(h,0,s)})}function Bt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let i=new Map(e.children(n).map((o,c)=>[e.identity(o),c])),r=[];for(let o of t){let c=i.get(e.identity(o));if(c===void 0)return!1;r.push(c)}return r.sort((o,c)=>o-c),r[r.length-1]-r[0]===r.length-1}function Ht(e,t,n,i,r){let o=null,c=r;for(let l=0;l<t.length;l++){if(!n[l]){o=t[l];continue}let s=o?e.parent(o):i;if(!s)continue;let f=o?Ye(e,s,o)+1:c++;e.insertAt(s,t[l],f),o=t[l]}}function D(e,t,n,i,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.");j(n,r);let o=[];if(Ce(n,i,[],o),o.length)throw new U(o);le(e,t,n,i,{depth:0,path:[]},r)}function le(e,t,n,i,r,o={}){if(r.depth>M)throw new _(r.path);if(i===void 0)return t;if(typeof n=="string")return Ut(e,t,n,i,r,o);if(Array.isArray(n)){let[c,l]=n;return Re(e,t,c,l,i,r,le,o),t}if(typeof n=="object"&&n!==null){for(let[c,l]of Object.entries(n)){let s=le(e,t,l,i==null?i:i[c],{depth:r.depth+1,path:[...r.path,c]},o);s&&s!==t&&(t=s)}return t}return t}function Ut(e,t,n,i,r,o){if(n.endsWith("[]")){let d=n.slice(0,-2);return Re(e,t,d,null,i,r,le,o),t}let c=ce(n,o);if(c){let d=c.selector?e.find(t,c.selector,o):[t];return d.length&&c.codec.write(e,d[0],i,{query:o.query}),t}if(n.startsWith("@"))return Ze(e,t,n.slice(1),i);let l=N(n);if(l!==-1){let{selector:d,all:h}=b(n),A=n.slice(l+1),a=d?e.find(t,d,o):[t];for(let m of h?a:a.slice(0,1))Ze(e,m,A,i);return t}if(n===".")return Ge(e,t,i),t;let{selector:s,all:f}=b(n),u=e.find(t,s,o);for(let d of f?u:u.slice(0,1))Ge(e,d,i);return t}function Ge(e,t,n){let i=n==null?"":String(n);e.text(t)!==i&&e.text(t,i)}function zt(e,t,n,i){if(e.styleVar){e.styleVar(t,n,i);return}se(e,t,n,i)}function Ze(e,t,n,i){if(k(n))return zt(e,t,n,i==null?"":String(i).trim()),t;if(B.has(n)){let r=e.prop(t,n);if(r===i||r!=null&&i!=null&&String(r)===String(i))return t;throw new z(n)}if(n==="outerHTML"){let r=i==null?"":String(i);return e.replaceWith(t,r)}if(he.has(n)){let r=pe(n,i);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(i==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(i);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function Ce(e,t,n,i){if(t!==void 0){if(typeof e=="string"){if($(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,o)=>{typeof r=="object"&&r!==null&&i.push({path:X([...n,o]),expected:"scalar",got:J(r)})}):i.push({path:X(n),expected:"array",got:J(t)});return}t!==null&&typeof t=="object"&&i.push({path:X(n),expected:"scalar",got:J(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){i.push({path:X(n),expected:"array",got:J(t)});return}let r=e[1];t.forEach((o,c)=>Ce(r,o,[...n,c],i));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){i.push({path:X(n),expected:"object",got:J(t)});return}for(let[r,o]of Object.entries(e))Ce(o,t[r],[...n,r],i)}}}function J(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function X(e){return e.join(".")}function Ne(e){try{return JSON.parse(e)}catch(t){throw new C(`Invalid strict JSON: ${t.message}`,t)}}function Y(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 o=[],c=0;for(;c<r.length;){let l=r[c];if(/\s/.test(l)){c++;continue}if("{}".includes(l)){o.push({type:l,value:l}),c++;continue}if(l==="["){let d=!1,h=c+1;for(;h<r.length&&/\s/.test(r[h]);)h++;if(h<r.length&&/[a-zA-Z_]/.test(r[h])&&(d=!0),!d){o.push({type:l,value:l}),c++;continue}}if(l==="]"){o.push({type:l,value:l}),c++;continue}if(l===":"){o.push({type:t.COLON,value:l}),c++;continue}if(l===","){o.push({type:t.COMMA,value:l}),c++;continue}if(l==='"'||l==="'"){let d=l,h=c+1;for(;h<r.length&&r[h]!==d;)r[h]==="\\"&&h++,h++;o.push({type:t.STRING,value:r.substring(c+1,h),quoted:!0,sourceQuote:d}),c=h+1;continue}let s=c,f;for(;s<r.length&&!/[{},]/.test(r[s]);)if(r[s]===":"){let d=[":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"],h=!1;for(let A of d){let a=A.substring(1);if(r.substring(s+1,s+1+a.length)===a){h=!0,s+=a.length;break}}if(!h)break}else if(r[s]==="["){for(s++;s<r.length&&r[s]!=="]";){if(r[s]==='"'||r[s]==="'"){let d=r[s];for(s++;s<r.length&&r[s]!==d;)r[s]==="\\"&&s++,s++}s++}s<r.length&&r[s]==="]"&&s++}else s++;f=r.substring(c,s);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(f)?u=t.NUMBER:f==="true"||f==="false"||f==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(f)&&(u=t.SELECTOR),o.push({type:u,value:f,quoted:!1}),c=s}return o}function i(r){let o="";for(let c=0;c<r.length;c++){let l=r[c];if("{}".includes(l.type)||"[]".includes(l.type)){o+=l.value;continue}if(l.type===t.COLON){o+=l.value;continue}if(l.type===t.COMMA){let s=r[c+1];if(s&&(s.type==="}"||s.type==="]"))continue;o+=l.value;continue}if(l.type===t.STRING&&l.quoted){let s=l.value;l.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(f,u)=>u.length%2===0?u+'\\"':f)),o+=`"${s}"`;continue}if(l.type===t.NUMBER||l.type===t.BOOLEAN){o+=l.value;continue}if(l.type===t.SELECTOR||l.type===t.IDENTIFIER){o+=`"${l.value}"`;continue}o+=`"${l.value}"`}return o}try{let r=n(e),o=i(r);return JSON.parse(o)}catch(r){throw new C("Invalid extraction rules syntax: "+r.message,r)}}var et=["1","2"],Qe=/^[a-zA-Z0-9_-]+$/;function W(e,t,n){let i;if(n===void 0)i="script[data-rules-name]";else{if(typeof n!="string"||!Qe.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Qe})`);i=`script[data-rules-name~="${n}"]`}let r=e.find(t,i,{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 o=r[0],c=e.attr(o,"data-rules-version");if(!et.includes(c))throw new H(c);return{rules:Y(e.text(o)),tagNode:o,version:c}}var fe=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"]})}),Ft=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),tt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function G(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 Pe(e,t){if(G(e,t))return!0;for(let[n,i]of Object.entries(Ft))if(i.includes(t)&&G(e,n))return!0;return!1}function Z(e){let t=fe[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Kt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let i=fe[t];if(!i)throw new Error(`Unknown region capability: ${t}`);if(i.tokens.some(r=>Pe(n,r))||i.bundles.some(r=>G(n,r)))return n;n=n.parentElement}return null}function nt(e,t){return!!Kt(e,t)}var ue=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",...tt],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"]})}),Jt=new Set(["textContent","innerText"]);function rt(e){let n=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?n[1].toLowerCase():null}var Xt=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function it(e,t,n=ue){if(!Xt.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let i=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>i.startsWith(r)))return`attribute "${i}" can run script`;if(n.refusedAttributes.includes(i))return`attribute "${i}" is not content`;if(n.urlAttributes.includes(i)&&t!=null){let r=i==="srcset"?String(t).split(",").map(o=>o.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let o of r){let c=rt(o);if(c&&n.refusedSchemes.includes(c))return`"${c}:" URLs are not allowed in "${i}"`}}return null}function Me(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function Yt(e,t){let n=Me(e,t)||"node",i=e.attr(t,"id");return i?`<${n}#${i}>`:`<${n}>`}function Gt(e,t,n){let i=t;for(;i;){let r=Me(e,i);if(r&&n.refusedTargets.includes(r))return r;i=e.parent(i)}return null}function ot(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function Zt(e,t){return Me(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:ot(e,t)}function Qt(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){r===n&&(n=null);continue}if(r==='"'||r==="'")n=r;else{if(r==="/"&&e[i+1]==="*")return"comments are not allowed in a custom property value";if(r==="(")t.push(")");else if(r==="[")t.push("]");else if((r===")"||r==="]")&&t.pop()!==r)return`"${r}" does not close anything in this custom property value`}}return n?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function st(e,t=ue){let n=t.customPropertyValues,i=String(e);if(i.length>n.maxLength)return`custom property values are limited to ${n.maxLength} characters`;let r=n.refusedCharacters.find(s=>i.includes(s));if(r)return`${JSON.stringify(r)} is not allowed in a custom property value`;let o=Qt(i);if(o)return o;let c=i.toLowerCase(),l=n.refusedFunctions.find(s=>new RegExp(`(^|[^a-z0-9_-])${s.replace(/[-]/g,"\\-")}\\s*\\(`).test(c));return l?`"${l}()" is not allowed in a custom property value`:null}function ae(e,t=ue){let n=[],i=(s,f)=>(n.push({target:Yt(e,s),reason:f}),!1),r=s=>{let f=Gt(e,s,t);return f?i(s,`inside <${f}>, which is not content`):!0},o=s=>r(s)?ot(e,s)?i(s,"a text write here would delete the data rules tag"):!0:!1,c=(s,f,u)=>{if(!r(s))return!1;let d=it(f,u,t);return d?i(s,d):!0};return{...e,text(s,f){if(f===void 0)return e.text(s);o(s)&&e.text(s,f)},attr(s,f,u){if(u===void 0)return e.attr(s,f);c(s,f,u)&&e.attr(s,f,u)},removeAttr(s,f){c(s,f,null)&&e.removeAttr(s,f)},styleVar(s,f,u){if((v(e.attr(s,"style"),f)??"")!==u&&r(s)){if(!k(f))return i(s,`"${f}" is not a custom property`);if(u!==""){let d=st(u,t);if(d)return i(s,d)}se(e,s,f,u)}},prop(s,f,u){if(u===void 0)return e.prop(s,f);if(t.refusedRuleForms.includes(f))return i(s,`"@${f}" writes HTML, only text is allowed`);if(Jt.has(f)){o(s)&&e.prop(s,f,u);return}c(s,f==="className"?"class":f,u)&&e.prop(s,f,u)},remove(s){if(Zt(e,s)){i(s,"removing this would delete the data rules tag");return}e.remove(s)},replaceWith(s,f){return f===e.prop(s,"outerHTML")||i(s,'"@outerHTML" writes HTML, only text is allowed'),s},refusals:n,assertClean(){if(n.length)throw new F(n.slice())}}}function Q(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ct(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function ke(e,t,n,i,r={}){j(n,r);let o=[],c=[];function l(f,u,d){if(Array.isArray(f)){let[,h]=f;if(!Array.isArray(u)||!Q(h))return;u.forEach((A,a)=>l(h,A,[...d,a]));return}if(!(!Q(f)||!Q(u)))for(let h of Object.keys(u))Object.prototype.hasOwnProperty.call(f,h)?l(f[h],u[h],[...d,h]):o.push(ct([...d,h]))}function s(f,u,d,h){if(d!==void 0){if(typeof u=="string"){if(u.endsWith("[]")||u==="."||u.startsWith("@"))return;let{selector:A}=b(u);if(!A)return;e.find(f,A,r).length===0&&c.push({path:ct(h),selector:A});return}if(!Array.isArray(u)&&Q(u)&&Q(d))for(let[A,a]of Object.entries(u))s(f,a,d[A],[...h,A])}}return l(n,i,[]),s(t,n,i,[]),{unknownKeys:o,unmatched:c}}function Le(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null,version:"1"};if(typeof n=="string"){let i=t&&t.ownerDocument?t.ownerDocument:t;return W(e,i,n)}return null}var tn=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function nn(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 lt(e,t,n,i){if(i)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 ft(e,t,n,i,r,o){return(o?nt(e,t):lt(e,n,r,!1))||!!(i&&(o&&e!==r?e.matches(i):lt(e,i,r,o)))}function rn(e,t){let n=fe[t];return n.tokens.some(i=>Pe(e,i))||n.bundles.some(i=>G(e,i))}var on=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function ut(e,t,n,i){if(e.nodeType===1&&i(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,o=t;if(e.nodeType===1){if(on.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,o=t.content,n.cloneToLive.set(o,r),n.liveToClone.set(r,o)}}else if(e.nodeType!==11)return;let c=o.firstChild;for(let l=r.firstChild;l&&c;l=l.nextSibling)ut(l,c,n,i),c=c.nextSibling}function ee(e,{capability:t="data",exclude:n=null,inherit:i=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let o=e.nodeType===9?e:e.ownerDocument;if(!o?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let c=o.implementation.createHTMLDocument(""),l=r||new WeakMap,s=new WeakMap,f=e.nodeType===9?e.documentElement:e;n&&c.documentElement.matches(n);let u=Z(t),d=i?a=>rn(a,t)||!!(n&&a.matches(n)):a=>ft(a,t,u,n,f,!1),h=null;if(f.nodeType!==1||!ft(f,t,u,n,f,i)){h=c.importNode(f,!0);let a={cloneToLive:l,liveToClone:s,dropped:[],controls:[]};ut(f,h,a,d);for(let m of a.dropped)m.remove();for(let m=0;m<a.controls.length;m+=2)nn(a.controls[m],a.controls[m+1])}e.nodeType===9&&h&&(c.replaceChild(h,c.documentElement),s.set(e,c),l.set(c,e));let A=a=>{if(tn.test(a))throw new Error(`Filtered content queries do not support stateful selector: ${a}`)};return{root:h,document:c,capability:t,selector:Z(t),cloneToLive:l,liveToClone:s,original(a){return l.get(a)||null},cloneOf(a){return s.get(a)||null},query(a,m=h){return A(a),Array.from(m.querySelectorAll(a),g=>l.get(g)||g)},text(a=h){return(a===h?h:s.get(a))?.textContent||""},html(a=h){return(a===h?h:s.get(a))?.innerHTML??""},clone(a=h){let m=a===h?h:s.get(a);return m?c.importNode(m,!0):null}}}function dt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function sn(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function at(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 ht(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function pt(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 i=n.type;i!=="file"&&i!=="checkbox"&&i!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var S={semanticExclude:!0,find(e,t,n={}){let i=sn(e);if(!i||!i.querySelectorAll)return[];let r=Array.from(i.querySelectorAll(t));n.includeRulesTag||(r=r.filter(l=>!dt(l)));let o=[];n.skip&&o.push(n.skip);let c=n.templateAttr===null?null:n.templateAttr||"cms-template";if(c&&o.push("["+c+"]"),o.length){let l=o.join(", ");r=r.filter(s=>!s.closest||!s.closest(l))}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,ht(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),at(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),at(e,t,null)},prop(e,t,n){if(n===void 0){let i=e?e[t]:void 0;return i!==void 0?i:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return pt(t),t},insertAt(e,t,n){let i=e.children[n]||null;e.insertBefore(t,i)},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 i=e.ownerDocument.createElement("template");i.innerHTML=t;let r=i.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(i=>{i.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function I(e,t={}){if(t.exclude===null)return S;let n=[Z("data"),t.exclude].filter(Boolean).join(", "),i=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!i?.querySelector?.(n))return S;let o=e.nodeType===9||!e.isConnected?e:e.ownerDocument,c=e.nodeType===9?e:e.ownerDocument,l=null,s=()=>l||(l=ee(o,{capability:"data",exclude:t.exclude||null})),f=a=>{let m=s();return a===e?m.cloneOf(e):m.cloneOf(a)||a},u=a=>l?.original(a)||a,d=(a,m)=>{s().liveToClone.set(a,m),s().cloneToLive.set(m,a);let g=a.childNodes||[],p=m.childNodes||[];for(let y=0;y<Math.min(g.length,p.length);y++)d(g[y],p[y])},h=(a,m,g,p)=>{let y=Array.from(a.childNodes).filter(T=>l.cloneOf(T)),E=y[0];for(;E&&y.includes(E);)E=E.nextSibling;for(let T of y)T.remove();if(g==="innerHTML"){let T=c.createElement("template");T.innerHTML=p;for(let V of Array.from(T.content.childNodes))a.insertBefore(V,E||null)}else a.insertBefore(c.createTextNode(p),E||null),ht(a,p);let x=ee(a,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(x.root?.childNodes||[]));let O=T=>{let V=x.original(T);V&&(l.liveToClone.set(V,T),l.cloneToLive.set(T,V));for(let wt of Array.from(T.childNodes||[]))O(wt)};for(let T of Array.from(m.childNodes))O(T)},A={...S,find(a,m,g={}){let p=f(a);if(!p?.querySelectorAll)return[];let y=s().query(m,p);g.includeRulesTag||(y=y.filter(x=>!dt(x)));let w=[];g.skip&&w.push(g.skip);let E=g.templateAttr===null?null:g.templateAttr||"cms-template";if(E&&w.push(`[${E}]`),w.length){let x=w.join(", ");y=y.filter(O=>!O.closest?.(x))}return y},parent(a){let m=f(a)?.parentElement;return m?u(m):null},children(a){return Array.from(f(a)?.children||[],u)},text(a,m){if(m===void 0){let y=u(a);return!y?.matches?.(n)&&!y?.querySelector?.(n)?S.text(y):(f(a)?.textContent||"").trim()}let g=u(a);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!l){S.text(g,m);return}let p=s().cloneOf(g);p?h(g,p,"textContent",m):S.text(g,m)},attr(a,m,g){let p=u(a);if(g===void 0)return S.attr(p,m);S.attr(p,m,g);let y=l?.cloneOf(p);y&&(S.attr(y,m,g),ee(p,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),l.liveToClone.delete(p),l.cloneToLive.delete(y)))},removeAttr(a,m){let g=u(a);S.removeAttr(g,m);let p=l?.cloneOf(g);p&&S.removeAttr(p,m)},prop(a,m,g){let p=u(a);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?S.prop(f(p),m):S.prop(p,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",w=y?s().cloneOf(p):l?.cloneOf(p);w&&y?h(p,w,m,g):(S.prop(p,m,g),w&&S.prop(w,m,g))},clone(a){let m=f(a);if(m===a)return S.clone(a);let g=c.importNode(m,!0);return pt(g),g},insertAt(a,m,g){let p=u(a),w=A.children(p)[g]||(()=>{for(let O=p.children.length-1;O>=0;O--){let T=p.children[O];if(s().cloneOf(T))return T.nextElementSibling}return p.firstElementChild})(),E=u(m);p.insertBefore(E,w||null);let x=s().cloneOf(p);if(x){let O=s().cloneOf(E);O||(O=c.importNode(E,!0),d(E,O));let T=Array.from(x.children);x.insertBefore(O,T[g]||null)}},insertBefore(a,m){let g=u(a),p=u(m);g.parentNode.insertBefore(p,g);let y=s().cloneOf(g.parentNode);if(y){let w=s().cloneOf(p);w||(w=c.importNode(p,!0),d(p,w));let E=s().cloneOf(g);E?E.before(w):y.appendChild(w)}},insertAfter(a,m){let g=u(a),p=u(m);g.parentNode.insertBefore(p,g.nextSibling);let y=s().cloneOf(g.parentNode);if(y){let w=s().cloneOf(p);w||(w=c.importNode(p,!0),d(p,w));let E=s().cloneOf(g);E?E.after(w):y.appendChild(w)}},identity(a){return u(a)||null},remove(a){let m=u(a),g=s().cloneOf(m);S.remove(m),g&&S.remove(g)},replaceWith(a,m){let g=u(a),p=s().cloneOf(g),y=S.replaceWith(g,m);if(p){let w=ee(y,{capability:"data",exclude:t.exclude||null});if(!w.root)p.remove();else{p.replaceWith(w.root);let E=x=>{let O=w.original(x);O&&(l.liveToClone.set(O,x),l.cloneToLive.set(x,O));for(let T of Array.from(x.childNodes||[]))E(T)};E(w.root)}}return y}};return A}var te=S;var ne=e=>({codecs:Oe(),...e}),de={extract:(e,t,n={})=>L(I(e,n),e,t,ne(n)),apply:(e,t,n,i={})=>D(I(e,{...i,_write:!0}),e,t,n,ne(i)),findRulesIn:(e,t)=>W(te,e,t),findRules:(e,t)=>Le(te,e,t),bind:(e,t,n={})=>{let i=Le(te,e,t);if(!i){let o=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${o}`)}let r=ne({version:i.version,...n});return{...i,get:()=>L(I(e,n),e,i.rules,r),set:o=>D(I(e,{...n,_write:!0}),e,i.rules,o,r)}},codecs:{register:Ee,get:Te},parseStrict:Ne,parseRelaxed:Y,ruleAttrIndex:N,splitRule:b,errors:R,DOM_PROPERTIES:re},Ie=e=>!!e&&typeof e.nodeType=="number";function mt(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=W(te,t,"api");if(!n)throw new R.NoRulesTag("api");return{rules:n.rules,version:n.version}}function cn(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let n=e;for(;n.parentNode;)n=n.parentNode;return n}function ln(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let n of e.childNodes)t.appendChild(n.cloneNode(!0));return t}function fn(e,t){let n=[];for(;t!==e;){let i=t.parentNode;n.push(Array.prototype.indexOf.call(i.childNodes,t)),t=i}return n.reverse()}function un(e,t){return t.reduce((n,i)=>n.childNodes[i],e)}function q(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function an(e,t){let n=q(e,"option"),i=q(t,"option");n.forEach((s,f)=>i[f].selected=s.selected);let r=q(e,"input"),o=q(t,"input");r.forEach((s,f)=>{let u=s.type.toLowerCase();u!=="file"&&(o[f].value=s.value),(u==="checkbox"||u==="radio")&&(o[f].checked=s.checked)});let c=q(e,"textarea"),l=q(t,"textarea");c.forEach((s,f)=>l[f].value=s.value)}function _e(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:N(e);if(n===-1)return;let i=e.slice(n+1);if(B.has(i))throw new R.RuleTargetReadOnly(i);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>_e(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,i]of Object.entries(e))_e(i,t[n])}}function dn(e,t,n,i){let r=ne({templateAttr:"cms-template",version:i}),o=cn(e),c=fn(o,e),l=ln(o);an(o,l);let s=un(l,c),f=I(l,{...r,_write:!0}),u=ke(f,s,t,n,r);if(u.unknownKeys.length||u.unmatched.length)throw new R.WriteRejected(u.unknownKeys,u.unmatched);let d=ae(f);D(d,s,t,n,r),d.assertClean(),_e(t,n);let h=ae(I(o,{...r,_write:!0}));D(h,e,t,n,r),h.assertClean()}function hn(e){if(!(e instanceof Error))return e;let n=e instanceof R.UnknownCodec||e instanceof R.CodecRefused?e.code:e.name||"Error";try{e.code=n}catch{Object.defineProperty(e,"code",{value:n,configurable:!0,enumerable:!0})}return e instanceof R.WriteRefused?e.details=e.refusals:e instanceof R.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof R.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function yt(e,t){let n=Ie(e)?e:document,i=Ie(e)?t:e;if(i===void 0){let{rules:r,version:o}=mt(n);return L(I(n),n,r,ne({version:o}))}return de.bind(n,i).get()}function gt(e,t,n){try{if(!Ie(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let{rules:i,version:r}=n===void 0?mt(e):de.bind(e,n);dn(e,i,t,r)}catch(i){throw hn(i)}return e}var pn={engine:de,extractData:yt,applyData:gt},$r=pn;export{gt as applyData,$r as default,de as engine,yt as extractData};
|
|
4
|
+
var At=Object.defineProperty;var Et=(e,t)=>{for(var n in t)At(e,n,{get:t[n],enumerable:!0})};var re=["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"],ie=new Set(re),he=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),B=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),$e=new Set(["checked","selected","disabled","readOnly","paused"]);function pe(e,t){return t==null?$e.has(e)?!1:"":$e.has(e)?t==="false"?!1:!!t:t}var R={};Et(R,{CodecRefused:()=>ge,EmptyListInsert:()=>P,MAX_RULE_DEPTH:()=>M,MaxRuleDepthExceeded:()=>_,NoRulesTag:()=>me,RuleTargetReadOnly:()=>z,RulesParseError:()=>C,ShapeMismatch:()=>U,UnknownCodec:()=>K,UnknownRulesVersion:()=>H,WriteNotRoundTripped:()=>oe,WriteRefused:()=>F,WriteRejected:()=>ye});var C=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},H=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=t}},M=20,_=class extends Error{constructor(t){super(`rule depth exceeded ${M} 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}},P=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}},z=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},F=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function Tt(e){return e.reduce((n,i)=>typeof i=="number"?`${n}[${i}]`:n?`${n}.${i}`:String(i),"")||"(root)"}var oe=class extends Error{constructor(t){super(`write did not round-trip at "${Tt(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},me=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},ye=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}},K=class extends Error{constructor(t){super(`unknown codec "${t}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=t}},ge=class extends Error{constructor(t,n){super(n),this.name="CodecRefused",this.code=t}};function N(e){let t=0,n=null,i=-1;for(let r=0;r<e.length;r++){let o=e[r];o==="\\"?r++:n?o===n&&(n=null):o==='"'||o==="'"?n=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(i=r)}return i}var je="[*]";function b(e){let t=N(e),n=t===-1?e:e.slice(0,t),i=n.endsWith(je),r={selector:i?n.slice(0,-je.length):n,prop:t===-1?null:e.slice(t+1)||null};return i&&(r.all=!0),r}function we(e){let t=0,n=null,i=-1,r=!1;for(let o=0;o<e.length;o++){let c=e[o];c==="\\"?o++:n?c===n&&(n=null):c==='"'||c==="'"?n=c:c==="["||c==="("?t++:c==="]"||c===")"?t>0&&t--:t===0&&c===">"?i=o:t===0&&c===","&&(r=!0)}return r||i===-1||!Ot(e,i+1)?null:e.slice(0,i).trim()||null}function Ot(e,t){let n=t,i=e.replace(/\s+$/,"").length;for(;n<i&&/\s/.test(e[n]);)n++;let r=0,o=null;for(;n<i;n++){let c=e[n];if(c==="\\")n++;else if(o)c===o&&(o=null);else if(c==='"'||c==="'")o=c;else if(c==="["||c==="(")r++;else if(c==="]"||c===")")r>0&&r--;else if(r===0&&(c==="+"||c==="~"||/\s/.test(c)))return!1}return!0}var St=/^codec\(([a-z][a-z0-9-]*)\)$/;function $(e){if(typeof e!="string")return null;let t=N(e);if(t===-1)return null;let n=St.exec(e.slice(t+1));if(!n)return null;let{selector:i,all:r}=b(e);if(r)throw new C("A @codec(name) rule cannot use [*].");return{selector:i,name:n[1]}}var xt=/^--[A-Za-z0-9_-]+$/;function k(e){return typeof e=="string"&&xt.test(e)}function De(e){let t=[],n=[],i=null,r=0;for(let o=0;o<e.length;o++){let c=e[o];if(i){c==="\\"?o++:c===i&&(i=null);continue}if(c==="/"&&e[o+1]==="*"){let l=e.indexOf("*/",o+2);o=l===-1?e.length:l+1;continue}c==='"'||c==="'"?i=c:c==="("?n.push(")"):c==="["?n.push("]"):c==="{"?n.push("}"):(c===")"||c==="]"||c==="}")&&n[n.length-1]===c?n.pop():c===";"&&n.length===0&&(t.push(e.slice(r,o)),r=o+1)}return t.push(e.slice(r)),t}function bt(e){let t="",n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){t+=r,r==="\\"&&i+1<e.length?t+=e[++i]:r===n&&(n=null);continue}if(r==="/"&&e[i+1]==="*"){let o=e.indexOf("*/",i+2);i=o===-1?e.length:o+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function ve(e){e=bt(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),i=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(i);return r&&(i=i.slice(0,r.index).trim()),{name:n,value:i,important:!!r}}function v(e,t){if(e==null)return null;let n=null;for(let i of De(String(e))){let r=ve(i);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function We(e,t,n){let i=e==null?"":String(e),r=n==null||n==="",o=De(i),c=o.map(ve),l=c.some(d=>d&&d.name===t&&d.important),s=[],f=!1;o.forEach((d,h)=>{let A=c[h];if(!A||A.name!==t){s.push(d);return}if(r||f)return;let a=/^\s*/.exec(d)[0];s.push(`${a}${t}: ${n}${l?" !important":""}`),f=!0});let u=s.join(";");if(!r&&!f){let d=u.trimEnd();u=d===""?`${t}: ${n}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${n}`}return u.trim()===""?null:u}function se(e,t,n,i){let r=e.attr(t,"style");if((v(r,n)??"")===i)return;let o=We(r,n,i);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}var qe=/^[a-z][a-z0-9-]*$/,Ae=new Map;function Ee(e,t){if(typeof e!="string"||!qe.test(e))throw new Error(`hyper-html-api: invalid codec name ${JSON.stringify(e)} (must match ${qe})`);if(!t||typeof t.read!="function"||typeof t.write!="function"||typeof t.same!="function")throw new Error(`hyper-html-api: codec "${e}" needs read, write and same functions`);Ae.set(e,t)}function Te(e){return Ae.get(e)??null}function Oe(){return Object.fromEntries(Ae)}var Rt='The @codec(name) rule form needs a rules tag with data-rules-version="2".',Ct="A @codec(name) rule must be the value of a top level key.";function ce(e,t){let n=$(e);return n?{...n,codec:t.codecs[n.name]}:null}function j(e,t={}){let n=t.version??"1",i=t.codecs??{};r(e,0);function r(o,c){if(!(c>M)){if(typeof o=="string"){let l=$(o);if(!l)return;if(n!=="2")throw new C(Rt);if(c!==1)throw new C(Ct);if(!Object.prototype.hasOwnProperty.call(i,l.name))throw new K(l.name);return}if(Array.isArray(o)){r(o[1],c+1);return}if(o&&typeof o=="object")for(let l of Object.values(o))r(l,c+1)}}}function L(e,t,n,i={}){if(Object.prototype.hasOwnProperty.call(i,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return j(n,i),xe(e,t,n,{depth:0,path:[]},i)}function xe(e,t,n,i,r){if(i.depth>M)throw new _(i.path);if(typeof n=="string")return Nt(e,t,n,i,r);if(Array.isArray(n)){let[o,c]=n,l=e.find(t,o,r);return Ve(r,i,l),l.map((s,f)=>xe(e,s,c,{depth:i.depth+1,path:[...i.path,f]},r))}if(typeof n=="object"&&n!==null){let o={};for(let[c,l]of Object.entries(n))o[c]=xe(e,t,l,{depth:i.depth+1,path:[...i.path,c]},r);return o}return null}function Nt(e,t,n,i,r){if(n.endsWith("[]")){let u=n.slice(0,-2),d=e.find(t,u,r);return Ve(r,i,d),d.map(h=>e.text(h))}let o=ce(n,r);if(o)return Pt(e,t,o,r);if(n.startsWith("@"))return Se(e,t,n.slice(1));let c=N(n);if(c!==-1){let{selector:u,all:d}=b(n),h=n.slice(c+1),A=u?e.find(t,u,r):[t];return d&&r.allMatches?A.map(a=>Se(e,a,h)):A.length===0?null:Se(e,A[0],h)}if(n===".")return e.text(t);let{selector:l,all:s}=b(n),f=e.find(t,l,r);return s&&r.allMatches?f.map(u=>e.text(u)):f.length===0?null:e.text(f[0])}function Pt(e,t,{selector:n,codec:i},r){let o=n?e.find(t,n,r):[t];return o.length===0?null:i.read(e,o[0],{query:r.query,view:r.view,region:r.region})}function Ve(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(i){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,i)}}function Se(e,t,n){if(k(n))return v(e.attr(t,"style"),n);if(ie.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let i=e.attr(t,n);return i??null}function Ue(e,t,n,i){let r=e.length,o=t.length,c=new Array(r).fill(-1);if(i){let p=new Set;for(let y=0;y<r;y++){let w=i[y];!(w>=0&&w<o)||p.has(w)||(c[y]=w,p.add(w))}}if(r===0||o===0)return c;let l=e.map(p=>Be(p,n)),s=t.map(p=>Be(p,n)),f=new Array(o).fill(!1);for(let p of c)p>=0&&(f[p]=!0);let u=new Map;s.forEach((p,y)=>{f[y]||u.set(p,u.has(p)?-1:y)});let d=new Map;l.forEach((p,y)=>{c[y]>=0||d.set(p,(d.get(p)||0)+1)}),l.forEach((p,y)=>{if(c[y]>=0||d.get(p)!==1)return;let w=u.get(p);w===void 0||w===-1||f[w]||(c[y]=w,f[w]=!0)});let h=[];for(let p=0;p<r;p++)c[p]<0&&h.push(p);let A=[];for(let p=0;p<o;p++)f[p]||A.push(p);if(h.length===0||A.length===0)return c;let a=r*o+1,m=Mt(e,t,n),g=(p,y)=>m(p,y)*a+Math.abs(p-y);for(let[p,y]of kt(h,A,g))c[p]=y;return c}var ze=e=>typeof e=="object"&&e!==null;function Be(e,t){if(!ze(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(i=>{let r=JSON.stringify(e?.[i]);return r===void 0?" undef":r}))}function Mt(e,t,n){if(!ze(n))return(l,s)=>e[l]===t[s]?0:1;let i=Object.keys(n),r=l=>i.map(s=>JSON.stringify(l?.[s])),o=e.map(r),c=t.map(r);return(l,s)=>{let f=o[l],u=c[s],d=0;for(let h=0;h<i.length;h++)f[h]!==u[h]&&d++;return d}}function kt(e,t,n){return e.length<=t.length?He(e,t,n,!1):He(t,e,(i,r)=>n(r,i),!0)}function He(e,t,n,i){let r=e.length,o=t.length,c=[];for(let d=0;d<=r;d++)c.push(new Float64Array(o+1).fill(1/0));let l=[];for(let d=0;d<=r;d++)l.push(new Uint8Array(o+1));for(let d=0;d<=o;d++)c[r][d]=0;for(let d=r-1;d>=0;d--)for(let h=o-1;h>=0;h--){let A=n(e[d],t[h])+c[d+1][h+1],a=c[d][h+1];A<=a?(c[d][h]=A,l[d][h]=1):c[d][h]=a}let s=[],f=0,u=0;for(;f<r&&u<o;)l[f][u]&&(s.push(i?[t[u],e[f]]:[e[f],t[u]]),f++),u++;return s}function Re(e,t,n,i,r,o,c,l={}){let s=e.find(t,n,l);if(r.length===0){s.forEach(E=>e.remove(E)),be(l,"onRowsApplied",o.path,[]);return}let f=r.length>s.length,u=s[0]||null;if(f&&!u&&(u=$t(e,t,n,l),!u))throw new P(o.path);let d=s.map(E=>_t(e,E,i,l)),h=null;if(f&&u){h=e.clone(u);let E=l.templateAttr&&e.attr(u,l.templateAttr)!=null;l.templateAttr&&e.removeAttr(h,l.templateAttr),E&&e.removeAttr(h,"hidden");let O=e.stripIds(h);O>0&&console.warn(`[hyper-html-api] stripped ${O} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let A=Ue(r,d,i,Lt(e,s,r,o,l)),a=s.length>0?e.parent(s[0]):Wt(e,t,n,u,o,l),m=s.length>0?Ye(e,a,s[0]):0,g=Bt(e,s),p=new Set,y=[],w=r.map((E,O)=>{let S=A[O];if(S>=0)return p.add(S),y.push(!1),s[S];y.push(!0);let T=e.clone(h);return e.stripIds(T),T});s.forEach((E,O)=>{p.has(O)||e.remove(E)}),g?Vt(e,a,m,w,y):Ht(e,w,y,a,m),It(e,w,i,r,o,c,l),be(l,"onRowsApplied",o.path,w)}function be(e,t,n,i){if(typeof e[t]=="function")try{return e[t](n.slice(),i)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function Lt(e,t,n,i,r){let o=be(r,"identifyRows",i.path,n);if(!Array.isArray(o))return null;let c=new Array(n.length).fill(-1),l=new Set,s=new Map(t.map((f,u)=>[e.identity(f),u]));for(let f=0;f<n.length;f++){if(!o[f])continue;let u=s.get(e.identity(o[f]));u===void 0||l.has(u)||(c[f]=u,l.add(u))}return c}function It(e,t,n,i,r,o,c){t.forEach((l,s)=>{if(n===null){let f=i[s],u=f==null?"":String(f);e.text(l)!==u&&e.text(l,u)}else{let f=o(e,l,n,i[s],{depth:r.depth+1,path:[...r.path,s]},c);f&&f!==l&&(t[s]=f)}})}function _t(e,t,n,i){return n===null?e.text(t):L(e,t,n,i.onRowsRead?{...i,onRowsRead:void 0}:i)}function Ye(e,t,n){let i=e.children(t);for(let r=0;r<i.length;r++)if(e.sameNode(i[r],n))return r;return-1}function $t(e,t,n,i){if(!i.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),o=new RegExp(":not\\(\\["+i.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),c=n.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),l=r?jt(c):0,s=we(c),f=t;for(;f;){let u=e.find(f,c,{includeRulesTag:!1,templateAttr:null});for(let d of u)if(e.attr(d,i.templateAttr)!=null&&!(r&&!vt(e,t,d,l))&&!(s&&!e.matches(e.parent(d),s)))return d;f=e.parent(f)}return null}function jt(e){let t=0,n=null,i=1;for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\")r++;else if(n)o===n&&(n=null);else if(o==='"'||o==="'")n=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")i++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!Dt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return i}function Dt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let i=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return Fe(i)||Fe(r)}function Fe(e){return e===">"||e==="+"||e==="~"}function vt(e,t,n,i){if(i===null)return!0;let r=n;for(let s=0;s<i;s++)if(r=e.parent(r),!r)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let c=e.prop(r,"tagName");if(!c||String(c).toLowerCase()!==String(o).toLowerCase())return!1;let l=new Set(Ke(e,r));return Ke(e,t).every(s=>l.has(s))}function Ke(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Wt(e,t,n,i,r,o){let c=e.parent(i);if(c&&qt(e,t,c)&&!Xe(e,c,o))return c;let l=we(n);if(!l)throw new P(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 f=(l===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,l,o)).filter(u=>!Xe(e,u,o));if(f.length===0)throw new P(r.path,`no container matching "${l}" inside this context to hold the new rows`);if(f.length>1)throw new P(r.path,`"${l}" matches ${f.length} containers inside this context, so the new rows have no single destination`);return f[0]}function qt(e,t,n){let i=n;for(;i;){if(e.sameNode(i,t))return!0;i=e.parent(i)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var Je=["no-data","editor-ui"];function Xe(e,t,n){let i=t;for(;i;){if(n.templateAttr&&e.attr(i,n.templateAttr)!=null||Je.some(o=>e.attr(i,o)!=null))return!0;let r=e.attr(i,"clay");if(r&&r.split(/\s+/).some(o=>Je.includes(o)))return!0;i=e.parent(i)}return!1}function Vt(e,t,n,i,r){let o=e.children(t),c=o.map(s=>e.identity(s)),l=!1;i.forEach((s,f)=>{let u=e.identity(s),d=n+f;if(c[d]===u)return;if(!r[f]){let A=c.indexOf(u);A!==-1&&(c.splice(A,1),o.splice(A,1))}let h=Math.min(d,o.length);h<o.length?e.insertBefore(o[h],s):o.length?l?e.insertAfter(o[o.length-1],s):(e.insertAt(t,s,d),l=!0):e.insertAt(t,s,0),c.splice(h,0,u),o.splice(h,0,s)})}function Bt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let i=new Map(e.children(n).map((o,c)=>[e.identity(o),c])),r=[];for(let o of t){let c=i.get(e.identity(o));if(c===void 0)return!1;r.push(c)}return r.sort((o,c)=>o-c),r[r.length-1]-r[0]===r.length-1}function Ht(e,t,n,i,r){let o=null,c=r;for(let l=0;l<t.length;l++){if(!n[l]){o=t[l];continue}let s=o?e.parent(o):i;if(!s)continue;let f=o?Ye(e,s,o)+1:c++;e.insertAt(s,t[l],f),o=t[l]}}function D(e,t,n,i,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.");j(n,r);let o=[];if(Ce(n,i,[],o),o.length)throw new U(o);le(e,t,n,i,{depth:0,path:[]},r)}function le(e,t,n,i,r,o={}){if(r.depth>M)throw new _(r.path);if(i===void 0)return t;if(typeof n=="string")return Ut(e,t,n,i,r,o);if(Array.isArray(n)){let[c,l]=n;return Re(e,t,c,l,i,r,le,o),t}if(typeof n=="object"&&n!==null){for(let[c,l]of Object.entries(n)){let s=le(e,t,l,i==null?i:i[c],{depth:r.depth+1,path:[...r.path,c]},o);s&&s!==t&&(t=s)}return t}return t}function Ut(e,t,n,i,r,o){if(n.endsWith("[]")){let d=n.slice(0,-2);return Re(e,t,d,null,i,r,le,o),t}let c=ce(n,o);if(c){let d=c.selector?e.find(t,c.selector,o):[t];return d.length&&c.codec.write(e,d[0],i,{query:o.query}),t}if(n.startsWith("@"))return Ze(e,t,n.slice(1),i);let l=N(n);if(l!==-1){let{selector:d,all:h}=b(n),A=n.slice(l+1),a=d?e.find(t,d,o):[t];for(let m of h?a:a.slice(0,1))Ze(e,m,A,i);return t}if(n===".")return Ge(e,t,i),t;let{selector:s,all:f}=b(n),u=e.find(t,s,o);for(let d of f?u:u.slice(0,1))Ge(e,d,i);return t}function Ge(e,t,n){let i=n==null?"":String(n);e.text(t)!==i&&e.text(t,i)}function zt(e,t,n,i){if(e.styleVar){e.styleVar(t,n,i);return}se(e,t,n,i)}function Ze(e,t,n,i){if(k(n))return zt(e,t,n,i==null?"":String(i).trim()),t;if(B.has(n)){let r=e.prop(t,n);if(r===i||r!=null&&i!=null&&String(r)===String(i))return t;throw new z(n)}if(n==="outerHTML"){let r=i==null?"":String(i);return e.replaceWith(t,r)}if(he.has(n)){let r=pe(n,i);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(i==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(i);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function Ce(e,t,n,i){if(t!==void 0){if(typeof e=="string"){if($(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,o)=>{typeof r=="object"&&r!==null&&i.push({path:X([...n,o]),expected:"scalar",got:J(r)})}):i.push({path:X(n),expected:"array",got:J(t)});return}t!==null&&typeof t=="object"&&i.push({path:X(n),expected:"scalar",got:J(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){i.push({path:X(n),expected:"array",got:J(t)});return}let r=e[1];t.forEach((o,c)=>Ce(r,o,[...n,c],i));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){i.push({path:X(n),expected:"object",got:J(t)});return}for(let[r,o]of Object.entries(e))Ce(o,t[r],[...n,r],i)}}}function J(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function X(e){return e.join(".")}function Ne(e){try{return JSON.parse(e)}catch(t){throw new C(`Invalid strict JSON: ${t.message}`,t)}}function Y(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 o=[],c=0;for(;c<r.length;){let l=r[c];if(/\s/.test(l)){c++;continue}if("{}".includes(l)){o.push({type:l,value:l}),c++;continue}if(l==="["){let d=!1,h=c+1;for(;h<r.length&&/\s/.test(r[h]);)h++;if(h<r.length&&/[a-zA-Z_]/.test(r[h])&&(d=!0),!d){o.push({type:l,value:l}),c++;continue}}if(l==="]"){o.push({type:l,value:l}),c++;continue}if(l===":"){o.push({type:t.COLON,value:l}),c++;continue}if(l===","){o.push({type:t.COMMA,value:l}),c++;continue}if(l==='"'||l==="'"){let d=l,h=c+1;for(;h<r.length&&r[h]!==d;)r[h]==="\\"&&h++,h++;o.push({type:t.STRING,value:r.substring(c+1,h),quoted:!0,sourceQuote:d}),c=h+1;continue}let s=c,f;for(;s<r.length&&!/[{},]/.test(r[s]);)if(r[s]===":"){let d=[":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"],h=!1;for(let A of d){let a=A.substring(1);if(r.substring(s+1,s+1+a.length)===a){h=!0,s+=a.length;break}}if(!h)break}else if(r[s]==="["){for(s++;s<r.length&&r[s]!=="]";){if(r[s]==='"'||r[s]==="'"){let d=r[s];for(s++;s<r.length&&r[s]!==d;)r[s]==="\\"&&s++,s++}s++}s<r.length&&r[s]==="]"&&s++}else s++;f=r.substring(c,s);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(f)?u=t.NUMBER:f==="true"||f==="false"||f==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(f)&&(u=t.SELECTOR),o.push({type:u,value:f,quoted:!1}),c=s}return o}function i(r){let o="";for(let c=0;c<r.length;c++){let l=r[c];if("{}".includes(l.type)||"[]".includes(l.type)){o+=l.value;continue}if(l.type===t.COLON){o+=l.value;continue}if(l.type===t.COMMA){let s=r[c+1];if(s&&(s.type==="}"||s.type==="]"))continue;o+=l.value;continue}if(l.type===t.STRING&&l.quoted){let s=l.value;l.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(f,u)=>u.length%2===0?u+'\\"':f)),o+=`"${s}"`;continue}if(l.type===t.NUMBER||l.type===t.BOOLEAN){o+=l.value;continue}if(l.type===t.SELECTOR||l.type===t.IDENTIFIER){o+=`"${l.value}"`;continue}o+=`"${l.value}"`}return o}try{let r=n(e),o=i(r);return JSON.parse(o)}catch(r){throw new C("Invalid extraction rules syntax: "+r.message,r)}}var et=["1","2"],Qe=/^[a-zA-Z0-9_-]+$/;function W(e,t,n){let i;if(n===void 0)i="script[data-rules-name]";else{if(typeof n!="string"||!Qe.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Qe})`);i=`script[data-rules-name~="${n}"]`}let r=e.find(t,i,{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 o=r[0],c=e.attr(o,"data-rules-version");if(!et.includes(c))throw new H(c);return{rules:Y(e.text(o)),tagNode:o,version:c}}var fe=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"]})}),Ft=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),tt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function G(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 Pe(e,t){if(G(e,t))return!0;for(let[n,i]of Object.entries(Ft))if(i.includes(t)&&G(e,n))return!0;return!1}function Z(e){let t=fe[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Kt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let i=fe[t];if(!i)throw new Error(`Unknown region capability: ${t}`);if(i.tokens.some(r=>Pe(n,r))||i.bundles.some(r=>G(n,r)))return n;n=n.parentElement}return null}function nt(e,t){return!!Kt(e,t)}var ue=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",...tt],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"]})}),Jt=new Set(["textContent","innerText"]);function rt(e){let n=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?n[1].toLowerCase():null}var Xt=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function it(e,t,n=ue){if(!Xt.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let i=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>i.startsWith(r)))return`attribute "${i}" can run script`;if(n.refusedAttributes.includes(i))return`attribute "${i}" is not content`;if(n.urlAttributes.includes(i)&&t!=null){let r=i==="srcset"?String(t).split(",").map(o=>o.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let o of r){let c=rt(o);if(c&&n.refusedSchemes.includes(c))return`"${c}:" URLs are not allowed in "${i}"`}}return null}function Me(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function Yt(e,t){let n=Me(e,t)||"node",i=e.attr(t,"id");return i?`<${n}#${i}>`:`<${n}>`}function Gt(e,t,n){let i=t;for(;i;){let r=Me(e,i);if(r&&n.refusedTargets.includes(r))return r;i=e.parent(i)}return null}function ot(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function Zt(e,t){return Me(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:ot(e,t)}function Qt(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],n=null;for(let i=0;i<e.length;i++){let r=e[i];if(n){r===n&&(n=null);continue}if(r==='"'||r==="'")n=r;else{if(r==="/"&&e[i+1]==="*")return"comments are not allowed in a custom property value";if(r==="(")t.push(")");else if(r==="[")t.push("]");else if((r===")"||r==="]")&&t.pop()!==r)return`"${r}" does not close anything in this custom property value`}}return n?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function st(e,t=ue){let n=t.customPropertyValues,i=String(e);if(i.length>n.maxLength)return`custom property values are limited to ${n.maxLength} characters`;let r=n.refusedCharacters.find(s=>i.includes(s));if(r)return`${JSON.stringify(r)} is not allowed in a custom property value`;let o=Qt(i);if(o)return o;let c=i.toLowerCase(),l=n.refusedFunctions.find(s=>new RegExp(`(^|[^a-z0-9_-])${s.replace(/[-]/g,"\\-")}\\s*\\(`).test(c));return l?`"${l}()" is not allowed in a custom property value`:null}function ae(e,t=ue){let n=[],i=(s,f)=>(n.push({target:Yt(e,s),reason:f}),!1),r=s=>{let f=Gt(e,s,t);return f?i(s,`inside <${f}>, which is not content`):!0},o=s=>r(s)?ot(e,s)?i(s,"a text write here would delete the data rules tag"):!0:!1,c=(s,f,u)=>{if(!r(s))return!1;let d=it(f,u,t);return d?i(s,d):!0};return{...e,text(s,f){if(f===void 0)return e.text(s);o(s)&&e.text(s,f)},attr(s,f,u){if(u===void 0)return e.attr(s,f);c(s,f,u)&&e.attr(s,f,u)},removeAttr(s,f){c(s,f,null)&&e.removeAttr(s,f)},styleVar(s,f,u){if((v(e.attr(s,"style"),f)??"")!==u&&r(s)){if(!k(f))return i(s,`"${f}" is not a custom property`);if(u!==""){let d=st(u,t);if(d)return i(s,d)}se(e,s,f,u)}},prop(s,f,u){if(u===void 0)return e.prop(s,f);if(t.refusedRuleForms.includes(f))return i(s,`"@${f}" writes HTML, only text is allowed`);if(Jt.has(f)){o(s)&&e.prop(s,f,u);return}c(s,f==="className"?"class":f,u)&&e.prop(s,f,u)},remove(s){if(Zt(e,s)){i(s,"removing this would delete the data rules tag");return}e.remove(s)},replaceWith(s,f){return f===e.prop(s,"outerHTML")||i(s,'"@outerHTML" writes HTML, only text is allowed'),s},refusals:n,assertClean(){if(n.length)throw new F(n.slice())}}}function Q(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ct(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function ke(e,t,n,i,r={}){j(n,r);let o=[],c=[];function l(f,u,d){if(Array.isArray(f)){let[,h]=f;if(!Array.isArray(u)||!Q(h))return;u.forEach((A,a)=>l(h,A,[...d,a]));return}if(!(!Q(f)||!Q(u)))for(let h of Object.keys(u))Object.prototype.hasOwnProperty.call(f,h)?l(f[h],u[h],[...d,h]):o.push(ct([...d,h]))}function s(f,u,d,h){if(d!==void 0){if(typeof u=="string"){if(u.endsWith("[]")||u==="."||u.startsWith("@"))return;let{selector:A}=b(u);if(!A)return;e.find(f,A,r).length===0&&c.push({path:ct(h),selector:A});return}if(!Array.isArray(u)&&Q(u)&&Q(d))for(let[A,a]of Object.entries(u))s(f,a,d[A],[...h,A])}}return l(n,i,[]),s(t,n,i,[]),{unknownKeys:o,unmatched:c}}function Le(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null,version:"1"};if(typeof n=="string"){let i=t&&t.ownerDocument?t.ownerDocument:t;return W(e,i,n)}return null}var tn=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function nn(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 lt(e,t,n,i){if(i)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 ft(e,t,n,i,r,o){return(o?nt(e,t):lt(e,n,r,!1))||!!(i&&(o&&e!==r?e.matches(i):lt(e,i,r,o)))}function rn(e,t){let n=fe[t];return n.tokens.some(i=>Pe(e,i))||n.bundles.some(i=>G(e,i))}var on=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function ut(e,t,n,i){if(e.nodeType===1&&i(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,o=t;if(e.nodeType===1){if(on.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,o=t.content,n.cloneToLive.set(o,r),n.liveToClone.set(r,o)}}else if(e.nodeType!==11)return;let c=o.firstChild;for(let l=r.firstChild;l&&c;l=l.nextSibling)ut(l,c,n,i),c=c.nextSibling}function ee(e,{capability:t="data",exclude:n=null,inherit:i=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let o=e.nodeType===9?e:e.ownerDocument;if(!o?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let c=o.implementation.createHTMLDocument(""),l=r||new WeakMap,s=new WeakMap,f=e.nodeType===9?e.documentElement:e;n&&c.documentElement.matches(n);let u=Z(t),d=i?a=>rn(a,t)||!!(n&&a.matches(n)):a=>ft(a,t,u,n,f,!1),h=null;if(f.nodeType!==1||!ft(f,t,u,n,f,i)){h=c.importNode(f,!0);let a={cloneToLive:l,liveToClone:s,dropped:[],controls:[]};ut(f,h,a,d);for(let m of a.dropped)m.remove();for(let m=0;m<a.controls.length;m+=2)nn(a.controls[m],a.controls[m+1])}e.nodeType===9&&h&&(c.replaceChild(h,c.documentElement),s.set(e,c),l.set(c,e));let A=a=>{if(tn.test(a))throw new Error(`Filtered content queries do not support stateful selector: ${a}`)};return{root:h,document:c,capability:t,selector:Z(t),cloneToLive:l,liveToClone:s,original(a){return l.get(a)||null},cloneOf(a){return s.get(a)||null},query(a,m=h){return A(a),Array.from(m.querySelectorAll(a),g=>l.get(g)||g)},text(a=h){return(a===h?h:s.get(a))?.textContent||""},html(a=h){return(a===h?h:s.get(a))?.innerHTML??""},clone(a=h){let m=a===h?h:s.get(a);return m?c.importNode(m,!0):null}}}function dt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function sn(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function at(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 ht(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function pt(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 i=n.type;i!=="file"&&i!=="checkbox"&&i!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var x={semanticExclude:!0,find(e,t,n={}){let i=sn(e);if(!i||!i.querySelectorAll)return[];let r=Array.from(i.querySelectorAll(t));n.includeRulesTag||(r=r.filter(l=>!dt(l)));let o=[];n.skip&&o.push(n.skip);let c=n.templateAttr===null?null:n.templateAttr||"cms-template";if(c&&o.push("["+c+"]"),o.length){let l=o.join(", ");r=r.filter(s=>!s.closest||!s.closest(l))}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,ht(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),at(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),at(e,t,null)},prop(e,t,n){if(n===void 0){let i=e?e[t]:void 0;return i!==void 0?i:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return pt(t),t},insertAt(e,t,n){let i=e.children[n]||null;e.insertBefore(t,i)},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 i=e.ownerDocument.createElement("template");i.innerHTML=t;let r=i.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(i=>{i.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function I(e,t={}){if(t.exclude===null)return x;let n=[Z("data"),t.exclude].filter(Boolean).join(", "),i=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!i?.querySelector?.(n))return x;let o=e.nodeType===9||!e.isConnected?e:e.ownerDocument,c=e.nodeType===9?e:e.ownerDocument,l=null,s=()=>l||(l=ee(o,{capability:"data",exclude:t.exclude||null})),f=a=>{let m=s();return a===e?m.cloneOf(e):m.cloneOf(a)||a},u=a=>l?.original(a)||a,d=(a,m)=>{s().liveToClone.set(a,m),s().cloneToLive.set(m,a);let g=a.childNodes||[],p=m.childNodes||[];for(let y=0;y<Math.min(g.length,p.length);y++)d(g[y],p[y])},h=(a,m,g,p)=>{let y=Array.from(a.childNodes).filter(T=>l.cloneOf(T)),E=y[0];for(;E&&y.includes(E);)E=E.nextSibling;for(let T of y)T.remove();if(g==="innerHTML"){let T=c.createElement("template");T.innerHTML=p;for(let V of Array.from(T.content.childNodes))a.insertBefore(V,E||null)}else a.insertBefore(c.createTextNode(p),E||null),ht(a,p);let O=ee(a,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(O.root?.childNodes||[]));let S=T=>{let V=O.original(T);V&&(l.liveToClone.set(V,T),l.cloneToLive.set(T,V));for(let wt of Array.from(T.childNodes||[]))S(wt)};for(let T of Array.from(m.childNodes))S(T)},A={...x,find(a,m,g={}){let p=f(a);if(!p?.querySelectorAll)return[];let y=s().query(m,p);g.includeRulesTag||(y=y.filter(O=>!dt(O)));let w=[];g.skip&&w.push(g.skip);let E=g.templateAttr===null?null:g.templateAttr||"cms-template";if(E&&w.push(`[${E}]`),w.length){let O=w.join(", ");y=y.filter(S=>!S.closest?.(O))}return y},parent(a){let m=f(a)?.parentElement;return m?u(m):null},children(a){return Array.from(f(a)?.children||[],u)},text(a,m){if(m===void 0){let y=u(a);return!y?.matches?.(n)&&!y?.querySelector?.(n)?x.text(y):(f(a)?.textContent||"").trim()}let g=u(a);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!l){x.text(g,m);return}let p=s().cloneOf(g);p?h(g,p,"textContent",m):x.text(g,m)},attr(a,m,g){let p=u(a);if(g===void 0)return x.attr(p,m);x.attr(p,m,g);let y=l?.cloneOf(p);y&&(x.attr(y,m,g),ee(p,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),l.liveToClone.delete(p),l.cloneToLive.delete(y)))},removeAttr(a,m){let g=u(a);x.removeAttr(g,m);let p=l?.cloneOf(g);p&&x.removeAttr(p,m)},prop(a,m,g){let p=u(a);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?x.prop(f(p),m):x.prop(p,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",w=y?s().cloneOf(p):l?.cloneOf(p);w&&y?h(p,w,m,g):(x.prop(p,m,g),w&&x.prop(w,m,g))},clone(a){let m=f(a);if(m===a)return x.clone(a);let g=c.importNode(m,!0);return pt(g),g},insertAt(a,m,g){let p=u(a),w=A.children(p)[g]||(()=>{for(let S=p.children.length-1;S>=0;S--){let T=p.children[S];if(s().cloneOf(T))return T.nextElementSibling}return p.firstElementChild})(),E=u(m);p.insertBefore(E,w||null);let O=s().cloneOf(p);if(O){let S=s().cloneOf(E);S||(S=c.importNode(E,!0),d(E,S));let T=Array.from(O.children);O.insertBefore(S,T[g]||null)}},insertBefore(a,m){let g=u(a),p=u(m);g.parentNode.insertBefore(p,g);let y=s().cloneOf(g.parentNode);if(y){let w=s().cloneOf(p);w||(w=c.importNode(p,!0),d(p,w));let E=s().cloneOf(g);E?E.before(w):y.appendChild(w)}},insertAfter(a,m){let g=u(a),p=u(m);g.parentNode.insertBefore(p,g.nextSibling);let y=s().cloneOf(g.parentNode);if(y){let w=s().cloneOf(p);w||(w=c.importNode(p,!0),d(p,w));let E=s().cloneOf(g);E?E.after(w):y.appendChild(w)}},identity(a){return u(a)||null},remove(a){let m=u(a),g=s().cloneOf(m);x.remove(m),g&&x.remove(g)},replaceWith(a,m){let g=u(a),p=s().cloneOf(g),y=x.replaceWith(g,m);if(p){let w=ee(y,{capability:"data",exclude:t.exclude||null});if(!w.root)p.remove();else{p.replaceWith(w.root);let E=O=>{let S=w.original(O);S&&(l.liveToClone.set(S,O),l.cloneToLive.set(O,S));for(let T of Array.from(O.childNodes||[]))E(T)};E(w.root)}}return y}};return A}var te=x;var ne=e=>({codecs:Oe(),...e}),de={extract:(e,t,n={})=>L(I(e,n),e,t,ne(n)),apply:(e,t,n,i={})=>D(I(e,{...i,_write:!0}),e,t,n,ne(i)),findRulesIn:(e,t)=>W(te,e,t),findRules:(e,t)=>Le(te,e,t),bind:(e,t,n={})=>{let i=Le(te,e,t);if(!i){let o=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${o}`)}let r=ne({version:i.version,...n});return{...i,get:()=>L(I(e,n),e,i.rules,r),set:o=>D(I(e,{...n,_write:!0}),e,i.rules,o,r)}},codecs:{register:Ee,get:Te},parseStrict:Ne,parseRelaxed:Y,ruleAttrIndex:N,splitRule:b,errors:R,DOM_PROPERTIES:re},Ie=e=>!!e&&typeof e.nodeType=="number";function mt(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=W(te,t,"api");if(!n)throw new R.NoRulesTag("api");return{rules:n.rules,version:n.version}}function cn(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let n=e;for(;n.parentNode;)n=n.parentNode;return n}function ln(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let n of e.childNodes)t.appendChild(n.cloneNode(!0));return t}function fn(e,t){let n=[];for(;t!==e;){let i=t.parentNode;n.push(Array.prototype.indexOf.call(i.childNodes,t)),t=i}return n.reverse()}function un(e,t){return t.reduce((n,i)=>n.childNodes[i],e)}function q(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function an(e,t){let n=q(e,"option"),i=q(t,"option");n.forEach((s,f)=>i[f].selected=s.selected);let r=q(e,"input"),o=q(t,"input");r.forEach((s,f)=>{let u=s.type.toLowerCase();u!=="file"&&(o[f].value=s.value),(u==="checkbox"||u==="radio")&&(o[f].checked=s.checked)});let c=q(e,"textarea"),l=q(t,"textarea");c.forEach((s,f)=>l[f].value=s.value)}function _e(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:N(e);if(n===-1)return;let i=e.slice(n+1);if(B.has(i))throw new R.RuleTargetReadOnly(i);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>_e(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,i]of Object.entries(e))_e(i,t[n])}}function dn(e,t,n,i){let r=ne({templateAttr:"cms-template",version:i}),o=cn(e),c=fn(o,e),l=ln(o);an(o,l);let s=un(l,c),f=I(l,{...r,_write:!0}),u=ke(f,s,t,n,r);if(u.unknownKeys.length||u.unmatched.length)throw new R.WriteRejected(u.unknownKeys,u.unmatched);let d=ae(f);D(d,s,t,n,r),d.assertClean(),_e(t,n);let h=ae(I(o,{...r,_write:!0}));D(h,e,t,n,r),h.assertClean()}function hn(e){if(!(e instanceof Error))return e;let n=e instanceof R.UnknownCodec||e instanceof R.CodecRefused?e.code:e.name||"Error";try{e.code=n}catch{Object.defineProperty(e,"code",{value:n,configurable:!0,enumerable:!0})}return e instanceof R.WriteRefused?e.details=e.refusals:e instanceof R.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof R.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function yt(e,t){let n=Ie(e)?e:document,i=Ie(e)?t:e;if(i===void 0){let{rules:r,version:o}=mt(n);return L(I(n),n,r,ne({version:o}))}return de.bind(n,i).get()}function gt(e,t,n){try{if(!Ie(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let{rules:i,version:r}=n===void 0?mt(e):de.bind(e,n);dn(e,i,t,r)}catch(i){throw hn(i)}return e}var pn={engine:de,extractData:yt,applyData:gt},$r=pn;export{gt as applyData,$r as default,de as engine,yt as extractData};
|