@panphora/clayjs 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/clay.standalone.js +1595 -828
- package/entries/sap.js +1 -1
- package/package.json +1 -1
- package/src/core/admin-contenteditable.js +4 -1
- package/src/core/admin-inputs.js +23 -13
- package/src/core/admin-onclick.js +5 -0
- package/src/core/is-edit-mode.js +7 -2
- package/src/core/save.js +13 -1
- package/src/core/snapshot.js +44 -1
- package/src/core/source-map.js +246 -38
- package/src/loader-logic.js +8 -2
- package/src/loader.js +2 -0
- package/src/plugins/ai-edit.js +625 -0
- package/src/plugins/source.js +150 -66
- package/src/sync/live-sync.js +3 -0
- package/src/vendor/control-serialize.vendor.js +10 -6
- package/src/vendor/hyper-morph.vendor.js +2 -2
package/dist/clay.standalone.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* clayjs 1.
|
|
1
|
+
/* clayjs 1.4.0 standalone build: every clayjs module in one file. https://clayjs.com/offline
|
|
2
2
|
Third-party code inside keeps its own license (Sortable MIT, Squire MIT, DOMPurify Apache-2.0 OR MPL-2.0, MicroModal MIT, parse5 MIT): https://clayjs.com/THIRD-PARTY-NOTICES.md */
|
|
3
3
|
(() => {
|
|
4
4
|
var __create = Object.create;
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
isEditMode: () => isEditMode,
|
|
170
170
|
isOwner: () => isOwner
|
|
171
171
|
});
|
|
172
|
-
var forcedEditMode, isEditMode, isOwner;
|
|
172
|
+
var forcedEditMode, isViewOnlyDocument, isEditMode, isOwner;
|
|
173
173
|
var init_is_edit_mode = __esm({
|
|
174
174
|
"src/core/is-edit-mode.js"() {
|
|
175
175
|
init_cookie();
|
|
@@ -183,7 +183,8 @@
|
|
|
183
183
|
forcedEditMode = Boolean(window.__hyperclayEditMode);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
isViewOnlyDocument = typeof document !== "undefined" && document.documentElement.hasAttribute("viewonly");
|
|
187
|
+
isEditMode = query_default.editmode ? query_default.editmode === "true" : isViewOnlyDocument || servedStaleToken() ? false : forcedEditMode != null ? forcedEditMode : hasSaveToken() || Boolean(cookie_default.get("isAdminOfCurrentResource"));
|
|
187
188
|
isOwner = Boolean(cookie_default.get("isAdminOfCurrentResource"));
|
|
188
189
|
}
|
|
189
190
|
});
|
|
@@ -1235,10 +1236,10 @@
|
|
|
1235
1236
|
}
|
|
1236
1237
|
for (const el4 of clone.querySelectorAll(`[${AUTHORED}]`)) {
|
|
1237
1238
|
const attr = el4.getAttribute(ATTR);
|
|
1238
|
-
const
|
|
1239
|
+
const authored2 = el4.getAttribute(AUTHORED);
|
|
1239
1240
|
const runtime = el4.getAttribute(RUNTIME);
|
|
1240
1241
|
if (attr && el4.getAttribute(attr) === runtime) {
|
|
1241
|
-
if (
|
|
1242
|
+
if (authored2) el4.setAttribute(attr, authored2);
|
|
1242
1243
|
else el4.removeAttribute(attr);
|
|
1243
1244
|
}
|
|
1244
1245
|
for (const name of OWNED) el4.removeAttribute(name);
|
|
@@ -1405,8 +1406,38 @@
|
|
|
1405
1406
|
function setSaveRenderer(renderer) {
|
|
1406
1407
|
saveRenderer = renderer;
|
|
1407
1408
|
}
|
|
1409
|
+
function serializeClone(clone) {
|
|
1410
|
+
const blocks = [];
|
|
1411
|
+
const collect = (node) => {
|
|
1412
|
+
for (const child of node.childNodes) {
|
|
1413
|
+
if (child.nodeType !== 1) continue;
|
|
1414
|
+
if (child.localName === "noscript" && child.namespaceURI === XHTML_NS) {
|
|
1415
|
+
const kids = Array.from(child.childNodes);
|
|
1416
|
+
if (kids.length && kids.every((n2) => n2.nodeType === 3)) blocks.push([child, kids]);
|
|
1417
|
+
continue;
|
|
1418
|
+
}
|
|
1419
|
+
collect(child.localName === "template" && child.content ? child.content : child);
|
|
1420
|
+
}
|
|
1421
|
+
};
|
|
1422
|
+
collect(clone);
|
|
1423
|
+
if (!blocks.length) return "<!DOCTYPE html>" + clone.outerHTML;
|
|
1424
|
+
const nonce = Math.random().toString(36).slice(2);
|
|
1425
|
+
const raw = blocks.map(([el4, kids], i2) => {
|
|
1426
|
+
const marker = `\uE000clay-noscript-${nonce}-${i2}\uE000`;
|
|
1427
|
+
el4.replaceChildren(el4.ownerDocument.createTextNode(marker));
|
|
1428
|
+
return [marker, kids.map((n2) => n2.data).join("")];
|
|
1429
|
+
});
|
|
1430
|
+
let html;
|
|
1431
|
+
try {
|
|
1432
|
+
html = "<!DOCTYPE html>" + clone.outerHTML;
|
|
1433
|
+
} finally {
|
|
1434
|
+
for (const [el4, kids] of blocks) el4.replaceChildren(...kids);
|
|
1435
|
+
}
|
|
1436
|
+
for (const [marker, text] of raw) html = html.split(marker).join(text);
|
|
1437
|
+
return html;
|
|
1438
|
+
}
|
|
1408
1439
|
function serializeSaveClone(clone) {
|
|
1409
|
-
const today =
|
|
1440
|
+
const today = serializeClone(clone);
|
|
1410
1441
|
if (!saveRenderer) return today;
|
|
1411
1442
|
try {
|
|
1412
1443
|
return saveRenderer(clone, today);
|
|
@@ -1427,7 +1458,7 @@
|
|
|
1427
1458
|
window.__preventOnclone = prev;
|
|
1428
1459
|
}
|
|
1429
1460
|
}
|
|
1430
|
-
function captureSnapshot({ flushUndo = true, authored = true } = {}) {
|
|
1461
|
+
function captureSnapshot({ flushUndo = true, authored: authored2 = true } = {}) {
|
|
1431
1462
|
if (flushUndo && typeof window !== "undefined" && window.clay?.undo?.flush) {
|
|
1432
1463
|
window.clay.undo.flush();
|
|
1433
1464
|
}
|
|
@@ -1446,14 +1477,14 @@
|
|
|
1446
1477
|
}
|
|
1447
1478
|
restoreAuthoredUrls(clone);
|
|
1448
1479
|
stripSnapshotRegions(clone);
|
|
1449
|
-
if (
|
|
1480
|
+
if (authored2) runAuthoredHandlers(clone, "onbeforesnapshot");
|
|
1450
1481
|
stripSnapshotRegions(clone);
|
|
1451
1482
|
stripExtensionNoise(clone);
|
|
1452
1483
|
return clone;
|
|
1453
1484
|
}
|
|
1454
|
-
function prepareCloneForSave(clone, { authored = true } = {}) {
|
|
1485
|
+
function prepareCloneForSave(clone, { authored: authored2 = true } = {}) {
|
|
1455
1486
|
stripSnapshotRegions(clone);
|
|
1456
|
-
if (
|
|
1487
|
+
if (authored2) runAuthoredHandlers(clone, "onbeforesave");
|
|
1457
1488
|
for (const hook of documentTransforms) {
|
|
1458
1489
|
stripSnapshotRegions(clone);
|
|
1459
1490
|
hook(clone);
|
|
@@ -1464,8 +1495,8 @@
|
|
|
1464
1495
|
}
|
|
1465
1496
|
return clone;
|
|
1466
1497
|
}
|
|
1467
|
-
function captureSaveClone({ flushUndo = true, authored = true } = {}) {
|
|
1468
|
-
return prepareCloneForSave(captureSnapshot({ flushUndo, authored }), { authored });
|
|
1498
|
+
function captureSaveClone({ flushUndo = true, authored: authored2 = true } = {}) {
|
|
1499
|
+
return prepareCloneForSave(captureSnapshot({ flushUndo, authored: authored2 }), { authored: authored2 });
|
|
1469
1500
|
}
|
|
1470
1501
|
function captureForComparison({ flushUndo = true } = {}) {
|
|
1471
1502
|
const clone = captureSnapshot({ flushUndo });
|
|
@@ -1616,7 +1647,7 @@
|
|
|
1616
1647
|
function getPageContents() {
|
|
1617
1648
|
return captureForSave({ emitForSync: false });
|
|
1618
1649
|
}
|
|
1619
|
-
var snapshotHooks, documentTransforms, snapshotProvenance, saveRenderer;
|
|
1650
|
+
var snapshotHooks, documentTransforms, snapshotProvenance, saveRenderer, XHTML_NS;
|
|
1620
1651
|
var init_snapshot = __esm({
|
|
1621
1652
|
"src/core/snapshot.js"() {
|
|
1622
1653
|
init_extension_noise();
|
|
@@ -1628,6 +1659,7 @@
|
|
|
1628
1659
|
documentTransforms = [];
|
|
1629
1660
|
snapshotProvenance = /* @__PURE__ */ new WeakMap();
|
|
1630
1661
|
saveRenderer = null;
|
|
1662
|
+
XHTML_NS = "http://www.w3.org/1999/xhtml";
|
|
1631
1663
|
}
|
|
1632
1664
|
});
|
|
1633
1665
|
|
|
@@ -2170,7 +2202,7 @@
|
|
|
2170
2202
|
let lastCall = executeFirst ? 0 : Date.now();
|
|
2171
2203
|
let timeoutId = null;
|
|
2172
2204
|
let pending2 = [];
|
|
2173
|
-
function
|
|
2205
|
+
function settle3(ctx, args, waiting) {
|
|
2174
2206
|
let result2;
|
|
2175
2207
|
try {
|
|
2176
2208
|
result2 = callback.apply(ctx, args);
|
|
@@ -2198,7 +2230,7 @@
|
|
|
2198
2230
|
lastCall = now3;
|
|
2199
2231
|
const waiting = pending2.concat({ resolve, reject });
|
|
2200
2232
|
pending2 = [];
|
|
2201
|
-
|
|
2233
|
+
settle3(ctx, args, waiting);
|
|
2202
2234
|
} else {
|
|
2203
2235
|
pending2.push({ resolve, reject });
|
|
2204
2236
|
if (!timeoutId) {
|
|
@@ -2207,7 +2239,7 @@
|
|
|
2207
2239
|
timeoutId = null;
|
|
2208
2240
|
const waiting = pending2;
|
|
2209
2241
|
pending2 = [];
|
|
2210
|
-
|
|
2242
|
+
settle3(ctx, args, waiting);
|
|
2211
2243
|
}, remaining);
|
|
2212
2244
|
}
|
|
2213
2245
|
}
|
|
@@ -2799,6 +2831,9 @@
|
|
|
2799
2831
|
addDocumentTransform((clone) => {
|
|
2800
2832
|
for (const name of ROOT_LIBRARY_ATTRS) clone.removeAttribute(name);
|
|
2801
2833
|
});
|
|
2834
|
+
addDocumentTransform((clone) => {
|
|
2835
|
+
for (const name of [...SAVE_TOKEN_ATTRS, ...LEGACY_SAVE_TOKEN_ATTRS]) clone.removeAttribute(name);
|
|
2836
|
+
});
|
|
2802
2837
|
savingTimeout = null;
|
|
2803
2838
|
window.addEventListener("offline", () => {
|
|
2804
2839
|
setOfflineStateQuiet();
|
|
@@ -3060,15 +3095,15 @@
|
|
|
3060
3095
|
if (tag === "INPUT") {
|
|
3061
3096
|
const type = inputType(target);
|
|
3062
3097
|
if (type === "checkbox" || type === "radio") {
|
|
3063
|
-
if (source2.checked) target.
|
|
3064
|
-
else target.
|
|
3065
|
-
} else {
|
|
3098
|
+
if (!source2.checked) target.removeAttribute("checked");
|
|
3099
|
+
else if (!target.hasAttribute("checked")) target.setAttribute("checked", "");
|
|
3100
|
+
} else if (source2.value !== (target.getAttribute("value") ?? "")) {
|
|
3066
3101
|
target.setAttribute("value", source2.value);
|
|
3067
3102
|
}
|
|
3068
3103
|
return;
|
|
3069
3104
|
}
|
|
3070
3105
|
if (tag === "TEXTAREA") {
|
|
3071
|
-
target.textContent = source2.value;
|
|
3106
|
+
if (target.textContent !== source2.value) target.textContent = source2.value;
|
|
3072
3107
|
target.removeAttribute("data-value");
|
|
3073
3108
|
return;
|
|
3074
3109
|
}
|
|
@@ -3076,8 +3111,8 @@
|
|
|
3076
3111
|
const tOpts = target.options;
|
|
3077
3112
|
const sOpts = source2.options;
|
|
3078
3113
|
for (let i2 = 0; i2 < tOpts.length; i2++) {
|
|
3079
|
-
if (sOpts[i2] && sOpts[i2].selected) tOpts[i2].
|
|
3080
|
-
else tOpts[i2].
|
|
3114
|
+
if (!(sOpts[i2] && sOpts[i2].selected)) tOpts[i2].removeAttribute("selected");
|
|
3115
|
+
else if (!tOpts[i2].hasAttribute("selected")) tOpts[i2].setAttribute("selected", "");
|
|
3081
3116
|
}
|
|
3082
3117
|
}
|
|
3083
3118
|
}
|
|
@@ -3152,7 +3187,8 @@
|
|
|
3152
3187
|
function enableContentEditable(root3 = document) {
|
|
3153
3188
|
root3.querySelectorAll(SELECTOR).forEach((el4) => {
|
|
3154
3189
|
const val = el4.getAttribute("inert-contenteditable");
|
|
3155
|
-
|
|
3190
|
+
const keyword = val === null ? null : val.toLowerCase();
|
|
3191
|
+
el4.setAttribute("contenteditable", ["", "true", "false", "plaintext-only"].includes(keyword) ? val : "true");
|
|
3156
3192
|
el4.removeAttribute("inert-contenteditable");
|
|
3157
3193
|
});
|
|
3158
3194
|
}
|
|
@@ -3173,12 +3209,14 @@
|
|
|
3173
3209
|
// src/core/admin-inputs.js
|
|
3174
3210
|
function disableAdminInputsBeforeSave() {
|
|
3175
3211
|
addDocumentTransform((docElem) => {
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3212
|
+
for (const [selector, name] of BOOLEANS) {
|
|
3213
|
+
docElem.querySelectorAll(selector).forEach((input) => {
|
|
3214
|
+
if (input.hasAttribute(name)) return;
|
|
3215
|
+
const live = originalSnapshotNode(input);
|
|
3216
|
+
const spelled = live && authored.get(live);
|
|
3217
|
+
input.setAttribute(name, spelled && spelled[name] !== void 0 ? spelled[name] : "");
|
|
3218
|
+
});
|
|
3219
|
+
}
|
|
3182
3220
|
});
|
|
3183
3221
|
}
|
|
3184
3222
|
function enableAdminInputsOnPageLoad() {
|
|
@@ -3188,18 +3226,19 @@
|
|
|
3188
3226
|
});
|
|
3189
3227
|
}
|
|
3190
3228
|
function enableAdminInputs(root3 = document) {
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3229
|
+
for (const [selector, name] of BOOLEANS) {
|
|
3230
|
+
root3.querySelectorAll(selector).forEach((input) => {
|
|
3231
|
+
const value = input.getAttribute(name);
|
|
3232
|
+
if (value !== null) authored.set(input, { ...authored.get(input) || {}, [name]: value });
|
|
3233
|
+
input.removeAttribute(name);
|
|
3234
|
+
});
|
|
3235
|
+
}
|
|
3197
3236
|
}
|
|
3198
3237
|
function init7() {
|
|
3199
3238
|
disableAdminInputsBeforeSave();
|
|
3200
3239
|
enableAdminInputsOnPageLoad();
|
|
3201
3240
|
}
|
|
3202
|
-
var SELECTOR_DISABLED, SELECTOR_READONLY;
|
|
3241
|
+
var SELECTOR_DISABLED, SELECTOR_READONLY, BOOLEANS, authored;
|
|
3203
3242
|
var init_admin_inputs = __esm({
|
|
3204
3243
|
"src/core/admin-inputs.js"() {
|
|
3205
3244
|
init_is_edit_mode();
|
|
@@ -3207,6 +3246,8 @@
|
|
|
3207
3246
|
init_snapshot();
|
|
3208
3247
|
SELECTOR_DISABLED = "[viewmode\\:disabled]";
|
|
3209
3248
|
SELECTOR_READONLY = "[viewmode\\:readonly]";
|
|
3249
|
+
BOOLEANS = [[SELECTOR_DISABLED, "disabled"], [SELECTOR_READONLY, "readonly"]];
|
|
3250
|
+
authored = /* @__PURE__ */ new WeakMap();
|
|
3210
3251
|
}
|
|
3211
3252
|
});
|
|
3212
3253
|
|
|
@@ -3215,6 +3256,7 @@
|
|
|
3215
3256
|
addDocumentTransform((docElem) => {
|
|
3216
3257
|
docElem.querySelectorAll(SELECTOR2).forEach((resource) => {
|
|
3217
3258
|
const originalValue = resource.getAttribute("onclick");
|
|
3259
|
+
if (originalValue === null) return;
|
|
3218
3260
|
resource.setAttribute("inert-onclick", originalValue);
|
|
3219
3261
|
resource.removeAttribute("onclick");
|
|
3220
3262
|
});
|
|
@@ -3565,244 +3607,244 @@
|
|
|
3565
3607
|
var init_hyper_morph_vendor = __esm({
|
|
3566
3608
|
"src/vendor/hyper-morph.vendor.js"() {
|
|
3567
3609
|
HyperMorph = (() => {
|
|
3568
|
-
var
|
|
3610
|
+
var we3 = Object.defineProperty;
|
|
3569
3611
|
var nt3 = Object.getOwnPropertyDescriptor;
|
|
3570
3612
|
var rt3 = Object.getOwnPropertyNames;
|
|
3571
3613
|
var st3 = Object.prototype.hasOwnProperty;
|
|
3572
|
-
var it3 = (e,
|
|
3573
|
-
for (var
|
|
3574
|
-
}, ot3 = (e,
|
|
3575
|
-
if (
|
|
3614
|
+
var it3 = (e, t) => {
|
|
3615
|
+
for (var n2 in t) we3(e, n2, { get: t[n2], enumerable: true });
|
|
3616
|
+
}, ot3 = (e, t, n2, g) => {
|
|
3617
|
+
if (t && typeof t == "object" || typeof t == "function") for (let u2 of rt3(t)) !st3.call(e, u2) && u2 !== n2 && we3(e, u2, { get: () => t[u2], enumerable: !(g = nt3(t, u2)) || g.enumerable });
|
|
3576
3618
|
return e;
|
|
3577
3619
|
};
|
|
3578
|
-
var at3 = (e) => ot3(
|
|
3620
|
+
var at3 = (e) => ot3(we3({}, "__esModule", { value: true }), e);
|
|
3579
3621
|
var Ht3 = {};
|
|
3580
|
-
it3(Ht3, { HyperMorph: () =>
|
|
3622
|
+
it3(Ht3, { HyperMorph: () => de3, default: () => Bt3, defaults: () => Ct3, findChangedRoots: () => Lt2, mergeJson: () => ve3, mergeScriptText: () => Me3, morph: () => xt3, parseJsonRelaxed: () => me3, parseRulesRelaxed: () => Ie3, spliceProtected: () => Rt3 });
|
|
3581
3623
|
var Pe3 = { includeClasses: true, includeAttributes: ["href", "src", "name", "type", "role", "aria-label", "alt", "title"], excludeAttributePrefixes: ["data-morph-", "data-hyper-", "data-im-"], textHintLength: 64, excludeIds: true, maxPathDepth: 4, landmarks: ["HEADER", "NAV", "MAIN", "ASIDE", "FOOTER", "SECTION", "ARTICLE"], weights: { signature: 100, pathSegment: 10, textMatch: 20, textMismatch: 25, uniqueCandidate: 50, positionPenalty: 1, maxDriftPenalty: 19, slotMatch: 30 }, minConfidence: 101, maxScoredCandidates: 16 };
|
|
3582
3624
|
function ut3(e) {
|
|
3583
|
-
let
|
|
3584
|
-
for (let
|
|
3585
|
-
return Math.abs(
|
|
3625
|
+
let t = 5381;
|
|
3626
|
+
for (let n2 = 0; n2 < e.length; n2++) t = (t << 5) + t ^ e.charCodeAt(n2);
|
|
3627
|
+
return Math.abs(t).toString(36);
|
|
3586
3628
|
}
|
|
3587
3629
|
function ct3(e) {
|
|
3588
3630
|
if (e.classList && e.classList.length > 0) return Array.from(e.classList).sort().join(" ");
|
|
3589
|
-
let
|
|
3590
|
-
return
|
|
3631
|
+
let t = e.getAttribute?.("class");
|
|
3632
|
+
return t ? t.split(/\s+/).filter(Boolean).sort().join(" ") : "";
|
|
3591
3633
|
}
|
|
3592
|
-
function lt3(e,
|
|
3593
|
-
let
|
|
3594
|
-
for (let
|
|
3595
|
-
let u2 =
|
|
3596
|
-
u2 === "id" || u2 === "class" ||
|
|
3634
|
+
function lt3(e, t) {
|
|
3635
|
+
let n2 = [];
|
|
3636
|
+
for (let g of e.attributes || []) {
|
|
3637
|
+
let u2 = g.name;
|
|
3638
|
+
u2 === "id" || u2 === "class" || t.excludeAttributePrefixes.some((y2) => u2.startsWith(y2)) || t.includeAttributes.includes(u2) && n2.push(`${u2}=${g.value}`);
|
|
3597
3639
|
}
|
|
3598
|
-
return
|
|
3640
|
+
return n2.sort().join("|");
|
|
3599
3641
|
}
|
|
3600
|
-
function ft2(e,
|
|
3601
|
-
return (e.textContent || "").replace(/\s+/g, " ").trim().slice(0,
|
|
3642
|
+
function ft2(e, t) {
|
|
3643
|
+
return (e.textContent || "").replace(/\s+/g, " ").trim().slice(0, t.textHintLength);
|
|
3602
3644
|
}
|
|
3603
|
-
function dt3(e,
|
|
3604
|
-
let
|
|
3605
|
-
return
|
|
3645
|
+
function dt3(e, t) {
|
|
3646
|
+
let n2 = [e.tagName];
|
|
3647
|
+
return t.includeClasses && n2.push(ct3(e)), n2.push(lt3(e, t)), ut3(n2.join("|"));
|
|
3606
3648
|
}
|
|
3607
3649
|
function ht3(e) {
|
|
3608
|
-
let
|
|
3609
|
-
for (;
|
|
3610
|
-
return
|
|
3650
|
+
let t = e.tagName, n2 = 1, g = e.previousElementSibling;
|
|
3651
|
+
for (; g; ) g.tagName === t && n2++, g = g.previousElementSibling;
|
|
3652
|
+
return n2;
|
|
3611
3653
|
}
|
|
3612
|
-
function pt3(e,
|
|
3613
|
-
return e.getAttribute?.("id") || e.getAttribute?.("role") ? true :
|
|
3654
|
+
function pt3(e, t) {
|
|
3655
|
+
return e.getAttribute?.("id") || e.getAttribute?.("role") ? true : t.landmarks.includes(e.tagName);
|
|
3614
3656
|
}
|
|
3615
3657
|
function gt3(e) {
|
|
3616
|
-
let
|
|
3617
|
-
if (
|
|
3618
|
-
let
|
|
3619
|
-
return
|
|
3658
|
+
let t = e.getAttribute?.("id");
|
|
3659
|
+
if (t) return `#${t}`;
|
|
3660
|
+
let n2 = e.getAttribute?.("role");
|
|
3661
|
+
return n2 ? `@${n2}` : e.tagName;
|
|
3620
3662
|
}
|
|
3621
|
-
function mt3(e,
|
|
3622
|
-
let
|
|
3623
|
-
for (;
|
|
3624
|
-
let u2 = `${
|
|
3625
|
-
if (
|
|
3626
|
-
|
|
3663
|
+
function mt3(e, t) {
|
|
3664
|
+
let n2 = [], g = e;
|
|
3665
|
+
for (; g && g.tagName && n2.length < t.maxPathDepth; ) {
|
|
3666
|
+
let u2 = `${g.tagName}:${ht3(g)}`;
|
|
3667
|
+
if (n2.unshift(u2), g !== e && pt3(g, t)) {
|
|
3668
|
+
n2.unshift(gt3(g));
|
|
3627
3669
|
break;
|
|
3628
3670
|
}
|
|
3629
|
-
|
|
3671
|
+
g = g.parentElement;
|
|
3630
3672
|
}
|
|
3631
|
-
return
|
|
3673
|
+
return n2;
|
|
3632
3674
|
}
|
|
3633
|
-
function yt3(e,
|
|
3634
|
-
let
|
|
3635
|
-
for (;
|
|
3636
|
-
return
|
|
3675
|
+
function yt3(e, t) {
|
|
3676
|
+
let n2 = 0, g = e.length - 1, u2 = t.length - 1;
|
|
3677
|
+
for (; g >= 0 && u2 >= 0 && e[g] === t[u2]; ) n2++, g--, u2--;
|
|
3678
|
+
return n2;
|
|
3637
3679
|
}
|
|
3638
|
-
function X2(e,
|
|
3639
|
-
if (
|
|
3640
|
-
let
|
|
3641
|
-
return
|
|
3642
|
-
}
|
|
3643
|
-
function qe3(e,
|
|
3644
|
-
if (
|
|
3645
|
-
let u2 = /* @__PURE__ */ new Map(),
|
|
3646
|
-
for (let d of
|
|
3647
|
-
let M2 = X2(d,
|
|
3648
|
-
M2.domIndex = S2++, !
|
|
3649
|
-
}
|
|
3650
|
-
return
|
|
3651
|
-
}
|
|
3652
|
-
function bt3(e,
|
|
3653
|
-
|
|
3654
|
-
let
|
|
3655
|
-
for (let u2 of
|
|
3656
|
-
}
|
|
3657
|
-
function
|
|
3658
|
-
let
|
|
3659
|
-
if (
|
|
3660
|
-
|
|
3661
|
-
let
|
|
3662
|
-
|
|
3680
|
+
function X2(e, t, n2) {
|
|
3681
|
+
if (n2.has(e)) return n2.get(e);
|
|
3682
|
+
let g = { signature: dt3(e, t), path: mt3(e, t), textHint: ft2(e, t) };
|
|
3683
|
+
return n2.set(e, g), g;
|
|
3684
|
+
}
|
|
3685
|
+
function qe3(e, t, n2, g) {
|
|
3686
|
+
if (g.has(e)) return g.get(e);
|
|
3687
|
+
let u2 = /* @__PURE__ */ new Map(), y2 = e.querySelectorAll("*"), S2 = 0;
|
|
3688
|
+
for (let d of y2) {
|
|
3689
|
+
let M2 = X2(d, t, n2);
|
|
3690
|
+
M2.domIndex = S2++, !t.shouldIgnore?.(d) && (u2.has(M2.signature) || u2.set(M2.signature, []), u2.get(M2.signature).push(d));
|
|
3691
|
+
}
|
|
3692
|
+
return g.set(e, u2), u2;
|
|
3693
|
+
}
|
|
3694
|
+
function bt3(e, t, n2) {
|
|
3695
|
+
n2.delete(e), t.delete(e);
|
|
3696
|
+
let g = e.querySelectorAll("*");
|
|
3697
|
+
for (let u2 of g) t.delete(u2);
|
|
3698
|
+
}
|
|
3699
|
+
function Te3(e, t, n2, g, u2) {
|
|
3700
|
+
let y2 = X2(e, n2, g), S2 = X2(t, n2, g), d = n2.weights, M2 = {}, P2 = 0;
|
|
3701
|
+
if (y2.signature !== S2.signature) return { score: 0, breakdown: { rejected: "signature mismatch" } };
|
|
3702
|
+
P2 += d.signature, M2.signature = d.signature;
|
|
3703
|
+
let B2 = yt3(y2.path, S2.path) * d.pathSegment;
|
|
3704
|
+
P2 += B2, M2.path = B2;
|
|
3663
3705
|
let I2 = true;
|
|
3664
|
-
if (
|
|
3665
|
-
let k2 = Math.abs(
|
|
3666
|
-
|
|
3706
|
+
if (y2.textHint && S2.textHint ? y2.textHint === S2.textHint ? (P2 += d.textMatch, M2.text = d.textMatch) : (P2 -= d.textMismatch, M2.text = -d.textMismatch, I2 = false) : y2.textHint !== S2.textHint && (P2 -= d.textMismatch, M2.text = -d.textMismatch, I2 = false), u2.candidateCount === 1 && I2 && (P2 += d.uniqueCandidate, M2.unique = d.uniqueCandidate), typeof y2.domIndex == "number" && typeof S2.domIndex == "number") {
|
|
3707
|
+
let k2 = Math.abs(y2.domIndex - S2.domIndex), E2 = Math.min(k2 * d.positionPenalty, d.maxDriftPenalty);
|
|
3708
|
+
P2 -= E2, M2.drift = -E2;
|
|
3667
3709
|
}
|
|
3668
|
-
return { score:
|
|
3710
|
+
return { score: P2, breakdown: M2 };
|
|
3669
3711
|
}
|
|
3670
|
-
function De3(e,
|
|
3671
|
-
if (
|
|
3672
|
-
let
|
|
3712
|
+
function De3(e, t, n2, g, u2) {
|
|
3713
|
+
if (n2.excludeIds && e.getAttribute("id")) return null;
|
|
3714
|
+
let y2 = qe3(t, n2, g, u2), S2 = X2(e, n2, g);
|
|
3673
3715
|
if (typeof S2.domIndex != "number") {
|
|
3674
3716
|
let I2 = 0, k2 = e.previousElementSibling;
|
|
3675
3717
|
for (; k2; ) I2++, k2 = k2.previousElementSibling;
|
|
3676
3718
|
S2.domIndex = I2;
|
|
3677
3719
|
}
|
|
3678
|
-
let d =
|
|
3720
|
+
let d = y2.get(S2.signature) || [], M2 = n2.excludeIds ? d.filter((I2) => !I2.getAttribute("id")) : d;
|
|
3679
3721
|
if (M2.length === 0) return null;
|
|
3680
|
-
let
|
|
3722
|
+
let P2 = null, q2 = 0, B2 = null;
|
|
3681
3723
|
for (let I2 of M2) {
|
|
3682
|
-
let { score: k2, breakdown: E2 } =
|
|
3683
|
-
k2 > q2 && (q2 = k2,
|
|
3724
|
+
let { score: k2, breakdown: E2 } = Te3(e, I2, n2, g, { candidateCount: M2.length });
|
|
3725
|
+
k2 > q2 && (q2 = k2, P2 = I2, B2 = E2);
|
|
3684
3726
|
}
|
|
3685
|
-
return q2 <
|
|
3727
|
+
return q2 < n2.minConfidence ? null : { element: P2, confidence: q2, breakdown: B2 };
|
|
3686
3728
|
}
|
|
3687
|
-
function At2(e,
|
|
3688
|
-
let u2 = [],
|
|
3689
|
-
function d(
|
|
3690
|
-
if (
|
|
3691
|
-
let I2 =
|
|
3729
|
+
function At2(e, t, n2, g) {
|
|
3730
|
+
let u2 = [], y2 = n2.weights.signature + n2.weights.slotMatch, S2 = { slot: y2 };
|
|
3731
|
+
function d(B2) {
|
|
3732
|
+
if (B2.children) return B2.children;
|
|
3733
|
+
let I2 = B2.childNodes;
|
|
3692
3734
|
if (!I2) return [];
|
|
3693
3735
|
let k2 = [];
|
|
3694
3736
|
for (let E2 = 0; E2 < I2.length; E2++) I2[E2].nodeType === 1 && k2.push(I2[E2]);
|
|
3695
3737
|
return k2;
|
|
3696
3738
|
}
|
|
3697
|
-
function M2(
|
|
3698
|
-
let k2 = d(
|
|
3699
|
-
if (k2.length === E2.length) for (let
|
|
3700
|
-
let
|
|
3701
|
-
if (
|
|
3702
|
-
let Q3 = X2(
|
|
3703
|
-
Q3 !== ee3 && u2.push({ newEl:
|
|
3739
|
+
function M2(B2, I2) {
|
|
3740
|
+
let k2 = d(B2), E2 = d(I2);
|
|
3741
|
+
if (k2.length === E2.length) for (let U3 = 0; U3 < k2.length; U3++) {
|
|
3742
|
+
let J3 = k2[U3], W3 = E2[U3];
|
|
3743
|
+
if (n2.shouldIgnore?.(J3) || n2.shouldIgnore?.(W3) || n2.excludeIds && (J3.getAttribute("id") || W3.getAttribute("id")) || J3.tagName !== W3.tagName) continue;
|
|
3744
|
+
let Q3 = X2(J3, n2, g).signature, ee3 = X2(W3, n2, g).signature;
|
|
3745
|
+
Q3 !== ee3 && u2.push({ newEl: J3, oldEl: W3, score: y2, breakdown: S2 }), M2(J3, W3);
|
|
3704
3746
|
}
|
|
3705
3747
|
}
|
|
3706
|
-
function
|
|
3748
|
+
function P2(B2, I2) {
|
|
3707
3749
|
for (; ; ) {
|
|
3708
|
-
if (
|
|
3709
|
-
let k2 = d(
|
|
3710
|
-
if (!
|
|
3711
|
-
|
|
3750
|
+
if (B2.tagName === I2.tagName) return [B2, I2];
|
|
3751
|
+
let k2 = d(B2);
|
|
3752
|
+
if (!B2.tagName && k2.length === 1) {
|
|
3753
|
+
B2 = k2[0];
|
|
3712
3754
|
continue;
|
|
3713
3755
|
}
|
|
3714
3756
|
let E2 = d(I2);
|
|
3715
|
-
if (E2.length === 1 && E2[0].tagName ===
|
|
3757
|
+
if (E2.length === 1 && E2[0].tagName === B2.tagName) {
|
|
3716
3758
|
I2 = E2[0];
|
|
3717
3759
|
continue;
|
|
3718
3760
|
}
|
|
3719
3761
|
return null;
|
|
3720
3762
|
}
|
|
3721
3763
|
}
|
|
3722
|
-
let q2 =
|
|
3764
|
+
let q2 = P2(e, t);
|
|
3723
3765
|
return q2 && M2(q2[0], q2[1]), u2;
|
|
3724
3766
|
}
|
|
3725
|
-
function ze3(e,
|
|
3726
|
-
let
|
|
3727
|
-
for (let k2 of
|
|
3728
|
-
let E2 = X2(k2,
|
|
3767
|
+
function ze3(e, t, n2, g, u2) {
|
|
3768
|
+
let y2 = t.querySelectorAll("*"), S2 = qe3(e, n2, g, u2), d = 0;
|
|
3769
|
+
for (let k2 of y2) {
|
|
3770
|
+
let E2 = X2(k2, n2, g);
|
|
3729
3771
|
E2.domIndex = d++;
|
|
3730
3772
|
}
|
|
3731
|
-
let M2 = [],
|
|
3732
|
-
function q2(k2, E2,
|
|
3733
|
-
let
|
|
3773
|
+
let M2 = [], P2 = /* @__PURE__ */ new Map();
|
|
3774
|
+
function q2(k2, E2, U3) {
|
|
3775
|
+
let J3 = /* @__PURE__ */ new Set();
|
|
3734
3776
|
if (k2.textHint) {
|
|
3735
|
-
let
|
|
3736
|
-
if (!
|
|
3737
|
-
|
|
3738
|
-
for (let
|
|
3739
|
-
let
|
|
3740
|
-
|
|
3777
|
+
let Z3 = P2.get(k2.signature);
|
|
3778
|
+
if (!Z3) {
|
|
3779
|
+
Z3 = /* @__PURE__ */ new Map();
|
|
3780
|
+
for (let re3 of E2) {
|
|
3781
|
+
let be3 = X2(re3, n2, g).textHint, se3 = Z3.get(be3);
|
|
3782
|
+
se3 || (se3 = [], Z3.set(be3, se3)), se3.push(re3);
|
|
3741
3783
|
}
|
|
3742
|
-
|
|
3784
|
+
P2.set(k2.signature, Z3);
|
|
3743
3785
|
}
|
|
3744
|
-
let
|
|
3745
|
-
if (
|
|
3786
|
+
let he3 = Z3.get(k2.textHint);
|
|
3787
|
+
if (he3) for (let re3 = 0; re3 < he3.length && re3 < U3; re3++) J3.add(he3[re3]);
|
|
3746
3788
|
}
|
|
3747
|
-
let
|
|
3748
|
-
for (;
|
|
3749
|
-
let
|
|
3750
|
-
X2(E2[
|
|
3789
|
+
let W3 = 0, Q3 = E2.length;
|
|
3790
|
+
for (; W3 < Q3; ) {
|
|
3791
|
+
let Z3 = W3 + Q3 >> 1;
|
|
3792
|
+
X2(E2[Z3], n2, g).domIndex < k2.domIndex ? W3 = Z3 + 1 : Q3 = Z3;
|
|
3751
3793
|
}
|
|
3752
|
-
let ee3 = Math.max(0, Math.min(
|
|
3753
|
-
for (let
|
|
3754
|
-
return [...
|
|
3794
|
+
let ee3 = Math.max(0, Math.min(W3 - (U3 >> 1), E2.length - U3)), ne3 = Math.min(ee3 + U3, E2.length);
|
|
3795
|
+
for (let Z3 = ee3; Z3 < ne3; Z3++) J3.add(E2[Z3]);
|
|
3796
|
+
return [...J3];
|
|
3755
3797
|
}
|
|
3756
|
-
for (let k2 of
|
|
3757
|
-
if (
|
|
3758
|
-
let E2 = X2(k2,
|
|
3798
|
+
for (let k2 of y2) {
|
|
3799
|
+
if (n2.shouldIgnore?.(k2) || n2.excludeIds && k2.getAttribute("id")) continue;
|
|
3800
|
+
let E2 = X2(k2, n2, g), U3 = S2.get(E2.signature) || [], J3 = n2.excludeIds ? U3.filter((ee3) => !ee3.getAttribute("id")) : U3, W3 = n2.maxScoredCandidates, Q3 = W3 && J3.length > W3 ? q2(E2, J3, W3) : J3;
|
|
3759
3801
|
for (let ee3 of Q3) {
|
|
3760
|
-
let { score:
|
|
3761
|
-
|
|
3802
|
+
let { score: ne3, breakdown: Z3 } = Te3(k2, ee3, n2, g, { candidateCount: J3.length });
|
|
3803
|
+
ne3 >= n2.minConfidence && M2.push({ newEl: k2, oldEl: ee3, score: ne3, breakdown: Z3 });
|
|
3762
3804
|
}
|
|
3763
3805
|
}
|
|
3764
|
-
if (
|
|
3765
|
-
let k2 = At2(
|
|
3806
|
+
if (n2.weights.slotMatch > 0) {
|
|
3807
|
+
let k2 = At2(t, e, n2, g);
|
|
3766
3808
|
for (let E2 of k2) M2.push(E2);
|
|
3767
3809
|
}
|
|
3768
3810
|
M2.sort((k2, E2) => E2.score - k2.score);
|
|
3769
|
-
let
|
|
3770
|
-
for (let { newEl: k2, oldEl: E2 } of M2)
|
|
3771
|
-
return
|
|
3811
|
+
let B2 = /* @__PURE__ */ new Map(), I2 = /* @__PURE__ */ new Set();
|
|
3812
|
+
for (let { newEl: k2, oldEl: E2 } of M2) B2.has(k2) || I2.has(E2) || (B2.set(k2, E2), I2.add(E2));
|
|
3813
|
+
return B2;
|
|
3772
3814
|
}
|
|
3773
|
-
function _e3(e,
|
|
3774
|
-
let u2 = X2(e,
|
|
3775
|
-
return { matches: S2 >=
|
|
3815
|
+
function _e3(e, t, n2, g) {
|
|
3816
|
+
let u2 = X2(e, n2, g), y2 = X2(t, n2, g), { score: S2, breakdown: d } = Te3(e, t, n2, g, { candidateCount: 1 });
|
|
3817
|
+
return { matches: S2 >= n2.minConfidence, score: S2, breakdown: d, newMeta: { signature: u2.signature, path: u2.path, textHint: u2.textHint }, oldMeta: { signature: y2.signature, path: y2.path, textHint: y2.textHint } };
|
|
3776
3818
|
}
|
|
3777
3819
|
function Fe3(e = {}) {
|
|
3778
|
-
let
|
|
3779
|
-
return { findMatch: (u2,
|
|
3780
|
-
let u2 = /* @__PURE__ */ new WeakMap(),
|
|
3781
|
-
return { findMatch: (S2, d) => De3(S2, d,
|
|
3782
|
-
}, getConfig: () => ({ ...
|
|
3820
|
+
let t = { ...Pe3, ...e, weights: { ...Pe3.weights, ...e.weights } }, n2 = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap();
|
|
3821
|
+
return { findMatch: (u2, y2) => De3(u2, y2, t, n2, g), computeMatches: (u2, y2) => ze3(u2, y2, t, n2, g), explain: (u2, y2) => _e3(u2, y2, t, n2), invalidate: (u2) => bt3(u2, n2, g), session: () => {
|
|
3822
|
+
let u2 = /* @__PURE__ */ new WeakMap(), y2 = /* @__PURE__ */ new WeakMap();
|
|
3823
|
+
return { findMatch: (S2, d) => De3(S2, d, t, u2, y2), computeMatches: (S2, d) => ze3(S2, d, t, u2, y2), explain: (S2, d) => _e3(S2, d, t, u2) };
|
|
3824
|
+
}, getConfig: () => ({ ...t }) };
|
|
3783
3825
|
}
|
|
3784
|
-
function
|
|
3826
|
+
function Ee3(e, t) {
|
|
3785
3827
|
for (; ; ) {
|
|
3786
|
-
for (;
|
|
3787
|
-
if (e[
|
|
3788
|
-
for (;
|
|
3789
|
-
`; )
|
|
3828
|
+
for (; t < e.length && /\s/.test(e[t]); ) t++;
|
|
3829
|
+
if (e[t] === "/" && e[t + 1] === "/") {
|
|
3830
|
+
for (; t < e.length && e[t] !== `
|
|
3831
|
+
`; ) t++;
|
|
3790
3832
|
continue;
|
|
3791
3833
|
}
|
|
3792
|
-
if (e[
|
|
3793
|
-
let
|
|
3794
|
-
if (
|
|
3795
|
-
|
|
3834
|
+
if (e[t] === "/" && e[t + 1] === "*") {
|
|
3835
|
+
let n2 = e.indexOf("*/", t + 2);
|
|
3836
|
+
if (n2 === -1) return e.length;
|
|
3837
|
+
t = n2 + 2;
|
|
3796
3838
|
continue;
|
|
3797
3839
|
}
|
|
3798
|
-
return
|
|
3840
|
+
return t;
|
|
3799
3841
|
}
|
|
3800
3842
|
}
|
|
3801
3843
|
function Ve2(e) {
|
|
3802
|
-
return e.replace(/\\'/g, "'").replace(/(\\*)"/g, (
|
|
3844
|
+
return e.replace(/\\'/g, "'").replace(/(\\*)"/g, (t, n2) => n2.length % 2 === 0 ? n2 + '\\"' : t);
|
|
3803
3845
|
}
|
|
3804
3846
|
var St3 = /^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/, vt2 = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
3805
|
-
function
|
|
3847
|
+
function me3(e) {
|
|
3806
3848
|
try {
|
|
3807
3849
|
return JSON.parse(e);
|
|
3808
3850
|
} catch {
|
|
@@ -3810,59 +3852,59 @@
|
|
|
3810
3852
|
}
|
|
3811
3853
|
}
|
|
3812
3854
|
function Mt3(e) {
|
|
3813
|
-
let
|
|
3814
|
-
throw new Error(`Invalid relaxed JSON: ${u2} at position ${
|
|
3855
|
+
let t = "", n2 = 0, g = (u2, y2) => {
|
|
3856
|
+
throw new Error(`Invalid relaxed JSON: ${u2} at position ${y2}`);
|
|
3815
3857
|
};
|
|
3816
|
-
for (;
|
|
3817
|
-
let u2 = e[
|
|
3858
|
+
for (; n2 < e.length && (n2 = Ee3(e, n2), !(n2 >= e.length)); ) {
|
|
3859
|
+
let u2 = e[n2];
|
|
3818
3860
|
if ("{}[]:".includes(u2)) {
|
|
3819
|
-
|
|
3861
|
+
t += u2, n2++;
|
|
3820
3862
|
continue;
|
|
3821
3863
|
}
|
|
3822
3864
|
if (u2 === ",") {
|
|
3823
|
-
let d =
|
|
3865
|
+
let d = Ee3(e, n2 + 1);
|
|
3824
3866
|
if (e[d] === "}" || e[d] === "]") {
|
|
3825
|
-
|
|
3867
|
+
n2++;
|
|
3826
3868
|
continue;
|
|
3827
3869
|
}
|
|
3828
|
-
|
|
3870
|
+
t += u2, n2++;
|
|
3829
3871
|
continue;
|
|
3830
3872
|
}
|
|
3831
3873
|
if (u2 === '"' || u2 === "'") {
|
|
3832
|
-
let d =
|
|
3874
|
+
let d = n2 + 1;
|
|
3833
3875
|
for (; d < e.length && e[d] !== u2; ) e[d] === "\\" && d++, d++;
|
|
3834
|
-
d >= e.length &&
|
|
3835
|
-
let M2 = e.slice(
|
|
3836
|
-
u2 === "'" && (M2 = Ve2(M2)),
|
|
3876
|
+
d >= e.length && g("unterminated string", n2);
|
|
3877
|
+
let M2 = e.slice(n2 + 1, d);
|
|
3878
|
+
u2 === "'" && (M2 = Ve2(M2)), t += '"' + M2 + '"', n2 = d + 1;
|
|
3837
3879
|
continue;
|
|
3838
3880
|
}
|
|
3839
|
-
let
|
|
3840
|
-
for (;
|
|
3841
|
-
|
|
3842
|
-
let S2 = e.slice(
|
|
3881
|
+
let y2 = n2;
|
|
3882
|
+
for (; y2 < e.length && /[A-Za-z0-9_$.+\-]/.test(e[y2]); ) y2++;
|
|
3883
|
+
y2 === n2 && g("unexpected character " + JSON.stringify(u2), n2);
|
|
3884
|
+
let S2 = e.slice(n2, y2);
|
|
3843
3885
|
if (S2 === "true" || S2 === "false" || S2 === "null" || St3.test(S2)) {
|
|
3844
|
-
|
|
3886
|
+
t += S2, n2 = y2;
|
|
3845
3887
|
continue;
|
|
3846
3888
|
}
|
|
3847
3889
|
if (vt2.test(S2)) {
|
|
3848
|
-
if (e[
|
|
3849
|
-
|
|
3890
|
+
if (e[Ee3(e, y2)] === ":") {
|
|
3891
|
+
t += '"' + S2 + '"', n2 = y2;
|
|
3850
3892
|
continue;
|
|
3851
3893
|
}
|
|
3852
|
-
|
|
3894
|
+
g("unquoted value " + JSON.stringify(S2), n2);
|
|
3853
3895
|
}
|
|
3854
|
-
|
|
3896
|
+
g("invalid token " + JSON.stringify(S2), n2);
|
|
3855
3897
|
}
|
|
3856
|
-
return
|
|
3898
|
+
return t;
|
|
3857
3899
|
}
|
|
3858
|
-
function
|
|
3900
|
+
function Ie3(e) {
|
|
3859
3901
|
try {
|
|
3860
3902
|
return JSON.parse(e);
|
|
3861
3903
|
} catch {
|
|
3862
3904
|
}
|
|
3863
|
-
let
|
|
3864
|
-
function
|
|
3865
|
-
let
|
|
3905
|
+
let t = { BRACE_OPEN: "{", BRACE_CLOSE: "}", BRACKET_OPEN: "[", BRACKET_CLOSE: "]", COLON: ":", COMMA: ",", STRING: "STRING", SELECTOR: "SELECTOR", IDENTIFIER: "IDENTIFIER", NUMBER: "NUMBER", BOOLEAN: "BOOLEAN" };
|
|
3906
|
+
function n2(u2) {
|
|
3907
|
+
let y2 = [], S2 = 0;
|
|
3866
3908
|
for (; S2 < u2.length; ) {
|
|
3867
3909
|
let d = u2[S2];
|
|
3868
3910
|
if (/\s/.test(d)) {
|
|
@@ -3870,39 +3912,39 @@
|
|
|
3870
3912
|
continue;
|
|
3871
3913
|
}
|
|
3872
3914
|
if ("{}".includes(d)) {
|
|
3873
|
-
|
|
3915
|
+
y2.push({ type: d, value: d }), S2++;
|
|
3874
3916
|
continue;
|
|
3875
3917
|
}
|
|
3876
3918
|
if (d === "[") {
|
|
3877
|
-
let
|
|
3919
|
+
let B2 = false, I2 = S2 + 1;
|
|
3878
3920
|
for (; I2 < u2.length && /\s/.test(u2[I2]); ) I2++;
|
|
3879
|
-
if (I2 < u2.length && /[a-zA-Z_]/.test(u2[I2]) && (
|
|
3880
|
-
|
|
3921
|
+
if (I2 < u2.length && /[a-zA-Z_]/.test(u2[I2]) && (B2 = true), !B2) {
|
|
3922
|
+
y2.push({ type: d, value: d }), S2++;
|
|
3881
3923
|
continue;
|
|
3882
3924
|
}
|
|
3883
3925
|
}
|
|
3884
3926
|
if (d === "]") {
|
|
3885
|
-
|
|
3927
|
+
y2.push({ type: d, value: d }), S2++;
|
|
3886
3928
|
continue;
|
|
3887
3929
|
}
|
|
3888
3930
|
if (d === ":") {
|
|
3889
|
-
|
|
3931
|
+
y2.push({ type: t.COLON, value: d }), S2++;
|
|
3890
3932
|
continue;
|
|
3891
3933
|
}
|
|
3892
3934
|
if (d === ",") {
|
|
3893
|
-
|
|
3935
|
+
y2.push({ type: t.COMMA, value: d }), S2++;
|
|
3894
3936
|
continue;
|
|
3895
3937
|
}
|
|
3896
3938
|
if (d === '"' || d === "'") {
|
|
3897
|
-
let
|
|
3898
|
-
for (; I2 < u2.length && u2[I2] !==
|
|
3899
|
-
|
|
3939
|
+
let B2 = d, I2 = S2 + 1;
|
|
3940
|
+
for (; I2 < u2.length && u2[I2] !== B2; ) u2[I2] === "\\" && I2++, I2++;
|
|
3941
|
+
y2.push({ type: t.STRING, value: u2.substring(S2 + 1, I2), quoted: true, sourceQuote: B2 }), S2 = I2 + 1;
|
|
3900
3942
|
continue;
|
|
3901
3943
|
}
|
|
3902
|
-
let M2 = S2,
|
|
3944
|
+
let M2 = S2, P2;
|
|
3903
3945
|
for (; M2 < u2.length && !/[{},]/.test(u2[M2]); ) if (u2[M2] === ":") {
|
|
3904
|
-
let
|
|
3905
|
-
for (let k2 of
|
|
3946
|
+
let B2 = [":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"], I2 = false;
|
|
3947
|
+
for (let k2 of B2) {
|
|
3906
3948
|
let E2 = k2.substring(1);
|
|
3907
3949
|
if (u2.substring(M2 + 1, M2 + 1 + E2.length) === E2) {
|
|
3908
3950
|
I2 = true, M2 += E2.length;
|
|
@@ -3913,197 +3955,197 @@
|
|
|
3913
3955
|
} else if (u2[M2] === "[") {
|
|
3914
3956
|
for (M2++; M2 < u2.length && u2[M2] !== "]"; ) {
|
|
3915
3957
|
if (u2[M2] === '"' || u2[M2] === "'") {
|
|
3916
|
-
let
|
|
3917
|
-
for (M2++; M2 < u2.length && u2[M2] !==
|
|
3958
|
+
let B2 = u2[M2];
|
|
3959
|
+
for (M2++; M2 < u2.length && u2[M2] !== B2; ) u2[M2] === "\\" && M2++, M2++;
|
|
3918
3960
|
}
|
|
3919
3961
|
M2++;
|
|
3920
3962
|
}
|
|
3921
3963
|
M2 < u2.length && u2[M2] === "]" && M2++;
|
|
3922
3964
|
} else M2++;
|
|
3923
|
-
|
|
3924
|
-
let q2 =
|
|
3925
|
-
/^-?\d+(\.\d+)?$/.test(
|
|
3965
|
+
P2 = u2.substring(S2, M2);
|
|
3966
|
+
let q2 = t.IDENTIFIER;
|
|
3967
|
+
/^-?\d+(\.\d+)?$/.test(P2) ? q2 = t.NUMBER : P2 === "true" || P2 === "false" || P2 === "null" ? q2 = t.BOOLEAN : /^[.#@\[]|[.#@\[]| /.test(P2) && (q2 = t.SELECTOR), y2.push({ type: q2, value: P2, quoted: false }), S2 = M2;
|
|
3926
3968
|
}
|
|
3927
|
-
return
|
|
3969
|
+
return y2;
|
|
3928
3970
|
}
|
|
3929
|
-
function
|
|
3930
|
-
let
|
|
3971
|
+
function g(u2) {
|
|
3972
|
+
let y2 = "";
|
|
3931
3973
|
for (let S2 = 0; S2 < u2.length; S2++) {
|
|
3932
3974
|
let d = u2[S2];
|
|
3933
3975
|
if ("{}".includes(d.type) || "[]".includes(d.type)) {
|
|
3934
|
-
|
|
3976
|
+
y2 += d.value;
|
|
3935
3977
|
continue;
|
|
3936
3978
|
}
|
|
3937
|
-
if (d.type ===
|
|
3938
|
-
|
|
3979
|
+
if (d.type === t.COLON) {
|
|
3980
|
+
y2 += d.value;
|
|
3939
3981
|
continue;
|
|
3940
3982
|
}
|
|
3941
|
-
if (d.type ===
|
|
3983
|
+
if (d.type === t.COMMA) {
|
|
3942
3984
|
let M2 = u2[S2 + 1];
|
|
3943
3985
|
if (M2 && (M2.type === "}" || M2.type === "]")) continue;
|
|
3944
|
-
|
|
3986
|
+
y2 += d.value;
|
|
3945
3987
|
continue;
|
|
3946
3988
|
}
|
|
3947
|
-
if (d.type ===
|
|
3989
|
+
if (d.type === t.STRING) {
|
|
3948
3990
|
let M2 = d.value;
|
|
3949
|
-
d.sourceQuote === "'" && (M2 = Ve2(M2)),
|
|
3991
|
+
d.sourceQuote === "'" && (M2 = Ve2(M2)), y2 += `"${M2}"`;
|
|
3950
3992
|
continue;
|
|
3951
3993
|
}
|
|
3952
|
-
if (d.type ===
|
|
3953
|
-
|
|
3994
|
+
if (d.type === t.NUMBER || d.type === t.BOOLEAN) {
|
|
3995
|
+
y2 += d.value;
|
|
3954
3996
|
continue;
|
|
3955
3997
|
}
|
|
3956
|
-
|
|
3998
|
+
y2 += `"${d.value}"`;
|
|
3957
3999
|
}
|
|
3958
|
-
return
|
|
4000
|
+
return y2;
|
|
3959
4001
|
}
|
|
3960
4002
|
try {
|
|
3961
|
-
let u2 =
|
|
3962
|
-
return JSON.parse(
|
|
4003
|
+
let u2 = n2(e), y2 = g(u2);
|
|
4004
|
+
return JSON.parse(y2);
|
|
3963
4005
|
} catch (u2) {
|
|
3964
4006
|
throw new Error("Invalid extraction rules syntax: " + u2.message);
|
|
3965
4007
|
}
|
|
3966
4008
|
}
|
|
3967
|
-
var
|
|
3968
|
-
function
|
|
4009
|
+
var F3 = /* @__PURE__ */ Symbol("hyper-morph-json-merge:missing"), Ke3 = ["id", "_id", "uuid", "key", "slug", "code", "name"];
|
|
4010
|
+
function fe3(e) {
|
|
3969
4011
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
3970
4012
|
}
|
|
3971
|
-
function
|
|
3972
|
-
return Object.prototype.hasOwnProperty.call(e,
|
|
4013
|
+
function ye3(e, t) {
|
|
4014
|
+
return Object.prototype.hasOwnProperty.call(e, t);
|
|
3973
4015
|
}
|
|
3974
|
-
function Nt3(e,
|
|
3975
|
-
Object.defineProperty(e,
|
|
4016
|
+
function Nt3(e, t, n2) {
|
|
4017
|
+
Object.defineProperty(e, t, { value: n2, enumerable: true, writable: true, configurable: true });
|
|
3976
4018
|
}
|
|
3977
|
-
function
|
|
3978
|
-
if (e ===
|
|
3979
|
-
if (Array.isArray(e) && Array.isArray(
|
|
3980
|
-
if (e.length !==
|
|
3981
|
-
for (let
|
|
4019
|
+
function oe3(e, t) {
|
|
4020
|
+
if (e === t) return true;
|
|
4021
|
+
if (Array.isArray(e) && Array.isArray(t)) {
|
|
4022
|
+
if (e.length !== t.length) return false;
|
|
4023
|
+
for (let n2 = 0; n2 < e.length; n2++) if (!oe3(e[n2], t[n2])) return false;
|
|
3982
4024
|
return true;
|
|
3983
4025
|
}
|
|
3984
|
-
if (
|
|
3985
|
-
let
|
|
3986
|
-
if (
|
|
3987
|
-
for (let
|
|
4026
|
+
if (fe3(e) && fe3(t)) {
|
|
4027
|
+
let n2 = Object.keys(e);
|
|
4028
|
+
if (n2.length !== Object.keys(t).length) return false;
|
|
4029
|
+
for (let g of n2) if (!ye3(t, g) || !oe3(e[g], t[g])) return false;
|
|
3988
4030
|
return true;
|
|
3989
4031
|
}
|
|
3990
4032
|
return false;
|
|
3991
4033
|
}
|
|
3992
|
-
function Ue3(e,
|
|
3993
|
-
return
|
|
4034
|
+
function Ue3(e, t, n2, g) {
|
|
4035
|
+
return oe3(t, n2) ? t : oe3(t, e) ? n2 : oe3(n2, e) ? t : fe3(t) && fe3(n2) ? kt3(fe3(e) ? e : {}, t, n2, g) : Array.isArray(t) && Array.isArray(n2) ? It3(Array.isArray(e) ? e : [], t, n2, g) : n2;
|
|
3994
4036
|
}
|
|
3995
|
-
function Je3(e,
|
|
3996
|
-
return
|
|
4037
|
+
function Je3(e, t, n2, g) {
|
|
4038
|
+
return t === F3 && n2 === F3 ? F3 : t === F3 ? e === F3 ? n2 : oe3(n2, e) ? F3 : n2 : n2 === F3 ? e === F3 ? t : F3 : Ue3(e, t, n2, g);
|
|
3997
4039
|
}
|
|
3998
|
-
function kt3(e,
|
|
3999
|
-
let u2 = {},
|
|
4000
|
-
for (let S2 of
|
|
4001
|
-
let d = Je3(
|
|
4002
|
-
d !==
|
|
4040
|
+
function kt3(e, t, n2, g) {
|
|
4041
|
+
let u2 = {}, y2 = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t), ...Object.keys(n2)]);
|
|
4042
|
+
for (let S2 of y2) {
|
|
4043
|
+
let d = Je3(ye3(e, S2) ? e[S2] : F3, ye3(t, S2) ? t[S2] : F3, ye3(n2, S2) ? n2[S2] : F3, g);
|
|
4044
|
+
d !== F3 && Nt3(u2, S2, d);
|
|
4003
4045
|
}
|
|
4004
4046
|
return u2;
|
|
4005
4047
|
}
|
|
4006
4048
|
function wt3(e) {
|
|
4007
4049
|
return e === null || typeof e != "object";
|
|
4008
4050
|
}
|
|
4009
|
-
function
|
|
4051
|
+
function Se3(e) {
|
|
4010
4052
|
return typeof e + ":" + String(e);
|
|
4011
4053
|
}
|
|
4012
|
-
function Tt3(e,
|
|
4013
|
-
for (let
|
|
4014
|
-
let
|
|
4015
|
-
for (let u2 of
|
|
4016
|
-
if (!
|
|
4017
|
-
let
|
|
4018
|
-
if (typeof
|
|
4019
|
-
let S2 =
|
|
4020
|
-
if (
|
|
4021
|
-
|
|
4054
|
+
function Tt3(e, t) {
|
|
4055
|
+
for (let n2 of t) {
|
|
4056
|
+
let g = /* @__PURE__ */ new Set();
|
|
4057
|
+
for (let u2 of n2) {
|
|
4058
|
+
if (!ye3(u2, e)) return false;
|
|
4059
|
+
let y2 = u2[e];
|
|
4060
|
+
if (typeof y2 != "string" && typeof y2 != "number") return false;
|
|
4061
|
+
let S2 = Se3(y2);
|
|
4062
|
+
if (g.has(S2)) return false;
|
|
4063
|
+
g.add(S2);
|
|
4022
4064
|
}
|
|
4023
4065
|
}
|
|
4024
4066
|
return true;
|
|
4025
4067
|
}
|
|
4026
|
-
function Et3(e,
|
|
4027
|
-
let u2 = [e,
|
|
4028
|
-
for (let S2 of u2) for (let d of S2)
|
|
4029
|
-
if (
|
|
4030
|
-
for (let S2 of
|
|
4068
|
+
function Et3(e, t, n2, g) {
|
|
4069
|
+
let u2 = [e, t, n2], y2 = true;
|
|
4070
|
+
for (let S2 of u2) for (let d of S2) fe3(d) || (y2 = false);
|
|
4071
|
+
if (y2) {
|
|
4072
|
+
for (let S2 of g.keyCandidates) if (Tt3(S2, u2)) return { kind: "keyed", field: S2 };
|
|
4031
4073
|
return null;
|
|
4032
4074
|
}
|
|
4033
4075
|
for (let S2 of u2) {
|
|
4034
4076
|
let d = /* @__PURE__ */ new Set();
|
|
4035
4077
|
for (let M2 of S2) {
|
|
4036
4078
|
if (!wt3(M2)) return null;
|
|
4037
|
-
let
|
|
4038
|
-
if (d.has(
|
|
4039
|
-
d.add(
|
|
4079
|
+
let P2 = Se3(M2);
|
|
4080
|
+
if (d.has(P2)) return null;
|
|
4081
|
+
d.add(P2);
|
|
4040
4082
|
}
|
|
4041
4083
|
}
|
|
4042
4084
|
return { kind: "self" };
|
|
4043
4085
|
}
|
|
4044
|
-
function It3(e,
|
|
4045
|
-
let u2 = Et3(e,
|
|
4046
|
-
if (!u2) return
|
|
4047
|
-
let
|
|
4086
|
+
function It3(e, t, n2, g) {
|
|
4087
|
+
let u2 = Et3(e, t, n2, g);
|
|
4088
|
+
if (!u2) return n2;
|
|
4089
|
+
let y2 = u2.kind === "self" ? Se3 : (k2) => Se3(k2[u2.field]), S2 = (k2) => {
|
|
4048
4090
|
let E2 = /* @__PURE__ */ new Map();
|
|
4049
|
-
for (let
|
|
4091
|
+
for (let U3 of k2) E2.set(y2(U3), U3);
|
|
4050
4092
|
return E2;
|
|
4051
|
-
}, d = S2(e), M2 = S2(
|
|
4052
|
-
for (let k2 of
|
|
4053
|
-
let E2 = Je3(d.has(k2) ? d.get(k2) :
|
|
4054
|
-
E2 !==
|
|
4093
|
+
}, d = S2(e), M2 = S2(t), P2 = S2(n2), q2 = /* @__PURE__ */ new Map(), B2 = /* @__PURE__ */ new Set([...d.keys(), ...M2.keys(), ...P2.keys()]);
|
|
4094
|
+
for (let k2 of B2) {
|
|
4095
|
+
let E2 = Je3(d.has(k2) ? d.get(k2) : F3, M2.has(k2) ? M2.get(k2) : F3, P2.has(k2) ? P2.get(k2) : F3, g);
|
|
4096
|
+
E2 !== F3 && q2.set(k2, E2);
|
|
4055
4097
|
}
|
|
4056
4098
|
let I2 = [];
|
|
4057
|
-
for (let k2 of
|
|
4058
|
-
let E2 =
|
|
4099
|
+
for (let k2 of n2) {
|
|
4100
|
+
let E2 = y2(k2);
|
|
4059
4101
|
q2.has(E2) && I2.push(E2);
|
|
4060
4102
|
}
|
|
4061
|
-
for (let k2 = 0; k2 <
|
|
4062
|
-
let E2 =
|
|
4103
|
+
for (let k2 = 0; k2 < t.length; k2++) {
|
|
4104
|
+
let E2 = y2(t[k2]);
|
|
4063
4105
|
if (!q2.has(E2) || I2.includes(E2)) continue;
|
|
4064
|
-
let
|
|
4065
|
-
for (let
|
|
4066
|
-
let
|
|
4067
|
-
if (
|
|
4068
|
-
|
|
4106
|
+
let U3 = 0;
|
|
4107
|
+
for (let J3 = k2 - 1; J3 >= 0; J3--) {
|
|
4108
|
+
let W3 = I2.indexOf(y2(t[J3]));
|
|
4109
|
+
if (W3 !== -1) {
|
|
4110
|
+
U3 = W3 + 1;
|
|
4069
4111
|
break;
|
|
4070
4112
|
}
|
|
4071
4113
|
}
|
|
4072
|
-
I2.splice(
|
|
4114
|
+
I2.splice(U3, 0, E2);
|
|
4073
4115
|
}
|
|
4074
4116
|
return I2.map((k2) => q2.get(k2));
|
|
4075
4117
|
}
|
|
4076
|
-
function
|
|
4077
|
-
let u2 =
|
|
4078
|
-
return Ue3(e === void 0 ?
|
|
4118
|
+
function ve3(e, t, n2, g = {}) {
|
|
4119
|
+
let u2 = g.keyCandidates ? [...g.keyCandidates, ...Ke3] : Ke3;
|
|
4120
|
+
return Ue3(e === void 0 ? F3 : e, t, n2, { keyCandidates: u2 });
|
|
4079
4121
|
}
|
|
4080
|
-
function
|
|
4081
|
-
let u2 =
|
|
4082
|
-
if (typeof
|
|
4122
|
+
function Me3(e, t, n2, g = {}) {
|
|
4123
|
+
let u2 = g.parse || me3, y2 = [], S2 = (B2, I2) => {
|
|
4124
|
+
if (typeof B2 != "string") return F3;
|
|
4083
4125
|
try {
|
|
4084
|
-
return u2(
|
|
4126
|
+
return u2(B2);
|
|
4085
4127
|
} catch (k2) {
|
|
4086
|
-
return
|
|
4128
|
+
return y2.push(`${I2} side is not valid JSON (${k2.message})`), F3;
|
|
4087
4129
|
}
|
|
4088
|
-
}, d = S2(
|
|
4089
|
-
if (d ===
|
|
4090
|
-
if (M2 ===
|
|
4091
|
-
let
|
|
4092
|
-
return
|
|
4130
|
+
}, d = S2(t, "local"), M2 = S2(n2, "remote");
|
|
4131
|
+
if (d === F3) return { text: n2, warnings: y2 };
|
|
4132
|
+
if (M2 === F3) return { text: t, warnings: y2 };
|
|
4133
|
+
let P2 = S2(e, "base"), q2 = ve3(P2 === F3 ? void 0 : P2, d, M2, g);
|
|
4134
|
+
return oe3(q2, M2) ? { text: n2, warnings: y2 } : oe3(q2, d) ? { text: t, warnings: y2 } : { text: JSON.stringify(q2, null, 2), warnings: y2 };
|
|
4093
4135
|
}
|
|
4094
4136
|
var Ot3 = 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"] }) }), _t2 = Object.freeze({ "editor-ui": Object.freeze(["no-data", "no-save", "no-snapshot", "no-watch", "no-undo"]) }), qt3 = Object.freeze(["no-save", "no-snapshot", "no-trigger-autosave", "no-dirty", "no-watch", "no-undo", "no-data", "freeze", "editor-ui"]);
|
|
4095
4137
|
function We3(e) {
|
|
4096
|
-
let
|
|
4097
|
-
if (!
|
|
4098
|
-
return [...
|
|
4138
|
+
let t = Ot3[e];
|
|
4139
|
+
if (!t) throw new Error(`Unknown region capability: ${e}`);
|
|
4140
|
+
return [...t.tokens, ...t.bundles].flatMap((n2) => [`[clay~="${n2}"]`, `[${n2}]`]).join(", ");
|
|
4099
4141
|
}
|
|
4100
|
-
var
|
|
4142
|
+
var de3 = (function() {
|
|
4101
4143
|
"use strict";
|
|
4102
4144
|
let e = () => {
|
|
4103
|
-
},
|
|
4104
|
-
function
|
|
4145
|
+
}, t = '[editor-ui],[clay~="editor-ui"],[save-ignore],[snapshot-remove],[no-snapshot],[no-save],[save-remove],[freeze],[save-freeze],[clay~="no-save"],[clay~="no-snapshot"],[clay~="freeze"]', n2 = `${We3("history")},[no-undo],[clay~="no-undo"]`;
|
|
4146
|
+
function g(r) {
|
|
4105
4147
|
if (r?.nodeType !== 1) return false;
|
|
4106
|
-
if (r.matches(
|
|
4148
|
+
if (r.matches(t)) return true;
|
|
4107
4149
|
if (r.tagName === "LINK" || r.tagName === "SCRIPT") {
|
|
4108
4150
|
let p2 = r.getAttribute("src") || r.getAttribute("href") || "";
|
|
4109
4151
|
if (p2.startsWith("chrome-extension://") || p2.startsWith("moz-extension://") || p2.startsWith("safari-web-extension://")) return true;
|
|
@@ -4111,25 +4153,25 @@
|
|
|
4111
4153
|
return false;
|
|
4112
4154
|
}
|
|
4113
4155
|
function u2(r) {
|
|
4114
|
-
return r?.nodeType !== 1 ? false : r.closest(
|
|
4156
|
+
return r?.nodeType !== 1 ? false : r.closest(t) ? true : g(r);
|
|
4115
4157
|
}
|
|
4116
|
-
function
|
|
4158
|
+
function y2(r, p2, h) {
|
|
4117
4159
|
if (h) {
|
|
4118
4160
|
let w2 = h.identityOf(r);
|
|
4119
4161
|
if (w2 && !h.disabled.has(w2.key)) return "hm-merge:" + w2.key;
|
|
4120
4162
|
}
|
|
4121
4163
|
if (p2 !== "smart") return r.outerHTML;
|
|
4122
|
-
let N2 = r.getAttribute("src"),
|
|
4164
|
+
let N2 = r.getAttribute("src"), b = r.getAttribute("type") || "text/javascript";
|
|
4123
4165
|
if (N2) try {
|
|
4124
4166
|
let w2 = new URL(N2, window.location.href);
|
|
4125
|
-
return `ext:${
|
|
4167
|
+
return `ext:${b}:${w2.origin}${w2.pathname}${w2.search}`;
|
|
4126
4168
|
} catch {
|
|
4127
|
-
return `ext:${
|
|
4169
|
+
return `ext:${b}:${N2}`;
|
|
4128
4170
|
}
|
|
4129
4171
|
else {
|
|
4130
4172
|
let w2 = r.textContent.trim(), a = 5381;
|
|
4131
4173
|
for (let c2 = 0; c2 < w2.length; c2++) a = (a << 5) + a ^ w2.charCodeAt(c2);
|
|
4132
|
-
return `inline:${
|
|
4174
|
+
return `inline:${b}:${Math.abs(a).toString(36)}`;
|
|
4133
4175
|
}
|
|
4134
4176
|
}
|
|
4135
4177
|
let S2 = "http://www.w3.org/1999/xhtml";
|
|
@@ -4143,7 +4185,7 @@
|
|
|
4143
4185
|
for (let N2 of r.attributes) h.setAttribute(N2.name, N2.value);
|
|
4144
4186
|
return h.textContent = r.textContent, h;
|
|
4145
4187
|
}
|
|
4146
|
-
function
|
|
4188
|
+
function P2(r) {
|
|
4147
4189
|
if (d(r)) return M2(r);
|
|
4148
4190
|
if (r?.nodeType === 1) for (let p2 of r.querySelectorAll("script")) d(p2) && p2.replaceWith(M2(p2));
|
|
4149
4191
|
return r;
|
|
@@ -4152,32 +4194,32 @@
|
|
|
4152
4194
|
let p2 = (r.getAttribute("type") || "").split(";")[0].trim().toLowerCase();
|
|
4153
4195
|
return p2 === "application/json" || p2.endsWith("+json");
|
|
4154
4196
|
}
|
|
4155
|
-
let
|
|
4197
|
+
let B2 = { match: (r) => r.hasAttribute("merge"), identity: (r) => r.getAttribute("merge") };
|
|
4156
4198
|
function I2(r, p2, h) {
|
|
4157
4199
|
if (h.merge === false) return null;
|
|
4158
|
-
let N2 = [
|
|
4159
|
-
if (
|
|
4160
|
-
let
|
|
4200
|
+
let N2 = [B2, ...h.mergeTags || []], b = /* @__PURE__ */ new WeakMap(), w2 = (i2) => {
|
|
4201
|
+
if (b.has(i2)) return b.get(i2);
|
|
4202
|
+
let m2 = null;
|
|
4161
4203
|
if (d(i2) && !i2.getAttribute("src") && !u2(i2)) {
|
|
4162
|
-
let
|
|
4163
|
-
for (let T2 = 0; T2 < N2.length; T2++) if (N2[T2].match(
|
|
4164
|
-
if (!q2(
|
|
4204
|
+
let v2 = i2;
|
|
4205
|
+
for (let T2 = 0; T2 < N2.length; T2++) if (N2[T2].match(v2)) {
|
|
4206
|
+
if (!q2(v2)) console.warn("[hyper-morph] merge ignored: script type is not JSON", v2);
|
|
4165
4207
|
else {
|
|
4166
|
-
let
|
|
4167
|
-
|
|
4208
|
+
let L3 = N2[T2].identity(v2);
|
|
4209
|
+
L3 != null && L3 !== "" && (m2 = { key: T2 + ":" + L3, raw: L3, recognizer: N2[T2] });
|
|
4168
4210
|
}
|
|
4169
4211
|
break;
|
|
4170
4212
|
}
|
|
4171
4213
|
}
|
|
4172
|
-
return
|
|
4214
|
+
return b.set(i2, m2), m2;
|
|
4173
4215
|
}, a = /* @__PURE__ */ new Set(), c2 = (i2) => {
|
|
4174
|
-
let
|
|
4175
|
-
let
|
|
4176
|
-
|
|
4216
|
+
let m2 = /* @__PURE__ */ new Map(), v2 = (T2) => {
|
|
4217
|
+
let L3 = w2(T2);
|
|
4218
|
+
L3 && (m2.has(L3.key) ? (a.add(L3.key), console.warn(`[hyper-morph] merge disabled for duplicate identity "${L3.raw}"`)) : m2.set(L3.key, T2));
|
|
4177
4219
|
};
|
|
4178
|
-
d(i2) &&
|
|
4179
|
-
for (let T2 of i2.querySelectorAll("script"))
|
|
4180
|
-
return
|
|
4220
|
+
d(i2) && v2(i2);
|
|
4221
|
+
for (let T2 of i2.querySelectorAll("script")) v2(T2);
|
|
4222
|
+
return m2;
|
|
4181
4223
|
}, l = c2(r), s2 = c2(p2.__hyperMorphRoot || p2);
|
|
4182
4224
|
if (l.size === 0 && s2.size === 0) return null;
|
|
4183
4225
|
let o2 = null;
|
|
@@ -4186,61 +4228,61 @@
|
|
|
4186
4228
|
o2 = /* @__PURE__ */ new Map();
|
|
4187
4229
|
let i2 = h.mergeBase;
|
|
4188
4230
|
if (!i2) return o2;
|
|
4189
|
-
let
|
|
4190
|
-
typeof i2 == "string" ?
|
|
4191
|
-
let
|
|
4192
|
-
let
|
|
4193
|
-
|
|
4231
|
+
let m2;
|
|
4232
|
+
typeof i2 == "string" ? m2 = new DOMParser().parseFromString(i2, "text/html").documentElement : i2?.nodeType === 9 ? m2 = i2.documentElement : m2 = i2;
|
|
4233
|
+
let v2 = (T2) => {
|
|
4234
|
+
let L3 = w2(T2);
|
|
4235
|
+
L3 && !o2.has(L3.key) && o2.set(L3.key, T2.textContent);
|
|
4194
4236
|
};
|
|
4195
|
-
d(
|
|
4196
|
-
for (let T2 of
|
|
4237
|
+
d(m2) && v2(m2);
|
|
4238
|
+
for (let T2 of m2.querySelectorAll("script")) v2(T2);
|
|
4197
4239
|
return o2;
|
|
4198
4240
|
} };
|
|
4199
4241
|
}
|
|
4200
4242
|
function k2(r, p2, h) {
|
|
4201
4243
|
let N2 = r.merge;
|
|
4202
4244
|
if (!N2) return false;
|
|
4203
|
-
let
|
|
4204
|
-
if (!
|
|
4245
|
+
let b = N2.identityOf(p2);
|
|
4246
|
+
if (!b || N2.disabled.has(b.key)) return false;
|
|
4205
4247
|
let w2 = N2.identityOf(h);
|
|
4206
|
-
if (!w2 || w2.key !==
|
|
4207
|
-
let a = p2, c2 = h, l = c2.getAttribute("merge-key") || a.getAttribute("merge-key"), { text: s2, warnings: o2 } =
|
|
4208
|
-
for (let f2 of o2) console.warn(`[hyper-morph] merge "${
|
|
4248
|
+
if (!w2 || w2.key !== b.key) return false;
|
|
4249
|
+
let a = p2, c2 = h, l = c2.getAttribute("merge-key") || a.getAttribute("merge-key"), { text: s2, warnings: o2 } = Me3(N2.baseTexts().get(b.key), a.textContent, c2.textContent, { parse: b.recognizer.parse, keyCandidates: l ? l.split(/[\s,]+/).filter(Boolean) : void 0 });
|
|
4250
|
+
for (let f2 of o2) console.warn(`[hyper-morph] merge "${b.raw}": ${f2}`);
|
|
4209
4251
|
return a.textContent !== s2 && (a.textContent = s2), true;
|
|
4210
4252
|
}
|
|
4211
|
-
let E2 = { morphStyle: "outerHTML", callbacks: { beforeNodeAdded: e, afterNodeAdded: e, beforeNodeMorphed: e, afterNodeMorphed: e, beforeNodeRemoved: e, afterNodeRemoved: e, beforeAttributeUpdated: e }, head: { style: "merge", shouldPreserve: (r) => r.getAttribute("im-preserve") === "true", shouldReAppend: (r) => r.getAttribute("im-re-append") === "true", shouldRemove: e, afterHeadMorphed: e }, scripts: { handle: true, matchMode: "outerHTML", shouldPreserve: (r) => r.getAttribute("im-preserve") === "true", shouldReAppend: (r) => r.getAttribute("im-re-append") === "true", shouldRemove: e, afterScriptsHandled: e }, restoreFocus: true },
|
|
4253
|
+
let E2 = { morphStyle: "outerHTML", callbacks: { beforeNodeAdded: e, afterNodeAdded: e, beforeNodeMorphed: e, afterNodeMorphed: e, beforeNodeRemoved: e, afterNodeRemoved: e, beforeAttributeUpdated: e }, head: { style: "merge", shouldPreserve: (r) => r.getAttribute("im-preserve") === "true", shouldReAppend: (r) => r.getAttribute("im-re-append") === "true", shouldRemove: e, afterHeadMorphed: e }, scripts: { handle: true, matchMode: "outerHTML", shouldPreserve: (r) => r.getAttribute("im-preserve") === "true", shouldReAppend: (r) => r.getAttribute("im-re-append") === "true", shouldRemove: e, afterScriptsHandled: e }, restoreFocus: true }, U3 = { computeMatches(r, p2, h = u2) {
|
|
4212
4254
|
let { computeMatches: N2 } = Fe3({ shouldIgnore: h }).session();
|
|
4213
4255
|
return N2(r, p2);
|
|
4214
4256
|
} };
|
|
4215
|
-
function
|
|
4257
|
+
function J3(r, p2, h = {}) {
|
|
4216
4258
|
r = Xe3(r);
|
|
4217
|
-
let N2 =
|
|
4259
|
+
let N2 = xe3(p2), b = Qe3(r, N2, h), w2 = b.scripts.handle ? new Set(Array.from(r.querySelectorAll("script")).map((s2) => y2(s2, b.scripts.matchMode, b.merge))) : null, a = re3(b), c2;
|
|
4218
4260
|
try {
|
|
4219
|
-
c2 = Ge3(
|
|
4261
|
+
c2 = Ge3(b, r, N2, (s2) => s2.morphStyle === "innerHTML" ? (se3(s2, r, N2), Array.from(r.childNodes)) : he3(s2, r, N2));
|
|
4220
4262
|
} catch (s2) {
|
|
4221
|
-
throw Q3(
|
|
4263
|
+
throw Q3(b), s2;
|
|
4222
4264
|
}
|
|
4223
4265
|
let l = (s2) => {
|
|
4224
|
-
a &&
|
|
4225
|
-
let o2 = w2 ? Ze3(s2, w2,
|
|
4266
|
+
a && be3(b, a), W3(b);
|
|
4267
|
+
let o2 = w2 ? Ze3(s2, w2, b) : [];
|
|
4226
4268
|
return o2.length > 0 ? Promise.all(o2).then(() => s2) : s2;
|
|
4227
4269
|
};
|
|
4228
4270
|
if (c2 instanceof Promise) return c2.then((s2) => {
|
|
4229
4271
|
try {
|
|
4230
4272
|
return l(s2);
|
|
4231
4273
|
} catch (o2) {
|
|
4232
|
-
throw Q3(
|
|
4274
|
+
throw Q3(b), o2;
|
|
4233
4275
|
}
|
|
4234
4276
|
}, (s2) => {
|
|
4235
|
-
throw Q3(
|
|
4277
|
+
throw Q3(b), s2;
|
|
4236
4278
|
});
|
|
4237
4279
|
try {
|
|
4238
4280
|
return l(c2);
|
|
4239
4281
|
} catch (s2) {
|
|
4240
|
-
throw Q3(
|
|
4282
|
+
throw Q3(b), s2;
|
|
4241
4283
|
}
|
|
4242
4284
|
}
|
|
4243
|
-
function
|
|
4285
|
+
function W3(r) {
|
|
4244
4286
|
let p2 = r.pantry;
|
|
4245
4287
|
if (p2) {
|
|
4246
4288
|
for (let h of Array.from(p2.childNodes)) r.callbacks.beforeNodeRemoved(h) !== false && r.callbacks.afterNodeRemoved(h);
|
|
@@ -4252,11 +4294,11 @@
|
|
|
4252
4294
|
let p2 = r.pantry;
|
|
4253
4295
|
if (!p2) return;
|
|
4254
4296
|
let h = Array.from(r.stagedNodes.entries()).reverse();
|
|
4255
|
-
for (let [N2,
|
|
4297
|
+
for (let [N2, b] of h) {
|
|
4256
4298
|
if (!p2.contains(N2)) continue;
|
|
4257
|
-
let w2 =
|
|
4299
|
+
let w2 = b.nextSibling?.parentNode === b.parent ? b.nextSibling : null;
|
|
4258
4300
|
try {
|
|
4259
|
-
|
|
4301
|
+
ne3(b.parent, N2, w2);
|
|
4260
4302
|
} catch {
|
|
4261
4303
|
}
|
|
4262
4304
|
}
|
|
@@ -4268,7 +4310,7 @@
|
|
|
4268
4310
|
let p2 = r.target.ownerDocument, h = p2.createElement("div");
|
|
4269
4311
|
return h.hidden = true, h.setAttribute("mutations-ignore", ""), p2.body.insertAdjacentElement("afterend", h), r.pantry = h, h;
|
|
4270
4312
|
}
|
|
4271
|
-
function
|
|
4313
|
+
function ne3(r, p2, h) {
|
|
4272
4314
|
if (r.moveBefore) try {
|
|
4273
4315
|
r.moveBefore(p2, h);
|
|
4274
4316
|
} catch {
|
|
@@ -4276,117 +4318,117 @@
|
|
|
4276
4318
|
}
|
|
4277
4319
|
else r.insertBefore(p2, h);
|
|
4278
4320
|
}
|
|
4279
|
-
function
|
|
4280
|
-
!r.stagedNodes.has(p2) && p2.parentNode && r.stagedNodes.set(p2, { parent: p2.parentNode, nextSibling: p2.nextSibling }),
|
|
4321
|
+
function Z3(r, p2) {
|
|
4322
|
+
!r.stagedNodes.has(p2) && p2.parentNode && r.stagedNodes.set(p2, { parent: p2.parentNode, nextSibling: p2.nextSibling }), ne3(ee3(r), p2, null);
|
|
4281
4323
|
}
|
|
4282
|
-
function
|
|
4283
|
-
let N2 =
|
|
4284
|
-
return
|
|
4324
|
+
function he3(r, p2, h) {
|
|
4325
|
+
let N2 = xe3(p2);
|
|
4326
|
+
return se3(r, N2, h, p2, p2.nextSibling), Array.from(N2.childNodes);
|
|
4285
4327
|
}
|
|
4286
|
-
function
|
|
4328
|
+
function re3(r) {
|
|
4287
4329
|
if (!r.config.restoreFocus) return null;
|
|
4288
4330
|
let p2 = document.activeElement;
|
|
4289
4331
|
if (!(p2 instanceof HTMLInputElement || p2 instanceof HTMLTextAreaElement)) return null;
|
|
4290
|
-
let { id: h, selectionStart: N2, selectionEnd:
|
|
4291
|
-
return { element: p2, id: h, selectionStart: N2, selectionEnd:
|
|
4332
|
+
let { id: h, selectionStart: N2, selectionEnd: b } = p2;
|
|
4333
|
+
return { element: p2, id: h, selectionStart: N2, selectionEnd: b };
|
|
4292
4334
|
}
|
|
4293
|
-
function
|
|
4335
|
+
function be3(r, p2) {
|
|
4294
4336
|
let h = p2.element;
|
|
4295
4337
|
if (p2.id && p2.id !== document.activeElement?.getAttribute("id") && (h = r.target.querySelector(`[id="${CSS.escape(p2.id)}"]`), h?.focus()), h && !h.selectionEnd && p2.selectionEnd != null) try {
|
|
4296
4338
|
h.setSelectionRange(p2.selectionStart, p2.selectionEnd);
|
|
4297
4339
|
} catch {
|
|
4298
4340
|
}
|
|
4299
4341
|
}
|
|
4300
|
-
let
|
|
4301
|
-
function r(s2, o2, f2, i2 = null,
|
|
4342
|
+
let se3 = /* @__PURE__ */ (function() {
|
|
4343
|
+
function r(s2, o2, f2, i2 = null, m2 = null) {
|
|
4302
4344
|
o2?.tagName === "TEMPLATE" && f2?.tagName === "TEMPLATE" && (o2 = o2.content, f2 = f2.content), i2 ||= o2.firstChild;
|
|
4303
|
-
for (let
|
|
4304
|
-
if (s2.shouldIgnore(
|
|
4305
|
-
if (i2 && i2 !=
|
|
4306
|
-
let
|
|
4307
|
-
if (
|
|
4308
|
-
|
|
4345
|
+
for (let v2 of f2.childNodes) {
|
|
4346
|
+
if (s2.shouldIgnore(v2)) continue;
|
|
4347
|
+
if (i2 && i2 != m2) {
|
|
4348
|
+
let L3 = N2(s2, v2, i2, m2);
|
|
4349
|
+
if (L3) {
|
|
4350
|
+
L3 !== i2 && w2(s2, i2, L3), Ae3(L3, v2, s2), i2 = L3.nextSibling;
|
|
4309
4351
|
continue;
|
|
4310
4352
|
}
|
|
4311
4353
|
}
|
|
4312
|
-
if (
|
|
4313
|
-
let
|
|
4314
|
-
if (s2.persistentIds.has(
|
|
4315
|
-
let
|
|
4316
|
-
|
|
4354
|
+
if (v2?.nodeType === 1) {
|
|
4355
|
+
let L3 = v2.getAttribute("id");
|
|
4356
|
+
if (s2.persistentIds.has(L3)) {
|
|
4357
|
+
let A2 = a(o2, L3, i2, s2);
|
|
4358
|
+
Ae3(A2, v2, s2), i2 = A2.nextSibling;
|
|
4317
4359
|
continue;
|
|
4318
4360
|
}
|
|
4319
|
-
if (!s2.idMap.has(
|
|
4320
|
-
let
|
|
4321
|
-
if (
|
|
4322
|
-
|
|
4361
|
+
if (!s2.idMap.has(v2)) {
|
|
4362
|
+
let A2 = s2.hyperMatches.get(v2);
|
|
4363
|
+
if (A2 && !s2.idMap.has(A2) && !l(A2, o2)) {
|
|
4364
|
+
ne3(o2, A2, i2), Ae3(A2, v2, s2), i2 = A2.nextSibling;
|
|
4323
4365
|
continue;
|
|
4324
4366
|
}
|
|
4325
4367
|
}
|
|
4326
4368
|
}
|
|
4327
|
-
let T2 = p2(o2,
|
|
4369
|
+
let T2 = p2(o2, v2, i2, s2);
|
|
4328
4370
|
T2 && (i2 = T2.nextSibling);
|
|
4329
4371
|
}
|
|
4330
|
-
for (; i2 && i2 !=
|
|
4331
|
-
let
|
|
4332
|
-
i2 = i2.nextSibling, s2.shouldIgnore(
|
|
4372
|
+
for (; i2 && i2 != m2; ) {
|
|
4373
|
+
let v2 = i2;
|
|
4374
|
+
i2 = i2.nextSibling, s2.shouldIgnore(v2) || b(s2, v2);
|
|
4333
4375
|
}
|
|
4334
4376
|
}
|
|
4335
4377
|
function p2(s2, o2, f2, i2) {
|
|
4336
4378
|
if (i2.callbacks.beforeNodeAdded(o2) === false) return null;
|
|
4337
|
-
let
|
|
4379
|
+
let m2 = s2.ownerDocument || s2.realParentNode?.ownerDocument || i2.target.ownerDocument;
|
|
4338
4380
|
if (i2.idMap.has(o2)) {
|
|
4339
|
-
let
|
|
4340
|
-
return s2.insertBefore(T2, f2),
|
|
4381
|
+
let v2 = o2, T2 = m2.createElementNS(v2.namespaceURI, v2.localName);
|
|
4382
|
+
return s2.insertBefore(T2, f2), Ae3(T2, o2, i2), i2.callbacks.afterNodeAdded(T2), T2;
|
|
4341
4383
|
} else {
|
|
4342
|
-
let
|
|
4343
|
-
return
|
|
4384
|
+
let v2 = P2(h(o2, m2, i2));
|
|
4385
|
+
return v2 ? (s2.insertBefore(v2, f2), i2.callbacks.afterNodeAdded(v2), v2) : null;
|
|
4344
4386
|
}
|
|
4345
4387
|
}
|
|
4346
4388
|
function h(s2, o2, f2) {
|
|
4347
4389
|
if (f2.shouldIgnore(s2)) return null;
|
|
4348
|
-
let i2 = o2.importNode(s2, false),
|
|
4349
|
-
for (let T2 of Array.from(
|
|
4350
|
-
let
|
|
4351
|
-
|
|
4390
|
+
let i2 = o2.importNode(s2, false), m2 = s2.nodeType === 1 && s2.tagName === "TEMPLATE" ? s2.content : s2, v2 = i2.nodeType === 1 && i2.tagName === "TEMPLATE" ? i2.content : i2;
|
|
4391
|
+
for (let T2 of Array.from(m2.childNodes || [])) {
|
|
4392
|
+
let L3 = h(T2, o2, f2);
|
|
4393
|
+
L3 && v2.appendChild(L3);
|
|
4352
4394
|
}
|
|
4353
4395
|
return i2;
|
|
4354
4396
|
}
|
|
4355
4397
|
let N2 = /* @__PURE__ */ (function() {
|
|
4356
|
-
function s2(i2,
|
|
4357
|
-
let
|
|
4358
|
-
for (;
|
|
4359
|
-
if (i2.shouldIgnore(
|
|
4360
|
-
|
|
4398
|
+
function s2(i2, m2, v2, T2) {
|
|
4399
|
+
let L3 = m2?.nodeType === 1 && !i2.idMap.has(m2) ? i2.hyperMatches.get(m2) : null, A2 = null, x2 = m2.nextSibling, V3 = 0, C2 = v2;
|
|
4400
|
+
for (; C2 && C2 != T2; ) {
|
|
4401
|
+
if (i2.shouldIgnore(C2)) {
|
|
4402
|
+
C2 = C2.nextSibling;
|
|
4361
4403
|
continue;
|
|
4362
4404
|
}
|
|
4363
|
-
if (f2(
|
|
4364
|
-
if (o2(i2,
|
|
4365
|
-
if (
|
|
4366
|
-
let
|
|
4367
|
-
!i2.idMap.has(
|
|
4405
|
+
if (f2(C2, m2)) {
|
|
4406
|
+
if (o2(i2, C2, m2) || C2 === L3 && !i2.idMap.has(C2)) return C2;
|
|
4407
|
+
if (A2 === null) {
|
|
4408
|
+
let z2 = C2?.nodeType === 1 && i2.hyperMatchedOldElements.has(C2);
|
|
4409
|
+
!i2.idMap.has(C2) && !z2 && (A2 = C2);
|
|
4368
4410
|
}
|
|
4369
4411
|
}
|
|
4370
|
-
if (
|
|
4371
|
-
|
|
4412
|
+
if (A2 === null && x2 && f2(C2, x2) && (V3++, x2 = x2.nextSibling, V3 >= 2 && (A2 = void 0)), i2.activeElementAndParents.includes(C2)) break;
|
|
4413
|
+
C2 = C2.nextSibling;
|
|
4372
4414
|
}
|
|
4373
|
-
return
|
|
4415
|
+
return A2 || null;
|
|
4374
4416
|
}
|
|
4375
|
-
function o2(i2,
|
|
4376
|
-
let T2 = i2.idMap.get(
|
|
4377
|
-
if (!
|
|
4378
|
-
for (let
|
|
4417
|
+
function o2(i2, m2, v2) {
|
|
4418
|
+
let T2 = i2.idMap.get(m2), L3 = i2.idMap.get(v2);
|
|
4419
|
+
if (!L3 || !T2) return false;
|
|
4420
|
+
for (let A2 of T2) if (L3.has(A2)) return true;
|
|
4379
4421
|
return false;
|
|
4380
4422
|
}
|
|
4381
|
-
function f2(i2,
|
|
4382
|
-
let
|
|
4383
|
-
return
|
|
4423
|
+
function f2(i2, m2) {
|
|
4424
|
+
let v2 = i2, T2 = m2;
|
|
4425
|
+
return v2.nodeType === T2.nodeType && v2.tagName === T2.tagName && (!v2.getAttribute?.("id") || v2.getAttribute?.("id") === T2.getAttribute?.("id"));
|
|
4384
4426
|
}
|
|
4385
4427
|
return s2;
|
|
4386
4428
|
})();
|
|
4387
|
-
function
|
|
4429
|
+
function b(s2, o2) {
|
|
4388
4430
|
let f2 = o2?.nodeType === 1 && s2.hyperMatchedOldElements.has(o2) && !s2.idMap.has(o2);
|
|
4389
|
-
if (s2.idMap.has(o2) || f2)
|
|
4431
|
+
if (s2.idMap.has(o2) || f2) Z3(s2, o2);
|
|
4390
4432
|
else {
|
|
4391
4433
|
if (s2.callbacks.beforeNodeRemoved(o2) === false) return;
|
|
4392
4434
|
o2.parentNode?.removeChild(o2), s2.callbacks.afterNodeRemoved(o2);
|
|
@@ -4395,14 +4437,14 @@
|
|
|
4395
4437
|
function w2(s2, o2, f2) {
|
|
4396
4438
|
let i2 = o2;
|
|
4397
4439
|
for (; i2 && i2 !== f2; ) {
|
|
4398
|
-
let
|
|
4399
|
-
i2 = i2.nextSibling, s2.shouldIgnore(
|
|
4440
|
+
let m2 = i2;
|
|
4441
|
+
i2 = i2.nextSibling, s2.shouldIgnore(m2) || b(s2, m2);
|
|
4400
4442
|
}
|
|
4401
4443
|
return i2;
|
|
4402
4444
|
}
|
|
4403
4445
|
function a(s2, o2, f2, i2) {
|
|
4404
|
-
let
|
|
4405
|
-
return c2(
|
|
4446
|
+
let m2 = i2.target.ownerDocument?.defaultView?.CSS?.escape ? i2.target.ownerDocument.defaultView.CSS.escape(o2) : String(o2).replace(/["\\]/g, "\\$&"), v2 = i2.target.getAttribute?.("id") === o2 && i2.target || i2.target.querySelector(`[id="${m2}"]`) || i2.pantry?.querySelector(`[id="${m2}"]`);
|
|
4447
|
+
return c2(v2, i2), ne3(s2, v2, f2), v2;
|
|
4406
4448
|
}
|
|
4407
4449
|
function c2(s2, o2) {
|
|
4408
4450
|
let f2 = s2.getAttribute("id");
|
|
@@ -4416,19 +4458,19 @@
|
|
|
4416
4458
|
return !!f2 && s2.contains(f2);
|
|
4417
4459
|
}
|
|
4418
4460
|
return r;
|
|
4419
|
-
})(),
|
|
4461
|
+
})(), Ae3 = /* @__PURE__ */ (function() {
|
|
4420
4462
|
function r(a, c2, l) {
|
|
4421
|
-
return l.ignoreActive && a === document.activeElement ? null : (l.callbacks.beforeNodeMorphed(a, c2) === false || (a?.tagName === "HEAD" && l.head.ignore || (a?.tagName === "HEAD" && l.head.style !== "morph" ?
|
|
4463
|
+
return l.ignoreActive && a === document.activeElement ? null : (l.callbacks.beforeNodeMorphed(a, c2) === false || (a?.tagName === "HEAD" && l.head.ignore || (a?.tagName === "HEAD" && l.head.style !== "morph" ? Oe3(a, c2, l) : (p2(a, c2, l), k2(l, a, c2) || w2(a, l) || se3(l, a, c2))), l.callbacks.afterNodeMorphed(a, c2)), a);
|
|
4422
4464
|
}
|
|
4423
4465
|
function p2(a, c2, l) {
|
|
4424
4466
|
let s2 = c2.nodeType;
|
|
4425
4467
|
if (s2 === 1) {
|
|
4426
|
-
let o2 = a, f2 = c2, i2 = o2.attributes,
|
|
4427
|
-
for (let
|
|
4428
|
-
for (let
|
|
4429
|
-
let T2 = i2[
|
|
4468
|
+
let o2 = a, f2 = c2, i2 = o2.attributes, m2 = f2.attributes;
|
|
4469
|
+
for (let v2 of m2) b(v2.name, o2, "update", l) || o2.getAttribute(v2.name) !== v2.value && o2.setAttribute(v2.name, v2.value);
|
|
4470
|
+
for (let v2 = i2.length - 1; 0 <= v2; v2--) {
|
|
4471
|
+
let T2 = i2[v2];
|
|
4430
4472
|
if (T2 && !f2.hasAttribute(T2.name)) {
|
|
4431
|
-
if (
|
|
4473
|
+
if (b(T2.name, o2, "remove", l)) continue;
|
|
4432
4474
|
o2.removeAttribute(T2.name);
|
|
4433
4475
|
}
|
|
4434
4476
|
}
|
|
@@ -4439,23 +4481,23 @@
|
|
|
4439
4481
|
function h(a, c2, l) {
|
|
4440
4482
|
if (a.tagName === "INPUT" && c2.tagName === "INPUT" && c2.type !== "file") {
|
|
4441
4483
|
let s2 = c2.value, o2 = a.value;
|
|
4442
|
-
N2(a, c2, "checked", l), N2(a, c2, "disabled", l), l.formStateSync === "property" && a.indeterminate !== c2.indeterminate && (a.indeterminate = c2.indeterminate), l.formStateSync === "property" ? o2 !== s2 && (
|
|
4484
|
+
N2(a, c2, "checked", l), N2(a, c2, "disabled", l), l.formStateSync === "property" && a.indeterminate !== c2.indeterminate && (a.indeterminate = c2.indeterminate), l.formStateSync === "property" ? o2 !== s2 && (b("value", a, "update", l) || (a.value = s2)) : c2.hasAttribute("value") ? o2 !== s2 && (b("value", a, "update", l) || (a.setAttribute("value", s2), a.value = s2)) : b("value", a, "remove", l) || (a.value = "", a.removeAttribute("value"));
|
|
4443
4485
|
} else if (a.tagName === "OPTION" && c2.tagName === "OPTION") N2(a, c2, "selected", l);
|
|
4444
4486
|
else if (a.tagName === "TEXTAREA" && c2.tagName === "TEXTAREA") {
|
|
4445
4487
|
let s2 = c2.value, o2 = a.value;
|
|
4446
|
-
if (
|
|
4488
|
+
if (b("value", a, "update", l) || (s2 !== o2 && (a.value = s2), l.formStateSync === "property")) return;
|
|
4447
4489
|
a.firstChild && a.firstChild.nodeValue !== s2 && (a.firstChild.nodeValue = s2);
|
|
4448
4490
|
}
|
|
4449
4491
|
}
|
|
4450
4492
|
function N2(a, c2, l, s2) {
|
|
4451
4493
|
let o2 = c2[l], f2 = a[l];
|
|
4452
4494
|
if (o2 !== f2) {
|
|
4453
|
-
let i2 =
|
|
4495
|
+
let i2 = b(l, a, "update", s2);
|
|
4454
4496
|
if (i2 || (a[l] = c2[l]), s2.formStateSync === "property") return;
|
|
4455
|
-
o2 ? i2 || a.setAttribute(l, "") :
|
|
4497
|
+
o2 ? i2 || a.setAttribute(l, "") : b(l, a, "remove", s2) || a.removeAttribute(l);
|
|
4456
4498
|
}
|
|
4457
4499
|
}
|
|
4458
|
-
function
|
|
4500
|
+
function b(a, c2, l, s2) {
|
|
4459
4501
|
return a === "value" && s2.ignoreActiveValue && c2 === document.activeElement ? true : s2.callbacks.beforeAttributeUpdated(a, c2, l) === false;
|
|
4460
4502
|
}
|
|
4461
4503
|
function w2(a, c2) {
|
|
@@ -4465,9 +4507,9 @@
|
|
|
4465
4507
|
})();
|
|
4466
4508
|
function Ge3(r, p2, h, N2) {
|
|
4467
4509
|
if (r.head.block) {
|
|
4468
|
-
let
|
|
4469
|
-
if (
|
|
4470
|
-
let a =
|
|
4510
|
+
let b = p2.querySelector("head"), w2 = h.querySelector("head");
|
|
4511
|
+
if (b && w2) {
|
|
4512
|
+
let a = Oe3(b, w2, r);
|
|
4471
4513
|
return Promise.all(a).then(() => (r.head.block = false, r.head.ignore = true, N2(r)));
|
|
4472
4514
|
}
|
|
4473
4515
|
}
|
|
@@ -4476,14 +4518,14 @@
|
|
|
4476
4518
|
function Ye3(r) {
|
|
4477
4519
|
return r.tagName === "SCRIPT" ? !!r.getAttribute("src") : r.tagName === "LINK" ? (r.getAttribute("rel") || "").toLowerCase().split(/\s+/).includes("stylesheet") && !!r.getAttribute("href") : false;
|
|
4478
4520
|
}
|
|
4479
|
-
function
|
|
4480
|
-
let N2 = [],
|
|
4481
|
-
if (f2.tagName === "SCRIPT") return
|
|
4521
|
+
function Oe3(r, p2, h) {
|
|
4522
|
+
let N2 = [], b = [], w2 = [], a = [], c2 = h.scripts.matchMode, l = (f2) => {
|
|
4523
|
+
if (f2.tagName === "SCRIPT") return y2(f2, c2, h.merge);
|
|
4482
4524
|
if (f2.tagName === "LINK" && c2 === "smart") {
|
|
4483
4525
|
let i2 = f2.getAttribute("href");
|
|
4484
4526
|
if (i2) try {
|
|
4485
|
-
let
|
|
4486
|
-
return `link:${f2.getAttribute("rel") || ""}:${
|
|
4527
|
+
let m2 = new URL(i2, window.location.href);
|
|
4528
|
+
return `link:${f2.getAttribute("rel") || ""}:${m2.origin}${m2.pathname}${m2.search}`;
|
|
4487
4529
|
} catch {
|
|
4488
4530
|
}
|
|
4489
4531
|
}
|
|
@@ -4491,20 +4533,20 @@
|
|
|
4491
4533
|
}, s2 = /* @__PURE__ */ new Map();
|
|
4492
4534
|
for (let f2 of p2.children) {
|
|
4493
4535
|
if (h.shouldIgnore(f2)) continue;
|
|
4494
|
-
let i2 = l(f2),
|
|
4495
|
-
|
|
4536
|
+
let i2 = l(f2), m2 = s2.get(i2);
|
|
4537
|
+
m2 || (m2 = [], s2.set(i2, m2)), m2.push(f2);
|
|
4496
4538
|
}
|
|
4497
4539
|
for (let f2 of r.children) {
|
|
4498
|
-
let i2 = l(f2),
|
|
4499
|
-
if (
|
|
4540
|
+
let i2 = l(f2), m2 = s2.get(i2), v2 = !!(m2 && m2.length), T2 = h.head.shouldReAppend(f2), L3 = h.head.shouldPreserve(f2);
|
|
4541
|
+
if (v2 || L3) if (T2) b.push(f2);
|
|
4500
4542
|
else {
|
|
4501
|
-
if (
|
|
4502
|
-
let
|
|
4503
|
-
|
|
4543
|
+
if (m2 && m2.length) {
|
|
4544
|
+
let A2 = m2.pop();
|
|
4545
|
+
m2.length || s2.delete(i2), k2(h, f2, A2);
|
|
4504
4546
|
}
|
|
4505
4547
|
w2.push(f2);
|
|
4506
4548
|
}
|
|
4507
|
-
else h.head.style === "append" ? T2 && (
|
|
4549
|
+
else h.head.style === "append" ? T2 && (b.push(f2), a.push(f2)) : h.head.shouldRemove(f2) !== false && !h.shouldIgnore(f2) && b.push(f2);
|
|
4508
4550
|
}
|
|
4509
4551
|
for (let f2 of s2.values()) a.push(...f2);
|
|
4510
4552
|
let o2 = [];
|
|
@@ -4512,32 +4554,32 @@
|
|
|
4512
4554
|
let i2 = document.createRange().createContextualFragment(f2.outerHTML).firstChild;
|
|
4513
4555
|
if (h.callbacks.beforeNodeAdded(i2) !== false) {
|
|
4514
4556
|
if (i2 instanceof Element && Ye3(i2)) {
|
|
4515
|
-
let
|
|
4516
|
-
|
|
4557
|
+
let m2, v2 = new Promise(function(T2) {
|
|
4558
|
+
m2 = T2;
|
|
4517
4559
|
});
|
|
4518
4560
|
i2.addEventListener("load", function() {
|
|
4519
|
-
|
|
4561
|
+
m2();
|
|
4520
4562
|
}), i2.addEventListener("error", function() {
|
|
4521
|
-
|
|
4522
|
-
}), o2.push(
|
|
4563
|
+
m2();
|
|
4564
|
+
}), o2.push(v2);
|
|
4523
4565
|
}
|
|
4524
4566
|
r.appendChild(i2), h.callbacks.afterNodeAdded(i2), N2.push(i2);
|
|
4525
4567
|
}
|
|
4526
4568
|
}
|
|
4527
|
-
for (let f2 of
|
|
4528
|
-
return h.head.afterHeadMorphed(r, { added: N2, kept: w2, removed:
|
|
4569
|
+
for (let f2 of b) h.callbacks.beforeNodeRemoved(f2) !== false && (r.removeChild(f2), h.callbacks.afterNodeRemoved(f2));
|
|
4570
|
+
return h.head.afterHeadMorphed(r, { added: N2, kept: w2, removed: b }), o2;
|
|
4529
4571
|
}
|
|
4530
4572
|
function Ze3(r, p2, h) {
|
|
4531
4573
|
if (!h.scripts.handle) return [];
|
|
4532
|
-
let N2 = [],
|
|
4574
|
+
let N2 = [], b = [], w2 = [], a = [], c2 = h.scripts.matchMode, l = [];
|
|
4533
4575
|
for (let o2 of r) if (o2 instanceof Element) {
|
|
4534
4576
|
d(o2) && l.push(o2);
|
|
4535
4577
|
for (let f2 of o2.querySelectorAll("script")) d(f2) && l.push(f2);
|
|
4536
4578
|
}
|
|
4537
4579
|
for (let o2 of l) {
|
|
4538
4580
|
if (o2.closest("head") || h.shouldIgnore(o2)) continue;
|
|
4539
|
-
let f2 =
|
|
4540
|
-
i2 ||
|
|
4581
|
+
let f2 = y2(o2, c2, h.merge), i2 = p2.has(f2), m2 = h.scripts.shouldPreserve(o2), v2 = h.scripts.shouldReAppend(o2);
|
|
4582
|
+
i2 || m2 ? v2 ? (b.push(o2), a.push(o2)) : w2.push(o2) : a.push(o2);
|
|
4541
4583
|
}
|
|
4542
4584
|
let s2 = [];
|
|
4543
4585
|
for (let o2 of a) {
|
|
@@ -4545,72 +4587,75 @@
|
|
|
4545
4587
|
let f2 = document.createElement("script");
|
|
4546
4588
|
for (let i2 of o2.attributes) f2.setAttribute(i2.name, i2.value);
|
|
4547
4589
|
if (f2.textContent = o2.textContent, f2.src) {
|
|
4548
|
-
let i2,
|
|
4549
|
-
i2 =
|
|
4590
|
+
let i2, m2 = new Promise(function(v2) {
|
|
4591
|
+
i2 = v2;
|
|
4550
4592
|
});
|
|
4551
4593
|
f2.addEventListener("load", function() {
|
|
4552
4594
|
i2();
|
|
4553
4595
|
}), f2.addEventListener("error", function() {
|
|
4554
4596
|
i2();
|
|
4555
|
-
}), s2.push(
|
|
4597
|
+
}), s2.push(m2);
|
|
4556
4598
|
}
|
|
4557
4599
|
o2.replaceWith(f2), h.callbacks.afterNodeAdded(f2), N2.push(f2);
|
|
4558
4600
|
}
|
|
4559
|
-
return h.scripts.afterScriptsHandled(h.target, { added: N2, kept: w2, removed:
|
|
4601
|
+
return h.scripts.afterScriptsHandled(h.target, { added: N2, kept: w2, removed: b }), s2;
|
|
4560
4602
|
}
|
|
4561
4603
|
let Qe3 = /* @__PURE__ */ (function() {
|
|
4562
4604
|
function r(c2, l, s2) {
|
|
4563
|
-
let o2 = s2.policy === "history" ?
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4605
|
+
let o2 = s2.policy === "history" ? n2 : t, f2 = (C2, z2) => {
|
|
4606
|
+
let K2 = C2.closest(z2);
|
|
4607
|
+
return K2 && (c2.contains(K2) || l.contains(K2)) ? K2 : null;
|
|
4608
|
+
}, i2 = s2.policy === "raw" ? () => false : (C2) => {
|
|
4609
|
+
if (C2?.nodeType !== 1) return false;
|
|
4610
|
+
if (s2.policy !== "history" && (g(C2) || f2(C2, t))) return true;
|
|
4611
|
+
let z2 = f2(C2, o2);
|
|
4612
|
+
return !(!z2 || s2.policy === "history" && z2 === c2 && z2.matches('[no-undo],[clay~="no-undo"]') && !z2.matches('[editor-ui],[clay~="editor-ui"]'));
|
|
4613
|
+
}, { persistentIds: m2, idMap: v2 } = w2(c2, l, i2), T2 = U3.computeMatches(c2, l, i2);
|
|
4569
4614
|
if (typeof s2.key == "function") {
|
|
4570
|
-
let
|
|
4571
|
-
let
|
|
4572
|
-
|
|
4615
|
+
let C2 = /* @__PURE__ */ new Map(), z2 = /* @__PURE__ */ new Set(), K2 = (R2) => {
|
|
4616
|
+
let H2 = s2.key(R2);
|
|
4617
|
+
H2 != null && (C2.has(H2) ? z2.add(H2) : C2.set(H2, R2));
|
|
4573
4618
|
};
|
|
4574
|
-
c2 instanceof Element &&
|
|
4575
|
-
for (let
|
|
4576
|
-
for (let
|
|
4577
|
-
let
|
|
4578
|
-
for (let [
|
|
4579
|
-
let
|
|
4580
|
-
let
|
|
4581
|
-
|
|
4619
|
+
c2 instanceof Element && K2(c2);
|
|
4620
|
+
for (let R2 of c2.querySelectorAll("*")) K2(R2);
|
|
4621
|
+
for (let R2 of z2) C2.delete(R2);
|
|
4622
|
+
let G3 = /* @__PURE__ */ new Map();
|
|
4623
|
+
for (let [R2, H2] of T2) G3.set(H2, R2);
|
|
4624
|
+
let _ = l.__hyperMorphRoot || l, O2 = /* @__PURE__ */ new Map(), D3 = /* @__PURE__ */ new Set(), $3 = (R2) => {
|
|
4625
|
+
let H2 = s2.key(R2);
|
|
4626
|
+
H2 != null && (O2.has(H2) ? D3.add(H2) : O2.set(H2, R2));
|
|
4582
4627
|
};
|
|
4583
|
-
|
|
4584
|
-
for (let
|
|
4585
|
-
for (let
|
|
4586
|
-
for (let [
|
|
4587
|
-
let
|
|
4588
|
-
if (!
|
|
4589
|
-
let
|
|
4590
|
-
|
|
4591
|
-
let
|
|
4592
|
-
|
|
4628
|
+
_ instanceof Element && $3(_);
|
|
4629
|
+
for (let R2 of _.querySelectorAll("*")) $3(R2);
|
|
4630
|
+
for (let R2 of D3) O2.delete(R2);
|
|
4631
|
+
for (let [R2, H2] of O2) {
|
|
4632
|
+
let te3 = C2.get(R2);
|
|
4633
|
+
if (!te3 || te3.tagName !== H2.tagName) continue;
|
|
4634
|
+
let ae3 = G3.get(te3);
|
|
4635
|
+
ae3 && ae3 !== H2 && T2.delete(ae3);
|
|
4636
|
+
let ce3 = T2.get(H2);
|
|
4637
|
+
ce3 && ce3 !== te3 && G3.delete(ce3), T2.set(H2, te3), G3.set(te3, H2);
|
|
4593
4638
|
}
|
|
4594
4639
|
}
|
|
4595
|
-
let
|
|
4596
|
-
if (
|
|
4597
|
-
let
|
|
4598
|
-
for (let [
|
|
4599
|
-
for (let [
|
|
4600
|
-
if (
|
|
4601
|
-
let
|
|
4602
|
-
if (!
|
|
4603
|
-
let
|
|
4604
|
-
|
|
4605
|
-
let
|
|
4606
|
-
|
|
4640
|
+
let L3 = p2(s2), A2 = I2(c2, l, L3.scripts);
|
|
4641
|
+
if (A2) {
|
|
4642
|
+
let C2 = /* @__PURE__ */ new Map();
|
|
4643
|
+
for (let [z2, K2] of T2) C2.set(K2, z2);
|
|
4644
|
+
for (let [z2, K2] of A2.newByKey) {
|
|
4645
|
+
if (A2.disabled.has(z2)) continue;
|
|
4646
|
+
let G3 = A2.oldByKey.get(z2);
|
|
4647
|
+
if (!G3) continue;
|
|
4648
|
+
let _ = C2.get(G3);
|
|
4649
|
+
_ && _ !== K2 && T2.delete(_);
|
|
4650
|
+
let O2 = T2.get(K2);
|
|
4651
|
+
O2 && O2 !== G3 && C2.delete(O2), T2.set(K2, G3), C2.set(G3, K2);
|
|
4607
4652
|
}
|
|
4608
4653
|
}
|
|
4609
|
-
let
|
|
4610
|
-
for (let
|
|
4611
|
-
let
|
|
4612
|
-
if (!["innerHTML", "outerHTML"].includes(
|
|
4613
|
-
return { target: c2, newContent: l, config:
|
|
4654
|
+
let x2 = /* @__PURE__ */ new Set();
|
|
4655
|
+
for (let C2 of T2.values()) x2.add(C2);
|
|
4656
|
+
let V3 = L3.morphStyle || "outerHTML";
|
|
4657
|
+
if (!["innerHTML", "outerHTML"].includes(V3)) throw new Error(`Do not understand how to morph style ${V3}`);
|
|
4658
|
+
return { target: c2, newContent: l, config: L3, morphStyle: V3, ignoreActive: L3.ignoreActive, ignoreActiveValue: L3.ignoreActiveValue, restoreFocus: L3.restoreFocus, formStateSync: L3.formStateSync || "attribute", idMap: v2, persistentIds: m2, hyperMatches: T2, hyperMatchedOldElements: x2, merge: A2, pantry: null, stagedNodes: /* @__PURE__ */ new Map(), activeElementAndParents: h(c2), callbacks: L3.callbacks, head: L3.head, scripts: L3.scripts, shouldIgnore: i2 };
|
|
4614
4659
|
}
|
|
4615
4660
|
function p2(c2) {
|
|
4616
4661
|
let l = Object.assign({}, E2);
|
|
@@ -4625,41 +4670,41 @@
|
|
|
4625
4670
|
let l = Array.from(c2.querySelectorAll("[id]"));
|
|
4626
4671
|
return c2.getAttribute?.("id") && l.push(c2), l;
|
|
4627
4672
|
}
|
|
4628
|
-
function
|
|
4673
|
+
function b(c2, l, s2, o2) {
|
|
4629
4674
|
for (let f2 of o2) {
|
|
4630
4675
|
let i2 = f2.getAttribute("id");
|
|
4631
4676
|
if (l.has(i2)) {
|
|
4632
|
-
let
|
|
4633
|
-
for (;
|
|
4634
|
-
let
|
|
4635
|
-
if (
|
|
4636
|
-
|
|
4677
|
+
let m2 = f2;
|
|
4678
|
+
for (; m2; ) {
|
|
4679
|
+
let v2 = c2.get(m2);
|
|
4680
|
+
if (v2 == null && (v2 = /* @__PURE__ */ new Set(), c2.set(m2, v2)), v2.add(i2), m2 === s2) break;
|
|
4681
|
+
m2 = m2.parentElement;
|
|
4637
4682
|
}
|
|
4638
4683
|
}
|
|
4639
4684
|
}
|
|
4640
4685
|
}
|
|
4641
4686
|
function w2(c2, l, s2) {
|
|
4642
|
-
let o2 = N2(c2).filter((T2) => !s2(T2)), f2 = N2(l).filter((T2) => !s2(T2)), i2 = a(o2, f2),
|
|
4643
|
-
|
|
4644
|
-
let
|
|
4645
|
-
return
|
|
4687
|
+
let o2 = N2(c2).filter((T2) => !s2(T2)), f2 = N2(l).filter((T2) => !s2(T2)), i2 = a(o2, f2), m2 = /* @__PURE__ */ new Map();
|
|
4688
|
+
b(m2, i2, c2, o2);
|
|
4689
|
+
let v2 = l.__hyperMorphRoot || l;
|
|
4690
|
+
return b(m2, i2, v2, f2), { persistentIds: i2, idMap: m2 };
|
|
4646
4691
|
}
|
|
4647
4692
|
function a(c2, l) {
|
|
4648
4693
|
let s2 = /* @__PURE__ */ new Set(), o2 = /* @__PURE__ */ new Map();
|
|
4649
4694
|
for (let i2 of c2) {
|
|
4650
|
-
let
|
|
4651
|
-
o2.has(
|
|
4695
|
+
let m2 = i2.getAttribute("id");
|
|
4696
|
+
o2.has(m2) ? s2.add(m2) : o2.set(m2, i2.tagName);
|
|
4652
4697
|
}
|
|
4653
4698
|
let f2 = /* @__PURE__ */ new Set();
|
|
4654
4699
|
for (let i2 of l) {
|
|
4655
|
-
let
|
|
4656
|
-
f2.has(
|
|
4700
|
+
let m2 = i2.getAttribute("id");
|
|
4701
|
+
f2.has(m2) ? s2.add(m2) : o2.get(m2) === i2.tagName && f2.add(m2);
|
|
4657
4702
|
}
|
|
4658
4703
|
for (let i2 of s2) f2.delete(i2);
|
|
4659
4704
|
return f2;
|
|
4660
4705
|
}
|
|
4661
4706
|
return r;
|
|
4662
|
-
})(), { normalizeElement: Xe3, normalizeParent:
|
|
4707
|
+
})(), { normalizeElement: Xe3, normalizeParent: xe3 } = /* @__PURE__ */ (function() {
|
|
4663
4708
|
let r = /* @__PURE__ */ new WeakSet();
|
|
4664
4709
|
function p2(a) {
|
|
4665
4710
|
return a?.nodeType === 9 ? a.documentElement : a;
|
|
@@ -4709,7 +4754,7 @@
|
|
|
4709
4754
|
return this.originalNode;
|
|
4710
4755
|
}
|
|
4711
4756
|
}
|
|
4712
|
-
function
|
|
4757
|
+
function b(a) {
|
|
4713
4758
|
let c2 = (f2) => `<${f2}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`, l = a.replace(/<!--[\s\S]*?-->/g, "");
|
|
4714
4759
|
for (let f2 of ["script", "style", "textarea", "title"]) l = l.replace(new RegExp(`${c2(f2)}[\\s\\S]*?</${f2}\\s*>`, "gi"), "");
|
|
4715
4760
|
let s2 = new RegExp(`${c2("svg")}[\\s\\S]*?</svg\\s*>`, "gi"), o2;
|
|
@@ -4719,7 +4764,7 @@
|
|
|
4719
4764
|
return l;
|
|
4720
4765
|
}
|
|
4721
4766
|
function w2(a) {
|
|
4722
|
-
let c2 = new DOMParser(), l =
|
|
4767
|
+
let c2 = new DOMParser(), l = b(a);
|
|
4723
4768
|
if (l.match(/<\/html>/) || l.match(/<\/head>/) || l.match(/<\/body>/)) {
|
|
4724
4769
|
let s2 = c2.parseFromString(a, "text/html");
|
|
4725
4770
|
if (l.match(/<\/html>/)) return r.add(s2), s2;
|
|
@@ -4733,242 +4778,242 @@
|
|
|
4733
4778
|
}
|
|
4734
4779
|
}
|
|
4735
4780
|
return { normalizeElement: p2, normalizeParent: h };
|
|
4736
|
-
})(),
|
|
4737
|
-
function
|
|
4781
|
+
})(), Ce3 = /* @__PURE__ */ Symbol("hyper-morph-duplicate-key"), Le3 = [(r) => r.getAttribute("data-id"), (r) => r.getAttribute("id")];
|
|
4782
|
+
function pe3(r, p2) {
|
|
4738
4783
|
return p2.map((h) => {
|
|
4739
4784
|
let N2 = /* @__PURE__ */ new Map();
|
|
4740
|
-
for (let
|
|
4741
|
-
if (
|
|
4742
|
-
let w2 = h(
|
|
4743
|
-
w2 == null || w2 === "" || N2.set(w2, N2.has(w2) ?
|
|
4785
|
+
for (let b of r) {
|
|
4786
|
+
if (b.nodeType !== 1) continue;
|
|
4787
|
+
let w2 = h(b);
|
|
4788
|
+
w2 == null || w2 === "" || N2.set(w2, N2.has(w2) ? Ce3 : b);
|
|
4744
4789
|
}
|
|
4745
4790
|
return N2;
|
|
4746
4791
|
});
|
|
4747
4792
|
}
|
|
4748
|
-
function
|
|
4749
|
-
for (let
|
|
4750
|
-
let w2 = N2[
|
|
4751
|
-
if (w2 == null || w2 === "" || p2[
|
|
4752
|
-
let a = h[
|
|
4753
|
-
if (!(!a || a ===
|
|
4793
|
+
function Re3(r, p2, h, N2) {
|
|
4794
|
+
for (let b = 0; b < N2.length; b++) {
|
|
4795
|
+
let w2 = N2[b](r);
|
|
4796
|
+
if (w2 == null || w2 === "" || p2[b].get(w2) !== r) continue;
|
|
4797
|
+
let a = h[b].get(w2);
|
|
4798
|
+
if (!(!a || a === Ce3) && a.tagName === r.tagName) return a;
|
|
4754
4799
|
}
|
|
4755
4800
|
return null;
|
|
4756
4801
|
}
|
|
4757
4802
|
function ue3(r, p2, h) {
|
|
4758
4803
|
for (let N2 = 0; N2 < h.length; N2++) {
|
|
4759
|
-
let
|
|
4760
|
-
if (!(
|
|
4804
|
+
let b = h[N2](r);
|
|
4805
|
+
if (!(b == null || b === "") && p2[N2].get(b) === r) return true;
|
|
4761
4806
|
}
|
|
4762
4807
|
return false;
|
|
4763
4808
|
}
|
|
4764
4809
|
function et3(r, p2, h = {}) {
|
|
4765
|
-
let N2 = h.skip || (() => false),
|
|
4810
|
+
let N2 = h.skip || (() => false), b = h.ignoreAttr || (() => false), w2 = h.tiers && h.tiers.length ? h.tiers : Le3, a = null;
|
|
4766
4811
|
function c2() {
|
|
4767
|
-
return a || (a =
|
|
4812
|
+
return a || (a = pe3([r, ...r.querySelectorAll("*")], w2)), a;
|
|
4768
4813
|
}
|
|
4769
4814
|
let l = null;
|
|
4770
4815
|
function s2() {
|
|
4771
|
-
return l || (l =
|
|
4816
|
+
return l || (l = pe3([p2, ...p2.querySelectorAll("*")], w2)), l;
|
|
4772
4817
|
}
|
|
4773
|
-
function o2(
|
|
4774
|
-
return !
|
|
4818
|
+
function o2(O2) {
|
|
4819
|
+
return !O2.parentElement || !O2.parentElement.parentElement;
|
|
4775
4820
|
}
|
|
4776
|
-
function f2(
|
|
4777
|
-
return o2(
|
|
4821
|
+
function f2(O2, D3, $3) {
|
|
4822
|
+
return o2(O2) || ue3(O2, c2(), w2) ? ($3.push({ type: "subtree", el: O2, base: D3 }), false) : true;
|
|
4778
4823
|
}
|
|
4779
|
-
function i2(
|
|
4780
|
-
let
|
|
4781
|
-
for (let
|
|
4782
|
-
for (let
|
|
4783
|
-
return
|
|
4824
|
+
function i2(O2, D3) {
|
|
4825
|
+
let $3 = [];
|
|
4826
|
+
for (let R2 of O2.attributes) b(O2, R2.name) || D3.getAttribute(R2.name) !== R2.value && $3.push(R2.name);
|
|
4827
|
+
for (let R2 of D3.attributes) b(O2, R2.name) || O2.hasAttribute(R2.name) || $3.push(R2.name);
|
|
4828
|
+
return $3;
|
|
4784
4829
|
}
|
|
4785
|
-
function
|
|
4786
|
-
let D3 = [],
|
|
4787
|
-
|
|
4830
|
+
function m2(O2) {
|
|
4831
|
+
let D3 = [], $3 = null, R2 = () => {
|
|
4832
|
+
$3 !== null && (D3.push({ nodeType: 3, nodeValue: $3 }), $3 = null);
|
|
4788
4833
|
};
|
|
4789
|
-
for (let
|
|
4790
|
-
if (
|
|
4791
|
-
|
|
4834
|
+
for (let H2 of O2.childNodes) {
|
|
4835
|
+
if (H2.nodeType === 3) {
|
|
4836
|
+
$3 = ($3 === null ? "" : $3) + H2.nodeValue;
|
|
4792
4837
|
continue;
|
|
4793
4838
|
}
|
|
4794
|
-
|
|
4839
|
+
H2.nodeType === 1 && N2(H2) || (R2(), (H2.nodeType === 1 || H2.nodeType === 8) && D3.push(H2));
|
|
4795
4840
|
}
|
|
4796
|
-
return
|
|
4841
|
+
return R2(), D3;
|
|
4797
4842
|
}
|
|
4798
|
-
function
|
|
4799
|
-
if (
|
|
4800
|
-
if (
|
|
4801
|
-
if (
|
|
4802
|
-
for (let
|
|
4803
|
-
let
|
|
4804
|
-
if (
|
|
4843
|
+
function v2(O2, D3) {
|
|
4844
|
+
if (O2.nodeType !== D3.nodeType) return false;
|
|
4845
|
+
if (O2.nodeType !== 1) return true;
|
|
4846
|
+
if (O2.tagName !== D3.tagName) return false;
|
|
4847
|
+
for (let $3 of w2) {
|
|
4848
|
+
let R2 = $3(O2), H2 = $3(D3);
|
|
4849
|
+
if (R2 != null && R2 !== "" && H2 != null && H2 !== "" && R2 !== H2) return false;
|
|
4805
4850
|
}
|
|
4806
4851
|
return true;
|
|
4807
4852
|
}
|
|
4808
|
-
function T2(
|
|
4853
|
+
function T2(O2) {
|
|
4809
4854
|
let D3 = "";
|
|
4810
|
-
for (let
|
|
4855
|
+
for (let $3 of O2) $3.nodeType === 3 && $3.nodeValue.trim() !== "" ? D3 += "\0" + $3.nodeValue : $3.nodeType === 8 && (D3 += "" + $3.nodeValue);
|
|
4811
4856
|
return D3;
|
|
4812
4857
|
}
|
|
4813
|
-
function
|
|
4814
|
-
let
|
|
4815
|
-
if (
|
|
4858
|
+
function L3(O2, D3, $3) {
|
|
4859
|
+
let R2 = m2(O2), H2 = m2(D3);
|
|
4860
|
+
if (R2.length === H2.length) {
|
|
4816
4861
|
let j2 = true;
|
|
4817
|
-
for (let
|
|
4862
|
+
for (let Y2 = 0; Y2 < R2.length; Y2++) if (!v2(R2[Y2], H2[Y2])) {
|
|
4818
4863
|
j2 = false;
|
|
4819
4864
|
break;
|
|
4820
4865
|
}
|
|
4821
4866
|
if (j2) {
|
|
4822
|
-
for (let
|
|
4823
|
-
let
|
|
4824
|
-
if (
|
|
4825
|
-
if (
|
|
4826
|
-
} else if (
|
|
4867
|
+
for (let Y2 = 0; Y2 < R2.length; Y2++) {
|
|
4868
|
+
let le3 = R2[Y2];
|
|
4869
|
+
if (le3.nodeType === 1) {
|
|
4870
|
+
if (A2(le3, H2[Y2], $3)) return true;
|
|
4871
|
+
} else if (le3.nodeValue !== H2[Y2].nodeValue) return true;
|
|
4827
4872
|
}
|
|
4828
4873
|
return false;
|
|
4829
4874
|
}
|
|
4830
4875
|
}
|
|
4831
|
-
let
|
|
4832
|
-
if (T2(
|
|
4833
|
-
let
|
|
4834
|
-
for (let j2 of
|
|
4835
|
-
let
|
|
4836
|
-
|
|
4837
|
-
}
|
|
4838
|
-
let
|
|
4839
|
-
for (let j2 of He3) ue3(j2,
|
|
4840
|
-
let
|
|
4841
|
-
for (let j2 of ae3)
|
|
4842
|
-
if (
|
|
4843
|
-
for (let j2 = 0; j2 <
|
|
4844
|
-
let je3 = new Map(
|
|
4845
|
-
for (let j2 = 0; j2 <
|
|
4876
|
+
let te3 = R2.filter((j2) => j2.nodeType === 1), ae3 = H2.filter((j2) => j2.nodeType === 1);
|
|
4877
|
+
if (T2(R2) !== T2(H2)) return true;
|
|
4878
|
+
let ce3 = pe3(te3, w2), Be3 = pe3(ae3, w2), Ne3 = [], ke3 = /* @__PURE__ */ new Set(), He3 = [];
|
|
4879
|
+
for (let j2 of te3) {
|
|
4880
|
+
let Y2 = Re3(j2, ce3, Be3, w2);
|
|
4881
|
+
Y2 && !ke3.has(Y2) ? (Ne3.push([j2, Y2]), ke3.add(Y2)) : He3.push(j2);
|
|
4882
|
+
}
|
|
4883
|
+
let ie3 = [];
|
|
4884
|
+
for (let j2 of He3) ue3(j2, ce3, w2) ? $3.push({ type: "subtree", el: j2, base: null }) : ie3.push(j2);
|
|
4885
|
+
let ge2 = [];
|
|
4886
|
+
for (let j2 of ae3) ke3.has(j2) || (ue3(j2, Be3, w2) ? $3.push({ type: "deletion", el: j2 }) : ge2.push(j2));
|
|
4887
|
+
if (ie3.length !== ge2.length) return true;
|
|
4888
|
+
for (let j2 = 0; j2 < ie3.length; j2++) if (!v2(ie3[j2], ge2[j2])) return true;
|
|
4889
|
+
let je3 = new Map(Ne3);
|
|
4890
|
+
for (let j2 = 0; j2 < ie3.length; j2++) je3.set(ie3[j2], ge2[j2]);
|
|
4846
4891
|
let $e3 = -1;
|
|
4847
|
-
for (let j2 of
|
|
4848
|
-
let
|
|
4849
|
-
if (!
|
|
4850
|
-
let
|
|
4851
|
-
if (
|
|
4852
|
-
$e3 =
|
|
4853
|
-
}
|
|
4854
|
-
for (let j2 = 0; j2 <
|
|
4855
|
-
for (let [j2,
|
|
4892
|
+
for (let j2 of te3) {
|
|
4893
|
+
let Y2 = je3.get(j2);
|
|
4894
|
+
if (!Y2) continue;
|
|
4895
|
+
let le3 = ae3.indexOf(Y2);
|
|
4896
|
+
if (le3 < $e3) return true;
|
|
4897
|
+
$e3 = le3;
|
|
4898
|
+
}
|
|
4899
|
+
for (let j2 = 0; j2 < ie3.length; j2++) if (A2(ie3[j2], ge2[j2], $3)) return true;
|
|
4900
|
+
for (let [j2, Y2] of Ne3) if (A2(j2, Y2, $3)) return true;
|
|
4856
4901
|
return false;
|
|
4857
4902
|
}
|
|
4858
|
-
function
|
|
4859
|
-
if (
|
|
4860
|
-
let
|
|
4861
|
-
if (
|
|
4862
|
-
if (
|
|
4863
|
-
if (!o2(
|
|
4864
|
-
|
|
4865
|
-
}
|
|
4866
|
-
return
|
|
4867
|
-
}
|
|
4868
|
-
let
|
|
4869
|
-
|
|
4870
|
-
let
|
|
4871
|
-
if (
|
|
4872
|
-
let
|
|
4873
|
-
|
|
4874
|
-
} else (
|
|
4875
|
-
let
|
|
4876
|
-
return
|
|
4903
|
+
function A2(O2, D3, $3) {
|
|
4904
|
+
if (O2.tagName !== D3.tagName) return f2(O2, D3, $3);
|
|
4905
|
+
let R2 = i2(O2, D3), H2 = [];
|
|
4906
|
+
if (L3(O2, D3, H2)) return f2(O2, D3, $3);
|
|
4907
|
+
if (R2.length) {
|
|
4908
|
+
if (!o2(O2) && !ue3(D3, s2(), w2)) return true;
|
|
4909
|
+
$3.push({ type: "attrs", el: O2, names: R2, base: D3 });
|
|
4910
|
+
}
|
|
4911
|
+
return $3.push(...H2), false;
|
|
4912
|
+
}
|
|
4913
|
+
let x2 = [], V3 = i2(r, p2);
|
|
4914
|
+
V3.length && x2.push({ type: "attrs", el: r, names: V3 });
|
|
4915
|
+
let C2 = (O2, D3) => Array.from(O2.children).find(($3) => $3.tagName === D3) || null, z2 = C2(r, "HEAD"), K2 = C2(p2, "HEAD");
|
|
4916
|
+
if (z2 && K2) {
|
|
4917
|
+
let O2 = [];
|
|
4918
|
+
A2(z2, K2, O2), O2.length && x2.push({ type: "head", el: z2 });
|
|
4919
|
+
} else (z2 || K2) && z2 && x2.push({ type: "head", el: z2 });
|
|
4920
|
+
let G3 = C2(r, "BODY"), _ = C2(p2, "BODY");
|
|
4921
|
+
return G3 && _ ? A2(G3, _, x2) : G3 && x2.push({ type: "subtree", el: G3, base: null }), { entries: x2 };
|
|
4877
4922
|
}
|
|
4878
4923
|
function tt3(r, p2, h = {}) {
|
|
4879
|
-
let N2 = h.tiers && h.tiers.length ? h.tiers :
|
|
4880
|
-
if (!
|
|
4881
|
-
function l(
|
|
4882
|
-
let
|
|
4883
|
-
return
|
|
4884
|
-
}
|
|
4885
|
-
let s2 = l(
|
|
4886
|
-
let
|
|
4887
|
-
if (!
|
|
4888
|
-
let
|
|
4889
|
-
|
|
4890
|
-
}
|
|
4891
|
-
return
|
|
4924
|
+
let N2 = h.tiers && h.tiers.length ? h.tiers : Le3, b = r.documentElement, w2 = [], a = 0, c2 = (A2) => ({ ok: false, placed: w2, held: A2, skippedAttrs: a });
|
|
4925
|
+
if (!b) return c2(null);
|
|
4926
|
+
function l(A2) {
|
|
4927
|
+
let x2 = [A2, ...A2.querySelectorAll("*")];
|
|
4928
|
+
return pe3(x2, N2);
|
|
4929
|
+
}
|
|
4930
|
+
let s2 = l(b), o2 = /* @__PURE__ */ new Map(), f2 = (A2) => {
|
|
4931
|
+
let x2 = A2.getRootNode(), V3 = o2.get(x2);
|
|
4932
|
+
if (!V3) {
|
|
4933
|
+
let C2 = x2.nodeType === 9 ? x2.documentElement : x2;
|
|
4934
|
+
V3 = l(C2), o2.set(x2, V3);
|
|
4935
|
+
}
|
|
4936
|
+
return V3;
|
|
4892
4937
|
};
|
|
4893
|
-
function i2(
|
|
4894
|
-
if (!
|
|
4895
|
-
if (
|
|
4896
|
-
if (
|
|
4897
|
-
if (
|
|
4938
|
+
function i2(A2) {
|
|
4939
|
+
if (!A2.parentElement && A2.tagName === "HTML") return b;
|
|
4940
|
+
if (A2.parentElement && !A2.parentElement.parentElement && A2.parentElement.tagName === "HTML") {
|
|
4941
|
+
if (A2.tagName === "BODY") return r.body || null;
|
|
4942
|
+
if (A2.tagName === "HEAD") return r.head || null;
|
|
4898
4943
|
}
|
|
4899
4944
|
return null;
|
|
4900
4945
|
}
|
|
4901
|
-
function
|
|
4902
|
-
let
|
|
4903
|
-
return
|
|
4946
|
+
function m2(A2) {
|
|
4947
|
+
let x2 = i2(A2);
|
|
4948
|
+
return x2 || Re3(A2, f2(A2), s2, N2);
|
|
4904
4949
|
}
|
|
4905
|
-
function
|
|
4906
|
-
if (!
|
|
4907
|
-
let
|
|
4908
|
-
return
|
|
4950
|
+
function v2(A2) {
|
|
4951
|
+
if (!A2) return null;
|
|
4952
|
+
let x2 = m2(A2);
|
|
4953
|
+
return x2 && x2.isConnected ? x2 : null;
|
|
4909
4954
|
}
|
|
4910
|
-
function T2(
|
|
4911
|
-
for (let
|
|
4912
|
-
let
|
|
4913
|
-
|
|
4955
|
+
function T2(A2) {
|
|
4956
|
+
for (let x2 = 0; x2 < N2.length; x2++) {
|
|
4957
|
+
let V3 = N2[x2](A2);
|
|
4958
|
+
V3 != null && V3 !== "" && s2[x2].set(V3, A2);
|
|
4914
4959
|
}
|
|
4915
4960
|
}
|
|
4916
|
-
for (let
|
|
4917
|
-
if (
|
|
4918
|
-
let
|
|
4919
|
-
|
|
4961
|
+
for (let A2 of p2) {
|
|
4962
|
+
if (A2.type !== "deletion") continue;
|
|
4963
|
+
let x2 = m2(A2.el);
|
|
4964
|
+
x2 && x2 !== b && x2.remove();
|
|
4920
4965
|
}
|
|
4921
|
-
let
|
|
4922
|
-
for (let
|
|
4923
|
-
if (
|
|
4924
|
-
let
|
|
4925
|
-
r.head ? r.head.replaceWith(
|
|
4966
|
+
let L3 = p2.filter((A2) => A2.type !== "deletion").sort((A2, x2) => A2.el === x2.el ? 0 : A2.el.compareDocumentPosition(x2.el) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
|
|
4967
|
+
for (let A2 of L3) {
|
|
4968
|
+
if (A2.type === "head") {
|
|
4969
|
+
let _ = r.importNode(A2.el, true);
|
|
4970
|
+
r.head ? r.head.replaceWith(_) : b.insertBefore(_, b.firstChild), w2.push({ entry: A2, imported: _ });
|
|
4926
4971
|
continue;
|
|
4927
4972
|
}
|
|
4928
|
-
if (
|
|
4929
|
-
let
|
|
4930
|
-
if (!
|
|
4973
|
+
if (A2.type === "attrs") {
|
|
4974
|
+
let _ = v2(A2.el) || v2(A2.base);
|
|
4975
|
+
if (!_) {
|
|
4931
4976
|
a++;
|
|
4932
4977
|
continue;
|
|
4933
4978
|
}
|
|
4934
|
-
for (let
|
|
4979
|
+
for (let O2 of A2.names) A2.el.hasAttribute(O2) ? _.setAttribute(O2, A2.el.getAttribute(O2)) : _.removeAttribute(O2);
|
|
4935
4980
|
continue;
|
|
4936
4981
|
}
|
|
4937
|
-
let
|
|
4938
|
-
if (i2(
|
|
4939
|
-
let
|
|
4940
|
-
if (
|
|
4941
|
-
let
|
|
4942
|
-
|
|
4982
|
+
let x2 = A2.el;
|
|
4983
|
+
if (i2(x2)) return c2(A2);
|
|
4984
|
+
let V3 = v2(x2) || v2(A2.base);
|
|
4985
|
+
if (V3) {
|
|
4986
|
+
let _ = r.importNode(x2, true);
|
|
4987
|
+
V3.replaceWith(_), T2(_), w2.push({ entry: A2, imported: _ });
|
|
4943
4988
|
continue;
|
|
4944
4989
|
}
|
|
4945
|
-
if (
|
|
4946
|
-
let
|
|
4947
|
-
if (!
|
|
4948
|
-
let
|
|
4949
|
-
if (!
|
|
4950
|
-
let
|
|
4951
|
-
for (let
|
|
4952
|
-
let
|
|
4953
|
-
if (
|
|
4954
|
-
|
|
4990
|
+
if (A2.base != null && !ue3(A2.base, f2(A2.base), N2) || !ue3(x2, f2(x2), N2)) return c2(A2);
|
|
4991
|
+
let C2 = x2.parentElement;
|
|
4992
|
+
if (!C2) return c2(A2);
|
|
4993
|
+
let z2 = v2(C2);
|
|
4994
|
+
if (!z2) return c2(A2);
|
|
4995
|
+
let K2 = null;
|
|
4996
|
+
for (let _ = x2.previousElementSibling; _; _ = _.previousElementSibling) {
|
|
4997
|
+
let O2 = v2(_);
|
|
4998
|
+
if (O2 && O2.parentNode === z2) {
|
|
4999
|
+
K2 = O2;
|
|
4955
5000
|
break;
|
|
4956
5001
|
}
|
|
4957
5002
|
}
|
|
4958
|
-
let
|
|
4959
|
-
if (
|
|
5003
|
+
let G3 = r.importNode(x2, true);
|
|
5004
|
+
if (K2) z2.insertBefore(G3, K2.nextSibling);
|
|
4960
5005
|
else {
|
|
4961
|
-
let
|
|
4962
|
-
|
|
5006
|
+
let _ = Array.prototype.indexOf.call(C2.children, x2);
|
|
5007
|
+
z2.insertBefore(G3, z2.children[_] || null);
|
|
4963
5008
|
}
|
|
4964
|
-
T2(
|
|
5009
|
+
T2(G3), w2.push({ entry: A2, imported: G3 });
|
|
4965
5010
|
}
|
|
4966
5011
|
return { ok: true, placed: w2, held: null, skippedAttrs: a };
|
|
4967
5012
|
}
|
|
4968
|
-
return { morph:
|
|
5013
|
+
return { morph: J3, defaults: E2, findChangedRoots: et3, spliceProtected: tt3, mergeJson: ve3, mergeScriptText: Me3, parseJsonRelaxed: me3, parseRulesRelaxed: Ie3 };
|
|
4969
5014
|
})();
|
|
4970
|
-
var xt3 =
|
|
4971
|
-
var Bt3 =
|
|
5015
|
+
var xt3 = de3.morph, Ct3 = de3.defaults, Lt2 = de3.findChangedRoots, Rt3 = de3.spliceProtected;
|
|
5016
|
+
var Bt3 = de3;
|
|
4972
5017
|
return at3(Ht3);
|
|
4973
5018
|
})();
|
|
4974
5019
|
morph = function(oldEl, newEl, options = {}) {
|
|
@@ -10895,7 +10940,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
10895
10940
|
seq,
|
|
10896
10941
|
source: "disk",
|
|
10897
10942
|
etag: typeof etag === "string" && etag ? etag : null,
|
|
10898
|
-
by: by || null
|
|
10943
|
+
by: by || null,
|
|
10944
|
+
// The bytes now on disk, exactly as they arrived. The source map models them
|
|
10945
|
+
// so this tab's next save copies from the file somebody else just wrote.
|
|
10946
|
+
html
|
|
10899
10947
|
}
|
|
10900
10948
|
}));
|
|
10901
10949
|
} finally {
|
|
@@ -19166,9 +19214,9 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
19166
19214
|
closeStreamIfIdle();
|
|
19167
19215
|
prune();
|
|
19168
19216
|
if (rec.settle) {
|
|
19169
|
-
const
|
|
19217
|
+
const settle3 = rec.settle;
|
|
19170
19218
|
rec.settle = null;
|
|
19171
|
-
|
|
19219
|
+
settle3(view(rec));
|
|
19172
19220
|
}
|
|
19173
19221
|
}
|
|
19174
19222
|
function loadSaveLane() {
|
|
@@ -19194,14 +19242,14 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
19194
19242
|
function once(eventName, timeout) {
|
|
19195
19243
|
return new Promise((resolve) => {
|
|
19196
19244
|
let done = false;
|
|
19197
|
-
const
|
|
19245
|
+
const settle3 = () => {
|
|
19198
19246
|
if (done) return;
|
|
19199
19247
|
done = true;
|
|
19200
|
-
document.removeEventListener(eventName,
|
|
19248
|
+
document.removeEventListener(eventName, settle3);
|
|
19201
19249
|
resolve();
|
|
19202
19250
|
};
|
|
19203
|
-
document.addEventListener(eventName,
|
|
19204
|
-
setTimeout(
|
|
19251
|
+
document.addEventListener(eventName, settle3);
|
|
19252
|
+
setTimeout(settle3, timeout);
|
|
19205
19253
|
});
|
|
19206
19254
|
}
|
|
19207
19255
|
async function flushSave() {
|
|
@@ -19460,6 +19508,520 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
19460
19508
|
}
|
|
19461
19509
|
});
|
|
19462
19510
|
|
|
19511
|
+
// src/plugins/ai-edit.js
|
|
19512
|
+
var ai_edit_exports = {};
|
|
19513
|
+
__export(ai_edit_exports, {
|
|
19514
|
+
aiEdit: () => aiEdit
|
|
19515
|
+
});
|
|
19516
|
+
async function available() {
|
|
19517
|
+
const list2 = await wire_default.helpers();
|
|
19518
|
+
return list2.some((h) => h.name === HELPER && h.state === "ready");
|
|
19519
|
+
}
|
|
19520
|
+
function pauseObservers() {
|
|
19521
|
+
mutation_default.pause();
|
|
19522
|
+
}
|
|
19523
|
+
function resumeObservers() {
|
|
19524
|
+
mutation_default.resume();
|
|
19525
|
+
}
|
|
19526
|
+
function unitFrom(target) {
|
|
19527
|
+
if (!(target instanceof Element)) return null;
|
|
19528
|
+
const section = target.closest("[data-edit-id]");
|
|
19529
|
+
if (!section) return null;
|
|
19530
|
+
const unit = target.closest(UNIT_SELECTOR);
|
|
19531
|
+
return unit && section.contains(unit) ? unit : section;
|
|
19532
|
+
}
|
|
19533
|
+
function editLabel(el4) {
|
|
19534
|
+
if (el4 === document.body) return "document";
|
|
19535
|
+
const own = el4.getAttribute("data-edit-id");
|
|
19536
|
+
if (own) return own;
|
|
19537
|
+
const section = el4.closest("[data-edit-id]");
|
|
19538
|
+
return (section ? section.getAttribute("data-edit-id") + " \u203A " : "") + el4.tagName.toLowerCase();
|
|
19539
|
+
}
|
|
19540
|
+
function quoteFromSelection(scope) {
|
|
19541
|
+
const selection = window.getSelection();
|
|
19542
|
+
if (!selection || selection.isCollapsed) return void 0;
|
|
19543
|
+
const text = selection.toString().trim();
|
|
19544
|
+
if (!text) return void 0;
|
|
19545
|
+
let node = selection.getRangeAt(0).commonAncestorContainer;
|
|
19546
|
+
if (node.nodeType !== 1) node = node.parentElement;
|
|
19547
|
+
if (scope && scope !== document.body && !scope.contains(node)) return void 0;
|
|
19548
|
+
return text.length > 400 ? text.slice(0, 400) + "\u2026" : text;
|
|
19549
|
+
}
|
|
19550
|
+
function strippedBodyHTML() {
|
|
19551
|
+
const clone = document.body.cloneNode(true);
|
|
19552
|
+
clone.querySelectorAll(STRIP_FROM_SAVE).forEach((node) => node.remove());
|
|
19553
|
+
return clone.outerHTML;
|
|
19554
|
+
}
|
|
19555
|
+
function morphTo(el4, content, scripts) {
|
|
19556
|
+
return HyperMorph.morph(el4, content, { morphStyle: "outerHTML", restoreFocus: true, scripts });
|
|
19557
|
+
}
|
|
19558
|
+
function sessionMorph(s2, content, { rewind = false } = {}) {
|
|
19559
|
+
const scripts = rewind ? { merge: false } : { mergeBase: s2.snapshot, mergeTags: mergeTagRecognizers };
|
|
19560
|
+
if (s2.docMode) {
|
|
19561
|
+
if (typeof content === "string") {
|
|
19562
|
+
content = new DOMParser().parseFromString(content, "text/html").body;
|
|
19563
|
+
}
|
|
19564
|
+
HyperMorph.morph(document.body, content, {
|
|
19565
|
+
morphStyle: "outerHTML",
|
|
19566
|
+
restoreFocus: true,
|
|
19567
|
+
scripts,
|
|
19568
|
+
callbacks: {
|
|
19569
|
+
beforeNodeRemoved: (node) => !(node.nodeType === 1 && node.matches(STRIP_FROM_SAVE))
|
|
19570
|
+
}
|
|
19571
|
+
});
|
|
19572
|
+
} else {
|
|
19573
|
+
morphTo(s2.el, content, scripts);
|
|
19574
|
+
}
|
|
19575
|
+
enableContentEditable();
|
|
19576
|
+
}
|
|
19577
|
+
function candidateFrom(html, tag) {
|
|
19578
|
+
const start = html.search(new RegExp("<" + tag + "(\\s|>)", "i"));
|
|
19579
|
+
if (start === -1) return null;
|
|
19580
|
+
const cleaned = html.slice(start).replace(/\s*`{1,3}\s*$/, "");
|
|
19581
|
+
if (tag.toLowerCase() === "body") {
|
|
19582
|
+
return new DOMParser().parseFromString(cleaned, "text/html").body;
|
|
19583
|
+
}
|
|
19584
|
+
const template = document.createElement("template");
|
|
19585
|
+
template.innerHTML = cleaned;
|
|
19586
|
+
const candidate = template.content.firstElementChild;
|
|
19587
|
+
if (!candidate || candidate.tagName.toLowerCase() !== tag.toLowerCase()) return null;
|
|
19588
|
+
return candidate;
|
|
19589
|
+
}
|
|
19590
|
+
function newSession(el4, comment, quote) {
|
|
19591
|
+
const docMode = el4 === document.body;
|
|
19592
|
+
const contextRefs = [...comment.matchAll(/@([\w.-]*[/.][\w./-]*)/g)].map((m2) => m2[1]).filter((ref) => ref !== "page");
|
|
19593
|
+
const elementHTML = docMode ? strippedBodyHTML() : el4.outerHTML;
|
|
19594
|
+
const payload = {
|
|
19595
|
+
id: "req-" + Date.now().toString(36) + "-" + ++requestCounter,
|
|
19596
|
+
editId: editLabel(el4),
|
|
19597
|
+
tag: el4.tagName.toLowerCase(),
|
|
19598
|
+
elementHTML,
|
|
19599
|
+
comment,
|
|
19600
|
+
contextRefs
|
|
19601
|
+
};
|
|
19602
|
+
if (quote) payload.quote = quote;
|
|
19603
|
+
if (!docMode && /@page\b/.test(comment)) payload.page = true;
|
|
19604
|
+
return {
|
|
19605
|
+
id: payload.id,
|
|
19606
|
+
el: el4,
|
|
19607
|
+
docMode,
|
|
19608
|
+
tag: payload.tag,
|
|
19609
|
+
reassertId: docMode ? null : el4.getAttribute("data-edit-id"),
|
|
19610
|
+
snapshot: elementHTML,
|
|
19611
|
+
payload,
|
|
19612
|
+
state: "requesting",
|
|
19613
|
+
paused: false,
|
|
19614
|
+
handle: null,
|
|
19615
|
+
finalCandidate: null
|
|
19616
|
+
};
|
|
19617
|
+
}
|
|
19618
|
+
async function sendRequest(el4, comment, quote) {
|
|
19619
|
+
session = newSession(el4, comment, quote);
|
|
19620
|
+
if (new Blob([JSON.stringify(session.payload)]).size > MAX_PAYLOAD_BYTES) {
|
|
19621
|
+
session = null;
|
|
19622
|
+
setStatus(TOO_LARGE, "warn");
|
|
19623
|
+
showButtons("send");
|
|
19624
|
+
return;
|
|
19625
|
+
}
|
|
19626
|
+
session.paused = true;
|
|
19627
|
+
pauseObservers();
|
|
19628
|
+
setStatus("sending\u2026");
|
|
19629
|
+
showButtons("stop");
|
|
19630
|
+
if (/@page\b/.test(comment) && !session.docMode) await window.clay.save();
|
|
19631
|
+
if (!session) return;
|
|
19632
|
+
const handle = wire_default.send(session.payload, {
|
|
19633
|
+
helper: HELPER,
|
|
19634
|
+
onStatus: ({ text }) => {
|
|
19635
|
+
if (session?.handle === handle) setStatus(text);
|
|
19636
|
+
}
|
|
19637
|
+
});
|
|
19638
|
+
session.handle = handle;
|
|
19639
|
+
const outcome = await handle.done;
|
|
19640
|
+
if (!session || session.handle !== handle) return;
|
|
19641
|
+
if (outcome.state === "done") onDone(outcome.result || {});
|
|
19642
|
+
else if (outcome.state === "cancelled") {
|
|
19643
|
+
revertSession();
|
|
19644
|
+
setStatus("cancelled");
|
|
19645
|
+
showButtons("send");
|
|
19646
|
+
} else onError(outcome.error || "the helper reported an error");
|
|
19647
|
+
}
|
|
19648
|
+
function onDone(payload) {
|
|
19649
|
+
if (!session || session.state !== "requesting") return;
|
|
19650
|
+
session.state = "deciding";
|
|
19651
|
+
const warnings = [];
|
|
19652
|
+
let candidate = candidateFrom(payload.html || "", session.tag);
|
|
19653
|
+
if (!candidate) {
|
|
19654
|
+
onError(`reply is not a single <${session.tag}> element`);
|
|
19655
|
+
return;
|
|
19656
|
+
}
|
|
19657
|
+
if (!session.docMode) {
|
|
19658
|
+
const template = document.createElement("template");
|
|
19659
|
+
template.innerHTML = payload.html || "";
|
|
19660
|
+
if (template.content.children.length > 1) {
|
|
19661
|
+
warnings.push("reply had extra root elements \u2014 kept the first");
|
|
19662
|
+
}
|
|
19663
|
+
}
|
|
19664
|
+
if (session.reassertId) candidate.setAttribute("data-edit-id", session.reassertId);
|
|
19665
|
+
if (!session.docMode) {
|
|
19666
|
+
if (candidate.querySelector("script")) {
|
|
19667
|
+
warnings.push("reply contains <script> \u2014 review before keeping");
|
|
19668
|
+
}
|
|
19669
|
+
for (const el4 of [candidate, ...candidate.querySelectorAll("*")]) {
|
|
19670
|
+
if ([...el4.attributes].some((a) => a.name.toLowerCase().startsWith("on"))) {
|
|
19671
|
+
warnings.push("reply contains inline event handlers \u2014 review before keeping");
|
|
19672
|
+
break;
|
|
19673
|
+
}
|
|
19674
|
+
}
|
|
19675
|
+
}
|
|
19676
|
+
session.finalCandidate = candidate;
|
|
19677
|
+
sessionMorph(session, candidate);
|
|
19678
|
+
positionChrome();
|
|
19679
|
+
setStatus(payload.model ? `done (${payload.model})` : "done");
|
|
19680
|
+
showWarnings(warnings);
|
|
19681
|
+
showButtons("keep", "revert");
|
|
19682
|
+
textarea.value = "";
|
|
19683
|
+
}
|
|
19684
|
+
function onError(message) {
|
|
19685
|
+
if (!session) return;
|
|
19686
|
+
revertSession();
|
|
19687
|
+
setStatus(message, "warn");
|
|
19688
|
+
showButtons("send");
|
|
19689
|
+
}
|
|
19690
|
+
function revertSession() {
|
|
19691
|
+
const s2 = session;
|
|
19692
|
+
session = null;
|
|
19693
|
+
if (!s2) return;
|
|
19694
|
+
if (s2.state === "requesting" || s2.state === "deciding") {
|
|
19695
|
+
sessionMorph(s2, s2.snapshot, { rewind: true });
|
|
19696
|
+
}
|
|
19697
|
+
if (s2.paused) resumeObservers();
|
|
19698
|
+
positionChrome();
|
|
19699
|
+
}
|
|
19700
|
+
async function keepSession() {
|
|
19701
|
+
const s2 = session;
|
|
19702
|
+
session = null;
|
|
19703
|
+
sessionMorph(s2, s2.snapshot, { rewind: true });
|
|
19704
|
+
if (s2.paused) resumeObservers();
|
|
19705
|
+
sessionMorph(s2, s2.finalCandidate);
|
|
19706
|
+
positionChrome();
|
|
19707
|
+
showButtons("send");
|
|
19708
|
+
setStatus("saving\u2026");
|
|
19709
|
+
const result2 = await window.clay.save();
|
|
19710
|
+
setStatus(result2 && result2.msg || "saved", result2 && result2.msgType === "error" ? "warn" : "");
|
|
19711
|
+
}
|
|
19712
|
+
function cancelStream() {
|
|
19713
|
+
session?.handle?.cancel();
|
|
19714
|
+
revertSession();
|
|
19715
|
+
setStatus("cancelled");
|
|
19716
|
+
showButtons("send");
|
|
19717
|
+
}
|
|
19718
|
+
function markRuntimeOnly(el4) {
|
|
19719
|
+
el4.setAttribute("clay", RUNTIME_ONLY3);
|
|
19720
|
+
return el4;
|
|
19721
|
+
}
|
|
19722
|
+
function buildChrome() {
|
|
19723
|
+
const style2 = document.createElement("style");
|
|
19724
|
+
style2.setAttribute("clay", RUNTIME_ONLY3);
|
|
19725
|
+
style2.textContent = `
|
|
19726
|
+
#hyper-edit-panel {
|
|
19727
|
+
position: fixed; z-index: 99999; width: min(30rem, calc(100vw - 2rem));
|
|
19728
|
+
background: #16161d; color: #e8e8f0; border: 1px solid #34343f;
|
|
19729
|
+
border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.45);
|
|
19730
|
+
font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
19731
|
+
padding: 10px;
|
|
19732
|
+
}
|
|
19733
|
+
#hyper-edit-panel[hidden] { display: none; }
|
|
19734
|
+
#hyper-edit-panel .hep-quote {
|
|
19735
|
+
color: #9a9ab0; border-left: 2px solid #4a4a5a; padding-left: 8px;
|
|
19736
|
+
margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
19737
|
+
}
|
|
19738
|
+
#hyper-edit-panel textarea {
|
|
19739
|
+
width: 100%; box-sizing: border-box; min-height: 3.2em; resize: vertical;
|
|
19740
|
+
background: #0e0e13; color: inherit; border: 1px solid #34343f;
|
|
19741
|
+
border-radius: 6px; padding: 8px; font: inherit; outline: none;
|
|
19742
|
+
}
|
|
19743
|
+
#hyper-edit-panel textarea:focus { border-color: #6a6a8a; }
|
|
19744
|
+
#hyper-edit-panel .hep-row {
|
|
19745
|
+
display: flex; align-items: center; gap: 8px; margin-top: 8px;
|
|
19746
|
+
}
|
|
19747
|
+
#hyper-edit-panel .hep-status { flex: 1; color: #9a9ab0; min-width: 0; }
|
|
19748
|
+
#hyper-edit-panel .hep-status.warn { color: #e8b04a; }
|
|
19749
|
+
#hyper-edit-panel button {
|
|
19750
|
+
background: #26262f; color: inherit; border: 1px solid #44444f;
|
|
19751
|
+
border-radius: 6px; padding: 4px 12px; font: inherit; cursor: pointer;
|
|
19752
|
+
}
|
|
19753
|
+
#hyper-edit-panel button:hover { background: #32323d; }
|
|
19754
|
+
#hyper-edit-panel .hep-keep { background: #1e3a2a; border-color: #2e5a40; }
|
|
19755
|
+
#hyper-edit-panel .hep-warnings {
|
|
19756
|
+
margin-top: 8px; color: #e8b04a; white-space: pre-line;
|
|
19757
|
+
}
|
|
19758
|
+
#hyper-edit-ring {
|
|
19759
|
+
position: fixed; z-index: 99998; pointer-events: none;
|
|
19760
|
+
border: 1px solid #7a7aff; border-radius: 4px; opacity: .8;
|
|
19761
|
+
}
|
|
19762
|
+
#hyper-edit-ring[hidden] { display: none; }
|
|
19763
|
+
#hyper-edit-chip {
|
|
19764
|
+
position: fixed; z-index: 99999; width: 26px; height: 26px; padding: 0;
|
|
19765
|
+
display: flex; align-items: center; justify-content: center;
|
|
19766
|
+
background: #16161d; color: #e8e8f0; border: 1px solid #44444f;
|
|
19767
|
+
border-radius: 50%; cursor: pointer; font-size: 13px; line-height: 1;
|
|
19768
|
+
box-shadow: 0 4px 14px rgba(0,0,0,.4);
|
|
19769
|
+
}
|
|
19770
|
+
#hyper-edit-chip[hidden] { display: none; }
|
|
19771
|
+
#hyper-edit-chip:hover { background: #32323d; border-color: #6a6a8a; }
|
|
19772
|
+
#hyper-edit-doc-bubble {
|
|
19773
|
+
position: fixed; right: 16px; bottom: 16px; z-index: 99999;
|
|
19774
|
+
width: 44px; height: 44px; padding: 0; border-radius: 50%;
|
|
19775
|
+
display: flex; align-items: center; justify-content: center;
|
|
19776
|
+
background: #16161d; color: #e8e8f0; border: 1px solid #44444f;
|
|
19777
|
+
font-size: 18px; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.45);
|
|
19778
|
+
}
|
|
19779
|
+
#hyper-edit-doc-bubble:hover { background: #32323d; border-color: #6a6a8a; }
|
|
19780
|
+
[editmode\\:contenteditable][contenteditable]:focus {
|
|
19781
|
+
outline: 1px solid #4a4a6a; outline-offset: 4px; border-radius: 2px;
|
|
19782
|
+
}
|
|
19783
|
+
`;
|
|
19784
|
+
document.head.appendChild(style2);
|
|
19785
|
+
ring = markRuntimeOnly(document.createElement("div"));
|
|
19786
|
+
ring.id = "hyper-edit-ring";
|
|
19787
|
+
ring.hidden = true;
|
|
19788
|
+
panel = markRuntimeOnly(document.createElement("div"));
|
|
19789
|
+
panel.id = "hyper-edit-panel";
|
|
19790
|
+
panel.hidden = true;
|
|
19791
|
+
panel.innerHTML = `
|
|
19792
|
+
<div class="hep-quote" hidden></div>
|
|
19793
|
+
<textarea rows="2" placeholder="Describe the change\u2026 (@file.ext adds context, @fable / @claude picks the agent)"></textarea>
|
|
19794
|
+
<div class="hep-row">
|
|
19795
|
+
<span class="hep-status"></span>
|
|
19796
|
+
<button class="hep-send" type="button">Send</button>
|
|
19797
|
+
<button class="hep-stop" type="button" hidden>Stop</button>
|
|
19798
|
+
<button class="hep-revert" type="button" hidden>Revert</button>
|
|
19799
|
+
<button class="hep-keep" type="button" hidden>Keep</button>
|
|
19800
|
+
</div>
|
|
19801
|
+
<div class="hep-warnings" hidden></div>
|
|
19802
|
+
`;
|
|
19803
|
+
chip = markRuntimeOnly(document.createElement("button"));
|
|
19804
|
+
chip.id = "hyper-edit-chip";
|
|
19805
|
+
chip.type = "button";
|
|
19806
|
+
chip.title = "Comment on this (\u2318K)";
|
|
19807
|
+
chip.textContent = "\u{1F4AC}";
|
|
19808
|
+
chip.hidden = true;
|
|
19809
|
+
docBubble = markRuntimeOnly(document.createElement("button"));
|
|
19810
|
+
docBubble.id = "hyper-edit-doc-bubble";
|
|
19811
|
+
docBubble.type = "button";
|
|
19812
|
+
docBubble.title = "Comment on the whole page";
|
|
19813
|
+
docBubble.textContent = "\u{1F4AC}";
|
|
19814
|
+
document.body.append(ring, panel, chip, docBubble);
|
|
19815
|
+
quoteEl = panel.querySelector(".hep-quote");
|
|
19816
|
+
textarea = panel.querySelector("textarea");
|
|
19817
|
+
statusEl = panel.querySelector(".hep-status");
|
|
19818
|
+
warningsEl = panel.querySelector(".hep-warnings");
|
|
19819
|
+
for (const name of ["send", "stop", "keep", "revert"]) {
|
|
19820
|
+
buttons[name] = panel.querySelector(".hep-" + name);
|
|
19821
|
+
}
|
|
19822
|
+
buttons.send.addEventListener("click", submit);
|
|
19823
|
+
buttons.stop.addEventListener("click", cancelStream);
|
|
19824
|
+
buttons.keep.addEventListener("click", keepSession);
|
|
19825
|
+
buttons.revert.addEventListener("click", () => {
|
|
19826
|
+
revertSession();
|
|
19827
|
+
setStatus("reverted");
|
|
19828
|
+
showButtons("send");
|
|
19829
|
+
});
|
|
19830
|
+
textarea.addEventListener("keydown", (event) => {
|
|
19831
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
19832
|
+
event.preventDefault();
|
|
19833
|
+
if (!buttons.send.hidden) submit();
|
|
19834
|
+
}
|
|
19835
|
+
});
|
|
19836
|
+
chip.addEventListener("click", () => {
|
|
19837
|
+
const target = chipTarget;
|
|
19838
|
+
hideChip();
|
|
19839
|
+
if (target && !session) openPanel(target, quoteFromSelection(target));
|
|
19840
|
+
});
|
|
19841
|
+
docBubble.addEventListener("click", () => {
|
|
19842
|
+
if (session) return;
|
|
19843
|
+
openPanel(document.body, quoteFromSelection(document.body));
|
|
19844
|
+
});
|
|
19845
|
+
window.addEventListener("scroll", () => {
|
|
19846
|
+
positionChrome();
|
|
19847
|
+
hideChip();
|
|
19848
|
+
}, { passive: true });
|
|
19849
|
+
window.addEventListener("resize", positionChrome, { passive: true });
|
|
19850
|
+
}
|
|
19851
|
+
function showChipFor(unit) {
|
|
19852
|
+
clearTimeout(chipHideTimer);
|
|
19853
|
+
chipHideTimer = null;
|
|
19854
|
+
chipTarget = unit;
|
|
19855
|
+
const rect = unit.getBoundingClientRect();
|
|
19856
|
+
chip.hidden = false;
|
|
19857
|
+
chip.style.left = Math.min(rect.right + 8, window.innerWidth - 34) + "px";
|
|
19858
|
+
chip.style.top = Math.max(8, rect.top) + "px";
|
|
19859
|
+
}
|
|
19860
|
+
function hideChip() {
|
|
19861
|
+
clearTimeout(chipHideTimer);
|
|
19862
|
+
chipHideTimer = null;
|
|
19863
|
+
chip.hidden = true;
|
|
19864
|
+
chipTarget = null;
|
|
19865
|
+
}
|
|
19866
|
+
function scheduleChipHide() {
|
|
19867
|
+
if (chip.hidden || chipHideTimer) return;
|
|
19868
|
+
chipHideTimer = setTimeout(hideChip, 400);
|
|
19869
|
+
}
|
|
19870
|
+
function setStatus(text, tone) {
|
|
19871
|
+
statusEl.textContent = text || "";
|
|
19872
|
+
statusEl.classList.toggle("warn", tone === "warn");
|
|
19873
|
+
}
|
|
19874
|
+
function showButtons(...names) {
|
|
19875
|
+
for (const [name, button2] of Object.entries(buttons)) {
|
|
19876
|
+
button2.hidden = !names.includes(name);
|
|
19877
|
+
}
|
|
19878
|
+
}
|
|
19879
|
+
function showWarnings(warnings) {
|
|
19880
|
+
warningsEl.hidden = !warnings.length;
|
|
19881
|
+
warningsEl.textContent = warnings.map((w2) => "\u26A0 " + w2).join("\n");
|
|
19882
|
+
}
|
|
19883
|
+
function positionChrome() {
|
|
19884
|
+
if (!anchorEl || panel.hidden) return;
|
|
19885
|
+
if (!anchorEl.isConnected) {
|
|
19886
|
+
closePanel();
|
|
19887
|
+
return;
|
|
19888
|
+
}
|
|
19889
|
+
if (anchorEl === document.body) {
|
|
19890
|
+
ring.hidden = true;
|
|
19891
|
+
panel.style.left = Math.max(16, window.innerWidth - (panel.offsetWidth || 480) - 16) + "px";
|
|
19892
|
+
panel.style.top = Math.max(16, window.innerHeight - (panel.offsetHeight || 120) - 76) + "px";
|
|
19893
|
+
return;
|
|
19894
|
+
}
|
|
19895
|
+
const rect = anchorEl.getBoundingClientRect();
|
|
19896
|
+
ring.hidden = false;
|
|
19897
|
+
ring.style.left = rect.left - 4 + "px";
|
|
19898
|
+
ring.style.top = rect.top - 4 + "px";
|
|
19899
|
+
ring.style.width = rect.width + 6 + "px";
|
|
19900
|
+
ring.style.height = rect.height + 6 + "px";
|
|
19901
|
+
const panelWidth = panel.offsetWidth || 480;
|
|
19902
|
+
const left = Math.max(16, Math.min(rect.left, window.innerWidth - panelWidth - 16));
|
|
19903
|
+
let top = rect.bottom + 10;
|
|
19904
|
+
const panelHeight = panel.offsetHeight || 120;
|
|
19905
|
+
if (top + panelHeight > window.innerHeight - 16) {
|
|
19906
|
+
top = Math.max(16, rect.top - panelHeight - 10);
|
|
19907
|
+
}
|
|
19908
|
+
panel.style.left = left + "px";
|
|
19909
|
+
panel.style.top = top + "px";
|
|
19910
|
+
}
|
|
19911
|
+
function openPanel(el4, quote) {
|
|
19912
|
+
anchorEl = el4;
|
|
19913
|
+
hideChip();
|
|
19914
|
+
panel.hidden = false;
|
|
19915
|
+
quoteEl.hidden = !quote;
|
|
19916
|
+
quoteEl.textContent = quote ? `\u201C${quote}\u201D` : "";
|
|
19917
|
+
panel.dataset.quote = quote || "";
|
|
19918
|
+
setStatus("");
|
|
19919
|
+
showWarnings([]);
|
|
19920
|
+
showButtons("send");
|
|
19921
|
+
positionChrome();
|
|
19922
|
+
textarea.focus();
|
|
19923
|
+
}
|
|
19924
|
+
function closePanel() {
|
|
19925
|
+
if (session) revertSession();
|
|
19926
|
+
anchorEl = null;
|
|
19927
|
+
panel.hidden = true;
|
|
19928
|
+
ring.hidden = true;
|
|
19929
|
+
textarea.value = "";
|
|
19930
|
+
}
|
|
19931
|
+
function submit() {
|
|
19932
|
+
const comment = textarea.value.trim();
|
|
19933
|
+
if (!comment || !anchorEl || session) return;
|
|
19934
|
+
sendRequest(anchorEl, comment, panel.dataset.quote || void 0);
|
|
19935
|
+
}
|
|
19936
|
+
function wireInteractions() {
|
|
19937
|
+
document.addEventListener("click", (event) => {
|
|
19938
|
+
if (panel.contains(event.target) || chip.contains(event.target) || docBubble.contains(event.target)) return;
|
|
19939
|
+
if (session) return;
|
|
19940
|
+
const section = event.target.closest?.("[data-edit-id]");
|
|
19941
|
+
const unit = section ? unitFrom(event.target) : null;
|
|
19942
|
+
if (section && unit === section) {
|
|
19943
|
+
if (section !== anchorEl || panel.hidden) openPanel(section, quoteFromSelection(section));
|
|
19944
|
+
} else if (!panel.hidden && !textarea.value.trim() && !(anchorEl && anchorEl.contains(event.target))) {
|
|
19945
|
+
closePanel();
|
|
19946
|
+
}
|
|
19947
|
+
});
|
|
19948
|
+
let lastMove = 0;
|
|
19949
|
+
document.addEventListener("mousemove", (event) => {
|
|
19950
|
+
const now3 = Date.now();
|
|
19951
|
+
if (now3 - lastMove < 80) return;
|
|
19952
|
+
lastMove = now3;
|
|
19953
|
+
if (session || !panel.hidden) {
|
|
19954
|
+
scheduleChipHide();
|
|
19955
|
+
return;
|
|
19956
|
+
}
|
|
19957
|
+
if (chip.contains(event.target)) {
|
|
19958
|
+
clearTimeout(chipHideTimer);
|
|
19959
|
+
chipHideTimer = null;
|
|
19960
|
+
return;
|
|
19961
|
+
}
|
|
19962
|
+
const unit = unitFrom(event.target);
|
|
19963
|
+
if (unit) showChipFor(unit);
|
|
19964
|
+
else scheduleChipHide();
|
|
19965
|
+
});
|
|
19966
|
+
document.addEventListener("keydown", (event) => {
|
|
19967
|
+
if ((event.metaKey || event.ctrlKey) && !event.shiftKey && !event.altKey && event.key.toLowerCase() === "k") {
|
|
19968
|
+
if (session) return;
|
|
19969
|
+
event.preventDefault();
|
|
19970
|
+
const selection = window.getSelection();
|
|
19971
|
+
let node = selection && selection.anchorNode;
|
|
19972
|
+
if (node && node.nodeType !== 1) node = node.parentElement;
|
|
19973
|
+
const target = node && unitFrom(node) || chipTarget;
|
|
19974
|
+
if (target) openPanel(target, quoteFromSelection(target));
|
|
19975
|
+
return;
|
|
19976
|
+
}
|
|
19977
|
+
if (event.key !== "Escape" || panel.hidden) return;
|
|
19978
|
+
if (session?.state === "requesting") {
|
|
19979
|
+
cancelStream();
|
|
19980
|
+
} else if (session?.state === "deciding") {
|
|
19981
|
+
revertSession();
|
|
19982
|
+
setStatus("reverted");
|
|
19983
|
+
showButtons("send");
|
|
19984
|
+
} else {
|
|
19985
|
+
closePanel();
|
|
19986
|
+
}
|
|
19987
|
+
});
|
|
19988
|
+
}
|
|
19989
|
+
async function init18() {
|
|
19990
|
+
if (!isEditMode) return;
|
|
19991
|
+
if (!await available()) return;
|
|
19992
|
+
buildChrome();
|
|
19993
|
+
wireInteractions();
|
|
19994
|
+
}
|
|
19995
|
+
var HELPER, UNIT_SELECTOR, RUNTIME_ONLY3, MAX_PAYLOAD_BYTES, TOO_LARGE, requestCounter, session, panel, ring, textarea, quoteEl, statusEl, warningsEl, chip, docBubble, buttons, anchorEl, chipTarget, chipHideTimer, aiEdit;
|
|
19996
|
+
var init_ai_edit = __esm({
|
|
19997
|
+
"src/plugins/ai-edit.js"() {
|
|
19998
|
+
init_hyper_morph_vendor();
|
|
19999
|
+
init_merge_tags();
|
|
20000
|
+
init_mutation();
|
|
20001
|
+
init_is_edit_mode();
|
|
20002
|
+
init_region_policy();
|
|
20003
|
+
init_admin_contenteditable();
|
|
20004
|
+
init_dom_ready();
|
|
20005
|
+
init_wire();
|
|
20006
|
+
HELPER = "ai-edit";
|
|
20007
|
+
UNIT_SELECTOR = "h1,h2,h3,h4,h5,h6,p,figure";
|
|
20008
|
+
RUNTIME_ONLY3 = "no-save no-watch no-snapshot";
|
|
20009
|
+
MAX_PAYLOAD_BYTES = 900 * 1024;
|
|
20010
|
+
TOO_LARGE = "This section is too large for AI editing; select a smaller part.";
|
|
20011
|
+
requestCounter = 0;
|
|
20012
|
+
session = null;
|
|
20013
|
+
buttons = {};
|
|
20014
|
+
anchorEl = null;
|
|
20015
|
+
chipTarget = null;
|
|
20016
|
+
chipHideTimer = null;
|
|
20017
|
+
dom_ready_default(() => {
|
|
20018
|
+
init18().catch(() => {
|
|
20019
|
+
});
|
|
20020
|
+
});
|
|
20021
|
+
aiEdit = { init: init18 };
|
|
20022
|
+
}
|
|
20023
|
+
});
|
|
20024
|
+
|
|
19463
20025
|
// src/plugins/demo.js
|
|
19464
20026
|
var demo_exports = {};
|
|
19465
20027
|
__export(demo_exports, {
|
|
@@ -24099,7 +24661,17 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24099
24661
|
const html = doc.childNodes.find((n2) => n2.nodeName === "html");
|
|
24100
24662
|
const outside = doc.childNodes.filter((n2) => n2 !== html).map((n2) => n2.nodeName === "#documentType" ? { kind: "doctype", name: n2.name || "", publicId: n2.publicId || "", systemId: n2.systemId || "" } : { kind: n2.nodeName === "#comment" ? "comment" : n2.nodeName, value: n2.data });
|
|
24101
24663
|
const root3 = html ? locOf(html, null, src) : null;
|
|
24102
|
-
|
|
24664
|
+
if (root3) settle(root3, src);
|
|
24665
|
+
return {
|
|
24666
|
+
src,
|
|
24667
|
+
doc,
|
|
24668
|
+
outside,
|
|
24669
|
+
root: root3,
|
|
24670
|
+
parseErrors,
|
|
24671
|
+
relocated: root3 ? firstOutOfOrder(root3) : null,
|
|
24672
|
+
movedIn: root3 ? firstOutOfOrder(root3, "movedIn") : null,
|
|
24673
|
+
tailOwner: root3 ? tailOwner(root3) : null
|
|
24674
|
+
};
|
|
24103
24675
|
}
|
|
24104
24676
|
function locOf(n2, parent, src) {
|
|
24105
24677
|
const l = n2.sourceCodeLocation || null;
|
|
@@ -24119,6 +24691,7 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24119
24691
|
loc.openTo = loc.located ? l.startTag.endOffset : -1;
|
|
24120
24692
|
loc.closeFrom = l && l.endTag ? l.endTag.startOffset : loc.located ? loc.to : -1;
|
|
24121
24693
|
loc.closeTo = l && l.endTag ? l.endTag.endOffset : loc.located ? loc.to : -1;
|
|
24694
|
+
loc.endTagged = !!(l && l.endTag);
|
|
24122
24695
|
if (loc.located) {
|
|
24123
24696
|
if (loc.to < loc.openTo) loc.to = loc.openTo;
|
|
24124
24697
|
if (loc.closeFrom < loc.openTo) loc.closeFrom = loc.closeTo = loc.openTo;
|
|
@@ -24144,23 +24717,28 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24144
24717
|
loc.from = first;
|
|
24145
24718
|
loc.to = last;
|
|
24146
24719
|
}
|
|
24720
|
+
return loc;
|
|
24721
|
+
}
|
|
24722
|
+
function settle(loc, src, limit = Infinity) {
|
|
24723
|
+
if (loc.kind !== "element") return;
|
|
24147
24724
|
for (const cl2 of loc.children) {
|
|
24725
|
+
if (cl2.from >= limit && !(cl2.kind === "text" && !/\S/.test(cl2.value))) loc.movedIn = true;
|
|
24148
24726
|
if (cl2.from >= 0 && loc.located) {
|
|
24149
24727
|
const to2 = Math.max(loc.openTo, Math.min(cl2.to, loc.closeFrom));
|
|
24150
24728
|
const from = Math.min(Math.max(cl2.from, loc.openTo), to2);
|
|
24151
24729
|
if (from !== cl2.from || to2 !== cl2.to) {
|
|
24152
|
-
if (cl2.kind === "text") {
|
|
24153
|
-
const
|
|
24154
|
-
if (cl2.value.
|
|
24155
|
-
const outside = cl2.value.slice(inside.length);
|
|
24156
|
-
if (outside && !/\S/.test(outside)) cl2.outsideTail = outside;
|
|
24157
|
-
}
|
|
24730
|
+
if (cl2.kind === "text" && !RAW_TEXT.has(loc.tag) && !RCDATA.has(loc.tag)) {
|
|
24731
|
+
const outside = src.slice(to2, cl2.to).replace(/<!--[\s\S]*?-->|<[^>]*>/g, "").replace(/\r\n?/g, "\n");
|
|
24732
|
+
if (outside && !/\S/.test(outside) && cl2.value.endsWith(outside)) cl2.outsideTail = outside;
|
|
24158
24733
|
}
|
|
24159
24734
|
cl2.clamped = true;
|
|
24160
24735
|
cl2.from = from;
|
|
24161
24736
|
cl2.to = to2;
|
|
24162
24737
|
}
|
|
24163
24738
|
}
|
|
24739
|
+
if (cl2.kind === "element" && cl2.located && !cl2.endTagged && cl2.closeFrom > cl2.to) {
|
|
24740
|
+
cl2.closeFrom = cl2.closeTo = cl2.to;
|
|
24741
|
+
}
|
|
24164
24742
|
}
|
|
24165
24743
|
let floor = loc.located ? loc.openTo : -1;
|
|
24166
24744
|
for (const cl2 of loc.children) {
|
|
@@ -24171,13 +24749,22 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24171
24749
|
}
|
|
24172
24750
|
floor = cl2.to;
|
|
24173
24751
|
}
|
|
24174
|
-
|
|
24752
|
+
const inner = loc.located && loc.endTagged ? Math.min(limit, loc.closeTo) : limit;
|
|
24753
|
+
for (const cl2 of loc.children) settle(cl2, src, inner);
|
|
24175
24754
|
}
|
|
24176
|
-
function firstOutOfOrder(loc) {
|
|
24177
|
-
if (loc
|
|
24755
|
+
function firstOutOfOrder(loc, flag = "outOfOrder") {
|
|
24756
|
+
if (loc[flag]) return loc.tag;
|
|
24178
24757
|
for (const c2 of loc.children) {
|
|
24179
24758
|
if (c2.kind !== "element") continue;
|
|
24180
|
-
const found = firstOutOfOrder(c2);
|
|
24759
|
+
const found = firstOutOfOrder(c2, flag);
|
|
24760
|
+
if (found) return found;
|
|
24761
|
+
}
|
|
24762
|
+
return null;
|
|
24763
|
+
}
|
|
24764
|
+
function tailOwner(loc) {
|
|
24765
|
+
if (loc.outsideTail) return loc;
|
|
24766
|
+
for (const c2 of loc.children || []) {
|
|
24767
|
+
const found = tailOwner(c2);
|
|
24181
24768
|
if (found) return found;
|
|
24182
24769
|
}
|
|
24183
24770
|
return null;
|
|
@@ -24186,6 +24773,7 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24186
24773
|
if (!m2.root) return "source has no <html> element";
|
|
24187
24774
|
if (m2.root.openFrom < 0) return "source has no content inside <html>";
|
|
24188
24775
|
if (m2.relocated) return "the parser moved content out of <" + m2.relocated + ">, so source order and tree order disagree";
|
|
24776
|
+
if (m2.movedIn) return "the parser moved content written after the end of <" + m2.movedIn + "> back inside it, so source order and tree order disagree";
|
|
24189
24777
|
const want = outsideOf(liveDocument);
|
|
24190
24778
|
const got = m2.outside.map(outsideKey);
|
|
24191
24779
|
if (want.length !== got.length) return "outside <html>: " + JSON.stringify(got) + " vs live " + JSON.stringify(want);
|
|
@@ -24457,21 +25045,52 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24457
25045
|
const text = (t) => {
|
|
24458
25046
|
if (t) pieces.push({ text: t });
|
|
24459
25047
|
};
|
|
25048
|
+
let printing = 0;
|
|
24460
25049
|
const locOfClone = (n2) => {
|
|
25050
|
+
if (printing) return null;
|
|
24461
25051
|
const live = provenance(n2);
|
|
24462
25052
|
const l = live ? map.get(live) : null;
|
|
24463
25053
|
return l && l.gen === m2.gen ? l : null;
|
|
24464
25054
|
};
|
|
25055
|
+
let tailMark = null;
|
|
25056
|
+
let afterBody = -1;
|
|
25057
|
+
let tailClean = false;
|
|
24465
25058
|
const rootLoc = m2.root;
|
|
24466
25059
|
keep2(0, rootLoc.openFrom);
|
|
24467
25060
|
emitElement(clone, rootLoc);
|
|
24468
25061
|
keep2(rootLoc.closeTo, src.length);
|
|
24469
|
-
|
|
25062
|
+
if (m2.tailOwner && afterBody >= 0 && !tailClean) {
|
|
25063
|
+
for (let i2 = afterBody; i2 < pieces.length; i2++) pieces[i2] = { text: withoutWhitespace(piece(pieces[i2])) };
|
|
25064
|
+
if (tailMark && tailMark.tail) pieces.splice(tailMark.at, 0, { text: tailMark.tail });
|
|
25065
|
+
}
|
|
25066
|
+
const out = pieces.map(piece).join("");
|
|
24470
25067
|
return { text: out, ms: now3() - t0 };
|
|
25068
|
+
function piece(p2) {
|
|
25069
|
+
return p2.text !== void 0 ? p2.text : src.slice(p2.from, p2.to);
|
|
25070
|
+
}
|
|
25071
|
+
function withoutWhitespace(s2) {
|
|
25072
|
+
return s2.split(/(<!--[\s\S]*?-->|<[^>]*>)/).map((seg, i2) => i2 % 2 ? seg : seg.replace(/[\t\n\f\r ]+/g, "")).join("");
|
|
25073
|
+
}
|
|
25074
|
+
function endOfBody() {
|
|
25075
|
+
afterBody = pieces.length;
|
|
25076
|
+
tailClean = !!tailMark && tailMark.whole && /^(?:<\/[^>]*>)*$/.test(pieces.slice(tailMark.at).map(piece).join(""));
|
|
25077
|
+
}
|
|
24471
25078
|
function emitNode(n2, parentTag) {
|
|
24472
25079
|
if (n2.nodeType === 3) return emitText(n2, parentTag);
|
|
24473
25080
|
if (n2.nodeType === 8) return emitComment(n2);
|
|
24474
|
-
if (n2.nodeType === 1)
|
|
25081
|
+
if (n2.nodeType === 1) {
|
|
25082
|
+
if (opts.print && opts.print.has(n2)) {
|
|
25083
|
+
printing++;
|
|
25084
|
+
try {
|
|
25085
|
+
emitElement(n2, null);
|
|
25086
|
+
} finally {
|
|
25087
|
+
printing--;
|
|
25088
|
+
}
|
|
25089
|
+
} else {
|
|
25090
|
+
emitElement(n2, locOfClone(n2));
|
|
25091
|
+
}
|
|
25092
|
+
if (n2.localName === "body" && n2.parentNode === clone) endOfBody();
|
|
25093
|
+
}
|
|
24475
25094
|
}
|
|
24476
25095
|
function emitComment(n2) {
|
|
24477
25096
|
const loc = locOfClone(n2);
|
|
@@ -24485,14 +25104,21 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24485
25104
|
opts.corrupted = true;
|
|
24486
25105
|
data = data.slice(1);
|
|
24487
25106
|
}
|
|
24488
|
-
|
|
25107
|
+
const sameContext = loc && loc.parent && textContext(loc.parent.tag) === textContext(parentTag);
|
|
25108
|
+
if (loc && loc.kind === "text" && loc.value === data && loc.from >= 0 && !opts.breakText && sameContext) {
|
|
24489
25109
|
keep2(loc.from, loc.to);
|
|
25110
|
+
if (opts.doubleCopied !== void 0 && data === opts.doubleCopied) keep2(loc.from, loc.to);
|
|
25111
|
+
if (loc.outsideTail) tailMark = { at: pieces.length, tail: loc.outsideTail, whole: true };
|
|
24490
25112
|
return;
|
|
24491
25113
|
}
|
|
24492
|
-
|
|
24493
|
-
|
|
25114
|
+
let owner = null;
|
|
25115
|
+
if (loc && loc.kind === "text" && loc.outsideTail) {
|
|
25116
|
+
const whole = data.endsWith(loc.outsideTail);
|
|
25117
|
+
if (whole) data = data.slice(0, data.length - loc.outsideTail.length);
|
|
25118
|
+
owner = { tail: whole ? loc.outsideTail : "", whole };
|
|
24494
25119
|
}
|
|
24495
25120
|
text(RAW_TEXT.has(parentTag) ? data : escText(data));
|
|
25121
|
+
if (owner) tailMark = { at: pieces.length, ...owner };
|
|
24496
25122
|
}
|
|
24497
25123
|
function emitElement(n2, loc) {
|
|
24498
25124
|
const tag = n2.localName;
|
|
@@ -24536,7 +25162,11 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24536
25162
|
const seen = /* @__PURE__ */ new Set();
|
|
24537
25163
|
let cursor = loc.openFrom;
|
|
24538
25164
|
for (const a of loc.attrs) {
|
|
24539
|
-
if (a.from < 0)
|
|
25165
|
+
if (a.from < 0) {
|
|
25166
|
+
const cur2 = live.get(a.key);
|
|
25167
|
+
if (cur2 && cur2.value === a.value) seen.add(a.key);
|
|
25168
|
+
continue;
|
|
25169
|
+
}
|
|
24540
25170
|
const cur = live.get(a.key);
|
|
24541
25171
|
seen.add(a.key);
|
|
24542
25172
|
if (!cur) {
|
|
@@ -24578,10 +25208,32 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24578
25208
|
if (q2 === "" && rest !== "" && value !== "" && !/[\s"'=<>`]/.test(value)) return name + "=" + esc;
|
|
24579
25209
|
return name + '="' + esc.replace(/"/g, """) + '"';
|
|
24580
25210
|
}
|
|
25211
|
+
function copiedOpen(c2) {
|
|
25212
|
+
if (c2.nodeType !== 1 || printing || opts.print && opts.print.has(c2)) return null;
|
|
25213
|
+
const l = locOfClone(c2);
|
|
25214
|
+
return l && l.kind === "element" && l.located && !l.endTagged && !VOID.has(l.tag) && !opts.breakTags ? l : null;
|
|
25215
|
+
}
|
|
25216
|
+
function openChain(c2) {
|
|
25217
|
+
const l = copiedOpen(c2);
|
|
25218
|
+
if (!l) return null;
|
|
25219
|
+
const kids = liveKids(c2);
|
|
25220
|
+
const inner = kids.length ? openChain(kids[kids.length - 1]) : null;
|
|
25221
|
+
return (inner || []).concat(l.tag);
|
|
25222
|
+
}
|
|
24581
25223
|
function emitChildren(el4, loc, parentTag) {
|
|
24582
25224
|
const C2 = liveKids(el4);
|
|
25225
|
+
let open = null;
|
|
25226
|
+
const closeOpen = (i2, j2) => {
|
|
25227
|
+
if (open && !(j2 >= 0 && open.j >= 0 && j2 === open.j + 1)) text(open.tags.map((t) => "</" + t + ">").join(""));
|
|
25228
|
+
open = null;
|
|
25229
|
+
};
|
|
24583
25230
|
if (!loc) {
|
|
24584
|
-
for (const c2 of C2)
|
|
25231
|
+
for (const c2 of C2) {
|
|
25232
|
+
closeOpen(-1, -1);
|
|
25233
|
+
emitNode(c2, parentTag);
|
|
25234
|
+
const tags = openChain(c2);
|
|
25235
|
+
if (tags) open = { tags, j: -1 };
|
|
25236
|
+
}
|
|
24585
25237
|
return;
|
|
24586
25238
|
}
|
|
24587
25239
|
const S2 = loc.children;
|
|
@@ -24590,6 +25242,35 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24590
25242
|
const l = locOfClone(c2);
|
|
24591
25243
|
return l && l.parent === loc && l.from >= 0 ? sIndex.get(l) : -1;
|
|
24592
25244
|
});
|
|
25245
|
+
const whole = /* @__PURE__ */ new Set();
|
|
25246
|
+
if (!opts.breakText && !opts.breakTags) {
|
|
25247
|
+
const taken = new Set(owned);
|
|
25248
|
+
const free = /* @__PURE__ */ new Map();
|
|
25249
|
+
S2.forEach((s2, j2) => {
|
|
25250
|
+
if (taken.has(j2) || s2.from < 0 || !s2.keys) return;
|
|
25251
|
+
if (!free.has(s2.keys.deep)) free.set(s2.keys.deep, []);
|
|
25252
|
+
free.get(s2.keys.deep).push(j2);
|
|
25253
|
+
});
|
|
25254
|
+
if (free.size) C2.forEach((c2, i2) => {
|
|
25255
|
+
if (owned[i2] >= 0 || locOfClone(c2)) return;
|
|
25256
|
+
const q2 = free.get(keysOfLive(c2, /* @__PURE__ */ new Map()).deep);
|
|
25257
|
+
if (q2 && q2.length) {
|
|
25258
|
+
owned[i2] = q2.shift();
|
|
25259
|
+
whole.add(i2);
|
|
25260
|
+
}
|
|
25261
|
+
});
|
|
25262
|
+
}
|
|
25263
|
+
const emitChild = (c2, i2) => {
|
|
25264
|
+
if (!whole.has(i2)) return emitNode(c2, parentTag);
|
|
25265
|
+
const s2 = S2[owned[i2]];
|
|
25266
|
+
keep2(s2.from, s2.to);
|
|
25267
|
+
if (s2.outsideTail) tailMark = { at: pieces.length, tail: s2.outsideTail, whole: true };
|
|
25268
|
+
};
|
|
25269
|
+
const openOf = (c2, i2) => {
|
|
25270
|
+
if (!whole.has(i2)) return openChain(c2);
|
|
25271
|
+
const s2 = S2[owned[i2]];
|
|
25272
|
+
return s2.kind === "element" && s2.located && !s2.endTagged && !VOID.has(s2.tag) ? [s2.tag] : null;
|
|
25273
|
+
};
|
|
24593
25274
|
const inPlace = new Set(lis(owned));
|
|
24594
25275
|
let cursor = loc.openTo;
|
|
24595
25276
|
let lastS = -1;
|
|
@@ -24603,16 +25284,22 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24603
25284
|
};
|
|
24604
25285
|
for (let i2 = 0; i2 < C2.length; i2++) {
|
|
24605
25286
|
const c2 = C2[i2];
|
|
25287
|
+
const tags = openOf(c2, i2);
|
|
24606
25288
|
if (inPlace.has(i2)) {
|
|
24607
25289
|
const j2 = owned[i2], s2 = S2[j2];
|
|
25290
|
+
closeOpen(i2, j2);
|
|
24608
25291
|
dropTo(j2);
|
|
24609
25292
|
keep2(cursor, s2.from);
|
|
24610
|
-
|
|
25293
|
+
emitChild(c2, i2);
|
|
24611
25294
|
cursor = Math.max(cursor, s2.to);
|
|
24612
25295
|
lastS = j2;
|
|
25296
|
+
open = tags ? { tags, j: j2 } : null;
|
|
24613
25297
|
continue;
|
|
24614
25298
|
}
|
|
24615
|
-
|
|
25299
|
+
const lc = locOfClone(c2);
|
|
25300
|
+
closeOpen(i2, lc && lc.parent === loc ? sIndex.get(lc) : -1);
|
|
25301
|
+
emitChild(c2, i2);
|
|
25302
|
+
open = tags ? { tags, j: -1 } : null;
|
|
24616
25303
|
}
|
|
24617
25304
|
dropTo(S2.length);
|
|
24618
25305
|
keep2(cursor, loc.closeFrom);
|
|
@@ -24650,12 +25337,25 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24650
25337
|
const diff = vDiff(A2.documentElement, B2.documentElement, "html");
|
|
24651
25338
|
const worse = diff ? null : vParseErrors(rendered, sourceErrors);
|
|
24652
25339
|
if (!diff) return worse ? { ok: false, diff: worse } : { ok: true, diff: null, oracle: "today" };
|
|
24653
|
-
if (clone
|
|
24654
|
-
const
|
|
24655
|
-
|
|
25340
|
+
if (clone) {
|
|
25341
|
+
const at3 = [];
|
|
25342
|
+
if (!vDiff(A2.documentElement, clone, "html", at3)) {
|
|
25343
|
+
const w2 = vParseErrors(rendered, sourceErrors);
|
|
25344
|
+
return w2 ? { ok: false, diff: w2 } : { ok: true, diff: null, oracle: "clone", todayDiff: diff };
|
|
25345
|
+
}
|
|
25346
|
+
return { ok: false, diff, at: at3 };
|
|
24656
25347
|
}
|
|
24657
25348
|
return { ok: false, diff };
|
|
24658
25349
|
}
|
|
25350
|
+
function nodeAt(root3, at3) {
|
|
25351
|
+
let n2 = root3;
|
|
25352
|
+
for (const i2 of at3) {
|
|
25353
|
+
const kids = vKids(n2);
|
|
25354
|
+
if (i2 >= kids.length) return null;
|
|
25355
|
+
n2 = kids[i2];
|
|
25356
|
+
}
|
|
25357
|
+
return n2;
|
|
25358
|
+
}
|
|
24659
25359
|
function vParseErrors(rendered, sourceErrors) {
|
|
24660
25360
|
if (!sourceErrors) return null;
|
|
24661
25361
|
const seen = /* @__PURE__ */ new Map();
|
|
@@ -24677,17 +25377,17 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24677
25377
|
}
|
|
24678
25378
|
function vNoscript(a, b, path) {
|
|
24679
25379
|
const P2 = new DOMParser();
|
|
24680
|
-
const
|
|
25380
|
+
const raw = (el4) => {
|
|
24681
25381
|
const kids = Array.from(el4.childNodes);
|
|
24682
25382
|
return kids.length && kids.every((n2) => n2.nodeType === 3) ? kids.map((n2) => n2.data).join("") : el4.innerHTML;
|
|
24683
25383
|
};
|
|
24684
|
-
return vDiff(P2.parseFromString(
|
|
25384
|
+
return vDiff(P2.parseFromString(a.innerHTML, "text/html").body, P2.parseFromString(raw(b), "text/html").body, path + ">#noscript");
|
|
24685
25385
|
}
|
|
24686
25386
|
function vKids(el4) {
|
|
24687
25387
|
const list2 = el4.localName === "template" && el4.content ? el4.content.childNodes : el4.childNodes;
|
|
24688
25388
|
return Array.from(list2).filter((n2) => n2.nodeType === 1 || n2.nodeType === 3 || n2.nodeType === 8);
|
|
24689
25389
|
}
|
|
24690
|
-
function vDiff(a, b, path) {
|
|
25390
|
+
function vDiff(a, b, path, at3 = []) {
|
|
24691
25391
|
if (a.nodeType !== b.nodeType) return path + ": node type " + a.nodeType + " vs " + b.nodeType;
|
|
24692
25392
|
if (a.nodeType === 3 || a.nodeType === 8) return a.data === b.data ? null : path + ": text " + JSON.stringify(a.data.slice(0, 60)) + " vs " + JSON.stringify(b.data.slice(0, 60));
|
|
24693
25393
|
if (a.localName !== b.localName || a.namespaceURI !== b.namespaceURI) return path + ": tag " + a.localName + " vs " + b.localName;
|
|
@@ -24696,16 +25396,20 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24696
25396
|
const ka2 = vKids(a), kb = vKids(b);
|
|
24697
25397
|
if (ka2.length !== kb.length) return path + ": " + ka2.length + " vs " + kb.length + " children";
|
|
24698
25398
|
for (let i2 = 0; i2 < ka2.length; i2++) {
|
|
24699
|
-
|
|
25399
|
+
at3.push(i2);
|
|
25400
|
+
const d = vDiff(ka2[i2], kb[i2], path + ">" + (ka2[i2].localName || "#") + "[" + i2 + "]", at3);
|
|
24700
25401
|
if (d) return d;
|
|
25402
|
+
at3.pop();
|
|
24701
25403
|
}
|
|
24702
25404
|
return null;
|
|
24703
25405
|
}
|
|
24704
|
-
var RAW_TEXT, VOID, XHTML, escText, escAttr, UNIT_SEP, liveAttrsKey, srcAttrsKey, TIERS, DP_CELLS, vAttrs;
|
|
25406
|
+
var RAW_TEXT, RCDATA, textContext, VOID, XHTML, escText, escAttr, UNIT_SEP, liveAttrsKey, srcAttrsKey, TIERS, DP_CELLS, vAttrs;
|
|
24705
25407
|
var init_source_map = __esm({
|
|
24706
25408
|
"src/core/source-map.js"() {
|
|
24707
25409
|
init_parse5_vendor();
|
|
24708
25410
|
RAW_TEXT = /* @__PURE__ */ new Set(["script", "style", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript"]);
|
|
25411
|
+
RCDATA = /* @__PURE__ */ new Set(["textarea", "title"]);
|
|
25412
|
+
textContext = (tag) => RAW_TEXT.has(tag) ? "raw" : RCDATA.has(tag) ? "rcdata" : "normal";
|
|
24709
25413
|
VOID = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
24710
25414
|
XHTML = "http://www.w3.org/1999/xhtml";
|
|
24711
25415
|
escText = (s2) => s2.replace(/&/g, "&").replace(/ /g, " ").replace(/</g, "<").replace(/>/g, ">");
|
|
@@ -24763,68 +25467,111 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24763
25467
|
}
|
|
24764
25468
|
function renderSave(clone, today, opts = {}) {
|
|
24765
25469
|
if (!state.installed) return today;
|
|
24766
|
-
state.
|
|
24767
|
-
|
|
24768
|
-
|
|
24769
|
-
|
|
24770
|
-
|
|
24771
|
-
|
|
25470
|
+
state.lastOutcome = null;
|
|
25471
|
+
const print = /* @__PURE__ */ new Set();
|
|
25472
|
+
let firstDiff = null;
|
|
25473
|
+
for (let round = 0; round <= MAX_PRINT_ROUNDS; round++) {
|
|
25474
|
+
let out;
|
|
25475
|
+
try {
|
|
25476
|
+
out = render(clone, state.map, state.model, originalSnapshotNode, { ...opts, print });
|
|
25477
|
+
} catch (err) {
|
|
25478
|
+
return fallback("render threw: " + (err && err.message ? err.message : err), today);
|
|
25479
|
+
}
|
|
25480
|
+
const v2 = verify(out.text, today, document, clone, state.model.parseErrors);
|
|
25481
|
+
if (v2.ok) {
|
|
25482
|
+
state.lastRenderMs = out.ms;
|
|
25483
|
+
state.lastBytes = out.text.length;
|
|
25484
|
+
state.lastOutcome = print.size ? { text: out.text, scope: "partial", reason: firstDiff, printed: print.size } : { text: out.text, scope: null };
|
|
25485
|
+
return out.text;
|
|
25486
|
+
}
|
|
25487
|
+
if (firstDiff === null) firstDiff = v2.diff;
|
|
25488
|
+
if (!v2.at || !widen(clone, nodeAt(clone, v2.at), print)) return fallback(firstDiff, today);
|
|
25489
|
+
}
|
|
25490
|
+
return fallback(firstDiff, today);
|
|
25491
|
+
}
|
|
25492
|
+
function widen(clone, node, print) {
|
|
25493
|
+
let el4 = node && node.nodeType === 1 ? node : node && node.parentNode;
|
|
25494
|
+
for (let a = el4; a && a !== clone; a = a.parentNode) {
|
|
25495
|
+
if (print.has(a)) {
|
|
25496
|
+
print.delete(a);
|
|
25497
|
+
el4 = a.parentNode;
|
|
25498
|
+
break;
|
|
25499
|
+
}
|
|
24772
25500
|
}
|
|
24773
|
-
|
|
24774
|
-
|
|
24775
|
-
|
|
24776
|
-
|
|
24777
|
-
|
|
25501
|
+
if (!el4 || el4.nodeType !== 1 || el4 === clone) return false;
|
|
25502
|
+
print.add(el4);
|
|
25503
|
+
return true;
|
|
25504
|
+
}
|
|
25505
|
+
function fallback(reason, today) {
|
|
25506
|
+
state.lastOutcome = { text: today, scope: "full", reason };
|
|
25507
|
+
return today;
|
|
24778
25508
|
}
|
|
24779
|
-
function reprint(reason
|
|
25509
|
+
function reprint(reason) {
|
|
24780
25510
|
state.reprints++;
|
|
24781
25511
|
state.lastReprint = reason;
|
|
24782
25512
|
console.warn("clayjs: source map did not verify, saving the full serialization instead:", reason);
|
|
24783
|
-
document.dispatchEvent(new CustomEvent("clay:save-reprinted", { detail: { reason } }));
|
|
24784
|
-
|
|
25513
|
+
document.dispatchEvent(new CustomEvent("clay:save-reprinted", { detail: { reason, scope: "full" } }));
|
|
25514
|
+
}
|
|
25515
|
+
function partialReprint(reason, printed) {
|
|
25516
|
+
state.partialReprints++;
|
|
25517
|
+
state.lastPartialReprint = reason;
|
|
25518
|
+
console.info(`clayjs: source map printed ${printed} element(s) in full to match the page:`, reason);
|
|
25519
|
+
document.dispatchEvent(new CustomEvent("clay:save-reprinted", { detail: { reason, scope: "partial", printed } }));
|
|
24785
25520
|
}
|
|
24786
25521
|
function adopt(bytes) {
|
|
24787
25522
|
if (!state.installed) return;
|
|
25523
|
+
report(bytes);
|
|
24788
25524
|
state.pendingBytes = bytes;
|
|
24789
25525
|
scheduleRefresh();
|
|
24790
25526
|
}
|
|
24791
|
-
function
|
|
25527
|
+
function report(bytes) {
|
|
25528
|
+
const outcome = state.lastOutcome;
|
|
25529
|
+
if (!outcome || outcome.text !== bytes) return;
|
|
25530
|
+
state.lastOutcome = null;
|
|
25531
|
+
state.saves++;
|
|
25532
|
+
if (outcome.scope === "full") reprint(outcome.reason);
|
|
25533
|
+
else if (outcome.scope === "partial") partialReprint(outcome.reason, outcome.printed);
|
|
25534
|
+
}
|
|
25535
|
+
function queueRepair(event) {
|
|
24792
25536
|
if (!state.installed) return;
|
|
25537
|
+
const detail = event && event.detail;
|
|
25538
|
+
if (detail && detail.source === "disk" && typeof detail.html === "string") state.pendingBytes = detail.html;
|
|
24793
25539
|
scheduleRefresh();
|
|
24794
25540
|
}
|
|
24795
25541
|
function scheduleRefresh() {
|
|
24796
25542
|
if (state.refreshQueued) return;
|
|
24797
25543
|
state.refreshQueued = true;
|
|
24798
|
-
|
|
24799
|
-
|
|
24800
|
-
|
|
24801
|
-
|
|
24802
|
-
|
|
24803
|
-
|
|
24804
|
-
|
|
24805
|
-
|
|
24806
|
-
|
|
24807
|
-
|
|
24808
|
-
|
|
24809
|
-
|
|
24810
|
-
m2 = next;
|
|
24811
|
-
} catch (err) {
|
|
24812
|
-
console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:", err);
|
|
24813
|
-
}
|
|
24814
|
-
}
|
|
25544
|
+
if (typeof requestIdleCallback === "function") requestIdleCallback(refreshNow, { timeout: 2e3 });
|
|
25545
|
+
else setTimeout(refreshNow, 0);
|
|
25546
|
+
}
|
|
25547
|
+
function refreshNow() {
|
|
25548
|
+
if (!state.refreshQueued) return;
|
|
25549
|
+
state.refreshQueued = false;
|
|
25550
|
+
if (!state.installed) return;
|
|
25551
|
+
const bytes = state.pendingBytes;
|
|
25552
|
+
state.pendingBytes = null;
|
|
25553
|
+
const t = now2();
|
|
25554
|
+
let m2 = state.model;
|
|
25555
|
+
if (bytes !== null) {
|
|
24815
25556
|
try {
|
|
24816
|
-
const
|
|
24817
|
-
|
|
24818
|
-
|
|
24819
|
-
|
|
24820
|
-
state.refreshes++;
|
|
24821
|
-
state.timing.refresh = now2() - t;
|
|
25557
|
+
const next = model(bytes);
|
|
25558
|
+
const refused = checkSource(next, document);
|
|
25559
|
+
if (refused) throw new Error(refused);
|
|
25560
|
+
m2 = next;
|
|
24822
25561
|
} catch (err) {
|
|
24823
|
-
console.warn("clayjs: source map
|
|
25562
|
+
console.warn("clayjs: source map kept the previous model, the accepted bytes did not model:", err);
|
|
24824
25563
|
}
|
|
24825
|
-
}
|
|
24826
|
-
|
|
24827
|
-
|
|
25564
|
+
}
|
|
25565
|
+
try {
|
|
25566
|
+
const { map, stats } = pairAgainstPage(m2);
|
|
25567
|
+
state.model = m2;
|
|
25568
|
+
state.map = map;
|
|
25569
|
+
state.stats = stats;
|
|
25570
|
+
state.refreshes++;
|
|
25571
|
+
state.timing.refresh = now2() - t;
|
|
25572
|
+
} catch (err) {
|
|
25573
|
+
console.warn("clayjs: source map could not re-pair, continuing on the previous map:", err);
|
|
25574
|
+
}
|
|
24828
25575
|
}
|
|
24829
25576
|
function summary() {
|
|
24830
25577
|
const s2 = state.stats;
|
|
@@ -24840,13 +25587,15 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24840
25587
|
saves: state.saves,
|
|
24841
25588
|
reprints: state.reprints,
|
|
24842
25589
|
lastReprint: state.lastReprint,
|
|
25590
|
+
partialReprints: state.partialReprints,
|
|
25591
|
+
lastPartialReprint: state.lastPartialReprint,
|
|
24843
25592
|
lastRenderMs: state.lastRenderMs,
|
|
24844
25593
|
lastBytes: state.lastBytes,
|
|
24845
25594
|
refreshes: state.refreshes,
|
|
24846
25595
|
timing: state.timing
|
|
24847
25596
|
};
|
|
24848
25597
|
}
|
|
24849
|
-
var state, now2, source, source_default;
|
|
25598
|
+
var state, now2, MAX_PRINT_ROUNDS, source, source_default;
|
|
24850
25599
|
var init_source = __esm({
|
|
24851
25600
|
"src/plugins/source.js"() {
|
|
24852
25601
|
init_source_map();
|
|
@@ -24861,6 +25610,11 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24861
25610
|
saves: 0,
|
|
24862
25611
|
reprints: 0,
|
|
24863
25612
|
lastReprint: null,
|
|
25613
|
+
partialReprints: 0,
|
|
25614
|
+
lastPartialReprint: null,
|
|
25615
|
+
// What the last render produced, so the save the host accepts can be counted and
|
|
25616
|
+
// announced as what it was. Cleared once reported.
|
|
25617
|
+
lastOutcome: null,
|
|
24864
25618
|
lastRenderMs: null,
|
|
24865
25619
|
lastBytes: null,
|
|
24866
25620
|
timing: { fetch: null, model: null, pair: null, refresh: null },
|
|
@@ -24869,11 +25623,15 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24869
25623
|
pendingBytes: null
|
|
24870
25624
|
};
|
|
24871
25625
|
now2 = () => typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
25626
|
+
MAX_PRINT_ROUNDS = 8;
|
|
24872
25627
|
source = {
|
|
24873
25628
|
ready: null,
|
|
24874
25629
|
stats: summary,
|
|
24875
|
-
/** The bytes this module believes are on disk right now. */
|
|
24876
|
-
text: () =>
|
|
25630
|
+
/** The bytes this module believes are on disk right now. A refresh still queued from a save or a disk frame runs first, so this is never the file before that. */
|
|
25631
|
+
text: () => {
|
|
25632
|
+
refreshNow();
|
|
25633
|
+
return state.model ? state.model.src : null;
|
|
25634
|
+
},
|
|
24877
25635
|
/**
|
|
24878
25636
|
* Where a live element is in those bytes: `{ from, to, line, column }`, or null.
|
|
24879
25637
|
*
|
|
@@ -24887,7 +25645,10 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
|
|
|
24887
25645
|
* agent that cannot tell "this element is new" from "this document has no map" will eventually
|
|
24888
25646
|
* write into a file it was never modelling.
|
|
24889
25647
|
*/
|
|
24890
|
-
locate: (node) =>
|
|
25648
|
+
locate: (node) => {
|
|
25649
|
+
refreshNow();
|
|
25650
|
+
return state.installed && node ? locate(node, state.map, state.model) : null;
|
|
25651
|
+
},
|
|
24891
25652
|
/** What did not pair, for working out why a document reprints more than it should. */
|
|
24892
25653
|
unpaired: () => state.stats ? { live: state.stats.unmatchedLive.slice(0, 50), source: state.stats.unmatchedSource.slice(0, 50) } : null
|
|
24893
25654
|
};
|
|
@@ -26014,16 +26775,16 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
26014
26775
|
let n2 = t.tagName;
|
|
26015
26776
|
if (n2 === "INPUT") {
|
|
26016
26777
|
let r = Xt3(t);
|
|
26017
|
-
r === "checkbox" || r === "radio" ? e.checked ? t.setAttribute("checked", "") : t.removeAttribute("checked") : t.setAttribute("value", e.value);
|
|
26778
|
+
r === "checkbox" || r === "radio" ? e.checked ? t.hasAttribute("checked") || t.setAttribute("checked", "") : t.removeAttribute("checked") : e.value !== (t.getAttribute("value") ?? "") && t.setAttribute("value", e.value);
|
|
26018
26779
|
return;
|
|
26019
26780
|
}
|
|
26020
26781
|
if (n2 === "TEXTAREA") {
|
|
26021
|
-
t.textContent = e.value, t.removeAttribute("data-value");
|
|
26782
|
+
t.textContent !== e.value && (t.textContent = e.value), t.removeAttribute("data-value");
|
|
26022
26783
|
return;
|
|
26023
26784
|
}
|
|
26024
26785
|
if (n2 === "SELECT") {
|
|
26025
26786
|
let r = t.options, s2 = e.options;
|
|
26026
|
-
for (let i2 = 0; i2 < r.length; i2++) s2[i2] && s2[i2].selected ? r[i2].setAttribute("selected", "") : r[i2].removeAttribute("selected");
|
|
26787
|
+
for (let i2 = 0; i2 < r.length; i2++) s2[i2] && s2[i2].selected ? r[i2].hasAttribute("selected") || r[i2].setAttribute("selected", "") : r[i2].removeAttribute("selected");
|
|
26027
26788
|
}
|
|
26028
26789
|
}
|
|
26029
26790
|
function At2(t) {
|
|
@@ -27335,9 +28096,9 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
27335
28096
|
cleanContentClone: () => cleanContentClone,
|
|
27336
28097
|
createContentView: () => createContentView,
|
|
27337
28098
|
default: () => dom_helpers_default,
|
|
27338
|
-
init: () =>
|
|
28099
|
+
init: () => init19
|
|
27339
28100
|
});
|
|
27340
|
-
function
|
|
28101
|
+
function init19() {
|
|
27341
28102
|
window.clay = window.clay || {};
|
|
27342
28103
|
window.clay.dom = Object.assign(window.clay.dom || {}, { createContentView, cleanContentClone });
|
|
27343
28104
|
if (HTMLElement.prototype.hasOwnProperty("nearest")) {
|
|
@@ -27488,8 +28249,8 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
27488
28249
|
init_nearest();
|
|
27489
28250
|
init_pipe();
|
|
27490
28251
|
init_content_dom();
|
|
27491
|
-
|
|
27492
|
-
dom_helpers_default =
|
|
28252
|
+
init19();
|
|
28253
|
+
dom_helpers_default = init19;
|
|
27493
28254
|
}
|
|
27494
28255
|
});
|
|
27495
28256
|
|
|
@@ -27505,12 +28266,12 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
27505
28266
|
timeoutId = setTimeout(() => {
|
|
27506
28267
|
const waiting = pending2;
|
|
27507
28268
|
pending2 = [];
|
|
27508
|
-
|
|
28269
|
+
settle2(callback, ctx, args, waiting);
|
|
27509
28270
|
}, delay);
|
|
27510
28271
|
});
|
|
27511
28272
|
};
|
|
27512
28273
|
}
|
|
27513
|
-
function
|
|
28274
|
+
function settle2(callback, ctx, args, waiting) {
|
|
27514
28275
|
let result2;
|
|
27515
28276
|
try {
|
|
27516
28277
|
result2 = callback.apply(ctx, args);
|
|
@@ -27551,13 +28312,13 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
27551
28312
|
|
|
27552
28313
|
// src/utils/copy-to-clipboard.js
|
|
27553
28314
|
function copyToClipboard(text) {
|
|
27554
|
-
const
|
|
27555
|
-
|
|
27556
|
-
|
|
27557
|
-
|
|
27558
|
-
document.body.appendChild(
|
|
27559
|
-
|
|
27560
|
-
|
|
28315
|
+
const textarea2 = document.createElement("textarea");
|
|
28316
|
+
textarea2.value = text;
|
|
28317
|
+
textarea2.style.position = "fixed";
|
|
28318
|
+
textarea2.style.opacity = "0";
|
|
28319
|
+
document.body.appendChild(textarea2);
|
|
28320
|
+
textarea2.select();
|
|
28321
|
+
textarea2.setSelectionRange(0, 99999);
|
|
27561
28322
|
try {
|
|
27562
28323
|
const successful = document.execCommand("copy");
|
|
27563
28324
|
if (successful) {
|
|
@@ -27568,7 +28329,7 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
27568
28329
|
} catch (err) {
|
|
27569
28330
|
console.error("Unable to copy:", err);
|
|
27570
28331
|
}
|
|
27571
|
-
document.body.removeChild(
|
|
28332
|
+
document.body.removeChild(textarea2);
|
|
27572
28333
|
}
|
|
27573
28334
|
var copy_to_clipboard_default;
|
|
27574
28335
|
var init_copy_to_clipboard = __esm({
|
|
@@ -28404,7 +29165,7 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
28404
29165
|
for (const id in triggerMap) validateModalPresence(id);
|
|
28405
29166
|
return true;
|
|
28406
29167
|
};
|
|
28407
|
-
const
|
|
29168
|
+
const init29 = (config) => {
|
|
28408
29169
|
const options = Object.assign({}, { openTrigger: "data-micromodal-trigger" }, config);
|
|
28409
29170
|
const triggers = [...document.querySelectorAll(`[${options.openTrigger}]`)];
|
|
28410
29171
|
const triggerMap = generateTriggerMap(triggers, options.openTrigger);
|
|
@@ -28429,7 +29190,7 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
28429
29190
|
targetModal ? activeModal.closeModalById(targetModal) : activeModal.closeModal();
|
|
28430
29191
|
activeModal = null;
|
|
28431
29192
|
};
|
|
28432
|
-
return { init:
|
|
29193
|
+
return { init: init29, show: show3, close };
|
|
28433
29194
|
})();
|
|
28434
29195
|
modalCss = `<style class="micromodal-css">
|
|
28435
29196
|
.micromodal {
|
|
@@ -29068,7 +29829,7 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29068
29829
|
modal_default.open();
|
|
29069
29830
|
return promise;
|
|
29070
29831
|
}
|
|
29071
|
-
function
|
|
29832
|
+
function init20() {
|
|
29072
29833
|
dom_ready_default(() => {
|
|
29073
29834
|
const micromodalParentElem = document.querySelector(".micromodal-parent");
|
|
29074
29835
|
if (micromodalParentElem) {
|
|
@@ -29086,7 +29847,7 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29086
29847
|
init_copy_to_clipboard();
|
|
29087
29848
|
CLOSE_BUTTON_SVG = `<svg viewBox="0 0 134 134" fill="none" xmlns="http://www.w3.org/2000/svg"><path class="micromodal__close-bg" d="M132 132.5 1 1.5h131v131Z" /><path class="micromodal__close-x" fill-rule="evenodd" clip-rule="evenodd" d="M0 0h3v1.5h1.5V3H6v1.5h1.5V6H9v1.5h1.5V9H12v1.5h1.5V12H15v1.5h1.5V15H18v1.5h1.5V18H21v1.5h1.5V21H24v1.5h1.5V24H27v1.5h1.5V27H30v1.5h1.5V30H33v1.5h1.5V33H36v1.5h1.5V36H39v1.5h1.5V39H42v1.5h1.5V42H45v1.5h1.5V45H48v1.5h1.5V48H51v1.5h1.5V51H54v1.5h1.5V54H57v1.5h1.5V57H60v1.5h1.5V60H63v1.5h1.5V63H66v1.5h1.5V66H69v1.5h1.5V69H72v1.5h1.5V72H75v1.5h1.5V75H78v1.5h1.5V78H81v1.5h1.5V81H84v1.5h1.5V84H87v1.5h1.5V87H90v1.5h1.5V90H93v1.5h1.5V93H96v1.5h1.5V96H99v1.5h1.5V99h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v1.5h1.5v3h-3V132H129v-1.5h-1.5V129H126v-1.5h-1.5V126H123v-1.5h-1.5V123H120v-1.5h-1.5V120H117v-1.5h-1.5V117H114v-1.5h-1.5V114H111v-1.5h-1.5V111H108v-1.5h-1.5V108H105v-1.5h-1.5V105H102v-1.5h-1.5V102H99v-1.5h-1.5V99H96v-1.5h-1.5V96H93v-1.5h-1.5V93H90v-1.5h-1.5V90H87v-1.5h-1.5V87H84v-1.5h-1.5V84H81v-1.5h-1.5V81H78v-1.5h-1.5V78H75v-1.5h-1.5V75H72v-1.5h-1.5V72H69v-1.5h-1.5V69H66v-1.5h-1.5V66H63v-1.5h-1.5V63H60v-1.5h-1.5V60H57v-1.5h-1.5V57H54v-1.5h-1.5V54H51v-1.5h-1.5V51H48v-1.5h-1.5V48H45v-1.5h-1.5V45H42v-1.5h-1.5V42H39v-1.5h-1.5V39H36v-1.5h-1.5V36H33v-1.5h-1.5V33H30v-1.5h-1.5V30H27v-1.5h-1.5V27H24v-1.5h-1.5V24H21v-1.5h-1.5V21H18v-1.5h-1.5V18H15v-1.5h-1.5V15H12v-1.5h-1.5V12H9v-1.5H7.5V9H6V7.5H4.5V6H3V4.5H1.5V3H0V0ZM108.8 22h5.2v5.1h-2.6v2.6H109v2.6h-2.6v2.6h-2.6v2.5h-2.6v5.2h2.6V45h2.6v2.6h2.6v2.6h2.5v2.6h2.6V58h-5.1v-2.6h-2.6V53h-2.6v-2.6h-2.6v-2.6h-2.5v-2.6h-5.2v2.6H91v2.6h-2.6v2.6h-2.6v2.5h-2.6V58H78v-5.1h2.6v-2.6H83v-2.6h2.6v-2.6h2.6v-2.5h2.6v-5.2h-2.6V35h-2.6v-2.6h-2.6v-2.6h-2.5v-2.6H78V22h5.2v2.6h2.5V27h2.6v2.6h2.6v2.6h2.5v2.6h5.2v-2.6h2.5v-2.6h2.6v-2.6h2.6v-2.5h2.5V22Z" /></svg>`;
|
|
29088
29849
|
CONFIRM_BUTTON_SVG = `<div style="width: 28px;"><svg viewBox="0 0 60 33" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M34.5 0.75H43.5V5.25H49V9.75H54.5V14.25H60V18.75H54.5V23.25H49V27.75H43.5V32.25H34.5V27.75H40V23.25H45.5V18.75H0V14.25H45.5V9.75H40V5.25H34.5V0.75Z" fill="white"/></svg></div>`;
|
|
29089
|
-
|
|
29850
|
+
init20();
|
|
29090
29851
|
}
|
|
29091
29852
|
});
|
|
29092
29853
|
|
|
@@ -29193,7 +29954,7 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29193
29954
|
var options_exports = {};
|
|
29194
29955
|
__export(options_exports, {
|
|
29195
29956
|
default: () => options_default,
|
|
29196
|
-
init: () =>
|
|
29957
|
+
init: () => init21,
|
|
29197
29958
|
parseOptionAttribute: () => parseOptionAttribute
|
|
29198
29959
|
});
|
|
29199
29960
|
function parseOptionAttribute(attrName, attrValue) {
|
|
@@ -29210,7 +29971,7 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29210
29971
|
const values = rawValue.split("|");
|
|
29211
29972
|
return { name, rawValue, values, kind: match.kind, prefix: match.prefix, negated: match.kind === "show-not" };
|
|
29212
29973
|
}
|
|
29213
|
-
function
|
|
29974
|
+
function init21() {
|
|
29214
29975
|
optionVisibility.start();
|
|
29215
29976
|
}
|
|
29216
29977
|
var STYLE_NAME, OPTION_PREFIXES, optionVisibility, options_default;
|
|
@@ -29344,12 +30105,12 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29344
30105
|
};
|
|
29345
30106
|
window.clay.optionVisibility = optionVisibility;
|
|
29346
30107
|
options_default = optionVisibility;
|
|
29347
|
-
|
|
30108
|
+
init21();
|
|
29348
30109
|
}
|
|
29349
30110
|
});
|
|
29350
30111
|
|
|
29351
30112
|
// src/events/onclickaway.js
|
|
29352
|
-
function
|
|
30113
|
+
function init22() {
|
|
29353
30114
|
document.addEventListener("click", function(event) {
|
|
29354
30115
|
const elementsWithOnClickAway = document.querySelectorAll("[onclickaway]");
|
|
29355
30116
|
elementsWithOnClickAway.forEach((element) => {
|
|
@@ -29370,7 +30131,7 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29370
30131
|
});
|
|
29371
30132
|
|
|
29372
30133
|
// src/events/onclickchildren.js
|
|
29373
|
-
function
|
|
30134
|
+
function init23() {
|
|
29374
30135
|
document.addEventListener("click", function(event) {
|
|
29375
30136
|
const parent = event.target.closest("[onclickchildren]");
|
|
29376
30137
|
if (parent && event.target !== parent) {
|
|
@@ -29385,7 +30146,7 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29385
30146
|
});
|
|
29386
30147
|
|
|
29387
30148
|
// src/events/onclone.js
|
|
29388
|
-
function
|
|
30149
|
+
function init24() {
|
|
29389
30150
|
if (Node.prototype.__hyperclayOnclone) {
|
|
29390
30151
|
return;
|
|
29391
30152
|
}
|
|
@@ -29438,7 +30199,7 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29438
30199
|
console.error("Error in onmutation execution:", error);
|
|
29439
30200
|
}
|
|
29440
30201
|
}
|
|
29441
|
-
function
|
|
30202
|
+
function init25() {
|
|
29442
30203
|
mutation_default.onAnyChange({ require: "observed" }, (changes2) => {
|
|
29443
30204
|
const toFire = /* @__PURE__ */ new Set();
|
|
29444
30205
|
for (const change of changes2) {
|
|
@@ -29458,7 +30219,7 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29458
30219
|
});
|
|
29459
30220
|
|
|
29460
30221
|
// src/events/onpagemutation.js
|
|
29461
|
-
function
|
|
30222
|
+
function init26() {
|
|
29462
30223
|
const executeGlobalMutation = async (element) => {
|
|
29463
30224
|
try {
|
|
29464
30225
|
const code = element.getAttribute("onglobalmutation") || element.getAttribute("onpagemutation");
|
|
@@ -29498,7 +30259,7 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29498
30259
|
});
|
|
29499
30260
|
|
|
29500
30261
|
// src/events/onrender.js
|
|
29501
|
-
function
|
|
30262
|
+
function init27() {
|
|
29502
30263
|
const executeRender = async (element) => {
|
|
29503
30264
|
try {
|
|
29504
30265
|
const code = element.getAttribute("onrender");
|
|
@@ -29531,15 +30292,15 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29531
30292
|
var events_exports = {};
|
|
29532
30293
|
__export(events_exports, {
|
|
29533
30294
|
default: () => events_default,
|
|
29534
|
-
init: () =>
|
|
30295
|
+
init: () => init28
|
|
29535
30296
|
});
|
|
29536
|
-
function
|
|
29537
|
-
init21();
|
|
30297
|
+
function init28() {
|
|
29538
30298
|
init22();
|
|
29539
30299
|
init23();
|
|
29540
30300
|
init24();
|
|
29541
30301
|
init25();
|
|
29542
30302
|
init26();
|
|
30303
|
+
init27();
|
|
29543
30304
|
}
|
|
29544
30305
|
var events_default;
|
|
29545
30306
|
var init_events = __esm({
|
|
@@ -29550,8 +30311,8 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29550
30311
|
init_onmutation();
|
|
29551
30312
|
init_onpagemutation();
|
|
29552
30313
|
init_onrender();
|
|
29553
|
-
|
|
29554
|
-
events_default =
|
|
30314
|
+
init28();
|
|
30315
|
+
events_default = init28;
|
|
29555
30316
|
}
|
|
29556
30317
|
});
|
|
29557
30318
|
|
|
@@ -29600,6 +30361,9 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29600
30361
|
// superset of the cms's, so the plugin is present exactly when it can be used.
|
|
29601
30362
|
upload: { path: "plugins/upload.js", editOnly: true, default: false },
|
|
29602
30363
|
wire: { path: "plugins/wire.js", editOnly: false, default: false },
|
|
30364
|
+
// Edit mode only: the AI comment box is an editing gesture, and the plugin is
|
|
30365
|
+
// dormant anyway on any host that does not list a ready `ai-edit` helper.
|
|
30366
|
+
"ai-edit": { path: "plugins/ai-edit.js", editOnly: true, default: false },
|
|
29603
30367
|
demo: { path: "plugins/demo.js", editOnly: false, default: false },
|
|
29604
30368
|
// Saves the file's own bytes back instead of a fresh serialization of the DOM.
|
|
29605
30369
|
// editOnly because a page that cannot save has nothing to preserve. On by default
|
|
@@ -29638,11 +30402,12 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29638
30402
|
"vendor/quickcrop.vendor.js": () => Promise.resolve().then(() => (init_quickcrop_vendor(), quickcrop_vendor_exports)),
|
|
29639
30403
|
"plugins/upload.js": () => Promise.resolve().then(() => (init_upload(), upload_exports)),
|
|
29640
30404
|
"plugins/wire.js": () => Promise.resolve().then(() => (init_wire(), wire_exports)),
|
|
30405
|
+
"plugins/ai-edit.js": () => Promise.resolve().then(() => (init_ai_edit(), ai_edit_exports)),
|
|
29641
30406
|
"plugins/demo.js": () => Promise.resolve().then(() => (init_demo(), demo_exports)),
|
|
29642
30407
|
"plugins/source.js": () => Promise.resolve().then(() => (init_source(), source_exports))
|
|
29643
30408
|
};
|
|
29644
|
-
var PLUGIN_ORDER = ["richclay", "indicator", "sortable", "undo", "quickcrop", "upload", "cms", "sync", "wire", "demo", "source"];
|
|
29645
|
-
var IMPLIES = { cms: ["quickcrop", "upload"] };
|
|
30409
|
+
var PLUGIN_ORDER = ["richclay", "indicator", "sortable", "undo", "quickcrop", "upload", "cms", "sync", "wire", "ai-edit", "demo", "source"];
|
|
30410
|
+
var IMPLIES = { cms: ["quickcrop", "upload"], "ai-edit": ["wire"] };
|
|
29646
30411
|
function parseCsv(params, key, enabled, apply) {
|
|
29647
30412
|
const raw = params.get(key);
|
|
29648
30413
|
if (!raw) return;
|
|
@@ -29754,6 +30519,8 @@ ${t}` : `"use strict"; return (${t});`;
|
|
|
29754
30519
|
clay4.upload = mod.upload || mod.default;
|
|
29755
30520
|
} else if (path === "plugins/wire.js") {
|
|
29756
30521
|
clay4.wire = mod.wire || mod.default;
|
|
30522
|
+
} else if (path === "plugins/ai-edit.js") {
|
|
30523
|
+
clay4.aiEdit = mod.aiEdit || mod.default;
|
|
29757
30524
|
} else if (path === "plugins/demo.js") {
|
|
29758
30525
|
clay4.demo = mod.demo;
|
|
29759
30526
|
} else if (path === "vendor/richclay.vendor.js") {
|