@panphora/clayjs 1.24.0 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +16610 -14400
- package/dist/m/attrs/{refetch-on-save-DPGJJMGN.js → refetch-on-save-5CBFUJUF.js} +1 -1
- package/dist/m/attrs/save-freeze-MH3AOD56.js +1 -0
- package/dist/m/c-277QP5ET.js +1 -0
- package/dist/m/{c-SXGEWPFC.js → c-3E2IK5HU.js} +1 -1
- package/dist/m/{c-A4L7APIU.js → c-4AE2A2LK.js} +1 -1
- package/dist/m/{c-DZPO22O3.js → c-4Q6QIODW.js} +1 -1
- package/dist/m/{c-RO73MKKR.js → c-52OC3OH3.js} +1 -1
- package/dist/m/{c-VNAYHV2J.js → c-5PZYDWTW.js} +1 -1
- package/dist/m/c-5Q5XBN56.js +1 -0
- package/dist/m/c-5SZ6KFR5.js +1 -0
- package/dist/m/{c-ZRGEN6QQ.js → c-AI3H6ETU.js} +2 -2
- package/dist/m/{c-7V6MGMX2.js → c-BCWYEG6P.js} +1 -1
- package/dist/m/{c-A7N5TNSL.js → c-BJ2RRQBQ.js} +1 -1
- package/dist/m/{c-CTGRDT6E.js → c-C6YZNU6E.js} +1 -1
- package/dist/m/{c-DLBX4JCJ.js → c-C7SUMNMI.js} +1 -1
- package/dist/m/c-CITLTVQ4.js +4 -0
- package/dist/m/{c-TWOXQQKV.js → c-CL5LSATX.js} +1 -1
- package/dist/m/c-CU33V6RW.js +4 -0
- package/dist/m/{c-2R4OBWIP.js → c-D62HRSZK.js} +1 -1
- package/dist/m/{c-DD26VXAP.js → c-DT7E76Z2.js} +1 -1
- package/dist/m/{c-54ZZZYUN.js → c-EAV7A6BT.js} +1 -1
- package/dist/m/{c-RBPZNU2D.js → c-EQ5NBOGA.js} +1 -1
- package/dist/m/{c-KQKKIVLW.js → c-FBOO2UY3.js} +1 -1
- package/dist/m/{c-RTSRGGTP.js → c-FJDTDGDA.js} +1 -1
- package/dist/m/{c-MQKSKQHG.js → c-FKTALXNV.js} +1 -1
- package/dist/m/{c-GNIVHLEJ.js → c-GDNZEOOZ.js} +1 -1
- package/dist/m/{c-SUXHUL7U.js → c-GEAG5XAK.js} +1 -1
- package/dist/m/{c-UM7VZDTW.js → c-GY4BREDT.js} +1 -1
- package/dist/m/{c-4PO3YGDC.js → c-HGG7M2S3.js} +1 -1
- package/dist/m/c-HKSLOVU4.js +1 -0
- package/dist/m/{c-KJHVB2KG.js → c-HXGNH6GY.js} +1 -1
- package/dist/m/{c-FLEIU6CG.js → c-IESDKFO6.js} +1 -1
- package/dist/m/{c-SNVDWMM3.js → c-IJHF4IO6.js} +1 -1
- package/dist/m/{c-SGGGCIVD.js → c-IL5IVTOG.js} +1 -1
- package/dist/m/c-JB5YU57S.js +1 -0
- package/dist/m/{c-MP6S4AZU.js → c-JD2VFAYG.js} +2 -2
- package/dist/m/{c-CV4T65JE.js → c-JWW6BHWD.js} +3 -3
- package/dist/m/{c-GM7OA6EJ.js → c-K4M76VPM.js} +1 -1
- package/dist/m/{c-RXTPKCMC.js → c-KU3PX7LL.js} +1 -1
- package/dist/m/{c-2PVGJFI5.js → c-KYTVZT4D.js} +1 -1
- package/dist/m/{c-RJKKRWHW.js → c-M7ITYKMF.js} +1 -1
- package/dist/m/c-MFB74XVN.js +3 -0
- package/dist/m/c-MOP5KBWZ.js +1 -0
- package/dist/m/{c-YB3CDTDZ.js → c-MUM53J5J.js} +1 -1
- package/dist/m/{c-YK2L436K.js → c-MV7TEUTD.js} +1 -1
- package/dist/m/{c-LA2BW7UY.js → c-MZCOGNZL.js} +1 -1
- package/dist/m/{c-YGGO2G2L.js → c-N4GEJMXW.js} +1 -1
- package/dist/m/{c-NQAPWM7O.js → c-NADLYVAH.js} +1 -1
- package/dist/m/{c-RS77ODLY.js → c-NL4I4KNG.js} +1 -1
- package/dist/m/{c-6UPEKW6O.js → c-O2QZDVZ2.js} +1 -1
- package/dist/m/{c-LTSPHVAK.js → c-OBMZASYQ.js} +1 -1
- package/dist/m/{c-LUXAB2XI.js → c-ORLPQFNU.js} +1 -1
- package/dist/m/c-P73XPAOA.js +1 -0
- package/dist/m/{c-PWJSJEJU.js → c-PNZIJFG7.js} +1 -1
- package/dist/m/{c-ZKKAF4UT.js → c-PRZNJUYZ.js} +2 -2
- package/dist/m/{c-Q6VNQDJE.js → c-Q2CB57UG.js} +1 -1
- package/dist/m/{c-TWCXBWS3.js → c-QCDVDZIR.js} +1 -1
- package/dist/m/{c-P5NKFRL4.js → c-QDVG4NAZ.js} +1 -1
- package/dist/m/c-QWB53KRW.js +1 -0
- package/dist/m/{c-GNI7WHKF.js → c-RGAALCDU.js} +1 -1
- package/dist/m/c-RHPHMTF2.js +2 -0
- package/dist/m/{c-BULK5J4M.js → c-RWJ3OSCP.js} +1 -1
- package/dist/m/{c-5FXEKU4Y.js → c-SEVOS4UE.js} +1 -1
- package/dist/m/{c-PMRRMT72.js → c-SFYTKRU7.js} +1 -1
- package/dist/m/{c-47IBJGPQ.js → c-SFZRY6RT.js} +1 -1
- package/dist/m/{c-QENKN7QI.js → c-SGG6MUXW.js} +1 -1
- package/dist/m/c-SMLAJASY.js +1 -0
- package/dist/m/{c-VSEUFJAO.js → c-SUAC5RSG.js} +1 -1
- package/dist/m/{c-6RGEQNVV.js → c-SXZYVXD6.js} +1 -1
- package/dist/m/{c-ZFO5RW6G.js → c-TCFVG3I4.js} +1 -1
- package/dist/m/{c-PZRWZZRO.js → c-TLQINES7.js} +2 -2
- package/dist/m/c-U4TWEIKZ.js +1 -0
- package/dist/m/{c-FZRZPIFS.js → c-U65PREMC.js} +1 -1
- package/dist/m/{c-7YETSAVY.js → c-U7F66I64.js} +1 -1
- package/dist/m/{c-WOELSNWS.js → c-UD4VDBGJ.js} +1 -1
- package/dist/m/{c-VI3BJHCM.js → c-V2FPBRO6.js} +1 -1
- package/dist/m/{c-2OIKXOY6.js → c-V4B3RUWB.js} +1 -1
- package/dist/m/{c-O5ARALMJ.js → c-V5L6HWVL.js} +1 -1
- package/dist/m/c-VMXCX52Q.js +1 -0
- package/dist/m/{c-PVJMJL3P.js → c-VO6RSFCO.js} +1 -1
- package/dist/m/c-WDFQ7PBU.js +1 -0
- package/dist/m/{c-OG6GFSUX.js → c-WGQVSKKC.js} +1 -1
- package/dist/m/c-WSTUCBHV.js +1 -0
- package/dist/m/{c-EY5KDUZF.js → c-WVCT3ITX.js} +1 -1
- package/dist/m/{c-SE3SIY7Y.js → c-X3V4RWMA.js} +1 -1
- package/dist/m/{c-HIX5H5L7.js → c-XHZIKRCV.js} +1 -1
- package/dist/m/{c-2BLVA6IN.js → c-XQTERKQA.js} +1 -1
- package/dist/m/{c-A5ZBFICF.js → c-YFO6ZJLQ.js} +1 -1
- package/dist/m/{c-PD5AKHY3.js → c-YX2MC7YL.js} +1 -1
- package/dist/m/{c-OYHI67B6.js → c-YYGUHSZR.js} +1 -1
- package/dist/m/{c-YYMZWQLR.js → c-Z2OZFX3N.js} +1 -1
- package/dist/m/{c-AT7GLQGV.js → c-ZEA3DCG3.js} +1 -1
- package/dist/m/{c-75N3KG35.js → c-ZJG6C2WL.js} +1 -1
- package/dist/m/{c-FVPNX2GO.js → c-ZORVIXUR.js} +1 -1
- package/dist/m/{c-FV46ZKGX.js → c-ZPI7M5U5.js} +1 -1
- package/dist/m/core/{admin-attrs-5UGMYCKW.js → admin-attrs-ZI6K6UGM.js} +1 -1
- package/dist/m/core/{autosave-4P66VXX7.js → autosave-BSM2ABJL.js} +1 -1
- package/dist/m/core/{conflict-notice-BAR23OWH.js → conflict-notice-7EQLDYPA.js} +1 -1
- package/dist/m/core/draft-mode-M5XNYBMY.js +1 -0
- package/dist/m/core/{host-permission-3HE4CFD6.js → host-permission-5BYP24GC.js} +1 -1
- package/dist/m/core/{is-edit-mode-GK7IFFMT.js → is-edit-mode-73OXKK5H.js} +1 -1
- package/dist/m/core/{persist-AIJGTKKI.js → persist-2SZO3PCE.js} +1 -1
- package/dist/m/core/{recovery-LPB6X72P.js → recovery-VZF7RJZF.js} +1 -1
- package/dist/m/core/{save-FV4ZCKBI.js → save-K6Q47J2X.js} +1 -1
- package/dist/m/core/{save-core-K7XFAWQ4.js → save-core-U3Z44XBO.js} +1 -1
- package/dist/m/core/{site-edits-TEQORBJU.js → site-edits-CFMF6GHD.js} +1 -1
- package/dist/m/core/{snapshot-FJP5IJL3.js → snapshot-PWCHYFL6.js} +1 -1
- package/dist/m/core/unsaved-warning-2WRZLJH5.js +1 -0
- package/dist/m/events/{index-B6TGDYMG.js → index-YKQIBZE5.js} +1 -1
- package/dist/m/internals/index-FSLC4M7J.js +1 -0
- package/dist/m/lib/{cache-bust-NH7VBWHO.js → cache-bust-BL4KUQAJ.js} +1 -1
- package/dist/m/loader-RC54UV7H.js +1 -0
- package/dist/m/manifest-3B84C829.js +1 -0
- package/dist/m/manifest-edit-1CB79AD4.js +1 -0
- package/dist/m/manifest.json +1215 -1129
- package/dist/m/options/{options-55LQHSJ4.js → options-LKIZ7YTG.js} +1 -1
- package/dist/m/page/{editor-KAZDJNND.js → editor-PKSPJ2XJ.js} +2 -2
- package/dist/m/plugins/{ai-edit-CUKQQWJX.js → ai-edit-3LG6MGS3.js} +1 -1
- package/dist/m/plugins/{cms-JANMGPHM.js → cms-T2HLI7JG.js} +16 -16
- package/dist/m/plugins/{demo-JIR7DXJA.js → demo-LMCMBILC.js} +1 -1
- package/dist/m/plugins/{derive-QVI3LI3A.js → derive-7DR5TUDH.js} +1 -1
- package/dist/m/plugins/{indicator-DAKZGAWI.js → indicator-CTKX4EY7.js} +1 -1
- package/dist/m/plugins/{live-UAJGWRNP.js → live-IFLL6YN5.js} +1 -1
- package/dist/m/plugins/{menu-BFJ644YX.js → menu-YJZ3JWBC.js} +1 -1
- package/dist/m/plugins/page-GTDPYGE4.js +2 -0
- package/dist/m/plugins/{page-view-OYN7Z5TS.js → page-view-NMCCU6MF.js} +1 -1
- package/dist/m/plugins/{people-VBDR5Y22.js → people-6WIWCZEG.js} +1 -1
- package/dist/m/plugins/{richclay-CBLZRFB4.js → richclay-L3BZMX4I.js} +3 -3
- package/dist/m/plugins/sortable-365SRRL3.js +1 -0
- package/dist/m/plugins/{source-ZXDD7F6X.js → source-7LSGOV46.js} +1 -1
- package/dist/m/plugins/{undo-5JI5G7CQ.js → undo-UES4KS7B.js} +1 -1
- package/dist/m/plugins/{upgrade-6B6QS3NR.js → upgrade-MMPZUCDM.js} +1 -1
- package/dist/m/plugins/{upload-DNJNW6H3.js → upload-NZET3DNQ.js} +1 -1
- package/dist/m/plugins/visitor-drafts-V5YB7XDH.js +20 -0
- package/dist/m/plugins/{visitor-drafts-owner-VIAZC3CF.js → visitor-drafts-owner-TLECTYWS.js} +1 -1
- package/dist/m/plugins/{visitor-menu-ZHKWIKKY.js → visitor-menu-QDV2MYJN.js} +1 -1
- package/dist/m/plugins/wire-3YGUO3GE.js +1 -0
- package/dist/m/{reader-core-F6RY3V64.js → reader-core-VR7EL4WV.js} +2 -2
- package/dist/m/sync/live-sync-XMXXZS3G.js +1 -0
- package/dist/m/vendor/sap-core.vendor-JANUQULT.js +7 -0
- package/dist/offline-manifest.json +724 -664
- package/docs/guide.md +1 -0
- package/entries/clay-data.js +1 -1
- package/entries/sap.js +6 -5
- package/package.json +2 -2
- package/src/core/draft-mode.js +11 -0
- package/src/core/save-core.js +16 -17
- package/src/core/save.js +1 -1
- package/src/core/unsaved-warning.js +2 -2
- package/src/lib/dirty-gate.js +19 -0
- package/src/lib/idb-error-code.js +20 -0
- package/src/loader.js +2 -0
- package/src/plugins/menu/visitor.js +33 -1
- package/src/plugins/page.js +19 -5
- package/src/plugins/sortable.js +7 -0
- package/src/plugins/visitor-drafts/commit.js +350 -0
- package/src/plugins/visitor-drafts/idb.js +227 -0
- package/src/plugins/visitor-drafts/prompt.js +23 -3
- package/src/plugins/visitor-drafts/recovery-menu.js +118 -0
- package/src/plugins/visitor-drafts/recovery.js +64 -0
- package/src/plugins/visitor-drafts/session.js +393 -0
- package/src/plugins/visitor-drafts/store.js +247 -27
- package/src/plugins/visitor-drafts.js +177 -28
- package/src/sync/live-sync.js +1 -1
- package/src/sync/wire-profile.js +9 -4
- 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/hypercms.vendor.js +16 -16
- package/src/vendor/richclay.vendor.js +1 -1
- package/src/vendor/sap-core.vendor.js +6 -5
- package/src/vendor/sap-ownership.vendor.js +181 -11
- package/tool-generation/system.md +1 -1
- package/dist/m/attrs/save-freeze-JZHKRQLR.js +0 -1
- package/dist/m/c-234RSEIW.js +0 -1
- package/dist/m/c-2YIJ6ZA6.js +0 -1
- package/dist/m/c-H2H7TI6O.js +0 -1
- package/dist/m/c-HSNGLIFB.js +0 -3
- package/dist/m/c-JMDKPBMC.js +0 -4
- package/dist/m/c-LO4C4J77.js +0 -1
- package/dist/m/c-N7JPUPGC.js +0 -1
- package/dist/m/c-NEXFVJIT.js +0 -1
- package/dist/m/c-R23UHMXG.js +0 -1
- package/dist/m/c-T527QHOB.js +0 -1
- package/dist/m/c-V2U3F4QX.js +0 -1
- package/dist/m/c-VG5XIN4T.js +0 -1
- package/dist/m/c-YINHPF4V.js +0 -1
- package/dist/m/core/draft-mode-WSQAT67S.js +0 -1
- package/dist/m/core/unsaved-warning-FF63QGKI.js +0 -1
- package/dist/m/internals/index-AX4CG7B2.js +0 -1
- package/dist/m/loader-5IA5OJ3J.js +0 -1
- package/dist/m/manifest-98258645.js +0 -1
- package/dist/m/manifest-edit-ABF56000.js +0 -1
- package/dist/m/plugins/page-ZBIYHGK4.js +0 -2
- package/dist/m/plugins/sortable-HDOQ6GAC.js +0 -1
- package/dist/m/plugins/visitor-drafts-A5FDQ2G7.js +0 -20
- package/dist/m/plugins/wire-XOT7XKJL.js +0 -1
- package/dist/m/sync/live-sync-M2PP2IWY.js +0 -1
- package/dist/m/vendor/sap-core.vendor-OA5SKL7Q.js +0 -6
- /package/dist/m/plugins/{richclay-CBLZRFB4.js.LEGAL.txt → richclay-L3BZMX4I.js.LEGAL.txt} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as wo}from"../c-NFQFV7OP.js";import"../c-MR75YPRT.js";import"../c-4JZDZFF6.js";import"../c-5RZNFTWD.js";import"../c-PKCCHJ5X.js";import"../c-NUHP2XDB.js";import{k as xo}from"../c-
|
|
1
|
+
import{a as wo}from"../c-NFQFV7OP.js";import"../c-MR75YPRT.js";import"../c-4JZDZFF6.js";import"../c-5RZNFTWD.js";import"../c-PKCCHJ5X.js";import"../c-NUHP2XDB.js";import{k as xo}from"../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-WRBKEJD4.js";import"../c-VHNSBD2M.js";var Eo=[".richclay-toolbar",".richclay-float",".richclay-dialog"],Co=`@layer clay-skin{
|
|
2
2
|
:is(.richclay-toolbar, .richclay-float, .richclay-dialog),:is(.richclay-toolbar, .richclay-float, .richclay-dialog) *{--richclay-surface:light-dark(#FFFCF6, #11131E) !important;--richclay-surface-alt:light-dark(#F4ECDF, #1A1D2C) !important;--richclay-text:light-dark(#2B241B, #ECEAF2) !important;--richclay-muted:light-dark(#6B5942, #8A90AB) !important;--richclay-border:light-dark(#D8C8AF, #353B52) !important;--richclay-accent:light-dark(#8F6310, #D9A445) !important;--richclay-accent-ink:light-dark(#FDF8F0, #0B0C13) !important;--richclay-focus:light-dark(#8F6310, #D9A445) !important;--richclay-danger:light-dark(#A83A2C, #FF5566) !important;--richclay-radius:0px !important;--richclay-control-size:32px !important;--richclay-shadow:0 1px 2px rgba(0,0,0,.12),0 10px 28px -12px rgba(0,0,0,.35) !important}
|
|
3
3
|
:is(.richclay-toolbar, .richclay-float, .richclay-dialog){font-family:system-ui,-apple-system,"Segoe UI",sans-serif !important}
|
|
4
4
|
:where(.richclay-float, .richclay-dialog):is(.richclay-toolbar, .richclay-float, .richclay-dialog){color:light-dark(#2B241B, #ECEAF2) !important;background:light-dark(#FFFCF6, #11131E) !important;border:1px solid light-dark(#D8C8AF, #353B52) !important}
|
|
@@ -95,7 +95,7 @@ import{a as wo}from"../c-NFQFV7OP.js";import"../c-MR75YPRT.js";import"../c-4JZDZ
|
|
|
95
95
|
`)),r.appendChild(N(o))}let a=new et(r,4);for(;o=a.nextNode();)o.data=o.data.replace(/ /g," ");return r.normalize(),W(x("PRE",this._config.tagAttributes.pre,[r]))},t),this.focus()):this.changeFormat({tag:"CODE",attributes:this._config.tagAttributes.code},null,t),this}removeCode(){let t=this.getSelection(),e=t.commonAncestorContainer;return A(e,this._root,"PRE")?(this.modifyBlocks(i=>{let r=this._root,n=i.querySelectorAll("PRE"),o=n.length;for(;o--;){let a=n[o],l=new et(a,4),c;for(;c=l.nextNode();){let h=c.data;h=h.replace(/ (?= )/g,"\xA0");let u=document.createDocumentFragment(),d;for(;(d=h.indexOf(`
|
|
96
96
|
`))>-1;)u.appendChild(document.createTextNode(h.slice(0,d))),u.appendChild(x("BR")),h=h.slice(d+1);c.parentNode.insertBefore(u,c),c.data=h}ut(a,r),Z(a,N(a))}return i},t),this.focus()):this.changeFormat(null,{tag:"CODE"},t),this}toggleCode(){return this.hasFormat("PRE")||this.hasFormat("CODE")?this.removeCode():this.code(),this}_removeFormatting(t,e){for(let i=t.firstChild,r;i;i=r){if(r=i.nextSibling,_(i)){if(i instanceof Text||i.nodeName==="BR"||i.nodeName==="IMG"){e.appendChild(i);continue}}else if(Tt(i)){e.appendChild(this.createDefaultBlock([this._removeFormatting(i,document.createDocumentFragment())]));continue}this._removeFormatting(i,e)}return e}removeAllFormatting(t){if(t||(t=this.getSelection()),t.collapsed)return this.focus();let e=this._root,i=t.commonAncestorContainer;for(;i&&i!==e&&!Tt(i);)i=i.parentNode;if(i||(Tr(t,e),i=e),i instanceof Text)return this.focus();this.saveUndoState(t),Bt(t,i,i,e);let r=t.startContainer,n=t.startOffset,o=t.endContainer,a=t.endOffset,l=document.createDocumentFragment(),c=document.createDocumentFragment(),h=st(o,a,i,e),u=st(r,n,i,e),d;for(;u!==h;)d=u.nextSibling,l.appendChild(u),u=d;if(this._removeFormatting(l,c),c.normalize(),u=c.firstChild,d=c.lastChild,u){i.insertBefore(c,h);let f=Array.from(i.childNodes);n=f.indexOf(u),a=d?f.indexOf(d)+1:0}else h&&(n=Array.from(i.childNodes).indexOf(h),a=n);return t.setStart(i,n),t.setEnd(i,a),Yt(i,t),Y(t),this.setSelection(t),this._updatePath(t,!0),this.focus()}},ua=da;function Fr(t,e){(e==null||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);i<e;i++)r[i]=t[i];return r}function pa(t){if(Array.isArray(t))return t}function fa(t,e){var i=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(i!=null){var r,n,o,a,l=[],c=!0,h=!1;try{if(o=(i=i.call(t)).next,e!==0)for(;!(c=(r=o.call(i)).done)&&(l.push(r.value),l.length!==e);c=!0);}catch(u){h=!0,n=u}finally{try{if(!c&&i.return!=null&&(a=i.return(),Object(a)!==a))return}finally{if(h)throw n}}return l}}function ma(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
97
97
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ga(t,e){return pa(t)||fa(t,e)||ya(t,e)||ma()}function ya(t,e){if(t){if(typeof t=="string")return Fr(t,e);var i={}.toString.call(t).slice(8,-1);return i==="Object"&&t.constructor&&(i=t.constructor.name),i==="Map"||i==="Set"?Array.from(t):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Fr(t,e):void 0}}var Pr=Object.entries,Hr=Object.setPrototypeOf,ba=Object.isFrozen,va=Object.getPrototypeOf,xa=Object.getOwnPropertyDescriptor,j=Object.freeze,V=Object.seal,Xt=Object.create,Ur=typeof Reflect<"u"&&Reflect,ui=Ur.apply,pi=Ur.construct;j||(j=function(t){return t}),V||(V=function(t){return t}),ui||(ui=function(t,e){for(var i=arguments.length,r=new Array(i>2?i-2:0),n=2;n<i;n++)r[n-2]=arguments[n];return t.apply(e,r)}),pi||(pi=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];return new t(...i)});var de=P(Array.prototype.forEach),wa=P(Array.prototype.lastIndexOf),qr=P(Array.prototype.pop),Jt=P(Array.prototype.push),Ea=P(Array.prototype.splice),At=Array.isArray,ue=P(String.prototype.toLowerCase),fi=P(String.prototype.toString),zr=P(String.prototype.match),pe=P(String.prototype.replace),Wr=P(String.prototype.indexOf),Ca=P(String.prototype.trim),Sa=P(Number.prototype.toString),ka=P(Boolean.prototype.toString),Kr=typeof BigInt>"u"?null:P(BigInt.prototype.toString),$r=typeof Symbol>"u"?null:P(Symbol.prototype.toString),K=P(Object.prototype.hasOwnProperty),fe=P(Object.prototype.toString),G=P(RegExp.prototype.test),qt=Ta(TypeError);function P(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;n<i;n++)r[n-1]=arguments[n];return ui(t,e,r)}}function Ta(t){return function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];return pi(t,i)}}function S(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ue;if(Hr&&Hr(t,null),!At(e))return t;let r=e.length;for(;r--;){let n=e[r];if(typeof n=="string"){let o=i(n);o!==n&&(ba(e)||(e[r]=o),n=o)}t[n]=!0}return t}function _a(t){for(let e=0;e<t.length;e++)K(t,e)||(t[e]=null);return t}function X(t){let e=Xt(null);for(let r of Pr(t)){var i=ga(r,2);let n=i[0],o=i[1];K(t,n)&&(At(o)?e[n]=_a(o):o&&typeof o=="object"&&o.constructor===Object?e[n]=X(o):e[n]=o)}return e}function Aa(t){switch(typeof t){case"string":return t;case"number":return Sa(t);case"boolean":return ka(t);case"bigint":return Kr?Kr(t):"0";case"symbol":return $r?$r(t):"Symbol()";case"undefined":return fe(t);case"function":case"object":{if(t===null)return fe(t);let e=t,i=pt(e,"toString");if(typeof i=="function"){let r=i(e);return typeof r=="string"?r:fe(r)}return fe(t)}default:return fe(t)}}function pt(t,e){for(;t!==null;){let r=xa(t,e);if(r){if(r.get)return P(r.get);if(typeof r.value=="function")return P(r.value)}t=va(t)}function i(){return null}return i}function Na(t){try{return G(t,""),!0}catch{return!1}}var jr=j(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),mi=j(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),gi=j(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),La=j(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),yi=j(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Da=j(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Vr=j(["#text"]),Gr=j(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),bi=j(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Zr=j(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Me=j(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Oa=V(/{{[\w\W]*|^[\w\W]*}}/g),Ra=V(/<%[\w\W]*|^[\w\W]*%>/g),Ma=V(/\${[\w\W]*/g),Ia=V(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ba=V(/^aria-[\-\w]+$/),Yr=V(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Fa=V(/^(?:\w+script|data):/i),Pa=V(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ha=V(/^html$/i),Ua=V(/^[a-z][.\w]*(-[.\w]+)+$/i),Qr=V(/<[/\w!]/g),qa=V(/<[/\w]/g),za=V(/<\/no(script|embed|frames)/i),Wa=V(/\/>/i),ft={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ka=function(){return typeof window>"u"?null:window},$a=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null,r="data-tt-policy-suffix";e&&e.hasAttribute(r)&&(i=e.getAttribute(r));let n="dompurify"+(i?"#"+i:"");try{return t.createPolicy(n,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+n+" could not be created."),null}},Xr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Nt=function(t,e,i,r){return K(t,e)&&At(t[e])?S(r.base?X(r.base):{},t[e],r.transform):i};function Jr(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ka(),e=s=>Jr(s);if(e.version="3.4.11",e.removed=[],!t||!t.document||t.document.nodeType!==ft.document||!t.Element)return e.isSupported=!1,e;let i=t.document,r=i,n=r.currentScript;t.DocumentFragment;let o=t.HTMLTemplateElement,a=t.Node,l=t.Element,c=t.NodeFilter;t.NamedNodeMap===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let u=t.DOMParser,d=t.trustedTypes,f=l.prototype,y=pt(f,"cloneNode"),g=pt(f,"remove"),w=pt(f,"nextSibling"),E=pt(f,"childNodes"),D=pt(f,"parentNode"),H=pt(f,"shadowRoot"),J=pt(f,"attributes"),q=a&&a.prototype?pt(a.prototype,"nodeType"):null,ht=a&&a.prototype?pt(a.prototype,"nodeName"):null;if(typeof o=="function"){let s=i.createElement("template");s.content&&s.content.ownerDocument&&(i=s.content.ownerDocument)}let nt,Wt="",Zi,Kn=!1,Ee=0,$n=function(){if(Ee>0)throw qt('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},ee=function(s){$n(),Ee++;try{return nt.createHTML(s)}finally{Ee--}},ks=function(s){$n(),Ee++;try{return nt.createScriptURL(s)}finally{Ee--}},Ts=function(){return Kn||(Zi=$a(d,n),Kn=!0),Zi},We=i,Yi=We.implementation,jn=We.createNodeIterator,_s=We.createDocumentFragment,As=We.getElementsByTagName,Ns=r.importNode,B=Xr();e.isSupported=typeof Pr=="function"&&typeof D=="function"&&Yi&&Yi.createHTMLDocument!==void 0;let Ls=Oa,Ds=Ra,Os=Ma,Rs=Ia,Ms=Ba,Is=Fa,Vn=Pa,Bs=Ua,Gn=Yr,O=null,Zn=S({},[...jr,...mi,...gi,...yi,...Vr]),R=null,Yn=S({},[...Gr,...bi,...Zr,...Me]),M=Object.seal(Xt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ce=null,Qn=null,Dt=Object.seal(Xt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Xn=!0,Qi=!0,Jn=!1,to=!0,Ot=!1,Se=!0,Kt=!1,Xi=!1,Ji=null,tr=null,er=!1,ie=!1,Ke=!1,$e=!1,eo=!0,io=!1,ro="user-content-",ir=!0,rr=!1,re={},gt=null,nr=S({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),no=null,oo=S({},["audio","video","img","source","image","track"]),or=null,ao=S({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),je="http://www.w3.org/1998/Math/MathML",Ve="http://www.w3.org/2000/svg",yt="http://www.w3.org/1999/xhtml",ne=yt,ar=!1,lr=null,Fs=S({},[je,Ve,yt],fi),lo=j(["mi","mo","mn","ms","mtext"]),sr=S({},lo),so=j(["annotation-xml"]),cr=S({},so),Ps=S({},["title","style","font","a","script"]),ke=null,Hs=["application/xhtml+xml","text/html"],Us="text/html",I=null,oe=null,qs=i.createElement("form"),co=function(s){return s instanceof RegExp||s instanceof Function},hr=function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(oe&&oe===s)return;(!s||typeof s!="object")&&(s={}),s=X(s),ke=Hs.indexOf(s.PARSER_MEDIA_TYPE)===-1?Us:s.PARSER_MEDIA_TYPE,I=ke==="application/xhtml+xml"?fi:ue,O=Nt(s,"ALLOWED_TAGS",Zn,{transform:I}),R=Nt(s,"ALLOWED_ATTR",Yn,{transform:I}),lr=Nt(s,"ALLOWED_NAMESPACES",Fs,{transform:fi}),or=Nt(s,"ADD_URI_SAFE_ATTR",ao,{transform:I,base:ao}),no=Nt(s,"ADD_DATA_URI_TAGS",oo,{transform:I,base:oo}),gt=Nt(s,"FORBID_CONTENTS",nr,{transform:I}),Ce=Nt(s,"FORBID_TAGS",X({}),{transform:I}),Qn=Nt(s,"FORBID_ATTR",X({}),{transform:I}),re=K(s,"USE_PROFILES")?s.USE_PROFILES&&typeof s.USE_PROFILES=="object"?X(s.USE_PROFILES):s.USE_PROFILES:!1,Xn=s.ALLOW_ARIA_ATTR!==!1,Qi=s.ALLOW_DATA_ATTR!==!1,Jn=s.ALLOW_UNKNOWN_PROTOCOLS||!1,to=s.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ot=s.SAFE_FOR_TEMPLATES||!1,Se=s.SAFE_FOR_XML!==!1,Kt=s.WHOLE_DOCUMENT||!1,ie=s.RETURN_DOM||!1,Ke=s.RETURN_DOM_FRAGMENT||!1,$e=s.RETURN_TRUSTED_TYPE||!1,er=s.FORCE_BODY||!1,eo=s.SANITIZE_DOM!==!1,io=s.SANITIZE_NAMED_PROPS||!1,ir=s.KEEP_CONTENT!==!1,rr=s.IN_PLACE||!1,Gn=Na(s.ALLOWED_URI_REGEXP)?s.ALLOWED_URI_REGEXP:Yr,ne=typeof s.NAMESPACE=="string"?s.NAMESPACE:yt,sr=K(s,"MATHML_TEXT_INTEGRATION_POINTS")&&s.MATHML_TEXT_INTEGRATION_POINTS&&typeof s.MATHML_TEXT_INTEGRATION_POINTS=="object"?X(s.MATHML_TEXT_INTEGRATION_POINTS):S({},lo),cr=K(s,"HTML_INTEGRATION_POINTS")&&s.HTML_INTEGRATION_POINTS&&typeof s.HTML_INTEGRATION_POINTS=="object"?X(s.HTML_INTEGRATION_POINTS):S({},so);let p=K(s,"CUSTOM_ELEMENT_HANDLING")&&s.CUSTOM_ELEMENT_HANDLING&&typeof s.CUSTOM_ELEMENT_HANDLING=="object"?X(s.CUSTOM_ELEMENT_HANDLING):Xt(null);if(M=Xt(null),K(p,"tagNameCheck")&&co(p.tagNameCheck)&&(M.tagNameCheck=p.tagNameCheck),K(p,"attributeNameCheck")&&co(p.attributeNameCheck)&&(M.attributeNameCheck=p.attributeNameCheck),K(p,"allowCustomizedBuiltInElements")&&typeof p.allowCustomizedBuiltInElements=="boolean"&&(M.allowCustomizedBuiltInElements=p.allowCustomizedBuiltInElements),V(M),Ot&&(Qi=!1),Ke&&(ie=!0),re&&(O=S({},Vr),R=Xt(null),re.html===!0&&(S(O,jr),S(R,Gr)),re.svg===!0&&(S(O,mi),S(R,bi),S(R,Me)),re.svgFilters===!0&&(S(O,gi),S(R,bi),S(R,Me)),re.mathMl===!0&&(S(O,yi),S(R,Zr),S(R,Me))),Dt.tagCheck=null,Dt.attributeCheck=null,K(s,"ADD_TAGS")&&(typeof s.ADD_TAGS=="function"?Dt.tagCheck=s.ADD_TAGS:At(s.ADD_TAGS)&&(O===Zn&&(O=X(O)),S(O,s.ADD_TAGS,I))),K(s,"ADD_ATTR")&&(typeof s.ADD_ATTR=="function"?Dt.attributeCheck=s.ADD_ATTR:At(s.ADD_ATTR)&&(R===Yn&&(R=X(R)),S(R,s.ADD_ATTR,I))),K(s,"ADD_URI_SAFE_ATTR")&&At(s.ADD_URI_SAFE_ATTR)&&S(or,s.ADD_URI_SAFE_ATTR,I),K(s,"FORBID_CONTENTS")&&At(s.FORBID_CONTENTS)&&(gt===nr&&(gt=X(gt)),S(gt,s.FORBID_CONTENTS,I)),K(s,"ADD_FORBID_CONTENTS")&&At(s.ADD_FORBID_CONTENTS)&&(gt===nr&&(gt=X(gt)),S(gt,s.ADD_FORBID_CONTENTS,I)),ir&&(O["#text"]=!0),Kt&&S(O,["html","head","body"]),O.table&&(S(O,["tbody"]),delete Ce.tbody),s.TRUSTED_TYPES_POLICY){if(typeof s.TRUSTED_TYPES_POLICY.createHTML!="function")throw qt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof s.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw qt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let m=nt;nt=s.TRUSTED_TYPES_POLICY;try{Wt=ee("")}catch(b){throw nt=m,b}}else s.TRUSTED_TYPES_POLICY===null?(nt=void 0,Wt=""):(nt===void 0&&(nt=Ts()),nt&&typeof Wt=="string"&&(Wt=ee("")));j&&j(s),oe=s},ho=S({},[...mi,...gi,...La]),uo=S({},[...yi,...Da]),zs=function(s,p,m){return p.namespaceURI===yt?s==="svg":p.namespaceURI===je?s==="svg"&&(m==="annotation-xml"||sr[m]):!!ho[s]},Ws=function(s,p,m){return p.namespaceURI===yt?s==="math":p.namespaceURI===Ve?s==="math"&&cr[m]:!!uo[s]},Ks=function(s,p,m){return p.namespaceURI===Ve&&!cr[m]||p.namespaceURI===je&&!sr[m]?!1:!uo[s]&&(Ps[s]||!ho[s])},$s=function(s){let p=D(s);(!p||!p.tagName)&&(p={namespaceURI:ne,tagName:"template"});let m=ue(s.tagName),b=ue(p.tagName);return lr[s.namespaceURI]?s.namespaceURI===Ve?zs(m,p,b):s.namespaceURI===je?Ws(m,p,b):s.namespaceURI===yt?Ks(m,p,b):!!(ke==="application/xhtml+xml"&&lr[s.namespaceURI]):!1},$t=function(s){Jt(e.removed,{element:s});try{D(s).removeChild(s)}catch{if(g(s),!D(s))throw qt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},po=function(s){let p=E(s);if(p){let b=[];de(p,C=>{Jt(b,C)}),de(b,C=>{try{g(C)}catch{}})}let m=J(s);if(m)for(let b=m.length-1;b>=0;--b){let C=m[b],k=C&&C.name;if(typeof k=="string")try{s.removeAttribute(k)}catch{}}},jt=function(s,p){try{Jt(e.removed,{attribute:p.getAttributeNode(s),from:p})}catch{Jt(e.removed,{attribute:null,from:p})}if(p.removeAttribute(s),s==="is")if(ie||Ke)try{$t(p)}catch{}else try{p.setAttribute(s,"")}catch{}},js=function(s){let p=J(s);if(p)for(let m=p.length-1;m>=0;--m){let b=p[m],C=b&&b.name;if(!(typeof C!="string"||R[I(C)]))try{s.removeAttribute(C)}catch{}}},Vs=function(s){let p=[s];for(;p.length>0;){let m=p.pop();(q?q(m):m.nodeType)===ft.element&&js(m);let b=E(m);if(b)for(let C=b.length-1;C>=0;--C)p.push(b[C])}},fo=function(s){let p=null,m=null;if(er)s="<remove></remove>"+s;else{let k=zr(s,/^[\r\n\t ]+/);m=k&&k[0]}ke==="application/xhtml+xml"&&ne===yt&&(s='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+s+"</body></html>");let b=nt?ee(s):s;if(ne===yt)try{p=new u().parseFromString(b,ke)}catch{}if(!p||!p.documentElement){p=Yi.createDocument(ne,"template",null);try{p.documentElement.innerHTML=ar?Wt:b}catch{}}let C=p.body||p.documentElement;return s&&m&&C.insertBefore(i.createTextNode(m),C.childNodes[0]||null),ne===yt?As.call(p,Kt?"html":"body")[0]:Kt?p.documentElement:C},mo=function(s){return jn.call(s.ownerDocument||s,s,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ge=function(s){return s=pe(s,Ls," "),s=pe(s,Ds," "),s=pe(s,Os," "),s},dr=function(s){var p;s.normalize();let m=jn.call(s.ownerDocument||s,s,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),b=m.nextNode();for(;b;)b.data=Ge(b.data),b=m.nextNode();let C=(p=s.querySelectorAll)===null||p===void 0?void 0:p.call(s,"template");C&&de(C,k=>{ae(k.content)&&dr(k.content)})},Ze=function(s){let p=ht?ht(s):null;return typeof p!="string"||I(p)!=="form"?!1:typeof s.nodeName!="string"||typeof s.textContent!="string"||typeof s.removeChild!="function"||s.attributes!==J(s)||typeof s.removeAttribute!="function"||typeof s.setAttribute!="function"||typeof s.namespaceURI!="string"||typeof s.insertBefore!="function"||typeof s.hasChildNodes!="function"||s.nodeType!==q(s)||s.childNodes!==E(s)},ae=function(s){if(!q||typeof s!="object"||s===null)return!1;try{return q(s)===ft.documentFragment}catch{return!1}},Te=function(s){if(!q||typeof s!="object"||s===null)return!1;try{return typeof q(s)=="number"}catch{return!1}};function St(s,p,m){s.length!==0&&de(s,b=>{b.call(e,p,m,oe)})}let Gs=function(s,p){return!!(Se&&s.hasChildNodes()&&!Te(s.firstElementChild)&&G(Qr,s.textContent)&&G(Qr,s.innerHTML)||Se&&s.namespaceURI===yt&&p==="style"&&Te(s.firstElementChild)||s.nodeType===ft.processingInstruction||Se&&s.nodeType===ft.comment&&G(qa,s.data))},Zs=function(s,p){if(!Ce[p]&&bo(p)&&(M.tagNameCheck instanceof RegExp&&G(M.tagNameCheck,p)||M.tagNameCheck instanceof Function&&M.tagNameCheck(p)))return!1;if(ir&&!gt[p]){let m=D(s),b=E(s);if(b&&m){let C=b.length;for(let k=C-1;k>=0;--k){let T=rr?b[k]:y(b[k],!0);m.insertBefore(T,w(s))}}}return $t(s),!0},go=function(s){if(St(B.beforeSanitizeElements,s,null),Ze(s))return $t(s),!0;let p=I(ht?ht(s):s.nodeName);if(St(B.uponSanitizeElement,s,{tagName:p,allowedTags:O}),Gs(s,p))return $t(s),!0;if(Ce[p]||!(Dt.tagCheck instanceof Function&&Dt.tagCheck(p))&&!O[p])return Zs(s,p);if((q?q(s):s.nodeType)===ft.element&&!$s(s)||(p==="noscript"||p==="noembed"||p==="noframes")&&G(za,s.innerHTML))return $t(s),!0;if(Ot&&s.nodeType===ft.text){let m=Ge(s.textContent);s.textContent!==m&&(Jt(e.removed,{element:s.cloneNode()}),s.textContent=m)}return St(B.afterSanitizeElements,s,null),!1},yo=function(s,p,m){if(Qn[p]||eo&&(p==="id"||p==="name")&&(m in i||m in qs))return!1;let b=R[p]||Dt.attributeCheck instanceof Function&&Dt.attributeCheck(p,s);if(!(Qi&&G(Rs,p))&&!(Xn&&G(Ms,p))){if(b){if(!or[p]&&!G(Gn,pe(m,Vn,""))&&!((p==="src"||p==="xlink:href"||p==="href")&&s!=="script"&&Wr(m,"data:")===0&&no[s])&&!(Jn&&!G(Is,pe(m,Vn,"")))&&m)return!1}else if(!(bo(s)&&(M.tagNameCheck instanceof RegExp&&G(M.tagNameCheck,s)||M.tagNameCheck instanceof Function&&M.tagNameCheck(s))&&(M.attributeNameCheck instanceof RegExp&&G(M.attributeNameCheck,p)||M.attributeNameCheck instanceof Function&&M.attributeNameCheck(p,s))||p==="is"&&M.allowCustomizedBuiltInElements&&(M.tagNameCheck instanceof RegExp&&G(M.tagNameCheck,m)||M.tagNameCheck instanceof Function&&M.tagNameCheck(m))))return!1}return!0},Ys=S({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),bo=function(s){return!Ys[ue(s)]&&G(Bs,s)},Qs=function(s,p,m,b){if(nt&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!m)switch(d.getAttributeType(s,p)){case"TrustedHTML":return ee(b);case"TrustedScriptURL":return ks(b)}return b},Xs=function(s,p,m,b){try{m?s.setAttributeNS(m,p,b):s.setAttribute(p,b),Ze(s)?$t(s):qr(e.removed)}catch{jt(p,s)}},vo=function(s){St(B.beforeSanitizeAttributes,s,null);let p=s.attributes;if(!p||Ze(s))return;let m={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:R,forceKeepAttr:void 0},b=p.length,C=I(s.nodeName);for(;b--;){let k=p[b],T=k.name,Vt=k.namespaceURI,Rt=k.value,ot=I(T),Mt=Rt,tt=T==="value"?Mt:Ca(Mt);if(m.attrName=ot,m.attrValue=tt,m.keepAttr=!0,m.forceKeepAttr=void 0,St(B.uponSanitizeAttribute,s,m),tt=m.attrValue,io&&(ot==="id"||ot==="name")&&Wr(tt,ro)!==0&&(jt(T,s),tt=ro+tt),Se&&G(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,tt)){jt(T,s);continue}if(ot==="attributename"&&zr(tt,"href")){jt(T,s);continue}if(!m.forceKeepAttr){if(!m.keepAttr){jt(T,s);continue}if(!to&&G(Wa,tt)){jt(T,s);continue}if(Ot&&(tt=Ge(tt)),!yo(C,ot,tt)){jt(T,s);continue}tt=Qs(C,ot,Vt,tt),tt!==Mt&&Xs(s,T,Vt,tt)}}St(B.afterSanitizeAttributes,s,null)},Ye=function(s){let p=null,m=mo(s);for(St(B.beforeSanitizeShadowDOM,s,null);p=m.nextNode();)if(St(B.uponSanitizeShadowNode,p,null),go(p),vo(p),ae(p.content)&&Ye(p.content),(q?q(p):p.nodeType)===ft.element){let b=H(p);ae(b)&&(ur(b),Ye(b))}St(B.afterSanitizeShadowDOM,s,null)},ur=function(s){let p=[{node:s,shadow:null}];for(;p.length>0;){let m=p.pop();if(m.shadow){Ye(m.shadow);continue}let b=m.node,C=(q?q(b):b.nodeType)===ft.element,k=E(b);if(k)for(let T=k.length-1;T>=0;--T)p.push({node:k[T],shadow:null});if(C){let T=ht?ht(b):null;if(typeof T=="string"&&I(T)==="template"){let Vt=b.content;ae(Vt)&&p.push({node:Vt,shadow:null})}}if(C){let T=H(b);ae(T)&&p.push({node:null,shadow:T},{node:T,shadow:null})}}};return e.sanitize=function(s){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},m=null,b=null,C=null,k=null;if(ar=!s,ar&&(s="<!-->"),typeof s!="string"&&!Te(s)&&(s=Aa(s),typeof s!="string"))throw qt("dirty is not a string, aborting");if(!e.isSupported)return s;Xi?(O=Ji,R=tr):hr(p),(B.uponSanitizeElement.length>0||B.uponSanitizeAttribute.length>0)&&(O=X(O)),B.uponSanitizeAttribute.length>0&&(R=X(R)),e.removed=[];let T=rr&&typeof s!="string"&&Te(s);if(T){let ot=ht?ht(s):s.nodeName;if(typeof ot=="string"){let Mt=I(ot);if(!O[Mt]||Ce[Mt])throw qt("root node is forbidden and cannot be sanitized in-place")}if(Ze(s))throw qt("root node is clobbered and cannot be sanitized in-place");try{ur(s)}catch(Mt){throw po(s),Mt}}else if(Te(s))m=fo("<!---->"),b=m.ownerDocument.importNode(s,!0),b.nodeType===ft.element&&b.nodeName==="BODY"||b.nodeName==="HTML"?m=b:m.appendChild(b),ur(b);else{if(!ie&&!Ot&&!Kt&&s.indexOf("<")===-1)return nt&&$e?ee(s):s;if(m=fo(s),!m)return ie?null:$e?Wt:""}m&&er&&$t(m.firstChild);let Vt=mo(T?s:m);try{for(;C=Vt.nextNode();)go(C),vo(C),ae(C.content)&&Ye(C.content)}catch(ot){throw T&&po(s),ot}if(T)return de(e.removed,ot=>{ot.element&&Vs(ot.element)}),Ot&&dr(s),s;if(ie){if(Ot&&dr(m),Ke)for(k=_s.call(m.ownerDocument);m.firstChild;)k.appendChild(m.firstChild);else k=m;return(R.shadowroot||R.shadowrootmode)&&(k=Ns.call(r,k,!0)),k}let Rt=Kt?m.outerHTML:m.innerHTML;return Kt&&O["!doctype"]&&m.ownerDocument&&m.ownerDocument.doctype&&m.ownerDocument.doctype.name&&G(Ha,m.ownerDocument.doctype.name)&&(Rt="<!DOCTYPE "+m.ownerDocument.doctype.name+`>
|
|
98
|
-
`+Rt),Ot&&(Rt=Ge(Rt)),nt&&$e?ee(Rt):Rt},e.setConfig=function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hr(s),Xi=!0,Ji=O,tr=R},e.clearConfig=function(){oe=null,Xi=!1,Ji=null,tr=null,nt=Zi,Wt=""},e.isValidAttribute=function(s,p,m){oe||hr({});let b=I(s),C=I(p);return yo(b,C,m)},e.addHook=function(s,p){typeof p=="function"&&K(B,s)&&Jt(B[s],p)},e.removeHook=function(s,p){if(K(B,s)){if(p!==void 0){let m=wa(B[s],p);return m===-1?void 0:Ea(B[s],m,1)[0]}return qr(B[s])}},e.removeHooks=function(s){K(B,s)&&(B[s]=[])},e.removeAllHooks=function(){B=Xr()},e}var ja=Jr(),U=(t,e="0 0 18 18")=>`<svg viewBox="${e}" width="18" height="18" aria-hidden="true" focusable="false">${t}</svg>`,L={bold:U('<path fill="currentColor" d="M178.48,115.7A44,44,0,0,0,148,40H80a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8h80a48,48,0,0,0,18.48-92.3ZM88,56h60a28,28,0,0,1,0,56H88Zm72,136H88V128h72a32,32,0,0,1,0,64Z"/>',"0 0 256 256"),italic:U('<path fill="currentColor" d="M200,56a8,8,0,0,1-8,8H157.77L115.1,192H144a8,8,0,0,1,0,16H64a8,8,0,0,1,0-16H98.23L140.9,64H112a8,8,0,0,1,0-16h80A8,8,0,0,1,200,56Z"/>',"0 0 256 256"),underline:U('<path fill="currentColor" d="M200,224a8,8,0,0,1-8,8H64a8,8,0,0,1,0-16H192A8,8,0,0,1,200,224Zm-72-24a64.07,64.07,0,0,0,64-64V56a8,8,0,0,0-16,0v80a48,48,0,0,1-96,0V56a8,8,0,0,0-16,0v80A64.07,64.07,0,0,0,128,200Z"/>',"0 0 256 256"),strike:U('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H175.93c9.19,7.11,16.07,17.2,16.07,32,0,13.34-7,25.7-19.75,34.79C160.33,211.31,144.61,216,128,216s-32.33-4.69-44.25-13.21C71,193.7,64,181.34,64,168a8,8,0,0,1,16,0c0,17.35,22,32,48,32s48-14.65,48-32c0-14.85-10.54-23.58-38.77-32H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM76.33,104a8,8,0,0,0,7.61-10.49A17.3,17.3,0,0,1,83.11,88c0-18.24,19.3-32,44.89-32,18.84,0,34.16,7.42,41,19.85a8,8,0,0,0,14-7.7C173.33,50.52,152.77,40,128,40,93.29,40,67.11,60.63,67.11,88a33.73,33.73,0,0,0,1.62,10.49A8,8,0,0,0,76.33,104Z"/>',"0 0 256 256"),link:U('<path fill="currentColor" d="M240,88.23a54.43,54.43,0,0,1-16,37L189.25,160a54.27,54.27,0,0,1-38.63,16h-.05A54.63,54.63,0,0,1,96,119.84a8,8,0,0,1,16,.45A38.62,38.62,0,0,0,150.58,160h0a38.39,38.39,0,0,0,27.31-11.31l34.75-34.75a38.63,38.63,0,0,0-54.63-54.63l-11,11A8,8,0,0,1,135.7,59l11-11A54.65,54.65,0,0,1,224,48,54.86,54.86,0,0,1,240,88.23ZM109,185.66l-11,11A38.41,38.41,0,0,1,70.6,208h0a38.63,38.63,0,0,1-27.29-65.94L78,107.31A38.63,38.63,0,0,1,144,135.71a8,8,0,0,0,16,.45A54.86,54.86,0,0,0,144,96a54.65,54.65,0,0,0-77.27,0L32,130.75A54.62,54.62,0,0,0,70.56,224h0a54.28,54.28,0,0,0,38.64-16l11-11A8,8,0,0,0,109,185.66Z"/>',"0 0 256 256"),unlink:U('<path fill="currentColor" d="M198.63,57.37a32,32,0,0,0-45.19-.06L141.79,69.52a8,8,0,0,1-11.58-11l11.72-12.29a1.59,1.59,0,0,1,.13-.13,48,48,0,0,1,67.88,67.88,1.59,1.59,0,0,1-.13.13l-12.29,11.72a8,8,0,0,1-11-11.58l12.21-11.65A32,32,0,0,0,198.63,57.37ZM114.21,186.48l-11.65,12.21a32,32,0,0,1-45.25-45.25l12.21-11.65a8,8,0,0,0-11-11.58L46.19,141.93a1.59,1.59,0,0,0-.13.13,48,48,0,0,0,67.88,67.88,1.59,1.59,0,0,0,.13-.13l11.72-12.29a8,8,0,1,0-11.58-11ZM216,152H192a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16ZM40,104H64a8,8,0,0,0,0-16H40a8,8,0,0,0,0,16Zm120,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V192A8,8,0,0,0,160,184ZM96,72a8,8,0,0,0,8-8V40a8,8,0,0,0-16,0V64A8,8,0,0,0,96,72Z"/>',"0 0 256 256"),ul:U('<path fill="currentColor" d="M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z"/>',"0 0 256 256"),ol:U('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H104a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM104,72H216a8,8,0,0,0,0-16H104a8,8,0,0,0,0,16ZM216,184H104a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM43.58,55.16,48,52.94V104a8,8,0,0,0,16,0V40a8,8,0,0,0-11.58-7.16l-16,8a8,8,0,0,0,7.16,14.32ZM79.77,156.72a23.73,23.73,0,0,0-9.6-15.95,24.86,24.86,0,0,0-34.11,4.7,23.63,23.63,0,0,0-3.57,6.46,8,8,0,1,0,15,5.47,7.84,7.84,0,0,1,1.18-2.13,8.76,8.76,0,0,1,12-1.59A7.91,7.91,0,0,1,63.93,159a7.64,7.64,0,0,1-1.57,5.78,1,1,0,0,0-.08.11L33.59,203.21A8,8,0,0,0,40,216H72a8,8,0,0,0,0-16H56l19.08-25.53A23.47,23.47,0,0,0,79.77,156.72Z"/>',"0 0 256 256"),quote:U('<path fill="currentColor" d="M100,56H40A16,16,0,0,0,24,72v64a16,16,0,0,0,16,16h60v8a32,32,0,0,1-32,32,8,8,0,0,0,0,16,48.05,48.05,0,0,0,48-48V72A16,16,0,0,0,100,56Zm0,80H40V72h60ZM216,56H156a16,16,0,0,0-16,16v64a16,16,0,0,0,16,16h60v8a32,32,0,0,1-32,32,8,8,0,0,0,0,16,48.05,48.05,0,0,0,48-48V72A16,16,0,0,0,216,56Zm0,80H156V72h60Z"/>',"0 0 256 256"),undo:U('<path fill="currentColor" d="M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L44.59,96H72a8,8,0,0,1,0,16H24a8,8,0,0,1-8-8V56a8,8,0,0,1,16,0V85.8L60.25,60A96,96,0,0,1,224,128Z"/>',"0 0 256 256"),redo:U('<path fill="currentColor" d="M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z"/>',"0 0 256 256"),clear:U('<path fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="square" stroke-linejoin="miter" d="M3 3l18 18M5 5v3M9 5h10v3M12 5v3M12 12v7M8 19h8"/>',"0 0 24 24"),code:U('<path fill="currentColor" d="M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z"/>',"0 0 256 256"),indent:U('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM112,72H216a8,8,0,0,0,0-16H112a8,8,0,0,0,0,16ZM216,184H40a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM34.34,141.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0,0-11.32l-40-40A8,8,0,0,0,34.34,61.66L68.69,96,34.34,130.34A8,8,0,0,0,34.34,141.66Z"/>',"0 0 256 256"),outdent:U('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM112,72H216a8,8,0,0,0,0-16H112a8,8,0,0,0,0,16ZM216,184H40a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM72,144a8,8,0,0,0,5.66-13.66L43.31,96,77.66,61.66A8,8,0,0,0,66.34,50.34l-40,40a8,8,0,0,0,0,11.32l40,40A8,8,0,0,0,72,144Z"/>',"0 0 256 256"),blocks:U('<path fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="square" stroke-linejoin="miter" d="M19 4h-9a4.5 4.5 0 0 0 0 9h3M13 4v16M17 4v16"/>',"0 0 24 24"),h1:U('<path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M3.5 5.5v12M12 5.5v12M3.5 11.5H12M17 12l3-2v10"/>',"0 0 24 24"),h2:U('<path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M3.5 5.5v12M12 5.5v12M3.5 11.5H12M16 12.5c0-3.5 6-3.5 6 0 0 2-2.5 3.5-6 7.5h6"/>',"0 0 24 24"),h3:U('<path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M3.5 5.5v12M12 5.5v12M3.5 11.5H12M16 11c1.5-1.5 6-1.5 6 1.5 0 1.5-1.5 2.5-3 2.5h-1M19 15c1.5 0 3 1 3 2.5 0 3-4.5 3-6 1.5"/>',"0 0 24 24")},Et=t=>t.blocksStayOut(),Va=t=>!!t.element.closest("a"),Ie={minimal:["bold","italic","link","unorderedList"],inline:["bold","italic","underline","strikethrough","code","link","undo","redo","clearFormatting"],standard:["blockMenu","bold","italic","underline","strikethrough","code","link","unorderedList","orderedList","quote","outdent","indent","undo","redo","clearFormatting"]};function Ga(){return new Map(Ya.map(t=>[t.id,t]))}function me(t=globalThis){let e=t?.navigator;return e?/Mac|iPhone|iPad|iPod/.test(e.platform||e.userAgent||""):!1}function Za(t,e=globalThis){return t?t.replace("Mod",me(e)?"Cmd":"Ctrl"):""}var Ya=[Lt("bold","Bold",L.bold,"Mod+B","inline",t=>t.toggleFormat("B","bold","removeBold")),Lt("italic","Italic",L.italic,"Mod+I","inline",t=>t.toggleFormat("I","italic","removeItalic")),Lt("underline","Underline",L.underline,"Mod+U","inline",t=>t.toggleFormat("U","underline","removeUnderline")),Lt("strikethrough","Strikethrough",L.strike,"Mod+Shift+7","inline",t=>t.toggleFormat("S","strikethrough","removeStrikethrough")),Lt("code","Code",L.code,null,"inline",t=>t.toggleCode(),t=>t.selectionHasFormat("CODE")||t.selectionHasFormat("PRE")),{id:"link",label:"Link",ariaLabel:"Insert or edit link",icon:L.link,group:"links",shortcut:"Mod+K",mutates:!1,isDisabled:Va,run:t=>t.openLinkDialog(),isActive:t=>!!t.currentLinkElement()},{id:"unlink",label:"Remove link",ariaLabel:"Remove link",icon:L.unlink,group:"links",run:t=>t.squire.removeLink()},Lt("unorderedList","Bulleted list",L.ul,"Mod+Shift+8","lists",t=>t.toggleList("UL"),t=>t.pathHas("UL"),Et),Lt("orderedList","Numbered list",L.ol,"Mod+Shift+9","lists",t=>t.toggleList("OL"),t=>t.pathHas("OL"),Et),Lt("quote","Quote",L.quote,null,"blocks",t=>t.pathHas("BLOCKQUOTE")?t.squire.decreaseQuoteLevel():t.squire.increaseQuoteLevel(),t=>t.pathHas("BLOCKQUOTE"),Et),{id:"outdent",label:"Outdent",ariaLabel:"Decrease indent",icon:L.outdent,group:"blocks",shortcut:"Mod+[",isDisabled:Et,run:t=>t.outdent()},{id:"indent",label:"Indent",ariaLabel:"Increase indent",icon:L.indent,group:"blocks",shortcut:"Mod+]",isDisabled:Et,run:t=>t.indent()},{id:"undo",label:"Undo",ariaLabel:"Undo",icon:L.undo,group:"history",shortcut:"Mod+Z",mutates:!1,run:t=>t.squire.undo()},{id:"redo",label:"Redo",ariaLabel:"Redo",icon:L.redo,group:"history",shortcut:"Mod+Shift+Z",mutates:!1,run:t=>t.squire.redo()},{id:"clearFormatting",label:"Clear formatting",ariaLabel:"Clear formatting",icon:L.clear,group:"cleanup",run:t=>t.squire.removeAllFormatting()},{id:"blockMenu",type:"menu",label:"Block style",ariaLabel:"Choose block style",icon:L.blocks,group:"blocks",isDisabled:Et,options:[Be("Paragraph","P",L.blocks),Be("Heading 1","H1",L.h1),Be("Heading 2","H2",L.h2),Be("Heading 3","H3",L.h3),{label:"Quote",icon:L.quote,value:"BLOCKQUOTE",isDisabled:Et,run:t=>t.squire.increaseQuoteLevel(),isActive:t=>t.pathHas("BLOCKQUOTE")},{label:"Code block",icon:L.code,value:"PRE",isDisabled:Et,run:t=>t.setBlockType("PRE"),isActive:t=>t.pathHas("PRE")}]}];function Lt(t,e,i,r,n,o,a=c=>c.selectionHasFormat(Qa(t)),l){return{id:t,label:e,ariaLabel:e,icon:i,group:n,shortcut:r,isDisabled:l,run:o,isActive:a}}function Qa(t){return{bold:"B",italic:"I",underline:"U",strikethrough:"S"}[t]}function Be(t,e,i){return{label:t,icon:i,value:e,isDisabled:Et,run:r=>r.setBlockType(e),isActive:r=>r.pathHas(e)}}var vi=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,Fe=/[^ \t\r\n]/,Xa=new Set(["BR","HR","IFRAME","IMG","INPUT","WBR"]),xi=t=>t?.nodeType===1&&t.matches('[editor-ui],[clay~="editor-ui"]'),ge=new Set(["svg","math"]);function Pe(t){let e=t.nodeType;return e===3||e===8?!0:e!==1?!1:ge.has(t.nodeName)?!0:vi.test(t.nodeName)?Array.from(t.childNodes).every(Pe):!1}function ye(t){return Array.from(t.childNodes).some(e=>!Pe(e))}var wi=t=>t?.nodeType===1&&!ge.has(t.nodeName)&&!vi.test(t.nodeName);function Ei(t,e){let i=Array.from(t.childNodes),r=0;return i.forEach((n,o)=>{if(!(n.nodeType!==1||ge.has(n.nodeName))&&(r+=Ei(n,e),!!wi(n))){for(wi(i[o-1])&&t.insertBefore(e(),n);n.firstChild;)t.insertBefore(n.firstChild,n);n.remove(),r+=1}}),r}var Ci=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","COLGROUP"]);function Si(t){return!!t.closest?.("p")||Ci.has(t.nodeName)}var Ja=new Set(["P","H1","H2","H3","H4","H5","H6","PRE","LABEL","LEGEND","LI","TD","TH","DT","DD","FIGCAPTION","SUMMARY","CAPTION"]);function tl(t){return Ja.has(t.nodeName)||ki(t)}var tn=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"]),el=new Set(["SCRIPT","STYLE","TEXTAREA","TITLE","IFRAME","NOSCRIPT","XMP"]),en="http://www.w3.org/1999/xhtml";function il(t){return Ci.has(t.nodeName)||tn.has(t.nodeName)||el.has(t.nodeName)||t.nodeName==="TEMPLATE"||!!t.namespaceURI&&t.namespaceURI!==en}function rl(t){return Ci.has(t.nodeName)?"a table element cannot be an editable region. Move the editable attribute to a <td>, a <th>, or an element inside one.":t.namespaceURI&&t.namespaceURI!==en?"an SVG or MathML element cannot be an editable region: an edit puts an HTML block inside it, and the next page load moves that text out of the graphic entirely. Put a <foreignObject> in the SVG and mark an HTML element inside it instead.":tn.has(t.nodeName)?"this element cannot contain anything, so there is nothing to edit. Move the editable attribute to an element that holds text.":t.nodeName==="TEMPLATE"?"a <template> keeps its content out of the document, so edits to it are never saved.":"this element treats its content as plain text, so any edit would be saved as visible markup rather than formatting."}function ki(t){return t.nodeType===1&&!ge.has(t.nodeName)&&vi.test(t.nodeName)}function rn(t){return Array.from(t.querySelectorAll("*")).some(wi)}function nl(t,e={}){let{blockTag:i="DIV",wrapBareRoot:r=!1,onBareRootWrapped:n,blocksAllowed:o=!Si(t)}=e;return on(t),o&&sl(t,i,r,n),t}var ol=t=>Pe(t)&&t.nodeType!==8&&!xi(t),al=t=>t.nodeType!==8&&!xi(t)&&!(t.nodeType===3&&!Fe.test(t.nodeValue));function ll(t,{wrapBareRoot:e=!1,blocksAllowed:i=!Si(t)}={}){return i?ye(t)?Array.from(t.childNodes).some(ol)||nn(t):e:!1}function nn(t){return Array.from(t.children).some(e=>ye(e)?!Ti(e)&&Array.from(e.childNodes).some(i=>i.nodeType===3&&!Fe.test(i.nodeValue))||nn(e):!1)}function on(t){ye(t)&&(Ti(t)||Array.from(t.childNodes).forEach(e=>{e.nodeType===3&&!Fe.test(e.nodeValue)&&e.remove()}),Array.from(t.children).forEach(on))}function sl(t,e,i,r){if(!ye(t)){if(!i)return;let a=t.ownerDocument.createElement(e);if(!Array.from(t.childNodes).some(al)){a.appendChild(t.ownerDocument.createElement("BR")),t.appendChild(a);return}for(;t.firstChild;)a.appendChild(t.firstChild);t.appendChild(a),r?.(t,a);return}let n=[],o=()=>{let a=n;if(n=[],!a.some(c=>c.nodeType!==8))return;let l=t.ownerDocument.createElement(e);t.insertBefore(l,a[0]),a.forEach(c=>l.appendChild(c))};Array.from(t.childNodes).forEach(a=>{xi(a)?o():Pe(a)?n.push(a):o()}),o()}function Ti(t){return t.nodeName==="PRE"}function cl(t,e){return{start:an(t,e.startContainer,e.startOffset),end:an(t,e.endContainer,e.endOffset),collapsed:e.collapsed}}function hl(t,e,i){sn(e,"setStart",t,i.start),i.collapsed?e.collapse(!0):sn(e,"setEnd",t,i.end)}function an(t,e,i){if(!t.contains(e))return{scope:t,after:[],before:[]};if(e.nodeType===3){if(!dl(e))return{container:e,offset:i};let r=e.parentNode;return ln(r,Array.from(r.childNodes).indexOf(e))}return{container:e,offset:i,childCount:e.childNodes.length,...ln(e,i)}}function ln(t,e){let i=Array.from(t.childNodes),r=Math.max(0,e);return{scope:t,after:i.slice(r),before:i.slice(0,r).reverse()}}function sn(t,e,i,r){let{container:n,childCount:o}=r;if(n&&i.contains(n)&&(o===void 0||o===n.childNodes.length)){t[e](n,Math.min(r.offset,_i(n)));return}let a=r.after?.find(h=>i.contains(h));if(a){t[e](He(a,!0),0);return}let l=r.before?.find(h=>i.contains(h));if(l){let h=He(l,!1);t[e](h,_i(h));return}let c=r.scope&&i.contains(r.scope)?r.scope:i;t[e](c,0)}function dl(t){return t.nodeType===3&&!Fe.test(t.nodeValue)&&!!t.parentNode&&t.parentNode.nodeType===1&&ye(t.parentNode)&&!Ti(t.parentNode)}var be=t=>t.nodeType===1||t.nodeType===3;function He(t,e=!0){let i=t;for(;i.nodeType===1&&!ge.has(i.nodeName);){let r=Array.from(i.childNodes).filter(be),n=e?r[0]:r[r.length-1];if(!n||Xa.has(n.nodeName))break;i=n}return i}function _i(t){return t.nodeType===3?t.nodeValue.length:t.childNodes.length}var mt="[data-richclay], [richclay], [editable], [clay-editable]",ul="[data-richclay], [richclay], [clay-editable]",pl=["editable","clay-editable"],Ai=':is([editable~="single-line"], [clay-editable~="single-line"])';function cn(t){return!t||typeof t.matches!="function"?!1:t.tagName.includes("-")?t.matches(ul):!0}var fl="[data-richclay-toolbar], [data-richclay-menu], [data-richclay-dialog], [data-richclay-link-popover], [data-richclay-live], [data-richclay-float]",ml=["richclay-editor","richclay-inline","richclay-active","richclay-empty","richclay-focused"],Ni=new WeakSet,hn=new WeakSet,dn=["clay:ready","hyperclay:ready"];function un(t){return[t.clay?.ready,t.hyperclay?.ready].find(e=>e&&typeof e.then=="function")||null}function pn(t){return typeof t.clay?.isEditMode=="boolean"?t.clay.isEditMode:typeof t.hyperclay?.isEditMode=="boolean"?t.hyperclay.isEditMode:null}function gl(t){let e=t.hyperclayModules,i=t.__hyperclayNoAutoExport===!1&&e&&typeof e=="object"&&typeof e.nodeType!="number";return pn(t)!==null||!!un(t)||!!i}function yl(t){return t.clay?.addDocumentTransform||t.hyperclay?.beforeSave||null}function bl(t){return t.clay?.onSnapshot||t.hyperclay?.onSnapshot||null}var vl={boxSizing:"border-box",minWidth:"100%",overflow:"auto",width:"0"};function Li(t={},e=window){return t.hyperclay===!1?!1:t.hyperclay===!0?!0:!!(gl(e)||Nl(e))}function fn(t=window){let e=bn(t);if(e!==null)return e;if(typeof t.__hyperclayEditMode=="boolean")return t.__hyperclayEditMode;let i=pn(t);return i!==null?i:Ll(t)}function xl(t={},e=window){return t.readOnly?!1:Li(t,e)?fn(e):!0}function wl(t){let e=pl.find(n=>t.hasAttribute(n));if(!e)return null;let i=new Set((t.getAttribute(e)||"").trim().split(/\s+/).filter(Boolean)),r={inline:!0,singleLine:i.has("single-line"),toolbarOnSelect:i.has("toolbar-on-select")};return i.has("no-toolbar")&&(r.toolbar=!1),i.has("link-label")&&(r.singleLine=!0,r.linkLabel=!0,r.toolbar=["link","undo","redo"]),r}function mn(t=window){if(Ni.has(t))return;let e=bl(t)||yl(t);if(typeof e!="function"){El(t);return}e(i=>gn(i)),Ni.add(t)}function El(t){if(hn.has(t))return;let e=t.document,i=un(t);if(!e&&!i)return;hn.add(t);let r=()=>{mn(t),Ni.has(t)&&n()},n=()=>{e&&dn.forEach(o=>e.removeEventListener(o,r))};e&&dn.forEach(o=>e.addEventListener(o,r)),i&&i.then(r,()=>{})}function gn(t){t.querySelectorAll?.(fl).forEach(e=>e.remove()),t.querySelectorAll?.(mt).forEach(e=>{if(e.getAttribute("data-richclay-active")==="true"){if(Oi(e,"save"),Tl(e)){let i=e.ownerDocument,r=!!e.matches?.(Ai);Ei(e,()=>r?i.createTextNode(" "):i.createElement("br")),e.querySelectorAll(e.localName).forEach(n=>{for(;n.firstChild;)n.parentNode.insertBefore(n.firstChild,n);n.remove()})}e.matches?.(Ai)&&Al(e),e.querySelectorAll("#squire-selection-start, #squire-selection-end").forEach(i=>{i.remove()}),e.querySelectorAll(".squire-image-resize-container").forEach(i=>i.remove()),_l(e),(e.matches?.("pre")?[e,...e.querySelectorAll("pre")]:Array.from(e.querySelectorAll("pre"))).filter(i=>i.hasAttribute("data-richclay-pre")).forEach(i=>{Object.entries(vl).forEach(([r,n])=>{i.style[r]||(i.style[r]=n)}),i.removeAttribute("data-richclay-pre")})}}),t.querySelectorAll?.("#squire-selection-start, #squire-selection-end").forEach(e=>e.remove())}var Cl="p, td, th, li, dl, dt, dd, table, blockquote, div, section, article, aside, main, header, footer, figure, figcaption",Di="data-richclay-measure";function Sl(t){let e=t.ownerDocument,i=t.closest(Cl)||t;t.setAttribute(Di,"");let r=e.createElement("div");try{r.innerHTML=i.outerHTML}finally{t.removeAttribute(Di)}let n=r.querySelector(`[${Di}]`);return!n||n.textContent!==t.textContent}var kl=t=>!!t.querySelector(t.localName),Tl=t=>!!t.matches?.(Ai)||(rn(t)||kl(t))&&Sl(t);function Oi(t,e){let i=t.getAttribute("data-richclay-runtime-contenteditable");t.hasAttribute("contenteditable")&&(i==="true"?t.removeAttribute("contenteditable"):i?e==="destroy"?t.setAttribute("contenteditable",i):(t.setAttribute("inert-contenteditable",i),t.removeAttribute("contenteditable")):e==="save"&&(t.setAttribute("inert-contenteditable",t.getAttribute("contenteditable")),t.removeAttribute("contenteditable"))),ml.forEach(r=>t.classList.remove(r)),t.getAttribute("class")===""&&t.removeAttribute("class"),Ri(t,"role","data-richclay-runtime-role"),Ri(t,"aria-multiline","data-richclay-runtime-aria-multiline"),Ri(t,"no-undo","data-richclay-runtime-no-undo"),t.getAttribute("data-richclay-runtime-display")==="true"&&(t.style.removeProperty("display"),t.getAttribute("style")===""&&t.removeAttribute("style")),Dl(t),t.removeAttribute("data-richclay-active"),t.removeAttribute("data-richclay-placeholder"),t.removeAttribute("data-richclay-pre"),t.removeAttribute("data-richclay-runtime-role"),t.removeAttribute("data-richclay-runtime-aria-multiline"),t.removeAttribute("data-richclay-runtime-no-undo"),t.removeAttribute("data-richclay-runtime-describedby"),t.removeAttribute("data-richclay-runtime-contenteditable"),t.removeAttribute("data-richclay-runtime-display"),t.getAttribute("data-richclay-runtime-marker")==="true"&&t.removeAttribute("data-richclay"),t.removeAttribute("data-richclay-runtime-marker")}function _l(t){let e=[t];for(;e.length;)e.pop().childNodes.forEach(i=>{i.nodeType===3?i.nodeValue.includes("\u200B")&&(i.nodeValue=i.nodeValue.split("\u200B").join("")):i.nodeType===1&&e.push(i)});t.querySelectorAll("b, i, u, s, em, strong, code, sub, sup, span").forEach(i=>{i.children.length===0&&(i.textContent||"")===""&&i.attributes.length===0&&i.remove()})}function Al(t){let e=Array.from(t.childNodes).filter(r=>r.nodeType!==3||(r.nodeValue||"").trim()!=="");if(e.length!==1)return;let i=e[0];if(!(i.nodeType!==1||i.nodeName!=="P"||i.attributes.length>0)){for(;i.firstChild;)t.insertBefore(i.firstChild,i);i.remove()}}function yn(t){if(!t.hasAttribute("inert-contenteditable"))return null;let e=t.getAttribute("inert-contenteditable");return["false","plaintext-only"].includes(e)||(e="true"),t.setAttribute("contenteditable",e),t.removeAttribute("inert-contenteditable"),e==="true"&&t.setAttribute("data-richclay-runtime-contenteditable","true"),e}function zt(t){return t.setAttribute("snapshot-remove",""),t.setAttribute("no-watch",""),t}function bn(t){try{let e=new URLSearchParams(t.location?.search||"");if(e.get("editmode")==="true")return!0;if(e.get("editmode")==="false")return!1}catch{return null}return null}function Nl(t){return bn(t)!==null||typeof t.__hyperclayEditMode=="boolean"}function Ll(t){let e=(t.document?.cookie||"").match(/(?:^|;\s*)isAdminOfCurrentResource=([^;]*)/);return!!(e&&e[1]!=="")}function Ri(t,e,i){t.hasAttribute(i)&&t.removeAttribute(e)}function Dl(t){let e=t.getAttribute("data-richclay-runtime-describedby");if(!e)return;let i=(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean).filter(r=>r!==e);i.length?t.setAttribute("aria-describedby",i.join(" ")):t.removeAttribute("aria-describedby")}var Ol=0;function Rl(t=document){let e=t.createElement("div");return e.id=`richclay-live-${++Ol}`,e.className="richclay-sr-only",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("data-richclay-live",""),zt(e),t.body.appendChild(e),e}function ve(t,e){!t||!e||(t.textContent="",t.ownerDocument.defaultView.setTimeout(()=>{t.textContent=e},20))}function Mi(t){t.preventDefault()}function vn(t){try{return t?.cloneRange?.()||null}catch{return null}}function xe(t){try{return vn(t?.getSelection?.())}catch{return null}}function Ii(t,e){if(!t||!e)return!1;try{return t.setSelection(e),!0}catch{return!1}}function Bi(t,e,i,r){t.hasAttribute(e)||t.setAttribute(r,"true"),t.setAttribute(e,i)}function Ml(t,e){let i=new Set((t.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));i.add(e.id),t.setAttribute("aria-describedby",Array.from(i).join(" ")),t.setAttribute("data-richclay-runtime-describedby",e.id)}var Il=0,xn=class{constructor(t,e,i={}){this.editor=t,this.controls=e,this.options=i,this.id=++Il,this.items=[],this.menus=new Map,this.activeIndex=0,this.root=this.createRoot(),this.onRootKeydown=r=>this.handleRootKeydown(r),this.onRootClick=r=>this.handleRootClick(r),this.onRootPointerDown=r=>this.handleRootPointerDown(r),this.onDocumentPointerDown=r=>this.handleDocumentPointerDown(r),this.render(),this.root.addEventListener("keydown",this.onRootKeydown),this.root.addEventListener("click",this.onRootClick),this.root.addEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.addEventListener("mousedown",this.onDocumentPointerDown)}destroy(){this.closeMenus(),this.root.removeEventListener("keydown",this.onRootKeydown),this.root.removeEventListener("click",this.onRootClick),this.root.removeEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.removeEventListener("mousedown",this.onDocumentPointerDown),this.root.remove()}update(){this.items.forEach(t=>{let{def:e,button:i}=t;if(typeof e.isActive=="function"){let r=!!e.isActive(this.editor);i.setAttribute("aria-pressed",r?"true":"false"),i.classList.toggle("is-active",r)}typeof e.isDisabled=="function"&&(i.disabled=!!e.isDisabled(this.editor))}),this.ensureSingleTabStop()}focusFirst(){this.activeIndex=0,this.ensureSingleTabStop(),this.items[0]?.button.focus()}createRoot(){let t=this.editor.element.ownerDocument,e=t.createElement("div");e.className="richclay-toolbar",e.setAttribute("role","toolbar"),e.setAttribute("aria-label",this.options.ariaLabel||"Rich text formatting"),e.setAttribute("data-richclay-toolbar",""),zt(e);let i=Bl(this.options.toolbarContainer,t);return i?i.appendChild(e):this.editor.element.insertAdjacentElement("beforebegin",e),e}render(){this.root.textContent="",this.items=[],this.menus.clear();let t=null;this.visibleControls().forEach((e,i)=>{if(e.type==="separator"){this.root.appendChild(En(this.root.ownerDocument)),t=null;return}t&&e.group&&e.group!==t&&this.root.appendChild(En(this.root.ownerDocument)),t=e.group||t,e.type==="menu"?this.renderMenu(e,i):this.renderButton(e,i)}),this.ensureSingleTabStop(),this.update()}visibleControls(){let t=this.controls.filter(i=>i.type==="separator"||!i.isDisabled?.(this.editor)),e=[];for(t.forEach(i=>{let r=e[e.length-1];i.type==="separator"&&(!r||r.type==="separator")||e.push(i)});e[e.length-1]?.type==="separator";)e.pop();return e}renderButton(t,e){let i=wn(this.root.ownerDocument,t);i.dataset.richclayControl=t.id,i.dataset.richclayIndex=String(e),typeof t.isActive=="function"&&i.setAttribute("aria-pressed","false"),this.root.appendChild(i),this.items.push({def:t,button:i,type:"button"})}renderMenu(t,e){let i=this.root.ownerDocument,r=wn(i,t),n=`richclay-menu-${this.id}-${t.id}`;r.dataset.richclayControl=t.id,r.dataset.richclayIndex=String(e),r.setAttribute("aria-haspopup","menu"),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-controls",n);let o=i.createElement("div");o.id=n,o.className="richclay-menu",o.hidden=!0,o.setAttribute("role","menu"),o.setAttribute("data-richclay-menu",""),zt(o),t.options.forEach((l,c)=>{let h=i.createElement("button");h.type="button",h.className="richclay-menu-item",h.setAttribute("role","menuitemradio"),h.setAttribute("tabindex","-1"),h.dataset.richclayMenuItem=t.id,h.dataset.richclayOptionIndex=String(c),h.innerHTML=l.icon||"",h.appendChild(i.createTextNode(l.label)),h.addEventListener("mousedown",Mi),h.addEventListener("click",u=>{u.preventDefault(),this.chooseMenuItem(t,l,r)}),h.addEventListener("keydown",u=>this.handleMenuKeydown(u,t,r)),o.appendChild(h)});let a=i.createElement("span");a.className="richclay-menu-wrap",a.append(r,o),this.root.appendChild(a),this.items.push({def:t,button:r,type:"menu",menu:o}),this.menus.set(t.id,{def:t,button:r,menu:o})}handleRootPointerDown(t){let e=t.target.closest?.("[data-richclay-control]");!e||!this.root.contains(e)||(Mi(t),this.editor.saveSelection())}handleRootClick(t){let e=t.target.closest?.("[data-richclay-control]");if(!e||!this.root.contains(e))return;t.preventDefault();let i=this.items.find(r=>r.button===e);if(!(!i||e.disabled)){if(this.activeIndex=this.items.indexOf(i),this.ensureSingleTabStop(),i.type==="menu"){this.toggleMenu(i.def.id);return}this.closeMenus(),this.editor.runControl(i.def)}}handleRootKeydown(t){let e=t.key,i={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1};if(e in i){t.preventDefault(),this.moveFocus(i[e]);return}if(e==="Home"){t.preventDefault(),this.setFocusIndex(0);return}if(e==="End"){t.preventDefault(),this.setFocusIndex(this.items.length-1);return}let r=this.items[this.activeIndex];if(r&&((e==="Enter"||e===" ")&&r.type==="menu"&&(t.preventDefault(),this.openMenu(r.def.id,"first")),e==="Escape")){let n=Array.from(this.menus.values()).some(o=>!o.menu.hidden);this.closeMenus(),n?r.button.focus():this.editor.focus()}}handleMenuKeydown(t,e,i){t.stopPropagation();let r=this.menus.get(e.id)?.menu,n=Array.from(r.querySelectorAll(".richclay-menu-item")),o=n.indexOf(t.currentTarget),a=o;if(t.key==="ArrowDown"&&(a=(o+1)%n.length),t.key==="ArrowUp"&&(a=(o-1+n.length)%n.length),t.key==="Home"&&(a=0),t.key==="End"&&(a=n.length-1),a!==o){t.preventDefault(),n[a].focus();return}if(t.key==="Escape"){t.preventDefault(),this.closeMenus(),i.focus();return}if(t.key==="Enter"||t.key===" "){t.preventDefault();let l=e.options[o];this.chooseMenuItem(e,l,i)}}handleDocumentPointerDown(t){this.root.contains(t.target)||this.closeMenus()}chooseMenuItem(t,e,i){this.closeMenus(),this.editor.runControl({...e,id:`${t.id}:${e.value}`,ariaLabel:e.label}),i.focus()}toggleMenu(t){let e=this.menus.get(t);e&&(e.menu.hidden?this.openMenu(t,"first"):this.closeMenus())}openMenu(t,e="first"){this.closeMenus(t);let i=this.menus.get(t);if(!i)return;i.menu.hidden=!1,i.button.setAttribute("aria-expanded","true"),this.updateMenuState(i);let r=Array.from(i.menu.querySelectorAll(".richclay-menu-item")),n=r.find(o=>o.getAttribute("aria-checked")==="true");(e==="active"&&n||r[0])?.focus()}closeMenus(t=null){this.menus.forEach((e,i)=>{i!==t&&(e.menu.hidden=!0,e.button.setAttribute("aria-expanded","false"))})}updateMenuState(t){Array.from(t.menu.querySelectorAll(".richclay-menu-item")).forEach((e,i)=>{let r=!!t.def.options[i].isActive?.(this.editor);e.setAttribute("aria-checked",r?"true":"false"),e.classList.toggle("is-active",r)})}moveFocus(t){if(!this.items.length)return;let e=this.activeIndex;do e=(e+t+this.items.length)%this.items.length;while(this.items[e].button.disabled&&e!==this.activeIndex);this.setFocusIndex(e)}setFocusIndex(t){this.activeIndex=Math.max(0,Math.min(t,this.items.length-1)),this.ensureSingleTabStop(),this.items[this.activeIndex]?.button.focus()}ensureSingleTabStop(){let t=this.items.filter(e=>!e.button.disabled);t.length&&(t.includes(this.items[this.activeIndex])||(this.activeIndex=this.items.indexOf(t[0])),this.items.forEach((e,i)=>{e.button.tabIndex=i===this.activeIndex?0:-1}))}};function wn(t,e){let i=t.createElement("button");i.type="button",i.className="richclay-button";let r=Za(e.shortcut,t.defaultView),n=r?`${e.ariaLabel||e.label} (${r})`:e.ariaLabel||e.label;return i.setAttribute("aria-label",n),i.title=n,i.innerHTML=`${e.icon||""}<span class="richclay-sr-only">${e.label}</span>`,i}function En(t){let e=t.createElement("span");return e.className="richclay-separator",e.setAttribute("role","separator"),e.setAttribute("aria-orientation","vertical"),e}function Bl(t,e){return t?typeof t=="string"?e.querySelector(t):t:null}var Cn=16,Fl=[16,8,0],$=8,Pl=4;function Hl({anchor:t,bar:e,rail:i,viewport:r,current:n=null}){let o=f=>n===f?Pl:0;if(t.bottom<=0||t.top>=r.height||t.right<=0||t.left>=r.width)return{mode:"hidden",x:0,y:0};let a=f=>Math.max($,Math.min(t.left,r.width-f-$)),l=t.top-Cn-e.height;if(l>=$-o("above"))return{mode:"above",x:a(e.width),y:l};let c=t.bottom+Cn;if(c+e.height<=r.height-$+o("below"))return{mode:"below",x:a(e.width),y:c};let h=r.width-t.right-$,u=t.left-$,d=h>=u?[["rail-right",h],["rail-left",u]]:[["rail-left",u],["rail-right",h]];for(let[f,y]of d)for(let g of Fl){if(i.width+g>y+o(f))continue;let w=f==="rail-right"?Math.min(t.right+g,r.width-i.width-$):Math.max(t.left-g-i.width,$),E=Math.min(t.bottom,r.height-$)-i.height,D=Math.max($,Math.min(Math.max(t.top,$),E));return{mode:f,x:w,y:D,gap:g}}return{mode:"pinned",x:a(e.width),y:$}}var Ul=10,ql=28;function Sn({anchor:t,box:e,viewport:i,gap:r=Ul}){let n=i.height-$-t.bottom-r,o=t.top-r-$,a=n>=e.height||n>=o?"below":"above",l=a==="below"?t.bottom+r:t.top-r-e.height,c=Math.max($,Math.min(l,i.height-$-e.height)),h=(t.left+t.right)/2,u=Math.max($,Math.min(h-ql,i.width-$-e.width)),d=Math.max(14,Math.min(h-u,e.width-14));return{side:a,x:u,y:c,arrow:d}}function rt(t,e,i){t.style.setProperty(e,i,"important")}var zl=class{constructor(t,e){this.editor=t,this.mode=null,this.hidden=!1,this.frame=0,this.bar={width:0,height:0},this.rail={width:0,height:0};let i=t.element.ownerDocument;this.doc=i,this.win=i.defaultView||globalThis,this.root=i.createElement("div"),this.root.className="richclay-float",this.root.setAttribute("data-richclay-float",""),this.root.setAttribute("save-remove",""),zt(this.root),i.body.appendChild(this.root),this.toolbar=new xn(t,e,{toolbarContainer:this.root}),this.onScroll=()=>this.schedule(),this.onResize=()=>{this.measure(),this.schedule()},i.addEventListener("scroll",this.onScroll,{capture:!0,passive:!0}),this.win.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("scroll",this.onScroll,{passive:!0}),this.resizeObserver=typeof this.win.ResizeObserver=="function"?new this.win.ResizeObserver(()=>this.schedule()):null,this.resizeObserver?.observe(t.element),this.measure(),this.reposition()}measure(){let t=this.root.classList.contains("richclay-float-rail");rt(this.root,"visibility","hidden"),this.root.classList.remove("richclay-float-rail"),this.bar={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.add("richclay-float-rail"),this.rail={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.toggle("richclay-float-rail",t),this.root.style.removeProperty("visibility")}schedule(){if(!this.win.requestAnimationFrame){this.reposition();return}this.frame||(this.frame=this.win.requestAnimationFrame(()=>{this.frame=0,this.reposition()}))}setVisible(t){this.hidden=!t,this.reposition()}reposition(){if(this.hidden){rt(this.root,"display","none");return}let t=this.editor.element.getBoundingClientRect(),e={width:this.win.visualViewport?.width??this.win.innerWidth,height:this.win.visualViewport?.height??this.win.innerHeight},i=Hl({anchor:t,bar:this.bar,rail:this.rail,viewport:e,current:this.mode});if(this.mode=i.mode,i.mode==="hidden"){rt(this.root,"display","none");return}this.root.style.removeProperty("display"),this.root.classList.toggle("richclay-float-rail",i.mode==="rail-left"||i.mode==="rail-right"),this.root.classList.toggle("richclay-float-pinned",i.mode==="pinned"),rt(this.root,"transform",`translate(${Math.round(i.x)}px, ${Math.round(i.y)}px)`)}destroy(){this.frame&&this.win.cancelAnimationFrame?.(this.frame),this.frame=0,this.doc.removeEventListener("scroll",this.onScroll,{capture:!0}),this.win.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("scroll",this.onScroll),this.resizeObserver?.disconnect(),this.toolbar.destroy(),this.root.remove()}},Wl={ALLOWED_TAGS:["a","b","blockquote","br","code","div","em","h1","h2","h3","h4","h5","h6","i","li","ol","p","pre","s","span","strong","sub","sup","u","ul"],ALLOWED_ATTR:["aria-label","href","rel","target","title"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0,ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,FORBID_TAGS:["script","style","iframe","object","embed","form","input"],FORBID_ATTR:["style","srcset","onerror","onclick","onload"]};function Kl(t={},e=document){let i=Ue(e);return{sanitizeHTML(r){return kn(r,t,e,i)},sanitizeElement(r){return Tn(r,t,i)},sanitizeToDOMFragment(r,n){let o=n?.getRoot?.().ownerDocument||e;return $l(r,t,o,i)}}}function kn(t,e={},i=document,r=Ue(i)){let n=i.createElement("template");return n.innerHTML=r.sanitize(String(t||""),Fi(e)),Pi(n.content),n.innerHTML}function Tn(t,e={},i=Ue(t.ownerDocument)){let r=t.ownerDocument.createElement("div");for(;t.firstChild;)r.appendChild(t.firstChild);for(i.sanitize(r,{...Fi(e),IN_PLACE:!0}),Pi(r);r.firstChild;)t.appendChild(r.firstChild);return t}function $l(t,e={},i=document,r=Ue(i)){let n=r.sanitize(String(t||""),{...Fi(e),RETURN_DOM_FRAGMENT:!0}),o=n?.ownerDocument===i?n:i.importNode(n,!0);return Pi(o),o||i.createDocumentFragment()}function Fi(t){return{...Wl,...t}}var jl=new Set(["http","https","mailto","tel"]),Vl=new RegExp("[\\u0000-\\u0020\\u007F-\\u009F]","g");function _n(t){let e=(String(t??"").replace(Vl,"").match(/^([a-z][a-z0-9+.\-]*):/i)||[])[1];return!e||jl.has(e.toLowerCase())}var Gl=/^[^\s/?#:]+\.(?:html?|pdf|txt|csv|json|xml|svg|png|jpe?g|gif|webp|docx?|xlsx?|pptx?|bib|tex|zip)(?:[?#]\S*)?$/i,Zl=/^[^\s/?#:.]+\/\S*$/;function Yl(t){let e=String(t??"").trim();return!e||!_n(e)?"":/^(?:https?:|mailto:|tel:)/i.test(e)?e:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?`mailto:${e}`:/^(?:[#?]|\/|\.{1,2}\/)/.test(e)||Gl.test(e)||Zl.test(e)?e:`https://${e}`}function Ue(t){let e=globalThis.DOMPurify;if(e?.sanitize)return e;if(typeof e=="function")return e(t.defaultView||globalThis);throw new Error("RichClay requires DOMPurify. Load vendor/purify.min.js before richclay.js or provide globalThis.DOMPurify.")}function Pi(t){t.querySelectorAll?.("a[href]").forEach(e=>{let i=e.getAttribute("href")||"";if(/^\s*javascript:/i.test(i)&&e.removeAttribute("href"),e.getAttribute("target")==="_blank"){let r=new Set((e.getAttribute("rel")||"").split(/\s+/).filter(Boolean));r.add("noopener"),r.add("noreferrer"),e.setAttribute("rel",Array.from(r).join(" "))}})}var An={ADD_TAGS:["img"],ADD_ATTR:["class","id","src","alt","width","height"]};function Ql(t={}){return{...t,ADD_TAGS:[...new Set([...An.ADD_TAGS,...t.ADD_TAGS||[]])],ADD_ATTR:[...new Set([...An.ADD_ATTR,...t.ADD_ATTR||[]])],ALLOW_DATA_ATTR:t.ALLOW_DATA_ATTR??!0}}var Nn="p, div, h1, h2, h3, h4, h5, h6, blockquote, pre, ul, ol, li, figure, figcaption, table, thead, tbody, tr, td, th";function Xl(t){let e=t.ownerDocument||document;t.querySelectorAll?.("br").forEach(r=>r.replaceWith(e.createTextNode(" ")));let i=t.querySelector?.(Nn);for(;i;){let r=i.parentNode;for(r.insertBefore(e.createTextNode(" "),i);i.firstChild;)r.insertBefore(i.firstChild,i);r.insertBefore(e.createTextNode(" "),i),i.remove(),i=t.querySelector(Nn)}return Jl(t,e),t}function Jl(t,e){t.normalize?.();let i=e.createTreeWalker(t,4),r=[];for(;i.nextNode();)r.push(i.currentNode);r.forEach(a=>{a.nodeValue=a.nodeValue.replace(/\s+/g," ")});let n=t.firstChild;n?.nodeType===3&&(n.nodeValue=n.nodeValue.replace(/^\s+/,""));let o=t.lastChild;o?.nodeType===3&&(o.nodeValue=o.nodeValue.replace(/\s+$/,""))}var ts=300,es=t=>t.replace(/^mailto:/i,"").replace(/^https?:\/\//i,""),is=class{constructor(t){this.editor=t,this.root=null,this.anchor=null,this.href=null,this.dismissed=null,this.hideTimer=null,this.pointerInside=!1,this.cleanup=null}currentAnchor(){let t=this.editor;return!t.active||t.options.readOnly||t.dialog||t.element.ownerDocument.hidden?null:t.currentLinkElement()}update(){let t=this.currentAnchor();if(!(t&&t===this.dismissed)){if(this.dismissed=null,!t){this.scheduleHide();return}this.cancelHide(),this.show(t)}}show(t){this.root||this.mount();let e=t.getAttribute("href")||"";if(t!==this.anchor||e!==this.href){this.anchor=t,this.href=e;let i=this.root.querySelector(".richclay-link-address");i.textContent=es(e)||e,i.title=e,e&&_n(e)?i.setAttribute("href",e):i.removeAttribute("href"),/^(?:mailto|tel):/i.test(e)?i.removeAttribute("target"):i.setAttribute("target","_blank")}this.position()}mount(){let t=this.editor,e=t.element.ownerDocument,i=e.defaultView||globalThis,r=e.createElement("div");r.className="richclay-dialog richclay-link-popover",r.setAttribute("role","group"),r.setAttribute("aria-label","Link"),r.setAttribute("data-richclay-link-popover",""),zt(r),r.setAttribute("save-remove",""),r.innerHTML=`
|
|
98
|
+
`+Rt),Ot&&(Rt=Ge(Rt)),nt&&$e?ee(Rt):Rt},e.setConfig=function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hr(s),Xi=!0,Ji=O,tr=R},e.clearConfig=function(){oe=null,Xi=!1,Ji=null,tr=null,nt=Zi,Wt=""},e.isValidAttribute=function(s,p,m){oe||hr({});let b=I(s),C=I(p);return yo(b,C,m)},e.addHook=function(s,p){typeof p=="function"&&K(B,s)&&Jt(B[s],p)},e.removeHook=function(s,p){if(K(B,s)){if(p!==void 0){let m=wa(B[s],p);return m===-1?void 0:Ea(B[s],m,1)[0]}return qr(B[s])}},e.removeHooks=function(s){K(B,s)&&(B[s]=[])},e.removeAllHooks=function(){B=Xr()},e}var ja=Jr(),U=(t,e="0 0 18 18")=>`<svg viewBox="${e}" width="18" height="18" aria-hidden="true" focusable="false">${t}</svg>`,L={bold:U('<path fill="currentColor" d="M178.48,115.7A44,44,0,0,0,148,40H80a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8h80a48,48,0,0,0,18.48-92.3ZM88,56h60a28,28,0,0,1,0,56H88Zm72,136H88V128h72a32,32,0,0,1,0,64Z"/>',"0 0 256 256"),italic:U('<path fill="currentColor" d="M200,56a8,8,0,0,1-8,8H157.77L115.1,192H144a8,8,0,0,1,0,16H64a8,8,0,0,1,0-16H98.23L140.9,64H112a8,8,0,0,1,0-16h80A8,8,0,0,1,200,56Z"/>',"0 0 256 256"),underline:U('<path fill="currentColor" d="M200,224a8,8,0,0,1-8,8H64a8,8,0,0,1,0-16H192A8,8,0,0,1,200,224Zm-72-24a64.07,64.07,0,0,0,64-64V56a8,8,0,0,0-16,0v80a48,48,0,0,1-96,0V56a8,8,0,0,0-16,0v80A64.07,64.07,0,0,0,128,200Z"/>',"0 0 256 256"),strike:U('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H175.93c9.19,7.11,16.07,17.2,16.07,32,0,13.34-7,25.7-19.75,34.79C160.33,211.31,144.61,216,128,216s-32.33-4.69-44.25-13.21C71,193.7,64,181.34,64,168a8,8,0,0,1,16,0c0,17.35,22,32,48,32s48-14.65,48-32c0-14.85-10.54-23.58-38.77-32H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM76.33,104a8,8,0,0,0,7.61-10.49A17.3,17.3,0,0,1,83.11,88c0-18.24,19.3-32,44.89-32,18.84,0,34.16,7.42,41,19.85a8,8,0,0,0,14-7.7C173.33,50.52,152.77,40,128,40,93.29,40,67.11,60.63,67.11,88a33.73,33.73,0,0,0,1.62,10.49A8,8,0,0,0,76.33,104Z"/>',"0 0 256 256"),link:U('<path fill="currentColor" d="M240,88.23a54.43,54.43,0,0,1-16,37L189.25,160a54.27,54.27,0,0,1-38.63,16h-.05A54.63,54.63,0,0,1,96,119.84a8,8,0,0,1,16,.45A38.62,38.62,0,0,0,150.58,160h0a38.39,38.39,0,0,0,27.31-11.31l34.75-34.75a38.63,38.63,0,0,0-54.63-54.63l-11,11A8,8,0,0,1,135.7,59l11-11A54.65,54.65,0,0,1,224,48,54.86,54.86,0,0,1,240,88.23ZM109,185.66l-11,11A38.41,38.41,0,0,1,70.6,208h0a38.63,38.63,0,0,1-27.29-65.94L78,107.31A38.63,38.63,0,0,1,144,135.71a8,8,0,0,0,16,.45A54.86,54.86,0,0,0,144,96a54.65,54.65,0,0,0-77.27,0L32,130.75A54.62,54.62,0,0,0,70.56,224h0a54.28,54.28,0,0,0,38.64-16l11-11A8,8,0,0,0,109,185.66Z"/>',"0 0 256 256"),unlink:U('<path fill="currentColor" d="M198.63,57.37a32,32,0,0,0-45.19-.06L141.79,69.52a8,8,0,0,1-11.58-11l11.72-12.29a1.59,1.59,0,0,1,.13-.13,48,48,0,0,1,67.88,67.88,1.59,1.59,0,0,1-.13.13l-12.29,11.72a8,8,0,0,1-11-11.58l12.21-11.65A32,32,0,0,0,198.63,57.37ZM114.21,186.48l-11.65,12.21a32,32,0,0,1-45.25-45.25l12.21-11.65a8,8,0,0,0-11-11.58L46.19,141.93a1.59,1.59,0,0,0-.13.13,48,48,0,0,0,67.88,67.88,1.59,1.59,0,0,0,.13-.13l11.72-12.29a8,8,0,1,0-11.58-11ZM216,152H192a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16ZM40,104H64a8,8,0,0,0,0-16H40a8,8,0,0,0,0,16Zm120,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V192A8,8,0,0,0,160,184ZM96,72a8,8,0,0,0,8-8V40a8,8,0,0,0-16,0V64A8,8,0,0,0,96,72Z"/>',"0 0 256 256"),ul:U('<path fill="currentColor" d="M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z"/>',"0 0 256 256"),ol:U('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H104a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM104,72H216a8,8,0,0,0,0-16H104a8,8,0,0,0,0,16ZM216,184H104a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM43.58,55.16,48,52.94V104a8,8,0,0,0,16,0V40a8,8,0,0,0-11.58-7.16l-16,8a8,8,0,0,0,7.16,14.32ZM79.77,156.72a23.73,23.73,0,0,0-9.6-15.95,24.86,24.86,0,0,0-34.11,4.7,23.63,23.63,0,0,0-3.57,6.46,8,8,0,1,0,15,5.47,7.84,7.84,0,0,1,1.18-2.13,8.76,8.76,0,0,1,12-1.59A7.91,7.91,0,0,1,63.93,159a7.64,7.64,0,0,1-1.57,5.78,1,1,0,0,0-.08.11L33.59,203.21A8,8,0,0,0,40,216H72a8,8,0,0,0,0-16H56l19.08-25.53A23.47,23.47,0,0,0,79.77,156.72Z"/>',"0 0 256 256"),quote:U('<path fill="currentColor" d="M100,56H40A16,16,0,0,0,24,72v64a16,16,0,0,0,16,16h60v8a32,32,0,0,1-32,32,8,8,0,0,0,0,16,48.05,48.05,0,0,0,48-48V72A16,16,0,0,0,100,56Zm0,80H40V72h60ZM216,56H156a16,16,0,0,0-16,16v64a16,16,0,0,0,16,16h60v8a32,32,0,0,1-32,32,8,8,0,0,0,0,16,48.05,48.05,0,0,0,48-48V72A16,16,0,0,0,216,56Zm0,80H156V72h60Z"/>',"0 0 256 256"),undo:U('<path fill="currentColor" d="M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L44.59,96H72a8,8,0,0,1,0,16H24a8,8,0,0,1-8-8V56a8,8,0,0,1,16,0V85.8L60.25,60A96,96,0,0,1,224,128Z"/>',"0 0 256 256"),redo:U('<path fill="currentColor" d="M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z"/>',"0 0 256 256"),clear:U('<path fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="square" stroke-linejoin="miter" d="M3 3l18 18M5 5v3M9 5h10v3M12 5v3M12 12v7M8 19h8"/>',"0 0 24 24"),code:U('<path fill="currentColor" d="M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z"/>',"0 0 256 256"),indent:U('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM112,72H216a8,8,0,0,0,0-16H112a8,8,0,0,0,0,16ZM216,184H40a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM34.34,141.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0,0-11.32l-40-40A8,8,0,0,0,34.34,61.66L68.69,96,34.34,130.34A8,8,0,0,0,34.34,141.66Z"/>',"0 0 256 256"),outdent:U('<path fill="currentColor" d="M224,128a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM112,72H216a8,8,0,0,0,0-16H112a8,8,0,0,0,0,16ZM216,184H40a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM72,144a8,8,0,0,0,5.66-13.66L43.31,96,77.66,61.66A8,8,0,0,0,66.34,50.34l-40,40a8,8,0,0,0,0,11.32l40,40A8,8,0,0,0,72,144Z"/>',"0 0 256 256"),blocks:U('<path fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="square" stroke-linejoin="miter" d="M19 4h-9a4.5 4.5 0 0 0 0 9h3M13 4v16M17 4v16"/>',"0 0 24 24"),h1:U('<path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M3.5 5.5v12M12 5.5v12M3.5 11.5H12M17 12l3-2v10"/>',"0 0 24 24"),h2:U('<path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M3.5 5.5v12M12 5.5v12M3.5 11.5H12M16 12.5c0-3.5 6-3.5 6 0 0 2-2.5 3.5-6 7.5h6"/>',"0 0 24 24"),h3:U('<path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" d="M3.5 5.5v12M12 5.5v12M3.5 11.5H12M16 11c1.5-1.5 6-1.5 6 1.5 0 1.5-1.5 2.5-3 2.5h-1M19 15c1.5 0 3 1 3 2.5 0 3-4.5 3-6 1.5"/>',"0 0 24 24")},Et=t=>t.blocksStayOut(),Va=t=>!!t.element.closest("a"),Ie={minimal:["bold","italic","link","unorderedList"],inline:["bold","italic","underline","strikethrough","code","link","undo","redo","clearFormatting"],standard:["blockMenu","bold","italic","underline","strikethrough","code","link","unorderedList","orderedList","quote","outdent","indent","undo","redo","clearFormatting"]};function Ga(){return new Map(Ya.map(t=>[t.id,t]))}function me(t=globalThis){let e=t?.navigator;return e?/Mac|iPhone|iPad|iPod/.test(e.platform||e.userAgent||""):!1}function Za(t,e=globalThis){return t?t.replace("Mod",me(e)?"Cmd":"Ctrl"):""}var Ya=[Lt("bold","Bold",L.bold,"Mod+B","inline",t=>t.toggleFormat("B","bold","removeBold")),Lt("italic","Italic",L.italic,"Mod+I","inline",t=>t.toggleFormat("I","italic","removeItalic")),Lt("underline","Underline",L.underline,"Mod+U","inline",t=>t.toggleFormat("U","underline","removeUnderline")),Lt("strikethrough","Strikethrough",L.strike,"Mod+Shift+7","inline",t=>t.toggleFormat("S","strikethrough","removeStrikethrough")),Lt("code","Code",L.code,null,"inline",t=>t.toggleCode(),t=>t.selectionHasFormat("CODE")||t.selectionHasFormat("PRE")),{id:"link",label:"Link",ariaLabel:"Insert or edit link",icon:L.link,group:"links",shortcut:"Mod+K",mutates:!1,isDisabled:Va,run:t=>t.openLinkDialog(),isActive:t=>!!t.currentLinkElement()},{id:"unlink",label:"Remove link",ariaLabel:"Remove link",icon:L.unlink,group:"links",run:t=>t.squire.removeLink()},Lt("unorderedList","Bulleted list",L.ul,"Mod+Shift+8","lists",t=>t.toggleList("UL"),t=>t.pathHas("UL"),Et),Lt("orderedList","Numbered list",L.ol,"Mod+Shift+9","lists",t=>t.toggleList("OL"),t=>t.pathHas("OL"),Et),Lt("quote","Quote",L.quote,null,"blocks",t=>t.pathHas("BLOCKQUOTE")?t.squire.decreaseQuoteLevel():t.squire.increaseQuoteLevel(),t=>t.pathHas("BLOCKQUOTE"),Et),{id:"outdent",label:"Outdent",ariaLabel:"Decrease indent",icon:L.outdent,group:"blocks",shortcut:"Mod+[",isDisabled:Et,run:t=>t.outdent()},{id:"indent",label:"Indent",ariaLabel:"Increase indent",icon:L.indent,group:"blocks",shortcut:"Mod+]",isDisabled:Et,run:t=>t.indent()},{id:"undo",label:"Undo",ariaLabel:"Undo",icon:L.undo,group:"history",shortcut:"Mod+Z",mutates:!1,run:t=>t.squire.undo()},{id:"redo",label:"Redo",ariaLabel:"Redo",icon:L.redo,group:"history",shortcut:"Mod+Shift+Z",mutates:!1,run:t=>t.squire.redo()},{id:"clearFormatting",label:"Clear formatting",ariaLabel:"Clear formatting",icon:L.clear,group:"cleanup",run:t=>t.squire.removeAllFormatting()},{id:"blockMenu",type:"menu",label:"Block style",ariaLabel:"Choose block style",icon:L.blocks,group:"blocks",isDisabled:Et,options:[Be("Paragraph","P",L.blocks),Be("Heading 1","H1",L.h1),Be("Heading 2","H2",L.h2),Be("Heading 3","H3",L.h3),{label:"Quote",icon:L.quote,value:"BLOCKQUOTE",isDisabled:Et,run:t=>t.squire.increaseQuoteLevel(),isActive:t=>t.pathHas("BLOCKQUOTE")},{label:"Code block",icon:L.code,value:"PRE",isDisabled:Et,run:t=>t.setBlockType("PRE"),isActive:t=>t.pathHas("PRE")}]}];function Lt(t,e,i,r,n,o,a=c=>c.selectionHasFormat(Qa(t)),l){return{id:t,label:e,ariaLabel:e,icon:i,group:n,shortcut:r,isDisabled:l,run:o,isActive:a}}function Qa(t){return{bold:"B",italic:"I",underline:"U",strikethrough:"S"}[t]}function Be(t,e,i){return{label:t,icon:i,value:e,isDisabled:Et,run:r=>r.setBlockType(e),isActive:r=>r.pathHas(e)}}var vi=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,Fe=/[^ \t\r\n]/,Xa=new Set(["BR","HR","IFRAME","IMG","INPUT","WBR"]),xi=t=>t?.nodeType===1&&t.matches('[editor-ui],[clay~="editor-ui"]'),ge=new Set(["svg","math"]);function Pe(t){let e=t.nodeType;return e===3||e===8?!0:e!==1?!1:ge.has(t.nodeName)?!0:vi.test(t.nodeName)?Array.from(t.childNodes).every(Pe):!1}function ye(t){return Array.from(t.childNodes).some(e=>!Pe(e))}var wi=t=>t?.nodeType===1&&!ge.has(t.nodeName)&&!vi.test(t.nodeName);function Ei(t,e){let i=Array.from(t.childNodes),r=0;return i.forEach((n,o)=>{if(!(n.nodeType!==1||ge.has(n.nodeName))&&(r+=Ei(n,e),!!wi(n))){for(wi(i[o-1])&&t.insertBefore(e(),n);n.firstChild;)t.insertBefore(n.firstChild,n);n.remove(),r+=1}}),r}var Ci=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","COLGROUP"]);function Si(t){return!!t.closest?.("p")||Ci.has(t.nodeName)}var Ja=new Set(["P","H1","H2","H3","H4","H5","H6","PRE","LABEL","LEGEND","LI","TD","TH","DT","DD","FIGCAPTION","SUMMARY","CAPTION"]);function tl(t){return Ja.has(t.nodeName)||ki(t)}var tn=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","PARAM","SOURCE","TRACK","WBR"]),el=new Set(["SCRIPT","STYLE","TEXTAREA","TITLE","IFRAME","NOSCRIPT","XMP"]),en="http://www.w3.org/1999/xhtml";function il(t){return Ci.has(t.nodeName)||tn.has(t.nodeName)||el.has(t.nodeName)||t.nodeName==="TEMPLATE"||!!t.namespaceURI&&t.namespaceURI!==en}function rl(t){return Ci.has(t.nodeName)?"a table element cannot be an editable region. Move the editable attribute to a <td>, a <th>, or an element inside one.":t.namespaceURI&&t.namespaceURI!==en?"an SVG or MathML element cannot be an editable region: an edit puts an HTML block inside it, and the next page load moves that text out of the graphic entirely. Put a <foreignObject> in the SVG and mark an HTML element inside it instead.":tn.has(t.nodeName)?"this element cannot contain anything, so there is nothing to edit. Move the editable attribute to an element that holds text.":t.nodeName==="TEMPLATE"?"a <template> keeps its content out of the document, so edits to it are never saved.":"this element treats its content as plain text, so any edit would be saved as visible markup rather than formatting."}function ki(t){return t.nodeType===1&&!ge.has(t.nodeName)&&vi.test(t.nodeName)}function rn(t){return Array.from(t.querySelectorAll("*")).some(wi)}function nl(t,e={}){let{blockTag:i="DIV",wrapBareRoot:r=!1,onBareRootWrapped:n,blocksAllowed:o=!Si(t)}=e;return on(t),o&&sl(t,i,r,n),t}var ol=t=>Pe(t)&&t.nodeType!==8&&!xi(t),al=t=>t.nodeType!==8&&!xi(t)&&!(t.nodeType===3&&!Fe.test(t.nodeValue));function ll(t,{wrapBareRoot:e=!1,blocksAllowed:i=!Si(t)}={}){return i?ye(t)?Array.from(t.childNodes).some(ol)||nn(t):e:!1}function nn(t){return Array.from(t.children).some(e=>ye(e)?!Ti(e)&&Array.from(e.childNodes).some(i=>i.nodeType===3&&!Fe.test(i.nodeValue))||nn(e):!1)}function on(t){ye(t)&&(Ti(t)||Array.from(t.childNodes).forEach(e=>{e.nodeType===3&&!Fe.test(e.nodeValue)&&e.remove()}),Array.from(t.children).forEach(on))}function sl(t,e,i,r){if(!ye(t)){if(!i)return;let a=t.ownerDocument.createElement(e);if(!Array.from(t.childNodes).some(al)){a.appendChild(t.ownerDocument.createElement("BR")),t.appendChild(a);return}for(;t.firstChild;)a.appendChild(t.firstChild);t.appendChild(a),r?.(t,a);return}let n=[],o=()=>{let a=n;if(n=[],!a.some(c=>c.nodeType!==8))return;let l=t.ownerDocument.createElement(e);t.insertBefore(l,a[0]),a.forEach(c=>l.appendChild(c))};Array.from(t.childNodes).forEach(a=>{xi(a)?o():Pe(a)?n.push(a):o()}),o()}function Ti(t){return t.nodeName==="PRE"}function cl(t,e){return{start:an(t,e.startContainer,e.startOffset),end:an(t,e.endContainer,e.endOffset),collapsed:e.collapsed}}function hl(t,e,i){sn(e,"setStart",t,i.start),i.collapsed?e.collapse(!0):sn(e,"setEnd",t,i.end)}function an(t,e,i){if(!t.contains(e))return{scope:t,after:[],before:[]};if(e.nodeType===3){if(!dl(e))return{container:e,offset:i};let r=e.parentNode;return ln(r,Array.from(r.childNodes).indexOf(e))}return{container:e,offset:i,childCount:e.childNodes.length,...ln(e,i)}}function ln(t,e){let i=Array.from(t.childNodes),r=Math.max(0,e);return{scope:t,after:i.slice(r),before:i.slice(0,r).reverse()}}function sn(t,e,i,r){let{container:n,childCount:o}=r;if(n&&i.contains(n)&&(o===void 0||o===n.childNodes.length)){t[e](n,Math.min(r.offset,_i(n)));return}let a=r.after?.find(h=>i.contains(h));if(a){t[e](He(a,!0),0);return}let l=r.before?.find(h=>i.contains(h));if(l){let h=He(l,!1);t[e](h,_i(h));return}let c=r.scope&&i.contains(r.scope)?r.scope:i;t[e](c,0)}function dl(t){return t.nodeType===3&&!Fe.test(t.nodeValue)&&!!t.parentNode&&t.parentNode.nodeType===1&&ye(t.parentNode)&&!Ti(t.parentNode)}var be=t=>t.nodeType===1||t.nodeType===3;function He(t,e=!0){let i=t;for(;i.nodeType===1&&!ge.has(i.nodeName);){let r=Array.from(i.childNodes).filter(be),n=e?r[0]:r[r.length-1];if(!n||Xa.has(n.nodeName))break;i=n}return i}function _i(t){return t.nodeType===3?t.nodeValue.length:t.childNodes.length}var mt="[data-richclay], [richclay], [editable], [clay-editable]",ul="[data-richclay], [richclay], [clay-editable]",pl=["editable","clay-editable"],Ai=':is([editable~="single-line"], [clay-editable~="single-line"])';function cn(t){return!t||typeof t.matches!="function"?!1:t.tagName.includes("-")?t.matches(ul):!0}var fl="[data-richclay-toolbar], [data-richclay-menu], [data-richclay-dialog], [data-richclay-link-popover], [data-richclay-live], [data-richclay-float]",ml=["richclay-editor","richclay-inline","richclay-active","richclay-empty","richclay-focused"],Ni=new WeakSet,hn=new WeakSet,dn=["clay:ready","hyperclay:ready"];function un(t){return[t.clay?.ready,t.hyperclay?.ready].find(e=>e&&typeof e.then=="function")||null}function pn(t){return typeof t.clay?.isEditMode=="boolean"?t.clay.isEditMode:typeof t.hyperclay?.isEditMode=="boolean"?t.hyperclay.isEditMode:null}function gl(t){let e=t.hyperclayModules,i=t.__hyperclayNoAutoExport===!1&&e&&typeof e=="object"&&typeof e.nodeType!="number";return pn(t)!==null||!!un(t)||!!i}function yl(t){return t.clay?.addDocumentTransform||t.hyperclay?.beforeSave||null}function bl(t){return t.clay?.onSnapshot||t.hyperclay?.onSnapshot||null}var vl={boxSizing:"border-box",minWidth:"100%",overflow:"auto",width:"0"};function Li(t={},e=window){return t.hyperclay===!1?!1:t.hyperclay===!0?!0:!!(gl(e)||Nl(e))}function fn(t=window){let e=bn(t);if(e!==null)return e;if(typeof t.__hyperclayEditMode=="boolean")return t.__hyperclayEditMode;let i=pn(t);return i!==null?i:Ll(t)}function xl(t={},e=window){return t.readOnly?!1:Li(t,e)?fn(e):!0}function wl(t){let e=pl.find(n=>t.hasAttribute(n));if(!e)return null;let i=new Set((t.getAttribute(e)||"").trim().split(/\s+/).filter(Boolean)),r={inline:!0,singleLine:i.has("single-line"),toolbarOnSelect:i.has("toolbar-on-select")};return i.has("no-toolbar")&&(r.toolbar=!1),i.has("link-label")&&(r.singleLine=!0,r.linkLabel=!0,r.toolbar=["link","undo","redo"]),r}function mn(t=window){if(Ni.has(t))return;let e=bl(t)||yl(t);if(typeof e!="function"){El(t);return}e(i=>gn(i)),Ni.add(t)}function El(t){if(hn.has(t))return;let e=t.document,i=un(t);if(!e&&!i)return;hn.add(t);let r=()=>{mn(t),Ni.has(t)&&n()},n=()=>{e&&dn.forEach(o=>e.removeEventListener(o,r))};e&&dn.forEach(o=>e.addEventListener(o,r)),i&&i.then(r,()=>{})}function gn(t){t.querySelectorAll?.(fl).forEach(e=>e.remove()),t.querySelectorAll?.(mt).forEach(e=>{if(e.getAttribute("data-richclay-active")==="true"){if(Oi(e,"save"),Tl(e)){let i=e.ownerDocument,r=!!e.matches?.(Ai);Ei(e,()=>r?i.createTextNode(" "):i.createElement("br")),e.querySelectorAll(e.localName).forEach(n=>{for(;n.firstChild;)n.parentNode.insertBefore(n.firstChild,n);n.remove()})}e.matches?.(Ai)&&Al(e),e.querySelectorAll("#squire-selection-start, #squire-selection-end").forEach(i=>{i.remove()}),e.querySelectorAll(".squire-image-resize-container").forEach(i=>i.remove()),_l(e),(e.matches?.("pre")?[e,...e.querySelectorAll("pre")]:Array.from(e.querySelectorAll("pre"))).filter(i=>i.hasAttribute("data-richclay-pre")).forEach(i=>{Object.entries(vl).forEach(([r,n])=>{i.style[r]||(i.style[r]=n)}),i.removeAttribute("data-richclay-pre")})}}),t.querySelectorAll?.("#squire-selection-start, #squire-selection-end").forEach(e=>e.remove())}var Cl="p, td, th, li, dl, dt, dd, table, blockquote, div, section, article, aside, main, header, footer, figure, figcaption",Di="data-richclay-measure";function Sl(t){let e=t.ownerDocument,i=t.closest(Cl)||t;t.setAttribute(Di,"");let r=e.createElement("div");try{r.innerHTML=i.outerHTML}finally{t.removeAttribute(Di)}let n=r.querySelector(`[${Di}]`);return!n||n.textContent!==t.textContent}var kl=t=>!!t.querySelector(t.localName),Tl=t=>!!t.matches?.(Ai)||(rn(t)||kl(t))&&Sl(t);function Oi(t,e){let i=t.getAttribute("data-richclay-runtime-contenteditable");t.hasAttribute("contenteditable")&&(i==="true"?t.removeAttribute("contenteditable"):i?e==="destroy"?t.setAttribute("contenteditable",i):(t.setAttribute("inert-contenteditable",i),t.removeAttribute("contenteditable")):e==="save"&&(t.setAttribute("inert-contenteditable",t.getAttribute("contenteditable")),t.removeAttribute("contenteditable"))),ml.forEach(r=>t.classList.remove(r)),t.getAttribute("class")===""&&t.removeAttribute("class"),Ri(t,"role","data-richclay-runtime-role"),Ri(t,"aria-multiline","data-richclay-runtime-aria-multiline"),Ri(t,"no-undo","data-richclay-runtime-no-undo"),t.getAttribute("data-richclay-runtime-display")==="true"&&(t.style.removeProperty("display"),t.getAttribute("style")===""&&t.removeAttribute("style")),Dl(t),t.removeAttribute("data-richclay-active"),t.removeAttribute("data-richclay-placeholder"),t.removeAttribute("data-richclay-pre"),t.removeAttribute("data-richclay-runtime-role"),t.removeAttribute("data-richclay-runtime-aria-multiline"),t.removeAttribute("data-richclay-runtime-no-undo"),t.removeAttribute("data-richclay-runtime-describedby"),t.removeAttribute("data-richclay-runtime-contenteditable"),t.removeAttribute("data-richclay-runtime-display"),t.getAttribute("data-richclay-runtime-marker")==="true"&&t.removeAttribute("data-richclay"),t.removeAttribute("data-richclay-runtime-marker")}function _l(t){let e=[t];for(;e.length;)e.pop().childNodes.forEach(i=>{i.nodeType===3?i.nodeValue.includes("\u200B")&&(i.nodeValue=i.nodeValue.split("\u200B").join("")):i.nodeType===1&&e.push(i)});t.querySelectorAll("b, i, u, s, em, strong, code, sub, sup, span").forEach(i=>{i.children.length===0&&(i.textContent||"")===""&&i.attributes.length===0&&i.remove()})}function Al(t){let e=Array.from(t.childNodes).filter(r=>r.nodeType!==3||(r.nodeValue||"").trim()!=="");if(e.length!==1)return;let i=e[0];if(!(i.nodeType!==1||i.nodeName!=="P"||i.attributes.length>0)){for(;i.firstChild;)t.insertBefore(i.firstChild,i);i.remove()}}function yn(t){if(!t.hasAttribute("inert-contenteditable"))return null;let e=t.getAttribute("inert-contenteditable");return["false","plaintext-only"].includes(e)||(e="true"),t.setAttribute("contenteditable",e),t.removeAttribute("inert-contenteditable"),e==="true"&&t.setAttribute("data-richclay-runtime-contenteditable","true"),e}function zt(t){return t.setAttribute("snapshot-remove",""),t.setAttribute("no-watch",""),t}function bn(t){try{let e=new URLSearchParams(t.location?.search||"");if(e.get("editmode")==="true")return!0;if(e.get("editmode")==="false")return!1}catch{return null}return null}function Nl(t){return bn(t)!==null||typeof t.__hyperclayEditMode=="boolean"}function Ll(t){let e=(t.document?.cookie||"").match(/(?:^|;\s*)isAdminOfCurrentResource=([^;]*)/);return!!(e&&e[1]!=="")}function Ri(t,e,i){t.hasAttribute(i)&&t.removeAttribute(e)}function Dl(t){let e=t.getAttribute("data-richclay-runtime-describedby");if(!e)return;let i=(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean).filter(r=>r!==e);i.length?t.setAttribute("aria-describedby",i.join(" ")):t.removeAttribute("aria-describedby")}var Ol=0;function Rl(t=document){let e=t.createElement("div");return e.id=`richclay-live-${++Ol}`,e.className="richclay-sr-only",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("data-richclay-live",""),zt(e),t.body.appendChild(e),e}function ve(t,e){!t||!e||(t.textContent="",t.ownerDocument.defaultView.setTimeout(()=>{t.textContent=e},20))}function Mi(t){t.preventDefault()}function vn(t){try{return t?.cloneRange?.()||null}catch{return null}}function xe(t){try{return vn(t?.getSelection?.())}catch{return null}}function Ii(t,e){if(!t||!e)return!1;try{return t.setSelection(e),!0}catch{return!1}}function Bi(t,e,i,r){t.hasAttribute(e)||t.setAttribute(r,"true"),t.setAttribute(e,i)}function Ml(t,e){let i=new Set((t.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));i.add(e.id),t.setAttribute("aria-describedby",Array.from(i).join(" ")),t.setAttribute("data-richclay-runtime-describedby",e.id)}var Il=0,xn=class{constructor(t,e,i={}){this.editor=t,this.controls=e,this.options=i,this.id=++Il,this.items=[],this.menus=new Map,this.activeIndex=0,this.root=this.createRoot(),this.onRootKeydown=r=>this.handleRootKeydown(r),this.onRootClick=r=>this.handleRootClick(r),this.onRootPointerDown=r=>this.handleRootPointerDown(r),this.onDocumentPointerDown=r=>this.handleDocumentPointerDown(r),this.render(),this.root.addEventListener("keydown",this.onRootKeydown),this.root.addEventListener("click",this.onRootClick),this.root.addEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.addEventListener("mousedown",this.onDocumentPointerDown)}destroy(){this.closeMenus(),this.root.removeEventListener("keydown",this.onRootKeydown),this.root.removeEventListener("click",this.onRootClick),this.root.removeEventListener("mousedown",this.onRootPointerDown),this.root.ownerDocument.removeEventListener("mousedown",this.onDocumentPointerDown),this.root.remove()}update(){this.items.forEach(t=>{let{def:e,button:i}=t;if(typeof e.isActive=="function"){let r=!!e.isActive(this.editor);i.setAttribute("aria-pressed",r?"true":"false"),i.classList.toggle("is-active",r)}typeof e.isDisabled=="function"&&(i.disabled=!!e.isDisabled(this.editor))}),this.ensureSingleTabStop()}focusFirst(){this.activeIndex=0,this.ensureSingleTabStop(),this.items[0]?.button.focus()}createRoot(){let t=this.editor.element.ownerDocument,e=t.createElement("div");e.className="richclay-toolbar",e.setAttribute("role","toolbar"),e.setAttribute("aria-label",this.options.ariaLabel||"Rich text formatting"),e.setAttribute("data-richclay-toolbar",""),zt(e);let i=Bl(this.options.toolbarContainer,t);return i?i.appendChild(e):this.editor.element.insertAdjacentElement("beforebegin",e),e}render(){this.root.textContent="",this.items=[],this.menus.clear();let t=null;this.visibleControls().forEach((e,i)=>{if(e.type==="separator"){this.root.appendChild(En(this.root.ownerDocument)),t=null;return}t&&e.group&&e.group!==t&&this.root.appendChild(En(this.root.ownerDocument)),t=e.group||t,e.type==="menu"?this.renderMenu(e,i):this.renderButton(e,i)}),this.ensureSingleTabStop(),this.update()}visibleControls(){let t=this.controls.filter(i=>i.type==="separator"||!i.isDisabled?.(this.editor)),e=[];for(t.forEach(i=>{let r=e[e.length-1];i.type==="separator"&&(!r||r.type==="separator")||e.push(i)});e[e.length-1]?.type==="separator";)e.pop();return e}renderButton(t,e){let i=wn(this.root.ownerDocument,t);i.dataset.richclayControl=t.id,i.dataset.richclayIndex=String(e),typeof t.isActive=="function"&&i.setAttribute("aria-pressed","false"),this.root.appendChild(i),this.items.push({def:t,button:i,type:"button"})}renderMenu(t,e){let i=this.root.ownerDocument,r=wn(i,t),n=`richclay-menu-${this.id}-${t.id}`;r.dataset.richclayControl=t.id,r.dataset.richclayIndex=String(e),r.setAttribute("aria-haspopup","menu"),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-controls",n);let o=i.createElement("div");o.id=n,o.className="richclay-menu",o.hidden=!0,o.setAttribute("role","menu"),o.setAttribute("data-richclay-menu",""),zt(o),t.options.forEach((l,c)=>{let h=i.createElement("button");h.type="button",h.className="richclay-menu-item",h.setAttribute("role","menuitemradio"),h.setAttribute("tabindex","-1"),h.dataset.richclayMenuItem=t.id,h.dataset.richclayOptionIndex=String(c),h.innerHTML=l.icon||"",h.appendChild(i.createTextNode(l.label)),h.addEventListener("mousedown",Mi),h.addEventListener("click",u=>{u.preventDefault(),this.chooseMenuItem(t,l,r)}),h.addEventListener("keydown",u=>this.handleMenuKeydown(u,t,r)),o.appendChild(h)});let a=i.createElement("span");a.className="richclay-menu-wrap",a.append(r,o),this.root.appendChild(a),this.items.push({def:t,button:r,type:"menu",menu:o}),this.menus.set(t.id,{def:t,button:r,menu:o})}handleRootPointerDown(t){let e=t.target.closest?.("[data-richclay-control]");!e||!this.root.contains(e)||(Mi(t),this.editor.saveSelection())}handleRootClick(t){let e=t.target.closest?.("[data-richclay-control]");if(!e||!this.root.contains(e))return;t.preventDefault();let i=this.items.find(r=>r.button===e);if(!(!i||e.disabled)){if(this.activeIndex=this.items.indexOf(i),this.ensureSingleTabStop(),i.type==="menu"){this.toggleMenu(i.def.id);return}this.closeMenus(),this.editor.runControl(i.def)}}handleRootKeydown(t){let e=t.key,i={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1};if(e in i){t.preventDefault(),this.moveFocus(i[e]);return}if(e==="Home"){t.preventDefault(),this.setFocusIndex(0);return}if(e==="End"){t.preventDefault(),this.setFocusIndex(this.items.length-1);return}let r=this.items[this.activeIndex];if(r&&((e==="Enter"||e===" ")&&r.type==="menu"&&(t.preventDefault(),this.openMenu(r.def.id,"first")),e==="Escape")){let n=Array.from(this.menus.values()).some(o=>!o.menu.hidden);this.closeMenus(),n?r.button.focus():this.editor.focus()}}handleMenuKeydown(t,e,i){t.stopPropagation();let r=this.menus.get(e.id)?.menu,n=Array.from(r.querySelectorAll(".richclay-menu-item")),o=n.indexOf(t.currentTarget),a=o;if(t.key==="ArrowDown"&&(a=(o+1)%n.length),t.key==="ArrowUp"&&(a=(o-1+n.length)%n.length),t.key==="Home"&&(a=0),t.key==="End"&&(a=n.length-1),a!==o){t.preventDefault(),n[a].focus();return}if(t.key==="Escape"){t.preventDefault(),this.closeMenus(),i.focus();return}if(t.key==="Enter"||t.key===" "){t.preventDefault();let l=e.options[o];this.chooseMenuItem(e,l,i)}}handleDocumentPointerDown(t){this.root.contains(t.target)||this.closeMenus()}chooseMenuItem(t,e,i){this.closeMenus(),this.editor.runControl({...e,id:`${t.id}:${e.value}`,ariaLabel:e.label}),i.focus()}toggleMenu(t){let e=this.menus.get(t);e&&(e.menu.hidden?this.openMenu(t,"first"):this.closeMenus())}openMenu(t,e="first"){this.closeMenus(t);let i=this.menus.get(t);if(!i)return;i.menu.hidden=!1,i.button.setAttribute("aria-expanded","true"),this.updateMenuState(i);let r=Array.from(i.menu.querySelectorAll(".richclay-menu-item")),n=r.find(o=>o.getAttribute("aria-checked")==="true");(e==="active"&&n||r[0])?.focus()}closeMenus(t=null){this.menus.forEach((e,i)=>{i!==t&&(e.menu.hidden=!0,e.button.setAttribute("aria-expanded","false"))})}updateMenuState(t){Array.from(t.menu.querySelectorAll(".richclay-menu-item")).forEach((e,i)=>{let r=!!t.def.options[i].isActive?.(this.editor);e.setAttribute("aria-checked",r?"true":"false"),e.classList.toggle("is-active",r)})}moveFocus(t){if(!this.items.length)return;let e=this.activeIndex;do e=(e+t+this.items.length)%this.items.length;while(this.items[e].button.disabled&&e!==this.activeIndex);this.setFocusIndex(e)}setFocusIndex(t){this.activeIndex=Math.max(0,Math.min(t,this.items.length-1)),this.ensureSingleTabStop(),this.items[this.activeIndex]?.button.focus()}ensureSingleTabStop(){let t=this.items.filter(e=>!e.button.disabled);t.length&&(t.includes(this.items[this.activeIndex])||(this.activeIndex=this.items.indexOf(t[0])),this.items.forEach((e,i)=>{e.button.tabIndex=i===this.activeIndex?0:-1}))}};function wn(t,e){let i=t.createElement("button");i.type="button",i.className="richclay-button";let r=Za(e.shortcut,t.defaultView),n=r?`${e.ariaLabel||e.label} (${r})`:e.ariaLabel||e.label;return i.setAttribute("aria-label",n),i.title=n,i.innerHTML=`${e.icon||""}<span class="richclay-sr-only">${e.label}</span>`,i}function En(t){let e=t.createElement("span");return e.className="richclay-separator",e.setAttribute("role","separator"),e.setAttribute("aria-orientation","vertical"),e}function Bl(t,e){return t?typeof t=="string"?e.querySelector(t):t:null}var Cn=16,Fl=[16,8,0],$=8,Pl=4;function Hl({anchor:t,bar:e,rail:i,viewport:r,current:n=null}){let o=f=>n===f?Pl:0;if(t.bottom<=0||t.top>=r.height||t.right<=0||t.left>=r.width)return{mode:"hidden",x:0,y:0};let a=f=>Math.max($,Math.min(t.left,r.width-f-$)),l=t.top-Cn-e.height;if(l>=$-o("above"))return{mode:"above",x:a(e.width),y:l};let c=t.bottom+Cn;if(c+e.height<=r.height-$+o("below"))return{mode:"below",x:a(e.width),y:c};let h=r.width-t.right-$,u=t.left-$,d=h>=u?[["rail-right",h],["rail-left",u]]:[["rail-left",u],["rail-right",h]];for(let[f,y]of d)for(let g of Fl){if(i.width+g>y+o(f))continue;let w=f==="rail-right"?Math.min(t.right+g,r.width-i.width-$):Math.max(t.left-g-i.width,$),E=Math.min(t.bottom,r.height-$)-i.height,D=Math.max($,Math.min(Math.max(t.top,$),E));return{mode:f,x:w,y:D,gap:g}}return{mode:"pinned",x:a(e.width),y:$}}var Ul=10,ql=28;function Sn({anchor:t,box:e,viewport:i,gap:r=Ul}){let n=i.height-$-t.bottom-r,o=t.top-r-$,a=n>=e.height||n>=o?"below":"above",l=a==="below"?t.bottom+r:t.top-r-e.height,c=Math.max($,Math.min(l,i.height-$-e.height)),h=(t.left+t.right)/2,u=Math.max($,Math.min(h-ql,i.width-$-e.width)),d=Math.max(14,Math.min(h-u,e.width-14));return{side:a,x:u,y:c,arrow:d}}function rt(t,e,i){t.style.setProperty(e,i,"important")}var zl=class{constructor(t,e){this.editor=t,this.mode=null,this.hidden=!1,this.frame=0,this.bar={width:0,height:0},this.rail={width:0,height:0};let i=t.element.ownerDocument;this.doc=i,this.win=i.defaultView||globalThis,this.root=i.createElement("div"),this.root.className="richclay-float",this.root.setAttribute("data-richclay-float",""),this.root.setAttribute("save-remove",""),zt(this.root),i.body.appendChild(this.root),this.toolbar=new xn(t,e,{toolbarContainer:this.root}),this.onScroll=()=>this.schedule(),this.onResize=()=>{this.measure(),this.schedule()},i.addEventListener("scroll",this.onScroll,{capture:!0,passive:!0}),this.win.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("resize",this.onResize,{passive:!0}),this.win.visualViewport?.addEventListener("scroll",this.onScroll,{passive:!0}),this.resizeObserver=typeof this.win.ResizeObserver=="function"?new this.win.ResizeObserver(()=>this.schedule()):null,this.resizeObserver?.observe(t.element),this.measure(),this.reposition()}measure(){let t=this.root.classList.contains("richclay-float-rail");rt(this.root,"visibility","hidden"),this.root.classList.remove("richclay-float-rail"),this.bar={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.add("richclay-float-rail"),this.rail={width:this.root.offsetWidth||0,height:this.root.offsetHeight||0},this.root.classList.toggle("richclay-float-rail",t),this.root.style.removeProperty("visibility")}schedule(){if(!this.win.requestAnimationFrame){this.reposition();return}this.frame||(this.frame=this.win.requestAnimationFrame(()=>{this.frame=0,this.reposition()}))}setVisible(t){this.hidden=!t,this.reposition()}reposition(){if(this.hidden){rt(this.root,"display","none");return}let t=this.editor.element.getBoundingClientRect(),e={width:this.win.visualViewport?.width??this.win.innerWidth,height:this.win.visualViewport?.height??this.win.innerHeight},i=Hl({anchor:t,bar:this.bar,rail:this.rail,viewport:e,current:this.mode});if(this.mode=i.mode,i.mode==="hidden"){rt(this.root,"display","none");return}this.root.style.removeProperty("display"),this.root.classList.toggle("richclay-float-rail",i.mode==="rail-left"||i.mode==="rail-right"),this.root.classList.toggle("richclay-float-pinned",i.mode==="pinned"),rt(this.root,"transform",`translate(${Math.round(i.x)}px, ${Math.round(i.y)}px)`)}destroy(){this.frame&&this.win.cancelAnimationFrame?.(this.frame),this.frame=0,this.doc.removeEventListener("scroll",this.onScroll,{capture:!0}),this.win.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("scroll",this.onScroll),this.resizeObserver?.disconnect(),this.toolbar.destroy(),this.root.remove()}},Wl={ALLOWED_TAGS:["a","b","blockquote","br","code","div","em","h1","h2","h3","h4","h5","h6","i","li","ol","p","pre","s","span","strong","sub","sup","u","ul"],ALLOWED_ATTR:["aria-label","href","rel","target","title"],ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!0,ALLOWED_URI_REGEXP:/^(?:(?:(?:f|ht)tps?|mailto|tel):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,FORBID_TAGS:["script","style","iframe","object","embed","form","input"],FORBID_ATTR:["style","srcset","onerror","onclick","onload"]};function Kl(t={},e=document){let i=Ue(e);return{sanitizeHTML(r){return kn(r,t,e,i)},sanitizeElement(r){return Tn(r,t,i)},sanitizeToDOMFragment(r,n){let o=n?.getRoot?.().ownerDocument||e;return $l(r,t,o,i)}}}function kn(t,e={},i=document,r=Ue(i)){let n=i.createElement("template");return n.innerHTML=r.sanitize(String(t||""),Fi(e)),Pi(n.content),n.innerHTML}function Tn(t,e={},i=Ue(t.ownerDocument)){let r=t.ownerDocument.createElement("div");for(;t.firstChild;)r.appendChild(t.firstChild);for(i.sanitize(r,{...Fi(e),IN_PLACE:!0}),Pi(r);r.firstChild;)t.appendChild(r.firstChild);return t}function $l(t,e={},i=document,r=Ue(i)){let n=r.sanitize(String(t||""),{...Fi(e),RETURN_DOM_FRAGMENT:!0}),o=n?.ownerDocument===i?n:i.importNode(n,!0);return Pi(o),o||i.createDocumentFragment()}function Fi(t){return{...Wl,...t}}var jl=new Set(["http","https","mailto","tel"]),Vl=new RegExp("[\\u0000-\\u0020\\u007F-\\u009F]","g");function _n(t){let e=(String(t??"").replace(Vl,"").match(/^([a-z][a-z0-9+.\-]*):/i)||[])[1];return!e||jl.has(e.toLowerCase())}var Gl=/^[^\s/?#:]+\.(?:html?|pdf|txt|csv|json|xml|svg|png|jpe?g|gif|webp|docx?|xlsx?|pptx?|bib|tex|zip)(?:[?#]\S*)?$/i,Zl=/^[^\s/?#:.]+\/\S*$/;function Yl(t){let e=String(t??"").trim();return!e||!_n(e)?"":/^(?:https?:|mailto:|tel:)/i.test(e)?e:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?`mailto:${e}`:/^(?:[#?]|\/|\.{1,2}\/)/.test(e)||Gl.test(e)||Zl.test(e)?e:`https://${e}`}function Ue(t){let e=globalThis.DOMPurify;if(e?.sanitize)return e;if(typeof e=="function")return e(t.defaultView||globalThis);throw new Error("RichClay requires DOMPurify. Load vendor/purify.min.js before richclay.js or provide globalThis.DOMPurify.")}function Pi(t){t.querySelectorAll?.("a[href]").forEach(e=>{let i=e.getAttribute("href")||"";if(/^\s*javascript:/i.test(i)&&e.removeAttribute("href"),e.getAttribute("target")==="_blank"){let r=new Set((e.getAttribute("rel")||"").split(/\s+/).filter(Boolean));r.add("noopener"),r.add("noreferrer"),e.setAttribute("rel",Array.from(r).join(" "))}})}var An={ADD_TAGS:["img"],ADD_ATTR:["class","id","src","alt","width","height"]};function Ql(t={}){return{...t,ADD_TAGS:[...new Set([...An.ADD_TAGS,...t.ADD_TAGS||[]])],ADD_ATTR:[...new Set([...An.ADD_ATTR,...t.ADD_ATTR||[]])],ALLOW_DATA_ATTR:t.ALLOW_DATA_ATTR??!0}}var Nn="p, div, h1, h2, h3, h4, h5, h6, blockquote, pre, ul, ol, li, figure, figcaption, table, thead, tbody, tr, td, th";function Xl(t){let e=t.ownerDocument||document;t.querySelectorAll?.("br").forEach(r=>r.replaceWith(e.createTextNode(" ")));let i=t.querySelector?.(Nn);for(;i;){let r=i.parentNode;for(r.insertBefore(e.createTextNode(" "),i);i.firstChild;)r.insertBefore(i.firstChild,i);r.insertBefore(e.createTextNode(" "),i),i.remove(),i=t.querySelector(Nn)}return Jl(t,e),t}function Jl(t,e){t.normalize?.();let i=e.createTreeWalker(t,4),r=[];for(;i.nextNode();)r.push(i.currentNode);r.forEach(a=>{a.nodeValue=a.nodeValue.replace(/\s+/g," ")});let n=t.firstChild;n?.nodeType===3&&(n.nodeValue=n.nodeValue.replace(/^\s+/,""));let o=t.lastChild;o?.nodeType===3&&(o.nodeValue=o.nodeValue.replace(/\s+$/,""))}var ts=300,es=t=>t.replace(/^mailto:/i,"").replace(/^https?:\/\//i,""),is=class{constructor(t){this.editor=t,this.root=null,this.anchor=null,this.href=null,this.dismissed=null,this.hideTimer=null,this.pointerInside=!1,this.cleanup=null}currentAnchor(){let t=this.editor;if(!t.active||t.options.readOnly||t.dialog)return null;let e=t.element.ownerDocument;if(e.hidden)return null;let i=e.getSelection?.();return!i||!i.rangeCount||!t.element.contains(i.anchorNode)?null:t.currentLinkElement()}update(){let t=this.currentAnchor();if(!(t&&t===this.dismissed)){if(this.dismissed=null,!t){this.scheduleHide();return}this.cancelHide(),this.show(t)}}show(t){this.root||this.mount();let e=t.getAttribute("href")||"";if(t!==this.anchor||e!==this.href){this.anchor=t,this.href=e;let i=this.root.querySelector(".richclay-link-address");i.textContent=es(e)||e,i.title=e,e&&_n(e)?i.setAttribute("href",e):i.removeAttribute("href"),/^(?:mailto|tel):/i.test(e)?i.removeAttribute("target"):i.setAttribute("target","_blank")}this.position()}mount(){let t=this.editor,e=t.element.ownerDocument,i=e.defaultView||globalThis,r=e.createElement("div");r.className="richclay-dialog richclay-link-popover",r.setAttribute("role","group"),r.setAttribute("aria-label","Link"),r.setAttribute("data-richclay-link-popover",""),zt(r),r.setAttribute("save-remove",""),r.innerHTML=`
|
|
99
99
|
<a class="richclay-link-address" rel="noopener noreferrer"></a>
|
|
100
100
|
<button type="button" class="richclay-secondary" data-richclay-link-edit>Edit</button>
|
|
101
101
|
<button type="button" class="richclay-secondary" data-richclay-link-remove>Remove</button>
|
|
@@ -546,4 +546,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
548
|
`,te=typeof globalThis<"u"?globalThis:self;te&&!te.Squire&&(te.Squire=ua),te&&!te.DOMPurify&&(te.DOMPurify=ja),rs(Es);var Cs=$i.autoInit(),Ss=$i;return No(pr)})();window.__hyperclayNoAutoExport||(window.hyperclay=window.hyperclay||{},window.hyperclay.RichClay=Qe.default,window.RichClay=window.RichClay||Qe.default,window.h=window.hyperclay);var bt=Qe.default,cc=Qe.default;wo("richclay",Co,{roots:Eo});var Xe=null,So=(v,ct)=>Object.assign(new Error(`clay:richclay: ${v}`),{code:ct}),Js=v=>v?v.signal?.aborted?!0:typeof v.isCurrent=="function"&&!v.isCurrent():!1,tc=v=>({root:v,win:v.ownerDocument?.defaultView||window,admitted:!1,stopWatch:null,subscriber:null}),To=v=>[...v.root.querySelectorAll(bt.selector)];function ko(v){for(let ct of bt.init(To(v)))ct.reattach()}function ec(v){let ct=()=>ko(v);return{enable(){if(v.admitted)return;v.admitted=!0,ko(v),v.stopWatch=bt.watch(v.win);let lt=v.root.ownerDocument||document;v.subscriber={target:lt,type:"clay:sync-applied",handler:ct},lt.addEventListener(v.subscriber.type,ct)},quiesce(){v.admitted=!1,v.stopWatch&&(v.stopWatch(),v.stopWatch=null)},resume(){v.admitted||(v.admitted=!0,v.stopWatch=bt.watch(v.win))},dispose(){v.admitted=!1,v.stopWatch&&(v.stopWatch(),v.stopWatch=null);let lt=v.subscriber;v.subscriber=null,lt&<.target.removeEventListener(lt.type,lt.handler);for(let Je of To(v))bt.stripElement(Je);Xe===v&&(Xe=null)}}}function ic(v=document){return{id:"clay:richclay",order:310,async prepare(ct={}){if(ct.initial===!0)return rc();if(typeof bt.watch!="function"||typeof bt.stripElement!="function")throw So("this vendor build has no watchable lifecycle","unsupported-plugin");if(Js(ct))throw So("prepared for a stale generation","stale-document");let lt=bt.autoInit?.();return typeof lt=="function"&<(),ec(Xe||(Xe=tc(v)))}}}async function rc(){let v=await oc;return{enable(){},quiesce:()=>v?.quiesce(),resume:()=>v?.resume(),dispose:()=>v?.dispose()}}async function nc(){if(!xo())return null;let v=await ic().prepare();return v.enable(),v}var oc=nc();var wc=bt;export{bt as RichClay,wc as default,nc as init,ic as modeParticipant,oc as ready,ic as richclayParticipant};
|
|
549
|
-
/*! For license information please see richclay-
|
|
549
|
+
/*! For license information please see richclay-L3BZMX4I.js.LEGAL.txt */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as x,d as I,e as g,f as U,g as M}from"../c-7DJDKPGL.js";import{a as $}from"../c-MZCOGNZL.js";import"../c-IJUK2GPW.js";import{f as F,k as R}from"../c-C7SUMNMI.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import{k as N}from"../c-PNZIJFG7.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{e as k}from"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var T=k("history"),W="[cms-template]",L=["draggable","style"],X=["pointerup","pointercancel","dragend","drop"],y=new Set,h=null,E=null,p=null;function q(e,t,n,r,i){let o={target:t,type:n,handler:r,options:i};return t.addEventListener(n,r,i),e.listeners.push(o),o}function H(e,t){t.target.removeEventListener(t.type,t.handler,t.options);let n=e.listeners.indexOf(t);n!==-1&&e.listeners.splice(n,1)}function _(e,t){let n=setTimeout(()=>{e.timers.delete(n),t()},0);return e.timers.add(n),n}function Y(e,t){return{Sortable:e,root:t,admitted:!1,instances:new Set,listeners:[],timers:new Set,presses:new Set,stop:null}}var Z={admitted:!0,instances:new Set,listeners:[],timers:new Set,presses:new Set};function C(e){return[e,...e.querySelectorAll("*")].filter(t=>!t.closest(T)).map(t=>[t,L.map(n=>t.getAttribute(n))])}function P(e){for(let[t,n]of e)L.forEach((r,i)=>{let o=n[i],a=t.getAttribute(r);if(a!==o)if(o===null){if(r==="style"&&a)return;t.removeAttribute(r)}else t.setAttribute(r,o)})}function B(e){return/^(UL|OL)$/.test(e.tagName)?"li":"*"}function ee(e){return`> ${B(e)}:not(${T})`}function V(e,t){return!e||!t||t.nodeType!==1||!t.matches(B(e))?!1:!t.closest(T)&&!t.closest(W)}function D(e,t){return!e||!t||t.parentElement!==e?!1:V(e,t)}function te(e,t){let n=t.nextElementSibling;for(;n&&!D(e,n);)n=n.nextElementSibling;return n}function j(e,t){return Array.prototype.indexOf.call(e.children,t)}function G(e,t){if(t)try{new Function(`return (async function(evt) { ${t} })`)().call(e.from,e)}catch(n){console.error("Error in onsorted execution:",n)}e.from.dispatchEvent(new CustomEvent("clay:sorted",{bubbles:!0,detail:{item:e.item,from:e.from,to:e.to,oldIndex:e.oldIndex,newIndex:e.newIndex}})),e.from.dispatchEvent(new Event("input",{bubbles:!0}))}function z(e,t,n=Z){let r={};if(r.draggable=ee(e),r.setData=s=>{s.clearData(),s.setData("application/x-clay-sortable","")},t.get(e))return;let i=e.getAttribute("sortable");i&&(r.group=i);let o=e.querySelectorAll("[sortable-handle]"),a=e.querySelectorAll("[sortable]");Array.from(o).some(s=>!Array.from(a).some(l=>l.contains(s)))&&(r.handle="[sortable-handle]");let c=e.getAttribute("onsorting");c&&(r.onMove=function(s){if(n.admitted)try{new Function(`return (async function(evt) { ${c} })`)().call(e,s)}catch(l){console.error("Error in onsorting execution:",l)}});let f=e.getAttribute("onsorted");r.onEnd=function(s){if(!n.admitted)return;let l={item:s.item,from:s.from,to:s.to,oldIndex:s.oldIndex,newIndex:s.newIndex},b=u;u=null,m&&(P(m),m=null),b&&(M(b,l),g(b)),G(l,f)};let d=null,u=null,m=null,w=!1,A=!1,v=[],K=()=>{let s=u;u=null,m=null,g(s)},O=()=>{let s=d;d=null,s&&(n.presses.delete(s),y.delete(s),m=s),v.forEach(l=>H(n,l)),v=[],s&&_(n,()=>P(s))},Q=s=>{A&&s?.type==="pointercancel"||(A=!1,w?I(u):(g(u),u=null),w=!1,O(),_(n,K))};q(n,e,"pointerdown",s=>{let l=s.target instanceof Element?s.target:null;for(;l&&l.parentElement!==e;)l=l.parentElement;!l||d||(d=C(l),u=x(l),w=!1,A=!1,n.presses.add(d),y.add(d),v=X.map(b=>q(n,document,b,Q,!0)),v.push(q(n,document,"dragstart",()=>{A=!0},!0)))},!0),r.onUnchoose=O,r.onStart=()=>{w=!0},t.create(e,r),n.instances.add(e)}function ne(e,t,n=null){let r=f=>({ok:!1,code:f});if(!F||p&&!p.admitted)return r("not-editable");let i=document;if(!e||e.nodeType!==1||!e.isConnected||e.ownerDocument!==i)return r("detached");let o=e.parentElement;if(!o||!o.isConnected||!t||t.nodeType!==1||!t.isConnected||t.ownerDocument!==i)return r("detached");if(!o.hasAttribute("sortable")||!D(o,e)||!t.hasAttribute("sortable")||!V(t,e)||e===t||e.contains(t))return r("item");if(o!==t){let f=o.getAttribute("sortable");if(!f||f!==t.getAttribute("sortable"))return r("group")}if(n===e)return{ok:!0,moved:!1};if(n!==null&&!D(t,n))return r("anchor");if(o===t&&te(o,e)===n)return{ok:!0,moved:!1};let a=j(o,e),S=x(e);I(S);let c;try{t.insertBefore(e,n),c={item:e,from:o,to:t,oldIndex:a,newIndex:j(t,e)},M(S,c)}finally{g(S)}return G(c,o.getAttribute("onsorted")),{ok:!0,moved:!0,...c}}function re(){return h||(h=import("../vendor/Sortable.vendor-A755ITLN.js").then(e=>window.Sortable||e.default),h.catch(()=>{h=null})),h}function se(){return E||(N((e,{original:t})=>{for(let r of e.querySelectorAll("[sortable] .sortable-chosen, [sortable] .sortable-ghost, [sortable] .sortable-drag"))r.classList.remove("sortable-chosen","sortable-ghost","sortable-drag"),r.classList.length||r.removeAttribute("class");if(!y.size)return;let n=new Map;for(let r of y)for(let[i,o]of r)n.set(i,o);for(let r of e.querySelectorAll("[sortable] *")){let i=n.get(t(r));i&&L.forEach((o,a)=>{i[a]===null?r.removeAttribute(o):r.setAttribute(o,i[a])})}}),E=!0,E)}function oe(e){return{enable(){if(!e.admitted){e.admitted=!0;for(let t of e.root.querySelectorAll("[sortable]"))z(t,e.Sortable,e);e.stop=$.onAddElement({selectorFilter:"[sortable]",debounce:200,require:"observed",pausable:!1},t=>{e.admitted&&t.forEach(({element:n})=>{z(n,e.Sortable,e)})})}},quiesce(){e.admitted=!1},resume(){e.admitted=!0},dispose(){e.admitted=!1,e.stop&&(e.stop(),e.stop=null);for(let t of[...e.listeners])H(e,t);for(let t of e.timers)clearTimeout(t);e.timers.clear();for(let t of e.presses)y.delete(t);e.presses.clear(),U();for(let t of e.instances)e.Sortable?.get?.(t)?.destroy?.();e.instances.clear(),p===e&&(p=null)}}}var le=e=>e?e.signal?.aborted?!0:typeof e.isCurrent=="function"&&!e.isCurrent():!1;function ie(e=document){return{id:"clay:sortable",order:300,async prepare(t={}){if(t.initial===!0)return ae();let n=await re();if(le(t))throw Object.assign(new Error("clay:sortable prepared for a stale generation"),{code:"stale-document"});return se(),oe(p||(p=Y(n,e)))}}}async function ae(){let e=await ue;return{enable(){},quiesce:()=>e?.quiesce(),resume:()=>e?.resume(),dispose:()=>e?.dispose()}}async function J(){if(!R())return null;let e=await ie().prepare();return e.enable(),e}var ue=J(),be=Object.freeze({move:ne});var ge=J;export{ge as default,J as init,z as makeSortable,ie as modeParticipant,ne as move,ue as ready,be as sortable,ie as sortableParticipant};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../c-
|
|
1
|
+
import"../c-MFB74XVN.js";import{a as d}from"../c-LD6UVV5R.js";import"../c-PGSBXHUE.js";import"../c-KU3PX7LL.js";import"../c-EQ5NBOGA.js";import"../c-IJUK2GPW.js";import{k as p}from"../c-C7SUMNMI.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import"../c-PNZIJFG7.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 g={installed:!1,refused:null,sourceBytes:null,paired:0,unresolved:0,unmatchedLive:0,unmatchedSource:0,attrDiffs:0,saves:0,reprints:0,lastReprint:null,partialReprints:0,lastPartialReprint:null,lastRenderMs:null,lastBytes:null,refreshes:0,timing:{fetch:null,model:null,pair:null,refresh:null}},n=null,c=null,i=null,u=p(),s=0,r=null,a=!1,o=null;function v(){return o??=import("../c-MUM53J5J.js").catch(e=>{throw o=null,e}),o}function f(e,t,l){typeof e=="string"&&(i=Object.freeze({bytes:e,etag:t??null,seq:l??null}))}function h(){if(r)return r;let e=s,t=c;return r=v().then(l=>(n=l,e!==s?(r=null,null):l.start({context:t,latest:()=>i}))).catch(l=>(r=null,console.info("clayjs: source map off ("+(l&&l.message?l.message:l)+"); saves use the full serialization"),null)).then(l=>(e===s&&(a=!0),l)),r}function x(){return!u||a?null:h()}function m(){s++,u=!1,a=!1,r=null,c=null,n&&n.release()}d((e,t)=>{f(e,i?i.etag:null,i?i.seq:null),n&&!n.installed()&&n.adoptAccepted(e,t)});document.addEventListener("clay:sync-applied",e=>{let t=e&&e.detail;!t||t.source!=="disk"||typeof t.html!="string"||(f(t.html,t.etag,t.seq),n&&!n.installed()&&n.adoptAccepted(t.html,null))});function y(e,t,l={}){return n?n.renderSave(e,t,l):t}var A={get ready(){return u?h():null},stats:()=>n?n.stats():{...g},text:()=>n?n.text():null,locate:e=>n?n.locateLive(e):null,unpaired:()=>n?n.unpaired():null,ensureForSave:x,get repairGeneration(){return n?n.repairGeneration():0}};function L(){return{id:"clay:source",order:30,prepare(e={}){let t=e&&e.represented;if(t&&(c={represented:t},f(t.bytes,t.etag,t.seq)),e&&e.initial===!0)return u=!0,{enable(){},quiesce(){},resume(){},dispose:m};let l=++s;return u=!1,a=!1,r=null,{enable(){l===s&&(u=!0)},quiesce(){},resume(){l===s&&(u=!0)},dispose(){l===s&&m()}}}}}var R=A;export{R as default,L as modeParticipant,y as renderSave,A as source,L as sourceParticipant};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as Ze,c as Qe}from"../c-7DJDKPGL.js";import{g as re}from"../c-LO4C4J77.js";import{a as te}from"../c-WYFDLITL.js";import"../c-LA2BW7UY.js";import"../c-IJUK2GPW.js";import{k as Ge}from"../c-DLBX4JCJ.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-N7JPUPGC.js";import{a as Ye}from"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import{l as Xe}from"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var et=(()=>{var d=Object.defineProperty,f=Object.getOwnPropertyDescriptor,k=Object.getOwnPropertyNames,v=Object.prototype.hasOwnProperty,N=(e,r)=>{for(var t in r)d(e,t,{get:r[t],enumerable:!0})},W=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of k(r))!v.call(e,i)&&i!==t&&d(e,i,{get:()=>r[i],enumerable:!(n=f(r,i))||n.enumerable});return e},X=e=>W(d({},"__esModule",{value:!0}),e),C={};N(C,{default:()=>Xt,undo:()=>se});function G(e,r=null){let t=[];if(e.type==="attributes"){let n=e.target,i=e.attributeName,a=e.oldValue,l=n.getAttribute(i);return a==null&&l!=null?t.push({kind:"attr-add",target:n,name:i,newValue:l}):a!=null&&l==null?t.push({kind:"attr-remove",target:n,name:i,oldValue:a}):a!==l&&t.push({kind:"attr-set",target:n,name:i,oldValue:a,newValue:l}),t}if(e.type==="characterData")return t.push({kind:"text",target:e.target,oldValue:e.oldValue,newValue:e.target.data}),t;if(e.type==="childList"){let n=e.target,i=e.nextSibling,a=e.nextSibling;for(;a&&r?.(a);)a=a.nextSibling;let l=e.previousSibling;for(;l&&r?.(l);)l=l.previousSibling;let s=r?Array.from(e.addedNodes).filter(b=>!r(b)):Array.from(e.addedNodes),p=r?Array.from(e.removedNodes).filter(b=>!r(b)):Array.from(e.removedNodes);return s.length>0&&t.push({kind:"add",parent:n,nodes:s,before:i,afterAuthored:a,beforeAuthored:l,record:e}),p.length>0&&t.push({kind:"remove",parent:n,nodes:p,before:i,afterAuthored:a,beforeAuthored:l,record:e}),t}return t}function ut(e,r=null){let t=[],n=new Map;for(let i of e){if(i.type==="attributes"){let a=i.target,l=i.attributeName,s=n.get(a);s||(s=new Map,n.set(a,s)),s.has(l)||(s.set(l,{idx:t.length,oldValue:i.oldValue}),t.push(null));continue}for(let a of G(i,r))t.push(a)}for(let[i,a]of n)for(let[l,s]of a){let p=s.oldValue,b=i.getAttribute(l),h=null;p===b?h=null:p==null?h={kind:"attr-add",target:i,name:l,newValue:b}:b==null?h={kind:"attr-remove",target:i,name:l,oldValue:p}:h={kind:"attr-set",target:i,name:l,oldValue:p,newValue:b},t[s.idx]=h}return t.filter(i=>i!=null)}function lt(e){let r=[],t=new Map;for(let i of e){let a=ke(i);if(a==null){r.push(i);continue}let l=t.get(i.target);l||(l=new Map,t.set(i.target,l));let s=l.get(a);if(s==null){let p=Ae(i);if(p.oldValue===p.newValue)continue;l.set(a,r.length),r.push({...i,...p})}else r[s]={...r[s],newValue:Ae(i).newValue}}let n=[];for(let i of r){if(ke(i)==null){n.push(i);continue}i.oldValue!==i.newValue&&n.push(st(i))}return n}var dt=new Set(["attr-set","attr-add","attr-remove","text","value"]);function ke(e){return dt.has(e.kind)?e.kind==="text"?"#text":e.kind==="value"?`#${e.prop||"value"}`:e.name==null?null:`@${e.name}`:null}function Ae(e){return e.kind==="attr-add"?{oldValue:null,newValue:e.newValue}:e.kind==="attr-remove"?{oldValue:e.oldValue,newValue:null}:{oldValue:e.oldValue,newValue:e.newValue}}function st(e){return e.kind!=="attr-add"&&e.kind!=="attr-remove"?e:e.oldValue==null&&e.newValue!=null?{...e,kind:"attr-add"}:e.oldValue!=null&&e.newValue==null?{...e,kind:"attr-remove"}:{...e,kind:"attr-set"}}var Ve=new WeakMap,ct=0;function O(e){let r=Ve.get(e);return r||(r=`n${++ct}`,Ve.set(e,r)),r}function x(e){return!!e&&typeof e=="object"&&typeof e.nodeType=="number"}function ft(e){return e.kind==="add"||e.kind==="remove"}function Ee(e,r){let t=[],n=e.childNodes;if(!n)return t;for(let i of n)r&&r(i)||t.push(O(i));return t}function H(e,r,t=null,n=null){if(!x(e))return null;if(e.nodeType===3)return`#text:${JSON.stringify(e.data)}`;if(e.nodeType===8)return`#comment:${JSON.stringify(e.data)}`;if(e.nodeType!==1)return`#node:${e.nodeType}`;let i=[];if(e.attributes){for(let l of e.attributes)pt(l.name,e,r,t)||i.push(`${l.name}=${JSON.stringify(l.value)}`);i.sort()}let a=[];if(e.childNodes)for(let l of e.childNodes)mt(l,n)||a.push(H(l,r,t,n));return`<${String(e.tagName||"").toLowerCase()}${i.length?` ${i.join(" ")}`:""}>${a.join("")}</>`}function oe(e,r=[]){if(!x(e))return r;if(e.nodeType===1){let t=e.getAttribute&&e.getAttribute("data-id");t&&r.push(t)}if(e.childNodes)for(let t of e.childNodes)oe(t,r);return r}function pt(e,r,t,n=null){if(typeof t!="function")return!1;try{return!!t(e,r,n)}catch{return!1}}function mt(e,r){if(typeof r!="function")return!1;try{return!!r(e)}catch{return!1}}function Ne(e,r){if(typeof r!="function")return[];let t=[],n=i=>{if(!x(i))return;let a=!1;try{a=!!r(i)}catch{a=!1}if(a&&t.push(R(i,"protected")),i.childNodes)for(let l of i.childNodes)n(l)};for(let i of e)n(i);return t}function R(e,r,t=null){let n=e;n&&n.nodeType!==1&&(n=n.parentElement);let i=n&&typeof n.closest=="function"?n.closest("[data-id]"):null;return!i&&t&&typeof t.closest=="function"&&(i=t.closest("[data-id]")),{id:(i?i.getAttribute("data-id"):null)||null,kind:r||null}}function gt(e,r,t=null){return(e||[]).filter(x).map(n=>R(n,r,t))}function J(e){return{replayable:!1,reason:e,steps:[]}}function Y(e,r){let t=[[r.afterAuthored,i=>i],[r.beforeAuthored,i=>i+1],[r.before,i=>i]],n=!1;for(let[i,a]of t){if(!x(i))continue;n=!0;let l=e.indexOf(O(i));if(l>=0)return a(l)}return n?null:e.length}function ht(e,r={}){let t=r.isIgnored||null,n=r.ignoreAttribute||null,i=lt(e),a=[];for(let h of i){if(!ft(h)){if(!x(h.target))return J("non-dom-target");continue}if(!x(h.parent))return J("non-dom-parent");let A=Array.from(h.nodes||[]).filter(x);if(A.length!==0){if(A.length!==Array.from(h.nodes||[]).length)return J("non-dom-node");a.push({primitive:h,nodes:A,parent:h.parent})}}if(yt(a))return J("in-record-move");let l=wt(a,t);if(!l)return J("ambiguous-structure");let s=bt(a,l),p=new Map(a.map(h=>[h.primitive,h])),b=[];for(let h of i){let A=p.get(h);if(!A){b.push(kt(h));continue}let E=s.get(A);if(E){E.at===A&&b.push(E.step);continue}b.push(vt(A,l.get(A),n,t))}return{replayable:!0,reason:null,steps:b}}function yt(e){let r=new Map;for(let t of e){let n=t.primitive.record;if(!n)continue;let i=r.get(n);i||(i=new Map,r.set(n,i));for(let a of t.nodes){let l=i.get(a);l||(l=new Set,i.set(a,l)),l.add(t.primitive.kind)}}for(let t of r.values())for(let n of t.values())if(n.size>1)return!0;return!1}function wt(e,r){let t=new Map;for(let i of e)t.has(i.parent)||t.set(i.parent,Ee(i.parent,r));let n=new Map;for(let i=e.length-1;i>=0;i--){let a=e[i],l=t.get(a.parent);if(!l)return null;let s=l.slice(),p;if(a.primitive.kind==="add"){let b=a.nodes.map(O);if(!b.every(h=>l.includes(h)))return null;p=l.filter(h=>!b.includes(h))}else{let b=Y(s,a.primitive);if(b==null)return null;p=s.slice(),p.splice(b,0,...a.nodes.map(O))}n.set(a,{before:p,after:s}),t.set(a.parent,p)}return n}function bt(e,r){let t=new Map,n=new Map;e.forEach((a,l)=>{for(let s of a.nodes){let p=O(s);a.primitive.kind==="remove"?t.set(p,{item:a,index:l,node:s}):n.set(p,{item:a,index:l,node:s})}});let i=new Map;for(let[a,l]of t){let s=n.get(a);if(!s||s.index<l.index||l.item.nodes.length!==1||s.item.nodes.length!==1)continue;let p={type:"move",node:l.node,sourceParent:l.item.parent,destParent:s.item.parent,source:r.get(l.item),dest:r.get(s.item),sourceSlot:l.item.primitive,destSlot:s.item.primitive,targets:[R(l.node,"move")]};i.set(l.item,{step:p,at:s.item}),i.set(s.item,{step:p,at:s.item})}return i}function vt(e,r,t,n){let i=e.primitive.kind;return{type:i==="add"?"add":"restore",parent:e.parent,nodes:e.nodes,seqBefore:r.before,seqAfter:r.after,slot:e.primitive,content:e.nodes.map(a=>H(a,t,e.parent,n)),ids:i==="remove"?e.nodes.flatMap(a=>oe(a)):[],targets:gt(e.nodes,i==="add"?"added":"removed",e.parent)}}function kt(e){return{type:e.kind,primitive:e,targets:[R(e.target,e.name||e.prop||"text")]}}function At(e,r,t={}){if(!e||!e.replayable)return{ok:!1,code:"unsupported",targets:[]};let n={isIgnored:t.isIgnored||null,ignoreAttribute:t.ignoreAttribute||null,isProtected:t.isProtected||null,inScope:t.inScope||(()=>!0),liveNodesWithIds:t.liveNodesWithIds||(()=>[]),sim:new Map,planned:new Map,operations:[]};for(let i=0;i<e.steps.length;i++){let a=e.steps[r==="undo"?e.steps.length-1-i:i],l=Et(a,r,n);if(l)return{ok:!1,code:l.code,targets:l.targets}}return{ok:!0,operations:n.operations}}function q(e,r){return e.sim.has(r)||e.sim.set(r,Ee(r,e.isIgnored)),e.sim.get(r)}function L(e,r){for(let t=e;t;t=t.parentNode)if(r.planned.has(t))return r.planned.get(t);return r.inScope(e)}function xe(e,r){return r.liveNodesWithIds(e).filter(t=>L(t,r)).length>0}function V(e,r){return{code:e,targets:r||[]}}function Vt(e){return e.kind==="text"?e.target.data:e.kind==="value"?typeof e.read=="function"?e.read(e.target):e.target[e.prop||"value"]:e.target.getAttribute(e.name)}function Et(e,r,t){let n=r==="undo";return e.type==="move"?St(e,n,t):e.type==="add"?xt(e,n,t):e.type==="restore"?Pt(e,n,t):Nt(e,n,t)}function Nt(e,r,t){let n=e.primitive,i=r?n.newValue:n.oldValue,a=r?n.oldValue:n.newValue;return x(n.target)?L(n.target,t)?n.kind==="value"&&typeof n.write=="function"&&typeof n.read!="function"?V("unsupported",e.targets):Vt(n)!==i?V("content-changed",e.targets):(n.kind==="value"?t.operations.push({type:"value",target:n.target,prop:n.prop||"value",value:a,read:n.read||null,write:n.write||null}):n.kind==="text"?t.operations.push({type:"text",target:n.target,data:a}):t.operations.push({type:"attr",target:n.target,name:n.name,value:a??null}),null):V("target-detached",e.targets):V("unsupported",e.targets)}function xt(e,r,t){if(!x(e.parent)||!L(e.parent,t))return V("target-detached",e.targets);if(r){if(!$(q(t,e.parent),e.seqAfter))return V("structure-changed",e.targets);let s=Ne(e.nodes,t.isProtected);if(s.length>0)return V("protected",s);for(let p=0;p<e.nodes.length;p++)if(H(e.nodes[p],t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[p])return V("content-changed",e.targets);for(let p of e.nodes)t.operations.push({type:"remove",node:p}),t.planned.set(p,!1);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!$(q(t,e.parent),e.seqBefore))return V("structure-changed",e.targets);for(let s of e.nodes)if(s.parentNode)return V("structure-changed",e.targets);let n=e.nodes.flatMap(s=>oe(s));if(n.length>0&&xe(n,t))return V("duplicate-id",e.targets);let i=Y(e.seqBefore,e.slot);if(i==null)return V("unsupported",e.targets);let a=e.seqBefore.slice(),l=i;for(let s of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:s,beforeId:a[l]??null}),a=a.slice(0,l).concat(O(s),a.slice(l)),l+=1,t.planned.set(s,!0);return t.sim.set(e.parent,e.seqAfter.slice()),null}function Pt(e,r,t){if(!x(e.parent)||!L(e.parent,t))return V("target-detached",e.targets);if(r){if(!$(q(t,e.parent),e.seqAfter))return V("structure-changed",e.targets);for(let p=0;p<e.nodes.length;p++){let b=e.nodes[p];if(b.parentNode||H(b,t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[p])return V("content-changed",e.targets)}if(e.ids.length>0&&xe(e.ids,t))return V("duplicate-id",e.targets);let a=Y(e.seqAfter,e.slot);if(a==null)return V("unsupported",e.targets);let l=e.seqAfter.slice(),s=a;for(let p of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:p,beforeId:l[s]??null}),l=l.slice(0,s).concat(O(p),l.slice(s)),s+=1,t.planned.set(p,!0);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!$(q(t,e.parent),e.seqBefore))return V("structure-changed",e.targets);let n=Ne(e.nodes,t.isProtected);if(n.length>0)return V("protected",n);let i=a=>t.planned.get(a)===!0||typeof t.isIgnored=="function"&&t.isIgnored(a);for(let a=0;a<e.nodes.length;a++){let l=e.nodes[a];if(l.parentNode!==e.parent||H(l,t.ignoreAttribute,e.parent,i)!==e.content[a])return V("content-changed",e.targets)}for(let a of e.nodes)t.operations.push({type:"remove",node:a}),t.planned.set(a,!1);return t.sim.set(e.parent,e.seqAfter.slice()),null}function It(e,r){let t=e.indexOf(r);return t<0?null:e.slice(0,t).concat(e.slice(t+1))}function St(e,r,t){let n=O(e.node),i=r?e.destParent:e.sourceParent,a=r?e.sourceParent:e.destParent,l=q(t,i),s=q(t,a),p=r?e.dest.after:e.source.before,b=r?e.source.after:e.dest.before,h=r?e.sourceSlot:e.destSlot;if(!x(i)||!x(a)||!L(i,t)||!L(a,t))return V("target-detached",e.targets);if(!$(l,p))return V("structure-changed",e.targets);let A=i===a?It(s,n):s;if(!$(A,b))return V("structure-changed",e.targets);let E=Y(b,h);return E==null?V("unsupported",e.targets):(t.operations.push({type:"insert",parent:a,node:e.node,beforeId:b[E]??null}),t.planned.set(e.node,!0),r?(t.sim.set(a,e.source.before.slice()),i!==a&&t.sim.set(i,e.dest.before.slice())):(t.sim.set(a,e.dest.after.slice()),i!==a&&t.sim.set(i,e.source.after.slice())),null)}function $(e,r){if(!e||!r||e.length!==r.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==r[t])return!1;return!0}function Rt(e,r){for(let t of e.childNodes||[])if(O(t)===r)return t;return null}function Pe(e,r){typeof e.write=="function"?e.write(e.target,r):e.target[e.prop]=r}function Ct(e){let r=[];try{for(let t of e)Ot(t,r);return{ok:!0}}catch(t){for(let n=r.length-1;n>=0;n--)try{r[n]()}catch{}return{ok:!1,error:t}}}function Ot(e,r){if(e.type==="attr"){let t=e.target.getAttribute(e.name);e.value==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,e.value),r.push(()=>{t==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,t)});return}if(e.type==="text"){let t=e.target.data;e.target.data=e.data,r.push(()=>{e.target.data=t});return}if(e.type==="value"){let t=typeof e.read=="function"?e.read(e.target):e.target[e.prop];Pe(e,e.value),r.push(()=>Pe(e,t));return}if(e.type==="insert"){let t=e.beforeId==null?null:Rt(e.parent,e.beforeId);if(e.beforeId!=null&&!t)throw new Error("hyper-undo: replay anchor vanished");let n=e.node.parentNode,i=e.node.nextSibling;e.parent.insertBefore(e.node,t),r.push(()=>{n?n.insertBefore(e.node,i&&i.parentNode===n?i:null):e.node.parentNode===e.parent&&e.parent.removeChild(e.node)});return}if(e.type==="remove"){let t=e.node.parentNode;if(!t)throw new Error("hyper-undo: replay target is no longer attached");let n=e.node.nextSibling;t.removeChild(e.node),r.push(()=>t.insertBefore(e.node,n))}}var Mt=['[src^="chrome-extension://"]','[href^="chrome-extension://"]','[src^="moz-extension://"]','[href^="moz-extension://"]','[src^="safari-web-extension://"]','[href^="safari-web-extension://"]','[id="1p-menu-live-region"]',"com-1password-button","com-1password-menu","com-1password-notification","grammarly-extension","grammarly-desktop-integration","lt-div","lt-card","lt-toolbar","lt-highlighter","[data-lastpass-root]","[data-lastpass-icon-root]","[data-dashlane-shadowhost]","[data-klarna-extension]",'[class*="klarna-extension"]',".skiptranslate","#goog-gt-tt",".goog-te-banner-frame",".goog-te-balloon-frame","style.darkreader","style[data-darkreader-mode]","style[data-darkreader-scheme]","#loom-companion-mv3","loom-container","[ext-id]"],Tt=["data-grammarly","data-lt","data-1p","data-com-onepassword","data-lastpass","data-lp","data-kwimpala","data-bitwarden","data-bw","data-dashlane","data-np","data-protonpass","data-proton-pass","data-keeper","data-rf","data-roboform","data-honey","data-rakuten","data-capital-one","data-wikibuy","data-klarna","data-darkreader","data-evernote","data-pocket","data-pin"],jt=Mt.join(","),qt=new RegExp("^(?:"+Tt.join("|")+")(?:-|$)"),zr=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Lt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),$t=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function ie(e,r){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(r)||e.hasAttribute?.(r))}function Ie(e,r){if(ie(e,r))return!0;for(let[t,n]of Object.entries(Lt))if(n.includes(r)&&ie(e,t))return!0;return!1}function Kt(e){return e==="clay"||$t.includes(e)}var zt=["mutations-ignore","save-remove","save-ignore","save-freeze","no-undo","no-watch"];function Dt(){if(typeof window>"u")return null;let e=window.clay?.region||window.hyperclay?.region;return e&&typeof e.resolveRegionPolicy=="function"?e.resolveRegionPolicy:null}function ae(e){let r=Dt();if(r)try{if(!r(e).undoable)return!0}catch{}let t=e&&e.nodeType!==1?e.parentElement:e;if(t&&t.closest&&t.closest(jt))return!0;for(;t&&t.nodeType===1;){if(Ie(t,"no-undo")||Ie(t,"no-watch"))return!0;for(let n of zt)if(ie(t,n))return!0;t=t.parentElement}return!1}function _t(e){let r=e.target,t=r.cloneNode(!1),n=t;for(;r.parentElement;){r=r.parentElement;let i=r.cloneNode(!1);i.appendChild(t),t=i}return e.oldValue==null?n.removeAttribute(e.attributeName):n.setAttribute(e.attributeName,e.oldValue),ae(n)}function ue(e,r,t){if(t?.type==="attributes"&&Kt(t.attributeName)){if(ae(e)&&_t(t))return!0}else if(ae(e))return!0;if(t&&t.type==="attributes"){if(t.attributeName&&qt.test(t.attributeName.toLowerCase()))return!0;if(r)try{if(r(t.attributeName,t.target))return!0}catch{}}return!1}function Ut(){let e=new Map;function r(i,a){let l=e.get(i);return l||(l=new Set,e.set(i,l)),l.add(a),()=>t(i,a)}function t(i,a){let l=e.get(i);l&&l.delete(a)}function n(i,a){let l=e.get(i);if(l)for(let s of Array.from(l))try{s(a)}catch(p){console.error("[hyper-undo] listener threw",p)}}return{on:r,off:t,emit:n}}var Bt={maxHistory:100,idleWindowMs:500,idleLabel:"Edit",recording:"automatic",ignoreAttribute:null,isProtected:null,ignoreNode:null,debug:!1};function Se(e){let r={...Bt,...e};if(!r.scope)throw new Error("hyper-undo: scope is required");let t=Ut(),n=[],i=[],a=`u${Math.random().toString(36).slice(2,8)}`,l=0,s=null,p=[],b=null,h=null,A=0,E=!1,K=r.recording==="commands"?"commands":"automatic",I=null,z=!1;function P(...o){r.debug&&console.log("[hyper-undo]",...o)}function Gt(){E||(E=!0,h=Yt(D),h.observe(r.scope,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),P("started"))}function Yt(o){let u=typeof document<"u"&&r.scope===document.body,c=typeof window<"u"&&(window.clay?.Mutation||window.hyperclay?.Mutation)||null;return u&&c&&typeof c.createObserver=="function"?(P("sourcing records from the platform Mutation hub (shared observer)"),c.createObserver(o)):new MutationObserver(o)}function Me(){E&&(E=!1,h&&(h.disconnect(),h=null),_(),n.length=0,i.length=0,p=[],s=null,I=null,z=!1,A=0,P("stopped"))}function Zt(){let o=r.scope;return!!(o&&o.nodeType===1&&o.isConnected===!1)}function D(o){Te(o,!1)}function Te(o,u){if(I){for(let m of o)I.records.push(m);return}if(K==="commands"||A>0)return;let c=ce(Qt(o),u);if(c.length>0){for(let m of c)p.push(m);je()}}function Qt(o){return typeof r.ignoreNode!="function"?o:o.filter(u=>{if(u.type!=="childList")return!0;let c=[...u.addedNodes,...u.removedNodes];return c.length===0?!0:!c.every(m=>er(m))})}function er(o){try{return!!r.ignoreNode(o)}catch{return!1}}function ce(o,u=!1){let c=yr(o),m=o.filter(y=>(ge(y.target)||c(y.target)||u&&Fe(y.target))&&!ue(y.target,r.ignoreAttribute,y));return ut(m,y=>ue(y,r.ignoreAttribute))}function je(){_(),b=setTimeout(qe,r.idleWindowMs)}function _(){b!=null&&(clearTimeout(b),b=null)}function qe(){if(b=null,p.length===0)return;let o=p;p=[],Z(r.idleLabel,o)}function Z(o,u){let c=ht(u,{isIgnored:fe,ignoreAttribute:Le});if(c.steps.length===0)return P("commit",o,"with nothing to record"),t.emit("commit"),null;let m={id:`${a}-${++l}`,label:o,timestamp:Date.now(),primitives:u,certificate:c};for(n.push(m),i.length=0,s=null;n.length>r.maxHistory;)n.shift();return P("commit",o,"primitives:",u.length),t.emit("commit"),m}function fe(o){return ue(o,r.ignoreAttribute)}function Le(o,u,c=null){if(typeof r.ignoreAttribute!="function")return!1;try{return!!r.ignoreAttribute(o,u,c)}catch{return!1}}function tr(o){if(typeof r.isProtected!="function")return!1;try{return!!r.isProtected(o)}catch{return!1}}function rr(o,u){if(!E)throw new Error("hyper-undo: scope not started");if(K==="commands")return ze(o,u,{honorPause:!0,receipt:!1});D(h.takeRecords()),U();let c=A===0?$e():null,m=u();if(m&&typeof m.then=="function")throw new Error("hyper-undo: commit() fn must be synchronous; returned a Promise");if(Te(h.takeRecords(),!0),c!=null&&Ke(c),p.length===0){t.emit("commit");return}_();let y=p;p=[],Z(o,y)}function nr(o){if(!E)throw new Error("hyper-undo: scope not started");if(!h)return;if(A>1){h.takeRecords();return}U();let u=ce(h.takeRecords(),!0);u.length!==0&&(_(),Z(o,u))}function or(){h&&h.takeRecords()}function pe(){let o=r.scope;return o&&o.ownerDocument||(typeof document<"u"?document:null)}function Q(){let o=pe();return!o||!o.head||typeof o.head.querySelector!="function"?null:o.head.querySelector("title")}function $e(){let o=Q();return o?o.textContent:null}function Ke(o){let u=Q();if(!u||o==null)return;let c=u.textContent;c!==o&&_e({kind:"value",target:u,prop:"textContent",oldValue:o,newValue:c})}function ir(o){if(!o)return null;let u=pe();if(!u||o.target!==u||o.prop!=="title")return o;let c=Q();return c?{kind:"value",target:c,prop:"textContent",oldValue:o.oldValue,newValue:o.newValue}:null}function ar(){if(typeof window>"u")return!1;let o=window.clay?.effect||window.hyperclay?.effect;return!!(o&&o.running)}function ur(){h&&D(h.takeRecords()),U(),I={records:[],primitives:[]}}function lr(){let o=I;if(I=null,!o)return[];let u=ce(o.records,!0);for(let c of o.primitives)u.push(c);return u}function ze(o,u,{honorPause:c,receipt:m}){if(typeof u!="function")throw new Error("hyper-undo: command() needs a synchronous function");if(I)throw new Error("hyper-undo: command() cannot nest inside another command");if(z)throw new Error("hyper-undo: command() cannot run during undo or redo");if(ar())throw new Error("hyper-undo: command() cannot run inside a derived-effect context");if(u.constructor&&u.constructor.name==="AsyncFunction")throw new Error("hyper-undo: command() fn must be synchronous; it was declared async");let y=c&&A>0,S=y?null:$e();ur();let M=[],j=null,B;try{try{B=u()}catch(kr){j=kr}if(h&&D(h.takeRecords()),B&&typeof B.then=="function"){try{B.then(void 0,()=>{})}catch{}j||(j=new Error("hyper-undo: command() fn must be synchronous; returned a Promise"))}y||Ke(S)}finally{M=lr()}let ee=y||M.length===0?null:Z(o,M);if(j)throw j;return m?ee?{id:ee.id,label:ee.label}:null:ee}function dr(o,u){if(!E)throw new Error("hyper-undo: scope not started");return ze(o,u,{honorPause:!1,receipt:!0})}function sr(o){if(o!=="automatic"&&o!=="commands")throw new Error("hyper-undo: setRecording() takes 'automatic' or 'commands'");if(I)throw new Error("hyper-undo: setRecording() cannot change while a command is running");return K===o||(U(),K=o,P("recording",o)),K}function De(o){if(!E||!o||!I&&(A>0||K==="commands"))return;let u=ir(o);u&&_e(u)}function _e(o){if(I){I.primitives.push(o);return}p.push(o),je()}function cr(o,{prop:u="value",oldValue:c,newValue:m,read:y,write:S}={}){!o||c===m||De({kind:"value",target:o,prop:u,oldValue:c,newValue:m,read:y,write:S})}function U(){A===0&&h&&D(h.takeRecords()),p.length!==0&&(_(),qe())}function Ue(){A===0&&h&&D(h.takeRecords()),A++,P("paused",A)}function Be(){A!==0&&(A--,A===0&&h&&h.takeRecords(),P("resumed",A))}function We(o,u){if(Zt())return Me(),{ok:!1,code:"disconnected"};U();let c=o==="undo"?n:i,m=o==="undo"?i:n,y=c.at(-1);if(!y)return{ok:!1,code:"empty"};if(u&&u!==y.id){let B=He(u)||y;return me(B,o,"stale-entry")}let S;z=!0;try{S=At(y.certificate,o,{isIgnored:fe,ignoreAttribute:Le,isProtected:tr,inScope:wr,liveNodesWithIds:br})}finally{z=!1}if(!S.ok)return me(y,o,S.code,S.targets);Ue();let M;z=!0;try{M=Ct(S.operations)}finally{z=!1,Be()}if(!M.ok)return P(`${o} failed and was rolled back`,M.error),me(y,o,"replay-error");c.pop(),m.push(y),s=null;let j={ok:!0,entryId:y.id,label:y.label,direction:o};return P(o,y.label),t.emit(o,j),j}function fr(o){return We("undo",o&&o.entryId)}function pr(o){return We("redo",o&&o.entryId)}function He(o){return n.find(u=>u.id===o)||i.find(u=>u.id===o)||null}function me(o,u,c,m=[]){return s={entryId:o.id,direction:u,code:c,targets:m},P("refused",u,c),t.emit("refused",{entryId:o.id,label:o.label,direction:u,code:c,targets:m}),{ok:!1,code:c,entryId:o.id,label:o.label,direction:u}}function mr(o){if(!s||s.entryId!==o)return{ok:!1,code:"not-refused",entryId:o};let u=s.direction,c=u==="undo"?n:i,m=c.at(-1);return!m||m.id!==o?{ok:!1,code:"stale-entry",entryId:o}:(c.pop(),s=null,P("discarded",m.label),t.emit("discard",{entryId:o,label:m.label,direction:u}),{ok:!0,entryId:o,direction:u})}function gr(o){let u=He(o);if(!u||!u.certificate||!u.certificate.replayable)return null;let c=s&&s.entryId===u.id?{direction:s.direction,code:s.code,targets:(s.targets||[]).map(m=>({id:m.id??null,kind:m.kind??null}))}:null;return{id:u.id,label:u.label,timestamp:u.timestamp,refused:c,steps:u.certificate.steps.map(hr)}}function hr(o){if(o.type==="move")return{kind:"move",node:{id:R(o.node).id},from:{id:R(o.sourceParent).id},to:{id:R(o.destParent).id}};if(o.type==="add"||o.type==="restore")return{kind:o.type==="add"?"add":"remove",parent:{id:R(o.parent).id},nodes:o.nodes.map((S,M)=>({id:R(S).id,html:o.content[M]??null}))};let u=o.primitive,c={id:R(u.target).id},m=u.oldValue??null,y=u.newValue??null;return o.type==="value"?{kind:"value",target:c,prop:u.prop??"value",before:m,after:y}:o.type==="text"?{kind:"text",target:c,before:m,after:y}:o.type==="attr-set"||o.type==="attr-add"||o.type==="attr-remove"?{kind:"attribute",target:c,name:u.name??null,before:m,after:y}:{kind:o.type,target:c,before:m,after:y}}function yr(o){let u=new Set,c=!0;for(;c;){c=!1;for(let m of o)if(!(m.type!=="childList"||!m.removedNodes?.length)&&!(!ge(m.target)&&!Je(m.target,u)))for(let y of m.removedNodes)u.has(y)||(u.add(y),c=!0)}return m=>!ge(m)&&Je(m,u)}function Je(o,u){for(let c=o;c;c=c.parentNode)if(u.has(c))return!0;return!1}function ge(o){let u=r.scope;return!u||!o?!1:o===u||typeof u.contains=="function"&&u.contains(o)}function Fe(o){let u=pe(),c=u&&u.head;if(!c||!o)return!1;let m=o.nodeType===1?o:o.parentElement;for(;m&&m!==c;m=m.parentElement)if(m.localName==="title")return!1;return m===c}function wr(o){let u=r.scope;return!o||!u?!1:o===u||Q()===o||Fe(o)?!0:typeof u.contains=="function"?u.contains(o):!1}function br(o){let u=r.scope;if(!o||o.length===0||typeof u?.querySelectorAll!="function")return[];let c=new Set(o),m=[];for(let y of u.querySelectorAll("[data-id]"))c.has(y.getAttribute("data-id"))&&(fe(y)||m.push(y));return m}function vr(){h&&h.takeRecords(),n.length=0,i.length=0,p=[],s=null,_(),P("cleared"),t.emit("clear")}return{_config:r,start:Gt,stop:Me,commit:rr,commitCaptured:nr,discardCaptured:or,flush:U,command:dr,setRecording:sr,record:De,recordValue:cr,undo:fr,redo:pr,clear:vr,discard:mr,describe:gr,pause:Ue,resume:Be,on:t.on,off:t.off,get canUndo(){return n.length>0},get canRedo(){return i.length>0},get isPaused(){return A>0},get history(){return n.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return s&&s.entryId===o.id&&(u.refused={direction:s.direction,code:s.code,targets:s.targets}),u})},get future(){return i.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return s&&s.entryId===o.id&&(u.refused={direction:s.direction,code:s.code,targets:s.targets}),u}).reverse()},get scope(){return r.scope}}}var Wt=new Set(["checkbox","radio","button","submit","reset","image","file","range","color"]);function Ht(e){let r=typeof e.composedPath=="function"?e.composedPath():[],t=r.length>0?r:Jt(e.target);for(let n of t){if(!n||n.nodeType!==1)continue;let i=String(n.tagName||"").toUpperCase();if(i==="TEXTAREA"||i==="SELECT"||i==="INPUT"&&!Wt.has(String(n.type||n.getAttribute?.("type")||"text").toLowerCase())||n.isContentEditable===!0)return!0;let a=n.getAttribute&&n.getAttribute("contenteditable");if(a!=null&&String(a).toLowerCase()!=="false")return!0}return!1}function Jt(e){let r=[];for(let t=e;t;t=t.parentNode||(t.host??null))r.push(t);return r}function Ft(e,r){let t=n=>{let i=e.scope;if(i&&i.nodeType===1&&i.isConnected===!1){r&&r();return}if(n.defaultPrevented||n.isComposing||n.keyCode===229||Ht(n))return;let a=n.target,l=e._config.shadowKeydownIn;if(a&&a.closest&&Array.isArray(l))for(let p of l)try{if(a.closest(p))return}catch{}if(!(n.metaKey||n.ctrlKey))return;let s=(n.key||"").toLowerCase();if(s==="z"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),e.undo();return}if(s==="z"&&n.shiftKey){n.preventDefault(),n.stopPropagation(),e.redo();return}if(s==="y"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),e.redo();return}};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)}var le=[".CodeMirror",".cm-editor",".monaco-editor",".ace_editor",".ql-editor",".tiptap",".ProseMirror",".overtype-input","[data-richclay-active]"],g=null,de=null,Re=null,T=null;function Ce(e,r){if(T){if(T.inst===e)return T.cleanup;throw new Error("hyper-undo: another scope already owns the global Cmd+Z binding (bindKeys: true). Stop it first, or use bindKeys: false for additional scopes.")}let t=Ft(e,r);return T={inst:e,cleanup:t},t}function Oe(e){T&&T.inst===e&&(T.cleanup(),T=null)}var se={defaults:{shadowKeydownIn:le},start(e={}){let r=e.scope||(typeof document<"u"?document.body:null);if(!r)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");if(g){if(de===r)return console.warn("[hyper-undo] start() called again on existing singleton; ignoring new options"),g;throw new Error("hyper-undo: start() called with a different scope while the singleton is already started. Use undo.create({ scope }) for additional scopes, or call undo.stop() first.")}let t={...e,scope:r,shadowKeydownIn:e.shadowKeydownIn||le};return g=Se(t),g.start(),de=r,e.bindKeys!==!1&&(Re=Ce(g,()=>se.stop())),g},stop(){g&&(Oe(g),Re=null,g.stop(),g=null,de=null)},create(e={}){let r=e.scope||(typeof document<"u"?document.body:null);if(!r)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");let t={...e,scope:r,shadowKeydownIn:e.shadowKeydownIn||le},n=Se(t),i=null,a={_config:n._config,commit:n.commit,command:n.command,setRecording:n.setRecording,commitCaptured:n.commitCaptured,discardCaptured:n.discardCaptured,flush:n.flush,record:n.record,recordValue:n.recordValue,undo:n.undo,redo:n.redo,clear:n.clear,discard:n.discard,describe:n.describe,pause:n.pause,resume:n.resume,on:n.on,off:n.off,get canUndo(){return n.canUndo},get canRedo(){return n.canRedo},get isPaused(){return n.isPaused},get history(){return n.history},get future(){return n.future},get scope(){return n.scope},start(){e.bindKeys&&(i=Ce(n,()=>a.stop())),n.start()},stop(){Oe(n),i=null,n.stop()}};return a},commit(e,r){return g?g.commit(e,r):void 0},command(e,r){return g?g.command(e,r):void 0},setRecording(e){return g?g.setRecording(e):void 0},commitCaptured(e){return g?g.commitCaptured(e):void 0},discardCaptured(){return g?g.discardCaptured():void 0},record(e){return g?g.record(e):void 0},recordValue(e,r){return g?g.recordValue(e,r):void 0},undo(e){return g?g.undo(e):void 0},redo(e){return g?g.redo(e):void 0},clear(){return g?g.clear():void 0},discard(e){return g?g.discard(e):void 0},describe(e){return g?g.describe(e):void 0},pause(){return g?g.pause():void 0},resume(){return g?g.resume():void 0},flush(){return g?g.flush():void 0},on(e,r){return g?g.on(e,r):void 0},off(e,r){return g?g.off(e,r):void 0},get canUndo(){return g?g.canUndo:!1},get canRedo(){return g?g.canRedo:!1},get history(){return g?g.history:[]},get future(){return g?g.future:[]},get isPaused(){return g?g.isPaused:!1}},Xt=se;return X(C)})();window.__hyperclayNoAutoExport||(window.hyperclay=window.hyperclay||{},window.hyperclay.undo=et.undo,window.h=window.hyperclay);var w=et.undo;var ye=new Set,it=(d={})=>{let f=d.ignoreAttribute;return{...d,ignoreAttribute:(k,v,N)=>ye.has(k)||Xe(k,v)||Ye(v,k,N)||Ze(k,v)||(f?f(k,v,N):!1),isProtected:d.isProtected||Ar,ignoreNode:d.ignoreNode||Qe}};function Ar(d){let f=window.clay?.region?.resolveRegionPolicy;if(!f||d.nodeType!==1)return!1;let k=f(d);if(k.undoable!==!1||k.persist==="none")return!1;let v=d.parentElement;return!v||f(v).undoable!==!1}var Vr=w.create.bind(w);w.create=d=>Vr(it(d));var we=null,Er=w.setRecording.bind(w);w.setRecording=d=>(we=d??null,Er(d));var tt=()=>w.history.at(-1)?.id??null,Nr=w.command.bind(w);w.command=(d,f)=>{let k=Nr(d,f);return k&&re(),k};var xr=w.commit.bind(w),rt=!1;w.commit=(d,f)=>{!rt&&window.clay?.effect?.running&&(rt=!0,console.warn(`clay.effect: undo.commit("${d}") was called inside an effect. Run commands from event handlers, not from an effect.`));let k=tt(),v=xr(d,f);return(v||tt()!==k)&&re(),v};var Pr=`input${te}:not([type="password"]):not([type="hidden"]):not([type="file"]), textarea${te}, select${te}`;function Ir(){let d=f=>window.clay?.region?.resolveRegionPolicy?.(f)?.undoable!==!1;document.querySelectorAll(Pr).forEach(f=>{if(!d(f))return;if(f.tagName==="SELECT"){for(let C of f.options){let G=C.hasAttribute("selected");C.selected!==G&&(C.selected=G)}return}let k=(f.getAttribute("type")||"text").toLowerCase();if(f.tagName==="INPUT"&&(k==="checkbox"||k==="radio")){let C=f.hasAttribute("checked");f.checked!==C&&(f.checked=C);return}let v=f.tagName==="TEXTAREA"?f.getAttribute("data-value")??f.textContent:f.getAttribute("value")??"";if(f.value===v)return;let N=f===document.activeElement,W,X;try{W=f.selectionStart,X=f.selectionEnd}catch{}if(f.value=v,N&&W!=null)try{f.setSelectionRange(Math.min(W,v.length),Math.min(X,v.length))}catch{}})}var nt=d=>{d?.ok&&(re(),Ir())},ot=({entryId:d,label:f,direction:k,code:v})=>{document.dispatchEvent(new CustomEvent("clay:undo-refused",{detail:{ok:!1,code:v,entryId:d,label:f,direction:k}})),Sr({ok:!1,code:v,entryId:d,label:f,direction:k})},he=null;function at(){return he??=import("../c-O5ARALMJ.js").catch(d=>(he=null,console.error("clayjs: the undo recovery module could not be downloaded; a refused step stays in this tab only",d),null)),he}async function Sr(d){let f={ok:!1,code:"unavailable"};try{let v=await at();v&&(f=await v.keepRefusal(w,d))}catch{f={ok:!1,code:"error"}}let k=f?.ok===!0?{ok:!0,entryId:d.entryId,direction:d.direction}:{ok:!1,code:f?.code||"error",entryId:d.entryId,direction:d.direction};document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:k}))}var ve=(d,f)=>(...k)=>at().then(v=>v?v[d](...k):f,()=>f),Rr=ve("keep",{ok:!1,code:"unavailable"});w.ignoreAttribute=d=>{let f=String(d||"");return f?(ye.add(f),()=>{ye.delete(f)}):()=>{}};w.keep=async d=>{let f=await Rr(d);return f?.ok===!0&&document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:{ok:!0,key:d?.key==null?null:`app:${d.key}`}})),f};w.kept=ve("kept",{ok:!1,code:"unavailable",records:[]});w.dismissKept=ve("dismissKept",{ok:!1,code:"unavailable"});var be=new Set;w.reviewActions=d=>typeof d!="function"?()=>{}:(be.add(d),()=>{be.delete(d)});w.reviewActionsFor=d=>{let f=[];for(let k of be){let v;try{v=k(d)}catch(N){console.error("clayjs: a review action could not describe itself; the copy stays reviewable",N);continue}for(let N of Array.isArray(v)?v:[])N&&typeof N.run=="function"&&N.label&&f.push(N)}return f};var Cr=["commit","undo","redo","refused","discard","clear"],ne=()=>{let d=!!F?.started;document.dispatchEvent(new CustomEvent("clay:undo-change",{detail:{canUndo:d&&w.canUndo,canRedo:d&&w.canRedo,undo:d&&w.history.at(-1)||null,redo:d&&w.future?.[0]||null}}))},F=null;function Or(){return{started:!1,admitted:!1,subscriptions:[]}}var Mr=d=>d?d.signal?.aborted?!0:typeof d.isCurrent=="function"&&!d.isCurrent():!1;function Tr(){return typeof document>"u"||document.readyState!=="loading"?Promise.resolve():new Promise(d=>document.addEventListener("DOMContentLoaded",d,{once:!0}))}function jr(d){return{enable(){if(!d.started){d.started=!0,d.admitted=!0,w.start(it({bindKeys:!0,...we?{recording:we}:{}}));for(let f of["undo","redo"])w.on(f,nt),d.subscriptions.push({type:f,handler:nt});w.on("refused",ot),d.subscriptions.push({type:"refused",handler:ot});for(let f of Cr)w.on(f,ne),d.subscriptions.push({type:f,handler:ne});ne()}},quiesce(){d.admitted&&(d.admitted=!1,w.pause())},resume(){d.admitted||(d.admitted=!0,w.resume())},dispose(){if(d.admitted=!1,F===d&&(F=null),!!d.started){d.started=!1;for(let{type:f,handler:k}of d.subscriptions.splice(0))w.off(f,k);w.stop(),ne()}}}}function qr(){return{id:"clay:undo",order:350,async prepare(d={}){if(d.initial===!0)return Lr();if(await Tr(),Mr(d))throw Object.assign(new Error("clay:undo prepared for a stale generation"),{code:"stale-document"});return jr(F||(F=Or()))}}}async function Lr(){let d=await Kr;return{enable(){},quiesce:()=>d?.quiesce(),resume:()=>d?.resume(),dispose:()=>d?.dispose()}}async function $r(){if(!Ge()||typeof document>"u")return null;let d=await qr().prepare();return d.enable(),d}var Kr=$r();var Gr=w;export{Gr as default,$r as init,qr as modeParticipant,Kr as ready,Ir as restoreControls,w as undo,qr as undoParticipant};
|
|
1
|
+
import{b as Ze,c as Qe}from"../c-7DJDKPGL.js";import{g as re}from"../c-P73XPAOA.js";import{a as te}from"../c-WYFDLITL.js";import"../c-MZCOGNZL.js";import"../c-IJUK2GPW.js";import{k as Ge}from"../c-C7SUMNMI.js";import"../c-BPF2NSPV.js";import"../c-P7KNDG34.js";import"../c-CYWLPPUS.js";import"../c-U4TWEIKZ.js";import{a as Ye}from"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import{l as Xe}from"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";var et=(()=>{var d=Object.defineProperty,f=Object.getOwnPropertyDescriptor,k=Object.getOwnPropertyNames,v=Object.prototype.hasOwnProperty,N=(e,r)=>{for(var t in r)d(e,t,{get:r[t],enumerable:!0})},W=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of k(r))!v.call(e,i)&&i!==t&&d(e,i,{get:()=>r[i],enumerable:!(n=f(r,i))||n.enumerable});return e},X=e=>W(d({},"__esModule",{value:!0}),e),C={};N(C,{default:()=>Xt,undo:()=>se});function G(e,r=null){let t=[];if(e.type==="attributes"){let n=e.target,i=e.attributeName,a=e.oldValue,l=n.getAttribute(i);return a==null&&l!=null?t.push({kind:"attr-add",target:n,name:i,newValue:l}):a!=null&&l==null?t.push({kind:"attr-remove",target:n,name:i,oldValue:a}):a!==l&&t.push({kind:"attr-set",target:n,name:i,oldValue:a,newValue:l}),t}if(e.type==="characterData")return t.push({kind:"text",target:e.target,oldValue:e.oldValue,newValue:e.target.data}),t;if(e.type==="childList"){let n=e.target,i=e.nextSibling,a=e.nextSibling;for(;a&&r?.(a);)a=a.nextSibling;let l=e.previousSibling;for(;l&&r?.(l);)l=l.previousSibling;let s=r?Array.from(e.addedNodes).filter(b=>!r(b)):Array.from(e.addedNodes),p=r?Array.from(e.removedNodes).filter(b=>!r(b)):Array.from(e.removedNodes);return s.length>0&&t.push({kind:"add",parent:n,nodes:s,before:i,afterAuthored:a,beforeAuthored:l,record:e}),p.length>0&&t.push({kind:"remove",parent:n,nodes:p,before:i,afterAuthored:a,beforeAuthored:l,record:e}),t}return t}function ut(e,r=null){let t=[],n=new Map;for(let i of e){if(i.type==="attributes"){let a=i.target,l=i.attributeName,s=n.get(a);s||(s=new Map,n.set(a,s)),s.has(l)||(s.set(l,{idx:t.length,oldValue:i.oldValue}),t.push(null));continue}for(let a of G(i,r))t.push(a)}for(let[i,a]of n)for(let[l,s]of a){let p=s.oldValue,b=i.getAttribute(l),h=null;p===b?h=null:p==null?h={kind:"attr-add",target:i,name:l,newValue:b}:b==null?h={kind:"attr-remove",target:i,name:l,oldValue:p}:h={kind:"attr-set",target:i,name:l,oldValue:p,newValue:b},t[s.idx]=h}return t.filter(i=>i!=null)}function lt(e){let r=[],t=new Map;for(let i of e){let a=ke(i);if(a==null){r.push(i);continue}let l=t.get(i.target);l||(l=new Map,t.set(i.target,l));let s=l.get(a);if(s==null){let p=Ae(i);if(p.oldValue===p.newValue)continue;l.set(a,r.length),r.push({...i,...p})}else r[s]={...r[s],newValue:Ae(i).newValue}}let n=[];for(let i of r){if(ke(i)==null){n.push(i);continue}i.oldValue!==i.newValue&&n.push(st(i))}return n}var dt=new Set(["attr-set","attr-add","attr-remove","text","value"]);function ke(e){return dt.has(e.kind)?e.kind==="text"?"#text":e.kind==="value"?`#${e.prop||"value"}`:e.name==null?null:`@${e.name}`:null}function Ae(e){return e.kind==="attr-add"?{oldValue:null,newValue:e.newValue}:e.kind==="attr-remove"?{oldValue:e.oldValue,newValue:null}:{oldValue:e.oldValue,newValue:e.newValue}}function st(e){return e.kind!=="attr-add"&&e.kind!=="attr-remove"?e:e.oldValue==null&&e.newValue!=null?{...e,kind:"attr-add"}:e.oldValue!=null&&e.newValue==null?{...e,kind:"attr-remove"}:{...e,kind:"attr-set"}}var Ve=new WeakMap,ct=0;function O(e){let r=Ve.get(e);return r||(r=`n${++ct}`,Ve.set(e,r)),r}function x(e){return!!e&&typeof e=="object"&&typeof e.nodeType=="number"}function ft(e){return e.kind==="add"||e.kind==="remove"}function Ee(e,r){let t=[],n=e.childNodes;if(!n)return t;for(let i of n)r&&r(i)||t.push(O(i));return t}function H(e,r,t=null,n=null){if(!x(e))return null;if(e.nodeType===3)return`#text:${JSON.stringify(e.data)}`;if(e.nodeType===8)return`#comment:${JSON.stringify(e.data)}`;if(e.nodeType!==1)return`#node:${e.nodeType}`;let i=[];if(e.attributes){for(let l of e.attributes)pt(l.name,e,r,t)||i.push(`${l.name}=${JSON.stringify(l.value)}`);i.sort()}let a=[];if(e.childNodes)for(let l of e.childNodes)mt(l,n)||a.push(H(l,r,t,n));return`<${String(e.tagName||"").toLowerCase()}${i.length?` ${i.join(" ")}`:""}>${a.join("")}</>`}function oe(e,r=[]){if(!x(e))return r;if(e.nodeType===1){let t=e.getAttribute&&e.getAttribute("data-id");t&&r.push(t)}if(e.childNodes)for(let t of e.childNodes)oe(t,r);return r}function pt(e,r,t,n=null){if(typeof t!="function")return!1;try{return!!t(e,r,n)}catch{return!1}}function mt(e,r){if(typeof r!="function")return!1;try{return!!r(e)}catch{return!1}}function Ne(e,r){if(typeof r!="function")return[];let t=[],n=i=>{if(!x(i))return;let a=!1;try{a=!!r(i)}catch{a=!1}if(a&&t.push(R(i,"protected")),i.childNodes)for(let l of i.childNodes)n(l)};for(let i of e)n(i);return t}function R(e,r,t=null){let n=e;n&&n.nodeType!==1&&(n=n.parentElement);let i=n&&typeof n.closest=="function"?n.closest("[data-id]"):null;return!i&&t&&typeof t.closest=="function"&&(i=t.closest("[data-id]")),{id:(i?i.getAttribute("data-id"):null)||null,kind:r||null}}function gt(e,r,t=null){return(e||[]).filter(x).map(n=>R(n,r,t))}function J(e){return{replayable:!1,reason:e,steps:[]}}function Y(e,r){let t=[[r.afterAuthored,i=>i],[r.beforeAuthored,i=>i+1],[r.before,i=>i]],n=!1;for(let[i,a]of t){if(!x(i))continue;n=!0;let l=e.indexOf(O(i));if(l>=0)return a(l)}return n?null:e.length}function ht(e,r={}){let t=r.isIgnored||null,n=r.ignoreAttribute||null,i=lt(e),a=[];for(let h of i){if(!ft(h)){if(!x(h.target))return J("non-dom-target");continue}if(!x(h.parent))return J("non-dom-parent");let A=Array.from(h.nodes||[]).filter(x);if(A.length!==0){if(A.length!==Array.from(h.nodes||[]).length)return J("non-dom-node");a.push({primitive:h,nodes:A,parent:h.parent})}}if(yt(a))return J("in-record-move");let l=wt(a,t);if(!l)return J("ambiguous-structure");let s=bt(a,l),p=new Map(a.map(h=>[h.primitive,h])),b=[];for(let h of i){let A=p.get(h);if(!A){b.push(kt(h));continue}let E=s.get(A);if(E){E.at===A&&b.push(E.step);continue}b.push(vt(A,l.get(A),n,t))}return{replayable:!0,reason:null,steps:b}}function yt(e){let r=new Map;for(let t of e){let n=t.primitive.record;if(!n)continue;let i=r.get(n);i||(i=new Map,r.set(n,i));for(let a of t.nodes){let l=i.get(a);l||(l=new Set,i.set(a,l)),l.add(t.primitive.kind)}}for(let t of r.values())for(let n of t.values())if(n.size>1)return!0;return!1}function wt(e,r){let t=new Map;for(let i of e)t.has(i.parent)||t.set(i.parent,Ee(i.parent,r));let n=new Map;for(let i=e.length-1;i>=0;i--){let a=e[i],l=t.get(a.parent);if(!l)return null;let s=l.slice(),p;if(a.primitive.kind==="add"){let b=a.nodes.map(O);if(!b.every(h=>l.includes(h)))return null;p=l.filter(h=>!b.includes(h))}else{let b=Y(s,a.primitive);if(b==null)return null;p=s.slice(),p.splice(b,0,...a.nodes.map(O))}n.set(a,{before:p,after:s}),t.set(a.parent,p)}return n}function bt(e,r){let t=new Map,n=new Map;e.forEach((a,l)=>{for(let s of a.nodes){let p=O(s);a.primitive.kind==="remove"?t.set(p,{item:a,index:l,node:s}):n.set(p,{item:a,index:l,node:s})}});let i=new Map;for(let[a,l]of t){let s=n.get(a);if(!s||s.index<l.index||l.item.nodes.length!==1||s.item.nodes.length!==1)continue;let p={type:"move",node:l.node,sourceParent:l.item.parent,destParent:s.item.parent,source:r.get(l.item),dest:r.get(s.item),sourceSlot:l.item.primitive,destSlot:s.item.primitive,targets:[R(l.node,"move")]};i.set(l.item,{step:p,at:s.item}),i.set(s.item,{step:p,at:s.item})}return i}function vt(e,r,t,n){let i=e.primitive.kind;return{type:i==="add"?"add":"restore",parent:e.parent,nodes:e.nodes,seqBefore:r.before,seqAfter:r.after,slot:e.primitive,content:e.nodes.map(a=>H(a,t,e.parent,n)),ids:i==="remove"?e.nodes.flatMap(a=>oe(a)):[],targets:gt(e.nodes,i==="add"?"added":"removed",e.parent)}}function kt(e){return{type:e.kind,primitive:e,targets:[R(e.target,e.name||e.prop||"text")]}}function At(e,r,t={}){if(!e||!e.replayable)return{ok:!1,code:"unsupported",targets:[]};let n={isIgnored:t.isIgnored||null,ignoreAttribute:t.ignoreAttribute||null,isProtected:t.isProtected||null,inScope:t.inScope||(()=>!0),liveNodesWithIds:t.liveNodesWithIds||(()=>[]),sim:new Map,planned:new Map,operations:[]};for(let i=0;i<e.steps.length;i++){let a=e.steps[r==="undo"?e.steps.length-1-i:i],l=Et(a,r,n);if(l)return{ok:!1,code:l.code,targets:l.targets}}return{ok:!0,operations:n.operations}}function q(e,r){return e.sim.has(r)||e.sim.set(r,Ee(r,e.isIgnored)),e.sim.get(r)}function L(e,r){for(let t=e;t;t=t.parentNode)if(r.planned.has(t))return r.planned.get(t);return r.inScope(e)}function xe(e,r){return r.liveNodesWithIds(e).filter(t=>L(t,r)).length>0}function V(e,r){return{code:e,targets:r||[]}}function Vt(e){return e.kind==="text"?e.target.data:e.kind==="value"?typeof e.read=="function"?e.read(e.target):e.target[e.prop||"value"]:e.target.getAttribute(e.name)}function Et(e,r,t){let n=r==="undo";return e.type==="move"?St(e,n,t):e.type==="add"?xt(e,n,t):e.type==="restore"?Pt(e,n,t):Nt(e,n,t)}function Nt(e,r,t){let n=e.primitive,i=r?n.newValue:n.oldValue,a=r?n.oldValue:n.newValue;return x(n.target)?L(n.target,t)?n.kind==="value"&&typeof n.write=="function"&&typeof n.read!="function"?V("unsupported",e.targets):Vt(n)!==i?V("content-changed",e.targets):(n.kind==="value"?t.operations.push({type:"value",target:n.target,prop:n.prop||"value",value:a,read:n.read||null,write:n.write||null}):n.kind==="text"?t.operations.push({type:"text",target:n.target,data:a}):t.operations.push({type:"attr",target:n.target,name:n.name,value:a??null}),null):V("target-detached",e.targets):V("unsupported",e.targets)}function xt(e,r,t){if(!x(e.parent)||!L(e.parent,t))return V("target-detached",e.targets);if(r){if(!$(q(t,e.parent),e.seqAfter))return V("structure-changed",e.targets);let s=Ne(e.nodes,t.isProtected);if(s.length>0)return V("protected",s);for(let p=0;p<e.nodes.length;p++)if(H(e.nodes[p],t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[p])return V("content-changed",e.targets);for(let p of e.nodes)t.operations.push({type:"remove",node:p}),t.planned.set(p,!1);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!$(q(t,e.parent),e.seqBefore))return V("structure-changed",e.targets);for(let s of e.nodes)if(s.parentNode)return V("structure-changed",e.targets);let n=e.nodes.flatMap(s=>oe(s));if(n.length>0&&xe(n,t))return V("duplicate-id",e.targets);let i=Y(e.seqBefore,e.slot);if(i==null)return V("unsupported",e.targets);let a=e.seqBefore.slice(),l=i;for(let s of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:s,beforeId:a[l]??null}),a=a.slice(0,l).concat(O(s),a.slice(l)),l+=1,t.planned.set(s,!0);return t.sim.set(e.parent,e.seqAfter.slice()),null}function Pt(e,r,t){if(!x(e.parent)||!L(e.parent,t))return V("target-detached",e.targets);if(r){if(!$(q(t,e.parent),e.seqAfter))return V("structure-changed",e.targets);for(let p=0;p<e.nodes.length;p++){let b=e.nodes[p];if(b.parentNode||H(b,t.ignoreAttribute,e.parent,t.isIgnored)!==e.content[p])return V("content-changed",e.targets)}if(e.ids.length>0&&xe(e.ids,t))return V("duplicate-id",e.targets);let a=Y(e.seqAfter,e.slot);if(a==null)return V("unsupported",e.targets);let l=e.seqAfter.slice(),s=a;for(let p of e.nodes)t.operations.push({type:"insert",parent:e.parent,node:p,beforeId:l[s]??null}),l=l.slice(0,s).concat(O(p),l.slice(s)),s+=1,t.planned.set(p,!0);return t.sim.set(e.parent,e.seqBefore.slice()),null}if(!$(q(t,e.parent),e.seqBefore))return V("structure-changed",e.targets);let n=Ne(e.nodes,t.isProtected);if(n.length>0)return V("protected",n);let i=a=>t.planned.get(a)===!0||typeof t.isIgnored=="function"&&t.isIgnored(a);for(let a=0;a<e.nodes.length;a++){let l=e.nodes[a];if(l.parentNode!==e.parent||H(l,t.ignoreAttribute,e.parent,i)!==e.content[a])return V("content-changed",e.targets)}for(let a of e.nodes)t.operations.push({type:"remove",node:a}),t.planned.set(a,!1);return t.sim.set(e.parent,e.seqAfter.slice()),null}function It(e,r){let t=e.indexOf(r);return t<0?null:e.slice(0,t).concat(e.slice(t+1))}function St(e,r,t){let n=O(e.node),i=r?e.destParent:e.sourceParent,a=r?e.sourceParent:e.destParent,l=q(t,i),s=q(t,a),p=r?e.dest.after:e.source.before,b=r?e.source.after:e.dest.before,h=r?e.sourceSlot:e.destSlot;if(!x(i)||!x(a)||!L(i,t)||!L(a,t))return V("target-detached",e.targets);if(!$(l,p))return V("structure-changed",e.targets);let A=i===a?It(s,n):s;if(!$(A,b))return V("structure-changed",e.targets);let E=Y(b,h);return E==null?V("unsupported",e.targets):(t.operations.push({type:"insert",parent:a,node:e.node,beforeId:b[E]??null}),t.planned.set(e.node,!0),r?(t.sim.set(a,e.source.before.slice()),i!==a&&t.sim.set(i,e.dest.before.slice())):(t.sim.set(a,e.dest.after.slice()),i!==a&&t.sim.set(i,e.source.after.slice())),null)}function $(e,r){if(!e||!r||e.length!==r.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==r[t])return!1;return!0}function Rt(e,r){for(let t of e.childNodes||[])if(O(t)===r)return t;return null}function Pe(e,r){typeof e.write=="function"?e.write(e.target,r):e.target[e.prop]=r}function Ct(e){let r=[];try{for(let t of e)Ot(t,r);return{ok:!0}}catch(t){for(let n=r.length-1;n>=0;n--)try{r[n]()}catch{}return{ok:!1,error:t}}}function Ot(e,r){if(e.type==="attr"){let t=e.target.getAttribute(e.name);e.value==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,e.value),r.push(()=>{t==null?e.target.removeAttribute(e.name):e.target.setAttribute(e.name,t)});return}if(e.type==="text"){let t=e.target.data;e.target.data=e.data,r.push(()=>{e.target.data=t});return}if(e.type==="value"){let t=typeof e.read=="function"?e.read(e.target):e.target[e.prop];Pe(e,e.value),r.push(()=>Pe(e,t));return}if(e.type==="insert"){let t=e.beforeId==null?null:Rt(e.parent,e.beforeId);if(e.beforeId!=null&&!t)throw new Error("hyper-undo: replay anchor vanished");let n=e.node.parentNode,i=e.node.nextSibling;e.parent.insertBefore(e.node,t),r.push(()=>{n?n.insertBefore(e.node,i&&i.parentNode===n?i:null):e.node.parentNode===e.parent&&e.parent.removeChild(e.node)});return}if(e.type==="remove"){let t=e.node.parentNode;if(!t)throw new Error("hyper-undo: replay target is no longer attached");let n=e.node.nextSibling;t.removeChild(e.node),r.push(()=>t.insertBefore(e.node,n))}}var Mt=['[src^="chrome-extension://"]','[href^="chrome-extension://"]','[src^="moz-extension://"]','[href^="moz-extension://"]','[src^="safari-web-extension://"]','[href^="safari-web-extension://"]','[id="1p-menu-live-region"]',"com-1password-button","com-1password-menu","com-1password-notification","grammarly-extension","grammarly-desktop-integration","lt-div","lt-card","lt-toolbar","lt-highlighter","[data-lastpass-root]","[data-lastpass-icon-root]","[data-dashlane-shadowhost]","[data-klarna-extension]",'[class*="klarna-extension"]',".skiptranslate","#goog-gt-tt",".goog-te-banner-frame",".goog-te-balloon-frame","style.darkreader","style[data-darkreader-mode]","style[data-darkreader-scheme]","#loom-companion-mv3","loom-container","[ext-id]"],Tt=["data-grammarly","data-lt","data-1p","data-com-onepassword","data-lastpass","data-lp","data-kwimpala","data-bitwarden","data-bw","data-dashlane","data-np","data-protonpass","data-proton-pass","data-keeper","data-rf","data-roboform","data-honey","data-rakuten","data-capital-one","data-wikibuy","data-klarna","data-darkreader","data-evernote","data-pocket","data-pin"],jt=Mt.join(","),qt=new RegExp("^(?:"+Tt.join("|")+")(?:-|$)"),zr=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Lt=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),$t=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function ie(e,r){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(r)||e.hasAttribute?.(r))}function Ie(e,r){if(ie(e,r))return!0;for(let[t,n]of Object.entries(Lt))if(n.includes(r)&&ie(e,t))return!0;return!1}function Kt(e){return e==="clay"||$t.includes(e)}var zt=["mutations-ignore","save-remove","save-ignore","save-freeze","no-undo","no-watch"];function Dt(){if(typeof window>"u")return null;let e=window.clay?.region||window.hyperclay?.region;return e&&typeof e.resolveRegionPolicy=="function"?e.resolveRegionPolicy:null}function ae(e){let r=Dt();if(r)try{if(!r(e).undoable)return!0}catch{}let t=e&&e.nodeType!==1?e.parentElement:e;if(t&&t.closest&&t.closest(jt))return!0;for(;t&&t.nodeType===1;){if(Ie(t,"no-undo")||Ie(t,"no-watch"))return!0;for(let n of zt)if(ie(t,n))return!0;t=t.parentElement}return!1}function _t(e){let r=e.target,t=r.cloneNode(!1),n=t;for(;r.parentElement;){r=r.parentElement;let i=r.cloneNode(!1);i.appendChild(t),t=i}return e.oldValue==null?n.removeAttribute(e.attributeName):n.setAttribute(e.attributeName,e.oldValue),ae(n)}function ue(e,r,t){if(t?.type==="attributes"&&Kt(t.attributeName)){if(ae(e)&&_t(t))return!0}else if(ae(e))return!0;if(t&&t.type==="attributes"){if(t.attributeName&&qt.test(t.attributeName.toLowerCase()))return!0;if(r)try{if(r(t.attributeName,t.target))return!0}catch{}}return!1}function Ut(){let e=new Map;function r(i,a){let l=e.get(i);return l||(l=new Set,e.set(i,l)),l.add(a),()=>t(i,a)}function t(i,a){let l=e.get(i);l&&l.delete(a)}function n(i,a){let l=e.get(i);if(l)for(let s of Array.from(l))try{s(a)}catch(p){console.error("[hyper-undo] listener threw",p)}}return{on:r,off:t,emit:n}}var Bt={maxHistory:100,idleWindowMs:500,idleLabel:"Edit",recording:"automatic",ignoreAttribute:null,isProtected:null,ignoreNode:null,debug:!1};function Se(e){let r={...Bt,...e};if(!r.scope)throw new Error("hyper-undo: scope is required");let t=Ut(),n=[],i=[],a=`u${Math.random().toString(36).slice(2,8)}`,l=0,s=null,p=[],b=null,h=null,A=0,E=!1,K=r.recording==="commands"?"commands":"automatic",I=null,z=!1;function P(...o){r.debug&&console.log("[hyper-undo]",...o)}function Gt(){E||(E=!0,h=Yt(D),h.observe(r.scope,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),P("started"))}function Yt(o){let u=typeof document<"u"&&r.scope===document.body,c=typeof window<"u"&&(window.clay?.Mutation||window.hyperclay?.Mutation)||null;return u&&c&&typeof c.createObserver=="function"?(P("sourcing records from the platform Mutation hub (shared observer)"),c.createObserver(o)):new MutationObserver(o)}function Me(){E&&(E=!1,h&&(h.disconnect(),h=null),_(),n.length=0,i.length=0,p=[],s=null,I=null,z=!1,A=0,P("stopped"))}function Zt(){let o=r.scope;return!!(o&&o.nodeType===1&&o.isConnected===!1)}function D(o){Te(o,!1)}function Te(o,u){if(I){for(let m of o)I.records.push(m);return}if(K==="commands"||A>0)return;let c=ce(Qt(o),u);if(c.length>0){for(let m of c)p.push(m);je()}}function Qt(o){return typeof r.ignoreNode!="function"?o:o.filter(u=>{if(u.type!=="childList")return!0;let c=[...u.addedNodes,...u.removedNodes];return c.length===0?!0:!c.every(m=>er(m))})}function er(o){try{return!!r.ignoreNode(o)}catch{return!1}}function ce(o,u=!1){let c=yr(o),m=o.filter(y=>(ge(y.target)||c(y.target)||u&&Fe(y.target))&&!ue(y.target,r.ignoreAttribute,y));return ut(m,y=>ue(y,r.ignoreAttribute))}function je(){_(),b=setTimeout(qe,r.idleWindowMs)}function _(){b!=null&&(clearTimeout(b),b=null)}function qe(){if(b=null,p.length===0)return;let o=p;p=[],Z(r.idleLabel,o)}function Z(o,u){let c=ht(u,{isIgnored:fe,ignoreAttribute:Le});if(c.steps.length===0)return P("commit",o,"with nothing to record"),t.emit("commit"),null;let m={id:`${a}-${++l}`,label:o,timestamp:Date.now(),primitives:u,certificate:c};for(n.push(m),i.length=0,s=null;n.length>r.maxHistory;)n.shift();return P("commit",o,"primitives:",u.length),t.emit("commit"),m}function fe(o){return ue(o,r.ignoreAttribute)}function Le(o,u,c=null){if(typeof r.ignoreAttribute!="function")return!1;try{return!!r.ignoreAttribute(o,u,c)}catch{return!1}}function tr(o){if(typeof r.isProtected!="function")return!1;try{return!!r.isProtected(o)}catch{return!1}}function rr(o,u){if(!E)throw new Error("hyper-undo: scope not started");if(K==="commands")return ze(o,u,{honorPause:!0,receipt:!1});D(h.takeRecords()),U();let c=A===0?$e():null,m=u();if(m&&typeof m.then=="function")throw new Error("hyper-undo: commit() fn must be synchronous; returned a Promise");if(Te(h.takeRecords(),!0),c!=null&&Ke(c),p.length===0){t.emit("commit");return}_();let y=p;p=[],Z(o,y)}function nr(o){if(!E)throw new Error("hyper-undo: scope not started");if(!h)return;if(A>1){h.takeRecords();return}U();let u=ce(h.takeRecords(),!0);u.length!==0&&(_(),Z(o,u))}function or(){h&&h.takeRecords()}function pe(){let o=r.scope;return o&&o.ownerDocument||(typeof document<"u"?document:null)}function Q(){let o=pe();return!o||!o.head||typeof o.head.querySelector!="function"?null:o.head.querySelector("title")}function $e(){let o=Q();return o?o.textContent:null}function Ke(o){let u=Q();if(!u||o==null)return;let c=u.textContent;c!==o&&_e({kind:"value",target:u,prop:"textContent",oldValue:o,newValue:c})}function ir(o){if(!o)return null;let u=pe();if(!u||o.target!==u||o.prop!=="title")return o;let c=Q();return c?{kind:"value",target:c,prop:"textContent",oldValue:o.oldValue,newValue:o.newValue}:null}function ar(){if(typeof window>"u")return!1;let o=window.clay?.effect||window.hyperclay?.effect;return!!(o&&o.running)}function ur(){h&&D(h.takeRecords()),U(),I={records:[],primitives:[]}}function lr(){let o=I;if(I=null,!o)return[];let u=ce(o.records,!0);for(let c of o.primitives)u.push(c);return u}function ze(o,u,{honorPause:c,receipt:m}){if(typeof u!="function")throw new Error("hyper-undo: command() needs a synchronous function");if(I)throw new Error("hyper-undo: command() cannot nest inside another command");if(z)throw new Error("hyper-undo: command() cannot run during undo or redo");if(ar())throw new Error("hyper-undo: command() cannot run inside a derived-effect context");if(u.constructor&&u.constructor.name==="AsyncFunction")throw new Error("hyper-undo: command() fn must be synchronous; it was declared async");let y=c&&A>0,S=y?null:$e();ur();let M=[],j=null,B;try{try{B=u()}catch(kr){j=kr}if(h&&D(h.takeRecords()),B&&typeof B.then=="function"){try{B.then(void 0,()=>{})}catch{}j||(j=new Error("hyper-undo: command() fn must be synchronous; returned a Promise"))}y||Ke(S)}finally{M=lr()}let ee=y||M.length===0?null:Z(o,M);if(j)throw j;return m?ee?{id:ee.id,label:ee.label}:null:ee}function dr(o,u){if(!E)throw new Error("hyper-undo: scope not started");return ze(o,u,{honorPause:!1,receipt:!0})}function sr(o){if(o!=="automatic"&&o!=="commands")throw new Error("hyper-undo: setRecording() takes 'automatic' or 'commands'");if(I)throw new Error("hyper-undo: setRecording() cannot change while a command is running");return K===o||(U(),K=o,P("recording",o)),K}function De(o){if(!E||!o||!I&&(A>0||K==="commands"))return;let u=ir(o);u&&_e(u)}function _e(o){if(I){I.primitives.push(o);return}p.push(o),je()}function cr(o,{prop:u="value",oldValue:c,newValue:m,read:y,write:S}={}){!o||c===m||De({kind:"value",target:o,prop:u,oldValue:c,newValue:m,read:y,write:S})}function U(){A===0&&h&&D(h.takeRecords()),p.length!==0&&(_(),qe())}function Ue(){A===0&&h&&D(h.takeRecords()),A++,P("paused",A)}function Be(){A!==0&&(A--,A===0&&h&&h.takeRecords(),P("resumed",A))}function We(o,u){if(Zt())return Me(),{ok:!1,code:"disconnected"};U();let c=o==="undo"?n:i,m=o==="undo"?i:n,y=c.at(-1);if(!y)return{ok:!1,code:"empty"};if(u&&u!==y.id){let B=He(u)||y;return me(B,o,"stale-entry")}let S;z=!0;try{S=At(y.certificate,o,{isIgnored:fe,ignoreAttribute:Le,isProtected:tr,inScope:wr,liveNodesWithIds:br})}finally{z=!1}if(!S.ok)return me(y,o,S.code,S.targets);Ue();let M;z=!0;try{M=Ct(S.operations)}finally{z=!1,Be()}if(!M.ok)return P(`${o} failed and was rolled back`,M.error),me(y,o,"replay-error");c.pop(),m.push(y),s=null;let j={ok:!0,entryId:y.id,label:y.label,direction:o};return P(o,y.label),t.emit(o,j),j}function fr(o){return We("undo",o&&o.entryId)}function pr(o){return We("redo",o&&o.entryId)}function He(o){return n.find(u=>u.id===o)||i.find(u=>u.id===o)||null}function me(o,u,c,m=[]){return s={entryId:o.id,direction:u,code:c,targets:m},P("refused",u,c),t.emit("refused",{entryId:o.id,label:o.label,direction:u,code:c,targets:m}),{ok:!1,code:c,entryId:o.id,label:o.label,direction:u}}function mr(o){if(!s||s.entryId!==o)return{ok:!1,code:"not-refused",entryId:o};let u=s.direction,c=u==="undo"?n:i,m=c.at(-1);return!m||m.id!==o?{ok:!1,code:"stale-entry",entryId:o}:(c.pop(),s=null,P("discarded",m.label),t.emit("discard",{entryId:o,label:m.label,direction:u}),{ok:!0,entryId:o,direction:u})}function gr(o){let u=He(o);if(!u||!u.certificate||!u.certificate.replayable)return null;let c=s&&s.entryId===u.id?{direction:s.direction,code:s.code,targets:(s.targets||[]).map(m=>({id:m.id??null,kind:m.kind??null}))}:null;return{id:u.id,label:u.label,timestamp:u.timestamp,refused:c,steps:u.certificate.steps.map(hr)}}function hr(o){if(o.type==="move")return{kind:"move",node:{id:R(o.node).id},from:{id:R(o.sourceParent).id},to:{id:R(o.destParent).id}};if(o.type==="add"||o.type==="restore")return{kind:o.type==="add"?"add":"remove",parent:{id:R(o.parent).id},nodes:o.nodes.map((S,M)=>({id:R(S).id,html:o.content[M]??null}))};let u=o.primitive,c={id:R(u.target).id},m=u.oldValue??null,y=u.newValue??null;return o.type==="value"?{kind:"value",target:c,prop:u.prop??"value",before:m,after:y}:o.type==="text"?{kind:"text",target:c,before:m,after:y}:o.type==="attr-set"||o.type==="attr-add"||o.type==="attr-remove"?{kind:"attribute",target:c,name:u.name??null,before:m,after:y}:{kind:o.type,target:c,before:m,after:y}}function yr(o){let u=new Set,c=!0;for(;c;){c=!1;for(let m of o)if(!(m.type!=="childList"||!m.removedNodes?.length)&&!(!ge(m.target)&&!Je(m.target,u)))for(let y of m.removedNodes)u.has(y)||(u.add(y),c=!0)}return m=>!ge(m)&&Je(m,u)}function Je(o,u){for(let c=o;c;c=c.parentNode)if(u.has(c))return!0;return!1}function ge(o){let u=r.scope;return!u||!o?!1:o===u||typeof u.contains=="function"&&u.contains(o)}function Fe(o){let u=pe(),c=u&&u.head;if(!c||!o)return!1;let m=o.nodeType===1?o:o.parentElement;for(;m&&m!==c;m=m.parentElement)if(m.localName==="title")return!1;return m===c}function wr(o){let u=r.scope;return!o||!u?!1:o===u||Q()===o||Fe(o)?!0:typeof u.contains=="function"?u.contains(o):!1}function br(o){let u=r.scope;if(!o||o.length===0||typeof u?.querySelectorAll!="function")return[];let c=new Set(o),m=[];for(let y of u.querySelectorAll("[data-id]"))c.has(y.getAttribute("data-id"))&&(fe(y)||m.push(y));return m}function vr(){h&&h.takeRecords(),n.length=0,i.length=0,p=[],s=null,_(),P("cleared"),t.emit("clear")}return{_config:r,start:Gt,stop:Me,commit:rr,commitCaptured:nr,discardCaptured:or,flush:U,command:dr,setRecording:sr,record:De,recordValue:cr,undo:fr,redo:pr,clear:vr,discard:mr,describe:gr,pause:Ue,resume:Be,on:t.on,off:t.off,get canUndo(){return n.length>0},get canRedo(){return i.length>0},get isPaused(){return A>0},get history(){return n.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return s&&s.entryId===o.id&&(u.refused={direction:s.direction,code:s.code,targets:s.targets}),u})},get future(){return i.map(o=>{let u={id:o.id,label:o.label,timestamp:o.timestamp};return s&&s.entryId===o.id&&(u.refused={direction:s.direction,code:s.code,targets:s.targets}),u}).reverse()},get scope(){return r.scope}}}var Wt=new Set(["checkbox","radio","button","submit","reset","image","file","range","color"]);function Ht(e){let r=typeof e.composedPath=="function"?e.composedPath():[],t=r.length>0?r:Jt(e.target);for(let n of t){if(!n||n.nodeType!==1)continue;let i=String(n.tagName||"").toUpperCase();if(i==="TEXTAREA"||i==="SELECT"||i==="INPUT"&&!Wt.has(String(n.type||n.getAttribute?.("type")||"text").toLowerCase())||n.isContentEditable===!0)return!0;let a=n.getAttribute&&n.getAttribute("contenteditable");if(a!=null&&String(a).toLowerCase()!=="false")return!0}return!1}function Jt(e){let r=[];for(let t=e;t;t=t.parentNode||(t.host??null))r.push(t);return r}function Ft(e,r){let t=n=>{let i=e.scope;if(i&&i.nodeType===1&&i.isConnected===!1){r&&r();return}if(n.defaultPrevented||n.isComposing||n.keyCode===229||Ht(n))return;let a=n.target,l=e._config.shadowKeydownIn;if(a&&a.closest&&Array.isArray(l))for(let p of l)try{if(a.closest(p))return}catch{}if(!(n.metaKey||n.ctrlKey))return;let s=(n.key||"").toLowerCase();if(s==="z"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),e.undo();return}if(s==="z"&&n.shiftKey){n.preventDefault(),n.stopPropagation(),e.redo();return}if(s==="y"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),e.redo();return}};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)}var le=[".CodeMirror",".cm-editor",".monaco-editor",".ace_editor",".ql-editor",".tiptap",".ProseMirror",".overtype-input","[data-richclay-active]"],g=null,de=null,Re=null,T=null;function Ce(e,r){if(T){if(T.inst===e)return T.cleanup;throw new Error("hyper-undo: another scope already owns the global Cmd+Z binding (bindKeys: true). Stop it first, or use bindKeys: false for additional scopes.")}let t=Ft(e,r);return T={inst:e,cleanup:t},t}function Oe(e){T&&T.inst===e&&(T.cleanup(),T=null)}var se={defaults:{shadowKeydownIn:le},start(e={}){let r=e.scope||(typeof document<"u"?document.body:null);if(!r)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");if(g){if(de===r)return console.warn("[hyper-undo] start() called again on existing singleton; ignoring new options"),g;throw new Error("hyper-undo: start() called with a different scope while the singleton is already started. Use undo.create({ scope }) for additional scopes, or call undo.stop() first.")}let t={...e,scope:r,shadowKeydownIn:e.shadowKeydownIn||le};return g=Se(t),g.start(),de=r,e.bindKeys!==!1&&(Re=Ce(g,()=>se.stop())),g},stop(){g&&(Oe(g),Re=null,g.stop(),g=null,de=null)},create(e={}){let r=e.scope||(typeof document<"u"?document.body:null);if(!r)throw new Error("hyper-undo: no scope (need document.body or explicit { scope })");let t={...e,scope:r,shadowKeydownIn:e.shadowKeydownIn||le},n=Se(t),i=null,a={_config:n._config,commit:n.commit,command:n.command,setRecording:n.setRecording,commitCaptured:n.commitCaptured,discardCaptured:n.discardCaptured,flush:n.flush,record:n.record,recordValue:n.recordValue,undo:n.undo,redo:n.redo,clear:n.clear,discard:n.discard,describe:n.describe,pause:n.pause,resume:n.resume,on:n.on,off:n.off,get canUndo(){return n.canUndo},get canRedo(){return n.canRedo},get isPaused(){return n.isPaused},get history(){return n.history},get future(){return n.future},get scope(){return n.scope},start(){e.bindKeys&&(i=Ce(n,()=>a.stop())),n.start()},stop(){Oe(n),i=null,n.stop()}};return a},commit(e,r){return g?g.commit(e,r):void 0},command(e,r){return g?g.command(e,r):void 0},setRecording(e){return g?g.setRecording(e):void 0},commitCaptured(e){return g?g.commitCaptured(e):void 0},discardCaptured(){return g?g.discardCaptured():void 0},record(e){return g?g.record(e):void 0},recordValue(e,r){return g?g.recordValue(e,r):void 0},undo(e){return g?g.undo(e):void 0},redo(e){return g?g.redo(e):void 0},clear(){return g?g.clear():void 0},discard(e){return g?g.discard(e):void 0},describe(e){return g?g.describe(e):void 0},pause(){return g?g.pause():void 0},resume(){return g?g.resume():void 0},flush(){return g?g.flush():void 0},on(e,r){return g?g.on(e,r):void 0},off(e,r){return g?g.off(e,r):void 0},get canUndo(){return g?g.canUndo:!1},get canRedo(){return g?g.canRedo:!1},get history(){return g?g.history:[]},get future(){return g?g.future:[]},get isPaused(){return g?g.isPaused:!1}},Xt=se;return X(C)})();window.__hyperclayNoAutoExport||(window.hyperclay=window.hyperclay||{},window.hyperclay.undo=et.undo,window.h=window.hyperclay);var w=et.undo;var ye=new Set,it=(d={})=>{let f=d.ignoreAttribute;return{...d,ignoreAttribute:(k,v,N)=>ye.has(k)||Xe(k,v)||Ye(v,k,N)||Ze(k,v)||(f?f(k,v,N):!1),isProtected:d.isProtected||Ar,ignoreNode:d.ignoreNode||Qe}};function Ar(d){let f=window.clay?.region?.resolveRegionPolicy;if(!f||d.nodeType!==1)return!1;let k=f(d);if(k.undoable!==!1||k.persist==="none")return!1;let v=d.parentElement;return!v||f(v).undoable!==!1}var Vr=w.create.bind(w);w.create=d=>Vr(it(d));var we=null,Er=w.setRecording.bind(w);w.setRecording=d=>(we=d??null,Er(d));var tt=()=>w.history.at(-1)?.id??null,Nr=w.command.bind(w);w.command=(d,f)=>{let k=Nr(d,f);return k&&re(),k};var xr=w.commit.bind(w),rt=!1;w.commit=(d,f)=>{!rt&&window.clay?.effect?.running&&(rt=!0,console.warn(`clay.effect: undo.commit("${d}") was called inside an effect. Run commands from event handlers, not from an effect.`));let k=tt(),v=xr(d,f);return(v||tt()!==k)&&re(),v};var Pr=`input${te}:not([type="password"]):not([type="hidden"]):not([type="file"]), textarea${te}, select${te}`;function Ir(){let d=f=>window.clay?.region?.resolveRegionPolicy?.(f)?.undoable!==!1;document.querySelectorAll(Pr).forEach(f=>{if(!d(f))return;if(f.tagName==="SELECT"){for(let C of f.options){let G=C.hasAttribute("selected");C.selected!==G&&(C.selected=G)}return}let k=(f.getAttribute("type")||"text").toLowerCase();if(f.tagName==="INPUT"&&(k==="checkbox"||k==="radio")){let C=f.hasAttribute("checked");f.checked!==C&&(f.checked=C);return}let v=f.tagName==="TEXTAREA"?f.getAttribute("data-value")??f.textContent:f.getAttribute("value")??"";if(f.value===v)return;let N=f===document.activeElement,W,X;try{W=f.selectionStart,X=f.selectionEnd}catch{}if(f.value=v,N&&W!=null)try{f.setSelectionRange(Math.min(W,v.length),Math.min(X,v.length))}catch{}})}var nt=d=>{d?.ok&&(re(),Ir())},ot=({entryId:d,label:f,direction:k,code:v})=>{document.dispatchEvent(new CustomEvent("clay:undo-refused",{detail:{ok:!1,code:v,entryId:d,label:f,direction:k}})),Sr({ok:!1,code:v,entryId:d,label:f,direction:k})},he=null;function at(){return he??=import("../c-V5L6HWVL.js").catch(d=>(he=null,console.error("clayjs: the undo recovery module could not be downloaded; a refused step stays in this tab only",d),null)),he}async function Sr(d){let f={ok:!1,code:"unavailable"};try{let v=await at();v&&(f=await v.keepRefusal(w,d))}catch{f={ok:!1,code:"error"}}let k=f?.ok===!0?{ok:!0,entryId:d.entryId,direction:d.direction}:{ok:!1,code:f?.code||"error",entryId:d.entryId,direction:d.direction};document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:k}))}var ve=(d,f)=>(...k)=>at().then(v=>v?v[d](...k):f,()=>f),Rr=ve("keep",{ok:!1,code:"unavailable"});w.ignoreAttribute=d=>{let f=String(d||"");return f?(ye.add(f),()=>{ye.delete(f)}):()=>{}};w.keep=async d=>{let f=await Rr(d);return f?.ok===!0&&document.dispatchEvent(new CustomEvent("clay:undo-kept",{detail:{ok:!0,key:d?.key==null?null:`app:${d.key}`}})),f};w.kept=ve("kept",{ok:!1,code:"unavailable",records:[]});w.dismissKept=ve("dismissKept",{ok:!1,code:"unavailable"});var be=new Set;w.reviewActions=d=>typeof d!="function"?()=>{}:(be.add(d),()=>{be.delete(d)});w.reviewActionsFor=d=>{let f=[];for(let k of be){let v;try{v=k(d)}catch(N){console.error("clayjs: a review action could not describe itself; the copy stays reviewable",N);continue}for(let N of Array.isArray(v)?v:[])N&&typeof N.run=="function"&&N.label&&f.push(N)}return f};var Cr=["commit","undo","redo","refused","discard","clear"],ne=()=>{let d=!!F?.started;document.dispatchEvent(new CustomEvent("clay:undo-change",{detail:{canUndo:d&&w.canUndo,canRedo:d&&w.canRedo,undo:d&&w.history.at(-1)||null,redo:d&&w.future?.[0]||null}}))},F=null;function Or(){return{started:!1,admitted:!1,subscriptions:[]}}var Mr=d=>d?d.signal?.aborted?!0:typeof d.isCurrent=="function"&&!d.isCurrent():!1;function Tr(){return typeof document>"u"||document.readyState!=="loading"?Promise.resolve():new Promise(d=>document.addEventListener("DOMContentLoaded",d,{once:!0}))}function jr(d){return{enable(){if(!d.started){d.started=!0,d.admitted=!0,w.start(it({bindKeys:!0,...we?{recording:we}:{}}));for(let f of["undo","redo"])w.on(f,nt),d.subscriptions.push({type:f,handler:nt});w.on("refused",ot),d.subscriptions.push({type:"refused",handler:ot});for(let f of Cr)w.on(f,ne),d.subscriptions.push({type:f,handler:ne});ne()}},quiesce(){d.admitted&&(d.admitted=!1,w.pause())},resume(){d.admitted||(d.admitted=!0,w.resume())},dispose(){if(d.admitted=!1,F===d&&(F=null),!!d.started){d.started=!1;for(let{type:f,handler:k}of d.subscriptions.splice(0))w.off(f,k);w.stop(),ne()}}}}function qr(){return{id:"clay:undo",order:350,async prepare(d={}){if(d.initial===!0)return Lr();if(await Tr(),Mr(d))throw Object.assign(new Error("clay:undo prepared for a stale generation"),{code:"stale-document"});return jr(F||(F=Or()))}}}async function Lr(){let d=await Kr;return{enable(){},quiesce:()=>d?.quiesce(),resume:()=>d?.resume(),dispose:()=>d?.dispose()}}async function $r(){if(!Ge()||typeof document>"u")return null;let d=await qr().prepare();return d.enable(),d}var Kr=$r();var Gr=w;export{Gr as default,$r as init,qr as modeParticipant,Kr as ready,Ir as restoreControls,w as undo,qr as undoParticipant};
|