@panphora/clayjs 1.25.0 → 1.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +1 -1
- package/dist/clay-dom.js +1 -1
- package/dist/clay-events.js +1 -1
- package/dist/clay-internals.js +1 -1
- package/dist/clay-options.js +1 -1
- package/dist/clay-router.js +1 -1
- package/dist/clay-ui.js +1 -1
- package/dist/clay-utils.js +1 -1
- package/dist/clay.js +1 -1
- package/dist/clay.standalone.js +4432 -3831
- package/dist/m/attrs/{save-freeze-MH3AOD56.js → save-freeze-PUYX32AK.js} +1 -1
- package/dist/m/{c-XHZIKRCV.js → c-2A2ATCIH.js} +1 -1
- package/dist/m/{c-BOMQIQ3V.js → c-2EFMJYGJ.js} +1 -1
- package/dist/m/{c-JD2VFAYG.js → c-2GB34XL4.js} +2 -2
- package/dist/m/{c-CITLTVQ4.js → c-2TJCFPX4.js} +1 -1
- package/dist/m/c-33SS5A4Y.js +1 -0
- package/dist/m/{c-V2FPBRO6.js → c-34J5HC7N.js} +1 -1
- package/dist/m/{c-ZEA3DCG3.js → c-3AAQJAKJ.js} +1 -1
- package/dist/m/c-3F3AADKG.js +1 -0
- package/dist/m/{c-GDNZEOOZ.js → c-3WX5FABT.js} +1 -1
- package/dist/m/{c-QWB53KRW.js → c-3XNTQQEJ.js} +1 -1
- package/dist/m/{c-AI3H6ETU.js → c-3Y234AUB.js} +2 -2
- package/dist/m/{c-GEAG5XAK.js → c-42RLKGEY.js} +1 -1
- package/dist/m/{c-XQTERKQA.js → c-44WITKWQ.js} +1 -1
- package/dist/m/c-47M4QHCK.js +1 -0
- package/dist/m/{c-UOUUI265.js → c-4M2T676V.js} +1 -1
- package/dist/m/{c-3E2IK5HU.js → c-4NAYDOWH.js} +1 -1
- package/dist/m/{c-TLQINES7.js → c-4OZZ7ENT.js} +2 -2
- package/dist/m/{c-QDVG4NAZ.js → c-5IIEOPIV.js} +1 -1
- package/dist/m/{c-4Q6QIODW.js → c-755ZOHOM.js} +1 -1
- package/dist/m/c-7Q4XYDF4.js +1 -0
- package/dist/m/c-7RHOMAMR.js +1 -0
- package/dist/m/{c-BCWYEG6P.js → c-7Z2625LX.js} +1 -1
- package/dist/m/{c-C6YZNU6E.js → c-A3OKSYRI.js} +1 -1
- package/dist/m/{c-RGAALCDU.js → c-A5IYL7JI.js} +1 -1
- package/dist/m/c-A5LASUEZ.js +1 -0
- package/dist/m/c-AQVQKFKB.js +1 -0
- package/dist/m/{c-IESDKFO6.js → c-ASGHHLFX.js} +1 -1
- package/dist/m/c-ASMLERFA.js +7 -0
- package/dist/m/{c-ORLPQFNU.js → c-AZM34SPO.js} +1 -1
- package/dist/m/{c-TCFVG3I4.js → c-BHLYQGTA.js} +1 -1
- package/dist/m/{c-ZORVIXUR.js → c-C27EVUQ6.js} +1 -1
- package/dist/m/{c-SUAC5RSG.js → c-C5UGNOC2.js} +1 -1
- package/dist/m/c-C6DXZIXD.js +1 -0
- package/dist/m/{c-WSTUCBHV.js → c-CPRGR2II.js} +1 -1
- package/dist/m/{c-NFQFV7OP.js → c-D2OPWOWO.js} +1 -1
- package/dist/m/{c-PRZNJUYZ.js → c-D4N4UJCQ.js} +2 -2
- package/dist/m/{c-D62HRSZK.js → c-DAUQ6JZ3.js} +1 -1
- package/dist/m/{c-5PZYDWTW.js → c-DDCYVLGG.js} +1 -1
- package/dist/m/{c-FBOO2UY3.js → c-DVMDYRAE.js} +1 -1
- package/dist/m/{c-WGQVSKKC.js → c-DYTBSJBI.js} +1 -1
- package/dist/m/{c-O2QZDVZ2.js → c-EEWPNUM2.js} +1 -1
- package/dist/m/{c-MFB74XVN.js → c-EHAR4RJJ.js} +2 -2
- package/dist/m/c-EIDZHQHZ.js +1 -0
- package/dist/m/c-ELXMSEN5.js +1 -0
- package/dist/m/c-FC5RUFPR.js +1 -0
- package/dist/m/{c-V4B3RUWB.js → c-GFASNR55.js} +1 -1
- package/dist/m/{c-4AE2A2LK.js → c-GNFDX6SU.js} +1 -1
- package/dist/m/{c-UD4VDBGJ.js → c-H3M6UDNV.js} +1 -1
- package/dist/m/{c-MUM53J5J.js → c-H4M2T4A6.js} +1 -1
- package/dist/m/{c-U7F66I64.js → c-HYNM5U6B.js} +1 -1
- package/dist/m/c-J2YYLEVM.js +1 -0
- package/dist/m/c-J2ZW4HMR.js +1 -0
- package/dist/m/{c-WCG6AKA7.js → c-JC4RZW4E.js} +1 -1
- package/dist/m/c-K2ZHQMPF.js +1 -0
- package/dist/m/{c-Z2OZFX3N.js → c-L6KVXPBO.js} +1 -1
- package/dist/m/{c-JWW6BHWD.js → c-LUBZU4AZ.js} +4 -4
- package/dist/m/{c-SEVOS4UE.js → c-LYNLY3MR.js} +1 -1
- package/dist/m/{c-NADLYVAH.js → c-MHTO3QAD.js} +1 -1
- package/dist/m/{c-SFYTKRU7.js → c-MKAUC6DB.js} +1 -1
- package/dist/m/c-MLMJUNRV.js +1 -0
- package/dist/m/{c-WDFQ7PBU.js → c-MMEVDN6D.js} +1 -1
- package/dist/m/{c-KYTVZT4D.js → c-NW4ZFKCY.js} +1 -1
- package/dist/m/{c-YFO6ZJLQ.js → c-O3DPFZCE.js} +1 -1
- package/dist/m/c-O4YIDULY.js +1 -0
- package/dist/m/c-OZOACVUD.js +1 -0
- package/dist/m/{c-MV7TEUTD.js → c-OZVK3TFI.js} +1 -1
- package/dist/m/c-PP3CUF3U.js +1 -0
- package/dist/m/{c-GY4BREDT.js → c-QL4NYM2L.js} +1 -1
- package/dist/m/c-RES2S5Q3.js +1 -0
- package/dist/m/c-RFGELYEU.js +2 -0
- package/dist/m/c-RGFPLQGV.js +1 -0
- package/dist/m/{c-FKTALXNV.js → c-STAPQ2X6.js} +1 -1
- package/dist/m/c-SYVF6ZMF.js +1 -0
- package/dist/m/{c-X3V4RWMA.js → c-T5IWJOMW.js} +1 -1
- package/dist/m/{c-DT7E76Z2.js → c-T7LOTEWO.js} +1 -1
- package/dist/m/{c-SFZRY6RT.js → c-TWB5ZQU4.js} +1 -1
- package/dist/m/c-U35T5NAY.js +1 -0
- package/dist/m/c-UW6MMZ4V.js +1 -0
- package/dist/m/c-VGG3UR7I.js +1 -0
- package/dist/m/c-VU4WEWPH.js +4 -0
- package/dist/m/{c-5Q5XBN56.js → c-W7LWCJHD.js} +1 -1
- package/dist/m/c-WOJ2RTV4.js +1 -0
- package/dist/m/{c-ZJG6C2WL.js → c-WOWGGNCJ.js} +1 -1
- package/dist/m/{c-SXZYVXD6.js → c-XCOQNISP.js} +1 -1
- package/dist/m/{c-IL5IVTOG.js → c-XS7G6U3Z.js} +1 -1
- package/dist/m/{c-HGG7M2S3.js → c-Y3J5LDKB.js} +1 -1
- package/dist/m/{c-JB5YU57S.js → c-Y3MPVURA.js} +1 -1
- package/dist/m/c-Y6HH7LTM.js +1 -0
- package/dist/m/{c-52OC3OH3.js → c-YRDKVEGR.js} +1 -1
- package/dist/m/{c-WVCT3ITX.js → c-YZGWSCMT.js} +1 -1
- package/dist/m/{c-YX2MC7YL.js → c-ZJ7726FO.js} +1 -1
- package/dist/m/core/{admin-attrs-ZI6K6UGM.js → admin-attrs-43JBA6JB.js} +1 -1
- package/dist/m/core/{autosave-BSM2ABJL.js → autosave-HD7Y7UNV.js} +1 -1
- package/dist/m/core/{conflict-notice-7EQLDYPA.js → conflict-notice-Y2NTMDGJ.js} +1 -1
- package/dist/m/core/{persist-2SZO3PCE.js → persist-MX3VYVBN.js} +1 -1
- package/dist/m/core/{save-K6Q47J2X.js → save-JZ7R4ET2.js} +1 -1
- package/dist/m/core/{save-core-U3Z44XBO.js → save-core-I4N6S4ED.js} +1 -1
- package/dist/m/core/{site-edits-CFMF6GHD.js → site-edits-TIJDPG6H.js} +1 -1
- package/dist/m/core/{snapshot-PWCHYFL6.js → snapshot-N5MKDGNI.js} +1 -1
- package/dist/m/core/{unsaved-warning-2WRZLJH5.js → unsaved-warning-BP6ZY3PG.js} +1 -1
- package/dist/m/internals/{index-FSLC4M7J.js → index-3LAVREAU.js} +1 -1
- package/dist/m/{loader-RC54UV7H.js → loader-7ORQVRCK.js} +1 -1
- package/dist/m/manifest-A27A4278.js +1 -0
- package/dist/m/manifest-edit-E8A61EB4.js +1 -0
- package/dist/m/manifest.json +1099 -1039
- package/dist/m/page/{editor-PKSPJ2XJ.js → editor-HS2CAV3W.js} +5 -5
- package/dist/m/plugins/{ai-edit-3LG6MGS3.js → ai-edit-WDV2GLDU.js} +2 -2
- package/dist/m/plugins/{cms-T2HLI7JG.js → cms-4KET6RZT.js} +9 -9
- package/dist/m/plugins/{derive-7DR5TUDH.js → derive-R4USHZ7P.js} +1 -1
- package/dist/m/plugins/{indicator-CTKX4EY7.js → indicator-OLPZ4WFI.js} +1 -1
- package/dist/m/plugins/{live-IFLL6YN5.js → live-CO4VJS46.js} +1 -1
- package/dist/m/plugins/{menu-YJZ3JWBC.js → menu-ESEFQARM.js} +1 -1
- package/dist/m/plugins/{page-GTDPYGE4.js → page-L3VKIQU2.js} +2 -2
- package/dist/m/plugins/{page-view-NMCCU6MF.js → page-view-6KNTXABH.js} +1 -1
- package/dist/m/plugins/{people-6WIWCZEG.js → people-EBWE337I.js} +1 -1
- package/dist/m/plugins/quickcrop-VNRXGRPC.js +26 -0
- package/dist/m/plugins/{richclay-L3BZMX4I.js → richclay-V6WKJTUF.js} +17 -17
- package/dist/m/plugins/sortable-BAG3MSWS.js +1 -0
- package/dist/m/plugins/{source-7LSGOV46.js → source-OYHDXKTB.js} +1 -1
- package/dist/m/plugins/undo-WUK2NLBA.js +1 -0
- package/dist/m/plugins/{upgrade-MMPZUCDM.js → upgrade-SZQJYEQQ.js} +1 -1
- package/dist/m/plugins/{visitor-drafts-V5YB7XDH.js → visitor-drafts-ZE6PCAFP.js} +2 -2
- package/dist/m/plugins/{visitor-menu-QDV2MYJN.js → visitor-menu-5XY57JQA.js} +1 -1
- package/dist/m/plugins/{wire-3YGUO3GE.js → wire-S5ATC4QI.js} +1 -1
- package/dist/m/reader-core-AHOAP5DH.js +77 -0
- package/dist/m/sync/{live-sync-XMXXZS3G.js → live-sync-DX4K5GDB.js} +1 -1
- package/dist/m/ui/index-G7ZJXNMG.js +1 -0
- package/dist/m/vendor/{sap-core.vendor-JANUQULT.js → sap-core.vendor-5TWOJYVM.js} +4 -4
- package/dist/offline-manifest.json +707 -677
- package/dist/server/core.cjs +4245 -2614
- package/dist/server/markdown.cjs +1 -0
- package/dist/server/markdown.mjs +7 -0
- package/docs/guide.md +26 -37
- package/entries/clay-data.js +1 -1
- package/entries/sap.js +5 -5
- package/package.json +6 -2
- package/packed-contract.json +3 -0
- package/src/attrs/save-freeze.js +1 -1
- package/src/core/admin-contenteditable.js +1 -1
- package/src/core/admin-inputs.js +1 -1
- package/src/core/admin-onclick.js +1 -1
- package/src/core/admin-resources.js +5 -2
- package/src/core/conflict-notice-ui.js +59 -34
- package/src/core/save.js +9 -9
- package/src/core/snapshot.js +56 -43
- package/src/core/stale-host-notice.js +20 -7
- package/src/page/editor.js +10 -4
- package/src/page/import-markdown.js +22 -8
- package/src/page/save-projection.js +1 -1
- package/src/plugins/quickcrop.js +128 -69
- package/src/plugins/sortable.js +25 -9
- package/src/server/markdown/index.js +23 -0
- package/src/sync/conflicts.js +3 -1
- package/src/sync/data-guard-notice.js +137 -18
- package/src/ui/bevel-controls.js +4 -1
- package/src/ui/dialogs.js +11 -7
- package/src/ui/modal.js +9 -7
- package/src/ui/toast.js +67 -32
- package/src/vendor/hyper-html-api-data.vendor.js +1 -1
- package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
- package/src/vendor/hyper-undo.vendor.js +1 -1
- package/src/vendor/hypercms.vendor.js +7 -7
- package/src/vendor/richclay.vendor.js +16 -16
- package/src/vendor/sap-core.vendor.js +4 -4
- package/tool-generation/context.md +69 -0
- package/tool-generation/system.md +1 -1
- package/dist/m/c-277QP5ET.js +0 -1
- package/dist/m/c-5SZ6KFR5.js +0 -1
- package/dist/m/c-CU33V6RW.js +0 -4
- package/dist/m/c-CVSWLX3X.js +0 -1
- package/dist/m/c-DXPOFLEJ.js +0 -1
- package/dist/m/c-EODTTNVA.js +0 -1
- package/dist/m/c-ESK4S67I.js +0 -1
- package/dist/m/c-FDWR3FL7.js +0 -1
- package/dist/m/c-FJDTDGDA.js +0 -1
- package/dist/m/c-FYDKYW6E.js +0 -1
- package/dist/m/c-HKSLOVU4.js +0 -1
- package/dist/m/c-IJHF4IO6.js +0 -1
- package/dist/m/c-IUL7PU4P.js +0 -1
- package/dist/m/c-K4M76VPM.js +0 -7
- package/dist/m/c-M7ITYKMF.js +0 -1
- package/dist/m/c-MR75YPRT.js +0 -1
- package/dist/m/c-NHXOBD6A.js +0 -1
- package/dist/m/c-NVU3DORS.js +0 -1
- package/dist/m/c-PNZIJFG7.js +0 -1
- package/dist/m/c-RHPHMTF2.js +0 -2
- package/dist/m/c-RWJ3OSCP.js +0 -1
- package/dist/m/c-SGG6MUXW.js +0 -1
- package/dist/m/c-SXNSSHPP.js +0 -1
- package/dist/m/c-TFLRT5JX.js +0 -1
- package/dist/m/c-U65PREMC.js +0 -1
- package/dist/m/c-VMXCX52Q.js +0 -1
- package/dist/m/c-YYGUHSZR.js +0 -1
- package/dist/m/manifest-3B84C829.js +0 -1
- package/dist/m/manifest-edit-1CB79AD4.js +0 -1
- package/dist/m/plugins/quickcrop-X5MRIBAP.js +0 -26
- package/dist/m/plugins/sortable-365SRRL3.js +0 -1
- package/dist/m/plugins/undo-UES4KS7B.js +0 -1
- package/dist/m/reader-core-VR7EL4WV.js +0 -77
- package/dist/m/ui/index-MGTWOW2C.js +0 -1
- /package/dist/m/{c-QTTJYJMA.js → c-FILLTJA7.js} +0 -0
- /package/dist/m/plugins/{quickcrop-X5MRIBAP.js.LEGAL.txt → quickcrop-VNRXGRPC.js.LEGAL.txt} +0 -0
- /package/dist/m/plugins/{richclay-L3BZMX4I.js.LEGAL.txt → richclay-V6WKJTUF.js.LEGAL.txt} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// GENERATED — do not edit. Vendored from
|
|
2
2
|
// hyper-html-api/src/upgrade.js via hyper-html-api
|
|
3
3
|
// `npm run copy-to-clayjs`. Edit the hyper-html-api source and re-run.
|
|
4
|
-
var bt=Object.defineProperty;var Rt=(e,t)=>{for(var n in t)bt(e,n,{get:t[n],enumerable:!0})};var ne=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],re=new Set(ne),ge=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),W=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),He=new Set(["checked","selected","disabled","readOnly","paused"]);function we(e,t){return t==null?He.has(e)?!1:"":He.has(e)?t==="false"?!1:!!t:t}var se={};Rt(se,{CodecRefused:()=>xe,EmptyListInsert:()=>I,MAX_RULE_DEPTH:()=>L,MaxRuleDepthExceeded:()=>$,NoRulesTag:()=>Ae,RuleTargetReadOnly:()=>z,RulesParseError:()=>C,ShapeMismatch:()=>B,UnknownCodec:()=>F,UnknownRulesVersion:()=>j,WriteNotRoundTripped:()=>ie,WriteRefused:()=>oe,WriteRejected:()=>Te});var C=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},j=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=t}},L=20,$=class extends Error{constructor(t){super(`rule depth exceeded ${L} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},B=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},I=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},z=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},oe=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function Ct(e){return e.reduce((n,o)=>typeof o=="number"?`${n}[${o}]`:n?`${n}.${o}`:String(o),"")||"(root)"}var ie=class extends Error{constructor(t){super(`write did not round-trip at "${Ct(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},Ae=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},Te=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}},F=class extends Error{constructor(t){super(`unknown codec "${t}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=t}},xe=class extends Error{constructor(t,n){super(n),this.name="CodecRefused",this.code=t}};function b(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let i=e[r];i==="\\"?r++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:i==="@"&&t===0&&(o=r)}return o}var qe="[*]";function R(e){let t=b(e),n=t===-1?e:e.slice(0,t),o=n.endsWith(qe),r={selector:o?n.slice(0,-qe.length):n,prop:t===-1?null:e.slice(t+1)||null};return o&&(r.all=!0),r}function Oe(e){let t=0,n=null,o=-1,r=!1;for(let i=0;i<e.length;i++){let s=e[i];s==="\\"?i++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:t===0&&s===">"?o=i:t===0&&s===","&&(r=!0)}return r||o===-1||!Nt(e,o+1)?null:e.slice(0,o).trim()||null}function Nt(e,t){let n=t,o=e.replace(/\s+$/,"").length;for(;n<o&&/\s/.test(e[n]);)n++;let r=0,i=null;for(;n<o;n++){let s=e[n];if(s==="\\")n++;else if(i)s===i&&(i=null);else if(s==='"'||s==="'")i=s;else if(s==="["||s==="(")r++;else if(s==="]"||s===")")r>0&&r--;else if(r===0&&(s==="+"||s==="~"||/\s/.test(s)))return!1}return!0}var kt=/^codec\(([a-z][a-z0-9-]*)\)$/;function P(e){if(typeof e!="string")return null;let t=b(e);if(t===-1)return null;let n=kt.exec(e.slice(t+1));if(!n)return null;let{selector:o,all:r}=R(e);if(r)throw new C("A @codec(name) rule cannot use [*].");return{selector:o,name:n[1]}}var Pt=/^--[A-Za-z0-9_-]+$/;function _(e){return typeof e=="string"&&Pt.test(e)}function Ve(e){let t=[],n=[],o=null,r=0;for(let i=0;i<e.length;i++){let s=e[i];if(o){s==="\\"?i++:s===o&&(o=null);continue}if(s==="/"&&e[i+1]==="*"){let c=e.indexOf("*/",i+2);i=c===-1?e.length:c+1;continue}s==='"'||s==="'"?o=s:s==="("?n.push(")"):s==="["?n.push("]"):s==="{"?n.push("}"):(s===")"||s==="]"||s==="}")&&n[n.length-1]===s?n.pop():s===";"&&n.length===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function Mt(e){let t="",n=null;for(let o=0;o<e.length;o++){let r=e[o];if(n){t+=r,r==="\\"&&o+1<e.length?t+=e[++o]:r===n&&(n=null);continue}if(r==="/"&&e[o+1]==="*"){let i=e.indexOf("*/",o+2);o=i===-1?e.length:i+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Be(e){e=Mt(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),o=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(o);return r&&(o=o.slice(0,r.index).trim()),{name:n,value:o,important:!!r}}function K(e,t){if(e==null)return null;let n=null;for(let o of Ve(String(e))){let r=Be(o);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function ze(e,t,n){let o=e==null?"":String(e),r=n==null||n==="",i=Ve(o),s=i.map(Be),c=s.some(d=>d&&d.name===t&&d.important),l=[],p=!1;i.forEach((d,h)=>{let A=s[h];if(!A||A.name!==t){l.push(d);return}if(r||p)return;let f=/^\s*/.exec(d)[0];l.push(`${f}${t}: ${n}${c?" !important":""}`),p=!0});let u=l.join(";");if(!r&&!p){let d=u.trimEnd();u=d===""?`${t}: ${n}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${n}`}return u.trim()===""?null:u}function Ee(e,t,n,o){let r=e.attr(t,"style");if((K(r,n)??"")===o)return;let i=ze(r,n,o);i==null?e.removeAttr(t,"style"):e.attr(t,"style",i)}var Fe=/^[a-z][a-z0-9-]*$/,Se=new Map;function be(e,t){if(typeof e!="string"||!Fe.test(e))throw new Error(`hyper-html-api: invalid codec name ${JSON.stringify(e)} (must match ${Fe})`);if(!t||typeof t.read!="function"||typeof t.write!="function"||typeof t.same!="function")throw new Error(`hyper-html-api: codec "${e}" needs read, write and same functions`);Se.set(e,t)}function Re(e){return Se.get(e)??null}function Ce(){return Object.fromEntries(Se)}var It='The @codec(name) rule form needs a rules tag with data-rules-version="2".',Lt="A @codec(name) rule must be the value of a top level key.";function ce(e,t){let n=P(e);return n?{...n,codec:t.codecs[n.name]}:null}function H(e,t={}){let n=t.version??"1",o=t.codecs??{};r(e,0);function r(i,s){if(!(s>L)){if(typeof i=="string"){let c=P(i);if(!c)return;if(n!=="2")throw new C(It);if(s!==1)throw new C(Lt);if(!Object.prototype.hasOwnProperty.call(o,c.name))throw new F(c.name);return}if(Array.isArray(i)){r(i[1],s+1);return}if(i&&typeof i=="object")for(let c of Object.values(i))r(c,s+1)}}}function M(e,t,n,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return H(n,o),ke(e,t,n,{depth:0,path:[]},o)}function ke(e,t,n,o,r){if(o.depth>L)throw new $(o.path);if(typeof n=="string")return jt(e,t,n,o,r);if(Array.isArray(n)){let[i,s]=n,c=e.find(t,i,r);return Ke(r,o,c),c.map((l,p)=>ke(e,l,s,{depth:o.depth+1,path:[...o.path,p]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[s,c]of Object.entries(n))i[s]=ke(e,t,c,{depth:o.depth+1,path:[...o.path,s]},r);return i}return null}function jt(e,t,n,o,r){if(n.endsWith("[]")){let u=n.slice(0,-2),d=e.find(t,u,r);return Ke(r,o,d),d.map(h=>e.text(h))}let i=ce(n,r);if(i)return $t(e,t,i,r);if(n.startsWith("@"))return Ne(e,t,n.slice(1));let s=b(n);if(s!==-1){let{selector:u,all:d}=R(n),h=n.slice(s+1),A=u?e.find(t,u,r):[t];return d&&r.allMatches?A.map(f=>Ne(e,f,h)):A.length===0?null:Ne(e,A[0],h)}if(n===".")return e.text(t);let{selector:c,all:l}=R(n),p=e.find(t,c,r);return l&&r.allMatches?p.map(u=>e.text(u)):p.length===0?null:e.text(p[0])}function $t(e,t,{selector:n,codec:o},r){let i=n?e.find(t,n,r):[t];return i.length===0?null:o.read(e,i[0],{query:r.query,view:r.view,region:r.region})}function Ke(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function Ne(e,t,n){if(_(n))return K(e.attr(t,"style"),n);if(re.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o??null}function Xe(e,t,n,o){let r=e.length,i=t.length,s=new Array(r).fill(-1);if(o){let a=new Set;for(let y=0;y<r;y++){let w=o[y];!(w>=0&&w<i)||a.has(w)||(s[y]=w,a.add(w))}}if(r===0||i===0)return s;let c=e.map(a=>Je(a,n)),l=t.map(a=>Je(a,n)),p=new Array(i).fill(!1);for(let a of s)a>=0&&(p[a]=!0);let u=new Map;l.forEach((a,y)=>{p[y]||u.set(a,u.has(a)?-1:y)});let d=new Map;c.forEach((a,y)=>{s[y]>=0||d.set(a,(d.get(a)||0)+1)}),c.forEach((a,y)=>{if(s[y]>=0||d.get(a)!==1)return;let w=u.get(a);w===void 0||w===-1||p[w]||(s[y]=w,p[w]=!0)});let h=[];for(let a=0;a<r;a++)s[a]<0&&h.push(a);let A=[];for(let a=0;a<i;a++)p[a]||A.push(a);if(h.length===0||A.length===0)return s;let f=r*i+1,m=_t(e,t,n),g=(a,y)=>m(a,y)*f+Math.abs(a-y);for(let[a,y]of Dt(h,A,g))s[a]=y;return s}var Ge=e=>typeof e=="object"&&e!==null;function Je(e,t){if(!Ge(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function _t(e,t,n){if(!Ge(n))return(c,l)=>e[c]===t[l]?0:1;let o=Object.keys(n),r=c=>o.map(l=>JSON.stringify(c?.[l])),i=e.map(r),s=t.map(r);return(c,l)=>{let p=i[c],u=s[l],d=0;for(let h=0;h<o.length;h++)p[h]!==u[h]&&d++;return d}}function Dt(e,t,n){return e.length<=t.length?Ye(e,t,n,!1):Ye(t,e,(o,r)=>n(r,o),!0)}function Ye(e,t,n,o){let r=e.length,i=t.length,s=[];for(let d=0;d<=r;d++)s.push(new Float64Array(i+1).fill(1/0));let c=[];for(let d=0;d<=r;d++)c.push(new Uint8Array(i+1));for(let d=0;d<=i;d++)s[r][d]=0;for(let d=r-1;d>=0;d--)for(let h=i-1;h>=0;h--){let A=n(e[d],t[h])+s[d+1][h+1],f=s[d][h+1];A<=f?(s[d][h]=A,c[d][h]=1):s[d][h]=f}let l=[],p=0,u=0;for(;p<r&&u<i;)c[p][u]&&(l.push(o?[t[u],e[p]]:[e[p],t[u]]),p++),u++;return l}function Me(e,t,n,o,r,i,s,c={}){let l=e.find(t,n,c);if(r.length===0){l.forEach(T=>e.remove(T)),Pe(c,"onRowsApplied",i.path,[]);return}let p=r.length>l.length,u=l[0]||null;if(p&&!u&&(u=Ht(e,t,n,c),!u))throw new I(i.path);let d=l.map(T=>Wt(e,T,o,c)),h=null;if(p&&u){h=e.clone(u),c.templateAttr&&e.removeAttr(h,c.templateAttr);let T=e.stripIds(h);T>0&&console.warn(`[hyper-html-api] stripped ${T} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let A=Xe(r,d,o,vt(e,l,r,i,c)),f=l.length>0?e.parent(l[0]):zt(e,t,n,u,i,c),m=l.length>0?nt(e,f,l[0]):0,g=Jt(e,l),a=new Set,y=[],w=r.map((T,S)=>{let O=A[S];if(O>=0)return a.add(O),y.push(!1),l[O];y.push(!0);let x=e.clone(h);return e.stripIds(x),x});l.forEach((T,S)=>{a.has(S)||e.remove(T)}),g?Kt(e,f,m,w,y):Yt(e,w,y,f,m),Ut(e,w,o,r,i,s,c),Pe(c,"onRowsApplied",i.path,w)}function Pe(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function vt(e,t,n,o,r){let i=Pe(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let s=new Array(n.length).fill(-1),c=new Set,l=new Map(t.map((p,u)=>[e.identity(p),u]));for(let p=0;p<n.length;p++){if(!i[p])continue;let u=l.get(e.identity(i[p]));u===void 0||c.has(u)||(s[p]=u,c.add(u))}return s}function Ut(e,t,n,o,r,i,s){t.forEach((c,l)=>{if(n===null){let p=o[l],u=p==null?"":String(p);e.text(c)!==u&&e.text(c,u)}else{let p=i(e,c,n,o[l],{depth:r.depth+1,path:[...r.path,l]},s);p&&p!==c&&(t[l]=p)}})}function Wt(e,t,n,o){return n===null?e.text(t):M(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function nt(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function Ht(e,t,n,o){if(!o.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),i=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),s=n.replace(/^\s*:scope\s*>\s*/,"").replace(i,""),c=r?qt(s):0,l=Oe(s),p=t;for(;p;){let u=e.find(p,s,{includeRulesTag:!1,templateAttr:null});for(let d of u)if(e.attr(d,o.templateAttr)!=null&&!(r&&!Bt(e,t,d,c))&&!(l&&!e.matches(e.parent(d),l)))return d;p=e.parent(p)}return null}function qt(e){let t=0,n=null,o=1;for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\")r++;else if(n)i===n&&(n=null);else if(i==='"'||i==="'")n=i;else if(i==="["||i==="(")t++;else if(i==="]"||i===")")t>0&&t--;else if(t===0&&i===">")o++;else{if(t===0&&(i==="+"||i==="~"))return null;if(t===0&&/\s/.test(i)){if(!Vt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return o}function Vt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let o=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return Ze(o)||Ze(r)}function Ze(e){return e===">"||e==="+"||e==="~"}function Bt(e,t,n,o){if(o===null)return!0;let r=n;for(let l=0;l<o;l++)if(r=e.parent(r),!r)return!1;let i=e.prop(t,"tagName");if(!i)return!0;let s=e.prop(r,"tagName");if(!s||String(s).toLowerCase()!==String(i).toLowerCase())return!1;let c=new Set(Qe(e,r));return Qe(e,t).every(l=>c.has(l))}function Qe(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function zt(e,t,n,o,r,i){let s=e.parent(o);if(s&&Ft(e,t,s)&&!tt(e,s,i))return s;let c=Oe(n);if(!c)throw new I(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let p=(c===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,c,i)).filter(u=>!tt(e,u,i));if(p.length===0)throw new I(r.path,`no container matching "${c}" inside this context to hold the new rows`);if(p.length>1)throw new I(r.path,`"${c}" matches ${p.length} containers inside this context, so the new rows have no single destination`);return p[0]}function Ft(e,t,n){let o=n;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var et=["no-data","editor-ui"];function tt(e,t,n){let o=t;for(;o;){if(n.templateAttr&&e.attr(o,n.templateAttr)!=null||et.some(i=>e.attr(o,i)!=null))return!0;let r=e.attr(o,"clay");if(r&&r.split(/\s+/).some(i=>et.includes(i)))return!0;o=e.parent(o)}return!1}function Kt(e,t,n,o,r){let i=e.children(t),s=i.map(l=>e.identity(l)),c=!1;o.forEach((l,p)=>{let u=e.identity(l),d=n+p;if(s[d]===u)return;if(!r[p]){let A=s.indexOf(u);A!==-1&&(s.splice(A,1),i.splice(A,1))}let h=Math.min(d,i.length);h<i.length?e.insertBefore(i[h],l):i.length?c?e.insertAfter(i[i.length-1],l):(e.insertAt(t,l,d),c=!0):e.insertAt(t,l,0),s.splice(h,0,u),i.splice(h,0,l)})}function Jt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=new Map(e.children(n).map((i,s)=>[e.identity(i),s])),r=[];for(let i of t){let s=o.get(e.identity(i));if(s===void 0)return!1;r.push(s)}return r.sort((i,s)=>i-s),r[r.length-1]-r[0]===r.length-1}function Yt(e,t,n,o,r){let i=null,s=r;for(let c=0;c<t.length;c++){if(!n[c]){i=t[c];continue}let l=i?e.parent(i):o;if(!l)continue;let p=i?nt(e,l,i)+1:s++;e.insertAt(l,t[c],p),i=t[c]}}function D(e,t,n,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");H(n,r);let i=[];if(Ie(n,o,[],i),i.length)throw new B(i);le(e,t,n,o,{depth:0,path:[]},r)}function le(e,t,n,o,r,i={}){if(r.depth>L)throw new $(r.path);if(o===void 0)return t;if(typeof n=="string")return Xt(e,t,n,o,r,i);if(Array.isArray(n)){let[s,c]=n;return Me(e,t,s,c,o,r,le,i),t}if(typeof n=="object"&&n!==null){for(let[s,c]of Object.entries(n)){let l=le(e,t,c,o==null?o:o[s],{depth:r.depth+1,path:[...r.path,s]},i);l&&l!==t&&(t=l)}return t}return t}function Xt(e,t,n,o,r,i){if(n.endsWith("[]")){let d=n.slice(0,-2);return Me(e,t,d,null,o,r,le,i),t}let s=ce(n,i);if(s){let d=s.selector?e.find(t,s.selector,i):[t];return d.length&&s.codec.write(e,d[0],o,{query:i.query}),t}if(n.startsWith("@"))return ot(e,t,n.slice(1),o);let c=b(n);if(c!==-1){let{selector:d,all:h}=R(n),A=n.slice(c+1),f=d?e.find(t,d,i):[t];for(let m of h?f:f.slice(0,1))ot(e,m,A,o);return t}if(n===".")return rt(e,t,o),t;let{selector:l,all:p}=R(n),u=e.find(t,l,i);for(let d of p?u:u.slice(0,1))rt(e,d,o);return t}function rt(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function Gt(e,t,n,o){if(e.styleVar){e.styleVar(t,n,o);return}Ee(e,t,n,o)}function ot(e,t,n,o){if(_(n))return Gt(e,t,n,o==null?"":String(o).trim()),t;if(W.has(n)){let r=e.prop(t,n);if(r===o||r!=null&&o!=null&&String(r)===String(o))return t;throw new z(n)}if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}if(ge.has(n)){let r=we(n,o);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(o==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(o);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function Ie(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(P(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,i)=>{typeof r=="object"&&r!==null&&o.push({path:Y([...n,i]),expected:"scalar",got:J(r)})}):o.push({path:Y(n),expected:"array",got:J(t)});return}t!==null&&typeof t=="object"&&o.push({path:Y(n),expected:"scalar",got:J(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:Y(n),expected:"array",got:J(t)});return}let r=e[1];t.forEach((i,s)=>Ie(r,i,[...n,s],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:Y(n),expected:"object",got:J(t)});return}for(let[r,i]of Object.entries(e))Ie(i,t[r],[...n,r],o)}}}function J(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Y(e){return e.join(".")}function Le(e){try{return JSON.parse(e)}catch(t){throw new C(`Invalid strict JSON: ${t.message}`,t)}}function v(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let i=[],s=0;for(;s<r.length;){let c=r[s];if(/\s/.test(c)){s++;continue}if("{}".includes(c)){i.push({type:c,value:c}),s++;continue}if(c==="["){let d=!1,h=s+1;for(;h<r.length&&/\s/.test(r[h]);)h++;if(h<r.length&&/[a-zA-Z_]/.test(r[h])&&(d=!0),!d){i.push({type:c,value:c}),s++;continue}}if(c==="]"){i.push({type:c,value:c}),s++;continue}if(c===":"){i.push({type:t.COLON,value:c}),s++;continue}if(c===","){i.push({type:t.COMMA,value:c}),s++;continue}if(c==='"'||c==="'"){let d=c,h=s+1;for(;h<r.length&&r[h]!==d;)r[h]==="\\"&&h++,h++;i.push({type:t.STRING,value:r.substring(s+1,h),quoted:!0,sourceQuote:d}),s=h+1;continue}let l=s,p;for(;l<r.length&&!/[{},]/.test(r[l]);)if(r[l]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],h=!1;for(let A of d){let f=A.substring(1);if(r.substring(l+1,l+1+f.length)===f){h=!0,l+=f.length;break}}if(!h)break}else if(r[l]==="["){for(l++;l<r.length&&r[l]!=="]";){if(r[l]==='"'||r[l]==="'"){let d=r[l];for(l++;l<r.length&&r[l]!==d;)r[l]==="\\"&&l++,l++}l++}l<r.length&&r[l]==="]"&&l++}else l++;p=r.substring(s,l);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(p)?u=t.NUMBER:p==="true"||p==="false"||p==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(p)&&(u=t.SELECTOR),i.push({type:u,value:p,quoted:!1}),s=l}return i}function o(r){let i="";for(let s=0;s<r.length;s++){let c=r[s];if("{}".includes(c.type)||"[]".includes(c.type)){i+=c.value;continue}if(c.type===t.COLON){i+=c.value;continue}if(c.type===t.COMMA){let l=r[s+1];if(l&&(l.type==="}"||l.type==="]"))continue;i+=c.value;continue}if(c.type===t.STRING&&c.quoted){let l=c.value;c.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(p,u)=>u.length%2===0?u+'\\"':p)),i+=`"${l}"`;continue}if(c.type===t.NUMBER||c.type===t.BOOLEAN){i+=c.value;continue}if(c.type===t.SELECTOR||c.type===t.IDENTIFIER){i+=`"${c.value}"`;continue}i+=`"${c.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new C("Invalid extraction rules syntax: "+r.message,r)}}var fe=["1","2"],it=/^[a-zA-Z0-9_-]+$/;function X(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!it.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${it})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let i=r[0],s=e.attr(i,"data-rules-version");if(!fe.includes(s))throw new j(s);return{rules:v(e.text(i)),tagNode:i,version:s}}var ue=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"]})}),Zt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),st=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function G(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function je(e,t){if(G(e,t))return!0;for(let[n,o]of Object.entries(Zt))if(o.includes(t)&&G(e,n))return!0;return!1}function Z(e){let t=ue[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Qt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=ue[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>je(n,r))||o.bundles.some(r=>G(n,r)))return n;n=n.parentElement}return null}function ct(e,t){return!!Qt(e,t)}var en=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...st],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})});function $e(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null,version:"1"};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return X(e,o,n)}return null}var on=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function sn(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function lt(e,t,n,o){if(o)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function ft(e,t,n,o,r,i){return(i?ct(e,t):lt(e,n,r,!1))||!!(o&&(i&&e!==r?e.matches(o):lt(e,o,r,i)))}function cn(e,t){let n=ue[t];return n.tokens.some(o=>je(e,o))||n.bundles.some(o=>G(e,o))}var ln=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function ut(e,t,n,o){if(e.nodeType===1&&o(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,i=t;if(e.nodeType===1){if(ln.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,i=t.content,n.cloneToLive.set(i,r),n.liveToClone.set(r,i)}}else if(e.nodeType!==11)return;let s=i.firstChild;for(let c=r.firstChild;c&&s;c=c.nextSibling)ut(c,s,n,o),s=s.nextSibling}function Q(e,{capability:t="data",exclude:n=null,inherit:o=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let i=e.nodeType===9?e:e.ownerDocument;if(!i?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=i.implementation.createHTMLDocument(""),c=r||new WeakMap,l=new WeakMap,p=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let u=Z(t),d=o?f=>cn(f,t)||!!(n&&f.matches(n)):f=>ft(f,t,u,n,p,!1),h=null;if(p.nodeType!==1||!ft(p,t,u,n,p,o)){h=s.importNode(p,!0);let f={cloneToLive:c,liveToClone:l,dropped:[],controls:[]};ut(p,h,f,d);for(let m of f.dropped)m.remove();for(let m=0;m<f.controls.length;m+=2)sn(f.controls[m],f.controls[m+1])}e.nodeType===9&&h&&(s.replaceChild(h,s.documentElement),l.set(e,s),c.set(s,e));let A=f=>{if(on.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:h,document:s,capability:t,selector:Z(t),cloneToLive:c,liveToClone:l,original(f){return c.get(f)||null},cloneOf(f){return l.get(f)||null},query(f,m=h){return A(f),Array.from(m.querySelectorAll(f),g=>c.get(g)||g)},text(f=h){return(f===h?h:l.get(f))?.textContent||""},html(f=h){return(f===h?h:l.get(f))?.innerHTML??""},clone(f=h){let m=f===h?h:l.get(f);return m?s.importNode(m,!0):null}}}function dt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function fn(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function at(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function pt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function ht(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let o=n.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var E={semanticExclude:!0,find(e,t,n={}){let o=fn(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(c=>!dt(c)));let i=[];n.skip&&i.push(n.skip);let s=n.templateAttr===null?null:n.templateAttr||"cms-template";if(s&&i.push("["+s+"]"),i.length){let c=i.join(", ");r=r.filter(l=>!l.closest||!l.closest(c))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,pt(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),at(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),at(e,t,null)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return ht(t),t},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function ee(e,t={}){if(t.exclude===null)return E;let n=[Z("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return E;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,s=e.nodeType===9?e:e.ownerDocument,c=null,l=()=>c||(c=Q(i,{capability:"data",exclude:t.exclude||null})),p=f=>{let m=l();return f===e?m.cloneOf(e):m.cloneOf(f)||f},u=f=>c?.original(f)||f,d=(f,m)=>{l().liveToClone.set(f,m),l().cloneToLive.set(m,f);let g=f.childNodes||[],a=m.childNodes||[];for(let y=0;y<Math.min(g.length,a.length);y++)d(g[y],a[y])},h=(f,m,g,a)=>{let y=Array.from(f.childNodes).filter(x=>c.cloneOf(x)),T=y[0];for(;T&&y.includes(T);)T=T.nextSibling;for(let x of y)x.remove();if(g==="innerHTML"){let x=s.createElement("template");x.innerHTML=a;for(let V of Array.from(x.content.childNodes))f.insertBefore(V,T||null)}else f.insertBefore(s.createTextNode(a),T||null),pt(f,a);let S=Q(f,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(S.root?.childNodes||[]));let O=x=>{let V=S.original(x);V&&(c.liveToClone.set(V,x),c.cloneToLive.set(x,V));for(let St of Array.from(x.childNodes||[]))O(St)};for(let x of Array.from(m.childNodes))O(x)},A={...E,find(f,m,g={}){let a=p(f);if(!a?.querySelectorAll)return[];let y=l().query(m,a);g.includeRulesTag||(y=y.filter(S=>!dt(S)));let w=[];g.skip&&w.push(g.skip);let T=g.templateAttr===null?null:g.templateAttr||"cms-template";if(T&&w.push(`[${T}]`),w.length){let S=w.join(", ");y=y.filter(O=>!O.closest?.(S))}return y},parent(f){let m=p(f)?.parentElement;return m?u(m):null},children(f){return Array.from(p(f)?.children||[],u)},text(f,m){if(m===void 0){let y=u(f);return!y?.matches?.(n)&&!y?.querySelector?.(n)?E.text(y):(p(f)?.textContent||"").trim()}let g=u(f);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!c){E.text(g,m);return}let a=l().cloneOf(g);a?h(g,a,"textContent",m):E.text(g,m)},attr(f,m,g){let a=u(f);if(g===void 0)return E.attr(a,m);E.attr(a,m,g);let y=c?.cloneOf(a);y&&(E.attr(y,m,g),Q(a,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),c.liveToClone.delete(a),c.cloneToLive.delete(y)))},removeAttr(f,m){let g=u(f);E.removeAttr(g,m);let a=c?.cloneOf(g);a&&E.removeAttr(a,m)},prop(f,m,g){let a=u(f);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?E.prop(p(a),m):E.prop(a,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",w=y?l().cloneOf(a):c?.cloneOf(a);w&&y?h(a,w,m,g):(E.prop(a,m,g),w&&E.prop(w,m,g))},clone(f){let m=p(f);if(m===f)return E.clone(f);let g=s.importNode(m,!0);return ht(g),g},insertAt(f,m,g){let a=u(f),w=A.children(a)[g]||(()=>{for(let O=a.children.length-1;O>=0;O--){let x=a.children[O];if(l().cloneOf(x))return x.nextElementSibling}return a.firstElementChild})(),T=u(m);a.insertBefore(T,w||null);let S=l().cloneOf(a);if(S){let O=l().cloneOf(T);O||(O=s.importNode(T,!0),d(T,O));let x=Array.from(S.children);S.insertBefore(O,x[g]||null)}},insertBefore(f,m){let g=u(f),a=u(m);g.parentNode.insertBefore(a,g);let y=l().cloneOf(g.parentNode);if(y){let w=l().cloneOf(a);w||(w=s.importNode(a,!0),d(a,w));let T=l().cloneOf(g);T?T.before(w):y.appendChild(w)}},insertAfter(f,m){let g=u(f),a=u(m);g.parentNode.insertBefore(a,g.nextSibling);let y=l().cloneOf(g.parentNode);if(y){let w=l().cloneOf(a);w||(w=s.importNode(a,!0),d(a,w));let T=l().cloneOf(g);T?T.after(w):y.appendChild(w)}},identity(f){return u(f)||null},remove(f){let m=u(f),g=l().cloneOf(m);E.remove(m),g&&E.remove(g)},replaceWith(f,m){let g=u(f),a=l().cloneOf(g),y=E.replaceWith(g,m);if(a){let w=Q(y,{capability:"data",exclude:t.exclude||null});if(!w.root)a.remove();else{a.replaceWith(w.root);let T=S=>{let O=w.original(S);O&&(c.liveToClone.set(O,S),c.cloneToLive.set(S,O));for(let x of Array.from(S.childNodes||[]))T(x)};T(w.root)}}return y}};return A}var N=E;var _e=e=>({codecs:Ce(),...e}),mt={extract:(e,t,n={})=>M(ee(e,n),e,t,_e(n)),apply:(e,t,n,o={})=>D(ee(e,{...o,_write:!0}),e,t,n,_e(o)),findRulesIn:(e,t)=>X(N,e,t),findRules:(e,t)=>$e(N,e,t),bind:(e,t,n={})=>{let o=$e(N,e,t);if(!o){let i=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${i}`)}let r=_e({version:o.version,...n});return{...o,get:()=>M(ee(e,n),e,o.rules,r),set:i=>D(ee(e,{...n,_write:!0}),e,o.rules,i,r)}},codecs:{register:be,get:Re},parseStrict:Le,parseRelaxed:v,ruleAttrIndex:b,splitRule:R,errors:se,DOM_PROPERTIES:ne};var un="hha:upgrade-check:";function k(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function De(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function yt(e,t){let n=De(e),o=De(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let s=n[i]||0,c=o[i]||0;if(s!==c)return s>c}return!1}function an(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function dn(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function gt({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:i=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(h=>fetch(h)),r=r??Date.now(),!t)return null;let s=k(t,"hyper-source");if(!s)return null;let c=k(t,"hyper-version"),l;try{l=new URL(s,n?n.href:void 0)}catch{return null}if(n&&l.origin===n.origin&&l.pathname===n.pathname)return null;let p=`${un}${l.href}:${c||"none"}`,u,d=e?null:an(p);if(d&&typeof d.checkedAt=="number"&&r-d.checkedAt<i)u=d.sourceVersion;else{try{let h=await o(l.href);if(!h.ok)throw new Error(`HTTP ${h.status}`);let A=await h.text(),f=new DOMParser().parseFromString(A,"text/html");u=k(f,"hyper-version")}catch{u=null}dn(p,{checkedAt:r,sourceVersion:u})}return u?{available:yt(u,c||"0.0.0"),currentVersion:c,sourceVersion:u,sourceUrl:l.href}:null}var pn="script[data-rules-name]";function hn(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ae(e,t){let n=e.find(t,pn,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let s=hn(e.attr(i,"data-rules-name"));if(!s)continue;if(o.has(s)){console.warn(`hyper-html-api: duplicate rules tag name "${s}"; using the first.`);continue}let c=e.attr(i,"data-rules-version");if(!fe.includes(c))throw new j(c);o.add(s),r.push({name:s,rules:v(e.text(i)),version:c})}return r}function de(e,t){if(t!=="2"||!e||typeof e!="object"||Array.isArray(e))return{rules:e,carried:[]};let n={},o=[];for(let[r,i]of Object.entries(e)){let s=P(i);s?o.push({key:r,selector:s.selector}):n[r]=i}return{rules:n,carried:o}}function pe(e,t,n){return e.find(t,n)[0]||null}function ve(e,t){let n={};for(let{name:o,rules:r,version:i}of ae(e,t)){let{rules:s,carried:c}=de(r,i),l=M(e,t,s,{version:i});for(let{key:p,selector:u}of c){let d=pe(e,t,u);l[p]=d?e.prop(d,"innerHTML"):null}n[o]=l}return n}function wt(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:ve(N,t),version:k(n,"hyper-version")}}var te=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},he=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},U=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},me=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var mn="text/hyper-upgrade";function At(e,t){let n=e.find(t,`script[type="${mn}"]`);if(n.length===0)return null;if(n.length>1)throw new me(n.length);return e.text(n[0])||null}var yn=new Function("url","return import(url)");async function Tt(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await yn(n)}catch(r){throw new U(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new U("transform must `export default` a function");return o.default}function ye(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=Ue(t,e,n);return We(t,e,n),{data:o,summary:n}}function Ue(e,t,n,o=!1){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):o?[]:void 0:t==null||typeof t=="object"?o&&!gn(e)?null:void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,r]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(i=>Ue(r,i,n,!0))):o?[]:void 0}if(typeof e=="object"&&e!==null){let r={};for(let[i,s]of Object.entries(e)){let c=Ue(s,t?.[i],n,o);c!==void 0&&(r[i]=c)}return r}}function gn(e){let t=b(e);return t!==-1&&W.has(e.slice(t+1))}function We(e,t,n){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let o=new Set(Object.keys(e));for(let r of Object.keys(t))o.has(r)?We(e[r],t[r],n):n.discarded+=q(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>We(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=q(t))}}function q(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+q(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+q(n),0):1}function xt(e,t,n){let o=ae(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},s=new Set;for(let{name:c,rules:l,version:p}of o){if(s.add(c),!Object.prototype.hasOwnProperty.call(n,c)){i[c]={carriedOver:0,discarded:0,listItems:0};continue}let{rules:u,carried:d}=de(l,p),h=n[c],{data:A,summary:f}=ye(wn(h,d),u);D(e,t,u,A,{templateAttr:"cms-template"});for(let{key:m,selector:g}of d){let a=Ot(h)?h[m]:void 0;if(a==null)continue;let y=pe(e,t,g);typeof a=="string"&&y?(e.prop(y,"innerHTML",a),f.carriedOver+=1):f.discarded+=1}i[c]=f,r.carriedOver+=f.carriedOver,r.discarded+=f.discarded,r.listItems+=f.listItems}for(let c of Object.keys(n))s.has(c)||(r.discarded+=q(n[c]));return{totals:r,byName:i,rulesTagCount:o.length}}function Ot(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function wn(e,t){if(!t.length||!Ot(e))return e;let n={...e};for(let{key:o}of t)delete n[o];return n}async function Et({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:i}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),i=i||(a=>fetch(a)),!o)throw new Error("upgrade.run requires a document context");if(e=e||k(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let s=new URL(e,r?r.href:void 0);n=n!==void 0?n:k(o,"hyper-version"),t=t||ve(N,o);let c;try{c=await i(s.href)}catch(a){throw new te(s.href,a)}if(!c.ok)throw new te(s.href,new Error(`HTTP ${c.status}`));let l=await c.text(),p=new DOMParser().parseFromString(l,"text/html"),u=k(p,"hyper-version"),d=t,h=!1,A=At(N,p);if(A){let y=await(await Tt(A))(d,{fromVersion:n,toVersion:u});if(!y||typeof y!="object"||Array.isArray(y))throw new U("transform must return a plain object map of { rulesName: data }");d=y,h=!0}let{totals:f,byName:m,rulesTagCount:g}=xt(N,p,d);if(g===0&&Object.keys(d).length>0)throw new he(s.href);return{html:Tn(p),fromVersion:n,toVersion:u,summary:{transformApplied:h,totals:f,byName:m}}}function An(e){for(let t of e.querySelectorAll("input")){let n=(t.getAttribute("type")||"").toLowerCase();n!=="file"&&(n==="checkbox"||n==="radio"?t.checked!==t.hasAttribute("checked")&&t.toggleAttribute("checked",t.checked):t.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",t.value))}for(let t of e.querySelectorAll("textarea"))t.value!==t.textContent&&(t.textContent=t.value);for(let t of e.querySelectorAll("select")){let n=[...t.options];if(!t.multiple){let o=n.findIndex(r=>r.hasAttribute("selected"));if(t.selectedIndex===o||o===-1&&t.selectedIndex<=0)continue}for(let o of n)o.selected!==o.hasAttribute("selected")&&o.toggleAttribute("selected",o.selected)}}function Tn(e){return An(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
5
|
-
`+e.documentElement.outerHTML}var xn={checkForUpdate:gt,run:Et,extractAll:
|
|
4
|
+
var bt=Object.defineProperty;var Rt=(e,t)=>{for(var n in t)bt(e,n,{get:t[n],enumerable:!0})};var ne=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],re=new Set(ne),ge=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),W=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),He=new Set(["checked","selected","disabled","readOnly","paused"]);function Ae(e,t){return t==null?He.has(e)?!1:"":He.has(e)?t==="false"?!1:!!t:t}var se={};Rt(se,{CodecRefused:()=>xe,EmptyListInsert:()=>I,MAX_RULE_DEPTH:()=>L,MaxRuleDepthExceeded:()=>$,NoRulesTag:()=>we,RuleTargetReadOnly:()=>z,RulesParseError:()=>C,ShapeMismatch:()=>B,UnknownCodec:()=>F,UnknownRulesVersion:()=>j,WriteNotRoundTripped:()=>ie,WriteRefused:()=>oe,WriteRejected:()=>Te});var C=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},j=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=t}},L=20,$=class extends Error{constructor(t){super(`rule depth exceeded ${L} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},B=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},I=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},z=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},oe=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function Ct(e){return e.reduce((n,o)=>typeof o=="number"?`${n}[${o}]`:n?`${n}.${o}`:String(o),"")||"(root)"}var ie=class extends Error{constructor(t){super(`write did not round-trip at "${Ct(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},we=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},Te=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}},F=class extends Error{constructor(t){super(`unknown codec "${t}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=t}},xe=class extends Error{constructor(t,n){super(n),this.name="CodecRefused",this.code=t}};function b(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let i=e[r];i==="\\"?r++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:i==="@"&&t===0&&(o=r)}return o}var qe="[*]";function R(e){let t=b(e),n=t===-1?e:e.slice(0,t),o=n.endsWith(qe),r={selector:o?n.slice(0,-qe.length):n,prop:t===-1?null:e.slice(t+1)||null};return o&&(r.all=!0),r}function Oe(e){let t=0,n=null,o=-1,r=!1;for(let i=0;i<e.length;i++){let s=e[i];s==="\\"?i++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:t===0&&s===">"?o=i:t===0&&s===","&&(r=!0)}return r||o===-1||!Nt(e,o+1)?null:e.slice(0,o).trim()||null}function Nt(e,t){let n=t,o=e.replace(/\s+$/,"").length;for(;n<o&&/\s/.test(e[n]);)n++;let r=0,i=null;for(;n<o;n++){let s=e[n];if(s==="\\")n++;else if(i)s===i&&(i=null);else if(s==='"'||s==="'")i=s;else if(s==="["||s==="(")r++;else if(s==="]"||s===")")r>0&&r--;else if(r===0&&(s==="+"||s==="~"||/\s/.test(s)))return!1}return!0}var kt=/^codec\(([a-z][a-z0-9-]*)\)$/;function P(e){if(typeof e!="string")return null;let t=b(e);if(t===-1)return null;let n=kt.exec(e.slice(t+1));if(!n)return null;let{selector:o,all:r}=R(e);if(r)throw new C("A @codec(name) rule cannot use [*].");return{selector:o,name:n[1]}}var Pt=/^--[A-Za-z0-9_-]+$/;function _(e){return typeof e=="string"&&Pt.test(e)}function Ve(e){let t=[],n=[],o=null,r=0;for(let i=0;i<e.length;i++){let s=e[i];if(o){s==="\\"?i++:s===o&&(o=null);continue}if(s==="/"&&e[i+1]==="*"){let c=e.indexOf("*/",i+2);i=c===-1?e.length:c+1;continue}s==='"'||s==="'"?o=s:s==="("?n.push(")"):s==="["?n.push("]"):s==="{"?n.push("}"):(s===")"||s==="]"||s==="}")&&n[n.length-1]===s?n.pop():s===";"&&n.length===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function Mt(e){let t="",n=null;for(let o=0;o<e.length;o++){let r=e[o];if(n){t+=r,r==="\\"&&o+1<e.length?t+=e[++o]:r===n&&(n=null);continue}if(r==="/"&&e[o+1]==="*"){let i=e.indexOf("*/",o+2);o=i===-1?e.length:i+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Be(e){e=Mt(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),o=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(o);return r&&(o=o.slice(0,r.index).trim()),{name:n,value:o,important:!!r}}function K(e,t){if(e==null)return null;let n=null;for(let o of Ve(String(e))){let r=Be(o);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function ze(e,t,n){let o=e==null?"":String(e),r=n==null||n==="",i=Ve(o),s=i.map(Be),c=s.some(d=>d&&d.name===t&&d.important),l=[],p=!1;i.forEach((d,h)=>{let w=s[h];if(!w||w.name!==t){l.push(d);return}if(r||p)return;let f=/^\s*/.exec(d)[0];l.push(`${f}${t}: ${n}${c?" !important":""}`),p=!0});let u=l.join(";");if(!r&&!p){let d=u.trimEnd();u=d===""?`${t}: ${n}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${n}`}return u.trim()===""?null:u}function Ee(e,t,n,o){let r=e.attr(t,"style");if((K(r,n)??"")===o)return;let i=ze(r,n,o);i==null?e.removeAttr(t,"style"):e.attr(t,"style",i)}var Fe=/^[a-z][a-z0-9-]*$/,Se=new Map;function be(e,t){if(typeof e!="string"||!Fe.test(e))throw new Error(`hyper-html-api: invalid codec name ${JSON.stringify(e)} (must match ${Fe})`);if(!t||typeof t.read!="function"||typeof t.write!="function"||typeof t.same!="function")throw new Error(`hyper-html-api: codec "${e}" needs read, write and same functions`);Se.set(e,t)}function Re(e){return Se.get(e)??null}function Ce(){return Object.fromEntries(Se)}var It='The @codec(name) rule form needs a rules tag with data-rules-version="2".',Lt="A @codec(name) rule must be the value of a top level key.";function ce(e,t){let n=P(e);return n?{...n,codec:t.codecs[n.name]}:null}function H(e,t={}){let n=t.version??"1",o=t.codecs??{};r(e,0);function r(i,s){if(!(s>L)){if(typeof i=="string"){let c=P(i);if(!c)return;if(n!=="2")throw new C(It);if(s!==1)throw new C(Lt);if(!Object.prototype.hasOwnProperty.call(o,c.name))throw new F(c.name);return}if(Array.isArray(i)){r(i[1],s+1);return}if(i&&typeof i=="object")for(let c of Object.values(i))r(c,s+1)}}}function M(e,t,n,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return H(n,o),ke(e,t,n,{depth:0,path:[]},o)}function ke(e,t,n,o,r){if(o.depth>L)throw new $(o.path);if(typeof n=="string")return jt(e,t,n,o,r);if(Array.isArray(n)){let[i,s]=n,c=e.find(t,i,r);return Ke(r,o,c),c.map((l,p)=>ke(e,l,s,{depth:o.depth+1,path:[...o.path,p]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[s,c]of Object.entries(n))i[s]=ke(e,t,c,{depth:o.depth+1,path:[...o.path,s]},r);return i}return null}function jt(e,t,n,o,r){if(n.endsWith("[]")){let u=n.slice(0,-2),d=e.find(t,u,r);return Ke(r,o,d),d.map(h=>e.text(h))}let i=ce(n,r);if(i)return $t(e,t,i,r);if(n.startsWith("@"))return Ne(e,t,n.slice(1));let s=b(n);if(s!==-1){let{selector:u,all:d}=R(n),h=n.slice(s+1),w=u?e.find(t,u,r):[t];return d&&r.allMatches?w.map(f=>Ne(e,f,h)):w.length===0?null:Ne(e,w[0],h)}if(n===".")return e.text(t);let{selector:c,all:l}=R(n),p=e.find(t,c,r);return l&&r.allMatches?p.map(u=>e.text(u)):p.length===0?null:e.text(p[0])}function $t(e,t,{selector:n,codec:o},r){let i=n?e.find(t,n,r):[t];return i.length===0?null:o.read(e,i[0],{query:r.query,view:r.view,region:r.region})}function Ke(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function Ne(e,t,n){if(_(n))return K(e.attr(t,"style"),n);if(re.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o??null}function Xe(e,t,n,o){let r=e.length,i=t.length,s=new Array(r).fill(-1);if(o){let a=new Set;for(let y=0;y<r;y++){let A=o[y];!(A>=0&&A<i)||a.has(A)||(s[y]=A,a.add(A))}}if(r===0||i===0)return s;let c=e.map(a=>Je(a,n)),l=t.map(a=>Je(a,n)),p=new Array(i).fill(!1);for(let a of s)a>=0&&(p[a]=!0);let u=new Map;l.forEach((a,y)=>{p[y]||u.set(a,u.has(a)?-1:y)});let d=new Map;c.forEach((a,y)=>{s[y]>=0||d.set(a,(d.get(a)||0)+1)}),c.forEach((a,y)=>{if(s[y]>=0||d.get(a)!==1)return;let A=u.get(a);A===void 0||A===-1||p[A]||(s[y]=A,p[A]=!0)});let h=[];for(let a=0;a<r;a++)s[a]<0&&h.push(a);let w=[];for(let a=0;a<i;a++)p[a]||w.push(a);if(h.length===0||w.length===0)return s;let f=r*i+1,m=_t(e,t,n),g=(a,y)=>m(a,y)*f+Math.abs(a-y);for(let[a,y]of Dt(h,w,g))s[a]=y;return s}var Ge=e=>typeof e=="object"&&e!==null;function Je(e,t){if(!Ge(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function _t(e,t,n){if(!Ge(n))return(c,l)=>e[c]===t[l]?0:1;let o=Object.keys(n),r=c=>o.map(l=>JSON.stringify(c?.[l])),i=e.map(r),s=t.map(r);return(c,l)=>{let p=i[c],u=s[l],d=0;for(let h=0;h<o.length;h++)p[h]!==u[h]&&d++;return d}}function Dt(e,t,n){return e.length<=t.length?Ye(e,t,n,!1):Ye(t,e,(o,r)=>n(r,o),!0)}function Ye(e,t,n,o){let r=e.length,i=t.length,s=[];for(let d=0;d<=r;d++)s.push(new Float64Array(i+1).fill(1/0));let c=[];for(let d=0;d<=r;d++)c.push(new Uint8Array(i+1));for(let d=0;d<=i;d++)s[r][d]=0;for(let d=r-1;d>=0;d--)for(let h=i-1;h>=0;h--){let w=n(e[d],t[h])+s[d+1][h+1],f=s[d][h+1];w<=f?(s[d][h]=w,c[d][h]=1):s[d][h]=f}let l=[],p=0,u=0;for(;p<r&&u<i;)c[p][u]&&(l.push(o?[t[u],e[p]]:[e[p],t[u]]),p++),u++;return l}function Me(e,t,n,o,r,i,s,c={}){let l=e.find(t,n,c);if(r.length===0){l.forEach(T=>e.remove(T)),Pe(c,"onRowsApplied",i.path,[]);return}let p=r.length>l.length,u=l[0]||null;if(p&&!u&&(u=Ht(e,t,n,c),!u))throw new I(i.path);let d=l.map(T=>Wt(e,T,o,c)),h=null;if(p&&u){h=e.clone(u);let T=c.templateAttr&&e.attr(u,c.templateAttr)!=null;c.templateAttr&&e.removeAttr(h,c.templateAttr),T&&e.removeAttr(h,"hidden");let O=e.stripIds(h);O>0&&console.warn(`[hyper-html-api] stripped ${O} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let w=Xe(r,d,o,vt(e,l,r,i,c)),f=l.length>0?e.parent(l[0]):zt(e,t,n,u,i,c),m=l.length>0?nt(e,f,l[0]):0,g=Jt(e,l),a=new Set,y=[],A=r.map((T,O)=>{let E=w[O];if(E>=0)return a.add(E),y.push(!1),l[E];y.push(!0);let x=e.clone(h);return e.stripIds(x),x});l.forEach((T,O)=>{a.has(O)||e.remove(T)}),g?Kt(e,f,m,A,y):Yt(e,A,y,f,m),Ut(e,A,o,r,i,s,c),Pe(c,"onRowsApplied",i.path,A)}function Pe(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function vt(e,t,n,o,r){let i=Pe(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let s=new Array(n.length).fill(-1),c=new Set,l=new Map(t.map((p,u)=>[e.identity(p),u]));for(let p=0;p<n.length;p++){if(!i[p])continue;let u=l.get(e.identity(i[p]));u===void 0||c.has(u)||(s[p]=u,c.add(u))}return s}function Ut(e,t,n,o,r,i,s){t.forEach((c,l)=>{if(n===null){let p=o[l],u=p==null?"":String(p);e.text(c)!==u&&e.text(c,u)}else{let p=i(e,c,n,o[l],{depth:r.depth+1,path:[...r.path,l]},s);p&&p!==c&&(t[l]=p)}})}function Wt(e,t,n,o){return n===null?e.text(t):M(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function nt(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function Ht(e,t,n,o){if(!o.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),i=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),s=n.replace(/^\s*:scope\s*>\s*/,"").replace(i,""),c=r?qt(s):0,l=Oe(s),p=t;for(;p;){let u=e.find(p,s,{includeRulesTag:!1,templateAttr:null});for(let d of u)if(e.attr(d,o.templateAttr)!=null&&!(r&&!Bt(e,t,d,c))&&!(l&&!e.matches(e.parent(d),l)))return d;p=e.parent(p)}return null}function qt(e){let t=0,n=null,o=1;for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\")r++;else if(n)i===n&&(n=null);else if(i==='"'||i==="'")n=i;else if(i==="["||i==="(")t++;else if(i==="]"||i===")")t>0&&t--;else if(t===0&&i===">")o++;else{if(t===0&&(i==="+"||i==="~"))return null;if(t===0&&/\s/.test(i)){if(!Vt(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return o}function Vt(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let o=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return Ze(o)||Ze(r)}function Ze(e){return e===">"||e==="+"||e==="~"}function Bt(e,t,n,o){if(o===null)return!0;let r=n;for(let l=0;l<o;l++)if(r=e.parent(r),!r)return!1;let i=e.prop(t,"tagName");if(!i)return!0;let s=e.prop(r,"tagName");if(!s||String(s).toLowerCase()!==String(i).toLowerCase())return!1;let c=new Set(Qe(e,r));return Qe(e,t).every(l=>c.has(l))}function Qe(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function zt(e,t,n,o,r,i){let s=e.parent(o);if(s&&Ft(e,t,s)&&!tt(e,s,i))return s;let c=Oe(n);if(!c)throw new I(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let p=(c===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,c,i)).filter(u=>!tt(e,u,i));if(p.length===0)throw new I(r.path,`no container matching "${c}" inside this context to hold the new rows`);if(p.length>1)throw new I(r.path,`"${c}" matches ${p.length} containers inside this context, so the new rows have no single destination`);return p[0]}function Ft(e,t,n){let o=n;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var et=["no-data","editor-ui"];function tt(e,t,n){let o=t;for(;o;){if(n.templateAttr&&e.attr(o,n.templateAttr)!=null||et.some(i=>e.attr(o,i)!=null))return!0;let r=e.attr(o,"clay");if(r&&r.split(/\s+/).some(i=>et.includes(i)))return!0;o=e.parent(o)}return!1}function Kt(e,t,n,o,r){let i=e.children(t),s=i.map(l=>e.identity(l)),c=!1;o.forEach((l,p)=>{let u=e.identity(l),d=n+p;if(s[d]===u)return;if(!r[p]){let w=s.indexOf(u);w!==-1&&(s.splice(w,1),i.splice(w,1))}let h=Math.min(d,i.length);h<i.length?e.insertBefore(i[h],l):i.length?c?e.insertAfter(i[i.length-1],l):(e.insertAt(t,l,d),c=!0):e.insertAt(t,l,0),s.splice(h,0,u),i.splice(h,0,l)})}function Jt(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=new Map(e.children(n).map((i,s)=>[e.identity(i),s])),r=[];for(let i of t){let s=o.get(e.identity(i));if(s===void 0)return!1;r.push(s)}return r.sort((i,s)=>i-s),r[r.length-1]-r[0]===r.length-1}function Yt(e,t,n,o,r){let i=null,s=r;for(let c=0;c<t.length;c++){if(!n[c]){i=t[c];continue}let l=i?e.parent(i):o;if(!l)continue;let p=i?nt(e,l,i)+1:s++;e.insertAt(l,t[c],p),i=t[c]}}function D(e,t,n,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");H(n,r);let i=[];if(Ie(n,o,[],i),i.length)throw new B(i);le(e,t,n,o,{depth:0,path:[]},r)}function le(e,t,n,o,r,i={}){if(r.depth>L)throw new $(r.path);if(o===void 0)return t;if(typeof n=="string")return Xt(e,t,n,o,r,i);if(Array.isArray(n)){let[s,c]=n;return Me(e,t,s,c,o,r,le,i),t}if(typeof n=="object"&&n!==null){for(let[s,c]of Object.entries(n)){let l=le(e,t,c,o==null?o:o[s],{depth:r.depth+1,path:[...r.path,s]},i);l&&l!==t&&(t=l)}return t}return t}function Xt(e,t,n,o,r,i){if(n.endsWith("[]")){let d=n.slice(0,-2);return Me(e,t,d,null,o,r,le,i),t}let s=ce(n,i);if(s){let d=s.selector?e.find(t,s.selector,i):[t];return d.length&&s.codec.write(e,d[0],o,{query:i.query}),t}if(n.startsWith("@"))return ot(e,t,n.slice(1),o);let c=b(n);if(c!==-1){let{selector:d,all:h}=R(n),w=n.slice(c+1),f=d?e.find(t,d,i):[t];for(let m of h?f:f.slice(0,1))ot(e,m,w,o);return t}if(n===".")return rt(e,t,o),t;let{selector:l,all:p}=R(n),u=e.find(t,l,i);for(let d of p?u:u.slice(0,1))rt(e,d,o);return t}function rt(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function Gt(e,t,n,o){if(e.styleVar){e.styleVar(t,n,o);return}Ee(e,t,n,o)}function ot(e,t,n,o){if(_(n))return Gt(e,t,n,o==null?"":String(o).trim()),t;if(W.has(n)){let r=e.prop(t,n);if(r===o||r!=null&&o!=null&&String(r)===String(o))return t;throw new z(n)}if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}if(ge.has(n)){let r=Ae(n,o);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(o==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(o);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function Ie(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(P(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,i)=>{typeof r=="object"&&r!==null&&o.push({path:Y([...n,i]),expected:"scalar",got:J(r)})}):o.push({path:Y(n),expected:"array",got:J(t)});return}t!==null&&typeof t=="object"&&o.push({path:Y(n),expected:"scalar",got:J(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:Y(n),expected:"array",got:J(t)});return}let r=e[1];t.forEach((i,s)=>Ie(r,i,[...n,s],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:Y(n),expected:"object",got:J(t)});return}for(let[r,i]of Object.entries(e))Ie(i,t[r],[...n,r],o)}}}function J(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Y(e){return e.join(".")}function Le(e){try{return JSON.parse(e)}catch(t){throw new C(`Invalid strict JSON: ${t.message}`,t)}}function v(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let i=[],s=0;for(;s<r.length;){let c=r[s];if(/\s/.test(c)){s++;continue}if("{}".includes(c)){i.push({type:c,value:c}),s++;continue}if(c==="["){let d=!1,h=s+1;for(;h<r.length&&/\s/.test(r[h]);)h++;if(h<r.length&&/[a-zA-Z_]/.test(r[h])&&(d=!0),!d){i.push({type:c,value:c}),s++;continue}}if(c==="]"){i.push({type:c,value:c}),s++;continue}if(c===":"){i.push({type:t.COLON,value:c}),s++;continue}if(c===","){i.push({type:t.COMMA,value:c}),s++;continue}if(c==='"'||c==="'"){let d=c,h=s+1;for(;h<r.length&&r[h]!==d;)r[h]==="\\"&&h++,h++;i.push({type:t.STRING,value:r.substring(s+1,h),quoted:!0,sourceQuote:d}),s=h+1;continue}let l=s,p;for(;l<r.length&&!/[{},]/.test(r[l]);)if(r[l]===":"){let d=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],h=!1;for(let w of d){let f=w.substring(1);if(r.substring(l+1,l+1+f.length)===f){h=!0,l+=f.length;break}}if(!h)break}else if(r[l]==="["){for(l++;l<r.length&&r[l]!=="]";){if(r[l]==='"'||r[l]==="'"){let d=r[l];for(l++;l<r.length&&r[l]!==d;)r[l]==="\\"&&l++,l++}l++}l<r.length&&r[l]==="]"&&l++}else l++;p=r.substring(s,l);let u=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(p)?u=t.NUMBER:p==="true"||p==="false"||p==="null"?u=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(p)&&(u=t.SELECTOR),i.push({type:u,value:p,quoted:!1}),s=l}return i}function o(r){let i="";for(let s=0;s<r.length;s++){let c=r[s];if("{}".includes(c.type)||"[]".includes(c.type)){i+=c.value;continue}if(c.type===t.COLON){i+=c.value;continue}if(c.type===t.COMMA){let l=r[s+1];if(l&&(l.type==="}"||l.type==="]"))continue;i+=c.value;continue}if(c.type===t.STRING&&c.quoted){let l=c.value;c.sourceQuote==="'"&&(l=l.replace(/\\'/g,"'"),l=l.replace(/(\\*)"/g,(p,u)=>u.length%2===0?u+'\\"':p)),i+=`"${l}"`;continue}if(c.type===t.NUMBER||c.type===t.BOOLEAN){i+=c.value;continue}if(c.type===t.SELECTOR||c.type===t.IDENTIFIER){i+=`"${c.value}"`;continue}i+=`"${c.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new C("Invalid extraction rules syntax: "+r.message,r)}}var fe=["1","2"],it=/^[a-zA-Z0-9_-]+$/;function X(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!it.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${it})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let i=r[0],s=e.attr(i,"data-rules-version");if(!fe.includes(s))throw new j(s);return{rules:v(e.text(i)),tagNode:i,version:s}}var ue=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"]})}),Zt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),st=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function G(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function je(e,t){if(G(e,t))return!0;for(let[n,o]of Object.entries(Zt))if(o.includes(t)&&G(e,n))return!0;return!1}function Z(e){let t=ue[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Qt(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=ue[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>je(n,r))||o.bundles.some(r=>G(n,r)))return n;n=n.parentElement}return null}function ct(e,t){return!!Qt(e,t)}var en=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...st],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})});function $e(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null,version:"1"};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return X(e,o,n)}return null}var on=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function sn(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function lt(e,t,n,o){if(o)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function ft(e,t,n,o,r,i){return(i?ct(e,t):lt(e,n,r,!1))||!!(o&&(i&&e!==r?e.matches(o):lt(e,o,r,i)))}function cn(e,t){let n=ue[t];return n.tokens.some(o=>je(e,o))||n.bundles.some(o=>G(e,o))}var ln=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function ut(e,t,n,o){if(e.nodeType===1&&o(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,i=t;if(e.nodeType===1){if(ln.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,i=t.content,n.cloneToLive.set(i,r),n.liveToClone.set(r,i)}}else if(e.nodeType!==11)return;let s=i.firstChild;for(let c=r.firstChild;c&&s;c=c.nextSibling)ut(c,s,n,o),s=s.nextSibling}function Q(e,{capability:t="data",exclude:n=null,inherit:o=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let i=e.nodeType===9?e:e.ownerDocument;if(!i?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=i.implementation.createHTMLDocument(""),c=r||new WeakMap,l=new WeakMap,p=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let u=Z(t),d=o?f=>cn(f,t)||!!(n&&f.matches(n)):f=>ft(f,t,u,n,p,!1),h=null;if(p.nodeType!==1||!ft(p,t,u,n,p,o)){h=s.importNode(p,!0);let f={cloneToLive:c,liveToClone:l,dropped:[],controls:[]};ut(p,h,f,d);for(let m of f.dropped)m.remove();for(let m=0;m<f.controls.length;m+=2)sn(f.controls[m],f.controls[m+1])}e.nodeType===9&&h&&(s.replaceChild(h,s.documentElement),l.set(e,s),c.set(s,e));let w=f=>{if(on.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:h,document:s,capability:t,selector:Z(t),cloneToLive:c,liveToClone:l,original(f){return c.get(f)||null},cloneOf(f){return l.get(f)||null},query(f,m=h){return w(f),Array.from(m.querySelectorAll(f),g=>c.get(g)||g)},text(f=h){return(f===h?h:l.get(f))?.textContent||""},html(f=h){return(f===h?h:l.get(f))?.innerHTML??""},clone(f=h){let m=f===h?h:l.get(f);return m?s.importNode(m,!0):null}}}function dt(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function fn(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function at(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function pt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function ht(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let o=n.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var S={semanticExclude:!0,find(e,t,n={}){let o=fn(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(c=>!dt(c)));let i=[];n.skip&&i.push(n.skip);let s=n.templateAttr===null?null:n.templateAttr||"cms-template";if(s&&i.push("["+s+"]"),i.length){let c=i.join(", ");r=r.filter(l=>!l.closest||!l.closest(c))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,pt(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),at(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),at(e,t,null)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return ht(t),t},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function ee(e,t={}){if(t.exclude===null)return S;let n=[Z("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return S;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,s=e.nodeType===9?e:e.ownerDocument,c=null,l=()=>c||(c=Q(i,{capability:"data",exclude:t.exclude||null})),p=f=>{let m=l();return f===e?m.cloneOf(e):m.cloneOf(f)||f},u=f=>c?.original(f)||f,d=(f,m)=>{l().liveToClone.set(f,m),l().cloneToLive.set(m,f);let g=f.childNodes||[],a=m.childNodes||[];for(let y=0;y<Math.min(g.length,a.length);y++)d(g[y],a[y])},h=(f,m,g,a)=>{let y=Array.from(f.childNodes).filter(x=>c.cloneOf(x)),T=y[0];for(;T&&y.includes(T);)T=T.nextSibling;for(let x of y)x.remove();if(g==="innerHTML"){let x=s.createElement("template");x.innerHTML=a;for(let V of Array.from(x.content.childNodes))f.insertBefore(V,T||null)}else f.insertBefore(s.createTextNode(a),T||null),pt(f,a);let O=Q(f,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(O.root?.childNodes||[]));let E=x=>{let V=O.original(x);V&&(c.liveToClone.set(V,x),c.cloneToLive.set(x,V));for(let St of Array.from(x.childNodes||[]))E(St)};for(let x of Array.from(m.childNodes))E(x)},w={...S,find(f,m,g={}){let a=p(f);if(!a?.querySelectorAll)return[];let y=l().query(m,a);g.includeRulesTag||(y=y.filter(O=>!dt(O)));let A=[];g.skip&&A.push(g.skip);let T=g.templateAttr===null?null:g.templateAttr||"cms-template";if(T&&A.push(`[${T}]`),A.length){let O=A.join(", ");y=y.filter(E=>!E.closest?.(O))}return y},parent(f){let m=p(f)?.parentElement;return m?u(m):null},children(f){return Array.from(p(f)?.children||[],u)},text(f,m){if(m===void 0){let y=u(f);return!y?.matches?.(n)&&!y?.querySelector?.(n)?S.text(y):(p(f)?.textContent||"").trim()}let g=u(f);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!c){S.text(g,m);return}let a=l().cloneOf(g);a?h(g,a,"textContent",m):S.text(g,m)},attr(f,m,g){let a=u(f);if(g===void 0)return S.attr(a,m);S.attr(a,m,g);let y=c?.cloneOf(a);y&&(S.attr(y,m,g),Q(a,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),c.liveToClone.delete(a),c.cloneToLive.delete(y)))},removeAttr(f,m){let g=u(f);S.removeAttr(g,m);let a=c?.cloneOf(g);a&&S.removeAttr(a,m)},prop(f,m,g){let a=u(f);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?S.prop(p(a),m):S.prop(a,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",A=y?l().cloneOf(a):c?.cloneOf(a);A&&y?h(a,A,m,g):(S.prop(a,m,g),A&&S.prop(A,m,g))},clone(f){let m=p(f);if(m===f)return S.clone(f);let g=s.importNode(m,!0);return ht(g),g},insertAt(f,m,g){let a=u(f),A=w.children(a)[g]||(()=>{for(let E=a.children.length-1;E>=0;E--){let x=a.children[E];if(l().cloneOf(x))return x.nextElementSibling}return a.firstElementChild})(),T=u(m);a.insertBefore(T,A||null);let O=l().cloneOf(a);if(O){let E=l().cloneOf(T);E||(E=s.importNode(T,!0),d(T,E));let x=Array.from(O.children);O.insertBefore(E,x[g]||null)}},insertBefore(f,m){let g=u(f),a=u(m);g.parentNode.insertBefore(a,g);let y=l().cloneOf(g.parentNode);if(y){let A=l().cloneOf(a);A||(A=s.importNode(a,!0),d(a,A));let T=l().cloneOf(g);T?T.before(A):y.appendChild(A)}},insertAfter(f,m){let g=u(f),a=u(m);g.parentNode.insertBefore(a,g.nextSibling);let y=l().cloneOf(g.parentNode);if(y){let A=l().cloneOf(a);A||(A=s.importNode(a,!0),d(a,A));let T=l().cloneOf(g);T?T.after(A):y.appendChild(A)}},identity(f){return u(f)||null},remove(f){let m=u(f),g=l().cloneOf(m);S.remove(m),g&&S.remove(g)},replaceWith(f,m){let g=u(f),a=l().cloneOf(g),y=S.replaceWith(g,m);if(a){let A=Q(y,{capability:"data",exclude:t.exclude||null});if(!A.root)a.remove();else{a.replaceWith(A.root);let T=O=>{let E=A.original(O);E&&(c.liveToClone.set(E,O),c.cloneToLive.set(O,E));for(let x of Array.from(O.childNodes||[]))T(x)};T(A.root)}}return y}};return w}var N=S;var _e=e=>({codecs:Ce(),...e}),mt={extract:(e,t,n={})=>M(ee(e,n),e,t,_e(n)),apply:(e,t,n,o={})=>D(ee(e,{...o,_write:!0}),e,t,n,_e(o)),findRulesIn:(e,t)=>X(N,e,t),findRules:(e,t)=>$e(N,e,t),bind:(e,t,n={})=>{let o=$e(N,e,t);if(!o){let i=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${i}`)}let r=_e({version:o.version,...n});return{...o,get:()=>M(ee(e,n),e,o.rules,r),set:i=>D(ee(e,{...n,_write:!0}),e,o.rules,i,r)}},codecs:{register:be,get:Re},parseStrict:Le,parseRelaxed:v,ruleAttrIndex:b,splitRule:R,errors:se,DOM_PROPERTIES:ne};var un="hha:upgrade-check:";function k(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function De(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function yt(e,t){let n=De(e),o=De(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let s=n[i]||0,c=o[i]||0;if(s!==c)return s>c}return!1}function an(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function dn(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function gt({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:i=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(h=>fetch(h)),r=r??Date.now(),!t)return null;let s=k(t,"hyper-source");if(!s)return null;let c=k(t,"hyper-version"),l;try{l=new URL(s,n?n.href:void 0)}catch{return null}if(n&&l.origin===n.origin&&l.pathname===n.pathname)return null;let p=`${un}${l.href}:${c||"none"}`,u,d=e?null:an(p);if(d&&typeof d.checkedAt=="number"&&r-d.checkedAt<i)u=d.sourceVersion;else{try{let h=await o(l.href);if(!h.ok)throw new Error(`HTTP ${h.status}`);let w=await h.text(),f=new DOMParser().parseFromString(w,"text/html");u=k(f,"hyper-version")}catch{u=null}dn(p,{checkedAt:r,sourceVersion:u})}return u?{available:yt(u,c||"0.0.0"),currentVersion:c,sourceVersion:u,sourceUrl:l.href}:null}var pn="script[data-rules-name]";function hn(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ae(e,t){let n=e.find(t,pn,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let s=hn(e.attr(i,"data-rules-name"));if(!s)continue;if(o.has(s)){console.warn(`hyper-html-api: duplicate rules tag name "${s}"; using the first.`);continue}let c=e.attr(i,"data-rules-version");if(!fe.includes(c))throw new j(c);o.add(s),r.push({name:s,rules:v(e.text(i)),version:c})}return r}function de(e,t){if(t!=="2"||!e||typeof e!="object"||Array.isArray(e))return{rules:e,carried:[]};let n={},o=[];for(let[r,i]of Object.entries(e)){let s=P(i);s?o.push({key:r,selector:s.selector}):n[r]=i}return{rules:n,carried:o}}function pe(e,t,n){return e.find(t,n)[0]||null}function ve(e,t){let n={};for(let{name:o,rules:r,version:i}of ae(e,t)){let{rules:s,carried:c}=de(r,i),l=M(e,t,s,{version:i});for(let{key:p,selector:u}of c){let d=pe(e,t,u);l[p]=d?e.prop(d,"innerHTML"):null}n[o]=l}return n}function At(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:ve(N,t),version:k(n,"hyper-version")}}var te=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},he=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},U=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},me=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var mn="text/hyper-upgrade";function wt(e,t){let n=e.find(t,`script[type="${mn}"]`);if(n.length===0)return null;if(n.length>1)throw new me(n.length);return e.text(n[0])||null}var yn=new Function("url","return import(url)");async function Tt(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await yn(n)}catch(r){throw new U(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new U("transform must `export default` a function");return o.default}function ye(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=Ue(t,e,n);return We(t,e,n),{data:o,summary:n}}function Ue(e,t,n,o=!1){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):o?[]:void 0:t==null||typeof t=="object"?o&&!gn(e)?null:void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,r]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(i=>Ue(r,i,n,!0))):o?[]:void 0}if(typeof e=="object"&&e!==null){let r={};for(let[i,s]of Object.entries(e)){let c=Ue(s,t?.[i],n,o);c!==void 0&&(r[i]=c)}return r}}function gn(e){let t=b(e);return t!==-1&&W.has(e.slice(t+1))}function We(e,t,n){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let o=new Set(Object.keys(e));for(let r of Object.keys(t))o.has(r)?We(e[r],t[r],n):n.discarded+=q(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>We(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=q(t))}}function q(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+q(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+q(n),0):1}function xt(e,t,n){let o=ae(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},s=new Set;for(let{name:c,rules:l,version:p}of o){if(s.add(c),!Object.prototype.hasOwnProperty.call(n,c)){i[c]={carriedOver:0,discarded:0,listItems:0};continue}let{rules:u,carried:d}=de(l,p),h=n[c],{data:w,summary:f}=ye(An(h,d),u);D(e,t,u,w,{templateAttr:"cms-template"});for(let{key:m,selector:g}of d){let a=Ot(h)?h[m]:void 0;if(a==null)continue;let y=pe(e,t,g);typeof a=="string"&&y?(e.prop(y,"innerHTML",a),f.carriedOver+=1):f.discarded+=1}i[c]=f,r.carriedOver+=f.carriedOver,r.discarded+=f.discarded,r.listItems+=f.listItems}for(let c of Object.keys(n))s.has(c)||(r.discarded+=q(n[c]));return{totals:r,byName:i,rulesTagCount:o.length}}function Ot(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function An(e,t){if(!t.length||!Ot(e))return e;let n={...e};for(let{key:o}of t)delete n[o];return n}async function Et({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:i}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),i=i||(a=>fetch(a)),!o)throw new Error("upgrade.run requires a document context");if(e=e||k(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let s=new URL(e,r?r.href:void 0);n=n!==void 0?n:k(o,"hyper-version"),t=t||ve(N,o);let c;try{c=await i(s.href)}catch(a){throw new te(s.href,a)}if(!c.ok)throw new te(s.href,new Error(`HTTP ${c.status}`));let l=await c.text(),p=new DOMParser().parseFromString(l,"text/html"),u=k(p,"hyper-version"),d=t,h=!1,w=wt(N,p);if(w){let y=await(await Tt(w))(d,{fromVersion:n,toVersion:u});if(!y||typeof y!="object"||Array.isArray(y))throw new U("transform must return a plain object map of { rulesName: data }");d=y,h=!0}let{totals:f,byName:m,rulesTagCount:g}=xt(N,p,d);if(g===0&&Object.keys(d).length>0)throw new he(s.href);return{html:Tn(p),fromVersion:n,toVersion:u,summary:{transformApplied:h,totals:f,byName:m}}}function wn(e){for(let t of e.querySelectorAll("input")){let n=(t.getAttribute("type")||"").toLowerCase();n!=="file"&&(n==="checkbox"||n==="radio"?t.checked!==t.hasAttribute("checked")&&t.toggleAttribute("checked",t.checked):t.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",t.value))}for(let t of e.querySelectorAll("textarea"))t.value!==t.textContent&&(t.textContent=t.value);for(let t of e.querySelectorAll("select")){let n=[...t.options];if(!t.multiple){let o=n.findIndex(r=>r.hasAttribute("selected"));if(t.selectedIndex===o||o===-1&&t.selectedIndex<=0)continue}for(let o of n)o.selected!==o.hasAttribute("selected")&&o.toggleAttribute("selected",o.selected)}}function Tn(e){return wn(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
5
|
+
`+e.documentElement.outerHTML}var xn={checkForUpdate:gt,run:Et,extractAll:At,shapeMatch:ye};var On={engine:mt,upgrade:xn},En=On;export{En as default,mt as engine,yt as isNewerVersion,De as parseVersion,k as readMeta,xn as upgrade};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var hyperundo=(()=>{var Y=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var pt=Object.getOwnPropertyNames;var gt=Object.prototype.hasOwnProperty;var ht=(e,n)=>{for(var t in n)Y(e,t,{get:n[t],enumerable:!0})},yt=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of pt(n))!gt.call(e,i)&&i!==t&&Y(e,i,{get:()=>n[i],enumerable:!(r=mt(n,i))||r.enumerable});return e};var bt=e=>yt(Y({},"__esModule",{value:!0}),e);var Qt={};ht(Qt,{default:()=>Zt,undo:()=>oe});function wt(e,n=null){let t=[];if(e.type==="attributes"){let r=e.target,i=e.attributeName,a=e.oldValue,s=r.getAttribute(i);return a==null&&s!=null?t.push({kind:"attr-add",target:r,name:i,newValue:s}):a!=null&&s==null?t.push({kind:"attr-remove",target:r,name:i,oldValue:a}):a!==s&&t.push({kind:"attr-set",target:r,name:i,oldValue:a,newValue:s}),t}if(e.type==="characterData")return t.push({kind:"text",target:e.target,oldValue:e.oldValue,newValue:e.target.data}),t;if(e.type==="childList"){let r=e.target,i=e.nextSibling,a=e.nextSibling;for(;a&&n?.(a);)a=a.nextSibling;let s=e.previousSibling;for(;s&&n?.(s);)s=s.previousSibling;let l=n?Array.from(e.addedNodes).filter(h=>!n(h)):Array.from(e.addedNodes),c=n?Array.from(e.removedNodes).filter(h=>!n(h)):Array.from(e.removedNodes);return l.length>0&&t.push({kind:"add",parent:r,nodes:l,before:i,afterAuthored:a,beforeAuthored:s,record:e}),c.length>0&&t.push({kind:"remove",parent:r,nodes:c,before:i,afterAuthored:a,beforeAuthored:s,record:e}),t}return t}function Ee(e,n=null){let t=[],r=new Map;for(let i of e){if(i.type==="attributes"){let a=i.target,s=i.attributeName,l=r.get(a);l||(l=new Map,r.set(a,l)),l.has(s)||(l.set(s,{idx:t.length,oldValue:i.oldValue}),t.push(null));continue}for(let a of wt(i,n))t.push(a)}for(let[i,a]of r)for(let[s,l]of a){let c=l.oldValue,h=i.getAttribute(s),p=null;c===h?p=null:c==null?p={kind:"attr-add",target:i,name:s,newValue:h}:h==null?p={kind:"attr-remove",target:i,name:s,oldValue:c}:p={kind:"attr-set",target:i,name:s,oldValue:c,newValue:h},t[l.idx]=p}return t.filter(i=>i!=null)}function Se(e){let n=[],t=new Map;for(let i of e){let a=Ae(i);if(a==null){n.push(i);continue}let s=t.get(i.target);s||(s=new Map,t.set(i.target,s));let l=s.get(a);if(l==null){let c=Ne(i);if(c.oldValue===c.newValue)continue;s.set(a,n.length),n.push({...i,...c})}else n[l]={...n[l],newValue:Ne(i).newValue}}let r=[];for(let i of n){if(Ae(i)==null){r.push(i);continue}i.oldValue!==i.newValue&&r.push(vt(i))}return r}var kt=new Set(["attr-set","attr-add","attr-remove","text","value"]);function Ae(e){return kt.has(e.kind)?e.kind==="text"?"#text":e.kind==="value"?`#${e.prop||"value"}`:e.name==null?null:`@${e.name}`:null}function Ne(e){return e.kind==="attr-add"?{oldValue:null,newValue:e.newValue}:e.kind==="attr-remove"?{oldValue:e.oldValue,newValue:null}:{oldValue:e.oldValue,newValue:e.newValue}}function vt(e){return e.kind!=="attr-add"&&e.kind!=="attr-remove"?e:e.oldValue==null&&e.newValue!=null?{...e,kind:"attr-add"}:e.oldValue!=null&&e.newValue==null?{...e,kind:"attr-remove"}:{...e,kind:"attr-set"}}var Te=new WeakMap,At=0;function T(e){let n=Te.get(e);return n||(n=`n${++At}`,Te.set(e,n)),n}function v(e){return!!e&&typeof e=="object"&&typeof e.nodeType=="number"}function Nt(e){return e.kind==="add"||e.kind==="remove"}function Ie(e,n){let t=[],r=e.childNodes;if(!r)return t;for(let i of r)n&&n(i)||t.push(T(i));return t}function K(e,n,t=null,r=null){if(!v(e))return null;if(e.nodeType===3)return`#text:${JSON.stringify(e.data)}`;if(e.nodeType===8)return`#comment:${JSON.stringify(e.data)}`;if(e.nodeType!==1)return`#node:${e.nodeType}`;let i=[];if(e.attributes){for(let l of e.attributes)Et(l.name,e,n,t)||i.push(`${l.name}=${JSON.stringify(l.value)}`);i.sort()}let a=[];if(e.childNodes)for(let l of e.childNodes)St(l,r)||a.push(K(l,n,t,r));return`<${String(e.tagName||"").toLowerCase()}${i.length?` ${i.join(" ")}`:""}>${a.join("")}</>`}function Z(e,n=[]){if(!v(e))return n;if(e.nodeType===1){let t=e.getAttribute&&e.getAttribute("data-id");t&&n.push(t)}if(e.childNodes)for(let t of e.childNodes)Z(t,n);return n}function Et(e,n,t,r=null){if(typeof t!="function")return!1;try{return!!t(e,n,r)}catch{return!1}}function St(e,n){if(typeof n!="function")return!1;try{return!!n(e)}catch{return!1}}function Pe(e,n){if(typeof n!="function")return[];let t=[],r=i=>{if(!v(i))return;let a=!1;try{a=!!n(i)}catch{a=!1}if(a&&t.push(E(i,"protected")),i.childNodes)for(let s of i.childNodes)r(s)};for(let i of e)r(i);return t}function E(e,n,t=null){let r=e;r&&r.nodeType!==1&&(r=r.parentElement);let i=r&&typeof r.closest=="function"?r.closest("[data-id]"):null;return!i&&t&&typeof t.closest=="function"&&(i=t.closest("[data-id]")),{id:(i?i.getAttribute("data-id"):null)||null,kind:n||null}}function Tt(e,n,t=null){return(e||[]).filter(v).map(r=>E(r,n,t))}function z(e){return{replayable:!1,reason:e,steps:[]}}function U(e,n){let t=[[n.afterAuthored,i=>i],[n.beforeAuthored,i=>i+1],[n.before,i=>i]],r=!1;for(let[i,a]of t){if(!v(i))continue;r=!0;let s=e.indexOf(T(i));if(s>=0)return a(s)}return r?null:e.length}function Ce(e,n={}){let t=n.isIgnored||null,r=n.ignoreAttribute||null,i=Se(e),a=[];for(let p of i){if(!Nt(p)){if(!v(p.target))return z("non-dom-target");continue}if(!v(p.parent))return z("non-dom-parent");let y=Array.from(p.nodes||[]).filter(v);if(y.length!==0){if(y.length!==Array.from(p.nodes||[]).length)return z("non-dom-node");a.push({primitive:p,nodes:y,parent:p.parent})}}if(Vt(a))return z("in-record-move");let s=It(a,t);if(!s)return z("ambiguous-structure");let l=Pt(a,s),c=new Map(a.map(p=>[p.primitive,p])),h=[];for(let p of i){let y=c.get(p);if(!y){h.push(Rt(p));continue}let w=l.get(y);if(w){w.at===y&&h.push(w.step);continue}h.push(Ct(y,s.get(y),r,t))}return{replayable:!0,reason:null,steps:h}}function Vt(e){let n=new Map;for(let t of e){let r=t.primitive.record;if(!r)continue;let i=n.get(r);i||(i=new Map,n.set(r,i));for(let a of t.nodes){let s=i.get(a);s||(s=new Set,i.set(a,s)),s.add(t.primitive.kind)}}for(let t of n.values())for(let r of t.values())if(r.size>1)return!0;return!1}function It(e,n){let t=new Map;for(let i of e)t.has(i.parent)||t.set(i.parent,Ie(i.parent,n));let r=new Map;for(let i=e.length-1;i>=0;i--){let a=e[i],s=t.get(a.parent);if(!s)return null;let l=s.slice(),c;if(a.primitive.kind==="add"){let h=a.nodes.map(T);if(!h.every(p=>s.includes(p)))return null;c=s.filter(p=>!h.includes(p))}else{let h=U(l,a.primitive);if(h==null)return null;c=l.slice(),c.splice(h,0,...a.nodes.map(T))}r.set(a,{before:c,after:l}),t.set(a.parent,c)}return r}function Pt(e,n){let t=new Map,r=new Map;e.forEach((a,s)=>{for(let l of a.nodes){let c=T(l);a.primitive.kind==="remove"?t.set(c,{item:a,index:s,node:l}):r.set(c,{item:a,index:s,node:l})}});let i=new Map;for(let[a,s]of t){let l=r.get(a);if(!l||l.index<s.index||s.item.nodes.length!==1||l.item.nodes.length!==1)continue;let c={type:"move",node:s.node,sourceParent:s.item.parent,destParent:l.item.parent,source:n.get(s.item),dest:n.get(l.item),sourceSlot:s.item.primitive,destSlot:l.item.primitive,targets:[E(s.node,"move")]};i.set(s.item,{step:c,at:l.item}),i.set(l.item,{step:c,at:l.item})}return i}function Ct(e,n,t,r){let i=e.primitive.kind;return{type:i==="add"?"add":"restore",parent:e.parent,nodes:e.nodes,seqBefore:n.before,seqAfter:n.after,slot:e.primitive,content:e.nodes.map(a=>K(a,t,e.parent,r)),ids:i==="remove"?e.nodes.flatMap(a=>Z(a)):[],targets:Tt(e.nodes,i==="add"?"added":"removed",e.parent)}}function Rt(e){return{type:e.kind,primitive:e,targets:[E(e.target,e.name||e.prop||"text")]}}function Re(e,n,t={}){if(!e||!e.replayable)return{ok:!1,code:"unsupported",targets:[]};let r={isIgnored:t.isIgnored||null,ignoreAttribute:t.ignoreAttribute||null,isProtected:t.isProtected||null,inScope:t.inScope||(()=>!0),liveNodesWithIds:t.liveNodesWithIds||(()=>[]),sim:new Map,planned:new Map,operations:[]};for(let i=0;i<e.steps.length;i++){let a=e.steps[n==="undo"?e.steps.length-1-i:i],s=xt(a,n,r);if(s)return{ok:!1,code:s.code,targets:s.targets}}return{ok:!0,operations:r.operations}}function M(e,n){return e.sim.has(n)||e.sim.set(n,Ie(n,e.isIgnored)),e.sim.get(n)}function L(e,n){for(let t=e;t;t=t.parentNode)if(n.planned.has(t))return n.planned.get(t);return n.inScope(e)}function Oe(e,n){return n.liveNodesWithIds(e).filter(t=>L(t,n)).length>0}function b(e,n){return{code:e,targets:n||[]}}function Ot(e){return e.kind==="text"?e.target.data:e.kind==="value"?typeof e.read=="function"?e.read(e.target):e.target[e.prop||"value"]:e.target.getAttribute(e.name)}function xt(e,n,t){let r=n==="undo";return e.type==="move"?zt(e,r,t):e.type==="add"?Mt(e,r,t):e.type==="restore"?Lt(e,r,t):_t(e,r,t)}function _t(e,n,t){let r=e.primitive,i=n?r.newValue:r.oldValue,a=n?r.oldValue:r.newValue;return v(r.target)?L(r.target,t)?r.kind==="value"&&typeof r.write=="function"&&typeof r.read!="function"?b("unsupported",e.targets):Ot(r)!==i?b("content-changed",e.targets):(r.kind==="value"?t.operations.push({type:"value",target:r.target,prop:r.prop||"value",value:a,read:r.read||null,write:r.write||null}):r.kind==="text"?t.operations.push({type:"text",target:r.target,data:a}):t.operations.push({type:"attr",target:r.target,name:r.name,value:a??null}),null):b("target-detached",e.targets):b("unsupported",e.targets)}function Mt(e,n,t){if(!v(e.parent)||!L(e.parent,t))return b("target-detached",e.targets);if(n){if(!q(M(t,e.parent),e.seqAfter))return b("structure-changed",e.targets);let l=Pe(e.nodes,t.isProtected);if(l.length>0)return b("protected",l);for(let c=0;c<e.nodes.length;c++)if(K(e.nodes[c],t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[c])return b("content-changed",e.targets);for(let c of e.nodes)t.operations.push({type:"remove",node:c}),t.planned.set(c,!1);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!q(M(t,e.parent),e.seqBefore))return b("structure-changed",e.targets);for(let l of e.nodes)if(l.parentNode)return b("structure-changed",e.targets);let r=e.nodes.flatMap(l=>Z(l));if(r.length>0&&Oe(r,t))return b("duplicate-id",e.targets);let i=U(e.seqBefore,e.slot);if(i==null)return b("unsupported",e.targets);let a=e.seqBefore.slice(),s=i;for(let l of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:l,beforeId:a[s]??null}),a=a.slice(0,s).concat(T(l),a.slice(s)),s+=1,t.planned.set(l,!0);return t.sim.set(e.parent,e.seqAfter.slice()),null}function Lt(e,n,t){if(!v(e.parent)||!L(e.parent,t))return b("target-detached",e.targets);if(n){if(!q(M(t,e.parent),e.seqAfter))return b("structure-changed",e.targets);for(let c=0;c<e.nodes.length;c++){let h=e.nodes[c];if(h.parentNode||K(h,t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[c])return b("content-changed",e.targets)}if(e.ids.length>0&&Oe(e.ids,t))return b("duplicate-id",e.targets);let a=U(e.seqAfter,e.slot);if(a==null)return b("unsupported",e.targets);let s=e.seqAfter.slice(),l=a;for(let c of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:c,beforeId:s[l]??null}),s=s.slice(0,l).concat(T(c),s.slice(l)),l+=1,t.planned.set(c,!0);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!q(M(t,e.parent),e.seqBefore))return b("structure-changed",e.targets);let r=Pe(e.nodes,t.isProtected);if(r.length>0)return b("protected",r);let i=a=>t.planned.get(a)===!0||typeof t.isIgnored=="function"&&t.isIgnored(a);for(let a=0;a<e.nodes.length;a++){let s=e.nodes[a];if(s.parentNode!==e.parent||K(s,t.ignoreAttribute,e.parent,i)!==e.content[a])return b("content-changed",e.targets)}for(let a of e.nodes)t.operations.push({type:"remove",node:a}),t.planned.set(a,!1);return t.sim.set(e.parent,e.seqAfter.slice()),null}function qt(e,n){let t=e.indexOf(n);return t<0?null:e.slice(0,t).concat(e.slice(t+1))}function zt(e,n,t){let r=T(e.node),i=n?e.destParent:e.sourceParent,a=n?e.sourceParent:e.destParent,s=M(t,i),l=M(t,a),c=n?e.dest.after:e.source.before,h=n?e.source.after:e.dest.before,p=n?e.sourceSlot:e.destSlot;if(!v(i)||!v(a)||!L(i,t)||!L(a,t))return b("target-detached",e.targets);if(!q(s,c))return b("structure-changed",e.targets);let y=i===a?qt(l,r):l;if(!q(y,h))return b("structure-changed",e.targets);let w=U(h,p);return w==null?b("unsupported",e.targets):(t.operations.push({type:"insert",parent:a,node:e.node,beforeId:h[w]??null}),t.planned.set(e.node,!0),n?(t.sim.set(a,e.source.before.slice()),i!==a&&t.sim.set(i,e.dest.before.slice())):(t.sim.set(a,e.dest.after.slice()),i!==a&&t.sim.set(i,e.source.after.slice())),null)}function q(e,n){if(!e||!n||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function Kt(e,n){for(let t of e.childNodes||[])if(T(t)===n)return t;return null}function Ve(e,n){typeof e.write=="function"?e.write(e.target,n):e.target[e.prop]=n}function xe(e){let n=[];try{for(let t of e)$t(t,n);return{ok:!0}}catch(t){for(let r=n.length-1;r>=0;r--)try{n[r]()}catch{}return{ok:!1,error:t}}}function $t(e,n){if(e.type==="attr"){let t=e.target.getAttribute(e.name);e.value==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,e.value),n.push(()=>{t==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,t)});return}if(e.type==="text"){let t=e.target.data;e.target.data=e.data,n.push(()=>{e.target.data=t});return}if(e.type==="value"){let t=typeof e.read=="function"?e.read(e.target):e.target[e.prop];Ve(e,e.value),n.push(()=>Ve(e,t));return}if(e.type==="insert"){let t=e.beforeId==null?null:Kt(e.parent,e.beforeId);if(e.beforeId!=null&&!t)throw new Error("hyper-undo: replay anchor vanished");let r=e.node.parentNode,i=e.node.nextSibling;e.parent.insertBefore(e.node,t),n.push(()=>{r?r.insertBefore(e.node,i&&i.parentNode===r?i:null):e.node.parentNode===e.parent&&e.parent.removeChild(e.node)});return}if(e.type==="remove"){let t=e.node.parentNode;if(!t)throw new Error("hyper-undo: replay target is no longer attached");let r=e.node.nextSibling;t.removeChild(e.node),n.push(()=>t.insertBefore(e.node,r))}}var Bt=['[src^="chrome-extension://"]','[href^="chrome-extension://"]','[src^="moz-extension://"]','[href^="moz-extension://"]','[src^="safari-web-extension://"]','[href^="safari-web-extension://"]','[id="1p-menu-live-region"]',"com-1password-button","com-1password-menu","com-1password-notification","grammarly-extension","grammarly-desktop-integration","lt-div","lt-card","lt-toolbar","lt-highlighter","[data-lastpass-root]","[data-lastpass-icon-root]","[data-dashlane-shadowhost]","[data-klarna-extension]",'[class*="klarna-extension"]',".skiptranslate","#goog-gt-tt",".goog-te-banner-frame",".goog-te-balloon-frame","style.darkreader","style[data-darkreader-mode]","style[data-darkreader-scheme]","#loom-companion-mv3","loom-container","[ext-id]"],Dt=["data-grammarly","data-lt","data-1p","data-com-onepassword","data-lastpass","data-lp","data-kwimpala","data-bitwarden","data-bw","data-dashlane","data-np","data-protonpass","data-proton-pass","data-keeper","data-rf","data-roboform","data-honey","data-rakuten","data-capital-one","data-wikibuy","data-klarna","data-darkreader","data-evernote","data-pocket","data-pin"],_e=Bt.join(","),Me=new RegExp("^(?:"+Dt.join("|")+")(?:-|$)");var an=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Ut=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),jt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function j(e,n){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(n)||e.hasAttribute?.(n))}function Q(e,n){if(j(e,n))return!0;for(let[t,r]of Object.entries(Ut))if(r.includes(n)&&j(e,t))return!0;return!1}function Le(e){return e==="clay"||jt.includes(e)}var Ft=["mutations-ignore","save-remove","save-ignore","save-freeze","no-undo","no-watch"];function Wt(){if(typeof window>"u")return null;let e=window.clay?.region||window.hyperclay?.region;return e&&typeof e.resolveRegionPolicy=="function"?e.resolveRegionPolicy:null}function ee(e){let n=Wt();if(n)try{if(!n(e).undoable)return!0}catch{}let t=e&&e.nodeType!==1?e.parentElement:e;if(t&&t.closest&&t.closest(_e))return!0;for(;t&&t.nodeType===1;){if(Q(t,"no-undo")||Q(t,"no-watch"))return!0;for(let r of Ft)if(j(t,r))return!0;t=t.parentElement}return!1}function Xt(e){let n=e.target,t=n.cloneNode(!1),r=t;for(;n.parentElement;){n=n.parentElement;let i=n.cloneNode(!1);i.appendChild(t),t=i}return e.oldValue==null?r.removeAttribute(e.attributeName):r.setAttribute(e.attributeName,e.oldValue),ee(r)}function F(e,n,t){if(t?.type==="attributes"&&Le(t.attributeName)){if(ee(e)&&Xt(t))return!0}else if(ee(e))return!0;if(t&&t.type==="attributes"){if(t.attributeName&&Me.test(t.attributeName.toLowerCase()))return!0;if(n)try{if(n(t.attributeName,t.target))return!0}catch{}}return!1}function qe(){let e=new Map;function n(i,a){let s=e.get(i);return s||(s=new Set,e.set(i,s)),s.add(a),()=>t(i,a)}function t(i,a){let s=e.get(i);s&&s.delete(a)}function r(i,a){let s=e.get(i);if(s)for(let l of Array.from(s))try{l(a)}catch(c){console.error("[hyper-undo] listener threw",c)}}return{on:n,off:t,emit:r}}var Ht={maxHistory:100,idleWindowMs:500,idleLabel:"Edit",recording:"automatic",ignoreAttribute:null,isProtected:null,ignoreNode:null,debug:!1};function te(e){let n={...Ht,...e};if(!n.scope)throw new Error("hyper-undo: scope is required");let t=qe(),r=[],i=[],a=`u${Math.random().toString(36).slice(2,8)}`,s=0,l=null,c=[],h=null,p=null,y=0,w=!1,P=n.recording==="commands"?"commands":"automatic",A=null,C=!1;function k(...o){n.debug&&console.log("[hyper-undo]",...o)}function De(){w||(w=!0,p=Ue(R),p.observe(n.scope,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),k("started"))}function Ue(o){let u=typeof document<"u"&&n.scope===document.body,d=typeof window<"u"&&(window.clay?.Mutation||window.hyperclay?.Mutation)||null;return u&&d&&typeof d.createObserver=="function"?(k("sourcing records from the platform Mutation hub (shared observer)"),d.createObserver(o)):new MutationObserver(o)}function ie(){w&&(w=!1,p&&(p.disconnect(),p=null),O(),r.length=0,i.length=0,c=[],l=null,A=null,C=!1,y=0,k("stopped"))}function je(){let o=n.scope;return!!(o&&o.nodeType===1&&o.isConnected===!1)}function R(o){ae(o,!1)}function ae(o,u){if(A){for(let f of o)A.records.push(f);return}if(P==="commands"||y>0)return;let d=W(Fe(o),u);if(d.length>0){for(let f of d)c.push(f);ue()}}function Fe(o){return typeof n.ignoreNode!="function"?o:o.filter(u=>{if(u.type!=="childList")return!0;let d=[...u.addedNodes,...u.removedNodes];return d.length===0?!0:!d.every(f=>We(f))})}function We(o){try{return!!n.ignoreNode(o)}catch{return!1}}function W(o,u=!1){let d=lt(o),f=o.filter(g=>(G(g.target)||d(g.target)||u&&ke(g.target))&&!F(g.target,n.ignoreAttribute,g));return Ee(f,g=>F(g,n.ignoreAttribute))}function ue(){O(),h=setTimeout(se,n.idleWindowMs)}function O(){h!=null&&(clearTimeout(h),h=null)}function se(){if(h=null,c.length===0)return;let o=c;c=[],$(n.idleLabel,o)}function $(o,u){let d=Ce(u,{isIgnored:X,ignoreAttribute:le});if(d.steps.length===0)return k("commit",o,"with nothing to record"),t.emit("commit"),null;let f={id:`${a}-${++s}`,label:o,timestamp:Date.now(),primitives:u,certificate:d};for(r.push(f),i.length=0,l=null;r.length>n.maxHistory;)r.shift();return k("commit",o,"primitives:",u.length),t.emit("commit"),f}function X(o){return F(o,n.ignoreAttribute)}function le(o,u,d=null){if(typeof n.ignoreAttribute!="function")return!1;try{return!!n.ignoreAttribute(o,u,d)}catch{return!1}}function Xe(o){if(typeof n.isProtected!="function")return!1;try{return!!n.isProtected(o)}catch{return!1}}function He(o,u){if(!w)throw new Error("hyper-undo: scope not started");if(P==="commands")return fe(o,u,{honorPause:!0,receipt:!1});R(p.takeRecords()),x();let d=y===0?de():null,f=u();if(f&&typeof f.then=="function")throw new Error("hyper-undo: commit() fn must be synchronous; returned a Promise");if(ae(p.takeRecords(),!0),d!=null&&ce(d),c.length===0){t.emit("commit");return}O();let g=c;c=[],$(o,g)}function Je(o){if(!w)throw new Error("hyper-undo: scope not started");if(!p)return;if(y>1){p.takeRecords();return}x();let u=W(p.takeRecords(),!0);u.length!==0&&(O(),$(o,u))}function Ge(){p&&p.takeRecords()}function H(){let o=n.scope;return o&&o.ownerDocument||(typeof document<"u"?document:null)}function B(){let o=H();return!o||!o.head||typeof o.head.querySelector!="function"?null:o.head.querySelector("title")}function de(){let o=B();return o?o.textContent:null}function ce(o){let u=B();if(!u||o==null)return;let d=u.textContent;d!==o&&pe({kind:"value",target:u,prop:"textContent",oldValue:o,newValue:d})}function Ye(o){if(!o)return null;let u=H();if(!u||o.target!==u||o.prop!=="title")return o;let d=B();return d?{kind:"value",target:d,prop:"textContent",oldValue:o.oldValue,newValue:o.newValue}:null}function Ze(){if(typeof window>"u")return!1;let o=window.clay?.effect||window.hyperclay?.effect;return!!(o&&o.running)}function Qe(){p&&R(p.takeRecords()),x(),A={records:[],primitives:[]}}function et(){let o=A;if(A=null,!o)return[];let u=W(o.records,!0);for(let d of o.primitives)u.push(d);return u}function fe(o,u,{honorPause:d,receipt:f}){if(typeof u!="function")throw new Error("hyper-undo: command() needs a synchronous function");if(A)throw new Error("hyper-undo: command() cannot nest inside another command");if(C)throw new Error("hyper-undo: command() cannot run during undo or redo");if(Ze())throw new Error("hyper-undo: command() cannot run inside a derived-effect context");if(u.constructor&&u.constructor.name==="AsyncFunction")throw new Error("hyper-undo: command() fn must be synchronous; it was declared async");let g=d&&y>0,N=g?null:de();Qe();let S=[],V=null,_;try{try{_=u()}catch(ve){V=ve}if(p&&R(p.takeRecords()),_&&typeof _.then=="function"){try{_.then(void 0,()=>{})}catch{}V||(V=new Error("hyper-undo: command() fn must be synchronous; returned a Promise"))}g||ce(N)}finally{S=et()}let D=g||S.length===0?null:$(o,S);if(V)throw V;return f?D?{id:D.id,label:D.label}:null:D}function tt(o,u){if(!w)throw new Error("hyper-undo: scope not started");return fe(o,u,{honorPause:!1,receipt:!0})}function nt(o){if(o!=="automatic"&&o!=="commands")throw new Error("hyper-undo: setRecording() takes 'automatic' or 'commands'");if(A)throw new Error("hyper-undo: setRecording() cannot change while a command is running");return P===o||(x(),P=o,k("recording",o)),P}function me(o){if(!w||!o||!A&&(y>0||P==="commands"))return;let u=Ye(o);u&&pe(u)}function pe(o){if(A){A.primitives.push(o);return}c.push(o),ue()}function rt(o,{prop:u="value",oldValue:d,newValue:f,read:g,write:N}={}){!o||d===f||me({kind:"value",target:o,prop:u,oldValue:d,newValue:f,read:g,write:N})}function x(){y===0&&p&&R(p.takeRecords()),c.length!==0&&(O(),se())}function ge(){y===0&&p&&R(p.takeRecords()),y++,k("paused",y)}function he(){y!==0&&(y--,y===0&&p&&p.takeRecords(),k("resumed",y))}function ye(o,u){if(je())return ie(),{ok:!1,code:"disconnected"};x();let d=o==="undo"?r:i,f=o==="undo"?i:r,g=d.at(-1);if(!g)return{ok:!1,code:"empty"};if(u&&u!==g.id){let _=be(u)||g;return J(_,o,"stale-entry")}let N;C=!0;try{N=Re(g.certificate,o,{isIgnored:X,ignoreAttribute:le,isProtected:Xe,inScope:dt,liveNodesWithIds:ct})}finally{C=!1}if(!N.ok)return J(g,o,N.code,N.targets);ge();let S;C=!0;try{S=xe(N.operations)}finally{C=!1,he()}if(!S.ok)return k(`${o} failed and was rolled back`,S.error),J(g,o,"replay-error");d.pop(),f.push(g),l=null;let V={ok:!0,entryId:g.id,label:g.label,direction:o};return k(o,g.label),t.emit(o,V),V}function ot(o){return ye("undo",o&&o.entryId)}function it(o){return ye("redo",o&&o.entryId)}function be(o){return r.find(u=>u.id===o)||i.find(u=>u.id===o)||null}function J(o,u,d,f=[]){return l={entryId:o.id,direction:u,code:d,targets:f},k("refused",u,d),t.emit("refused",{entryId:o.id,label:o.label,direction:u,code:d,targets:f}),{ok:!1,code:d,entryId:o.id,label:o.label,direction:u}}function at(o){if(!l||l.entryId!==o)return{ok:!1,code:"not-refused",entryId:o};let u=l.direction,d=u==="undo"?r:i,f=d.at(-1);return!f||f.id!==o?{ok:!1,code:"stale-entry",entryId:o}:(d.pop(),l=null,k("discarded",f.label),t.emit("discard",{entryId:o,label:f.label,direction:u}),{ok:!0,entryId:o,direction:u})}function ut(o){let u=be(o);if(!u||!u.certificate||!u.certificate.replayable)return null;let d=l&&l.entryId===u.id?{direction:l.direction,code:l.code,targets:(l.targets||[]).map(f=>({id:f.id??null,kind:f.kind??null}))}:null;return{id:u.id,label:u.label,timestamp:u.timestamp,refused:d,steps:u.certificate.steps.map(st)}}function st(o){if(o.type==="move")return{kind:"move",node:{id:E(o.node).id},from:{id:E(o.sourceParent).id},to:{id:E(o.destParent).id}};if(o.type==="add"||o.type==="restore")return{kind:o.type==="add"?"add":"remove",parent:{id:E(o.parent).id},nodes:o.nodes.map((N,S)=>({id:E(N).id,html:o.content[S]??null}))};let u=o.primitive,d={id:E(u.target).id},f=u.oldValue??null,g=u.newValue??null;return o.type==="value"?{kind:"value",target:d,prop:u.prop??"value",before:f,after:g}:o.type==="text"?{kind:"text",target:d,before:f,after:g}:o.type==="attr-set"||o.type==="attr-add"||o.type==="attr-remove"?{kind:"attribute",target:d,name:u.name??null,before:f,after:g}:{kind:o.type,target:d,before:f,after:g}}function lt(o){let u=new Set,d=!0;for(;d;){d=!1;for(let f of o)if(!(f.type!=="childList"||!f.removedNodes?.length)&&!(!G(f.target)&&!we(f.target,u)))for(let g of f.removedNodes)u.has(g)||(u.add(g),d=!0)}return f=>!G(f)&&we(f,u)}function we(o,u){for(let d=o;d;d=d.parentNode)if(u.has(d))return!0;return!1}function G(o){let u=n.scope;return!u||!o?!1:o===u||typeof u.contains=="function"&&u.contains(o)}function ke(o){let u=H(),d=u&&u.head;if(!d||!o)return!1;let f=o.nodeType===1?o:o.parentElement;for(;f&&f!==d;f=f.parentElement)if(f.localName==="title")return!1;return f===d}function dt(o){let u=n.scope;return!o||!u?!1:o===u||B()===o||ke(o)?!0:typeof u.contains=="function"?u.contains(o):!1}function ct(o){let u=n.scope;if(!o||o.length===0||typeof u?.querySelectorAll!="function")return[];let d=new Set(o),f=[];for(let g of u.querySelectorAll("[data-id]"))d.has(g.getAttribute("data-id"))&&(X(g)||f.push(g));return f}function ft(){p&&p.takeRecords(),r.length=0,i.length=0,c=[],l=null,O(),k("cleared"),t.emit("clear")}return{_config:n,start:De,stop:ie,commit:He,commitCaptured:Je,discardCaptured:Ge,flush:x,command:tt,setRecording:nt,record:me,recordValue:rt,undo:ot,redo:it,clear:ft,discard:at,describe:ut,pause:ge,resume:he,on:t.on,off:t.off,get canUndo(){return r.length>0},get canRedo(){return i.length>0},get isPaused(){return y>0},get history(){return r.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return l&&l.entryId===o.id&&(u.refused={direction:l.direction,code:l.code,targets:l.targets}),u})},get future(){return i.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return l&&l.entryId===o.id&&(u.refused={direction:l.direction,code:l.code,targets:l.targets}),u}).reverse()},get scope(){return n.scope}}}var Jt=new Set(["checkbox","radio","button","submit","reset","image","file","range","color"]);function Gt(e){let n=typeof e.composedPath=="function"?e.composedPath():[],t=n.length>0?n:Yt(e.target);for(let r of t){if(!r||r.nodeType!==1)continue;let i=String(r.tagName||"").toUpperCase();if(i==="TEXTAREA"||i==="SELECT"||i==="INPUT"&&!Jt.has(String(r.type||r.getAttribute?.("type")||"text").toLowerCase())||r.isContentEditable===!0)return!0;let a=r.getAttribute&&r.getAttribute("contenteditable");if(a!=null&&String(a).toLowerCase()!=="false")return!0}return!1}function Yt(e){let n=[];for(let t=e;t;t=t.parentNode||(t.host??null))n.push(t);return n}function ze(e,n){let t=r=>{let i=e.scope;if(i&&i.nodeType===1&&i.isConnected===!1){n&&n();return}if(r.defaultPrevented||r.isComposing||r.keyCode===229||Gt(r))return;let a=r.target,s=e._config.shadowKeydownIn;if(a&&a.closest&&Array.isArray(s))for(let h of s)try{if(a.closest(h))return}catch{}if(!(r.metaKey||r.ctrlKey))return;let c=(r.key||"").toLowerCase();if(c==="z"&&!r.shiftKey){r.preventDefault(),r.stopPropagation(),e.undo();return}if(c==="z"&&r.shiftKey){r.preventDefault(),r.stopPropagation(),e.redo();return}if(c==="y"&&!r.shiftKey){r.preventDefault(),r.stopPropagation(),e.redo();return}};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)}var ne=[".CodeMirror",".cm-editor",".monaco-editor",".ace_editor",".ql-editor",".tiptap",".ProseMirror",".overtype-input","[data-richclay-active]"],m=null,re=null,Ke=null,I=null;function $e(e,n){if(I){if(I.inst===e)return I.cleanup;throw new Error("hyper-undo: another scope already owns the global Cmd+Z binding (bindKeys: true). Stop it first, or use bindKeys: false for additional scopes.")}let t=ze(e,n);return I={inst:e,cleanup:t},t}function Be(e){I&&I.inst===e&&(I.cleanup(),I=null)}var oe={defaults:{shadowKeydownIn:ne},start(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");if(m){if(re===n)return console.warn("[hyper-undo] start() called again on existing singleton; ignoring new options"),m;throw new Error("hyper-undo: start() called with a different scope while the singleton is already started. Use undo.create({ scope }) for additional scopes, or call undo.stop() first.")}let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||ne};return m=te(t),m.start(),re=n,e.bindKeys!==!1&&(Ke=$e(m,()=>oe.stop())),m},stop(){m&&(Be(m),Ke=null,m.stop(),m=null,re=null)},create(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||ne},r=te(t),i=null,a={_config:r._config,commit:r.commit,command:r.command,setRecording:r.setRecording,commitCaptured:r.commitCaptured,discardCaptured:r.discardCaptured,flush:r.flush,record:r.record,recordValue:r.recordValue,undo:r.undo,redo:r.redo,clear:r.clear,discard:r.discard,describe:r.describe,pause:r.pause,resume:r.resume,on:r.on,off:r.off,get canUndo(){return r.canUndo},get canRedo(){return r.canRedo},get isPaused(){return r.isPaused},get history(){return r.history},get future(){return r.future},get scope(){return r.scope},start(){e.bindKeys&&(i=$e(r,()=>a.stop())),r.start()},stop(){Be(r),i=null,r.stop()}};return a},commit(e,n){return m?m.commit(e,n):void 0},command(e,n){return m?m.command(e,n):void 0},setRecording(e){return m?m.setRecording(e):void 0},commitCaptured(e){return m?m.commitCaptured(e):void 0},discardCaptured(){return m?m.discardCaptured():void 0},record(e){return m?m.record(e):void 0},recordValue(e,n){return m?m.recordValue(e,n):void 0},undo(e){return m?m.undo(e):void 0},redo(e){return m?m.redo(e):void 0},clear(){return m?m.clear():void 0},discard(e){return m?m.discard(e):void 0},describe(e){return m?m.describe(e):void 0},pause(){return m?m.pause():void 0},resume(){return m?m.resume():void 0},flush(){return m?m.flush():void 0},on(e,n){return m?m.on(e,n):void 0},off(e,n){return m?m.off(e,n):void 0},get canUndo(){return m?m.canUndo:!1},get canRedo(){return m?m.canRedo:!1},get history(){return m?m.history:[]},get future(){return m?m.future:[]},get isPaused(){return m?m.isPaused:!1}};var Zt=oe;return bt(Qt);})();
|
|
1
|
+
var hyperundo=(()=>{var he=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Bt=Object.getOwnPropertyNames;var Ft=Object.prototype.hasOwnProperty;var qt=(e,n)=>{for(var t in n)he(e,t,{get:n[t],enumerable:!0})},zt=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of Bt(n))!Ft.call(e,a)&&a!==t&&he(e,a,{get:()=>n[a],enumerable:!(o=Kt(n,a))||o.enumerable});return e};var $t=e=>zt(he({},"__esModule",{value:!0}),e);var Rn={};qt(Rn,{default:()=>Pn,endsSentence:()=>ke,undo:()=>Ne});function Ut(e,n=null){let t=[];if(e.type==="attributes"){let o=e.target,a=e.attributeName,i=e.oldValue,s=o.getAttribute(a);return i==null&&s!=null?t.push({kind:"attr-add",target:o,name:a,newValue:s}):i!=null&&s==null?t.push({kind:"attr-remove",target:o,name:a,oldValue:i}):i!==s&&t.push({kind:"attr-set",target:o,name:a,oldValue:i,newValue:s}),t}if(e.type==="characterData")return t.push({kind:"text",target:e.target,oldValue:e.oldValue,newValue:e.target.data}),t;if(e.type==="childList"){let o=e.target,a=e.nextSibling,i=e.nextSibling;for(;i&&n?.(i);)i=i.nextSibling;let s=e.previousSibling;for(;s&&n?.(s);)s=s.previousSibling;let d=n?Array.from(e.addedNodes).filter(y=>!n(y)):Array.from(e.addedNodes),f=n?Array.from(e.removedNodes).filter(y=>!n(y)):Array.from(e.removedNodes);return d.length>0&&t.push({kind:"add",parent:o,nodes:d,before:a,afterAuthored:i,beforeAuthored:s,record:e}),f.length>0&&t.push({kind:"remove",parent:o,nodes:f,before:a,afterAuthored:i,beforeAuthored:s,record:e}),t}return t}function We(e,n=null){let t=[],o=new Map;for(let a of e){if(a.type==="attributes"){let i=a.target,s=a.attributeName,d=o.get(i);d||(d=new Map,o.set(i,d)),d.has(s)||(d.set(s,{idx:t.length,oldValue:a.oldValue}),t.push(null));continue}for(let i of Ut(a,n))t.push(i)}for(let[a,i]of o)for(let[s,d]of i){let f=d.oldValue,y=a.getAttribute(s),p=null;f===y?p=null:f==null?p={kind:"attr-add",target:a,name:s,newValue:y}:y==null?p={kind:"attr-remove",target:a,name:s,oldValue:f}:p={kind:"attr-set",target:a,name:s,oldValue:f,newValue:y},t[d.idx]=p}return t.filter(a=>a!=null)}function je(e,{sameContent:n=(t,o)=>t===o}={}){let t=[],o=new Map;for(let i of e){let s=$e(i);if(s==null){t.push(i);continue}let d=o.get(i.target);d||(d=new Map,o.set(i.target,d));let f=d.get(s);if(f==null){let y=Ue(i);if(y.oldValue===y.newValue)continue;d.set(s,t.length),t.push({...i,...y})}else t[f]={...t[f],newValue:Ue(i).newValue}}let a=[];for(let i of t){if($e(i)==null){a.push(i);continue}i.oldValue!==i.newValue&&(i.kind==="value"&&i.content===!0&&n(i.oldValue,i.newValue)||a.push(jt(i)))}return a}var Wt=new Set(["attr-set","attr-add","attr-remove","text","value"]);function $e(e){return Wt.has(e.kind)?e.kind==="text"?"#text":e.kind==="value"?`#${e.prop||"value"}`:e.name==null?null:`@${e.name}`:null}function Ue(e){return e.kind==="attr-add"?{oldValue:null,newValue:e.newValue}:e.kind==="attr-remove"?{oldValue:e.oldValue,newValue:null}:{oldValue:e.oldValue,newValue:e.newValue}}function jt(e){return e.kind!=="attr-add"&&e.kind!=="attr-remove"?e:e.oldValue==null&&e.newValue!=null?{...e,kind:"attr-add"}:e.oldValue!=null&&e.newValue==null?{...e,kind:"attr-remove"}:{...e,kind:"attr-set"}}var Xe=new WeakMap,Xt=0;function _(e){let n=Xe.get(e);return n||(n=`n${++Xt}`,Xe.set(e,n)),n}function N(e){return!!e&&typeof e=="object"&&typeof e.nodeType=="number"}function Ht(e){return e.kind==="add"||e.kind==="remove"}function Ge(e,n){let t=[],o=e.childNodes;if(!o)return t;for(let a of o)n&&n(a)||t.push(_(a));return t}function He(e,n,t){if(typeof n!="function"||!N(e)||e.nodeType!==1)return null;let o=null;try{o=n(e,t)}catch{o=null}return typeof o=="string"?`#form:${JSON.stringify(o)}`:null}function Q(e,n,t=null,o=null,a=null,i=null){if(!N(e))return null;let s=He(e,a,t);if(s!=null)return s;if(e.nodeType===3)return`#text:${JSON.stringify(i&&i.has(e)?i.get(e):e.data)}`;if(e.nodeType===8)return`#comment:${JSON.stringify(e.data)}`;if(e.nodeType!==1)return`#node:${e.nodeType}`;let d=[];if(e.attributes){for(let p of e.attributes)Jt(p.name,e,n,t)||d.push(`${p.name}=${JSON.stringify(p.value)}`);d.sort()}let f=[];if(e.childNodes)for(let p of e.childNodes){let w=He(p,a,t);if(w!=null){f.push(w);continue}Yt(p,o)||f.push(Q(p,n,t,o,a,i))}return`<${String(e.tagName||"").toLowerCase()}${d.length?` ${d.join(" ")}`:""}>${f.join("")}</>`}function ye(e,n=[]){if(!N(e))return n;if(e.nodeType===1){let t=e.getAttribute&&e.getAttribute("data-id");t&&n.push(t)}if(e.childNodes)for(let t of e.childNodes)ye(t,n);return n}function Jt(e,n,t,o=null){if(typeof t!="function")return!1;try{return!!t(e,n,o)}catch{return!1}}function Yt(e,n){if(typeof n!="function")return!1;try{return!!n(e)}catch{return!1}}function Ze(e,n){if(typeof n!="function")return[];let t=[],o=a=>{if(!N(a))return;let i=!1;try{i=!!n(a)}catch{i=!1}if(i&&t.push(I(a,"protected")),a.childNodes)for(let s of a.childNodes)o(s)};for(let a of e)o(a);return t}function I(e,n,t=null){let o=e;o&&o.nodeType!==1&&(o=o.parentElement);let a=o&&typeof o.closest=="function"?o.closest("[data-id]"):null;return!a&&t&&typeof t.closest=="function"&&(a=t.closest("[data-id]")),{id:(a?a.getAttribute("data-id"):null)||null,kind:n||null}}function Gt(e,n,t=null){return(e||[]).filter(N).map(o=>I(o,n,t))}function Z(e){return{replayable:!1,reason:e,steps:[]}}function ie(e,n){let t=[[n.afterAuthored,a=>a],[n.beforeAuthored,a=>a+1],[n.before,a=>a]],o=!1;for(let[a,i]of t){if(!N(a))continue;o=!0;let s=e.indexOf(_(a));if(s>=0)return i(s)}return o?null:e.length}function Qe(e,n={}){let t=n.isIgnored||null,o=n.ignoreAttribute||null,a=n.durableForm||null,i=je(e,{sameContent:ae}),s=[];for(let w of i){if(!Ht(w)){if(!N(w.target))return Z("non-dom-target");continue}if(!N(w.parent))return Z("non-dom-parent");let k=Array.from(w.nodes||[]).filter(N);if(k.length!==0){if(k.length!==Array.from(w.nodes||[]).length)return Z("non-dom-node");s.push({primitive:w,nodes:k,parent:w.parent})}}if(Zt(s))return Z("in-record-move");let d=Qt(s,t);if(!d)return Z("ambiguous-structure");let f=en(s,d),y=new Map(s.map(w=>[w.primitive,w])),p=[];for(let w of i){let k=y.get(w);if(!k){p.push(nn(w));continue}let A=f.get(k);if(A){A.at===k&&p.push(A.step);continue}p.push(tn(k,d.get(k),o,t,a))}return{replayable:!0,reason:null,steps:p}}function Zt(e){let n=new Map;for(let t of e){let o=t.primitive.record;if(!o)continue;let a=n.get(o);a||(a=new Map,n.set(o,a));for(let i of t.nodes){let s=a.get(i);s||(s=new Set,a.set(i,s)),s.add(t.primitive.kind)}}for(let t of n.values())for(let o of t.values())if(o.size>1)return!0;return!1}function Qt(e,n){let t=new Map;for(let a of e)t.has(a.parent)||t.set(a.parent,Ge(a.parent,n));let o=new Map;for(let a=e.length-1;a>=0;a--){let i=e[a],s=t.get(i.parent);if(!s)return null;let d=s.slice(),f;if(i.primitive.kind==="add"){let y=i.nodes.map(_);if(!y.every(p=>s.includes(p)))return null;f=s.filter(p=>!y.includes(p))}else{let y=ie(d,i.primitive);if(y==null)return null;f=d.slice(),f.splice(y,0,...i.nodes.map(_))}o.set(i,{before:f,after:d}),t.set(i.parent,f)}return o}function en(e,n){let t=new Map,o=new Map;e.forEach((i,s)=>{for(let d of i.nodes){let f=_(d);i.primitive.kind==="remove"?t.set(f,{item:i,index:s,node:d}):o.set(f,{item:i,index:s,node:d})}});let a=new Map;for(let[i,s]of t){let d=o.get(i);if(!d||d.index<s.index||s.item.nodes.length!==1||d.item.nodes.length!==1)continue;let f={type:"move",node:s.node,sourceParent:s.item.parent,destParent:d.item.parent,source:n.get(s.item),dest:n.get(d.item),sourceSlot:s.item.primitive,destSlot:d.item.primitive,targets:[I(s.node,"move")]};a.set(s.item,{step:f,at:d.item}),a.set(d.item,{step:f,at:d.item})}return a}function tn(e,n,t,o,a=null){let i=e.primitive.kind;return{type:i==="add"?"add":"restore",parent:e.parent,nodes:e.nodes,seqBefore:n.before,seqAfter:n.after,slot:e.primitive,content:e.nodes.map(s=>Q(s,t,e.parent,o,a)),ids:i==="remove"?e.nodes.flatMap(s=>ye(s)):[],targets:Gt(e.nodes,i==="add"?"added":"removed",e.parent)}}function nn(e){return{type:e.kind,primitive:e,targets:[I(e.target,e.name||e.prop||"text")]}}function et(e,n,t={}){if(!e||!e.replayable)return{ok:!1,code:"unsupported",targets:[]};let o={isIgnored:t.isIgnored||null,ignoreAttribute:t.ignoreAttribute||null,durableForm:t.durableForm||null,isProtected:t.isProtected||null,inScope:t.inScope||(()=>!0),liveNodesWithIds:t.liveNodesWithIds||(()=>[]),sim:new Map,planned:new Map,texts:new Map,operations:[]};for(let a=0;a<e.steps.length;a++){let i=e.steps[n==="undo"?e.steps.length-1-a:a],s=on(i,n,o);if(s)return{ok:!1,code:s.code,targets:s.targets}}return{ok:!0,operations:o.operations}}function X(e,n){return e.sim.has(n)||e.sim.set(n,Ge(n,e.isIgnored)),e.sim.get(n)}function H(e,n){for(let t=e;t;t=t.parentNode)if(n.planned.has(t))return n.planned.get(t);return n.inScope(e)}function tt(e,n){return n.liveNodesWithIds(e).filter(t=>H(t,n)).length>0}function b(e,n){return{code:e,targets:n||[]}}function ae(e,n){return e===n?!0:typeof e!="string"||typeof n!="string"?!1:e.replace(/\u00A0| /g," ")===n.replace(/\u00A0| /g," ")}function rn(e){return e.kind==="text"?e.target.data:e.kind==="value"?typeof e.read=="function"?e.read(e.target):e.target[e.prop||"value"]:e.target.getAttribute(e.name)}function on(e,n,t){let o=n==="undo";return e.type==="move"?dn(e,o,t):e.type==="add"?un(e,o,t):e.type==="restore"?sn(e,o,t):an(e,o,t)}function an(e,n,t){let o=e.primitive,a=n?o.newValue:o.oldValue,i=n?o.oldValue:o.newValue;if(!N(o.target))return b("unsupported",e.targets);if(!H(o.target,t))return b("target-detached",e.targets);if(o.kind==="value"&&typeof o.write=="function"&&typeof o.read!="function")return b("unsupported",e.targets);let s=rn(o);return(o.content===!0?!ae(s,a):s!==a)?b("content-changed",e.targets):(o.kind==="value"?t.operations.push({type:"value",target:o.target,prop:o.prop||"value",value:i,read:o.read||null,write:o.write||null,content:o.content===!0}):o.kind==="text"?(t.operations.push({type:"text",target:o.target,data:i}),t.texts.set(o.target,i)):t.operations.push({type:"attr",target:o.target,name:o.name,value:i??null}),null)}function un(e,n,t){if(!N(e.parent)||!H(e.parent,t))return b("target-detached",e.targets);if(n){if(!J(X(t,e.parent),e.seqAfter))return b("structure-changed",e.targets);let d=Ze(e.nodes,t.isProtected);if(d.length>0)return b("protected",d);for(let f=0;f<e.nodes.length;f++)if(Q(e.nodes[f],t.ignoreAttribute,e.parent,t.isIgnored,t.durableForm)!==e.content[f])return b("content-changed",e.targets);for(let f of e.nodes)t.operations.push({type:"remove",node:f}),t.planned.set(f,!1);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!J(X(t,e.parent),e.seqBefore))return b("structure-changed",e.targets);for(let d of e.nodes)if(d.parentNode)return b("structure-changed",e.targets);let o=e.nodes.flatMap(d=>ye(d));if(o.length>0&&tt(o,t))return b("duplicate-id",e.targets);let a=ie(e.seqBefore,e.slot);if(a==null)return b("unsupported",e.targets);let i=e.seqBefore.slice(),s=a;for(let d of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:d,beforeId:i[s]??null}),i=i.slice(0,s).concat(_(d),i.slice(s)),s+=1,t.planned.set(d,!0);return t.sim.set(e.parent,e.seqAfter.slice()),null}function sn(e,n,t){if(!N(e.parent)||!H(e.parent,t))return b("target-detached",e.targets);if(n){if(!J(X(t,e.parent),e.seqAfter))return b("structure-changed",e.targets);for(let f=0;f<e.nodes.length;f++){let y=e.nodes[f];if(y.parentNode||Q(y,t.ignoreAttribute,e.parent,t.isIgnored,t.durableForm)!==e.content[f])return b("content-changed",e.targets)}if(e.ids.length>0&&tt(e.ids,t))return b("duplicate-id",e.targets);let i=ie(e.seqAfter,e.slot);if(i==null)return b("unsupported",e.targets);let s=e.seqAfter.slice(),d=i;for(let f of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:f,beforeId:s[d]??null}),s=s.slice(0,d).concat(_(f),s.slice(d)),d+=1,t.planned.set(f,!0);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!J(X(t,e.parent),e.seqBefore))return b("structure-changed",e.targets);let o=Ze(e.nodes,t.isProtected);if(o.length>0)return b("protected",o);let a=i=>t.planned.get(i)===!0||typeof t.isIgnored=="function"&&t.isIgnored(i);for(let i=0;i<e.nodes.length;i++){let s=e.nodes[i];if(s.parentNode!==e.parent||Q(s,t.ignoreAttribute,e.parent,a,t.durableForm,t.texts)!==e.content[i])return b("content-changed",e.targets)}for(let i of e.nodes)t.operations.push({type:"remove",node:i}),t.planned.set(i,!1);return t.sim.set(e.parent,e.seqAfter.slice()),null}function ln(e,n){let t=e.indexOf(n);return t<0?null:e.slice(0,t).concat(e.slice(t+1))}function dn(e,n,t){let o=_(e.node),a=n?e.destParent:e.sourceParent,i=n?e.sourceParent:e.destParent,s=X(t,a),d=X(t,i),f=n?e.dest.after:e.source.before,y=n?e.source.after:e.dest.before,p=n?e.sourceSlot:e.destSlot;if(!N(a)||!N(i)||!H(a,t)||!H(i,t))return b("target-detached",e.targets);if(!J(s,f))return b("structure-changed",e.targets);let w=a===i?ln(d,o):d;if(!J(w,y))return b("structure-changed",e.targets);let k=ie(y,p);return k==null?b("unsupported",e.targets):(t.operations.push({type:"insert",parent:i,node:e.node,beforeId:y[k]??null}),t.planned.set(e.node,!0),n?(t.sim.set(i,e.source.before.slice()),a!==i&&t.sim.set(a,e.dest.before.slice())):(t.sim.set(i,e.dest.after.slice()),a!==i&&t.sim.set(a,e.source.after.slice())),null)}function J(e,n){if(!e||!n||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function cn(e,n){for(let t of e.childNodes||[])if(_(t)===n)return t;return null}function Je(e,n){let t=Math.min(e.length,n.length),o=0;for(;o<t&&e[o]===n[o];)o++;let a=0;for(;a<t-o&&e[e.length-1-a]===n[n.length-1-a];)a++;return n.length-a}function Ye(e,n){typeof e.write=="function"?e.write(e.target,n):e.target[e.prop]=n}function nt(e){let n=[];try{let t=null;for(let o of e)t=fn(o,n)||t;return{ok:!0,caret:t}}catch(t){for(let o=n.length-1;o>=0;o--)try{n[o]()}catch{}return{ok:!1,error:t}}}function fn(e,n){if(e.type==="attr"){let t=e.target.getAttribute(e.name);e.value==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,e.value),n.push(()=>{t==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,t)});return}if(e.type==="text"){let t=e.target.data;return e.target.data=e.data,n.push(()=>{e.target.data=t}),{node:e.target,offset:Je(t,e.data)}}if(e.type==="value"){let t=typeof e.read=="function"?e.read(e.target):e.target[e.prop],o=e.content?e.target.textContent:null;if(Ye(e,e.value),n.push(()=>Ye(e,t)),!e.content)return;let a=e.target.textContent;return a===o?void 0:{root:e.target,textOffset:Je(o,a)}}if(e.type==="insert"){let t=e.beforeId==null?null:cn(e.parent,e.beforeId);if(e.beforeId!=null&&!t)throw new Error("hyper-undo: replay anchor vanished");let o=e.node.parentNode,a=e.node.nextSibling;return e.parent.insertBefore(e.node,t),n.push(()=>{o?o.insertBefore(e.node,a&&a.parentNode===o?a:null):e.node.parentNode===e.parent&&e.parent.removeChild(e.node)}),e.node.nodeType!==3?void 0:{node:e.node,offset:e.node.data.length}}if(e.type==="remove"){let t=e.node.parentNode;if(!t)throw new Error("hyper-undo: replay target is no longer attached");let o=e.node.nextSibling,a=Array.prototype.indexOf.call(t.childNodes,e.node);return t.removeChild(e.node),n.push(()=>t.insertBefore(e.node,o)),e.node.nodeType!==3?void 0:{node:t,offset:a}}}var pn=['[src^="chrome-extension://"]','[href^="chrome-extension://"]','[src^="moz-extension://"]','[href^="moz-extension://"]','[src^="safari-web-extension://"]','[href^="safari-web-extension://"]','[id="1p-menu-live-region"]',"com-1password-button","com-1password-menu","com-1password-notification","grammarly-extension","grammarly-desktop-integration","lt-div","lt-card","lt-toolbar","lt-highlighter","[data-lastpass-root]","[data-lastpass-icon-root]","[data-dashlane-shadowhost]","[data-klarna-extension]",'[class*="klarna-extension"]',".skiptranslate","#goog-gt-tt",".goog-te-banner-frame",".goog-te-balloon-frame","style.darkreader","style[data-darkreader-mode]","style[data-darkreader-scheme]","#loom-companion-mv3","loom-container","[ext-id]"],mn=["data-grammarly","data-lt","data-1p","data-com-onepassword","data-lastpass","data-lp","data-kwimpala","data-bitwarden","data-bw","data-dashlane","data-np","data-protonpass","data-proton-pass","data-keeper","data-rf","data-roboform","data-honey","data-rakuten","data-capital-one","data-wikibuy","data-klarna","data-darkreader","data-evernote","data-pocket","data-pin"],rt=pn.join(","),ot=new RegExp("^(?:"+mn.join("|")+")(?:-|$)");var Dn=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"]})}),gn=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),hn=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function ue(e,n){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(n)||e.hasAttribute?.(n))}function we(e,n){if(ue(e,n))return!0;for(let[t,o]of Object.entries(gn))if(o.includes(n)&&ue(e,t))return!0;return!1}function it(e){return e==="clay"||hn.includes(e)}var yn=["mutations-ignore","save-remove","save-ignore","save-freeze","no-undo","no-watch"];function wn(){if(typeof window>"u")return null;let e=window.clay?.region||window.hyperclay?.region;return e&&typeof e.resolveRegionPolicy=="function"?e.resolveRegionPolicy:null}function be(e){let n=wn();if(n)try{if(!n(e).undoable)return!0}catch{}let t=e&&e.nodeType!==1?e.parentElement:e;if(t&&t.closest&&t.closest(rt))return!0;for(;t&&t.nodeType===1;){if(we(t,"no-undo")||we(t,"no-watch"))return!0;for(let o of yn)if(ue(t,o))return!0;t=t.parentElement}return!1}function bn(e){let n=e.target,t=n.cloneNode(!1),o=t;for(;n.parentElement;){n=n.parentElement;let a=n.cloneNode(!1);a.appendChild(t),t=a}return e.oldValue==null?o.removeAttribute(e.attributeName):o.setAttribute(e.attributeName,e.oldValue),be(o)}function ee(e,n,t){if(t?.type==="attributes"&&it(t.attributeName)){if(be(e)&&bn(t))return!0}else if(be(e))return!0;if(t&&t.type==="attributes"){if(t.attributeName&&ot.test(t.attributeName.toLowerCase()))return!0;if(n)try{if(n(t.attributeName,t.target))return!0}catch{}}return!1}function at(){let e=new Map;function n(a,i){let s=e.get(a);return s||(s=new Set,e.set(a,s)),s.add(i),()=>t(a,i)}function t(a,i){let s=e.get(a);s&&s.delete(i)}function o(a,i){let s=e.get(a);if(s)for(let d of Array.from(s))try{d(i)}catch(f){console.error("[hyper-undo] listener threw",f)}}return{on:n,off:t,emit:o}}var kn=/[.?!]["'\u201D\u2019)\]]*$/,vn=new Set(["insertParagraph","insertLineBreak"]),En=new Set(["insertFromPaste","insertFromDrop","insertFromYank","insertReplacementText","deleteByCut","deleteByDrag"]),An=new Set(["Enter","Backspace","Delete"]),Sn=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function ke(e){return kn.test(e)}function ut(e,{sentence:n,endStep:t,stepOpen:o=()=>!0,composing:a}){let i=e.ownerDocument&&e.ownerDocument.defaultView;if(!i)return()=>{};let s=m=>!!m&&typeof m.nodeType=="number"&&(m===e||e.contains(m)),d=!1,f=!1,y=!1,p={kind:"other",host:null},w=m=>En.has(m)||m.startsWith("format")?"alone":m.startsWith("delete")?"delete":m.startsWith("insert")?"insert":"other",k=m=>{if(!m)return null;let T=m.nodeType===1?m:m.parentElement;return T&&T.closest&&T.closest('[contenteditable]:not([contenteditable="false"])')||m},A=()=>{d&&(d=!1,t())},S=m=>{if(!n||m.isComposing||!s(m.target))return;let T=m.inputType||"",V=w(T),Y=k(m.target),te=i.getSelection&&i.getSelection(),G=!te||te.isCollapsed,se=f;f=!1;let U=y;if(y=!1,(V==="alone"||!U&&V!==p.kind&&V!=="other"&&p.kind!=="other"||!U&&(p.host!==null&&Y!==p.host||!G||se))&&t(),p={kind:V,host:Y},V==="alone"){d=!0,setTimeout(A,0);return}let W=T==="insertText"&&(m.data===" "||m.data==="\xA0");!W&&!vn.has(T)||W&&!o()||ke(Nn(i))&&(d=!0,setTimeout(A,0))},R=m=>{s(m.target)&&A()},C=m=>{s(m.target)&&a(!0)},D=m=>{s(m.target)&&a(!1)},K=m=>{s(m.target)&&(f=!0)},B=m=>{if(!s(m.target))return;if(Sn.has(m.key)){f=!0;return}if(!n||m.isComposing||m.keyCode===229||m.ctrlKey||m.metaKey||!m.key||m.key.length!==1&&!An.has(m.key))return;let T=i.getSelection&&i.getSelection(),V=p.host!==null&&k(m.target)!==p.host;!f&&!V&&(!T||T.isCollapsed)||(t(),f=!1,y=!0,setTimeout(()=>{y=!1},0))};return e.addEventListener("beforeinput",S,!0),e.addEventListener("input",R,!0),e.addEventListener("compositionstart",C,!0),e.addEventListener("compositionend",D,!0),e.addEventListener("pointerdown",K,!0),e.addEventListener("keydown",B,!0),()=>{e.removeEventListener("beforeinput",S,!0),e.removeEventListener("input",R,!0),e.removeEventListener("compositionstart",C,!0),e.removeEventListener("compositionend",D,!0),e.removeEventListener("pointerdown",K,!0),e.removeEventListener("keydown",B,!0)}}function Nn(e){let n=e.getSelection&&e.getSelection();if(!n||!n.isCollapsed||!n.anchorNode)return"";let t=n.anchorNode,o=t.nodeType===1?t:t.parentElement,a=o&&o.closest('[contenteditable]:not([contenteditable="false"])');if(!a)return"";let i=a.ownerDocument.createRange();return i.setStart(a,0),i.setEnd(t,n.anchorOffset),i.toString().replace(/\u200B/g,"").slice(-8)}var Tn={maxHistory:100,idleWindowMs:500,idleLabel:"Edit",recording:"automatic",ignoreAttribute:null,isProtected:null,ignoreNode:null,durableForm:null,typingBreak:null,refused:null,debug:!1};function ve(e){let n={...Tn,...e};if(!n.scope)throw new Error("hyper-undo: scope is required");let t=at(),o=[],a=[],i=`u${Math.random().toString(36).slice(2,8)}`,s=0,d=null,f=[],y=null,p=null,w=0,k=!1,A=n.recording==="commands"?"commands":"automatic",S=null,R=!1,C=new WeakMap,D=!1,K=!1,B=null;function m(...r){n.debug&&console.log("[hyper-undo]",...r)}function T(){k||(k=!0,p=V(F),p.observe(n.scope,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),B=ut(n.scope,{sentence:n.typingBreak==="sentence",stepOpen:()=>(w===0&&p&&F(p.takeRecords()),f.length>0),endStep:z,composing:yt}),m("started"))}function V(r){let u=typeof document<"u"&&n.scope===document.body,l=typeof window<"u"&&(window.clay?.Mutation||window.hyperclay?.Mutation)||null;return u&&l&&typeof l.createObserver=="function"?(m("sourcing records from the platform Mutation hub (shared observer)"),l.createObserver(r)):new MutationObserver(r)}function Y(){k&&(k=!1,p&&(p.disconnect(),p=null),B&&(B(),B=null),D=!1,q(),o.length=0,a.length=0,f=[],d=null,S=null,R=!1,w=0,C=new WeakMap,m("stopped"))}function te(){let r=n.scope;return!!(r&&r.nodeType===1&&r.isConnected===!1)}function G(r,u){try{let l=u(r);return typeof l=="string"?l:null}catch{return null}}function se(r,{read:u,write:l,prop:c="content"}={}){if(!r||typeof u!="function"||typeof l!="function")return()=>{};let h={prop:c,read:u,write:l,baseline:G(r,u)};return C.set(r,h),()=>{C.get(r)===h&&C.delete(r)}}function U(r){for(let u=r;u;u=u.parentNode)if(C.has(u))return u;return null}function W(r){let u=U(r.target);return!!u&&!(r.type==="attributes"&&r.target===u)}function L(r){let u=new Set;for(let l of r)W(l)&&u.add(U(l.target));return u}function le(r){let u=[];for(let l of r){let c=C.get(l),h=G(l,c.read);if(h!=null){if(ae(h,c.baseline)){c.baseline=h;continue}c.baseline!=null&&u.push({kind:"value",target:l,prop:c.prop,oldValue:c.baseline,newValue:h,read:c.read,write:c.write,content:!0}),c.baseline=h}}return u}function j(r){for(let u of r){let l=C.get(u);l.baseline=G(u,l.read)}}function Te(r){let u=L(r);!K&&f.some(l=>l.kind==="value"?u.has(l.target):r.some(c=>c.target===l.target&&(c.type==="characterData"?l.kind==="text":c.type==="attributes"&&c.attributeName===l.name)))&&(K=!0),j(u)}function F(r){Ce(r,!1)}function Ce(r,u){if(S){for(let c of r)S.records.push(c);return}if(A==="commands"){j(L(r));return}if(w>0){Te(r);return}let l=de(gt(r),u);for(let c of le(L(r)))l.push(c);if(l.length>0){for(let c of l)f.push(c);ce()}}function gt(r){return typeof n.ignoreNode!="function"?r:r.filter(u=>{if(u.type!=="childList")return!0;let l=[...u.addedNodes,...u.removedNodes];return l.length===0?!0:!l.every(c=>ht(c))})}function ht(r){try{return!!n.ignoreNode(r)}catch{return!1}}function de(r,u=!1){let l=_t(r),c=r.filter(h=>(ge(h.target)||l(h.target)||u&&ze(h.target))&&!W(h)&&!ee(h.target,n.ignoreAttribute,h));return We(c,h=>ee(h,n.ignoreAttribute))}function yt(r){D=!!r,!D&&f.length>0&&ce()}function ce(){q(),y=setTimeout(Ie,n.idleWindowMs)}function Ie(){if(y=null,D){y=setTimeout(Ie,n.idleWindowMs);return}fe()}function q(){y!=null&&(clearTimeout(y),y=null)}function fe(){if(y=null,f.length===0)return;let r=f;f=[],ne(n.idleLabel,r)}function ne(r,u){let l=Qe(u,{isIgnored:re,ignoreAttribute:Ve,durableForm:n.durableForm});if(l.steps.length===0)return m("commit",r,"with nothing to record"),t.emit("commit"),null;let c={id:`${i}-${++s}`,label:r,timestamp:Date.now(),primitives:u,certificate:l};for(o.push(c),a.length=0,d=null;o.length>n.maxHistory;)o.shift();return m("commit",r,"primitives:",u.length),t.emit("commit"),c}function re(r){return ee(r,n.ignoreAttribute)}function Ve(r,u,l=null){if(typeof n.ignoreAttribute!="function")return!1;try{return!!n.ignoreAttribute(r,u,l)}catch{return!1}}function wt(r){if(typeof n.isProtected!="function")return!1;try{return!!n.isProtected(r)}catch{return!1}}function bt(r,u){if(!k)throw new Error("hyper-undo: scope not started");if(A==="commands")return xe(r,u,{honorPause:!0,receipt:!1});F(p.takeRecords()),z();let l=w===0?Pe():null,c=u();if(c&&typeof c.then=="function")throw new Error("hyper-undo: commit() fn must be synchronous; returned a Promise");if(Ce(p.takeRecords(),!0),l!=null&&Re(l),f.length===0){t.emit("commit");return}q();let h=f;f=[],ne(r,h)}function kt(r){if(!k)throw new Error("hyper-undo: scope not started");if(!p)return;if(w>1){j(L(p.takeRecords()));return}z();let u=p.takeRecords(),l=de(u,!0);for(let c of le(L(u)))l.push(c);l.length!==0&&(q(),ne(r,l))}function vt(){p&&j(L(p.takeRecords()))}function pe(){let r=n.scope;return r&&r.ownerDocument||(typeof document<"u"?document:null)}function oe(){let r=pe();return!r||!r.head||typeof r.head.querySelector!="function"?null:r.head.querySelector("title")}function Pe(){let r=oe();return r?r.textContent:null}function Re(r){let u=oe();if(!u||r==null)return;let l=u.textContent;l!==r&&_e({kind:"value",target:u,prop:"textContent",oldValue:r,newValue:l})}function Et(r){if(!r)return null;let u=pe();if(!u||r.target!==u||r.prop!=="title")return r;let l=oe();return l?{kind:"value",target:l,prop:"textContent",oldValue:r.oldValue,newValue:r.newValue}:null}function At(){if(typeof window>"u")return!1;let r=window.clay?.effect||window.hyperclay?.effect;return!!(r&&r.running)}function St(){p&&F(p.takeRecords()),z(),S={records:[],primitives:[]}}function Nt(){let r=S;if(S=null,!r)return[];let u=de(r.records,!0);for(let l of le(L(r.records)))u.push(l);for(let l of r.primitives)u.push(l);return u}function xe(r,u,{honorPause:l,receipt:c}){if(typeof u!="function")throw new Error("hyper-undo: command() needs a synchronous function");if(S)throw new Error("hyper-undo: command() cannot nest inside another command");if(R)throw new Error("hyper-undo: command() cannot run during undo or redo");if(At())throw new Error("hyper-undo: command() cannot run inside a derived-effect context");if(u.constructor&&u.constructor.name==="AsyncFunction")throw new Error("hyper-undo: command() fn must be synchronous; it was declared async");let h=l&&w>0,v=h?null:Pe();St();let x=[],E=null,P;try{try{P=u()}catch($){E=$}if(p&&F(p.takeRecords()),P&&typeof P.then=="function"){try{P.then(void 0,()=>{})}catch{}E||(E=new Error("hyper-undo: command() fn must be synchronous; returned a Promise"))}h||Re(v)}finally{x=Nt()}let O=h||x.length===0?null:ne(r,x);if(E)throw E;return c?O?{id:O.id,label:O.label}:null:O}function Tt(r,u){if(!k)throw new Error("hyper-undo: scope not started");return xe(r,u,{honorPause:!1,receipt:!0})}function Ct(r){if(r!=="automatic"&&r!=="commands")throw new Error("hyper-undo: setRecording() takes 'automatic' or 'commands'");if(S)throw new Error("hyper-undo: setRecording() cannot change while a command is running");return A===r||(z(),A=r,m("recording",r)),A}function Oe(r){if(!k||!r||!S&&(w>0||A==="commands"))return;let u=Et(r);u&&_e(u)}function _e(r){if(S){S.primitives.push(r);return}f.push(r),ce()}function It(r,{prop:u="value",oldValue:l,newValue:c,read:h,write:v}={}){!r||l===c||Oe({kind:"value",target:r,prop:u,oldValue:l,newValue:c,read:h,write:v})}function z(){w===0&&p&&F(p.takeRecords()),f.length!==0&&(q(),fe())}function Le(){w===0&&p&&F(p.takeRecords()),w++,m("paused",w)}function Me(){w!==0&&(w--,w===0&&p&&(Te(p.takeRecords()),K&&(K=!1,q(),fe())),m("resumed",w))}function De(r,u){if(te())return Y(),{ok:!1,code:"disconnected"};if(typeof n.holdReplay=="function"&&n.holdReplay())return{ok:!1,code:"held"};z();let l=r==="undo"?o:a,c=r==="undo"?a:o,h=[],v=l.at(-1);if(!v)return{ok:!1,code:"empty"};if(u&&u!==v.id){let E=Be(u)||v;return me(E,r,"stale-entry")}let x=n.refused==="skip"&&!u;for(;v;){let E;R=!0;try{E=et(v.certificate,r,{isIgnored:re,ignoreAttribute:Ve,durableForm:n.durableForm,isProtected:wt,inScope:Lt,liveNodesWithIds:Mt})}finally{R=!1}if(!E.ok){if(!x)return me(v,r,E.code,E.targets);Ke(v,r,E.code,E.targets,h),v=l.at(-1);continue}Le();let P;R=!0;try{P=nt(E.operations)}finally{R=!1,Me()}if(!P.ok){if(m(`${r} failed and was rolled back`,P.error),!x)return me(v,r,"replay-error");Ke(v,r,"replay-error",[],h),v=l.at(-1);continue}j(new Set(E.operations.filter($=>$.type==="value"&&C.has($.target)).map($=>$.target))),l.pop(),c.push(v),d=null;let O={ok:!0,entryId:v.id,label:v.label,direction:r};return h.length&&(O.skipped=h),P.caret&&(O.caret=P.caret),m(r,v.label),t.emit(r,O),O}return{ok:!1,code:"empty",direction:r,skipped:h}}function Ke(r,u,l,c,h){d={entryId:r.id,direction:u,code:l,targets:c};let v=Fe(r.id);(u==="undo"?o:a).pop(),d=null;let E={entryId:r.id,label:r.label,direction:u,code:l,targets:c,description:v};m("skipped",u,l),t.emit("skipped",E),h.push(E)}function Vt(r){return De("undo",r&&r.entryId)}function Pt(r){return De("redo",r&&r.entryId)}function Be(r){return o.find(u=>u.id===r)||a.find(u=>u.id===r)||null}function me(r,u,l,c=[]){return d={entryId:r.id,direction:u,code:l,targets:c},m("refused",u,l),t.emit("refused",{entryId:r.id,label:r.label,direction:u,code:l,targets:c}),{ok:!1,code:l,entryId:r.id,label:r.label,direction:u}}function Rt(r){if(!d||d.entryId!==r)return{ok:!1,code:"not-refused",entryId:r};let u=d.direction,l=u==="undo"?o:a,c=l.at(-1);return!c||c.id!==r?{ok:!1,code:"stale-entry",entryId:r}:(l.pop(),d=null,m("discarded",c.label),t.emit("discard",{entryId:r,label:c.label,direction:u}),{ok:!0,entryId:r,direction:u})}function Fe(r){let u=Be(r);if(!u||!u.certificate||!u.certificate.replayable)return null;let l=d&&d.entryId===u.id?{direction:d.direction,code:d.code,targets:(d.targets||[]).map(c=>({id:c.id??null,kind:c.kind??null}))}:null;return{id:u.id,label:u.label,timestamp:u.timestamp,refused:l,steps:u.certificate.steps.map(Ot)}}function xt(r){return typeof r!="string"?null:r.replace(/#form:("(?:[^"\\]|\\.)*")/g,(u,l)=>{try{return JSON.parse(l)}catch{return""}})}function Ot(r){if(r.type==="move")return{kind:"move",node:{id:I(r.node).id},from:{id:I(r.sourceParent).id},to:{id:I(r.destParent).id}};if(r.type==="add"||r.type==="restore")return{kind:r.type==="add"?"add":"remove",parent:{id:I(r.parent).id},nodes:r.nodes.map((v,x)=>({id:I(v).id,html:xt(r.content[x])}))};let u=r.primitive,l={id:I(u.target).id},c=u.oldValue??null,h=u.newValue??null;return r.type==="value"?{kind:"value",target:l,prop:u.prop??"value",before:c,after:h}:r.type==="text"?{kind:"text",target:l,before:c,after:h}:r.type==="attr-set"||r.type==="attr-add"||r.type==="attr-remove"?{kind:"attribute",target:l,name:u.name??null,before:c,after:h}:{kind:r.type,target:l,before:c,after:h}}function _t(r){let u=new Set,l=!0;for(;l;){l=!1;for(let c of r)if(!(c.type!=="childList"||!c.removedNodes?.length)&&!W(c)&&!(!ge(c.target)&&!qe(c.target,u))&&!ee(c.target,n.ignoreAttribute,c))for(let h of c.removedNodes)u.has(h)||(u.add(h),l=!0)}return c=>!ge(c)&&qe(c,u)}function qe(r,u){for(let l=r;l;l=l.parentNode)if(u.has(l))return!0;return!1}function ge(r){let u=n.scope;return!u||!r||typeof r.nodeType!="number"?!1:r===u||typeof u.contains=="function"&&u.contains(r)}function ze(r){let u=pe(),l=u&&u.head;if(!l||!r)return!1;let c=r.nodeType===1?r:r.parentElement;for(;c&&c!==l;c=c.parentElement)if(c.localName==="title")return!1;return c===l}function Lt(r){let u=n.scope;return!r||!u?!1:r===u||oe()===r||ze(r)?!0:typeof u.contains=="function"?u.contains(r):!1}function Mt(r){let u=n.scope;if(!r||r.length===0||typeof u?.querySelectorAll!="function")return[];let l=new Set(r),c=[];for(let h of u.querySelectorAll("[data-id]"))l.has(h.getAttribute("data-id"))&&(re(h)||c.push(h));return c}function Dt(){p&&j(L(p.takeRecords())),o.length=0,a.length=0,f=[],d=null,q(),m("cleared"),t.emit("clear")}return{_config:n,_tracksContentAt:r=>A!=="commands"&&!!U(r),_recordsAt:r=>A!=="commands"&&!re(r),start:T,stop:Y,commit:bt,commitCaptured:kt,discardCaptured:vt,flush:z,command:Tt,setRecording:Ct,record:Oe,recordValue:It,trackContent:se,undo:Vt,redo:Pt,clear:Dt,discard:Rt,describe:Fe,pause:Le,resume:Me,on:t.on,off:t.off,get canUndo(){return o.length>0},get canRedo(){return a.length>0},get isPaused(){return w>0},get history(){return o.map(r=>{let u={id:r.id,label:r.label,timestamp:r.timestamp};return d&&d.entryId===r.id&&(u.refused={direction:d.direction,code:d.code,targets:d.targets}),u})},get future(){return a.map(r=>{let u={id:r.id,label:r.label,timestamp:r.timestamp};return d&&d.entryId===r.id&&(u.refused={direction:d.direction,code:d.code,targets:d.targets}),u}).reverse()},get scope(){return n.scope}}}var Cn=new Set(["checkbox","radio","button","submit","reset","image","file","range","color"]);function dt(e){let n=typeof e.composedPath=="function"?e.composedPath():[];return n.length>0?n:Vn(e.target)}function In(e){for(let n of dt(e)){if(!n||n.nodeType!==1)continue;let t=String(n.tagName||"").toUpperCase();if(t==="TEXTAREA"||t==="SELECT"||t==="INPUT"&&!Cn.has(String(n.type||n.getAttribute?.("type")||"text").toLowerCase()))return!0}return!1}function st(e){for(let n of dt(e)){if(!n||n.nodeType!==1)continue;if(n.isContentEditable===!0)return!0;let t=n.getAttribute&&n.getAttribute("contenteditable");if(t!=null&&String(t).toLowerCase()!=="false")return!0}return!1}function Ee(e,n){if(!e||!e.closest||!Array.isArray(n))return!1;for(let t of n)try{if(e.closest(t))return!0}catch{}return!1}function lt(e,n){if(In(e))return!0;let t=n._config,o=e.target;return t.editableKeys!=="page"?st(e)||Ee(o,t.shadowKeydownIn):Ee(o,t.ownKeysIn)||n._tracksContentAt(o)?!1:Ee(o,t.shadowKeydownIn)?!0:st(e)&&!n._recordsAt(o)}function Vn(e){let n=[];for(let t=e;t;t=t.parentNode||(t.host??null))n.push(t);return n}function ct(e,n){let t=i=>{let s=e.scope;if(s&&s.nodeType===1&&s.isConnected===!1){n&&n();return}if(i.defaultPrevented||i.isComposing||i.keyCode===229||lt(i,e)||!(i.metaKey||i.ctrlKey))return;let f=(i.key||"").toLowerCase();if(f==="z"&&!i.shiftKey){i.preventDefault(),i.stopPropagation(),e.undo();return}if(f==="z"&&i.shiftKey){i.preventDefault(),i.stopPropagation(),e.redo();return}if(f==="y"&&!i.shiftKey){i.preventDefault(),i.stopPropagation(),e.redo();return}},o=i=>{if(i.inputType!=="historyUndo"&&i.inputType!=="historyRedo")return;let s=e.scope;s&&s.nodeType===1&&s.isConnected===!1||i.defaultPrevented||i.isComposing||lt(i,e)||(i.preventDefault(),i.stopPropagation(),i.inputType==="historyRedo"?e.redo():e.undo())},a=e._config.editableKeys==="page";return window.addEventListener("keydown",t,!0),a&&window.addEventListener("beforeinput",o,!0),()=>{window.removeEventListener("keydown",t,!0),a&&window.removeEventListener("beforeinput",o,!0)}}var Ae=[".CodeMirror",".cm-editor",".monaco-editor",".ace_editor",".ql-editor",".tiptap",".ProseMirror",".overtype-input","[data-richclay-active]",".ck-editor__editable","[data-lexical-editor]","[data-slate-editor]","trix-editor",".mce-content-body"],g=null,Se=null,ft=null,M=null;function pt(e,n){if(M){if(M.inst===e)return M.cleanup;throw new Error("hyper-undo: another scope already owns the global Cmd+Z binding (bindKeys: true). Stop it first, or use bindKeys: false for additional scopes.")}let t=ct(e,n);return M={inst:e,cleanup:t},t}function mt(e){M&&M.inst===e&&(M.cleanup(),M=null)}var Ne={defaults:{shadowKeydownIn:Ae},start(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");if(g){if(Se===n)return console.warn("[hyper-undo] start() called again on existing singleton; ignoring new options"),g;throw new Error("hyper-undo: start() called with a different scope while the singleton is already started. Use undo.create({ scope }) for additional scopes, or call undo.stop() first.")}let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||Ae};return g=ve(t),g.start(),Se=n,e.bindKeys!==!1&&(ft=pt(g,()=>Ne.stop())),g},stop(){g&&(mt(g),ft=null,g.stop(),g=null,Se=null)},create(e={}){let n=e.scope||(typeof document<"u"?document.body:null);if(!n)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");let t={...e,scope:n,shadowKeydownIn:e.shadowKeydownIn||Ae},o=ve(t),a=null,i={_config:o._config,commit:o.commit,command:o.command,setRecording:o.setRecording,commitCaptured:o.commitCaptured,discardCaptured:o.discardCaptured,flush:o.flush,record:o.record,recordValue:o.recordValue,trackContent:o.trackContent,undo:o.undo,redo:o.redo,clear:o.clear,discard:o.discard,describe:o.describe,pause:o.pause,resume:o.resume,on:o.on,off:o.off,get canUndo(){return o.canUndo},get canRedo(){return o.canRedo},get isPaused(){return o.isPaused},get history(){return o.history},get future(){return o.future},get scope(){return o.scope},start(){e.bindKeys&&(a=pt(o,()=>i.stop())),o.start()},stop(){mt(o),a=null,o.stop()}};return i},commit(e,n){return g?g.commit(e,n):void 0},command(e,n){return g?g.command(e,n):void 0},setRecording(e){return g?g.setRecording(e):void 0},commitCaptured(e){return g?g.commitCaptured(e):void 0},discardCaptured(){return g?g.discardCaptured():void 0},record(e){return g?g.record(e):void 0},recordValue(e,n){return g?g.recordValue(e,n):void 0},trackContent(e,n){return g?g.trackContent(e,n):()=>{}},undo(e){return g?g.undo(e):void 0},redo(e){return g?g.redo(e):void 0},clear(){return g?g.clear():void 0},discard(e){return g?g.discard(e):void 0},describe(e){return g?g.describe(e):void 0},pause(){return g?g.pause():void 0},resume(){return g?g.resume():void 0},flush(){return g?g.flush():void 0},on(e,n){return g?g.on(e,n):void 0},off(e,n){return g?g.off(e,n):void 0},get canUndo(){return g?g.canUndo:!1},get canRedo(){return g?g.canRedo:!1},get history(){return g?g.history:[]},get future(){return g?g.future:[]},get isPaused(){return g?g.isPaused:!1}};var Pn=Ne;return $t(Rn);})();
|
|
2
2
|
|
|
3
3
|
// Auto-export to window unless suppressed by loader.
|
|
4
4
|
if (!window.__hyperclayNoAutoExport) {
|