@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
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as ee}from"./c-755ZOHOM.js";import{b as Q}from"./c-3G2DGZUP.js";import{p as K,q as Z}from"./c-EHAR4RJJ.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import{a as B,h as X}from"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import"./c-IJUK2GPW.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-UW6MMZ4V.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var We=Object.defineProperty,Ve=(e,t)=>{for(var r in t)We(e,r,{get:t[r],enumerable:!0})},Fe=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],ze=new Set(Fe),_e=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),he=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),te=new Set(["checked","selected","disabled","readOnly","paused"]);function Je(e,t){return t==null?te.has(e)?!1:"":te.has(e)?t==="false"?!1:!!t:t}var Ye={};Ve(Ye,{CodecRefused:()=>et,EmptyListInsert:()=>R,MAX_RULE_DEPTH:()=>L,MaxRuleDepthExceeded:()=>G,NoRulesTag:()=>Ze,RuleTargetReadOnly:()=>ge,RulesParseError:()=>$,ShapeMismatch:()=>ye,UnknownCodec:()=>we,UnknownRulesVersion:()=>me,WriteNotRoundTripped:()=>Ke,WriteRefused:()=>Ge,WriteRejected:()=>Qe});var $=class extends Error{constructor(e,t){super(e),this.name="RulesParseError",this.cause=t}},me=class extends Error{constructor(e){super(`unknown rules version: ${e}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=e}},L=20,G=class extends Error{constructor(e){super(`rule depth exceeded ${L} at path: ${e.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=e}},ye=class extends Error{constructor(e){super(`shape mismatch: ${e.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=e}},R=class extends Error{constructor(e,t){super(t?`cannot add items to empty list at "${e.join(".")}" \u2014 ${t}`:`cannot add items to empty list at "${e.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=e}},ge=class extends Error{constructor(e){super(`cannot write to read-only DOM property "${e}"`),this.name="RuleTargetReadOnly",this.target=e}},Ge=class extends Error{constructor(e){super(`write refused: ${e.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=e}};function Xe(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:String(r),"")||"(root)"}var Ke=class extends Error{constructor(e){super(`write did not round-trip at "${Xe(e)}"`),this.name="WriteNotRoundTripped",this.path=e}},Ze=class extends Error{constructor(e){super(`no <script data-rules-name~="${e}"> rules tag in this document`),this.name="NoRulesTag",this.token=e}},Qe=class extends Error{constructor(e,t){super(`write rejected: ${e.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=e,this.unmatched=t}},we=class extends Error{constructor(e){super(`unknown codec "${e}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=e}},et=class extends Error{constructor(e,t){super(t),this.name="CodecRefused",this.code=e}};function M(e){let t=0,r=null,l=-1;for(let n=0;n<e.length;n++){let o=e[n];o==="\\"?n++:r?o===r&&(r=null):o==='"'||o==="'"?r=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(l=n)}return l}var re="[*]";function j(e){let t=M(e),r=t===-1?e:e.slice(0,t),l=r.endsWith(re),n={selector:l?r.slice(0,-re.length):r,prop:t===-1?null:e.slice(t+1)||null};return l&&(n.all=!0),n}function ve(e){let t=0,r=null,l=-1,n=!1;for(let o=0;o<e.length;o++){let i=e[o];i==="\\"?o++:r?i===r&&(r=null):i==='"'||i==="'"?r=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:t===0&&i===">"?l=o:t===0&&i===","&&(n=!0)}return n||l===-1||!tt(e,l+1)?null:e.slice(0,l).trim()||null}function tt(e,t){let r=t,l=e.replace(/\s+$/,"").length;for(;r<l&&/\s/.test(e[r]);)r++;let n=0,o=null;for(;r<l;r++){let i=e[r];if(i==="\\")r++;else if(o)i===o&&(o=null);else if(i==='"'||i==="'")o=i;else if(i==="["||i==="(")n++;else if(i==="]"||i===")")n>0&&n--;else if(n===0&&(i==="+"||i==="~"||/\s/.test(i)))return!1}return!0}var rt=/^codec\(([a-z][a-z0-9-]*)\)$/;function P(e){if(typeof e!="string")return null;let t=M(e);if(t===-1)return null;let r=rt.exec(e.slice(t+1));if(!r)return null;let{selector:l,all:n}=j(e);if(n)throw new $("A @codec(name) rule cannot use [*].");return{selector:l,name:r[1]}}var nt=/^--[A-Za-z0-9_-]+$/;function be(e){return typeof e=="string"&&nt.test(e)}function xe(e){let t=[],r=[],l=null,n=0;for(let o=0;o<e.length;o++){let i=e[o];if(l){i==="\\"?o++:i===l&&(l=null);continue}if(i==="/"&&e[o+1]==="*"){let a=e.indexOf("*/",o+2);o=a===-1?e.length:a+1;continue}i==='"'||i==="'"?l=i:i==="("?r.push(")"):i==="["?r.push("]"):i==="{"?r.push("}"):(i===")"||i==="]"||i==="}")&&r[r.length-1]===i?r.pop():i===";"&&r.length===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t}function lt(e){let t="",r=null;for(let l=0;l<e.length;l++){let n=e[l];if(r){t+=n,n==="\\"&&l+1<e.length?t+=e[++l]:n===r&&(r=null);continue}if(n==="/"&&e[l+1]==="*"){let o=e.indexOf("*/",l+2);l=o===-1?e.length:o+1,t+=" ";continue}(n==='"'||n==="'")&&(r=n),t+=n}return t}function Ae(e){e=lt(e);let t=e.indexOf(":");if(t===-1)return null;let r=e.slice(0,t).trim(),l=e.slice(t+1).trim(),n=/!\s*important\s*$/i.exec(l);return n&&(l=l.slice(0,n.index).trim()),{name:r,value:l,important:!!n}}function Te(e,t){if(e==null)return null;let r=null;for(let l of xe(String(e))){let n=Ae(l);!n||n.name!==t||(!r||n.important||!r.important)&&(r=n)}return r?r.value:null}function ot(e,t,r){let l=e==null?"":String(e),n=r==null||r==="",o=xe(l),i=o.map(Ae),a=i.some(u=>u&&u.name===t&&u.important),s=[],c=!1;o.forEach((u,d)=>{let m=i[d];if(!m||m.name!==t){s.push(u);return}if(n||c)return;let p=/^\s*/.exec(u)[0];s.push(`${p}${t}: ${r}${a?" !important":""}`),c=!0});let f=s.join(";");if(!n&&!c){let u=f.trimEnd();f=u===""?`${t}: ${r}`:`${u}${u.endsWith(";")?" ":"; "}${t}: ${r}`}return f.trim()===""?null:f}function it(e,t,r,l){let n=e.attr(t,"style");if((Te(n,r)??"")===l)return;let o=ot(n,r,l);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}var at='The @codec(name) rule form needs a rules tag with data-rules-version="2".',st="A @codec(name) rule must be the value of a top level key.";function Oe(e,t){let r=P(e);return r?{...r,codec:t.codecs[r.name]}:null}function Ee(e,t={}){let r=t.version??"1",l=t.codecs??{};n(e,0);function n(o,i){if(!(i>L)){if(typeof o=="string"){let a=P(o);if(!a)return;if(r!=="2")throw new $(at);if(i!==1)throw new $(st);if(!Object.prototype.hasOwnProperty.call(l,a.name))throw new we(a.name);return}if(Array.isArray(o)){n(o[1],i+1);return}if(o&&typeof o=="object")for(let a of Object.values(o))n(a,i+1)}}}function ke(e,t,r,l={}){if(Object.prototype.hasOwnProperty.call(l,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return Ee(r,l),V(e,t,r,{depth:0,path:[]},l)}function V(e,t,r,l,n){if(l.depth>L)throw new G(l.path);if(typeof r=="string")return ut(e,t,r,l,n);if(Array.isArray(r)){let[o,i]=r,a=e.find(t,o,n);return Ne(n,l,a),a.map((s,c)=>V(e,s,i,{depth:l.depth+1,path:[...l.path,c]},n))}if(typeof r=="object"&&r!==null){let o={};for(let[i,a]of Object.entries(r))o[i]=V(e,t,a,{depth:l.depth+1,path:[...l.path,i]},n);return o}return null}function ut(e,t,r,l,n){if(r.endsWith("[]")){let f=r.slice(0,-2),u=e.find(t,f,n);return Ne(n,l,u),u.map(d=>e.text(d))}let o=Oe(r,n);if(o)return ct(e,t,o,n);if(r.startsWith("@"))return W(e,t,r.slice(1));let i=M(r);if(i!==-1){let{selector:f,all:u}=j(r),d=r.slice(i+1),m=f?e.find(t,f,n):[t];return u&&n.allMatches?m.map(p=>W(e,p,d)):m.length===0?null:W(e,m[0],d)}if(r===".")return e.text(t);let{selector:a,all:s}=j(r),c=e.find(t,a,n);return s&&n.allMatches?c.map(f=>e.text(f)):c.length===0?null:e.text(c[0])}function ct(e,t,{selector:r,codec:l},n){let o=r?e.find(t,r,n):[t];return o.length===0?null:l.read(e,o[0],{query:n.query,view:n.view,region:n.region})}function Ne(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(l){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,l)}}function W(e,t,r){if(be(r))return Te(e.attr(t,"style"),r);if(ze.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}return e.attr(t,r)??null}function ft(e,t,r,l){let n=e.length,o=t.length,i=new Array(n).fill(-1);if(l){let h=new Set;for(let y=0;y<n;y++){let g=l[y];!(g>=0&&g<o)||h.has(g)||(i[y]=g,h.add(g))}}if(n===0||o===0)return i;let a=e.map(h=>ne(h,r)),s=t.map(h=>ne(h,r)),c=new Array(o).fill(!1);for(let h of i)h>=0&&(c[h]=!0);let f=new Map;s.forEach((h,y)=>{c[y]||f.set(h,f.has(h)?-1:y)});let u=new Map;a.forEach((h,y)=>{i[y]>=0||u.set(h,(u.get(h)||0)+1)}),a.forEach((h,y)=>{if(i[y]>=0||u.get(h)!==1)return;let g=f.get(h);g===void 0||g===-1||c[g]||(i[y]=g,c[g]=!0)});let d=[];for(let h=0;h<n;h++)i[h]<0&&d.push(h);let m=[];for(let h=0;h<o;h++)c[h]||m.push(h);if(d.length===0||m.length===0)return i;let p=n*o+1,w=dt(e,t,r),v=(h,y)=>w(h,y)*p+Math.abs(h-y);for(let[h,y]of pt(d,m,v))i[h]=y;return i}var Se=e=>typeof e=="object"&&e!==null;function ne(e,t){if(!Se(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(l=>{let n=JSON.stringify(e?.[l]);return n===void 0?" undef":n}))}function dt(e,t,r){if(!Se(r))return(a,s)=>e[a]===t[s]?0:1;let l=Object.keys(r),n=a=>l.map(s=>JSON.stringify(a?.[s])),o=e.map(n),i=t.map(n);return(a,s)=>{let c=o[a],f=i[s],u=0;for(let d=0;d<l.length;d++)c[d]!==f[d]&&u++;return u}}function pt(e,t,r){return e.length<=t.length?le(e,t,r,!1):le(t,e,(l,n)=>r(n,l),!0)}function le(e,t,r,l){let n=e.length,o=t.length,i=[];for(let u=0;u<=n;u++)i.push(new Float64Array(o+1).fill(1/0));let a=[];for(let u=0;u<=n;u++)a.push(new Uint8Array(o+1));for(let u=0;u<=o;u++)i[n][u]=0;for(let u=n-1;u>=0;u--)for(let d=o-1;d>=0;d--){let m=r(e[u],t[d])+i[u+1][d+1],p=i[u][d+1];m<=p?(i[u][d]=m,a[u][d]=1):i[u][d]=p}let s=[],c=0,f=0;for(;c<n&&f<o;)a[c][f]&&(s.push(l?[t[f],e[c]]:[e[c],t[f]]),c++),f++;return s}function Re(e,t,r,l,n,o,i,a={}){let s=e.find(t,r,a);if(n.length===0){s.forEach(A=>e.remove(A)),F(a,"onRowsApplied",o.path,[]);return}let c=n.length>s.length,f=s[0]||null;if(c&&!f&&(f=gt(e,t,r,a),!f))throw new R(o.path);let u=s.map(A=>yt(e,A,l,a)),d=null;if(c&&f){d=e.clone(f);let A=a.templateAttr&&e.attr(f,a.templateAttr)!=null;a.templateAttr&&e.removeAttr(d,a.templateAttr),A&&e.removeAttr(d,"hidden");let T=e.stripIds(d);T>0&&console.warn(`[hyper-html-api] stripped ${T} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let m=ft(n,u,l,ht(e,s,n,o,a)),p=s.length>0?e.parent(s[0]):xt(e,t,r,f,o,a),w=s.length>0?$e(e,p,s[0]):0,v=Ot(e,s),h=new Set,y=[],g=n.map((A,T)=>{let k=m[T];if(k>=0)return h.add(k),y.push(!1),s[k];y.push(!0);let O=e.clone(d);return e.stripIds(O),O});s.forEach((A,T)=>{h.has(T)||e.remove(A)}),v?Tt(e,p,w,g,y):Et(e,g,y,p,w),mt(e,g,l,n,o,i,a),F(a,"onRowsApplied",o.path,g)}function F(e,t,r,l){if(typeof e[t]=="function")try{return e[t](r.slice(),l)}catch(n){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,n);return}}function ht(e,t,r,l,n){let o=F(n,"identifyRows",l.path,r);if(!Array.isArray(o))return null;let i=new Array(r.length).fill(-1),a=new Set,s=new Map(t.map((c,f)=>[e.identity(c),f]));for(let c=0;c<r.length;c++){if(!o[c])continue;let f=s.get(e.identity(o[c]));f===void 0||a.has(f)||(i[c]=f,a.add(f))}return i}function mt(e,t,r,l,n,o,i){t.forEach((a,s)=>{if(r===null){let c=l[s],f=c==null?"":String(c);e.text(a)!==f&&e.text(a,f)}else{let c=o(e,a,r,l[s],{depth:n.depth+1,path:[...n.path,s]},i);c&&c!==a&&(t[s]=c)}})}function yt(e,t,r,l){return r===null?e.text(t):ke(e,t,r,l.onRowsRead?{...l,onRowsRead:void 0}:l)}function $e(e,t,r){let l=e.children(t);for(let n=0;n<l.length;n++)if(e.sameNode(l[n],r))return n;return-1}function gt(e,t,r,l){if(!l.templateAttr)return null;let n=/^\s*:scope\s*>\s*/.test(r),o=new RegExp(":not\\(\\["+l.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),i=r.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),a=n?wt(i):0,s=ve(i),c=t;for(;c;){let f=e.find(c,i,{includeRulesTag:!1,templateAttr:null});for(let u of f)if(e.attr(u,l.templateAttr)!=null&&!(n&&!bt(e,t,u,a))&&!(s&&!e.matches(e.parent(u),s)))return u;c=e.parent(c)}return null}function wt(e){let t=0,r=null,l=1;for(let n=0;n<e.length;n++){let o=e[n];if(o==="\\")n++;else if(r)o===r&&(r=null);else if(o==='"'||o==="'")r=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")l++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!vt(e,n))return null;for(;n+1<e.length&&/\s/.test(e[n+1]);)n++}}}return l}function vt(e,t){let r=t;for(;r<e.length&&/\s/.test(e[r]);)r++;let l=t>0?e[t-1]:"",n=r<e.length?e[r]:"";return oe(l)||oe(n)}function oe(e){return e===">"||e==="+"||e==="~"}function bt(e,t,r,l){if(l===null)return!0;let n=r;for(let s=0;s<l;s++)if(n=e.parent(n),!n)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let i=e.prop(n,"tagName");if(!i||String(i).toLowerCase()!==String(o).toLowerCase())return!1;let a=new Set(ie(e,n));return ie(e,t).every(s=>a.has(s))}function ie(e,t){let r=e.attr(t,"class");return r?String(r).split(/\s+/).filter(Boolean):[]}function xt(e,t,r,l,n,o){let i=e.parent(l);if(i&&At(e,t,i)&&!se(e,i,o))return i;let a=ve(r);if(!a)throw new R(n.path,`the list selector "${r}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let s=(a===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,a,o)).filter(c=>!se(e,c,o));if(s.length===0)throw new R(n.path,`no container matching "${a}" inside this context to hold the new rows`);if(s.length>1)throw new R(n.path,`"${a}" matches ${s.length} containers inside this context, so the new rows have no single destination`);return s[0]}function At(e,t,r){let l=r;for(;l;){if(e.sameNode(l,t))return!0;l=e.parent(l)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(n=>e.sameNode(n,r))}var ae=["no-data","editor-ui"];function se(e,t,r){let l=t;for(;l;){if(r.templateAttr&&e.attr(l,r.templateAttr)!=null||ae.some(o=>e.attr(l,o)!=null))return!0;let n=e.attr(l,"clay");if(n&&n.split(/\s+/).some(o=>ae.includes(o)))return!0;l=e.parent(l)}return!1}function Tt(e,t,r,l,n){let o=e.children(t),i=o.map(s=>e.identity(s)),a=!1;l.forEach((s,c)=>{let f=e.identity(s),u=r+c;if(i[u]===f)return;if(!n[c]){let m=i.indexOf(f);m!==-1&&(i.splice(m,1),o.splice(m,1))}let d=Math.min(u,o.length);d<o.length?e.insertBefore(o[d],s):o.length?a?e.insertAfter(o[o.length-1],s):(e.insertAt(t,s,u),a=!0):e.insertAt(t,s,0),i.splice(d,0,f),o.splice(d,0,s)})}function Ot(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let l=new Map(e.children(r).map((o,i)=>[e.identity(o),i])),n=[];for(let o of t){let i=l.get(e.identity(o));if(i===void 0)return!1;n.push(i)}return n.sort((o,i)=>o-i),n[n.length-1]-n[0]===n.length-1}function Et(e,t,r,l,n){let o=null,i=n;for(let a=0;a<t.length;a++){if(!r[a]){o=t[a];continue}let s=o?e.parent(o):l;if(!s)continue;let c=o?$e(e,s,o)+1:i++;e.insertAt(s,t[a],c),o=t[a]}}function kt(e,t,r,l,n={}){if(Object.prototype.hasOwnProperty.call(n,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");Ee(r,n);let o=[];if(z(r,l,[],o),o.length)throw new ye(o);I(e,t,r,l,{depth:0,path:[]},n)}function I(e,t,r,l,n,o={}){if(n.depth>L)throw new G(n.path);if(l===void 0)return t;if(typeof r=="string")return Nt(e,t,r,l,n,o);if(Array.isArray(r)){let[i,a]=r;return Re(e,t,i,a,l,n,I,o),t}if(typeof r=="object"&&r!==null){for(let[i,a]of Object.entries(r)){let s=I(e,t,a,l==null?l:l[i],{depth:n.depth+1,path:[...n.path,i]},o);s&&s!==t&&(t=s)}return t}return t}function Nt(e,t,r,l,n,o){if(r.endsWith("[]")){let u=r.slice(0,-2);return Re(e,t,u,null,l,n,I,o),t}let i=Oe(r,o);if(i){let u=i.selector?e.find(t,i.selector,o):[t];return u.length&&i.codec.write(e,u[0],l,{query:o.query}),t}if(r.startsWith("@"))return ce(e,t,r.slice(1),l);let a=M(r);if(a!==-1){let{selector:u,all:d}=j(r),m=r.slice(a+1),p=u?e.find(t,u,o):[t];for(let w of d?p:p.slice(0,1))ce(e,w,m,l);return t}if(r===".")return ue(e,t,l),t;let{selector:s,all:c}=j(r),f=e.find(t,s,o);for(let u of c?f:f.slice(0,1))ue(e,u,l);return t}function ue(e,t,r){let l=r==null?"":String(r);e.text(t)!==l&&e.text(t,l)}function St(e,t,r,l){if(e.styleVar){e.styleVar(t,r,l);return}it(e,t,r,l)}function ce(e,t,r,l){if(be(r))return St(e,t,r,l==null?"":String(l).trim()),t;if(he.has(r)){let n=e.prop(t,r);if(n===l||n!=null&&l!=null&&String(n)===String(l))return t;throw new ge(r)}if(r==="outerHTML"){let n=l==null?"":String(l);return e.replaceWith(t,n)}if(_e.has(r)){let n=Je(r,l);return e.prop(t,r)!==n&&e.prop(t,r,n),t}if(l==null)e.attr(t,r)!=null&&e.removeAttr(t,r);else{let n=String(l);e.attr(t,r)!==n&&e.attr(t,r,n)}return t}function z(e,t,r,l){if(t!==void 0){if(typeof e=="string"){if(P(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,o)=>{typeof n=="object"&&n!==null&&l.push({path:S([...r,o]),expected:"scalar",got:N(n)})}):l.push({path:S(r),expected:"array",got:N(t)});return}t!==null&&typeof t=="object"&&l.push({path:S(r),expected:"scalar",got:N(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){l.push({path:S(r),expected:"array",got:N(t)});return}let n=e[1];t.forEach((o,i)=>z(n,o,[...r,i],l));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){l.push({path:S(r),expected:"object",got:N(t)});return}for(let[n,o]of Object.entries(e))z(o,t[n],[...r,n],l)}}}function N(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function S(e){return e.join(".")}function Rt(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(n){let o=[],i=0;for(;i<n.length;){let a=n[i];if(/\s/.test(a)){i++;continue}if("{}".includes(a)){o.push({type:a,value:a}),i++;continue}if(a==="["){let u=!1,d=i+1;for(;d<n.length&&/\s/.test(n[d]);)d++;if(d<n.length&&/[a-zA-Z_]/.test(n[d])&&(u=!0),!u){o.push({type:a,value:a}),i++;continue}}if(a==="]"){o.push({type:a,value:a}),i++;continue}if(a===":"){o.push({type:t.COLON,value:a}),i++;continue}if(a===","){o.push({type:t.COMMA,value:a}),i++;continue}if(a==='"'||a==="'"){let u=a,d=i+1;for(;d<n.length&&n[d]!==u;)n[d]==="\\"&&d++,d++;o.push({type:t.STRING,value:n.substring(i+1,d),quoted:!0,sourceQuote:u}),i=d+1;continue}let s=i,c;for(;s<n.length&&!/[{},]/.test(n[s]);)if(n[s]===":"){let u=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],d=!1;for(let m of u){let p=m.substring(1);if(n.substring(s+1,s+1+p.length)===p){d=!0,s+=p.length;break}}if(!d)break}else if(n[s]==="["){for(s++;s<n.length&&n[s]!=="]";){if(n[s]==='"'||n[s]==="'"){let u=n[s];for(s++;s<n.length&&n[s]!==u;)n[s]==="\\"&&s++,s++}s++}s<n.length&&n[s]==="]"&&s++}else s++;c=n.substring(i,s);let f=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?f=t.NUMBER:c==="true"||c==="false"||c==="null"?f=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(f=t.SELECTOR),o.push({type:f,value:c,quoted:!1}),i=s}return o}function l(n){let o="";for(let i=0;i<n.length;i++){let a=n[i];if("{}".includes(a.type)||"[]".includes(a.type)){o+=a.value;continue}if(a.type===t.COLON){o+=a.value;continue}if(a.type===t.COMMA){let s=n[i+1];if(s&&(s.type==="}"||s.type==="]"))continue;o+=a.value;continue}if(a.type===t.STRING&&a.quoted){let s=a.value;a.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(c,f)=>f.length%2===0?f+'\\"':c)),o+=`"${s}"`;continue}if(a.type===t.NUMBER||a.type===t.BOOLEAN){o+=a.value;continue}if(a.type===t.SELECTOR||a.type===t.IDENTIFIER){o+=`"${a.value}"`;continue}o+=`"${a.value}"`}return o}try{let n=r(e),o=l(n);return JSON.parse(o)}catch(n){throw new $("Invalid extraction rules syntax: "+n.message,n)}}var $t=["1","2"];var Ar=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Tr=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),jt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);var Or=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...jt],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})});function Ct(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Lt(e){return e?(e.nodeType===9||e.nodeType,e):null}function fe(e,t,r){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=r===null?"":r:t==="checked"&&e.tagName==="INPUT"?e.checked=r!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=r!==null))}function Mt(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Ut(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let r of t)if(r.tagName==="TEXTAREA")r.value=r.defaultValue;else if(r.tagName==="INPUT"){let l=r.type;l!=="file"&&l!=="checkbox"&&l!=="radio"&&(r.value=r.defaultValue),r.checked=r.defaultChecked}else r.tagName==="OPTION"&&(r.selected=r.defaultSelected)}var It={semanticExclude:!0,find(e,t,r={}){let l=Lt(e);if(!l||!l.querySelectorAll)return[];let n=Array.from(l.querySelectorAll(t));r.includeRulesTag||(n=n.filter(a=>!Ct(a)));let o=[];r.skip&&o.push(r.skip);let i=r.templateAttr===null?null:r.templateAttr||"cms-template";if(i&&o.push("["+i+"]"),o.length){let a=o.join(", ");n=n.filter(s=>!s.closest||!s.closest(a))}return n},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Mt(e,t)},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r),fe(e,t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),fe(e,t,null)},prop(e,t,r){if(r===void 0){let l=e?e[t]:void 0;return l!==void 0?l:null}e[t]=r},clone(e){let t=e.cloneNode(!0);return Ut(t),t},insertAt(e,t,r){let l=e.children[r]||null;e.insertBefore(t,l)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let l=r.content.firstElementChild;if(!l)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(l,e),l},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};var U=It;var Pt="hha:upgrade-check:";function b(e,t){let r=e.querySelector(`meta[name="${t}"]`),l=r?r.getAttribute("content"):null;return l&&l.trim()?l.trim():null}function de(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Dt(e,t){let r=de(e),l=de(t);if(!r||!l)return!1;let n=Math.max(r.length,l.length);for(let o=0;o<n;o++){let i=r[o]||0,a=l[o]||0;if(i!==a)return i>a}return!1}function qt(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Ht(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function Bt({force:e=!1,doc:t,loc:r,fetchFn:l,now:n,ttlMs:o=864e5}={}){if(t=t||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),l=l||(d=>fetch(d)),n=n??Date.now(),!t)return null;let i=b(t,"hyper-source");if(!i)return null;let a=b(t,"hyper-version"),s;try{s=new URL(i,r?r.href:void 0)}catch{return null}if(r&&s.origin===r.origin&&s.pathname===r.pathname)return null;let c=`${Pt}${s.href}:${a||"none"}`,f,u=e?null:qt(c);if(u&&typeof u.checkedAt=="number"&&n-u.checkedAt<o)f=u.sourceVersion;else{try{let d=await l(s.href);if(!d.ok)throw new Error(`HTTP ${d.status}`);let m=await d.text(),p=new DOMParser().parseFromString(m,"text/html");f=b(p,"hyper-version")}catch{f=null}Ht(c,{checkedAt:n,sourceVersion:f})}return f?{available:Dt(f,a||"0.0.0"),currentVersion:a,sourceVersion:f,sourceUrl:s.href}:null}var Wt="script[data-rules-name]";function Vt(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function je(e,t){let r=e.find(t,Wt,{includeRulesTag:!0}),l=new Set,n=[];for(let o of r){let i=Vt(e.attr(o,"data-rules-name"));if(!i)continue;if(l.has(i)){console.warn(`hyper-html-api: duplicate rules tag name "${i}"; using the first.`);continue}let a=e.attr(o,"data-rules-version");if(!$t.includes(a))throw new me(a);l.add(i),n.push({name:i,rules:Rt(e.text(o)),version:a})}return n}function Ce(e,t){if(t!=="2"||!e||typeof e!="object"||Array.isArray(e))return{rules:e,carried:[]};let r={},l=[];for(let[n,o]of Object.entries(e)){let i=P(o);i?l.push({key:n,selector:i.selector}):r[n]=o}return{rules:r,carried:l}}function Le(e,t,r){return e.find(t,r)[0]||null}function Me(e,t){let r={};for(let{name:l,rules:n,version:o}of je(e,t)){let{rules:i,carried:a}=Ce(n,o),s=ke(e,t,i,{version:o});for(let{key:c,selector:f}of a){let u=Le(e,t,f);s[c]=u?e.prop(u,"innerHTML"):null}r[l]=s}return r}function Ft(e){let t=e||document,r=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Me(U,t),version:b(r,"hyper-version")}}var pe=class extends Error{constructor(e,t){super(`could not fetch upgrade source: ${e}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=e,this.cause=t}},zt=class extends Error{constructor(e){super(`upgrade source has no rules tags; refusing to drop all existing data: ${e}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=e}},_=class extends Error{constructor(e,t){super(e),this.name="UpgradeTransformInvalid",this.cause=t}},_t=class extends Error{constructor(e){super(`found ${e} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=e}},Jt="text/hyper-upgrade";function Yt(e,t){let r=e.find(t,`script[type="${Jt}"]`);if(r.length===0)return null;if(r.length>1)throw new _t(r.length);return e.text(r[0])||null}var Gt=new Function("url","return import(url)");async function Xt(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t),l;try{l=await Gt(r)}catch(n){throw new _(`transform failed to load: ${n&&n.message?n.message:n}`,n)}finally{URL.revokeObjectURL(r)}if(typeof l.default!="function")throw new _("transform must `export default` a function");return l.default}function Ue(e,t){let r={carriedOver:0,discarded:0,listItems:0},l=J(t,e,r);return Y(t,e,r),{data:l,summary:r}}function J(e,t,r,l=!1){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(r.listItems+=t.length,r.carriedOver+=t.length,t):l?[]:void 0:t==null||typeof t=="object"?l&&!Kt(e)?null:void 0:(r.carriedOver++,t);if(Array.isArray(e)){let[,n]=e;return Array.isArray(t)?(r.listItems+=t.length,t.map(o=>J(n,o,r,!0))):l?[]:void 0}if(typeof e=="object"&&e!==null){let n={};for(let[o,i]of Object.entries(e)){let a=J(i,t?.[o],r,l);a!==void 0&&(n[o]=a)}return n}}function Kt(e){let t=M(e);return t!==-1&&he.has(e.slice(t+1))}function Y(e,t,r){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let l=new Set(Object.keys(e));for(let n of Object.keys(t))l.has(n)?Y(e[n],t[n],r):r.discarded+=C(t[n]);return}if(Array.isArray(e)&&Array.isArray(t)){let l=e[1];t.forEach(n=>Y(l,n,r));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(r.discarded+=C(t))}}function C(e){return e==null?0:Array.isArray(e)?e.reduce((t,r)=>t+C(r),0):typeof e=="object"?Object.values(e).reduce((t,r)=>t+C(r),0):1}function Zt(e,t,r){let l=je(e,t),n={carriedOver:0,discarded:0,listItems:0},o={},i=new Set;for(let{name:a,rules:s,version:c}of l){if(i.add(a),!Object.prototype.hasOwnProperty.call(r,a)){o[a]={carriedOver:0,discarded:0,listItems:0};continue}let{rules:f,carried:u}=Ce(s,c),d=r[a],{data:m,summary:p}=Ue(Qt(d,u),f);kt(e,t,f,m,{templateAttr:"cms-template"});for(let{key:w,selector:v}of u){let h=Ie(d)?d[w]:void 0;if(h==null)continue;let y=Le(e,t,v);typeof h=="string"&&y?(e.prop(y,"innerHTML",h),p.carriedOver+=1):p.discarded+=1}o[a]=p,n.carriedOver+=p.carriedOver,n.discarded+=p.discarded,n.listItems+=p.listItems}for(let a of Object.keys(r))i.has(a)||(n.discarded+=C(r[a]));return{totals:n,byName:o,rulesTagCount:l.length}}function Ie(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Qt(e,t){if(!t.length||!Ie(e))return e;let r={...e};for(let{key:l}of t)delete r[l];return r}async function er({sourceUrl:e,dataByName:t,fromVersion:r,doc:l,loc:n,fetchFn:o}={}){if(l=l||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(h=>fetch(h)),!l)throw new Error("upgrade.run requires a document context");if(e=e||b(l,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let i=new URL(e,n?n.href:void 0);r=r!==void 0?r:b(l,"hyper-version"),t=t||Me(U,l);let a;try{a=await o(i.href)}catch(h){throw new pe(i.href,h)}if(!a.ok)throw new pe(i.href,new Error(`HTTP ${a.status}`));let s=await a.text(),c=new DOMParser().parseFromString(s,"text/html"),f=b(c,"hyper-version"),u=t,d=!1,m=Yt(U,c);if(m){let h=await(await Xt(m))(u,{fromVersion:r,toVersion:f});if(!h||typeof h!="object"||Array.isArray(h))throw new _("transform must return a plain object map of { rulesName: data }");u=h,d=!0}let{totals:p,byName:w,rulesTagCount:v}=Zt(U,c,u);if(v===0&&Object.keys(u).length>0)throw new zt(i.href);return{html:rr(c),fromVersion:r,toVersion:f,summary:{transformApplied:d,totals:p,byName:w}}}function tr(e){for(let t of e.querySelectorAll("input")){let r=(t.getAttribute("type")||"").toLowerCase();r!=="file"&&(r==="checkbox"||r==="radio"?t.checked!==t.hasAttribute("checked")&&t.toggleAttribute("checked",t.checked):t.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",t.value))}for(let t of e.querySelectorAll("textarea"))t.value!==t.textContent&&(t.textContent=t.value);for(let t of e.querySelectorAll("select")){let r=[...t.options];if(!t.multiple){let l=r.findIndex(n=>n.hasAttribute("selected"));if(t.selectedIndex===l||l===-1&&t.selectedIndex<=0)continue}for(let l of r)l.selected!==l.hasAttribute("selected")&&l.toggleAttribute("selected",l.selected)}}function rr(e){return tr(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
|
|
2
|
+
`+e.documentElement.outerHTML}var D={checkForUpdate:Bt,run:er,extractAll:Ft,shapeMatch:Ue};var x="The new version could not be downloaded. Nothing was changed.",q="The upgrade could not be saved. Nothing was changed.",qe="This document changed somewhere else. Reload and try again.",nr="Something else is changing this document. Nothing was changed.",lr="This document does not say which parts are its data, so it cannot be upgraded safely. Nothing was changed.",or="The new version has no place for this page's content. Nothing was changed.";async function ir(e){let t=globalThis.crypto&&globalThis.crypto.subtle;if(!t)return null;let r=await t.digest("SHA-256",e);return[...new Uint8Array(r)].map(l=>l.toString(16).padStart(2,"0")).join("")}async function Pe(e,t){try{let r=await e(t,{credentials:"omit"});return!r||!r.ok?null:r}catch{return null}}function ar(e,t,r){if(e&&typeof e.latestUrl=="string"&&e.latestUrl)return e.latestUrl;let l=b(t,"hyper-source");if(!l)return null;try{let n=new URL(l,r?r.href:void 0);return n.pathname=n.pathname.replace(/\.html$/,".json"),n.href}catch{return null}}function sr(e){let t=b(e,"clay-template");if(!t)return null;let[r,l]=t.split(/\s+/);return r&&l?{id:r,variant:l}:null}function H(e,t="",r=[]){if(Array.isArray(e)){for(let l of e)H(l,`${t}[]`,r);return r}if(e&&typeof e=="object"){for(let[l,n]of Object.entries(e))H(n,t?`${t}.${l}`:l,r);return r}return e!=null&&r.push({path:t,value:e}),r}function ur(e,t){let r=[e];for(let l of String(t).split(".")){let n=l.endsWith("[]"),o=n?l.slice(0,-2):l,i=[];for(let a of r){let s=o?a?.[o]:a;n?Array.isArray(s)&&i.push(...s):i.push(s)}r=i}return r}function cr(e,t,r={}){let l=new Map;for(let{path:o,value:i}of H(t)){let a=`${o}\0${String(i)}`;l.set(a,(l.get(a)||0)+1)}let n=[];for(let{path:o,value:i}of H(e)){let a=`${o}\0${String(i)}`;if(l.get(a)>0){l.set(a,l.get(a)-1);continue}let s=r[o];typeof s=="string"&&ur(t,s).some(c=>c===i)||n.push({path:o,value:i})}return n}async function fr(e){let t=new Blob([e],{type:"text/javascript"}),r=URL.createObjectURL(t);try{return await new Function("url","return import(url)")(r)}finally{URL.revokeObjectURL(r)}}async function dr(e){let r=new DOMParser().parseFromString(e,"text/html").querySelector('script[type="text/hyper-upgrade"]');if(!r)return{};let l=await fr(r.textContent||"");return l&&l.renames&&typeof l.renames=="object"?l.renames:{}}var De='script[clay~="live"][merge]';function pr(e,t,r){let l=t.querySelector("article[data-blockeditor]");if(!l)return null;l.replaceWith(t.importNode(r,!0));for(let o of e.querySelectorAll(De)){let i=o.getAttribute("merge");if(i!=="blockeditor"&&!i.startsWith("blockeditor."))continue;let a=t.importNode(o,!0),s=[...t.querySelectorAll(De)].find(c=>c.getAttribute("merge")===i);s?s.replaceWith(a):t.querySelector("article[data-blockeditor]").after(a)}return(t.doctype?`<!DOCTYPE ${t.doctype.name}>
|
|
3
|
+
`:"")+t.documentElement.outerHTML}async function He(e,{doc:t=document,loc:r=location,fetchFn:l=(n,o)=>fetch(n,o)}={}){if((typeof window<"u"&&window.clay||{}).isDraftMode)return{ok:!1,code:"draft"};if(!e||typeof e.version!="string")return{ok:!1,code:"unavailable",message:x};let o=ar(e,t,r);if(!o)return{ok:!1,code:"unavailable",message:x};let i=await Pe(l,o);if(!i)return{ok:!1,code:"unavailable",message:x};let a;try{a=await i.json()}catch{return{ok:!1,code:"unavailable",message:x}}if(!a||typeof a!="object")return{ok:!1,code:"unavailable",message:x};let s=sr(t);if(!s||a.id!==s.id||a.variant!==s.variant)return{ok:!1,code:"template",message:"This upgrade is for a different document."};let c=b(t,"hyper-version");if(!c||typeof a.version!="string"||!Q(a.version,c))return{ok:!1,code:"not-newer",message:"There is no newer version to install."};if(typeof a.html!="string"||!a.html)return{ok:!1,code:"unavailable",message:x};let f;try{f=new URL(a.html,o).href}catch{return{ok:!1,code:"unavailable",message:x}}if(!/^https:\/\/hyperclay\.com\/templates\//.test(f))return{ok:!1,code:"source",message:"This upgrade is not from the template host."};let u=await Pe(l,f);if(!u)return{ok:!1,code:"unavailable",message:x};let d;try{d=await u.text()}catch{return{ok:!1,code:"unavailable",message:x}}let m=await ir(new TextEncoder().encode(d));if(!m||m!==String(a.sha256||"").toLowerCase())return{ok:!1,code:"unavailable",message:x};let p,w;try{w=await dr(d),p=await D.run({sourceUrl:f,doc:t,loc:r,fromVersion:c,fetchFn:async()=>({ok:!0,status:200,text:async()=>d})})}catch(O){return{ok:!1,code:"transform",message:O&&O.message?O.message:x}}let v=new DOMParser().parseFromString(p.html,"text/html"),h=D.extractAll(t).dataByName,y=t.querySelector("article[data-blockeditor]");if(!y&&!Object.keys(h||{}).length)return{ok:!1,code:"undeclared",message:lr};let g=p.html;if(y){let O=pr(t,v,y);if(!O)return{ok:!1,code:"lost",lost:[],discarded:0,message:or};g=O}let A=D.extractAll(v).dataByName,T=cr(h,A,w),k=p.summary&&p.summary.totals&&p.summary.totals.discarded||0;return T.length||k>0?{ok:!1,code:"lost",lost:T,discarded:k,message:hr(T,k)}:{ok:!0,html:g,version:p.toVersion||a.version}}function hr(e,t){let r=e.slice(0,5).map(({path:n})=>n),l=e.length>r.length?` and ${e.length-r.length} more`:"";return r.length?`This upgrade would lose data: ${r.join(", ")}${l}. Nothing was changed.`:`This upgrade would lose ${t} value${t===1?"":"s"}. Nothing was changed.`}function mr(e){let t=e&&e.state;if(t==="conflict")return{ok:!1,code:"conflict",message:qe};let r=e&&e.message?e.message:"The document could not be saved.";return{ok:!1,code:"flush",state:t||"failed",message:r}}async function Be(e,{doc:t=document,loc:r=location,fetchFn:l=(s,c)=>fetch(s,c),clay:n=typeof window<"u"?window.clay:null,reload:o=()=>window.location.reload(),replace:i=null,etag:a}={}){if((n||{}).isDraftMode)return{ok:!1,code:"draft"};let c=K("upgrade");if(!c)return{ok:!1,code:"busy",message:nr};try{return await yr(e,{doc:t,loc:r,fetchFn:l,clay:n,reload:o,replace:i,etag:a})}finally{Z(c)}}async function yr(e,{doc:t,loc:r,fetchFn:l,clay:n,reload:o,replace:i,etag:a}){let s=n||{};if(s.isEditMode&&s.save&&typeof s.save.flush=="function"){let p;try{p=await s.save.flush()}catch(w){return mr(w)}if(p&&typeof p.state=="string"&&p.state!=="saved"&&p.state!=="clean"&&p.state!=="view")return{ok:!1,code:"flush",state:p.state,message:"This document has changes that could not be saved. Nothing was changed."}}if(a===void 0&&!B())try{await X()}catch{}let c=a!==void 0?a:B(),f=t;if(s.isEditMode&&typeof s.getHTML=="function")try{f=new DOMParser().parseFromString(await s.getHTML(),"text/html")}catch{return{ok:!1,code:"failed",message:q}}else f=new DOMParser().parseFromString(`<!DOCTYPE html>
|
|
4
|
+
`+t.documentElement.outerHTML,"text/html");let u=await He(e,{doc:f,loc:r,fetchFn:l});if(!u.ok)return u;let d=typeof i=="function"?i:s.save&&typeof s.save.replace=="function"?s.save.replace:ee,m;try{m=await d(u.html,{etag:c})}catch{return{ok:!1,code:"failed",message:q}}if(!m||!m.ok){let p=m&&m.code?m.code:"failed";return p==="conflict"?{ok:!1,code:p,message:qe}:p==="forbidden"?{ok:!1,code:p,message:"You are not allowed to save this document."}:p==="unsupported"?{ok:!1,code:p,message:"This host cannot save the upgrade."}:{ok:!1,code:p,message:q}}return o(),{ok:!0,html:u.html,version:u.version,etag:m.etag}}function E(e,t,r={}){let l=e.createElement(t);l.setAttribute("clay","editor-ui");for(let[n,o]of Object.entries(r))n==="style"?l.setAttribute("style",o):n==="text"?l.textContent=o:l.setAttribute(n,o);return l}function gr(e){let r=(e&&e.pathname?e.pathname:"/").split("/").filter(Boolean).pop()||"page.html";try{r=decodeURIComponent(r)}catch{}return/\.html?$/i.test(r)?r:`${r}.html`}async function wr(e,{loc:t=location,fetchFn:r=(l,n)=>fetch(l,n)}={}){if(typeof e.getHTML=="function")return e.getHTML();let l=await r(t.href,{cache:"no-store",credentials:"same-origin"});if(!l.ok)throw new Error(`copy fetch ${l.status}`);return l.text()}async function vr({clay:e,doc:t=document,loc:r=location,fetchFn:l}={}){if(typeof URL>"u"||typeof URL.createObjectURL!="function")return!1;try{let n=await wr(e,{loc:r,fetchFn:l});if(typeof n=="string"&&/clay|data-paid-only/i.test(n)){let{stripCopyContent:a}=await import("./c-C4IIQZGJ.js");n=a(n)}let o=URL.createObjectURL(new Blob([n],{type:"text/html"})),i=t.createElement("a");return i.setAttribute("clay","editor-ui"),i.href=o,i.download=gr(r),i.style.setProperty("display","none","important"),t.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(o),4e4),!0}catch{return!1}}async function br(e){let t=e&&e.host;if(!t||!t.versions)return!1;try{return await t.versions===!0}catch{return!1}}async function xr(e,t={}){let r=t.doc||document,l=t.clay||(typeof window<"u"?window.clay:null)||{};if(l.isDraftMode||!e||typeof e.version!="string")return null;let n=await br(l),o=E(r,"div",{role:"dialog","aria-modal":"true","data-clay-upgrade":"",style:"position:fixed;inset:0;z-index:2147483000;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(15,17,21,.42);font-family:system-ui,-apple-system,'Segoe UI',sans-serif;"}),i=E(r,"div",{style:"width:min(460px,100%);padding:20px;border-radius:14px;background:var(--clay-ui-bg,#fff);color:var(--clay-ui-fg,#1f2328);box-shadow:0 18px 48px -16px rgba(0,0,0,.55);font-size:14px;line-height:1.5;"}),a=E(r,"h2",{text:`Upgrade to version ${e.version}`,style:"margin:0 0 8px;font-size:16px;"}),s=E(r,"p",{text:`Your data moves into version ${e.version}. The page's layout and code are replaced; your current version stays in this document's history.`,style:"margin:0 0 16px;"}),c=E(r,"p",{role:"status",style:"margin:0 0 12px;min-height:1.5em;"}),f=E(r,"div",{style:"display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end;"}),u="padding:7px 12px;border-radius:8px;border:1px solid rgba(23,28,36,.2);background:transparent;color:inherit;font:inherit;cursor:pointer;",d=E(r,"button",{type:"button",text:"Cancel",style:u}),m=n?null:E(r,"button",{type:"button",text:"Download a copy first",style:u}),p=E(r,"button",{type:"button",text:"Upgrade",style:`${u}border-color:transparent;background:#2f6fed;color:#fff;font-weight:600;`});n||(p.disabled=!0),m&&f.append(m),f.append(d,p),i.append(a,s,c,f),o.append(i),r.body.appendChild(o);let w=!1,v=()=>{w||(w=!0,o.remove())};m&&m.addEventListener("click",async()=>{await vr({clay:l,doc:r,loc:t.loc,fetchFn:t.fetchFn})?(p.disabled=!1,c.textContent="Your copy was downloaded."):c.textContent="The copy could not be downloaded. Nothing was changed."}),d.addEventListener("click",v);let h,y=new Promise(g=>{h=g});return p.addEventListener("click",async()=>{p.disabled=!0,m&&(m.disabled=!0),c.textContent=`Upgrading to version ${e.version}\u2026`;let g=await Be(e,t);if(g.ok){v(),h(g);return}c.textContent=g.message||q,p.disabled=!1,m&&(m.disabled=!1),h(g)}),{root:o,title:a,body:s,status:c,cancel:d,download:m,upgrade:p,close:v,done:y}}export{Be as apply,He as prepare,xr as start};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as ne}from"./c-U4TWEIKZ.js";import"./c-VHNSBD2M.js";function J(e){let r=e?.name||"";return r==="QuotaExceededError"||r==="NS_ERROR_DOM_QUOTA_REACHED"?"quota":r==="VersionError"?"unknown-schema":r==="DataCloneError"?"uncloneable":r==="AbortError"||r==="TransactionInactiveError"||r==="InvalidStateError"?"aborted":r==="SecurityError"||r==="UnknownError"||r==="NotSupportedError"?"unavailable":"error"}var Te="clay-visitor-drafts",Ie=1,V="records",Q="parts",xe=2e3;function _(e,r){let d=new Error(`visitor-drafts: the draft database failed (${e})`);return d.code=e,r!==void 0&&(d.cause=r),d}function me(e,r){return new Promise((d,h)=>{let m=[],l=e.openCursor(r);l.onerror=()=>h(l.error),l.onsuccess=()=>{let s=l.result;if(!s)return d(m);m.push([s.key,s.value]),s.continue()}})}function ve({factory:e=globalThis.indexedDB,keyRange:r=globalThis.IDBKeyRange,name:d=Te,timeout:h=xe}={}){return new Promise((m,l)=>{if(!e||typeof e.open!="function"||!r)return l(_("unavailable"));let s;try{s=e.open(d,Ie)}catch(n){return l(_(J(n),n))}let b=!1,E=(n,k)=>b?!1:(b=!0,clearTimeout(a),n(k),!0),a=setTimeout(()=>E(l,_("blocked")),h);s.onupgradeneeded=()=>{let n=s.result;n.objectStoreNames.contains(V)||n.createObjectStore(V),n.objectStoreNames.contains(Q)||n.createObjectStore(Q)},s.onsuccess=()=>{let n=s.result;E(m,Ne(n,r))||n.close()},s.onerror=()=>E(l,_(J(s.error),s.error)),s.onblocked=()=>E(l,_("blocked"))})}function Ne(e,r){let d=!1;e.onversionchange=()=>{d=!0;try{e.close()}catch{}};function h(a,n){if(d)throw _("closed");try{return e.transaction(a,n)}catch(k){throw _(J(k),k)}}async function m(a){let n=h(V,"readonly"),k=r.bound(a,a+":\uFFFF");try{let v=await me(n.objectStore(V),k);return new Map(v.filter(([u])=>u===a||u.startsWith(a+":")))}catch(v){throw _(J(v),v)}}async function l(a,n){let k=h(Q,"readonly"),v=r.bound([a,n],[a,n,[]]);try{let u=await me(k.objectStore(Q),v);return new Map(u.map(([I,o])=>[I[2],o]))}catch(u){throw _(J(u),u)}}function s(a,n,{timeout:k=0,recovery:v=!1}={}){return new Promise((u,I)=>{let o;try{o=h([V,Q],"readwrite")}catch(i){return I(i)}let f=null,P,y=!1,D,C=(i,g)=>{y||(y=!0,clearTimeout(D),i(g))};k>0&&(D=setTimeout(()=>{f=_("blocked");try{o.abort()}catch{}C(I,f)},k)),o.oncomplete=()=>C(u,P),o.onabort=()=>C(I,f||_(o.error?J(o.error):"aborted",o.error));try{let i=o.objectStore(V),g=r.bound(a+":op:",a+":op:\uFFFF"),w={record:i.get(a),meta:i.get(a+":meta"),v1base:i.get(a+":v1base"),names:i.getAllKeys(g),values:i.getAll(g)},S=v?r.bound(a+":recovery:",a+":recovery:\uFFFF"):null;S&&(w.copyNames=i.getAllKeys(S),w.copyValues=i.getAll(S)),(w.copyValues??w.values).onsuccess=()=>{if(!y)try{let A={record:w.record.result??null,meta:w.meta.result??null,v1base:w.v1base.result??null,rows:w.names.result.map((N,R)=>[N,w.values.result[R]]),...S&&{recovery:w.copyNames.result.map((N,R)=>[N,w.copyValues.result[R]])}},M=n(A);for(let[N,R]of M.puts)i.put(R,N);for(let N of M.deletes)i.delete(N);P=M.result}catch(A){f=_(J(A),A);try{o.abort()}catch{}}}}catch(i){f=_(J(i),i);try{o.abort()}catch{}}})}function b(a,n){return new Promise((k,v)=>{if(!/:op:[^:]+$/.test(a))return v(_("bad-op"));let u;try{u=h(V,"readwrite"),u.objectStore(V).put(n,a),u.commit?.()}catch(I){return v(I instanceof Error&&I.code?I:_(J(I),I))}u.oncomplete=()=>k(),u.onabort=()=>v(_(u.error?J(u.error):"aborted",u.error))})}function E(){d=!0;try{e.close()}catch{}}return{readAll:m,readParts:l,change:s,putRow:b,close:E}}var x=e=>e===void 0?void 0:JSON.parse(JSON.stringify(e)),K=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Re=e=>e+":meta",ce=(e,r)=>`${e}:op:${r}`,ge=(e,r)=>r===void 0?e+":conflict":`${e}:conflict:${r}`,oe=(e,r)=>`${e}:recovery:${r}`,X=e=>K(e)&&e.v===1&&e.w===void 0&&K(e.data),L=e=>typeof e.id=="string"?e.id:"at:"+e.savedAt,we=(e,r)=>`${e}~${r}`;function Z(e){let r=/^(\d+)~/.exec(e??"");return r?Number(r[1]):null}function _e(e,r,d){let h={...e},m={...e};for(let[l,s]of Object.entries(r))"b"in s?h[l]=s.b:delete h[l],"m"in s?m[l]=s.m:delete m[l];return d(h,m,e)}var G=e=>K(e)&&typeof e.tab=="string"&&typeof e.reset=="string"&&Array.isArray(e.ops),$=e=>G(e)?`op:${e.tab}:${e.ops.at(-1)?.seq??e.acked??0}`:L(e);function se(e,r){if(K(e)&&e.v===1&&K(e.data))return x(e);if(!G(e)||!e.ops.length)return null;let d=x(r),h=null;for(let m of e.ops){for(let[l,s]of Object.entries(m.keys??{}))"m"in s?Object.defineProperty(d,l,{value:x(s.m),enumerable:!0,writable:!0,configurable:!0}):delete d[l];m.unit!==void 0&&(h=m.unit.to)}return{v:1,savedAt:e.ops.at(-1).savedAt,data:d,...h&&{live:x(h.live),blockeditor:x(h.blockeditor)}}}function fe(e,r){if(K(e)&&r.recovery?.includes($(e)))return!0;if(!G(e))return!1;let d=Math.max(e.acked??0,e.reset===r.reset?r.tabs[e.tab]?.seq??0:0);return e.ops.every(h=>h.seq<=d)}function ue(e=null){return{gen:Z(e)??1,rev:0,reset:e??"",tabs:{},foreign:null,unit:null}}var q=e=>e&&e.blockeditor?{live:e.live,blockeditor:e.blockeditor}:null;function ae(e,r,d){let h=[...e,r?.id,...r?.ancestry??[]].filter(m=>typeof m=="string");return h.length?h.slice(0,32):["root:"+d.reset]}function Me(e,{record:r,seen:d,direct:h,v1base:m,meta:l}){let s=K(d)&&d.v===1&&K(d.data)&&d.w?.reset===l.reset?d:null,b=a=>a&&typeof a.id=="string"?e.indexOf(a.id):-1,E=[[r,b(r)],[s,s&&h?0:b(s)],[m,b(m)]].filter(([,a])=>a>=0);return E.length?E.reduce((a,n)=>n[1]<a[1]?n:a)[0]:null}function De(e,{seed:r,newId:d,now:h,merge3:m,same:l,unitMark:s,marker:b=null,resets:E=[],chains:a=[],local:n=null,seen:k=null,direct:v=!1,recovery:u=null,copies:I=[]}){let o=e.meta?x(e.meta):ue(b);!e.meta&&Number.isInteger(n?.w?.rev)&&(o.rev=n.w.rev);let f=e.record?x(e.record):null,P=e.v1base?x(e.v1base):null,y={conflicts:[],recovered:[],released:[],dropped:[],stale:[],applied:{},changed:!e.meta};function D(i,g=[]){let w=$(i);if(o.recovery?.includes(w))return;y.recovered.push(x(i));let S=[w,...(o.recovery??[]).filter(A=>A!==w&&!g.includes(A))].slice(0,8);return y.dropped=[...new Set([...y.dropped,...o.recovery??[]])].filter(A=>!S.includes(A)),o.recovery=S,y.changed=!0,!0}let C=[...E];b&&b!==o.reset&&C.push({ends:Z(b)===null?null:Z(b)-1,marker:b});for(let i of C){if(i.marker===o.reset||o.ended?.includes(i.marker)||i.ends!==null&&i.ends<o.gen)continue;i.ends!==o.gen&&f&&D(f);let g=typeof n?.reset=="string"?n.reset===i.marker:i.ends===null||Array.isArray(n?.ancestry)&&n.ancestry.includes("root:"+i.marker);X(n)&&L(n)!==o.foreign&&!g&&(D(n),o.foreign=L(n)),o.ended=[...o.ended??[],o.reset].slice(-32),Object.assign(o,{gen:o.gen+1,reset:i.marker,tabs:{},unit:null}),o.rev++,f=null,P=null,y.changed=!0}if(!e.meta&&!f&&K(n)&&n.v===1&&K(n.data)&&(n.w===void 0||n.w.reset===o.reset)){let{w:i,...g}=n;f=x(g),i===void 0&&(P=x(g),o.foreign=L(n),o.rev++)}if(e.meta||(o.unit=s(q(f))),e.meta&&X(n)&&L(n)!==o.foreign){let i=L(n),g=Array.isArray(n.ancestry)?n.ancestry:[],w=f?Me(g,{record:f,seen:k,direct:v,v1base:P,meta:o}):null;if(typeof n.reset=="string"&&o.ended?.includes(n.reset))D(n,g)&&y.released.push(x(n));else if(!f)f=x(n),P=x(n),o.unit=s(q(f)),o.rev++;else if(w){let S=m(w.data,n.data,f.data),A=q(n),M=!!A&&s(A)!==s(q(w)),N=M&&q(f)&&s(q(w))!==o.unit;(S.conflict||N)&&y.conflicts.push(x(f));let R=M?A:q(f);f={v:1,savedAt:n.savedAt??new Date(h).toISOString(),id:d(),ancestry:ae(typeof n.id=="string"?[n.id]:[],f,o),data:S.value,...R&&{live:R.live,blockeditor:R.blockeditor}},M&&(o.unit=s(R)),P=x(n),o.rev++}else D(n,g)&&y.released.push(x(n));o.foreign=i,y.changed=!0}for(let i of a){if(!G(i))continue;if(i.reset!==o.reset){let S=i.reset===e.meta?.reset?e.meta.tabs[i.tab]?.seq??0:0;i.ops.some(A=>A.seq>Math.max(S,i.acked??0))&&D(i),y.stale.includes(i.tab)||y.stale.push(i.tab);continue}let g=o.tabs[i.tab]?.seq??0,w=Math.max(g,Number.isInteger(i.acked)?i.acked:0);for(let S of i.ops){if(S.seq<=w)continue;if(S.seq!==w+1)break;let A=_e(f?f.data:r,S.keys??{},m),M=S.unit!==void 0&&f&&q(f)&&S.unit.seen!==o.unit;f&&(A.conflict||M)&&y.conflicts.push(x(f));let N=S.unit!==void 0?S.unit.to:q(f),R=d();f={v:1,savedAt:S.savedAt??new Date(h).toISOString(),id:R,ancestry:ae([],f,o),data:A.value,...N&&{live:N.live,blockeditor:N.blockeditor}},S.unit!==void 0&&(o.unit=s(N)),o.rev++,w=S.seq,y.changed=!0}(w!==g||o.tabs[i.tab])&&(o.tabs[i.tab]={seq:w,at:h},y.changed=!0),y.applied[i.tab]=w}if(u){let i=I.find(([g])=>g===u.mark);if(!i)throw new Error("That draft is no longer available. Open the list again.");if(u.type==="remove")o.recovery=(o.recovery??[]).filter(g=>g!==u.mark),y.dropped.push(u.mark),y.removedMark=u.mark,y.changed=!0;else if(u.type==="restore"&&u.reset===o.reset){let g=se(i[1],r);if(!g)throw new Error("This draft cannot be restored by this version.");o.recovery?.includes(u.mark)&&(o.recovery=[u.mark,...o.recovery.filter(S=>S!==u.mark)]);let w=f&&I.some(([S,A])=>{if(!o.recovery?.includes(S))return!1;let M=se(A,r);return M&&l(f.data,M.data)&&l(q(f),q(M))});f&&!w&&D(f),f={v:1,savedAt:new Date(h).toISOString(),id:d(),ancestry:ae([],f,o),data:g.data,...g.blockeditor&&{live:g.live,blockeditor:g.blockeditor}},o.unit=s(q(f)),o.rev++,y.changed=!0,y.restoredCopy=!0}}for(let[i,g]of Object.entries(o.tabs))h-(g.at??0)>2592e6&&(delete o.tabs[i],y.changed=!0);return{meta:o,record:f,v1base:P,...y}}var z=e=>{if(e==null)return null;try{return JSON.parse(e)}catch{return null}};function ye(e,r,d,h){return e.change(r,m=>{let l={meta:z(m.meta),record:z(m.record),v1base:z(m.v1base)},s=m.rows.map(([v,u])=>[v,z(u)]),b=d(l),E=(m.recovery??[]).map(([v,u])=>[v.slice((r+":recovery:").length),z(u)]),a=De(l,{...b,copies:E,chains:[...s.map(([,v])=>v),...b.chains??[]]}),n=[],k=[];a.changed&&(n.push([Re(r),JSON.stringify(a.meta)]),a.record?n.push([r,JSON.stringify(a.record)]):l.record&&k.push(r),a.v1base?n.push([r+":v1base",JSON.stringify(a.v1base)]):l.v1base&&k.push(r+":v1base"));for(let v of a.conflicts)n.push([ge(r,L(v)),JSON.stringify(v)]);a.conflicts.length&&n.push([ge(r),JSON.stringify(a.conflicts[a.conflicts.length-1])]);for(let v of a.recovered)n.push([oe(r,$(v)),JSON.stringify(v)]);for(let v of a.dropped)k.push(oe(r,v));for(let[v,u]of s)(fe(u,a.meta)||a.removedMark&&G(u)&&$(u)===a.removedMark)&&k.push(v);return{puts:n,deletes:k,result:a}},h)}var Pe=256*1024,qe=2*1024,Je=new Set(["v","savedAt","id","ancestry","reset","data"]),Ce=10*1e3,Ke=1500,be=2e3,Le="This draft was started over in another tab.",Ve="This draft was started over in another tab. The earlier draft was kept aside in this browser.",$e="A tab that was open before an update saved another copy of this draft. That copy was kept aside, and this draft was not changed. Reload that tab to go on from this draft.",U=e=>{if(e==null)return null;try{return JSON.parse(e)}catch{return null}};function je(e,r){let d={},h=Object.keys(e).every(m=>Je.has(m));for(let[m,l]of Object.entries(e.data))JSON.stringify(l).length<qe?d[m]=l:h=!1;return JSON.stringify({v:2,savedAt:e.savedAt,id:e.id,ancestry:e.ancestry,idb:!0,...h&&{full:!0},data:d,w:r})}async function Qe({store:e,storage:r,doc:d=document,now:h=()=>Date.now(),reload:m=()=>window.location.reload()}){let l=await ve(),{key:s}=e,b=s+":reset",E=t=>{try{return r?.getItem(t)??null}catch{return null}},a=t=>{try{r?.removeItem(t)}catch{}},n=s+":started-over",k=s+":recovery-notice";try{window.sessionStorage.getItem(n)&&(window.sessionStorage.removeItem(n),window.sessionStorage.getItem(k)||import("./c-NVU3DORS.js").then(t=>t.toastPersistent(Le,"info")).catch(()=>{}))}catch{}let v=null,u="",I=null,o=null,f=null,P=0,y=!1,D=!1,C=e.held()?.id,i=null,g=null,w=new Set;try{let t=window.sessionStorage.getItem(k);if(t){window.sessionStorage.removeItem(k);let c=U(t);le({id:c?.mark??t},!!c?.reset)}}catch{}function S(t){try{window.sessionStorage.setItem(k,JSON.stringify({mark:t,reset:!0}))}catch{}}function A(t){try{window.sessionStorage.setItem(s+":generation",JSON.stringify({marker:u,reset:t}))}catch{}}function M(){let t=E(b);u=t??"";let c=e.journalSlots().filter(T=>T!==e.slotKey).map(T=>U(E(T)));f=e.stopped()?null:o,P=e.chain().ops.at(-1)?.seq??0;let p=e.held();p?.v===1&&p.w!==void 0&&(i=p);let O=f?[f]:[];return{seed:e.seed(),newId:e.newId,merge3:e.merge3,same:e.same,unitMark:e.unitMark,now:h(),marker:t,resets:O,local:p,seen:i,direct:g!==null&&E(s)===g,chains:e.pending()?[...c,e.chain()]:c}}function N(t,c){let p=h();for(let O of e.journalSlots()){if(O===e.slotKey)continue;let T=U(E(O));(c&&G(T)&&$(T)===c||fe(T,t)&&p-(T?.at??0)>Ce)&&a(O)}}function R({meta:t,record:c}){let p=e.held();if(X(p)&&L(p)!==t.foreign)return void setTimeout(Y,0);if((E(b)??"")!==t.reset)return;if(!c)return void(p&&a(s));if(p?.w&&p.w.reset===t.reset&&p.w.rev>=t.rev)return;let O={rev:t.rev,reset:t.reset},T=JSON.stringify({...c,w:O});try{if(T.length<=Pe){r.setItem(s,T),i={...c,w:O};return}}catch{}try{r.setItem(s,je(c,O))}catch{}}async function de(){if(e.stop({keepPending:!0}),e.unsafe()){try{await l.putRow(ce(s,e.tab),JSON.stringify(e.chain()))}catch(t){throw e.failed(t)}e.acknowledge(e.chain().ops.at(-1)?.seq??0)}}async function ie(t){try{e.captureLate()}catch(W){throw e.failed(W)}y=!0;let c=e.chain(),p=$(c),O=c.ops.some(W=>W.seq>P)||t.meta.recovery?.includes(p)?p:t.meta.recovery?.includes(C)?C:null;e.acknowledge(P),await de(),R(t),O&&S(O);let T=e.held();T?.w&&T.w.reset!==t.meta.reset&&a(s);try{window.sessionStorage.setItem(n,"1")}catch{}return A(t.meta.reset),y=!1,m(),t}async function Se(){let t=e.generation(),c=()=>{e.stop(),ne(!1)},p=()=>(E(b)??"")!==t&&(I===null||(E(b)??"")!==u);if(p())return c();let O=I??Z(t);if(O===null){let F=await re.catch(()=>l.change(s,({meta:H})=>({puts:[],deletes:[],result:{meta:U(H)??ue(t)}}),{timeout:be}));if(p())return c();if(O=F.meta.gen,F.meta.reset!==t){o={ends:null,marker:t};let H=await te();if(e.stopped())return c();O=H.meta.gen}}let T=we(O+1,e.newId());o={ends:O,marker:T};let W=E(s);e.held()?.w&&a(s);try{r.setItem(b,T)}catch{}let he;try{let F=te();E(b)!==T?await F:await Promise.race([F.catch(()=>{}),new Promise(H=>{he=setTimeout(H,Ke)})]),c()}catch(F){if(o=null,W!==null&&E(s)===null&&(E(b)??"")===t)try{r.setItem(s,W)}catch{}throw F}finally{clearTimeout(he)}}function le(t,c=!1){console.warn(c?"visitor-drafts: the draft was started over; the earlier draft was kept in this browser's draft database under":"visitor-drafts: a tab on an earlier ClayJS saved a copy that could not be merged exactly; it was kept in this browser's draft database under",oe(s,$(t))),!w.has(c)&&(w.add(c),import("./c-NVU3DORS.js").then(p=>p.toastPersistent(c?Ve:$e,"warning")).catch(()=>{}))}function Ee(t){let{meta:c,record:p}=t;if(u!==c.reset&&(E(b)??"")===u)try{r.setItem(b,c.reset)}catch{}if(f&&f===o&&c.reset!==e.generation()&&(f.marker===c.reset&&A(c.reset),e.stop(),ne(!1)),f===o&&(o=null),e.stopped())return y?ie(t):(R(t),t);if(t.conflicts.length&&console.warn("visitor-drafts: another tab changed the same thing; its copy was kept in this browser's draft database under",s+":conflict"),t.stale.includes(e.tab))return ie(t);if(c.reset!==e.generation()){if(!e.fresh())return ie(t);e.enter(c.reset)}t.released.length&&le(t.released[0]),I=c.gen,A(c.reset);let O=e.acknowledge(c.tabs[e.tab]?.seq??0);if(N(c,t.removedMark),R(t),e.pending()||(O&&(ne(!1),d.dispatchEvent(new CustomEvent("clay:drafts-saved",{detail:{data:p.data}}))),D))return t;if(!e.shown())return v=c.rev,t;e.changed()||(p&&c.rev!==v&&e.take(p.data),C=p?.id,v=c.rev);let T=e.externalUnit(p);return T&&d.dispatchEvent(new CustomEvent("clay:drafts-blockeditor-external",{detail:{live:T.live,adopted:()=>e.adoptedUnit(T)}})),t}let j=null,B=null;function ee(t,c=null){return j=ye(l,s,()=>{if(c?.type==="restore"){if(e.stopped())throw new Error("This page has started over. Reload it before restoring a draft.");e.captureNow()}return{...M(),recovery:c}},t).then(Ee,O=>{throw e.pending()?e.failed(O):O}).finally(()=>{j=null}),j}function te(){return B||(j?(B=j.then(()=>{},()=>{}).then(()=>(B=null,ee())),B):ee())}async function pe(t){for(;j||B;)await(B??j).catch(()=>{});return ee({recovery:!0},t)}async function ke(t){if(D)throw new Error("A draft is already being restored.");D=!0;try{if(e.stopped())throw new Error("This page has started over. Reload it before restoring a draft.");e.captureNow();let c;do if(c=await pe({type:"restore",mark:t,reset:e.generation()}),!c.restoredCopy||e.stopped())throw new Error("This page has started over. Reload it before restoring a draft.");while(e.pending());try{e.captureLate("restored:"+e.tab)}catch(p){throw e.failed(p)}return await de(),m(),c}finally{D=!1}}async function Oe(){await re.catch(()=>{});let t=s+":recovery:";return[...await l.readAll(s)].filter(([p])=>p.startsWith(t)).map(([p,O])=>({mark:p.slice(t.length),copy:U(O)}))}let Y=()=>{te().catch(()=>{})};function Ae(){e.unsafe()&&l.putRow(ce(s,e.tab),JSON.stringify(e.chain())).catch(()=>{}),e.pending()&&Y()}window.addEventListener("storage",t=>{if(t.key===s){let[c,p]=[U(t.oldValue),U(t.newValue)];p?.v===1&&p.w!==void 0?i=p:X(p)&&c?.v===1&&c.w!==void 0&&([i,g]=[c,t.newValue])}(t.key===null||t.key===s||t.key===b)&&Y()}),window.addEventListener("pageshow",t=>{t.persisted&&Y()}),d.addEventListener("clay:drafts-blockeditor-listening",Y);let re=ee({timeout:be});return re.catch(()=>{}),{first:re,sync:te,hide:Ae,startOver:Se,listRecovery:Oe,restoreRecovery:ke,recoveryRecord:t=>se(t,e.seed()),removeRecovery:t=>pe({type:"remove",mark:t})}}export{Pe as FULL_COPY_LIMIT,Qe as openSession};
|
|
1
|
+
import{l as ne}from"./c-U4TWEIKZ.js";import"./c-VHNSBD2M.js";function J(e){let r=e?.name||"";return r==="QuotaExceededError"||r==="NS_ERROR_DOM_QUOTA_REACHED"?"quota":r==="VersionError"?"unknown-schema":r==="DataCloneError"?"uncloneable":r==="AbortError"||r==="TransactionInactiveError"||r==="InvalidStateError"?"aborted":r==="SecurityError"||r==="UnknownError"||r==="NotSupportedError"?"unavailable":"error"}var Te="clay-visitor-drafts",Ie=1,V="records",Q="parts",xe=2e3;function _(e,r){let d=new Error(`visitor-drafts: the draft database failed (${e})`);return d.code=e,r!==void 0&&(d.cause=r),d}function me(e,r){return new Promise((d,h)=>{let m=[],l=e.openCursor(r);l.onerror=()=>h(l.error),l.onsuccess=()=>{let s=l.result;if(!s)return d(m);m.push([s.key,s.value]),s.continue()}})}function ve({factory:e=globalThis.indexedDB,keyRange:r=globalThis.IDBKeyRange,name:d=Te,timeout:h=xe}={}){return new Promise((m,l)=>{if(!e||typeof e.open!="function"||!r)return l(_("unavailable"));let s;try{s=e.open(d,Ie)}catch(n){return l(_(J(n),n))}let b=!1,E=(n,k)=>b?!1:(b=!0,clearTimeout(a),n(k),!0),a=setTimeout(()=>E(l,_("blocked")),h);s.onupgradeneeded=()=>{let n=s.result;n.objectStoreNames.contains(V)||n.createObjectStore(V),n.objectStoreNames.contains(Q)||n.createObjectStore(Q)},s.onsuccess=()=>{let n=s.result;E(m,Ne(n,r))||n.close()},s.onerror=()=>E(l,_(J(s.error),s.error)),s.onblocked=()=>E(l,_("blocked"))})}function Ne(e,r){let d=!1;e.onversionchange=()=>{d=!0;try{e.close()}catch{}};function h(a,n){if(d)throw _("closed");try{return e.transaction(a,n)}catch(k){throw _(J(k),k)}}async function m(a){let n=h(V,"readonly"),k=r.bound(a,a+":\uFFFF");try{let v=await me(n.objectStore(V),k);return new Map(v.filter(([u])=>u===a||u.startsWith(a+":")))}catch(v){throw _(J(v),v)}}async function l(a,n){let k=h(Q,"readonly"),v=r.bound([a,n],[a,n,[]]);try{let u=await me(k.objectStore(Q),v);return new Map(u.map(([I,o])=>[I[2],o]))}catch(u){throw _(J(u),u)}}function s(a,n,{timeout:k=0,recovery:v=!1}={}){return new Promise((u,I)=>{let o;try{o=h([V,Q],"readwrite")}catch(i){return I(i)}let f=null,P,y=!1,D,C=(i,g)=>{y||(y=!0,clearTimeout(D),i(g))};k>0&&(D=setTimeout(()=>{f=_("blocked");try{o.abort()}catch{}C(I,f)},k)),o.oncomplete=()=>C(u,P),o.onabort=()=>C(I,f||_(o.error?J(o.error):"aborted",o.error));try{let i=o.objectStore(V),g=r.bound(a+":op:",a+":op:\uFFFF"),w={record:i.get(a),meta:i.get(a+":meta"),v1base:i.get(a+":v1base"),names:i.getAllKeys(g),values:i.getAll(g)},S=v?r.bound(a+":recovery:",a+":recovery:\uFFFF"):null;S&&(w.copyNames=i.getAllKeys(S),w.copyValues=i.getAll(S)),(w.copyValues??w.values).onsuccess=()=>{if(!y)try{let A={record:w.record.result??null,meta:w.meta.result??null,v1base:w.v1base.result??null,rows:w.names.result.map((N,R)=>[N,w.values.result[R]]),...S&&{recovery:w.copyNames.result.map((N,R)=>[N,w.copyValues.result[R]])}},M=n(A);for(let[N,R]of M.puts)i.put(R,N);for(let N of M.deletes)i.delete(N);P=M.result}catch(A){f=_(J(A),A);try{o.abort()}catch{}}}}catch(i){f=_(J(i),i);try{o.abort()}catch{}}})}function b(a,n){return new Promise((k,v)=>{if(!/:op:[^:]+$/.test(a))return v(_("bad-op"));let u;try{u=h(V,"readwrite"),u.objectStore(V).put(n,a),u.commit?.()}catch(I){return v(I instanceof Error&&I.code?I:_(J(I),I))}u.oncomplete=()=>k(),u.onabort=()=>v(_(u.error?J(u.error):"aborted",u.error))})}function E(){d=!0;try{e.close()}catch{}}return{readAll:m,readParts:l,change:s,putRow:b,close:E}}var x=e=>e===void 0?void 0:JSON.parse(JSON.stringify(e)),K=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Re=e=>e+":meta",ce=(e,r)=>`${e}:op:${r}`,ge=(e,r)=>r===void 0?e+":conflict":`${e}:conflict:${r}`,oe=(e,r)=>`${e}:recovery:${r}`,X=e=>K(e)&&e.v===1&&e.w===void 0&&K(e.data),L=e=>typeof e.id=="string"?e.id:"at:"+e.savedAt,we=(e,r)=>`${e}~${r}`;function Z(e){let r=/^(\d+)~/.exec(e??"");return r?Number(r[1]):null}function _e(e,r,d){let h={...e},m={...e};for(let[l,s]of Object.entries(r))"b"in s?h[l]=s.b:delete h[l],"m"in s?m[l]=s.m:delete m[l];return d(h,m,e)}var G=e=>K(e)&&typeof e.tab=="string"&&typeof e.reset=="string"&&Array.isArray(e.ops),$=e=>G(e)?`op:${e.tab}:${e.ops.at(-1)?.seq??e.acked??0}`:L(e);function se(e,r){if(K(e)&&e.v===1&&K(e.data))return x(e);if(!G(e)||!e.ops.length)return null;let d=x(r),h=null;for(let m of e.ops){for(let[l,s]of Object.entries(m.keys??{}))"m"in s?Object.defineProperty(d,l,{value:x(s.m),enumerable:!0,writable:!0,configurable:!0}):delete d[l];m.unit!==void 0&&(h=m.unit.to)}return{v:1,savedAt:e.ops.at(-1).savedAt,data:d,...h&&{live:x(h.live),blockeditor:x(h.blockeditor)}}}function fe(e,r){if(K(e)&&r.recovery?.includes($(e)))return!0;if(!G(e))return!1;let d=Math.max(e.acked??0,e.reset===r.reset?r.tabs[e.tab]?.seq??0:0);return e.ops.every(h=>h.seq<=d)}function ue(e=null){return{gen:Z(e)??1,rev:0,reset:e??"",tabs:{},foreign:null,unit:null}}var q=e=>e&&e.blockeditor?{live:e.live,blockeditor:e.blockeditor}:null;function ae(e,r,d){let h=[...e,r?.id,...r?.ancestry??[]].filter(m=>typeof m=="string");return h.length?h.slice(0,32):["root:"+d.reset]}function Me(e,{record:r,seen:d,direct:h,v1base:m,meta:l}){let s=K(d)&&d.v===1&&K(d.data)&&d.w?.reset===l.reset?d:null,b=a=>a&&typeof a.id=="string"?e.indexOf(a.id):-1,E=[[r,b(r)],[s,s&&h?0:b(s)],[m,b(m)]].filter(([,a])=>a>=0);return E.length?E.reduce((a,n)=>n[1]<a[1]?n:a)[0]:null}function De(e,{seed:r,newId:d,now:h,merge3:m,same:l,unitMark:s,marker:b=null,resets:E=[],chains:a=[],local:n=null,seen:k=null,direct:v=!1,recovery:u=null,copies:I=[]}){let o=e.meta?x(e.meta):ue(b);!e.meta&&Number.isInteger(n?.w?.rev)&&(o.rev=n.w.rev);let f=e.record?x(e.record):null,P=e.v1base?x(e.v1base):null,y={conflicts:[],recovered:[],released:[],dropped:[],stale:[],applied:{},changed:!e.meta};function D(i,g=[]){let w=$(i);if(o.recovery?.includes(w))return;y.recovered.push(x(i));let S=[w,...(o.recovery??[]).filter(A=>A!==w&&!g.includes(A))].slice(0,8);return y.dropped=[...new Set([...y.dropped,...o.recovery??[]])].filter(A=>!S.includes(A)),o.recovery=S,y.changed=!0,!0}let C=[...E];b&&b!==o.reset&&C.push({ends:Z(b)===null?null:Z(b)-1,marker:b});for(let i of C){if(i.marker===o.reset||o.ended?.includes(i.marker)||i.ends!==null&&i.ends<o.gen)continue;i.ends!==o.gen&&f&&D(f);let g=typeof n?.reset=="string"?n.reset===i.marker:i.ends===null||Array.isArray(n?.ancestry)&&n.ancestry.includes("root:"+i.marker);X(n)&&L(n)!==o.foreign&&!g&&(D(n),o.foreign=L(n)),o.ended=[...o.ended??[],o.reset].slice(-32),Object.assign(o,{gen:o.gen+1,reset:i.marker,tabs:{},unit:null}),o.rev++,f=null,P=null,y.changed=!0}if(!e.meta&&!f&&K(n)&&n.v===1&&K(n.data)&&(n.w===void 0||n.w.reset===o.reset)){let{w:i,...g}=n;f=x(g),i===void 0&&(P=x(g),o.foreign=L(n),o.rev++)}if(e.meta||(o.unit=s(q(f))),e.meta&&X(n)&&L(n)!==o.foreign){let i=L(n),g=Array.isArray(n.ancestry)?n.ancestry:[],w=f?Me(g,{record:f,seen:k,direct:v,v1base:P,meta:o}):null;if(typeof n.reset=="string"&&o.ended?.includes(n.reset))D(n,g)&&y.released.push(x(n));else if(!f)f=x(n),P=x(n),o.unit=s(q(f)),o.rev++;else if(w){let S=m(w.data,n.data,f.data),A=q(n),M=!!A&&s(A)!==s(q(w)),N=M&&q(f)&&s(q(w))!==o.unit;(S.conflict||N)&&y.conflicts.push(x(f));let R=M?A:q(f);f={v:1,savedAt:n.savedAt??new Date(h).toISOString(),id:d(),ancestry:ae(typeof n.id=="string"?[n.id]:[],f,o),data:S.value,...R&&{live:R.live,blockeditor:R.blockeditor}},M&&(o.unit=s(R)),P=x(n),o.rev++}else D(n,g)&&y.released.push(x(n));o.foreign=i,y.changed=!0}for(let i of a){if(!G(i))continue;if(i.reset!==o.reset){let S=i.reset===e.meta?.reset?e.meta.tabs[i.tab]?.seq??0:0;i.ops.some(A=>A.seq>Math.max(S,i.acked??0))&&D(i),y.stale.includes(i.tab)||y.stale.push(i.tab);continue}let g=o.tabs[i.tab]?.seq??0,w=Math.max(g,Number.isInteger(i.acked)?i.acked:0);for(let S of i.ops){if(S.seq<=w)continue;if(S.seq!==w+1)break;let A=_e(f?f.data:r,S.keys??{},m),M=S.unit!==void 0&&f&&q(f)&&S.unit.seen!==o.unit;f&&(A.conflict||M)&&y.conflicts.push(x(f));let N=S.unit!==void 0?S.unit.to:q(f),R=d();f={v:1,savedAt:S.savedAt??new Date(h).toISOString(),id:R,ancestry:ae([],f,o),data:A.value,...N&&{live:N.live,blockeditor:N.blockeditor}},S.unit!==void 0&&(o.unit=s(N)),o.rev++,w=S.seq,y.changed=!0}(w!==g||o.tabs[i.tab])&&(o.tabs[i.tab]={seq:w,at:h},y.changed=!0),y.applied[i.tab]=w}if(u){let i=I.find(([g])=>g===u.mark);if(!i)throw new Error("That draft is no longer available. Open the list again.");if(u.type==="remove")o.recovery=(o.recovery??[]).filter(g=>g!==u.mark),y.dropped.push(u.mark),y.removedMark=u.mark,y.changed=!0;else if(u.type==="restore"&&u.reset===o.reset){let g=se(i[1],r);if(!g)throw new Error("This draft cannot be restored by this version.");o.recovery?.includes(u.mark)&&(o.recovery=[u.mark,...o.recovery.filter(S=>S!==u.mark)]);let w=f&&I.some(([S,A])=>{if(!o.recovery?.includes(S))return!1;let M=se(A,r);return M&&l(f.data,M.data)&&l(q(f),q(M))});f&&!w&&D(f),f={v:1,savedAt:new Date(h).toISOString(),id:d(),ancestry:ae([],f,o),data:g.data,...g.blockeditor&&{live:g.live,blockeditor:g.blockeditor}},o.unit=s(q(f)),o.rev++,y.changed=!0,y.restoredCopy=!0}}for(let[i,g]of Object.entries(o.tabs))h-(g.at??0)>2592e6&&(delete o.tabs[i],y.changed=!0);return{meta:o,record:f,v1base:P,...y}}var z=e=>{if(e==null)return null;try{return JSON.parse(e)}catch{return null}};function ye(e,r,d,h){return e.change(r,m=>{let l={meta:z(m.meta),record:z(m.record),v1base:z(m.v1base)},s=m.rows.map(([v,u])=>[v,z(u)]),b=d(l),E=(m.recovery??[]).map(([v,u])=>[v.slice((r+":recovery:").length),z(u)]),a=De(l,{...b,copies:E,chains:[...s.map(([,v])=>v),...b.chains??[]]}),n=[],k=[];a.changed&&(n.push([Re(r),JSON.stringify(a.meta)]),a.record?n.push([r,JSON.stringify(a.record)]):l.record&&k.push(r),a.v1base?n.push([r+":v1base",JSON.stringify(a.v1base)]):l.v1base&&k.push(r+":v1base"));for(let v of a.conflicts)n.push([ge(r,L(v)),JSON.stringify(v)]);a.conflicts.length&&n.push([ge(r),JSON.stringify(a.conflicts[a.conflicts.length-1])]);for(let v of a.recovered)n.push([oe(r,$(v)),JSON.stringify(v)]);for(let v of a.dropped)k.push(oe(r,v));for(let[v,u]of s)(fe(u,a.meta)||a.removedMark&&G(u)&&$(u)===a.removedMark)&&k.push(v);return{puts:n,deletes:k,result:a}},h)}var Pe=256*1024,qe=2*1024,Je=new Set(["v","savedAt","id","ancestry","reset","data"]),Ce=10*1e3,Ke=1500,be=2e3,Le="This draft was started over in another tab.",Ve="This draft was started over in another tab. The earlier draft was kept aside in this browser.",$e="A tab that was open before an update saved another copy of this draft. That copy was kept aside, and this draft was not changed. Reload that tab to go on from this draft.",U=e=>{if(e==null)return null;try{return JSON.parse(e)}catch{return null}};function je(e,r){let d={},h=Object.keys(e).every(m=>Je.has(m));for(let[m,l]of Object.entries(e.data))JSON.stringify(l).length<qe?d[m]=l:h=!1;return JSON.stringify({v:2,savedAt:e.savedAt,id:e.id,ancestry:e.ancestry,idb:!0,...h&&{full:!0},data:d,w:r})}async function Qe({store:e,storage:r,doc:d=document,now:h=()=>Date.now(),reload:m=()=>window.location.reload()}){let l=await ve(),{key:s}=e,b=s+":reset",E=t=>{try{return r?.getItem(t)??null}catch{return null}},a=t=>{try{r?.removeItem(t)}catch{}},n=s+":started-over",k=s+":recovery-notice";try{window.sessionStorage.getItem(n)&&(window.sessionStorage.removeItem(n),window.sessionStorage.getItem(k)||import("./c-C6DXZIXD.js").then(t=>t.toastPersistent(Le,"info")).catch(()=>{}))}catch{}let v=null,u="",I=null,o=null,f=null,P=0,y=!1,D=!1,C=e.held()?.id,i=null,g=null,w=new Set;try{let t=window.sessionStorage.getItem(k);if(t){window.sessionStorage.removeItem(k);let c=U(t);le({id:c?.mark??t},!!c?.reset)}}catch{}function S(t){try{window.sessionStorage.setItem(k,JSON.stringify({mark:t,reset:!0}))}catch{}}function A(t){try{window.sessionStorage.setItem(s+":generation",JSON.stringify({marker:u,reset:t}))}catch{}}function M(){let t=E(b);u=t??"";let c=e.journalSlots().filter(T=>T!==e.slotKey).map(T=>U(E(T)));f=e.stopped()?null:o,P=e.chain().ops.at(-1)?.seq??0;let p=e.held();p?.v===1&&p.w!==void 0&&(i=p);let O=f?[f]:[];return{seed:e.seed(),newId:e.newId,merge3:e.merge3,same:e.same,unitMark:e.unitMark,now:h(),marker:t,resets:O,local:p,seen:i,direct:g!==null&&E(s)===g,chains:e.pending()?[...c,e.chain()]:c}}function N(t,c){let p=h();for(let O of e.journalSlots()){if(O===e.slotKey)continue;let T=U(E(O));(c&&G(T)&&$(T)===c||fe(T,t)&&p-(T?.at??0)>Ce)&&a(O)}}function R({meta:t,record:c}){let p=e.held();if(X(p)&&L(p)!==t.foreign)return void setTimeout(Y,0);if((E(b)??"")!==t.reset)return;if(!c)return void(p&&a(s));if(p?.w&&p.w.reset===t.reset&&p.w.rev>=t.rev)return;let O={rev:t.rev,reset:t.reset},T=JSON.stringify({...c,w:O});try{if(T.length<=Pe){r.setItem(s,T),i={...c,w:O};return}}catch{}try{r.setItem(s,je(c,O))}catch{}}async function de(){if(e.stop({keepPending:!0}),e.unsafe()){try{await l.putRow(ce(s,e.tab),JSON.stringify(e.chain()))}catch(t){throw e.failed(t)}e.acknowledge(e.chain().ops.at(-1)?.seq??0)}}async function ie(t){try{e.captureLate()}catch(W){throw e.failed(W)}y=!0;let c=e.chain(),p=$(c),O=c.ops.some(W=>W.seq>P)||t.meta.recovery?.includes(p)?p:t.meta.recovery?.includes(C)?C:null;e.acknowledge(P),await de(),R(t),O&&S(O);let T=e.held();T?.w&&T.w.reset!==t.meta.reset&&a(s);try{window.sessionStorage.setItem(n,"1")}catch{}return A(t.meta.reset),y=!1,m(),t}async function Se(){let t=e.generation(),c=()=>{e.stop(),ne(!1)},p=()=>(E(b)??"")!==t&&(I===null||(E(b)??"")!==u);if(p())return c();let O=I??Z(t);if(O===null){let F=await re.catch(()=>l.change(s,({meta:H})=>({puts:[],deletes:[],result:{meta:U(H)??ue(t)}}),{timeout:be}));if(p())return c();if(O=F.meta.gen,F.meta.reset!==t){o={ends:null,marker:t};let H=await te();if(e.stopped())return c();O=H.meta.gen}}let T=we(O+1,e.newId());o={ends:O,marker:T};let W=E(s);e.held()?.w&&a(s);try{r.setItem(b,T)}catch{}let he;try{let F=te();E(b)!==T?await F:await Promise.race([F.catch(()=>{}),new Promise(H=>{he=setTimeout(H,Ke)})]),c()}catch(F){if(o=null,W!==null&&E(s)===null&&(E(b)??"")===t)try{r.setItem(s,W)}catch{}throw F}finally{clearTimeout(he)}}function le(t,c=!1){console.warn(c?"visitor-drafts: the draft was started over; the earlier draft was kept in this browser's draft database under":"visitor-drafts: a tab on an earlier ClayJS saved a copy that could not be merged exactly; it was kept in this browser's draft database under",oe(s,$(t))),!w.has(c)&&(w.add(c),import("./c-C6DXZIXD.js").then(p=>p.toastPersistent(c?Ve:$e,"warning")).catch(()=>{}))}function Ee(t){let{meta:c,record:p}=t;if(u!==c.reset&&(E(b)??"")===u)try{r.setItem(b,c.reset)}catch{}if(f&&f===o&&c.reset!==e.generation()&&(f.marker===c.reset&&A(c.reset),e.stop(),ne(!1)),f===o&&(o=null),e.stopped())return y?ie(t):(R(t),t);if(t.conflicts.length&&console.warn("visitor-drafts: another tab changed the same thing; its copy was kept in this browser's draft database under",s+":conflict"),t.stale.includes(e.tab))return ie(t);if(c.reset!==e.generation()){if(!e.fresh())return ie(t);e.enter(c.reset)}t.released.length&&le(t.released[0]),I=c.gen,A(c.reset);let O=e.acknowledge(c.tabs[e.tab]?.seq??0);if(N(c,t.removedMark),R(t),e.pending()||(O&&(ne(!1),d.dispatchEvent(new CustomEvent("clay:drafts-saved",{detail:{data:p.data}}))),D))return t;if(!e.shown())return v=c.rev,t;e.changed()||(p&&c.rev!==v&&e.take(p.data),C=p?.id,v=c.rev);let T=e.externalUnit(p);return T&&d.dispatchEvent(new CustomEvent("clay:drafts-blockeditor-external",{detail:{live:T.live,adopted:()=>e.adoptedUnit(T)}})),t}let j=null,B=null;function ee(t,c=null){return j=ye(l,s,()=>{if(c?.type==="restore"){if(e.stopped())throw new Error("This page has started over. Reload it before restoring a draft.");e.captureNow()}return{...M(),recovery:c}},t).then(Ee,O=>{throw e.pending()?e.failed(O):O}).finally(()=>{j=null}),j}function te(){return B||(j?(B=j.then(()=>{},()=>{}).then(()=>(B=null,ee())),B):ee())}async function pe(t){for(;j||B;)await(B??j).catch(()=>{});return ee({recovery:!0},t)}async function ke(t){if(D)throw new Error("A draft is already being restored.");D=!0;try{if(e.stopped())throw new Error("This page has started over. Reload it before restoring a draft.");e.captureNow();let c;do if(c=await pe({type:"restore",mark:t,reset:e.generation()}),!c.restoredCopy||e.stopped())throw new Error("This page has started over. Reload it before restoring a draft.");while(e.pending());try{e.captureLate("restored:"+e.tab)}catch(p){throw e.failed(p)}return await de(),m(),c}finally{D=!1}}async function Oe(){await re.catch(()=>{});let t=s+":recovery:";return[...await l.readAll(s)].filter(([p])=>p.startsWith(t)).map(([p,O])=>({mark:p.slice(t.length),copy:U(O)}))}let Y=()=>{te().catch(()=>{})};function Ae(){e.unsafe()&&l.putRow(ce(s,e.tab),JSON.stringify(e.chain())).catch(()=>{}),e.pending()&&Y()}window.addEventListener("storage",t=>{if(t.key===s){let[c,p]=[U(t.oldValue),U(t.newValue)];p?.v===1&&p.w!==void 0?i=p:X(p)&&c?.v===1&&c.w!==void 0&&([i,g]=[c,t.newValue])}(t.key===null||t.key===s||t.key===b)&&Y()}),window.addEventListener("pageshow",t=>{t.persisted&&Y()}),d.addEventListener("clay:drafts-blockeditor-listening",Y);let re=ee({timeout:be});return re.catch(()=>{}),{first:re,sync:te,hide:Ae,startOver:Se,listRecovery:Oe,restoreRecovery:ke,recoveryRecord:t=>se(t,e.seed()),removeRecovery:t=>pe({type:"remove",mark:t})}}export{Pe as FULL_COPY_LIMIT,Qe as openSession};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o}from"./c-VKEDWYDF.js";import{f as r}from"./c-C7SUMNMI.js";import{r as c}from"./c-UW6MMZ4V.js";var s="[editmode\\:resource]:is(style, link, script)",u='[editmode\\:resource]:is(style, link, script)[type^="inert/"]',n="inert/";function l(e){let t=e.getAttribute("type");return t&&t.startsWith(n)?!1:(e.setAttribute("type",n+(t||"")),!0)}function a(e){let t=e.getAttribute("type").slice(n.length);t==="javascript"?e.setAttribute("type","text/javascript"):t?e.setAttribute("type",t):e.removeAttribute("type")}function p(){c(e=>{e.querySelectorAll(s).forEach(l)},{required:!0})}function d(){r&&o(()=>{f()})}function f(e=document){let t=(e.ownerDocument||e)===document;e.querySelectorAll(u).forEach(i=>{a(i),t&&i.replaceWith(i.cloneNode(!0))})}function b(){document.querySelectorAll(s).forEach(e=>{l(e)&&e.replaceWith(e.cloneNode(!0))})}function R(){p(),d()}export{s as a,f as b,b as c,R as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as d}from"./c-VO6RSFCO.js";import"./c-WN3MXOLT.js";import{b as f,c as m}from"./c-RVMWGXEJ.js";import{b as n,c as r}from"./c-NUHP2XDB.js";import{e as c}from"./c-EQ5NBOGA.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=30,g=6,e=null,u=null;function O(){return u??=Promise.all([import("./c-
|
|
1
|
+
import{f as d}from"./c-VO6RSFCO.js";import"./c-WN3MXOLT.js";import{b as f,c as m}from"./c-RVMWGXEJ.js";import{b as n,c as r}from"./c-NUHP2XDB.js";import{e as c}from"./c-EQ5NBOGA.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var x=30,g=6,e=null,u=null;function O(){return u??=Promise.all([import("./c-33SS5A4Y.js"),import("./c-46LJAZZJ.js")]).then(([o,t])=>e={pageScheme:o.pageScheme,paintLook:o.paintLook,RUNTIME_ONLY:o.RUNTIME_ONLY,TOKENS:t.TOKENS,SHADOW:t.SHADOW,FONT:`600 11px/1 ${t.FONT_MONO}`,LABEL_FONT:`500 11px/1.4 ${t.FONT_MONO}`}).catch(o=>{throw u=null,o}),u}var N=()=>O().then(()=>!0,()=>!1),a=["all:initial","color-scheme:inherit","direction:ltr","unicode-bidi:isolate"],T="#FFFCF6";function l(o){return o.setAttribute("clay",e.RUNTIME_ONLY),o}function E(o){return{people:o.people.map(i=>({id:i.id,name:i.name,you:i.you})),anonymous:o.anonymous}}var h=class{constructor(){this.roster={people:[],anonymous:0},this.root=null,this.stack=null,this.count=null,this.tip=null,this._gate=null}supported(){return this._gate||(this._gate=Promise.all([c("presence"),c("record-awareness-v1"),c("blockeditor-awareness-v1")]).then(([t,i,s])=>(d.setCapabilities({supported:t,recordAwareness:i,pageAwareness:s}),t===!0),()=>!1)),this._gate}async update(t){let i=E(d.receive(t)),s=this.root&&JSON.stringify(i)===JSON.stringify(this.roster);if(this.roster=i,!!await this.supported()){if(s){e.paintLook(this.root);return}await this.render()}}clear(){d.clear(),this.roster={people:[],anonymous:0},this.root&&(this.root.remove(),this.root=null,this.stack=null,this.count=null,this.tip=null)}async render(){let{people:t,anonymous:i}=this.roster;if(t.length+i<=1||window.clay?.menu){this.hide();return}if(await N()&&this.build()){this.hideTip(),this.stack.textContent="";for(let s of t)this.stack.appendChild(this.avatar(s));this.stack.firstElementChild&&n(this.stack.firstElementChild,"margin-left","0"),i>0?(this.count.textContent=`+${i} viewing`,n(this.count,"display","inline-block")):(this.count.textContent="",n(this.count,"display","none")),n(this.root,"display","flex"),e.paintLook(this.root)}}hide(){this.root&&(this.hideTip(),this.stack.textContent="",this.count.textContent="",n(this.root,"display","none"))}build(){return this.root?!0:typeof document>"u"||!document.body?!1:(this.root=l(r("div",[...a,`color-scheme:${e.pageScheme()}`,"position:fixed","top:calc(12px + env(safe-area-inset-top,0px))","right:calc(12px + env(safe-area-inset-right,0px))","z-index:2147483000","display:flex","align-items:center","gap:8px","max-width:calc(100vw - 24px)",`font:${e.LABEL_FONT}`,`color:${e.TOKENS.ink}`,"pointer-events:none"])),this.root.setAttribute("data-clay-presence",""),this.count=l(r("span",[...a,"box-sizing:border-box","flex:none","white-space:nowrap","padding:3px 8px","border-radius:0",`background:${e.TOKENS.surface}`,`color:${e.TOKENS.muted}`,`border:1px solid ${e.TOKENS["line-2"]}`,`font:${e.LABEL_FONT}`,"letter-spacing:.02em",`box-shadow:${e.SHADOW}`,"display:none","pointer-events:none"])),this.count.setAttribute("data-clay-presence-count",""),this.stack=l(r("div",[...a,"display:flex","align-items:center","flex:none","pointer-events:none"])),this.tip=l(r("span",[...a,"position:absolute","top:100%","right:0","margin-top:6px","box-sizing:border-box","white-space:nowrap","pointer-events:none","padding:5px 9px","border-radius:0",`background:${e.TOKENS.ink}`,`color:${e.TOKENS.ground}`,`font:${e.LABEL_FONT}`,"letter-spacing:.02em",`box-shadow:${e.SHADOW}`,"display:none"])),this.tip.setAttribute("data-clay-presence-tip",""),this.root.append(this.stack,this.count,this.tip),document.body.appendChild(this.root),!0)}avatar(t){let i=f(t.id),s=[`background-color:${T}`,`color:${i}`,`border-color:${i}`],p=l(r("div",[...a,"box-sizing:border-box","flex:none",`width:${x}px`,`height:${x}px`,"border-radius:0","display:flex","align-items:center","justify-content:center",`font:${e.FONT}`,"letter-spacing:.02em",`margin-left:-${g}px`,"border-width:2px","border-style:solid","background-image:none",`box-shadow:${e.SHADOW}`,"user-select:none","cursor:default","pointer-events:auto",...s],m(t.name)));p.setAttribute("data-clay-presence-avatar","");let b=t.you?`${t.name} (you)`:t.name;return p.addEventListener("mouseenter",()=>this.showTip(b)),p.addEventListener("mouseleave",()=>this.hideTip()),p}showTip(t){this.tip&&(this.tip.textContent=t,n(this.tip,"display","block"))}hideTip(){this.tip&&(this.tip.textContent="",n(this.tip,"display","none"))}},y=new h;typeof document<"u"&&document.addEventListener("clay:menu-ready",()=>y.render());var v=y;export{h as Presence,v as default,y as presence};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var o={table:{types:["table"],views:["table","table_cell"],module:"page/features/table.js",load:()=>import("./c-
|
|
1
|
+
var o={table:{types:["table"],views:["table","table_cell"],module:"page/features/table.js",load:()=>import("./c-A5IYL7JI.js")},board:{types:["board"],module:"page/features/board.js",load:()=>import("./c-C27EVUQ6.js")},chart:{types:["chart"],views:["chart"],module:"page/features/chart.js",load:()=>import("./c-O4YIDULY.js")},checklist:{types:[],views:[],match:e=>e.type.name==="list_item"&&e.attrs.kind==="check",module:"page/features/checklist.js",load:()=>import("./c-7Z2625LX.js")},code:{types:["code_block"],module:"page/features/code.js",load:()=>import("./c-STAPQ2X6.js")},toc:{types:["toc"],module:"page/features/toc.js",load:()=>import("./c-MHTO3QAD.js")},titleIcon:{types:[],views:["heading"],match:e=>e.attrs.pageIcon!=null||e.attrs.pageCoverSrc!=null,module:"page/features/title-icon.js",load:()=>import("./c-2GB34XL4.js")},media:{types:["image","file"],module:"page/features/media.js",load:()=>import("./c-3AAQJAKJ.js")},tool:{types:["tool"],module:"page/features/tool.js",boot:["page/tools.js","page/tool-data.js"],load:()=>import("./c-44WITKWQ.js")}},r=e=>Object.keys(o).find(t=>o[t].types.includes(e))??null,s=e=>{for(let t of Object.keys(o)){let a=o[t];if(a.match?a.match(e):a.types.includes(e.type.name))return t}return null},l={mentions:{module:"page/features/mentions.js",load:()=>import("./c-XS7G6U3Z.js")},dates:{module:"page/features/dates.js",load:()=>import("./c-42RLKGEY.js")},emoji:{module:"page/features/emoji.js",load:()=>import("./c-2A2ATCIH.js")},titleIcon:{module:"page/features/title-icon.js",load:()=>import("./c-2GB34XL4.js")},titleCover:{module:"page/features/title-cover.js",load:()=>import("./c-4NAYDOWH.js")},exportHtml:{module:"page/features/export-html.js",load:()=>import("./c-65LJU2H2.js")},importMarkdown:{module:"page/features/import-markdown.js",load:()=>import("./c-PP3CUF3U.js")},exportMarkdown:{module:"page/features/export-markdown.js",load:()=>import("./c-XB6EAIAR.js")}};export{o as a,r as b,s as c,l as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as E,b as S,c as P}from"./c-Q6BG3ZLO.js";import{i as A,j as q}from"./c-
|
|
1
|
+
import{a as E,b as S,c as P}from"./c-Q6BG3ZLO.js";import{i as A,j as q}from"./c-LUBZU4AZ.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as T}from"./c-3Y234AUB.js";import{d as x}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{b as k}from"./c-RETTCOWO.js";import"./c-JC4RZW4E.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var R=/^[A-Za-z0-9_-]{8,64}$/,D="@",F=100;function _({view:o=null}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let f=o.dom.ownerDocument,y=()=>globalThis.clay?.people??null,l=null;function d(t){let e=o.state;if(!e.selection.empty)return null;let r=e.selection.head;if(r<=t.from||r-t.from>F+1||r>e.doc.content.size)return null;let n=e.doc.resolve(t.from);return!n.parent.isTextblock||n.parent.type.spec.code||r>n.end()||r<n.start()||n.parentOffset&&!/\s/.test(e.doc.textBetween(t.from-1,t.from,"",`
|
|
2
2
|
`))||e.doc.textBetween(t.from,t.from+1)!==D?null:{head:r,query:e.doc.textBetween(t.from+1,r)}}function $(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function h(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function m(t){t.picker.show(S(E(t.saved,t.allowed),t.query),$(t)),h(t)}function i(){let t=l;if(t){l=null;for(let[e,r,n,s]of t.listen)e.removeEventListener(r,n,s);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function p(){let t=l;if(!t||o.composing)return;let e=d(t);if(!e)return i();t.query=e.query,m(t)}async function g(t){let e=l;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),n=d(e);if(!(r&&n&&n.query===e.query&&R.test(String(r.id??""))&&String(r.name??"").trim()))return i(),{ok:!1,code:r?"stale-target":"no-person"};let c=String(r.name).trim();return i(),A(o,()=>{let u=d(e);if(!u||u.query!==e.query)return{ok:!1,code:"stale-target"};let a=o.state.tr.insertText(c,e.from,u.head);return a.addMark(e.from,e.from+c.length,x.marks.mention.create({id:r.id})),a.insertText(" ",e.from+c.length),a.setSelection(k.TextSelection.create(a.doc,e.from+c.length+1)),o.dispatch(T(a)),o.focus(),{ok:!0,id:r.id,label:c}})}function B(t){let e=l;if(!e||q(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),h(e)):t.key==="Enter"?(r(),g(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),i())}function I(t){let e=y()?.available;e&&Promise.resolve().then(()=>e()).then(r=>{l===t&&(t.allowed=Array.isArray(r)?r:null,m(t))}).catch(()=>{})}function M(t){i();let e=P({document:f,onPick:c=>g(c)}),r={from:t,picker:e,query:"",allowed:null,saved:[],listen:[]};try{r.saved=y()?.list?.()??[]}catch{r.saved=[]}l=r;let n=(c,u,a,b)=>{c.addEventListener(u,a,b),r.listen.push([c,u,a,b])};n(f,"keydown",c=>B(c),!0),n(o.dom,"input",()=>p()),n(o.dom,"keyup",()=>p()),n(o.dom,"compositionend",()=>p()),n(f,"mousedown",c=>{r.picker.el.contains(c.target)||i()},!0),(o.dom.parentElement??f.body).appendChild(e.el);let s=d(r);return s?(r.query=s.query,m(r),I(r),{ok:!0,picker:!0}):(i(),{ok:!1,code:"stale-target"})}return{async run(t={}){let e=Number.isInteger(t?.from)?t.from:null;if(e===null){let r=o.state,n=r.selection.$from;if(!r.selection.empty||!n.parent.isTextblock||n.parent.type.spec.code)return{ok:!1,code:"stale-target"};e=r.selection.from;let s=o.state.tr.insertText(D);s.setSelection(k.TextSelection.create(s.doc,e+1)),o.dispatch(s)}return M(e)},dispose(){i()}}}export{_ as createFeature};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as m}from"./c-PZ4XEPUP.js";import{a as c}from"./c-SFKI6OLM.js";import{a as p,b as y}from"./c-RHMPKZZ7.js";import{L as f,M as d}from"./c-
|
|
1
|
+
import{b as m}from"./c-PZ4XEPUP.js";import{a as c}from"./c-SFKI6OLM.js";import{a as p,b as y}from"./c-RHMPKZZ7.js";import{L as f,M as d}from"./c-UW6MMZ4V.js";function g(e=new Date){let t=r=>String(r).padStart(2,"0");return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`}function h(e,t){let n=`<script type="application/json" id="clay-lost-edits" clay="no-save">${JSON.stringify(t).replace(/</g,"\\u003c")}<\/script>`,s=e.lastIndexOf("</body>");return s>=0?e.slice(0,s)+n+e.slice(s):e+n}function j(e,{refused:t=!1}={}){let r=window.clay?.conflicts||null,n=[],s=new Set;for(let o of e){let a=r?.recoveryOf(o.id);a&&!s.has(a.id)&&(s.add(a.id),n.push(a))}n.sort((o,a)=>(o.ticket||0)-(a.ticket||0));let u=o=>c(f(o.recoveryRoot??o.root,{prepared:o.domain==="save"})),i,l;t||!n.length?(i=c(d()),l=n):(i=u(n[n.length-1]),l=n.slice(0,-1));let w=e.map(o=>{if(o.kind==="apply-incomplete")return{id:o.id,kind:"apply-incomplete",name:"Sync update that did not finish",error:o.error??null};let{id:a,name:$,kind:S,yours:O,now:b,sentence:k}=m(o);return{id:a,name:$,kind:S,yours:O,now:b,sentence:k}}),v={format:"clay-lost-edits",version:1,savedAt:new Date().toISOString(),page:location.href,refused:!!t,edits:w,earlierPages:l.map(o=>({applyId:o.id,source:o.source,html:u(o)}))};return{html:h(i,v),name:`${p()}-${t?"my-version":"my-copy"}-${g()}.html`}}async function I({html:e=null,edits:t=[]}={}){try{let r=c(typeof e=="string"?e:d()),n={format:"clay-lost-edits",version:1,savedAt:new Date().toISOString(),page:location.href,refused:!1,edits:Array.isArray(t)?t:[],earlierPages:[]};return await y({html:h(r,n),name:`${p()}-my-copy-${g()}.html`})}catch(r){return console.error("clayjs: could not build the download",r),!1}}async function C(e,{refused:t=!1}={}){try{let{html:r,name:n}=j(e,{refused:t});return await y({html:r,name:n})}catch(r){return console.error("clayjs: could not build the download",r),!1}}export{I as a,C as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./c-
|
|
1
|
+
import{a}from"./c-755ZOHOM.js";import"./c-EHAR4RJJ.js";import"./c-LD6UVV5R.js";import"./c-PGSBXHUE.js";import"./c-KU3PX7LL.js";import"./c-EQ5NBOGA.js";import"./c-IJUK2GPW.js";import"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-UW6MMZ4V.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{a as replace};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Ze=Object.defineProperty,Ge=(e,t)=>{for(var r in t)Ze(e,r,{get:t[r],enumerable:!0})},Oe=["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"],Qe=new Set(Oe),Ye=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Ne=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),ue=new Set(["checked","selected","disabled","readOnly","paused"]);function et(e,t){return t==null?ue.has(e)?!1:"":ue.has(e)?t==="false"?!1:!!t:t}var O={};Ge(O,{CodecRefused:()=>ot,EmptyListInsert:()=>M,MAX_RULE_DEPTH:()=>W,MaxRuleDepthExceeded:()=>Z,NoRulesTag:()=>nt,RuleTargetReadOnly:()=>Re,RulesParseError:()=>R,ShapeMismatch:()=>$e,UnknownCodec:()=>ke,UnknownRulesVersion:()=>Se,WriteNotRoundTripped:()=>rt,WriteRefused:()=>Ce,WriteRejected:()=>lt});var R=class extends Error{constructor(e,t){super(e),this.name="RulesParseError",this.cause=t}},Se=class extends Error{constructor(e){super(`unknown rules version: ${e}. Library supports "1" and "2".`),this.name="UnknownRulesVersion",this.version=e}},W=20,Z=class extends Error{constructor(e){super(`rule depth exceeded ${W} at path: ${e.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=e}},$e=class extends Error{constructor(e){super(`shape mismatch: ${e.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=e}},M=class extends Error{constructor(e,t){super(t?`cannot add items to empty list at "${e.join(".")}" \u2014 ${t}`:`cannot add items to empty list at "${e.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=e}},Re=class extends Error{constructor(e){super(`cannot write to read-only DOM property "${e}"`),this.name="RuleTargetReadOnly",this.target=e}},Ce=class extends Error{constructor(e){super(`write refused: ${e.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=e}};function tt(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:String(r),"")||"(root)"}var rt=class extends Error{constructor(e){super(`write did not round-trip at "${tt(e)}"`),this.name="WriteNotRoundTripped",this.path=e}},nt=class extends Error{constructor(e){super(`no <script data-rules-name~="${e}"> rules tag in this document`),this.name="NoRulesTag",this.token=e}},lt=class extends Error{constructor(e,t){super(`write rejected: ${e.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=e,this.unmatched=t}},ke=class extends Error{constructor(e){super(`unknown codec "${e}": no codec by that name is given to this call`),this.name="UnknownCodec",this.code="unknown-codec",this.codec=e}},ot=class extends Error{constructor(e,t){super(t),this.name="CodecRefused",this.code=e}};function C(e){let t=0,r=null,l=-1;for(let n=0;n<e.length;n++){let o=e[n];o==="\\"?n++:r?o===r&&(r=null):o==='"'||o==="'"?r=o:o==="["||o==="("?t++:o==="]"||o===")"?t>0&&t--:o==="@"&&t===0&&(l=n)}return l}var ae="[*]";function S(e){let t=C(e),r=t===-1?e:e.slice(0,t),l=r.endsWith(ae),n={selector:l?r.slice(0,-ae.length):r,prop:t===-1?null:e.slice(t+1)||null};return l&&(n.all=!0),n}function je(e){let t=0,r=null,l=-1,n=!1;for(let o=0;o<e.length;o++){let a=e[o];a==="\\"?o++:r?a===r&&(r=null):a==='"'||a==="'"?r=a:a==="["||a==="("?t++:a==="]"||a===")"?t>0&&t--:t===0&&a===">"?l=o:t===0&&a===","&&(n=!0)}return n||l===-1||!it(e,l+1)?null:e.slice(0,l).trim()||null}function it(e,t){let r=t,l=e.replace(/\s+$/,"").length;for(;r<l&&/\s/.test(e[r]);)r++;let n=0,o=null;for(;r<l;r++){let a=e[r];if(a==="\\")r++;else if(o)a===o&&(o=null);else if(a==='"'||a==="'")o=a;else if(a==="["||a==="(")n++;else if(a==="]"||a===")")n>0&&n--;else if(n===0&&(a==="+"||a==="~"||/\s/.test(a)))return!1}return!0}var ut=/^codec\(([a-z][a-z0-9-]*)\)$/;function G(e){if(typeof e!="string")return null;let t=C(e);if(t===-1)return null;let r=ut.exec(e.slice(t+1));if(!r)return null;let{selector:l,all:n}=S(e);if(n)throw new R("A @codec(name) rule cannot use [*].");return{selector:l,name:r[1]}}var at=/^--[A-Za-z0-9_-]+$/;function Q(e){return typeof e=="string"&&at.test(e)}function Le(e){let t=[],r=[],l=null,n=0;for(let o=0;o<e.length;o++){let a=e[o];if(l){a==="\\"?o++:a===l&&(l=null);continue}if(a==="/"&&e[o+1]==="*"){let i=e.indexOf("*/",o+2);o=i===-1?e.length:i+1;continue}a==='"'||a==="'"?l=a:a==="("?r.push(")"):a==="["?r.push("]"):a==="{"?r.push("}"):(a===")"||a==="]"||a==="}")&&r[r.length-1]===a?r.pop():a===";"&&r.length===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t}function st(e){let t="",r=null;for(let l=0;l<e.length;l++){let n=e[l];if(r){t+=n,n==="\\"&&l+1<e.length?t+=e[++l]:n===r&&(r=null);continue}if(n==="/"&&e[l+1]==="*"){let o=e.indexOf("*/",l+2);l=o===-1?e.length:o+1,t+=" ";continue}(n==='"'||n==="'")&&(r=n),t+=n}return t}function Me(e){e=st(e);let t=e.indexOf(":");if(t===-1)return null;let r=e.slice(0,t).trim(),l=e.slice(t+1).trim(),n=/!\s*important\s*$/i.exec(l);return n&&(l=l.slice(0,n.index).trim()),{name:r,value:l,important:!!n}}function Y(e,t){if(e==null)return null;let r=null;for(let l of Le(String(e))){let n=Me(l);!n||n.name!==t||(!r||n.important||!r.important)&&(r=n)}return r?r.value:null}function ct(e,t,r){let l=e==null?"":String(e),n=r==null||r==="",o=Le(l),a=o.map(Me),i=a.some(d=>d&&d.name===t&&d.important),u=[],s=!1;o.forEach((d,p)=>{let v=a[p];if(!v||v.name!==t){u.push(d);return}if(n||s)return;let f=/^\s*/.exec(d)[0];u.push(`${f}${t}: ${r}${i?" !important":""}`),s=!0});let c=u.join(";");if(!n&&!s){let d=c.trimEnd();c=d===""?`${t}: ${r}`:`${d}${d.endsWith(";")?" ":"; "}${t}: ${r}`}return c.trim()===""?null:c}function Ie(e,t,r,l){let n=e.attr(t,"style");if((Y(n,r)??"")===l)return;let o=ct(n,r,l);o==null?e.removeAttr(t,"style"):e.attr(t,"style",o)}var se=/^[a-z][a-z0-9-]*$/,ee=new Map;function ft(e,t){if(typeof e!="string"||!se.test(e))throw new Error(`hyper-html-api: invalid codec name ${JSON.stringify(e)} (must match ${se})`);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`);ee.set(e,t)}function dt(e){return ee.get(e)??null}function pt(){return Object.fromEntries(ee)}var ht='The @codec(name) rule form needs a rules tag with data-rules-version="2".',mt="A @codec(name) rule must be the value of a top level key.";function We(e,t){let r=G(e);return r?{...r,codec:t.codecs[r.name]}:null}function te(e,t={}){let r=t.version??"1",l=t.codecs??{};n(e,0);function n(o,a){if(!(a>W)){if(typeof o=="string"){let i=G(o);if(!i)return;if(r!=="2")throw new R(ht);if(a!==1)throw new R(mt);if(!Object.prototype.hasOwnProperty.call(l,i.name))throw new ke(i.name);return}if(Array.isArray(o)){n(o[1],a+1);return}if(o&&typeof o=="object")for(let i of Object.values(o))n(i,a+1)}}}function q(e,t,r,l={}){if(Object.prototype.hasOwnProperty.call(l,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return te(r,l),_(e,t,r,{depth:0,path:[]},l)}function _(e,t,r,l,n){if(l.depth>W)throw new Z(l.path);if(typeof r=="string")return yt(e,t,r,l,n);if(Array.isArray(r)){let[o,a]=r,i=e.find(t,o,n);return De(n,l,i),i.map((u,s)=>_(e,u,a,{depth:l.depth+1,path:[...l.path,s]},n))}if(typeof r=="object"&&r!==null){let o={};for(let[a,i]of Object.entries(r))o[a]=_(e,t,i,{depth:l.depth+1,path:[...l.path,a]},n);return o}return null}function yt(e,t,r,l,n){if(r.endsWith("[]")){let c=r.slice(0,-2),d=e.find(t,c,n);return De(n,l,d),d.map(p=>e.text(p))}let o=We(r,n);if(o)return gt(e,t,o,n);if(r.startsWith("@"))return z(e,t,r.slice(1));let a=C(r);if(a!==-1){let{selector:c,all:d}=S(r),p=r.slice(a+1),v=c?e.find(t,c,n):[t];return d&&n.allMatches?v.map(f=>z(e,f,p)):v.length===0?null:z(e,v[0],p)}if(r===".")return e.text(t);let{selector:i,all:u}=S(r),s=e.find(t,i,n);return u&&n.allMatches?s.map(c=>e.text(c)):s.length===0?null:e.text(s[0])}function gt(e,t,{selector:r,codec:l},n){let o=r?e.find(t,r,n):[t];return o.length===0?null:l.read(e,o[0],{query:n.query,view:n.view,region:n.region})}function De(e,t,r){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),r)}catch(l){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,l)}}function z(e,t,r){if(Q(r))return Y(e.attr(t,"style"),r);if(Qe.has(r)){let n=e.prop(t,r);return n==null?null:String(n)}return e.attr(t,r)??null}function wt(e,t,r,l){let n=e.length,o=t.length,a=new Array(n).fill(-1);if(l){let h=new Set;for(let y=0;y<n;y++){let w=l[y];!(w>=0&&w<o)||h.has(w)||(a[y]=w,h.add(w))}}if(n===0||o===0)return a;let i=e.map(h=>ce(h,r)),u=t.map(h=>ce(h,r)),s=new Array(o).fill(!1);for(let h of a)h>=0&&(s[h]=!0);let c=new Map;u.forEach((h,y)=>{s[y]||c.set(h,c.has(h)?-1:y)});let d=new Map;i.forEach((h,y)=>{a[y]>=0||d.set(h,(d.get(h)||0)+1)}),i.forEach((h,y)=>{if(a[y]>=0||d.get(h)!==1)return;let w=c.get(h);w===void 0||w===-1||s[w]||(a[y]=w,s[w]=!0)});let p=[];for(let h=0;h<n;h++)a[h]<0&&p.push(h);let v=[];for(let h=0;h<o;h++)s[h]||v.push(h);if(p.length===0||v.length===0)return a;let f=n*o+1,m=vt(e,t,r),g=(h,y)=>m(h,y)*f+Math.abs(h-y);for(let[h,y]of At(p,v,g))a[h]=y;return a}var Pe=e=>typeof e=="object"&&e!==null;function ce(e,t){if(!Pe(t))return e==null?" null":String(e);let r=Object.keys(t);return JSON.stringify(r.map(l=>{let n=JSON.stringify(e?.[l]);return n===void 0?" undef":n}))}function vt(e,t,r){if(!Pe(r))return(i,u)=>e[i]===t[u]?0:1;let l=Object.keys(r),n=i=>l.map(u=>JSON.stringify(i?.[u])),o=e.map(n),a=t.map(n);return(i,u)=>{let s=o[i],c=a[u],d=0;for(let p=0;p<l.length;p++)s[p]!==c[p]&&d++;return d}}function At(e,t,r){return e.length<=t.length?fe(e,t,r,!1):fe(t,e,(l,n)=>r(n,l),!0)}function fe(e,t,r,l){let n=e.length,o=t.length,a=[];for(let d=0;d<=n;d++)a.push(new Float64Array(o+1).fill(1/0));let i=[];for(let d=0;d<=n;d++)i.push(new Uint8Array(o+1));for(let d=0;d<=o;d++)a[n][d]=0;for(let d=n-1;d>=0;d--)for(let p=o-1;p>=0;p--){let v=r(e[d],t[p])+a[d+1][p+1],f=a[d][p+1];v<=f?(a[d][p]=v,i[d][p]=1):a[d][p]=f}let u=[],s=0,c=0;for(;s<n&&c<o;)i[s][c]&&(u.push(l?[t[c],e[s]]:[e[s],t[c]]),s++),c++;return u}function qe(e,t,r,l,n,o,a,i={}){let u=e.find(t,r,i);if(n.length===0){u.forEach(b=>e.remove(b)),V(i,"onRowsApplied",o.path,[]);return}let s=n.length>u.length,c=u[0]||null;if(s&&!c&&(c=xt(e,t,r,i),!c))throw new M(o.path);let d=u.map(b=>Et(e,b,l,i)),p=null;if(s&&c){p=e.clone(c);let b=i.templateAttr&&e.attr(c,i.templateAttr)!=null;i.templateAttr&&e.removeAttr(p,i.templateAttr),b&&e.removeAttr(p,"hidden");let T=e.stripIds(p);T>0&&console.warn(`[hyper-html-api] stripped ${T} id attribute(s) from cloned template at "${o.path.join(".")||"(root)"}"`)}let v=wt(n,d,l,bt(e,u,n,o,i)),f=u.length>0?e.parent(u[0]):$t(e,t,r,c,o,i),m=u.length>0?Be(e,f,u[0]):0,g=kt(e,u),h=new Set,y=[],w=n.map((b,T)=>{let A=v[T];if(A>=0)return h.add(A),y.push(!1),u[A];y.push(!0);let x=e.clone(p);return e.stripIds(x),x});u.forEach((b,T)=>{h.has(T)||e.remove(b)}),g?Ct(e,f,m,w,y):jt(e,w,y,f,m),Tt(e,w,l,n,o,a,i),V(i,"onRowsApplied",o.path,w)}function V(e,t,r,l){if(typeof e[t]=="function")try{return e[t](r.slice(),l)}catch(n){console.warn(`[hyper-html-api] ${t} threw at "${r.join(".")||"(root)"}"`,n);return}}function bt(e,t,r,l,n){let o=V(n,"identifyRows",l.path,r);if(!Array.isArray(o))return null;let a=new Array(r.length).fill(-1),i=new Set,u=new Map(t.map((s,c)=>[e.identity(s),c]));for(let s=0;s<r.length;s++){if(!o[s])continue;let c=u.get(e.identity(o[s]));c===void 0||i.has(c)||(a[s]=c,i.add(c))}return a}function Tt(e,t,r,l,n,o,a){t.forEach((i,u)=>{if(r===null){let s=l[u],c=s==null?"":String(s);e.text(i)!==c&&e.text(i,c)}else{let s=o(e,i,r,l[u],{depth:n.depth+1,path:[...n.path,u]},a);s&&s!==i&&(t[u]=s)}})}function Et(e,t,r,l){return r===null?e.text(t):q(e,t,r,l.onRowsRead?{...l,onRowsRead:void 0}:l)}function Be(e,t,r){let l=e.children(t);for(let n=0;n<l.length;n++)if(e.sameNode(l[n],r))return n;return-1}function xt(e,t,r,l){if(!l.templateAttr)return null;let n=/^\s*:scope\s*>\s*/.test(r),o=new RegExp(":not\\(\\["+l.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),a=r.replace(/^\s*:scope\s*>\s*/,"").replace(o,""),i=n?Ot(a):0,u=je(a),s=t;for(;s;){let c=e.find(s,a,{includeRulesTag:!1,templateAttr:null});for(let d of c)if(e.attr(d,l.templateAttr)!=null&&!(n&&!St(e,t,d,i))&&!(u&&!e.matches(e.parent(d),u)))return d;s=e.parent(s)}return null}function Ot(e){let t=0,r=null,l=1;for(let n=0;n<e.length;n++){let o=e[n];if(o==="\\")n++;else if(r)o===r&&(r=null);else if(o==='"'||o==="'")r=o;else if(o==="["||o==="(")t++;else if(o==="]"||o===")")t>0&&t--;else if(t===0&&o===">")l++;else{if(t===0&&(o==="+"||o==="~"))return null;if(t===0&&/\s/.test(o)){if(!Nt(e,n))return null;for(;n+1<e.length&&/\s/.test(e[n+1]);)n++}}}return l}function Nt(e,t){let r=t;for(;r<e.length&&/\s/.test(e[r]);)r++;let l=t>0?e[t-1]:"",n=r<e.length?e[r]:"";return de(l)||de(n)}function de(e){return e===">"||e==="+"||e==="~"}function St(e,t,r,l){if(l===null)return!0;let n=r;for(let u=0;u<l;u++)if(n=e.parent(n),!n)return!1;let o=e.prop(t,"tagName");if(!o)return!0;let a=e.prop(n,"tagName");if(!a||String(a).toLowerCase()!==String(o).toLowerCase())return!1;let i=new Set(pe(e,n));return pe(e,t).every(u=>i.has(u))}function pe(e,t){let r=e.attr(t,"class");return r?String(r).split(/\s+/).filter(Boolean):[]}function $t(e,t,r,l,n,o){let a=e.parent(l);if(a&&Rt(e,t,a)&&!me(e,a,o))return a;let i=je(r);if(!i)throw new M(n.path,`the list selector "${r}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let u=(i===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,i,o)).filter(s=>!me(e,s,o));if(u.length===0)throw new M(n.path,`no container matching "${i}" inside this context to hold the new rows`);if(u.length>1)throw new M(n.path,`"${i}" matches ${u.length} containers inside this context, so the new rows have no single destination`);return u[0]}function Rt(e,t,r){let l=r;for(;l;){if(e.sameNode(l,t))return!0;l=e.parent(l)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(n=>e.sameNode(n,r))}var he=["no-data","editor-ui"];function me(e,t,r){let l=t;for(;l;){if(r.templateAttr&&e.attr(l,r.templateAttr)!=null||he.some(o=>e.attr(l,o)!=null))return!0;let n=e.attr(l,"clay");if(n&&n.split(/\s+/).some(o=>he.includes(o)))return!0;l=e.parent(l)}return!1}function Ct(e,t,r,l,n){let o=e.children(t),a=o.map(u=>e.identity(u)),i=!1;l.forEach((u,s)=>{let c=e.identity(u),d=r+s;if(a[d]===c)return;if(!n[s]){let v=a.indexOf(c);v!==-1&&(a.splice(v,1),o.splice(v,1))}let p=Math.min(d,o.length);p<o.length?e.insertBefore(o[p],u):o.length?i?e.insertAfter(o[o.length-1],u):(e.insertAt(t,u,d),i=!0):e.insertAt(t,u,0),a.splice(p,0,c),o.splice(p,0,u)})}function kt(e,t){if(t.length<=1)return!0;let r=e.parent(t[0]);if(!r)return!1;let l=new Map(e.children(r).map((o,a)=>[e.identity(o),a])),n=[];for(let o of t){let a=l.get(e.identity(o));if(a===void 0)return!1;n.push(a)}return n.sort((o,a)=>o-a),n[n.length-1]-n[0]===n.length-1}function jt(e,t,r,l,n){let o=null,a=n;for(let i=0;i<t.length;i++){if(!r[i]){o=t[i];continue}let u=o?e.parent(o):l;if(!u)continue;let s=o?Be(e,u,o)+1:a++;e.insertAt(u,t[i],s),o=t[i]}}function B(e,t,r,l,n={}){if(Object.prototype.hasOwnProperty.call(n,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");te(r,n);let o=[];if(F(r,l,[],o),o.length)throw new $e(o);H(e,t,r,l,{depth:0,path:[]},n)}function H(e,t,r,l,n,o={}){if(n.depth>W)throw new Z(n.path);if(l===void 0)return t;if(typeof r=="string")return Lt(e,t,r,l,n,o);if(Array.isArray(r)){let[a,i]=r;return qe(e,t,a,i,l,n,H,o),t}if(typeof r=="object"&&r!==null){for(let[a,i]of Object.entries(r)){let u=H(e,t,i,l==null?l:l[a],{depth:n.depth+1,path:[...n.path,a]},o);u&&u!==t&&(t=u)}return t}return t}function Lt(e,t,r,l,n,o){if(r.endsWith("[]")){let d=r.slice(0,-2);return qe(e,t,d,null,l,n,H,o),t}let a=We(r,o);if(a){let d=a.selector?e.find(t,a.selector,o):[t];return d.length&&a.codec.write(e,d[0],l,{query:o.query}),t}if(r.startsWith("@"))return ge(e,t,r.slice(1),l);let i=C(r);if(i!==-1){let{selector:d,all:p}=S(r),v=r.slice(i+1),f=d?e.find(t,d,o):[t];for(let m of p?f:f.slice(0,1))ge(e,m,v,l);return t}if(r===".")return ye(e,t,l),t;let{selector:u,all:s}=S(r),c=e.find(t,u,o);for(let d of s?c:c.slice(0,1))ye(e,d,l);return t}function ye(e,t,r){let l=r==null?"":String(r);e.text(t)!==l&&e.text(t,l)}function Mt(e,t,r,l){if(e.styleVar){e.styleVar(t,r,l);return}Ie(e,t,r,l)}function ge(e,t,r,l){if(Q(r))return Mt(e,t,r,l==null?"":String(l).trim()),t;if(Ne.has(r)){let n=e.prop(t,r);if(n===l||n!=null&&l!=null&&String(n)===String(l))return t;throw new Re(r)}if(r==="outerHTML"){let n=l==null?"":String(l);return e.replaceWith(t,n)}if(Ye.has(r)){let n=et(r,l);return e.prop(t,r)!==n&&e.prop(t,r,n),t}if(l==null)e.attr(t,r)!=null&&e.removeAttr(t,r);else{let n=String(l);e.attr(t,r)!==n&&e.attr(t,r,n)}return t}function F(e,t,r,l){if(t!==void 0){if(typeof e=="string"){if(G(e))return;if(e.endsWith("[]")){Array.isArray(t)?t.forEach((n,o)=>{typeof n=="object"&&n!==null&&l.push({path:j([...r,o]),expected:"scalar",got:k(n)})}):l.push({path:j(r),expected:"array",got:k(t)});return}t!==null&&typeof t=="object"&&l.push({path:j(r),expected:"scalar",got:k(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){l.push({path:j(r),expected:"array",got:k(t)});return}let n=e[1];t.forEach((o,a)=>F(n,o,[...r,a],l));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){l.push({path:j(r),expected:"object",got:k(t)});return}for(let[n,o]of Object.entries(e))F(o,t[n],[...r,n],l)}}}function k(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function j(e){return e.join(".")}function It(e){try{return JSON.parse(e)}catch(t){throw new R(`Invalid strict JSON: ${t.message}`,t)}}function He(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function r(n){let o=[],a=0;for(;a<n.length;){let i=n[a];if(/\s/.test(i)){a++;continue}if("{}".includes(i)){o.push({type:i,value:i}),a++;continue}if(i==="["){let d=!1,p=a+1;for(;p<n.length&&/\s/.test(n[p]);)p++;if(p<n.length&&/[a-zA-Z_]/.test(n[p])&&(d=!0),!d){o.push({type:i,value:i}),a++;continue}}if(i==="]"){o.push({type:i,value:i}),a++;continue}if(i===":"){o.push({type:t.COLON,value:i}),a++;continue}if(i===","){o.push({type:t.COMMA,value:i}),a++;continue}if(i==='"'||i==="'"){let d=i,p=a+1;for(;p<n.length&&n[p]!==d;)n[p]==="\\"&&p++,p++;o.push({type:t.STRING,value:n.substring(a+1,p),quoted:!0,sourceQuote:d}),a=p+1;continue}let u=a,s;for(;u<n.length&&!/[{},]/.test(n[u]);)if(n[u]===":"){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"],p=!1;for(let v of d){let f=v.substring(1);if(n.substring(u+1,u+1+f.length)===f){p=!0,u+=f.length;break}}if(!p)break}else if(n[u]==="["){for(u++;u<n.length&&n[u]!=="]";){if(n[u]==='"'||n[u]==="'"){let d=n[u];for(u++;u<n.length&&n[u]!==d;)n[u]==="\\"&&u++,u++}u++}u<n.length&&n[u]==="]"&&u++}else u++;s=n.substring(a,u);let c=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(s)?c=t.NUMBER:s==="true"||s==="false"||s==="null"?c=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(s)&&(c=t.SELECTOR),o.push({type:c,value:s,quoted:!1}),a=u}return o}function l(n){let o="";for(let a=0;a<n.length;a++){let i=n[a];if("{}".includes(i.type)||"[]".includes(i.type)){o+=i.value;continue}if(i.type===t.COLON){o+=i.value;continue}if(i.type===t.COMMA){let u=n[a+1];if(u&&(u.type==="}"||u.type==="]"))continue;o+=i.value;continue}if(i.type===t.STRING&&i.quoted){let u=i.value;i.sourceQuote==="'"&&(u=u.replace(/\\'/g,"'"),u=u.replace(/(\\*)"/g,(s,c)=>c.length%2===0?c+'\\"':s)),o+=`"${u}"`;continue}if(i.type===t.NUMBER||i.type===t.BOOLEAN){o+=i.value;continue}if(i.type===t.SELECTOR||i.type===t.IDENTIFIER){o+=`"${i.value}"`;continue}o+=`"${i.value}"`}return o}try{let n=r(e),o=l(n);return JSON.parse(o)}catch(n){throw new R("Invalid extraction rules syntax: "+n.message,n)}}var Wt=["1","2"],we=/^[a-zA-Z0-9_-]+$/;function re(e,t,r){let l;if(r===void 0)l="script[data-rules-name]";else{if(typeof r!="string"||!we.test(r))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(r)} (must match ${we})`);l=`script[data-rules-name~="${r}"]`}let n=e.find(t,l,{includeRulesTag:!0});if(n.length===0)return null;r!==void 0&&n.length>1&&console.warn(`hyper-html-api: ${n.length} rules tags match data-rules-name~="${r}"; using the first.`);let o=n[0],a=e.attr(o,"data-rules-version");if(!Wt.includes(a))throw new Se(a);return{rules:He(e.text(o)),tagNode:o,version:a}}var ne=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"]})}),Dt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Pt=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function U(e,t){if(!e||e.nodeType!==1)return!1;let r=e.getAttribute?.("clay");return!!(r&&r.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Ue(e,t){if(U(e,t))return!0;for(let[r,l]of Object.entries(Dt))if(l.includes(t)&&U(e,r))return!0;return!1}function J(e){let t=ne[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(r=>[`[clay~="${r}"]`,`[${r}]`]).join(", ")}function qt(e,t){let r=e&&e.nodeType===1?e:e?.parentElement;for(;r&&r.nodeType===1;){let l=ne[t];if(!l)throw new Error(`Unknown region capability: ${t}`);if(l.tokens.some(n=>Ue(r,n))||l.bundles.some(n=>U(r,n)))return r;r=r.parentElement}return null}function Bt(e,t){return!!qt(e,t)}var le=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",...Pt],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"]})}),Ht=new Set(["textContent","innerText"]);function Ut(e){let t=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return t?t[1].toLowerCase():null}var zt=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function _t(e,t,r=le){if(!zt.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let l=String(e).toLowerCase();if(r.refusedAttributePrefixes.some(n=>l.startsWith(n)))return`attribute "${l}" can run script`;if(r.refusedAttributes.includes(l))return`attribute "${l}" is not content`;if(r.urlAttributes.includes(l)&&t!=null){let n=l==="srcset"?String(t).split(",").map(o=>o.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let o of n){let a=Ut(o);if(a&&r.refusedSchemes.includes(a))return`"${a}:" URLs are not allowed in "${l}"`}}return null}function oe(e,t){let r=e.prop(t,"tagName");return r?String(r).toLowerCase():""}function Vt(e,t){let r=oe(e,t)||"node",l=e.attr(t,"id");return l?`<${r}#${l}>`:`<${r}>`}function Ft(e,t,r){let l=t;for(;l;){let n=oe(e,l);if(n&&r.refusedTargets.includes(n))return n;l=e.parent(l)}return null}function ze(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function Jt(e,t){return oe(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:ze(e,t)}function Kt(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],r=null;for(let l=0;l<e.length;l++){let n=e[l];if(r){n===r&&(r=null);continue}if(n==='"'||n==="'")r=n;else{if(n==="/"&&e[l+1]==="*")return"comments are not allowed in a custom property value";if(n==="(")t.push(")");else if(n==="[")t.push("]");else if((n===")"||n==="]")&&t.pop()!==n)return`"${n}" does not close anything in this custom property value`}}return r?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function Xt(e,t=le){let r=t.customPropertyValues,l=String(e);if(l.length>r.maxLength)return`custom property values are limited to ${r.maxLength} characters`;let n=r.refusedCharacters.find(u=>l.includes(u));if(n)return`${JSON.stringify(n)} is not allowed in a custom property value`;let o=Kt(l);if(o)return o;let a=l.toLowerCase(),i=r.refusedFunctions.find(u=>new RegExp(`(^|[^a-z0-9_-])${u.replace(/[-]/g,"\\-")}\\s*\\(`).test(a));return i?`"${i}()" is not allowed in a custom property value`:null}function ve(e,t=le){let r=[],l=(i,u)=>(r.push({target:Vt(e,i),reason:u}),!1),n=i=>{let u=Ft(e,i,t);return u?l(i,`inside <${u}>, which is not content`):!0},o=i=>n(i)?ze(e,i)?l(i,"a text write here would delete the data rules tag"):!0:!1,a=(i,u,s)=>{if(!n(i))return!1;let c=_t(u,s,t);return c?l(i,c):!0};return{...e,text(i,u){if(u===void 0)return e.text(i);o(i)&&e.text(i,u)},attr(i,u,s){if(s===void 0)return e.attr(i,u);a(i,u,s)&&e.attr(i,u,s)},removeAttr(i,u){a(i,u,null)&&e.removeAttr(i,u)},styleVar(i,u,s){if((Y(e.attr(i,"style"),u)??"")!==s&&n(i)){if(!Q(u))return l(i,`"${u}" is not a custom property`);if(s!==""){let c=Xt(s,t);if(c)return l(i,c)}Ie(e,i,u,s)}},prop(i,u,s){if(s===void 0)return e.prop(i,u);if(t.refusedRuleForms.includes(u))return l(i,`"@${u}" writes HTML, only text is allowed`);if(Ht.has(u)){o(i)&&e.prop(i,u,s);return}a(i,u==="className"?"class":u,s)&&e.prop(i,u,s)},remove(i){if(Jt(e,i)){l(i,"removing this would delete the data rules tag");return}e.remove(i)},replaceWith(i,u){return u===e.prop(i,"outerHTML")||l(i,'"@outerHTML" writes HTML, only text is allowed'),i},refusals:r,assertClean(){if(r.length)throw new Ce(r.slice())}}}function L(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ae(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t?`${t}.${r}`:r,"")}function Zt(e,t,r,l,n={}){te(r,n);let o=[],a=[];function i(s,c,d){if(Array.isArray(s)){let[,p]=s;if(!Array.isArray(c)||!L(p))return;c.forEach((v,f)=>i(p,v,[...d,f]));return}if(!(!L(s)||!L(c)))for(let p of Object.keys(c))Object.prototype.hasOwnProperty.call(s,p)?i(s[p],c[p],[...d,p]):o.push(Ae([...d,p]))}function u(s,c,d,p){if(d!==void 0){if(typeof c=="string"){if(c.endsWith("[]")||c==="."||c.startsWith("@"))return;let{selector:v}=S(c);if(!v)return;e.find(s,v,n).length===0&&a.push({path:Ae(p),selector:v});return}if(!Array.isArray(c)&&L(c)&&L(d))for(let[v,f]of Object.entries(c))u(s,f,d[v],[...p,v])}}return i(r,l,[]),u(t,r,l,[]),{unknownKeys:o,unmatched:a}}function be(e,t,r){if(r&&typeof r=="object")return{rules:r,tagNode:null,version:"1"};if(typeof r=="string"){let l=t&&t.ownerDocument?t.ownerDocument:t;return re(e,l,r)}return null}var Gt=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Qt(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let r=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&r!=="checkbox"&&r!=="radio"&&r!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(r==="checkbox"||r==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Te(e,t,r,l){if(l)return!!e.closest?.(t);let n=e;for(;n?.nodeType===1;){if(n.matches(t))return!0;if(n===r)break;n=n.parentElement}return!1}function Ee(e,t,r,l,n,o){return(o?Bt(e,t):Te(e,r,n,!1))||!!(l&&(o&&e!==n?e.matches(l):Te(e,l,n,o)))}function Yt(e,t){let r=ne[t];return r.tokens.some(l=>Ue(e,l))||r.bundles.some(l=>U(e,l))}var er=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function _e(e,t,r,l){if(e.nodeType===1&&l(e)){r.dropped.push(t);return}r.cloneToLive.set(t,e),r.liveToClone.set(e,t);let n=e,o=t;if(e.nodeType===1){if(er.has(e.tagName)&&r.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);n=e.content,o=t.content,r.cloneToLive.set(o,n),r.liveToClone.set(n,o)}}else if(e.nodeType!==11)return;let a=o.firstChild;for(let i=n.firstChild;i&&a;i=i.nextSibling)_e(i,a,r,l),a=a.nextSibling}function D(e,{capability:t="data",exclude:r=null,inherit:l=!0,provenance:n=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let o=e.nodeType===9?e:e.ownerDocument;if(!o?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let a=o.implementation.createHTMLDocument(""),i=n||new WeakMap,u=new WeakMap,s=e.nodeType===9?e.documentElement:e;r&&a.documentElement.matches(r);let c=J(t),d=l?f=>Yt(f,t)||!!(r&&f.matches(r)):f=>Ee(f,t,c,r,s,!1),p=null;if(s.nodeType!==1||!Ee(s,t,c,r,s,l)){p=a.importNode(s,!0);let f={cloneToLive:i,liveToClone:u,dropped:[],controls:[]};_e(s,p,f,d);for(let m of f.dropped)m.remove();for(let m=0;m<f.controls.length;m+=2)Qt(f.controls[m],f.controls[m+1])}e.nodeType===9&&p&&(a.replaceChild(p,a.documentElement),u.set(e,a),i.set(a,e));let v=f=>{if(Gt.test(f))throw new Error(`Filtered content queries do not support stateful selector: ${f}`)};return{root:p,document:a,capability:t,selector:J(t),cloneToLive:i,liveToClone:u,original(f){return i.get(f)||null},cloneOf(f){return u.get(f)||null},query(f,m=p){return v(f),Array.from(m.querySelectorAll(f),g=>i.get(g)||g)},text(f=p){return(f===p?p:u.get(f))?.textContent||""},html(f=p){return(f===p?p:u.get(f))?.innerHTML??""},clone(f=p){let m=f===p?p:u.get(f);return m?a.importNode(m,!0):null}}}function Ve(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function tr(e){return e?(e.nodeType===9||e.nodeType,e):null}function xe(e,t,r){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=r===null?"":r:t==="checked"&&e.tagName==="INPUT"?e.checked=r!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=r!==null))}function Fe(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Je(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let r of t)if(r.tagName==="TEXTAREA")r.value=r.defaultValue;else if(r.tagName==="INPUT"){let l=r.type;l!=="file"&&l!=="checkbox"&&l!=="radio"&&(r.value=r.defaultValue),r.checked=r.defaultChecked}else r.tagName==="OPTION"&&(r.selected=r.defaultSelected)}var E={semanticExclude:!0,find(e,t,r={}){let l=tr(e);if(!l||!l.querySelectorAll)return[];let n=Array.from(l.querySelectorAll(t));r.includeRulesTag||(n=n.filter(i=>!Ve(i)));let o=[];r.skip&&o.push(r.skip);let a=r.templateAttr===null?null:r.templateAttr||"cms-template";if(a&&o.push("["+a+"]"),o.length){let i=o.join(", ");n=n.filter(u=>!u.closest||!u.closest(i))}return n},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Fe(e,t)},attr(e,t,r){if(r===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,r),xe(e,t,r)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),xe(e,t,null)},prop(e,t,r){if(r===void 0){let l=e?e[t]:void 0;return l!==void 0?l:null}e[t]=r},clone(e){let t=e.cloneNode(!0);return Je(t),t},insertAt(e,t,r){let l=e.children[r]||null;e.insertBefore(t,l)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let l=r.content.firstElementChild;if(!l)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(l,e),l},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function N(e,t={}){if(t.exclude===null)return E;let r=[J("data"),t.exclude].filter(Boolean).join(", "),l=e.nodeType===9?e:e.ownerDocument||e,n=e.nodeType===9?e.documentElement:e;if(!t._write&&!n?.matches?.(r)&&!n?.querySelector?.(r)&&!l?.querySelector?.(r))return E;let o=e.nodeType===9||!e.isConnected?e:e.ownerDocument,a=e.nodeType===9?e:e.ownerDocument,i=null,u=()=>i||(i=D(o,{capability:"data",exclude:t.exclude||null})),s=f=>{let m=u();return f===e?m.cloneOf(e):m.cloneOf(f)||f},c=f=>i?.original(f)||f,d=(f,m)=>{u().liveToClone.set(f,m),u().cloneToLive.set(m,f);let g=f.childNodes||[],h=m.childNodes||[];for(let y=0;y<Math.min(g.length,h.length);y++)d(g[y],h[y])},p=(f,m,g,h)=>{let y=Array.from(f.childNodes).filter(A=>i.cloneOf(A)),w=y[0];for(;w&&y.includes(w);)w=w.nextSibling;for(let A of y)A.remove();if(g==="innerHTML"){let A=a.createElement("template");A.innerHTML=h;for(let x of Array.from(A.content.childNodes))f.insertBefore(x,w||null)}else f.insertBefore(a.createTextNode(h),w||null),Fe(f,h);let b=D(f,{capability:"data",exclude:t.exclude||null});m.replaceChildren(...Array.from(b.root?.childNodes||[]));let T=A=>{let x=b.original(A);x&&(i.liveToClone.set(x,A),i.cloneToLive.set(A,x));for(let Xe of Array.from(A.childNodes||[]))T(Xe)};for(let A of Array.from(m.childNodes))T(A)},v={...E,find(f,m,g={}){let h=s(f);if(!h?.querySelectorAll)return[];let y=u().query(m,h);g.includeRulesTag||(y=y.filter(T=>!Ve(T)));let w=[];g.skip&&w.push(g.skip);let b=g.templateAttr===null?null:g.templateAttr||"cms-template";if(b&&w.push(`[${b}]`),w.length){let T=w.join(", ");y=y.filter(A=>!A.closest?.(T))}return y},parent(f){let m=s(f)?.parentElement;return m?c(m):null},children(f){return Array.from(s(f)?.children||[],c)},text(f,m){if(m===void 0){let y=c(f);return!y?.matches?.(r)&&!y?.querySelector?.(r)?E.text(y):(s(f)?.textContent||"").trim()}let g=c(f);if(!g?.matches?.(r)&&!g?.querySelector?.(r)&&!i){E.text(g,m);return}let h=u().cloneOf(g);h?p(g,h,"textContent",m):E.text(g,m)},attr(f,m,g){let h=c(f);if(g===void 0)return E.attr(h,m);E.attr(h,m,g);let y=i?.cloneOf(h);y&&(E.attr(y,m,g),D(h,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),i.liveToClone.delete(h),i.cloneToLive.delete(y)))},removeAttr(f,m){let g=c(f);E.removeAttr(g,m);let h=i?.cloneOf(g);h&&E.removeAttr(h,m)},prop(f,m,g){let h=c(f);if(g===void 0)return m==="innerHTML"||m==="outerHTML"||m==="textContent"||m==="innerText"?E.prop(s(h),m):E.prop(h,m);let y=m==="innerHTML"||m==="textContent"||m==="innerText",w=y?u().cloneOf(h):i?.cloneOf(h);w&&y?p(h,w,m,g):(E.prop(h,m,g),w&&E.prop(w,m,g))},clone(f){let m=s(f);if(m===f)return E.clone(f);let g=a.importNode(m,!0);return Je(g),g},insertAt(f,m,g){let h=c(f),y=v.children(h)[g]||(()=>{for(let T=h.children.length-1;T>=0;T--){let A=h.children[T];if(u().cloneOf(A))return A.nextElementSibling}return h.firstElementChild})(),w=c(m);h.insertBefore(w,y||null);let b=u().cloneOf(h);if(b){let T=u().cloneOf(w);T||(T=a.importNode(w,!0),d(w,T));let A=Array.from(b.children);b.insertBefore(T,A[g]||null)}},insertBefore(f,m){let g=c(f),h=c(m);g.parentNode.insertBefore(h,g);let y=u().cloneOf(g.parentNode);if(y){let w=u().cloneOf(h);w||(w=a.importNode(h,!0),d(h,w));let b=u().cloneOf(g);b?b.before(w):y.appendChild(w)}},insertAfter(f,m){let g=c(f),h=c(m);g.parentNode.insertBefore(h,g.nextSibling);let y=u().cloneOf(g.parentNode);if(y){let w=u().cloneOf(h);w||(w=a.importNode(h,!0),d(h,w));let b=u().cloneOf(g);b?b.after(w):y.appendChild(w)}},identity(f){return c(f)||null},remove(f){let m=c(f),g=u().cloneOf(m);E.remove(m),g&&E.remove(g)},replaceWith(f,m){let g=c(f),h=u().cloneOf(g),y=E.replaceWith(g,m);if(h){let w=D(y,{capability:"data",exclude:t.exclude||null});if(!w.root)h.remove();else{h.replaceWith(w.root);let b=T=>{let A=w.original(T);A&&(i.liveToClone.set(A,T),i.cloneToLive.set(T,A));for(let x of Array.from(T.childNodes||[]))b(x)};b(w.root)}}return y}};return v}var P=E,I=e=>({codecs:pt(),...e}),ie={extract:(e,t,r={})=>q(N(e,r),e,t,I(r)),apply:(e,t,r,l={})=>B(N(e,{...l,_write:!0}),e,t,r,I(l)),findRulesIn:(e,t)=>re(P,e,t),findRules:(e,t)=>be(P,e,t),bind:(e,t,r={})=>{let l=be(P,e,t);if(!l){let o=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${o}`)}let n=I({version:l.version,...r});return{...l,get:()=>q(N(e,r),e,l.rules,n),set:o=>B(N(e,{...r,_write:!0}),e,l.rules,o,n)}},codecs:{register:ft,get:dt},parseStrict:It,parseRelaxed:He,ruleAttrIndex:C,splitRule:S,errors:O,DOM_PROPERTIES:Oe},K=e=>!!e&&typeof e.nodeType=="number";function Ke(e){let t=e&&e.ownerDocument?e.ownerDocument:e,r=re(P,t,"api");if(!r)throw new O.NoRulesTag("api");return{rules:r.rules,version:r.version}}function rr(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let r=e;for(;r.parentNode;)r=r.parentNode;return r}function nr(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let r of e.childNodes)t.appendChild(r.cloneNode(!0));return t}function lr(e,t){let r=[];for(;t!==e;){let l=t.parentNode;r.push(Array.prototype.indexOf.call(l.childNodes,t)),t=l}return r.reverse()}function or(e,t){return t.reduce((r,l)=>r.childNodes[l],e)}function $(e,t){let r=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&r.unshift(e),r}function ir(e,t){let r=$(e,"option"),l=$(t,"option");r.forEach((u,s)=>l[s].selected=u.selected);let n=$(e,"input"),o=$(t,"input");n.forEach((u,s)=>{let c=u.type.toLowerCase();c!=="file"&&(o[s].value=u.value),(c==="checkbox"||c==="radio")&&(o[s].checked=u.checked)});let a=$(e,"textarea"),i=$(t,"textarea");a.forEach((u,s)=>i[s].value=u.value)}function X(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let r=e.startsWith("@")?0:C(e);if(r===-1)return;let l=e.slice(r+1);if(Ne.has(l))throw new O.RuleTargetReadOnly(l);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(r=>X(e[1],r));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[r,l]of Object.entries(e))X(l,t[r])}}function ur(e,t,r,l){let n=I({templateAttr:"cms-template",version:l}),o=rr(e),a=lr(o,e),i=nr(o);ir(o,i);let u=or(i,a),s=N(i,{...n,_write:!0}),c=Zt(s,u,t,r,n);if(c.unknownKeys.length||c.unmatched.length)throw new O.WriteRejected(c.unknownKeys,c.unmatched);let d=ve(s);B(d,u,t,r,n),d.assertClean(),X(t,r);let p=ve(N(o,{...n,_write:!0}));B(p,e,t,r,n),p.assertClean()}function ar(e){if(!(e instanceof Error))return e;let t=e instanceof O.UnknownCodec||e instanceof O.CodecRefused?e.code:e.name||"Error";try{e.code=t}catch{Object.defineProperty(e,"code",{value:t,configurable:!0,enumerable:!0})}return e instanceof O.WriteRefused?e.details=e.refusals:e instanceof O.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof O.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function sr(e,t){let r=K(e)?e:document,l=K(e)?t:e;if(l===void 0){let{rules:n,version:o}=Ke(r);return q(N(r),r,n,I({version:o}))}return ie.bind(r,l).get()}function cr(e,t,r){try{if(!K(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let{rules:l,version:n}=r===void 0?Ke(e):ie.bind(e,r);ur(e,l,t,n)}catch(l){throw ar(l)}return e}var fr={engine:ie,extractData:sr,applyData:cr},dr=fr;export{ie as a,sr as b,cr as c,dr as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as p,p as f,s as i,v as y}from"./c-
|
|
1
|
+
import{n as p,p as f,s as i,v as y}from"./c-UW6MMZ4V.js";import{i as m}from"./c-HA6INT6J.js";var S="http://www.w3.org/1999/xhtml",C=64*1024,g=256;function E(e){return e.namespaceURI===S&&e.localName!=="template"&&e.getElementsByTagName("*").length>=g}function*d(e,t,l,o){for(let n of e.childNodes){if(n.nodeType===1&&E(n)){yield*T(n,l,o);continue}let r;n.nodeType===1?r=n.outerHTML:(t.replaceChildren(n.cloneNode(!1)),r=t.innerHTML),l.push(r),o.bytes+=r.length,o.bytes>=C&&(o.bytes=0,yield)}}function*T(e,t,l){let o=i(e,!1),n=o.outerHTML,r=`</${o.localName}>`;t.push(n.slice(0,n.length-r.length)),yield*d(e,o,t,l),t.push(r)}function*h(e){let t=["<!DOCTYPE html>"];return yield*T(e,t,{bytes:0}),t.join("")}function*k(e){let t=p(e);if(!t.length)return yield*h(e);let l=f(t),o;try{o=yield*h(e)}finally{for(let[n,r]of t)n.replaceChildren(...r)}for(let[n,r]of l)o=o.split(n).join(r);return o}function*M(e){return y(e),yield*h(e)}function*b(e){let t=i(e,!1);for(let s of m)t.removeAttribute(s);let l=t.outerHTML,o=`</${t.localName}>`,n=["<!DOCTYPE html>",l.slice(0,l.length-o.length)],r=p(e),u=r.length?f(r):[];try{yield*d(e,i(e,!1),n,{bytes:0})}finally{for(let[s,a]of r)s.replaceChildren(...a)}n.push(o);let c=n.join("");for(let[s,a]of u)c=c.split(s).join(a);return c}export{h as a,k as b,M as c,b as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as w}from"./c-MJ7GVE46.js";import{b as m,c as v}from"./c-
|
|
1
|
+
import{a as w}from"./c-MJ7GVE46.js";import{b as m,c as v}from"./c-WOJ2RTV4.js";import"./c-VKEDWYDF.js";import{m as f,o as y}from"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-UW6MMZ4V.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var L="script[editmode\\:resource]";function d(e=document){let t=[...e.querySelectorAll(L)];return{reversible:t.length===0,scripts:t}}function R(e=document){return{enable(){m(e)},quiesce(){},resume(){},dispose(){v()}}}function g(e=document){return{id:"clay:resources",order:100,prepare(){let{reversible:t}=d(e);if(!t)throw Object.assign(new Error("clay.modeLifecycle: an editmode:resource script cannot be re-run"),{code:"unsupported-plugin"});return R(e)}}}var b=!1,S=()=>{let e=new Set;for(let t of f()){if(typeof t?.then=="function")continue;let n=t?.id;if(typeof n!="string"||typeof t?.prepare!="function"||e.has(n))return!1;e.add(n)}return!0},j=e=>[...e?.edit?.core??[],...e?.edit?.plugins??[],...e?.edit?.late??[],...e?.view?.plugins??[],...e?.view?.late??[]];function A(e){return[...new Set(j(e))].filter(t=>w(t)===null)}function T(e){return S()&&A(e).length===0&&d().reversible}function _(){b||(b=!0,y(g()))}var l=()=>Object.assign(new Error("clay.modeLifecycle: the import was cancelled"),{name:"AbortError",code:"aborted"}),O=15e3,E=(e,t)=>Object.assign(new Error(`clayjs: ${e}`),{code:t}),q=(e,t)=>new Promise((n,s)=>{if(t?.aborted)return s(l());let o=()=>s(l());t?.addEventListener?.("abort",o),Promise.resolve(e).then(i=>{t?.removeEventListener?.("abort",o),n(i)},i=>{t?.removeEventListener?.("abort",o),s(i)})}),h=e=>!e?.represented||e.represented.bytes===null,P=e=>e&&(e.liveSync??e.default??e)||null;async function k(e,t={}){let n=t.signal,s={signal:n,deadline:O},o=e?.loaded?.["plugins/page-view.js"];if(o?.ready){await q(o.acquired,n);let a=await o.prepareHandoff(s);if(h(a))throw E("the reader has no file to hand over","not-acquired");return a}let i=P(e?.loaded?.["sync/live-sync.js"]);if(i&&!i.isDestroyed&&i.lane==="saved"){let a=await i.prepareHandoff(s);if(h(a))throw E("the reader has no file to hand over","not-acquired");return a}return null}function I(e,t=null){let n=e?.loaded?.["plugins/page-view.js"],s=Array.isArray(e?.view?.plugins)?e.view.plugins.includes("sync/live-sync.js"):!!e?.loaded?.["sync/live-sync.js"];if(n&&((n.restart??n.start)({sync:s,represented:t}),!s))return;let o=P(e?.loaded?.["sync/live-sync.js"]);if(o)return o.start(o.currentFile,{lane:"saved",represented:t})}async function V(e,t,{signal:n}={}){let s=e.inflight||=new Map,o=[],i=()=>{if(n?.aborted)throw l()},a=e.loadEditHints?.();if(a)try{await a}catch{}let u=r=>{if(!s.has(r)){let c=Promise.resolve().then(()=>e.modules[r]()).catch(x=>{throw s.delete(r),x});s.set(r,c)}return s.get(r)};for(let r of t.core??[]){if(e.loaded[r])continue;i();let c=await u(r);e.loaded[r]=c,c.install?.()}e.attachEditCore(e.loaded);for(let r of t.plugins??[]){if(e.loaded[r])continue;i();let c=await u(r);e.loaded[r]=c,e.attach(r,c),o.push(r)}let p=(t.late??[]).filter(r=>!e.loaded[r]);if(p.length){i();try{await e.late}catch{}for(let r of p){if(e.loaded[r])continue;i();let c=await u(r);e.loaded[r]=c,e.attach(r,c),o.push(r)}}return o}export{V as importPlan,T as liveAllowed,_ as openResources,k as prepareReader,I as startReader,A as unsupportedPaths};
|